@zuplo/runtime 5.1905.0 → 5.1909.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.minified.js CHANGED
@@ -38,7 +38,7 @@
38
38
  `);let w=new r("!xml"),S=w,M="",A="";for(let _=0;_<h.length;_++)if(h[_]==="<")if(h[_+1]==="/"){let k=f(h,">",_,"Closing Tag is not closed."),N=h.substring(_+2,k).trim();if(this.options.removeNSPrefix){let me=N.indexOf(":");me!==-1&&(N=N.substr(me+1))}this.options.transformTagName&&(N=this.options.transformTagName(N)),S&&(M=this.saveTextToParentTag(M,S,A));let W=A.substring(A.lastIndexOf(".")+1);if(N&&this.options.unpairedTags.indexOf(N)!==-1)throw new Error(`Unpaired tag can not be used as closing tag: </${N}>`);let j=0;W&&this.options.unpairedTags.indexOf(W)!==-1?(j=A.lastIndexOf(".",A.lastIndexOf(".")-1),this.tagsNodeStack.pop()):j=A.lastIndexOf("."),A=A.substring(0,j),S=this.tagsNodeStack.pop(),M="",_=k}else if(h[_+1]==="?"){let k=I(h,_,!1,"?>");if(!k)throw new Error("Pi Tag is not closed.");if(M=this.saveTextToParentTag(M,S,A),!(this.options.ignoreDeclaration&&k.tagName==="?xml"||this.options.ignorePiTags)){let N=new r(k.tagName);N.add(this.options.textNodeName,""),k.tagName!==k.tagExp&&k.attrExpPresent&&(N[":@"]=this.buildAttributesMap(k.tagExp,A,k.tagName)),this.addChild(S,N,A)}_=k.closeIndex+1}else if(h.substr(_+1,3)==="!--"){let k=f(h,"-->",_+4,"Comment is not closed.");if(this.options.commentPropName){let N=h.substring(_+4,k-2);M=this.saveTextToParentTag(M,S,A),S.add(this.options.commentPropName,[{[this.options.textNodeName]:N}])}_=k}else if(h.substr(_+1,2)==="!D"){let k=o(h,_);this.docTypeEntities=k.entities,_=k.i}else if(h.substr(_+1,2)==="!["){let k=f(h,"]]>",_,"CDATA is not closed.")-2,N=h.substring(_+9,k);M=this.saveTextToParentTag(M,S,A);let W=this.parseTextData(N,S.tagname,A,!0,!1,!0,!0);W==null&&(W=""),this.options.cdataPropName?S.add(this.options.cdataPropName,[{[this.options.textNodeName]:N}]):S.add(this.options.textNodeName,W),_=k+2}else{let k=I(h,_,this.options.removeNSPrefix),N=k.tagName,W=k.rawTagName,j=k.tagExp,me=k.attrExpPresent,Wo=k.closeIndex;this.options.transformTagName&&(N=this.options.transformTagName(N)),S&&M&&S.tagname!=="!xml"&&(M=this.saveTextToParentTag(M,S,A,!1));let Ko=S;if(Ko&&this.options.unpairedTags.indexOf(Ko.tagname)!==-1&&(S=this.tagsNodeStack.pop(),A=A.substring(0,A.lastIndexOf("."))),N!==w.tagname&&(A+=A?"."+N:N),this.isItStopNode(this.options.stopNodes,A,N)){let de="";if(j.length>0&&j.lastIndexOf("/")===j.length-1)_=k.closeIndex;else if(this.options.unpairedTags.indexOf(N)!==-1)_=k.closeIndex;else{let ir=this.readStopNodeData(h,W,Wo+1);if(!ir)throw new Error(`Unexpected end of ${W}`);_=ir.i,de=ir.tagContent}let or=new r(N);N!==j&&me&&(or[":@"]=this.buildAttributesMap(j,A,N)),de&&(de=this.parseTextData(de,N,A,!0,me,!0,!0)),A=A.substr(0,A.lastIndexOf(".")),or.add(this.options.textNodeName,de),this.addChild(S,or,A)}else{if(j.length>0&&j.lastIndexOf("/")===j.length-1){N[N.length-1]==="/"?(N=N.substr(0,N.length-1),A=A.substr(0,A.length-1),j=N):j=j.substr(0,j.length-1),this.options.transformTagName&&(N=this.options.transformTagName(N));let de=new r(N);N!==j&&me&&(de[":@"]=this.buildAttributesMap(j,A,N)),this.addChild(S,de,A),A=A.substr(0,A.lastIndexOf("."))}else{let de=new r(N);this.tagsNodeStack.push(S),N!==j&&me&&(de[":@"]=this.buildAttributesMap(j,A,N)),this.addChild(S,de,A),S=de}M="",_=Wo}}else M+=h[_];return w.child},"parseXml");function g(h,w,S){let M=this.options.updateTag(w.tagname,S,w[":@"]);M===!1||(typeof M=="string"&&(w.tagname=M),h.addChild(w))}i(g,"addChild"),D(g,"addChild");var R=D(function(h){if(this.options.processEntities){for(let w in this.docTypeEntities){let S=this.docTypeEntities[w];h=h.replace(S.regx,S.val)}for(let w in this.lastEntities){let S=this.lastEntities[w];h=h.replace(S.regex,S.val)}if(this.options.htmlEntities)for(let w in this.htmlEntities){let S=this.htmlEntities[w];h=h.replace(S.regex,S.val)}h=h.replace(this.ampEntity.regex,this.ampEntity.val)}return h},"replaceEntitiesValue");function b(h,w,S,M){return h&&(M===void 0&&(M=Object.keys(w.child).length===0),h=this.parseTextData(h,w.tagname,S,!1,w[":@"]?Object.keys(w[":@"]).length!==0:!1,M),h!==void 0&&h!==""&&w.add(this.options.textNodeName,h),h=""),h}i(b,"saveTextToParentTag"),D(b,"saveTextToParentTag");function v(h,w,S){let M="*."+S;for(let A in h){let _=h[A];if(M===_||w===_)return!0}return!1}i(v,"isItStopNode"),D(v,"isItStopNode");function O(h,w,S=">"){let M,A="";for(let _=w;_<h.length;_++){let B=h[_];if(M)B===M&&(M="");else if(B==='"'||B==="'")M=B;else if(B===S[0])if(S[1]){if(h[_+1]===S[1])return{data:A,index:_}}else return{data:A,index:_};else B===" "&&(B=" ");A+=B}}i(O,"tagExpWithClosingIndex"),D(O,"tagExpWithClosingIndex");function f(h,w,S,M){let A=h.indexOf(w,S);if(A===-1)throw new Error(M);return A+w.length-1}i(f,"findClosingIndex"),D(f,"findClosingIndex");function I(h,w,S,M=">"){let A=O(h,w+1,M);if(!A)return;let _=A.data,B=A.index,k=_.search(/\s/),N=_,W=!0;k!==-1&&(N=_.substring(0,k),_=_.substring(k+1).trimStart());let j=N;if(S){let me=N.indexOf(":");me!==-1&&(N=N.substr(me+1),W=N!==A.data.substr(me+1))}return{tagName:N,tagExp:_,closeIndex:B,attrExpPresent:W,rawTagName:j}}i(I,"readTagExp"),D(I,"readTagExp");function C(h,w,S){let M=S,A=1;for(;S<h.length;S++)if(h[S]==="<")if(h[S+1]==="/"){let _=f(h,">",S,`${w} is not closed`);if(h.substring(S+2,_).trim()===w&&(A--,A===0))return{tagContent:h.substring(M,S),i:_};S=_}else if(h[S+1]==="?")S=f(h,"?>",S+1,"StopNode is not closed.");else if(h.substr(S+1,3)==="!--")S=f(h,"-->",S+3,"StopNode is not closed.");else if(h.substr(S+1,2)==="![")S=f(h,"]]>",S,"StopNode is not closed.")-2;else{let _=I(h,S,">");_&&((_&&_.tagName)===w&&_.tagExp[_.tagExp.length-1]!=="/"&&A++,S=_.closeIndex)}}i(C,"readStopNodeData"),D(C,"readStopNodeData");function U(h,w,S){if(w&&typeof h=="string"){let M=h.trim();return M==="true"?!0:M==="false"?!1:s(h,S)}else return n.isExist(h)?h:""}i(U,"parseValue"),D(U,"parseValue"),e.exports=a}}),_d=we({"node_modules/fast-xml-parser/src/xmlparser/node2json.js"(t){"use strict";function e(a,u){return n(a,u)}i(e,"prettify"),D(e,"prettify");function n(a,u,c){let l,d={};for(let p=0;p<a.length;p++){let m=a[p],g=r(m),R="";if(c===void 0?R=g:R=c+"."+g,g===u.textNodeName)l===void 0?l=m[g]:l+=""+m[g];else{if(g===void 0)continue;if(m[g]){let b=n(m[g],u,R),v=s(b,u);m[":@"]?o(b,m[":@"],R,u):Object.keys(b).length===1&&b[u.textNodeName]!==void 0&&!u.alwaysCreateTextNode?b=b[u.textNodeName]:Object.keys(b).length===0&&(u.alwaysCreateTextNode?b[u.textNodeName]="":b=""),d[g]!==void 0&&d.hasOwnProperty(g)?(Array.isArray(d[g])||(d[g]=[d[g]]),d[g].push(b)):u.isArray(g,R,v)?d[g]=[b]:d[g]=b}}}return typeof l=="string"?l.length>0&&(d[u.textNodeName]=l):l!==void 0&&(d[u.textNodeName]=l),d}i(n,"compress"),D(n,"compress");function r(a){let u=Object.keys(a);for(let c=0;c<u.length;c++){let l=u[c];if(l!==":@")return l}}i(r,"propName"),D(r,"propName");function o(a,u,c,l){if(u){let d=Object.keys(u),p=d.length;for(let m=0;m<p;m++){let g=d[m];l.isArray(g,c+"."+g,!0,!0)?a[g]=[u[g]]:a[g]=u[g]}}}i(o,"assignAttributes"),D(o,"assignAttributes");function s(a,u){let{textNodeName:c}=u,l=Object.keys(a).length;return!!(l===0||l===1&&(a[c]||typeof a[c]=="boolean"||a[c]===0))}i(s,"isLeafTag"),D(s,"isLeafTag"),t.prettify=e}}),Nd=we({"node_modules/fast-xml-parser/src/xmlparser/XMLParser.js"(t,e){var{buildOptions:n}=Sd(),r=Ld(),{prettify:o}=_d(),s=hu(),a=class{static{i(this,"XMLParser2")}static{D(this,"XMLParser")}constructor(u){this.externalEntities={},this.options=n(u)}parse(u,c){if(typeof u!="string")if(u.toString)u=u.toString();else throw new Error("XML data is accepted in String or Bytes[] form.");if(c){c===!0&&(c={});let p=s.validate(u,c);if(p!==!0)throw Error(`${p.err.msg}:${p.err.line}:${p.err.col}`)}let l=new r(this.options);l.addExternalEntities(this.externalEntities);let d=l.parseXml(u);return this.options.preserveOrder||d===void 0?d:o(d,this.options)}addEntity(u,c){if(c.indexOf("&")!==-1)throw new Error("Entity value can't have '&'");if(u.indexOf("&")!==-1||u.indexOf(";")!==-1)throw new Error("An entity must be set without '&' and ';'. Eg. use '#xD' for '&#xD;'");if(c==="&")throw new Error("An entity with value '&' is not permitted");this.externalEntities[u]=c}};e.exports=a}}),kd=we({"node_modules/fast-xml-parser/src/xmlbuilder/orderedJs2Xml.js"(t,e){var n=`
39
39
  `;function r(l,d){let p="";return d.format&&d.indentBy.length>0&&(p=n),o(l,d,"",p)}i(r,"toXml"),D(r,"toXml");function o(l,d,p,m){let g="",R=!1;for(let b=0;b<l.length;b++){let v=l[b],O=s(v);if(O===void 0)continue;let f="";if(p.length===0?f=O:f=`${p}.${O}`,O===d.textNodeName){let w=v[O];u(f,d)||(w=d.tagValueProcessor(O,w),w=c(w,d)),R&&(g+=m),g+=w,R=!1;continue}else if(O===d.cdataPropName){R&&(g+=m),g+=`<![CDATA[${v[O][0][d.textNodeName]}]]>`,R=!1;continue}else if(O===d.commentPropName){g+=m+`<!--${v[O][0][d.textNodeName]}-->`,R=!0;continue}else if(O[0]==="?"){let w=a(v[":@"],d),S=O==="?xml"?"":m,M=v[O][0][d.textNodeName];M=M.length!==0?" "+M:"",g+=S+`<${O}${M}${w}?>`,R=!0;continue}let I=m;I!==""&&(I+=d.indentBy);let C=a(v[":@"],d),U=m+`<${O}${C}`,h=o(v[O],d,f,I);d.unpairedTags.indexOf(O)!==-1?d.suppressUnpairedNode?g+=U+">":g+=U+"/>":(!h||h.length===0)&&d.suppressEmptyNode?g+=U+"/>":h&&h.endsWith(">")?g+=U+`>${h}${m}</${O}>`:(g+=U+">",h&&m!==""&&(h.includes("/>")||h.includes("</"))?g+=m+d.indentBy+h+m:g+=h,g+=`</${O}>`),R=!0}return g}i(o,"arrToStr"),D(o,"arrToStr");function s(l){let d=Object.keys(l);for(let p=0;p<d.length;p++){let m=d[p];if(l.hasOwnProperty(m)&&m!==":@")return m}}i(s,"propName"),D(s,"propName");function a(l,d){let p="";if(l&&!d.ignoreAttributes)for(let m in l){if(!l.hasOwnProperty(m))continue;let g=d.attributeValueProcessor(m,l[m]);g=c(g,d),g===!0&&d.suppressBooleanAttributes?p+=` ${m.substr(d.attributeNamePrefix.length)}`:p+=` ${m.substr(d.attributeNamePrefix.length)}="${g}"`}return p}i(a,"attr_to_str"),D(a,"attr_to_str");function u(l,d){l=l.substr(0,l.length-d.textNodeName.length-1);let p=l.substr(l.lastIndexOf(".")+1);for(let m in d.stopNodes)if(d.stopNodes[m]===l||d.stopNodes[m]==="*."+p)return!0;return!1}i(u,"isStopNode"),D(u,"isStopNode");function c(l,d){if(l&&l.length>0&&d.processEntities)for(let p=0;p<d.entities.length;p++){let m=d.entities[p];l=l.replace(m.regex,m.val)}return l}i(c,"replaceEntitiesValue"),D(c,"replaceEntitiesValue"),e.exports=r}}),Md=we({"node_modules/fast-xml-parser/src/xmlbuilder/json2xml.js"(t,e){"use strict";var n=kd(),r={attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,cdataPropName:!1,format:!1,indentBy:" ",suppressEmptyNode:!1,suppressUnpairedNode:!0,suppressBooleanAttributes:!0,tagValueProcessor:function(c,l){return l},attributeValueProcessor:function(c,l){return l},preserveOrder:!1,commentPropName:!1,unpairedTags:[],entities:[{regex:new RegExp("&","g"),val:"&amp;"},{regex:new RegExp(">","g"),val:"&gt;"},{regex:new RegExp("<","g"),val:"&lt;"},{regex:new RegExp("'","g"),val:"&apos;"},{regex:new RegExp('"',"g"),val:"&quot;"}],processEntities:!0,stopNodes:[],oneListGroup:!1};function o(c){this.options=Object.assign({},r,c),this.options.ignoreAttributes||this.options.attributesGroupName?this.isAttribute=function(){return!1}:(this.attrPrefixLen=this.options.attributeNamePrefix.length,this.isAttribute=u),this.processTextOrObjNode=s,this.options.format?(this.indentate=a,this.tagEndChar=`>
40
40
  `,this.newLine=`
