"use strict";(()=>{var e={};e.id=1251,e.ids=[1251],e.modules={53524:e=>{e.exports=require("@prisma/client")},72934:e=>{e.exports=require("next/dist/client/components/action-async-storage.external.js")},54580:e=>{e.exports=require("next/dist/client/components/request-async-storage.external.js")},45869:e=>{e.exports=require("next/dist/client/components/static-generation-async-storage.external.js")},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")},6113:e=>{e.exports=require("crypto")},6005:e=>{e.exports=require("node:crypto")},43151:(e,t,r)=>{r.r(t),r.d(t,{originalPathname:()=>f,patchFetch:()=>y,requestAsyncStorage:()=>h,routeModule:()=>m,serverHooks:()=>x,staticGenerationAsyncStorage:()=>v});var s={};r.r(s),r.d(s,{GET:()=>d,POST:()=>p,dynamic:()=>c});var n=r(49303),o=r(88716),a=r(60670),i=r(87070),u=r(13538),l=r(5710);let c="force-dynamic";async function d(e){try{let{userId:t}=(0,l.v0)();if(!t)return(0,l.Hs)();let{searchParams:r}=new URL(e.url),s=r.get("visibility"),n={};s&&(n.visibility=s);let o=await u.Z.schoolEvent.findMany({where:n,orderBy:{date:"asc"},include:{_count:{select:{attendees:!0}}}});return i.NextResponse.json(o)}catch(e){return(0,l.I3)(e)}}async function p(e){try{let{userId:t,role:r}=(0,l.v0)();if(!t)return(0,l.Hs)();if("admin"!==r&&"teacher"!==r)return(0,l.ID)();let{title:s,description:n,date:o,time:a,location:c,visibility:d}=await e.json();if(!s||!o||!d)return(0,l.yw)("Missing required fields: title, date, visibility");let p=await u.Z.schoolEvent.create({data:{title:s,description:n,date:new Date(o),time:a,location:c,visibility:d,createdBy:t}});return i.NextResponse.json(p,{status:201})}catch(e){return(0,l.I3)(e)}}let m=new n.AppRouteRouteModule({definition:{kind:o.x.APP_ROUTE,page:"/api/school-life/events/route",pathname:"/api/school-life/events",filename:"route",bundlePath:"app/api/school-life/events/route"},resolvedPagePath:"C:\\School Management System\\Working\\V2\\src\\app\\api\\school-life\\events\\route.ts",nextConfigOutput:"standalone",userland:s}),{requestAsyncStorage:h,staticGenerationAsyncStorage:v,serverHooks:x}=m,f="/api/school-life/events/route";function y(){return(0,a.patchFetch)({serverHooks:x,staticGenerationAsyncStorage:v})}},49303:(e,t,r)=>{e.exports=r(30517)},5710:(e,t,r)=>{r.d(t,{Hs:()=>a,I3:()=>l,ID:()=>i,v0:()=>o,yw:()=>u});var s=r(26501),n=r(87070);function o(){let{userId:e,sessionClaims:t}=(0,s.d)();return{userId:e,role:t?.metadata?.role}}function a(){return n.NextResponse.json({message:"Unauthorized"},{status:401})}function i(){return n.NextResponse.json({message:"Forbidden"},{status:403})}function u(e){return n.NextResponse.json({message:e},{status:400})}function l(e){return console.error(e),n.NextResponse.json({message:"Internal Server Error"},{status:500})}},26501:(e,t,r)=>{r.d(t,{d:()=>n});var s=r(78459);function n(){try{let{userId:e,sessionClaims:t}=(0,s.I)();return{userId:e,sessionClaims:t,isBuildPhase:!1}}catch(e){if(e instanceof Error&&(e.message.includes("DYNAMIC_SERVER_USAGE")||e.message.includes("Dynamic server usage")||e.message.includes("headers")))return console.warn("[DeploymentGuard] Build-phase detected — auth() skipped."),{userId:null,sessionClaims:null,isBuildPhase:!0};throw e}}},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,8459],()=>r(43151));module.exports=s})();