(()=>{var e={};e.id=1420,e.ids=[1420],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")},78335:()=>{},79428:e=>{"use strict";e.exports=require("buffer")},79530:(e,r,t)=>{"use strict";t.r(r),t.d(r,{patchFetch:()=>v,routeModule:()=>y,serverHooks:()=>w,workAsyncStorage:()=>h,workUnitAsyncStorage:()=>k});var s={};t.r(s),t.d(s,{POST:()=>x});var a=t(96559),n=t(48088),o=t(37719),i=t(32190),u=t(43205),p=t.n(u),c=t(96330),d=t(12909);let l=new c.PrismaClient,m=(0,d.u)();async function f(e){let r=(0,d.V)(e);if(!r)return null;try{let e=p().verify(r,m);if(e.isGlobalAdmin&&e.globalAdminId)return e}catch{}return null}async function x(e){try{if(!await f(e))return i.NextResponse.json({error:"Unauthorized"},{status:401});let{companyId:r,marketplaceId:t,name:s,credentials:a}=await e.json();if(!r||!t||!s)return i.NextResponse.json({error:"Company ID, Marketplace ID, and Store name are required"},{status:400});if(!await l.company.findUnique({where:{id:parseInt(r)}}))return i.NextResponse.json({error:"Company not found"},{status:404});if(!await l.marketplace.findUnique({where:{id:parseInt(t)}}))return i.NextResponse.json({error:"Marketplace not found"},{status:404});if(await l.companyMarketplace.findFirst({where:{companyId:parseInt(r),marketplaceId:parseInt(t),name:s}}))return i.NextResponse.json({error:"Store with this name already exists for this company and marketplace"},{status:400});let n=await l.companyMarketplace.create({data:{companyId:parseInt(r),marketplaceId:parseInt(t),name:s,credentials:a||null}});return i.NextResponse.json({companyMarketplace:n,message:"Store created successfully"},{status:201})}catch(e){return console.error("Create store error:",e),i.NextResponse.json({error:"Server error"},{status:500})}}let y=new a.AppRouteRouteModule({definition:{kind:n.RouteKind.APP_ROUTE,page:"/api/admin/stores/route",pathname:"/api/admin/stores",filename:"route",bundlePath:"app/api/admin/stores/route"},resolvedPagePath:"/Users/mustafaseyhan/Project/PazarAnalist/src/app/api/admin/stores/route.ts",nextConfigOutput:"standalone",userland:s}),{workAsyncStorage:h,workUnitAsyncStorage:k,serverHooks:w}=y;function v(){return(0,o.patchFetch)({workAsyncStorage:h,workUnitAsyncStorage:k})}},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(79530));module.exports=s})();