"use strict";(()=>{var e={};e.id=4831,e.ids=[4831],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")},89785:(e,t,r)=>{r.r(t),r.d(t,{originalPathname:()=>f,patchFetch:()=>h,requestAsyncStorage:()=>m,routeModule:()=>g,serverHooks:()=>x,staticGenerationAsyncStorage:()=>y});var n={};r.r(n),r.d(n,{DELETE:()=>p,PUT:()=>l});var a=r(49303),s=r(88716),i=r(60670),o=r(87070),u=r(8194),c=r(95456),d=r(57662);async function l(e,{params:t}){try{let r=await (0,c.ts)();if(!r)return o.NextResponse.json({error:"Unauthorized"},{status:401});let{id:n}=await t,a=await e.json(),s=await u._.category.update({where:{id:n,tenantId:r.tenantId},data:a});return(0,d.w)({tenantId:r.tenantId,userId:r.id,userName:r.name,userRole:r.role,action:"UPDATE",entity:"Category",entityId:n,description:`Mengubah kategori "${s.name}"`,meta:{changes:a}}),o.NextResponse.json({category:s})}catch{return o.NextResponse.json({error:"Server error"},{status:500})}}async function p(e,{params:t}){try{let e=await (0,c.ts)();if(!e)return o.NextResponse.json({error:"Unauthorized"},{status:401});let{id:r}=await t,n=await u._.category.findFirst({where:{id:r,tenantId:e.tenantId},select:{name:!0}});return await u._.category.update({where:{id:r,tenantId:e.tenantId},data:{isActive:!1}}),(0,d.w)({tenantId:e.tenantId,userId:e.id,userName:e.name,userRole:e.role,action:"DELETE",entity:"Category",entityId:r,description:`Menghapus kategori "${n?.name||r}"`}),o.NextResponse.json({success:!0})}catch{return o.NextResponse.json({error:"Server error"},{status:500})}}let g=new a.AppRouteRouteModule({definition:{kind:s.x.APP_ROUTE,page:"/api/categories/[id]/route",pathname:"/api/categories/[id]",filename:"route",bundlePath:"app/api/categories/[id]/route"},resolvedPagePath:"D:\\PROJECT\\resto-saas\\src\\app\\api\\categories\\[id]\\route.ts",nextConfigOutput:"",userland:n}),{requestAsyncStorage:m,staticGenerationAsyncStorage:y,serverHooks:x}=g,f="/api/categories/[id]/route";function h(){return(0,i.patchFetch)({serverHooks:x,staticGenerationAsyncStorage:y})}},57662:(e,t,r)=>{r.d(t,{w:()=>s});var n=r(8194);async function a(e){return n._.auditLog.create({data:{tenantId:e.tenantId,userId:e.userId||null,userName:e.userName||null,userRole:e.userRole||null,action:e.action,entity:e.entity,entityId:e.entityId||null,description:e.description,meta:e.meta?JSON.stringify(e.meta):null}})}function s(e){a(e).catch(e=>{console.error("[AuditLog] Failed to log activity:",e)})}},95456:(e,t,r)=>{r.d(t,{Gv:()=>l,MH:()=>y,PT:()=>x,RA:()=>p,WX:()=>g,c_:()=>d,ts:()=>m});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 d(e){return i().hash(e,12)}async function l(e,t){return i().compare(e,t)}function p(e){return a().sign(e,c,{expiresIn:"7d"})}function g(e){try{return a().verify(e,c)}catch{return null}}async function m(){let e=await (0,o.cookies)(),t=e.get("token")?.value;if(!t)return null;let r=g(t);return r?await u._.user.findUnique({where:{id:r.userId},include:{tenant:!0,store:!0}}):null}function y(e,t){return t.includes(e)}function x(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}};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(89785));module.exports=n})();