"use strict";(()=>{var e={};e.id=4529,e.ids=[4529],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")},966:(e,r,t)=>{t.r(r),t.d(r,{originalPathname:()=>w,patchFetch:()=>R,requestAsyncStorage:()=>f,routeModule:()=>x,serverHooks:()=>m,staticGenerationAsyncStorage:()=>h});var s={};t.r(s),t.d(s,{DELETE:()=>c,GET:()=>d,PATCH:()=>l});var n=t(49303),a=t(88716),o=t(60670),i=t(87070),u=t(72331);async function p(e){let{searchParams:r}=new URL(e.url),t=r.get("userId")||e.headers.get("x-user-id");if(!t)return!1;let s=await u._.user.findUnique({where:{id:t}});return s?.role==="ADMIN"}async function d(e){if(!await p(e))return i.NextResponse.json({error:"Unauthorized"},{status:401});try{let e=await u._.report.findMany({orderBy:{createdAt:"desc"}});return i.NextResponse.json(e)}catch(e){return i.NextResponse.json({error:"Failed to fetch reports"},{status:500})}}async function l(e){if(!await p(e))return i.NextResponse.json({error:"Unauthorized"},{status:401});try{let{id:r,status:t}=await e.json();if(!r||!t)return i.NextResponse.json({error:"Missing required fields"},{status:400});let s=await u._.report.update({where:{id:r},data:{status:t}});return i.NextResponse.json(s)}catch(e){return i.NextResponse.json({error:"Failed to update report"},{status:500})}}async function c(e){if(!await p(e))return i.NextResponse.json({error:"Unauthorized"},{status:401});try{let{searchParams:r}=new URL(e.url),t=r.get("id");if(!t)return i.NextResponse.json({error:"Missing report ID"},{status:400});return await u._.report.delete({where:{id:t}}),i.NextResponse.json({success:!0})}catch(e){return i.NextResponse.json({error:"Failed to delete report"},{status:500})}}let x=new n.AppRouteRouteModule({definition:{kind:a.x.APP_ROUTE,page:"/api/admin/reports/route",pathname:"/api/admin/reports",filename:"route",bundlePath:"app/api/admin/reports/route"},resolvedPagePath:"C:\\Users\\MSI\\Downloads\\film\\app\\api\\admin\\reports\\route.ts",nextConfigOutput:"standalone",userland:s}),{requestAsyncStorage:f,staticGenerationAsyncStorage:h,serverHooks:m}=x,w="/api/admin/reports/route";function R(){return(0,o.patchFetch)({serverHooks:m,staticGenerationAsyncStorage:h})}},72331:(e,r,t)=>{t.d(r,{_:()=>n});var s=t(53524);let n=global.prisma||new s.PrismaClient}};var r=require("../../../../webpack-runtime.js");r.C(e);var t=e=>r(r.s=e),s=r.X(0,[8948,5972],()=>t(966));module.exports=s})();