"use strict";(()=>{var e={};e.id=1936,e.ids=[1936],e.modules={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")},78893:e=>{e.exports=require("buffer")},84770:e=>{e.exports=require("crypto")},76162:e=>{e.exports=require("stream")},21764:e=>{e.exports=require("util")},89767:(e,t,r)=>{r.r(t),r.d(t,{originalPathname:()=>m,patchFetch:()=>w,requestAsyncStorage:()=>f,routeModule:()=>p,serverHooks:()=>x,staticGenerationAsyncStorage:()=>d});var a={};r.r(a),r.d(a,{GET:()=>c});var i=r(49303),n=r(88716),s=r(60670),o=r(87070),l=r(39655),u=r(8194);async function c(){try{let e=await (0,l.Of)();if(!e)return o.NextResponse.json({error:"Unauthorized"},{status:401});let t=await u._.affiliateWallet.findUnique({where:{affiliateId:e.id},include:{transactions:{orderBy:{createdAt:"desc"},take:50}}});return o.NextResponse.json({balance:Number(t?.balance||0),transactions:(t?.transactions||[]).map(e=>({id:e.id,type:e.type,amount:Number(e.amount),balanceAfter:Number(e.balanceAfter),description:e.description,createdAt:e.createdAt}))})}catch(e){return console.error("Affiliate wallet error:",e),o.NextResponse.json({error:"Server error"},{status:500})}}let p=new i.AppRouteRouteModule({definition:{kind:n.x.APP_ROUTE,page:"/api/affiliate/wallet/route",pathname:"/api/affiliate/wallet",filename:"route",bundlePath:"app/api/affiliate/wallet/route"},resolvedPagePath:"D:\\PROJECT\\resto-saas\\src\\app\\api\\affiliate\\wallet\\route.ts",nextConfigOutput:"",userland:a}),{requestAsyncStorage:f,staticGenerationAsyncStorage:d,serverHooks:x}=p,m="/api/affiliate/wallet/route";function w(){return(0,s.patchFetch)({serverHooks:x,staticGenerationAsyncStorage:d})}},39655:(e,t,r)=>{r.d(t,{No:()=>u,Of:()=>c,PX:()=>l});var a=r(41482),i=r.n(a),n=r(71615),s=r(8194);let o=process.env.JWT_SECRET||"fallback-secret-change-me";function l(e){return i().sign({...e,isAffiliate:!0},o,{expiresIn:"7d"})}async function u(){let e=await (0,n.cookies)(),t=e.get("aff_token")?.value;if(!t)return null;let r=function(e){try{let t=i().verify(e,o);if(!t.isAffiliate)return null;return t}catch{return null}}(t);return r&&await s._.affiliate.findUnique({where:{id:r.affiliateId}})||null}async function c(){return await u()||null}},8194:(e,t,r)=>{r.d(t,{_:()=>i});let a=require("@prisma/client"),i=globalThis.prisma??new a.PrismaClient}};var t=require("../../../../webpack-runtime.js");t.C(e);var r=e=>t(t.s=e),a=t.X(0,[8948,5972,4261],()=>r(89767));module.exports=a})();