"use strict";(()=>{var e={};e.id=3894,e.ids=[3894],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")},89200:(e,t,r)=>{r.r(t),r.d(t,{originalPathname:()=>h,patchFetch:()=>m,requestAsyncStorage:()=>x,routeModule:()=>d,serverHooks:()=>v,staticGenerationAsyncStorage:()=>f});var s={};r.r(s),r.d(s,{DELETE:()=>l,PUT:()=>p});var n=r(49303),a=r(88716),o=r(60670),i=r(87070),u=r(8194),c=r(95456);async function p(e,{params:t}){try{let r=await (0,c.ts)();if(!r)return i.NextResponse.json({error:"Unauthorized"},{status:401});let{id:s}=await t,n=await e.json(),a=await u._.restTable.findFirst({where:{id:s},include:{store:{select:{tenantId:!0}}}});if(!a||a.store.tenantId!==r.tenantId)return i.NextResponse.json({error:"Not found"},{status:404});let o={};void 0!==n.name&&(o.name=n.name),void 0!==n.capacity&&(o.capacity=parseInt(n.capacity)),void 0!==n.posX&&(o.posX=n.posX),void 0!==n.posY&&(o.posY=n.posY),void 0!==n.shape&&(o.shape=n.shape),void 0!==n.floorAreaId&&(o.floorAreaId=n.floorAreaId||null),void 0!==n.isActive&&(o.isActive=n.isActive);let p=await u._.restTable.update({where:{id:s},data:o});return i.NextResponse.json({table:p})}catch{return i.NextResponse.json({error:"Server error"},{status:500})}}async function l(e,{params:t}){try{if(!await (0,c.ts)())return i.NextResponse.json({error:"Unauthorized"},{status:401});let{id:e}=await t;return await u._.restTable.delete({where:{id:e}}),i.NextResponse.json({success:!0})}catch{return i.NextResponse.json({error:"Server error"},{status:500})}}let d=new n.AppRouteRouteModule({definition:{kind:a.x.APP_ROUTE,page:"/api/tables/[id]/route",pathname:"/api/tables/[id]",filename:"route",bundlePath:"app/api/tables/[id]/route"},resolvedPagePath:"D:\\PROJECT\\resto-saas\\src\\app\\api\\tables\\[id]\\route.ts",nextConfigOutput:"",userland:s}),{requestAsyncStorage:x,staticGenerationAsyncStorage:f,serverHooks:v}=d,h="/api/tables/[id]/route";function m(){return(0,o.patchFetch)({serverHooks:v,staticGenerationAsyncStorage:f})}},95456:(e,t,r)=>{r.d(t,{Gv:()=>l,MH:()=>v,PT:()=>h,RA:()=>d,WX:()=>x,c_:()=>p,ts:()=>f});var s=r(41482),n=r.n(s),a=r(42023),o=r.n(a),i=r(71615),u=r(8194);let c=process.env.JWT_SECRET||"fallback-secret-change-me";async function p(e){return o().hash(e,12)}async function l(e,t){return o().compare(e,t)}function d(e){return n().sign(e,c,{expiresIn:"7d"})}function x(e){try{return n().verify(e,c)}catch{return null}}async function f(){let e=await (0,i.cookies)(),t=e.get("token")?.value;if(!t)return null;let r=x(t);return r?await u._.user.findUnique({where:{id:r.userId},include:{tenant:!0,store:!0}}):null}function v(e,t){return t.includes(e)}function h(e){return!["owner","admin"].includes(e.role)&&!!e.storeId&&!!e.store&&!e.store.isActive}},8194:(e,t,r)=>{r.d(t,{_:()=>n});let s=require("@prisma/client"),n=globalThis.prisma??new s.PrismaClient}};var t=require("../../../../webpack-runtime.js");t.C(e);var r=e=>t(t.s=e),s=t.X(0,[8948,5972,4261,2023],()=>r(89200));module.exports=s})();