(()=>{var e={};e.id=3146,e.ids=[3146],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 n(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:()=>n,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")},38943:(e,r,t)=>{"use strict";t.r(r),t.d(r,{patchFetch:()=>v,routeModule:()=>y,serverHooks:()=>h,workAsyncStorage:()=>f,workUnitAsyncStorage:()=>k});var s={};t.r(s),t.d(s,{POST:()=>x});var n=t(96559),o=t(48088),u=t(37719),a=t(32190),i=t(43205),d=t.n(i),l=t(96330),p=t(12909);let c=new l.PrismaClient,m=(0,p.u)();async function x(e){try{let r,t=(0,p.V)(e);if(!t)return a.NextResponse.json({error:"Authorization token gerekli"},{status:401});try{r=d().verify(t,m)}catch(e){return a.NextResponse.json({error:"Ge\xe7ersiz token"},{status:401})}let s=await c.user.findUnique({where:{id:r.userId},include:{company:!0}});if(!s)return a.NextResponse.json({error:"Kullanıcı bulunamadı"},{status:404});let{title:n,brand:o,category:u,stockCode:i,isbn:l,cost:x,quantity:y,desi:f,psf:k}=await e.json();if(!n||""===n.trim())return a.NextResponse.json({error:"\xdcr\xfcn adı zorunludur"},{status:400});if(null==x||x<0)return a.NextResponse.json({error:"Maliyet zorunludur ve 0 veya daha b\xfcy\xfck olmalıdır"},{status:400});if(null!=f&&f<0)return a.NextResponse.json({error:"Desi 0 veya daha b\xfcy\xfck olmalıdır"},{status:400});if(!l||""===l.trim())return a.NextResponse.json({error:"ISBN zorunludur"},{status:400});if(!i||""===i.trim())return a.NextResponse.json({error:"Stok kodu zorunludur"},{status:400});if(null!=y&&y<0)return a.NextResponse.json({error:"Stok 0 veya daha b\xfcy\xfck olmalıdır"},{status:400});if(null!=k&&k<0)return a.NextResponse.json({error:"PSF 0 veya daha b\xfcy\xfck olmalıdır"},{status:400});if(await c.product.findFirst({where:{companyId:s.companyId,stockCode:i.trim()}}))return a.NextResponse.json({error:"Bu stok koduna sahip bir \xfcr\xfcn zaten mevcut"},{status:400});let h=await c.product.create({data:{companyId:s.companyId,title:n.trim(),cost:x,desi:f||null,isbn:l.trim(),stockCode:i.trim(),quantity:y||null,brand:o?.trim()||null,category:u?.trim()||null,psf:k||null}});return a.NextResponse.json({message:"\xdcr\xfcn başarıyla eklendi",product:{id:h.id,title:h.title,brand:h.brand,category:h.category,stockCode:h.stockCode,isbn:h.isbn,cost:h.cost,quantity:h.quantity,desi:h.desi,psf:h.psf}},{status:201})}catch(e){return console.error("Product create error:",e),a.NextResponse.json({error:"Sunucu hatası"},{status:500})}}let y=new n.AppRouteRouteModule({definition:{kind:o.RouteKind.APP_ROUTE,page:"/api/products/route",pathname:"/api/products",filename:"route",bundlePath:"app/api/products/route"},resolvedPagePath:"/Users/mustafaseyhan/Project/PazarAnalist/src/app/api/products/route.ts",nextConfigOutput:"standalone",userland:s}),{workAsyncStorage:f,workUnitAsyncStorage:k,serverHooks:h}=y;function v(){return(0,u.patchFetch)({workAsyncStorage:f,workUnitAsyncStorage:k})}},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 r=require("../../../webpack-runtime.js");r.C(e);var t=e=>r(r.s=e),s=r.X(0,[4447,580,3205],()=>t(38943));module.exports=s})();