"use strict";(()=>{var e={};e.id=6656,e.ids=[6656],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")},49054:(e,r,t)=>{t.r(r),t.d(r,{originalPathname:()=>w,patchFetch:()=>N,requestAsyncStorage:()=>g,routeModule:()=>m,serverHooks:()=>f,staticGenerationAsyncStorage:()=>x});var n={};t.r(n),t.d(n,{DELETE:()=>l,GET:()=>p,POST:()=>d});var s=t(49303),a=t(88716),i=t(60670),o=t(87070),u=t(72331);async function c(e){let{searchParams:r}=new URL(e.url),t=r.get("userId")||e.headers.get("x-user-id");if(!t)return!1;let n=await u._.user.findUnique({where:{id:t}});return n?.role==="ADMIN"}async function p(e){if(!await c(e))return o.NextResponse.json({error:"Unauthorized"},{status:401});let r=await u._.coinPackage.findMany({orderBy:{price:"asc"}});return o.NextResponse.json(r)}async function d(e){if(!await c(e))return o.NextResponse.json({error:"Unauthorized"},{status:401});try{let r=await e.json();if(!r.name||!r.price||!r.coins)return o.NextResponse.json({error:"Name, price, and coins are required"},{status:400});let t=parseInt(r.price),n=parseInt(r.coins);if(isNaN(t)||isNaN(n))return o.NextResponse.json({error:"Price and coins must be valid numbers"},{status:400});let s=await u._.coinPackage.create({data:{name:r.name,price:t,coins:n,bonusCoins:parseInt(r.bonusCoins||0)||0,bonusTickets:parseInt(r.bonusTickets||0)||0,isActive:!1!==r.isActive}});return o.NextResponse.json(s)}catch(e){return o.NextResponse.json({error:e.message||"Failed to create package"},{status:500})}}async function l(e){if(!await c(e))return o.NextResponse.json({error:"Unauthorized"},{status:401});let{searchParams:r}=new URL(e.url),t=r.get("id");return t?(await u._.coinPackage.delete({where:{id:t}}),o.NextResponse.json({success:!0})):o.NextResponse.json({error:"ID required"},{status:400})}let m=new s.AppRouteRouteModule({definition:{kind:a.x.APP_ROUTE,page:"/api/admin/coin-packages/route",pathname:"/api/admin/coin-packages",filename:"route",bundlePath:"app/api/admin/coin-packages/route"},resolvedPagePath:"C:\\Users\\MSI\\Downloads\\film\\app\\api\\admin\\coin-packages\\route.ts",nextConfigOutput:"standalone",userland:n}),{requestAsyncStorage:g,staticGenerationAsyncStorage:x,serverHooks:f}=m,w="/api/admin/coin-packages/route";function N(){return(0,i.patchFetch)({serverHooks:f,staticGenerationAsyncStorage:x})}},72331:(e,r,t)=>{t.d(r,{_:()=>s});var n=t(53524);let s=global.prisma||new n.PrismaClient}};var r=require("../../../../webpack-runtime.js");r.C(e);var t=e=>r(r.s=e),n=r.X(0,[8948,5972],()=>t(49054));module.exports=n})();