"use strict";(()=>{var e={};e.id=5467,e.ids=[5467],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")},41187:(e,t,r)=>{r.r(t),r.d(t,{originalPathname:()=>R,patchFetch:()=>h,requestAsyncStorage:()=>S,routeModule:()=>T,serverHooks:()=>v,staticGenerationAsyncStorage:()=>m});var s={};r.r(s),r.d(s,{GET:()=>p,POST:()=>c,dynamic:()=>l});var a=r(49303),n=r(88716),o=r(60670),u=r(87070),i=r(13538);let l="force-dynamic",d={SCHOOL_START_TIME:"09:00",LATE_THRESHOLD_MINUTES:"15"};async function p(){try{let e=await i.Z.attendanceRule.findMany(),t={...d};for(let r of e)t[r.key]=r.value;return u.NextResponse.json({rules:t,schoolStartTime:t.SCHOOL_START_TIME,lateThresholdMinutes:parseInt(t.LATE_THRESHOLD_MINUTES,10)})}catch(e){return console.error("[AttendanceRules] GET Error:",e),u.NextResponse.json({error:"Internal Server Error",message:String(e)},{status:500})}}async function c(e){try{let{schoolStartTime:t,lateThresholdMinutes:r}=await e.json(),s=[];if(t&&"string"==typeof t){if(!/^\d{2}:\d{2}$/.test(t))return u.NextResponse.json({error:"Bad Request",message:"schoolStartTime must be in HH:MM format"},{status:400});s.push({key:"SCHOOL_START_TIME",value:t})}if(void 0!==r){let e=parseInt(String(r),10);if(isNaN(e)||e<0||e>120)return u.NextResponse.json({error:"Bad Request",message:"lateThresholdMinutes must be 0-120"},{status:400});s.push({key:"LATE_THRESHOLD_MINUTES",value:String(e)})}if(0===s.length)return u.NextResponse.json({error:"Bad Request",message:"No valid fields to update"},{status:400});for(let e of s)await i.Z.attendanceRule.upsert({where:{key:e.key},update:{value:e.value},create:{key:e.key,value:e.value}});let a=await i.Z.attendanceRule.findMany(),n={...d};for(let e of a)n[e.key]=e.value;return u.NextResponse.json({message:"Rules updated successfully",rules:n,schoolStartTime:n.SCHOOL_START_TIME,lateThresholdMinutes:parseInt(n.LATE_THRESHOLD_MINUTES,10)})}catch(e){return console.error("[AttendanceRules] POST Error:",e),u.NextResponse.json({error:"Internal Server Error",message:String(e)},{status:500})}}let T=new a.AppRouteRouteModule({definition:{kind:n.x.APP_ROUTE,page:"/api/v1/attendance/rules/route",pathname:"/api/v1/attendance/rules",filename:"route",bundlePath:"app/api/v1/attendance/rules/route"},resolvedPagePath:"C:\\School Management System\\Working\\V2\\src\\app\\api\\v1\\attendance\\rules\\route.ts",nextConfigOutput:"standalone",userland:s}),{requestAsyncStorage:S,staticGenerationAsyncStorage:m,serverHooks:v}=T,R="/api/v1/attendance/rules/route";function h(){return(0,o.patchFetch)({serverHooks:v,staticGenerationAsyncStorage:m})}},49303:(e,t,r)=>{e.exports=r(30517)},13538:(e,t,r)=>{r.d(t,{Z:()=>a});var s=r(53524);let a=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(41187));module.exports=s})();