"use strict";(()=>{var e={};e.id=5501,e.ids=[5501,2331],e.modules={53524:e=>{e.exports=require("@prisma/client")},20399:e=>{e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},30517:e=>{e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},49413:(e,a,t)=>{t.r(a),t.d(a,{originalPathname:()=>h,patchFetch:()=>T,requestAsyncStorage:()=>p,routeModule:()=>u,serverHooks:()=>c,staticGenerationAsyncStorage:()=>l});var r={};t.r(r),t.d(r,{GET:()=>d});var s=t(49303),o=t(88716),i=t(60670),m=t(87070),n=t(72331);async function d(e){try{let e=new Date,a=new Date(e);a.setHours(0,0,0,0);let t=new Date(e);t.setHours(23,59,59,999);let r=new Date(e);r.setDate(r.getDate()-7),e.getFullYear(),e.getMonth();let[s,o,i,d,u,p,l,c,h,T,w,y]=await Promise.all([n.prisma.user.count(),n.prisma.user.count({where:{createdAt:{gte:r}}}),n.prisma.user.count({where:{premiumTier:{not:"free"}}}),n.prisma.user.count({where:{premiumTier:{not:"free"},updatedAt:{gte:r}}}),n.prisma.prediction.count({where:{createdAt:{gte:a,lte:t}}}),n.prisma.prediction.count({where:{createdAt:{gte:new Date(a.getTime()-864e5),lt:a}}}),n.prisma.match.findMany({where:{kickoffAt:{gte:a,lte:t}},include:{league:!0},orderBy:{kickoffAt:"asc"},take:5}),n.prisma.supportTicket.count({where:{status:"open"}}),n.prisma.supportTicket.count({where:{status:"in_progress"}}),n.prisma.supportTicket.count({where:{status:"resolved",resolvedAt:{gte:a,lte:t}}}),n.prisma.redemptionOrder.count({where:{createdAt:{gte:a,lte:t}}}),n.prisma.auditLog.findMany({orderBy:{createdAt:"desc"},take:6,include:{user:{select:{userId:!0}}}})]),g=Array.from(new Set(l.flatMap(e=>["club"===e.homeTeamType?e.homeTeamId:null,"club"===e.awayTeamType?e.awayTeamId:null]).filter(e=>null!==e))),f=Array.from(new Set(l.flatMap(e=>["club"!==e.homeTeamType?e.homeTeamId:null,"club"!==e.awayTeamType?e.awayTeamId:null]).filter(e=>null!==e))),[A,b]=await Promise.all([g.length?n.prisma.club.findMany({where:{id:{in:g}},select:{id:!0,name:!0}}):Promise.resolve([]),f.length?n.prisma.team.findMany({where:{id:{in:f}},select:{id:!0,name:!0}}):Promise.resolve([])]),k=new Map(A.map(e=>[e.id,e.name])),v=new Map(b.map(e=>[e.id,e.name])),x=(e,a,t)=>"club"===e?k.get(a)||t||`Tim ${a}`:v.get(a)||t||`Tim ${a}`,I=l.map(e=>({id:e.id,leagueName:e.league.name,leagueCode:e.league.code,homeTeamId:e.homeTeamId,awayTeamId:e.awayTeamId,homeTeamType:e.homeTeamType,awayTeamType:e.awayTeamType,homeTeamName:x(e.homeTeamType,e.homeTeamId,e.homeTeamName),awayTeamName:x(e.awayTeamType,e.awayTeamId,e.awayTeamName),kickoffAt:e.kickoffAt,status:e.status})),M=y.map(e=>({action:e.action,userId:e.user?.userId||null,createdAt:e.createdAt,metadata:e.metadata}));return m.NextResponse.json({success:!0,data:{stats:{totalUsers:s,newUsersThisWeek:o,premiumUsers:i,newPremiumThisWeek:d,todayPredictions:u,predictionChange:p>0?Math.round((u-p)/p*100):0,openTickets:c,inProgressTickets:h,resolvedTodayTickets:T,todayRedemptions:w},todayMatches:I,recentActivity:M}})}catch(e){return console.error("Admin dashboard error:",e),m.NextResponse.json({success:!1,message:"Gagal memuat data dashboard"},{status:500})}}let u=new s.AppRouteRouteModule({definition:{kind:o.x.APP_ROUTE,page:"/api/admin/dashboard/route",pathname:"/api/admin/dashboard",filename:"route",bundlePath:"app/api/admin/dashboard/route"},resolvedPagePath:"C:\\xampp\\htdocs\\Bolafest\\app\\api\\admin\\dashboard\\route.ts",nextConfigOutput:"standalone",userland:r}),{requestAsyncStorage:p,staticGenerationAsyncStorage:l,serverHooks:c}=u,h="/api/admin/dashboard/route";function T(){return(0,i.patchFetch)({serverHooks:c,staticGenerationAsyncStorage:l})}},72331:(e,a,t)=>{t.d(a,{prisma:()=>s});var r=t(53524);let s=globalThis.prisma??new r.PrismaClient({log:["error"]})}};var a=require("../../../../webpack-runtime.js");a.C(e);var t=e=>a(a.s=e),r=a.X(0,[9276,5972],()=>t(49413));module.exports=r})();