@zuplo/graphql 5.1815.0 → 5.1817.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.minified.js CHANGED
@@ -32,7 +32,7 @@
32
32
  `))):c=t.stylize("[Circular]","special")),Fh(a)){if(s&&i.match(/^\d+$/))return c;a=JSON.stringify(""+i),a.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(a=a.substr(1,a.length-2),a=t.stylize(a,"name")):(a=a.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),a=t.stylize(a,"string"))}return a+": "+c}o(Zu,"formatProperty");function Gv(t,e){if(Fh(e))return t.stylize("undefined","undefined");if(Hh(e)){let r="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return t.stylize(r,"string")}if(jv(e))return t.stylize(""+e,"number");if(qv(e))return t.stylize(""+e,"boolean");if(qh(e))return t.stylize("null","null")}o(Gv,"formatPrimitive");function Kv(t,e,r){let n=0;return t.reduce(function(s,a){return n++,a.indexOf(`
33
33
  `)>=0&&n++,s+a.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60?r[0]+(e===""?"":e+`
34
34
  `)+" "+t.join(`,
35
- `)+" "+r[1]:r[0]+e+" "+t.join(", ")+" "+r[1]}o(Kv,"reduceToSingleString")});var Vh=_(Mo=>{"use strict";Object.defineProperty(Mo,"__esModule",{value:!0});Mo.format=void 0;var Jv=Uh(),zv=jh(),Wv=o((t,...e)=>(0,Jv.format)(zv.inspect,t,e),"format");Mo.format=Wv});var kr=_(or=>{"use strict";Object.defineProperty(or,"__esModule",{value:!0});or.debug=or.withoutEnv=or.Debugger=void 0;var Qv=Mh(),Yv=Vh(),Uo=class{static{o(this,"Debugger")}manager;ns;color;last;enabled;constructor(e,r){this.manager=e,this.ns=r,this.color=(0,Qv.generateColor)(r),this.last=0,this.enabled=e.enabled.some(n=>n.test(r))}log(...e){if(!this.enabled)return;let r,n=e[0];typeof n=="function"?r=n():r=String(n);let i=Date.now()-(this.last||Date.now());r=(0,Yv.format)(r,...e);let s=`${this.color(this.ns)} ${r} ${this.color(`+${i}ms`)}`;console.log(s),this.last=Date.now()}};or.Debugger=Uo;var ko=class{static{o(this,"DebugManager")}debuggers;enabled;constructor(e){this.debuggers=new Map,this.enabled=e??[]}};function Bh(t){return!t||t.length===0?[]:(t=t.replace(/\s/g,"").replace(/\*/g,".+"),t.split(",").map(e=>new RegExp(`^${e}$`)))}o(Bh,"extract");var Si;function Zv(t){t||(t=[]),typeof t=="string"&&(t=Bh(t)),Si=new ko(t)}o(Zv,"withoutEnv");or.withoutEnv=Zv;function Xv(t){let e=globalThis.DEBUG;Si||(Si=new ko(Bh(e)));let r=new Uo(Si,t);return Si.debuggers.set(t,r),Object.assign(r.log.bind(r),{self:r})}o(Xv,"debug");or.debug=Xv});var Ho=_(ln=>{"use strict";Object.defineProperty(ln,"__esModule",{value:!0});ln.ProblemResponseFormatter=ln.InternalProblemResponseFormatter=void 0;var eT=k(),Fo=class t{static{o(this,"InternalProblemResponseFormatter")}static problemResponseFormat=async e=>{let r=e.problem,n=JSON.stringify(r,null,2);return new Response(n,{status:e.problem.status,statusText:e.statusText,headers:{...e.additionalHeaders,"content-type":"application/problem+json"}})};static setProblemResponseFormat(e){e&&(t.problemResponseFormat=(r,n,i)=>{try{return e(r,n,i)}catch(s){throw new eT.RuntimeError("Error in custom 'problemResponseFormat'",{cause:s})}})}};ln.InternalProblemResponseFormatter=Fo;var tl=class{static{o(this,"ProblemResponseFormatter")}static async format(e,r,n){return await Fo.problemResponseFormat(e,r,n)}};ln.ProblemResponseFormatter=tl});var Kh=_(qo=>{"use strict";Object.defineProperty(qo,"__esModule",{value:!0});qo.deepFreeze=void 0;function Gh(t){for(let e in t){let r=t[e];r&&typeof r=="object"&&Gh(r)}return Object.freeze(t)}o(Gh,"deepFreeze");qo.deepFreeze=Gh});var Ge=_($o=>{"use strict";Object.defineProperty($o,"__esModule",{value:!0});$o.ZuploRequest=void 0;var Jh=Kh(),rl=class t extends Request{static{o(this,"ZuploRequest")}#e=void 0;#t;constructor(e,r){super(e,r);let n=r?.params;n?this.#t=n:e instanceof t?this.#t=e.#t:this.#t={};let i=r?.user;i?this.user=i:e instanceof t&&(this.user=e.user)}get query(){if(this.#e===void 0){let e={},r=new URL(this.url).searchParams;for(let[n,i]of r.entries())e[n]=i;this.#e=e}return(0,Jh.deepFreeze)(this.#e)}get params(){return(0,Jh.deepFreeze)(this.#t)}user};$o.ZuploRequest=rl});var Rt=_(Se=>{"use strict";Object.defineProperty(Se,"__esModule",{value:!0});Se.initializeRuntime=Se.invokeOnResponseSendingFinalExtensions=Se.invokeOnResponseSendingExtensions=Se.invokeOnRequestExtensions=Se.plugins=Se.runtimeExtensions=Se.SystemRuntimePlugin=Se.RuntimePlugin=void 0;var zh=k(),tT=Ho(),rT=Ge(),Vo=class{static{o(this,"RuntimePlugin")}};Se.RuntimePlugin=Vo;var Bo=class extends Vo{static{o(this,"SystemRuntimePlugin")}async initialize(e){return Promise.resolve()}registerRoutes(e,r){}};Se.SystemRuntimePlugin=Bo;Se.runtimeExtensions={};var nl=[];Se.plugins=nl;var Wh=[],Qh=[],Yh=[],jo={addPlugin(t){nl.push(t)},addRequestHook(t){Wh.push(t)},addResponseSendingHook(t){Qh.push(t)},addResponseSendingFinalHook(t){Yh.push(t)}},nT=o(async(t,e)=>{let r=t;for(let n of Wh){let i=await n(r,e);if(i instanceof rT.ZuploRequest)r=i;else{if(i instanceof Response)return i;throw new zh.ConfigurationError(`Invalid state - the OnRequest hook must return a ZuploRequest or Response. Received ${typeof r}.`)}}return r},"invokeOnRequestExtensions");Se.invokeOnRequestExtensions=nT;var iT=o(async(t,e,r)=>{let n=t;for(let i of Qh){let s=await i(t,e,r);if(s instanceof Response)n=s;else throw new zh.ConfigurationError(`Invalid state - the OnResponseSending hook must return a Response. Received ${typeof n}.`)}return n},"invokeOnResponseSendingExtensions");Se.invokeOnResponseSendingExtensions=iT;var oT=o(async(t,e,r)=>{for(let n of Yh)await n(t,e,r)},"invokeOnResponseSendingFinalExtensions");Se.invokeOnResponseSendingFinalExtensions=oT;async function sT(t=()=>Promise.resolve()){await t(jo),Se.runtimeExtensions.value=jo;for(let e of nl)e instanceof Bo&&await e.initialize(jo);tT.InternalProblemResponseFormatter.setProblemResponseFormat(jo.problemResponseFormat)}o(sT,"initializeRuntime");Se.initializeRuntime=sT});var il=_(sr=>{"use strict";Object.defineProperty(sr,"__esModule",{value:!0});sr.serialize=sr.ContentTypes=void 0;sr.ContentTypes={Json:"application/json",Form:"application/x-www-form-urlencoded"};function aT(t,e){if(t!==null)return e&&typeof t=="string"?t:typeof t=="object"&&e?.startsWith(sr.ContentTypes.Form)?new URLSearchParams(t).toString():typeof t=="object"&&e?.startsWith(sr.ContentTypes.Json)||!e?JSON.stringify(t):t}o(aT,"serialize");sr.serialize=aT});var ol=_(Go=>{"use strict";Object.defineProperty(Go,"__esModule",{value:!0});Go.isSystemRoute=void 0;var Zh=Fr();function cT(t){return Zh.Gateway.instance.runtimeSettings.developerPortal.enabled&&t.pathname.startsWith(Zh.Gateway.instance.runtimeSettings.developerPortal.sitePathname)||t.pathname.startsWith("/__zuplo/")}o(cT,"isSystemRoute");Go.isSystemRoute=cT});var Bt=_(Ko=>{"use strict";Object.defineProperty(Ko,"__esModule",{value:!0});Ko.Pipeline=void 0;var sl=Hr(),Xh=Rt(),uT=il(),lT=ie(),dT=ol(),al=class{static{o(this,"Pipeline")}constructor(e){this.execute=this.#t(e)}execute;#e=(e,r)=>async(n,i)=>{try{return await e(n,i)}catch(s){return i.log.error("Error executing request handler.",s),r.errorHandler(n,i,s)}};#t=({processors:e,gateway:r,handler:n})=>async(i,s)=>{let a=[...e],c=o(async b=>{let v=a.pop();return v?v(i,s,r,c):await this.#e(async g=>{let S=await n(g,s);return pT(S)},r)(b,s)},"nextPipe"),l=await c(i),d=new URL(i.url);if((0,dT.isSystemRoute)(d)&&lT.Environment.instance.build.COMPATIBILITY_FLAGS.doNotRunHooksOnSystemRoutes)return l;let p=new sl.ResponseSendingEvent(i,l);s.dispatchEvent(p);let f=sl.ZuploContextExtensions.getContextExtensions(s),h=f.latestRequest,m;try{m=await p.mutableResponse}catch(b){return s.log.error(b),r.errorHandler(i,s,b)}try{m=await f.onResponseSending(m,h,s)}catch(b){return s.log.error(`Error invoking 'context.onResponseSending' hook: '${b.message}'`,b),r.errorHandler(i,s,b)}try{m=await(0,Xh.invokeOnResponseSendingExtensions)(m,h,s)}catch(b){return s.log.error(`Error invoking 'context.onResponseSending' hook: '${b.message}'`,b),r.errorHandler(i,s,b)}s.dispatchEvent(new sl.ResponseSentEvent(i,m));try{await f.onResponseSendingFinal(l,h,s)}catch(b){throw s.log.error(`Error invoking 'runtime.onResponseSending' hook: '${b.message}'`,b),b}try{await(0,Xh.invokeOnResponseSendingFinalExtensions)(l,h,s)}catch(b){throw s.log.error(`Error invoking 'runtime.onResponseSending' hook: '${b.message}'`,b),b}return m}};Ko.Pipeline=al;function pT(t){return t instanceof Response?t:typeof t>"u"?new Response:new Response((0,uT.serialize)(t),{headers:{"content-type":"application/json"}})}o(pT,"resultToResponse")});var zo=_(Jo=>{"use strict";Object.defineProperty(Jo,"__esModule",{value:!0});Jo.MetricsPlugin=void 0;var fT=Rt(),cl=class extends fT.RuntimePlugin{static{o(this,"MetricsPlugin")}};Jo.MetricsPlugin=cl});var Ze=_(Wo=>{"use strict";Object.defineProperty(Wo,"__esModule",{value:!0});Wo.SystemLogMap=void 0;var hT=k(),ul=class t{static{o(this,"SystemLogMap")}static#e=new WeakMap;static getLogger(e){let r=t.#e.get(e);if(!r){let n=`No system logger found for context with requestId '${e.requestId}'`;throw console.error(n),new hT.SystemError(n)}return r}static addLogger(e,r){t.#e.set(e,r)}};Wo.SystemLogMap=ul});var Ne=_(Qo=>{"use strict";Object.defineProperty(Qo,"__esModule",{value:!0});Qo.BatchDispatch=void 0;var ll=class{static{o(this,"BatchDispatch")}constructor(e,r,n,i){this.#t=e,this.#o=r,this.#n=n,this.#r=i}#e=void 0;#t;#r;#n;#i=[];#o;enqueue=e=>{this.#i.push(e),this.#e||(this.#e=new Promise(r=>{setTimeout(()=>{if(this.#i.length>0){let n=[...this.#i];this.#i.length=0,this.#e=void 0,this.#n(n).catch(i=>{this.#r&&this.#r.error(`Uncaught error in BatchDispatcher named '${this.#t}'}`,i.message,i.stack)}).finally(()=>{r()})}},this.#o)}))};waitUntilFlushed=async()=>{if(this.#e)return this.#e}};Qo.BatchDispatch=ll});var tm=_(Zo=>{"use strict";Object.defineProperty(Zo,"__esModule",{value:!0});Zo.EllieMetricsTransport=void 0;var em=Ze(),mT=Ne(),Yo=ie(),dl=class{static{o(this,"EllieMetricsTransport")}#e;#t;#r;constructor(e){this.#r=Yo.Environment.instance.loggingId,this.#e=e,this.#t=new mT.BatchDispatch("ellie-metrics-transport",10,this.dispatchFunction,em.SystemLogMap.getLogger(e))}pushMetrics(e,r){this.#r!==void 0&&(this.#t.enqueue(e),r.waitUntil(this.#t.waitUntilFlushed()))}dispatchFunction=async e=>{if(e.length===0)return;let r,{loggingId:n,remoteLogURL:i,deploymentName:s}=Yo.Environment.instance,a=e.map(c=>{let u=Object.assign({},c);return delete u.requestContentLength,delete u.responseContentLength,u});if(n&&s&&(r=`${i}/v1-alpha/metrics?loggingId=${encodeURI(n)}&deploymentName=${encodeURI(s)}`),r){let c=await fetch(r,{method:"POST",body:JSON.stringify(a),headers:{"content-type":"application/json","zp-dn":Yo.Environment.instance.deploymentName??"unknown","user-agent":Yo.Environment.instance.systemUserAgent}});if(!c.ok){let u=await c.text();em.SystemLogMap.getLogger(this.#e).error(`Metrics POST responded ${c.status}: ${c.statusText}`,u)}}}};Zo.EllieMetricsTransport=dl});var mt=_(qr=>{"use strict";Object.defineProperty(qr,"__esModule",{value:!0});qr.systemNoVersion=qr.SystemRouteConfiguration=void 0;var pl=class{static{o(this,"SystemRouteConfiguration")}constructor({label:e,path:r,methods:n,systemRouteName:i,corsPolicy:s="none"}){this.label=e,this.path=r,this.methods=n,this.corsPolicy=s,this.version=qr.systemNoVersion.name,this.handler={export:"SYSTEM_IGNORED",module:"SYSTEM_IGNORED"},this.systemRouteName=i}label;path;methods;handler;corsPolicy;version;policies;systemRouteName;raw(){return{}}};qr.SystemRouteConfiguration=pl;qr.systemNoVersion={name:"__system-no-version",pathPrefix:""}});var ar=_(Xo=>{"use strict";Object.defineProperty(Xo,"__esModule",{value:!0});Xo.metricsProcessor=void 0;var rm=un(),yT=Hr(),gT=Rt(),bT=zo(),_T=tm(),ET=mt(),wT=o(async(t,e,r,n)=>{let i=new Date,s=Date.now(),a=await n(t),c=t.headers.get(rm.RAY_ID_HEADER)??void 0,u=t.headers.get(rm.TRUE_CLIENT_IP)??void 0,l=e.incomingRequestProperties,d;e.route instanceof ET.SystemRouteConfiguration&&(d=e.route.systemRouteName);let p=yT.ZuploContextExtensions.getContextExtensions(e).latestRequest,f={timestamp:i,statusCode:a.status,durationMs:Date.now()-s,requestContentLength:t.headers.get("content-length")?Number(t.headers.get("content-length")):void 0,responseContentLength:a.headers.get("content-length")?Number(a.headers.get("content-length")):void 0,routePath:e.route?.path??"SYSTEM_OR_NOT_FOUND",systemRouteName:d,requestId:e.requestId,method:t.method,asn:l.asn,asOrganization:l.asOrganization,colo:l.colo,continent:l.continent,country:l.country,city:l.city,latitude:l.latitude,longitude:l.longitude,rayId:c,instanceId:r.instanceId,userSub:p.user?.sub,clientIp:u},h=[];return h.push(new _T.EllieMetricsTransport(e)),gT.plugins.forEach(m=>{if(m instanceof bT.MetricsPlugin){let b=m.getTransport();h.push(b)}}),h.forEach(m=>{m.pushMetrics(f,e)}),a},"metricsProcessor");Xo.metricsProcessor=wT});var fl=_(es=>{"use strict";Object.defineProperty(es,"__esModule",{value:!0});es.SystemRouteName=void 0;var nm;(function(t){t.Build="build-data",t.CorsPreflight="cors-preflight",t.DeveloperPortal="developer-portal",t.DeveloperPortalLegacy="developer-portal-legacy",t.StripePlugin="stripe-plugin",t.EmptyGatewayCatchall="empty-gateway-catchall",t.Ping="ping",t.UnmatchedPath="unmatched-path"})(nm||(es.SystemRouteName=nm={}))});var om=_(im=>{"use strict";Object.defineProperty(im,"__esModule",{value:!0})});var $r=_(cr=>{"use strict";var vT=cr&&cr.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),sm=cr&&cr.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&vT(e,t,r)};Object.defineProperty(cr,"__esModule",{value:!0});sm(fl(),cr);sm(om(),cr)});var am=_(ts=>{"use strict";Object.defineProperty(ts,"__esModule",{value:!0});ts.registerBuildRoute=void 0;var TT=Gt(),ST=Bt(),IT=ar(),PT=$r(),AT=mt(),RT=Ze(),OT=ie(),NT=o((t,e)=>{let r=o(async(s,a)=>{let u=new URL(s.url).hostname.toLowerCase();if(!u.endsWith(".zuplo.app")&&!u.endsWith(".zuplo.dev")&&!u.endsWith(".fly.dev")&&!u.endsWith("zuplotest.com")&&u!=="localhost")return TT.HttpProblems.notFound(s,a);let l=OT.Environment.instance.build,d={buildId:l.BUILD_ID,zuploVersion:l.ZUPLO_VERSION,apiVersion:l.API_VERSION,gitSha:l.GIT_SHA,timestamp:l.TIMESTAMP,isProduction:l.IS_PRODUCTION},p=s.url.toString().split("?");return p.length>0&&new URLSearchParams(p[1]).get("system_log")==="true"&&RT.SystemLogMap.getLogger(a).error("Test System Log",d),new Response(JSON.stringify(d,null,2),{status:200,headers:{"content-type":"application/json"}})},"buildRouteHandler"),n=new ST.Pipeline({processors:[IT.metricsProcessor],handler:r,gateway:e}),i=new AT.SystemRouteConfiguration({label:"SYSTEM_BUILD_ROUTE",methods:["GET"],path:"/__zuplo/build",systemRouteName:PT.SystemRouteName.Build});t.addRoute(i,n.execute)},"registerBuildRoute");ts.registerBuildRoute=NT});var hl=_(dn=>{"use strict";Object.defineProperty(dn,"__esModule",{value:!0});dn.HTTP_STATUS_TITLES=dn.HttpStatusCode=void 0;var cm;(function(t){t[t.CONTINUE=100]="CONTINUE",t[t.SWITCHING_PROTOCOLS=101]="SWITCHING_PROTOCOLS",t[t.PROCESSING=102]="PROCESSING",t[t.EARLY_HINTS=103]="EARLY_HINTS",t[t.OK=200]="OK",t[t.CREATED=201]="CREATED",t[t.ACCEPTED=202]="ACCEPTED",t[t.NON_AUTHORITATIVE_INFORMATION=203]="NON_AUTHORITATIVE_INFORMATION",t[t.NO_CONTENT=204]="NO_CONTENT",t[t.RESET_CONTENT=205]="RESET_CONTENT",t[t.PARTIAL_CONTENT=206]="PARTIAL_CONTENT",t[t.MULTI_STATUS=207]="MULTI_STATUS",t[t.ALREADY_REPORTED=208]="ALREADY_REPORTED",t[t.IM_USED=226]="IM_USED",t[t.MULTIPLE_CHOICES=300]="MULTIPLE_CHOICES",t[t.MOVED_PERMANENTLY=301]="MOVED_PERMANENTLY",t[t.FOUND=302]="FOUND",t[t.SEE_OTHER=303]="SEE_OTHER",t[t.NOT_MODIFIED=304]="NOT_MODIFIED",t[t.USE_PROXY=305]="USE_PROXY",t[t.SWITCH_PROXY=306]="SWITCH_PROXY",t[t.TEMPORARY_REDIRECT=307]="TEMPORARY_REDIRECT",t[t.PERMANENT_REDIRECT=308]="PERMANENT_REDIRECT",t[t.BAD_REQUEST=400]="BAD_REQUEST",t[t.UNAUTHORIZED=401]="UNAUTHORIZED",t[t.PAYMENT_REQUIRED=402]="PAYMENT_REQUIRED",t[t.FORBIDDEN=403]="FORBIDDEN",t[t.NOT_FOUND=404]="NOT_FOUND",t[t.METHOD_NOT_ALLOWED=405]="METHOD_NOT_ALLOWED",t[t.NOT_ACCEPTABLE=406]="NOT_ACCEPTABLE",t[t.PROXY_AUTHENTICATION_REQUIRED=407]="PROXY_AUTHENTICATION_REQUIRED",t[t.REQUEST_TIMEOUT=408]="REQUEST_TIMEOUT",t[t.CONFLICT=409]="CONFLICT",t[t.GONE=410]="GONE",t[t.LENGTH_REQUIRED=411]="LENGTH_REQUIRED",t[t.PRECONDITION_FAILED=412]="PRECONDITION_FAILED",t[t.CONTENT_TOO_LARGE=413]="CONTENT_TOO_LARGE",t[t.PAYLOAD_TOO_LARGE=413]="PAYLOAD_TOO_LARGE",t[t.URI_TOO_LONG=414]="URI_TOO_LONG",t[t.UNSUPPORTED_MEDIA_TYPE=415]="UNSUPPORTED_MEDIA_TYPE",t[t.RANGE_NOT_SATISFIABLE=416]="RANGE_NOT_SATISFIABLE",t[t.EXPECTATION_FAILED=417]="EXPECTATION_FAILED",t[t.I_AM_A_TEAPOT=418]="I_AM_A_TEAPOT",t[t.MISDIRECTED_REQUEST=421]="MISDIRECTED_REQUEST",t[t.UNPROCESSABLE_ENTITY=422]="UNPROCESSABLE_ENTITY",t[t.UNPROCESSABLE_CONTENT=422]="UNPROCESSABLE_CONTENT",t[t.LOCKED=423]="LOCKED",t[t.FAILED_DEPENDENCY=424]="FAILED_DEPENDENCY",t[t.TOO_EARLY=425]="TOO_EARLY",t[t.UPGRADE_REQUIRED=426]="UPGRADE_REQUIRED",t[t.PRECONDITION_REQUIRED=428]="PRECONDITION_REQUIRED",t[t.TOO_MANY_REQUESTS=429]="TOO_MANY_REQUESTS",t[t.REQUEST_HEADER_FIELDS_TOO_LARGE=431]="REQUEST_HEADER_FIELDS_TOO_LARGE",t[t.UNAVAILABLE_FOR_LEGAL_REASONS=451]="UNAVAILABLE_FOR_LEGAL_REASONS",t[t.INTERNAL_SERVER_ERROR=500]="INTERNAL_SERVER_ERROR",t[t.NOT_IMPLEMENTED=501]="NOT_IMPLEMENTED",t[t.BAD_GATEWAY=502]="BAD_GATEWAY",t[t.SERVICE_UNAVAILABLE=503]="SERVICE_UNAVAILABLE",t[t.GATEWAY_TIMEOUT=504]="GATEWAY_TIMEOUT",t[t.HTTP_VERSION_NOT_SUPPORTED=505]="HTTP_VERSION_NOT_SUPPORTED",t[t.VARIANT_ALSO_NEGOTIATES=506]="VARIANT_ALSO_NEGOTIATES",t[t.INSUFFICIENT_STORAGE=507]="INSUFFICIENT_STORAGE",t[t.LOOP_DETECTED=508]="LOOP_DETECTED",t[t.NOT_EXTENDED=510]="NOT_EXTENDED",t[t.NETWORK_AUTHENTICATION_REQUIRED=511]="NETWORK_AUTHENTICATION_REQUIRED"})(cm||(dn.HttpStatusCode=cm={}));dn.HTTP_STATUS_TITLES={100:"Continue",101:"Switching Protocols",102:"Processing",103:"Early Hints",200:"OK",201:"Created",202:"Accepted",203:"Non-Authoritative Information",204:"No Content",205:"Reset Content",206:"Partial Content",207:"Multi-Status",208:"Already Reported",226:"IM Used",300:"Multiple Choices",301:"Moved Permanently",302:"Found",303:"See Other",304:"Not Modified",305:"Use Proxy",306:"Switch Proxy",307:"Temporary Redirect",308:"Permanent Redirect",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Timeout",409:"Conflict",410:"Gone",411:"Length Required",412:"Precondition Failed",413:"Content Too Large",414:"URI Too Long",415:"Unsupported Media Type",416:"Range Not Satisfiable",417:"Expectation Failed",418:"I'm a teapot",421:"Misdirected Request",422:"Unprocessable Content",423:"Locked",424:"Failed Dependency",425:"Too Early",426:"Upgrade Required",428:"Precondition Required",429:"Too Many Requests",431:"Request Header Fields Too Large",451:"Unavailable For Legal Reasons",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Timeout",505:"HTTP Version Not Supported",506:"Variant Also Negotiates",507:"Insufficient Storage",508:"Loop Detected",510:"Not Extended",511:"Network Authentication Required"}});var yl=_(ml=>{"use strict";Object.defineProperty(ml,"__esModule",{value:!0});var CT={100:"Continue",101:"Switching Protocols",102:"Processing",103:"Early Hints",200:"OK",201:"Created",202:"Accepted",203:"Non-Authoritative Information",204:"No Content",205:"Reset Content",206:"Partial Content",207:"Multi-Status",208:"Already Reported",226:"IM Used",300:"Multiple Choices",301:"Moved Permanently",302:"Found",303:"See Other",304:"Not Modified",305:"Use Proxy",307:"Temporary Redirect",308:"Permanent Redirect",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Timeout",409:"Conflict",410:"Gone",411:"Length Required",412:"Precondition Failed",413:"Payload Too Large",414:"URI Too Long",415:"Unsupported Media Type",416:"Range Not Satisfiable",417:"Expectation Failed",418:"I'm a Teapot",421:"Misdirected Request",422:"Unprocessable Entity",423:"Locked",424:"Failed Dependency",425:"Too Early",426:"Upgrade Required",428:"Precondition Required",429:"Too Many Requests",431:"Request Header Fields Too Large",451:"Unavailable For Legal Reasons",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Timeout",505:"HTTP Version Not Supported",506:"Variant Also Negotiates",507:"Insufficient Storage",508:"Loop Detected",509:"Bandwidth Limit Exceeded",510:"Not Extended",511:"Network Authentication Required"};ml.default=CT});var pe=_(pn=>{"use strict";var xT=pn&&pn.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(pn,"__esModule",{value:!0});pn.HttpProblems=void 0;var LT=un(),H=hl(),DT=xT(yl()),MT=ie(),gl=Ho();function UT(t){return`${new URL(t.url).pathname}`}o(UT,"instance");function kT(t,e){let r={timestamp:new Date().toISOString(),requestId:e.requestId,buildId:MT.Environment.instance.build.BUILD_ID},n=t.headers.get(LT.RAY_ID_HEADER);return n&&(r.rayId=n),r}o(kT,"trace");var FT=o((t,e,r,n,i)=>({problem:{type:t.type,title:t.title,status:t.status,detail:t.detail,instance:UT(e),trace:kT(e,r),...n},additionalHeaders:i,statusText:DT.default[t.status]}),"merge"),bl=class{static{o(this,"HttpProblemsBase")}static format=(e,r,n)=>"problem"in e?gl.ProblemResponseFormatter.format(e,r,n):gl.ProblemResponseFormatter.format({problem:e},r,n);static getProblemFromStatus(e,r){return{type:`https://httpproblems.com/http-status/${e}`,status:e,title:H.HTTP_STATUS_TITLES[e],...r}}},_l=class extends bl{static{o(this,"HttpProblems")}static#e(e,r,n,i,s){let a=FT(this.getProblemFromStatus(e),r,n,i,s);return gl.ProblemResponseFormatter.format(a,r,n)}static continue=(e,r,n,i)=>this.#e(H.HttpStatusCode.OK,e,r,n,i);static switchingProtocols=(e,r,n,i)=>this.#e(H.HttpStatusCode.SWITCHING_PROTOCOLS,e,r,n,i);static processing=(e,r,n,i)=>this.#e(H.HttpStatusCode.PROCESSING,e,r,n,i);static earlyHints=(e,r,n,i)=>this.#e(H.HttpStatusCode.EARLY_HINTS,e,r,n,i);static ok=(e,r,n,i)=>this.#e(H.HttpStatusCode.OK,e,r,n,i);static created=(e,r,n,i)=>this.#e(H.HttpStatusCode.CREATED,e,r,n,i);static accepted=(e,r,n,i)=>this.#e(H.HttpStatusCode.ACCEPTED,e,r,n,i);static nonAuthoritativeInformation=(e,r,n,i)=>this.#e(H.HttpStatusCode.NON_AUTHORITATIVE_INFORMATION,e,r,n,i);static noContent=(e,r,n,i)=>this.#e(H.HttpStatusCode.NO_CONTENT,e,r,n,i);static resetContent=(e,r,n,i)=>this.#e(H.HttpStatusCode.RESET_CONTENT,e,r,n,i);static partialContent=(e,r,n,i)=>this.#e(H.HttpStatusCode.PARTIAL_CONTENT,e,r,n,i);static multiStatus=(e,r,n,i)=>this.#e(H.HttpStatusCode.MULTI_STATUS,e,r,n,i);static alreadyReported=(e,r,n,i)=>this.#e(H.HttpStatusCode.ALREADY_REPORTED,e,r,n,i);static imUsed=(e,r,n,i)=>this.#e(H.HttpStatusCode.IM_USED,e,r,n,i);static multipleChoices=(e,r,n,i)=>this.#e(H.HttpStatusCode.MULTIPLE_CHOICES,e,r,n,i);static movedPermanently=(e,r,n,i)=>this.#e(H.HttpStatusCode.MOVED_PERMANENTLY,e,r,n,i);static found=(e,r,n,i)=>this.#e(H.HttpStatusCode.FOUND,e,r,n,i);static seeOther=(e,r,n,i)=>this.#e(H.HttpStatusCode.SEE_OTHER,e,r,n,i);static notModified=(e,r,n,i)=>this.#e(H.HttpStatusCode.NOT_MODIFIED,e,r,n,i);static useProxy=(e,r,n,i)=>this.#e(H.HttpStatusCode.USE_PROXY,e,r,n,i);static switchProxy=(e,r,n,i)=>this.#e(H.HttpStatusCode.SWITCH_PROXY,e,r,n,i);static temporaryRedirect=(e,r,n,i)=>this.#e(H.HttpStatusCode.TEMPORARY_REDIRECT,e,r,n,i);static permanentRedirect=(e,r,n,i)=>this.#e(H.HttpStatusCode.PERMANENT_REDIRECT,e,r,n,i);static badRequest=(e,r,n,i)=>this.#e(H.HttpStatusCode.BAD_REQUEST,e,r,n,i);static unauthorized=(e,r,n,i)=>this.#e(H.HttpStatusCode.UNAUTHORIZED,e,r,n,i);static paymentRequired=(e,r,n,i)=>this.#e(H.HttpStatusCode.PAYMENT_REQUIRED,e,r,n,i);static forbidden=(e,r,n,i)=>this.#e(H.HttpStatusCode.FORBIDDEN,e,r,n,i);static notFound=(e,r,n,i)=>this.#e(H.HttpStatusCode.NOT_FOUND,e,r,n,i);static methodNotAllowed=(e,r,n,i)=>this.#e(H.HttpStatusCode.METHOD_NOT_ALLOWED,e,r,n,i);static notAcceptable=(e,r,n,i)=>this.#e(H.HttpStatusCode.NOT_ACCEPTABLE,e,r,n,i);static proxyAuthenticationRequired=(e,r,n,i)=>this.#e(H.HttpStatusCode.PROXY_AUTHENTICATION_REQUIRED,e,r,n,i);static requestTimeout=(e,r,n,i)=>this.#e(H.HttpStatusCode.REQUEST_TIMEOUT,e,r,n,i);static conflict=(e,r,n,i)=>this.#e(H.HttpStatusCode.CONFLICT,e,r,n,i);static gone=(e,r,n,i)=>this.#e(H.HttpStatusCode.GONE,e,r,n,i);static lengthRequired=(e,r,n,i)=>this.#e(H.HttpStatusCode.LENGTH_REQUIRED,e,r,n,i);static preconditionFailed=(e,r,n,i)=>this.#e(H.HttpStatusCode.PRECONDITION_FAILED,e,r,n,i);static contentTooLarge=(e,r,n,i)=>this.#e(H.HttpStatusCode.CONTENT_TOO_LARGE,e,r,n,i);static uriTooLong=(e,r,n,i)=>this.#e(H.HttpStatusCode.URI_TOO_LONG,e,r,n,i);static unsupportedMediaType=(e,r,n,i)=>this.#e(H.HttpStatusCode.UNSUPPORTED_MEDIA_TYPE,e,r,n,i);static rangeNotSatisfiable=(e,r,n,i)=>this.#e(H.HttpStatusCode.RANGE_NOT_SATISFIABLE,e,r,n,i);static expectationFailed=(e,r,n,i)=>this.#e(H.HttpStatusCode.EXPECTATION_FAILED,e,r,n,i);static imATeapot=(e,r,n,i)=>this.#e(H.HttpStatusCode.I_AM_A_TEAPOT,e,r,n,i);static misdirectedRequest=(e,r,n,i)=>this.#e(H.HttpStatusCode.MISDIRECTED_REQUEST,e,r,n,i);static unprocessableContent=(e,r,n,i)=>this.#e(H.HttpStatusCode.UNPROCESSABLE_CONTENT,e,r,n,i);static locked=(e,r,n,i)=>this.#e(H.HttpStatusCode.LOCKED,e,r,n,i);static failedDependency=(e,r,n,i)=>this.#e(H.HttpStatusCode.FAILED_DEPENDENCY,e,r,n,i);static tooEarly=(e,r,n,i)=>this.#e(H.HttpStatusCode.TOO_EARLY,e,r,n,i);static upgradeRequired=(e,r,n,i)=>this.#e(H.HttpStatusCode.UPGRADE_REQUIRED,e,r,n,i);static preconditionRequired=(e,r,n,i)=>this.#e(H.HttpStatusCode.PRECONDITION_REQUIRED,e,r,n,i);static tooManyRequests=(e,r,n,i)=>this.#e(H.HttpStatusCode.TOO_MANY_REQUESTS,e,r,n,i);static requestHeaderFieldsTooLarge=(e,r,n,i)=>this.#e(H.HttpStatusCode.REQUEST_HEADER_FIELDS_TOO_LARGE,e,r,n,i);static unavailableForLegalReasons=(e,r,n,i)=>this.#e(H.HttpStatusCode.UNAVAILABLE_FOR_LEGAL_REASONS,e,r,n,i);static internalServerError=(e,r,n,i)=>this.#e(H.HttpStatusCode.INTERNAL_SERVER_ERROR,e,r,n,i);static notImplemented=(e,r,n,i)=>this.#e(H.HttpStatusCode.NOT_IMPLEMENTED,e,r,n,i);static badGateway=(e,r,n,i)=>this.#e(H.HttpStatusCode.BAD_GATEWAY,e,r,n,i);static serviceUnavailable=(e,r,n,i)=>this.#e(H.HttpStatusCode.SERVICE_UNAVAILABLE,e,r,n,i);static gatewayTimeout=(e,r,n,i)=>this.#e(H.HttpStatusCode.GATEWAY_TIMEOUT,e,r,n,i);static httpVersionNotSupported=(e,r,n,i)=>this.#e(H.HttpStatusCode.HTTP_VERSION_NOT_SUPPORTED,e,r,n,i);static variantAlsoNegotiates=(e,r,n,i)=>this.#e(H.HttpStatusCode.VARIANT_ALSO_NEGOTIATES,e,r,n,i);static insufficientStorage=(e,r,n,i)=>this.#e(H.HttpStatusCode.INSUFFICIENT_STORAGE,e,r,n,i);static loopDetected=(e,r,n,i)=>this.#e(H.HttpStatusCode.LOOP_DETECTED,e,r,n,i);static notExtended=(e,r,n,i)=>this.#e(H.HttpStatusCode.NOT_EXTENDED,e,r,n,i);static networkAuthenticationRequired=(e,r,n,i)=>this.#e(H.HttpStatusCode.NETWORK_AUTHENTICATION_REQUIRED,e,r,n,i)};pn.HttpProblems=_l});var st=_(K=>{"use strict";Object.defineProperty(K,"__esModule",{value:!0});K.isErrorLike=K.withUndefinedAsNull=K.withNullAsUndefined=K.validateConstraint=K.validateConstraints=K.areFunctions=K.isFunction=K.isEmptyObject=K.assertAllDefined=K.assertIsDefined=K.assertType=K.isUndefinedOrNull=K.isDefined=K.isUndefined=K.isBoolean=K.isIterable=K.isNumber=K.isTypedArray=K.isArray=K.isObject=K.getOwnEnumerableKeys=K.isRegexp=K.isStringArray=K.isNonEmptyString=K.isString=K.toString=void 0;var{toString:HT}=Object.prototype,{propertyIsEnumerable:qT}=Object.prototype;function um(t){return HT.call(t)}o(um,"toString");K.toString=um;function rs(t){return typeof t=="string"}o(rs,"isString");K.isString=rs;function $T(t){return rs(t)&&t!==""}o($T,"isNonEmptyString");K.isNonEmptyString=$T;function jT(t){return Array.isArray(t)&&t.every(e=>rs(e))}o(jT,"isStringArray");K.isStringArray=jT;function VT(t){return um(t)==="[object RegExp]"}o(VT,"isRegexp");K.isRegexp=VT;function BT(t){return[...Object.keys(t),...Object.getOwnPropertySymbols(t).filter(e=>qT.call(t,e))]}o(BT,"getOwnEnumerableKeys");K.getOwnEnumerableKeys=BT;function El(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)&&!(t instanceof RegExp)&&!(t instanceof Date)}o(El,"isObject");K.isObject=El;function GT(t){return El(t)&&Array.isArray(t)}o(GT,"isArray");K.isArray=GT;function KT(t){let e=Object.getPrototypeOf(Uint8Array);return typeof t=="object"&&t instanceof e}o(KT,"isTypedArray");K.isTypedArray=KT;function JT(t){return typeof t=="number"&&!isNaN(t)}o(JT,"isNumber");K.isNumber=JT;function zT(t){return!!t&&typeof t[Symbol.iterator]=="function"}o(zT,"isIterable");K.isIterable=zT;function WT(t){return t===!0||t===!1}o(WT,"isBoolean");K.isBoolean=WT;function lm(t){return typeof t>"u"}o(lm,"isUndefined");K.isUndefined=lm;function QT(t){return!Ii(t)}o(QT,"isDefined");K.isDefined=QT;function Ii(t){return lm(t)||t===null}o(Ii,"isUndefinedOrNull");K.isUndefinedOrNull=Ii;function YT(t,e){if(!t)throw new Error(e?`Unexpected type, expected '${e}'`:"Unexpected type")}o(YT,"assertType");K.assertType=YT;function ZT(t){if(Ii(t))throw new Error("Assertion Failed: argument is undefined or null");return t}o(ZT,"assertIsDefined");K.assertIsDefined=ZT;function XT(...t){let e=[];for(let r=0;r<t.length;r++){let n=t[r];if(Ii(n))throw new Error(`Assertion Failed: argument at index ${r} is undefined or null`);e.push(n)}return e}o(XT,"assertAllDefined");K.assertAllDefined=XT;var eS=Object.prototype.hasOwnProperty;function tS(t){if(!El(t))return!1;for(let e in t)if(eS.call(t,e))return!1;return!0}o(tS,"isEmptyObject");K.isEmptyObject=tS;function wl(t){return typeof t=="function"}o(wl,"isFunction");K.isFunction=wl;function rS(...t){return t.length>0&&t.every(wl)}o(rS,"areFunctions");K.areFunctions=rS;function nS(t,e){let r=Math.min(t.length,e.length);for(let n=0;n<r;n++)dm(t[n],e[n])}o(nS,"validateConstraints");K.validateConstraints=nS;function dm(t,e){if(rs(e)){if(typeof t!==e)throw new Error(`argument does not match constraint: typeof ${e}`)}else if(wl(e)){try{if(t instanceof e)return}catch{}if(!Ii(t)&&t.constructor===e||e.length===1&&e.call(void 0,t)===!0)return;throw new Error("argument does not match one of these constraints: arg instanceof constraint, arg.constructor === constraint, nor constraint(arg) === true")}}o(dm,"validateConstraint");K.validateConstraint=dm;function iS(t){return t===null?void 0:t}o(iS,"withNullAsUndefined");K.withNullAsUndefined=iS;function oS(t){return typeof t>"u"?null:t}o(oS,"withUndefinedAsNull");K.withUndefinedAsNull=oS;function sS(t){return!!t&&typeof t=="object"&&"name"in t&&"message"in t&&"stack"in t}o(sS,"isErrorLike");K.isErrorLike=sS});var Kt=_(Ot=>{"use strict";Object.defineProperty(Ot,"__esModule",{value:!0});Ot.parseValueToBoolean=Ot.parseValueToStringArray=Ot.getValueFromRequestUser=Ot.statusCodesStringToNumberArray=void 0;var fn=k(),vl=st(),pm=new Map;function aS(t){if(Array.isArray(t)&&!t.some(i=>typeof i!="number"))return t;if(typeof t!="string")throw new Error("Input must be a string or an array of numbers");if(!/^\d+(?:-\d+)?(?:,\s*\d+(?:-\d+)?)*$/.test(t))throw new Error("Malformed input string");let e=pm.get(t);if(e)return e;let r=t.split(","),n=[];for(let i of r){let s=i.split("-");if(s.length===2){let a=parseInt(s[0],10),c=parseInt(s[1],10);for(let u=a;u<=c;u++)n.push(u)}else n.push(parseInt(i,10))}return pm.set(t,n),n}o(aS,"statusCodesStringToNumberArray");Ot.statusCodesStringToNumberArray=aS;function cS(t,e,r){if(!e.startsWith("."))throw new fn.ConfigurationError(`Invalid ${r} - must start with '.' - '${e}' does not`);let n=e.split(".").splice(1),i=t;return n.forEach(s=>{if(i===void 0)throw new fn.RuntimeError(`Error applying ${r} '${e}', reading '${s}'`);i=i[s]}),`${i}`}o(cS,"getValueFromRequestUser");Ot.getValueFromRequestUser=cS;function uS(t){if(Array.isArray(t)){if(t.includes(r=>typeof r!="string"))throw new fn.ConfigurationError("Received an array that contains non-string values.");return t}if((0,vl.isString)(t))return t.includes(",")?t.split(",").map(r=>r.trim()).filter(r=>r!==","&&r!==""):[t];throw new fn.ConfigurationError(`Expected type of string, received type '${typeof t}'`)}o(uS,"parseValueToStringArray");Ot.parseValueToStringArray=uS;function lS(t){if((0,vl.isBoolean)(t))return t;if((0,vl.isString)(t)){if(t.toLowerCase()==="true")return!0;if(t.toLowerCase()==="false")return!1;throw new fn.ConfigurationError(`Attempted to parse string to boolean, but received ${t} which cannot be parsed.`)}throw new fn.ConfigurationError(`Expected type of boolean, received type '${typeof t}'`)}o(lS,"parseValueToBoolean");Ot.parseValueToBoolean=lS});var is=_(ur=>{"use strict";Object.defineProperty(ur,"__esModule",{value:!0});ur.generateCorsHeaders=ur.findMatchingOrigin=ur.parseCorsPolicies=void 0;var jr=k(),fm=Kt(),ns=st();function dS(t){if(t==null)return[];if(!Array.isArray(t))throw new jr.ConfigurationError(`Invalid corsPolicy configuration. Expected an array of objects, received '${typeof t}'`);return t.map(r=>{if(!(0,ns.isObject)(r))throw new jr.ConfigurationError(`Invalid custom cors policy is set. Expected an object, received '${typeof r}'`);if(!(0,ns.isNonEmptyString)(r.name))throw new jr.ConfigurationError("Value of 'name' on custom cors policies must be a non-empty string.");if(r.maxAge!==void 0&&!(0,ns.isNumber)(r.maxAge))throw new jr.ConfigurationError(`Value of 'maxAge' on custom cors policies must be a non-empty string. Received type '${typeof r.maxAge}'`);if(r.allowCredentials!==void 0&&!(0,ns.isBoolean)(r.allowCredentials))throw new jr.ConfigurationError("Value of 'allowCredentials' on custom cors policies must be a boolean or not be set. If using an environment variable, check that it is set correctly.");let n=Tl(r,"allowedHeaders"),i=Tl(r,"allowedMethods"),s=Tl(r,"exposeHeaders"),a;try{a=(0,fm.parseValueToStringArray)(r.allowedOrigins)}catch(u){throw new jr.ConfigurationError(`Value of 'allowedOrigins' on custom cors policies is invalid. ${u.message} If using an environment variable, check that it is set correctly.`)}return{name:r.name,allowCredentials:typeof r.allowCredentials=="boolean"?String(r.allowCredentials):void 0,allowedOrigins:a,allowedHeaders:n?n.join(", "):void 0,allowedMethods:i?i.join(", "):void 0,exposeHeaders:s?s.join(", "):void 0,maxAge:typeof r.maxAge=="number"?r.maxAge.toString():void 0}})}o(dS,"parseCorsPolicies");ur.parseCorsPolicies=dS;function Tl(t,e){let r;if(t[e]!==void 0)try{r=(0,fm.parseValueToStringArray)(t[e])}catch(n){throw new jr.ConfigurationError(`Value of '${e}' on custom cors policies is invalid. ${n.message} If using an environment variable, check that it is set correctly.`)}return r}o(Tl,"parseOptionalProperty");var pS=o((t,e)=>{if(e===null)return;if(t.find(a=>a==="*"))return e;let n=t.map(a=>a.trim().toLowerCase()),i=e.toLowerCase();return n.find(a=>a===i)},"findMatchingOrigin");ur.findMatchingOrigin=pS;var fS=o((t,e)=>{let r={"access-control-allow-origin":e};t.allowedHeaders&&(r["access-control-allow-headers"]=t.allowedHeaders),t.allowedMethods&&(r["access-control-allow-methods"]=t.allowedMethods),t.exposeHeaders&&(r["access-control-expose-headers"]=t.exposeHeaders);let n=t.allowCredentials;n&&(r["access-control-allow-credentials"]=n);let i=t.maxAge?.toString()??void 0;return i&&(r["access-control-max-age"]=i),r},"generateCorsHeaders");ur.generateCorsHeaders=fS});var mm=_(os=>{"use strict";Object.defineProperty(os,"__esModule",{value:!0});os.registerCorsRoute=void 0;var hS=k(),mS=Bt(),Sl=pe(),yS=ar(),gS=$r(),bS=mt(),hm=is(),_S=o((t,e)=>{let r=e.routeData.corsPolicies,n=o(async(a,c)=>{let u=new URL(a.url.toString()).pathname,l=a.headers.get("access-control-request-method"),d=a.headers.get("access-control-request-headers"),p=a.headers.get("origin");if(p===null||l===null)return Sl.HttpProblems.badRequest(a,c,{detail:"Expect headers origin and access-control-request-method"});let f=t.lookup(l,u);if(!f)return Sl.HttpProblems.notFound(a,c);let h=f.routeConfiguration,m=ES(l,d,p,h,r);return m.isValid?new Response(void 0,{status:200,statusText:"OK",headers:m.headers}):(m.error&&c.log.warn(m.error),Sl.HttpProblems.notFound(a,c))},"optionsHandler"),i=new mS.Pipeline({processors:[yS.metricsProcessor],handler:n,gateway:e}),s=new bS.SystemRouteConfiguration({label:"SYSTEM_CORS_ROUTE",methods:["OPTIONS"],path:"/(.*)",systemRouteName:gS.SystemRouteName.CorsPreflight});t.addRoute(s,i.execute)},"registerCorsRoute");os.registerCorsRoute=_S;var ES=o((t,e,r,n,i)=>{let s={isValid:!1,headers:{}};if(n.corsPolicy==="anything-goes")return{isValid:!0,headers:{"access-control-allow-origin":r,"access-control-allow-methods":t,"access-control-allow-headers":e??"*","access-control-expose-headers":"*","access-control-allow-credentials":"true","access-control-max-age":"600"}};if(n.corsPolicy==="none")return{...s,error:`No CORS policy set for the route '${n.pathPattern}'`};let a=i?.find(l=>l.name===n.corsPolicy);if(!a)throw new hS.ConfigurationError(`Invalid Configuration - corsPolicy '${n.corsPolicy}' not found in *.oas.json 'corsPolicies' section.`);let c=(0,hm.findMatchingOrigin)(a.allowedOrigins,r);return c?{isValid:!0,headers:(0,hm.generateCorsHeaders)(a,c)}:{...s,error:`The CORS policy '${a.name}' does not allow the origin '${r}'`}},"validateAndBuildResponseHeaders")});var ym=_(ss=>{"use strict";Object.defineProperty(ss,"__esModule",{value:!0});ss.registerNoRoutes=void 0;var wS=Bt(),vS=ar(),TS=$r(),SS=mt(),IS=o((t,e)=>{let r=o(async()=>new Response("You have no routes. Add a route in routes.oas.json to get started",{status:200}),"noRoutesHandler"),n=new wS.Pipeline({processors:[vS.metricsProcessor],handler:r,gateway:e}),i=new SS.SystemRouteConfiguration({label:"SYSTEM_NO_ROUTES",methods:["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"],path:"/(.*)",systemRouteName:TS.SystemRouteName.EmptyGatewayCatchall});t.addRoute(i,n.execute)},"registerNoRoutes");ss.registerNoRoutes=IS});var gm=_(Vr=>{"use strict";Object.defineProperty(Vr,"__esModule",{value:!0});Vr.registerNotMatchedHandler=Vr.notFoundRouteConfiguration=void 0;var PS=Hr(),AS=Rt(),RS=Bt(),OS=pe(),NS=ar(),CS=$r(),xS=mt();Vr.notFoundRouteConfiguration=new xS.SystemRouteConfiguration({label:"SYSTEM_NOT_FOUND_ROUTE",methods:["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"],path:"/(.*)",systemRouteName:CS.SystemRouteName.UnmatchedPath});var LS=o((t,e)=>{let r=o(async(i,s)=>{let a=AS.runtimeExtensions.value?.notFoundHandler;if(a){let c=PS.ZuploContextExtensions.getContextExtensions(s);return a(i,s,{routesMatchedByPathOnly:c.pathOnlyMatches??[]})}return OS.HttpProblems.notFound(i,s)},"notFoundHandler"),n=new RS.Pipeline({processors:[NS.metricsProcessor],handler:r,gateway:e});t.addRoute(Vr.notFoundRouteConfiguration,n.execute)},"registerNotMatchedHandler");Vr.registerNotMatchedHandler=LS});var Il=_(as=>{"use strict";Object.defineProperty(as,"__esModule",{value:!0});as.corsProcessor=void 0;var Em=k(),bm=is(),DS=["access-control-allow-origin","access-control-allow-headers","access-control-expose-headers","access-control-allow-credentials","access-control-max-age"],_m=o(t=>{DS.forEach(e=>t.delete(e))},"stripCorsHeaders"),MS=o(async(t,e,r,n)=>{let i=e.route;if(!i.corsPolicy||i.corsPolicy==="none"){let d=await n(t),p=new Headers(d.headers);return _m(p),new Response(d.body,{status:d.status,statusText:d.statusText,headers:p,webSocket:d.webSocket})}let s=await n(t);if(!(s instanceof Response))throw new Em.SystemError(`The CorsProcessor is in the wrong place in the pipeline. It should only receive HttpResponse type but got '${typeof s}'`);let a=US(i,r.routeData.corsPolicies),c=kS(t,a),u=new Headers(s.headers);return _m(u),Object.entries(c).forEach(([d,p])=>{u.set(d,p)}),new Response(s.body,{status:s.status,statusText:s.statusText,headers:u,webSocket:s.webSocket})},"corsProcessor");as.corsProcessor=MS;var US=o((t,e)=>{if(t.corsPolicy==="anything-goes")return{name:"anything-goes",allowedHeaders:"*",allowedOrigins:["*"],allowedMethods:t.methods.join(", "),exposeHeaders:"*",allowCredentials:"true",maxAge:"600"};let r=e?.find(n=>n.name===t.corsPolicy);if(r===void 0)throw new Em.ConfigurationError(`Invalid Configuration - no corsPolicy '${t.corsPolicy}' found in *.oas.json`);return r},"getCorsPolicy"),kS=o((t,e)=>{let r=(0,bm.findMatchingOrigin)(e.allowedOrigins,t.headers.get("origin"));return r?(0,bm.generateCorsHeaders)(e,r):{}},"getCorsHeaders")});var wm=_(cs=>{"use strict";Object.defineProperty(cs,"__esModule",{value:!0});cs.registerPingRoute=void 0;var FS=Bt(),HS=Il(),qS=$r(),$S=mt(),jS=o((t,e)=>{let r=o(async()=>new Response(null,{status:200}),"pingRouteHandler"),n=new FS.Pipeline({processors:[HS.corsProcessor],handler:r,gateway:e}),i=new $S.SystemRouteConfiguration({corsPolicy:"anything-goes",label:"SYSTEM_PING_ROUTE",methods:["GET"],path:"/__zuplo/ping",systemRouteName:qS.SystemRouteName.Ping});t.addRoute(i,n.execute)},"registerPingRoute");cs.registerPingRoute=jS});var mn=_(hn=>{"use strict";Object.defineProperty(hn,"__esModule",{value:!0});hn.OutboundPolicy=hn.InboundPolicy=void 0;var VS=k(),BS=st(),us=class{static{o(this,"PolicyBase")}options;policyName;constructor(e,r){if(!(0,BS.isString)(r))throw new VS.RuntimeError(`The name of a policy must be a string. Received '${r}' of type '${typeof r}'`);this.options=e,this.policyName=r}},Pl=class extends us{static{o(this,"InboundPolicy")}};hn.InboundPolicy=Pl;var Al=class extends us{static{o(this,"OutboundPolicy")}};hn.OutboundPolicy=Al});var yn=_(yt=>{"use strict";Object.defineProperty(yt,"__esModule",{value:!0});yt.createInternalPolicyProcessor=yt.policyProcessor=yt.toStackedInboundHandler=yt.getInboundPolicyInstances=void 0;var GS=Hr(),qe=k(),ls=mn(),vm=Ge(),KS=ie(),Nl=class extends ls.InboundPolicy{static{o(this,"InboundFunctionOnlyPolicy")}#e;constructor(e,r,n){super(r,n),this.#e=e}handler(e,r){return this.#e(e,r,this.options,this.policyName)}},Cl=class extends ls.OutboundPolicy{static{o(this,"OutboundFunctionOnlyPolicy")}#e;constructor(e,r,n){super(r,n),this.#e=e}handler(e,r,n){return this.#e(e,r,n,this.options,this.policyName)}},Rl=new Map;function Tm(t,e){let r,n;return Array.isArray(t)?r=t:(r=t.policies?.inbound??[],n=t.path),r.filter(s=>!Rl.has(s)).forEach(s=>{let a=e?.find(l=>l.name===s);if(!a)throw new qe.ConfigurationError(`Invalid state - no Policy with the name '${s}' ${n&&`on route '${n}'`} was found in the policies configuration (check case).`);if(typeof a.handler?.module!="object")throw new qe.ConfigurationError(`Invalid state - invalid policy '${s}' on route '${n}' (typeof policy '${typeof a.handler?.module}')`);let c=a.handler?.module[a.handler.export];if(typeof c!="function")throw new qe.ConfigurationError(`Invalid state - invalid policy '${s}' on route '${n}' (typeof module '${typeof c}')`);let u;if(typeof c!="function")throw new qe.ConfigurationError(`Invalid state - invalid policy '${s}' on route '${n}' (typeof module '${typeof c}')`);if(c.prototype instanceof ls.InboundPolicy)u=new c(a.handler.options,a.name);else if(typeof c=="function")u=new Nl(c,a.handler.options,a.name);else throw new qe.ConfigurationError(`Invalid state - invalid policy '${s}' on route '${n}' (typeof policy '${typeof c}')`);if(typeof u.handler!="function")throw new qe.ConfigurationError(`Invalid state - invalid handler on policy '${s}' on route '${n}' (typeof handler '${typeof u.handler}')`);Rl.set(a.name,u)}),r.map(s=>{let a=Rl.get(s);if(a===void 0)throw new qe.RuntimeError("Internal error. Policy not found in cache.");return a})}o(Tm,"getInboundPolicyInstances");yt.getInboundPolicyInstances=Tm;var Ol=new Map;function JS(t,e){let r=t.policies?.outbound??[];return r.filter(i=>!Ol.has(i)).forEach(i=>{let s=e?.find(u=>u.name===i);if(!s)throw new qe.ConfigurationError(`Invalid state - no Policy with the name '${i}' on route '${t.path}' was found in the policies configuration (check case).`);if(typeof s.handler?.module!="object")throw new qe.ConfigurationError(`Invalid state - invalid policy '${i}' on route '${t.path}' (typeof policy '${typeof s.handler?.module}')`);let a=s.handler?.module[s.handler.export],c;if(typeof a!="function")throw new qe.ConfigurationError(`Invalid state - invalid policy '${i}' on route '${t.path}' (typeof module '${typeof a}')`);if(a.prototype instanceof ls.OutboundPolicy)c=new a(s.handler.options??{},s.name);else if(typeof a=="function")c=new Cl(a,s.handler.options??{},s.name);else throw new qe.ConfigurationError(`Invalid state - invalid policy '${i}' on route '${t.path}' (typeof policy '${typeof a}')`);if(typeof c.handler!="function")throw new qe.ConfigurationError(`Invalid state - invalid handler on policy '${i}' on route '${t.path}'`);Ol.set(s.name,c)}),r.map(i=>{let s=Ol.get(i);if(s===void 0)throw new qe.RuntimeError("Internal error. Policy not found in cache.");return s})}o(JS,"getOutboundPolicyInstances");var zS=o(t=>async(e,r)=>{let n=GS.ZuploContextExtensions.getContextExtensions(r),i=[...t],s=e;for(;i.length>0;){let a=i.shift();if(!a)return s;let c=await a.handler(s,r);if(c instanceof vm.ZuploRequest)s=c;else if(c instanceof Request)s=new vm.ZuploRequest(c);else{if(c instanceof Response)return c;throw new qe.ConfigurationError(`Invalid state - invalid handler on policy '${a.policyName}' on route '${r.route.path}. The result of an inbound policy must be a Response or Request.`)}n.latestRequest=s}return s},"toStackedInboundHandler");yt.toStackedInboundHandler=zS;var WS=o(t=>async(e,r,n)=>{let i=[...t],s=e;for(;i.length>0;){let a=i.shift();if(!a)return s;let c=await a.handler(s,r,n);if(!(c instanceof Response))throw new qe.ConfigurationError(`Invalid state - invalid handler on policy '${a.policyName}' on route '${n.route.path}. The result of an outbound policy must be a Response.`);s=c}return s},"toStackedOutboundHandler"),QS=o(async(t,e,r,n)=>{let i=Tm(e.route,r.routeData.policies),s=JS(e.route,r.routeData.policies);return Sm({request:t,context:e,inboundPolicies:i,outboundPolicies:s,gateway:r,next:n})},"policyProcessor");yt.policyProcessor=QS;function YS({inboundPolicies:t=[],outboundPolicies:e=[]}){return o(async(n,i,s,a)=>Sm({request:n,context:i,inboundPolicies:t,outboundPolicies:e,gateway:s,next:a}),"policyProcessor")}o(YS,"createInternalPolicyProcessor");yt.createInternalPolicyProcessor=YS;async function Sm({request:t,context:e,inboundPolicies:r,outboundPolicies:n,gateway:i,next:s}){let a=(0,yt.toStackedInboundHandler)(r);try{let c=await a(t,e);if(c instanceof Response)return c;let u=await s(c),l=WS(n),d;return KS.Environment.instance.build.COMPATIBILITY_FLAGS.runOutboundPoliciesOnHandlerOnAllStatuses?d=l(u,t,e):d=u.ok?l(u,t,e):u,d}catch(c){return e.log.error(c),i.errorHandler(t,e,c)}}o(Sm,"executePolicyProcessor")});var Im=_(gn=>{"use strict";Object.defineProperty(gn,"__esModule",{value:!0});gn.serialize=gn.parse=void 0;var ZS=Object.prototype.toString,ds=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;function XS(t,e){if(typeof t!="string")throw new TypeError("argument str must be a string");let r={},i=(e||{}).decode||tI,s=0;for(;s<t.length;){let a=t.indexOf("=",s);if(a===-1)break;let c=t.indexOf(";",s);if(c===-1)c=t.length;else if(c<a){s=t.lastIndexOf(";",a-1)+1;continue}let u=t.slice(s,a).trim();if(r[u]===void 0){let l=t.slice(a+1,c).trim();l.charCodeAt(0)===34&&(l=l.slice(1,-1)),r[u]=iI(l,i)}s=c+1}return r}o(XS,"parse");gn.parse=XS;function eI(t,e,r){let n=r||{},i=n.encode||rI;if(typeof i!="function")throw new TypeError("option encode is invalid");if(!ds.test(t))throw new TypeError("argument name is invalid");let s=i(e);if(s&&!ds.test(s))throw new TypeError("argument val is invalid");let a=t+"="+s;if(n.maxAge!=null){let c=n.maxAge-0;if(isNaN(c)||!isFinite(c))throw new TypeError("option maxAge is invalid");a+="; Max-Age="+Math.floor(c)}if(n.domain){if(!ds.test(n.domain))throw new TypeError("option domain is invalid");a+="; Domain="+n.domain}if(n.path){if(!ds.test(n.path))throw new TypeError("option path is invalid");a+="; Path="+n.path}if(n.expires){let c=n.expires;if(!nI(c)||isNaN(c.valueOf()))throw new TypeError("option expires is invalid");a+="; Expires="+c.toUTCString()}if(n.httpOnly&&(a+="; HttpOnly"),n.secure&&(a+="; Secure"),n.priority)switch(typeof n.priority=="string"?n.priority.toLowerCase():n.priority){case"low":a+="; Priority=Low";break;case"medium":a+="; Priority=Medium";break;case"high":a+="; Priority=High";break;default:throw new TypeError("option priority is invalid")}if(n.sameSite)switch(typeof n.sameSite=="string"?n.sameSite.toLowerCase():n.sameSite){case!0:a+="; SameSite=Strict";break;case"lax":a+="; SameSite=Lax";break;case"strict":a+="; SameSite=Strict";break;case"none":a+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}return a}o(eI,"serialize");gn.serialize=eI;function tI(t){return t.indexOf("%")!==-1?decodeURIComponent(t):t}o(tI,"decode");function rI(t){return encodeURIComponent(t)}o(rI,"encode");function nI(t){return ZS.call(t)==="[object Date]"||t instanceof Date}o(nI,"isDate");function iI(t,e){try{return e(t)}catch{return t}}o(iI,"tryDecode")});var Pm=_(ps=>{"use strict";Object.defineProperty(ps,"__esModule",{value:!0});ps.devPortalBaseURL=void 0;var oI=Im();function sI(t,e){try{let r=/v\d+(-\d+)?/g,i=(0,oI.parse)(e.get("Cookie")||"")["zp-dev-portal"];return i!==null&&i&&r.test(i)?`https://dev-portal-${i}.zuplo.com`:t}catch{}return t}o(sI,"devPortalBaseURL");ps.devPortalBaseURL=sI});var Cm=_(bn=>{"use strict";Object.defineProperty(bn,"__esModule",{value:!0});bn.registerDevPortalLegacyRedirectRoute=bn.registerDevPortalV3Route=void 0;var xl=Gt(),Rm=Bt(),Om=ar(),aI=yn(),Nm=mt(),cI=Pm(),lr=ie(),Am="/__zuplo/dev-portal",uI="dev-portal-id",lI="dev-portal-host",dI="zp-account",pI="zp-project",fI="dev-portal-build",hI=`
35
+ `)+" "+r[1]:r[0]+e+" "+t.join(", ")+" "+r[1]}o(Kv,"reduceToSingleString")});var Vh=_(Mo=>{"use strict";Object.defineProperty(Mo,"__esModule",{value:!0});Mo.format=void 0;var Jv=Uh(),zv=jh(),Wv=o((t,...e)=>(0,Jv.format)(zv.inspect,t,e),"format");Mo.format=Wv});var kr=_(or=>{"use strict";Object.defineProperty(or,"__esModule",{value:!0});or.debug=or.withoutEnv=or.Debugger=void 0;var Qv=Mh(),Yv=Vh(),Uo=class{static{o(this,"Debugger")}manager;ns;color;last;enabled;constructor(e,r){this.manager=e,this.ns=r,this.color=(0,Qv.generateColor)(r),this.last=0,this.enabled=e.enabled.some(n=>n.test(r))}log(...e){if(!this.enabled)return;let r,n=e[0];typeof n=="function"?r=n():r=String(n);let i=Date.now()-(this.last||Date.now());r=(0,Yv.format)(r,...e);let s=`${this.color(this.ns)} ${r} ${this.color(`+${i}ms`)}`;console.log(s),this.last=Date.now()}};or.Debugger=Uo;var ko=class{static{o(this,"DebugManager")}debuggers;enabled;constructor(e){this.debuggers=new Map,this.enabled=e??[]}};function Bh(t){return!t||t.length===0?[]:(t=t.replace(/\s/g,"").replace(/\*/g,".+"),t.split(",").map(e=>new RegExp(`^${e}$`)))}o(Bh,"extract");var Si;function Zv(t){t||(t=[]),typeof t=="string"&&(t=Bh(t)),Si=new ko(t)}o(Zv,"withoutEnv");or.withoutEnv=Zv;function Xv(t){let e=globalThis.DEBUG;Si||(Si=new ko(Bh(e)));let r=new Uo(Si,t);return Si.debuggers.set(t,r),Object.assign(r.log.bind(r),{self:r})}o(Xv,"debug");or.debug=Xv});var Ho=_(ln=>{"use strict";Object.defineProperty(ln,"__esModule",{value:!0});ln.ProblemResponseFormatter=ln.InternalProblemResponseFormatter=void 0;var eT=k(),Fo=class t{static{o(this,"InternalProblemResponseFormatter")}static problemResponseFormat=async e=>{let r=e.problem,n=JSON.stringify(r,null,2);return new Response(n,{status:e.problem.status,statusText:e.statusText,headers:{...e.additionalHeaders,"content-type":"application/problem+json"}})};static setProblemResponseFormat(e){e&&(t.problemResponseFormat=(r,n,i)=>{try{return e(r,n,i)}catch(s){throw new eT.RuntimeError("Error in custom 'problemResponseFormat'",{cause:s})}})}};ln.InternalProblemResponseFormatter=Fo;var tl=class{static{o(this,"ProblemResponseFormatter")}static async format(e,r,n){return await Fo.problemResponseFormat(e,r,n)}};ln.ProblemResponseFormatter=tl});var Kh=_(qo=>{"use strict";Object.defineProperty(qo,"__esModule",{value:!0});qo.deepFreeze=void 0;function Gh(t){for(let e in t){let r=t[e];r&&typeof r=="object"&&Gh(r)}return Object.freeze(t)}o(Gh,"deepFreeze");qo.deepFreeze=Gh});var Ge=_($o=>{"use strict";Object.defineProperty($o,"__esModule",{value:!0});$o.ZuploRequest=void 0;var Jh=Kh(),rl=class t extends Request{static{o(this,"ZuploRequest")}#e=void 0;#t;constructor(e,r){super(e,r);let n=r?.params;n?this.#t=n:e instanceof t?this.#t=e.#t:this.#t={};let i=r?.user;i?this.user=i:e instanceof t&&(this.user=e.user)}get query(){if(this.#e===void 0){let e={},r=new URL(this.url).searchParams;for(let[n,i]of r.entries())e[n]=i;this.#e=e}return(0,Jh.deepFreeze)(this.#e)}get params(){return(0,Jh.deepFreeze)(this.#t)}user};$o.ZuploRequest=rl});var Rt=_(Se=>{"use strict";Object.defineProperty(Se,"__esModule",{value:!0});Se.initializeRuntime=Se.invokeOnResponseSendingFinalExtensions=Se.invokeOnResponseSendingExtensions=Se.invokeOnRequestExtensions=Se.plugins=Se.runtimeExtensions=Se.SystemRuntimePlugin=Se.RuntimePlugin=void 0;var zh=k(),tT=Ho(),rT=Ge(),Vo=class{static{o(this,"RuntimePlugin")}};Se.RuntimePlugin=Vo;var Bo=class extends Vo{static{o(this,"SystemRuntimePlugin")}async initialize(e){return Promise.resolve()}registerRoutes(e,r){}};Se.SystemRuntimePlugin=Bo;Se.runtimeExtensions={};var nl=[];Se.plugins=nl;var Wh=[],Qh=[],Yh=[],jo={addPlugin(t){nl.push(t)},addRequestHook(t){Wh.push(t)},addResponseSendingHook(t){Qh.push(t)},addResponseSendingFinalHook(t){Yh.push(t)}},nT=o(async(t,e)=>{let r=t;for(let n of Wh){let i=await n(r,e);if(i instanceof rT.ZuploRequest)r=i;else{if(i instanceof Response)return i;throw new zh.ConfigurationError(`Invalid state - the OnRequest hook must return a ZuploRequest or Response. Received ${typeof r}.`)}}return r},"invokeOnRequestExtensions");Se.invokeOnRequestExtensions=nT;var iT=o(async(t,e,r)=>{let n=t;for(let i of Qh){let s=await i(t,e,r);if(s instanceof Response)n=s;else throw new zh.ConfigurationError(`Invalid state - the OnResponseSending hook must return a Response. Received ${typeof n}.`)}return n},"invokeOnResponseSendingExtensions");Se.invokeOnResponseSendingExtensions=iT;var oT=o(async(t,e,r)=>{for(let n of Yh)await n(t,e,r)},"invokeOnResponseSendingFinalExtensions");Se.invokeOnResponseSendingFinalExtensions=oT;async function sT(t=()=>Promise.resolve()){await t(jo),Se.runtimeExtensions.value=jo;for(let e of nl)e instanceof Bo&&await e.initialize(jo);tT.InternalProblemResponseFormatter.setProblemResponseFormat(jo.problemResponseFormat)}o(sT,"initializeRuntime");Se.initializeRuntime=sT});var il=_(sr=>{"use strict";Object.defineProperty(sr,"__esModule",{value:!0});sr.serialize=sr.ContentTypes=void 0;sr.ContentTypes={Json:"application/json",Form:"application/x-www-form-urlencoded"};function aT(t,e){if(t!==null)return e&&typeof t=="string"?t:typeof t=="object"&&e?.startsWith(sr.ContentTypes.Form)?new URLSearchParams(t).toString():typeof t=="object"&&e?.startsWith(sr.ContentTypes.Json)||!e?JSON.stringify(t):t}o(aT,"serialize");sr.serialize=aT});var ol=_(Go=>{"use strict";Object.defineProperty(Go,"__esModule",{value:!0});Go.isSystemRoute=void 0;var Zh=Fr();function cT(t){return Zh.Gateway.instance.runtimeSettings.developerPortal.enabled&&t.pathname.startsWith(Zh.Gateway.instance.runtimeSettings.developerPortal.sitePathname)||t.pathname.startsWith("/__zuplo/")}o(cT,"isSystemRoute");Go.isSystemRoute=cT});var Bt=_(Ko=>{"use strict";Object.defineProperty(Ko,"__esModule",{value:!0});Ko.Pipeline=void 0;var sl=Hr(),Xh=Rt(),uT=il(),lT=ie(),dT=ol(),al=class{static{o(this,"Pipeline")}constructor(e){this.execute=this.#t(e)}execute;#e=(e,r)=>async(n,i)=>{try{return await e(n,i)}catch(s){return i.log.error("Error executing request handler.",s),r.errorHandler(n,i,s)}};#t=({processors:e,gateway:r,handler:n})=>async(i,s)=>{let a=[...e],c=o(async b=>{let v=a.pop();return v?v(i,s,r,c):await this.#e(async g=>{let S=await n(g,s);return pT(S)},r)(b,s)},"nextPipe"),l=await c(i),d=new URL(i.url);if((0,dT.isSystemRoute)(d)&&lT.Environment.instance.build.COMPATIBILITY_FLAGS.doNotRunHooksOnSystemRoutes)return l;let p=new sl.ResponseSendingEvent(i,l);s.dispatchEvent(p);let f=sl.ZuploContextExtensions.getContextExtensions(s),h=f.latestRequest,m;try{m=await p.mutableResponse}catch(b){return s.log.error(b),r.errorHandler(i,s,b)}try{m=await f.onResponseSending(m,h,s)}catch(b){return s.log.error(`Error invoking 'context.onResponseSending' hook: '${b.message}'`,b),r.errorHandler(i,s,b)}try{m=await(0,Xh.invokeOnResponseSendingExtensions)(m,h,s)}catch(b){return s.log.error(`Error invoking 'context.onResponseSending' hook: '${b.message}'`,b),r.errorHandler(i,s,b)}s.dispatchEvent(new sl.ResponseSentEvent(i,m));try{await f.onResponseSendingFinal(l,h,s)}catch(b){throw s.log.error(`Error invoking 'runtime.onResponseSending' hook: '${b.message}'`,b),b}try{await(0,Xh.invokeOnResponseSendingFinalExtensions)(l,h,s)}catch(b){throw s.log.error(`Error invoking 'runtime.onResponseSending' hook: '${b.message}'`,b),b}return m}};Ko.Pipeline=al;function pT(t){return t instanceof Response?t:typeof t>"u"?new Response:new Response((0,uT.serialize)(t),{headers:{"content-type":"application/json"}})}o(pT,"resultToResponse")});var zo=_(Jo=>{"use strict";Object.defineProperty(Jo,"__esModule",{value:!0});Jo.MetricsPlugin=void 0;var fT=Rt(),cl=class extends fT.RuntimePlugin{static{o(this,"MetricsPlugin")}};Jo.MetricsPlugin=cl});var Ze=_(Wo=>{"use strict";Object.defineProperty(Wo,"__esModule",{value:!0});Wo.SystemLogMap=void 0;var hT=k(),ul=class t{static{o(this,"SystemLogMap")}static#e=new WeakMap;static getLogger(e){let r=t.#e.get(e);if(!r){let n=`No system logger found for context with requestId '${e.requestId}'`;throw console.error(n),new hT.SystemError(n)}return r}static addLogger(e,r){t.#e.set(e,r)}};Wo.SystemLogMap=ul});var Ne=_(Qo=>{"use strict";Object.defineProperty(Qo,"__esModule",{value:!0});Qo.BatchDispatch=void 0;var ll=class{static{o(this,"BatchDispatch")}constructor(e,r,n,i){this.#t=e,this.#o=r,this.#n=n,this.#r=i??console}#e=void 0;#t;#r;#n;#i=[];#o;enqueue=e=>{this.#i.push(e),this.#e||(this.#e=new Promise(r=>{setTimeout(()=>{if(this.#i.length>0){let n=[...this.#i];this.#i.length=0,this.#e=void 0,this.#n(n).catch(i=>{this.#r.error(`Uncaught error in BatchDispatcher named '${this.#t}'}`,i.message,i.stack)}).finally(()=>{r()})}},this.#o)}))};waitUntilFlushed=async()=>{if(this.#e)return this.#e}};Qo.BatchDispatch=ll});var tm=_(Zo=>{"use strict";Object.defineProperty(Zo,"__esModule",{value:!0});Zo.EllieMetricsTransport=void 0;var em=Ze(),mT=Ne(),Yo=ie(),dl=class{static{o(this,"EllieMetricsTransport")}#e;#t;#r;constructor(e){this.#r=Yo.Environment.instance.loggingId,this.#e=e,this.#t=new mT.BatchDispatch("ellie-metrics-transport",10,this.dispatchFunction,em.SystemLogMap.getLogger(e))}pushMetrics(e,r){this.#r!==void 0&&(this.#t.enqueue(e),r.waitUntil(this.#t.waitUntilFlushed()))}dispatchFunction=async e=>{if(e.length===0)return;let r,{loggingId:n,remoteLogURL:i,deploymentName:s}=Yo.Environment.instance,a=e.map(c=>{let u=Object.assign({},c);return delete u.requestContentLength,delete u.responseContentLength,u});if(n&&s&&(r=`${i}/v1-alpha/metrics?loggingId=${encodeURI(n)}&deploymentName=${encodeURI(s)}`),r){let c=await fetch(r,{method:"POST",body:JSON.stringify(a),headers:{"content-type":"application/json","zp-dn":Yo.Environment.instance.deploymentName??"unknown","user-agent":Yo.Environment.instance.systemUserAgent}});if(!c.ok){let u=await c.text();em.SystemLogMap.getLogger(this.#e).error(`Metrics POST responded ${c.status}: ${c.statusText}`,u)}}}};Zo.EllieMetricsTransport=dl});var mt=_(qr=>{"use strict";Object.defineProperty(qr,"__esModule",{value:!0});qr.systemNoVersion=qr.SystemRouteConfiguration=void 0;var pl=class{static{o(this,"SystemRouteConfiguration")}constructor({label:e,path:r,methods:n,systemRouteName:i,corsPolicy:s="none"}){this.label=e,this.path=r,this.methods=n,this.corsPolicy=s,this.version=qr.systemNoVersion.name,this.handler={export:"SYSTEM_IGNORED",module:"SYSTEM_IGNORED"},this.systemRouteName=i}label;path;methods;handler;corsPolicy;version;policies;systemRouteName;raw(){return{}}};qr.SystemRouteConfiguration=pl;qr.systemNoVersion={name:"__system-no-version",pathPrefix:""}});var ar=_(Xo=>{"use strict";Object.defineProperty(Xo,"__esModule",{value:!0});Xo.metricsProcessor=void 0;var rm=un(),yT=Hr(),gT=Rt(),bT=zo(),_T=tm(),ET=mt(),wT=o(async(t,e,r,n)=>{let i=new Date,s=Date.now(),a=await n(t),c=t.headers.get(rm.RAY_ID_HEADER)??void 0,u=t.headers.get(rm.TRUE_CLIENT_IP)??void 0,l=e.incomingRequestProperties,d;e.route instanceof ET.SystemRouteConfiguration&&(d=e.route.systemRouteName);let p=yT.ZuploContextExtensions.getContextExtensions(e).latestRequest,f={timestamp:i,statusCode:a.status,durationMs:Date.now()-s,requestContentLength:t.headers.get("content-length")?Number(t.headers.get("content-length")):void 0,responseContentLength:a.headers.get("content-length")?Number(a.headers.get("content-length")):void 0,routePath:e.route?.path??"SYSTEM_OR_NOT_FOUND",systemRouteName:d,requestId:e.requestId,method:t.method,asn:l.asn,asOrganization:l.asOrganization,colo:l.colo,continent:l.continent,country:l.country,city:l.city,latitude:l.latitude,longitude:l.longitude,rayId:c,instanceId:r.instanceId,userSub:p.user?.sub,clientIp:u},h=[];return h.push(new _T.EllieMetricsTransport(e)),gT.plugins.forEach(m=>{if(m instanceof bT.MetricsPlugin){let b=m.getTransport();h.push(b)}}),h.forEach(m=>{m.pushMetrics(f,e)}),a},"metricsProcessor");Xo.metricsProcessor=wT});var fl=_(es=>{"use strict";Object.defineProperty(es,"__esModule",{value:!0});es.SystemRouteName=void 0;var nm;(function(t){t.Build="build-data",t.CorsPreflight="cors-preflight",t.DeveloperPortal="developer-portal",t.DeveloperPortalLegacy="developer-portal-legacy",t.StripePlugin="stripe-plugin",t.EmptyGatewayCatchall="empty-gateway-catchall",t.Ping="ping",t.UnmatchedPath="unmatched-path"})(nm||(es.SystemRouteName=nm={}))});var om=_(im=>{"use strict";Object.defineProperty(im,"__esModule",{value:!0})});var $r=_(cr=>{"use strict";var vT=cr&&cr.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),sm=cr&&cr.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&vT(e,t,r)};Object.defineProperty(cr,"__esModule",{value:!0});sm(fl(),cr);sm(om(),cr)});var am=_(ts=>{"use strict";Object.defineProperty(ts,"__esModule",{value:!0});ts.registerBuildRoute=void 0;var TT=Gt(),ST=Bt(),IT=ar(),PT=$r(),AT=mt(),RT=Ze(),OT=ie(),NT=o((t,e)=>{let r=o(async(s,a)=>{let u=new URL(s.url).hostname.toLowerCase();if(!u.endsWith(".zuplo.app")&&!u.endsWith(".zuplo.dev")&&!u.endsWith(".fly.dev")&&!u.endsWith("zuplotest.com")&&u!=="localhost")return TT.HttpProblems.notFound(s,a);let l=OT.Environment.instance.build,d={buildId:l.BUILD_ID,zuploVersion:l.ZUPLO_VERSION,apiVersion:l.API_VERSION,gitSha:l.GIT_SHA,timestamp:l.TIMESTAMP,isProduction:l.IS_PRODUCTION},p=s.url.toString().split("?");return p.length>0&&new URLSearchParams(p[1]).get("system_log")==="true"&&RT.SystemLogMap.getLogger(a).error("Test System Log",d),new Response(JSON.stringify(d,null,2),{status:200,headers:{"content-type":"application/json"}})},"buildRouteHandler"),n=new ST.Pipeline({processors:[IT.metricsProcessor],handler:r,gateway:e}),i=new AT.SystemRouteConfiguration({label:"SYSTEM_BUILD_ROUTE",methods:["GET"],path:"/__zuplo/build",systemRouteName:PT.SystemRouteName.Build});t.addRoute(i,n.execute)},"registerBuildRoute");ts.registerBuildRoute=NT});var hl=_(dn=>{"use strict";Object.defineProperty(dn,"__esModule",{value:!0});dn.HTTP_STATUS_TITLES=dn.HttpStatusCode=void 0;var cm;(function(t){t[t.CONTINUE=100]="CONTINUE",t[t.SWITCHING_PROTOCOLS=101]="SWITCHING_PROTOCOLS",t[t.PROCESSING=102]="PROCESSING",t[t.EARLY_HINTS=103]="EARLY_HINTS",t[t.OK=200]="OK",t[t.CREATED=201]="CREATED",t[t.ACCEPTED=202]="ACCEPTED",t[t.NON_AUTHORITATIVE_INFORMATION=203]="NON_AUTHORITATIVE_INFORMATION",t[t.NO_CONTENT=204]="NO_CONTENT",t[t.RESET_CONTENT=205]="RESET_CONTENT",t[t.PARTIAL_CONTENT=206]="PARTIAL_CONTENT",t[t.MULTI_STATUS=207]="MULTI_STATUS",t[t.ALREADY_REPORTED=208]="ALREADY_REPORTED",t[t.IM_USED=226]="IM_USED",t[t.MULTIPLE_CHOICES=300]="MULTIPLE_CHOICES",t[t.MOVED_PERMANENTLY=301]="MOVED_PERMANENTLY",t[t.FOUND=302]="FOUND",t[t.SEE_OTHER=303]="SEE_OTHER",t[t.NOT_MODIFIED=304]="NOT_MODIFIED",t[t.USE_PROXY=305]="USE_PROXY",t[t.SWITCH_PROXY=306]="SWITCH_PROXY",t[t.TEMPORARY_REDIRECT=307]="TEMPORARY_REDIRECT",t[t.PERMANENT_REDIRECT=308]="PERMANENT_REDIRECT",t[t.BAD_REQUEST=400]="BAD_REQUEST",t[t.UNAUTHORIZED=401]="UNAUTHORIZED",t[t.PAYMENT_REQUIRED=402]="PAYMENT_REQUIRED",t[t.FORBIDDEN=403]="FORBIDDEN",t[t.NOT_FOUND=404]="NOT_FOUND",t[t.METHOD_NOT_ALLOWED=405]="METHOD_NOT_ALLOWED",t[t.NOT_ACCEPTABLE=406]="NOT_ACCEPTABLE",t[t.PROXY_AUTHENTICATION_REQUIRED=407]="PROXY_AUTHENTICATION_REQUIRED",t[t.REQUEST_TIMEOUT=408]="REQUEST_TIMEOUT",t[t.CONFLICT=409]="CONFLICT",t[t.GONE=410]="GONE",t[t.LENGTH_REQUIRED=411]="LENGTH_REQUIRED",t[t.PRECONDITION_FAILED=412]="PRECONDITION_FAILED",t[t.CONTENT_TOO_LARGE=413]="CONTENT_TOO_LARGE",t[t.PAYLOAD_TOO_LARGE=413]="PAYLOAD_TOO_LARGE",t[t.URI_TOO_LONG=414]="URI_TOO_LONG",t[t.UNSUPPORTED_MEDIA_TYPE=415]="UNSUPPORTED_MEDIA_TYPE",t[t.RANGE_NOT_SATISFIABLE=416]="RANGE_NOT_SATISFIABLE",t[t.EXPECTATION_FAILED=417]="EXPECTATION_FAILED",t[t.I_AM_A_TEAPOT=418]="I_AM_A_TEAPOT",t[t.MISDIRECTED_REQUEST=421]="MISDIRECTED_REQUEST",t[t.UNPROCESSABLE_ENTITY=422]="UNPROCESSABLE_ENTITY",t[t.UNPROCESSABLE_CONTENT=422]="UNPROCESSABLE_CONTENT",t[t.LOCKED=423]="LOCKED",t[t.FAILED_DEPENDENCY=424]="FAILED_DEPENDENCY",t[t.TOO_EARLY=425]="TOO_EARLY",t[t.UPGRADE_REQUIRED=426]="UPGRADE_REQUIRED",t[t.PRECONDITION_REQUIRED=428]="PRECONDITION_REQUIRED",t[t.TOO_MANY_REQUESTS=429]="TOO_MANY_REQUESTS",t[t.REQUEST_HEADER_FIELDS_TOO_LARGE=431]="REQUEST_HEADER_FIELDS_TOO_LARGE",t[t.UNAVAILABLE_FOR_LEGAL_REASONS=451]="UNAVAILABLE_FOR_LEGAL_REASONS",t[t.INTERNAL_SERVER_ERROR=500]="INTERNAL_SERVER_ERROR",t[t.NOT_IMPLEMENTED=501]="NOT_IMPLEMENTED",t[t.BAD_GATEWAY=502]="BAD_GATEWAY",t[t.SERVICE_UNAVAILABLE=503]="SERVICE_UNAVAILABLE",t[t.GATEWAY_TIMEOUT=504]="GATEWAY_TIMEOUT",t[t.HTTP_VERSION_NOT_SUPPORTED=505]="HTTP_VERSION_NOT_SUPPORTED",t[t.VARIANT_ALSO_NEGOTIATES=506]="VARIANT_ALSO_NEGOTIATES",t[t.INSUFFICIENT_STORAGE=507]="INSUFFICIENT_STORAGE",t[t.LOOP_DETECTED=508]="LOOP_DETECTED",t[t.NOT_EXTENDED=510]="NOT_EXTENDED",t[t.NETWORK_AUTHENTICATION_REQUIRED=511]="NETWORK_AUTHENTICATION_REQUIRED"})(cm||(dn.HttpStatusCode=cm={}));dn.HTTP_STATUS_TITLES={100:"Continue",101:"Switching Protocols",102:"Processing",103:"Early Hints",200:"OK",201:"Created",202:"Accepted",203:"Non-Authoritative Information",204:"No Content",205:"Reset Content",206:"Partial Content",207:"Multi-Status",208:"Already Reported",226:"IM Used",300:"Multiple Choices",301:"Moved Permanently",302:"Found",303:"See Other",304:"Not Modified",305:"Use Proxy",306:"Switch Proxy",307:"Temporary Redirect",308:"Permanent Redirect",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Timeout",409:"Conflict",410:"Gone",411:"Length Required",412:"Precondition Failed",413:"Content Too Large",414:"URI Too Long",415:"Unsupported Media Type",416:"Range Not Satisfiable",417:"Expectation Failed",418:"I'm a teapot",421:"Misdirected Request",422:"Unprocessable Content",423:"Locked",424:"Failed Dependency",425:"Too Early",426:"Upgrade Required",428:"Precondition Required",429:"Too Many Requests",431:"Request Header Fields Too Large",451:"Unavailable For Legal Reasons",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Timeout",505:"HTTP Version Not Supported",506:"Variant Also Negotiates",507:"Insufficient Storage",508:"Loop Detected",510:"Not Extended",511:"Network Authentication Required"}});var yl=_(ml=>{"use strict";Object.defineProperty(ml,"__esModule",{value:!0});var CT={100:"Continue",101:"Switching Protocols",102:"Processing",103:"Early Hints",200:"OK",201:"Created",202:"Accepted",203:"Non-Authoritative Information",204:"No Content",205:"Reset Content",206:"Partial Content",207:"Multi-Status",208:"Already Reported",226:"IM Used",300:"Multiple Choices",301:"Moved Permanently",302:"Found",303:"See Other",304:"Not Modified",305:"Use Proxy",307:"Temporary Redirect",308:"Permanent Redirect",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Timeout",409:"Conflict",410:"Gone",411:"Length Required",412:"Precondition Failed",413:"Payload Too Large",414:"URI Too Long",415:"Unsupported Media Type",416:"Range Not Satisfiable",417:"Expectation Failed",418:"I'm a Teapot",421:"Misdirected Request",422:"Unprocessable Entity",423:"Locked",424:"Failed Dependency",425:"Too Early",426:"Upgrade Required",428:"Precondition Required",429:"Too Many Requests",431:"Request Header Fields Too Large",451:"Unavailable For Legal Reasons",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Timeout",505:"HTTP Version Not Supported",506:"Variant Also Negotiates",507:"Insufficient Storage",508:"Loop Detected",509:"Bandwidth Limit Exceeded",510:"Not Extended",511:"Network Authentication Required"};ml.default=CT});var pe=_(pn=>{"use strict";var xT=pn&&pn.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(pn,"__esModule",{value:!0});pn.HttpProblems=void 0;var LT=un(),H=hl(),DT=xT(yl()),MT=ie(),gl=Ho();function UT(t){return`${new URL(t.url).pathname}`}o(UT,"instance");function kT(t,e){let r={timestamp:new Date().toISOString(),requestId:e.requestId,buildId:MT.Environment.instance.build.BUILD_ID},n=t.headers.get(LT.RAY_ID_HEADER);return n&&(r.rayId=n),r}o(kT,"trace");var FT=o((t,e,r,n,i)=>({problem:{type:t.type,title:t.title,status:t.status,detail:t.detail,instance:UT(e),trace:kT(e,r),...n},additionalHeaders:i,statusText:DT.default[t.status]}),"merge"),bl=class{static{o(this,"HttpProblemsBase")}static format=(e,r,n)=>"problem"in e?gl.ProblemResponseFormatter.format(e,r,n):gl.ProblemResponseFormatter.format({problem:e},r,n);static getProblemFromStatus(e,r){return{type:`https://httpproblems.com/http-status/${e}`,status:e,title:H.HTTP_STATUS_TITLES[e],...r}}},_l=class extends bl{static{o(this,"HttpProblems")}static#e(e,r,n,i,s){let a=FT(this.getProblemFromStatus(e),r,n,i,s);return gl.ProblemResponseFormatter.format(a,r,n)}static continue=(e,r,n,i)=>this.#e(H.HttpStatusCode.OK,e,r,n,i);static switchingProtocols=(e,r,n,i)=>this.#e(H.HttpStatusCode.SWITCHING_PROTOCOLS,e,r,n,i);static processing=(e,r,n,i)=>this.#e(H.HttpStatusCode.PROCESSING,e,r,n,i);static earlyHints=(e,r,n,i)=>this.#e(H.HttpStatusCode.EARLY_HINTS,e,r,n,i);static ok=(e,r,n,i)=>this.#e(H.HttpStatusCode.OK,e,r,n,i);static created=(e,r,n,i)=>this.#e(H.HttpStatusCode.CREATED,e,r,n,i);static accepted=(e,r,n,i)=>this.#e(H.HttpStatusCode.ACCEPTED,e,r,n,i);static nonAuthoritativeInformation=(e,r,n,i)=>this.#e(H.HttpStatusCode.NON_AUTHORITATIVE_INFORMATION,e,r,n,i);static noContent=(e,r,n,i)=>this.#e(H.HttpStatusCode.NO_CONTENT,e,r,n,i);static resetContent=(e,r,n,i)=>this.#e(H.HttpStatusCode.RESET_CONTENT,e,r,n,i);static partialContent=(e,r,n,i)=>this.#e(H.HttpStatusCode.PARTIAL_CONTENT,e,r,n,i);static multiStatus=(e,r,n,i)=>this.#e(H.HttpStatusCode.MULTI_STATUS,e,r,n,i);static alreadyReported=(e,r,n,i)=>this.#e(H.HttpStatusCode.ALREADY_REPORTED,e,r,n,i);static imUsed=(e,r,n,i)=>this.#e(H.HttpStatusCode.IM_USED,e,r,n,i);static multipleChoices=(e,r,n,i)=>this.#e(H.HttpStatusCode.MULTIPLE_CHOICES,e,r,n,i);static movedPermanently=(e,r,n,i)=>this.#e(H.HttpStatusCode.MOVED_PERMANENTLY,e,r,n,i);static found=(e,r,n,i)=>this.#e(H.HttpStatusCode.FOUND,e,r,n,i);static seeOther=(e,r,n,i)=>this.#e(H.HttpStatusCode.SEE_OTHER,e,r,n,i);static notModified=(e,r,n,i)=>this.#e(H.HttpStatusCode.NOT_MODIFIED,e,r,n,i);static useProxy=(e,r,n,i)=>this.#e(H.HttpStatusCode.USE_PROXY,e,r,n,i);static switchProxy=(e,r,n,i)=>this.#e(H.HttpStatusCode.SWITCH_PROXY,e,r,n,i);static temporaryRedirect=(e,r,n,i)=>this.#e(H.HttpStatusCode.TEMPORARY_REDIRECT,e,r,n,i);static permanentRedirect=(e,r,n,i)=>this.#e(H.HttpStatusCode.PERMANENT_REDIRECT,e,r,n,i);static badRequest=(e,r,n,i)=>this.#e(H.HttpStatusCode.BAD_REQUEST,e,r,n,i);static unauthorized=(e,r,n,i)=>this.#e(H.HttpStatusCode.UNAUTHORIZED,e,r,n,i);static paymentRequired=(e,r,n,i)=>this.#e(H.HttpStatusCode.PAYMENT_REQUIRED,e,r,n,i);static forbidden=(e,r,n,i)=>this.#e(H.HttpStatusCode.FORBIDDEN,e,r,n,i);static notFound=(e,r,n,i)=>this.#e(H.HttpStatusCode.NOT_FOUND,e,r,n,i);static methodNotAllowed=(e,r,n,i)=>this.#e(H.HttpStatusCode.METHOD_NOT_ALLOWED,e,r,n,i);static notAcceptable=(e,r,n,i)=>this.#e(H.HttpStatusCode.NOT_ACCEPTABLE,e,r,n,i);static proxyAuthenticationRequired=(e,r,n,i)=>this.#e(H.HttpStatusCode.PROXY_AUTHENTICATION_REQUIRED,e,r,n,i);static requestTimeout=(e,r,n,i)=>this.#e(H.HttpStatusCode.REQUEST_TIMEOUT,e,r,n,i);static conflict=(e,r,n,i)=>this.#e(H.HttpStatusCode.CONFLICT,e,r,n,i);static gone=(e,r,n,i)=>this.#e(H.HttpStatusCode.GONE,e,r,n,i);static lengthRequired=(e,r,n,i)=>this.#e(H.HttpStatusCode.LENGTH_REQUIRED,e,r,n,i);static preconditionFailed=(e,r,n,i)=>this.#e(H.HttpStatusCode.PRECONDITION_FAILED,e,r,n,i);static contentTooLarge=(e,r,n,i)=>this.#e(H.HttpStatusCode.CONTENT_TOO_LARGE,e,r,n,i);static uriTooLong=(e,r,n,i)=>this.#e(H.HttpStatusCode.URI_TOO_LONG,e,r,n,i);static unsupportedMediaType=(e,r,n,i)=>this.#e(H.HttpStatusCode.UNSUPPORTED_MEDIA_TYPE,e,r,n,i);static rangeNotSatisfiable=(e,r,n,i)=>this.#e(H.HttpStatusCode.RANGE_NOT_SATISFIABLE,e,r,n,i);static expectationFailed=(e,r,n,i)=>this.#e(H.HttpStatusCode.EXPECTATION_FAILED,e,r,n,i);static imATeapot=(e,r,n,i)=>this.#e(H.HttpStatusCode.I_AM_A_TEAPOT,e,r,n,i);static misdirectedRequest=(e,r,n,i)=>this.#e(H.HttpStatusCode.MISDIRECTED_REQUEST,e,r,n,i);static unprocessableContent=(e,r,n,i)=>this.#e(H.HttpStatusCode.UNPROCESSABLE_CONTENT,e,r,n,i);static locked=(e,r,n,i)=>this.#e(H.HttpStatusCode.LOCKED,e,r,n,i);static failedDependency=(e,r,n,i)=>this.#e(H.HttpStatusCode.FAILED_DEPENDENCY,e,r,n,i);static tooEarly=(e,r,n,i)=>this.#e(H.HttpStatusCode.TOO_EARLY,e,r,n,i);static upgradeRequired=(e,r,n,i)=>this.#e(H.HttpStatusCode.UPGRADE_REQUIRED,e,r,n,i);static preconditionRequired=(e,r,n,i)=>this.#e(H.HttpStatusCode.PRECONDITION_REQUIRED,e,r,n,i);static tooManyRequests=(e,r,n,i)=>this.#e(H.HttpStatusCode.TOO_MANY_REQUESTS,e,r,n,i);static requestHeaderFieldsTooLarge=(e,r,n,i)=>this.#e(H.HttpStatusCode.REQUEST_HEADER_FIELDS_TOO_LARGE,e,r,n,i);static unavailableForLegalReasons=(e,r,n,i)=>this.#e(H.HttpStatusCode.UNAVAILABLE_FOR_LEGAL_REASONS,e,r,n,i);static internalServerError=(e,r,n,i)=>this.#e(H.HttpStatusCode.INTERNAL_SERVER_ERROR,e,r,n,i);static notImplemented=(e,r,n,i)=>this.#e(H.HttpStatusCode.NOT_IMPLEMENTED,e,r,n,i);static badGateway=(e,r,n,i)=>this.#e(H.HttpStatusCode.BAD_GATEWAY,e,r,n,i);static serviceUnavailable=(e,r,n,i)=>this.#e(H.HttpStatusCode.SERVICE_UNAVAILABLE,e,r,n,i);static gatewayTimeout=(e,r,n,i)=>this.#e(H.HttpStatusCode.GATEWAY_TIMEOUT,e,r,n,i);static httpVersionNotSupported=(e,r,n,i)=>this.#e(H.HttpStatusCode.HTTP_VERSION_NOT_SUPPORTED,e,r,n,i);static variantAlsoNegotiates=(e,r,n,i)=>this.#e(H.HttpStatusCode.VARIANT_ALSO_NEGOTIATES,e,r,n,i);static insufficientStorage=(e,r,n,i)=>this.#e(H.HttpStatusCode.INSUFFICIENT_STORAGE,e,r,n,i);static loopDetected=(e,r,n,i)=>this.#e(H.HttpStatusCode.LOOP_DETECTED,e,r,n,i);static notExtended=(e,r,n,i)=>this.#e(H.HttpStatusCode.NOT_EXTENDED,e,r,n,i);static networkAuthenticationRequired=(e,r,n,i)=>this.#e(H.HttpStatusCode.NETWORK_AUTHENTICATION_REQUIRED,e,r,n,i)};pn.HttpProblems=_l});var st=_(K=>{"use strict";Object.defineProperty(K,"__esModule",{value:!0});K.isErrorLike=K.withUndefinedAsNull=K.withNullAsUndefined=K.validateConstraint=K.validateConstraints=K.areFunctions=K.isFunction=K.isEmptyObject=K.assertAllDefined=K.assertIsDefined=K.assertType=K.isUndefinedOrNull=K.isDefined=K.isUndefined=K.isBoolean=K.isIterable=K.isNumber=K.isTypedArray=K.isArray=K.isObject=K.getOwnEnumerableKeys=K.isRegexp=K.isStringArray=K.isNonEmptyString=K.isString=K.toString=void 0;var{toString:HT}=Object.prototype,{propertyIsEnumerable:qT}=Object.prototype;function um(t){return HT.call(t)}o(um,"toString");K.toString=um;function rs(t){return typeof t=="string"}o(rs,"isString");K.isString=rs;function $T(t){return rs(t)&&t!==""}o($T,"isNonEmptyString");K.isNonEmptyString=$T;function jT(t){return Array.isArray(t)&&t.every(e=>rs(e))}o(jT,"isStringArray");K.isStringArray=jT;function VT(t){return um(t)==="[object RegExp]"}o(VT,"isRegexp");K.isRegexp=VT;function BT(t){return[...Object.keys(t),...Object.getOwnPropertySymbols(t).filter(e=>qT.call(t,e))]}o(BT,"getOwnEnumerableKeys");K.getOwnEnumerableKeys=BT;function El(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)&&!(t instanceof RegExp)&&!(t instanceof Date)}o(El,"isObject");K.isObject=El;function GT(t){return El(t)&&Array.isArray(t)}o(GT,"isArray");K.isArray=GT;function KT(t){let e=Object.getPrototypeOf(Uint8Array);return typeof t=="object"&&t instanceof e}o(KT,"isTypedArray");K.isTypedArray=KT;function JT(t){return typeof t=="number"&&!isNaN(t)}o(JT,"isNumber");K.isNumber=JT;function zT(t){return!!t&&typeof t[Symbol.iterator]=="function"}o(zT,"isIterable");K.isIterable=zT;function WT(t){return t===!0||t===!1}o(WT,"isBoolean");K.isBoolean=WT;function lm(t){return typeof t>"u"}o(lm,"isUndefined");K.isUndefined=lm;function QT(t){return!Ii(t)}o(QT,"isDefined");K.isDefined=QT;function Ii(t){return lm(t)||t===null}o(Ii,"isUndefinedOrNull");K.isUndefinedOrNull=Ii;function YT(t,e){if(!t)throw new Error(e?`Unexpected type, expected '${e}'`:"Unexpected type")}o(YT,"assertType");K.assertType=YT;function ZT(t){if(Ii(t))throw new Error("Assertion Failed: argument is undefined or null");return t}o(ZT,"assertIsDefined");K.assertIsDefined=ZT;function XT(...t){let e=[];for(let r=0;r<t.length;r++){let n=t[r];if(Ii(n))throw new Error(`Assertion Failed: argument at index ${r} is undefined or null`);e.push(n)}return e}o(XT,"assertAllDefined");K.assertAllDefined=XT;var eS=Object.prototype.hasOwnProperty;function tS(t){if(!El(t))return!1;for(let e in t)if(eS.call(t,e))return!1;return!0}o(tS,"isEmptyObject");K.isEmptyObject=tS;function wl(t){return typeof t=="function"}o(wl,"isFunction");K.isFunction=wl;function rS(...t){return t.length>0&&t.every(wl)}o(rS,"areFunctions");K.areFunctions=rS;function nS(t,e){let r=Math.min(t.length,e.length);for(let n=0;n<r;n++)dm(t[n],e[n])}o(nS,"validateConstraints");K.validateConstraints=nS;function dm(t,e){if(rs(e)){if(typeof t!==e)throw new Error(`argument does not match constraint: typeof ${e}`)}else if(wl(e)){try{if(t instanceof e)return}catch{}if(!Ii(t)&&t.constructor===e||e.length===1&&e.call(void 0,t)===!0)return;throw new Error("argument does not match one of these constraints: arg instanceof constraint, arg.constructor === constraint, nor constraint(arg) === true")}}o(dm,"validateConstraint");K.validateConstraint=dm;function iS(t){return t===null?void 0:t}o(iS,"withNullAsUndefined");K.withNullAsUndefined=iS;function oS(t){return typeof t>"u"?null:t}o(oS,"withUndefinedAsNull");K.withUndefinedAsNull=oS;function sS(t){return!!t&&typeof t=="object"&&"name"in t&&"message"in t&&"stack"in t}o(sS,"isErrorLike");K.isErrorLike=sS});var Kt=_(Ot=>{"use strict";Object.defineProperty(Ot,"__esModule",{value:!0});Ot.parseValueToBoolean=Ot.parseValueToStringArray=Ot.getValueFromRequestUser=Ot.statusCodesStringToNumberArray=void 0;var fn=k(),vl=st(),pm=new Map;function aS(t){if(Array.isArray(t)&&!t.some(i=>typeof i!="number"))return t;if(typeof t!="string")throw new Error("Input must be a string or an array of numbers");if(!/^\d+(?:-\d+)?(?:,\s*\d+(?:-\d+)?)*$/.test(t))throw new Error("Malformed input string");let e=pm.get(t);if(e)return e;let r=t.split(","),n=[];for(let i of r){let s=i.split("-");if(s.length===2){let a=parseInt(s[0],10),c=parseInt(s[1],10);for(let u=a;u<=c;u++)n.push(u)}else n.push(parseInt(i,10))}return pm.set(t,n),n}o(aS,"statusCodesStringToNumberArray");Ot.statusCodesStringToNumberArray=aS;function cS(t,e,r){if(!e.startsWith("."))throw new fn.ConfigurationError(`Invalid ${r} - must start with '.' - '${e}' does not`);let n=e.split(".").splice(1),i=t;return n.forEach(s=>{if(i===void 0)throw new fn.RuntimeError(`Error applying ${r} '${e}', reading '${s}'`);i=i[s]}),`${i}`}o(cS,"getValueFromRequestUser");Ot.getValueFromRequestUser=cS;function uS(t){if(Array.isArray(t)){if(t.includes(r=>typeof r!="string"))throw new fn.ConfigurationError("Received an array that contains non-string values.");return t}if((0,vl.isString)(t))return t.includes(",")?t.split(",").map(r=>r.trim()).filter(r=>r!==","&&r!==""):[t];throw new fn.ConfigurationError(`Expected type of string, received type '${typeof t}'`)}o(uS,"parseValueToStringArray");Ot.parseValueToStringArray=uS;function lS(t){if((0,vl.isBoolean)(t))return t;if((0,vl.isString)(t)){if(t.toLowerCase()==="true")return!0;if(t.toLowerCase()==="false")return!1;throw new fn.ConfigurationError(`Attempted to parse string to boolean, but received ${t} which cannot be parsed.`)}throw new fn.ConfigurationError(`Expected type of boolean, received type '${typeof t}'`)}o(lS,"parseValueToBoolean");Ot.parseValueToBoolean=lS});var is=_(ur=>{"use strict";Object.defineProperty(ur,"__esModule",{value:!0});ur.generateCorsHeaders=ur.findMatchingOrigin=ur.parseCorsPolicies=void 0;var jr=k(),fm=Kt(),ns=st();function dS(t){if(t==null)return[];if(!Array.isArray(t))throw new jr.ConfigurationError(`Invalid corsPolicy configuration. Expected an array of objects, received '${typeof t}'`);return t.map(r=>{if(!(0,ns.isObject)(r))throw new jr.ConfigurationError(`Invalid custom cors policy is set. Expected an object, received '${typeof r}'`);if(!(0,ns.isNonEmptyString)(r.name))throw new jr.ConfigurationError("Value of 'name' on custom cors policies must be a non-empty string.");if(r.maxAge!==void 0&&!(0,ns.isNumber)(r.maxAge))throw new jr.ConfigurationError(`Value of 'maxAge' on custom cors policies must be a non-empty string. Received type '${typeof r.maxAge}'`);if(r.allowCredentials!==void 0&&!(0,ns.isBoolean)(r.allowCredentials))throw new jr.ConfigurationError("Value of 'allowCredentials' on custom cors policies must be a boolean or not be set. If using an environment variable, check that it is set correctly.");let n=Tl(r,"allowedHeaders"),i=Tl(r,"allowedMethods"),s=Tl(r,"exposeHeaders"),a;try{a=(0,fm.parseValueToStringArray)(r.allowedOrigins)}catch(u){throw new jr.ConfigurationError(`Value of 'allowedOrigins' on custom cors policies is invalid. ${u.message} If using an environment variable, check that it is set correctly.`)}return{name:r.name,allowCredentials:typeof r.allowCredentials=="boolean"?String(r.allowCredentials):void 0,allowedOrigins:a,allowedHeaders:n?n.join(", "):void 0,allowedMethods:i?i.join(", "):void 0,exposeHeaders:s?s.join(", "):void 0,maxAge:typeof r.maxAge=="number"?r.maxAge.toString():void 0}})}o(dS,"parseCorsPolicies");ur.parseCorsPolicies=dS;function Tl(t,e){let r;if(t[e]!==void 0)try{r=(0,fm.parseValueToStringArray)(t[e])}catch(n){throw new jr.ConfigurationError(`Value of '${e}' on custom cors policies is invalid. ${n.message} If using an environment variable, check that it is set correctly.`)}return r}o(Tl,"parseOptionalProperty");var pS=o((t,e)=>{if(e===null)return;if(t.find(a=>a==="*"))return e;let n=t.map(a=>a.trim().toLowerCase()),i=e.toLowerCase();return n.find(a=>a===i)},"findMatchingOrigin");ur.findMatchingOrigin=pS;var fS=o((t,e)=>{let r={"access-control-allow-origin":e};t.allowedHeaders&&(r["access-control-allow-headers"]=t.allowedHeaders),t.allowedMethods&&(r["access-control-allow-methods"]=t.allowedMethods),t.exposeHeaders&&(r["access-control-expose-headers"]=t.exposeHeaders);let n=t.allowCredentials;n&&(r["access-control-allow-credentials"]=n);let i=t.maxAge?.toString()??void 0;return i&&(r["access-control-max-age"]=i),r},"generateCorsHeaders");ur.generateCorsHeaders=fS});var mm=_(os=>{"use strict";Object.defineProperty(os,"__esModule",{value:!0});os.registerCorsRoute=void 0;var hS=k(),mS=Bt(),Sl=pe(),yS=ar(),gS=$r(),bS=mt(),hm=is(),_S=o((t,e)=>{let r=e.routeData.corsPolicies,n=o(async(a,c)=>{let u=new URL(a.url.toString()).pathname,l=a.headers.get("access-control-request-method"),d=a.headers.get("access-control-request-headers"),p=a.headers.get("origin");if(p===null||l===null)return Sl.HttpProblems.badRequest(a,c,{detail:"Expect headers origin and access-control-request-method"});let f=t.lookup(l,u);if(!f)return Sl.HttpProblems.notFound(a,c);let h=f.routeConfiguration,m=ES(l,d,p,h,r);return m.isValid?new Response(void 0,{status:200,statusText:"OK",headers:m.headers}):(m.error&&c.log.warn(m.error),Sl.HttpProblems.notFound(a,c))},"optionsHandler"),i=new mS.Pipeline({processors:[yS.metricsProcessor],handler:n,gateway:e}),s=new bS.SystemRouteConfiguration({label:"SYSTEM_CORS_ROUTE",methods:["OPTIONS"],path:"/(.*)",systemRouteName:gS.SystemRouteName.CorsPreflight});t.addRoute(s,i.execute)},"registerCorsRoute");os.registerCorsRoute=_S;var ES=o((t,e,r,n,i)=>{let s={isValid:!1,headers:{}};if(n.corsPolicy==="anything-goes")return{isValid:!0,headers:{"access-control-allow-origin":r,"access-control-allow-methods":t,"access-control-allow-headers":e??"*","access-control-expose-headers":"*","access-control-allow-credentials":"true","access-control-max-age":"600"}};if(n.corsPolicy==="none")return{...s,error:`No CORS policy set for the route '${n.pathPattern}'`};let a=i?.find(l=>l.name===n.corsPolicy);if(!a)throw new hS.ConfigurationError(`Invalid Configuration - corsPolicy '${n.corsPolicy}' not found in *.oas.json 'corsPolicies' section.`);let c=(0,hm.findMatchingOrigin)(a.allowedOrigins,r);return c?{isValid:!0,headers:(0,hm.generateCorsHeaders)(a,c)}:{...s,error:`The CORS policy '${a.name}' does not allow the origin '${r}'`}},"validateAndBuildResponseHeaders")});var ym=_(ss=>{"use strict";Object.defineProperty(ss,"__esModule",{value:!0});ss.registerNoRoutes=void 0;var wS=Bt(),vS=ar(),TS=$r(),SS=mt(),IS=o((t,e)=>{let r=o(async()=>new Response("You have no routes. Add a route in routes.oas.json to get started",{status:200}),"noRoutesHandler"),n=new wS.Pipeline({processors:[vS.metricsProcessor],handler:r,gateway:e}),i=new SS.SystemRouteConfiguration({label:"SYSTEM_NO_ROUTES",methods:["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"],path:"/(.*)",systemRouteName:TS.SystemRouteName.EmptyGatewayCatchall});t.addRoute(i,n.execute)},"registerNoRoutes");ss.registerNoRoutes=IS});var gm=_(Vr=>{"use strict";Object.defineProperty(Vr,"__esModule",{value:!0});Vr.registerNotMatchedHandler=Vr.notFoundRouteConfiguration=void 0;var PS=Hr(),AS=Rt(),RS=Bt(),OS=pe(),NS=ar(),CS=$r(),xS=mt();Vr.notFoundRouteConfiguration=new xS.SystemRouteConfiguration({label:"SYSTEM_NOT_FOUND_ROUTE",methods:["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"],path:"/(.*)",systemRouteName:CS.SystemRouteName.UnmatchedPath});var LS=o((t,e)=>{let r=o(async(i,s)=>{let a=AS.runtimeExtensions.value?.notFoundHandler;if(a){let c=PS.ZuploContextExtensions.getContextExtensions(s);return a(i,s,{routesMatchedByPathOnly:c.pathOnlyMatches??[]})}return OS.HttpProblems.notFound(i,s)},"notFoundHandler"),n=new RS.Pipeline({processors:[NS.metricsProcessor],handler:r,gateway:e});t.addRoute(Vr.notFoundRouteConfiguration,n.execute)},"registerNotMatchedHandler");Vr.registerNotMatchedHandler=LS});var Il=_(as=>{"use strict";Object.defineProperty(as,"__esModule",{value:!0});as.corsProcessor=void 0;var Em=k(),bm=is(),DS=["access-control-allow-origin","access-control-allow-headers","access-control-expose-headers","access-control-allow-credentials","access-control-max-age"],_m=o(t=>{DS.forEach(e=>t.delete(e))},"stripCorsHeaders"),MS=o(async(t,e,r,n)=>{let i=e.route;if(!i.corsPolicy||i.corsPolicy==="none"){let d=await n(t),p=new Headers(d.headers);return _m(p),new Response(d.body,{status:d.status,statusText:d.statusText,headers:p,webSocket:d.webSocket})}let s=await n(t);if(!(s instanceof Response))throw new Em.SystemError(`The CorsProcessor is in the wrong place in the pipeline. It should only receive HttpResponse type but got '${typeof s}'`);let a=US(i,r.routeData.corsPolicies),c=kS(t,a),u=new Headers(s.headers);return _m(u),Object.entries(c).forEach(([d,p])=>{u.set(d,p)}),new Response(s.body,{status:s.status,statusText:s.statusText,headers:u,webSocket:s.webSocket})},"corsProcessor");as.corsProcessor=MS;var US=o((t,e)=>{if(t.corsPolicy==="anything-goes")return{name:"anything-goes",allowedHeaders:"*",allowedOrigins:["*"],allowedMethods:t.methods.join(", "),exposeHeaders:"*",allowCredentials:"true",maxAge:"600"};let r=e?.find(n=>n.name===t.corsPolicy);if(r===void 0)throw new Em.ConfigurationError(`Invalid Configuration - no corsPolicy '${t.corsPolicy}' found in *.oas.json`);return r},"getCorsPolicy"),kS=o((t,e)=>{let r=(0,bm.findMatchingOrigin)(e.allowedOrigins,t.headers.get("origin"));return r?(0,bm.generateCorsHeaders)(e,r):{}},"getCorsHeaders")});var wm=_(cs=>{"use strict";Object.defineProperty(cs,"__esModule",{value:!0});cs.registerPingRoute=void 0;var FS=Bt(),HS=Il(),qS=$r(),$S=mt(),jS=o((t,e)=>{let r=o(async()=>new Response(null,{status:200}),"pingRouteHandler"),n=new FS.Pipeline({processors:[HS.corsProcessor],handler:r,gateway:e}),i=new $S.SystemRouteConfiguration({corsPolicy:"anything-goes",label:"SYSTEM_PING_ROUTE",methods:["GET"],path:"/__zuplo/ping",systemRouteName:qS.SystemRouteName.Ping});t.addRoute(i,n.execute)},"registerPingRoute");cs.registerPingRoute=jS});var mn=_(hn=>{"use strict";Object.defineProperty(hn,"__esModule",{value:!0});hn.OutboundPolicy=hn.InboundPolicy=void 0;var VS=k(),BS=st(),us=class{static{o(this,"PolicyBase")}options;policyName;constructor(e,r){if(!(0,BS.isString)(r))throw new VS.RuntimeError(`The name of a policy must be a string. Received '${r}' of type '${typeof r}'`);this.options=e,this.policyName=r}},Pl=class extends us{static{o(this,"InboundPolicy")}};hn.InboundPolicy=Pl;var Al=class extends us{static{o(this,"OutboundPolicy")}};hn.OutboundPolicy=Al});var yn=_(yt=>{"use strict";Object.defineProperty(yt,"__esModule",{value:!0});yt.createInternalPolicyProcessor=yt.policyProcessor=yt.toStackedInboundHandler=yt.getInboundPolicyInstances=void 0;var GS=Hr(),qe=k(),ls=mn(),vm=Ge(),KS=ie(),Nl=class extends ls.InboundPolicy{static{o(this,"InboundFunctionOnlyPolicy")}#e;constructor(e,r,n){super(r,n),this.#e=e}handler(e,r){return this.#e(e,r,this.options,this.policyName)}},Cl=class extends ls.OutboundPolicy{static{o(this,"OutboundFunctionOnlyPolicy")}#e;constructor(e,r,n){super(r,n),this.#e=e}handler(e,r,n){return this.#e(e,r,n,this.options,this.policyName)}},Rl=new Map;function Tm(t,e){let r,n;return Array.isArray(t)?r=t:(r=t.policies?.inbound??[],n=t.path),r.filter(s=>!Rl.has(s)).forEach(s=>{let a=e?.find(l=>l.name===s);if(!a)throw new qe.ConfigurationError(`Invalid state - no Policy with the name '${s}' ${n&&`on route '${n}'`} was found in the policies configuration (check case).`);if(typeof a.handler?.module!="object")throw new qe.ConfigurationError(`Invalid state - invalid policy '${s}' on route '${n}' (typeof policy '${typeof a.handler?.module}')`);let c=a.handler?.module[a.handler.export];if(typeof c!="function")throw new qe.ConfigurationError(`Invalid state - invalid policy '${s}' on route '${n}' (typeof module '${typeof c}')`);let u;if(typeof c!="function")throw new qe.ConfigurationError(`Invalid state - invalid policy '${s}' on route '${n}' (typeof module '${typeof c}')`);if(c.prototype instanceof ls.InboundPolicy)u=new c(a.handler.options,a.name);else if(typeof c=="function")u=new Nl(c,a.handler.options,a.name);else throw new qe.ConfigurationError(`Invalid state - invalid policy '${s}' on route '${n}' (typeof policy '${typeof c}')`);if(typeof u.handler!="function")throw new qe.ConfigurationError(`Invalid state - invalid handler on policy '${s}' on route '${n}' (typeof handler '${typeof u.handler}')`);Rl.set(a.name,u)}),r.map(s=>{let a=Rl.get(s);if(a===void 0)throw new qe.RuntimeError("Internal error. Policy not found in cache.");return a})}o(Tm,"getInboundPolicyInstances");yt.getInboundPolicyInstances=Tm;var Ol=new Map;function JS(t,e){let r=t.policies?.outbound??[];return r.filter(i=>!Ol.has(i)).forEach(i=>{let s=e?.find(u=>u.name===i);if(!s)throw new qe.ConfigurationError(`Invalid state - no Policy with the name '${i}' on route '${t.path}' was found in the policies configuration (check case).`);if(typeof s.handler?.module!="object")throw new qe.ConfigurationError(`Invalid state - invalid policy '${i}' on route '${t.path}' (typeof policy '${typeof s.handler?.module}')`);let a=s.handler?.module[s.handler.export],c;if(typeof a!="function")throw new qe.ConfigurationError(`Invalid state - invalid policy '${i}' on route '${t.path}' (typeof module '${typeof a}')`);if(a.prototype instanceof ls.OutboundPolicy)c=new a(s.handler.options??{},s.name);else if(typeof a=="function")c=new Cl(a,s.handler.options??{},s.name);else throw new qe.ConfigurationError(`Invalid state - invalid policy '${i}' on route '${t.path}' (typeof policy '${typeof a}')`);if(typeof c.handler!="function")throw new qe.ConfigurationError(`Invalid state - invalid handler on policy '${i}' on route '${t.path}'`);Ol.set(s.name,c)}),r.map(i=>{let s=Ol.get(i);if(s===void 0)throw new qe.RuntimeError("Internal error. Policy not found in cache.");return s})}o(JS,"getOutboundPolicyInstances");var zS=o(t=>async(e,r)=>{let n=GS.ZuploContextExtensions.getContextExtensions(r),i=[...t],s=e;for(;i.length>0;){let a=i.shift();if(!a)return s;let c=await a.handler(s,r);if(c instanceof vm.ZuploRequest)s=c;else if(c instanceof Request)s=new vm.ZuploRequest(c);else{if(c instanceof Response)return c;throw new qe.ConfigurationError(`Invalid state - invalid handler on policy '${a.policyName}' on route '${r.route.path}. The result of an inbound policy must be a Response or Request.`)}n.latestRequest=s}return s},"toStackedInboundHandler");yt.toStackedInboundHandler=zS;var WS=o(t=>async(e,r,n)=>{let i=[...t],s=e;for(;i.length>0;){let a=i.shift();if(!a)return s;let c=await a.handler(s,r,n);if(!(c instanceof Response))throw new qe.ConfigurationError(`Invalid state - invalid handler on policy '${a.policyName}' on route '${n.route.path}. The result of an outbound policy must be a Response.`);s=c}return s},"toStackedOutboundHandler"),QS=o(async(t,e,r,n)=>{let i=Tm(e.route,r.routeData.policies),s=JS(e.route,r.routeData.policies);return Sm({request:t,context:e,inboundPolicies:i,outboundPolicies:s,gateway:r,next:n})},"policyProcessor");yt.policyProcessor=QS;function YS({inboundPolicies:t=[],outboundPolicies:e=[]}){return o(async(n,i,s,a)=>Sm({request:n,context:i,inboundPolicies:t,outboundPolicies:e,gateway:s,next:a}),"policyProcessor")}o(YS,"createInternalPolicyProcessor");yt.createInternalPolicyProcessor=YS;async function Sm({request:t,context:e,inboundPolicies:r,outboundPolicies:n,gateway:i,next:s}){let a=(0,yt.toStackedInboundHandler)(r);try{let c=await a(t,e);if(c instanceof Response)return c;let u=await s(c),l=WS(n),d;return KS.Environment.instance.build.COMPATIBILITY_FLAGS.runOutboundPoliciesOnHandlerOnAllStatuses?d=l(u,t,e):d=u.ok?l(u,t,e):u,d}catch(c){return e.log.error(c),i.errorHandler(t,e,c)}}o(Sm,"executePolicyProcessor")});var Im=_(gn=>{"use strict";Object.defineProperty(gn,"__esModule",{value:!0});gn.serialize=gn.parse=void 0;var ZS=Object.prototype.toString,ds=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;function XS(t,e){if(typeof t!="string")throw new TypeError("argument str must be a string");let r={},i=(e||{}).decode||tI,s=0;for(;s<t.length;){let a=t.indexOf("=",s);if(a===-1)break;let c=t.indexOf(";",s);if(c===-1)c=t.length;else if(c<a){s=t.lastIndexOf(";",a-1)+1;continue}let u=t.slice(s,a).trim();if(r[u]===void 0){let l=t.slice(a+1,c).trim();l.charCodeAt(0)===34&&(l=l.slice(1,-1)),r[u]=iI(l,i)}s=c+1}return r}o(XS,"parse");gn.parse=XS;function eI(t,e,r){let n=r||{},i=n.encode||rI;if(typeof i!="function")throw new TypeError("option encode is invalid");if(!ds.test(t))throw new TypeError("argument name is invalid");let s=i(e);if(s&&!ds.test(s))throw new TypeError("argument val is invalid");let a=t+"="+s;if(n.maxAge!=null){let c=n.maxAge-0;if(isNaN(c)||!isFinite(c))throw new TypeError("option maxAge is invalid");a+="; Max-Age="+Math.floor(c)}if(n.domain){if(!ds.test(n.domain))throw new TypeError("option domain is invalid");a+="; Domain="+n.domain}if(n.path){if(!ds.test(n.path))throw new TypeError("option path is invalid");a+="; Path="+n.path}if(n.expires){let c=n.expires;if(!nI(c)||isNaN(c.valueOf()))throw new TypeError("option expires is invalid");a+="; Expires="+c.toUTCString()}if(n.httpOnly&&(a+="; HttpOnly"),n.secure&&(a+="; Secure"),n.priority)switch(typeof n.priority=="string"?n.priority.toLowerCase():n.priority){case"low":a+="; Priority=Low";break;case"medium":a+="; Priority=Medium";break;case"high":a+="; Priority=High";break;default:throw new TypeError("option priority is invalid")}if(n.sameSite)switch(typeof n.sameSite=="string"?n.sameSite.toLowerCase():n.sameSite){case!0:a+="; SameSite=Strict";break;case"lax":a+="; SameSite=Lax";break;case"strict":a+="; SameSite=Strict";break;case"none":a+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}return a}o(eI,"serialize");gn.serialize=eI;function tI(t){return t.indexOf("%")!==-1?decodeURIComponent(t):t}o(tI,"decode");function rI(t){return encodeURIComponent(t)}o(rI,"encode");function nI(t){return ZS.call(t)==="[object Date]"||t instanceof Date}o(nI,"isDate");function iI(t,e){try{return e(t)}catch{return t}}o(iI,"tryDecode")});var Pm=_(ps=>{"use strict";Object.defineProperty(ps,"__esModule",{value:!0});ps.devPortalBaseURL=void 0;var oI=Im();function sI(t,e){try{let r=/v\d+(-\d+)?/g,i=(0,oI.parse)(e.get("Cookie")||"")["zp-dev-portal"];return i!==null&&i&&r.test(i)?`https://dev-portal-${i}.zuplo.com`:t}catch{}return t}o(sI,"devPortalBaseURL");ps.devPortalBaseURL=sI});var Cm=_(bn=>{"use strict";Object.defineProperty(bn,"__esModule",{value:!0});bn.registerDevPortalLegacyRedirectRoute=bn.registerDevPortalV3Route=void 0;var xl=Gt(),Rm=Bt(),Om=ar(),aI=yn(),Nm=mt(),cI=Pm(),lr=ie(),Am="/__zuplo/dev-portal",uI="dev-portal-id",lI="dev-portal-host",dI="zp-account",pI="zp-project",fI="dev-portal-build",hI=`
36
36
  <!DOCTYPE html>
37
37
  <html lang="en">
38
38
  <head>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zuplo/graphql",
3
- "version": "5.1815.0",
3
+ "version": "5.1817.0",
4
4
  "repository": "https://github.com/zuplo/zuplo",
5
5
  "author": "Zuplo, Inc.",
6
6
  "exports": {