"use strict";(()=>{var e={};e.id=7373,e.ids=[7373],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")},17988:(e,t,r)=>{r.r(t),r.d(t,{originalPathname:()=>h,patchFetch:()=>v,requestAsyncStorage:()=>c,routeModule:()=>p,serverHooks:()=>g,staticGenerationAsyncStorage:()=>m});var a={};r.r(a),r.d(a,{GET:()=>l,dynamic:()=>d});var s=r(49303),n=r(88716),o=r(60670),i=r(87070),u=r(13538);let d="force-dynamic";async function l(e){try{let{searchParams:t}=new URL(e.url),r=t.get("studentId");if(!r)return i.NextResponse.json({error:"Bad Request",message:"studentId is required"},{status:400});let a=await u.Z.student.findUnique({where:{id:r},select:{id:!0,name:!0,surname:!0,class:{select:{name:!0}}}});if(!a)return i.NextResponse.json({error:"Not Found",message:"Student not found"},{status:404});let s=new Date;s.setUTCHours(0,0,0,0),s.setDate(s.getDate()-30);let n=await u.Z.gateScan.findMany({where:{studentId:r,date:{gte:s}},select:{date:!0,status:!0,timestamp:!0,confidence:!0},orderBy:{date:"asc"}}),o=[],d=new Date;d.setUTCHours(0,0,0,0);for(let e=new Date(s);e<=d;e.setDate(e.getDate()+1)){let t=e.toISOString().split("T")[0],r=n.find(e=>e.date.toISOString().split("T")[0]===t),a=e.getDay();0!==a&&6!==a&&o.push({date:t,status:r?r.status:null,time:r?r.timestamp.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:!1}):null})}return i.NextResponse.json({student:{id:a.id,name:`${a.name} ${a.surname}`,className:a.class.name},history:o})}catch(e){return console.error("[AttendanceHistory] Error:",e),i.NextResponse.json({error:"Internal Server Error",message:String(e)},{status:500})}}let p=new s.AppRouteRouteModule({definition:{kind:n.x.APP_ROUTE,page:"/api/v1/attendance/history/route",pathname:"/api/v1/attendance/history",filename:"route",bundlePath:"app/api/v1/attendance/history/route"},resolvedPagePath:"C:\\School Management System\\Working\\V2\\src\\app\\api\\v1\\attendance\\history\\route.ts",nextConfigOutput:"standalone",userland:a}),{requestAsyncStorage:c,staticGenerationAsyncStorage:m,serverHooks:g}=p,h="/api/v1/attendance/history/route";function v(){return(0,o.patchFetch)({serverHooks:g,staticGenerationAsyncStorage:m})}},49303:(e,t,r)=>{e.exports=r(30517)},13538:(e,t,r)=>{r.d(t,{Z:()=>s});var a=r(53524);let s=globalThis.prisma??new a.PrismaClient({log:["error"],datasources:{db:{url:process.env.DATABASE_URL}}})}};var t=require("../../../../../webpack-runtime.js");t.C(e);var r=e=>t(t.s=e),a=t.X(0,[8948,7070],()=>r(17988));module.exports=a})();