"use strict";(()=>{var e={};e.id=4472,e.ids=[4472],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")},38651:(e,t,s)=>{s.r(t),s.d(t,{originalPathname:()=>g,patchFetch:()=>y,requestAsyncStorage:()=>f,routeModule:()=>h,serverHooks:()=>x,staticGenerationAsyncStorage:()=>v});var n={};s.r(n),s.d(n,{DELETE:()=>m,GET:()=>l,PATCH:()=>p,dynamic:()=>c});var r=s(49303),o=s(88716),a=s(60670),i=s(87070),u=s(13538),d=s(5710);let c="force-dynamic";async function l(e,{params:t}){try{let{userId:e}=(0,d.v0)();if(!e)return(0,d.Hs)();let s=await u.Z.schoolEvent.findUnique({where:{id:t.id},include:{attendees:!0}});if(!s)return i.NextResponse.json({message:"Event not found"},{status:404});return i.NextResponse.json(s)}catch(e){return(0,d.I3)(e)}}async function p(e,{params:t}){try{let{userId:s,role:n}=(0,d.v0)();if(!s)return(0,d.Hs)();let r=await u.Z.schoolEvent.findUnique({where:{id:t.id}});if(!r)return i.NextResponse.json({message:"Event not found"},{status:404});if("admin"!==n&&r.createdBy!==s)return(0,d.ID)();let{title:o,description:a,date:c,time:l,location:p,visibility:m}=await e.json(),h=await u.Z.schoolEvent.update({where:{id:t.id},data:{title:o,description:a,date:c?new Date(c):void 0,time:l,location:p,visibility:m}});return i.NextResponse.json(h)}catch(e){return(0,d.I3)(e)}}async function m(e,{params:t}){try{let{userId:e,role:s}=(0,d.v0)();if(!e)return(0,d.Hs)();if("admin"!==s)return(0,d.ID)();return await u.Z.schoolEvent.delete({where:{id:t.id}}),i.NextResponse.json({message:"Event deleted successfully"})}catch(e){return(0,d.I3)(e)}}let h=new r.AppRouteRouteModule({definition:{kind:o.x.APP_ROUTE,page:"/api/school-life/events/[id]/route",pathname:"/api/school-life/events/[id]",filename:"route",bundlePath:"app/api/school-life/events/[id]/route"},resolvedPagePath:"C:\\School Management System\\Working\\V2\\src\\app\\api\\school-life\\events\\[id]\\route.ts",nextConfigOutput:"standalone",userland:n}),{requestAsyncStorage:f,staticGenerationAsyncStorage:v,serverHooks:x}=h,g="/api/school-life/events/[id]/route";function y(){return(0,a.patchFetch)({serverHooks:x,staticGenerationAsyncStorage:v})}},49303:(e,t,s)=>{e.exports=s(30517)},5710:(e,t,s)=>{s.d(t,{Hs:()=>a,I3:()=>d,ID:()=>i,v0:()=>o,yw:()=>u});var n=s(26501),r=s(87070);function o(){let{userId:e,sessionClaims:t}=(0,n.d)();return{userId:e,role:t?.metadata?.role}}function a(){return r.NextResponse.json({message:"Unauthorized"},{status:401})}function i(){return r.NextResponse.json({message:"Forbidden"},{status:403})}function u(e){return r.NextResponse.json({message:e},{status:400})}function d(e){return console.error(e),r.NextResponse.json({message:"Internal Server Error"},{status:500})}},26501:(e,t,s)=>{s.d(t,{d:()=>r});var n=s(78459);function r(){try{let{userId:e,sessionClaims:t}=(0,n.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,s)=>{s.d(t,{Z:()=>r});var n=s(53524);let r=globalThis.prisma??new n.PrismaClient({log:["error"],datasources:{db:{url:process.env.DATABASE_URL}}})}};var t=require("../../../../../webpack-runtime.js");t.C(e);var s=e=>t(t.s=e),n=t.X(0,[8948,7070,8459],()=>s(38651));module.exports=n})();