@zuplo/core 6.51.45 → 6.51.46

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.
@@ -579,7 +579,7 @@ globstar while`,s,Q,l,Me,Ie),this.matchOne(s.slice(Q),l.slice(Me),_))return this
579
579
  `),stderr:b.join(`
580
580
  `),exitCode:D},"Tar process logs")}}t(tar,"tarFolder");async function rar({tarFilePath:a,outputDir:s,logger:l}){let _=[],h=[],b;try{await new Promise((D,N)=>{let M=Rut("sh",["-c",`tar -xvf ${a} -C ${s};`]);M.stdout.on("data",z=>{let ne=z.toString().trim();ne.length>0&&_.push(ne.trim())}),M.stderr.on("data",z=>{let ne=z.toString().trim();ne.length>0&&h.push(ne.trim())}),M.on("close",z=>{b=z,z===0?D():N(new Error(`tar process exited with code ${z}`))}),M.on("error",z=>{N(z)})})}catch(D){throw new Error("Failed to untar file",{cause:D})}finally{l.info({stdout:_.join(`
581
581
  `),stderr:h.join(`
582
- `),exitCode:b},"Untar process logs")}}t(rar,"untarFile");async function nar(a){if(await M3e(a))return await M3.rm(a,{recursive:!0})}t(nar,"deleteFolder");var ou=j3e;var IT=ap(R3e(),1);var sO=class extends Error{static{t(this,"CustomResolveError")}},j3=class{static{t(this,"RefParser")}sourceDirectory;logger;constructor(s,l){this.sourceDirectory=s,this.logger=l}dereference(s,l){return gG.$RefParser.dereference(s,{resolve:{json:!0,file:aue(this.sourceDirectory,this.logger),external:!0,http:!1},dereference:{circular:"ignore",onDereference:l?.onDereference}})}bundle(s){return gG.$RefParser.bundle(s,{resolve:{file:aue(this.sourceDirectory,this.logger),external:!0,http:!1}})}parse(s){return gG.$RefParser.parse(s,{resolve:{file:aue(this.sourceDirectory,this.logger),external:!0,http:!1}})}resolve(s){return gG.$RefParser.resolve(s,{resolve:{file:aue(this.sourceDirectory,this.logger),external:!0,http:!1}})}};function aue(a,s){return{order:100,canRead(l){let _=oar(l.url);if(!(_===void 0||_==="file"))return!1;let b;try{b=Uut(l.url)}catch(D){throw new sO(`Malformed URI: ${l.url}`,{cause:D})}try{ou.safePath(a).resolve(b)}catch(D){return s?.warn(D),!1}return!0},async read(l){let _;try{_=Uut(l.url)}catch(h){throw new sO(`Malformed URI: ${l.url}`,{cause:h})}try{return await iar(_)}catch(h){throw new sO(`Error opening file "${_}"`,{cause:h})}}}}t(aue,"customResolver");var tj=/^win/.test(globalThis.process?globalThis.process.platform:""),sar=/\//g,aar=/^(\w{2,}):\/\//i,B3e=[/%23/g,"#",/%24/g,"$",/%26/g,"&",/%2C/g,",",/%40/g,"@"];function oar(a){let s=aar.exec(a);if(s)return s[1].toLowerCase()}t(oar,"getProtocol");function Uut(a,s){a=decodeURI(a);for(let _=0;_<B3e.length;_+=2)a=a.replace(B3e[_],B3e[_+1]);let l=a.substr(0,7).toLowerCase()==="file://";if(l&&(a=a[7]==="/"?a.substr(8):a.substr(7),tj&&a[1]==="/"&&(a=a[0]+":"+a.substr(1)),s?a="file:///"+a:(l=!1,a=tj?a:"/"+a)),!l){let _=a.split(tj?"\\":"/"),h=[];for(let b of _)b===".."?h.length&&h[h.length-1]!==""&&h.pop():(b!==""||h.length===0)&&h.push(b);a=h.join(tj?"\\":"/"),!tj&&h[0]===""&&(a="/"+a.substring(1))}return tj&&!l&&(a=a.replace(sar,"\\"),a.substr(1,2)===":\\"&&(a=a[0].toUpperCase()+a.substr(1))),a}t(Uut,"toFileSystemPath");var $ut="YOUR_KEY_HERE";async function zut(a){let l=await new j3(a.sourceDirectory,a.logger).bundle(a.openApiDocPath),_=a.openApiDocPath.replace(a.sourceDirectory,"");return car({...a,relativeOpenApiPath:_},l)}t(zut,"buildPublicOpenApiFile");async function car(a,s){_ar({relativeOpenApiPath:a.relativeOpenApiPath},s);let l=s;return l=uar(l),lar(l,a.deploymentUrl),l=far(l,a),Jut(l,"x-zuplo"),l}t(car,"buildRawOpenApiFile");function lar(a,s){s?a.servers=[{url:s}]:a.servers=[]}t(lar,"addServerHost");function uar(a){if(!a.paths)return a;let{components:s}=a,l=s?{...s}:void 0,_=[];l&&l.parameters&&(_=Object.entries(l.parameters).reduce((b,[D,N])=>(DM in N&&Qce(N[DM])&&(b.push(D),l.parameters&&delete l.parameters[D]),b),[]));let h=Object.entries(a.paths).reduce((b,[D,N])=>{if(!N)return b;let M={...N},z=["delete","get","head","patch","post","put","trace","options"];return z.forEach(ne=>{let ie=N[ne];if(!ie)return;if(Qce(ie[DM])){delete M[ne];return}let{parameters:Q}=ie;if(!Q)return;let Me=Q.filter(Ie=>{if(DM in Ie&&Qce(Ie[DM]))return!1;if("$ref"in Ie){let Pe=Ie.$ref.split("/").pop();return Pe?!_.includes(Pe):!0}return!0});M[ne]={...ie,parameters:Me}}),z.some(ne=>!!M[ne])&&(b[D]=M),b},{});return{...a,paths:h,components:l}}t(uar,"removeHiddenRoutesAndParams");function far(a,{policiesConfig:s}){if(!a.paths)return a;let l=Object.entries(a.paths).reduce((_,[h,b])=>{if(!b)return _;let D={...b};return[D.delete,D.get,D.head,D.patch,D.post,D.put,D.trace,D.options].forEach(N=>{if(!N)return;let M=N["x-zuplo-route"]?.policies?.inbound?.reduce((ie,Q)=>{let Me=s.policies?.find(({name:Pt})=>Pt===Q);if(!Me)return ie;if(!(Me.handler.export==="CompositeInboundPolicy"))return ie.concat(Q);let Pe=Me.handler.options?.policies;return Pe?ie.concat(Pe):ie},[]),z=[];if(M&&M.forEach(ie=>{s.policies?.forEach(Q=>{Q.name===ie&&(Q.handler.export==="ApiAuthKeyInboundPolicy"||Q.handler.export==="ApiKeyInboundPolicy")&&!Q.handler.options?.disableAutomaticallyAddingKeyHeaderToOpenApi&&z.push(Q)})}),z.length>0){let ie=z.length>0&&z[0].handler&&z[0].handler.options&&z[0].handler.options.authHeader?z[0].handler.options.authHeader:"Authorization",Q=z.length>0&&z[0].handler&&z[0].handler.options&&(z[0].handler.options.authScheme||z[0].handler.options.authScheme==="")?z[0].handler.options.authScheme:"Bearer",Me=Q!==""?`${Q} ${$ut}`:$ut,Ie={name:ie,in:"header",required:!0,example:Me,schema:{type:"string"},description:`The \`${ie}\` header is used to authenticate with the API using your API key. Value is of the format \`${Me}\`.`};N.parameters?N.parameters.some(Tr=>"name"in Tr&&Tr.name===Ie.name)||N.parameters.unshift(Ie):N.parameters=[Ie];let Pe={type:"http",scheme:Q.toLowerCase()},Pt="api_key";a.components?.securitySchemes?Object.values(a.components?.securitySchemes).some(Tr=>"name"in Tr&&Tr.type==="apiKey"||"type"in Tr&&Tr.type==="http"&&Tr.scheme===Q)||(a.components.securitySchemes={...a.components.securitySchemes,[Pt]:Pe}):(a.components||(a.components={}),a.components.securitySchemes={[Pt]:Pe});let xt={[Pt]:[]};N.security?N.security.some(Tr=>Tr[Pt]!==void 0)||N.security.unshift(xt):N.security=[xt]}let ne=[];if(M&&M.forEach(ie=>{s.policies?.forEach(Q=>{Q.name===ie&&(Q.handler.export==="RateLimitInboundPolicy"||Q.handler.export==="ComplexRateLimitInboundPolicy")&&ne.push(Q)})}),ne.length>0){let ie={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"}}}}}},Q={...ie,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:ie,RateLimitWithRetryAfter:Q},N.responses||(N.responses={});let Me=ne.some(Ie=>Ie.handler.options?.headerMode!=="none");N.responses[429]||(N.responses[429]={$ref:Me?"#/components/responses/RateLimitWithRetryAfter":"#/components/responses/RateLimitNoRetryAfter"})}}),_[h]=D,_},{});return{...a,paths:l}}t(far,"enrichSpecWithZuploData");function Jut(a,s){for(let l in a)l.startsWith(s)?delete a[l]:typeof a[l]=="object"&&Jut(a[l],s)}t(Jut,"removePropertiesByPrefix");function _ar({relativeOpenApiPath:a},s){if(!s||typeof s!="object")throw new z1({message:"The OpenAPI Document could not be parsed.",severity:"error"});if(!("info"in s)||typeof s.info!="object"||!s.info)throw new z1({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 z1({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(_ar,"assertIsZuploOpenApiSpec");import vK from"node:path";function par(a){if(a.length>=255)throw new TypeError("Alphabet too long");let s=new Uint8Array(256);for(let z=0;z<s.length;z++)s[z]=255;for(let z=0;z<a.length;z++){let ne=a.charAt(z),ie=ne.charCodeAt(0);if(s[ie]!==255)throw new TypeError(ne+" is ambiguous");s[ie]=z}let l=a.length,_=a.charAt(0),h=Math.log(l)/Math.log(256),b=Math.log(256)/Math.log(l);function D(z){if(z instanceof Uint8Array||(ArrayBuffer.isView(z)?z=new Uint8Array(z.buffer,z.byteOffset,z.byteLength):Array.isArray(z)&&(z=Uint8Array.from(z))),!(z instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(z.length===0)return"";let ne=0,ie=0,Q=0,Me=z.length;for(;Q!==Me&&z[Q]===0;)Q++,ne++;let Ie=(Me-Q)*b+1>>>0,Pe=new Uint8Array(Ie);for(;Q!==Me;){let Tr=z[Q],cn=0;for(let tn=Ie-1;(Tr!==0||cn<ie)&&tn!==-1;tn--,cn++)Tr+=256*Pe[tn]>>>0,Pe[tn]=Tr%l>>>0,Tr=Tr/l>>>0;if(Tr!==0)throw new Error("Non-zero carry");ie=cn,Q++}let Pt=Ie-ie;for(;Pt!==Ie&&Pe[Pt]===0;)Pt++;let xt=_.repeat(ne);for(;Pt<Ie;++Pt)xt+=a.charAt(Pe[Pt]);return xt}t(D,"encode");function N(z){if(typeof z!="string")throw new TypeError("Expected String");if(z.length===0)return new Uint8Array;let ne=0,ie=0,Q=0;for(;z[ne]===_;)ie++,ne++;let Me=(z.length-ne)*h+1>>>0,Ie=new Uint8Array(Me);for(;z[ne];){let Tr=s[z.charCodeAt(ne)];if(Tr===255)return;let cn=0;for(let tn=Me-1;(Tr!==0||cn<Q)&&tn!==-1;tn--,cn++)Tr+=l*Ie[tn]>>>0,Ie[tn]=Tr%256>>>0,Tr=Tr/256>>>0;if(Tr!==0)throw new Error("Non-zero carry");Q=cn,ne++}let Pe=Me-Q;for(;Pe!==Me&&Ie[Pe]===0;)Pe++;let Pt=new Uint8Array(ie+(Me-Pe)),xt=ie;for(;Pe!==Me;)Pt[xt++]=Ie[Pe++];return Pt}t(N,"decodeUnsafe");function M(z){let ne=N(z);if(ne)return ne;throw new Error("Non-base"+l+" character")}return t(M,"decode"),{encode:D,decodeUnsafe:N,decode:M}}t(par,"base");var qut=par;var dar="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",oue=qut(dar);var U3e="2025-02-06",Vut=Object.freeze({none:{runOutboundPoliciesOnHandlerOnAllStatuses:!1,doNotRunHooksOnSystemRoutes:!1,removeAllVendorHeadersExceptListed:!1,allowCustomPorts:!1,removeLegacyLogInitialization:!1,useForwardRedirectsPropOnUrlForwardHandler:!1},"2023-03-14":{runOutboundPoliciesOnHandlerOnAllStatuses:!1,doNotRunHooksOnSystemRoutes:!1,removeAllVendorHeadersExceptListed:!1,allowCustomPorts:!1,removeLegacyLogInitialization:!1,useForwardRedirectsPropOnUrlForwardHandler:!1},"2024-01-15":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!1,removeLegacyLogInitialization:!1,useForwardRedirectsPropOnUrlForwardHandler:!1},"2024-03-14":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!1,removeLegacyLogInitialization:!1,useForwardRedirectsPropOnUrlForwardHandler:!1},"2024-09-02":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!0,removeLegacyLogInitialization:!1,useForwardRedirectsPropOnUrlForwardHandler:!1},"2025-02-06":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!0,removeLegacyLogInitialization:!0,useForwardRedirectsPropOnUrlForwardHandler:!0}});function Wut(){return new V2({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:U3e,ENVIRONMENT_TYPE:"mock-environment-type",GIT_SHA:void 0,IS_LOCAL_DEVELOPMENT:!1,COMPATIBILITY_FLAGS:Vut[U3e]},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(Wut,"getMockEnvironment");var V2=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=Wut()),this.#r}constructor({build:s,runtime:l}){let _;try{if(l.ZUPLO_SYSTEM_CONFIGURATIONS){let h=new TextDecoder().decode(oue.decode(l.ZUPLO_SYSTEM_CONFIGURATIONS)),b=JSON.parse(h);for(let D of Object.keys(b))l[D]||(l[D]=b[D])}if(l.__ZUPLO_CONFIG){let h=atob(l.__ZUPLO_CONFIG);_=JSON.parse(h)}}catch(h){console.error("Failed to parse runtime configuration",h)}this.config=_??{},this.build=s,this.runtime=l,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 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 mar=["ZUPLO_USER_LOGGER_DATA_DOG_API_KEY","ZUPLO_USER_LOGGER_DATA_DOG_URL","ZUPLO_LOG_LEVEL","ZUPLO_HANDLER_WRITE_LOG_LEVEL"];function Hut(a){return a.startsWith("__ZUPLO")||a.startsWith("ZUPLO_")?!mar.includes(a)&&!a.startsWith("ZUPLO_PUBLIC_"):!1}t(Hut,"isRestrictedEnvVariableName");function Gut(a){return!!a.startsWith("ZUPLO_")}t(Gut,"isZuploReadableEnvVariableName");var N8r=new Proxy({},{get(a,s){let l=String(s);switch(l){case"ZUPLO_ENVIRONMENT_TYPE":return V2.instance.loggingEnvironmentType;case"ZUPLO_ENVIRONMENT_STAGE":return V2.instance.loggingEnvironmentStage;case"ZUPLO_ENVIRONMENT_NAME":return V2.instance.runtime.__ZUPLO_DEPLOYMENT_NAME;case"ZUPLO_ACCOUNT_NAME":return V2.instance.build.ACCOUNT_NAME;case"ZUPLO_PROJECT_NAME":return V2.instance.build.PROJECT_NAME;case"ZUPLO_BUILD_ID":return V2.instance.build.BUILD_ID;case"ZUPLO_COMPATIBILITY_DATE":return V2.instance.build.COMPATIBILITY_DATE}if(!(Hut(l)&&!Gut(l)))return V2.instance.runtime[l]}});function yG(a,s,l){return`_${CA(`${a}_${s}_${l}`)}`}t(yG,"getRawOperationDataIdentifierName");function $3e(a,s,l,_){return`_${CA(a.toLowerCase())}_${s.toLowerCase()}_${l.toLowerCase()}_${_.toLowerCase()}`}t($3e,"getIdForParameterSchema");function z3e(a,s,l){return`_${CA(a.toLowerCase())}_${s.toLowerCase()}_rb_${CA(l.toLowerCase())}`}t(z3e,"getIdForRequestBodySchema");function vG(a,s){return`_${CA(a)}_${CA(s)}`}t(vG,"getIdForRefSchema");function CA(a){let s=a.replace(/\[/g,"_LBRACKET_").replace(/\]/g,"_RBRACKET_").replace(/\{/g,"_LCURLY_").replace(/\}/g,"_RCURLY_").replace(/\//g,"_SLASH_").replace(/-/g,"_DASH_").replace(/\./g,"_DOT_").replace(/\+/g,"_PLUS_").replace(/:/g,"_COLON_").replace(/@/g,"_AT_").replace(/\$/g,"_DOLLAR_").replace(/[^a-zA-Z0-9_]/g,"_");return/^[a-zA-Z_]/.test(s)||(s="_"+s),s}t(CA,"sanitizedIdentifierName");var Dht=ap(j_t(),1);var LG=class{static{t(this,"R")}type=3;name="";prefix="";value="";suffix="";modifier=3;constructor(a,s,l,_,h,b){this.type=a,this.name=s,this.prefix=l,this.value=_,this.suffix=h,this.modifier=b}hasCustomName(){return this.name!==""&&typeof this.name!="number"}},llr=/[$_\p{ID_Start}]/u,ulr=/[$_\u200C\u200D\p{ID_Continue}]/u,RNe=".*";function flr(a,s){return(s?/^[\x00-\xFF]*$/:/^[\x00-\x7F]*$/).test(a)}t(flr,"Re");function $_t(a,s=!1){let l=[],_=0;for(;_<a.length;){let h=a[_],b=t(function(D){if(!s)throw new TypeError(D);l.push({type:"INVALID_CHAR",index:_,value:a[_++]})},"c");if(h==="*"){l.push({type:"ASTERISK",index:_,value:a[_++]});continue}if(h==="+"||h==="?"){l.push({type:"OTHER_MODIFIER",index:_,value:a[_++]});continue}if(h==="\\"){l.push({type:"ESCAPED_CHAR",index:_++,value:a[_++]});continue}if(h==="{"){l.push({type:"OPEN",index:_,value:a[_++]});continue}if(h==="}"){l.push({type:"CLOSE",index:_,value:a[_++]});continue}if(h===":"){let D="",N=_+1;for(;N<a.length;){let M=a.substr(N,1);if(N===_+1&&llr.test(M)||N!==_+1&&ulr.test(M)){D+=a[N++];continue}break}if(!D){b(`Missing parameter name at ${_}`);continue}l.push({type:"NAME",index:_,value:D}),_=N;continue}if(h==="("){let D=1,N="",M=_+1,z=!1;if(a[M]==="?"){b(`Pattern cannot start with "?" at ${M}`);continue}for(;M<a.length;){if(!flr(a[M],!1)){b(`Invalid character '${a[M]}' at ${M}.`),z=!0;break}if(a[M]==="\\"){N+=a[M++]+a[M++];continue}if(a[M]===")"){if(D--,D===0){M++;break}}else if(a[M]==="("&&(D++,a[M+1]!=="?")){b(`Capturing groups are not allowed at ${M}`),z=!0;break}N+=a[M++]}if(z)continue;if(D){b(`Unbalanced pattern at ${_}`);continue}if(!N){b(`Missing pattern at ${_}`);continue}l.push({type:"REGEX",index:_,value:N}),_=M;continue}l.push({type:"CHAR",index:_,value:a[_++]})}return l.push({type:"END",index:_,value:""}),l}t($_t,"v");function z_t(a,s={}){let l=$_t(a);s.delimiter??="/#?",s.prefixes??="./";let _=`[^${RT(s.delimiter)}]+?`,h=[],b=0,D=0,N="",M=new Set,z=t(cn=>{if(D<l.length&&l[D].type===cn)return l[D++].value},"a"),ne=t(()=>z("OTHER_MODIFIER")??z("ASTERISK"),"f"),ie=t(cn=>{let tn=z(cn);if(tn!==void 0)return tn;let{type:ln,index:Cr}=l[D];throw new TypeError(`Unexpected ${ln} at ${Cr}, expected ${cn}`)},"d"),Q=t(()=>{let cn="",tn;for(;tn=z("CHAR")??z("ESCAPED_CHAR");)cn+=tn;return cn},"T"),Me=t(cn=>cn,"Se"),Ie=s.encodePart||Me,Pe="",Pt=t(cn=>{Pe+=cn},"U"),xt=t(()=>{Pe.length&&(h.push(new LG(3,"","",Ie(Pe),"",3)),Pe="")},"$"),Tr=t((cn,tn,ln,Cr,vr)=>{let fs=3;switch(vr){case"?":fs=1;break;case"*":fs=0;break;case"+":fs=2;break}if(!tn&&!ln&&fs===3){Pt(cn);return}if(xt(),!tn&&!ln){if(!cn)return;h.push(new LG(3,"","",Ie(cn),"",fs));return}let Fi;ln?ln==="*"?Fi=RNe:Fi=ln:Fi=_;let Ho=2;Fi===_?(Ho=1,Fi=""):Fi===RNe&&(Ho=0,Fi="");let di;if(tn?di=tn:ln&&(di=b++),M.has(di))throw new TypeError(`Duplicate name '${di}'.`);M.add(di),h.push(new LG(Ho,di,Ie(cn),Fi,Ie(Cr),fs))},"V");for(;D<l.length;){let cn=z("CHAR"),tn=z("NAME"),ln=z("REGEX");if(!tn&&!ln&&(ln=z("ASTERISK")),tn||ln){let vr=cn??"";s.prefixes.indexOf(vr)===-1&&(Pt(vr),vr=""),xt();let fs=ne();Tr(vr,tn,ln,"",fs);continue}let Cr=cn??z("ESCAPED_CHAR");if(Cr){Pt(Cr);continue}if(z("OPEN")){let vr=Q(),fs=z("NAME"),Fi=z("REGEX");!fs&&!Fi&&(Fi=z("ASTERISK"));let Ho=Q();ie("CLOSE");let di=ne();Tr(vr,fs,Fi,Ho,di);continue}xt(),ie("END")}return h}t(z_t,"D");function RT(a){return a.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}t(RT,"S");function B_t(a){return a&&a.ignoreCase?"ui":"u"}t(B_t,"X");function _lr(a,s,l){return J_t(z_t(a,l),s,l)}t(_lr,"Z");function fj(a){switch(a){case 0:return"*";case 1:return"?";case 2:return"+";case 3:return""}}t(fj,"k");function J_t(a,s,l={}){l.delimiter??="/#?",l.prefixes??="./",l.sensitive??=!1,l.strict??=!1,l.end??=!0,l.start??=!0,l.endsWith="";let _=l.start?"^":"";for(let N of a){if(N.type===3){N.modifier===3?_+=RT(N.value):_+=`(?:${RT(N.value)})${fj(N.modifier)}`;continue}s&&s.push(N.name);let M=`[^${RT(l.delimiter)}]+?`,z=N.value;if(N.type===1?z=M:N.type===0&&(z=RNe),!N.prefix.length&&!N.suffix.length){N.modifier===3||N.modifier===1?_+=`(${z})${fj(N.modifier)}`:_+=`((?:${z})${fj(N.modifier)})`;continue}if(N.modifier===3||N.modifier===1){_+=`(?:${RT(N.prefix)}(${z})${RT(N.suffix)})`,_+=fj(N.modifier);continue}_+=`(?:${RT(N.prefix)}`,_+=`((?:${z})(?:`,_+=RT(N.suffix),_+=RT(N.prefix),_+=`(?:${z}))*)${RT(N.suffix)})`,N.modifier===0&&(_+="?")}let h=`[${RT(l.endsWith)}]|$`,b=`[${RT(l.delimiter)}]`;if(l.end)return l.strict||(_+=`${b}?`),l.endsWith.length?_+=`(?=${h})`:_+="$",new RegExp(_,B_t(l));l.strict||(_+=`(?:${b}(?=${h}))?`);let D=!1;if(a.length){let N=a[a.length-1];N.type===3&&N.modifier===3&&(D=l.delimiter.indexOf(N)>-1)}return D||(_+=`(?=${b}|${h})`),new RegExp(_,B_t(l))}t(J_t,"F");var z3={delimiter:"",prefixes:"",sensitive:!0,strict:!0},plr={delimiter:".",prefixes:"",sensitive:!0,strict:!0},dlr={delimiter:"/",prefixes:"/",sensitive:!0,strict:!0};function mlr(a,s){return a.length?a[0]==="/"?!0:!s||a.length<2?!1:(a[0]=="\\"||a[0]=="{")&&a[1]=="/":!1}t(mlr,"J");function q_t(a,s){return a.startsWith(s)?a.substring(s.length,a.length):a}t(q_t,"Q");function hlr(a,s){return a.endsWith(s)?a.substr(0,a.length-s.length):a}t(hlr,"Ee");function V_t(a){return!a||a.length<2?!1:a[0]==="["||(a[0]==="\\"||a[0]==="{")&&a[1]==="["}t(V_t,"W");var W_t=["ftp","file","http","https","ws","wss"];function H_t(a){if(!a)return!0;for(let s of W_t)if(a.test(s))return!0;return!1}t(H_t,"N");function glr(a,s){if(a=q_t(a,"#"),s||a==="")return a;let l=new URL("https://example.com");return l.hash=a,l.hash?l.hash.substring(1,l.hash.length):""}t(glr,"te");function ylr(a,s){if(a=q_t(a,"?"),s||a==="")return a;let l=new URL("https://example.com");return l.search=a,l.search?l.search.substring(1,l.search.length):""}t(ylr,"re");function vlr(a,s){return s||a===""?a:V_t(a)?Y_t(a):K_t(a)}t(vlr,"ne");function blr(a,s){if(s||a==="")return a;let l=new URL("https://example.com");return l.password=a,l.password}t(blr,"se");function Slr(a,s){if(s||a==="")return a;let l=new URL("https://example.com");return l.username=a,l.username}t(Slr,"ie");function Tlr(a,s,l){if(l||a==="")return a;if(s&&!W_t.includes(s))return new URL(`${s}:${a}`).pathname;let _=a[0]=="/";return a=new URL(_?a:"/-"+a,"https://example.com").pathname,_||(a=a.substring(2,a.length)),a}t(Tlr,"ae");function xlr(a,s,l){return G_t(s)===a&&(a=""),l||a===""?a:X_t(a)}t(xlr,"oe");function Clr(a,s){return a=hlr(a,":"),s||a===""?a:MNe(a)}t(Clr,"ce");function G_t(a){switch(a){case"ws":case"http":return"80";case"wws":case"https":return"443";case"ftp":return"21";default:return""}}t(G_t,"_");function MNe(a){if(a==="")return a;if(/^[-+.A-Za-z0-9]*$/.test(a))return a.toLowerCase();throw new TypeError(`Invalid protocol '${a}'.`)}t(MNe,"y");function Elr(a){if(a==="")return a;let s=new URL("https://example.com");return s.username=a,s.username}t(Elr,"le");function Dlr(a){if(a==="")return a;let s=new URL("https://example.com");return s.password=a,s.password}t(Dlr,"fe");function K_t(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(K_t,"z");function Y_t(a){if(a==="")return a;if(/[^0-9a-fA-F[\]:]/g.test(a))throw new TypeError(`Invalid IPv6 hostname '${a}'`);return a.toLowerCase()}t(Y_t,"j");function X_t(a){if(a===""||/^[0-9]*$/.test(a)&&parseInt(a)<=65535)return a;throw new TypeError(`Invalid port '${a}'.`)}t(X_t,"K");function klr(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(klr,"he");function wlr(a){return a===""?a:new URL(`data:${a}`).pathname}t(wlr,"ue");function Plr(a){if(a==="")return a;let s=new URL("https://example.com");return s.search=a,s.search.substring(1,s.search.length)}t(Plr,"de");function Alr(a){if(a==="")return a;let s=new URL("https://example.com");return s.hash=a,s.hash.substring(1,s.hash.length)}t(Alr,"pe");var Nlr=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=$_t(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.#w()){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.#E()?(a=2,s=3):this.#l&&(a=2),this.#i(a,s)}break;case 2:this.#x()?this.#d(3):(this.#C()||this.#y()||this.#D())&&this.#d(5);break;case 3:this.#b()?this.#i(4,1):this.#x()&&this.#i(5,1);break;case 4:this.#x()&&this.#i(5,1);break;case 5:this.#N()?this.#c+=1:this.#S()&&(this.#c-=1),this.#k()&&!this.#c?this.#i(6,1):this.#C()?this.#i(7,0):this.#y()?this.#i(8,1):this.#D()&&this.#i(9,1);break;case 6:this.#C()?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 l=this.#u(a);return l.value===s&&(l.type==="CHAR"||l.type==="ESCAPED_CHAR"||l.type==="INVALID_CHAR")}#g(){return this.#m(this.#t,":")}#E(){return this.#m(this.#t+1,"/")&&this.#m(this.#t+2,"/")}#x(){return this.#m(this.#t,"@")}#b(){return this.#m(this.#t,":")}#k(){return this.#m(this.#t,":")}#C(){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,"#")}#w(){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,z3),a.encodePart=MNe;let s=_lr(this.#T(),void 0,a);this.#l=H_t(s)}},LNe=["protocol","username","password","hostname","port","pathname","search","hash"],$3="*";function U_t(a,s){if(typeof a!="string")throw new TypeError("parameter 1 is not of type 'string'.");let l=new URL(a,s);return{protocol:l.protocol.substring(0,l.protocol.length-1),username:l.username,password:l.password,hostname:l.hostname,port:l.port,pathname:l.pathname,search:l.search!==""?l.search.substring(1,l.search.length):void 0,hash:l.hash!==""?l.hash.substring(1,l.hash.length):void 0}}t(U_t,"ge");function PA(a,s){return s?OG(a):a}t(PA,"b");function FG(a,s,l){let _;if(typeof s.baseURL=="string")try{_=new URL(s.baseURL),s.protocol===void 0&&(a.protocol=PA(_.protocol.substring(0,_.protocol.length-1),l)),!l&&s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.username===void 0&&(a.username=PA(_.username,l)),!l&&s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.username===void 0&&s.password===void 0&&(a.password=PA(_.password,l)),s.protocol===void 0&&s.hostname===void 0&&(a.hostname=PA(_.hostname,l)),s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&(a.port=PA(_.port,l)),s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.pathname===void 0&&(a.pathname=PA(_.pathname,l)),s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.pathname===void 0&&s.search===void 0&&(a.search=PA(_.search.substring(1,_.search.length),l)),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=PA(_.hash.substring(1,_.hash.length),l))}catch{throw new TypeError(`invalid baseURL '${s.baseURL}'.`)}if(typeof s.protocol=="string"&&(a.protocol=Clr(s.protocol,l)),typeof s.username=="string"&&(a.username=Slr(s.username,l)),typeof s.password=="string"&&(a.password=blr(s.password,l)),typeof s.hostname=="string"&&(a.hostname=vlr(s.hostname,l)),typeof s.port=="string"&&(a.port=xlr(s.port,a.protocol,l)),typeof s.pathname=="string"){if(a.pathname=s.pathname,_&&!mlr(a.pathname,l)){let h=_.pathname.lastIndexOf("/");h>=0&&(a.pathname=PA(_.pathname.substring(0,h+1),l)+a.pathname)}a.pathname=Tlr(a.pathname,a.protocol,l)}return typeof s.search=="string"&&(a.search=ylr(s.search,l)),typeof s.hash=="string"&&(a.hash=glr(s.hash,l)),a}t(FG,"w");function OG(a){return a.replace(/([+*?:{}()\\])/g,"\\$1")}t(OG,"C");function Ilr(a){return a.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}t(Ilr,"Oe");function Flr(a,s){s.delimiter??="/#?",s.prefixes??="./",s.sensitive??=!1,s.strict??=!1,s.end??=!0,s.start??=!0,s.endsWith="";let l=".*",_=`[^${Ilr(s.delimiter)}]+?`,h=/[$_\u200C\u200D\p{ID_Continue}]/u,b="";for(let D=0;D<a.length;++D){let N=a[D];if(N.type===3){if(N.modifier===3){b+=OG(N.value);continue}b+=`{${OG(N.value)}}${fj(N.modifier)}`;continue}let M=N.hasCustomName(),z=!!N.suffix.length||!!N.prefix.length&&(N.prefix.length!==1||!s.prefixes.includes(N.prefix)),ne=D>0?a[D-1]:null,ie=D<a.length-1?a[D+1]:null;if(!z&&M&&N.type===1&&N.modifier===3&&ie&&!ie.prefix.length&&!ie.suffix.length)if(ie.type===3){let Q=ie.value.length>0?ie.value[0]:"";z=h.test(Q)}else z=!ie.hasCustomName();if(!z&&!N.prefix.length&&ne&&ne.type===3){let Q=ne.value[ne.value.length-1];z=s.prefixes.includes(Q)}z&&(b+="{"),b+=OG(N.prefix),M&&(b+=`:${N.name}`),N.type===2?b+=`(${N.value})`:N.type===1?M||(b+=`(${_})`):N.type===0&&(!M&&(!ne||ne.type===3||ne.modifier!==3||z||N.prefix!=="")?b+="*":b+=`(${l})`),N.type===1&&M&&N.suffix.length&&h.test(N.suffix[0])&&(b+="\\"),b+=OG(N.suffix),z&&(b+="}"),N.modifier!==3&&(b+=fj(N.modifier))}return b}t(Flr,"ke");var Q_t=class{static{t(this,"me")}#r;#n={};#e={};#t={};#s={};#p=!1;constructor(a={},s,l){try{let _;if(typeof s=="string"?_=s:l=s,typeof a=="string"){let N=new Nlr(a);if(N.parse(),a=N.result,_===void 0&&typeof a.protocol!="string")throw new TypeError("A base URL must be provided for a relative constructor string.");a.baseURL=_}else{if(!a||typeof a!="object")throw new TypeError("parameter 1 is not of type 'string' and cannot convert to dictionary.");if(_)throw new TypeError("parameter 1 is not of type 'string'.")}typeof l>"u"&&(l={ignoreCase:!1});let h={ignoreCase:l.ignoreCase===!0},b={pathname:$3,protocol:$3,username:$3,password:$3,hostname:$3,port:$3,search:$3,hash:$3};this.#r=FG(b,a,!0),G_t(this.#r.protocol)===this.#r.port&&(this.#r.port="");let D;for(D of LNe){if(!(D in this.#r))continue;let N={},M=this.#r[D];switch(this.#e[D]=[],D){case"protocol":Object.assign(N,z3),N.encodePart=MNe;break;case"username":Object.assign(N,z3),N.encodePart=Elr;break;case"password":Object.assign(N,z3),N.encodePart=Dlr;break;case"hostname":Object.assign(N,plr),V_t(M)?N.encodePart=Y_t:N.encodePart=K_t;break;case"port":Object.assign(N,z3),N.encodePart=X_t;break;case"pathname":H_t(this.#n.protocol)?(Object.assign(N,dlr,h),N.encodePart=klr):(Object.assign(N,z3,h),N.encodePart=wlr);break;case"search":Object.assign(N,z3,h),N.encodePart=Plr;break;case"hash":Object.assign(N,z3,h),N.encodePart=Alr;break}try{this.#s[D]=z_t(M,N),this.#n[D]=J_t(this.#s[D],this.#e[D],N),this.#t[D]=Flr(this.#s[D],N),this.#p=this.#p||this.#s[D].some(z=>z.type===2)}catch{throw new TypeError(`invalid ${D} pattern '${this.#r[D]}'.`)}}}catch(_){throw new TypeError(`Failed to construct 'URLPattern': ${_.message}`)}}test(a={},s){let l={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"?l=FG(l,a,!1):l=FG(l,U_t(a,s),!1)}catch{return!1}let _;for(_ of LNe)if(!this.#n[_].exec(l[_]))return!1;return!0}exec(a={},s){let l={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"?l=FG(l,a,!1):l=FG(l,U_t(a,s),!1)}catch{return null}let _={};s?_.inputs=[a,s]:_.inputs=[a];let h;for(h of LNe){let b=this.#n[h].exec(l[h]);if(!b)return null;let D={};for(let[N,M]of this.#e[h].entries())if(typeof M=="string"||typeof M=="number"){let z=b[N+1];D[M]=z}_[h]={input:l[h]??"",groups:D}}return _}static compareComponent(a,s,l){let _=t((N,M)=>{for(let z of["type","modifier","prefix","value","suffix"]){if(N[z]<M[z])return-1;if(N[z]!==M[z])return 1}return 0},"o"),h=new LG(3,"","","","",3),b=new LG(0,"","","","",3),D=t((N,M)=>{let z=0;for(;z<Math.min(N.length,M.length);++z){let ne=_(N[z],M[z]);if(ne)return ne}return N.length===M.length?0:_(N[z]??h,M[z]??h)},"s");return!s.#t[a]&&!l.#t[a]?0:s.#t[a]&&!l.#t[a]?D(s.#s[a],[b]):!s.#t[a]&&l.#t[a]?D([b],l.#s[a]):D(s.#s[a],l.#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=Q_t);import{AssertionError as Olr}from"node:assert";function AA(a,s){if(a===!1)throw new Olr({message:s})}t(AA,"assert");var ec;(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"})(ec||(ec={}));function _j(a){return a.type===ec.Object}t(_j,"isAstObject");function NA(a){return a.type===ec.Property}t(NA,"isAstProperty");function Z_t(a){return a.type===ec.Array}t(Z_t,"isAstArray");function pj(a){return a.type===ec.Literal}t(pj,"isAstLiteral");function J3(a){if(a===void 0)throw new Error("Node is undefined");if(!_j(a))throw new Error("Node is not object")}t(J3,"assertAstObject");import{findNodeAtLocation as Llr,getNodeValue as Rlr,printParseErrorCode as Mlr,visit as jlr}from"jsonc-parser";var Blr={DEFAULT:{allowTrailingComma:!1}};function RG(a,s=[],l=Blr.DEFAULT){let _={type:"array",offset:-1,length:-1,line:-1,column:-1,children:[],parent:void 0};function h(M){_.type==="property"&&(_.length=M-_.offset,_=_.parent)}t(h,"ensurePropertyComplete");function b(M){return _.children?.push(M),M}t(b,"onValue"),jlr(a,{onObjectBegin:t((M,z,ne)=>{_=b({type:"object",offset:M,length:-1,line:z+1,column:ne+1,parent:_,children:[]})},"onObjectBegin"),onObjectProperty:t((M,z,ne,ie,Q)=>{_=b({type:"property",offset:z,length:-1,line:ie+1,column:Q+1,parent:_,children:[]}),_.children?.push({type:"string",value:M,offset:z,length:ne,line:ie,column:Q,parent:_})},"onObjectProperty"),onObjectEnd:t((M,z)=>{h(M+z),_.length=M+z-_.offset,_=_.parent,h(M+z)},"onObjectEnd"),onArrayBegin:t((M,z,ne,ie)=>{_=b({type:"array",offset:M,length:-1,line:ne+1,column:ie+1,parent:_,children:[]})},"onArrayBegin"),onArrayEnd:t((M,z)=>{_.length=M+z-_.offset,_=_.parent,h(M+z)},"onArrayEnd"),onLiteralValue:t((M,z,ne,ie,Q)=>{b({type:Ulr(M),offset:z,length:ne,line:ie+1,column:Q+1,parent:_,value:M}),h(z+ne)},"onLiteralValue"),onSeparator:t((M,z)=>{_.type==="property"&&(M===":"?_.colonOffset=z:M===","&&h(z))},"onSeparator"),onError:t((M,z,ne,ie,Q)=>{s.push({error:M,offset:z,length:ne,line:ie+1,column:Q+1})},"onError")},l);let N=_.children[0];return N&&delete N.parent,N}t(RG,"parse");function Ulr(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(Ulr,"getNodeType");function jNe(a,s){return Llr(a,s)}t(jNe,"findNodeAtLocation");function MG(a){return Rlr(a)}t(MG,"getNodeValue");function ept(a){return Mlr(a)}t(ept,"printParseErrorCode");var jG=class{static{t(this,"AstAdapter")}parse(s){let _=RG(s,[]);if(_)return this.parseNode(_,void 0);throw new Error("Failed to parse JSON")}convert(s){return this.parseNode(s,void 0)}parseNode(s,l){switch(s.type){case"object":return this.createObject(s,l);case"array":return this.createArray(s,l);case"property":return this.createProperty(s,l);case"string":return this.createLiteral(s,l);case"number":return this.createLiteral(s,l);case"boolean":return this.createLiteral(s,l);case"null":return this.createLiteral(s,l)}}createLiteral(s,l){return{type:ec.Literal,location:{line:s.line,column:s.column},parent:l,value:s.type==="null"?null:s.value}}createObject(s,l){let _={type:ec.Object,children:[],parent:l,location:{line:s.line,column:s.column}};return s.children?.forEach(h=>{_.children.push(this.parseNode(h,_))}),_}createProperty(s,l){AA(s.children?.length===2,"Invalid property node");let _={type:ec.Property,location:{line:s.line,column:s.column},parent:l,name:null,value:null};return _.name={value:s.children[0].value,location:{line:s.line,column:s.column},type:ec.Identifier,parent:_},_.value=this.parseNode(s.children[1],_),_}createArray(s,l){let _={type:ec.Array,location:{line:s.line,column:s.column},parent:l,children:[]};return s.children?.forEach(h=>_.children.push(this.parseNode(h,_))),_}};var MT={createLiteral:t((a,s)=>({type:ec.Literal,parent:s,value:a}),"createLiteral"),createTemplateString:t((a,s)=>({type:ec.TemplateString,parent:s,value:a}),"createTemplateString"),createIdentifier:t((a,s)=>({type:ec.Identifier,value:a,parent:s}),"createIdentifier"),createProperty:t((a,s,l)=>{let _={type:ec.Property,parent:l,name:null,value:s};return _.name={value:a,type:ec.Identifier,parent:_},_.value.parent=_,_},"createProperty"),createArrayOfLiterals:t((a,s)=>{let l={type:ec.Array,parent:s,children:[]};for(let _ of a)l.children.push(MT.createLiteral(_,l));return l},"createArrayOfLiterals")};var $lr=/^[a-zA-Z_$][a-zA-Z0-9_$]*$/,BG=class{static{t(this,"SourceGenerator")}generate(s){let l=[];return this.generateSource(l,s),l.join("")}generateSource(s,l){switch(l.type){case ec.Array:return this.generateArray(s,l);case ec.Object:return this.generateObject(s,l);case ec.Property:return this.generateProperty(s,l);case ec.Literal:return this.generateLiteral(s,l);case ec.FunctionCall:return this.generateFunctionCall(s,l);case ec.Identifier:return this.generateIdentifier(s,l);case ec.Raw:return this.generateRaw(s,l);case ec.TemplateString:return this.generateTemplateString(s,l)}}generateArray(s,l){s.push("["),l.children.map(_=>{this.generateSource(s,_),s.push(",")}),s.push("]")}generateObject(s,l){s.push("{"),l.children.forEach(_=>{this.generateSource(s,_),s.push(",")}),s.push("}")}generateProperty(s,l){this.generateIdentifier(s,l.name),s.push(":"),this.generateSource(s,l.value)}generateFunctionCall(s,l){s.push(l.name.value),s.push("("),l.children.forEach((_,h,b)=>{this.generateSource(s,_),h<b.length&&s.push(",")}),s.push(")")}generateRaw(s,l){s.push(l.value)}generateTemplateString(s,l){s.push("`"),s.push(l.value.replaceAll("`","\\`")),s.push("`")}generateLiteral(s,l){if(l.value===null)return s.push("null");switch(typeof l.value){case"number":case"boolean":return s.push(`${l.value}`);case"string":{let _=l.value,h=JSON.stringify(_);return s.push(`${h}`)}}}generateIdentifier(s,l){let _=$lr.test(l.value)?l.value:`'${l.value}'`;s.push(_)}};import zlr from"node:fs/promises";import{parse as Jlr}from"@swc/core";var tpt=t(async a=>{let s=new Set;try{let l=await zlr.readFile(a,"utf-8");(await Jlr(l,{syntax:"typescript"})).body.forEach(h=>{h.type==="ExportDefaultDeclaration"||h.type==="ExportDefaultExpression"?s.add("default"):h.type==="ExportDeclaration"&&h.declaration.type==="FunctionDeclaration"?s.add(h.declaration.identifier.value):h.type==="ExportDeclaration"&&h.declaration.type==="VariableDeclaration"&&h.declaration.declarations[0].id.type==="Identifier"&&s.add(h.declaration.declarations[0].id.value)})}catch{return null}return s},"getJSFileExports");var rpt={$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 BNe={$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 npt={$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 UNe={$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 $Ne={$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 hht=ap(Bmt(),1),ght=ap(mht(),1);var Efe=class a{static{t(this,"JsonValidator")}static#r=new a;static get instance(){return a.#r}ajv;constructor(){this.ajv=new ght.Ajv2020({allErrors:!0,allowUnionTypes:!0}),this.ajv.addKeyword("faker"),(0,hht.default)(this.ajv,{mode:"fast"})}addSchema(s,l){this.ajv.addSchema(s,l)}compile(s){let l=this.ajv.compile(s);return t(h=>({isValid:l(h),errors:this.toSimpleErrors(l.errors,h),warnings:[]}),"validator")}toSimpleErrors(s,l){let _=[];return s?.forEach(h=>{h.keyword==="enum"&&h.params.allowedValues&&Array.isArray(h.params.allowedValues)&&(h.message+=`; ${h.params.allowedValues.join(", ")}`),h.instancePath&&(h.instancePath=h.instancePath.replaceAll(/(\/)?(~1)(\/)?/gm,"/"));let b={details:{}},D=h.instancePath.split("/");if(D.length>2){let M=D[1],z=D[2]?parseInt(D[2]):0,ne=D[3],ie=isNaN(z)?void 0:l[M][z][ne];b={details:{property:M,index:z,field:ne,fieldValue:ie}}}if(h.keyword==="required"&&h.params.missingProperty&&h.instancePath&&(h.message=`A 'path' is missing required property '${h.params.missingProperty}'`),h.keyword==="additionalProperties"&&h.params.additionalProperty&&h.instancePath&&(h.message=`A 'path' should NOT include property '${h.params.additionalProperty}'`),h.keyword==="type"&&h.params.type&&h.instancePath){let M=h.instancePath.split("/"),z=M[M.length-1];h.message=`Value of property '${z}' must be '${h.params.type}'`}let N=Object.assign(h,b);_.push(N)}),_}};var Z3=Efe.instance;Z3.addSchema($Ne,"route-configuration.schema.json");Z3.addSchema(npt,"policy-configuration.schema.json");Z3.addSchema(BNe,"policies.schema.json");Z3.addSchema(UNe,"open-api-route-configuration.schema.json");Z3.addSchema(rpt,"fragments.schema.json");var A9r=Z3.compile($Ne),yht=Z3.compile(UNe),rFe=Z3.compile(BNe);var Dfe=class{static{t(this,"PoliciesConfigurationValidator")}results;validate(s){return this.results=rFe(s),this.results}};var kfe=class{static{t(this,"OpenAPILocalizedValidator")}results;validate(s){return this.results=yht(s),this.results}};import Yhr from"node:path";var nFe=/\$import\((.*)\)/,wfe=/\$env\((.*?)\)/g;var RA=class extends Error{static{t(this,"CodeGenError")}location;constructor(s,l,_,h){super(s),this.location={file:l,namespace:"",line:_?_.line:0,column:_?_.column:0,length:0,lineText:h??"",suggestion:""}}},Khr=t(a=>{let s=[],l=a;for(;l.parent;)s.push(l),l=l.parent;return s.reverse()},"invertTree"),eN=t((a,s)=>{if(!a)return!1;let l=Khr(a);return s.split("/").every((b,D)=>{let N=l[D];return N?b==="*"||NA(N)&&N.name.value===b?!0:b==="{}"?N.type===ec.Object:b==="[]"?N.type===ec.Array:!1:!1})},"testPosition");var Pfe=class{static{t(this,"AstTransformer")}errors=[];transform(s){return this.visitor(s),s}visitor(s){this.visit(s),_j(s)?s.children.forEach(l=>{this.visitor(l)}):Z_t(s)?s.children.forEach(l=>{this.visitor(l)}):NA(s)&&this.visitor(s.value)}},vht=t((a,s,l)=>_=>{if(!NA(_)||!pj(_.value)||typeof _.value.value!="string")return;if(!a.some(b=>eN(_,b))){wfe.test(_.value.value)&&s.push(new RA("An $env() statement is not expected at this location.",l,_.location,_.value.value));return}let h=new RegExp(wfe).exec(_.value.value);if(h?.length===2&&h[0]===_.value.value){let b={type:ec.Raw,parent:null,value:`environment["${h[1]}"]`};_.value=b}else{let b=_.value.value.replaceAll(new RegExp(wfe),(D,N)=>`\${environment["${N}"] ? environment["${N}"] : ""}`);b!==_.value.value&&(_.value=MT.createTemplateString(b,_))}},"getEnvStatementTransformer");var yK="config/routes.json",Xhr=["handler/{}/options/*","policies/[]/{}/handler/{}/options/*","corsPolicies/[]/{}/*"],Qhr=["handler/{}/module","handler/{}/options/{}/policies/{}/inbound/[]/{}/module","handler/{}/options/{}/policies/{}/outbound/[]/{}/module","policies/[]/{}/handler/{}/module","policies/[]/{}/handler/{}/options/{}/identifier/{}/module","policies/[]/{}/handler/{}/options/{}/validator"],bht=["handler/{}/options/*","policies/[]/{}/handler/{}/options/*"],Zhr="handler/{}/options/{}/rewritePattern",egr="handler/{}/options/{}/baseUrl",Afe=class extends Pfe{static{t(this,"OpenAPIRoutesFragmentAstTransformer")}importCount=0;addedImports=new Map;getImportName(s){this.addedImports.has(s)||this.addedImports.set(s,`__import${this.importCount++}`);let l=this.addedImports.get(s);if(!l)throw new Error("Import name is undefined. This should not happen.");return l}getImports(){let s=[];return this.addedImports.forEach((l,_)=>{s.push({name:l,path:_})}),s}visit(s){this.rewriteHandlerFunction(s),this.rewriteForwardFunction(s),this.replaceImportStatements(s),this.replaceEnvStatements(s)}rewriteHandlerFunction(s){if(!(!NA(s)||!pj(s.value)||typeof s.value.value!="string")&&eN(s,Zhr)){if(!s.parent||!_j(s.parent)){this.errors.push(new RA("Invalid node, expected object",yK,s.parent?s.parent.location:s.location,void 0));return}let l=s.value.value,_={type:ec.Raw,parent:null,value:Sht(l)},h=MT.createProperty("__rewriteFunction",_,s);s.parent.children.push(h)}}rewriteForwardFunction(s){if(!(!NA(s)||!pj(s.value)||typeof s.value.value!="string")&&eN(s,egr)){if(!s.parent||!_j(s.parent)){this.errors.push(new RA("Invalid node, expected object",yK,s.parent?s.parent.location:s.location,void 0));return}let l=s.value.value,_={type:ec.Raw,parent:null,value:Sht(l)},h=MT.createProperty("__rewriteFunction",_,s);s.parent.children.push(h)}}replaceImportStatements(s){if(!NA(s)||!pj(s.value))return;let l=s.value.value;if(typeof l!="string")return;if(!Qhr.some(N=>eN(s,N))&&!bht.some(N=>eN(s,N))){if(nFe.test(l)){if(s.name.value==="$ref")return;this.errors.push(new RA("An $import() statement is not expected at this location.",yK,s.location,l))}return}let _=nFe.exec(l);if(bht.some(N=>eN(s,N))&&!_)return;if(!_){this.errors.push(new RA("Invalid $import() statement",yK,s.location,l));return}let h=_[1];h=h.replace(/\\/g,"/"),h.startsWith(".")&&(h=Yhr.posix.join("..",h));let b=this.getImportName(h),D={type:ec.Identifier,parent:s.parent,value:b};s.value=D}replaceEnvStatements=vht(Xhr,this.errors,yK)};function Sht(a){return`(request, context) => {
582
+ `),exitCode:b},"Untar process logs")}}t(rar,"untarFile");async function nar(a){if(await M3e(a))return await M3.rm(a,{recursive:!0})}t(nar,"deleteFolder");var ou=j3e;var IT=ap(R3e(),1);var sO=class extends Error{static{t(this,"CustomResolveError")}},j3=class{static{t(this,"RefParser")}sourceDirectory;logger;constructor(s,l){this.sourceDirectory=s,this.logger=l}dereference(s,l){return gG.$RefParser.dereference(s,{resolve:{json:!0,file:aue(this.sourceDirectory,this.logger),external:!0,http:!1},dereference:{circular:"ignore",onDereference:l?.onDereference}})}bundle(s){return gG.$RefParser.bundle(s,{resolve:{file:aue(this.sourceDirectory,this.logger),external:!0,http:!1}})}parse(s){return gG.$RefParser.parse(s,{resolve:{file:aue(this.sourceDirectory,this.logger),external:!0,http:!1}})}resolve(s){return gG.$RefParser.resolve(s,{resolve:{file:aue(this.sourceDirectory,this.logger),external:!0,http:!1}})}};function aue(a,s){return{order:100,canRead(l){let _=oar(l.url);if(!(_===void 0||_==="file"))return!1;let b;try{b=Uut(l.url)}catch(D){throw new sO(`Malformed URI: ${l.url}`,{cause:D})}try{ou.safePath(a).resolve(b)}catch(D){return s?.warn(D),!1}return!0},async read(l){let _;try{_=Uut(l.url)}catch(h){throw new sO(`Malformed URI: ${l.url}`,{cause:h})}try{return await iar(_)}catch(h){throw new sO(`Error opening file "${_}"`,{cause:h})}}}}t(aue,"customResolver");var tj=/^win/.test(globalThis.process?globalThis.process.platform:""),sar=/\//g,aar=/^(\w{2,}):\/\//i,B3e=[/%23/g,"#",/%24/g,"$",/%26/g,"&",/%2C/g,",",/%40/g,"@"];function oar(a){let s=aar.exec(a);if(s)return s[1].toLowerCase()}t(oar,"getProtocol");function Uut(a,s){a=decodeURI(a);for(let _=0;_<B3e.length;_+=2)a=a.replace(B3e[_],B3e[_+1]);let l=a.substr(0,7).toLowerCase()==="file://";if(l&&(a=a[7]==="/"?a.substr(8):a.substr(7),tj&&a[1]==="/"&&(a=a[0]+":"+a.substr(1)),s?a="file:///"+a:(l=!1,a=tj?a:"/"+a)),!l){let _=a.split(tj?"\\":"/"),h=[];for(let b of _)b===".."?h.length&&h[h.length-1]!==""&&h.pop():(b!==""||h.length===0)&&h.push(b);a=h.join(tj?"\\":"/"),!tj&&h[0]===""&&(a="/"+a.substring(1))}return tj&&!l&&(a=a.replace(sar,"\\"),a.substr(1,2)===":\\"&&(a=a[0].toUpperCase()+a.substr(1))),a}t(Uut,"toFileSystemPath");var $ut="YOUR_KEY_HERE";async function zut(a){let l=await new j3(a.sourceDirectory,a.logger).bundle(a.openApiDocPath),_=a.openApiDocPath.replace(a.sourceDirectory,"");return car({...a,relativeOpenApiPath:_},l)}t(zut,"buildPublicOpenApiFile");async function car(a,s){_ar({relativeOpenApiPath:a.relativeOpenApiPath},s);let l=s;return l=uar(l),lar(l,a.deploymentUrl),l=far(l,a),Jut(l,"x-zuplo"),l}t(car,"buildRawOpenApiFile");function lar(a,s){s?a.servers=[{url:s}]:a.servers=[]}t(lar,"addServerHost");function uar(a){if(!a.paths)return a;let{components:s}=a,l=s?{...s}:void 0,_=[];l&&l.parameters&&(_=Object.entries(l.parameters).reduce((b,[D,N])=>(DM in N&&Qce(N[DM])&&(b.push(D),l.parameters&&delete l.parameters[D]),b),[]));let h=Object.entries(a.paths).reduce((b,[D,N])=>{if(!N)return b;let M={...N},z=["delete","get","head","patch","post","put","trace","options"];return z.forEach(ne=>{let ie=N[ne];if(!ie)return;if(Qce(ie[DM])){delete M[ne];return}let{parameters:Q}=ie;if(!Q)return;let Me=Q.filter(Ie=>{if(DM in Ie&&Qce(Ie[DM]))return!1;if("$ref"in Ie){let Pe=Ie.$ref.split("/").pop();return Pe?!_.includes(Pe):!0}return!0});M[ne]={...ie,parameters:Me}}),z.some(ne=>!!M[ne])&&(b[D]=M),b},{});return{...a,paths:h,components:l}}t(uar,"removeHiddenRoutesAndParams");function far(a,{policiesConfig:s}){if(!a.paths)return a;let l=Object.entries(a.paths).reduce((_,[h,b])=>{if(!b)return _;let D={...b};return[D.delete,D.get,D.head,D.patch,D.post,D.put,D.trace,D.options].forEach(N=>{if(!N)return;let M=N["x-zuplo-route"]?.policies?.inbound?.reduce((ie,Q)=>{let Me=s.policies?.find(({name:Pt})=>Pt===Q);if(!Me)return ie;if(!(Me.handler.export==="CompositeInboundPolicy"))return ie.concat(Q);let Pe=Me.handler.options?.policies;return Pe?ie.concat(Pe):ie},[]),z=[];if(M&&M.forEach(ie=>{s.policies?.forEach(Q=>{Q.name===ie&&(Q.handler.export==="ApiAuthKeyInboundPolicy"||Q.handler.export==="ApiKeyInboundPolicy")&&!Q.handler.options?.disableAutomaticallyAddingKeyHeaderToOpenApi&&z.push(Q)})}),z.length>0){let ie=z.length>0&&z[0].handler&&z[0].handler.options&&z[0].handler.options.authHeader?z[0].handler.options.authHeader:"Authorization",Q=z.length>0&&z[0].handler&&z[0].handler.options&&(z[0].handler.options.authScheme||z[0].handler.options.authScheme==="")?z[0].handler.options.authScheme:"Bearer",Me=Q!==""?`${Q} ${$ut}`:$ut,Ie={name:ie,in:"header",required:!0,example:Me,schema:{type:"string"},description:`The \`${ie}\` header is used to authenticate with the API using your API key. Value is of the format \`${Me}\`.`};N.parameters?N.parameters.some(Tr=>"name"in Tr&&Tr.name===Ie.name)||N.parameters.unshift(Ie):N.parameters=[Ie];let Pe={type:"http",scheme:Q.toLowerCase()},Pt="api_key";a.components?.securitySchemes?Object.values(a.components?.securitySchemes).some(Tr=>"name"in Tr&&Tr.type==="apiKey"||"type"in Tr&&Tr.type==="http"&&Tr.scheme===Q)||(a.components.securitySchemes={...a.components.securitySchemes,[Pt]:Pe}):(a.components||(a.components={}),a.components.securitySchemes={[Pt]:Pe});let xt={[Pt]:[]};N.security?N.security.some(Tr=>Tr[Pt]!==void 0)||N.security.unshift(xt):N.security=[xt]}let ne=[];if(M&&M.forEach(ie=>{s.policies?.forEach(Q=>{Q.name===ie&&(Q.handler.export==="RateLimitInboundPolicy"||Q.handler.export==="ComplexRateLimitInboundPolicy")&&ne.push(Q)})}),ne.length>0){let ie={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"}}}}}},Q={...ie,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:ie,RateLimitWithRetryAfter:Q},N.responses||(N.responses={});let Me=ne.some(Ie=>Ie.handler.options?.headerMode!=="none");N.responses[429]||(N.responses[429]={$ref:Me?"#/components/responses/RateLimitWithRetryAfter":"#/components/responses/RateLimitNoRetryAfter"})}}),_[h]=D,_},{});return{...a,paths:l}}t(far,"enrichSpecWithZuploData");function Jut(a,s){for(let l in a)l.startsWith(s)?delete a[l]:typeof a[l]=="object"&&Jut(a[l],s)}t(Jut,"removePropertiesByPrefix");function _ar({relativeOpenApiPath:a},s){if(!s||typeof s!="object")throw new z1({message:"The OpenAPI Document could not be parsed.",severity:"error"});if(!("info"in s)||typeof s.info!="object"||!s.info)throw new z1({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 z1({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(_ar,"assertIsZuploOpenApiSpec");import vK from"node:path";function par(a){if(a.length>=255)throw new TypeError("Alphabet too long");let s=new Uint8Array(256);for(let z=0;z<s.length;z++)s[z]=255;for(let z=0;z<a.length;z++){let ne=a.charAt(z),ie=ne.charCodeAt(0);if(s[ie]!==255)throw new TypeError(ne+" is ambiguous");s[ie]=z}let l=a.length,_=a.charAt(0),h=Math.log(l)/Math.log(256),b=Math.log(256)/Math.log(l);function D(z){if(z instanceof Uint8Array||(ArrayBuffer.isView(z)?z=new Uint8Array(z.buffer,z.byteOffset,z.byteLength):Array.isArray(z)&&(z=Uint8Array.from(z))),!(z instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(z.length===0)return"";let ne=0,ie=0,Q=0,Me=z.length;for(;Q!==Me&&z[Q]===0;)Q++,ne++;let Ie=(Me-Q)*b+1>>>0,Pe=new Uint8Array(Ie);for(;Q!==Me;){let Tr=z[Q],cn=0;for(let tn=Ie-1;(Tr!==0||cn<ie)&&tn!==-1;tn--,cn++)Tr+=256*Pe[tn]>>>0,Pe[tn]=Tr%l>>>0,Tr=Tr/l>>>0;if(Tr!==0)throw new Error("Non-zero carry");ie=cn,Q++}let Pt=Ie-ie;for(;Pt!==Ie&&Pe[Pt]===0;)Pt++;let xt=_.repeat(ne);for(;Pt<Ie;++Pt)xt+=a.charAt(Pe[Pt]);return xt}t(D,"encode");function N(z){if(typeof z!="string")throw new TypeError("Expected String");if(z.length===0)return new Uint8Array;let ne=0,ie=0,Q=0;for(;z[ne]===_;)ie++,ne++;let Me=(z.length-ne)*h+1>>>0,Ie=new Uint8Array(Me);for(;z[ne];){let Tr=s[z.charCodeAt(ne)];if(Tr===255)return;let cn=0;for(let tn=Me-1;(Tr!==0||cn<Q)&&tn!==-1;tn--,cn++)Tr+=l*Ie[tn]>>>0,Ie[tn]=Tr%256>>>0,Tr=Tr/256>>>0;if(Tr!==0)throw new Error("Non-zero carry");Q=cn,ne++}let Pe=Me-Q;for(;Pe!==Me&&Ie[Pe]===0;)Pe++;let Pt=new Uint8Array(ie+(Me-Pe)),xt=ie;for(;Pe!==Me;)Pt[xt++]=Ie[Pe++];return Pt}t(N,"decodeUnsafe");function M(z){let ne=N(z);if(ne)return ne;throw new Error("Non-base"+l+" character")}return t(M,"decode"),{encode:D,decodeUnsafe:N,decode:M}}t(par,"base");var qut=par;var dar="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",oue=qut(dar);var U3e="2025-02-06",Vut=Object.freeze({none:{runOutboundPoliciesOnHandlerOnAllStatuses:!1,doNotRunHooksOnSystemRoutes:!1,removeAllVendorHeadersExceptListed:!1,allowCustomPorts:!1,removeLegacyLogInitialization:!1,useForwardRedirectsPropOnUrlForwardHandler:!1},"2023-03-14":{runOutboundPoliciesOnHandlerOnAllStatuses:!1,doNotRunHooksOnSystemRoutes:!1,removeAllVendorHeadersExceptListed:!1,allowCustomPorts:!1,removeLegacyLogInitialization:!1,useForwardRedirectsPropOnUrlForwardHandler:!1},"2024-01-15":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!1,removeLegacyLogInitialization:!1,useForwardRedirectsPropOnUrlForwardHandler:!1},"2024-03-14":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!1,removeLegacyLogInitialization:!1,useForwardRedirectsPropOnUrlForwardHandler:!1},"2024-09-02":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!0,removeLegacyLogInitialization:!1,useForwardRedirectsPropOnUrlForwardHandler:!1},"2025-02-06":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!0,removeLegacyLogInitialization:!0,useForwardRedirectsPropOnUrlForwardHandler:!0}});function Wut(){return new V2({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:U3e,ENVIRONMENT_TYPE:"mock-environment-type",GIT_SHA:void 0,IS_LOCAL_DEVELOPMENT:!1,COMPATIBILITY_FLAGS:Vut[U3e]},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(Wut,"getMockEnvironment");var V2=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=Wut()),this.#r}constructor({build:s,runtime:l}){let _;try{if(l.ZUPLO_SYSTEM_CONFIGURATIONS){let h=new TextDecoder().decode(oue.decode(l.ZUPLO_SYSTEM_CONFIGURATIONS)),b=JSON.parse(h);for(let D of Object.keys(b))l[D]||(l[D]=b[D])}if(l.__ZUPLO_CONFIG){let h=atob(l.__ZUPLO_CONFIG);_=JSON.parse(h)}}catch(h){console.error("Failed to parse runtime configuration",h)}this.config=_??{},this.build=s,this.runtime=l,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 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 mar=["ZUPLO_USER_LOGGER_DATA_DOG_API_KEY","ZUPLO_USER_LOGGER_DATA_DOG_URL","ZUPLO_LOG_LEVEL","ZUPLO_HANDLER_WRITE_LOG_LEVEL"];function Hut(a){return a.startsWith("__ZUPLO")||a.startsWith("ZUPLO_")?!mar.includes(a)&&!a.startsWith("ZUPLO_PUBLIC_"):!1}t(Hut,"isRestrictedEnvVariableName");function Gut(a){return!!a.startsWith("ZUPLO_")}t(Gut,"isZuploReadableEnvVariableName");var N8r=new Proxy({},{get(a,s){let l=String(s);switch(l){case"ZUPLO_ENVIRONMENT_TYPE":return V2.instance.loggingEnvironmentType;case"ZUPLO_ENVIRONMENT_STAGE":return V2.instance.loggingEnvironmentStage;case"ZUPLO_ENVIRONMENT_NAME":return V2.instance.runtime.__ZUPLO_DEPLOYMENT_NAME;case"ZUPLO_ACCOUNT_NAME":return V2.instance.build.ACCOUNT_NAME;case"ZUPLO_PROJECT_NAME":return V2.instance.build.PROJECT_NAME;case"ZUPLO_BUILD_ID":return V2.instance.build.BUILD_ID;case"ZUPLO_COMPATIBILITY_DATE":return V2.instance.build.COMPATIBILITY_DATE}if(!(Hut(l)&&!Gut(l)))return V2.instance.runtime[l]}});function yG(a,s,l){return`_${CA(`${a}_${s}_${l}`)}`}t(yG,"getRawOperationDataIdentifierName");function $3e(a,s,l,_){return`_${CA(a.toLowerCase())}_${s.toLowerCase()}_${l.toLowerCase()}_${_.toLowerCase()}`}t($3e,"getIdForParameterSchema");function z3e(a,s,l){return`_${CA(a.toLowerCase())}_${s.toLowerCase()}_rb_${CA(l.toLowerCase())}`}t(z3e,"getIdForRequestBodySchema");function vG(a,s){return`_${CA(a)}_${CA(s)}`}t(vG,"getIdForRefSchema");function CA(a){let s=a.replace(/\[/g,"_LBRACKET_").replace(/\]/g,"_RBRACKET_").replace(/\{/g,"_LCURLY_").replace(/\}/g,"_RCURLY_").replace(/\//g,"_SLASH_").replace(/-/g,"_DASH_").replace(/\./g,"_DOT_").replace(/\+/g,"_PLUS_").replace(/:/g,"_COLON_").replace(/@/g,"_AT_").replace(/\$/g,"_DOLLAR_").replace(/[^a-zA-Z0-9_]/g,"_");return/^[a-zA-Z_]/.test(s)||(s="_"+s),s}t(CA,"sanitizedIdentifierName");var Dht=ap(j_t(),1);var LG=class{static{t(this,"R")}type=3;name="";prefix="";value="";suffix="";modifier=3;constructor(a,s,l,_,h,b){this.type=a,this.name=s,this.prefix=l,this.value=_,this.suffix=h,this.modifier=b}hasCustomName(){return this.name!==""&&typeof this.name!="number"}},llr=/[$_\p{ID_Start}]/u,ulr=/[$_\u200C\u200D\p{ID_Continue}]/u,RNe=".*";function flr(a,s){return(s?/^[\x00-\xFF]*$/:/^[\x00-\x7F]*$/).test(a)}t(flr,"Re");function $_t(a,s=!1){let l=[],_=0;for(;_<a.length;){let h=a[_],b=t(function(D){if(!s)throw new TypeError(D);l.push({type:"INVALID_CHAR",index:_,value:a[_++]})},"c");if(h==="*"){l.push({type:"ASTERISK",index:_,value:a[_++]});continue}if(h==="+"||h==="?"){l.push({type:"OTHER_MODIFIER",index:_,value:a[_++]});continue}if(h==="\\"){l.push({type:"ESCAPED_CHAR",index:_++,value:a[_++]});continue}if(h==="{"){l.push({type:"OPEN",index:_,value:a[_++]});continue}if(h==="}"){l.push({type:"CLOSE",index:_,value:a[_++]});continue}if(h===":"){let D="",N=_+1;for(;N<a.length;){let M=a.substr(N,1);if(N===_+1&&llr.test(M)||N!==_+1&&ulr.test(M)){D+=a[N++];continue}break}if(!D){b(`Missing parameter name at ${_}`);continue}l.push({type:"NAME",index:_,value:D}),_=N;continue}if(h==="("){let D=1,N="",M=_+1,z=!1;if(a[M]==="?"){b(`Pattern cannot start with "?" at ${M}`);continue}for(;M<a.length;){if(!flr(a[M],!1)){b(`Invalid character '${a[M]}' at ${M}.`),z=!0;break}if(a[M]==="\\"){N+=a[M++]+a[M++];continue}if(a[M]===")"){if(D--,D===0){M++;break}}else if(a[M]==="("&&(D++,a[M+1]!=="?")){b(`Capturing groups are not allowed at ${M}`),z=!0;break}N+=a[M++]}if(z)continue;if(D){b(`Unbalanced pattern at ${_}`);continue}if(!N){b(`Missing pattern at ${_}`);continue}l.push({type:"REGEX",index:_,value:N}),_=M;continue}l.push({type:"CHAR",index:_,value:a[_++]})}return l.push({type:"END",index:_,value:""}),l}t($_t,"v");function z_t(a,s={}){let l=$_t(a);s.delimiter??="/#?",s.prefixes??="./";let _=`[^${RT(s.delimiter)}]+?`,h=[],b=0,D=0,N="",M=new Set,z=t(cn=>{if(D<l.length&&l[D].type===cn)return l[D++].value},"a"),ne=t(()=>z("OTHER_MODIFIER")??z("ASTERISK"),"f"),ie=t(cn=>{let tn=z(cn);if(tn!==void 0)return tn;let{type:ln,index:Cr}=l[D];throw new TypeError(`Unexpected ${ln} at ${Cr}, expected ${cn}`)},"d"),Q=t(()=>{let cn="",tn;for(;tn=z("CHAR")??z("ESCAPED_CHAR");)cn+=tn;return cn},"T"),Me=t(cn=>cn,"Se"),Ie=s.encodePart||Me,Pe="",Pt=t(cn=>{Pe+=cn},"U"),xt=t(()=>{Pe.length&&(h.push(new LG(3,"","",Ie(Pe),"",3)),Pe="")},"$"),Tr=t((cn,tn,ln,Cr,vr)=>{let fs=3;switch(vr){case"?":fs=1;break;case"*":fs=0;break;case"+":fs=2;break}if(!tn&&!ln&&fs===3){Pt(cn);return}if(xt(),!tn&&!ln){if(!cn)return;h.push(new LG(3,"","",Ie(cn),"",fs));return}let Fi;ln?ln==="*"?Fi=RNe:Fi=ln:Fi=_;let Ho=2;Fi===_?(Ho=1,Fi=""):Fi===RNe&&(Ho=0,Fi="");let di;if(tn?di=tn:ln&&(di=b++),M.has(di))throw new TypeError(`Duplicate name '${di}'.`);M.add(di),h.push(new LG(Ho,di,Ie(cn),Fi,Ie(Cr),fs))},"V");for(;D<l.length;){let cn=z("CHAR"),tn=z("NAME"),ln=z("REGEX");if(!tn&&!ln&&(ln=z("ASTERISK")),tn||ln){let vr=cn??"";s.prefixes.indexOf(vr)===-1&&(Pt(vr),vr=""),xt();let fs=ne();Tr(vr,tn,ln,"",fs);continue}let Cr=cn??z("ESCAPED_CHAR");if(Cr){Pt(Cr);continue}if(z("OPEN")){let vr=Q(),fs=z("NAME"),Fi=z("REGEX");!fs&&!Fi&&(Fi=z("ASTERISK"));let Ho=Q();ie("CLOSE");let di=ne();Tr(vr,fs,Fi,Ho,di);continue}xt(),ie("END")}return h}t(z_t,"D");function RT(a){return a.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}t(RT,"S");function B_t(a){return a&&a.ignoreCase?"ui":"u"}t(B_t,"X");function _lr(a,s,l){return J_t(z_t(a,l),s,l)}t(_lr,"Z");function fj(a){switch(a){case 0:return"*";case 1:return"?";case 2:return"+";case 3:return""}}t(fj,"k");function J_t(a,s,l={}){l.delimiter??="/#?",l.prefixes??="./",l.sensitive??=!1,l.strict??=!1,l.end??=!0,l.start??=!0,l.endsWith="";let _=l.start?"^":"";for(let N of a){if(N.type===3){N.modifier===3?_+=RT(N.value):_+=`(?:${RT(N.value)})${fj(N.modifier)}`;continue}s&&s.push(N.name);let M=`[^${RT(l.delimiter)}]+?`,z=N.value;if(N.type===1?z=M:N.type===0&&(z=RNe),!N.prefix.length&&!N.suffix.length){N.modifier===3||N.modifier===1?_+=`(${z})${fj(N.modifier)}`:_+=`((?:${z})${fj(N.modifier)})`;continue}if(N.modifier===3||N.modifier===1){_+=`(?:${RT(N.prefix)}(${z})${RT(N.suffix)})`,_+=fj(N.modifier);continue}_+=`(?:${RT(N.prefix)}`,_+=`((?:${z})(?:`,_+=RT(N.suffix),_+=RT(N.prefix),_+=`(?:${z}))*)${RT(N.suffix)})`,N.modifier===0&&(_+="?")}let h=`[${RT(l.endsWith)}]|$`,b=`[${RT(l.delimiter)}]`;if(l.end)return l.strict||(_+=`${b}?`),l.endsWith.length?_+=`(?=${h})`:_+="$",new RegExp(_,B_t(l));l.strict||(_+=`(?:${b}(?=${h}))?`);let D=!1;if(a.length){let N=a[a.length-1];N.type===3&&N.modifier===3&&(D=l.delimiter.indexOf(N)>-1)}return D||(_+=`(?=${b}|${h})`),new RegExp(_,B_t(l))}t(J_t,"F");var z3={delimiter:"",prefixes:"",sensitive:!0,strict:!0},plr={delimiter:".",prefixes:"",sensitive:!0,strict:!0},dlr={delimiter:"/",prefixes:"/",sensitive:!0,strict:!0};function mlr(a,s){return a.length?a[0]==="/"?!0:!s||a.length<2?!1:(a[0]=="\\"||a[0]=="{")&&a[1]=="/":!1}t(mlr,"J");function q_t(a,s){return a.startsWith(s)?a.substring(s.length,a.length):a}t(q_t,"Q");function hlr(a,s){return a.endsWith(s)?a.substr(0,a.length-s.length):a}t(hlr,"Ee");function V_t(a){return!a||a.length<2?!1:a[0]==="["||(a[0]==="\\"||a[0]==="{")&&a[1]==="["}t(V_t,"W");var W_t=["ftp","file","http","https","ws","wss"];function H_t(a){if(!a)return!0;for(let s of W_t)if(a.test(s))return!0;return!1}t(H_t,"N");function glr(a,s){if(a=q_t(a,"#"),s||a==="")return a;let l=new URL("https://example.com");return l.hash=a,l.hash?l.hash.substring(1,l.hash.length):""}t(glr,"te");function ylr(a,s){if(a=q_t(a,"?"),s||a==="")return a;let l=new URL("https://example.com");return l.search=a,l.search?l.search.substring(1,l.search.length):""}t(ylr,"re");function vlr(a,s){return s||a===""?a:V_t(a)?Y_t(a):K_t(a)}t(vlr,"ne");function blr(a,s){if(s||a==="")return a;let l=new URL("https://example.com");return l.password=a,l.password}t(blr,"se");function Slr(a,s){if(s||a==="")return a;let l=new URL("https://example.com");return l.username=a,l.username}t(Slr,"ie");function Tlr(a,s,l){if(l||a==="")return a;if(s&&!W_t.includes(s))return new URL(`${s}:${a}`).pathname;let _=a[0]=="/";return a=new URL(_?a:"/-"+a,"https://example.com").pathname,_||(a=a.substring(2,a.length)),a}t(Tlr,"ae");function xlr(a,s,l){return G_t(s)===a&&(a=""),l||a===""?a:X_t(a)}t(xlr,"oe");function Clr(a,s){return a=hlr(a,":"),s||a===""?a:MNe(a)}t(Clr,"ce");function G_t(a){switch(a){case"ws":case"http":return"80";case"wws":case"https":return"443";case"ftp":return"21";default:return""}}t(G_t,"_");function MNe(a){if(a==="")return a;if(/^[-+.A-Za-z0-9]*$/.test(a))return a.toLowerCase();throw new TypeError(`Invalid protocol '${a}'.`)}t(MNe,"y");function Elr(a){if(a==="")return a;let s=new URL("https://example.com");return s.username=a,s.username}t(Elr,"le");function Dlr(a){if(a==="")return a;let s=new URL("https://example.com");return s.password=a,s.password}t(Dlr,"fe");function K_t(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(K_t,"z");function Y_t(a){if(a==="")return a;if(/[^0-9a-fA-F[\]:]/g.test(a))throw new TypeError(`Invalid IPv6 hostname '${a}'`);return a.toLowerCase()}t(Y_t,"j");function X_t(a){if(a===""||/^[0-9]*$/.test(a)&&parseInt(a)<=65535)return a;throw new TypeError(`Invalid port '${a}'.`)}t(X_t,"K");function klr(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(klr,"he");function wlr(a){return a===""?a:new URL(`data:${a}`).pathname}t(wlr,"ue");function Plr(a){if(a==="")return a;let s=new URL("https://example.com");return s.search=a,s.search.substring(1,s.search.length)}t(Plr,"de");function Alr(a){if(a==="")return a;let s=new URL("https://example.com");return s.hash=a,s.hash.substring(1,s.hash.length)}t(Alr,"pe");var Nlr=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=$_t(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.#w()){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.#E()?(a=2,s=3):this.#l&&(a=2),this.#i(a,s)}break;case 2:this.#x()?this.#d(3):(this.#C()||this.#y()||this.#D())&&this.#d(5);break;case 3:this.#b()?this.#i(4,1):this.#x()&&this.#i(5,1);break;case 4:this.#x()&&this.#i(5,1);break;case 5:this.#N()?this.#c+=1:this.#S()&&(this.#c-=1),this.#k()&&!this.#c?this.#i(6,1):this.#C()?this.#i(7,0):this.#y()?this.#i(8,1):this.#D()&&this.#i(9,1);break;case 6:this.#C()?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 l=this.#u(a);return l.value===s&&(l.type==="CHAR"||l.type==="ESCAPED_CHAR"||l.type==="INVALID_CHAR")}#g(){return this.#m(this.#t,":")}#E(){return this.#m(this.#t+1,"/")&&this.#m(this.#t+2,"/")}#x(){return this.#m(this.#t,"@")}#b(){return this.#m(this.#t,":")}#k(){return this.#m(this.#t,":")}#C(){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,"#")}#w(){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,z3),a.encodePart=MNe;let s=_lr(this.#T(),void 0,a);this.#l=H_t(s)}},LNe=["protocol","username","password","hostname","port","pathname","search","hash"],$3="*";function U_t(a,s){if(typeof a!="string")throw new TypeError("parameter 1 is not of type 'string'.");let l=new URL(a,s);return{protocol:l.protocol.substring(0,l.protocol.length-1),username:l.username,password:l.password,hostname:l.hostname,port:l.port,pathname:l.pathname,search:l.search!==""?l.search.substring(1,l.search.length):void 0,hash:l.hash!==""?l.hash.substring(1,l.hash.length):void 0}}t(U_t,"ge");function PA(a,s){return s?OG(a):a}t(PA,"b");function FG(a,s,l){let _;if(typeof s.baseURL=="string")try{_=new URL(s.baseURL),s.protocol===void 0&&(a.protocol=PA(_.protocol.substring(0,_.protocol.length-1),l)),!l&&s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.username===void 0&&(a.username=PA(_.username,l)),!l&&s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.username===void 0&&s.password===void 0&&(a.password=PA(_.password,l)),s.protocol===void 0&&s.hostname===void 0&&(a.hostname=PA(_.hostname,l)),s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&(a.port=PA(_.port,l)),s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.pathname===void 0&&(a.pathname=PA(_.pathname,l)),s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.pathname===void 0&&s.search===void 0&&(a.search=PA(_.search.substring(1,_.search.length),l)),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=PA(_.hash.substring(1,_.hash.length),l))}catch{throw new TypeError(`invalid baseURL '${s.baseURL}'.`)}if(typeof s.protocol=="string"&&(a.protocol=Clr(s.protocol,l)),typeof s.username=="string"&&(a.username=Slr(s.username,l)),typeof s.password=="string"&&(a.password=blr(s.password,l)),typeof s.hostname=="string"&&(a.hostname=vlr(s.hostname,l)),typeof s.port=="string"&&(a.port=xlr(s.port,a.protocol,l)),typeof s.pathname=="string"){if(a.pathname=s.pathname,_&&!mlr(a.pathname,l)){let h=_.pathname.lastIndexOf("/");h>=0&&(a.pathname=PA(_.pathname.substring(0,h+1),l)+a.pathname)}a.pathname=Tlr(a.pathname,a.protocol,l)}return typeof s.search=="string"&&(a.search=ylr(s.search,l)),typeof s.hash=="string"&&(a.hash=glr(s.hash,l)),a}t(FG,"w");function OG(a){return a.replace(/([+*?:{}()\\])/g,"\\$1")}t(OG,"C");function Ilr(a){return a.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}t(Ilr,"Oe");function Flr(a,s){s.delimiter??="/#?",s.prefixes??="./",s.sensitive??=!1,s.strict??=!1,s.end??=!0,s.start??=!0,s.endsWith="";let l=".*",_=`[^${Ilr(s.delimiter)}]+?`,h=/[$_\u200C\u200D\p{ID_Continue}]/u,b="";for(let D=0;D<a.length;++D){let N=a[D];if(N.type===3){if(N.modifier===3){b+=OG(N.value);continue}b+=`{${OG(N.value)}}${fj(N.modifier)}`;continue}let M=N.hasCustomName(),z=!!N.suffix.length||!!N.prefix.length&&(N.prefix.length!==1||!s.prefixes.includes(N.prefix)),ne=D>0?a[D-1]:null,ie=D<a.length-1?a[D+1]:null;if(!z&&M&&N.type===1&&N.modifier===3&&ie&&!ie.prefix.length&&!ie.suffix.length)if(ie.type===3){let Q=ie.value.length>0?ie.value[0]:"";z=h.test(Q)}else z=!ie.hasCustomName();if(!z&&!N.prefix.length&&ne&&ne.type===3){let Q=ne.value[ne.value.length-1];z=s.prefixes.includes(Q)}z&&(b+="{"),b+=OG(N.prefix),M&&(b+=`:${N.name}`),N.type===2?b+=`(${N.value})`:N.type===1?M||(b+=`(${_})`):N.type===0&&(!M&&(!ne||ne.type===3||ne.modifier!==3||z||N.prefix!=="")?b+="*":b+=`(${l})`),N.type===1&&M&&N.suffix.length&&h.test(N.suffix[0])&&(b+="\\"),b+=OG(N.suffix),z&&(b+="}"),N.modifier!==3&&(b+=fj(N.modifier))}return b}t(Flr,"ke");var Q_t=class{static{t(this,"me")}#r;#n={};#e={};#t={};#s={};#p=!1;constructor(a={},s,l){try{let _;if(typeof s=="string"?_=s:l=s,typeof a=="string"){let N=new Nlr(a);if(N.parse(),a=N.result,_===void 0&&typeof a.protocol!="string")throw new TypeError("A base URL must be provided for a relative constructor string.");a.baseURL=_}else{if(!a||typeof a!="object")throw new TypeError("parameter 1 is not of type 'string' and cannot convert to dictionary.");if(_)throw new TypeError("parameter 1 is not of type 'string'.")}typeof l>"u"&&(l={ignoreCase:!1});let h={ignoreCase:l.ignoreCase===!0},b={pathname:$3,protocol:$3,username:$3,password:$3,hostname:$3,port:$3,search:$3,hash:$3};this.#r=FG(b,a,!0),G_t(this.#r.protocol)===this.#r.port&&(this.#r.port="");let D;for(D of LNe){if(!(D in this.#r))continue;let N={},M=this.#r[D];switch(this.#e[D]=[],D){case"protocol":Object.assign(N,z3),N.encodePart=MNe;break;case"username":Object.assign(N,z3),N.encodePart=Elr;break;case"password":Object.assign(N,z3),N.encodePart=Dlr;break;case"hostname":Object.assign(N,plr),V_t(M)?N.encodePart=Y_t:N.encodePart=K_t;break;case"port":Object.assign(N,z3),N.encodePart=X_t;break;case"pathname":H_t(this.#n.protocol)?(Object.assign(N,dlr,h),N.encodePart=klr):(Object.assign(N,z3,h),N.encodePart=wlr);break;case"search":Object.assign(N,z3,h),N.encodePart=Plr;break;case"hash":Object.assign(N,z3,h),N.encodePart=Alr;break}try{this.#s[D]=z_t(M,N),this.#n[D]=J_t(this.#s[D],this.#e[D],N),this.#t[D]=Flr(this.#s[D],N),this.#p=this.#p||this.#s[D].some(z=>z.type===2)}catch{throw new TypeError(`invalid ${D} pattern '${this.#r[D]}'.`)}}}catch(_){throw new TypeError(`Failed to construct 'URLPattern': ${_.message}`)}}test(a={},s){let l={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"?l=FG(l,a,!1):l=FG(l,U_t(a,s),!1)}catch{return!1}let _;for(_ of LNe)if(!this.#n[_].exec(l[_]))return!1;return!0}exec(a={},s){let l={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"?l=FG(l,a,!1):l=FG(l,U_t(a,s),!1)}catch{return null}let _={};s?_.inputs=[a,s]:_.inputs=[a];let h;for(h of LNe){let b=this.#n[h].exec(l[h]);if(!b)return null;let D={};for(let[N,M]of this.#e[h].entries())if(typeof M=="string"||typeof M=="number"){let z=b[N+1];D[M]=z}_[h]={input:l[h]??"",groups:D}}return _}static compareComponent(a,s,l){let _=t((N,M)=>{for(let z of["type","modifier","prefix","value","suffix"]){if(N[z]<M[z])return-1;if(N[z]!==M[z])return 1}return 0},"o"),h=new LG(3,"","","","",3),b=new LG(0,"","","","",3),D=t((N,M)=>{let z=0;for(;z<Math.min(N.length,M.length);++z){let ne=_(N[z],M[z]);if(ne)return ne}return N.length===M.length?0:_(N[z]??h,M[z]??h)},"s");return!s.#t[a]&&!l.#t[a]?0:s.#t[a]&&!l.#t[a]?D(s.#s[a],[b]):!s.#t[a]&&l.#t[a]?D([b],l.#s[a]):D(s.#s[a],l.#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=Q_t);import{AssertionError as Olr}from"node:assert";function AA(a,s){if(a===!1)throw new Olr({message:s})}t(AA,"assert");var ec;(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"})(ec||(ec={}));function _j(a){return a.type===ec.Object}t(_j,"isAstObject");function NA(a){return a.type===ec.Property}t(NA,"isAstProperty");function Z_t(a){return a.type===ec.Array}t(Z_t,"isAstArray");function pj(a){return a.type===ec.Literal}t(pj,"isAstLiteral");function J3(a){if(a===void 0)throw new Error("Node is undefined");if(!_j(a))throw new Error("Node is not object")}t(J3,"assertAstObject");import{findNodeAtLocation as Llr,getNodeValue as Rlr,printParseErrorCode as Mlr,visit as jlr}from"jsonc-parser";var Blr={DEFAULT:{allowTrailingComma:!1}};function RG(a,s=[],l=Blr.DEFAULT){let _={type:"array",offset:-1,length:-1,line:-1,column:-1,children:[],parent:void 0};function h(M){_.type==="property"&&(_.length=M-_.offset,_=_.parent)}t(h,"ensurePropertyComplete");function b(M){return _.children?.push(M),M}t(b,"onValue"),jlr(a,{onObjectBegin:t((M,z,ne)=>{_=b({type:"object",offset:M,length:-1,line:z+1,column:ne+1,parent:_,children:[]})},"onObjectBegin"),onObjectProperty:t((M,z,ne,ie,Q)=>{_=b({type:"property",offset:z,length:-1,line:ie+1,column:Q+1,parent:_,children:[]}),_.children?.push({type:"string",value:M,offset:z,length:ne,line:ie,column:Q,parent:_})},"onObjectProperty"),onObjectEnd:t((M,z)=>{h(M+z),_.length=M+z-_.offset,_=_.parent,h(M+z)},"onObjectEnd"),onArrayBegin:t((M,z,ne,ie)=>{_=b({type:"array",offset:M,length:-1,line:ne+1,column:ie+1,parent:_,children:[]})},"onArrayBegin"),onArrayEnd:t((M,z)=>{_.length=M+z-_.offset,_=_.parent,h(M+z)},"onArrayEnd"),onLiteralValue:t((M,z,ne,ie,Q)=>{b({type:Ulr(M),offset:z,length:ne,line:ie+1,column:Q+1,parent:_,value:M}),h(z+ne)},"onLiteralValue"),onSeparator:t((M,z)=>{_.type==="property"&&(M===":"?_.colonOffset=z:M===","&&h(z))},"onSeparator"),onError:t((M,z,ne,ie,Q)=>{s.push({error:M,offset:z,length:ne,line:ie+1,column:Q+1})},"onError")},l);let N=_.children[0];return N&&delete N.parent,N}t(RG,"parse");function Ulr(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(Ulr,"getNodeType");function jNe(a,s){return Llr(a,s)}t(jNe,"findNodeAtLocation");function MG(a){return Rlr(a)}t(MG,"getNodeValue");function ept(a){return Mlr(a)}t(ept,"printParseErrorCode");var jG=class{static{t(this,"AstAdapter")}parse(s){let _=RG(s,[]);if(_)return this.parseNode(_,void 0);throw new Error("Failed to parse JSON")}convert(s){return this.parseNode(s,void 0)}parseNode(s,l){switch(s.type){case"object":return this.createObject(s,l);case"array":return this.createArray(s,l);case"property":return this.createProperty(s,l);case"string":return this.createLiteral(s,l);case"number":return this.createLiteral(s,l);case"boolean":return this.createLiteral(s,l);case"null":return this.createLiteral(s,l)}}createLiteral(s,l){return{type:ec.Literal,location:{line:s.line,column:s.column},parent:l,value:s.type==="null"?null:s.value}}createObject(s,l){let _={type:ec.Object,children:[],parent:l,location:{line:s.line,column:s.column}};return s.children?.forEach(h=>{_.children.push(this.parseNode(h,_))}),_}createProperty(s,l){AA(s.children?.length===2,"Invalid property node");let _={type:ec.Property,location:{line:s.line,column:s.column},parent:l,name:null,value:null};return _.name={value:s.children[0].value,location:{line:s.line,column:s.column},type:ec.Identifier,parent:_},_.value=this.parseNode(s.children[1],_),_}createArray(s,l){let _={type:ec.Array,location:{line:s.line,column:s.column},parent:l,children:[]};return s.children?.forEach(h=>_.children.push(this.parseNode(h,_))),_}};var MT={createLiteral:t((a,s)=>({type:ec.Literal,parent:s,value:a}),"createLiteral"),createTemplateString:t((a,s)=>({type:ec.TemplateString,parent:s,value:a}),"createTemplateString"),createIdentifier:t((a,s)=>({type:ec.Identifier,value:a,parent:s}),"createIdentifier"),createProperty:t((a,s,l)=>{let _={type:ec.Property,parent:l,name:null,value:s};return _.name={value:a,type:ec.Identifier,parent:_},_.value.parent=_,_},"createProperty"),createArrayOfLiterals:t((a,s)=>{let l={type:ec.Array,parent:s,children:[]};for(let _ of a)l.children.push(MT.createLiteral(_,l));return l},"createArrayOfLiterals")};var $lr=/^[a-zA-Z_$][a-zA-Z0-9_$]*$/,BG=class{static{t(this,"SourceGenerator")}generate(s){let l=[];return this.generateSource(l,s),l.join("")}generateSource(s,l){switch(l.type){case ec.Array:return this.generateArray(s,l);case ec.Object:return this.generateObject(s,l);case ec.Property:return this.generateProperty(s,l);case ec.Literal:return this.generateLiteral(s,l);case ec.FunctionCall:return this.generateFunctionCall(s,l);case ec.Identifier:return this.generateIdentifier(s,l);case ec.Raw:return this.generateRaw(s,l);case ec.TemplateString:return this.generateTemplateString(s,l)}}generateArray(s,l){s.push("["),l.children.map(_=>{this.generateSource(s,_),s.push(",")}),s.push("]")}generateObject(s,l){s.push("{"),l.children.forEach(_=>{this.generateSource(s,_),s.push(",")}),s.push("}")}generateProperty(s,l){this.generateIdentifier(s,l.name),s.push(":"),this.generateSource(s,l.value)}generateFunctionCall(s,l){s.push(l.name.value),s.push("("),l.children.forEach((_,h,b)=>{this.generateSource(s,_),h<b.length&&s.push(",")}),s.push(")")}generateRaw(s,l){s.push(l.value)}generateTemplateString(s,l){s.push("`"),s.push(l.value.replaceAll("`","\\`")),s.push("`")}generateLiteral(s,l){if(l.value===null)return s.push("null");switch(typeof l.value){case"number":case"boolean":return s.push(`${l.value}`);case"string":{let _=l.value,h=JSON.stringify(_);return s.push(`${h}`)}}}generateIdentifier(s,l){let _=$lr.test(l.value)?l.value:`'${l.value}'`;s.push(_)}};import zlr from"node:fs/promises";import{parse as Jlr}from"@swc/core";var tpt=t(async a=>{let s=new Set;try{let l=await zlr.readFile(a,"utf-8");(await Jlr(l,{syntax:"typescript"})).body.forEach(h=>{h.type==="ExportDefaultDeclaration"||h.type==="ExportDefaultExpression"?s.add("default"):h.type==="ExportDeclaration"&&h.declaration.type==="FunctionDeclaration"?s.add(h.declaration.identifier.value):h.type==="ExportDeclaration"&&h.declaration.type==="VariableDeclaration"&&h.declaration.declarations[0].id.type==="Identifier"&&s.add(h.declaration.declarations[0].id.value)})}catch{return null}return s},"getJSFileExports");var rpt={$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 BNe={$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 npt={$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 UNe={$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:{},mcp:{type:"object",additionalProperties:!1,properties:{enabled:{type:"boolean"}}},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 $Ne={$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:{},mcp:{type:"object",additionalProperties:!1,properties:{enabled:{type:"boolean"}}},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 hht=ap(Bmt(),1),ght=ap(mht(),1);var Efe=class a{static{t(this,"JsonValidator")}static#r=new a;static get instance(){return a.#r}ajv;constructor(){this.ajv=new ght.Ajv2020({allErrors:!0,allowUnionTypes:!0}),this.ajv.addKeyword("faker"),(0,hht.default)(this.ajv,{mode:"fast"})}addSchema(s,l){this.ajv.addSchema(s,l)}compile(s){let l=this.ajv.compile(s);return t(h=>({isValid:l(h),errors:this.toSimpleErrors(l.errors,h),warnings:[]}),"validator")}toSimpleErrors(s,l){let _=[];return s?.forEach(h=>{h.keyword==="enum"&&h.params.allowedValues&&Array.isArray(h.params.allowedValues)&&(h.message+=`; ${h.params.allowedValues.join(", ")}`),h.instancePath&&(h.instancePath=h.instancePath.replaceAll(/(\/)?(~1)(\/)?/gm,"/"));let b={details:{}},D=h.instancePath.split("/");if(D.length>2){let M=D[1],z=D[2]?parseInt(D[2]):0,ne=D[3],ie=isNaN(z)?void 0:l[M][z][ne];b={details:{property:M,index:z,field:ne,fieldValue:ie}}}if(h.keyword==="required"&&h.params.missingProperty&&h.instancePath&&(h.message=`A 'path' is missing required property '${h.params.missingProperty}'`),h.keyword==="additionalProperties"&&h.params.additionalProperty&&h.instancePath&&(h.message=`A 'path' should NOT include property '${h.params.additionalProperty}'`),h.keyword==="type"&&h.params.type&&h.instancePath){let M=h.instancePath.split("/"),z=M[M.length-1];h.message=`Value of property '${z}' must be '${h.params.type}'`}let N=Object.assign(h,b);_.push(N)}),_}};var Z3=Efe.instance;Z3.addSchema($Ne,"route-configuration.schema.json");Z3.addSchema(npt,"policy-configuration.schema.json");Z3.addSchema(BNe,"policies.schema.json");Z3.addSchema(UNe,"open-api-route-configuration.schema.json");Z3.addSchema(rpt,"fragments.schema.json");var A9r=Z3.compile($Ne),yht=Z3.compile(UNe),rFe=Z3.compile(BNe);var Dfe=class{static{t(this,"PoliciesConfigurationValidator")}results;validate(s){return this.results=rFe(s),this.results}};var kfe=class{static{t(this,"OpenAPILocalizedValidator")}results;validate(s){return this.results=yht(s),this.results}};import Yhr from"node:path";var nFe=/\$import\((.*)\)/,wfe=/\$env\((.*?)\)/g;var RA=class extends Error{static{t(this,"CodeGenError")}location;constructor(s,l,_,h){super(s),this.location={file:l,namespace:"",line:_?_.line:0,column:_?_.column:0,length:0,lineText:h??"",suggestion:""}}},Khr=t(a=>{let s=[],l=a;for(;l.parent;)s.push(l),l=l.parent;return s.reverse()},"invertTree"),eN=t((a,s)=>{if(!a)return!1;let l=Khr(a);return s.split("/").every((b,D)=>{let N=l[D];return N?b==="*"||NA(N)&&N.name.value===b?!0:b==="{}"?N.type===ec.Object:b==="[]"?N.type===ec.Array:!1:!1})},"testPosition");var Pfe=class{static{t(this,"AstTransformer")}errors=[];transform(s){return this.visitor(s),s}visitor(s){this.visit(s),_j(s)?s.children.forEach(l=>{this.visitor(l)}):Z_t(s)?s.children.forEach(l=>{this.visitor(l)}):NA(s)&&this.visitor(s.value)}},vht=t((a,s,l)=>_=>{if(!NA(_)||!pj(_.value)||typeof _.value.value!="string")return;if(!a.some(b=>eN(_,b))){wfe.test(_.value.value)&&s.push(new RA("An $env() statement is not expected at this location.",l,_.location,_.value.value));return}let h=new RegExp(wfe).exec(_.value.value);if(h?.length===2&&h[0]===_.value.value){let b={type:ec.Raw,parent:null,value:`environment["${h[1]}"]`};_.value=b}else{let b=_.value.value.replaceAll(new RegExp(wfe),(D,N)=>`\${environment["${N}"] ? environment["${N}"] : ""}`);b!==_.value.value&&(_.value=MT.createTemplateString(b,_))}},"getEnvStatementTransformer");var yK="config/routes.json",Xhr=["handler/{}/options/*","policies/[]/{}/handler/{}/options/*","corsPolicies/[]/{}/*"],Qhr=["handler/{}/module","handler/{}/options/{}/policies/{}/inbound/[]/{}/module","handler/{}/options/{}/policies/{}/outbound/[]/{}/module","policies/[]/{}/handler/{}/module","policies/[]/{}/handler/{}/options/{}/identifier/{}/module","policies/[]/{}/handler/{}/options/{}/validator"],bht=["handler/{}/options/*","policies/[]/{}/handler/{}/options/*"],Zhr="handler/{}/options/{}/rewritePattern",egr="handler/{}/options/{}/baseUrl",Afe=class extends Pfe{static{t(this,"OpenAPIRoutesFragmentAstTransformer")}importCount=0;addedImports=new Map;getImportName(s){this.addedImports.has(s)||this.addedImports.set(s,`__import${this.importCount++}`);let l=this.addedImports.get(s);if(!l)throw new Error("Import name is undefined. This should not happen.");return l}getImports(){let s=[];return this.addedImports.forEach((l,_)=>{s.push({name:l,path:_})}),s}visit(s){this.rewriteHandlerFunction(s),this.rewriteForwardFunction(s),this.replaceImportStatements(s),this.replaceEnvStatements(s)}rewriteHandlerFunction(s){if(!(!NA(s)||!pj(s.value)||typeof s.value.value!="string")&&eN(s,Zhr)){if(!s.parent||!_j(s.parent)){this.errors.push(new RA("Invalid node, expected object",yK,s.parent?s.parent.location:s.location,void 0));return}let l=s.value.value,_={type:ec.Raw,parent:null,value:Sht(l)},h=MT.createProperty("__rewriteFunction",_,s);s.parent.children.push(h)}}rewriteForwardFunction(s){if(!(!NA(s)||!pj(s.value)||typeof s.value.value!="string")&&eN(s,egr)){if(!s.parent||!_j(s.parent)){this.errors.push(new RA("Invalid node, expected object",yK,s.parent?s.parent.location:s.location,void 0));return}let l=s.value.value,_={type:ec.Raw,parent:null,value:Sht(l)},h=MT.createProperty("__rewriteFunction",_,s);s.parent.children.push(h)}}replaceImportStatements(s){if(!NA(s)||!pj(s.value))return;let l=s.value.value;if(typeof l!="string")return;if(!Qhr.some(N=>eN(s,N))&&!bht.some(N=>eN(s,N))){if(nFe.test(l)){if(s.name.value==="$ref")return;this.errors.push(new RA("An $import() statement is not expected at this location.",yK,s.location,l))}return}let _=nFe.exec(l);if(bht.some(N=>eN(s,N))&&!_)return;if(!_){this.errors.push(new RA("Invalid $import() statement",yK,s.location,l));return}let h=_[1];h=h.replace(/\\/g,"/"),h.startsWith(".")&&(h=Yhr.posix.join("..",h));let b=this.getImportName(h),D={type:ec.Identifier,parent:s.parent,value:b};s.value=D}replaceEnvStatements=vht(Xhr,this.errors,yK)};function Sht(a){return`(request, context) => {
583
583
  const { params, url, query, method, headers } = request;
584
584
  const { host, hostname, origin, pathname, port, search } = new URL(url);
585
585
  const e = encodeURIComponent;
package/index.minified.js CHANGED
@@ -579,7 +579,7 @@ globstar while`,s,Q,l,Me,Ie),this.matchOne(s.slice(Q),l.slice(Me),_))return this
579
579
  `),stderr:b.join(`
580
580
  `),exitCode:D},"Tar process logs")}}t(Dar,"tarFolder");async function kar({tarFilePath:a,outputDir:s,logger:l}){let _=[],h=[],b;try{await new Promise((D,N)=>{let M=Jut("sh",["-c",`tar -xvf ${a} -C ${s};`]);M.stdout.on("data",z=>{let ne=z.toString().trim();ne.length>0&&_.push(ne.trim())}),M.stderr.on("data",z=>{let ne=z.toString().trim();ne.length>0&&h.push(ne.trim())}),M.on("close",z=>{b=z,z===0?D():N(new Error(`tar process exited with code ${z}`))}),M.on("error",z=>{N(z)})})}catch(D){throw new Error("Failed to untar file",{cause:D})}finally{l.info({stdout:_.join(`
581
581
  `),stderr:h.join(`
582
- `),exitCode:b},"Untar process logs")}}t(kar,"untarFile");async function war(a){if(await z3e(a))return await B3.rm(a,{recursive:!0})}t(war,"deleteFolder");var ou=J3e;var IT=x_($3e(),1);var oO=class extends Error{static{t(this,"CustomResolveError")}},U3=class{static{t(this,"RefParser")}sourceDirectory;logger;constructor(s,l){this.sourceDirectory=s,this.logger=l}dereference(s,l){return yG.$RefParser.dereference(s,{resolve:{json:!0,file:aue(this.sourceDirectory,this.logger),external:!0,http:!1},dereference:{circular:"ignore",onDereference:l?.onDereference}})}bundle(s){return yG.$RefParser.bundle(s,{resolve:{file:aue(this.sourceDirectory,this.logger),external:!0,http:!1}})}parse(s){return yG.$RefParser.parse(s,{resolve:{file:aue(this.sourceDirectory,this.logger),external:!0,http:!1}})}resolve(s){return yG.$RefParser.resolve(s,{resolve:{file:aue(this.sourceDirectory,this.logger),external:!0,http:!1}})}};function aue(a,s){return{order:100,canRead(l){let _=Iar(l.url);if(!(_===void 0||_==="file"))return!1;let b;try{b=Hut(l.url)}catch(D){throw new oO(`Malformed URI: ${l.url}`,{cause:D})}try{ou.safePath(a).resolve(b)}catch(D){return s?.warn(D),!1}return!0},async read(l){let _;try{_=Hut(l.url)}catch(h){throw new oO(`Malformed URI: ${l.url}`,{cause:h})}try{return await Par(_)}catch(h){throw new oO(`Error opening file "${_}"`,{cause:h})}}}}t(aue,"customResolver");var rj=/^win/.test(globalThis.process?globalThis.process.platform:""),Aar=/\//g,Nar=/^(\w{2,}):\/\//i,q3e=[/%23/g,"#",/%24/g,"$",/%26/g,"&",/%2C/g,",",/%40/g,"@"];function Iar(a){let s=Nar.exec(a);if(s)return s[1].toLowerCase()}t(Iar,"getProtocol");function Hut(a,s){a=decodeURI(a);for(let _=0;_<q3e.length;_+=2)a=a.replace(q3e[_],q3e[_+1]);let l=a.substr(0,7).toLowerCase()==="file://";if(l&&(a=a[7]==="/"?a.substr(8):a.substr(7),rj&&a[1]==="/"&&(a=a[0]+":"+a.substr(1)),s?a="file:///"+a:(l=!1,a=rj?a:"/"+a)),!l){let _=a.split(rj?"\\":"/"),h=[];for(let b of _)b===".."?h.length&&h[h.length-1]!==""&&h.pop():(b!==""||h.length===0)&&h.push(b);a=h.join(rj?"\\":"/"),!rj&&h[0]===""&&(a="/"+a.substring(1))}return rj&&!l&&(a=a.replace(Aar,"\\"),a.substr(1,2)===":\\"&&(a=a[0].toUpperCase()+a.substr(1))),a}t(Hut,"toFileSystemPath");var Gut="YOUR_KEY_HERE";async function Kut(a){let l=await new U3(a.sourceDirectory,a.logger).bundle(a.openApiDocPath),_=a.openApiDocPath.replace(a.sourceDirectory,"");return Far({...a,relativeOpenApiPath:_},l)}t(Kut,"buildPublicOpenApiFile");async function Far(a,s){Mar({relativeOpenApiPath:a.relativeOpenApiPath},s);let l=s;return l=Lar(l),Oar(l,a.deploymentUrl),l=Rar(l,a),Yut(l,"x-zuplo"),l}t(Far,"buildRawOpenApiFile");function Oar(a,s){s?a.servers=[{url:s}]:a.servers=[]}t(Oar,"addServerHost");function Lar(a){if(!a.paths)return a;let{components:s}=a,l=s?{...s}:void 0,_=[];l&&l.parameters&&(_=Object.entries(l.parameters).reduce((b,[D,N])=>(wM in N&&Qce(N[wM])&&(b.push(D),l.parameters&&delete l.parameters[D]),b),[]));let h=Object.entries(a.paths).reduce((b,[D,N])=>{if(!N)return b;let M={...N},z=["delete","get","head","patch","post","put","trace","options"];return z.forEach(ne=>{let ie=N[ne];if(!ie)return;if(Qce(ie[wM])){delete M[ne];return}let{parameters:Q}=ie;if(!Q)return;let Me=Q.filter(Ie=>{if(wM in Ie&&Qce(Ie[wM]))return!1;if("$ref"in Ie){let Pe=Ie.$ref.split("/").pop();return Pe?!_.includes(Pe):!0}return!0});M[ne]={...ie,parameters:Me}}),z.some(ne=>!!M[ne])&&(b[D]=M),b},{});return{...a,paths:h,components:l}}t(Lar,"removeHiddenRoutesAndParams");function Rar(a,{policiesConfig:s}){if(!a.paths)return a;let l=Object.entries(a.paths).reduce((_,[h,b])=>{if(!b)return _;let D={...b};return[D.delete,D.get,D.head,D.patch,D.post,D.put,D.trace,D.options].forEach(N=>{if(!N)return;let M=N["x-zuplo-route"]?.policies?.inbound?.reduce((ie,Q)=>{let Me=s.policies?.find(({name:Pt})=>Pt===Q);if(!Me)return ie;if(!(Me.handler.export==="CompositeInboundPolicy"))return ie.concat(Q);let Pe=Me.handler.options?.policies;return Pe?ie.concat(Pe):ie},[]),z=[];if(M&&M.forEach(ie=>{s.policies?.forEach(Q=>{Q.name===ie&&(Q.handler.export==="ApiAuthKeyInboundPolicy"||Q.handler.export==="ApiKeyInboundPolicy")&&!Q.handler.options?.disableAutomaticallyAddingKeyHeaderToOpenApi&&z.push(Q)})}),z.length>0){let ie=z.length>0&&z[0].handler&&z[0].handler.options&&z[0].handler.options.authHeader?z[0].handler.options.authHeader:"Authorization",Q=z.length>0&&z[0].handler&&z[0].handler.options&&(z[0].handler.options.authScheme||z[0].handler.options.authScheme==="")?z[0].handler.options.authScheme:"Bearer",Me=Q!==""?`${Q} ${Gut}`:Gut,Ie={name:ie,in:"header",required:!0,example:Me,schema:{type:"string"},description:`The \`${ie}\` header is used to authenticate with the API using your API key. Value is of the format \`${Me}\`.`};N.parameters?N.parameters.some(Tr=>"name"in Tr&&Tr.name===Ie.name)||N.parameters.unshift(Ie):N.parameters=[Ie];let Pe={type:"http",scheme:Q.toLowerCase()},Pt="api_key";a.components?.securitySchemes?Object.values(a.components?.securitySchemes).some(Tr=>"name"in Tr&&Tr.type==="apiKey"||"type"in Tr&&Tr.type==="http"&&Tr.scheme===Q)||(a.components.securitySchemes={...a.components.securitySchemes,[Pt]:Pe}):(a.components||(a.components={}),a.components.securitySchemes={[Pt]:Pe});let xt={[Pt]:[]};N.security?N.security.some(Tr=>Tr[Pt]!==void 0)||N.security.unshift(xt):N.security=[xt]}let ne=[];if(M&&M.forEach(ie=>{s.policies?.forEach(Q=>{Q.name===ie&&(Q.handler.export==="RateLimitInboundPolicy"||Q.handler.export==="ComplexRateLimitInboundPolicy")&&ne.push(Q)})}),ne.length>0){let ie={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"}}}}}},Q={...ie,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:ie,RateLimitWithRetryAfter:Q},N.responses||(N.responses={});let Me=ne.some(Ie=>Ie.handler.options?.headerMode!=="none");N.responses[429]||(N.responses[429]={$ref:Me?"#/components/responses/RateLimitWithRetryAfter":"#/components/responses/RateLimitNoRetryAfter"})}}),_[h]=D,_},{});return{...a,paths:l}}t(Rar,"enrichSpecWithZuploData");function Yut(a,s){for(let l in a)l.startsWith(s)?delete a[l]:typeof a[l]=="object"&&Yut(a[l],s)}t(Yut,"removePropertiesByPrefix");function Mar({relativeOpenApiPath:a},s){if(!s||typeof s!="object")throw new z1({message:"The OpenAPI Document could not be parsed.",severity:"error"});if(!("info"in s)||typeof s.info!="object"||!s.info)throw new z1({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 z1({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(Mar,"assertIsZuploOpenApiSpec");import bK from"node:path";function jar(a){if(a.length>=255)throw new TypeError("Alphabet too long");let s=new Uint8Array(256);for(let z=0;z<s.length;z++)s[z]=255;for(let z=0;z<a.length;z++){let ne=a.charAt(z),ie=ne.charCodeAt(0);if(s[ie]!==255)throw new TypeError(ne+" is ambiguous");s[ie]=z}let l=a.length,_=a.charAt(0),h=Math.log(l)/Math.log(256),b=Math.log(256)/Math.log(l);function D(z){if(z instanceof Uint8Array||(ArrayBuffer.isView(z)?z=new Uint8Array(z.buffer,z.byteOffset,z.byteLength):Array.isArray(z)&&(z=Uint8Array.from(z))),!(z instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(z.length===0)return"";let ne=0,ie=0,Q=0,Me=z.length;for(;Q!==Me&&z[Q]===0;)Q++,ne++;let Ie=(Me-Q)*b+1>>>0,Pe=new Uint8Array(Ie);for(;Q!==Me;){let Tr=z[Q],cn=0;for(let tn=Ie-1;(Tr!==0||cn<ie)&&tn!==-1;tn--,cn++)Tr+=256*Pe[tn]>>>0,Pe[tn]=Tr%l>>>0,Tr=Tr/l>>>0;if(Tr!==0)throw new Error("Non-zero carry");ie=cn,Q++}let Pt=Ie-ie;for(;Pt!==Ie&&Pe[Pt]===0;)Pt++;let xt=_.repeat(ne);for(;Pt<Ie;++Pt)xt+=a.charAt(Pe[Pt]);return xt}t(D,"encode");function N(z){if(typeof z!="string")throw new TypeError("Expected String");if(z.length===0)return new Uint8Array;let ne=0,ie=0,Q=0;for(;z[ne]===_;)ie++,ne++;let Me=(z.length-ne)*h+1>>>0,Ie=new Uint8Array(Me);for(;z[ne];){let Tr=s[z.charCodeAt(ne)];if(Tr===255)return;let cn=0;for(let tn=Me-1;(Tr!==0||cn<Q)&&tn!==-1;tn--,cn++)Tr+=l*Ie[tn]>>>0,Ie[tn]=Tr%256>>>0,Tr=Tr/256>>>0;if(Tr!==0)throw new Error("Non-zero carry");Q=cn,ne++}let Pe=Me-Q;for(;Pe!==Me&&Ie[Pe]===0;)Pe++;let Pt=new Uint8Array(ie+(Me-Pe)),xt=ie;for(;Pe!==Me;)Pt[xt++]=Ie[Pe++];return Pt}t(N,"decodeUnsafe");function M(z){let ne=N(z);if(ne)return ne;throw new Error("Non-base"+l+" character")}return t(M,"decode"),{encode:D,decodeUnsafe:N,decode:M}}t(jar,"base");var Xut=jar;var Bar="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",oue=Xut(Bar);var V3e="2025-02-06",Qut=Object.freeze({none:{runOutboundPoliciesOnHandlerOnAllStatuses:!1,doNotRunHooksOnSystemRoutes:!1,removeAllVendorHeadersExceptListed:!1,allowCustomPorts:!1,removeLegacyLogInitialization:!1,useForwardRedirectsPropOnUrlForwardHandler:!1},"2023-03-14":{runOutboundPoliciesOnHandlerOnAllStatuses:!1,doNotRunHooksOnSystemRoutes:!1,removeAllVendorHeadersExceptListed:!1,allowCustomPorts:!1,removeLegacyLogInitialization:!1,useForwardRedirectsPropOnUrlForwardHandler:!1},"2024-01-15":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!1,removeLegacyLogInitialization:!1,useForwardRedirectsPropOnUrlForwardHandler:!1},"2024-03-14":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!1,removeLegacyLogInitialization:!1,useForwardRedirectsPropOnUrlForwardHandler:!1},"2024-09-02":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!0,removeLegacyLogInitialization:!1,useForwardRedirectsPropOnUrlForwardHandler:!1},"2025-02-06":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!0,removeLegacyLogInitialization:!0,useForwardRedirectsPropOnUrlForwardHandler:!0}});function Zut(){return new V2({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:V3e,ENVIRONMENT_TYPE:"mock-environment-type",GIT_SHA:void 0,IS_LOCAL_DEVELOPMENT:!1,COMPATIBILITY_FLAGS:Qut[V3e]},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(Zut,"getMockEnvironment");var V2=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=Zut()),this.#r}constructor({build:s,runtime:l}){let _;try{if(l.ZUPLO_SYSTEM_CONFIGURATIONS){let h=new TextDecoder().decode(oue.decode(l.ZUPLO_SYSTEM_CONFIGURATIONS)),b=JSON.parse(h);for(let D of Object.keys(b))l[D]||(l[D]=b[D])}if(l.__ZUPLO_CONFIG){let h=atob(l.__ZUPLO_CONFIG);_=JSON.parse(h)}}catch(h){console.error("Failed to parse runtime configuration",h)}this.config=_??{},this.build=s,this.runtime=l,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 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 Uar=["ZUPLO_USER_LOGGER_DATA_DOG_API_KEY","ZUPLO_USER_LOGGER_DATA_DOG_URL","ZUPLO_LOG_LEVEL","ZUPLO_HANDLER_WRITE_LOG_LEVEL"];function eft(a){return a.startsWith("__ZUPLO")||a.startsWith("ZUPLO_")?!Uar.includes(a)&&!a.startsWith("ZUPLO_PUBLIC_"):!1}t(eft,"isRestrictedEnvVariableName");function tft(a){return!!a.startsWith("ZUPLO_")}t(tft,"isZuploReadableEnvVariableName");var eFr=new Proxy({},{get(a,s){let l=String(s);switch(l){case"ZUPLO_ENVIRONMENT_TYPE":return V2.instance.loggingEnvironmentType;case"ZUPLO_ENVIRONMENT_STAGE":return V2.instance.loggingEnvironmentStage;case"ZUPLO_ENVIRONMENT_NAME":return V2.instance.runtime.__ZUPLO_DEPLOYMENT_NAME;case"ZUPLO_ACCOUNT_NAME":return V2.instance.build.ACCOUNT_NAME;case"ZUPLO_PROJECT_NAME":return V2.instance.build.PROJECT_NAME;case"ZUPLO_BUILD_ID":return V2.instance.build.BUILD_ID;case"ZUPLO_COMPATIBILITY_DATE":return V2.instance.build.COMPATIBILITY_DATE}if(!(eft(l)&&!tft(l)))return V2.instance.runtime[l]}});function vG(a,s,l){return`_${kA(`${a}_${s}_${l}`)}`}t(vG,"getRawOperationDataIdentifierName");function W3e(a,s,l,_){return`_${kA(a.toLowerCase())}_${s.toLowerCase()}_${l.toLowerCase()}_${_.toLowerCase()}`}t(W3e,"getIdForParameterSchema");function H3e(a,s,l){return`_${kA(a.toLowerCase())}_${s.toLowerCase()}_rb_${kA(l.toLowerCase())}`}t(H3e,"getIdForRequestBodySchema");function bG(a,s){return`_${kA(a)}_${kA(s)}`}t(bG,"getIdForRefSchema");function kA(a){let s=a.replace(/\[/g,"_LBRACKET_").replace(/\]/g,"_RBRACKET_").replace(/\{/g,"_LCURLY_").replace(/\}/g,"_RCURLY_").replace(/\//g,"_SLASH_").replace(/-/g,"_DASH_").replace(/\./g,"_DOT_").replace(/\+/g,"_PLUS_").replace(/:/g,"_COLON_").replace(/@/g,"_AT_").replace(/\$/g,"_DOLLAR_").replace(/[^a-zA-Z0-9_]/g,"_");return/^[a-zA-Z_]/.test(s)||(s="_"+s),s}t(kA,"sanitizedIdentifierName");var Fht=x_(V_t(),1);var RG=class{static{t(this,"R")}type=3;name="";prefix="";value="";suffix="";modifier=3;constructor(a,s,l,_,h,b){this.type=a,this.name=s,this.prefix=l,this.value=_,this.suffix=h,this.modifier=b}hasCustomName(){return this.name!==""&&typeof this.name!="number"}},Flr=/[$_\p{ID_Start}]/u,Olr=/[$_\u200C\u200D\p{ID_Continue}]/u,$Ne=".*";function Llr(a,s){return(s?/^[\x00-\xFF]*$/:/^[\x00-\x7F]*$/).test(a)}t(Llr,"Re");function G_t(a,s=!1){let l=[],_=0;for(;_<a.length;){let h=a[_],b=t(function(D){if(!s)throw new TypeError(D);l.push({type:"INVALID_CHAR",index:_,value:a[_++]})},"c");if(h==="*"){l.push({type:"ASTERISK",index:_,value:a[_++]});continue}if(h==="+"||h==="?"){l.push({type:"OTHER_MODIFIER",index:_,value:a[_++]});continue}if(h==="\\"){l.push({type:"ESCAPED_CHAR",index:_++,value:a[_++]});continue}if(h==="{"){l.push({type:"OPEN",index:_,value:a[_++]});continue}if(h==="}"){l.push({type:"CLOSE",index:_,value:a[_++]});continue}if(h===":"){let D="",N=_+1;for(;N<a.length;){let M=a.substr(N,1);if(N===_+1&&Flr.test(M)||N!==_+1&&Olr.test(M)){D+=a[N++];continue}break}if(!D){b(`Missing parameter name at ${_}`);continue}l.push({type:"NAME",index:_,value:D}),_=N;continue}if(h==="("){let D=1,N="",M=_+1,z=!1;if(a[M]==="?"){b(`Pattern cannot start with "?" at ${M}`);continue}for(;M<a.length;){if(!Llr(a[M],!1)){b(`Invalid character '${a[M]}' at ${M}.`),z=!0;break}if(a[M]==="\\"){N+=a[M++]+a[M++];continue}if(a[M]===")"){if(D--,D===0){M++;break}}else if(a[M]==="("&&(D++,a[M+1]!=="?")){b(`Capturing groups are not allowed at ${M}`),z=!0;break}N+=a[M++]}if(z)continue;if(D){b(`Unbalanced pattern at ${_}`);continue}if(!N){b(`Missing pattern at ${_}`);continue}l.push({type:"REGEX",index:_,value:N}),_=M;continue}l.push({type:"CHAR",index:_,value:a[_++]})}return l.push({type:"END",index:_,value:""}),l}t(G_t,"v");function K_t(a,s={}){let l=G_t(a);s.delimiter??="/#?",s.prefixes??="./";let _=`[^${RT(s.delimiter)}]+?`,h=[],b=0,D=0,N="",M=new Set,z=t(cn=>{if(D<l.length&&l[D].type===cn)return l[D++].value},"a"),ne=t(()=>z("OTHER_MODIFIER")??z("ASTERISK"),"f"),ie=t(cn=>{let tn=z(cn);if(tn!==void 0)return tn;let{type:ln,index:Cr}=l[D];throw new TypeError(`Unexpected ${ln} at ${Cr}, expected ${cn}`)},"d"),Q=t(()=>{let cn="",tn;for(;tn=z("CHAR")??z("ESCAPED_CHAR");)cn+=tn;return cn},"T"),Me=t(cn=>cn,"Se"),Ie=s.encodePart||Me,Pe="",Pt=t(cn=>{Pe+=cn},"U"),xt=t(()=>{Pe.length&&(h.push(new RG(3,"","",Ie(Pe),"",3)),Pe="")},"$"),Tr=t((cn,tn,ln,Cr,vr)=>{let fs=3;switch(vr){case"?":fs=1;break;case"*":fs=0;break;case"+":fs=2;break}if(!tn&&!ln&&fs===3){Pt(cn);return}if(xt(),!tn&&!ln){if(!cn)return;h.push(new RG(3,"","",Ie(cn),"",fs));return}let Fi;ln?ln==="*"?Fi=$Ne:Fi=ln:Fi=_;let Ho=2;Fi===_?(Ho=1,Fi=""):Fi===$Ne&&(Ho=0,Fi="");let di;if(tn?di=tn:ln&&(di=b++),M.has(di))throw new TypeError(`Duplicate name '${di}'.`);M.add(di),h.push(new RG(Ho,di,Ie(cn),Fi,Ie(Cr),fs))},"V");for(;D<l.length;){let cn=z("CHAR"),tn=z("NAME"),ln=z("REGEX");if(!tn&&!ln&&(ln=z("ASTERISK")),tn||ln){let vr=cn??"";s.prefixes.indexOf(vr)===-1&&(Pt(vr),vr=""),xt();let fs=ne();Tr(vr,tn,ln,"",fs);continue}let Cr=cn??z("ESCAPED_CHAR");if(Cr){Pt(Cr);continue}if(z("OPEN")){let vr=Q(),fs=z("NAME"),Fi=z("REGEX");!fs&&!Fi&&(Fi=z("ASTERISK"));let Ho=Q();ie("CLOSE");let di=ne();Tr(vr,fs,Fi,Ho,di);continue}xt(),ie("END")}return h}t(K_t,"D");function RT(a){return a.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}t(RT,"S");function W_t(a){return a&&a.ignoreCase?"ui":"u"}t(W_t,"X");function Rlr(a,s,l){return Y_t(K_t(a,l),s,l)}t(Rlr,"Z");function _j(a){switch(a){case 0:return"*";case 1:return"?";case 2:return"+";case 3:return""}}t(_j,"k");function Y_t(a,s,l={}){l.delimiter??="/#?",l.prefixes??="./",l.sensitive??=!1,l.strict??=!1,l.end??=!0,l.start??=!0,l.endsWith="";let _=l.start?"^":"";for(let N of a){if(N.type===3){N.modifier===3?_+=RT(N.value):_+=`(?:${RT(N.value)})${_j(N.modifier)}`;continue}s&&s.push(N.name);let M=`[^${RT(l.delimiter)}]+?`,z=N.value;if(N.type===1?z=M:N.type===0&&(z=$Ne),!N.prefix.length&&!N.suffix.length){N.modifier===3||N.modifier===1?_+=`(${z})${_j(N.modifier)}`:_+=`((?:${z})${_j(N.modifier)})`;continue}if(N.modifier===3||N.modifier===1){_+=`(?:${RT(N.prefix)}(${z})${RT(N.suffix)})`,_+=_j(N.modifier);continue}_+=`(?:${RT(N.prefix)}`,_+=`((?:${z})(?:`,_+=RT(N.suffix),_+=RT(N.prefix),_+=`(?:${z}))*)${RT(N.suffix)})`,N.modifier===0&&(_+="?")}let h=`[${RT(l.endsWith)}]|$`,b=`[${RT(l.delimiter)}]`;if(l.end)return l.strict||(_+=`${b}?`),l.endsWith.length?_+=`(?=${h})`:_+="$",new RegExp(_,W_t(l));l.strict||(_+=`(?:${b}(?=${h}))?`);let D=!1;if(a.length){let N=a[a.length-1];N.type===3&&N.modifier===3&&(D=l.delimiter.indexOf(N)>-1)}return D||(_+=`(?=${b}|${h})`),new RegExp(_,W_t(l))}t(Y_t,"F");var q3={delimiter:"",prefixes:"",sensitive:!0,strict:!0},Mlr={delimiter:".",prefixes:"",sensitive:!0,strict:!0},jlr={delimiter:"/",prefixes:"/",sensitive:!0,strict:!0};function Blr(a,s){return a.length?a[0]==="/"?!0:!s||a.length<2?!1:(a[0]=="\\"||a[0]=="{")&&a[1]=="/":!1}t(Blr,"J");function X_t(a,s){return a.startsWith(s)?a.substring(s.length,a.length):a}t(X_t,"Q");function Ulr(a,s){return a.endsWith(s)?a.substr(0,a.length-s.length):a}t(Ulr,"Ee");function Q_t(a){return!a||a.length<2?!1:a[0]==="["||(a[0]==="\\"||a[0]==="{")&&a[1]==="["}t(Q_t,"W");var Z_t=["ftp","file","http","https","ws","wss"];function ept(a){if(!a)return!0;for(let s of Z_t)if(a.test(s))return!0;return!1}t(ept,"N");function $lr(a,s){if(a=X_t(a,"#"),s||a==="")return a;let l=new URL("https://example.com");return l.hash=a,l.hash?l.hash.substring(1,l.hash.length):""}t($lr,"te");function zlr(a,s){if(a=X_t(a,"?"),s||a==="")return a;let l=new URL("https://example.com");return l.search=a,l.search?l.search.substring(1,l.search.length):""}t(zlr,"re");function Jlr(a,s){return s||a===""?a:Q_t(a)?npt(a):rpt(a)}t(Jlr,"ne");function qlr(a,s){if(s||a==="")return a;let l=new URL("https://example.com");return l.password=a,l.password}t(qlr,"se");function Vlr(a,s){if(s||a==="")return a;let l=new URL("https://example.com");return l.username=a,l.username}t(Vlr,"ie");function Wlr(a,s,l){if(l||a==="")return a;if(s&&!Z_t.includes(s))return new URL(`${s}:${a}`).pathname;let _=a[0]=="/";return a=new URL(_?a:"/-"+a,"https://example.com").pathname,_||(a=a.substring(2,a.length)),a}t(Wlr,"ae");function Hlr(a,s,l){return tpt(s)===a&&(a=""),l||a===""?a:ipt(a)}t(Hlr,"oe");function Glr(a,s){return a=Ulr(a,":"),s||a===""?a:zNe(a)}t(Glr,"ce");function tpt(a){switch(a){case"ws":case"http":return"80";case"wws":case"https":return"443";case"ftp":return"21";default:return""}}t(tpt,"_");function zNe(a){if(a==="")return a;if(/^[-+.A-Za-z0-9]*$/.test(a))return a.toLowerCase();throw new TypeError(`Invalid protocol '${a}'.`)}t(zNe,"y");function Klr(a){if(a==="")return a;let s=new URL("https://example.com");return s.username=a,s.username}t(Klr,"le");function Ylr(a){if(a==="")return a;let s=new URL("https://example.com");return s.password=a,s.password}t(Ylr,"fe");function rpt(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(rpt,"z");function npt(a){if(a==="")return a;if(/[^0-9a-fA-F[\]:]/g.test(a))throw new TypeError(`Invalid IPv6 hostname '${a}'`);return a.toLowerCase()}t(npt,"j");function ipt(a){if(a===""||/^[0-9]*$/.test(a)&&parseInt(a)<=65535)return a;throw new TypeError(`Invalid port '${a}'.`)}t(ipt,"K");function Xlr(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(Xlr,"he");function Qlr(a){return a===""?a:new URL(`data:${a}`).pathname}t(Qlr,"ue");function Zlr(a){if(a==="")return a;let s=new URL("https://example.com");return s.search=a,s.search.substring(1,s.search.length)}t(Zlr,"de");function eur(a){if(a==="")return a;let s=new URL("https://example.com");return s.hash=a,s.hash.substring(1,s.hash.length)}t(eur,"pe");var tur=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=G_t(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.#w()){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.#E()?(a=2,s=3):this.#l&&(a=2),this.#i(a,s)}break;case 2:this.#x()?this.#d(3):(this.#C()||this.#y()||this.#D())&&this.#d(5);break;case 3:this.#b()?this.#i(4,1):this.#x()&&this.#i(5,1);break;case 4:this.#x()&&this.#i(5,1);break;case 5:this.#N()?this.#c+=1:this.#S()&&(this.#c-=1),this.#k()&&!this.#c?this.#i(6,1):this.#C()?this.#i(7,0):this.#y()?this.#i(8,1):this.#D()&&this.#i(9,1);break;case 6:this.#C()?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 l=this.#u(a);return l.value===s&&(l.type==="CHAR"||l.type==="ESCAPED_CHAR"||l.type==="INVALID_CHAR")}#g(){return this.#m(this.#t,":")}#E(){return this.#m(this.#t+1,"/")&&this.#m(this.#t+2,"/")}#x(){return this.#m(this.#t,"@")}#b(){return this.#m(this.#t,":")}#k(){return this.#m(this.#t,":")}#C(){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,"#")}#w(){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,q3),a.encodePart=zNe;let s=Rlr(this.#T(),void 0,a);this.#l=ept(s)}},UNe=["protocol","username","password","hostname","port","pathname","search","hash"],J3="*";function H_t(a,s){if(typeof a!="string")throw new TypeError("parameter 1 is not of type 'string'.");let l=new URL(a,s);return{protocol:l.protocol.substring(0,l.protocol.length-1),username:l.username,password:l.password,hostname:l.hostname,port:l.port,pathname:l.pathname,search:l.search!==""?l.search.substring(1,l.search.length):void 0,hash:l.hash!==""?l.hash.substring(1,l.hash.length):void 0}}t(H_t,"ge");function IA(a,s){return s?LG(a):a}t(IA,"b");function OG(a,s,l){let _;if(typeof s.baseURL=="string")try{_=new URL(s.baseURL),s.protocol===void 0&&(a.protocol=IA(_.protocol.substring(0,_.protocol.length-1),l)),!l&&s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.username===void 0&&(a.username=IA(_.username,l)),!l&&s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.username===void 0&&s.password===void 0&&(a.password=IA(_.password,l)),s.protocol===void 0&&s.hostname===void 0&&(a.hostname=IA(_.hostname,l)),s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&(a.port=IA(_.port,l)),s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.pathname===void 0&&(a.pathname=IA(_.pathname,l)),s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.pathname===void 0&&s.search===void 0&&(a.search=IA(_.search.substring(1,_.search.length),l)),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=IA(_.hash.substring(1,_.hash.length),l))}catch{throw new TypeError(`invalid baseURL '${s.baseURL}'.`)}if(typeof s.protocol=="string"&&(a.protocol=Glr(s.protocol,l)),typeof s.username=="string"&&(a.username=Vlr(s.username,l)),typeof s.password=="string"&&(a.password=qlr(s.password,l)),typeof s.hostname=="string"&&(a.hostname=Jlr(s.hostname,l)),typeof s.port=="string"&&(a.port=Hlr(s.port,a.protocol,l)),typeof s.pathname=="string"){if(a.pathname=s.pathname,_&&!Blr(a.pathname,l)){let h=_.pathname.lastIndexOf("/");h>=0&&(a.pathname=IA(_.pathname.substring(0,h+1),l)+a.pathname)}a.pathname=Wlr(a.pathname,a.protocol,l)}return typeof s.search=="string"&&(a.search=zlr(s.search,l)),typeof s.hash=="string"&&(a.hash=$lr(s.hash,l)),a}t(OG,"w");function LG(a){return a.replace(/([+*?:{}()\\])/g,"\\$1")}t(LG,"C");function rur(a){return a.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}t(rur,"Oe");function nur(a,s){s.delimiter??="/#?",s.prefixes??="./",s.sensitive??=!1,s.strict??=!1,s.end??=!0,s.start??=!0,s.endsWith="";let l=".*",_=`[^${rur(s.delimiter)}]+?`,h=/[$_\u200C\u200D\p{ID_Continue}]/u,b="";for(let D=0;D<a.length;++D){let N=a[D];if(N.type===3){if(N.modifier===3){b+=LG(N.value);continue}b+=`{${LG(N.value)}}${_j(N.modifier)}`;continue}let M=N.hasCustomName(),z=!!N.suffix.length||!!N.prefix.length&&(N.prefix.length!==1||!s.prefixes.includes(N.prefix)),ne=D>0?a[D-1]:null,ie=D<a.length-1?a[D+1]:null;if(!z&&M&&N.type===1&&N.modifier===3&&ie&&!ie.prefix.length&&!ie.suffix.length)if(ie.type===3){let Q=ie.value.length>0?ie.value[0]:"";z=h.test(Q)}else z=!ie.hasCustomName();if(!z&&!N.prefix.length&&ne&&ne.type===3){let Q=ne.value[ne.value.length-1];z=s.prefixes.includes(Q)}z&&(b+="{"),b+=LG(N.prefix),M&&(b+=`:${N.name}`),N.type===2?b+=`(${N.value})`:N.type===1?M||(b+=`(${_})`):N.type===0&&(!M&&(!ne||ne.type===3||ne.modifier!==3||z||N.prefix!=="")?b+="*":b+=`(${l})`),N.type===1&&M&&N.suffix.length&&h.test(N.suffix[0])&&(b+="\\"),b+=LG(N.suffix),z&&(b+="}"),N.modifier!==3&&(b+=_j(N.modifier))}return b}t(nur,"ke");var spt=class{static{t(this,"me")}#r;#n={};#e={};#t={};#s={};#p=!1;constructor(a={},s,l){try{let _;if(typeof s=="string"?_=s:l=s,typeof a=="string"){let N=new tur(a);if(N.parse(),a=N.result,_===void 0&&typeof a.protocol!="string")throw new TypeError("A base URL must be provided for a relative constructor string.");a.baseURL=_}else{if(!a||typeof a!="object")throw new TypeError("parameter 1 is not of type 'string' and cannot convert to dictionary.");if(_)throw new TypeError("parameter 1 is not of type 'string'.")}typeof l>"u"&&(l={ignoreCase:!1});let h={ignoreCase:l.ignoreCase===!0},b={pathname:J3,protocol:J3,username:J3,password:J3,hostname:J3,port:J3,search:J3,hash:J3};this.#r=OG(b,a,!0),tpt(this.#r.protocol)===this.#r.port&&(this.#r.port="");let D;for(D of UNe){if(!(D in this.#r))continue;let N={},M=this.#r[D];switch(this.#e[D]=[],D){case"protocol":Object.assign(N,q3),N.encodePart=zNe;break;case"username":Object.assign(N,q3),N.encodePart=Klr;break;case"password":Object.assign(N,q3),N.encodePart=Ylr;break;case"hostname":Object.assign(N,Mlr),Q_t(M)?N.encodePart=npt:N.encodePart=rpt;break;case"port":Object.assign(N,q3),N.encodePart=ipt;break;case"pathname":ept(this.#n.protocol)?(Object.assign(N,jlr,h),N.encodePart=Xlr):(Object.assign(N,q3,h),N.encodePart=Qlr);break;case"search":Object.assign(N,q3,h),N.encodePart=Zlr;break;case"hash":Object.assign(N,q3,h),N.encodePart=eur;break}try{this.#s[D]=K_t(M,N),this.#n[D]=Y_t(this.#s[D],this.#e[D],N),this.#t[D]=nur(this.#s[D],N),this.#p=this.#p||this.#s[D].some(z=>z.type===2)}catch{throw new TypeError(`invalid ${D} pattern '${this.#r[D]}'.`)}}}catch(_){throw new TypeError(`Failed to construct 'URLPattern': ${_.message}`)}}test(a={},s){let l={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"?l=OG(l,a,!1):l=OG(l,H_t(a,s),!1)}catch{return!1}let _;for(_ of UNe)if(!this.#n[_].exec(l[_]))return!1;return!0}exec(a={},s){let l={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"?l=OG(l,a,!1):l=OG(l,H_t(a,s),!1)}catch{return null}let _={};s?_.inputs=[a,s]:_.inputs=[a];let h;for(h of UNe){let b=this.#n[h].exec(l[h]);if(!b)return null;let D={};for(let[N,M]of this.#e[h].entries())if(typeof M=="string"||typeof M=="number"){let z=b[N+1];D[M]=z}_[h]={input:l[h]??"",groups:D}}return _}static compareComponent(a,s,l){let _=t((N,M)=>{for(let z of["type","modifier","prefix","value","suffix"]){if(N[z]<M[z])return-1;if(N[z]!==M[z])return 1}return 0},"o"),h=new RG(3,"","","","",3),b=new RG(0,"","","","",3),D=t((N,M)=>{let z=0;for(;z<Math.min(N.length,M.length);++z){let ne=_(N[z],M[z]);if(ne)return ne}return N.length===M.length?0:_(N[z]??h,M[z]??h)},"s");return!s.#t[a]&&!l.#t[a]?0:s.#t[a]&&!l.#t[a]?D(s.#s[a],[b]):!s.#t[a]&&l.#t[a]?D([b],l.#s[a]):D(s.#s[a],l.#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=spt);import{AssertionError as iur}from"node:assert";function FA(a,s){if(a===!1)throw new iur({message:s})}t(FA,"assert");var ec;(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"})(ec||(ec={}));function pj(a){return a.type===ec.Object}t(pj,"isAstObject");function OA(a){return a.type===ec.Property}t(OA,"isAstProperty");function apt(a){return a.type===ec.Array}t(apt,"isAstArray");function dj(a){return a.type===ec.Literal}t(dj,"isAstLiteral");function V3(a){if(a===void 0)throw new Error("Node is undefined");if(!pj(a))throw new Error("Node is not object")}t(V3,"assertAstObject");import{findNodeAtLocation as sur,getNodeValue as aur,printParseErrorCode as our,visit as cur}from"jsonc-parser";var lur={DEFAULT:{allowTrailingComma:!1}};function MG(a,s=[],l=lur.DEFAULT){let _={type:"array",offset:-1,length:-1,line:-1,column:-1,children:[],parent:void 0};function h(M){_.type==="property"&&(_.length=M-_.offset,_=_.parent)}t(h,"ensurePropertyComplete");function b(M){return _.children?.push(M),M}t(b,"onValue"),cur(a,{onObjectBegin:t((M,z,ne)=>{_=b({type:"object",offset:M,length:-1,line:z+1,column:ne+1,parent:_,children:[]})},"onObjectBegin"),onObjectProperty:t((M,z,ne,ie,Q)=>{_=b({type:"property",offset:z,length:-1,line:ie+1,column:Q+1,parent:_,children:[]}),_.children?.push({type:"string",value:M,offset:z,length:ne,line:ie,column:Q,parent:_})},"onObjectProperty"),onObjectEnd:t((M,z)=>{h(M+z),_.length=M+z-_.offset,_=_.parent,h(M+z)},"onObjectEnd"),onArrayBegin:t((M,z,ne,ie)=>{_=b({type:"array",offset:M,length:-1,line:ne+1,column:ie+1,parent:_,children:[]})},"onArrayBegin"),onArrayEnd:t((M,z)=>{_.length=M+z-_.offset,_=_.parent,h(M+z)},"onArrayEnd"),onLiteralValue:t((M,z,ne,ie,Q)=>{b({type:uur(M),offset:z,length:ne,line:ie+1,column:Q+1,parent:_,value:M}),h(z+ne)},"onLiteralValue"),onSeparator:t((M,z)=>{_.type==="property"&&(M===":"?_.colonOffset=z:M===","&&h(z))},"onSeparator"),onError:t((M,z,ne,ie,Q)=>{s.push({error:M,offset:z,length:ne,line:ie+1,column:Q+1})},"onError")},l);let N=_.children[0];return N&&delete N.parent,N}t(MG,"parse");function uur(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(uur,"getNodeType");function JNe(a,s){return sur(a,s)}t(JNe,"findNodeAtLocation");function jG(a){return aur(a)}t(jG,"getNodeValue");function opt(a){return our(a)}t(opt,"printParseErrorCode");var BG=class{static{t(this,"AstAdapter")}parse(s){let _=MG(s,[]);if(_)return this.parseNode(_,void 0);throw new Error("Failed to parse JSON")}convert(s){return this.parseNode(s,void 0)}parseNode(s,l){switch(s.type){case"object":return this.createObject(s,l);case"array":return this.createArray(s,l);case"property":return this.createProperty(s,l);case"string":return this.createLiteral(s,l);case"number":return this.createLiteral(s,l);case"boolean":return this.createLiteral(s,l);case"null":return this.createLiteral(s,l)}}createLiteral(s,l){return{type:ec.Literal,location:{line:s.line,column:s.column},parent:l,value:s.type==="null"?null:s.value}}createObject(s,l){let _={type:ec.Object,children:[],parent:l,location:{line:s.line,column:s.column}};return s.children?.forEach(h=>{_.children.push(this.parseNode(h,_))}),_}createProperty(s,l){FA(s.children?.length===2,"Invalid property node");let _={type:ec.Property,location:{line:s.line,column:s.column},parent:l,name:null,value:null};return _.name={value:s.children[0].value,location:{line:s.line,column:s.column},type:ec.Identifier,parent:_},_.value=this.parseNode(s.children[1],_),_}createArray(s,l){let _={type:ec.Array,location:{line:s.line,column:s.column},parent:l,children:[]};return s.children?.forEach(h=>_.children.push(this.parseNode(h,_))),_}};var MT={createLiteral:t((a,s)=>({type:ec.Literal,parent:s,value:a}),"createLiteral"),createTemplateString:t((a,s)=>({type:ec.TemplateString,parent:s,value:a}),"createTemplateString"),createIdentifier:t((a,s)=>({type:ec.Identifier,value:a,parent:s}),"createIdentifier"),createProperty:t((a,s,l)=>{let _={type:ec.Property,parent:l,name:null,value:s};return _.name={value:a,type:ec.Identifier,parent:_},_.value.parent=_,_},"createProperty"),createArrayOfLiterals:t((a,s)=>{let l={type:ec.Array,parent:s,children:[]};for(let _ of a)l.children.push(MT.createLiteral(_,l));return l},"createArrayOfLiterals")};var fur=/^[a-zA-Z_$][a-zA-Z0-9_$]*$/,UG=class{static{t(this,"SourceGenerator")}generate(s){let l=[];return this.generateSource(l,s),l.join("")}generateSource(s,l){switch(l.type){case ec.Array:return this.generateArray(s,l);case ec.Object:return this.generateObject(s,l);case ec.Property:return this.generateProperty(s,l);case ec.Literal:return this.generateLiteral(s,l);case ec.FunctionCall:return this.generateFunctionCall(s,l);case ec.Identifier:return this.generateIdentifier(s,l);case ec.Raw:return this.generateRaw(s,l);case ec.TemplateString:return this.generateTemplateString(s,l)}}generateArray(s,l){s.push("["),l.children.map(_=>{this.generateSource(s,_),s.push(",")}),s.push("]")}generateObject(s,l){s.push("{"),l.children.forEach(_=>{this.generateSource(s,_),s.push(",")}),s.push("}")}generateProperty(s,l){this.generateIdentifier(s,l.name),s.push(":"),this.generateSource(s,l.value)}generateFunctionCall(s,l){s.push(l.name.value),s.push("("),l.children.forEach((_,h,b)=>{this.generateSource(s,_),h<b.length&&s.push(",")}),s.push(")")}generateRaw(s,l){s.push(l.value)}generateTemplateString(s,l){s.push("`"),s.push(l.value.replaceAll("`","\\`")),s.push("`")}generateLiteral(s,l){if(l.value===null)return s.push("null");switch(typeof l.value){case"number":case"boolean":return s.push(`${l.value}`);case"string":{let _=l.value,h=JSON.stringify(_);return s.push(`${h}`)}}}generateIdentifier(s,l){let _=fur.test(l.value)?l.value:`'${l.value}'`;s.push(_)}};import _ur from"node:fs/promises";import{parse as pur}from"@swc/core";var cpt=t(async a=>{let s=new Set;try{let l=await _ur.readFile(a,"utf-8");(await pur(l,{syntax:"typescript"})).body.forEach(h=>{h.type==="ExportDefaultDeclaration"||h.type==="ExportDefaultExpression"?s.add("default"):h.type==="ExportDeclaration"&&h.declaration.type==="FunctionDeclaration"?s.add(h.declaration.identifier.value):h.type==="ExportDeclaration"&&h.declaration.type==="VariableDeclaration"&&h.declaration.declarations[0].id.type==="Identifier"&&s.add(h.declaration.declarations[0].id.value)})}catch{return null}return s},"getJSFileExports");var lpt={$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 qNe={$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 upt={$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 VNe={$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 WNe={$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 xht=x_(Wmt(),1),Cht=x_(Tht(),1);var Efe=class a{static{t(this,"JsonValidator")}static#r=new a;static get instance(){return a.#r}ajv;constructor(){this.ajv=new Cht.Ajv2020({allErrors:!0,allowUnionTypes:!0}),this.ajv.addKeyword("faker"),(0,xht.default)(this.ajv,{mode:"fast"})}addSchema(s,l){this.ajv.addSchema(s,l)}compile(s){let l=this.ajv.compile(s);return t(h=>({isValid:l(h),errors:this.toSimpleErrors(l.errors,h),warnings:[]}),"validator")}toSimpleErrors(s,l){let _=[];return s?.forEach(h=>{h.keyword==="enum"&&h.params.allowedValues&&Array.isArray(h.params.allowedValues)&&(h.message+=`; ${h.params.allowedValues.join(", ")}`),h.instancePath&&(h.instancePath=h.instancePath.replaceAll(/(\/)?(~1)(\/)?/gm,"/"));let b={details:{}},D=h.instancePath.split("/");if(D.length>2){let M=D[1],z=D[2]?parseInt(D[2]):0,ne=D[3],ie=isNaN(z)?void 0:l[M][z][ne];b={details:{property:M,index:z,field:ne,fieldValue:ie}}}if(h.keyword==="required"&&h.params.missingProperty&&h.instancePath&&(h.message=`A 'path' is missing required property '${h.params.missingProperty}'`),h.keyword==="additionalProperties"&&h.params.additionalProperty&&h.instancePath&&(h.message=`A 'path' should NOT include property '${h.params.additionalProperty}'`),h.keyword==="type"&&h.params.type&&h.instancePath){let M=h.instancePath.split("/"),z=M[M.length-1];h.message=`Value of property '${z}' must be '${h.params.type}'`}let N=Object.assign(h,b);_.push(N)}),_}};var tN=Efe.instance;tN.addSchema(WNe,"route-configuration.schema.json");tN.addSchema(upt,"policy-configuration.schema.json");tN.addSchema(qNe,"policies.schema.json");tN.addSchema(VNe,"open-api-route-configuration.schema.json");tN.addSchema(lpt,"fragments.schema.json");var Z9r=tN.compile(WNe),Eht=tN.compile(VNe),oFe=tN.compile(qNe);var Dfe=class{static{t(this,"PoliciesConfigurationValidator")}results;validate(s){return this.results=oFe(s),this.results}};var kfe=class{static{t(this,"OpenAPILocalizedValidator")}results;validate(s){return this.results=Eht(s),this.results}};import bgr from"node:path";var cFe=/\$import\((.*)\)/,wfe=/\$env\((.*?)\)/g;var BA=class extends Error{static{t(this,"CodeGenError")}location;constructor(s,l,_,h){super(s),this.location={file:l,namespace:"",line:_?_.line:0,column:_?_.column:0,length:0,lineText:h??"",suggestion:""}}},vgr=t(a=>{let s=[],l=a;for(;l.parent;)s.push(l),l=l.parent;return s.reverse()},"invertTree"),rN=t((a,s)=>{if(!a)return!1;let l=vgr(a);return s.split("/").every((b,D)=>{let N=l[D];return N?b==="*"||OA(N)&&N.name.value===b?!0:b==="{}"?N.type===ec.Object:b==="[]"?N.type===ec.Array:!1:!1})},"testPosition");var Pfe=class{static{t(this,"AstTransformer")}errors=[];transform(s){return this.visitor(s),s}visitor(s){this.visit(s),pj(s)?s.children.forEach(l=>{this.visitor(l)}):apt(s)?s.children.forEach(l=>{this.visitor(l)}):OA(s)&&this.visitor(s.value)}},Dht=t((a,s,l)=>_=>{if(!OA(_)||!dj(_.value)||typeof _.value.value!="string")return;if(!a.some(b=>rN(_,b))){wfe.test(_.value.value)&&s.push(new BA("An $env() statement is not expected at this location.",l,_.location,_.value.value));return}let h=new RegExp(wfe).exec(_.value.value);if(h?.length===2&&h[0]===_.value.value){let b={type:ec.Raw,parent:null,value:`environment["${h[1]}"]`};_.value=b}else{let b=_.value.value.replaceAll(new RegExp(wfe),(D,N)=>`\${environment["${N}"] ? environment["${N}"] : ""}`);b!==_.value.value&&(_.value=MT.createTemplateString(b,_))}},"getEnvStatementTransformer");var vK="config/routes.json",Sgr=["handler/{}/options/*","policies/[]/{}/handler/{}/options/*","corsPolicies/[]/{}/*"],Tgr=["handler/{}/module","handler/{}/options/{}/policies/{}/inbound/[]/{}/module","handler/{}/options/{}/policies/{}/outbound/[]/{}/module","policies/[]/{}/handler/{}/module","policies/[]/{}/handler/{}/options/{}/identifier/{}/module","policies/[]/{}/handler/{}/options/{}/validator"],kht=["handler/{}/options/*","policies/[]/{}/handler/{}/options/*"],xgr="handler/{}/options/{}/rewritePattern",Cgr="handler/{}/options/{}/baseUrl",Afe=class extends Pfe{static{t(this,"OpenAPIRoutesFragmentAstTransformer")}importCount=0;addedImports=new Map;getImportName(s){this.addedImports.has(s)||this.addedImports.set(s,`__import${this.importCount++}`);let l=this.addedImports.get(s);if(!l)throw new Error("Import name is undefined. This should not happen.");return l}getImports(){let s=[];return this.addedImports.forEach((l,_)=>{s.push({name:l,path:_})}),s}visit(s){this.rewriteHandlerFunction(s),this.rewriteForwardFunction(s),this.replaceImportStatements(s),this.replaceEnvStatements(s)}rewriteHandlerFunction(s){if(!(!OA(s)||!dj(s.value)||typeof s.value.value!="string")&&rN(s,xgr)){if(!s.parent||!pj(s.parent)){this.errors.push(new BA("Invalid node, expected object",vK,s.parent?s.parent.location:s.location,void 0));return}let l=s.value.value,_={type:ec.Raw,parent:null,value:wht(l)},h=MT.createProperty("__rewriteFunction",_,s);s.parent.children.push(h)}}rewriteForwardFunction(s){if(!(!OA(s)||!dj(s.value)||typeof s.value.value!="string")&&rN(s,Cgr)){if(!s.parent||!pj(s.parent)){this.errors.push(new BA("Invalid node, expected object",vK,s.parent?s.parent.location:s.location,void 0));return}let l=s.value.value,_={type:ec.Raw,parent:null,value:wht(l)},h=MT.createProperty("__rewriteFunction",_,s);s.parent.children.push(h)}}replaceImportStatements(s){if(!OA(s)||!dj(s.value))return;let l=s.value.value;if(typeof l!="string")return;if(!Tgr.some(N=>rN(s,N))&&!kht.some(N=>rN(s,N))){if(cFe.test(l)){if(s.name.value==="$ref")return;this.errors.push(new BA("An $import() statement is not expected at this location.",vK,s.location,l))}return}let _=cFe.exec(l);if(kht.some(N=>rN(s,N))&&!_)return;if(!_){this.errors.push(new BA("Invalid $import() statement",vK,s.location,l));return}let h=_[1];h=h.replace(/\\/g,"/"),h.startsWith(".")&&(h=bgr.posix.join("..",h));let b=this.getImportName(h),D={type:ec.Identifier,parent:s.parent,value:b};s.value=D}replaceEnvStatements=Dht(Sgr,this.errors,vK)};function wht(a){return`(request, context) => {
582
+ `),exitCode:b},"Untar process logs")}}t(kar,"untarFile");async function war(a){if(await z3e(a))return await B3.rm(a,{recursive:!0})}t(war,"deleteFolder");var ou=J3e;var IT=x_($3e(),1);var oO=class extends Error{static{t(this,"CustomResolveError")}},U3=class{static{t(this,"RefParser")}sourceDirectory;logger;constructor(s,l){this.sourceDirectory=s,this.logger=l}dereference(s,l){return yG.$RefParser.dereference(s,{resolve:{json:!0,file:aue(this.sourceDirectory,this.logger),external:!0,http:!1},dereference:{circular:"ignore",onDereference:l?.onDereference}})}bundle(s){return yG.$RefParser.bundle(s,{resolve:{file:aue(this.sourceDirectory,this.logger),external:!0,http:!1}})}parse(s){return yG.$RefParser.parse(s,{resolve:{file:aue(this.sourceDirectory,this.logger),external:!0,http:!1}})}resolve(s){return yG.$RefParser.resolve(s,{resolve:{file:aue(this.sourceDirectory,this.logger),external:!0,http:!1}})}};function aue(a,s){return{order:100,canRead(l){let _=Iar(l.url);if(!(_===void 0||_==="file"))return!1;let b;try{b=Hut(l.url)}catch(D){throw new oO(`Malformed URI: ${l.url}`,{cause:D})}try{ou.safePath(a).resolve(b)}catch(D){return s?.warn(D),!1}return!0},async read(l){let _;try{_=Hut(l.url)}catch(h){throw new oO(`Malformed URI: ${l.url}`,{cause:h})}try{return await Par(_)}catch(h){throw new oO(`Error opening file "${_}"`,{cause:h})}}}}t(aue,"customResolver");var rj=/^win/.test(globalThis.process?globalThis.process.platform:""),Aar=/\//g,Nar=/^(\w{2,}):\/\//i,q3e=[/%23/g,"#",/%24/g,"$",/%26/g,"&",/%2C/g,",",/%40/g,"@"];function Iar(a){let s=Nar.exec(a);if(s)return s[1].toLowerCase()}t(Iar,"getProtocol");function Hut(a,s){a=decodeURI(a);for(let _=0;_<q3e.length;_+=2)a=a.replace(q3e[_],q3e[_+1]);let l=a.substr(0,7).toLowerCase()==="file://";if(l&&(a=a[7]==="/"?a.substr(8):a.substr(7),rj&&a[1]==="/"&&(a=a[0]+":"+a.substr(1)),s?a="file:///"+a:(l=!1,a=rj?a:"/"+a)),!l){let _=a.split(rj?"\\":"/"),h=[];for(let b of _)b===".."?h.length&&h[h.length-1]!==""&&h.pop():(b!==""||h.length===0)&&h.push(b);a=h.join(rj?"\\":"/"),!rj&&h[0]===""&&(a="/"+a.substring(1))}return rj&&!l&&(a=a.replace(Aar,"\\"),a.substr(1,2)===":\\"&&(a=a[0].toUpperCase()+a.substr(1))),a}t(Hut,"toFileSystemPath");var Gut="YOUR_KEY_HERE";async function Kut(a){let l=await new U3(a.sourceDirectory,a.logger).bundle(a.openApiDocPath),_=a.openApiDocPath.replace(a.sourceDirectory,"");return Far({...a,relativeOpenApiPath:_},l)}t(Kut,"buildPublicOpenApiFile");async function Far(a,s){Mar({relativeOpenApiPath:a.relativeOpenApiPath},s);let l=s;return l=Lar(l),Oar(l,a.deploymentUrl),l=Rar(l,a),Yut(l,"x-zuplo"),l}t(Far,"buildRawOpenApiFile");function Oar(a,s){s?a.servers=[{url:s}]:a.servers=[]}t(Oar,"addServerHost");function Lar(a){if(!a.paths)return a;let{components:s}=a,l=s?{...s}:void 0,_=[];l&&l.parameters&&(_=Object.entries(l.parameters).reduce((b,[D,N])=>(wM in N&&Qce(N[wM])&&(b.push(D),l.parameters&&delete l.parameters[D]),b),[]));let h=Object.entries(a.paths).reduce((b,[D,N])=>{if(!N)return b;let M={...N},z=["delete","get","head","patch","post","put","trace","options"];return z.forEach(ne=>{let ie=N[ne];if(!ie)return;if(Qce(ie[wM])){delete M[ne];return}let{parameters:Q}=ie;if(!Q)return;let Me=Q.filter(Ie=>{if(wM in Ie&&Qce(Ie[wM]))return!1;if("$ref"in Ie){let Pe=Ie.$ref.split("/").pop();return Pe?!_.includes(Pe):!0}return!0});M[ne]={...ie,parameters:Me}}),z.some(ne=>!!M[ne])&&(b[D]=M),b},{});return{...a,paths:h,components:l}}t(Lar,"removeHiddenRoutesAndParams");function Rar(a,{policiesConfig:s}){if(!a.paths)return a;let l=Object.entries(a.paths).reduce((_,[h,b])=>{if(!b)return _;let D={...b};return[D.delete,D.get,D.head,D.patch,D.post,D.put,D.trace,D.options].forEach(N=>{if(!N)return;let M=N["x-zuplo-route"]?.policies?.inbound?.reduce((ie,Q)=>{let Me=s.policies?.find(({name:Pt})=>Pt===Q);if(!Me)return ie;if(!(Me.handler.export==="CompositeInboundPolicy"))return ie.concat(Q);let Pe=Me.handler.options?.policies;return Pe?ie.concat(Pe):ie},[]),z=[];if(M&&M.forEach(ie=>{s.policies?.forEach(Q=>{Q.name===ie&&(Q.handler.export==="ApiAuthKeyInboundPolicy"||Q.handler.export==="ApiKeyInboundPolicy")&&!Q.handler.options?.disableAutomaticallyAddingKeyHeaderToOpenApi&&z.push(Q)})}),z.length>0){let ie=z.length>0&&z[0].handler&&z[0].handler.options&&z[0].handler.options.authHeader?z[0].handler.options.authHeader:"Authorization",Q=z.length>0&&z[0].handler&&z[0].handler.options&&(z[0].handler.options.authScheme||z[0].handler.options.authScheme==="")?z[0].handler.options.authScheme:"Bearer",Me=Q!==""?`${Q} ${Gut}`:Gut,Ie={name:ie,in:"header",required:!0,example:Me,schema:{type:"string"},description:`The \`${ie}\` header is used to authenticate with the API using your API key. Value is of the format \`${Me}\`.`};N.parameters?N.parameters.some(Tr=>"name"in Tr&&Tr.name===Ie.name)||N.parameters.unshift(Ie):N.parameters=[Ie];let Pe={type:"http",scheme:Q.toLowerCase()},Pt="api_key";a.components?.securitySchemes?Object.values(a.components?.securitySchemes).some(Tr=>"name"in Tr&&Tr.type==="apiKey"||"type"in Tr&&Tr.type==="http"&&Tr.scheme===Q)||(a.components.securitySchemes={...a.components.securitySchemes,[Pt]:Pe}):(a.components||(a.components={}),a.components.securitySchemes={[Pt]:Pe});let xt={[Pt]:[]};N.security?N.security.some(Tr=>Tr[Pt]!==void 0)||N.security.unshift(xt):N.security=[xt]}let ne=[];if(M&&M.forEach(ie=>{s.policies?.forEach(Q=>{Q.name===ie&&(Q.handler.export==="RateLimitInboundPolicy"||Q.handler.export==="ComplexRateLimitInboundPolicy")&&ne.push(Q)})}),ne.length>0){let ie={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"}}}}}},Q={...ie,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:ie,RateLimitWithRetryAfter:Q},N.responses||(N.responses={});let Me=ne.some(Ie=>Ie.handler.options?.headerMode!=="none");N.responses[429]||(N.responses[429]={$ref:Me?"#/components/responses/RateLimitWithRetryAfter":"#/components/responses/RateLimitNoRetryAfter"})}}),_[h]=D,_},{});return{...a,paths:l}}t(Rar,"enrichSpecWithZuploData");function Yut(a,s){for(let l in a)l.startsWith(s)?delete a[l]:typeof a[l]=="object"&&Yut(a[l],s)}t(Yut,"removePropertiesByPrefix");function Mar({relativeOpenApiPath:a},s){if(!s||typeof s!="object")throw new z1({message:"The OpenAPI Document could not be parsed.",severity:"error"});if(!("info"in s)||typeof s.info!="object"||!s.info)throw new z1({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 z1({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(Mar,"assertIsZuploOpenApiSpec");import bK from"node:path";function jar(a){if(a.length>=255)throw new TypeError("Alphabet too long");let s=new Uint8Array(256);for(let z=0;z<s.length;z++)s[z]=255;for(let z=0;z<a.length;z++){let ne=a.charAt(z),ie=ne.charCodeAt(0);if(s[ie]!==255)throw new TypeError(ne+" is ambiguous");s[ie]=z}let l=a.length,_=a.charAt(0),h=Math.log(l)/Math.log(256),b=Math.log(256)/Math.log(l);function D(z){if(z instanceof Uint8Array||(ArrayBuffer.isView(z)?z=new Uint8Array(z.buffer,z.byteOffset,z.byteLength):Array.isArray(z)&&(z=Uint8Array.from(z))),!(z instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(z.length===0)return"";let ne=0,ie=0,Q=0,Me=z.length;for(;Q!==Me&&z[Q]===0;)Q++,ne++;let Ie=(Me-Q)*b+1>>>0,Pe=new Uint8Array(Ie);for(;Q!==Me;){let Tr=z[Q],cn=0;for(let tn=Ie-1;(Tr!==0||cn<ie)&&tn!==-1;tn--,cn++)Tr+=256*Pe[tn]>>>0,Pe[tn]=Tr%l>>>0,Tr=Tr/l>>>0;if(Tr!==0)throw new Error("Non-zero carry");ie=cn,Q++}let Pt=Ie-ie;for(;Pt!==Ie&&Pe[Pt]===0;)Pt++;let xt=_.repeat(ne);for(;Pt<Ie;++Pt)xt+=a.charAt(Pe[Pt]);return xt}t(D,"encode");function N(z){if(typeof z!="string")throw new TypeError("Expected String");if(z.length===0)return new Uint8Array;let ne=0,ie=0,Q=0;for(;z[ne]===_;)ie++,ne++;let Me=(z.length-ne)*h+1>>>0,Ie=new Uint8Array(Me);for(;z[ne];){let Tr=s[z.charCodeAt(ne)];if(Tr===255)return;let cn=0;for(let tn=Me-1;(Tr!==0||cn<Q)&&tn!==-1;tn--,cn++)Tr+=l*Ie[tn]>>>0,Ie[tn]=Tr%256>>>0,Tr=Tr/256>>>0;if(Tr!==0)throw new Error("Non-zero carry");Q=cn,ne++}let Pe=Me-Q;for(;Pe!==Me&&Ie[Pe]===0;)Pe++;let Pt=new Uint8Array(ie+(Me-Pe)),xt=ie;for(;Pe!==Me;)Pt[xt++]=Ie[Pe++];return Pt}t(N,"decodeUnsafe");function M(z){let ne=N(z);if(ne)return ne;throw new Error("Non-base"+l+" character")}return t(M,"decode"),{encode:D,decodeUnsafe:N,decode:M}}t(jar,"base");var Xut=jar;var Bar="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",oue=Xut(Bar);var V3e="2025-02-06",Qut=Object.freeze({none:{runOutboundPoliciesOnHandlerOnAllStatuses:!1,doNotRunHooksOnSystemRoutes:!1,removeAllVendorHeadersExceptListed:!1,allowCustomPorts:!1,removeLegacyLogInitialization:!1,useForwardRedirectsPropOnUrlForwardHandler:!1},"2023-03-14":{runOutboundPoliciesOnHandlerOnAllStatuses:!1,doNotRunHooksOnSystemRoutes:!1,removeAllVendorHeadersExceptListed:!1,allowCustomPorts:!1,removeLegacyLogInitialization:!1,useForwardRedirectsPropOnUrlForwardHandler:!1},"2024-01-15":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!1,removeLegacyLogInitialization:!1,useForwardRedirectsPropOnUrlForwardHandler:!1},"2024-03-14":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!1,removeLegacyLogInitialization:!1,useForwardRedirectsPropOnUrlForwardHandler:!1},"2024-09-02":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!0,removeLegacyLogInitialization:!1,useForwardRedirectsPropOnUrlForwardHandler:!1},"2025-02-06":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!0,removeLegacyLogInitialization:!0,useForwardRedirectsPropOnUrlForwardHandler:!0}});function Zut(){return new V2({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:V3e,ENVIRONMENT_TYPE:"mock-environment-type",GIT_SHA:void 0,IS_LOCAL_DEVELOPMENT:!1,COMPATIBILITY_FLAGS:Qut[V3e]},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(Zut,"getMockEnvironment");var V2=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=Zut()),this.#r}constructor({build:s,runtime:l}){let _;try{if(l.ZUPLO_SYSTEM_CONFIGURATIONS){let h=new TextDecoder().decode(oue.decode(l.ZUPLO_SYSTEM_CONFIGURATIONS)),b=JSON.parse(h);for(let D of Object.keys(b))l[D]||(l[D]=b[D])}if(l.__ZUPLO_CONFIG){let h=atob(l.__ZUPLO_CONFIG);_=JSON.parse(h)}}catch(h){console.error("Failed to parse runtime configuration",h)}this.config=_??{},this.build=s,this.runtime=l,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 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 Uar=["ZUPLO_USER_LOGGER_DATA_DOG_API_KEY","ZUPLO_USER_LOGGER_DATA_DOG_URL","ZUPLO_LOG_LEVEL","ZUPLO_HANDLER_WRITE_LOG_LEVEL"];function eft(a){return a.startsWith("__ZUPLO")||a.startsWith("ZUPLO_")?!Uar.includes(a)&&!a.startsWith("ZUPLO_PUBLIC_"):!1}t(eft,"isRestrictedEnvVariableName");function tft(a){return!!a.startsWith("ZUPLO_")}t(tft,"isZuploReadableEnvVariableName");var eFr=new Proxy({},{get(a,s){let l=String(s);switch(l){case"ZUPLO_ENVIRONMENT_TYPE":return V2.instance.loggingEnvironmentType;case"ZUPLO_ENVIRONMENT_STAGE":return V2.instance.loggingEnvironmentStage;case"ZUPLO_ENVIRONMENT_NAME":return V2.instance.runtime.__ZUPLO_DEPLOYMENT_NAME;case"ZUPLO_ACCOUNT_NAME":return V2.instance.build.ACCOUNT_NAME;case"ZUPLO_PROJECT_NAME":return V2.instance.build.PROJECT_NAME;case"ZUPLO_BUILD_ID":return V2.instance.build.BUILD_ID;case"ZUPLO_COMPATIBILITY_DATE":return V2.instance.build.COMPATIBILITY_DATE}if(!(eft(l)&&!tft(l)))return V2.instance.runtime[l]}});function vG(a,s,l){return`_${kA(`${a}_${s}_${l}`)}`}t(vG,"getRawOperationDataIdentifierName");function W3e(a,s,l,_){return`_${kA(a.toLowerCase())}_${s.toLowerCase()}_${l.toLowerCase()}_${_.toLowerCase()}`}t(W3e,"getIdForParameterSchema");function H3e(a,s,l){return`_${kA(a.toLowerCase())}_${s.toLowerCase()}_rb_${kA(l.toLowerCase())}`}t(H3e,"getIdForRequestBodySchema");function bG(a,s){return`_${kA(a)}_${kA(s)}`}t(bG,"getIdForRefSchema");function kA(a){let s=a.replace(/\[/g,"_LBRACKET_").replace(/\]/g,"_RBRACKET_").replace(/\{/g,"_LCURLY_").replace(/\}/g,"_RCURLY_").replace(/\//g,"_SLASH_").replace(/-/g,"_DASH_").replace(/\./g,"_DOT_").replace(/\+/g,"_PLUS_").replace(/:/g,"_COLON_").replace(/@/g,"_AT_").replace(/\$/g,"_DOLLAR_").replace(/[^a-zA-Z0-9_]/g,"_");return/^[a-zA-Z_]/.test(s)||(s="_"+s),s}t(kA,"sanitizedIdentifierName");var Fht=x_(V_t(),1);var RG=class{static{t(this,"R")}type=3;name="";prefix="";value="";suffix="";modifier=3;constructor(a,s,l,_,h,b){this.type=a,this.name=s,this.prefix=l,this.value=_,this.suffix=h,this.modifier=b}hasCustomName(){return this.name!==""&&typeof this.name!="number"}},Flr=/[$_\p{ID_Start}]/u,Olr=/[$_\u200C\u200D\p{ID_Continue}]/u,$Ne=".*";function Llr(a,s){return(s?/^[\x00-\xFF]*$/:/^[\x00-\x7F]*$/).test(a)}t(Llr,"Re");function G_t(a,s=!1){let l=[],_=0;for(;_<a.length;){let h=a[_],b=t(function(D){if(!s)throw new TypeError(D);l.push({type:"INVALID_CHAR",index:_,value:a[_++]})},"c");if(h==="*"){l.push({type:"ASTERISK",index:_,value:a[_++]});continue}if(h==="+"||h==="?"){l.push({type:"OTHER_MODIFIER",index:_,value:a[_++]});continue}if(h==="\\"){l.push({type:"ESCAPED_CHAR",index:_++,value:a[_++]});continue}if(h==="{"){l.push({type:"OPEN",index:_,value:a[_++]});continue}if(h==="}"){l.push({type:"CLOSE",index:_,value:a[_++]});continue}if(h===":"){let D="",N=_+1;for(;N<a.length;){let M=a.substr(N,1);if(N===_+1&&Flr.test(M)||N!==_+1&&Olr.test(M)){D+=a[N++];continue}break}if(!D){b(`Missing parameter name at ${_}`);continue}l.push({type:"NAME",index:_,value:D}),_=N;continue}if(h==="("){let D=1,N="",M=_+1,z=!1;if(a[M]==="?"){b(`Pattern cannot start with "?" at ${M}`);continue}for(;M<a.length;){if(!Llr(a[M],!1)){b(`Invalid character '${a[M]}' at ${M}.`),z=!0;break}if(a[M]==="\\"){N+=a[M++]+a[M++];continue}if(a[M]===")"){if(D--,D===0){M++;break}}else if(a[M]==="("&&(D++,a[M+1]!=="?")){b(`Capturing groups are not allowed at ${M}`),z=!0;break}N+=a[M++]}if(z)continue;if(D){b(`Unbalanced pattern at ${_}`);continue}if(!N){b(`Missing pattern at ${_}`);continue}l.push({type:"REGEX",index:_,value:N}),_=M;continue}l.push({type:"CHAR",index:_,value:a[_++]})}return l.push({type:"END",index:_,value:""}),l}t(G_t,"v");function K_t(a,s={}){let l=G_t(a);s.delimiter??="/#?",s.prefixes??="./";let _=`[^${RT(s.delimiter)}]+?`,h=[],b=0,D=0,N="",M=new Set,z=t(cn=>{if(D<l.length&&l[D].type===cn)return l[D++].value},"a"),ne=t(()=>z("OTHER_MODIFIER")??z("ASTERISK"),"f"),ie=t(cn=>{let tn=z(cn);if(tn!==void 0)return tn;let{type:ln,index:Cr}=l[D];throw new TypeError(`Unexpected ${ln} at ${Cr}, expected ${cn}`)},"d"),Q=t(()=>{let cn="",tn;for(;tn=z("CHAR")??z("ESCAPED_CHAR");)cn+=tn;return cn},"T"),Me=t(cn=>cn,"Se"),Ie=s.encodePart||Me,Pe="",Pt=t(cn=>{Pe+=cn},"U"),xt=t(()=>{Pe.length&&(h.push(new RG(3,"","",Ie(Pe),"",3)),Pe="")},"$"),Tr=t((cn,tn,ln,Cr,vr)=>{let fs=3;switch(vr){case"?":fs=1;break;case"*":fs=0;break;case"+":fs=2;break}if(!tn&&!ln&&fs===3){Pt(cn);return}if(xt(),!tn&&!ln){if(!cn)return;h.push(new RG(3,"","",Ie(cn),"",fs));return}let Fi;ln?ln==="*"?Fi=$Ne:Fi=ln:Fi=_;let Ho=2;Fi===_?(Ho=1,Fi=""):Fi===$Ne&&(Ho=0,Fi="");let di;if(tn?di=tn:ln&&(di=b++),M.has(di))throw new TypeError(`Duplicate name '${di}'.`);M.add(di),h.push(new RG(Ho,di,Ie(cn),Fi,Ie(Cr),fs))},"V");for(;D<l.length;){let cn=z("CHAR"),tn=z("NAME"),ln=z("REGEX");if(!tn&&!ln&&(ln=z("ASTERISK")),tn||ln){let vr=cn??"";s.prefixes.indexOf(vr)===-1&&(Pt(vr),vr=""),xt();let fs=ne();Tr(vr,tn,ln,"",fs);continue}let Cr=cn??z("ESCAPED_CHAR");if(Cr){Pt(Cr);continue}if(z("OPEN")){let vr=Q(),fs=z("NAME"),Fi=z("REGEX");!fs&&!Fi&&(Fi=z("ASTERISK"));let Ho=Q();ie("CLOSE");let di=ne();Tr(vr,fs,Fi,Ho,di);continue}xt(),ie("END")}return h}t(K_t,"D");function RT(a){return a.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}t(RT,"S");function W_t(a){return a&&a.ignoreCase?"ui":"u"}t(W_t,"X");function Rlr(a,s,l){return Y_t(K_t(a,l),s,l)}t(Rlr,"Z");function _j(a){switch(a){case 0:return"*";case 1:return"?";case 2:return"+";case 3:return""}}t(_j,"k");function Y_t(a,s,l={}){l.delimiter??="/#?",l.prefixes??="./",l.sensitive??=!1,l.strict??=!1,l.end??=!0,l.start??=!0,l.endsWith="";let _=l.start?"^":"";for(let N of a){if(N.type===3){N.modifier===3?_+=RT(N.value):_+=`(?:${RT(N.value)})${_j(N.modifier)}`;continue}s&&s.push(N.name);let M=`[^${RT(l.delimiter)}]+?`,z=N.value;if(N.type===1?z=M:N.type===0&&(z=$Ne),!N.prefix.length&&!N.suffix.length){N.modifier===3||N.modifier===1?_+=`(${z})${_j(N.modifier)}`:_+=`((?:${z})${_j(N.modifier)})`;continue}if(N.modifier===3||N.modifier===1){_+=`(?:${RT(N.prefix)}(${z})${RT(N.suffix)})`,_+=_j(N.modifier);continue}_+=`(?:${RT(N.prefix)}`,_+=`((?:${z})(?:`,_+=RT(N.suffix),_+=RT(N.prefix),_+=`(?:${z}))*)${RT(N.suffix)})`,N.modifier===0&&(_+="?")}let h=`[${RT(l.endsWith)}]|$`,b=`[${RT(l.delimiter)}]`;if(l.end)return l.strict||(_+=`${b}?`),l.endsWith.length?_+=`(?=${h})`:_+="$",new RegExp(_,W_t(l));l.strict||(_+=`(?:${b}(?=${h}))?`);let D=!1;if(a.length){let N=a[a.length-1];N.type===3&&N.modifier===3&&(D=l.delimiter.indexOf(N)>-1)}return D||(_+=`(?=${b}|${h})`),new RegExp(_,W_t(l))}t(Y_t,"F");var q3={delimiter:"",prefixes:"",sensitive:!0,strict:!0},Mlr={delimiter:".",prefixes:"",sensitive:!0,strict:!0},jlr={delimiter:"/",prefixes:"/",sensitive:!0,strict:!0};function Blr(a,s){return a.length?a[0]==="/"?!0:!s||a.length<2?!1:(a[0]=="\\"||a[0]=="{")&&a[1]=="/":!1}t(Blr,"J");function X_t(a,s){return a.startsWith(s)?a.substring(s.length,a.length):a}t(X_t,"Q");function Ulr(a,s){return a.endsWith(s)?a.substr(0,a.length-s.length):a}t(Ulr,"Ee");function Q_t(a){return!a||a.length<2?!1:a[0]==="["||(a[0]==="\\"||a[0]==="{")&&a[1]==="["}t(Q_t,"W");var Z_t=["ftp","file","http","https","ws","wss"];function ept(a){if(!a)return!0;for(let s of Z_t)if(a.test(s))return!0;return!1}t(ept,"N");function $lr(a,s){if(a=X_t(a,"#"),s||a==="")return a;let l=new URL("https://example.com");return l.hash=a,l.hash?l.hash.substring(1,l.hash.length):""}t($lr,"te");function zlr(a,s){if(a=X_t(a,"?"),s||a==="")return a;let l=new URL("https://example.com");return l.search=a,l.search?l.search.substring(1,l.search.length):""}t(zlr,"re");function Jlr(a,s){return s||a===""?a:Q_t(a)?npt(a):rpt(a)}t(Jlr,"ne");function qlr(a,s){if(s||a==="")return a;let l=new URL("https://example.com");return l.password=a,l.password}t(qlr,"se");function Vlr(a,s){if(s||a==="")return a;let l=new URL("https://example.com");return l.username=a,l.username}t(Vlr,"ie");function Wlr(a,s,l){if(l||a==="")return a;if(s&&!Z_t.includes(s))return new URL(`${s}:${a}`).pathname;let _=a[0]=="/";return a=new URL(_?a:"/-"+a,"https://example.com").pathname,_||(a=a.substring(2,a.length)),a}t(Wlr,"ae");function Hlr(a,s,l){return tpt(s)===a&&(a=""),l||a===""?a:ipt(a)}t(Hlr,"oe");function Glr(a,s){return a=Ulr(a,":"),s||a===""?a:zNe(a)}t(Glr,"ce");function tpt(a){switch(a){case"ws":case"http":return"80";case"wws":case"https":return"443";case"ftp":return"21";default:return""}}t(tpt,"_");function zNe(a){if(a==="")return a;if(/^[-+.A-Za-z0-9]*$/.test(a))return a.toLowerCase();throw new TypeError(`Invalid protocol '${a}'.`)}t(zNe,"y");function Klr(a){if(a==="")return a;let s=new URL("https://example.com");return s.username=a,s.username}t(Klr,"le");function Ylr(a){if(a==="")return a;let s=new URL("https://example.com");return s.password=a,s.password}t(Ylr,"fe");function rpt(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(rpt,"z");function npt(a){if(a==="")return a;if(/[^0-9a-fA-F[\]:]/g.test(a))throw new TypeError(`Invalid IPv6 hostname '${a}'`);return a.toLowerCase()}t(npt,"j");function ipt(a){if(a===""||/^[0-9]*$/.test(a)&&parseInt(a)<=65535)return a;throw new TypeError(`Invalid port '${a}'.`)}t(ipt,"K");function Xlr(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(Xlr,"he");function Qlr(a){return a===""?a:new URL(`data:${a}`).pathname}t(Qlr,"ue");function Zlr(a){if(a==="")return a;let s=new URL("https://example.com");return s.search=a,s.search.substring(1,s.search.length)}t(Zlr,"de");function eur(a){if(a==="")return a;let s=new URL("https://example.com");return s.hash=a,s.hash.substring(1,s.hash.length)}t(eur,"pe");var tur=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=G_t(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.#w()){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.#E()?(a=2,s=3):this.#l&&(a=2),this.#i(a,s)}break;case 2:this.#x()?this.#d(3):(this.#C()||this.#y()||this.#D())&&this.#d(5);break;case 3:this.#b()?this.#i(4,1):this.#x()&&this.#i(5,1);break;case 4:this.#x()&&this.#i(5,1);break;case 5:this.#N()?this.#c+=1:this.#S()&&(this.#c-=1),this.#k()&&!this.#c?this.#i(6,1):this.#C()?this.#i(7,0):this.#y()?this.#i(8,1):this.#D()&&this.#i(9,1);break;case 6:this.#C()?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 l=this.#u(a);return l.value===s&&(l.type==="CHAR"||l.type==="ESCAPED_CHAR"||l.type==="INVALID_CHAR")}#g(){return this.#m(this.#t,":")}#E(){return this.#m(this.#t+1,"/")&&this.#m(this.#t+2,"/")}#x(){return this.#m(this.#t,"@")}#b(){return this.#m(this.#t,":")}#k(){return this.#m(this.#t,":")}#C(){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,"#")}#w(){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,q3),a.encodePart=zNe;let s=Rlr(this.#T(),void 0,a);this.#l=ept(s)}},UNe=["protocol","username","password","hostname","port","pathname","search","hash"],J3="*";function H_t(a,s){if(typeof a!="string")throw new TypeError("parameter 1 is not of type 'string'.");let l=new URL(a,s);return{protocol:l.protocol.substring(0,l.protocol.length-1),username:l.username,password:l.password,hostname:l.hostname,port:l.port,pathname:l.pathname,search:l.search!==""?l.search.substring(1,l.search.length):void 0,hash:l.hash!==""?l.hash.substring(1,l.hash.length):void 0}}t(H_t,"ge");function IA(a,s){return s?LG(a):a}t(IA,"b");function OG(a,s,l){let _;if(typeof s.baseURL=="string")try{_=new URL(s.baseURL),s.protocol===void 0&&(a.protocol=IA(_.protocol.substring(0,_.protocol.length-1),l)),!l&&s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.username===void 0&&(a.username=IA(_.username,l)),!l&&s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.username===void 0&&s.password===void 0&&(a.password=IA(_.password,l)),s.protocol===void 0&&s.hostname===void 0&&(a.hostname=IA(_.hostname,l)),s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&(a.port=IA(_.port,l)),s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.pathname===void 0&&(a.pathname=IA(_.pathname,l)),s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.pathname===void 0&&s.search===void 0&&(a.search=IA(_.search.substring(1,_.search.length),l)),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=IA(_.hash.substring(1,_.hash.length),l))}catch{throw new TypeError(`invalid baseURL '${s.baseURL}'.`)}if(typeof s.protocol=="string"&&(a.protocol=Glr(s.protocol,l)),typeof s.username=="string"&&(a.username=Vlr(s.username,l)),typeof s.password=="string"&&(a.password=qlr(s.password,l)),typeof s.hostname=="string"&&(a.hostname=Jlr(s.hostname,l)),typeof s.port=="string"&&(a.port=Hlr(s.port,a.protocol,l)),typeof s.pathname=="string"){if(a.pathname=s.pathname,_&&!Blr(a.pathname,l)){let h=_.pathname.lastIndexOf("/");h>=0&&(a.pathname=IA(_.pathname.substring(0,h+1),l)+a.pathname)}a.pathname=Wlr(a.pathname,a.protocol,l)}return typeof s.search=="string"&&(a.search=zlr(s.search,l)),typeof s.hash=="string"&&(a.hash=$lr(s.hash,l)),a}t(OG,"w");function LG(a){return a.replace(/([+*?:{}()\\])/g,"\\$1")}t(LG,"C");function rur(a){return a.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}t(rur,"Oe");function nur(a,s){s.delimiter??="/#?",s.prefixes??="./",s.sensitive??=!1,s.strict??=!1,s.end??=!0,s.start??=!0,s.endsWith="";let l=".*",_=`[^${rur(s.delimiter)}]+?`,h=/[$_\u200C\u200D\p{ID_Continue}]/u,b="";for(let D=0;D<a.length;++D){let N=a[D];if(N.type===3){if(N.modifier===3){b+=LG(N.value);continue}b+=`{${LG(N.value)}}${_j(N.modifier)}`;continue}let M=N.hasCustomName(),z=!!N.suffix.length||!!N.prefix.length&&(N.prefix.length!==1||!s.prefixes.includes(N.prefix)),ne=D>0?a[D-1]:null,ie=D<a.length-1?a[D+1]:null;if(!z&&M&&N.type===1&&N.modifier===3&&ie&&!ie.prefix.length&&!ie.suffix.length)if(ie.type===3){let Q=ie.value.length>0?ie.value[0]:"";z=h.test(Q)}else z=!ie.hasCustomName();if(!z&&!N.prefix.length&&ne&&ne.type===3){let Q=ne.value[ne.value.length-1];z=s.prefixes.includes(Q)}z&&(b+="{"),b+=LG(N.prefix),M&&(b+=`:${N.name}`),N.type===2?b+=`(${N.value})`:N.type===1?M||(b+=`(${_})`):N.type===0&&(!M&&(!ne||ne.type===3||ne.modifier!==3||z||N.prefix!=="")?b+="*":b+=`(${l})`),N.type===1&&M&&N.suffix.length&&h.test(N.suffix[0])&&(b+="\\"),b+=LG(N.suffix),z&&(b+="}"),N.modifier!==3&&(b+=_j(N.modifier))}return b}t(nur,"ke");var spt=class{static{t(this,"me")}#r;#n={};#e={};#t={};#s={};#p=!1;constructor(a={},s,l){try{let _;if(typeof s=="string"?_=s:l=s,typeof a=="string"){let N=new tur(a);if(N.parse(),a=N.result,_===void 0&&typeof a.protocol!="string")throw new TypeError("A base URL must be provided for a relative constructor string.");a.baseURL=_}else{if(!a||typeof a!="object")throw new TypeError("parameter 1 is not of type 'string' and cannot convert to dictionary.");if(_)throw new TypeError("parameter 1 is not of type 'string'.")}typeof l>"u"&&(l={ignoreCase:!1});let h={ignoreCase:l.ignoreCase===!0},b={pathname:J3,protocol:J3,username:J3,password:J3,hostname:J3,port:J3,search:J3,hash:J3};this.#r=OG(b,a,!0),tpt(this.#r.protocol)===this.#r.port&&(this.#r.port="");let D;for(D of UNe){if(!(D in this.#r))continue;let N={},M=this.#r[D];switch(this.#e[D]=[],D){case"protocol":Object.assign(N,q3),N.encodePart=zNe;break;case"username":Object.assign(N,q3),N.encodePart=Klr;break;case"password":Object.assign(N,q3),N.encodePart=Ylr;break;case"hostname":Object.assign(N,Mlr),Q_t(M)?N.encodePart=npt:N.encodePart=rpt;break;case"port":Object.assign(N,q3),N.encodePart=ipt;break;case"pathname":ept(this.#n.protocol)?(Object.assign(N,jlr,h),N.encodePart=Xlr):(Object.assign(N,q3,h),N.encodePart=Qlr);break;case"search":Object.assign(N,q3,h),N.encodePart=Zlr;break;case"hash":Object.assign(N,q3,h),N.encodePart=eur;break}try{this.#s[D]=K_t(M,N),this.#n[D]=Y_t(this.#s[D],this.#e[D],N),this.#t[D]=nur(this.#s[D],N),this.#p=this.#p||this.#s[D].some(z=>z.type===2)}catch{throw new TypeError(`invalid ${D} pattern '${this.#r[D]}'.`)}}}catch(_){throw new TypeError(`Failed to construct 'URLPattern': ${_.message}`)}}test(a={},s){let l={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"?l=OG(l,a,!1):l=OG(l,H_t(a,s),!1)}catch{return!1}let _;for(_ of UNe)if(!this.#n[_].exec(l[_]))return!1;return!0}exec(a={},s){let l={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"?l=OG(l,a,!1):l=OG(l,H_t(a,s),!1)}catch{return null}let _={};s?_.inputs=[a,s]:_.inputs=[a];let h;for(h of UNe){let b=this.#n[h].exec(l[h]);if(!b)return null;let D={};for(let[N,M]of this.#e[h].entries())if(typeof M=="string"||typeof M=="number"){let z=b[N+1];D[M]=z}_[h]={input:l[h]??"",groups:D}}return _}static compareComponent(a,s,l){let _=t((N,M)=>{for(let z of["type","modifier","prefix","value","suffix"]){if(N[z]<M[z])return-1;if(N[z]!==M[z])return 1}return 0},"o"),h=new RG(3,"","","","",3),b=new RG(0,"","","","",3),D=t((N,M)=>{let z=0;for(;z<Math.min(N.length,M.length);++z){let ne=_(N[z],M[z]);if(ne)return ne}return N.length===M.length?0:_(N[z]??h,M[z]??h)},"s");return!s.#t[a]&&!l.#t[a]?0:s.#t[a]&&!l.#t[a]?D(s.#s[a],[b]):!s.#t[a]&&l.#t[a]?D([b],l.#s[a]):D(s.#s[a],l.#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=spt);import{AssertionError as iur}from"node:assert";function FA(a,s){if(a===!1)throw new iur({message:s})}t(FA,"assert");var ec;(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"})(ec||(ec={}));function pj(a){return a.type===ec.Object}t(pj,"isAstObject");function OA(a){return a.type===ec.Property}t(OA,"isAstProperty");function apt(a){return a.type===ec.Array}t(apt,"isAstArray");function dj(a){return a.type===ec.Literal}t(dj,"isAstLiteral");function V3(a){if(a===void 0)throw new Error("Node is undefined");if(!pj(a))throw new Error("Node is not object")}t(V3,"assertAstObject");import{findNodeAtLocation as sur,getNodeValue as aur,printParseErrorCode as our,visit as cur}from"jsonc-parser";var lur={DEFAULT:{allowTrailingComma:!1}};function MG(a,s=[],l=lur.DEFAULT){let _={type:"array",offset:-1,length:-1,line:-1,column:-1,children:[],parent:void 0};function h(M){_.type==="property"&&(_.length=M-_.offset,_=_.parent)}t(h,"ensurePropertyComplete");function b(M){return _.children?.push(M),M}t(b,"onValue"),cur(a,{onObjectBegin:t((M,z,ne)=>{_=b({type:"object",offset:M,length:-1,line:z+1,column:ne+1,parent:_,children:[]})},"onObjectBegin"),onObjectProperty:t((M,z,ne,ie,Q)=>{_=b({type:"property",offset:z,length:-1,line:ie+1,column:Q+1,parent:_,children:[]}),_.children?.push({type:"string",value:M,offset:z,length:ne,line:ie,column:Q,parent:_})},"onObjectProperty"),onObjectEnd:t((M,z)=>{h(M+z),_.length=M+z-_.offset,_=_.parent,h(M+z)},"onObjectEnd"),onArrayBegin:t((M,z,ne,ie)=>{_=b({type:"array",offset:M,length:-1,line:ne+1,column:ie+1,parent:_,children:[]})},"onArrayBegin"),onArrayEnd:t((M,z)=>{_.length=M+z-_.offset,_=_.parent,h(M+z)},"onArrayEnd"),onLiteralValue:t((M,z,ne,ie,Q)=>{b({type:uur(M),offset:z,length:ne,line:ie+1,column:Q+1,parent:_,value:M}),h(z+ne)},"onLiteralValue"),onSeparator:t((M,z)=>{_.type==="property"&&(M===":"?_.colonOffset=z:M===","&&h(z))},"onSeparator"),onError:t((M,z,ne,ie,Q)=>{s.push({error:M,offset:z,length:ne,line:ie+1,column:Q+1})},"onError")},l);let N=_.children[0];return N&&delete N.parent,N}t(MG,"parse");function uur(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(uur,"getNodeType");function JNe(a,s){return sur(a,s)}t(JNe,"findNodeAtLocation");function jG(a){return aur(a)}t(jG,"getNodeValue");function opt(a){return our(a)}t(opt,"printParseErrorCode");var BG=class{static{t(this,"AstAdapter")}parse(s){let _=MG(s,[]);if(_)return this.parseNode(_,void 0);throw new Error("Failed to parse JSON")}convert(s){return this.parseNode(s,void 0)}parseNode(s,l){switch(s.type){case"object":return this.createObject(s,l);case"array":return this.createArray(s,l);case"property":return this.createProperty(s,l);case"string":return this.createLiteral(s,l);case"number":return this.createLiteral(s,l);case"boolean":return this.createLiteral(s,l);case"null":return this.createLiteral(s,l)}}createLiteral(s,l){return{type:ec.Literal,location:{line:s.line,column:s.column},parent:l,value:s.type==="null"?null:s.value}}createObject(s,l){let _={type:ec.Object,children:[],parent:l,location:{line:s.line,column:s.column}};return s.children?.forEach(h=>{_.children.push(this.parseNode(h,_))}),_}createProperty(s,l){FA(s.children?.length===2,"Invalid property node");let _={type:ec.Property,location:{line:s.line,column:s.column},parent:l,name:null,value:null};return _.name={value:s.children[0].value,location:{line:s.line,column:s.column},type:ec.Identifier,parent:_},_.value=this.parseNode(s.children[1],_),_}createArray(s,l){let _={type:ec.Array,location:{line:s.line,column:s.column},parent:l,children:[]};return s.children?.forEach(h=>_.children.push(this.parseNode(h,_))),_}};var MT={createLiteral:t((a,s)=>({type:ec.Literal,parent:s,value:a}),"createLiteral"),createTemplateString:t((a,s)=>({type:ec.TemplateString,parent:s,value:a}),"createTemplateString"),createIdentifier:t((a,s)=>({type:ec.Identifier,value:a,parent:s}),"createIdentifier"),createProperty:t((a,s,l)=>{let _={type:ec.Property,parent:l,name:null,value:s};return _.name={value:a,type:ec.Identifier,parent:_},_.value.parent=_,_},"createProperty"),createArrayOfLiterals:t((a,s)=>{let l={type:ec.Array,parent:s,children:[]};for(let _ of a)l.children.push(MT.createLiteral(_,l));return l},"createArrayOfLiterals")};var fur=/^[a-zA-Z_$][a-zA-Z0-9_$]*$/,UG=class{static{t(this,"SourceGenerator")}generate(s){let l=[];return this.generateSource(l,s),l.join("")}generateSource(s,l){switch(l.type){case ec.Array:return this.generateArray(s,l);case ec.Object:return this.generateObject(s,l);case ec.Property:return this.generateProperty(s,l);case ec.Literal:return this.generateLiteral(s,l);case ec.FunctionCall:return this.generateFunctionCall(s,l);case ec.Identifier:return this.generateIdentifier(s,l);case ec.Raw:return this.generateRaw(s,l);case ec.TemplateString:return this.generateTemplateString(s,l)}}generateArray(s,l){s.push("["),l.children.map(_=>{this.generateSource(s,_),s.push(",")}),s.push("]")}generateObject(s,l){s.push("{"),l.children.forEach(_=>{this.generateSource(s,_),s.push(",")}),s.push("}")}generateProperty(s,l){this.generateIdentifier(s,l.name),s.push(":"),this.generateSource(s,l.value)}generateFunctionCall(s,l){s.push(l.name.value),s.push("("),l.children.forEach((_,h,b)=>{this.generateSource(s,_),h<b.length&&s.push(",")}),s.push(")")}generateRaw(s,l){s.push(l.value)}generateTemplateString(s,l){s.push("`"),s.push(l.value.replaceAll("`","\\`")),s.push("`")}generateLiteral(s,l){if(l.value===null)return s.push("null");switch(typeof l.value){case"number":case"boolean":return s.push(`${l.value}`);case"string":{let _=l.value,h=JSON.stringify(_);return s.push(`${h}`)}}}generateIdentifier(s,l){let _=fur.test(l.value)?l.value:`'${l.value}'`;s.push(_)}};import _ur from"node:fs/promises";import{parse as pur}from"@swc/core";var cpt=t(async a=>{let s=new Set;try{let l=await _ur.readFile(a,"utf-8");(await pur(l,{syntax:"typescript"})).body.forEach(h=>{h.type==="ExportDefaultDeclaration"||h.type==="ExportDefaultExpression"?s.add("default"):h.type==="ExportDeclaration"&&h.declaration.type==="FunctionDeclaration"?s.add(h.declaration.identifier.value):h.type==="ExportDeclaration"&&h.declaration.type==="VariableDeclaration"&&h.declaration.declarations[0].id.type==="Identifier"&&s.add(h.declaration.declarations[0].id.value)})}catch{return null}return s},"getJSFileExports");var lpt={$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 qNe={$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 upt={$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 VNe={$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:{},mcp:{type:"object",additionalProperties:!1,properties:{enabled:{type:"boolean"}}},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 WNe={$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:{},mcp:{type:"object",additionalProperties:!1,properties:{enabled:{type:"boolean"}}},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 xht=x_(Wmt(),1),Cht=x_(Tht(),1);var Efe=class a{static{t(this,"JsonValidator")}static#r=new a;static get instance(){return a.#r}ajv;constructor(){this.ajv=new Cht.Ajv2020({allErrors:!0,allowUnionTypes:!0}),this.ajv.addKeyword("faker"),(0,xht.default)(this.ajv,{mode:"fast"})}addSchema(s,l){this.ajv.addSchema(s,l)}compile(s){let l=this.ajv.compile(s);return t(h=>({isValid:l(h),errors:this.toSimpleErrors(l.errors,h),warnings:[]}),"validator")}toSimpleErrors(s,l){let _=[];return s?.forEach(h=>{h.keyword==="enum"&&h.params.allowedValues&&Array.isArray(h.params.allowedValues)&&(h.message+=`; ${h.params.allowedValues.join(", ")}`),h.instancePath&&(h.instancePath=h.instancePath.replaceAll(/(\/)?(~1)(\/)?/gm,"/"));let b={details:{}},D=h.instancePath.split("/");if(D.length>2){let M=D[1],z=D[2]?parseInt(D[2]):0,ne=D[3],ie=isNaN(z)?void 0:l[M][z][ne];b={details:{property:M,index:z,field:ne,fieldValue:ie}}}if(h.keyword==="required"&&h.params.missingProperty&&h.instancePath&&(h.message=`A 'path' is missing required property '${h.params.missingProperty}'`),h.keyword==="additionalProperties"&&h.params.additionalProperty&&h.instancePath&&(h.message=`A 'path' should NOT include property '${h.params.additionalProperty}'`),h.keyword==="type"&&h.params.type&&h.instancePath){let M=h.instancePath.split("/"),z=M[M.length-1];h.message=`Value of property '${z}' must be '${h.params.type}'`}let N=Object.assign(h,b);_.push(N)}),_}};var tN=Efe.instance;tN.addSchema(WNe,"route-configuration.schema.json");tN.addSchema(upt,"policy-configuration.schema.json");tN.addSchema(qNe,"policies.schema.json");tN.addSchema(VNe,"open-api-route-configuration.schema.json");tN.addSchema(lpt,"fragments.schema.json");var Z9r=tN.compile(WNe),Eht=tN.compile(VNe),oFe=tN.compile(qNe);var Dfe=class{static{t(this,"PoliciesConfigurationValidator")}results;validate(s){return this.results=oFe(s),this.results}};var kfe=class{static{t(this,"OpenAPILocalizedValidator")}results;validate(s){return this.results=Eht(s),this.results}};import bgr from"node:path";var cFe=/\$import\((.*)\)/,wfe=/\$env\((.*?)\)/g;var BA=class extends Error{static{t(this,"CodeGenError")}location;constructor(s,l,_,h){super(s),this.location={file:l,namespace:"",line:_?_.line:0,column:_?_.column:0,length:0,lineText:h??"",suggestion:""}}},vgr=t(a=>{let s=[],l=a;for(;l.parent;)s.push(l),l=l.parent;return s.reverse()},"invertTree"),rN=t((a,s)=>{if(!a)return!1;let l=vgr(a);return s.split("/").every((b,D)=>{let N=l[D];return N?b==="*"||OA(N)&&N.name.value===b?!0:b==="{}"?N.type===ec.Object:b==="[]"?N.type===ec.Array:!1:!1})},"testPosition");var Pfe=class{static{t(this,"AstTransformer")}errors=[];transform(s){return this.visitor(s),s}visitor(s){this.visit(s),pj(s)?s.children.forEach(l=>{this.visitor(l)}):apt(s)?s.children.forEach(l=>{this.visitor(l)}):OA(s)&&this.visitor(s.value)}},Dht=t((a,s,l)=>_=>{if(!OA(_)||!dj(_.value)||typeof _.value.value!="string")return;if(!a.some(b=>rN(_,b))){wfe.test(_.value.value)&&s.push(new BA("An $env() statement is not expected at this location.",l,_.location,_.value.value));return}let h=new RegExp(wfe).exec(_.value.value);if(h?.length===2&&h[0]===_.value.value){let b={type:ec.Raw,parent:null,value:`environment["${h[1]}"]`};_.value=b}else{let b=_.value.value.replaceAll(new RegExp(wfe),(D,N)=>`\${environment["${N}"] ? environment["${N}"] : ""}`);b!==_.value.value&&(_.value=MT.createTemplateString(b,_))}},"getEnvStatementTransformer");var vK="config/routes.json",Sgr=["handler/{}/options/*","policies/[]/{}/handler/{}/options/*","corsPolicies/[]/{}/*"],Tgr=["handler/{}/module","handler/{}/options/{}/policies/{}/inbound/[]/{}/module","handler/{}/options/{}/policies/{}/outbound/[]/{}/module","policies/[]/{}/handler/{}/module","policies/[]/{}/handler/{}/options/{}/identifier/{}/module","policies/[]/{}/handler/{}/options/{}/validator"],kht=["handler/{}/options/*","policies/[]/{}/handler/{}/options/*"],xgr="handler/{}/options/{}/rewritePattern",Cgr="handler/{}/options/{}/baseUrl",Afe=class extends Pfe{static{t(this,"OpenAPIRoutesFragmentAstTransformer")}importCount=0;addedImports=new Map;getImportName(s){this.addedImports.has(s)||this.addedImports.set(s,`__import${this.importCount++}`);let l=this.addedImports.get(s);if(!l)throw new Error("Import name is undefined. This should not happen.");return l}getImports(){let s=[];return this.addedImports.forEach((l,_)=>{s.push({name:l,path:_})}),s}visit(s){this.rewriteHandlerFunction(s),this.rewriteForwardFunction(s),this.replaceImportStatements(s),this.replaceEnvStatements(s)}rewriteHandlerFunction(s){if(!(!OA(s)||!dj(s.value)||typeof s.value.value!="string")&&rN(s,xgr)){if(!s.parent||!pj(s.parent)){this.errors.push(new BA("Invalid node, expected object",vK,s.parent?s.parent.location:s.location,void 0));return}let l=s.value.value,_={type:ec.Raw,parent:null,value:wht(l)},h=MT.createProperty("__rewriteFunction",_,s);s.parent.children.push(h)}}rewriteForwardFunction(s){if(!(!OA(s)||!dj(s.value)||typeof s.value.value!="string")&&rN(s,Cgr)){if(!s.parent||!pj(s.parent)){this.errors.push(new BA("Invalid node, expected object",vK,s.parent?s.parent.location:s.location,void 0));return}let l=s.value.value,_={type:ec.Raw,parent:null,value:wht(l)},h=MT.createProperty("__rewriteFunction",_,s);s.parent.children.push(h)}}replaceImportStatements(s){if(!OA(s)||!dj(s.value))return;let l=s.value.value;if(typeof l!="string")return;if(!Tgr.some(N=>rN(s,N))&&!kht.some(N=>rN(s,N))){if(cFe.test(l)){if(s.name.value==="$ref")return;this.errors.push(new BA("An $import() statement is not expected at this location.",vK,s.location,l))}return}let _=cFe.exec(l);if(kht.some(N=>rN(s,N))&&!_)return;if(!_){this.errors.push(new BA("Invalid $import() statement",vK,s.location,l));return}let h=_[1];h=h.replace(/\\/g,"/"),h.startsWith(".")&&(h=bgr.posix.join("..",h));let b=this.getImportName(h),D={type:ec.Identifier,parent:s.parent,value:b};s.value=D}replaceEnvStatements=Dht(Sgr,this.errors,vK)};function wht(a){return`(request, context) => {
583
583
  const { params, url, query, method, headers } = request;
584
584
  const { host, hostname, origin, pathname, port, search } = new URL(url);
585
585
  const e = encodeURIComponent;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zuplo/core",
3
- "version": "6.51.45",
3
+ "version": "6.51.46",
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.5.3"
41
41
  },
42
42
  "peerDependencies": {
43
- "@zuplo/graphql": "^6.51.45",
44
- "@zuplo/otel": "^6.51.45",
45
- "@zuplo/runtime": "^6.51.45"
43
+ "@zuplo/graphql": "^6.51.46",
44
+ "@zuplo/otel": "^6.51.46",
45
+ "@zuplo/runtime": "^6.51.46"
46
46
  }
47
47
  }