(()=>{var e={};e.id=7785,e.ids=[7785],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,t,r)=>{"use strict";function a(){let e=process.env.JWT_SECRET;if(!e)throw Error("JWT_SECRET is not set");return e}function s(e){let t=e.headers.get("authorization");if(t&&t.startsWith("Bearer "))return t.slice(7);let r=e.cookies.get("admin_token")?.value;if(r)return r;let a=e.cookies.get("token")?.value;return a||null}r.d(t,{V:()=>s,u:()=>a})},19117:(e,t,r)=>{"use strict";r.r(t),r.d(t,{patchFetch:()=>h,routeModule:()=>f,serverHooks:()=>w,workAsyncStorage:()=>g,workUnitAsyncStorage:()=>y});var a={};r.r(a),r.d(a,{POST:()=>x});var s=r(96559),n=r(48088),i=r(37719),o=r(32190),u=r(43205),p=r.n(u),c=r(96330),d=r(12909);let l=new c.PrismaClient,m=(0,d.u)();async function k(e){let t=(0,d.V)(e);if(!t)return null;try{let e=p().verify(t,m);if(e.isGlobalAdmin&&e.globalAdminId)return e}catch{}return null}async function x(e,{params:t}){try{if(!await k(e))return o.NextResponse.json({error:"Unauthorized"},{status:401});let r=parseInt(t.id);if(isNaN(r))return o.NextResponse.json({error:"Invalid company ID"},{status:400});if(!await l.company.findUnique({where:{id:r}}))return o.NextResponse.json({error:"Company not found"},{status:404});let a=new Date;if(await l.companyPackage.findFirst({where:{companyId:r,status:!0,packageEndDate:{gte:a}}}))return o.NextResponse.json({error:"Bu şirket i\xe7in zaten aktif bir paket mevcut"},{status:400});let s=await l.package.findFirst({where:{name:"Free"}});if(!s)return o.NextResponse.json({error:"Free paketi bulunamadı"},{status:404});let n=await l.companyMarketplace.count({where:{companyId:r}}),i=new Date(Date.now()+31536e6),u=await l.companyPackage.create({data:{companyId:r,packageId:s.id,status:!0,packageEndDate:i,maxStores:n>0?n:null},include:{package:!0,company:{select:{id:!0,name:!0}}}});return o.NextResponse.json({message:"Free paket başarıyla eklendi",companyPackage:u},{status:201})}catch(e){return console.error("Create company package error:",e),o.NextResponse.json({error:"Server error"},{status:500})}}let f=new s.AppRouteRouteModule({definition:{kind:n.RouteKind.APP_ROUTE,page:"/api/admin/companies/[id]/packages/route",pathname:"/api/admin/companies/[id]/packages",filename:"route",bundlePath:"app/api/admin/companies/[id]/packages/route"},resolvedPagePath:"/Users/mustafaseyhan/Project/PazarAnalist/src/app/api/admin/companies/[id]/packages/route.ts",nextConfigOutput:"standalone",userland:a}),{workAsyncStorage:g,workUnitAsyncStorage:y,serverHooks:w}=f;function h(){return(0,i.patchFetch)({workAsyncStorage:g,workUnitAsyncStorage:y})}},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")},96330:e=>{"use strict";e.exports=require("@prisma/client")},96487:()=>{}};var t=require("../../../../../../webpack-runtime.js");t.C(e);var r=e=>t(t.s=e),a=t.X(0,[4447,580,3205],()=>r(19117));module.exports=a})();