@zuplo/graphql 5.1853.0 → 5.1855.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 +1 -1
- package/package.json +1 -1
package/index.minified.js
CHANGED
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
`))):c=t.stylize("[Circular]","special")),Zh(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(ul,"formatProperty");function pT(t,e){if(Zh(e))return t.stylize("undefined","undefined");if(Xh(e)){let r="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return t.stylize(r,"string")}if(uT(e))return t.stylize(""+e,"number");if(aT(e))return t.stylize(""+e,"boolean");if(em(e))return t.stylize("null","null")}o(pT,"formatPrimitive");function fT(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(fT,"reduceToSingleString")});var nm=_($o=>{"use strict";Object.defineProperty($o,"__esModule",{value:!0});$o.format=void 0;var hT=Qh(),mT=rm(),yT=o((t,...e)=>(0,hT.format)(mT.inspect,t,e),"format");$o.format=yT});var or=_(ir=>{"use strict";Object.defineProperty(ir,"__esModule",{value:!0});ir.debug=ir.withoutEnv=ir.Debugger=void 0;var gT=Wh(),bT=nm(),jo=class{static{o(this,"Debugger")}manager;ns;color;last;enabled;constructor(e,r){this.manager=e,this.ns=r,this.color=(0,gT.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,bT.format)(r,...e);let s=`${this.color(this.ns)} ${r} ${this.color(`+${i}ms`)}`;console.log(s),this.last=Date.now()}};ir.Debugger=jo;var Vo=class{static{o(this,"DebugManager")}debuggers;enabled;constructor(e){this.debuggers=new Map,this.enabled=e??[]}};function im(t){return!t||t.length===0?[]:(t=t.replace(/\s/g,"").replace(/\*/g,".+"),t.split(",").map(e=>new RegExp(`^${e}$`)))}o(im,"extract");var Oi;function _T(t){t||(t=[]),typeof t=="string"&&(t=im(t)),Oi=new Vo(t)}o(_T,"withoutEnv");ir.withoutEnv=_T;function ET(t){let e=globalThis.DEBUG;Oi||(Oi=new Vo(im(e)));let r=new jo(Oi,t);return Oi.debuggers.set(t,r),Object.assign(r.log.bind(r),{self:r})}o(ET,"debug");ir.debug=ET});var Go=_(hn=>{"use strict";Object.defineProperty(hn,"__esModule",{value:!0});hn.ProblemResponseFormatter=hn.InternalProblemResponseFormatter=void 0;var wT=k(),Bo=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 wT.RuntimeError("Error in custom 'problemResponseFormat'",{cause:s})}})}};hn.InternalProblemResponseFormatter=Bo;var pl=class{static{o(this,"ProblemResponseFormatter")}static async format(e,r,n){return await Bo.problemResponseFormat(e,r,n)}};hn.ProblemResponseFormatter=pl});var sm=_(Ko=>{"use strict";Object.defineProperty(Ko,"__esModule",{value:!0});Ko.deepFreeze=void 0;function om(t){for(let e in t){let r=t[e];r&&typeof r=="object"&&om(r)}return Object.freeze(t)}o(om,"deepFreeze");Ko.deepFreeze=om});var Ke=_(Jo=>{"use strict";Object.defineProperty(Jo,"__esModule",{value:!0});Jo.ZuploRequest=void 0;var am=sm(),fl=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,am.deepFreeze)(this.#e)}get params(){return(0,am.deepFreeze)(this.#t)}user};Jo.ZuploRequest=fl});var Ot=_(Ie=>{"use strict";Object.defineProperty(Ie,"__esModule",{value:!0});Ie.initializeRuntime=Ie.invokeOnResponseSendingFinalExtensions=Ie.invokeOnResponseSendingExtensions=Ie.invokeOnRequestExtensions=Ie.plugins=Ie.runtimeExtensions=Ie.SystemRuntimePlugin=Ie.RuntimePlugin=void 0;var cm=k(),vT=Go(),TT=Ke(),Wo=class{static{o(this,"RuntimePlugin")}};Ie.RuntimePlugin=Wo;var Qo=class extends Wo{static{o(this,"SystemRuntimePlugin")}async initialize(e){return Promise.resolve()}registerRoutes(e,r){}};Ie.SystemRuntimePlugin=Qo;Ie.runtimeExtensions={};var hl=[];Ie.plugins=hl;var um=[],lm=[],dm=[],zo={addPlugin(t){hl.push(t)},addRequestHook(t){um.push(t)},addResponseSendingHook(t){lm.push(t)},addResponseSendingFinalHook(t){dm.push(t)}},ST=o(async(t,e)=>{let r=t;for(let n of um){let i=await n(r,e);if(i instanceof TT.ZuploRequest)r=i;else{if(i instanceof Response)return i;throw new cm.ConfigurationError(`Invalid state - the OnRequest hook must return a ZuploRequest or Response. Received ${typeof r}.`)}}return r},"invokeOnRequestExtensions");Ie.invokeOnRequestExtensions=ST;var IT=o(async(t,e,r)=>{let n=t;for(let i of lm){let s=await i(t,e,r);if(s instanceof Response)n=s;else throw new cm.ConfigurationError(`Invalid state - the OnResponseSending hook must return a Response. Received ${typeof n}.`)}return n},"invokeOnResponseSendingExtensions");Ie.invokeOnResponseSendingExtensions=IT;var PT=o(async(t,e,r)=>{for(let n of dm)await n(t,e,r)},"invokeOnResponseSendingFinalExtensions");Ie.invokeOnResponseSendingFinalExtensions=PT;async function AT(t=()=>Promise.resolve()){await t(zo),Ie.runtimeExtensions.value=zo;for(let e of hl)e instanceof Qo&&await e.initialize(zo);vT.InternalProblemResponseFormatter.setProblemResponseFormat(zo.problemResponseFormat)}o(AT,"initializeRuntime");Ie.initializeRuntime=AT});var ml=_(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 RT(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(RT,"serialize");sr.serialize=RT});var yl=_(Yo=>{"use strict";Object.defineProperty(Yo,"__esModule",{value:!0});Yo.isSystemRoute=void 0;var pm=qr();function OT(t){return pm.Gateway.instance.runtimeSettings.developerPortal.enabled&&t.pathname.startsWith(pm.Gateway.instance.runtimeSettings.developerPortal.sitePathname)||t.pathname.startsWith("/__zuplo/")}o(OT,"isSystemRoute");Yo.isSystemRoute=OT});var Gt=_(Zo=>{"use strict";Object.defineProperty(Zo,"__esModule",{value:!0});Zo.Pipeline=void 0;var gl=$r(),fm=Ot(),NT=ml(),CT=ie(),xT=yl(),bl=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 I=a.pop();return I?I(i,s,r,c):await this.#e(async g=>{let v=await n(g,s);return LT(v)},r)(b,s)},"nextPipe"),l=await c(i),d=new URL(i.url);if((0,xT.isSystemRoute)(d)&&CT.Environment.instance.build.COMPATIBILITY_FLAGS.doNotRunHooksOnSystemRoutes)return l;let p=new gl.ResponseSendingEvent(i,l);s.dispatchEvent(p);let f=gl.ZuploContextExtensions.getContextExtensions(s),h=f.latestRequest,y;try{y=await p.mutableResponse}catch(b){return s.log.error(b),r.errorHandler(i,s,b)}try{y=await f.onResponseSending(y,h,s)}catch(b){return s.log.error(`Error invoking 'context.onResponseSending' hook: '${b.message}'`,b),r.errorHandler(i,s,b)}try{y=await(0,fm.invokeOnResponseSendingExtensions)(y,h,s)}catch(b){return s.log.error(`Error invoking 'context.onResponseSending' hook: '${b.message}'`,b),r.errorHandler(i,s,b)}s.dispatchEvent(new gl.ResponseSentEvent(i,y));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,fm.invokeOnResponseSendingFinalExtensions)(l,h,s)}catch(b){throw s.log.error(`Error invoking 'runtime.onResponseSending' hook: '${b.message}'`,b),b}return y}};Zo.Pipeline=bl;function LT(t){return t instanceof Response?t:typeof t>"u"?new Response:new Response((0,NT.serialize)(t),{headers:{"content-type":"application/json"}})}o(LT,"resultToResponse")});var es=_(Xo=>{"use strict";Object.defineProperty(Xo,"__esModule",{value:!0});Xo.MetricsPlugin=void 0;var DT=Ot(),_l=class extends DT.RuntimePlugin{static{o(this,"MetricsPlugin")}};Xo.MetricsPlugin=_l});var Je=_(ts=>{"use strict";Object.defineProperty(ts,"__esModule",{value:!0});ts.SystemLogMap=void 0;var MT=k(),El=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 MT.SystemError(n)}return r}static addLogger(e,r){t.#e.set(e,r)}};ts.SystemLogMap=El});var Re=_(rs=>{"use strict";Object.defineProperty(rs,"__esModule",{value:!0});rs.BatchDispatch=void 0;var wl=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}};rs.BatchDispatch=wl});var mm=_(is=>{"use strict";Object.defineProperty(is,"__esModule",{value:!0});is.EllieMetricsTransport=void 0;var hm=Je(),UT=Re(),ns=ie(),vl=class{static{o(this,"EllieMetricsTransport")}#e;#t;#r;constructor(e){this.#r=ns.Environment.instance.loggingId,this.#e=e,this.#t=new UT.BatchDispatch("ellie-metrics-transport",10,this.dispatchFunction,hm.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}=ns.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":ns.Environment.instance.deploymentName??"unknown","user-agent":ns.Environment.instance.systemUserAgent}});if(!c.ok){let u=await c.text();hm.SystemLogMap.getLogger(this.#e).error(`Metrics POST responded ${c.status}: ${c.statusText}`,u)}}}};is.EllieMetricsTransport=vl});var gt=_(jr=>{"use strict";Object.defineProperty(jr,"__esModule",{value:!0});jr.systemNoVersion=jr.SystemRouteConfiguration=void 0;var Tl=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=jr.systemNoVersion.name,this.handler={export:"SYSTEM_IGNORED",module:"SYSTEM_IGNORED"},this.systemRouteName=i}label;path;methods;handler;corsPolicy;version;policies;systemRouteName;raw(){return{}}};jr.SystemRouteConfiguration=Tl;jr.systemNoVersion={name:"__system-no-version",pathPrefix:""}});var ar=_(os=>{"use strict";Object.defineProperty(os,"__esModule",{value:!0});os.metricsProcessor=void 0;var ym=Fr(),kT=$r(),FT=Ot(),HT=es(),qT=mm(),$T=gt(),jT=o(async(t,e,r,n)=>{let i=new Date,s=Date.now(),a=await n(t),c=t.headers.get(ym.RAY_ID_HEADER)??void 0,u=t.headers.get(ym.TRUE_CLIENT_IP)??void 0,l=e.incomingRequestProperties,d;e.route instanceof $T.SystemRouteConfiguration&&(d=e.route.systemRouteName);let p=kT.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 qT.EllieMetricsTransport(e)),FT.plugins.forEach(y=>{if(y instanceof HT.MetricsPlugin){let b=y.getTransport();h.push(b)}}),h.forEach(y=>{y.pushMetrics(f,e)}),a},"metricsProcessor");os.metricsProcessor=jT});var Sl=_(ss=>{"use strict";Object.defineProperty(ss,"__esModule",{value:!0});ss.SystemRouteName=void 0;var gm;(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"})(gm||(ss.SystemRouteName=gm={}))});var _m=_(bm=>{"use strict";Object.defineProperty(bm,"__esModule",{value:!0})});var Vr=_(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]}),Em=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});Em(Sl(),cr);Em(_m(),cr)});var wm=_(as=>{"use strict";Object.defineProperty(as,"__esModule",{value:!0});as.registerBuildRoute=void 0;var BT=Kt(),GT=Gt(),KT=ar(),JT=Vr(),zT=gt(),WT=Je(),QT=ie(),YT=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 BT.HttpProblems.notFound(s,a);let l=QT.Environment.instance.build,d={buildId:l.BUILD_ID,zuploVersion:l.ZUPLO_VERSION,compatibilityDate:l.COMPATIBILITY_DATE,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"&&WT.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 GT.Pipeline({processors:[KT.metricsProcessor],handler:r,gateway:e}),i=new zT.SystemRouteConfiguration({label:"SYSTEM_BUILD_ROUTE",methods:["GET"],path:"/__zuplo/build",systemRouteName:JT.SystemRouteName.Build});t.addRoute(i,n.execute)},"registerBuildRoute");as.registerBuildRoute=YT});var Il=_(mn=>{"use strict";Object.defineProperty(mn,"__esModule",{value:!0});mn.HTTP_STATUS_TITLES=mn.HttpStatusCode=void 0;var vm;(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"})(vm||(mn.HttpStatusCode=vm={}));mn.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 Al=_(Pl=>{"use strict";Object.defineProperty(Pl,"__esModule",{value:!0});var ZT={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"};Pl.default=ZT});var de=_(yn=>{"use strict";var XT=yn&&yn.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(yn,"__esModule",{value:!0});yn.HttpProblems=void 0;var eS=Fr(),H=Il(),tS=XT(Al()),rS=ie(),Rl=Go();function nS(t){return`${new URL(t.url).pathname}`}o(nS,"instance");function iS(t,e){let r={timestamp:new Date().toISOString(),requestId:e.requestId,buildId:rS.Environment.instance.build.BUILD_ID},n=t.headers.get(eS.RAY_ID_HEADER);return n&&(r.rayId=n),r}o(iS,"trace");var oS=o((t,e,r,n,i)=>({problem:{type:t.type,title:t.title,status:t.status,detail:t.detail,instance:nS(e),trace:iS(e,r),...n},additionalHeaders:i,statusText:tS.default[t.status]}),"merge"),Ol=class{static{o(this,"HttpProblemsBase")}static format=(e,r,n)=>"problem"in e?Rl.ProblemResponseFormatter.format(e,r,n):Rl.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}}},Nl=class extends Ol{static{o(this,"HttpProblems")}static#e(e,r,n,i,s){let a=oS(this.getProblemFromStatus(e),r,n,i,s);return Rl.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)};yn.HttpProblems=Nl});var at=_(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:sS}=Object.prototype,{propertyIsEnumerable:aS}=Object.prototype;function Tm(t){return sS.call(t)}o(Tm,"toString");K.toString=Tm;function cs(t){return typeof t=="string"}o(cs,"isString");K.isString=cs;function cS(t){return cs(t)&&t!==""}o(cS,"isNonEmptyString");K.isNonEmptyString=cS;function uS(t){return Array.isArray(t)&&t.every(e=>cs(e))}o(uS,"isStringArray");K.isStringArray=uS;function lS(t){return Tm(t)==="[object RegExp]"}o(lS,"isRegexp");K.isRegexp=lS;function dS(t){return[...Object.keys(t),...Object.getOwnPropertySymbols(t).filter(e=>aS.call(t,e))]}o(dS,"getOwnEnumerableKeys");K.getOwnEnumerableKeys=dS;function Cl(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)&&!(t instanceof RegExp)&&!(t instanceof Date)}o(Cl,"isObject");K.isObject=Cl;function pS(t){return Cl(t)&&Array.isArray(t)}o(pS,"isArray");K.isArray=pS;function fS(t){let e=Object.getPrototypeOf(Uint8Array);return typeof t=="object"&&t instanceof e}o(fS,"isTypedArray");K.isTypedArray=fS;function hS(t){return typeof t=="number"&&!isNaN(t)}o(hS,"isNumber");K.isNumber=hS;function mS(t){return!!t&&typeof t[Symbol.iterator]=="function"}o(mS,"isIterable");K.isIterable=mS;function yS(t){return t===!0||t===!1}o(yS,"isBoolean");K.isBoolean=yS;function Sm(t){return typeof t>"u"}o(Sm,"isUndefined");K.isUndefined=Sm;function gS(t){return!Ni(t)}o(gS,"isDefined");K.isDefined=gS;function Ni(t){return Sm(t)||t===null}o(Ni,"isUndefinedOrNull");K.isUndefinedOrNull=Ni;function bS(t,e){if(!t)throw new Error(e?`Unexpected type, expected '${e}'`:"Unexpected type")}o(bS,"assertType");K.assertType=bS;function _S(t){if(Ni(t))throw new Error("Assertion Failed: argument is undefined or null");return t}o(_S,"assertIsDefined");K.assertIsDefined=_S;function ES(...t){let e=[];for(let r=0;r<t.length;r++){let n=t[r];if(Ni(n))throw new Error(`Assertion Failed: argument at index ${r} is undefined or null`);e.push(n)}return e}o(ES,"assertAllDefined");K.assertAllDefined=ES;var wS=Object.prototype.hasOwnProperty;function vS(t){if(!Cl(t))return!1;for(let e in t)if(wS.call(t,e))return!1;return!0}o(vS,"isEmptyObject");K.isEmptyObject=vS;function xl(t){return typeof t=="function"}o(xl,"isFunction");K.isFunction=xl;function TS(...t){return t.length>0&&t.every(xl)}o(TS,"areFunctions");K.areFunctions=TS;function SS(t,e){let r=Math.min(t.length,e.length);for(let n=0;n<r;n++)Im(t[n],e[n])}o(SS,"validateConstraints");K.validateConstraints=SS;function Im(t,e){if(cs(e)){if(typeof t!==e)throw new Error(`argument does not match constraint: typeof ${e}`)}else if(xl(e)){try{if(t instanceof e)return}catch{}if(!Ni(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(Im,"validateConstraint");K.validateConstraint=Im;function IS(t){return t===null?void 0:t}o(IS,"withNullAsUndefined");K.withNullAsUndefined=IS;function PS(t){return typeof t>"u"?null:t}o(PS,"withUndefinedAsNull");K.withUndefinedAsNull=PS;function AS(t){return!!t&&typeof t=="object"&&"name"in t&&"message"in t&&"stack"in t}o(AS,"isErrorLike");K.isErrorLike=AS});var Jt=_(Nt=>{"use strict";Object.defineProperty(Nt,"__esModule",{value:!0});Nt.parseValueToBoolean=Nt.parseValueToStringArray=Nt.getValueFromRequestUser=Nt.statusCodesStringToNumberArray=void 0;var gn=k(),Ll=at(),Pm=new Map;function RS(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(RS,"statusCodesStringToNumberArray");Nt.statusCodesStringToNumberArray=RS;function OS(t,e,r){if(!e.startsWith("."))throw new gn.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 gn.RuntimeError(`Error applying ${r} '${e}', reading '${s}'`);i=i[s]}),`${i}`}o(OS,"getValueFromRequestUser");Nt.getValueFromRequestUser=OS;function NS(t){if(Array.isArray(t)){if(t.includes(r=>typeof r!="string"))throw new gn.ConfigurationError("Received an array that contains non-string values.");return t}if((0,Ll.isString)(t))return t.includes(",")?t.split(",").map(r=>r.trim()).filter(r=>r!==","&&r!==""):[t];throw new gn.ConfigurationError(`Expected type of string, received type '${typeof t}'`)}o(NS,"parseValueToStringArray");Nt.parseValueToStringArray=NS;function CS(t){if((0,Ll.isBoolean)(t))return t;if((0,Ll.isString)(t)){if(t.toLowerCase()==="true")return!0;if(t.toLowerCase()==="false")return!1;throw new gn.ConfigurationError(`Attempted to parse string to boolean, but received ${t} which cannot be parsed.`)}throw new gn.ConfigurationError(`Expected type of boolean, received type '${typeof t}'`)}o(CS,"parseValueToBoolean");Nt.parseValueToBoolean=CS});var ls=_(ur=>{"use strict";Object.defineProperty(ur,"__esModule",{value:!0});ur.generateCorsHeaders=ur.findMatchingOrigin=ur.parseCorsPolicies=void 0;var Br=k(),Am=Jt(),us=at();function xS(t){if(t==null)return[];if(!Array.isArray(t))throw new Br.ConfigurationError(`Invalid corsPolicy configuration. Expected an array of objects, received '${typeof t}'`);return t.map(r=>{if(!(0,us.isObject)(r))throw new Br.ConfigurationError(`Invalid custom cors policy is set. Expected an object, received '${typeof r}'`);if(!(0,us.isNonEmptyString)(r.name))throw new Br.ConfigurationError("Value of 'name' on custom cors policies must be a non-empty string.");if(r.maxAge!==void 0&&!(0,us.isNumber)(r.maxAge))throw new Br.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,us.isBoolean)(r.allowCredentials))throw new Br.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=Dl(r,"allowedHeaders"),i=Dl(r,"allowedMethods"),s=Dl(r,"exposeHeaders"),a;try{a=(0,Am.parseValueToStringArray)(r.allowedOrigins)}catch(u){throw new Br.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(xS,"parseCorsPolicies");ur.parseCorsPolicies=xS;function Dl(t,e){let r;if(t[e]!==void 0)try{r=(0,Am.parseValueToStringArray)(t[e])}catch(n){throw new Br.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(Dl,"parseOptionalProperty");var LS=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=LS;var DS=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=DS});var Om=_(ds=>{"use strict";Object.defineProperty(ds,"__esModule",{value:!0});ds.registerCorsRoute=void 0;var MS=k(),US=Gt(),Ml=de(),kS=ar(),FS=Vr(),HS=gt(),Rm=ls(),qS=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 Ml.HttpProblems.badRequest(a,c,{detail:"Expect headers origin and access-control-request-method"});let f=t.lookup(l,u);if(!f)return Ml.HttpProblems.notFound(a,c);let h=f.routeConfiguration,y=$S(l,d,p,h,r);return y.isValid?new Response(void 0,{status:200,statusText:"OK",headers:y.headers}):(y.error&&c.log.warn(y.error),Ml.HttpProblems.notFound(a,c))},"optionsHandler"),i=new US.Pipeline({processors:[kS.metricsProcessor],handler:n,gateway:e}),s=new HS.SystemRouteConfiguration({label:"SYSTEM_CORS_ROUTE",methods:["OPTIONS"],path:"/(.*)",systemRouteName:FS.SystemRouteName.CorsPreflight});t.addRoute(s,i.execute)},"registerCorsRoute");ds.registerCorsRoute=qS;var $S=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 MS.ConfigurationError(`Invalid Configuration - corsPolicy '${n.corsPolicy}' not found in *.oas.json 'corsPolicies' section.`);let c=(0,Rm.findMatchingOrigin)(a.allowedOrigins,r);return c?{isValid:!0,headers:(0,Rm.generateCorsHeaders)(a,c)}:{...s,error:`The CORS policy '${a.name}' does not allow the origin '${r}'`}},"validateAndBuildResponseHeaders")});var Nm=_(ps=>{"use strict";Object.defineProperty(ps,"__esModule",{value:!0});ps.registerNoRoutes=void 0;var jS=Gt(),VS=ar(),BS=Vr(),GS=gt(),KS=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 jS.Pipeline({processors:[VS.metricsProcessor],handler:r,gateway:e}),i=new GS.SystemRouteConfiguration({label:"SYSTEM_NO_ROUTES",methods:["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"],path:"/(.*)",systemRouteName:BS.SystemRouteName.EmptyGatewayCatchall});t.addRoute(i,n.execute)},"registerNoRoutes");ps.registerNoRoutes=KS});var Cm=_(Gr=>{"use strict";Object.defineProperty(Gr,"__esModule",{value:!0});Gr.registerNotMatchedHandler=Gr.notFoundRouteConfiguration=void 0;var JS=$r(),zS=Ot(),WS=Gt(),QS=de(),YS=ar(),ZS=Vr(),XS=gt();Gr.notFoundRouteConfiguration=new XS.SystemRouteConfiguration({label:"SYSTEM_NOT_FOUND_ROUTE",methods:["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"],path:"/(.*)",systemRouteName:ZS.SystemRouteName.UnmatchedPath});var eI=o((t,e)=>{let r=o(async(i,s)=>{let a=zS.runtimeExtensions.value?.notFoundHandler;if(a){let c=JS.ZuploContextExtensions.getContextExtensions(s);return a(i,s,{routesMatchedByPathOnly:c.pathOnlyMatches??[]})}return QS.HttpProblems.notFound(i,s)},"notFoundHandler"),n=new WS.Pipeline({processors:[YS.metricsProcessor],handler:r,gateway:e});t.addRoute(Gr.notFoundRouteConfiguration,n.execute)},"registerNotMatchedHandler");Gr.registerNotMatchedHandler=eI});var Ul=_(fs=>{"use strict";Object.defineProperty(fs,"__esModule",{value:!0});fs.corsProcessor=void 0;var Dm=k(),xm=ls(),tI=["access-control-allow-origin","access-control-allow-headers","access-control-expose-headers","access-control-allow-credentials","access-control-max-age"],Lm=o(t=>{tI.forEach(e=>t.delete(e))},"stripCorsHeaders"),rI=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 Lm(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 Dm.SystemError(`The CorsProcessor is in the wrong place in the pipeline. It should only receive HttpResponse type but got '${typeof s}'`);let a=nI(i,r.routeData.corsPolicies),c=iI(t,a),u=new Headers(s.headers);return Lm(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");fs.corsProcessor=rI;var nI=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 Dm.ConfigurationError(`Invalid Configuration - no corsPolicy '${t.corsPolicy}' found in *.oas.json`);return r},"getCorsPolicy"),iI=o((t,e)=>{let r=(0,xm.findMatchingOrigin)(e.allowedOrigins,t.headers.get("origin"));return r?(0,xm.generateCorsHeaders)(e,r):{}},"getCorsHeaders")});var Mm=_(hs=>{"use strict";Object.defineProperty(hs,"__esModule",{value:!0});hs.registerPingRoute=void 0;var oI=Gt(),sI=Ul(),aI=Vr(),cI=gt(),uI=o((t,e)=>{let r=o(async()=>new Response(null,{status:200}),"pingRouteHandler"),n=new oI.Pipeline({processors:[sI.corsProcessor],handler:r,gateway:e}),i=new cI.SystemRouteConfiguration({corsPolicy:"anything-goes",label:"SYSTEM_PING_ROUTE",methods:["GET"],path:"/__zuplo/ping",systemRouteName:aI.SystemRouteName.Ping});t.addRoute(i,n.execute)},"registerPingRoute");hs.registerPingRoute=uI});var _n=_(bn=>{"use strict";Object.defineProperty(bn,"__esModule",{value:!0});bn.OutboundPolicy=bn.InboundPolicy=void 0;var lI=k(),dI=at(),ms=class{static{o(this,"PolicyBase")}options;policyName;constructor(e,r){if(!(0,dI.isString)(r))throw new lI.RuntimeError(`The name of a policy must be a string. Received '${r}' of type '${typeof r}'`);this.options=e,this.policyName=r}},kl=class extends ms{static{o(this,"InboundPolicy")}};bn.InboundPolicy=kl;var Fl=class extends ms{static{o(this,"OutboundPolicy")}};bn.OutboundPolicy=Fl});var En=_(bt=>{"use strict";Object.defineProperty(bt,"__esModule",{value:!0});bt.createInternalPolicyProcessor=bt.policyProcessor=bt.toStackedInboundHandler=bt.getInboundPolicyInstances=void 0;var pI=$r(),$e=k(),ys=_n(),Um=Ke(),fI=ie(),$l=class extends ys.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)}},jl=class extends ys.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)}},Hl=new Map;function km(t,e){let r,n;return Array.isArray(t)?r=t:(r=t.policies?.inbound??[],n=t.path),r.filter(s=>!Hl.has(s)).forEach(s=>{let a=e?.find(l=>l.name===s);if(!a)throw new $e.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 $e.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 $e.ConfigurationError(`Invalid state - invalid policy '${s}' on route '${n}' (typeof module '${typeof c}')`);let u;if(typeof c!="function")throw new $e.ConfigurationError(`Invalid state - invalid policy '${s}' on route '${n}' (typeof module '${typeof c}')`);if(c.prototype instanceof ys.InboundPolicy)u=new c(a.handler.options,a.name);else if(typeof c=="function")u=new $l(c,a.handler.options,a.name);else throw new $e.ConfigurationError(`Invalid state - invalid policy '${s}' on route '${n}' (typeof policy '${typeof c}')`);if(typeof u.handler!="function")throw new $e.ConfigurationError(`Invalid state - invalid handler on policy '${s}' on route '${n}' (typeof handler '${typeof u.handler}')`);Hl.set(a.name,u)}),r.map(s=>{let a=Hl.get(s);if(a===void 0)throw new $e.RuntimeError("Internal error. Policy not found in cache.");return a})}o(km,"getInboundPolicyInstances");bt.getInboundPolicyInstances=km;var ql=new Map;function hI(t,e){let r=t.policies?.outbound??[];return r.filter(i=>!ql.has(i)).forEach(i=>{let s=e?.find(u=>u.name===i);if(!s)throw new $e.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 $e.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 $e.ConfigurationError(`Invalid state - invalid policy '${i}' on route '${t.path}' (typeof module '${typeof a}')`);if(a.prototype instanceof ys.OutboundPolicy)c=new a(s.handler.options??{},s.name);else if(typeof a=="function")c=new jl(a,s.handler.options??{},s.name);else throw new $e.ConfigurationError(`Invalid state - invalid policy '${i}' on route '${t.path}' (typeof policy '${typeof a}')`);if(typeof c.handler!="function")throw new $e.ConfigurationError(`Invalid state - invalid handler on policy '${i}' on route '${t.path}'`);ql.set(s.name,c)}),r.map(i=>{let s=ql.get(i);if(s===void 0)throw new $e.RuntimeError("Internal error. Policy not found in cache.");return s})}o(hI,"getOutboundPolicyInstances");var mI=o(t=>async(e,r)=>{let n=pI.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 Um.ZuploRequest)s=c;else if(c instanceof Request)s=new Um.ZuploRequest(c);else{if(c instanceof Response)return c;throw new $e.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");bt.toStackedInboundHandler=mI;var yI=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 $e.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"),gI=o(async(t,e,r,n)=>{let i=km(e.route,r.routeData.policies),s=hI(e.route,r.routeData.policies);return Fm({request:t,context:e,inboundPolicies:i,outboundPolicies:s,gateway:r,next:n})},"policyProcessor");bt.policyProcessor=gI;function bI({inboundPolicies:t=[],outboundPolicies:e=[]}){return o(async(n,i,s,a)=>Fm({request:n,context:i,inboundPolicies:t,outboundPolicies:e,gateway:s,next:a}),"policyProcessor")}o(bI,"createInternalPolicyProcessor");bt.createInternalPolicyProcessor=bI;async function Fm({request:t,context:e,inboundPolicies:r,outboundPolicies:n,gateway:i,next:s}){let a=(0,bt.toStackedInboundHandler)(r);try{let c=await a(t,e);if(c instanceof Response)return c;let u=await s(c),l=yI(n),d;return fI.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(Fm,"executePolicyProcessor")});var Hm=_(wn=>{"use strict";Object.defineProperty(wn,"__esModule",{value:!0});wn.serialize=wn.parse=void 0;var _I=Object.prototype.toString,gs=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;function EI(t,e){if(typeof t!="string")throw new TypeError("argument str must be a string");let r={},i=(e||{}).decode||vI,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(EI,"parse");wn.parse=EI;function wI(t,e,r){let n=r||{},i=n.encode||TI;if(typeof i!="function")throw new TypeError("option encode is invalid");if(!gs.test(t))throw new TypeError("argument name is invalid");let s=i(e);if(s&&!gs.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(!gs.test(n.domain))throw new TypeError("option domain is invalid");a+="; Domain="+n.domain}if(n.path){if(!gs.test(n.path))throw new TypeError("option path is invalid");a+="; Path="+n.path}if(n.expires){let c=n.expires;if(!SI(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(wI,"serialize");wn.serialize=wI;function vI(t){return t.indexOf("%")!==-1?decodeURIComponent(t):t}o(vI,"decode");function TI(t){return encodeURIComponent(t)}o(TI,"encode");function SI(t){return _I.call(t)==="[object Date]"||t instanceof Date}o(SI,"isDate");function II(t,e){try{return e(t)}catch{return t}}o(II,"tryDecode")});var qm=_(bs=>{"use strict";Object.defineProperty(bs,"__esModule",{value:!0});bs.devPortalBaseURL=void 0;var PI=Hm();function AI(t,e){try{let r=/v\d+(-\d+)?/g,i=(0,PI.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(AI,"devPortalBaseURL");bs.devPortalBaseURL=AI});var Gm=_(vn=>{"use strict";Object.defineProperty(vn,"__esModule",{value:!0});vn.registerDevPortalLegacyRedirectRoute=vn.registerDevPortalV3Route=void 0;var Vl=Kt(),jm=Gt(),Vm=ar(),RI=En(),Bm=gt(),OI=qm(),lr=ie(),$m="/__zuplo/dev-portal",NI="dev-portal-id",CI="dev-portal-host",xI="zp-account",LI="zp-project",DI="dev-portal-build",MI=`
|
|
35
|
+
`)+" "+r[1]:r[0]+e+" "+t.join(", ")+" "+r[1]}o(fT,"reduceToSingleString")});var nm=_($o=>{"use strict";Object.defineProperty($o,"__esModule",{value:!0});$o.format=void 0;var hT=Qh(),mT=rm(),yT=o((t,...e)=>(0,hT.format)(mT.inspect,t,e),"format");$o.format=yT});var or=_(ir=>{"use strict";Object.defineProperty(ir,"__esModule",{value:!0});ir.debug=ir.withoutEnv=ir.Debugger=void 0;var gT=Wh(),bT=nm(),jo=class{static{o(this,"Debugger")}manager;ns;color;last;enabled;constructor(e,r){this.manager=e,this.ns=r,this.color=(0,gT.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,bT.format)(r,...e);let s=`${this.color(this.ns)} ${r} ${this.color(`+${i}ms`)}`;console.log(s),this.last=Date.now()}};ir.Debugger=jo;var Vo=class{static{o(this,"DebugManager")}debuggers;enabled;constructor(e){this.debuggers=new Map,this.enabled=e??[]}};function im(t){return!t||t.length===0?[]:(t=t.replace(/\s/g,"").replace(/\*/g,".+"),t.split(",").map(e=>new RegExp(`^${e}$`)))}o(im,"extract");var Oi;function _T(t){t||(t=[]),typeof t=="string"&&(t=im(t)),Oi=new Vo(t)}o(_T,"withoutEnv");ir.withoutEnv=_T;function ET(t){let e=globalThis.DEBUG;Oi||(Oi=new Vo(im(e)));let r=new jo(Oi,t);return Oi.debuggers.set(t,r),Object.assign(r.log.bind(r),{self:r})}o(ET,"debug");ir.debug=ET});var Go=_(hn=>{"use strict";Object.defineProperty(hn,"__esModule",{value:!0});hn.ProblemResponseFormatter=hn.InternalProblemResponseFormatter=void 0;var wT=k(),Bo=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 wT.RuntimeError("Error in custom 'problemResponseFormat'",{cause:s})}})}};hn.InternalProblemResponseFormatter=Bo;var pl=class{static{o(this,"ProblemResponseFormatter")}static async format(e,r,n){return await Bo.problemResponseFormat(e,r,n)}};hn.ProblemResponseFormatter=pl});var sm=_(Ko=>{"use strict";Object.defineProperty(Ko,"__esModule",{value:!0});Ko.deepFreeze=void 0;function om(t){for(let e in t){let r=t[e];r&&typeof r=="object"&&om(r)}return Object.freeze(t)}o(om,"deepFreeze");Ko.deepFreeze=om});var Ke=_(Jo=>{"use strict";Object.defineProperty(Jo,"__esModule",{value:!0});Jo.ZuploRequest=void 0;var am=sm(),fl=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,am.deepFreeze)(this.#e)}get params(){return(0,am.deepFreeze)(this.#t)}user};Jo.ZuploRequest=fl});var Ot=_(Ie=>{"use strict";Object.defineProperty(Ie,"__esModule",{value:!0});Ie.initializeRuntime=Ie.invokeOnResponseSendingFinalExtensions=Ie.invokeOnResponseSendingExtensions=Ie.invokeOnRequestExtensions=Ie.plugins=Ie.runtimeExtensions=Ie.SystemRuntimePlugin=Ie.RuntimePlugin=void 0;var cm=k(),vT=Go(),TT=Ke(),Wo=class{static{o(this,"RuntimePlugin")}};Ie.RuntimePlugin=Wo;var Qo=class extends Wo{static{o(this,"SystemRuntimePlugin")}async initialize(e){return Promise.resolve()}registerRoutes(e,r){}};Ie.SystemRuntimePlugin=Qo;Ie.runtimeExtensions={};var hl=[];Ie.plugins=hl;var um=[],lm=[],dm=[],zo={addPlugin(t){hl.push(t)},addRequestHook(t){um.push(t)},addResponseSendingHook(t){lm.push(t)},addResponseSendingFinalHook(t){dm.push(t)}},ST=o(async(t,e)=>{let r=t;for(let n of um){let i=await n(r,e);if(i instanceof TT.ZuploRequest)r=i;else{if(i instanceof Response)return i;throw new cm.ConfigurationError(`Invalid state - the OnRequest hook must return a ZuploRequest or Response. Received ${typeof r}.`)}}return r},"invokeOnRequestExtensions");Ie.invokeOnRequestExtensions=ST;var IT=o(async(t,e,r)=>{let n=t;for(let i of lm){let s=await i(t,e,r);if(s instanceof Response)n=s;else throw new cm.ConfigurationError(`Invalid state - the OnResponseSending hook must return a Response. Received ${typeof n}.`)}return n},"invokeOnResponseSendingExtensions");Ie.invokeOnResponseSendingExtensions=IT;var PT=o(async(t,e,r)=>{for(let n of dm)await n(t,e,r)},"invokeOnResponseSendingFinalExtensions");Ie.invokeOnResponseSendingFinalExtensions=PT;async function AT(t=()=>Promise.resolve()){await t(zo),Ie.runtimeExtensions.value=zo;for(let e of hl)e instanceof Qo&&await e.initialize(zo);vT.InternalProblemResponseFormatter.setProblemResponseFormat(zo.problemResponseFormat)}o(AT,"initializeRuntime");Ie.initializeRuntime=AT});var ml=_(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 RT(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(RT,"serialize");sr.serialize=RT});var yl=_(Yo=>{"use strict";Object.defineProperty(Yo,"__esModule",{value:!0});Yo.isSystemRoute=void 0;var pm=qr();function OT(t){return pm.Gateway.instance.runtimeSettings.developerPortal.enabled&&t.pathname.startsWith(pm.Gateway.instance.runtimeSettings.developerPortal.sitePathname)||t.pathname.startsWith("/__zuplo/")||t.pathname.startsWith("/__/zuplo/")}o(OT,"isSystemRoute");Yo.isSystemRoute=OT});var Gt=_(Zo=>{"use strict";Object.defineProperty(Zo,"__esModule",{value:!0});Zo.Pipeline=void 0;var gl=$r(),fm=Ot(),NT=ml(),CT=ie(),xT=yl(),bl=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 I=a.pop();return I?I(i,s,r,c):await this.#e(async g=>{let v=await n(g,s);return LT(v)},r)(b,s)},"nextPipe"),l=await c(i),d=new URL(i.url);if((0,xT.isSystemRoute)(d)&&CT.Environment.instance.build.COMPATIBILITY_FLAGS.doNotRunHooksOnSystemRoutes)return l;let p=new gl.ResponseSendingEvent(i,l);s.dispatchEvent(p);let f=gl.ZuploContextExtensions.getContextExtensions(s),h=f.latestRequest,y;try{y=await p.mutableResponse}catch(b){return s.log.error(b),r.errorHandler(i,s,b)}try{y=await f.onResponseSending(y,h,s)}catch(b){return s.log.error(`Error invoking 'context.onResponseSending' hook: '${b.message}'`,b),r.errorHandler(i,s,b)}try{y=await(0,fm.invokeOnResponseSendingExtensions)(y,h,s)}catch(b){return s.log.error(`Error invoking 'context.onResponseSending' hook: '${b.message}'`,b),r.errorHandler(i,s,b)}s.dispatchEvent(new gl.ResponseSentEvent(i,y));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,fm.invokeOnResponseSendingFinalExtensions)(l,h,s)}catch(b){throw s.log.error(`Error invoking 'runtime.onResponseSending' hook: '${b.message}'`,b),b}return y}};Zo.Pipeline=bl;function LT(t){return t instanceof Response?t:typeof t>"u"?new Response:new Response((0,NT.serialize)(t),{headers:{"content-type":"application/json"}})}o(LT,"resultToResponse")});var es=_(Xo=>{"use strict";Object.defineProperty(Xo,"__esModule",{value:!0});Xo.MetricsPlugin=void 0;var DT=Ot(),_l=class extends DT.RuntimePlugin{static{o(this,"MetricsPlugin")}};Xo.MetricsPlugin=_l});var Je=_(ts=>{"use strict";Object.defineProperty(ts,"__esModule",{value:!0});ts.SystemLogMap=void 0;var MT=k(),El=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 MT.SystemError(n)}return r}static addLogger(e,r){t.#e.set(e,r)}};ts.SystemLogMap=El});var Re=_(rs=>{"use strict";Object.defineProperty(rs,"__esModule",{value:!0});rs.BatchDispatch=void 0;var wl=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}};rs.BatchDispatch=wl});var mm=_(is=>{"use strict";Object.defineProperty(is,"__esModule",{value:!0});is.EllieMetricsTransport=void 0;var hm=Je(),UT=Re(),ns=ie(),vl=class{static{o(this,"EllieMetricsTransport")}#e;#t;#r;constructor(e){this.#r=ns.Environment.instance.loggingId,this.#e=e,this.#t=new UT.BatchDispatch("ellie-metrics-transport",10,this.dispatchFunction,hm.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}=ns.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":ns.Environment.instance.deploymentName??"unknown","user-agent":ns.Environment.instance.systemUserAgent}});if(!c.ok){let u=await c.text();hm.SystemLogMap.getLogger(this.#e).error(`Metrics POST responded ${c.status}: ${c.statusText}`,u)}}}};is.EllieMetricsTransport=vl});var gt=_(jr=>{"use strict";Object.defineProperty(jr,"__esModule",{value:!0});jr.systemNoVersion=jr.SystemRouteConfiguration=void 0;var Tl=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=jr.systemNoVersion.name,this.handler={export:"SYSTEM_IGNORED",module:"SYSTEM_IGNORED"},this.systemRouteName=i}label;path;methods;handler;corsPolicy;version;policies;systemRouteName;raw(){return{}}};jr.SystemRouteConfiguration=Tl;jr.systemNoVersion={name:"__system-no-version",pathPrefix:""}});var ar=_(os=>{"use strict";Object.defineProperty(os,"__esModule",{value:!0});os.metricsProcessor=void 0;var ym=Fr(),kT=$r(),FT=Ot(),HT=es(),qT=mm(),$T=gt(),jT=o(async(t,e,r,n)=>{let i=new Date,s=Date.now(),a=await n(t),c=t.headers.get(ym.RAY_ID_HEADER)??void 0,u=t.headers.get(ym.TRUE_CLIENT_IP)??void 0,l=e.incomingRequestProperties,d;e.route instanceof $T.SystemRouteConfiguration&&(d=e.route.systemRouteName);let p=kT.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 qT.EllieMetricsTransport(e)),FT.plugins.forEach(y=>{if(y instanceof HT.MetricsPlugin){let b=y.getTransport();h.push(b)}}),h.forEach(y=>{y.pushMetrics(f,e)}),a},"metricsProcessor");os.metricsProcessor=jT});var Sl=_(ss=>{"use strict";Object.defineProperty(ss,"__esModule",{value:!0});ss.SystemRouteName=void 0;var gm;(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"})(gm||(ss.SystemRouteName=gm={}))});var _m=_(bm=>{"use strict";Object.defineProperty(bm,"__esModule",{value:!0})});var Vr=_(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]}),Em=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});Em(Sl(),cr);Em(_m(),cr)});var wm=_(as=>{"use strict";Object.defineProperty(as,"__esModule",{value:!0});as.registerBuildRoute=void 0;var BT=Kt(),GT=Gt(),KT=ar(),JT=Vr(),zT=gt(),WT=Je(),QT=ie(),YT=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 BT.HttpProblems.notFound(s,a);let l=QT.Environment.instance.build,d={buildId:l.BUILD_ID,zuploVersion:l.ZUPLO_VERSION,compatibilityDate:l.COMPATIBILITY_DATE,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"&&WT.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 GT.Pipeline({processors:[KT.metricsProcessor],handler:r,gateway:e}),i=new zT.SystemRouteConfiguration({label:"SYSTEM_BUILD_ROUTE",methods:["GET"],path:"/__zuplo/build",systemRouteName:JT.SystemRouteName.Build});t.addRoute(i,n.execute)},"registerBuildRoute");as.registerBuildRoute=YT});var Il=_(mn=>{"use strict";Object.defineProperty(mn,"__esModule",{value:!0});mn.HTTP_STATUS_TITLES=mn.HttpStatusCode=void 0;var vm;(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"})(vm||(mn.HttpStatusCode=vm={}));mn.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 Al=_(Pl=>{"use strict";Object.defineProperty(Pl,"__esModule",{value:!0});var ZT={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"};Pl.default=ZT});var de=_(yn=>{"use strict";var XT=yn&&yn.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(yn,"__esModule",{value:!0});yn.HttpProblems=void 0;var eS=Fr(),H=Il(),tS=XT(Al()),rS=ie(),Rl=Go();function nS(t){return`${new URL(t.url).pathname}`}o(nS,"instance");function iS(t,e){let r={timestamp:new Date().toISOString(),requestId:e.requestId,buildId:rS.Environment.instance.build.BUILD_ID},n=t.headers.get(eS.RAY_ID_HEADER);return n&&(r.rayId=n),r}o(iS,"trace");var oS=o((t,e,r,n,i)=>({problem:{type:t.type,title:t.title,status:t.status,detail:t.detail,instance:nS(e),trace:iS(e,r),...n},additionalHeaders:i,statusText:tS.default[t.status]}),"merge"),Ol=class{static{o(this,"HttpProblemsBase")}static format=(e,r,n)=>"problem"in e?Rl.ProblemResponseFormatter.format(e,r,n):Rl.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}}},Nl=class extends Ol{static{o(this,"HttpProblems")}static#e(e,r,n,i,s){let a=oS(this.getProblemFromStatus(e),r,n,i,s);return Rl.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)};yn.HttpProblems=Nl});var at=_(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:sS}=Object.prototype,{propertyIsEnumerable:aS}=Object.prototype;function Tm(t){return sS.call(t)}o(Tm,"toString");K.toString=Tm;function cs(t){return typeof t=="string"}o(cs,"isString");K.isString=cs;function cS(t){return cs(t)&&t!==""}o(cS,"isNonEmptyString");K.isNonEmptyString=cS;function uS(t){return Array.isArray(t)&&t.every(e=>cs(e))}o(uS,"isStringArray");K.isStringArray=uS;function lS(t){return Tm(t)==="[object RegExp]"}o(lS,"isRegexp");K.isRegexp=lS;function dS(t){return[...Object.keys(t),...Object.getOwnPropertySymbols(t).filter(e=>aS.call(t,e))]}o(dS,"getOwnEnumerableKeys");K.getOwnEnumerableKeys=dS;function Cl(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)&&!(t instanceof RegExp)&&!(t instanceof Date)}o(Cl,"isObject");K.isObject=Cl;function pS(t){return Cl(t)&&Array.isArray(t)}o(pS,"isArray");K.isArray=pS;function fS(t){let e=Object.getPrototypeOf(Uint8Array);return typeof t=="object"&&t instanceof e}o(fS,"isTypedArray");K.isTypedArray=fS;function hS(t){return typeof t=="number"&&!isNaN(t)}o(hS,"isNumber");K.isNumber=hS;function mS(t){return!!t&&typeof t[Symbol.iterator]=="function"}o(mS,"isIterable");K.isIterable=mS;function yS(t){return t===!0||t===!1}o(yS,"isBoolean");K.isBoolean=yS;function Sm(t){return typeof t>"u"}o(Sm,"isUndefined");K.isUndefined=Sm;function gS(t){return!Ni(t)}o(gS,"isDefined");K.isDefined=gS;function Ni(t){return Sm(t)||t===null}o(Ni,"isUndefinedOrNull");K.isUndefinedOrNull=Ni;function bS(t,e){if(!t)throw new Error(e?`Unexpected type, expected '${e}'`:"Unexpected type")}o(bS,"assertType");K.assertType=bS;function _S(t){if(Ni(t))throw new Error("Assertion Failed: argument is undefined or null");return t}o(_S,"assertIsDefined");K.assertIsDefined=_S;function ES(...t){let e=[];for(let r=0;r<t.length;r++){let n=t[r];if(Ni(n))throw new Error(`Assertion Failed: argument at index ${r} is undefined or null`);e.push(n)}return e}o(ES,"assertAllDefined");K.assertAllDefined=ES;var wS=Object.prototype.hasOwnProperty;function vS(t){if(!Cl(t))return!1;for(let e in t)if(wS.call(t,e))return!1;return!0}o(vS,"isEmptyObject");K.isEmptyObject=vS;function xl(t){return typeof t=="function"}o(xl,"isFunction");K.isFunction=xl;function TS(...t){return t.length>0&&t.every(xl)}o(TS,"areFunctions");K.areFunctions=TS;function SS(t,e){let r=Math.min(t.length,e.length);for(let n=0;n<r;n++)Im(t[n],e[n])}o(SS,"validateConstraints");K.validateConstraints=SS;function Im(t,e){if(cs(e)){if(typeof t!==e)throw new Error(`argument does not match constraint: typeof ${e}`)}else if(xl(e)){try{if(t instanceof e)return}catch{}if(!Ni(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(Im,"validateConstraint");K.validateConstraint=Im;function IS(t){return t===null?void 0:t}o(IS,"withNullAsUndefined");K.withNullAsUndefined=IS;function PS(t){return typeof t>"u"?null:t}o(PS,"withUndefinedAsNull");K.withUndefinedAsNull=PS;function AS(t){return!!t&&typeof t=="object"&&"name"in t&&"message"in t&&"stack"in t}o(AS,"isErrorLike");K.isErrorLike=AS});var Jt=_(Nt=>{"use strict";Object.defineProperty(Nt,"__esModule",{value:!0});Nt.parseValueToBoolean=Nt.parseValueToStringArray=Nt.getValueFromRequestUser=Nt.statusCodesStringToNumberArray=void 0;var gn=k(),Ll=at(),Pm=new Map;function RS(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(RS,"statusCodesStringToNumberArray");Nt.statusCodesStringToNumberArray=RS;function OS(t,e,r){if(!e.startsWith("."))throw new gn.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 gn.RuntimeError(`Error applying ${r} '${e}', reading '${s}'`);i=i[s]}),`${i}`}o(OS,"getValueFromRequestUser");Nt.getValueFromRequestUser=OS;function NS(t){if(Array.isArray(t)){if(t.includes(r=>typeof r!="string"))throw new gn.ConfigurationError("Received an array that contains non-string values.");return t}if((0,Ll.isString)(t))return t.includes(",")?t.split(",").map(r=>r.trim()).filter(r=>r!==","&&r!==""):[t];throw new gn.ConfigurationError(`Expected type of string, received type '${typeof t}'`)}o(NS,"parseValueToStringArray");Nt.parseValueToStringArray=NS;function CS(t){if((0,Ll.isBoolean)(t))return t;if((0,Ll.isString)(t)){if(t.toLowerCase()==="true")return!0;if(t.toLowerCase()==="false")return!1;throw new gn.ConfigurationError(`Attempted to parse string to boolean, but received ${t} which cannot be parsed.`)}throw new gn.ConfigurationError(`Expected type of boolean, received type '${typeof t}'`)}o(CS,"parseValueToBoolean");Nt.parseValueToBoolean=CS});var ls=_(ur=>{"use strict";Object.defineProperty(ur,"__esModule",{value:!0});ur.generateCorsHeaders=ur.findMatchingOrigin=ur.parseCorsPolicies=void 0;var Br=k(),Am=Jt(),us=at();function xS(t){if(t==null)return[];if(!Array.isArray(t))throw new Br.ConfigurationError(`Invalid corsPolicy configuration. Expected an array of objects, received '${typeof t}'`);return t.map(r=>{if(!(0,us.isObject)(r))throw new Br.ConfigurationError(`Invalid custom cors policy is set. Expected an object, received '${typeof r}'`);if(!(0,us.isNonEmptyString)(r.name))throw new Br.ConfigurationError("Value of 'name' on custom cors policies must be a non-empty string.");if(r.maxAge!==void 0&&!(0,us.isNumber)(r.maxAge))throw new Br.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,us.isBoolean)(r.allowCredentials))throw new Br.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=Dl(r,"allowedHeaders"),i=Dl(r,"allowedMethods"),s=Dl(r,"exposeHeaders"),a;try{a=(0,Am.parseValueToStringArray)(r.allowedOrigins)}catch(u){throw new Br.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(xS,"parseCorsPolicies");ur.parseCorsPolicies=xS;function Dl(t,e){let r;if(t[e]!==void 0)try{r=(0,Am.parseValueToStringArray)(t[e])}catch(n){throw new Br.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(Dl,"parseOptionalProperty");var LS=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=LS;var DS=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=DS});var Om=_(ds=>{"use strict";Object.defineProperty(ds,"__esModule",{value:!0});ds.registerCorsRoute=void 0;var MS=k(),US=Gt(),Ml=de(),kS=ar(),FS=Vr(),HS=gt(),Rm=ls(),qS=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 Ml.HttpProblems.badRequest(a,c,{detail:"Expect headers origin and access-control-request-method"});let f=t.lookup(l,u);if(!f)return Ml.HttpProblems.notFound(a,c);let h=f.routeConfiguration,y=$S(l,d,p,h,r);return y.isValid?new Response(void 0,{status:200,statusText:"OK",headers:y.headers}):(y.error&&c.log.warn(y.error),Ml.HttpProblems.notFound(a,c))},"optionsHandler"),i=new US.Pipeline({processors:[kS.metricsProcessor],handler:n,gateway:e}),s=new HS.SystemRouteConfiguration({label:"SYSTEM_CORS_ROUTE",methods:["OPTIONS"],path:"/(.*)",systemRouteName:FS.SystemRouteName.CorsPreflight});t.addRoute(s,i.execute)},"registerCorsRoute");ds.registerCorsRoute=qS;var $S=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 MS.ConfigurationError(`Invalid Configuration - corsPolicy '${n.corsPolicy}' not found in *.oas.json 'corsPolicies' section.`);let c=(0,Rm.findMatchingOrigin)(a.allowedOrigins,r);return c?{isValid:!0,headers:(0,Rm.generateCorsHeaders)(a,c)}:{...s,error:`The CORS policy '${a.name}' does not allow the origin '${r}'`}},"validateAndBuildResponseHeaders")});var Nm=_(ps=>{"use strict";Object.defineProperty(ps,"__esModule",{value:!0});ps.registerNoRoutes=void 0;var jS=Gt(),VS=ar(),BS=Vr(),GS=gt(),KS=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 jS.Pipeline({processors:[VS.metricsProcessor],handler:r,gateway:e}),i=new GS.SystemRouteConfiguration({label:"SYSTEM_NO_ROUTES",methods:["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"],path:"/(.*)",systemRouteName:BS.SystemRouteName.EmptyGatewayCatchall});t.addRoute(i,n.execute)},"registerNoRoutes");ps.registerNoRoutes=KS});var Cm=_(Gr=>{"use strict";Object.defineProperty(Gr,"__esModule",{value:!0});Gr.registerNotMatchedHandler=Gr.notFoundRouteConfiguration=void 0;var JS=$r(),zS=Ot(),WS=Gt(),QS=de(),YS=ar(),ZS=Vr(),XS=gt();Gr.notFoundRouteConfiguration=new XS.SystemRouteConfiguration({label:"SYSTEM_NOT_FOUND_ROUTE",methods:["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"],path:"/(.*)",systemRouteName:ZS.SystemRouteName.UnmatchedPath});var eI=o((t,e)=>{let r=o(async(i,s)=>{let a=zS.runtimeExtensions.value?.notFoundHandler;if(a){let c=JS.ZuploContextExtensions.getContextExtensions(s);return a(i,s,{routesMatchedByPathOnly:c.pathOnlyMatches??[]})}return QS.HttpProblems.notFound(i,s)},"notFoundHandler"),n=new WS.Pipeline({processors:[YS.metricsProcessor],handler:r,gateway:e});t.addRoute(Gr.notFoundRouteConfiguration,n.execute)},"registerNotMatchedHandler");Gr.registerNotMatchedHandler=eI});var Ul=_(fs=>{"use strict";Object.defineProperty(fs,"__esModule",{value:!0});fs.corsProcessor=void 0;var Dm=k(),xm=ls(),tI=["access-control-allow-origin","access-control-allow-headers","access-control-expose-headers","access-control-allow-credentials","access-control-max-age"],Lm=o(t=>{tI.forEach(e=>t.delete(e))},"stripCorsHeaders"),rI=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 Lm(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 Dm.SystemError(`The CorsProcessor is in the wrong place in the pipeline. It should only receive HttpResponse type but got '${typeof s}'`);let a=nI(i,r.routeData.corsPolicies),c=iI(t,a),u=new Headers(s.headers);return Lm(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");fs.corsProcessor=rI;var nI=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 Dm.ConfigurationError(`Invalid Configuration - no corsPolicy '${t.corsPolicy}' found in *.oas.json`);return r},"getCorsPolicy"),iI=o((t,e)=>{let r=(0,xm.findMatchingOrigin)(e.allowedOrigins,t.headers.get("origin"));return r?(0,xm.generateCorsHeaders)(e,r):{}},"getCorsHeaders")});var Mm=_(hs=>{"use strict";Object.defineProperty(hs,"__esModule",{value:!0});hs.registerPingRoute=void 0;var oI=Gt(),sI=Ul(),aI=Vr(),cI=gt(),uI=o((t,e)=>{let r=o(async()=>new Response(null,{status:200}),"pingRouteHandler"),n=new oI.Pipeline({processors:[sI.corsProcessor],handler:r,gateway:e}),i=new cI.SystemRouteConfiguration({corsPolicy:"anything-goes",label:"SYSTEM_PING_ROUTE",methods:["GET"],path:"/__zuplo/ping",systemRouteName:aI.SystemRouteName.Ping});t.addRoute(i,n.execute)},"registerPingRoute");hs.registerPingRoute=uI});var _n=_(bn=>{"use strict";Object.defineProperty(bn,"__esModule",{value:!0});bn.OutboundPolicy=bn.InboundPolicy=void 0;var lI=k(),dI=at(),ms=class{static{o(this,"PolicyBase")}options;policyName;constructor(e,r){if(!(0,dI.isString)(r))throw new lI.RuntimeError(`The name of a policy must be a string. Received '${r}' of type '${typeof r}'`);this.options=e,this.policyName=r}},kl=class extends ms{static{o(this,"InboundPolicy")}};bn.InboundPolicy=kl;var Fl=class extends ms{static{o(this,"OutboundPolicy")}};bn.OutboundPolicy=Fl});var En=_(bt=>{"use strict";Object.defineProperty(bt,"__esModule",{value:!0});bt.createInternalPolicyProcessor=bt.policyProcessor=bt.toStackedInboundHandler=bt.getInboundPolicyInstances=void 0;var pI=$r(),$e=k(),ys=_n(),Um=Ke(),fI=ie(),$l=class extends ys.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)}},jl=class extends ys.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)}},Hl=new Map;function km(t,e){let r,n;return Array.isArray(t)?r=t:(r=t.policies?.inbound??[],n=t.path),r.filter(s=>!Hl.has(s)).forEach(s=>{let a=e?.find(l=>l.name===s);if(!a)throw new $e.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 $e.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 $e.ConfigurationError(`Invalid state - invalid policy '${s}' on route '${n}' (typeof module '${typeof c}')`);let u;if(typeof c!="function")throw new $e.ConfigurationError(`Invalid state - invalid policy '${s}' on route '${n}' (typeof module '${typeof c}')`);if(c.prototype instanceof ys.InboundPolicy)u=new c(a.handler.options,a.name);else if(typeof c=="function")u=new $l(c,a.handler.options,a.name);else throw new $e.ConfigurationError(`Invalid state - invalid policy '${s}' on route '${n}' (typeof policy '${typeof c}')`);if(typeof u.handler!="function")throw new $e.ConfigurationError(`Invalid state - invalid handler on policy '${s}' on route '${n}' (typeof handler '${typeof u.handler}')`);Hl.set(a.name,u)}),r.map(s=>{let a=Hl.get(s);if(a===void 0)throw new $e.RuntimeError("Internal error. Policy not found in cache.");return a})}o(km,"getInboundPolicyInstances");bt.getInboundPolicyInstances=km;var ql=new Map;function hI(t,e){let r=t.policies?.outbound??[];return r.filter(i=>!ql.has(i)).forEach(i=>{let s=e?.find(u=>u.name===i);if(!s)throw new $e.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 $e.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 $e.ConfigurationError(`Invalid state - invalid policy '${i}' on route '${t.path}' (typeof module '${typeof a}')`);if(a.prototype instanceof ys.OutboundPolicy)c=new a(s.handler.options??{},s.name);else if(typeof a=="function")c=new jl(a,s.handler.options??{},s.name);else throw new $e.ConfigurationError(`Invalid state - invalid policy '${i}' on route '${t.path}' (typeof policy '${typeof a}')`);if(typeof c.handler!="function")throw new $e.ConfigurationError(`Invalid state - invalid handler on policy '${i}' on route '${t.path}'`);ql.set(s.name,c)}),r.map(i=>{let s=ql.get(i);if(s===void 0)throw new $e.RuntimeError("Internal error. Policy not found in cache.");return s})}o(hI,"getOutboundPolicyInstances");var mI=o(t=>async(e,r)=>{let n=pI.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 Um.ZuploRequest)s=c;else if(c instanceof Request)s=new Um.ZuploRequest(c);else{if(c instanceof Response)return c;throw new $e.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");bt.toStackedInboundHandler=mI;var yI=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 $e.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"),gI=o(async(t,e,r,n)=>{let i=km(e.route,r.routeData.policies),s=hI(e.route,r.routeData.policies);return Fm({request:t,context:e,inboundPolicies:i,outboundPolicies:s,gateway:r,next:n})},"policyProcessor");bt.policyProcessor=gI;function bI({inboundPolicies:t=[],outboundPolicies:e=[]}){return o(async(n,i,s,a)=>Fm({request:n,context:i,inboundPolicies:t,outboundPolicies:e,gateway:s,next:a}),"policyProcessor")}o(bI,"createInternalPolicyProcessor");bt.createInternalPolicyProcessor=bI;async function Fm({request:t,context:e,inboundPolicies:r,outboundPolicies:n,gateway:i,next:s}){let a=(0,bt.toStackedInboundHandler)(r);try{let c=await a(t,e);if(c instanceof Response)return c;let u=await s(c),l=yI(n),d;return fI.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(Fm,"executePolicyProcessor")});var Hm=_(wn=>{"use strict";Object.defineProperty(wn,"__esModule",{value:!0});wn.serialize=wn.parse=void 0;var _I=Object.prototype.toString,gs=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;function EI(t,e){if(typeof t!="string")throw new TypeError("argument str must be a string");let r={},i=(e||{}).decode||vI,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(EI,"parse");wn.parse=EI;function wI(t,e,r){let n=r||{},i=n.encode||TI;if(typeof i!="function")throw new TypeError("option encode is invalid");if(!gs.test(t))throw new TypeError("argument name is invalid");let s=i(e);if(s&&!gs.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(!gs.test(n.domain))throw new TypeError("option domain is invalid");a+="; Domain="+n.domain}if(n.path){if(!gs.test(n.path))throw new TypeError("option path is invalid");a+="; Path="+n.path}if(n.expires){let c=n.expires;if(!SI(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(wI,"serialize");wn.serialize=wI;function vI(t){return t.indexOf("%")!==-1?decodeURIComponent(t):t}o(vI,"decode");function TI(t){return encodeURIComponent(t)}o(TI,"encode");function SI(t){return _I.call(t)==="[object Date]"||t instanceof Date}o(SI,"isDate");function II(t,e){try{return e(t)}catch{return t}}o(II,"tryDecode")});var qm=_(bs=>{"use strict";Object.defineProperty(bs,"__esModule",{value:!0});bs.devPortalBaseURL=void 0;var PI=Hm();function AI(t,e){try{let r=/v\d+(-\d+)?/g,i=(0,PI.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(AI,"devPortalBaseURL");bs.devPortalBaseURL=AI});var Gm=_(vn=>{"use strict";Object.defineProperty(vn,"__esModule",{value:!0});vn.registerDevPortalLegacyRedirectRoute=vn.registerDevPortalV3Route=void 0;var Vl=Kt(),jm=Gt(),Vm=ar(),RI=En(),Bm=gt(),OI=qm(),lr=ie(),$m="/__zuplo/dev-portal",NI="dev-portal-id",CI="dev-portal-host",xI="zp-account",LI="zp-project",DI="dev-portal-build",MI=`
|
|
36
36
|
<!DOCTYPE html>
|
|
37
37
|
<html lang="en">
|
|
38
38
|
<head>
|