"use strict";(()=>{var e={};e.id=646,e.ids=[646],e.modules={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")},88177:(e,t,a)=>{a.r(t),a.d(t,{originalPathname:()=>T,patchFetch:()=>v,requestAsyncStorage:()=>m,routeModule:()=>c,serverHooks:()=>h,staticGenerationAsyncStorage:()=>f});var r={};a.r(r),a.d(r,{GET:()=>p});var i=a(49303),o=a(88716),n=a(60670),s=a(87070);let l=process.env.API_FOOTBALL_URL||"https://v3.football.api-sports.io",u=process.env.API_FOOTBALL_KEY||"e7d01e7cfe8207696d937b2381f7480a",d={NS:"upcoming",TBD:"upcoming","1H":"live",HT:"live","2H":"live",ET:"live",P:"live",BT:"live",LIVE:"live",FT:"finished",AET:"finished",PEN:"finished",PST:"postponed",CANC:"cancelled",ABD:"cancelled"},g=new Map;async function p(e){let{searchParams:t}=new URL(e.url),a=new Date(new Date().getTime()+252e5).toISOString().split("T")[0],r=t.get("tanggal")||a,i=`livescore-${r}`,o=g.get(i),n=Date.now();if(o){let e=o.hasLive?3e4:18e4;if(n-o.waktu<e)return s.NextResponse.json({sukses:!0,tanggal:r,total:o.data.length,data:o.data,sumber:"cache"})}let p=new Date(new Date(r+"T00:00:00Z").getTime()-252e5),c=[p.getUTCFullYear(),String(p.getUTCMonth()+1).padStart(2,"0"),String(p.getUTCDate()).padStart(2,"0")].join("-"),m=c!==r?[c,r]:[r],f=[],h=!1;await Promise.allSettled(m.map(async e=>{try{let t=`${l}/fixtures?date=${e}`,a=await fetch(t,{headers:{"x-apisports-key":u},cache:"no-store"});if(!a.ok)throw Error(`HTTP ${a.status}`);let r=await a.json();if(r.errors&&Object.keys(r.errors).length>0)throw Error(`API error: ${JSON.stringify(r.errors)}`);for(let e of r.response||[]){let t=new Date(e.fixture.date),a=new Date(t.getTime()+252e5),r=new Date(t.getTime()-864e5),i=d[e.fixture.status.short]||"upcoming";"live"===i&&(h=!0),f.push({id:String(e.fixture.id),ligaId:String(e.league.id),ligaNama:e.league.name,ligaLogo:e.league.logo,ligaPutaran:e.league.round,kandang:{id:e.teams.home.id,nama:e.teams.home.name,logo:e.teams.home.logo},tandang:{id:e.teams.away.id,nama:e.teams.away.name,logo:e.teams.away.logo},kickoffUTC:e.fixture.date,kickoffWIB:a.toISOString(),waktuWIB:a.toLocaleTimeString("id-ID",{hour:"2-digit",minute:"2-digit",timeZone:"UTC"}),tanggalWIB:a.toLocaleDateString("id-ID",{weekday:"short",day:"numeric",month:"short",timeZone:"UTC"}),status:i,statusKode:e.fixture.status.short,elapsedMinutes:e.fixture.status.elapsed??null,skorKandang:e.goals.home,skorTandang:e.goals.away,deadlinePrediksi:r.toISOString(),isPremium:!1,isFallback:!1,venue:e.fixture.venue?.name??null,kota:e.fixture.venue?.city??null})}}catch(t){console.error(`LiveScore API error (${e}):`,t)}}));let T=new Set,v=f.filter(e=>{if(T.has(e.id))return!1;T.add(e.id);let t=new Date(e.kickoffWIB);return[t.getUTCFullYear(),String(t.getUTCMonth()+1).padStart(2,"0"),String(t.getUTCDate()).padStart(2,"0")].join("-")===r}).sort((e,t)=>new Date(e.kickoffUTC).getTime()-new Date(t.kickoffUTC).getTime());return g.set(i,{data:v,waktu:n,hasLive:h}),s.NextResponse.json({sukses:!0,tanggal:r,total:v.length,data:v,sumber:v.length>0?"api":"api_kosong"})}let c=new i.AppRouteRouteModule({definition:{kind:o.x.APP_ROUTE,page:"/api/livescore/route",pathname:"/api/livescore",filename:"route",bundlePath:"app/api/livescore/route"},resolvedPagePath:"C:\\xampp\\htdocs\\Bolafest\\app\\api\\livescore\\route.ts",nextConfigOutput:"standalone",userland:r}),{requestAsyncStorage:m,staticGenerationAsyncStorage:f,serverHooks:h}=c,T="/api/livescore/route";function v(){return(0,n.patchFetch)({serverHooks:h,staticGenerationAsyncStorage:f})}}};var t=require("../../../webpack-runtime.js");t.C(e);var a=e=>t(t.s=e),r=t.X(0,[9276,5972],()=>a(88177));module.exports=r})();