@zuplo/core 6.33.10 → 6.33.13

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.
@@ -581,7 +581,7 @@ globstar while`,s,K,c,Ne,xe),this.matchOne(s.slice(K),c.slice(Ne),f))return this
581
581
  else
582
582
  tar -xf ${a} -C ${s};
583
583
  fi
584
- `.trim(),v=ndt("sh",["-c",d]);process.env.DEBUG_TAR&&(v.stdout.on("data",E=>{let A=E.toString().trim();A.length>0&&console.info(A)}),v.stderr.on("data",E=>{let A=E.toString().trim();A.length>0&&console.error(A)})),v.on("close",E=>{E===0?c("Extraction completed."):f(new Error(`tar process exited with code ${E}`))}),v.on("error",E=>{f(E)})})}t(n_r,"untarFile");async function i_r(a){if(await KIe(a))return await kN.rm(a,{recursive:!0})}t(i_r,"deleteFolder");var Ml=YIe;var bC=jp(QIe(),1);import{readFile as s_r}from"fs/promises";var r7=class extends Error{static{t(this,"CustomResolveError")}},wN=class{static{t(this,"RefParser")}sourceDirectory;logger;constructor(s,c){this.sourceDirectory=s,this.logger=c}dereference(s,c){return KQ.$RefParser.dereference(s,{resolve:{json:!0,file:qfe(this.sourceDirectory,this.logger),external:!0,http:!1},dereference:{circular:"ignore",onDereference:c?.onDereference}})}bundle(s){return KQ.$RefParser.bundle(s,{resolve:{file:qfe(this.sourceDirectory,this.logger),external:!0,http:!1}})}parse(s){return KQ.$RefParser.parse(s,{resolve:{file:qfe(this.sourceDirectory,this.logger),external:!0,http:!1}})}resolve(s){return KQ.$RefParser.resolve(s,{resolve:{file:qfe(this.sourceDirectory,this.logger),external:!0,http:!1}})}};function qfe(a,s){return{order:100,canRead(c){let f=c_r(c.url);if(!(f===void 0||f==="file"))return!1;let v;try{v=odt(c.url)}catch(E){throw new r7(`Malformed URI: ${c.url}`,{cause:E})}try{Ml.safePath(a).resolve(v)}catch(E){return s?.warn(E),!1}return!0},async read(c){let f;try{f=odt(c.url)}catch(d){throw new r7(`Malformed URI: ${c.url}`,{cause:d})}try{return await s_r(f)}catch(d){throw new r7(`Error opening file "${f}"`,{cause:d})}}}}t(qfe,"customResolver");var XIe=/^win/.test(globalThis.process?globalThis.process.platform:""),a_r=/\//g,o_r=/^(\w{2,}):\/\//i,ZIe=[/%23/g,"#",/%24/g,"$",/%26/g,"&",/%2C/g,",",/%40/g,"@"];function c_r(a){let s=o_r.exec(a);if(s)return s[1].toLowerCase()}t(c_r,"getProtocol");function odt(a,s){a=decodeURI(a);for(let f=0;f<ZIe.length;f+=2)a=a.replace(ZIe[f],ZIe[f+1]);let c=a.substr(0,7).toLowerCase()==="file://";return c&&(a=a[7]==="/"?a.substr(8):a.substr(7),XIe&&a[1]==="/"&&(a=a[0]+":"+a.substr(1)),s?a="file:///"+a:(c=!1,a=XIe?a:"/"+a)),XIe&&!c&&(a=a.replace(a_r,"\\"),a.substr(1,2)===":\\"&&(a=a[0].toUpperCase()+a.substr(1))),a}t(odt,"toFileSystemPath");var cdt="YOUR_KEY_HERE";async function ldt(a){let c=await new wN(a.sourceDirectory,a.logger).bundle(a.openApiDocPath),f=a.openApiDocPath.replace(a.sourceDirectory,"");return l_r({...a,relativeOpenApiPath:f},c)}t(ldt,"buildPublicOpenApiFile");async function l_r(a,s){p_r({relativeOpenApiPath:a.relativeOpenApiPath},s);let c=s;return c=f_r(c),u_r(c,a),c=__r(c,a),udt(c,"x-zuplo"),c}t(l_r,"buildRawOpenApiFile");function u_r(a,{deploymentUrl:s,deploymentName:c,environmentType:f}){let d;s?d=s.hostname:f&&c&&(d=f===Flt.WORKING_COPY?`${c}.${FNe.ZUP_WORKING_COPY_HOSTNAME}`:`${c}.${FNe.ZUP_HOSTNAME}`),d?a.servers=[{url:`https://${d}`}]:a.servers=void 0}t(u_r,"addServerHost");function f_r(a){if(!a.paths)return a;let{components:s}=a,c=s?{...s}:void 0,f=[];c&&c.parameters&&(f=Object.entries(c.parameters).reduce((v,[E,A])=>(qj in A&&Mue(A[qj])&&(v.push(E),c.parameters&&delete c.parameters[E]),v),[]));let d=Object.entries(a.paths).reduce((v,[E,A])=>{if(!A)return v;let O={...A},M=["delete","get","head","patch","post","put","trace","options"];return M.forEach(H=>{let $=A[H];if(!$)return;if(Mue($[qj])){delete O[H];return}let{parameters:K}=$;if(!K)return;let Ne=K.filter(xe=>{if(qj in xe&&Mue(xe[qj]))return!1;if("$ref"in xe){let Te=xe.$ref.split("/").pop();return Te?!f.includes(Te):!0}return!0});O[H]={...$,parameters:Ne}}),M.some(H=>!!O[H])&&(v[E]=O),v},{});return{...a,paths:d,components:c}}t(f_r,"removeHiddenRoutesAndParams");function __r(a,{policiesConfig:s}){if(!a.paths)return a;let c=Object.entries(a.paths).reduce((f,[d,v])=>{if(!v)return f;let E={...v};return[E.delete,E.get,E.head,E.patch,E.post,E.put,E.trace,E.options].forEach(A=>{if(!A)return;let O=A["x-zuplo-route"]?.policies?.inbound?.reduce(($,K)=>{let Ne=s.policies?.find(({name:Tt})=>Tt===K);if(!Ne)return $;if(!(Ne.handler.export==="CompositeInboundPolicy"))return $.concat(K);let Te=Ne.handler.options?.policies;return Te?$.concat(Te):$},[]),M=[];if(O&&O.forEach($=>{s.policies?.forEach(K=>{K.name===$&&(K.handler.export==="ApiAuthKeyInboundPolicy"||K.handler.export==="ApiKeyInboundPolicy")&&!K.handler.options?.disableAutomaticallyAddingKeyHeaderToOpenApi&&M.push(K)})}),M.length>0){let $=M.length>0&&M[0].handler&&M[0].handler.options&&M[0].handler.options.authHeader?M[0].handler.options.authHeader:"Authorization",K=M.length>0&&M[0].handler&&M[0].handler.options&&(M[0].handler.options.authScheme||M[0].handler.options.authScheme==="")?M[0].handler.options.authScheme:"Bearer",Ne=K!==""?`${K} ${cdt}`:cdt,xe={name:$,in:"header",required:!0,example:Ne,schema:{type:"string"},description:`The \`${$}\` header is used to authenticate with the API using your API key. Value is of the format \`${Ne}\`.`};A.parameters?A.parameters.some(br=>"name"in br&&br.name===xe.name)||A.parameters.unshift(xe):A.parameters=[xe];let Te={type:"http",scheme:K.toLowerCase()},Tt="api_key";a.components?.securitySchemes?Object.values(a.components?.securitySchemes).some(br=>"name"in br&&br.type==="apiKey"||"type"in br&&br.type==="http"&&br.scheme===K)||(a.components.securitySchemes={...a.components.securitySchemes,[Tt]:Te}):(a.components||(a.components={}),a.components.securitySchemes={[Tt]:Te});let Dt={[Tt]:[]};A.security?A.security.some(br=>br[Tt]!==void 0)||A.security.unshift(Dt):A.security=[Dt]}let H=[];if(O&&O.forEach($=>{s.policies?.forEach(K=>{K.name===$&&(K.handler.export==="RateLimitInboundPolicy"||K.handler.export==="ComplexRateLimitInboundPolicy")&&H.push(K)})}),H.length>0){let $={description:"Rate Limiting Response",content:{"application/json":{schema:{type:"object",required:["type","title","status"],examples:[{type:"https://httpproblems.com/http-status/429",title:"Too Many Requests",status:429,instance:"/foo/bar"}],properties:{type:{type:"string",example:"https://httpproblems.com/http-status/429",description:"A URI reference that identifies the problem."},title:{type:"string",example:"Too Many Requests",description:"A short, human-readable summary of the problem."},status:{type:"number",example:429,description:"The HTTP status code."},instance:{type:"string",example:"/foo/bar"}}}}}},K={...$,headers:{"retry-after":{description:"The number of seconds to wait before making a new request.",schema:{type:"integer",example:60}}}};a.components?.responses||a.components||(a.components={}),a.components.responses={...a.components.responses,RateLimitNoRetryAfter:$,RateLimitWithRetryAfter:K},A.responses||(A.responses={});let Ne=H.some(xe=>xe.handler.options?.headerMode!=="none");A.responses[429]||(A.responses[429]={$ref:Ne?"#/components/responses/RateLimitWithRetryAfter":"#/components/responses/RateLimitNoRetryAfter"})}}),f[d]=E,f},{});return{...a,paths:c}}t(__r,"enrichSpecWithZuploData");function udt(a,s){for(let c in a)c.startsWith(s)?delete a[c]:typeof a[c]=="object"&&udt(a[c],s)}t(udt,"removePropertiesByPrefix");function p_r({relativeOpenApiPath:a},s){if(!s||typeof s!="object")throw new Tv({message:"The OpenAPI Document could not be parsed.",severity:"error"});if(!("info"in s)||typeof s.info!="object"||!s.info)throw new Tv({message:"The OpenAPI document does not have the required 'info' property.",location:{file:a,column:0,length:0,line:0,lineText:"",namespace:"",suggestion:"Add the required 'info' property. https://spec.openapis.org/oas/v3.1.0#info-object"},severity:"error"});if(!("title"in s.info)||typeof s.info.title!="string")throw new Tv({message:"The OpenAPI document does not have the required 'info.title' property.",location:{file:a,column:0,length:0,line:0,lineText:"",namespace:"",suggestion:"Add the required 'info.title' property. https://spec.openapis.org/oas/v3.1.0#info-object"},severity:"error"})}t(p_r,"assertIsZuploOpenApiSpec");function d_r(a){if(a.length>=255)throw new TypeError("Alphabet too long");let s=new Uint8Array(256);for(let M=0;M<s.length;M++)s[M]=255;for(let M=0;M<a.length;M++){let H=a.charAt(M),$=H.charCodeAt(0);if(s[$]!==255)throw new TypeError(H+" is ambiguous");s[$]=M}let c=a.length,f=a.charAt(0),d=Math.log(c)/Math.log(256),v=Math.log(256)/Math.log(c);function E(M){if(M instanceof Uint8Array||(ArrayBuffer.isView(M)?M=new Uint8Array(M.buffer,M.byteOffset,M.byteLength):Array.isArray(M)&&(M=Uint8Array.from(M))),!(M instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(M.length===0)return"";let H=0,$=0,K=0,Ne=M.length;for(;K!==Ne&&M[K]===0;)K++,H++;let xe=(Ne-K)*v+1>>>0,Te=new Uint8Array(xe);for(;K!==Ne;){let br=M[K],dr=0;for(let jr=xe-1;(br!==0||dr<$)&&jr!==-1;jr--,dr++)br+=256*Te[jr]>>>0,Te[jr]=br%c>>>0,br=br/c>>>0;if(br!==0)throw new Error("Non-zero carry");$=dr,K++}let Tt=xe-$;for(;Tt!==xe&&Te[Tt]===0;)Tt++;let Dt=f.repeat(H);for(;Tt<xe;++Tt)Dt+=a.charAt(Te[Tt]);return Dt}t(E,"encode");function A(M){if(typeof M!="string")throw new TypeError("Expected String");if(M.length===0)return new Uint8Array;let H=0,$=0,K=0;for(;M[H]===f;)$++,H++;let Ne=(M.length-H)*d+1>>>0,xe=new Uint8Array(Ne);for(;M[H];){let br=s[M.charCodeAt(H)];if(br===255)return;let dr=0;for(let jr=Ne-1;(br!==0||dr<K)&&jr!==-1;jr--,dr++)br+=c*xe[jr]>>>0,xe[jr]=br%256>>>0,br=br/256>>>0;if(br!==0)throw new Error("Non-zero carry");K=dr,H++}let Te=Ne-K;for(;Te!==Ne&&xe[Te]===0;)Te++;let Tt=new Uint8Array($+(Ne-Te)),Dt=$;for(;Te!==Ne;)Tt[Dt++]=xe[Te++];return Tt}t(A,"decodeUnsafe");function O(M){let H=A(M);if(H)return H;throw new Error("Non-base"+c+" character")}return t(O,"decode"),{encode:E,decodeUnsafe:A,decode:O}}t(d_r,"base");var fdt=d_r;var m_r="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",Vfe=fdt(m_r);var e8e="2024-09-02",_dt=Object.freeze({none:{runOutboundPoliciesOnHandlerOnAllStatuses:!1,doNotRunHooksOnSystemRoutes:!1,removeAllVendorHeadersExceptListed:!1,allowCustomPorts:!1},"2023-03-14":{runOutboundPoliciesOnHandlerOnAllStatuses:!1,doNotRunHooksOnSystemRoutes:!1,removeAllVendorHeadersExceptListed:!1,allowCustomPorts:!1},"2024-01-15":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!1},"2024-03-14":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!1},"2024-09-02":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!0}});function pdt(){return new SC({build:{ACCOUNT_NAME:"mock-account-name",PROJECT_NAME:"mock-project-name",API_VERSION:"0.0.0",BUILD_ID:crypto.randomUUID(),TIMESTAMP:new Date().toISOString(),BUILD_ENV:"test",ZUPLO_VERSION:"0.0.0",COMPATIBILITY_DATE:e8e,ENVIRONMENT_TYPE:"mock-environment-type",GIT_SHA:void 0,IS_LOCAL_DEVELOPMENT:!1,COMPATIBILITY_FLAGS:_dt[e8e]},runtime:{RUNTIME_ENV:"test",RUNTIME_STAGE:"test",__ZUPLO_DEPLOYMENT_NAME:"mock-deployment-name",__ZUPLO_LOG_LEVEL:"debug",__ZUPLO_LOG_FORMAT:"pretty",__ZUPLO_MANAGEMENT_API_URL:"",__ZUPLO_RUNTIME_TYPE:"cloudflare",__ZUPLO_AUTH_API_JWT:""}})}t(pdt,"getMockEnvironment");var SC=class a{static{t(this,"Environment")}config;static#r;static#n=!1;static initialize(s){this.#r||(this.#r=new a(s),this.#n=!0)}static get instance(){return this.#n||(console.debug("Environment has not been initialized. This is okay when running tests, a mock environment will be used."),this.#r=pdt()),this.#r}constructor({build:s,runtime:c}){let f;try{if(c.__ZUPLO_CONFIG){let d=atob(c.__ZUPLO_CONFIG);f=JSON.parse(d)}if(c.ZUPLO_SYSTEM_CONFIGURATIONS){let d=new TextDecoder().decode(Vfe.decode(c.ZUPLO_SYSTEM_CONFIGURATIONS)),v=JSON.parse(d);for(let E of Object.keys(v))c[E]||(c[E]=v[E])}}catch(d){console.error("Failed to parse runtime configuration",d)}this.config=f??{},this.build=s,this.runtime=c,this.instanceId=crypto.randomUUID()}build;runtime;instanceId;get deploymentName(){return this.runtime.__ZUPLO_DEPLOYMENT_NAME??this.config.deployment_name??void 0}get useLegacyServiceRouting(){return this.config.use_legacy_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 zudokuHostUrl(){return this.runtime.__ZUPLO_ZUDOKU_HOST_URL??this.config.zudoku_host_url??"https://zudoku.zuploedge.com"}get buildAssetsUrl(){return this.runtime.__ZUPLO_BUILD_ASSETS_URL??this.config.build_assets_url??"https://build-assets.zuplo.com"}get zuploEdgeApiUrl(){return this.config.zuplo_edge_api_url??"https://api.zuploedge.com"}get remoteLogToken(){return this.runtime.__ZUPLO_REMOTE_LOG_TOKEN??this.config.remote_log_token??void 0}get zuploClientAuthBucketId(){return this.config.zuplo_auth_client_bucket_id??"auth_o8PUdhKxSTOiB794GWPwLQCD"}get managementApiURL(){return this.runtime.__ZUPLO_MANAGEMENT_API_URL??this.config.management_api_url??"https://api.zuplo.com"}get developerApiUrl(){return this.config.developer_api_url??"https://dev.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.zuploedge.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.zuploedge.com"}get apiKeyServiceUrl(){return this.runtime.__ZUPLO_API_KEY_SERVICE_URL??this.config.api_key_service_url??"https://apikey.zuploedge.com"}get meteringServiceUrl(){return this.config.metering_service_url??"https://meters.zuploedge.com"}get authApiJWT(){return this.runtime.__ZUPLO_AUTH_API_JWT??void 0}get authClientId(){return this.runtime.__ZUPLO_AUTH_CLIENT_ID}get authClientSecret(){return this.runtime.__ZUPLO_AUTH_CLIENT_SECRET}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.IS_LOCAL_DEVELOPMENT}get isTestMode(){return!!this.runtime.__ZUPLO_TEST_MODE}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.isWorkingCopy?"working-copy":"unknown"}get isWorkingCopy(){return this.build.ENVIRONMENT_TYPE==="WORKING_COPY"}};var h_r=["ZUPLO_USER_LOGGER_DATA_DOG_API_KEY","ZUPLO_USER_LOGGER_DATA_DOG_URL","ZUPLO_LOG_LEVEL","ZUPLO_HANDLER_WRITE_LOG_LEVEL"];function ddt(a){return a.startsWith("__ZUPLO")||a.startsWith("ZUPLO_")?!h_r.includes(a)&&!a.startsWith("ZUPLO_PUBLIC_"):!1}t(ddt,"isRestrictedEnvVariableName");function mdt(a){return!!a.startsWith("ZUPLO_")}t(mdt,"isZuploReadableEnvVariableName");var jBr=new Proxy({},{get(a,s){let c=String(s);switch(c){case"ZUPLO_ENVIRONMENT_TYPE":return SC.instance.loggingEnvironmentType;case"ZUPLO_ENVIRONMENT_STAGE":return SC.instance.loggingEnvironmentStage;case"ZUPLO_ENVIRONMENT_NAME":return SC.instance.runtime.__ZUPLO_DEPLOYMENT_NAME;case"ZUPLO_ACCOUNT_NAME":return SC.instance.build.ACCOUNT_NAME;case"ZUPLO_PROJECT_NAME":return SC.instance.build.PROJECT_NAME;case"ZUPLO_BUILD_ID":return SC.instance.build.BUILD_ID}if(!(ddt(c)&&!mdt(c)))return SC.instance.runtime[c]}});function YQ(a,s,c){return`_${l6(`${a}_${s}_${c}`)}`}t(YQ,"getRawOperationDataIdentifierName");function t8e(a,s,c,f){return`_${l6(a.toLowerCase())}_${s.toLowerCase()}_${c.toLowerCase()}_${f.toLowerCase()}`}t(t8e,"getIdForParameterSchema");function r8e(a,s,c){return`_${l6(a.toLowerCase())}_${s.toLowerCase()}_rb_${l6(c.toLowerCase())}`}t(r8e,"getIdForRequestBodySchema");function XQ(a,s){return`_${l6(a)}_${l6(s)}`}t(XQ,"getIdForRefSchema");function l6(a){return a.replace(/[^a-zA-Z0-9]/g,"_")}t(l6,"sanitizedIdentifierName");var Hyt=jp(sht(),1);import gpe from"path";var dK=class{static{t(this,"R")}type=3;name="";prefix="";value="";suffix="";modifier=3;constructor(a,s,c,f,d,v){this.type=a,this.name=s,this.prefix=c,this.value=f,this.suffix=d,this.modifier=v}hasCustomName(){return this.name!==""&&typeof this.name!="number"}},cmr=/[$_\p{ID_Start}]/u,lmr=/[$_\u200C\u200D\p{ID_Continue}]/u,K8e=".*";function umr(a,s){return(s?/^[\x00-\xFF]*$/:/^[\x00-\x7F]*$/).test(a)}t(umr,"Re");function cht(a,s=!1){let c=[],f=0;for(;f<a.length;){let d=a[f],v=t(function(E){if(!s)throw new TypeError(E);c.push({type:"INVALID_CHAR",index:f,value:a[f++]})},"c");if(d==="*"){c.push({type:"ASTERISK",index:f,value:a[f++]});continue}if(d==="+"||d==="?"){c.push({type:"OTHER_MODIFIER",index:f,value:a[f++]});continue}if(d==="\\"){c.push({type:"ESCAPED_CHAR",index:f++,value:a[f++]});continue}if(d==="{"){c.push({type:"OPEN",index:f,value:a[f++]});continue}if(d==="}"){c.push({type:"CLOSE",index:f,value:a[f++]});continue}if(d===":"){let E="",A=f+1;for(;A<a.length;){let O=a.substr(A,1);if(A===f+1&&cmr.test(O)||A!==f+1&&lmr.test(O)){E+=a[A++];continue}break}if(!E){v(`Missing parameter name at ${f}`);continue}c.push({type:"NAME",index:f,value:E}),f=A;continue}if(d==="("){let E=1,A="",O=f+1,M=!1;if(a[O]==="?"){v(`Pattern cannot start with "?" at ${O}`);continue}for(;O<a.length;){if(!umr(a[O],!1)){v(`Invalid character '${a[O]}' at ${O}.`),M=!0;break}if(a[O]==="\\"){A+=a[O++]+a[O++];continue}if(a[O]===")"){if(E--,E===0){O++;break}}else if(a[O]==="("&&(E++,a[O+1]!=="?")){v(`Capturing groups are not allowed at ${O}`),M=!0;break}A+=a[O++]}if(M)continue;if(E){v(`Unbalanced pattern at ${f}`);continue}if(!A){v(`Missing pattern at ${f}`);continue}c.push({type:"REGEX",index:f,value:A}),f=O;continue}c.push({type:"CHAR",index:f,value:a[f++]})}return c.push({type:"END",index:f,value:""}),c}t(cht,"v");function lht(a,s={}){let c=cht(a);s.delimiter??="/#?",s.prefixes??="./";let f=`[^${xC(s.delimiter)}]+?`,d=[],v=0,E=0,A="",O=new Set,M=t(dr=>{if(E<c.length&&c[E].type===dr)return c[E++].value},"a"),H=t(()=>M("OTHER_MODIFIER")??M("ASTERISK"),"f"),$=t(dr=>{let jr=M(dr);if(jr!==void 0)return jr;let{type:Cr,index:pr}=c[E];throw new TypeError(`Unexpected ${Cr} at ${pr}, expected ${dr}`)},"d"),K=t(()=>{let dr="",jr;for(;jr=M("CHAR")??M("ESCAPED_CHAR");)dr+=jr;return dr},"T"),Ne=t(dr=>dr,"Se"),xe=s.encodePart||Ne,Te="",Tt=t(dr=>{Te+=dr},"U"),Dt=t(()=>{Te.length&&(d.push(new dK(3,"","",xe(Te),"",3)),Te="")},"$"),br=t((dr,jr,Cr,pr,sr)=>{let Cs=3;switch(sr){case"?":Cs=1;break;case"*":Cs=0;break;case"+":Cs=2;break}if(!jr&&!Cr&&Cs===3){Tt(dr);return}if(Dt(),!jr&&!Cr){if(!dr)return;d.push(new dK(3,"","",xe(dr),"",Cs));return}let Di;Cr?Cr==="*"?Di=K8e:Di=Cr:Di=f;let _o=2;Di===f?(_o=1,Di=""):Di===K8e&&(_o=0,Di="");let hi;if(jr?hi=jr:Cr&&(hi=v++),O.has(hi))throw new TypeError(`Duplicate name '${hi}'.`);O.add(hi),d.push(new dK(_o,hi,xe(dr),Di,xe(pr),Cs))},"V");for(;E<c.length;){let dr=M("CHAR"),jr=M("NAME"),Cr=M("REGEX");if(!jr&&!Cr&&(Cr=M("ASTERISK")),jr||Cr){let sr=dr??"";s.prefixes.indexOf(sr)===-1&&(Tt(sr),sr=""),Dt();let Cs=H();br(sr,jr,Cr,"",Cs);continue}let pr=dr??M("ESCAPED_CHAR");if(pr){Tt(pr);continue}if(M("OPEN")){let sr=K(),Cs=M("NAME"),Di=M("REGEX");!Cs&&!Di&&(Di=M("ASTERISK"));let _o=K();$("CLOSE");let hi=H();br(sr,Cs,Di,_o,hi);continue}Dt(),$("END")}return d}t(lht,"D");function xC(a){return a.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}t(xC,"S");function aht(a){return a&&a.ignoreCase?"ui":"u"}t(aht,"X");function fmr(a,s,c){return uht(lht(a,c),s,c)}t(fmr,"Z");function kB(a){switch(a){case 0:return"*";case 1:return"?";case 2:return"+";case 3:return""}}t(kB,"k");function uht(a,s,c={}){c.delimiter??="/#?",c.prefixes??="./",c.sensitive??=!1,c.strict??=!1,c.end??=!0,c.start??=!0,c.endsWith="";let f=c.start?"^":"";for(let A of a){if(A.type===3){A.modifier===3?f+=xC(A.value):f+=`(?:${xC(A.value)})${kB(A.modifier)}`;continue}s&&s.push(A.name);let O=`[^${xC(c.delimiter)}]+?`,M=A.value;if(A.type===1?M=O:A.type===0&&(M=K8e),!A.prefix.length&&!A.suffix.length){A.modifier===3||A.modifier===1?f+=`(${M})${kB(A.modifier)}`:f+=`((?:${M})${kB(A.modifier)})`;continue}if(A.modifier===3||A.modifier===1){f+=`(?:${xC(A.prefix)}(${M})${xC(A.suffix)})`,f+=kB(A.modifier);continue}f+=`(?:${xC(A.prefix)}`,f+=`((?:${M})(?:`,f+=xC(A.suffix),f+=xC(A.prefix),f+=`(?:${M}))*)${xC(A.suffix)})`,A.modifier===0&&(f+="?")}let d=`[${xC(c.endsWith)}]|$`,v=`[${xC(c.delimiter)}]`;if(c.end)return c.strict||(f+=`${v}?`),c.endsWith.length?f+=`(?=${d})`:f+="$",new RegExp(f,aht(c));c.strict||(f+=`(?:${v}(?=${d}))?`);let E=!1;if(a.length){let A=a[a.length-1];A.type===3&&A.modifier===3&&(E=c.delimiter.indexOf(A)>-1)}return E||(f+=`(?=${v}|${d})`),new RegExp(f,aht(c))}t(uht,"F");var ON={delimiter:"",prefixes:"",sensitive:!0,strict:!0},_mr={delimiter:".",prefixes:"",sensitive:!0,strict:!0},pmr={delimiter:"/",prefixes:"/",sensitive:!0,strict:!0};function dmr(a,s){return a.length?a[0]==="/"?!0:!s||a.length<2?!1:(a[0]=="\\"||a[0]=="{")&&a[1]=="/":!1}t(dmr,"J");function fht(a,s){return a.startsWith(s)?a.substring(s.length,a.length):a}t(fht,"Q");function mmr(a,s){return a.endsWith(s)?a.substr(0,a.length-s.length):a}t(mmr,"Ee");function _ht(a){return!a||a.length<2?!1:a[0]==="["||(a[0]==="\\"||a[0]==="{")&&a[1]==="["}t(_ht,"W");var pht=["ftp","file","http","https","ws","wss"];function dht(a){if(!a)return!0;for(let s of pht)if(a.test(s))return!0;return!1}t(dht,"N");function hmr(a,s){if(a=fht(a,"#"),s||a==="")return a;let c=new URL("https://example.com");return c.hash=a,c.hash?c.hash.substring(1,c.hash.length):""}t(hmr,"te");function gmr(a,s){if(a=fht(a,"?"),s||a==="")return a;let c=new URL("https://example.com");return c.search=a,c.search?c.search.substring(1,c.search.length):""}t(gmr,"re");function ymr(a,s){return s||a===""?a:_ht(a)?ght(a):hht(a)}t(ymr,"ne");function vmr(a,s){if(s||a==="")return a;let c=new URL("https://example.com");return c.password=a,c.password}t(vmr,"se");function bmr(a,s){if(s||a==="")return a;let c=new URL("https://example.com");return c.username=a,c.username}t(bmr,"ie");function Smr(a,s,c){if(c||a==="")return a;if(s&&!pht.includes(s))return new URL(`${s}:${a}`).pathname;let f=a[0]=="/";return a=new URL(f?a:"/-"+a,"https://example.com").pathname,f||(a=a.substring(2,a.length)),a}t(Smr,"ae");function Tmr(a,s,c){return mht(s)===a&&(a=""),c||a===""?a:yht(a)}t(Tmr,"oe");function Cmr(a,s){return a=mmr(a,":"),s||a===""?a:Y8e(a)}t(Cmr,"ce");function mht(a){switch(a){case"ws":case"http":return"80";case"wws":case"https":return"443";case"ftp":return"21";default:return""}}t(mht,"_");function Y8e(a){if(a==="")return a;if(/^[-+.A-Za-z0-9]*$/.test(a))return a.toLowerCase();throw new TypeError(`Invalid protocol '${a}'.`)}t(Y8e,"y");function Emr(a){if(a==="")return a;let s=new URL("https://example.com");return s.username=a,s.username}t(Emr,"le");function xmr(a){if(a==="")return a;let s=new URL("https://example.com");return s.password=a,s.password}t(xmr,"fe");function hht(a){if(a==="")return a;if(/[\t\n\r #%/:<>?@[\]^\\|]/g.test(a))throw new TypeError(`Invalid hostname '${a}'`);let s=new URL("https://example.com");return s.hostname=a,s.hostname}t(hht,"z");function ght(a){if(a==="")return a;if(/[^0-9a-fA-F[\]:]/g.test(a))throw new TypeError(`Invalid IPv6 hostname '${a}'`);return a.toLowerCase()}t(ght,"j");function yht(a){if(a===""||/^[0-9]*$/.test(a)&&parseInt(a)<=65535)return a;throw new TypeError(`Invalid port '${a}'.`)}t(yht,"K");function Dmr(a){if(a==="")return a;let s=new URL("https://example.com");return s.pathname=a[0]!=="/"?"/-"+a:a,a[0]!=="/"?s.pathname.substring(2,s.pathname.length):s.pathname}t(Dmr,"he");function Amr(a){return a===""?a:new URL(`data:${a}`).pathname}t(Amr,"ue");function kmr(a){if(a==="")return a;let s=new URL("https://example.com");return s.search=a,s.search.substring(1,s.search.length)}t(kmr,"de");function wmr(a){if(a==="")return a;let s=new URL("https://example.com");return s.hash=a,s.hash.substring(1,s.hash.length)}t(wmr,"pe");var Pmr=class{static{t(this,"H")}#r;#n=[];#e={};#t=0;#s=1;#p=0;#a=0;#_=0;#c=0;#l=!1;constructor(a){this.#r=a}get result(){return this.#e}parse(){for(this.#n=cht(this.#r,!0);this.#t<this.#n.length;this.#t+=this.#s){if(this.#s=1,this.#n[this.#t].type==="END"){if(this.#a===0){this.#v(),this.#D()?this.#i(9,1):this.#y()?this.#i(8,1):this.#i(7,0);continue}else if(this.#a===2){this.#d(5);continue}this.#i(10,0);break}if(this.#_>0)if(this.#o())this.#_-=1;else continue;if(this.#k()){this.#_+=1;continue}switch(this.#a){case 0:this.#g()&&this.#d(1);break;case 1:if(this.#g()){this.#I();let a=7,s=1;this.#x()?(a=2,s=3):this.#l&&(a=2),this.#i(a,s)}break;case 2:this.#C()?this.#d(3):(this.#E()||this.#y()||this.#D())&&this.#d(5);break;case 3:this.#b()?this.#i(4,1):this.#C()&&this.#i(5,1);break;case 4:this.#C()&&this.#i(5,1);break;case 5:this.#N()?this.#c+=1:this.#S()&&(this.#c-=1),this.#A()&&!this.#c?this.#i(6,1):this.#E()?this.#i(7,0):this.#y()?this.#i(8,1):this.#D()&&this.#i(9,1);break;case 6:this.#E()?this.#i(7,0):this.#y()?this.#i(8,1):this.#D()&&this.#i(9,1);break;case 7:this.#y()?this.#i(8,1):this.#D()&&this.#i(9,1);break;case 8:this.#D()&&this.#i(9,1);break;case 9:break;case 10:break}}this.#e.hostname!==void 0&&this.#e.port===void 0&&(this.#e.port="")}#i(a,s){switch(this.#a){case 0:break;case 1:this.#e.protocol=this.#T();break;case 2:break;case 3:this.#e.username=this.#T();break;case 4:this.#e.password=this.#T();break;case 5:this.#e.hostname=this.#T();break;case 6:this.#e.port=this.#T();break;case 7:this.#e.pathname=this.#T();break;case 8:this.#e.search=this.#T();break;case 9:this.#e.hash=this.#T();break;case 10:break}this.#a!==0&&a!==10&&([1,2,3,4].includes(this.#a)&&[6,7,8,9].includes(a)&&(this.#e.hostname??=""),[1,2,3,4,5,6].includes(this.#a)&&[8,9].includes(a)&&(this.#e.pathname??=this.#l?"/":""),[1,2,3,4,5,6,7].includes(this.#a)&&a===9&&(this.#e.search??="")),this.#f(a,s)}#f(a,s){this.#a=a,this.#p=this.#t+s,this.#t+=s,this.#s=0}#v(){this.#t=this.#p,this.#s=0}#d(a){this.#v(),this.#a=a}#u(a){return a<0&&(a=this.#n.length-a),a<this.#n.length?this.#n[a]:this.#n[this.#n.length-1]}#m(a,s){let c=this.#u(a);return c.value===s&&(c.type==="CHAR"||c.type==="ESCAPED_CHAR"||c.type==="INVALID_CHAR")}#g(){return this.#m(this.#t,":")}#x(){return this.#m(this.#t+1,"/")&&this.#m(this.#t+2,"/")}#C(){return this.#m(this.#t,"@")}#b(){return this.#m(this.#t,":")}#A(){return this.#m(this.#t,":")}#E(){return this.#m(this.#t,"/")}#y(){if(this.#m(this.#t,"?"))return!0;if(this.#n[this.#t].value!=="?")return!1;let a=this.#u(this.#t-1);return a.type!=="NAME"&&a.type!=="REGEX"&&a.type!=="CLOSE"&&a.type!=="ASTERISK"}#D(){return this.#m(this.#t,"#")}#k(){return this.#n[this.#t].type=="OPEN"}#o(){return this.#n[this.#t].type=="CLOSE"}#N(){return this.#m(this.#t,"[")}#S(){return this.#m(this.#t,"]")}#T(){let a=this.#n[this.#t],s=this.#u(this.#p).index;return this.#r.substring(s,a.index)}#I(){let a={};Object.assign(a,ON),a.encodePart=Y8e;let s=fmr(this.#T(),void 0,a);this.#l=dht(s)}},Q8e=["protocol","username","password","hostname","port","pathname","search","hash"],IN="*";function oht(a,s){if(typeof a!="string")throw new TypeError("parameter 1 is not of type 'string'.");let c=new URL(a,s);return{protocol:c.protocol.substring(0,c.protocol.length-1),username:c.username,password:c.password,hostname:c.hostname,port:c.port,pathname:c.pathname,search:c.search!==""?c.search.substring(1,c.search.length):void 0,hash:c.hash!==""?c.hash.substring(1,c.hash.length):void 0}}t(oht,"ge");function d6(a,s){return s?pK(a):a}t(d6,"b");function _K(a,s,c){let f;if(typeof s.baseURL=="string")try{f=new URL(s.baseURL),s.protocol===void 0&&(a.protocol=d6(f.protocol.substring(0,f.protocol.length-1),c)),!c&&s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.username===void 0&&(a.username=d6(f.username,c)),!c&&s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.username===void 0&&s.password===void 0&&(a.password=d6(f.password,c)),s.protocol===void 0&&s.hostname===void 0&&(a.hostname=d6(f.hostname,c)),s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&(a.port=d6(f.port,c)),s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.pathname===void 0&&(a.pathname=d6(f.pathname,c)),s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.pathname===void 0&&s.search===void 0&&(a.search=d6(f.search.substring(1,f.search.length),c)),s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.pathname===void 0&&s.search===void 0&&s.hash===void 0&&(a.hash=d6(f.hash.substring(1,f.hash.length),c))}catch{throw new TypeError(`invalid baseURL '${s.baseURL}'.`)}if(typeof s.protocol=="string"&&(a.protocol=Cmr(s.protocol,c)),typeof s.username=="string"&&(a.username=bmr(s.username,c)),typeof s.password=="string"&&(a.password=vmr(s.password,c)),typeof s.hostname=="string"&&(a.hostname=ymr(s.hostname,c)),typeof s.port=="string"&&(a.port=Tmr(s.port,a.protocol,c)),typeof s.pathname=="string"){if(a.pathname=s.pathname,f&&!dmr(a.pathname,c)){let d=f.pathname.lastIndexOf("/");d>=0&&(a.pathname=d6(f.pathname.substring(0,d+1),c)+a.pathname)}a.pathname=Smr(a.pathname,a.protocol,c)}return typeof s.search=="string"&&(a.search=gmr(s.search,c)),typeof s.hash=="string"&&(a.hash=hmr(s.hash,c)),a}t(_K,"w");function pK(a){return a.replace(/([+*?:{}()\\])/g,"\\$1")}t(pK,"C");function Nmr(a){return a.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}t(Nmr,"Oe");function Imr(a,s){s.delimiter??="/#?",s.prefixes??="./",s.sensitive??=!1,s.strict??=!1,s.end??=!0,s.start??=!0,s.endsWith="";let c=".*",f=`[^${Nmr(s.delimiter)}]+?`,d=/[$_\u200C\u200D\p{ID_Continue}]/u,v="";for(let E=0;E<a.length;++E){let A=a[E];if(A.type===3){if(A.modifier===3){v+=pK(A.value);continue}v+=`{${pK(A.value)}}${kB(A.modifier)}`;continue}let O=A.hasCustomName(),M=!!A.suffix.length||!!A.prefix.length&&(A.prefix.length!==1||!s.prefixes.includes(A.prefix)),H=E>0?a[E-1]:null,$=E<a.length-1?a[E+1]:null;if(!M&&O&&A.type===1&&A.modifier===3&&$&&!$.prefix.length&&!$.suffix.length)if($.type===3){let K=$.value.length>0?$.value[0]:"";M=d.test(K)}else M=!$.hasCustomName();if(!M&&!A.prefix.length&&H&&H.type===3){let K=H.value[H.value.length-1];M=s.prefixes.includes(K)}M&&(v+="{"),v+=pK(A.prefix),O&&(v+=`:${A.name}`),A.type===2?v+=`(${A.value})`:A.type===1?O||(v+=`(${f})`):A.type===0&&(!O&&(!H||H.type===3||H.modifier!==3||M||A.prefix!=="")?v+="*":v+=`(${c})`),A.type===1&&O&&A.suffix.length&&d.test(A.suffix[0])&&(v+="\\"),v+=pK(A.suffix),M&&(v+="}"),A.modifier!==3&&(v+=kB(A.modifier))}return v}t(Imr,"ke");var vht=class{static{t(this,"me")}#r;#n={};#e={};#t={};#s={};#p=!1;constructor(a={},s,c){try{let f;if(typeof s=="string"?f=s:c=s,typeof a=="string"){let A=new Pmr(a);if(A.parse(),a=A.result,f===void 0&&typeof a.protocol!="string")throw new TypeError("A base URL must be provided for a relative constructor string.");a.baseURL=f}else{if(!a||typeof a!="object")throw new TypeError("parameter 1 is not of type 'string' and cannot convert to dictionary.");if(f)throw new TypeError("parameter 1 is not of type 'string'.")}typeof c>"u"&&(c={ignoreCase:!1});let d={ignoreCase:c.ignoreCase===!0},v={pathname:IN,protocol:IN,username:IN,password:IN,hostname:IN,port:IN,search:IN,hash:IN};this.#r=_K(v,a,!0),mht(this.#r.protocol)===this.#r.port&&(this.#r.port="");let E;for(E of Q8e){if(!(E in this.#r))continue;let A={},O=this.#r[E];switch(this.#e[E]=[],E){case"protocol":Object.assign(A,ON),A.encodePart=Y8e;break;case"username":Object.assign(A,ON),A.encodePart=Emr;break;case"password":Object.assign(A,ON),A.encodePart=xmr;break;case"hostname":Object.assign(A,_mr),_ht(O)?A.encodePart=ght:A.encodePart=hht;break;case"port":Object.assign(A,ON),A.encodePart=yht;break;case"pathname":dht(this.#n.protocol)?(Object.assign(A,pmr,d),A.encodePart=Dmr):(Object.assign(A,ON,d),A.encodePart=Amr);break;case"search":Object.assign(A,ON,d),A.encodePart=kmr;break;case"hash":Object.assign(A,ON,d),A.encodePart=wmr;break}try{this.#s[E]=lht(O,A),this.#n[E]=uht(this.#s[E],this.#e[E],A),this.#t[E]=Imr(this.#s[E],A),this.#p=this.#p||this.#s[E].some(M=>M.type===2)}catch{throw new TypeError(`invalid ${E} pattern '${this.#r[E]}'.`)}}}catch(f){throw new TypeError(`Failed to construct 'URLPattern': ${f.message}`)}}test(a={},s){let c={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof a!="string"&&s)throw new TypeError("parameter 1 is not of type 'string'.");if(typeof a>"u")return!1;try{typeof a=="object"?c=_K(c,a,!1):c=_K(c,oht(a,s),!1)}catch{return!1}let f;for(f of Q8e)if(!this.#n[f].exec(c[f]))return!1;return!0}exec(a={},s){let c={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof a!="string"&&s)throw new TypeError("parameter 1 is not of type 'string'.");if(typeof a>"u")return;try{typeof a=="object"?c=_K(c,a,!1):c=_K(c,oht(a,s),!1)}catch{return null}let f={};s?f.inputs=[a,s]:f.inputs=[a];let d;for(d of Q8e){let v=this.#n[d].exec(c[d]);if(!v)return null;let E={};for(let[A,O]of this.#e[d].entries())if(typeof O=="string"||typeof O=="number"){let M=v[A+1];E[O]=M}f[d]={input:c[d]??"",groups:E}}return f}static compareComponent(a,s,c){let f=t((A,O)=>{for(let M of["type","modifier","prefix","value","suffix"]){if(A[M]<O[M])return-1;if(A[M]!==O[M])return 1}return 0},"o"),d=new dK(3,"","","","",3),v=new dK(0,"","","","",3),E=t((A,O)=>{let M=0;for(;M<Math.min(A.length,O.length);++M){let H=f(A[M],O[M]);if(H)return H}return A.length===O.length?0:f(A[M]??d,O[M]??d)},"s");return!s.#t[a]&&!c.#t[a]?0:s.#t[a]&&!c.#t[a]?E(s.#s[a],[v]):!s.#t[a]&&c.#t[a]?E([v],c.#s[a]):E(s.#s[a],c.#s[a])}get protocol(){return this.#t.protocol}get username(){return this.#t.username}get password(){return this.#t.password}get hostname(){return this.#t.hostname}get port(){return this.#t.port}get pathname(){return this.#t.pathname}get search(){return this.#t.search}get hash(){return this.#t.hash}get hasRegExpGroups(){return this.#p}};globalThis.URLPattern||(globalThis.URLPattern=vht);import{AssertionError as Omr}from"assert";function m6(a,s){if(a===!1)throw new Omr({message:s})}t(m6,"assert");var Jc;(function(a){a.Object="Object",a.Property="Property",a.Array="Array",a.Literal="Literal",a.TemplateString="TemplateString",a.Identifier="Identifier",a.FunctionCall="FunctionCall",a.Raw="Raw"})(Jc||(Jc={}));function wB(a){return a.type===Jc.Object}t(wB,"isAstObject");function h6(a){return a.type===Jc.Property}t(h6,"isAstProperty");function bht(a){return a.type===Jc.Array}t(bht,"isAstArray");function PB(a){return a.type===Jc.Literal}t(PB,"isAstLiteral");function l7(a){if(a===void 0)throw new Error("Node is undefined");if(!wB(a))throw new Error("Node is not object")}t(l7,"assertAstObject");import{findNodeAtLocation as Fmr,getNodeValue as Lmr,printParseErrorCode as Rmr,visit as Mmr}from"jsonc-parser";var jmr={DEFAULT:{allowTrailingComma:!1}};function mK(a,s=[],c=jmr.DEFAULT){let f={type:"array",offset:-1,length:-1,line:-1,column:-1,children:[],parent:void 0};function d(O){f.type==="property"&&(f.length=O-f.offset,f=f.parent)}t(d,"ensurePropertyComplete");function v(O){return f.children?.push(O),O}t(v,"onValue"),Mmr(a,{onObjectBegin:t((O,M,H)=>{f=v({type:"object",offset:O,length:-1,line:M+1,column:H+1,parent:f,children:[]})},"onObjectBegin"),onObjectProperty:t((O,M,H,$,K)=>{f=v({type:"property",offset:M,length:-1,line:$+1,column:K+1,parent:f,children:[]}),f.children?.push({type:"string",value:O,offset:M,length:H,line:$,column:K,parent:f})},"onObjectProperty"),onObjectEnd:t((O,M)=>{d(O+M),f.length=O+M-f.offset,f=f.parent,d(O+M)},"onObjectEnd"),onArrayBegin:t((O,M,H,$)=>{f=v({type:"array",offset:O,length:-1,line:H+1,column:$+1,parent:f,children:[]})},"onArrayBegin"),onArrayEnd:t((O,M)=>{f.length=O+M-f.offset,f=f.parent,d(O+M)},"onArrayEnd"),onLiteralValue:t((O,M,H,$,K)=>{v({type:Bmr(O),offset:M,length:H,line:$+1,column:K+1,parent:f,value:O}),d(M+H)},"onLiteralValue"),onSeparator:t((O,M)=>{f.type==="property"&&(O===":"?f.colonOffset=M:O===","&&d(M))},"onSeparator"),onError:t((O,M,H,$,K)=>{s.push({error:O,offset:M,length:H,line:$+1,column:K+1})},"onError")},c);let A=f.children[0];return A&&delete A.parent,A}t(mK,"parse");function Bmr(a){switch(typeof a){case"boolean":return"boolean";case"number":return"number";case"string":return"string";case"object":{if(a){if(Array.isArray(a))return"array"}else return"null";return"object"}default:return"null"}}t(Bmr,"getNodeType");function X8e(a,s){return Fmr(a,s)}t(X8e,"findNodeAtLocation");function hK(a){return Lmr(a)}t(hK,"getNodeValue");function Sht(a){return Rmr(a)}t(Sht,"printParseErrorCode");var gK=class{static{t(this,"AstAdapter")}parse(s){let f=mK(s,[]);if(f)return this.parseNode(f,void 0);throw new Error("Failed to parse JSON")}convert(s){return this.parseNode(s,void 0)}parseNode(s,c){switch(s.type){case"object":return this.createObject(s,c);case"array":return this.createArray(s,c);case"property":return this.createProperty(s,c);case"string":return this.createLiteral(s,c);case"number":return this.createLiteral(s,c);case"boolean":return this.createLiteral(s,c);case"null":return this.createLiteral(s,c)}}createLiteral(s,c){return{type:Jc.Literal,location:{line:s.line,column:s.column},parent:c,value:s.type==="null"?null:s.value}}createObject(s,c){let f={type:Jc.Object,children:[],parent:c,location:{line:s.line,column:s.column}};return s.children?.forEach(d=>{f.children.push(this.parseNode(d,f))}),f}createProperty(s,c){m6(s.children?.length===2,"Invalid property node");let f={type:Jc.Property,location:{line:s.line,column:s.column},parent:c,name:null,value:null};return f.name={value:s.children[0].value,location:{line:s.line,column:s.column},type:Jc.Identifier,parent:f},f.value=this.parseNode(s.children[1],f),f}createArray(s,c){let f={type:Jc.Array,location:{line:s.line,column:s.column},parent:c,children:[]};return s.children?.forEach(d=>f.children.push(this.parseNode(d,f))),f}};var Rx={createLiteral:t((a,s)=>({type:Jc.Literal,parent:s,value:a}),"createLiteral"),createTemplateString:t((a,s)=>({type:Jc.TemplateString,parent:s,value:a}),"createTemplateString"),createIdentifier:t((a,s)=>({type:Jc.Identifier,value:a,parent:s}),"createIdentifier"),createProperty:t((a,s,c)=>{let f={type:Jc.Property,parent:c,name:null,value:s};return f.name={value:a,type:Jc.Identifier,parent:f},f.value.parent=f,f},"createProperty"),createArrayOfLiterals:t((a,s)=>{let c={type:Jc.Array,parent:s,children:[]};for(let f of a)c.children.push(Rx.createLiteral(f,c));return c},"createArrayOfLiterals")};var Umr=/^[a-zA-Z_$][a-zA-Z0-9_$]*$/,yK=class{static{t(this,"SourceGenerator")}generate(s){let c=[];return this.generateSource(c,s),c.join("")}generateSource(s,c){switch(c.type){case Jc.Array:return this.generateArray(s,c);case Jc.Object:return this.generateObject(s,c);case Jc.Property:return this.generateProperty(s,c);case Jc.Literal:return this.generateLiteral(s,c);case Jc.FunctionCall:return this.generateFunctionCall(s,c);case Jc.Identifier:return this.generateIdentifier(s,c);case Jc.Raw:return this.generateRaw(s,c);case Jc.TemplateString:return this.generateTemplateString(s,c)}}generateArray(s,c){s.push("["),c.children.map(f=>{this.generateSource(s,f),s.push(",")}),s.push("]")}generateObject(s,c){s.push("{"),c.children.forEach(f=>{this.generateSource(s,f),s.push(",")}),s.push("}")}generateProperty(s,c){this.generateIdentifier(s,c.name),s.push(":"),this.generateSource(s,c.value)}generateFunctionCall(s,c){s.push(c.name.value),s.push("("),c.children.forEach((f,d,v)=>{this.generateSource(s,f),d<v.length&&s.push(",")}),s.push(")")}generateRaw(s,c){s.push(c.value)}generateTemplateString(s,c){s.push("`"),s.push(c.value.replaceAll("`","\\`")),s.push("`")}generateLiteral(s,c){if(c.value===null)return s.push("null");switch(typeof c.value){case"number":case"boolean":return s.push(`${c.value}`);case"string":{let f=c.value,d=JSON.stringify(f);return s.push(`${d}`)}}}generateIdentifier(s,c){let f=Umr.test(c.value)?c.value:`'${c.value}'`;s.push(f)}};import{parse as $mr}from"@swc/core";import Jmr from"fs/promises";var Tht=t(async a=>{let s=new Set;try{let c=await Jmr.readFile(a,"utf-8");(await $mr(c,{syntax:"typescript"})).body.forEach(d=>{d.type==="ExportDefaultDeclaration"||d.type==="ExportDefaultExpression"?s.add("default"):d.type==="ExportDeclaration"&&d.declaration.type==="FunctionDeclaration"?s.add(d.declaration.identifier.value):d.type==="ExportDeclaration"&&d.declaration.type==="VariableDeclaration"&&d.declaration.declarations[0].id.type==="Identifier"&&s.add(d.declaration.declarations[0].id.value)})}catch{return null}return s},"getJSFileExports");var Cht={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/fragments.schema.json",$defs:{corsPolicyConfiguration:{type:"object",required:["name","allowedOrigins"],additionalProperties:!1,properties:{name:{type:"string",pattern:"^[0-9a-z-]+$"},allowCredentials:{type:"boolean"},maxAge:{type:"number"},allowedOrigins:{oneOf:[{type:"array",items:{type:"string"}},{type:"string"}]},allowedMethods:{oneOf:[{type:"array",items:{$ref:"fragments.schema.json#/$defs/httpMethod"}},{type:"string"}]},allowedHeaders:{oneOf:[{type:"array",items:{type:"string"}},{type:"string"}]},exposeHeaders:{oneOf:[{type:"array",items:{type:"string"}},{type:"string"}]}}},handlerDefinition:{type:"object",properties:{module:{type:"string",pattern:"^\\$import\\([^ )]*?\\)$"},export:{type:"string"},options:{type:"object",additionalProperties:!0}},additionalProperties:!1,required:["module","export"]},httpMethod:{type:"string",enum:["GET","HEAD","POST","PUT","DELETE","CONNECT","OPTIONS","TRACE","PATCH"]}}};var Z8e={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/policies.schema.json",title:"Policies Config File",type:"object",additionalProperties:!1,properties:{policies:{type:"array",items:{$ref:"policy-configuration.schema.json"}},corsPolicies:{type:"array",items:{$ref:"fragments.schema.json#/$defs/corsPolicyConfiguration"}}}};var Eht={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/policy-configuration.schema.json",title:"Policy Configuration Fragment",type:"object",required:["name","policyType","handler"],additionalProperties:!1,properties:{name:{type:"string",pattern:"^[0-9a-z-]+$"},policyType:{type:"string"},handler:{$ref:"fragments.schema.json#/$defs/handlerDefinition"},options:{type:"object",additionalProperties:!0}}};var eOe={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/route-configuration-open-api.schema.json",title:"Open API Route Configuration Fragment",description:"These are the properties that can appear under the x-zuplo-route extension in a PathObject in Open API. It's a subset of what can appear in Zuplo's routes.json.",type:"object",required:["handler"],additionalProperties:!1,properties:{label:{type:"string",description:"An internal user-friendly identifier of the route."},key:{type:"string",deprecated:!0},handler:{$ref:"fragments.schema.json#/$defs/handlerDefinition"},corsPolicy:{type:"string",pattern:"^[0-9a-z-]+$"},custom:{},policies:{type:"object",additionalProperties:!1,properties:{inbound:{type:"array",items:{type:"string",pattern:"^[0-9a-z-]+$"}},outbound:{type:"array",items:{type:"string",pattern:"^[0-9a-z-]+$"}}}},tags:{type:"array",items:{type:"string"}}}};var tOe={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/route-configuration.schema.json",title:"Route Configuration Fragment",description:"",type:"object",required:["path","methods","handler"],additionalProperties:!1,$defs:{corsPolicy:{type:"string",pattern:"^[0-9a-z-]+$"}},properties:{operationId:{type:"string"},path:{type:"string",pattern:"^/[^\\s]*$"},methods:{type:"array",items:{$ref:"fragments.schema.json#/$defs/httpMethod"}},label:{type:"string",description:"An internal user-friendly identifier of the route."},enforceOpenApi:{type:"boolean",description:"If true, schema validation found in the OpenAPI spec will be enforced on requests/responses."},key:{type:"string",deprecated:!0},handler:{$ref:"fragments.schema.json#/$defs/handlerDefinition"},corsPolicy:{$ref:"#/$defs/corsPolicy"},custom:{},policies:{type:"object",additionalProperties:!1,properties:{inbound:{type:"array",items:{type:"string",pattern:"^[0-9a-z-]+$"}},outbound:{type:"array",items:{type:"string",pattern:"^[0-9a-z-]+$"}}}},summary:{type:"string"},description:{type:"string"},excludeFromOpenApi:{type:"boolean"},tags:{type:"array",items:{type:"string"}}}};var Myt=jp(ayt(),1),jyt=jp(Ryt(),1);var lpe=class a{static{t(this,"JsonValidator")}static#r=new a;static get instance(){return a.#r}ajv;constructor(){this.ajv=new jyt.Ajv2020({allErrors:!0,allowUnionTypes:!0}),this.ajv.addKeyword("faker"),(0,Myt.default)(this.ajv,{mode:"fast"})}addSchema(s,c){this.ajv.addSchema(s,c)}compile(s){let c=this.ajv.compile(s);return t(d=>({isValid:c(d),errors:this.toSimpleErrors(c.errors,d),warnings:[]}),"validator")}toSimpleErrors(s,c){let f=[];return s?.forEach(d=>{d.keyword==="enum"&&d.params.allowedValues&&Array.isArray(d.params.allowedValues)&&(d.message+=`; ${d.params.allowedValues.join(", ")}`),d.instancePath&&(d.instancePath=d.instancePath.replaceAll(/(\/)?(~1)(\/)?/gm,"/"));let v={details:{}},E=d.instancePath.split("/");if(E.length>2){let O=E[1],M=E[2]?parseInt(E[2]):0,H=E[3],$=isNaN(M)?void 0:c[O][M][H];v={details:{property:O,index:M,field:H,fieldValue:$}}}if(d.keyword==="required"&&d.params.missingProperty&&d.instancePath&&(d.message=`A 'path' is missing required property '${d.params.missingProperty}'`),d.keyword==="additionalProperties"&&d.params.additionalProperty&&d.instancePath&&(d.message=`A 'path' should NOT include property '${d.params.additionalProperty}'`),d.keyword==="type"&&d.params.type&&d.instancePath){let O=d.instancePath.split("/"),M=O[O.length-1];d.message=`Value of property '${M}' must be '${d.params.type}'`}let A=Object.assign(d,v);f.push(A)}),f}};var zN=lpe.instance;zN.addSchema(tOe,"route-configuration.schema.json");zN.addSchema(Eht,"policy-configuration.schema.json");zN.addSchema(Z8e,"policies.schema.json");zN.addSchema(eOe,"open-api-route-configuration.schema.json");zN.addSchema(Cht,"fragments.schema.json");var Mqr=zN.compile(tOe),Byt=zN.compile(eOe),h7e=zN.compile(Z8e);var upe=class{static{t(this,"PoliciesConfigurationValidator")}results;validate(s){return this.results=h7e(s),this.results}};var fpe=class{static{t(this,"OpenAPILocalizedValidator")}results;validate(s){return this.results=Byt(s),this.results}};import Gbr from"path";var g7e=/\$import\((.*)\)/,_pe=/\$env\((.*?)\)/g;var S6=class extends Error{static{t(this,"CodeGenError")}location;constructor(s,c,f,d){super(s),this.location={file:c,namespace:"",line:f?f.line:0,column:f?f.column:0,length:0,lineText:d??"",suggestion:""}}},Hbr=t(a=>{let s=[],c=a;for(;c.parent;)s.push(c),c=c.parent;return s.reverse()},"invertTree"),qN=t((a,s)=>{if(!a)return!1;let c=Hbr(a);return s.split("/").every((v,E)=>{let A=c[E];return A?v==="*"||h6(A)&&A.name.value===v?!0:v==="{}"?A.type===Jc.Object:v==="[]"?A.type===Jc.Array:!1:!1})},"testPosition");var ppe=class{static{t(this,"AstTransformer")}errors=[];transform(s){return this.visitor(s),s}visitor(s){this.visit(s),wB(s)?s.children.forEach(c=>{this.visitor(c)}):bht(s)?s.children.forEach(c=>{this.visitor(c)}):h6(s)&&this.visitor(s.value)}},Uyt=t((a,s,c)=>f=>{if(!h6(f)||!PB(f.value)||typeof f.value.value!="string")return;if(!a.some(v=>qN(f,v))){_pe.test(f.value.value)&&s.push(new S6("An $env() statement is not expected at this location.",c,f.location,f.value.value));return}let d=new RegExp(_pe).exec(f.value.value);if(d?.length===2&&d[0]===f.value.value){let v={type:Jc.Raw,parent:null,value:`environment["${d[1]}"]`};f.value=v}else{let v=f.value.value.replaceAll(new RegExp(_pe),(E,A)=>`\${environment["${A}"] ? environment["${A}"] : ""}`);v!==f.value.value&&(f.value=Rx.createTemplateString(v,f))}},"getEnvStatementTransformer");var YK="config/routes.json",Qbr=["handler/{}/options/*","policies/[]/{}/handler/{}/options/*","corsPolicies/[]/{}/*"],Kbr=["handler/{}/module","handler/{}/options/{}/policies/{}/inbound/[]/{}/module","handler/{}/options/{}/policies/{}/outbound/[]/{}/module","policies/[]/{}/handler/{}/module","policies/[]/{}/handler/{}/options/{}/identifier/{}/module","policies/[]/{}/handler/{}/options/{}/validator"],$yt=["handler/{}/options/*","policies/[]/{}/handler/{}/options/*"],Ybr="handler/{}/options/{}/rewritePattern",Xbr="handler/{}/options/{}/baseUrl",dpe=class extends ppe{static{t(this,"OpenAPIRoutesFragmentAstTransformer")}importCount=0;addedImports=new Map;getImportName(s){this.addedImports.has(s)||this.addedImports.set(s,`__import${this.importCount++}`);let c=this.addedImports.get(s);if(!c)throw new Error("Import name is undefined. This should not happen.");return c}getImports(){let s=[];return this.addedImports.forEach((c,f)=>{s.push({name:c,path:f})}),s}visit(s){this.rewriteHandlerFunction(s),this.rewriteForwardFunction(s),this.replaceImportStatements(s),this.replaceEnvStatements(s)}rewriteHandlerFunction(s){if(!(!h6(s)||!PB(s.value)||typeof s.value.value!="string")&&qN(s,Ybr)){if(!s.parent||!wB(s.parent)){this.errors.push(new S6("Invalid node, expected object",YK,s.parent?s.parent.location:s.location,void 0));return}let c=s.value.value,f={type:Jc.Raw,parent:null,value:Jyt(c)},d=Rx.createProperty("__rewriteFunction",f,s);s.parent.children.push(d)}}rewriteForwardFunction(s){if(!(!h6(s)||!PB(s.value)||typeof s.value.value!="string")&&qN(s,Xbr)){if(!s.parent||!wB(s.parent)){this.errors.push(new S6("Invalid node, expected object",YK,s.parent?s.parent.location:s.location,void 0));return}let c=s.value.value,f={type:Jc.Raw,parent:null,value:Jyt(c)},d=Rx.createProperty("__rewriteFunction",f,s);s.parent.children.push(d)}}replaceImportStatements(s){if(!h6(s)||!PB(s.value))return;let c=s.value.value;if(typeof c!="string")return;if(!Kbr.some(A=>qN(s,A))&&!$yt.some(A=>qN(s,A))){if(g7e.test(c)){if(s.name.value==="$ref")return;this.errors.push(new S6("An $import() statement is not expected at this location.",YK,s.location,c))}return}let f=g7e.exec(c);if($yt.some(A=>qN(s,A))&&!f)return;if(!f){this.errors.push(new S6("Invalid $import() statement",YK,s.location,c));return}let d=f[1];d.startsWith(".")&&(d=Gbr.join("..",d));let v=this.getImportName(d),E={type:Jc.Identifier,parent:s.parent,value:v};s.value=E}replaceEnvStatements=Uyt(Qbr,this.errors,YK)};function Jyt(a){return`(request, context) => {
584
+ `.trim(),v=ndt("sh",["-c",d]);process.env.DEBUG_TAR&&(v.stdout.on("data",E=>{let A=E.toString().trim();A.length>0&&console.info(A)}),v.stderr.on("data",E=>{let A=E.toString().trim();A.length>0&&console.error(A)})),v.on("close",E=>{E===0?c("Extraction completed."):f(new Error(`tar process exited with code ${E}`))}),v.on("error",E=>{f(E)})})}t(n_r,"untarFile");async function i_r(a){if(await KIe(a))return await kN.rm(a,{recursive:!0})}t(i_r,"deleteFolder");var Ml=YIe;var bC=jp(QIe(),1);import{readFile as s_r}from"fs/promises";var r7=class extends Error{static{t(this,"CustomResolveError")}},wN=class{static{t(this,"RefParser")}sourceDirectory;logger;constructor(s,c){this.sourceDirectory=s,this.logger=c}dereference(s,c){return KQ.$RefParser.dereference(s,{resolve:{json:!0,file:qfe(this.sourceDirectory,this.logger),external:!0,http:!1},dereference:{circular:"ignore",onDereference:c?.onDereference}})}bundle(s){return KQ.$RefParser.bundle(s,{resolve:{file:qfe(this.sourceDirectory,this.logger),external:!0,http:!1}})}parse(s){return KQ.$RefParser.parse(s,{resolve:{file:qfe(this.sourceDirectory,this.logger),external:!0,http:!1}})}resolve(s){return KQ.$RefParser.resolve(s,{resolve:{file:qfe(this.sourceDirectory,this.logger),external:!0,http:!1}})}};function qfe(a,s){return{order:100,canRead(c){let f=c_r(c.url);if(!(f===void 0||f==="file"))return!1;let v;try{v=odt(c.url)}catch(E){throw new r7(`Malformed URI: ${c.url}`,{cause:E})}try{Ml.safePath(a).resolve(v)}catch(E){return s?.warn(E),!1}return!0},async read(c){let f;try{f=odt(c.url)}catch(d){throw new r7(`Malformed URI: ${c.url}`,{cause:d})}try{return await s_r(f)}catch(d){throw new r7(`Error opening file "${f}"`,{cause:d})}}}}t(qfe,"customResolver");var XIe=/^win/.test(globalThis.process?globalThis.process.platform:""),a_r=/\//g,o_r=/^(\w{2,}):\/\//i,ZIe=[/%23/g,"#",/%24/g,"$",/%26/g,"&",/%2C/g,",",/%40/g,"@"];function c_r(a){let s=o_r.exec(a);if(s)return s[1].toLowerCase()}t(c_r,"getProtocol");function odt(a,s){a=decodeURI(a);for(let f=0;f<ZIe.length;f+=2)a=a.replace(ZIe[f],ZIe[f+1]);let c=a.substr(0,7).toLowerCase()==="file://";return c&&(a=a[7]==="/"?a.substr(8):a.substr(7),XIe&&a[1]==="/"&&(a=a[0]+":"+a.substr(1)),s?a="file:///"+a:(c=!1,a=XIe?a:"/"+a)),XIe&&!c&&(a=a.replace(a_r,"\\"),a.substr(1,2)===":\\"&&(a=a[0].toUpperCase()+a.substr(1))),a}t(odt,"toFileSystemPath");var cdt="YOUR_KEY_HERE";async function ldt(a){let c=await new wN(a.sourceDirectory,a.logger).bundle(a.openApiDocPath),f=a.openApiDocPath.replace(a.sourceDirectory,"");return l_r({...a,relativeOpenApiPath:f},c)}t(ldt,"buildPublicOpenApiFile");async function l_r(a,s){p_r({relativeOpenApiPath:a.relativeOpenApiPath},s);let c=s;return c=f_r(c),u_r(c,a),c=__r(c,a),udt(c,"x-zuplo"),c}t(l_r,"buildRawOpenApiFile");function u_r(a,{deploymentUrl:s,deploymentName:c,environmentType:f}){let d;s?d=new URL(s).hostname:f&&c&&(d=f===Flt.WORKING_COPY?`${c}.${FNe.ZUP_WORKING_COPY_HOSTNAME}`:`${c}.${FNe.ZUP_HOSTNAME}`),d?a.servers=[{url:`https://${d}`}]:a.servers=void 0}t(u_r,"addServerHost");function f_r(a){if(!a.paths)return a;let{components:s}=a,c=s?{...s}:void 0,f=[];c&&c.parameters&&(f=Object.entries(c.parameters).reduce((v,[E,A])=>(qj in A&&Mue(A[qj])&&(v.push(E),c.parameters&&delete c.parameters[E]),v),[]));let d=Object.entries(a.paths).reduce((v,[E,A])=>{if(!A)return v;let O={...A},M=["delete","get","head","patch","post","put","trace","options"];return M.forEach(H=>{let $=A[H];if(!$)return;if(Mue($[qj])){delete O[H];return}let{parameters:K}=$;if(!K)return;let Ne=K.filter(xe=>{if(qj in xe&&Mue(xe[qj]))return!1;if("$ref"in xe){let Te=xe.$ref.split("/").pop();return Te?!f.includes(Te):!0}return!0});O[H]={...$,parameters:Ne}}),M.some(H=>!!O[H])&&(v[E]=O),v},{});return{...a,paths:d,components:c}}t(f_r,"removeHiddenRoutesAndParams");function __r(a,{policiesConfig:s}){if(!a.paths)return a;let c=Object.entries(a.paths).reduce((f,[d,v])=>{if(!v)return f;let E={...v};return[E.delete,E.get,E.head,E.patch,E.post,E.put,E.trace,E.options].forEach(A=>{if(!A)return;let O=A["x-zuplo-route"]?.policies?.inbound?.reduce(($,K)=>{let Ne=s.policies?.find(({name:Tt})=>Tt===K);if(!Ne)return $;if(!(Ne.handler.export==="CompositeInboundPolicy"))return $.concat(K);let Te=Ne.handler.options?.policies;return Te?$.concat(Te):$},[]),M=[];if(O&&O.forEach($=>{s.policies?.forEach(K=>{K.name===$&&(K.handler.export==="ApiAuthKeyInboundPolicy"||K.handler.export==="ApiKeyInboundPolicy")&&!K.handler.options?.disableAutomaticallyAddingKeyHeaderToOpenApi&&M.push(K)})}),M.length>0){let $=M.length>0&&M[0].handler&&M[0].handler.options&&M[0].handler.options.authHeader?M[0].handler.options.authHeader:"Authorization",K=M.length>0&&M[0].handler&&M[0].handler.options&&(M[0].handler.options.authScheme||M[0].handler.options.authScheme==="")?M[0].handler.options.authScheme:"Bearer",Ne=K!==""?`${K} ${cdt}`:cdt,xe={name:$,in:"header",required:!0,example:Ne,schema:{type:"string"},description:`The \`${$}\` header is used to authenticate with the API using your API key. Value is of the format \`${Ne}\`.`};A.parameters?A.parameters.some(br=>"name"in br&&br.name===xe.name)||A.parameters.unshift(xe):A.parameters=[xe];let Te={type:"http",scheme:K.toLowerCase()},Tt="api_key";a.components?.securitySchemes?Object.values(a.components?.securitySchemes).some(br=>"name"in br&&br.type==="apiKey"||"type"in br&&br.type==="http"&&br.scheme===K)||(a.components.securitySchemes={...a.components.securitySchemes,[Tt]:Te}):(a.components||(a.components={}),a.components.securitySchemes={[Tt]:Te});let Dt={[Tt]:[]};A.security?A.security.some(br=>br[Tt]!==void 0)||A.security.unshift(Dt):A.security=[Dt]}let H=[];if(O&&O.forEach($=>{s.policies?.forEach(K=>{K.name===$&&(K.handler.export==="RateLimitInboundPolicy"||K.handler.export==="ComplexRateLimitInboundPolicy")&&H.push(K)})}),H.length>0){let $={description:"Rate Limiting Response",content:{"application/json":{schema:{type:"object",required:["type","title","status"],examples:[{type:"https://httpproblems.com/http-status/429",title:"Too Many Requests",status:429,instance:"/foo/bar"}],properties:{type:{type:"string",example:"https://httpproblems.com/http-status/429",description:"A URI reference that identifies the problem."},title:{type:"string",example:"Too Many Requests",description:"A short, human-readable summary of the problem."},status:{type:"number",example:429,description:"The HTTP status code."},instance:{type:"string",example:"/foo/bar"}}}}}},K={...$,headers:{"retry-after":{description:"The number of seconds to wait before making a new request.",schema:{type:"integer",example:60}}}};a.components?.responses||a.components||(a.components={}),a.components.responses={...a.components.responses,RateLimitNoRetryAfter:$,RateLimitWithRetryAfter:K},A.responses||(A.responses={});let Ne=H.some(xe=>xe.handler.options?.headerMode!=="none");A.responses[429]||(A.responses[429]={$ref:Ne?"#/components/responses/RateLimitWithRetryAfter":"#/components/responses/RateLimitNoRetryAfter"})}}),f[d]=E,f},{});return{...a,paths:c}}t(__r,"enrichSpecWithZuploData");function udt(a,s){for(let c in a)c.startsWith(s)?delete a[c]:typeof a[c]=="object"&&udt(a[c],s)}t(udt,"removePropertiesByPrefix");function p_r({relativeOpenApiPath:a},s){if(!s||typeof s!="object")throw new Tv({message:"The OpenAPI Document could not be parsed.",severity:"error"});if(!("info"in s)||typeof s.info!="object"||!s.info)throw new Tv({message:"The OpenAPI document does not have the required 'info' property.",location:{file:a,column:0,length:0,line:0,lineText:"",namespace:"",suggestion:"Add the required 'info' property. https://spec.openapis.org/oas/v3.1.0#info-object"},severity:"error"});if(!("title"in s.info)||typeof s.info.title!="string")throw new Tv({message:"The OpenAPI document does not have the required 'info.title' property.",location:{file:a,column:0,length:0,line:0,lineText:"",namespace:"",suggestion:"Add the required 'info.title' property. https://spec.openapis.org/oas/v3.1.0#info-object"},severity:"error"})}t(p_r,"assertIsZuploOpenApiSpec");function d_r(a){if(a.length>=255)throw new TypeError("Alphabet too long");let s=new Uint8Array(256);for(let M=0;M<s.length;M++)s[M]=255;for(let M=0;M<a.length;M++){let H=a.charAt(M),$=H.charCodeAt(0);if(s[$]!==255)throw new TypeError(H+" is ambiguous");s[$]=M}let c=a.length,f=a.charAt(0),d=Math.log(c)/Math.log(256),v=Math.log(256)/Math.log(c);function E(M){if(M instanceof Uint8Array||(ArrayBuffer.isView(M)?M=new Uint8Array(M.buffer,M.byteOffset,M.byteLength):Array.isArray(M)&&(M=Uint8Array.from(M))),!(M instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(M.length===0)return"";let H=0,$=0,K=0,Ne=M.length;for(;K!==Ne&&M[K]===0;)K++,H++;let xe=(Ne-K)*v+1>>>0,Te=new Uint8Array(xe);for(;K!==Ne;){let br=M[K],dr=0;for(let jr=xe-1;(br!==0||dr<$)&&jr!==-1;jr--,dr++)br+=256*Te[jr]>>>0,Te[jr]=br%c>>>0,br=br/c>>>0;if(br!==0)throw new Error("Non-zero carry");$=dr,K++}let Tt=xe-$;for(;Tt!==xe&&Te[Tt]===0;)Tt++;let Dt=f.repeat(H);for(;Tt<xe;++Tt)Dt+=a.charAt(Te[Tt]);return Dt}t(E,"encode");function A(M){if(typeof M!="string")throw new TypeError("Expected String");if(M.length===0)return new Uint8Array;let H=0,$=0,K=0;for(;M[H]===f;)$++,H++;let Ne=(M.length-H)*d+1>>>0,xe=new Uint8Array(Ne);for(;M[H];){let br=s[M.charCodeAt(H)];if(br===255)return;let dr=0;for(let jr=Ne-1;(br!==0||dr<K)&&jr!==-1;jr--,dr++)br+=c*xe[jr]>>>0,xe[jr]=br%256>>>0,br=br/256>>>0;if(br!==0)throw new Error("Non-zero carry");K=dr,H++}let Te=Ne-K;for(;Te!==Ne&&xe[Te]===0;)Te++;let Tt=new Uint8Array($+(Ne-Te)),Dt=$;for(;Te!==Ne;)Tt[Dt++]=xe[Te++];return Tt}t(A,"decodeUnsafe");function O(M){let H=A(M);if(H)return H;throw new Error("Non-base"+c+" character")}return t(O,"decode"),{encode:E,decodeUnsafe:A,decode:O}}t(d_r,"base");var fdt=d_r;var m_r="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",Vfe=fdt(m_r);var e8e="2024-09-02",_dt=Object.freeze({none:{runOutboundPoliciesOnHandlerOnAllStatuses:!1,doNotRunHooksOnSystemRoutes:!1,removeAllVendorHeadersExceptListed:!1,allowCustomPorts:!1},"2023-03-14":{runOutboundPoliciesOnHandlerOnAllStatuses:!1,doNotRunHooksOnSystemRoutes:!1,removeAllVendorHeadersExceptListed:!1,allowCustomPorts:!1},"2024-01-15":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!1},"2024-03-14":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!1},"2024-09-02":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!0}});function pdt(){return new SC({build:{ACCOUNT_NAME:"mock-account-name",PROJECT_NAME:"mock-project-name",API_VERSION:"0.0.0",BUILD_ID:crypto.randomUUID(),TIMESTAMP:new Date().toISOString(),BUILD_ENV:"test",ZUPLO_VERSION:"0.0.0",COMPATIBILITY_DATE:e8e,ENVIRONMENT_TYPE:"mock-environment-type",GIT_SHA:void 0,IS_LOCAL_DEVELOPMENT:!1,COMPATIBILITY_FLAGS:_dt[e8e]},runtime:{RUNTIME_ENV:"test",RUNTIME_STAGE:"test",__ZUPLO_DEPLOYMENT_NAME:"mock-deployment-name",__ZUPLO_LOG_LEVEL:"debug",__ZUPLO_LOG_FORMAT:"pretty",__ZUPLO_MANAGEMENT_API_URL:"",__ZUPLO_RUNTIME_TYPE:"cloudflare",__ZUPLO_AUTH_API_JWT:""}})}t(pdt,"getMockEnvironment");var SC=class a{static{t(this,"Environment")}config;static#r;static#n=!1;static initialize(s){this.#r||(this.#r=new a(s),this.#n=!0)}static get instance(){return this.#n||(console.debug("Environment has not been initialized. This is okay when running tests, a mock environment will be used."),this.#r=pdt()),this.#r}constructor({build:s,runtime:c}){let f;try{if(c.__ZUPLO_CONFIG){let d=atob(c.__ZUPLO_CONFIG);f=JSON.parse(d)}if(c.ZUPLO_SYSTEM_CONFIGURATIONS){let d=new TextDecoder().decode(Vfe.decode(c.ZUPLO_SYSTEM_CONFIGURATIONS)),v=JSON.parse(d);for(let E of Object.keys(v))c[E]||(c[E]=v[E])}}catch(d){console.error("Failed to parse runtime configuration",d)}this.config=f??{},this.build=s,this.runtime=c,this.instanceId=crypto.randomUUID()}build;runtime;instanceId;get deploymentName(){return this.runtime.__ZUPLO_DEPLOYMENT_NAME??this.config.deployment_name??void 0}get useLegacyServiceRouting(){return this.config.use_legacy_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 zudokuHostUrl(){return this.runtime.__ZUPLO_ZUDOKU_HOST_URL??this.config.zudoku_host_url??"https://zudoku.zuploedge.com"}get buildAssetsUrl(){return this.runtime.__ZUPLO_BUILD_ASSETS_URL??this.config.build_assets_url??"https://build-assets.zuplo.com"}get zuploEdgeApiUrl(){return this.config.zuplo_edge_api_url??"https://api.zuploedge.com"}get remoteLogToken(){return this.runtime.__ZUPLO_REMOTE_LOG_TOKEN??this.config.remote_log_token??void 0}get zuploClientAuthBucketId(){return this.config.zuplo_auth_client_bucket_id??"auth_o8PUdhKxSTOiB794GWPwLQCD"}get managementApiURL(){return this.runtime.__ZUPLO_MANAGEMENT_API_URL??this.config.management_api_url??"https://api.zuplo.com"}get developerApiUrl(){return this.config.developer_api_url??"https://dev.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.zuploedge.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.zuploedge.com"}get apiKeyServiceUrl(){return this.runtime.__ZUPLO_API_KEY_SERVICE_URL??this.config.api_key_service_url??"https://apikey.zuploedge.com"}get meteringServiceUrl(){return this.config.metering_service_url??"https://meters.zuploedge.com"}get authApiJWT(){return this.runtime.__ZUPLO_AUTH_API_JWT??void 0}get authClientId(){return this.runtime.__ZUPLO_AUTH_CLIENT_ID}get authClientSecret(){return this.runtime.__ZUPLO_AUTH_CLIENT_SECRET}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.IS_LOCAL_DEVELOPMENT}get isTestMode(){return!!this.runtime.__ZUPLO_TEST_MODE}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.isWorkingCopy?"working-copy":"unknown"}get isWorkingCopy(){return this.build.ENVIRONMENT_TYPE==="WORKING_COPY"}};var h_r=["ZUPLO_USER_LOGGER_DATA_DOG_API_KEY","ZUPLO_USER_LOGGER_DATA_DOG_URL","ZUPLO_LOG_LEVEL","ZUPLO_HANDLER_WRITE_LOG_LEVEL"];function ddt(a){return a.startsWith("__ZUPLO")||a.startsWith("ZUPLO_")?!h_r.includes(a)&&!a.startsWith("ZUPLO_PUBLIC_"):!1}t(ddt,"isRestrictedEnvVariableName");function mdt(a){return!!a.startsWith("ZUPLO_")}t(mdt,"isZuploReadableEnvVariableName");var jBr=new Proxy({},{get(a,s){let c=String(s);switch(c){case"ZUPLO_ENVIRONMENT_TYPE":return SC.instance.loggingEnvironmentType;case"ZUPLO_ENVIRONMENT_STAGE":return SC.instance.loggingEnvironmentStage;case"ZUPLO_ENVIRONMENT_NAME":return SC.instance.runtime.__ZUPLO_DEPLOYMENT_NAME;case"ZUPLO_ACCOUNT_NAME":return SC.instance.build.ACCOUNT_NAME;case"ZUPLO_PROJECT_NAME":return SC.instance.build.PROJECT_NAME;case"ZUPLO_BUILD_ID":return SC.instance.build.BUILD_ID}if(!(ddt(c)&&!mdt(c)))return SC.instance.runtime[c]}});function YQ(a,s,c){return`_${l6(`${a}_${s}_${c}`)}`}t(YQ,"getRawOperationDataIdentifierName");function t8e(a,s,c,f){return`_${l6(a.toLowerCase())}_${s.toLowerCase()}_${c.toLowerCase()}_${f.toLowerCase()}`}t(t8e,"getIdForParameterSchema");function r8e(a,s,c){return`_${l6(a.toLowerCase())}_${s.toLowerCase()}_rb_${l6(c.toLowerCase())}`}t(r8e,"getIdForRequestBodySchema");function XQ(a,s){return`_${l6(a)}_${l6(s)}`}t(XQ,"getIdForRefSchema");function l6(a){return a.replace(/[^a-zA-Z0-9]/g,"_")}t(l6,"sanitizedIdentifierName");var Hyt=jp(sht(),1);import gpe from"path";var dK=class{static{t(this,"R")}type=3;name="";prefix="";value="";suffix="";modifier=3;constructor(a,s,c,f,d,v){this.type=a,this.name=s,this.prefix=c,this.value=f,this.suffix=d,this.modifier=v}hasCustomName(){return this.name!==""&&typeof this.name!="number"}},cmr=/[$_\p{ID_Start}]/u,lmr=/[$_\u200C\u200D\p{ID_Continue}]/u,K8e=".*";function umr(a,s){return(s?/^[\x00-\xFF]*$/:/^[\x00-\x7F]*$/).test(a)}t(umr,"Re");function cht(a,s=!1){let c=[],f=0;for(;f<a.length;){let d=a[f],v=t(function(E){if(!s)throw new TypeError(E);c.push({type:"INVALID_CHAR",index:f,value:a[f++]})},"c");if(d==="*"){c.push({type:"ASTERISK",index:f,value:a[f++]});continue}if(d==="+"||d==="?"){c.push({type:"OTHER_MODIFIER",index:f,value:a[f++]});continue}if(d==="\\"){c.push({type:"ESCAPED_CHAR",index:f++,value:a[f++]});continue}if(d==="{"){c.push({type:"OPEN",index:f,value:a[f++]});continue}if(d==="}"){c.push({type:"CLOSE",index:f,value:a[f++]});continue}if(d===":"){let E="",A=f+1;for(;A<a.length;){let O=a.substr(A,1);if(A===f+1&&cmr.test(O)||A!==f+1&&lmr.test(O)){E+=a[A++];continue}break}if(!E){v(`Missing parameter name at ${f}`);continue}c.push({type:"NAME",index:f,value:E}),f=A;continue}if(d==="("){let E=1,A="",O=f+1,M=!1;if(a[O]==="?"){v(`Pattern cannot start with "?" at ${O}`);continue}for(;O<a.length;){if(!umr(a[O],!1)){v(`Invalid character '${a[O]}' at ${O}.`),M=!0;break}if(a[O]==="\\"){A+=a[O++]+a[O++];continue}if(a[O]===")"){if(E--,E===0){O++;break}}else if(a[O]==="("&&(E++,a[O+1]!=="?")){v(`Capturing groups are not allowed at ${O}`),M=!0;break}A+=a[O++]}if(M)continue;if(E){v(`Unbalanced pattern at ${f}`);continue}if(!A){v(`Missing pattern at ${f}`);continue}c.push({type:"REGEX",index:f,value:A}),f=O;continue}c.push({type:"CHAR",index:f,value:a[f++]})}return c.push({type:"END",index:f,value:""}),c}t(cht,"v");function lht(a,s={}){let c=cht(a);s.delimiter??="/#?",s.prefixes??="./";let f=`[^${xC(s.delimiter)}]+?`,d=[],v=0,E=0,A="",O=new Set,M=t(dr=>{if(E<c.length&&c[E].type===dr)return c[E++].value},"a"),H=t(()=>M("OTHER_MODIFIER")??M("ASTERISK"),"f"),$=t(dr=>{let jr=M(dr);if(jr!==void 0)return jr;let{type:Cr,index:pr}=c[E];throw new TypeError(`Unexpected ${Cr} at ${pr}, expected ${dr}`)},"d"),K=t(()=>{let dr="",jr;for(;jr=M("CHAR")??M("ESCAPED_CHAR");)dr+=jr;return dr},"T"),Ne=t(dr=>dr,"Se"),xe=s.encodePart||Ne,Te="",Tt=t(dr=>{Te+=dr},"U"),Dt=t(()=>{Te.length&&(d.push(new dK(3,"","",xe(Te),"",3)),Te="")},"$"),br=t((dr,jr,Cr,pr,sr)=>{let Cs=3;switch(sr){case"?":Cs=1;break;case"*":Cs=0;break;case"+":Cs=2;break}if(!jr&&!Cr&&Cs===3){Tt(dr);return}if(Dt(),!jr&&!Cr){if(!dr)return;d.push(new dK(3,"","",xe(dr),"",Cs));return}let Di;Cr?Cr==="*"?Di=K8e:Di=Cr:Di=f;let _o=2;Di===f?(_o=1,Di=""):Di===K8e&&(_o=0,Di="");let hi;if(jr?hi=jr:Cr&&(hi=v++),O.has(hi))throw new TypeError(`Duplicate name '${hi}'.`);O.add(hi),d.push(new dK(_o,hi,xe(dr),Di,xe(pr),Cs))},"V");for(;E<c.length;){let dr=M("CHAR"),jr=M("NAME"),Cr=M("REGEX");if(!jr&&!Cr&&(Cr=M("ASTERISK")),jr||Cr){let sr=dr??"";s.prefixes.indexOf(sr)===-1&&(Tt(sr),sr=""),Dt();let Cs=H();br(sr,jr,Cr,"",Cs);continue}let pr=dr??M("ESCAPED_CHAR");if(pr){Tt(pr);continue}if(M("OPEN")){let sr=K(),Cs=M("NAME"),Di=M("REGEX");!Cs&&!Di&&(Di=M("ASTERISK"));let _o=K();$("CLOSE");let hi=H();br(sr,Cs,Di,_o,hi);continue}Dt(),$("END")}return d}t(lht,"D");function xC(a){return a.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}t(xC,"S");function aht(a){return a&&a.ignoreCase?"ui":"u"}t(aht,"X");function fmr(a,s,c){return uht(lht(a,c),s,c)}t(fmr,"Z");function kB(a){switch(a){case 0:return"*";case 1:return"?";case 2:return"+";case 3:return""}}t(kB,"k");function uht(a,s,c={}){c.delimiter??="/#?",c.prefixes??="./",c.sensitive??=!1,c.strict??=!1,c.end??=!0,c.start??=!0,c.endsWith="";let f=c.start?"^":"";for(let A of a){if(A.type===3){A.modifier===3?f+=xC(A.value):f+=`(?:${xC(A.value)})${kB(A.modifier)}`;continue}s&&s.push(A.name);let O=`[^${xC(c.delimiter)}]+?`,M=A.value;if(A.type===1?M=O:A.type===0&&(M=K8e),!A.prefix.length&&!A.suffix.length){A.modifier===3||A.modifier===1?f+=`(${M})${kB(A.modifier)}`:f+=`((?:${M})${kB(A.modifier)})`;continue}if(A.modifier===3||A.modifier===1){f+=`(?:${xC(A.prefix)}(${M})${xC(A.suffix)})`,f+=kB(A.modifier);continue}f+=`(?:${xC(A.prefix)}`,f+=`((?:${M})(?:`,f+=xC(A.suffix),f+=xC(A.prefix),f+=`(?:${M}))*)${xC(A.suffix)})`,A.modifier===0&&(f+="?")}let d=`[${xC(c.endsWith)}]|$`,v=`[${xC(c.delimiter)}]`;if(c.end)return c.strict||(f+=`${v}?`),c.endsWith.length?f+=`(?=${d})`:f+="$",new RegExp(f,aht(c));c.strict||(f+=`(?:${v}(?=${d}))?`);let E=!1;if(a.length){let A=a[a.length-1];A.type===3&&A.modifier===3&&(E=c.delimiter.indexOf(A)>-1)}return E||(f+=`(?=${v}|${d})`),new RegExp(f,aht(c))}t(uht,"F");var ON={delimiter:"",prefixes:"",sensitive:!0,strict:!0},_mr={delimiter:".",prefixes:"",sensitive:!0,strict:!0},pmr={delimiter:"/",prefixes:"/",sensitive:!0,strict:!0};function dmr(a,s){return a.length?a[0]==="/"?!0:!s||a.length<2?!1:(a[0]=="\\"||a[0]=="{")&&a[1]=="/":!1}t(dmr,"J");function fht(a,s){return a.startsWith(s)?a.substring(s.length,a.length):a}t(fht,"Q");function mmr(a,s){return a.endsWith(s)?a.substr(0,a.length-s.length):a}t(mmr,"Ee");function _ht(a){return!a||a.length<2?!1:a[0]==="["||(a[0]==="\\"||a[0]==="{")&&a[1]==="["}t(_ht,"W");var pht=["ftp","file","http","https","ws","wss"];function dht(a){if(!a)return!0;for(let s of pht)if(a.test(s))return!0;return!1}t(dht,"N");function hmr(a,s){if(a=fht(a,"#"),s||a==="")return a;let c=new URL("https://example.com");return c.hash=a,c.hash?c.hash.substring(1,c.hash.length):""}t(hmr,"te");function gmr(a,s){if(a=fht(a,"?"),s||a==="")return a;let c=new URL("https://example.com");return c.search=a,c.search?c.search.substring(1,c.search.length):""}t(gmr,"re");function ymr(a,s){return s||a===""?a:_ht(a)?ght(a):hht(a)}t(ymr,"ne");function vmr(a,s){if(s||a==="")return a;let c=new URL("https://example.com");return c.password=a,c.password}t(vmr,"se");function bmr(a,s){if(s||a==="")return a;let c=new URL("https://example.com");return c.username=a,c.username}t(bmr,"ie");function Smr(a,s,c){if(c||a==="")return a;if(s&&!pht.includes(s))return new URL(`${s}:${a}`).pathname;let f=a[0]=="/";return a=new URL(f?a:"/-"+a,"https://example.com").pathname,f||(a=a.substring(2,a.length)),a}t(Smr,"ae");function Tmr(a,s,c){return mht(s)===a&&(a=""),c||a===""?a:yht(a)}t(Tmr,"oe");function Cmr(a,s){return a=mmr(a,":"),s||a===""?a:Y8e(a)}t(Cmr,"ce");function mht(a){switch(a){case"ws":case"http":return"80";case"wws":case"https":return"443";case"ftp":return"21";default:return""}}t(mht,"_");function Y8e(a){if(a==="")return a;if(/^[-+.A-Za-z0-9]*$/.test(a))return a.toLowerCase();throw new TypeError(`Invalid protocol '${a}'.`)}t(Y8e,"y");function Emr(a){if(a==="")return a;let s=new URL("https://example.com");return s.username=a,s.username}t(Emr,"le");function xmr(a){if(a==="")return a;let s=new URL("https://example.com");return s.password=a,s.password}t(xmr,"fe");function hht(a){if(a==="")return a;if(/[\t\n\r #%/:<>?@[\]^\\|]/g.test(a))throw new TypeError(`Invalid hostname '${a}'`);let s=new URL("https://example.com");return s.hostname=a,s.hostname}t(hht,"z");function ght(a){if(a==="")return a;if(/[^0-9a-fA-F[\]:]/g.test(a))throw new TypeError(`Invalid IPv6 hostname '${a}'`);return a.toLowerCase()}t(ght,"j");function yht(a){if(a===""||/^[0-9]*$/.test(a)&&parseInt(a)<=65535)return a;throw new TypeError(`Invalid port '${a}'.`)}t(yht,"K");function Dmr(a){if(a==="")return a;let s=new URL("https://example.com");return s.pathname=a[0]!=="/"?"/-"+a:a,a[0]!=="/"?s.pathname.substring(2,s.pathname.length):s.pathname}t(Dmr,"he");function Amr(a){return a===""?a:new URL(`data:${a}`).pathname}t(Amr,"ue");function kmr(a){if(a==="")return a;let s=new URL("https://example.com");return s.search=a,s.search.substring(1,s.search.length)}t(kmr,"de");function wmr(a){if(a==="")return a;let s=new URL("https://example.com");return s.hash=a,s.hash.substring(1,s.hash.length)}t(wmr,"pe");var Pmr=class{static{t(this,"H")}#r;#n=[];#e={};#t=0;#s=1;#p=0;#a=0;#_=0;#c=0;#l=!1;constructor(a){this.#r=a}get result(){return this.#e}parse(){for(this.#n=cht(this.#r,!0);this.#t<this.#n.length;this.#t+=this.#s){if(this.#s=1,this.#n[this.#t].type==="END"){if(this.#a===0){this.#v(),this.#D()?this.#i(9,1):this.#y()?this.#i(8,1):this.#i(7,0);continue}else if(this.#a===2){this.#d(5);continue}this.#i(10,0);break}if(this.#_>0)if(this.#o())this.#_-=1;else continue;if(this.#k()){this.#_+=1;continue}switch(this.#a){case 0:this.#g()&&this.#d(1);break;case 1:if(this.#g()){this.#I();let a=7,s=1;this.#x()?(a=2,s=3):this.#l&&(a=2),this.#i(a,s)}break;case 2:this.#C()?this.#d(3):(this.#E()||this.#y()||this.#D())&&this.#d(5);break;case 3:this.#b()?this.#i(4,1):this.#C()&&this.#i(5,1);break;case 4:this.#C()&&this.#i(5,1);break;case 5:this.#N()?this.#c+=1:this.#S()&&(this.#c-=1),this.#A()&&!this.#c?this.#i(6,1):this.#E()?this.#i(7,0):this.#y()?this.#i(8,1):this.#D()&&this.#i(9,1);break;case 6:this.#E()?this.#i(7,0):this.#y()?this.#i(8,1):this.#D()&&this.#i(9,1);break;case 7:this.#y()?this.#i(8,1):this.#D()&&this.#i(9,1);break;case 8:this.#D()&&this.#i(9,1);break;case 9:break;case 10:break}}this.#e.hostname!==void 0&&this.#e.port===void 0&&(this.#e.port="")}#i(a,s){switch(this.#a){case 0:break;case 1:this.#e.protocol=this.#T();break;case 2:break;case 3:this.#e.username=this.#T();break;case 4:this.#e.password=this.#T();break;case 5:this.#e.hostname=this.#T();break;case 6:this.#e.port=this.#T();break;case 7:this.#e.pathname=this.#T();break;case 8:this.#e.search=this.#T();break;case 9:this.#e.hash=this.#T();break;case 10:break}this.#a!==0&&a!==10&&([1,2,3,4].includes(this.#a)&&[6,7,8,9].includes(a)&&(this.#e.hostname??=""),[1,2,3,4,5,6].includes(this.#a)&&[8,9].includes(a)&&(this.#e.pathname??=this.#l?"/":""),[1,2,3,4,5,6,7].includes(this.#a)&&a===9&&(this.#e.search??="")),this.#f(a,s)}#f(a,s){this.#a=a,this.#p=this.#t+s,this.#t+=s,this.#s=0}#v(){this.#t=this.#p,this.#s=0}#d(a){this.#v(),this.#a=a}#u(a){return a<0&&(a=this.#n.length-a),a<this.#n.length?this.#n[a]:this.#n[this.#n.length-1]}#m(a,s){let c=this.#u(a);return c.value===s&&(c.type==="CHAR"||c.type==="ESCAPED_CHAR"||c.type==="INVALID_CHAR")}#g(){return this.#m(this.#t,":")}#x(){return this.#m(this.#t+1,"/")&&this.#m(this.#t+2,"/")}#C(){return this.#m(this.#t,"@")}#b(){return this.#m(this.#t,":")}#A(){return this.#m(this.#t,":")}#E(){return this.#m(this.#t,"/")}#y(){if(this.#m(this.#t,"?"))return!0;if(this.#n[this.#t].value!=="?")return!1;let a=this.#u(this.#t-1);return a.type!=="NAME"&&a.type!=="REGEX"&&a.type!=="CLOSE"&&a.type!=="ASTERISK"}#D(){return this.#m(this.#t,"#")}#k(){return this.#n[this.#t].type=="OPEN"}#o(){return this.#n[this.#t].type=="CLOSE"}#N(){return this.#m(this.#t,"[")}#S(){return this.#m(this.#t,"]")}#T(){let a=this.#n[this.#t],s=this.#u(this.#p).index;return this.#r.substring(s,a.index)}#I(){let a={};Object.assign(a,ON),a.encodePart=Y8e;let s=fmr(this.#T(),void 0,a);this.#l=dht(s)}},Q8e=["protocol","username","password","hostname","port","pathname","search","hash"],IN="*";function oht(a,s){if(typeof a!="string")throw new TypeError("parameter 1 is not of type 'string'.");let c=new URL(a,s);return{protocol:c.protocol.substring(0,c.protocol.length-1),username:c.username,password:c.password,hostname:c.hostname,port:c.port,pathname:c.pathname,search:c.search!==""?c.search.substring(1,c.search.length):void 0,hash:c.hash!==""?c.hash.substring(1,c.hash.length):void 0}}t(oht,"ge");function d6(a,s){return s?pK(a):a}t(d6,"b");function _K(a,s,c){let f;if(typeof s.baseURL=="string")try{f=new URL(s.baseURL),s.protocol===void 0&&(a.protocol=d6(f.protocol.substring(0,f.protocol.length-1),c)),!c&&s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.username===void 0&&(a.username=d6(f.username,c)),!c&&s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.username===void 0&&s.password===void 0&&(a.password=d6(f.password,c)),s.protocol===void 0&&s.hostname===void 0&&(a.hostname=d6(f.hostname,c)),s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&(a.port=d6(f.port,c)),s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.pathname===void 0&&(a.pathname=d6(f.pathname,c)),s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.pathname===void 0&&s.search===void 0&&(a.search=d6(f.search.substring(1,f.search.length),c)),s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.pathname===void 0&&s.search===void 0&&s.hash===void 0&&(a.hash=d6(f.hash.substring(1,f.hash.length),c))}catch{throw new TypeError(`invalid baseURL '${s.baseURL}'.`)}if(typeof s.protocol=="string"&&(a.protocol=Cmr(s.protocol,c)),typeof s.username=="string"&&(a.username=bmr(s.username,c)),typeof s.password=="string"&&(a.password=vmr(s.password,c)),typeof s.hostname=="string"&&(a.hostname=ymr(s.hostname,c)),typeof s.port=="string"&&(a.port=Tmr(s.port,a.protocol,c)),typeof s.pathname=="string"){if(a.pathname=s.pathname,f&&!dmr(a.pathname,c)){let d=f.pathname.lastIndexOf("/");d>=0&&(a.pathname=d6(f.pathname.substring(0,d+1),c)+a.pathname)}a.pathname=Smr(a.pathname,a.protocol,c)}return typeof s.search=="string"&&(a.search=gmr(s.search,c)),typeof s.hash=="string"&&(a.hash=hmr(s.hash,c)),a}t(_K,"w");function pK(a){return a.replace(/([+*?:{}()\\])/g,"\\$1")}t(pK,"C");function Nmr(a){return a.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}t(Nmr,"Oe");function Imr(a,s){s.delimiter??="/#?",s.prefixes??="./",s.sensitive??=!1,s.strict??=!1,s.end??=!0,s.start??=!0,s.endsWith="";let c=".*",f=`[^${Nmr(s.delimiter)}]+?`,d=/[$_\u200C\u200D\p{ID_Continue}]/u,v="";for(let E=0;E<a.length;++E){let A=a[E];if(A.type===3){if(A.modifier===3){v+=pK(A.value);continue}v+=`{${pK(A.value)}}${kB(A.modifier)}`;continue}let O=A.hasCustomName(),M=!!A.suffix.length||!!A.prefix.length&&(A.prefix.length!==1||!s.prefixes.includes(A.prefix)),H=E>0?a[E-1]:null,$=E<a.length-1?a[E+1]:null;if(!M&&O&&A.type===1&&A.modifier===3&&$&&!$.prefix.length&&!$.suffix.length)if($.type===3){let K=$.value.length>0?$.value[0]:"";M=d.test(K)}else M=!$.hasCustomName();if(!M&&!A.prefix.length&&H&&H.type===3){let K=H.value[H.value.length-1];M=s.prefixes.includes(K)}M&&(v+="{"),v+=pK(A.prefix),O&&(v+=`:${A.name}`),A.type===2?v+=`(${A.value})`:A.type===1?O||(v+=`(${f})`):A.type===0&&(!O&&(!H||H.type===3||H.modifier!==3||M||A.prefix!=="")?v+="*":v+=`(${c})`),A.type===1&&O&&A.suffix.length&&d.test(A.suffix[0])&&(v+="\\"),v+=pK(A.suffix),M&&(v+="}"),A.modifier!==3&&(v+=kB(A.modifier))}return v}t(Imr,"ke");var vht=class{static{t(this,"me")}#r;#n={};#e={};#t={};#s={};#p=!1;constructor(a={},s,c){try{let f;if(typeof s=="string"?f=s:c=s,typeof a=="string"){let A=new Pmr(a);if(A.parse(),a=A.result,f===void 0&&typeof a.protocol!="string")throw new TypeError("A base URL must be provided for a relative constructor string.");a.baseURL=f}else{if(!a||typeof a!="object")throw new TypeError("parameter 1 is not of type 'string' and cannot convert to dictionary.");if(f)throw new TypeError("parameter 1 is not of type 'string'.")}typeof c>"u"&&(c={ignoreCase:!1});let d={ignoreCase:c.ignoreCase===!0},v={pathname:IN,protocol:IN,username:IN,password:IN,hostname:IN,port:IN,search:IN,hash:IN};this.#r=_K(v,a,!0),mht(this.#r.protocol)===this.#r.port&&(this.#r.port="");let E;for(E of Q8e){if(!(E in this.#r))continue;let A={},O=this.#r[E];switch(this.#e[E]=[],E){case"protocol":Object.assign(A,ON),A.encodePart=Y8e;break;case"username":Object.assign(A,ON),A.encodePart=Emr;break;case"password":Object.assign(A,ON),A.encodePart=xmr;break;case"hostname":Object.assign(A,_mr),_ht(O)?A.encodePart=ght:A.encodePart=hht;break;case"port":Object.assign(A,ON),A.encodePart=yht;break;case"pathname":dht(this.#n.protocol)?(Object.assign(A,pmr,d),A.encodePart=Dmr):(Object.assign(A,ON,d),A.encodePart=Amr);break;case"search":Object.assign(A,ON,d),A.encodePart=kmr;break;case"hash":Object.assign(A,ON,d),A.encodePart=wmr;break}try{this.#s[E]=lht(O,A),this.#n[E]=uht(this.#s[E],this.#e[E],A),this.#t[E]=Imr(this.#s[E],A),this.#p=this.#p||this.#s[E].some(M=>M.type===2)}catch{throw new TypeError(`invalid ${E} pattern '${this.#r[E]}'.`)}}}catch(f){throw new TypeError(`Failed to construct 'URLPattern': ${f.message}`)}}test(a={},s){let c={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof a!="string"&&s)throw new TypeError("parameter 1 is not of type 'string'.");if(typeof a>"u")return!1;try{typeof a=="object"?c=_K(c,a,!1):c=_K(c,oht(a,s),!1)}catch{return!1}let f;for(f of Q8e)if(!this.#n[f].exec(c[f]))return!1;return!0}exec(a={},s){let c={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof a!="string"&&s)throw new TypeError("parameter 1 is not of type 'string'.");if(typeof a>"u")return;try{typeof a=="object"?c=_K(c,a,!1):c=_K(c,oht(a,s),!1)}catch{return null}let f={};s?f.inputs=[a,s]:f.inputs=[a];let d;for(d of Q8e){let v=this.#n[d].exec(c[d]);if(!v)return null;let E={};for(let[A,O]of this.#e[d].entries())if(typeof O=="string"||typeof O=="number"){let M=v[A+1];E[O]=M}f[d]={input:c[d]??"",groups:E}}return f}static compareComponent(a,s,c){let f=t((A,O)=>{for(let M of["type","modifier","prefix","value","suffix"]){if(A[M]<O[M])return-1;if(A[M]!==O[M])return 1}return 0},"o"),d=new dK(3,"","","","",3),v=new dK(0,"","","","",3),E=t((A,O)=>{let M=0;for(;M<Math.min(A.length,O.length);++M){let H=f(A[M],O[M]);if(H)return H}return A.length===O.length?0:f(A[M]??d,O[M]??d)},"s");return!s.#t[a]&&!c.#t[a]?0:s.#t[a]&&!c.#t[a]?E(s.#s[a],[v]):!s.#t[a]&&c.#t[a]?E([v],c.#s[a]):E(s.#s[a],c.#s[a])}get protocol(){return this.#t.protocol}get username(){return this.#t.username}get password(){return this.#t.password}get hostname(){return this.#t.hostname}get port(){return this.#t.port}get pathname(){return this.#t.pathname}get search(){return this.#t.search}get hash(){return this.#t.hash}get hasRegExpGroups(){return this.#p}};globalThis.URLPattern||(globalThis.URLPattern=vht);import{AssertionError as Omr}from"assert";function m6(a,s){if(a===!1)throw new Omr({message:s})}t(m6,"assert");var Jc;(function(a){a.Object="Object",a.Property="Property",a.Array="Array",a.Literal="Literal",a.TemplateString="TemplateString",a.Identifier="Identifier",a.FunctionCall="FunctionCall",a.Raw="Raw"})(Jc||(Jc={}));function wB(a){return a.type===Jc.Object}t(wB,"isAstObject");function h6(a){return a.type===Jc.Property}t(h6,"isAstProperty");function bht(a){return a.type===Jc.Array}t(bht,"isAstArray");function PB(a){return a.type===Jc.Literal}t(PB,"isAstLiteral");function l7(a){if(a===void 0)throw new Error("Node is undefined");if(!wB(a))throw new Error("Node is not object")}t(l7,"assertAstObject");import{findNodeAtLocation as Fmr,getNodeValue as Lmr,printParseErrorCode as Rmr,visit as Mmr}from"jsonc-parser";var jmr={DEFAULT:{allowTrailingComma:!1}};function mK(a,s=[],c=jmr.DEFAULT){let f={type:"array",offset:-1,length:-1,line:-1,column:-1,children:[],parent:void 0};function d(O){f.type==="property"&&(f.length=O-f.offset,f=f.parent)}t(d,"ensurePropertyComplete");function v(O){return f.children?.push(O),O}t(v,"onValue"),Mmr(a,{onObjectBegin:t((O,M,H)=>{f=v({type:"object",offset:O,length:-1,line:M+1,column:H+1,parent:f,children:[]})},"onObjectBegin"),onObjectProperty:t((O,M,H,$,K)=>{f=v({type:"property",offset:M,length:-1,line:$+1,column:K+1,parent:f,children:[]}),f.children?.push({type:"string",value:O,offset:M,length:H,line:$,column:K,parent:f})},"onObjectProperty"),onObjectEnd:t((O,M)=>{d(O+M),f.length=O+M-f.offset,f=f.parent,d(O+M)},"onObjectEnd"),onArrayBegin:t((O,M,H,$)=>{f=v({type:"array",offset:O,length:-1,line:H+1,column:$+1,parent:f,children:[]})},"onArrayBegin"),onArrayEnd:t((O,M)=>{f.length=O+M-f.offset,f=f.parent,d(O+M)},"onArrayEnd"),onLiteralValue:t((O,M,H,$,K)=>{v({type:Bmr(O),offset:M,length:H,line:$+1,column:K+1,parent:f,value:O}),d(M+H)},"onLiteralValue"),onSeparator:t((O,M)=>{f.type==="property"&&(O===":"?f.colonOffset=M:O===","&&d(M))},"onSeparator"),onError:t((O,M,H,$,K)=>{s.push({error:O,offset:M,length:H,line:$+1,column:K+1})},"onError")},c);let A=f.children[0];return A&&delete A.parent,A}t(mK,"parse");function Bmr(a){switch(typeof a){case"boolean":return"boolean";case"number":return"number";case"string":return"string";case"object":{if(a){if(Array.isArray(a))return"array"}else return"null";return"object"}default:return"null"}}t(Bmr,"getNodeType");function X8e(a,s){return Fmr(a,s)}t(X8e,"findNodeAtLocation");function hK(a){return Lmr(a)}t(hK,"getNodeValue");function Sht(a){return Rmr(a)}t(Sht,"printParseErrorCode");var gK=class{static{t(this,"AstAdapter")}parse(s){let f=mK(s,[]);if(f)return this.parseNode(f,void 0);throw new Error("Failed to parse JSON")}convert(s){return this.parseNode(s,void 0)}parseNode(s,c){switch(s.type){case"object":return this.createObject(s,c);case"array":return this.createArray(s,c);case"property":return this.createProperty(s,c);case"string":return this.createLiteral(s,c);case"number":return this.createLiteral(s,c);case"boolean":return this.createLiteral(s,c);case"null":return this.createLiteral(s,c)}}createLiteral(s,c){return{type:Jc.Literal,location:{line:s.line,column:s.column},parent:c,value:s.type==="null"?null:s.value}}createObject(s,c){let f={type:Jc.Object,children:[],parent:c,location:{line:s.line,column:s.column}};return s.children?.forEach(d=>{f.children.push(this.parseNode(d,f))}),f}createProperty(s,c){m6(s.children?.length===2,"Invalid property node");let f={type:Jc.Property,location:{line:s.line,column:s.column},parent:c,name:null,value:null};return f.name={value:s.children[0].value,location:{line:s.line,column:s.column},type:Jc.Identifier,parent:f},f.value=this.parseNode(s.children[1],f),f}createArray(s,c){let f={type:Jc.Array,location:{line:s.line,column:s.column},parent:c,children:[]};return s.children?.forEach(d=>f.children.push(this.parseNode(d,f))),f}};var Rx={createLiteral:t((a,s)=>({type:Jc.Literal,parent:s,value:a}),"createLiteral"),createTemplateString:t((a,s)=>({type:Jc.TemplateString,parent:s,value:a}),"createTemplateString"),createIdentifier:t((a,s)=>({type:Jc.Identifier,value:a,parent:s}),"createIdentifier"),createProperty:t((a,s,c)=>{let f={type:Jc.Property,parent:c,name:null,value:s};return f.name={value:a,type:Jc.Identifier,parent:f},f.value.parent=f,f},"createProperty"),createArrayOfLiterals:t((a,s)=>{let c={type:Jc.Array,parent:s,children:[]};for(let f of a)c.children.push(Rx.createLiteral(f,c));return c},"createArrayOfLiterals")};var Umr=/^[a-zA-Z_$][a-zA-Z0-9_$]*$/,yK=class{static{t(this,"SourceGenerator")}generate(s){let c=[];return this.generateSource(c,s),c.join("")}generateSource(s,c){switch(c.type){case Jc.Array:return this.generateArray(s,c);case Jc.Object:return this.generateObject(s,c);case Jc.Property:return this.generateProperty(s,c);case Jc.Literal:return this.generateLiteral(s,c);case Jc.FunctionCall:return this.generateFunctionCall(s,c);case Jc.Identifier:return this.generateIdentifier(s,c);case Jc.Raw:return this.generateRaw(s,c);case Jc.TemplateString:return this.generateTemplateString(s,c)}}generateArray(s,c){s.push("["),c.children.map(f=>{this.generateSource(s,f),s.push(",")}),s.push("]")}generateObject(s,c){s.push("{"),c.children.forEach(f=>{this.generateSource(s,f),s.push(",")}),s.push("}")}generateProperty(s,c){this.generateIdentifier(s,c.name),s.push(":"),this.generateSource(s,c.value)}generateFunctionCall(s,c){s.push(c.name.value),s.push("("),c.children.forEach((f,d,v)=>{this.generateSource(s,f),d<v.length&&s.push(",")}),s.push(")")}generateRaw(s,c){s.push(c.value)}generateTemplateString(s,c){s.push("`"),s.push(c.value.replaceAll("`","\\`")),s.push("`")}generateLiteral(s,c){if(c.value===null)return s.push("null");switch(typeof c.value){case"number":case"boolean":return s.push(`${c.value}`);case"string":{let f=c.value,d=JSON.stringify(f);return s.push(`${d}`)}}}generateIdentifier(s,c){let f=Umr.test(c.value)?c.value:`'${c.value}'`;s.push(f)}};import{parse as $mr}from"@swc/core";import Jmr from"fs/promises";var Tht=t(async a=>{let s=new Set;try{let c=await Jmr.readFile(a,"utf-8");(await $mr(c,{syntax:"typescript"})).body.forEach(d=>{d.type==="ExportDefaultDeclaration"||d.type==="ExportDefaultExpression"?s.add("default"):d.type==="ExportDeclaration"&&d.declaration.type==="FunctionDeclaration"?s.add(d.declaration.identifier.value):d.type==="ExportDeclaration"&&d.declaration.type==="VariableDeclaration"&&d.declaration.declarations[0].id.type==="Identifier"&&s.add(d.declaration.declarations[0].id.value)})}catch{return null}return s},"getJSFileExports");var Cht={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/fragments.schema.json",$defs:{corsPolicyConfiguration:{type:"object",required:["name","allowedOrigins"],additionalProperties:!1,properties:{name:{type:"string",pattern:"^[0-9a-z-]+$"},allowCredentials:{type:"boolean"},maxAge:{type:"number"},allowedOrigins:{oneOf:[{type:"array",items:{type:"string"}},{type:"string"}]},allowedMethods:{oneOf:[{type:"array",items:{$ref:"fragments.schema.json#/$defs/httpMethod"}},{type:"string"}]},allowedHeaders:{oneOf:[{type:"array",items:{type:"string"}},{type:"string"}]},exposeHeaders:{oneOf:[{type:"array",items:{type:"string"}},{type:"string"}]}}},handlerDefinition:{type:"object",properties:{module:{type:"string",pattern:"^\\$import\\([^ )]*?\\)$"},export:{type:"string"},options:{type:"object",additionalProperties:!0}},additionalProperties:!1,required:["module","export"]},httpMethod:{type:"string",enum:["GET","HEAD","POST","PUT","DELETE","CONNECT","OPTIONS","TRACE","PATCH"]}}};var Z8e={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/policies.schema.json",title:"Policies Config File",type:"object",additionalProperties:!1,properties:{policies:{type:"array",items:{$ref:"policy-configuration.schema.json"}},corsPolicies:{type:"array",items:{$ref:"fragments.schema.json#/$defs/corsPolicyConfiguration"}}}};var Eht={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/policy-configuration.schema.json",title:"Policy Configuration Fragment",type:"object",required:["name","policyType","handler"],additionalProperties:!1,properties:{name:{type:"string",pattern:"^[0-9a-z-]+$"},policyType:{type:"string"},handler:{$ref:"fragments.schema.json#/$defs/handlerDefinition"},options:{type:"object",additionalProperties:!0}}};var eOe={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/route-configuration-open-api.schema.json",title:"Open API Route Configuration Fragment",description:"These are the properties that can appear under the x-zuplo-route extension in a PathObject in Open API. It's a subset of what can appear in Zuplo's routes.json.",type:"object",required:["handler"],additionalProperties:!1,properties:{label:{type:"string",description:"An internal user-friendly identifier of the route."},key:{type:"string",deprecated:!0},handler:{$ref:"fragments.schema.json#/$defs/handlerDefinition"},corsPolicy:{type:"string",pattern:"^[0-9a-z-]+$"},custom:{},policies:{type:"object",additionalProperties:!1,properties:{inbound:{type:"array",items:{type:"string",pattern:"^[0-9a-z-]+$"}},outbound:{type:"array",items:{type:"string",pattern:"^[0-9a-z-]+$"}}}},tags:{type:"array",items:{type:"string"}}}};var tOe={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/route-configuration.schema.json",title:"Route Configuration Fragment",description:"",type:"object",required:["path","methods","handler"],additionalProperties:!1,$defs:{corsPolicy:{type:"string",pattern:"^[0-9a-z-]+$"}},properties:{operationId:{type:"string"},path:{type:"string",pattern:"^/[^\\s]*$"},methods:{type:"array",items:{$ref:"fragments.schema.json#/$defs/httpMethod"}},label:{type:"string",description:"An internal user-friendly identifier of the route."},enforceOpenApi:{type:"boolean",description:"If true, schema validation found in the OpenAPI spec will be enforced on requests/responses."},key:{type:"string",deprecated:!0},handler:{$ref:"fragments.schema.json#/$defs/handlerDefinition"},corsPolicy:{$ref:"#/$defs/corsPolicy"},custom:{},policies:{type:"object",additionalProperties:!1,properties:{inbound:{type:"array",items:{type:"string",pattern:"^[0-9a-z-]+$"}},outbound:{type:"array",items:{type:"string",pattern:"^[0-9a-z-]+$"}}}},summary:{type:"string"},description:{type:"string"},excludeFromOpenApi:{type:"boolean"},tags:{type:"array",items:{type:"string"}}}};var Myt=jp(ayt(),1),jyt=jp(Ryt(),1);var lpe=class a{static{t(this,"JsonValidator")}static#r=new a;static get instance(){return a.#r}ajv;constructor(){this.ajv=new jyt.Ajv2020({allErrors:!0,allowUnionTypes:!0}),this.ajv.addKeyword("faker"),(0,Myt.default)(this.ajv,{mode:"fast"})}addSchema(s,c){this.ajv.addSchema(s,c)}compile(s){let c=this.ajv.compile(s);return t(d=>({isValid:c(d),errors:this.toSimpleErrors(c.errors,d),warnings:[]}),"validator")}toSimpleErrors(s,c){let f=[];return s?.forEach(d=>{d.keyword==="enum"&&d.params.allowedValues&&Array.isArray(d.params.allowedValues)&&(d.message+=`; ${d.params.allowedValues.join(", ")}`),d.instancePath&&(d.instancePath=d.instancePath.replaceAll(/(\/)?(~1)(\/)?/gm,"/"));let v={details:{}},E=d.instancePath.split("/");if(E.length>2){let O=E[1],M=E[2]?parseInt(E[2]):0,H=E[3],$=isNaN(M)?void 0:c[O][M][H];v={details:{property:O,index:M,field:H,fieldValue:$}}}if(d.keyword==="required"&&d.params.missingProperty&&d.instancePath&&(d.message=`A 'path' is missing required property '${d.params.missingProperty}'`),d.keyword==="additionalProperties"&&d.params.additionalProperty&&d.instancePath&&(d.message=`A 'path' should NOT include property '${d.params.additionalProperty}'`),d.keyword==="type"&&d.params.type&&d.instancePath){let O=d.instancePath.split("/"),M=O[O.length-1];d.message=`Value of property '${M}' must be '${d.params.type}'`}let A=Object.assign(d,v);f.push(A)}),f}};var zN=lpe.instance;zN.addSchema(tOe,"route-configuration.schema.json");zN.addSchema(Eht,"policy-configuration.schema.json");zN.addSchema(Z8e,"policies.schema.json");zN.addSchema(eOe,"open-api-route-configuration.schema.json");zN.addSchema(Cht,"fragments.schema.json");var Mqr=zN.compile(tOe),Byt=zN.compile(eOe),h7e=zN.compile(Z8e);var upe=class{static{t(this,"PoliciesConfigurationValidator")}results;validate(s){return this.results=h7e(s),this.results}};var fpe=class{static{t(this,"OpenAPILocalizedValidator")}results;validate(s){return this.results=Byt(s),this.results}};import Gbr from"path";var g7e=/\$import\((.*)\)/,_pe=/\$env\((.*?)\)/g;var S6=class extends Error{static{t(this,"CodeGenError")}location;constructor(s,c,f,d){super(s),this.location={file:c,namespace:"",line:f?f.line:0,column:f?f.column:0,length:0,lineText:d??"",suggestion:""}}},Hbr=t(a=>{let s=[],c=a;for(;c.parent;)s.push(c),c=c.parent;return s.reverse()},"invertTree"),qN=t((a,s)=>{if(!a)return!1;let c=Hbr(a);return s.split("/").every((v,E)=>{let A=c[E];return A?v==="*"||h6(A)&&A.name.value===v?!0:v==="{}"?A.type===Jc.Object:v==="[]"?A.type===Jc.Array:!1:!1})},"testPosition");var ppe=class{static{t(this,"AstTransformer")}errors=[];transform(s){return this.visitor(s),s}visitor(s){this.visit(s),wB(s)?s.children.forEach(c=>{this.visitor(c)}):bht(s)?s.children.forEach(c=>{this.visitor(c)}):h6(s)&&this.visitor(s.value)}},Uyt=t((a,s,c)=>f=>{if(!h6(f)||!PB(f.value)||typeof f.value.value!="string")return;if(!a.some(v=>qN(f,v))){_pe.test(f.value.value)&&s.push(new S6("An $env() statement is not expected at this location.",c,f.location,f.value.value));return}let d=new RegExp(_pe).exec(f.value.value);if(d?.length===2&&d[0]===f.value.value){let v={type:Jc.Raw,parent:null,value:`environment["${d[1]}"]`};f.value=v}else{let v=f.value.value.replaceAll(new RegExp(_pe),(E,A)=>`\${environment["${A}"] ? environment["${A}"] : ""}`);v!==f.value.value&&(f.value=Rx.createTemplateString(v,f))}},"getEnvStatementTransformer");var YK="config/routes.json",Qbr=["handler/{}/options/*","policies/[]/{}/handler/{}/options/*","corsPolicies/[]/{}/*"],Kbr=["handler/{}/module","handler/{}/options/{}/policies/{}/inbound/[]/{}/module","handler/{}/options/{}/policies/{}/outbound/[]/{}/module","policies/[]/{}/handler/{}/module","policies/[]/{}/handler/{}/options/{}/identifier/{}/module","policies/[]/{}/handler/{}/options/{}/validator"],$yt=["handler/{}/options/*","policies/[]/{}/handler/{}/options/*"],Ybr="handler/{}/options/{}/rewritePattern",Xbr="handler/{}/options/{}/baseUrl",dpe=class extends ppe{static{t(this,"OpenAPIRoutesFragmentAstTransformer")}importCount=0;addedImports=new Map;getImportName(s){this.addedImports.has(s)||this.addedImports.set(s,`__import${this.importCount++}`);let c=this.addedImports.get(s);if(!c)throw new Error("Import name is undefined. This should not happen.");return c}getImports(){let s=[];return this.addedImports.forEach((c,f)=>{s.push({name:c,path:f})}),s}visit(s){this.rewriteHandlerFunction(s),this.rewriteForwardFunction(s),this.replaceImportStatements(s),this.replaceEnvStatements(s)}rewriteHandlerFunction(s){if(!(!h6(s)||!PB(s.value)||typeof s.value.value!="string")&&qN(s,Ybr)){if(!s.parent||!wB(s.parent)){this.errors.push(new S6("Invalid node, expected object",YK,s.parent?s.parent.location:s.location,void 0));return}let c=s.value.value,f={type:Jc.Raw,parent:null,value:Jyt(c)},d=Rx.createProperty("__rewriteFunction",f,s);s.parent.children.push(d)}}rewriteForwardFunction(s){if(!(!h6(s)||!PB(s.value)||typeof s.value.value!="string")&&qN(s,Xbr)){if(!s.parent||!wB(s.parent)){this.errors.push(new S6("Invalid node, expected object",YK,s.parent?s.parent.location:s.location,void 0));return}let c=s.value.value,f={type:Jc.Raw,parent:null,value:Jyt(c)},d=Rx.createProperty("__rewriteFunction",f,s);s.parent.children.push(d)}}replaceImportStatements(s){if(!h6(s)||!PB(s.value))return;let c=s.value.value;if(typeof c!="string")return;if(!Kbr.some(A=>qN(s,A))&&!$yt.some(A=>qN(s,A))){if(g7e.test(c)){if(s.name.value==="$ref")return;this.errors.push(new S6("An $import() statement is not expected at this location.",YK,s.location,c))}return}let f=g7e.exec(c);if($yt.some(A=>qN(s,A))&&!f)return;if(!f){this.errors.push(new S6("Invalid $import() statement",YK,s.location,c));return}let d=f[1];d.startsWith(".")&&(d=Gbr.join("..",d));let v=this.getImportName(d),E={type:Jc.Identifier,parent:s.parent,value:v};s.value=E}replaceEnvStatements=Uyt(Qbr,this.errors,YK)};function Jyt(a){return`(request, context) => {
585
585
  const { params, url, query, method, headers } = request;
