"use strict";(()=>{var e={};e.id=9359,e.ids=[9359],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")},59184:(e,t,r)=>{r.r(t),r.d(t,{originalPathname:()=>y,patchFetch:()=>h,requestAsyncStorage:()=>x,routeModule:()=>d,serverHooks:()=>m,staticGenerationAsyncStorage:()=>f});var n={};r.r(n),r.d(n,{GET:()=>p,POST:()=>l});var s=r(49303),a=r(88716),o=r(60670),i=r(87070),u=r(8194),c=r(95456);async function p(e){try{let t=await (0,c.ts)();if(!t)return i.NextResponse.json({error:"Unauthorized"},{status:401});let r=e.nextUrl.searchParams.get("storeId"),n=e.nextUrl.searchParams.get("type"),s="true"===e.nextUrl.searchParams.get("unreadOnly"),a={tenantId:t.tenantId};r&&(a.storeId=r),t.storeId&&(a.storeId=t.storeId),n&&(a.type=n),s&&(a.isRead=!1);let o=await u._.notification.findMany({where:a,orderBy:{createdAt:"desc"},take:50});return i.NextResponse.json({notifications:o})}catch{return i.NextResponse.json({error:"Server error"},{status:500})}}async function l(e){try{let{tenantId:t,storeId:r,type:n,title:s,message:a,data:o}=await e.json(),c=await u._.notification.create({data:{tenantId:t,storeId:r,type:n,title:s,message:a,data:o?JSON.stringify(o):null}});return i.NextResponse.json({notification:c},{status:201})}catch(e){return console.error("Notification error:",e),i.NextResponse.json({error:"Server error"},{status:500})}}let d=new s.AppRouteRouteModule({definition:{kind:a.x.APP_ROUTE,page:"/api/notifications/route",pathname:"/api/notifications",filename:"route",bundlePath:"app/api/notifications/route"},resolvedPagePath:"D:\\PROJECT\\resto-saas\\src\\app\\api\\notifications\\route.ts",nextConfigOutput:"",userland:n}),{requestAsyncStorage:x,staticGenerationAsyncStorage:f,serverHooks:m}=d,y="/api/notifications/route";function h(){return(0,o.patchFetch)({serverHooks:m,staticGenerationAsyncStorage:f})}},95456:(e,t,r)=>{r.d(t,{Gv:()=>l,MH:()=>m,PT:()=>y,RA:()=>d,WX:()=>x,c_:()=>p,ts:()=>f});var n=r(41482),s=r.n(n),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 s().sign(e,c,{expiresIn:"7d"})}function x(e){try{return s().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 m(e,t){return t.includes(e)}function y(e){return!["owner","admin"].includes(e.role)&&!!e.storeId&&!!e.store&&!e.store.isActive}},8194:(e,t,r)=>{r.d(t,{_:()=>s});let n=require("@prisma/client"),s=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(59184));module.exports=n})();