"use strict";(()=>{var e={};e.id=3898,e.ids=[3898],e.modules={53524:e=>{e.exports=require("@prisma/client")},30517:e=>{e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},56427:(e,r,t)=>{t.r(r),t.d(r,{headerHooks:()=>A,originalPathname:()=>w,requestAsyncStorage:()=>l,routeModule:()=>c,serverHooks:()=>m,staticGenerationAsyncStorage:()=>P,staticGenerationBailout:()=>E});var a={};t.r(a),t.d(a,{DELETE:()=>s,PUT:()=>u}),t(95655);var o=t(83323),i=t(54647),d=t(66886),n=t(30953);async function u(e,{params:r}){try{let{id:t}=r,a=await e.json(),{nameEn:o,nameFr:i,slug:u,descriptionEn:s,descriptionFr:p,seoTitle:c,seoDescription:l,category:P,categoryId:m,image:A,gallery:E,unit:w,minOrder:g,origin:h,sku:v,stockStatus:y,dimensions:_,weight:f,featured:j,price:k,variants:x}=a,G=x?.map(e=>e.id.startsWith("new-")?{...e,id:crypto.randomUUID()}:e)||[],I=G.map(e=>e.id),b=await n._.product.update({where:{id:t},data:{nameEn:o,nameFr:i,slug:u,descriptionEn:s,descriptionFr:p,seoTitle:c,seoDescription:l,category:P,categoryId:m||void 0,image:A,gallery:E||void 0,unit:w,minOrder:g,origin:h,sku:v,stockStatus:y,dimensions:_,weight:f,featured:j,price:k?Number(k):0,variants:{deleteMany:{id:{notIn:I}},upsert:G.map(e=>({where:{id:e.id},update:{size:e.size,sku:e.sku},create:{id:e.id,size:e.size,sku:e.sku}}))}},include:{variants:!0}});return d.Z.json(b)}catch(e){return console.error("Error updating product:",e),d.Z.json({error:"Error updating product"},{status:500})}}async function s(e,{params:r}){try{let{id:e}=r;await n._.orderItem.deleteMany({where:{productId:e}}),await n._.productVariant.deleteMany({where:{productId:e}});let t=await n._.product.delete({where:{id:e}});return d.Z.json(t)}catch(e){return console.error("Error deleting product:",e),d.Z.json({error:"Error deleting product"},{status:500})}}let p=o.AppRouteRouteModule,c=new p({definition:{kind:i.x.APP_ROUTE,page:"/api/products/[id]/route",pathname:"/api/products/[id]",filename:"route",bundlePath:"app/api/products/[id]/route"},resolvedPagePath:"D:\\Code\\MusaFoods_New\\musafoods\\app\\api\\products\\[id]\\route.ts",nextConfigOutput:"standalone",userland:a}),{requestAsyncStorage:l,staticGenerationAsyncStorage:P,serverHooks:m,headerHooks:A,staticGenerationBailout:E}=c,w="/api/products/[id]/route"},30953:(e,r,t)=>{t.d(r,{_:()=>i});var a=t(53524);let o=globalThis,i=o.prisma??new a.PrismaClient},54647:(e,r)=>{var t;Object.defineProperty(r,"x",{enumerable:!0,get:function(){return t}}),function(e){e.PAGES="PAGES",e.PAGES_API="PAGES_API",e.APP_PAGE="APP_PAGE",e.APP_ROUTE="APP_ROUTE"}(t||(t={}))}};var r=require("../../../../webpack-runtime.js");r.C(e);var t=e=>r(r.s=e),a=r.X(0,[9727,3497,6886],()=>t(56427));module.exports=a})();