"use strict";(()=>{var e={};e.id=2847,e.ids=[2847],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")},75602:(e,r,t)=>{t.r(r),t.d(r,{originalPathname:()=>x,patchFetch:()=>v,requestAsyncStorage:()=>p,routeModule:()=>f,serverHooks:()=>m,staticGenerationAsyncStorage:()=>d});var a={};t.r(a),t.d(a,{GET:()=>c});var i=t(49303),n=t(88716),s=t(60670),o=t(87070),l=t(39655),u=t(8194);async function c(){try{let e=await (0,l.Of)();if(!e)return o.NextResponse.json({error:"Unauthorized"},{status:401});let r=await u._.tenant.findMany({where:{affiliateId:e.id},select:{id:!0,name:!0,plan:!0,isActive:!0,createdAt:!0,_count:{select:{affiliateCommissions:!0}}},orderBy:{createdAt:"desc"}});return o.NextResponse.json({referrals:r.map(e=>({id:e.id,name:e.name,plan:e.plan,isActive:e.isActive,createdAt:e.createdAt,totalCommissions:e._count.affiliateCommissions}))})}catch(e){return console.error("Affiliate referrals error:",e),o.NextResponse.json({error:"Server error"},{status:500})}}let f=new i.AppRouteRouteModule({definition:{kind:n.x.APP_ROUTE,page:"/api/affiliate/referrals/route",pathname:"/api/affiliate/referrals",filename:"route",bundlePath:"app/api/affiliate/referrals/route"},resolvedPagePath:"D:\\PROJECT\\resto-saas\\src\\app\\api\\affiliate\\referrals\\route.ts",nextConfigOutput:"",userland:a}),{requestAsyncStorage:p,staticGenerationAsyncStorage:d,serverHooks:m}=f,x="/api/affiliate/referrals/route";function v(){return(0,s.patchFetch)({serverHooks:m,staticGenerationAsyncStorage:d})}},39655:(e,r,t)=>{t.d(r,{No:()=>u,Of:()=>c,PX:()=>l});var a=t(41482),i=t.n(a),n=t(71615),s=t(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)(),r=e.get("aff_token")?.value;if(!r)return null;let t=function(e){try{let r=i().verify(e,o);if(!r.isAffiliate)return null;return r}catch{return null}}(r);return t&&await s._.affiliate.findUnique({where:{id:t.affiliateId}})||null}async function c(){return await u()||null}},8194:(e,r,t)=>{t.d(r,{_:()=>i});let a=require("@prisma/client"),i=globalThis.prisma??new a.PrismaClient}};var r=require("../../../../webpack-runtime.js");r.C(e);var t=e=>r(r.s=e),a=r.X(0,[8948,5972,4261],()=>t(75602));module.exports=a})();