"use strict";(()=>{var e={};e.id=1105,e.ids=[1105],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")},53014:(e,t,r)=>{r.r(t),r.d(t,{originalPathname:()=>g,patchFetch:()=>x,requestAsyncStorage:()=>m,routeModule:()=>p,serverHooks:()=>v,staticGenerationAsyncStorage:()=>c});var s={};r.r(s),r.d(s,{POST:()=>l,dynamic:()=>d});var n=r(49303),a=r(88716),o=r(60670),i=r(87070),u=r(13538);let d="force-dynamic";async function l(e){try{let t=e.headers.get("Authorization"),r=process.env.ATLAS_DEVICE_API_KEY;if(r&&(t?.startsWith("Bearer ")?t.slice(7):"")!==r)return i.NextResponse.json({error:"Unauthorized"},{status:401});let{code:s}=await e.json();if(!s)return i.NextResponse.json({error:"Bad Request",message:"code is required"},{status:400});let n=await u.Z.enrollmentToken.findUnique({where:{code:String(s)},include:{student:{select:{id:!0,name:!0,surname:!0,img:!0,class:{select:{name:!0}}}}}});if(!n)return i.NextResponse.json({error:"Invalid",message:"Token not found"},{status:404});if(n.used)return i.NextResponse.json({error:"Used",message:"Token has already been used"},{status:410});if(new Date>n.expiresAt)return i.NextResponse.json({error:"Expired",message:"Token has expired"},{status:410});return i.NextResponse.json({valid:!0,studentId:n.student.id,studentName:`${n.student.name} ${n.student.surname}`,className:n.student.class.name,img:n.student.img,expiresAt:n.expiresAt.toISOString()},{status:200})}catch(e){return console.error("[Enrollment Validate] Error:",e),i.NextResponse.json({error:"Internal Server Error",message:String(e)},{status:500})}}let p=new n.AppRouteRouteModule({definition:{kind:a.x.APP_ROUTE,page:"/api/v1/enrollment/validate/route",pathname:"/api/v1/enrollment/validate",filename:"route",bundlePath:"app/api/v1/enrollment/validate/route"},resolvedPagePath:"C:\\School Management System\\Working\\V2\\src\\app\\api\\v1\\enrollment\\validate\\route.ts",nextConfigOutput:"standalone",userland:s}),{requestAsyncStorage:m,staticGenerationAsyncStorage:c,serverHooks:v}=p,g="/api/v1/enrollment/validate/route";function x(){return(0,o.patchFetch)({serverHooks:v,staticGenerationAsyncStorage:c})}},49303:(e,t,r)=>{e.exports=r(30517)},13538:(e,t,r)=>{r.d(t,{Z:()=>n});var s=r(53524);let n=globalThis.prisma??new s.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),s=t.X(0,[8948,7070],()=>r(53014));module.exports=s})();