"use strict";(()=>{var e={};e.id=6556,e.ids=[6556],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")},46349:(e,t,r)=>{r.r(t),r.d(t,{originalPathname:()=>m,patchFetch:()=>y,requestAsyncStorage:()=>d,routeModule:()=>p,serverHooks:()=>k,staticGenerationAsyncStorage:()=>l});var s={};r.r(s),r.d(s,{POST:()=>c});var n=r(49303),i=r(88716),a=r(60670),o=r(87070),u=r(72331);async function c(e){try{let{userId:t,ticketAmount:r}=await e.json();if(!t||!r||r<=0)return o.NextResponse.json({error:"Invalid data"},{status:400});let s=await u._.user.findUnique({where:{id:t}});if(!s)return o.NextResponse.json({error:"User not found"},{status:404});let n=2500*r;if(s.coins<n)return o.NextResponse.json({error:"Insufficient coins"},{status:400});let i=await u._.user.update({where:{id:t},data:{coins:{decrement:n},spinTickets:{increment:r}}});return await u._.transaction.create({data:{userId:s.id,type:"TICKET_PURCHASE",amount:n,coins:-n,status:"SUCCESS",description:`Purchased ${r} Lucky Spin Ticket(s)`}}),o.NextResponse.json({success:!0,coins:i.coins,spinTickets:i.spinTickets})}catch(e){return console.error("Buy Ticket Error:",e),o.NextResponse.json({error:"Internal server error"},{status:500})}}let p=new n.AppRouteRouteModule({definition:{kind:i.x.APP_ROUTE,page:"/api/luckyspin/buy-ticket/route",pathname:"/api/luckyspin/buy-ticket",filename:"route",bundlePath:"app/api/luckyspin/buy-ticket/route"},resolvedPagePath:"C:\\Users\\MSI\\Downloads\\film\\app\\api\\luckyspin\\buy-ticket\\route.ts",nextConfigOutput:"standalone",userland:s}),{requestAsyncStorage:d,staticGenerationAsyncStorage:l,serverHooks:k}=p,m="/api/luckyspin/buy-ticket/route";function y(){return(0,a.patchFetch)({serverHooks:k,staticGenerationAsyncStorage:l})}},72331:(e,t,r)=>{r.d(t,{_:()=>n});var s=r(53524);let n=global.prisma||new s.PrismaClient}};var t=require("../../../../webpack-runtime.js");t.C(e);var r=e=>t(t.s=e),s=t.X(0,[8948,5972],()=>r(46349));module.exports=s})();