586
586
  const { host, hostname, origin, pathname, port, search } = new URL(url);
587
587
  const e = encodeURIComponent;
package/index.minified.js CHANGED
@@ -581,7 +581,7 @@ globstar while`,s,K,c,Ne,xe),this.matchOne(s.slice(K),c.slice(Ne),f))return this
581
581
  else
582
582
  tar -xf ${a} -C ${s};
583
583
  fi
584
- `.trim(),v=ldt("sh",["-c",d]);process.env.DEBUG_TAR&&(v.stdout.on("data",E=>{let A=E.toString().trim();A.length>0&&console.info(A)}),v.stderr.on("data",E=>{let A=E.toString().trim();A.length>0&&console.error(A)})),v.on("close",E=>{E===0?c("Extraction completed."):f(new Error(`tar process exited with code ${E}`))}),v.on("error",E=>{f(E)})})}t(k_r,"untarFile");async function w_r(a){if(await r8e(a))return await PN.rm(a,{recursive:!0})}t(w_r,"deleteFolder");var Ml=n8e;var bC=W_(t8e(),1);import{readFile as P_r}from"fs/promises";var i7=class extends Error{static{t(this,"CustomResolveError")}},NN=class{static{t(this,"RefParser")}sourceDirectory;logger;constructor(s,c){this.sourceDirectory=s,this.logger=c}dereference(s,c){return KQ.$RefParser.dereference(s,{resolve:{json:!0,file:Vfe(this.sourceDirectory,this.logger),external:!0,http:!1},dereference:{circular:"ignore",onDereference:c?.onDereference}})}bundle(s){return KQ.$RefParser.bundle(s,{resolve:{file:Vfe(this.sourceDirectory,this.logger),external:!0,http:!1}})}parse(s){return KQ.$RefParser.parse(s,{resolve:{file:Vfe(this.sourceDirectory,this.logger),external:!0,http:!1}})}resolve(s){return KQ.$RefParser.resolve(s,{resolve:{file:Vfe(this.sourceDirectory,this.logger),external:!0,http:!1}})}};function Vfe(a,s){return{order:100,canRead(c){let f=O_r(c.url);if(!(f===void 0||f==="file"))return!1;let v;try{v=pdt(c.url)}catch(E){throw new i7(`Malformed URI: ${c.url}`,{cause:E})}try{Ml.safePath(a).resolve(v)}catch(E){return s?.warn(E),!1}return!0},async read(c){let f;try{f=pdt(c.url)}catch(d){throw new i7(`Malformed URI: ${c.url}`,{cause:d})}try{return await P_r(f)}catch(d){throw new i7(`Error opening file "${f}"`,{cause:d})}}}}t(Vfe,"customResolver");var i8e=/^win/.test(globalThis.process?globalThis.process.platform:""),N_r=/\//g,I_r=/^(\w{2,}):\/\//i,s8e=[/%23/g,"#",/%24/g,"$",/%26/g,"&",/%2C/g,",",/%40/g,"@"];function O_r(a){let s=I_r.exec(a);if(s)return s[1].toLowerCase()}t(O_r,"getProtocol");function pdt(a,s){a=decodeURI(a);for(let f=0;f<s8e.length;f+=2)a=a.replace(s8e[f],s8e[f+1]);let c=a.substr(0,7).toLowerCase()==="file://";return c&&(a=a[7]==="/"?a.substr(8):a.substr(7),i8e&&a[1]==="/"&&(a=a[0]+":"+a.substr(1)),s?a="file:///"+a:(c=!1,a=i8e?a:"/"+a)),i8e&&!c&&(a=a.replace(N_r,"\\"),a.substr(1,2)===":\\"&&(a=a[0].toUpperCase()+a.substr(1))),a}t(pdt,"toFileSystemPath");var ddt="YOUR_KEY_HERE";async function mdt(a){let c=await new NN(a.sourceDirectory,a.logger).bundle(a.openApiDocPath),f=a.openApiDocPath.replace(a.sourceDirectory,"");return F_r({...a,relativeOpenApiPath:f},c)}t(mdt,"buildPublicOpenApiFile");async function F_r(a,s){j_r({relativeOpenApiPath:a.relativeOpenApiPath},s);let c=s;return c=R_r(c),L_r(c,a),c=M_r(c,a),hdt(c,"x-zuplo"),c}t(F_r,"buildRawOpenApiFile");function L_r(a,{deploymentUrl:s,deploymentName:c,environmentType:f}){let d;s?d=s.hostname:f&&c&&(d=f===Jlt.WORKING_COPY?`${c}.${UNe.ZUP_WORKING_COPY_HOSTNAME}`:`${c}.${UNe.ZUP_HOSTNAME}`),d?a.servers=[{url:`https://${d}`}]:a.servers=void 0}t(L_r,"addServerHost");function R_r(a){if(!a.paths)return a;let{components:s}=a,c=s?{...s}:void 0,f=[];c&&c.parameters&&(f=Object.entries(c.parameters).reduce((v,[E,A])=>(Wj in A&&jue(A[Wj])&&(v.push(E),c.parameters&&delete c.parameters[E]),v),[]));let d=Object.entries(a.paths).reduce((v,[E,A])=>{if(!A)return v;let O={...A},M=["delete","get","head","patch","post","put","trace","options"];return M.forEach(H=>{let $=A[H];if(!$)return;if(jue($[Wj])){delete O[H];return}let{parameters:K}=$;if(!K)return;let Ne=K.filter(xe=>{if(Wj in xe&&jue(xe[Wj]))return!1;if("$ref"in xe){let Te=xe.$ref.split("/").pop();return Te?!f.includes(Te):!0}return!0});O[H]={...$,parameters:Ne}}),M.some(H=>!!O[H])&&(v[E]=O),v},{});return{...a,paths:d,components:c}}t(R_r,"removeHiddenRoutesAndParams");function M_r(a,{policiesConfig:s}){if(!a.paths)return a;let c=Object.entries(a.paths).reduce((f,[d,v])=>{if(!v)return f;let E={...v};return[E.delete,E.get,E.head,E.patch,E.post,E.put,E.trace,E.options].forEach(A=>{if(!A)return;let O=A["x-zuplo-route"]?.policies?.inbound?.reduce(($,K)=>{let Ne=s.policies?.find(({name:Tt})=>Tt===K);if(!Ne)return $;if(!(Ne.handler.export==="CompositeInboundPolicy"))return $.concat(K);let Te=Ne.handler.options?.policies;return Te?$.concat(Te):$},[]),M=[];if(O&&O.forEach($=>{s.policies?.forEach(K=>{K.name===$&&(K.handler.export==="ApiAuthKeyInboundPolicy"||K.handler.export==="ApiKeyInboundPolicy")&&!K.handler.options?.disableAutomaticallyAddingKeyHeaderToOpenApi&&M.push(K)})}),M.length>0){let $=M.length>0&&M[0].handler&&M[0].handler.options&&M[0].handler.options.authHeader?M[0].handler.options.authHeader:"Authorization",K=M.length>0&&M[0].handler&&M[0].handler.options&&(M[0].handler.options.authScheme||M[0].handler.options.authScheme==="")?M[0].handler.options.authScheme:"Bearer",Ne=K!==""?`${K} ${ddt}`:ddt,xe={name:$,in:"header",required:!0,example:Ne,schema:{type:"string"},description:`The \`${$}\` header is used to authenticate with the API using your API key. Value is of the format \`${Ne}\`.`};A.parameters?A.parameters.some(br=>"name"in br&&br.name===xe.name)||A.parameters.unshift(xe):A.parameters=[xe];let Te={type:"http",scheme:K.toLowerCase()},Tt="api_key";a.components?.securitySchemes?Object.values(a.components?.securitySchemes).some(br=>"name"in br&&br.type==="apiKey"||"type"in br&&br.type==="http"&&br.scheme===K)||(a.components.securitySchemes={...a.components.securitySchemes,[Tt]:Te}):(a.components||(a.components={}),a.components.securitySchemes={[Tt]:Te});let Dt={[Tt]:[]};A.security?A.security.some(br=>br[Tt]!==void 0)||A.security.unshift(Dt):A.security=[Dt]}let H=[];if(O&&O.forEach($=>{s.policies?.forEach(K=>{K.name===$&&(K.handler.export==="RateLimitInboundPolicy"||K.handler.export==="ComplexRateLimitInboundPolicy")&&H.push(K)})}),H.length>0){let $={description:"Rate Limiting Response",content:{"application/json":{schema:{type:"object",required:["type","title","status"],examples:[{type:"https://httpproblems.com/http-status/429",title:"Too Many Requests",status:429,instance:"/foo/bar"}],properties:{type:{type:"string",example:"https://httpproblems.com/http-status/429",description:"A URI reference that identifies the problem."},title:{type:"string",example:"Too Many Requests",description:"A short, human-readable summary of the problem."},status:{type:"number",example:429,description:"The HTTP status code."},instance:{type:"string",example:"/foo/bar"}}}}}},K={...$,headers:{"retry-after":{description:"The number of seconds to wait before making a new request.",schema:{type:"integer",example:60}}}};a.components?.responses||a.components||(a.components={}),a.components.responses={...a.components.responses,RateLimitNoRetryAfter:$,RateLimitWithRetryAfter:K},A.responses||(A.responses={});let Ne=H.some(xe=>xe.handler.options?.headerMode!=="none");A.responses[429]||(A.responses[429]={$ref:Ne?"#/components/responses/RateLimitWithRetryAfter":"#/components/responses/RateLimitNoRetryAfter"})}}),f[d]=E,f},{});return{...a,paths:c}}t(M_r,"enrichSpecWithZuploData");function hdt(a,s){for(let c in a)c.startsWith(s)?delete a[c]:typeof a[c]=="object"&&hdt(a[c],s)}t(hdt,"removePropertiesByPrefix");function j_r({relativeOpenApiPath:a},s){if(!s||typeof s!="object")throw new Tv({message:"The OpenAPI Document could not be parsed.",severity:"error"});if(!("info"in s)||typeof s.info!="object"||!s.info)throw new Tv({message:"The OpenAPI document does not have the required 'info' property.",location:{file:a,column:0,length:0,line:0,lineText:"",namespace:"",suggestion:"Add the required 'info' property. https://spec.openapis.org/oas/v3.1.0#info-object"},severity:"error"});if(!("title"in s.info)||typeof s.info.title!="string")throw new Tv({message:"The OpenAPI document does not have the required 'info.title' property.",location:{file:a,column:0,length:0,line:0,lineText:"",namespace:"",suggestion:"Add the required 'info.title' property. https://spec.openapis.org/oas/v3.1.0#info-object"},severity:"error"})}t(j_r,"assertIsZuploOpenApiSpec");function B_r(a){if(a.length>=255)throw new TypeError("Alphabet too long");let s=new Uint8Array(256);for(let M=0;M<s.length;M++)s[M]=255;for(let M=0;M<a.length;M++){let H=a.charAt(M),$=H.charCodeAt(0);if(s[$]!==255)throw new TypeError(H+" is ambiguous");s[$]=M}let c=a.length,f=a.charAt(0),d=Math.log(c)/Math.log(256),v=Math.log(256)/Math.log(c);function E(M){if(M instanceof Uint8Array||(ArrayBuffer.isView(M)?M=new Uint8Array(M.buffer,M.byteOffset,M.byteLength):Array.isArray(M)&&(M=Uint8Array.from(M))),!(M instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(M.length===0)return"";let H=0,$=0,K=0,Ne=M.length;for(;K!==Ne&&M[K]===0;)K++,H++;let xe=(Ne-K)*v+1>>>0,Te=new Uint8Array(xe);for(;K!==Ne;){let br=M[K],dr=0;for(let jr=xe-1;(br!==0||dr<$)&&jr!==-1;jr--,dr++)br+=256*Te[jr]>>>0,Te[jr]=br%c>>>0,br=br/c>>>0;if(br!==0)throw new Error("Non-zero carry");$=dr,K++}let Tt=xe-$;for(;Tt!==xe&&Te[Tt]===0;)Tt++;let Dt=f.repeat(H);for(;Tt<xe;++Tt)Dt+=a.charAt(Te[Tt]);return Dt}t(E,"encode");function A(M){if(typeof M!="string")throw new TypeError("Expected String");if(M.length===0)return new Uint8Array;let H=0,$=0,K=0;for(;M[H]===f;)$++,H++;let Ne=(M.length-H)*d+1>>>0,xe=new Uint8Array(Ne);for(;M[H];){let br=s[M.charCodeAt(H)];if(br===255)return;let dr=0;for(let jr=Ne-1;(br!==0||dr<K)&&jr!==-1;jr--,dr++)br+=c*xe[jr]>>>0,xe[jr]=br%256>>>0,br=br/256>>>0;if(br!==0)throw new Error("Non-zero carry");K=dr,H++}let Te=Ne-K;for(;Te!==Ne&&xe[Te]===0;)Te++;let Tt=new Uint8Array($+(Ne-Te)),Dt=$;for(;Te!==Ne;)Tt[Dt++]=xe[Te++];return Tt}t(A,"decodeUnsafe");function O(M){let H=A(M);if(H)return H;throw new Error("Non-base"+c+" character")}return t(O,"decode"),{encode:E,decodeUnsafe:A,decode:O}}t(B_r,"base");var gdt=B_r;var U_r="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",Wfe=gdt(U_r);var a8e="2024-09-02",ydt=Object.freeze({none:{runOutboundPoliciesOnHandlerOnAllStatuses:!1,doNotRunHooksOnSystemRoutes:!1,removeAllVendorHeadersExceptListed:!1,allowCustomPorts:!1},"2023-03-14":{runOutboundPoliciesOnHandlerOnAllStatuses:!1,doNotRunHooksOnSystemRoutes:!1,removeAllVendorHeadersExceptListed:!1,allowCustomPorts:!1},"2024-01-15":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!1},"2024-03-14":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!1},"2024-09-02":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!0}});function vdt(){return new SC({build:{ACCOUNT_NAME:"mock-account-name",PROJECT_NAME:"mock-project-name",API_VERSION:"0.0.0",BUILD_ID:crypto.randomUUID(),TIMESTAMP:new Date().toISOString(),BUILD_ENV:"test",ZUPLO_VERSION:"0.0.0",COMPATIBILITY_DATE:a8e,ENVIRONMENT_TYPE:"mock-environment-type",GIT_SHA:void 0,IS_LOCAL_DEVELOPMENT:!1,COMPATIBILITY_FLAGS:ydt[a8e]},runtime:{RUNTIME_ENV:"test",RUNTIME_STAGE:"test",__ZUPLO_DEPLOYMENT_NAME:"mock-deployment-name",__ZUPLO_LOG_LEVEL:"debug",__ZUPLO_LOG_FORMAT:"pretty",__ZUPLO_MANAGEMENT_API_URL:"",__ZUPLO_RUNTIME_TYPE:"cloudflare",__ZUPLO_AUTH_API_JWT:""}})}t(vdt,"getMockEnvironment");var SC=class a{static{t(this,"Environment")}config;static#r;static#n=!1;static initialize(s){this.#r||(this.#r=new a(s),this.#n=!0)}static get instance(){return this.#n||(console.debug("Environment has not been initialized. This is okay when running tests, a mock environment will be used."),this.#r=vdt()),this.#r}constructor({build:s,runtime:c}){let f;try{if(c.__ZUPLO_CONFIG){let d=atob(c.__ZUPLO_CONFIG);f=JSON.parse(d)}if(c.ZUPLO_SYSTEM_CONFIGURATIONS){let d=new TextDecoder().decode(Wfe.decode(c.ZUPLO_SYSTEM_CONFIGURATIONS)),v=JSON.parse(d);for(let E of Object.keys(v))c[E]||(c[E]=v[E])}}catch(d){console.error("Failed to parse runtime configuration",d)}this.config=f??{},this.build=s,this.runtime=c,this.instanceId=crypto.randomUUID()}build;runtime;instanceId;get deploymentName(){return this.runtime.__ZUPLO_DEPLOYMENT_NAME??this.config.deployment_name??void 0}get useLegacyServiceRouting(){return this.config.use_legacy_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 zudokuHostUrl(){return this.runtime.__ZUPLO_ZUDOKU_HOST_URL??this.config.zudoku_host_url??"https://zudoku.zuploedge.com"}get buildAssetsUrl(){return this.runtime.__ZUPLO_BUILD_ASSETS_URL??this.config.build_assets_url??"https://build-assets.zuplo.com"}get zuploEdgeApiUrl(){return this.config.zuplo_edge_api_url??"https://api.zuploedge.com"}get remoteLogToken(){return this.runtime.__ZUPLO_REMOTE_LOG_TOKEN??this.config.remote_log_token??void 0}get zuploClientAuthBucketId(){return this.config.zuplo_auth_client_bucket_id??"auth_o8PUdhKxSTOiB794GWPwLQCD"}get managementApiURL(){return this.runtime.__ZUPLO_MANAGEMENT_API_URL??this.config.management_api_url??"https://api.zuplo.com"}get developerApiUrl(){return this.config.developer_api_url??"https://dev.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.zuploedge.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.zuploedge.com"}get apiKeyServiceUrl(){return this.runtime.__ZUPLO_API_KEY_SERVICE_URL??this.config.api_key_service_url??"https://apikey.zuploedge.com"}get meteringServiceUrl(){return this.config.metering_service_url??"https://meters.zuploedge.com"}get authApiJWT(){return this.runtime.__ZUPLO_AUTH_API_JWT??void 0}get authClientId(){return this.runtime.__ZUPLO_AUTH_CLIENT_ID}get authClientSecret(){return this.runtime.__ZUPLO_AUTH_CLIENT_SECRET}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.IS_LOCAL_DEVELOPMENT}get isTestMode(){return!!this.runtime.__ZUPLO_TEST_MODE}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.isWorkingCopy?"working-copy":"unknown"}get isWorkingCopy(){return this.build.ENVIRONMENT_TYPE==="WORKING_COPY"}};var $_r=["ZUPLO_USER_LOGGER_DATA_DOG_API_KEY","ZUPLO_USER_LOGGER_DATA_DOG_URL","ZUPLO_LOG_LEVEL","ZUPLO_HANDLER_WRITE_LOG_LEVEL"];function bdt(a){return a.startsWith("__ZUPLO")||a.startsWith("ZUPLO_")?!$_r.includes(a)&&!a.startsWith("ZUPLO_PUBLIC_"):!1}t(bdt,"isRestrictedEnvVariableName");function Sdt(a){return!!a.startsWith("ZUPLO_")}t(Sdt,"isZuploReadableEnvVariableName");var oUr=new Proxy({},{get(a,s){let c=String(s);switch(c){case"ZUPLO_ENVIRONMENT_TYPE":return SC.instance.loggingEnvironmentType;case"ZUPLO_ENVIRONMENT_STAGE":return SC.instance.loggingEnvironmentStage;case"ZUPLO_ENVIRONMENT_NAME":return SC.instance.runtime.__ZUPLO_DEPLOYMENT_NAME;case"ZUPLO_ACCOUNT_NAME":return SC.instance.build.ACCOUNT_NAME;case"ZUPLO_PROJECT_NAME":return SC.instance.build.PROJECT_NAME;case"ZUPLO_BUILD_ID":return SC.instance.build.BUILD_ID}if(!(bdt(c)&&!Sdt(c)))return SC.instance.runtime[c]}});function YQ(a,s,c){return`_${_6(`${a}_${s}_${c}`)}`}t(YQ,"getRawOperationDataIdentifierName");function o8e(a,s,c,f){return`_${_6(a.toLowerCase())}_${s.toLowerCase()}_${c.toLowerCase()}_${f.toLowerCase()}`}t(o8e,"getIdForParameterSchema");function c8e(a,s,c){return`_${_6(a.toLowerCase())}_${s.toLowerCase()}_rb_${_6(c.toLowerCase())}`}t(c8e,"getIdForRequestBodySchema");function XQ(a,s){return`_${_6(a)}_${_6(s)}`}t(XQ,"getIdForRefSchema");function _6(a){return a.replace(/[^a-zA-Z0-9]/g,"_")}t(_6,"sanitizedIdentifierName");var Zyt=W_(fht(),1);import ype from"path";var dK=class{static{t(this,"R")}type=3;name="";prefix="";value="";suffix="";modifier=3;constructor(a,s,c,f,d,v){this.type=a,this.name=s,this.prefix=c,this.value=f,this.suffix=d,this.modifier=v}hasCustomName(){return this.name!==""&&typeof this.name!="number"}},Omr=/[$_\p{ID_Start}]/u,Fmr=/[$_\u200C\u200D\p{ID_Continue}]/u,rOe=".*";function Lmr(a,s){return(s?/^[\x00-\xFF]*$/:/^[\x00-\x7F]*$/).test(a)}t(Lmr,"Re");function dht(a,s=!1){let c=[],f=0;for(;f<a.length;){let d=a[f],v=t(function(E){if(!s)throw new TypeError(E);c.push({type:"INVALID_CHAR",index:f,value:a[f++]})},"c");if(d==="*"){c.push({type:"ASTERISK",index:f,value:a[f++]});continue}if(d==="+"||d==="?"){c.push({type:"OTHER_MODIFIER",index:f,value:a[f++]});continue}if(d==="\\"){c.push({type:"ESCAPED_CHAR",index:f++,value:a[f++]});continue}if(d==="{"){c.push({type:"OPEN",index:f,value:a[f++]});continue}if(d==="}"){c.push({type:"CLOSE",index:f,value:a[f++]});continue}if(d===":"){let E="",A=f+1;for(;A<a.length;){let O=a.substr(A,1);if(A===f+1&&Omr.test(O)||A!==f+1&&Fmr.test(O)){E+=a[A++];continue}break}if(!E){v(`Missing parameter name at ${f}`);continue}c.push({type:"NAME",index:f,value:E}),f=A;continue}if(d==="("){let E=1,A="",O=f+1,M=!1;if(a[O]==="?"){v(`Pattern cannot start with "?" at ${O}`);continue}for(;O<a.length;){if(!Lmr(a[O],!1)){v(`Invalid character '${a[O]}' at ${O}.`),M=!0;break}if(a[O]==="\\"){A+=a[O++]+a[O++];continue}if(a[O]===")"){if(E--,E===0){O++;break}}else if(a[O]==="("&&(E++,a[O+1]!=="?")){v(`Capturing groups are not allowed at ${O}`),M=!0;break}A+=a[O++]}if(M)continue;if(E){v(`Unbalanced pattern at ${f}`);continue}if(!A){v(`Missing pattern at ${f}`);continue}c.push({type:"REGEX",index:f,value:A}),f=O;continue}c.push({type:"CHAR",index:f,value:a[f++]})}return c.push({type:"END",index:f,value:""}),c}t(dht,"v");function mht(a,s={}){let c=dht(a);s.delimiter??="/#?",s.prefixes??="./";let f=`[^${xC(s.delimiter)}]+?`,d=[],v=0,E=0,A="",O=new Set,M=t(dr=>{if(E<c.length&&c[E].type===dr)return c[E++].value},"a"),H=t(()=>M("OTHER_MODIFIER")??M("ASTERISK"),"f"),$=t(dr=>{let jr=M(dr);if(jr!==void 0)return jr;let{type:Cr,index:pr}=c[E];throw new TypeError(`Unexpected ${Cr} at ${pr}, expected ${dr}`)},"d"),K=t(()=>{let dr="",jr;for(;jr=M("CHAR")??M("ESCAPED_CHAR");)dr+=jr;return dr},"T"),Ne=t(dr=>dr,"Se"),xe=s.encodePart||Ne,Te="",Tt=t(dr=>{Te+=dr},"U"),Dt=t(()=>{Te.length&&(d.push(new dK(3,"","",xe(Te),"",3)),Te="")},"$"),br=t((dr,jr,Cr,pr,sr)=>{let Cs=3;switch(sr){case"?":Cs=1;break;case"*":Cs=0;break;case"+":Cs=2;break}if(!jr&&!Cr&&Cs===3){Tt(dr);return}if(Dt(),!jr&&!Cr){if(!dr)return;d.push(new dK(3,"","",xe(dr),"",Cs));return}let Di;Cr?Cr==="*"?Di=rOe:Di=Cr:Di=f;let _o=2;Di===f?(_o=1,Di=""):Di===rOe&&(_o=0,Di="");let hi;if(jr?hi=jr:Cr&&(hi=v++),O.has(hi))throw new TypeError(`Duplicate name '${hi}'.`);O.add(hi),d.push(new dK(_o,hi,xe(dr),Di,xe(pr),Cs))},"V");for(;E<c.length;){let dr=M("CHAR"),jr=M("NAME"),Cr=M("REGEX");if(!jr&&!Cr&&(Cr=M("ASTERISK")),jr||Cr){let sr=dr??"";s.prefixes.indexOf(sr)===-1&&(Tt(sr),sr=""),Dt();let Cs=H();br(sr,jr,Cr,"",Cs);continue}let pr=dr??M("ESCAPED_CHAR");if(pr){Tt(pr);continue}if(M("OPEN")){let sr=K(),Cs=M("NAME"),Di=M("REGEX");!Cs&&!Di&&(Di=M("ASTERISK"));let _o=K();$("CLOSE");let hi=H();br(sr,Cs,Di,_o,hi);continue}Dt(),$("END")}return d}t(mht,"D");function xC(a){return a.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}t(xC,"S");function _ht(a){return a&&a.ignoreCase?"ui":"u"}t(_ht,"X");function Rmr(a,s,c){return hht(mht(a,c),s,c)}t(Rmr,"Z");function wB(a){switch(a){case 0:return"*";case 1:return"?";case 2:return"+";case 3:return""}}t(wB,"k");function hht(a,s,c={}){c.delimiter??="/#?",c.prefixes??="./",c.sensitive??=!1,c.strict??=!1,c.end??=!0,c.start??=!0,c.endsWith="";let f=c.start?"^":"";for(let A of a){if(A.type===3){A.modifier===3?f+=xC(A.value):f+=`(?:${xC(A.value)})${wB(A.modifier)}`;continue}s&&s.push(A.name);let O=`[^${xC(c.delimiter)}]+?`,M=A.value;if(A.type===1?M=O:A.type===0&&(M=rOe),!A.prefix.length&&!A.suffix.length){A.modifier===3||A.modifier===1?f+=`(${M})${wB(A.modifier)}`:f+=`((?:${M})${wB(A.modifier)})`;continue}if(A.modifier===3||A.modifier===1){f+=`(?:${xC(A.prefix)}(${M})${xC(A.suffix)})`,f+=wB(A.modifier);continue}f+=`(?:${xC(A.prefix)}`,f+=`((?:${M})(?:`,f+=xC(A.suffix),f+=xC(A.prefix),f+=`(?:${M}))*)${xC(A.suffix)})`,A.modifier===0&&(f+="?")}let d=`[${xC(c.endsWith)}]|$`,v=`[${xC(c.delimiter)}]`;if(c.end)return c.strict||(f+=`${v}?`),c.endsWith.length?f+=`(?=${d})`:f+="$",new RegExp(f,_ht(c));c.strict||(f+=`(?:${v}(?=${d}))?`);let E=!1;if(a.length){let A=a[a.length-1];A.type===3&&A.modifier===3&&(E=c.delimiter.indexOf(A)>-1)}return E||(f+=`(?=${v}|${d})`),new RegExp(f,_ht(c))}t(hht,"F");var LN={delimiter:"",prefixes:"",sensitive:!0,strict:!0},Mmr={delimiter:".",prefixes:"",sensitive:!0,strict:!0},jmr={delimiter:"/",prefixes:"/",sensitive:!0,strict:!0};function Bmr(a,s){return a.length?a[0]==="/"?!0:!s||a.length<2?!1:(a[0]=="\\"||a[0]=="{")&&a[1]=="/":!1}t(Bmr,"J");function ght(a,s){return a.startsWith(s)?a.substring(s.length,a.length):a}t(ght,"Q");function Umr(a,s){return a.endsWith(s)?a.substr(0,a.length-s.length):a}t(Umr,"Ee");function yht(a){return!a||a.length<2?!1:a[0]==="["||(a[0]==="\\"||a[0]==="{")&&a[1]==="["}t(yht,"W");var vht=["ftp","file","http","https","ws","wss"];function bht(a){if(!a)return!0;for(let s of vht)if(a.test(s))return!0;return!1}t(bht,"N");function $mr(a,s){if(a=ght(a,"#"),s||a==="")return a;let c=new URL("https://example.com");return c.hash=a,c.hash?c.hash.substring(1,c.hash.length):""}t($mr,"te");function Jmr(a,s){if(a=ght(a,"?"),s||a==="")return a;let c=new URL("https://example.com");return c.search=a,c.search?c.search.substring(1,c.search.length):""}t(Jmr,"re");function zmr(a,s){return s||a===""?a:yht(a)?Cht(a):Tht(a)}t(zmr,"ne");function qmr(a,s){if(s||a==="")return a;let c=new URL("https://example.com");return c.password=a,c.password}t(qmr,"se");function Vmr(a,s){if(s||a==="")return a;let c=new URL("https://example.com");return c.username=a,c.username}t(Vmr,"ie");function Wmr(a,s,c){if(c||a==="")return a;if(s&&!vht.includes(s))return new URL(`${s}:${a}`).pathname;let f=a[0]=="/";return a=new URL(f?a:"/-"+a,"https://example.com").pathname,f||(a=a.substring(2,a.length)),a}t(Wmr,"ae");function Hmr(a,s,c){return Sht(s)===a&&(a=""),c||a===""?a:Eht(a)}t(Hmr,"oe");function Gmr(a,s){return a=Umr(a,":"),s||a===""?a:nOe(a)}t(Gmr,"ce");function Sht(a){switch(a){case"ws":case"http":return"80";case"wws":case"https":return"443";case"ftp":return"21";default:return""}}t(Sht,"_");function nOe(a){if(a==="")return a;if(/^[-+.A-Za-z0-9]*$/.test(a))return a.toLowerCase();throw new TypeError(`Invalid protocol '${a}'.`)}t(nOe,"y");function Qmr(a){if(a==="")return a;let s=new URL("https://example.com");return s.username=a,s.username}t(Qmr,"le");function Kmr(a){if(a==="")return a;let s=new URL("https://example.com");return s.password=a,s.password}t(Kmr,"fe");function Tht(a){if(a==="")return a;if(/[\t\n\r #%/:<>?@[\]^\\|]/g.test(a))throw new TypeError(`Invalid hostname '${a}'`);let s=new URL("https://example.com");return s.hostname=a,s.hostname}t(Tht,"z");function Cht(a){if(a==="")return a;if(/[^0-9a-fA-F[\]:]/g.test(a))throw new TypeError(`Invalid IPv6 hostname '${a}'`);return a.toLowerCase()}t(Cht,"j");function Eht(a){if(a===""||/^[0-9]*$/.test(a)&&parseInt(a)<=65535)return a;throw new TypeError(`Invalid port '${a}'.`)}t(Eht,"K");function Ymr(a){if(a==="")return a;let s=new URL("https://example.com");return s.pathname=a[0]!=="/"?"/-"+a:a,a[0]!=="/"?s.pathname.substring(2,s.pathname.length):s.pathname}t(Ymr,"he");function Xmr(a){return a===""?a:new URL(`data:${a}`).pathname}t(Xmr,"ue");function Zmr(a){if(a==="")return a;let s=new URL("https://example.com");return s.search=a,s.search.substring(1,s.search.length)}t(Zmr,"de");function ehr(a){if(a==="")return a;let s=new URL("https://example.com");return s.hash=a,s.hash.substring(1,s.hash.length)}t(ehr,"pe");var thr=class{static{t(this,"H")}#r;#n=[];#e={};#t=0;#s=1;#p=0;#a=0;#_=0;#c=0;#l=!1;constructor(a){this.#r=a}get result(){return this.#e}parse(){for(this.#n=dht(this.#r,!0);this.#t<this.#n.length;this.#t+=this.#s){if(this.#s=1,this.#n[this.#t].type==="END"){if(this.#a===0){this.#v(),this.#D()?this.#i(9,1):this.#y()?this.#i(8,1):this.#i(7,0);continue}else if(this.#a===2){this.#d(5);continue}this.#i(10,0);break}if(this.#_>0)if(this.#o())this.#_-=1;else continue;if(this.#k()){this.#_+=1;continue}switch(this.#a){case 0:this.#g()&&this.#d(1);break;case 1:if(this.#g()){this.#I();let a=7,s=1;this.#x()?(a=2,s=3):this.#l&&(a=2),this.#i(a,s)}break;case 2:this.#C()?this.#d(3):(this.#E()||this.#y()||this.#D())&&this.#d(5);break;case 3:this.#b()?this.#i(4,1):this.#C()&&this.#i(5,1);break;case 4:this.#C()&&this.#i(5,1);break;case 5:this.#N()?this.#c+=1:this.#S()&&(this.#c-=1),this.#A()&&!this.#c?this.#i(6,1):this.#E()?this.#i(7,0):this.#y()?this.#i(8,1):this.#D()&&this.#i(9,1);break;case 6:this.#E()?this.#i(7,0):this.#y()?this.#i(8,1):this.#D()&&this.#i(9,1);break;case 7:this.#y()?this.#i(8,1):this.#D()&&this.#i(9,1);break;case 8:this.#D()&&this.#i(9,1);break;case 9:break;case 10:break}}this.#e.hostname!==void 0&&this.#e.port===void 0&&(this.#e.port="")}#i(a,s){switch(this.#a){case 0:break;case 1:this.#e.protocol=this.#T();break;case 2:break;case 3:this.#e.username=this.#T();break;case 4:this.#e.password=this.#T();break;case 5:this.#e.hostname=this.#T();break;case 6:this.#e.port=this.#T();break;case 7:this.#e.pathname=this.#T();break;case 8:this.#e.search=this.#T();break;case 9:this.#e.hash=this.#T();break;case 10:break}this.#a!==0&&a!==10&&([1,2,3,4].includes(this.#a)&&[6,7,8,9].includes(a)&&(this.#e.hostname??=""),[1,2,3,4,5,6].includes(this.#a)&&[8,9].includes(a)&&(this.#e.pathname??=this.#l?"/":""),[1,2,3,4,5,6,7].includes(this.#a)&&a===9&&(this.#e.search??="")),this.#f(a,s)}#f(a,s){this.#a=a,this.#p=this.#t+s,this.#t+=s,this.#s=0}#v(){this.#t=this.#p,this.#s=0}#d(a){this.#v(),this.#a=a}#u(a){return a<0&&(a=this.#n.length-a),a<this.#n.length?this.#n[a]:this.#n[this.#n.length-1]}#m(a,s){let c=this.#u(a);return c.value===s&&(c.type==="CHAR"||c.type==="ESCAPED_CHAR"||c.type==="INVALID_CHAR")}#g(){return this.#m(this.#t,":")}#x(){return this.#m(this.#t+1,"/")&&this.#m(this.#t+2,"/")}#C(){return this.#m(this.#t,"@")}#b(){return this.#m(this.#t,":")}#A(){return this.#m(this.#t,":")}#E(){return this.#m(this.#t,"/")}#y(){if(this.#m(this.#t,"?"))return!0;if(this.#n[this.#t].value!=="?")return!1;let a=this.#u(this.#t-1);return a.type!=="NAME"&&a.type!=="REGEX"&&a.type!=="CLOSE"&&a.type!=="ASTERISK"}#D(){return this.#m(this.#t,"#")}#k(){return this.#n[this.#t].type=="OPEN"}#o(){return this.#n[this.#t].type=="CLOSE"}#N(){return this.#m(this.#t,"[")}#S(){return this.#m(this.#t,"]")}#T(){let a=this.#n[this.#t],s=this.#u(this.#p).index;return this.#r.substring(s,a.index)}#I(){let a={};Object.assign(a,LN),a.encodePart=nOe;let s=Rmr(this.#T(),void 0,a);this.#l=bht(s)}},tOe=["protocol","username","password","hostname","port","pathname","search","hash"],FN="*";function pht(a,s){if(typeof a!="string")throw new TypeError("parameter 1 is not of type 'string'.");let c=new URL(a,s);return{protocol:c.protocol.substring(0,c.protocol.length-1),username:c.username,password:c.password,hostname:c.hostname,port:c.port,pathname:c.pathname,search:c.search!==""?c.search.substring(1,c.search.length):void 0,hash:c.hash!==""?c.hash.substring(1,c.hash.length):void 0}}t(pht,"ge");function g6(a,s){return s?pK(a):a}t(g6,"b");function _K(a,s,c){let f;if(typeof s.baseURL=="string")try{f=new URL(s.baseURL),s.protocol===void 0&&(a.protocol=g6(f.protocol.substring(0,f.protocol.length-1),c)),!c&&s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.username===void 0&&(a.username=g6(f.username,c)),!c&&s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.username===void 0&&s.password===void 0&&(a.password=g6(f.password,c)),s.protocol===void 0&&s.hostname===void 0&&(a.hostname=g6(f.hostname,c)),s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&(a.port=g6(f.port,c)),s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.pathname===void 0&&(a.pathname=g6(f.pathname,c)),s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.pathname===void 0&&s.search===void 0&&(a.search=g6(f.search.substring(1,f.search.length),c)),s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.pathname===void 0&&s.search===void 0&&s.hash===void 0&&(a.hash=g6(f.hash.substring(1,f.hash.length),c))}catch{throw new TypeError(`invalid baseURL '${s.baseURL}'.`)}if(typeof s.protocol=="string"&&(a.protocol=Gmr(s.protocol,c)),typeof s.username=="string"&&(a.username=Vmr(s.username,c)),typeof s.password=="string"&&(a.password=qmr(s.password,c)),typeof s.hostname=="string"&&(a.hostname=zmr(s.hostname,c)),typeof s.port=="string"&&(a.port=Hmr(s.port,a.protocol,c)),typeof s.pathname=="string"){if(a.pathname=s.pathname,f&&!Bmr(a.pathname,c)){let d=f.pathname.lastIndexOf("/");d>=0&&(a.pathname=g6(f.pathname.substring(0,d+1),c)+a.pathname)}a.pathname=Wmr(a.pathname,a.protocol,c)}return typeof s.search=="string"&&(a.search=Jmr(s.search,c)),typeof s.hash=="string"&&(a.hash=$mr(s.hash,c)),a}t(_K,"w");function pK(a){return a.replace(/([+*?:{}()\\])/g,"\\$1")}t(pK,"C");function rhr(a){return a.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}t(rhr,"Oe");function nhr(a,s){s.delimiter??="/#?",s.prefixes??="./",s.sensitive??=!1,s.strict??=!1,s.end??=!0,s.start??=!0,s.endsWith="";let c=".*",f=`[^${rhr(s.delimiter)}]+?`,d=/[$_\u200C\u200D\p{ID_Continue}]/u,v="";for(let E=0;E<a.length;++E){let A=a[E];if(A.type===3){if(A.modifier===3){v+=pK(A.value);continue}v+=`{${pK(A.value)}}${wB(A.modifier)}`;continue}let O=A.hasCustomName(),M=!!A.suffix.length||!!A.prefix.length&&(A.prefix.length!==1||!s.prefixes.includes(A.prefix)),H=E>0?a[E-1]:null,$=E<a.length-1?a[E+1]:null;if(!M&&O&&A.type===1&&A.modifier===3&&$&&!$.prefix.length&&!$.suffix.length)if($.type===3){let K=$.value.length>0?$.value[0]:"";M=d.test(K)}else M=!$.hasCustomName();if(!M&&!A.prefix.length&&H&&H.type===3){let K=H.value[H.value.length-1];M=s.prefixes.includes(K)}M&&(v+="{"),v+=pK(A.prefix),O&&(v+=`:${A.name}`),A.type===2?v+=`(${A.value})`:A.type===1?O||(v+=`(${f})`):A.type===0&&(!O&&(!H||H.type===3||H.modifier!==3||M||A.prefix!=="")?v+="*":v+=`(${c})`),A.type===1&&O&&A.suffix.length&&d.test(A.suffix[0])&&(v+="\\"),v+=pK(A.suffix),M&&(v+="}"),A.modifier!==3&&(v+=wB(A.modifier))}return v}t(nhr,"ke");var xht=class{static{t(this,"me")}#r;#n={};#e={};#t={};#s={};#p=!1;constructor(a={},s,c){try{let f;if(typeof s=="string"?f=s:c=s,typeof a=="string"){let A=new thr(a);if(A.parse(),a=A.result,f===void 0&&typeof a.protocol!="string")throw new TypeError("A base URL must be provided for a relative constructor string.");a.baseURL=f}else{if(!a||typeof a!="object")throw new TypeError("parameter 1 is not of type 'string' and cannot convert to dictionary.");if(f)throw new TypeError("parameter 1 is not of type 'string'.")}typeof c>"u"&&(c={ignoreCase:!1});let d={ignoreCase:c.ignoreCase===!0},v={pathname:FN,protocol:FN,username:FN,password:FN,hostname:FN,port:FN,search:FN,hash:FN};this.#r=_K(v,a,!0),Sht(this.#r.protocol)===this.#r.port&&(this.#r.port="");let E;for(E of tOe){if(!(E in this.#r))continue;let A={},O=this.#r[E];switch(this.#e[E]=[],E){case"protocol":Object.assign(A,LN),A.encodePart=nOe;break;case"username":Object.assign(A,LN),A.encodePart=Qmr;break;case"password":Object.assign(A,LN),A.encodePart=Kmr;break;case"hostname":Object.assign(A,Mmr),yht(O)?A.encodePart=Cht:A.encodePart=Tht;break;case"port":Object.assign(A,LN),A.encodePart=Eht;break;case"pathname":bht(this.#n.protocol)?(Object.assign(A,jmr,d),A.encodePart=Ymr):(Object.assign(A,LN,d),A.encodePart=Xmr);break;case"search":Object.assign(A,LN,d),A.encodePart=Zmr;break;case"hash":Object.assign(A,LN,d),A.encodePart=ehr;break}try{this.#s[E]=mht(O,A),this.#n[E]=hht(this.#s[E],this.#e[E],A),this.#t[E]=nhr(this.#s[E],A),this.#p=this.#p||this.#s[E].some(M=>M.type===2)}catch{throw new TypeError(`invalid ${E} pattern '${this.#r[E]}'.`)}}}catch(f){throw new TypeError(`Failed to construct 'URLPattern': ${f.message}`)}}test(a={},s){let c={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof a!="string"&&s)throw new TypeError("parameter 1 is not of type 'string'.");if(typeof a>"u")return!1;try{typeof a=="object"?c=_K(c,a,!1):c=_K(c,pht(a,s),!1)}catch{return!1}let f;for(f of tOe)if(!this.#n[f].exec(c[f]))return!1;return!0}exec(a={},s){let c={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof a!="string"&&s)throw new TypeError("parameter 1 is not of type 'string'.");if(typeof a>"u")return;try{typeof a=="object"?c=_K(c,a,!1):c=_K(c,pht(a,s),!1)}catch{return null}let f={};s?f.inputs=[a,s]:f.inputs=[a];let d;for(d of tOe){let v=this.#n[d].exec(c[d]);if(!v)return null;let E={};for(let[A,O]of this.#e[d].entries())if(typeof O=="string"||typeof O=="number"){let M=v[A+1];E[O]=M}f[d]={input:c[d]??"",groups:E}}return f}static compareComponent(a,s,c){let f=t((A,O)=>{for(let M of["type","modifier","prefix","value","suffix"]){if(A[M]<O[M])return-1;if(A[M]!==O[M])return 1}return 0},"o"),d=new dK(3,"","","","",3),v=new dK(0,"","","","",3),E=t((A,O)=>{let M=0;for(;M<Math.min(A.length,O.length);++M){let H=f(A[M],O[M]);if(H)return H}return A.length===O.length?0:f(A[M]??d,O[M]??d)},"s");return!s.#t[a]&&!c.#t[a]?0:s.#t[a]&&!c.#t[a]?E(s.#s[a],[v]):!s.#t[a]&&c.#t[a]?E([v],c.#s[a]):E(s.#s[a],c.#s[a])}get protocol(){return this.#t.protocol}get username(){return this.#t.username}get password(){return this.#t.password}get hostname(){return this.#t.hostname}get port(){return this.#t.port}get pathname(){return this.#t.pathname}get search(){return this.#t.search}get hash(){return this.#t.hash}get hasRegExpGroups(){return this.#p}};globalThis.URLPattern||(globalThis.URLPattern=xht);import{AssertionError as ihr}from"assert";function y6(a,s){if(a===!1)throw new ihr({message:s})}t(y6,"assert");var Jc;(function(a){a.Object="Object",a.Property="Property",a.Array="Array",a.Literal="Literal",a.TemplateString="TemplateString",a.Identifier="Identifier",a.FunctionCall="FunctionCall",a.Raw="Raw"})(Jc||(Jc={}));function PB(a){return a.type===Jc.Object}t(PB,"isAstObject");function v6(a){return a.type===Jc.Property}t(v6,"isAstProperty");function Dht(a){return a.type===Jc.Array}t(Dht,"isAstArray");function NB(a){return a.type===Jc.Literal}t(NB,"isAstLiteral");function f7(a){if(a===void 0)throw new Error("Node is undefined");if(!PB(a))throw new Error("Node is not object")}t(f7,"assertAstObject");import{findNodeAtLocation as shr,getNodeValue as ahr,printParseErrorCode as ohr,visit as chr}from"jsonc-parser";var lhr={DEFAULT:{allowTrailingComma:!1}};function mK(a,s=[],c=lhr.DEFAULT){let f={type:"array",offset:-1,length:-1,line:-1,column:-1,children:[],parent:void 0};function d(O){f.type==="property"&&(f.length=O-f.offset,f=f.parent)}t(d,"ensurePropertyComplete");function v(O){return f.children?.push(O),O}t(v,"onValue"),chr(a,{onObjectBegin:t((O,M,H)=>{f=v({type:"object",offset:O,length:-1,line:M+1,column:H+1,parent:f,children:[]})},"onObjectBegin"),onObjectProperty:t((O,M,H,$,K)=>{f=v({type:"property",offset:M,length:-1,line:$+1,column:K+1,parent:f,children:[]}),f.children?.push({type:"string",value:O,offset:M,length:H,line:$,column:K,parent:f})},"onObjectProperty"),onObjectEnd:t((O,M)=>{d(O+M),f.length=O+M-f.offset,f=f.parent,d(O+M)},"onObjectEnd"),onArrayBegin:t((O,M,H,$)=>{f=v({type:"array",offset:O,length:-1,line:H+1,column:$+1,parent:f,children:[]})},"onArrayBegin"),onArrayEnd:t((O,M)=>{f.length=O+M-f.offset,f=f.parent,d(O+M)},"onArrayEnd"),onLiteralValue:t((O,M,H,$,K)=>{v({type:uhr(O),offset:M,length:H,line:$+1,column:K+1,parent:f,value:O}),d(M+H)},"onLiteralValue"),onSeparator:t((O,M)=>{f.type==="property"&&(O===":"?f.colonOffset=M:O===","&&d(M))},"onSeparator"),onError:t((O,M,H,$,K)=>{s.push({error:O,offset:M,length:H,line:$+1,column:K+1})},"onError")},c);let A=f.children[0];return A&&delete A.parent,A}t(mK,"parse");function uhr(a){switch(typeof a){case"boolean":return"boolean";case"number":return"number";case"string":return"string";case"object":{if(a){if(Array.isArray(a))return"array"}else return"null";return"object"}default:return"null"}}t(uhr,"getNodeType");function iOe(a,s){return shr(a,s)}t(iOe,"findNodeAtLocation");function hK(a){return ahr(a)}t(hK,"getNodeValue");function Aht(a){return ohr(a)}t(Aht,"printParseErrorCode");var gK=class{static{t(this,"AstAdapter")}parse(s){let f=mK(s,[]);if(f)return this.parseNode(f,void 0);throw new Error("Failed to parse JSON")}convert(s){return this.parseNode(s,void 0)}parseNode(s,c){switch(s.type){case"object":return this.createObject(s,c);case"array":return this.createArray(s,c);case"property":return this.createProperty(s,c);case"string":return this.createLiteral(s,c);case"number":return this.createLiteral(s,c);case"boolean":return this.createLiteral(s,c);case"null":return this.createLiteral(s,c)}}createLiteral(s,c){return{type:Jc.Literal,location:{line:s.line,column:s.column},parent:c,value:s.type==="null"?null:s.value}}createObject(s,c){let f={type:Jc.Object,children:[],parent:c,location:{line:s.line,column:s.column}};return s.children?.forEach(d=>{f.children.push(this.parseNode(d,f))}),f}createProperty(s,c){y6(s.children?.length===2,"Invalid property node");let f={type:Jc.Property,location:{line:s.line,column:s.column},parent:c,name:null,value:null};return f.name={value:s.children[0].value,location:{line:s.line,column:s.column},type:Jc.Identifier,parent:f},f.value=this.parseNode(s.children[1],f),f}createArray(s,c){let f={type:Jc.Array,location:{line:s.line,column:s.column},parent:c,children:[]};return s.children?.forEach(d=>f.children.push(this.parseNode(d,f))),f}};var Mx={createLiteral:t((a,s)=>({type:Jc.Literal,parent:s,value:a}),"createLiteral"),createTemplateString:t((a,s)=>({type:Jc.TemplateString,parent:s,value:a}),"createTemplateString"),createIdentifier:t((a,s)=>({type:Jc.Identifier,value:a,parent:s}),"createIdentifier"),createProperty:t((a,s,c)=>{let f={type:Jc.Property,parent:c,name:null,value:s};return f.name={value:a,type:Jc.Identifier,parent:f},f.value.parent=f,f},"createProperty"),createArrayOfLiterals:t((a,s)=>{let c={type:Jc.Array,parent:s,children:[]};for(let f of a)c.children.push(Mx.createLiteral(f,c));return c},"createArrayOfLiterals")};var fhr=/^[a-zA-Z_$][a-zA-Z0-9_$]*$/,yK=class{static{t(this,"SourceGenerator")}generate(s){let c=[];return this.generateSource(c,s),c.join("")}generateSource(s,c){switch(c.type){case Jc.Array:return this.generateArray(s,c);case Jc.Object:return this.generateObject(s,c);case Jc.Property:return this.generateProperty(s,c);case Jc.Literal:return this.generateLiteral(s,c);case Jc.FunctionCall:return this.generateFunctionCall(s,c);case Jc.Identifier:return this.generateIdentifier(s,c);case Jc.Raw:return this.generateRaw(s,c);case Jc.TemplateString:return this.generateTemplateString(s,c)}}generateArray(s,c){s.push("["),c.children.map(f=>{this.generateSource(s,f),s.push(",")}),s.push("]")}generateObject(s,c){s.push("{"),c.children.forEach(f=>{this.generateSource(s,f),s.push(",")}),s.push("}")}generateProperty(s,c){this.generateIdentifier(s,c.name),s.push(":"),this.generateSource(s,c.value)}generateFunctionCall(s,c){s.push(c.name.value),s.push("("),c.children.forEach((f,d,v)=>{this.generateSource(s,f),d<v.length&&s.push(",")}),s.push(")")}generateRaw(s,c){s.push(c.value)}generateTemplateString(s,c){s.push("`"),s.push(c.value.replaceAll("`","\\`")),s.push("`")}generateLiteral(s,c){if(c.value===null)return s.push("null");switch(typeof c.value){case"number":case"boolean":return s.push(`${c.value}`);case"string":{let f=c.value,d=JSON.stringify(f);return s.push(`${d}`)}}}generateIdentifier(s,c){let f=fhr.test(c.value)?c.value:`'${c.value}'`;s.push(f)}};import{parse as _hr}from"@swc/core";import phr from"fs/promises";var kht=t(async a=>{let s=new Set;try{let c=await phr.readFile(a,"utf-8");(await _hr(c,{syntax:"typescript"})).body.forEach(d=>{d.type==="ExportDefaultDeclaration"||d.type==="ExportDefaultExpression"?s.add("default"):d.type==="ExportDeclaration"&&d.declaration.type==="FunctionDeclaration"?s.add(d.declaration.identifier.value):d.type==="ExportDeclaration"&&d.declaration.type==="VariableDeclaration"&&d.declaration.declarations[0].id.type==="Identifier"&&s.add(d.declaration.declarations[0].id.value)})}catch{return null}return s},"getJSFileExports");var wht={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/fragments.schema.json",$defs:{corsPolicyConfiguration:{type:"object",required:["name","allowedOrigins"],additionalProperties:!1,properties:{name:{type:"string",pattern:"^[0-9a-z-]+$"},allowCredentials:{type:"boolean"},maxAge:{type:"number"},allowedOrigins:{oneOf:[{type:"array",items:{type:"string"}},{type:"string"}]},allowedMethods:{oneOf:[{type:"array",items:{$ref:"fragments.schema.json#/$defs/httpMethod"}},{type:"string"}]},allowedHeaders:{oneOf:[{type:"array",items:{type:"string"}},{type:"string"}]},exposeHeaders:{oneOf:[{type:"array",items:{type:"string"}},{type:"string"}]}}},handlerDefinition:{type:"object",properties:{module:{type:"string",pattern:"^\\$import\\([^ )]*?\\)$"},export:{type:"string"},options:{type:"object",additionalProperties:!0}},additionalProperties:!1,required:["module","export"]},httpMethod:{type:"string",enum:["GET","HEAD","POST","PUT","DELETE","CONNECT","OPTIONS","TRACE","PATCH"]}}};var sOe={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/policies.schema.json",title:"Policies Config File",type:"object",additionalProperties:!1,properties:{policies:{type:"array",items:{$ref:"policy-configuration.schema.json"}},corsPolicies:{type:"array",items:{$ref:"fragments.schema.json#/$defs/corsPolicyConfiguration"}}}};var Pht={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/policy-configuration.schema.json",title:"Policy Configuration Fragment",type:"object",required:["name","policyType","handler"],additionalProperties:!1,properties:{name:{type:"string",pattern:"^[0-9a-z-]+$"},policyType:{type:"string"},handler:{$ref:"fragments.schema.json#/$defs/handlerDefinition"},options:{type:"object",additionalProperties:!0}}};var aOe={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/route-configuration-open-api.schema.json",title:"Open API Route Configuration Fragment",description:"These are the properties that can appear under the x-zuplo-route extension in a PathObject in Open API. It's a subset of what can appear in Zuplo's routes.json.",type:"object",required:["handler"],additionalProperties:!1,properties:{label:{type:"string",description:"An internal user-friendly identifier of the route."},key:{type:"string",deprecated:!0},handler:{$ref:"fragments.schema.json#/$defs/handlerDefinition"},corsPolicy:{type:"string",pattern:"^[0-9a-z-]+$"},custom:{},policies:{type:"object",additionalProperties:!1,properties:{inbound:{type:"array",items:{type:"string",pattern:"^[0-9a-z-]+$"}},outbound:{type:"array",items:{type:"string",pattern:"^[0-9a-z-]+$"}}}},tags:{type:"array",items:{type:"string"}}}};var oOe={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/route-configuration.schema.json",title:"Route Configuration Fragment",description:"",type:"object",required:["path","methods","handler"],additionalProperties:!1,$defs:{corsPolicy:{type:"string",pattern:"^[0-9a-z-]+$"}},properties:{operationId:{type:"string"},path:{type:"string",pattern:"^/[^\\s]*$"},methods:{type:"array",items:{$ref:"fragments.schema.json#/$defs/httpMethod"}},label:{type:"string",description:"An internal user-friendly identifier of the route."},enforceOpenApi:{type:"boolean",description:"If true, schema validation found in the OpenAPI spec will be enforced on requests/responses."},key:{type:"string",deprecated:!0},handler:{$ref:"fragments.schema.json#/$defs/handlerDefinition"},corsPolicy:{$ref:"#/$defs/corsPolicy"},custom:{},policies:{type:"object",additionalProperties:!1,properties:{inbound:{type:"array",items:{type:"string",pattern:"^[0-9a-z-]+$"}},outbound:{type:"array",items:{type:"string",pattern:"^[0-9a-z-]+$"}}}},summary:{type:"string"},description:{type:"string"},excludeFromOpenApi:{type:"boolean"},tags:{type:"array",items:{type:"string"}}}};var zyt=W_(_yt(),1),qyt=W_(Jyt(),1);var upe=class a{static{t(this,"JsonValidator")}static#r=new a;static get instance(){return a.#r}ajv;constructor(){this.ajv=new qyt.Ajv2020({allErrors:!0,allowUnionTypes:!0}),this.ajv.addKeyword("faker"),(0,zyt.default)(this.ajv,{mode:"fast"})}addSchema(s,c){this.ajv.addSchema(s,c)}compile(s){let c=this.ajv.compile(s);return t(d=>({isValid:c(d),errors:this.toSimpleErrors(c.errors,d),warnings:[]}),"validator")}toSimpleErrors(s,c){let f=[];return s?.forEach(d=>{d.keyword==="enum"&&d.params.allowedValues&&Array.isArray(d.params.allowedValues)&&(d.message+=`; ${d.params.allowedValues.join(", ")}`),d.instancePath&&(d.instancePath=d.instancePath.replaceAll(/(\/)?(~1)(\/)?/gm,"/"));let v={details:{}},E=d.instancePath.split("/");if(E.length>2){let O=E[1],M=E[2]?parseInt(E[2]):0,H=E[3],$=isNaN(M)?void 0:c[O][M][H];v={details:{property:O,index:M,field:H,fieldValue:$}}}if(d.keyword==="required"&&d.params.missingProperty&&d.instancePath&&(d.message=`A 'path' is missing required property '${d.params.missingProperty}'`),d.keyword==="additionalProperties"&&d.params.additionalProperty&&d.instancePath&&(d.message=`A 'path' should NOT include property '${d.params.additionalProperty}'`),d.keyword==="type"&&d.params.type&&d.instancePath){let O=d.instancePath.split("/"),M=O[O.length-1];d.message=`Value of property '${M}' must be '${d.params.type}'`}let A=Object.assign(d,v);f.push(A)}),f}};var VN=upe.instance;VN.addSchema(oOe,"route-configuration.schema.json");VN.addSchema(Pht,"policy-configuration.schema.json");VN.addSchema(sOe,"policies.schema.json");VN.addSchema(aOe,"open-api-route-configuration.schema.json");VN.addSchema(wht,"fragments.schema.json");var aVr=VN.compile(oOe),Vyt=VN.compile(aOe),T7e=VN.compile(sOe);var fpe=class{static{t(this,"PoliciesConfigurationValidator")}results;validate(s){return this.results=T7e(s),this.results}};var _pe=class{static{t(this,"OpenAPILocalizedValidator")}results;validate(s){return this.results=Vyt(s),this.results}};import v2r from"path";var C7e=/\$import\((.*)\)/,ppe=/\$env\((.*?)\)/g;var E6=class extends Error{static{t(this,"CodeGenError")}location;constructor(s,c,f,d){super(s),this.location={file:c,namespace:"",line:f?f.line:0,column:f?f.column:0,length:0,lineText:d??"",suggestion:""}}},y2r=t(a=>{let s=[],c=a;for(;c.parent;)s.push(c),c=c.parent;return s.reverse()},"invertTree"),WN=t((a,s)=>{if(!a)return!1;let c=y2r(a);return s.split("/").every((v,E)=>{let A=c[E];return A?v==="*"||v6(A)&&A.name.value===v?!0:v==="{}"?A.type===Jc.Object:v==="[]"?A.type===Jc.Array:!1:!1})},"testPosition");var dpe=class{static{t(this,"AstTransformer")}errors=[];transform(s){return this.visitor(s),s}visitor(s){this.visit(s),PB(s)?s.children.forEach(c=>{this.visitor(c)}):Dht(s)?s.children.forEach(c=>{this.visitor(c)}):v6(s)&&this.visitor(s.value)}},Wyt=t((a,s,c)=>f=>{if(!v6(f)||!NB(f.value)||typeof f.value.value!="string")return;if(!a.some(v=>WN(f,v))){ppe.test(f.value.value)&&s.push(new E6("An $env() statement is not expected at this location.",c,f.location,f.value.value));return}let d=new RegExp(ppe).exec(f.value.value);if(d?.length===2&&d[0]===f.value.value){let v={type:Jc.Raw,parent:null,value:`environment["${d[1]}"]`};f.value=v}else{let v=f.value.value.replaceAll(new RegExp(ppe),(E,A)=>`\${environment["${A}"] ? environment["${A}"] : ""}`);v!==f.value.value&&(f.value=Mx.createTemplateString(v,f))}},"getEnvStatementTransformer");var YK="config/routes.json",b2r=["handler/{}/options/*","policies/[]/{}/handler/{}/options/*","corsPolicies/[]/{}/*"],S2r=["handler/{}/module","handler/{}/options/{}/policies/{}/inbound/[]/{}/module","handler/{}/options/{}/policies/{}/outbound/[]/{}/module","policies/[]/{}/handler/{}/module","policies/[]/{}/handler/{}/options/{}/identifier/{}/module","policies/[]/{}/handler/{}/options/{}/validator"],Hyt=["handler/{}/options/*","policies/[]/{}/handler/{}/options/*"],T2r="handler/{}/options/{}/rewritePattern",C2r="handler/{}/options/{}/baseUrl",mpe=class extends dpe{static{t(this,"OpenAPIRoutesFragmentAstTransformer")}importCount=0;addedImports=new Map;getImportName(s){this.addedImports.has(s)||this.addedImports.set(s,`__import${this.importCount++}`);let c=this.addedImports.get(s);if(!c)throw new Error("Import name is undefined. This should not happen.");return c}getImports(){let s=[];return this.addedImports.forEach((c,f)=>{s.push({name:c,path:f})}),s}visit(s){this.rewriteHandlerFunction(s),this.rewriteForwardFunction(s),this.replaceImportStatements(s),this.replaceEnvStatements(s)}rewriteHandlerFunction(s){if(!(!v6(s)||!NB(s.value)||typeof s.value.value!="string")&&WN(s,T2r)){if(!s.parent||!PB(s.parent)){this.errors.push(new E6("Invalid node, expected object",YK,s.parent?s.parent.location:s.location,void 0));return}let c=s.value.value,f={type:Jc.Raw,parent:null,value:Gyt(c)},d=Mx.createProperty("__rewriteFunction",f,s);s.parent.children.push(d)}}rewriteForwardFunction(s){if(!(!v6(s)||!NB(s.value)||typeof s.value.value!="string")&&WN(s,C2r)){if(!s.parent||!PB(s.parent)){this.errors.push(new E6("Invalid node, expected object",YK,s.parent?s.parent.location:s.location,void 0));return}let c=s.value.value,f={type:Jc.Raw,parent:null,value:Gyt(c)},d=Mx.createProperty("__rewriteFunction",f,s);s.parent.children.push(d)}}replaceImportStatements(s){if(!v6(s)||!NB(s.value))return;let c=s.value.value;if(typeof c!="string")return;if(!S2r.some(A=>WN(s,A))&&!Hyt.some(A=>WN(s,A))){if(C7e.test(c)){if(s.name.value==="$ref")return;this.errors.push(new E6("An $import() statement is not expected at this location.",YK,s.location,c))}return}let f=C7e.exec(c);if(Hyt.some(A=>WN(s,A))&&!f)return;if(!f){this.errors.push(new E6("Invalid $import() statement",YK,s.location,c));return}let d=f[1];d.startsWith(".")&&(d=v2r.join("..",d));let v=this.getImportName(d),E={type:Jc.Identifier,parent:s.parent,value:v};s.value=E}replaceEnvStatements=Wyt(b2r,this.errors,YK)};function Gyt(a){return`(request, context) => {
584
+ `.trim(),v=ldt("sh",["-c",d]);process.env.DEBUG_TAR&&(v.stdout.on("data",E=>{let A=E.toString().trim();A.length>0&&console.info(A)}),v.stderr.on("data",E=>{let A=E.toString().trim();A.length>0&&console.error(A)})),v.on("close",E=>{E===0?c("Extraction completed."):f(new Error(`tar process exited with code ${E}`))}),v.on("error",E=>{f(E)})})}t(k_r,"untarFile");async function w_r(a){if(await r8e(a))return await PN.rm(a,{recursive:!0})}t(w_r,"deleteFolder");var Ml=n8e;var bC=W_(t8e(),1);import{readFile as P_r}from"fs/promises";var i7=class extends Error{static{t(this,"CustomResolveError")}},NN=class{static{t(this,"RefParser")}sourceDirectory;logger;constructor(s,c){this.sourceDirectory=s,this.logger=c}dereference(s,c){return KQ.$RefParser.dereference(s,{resolve:{json:!0,file:Vfe(this.sourceDirectory,this.logger),external:!0,http:!1},dereference:{circular:"ignore",onDereference:c?.onDereference}})}bundle(s){return KQ.$RefParser.bundle(s,{resolve:{file:Vfe(this.sourceDirectory,this.logger),external:!0,http:!1}})}parse(s){return KQ.$RefParser.parse(s,{resolve:{file:Vfe(this.sourceDirectory,this.logger),external:!0,http:!1}})}resolve(s){return KQ.$RefParser.resolve(s,{resolve:{file:Vfe(this.sourceDirectory,this.logger),external:!0,http:!1}})}};function Vfe(a,s){return{order:100,canRead(c){let f=O_r(c.url);if(!(f===void 0||f==="file"))return!1;let v;try{v=pdt(c.url)}catch(E){throw new i7(`Malformed URI: ${c.url}`,{cause:E})}try{Ml.safePath(a).resolve(v)}catch(E){return s?.warn(E),!1}return!0},async read(c){let f;try{f=pdt(c.url)}catch(d){throw new i7(`Malformed URI: ${c.url}`,{cause:d})}try{return await P_r(f)}catch(d){throw new i7(`Error opening file "${f}"`,{cause:d})}}}}t(Vfe,"customResolver");var i8e=/^win/.test(globalThis.process?globalThis.process.platform:""),N_r=/\//g,I_r=/^(\w{2,}):\/\//i,s8e=[/%23/g,"#",/%24/g,"$",/%26/g,"&",/%2C/g,",",/%40/g,"@"];function O_r(a){let s=I_r.exec(a);if(s)return s[1].toLowerCase()}t(O_r,"getProtocol");function pdt(a,s){a=decodeURI(a);for(let f=0;f<s8e.length;f+=2)a=a.replace(s8e[f],s8e[f+1]);let c=a.substr(0,7).toLowerCase()==="file://";return c&&(a=a[7]==="/"?a.substr(8):a.substr(7),i8e&&a[1]==="/"&&(a=a[0]+":"+a.substr(1)),s?a="file:///"+a:(c=!1,a=i8e?a:"/"+a)),i8e&&!c&&(a=a.replace(N_r,"\\"),a.substr(1,2)===":\\"&&(a=a[0].toUpperCase()+a.substr(1))),a}t(pdt,"toFileSystemPath");var ddt="YOUR_KEY_HERE";async function mdt(a){let c=await new NN(a.sourceDirectory,a.logger).bundle(a.openApiDocPath),f=a.openApiDocPath.replace(a.sourceDirectory,"");return F_r({...a,relativeOpenApiPath:f},c)}t(mdt,"buildPublicOpenApiFile");async function F_r(a,s){j_r({relativeOpenApiPath:a.relativeOpenApiPath},s);let c=s;return c=R_r(c),L_r(c,a),c=M_r(c,a),hdt(c,"x-zuplo"),c}t(F_r,"buildRawOpenApiFile");function L_r(a,{deploymentUrl:s,deploymentName:c,environmentType:f}){let d;s?d=new URL(s).hostname:f&&c&&(d=f===Jlt.WORKING_COPY?`${c}.${UNe.ZUP_WORKING_COPY_HOSTNAME}`:`${c}.${UNe.ZUP_HOSTNAME}`),d?a.servers=[{url:`https://${d}`}]:a.servers=void 0}t(L_r,"addServerHost");function R_r(a){if(!a.paths)return a;let{components:s}=a,c=s?{...s}:void 0,f=[];c&&c.parameters&&(f=Object.entries(c.parameters).reduce((v,[E,A])=>(Wj in A&&jue(A[Wj])&&(v.push(E),c.parameters&&delete c.parameters[E]),v),[]));let d=Object.entries(a.paths).reduce((v,[E,A])=>{if(!A)return v;let O={...A},M=["delete","get","head","patch","post","put","trace","options"];return M.forEach(H=>{let $=A[H];if(!$)return;if(jue($[Wj])){delete O[H];return}let{parameters:K}=$;if(!K)return;let Ne=K.filter(xe=>{if(Wj in xe&&jue(xe[Wj]))return!1;if("$ref"in xe){let Te=xe.$ref.split("/").pop();return Te?!f.includes(Te):!0}return!0});O[H]={...$,parameters:Ne}}),M.some(H=>!!O[H])&&(v[E]=O),v},{});return{...a,paths:d,components:c}}t(R_r,"removeHiddenRoutesAndParams");function M_r(a,{policiesConfig:s}){if(!a.paths)return a;let c=Object.entries(a.paths).reduce((f,[d,v])=>{if(!v)return f;let E={...v};return[E.delete,E.get,E.head,E.patch,E.post,E.put,E.trace,E.options].forEach(A=>{if(!A)return;let O=A["x-zuplo-route"]?.policies?.inbound?.reduce(($,K)=>{let Ne=s.policies?.find(({name:Tt})=>Tt===K);if(!Ne)return $;if(!(Ne.handler.export==="CompositeInboundPolicy"))return $.concat(K);let Te=Ne.handler.options?.policies;return Te?$.concat(Te):$},[]),M=[];if(O&&O.forEach($=>{s.policies?.forEach(K=>{K.name===$&&(K.handler.export==="ApiAuthKeyInboundPolicy"||K.handler.export==="ApiKeyInboundPolicy")&&!K.handler.options?.disableAutomaticallyAddingKeyHeaderToOpenApi&&M.push(K)})}),M.length>0){let $=M.length>0&&M[0].handler&&M[0].handler.options&&M[0].handler.options.authHeader?M[0].handler.options.authHeader:"Authorization",K=M.length>0&&M[0].handler&&M[0].handler.options&&(M[0].handler.options.authScheme||M[0].handler.options.authScheme==="")?M[0].handler.options.authScheme:"Bearer",Ne=K!==""?`${K} ${ddt}`:ddt,xe={name:$,in:"header",required:!0,example:Ne,schema:{type:"string"},description:`The \`${$}\` header is used to authenticate with the API using your API key. Value is of the format \`${Ne}\`.`};A.parameters?A.parameters.some(br=>"name"in br&&br.name===xe.name)||A.parameters.unshift(xe):A.parameters=[xe];let Te={type:"http",scheme:K.toLowerCase()},Tt="api_key";a.components?.securitySchemes?Object.values(a.components?.securitySchemes).some(br=>"name"in br&&br.type==="apiKey"||"type"in br&&br.type==="http"&&br.scheme===K)||(a.components.securitySchemes={...a.components.securitySchemes,[Tt]:Te}):(a.components||(a.components={}),a.components.securitySchemes={[Tt]:Te});let Dt={[Tt]:[]};A.security?A.security.some(br=>br[Tt]!==void 0)||A.security.unshift(Dt):A.security=[Dt]}let H=[];if(O&&O.forEach($=>{s.policies?.forEach(K=>{K.name===$&&(K.handler.export==="RateLimitInboundPolicy"||K.handler.export==="ComplexRateLimitInboundPolicy")&&H.push(K)})}),H.length>0){let $={description:"Rate Limiting Response",content:{"application/json":{schema:{type:"object",required:["type","title","status"],examples:[{type:"https://httpproblems.com/http-status/429",title:"Too Many Requests",status:429,instance:"/foo/bar"}],properties:{type:{type:"string",example:"https://httpproblems.com/http-status/429",description:"A URI reference that identifies the problem."},title:{type:"string",example:"Too Many Requests",description:"A short, human-readable summary of the problem."},status:{type:"number",example:429,description:"The HTTP status code."},instance:{type:"string",example:"/foo/bar"}}}}}},K={...$,headers:{"retry-after":{description:"The number of seconds to wait before making a new request.",schema:{type:"integer",example:60}}}};a.components?.responses||a.components||(a.components={}),a.components.responses={...a.components.responses,RateLimitNoRetryAfter:$,RateLimitWithRetryAfter:K},A.responses||(A.responses={});let Ne=H.some(xe=>xe.handler.options?.headerMode!=="none");A.responses[429]||(A.responses[429]={$ref:Ne?"#/components/responses/RateLimitWithRetryAfter":"#/components/responses/RateLimitNoRetryAfter"})}}),f[d]=E,f},{});return{...a,paths:c}}t(M_r,"enrichSpecWithZuploData");function hdt(a,s){for(let c in a)c.startsWith(s)?delete a[c]:typeof a[c]=="object"&&hdt(a[c],s)}t(hdt,"removePropertiesByPrefix");function j_r({relativeOpenApiPath:a},s){if(!s||typeof s!="object")throw new Tv({message:"The OpenAPI Document could not be parsed.",severity:"error"});if(!("info"in s)||typeof s.info!="object"||!s.info)throw new Tv({message:"The OpenAPI document does not have the required 'info' property.",location:{file:a,column:0,length:0,line:0,lineText:"",namespace:"",suggestion:"Add the required 'info' property. https://spec.openapis.org/oas/v3.1.0#info-object"},severity:"error"});if(!("title"in s.info)||typeof s.info.title!="string")throw new Tv({message:"The OpenAPI document does not have the required 'info.title' property.",location:{file:a,column:0,length:0,line:0,lineText:"",namespace:"",suggestion:"Add the required 'info.title' property. https://spec.openapis.org/oas/v3.1.0#info-object"},severity:"error"})}t(j_r,"assertIsZuploOpenApiSpec");function B_r(a){if(a.length>=255)throw new TypeError("Alphabet too long");let s=new Uint8Array(256);for(let M=0;M<s.length;M++)s[M]=255;for(let M=0;M<a.length;M++){let H=a.charAt(M),$=H.charCodeAt(0);if(s[$]!==255)throw new TypeError(H+" is ambiguous");s[$]=M}let c=a.length,f=a.charAt(0),d=Math.log(c)/Math.log(256),v=Math.log(256)/Math.log(c);function E(M){if(M instanceof Uint8Array||(ArrayBuffer.isView(M)?M=new Uint8Array(M.buffer,M.byteOffset,M.byteLength):Array.isArray(M)&&(M=Uint8Array.from(M))),!(M instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(M.length===0)return"";let H=0,$=0,K=0,Ne=M.length;for(;K!==Ne&&M[K]===0;)K++,H++;let xe=(Ne-K)*v+1>>>0,Te=new Uint8Array(xe);for(;K!==Ne;){let br=M[K],dr=0;for(let jr=xe-1;(br!==0||dr<$)&&jr!==-1;jr--,dr++)br+=256*Te[jr]>>>0,Te[jr]=br%c>>>0,br=br/c>>>0;if(br!==0)throw new Error("Non-zero carry");$=dr,K++}let Tt=xe-$;for(;Tt!==xe&&Te[Tt]===0;)Tt++;let Dt=f.repeat(H);for(;Tt<xe;++Tt)Dt+=a.charAt(Te[Tt]);return Dt}t(E,"encode");function A(M){if(typeof M!="string")throw new TypeError("Expected String");if(M.length===0)return new Uint8Array;let H=0,$=0,K=0;for(;M[H]===f;)$++,H++;let Ne=(M.length-H)*d+1>>>0,xe=new Uint8Array(Ne);for(;M[H];){let br=s[M.charCodeAt(H)];if(br===255)return;let dr=0;for(let jr=Ne-1;(br!==0||dr<K)&&jr!==-1;jr--,dr++)br+=c*xe[jr]>>>0,xe[jr]=br%256>>>0,br=br/256>>>0;if(br!==0)throw new Error("Non-zero carry");K=dr,H++}let Te=Ne-K;for(;Te!==Ne&&xe[Te]===0;)Te++;let Tt=new Uint8Array($+(Ne-Te)),Dt=$;for(;Te!==Ne;)Tt[Dt++]=xe[Te++];return Tt}t(A,"decodeUnsafe");function O(M){let H=A(M);if(H)return H;throw new Error("Non-base"+c+" character")}return t(O,"decode"),{encode:E,decodeUnsafe:A,decode:O}}t(B_r,"base");var gdt=B_r;var U_r="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",Wfe=gdt(U_r);var a8e="2024-09-02",ydt=Object.freeze({none:{runOutboundPoliciesOnHandlerOnAllStatuses:!1,doNotRunHooksOnSystemRoutes:!1,removeAllVendorHeadersExceptListed:!1,allowCustomPorts:!1},"2023-03-14":{runOutboundPoliciesOnHandlerOnAllStatuses:!1,doNotRunHooksOnSystemRoutes:!1,removeAllVendorHeadersExceptListed:!1,allowCustomPorts:!1},"2024-01-15":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!1},"2024-03-14":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!1},"2024-09-02":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!0}});function vdt(){return new SC({build:{ACCOUNT_NAME:"mock-account-name",PROJECT_NAME:"mock-project-name",API_VERSION:"0.0.0",BUILD_ID:crypto.randomUUID(),TIMESTAMP:new Date().toISOString(),BUILD_ENV:"test",ZUPLO_VERSION:"0.0.0",COMPATIBILITY_DATE:a8e,ENVIRONMENT_TYPE:"mock-environment-type",GIT_SHA:void 0,IS_LOCAL_DEVELOPMENT:!1,COMPATIBILITY_FLAGS:ydt[a8e]},runtime:{RUNTIME_ENV:"test",RUNTIME_STAGE:"test",__ZUPLO_DEPLOYMENT_NAME:"mock-deployment-name",__ZUPLO_LOG_LEVEL:"debug",__ZUPLO_LOG_FORMAT:"pretty",__ZUPLO_MANAGEMENT_API_URL:"",__ZUPLO_RUNTIME_TYPE:"cloudflare",__ZUPLO_AUTH_API_JWT:""}})}t(vdt,"getMockEnvironment");var SC=class a{static{t(this,"Environment")}config;static#r;static#n=!1;static initialize(s){this.#r||(this.#r=new a(s),this.#n=!0)}static get instance(){return this.#n||(console.debug("Environment has not been initialized. This is okay when running tests, a mock environment will be used."),this.#r=vdt()),this.#r}constructor({build:s,runtime:c}){let f;try{if(c.__ZUPLO_CONFIG){let d=atob(c.__ZUPLO_CONFIG);f=JSON.parse(d)}if(c.ZUPLO_SYSTEM_CONFIGURATIONS){let d=new TextDecoder().decode(Wfe.decode(c.ZUPLO_SYSTEM_CONFIGURATIONS)),v=JSON.parse(d);for(let E of Object.keys(v))c[E]||(c[E]=v[E])}}catch(d){console.error("Failed to parse runtime configuration",d)}this.config=f??{},this.build=s,this.runtime=c,this.instanceId=crypto.randomUUID()}build;runtime;instanceId;get deploymentName(){return this.runtime.__ZUPLO_DEPLOYMENT_NAME??this.config.deployment_name??void 0}get useLegacyServiceRouting(){return this.config.use_legacy_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 zudokuHostUrl(){return this.runtime.__ZUPLO_ZUDOKU_HOST_URL??this.config.zudoku_host_url??"https://zudoku.zuploedge.com"}get buildAssetsUrl(){return this.runtime.__ZUPLO_BUILD_ASSETS_URL??this.config.build_assets_url??"https://build-assets.zuplo.com"}get zuploEdgeApiUrl(){return this.config.zuplo_edge_api_url??"https://api.zuploedge.com"}get remoteLogToken(){return this.runtime.__ZUPLO_REMOTE_LOG_TOKEN??this.config.remote_log_token??void 0}get zuploClientAuthBucketId(){return this.config.zuplo_auth_client_bucket_id??"auth_o8PUdhKxSTOiB794GWPwLQCD"}get managementApiURL(){return this.runtime.__ZUPLO_MANAGEMENT_API_URL??this.config.management_api_url??"https://api.zuplo.com"}get developerApiUrl(){return this.config.developer_api_url??"https://dev.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.zuploedge.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.zuploedge.com"}get apiKeyServiceUrl(){return this.runtime.__ZUPLO_API_KEY_SERVICE_URL??this.config.api_key_service_url??"https://apikey.zuploedge.com"}get meteringServiceUrl(){return this.config.metering_service_url??"https://meters.zuploedge.com"}get authApiJWT(){return this.runtime.__ZUPLO_AUTH_API_JWT??void 0}get authClientId(){return this.runtime.__ZUPLO_AUTH_CLIENT_ID}get authClientSecret(){return this.runtime.__ZUPLO_AUTH_CLIENT_SECRET}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.IS_LOCAL_DEVELOPMENT}get isTestMode(){return!!this.runtime.__ZUPLO_TEST_MODE}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.isWorkingCopy?"working-copy":"unknown"}get isWorkingCopy(){return this.build.ENVIRONMENT_TYPE==="WORKING_COPY"}};var $_r=["ZUPLO_USER_LOGGER_DATA_DOG_API_KEY","ZUPLO_USER_LOGGER_DATA_DOG_URL","ZUPLO_LOG_LEVEL","ZUPLO_HANDLER_WRITE_LOG_LEVEL"];function bdt(a){return a.startsWith("__ZUPLO")||a.startsWith("ZUPLO_")?!$_r.includes(a)&&!a.startsWith("ZUPLO_PUBLIC_"):!1}t(bdt,"isRestrictedEnvVariableName");function Sdt(a){return!!a.startsWith("ZUPLO_")}t(Sdt,"isZuploReadableEnvVariableName");var oUr=new Proxy({},{get(a,s){let c=String(s);switch(c){case"ZUPLO_ENVIRONMENT_TYPE":return SC.instance.loggingEnvironmentType;case"ZUPLO_ENVIRONMENT_STAGE":return SC.instance.loggingEnvironmentStage;case"ZUPLO_ENVIRONMENT_NAME":return SC.instance.runtime.__ZUPLO_DEPLOYMENT_NAME;case"ZUPLO_ACCOUNT_NAME":return SC.instance.build.ACCOUNT_NAME;case"ZUPLO_PROJECT_NAME":return SC.instance.build.PROJECT_NAME;case"ZUPLO_BUILD_ID":return SC.instance.build.BUILD_ID}if(!(bdt(c)&&!Sdt(c)))return SC.instance.runtime[c]}});function YQ(a,s,c){return`_${_6(`${a}_${s}_${c}`)}`}t(YQ,"getRawOperationDataIdentifierName");function o8e(a,s,c,f){return`_${_6(a.toLowerCase())}_${s.toLowerCase()}_${c.toLowerCase()}_${f.toLowerCase()}`}t(o8e,"getIdForParameterSchema");function c8e(a,s,c){return`_${_6(a.toLowerCase())}_${s.toLowerCase()}_rb_${_6(c.toLowerCase())}`}t(c8e,"getIdForRequestBodySchema");function XQ(a,s){return`_${_6(a)}_${_6(s)}`}t(XQ,"getIdForRefSchema");function _6(a){return a.replace(/[^a-zA-Z0-9]/g,"_")}t(_6,"sanitizedIdentifierName");var Zyt=W_(fht(),1);import ype from"path";var dK=class{static{t(this,"R")}type=3;name="";prefix="";value="";suffix="";modifier=3;constructor(a,s,c,f,d,v){this.type=a,this.name=s,this.prefix=c,this.value=f,this.suffix=d,this.modifier=v}hasCustomName(){return this.name!==""&&typeof this.name!="number"}},Omr=/[$_\p{ID_Start}]/u,Fmr=/[$_\u200C\u200D\p{ID_Continue}]/u,rOe=".*";function Lmr(a,s){return(s?/^[\x00-\xFF]*$/:/^[\x00-\x7F]*$/).test(a)}t(Lmr,"Re");function dht(a,s=!1){let c=[],f=0;for(;f<a.length;){let d=a[f],v=t(function(E){if(!s)throw new TypeError(E);c.push({type:"INVALID_CHAR",index:f,value:a[f++]})},"c");if(d==="*"){c.push({type:"ASTERISK",index:f,value:a[f++]});continue}if(d==="+"||d==="?"){c.push({type:"OTHER_MODIFIER",index:f,value:a[f++]});continue}if(d==="\\"){c.push({type:"ESCAPED_CHAR",index:f++,value:a[f++]});continue}if(d==="{"){c.push({type:"OPEN",index:f,value:a[f++]});continue}if(d==="}"){c.push({type:"CLOSE",index:f,value:a[f++]});continue}if(d===":"){let E="",A=f+1;for(;A<a.length;){let O=a.substr(A,1);if(A===f+1&&Omr.test(O)||A!==f+1&&Fmr.test(O)){E+=a[A++];continue}break}if(!E){v(`Missing parameter name at ${f}`);continue}c.push({type:"NAME",index:f,value:E}),f=A;continue}if(d==="("){let E=1,A="",O=f+1,M=!1;if(a[O]==="?"){v(`Pattern cannot start with "?" at ${O}`);continue}for(;O<a.length;){if(!Lmr(a[O],!1)){v(`Invalid character '${a[O]}' at ${O}.`),M=!0;break}if(a[O]==="\\"){A+=a[O++]+a[O++];continue}if(a[O]===")"){if(E--,E===0){O++;break}}else if(a[O]==="("&&(E++,a[O+1]!=="?")){v(`Capturing groups are not allowed at ${O}`),M=!0;break}A+=a[O++]}if(M)continue;if(E){v(`Unbalanced pattern at ${f}`);continue}if(!A){v(`Missing pattern at ${f}`);continue}c.push({type:"REGEX",index:f,value:A}),f=O;continue}c.push({type:"CHAR",index:f,value:a[f++]})}return c.push({type:"END",index:f,value:""}),c}t(dht,"v");function mht(a,s={}){let c=dht(a);s.delimiter??="/#?",s.prefixes??="./";let f=`[^${xC(s.delimiter)}]+?`,d=[],v=0,E=0,A="",O=new Set,M=t(dr=>{if(E<c.length&&c[E].type===dr)return c[E++].value},"a"),H=t(()=>M("OTHER_MODIFIER")??M("ASTERISK"),"f"),$=t(dr=>{let jr=M(dr);if(jr!==void 0)return jr;let{type:Cr,index:pr}=c[E];throw new TypeError(`Unexpected ${Cr} at ${pr}, expected ${dr}`)},"d"),K=t(()=>{let dr="",jr;for(;jr=M("CHAR")??M("ESCAPED_CHAR");)dr+=jr;return dr},"T"),Ne=t(dr=>dr,"Se"),xe=s.encodePart||Ne,Te="",Tt=t(dr=>{Te+=dr},"U"),Dt=t(()=>{Te.length&&(d.push(new dK(3,"","",xe(Te),"",3)),Te="")},"$"),br=t((dr,jr,Cr,pr,sr)=>{let Cs=3;switch(sr){case"?":Cs=1;break;case"*":Cs=0;break;case"+":Cs=2;break}if(!jr&&!Cr&&Cs===3){Tt(dr);return}if(Dt(),!jr&&!Cr){if(!dr)return;d.push(new dK(3,"","",xe(dr),"",Cs));return}let Di;Cr?Cr==="*"?Di=rOe:Di=Cr:Di=f;let _o=2;Di===f?(_o=1,Di=""):Di===rOe&&(_o=0,Di="");let hi;if(jr?hi=jr:Cr&&(hi=v++),O.has(hi))throw new TypeError(`Duplicate name '${hi}'.`);O.add(hi),d.push(new dK(_o,hi,xe(dr),Di,xe(pr),Cs))},"V");for(;E<c.length;){let dr=M("CHAR"),jr=M("NAME"),Cr=M("REGEX");if(!jr&&!Cr&&(Cr=M("ASTERISK")),jr||Cr){let sr=dr??"";s.prefixes.indexOf(sr)===-1&&(Tt(sr),sr=""),Dt();let Cs=H();br(sr,jr,Cr,"",Cs);continue}let pr=dr??M("ESCAPED_CHAR");if(pr){Tt(pr);continue}if(M("OPEN")){let sr=K(),Cs=M("NAME"),Di=M("REGEX");!Cs&&!Di&&(Di=M("ASTERISK"));let _o=K();$("CLOSE");let hi=H();br(sr,Cs,Di,_o,hi);continue}Dt(),$("END")}return d}t(mht,"D");function xC(a){return a.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}t(xC,"S");function _ht(a){return a&&a.ignoreCase?"ui":"u"}t(_ht,"X");function Rmr(a,s,c){return hht(mht(a,c),s,c)}t(Rmr,"Z");function wB(a){switch(a){case 0:return"*";case 1:return"?";case 2:return"+";case 3:return""}}t(wB,"k");function hht(a,s,c={}){c.delimiter??="/#?",c.prefixes??="./",c.sensitive??=!1,c.strict??=!1,c.end??=!0,c.start??=!0,c.endsWith="";let f=c.start?"^":"";for(let A of a){if(A.type===3){A.modifier===3?f+=xC(A.value):f+=`(?:${xC(A.value)})${wB(A.modifier)}`;continue}s&&s.push(A.name);let O=`[^${xC(c.delimiter)}]+?`,M=A.value;if(A.type===1?M=O:A.type===0&&(M=rOe),!A.prefix.length&&!A.suffix.length){A.modifier===3||A.modifier===1?f+=`(${M})${wB(A.modifier)}`:f+=`((?:${M})${wB(A.modifier)})`;continue}if(A.modifier===3||A.modifier===1){f+=`(?:${xC(A.prefix)}(${M})${xC(A.suffix)})`,f+=wB(A.modifier);continue}f+=`(?:${xC(A.prefix)}`,f+=`((?:${M})(?:`,f+=xC(A.suffix),f+=xC(A.prefix),f+=`(?:${M}))*)${xC(A.suffix)})`,A.modifier===0&&(f+="?")}let d=`[${xC(c.endsWith)}]|$`,v=`[${xC(c.delimiter)}]`;if(c.end)return c.strict||(f+=`${v}?`),c.endsWith.length?f+=`(?=${d})`:f+="$",new RegExp(f,_ht(c));c.strict||(f+=`(?:${v}(?=${d}))?`);let E=!1;if(a.length){let A=a[a.length-1];A.type===3&&A.modifier===3&&(E=c.delimiter.indexOf(A)>-1)}return E||(f+=`(?=${v}|${d})`),new RegExp(f,_ht(c))}t(hht,"F");var LN={delimiter:"",prefixes:"",sensitive:!0,strict:!0},Mmr={delimiter:".",prefixes:"",sensitive:!0,strict:!0},jmr={delimiter:"/",prefixes:"/",sensitive:!0,strict:!0};function Bmr(a,s){return a.length?a[0]==="/"?!0:!s||a.length<2?!1:(a[0]=="\\"||a[0]=="{")&&a[1]=="/":!1}t(Bmr,"J");function ght(a,s){return a.startsWith(s)?a.substring(s.length,a.length):a}t(ght,"Q");function Umr(a,s){return a.endsWith(s)?a.substr(0,a.length-s.length):a}t(Umr,"Ee");function yht(a){return!a||a.length<2?!1:a[0]==="["||(a[0]==="\\"||a[0]==="{")&&a[1]==="["}t(yht,"W");var vht=["ftp","file","http","https","ws","wss"];function bht(a){if(!a)return!0;for(let s of vht)if(a.test(s))return!0;return!1}t(bht,"N");function $mr(a,s){if(a=ght(a,"#"),s||a==="")return a;let c=new URL("https://example.com");return c.hash=a,c.hash?c.hash.substring(1,c.hash.length):""}t($mr,"te");function Jmr(a,s){if(a=ght(a,"?"),s||a==="")return a;let c=new URL("https://example.com");return c.search=a,c.search?c.search.substring(1,c.search.length):""}t(Jmr,"re");function zmr(a,s){return s||a===""?a:yht(a)?Cht(a):Tht(a)}t(zmr,"ne");function qmr(a,s){if(s||a==="")return a;let c=new URL("https://example.com");return c.password=a,c.password}t(qmr,"se");function Vmr(a,s){if(s||a==="")return a;let c=new URL("https://example.com");return c.username=a,c.username}t(Vmr,"ie");function Wmr(a,s,c){if(c||a==="")return a;if(s&&!vht.includes(s))return new URL(`${s}:${a}`).pathname;let f=a[0]=="/";return a=new URL(f?a:"/-"+a,"https://example.com").pathname,f||(a=a.substring(2,a.length)),a}t(Wmr,"ae");function Hmr(a,s,c){return Sht(s)===a&&(a=""),c||a===""?a:Eht(a)}t(Hmr,"oe");function Gmr(a,s){return a=Umr(a,":"),s||a===""?a:nOe(a)}t(Gmr,"ce");function Sht(a){switch(a){case"ws":case"http":return"80";case"wws":case"https":return"443";case"ftp":return"21";default:return""}}t(Sht,"_");function nOe(a){if(a==="")return a;if(/^[-+.A-Za-z0-9]*$/.test(a))return a.toLowerCase();throw new TypeError(`Invalid protocol '${a}'.`)}t(nOe,"y");function Qmr(a){if(a==="")return a;let s=new URL("https://example.com");return s.username=a,s.username}t(Qmr,"le");function Kmr(a){if(a==="")return a;let s=new URL("https://example.com");return s.password=a,s.password}t(Kmr,"fe");function Tht(a){if(a==="")return a;if(/[\t\n\r #%/:<>?@[\]^\\|]/g.test(a))throw new TypeError(`Invalid hostname '${a}'`);let s=new URL("https://example.com");return s.hostname=a,s.hostname}t(Tht,"z");function Cht(a){if(a==="")return a;if(/[^0-9a-fA-F[\]:]/g.test(a))throw new TypeError(`Invalid IPv6 hostname '${a}'`);return a.toLowerCase()}t(Cht,"j");function Eht(a){if(a===""||/^[0-9]*$/.test(a)&&parseInt(a)<=65535)return a;throw new TypeError(`Invalid port '${a}'.`)}t(Eht,"K");function Ymr(a){if(a==="")return a;let s=new URL("https://example.com");return s.pathname=a[0]!=="/"?"/-"+a:a,a[0]!=="/"?s.pathname.substring(2,s.pathname.length):s.pathname}t(Ymr,"he");function Xmr(a){return a===""?a:new URL(`data:${a}`).pathname}t(Xmr,"ue");function Zmr(a){if(a==="")return a;let s=new URL("https://example.com");return s.search=a,s.search.substring(1,s.search.length)}t(Zmr,"de");function ehr(a){if(a==="")return a;let s=new URL("https://example.com");return s.hash=a,s.hash.substring(1,s.hash.length)}t(ehr,"pe");var thr=class{static{t(this,"H")}#r;#n=[];#e={};#t=0;#s=1;#p=0;#a=0;#_=0;#c=0;#l=!1;constructor(a){this.#r=a}get result(){return this.#e}parse(){for(this.#n=dht(this.#r,!0);this.#t<this.#n.length;this.#t+=this.#s){if(this.#s=1,this.#n[this.#t].type==="END"){if(this.#a===0){this.#v(),this.#D()?this.#i(9,1):this.#y()?this.#i(8,1):this.#i(7,0);continue}else if(this.#a===2){this.#d(5);continue}this.#i(10,0);break}if(this.#_>0)if(this.#o())this.#_-=1;else continue;if(this.#k()){this.#_+=1;continue}switch(this.#a){case 0:this.#g()&&this.#d(1);break;case 1:if(this.#g()){this.#I();let a=7,s=1;this.#x()?(a=2,s=3):this.#l&&(a=2),this.#i(a,s)}break;case 2:this.#C()?this.#d(3):(this.#E()||this.#y()||this.#D())&&this.#d(5);break;case 3:this.#b()?this.#i(4,1):this.#C()&&this.#i(5,1);break;case 4:this.#C()&&this.#i(5,1);break;case 5:this.#N()?this.#c+=1:this.#S()&&(this.#c-=1),this.#A()&&!this.#c?this.#i(6,1):this.#E()?this.#i(7,0):this.#y()?this.#i(8,1):this.#D()&&this.#i(9,1);break;case 6:this.#E()?this.#i(7,0):this.#y()?this.#i(8,1):this.#D()&&this.#i(9,1);break;case 7:this.#y()?this.#i(8,1):this.#D()&&this.#i(9,1);break;case 8:this.#D()&&this.#i(9,1);break;case 9:break;case 10:break}}this.#e.hostname!==void 0&&this.#e.port===void 0&&(this.#e.port="")}#i(a,s){switch(this.#a){case 0:break;case 1:this.#e.protocol=this.#T();break;case 2:break;case 3:this.#e.username=this.#T();break;case 4:this.#e.password=this.#T();break;case 5:this.#e.hostname=this.#T();break;case 6:this.#e.port=this.#T();break;case 7:this.#e.pathname=this.#T();break;case 8:this.#e.search=this.#T();break;case 9:this.#e.hash=this.#T();break;case 10:break}this.#a!==0&&a!==10&&([1,2,3,4].includes(this.#a)&&[6,7,8,9].includes(a)&&(this.#e.hostname??=""),[1,2,3,4,5,6].includes(this.#a)&&[8,9].includes(a)&&(this.#e.pathname??=this.#l?"/":""),[1,2,3,4,5,6,7].includes(this.#a)&&a===9&&(this.#e.search??="")),this.#f(a,s)}#f(a,s){this.#a=a,this.#p=this.#t+s,this.#t+=s,this.#s=0}#v(){this.#t=this.#p,this.#s=0}#d(a){this.#v(),this.#a=a}#u(a){return a<0&&(a=this.#n.length-a),a<this.#n.length?this.#n[a]:this.#n[this.#n.length-1]}#m(a,s){let c=this.#u(a);return c.value===s&&(c.type==="CHAR"||c.type==="ESCAPED_CHAR"||c.type==="INVALID_CHAR")}#g(){return this.#m(this.#t,":")}#x(){return this.#m(this.#t+1,"/")&&this.#m(this.#t+2,"/")}#C(){return this.#m(this.#t,"@")}#b(){return this.#m(this.#t,":")}#A(){return this.#m(this.#t,":")}#E(){return this.#m(this.#t,"/")}#y(){if(this.#m(this.#t,"?"))return!0;if(this.#n[this.#t].value!=="?")return!1;let a=this.#u(this.#t-1);return a.type!=="NAME"&&a.type!=="REGEX"&&a.type!=="CLOSE"&&a.type!=="ASTERISK"}#D(){return this.#m(this.#t,"#")}#k(){return this.#n[this.#t].type=="OPEN"}#o(){return this.#n[this.#t].type=="CLOSE"}#N(){return this.#m(this.#t,"[")}#S(){return this.#m(this.#t,"]")}#T(){let a=this.#n[this.#t],s=this.#u(this.#p).index;return this.#r.substring(s,a.index)}#I(){let a={};Object.assign(a,LN),a.encodePart=nOe;let s=Rmr(this.#T(),void 0,a);this.#l=bht(s)}},tOe=["protocol","username","password","hostname","port","pathname","search","hash"],FN="*";function pht(a,s){if(typeof a!="string")throw new TypeError("parameter 1 is not of type 'string'.");let c=new URL(a,s);return{protocol:c.protocol.substring(0,c.protocol.length-1),username:c.username,password:c.password,hostname:c.hostname,port:c.port,pathname:c.pathname,search:c.search!==""?c.search.substring(1,c.search.length):void 0,hash:c.hash!==""?c.hash.substring(1,c.hash.length):void 0}}t(pht,"ge");function g6(a,s){return s?pK(a):a}t(g6,"b");function _K(a,s,c){let f;if(typeof s.baseURL=="string")try{f=new URL(s.baseURL),s.protocol===void 0&&(a.protocol=g6(f.protocol.substring(0,f.protocol.length-1),c)),!c&&s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.username===void 0&&(a.username=g6(f.username,c)),!c&&s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.username===void 0&&s.password===void 0&&(a.password=g6(f.password,c)),s.protocol===void 0&&s.hostname===void 0&&(a.hostname=g6(f.hostname,c)),s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&(a.port=g6(f.port,c)),s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.pathname===void 0&&(a.pathname=g6(f.pathname,c)),s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.pathname===void 0&&s.search===void 0&&(a.search=g6(f.search.substring(1,f.search.length),c)),s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.pathname===void 0&&s.search===void 0&&s.hash===void 0&&(a.hash=g6(f.hash.substring(1,f.hash.length),c))}catch{throw new TypeError(`invalid baseURL '${s.baseURL}'.`)}if(typeof s.protocol=="string"&&(a.protocol=Gmr(s.protocol,c)),typeof s.username=="string"&&(a.username=Vmr(s.username,c)),typeof s.password=="string"&&(a.password=qmr(s.password,c)),typeof s.hostname=="string"&&(a.hostname=zmr(s.hostname,c)),typeof s.port=="string"&&(a.port=Hmr(s.port,a.protocol,c)),typeof s.pathname=="string"){if(a.pathname=s.pathname,f&&!Bmr(a.pathname,c)){let d=f.pathname.lastIndexOf("/");d>=0&&(a.pathname=g6(f.pathname.substring(0,d+1),c)+a.pathname)}a.pathname=Wmr(a.pathname,a.protocol,c)}return typeof s.search=="string"&&(a.search=Jmr(s.search,c)),typeof s.hash=="string"&&(a.hash=$mr(s.hash,c)),a}t(_K,"w");function pK(a){return a.replace(/([+*?:{}()\\])/g,"\\$1")}t(pK,"C");function rhr(a){return a.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}t(rhr,"Oe");function nhr(a,s){s.delimiter??="/#?",s.prefixes??="./",s.sensitive??=!1,s.strict??=!1,s.end??=!0,s.start??=!0,s.endsWith="";let c=".*",f=`[^${rhr(s.delimiter)}]+?`,d=/[$_\u200C\u200D\p{ID_Continue}]/u,v="";for(let E=0;E<a.length;++E){let A=a[E];if(A.type===3){if(A.modifier===3){v+=pK(A.value);continue}v+=`{${pK(A.value)}}${wB(A.modifier)}`;continue}let O=A.hasCustomName(),M=!!A.suffix.length||!!A.prefix.length&&(A.prefix.length!==1||!s.prefixes.includes(A.prefix)),H=E>0?a[E-1]:null,$=E<a.length-1?a[E+1]:null;if(!M&&O&&A.type===1&&A.modifier===3&&$&&!$.prefix.length&&!$.suffix.length)if($.type===3){let K=$.value.length>0?$.value[0]:"";M=d.test(K)}else M=!$.hasCustomName();if(!M&&!A.prefix.length&&H&&H.type===3){let K=H.value[H.value.length-1];M=s.prefixes.includes(K)}M&&(v+="{"),v+=pK(A.prefix),O&&(v+=`:${A.name}`),A.type===2?v+=`(${A.value})`:A.type===1?O||(v+=`(${f})`):A.type===0&&(!O&&(!H||H.type===3||H.modifier!==3||M||A.prefix!=="")?v+="*":v+=`(${c})`),A.type===1&&O&&A.suffix.length&&d.test(A.suffix[0])&&(v+="\\"),v+=pK(A.suffix),M&&(v+="}"),A.modifier!==3&&(v+=wB(A.modifier))}return v}t(nhr,"ke");var xht=class{static{t(this,"me")}#r;#n={};#e={};#t={};#s={};#p=!1;constructor(a={},s,c){try{let f;if(typeof s=="string"?f=s:c=s,typeof a=="string"){let A=new thr(a);if(A.parse(),a=A.result,f===void 0&&typeof a.protocol!="string")throw new TypeError("A base URL must be provided for a relative constructor string.");a.baseURL=f}else{if(!a||typeof a!="object")throw new TypeError("parameter 1 is not of type 'string' and cannot convert to dictionary.");if(f)throw new TypeError("parameter 1 is not of type 'string'.")}typeof c>"u"&&(c={ignoreCase:!1});let d={ignoreCase:c.ignoreCase===!0},v={pathname:FN,protocol:FN,username:FN,password:FN,hostname:FN,port:FN,search:FN,hash:FN};this.#r=_K(v,a,!0),Sht(this.#r.protocol)===this.#r.port&&(this.#r.port="");let E;for(E of tOe){if(!(E in this.#r))continue;let A={},O=this.#r[E];switch(this.#e[E]=[],E){case"protocol":Object.assign(A,LN),A.encodePart=nOe;break;case"username":Object.assign(A,LN),A.encodePart=Qmr;break;case"password":Object.assign(A,LN),A.encodePart=Kmr;break;case"hostname":Object.assign(A,Mmr),yht(O)?A.encodePart=Cht:A.encodePart=Tht;break;case"port":Object.assign(A,LN),A.encodePart=Eht;break;case"pathname":bht(this.#n.protocol)?(Object.assign(A,jmr,d),A.encodePart=Ymr):(Object.assign(A,LN,d),A.encodePart=Xmr);break;case"search":Object.assign(A,LN,d),A.encodePart=Zmr;break;case"hash":Object.assign(A,LN,d),A.encodePart=ehr;break}try{this.#s[E]=mht(O,A),this.#n[E]=hht(this.#s[E],this.#e[E],A),this.#t[E]=nhr(this.#s[E],A),this.#p=this.#p||this.#s[E].some(M=>M.type===2)}catch{throw new TypeError(`invalid ${E} pattern '${this.#r[E]}'.`)}}}catch(f){throw new TypeError(`Failed to construct 'URLPattern': ${f.message}`)}}test(a={},s){let c={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof a!="string"&&s)throw new TypeError("parameter 1 is not of type 'string'.");if(typeof a>"u")return!1;try{typeof a=="object"?c=_K(c,a,!1):c=_K(c,pht(a,s),!1)}catch{return!1}let f;for(f of tOe)if(!this.#n[f].exec(c[f]))return!1;return!0}exec(a={},s){let c={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof a!="string"&&s)throw new TypeError("parameter 1 is not of type 'string'.");if(typeof a>"u")return;try{typeof a=="object"?c=_K(c,a,!1):c=_K(c,pht(a,s),!1)}catch{return null}let f={};s?f.inputs=[a,s]:f.inputs=[a];let d;for(d of tOe){let v=this.#n[d].exec(c[d]);if(!v)return null;let E={};for(let[A,O]of this.#e[d].entries())if(typeof O=="string"||typeof O=="number"){let M=v[A+1];E[O]=M}f[d]={input:c[d]??"",groups:E}}return f}static compareComponent(a,s,c){let f=t((A,O)=>{for(let M of["type","modifier","prefix","value","suffix"]){if(A[M]<O[M])return-1;if(A[M]!==O[M])return 1}return 0},"o"),d=new dK(3,"","","","",3),v=new dK(0,"","","","",3),E=t((A,O)=>{let M=0;for(;M<Math.min(A.length,O.length);++M){let H=f(A[M],O[M]);if(H)return H}return A.length===O.length?0:f(A[M]??d,O[M]??d)},"s");return!s.#t[a]&&!c.#t[a]?0:s.#t[a]&&!c.#t[a]?E(s.#s[a],[v]):!s.#t[a]&&c.#t[a]?E([v],c.#s[a]):E(s.#s[a],c.#s[a])}get protocol(){return this.#t.protocol}get username(){return this.#t.username}get password(){return this.#t.password}get hostname(){return this.#t.hostname}get port(){return this.#t.port}get pathname(){return this.#t.pathname}get search(){return this.#t.search}get hash(){return this.#t.hash}get hasRegExpGroups(){return this.#p}};globalThis.URLPattern||(globalThis.URLPattern=xht);import{AssertionError as ihr}from"assert";function y6(a,s){if(a===!1)throw new ihr({message:s})}t(y6,"assert");var Jc;(function(a){a.Object="Object",a.Property="Property",a.Array="Array",a.Literal="Literal",a.TemplateString="TemplateString",a.Identifier="Identifier",a.FunctionCall="FunctionCall",a.Raw="Raw"})(Jc||(Jc={}));function PB(a){return a.type===Jc.Object}t(PB,"isAstObject");function v6(a){return a.type===Jc.Property}t(v6,"isAstProperty");function Dht(a){return a.type===Jc.Array}t(Dht,"isAstArray");function NB(a){return a.type===Jc.Literal}t(NB,"isAstLiteral");function f7(a){if(a===void 0)throw new Error("Node is undefined");if(!PB(a))throw new Error("Node is not object")}t(f7,"assertAstObject");import{findNodeAtLocation as shr,getNodeValue as ahr,printParseErrorCode as ohr,visit as chr}from"jsonc-parser";var lhr={DEFAULT:{allowTrailingComma:!1}};function mK(a,s=[],c=lhr.DEFAULT){let f={type:"array",offset:-1,length:-1,line:-1,column:-1,children:[],parent:void 0};function d(O){f.type==="property"&&(f.length=O-f.offset,f=f.parent)}t(d,"ensurePropertyComplete");function v(O){return f.children?.push(O),O}t(v,"onValue"),chr(a,{onObjectBegin:t((O,M,H)=>{f=v({type:"object",offset:O,length:-1,line:M+1,column:H+1,parent:f,children:[]})},"onObjectBegin"),onObjectProperty:t((O,M,H,$,K)=>{f=v({type:"property",offset:M,length:-1,line:$+1,column:K+1,parent:f,children:[]}),f.children?.push({type:"string",value:O,offset:M,length:H,line:$,column:K,parent:f})},"onObjectProperty"),onObjectEnd:t((O,M)=>{d(O+M),f.length=O+M-f.offset,f=f.parent,d(O+M)},"onObjectEnd"),onArrayBegin:t((O,M,H,$)=>{f=v({type:"array",offset:O,length:-1,line:H+1,column:$+1,parent:f,children:[]})},"onArrayBegin"),onArrayEnd:t((O,M)=>{f.length=O+M-f.offset,f=f.parent,d(O+M)},"onArrayEnd"),onLiteralValue:t((O,M,H,$,K)=>{v({type:uhr(O),offset:M,length:H,line:$+1,column:K+1,parent:f,value:O}),d(M+H)},"onLiteralValue"),onSeparator:t((O,M)=>{f.type==="property"&&(O===":"?f.colonOffset=M:O===","&&d(M))},"onSeparator"),onError:t((O,M,H,$,K)=>{s.push({error:O,offset:M,length:H,line:$+1,column:K+1})},"onError")},c);let A=f.children[0];return A&&delete A.parent,A}t(mK,"parse");function uhr(a){switch(typeof a){case"boolean":return"boolean";case"number":return"number";case"string":return"string";case"object":{if(a){if(Array.isArray(a))return"array"}else return"null";return"object"}default:return"null"}}t(uhr,"getNodeType");function iOe(a,s){return shr(a,s)}t(iOe,"findNodeAtLocation");function hK(a){return ahr(a)}t(hK,"getNodeValue");function Aht(a){return ohr(a)}t(Aht,"printParseErrorCode");var gK=class{static{t(this,"AstAdapter")}parse(s){let f=mK(s,[]);if(f)return this.parseNode(f,void 0);throw new Error("Failed to parse JSON")}convert(s){return this.parseNode(s,void 0)}parseNode(s,c){switch(s.type){case"object":return this.createObject(s,c);case"array":return this.createArray(s,c);case"property":return this.createProperty(s,c);case"string":return this.createLiteral(s,c);case"number":return this.createLiteral(s,c);case"boolean":return this.createLiteral(s,c);case"null":return this.createLiteral(s,c)}}createLiteral(s,c){return{type:Jc.Literal,location:{line:s.line,column:s.column},parent:c,value:s.type==="null"?null:s.value}}createObject(s,c){let f={type:Jc.Object,children:[],parent:c,location:{line:s.line,column:s.column}};return s.children?.forEach(d=>{f.children.push(this.parseNode(d,f))}),f}createProperty(s,c){y6(s.children?.length===2,"Invalid property node");let f={type:Jc.Property,location:{line:s.line,column:s.column},parent:c,name:null,value:null};return f.name={value:s.children[0].value,location:{line:s.line,column:s.column},type:Jc.Identifier,parent:f},f.value=this.parseNode(s.children[1],f),f}createArray(s,c){let f={type:Jc.Array,location:{line:s.line,column:s.column},parent:c,children:[]};return s.children?.forEach(d=>f.children.push(this.parseNode(d,f))),f}};var Mx={createLiteral:t((a,s)=>({type:Jc.Literal,parent:s,value:a}),"createLiteral"),createTemplateString:t((a,s)=>({type:Jc.TemplateString,parent:s,value:a}),"createTemplateString"),createIdentifier:t((a,s)=>({type:Jc.Identifier,value:a,parent:s}),"createIdentifier"),createProperty:t((a,s,c)=>{let f={type:Jc.Property,parent:c,name:null,value:s};return f.name={value:a,type:Jc.Identifier,parent:f},f.value.parent=f,f},"createProperty"),createArrayOfLiterals:t((a,s)=>{let c={type:Jc.Array,parent:s,children:[]};for(let f of a)c.children.push(Mx.createLiteral(f,c));return c},"createArrayOfLiterals")};var fhr=/^[a-zA-Z_$][a-zA-Z0-9_$]*$/,yK=class{static{t(this,"SourceGenerator")}generate(s){let c=[];return this.generateSource(c,s),c.join("")}generateSource(s,c){switch(c.type){case Jc.Array:return this.generateArray(s,c);case Jc.Object:return this.generateObject(s,c);case Jc.Property:return this.generateProperty(s,c);case Jc.Literal:return this.generateLiteral(s,c);case Jc.FunctionCall:return this.generateFunctionCall(s,c);case Jc.Identifier:return this.generateIdentifier(s,c);case Jc.Raw:return this.generateRaw(s,c);case Jc.TemplateString:return this.generateTemplateString(s,c)}}generateArray(s,c){s.push("["),c.children.map(f=>{this.generateSource(s,f),s.push(",")}),s.push("]")}generateObject(s,c){s.push("{"),c.children.forEach(f=>{this.generateSource(s,f),s.push(",")}),s.push("}")}generateProperty(s,c){this.generateIdentifier(s,c.name),s.push(":"),this.generateSource(s,c.value)}generateFunctionCall(s,c){s.push(c.name.value),s.push("("),c.children.forEach((f,d,v)=>{this.generateSource(s,f),d<v.length&&s.push(",")}),s.push(")")}generateRaw(s,c){s.push(c.value)}generateTemplateString(s,c){s.push("`"),s.push(c.value.replaceAll("`","\\`")),s.push("`")}generateLiteral(s,c){if(c.value===null)return s.push("null");switch(typeof c.value){case"number":case"boolean":return s.push(`${c.value}`);case"string":{let f=c.value,d=JSON.stringify(f);return s.push(`${d}`)}}}generateIdentifier(s,c){let f=fhr.test(c.value)?c.value:`'${c.value}'`;s.push(f)}};import{parse as _hr}from"@swc/core";import phr from"fs/promises";var kht=t(async a=>{let s=new Set;try{let c=await phr.readFile(a,"utf-8");(await _hr(c,{syntax:"typescript"})).body.forEach(d=>{d.type==="ExportDefaultDeclaration"||d.type==="ExportDefaultExpression"?s.add("default"):d.type==="ExportDeclaration"&&d.declaration.type==="FunctionDeclaration"?s.add(d.declaration.identifier.value):d.type==="ExportDeclaration"&&d.declaration.type==="VariableDeclaration"&&d.declaration.declarations[0].id.type==="Identifier"&&s.add(d.declaration.declarations[0].id.value)})}catch{return null}return s},"getJSFileExports");var wht={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/fragments.schema.json",$defs:{corsPolicyConfiguration:{type:"object",required:["name","allowedOrigins"],additionalProperties:!1,properties:{name:{type:"string",pattern:"^[0-9a-z-]+$"},allowCredentials:{type:"boolean"},maxAge:{type:"number"},allowedOrigins:{oneOf:[{type:"array",items:{type:"string"}},{type:"string"}]},allowedMethods:{oneOf:[{type:"array",items:{$ref:"fragments.schema.json#/$defs/httpMethod"}},{type:"string"}]},allowedHeaders:{oneOf:[{type:"array",items:{type:"string"}},{type:"string"}]},exposeHeaders:{oneOf:[{type:"array",items:{type:"string"}},{type:"string"}]}}},handlerDefinition:{type:"object",properties:{module:{type:"string",pattern:"^\\$import\\([^ )]*?\\)$"},export:{type:"string"},options:{type:"object",additionalProperties:!0}},additionalProperties:!1,required:["module","export"]},httpMethod:{type:"string",enum:["GET","HEAD","POST","PUT","DELETE","CONNECT","OPTIONS","TRACE","PATCH"]}}};var sOe={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/policies.schema.json",title:"Policies Config File",type:"object",additionalProperties:!1,properties:{policies:{type:"array",items:{$ref:"policy-configuration.schema.json"}},corsPolicies:{type:"array",items:{$ref:"fragments.schema.json#/$defs/corsPolicyConfiguration"}}}};var Pht={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/policy-configuration.schema.json",title:"Policy Configuration Fragment",type:"object",required:["name","policyType","handler"],additionalProperties:!1,properties:{name:{type:"string",pattern:"^[0-9a-z-]+$"},policyType:{type:"string"},handler:{$ref:"fragments.schema.json#/$defs/handlerDefinition"},options:{type:"object",additionalProperties:!0}}};var aOe={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/route-configuration-open-api.schema.json",title:"Open API Route Configuration Fragment",description:"These are the properties that can appear under the x-zuplo-route extension in a PathObject in Open API. It's a subset of what can appear in Zuplo's routes.json.",type:"object",required:["handler"],additionalProperties:!1,properties:{label:{type:"string",description:"An internal user-friendly identifier of the route."},key:{type:"string",deprecated:!0},handler:{$ref:"fragments.schema.json#/$defs/handlerDefinition"},corsPolicy:{type:"string",pattern:"^[0-9a-z-]+$"},custom:{},policies:{type:"object",additionalProperties:!1,properties:{inbound:{type:"array",items:{type:"string",pattern:"^[0-9a-z-]+$"}},outbound:{type:"array",items:{type:"string",pattern:"^[0-9a-z-]+$"}}}},tags:{type:"array",items:{type:"string"}}}};var oOe={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/route-configuration.schema.json",title:"Route Configuration Fragment",description:"",type:"object",required:["path","methods","handler"],additionalProperties:!1,$defs:{corsPolicy:{type:"string",pattern:"^[0-9a-z-]+$"}},properties:{operationId:{type:"string"},path:{type:"string",pattern:"^/[^\\s]*$"},methods:{type:"array",items:{$ref:"fragments.schema.json#/$defs/httpMethod"}},label:{type:"string",description:"An internal user-friendly identifier of the route."},enforceOpenApi:{type:"boolean",description:"If true, schema validation found in the OpenAPI spec will be enforced on requests/responses."},key:{type:"string",deprecated:!0},handler:{$ref:"fragments.schema.json#/$defs/handlerDefinition"},corsPolicy:{$ref:"#/$defs/corsPolicy"},custom:{},policies:{type:"object",additionalProperties:!1,properties:{inbound:{type:"array",items:{type:"string",pattern:"^[0-9a-z-]+$"}},outbound:{type:"array",items:{type:"string",pattern:"^[0-9a-z-]+$"}}}},summary:{type:"string"},description:{type:"string"},excludeFromOpenApi:{type:"boolean"},tags:{type:"array",items:{type:"string"}}}};var zyt=W_(_yt(),1),qyt=W_(Jyt(),1);var upe=class a{static{t(this,"JsonValidator")}static#r=new a;static get instance(){return a.#r}ajv;constructor(){this.ajv=new qyt.Ajv2020({allErrors:!0,allowUnionTypes:!0}),this.ajv.addKeyword("faker"),(0,zyt.default)(this.ajv,{mode:"fast"})}addSchema(s,c){this.ajv.addSchema(s,c)}compile(s){let c=this.ajv.compile(s);return t(d=>({isValid:c(d),errors:this.toSimpleErrors(c.errors,d),warnings:[]}),"validator")}toSimpleErrors(s,c){let f=[];return s?.forEach(d=>{d.keyword==="enum"&&d.params.allowedValues&&Array.isArray(d.params.allowedValues)&&(d.message+=`; ${d.params.allowedValues.join(", ")}`),d.instancePath&&(d.instancePath=d.instancePath.replaceAll(/(\/)?(~1)(\/)?/gm,"/"));let v={details:{}},E=d.instancePath.split("/");if(E.length>2){let O=E[1],M=E[2]?parseInt(E[2]):0,H=E[3],$=isNaN(M)?void 0:c[O][M][H];v={details:{property:O,index:M,field:H,fieldValue:$}}}if(d.keyword==="required"&&d.params.missingProperty&&d.instancePath&&(d.message=`A 'path' is missing required property '${d.params.missingProperty}'`),d.keyword==="additionalProperties"&&d.params.additionalProperty&&d.instancePath&&(d.message=`A 'path' should NOT include property '${d.params.additionalProperty}'`),d.keyword==="type"&&d.params.type&&d.instancePath){let O=d.instancePath.split("/"),M=O[O.length-1];d.message=`Value of property '${M}' must be '${d.params.type}'`}let A=Object.assign(d,v);f.push(A)}),f}};var VN=upe.instance;VN.addSchema(oOe,"route-configuration.schema.json");VN.addSchema(Pht,"policy-configuration.schema.json");VN.addSchema(sOe,"policies.schema.json");VN.addSchema(aOe,"open-api-route-configuration.schema.json");VN.addSchema(wht,"fragments.schema.json");var aVr=VN.compile(oOe),Vyt=VN.compile(aOe),T7e=VN.compile(sOe);var fpe=class{static{t(this,"PoliciesConfigurationValidator")}results;validate(s){return this.results=T7e(s),this.results}};var _pe=class{static{t(this,"OpenAPILocalizedValidator")}results;validate(s){return this.results=Vyt(s),this.results}};import v2r from"path";var C7e=/\$import\((.*)\)/,ppe=/\$env\((.*?)\)/g;var E6=class extends Error{static{t(this,"CodeGenError")}location;constructor(s,c,f,d){super(s),this.location={file:c,namespace:"",line:f?f.line:0,column:f?f.column:0,length:0,lineText:d??"",suggestion:""}}},y2r=t(a=>{let s=[],c=a;for(;c.parent;)s.push(c),c=c.parent;return s.reverse()},"invertTree"),WN=t((a,s)=>{if(!a)return!1;let c=y2r(a);return s.split("/").every((v,E)=>{let A=c[E];return A?v==="*"||v6(A)&&A.name.value===v?!0:v==="{}"?A.type===Jc.Object:v==="[]"?A.type===Jc.Array:!1:!1})},"testPosition");var dpe=class{static{t(this,"AstTransformer")}errors=[];transform(s){return this.visitor(s),s}visitor(s){this.visit(s),PB(s)?s.children.forEach(c=>{this.visitor(c)}):Dht(s)?s.children.forEach(c=>{this.visitor(c)}):v6(s)&&this.visitor(s.value)}},Wyt=t((a,s,c)=>f=>{if(!v6(f)||!NB(f.value)||typeof f.value.value!="string")return;if(!a.some(v=>WN(f,v))){ppe.test(f.value.value)&&s.push(new E6("An $env() statement is not expected at this location.",c,f.location,f.value.value));return}let d=new RegExp(ppe).exec(f.value.value);if(d?.length===2&&d[0]===f.value.value){let v={type:Jc.Raw,parent:null,value:`environment["${d[1]}"]`};f.value=v}else{let v=f.value.value.replaceAll(new RegExp(ppe),(E,A)=>`\${environment["${A}"] ? environment["${A}"] : ""}`);v!==f.value.value&&(f.value=Mx.createTemplateString(v,f))}},"getEnvStatementTransformer");var YK="config/routes.json",b2r=["handler/{}/options/*","policies/[]/{}/handler/{}/options/*","corsPolicies/[]/{}/*"],S2r=["handler/{}/module","handler/{}/options/{}/policies/{}/inbound/[]/{}/module","handler/{}/options/{}/policies/{}/outbound/[]/{}/module","policies/[]/{}/handler/{}/module","policies/[]/{}/handler/{}/options/{}/identifier/{}/module","policies/[]/{}/handler/{}/options/{}/validator"],Hyt=["handler/{}/options/*","policies/[]/{}/handler/{}/options/*"],T2r="handler/{}/options/{}/rewritePattern",C2r="handler/{}/options/{}/baseUrl",mpe=class extends dpe{static{t(this,"OpenAPIRoutesFragmentAstTransformer")}importCount=0;addedImports=new Map;getImportName(s){this.addedImports.has(s)||this.addedImports.set(s,`__import${this.importCount++}`);let c=this.addedImports.get(s);if(!c)throw new Error("Import name is undefined. This should not happen.");return c}getImports(){let s=[];return this.addedImports.forEach((c,f)=>{s.push({name:c,path:f})}),s}visit(s){this.rewriteHandlerFunction(s),this.rewriteForwardFunction(s),this.replaceImportStatements(s),this.replaceEnvStatements(s)}rewriteHandlerFunction(s){if(!(!v6(s)||!NB(s.value)||typeof s.value.value!="string")&&WN(s,T2r)){if(!s.parent||!PB(s.parent)){this.errors.push(new E6("Invalid node, expected object",YK,s.parent?s.parent.location:s.location,void 0));return}let c=s.value.value,f={type:Jc.Raw,parent:null,value:Gyt(c)},d=Mx.createProperty("__rewriteFunction",f,s);s.parent.children.push(d)}}rewriteForwardFunction(s){if(!(!v6(s)||!NB(s.value)||typeof s.value.value!="string")&&WN(s,C2r)){if(!s.parent||!PB(s.parent)){this.errors.push(new E6("Invalid node, expected object",YK,s.parent?s.parent.location:s.location,void 0));return}let c=s.value.value,f={type:Jc.Raw,parent:null,value:Gyt(c)},d=Mx.createProperty("__rewriteFunction",f,s);s.parent.children.push(d)}}replaceImportStatements(s){if(!v6(s)||!NB(s.value))return;let c=s.value.value;if(typeof c!="string")return;if(!S2r.some(A=>WN(s,A))&&!Hyt.some(A=>WN(s,A))){if(C7e.test(c)){if(s.name.value==="$ref")return;this.errors.push(new E6("An $import() statement is not expected at this location.",YK,s.location,c))}return}let f=C7e.exec(c);if(Hyt.some(A=>WN(s,A))&&!f)return;if(!f){this.errors.push(new E6("Invalid $import() statement",YK,s.location,c));return}let d=f[1];d.startsWith(".")&&(d=v2r.join("..",d));let v=this.getImportName(d),E={type:Jc.Identifier,parent:s.parent,value:v};s.value=E}replaceEnvStatements=Wyt(b2r,this.errors,YK)};function Gyt(a){return`(request, context) => {
585
585
  const { params, url, query, method, headers } = request;
586
586
  const { host, hostname, origin, pathname, port, search } = new URL(url);
587
587
  const e = encodeURIComponent;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zuplo/core",
3
- "version": "6.33.10",
3
+ "version": "6.33.13",
4
4
  "repository": "https://github.com/zuplo/zuplo",
5
5
  "author": "Zuplo, Inc.",
6
6
  "type": "module",
@@ -40,8 +40,8 @@
40
40
  "prettier": "^3.3.3"
41
41
  },
42
42
  "peerDependencies": {
43
- "@zuplo/graphql": "^6.33.10",
44
- "@zuplo/otel": "^6.33.10",
45
- "@zuplo/runtime": "^6.33.10"
43
+ "@zuplo/graphql": "^6.33.13",
44
+ "@zuplo/otel": "^6.33.13",
45
+ "@zuplo/runtime": "^6.33.13"
46
46
  }
47
47
  }