41
- `):(this.indentate=function(){return""},this.tagEndChar=">",this.newLine="")}i(o,"Builder"),D(o,"Builder"),o.prototype.build=function(c){return this.options.preserveOrder?n(c,this.options):(Array.isArray(c)&&this.options.arrayNodeName&&this.options.arrayNodeName.length>1&&(c={[this.options.arrayNodeName]:c}),this.j2x(c,0).val)},o.prototype.j2x=function(c,l){let d="",p="";for(let m in c)if(Object.prototype.hasOwnProperty.call(c,m))if(typeof c[m]>"u")this.isAttribute(m)&&(p+="");else if(c[m]===null)this.isAttribute(m)?p+="":m[0]==="?"?p+=this.indentate(l)+"<"+m+"?"+this.tagEndChar:p+=this.indentate(l)+"<"+m+"/"+this.tagEndChar;else if(c[m]instanceof Date)p+=this.buildTextValNode(c[m],m,"",l);else if(typeof c[m]!="object"){let g=this.isAttribute(m);if(g)d+=this.buildAttrPairStr(g,""+c[m]);else if(m===this.options.textNodeName){let R=this.options.tagValueProcessor(m,""+c[m]);p+=this.replaceEntitiesValue(R)}else p+=this.buildTextValNode(c[m],m,"",l)}else if(Array.isArray(c[m])){let g=c[m].length,R="";for(let b=0;b<g;b++){let v=c[m][b];typeof v>"u"||(v===null?m[0]==="?"?p+=this.indentate(l)+"<"+m+"?"+this.tagEndChar:p+=this.indentate(l)+"<"+m+"/"+this.tagEndChar:typeof v=="object"?this.options.oneListGroup?R+=this.j2x(v,l+1).val:R+=this.processTextOrObjNode(v,m,l):R+=this.buildTextValNode(v,m,"",l))}this.options.oneListGroup&&(R=this.buildObjectNode(R,m,"",l)),p+=R}else if(this.options.attributesGroupName&&m===this.options.attributesGroupName){let g=Object.keys(c[m]),R=g.length;for(let b=0;b<R;b++)d+=this.buildAttrPairStr(g[b],""+c[m][g[b]])}else p+=this.processTextOrObjNode(c[m],m,l);return{attrStr:d,val:p}},o.prototype.buildAttrPairStr=function(c,l){return l=this.options.attributeValueProcessor(c,""+l),l=this.replaceEntitiesValue(l),this.options.suppressBooleanAttributes&&l==="true"?" "+c:" "+c+'="'+l+'"'};function s(c,l,d){let p=this.j2x(c,d+1);return c[this.options.textNodeName]!==void 0&&Object.keys(c).length===1?this.buildTextValNode(c[this.options.textNodeName],l,p.attrStr,d):this.buildObjectNode(p.val,l,p.attrStr,d)}i(s,"processTextOrObjNode"),D(s,"processTextOrObjNode"),o.prototype.buildObjectNode=function(c,l,d,p){if(c==="")return l[0]==="?"?this.indentate(p)+"<"+l+d+"?"+this.tagEndChar:this.indentate(p)+"<"+l+d+this.closeTag(l)+this.tagEndChar;{let m="</"+l+this.tagEndChar,g="";return l[0]==="?"&&(g="?",m=""),(d||d==="")&&c.indexOf("<")===-1?this.indentate(p)+"<"+l+d+g+">"+c+m:this.options.commentPropName!==!1&&l===this.options.commentPropName&&g.length===0?this.indentate(p)+`<!--${c}-->`+this.newLine:this.indentate(p)+"<"+l+d+g+this.tagEndChar+c+this.indentate(p)+m}},o.prototype.closeTag=function(c){let l="";return this.options.unpairedTags.indexOf(c)!==-1?this.options.suppressUnpairedNode||(l="/"):this.options.suppressEmptyNode?l="/":l=`></${c}`,l},o.prototype.buildTextValNode=function(c,l,d,p){if(this.options.cdataPropName!==!1&&l===this.options.cdataPropName)return this.indentate(p)+`<![CDATA[${c}]]>`+this.newLine;if(this.options.commentPropName!==!1&&l===this.options.commentPropName)return this.indentate(p)+`<!--${c}-->`+this.newLine;if(l[0]==="?")return this.indentate(p)+"<"+l+d+"?"+this.tagEndChar;{let m=this.options.tagValueProcessor(l,c);return m=this.replaceEntitiesValue(m),m===""?this.indentate(p)+"<"+l+d+this.closeTag(l)+this.tagEndChar:this.indentate(p)+"<"+l+d+">"+m+"</"+l+this.tagEndChar}},o.prototype.replaceEntitiesValue=function(c){if(c&&c.length>0&&this.options.processEntities)for(let l=0;l<this.options.entities.length;l++){let d=this.options.entities[l];c=c.replace(d.regex,d.val)}return c};function a(c){return this.options.indentBy.repeat(c)}i(a,"indentate"),D(a,"indentate");function u(c){return c.startsWith(this.options.attributeNamePrefix)&&c!==this.options.textNodeName?c.substr(this.attrPrefixLen):!1}i(u,"isAttribute"),D(u,"isAttribute"),e.exports=o}}),Dd=hu(),Ud=Nd(),Hd=Md();yu.exports={XMLParser:Ud,XMLValidator:Dd,XMLBuilder:Hd};});var Zd={};vu(Zd,{API_KEY:()=>os,AWSLoggingPlugin:()=>xn,AmberfloMeteringInboundPolicy:()=>ea,AmberfloMeteringPolicy:()=>_n,ApiAuthKeyInboundPolicy:()=>ra,ApiKeyInboundPolicy:()=>kn,AuditLogDataStaxProvider:()=>Sn,AuditLogPlugin:()=>On,Auth0JwtInboundPolicy:()=>oa,AwsLambdaHandlerExtensions:()=>ks,BackgroundDispatcher:()=>Qn,BackgroundLoader:()=>Xn,BasicAuthInboundPolicy:()=>ia,BasicRateLimitInboundPolicy:()=>Ho,BatchDispatch:()=>q,CachingInboundPolicy:()=>sa,ChangeMethodInboundPolicy:()=>aa,ClearHeadersInboundPolicy:()=>ua,ClearHeadersOutboundPolicy:()=>ca,ClerkJwtInboundPolicy:()=>la,CognitoJwtInboundPolicy:()=>da,CompositeInboundPolicy:()=>pa,ConfigurationError:()=>y,ContentTypes:()=>jt,ContextData:()=>pe,CryptoBeta:()=>tr,CurityPhantomTokenInboundPolicy:()=>ma,DataDogLoggingPlugin:()=>cn,DataDogMetricsPlugin:()=>vn,DynaTraceLoggingPlugin:()=>Rn,DynatraceMetricsPlugin:()=>Tn,FirebaseJwtInboundPolicy:()=>ga,FormDataToJsonInboundPolicy:()=>fa,GeoFilterInboundPolicy:()=>ha,GoogleCloudLoggingPlugin:()=>sn,Handler:()=>bn,HttpProblems:()=>T,HttpStatusCode:()=>Wt,InboundPolicy:()=>ge,JWTScopeValidationInboundPolicy:()=>ya,KeyValueStore:()=>rr,LokiLoggingPlugin:()=>Pn,LookupResult:()=>et,MemoryZoneReadThroughCache:()=>Y,MockApiInboundPolicy:()=>wa,MoesifInboundPolicy:()=>va,MonetizationInboundPolicy:()=>Dn,OktaJwtInboundPolicy:()=>Aa,OpenIdJwtInboundPolicy:()=>te,OutboundPolicy:()=>ve,ProblemResponseFormatter:()=>Le,PropelAuthJwtInboundPolicy:()=>_a,RateLimitInboundPolicy:()=>Ho,ReadmeMetricsInboundPolicy:()=>qa,RemoveHeadersInboundPolicy:()=>$a,RemoveHeadersOutboundPolicy:()=>Fa,RemoveQueryParamsInboundPolicy:()=>Ba,ReplaceStringOutboundPolicy:()=>za,RequestSizeLimitInboundPolicy:()=>Va,RequestValidationInboundPolicy:()=>$o,RequireOriginInboundPolicy:()=>eu,ResponseSendingEvent:()=>Ke,ResponseSentEvent:()=>Je,Router:()=>tt,RuntimeError:()=>L,SYSTEM_LOGGER:()=>Pt,SchemaBasedRequestValidation:()=>Xa,ServiceProviderImpl:()=>Yn,SetBodyInboundPolicy:()=>tu,SetHeadersInboundPolicy:()=>nu,SetHeadersOutboundPolicy:()=>ru,SetQueryParamsInboundPolicy:()=>ou,SetStatusOutboundPolicy:()=>iu,SleepInboundPolicy:()=>su,StripeMonetizationPlugin:()=>Ao,StripeWebhookVerificationInboundPolicy:()=>st,SumoLogicLoggingPlugin:()=>En,SupabaseJwtInboundPolicy:()=>au,SystemLogMap:()=>F,SystemRouteName:()=>Re,UpstreamAzureAdServiceAuthInboundPolicy:()=>uu,UpstreamFirebaseAdminAuthInboundPolicy:()=>lu,UpstreamFirebaseUserAuthInboundPolicy:()=>du,UpstreamGcpJwtInboundPolicy:()=>pu,UpstreamGcpServiceAuthInboundPolicy:()=>gu,VMWareLogInsightLoggingPlugin:()=>In,ValidateJsonSchemaInbound:()=>fu,XmlToJsonOutboundPolicy:()=>Jn,ZoneCache:()=>Ge,ZuploRequest:()=>z,awsLambdaHandler:()=>Ms,environment:()=>oe,getIdForParameterSchema:()=>Wn,getIdForRefSchema:()=>Wa,getIdForRequestBodySchema:()=>Kn,getRawOperationDataIdentifierName:()=>Ga,httpStatuses:()=>Kt,isRestrictedEnvVariableName:()=>to,isZuploReadableEnvVariableName:()=>no,openApiSpecHandler:()=>Ds,originalFetch:()=>nt,purgeGatewayCache:()=>Is,redirectHandler:()=>Us,sanitizedIdentifierName:()=>De,serialize:()=>Vt,setMoesifContext:()=>xa,urlForwardHandler:()=>Hs,urlRewriteHandler:()=>Zs,webSocketHandler:()=>qs,webSocketPipelineHandler:()=>Bs});module.exports=Tu(Zd);var $=class extends Error{static{i(this,"SystemError")}constructor(e,n){super(e,n),this.name="InternalError"}},L=class extends Error{static{i(this,"RuntimeError")}extensionMembers;constructor(e,n){typeof e=="string"?super(e,n):(super(e.message,n),this.extensionMembers=e.extensionMembers),this.name="RuntimeError"}},y=class extends L{static{i(this,"ConfigurationError")}constructor(e,n){super(e,n),this.name="ConfigurationError"}},kt=class extends L{static{i(this,"FeatureNotEnabledError")}constructor(e,n){super(e,n),this.name="FeatureNotEnabledError"}};var E=class t{static{i(this,"Environment")}config;static#e;static initialize(e,n){this.#e||(this.#e=new t(e,n))}static get instance(){if(!this.#e)throw new $("Environment has not been initialized");return this.#e}constructor(e,n){let r;try{if(n.__ZUPLO_CONFIG){let o=atob(n.__ZUPLO_CONFIG);r=JSON.parse(o)}}catch{console.warn("Failed to parse runtime configuration")}this.config=r??{},this.build=e,this.runtime=n}build;runtime;get deploymentName(){return this.runtime.__ZUPLO_DEPLOYMENT_NAME??this.config.deployment_name??void 0}get useSha256ServiceRouting(){return this.config.use_sha256_service_routing??void 0}get useProxyForFetchFromZups(){return this.config.use_proxy_for_fetch_from_zups??void 0}get devPortalBaseUrl(){return this.runtime.__ZUPLO_DEV_PORTAL_URL??this.config.dev_portal_url??"https://dev-portal-v4-1.zuplo.com"}get buildAssetsUrl(){return this.runtime.__ZUPLO_BUILD_ASSETS_URL??this.config.build_assets_url??"https://build-assets.zuplo.dev"}get remoteLogToken(){return this.runtime.__ZUPLO_REMOTE_LOG_TOKEN??this.config.remote_log_token??void 0}get managementApiURL(){return this.runtime.__ZUPLO_MANAGEMENT_API_URL??this.config.management_api_url??"https://api.zuplo.com"}get cdnURL(){return this.runtime.__ZUPLO_CDN_URL??this.config.cdn_url??"https://cdn.zuplo.com"}get remoteLogURL(){return this.runtime.__ZUPLO_REMOTE_LOG_URL??this.config.log_event_api??"https://ellie.zuplo.com"}get loggingId(){return this.runtime.__ZUPLO_LOGGING_ID??this.config.logging_id??void 0}get redisURL(){return this.runtime.__ZUPLO_REDIS_URL??this.config.redis_proxy_url??"https://redis-proxy.zuplo.com"}get apiKeyServiceUrl(){return this.runtime.__ZUPLO_API_KEY_SERVICE_URL??this.config.api_key_service_url??"https://apikey.zuplo.com"}get meteringServiceUrl(){return this.config.metering_service_url??"https://meters.zuplo.com"}get authApiJWT(){return this.runtime.__ZUPLO_AUTH_API_JWT??void 0}get userLogLevel(){return this.runtime.ZUPLO_LOG_LEVEL??this.runtime.__ZUPLO_LOG_LEVEL??this.config.user_log_level??"debug"}get systemLogLevel(){return this.runtime.__ZUPLO_LOG_LEVEL??this.config.system_log_level??"debug"}get logFormat(){return this.runtime.__ZUPLO_LOG_FORMAT??this.config.log_format??"cloudflare"}get isCloudflare(){return this.runtime.__ZUPLO_RUNTIME_TYPE?this.runtime.__ZUPLO_RUNTIME_TYPE==="cloudflare":this.config.runtime_type?this.config.runtime_type==="cloudflare":typeof WebSocketPair=="function"}get isDeno(){return this.runtime.__ZUPLO_RUNTIME_TYPE?this.runtime.__ZUPLO_RUNTIME_TYPE==="deno":this.config.runtime_type?this.config.runtime_type==="deno":typeof WebSocketPair!="function"}get isLocalDevelopment(){return this.build.ENVIRONMENT_TYPE?this.build.ENVIRONMENT_TYPE==="LOCAL_DEVELOPMENT":!1}get systemUserAgent(){return`Zuplo/${this.build.ZUPLO_VERSION}`}get loggingEnvironmentType(){return this.isCloudflare?"edge":this.isLocalDevelopment?"local":this.isDeno?"working-copy":"unknown"}get loggingEnvironmentStage(){return this.build.ENVIRONMENT_TYPE==="PRODUCTION"?"production":this.build.ENVIRONMENT_TYPE==="PREVIEW"?"preview":this.isLocalDevelopment?"local":this.isDeno?"working-copy":"unknown"}};Function.prototype.toString=function(){return"[native code]"};var Mt=globalThis,Yo=Mt.caches;if(Yo){let t=Yo.open;Mt.caches.open=function(e){let n=E.instance.deploymentName??E.instance.build.BUILD_ID;return t.call(this,`${n}-${e}`)},delete Mt.caches.default,Object.freeze(Mt.caches)}var Qo=new Map,sr=class{static{i(this,"InnerCache")}constructor(e){this.#e=e.maxSize}#e;#t=0;#n=new Map;#r=[];get(e){let n=this.#n.get(e);if(!n)return;let r=Date.now();if(r>n.expiresAt){this.#n.delete(e);return}return n.lastUsed=r,this.#o(),n?.data}put(e,n,r){if(r<=0)return;if(this.#n.size>=this.#e){let a=this.#r.shift();a&&this.#n.delete(a)}let o=Date.now(),s={created:o,lastUsed:o,expiresAt:o+r*1e3,data:n};this.#r.push(e),this.#n.set(e,s)}delete(e){let n=this.#r.indexOf(e);n>=0&&this.#r.slice(n,1),this.#n.delete(e)}get size(){return this.#n.size}#o(){let e=Date.now();this.#t+1e4*1e3>e&&(this.purge(),this.#t=e)}purge(){let e=Date.now();this.#n.forEach((n,r)=>{n.expiresAt>=e&&this.#n.delete(r)})}},Ve=class{static{i(this,"MemoryCache")}constructor(e,n={maxSize:1e3}){this.name=e;let r=Qo.get(e);r||(r=new sr(n),Qo.set(e,r)),this.#e=r}name;#e;get(e){return this.#e.get(e)}put(e,n,r){return this.#e.put(e,n,r)}delete(e){return this.#e.delete(e)}get size(){return this.#e.size}purge(){this.#e.purge()}};var ar="__zuplo-expiry-header",Ge=class{static{i(this,"ZoneCache")}constructor(e,n){this.#t=e,this.#e=n}#e;#t;#n;async#r(){return this.#n||(this.#n=await caches.open(this.#t)),this.#n}#o(e){return new Request(`https://zone-cache.zuplo.app/${encodeURIComponent(e)}`)}async get(e){try{let n=await this.#r(),r=this.#o(e),o=await n.match(r);if(!o)return;let s=o.headers.get(ar);if(!s){try{await n.delete(r)}catch(c){this.logDebug("Handled failure to delete with CF cache because of missing expiryHeader",c),await this.deleteFallback(e)}return}let a=parseInt(s);if(Date.now()>=a){try{await n.delete(r)}catch(c){this.logDebug("Handled failure to delete with CF cache because of expiration",c),await this.deleteFallback(e)}return}return await o.json()}catch(n){this.logDebug(n)}}async put(e,n,r){let o=new Headers({"cache-control":`s-maxage=${r}, must-revalidate`,"content-type":"application/json"});o.set(ar,`${Date.now()+r*1e3}`);let s=await this.#r(),a=this.#o(e),u=new Response(JSON.stringify(n),{headers:o});await s.put(a,u)}async delete(e){let n=await this.#r(),r=this.#o(e);try{await n.delete(r)}catch(o){this.logDebug("Handled failure to delete with CF cache due to explicit delete call",o),await this.deleteFallback(e)}}async deleteFallback(e){let n=new Headers({"Cache-Control":"s-maxage=0, must-revalidate"});n.set(ar,`${Date.now()}`);let r=await this.#r(),o=this.#o(e),s=new Response("",{headers:n});await r.put(o,s)}logDebug(...e){"logger"in this.#e?this.#e.logger?.debug(`Error in ZoneCache: '${this.#t}'`,e):"log"in this.#e&&this.#e.log.debug(`Error in ZoneCache: '${this.#t}'`,e)}};var Y=class{static{i(this,"MemoryZoneReadThroughCache")}constructor(e,n){let r=`f6726488-fd18-4b7f-9c30-6070565e8042-${e}`;this.#e=e,this.#t=new Ve(r),this.#n=new Ge(r,n),this.#r=n}#e;#t;#n;#r;async get(e){let n=this.#t.get(e);if(n)return n;let r=await this.#n.get(e);if(r){let o=Math.floor((r.expires-Date.now())/1e3);if(o>0)return this.#t.put(e,r.data,o),r.data}}put(e,n,r){this.#t.put(e,n,r);let o={data:n,expires:Date.now()+r*1e3},s=this.#n.put(e,o,r).catch(a=>{this.#r.log.error(`Error in MemoryZoneReadThroughCache: '${this.#e}'`,a)});this.#r.waitUntil(s)}};var Xo="zuplo-request-id",We="zp-rid",ur="zp-body-removed",Ue="cf-ray",ei="x-real-ip",cr="cf-ipcity",lr="cf-ipcontinent",dr="cf-ipcountry",pr="cf-iplongitude",mr="cf-iplatitude",ti="cf-region",ni="cf-region-code",ri="cf-metro-code",oi="cf-postal-code",ii="cf-timezone",si="zp-ipcity",ai="zp-ipcontinent",ui="zp-ipcountry",ci="zp-iplongitude",li="zp-iplatitude",di="true-client-ip",gr="zp-asn",fr="zp-asorg",hr="zp-colo",yr="zp-postalcode",br="zp-metrocode",wr="zp-region",Rr="zp-regioncode",Pr="zp-timezone",pi=[cr,lr,dr,pr,mr,gr,fr,hr,yr,br,wr,Rr,Pr],mi=["zp-","cf-"],gi=[We,Ue,ur],fi=["x-b3-sampled","x-b3-spanid","x-b3-traceid","x-envoy-attempt-count","x-envoy-decorator-operation","x-envoy-external-address","x-envoy-peer-metadata","x-envoy-peer-metadata-id","k-proxy-request","fly-client-ip","fly-forwarded-port","fly-forwarded-proto","fly-forwarded-ssl","fly-region","fly-request-id","fly-traceparent","fly-tracestate"],mt="zuplo_meters_d7831150-6d8a-416d-b920-4a7bec209a49",Dt="zuplo_dynamic_meters_0c8cdc26-2514-4756-8adb-474a6e103d91";var gs=Se(Ae());var ft=class t{static{i(this,"InternalProblemResponseFormatter")}static problemResponseFormat=async e=>{let n=e.problem,r=JSON.stringify(n,null,2);return new Response(r,{status:e.problem.status,statusText:e.statusText,headers:{...e.additionalHeaders,"content-type":"application/problem+json"}})};static setProblemResponseFormat(e){e&&(t.problemResponseFormat=(n,r,o)=>{try{return e(n,r,o)}catch(s){throw new L("Error in custom 'problemResponseFormat'",{cause:s})}})}},Le=class{static{i(this,"ProblemResponseFormatter")}static async format(e,n,r){return await ft.problemResponseFormat(e,n,r)}};function Bt(t){for(let e in t){let n=t[e];n&&typeof n=="object"&&Bt(n)}return Object.freeze(t)}i(Bt,"deepFreeze");var z=class t extends Request{static{i(this,"ZuploRequest")}#e=void 0;#t;constructor(e,n){super(e,n);let r=n?.params;r?this.#t=r:e instanceof t?this.#t=e.#t:this.#t={};let o=n?.user;o?this.user=o:e instanceof t&&(this.user=e.user)}get query(){if(this.#e===void 0){let e={},n=new URL(this.url).searchParams;for(let[r,o]of n.entries())e[r]=o;this.#e=e}return Bt(this.#e)}get params(){return Bt(this.#t)}user};var Ze=class{static{i(this,"RuntimePlugin")}},xe=class extends Ze{static{i(this,"SystemRuntimePlugin")}async initialize(e){return Promise.resolve()}registerRoutes(e,n){}},ht={},_e=[],ki=[],Mi=[],Di=[];var zt={addPlugin(t){_e.push(t)},addRequestHook(t){ki.push(t)},addResponseSendingHook(t){Mi.push(t)},addResponseSendingFinalHook(t){Di.push(t)}},Ui=i(async(t,e)=>{let n=t;for(let r of ki){let o=await r(n,e);if(o instanceof z)n=o;else{if(o instanceof Response)return o;throw new y(`Invalid state - the OnRequest hook must return a ZuploRequest or Response. Received ${typeof n}.`)}}return n},"invokeOnRequestExtensions"),Hi=i(async(t,e,n)=>{let r=t;for(let o of Mi){let s=await o(t,e,n);if(s instanceof Response)r=s;else throw new y(`Invalid state - the OnResponseSending hook must return a Response. Received ${typeof r}.`)}return r},"invokeOnResponseSendingExtensions"),Zi=i(async(t,e,n)=>{for(let r of Di)await r(t,e,n)},"invokeOnResponseSendingFinalExtensions");async function qi(t=()=>Promise.resolve()){await t(zt),ht.value=zt;for(let e of _e)e instanceof xe&&await e.initialize(zt);ft.setProblemResponseFormat(zt.problemResponseFormat)}i(qi,"initializeRuntime");var jt={Json:"application/json",Form:"application/x-www-form-urlencoded"};function Vt(t,e){if(t!==null)return e&&typeof t=="string"?t:typeof t=="object"&&e?.startsWith(jt.Form)?new URLSearchParams(t).toString():typeof t=="object"&&e?.startsWith(jt.Json)||!e?JSON.stringify(t):t}i(Vt,"serialize");function yt(t){return X.instance.runtimeSettings.developerPortal.enabled&&t.pathname.startsWith(X.instance.runtimeSettings.developerPortal.sitePathname)||t.pathname.startsWith("/__zuplo/")||t.pathname.startsWith("/__/zuplo/")}i(yt,"isSystemRoute");var J=class{static{i(this,"Pipeline")}constructor(e){this.execute=this.#t(e)}execute;#e=(e,n)=>async(r,o)=>{try{return await e(r,o)}catch(s){return o.log.error("Error executing request handler.",s),n.errorHandler(r,o,s)}};#t=({processors:e,gateway:n,handler:r})=>async(o,s)=>{let a=[...e],u=i(async b=>{let v=a.pop();return v?v(o,s,n,u):await this.#e(async f=>{let I=await r(f,s);return Nc(I)},n)(b,s)},"nextPipe"),l=await u(o),d=new URL(o.url);if(yt(d)&&E.instance.build.COMPATIBILITY_FLAGS.doNotRunHooksOnSystemRoutes)return l;let p=new Ke(o,l);s.dispatchEvent(p);let m=ne.getContextExtensions(s),g=m.latestRequest,R;try{R=await p.mutableResponse}catch(b){return s.log.error(b),n.errorHandler(o,s,b)}try{R=await m.onResponseSending(R,g,s)}catch(b){return s.log.error(`Error invoking 'context.onResponseSending' hook: '${b.message}'`,b),n.errorHandler(o,s,b)}try{R=await Hi(R,g,s)}catch(b){return s.log.error(`Error invoking 'context.onResponseSending' hook: '${b.message}'`,b),n.errorHandler(o,s,b)}s.dispatchEvent(new Je(o,R));try{await m.onResponseSendingFinal(l,g,s)}catch(b){throw s.log.error(`Error invoking 'runtime.onResponseSending' hook: '${b.message}'`,b),b}try{await Zi(l,g,s)}catch(b){throw s.log.error(`Error invoking 'runtime.onResponseSending' hook: '${b.message}'`,b),b}return R}};function Nc(t){return t instanceof Response?t:typeof t>"u"?new Response:new Response(Vt(t),{headers:{"content-type":"application/json"}})}i(Nc,"resultToResponse");var Ne=class extends Ze{static{i(this,"MetricsPlugin")}};var F=class t{static{i(this,"SystemLogMap")}static#e=new WeakMap;static getLogger(e){let n=t.#e.get(e);if(!n){let r=`No system logger found for context with requestId '${e.requestId}'`;throw console.error(r),new $(r)}return n}static addLogger(e,n){t.#e.set(e,n)}};var q=class{static{i(this,"BatchDispatch")}constructor(e,n,r,o){this.#t=e,this.#i=n,this.#r=r,this.#n=o??console}#e=void 0;#t;#n;#r;#o=[];#i;enqueue=e=>{this.#o.push(e),this.#e||(this.#e=new Promise(n=>{setTimeout(()=>{if(this.#o.length>0){let r=[...this.#o];this.#o.length=0,this.#e=void 0,this.#r(r).catch(o=>{this.#n.error(`Uncaught error in BatchDispatcher named '${this.#t}'}`,o.message,o.stack)}).finally(()=>{n()})}},this.#i)}))};waitUntilFlushed=async()=>{if(this.#e)return this.#e}};var Gt=class{static{i(this,"EllieMetricsTransport")}#e;#t;#n;constructor(e){this.#n=E.instance.loggingId,this.#e=e,this.#t=new q("ellie-metrics-transport",10,this.dispatchFunction,F.getLogger(e))}pushMetrics(e,n){this.#n!==void 0&&(this.#t.enqueue(e),n.waitUntil(this.#t.waitUntilFlushed()))}dispatchFunction=async e=>{if(e.length===0)return;let n,{loggingId:r,remoteLogURL:o,deploymentName:s}=E.instance,a=e.map(u=>{let c=Object.assign({},u);return delete c.requestContentLength,delete c.responseContentLength,c});if(r&&s&&(n=`${o}/v1-alpha/metrics?loggingId=${encodeURI(r)}&deploymentName=${encodeURI(s)}`),n){let u=await fetch(n,{method:"POST",body:JSON.stringify(a),headers:{"content-type":"application/json","zp-dn":E.instance.deploymentName??"unknown","user-agent":E.instance.systemUserAgent}});if(!u.ok){let c=await u.text();F.getLogger(this.#e).error(`Metrics POST responded ${u.status}: ${u.statusText}`,c)}}}};var K=class{static{i(this,"SystemRouteConfiguration")}constructor({label:e,path:n,methods:r,systemRouteName:o,corsPolicy:s="none"}){this.label=e,this.path=n,this.methods=r,this.corsPolicy=s,this.version=bt.name,this.handler={export:"SYSTEM_IGNORED",module:"SYSTEM_IGNORED"},this.systemRouteName=o}label;path;methods;handler;corsPolicy;version;policies;systemRouteName;raw(){return{}}},bt={name:"__system-no-version",pathPrefix:""};var re=i(async(t,e,n,r)=>{let o=new Date,s=Date.now(),a=await r(t),u=t.headers.get(Ue)??void 0,c=t.headers.get(di)??void 0,l=e.incomingRequestProperties,d;e.route instanceof K&&(d=e.route.systemRouteName);let p=ne.getContextExtensions(e).latestRequest,m={timestamp:o,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:u,instanceId:n.instanceId,userSub:p.user?.sub,clientIp:c},g=[];return g.push(new Gt(e)),_e.forEach(R=>{if(R instanceof Ne){let b=R.getTransport();g.push(b)}}),g.forEach(R=>{R.pushMetrics(m,e)}),a},"metricsProcessor");var Re=(c=>(c.Build="build-data",c.CorsPreflight="cors-preflight",c.DeveloperPortal="developer-portal",c.DeveloperPortalLegacy="developer-portal-legacy",c.StripePlugin="stripe-plugin",c.EmptyGatewayCatchall="empty-gateway-catchall",c.Ping="ping",c.UnmatchedPath="unmatched-path",c))(Re||{});var Ar=i((t,e)=>{let n=i(async(s,a)=>{let c=new URL(s.url).hostname.toLowerCase();if(!c.endsWith(".zuplo.app")&&!c.endsWith(".zuplo.dev")&&!c.endsWith(".fly.dev")&&!c.endsWith("zuplotest.com")&&c!=="localhost")return T.notFound(s,a);let l=E.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"&&F.getLogger(a).error("Test System Log",d),new Response(JSON.stringify(d,null,2),{status:200,headers:{"content-type":"application/json"}})},"buildRouteHandler"),r=new J({processors:[re],handler:n,gateway:e}),o=new K({label:"SYSTEM_BUILD_ROUTE",methods:["GET"],path:"/__zuplo/build",systemRouteName:"build-data"});t.addRoute(o,r.execute)},"registerBuildRoute");var Wt=(P=>(P[P.CONTINUE=100]="CONTINUE",P[P.SWITCHING_PROTOCOLS=101]="SWITCHING_PROTOCOLS",P[P.PROCESSING=102]="PROCESSING",P[P.EARLY_HINTS=103]="EARLY_HINTS",P[P.OK=200]="OK",P[P.CREATED=201]="CREATED",P[P.ACCEPTED=202]="ACCEPTED",P[P.NON_AUTHORITATIVE_INFORMATION=203]="NON_AUTHORITATIVE_INFORMATION",P[P.NO_CONTENT=204]="NO_CONTENT",P[P.RESET_CONTENT=205]="RESET_CONTENT",P[P.PARTIAL_CONTENT=206]="PARTIAL_CONTENT",P[P.MULTI_STATUS=207]="MULTI_STATUS",P[P.ALREADY_REPORTED=208]="ALREADY_REPORTED",P[P.IM_USED=226]="IM_USED",P[P.MULTIPLE_CHOICES=300]="MULTIPLE_CHOICES",P[P.MOVED_PERMANENTLY=301]="MOVED_PERMANENTLY",P[P.FOUND=302]="FOUND",P[P.SEE_OTHER=303]="SEE_OTHER",P[P.NOT_MODIFIED=304]="NOT_MODIFIED",P[P.USE_PROXY=305]="USE_PROXY",P[P.SWITCH_PROXY=306]="SWITCH_PROXY",P[P.TEMPORARY_REDIRECT=307]="TEMPORARY_REDIRECT",P[P.PERMANENT_REDIRECT=308]="PERMANENT_REDIRECT",P[P.BAD_REQUEST=400]="BAD_REQUEST",P[P.UNAUTHORIZED=401]="UNAUTHORIZED",P[P.PAYMENT_REQUIRED=402]="PAYMENT_REQUIRED",P[P.FORBIDDEN=403]="FORBIDDEN",P[P.NOT_FOUND=404]="NOT_FOUND",P[P.METHOD_NOT_ALLOWED=405]="METHOD_NOT_ALLOWED",P[P.NOT_ACCEPTABLE=406]="NOT_ACCEPTABLE",P[P.PROXY_AUTHENTICATION_REQUIRED=407]="PROXY_AUTHENTICATION_REQUIRED",P[P.REQUEST_TIMEOUT=408]="REQUEST_TIMEOUT",P[P.CONFLICT=409]="CONFLICT",P[P.GONE=410]="GONE",P[P.LENGTH_REQUIRED=411]="LENGTH_REQUIRED",P[P.PRECONDITION_FAILED=412]="PRECONDITION_FAILED",P[P.CONTENT_TOO_LARGE=413]="CONTENT_TOO_LARGE",P[P.PAYLOAD_TOO_LARGE=413]="PAYLOAD_TOO_LARGE",P[P.URI_TOO_LONG=414]="URI_TOO_LONG",P[P.UNSUPPORTED_MEDIA_TYPE=415]="UNSUPPORTED_MEDIA_TYPE",P[P.RANGE_NOT_SATISFIABLE=416]="RANGE_NOT_SATISFIABLE",P[P.EXPECTATION_FAILED=417]="EXPECTATION_FAILED",P[P.I_AM_A_TEAPOT=418]="I_AM_A_TEAPOT",P[P.MISDIRECTED_REQUEST=421]="MISDIRECTED_REQUEST",P[P.UNPROCESSABLE_ENTITY=422]="UNPROCESSABLE_ENTITY",P[P.UNPROCESSABLE_CONTENT=422]="UNPROCESSABLE_CONTENT",P[P.LOCKED=423]="LOCKED",P[P.FAILED_DEPENDENCY=424]="FAILED_DEPENDENCY",P[P.TOO_EARLY=425]="TOO_EARLY",P[P.UPGRADE_REQUIRED=426]="UPGRADE_REQUIRED",P[P.PRECONDITION_REQUIRED=428]="PRECONDITION_REQUIRED",P[P.TOO_MANY_REQUESTS=429]="TOO_MANY_REQUESTS",P[P.REQUEST_HEADER_FIELDS_TOO_LARGE=431]="REQUEST_HEADER_FIELDS_TOO_LARGE",P[P.UNAVAILABLE_FOR_LEGAL_REASONS=451]="UNAVAILABLE_FOR_LEGAL_REASONS",P[P.INTERNAL_SERVER_ERROR=500]="INTERNAL_SERVER_ERROR",P[P.NOT_IMPLEMENTED=501]="NOT_IMPLEMENTED",P[P.BAD_GATEWAY=502]="BAD_GATEWAY",P[P.SERVICE_UNAVAILABLE=503]="SERVICE_UNAVAILABLE",P[P.GATEWAY_TIMEOUT=504]="GATEWAY_TIMEOUT",P[P.HTTP_VERSION_NOT_SUPPORTED=505]="HTTP_VERSION_NOT_SUPPORTED",P[P.VARIANT_ALSO_NEGOTIATES=506]="VARIANT_ALSO_NEGOTIATES",P[P.INSUFFICIENT_STORAGE=507]="INSUFFICIENT_STORAGE",P[P.LOOP_DETECTED=508]="LOOP_DETECTED",P[P.NOT_EXTENDED=510]="NOT_EXTENDED",P[P.NETWORK_AUTHENTICATION_REQUIRED=511]="NETWORK_AUTHENTICATION_REQUIRED",P))(Wt||{}),$i={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 kc={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"},Kt=kc;function Mc(t){return`${new URL(t.url).pathname}`}i(Mc,"instance");function Dc(t,e){let n={timestamp:new Date().toISOString(),requestId:e.requestId,buildId:E.instance.build.BUILD_ID},r=t.headers.get(Ue);return r&&(n.rayId=r),n}i(Dc,"trace");var Uc=i((t,e,n,r,o)=>({problem:{type:t.type,title:t.title,status:t.status,detail:t.detail,instance:Mc(e),trace:Dc(e,n),...r},additionalHeaders:o,statusText:Kt[t.status]}),"merge"),Lr=class{static{i(this,"HttpProblemsBase")}static format=(e,n,r)=>"problem"in e?Le.format(e,n,r):Le.format({problem:e},n,r);static getProblemFromStatus(e,n){return{type:`https://httpproblems.com/http-status/${e}`,status:e,title:$i[e],...n}}},T=class extends Lr{static{i(this,"HttpProblems")}static#e(e,n,r,o,s){let a=Uc(this.getProblemFromStatus(e),n,r,o,s);return Le.format(a,n,r)}static continue=(e,n,r,o)=>this.#e(200,e,n,r,o);static switchingProtocols=(e,n,r,o)=>this.#e(101,e,n,r,o);static processing=(e,n,r,o)=>this.#e(102,e,n,r,o);static earlyHints=(e,n,r,o)=>this.#e(103,e,n,r,o);static ok=(e,n,r,o)=>this.#e(200,e,n,r,o);static created=(e,n,r,o)=>this.#e(201,e,n,r,o);static accepted=(e,n,r,o)=>this.#e(202,e,n,r,o);static nonAuthoritativeInformation=(e,n,r,o)=>this.#e(203,e,n,r,o);static noContent=(e,n,r,o)=>this.#e(204,e,n,r,o);static resetContent=(e,n,r,o)=>this.#e(205,e,n,r,o);static partialContent=(e,n,r,o)=>this.#e(206,e,n,r,o);static multiStatus=(e,n,r,o)=>this.#e(207,e,n,r,o);static alreadyReported=(e,n,r,o)=>this.#e(208,e,n,r,o);static imUsed=(e,n,r,o)=>this.#e(226,e,n,r,o);static multipleChoices=(e,n,r,o)=>this.#e(300,e,n,r,o);static movedPermanently=(e,n,r,o)=>this.#e(301,e,n,r,o);static found=(e,n,r,o)=>this.#e(302,e,n,r,o);static seeOther=(e,n,r,o)=>this.#e(303,e,n,r,o);static notModified=(e,n,r,o)=>this.#e(304,e,n,r,o);static useProxy=(e,n,r,o)=>this.#e(305,e,n,r,o);static switchProxy=(e,n,r,o)=>this.#e(306,e,n,r,o);static temporaryRedirect=(e,n,r,o)=>this.#e(307,e,n,r,o);static permanentRedirect=(e,n,r,o)=>this.#e(308,e,n,r,o);static badRequest=(e,n,r,o)=>this.#e(400,e,n,r,o);static unauthorized=(e,n,r,o)=>this.#e(401,e,n,r,o);static paymentRequired=(e,n,r,o)=>this.#e(402,e,n,r,o);static forbidden=(e,n,r,o)=>this.#e(403,e,n,r,o);static notFound=(e,n,r,o)=>this.#e(404,e,n,r,o);static methodNotAllowed=(e,n,r,o)=>this.#e(405,e,n,r,o);static notAcceptable=(e,n,r,o)=>this.#e(406,e,n,r,o);static proxyAuthenticationRequired=(e,n,r,o)=>this.#e(407,e,n,r,o);static requestTimeout=(e,n,r,o)=>this.#e(408,e,n,r,o);static conflict=(e,n,r,o)=>this.#e(409,e,n,r,o);static gone=(e,n,r,o)=>this.#e(410,e,n,r,o);static lengthRequired=(e,n,r,o)=>this.#e(411,e,n,r,o);static preconditionFailed=(e,n,r,o)=>this.#e(412,e,n,r,o);static contentTooLarge=(e,n,r,o)=>this.#e(413,e,n,r,o);static uriTooLong=(e,n,r,o)=>this.#e(414,e,n,r,o);static unsupportedMediaType=(e,n,r,o)=>this.#e(415,e,n,r,o);static rangeNotSatisfiable=(e,n,r,o)=>this.#e(416,e,n,r,o);static expectationFailed=(e,n,r,o)=>this.#e(417,e,n,r,o);static imATeapot=(e,n,r,o)=>this.#e(418,e,n,r,o);static misdirectedRequest=(e,n,r,o)=>this.#e(421,e,n,r,o);static unprocessableContent=(e,n,r,o)=>this.#e(422,e,n,r,o);static locked=(e,n,r,o)=>this.#e(423,e,n,r,o);static failedDependency=(e,n,r,o)=>this.#e(424,e,n,r,o);static tooEarly=(e,n,r,o)=>this.#e(425,e,n,r,o);static upgradeRequired=(e,n,r,o)=>this.#e(426,e,n,r,o);static preconditionRequired=(e,n,r,o)=>this.#e(428,e,n,r,o);static tooManyRequests=(e,n,r,o)=>this.#e(429,e,n,r,o);static requestHeaderFieldsTooLarge=(e,n,r,o)=>this.#e(431,e,n,r,o);static unavailableForLegalReasons=(e,n,r,o)=>this.#e(451,e,n,r,o);static internalServerError=(e,n,r,o)=>this.#e(500,e,n,r,o);static notImplemented=(e,n,r,o)=>this.#e(501,e,n,r,o);static badGateway=(e,n,r,o)=>this.#e(502,e,n,r,o);static serviceUnavailable=(e,n,r,o)=>this.#e(503,e,n,r,o);static gatewayTimeout=(e,n,r,o)=>this.#e(504,e,n,r,o);static httpVersionNotSupported=(e,n,r,o)=>this.#e(505,e,n,r,o);static variantAlsoNegotiates=(e,n,r,o)=>this.#e(506,e,n,r,o);static insufficientStorage=(e,n,r,o)=>this.#e(507,e,n,r,o);static loopDetected=(e,n,r,o)=>this.#e(508,e,n,r,o);static notExtended=(e,n,r,o)=>this.#e(510,e,n,r,o);static networkAuthenticationRequired=(e,n,r,o)=>this.#e(511,e,n,r,o)};var{toString:Hc}=Object.prototype,{propertyIsEnumerable:Zc}=Object.prototype;function _r(t){return Hc.call(t)}i(_r,"toString");function ae(t){return typeof t=="string"}i(ae,"isString");function Ye(t){return ae(t)&&t!==""}i(Ye,"isNonEmptyString");function Fi(t){return _r(t)==="[object RegExp]"}i(Fi,"isRegexp");function Bi(t){return[...Object.keys(t),...Object.getOwnPropertySymbols(t).filter(e=>Zc.call(t,e))]}i(Bi,"getOwnEnumerableKeys");function qe(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)&&!(t instanceof RegExp)&&!(t instanceof Date)}i(qe,"isObject");function Nr(t){return typeof t=="number"&&!isNaN(t)}i(Nr,"isNumber");function kr(t){return t===!0||t===!1}i(kr,"isBoolean");function zi(t){return typeof t>"u"}i(zi,"isUndefined");function ji(t){return zi(t)||t===null}i(ji,"isUndefinedOrNull");function wt(t){return!!t&&typeof t=="object"&&"name"in t&&"message"in t&&"stack"in t}i(wt,"isErrorLike");var Vi=new Map;function Qe(t){if(Array.isArray(t)&&!t.some(o=>typeof o!="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=Vi.get(t);if(e)return e;let n=t.split(","),r=[];for(let o of n){let s=o.split("-");if(s.length===2){let a=parseInt(s[0],10),u=parseInt(s[1],10);for(let c=a;c<=u;c++)r.push(c)}else r.push(parseInt(o,10))}return Vi.set(t,r),r}i(Qe,"statusCodesStringToNumberArray");function $e(t,e,n){if(!e.startsWith("."))throw new y(`Invalid ${n} - must start with '.' - '${e}' does not`);let r=e.split(".").splice(1),o=t;return r.forEach(s=>{if(o===void 0)throw new L(`Error applying ${n} '${e}', reading '${s}'`);o=o[s]}),`${o}`}i($e,"getValueFromRequestUser");function Fe(t){if(Array.isArray(t)){if(t.includes(n=>typeof n!="string"))throw new y("Received an array that contains non-string values.");return t}if(ae(t))return t.includes(",")?t.split(",").map(n=>n.trim()).filter(n=>n!==","&&n!==""):[t];throw new y(`Expected type of string, received type '${typeof t}'`)}i(Fe,"parseValueToStringArray");function Gi(t){if(t==null)return[];if(!Array.isArray(t))throw new y(`Invalid corsPolicy configuration. Expected an array of objects, received '${typeof t}'`);return t.map(n=>{if(!qe(n))throw new y(`Invalid custom cors policy is set. Expected an object, received '${typeof n}'`);if(!Ye(n.name))throw new y("Value of 'name' on custom cors policies must be a non-empty string.");if(n.maxAge!==void 0&&!Nr(n.maxAge))throw new y(`Value of 'maxAge' on custom cors policies must be a non-empty string. Received type '${typeof n.maxAge}'`);if(n.allowCredentials!==void 0&&!kr(n.allowCredentials))throw new y("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 r=Mr(n,"allowedHeaders"),o=Mr(n,"allowedMethods"),s=Mr(n,"exposeHeaders"),a;try{a=Fe(n.allowedOrigins)}catch(c){throw new y(`Value of 'allowedOrigins' on custom cors policies is invalid. ${c.message} If using an environment variable, check that it is set correctly.`)}return{name:n.name,allowCredentials:typeof n.allowCredentials=="boolean"?String(n.allowCredentials):void 0,allowedOrigins:a,allowedHeaders:r?r.join(", "):void 0,allowedMethods:o?o.join(", "):void 0,exposeHeaders:s?s.join(", "):void 0,maxAge:typeof n.maxAge=="number"?n.maxAge.toString():void 0}})}i(Gi,"parseCorsPolicies");function Mr(t,e){let n;if(t[e]!==void 0)try{n=Fe(t[e])}catch(r){throw new y(`Value of '${e}' on custom cors policies is invalid. ${r.message} If using an environment variable, check that it is set correctly.`)}return n}i(Mr,"parseOptionalProperty");var Jt=i((t,e)=>{if(e===null)return;if(t.find(a=>a==="*"))return e;let r=t.map(a=>a.trim().toLowerCase()),o=e.toLowerCase();return r.find(a=>a===o)},"findMatchingOrigin"),Yt=i((t,e)=>{let n={"access-control-allow-origin":e};t.allowedHeaders&&(n["access-control-allow-headers"]=t.allowedHeaders),t.allowedMethods&&(n["access-control-allow-methods"]=t.allowedMethods),t.exposeHeaders&&(n["access-control-expose-headers"]=t.exposeHeaders);let r=t.allowCredentials;r&&(n["access-control-allow-credentials"]=r);let o=t.maxAge?.toString()??void 0;return o&&(n["access-control-max-age"]=o),n},"generateCorsHeaders");var Dr=i((t,e)=>{let n=e.routeData.corsPolicies,r=i(async(a,u)=>{let c=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 T.badRequest(a,u,{detail:"Expect headers origin and access-control-request-method"});let m=t.lookup(l,c);if(!m)return T.notFound(a,u);let g=m.routeConfiguration,R=qc(l,d,p,g,n);return R.isValid?new Response(void 0,{status:200,statusText:"OK",headers:R.headers}):(R.error&&u.log.warn(R.error),T.notFound(a,u))},"optionsHandler"),o=new J({processors:[re],handler:r,gateway:e}),s=new K({label:"SYSTEM_CORS_ROUTE",methods:["OPTIONS"],path:"/(.*)",systemRouteName:"cors-preflight"});t.addRoute(s,o.execute)},"registerCorsRoute"),qc=i((t,e,n,r,o)=>{let s={isValid:!1,headers:{}};if(r.corsPolicy==="anything-goes")return{isValid:!0,headers:{"access-control-allow-origin":n,"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(r.corsPolicy==="none")return{...s,error:`No CORS policy set for the route '${r.pathPattern}'`};let a=o?.find(l=>l.name===r.corsPolicy);if(!a)throw new y(`Invalid Configuration - corsPolicy '${r.corsPolicy}' not found in *.oas.json 'corsPolicies' section.`);let u=Jt(a.allowedOrigins,n);return u?{isValid:!0,headers:Yt(a,u)}:{...s,error:`The CORS policy '${a.name}' does not allow the origin '${n}'`}},"validateAndBuildResponseHeaders");var Wi=i((t,e)=>{let n=i(async()=>new Response("You have no routes. Add a route in routes.oas.json to get started",{status:200}),"noRoutesHandler"),r=new J({processors:[re],handler:n,gateway:e}),o=new K({label:"SYSTEM_NO_ROUTES",methods:["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"],path:"/(.*)",systemRouteName:"empty-gateway-catchall"});t.addRoute(o,r.execute)},"registerNoRoutes");var Ur=new K({label:"SYSTEM_NOT_FOUND_ROUTE",methods:["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"],path:"/(.*)",systemRouteName:"unmatched-path"}),Ki=i((t,e)=>{let n=i(async(o,s)=>{let a=ht.value?.notFoundHandler;if(a){let u=ne.getContextExtensions(s);return a(o,s,{routesMatchedByPathOnly:u.pathOnlyMatches??[]})}return T.notFound(o,s)},"notFoundHandler"),r=new J({processors:[re],handler:n,gateway:e});t.addRoute(Ur,r.execute)},"registerNotMatchedHandler");var $c=["access-control-allow-origin","access-control-allow-headers","access-control-expose-headers","access-control-allow-credentials","access-control-max-age"],Ji=i(t=>{$c.forEach(e=>t.delete(e))},"stripCorsHeaders"),Qt=i(async(t,e,n,r)=>{let o=e.route;if(!o.corsPolicy||o.corsPolicy==="none"){let d=await r(t),p=new Headers(d.headers);return Ji(p),new Response(d.body,{status:d.status,statusText:d.statusText,headers:p,webSocket:d.webSocket})}let s=await r(t);if(!(s instanceof Response))throw new $(`The CorsProcessor is in the wrong place in the pipeline. It should only receive HttpResponse type but got '${typeof s}'`);let a=Fc(o,n.routeData.corsPolicies),u=Bc(t,a),c=new Headers(s.headers);return Ji(c),Object.entries(u).forEach(([d,p])=>{c.set(d,p)}),new Response(s.body,{status:s.status,statusText:s.statusText,headers:c,webSocket:s.webSocket})},"corsProcessor"),Fc=i((t,e)=>{if(t.corsPolicy==="anything-goes")return{name:"anything-goes",allowedHeaders:"*",allowedOrigins:["*"],allowedMethods:t.methods.join(", "),exposeHeaders:"*",allowCredentials:"true",maxAge:"600"};let n=e?.find(r=>r.name===t.corsPolicy);if(n===void 0)throw new y(`Invalid Configuration - no corsPolicy '${t.corsPolicy}' found in *.oas.json`);return n},"getCorsPolicy"),Bc=i((t,e)=>{let n=Jt(e.allowedOrigins,t.headers.get("origin"));return n?Yt(e,n):{}},"getCorsHeaders");var Hr=i((t,e)=>{let n=i(async()=>new Response(null,{status:200}),"pingRouteHandler"),r=new J({processors:[Qt],handler:n,gateway:e}),o=new K({corsPolicy:"anything-goes",label:"SYSTEM_PING_ROUTE",methods:["GET"],path:"/__zuplo/ping",systemRouteName:"ping"});t.addRoute(o,r.execute)},"registerPingRoute");var Xt=class{static{i(this,"PolicyBase")}options;policyName;constructor(e,n){if(!ae(n))throw new L(`The name of a policy must be a string. Received '${n}' of type '${typeof n}'`);this.options=e,this.policyName=n}},ge=class extends Xt{static{i(this,"InboundPolicy")}},ve=class extends Xt{static{i(this,"OutboundPolicy")}};var $r=class extends ge{static{i(this,"InboundFunctionOnlyPolicy")}#e;constructor(e,n,r){super(n,r),this.#e=e}handler(e,n){return this.#e(e,n,this.options,this.policyName)}},Fr=class extends ve{static{i(this,"OutboundFunctionOnlyPolicy")}#e;constructor(e,n,r){super(n,r),this.#e=e}handler(e,n,r){return this.#e(e,n,r,this.options,this.policyName)}},Zr=new Map;function Rt(t,e){let n,r;return Array.isArray(t)?n=t:(n=t.policies?.inbound??[],r=t.path),n.filter(s=>!Zr.has(s)).forEach(s=>{let a=e?.find(l=>l.name===s);if(!a)throw new y(`Invalid state - no Policy with the name '${s}' ${r&&`on route '${r}'`} was found in the policies configuration (check case).`);if(typeof a.handler?.module!="object")throw new y(`Invalid state - invalid policy '${s}' on route '${r}' (typeof policy '${typeof a.handler?.module}')`);let u=a.handler?.module[a.handler.export];if(typeof u!="function")throw new y(`Invalid state - invalid policy '${s}' on route '${r}' (typeof module '${typeof u}')`);let c;if(typeof u!="function")throw new y(`Invalid state - invalid policy '${s}' on route '${r}' (typeof module '${typeof u}')`);if(u.prototype instanceof ge)c=new u(a.handler.options,a.name);else if(typeof u=="function")c=new $r(u,a.handler.options,a.name);else throw new y(`Invalid state - invalid policy '${s}' on route '${r}' (typeof policy '${typeof u}')`);if(typeof c.handler!="function")throw new y(`Invalid state - invalid handler on policy '${s}' on route '${r}' (typeof handler '${typeof c.handler}')`);Zr.set(a.name,c)}),n.map(s=>{let a=Zr.get(s);if(a===void 0)throw new L("Internal error. Policy not found in cache.");return a})}i(Rt,"getInboundPolicyInstances");var qr=new Map;function zc(t,e){let n=t.policies?.outbound??[];return n.filter(o=>!qr.has(o)).forEach(o=>{let s=e?.find(c=>c.name===o);if(!s)throw new y(`Invalid state - no Policy with the name '${o}' on route '${t.path}' was found in the policies configuration (check case).`);if(typeof s.handler?.module!="object")throw new y(`Invalid state - invalid policy '${o}' on route '${t.path}' (typeof policy '${typeof s.handler?.module}')`);let a=s.handler?.module[s.handler.export],u;if(typeof a!="function")throw new y(`Invalid state - invalid policy '${o}' on route '${t.path}' (typeof module '${typeof a}')`);if(a.prototype instanceof ve)u=new a(s.handler.options??{},s.name);else if(typeof a=="function")u=new Fr(a,s.handler.options??{},s.name);else throw new y(`Invalid state - invalid policy '${o}' on route '${t.path}' (typeof policy '${typeof a}')`);if(typeof u.handler!="function")throw new y(`Invalid state - invalid handler on policy '${o}' on route '${t.path}'`);qr.set(s.name,u)}),n.map(o=>{let s=qr.get(o);if(s===void 0)throw new L("Internal error. Policy not found in cache.");return s})}i(zc,"getOutboundPolicyInstances");var Br=i(t=>async(e,n)=>{let r=ne.getContextExtensions(n),o=[...t],s=e;for(;o.length>0;){let a=o.shift();if(!a)return s;let u=await a.handler(s,n);if(u instanceof z)s=u;else if(u instanceof Request)s=new z(u);else{if(u instanceof Response)return u;throw new y(`Invalid state - invalid handler on policy '${a.policyName}' on route '${n.route.path}. The result of an inbound policy must be a Response or Request.`)}r.latestRequest=s}return s},"toStackedInboundHandler"),jc=i(t=>async(e,n,r)=>{let o=[...t],s=e;for(;o.length>0;){let a=o.shift();if(!a)return s;let u=await a.handler(s,n,r);if(!(u instanceof Response))throw new y(`Invalid state - invalid handler on policy '${a.policyName}' on route '${r.route.path}. The result of an outbound policy must be a Response.`);s=u}return s},"toStackedOutboundHandler"),en=i(async(t,e,n,r)=>{let o=Rt(e.route,n.routeData.policies),s=zc(e.route,n.routeData.policies);return Qi({request:t,context:e,inboundPolicies:o,outboundPolicies:s,gateway:n,next:r})},"policyProcessor");function Yi({inboundPolicies:t=[],outboundPolicies:e=[]}){return i(async(r,o,s,a)=>Qi({request:r,context:o,inboundPolicies:t,outboundPolicies:e,gateway:s,next:a}),"policyProcessor")}i(Yi,"createInternalPolicyProcessor");async function Qi({request:t,context:e,inboundPolicies:n,outboundPolicies:r,gateway:o,next:s}){let a=Br(n);try{let u=await a(t,e);if(u instanceof Response)return u;let c=await s(u),l=jc(r),d;return E.instance.build.COMPATIBILITY_FLAGS.runOutboundPoliciesOnHandlerOnAllStatuses?d=l(c,t,e):d=c.ok?l(c,t,e):c,d}catch(u){return e.log.error(u),o.errorHandler(t,e,u)}}i(Qi,"executePolicyProcessor");function Xi(t,e){if(typeof t!="string")throw new TypeError("argument str must be a string");let n={},o=(e||{}).decode||Vc,s=0;for(;s<t.length;){let a=t.indexOf("=",s);if(a===-1)break;let u=t.indexOf(";",s);if(u===-1)u=t.length;else if(u<a){s=t.lastIndexOf(";",a-1)+1;continue}let c=t.slice(s,a).trim();if(n[c]===void 0){let l=t.slice(a+1,u).trim();l.charCodeAt(0)===34&&(l=l.slice(1,-1)),n[c]=Gc(l,o)}s=u+1}return n}i(Xi,"parse");function Vc(t){return t.indexOf("%")!==-1?decodeURIComponent(t):t}i(Vc,"decode");function Gc(t,e){try{return e(t)}catch{return t}}i(Gc,"tryDecode");function es(t,e){try{let n=/v\d+(-\d+)?/g,o=Xi(e.get("Cookie")||"")["zp-dev-portal"];return o!==null&&o&&n.test(o)?`https://dev-portal-${o}.zuplo.com`:t}catch{}return t}i(es,"devPortalBaseURL");var ts="/__zuplo/dev-portal",Wc="dev-portal-id",Kc="dev-portal-host",Jc="zp-account",Yc="zp-project",Qc="dev-portal-build",Xc=`
41
+ `):(this.indentate=function(){return""},this.tagEndChar=">",this.newLine="")}i(o,"Builder"),D(o,"Builder"),o.prototype.build=function(c){return this.options.preserveOrder?n(c,this.options):(Array.isArray(c)&&this.options.arrayNodeName&&this.options.arrayNodeName.length>1&&(c={[this.options.arrayNodeName]:c}),this.j2x(c,0).val)},o.prototype.j2x=function(c,l){let d="",p="";for(let m in c)if(Object.prototype.hasOwnProperty.call(c,m))if(typeof c[m]>"u")this.isAttribute(m)&&(p+="");else if(c[m]===null)this.isAttribute(m)?p+="":m[0]==="?"?p+=this.indentate(l)+"<"+m+"?"+this.tagEndChar:p+=this.indentate(l)+"<"+m+"/"+this.tagEndChar;else if(c[m]instanceof Date)p+=this.buildTextValNode(c[m],m,"",l);else if(typeof c[m]!="object"){let g=this.isAttribute(m);if(g)d+=this.buildAttrPairStr(g,""+c[m]);else if(m===this.options.textNodeName){let R=this.options.tagValueProcessor(m,""+c[m]);p+=this.replaceEntitiesValue(R)}else p+=this.buildTextValNode(c[m],m,"",l)}else if(Array.isArray(c[m])){let g=c[m].length,R="";for(let b=0;b<g;b++){let v=c[m][b];typeof v>"u"||(v===null?m[0]==="?"?p+=this.indentate(l)+"<"+m+"?"+this.tagEndChar:p+=this.indentate(l)+"<"+m+"/"+this.tagEndChar:typeof v=="object"?this.options.oneListGroup?R+=this.j2x(v,l+1).val:R+=this.processTextOrObjNode(v,m,l):R+=this.buildTextValNode(v,m,"",l))}this.options.oneListGroup&&(R=this.buildObjectNode(R,m,"",l)),p+=R}else if(this.options.attributesGroupName&&m===this.options.attributesGroupName){let g=Object.keys(c[m]),R=g.length;for(let b=0;b<R;b++)d+=this.buildAttrPairStr(g[b],""+c[m][g[b]])}else p+=this.processTextOrObjNode(c[m],m,l);return{attrStr:d,val:p}},o.prototype.buildAttrPairStr=function(c,l){return l=this.options.attributeValueProcessor(c,""+l),l=this.replaceEntitiesValue(l),this.options.suppressBooleanAttributes&&l==="true"?" "+c:" "+c+'="'+l+'"'};function s(c,l,d){let p=this.j2x(c,d+1);return c[this.options.textNodeName]!==void 0&&Object.keys(c).length===1?this.buildTextValNode(c[this.options.textNodeName],l,p.attrStr,d):this.buildObjectNode(p.val,l,p.attrStr,d)}i(s,"processTextOrObjNode"),D(s,"processTextOrObjNode"),o.prototype.buildObjectNode=function(c,l,d,p){if(c==="")return l[0]==="?"?this.indentate(p)+"<"+l+d+"?"+this.tagEndChar:this.indentate(p)+"<"+l+d+this.closeTag(l)+this.tagEndChar;{let m="</"+l+this.tagEndChar,g="";return l[0]==="?"&&(g="?",m=""),(d||d==="")&&c.indexOf("<")===-1?this.indentate(p)+"<"+l+d+g+">"+c+m:this.options.commentPropName!==!1&&l===this.options.commentPropName&&g.length===0?this.indentate(p)+`<!--${c}-->`+this.newLine:this.indentate(p)+"<"+l+d+g+this.tagEndChar+c+this.indentate(p)+m}},o.prototype.closeTag=function(c){let l="";return this.options.unpairedTags.indexOf(c)!==-1?this.options.suppressUnpairedNode||(l="/"):this.options.suppressEmptyNode?l="/":l=`></${c}`,l},o.prototype.buildTextValNode=function(c,l,d,p){if(this.options.cdataPropName!==!1&&l===this.options.cdataPropName)return this.indentate(p)+`<![CDATA[${c}]]>`+this.newLine;if(this.options.commentPropName!==!1&&l===this.options.commentPropName)return this.indentate(p)+`<!--${c}-->`+this.newLine;if(l[0]==="?")return this.indentate(p)+"<"+l+d+"?"+this.tagEndChar;{let m=this.options.tagValueProcessor(l,c);return m=this.replaceEntitiesValue(m),m===""?this.indentate(p)+"<"+l+d+this.closeTag(l)+this.tagEndChar:this.indentate(p)+"<"+l+d+">"+m+"</"+l+this.tagEndChar}},o.prototype.replaceEntitiesValue=function(c){if(c&&c.length>0&&this.options.processEntities)for(let l=0;l<this.options.entities.length;l++){let d=this.options.entities[l];c=c.replace(d.regex,d.val)}return c};function a(c){return this.options.indentBy.repeat(c)}i(a,"indentate"),D(a,"indentate");function u(c){return c.startsWith(this.options.attributeNamePrefix)&&c!==this.options.textNodeName?c.substr(this.attrPrefixLen):!1}i(u,"isAttribute"),D(u,"isAttribute"),e.exports=o}}),Dd=hu(),Ud=Nd(),Hd=Md();yu.exports={XMLParser:Ud,XMLValidator:Dd,XMLBuilder:Hd};});var Zd={};vu(Zd,{API_KEY:()=>os,AWSLoggingPlugin:()=>xn,AmberfloMeteringInboundPolicy:()=>ea,AmberfloMeteringPolicy:()=>_n,ApiAuthKeyInboundPolicy:()=>ra,ApiKeyInboundPolicy:()=>kn,AuditLogDataStaxProvider:()=>Sn,AuditLogPlugin:()=>On,Auth0JwtInboundPolicy:()=>oa,AwsLambdaHandlerExtensions:()=>ks,BackgroundDispatcher:()=>Qn,BackgroundLoader:()=>Xn,BasicAuthInboundPolicy:()=>ia,BasicRateLimitInboundPolicy:()=>Ho,BatchDispatch:()=>q,CachingInboundPolicy:()=>sa,ChangeMethodInboundPolicy:()=>aa,ClearHeadersInboundPolicy:()=>ua,ClearHeadersOutboundPolicy:()=>ca,ClerkJwtInboundPolicy:()=>la,CognitoJwtInboundPolicy:()=>da,CompositeInboundPolicy:()=>pa,ConfigurationError:()=>y,ContentTypes:()=>jt,ContextData:()=>pe,CryptoBeta:()=>tr,CurityPhantomTokenInboundPolicy:()=>ma,DataDogLoggingPlugin:()=>cn,DataDogMetricsPlugin:()=>vn,DynaTraceLoggingPlugin:()=>Rn,DynatraceMetricsPlugin:()=>Tn,FirebaseJwtInboundPolicy:()=>ga,FormDataToJsonInboundPolicy:()=>fa,GeoFilterInboundPolicy:()=>ha,GoogleCloudLoggingPlugin:()=>sn,Handler:()=>bn,HttpProblems:()=>T,HttpStatusCode:()=>Wt,InboundPolicy:()=>ge,JWTScopeValidationInboundPolicy:()=>ya,KeyValueStore:()=>rr,LokiLoggingPlugin:()=>Pn,LookupResult:()=>et,MemoryZoneReadThroughCache:()=>Y,MockApiInboundPolicy:()=>wa,MoesifInboundPolicy:()=>va,MonetizationInboundPolicy:()=>Dn,OktaJwtInboundPolicy:()=>Aa,OpenIdJwtInboundPolicy:()=>te,OutboundPolicy:()=>ve,ProblemResponseFormatter:()=>Le,PropelAuthJwtInboundPolicy:()=>_a,RateLimitInboundPolicy:()=>Ho,ReadmeMetricsInboundPolicy:()=>qa,RemoveHeadersInboundPolicy:()=>$a,RemoveHeadersOutboundPolicy:()=>Fa,RemoveQueryParamsInboundPolicy:()=>Ba,ReplaceStringOutboundPolicy:()=>za,RequestSizeLimitInboundPolicy:()=>Va,RequestValidationInboundPolicy:()=>$o,RequireOriginInboundPolicy:()=>eu,ResponseSendingEvent:()=>Ke,ResponseSentEvent:()=>Je,Router:()=>tt,RuntimeError:()=>L,SYSTEM_LOGGER:()=>Pt,SchemaBasedRequestValidation:()=>Xa,ServiceProviderImpl:()=>Yn,SetBodyInboundPolicy:()=>tu,SetHeadersInboundPolicy:()=>nu,SetHeadersOutboundPolicy:()=>ru,SetQueryParamsInboundPolicy:()=>ou,SetStatusOutboundPolicy:()=>iu,SleepInboundPolicy:()=>su,StripeMonetizationPlugin:()=>Ao,StripeWebhookVerificationInboundPolicy:()=>st,SumoLogicLoggingPlugin:()=>En,SupabaseJwtInboundPolicy:()=>au,SystemLogMap:()=>F,SystemRouteName:()=>Re,UpstreamAzureAdServiceAuthInboundPolicy:()=>uu,UpstreamFirebaseAdminAuthInboundPolicy:()=>lu,UpstreamFirebaseUserAuthInboundPolicy:()=>du,UpstreamGcpJwtInboundPolicy:()=>pu,UpstreamGcpServiceAuthInboundPolicy:()=>gu,VMWareLogInsightLoggingPlugin:()=>In,ValidateJsonSchemaInbound:()=>fu,XmlToJsonOutboundPolicy:()=>Jn,ZoneCache:()=>Ge,ZuploRequest:()=>z,awsLambdaHandler:()=>Ms,environment:()=>oe,getIdForParameterSchema:()=>Wn,getIdForRefSchema:()=>Wa,getIdForRequestBodySchema:()=>Kn,getRawOperationDataIdentifierName:()=>Ga,httpStatuses:()=>Kt,isRestrictedEnvVariableName:()=>to,isZuploReadableEnvVariableName:()=>no,openApiSpecHandler:()=>Ds,originalFetch:()=>nt,purgeGatewayCache:()=>Is,redirectHandler:()=>Us,sanitizedIdentifierName:()=>De,serialize:()=>Vt,setMoesifContext:()=>xa,urlForwardHandler:()=>Hs,urlRewriteHandler:()=>Zs,webSocketHandler:()=>qs,webSocketPipelineHandler:()=>Bs});module.exports=Tu(Zd);var $=class extends Error{static{i(this,"SystemError")}constructor(e,n){super(e,n),this.name="InternalError"}},L=class extends Error{static{i(this,"RuntimeError")}extensionMembers;constructor(e,n){typeof e=="string"?super(e,n):(super(e.message,n),this.extensionMembers=e.extensionMembers),this.name="RuntimeError"}},y=class extends L{static{i(this,"ConfigurationError")}constructor(e,n){super(e,n),this.name="ConfigurationError"}},kt=class extends L{static{i(this,"FeatureNotEnabledError")}constructor(e,n){super(e,n),this.name="FeatureNotEnabledError"}};var E=class t{static{i(this,"Environment")}config;static#e;static initialize(e,n){this.#e||(this.#e=new t(e,n))}static get instance(){if(!this.#e)throw new $("Environment has not been initialized");return this.#e}constructor(e,n){let r;try{if(n.__ZUPLO_CONFIG){let o=atob(n.__ZUPLO_CONFIG);r=JSON.parse(o)}}catch{console.warn("Failed to parse runtime configuration")}this.config=r??{},this.build=e,this.runtime=n}build;runtime;get deploymentName(){return this.runtime.__ZUPLO_DEPLOYMENT_NAME??this.config.deployment_name??void 0}get useSha256ServiceRouting(){return this.config.use_sha256_service_routing??void 0}get useProxyForFetchFromZups(){return this.config.use_proxy_for_fetch_from_zups??void 0}get devPortalBaseUrl(){return this.runtime.__ZUPLO_DEV_PORTAL_URL??this.config.dev_portal_url??"https://dev-portal-v4-1.zuplo.com"}get buildAssetsUrl(){return this.runtime.__ZUPLO_BUILD_ASSETS_URL??this.config.build_assets_url??"https://build-assets.zuplo.com"}get remoteLogToken(){return this.runtime.__ZUPLO_REMOTE_LOG_TOKEN??this.config.remote_log_token??void 0}get managementApiURL(){return this.runtime.__ZUPLO_MANAGEMENT_API_URL??this.config.management_api_url??"https://api.zuplo.com"}get cdnURL(){return this.runtime.__ZUPLO_CDN_URL??this.config.cdn_url??"https://cdn.zuplo.com"}get remoteLogURL(){return this.runtime.__ZUPLO_REMOTE_LOG_URL??this.config.log_event_api??"https://ellie.zuplo.com"}get loggingId(){return this.runtime.__ZUPLO_LOGGING_ID??this.config.logging_id??void 0}get redisURL(){return this.runtime.__ZUPLO_REDIS_URL??this.config.redis_proxy_url??"https://redis-proxy.zuplo.com"}get apiKeyServiceUrl(){return this.runtime.__ZUPLO_API_KEY_SERVICE_URL??this.config.api_key_service_url??"https://apikey.zuplo.com"}get meteringServiceUrl(){return this.config.metering_service_url??"https://meters.zuplo.com"}get authApiJWT(){return this.runtime.__ZUPLO_AUTH_API_JWT??void 0}get userLogLevel(){return this.runtime.ZUPLO_LOG_LEVEL??this.runtime.__ZUPLO_LOG_LEVEL??this.config.user_log_level??"debug"}get systemLogLevel(){return this.runtime.__ZUPLO_LOG_LEVEL??this.config.system_log_level??"debug"}get logFormat(){return this.runtime.__ZUPLO_LOG_FORMAT??this.config.log_format??"cloudflare"}get isCloudflare(){return this.runtime.__ZUPLO_RUNTIME_TYPE?this.runtime.__ZUPLO_RUNTIME_TYPE==="cloudflare":this.config.runtime_type?this.config.runtime_type==="cloudflare":typeof WebSocketPair=="function"}get isDeno(){return this.runtime.__ZUPLO_RUNTIME_TYPE?this.runtime.__ZUPLO_RUNTIME_TYPE==="deno":this.config.runtime_type?this.config.runtime_type==="deno":typeof WebSocketPair!="function"}get isLocalDevelopment(){return this.build.ENVIRONMENT_TYPE?this.build.ENVIRONMENT_TYPE==="LOCAL_DEVELOPMENT":!1}get systemUserAgent(){return`Zuplo/${this.build.ZUPLO_VERSION}`}get loggingEnvironmentType(){return this.isCloudflare?"edge":this.isLocalDevelopment?"local":this.isDeno?"working-copy":"unknown"}get loggingEnvironmentStage(){return this.build.ENVIRONMENT_TYPE==="PRODUCTION"?"production":this.build.ENVIRONMENT_TYPE==="PREVIEW"?"preview":this.isLocalDevelopment?"local":this.isDeno?"working-copy":"unknown"}};Function.prototype.toString=function(){return"[native code]"};var Mt=globalThis,Yo=Mt.caches;if(Yo){let t=Yo.open;Mt.caches.open=function(e){let n=E.instance.deploymentName??E.instance.build.BUILD_ID;return t.call(this,`${n}-${e}`)},delete Mt.caches.default,Object.freeze(Mt.caches)}var Qo=new Map,sr=class{static{i(this,"InnerCache")}constructor(e){this.#e=e.maxSize}#e;#t=0;#n=new Map;#r=[];get(e){let n=this.#n.get(e);if(!n)return;let r=Date.now();if(r>n.expiresAt){this.#n.delete(e);return}return n.lastUsed=r,this.#o(),n?.data}put(e,n,r){if(r<=0)return;if(this.#n.size>=this.#e){let a=this.#r.shift();a&&this.#n.delete(a)}let o=Date.now(),s={created:o,lastUsed:o,expiresAt:o+r*1e3,data:n};this.#r.push(e),this.#n.set(e,s)}delete(e){let n=this.#r.indexOf(e);n>=0&&this.#r.slice(n,1),this.#n.delete(e)}get size(){return this.#n.size}#o(){let e=Date.now();this.#t+1e4*1e3>e&&(this.purge(),this.#t=e)}purge(){let e=Date.now();this.#n.forEach((n,r)=>{n.expiresAt>=e&&this.#n.delete(r)})}},Ve=class{static{i(this,"MemoryCache")}constructor(e,n={maxSize:1e3}){this.name=e;let r=Qo.get(e);r||(r=new sr(n),Qo.set(e,r)),this.#e=r}name;#e;get(e){return this.#e.get(e)}put(e,n,r){return this.#e.put(e,n,r)}delete(e){return this.#e.delete(e)}get size(){return this.#e.size}purge(){this.#e.purge()}};var ar="__zuplo-expiry-header",Ge=class{static{i(this,"ZoneCache")}constructor(e,n){this.#t=e,this.#e=n}#e;#t;#n;async#r(){return this.#n||(this.#n=await caches.open(this.#t)),this.#n}#o(e){return new Request(`https://zone-cache.zuplo.app/${encodeURIComponent(e)}`)}async get(e){try{let n=await this.#r(),r=this.#o(e),o=await n.match(r);if(!o)return;let s=o.headers.get(ar);if(!s){try{await n.delete(r)}catch(c){this.logDebug("Handled failure to delete with CF cache because of missing expiryHeader",c),await this.deleteFallback(e)}return}let a=parseInt(s);if(Date.now()>=a){try{await n.delete(r)}catch(c){this.logDebug("Handled failure to delete with CF cache because of expiration",c),await this.deleteFallback(e)}return}return await o.json()}catch(n){this.logDebug(n)}}async put(e,n,r){let o=new Headers({"cache-control":`s-maxage=${r}, must-revalidate`,"content-type":"application/json"});o.set(ar,`${Date.now()+r*1e3}`);let s=await this.#r(),a=this.#o(e),u=new Response(JSON.stringify(n),{headers:o});await s.put(a,u)}async delete(e){let n=await this.#r(),r=this.#o(e);try{await n.delete(r)}catch(o){this.logDebug("Handled failure to delete with CF cache due to explicit delete call",o),await this.deleteFallback(e)}}async deleteFallback(e){let n=new Headers({"Cache-Control":"s-maxage=0, must-revalidate"});n.set(ar,`${Date.now()}`);let r=await this.#r(),o=this.#o(e),s=new Response("",{headers:n});await r.put(o,s)}logDebug(...e){"logger"in this.#e?this.#e.logger?.debug(`Error in ZoneCache: '${this.#t}'`,e):"log"in this.#e&&this.#e.log.debug(`Error in ZoneCache: '${this.#t}'`,e)}};var Y=class{static{i(this,"MemoryZoneReadThroughCache")}constructor(e,n){let r=`f6726488-fd18-4b7f-9c30-6070565e8042-${e}`;this.#e=e,this.#t=new Ve(r),this.#n=new Ge(r,n),this.#r=n}#e;#t;#n;#r;async get(e){let n=this.#t.get(e);if(n)return n;let r=await this.#n.get(e);if(r){let o=Math.floor((r.expires-Date.now())/1e3);if(o>0)return this.#t.put(e,r.data,o),r.data}}put(e,n,r){this.#t.put(e,n,r);let o={data:n,expires:Date.now()+r*1e3},s=this.#n.put(e,o,r).catch(a=>{this.#r.log.error(`Error in MemoryZoneReadThroughCache: '${this.#e}'`,a)});this.#r.waitUntil(s)}};var Xo="zuplo-request-id",We="zp-rid",ur="zp-body-removed",Ue="cf-ray",ei="x-real-ip",cr="cf-ipcity",lr="cf-ipcontinent",dr="cf-ipcountry",pr="cf-iplongitude",mr="cf-iplatitude",ti="cf-region",ni="cf-region-code",ri="cf-metro-code",oi="cf-postal-code",ii="cf-timezone",si="zp-ipcity",ai="zp-ipcontinent",ui="zp-ipcountry",ci="zp-iplongitude",li="zp-iplatitude",di="true-client-ip",gr="zp-asn",fr="zp-asorg",hr="zp-colo",yr="zp-postalcode",br="zp-metrocode",wr="zp-region",Rr="zp-regioncode",Pr="zp-timezone",pi=[cr,lr,dr,pr,mr,gr,fr,hr,yr,br,wr,Rr,Pr],mi=["zp-","cf-"],gi=[We,Ue,ur],fi=["x-b3-sampled","x-b3-spanid","x-b3-traceid","x-envoy-attempt-count","x-envoy-decorator-operation","x-envoy-external-address","x-envoy-peer-metadata","x-envoy-peer-metadata-id","k-proxy-request","fly-client-ip","fly-forwarded-port","fly-forwarded-proto","fly-forwarded-ssl","fly-region","fly-request-id","fly-traceparent","fly-tracestate"],mt="zuplo_meters_d7831150-6d8a-416d-b920-4a7bec209a49",Dt="zuplo_dynamic_meters_0c8cdc26-2514-4756-8adb-474a6e103d91";var gs=Se(Ae());var ft=class t{static{i(this,"InternalProblemResponseFormatter")}static problemResponseFormat=async e=>{let n=e.problem,r=JSON.stringify(n,null,2);return new Response(r,{status:e.problem.status,statusText:e.statusText,headers:{...e.additionalHeaders,"content-type":"application/problem+json"}})};static setProblemResponseFormat(e){e&&(t.problemResponseFormat=(n,r,o)=>{try{return e(n,r,o)}catch(s){throw new L("Error in custom 'problemResponseFormat'",{cause:s})}})}},Le=class{static{i(this,"ProblemResponseFormatter")}static async format(e,n,r){return await ft.problemResponseFormat(e,n,r)}};function Bt(t){for(let e in t){let n=t[e];n&&typeof n=="object"&&Bt(n)}return Object.freeze(t)}i(Bt,"deepFreeze");var z=class t extends Request{static{i(this,"ZuploRequest")}#e=void 0;#t;constructor(e,n){super(e,n);let r=n?.params;r?this.#t=r:e instanceof t?this.#t=e.#t:this.#t={};let o=n?.user;o?this.user=o:e instanceof t&&(this.user=e.user)}get query(){if(this.#e===void 0){let e={},n=new URL(this.url).searchParams;for(let[r,o]of n.entries())e[r]=o;this.#e=e}return Bt(this.#e)}get params(){return Bt(this.#t)}user};var Ze=class{static{i(this,"RuntimePlugin")}},xe=class extends Ze{static{i(this,"SystemRuntimePlugin")}async initialize(e){return Promise.resolve()}registerRoutes(e,n){}},ht={},_e=[],ki=[],Mi=[],Di=[];var zt={addPlugin(t){_e.push(t)},addRequestHook(t){ki.push(t)},addResponseSendingHook(t){Mi.push(t)},addResponseSendingFinalHook(t){Di.push(t)}},Ui=i(async(t,e)=>{let n=t;for(let r of ki){let o=await r(n,e);if(o instanceof z)n=o;else{if(o instanceof Response)return o;throw new y(`Invalid state - the OnRequest hook must return a ZuploRequest or Response. Received ${typeof n}.`)}}return n},"invokeOnRequestExtensions"),Hi=i(async(t,e,n)=>{let r=t;for(let o of Mi){let s=await o(t,e,n);if(s instanceof Response)r=s;else throw new y(`Invalid state - the OnResponseSending hook must return a Response. Received ${typeof r}.`)}return r},"invokeOnResponseSendingExtensions"),Zi=i(async(t,e,n)=>{for(let r of Di)await r(t,e,n)},"invokeOnResponseSendingFinalExtensions");async function qi(t=()=>Promise.resolve()){await t(zt),ht.value=zt;for(let e of _e)e instanceof xe&&await e.initialize(zt);ft.setProblemResponseFormat(zt.problemResponseFormat)}i(qi,"initializeRuntime");var jt={Json:"application/json",Form:"application/x-www-form-urlencoded"};function Vt(t,e){if(t!==null)return e&&typeof t=="string"?t:typeof t=="object"&&e?.startsWith(jt.Form)?new URLSearchParams(t).toString():typeof t=="object"&&e?.startsWith(jt.Json)||!e?JSON.stringify(t):t}i(Vt,"serialize");function yt(t){return X.instance.runtimeSettings.developerPortal.enabled&&t.pathname.startsWith(X.instance.runtimeSettings.developerPortal.sitePathname)||t.pathname.startsWith("/__zuplo/")||t.pathname.startsWith("/__/zuplo/")}i(yt,"isSystemRoute");var J=class{static{i(this,"Pipeline")}constructor(e){this.execute=this.#t(e)}execute;#e=(e,n)=>async(r,o)=>{try{return await e(r,o)}catch(s){return o.log.error("Error executing request handler.",s),n.errorHandler(r,o,s)}};#t=({processors:e,gateway:n,handler:r})=>async(o,s)=>{let a=[...e],u=i(async b=>{let v=a.pop();return v?v(o,s,n,u):await this.#e(async f=>{let I=await r(f,s);return Nc(I)},n)(b,s)},"nextPipe"),l=await u(o),d=new URL(o.url);if(yt(d)&&E.instance.build.COMPATIBILITY_FLAGS.doNotRunHooksOnSystemRoutes)return l;let p=new Ke(o,l);s.dispatchEvent(p);let m=ne.getContextExtensions(s),g=m.latestRequest,R;try{R=await p.mutableResponse}catch(b){return s.log.error(b),n.errorHandler(o,s,b)}try{R=await m.onResponseSending(R,g,s)}catch(b){return s.log.error(`Error invoking 'context.onResponseSending' hook: '${b.message}'`,b),n.errorHandler(o,s,b)}try{R=await Hi(R,g,s)}catch(b){return s.log.error(`Error invoking 'context.onResponseSending' hook: '${b.message}'`,b),n.errorHandler(o,s,b)}s.dispatchEvent(new Je(o,R));try{await m.onResponseSendingFinal(l,g,s)}catch(b){throw s.log.error(`Error invoking 'runtime.onResponseSending' hook: '${b.message}'`,b),b}try{await Zi(l,g,s)}catch(b){throw s.log.error(`Error invoking 'runtime.onResponseSending' hook: '${b.message}'`,b),b}return R}};function Nc(t){return t instanceof Response?t:typeof t>"u"?new Response:new Response(Vt(t),{headers:{"content-type":"application/json"}})}i(Nc,"resultToResponse");var Ne=class extends Ze{static{i(this,"MetricsPlugin")}};var F=class t{static{i(this,"SystemLogMap")}static#e=new WeakMap;static getLogger(e){let n=t.#e.get(e);if(!n){let r=`No system logger found for context with requestId '${e.requestId}'`;throw console.error(r),new $(r)}return n}static addLogger(e,n){t.#e.set(e,n)}};var q=class{static{i(this,"BatchDispatch")}constructor(e,n,r,o){this.#t=e,this.#i=n,this.#r=r,this.#n=o??console}#e=void 0;#t;#n;#r;#o=[];#i;enqueue=e=>{this.#o.push(e),this.#e||(this.#e=new Promise(n=>{setTimeout(()=>{if(this.#o.length>0){let r=[...this.#o];this.#o.length=0,this.#e=void 0,this.#r(r).catch(o=>{this.#n.error(`Uncaught error in BatchDispatcher named '${this.#t}'}`,o.message,o.stack)}).finally(()=>{n()})}},this.#i)}))};waitUntilFlushed=async()=>{if(this.#e)return this.#e}};var Gt=class{static{i(this,"EllieMetricsTransport")}#e;#t;#n;constructor(e){this.#n=E.instance.loggingId,this.#e=e,this.#t=new q("ellie-metrics-transport",10,this.dispatchFunction,F.getLogger(e))}pushMetrics(e,n){this.#n!==void 0&&(this.#t.enqueue(e),n.waitUntil(this.#t.waitUntilFlushed()))}dispatchFunction=async e=>{if(e.length===0)return;let n,{loggingId:r,remoteLogURL:o,deploymentName:s}=E.instance,a=e.map(u=>{let c=Object.assign({},u);return delete c.requestContentLength,delete c.responseContentLength,c});if(r&&s&&(n=`${o}/v1-alpha/metrics?loggingId=${encodeURI(r)}&deploymentName=${encodeURI(s)}`),n){let u=await fetch(n,{method:"POST",body:JSON.stringify(a),headers:{"content-type":"application/json","zp-dn":E.instance.deploymentName??"unknown","user-agent":E.instance.systemUserAgent}});if(!u.ok){let c=await u.text();F.getLogger(this.#e).error(`Metrics POST responded ${u.status}: ${u.statusText}`,c)}}}};var K=class{static{i(this,"SystemRouteConfiguration")}constructor({label:e,path:n,methods:r,systemRouteName:o,corsPolicy:s="none"}){this.label=e,this.path=n,this.methods=r,this.corsPolicy=s,this.version=bt.name,this.handler={export:"SYSTEM_IGNORED",module:"SYSTEM_IGNORED"},this.systemRouteName=o}label;path;methods;handler;corsPolicy;version;policies;systemRouteName;raw(){return{}}},bt={name:"__system-no-version",pathPrefix:""};var re=i(async(t,e,n,r)=>{let o=new Date,s=Date.now(),a=await r(t),u=t.headers.get(Ue)??void 0,c=t.headers.get(di)??void 0,l=e.incomingRequestProperties,d;e.route instanceof K&&(d=e.route.systemRouteName);let p=ne.getContextExtensions(e).latestRequest,m={timestamp:o,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:u,instanceId:n.instanceId,userSub:p.user?.sub,clientIp:c},g=[];return g.push(new Gt(e)),_e.forEach(R=>{if(R instanceof Ne){let b=R.getTransport();g.push(b)}}),g.forEach(R=>{R.pushMetrics(m,e)}),a},"metricsProcessor");var Re=(c=>(c.Build="build-data",c.CorsPreflight="cors-preflight",c.DeveloperPortal="developer-portal",c.DeveloperPortalLegacy="developer-portal-legacy",c.StripePlugin="stripe-plugin",c.EmptyGatewayCatchall="empty-gateway-catchall",c.Ping="ping",c.UnmatchedPath="unmatched-path",c))(Re||{});var Ar=i((t,e)=>{let n=i(async(s,a)=>{let c=new URL(s.url).hostname.toLowerCase();if(!c.endsWith(".zuplo.app")&&!c.endsWith(".zuplo.dev")&&!c.endsWith(".fly.dev")&&!c.endsWith("zuplotest.com")&&c!=="localhost")return T.notFound(s,a);let l=E.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"&&F.getLogger(a).error("Test System Log",d),new Response(JSON.stringify(d,null,2),{status:200,headers:{"content-type":"application/json"}})},"buildRouteHandler"),r=new J({processors:[re],handler:n,gateway:e}),o=new K({label:"SYSTEM_BUILD_ROUTE",methods:["GET"],path:"/__zuplo/build",systemRouteName:"build-data"});t.addRoute(o,r.execute)},"registerBuildRoute");var Wt=(P=>(P[P.CONTINUE=100]="CONTINUE",P[P.SWITCHING_PROTOCOLS=101]="SWITCHING_PROTOCOLS",P[P.PROCESSING=102]="PROCESSING",P[P.EARLY_HINTS=103]="EARLY_HINTS",P[P.OK=200]="OK",P[P.CREATED=201]="CREATED",P[P.ACCEPTED=202]="ACCEPTED",P[P.NON_AUTHORITATIVE_INFORMATION=203]="NON_AUTHORITATIVE_INFORMATION",P[P.NO_CONTENT=204]="NO_CONTENT",P[P.RESET_CONTENT=205]="RESET_CONTENT",P[P.PARTIAL_CONTENT=206]="PARTIAL_CONTENT",P[P.MULTI_STATUS=207]="MULTI_STATUS",P[P.ALREADY_REPORTED=208]="ALREADY_REPORTED",P[P.IM_USED=226]="IM_USED",P[P.MULTIPLE_CHOICES=300]="MULTIPLE_CHOICES",P[P.MOVED_PERMANENTLY=301]="MOVED_PERMANENTLY",P[P.FOUND=302]="FOUND",P[P.SEE_OTHER=303]="SEE_OTHER",P[P.NOT_MODIFIED=304]="NOT_MODIFIED",P[P.USE_PROXY=305]="USE_PROXY",P[P.SWITCH_PROXY=306]="SWITCH_PROXY",P[P.TEMPORARY_REDIRECT=307]="TEMPORARY_REDIRECT",P[P.PERMANENT_REDIRECT=308]="PERMANENT_REDIRECT",P[P.BAD_REQUEST=400]="BAD_REQUEST",P[P.UNAUTHORIZED=401]="UNAUTHORIZED",P[P.PAYMENT_REQUIRED=402]="PAYMENT_REQUIRED",P[P.FORBIDDEN=403]="FORBIDDEN",P[P.NOT_FOUND=404]="NOT_FOUND",P[P.METHOD_NOT_ALLOWED=405]="METHOD_NOT_ALLOWED",P[P.NOT_ACCEPTABLE=406]="NOT_ACCEPTABLE",P[P.PROXY_AUTHENTICATION_REQUIRED=407]="PROXY_AUTHENTICATION_REQUIRED",P[P.REQUEST_TIMEOUT=408]="REQUEST_TIMEOUT",P[P.CONFLICT=409]="CONFLICT",P[P.GONE=410]="GONE",P[P.LENGTH_REQUIRED=411]="LENGTH_REQUIRED",P[P.PRECONDITION_FAILED=412]="PRECONDITION_FAILED",P[P.CONTENT_TOO_LARGE=413]="CONTENT_TOO_LARGE",P[P.PAYLOAD_TOO_LARGE=413]="PAYLOAD_TOO_LARGE",P[P.URI_TOO_LONG=414]="URI_TOO_LONG",P[P.UNSUPPORTED_MEDIA_TYPE=415]="UNSUPPORTED_MEDIA_TYPE",P[P.RANGE_NOT_SATISFIABLE=416]="RANGE_NOT_SATISFIABLE",P[P.EXPECTATION_FAILED=417]="EXPECTATION_FAILED",P[P.I_AM_A_TEAPOT=418]="I_AM_A_TEAPOT",P[P.MISDIRECTED_REQUEST=421]="MISDIRECTED_REQUEST",P[P.UNPROCESSABLE_ENTITY=422]="UNPROCESSABLE_ENTITY",P[P.UNPROCESSABLE_CONTENT=422]="UNPROCESSABLE_CONTENT",P[P.LOCKED=423]="LOCKED",P[P.FAILED_DEPENDENCY=424]="FAILED_DEPENDENCY",P[P.TOO_EARLY=425]="TOO_EARLY",P[P.UPGRADE_REQUIRED=426]="UPGRADE_REQUIRED",P[P.PRECONDITION_REQUIRED=428]="PRECONDITION_REQUIRED",P[P.TOO_MANY_REQUESTS=429]="TOO_MANY_REQUESTS",P[P.REQUEST_HEADER_FIELDS_TOO_LARGE=431]="REQUEST_HEADER_FIELDS_TOO_LARGE",P[P.UNAVAILABLE_FOR_LEGAL_REASONS=451]="UNAVAILABLE_FOR_LEGAL_REASONS",P[P.INTERNAL_SERVER_ERROR=500]="INTERNAL_SERVER_ERROR",P[P.NOT_IMPLEMENTED=501]="NOT_IMPLEMENTED",P[P.BAD_GATEWAY=502]="BAD_GATEWAY",P[P.SERVICE_UNAVAILABLE=503]="SERVICE_UNAVAILABLE",P[P.GATEWAY_TIMEOUT=504]="GATEWAY_TIMEOUT",P[P.HTTP_VERSION_NOT_SUPPORTED=505]="HTTP_VERSION_NOT_SUPPORTED",P[P.VARIANT_ALSO_NEGOTIATES=506]="VARIANT_ALSO_NEGOTIATES",P[P.INSUFFICIENT_STORAGE=507]="INSUFFICIENT_STORAGE",P[P.LOOP_DETECTED=508]="LOOP_DETECTED",P[P.NOT_EXTENDED=510]="NOT_EXTENDED",P[P.NETWORK_AUTHENTICATION_REQUIRED=511]="NETWORK_AUTHENTICATION_REQUIRED",P))(Wt||{}),$i={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 kc={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"},Kt=kc;function Mc(t){return`${new URL(t.url).pathname}`}i(Mc,"instance");function Dc(t,e){let n={timestamp:new Date().toISOString(),requestId:e.requestId,buildId:E.instance.build.BUILD_ID},r=t.headers.get(Ue);return r&&(n.rayId=r),n}i(Dc,"trace");var Uc=i((t,e,n,r,o)=>({problem:{type:t.type,title:t.title,status:t.status,detail:t.detail,instance:Mc(e),trace:Dc(e,n),...r},additionalHeaders:o,statusText:Kt[t.status]}),"merge"),Lr=class{static{i(this,"HttpProblemsBase")}static format=(e,n,r)=>"problem"in e?Le.format(e,n,r):Le.format({problem:e},n,r);static getProblemFromStatus(e,n){return{type:`https://httpproblems.com/http-status/${e}`,status:e,title:$i[e],...n}}},T=class extends Lr{static{i(this,"HttpProblems")}static#e(e,n,r,o,s){let a=Uc(this.getProblemFromStatus(e),n,r,o,s);return Le.format(a,n,r)}static continue=(e,n,r,o)=>this.#e(200,e,n,r,o);static switchingProtocols=(e,n,r,o)=>this.#e(101,e,n,r,o);static processing=(e,n,r,o)=>this.#e(102,e,n,r,o);static earlyHints=(e,n,r,o)=>this.#e(103,e,n,r,o);static ok=(e,n,r,o)=>this.#e(200,e,n,r,o);static created=(e,n,r,o)=>this.#e(201,e,n,r,o);static accepted=(e,n,r,o)=>this.#e(202,e,n,r,o);static nonAuthoritativeInformation=(e,n,r,o)=>this.#e(203,e,n,r,o);static noContent=(e,n,r,o)=>this.#e(204,e,n,r,o);static resetContent=(e,n,r,o)=>this.#e(205,e,n,r,o);static partialContent=(e,n,r,o)=>this.#e(206,e,n,r,o);static multiStatus=(e,n,r,o)=>this.#e(207,e,n,r,o);static alreadyReported=(e,n,r,o)=>this.#e(208,e,n,r,o);static imUsed=(e,n,r,o)=>this.#e(226,e,n,r,o);static multipleChoices=(e,n,r,o)=>this.#e(300,e,n,r,o);static movedPermanently=(e,n,r,o)=>this.#e(301,e,n,r,o);static found=(e,n,r,o)=>this.#e(302,e,n,r,o);static seeOther=(e,n,r,o)=>this.#e(303,e,n,r,o);static notModified=(e,n,r,o)=>this.#e(304,e,n,r,o);static useProxy=(e,n,r,o)=>this.#e(305,e,n,r,o);static switchProxy=(e,n,r,o)=>this.#e(306,e,n,r,o);static temporaryRedirect=(e,n,r,o)=>this.#e(307,e,n,r,o);static permanentRedirect=(e,n,r,o)=>this.#e(308,e,n,r,o);static badRequest=(e,n,r,o)=>this.#e(400,e,n,r,o);static unauthorized=(e,n,r,o)=>this.#e(401,e,n,r,o);static paymentRequired=(e,n,r,o)=>this.#e(402,e,n,r,o);static forbidden=(e,n,r,o)=>this.#e(403,e,n,r,o);static notFound=(e,n,r,o)=>this.#e(404,e,n,r,o);static methodNotAllowed=(e,n,r,o)=>this.#e(405,e,n,r,o);static notAcceptable=(e,n,r,o)=>this.#e(406,e,n,r,o);static proxyAuthenticationRequired=(e,n,r,o)=>this.#e(407,e,n,r,o);static requestTimeout=(e,n,r,o)=>this.#e(408,e,n,r,o);static conflict=(e,n,r,o)=>this.#e(409,e,n,r,o);static gone=(e,n,r,o)=>this.#e(410,e,n,r,o);static lengthRequired=(e,n,r,o)=>this.#e(411,e,n,r,o);static preconditionFailed=(e,n,r,o)=>this.#e(412,e,n,r,o);static contentTooLarge=(e,n,r,o)=>this.#e(413,e,n,r,o);static uriTooLong=(e,n,r,o)=>this.#e(414,e,n,r,o);static unsupportedMediaType=(e,n,r,o)=>this.#e(415,e,n,r,o);static rangeNotSatisfiable=(e,n,r,o)=>this.#e(416,e,n,r,o);static expectationFailed=(e,n,r,o)=>this.#e(417,e,n,r,o);static imATeapot=(e,n,r,o)=>this.#e(418,e,n,r,o);static misdirectedRequest=(e,n,r,o)=>this.#e(421,e,n,r,o);static unprocessableContent=(e,n,r,o)=>this.#e(422,e,n,r,o);static locked=(e,n,r,o)=>this.#e(423,e,n,r,o);static failedDependency=(e,n,r,o)=>this.#e(424,e,n,r,o);static tooEarly=(e,n,r,o)=>this.#e(425,e,n,r,o);static upgradeRequired=(e,n,r,o)=>this.#e(426,e,n,r,o);static preconditionRequired=(e,n,r,o)=>this.#e(428,e,n,r,o);static tooManyRequests=(e,n,r,o)=>this.#e(429,e,n,r,o);static requestHeaderFieldsTooLarge=(e,n,r,o)=>this.#e(431,e,n,r,o);static unavailableForLegalReasons=(e,n,r,o)=>this.#e(451,e,n,r,o);static internalServerError=(e,n,r,o)=>this.#e(500,e,n,r,o);static notImplemented=(e,n,r,o)=>this.#e(501,e,n,r,o);static badGateway=(e,n,r,o)=>this.#e(502,e,n,r,o);static serviceUnavailable=(e,n,r,o)=>this.#e(503,e,n,r,o);static gatewayTimeout=(e,n,r,o)=>this.#e(504,e,n,r,o);static httpVersionNotSupported=(e,n,r,o)=>this.#e(505,e,n,r,o);static variantAlsoNegotiates=(e,n,r,o)=>this.#e(506,e,n,r,o);static insufficientStorage=(e,n,r,o)=>this.#e(507,e,n,r,o);static loopDetected=(e,n,r,o)=>this.#e(508,e,n,r,o);static notExtended=(e,n,r,o)=>this.#e(510,e,n,r,o);static networkAuthenticationRequired=(e,n,r,o)=>this.#e(511,e,n,r,o)};var{toString:Hc}=Object.prototype,{propertyIsEnumerable:Zc}=Object.prototype;function _r(t){return Hc.call(t)}i(_r,"toString");function ae(t){return typeof t=="string"}i(ae,"isString");function Ye(t){return ae(t)&&t!==""}i(Ye,"isNonEmptyString");function Fi(t){return _r(t)==="[object RegExp]"}i(Fi,"isRegexp");function Bi(t){return[...Object.keys(t),...Object.getOwnPropertySymbols(t).filter(e=>Zc.call(t,e))]}i(Bi,"getOwnEnumerableKeys");function qe(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)&&!(t instanceof RegExp)&&!(t instanceof Date)}i(qe,"isObject");function Nr(t){return typeof t=="number"&&!isNaN(t)}i(Nr,"isNumber");function kr(t){return t===!0||t===!1}i(kr,"isBoolean");function zi(t){return typeof t>"u"}i(zi,"isUndefined");function ji(t){return zi(t)||t===null}i(ji,"isUndefinedOrNull");function wt(t){return!!t&&typeof t=="object"&&"name"in t&&"message"in t&&"stack"in t}i(wt,"isErrorLike");var Vi=new Map;function Qe(t){if(Array.isArray(t)&&!t.some(o=>typeof o!="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=Vi.get(t);if(e)return e;let n=t.split(","),r=[];for(let o of n){let s=o.split("-");if(s.length===2){let a=parseInt(s[0],10),u=parseInt(s[1],10);for(let c=a;c<=u;c++)r.push(c)}else r.push(parseInt(o,10))}return Vi.set(t,r),r}i(Qe,"statusCodesStringToNumberArray");function $e(t,e,n){if(!e.startsWith("."))throw new y(`Invalid ${n} - must start with '.' - '${e}' does not`);let r=e.split(".").splice(1),o=t;return r.forEach(s=>{if(o===void 0)throw new L(`Error applying ${n} '${e}', reading '${s}'`);o=o[s]}),`${o}`}i($e,"getValueFromRequestUser");function Fe(t){if(Array.isArray(t)){if(t.includes(n=>typeof n!="string"))throw new y("Received an array that contains non-string values.");return t}if(ae(t))return t.includes(",")?t.split(",").map(n=>n.trim()).filter(n=>n!==","&&n!==""):[t];throw new y(`Expected type of string, received type '${typeof t}'`)}i(Fe,"parseValueToStringArray");function Gi(t){if(t==null)return[];if(!Array.isArray(t))throw new y(`Invalid corsPolicy configuration. Expected an array of objects, received '${typeof t}'`);return t.map(n=>{if(!qe(n))throw new y(`Invalid custom cors policy is set. Expected an object, received '${typeof n}'`);if(!Ye(n.name))throw new y("Value of 'name' on custom cors policies must be a non-empty string.");if(n.maxAge!==void 0&&!Nr(n.maxAge))throw new y(`Value of 'maxAge' on custom cors policies must be a non-empty string. Received type '${typeof n.maxAge}'`);if(n.allowCredentials!==void 0&&!kr(n.allowCredentials))throw new y("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 r=Mr(n,"allowedHeaders"),o=Mr(n,"allowedMethods"),s=Mr(n,"exposeHeaders"),a;try{a=Fe(n.allowedOrigins)}catch(c){throw new y(`Value of 'allowedOrigins' on custom cors policies is invalid. ${c.message} If using an environment variable, check that it is set correctly.`)}return{name:n.name,allowCredentials:typeof n.allowCredentials=="boolean"?String(n.allowCredentials):void 0,allowedOrigins:a,allowedHeaders:r?r.join(", "):void 0,allowedMethods:o?o.join(", "):void 0,exposeHeaders:s?s.join(", "):void 0,maxAge:typeof n.maxAge=="number"?n.maxAge.toString():void 0}})}i(Gi,"parseCorsPolicies");function Mr(t,e){let n;if(t[e]!==void 0)try{n=Fe(t[e])}catch(r){throw new y(`Value of '${e}' on custom cors policies is invalid. ${r.message} If using an environment variable, check that it is set correctly.`)}return n}i(Mr,"parseOptionalProperty");var Jt=i((t,e)=>{if(e===null)return;if(t.find(a=>a==="*"))return e;let r=t.map(a=>a.trim().toLowerCase()),o=e.toLowerCase();return r.find(a=>a===o)},"findMatchingOrigin"),Yt=i((t,e)=>{let n={"access-control-allow-origin":e};t.allowedHeaders&&(n["access-control-allow-headers"]=t.allowedHeaders),t.allowedMethods&&(n["access-control-allow-methods"]=t.allowedMethods),t.exposeHeaders&&(n["access-control-expose-headers"]=t.exposeHeaders);let r=t.allowCredentials;r&&(n["access-control-allow-credentials"]=r);let o=t.maxAge?.toString()??void 0;return o&&(n["access-control-max-age"]=o),n},"generateCorsHeaders");var Dr=i((t,e)=>{let n=e.routeData.corsPolicies,r=i(async(a,u)=>{let c=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 T.badRequest(a,u,{detail:"Expect headers origin and access-control-request-method"});let m=t.lookup(l,c);if(!m)return T.notFound(a,u);let g=m.routeConfiguration,R=qc(l,d,p,g,n);return R.isValid?new Response(void 0,{status:200,statusText:"OK",headers:R.headers}):(R.error&&u.log.warn(R.error),T.notFound(a,u))},"optionsHandler"),o=new J({processors:[re],handler:r,gateway:e}),s=new K({label:"SYSTEM_CORS_ROUTE",methods:["OPTIONS"],path:"/(.*)",systemRouteName:"cors-preflight"});t.addRoute(s,o.execute)},"registerCorsRoute"),qc=i((t,e,n,r,o)=>{let s={isValid:!1,headers:{}};if(r.corsPolicy==="anything-goes")return{isValid:!0,headers:{"access-control-allow-origin":n,"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(r.corsPolicy==="none")return{...s,error:`No CORS policy set for the route '${r.pathPattern}'`};let a=o?.find(l=>l.name===r.corsPolicy);if(!a)throw new y(`Invalid Configuration - corsPolicy '${r.corsPolicy}' not found in *.oas.json 'corsPolicies' section.`);let u=Jt(a.allowedOrigins,n);return u?{isValid:!0,headers:Yt(a,u)}:{...s,error:`The CORS policy '${a.name}' does not allow the origin '${n}'`}},"validateAndBuildResponseHeaders");var Wi=i((t,e)=>{let n=i(async()=>new Response("You have no routes. Add a route in routes.oas.json to get started",{status:200}),"noRoutesHandler"),r=new J({processors:[re],handler:n,gateway:e}),o=new K({label:"SYSTEM_NO_ROUTES",methods:["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"],path:"/(.*)",systemRouteName:"empty-gateway-catchall"});t.addRoute(o,r.execute)},"registerNoRoutes");var Ur=new K({label:"SYSTEM_NOT_FOUND_ROUTE",methods:["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"],path:"/(.*)",systemRouteName:"unmatched-path"}),Ki=i((t,e)=>{let n=i(async(o,s)=>{let a=ht.value?.notFoundHandler;if(a){let u=ne.getContextExtensions(s);return a(o,s,{routesMatchedByPathOnly:u.pathOnlyMatches??[]})}return T.notFound(o,s)},"notFoundHandler"),r=new J({processors:[re],handler:n,gateway:e});t.addRoute(Ur,r.execute)},"registerNotMatchedHandler");var $c=["access-control-allow-origin","access-control-allow-headers","access-control-expose-headers","access-control-allow-credentials","access-control-max-age"],Ji=i(t=>{$c.forEach(e=>t.delete(e))},"stripCorsHeaders"),Qt=i(async(t,e,n,r)=>{let o=e.route;if(!o.corsPolicy||o.corsPolicy==="none"){let d=await r(t),p=new Headers(d.headers);return Ji(p),new Response(d.body,{status:d.status,statusText:d.statusText,headers:p,webSocket:d.webSocket})}let s=await r(t);if(!(s instanceof Response))throw new $(`The CorsProcessor is in the wrong place in the pipeline. It should only receive HttpResponse type but got '${typeof s}'`);let a=Fc(o,n.routeData.corsPolicies),u=Bc(t,a),c=new Headers(s.headers);return Ji(c),Object.entries(u).forEach(([d,p])=>{c.set(d,p)}),new Response(s.body,{status:s.status,statusText:s.statusText,headers:c,webSocket:s.webSocket})},"corsProcessor"),Fc=i((t,e)=>{if(t.corsPolicy==="anything-goes")return{name:"anything-goes",allowedHeaders:"*",allowedOrigins:["*"],allowedMethods:t.methods.join(", "),exposeHeaders:"*",allowCredentials:"true",maxAge:"600"};let n=e?.find(r=>r.name===t.corsPolicy);if(n===void 0)throw new y(`Invalid Configuration - no corsPolicy '${t.corsPolicy}' found in *.oas.json`);return n},"getCorsPolicy"),Bc=i((t,e)=>{let n=Jt(e.allowedOrigins,t.headers.get("origin"));return n?Yt(e,n):{}},"getCorsHeaders");var Hr=i((t,e)=>{let n=i(async()=>new Response(null,{status:200}),"pingRouteHandler"),r=new J({processors:[Qt],handler:n,gateway:e}),o=new K({corsPolicy:"anything-goes",label:"SYSTEM_PING_ROUTE",methods:["GET"],path:"/__zuplo/ping",systemRouteName:"ping"});t.addRoute(o,r.execute)},"registerPingRoute");var Xt=class{static{i(this,"PolicyBase")}options;policyName;constructor(e,n){if(!ae(n))throw new L(`The name of a policy must be a string. Received '${n}' of type '${typeof n}'`);this.options=e,this.policyName=n}},ge=class extends Xt{static{i(this,"InboundPolicy")}},ve=class extends Xt{static{i(this,"OutboundPolicy")}};var $r=class extends ge{static{i(this,"InboundFunctionOnlyPolicy")}#e;constructor(e,n,r){super(n,r),this.#e=e}handler(e,n){return this.#e(e,n,this.options,this.policyName)}},Fr=class extends ve{static{i(this,"OutboundFunctionOnlyPolicy")}#e;constructor(e,n,r){super(n,r),this.#e=e}handler(e,n,r){return this.#e(e,n,r,this.options,this.policyName)}},Zr=new Map;function Rt(t,e){let n,r;return Array.isArray(t)?n=t:(n=t.policies?.inbound??[],r=t.path),n.filter(s=>!Zr.has(s)).forEach(s=>{let a=e?.find(l=>l.name===s);if(!a)throw new y(`Invalid state - no Policy with the name '${s}' ${r&&`on route '${r}'`} was found in the policies configuration (check case).`);if(typeof a.handler?.module!="object")throw new y(`Invalid state - invalid policy '${s}' on route '${r}' (typeof policy '${typeof a.handler?.module}')`);let u=a.handler?.module[a.handler.export];if(typeof u!="function")throw new y(`Invalid state - invalid policy '${s}' on route '${r}' (typeof module '${typeof u}')`);let c;if(typeof u!="function")throw new y(`Invalid state - invalid policy '${s}' on route '${r}' (typeof module '${typeof u}')`);if(u.prototype instanceof ge)c=new u(a.handler.options,a.name);else if(typeof u=="function")c=new $r(u,a.handler.options,a.name);else throw new y(`Invalid state - invalid policy '${s}' on route '${r}' (typeof policy '${typeof u}')`);if(typeof c.handler!="function")throw new y(`Invalid state - invalid handler on policy '${s}' on route '${r}' (typeof handler '${typeof c.handler}')`);Zr.set(a.name,c)}),n.map(s=>{let a=Zr.get(s);if(a===void 0)throw new L("Internal error. Policy not found in cache.");return a})}i(Rt,"getInboundPolicyInstances");var qr=new Map;function zc(t,e){let n=t.policies?.outbound??[];return n.filter(o=>!qr.has(o)).forEach(o=>{let s=e?.find(c=>c.name===o);if(!s)throw new y(`Invalid state - no Policy with the name '${o}' on route '${t.path}' was found in the policies configuration (check case).`);if(typeof s.handler?.module!="object")throw new y(`Invalid state - invalid policy '${o}' on route '${t.path}' (typeof policy '${typeof s.handler?.module}')`);let a=s.handler?.module[s.handler.export],u;if(typeof a!="function")throw new y(`Invalid state - invalid policy '${o}' on route '${t.path}' (typeof module '${typeof a}')`);if(a.prototype instanceof ve)u=new a(s.handler.options??{},s.name);else if(typeof a=="function")u=new Fr(a,s.handler.options??{},s.name);else throw new y(`Invalid state - invalid policy '${o}' on route '${t.path}' (typeof policy '${typeof a}')`);if(typeof u.handler!="function")throw new y(`Invalid state - invalid handler on policy '${o}' on route '${t.path}'`);qr.set(s.name,u)}),n.map(o=>{let s=qr.get(o);if(s===void 0)throw new L("Internal error. Policy not found in cache.");return s})}i(zc,"getOutboundPolicyInstances");var Br=i(t=>async(e,n)=>{let r=ne.getContextExtensions(n),o=[...t],s=e;for(;o.length>0;){let a=o.shift();if(!a)return s;let u=await a.handler(s,n);if(u instanceof z)s=u;else if(u instanceof Request)s=new z(u);else{if(u instanceof Response)return u;throw new y(`Invalid state - invalid handler on policy '${a.policyName}' on route '${n.route.path}. The result of an inbound policy must be a Response or Request.`)}r.latestRequest=s}return s},"toStackedInboundHandler"),jc=i(t=>async(e,n,r)=>{let o=[...t],s=e;for(;o.length>0;){let a=o.shift();if(!a)return s;let u=await a.handler(s,n,r);if(!(u instanceof Response))throw new y(`Invalid state - invalid handler on policy '${a.policyName}' on route '${r.route.path}. The result of an outbound policy must be a Response.`);s=u}return s},"toStackedOutboundHandler"),en=i(async(t,e,n,r)=>{let o=Rt(e.route,n.routeData.policies),s=zc(e.route,n.routeData.policies);return Qi({request:t,context:e,inboundPolicies:o,outboundPolicies:s,gateway:n,next:r})},"policyProcessor");function Yi({inboundPolicies:t=[],outboundPolicies:e=[]}){return i(async(r,o,s,a)=>Qi({request:r,context:o,inboundPolicies:t,outboundPolicies:e,gateway:s,next:a}),"policyProcessor")}i(Yi,"createInternalPolicyProcessor");async function Qi({request:t,context:e,inboundPolicies:n,outboundPolicies:r,gateway:o,next:s}){let a=Br(n);try{let u=await a(t,e);if(u instanceof Response)return u;let c=await s(u),l=jc(r),d;return E.instance.build.COMPATIBILITY_FLAGS.runOutboundPoliciesOnHandlerOnAllStatuses?d=l(c,t,e):d=c.ok?l(c,t,e):c,d}catch(u){return e.log.error(u),o.errorHandler(t,e,u)}}i(Qi,"executePolicyProcessor");function Xi(t,e){if(typeof t!="string")throw new TypeError("argument str must be a string");let n={},o=(e||{}).decode||Vc,s=0;for(;s<t.length;){let a=t.indexOf("=",s);if(a===-1)break;let u=t.indexOf(";",s);if(u===-1)u=t.length;else if(u<a){s=t.lastIndexOf(";",a-1)+1;continue}let c=t.slice(s,a).trim();if(n[c]===void 0){let l=t.slice(a+1,u).trim();l.charCodeAt(0)===34&&(l=l.slice(1,-1)),n[c]=Gc(l,o)}s=u+1}return n}i(Xi,"parse");function Vc(t){return t.indexOf("%")!==-1?decodeURIComponent(t):t}i(Vc,"decode");function Gc(t,e){try{return e(t)}catch{return t}}i(Gc,"tryDecode");function es(t,e){try{let n=/v\d+(-\d+)?/g,o=Xi(e.get("Cookie")||"")["zp-dev-portal"];return o!==null&&o&&n.test(o)?`https://dev-portal-${o}.zuplo.com`:t}catch{}return t}i(es,"devPortalBaseURL");var ts="/__zuplo/dev-portal",Wc="dev-portal-id",Kc="dev-portal-host",Jc="zp-account",Yc="zp-project",Qc="dev-portal-build",Xc=`
42
42
  <!DOCTYPE html>
43
43
  <html lang="en">
44
44
  <head>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zuplo/runtime",
3
- "version": "5.1905.0",
3
+ "version": "5.1909.0",
4
4
  "repository": "https://github.com/zuplo/zuplo",
5
5
  "author": "Zuplo, Inc.",
6
6
  "exports": {