"use strict";(()=>{var e={};e.id=873,e.ids=[873],e.modules={399:e=>{e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},517:e=>{e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},3869:(e,t,n)=>{n.r(t),n.d(t,{originalPathname:()=>h,patchFetch:()=>v,requestAsyncStorage:()=>i,routeModule:()=>l,serverHooks:()=>p,staticGenerationAsyncStorage:()=>d});var a={};n.r(a),n.d(a,{GET:()=>u});var r=n(3036),o=n(5736),s=n(5262),c=n(7698);async function u(e){let t=new URL(e.url),n=t.searchParams.get("project")??"",a=n&&"default"!==n?`/projects/${encodeURIComponent(n)}/events`:"/events",r={Accept:"text/event-stream"},o=e.headers.get("authorization"),s=t.searchParams.get("access_token");o?r.Authorization=o:s&&(r.Authorization=`Bearer ${s}`);let u=e.headers.get("last-event-id");u&&(r["Last-Event-ID"]=u);try{let e=await fetch(`${c.Wx}${a}`,{cache:"no-store",headers:r});if(!e.ok||!e.body){let e=new ReadableStream({start(e){e.enqueue(new TextEncoder().encode('event: error\ndata: {"reason":"unavailable"}\n\n')),e.close()}});return new Response(e,{status:200,headers:{"content-type":"text/event-stream","cache-control":"no-cache"}})}let t=new TextEncoder,n=e.body.getReader(),o=null,s=new ReadableStream({start(e){e.enqueue(t.encode(": connected\n\n")),o=setInterval(()=>{try{e.enqueue(t.encode(": keepalive\n\n"))}catch{}},3e3),function t(){n.read().then(({done:n,value:a})=>{if(n){o&&clearInterval(o),e.close();return}a&&e.enqueue(a),t()}).catch(()=>{o&&clearInterval(o);try{e.close()}catch{}})}()},cancel(){o&&clearInterval(o),n.cancel().catch(()=>{})}});return new Response(s,{status:200,headers:{"content-type":"text/event-stream","cache-control":"no-cache","x-accel-buffering":"no"}})}catch{return new Response(new ReadableStream({start(e){e.enqueue(new TextEncoder().encode('event: error\ndata: {"reason":"unavailable"}\n\n')),e.close()}}),{status:200,headers:{"content-type":"text/event-stream","cache-control":"no-cache"}})}}let l=new r.AppRouteRouteModule({definition:{kind:o.x.APP_ROUTE,page:"/api/events/route",pathname:"/api/events",filename:"route",bundlePath:"app/api/events/route"},resolvedPagePath:"/home/runner/work/neat/neat/packages/web/app/api/events/route.ts",nextConfigOutput:"standalone",userland:a}),{requestAsyncStorage:i,staticGenerationAsyncStorage:d,serverHooks:p}=l,h="/api/events/route";function v(){return(0,s.patchFetch)({serverHooks:p,staticGenerationAsyncStorage:d})}},3036:(e,t,n)=>{e.exports=n(517)},7698:(e,t,n)=>{n.d(t,{Wx:()=>a,s0:()=>s});let a=process.env.NEAT_API_URL??process.env.NEAT_CORE_URL??"http://localhost:8080",r="1"===process.env.NEAT_DEMO,o=["authorization","last-event-id"];async function s(e,t,n){try{let t=await fetch(e,{cache:"no-store",headers:function(e){if(!e)return;let t={};for(let n of o){let a=e.headers.get(n);a&&(t[n]=a)}return Object.keys(t).length>0?t:void 0}(n)}),a=await t.text();return new Response(a,{status:t.status,headers:{"content-type":t.headers.get("content-type")??"application/json"}})}catch{if(r)return t();return Response.json({error:"failed to reach neat-core",coreUrl:a},{status:502})}}}};var t=require("../../../webpack-runtime.js");t.C(e);var n=e=>t(t.s=e),a=t.X(0,[522],()=>n(3869));module.exports=a})();