"use strict";(()=>{var e={};e.id=3156,e.ids=[3156],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")},88057:(e,r,t)=>{t.r(r),t.d(r,{originalPathname:()=>w,patchFetch:()=>h,requestAsyncStorage:()=>l,routeModule:()=>c,serverHooks:()=>x,staticGenerationAsyncStorage:()=>m});var n={};t.r(n),t.d(n,{POST:()=>d});var s=t(49303),a=t(88716),i=t(60670),o=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 n=await u._.user.findUnique({where:{id:t}});return n?.role==="ADMIN"}async function d(e){if(!await p(e))return o.NextResponse.json({error:"Unauthorized"},{status:401});try{let{targetUserId:r,amount:t}=await e.json();if(!r||!t)return o.NextResponse.json({error:"Target User ID and Amount are required"},{status:400});let n=parseInt(t);if(isNaN(n)||n<=0)return o.NextResponse.json({error:"Invalid amount"},{status:400});let s=n,a=0,i=0,p=await u._.coinPackage.findFirst({where:{coins:n}});p?(a=p.bonusCoins,i=p.bonusTickets):500===n?a=25:750===n?a=35:1e3===n?a=50:2e3===n?(a=115,i=1):5e3===n&&(a=300,i=3),s=n+a;let d=await u._.$transaction(async e=>{let t=await e.user.update({where:{id:r},data:{coins:{increment:s},spinTickets:i>0?{increment:i}:void 0}});return await e.transaction.create({data:{userId:r,type:"TOPUP_ADMIN",amount:0,coins:s,status:"SUCCESS",description:`Admin Topup: ${n} Coins`+(a>0?` + Bonus ${a} Coins`:"")+(i>0?` + ${i} Spin Tickets`:"")}}),t});return o.NextResponse.json(d)}catch(e){return console.error("Admin Topup Error:",e),o.NextResponse.json({error:"Internal server error"},{status:500})}}let c=new s.AppRouteRouteModule({definition:{kind:a.x.APP_ROUTE,page:"/api/admin/users/topup/route",pathname:"/api/admin/users/topup",filename:"route",bundlePath:"app/api/admin/users/topup/route"},resolvedPagePath:"C:\\Users\\MSI\\Downloads\\film\\app\\api\\admin\\users\\topup\\route.ts",nextConfigOutput:"standalone",userland:n}),{requestAsyncStorage:l,staticGenerationAsyncStorage:m,serverHooks:x}=c,w="/api/admin/users/topup/route";function h(){return(0,i.patchFetch)({serverHooks:x,staticGenerationAsyncStorage:m})}},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(88057));module.exports=n})();