"use strict";(()=>{var e={};e.id=4636,e.ids=[4636],e.modules={72934:e=>{e.exports=require("next/dist/client/components/action-async-storage.external.js")},54580:e=>{e.exports=require("next/dist/client/components/request-async-storage.external.js")},45869:e=>{e.exports=require("next/dist/client/components/static-generation-async-storage.external.js")},20399:e=>{e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},30517:e=>{e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},78893:e=>{e.exports=require("buffer")},84770:e=>{e.exports=require("crypto")},76162:e=>{e.exports=require("stream")},21764:e=>{e.exports=require("util")},36316:(e,t,r)=>{r.r(t),r.d(t,{originalPathname:()=>v,patchFetch:()=>w,requestAsyncStorage:()=>m,routeModule:()=>p,serverHooks:()=>f,staticGenerationAsyncStorage:()=>x});var n={};r.r(n),r.d(n,{PUT:()=>d});var a=r(49303),s=r(88716),i=r(60670),o=r(87070),u=r(95456),c=r(8194),l=r(45239);async function d(e,{params:t}){try{let r=await (0,u.ts)();if(!r)return o.NextResponse.json({error:"Unauthorized"},{status:401});if(!(0,u.MH)(r.role,["owner","admin","manager"]))return o.NextResponse.json({error:"Forbidden"},{status:403});let n=await (0,l.F)(r.tenantId,"inventory");if(n)return n;let{id:a}=await t,{minStock:s}=await e.json();if(null==s)return o.NextResponse.json({error:"minStock wajib diisi"},{status:400});if(!await c._.stockLevel.findFirst({where:{id:a,ingredient:{tenantId:r.tenantId}}}))return o.NextResponse.json({error:"Data stok tidak ditemukan"},{status:404});let i=await c._.stockLevel.update({where:{id:a},data:{minStock:parseFloat(s)},include:{ingredient:{select:{id:!0,name:!0,unit:!0,costPerUnit:!0}},store:{select:{id:!0,name:!0}}}});return o.NextResponse.json({stockLevel:i})}catch{return o.NextResponse.json({error:"Internal server error"},{status:500})}}let p=new a.AppRouteRouteModule({definition:{kind:s.x.APP_ROUTE,page:"/api/inventory/stock-levels/[id]/route",pathname:"/api/inventory/stock-levels/[id]",filename:"route",bundlePath:"app/api/inventory/stock-levels/[id]/route"},resolvedPagePath:"D:\\PROJECT\\resto-saas\\src\\app\\api\\inventory\\stock-levels\\[id]\\route.ts",nextConfigOutput:"",userland:n}),{requestAsyncStorage:m,staticGenerationAsyncStorage:x,serverHooks:f}=p,v="/api/inventory/stock-levels/[id]/route";function w(){return(0,i.patchFetch)({serverHooks:f,staticGenerationAsyncStorage:x})}},95456:(e,t,r)=>{r.d(t,{Gv:()=>d,MH:()=>f,PT:()=>v,RA:()=>p,WX:()=>m,c_:()=>l,ts:()=>x});var n=r(41482),a=r.n(n),s=r(42023),i=r.n(s),o=r(71615),u=r(8194);let c=process.env.JWT_SECRET||"fallback-secret-change-me";async function l(e){return i().hash(e,12)}async function d(e,t){return i().compare(e,t)}function p(e){return a().sign(e,c,{expiresIn:"7d"})}function m(e){try{return a().verify(e,c)}catch{return null}}async function x(){let e=await (0,o.cookies)(),t=e.get("token")?.value;if(!t)return null;let r=m(t);return r?await u._.user.findUnique({where:{id:r.userId},include:{tenant:!0,store:!0}}):null}function f(e,t){return t.includes(e)}function v(e){return!["owner","admin"].includes(e.role)&&!!e.storeId&&!!e.store&&!e.store.isActive}},8194:(e,t,r)=>{r.d(t,{_:()=>a});let n=require("@prisma/client"),a=globalThis.prisma??new n.PrismaClient},45239:(e,t,r)=>{r.d(t,{F:()=>s});var n=r(87070),a=r(15230);async function s(e,t){let r=await (0,a.p6)(e);return(0,a.U6)(r.features,t)?null:n.NextResponse.json({error:"Fitur ini tidak tersedia pada paket Anda. Silakan upgrade."},{status:403})}},15230:(e,t,r)=>{r.d(t,{MN:()=>s,U6:()=>i,p6:()=>a});var n=r(8194);async function a(e){let t=await n._.subscription.findFirst({where:{tenantId:e,status:{in:["active","trial"]}},include:{plan:!0},orderBy:{createdAt:"desc"}});return t?{maxStores:t.plan.maxStores,maxStaff:t.plan.maxStaff,maxMenuItems:t.plan.maxMenuItems,maxOrders:t.plan.maxOrders,features:JSON.parse(t.plan.features)}:{maxStores:1,maxStaff:3,maxMenuItems:30,maxOrders:100,features:["pos","qr_menu"]}}async function s(e,t){let r=await a(e),s=0,i=0;switch(t){case"stores":s=await n._.store.count({where:{tenantId:e,isActive:!0}}),i=r.maxStores;break;case"staff":s=await n._.user.count({where:{tenantId:e,isActive:!0}}),i=r.maxStaff;break;case"menuItems":s=await n._.menuItem.count({where:{tenantId:e,isActive:!0}}),i=r.maxMenuItems;break;case"orders":let o=new Date;o.setDate(1),o.setHours(0,0,0,0),s=await n._.order.count({where:{tenantId:e,createdAt:{gte:o}}}),i=r.maxOrders}return 0===i?{allowed:!0,current:s,max:i}:{allowed:s<i,current:s,max:i}}function i(e,t){return e.includes(t)}}};var t=require("../../../../../webpack-runtime.js");t.C(e);var r=e=>t(t.s=e),n=t.X(0,[8948,5972,4261,2023],()=>r(36316));module.exports=n})();