(()=>{var e={};e.id=2691,e.ids=[2691],e.modules={3295:e=>{"use strict";e.exports=require("next/dist/server/app-render/after-task-async-storage.external.js")},10846:e=>{"use strict";e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},12909:(e,r,t)=>{"use strict";function s(){let e=process.env.JWT_SECRET;if(!e)throw Error("JWT_SECRET is not set");return e}function a(e){let r=e.headers.get("authorization");if(r&&r.startsWith("Bearer "))return r.slice(7);let t=e.cookies.get("admin_token")?.value;if(t)return t;let s=e.cookies.get("token")?.value;return s||null}t.d(r,{V:()=>a,u:()=>s})},27910:e=>{"use strict";e.exports=require("stream")},28354:e=>{"use strict";e.exports=require("util")},29294:e=>{"use strict";e.exports=require("next/dist/server/app-render/work-async-storage.external.js")},44870:e=>{"use strict";e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},55511:e=>{"use strict";e.exports=require("crypto")},63033:e=>{"use strict";e.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},73232:(e,r,t)=>{"use strict";t.r(r),t.d(r,{patchFetch:()=>h,routeModule:()=>m,serverHooks:()=>k,workAsyncStorage:()=>x,workUnitAsyncStorage:()=>f});var s={};t.r(s),t.d(s,{GET:()=>l});var a=t(96559),n=t(48088),o=t(37719),i=t(32190),c=t(43205),u=t.n(c),p=t(96330),d=t(12909);async function l(e){let r=new p.PrismaClient;try{let t,s;try{t=(0,d.u)()}catch(e){return await r.$disconnect(),i.NextResponse.json({error:"Server configuration error"},{status:500})}let a=(0,d.V)(e);if(!a)return await r.$disconnect(),i.NextResponse.json({error:"Authorization token gerekli"},{status:401});try{s=u().verify(a,t)}catch(e){return await r.$disconnect(),i.NextResponse.json({error:"Ge\xe7ersiz token"},{status:401})}let{searchParams:n}=new URL(e.url),o=n.get("productIds"),c=n.get("companyMarketplaceId");if(!o||!c)return await r.$disconnect(),i.NextResponse.json({error:"productIds (comma-separated) ve companyMarketplaceId parametreleri gerekli"},{status:400});let p=o.split(",").map(e=>parseInt(e.trim())).filter(e=>!isNaN(e));if(0===p.length)return await r.$disconnect(),i.NextResponse.json({error:"Ge\xe7erli productId bulunamadı"},{status:400});let l=await r.user.findUnique({where:{id:s.userId},include:{company:{include:{companyMarketplaces:{where:{id:parseInt(c)}}}}}});if(!l)return await r.$disconnect(),i.NextResponse.json({error:"Kullanıcı bulunamadı"},{status:404});if(!l.company.companyMarketplaces[0])return await r.$disconnect(),i.NextResponse.json({error:"Mağaza bulunamadı"},{status:404});let m=(await r.product.findMany({where:{id:{in:p},companyId:l.companyId},select:{id:!0}})).map(e=>e.id),x=await r.productMarketplace.findMany({where:{productId:{in:m},companyMarketplaceId:parseInt(c),isManual:!0},select:{productId:!0}}),f={};return m.forEach(e=>{f[e]=0}),x.forEach(e=>{f[e.productId]=(f[e.productId]||0)+1}),await r.$disconnect(),i.NextResponse.json({counts:f})}catch(e){console.error("ProductMarketplace counts fetch error:",e),e instanceof Error&&e.message;try{await r.$disconnect()}catch(e){console.error("Prisma disconnect error:",e)}return i.NextResponse.json({error:"Sunucu hatası",message:void 0},{status:500})}}let m=new a.AppRouteRouteModule({definition:{kind:n.RouteKind.APP_ROUTE,page:"/api/products/product-marketplace/counts/route",pathname:"/api/products/product-marketplace/counts",filename:"route",bundlePath:"app/api/products/product-marketplace/counts/route"},resolvedPagePath:"/Users/mustafaseyhan/Project/PazarAnalist/src/app/api/products/product-marketplace/counts/route.ts",nextConfigOutput:"standalone",userland:s}),{workAsyncStorage:x,workUnitAsyncStorage:f,serverHooks:k}=m;function h(){return(0,o.patchFetch)({workAsyncStorage:x,workUnitAsyncStorage:f})}},78335:()=>{},79428:e=>{"use strict";e.exports=require("buffer")},96330:e=>{"use strict";e.exports=require("@prisma/client")},96487:()=>{}};var r=require("../../../../../webpack-runtime.js");r.C(e);var t=e=>r(r.s=e),s=r.X(0,[4447,580,3205],()=>t(73232));module.exports=s})();