"use strict";(()=>{var e={};e.id=3324,e.ids=[3324],e.modules={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")},17702:e=>{e.exports=require("events")},13076:(e,t,r)=>{r.r(t),r.d(t,{originalPathname:()=>h,patchFetch:()=>f,requestAsyncStorage:()=>m,routeModule:()=>c,serverHooks:()=>g,staticGenerationAsyncStorage:()=>v});var n={};r.r(n),r.d(n,{GET:()=>l,dynamic:()=>u,runtime:()=>p});var s=r(49303),a=r(88716),i=r(60670),o=r(8194),d=r(64434);let u="force-dynamic",p="nodejs";async function l(e){let t=e.nextUrl.searchParams.get("tenantSlug"),r=e.nextUrl.searchParams.get("storeSlug");if(!t||!r)return new Response("Missing params",{status:400});let n=await o._.tenant.findUnique({where:{slug:t}});if(!n)return new Response("Not found",{status:404});let s=await o._.store.findFirst({where:{tenantId:n.id,slug:r}});return s?new Response(new ReadableStream({start(t){let r=new TextEncoder;t.enqueue(r.encode(`data: ${JSON.stringify({type:"connected"})}

`));let a=setInterval(()=>{try{t.enqueue(r.encode(`: keep-alive

`))}catch{clearInterval(a)}},3e4),i=e=>{if(e.tenantId===n.id&&e.storeId===s.id&&["order_updated","order_item_updated"].includes(e.type))try{t.enqueue(r.encode(`event: ${e.type}
data: ${JSON.stringify(e.data)}

`))}catch{o()}},o=()=>{clearInterval(a),d.d.removeListener("sse_event",i);try{t.close()}catch{}};d.d.on("sse_event",i),e.signal.addEventListener("abort",o)}}),{headers:{"Content-Type":"text/event-stream","Cache-Control":"no-cache, no-transform",Connection:"keep-alive","X-Accel-Buffering":"no"}}):new Response("Not found",{status:404})}let c=new s.AppRouteRouteModule({definition:{kind:a.x.APP_ROUTE,page:"/api/public/sse/orders/route",pathname:"/api/public/sse/orders",filename:"route",bundlePath:"app/api/public/sse/orders/route"},resolvedPagePath:"D:\\PROJECT\\resto-saas\\src\\app\\api\\public\\sse\\orders\\route.ts",nextConfigOutput:"",userland:n}),{requestAsyncStorage:m,staticGenerationAsyncStorage:v,serverHooks:g}=c,h="/api/public/sse/orders/route";function f(){return(0,i.patchFetch)({serverHooks:g,staticGenerationAsyncStorage:v})}},49303:(e,t,r)=>{e.exports=r(30517)},8194:(e,t,r)=>{r.d(t,{_:()=>s});let n=require("@prisma/client"),s=globalThis.prisma??new n.PrismaClient},64434:(e,t,r)=>{r.d(t,{d:()=>s});var n=r(17702);let s=globalThis.orderEmitter??new n.EventEmitter;s.setMaxListeners(100)}};var t=require("../../../../../webpack-runtime.js");t.C(e);var r=e=>t(t.s=e),n=t.X(0,[8948],()=>r(13076));module.exports=n})();