@zuplo/core 6.21.6 → 6.21.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.minified.js CHANGED
@@ -557,7 +557,7 @@ globstar while`,s,Z,l,Re,Pe),this.matchOne(s.slice(Z),l.slice(Re),_))return this
557
557
  >>> no match, partial?`,s,Z,l,Re),Z===M))}let ke;if(typeof ie=="string"?(ke=se===ie,this.debug("string match",ie,se,ke)):(ke=ie.test(se),this.debug("pattern match",ie,se,ke)),!ke)return!1}if(D===M&&A===U)return!0;if(D===M)return _;if(A===U)return D===M-1&&s[D]==="";throw new Error("wtf?")}braceExpand(){return Jat(this.pattern,this.options)}parse(s){hH(s);let l=this.options;if(s==="**")return F0;if(s==="")return"";let _,m=null;(_=s.match(rZt))?m=l.dot?iZt:nZt:(_=s.match(WQt))?m=(l.nocase?l.dot?YQt:KQt:l.dot?GQt:HQt)(_[1]):(_=s.match(sZt))?m=(l.nocase?l.dot?oZt:aZt:l.dot?cZt:lZt)(_):(_=s.match(XQt))?m=l.dot?ZQt:QQt:(_=s.match(eZt))&&(m=tZt);let b=QR.fromGlob(s,this.options).toMMPattern();return m&&typeof b=="object"&&Reflect.defineProperty(b,"test",{value:m}),b}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let s=this.set;if(!s.length)return this.regexp=!1,this.regexp;let l=this.options,_=l.noglobstar?_Zt:l.dot?pZt:dZt,m=new Set(l.nocase?["i"]:[]),b=s.map(M=>{let U=M.map(ie=>{if(ie instanceof RegExp)for(let se of ie.flags.split(""))m.add(se);return typeof ie=="string"?vZt(ie):ie===F0?F0:ie._src});return U.forEach((ie,se)=>{let Z=U[se+1],Re=U[se-1];ie!==F0||Re===F0||(Re===void 0?Z!==void 0&&Z!==F0?U[se+1]="(?:\\/|"+_+"\\/)?"+Z:U[se]=_:Z===void 0?U[se-1]=Re+"(?:\\/|"+_+")?":Z!==F0&&(U[se-1]=Re+"(?:\\/|\\/"+_+"\\/)"+Z,U[se+1]=F0))}),U.filter(ie=>ie!==F0).join("/")}).join("|"),[D,A]=s.length>1?["(?:",")"]:["",""];b="^"+D+b+A+"$",this.negate&&(b="^(?!"+b+").+$");try{this.regexp=new RegExp(b,[...m].join(""))}catch{this.regexp=!1}return this.regexp}slashSplit(s){return this.preserveMultipleSlashes?s.split("/"):this.isWindows&&/^\/\/[^\/]+/.test(s)?["",...s.split(/\/+/)]:s.split(/\/+/)}match(s,l=this.partial){if(this.debug("match",s,this.pattern),this.comment)return!1;if(this.empty)return s==="";if(s==="/"&&l)return!0;let _=this.options;this.isWindows&&(s=s.split("\\").join("/"));let m=this.slashSplit(s);this.debug(this.pattern,"split",m);let b=this.set;this.debug(this.pattern,"set",b);let D=m[m.length-1];if(!D)for(let A=m.length-2;!D&&A>=0;A--)D=m[A];for(let A=0;A<b.length;A++){let M=b[A],U=m;if(_.matchBase&&M.length===1&&(U=[D]),this.matchOne(U,M,l))return _.flipNegate?!0:!this.negate}return _.flipNegate?!1:this.negate}static defaults(s){return j1.defaults(s).Minimatch}};j1.AST=QR;j1.Minimatch=B2;j1.escape=ZR;j1.unescape=kE;import{fileURLToPath as XZt}from"url";var eM=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,qat=new Set,o6e=typeof process=="object"&&process?process:{},Vat=t((a,s,l,_)=>{typeof o6e.emitWarning=="function"?o6e.emitWarning(a,s,l,_):console.error(`[${l}] ${s}: ${a}`)},"emitWarning"),Dce=globalThis.AbortController,zat=globalThis.AbortSignal;if(typeof Dce>"u"){zat=class{static{t(this,"AbortSignal")}onabort;_onabort=[];reason;aborted=!1;addEventListener(_,m){this._onabort.push(m)}},Dce=class{static{t(this,"AbortController")}constructor(){s()}signal=new zat;abort(_){if(!this.signal.aborted){this.signal.reason=_,this.signal.aborted=!0;for(let m of this.signal._onabort)m(_);this.signal.onabort?.(_)}}};let a=o6e.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",s=t(()=>{a&&(a=!1,Vat("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",s))},"warnACPolyfill")}var bZt=t(a=>!qat.has(a),"shouldWarn"),l4r=Symbol("type"),e3=t(a=>a&&a===Math.floor(a)&&a>0&&isFinite(a),"isPosInt"),Wat=t(a=>e3(a)?a<=Math.pow(2,8)?Uint8Array:a<=Math.pow(2,16)?Uint16Array:a<=Math.pow(2,32)?Uint32Array:a<=Number.MAX_SAFE_INTEGER?tM:null:null,"getUintArray"),tM=class extends Array{static{t(this,"ZeroArray")}constructor(s){super(s),this.fill(0)}},c6e=class a{static{t(this,"Stack")}heap;length;static#r=!1;static create(s){let l=Wat(s);if(!l)return[];a.#r=!0;let _=new a(s,l);return a.#r=!1,_}constructor(s,l){if(!a.#r)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new l(s),this.length=0}push(s){this.heap[this.length++]=s}pop(){return this.heap[--this.length]}},yH=class a{static{t(this,"LRUCache")}#r;#n;#e;#t;#s;#p;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#a;#_;#c;#l;#i;#f;#v;#d;#u;#m;#g;#C;#x;#b;#k;#E;#y;static unsafeExposeInternals(s){return{starts:s.#x,ttls:s.#b,sizes:s.#C,keyMap:s.#c,keyList:s.#l,valList:s.#i,next:s.#f,prev:s.#v,get head(){return s.#d},get tail(){return s.#u},free:s.#m,isBackgroundFetch:t(l=>s.#h(l),"isBackgroundFetch"),backgroundFetch:t((l,_,m,b)=>s.#j(l,_,m,b),"backgroundFetch"),moveToTail:t(l=>s.#U(l),"moveToTail"),indexes:t(l=>s.#P(l),"indexes"),rindexes:t(l=>s.#A(l),"rindexes"),isStale:t(l=>s.#S(l),"isStale")}}get max(){return this.#r}get maxSize(){return this.#n}get calculatedSize(){return this.#_}get size(){return this.#a}get fetchMethod(){return this.#s}get memoMethod(){return this.#p}get dispose(){return this.#e}get disposeAfter(){return this.#t}constructor(s){let{max:l=0,ttl:_,ttlResolution:m=1,ttlAutopurge:b,updateAgeOnGet:D,updateAgeOnHas:A,allowStale:M,dispose:U,disposeAfter:ie,noDisposeOnSet:se,noUpdateTTL:Z,maxSize:Re=0,maxEntrySize:Pe=0,sizeCalculation:ke,fetchMethod:wt,memoMethod:At,noDeleteOnFetchRejection:yr,noDeleteOnStaleGet:zr,allowStaleOnFetchRejection:en,allowStaleOnFetchAbort:hn,ignoreFetchAbort:br}=s;if(l!==0&&!e3(l))throw new TypeError("max option must be a nonnegative integer");let mr=l?Wat(l):Array;if(!mr)throw new Error("invalid max value: "+l);if(this.#r=l,this.#n=Re,this.maxEntrySize=Pe||this.#n,this.sizeCalculation=ke,this.sizeCalculation){if(!this.#n&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(At!==void 0&&typeof At!="function")throw new TypeError("memoMethod must be a function if defined");if(this.#p=At,wt!==void 0&&typeof wt!="function")throw new TypeError("fetchMethod must be a function if specified");if(this.#s=wt,this.#E=!!wt,this.#c=new Map,this.#l=new Array(l).fill(void 0),this.#i=new Array(l).fill(void 0),this.#f=new mr(l),this.#v=new mr(l),this.#d=0,this.#u=0,this.#m=c6e.create(l),this.#a=0,this.#_=0,typeof U=="function"&&(this.#e=U),typeof ie=="function"?(this.#t=ie,this.#g=[]):(this.#t=void 0,this.#g=void 0),this.#k=!!this.#e,this.#y=!!this.#t,this.noDisposeOnSet=!!se,this.noUpdateTTL=!!Z,this.noDeleteOnFetchRejection=!!yr,this.allowStaleOnFetchRejection=!!en,this.allowStaleOnFetchAbort=!!hn,this.ignoreFetchAbort=!!br,this.maxEntrySize!==0){if(this.#n!==0&&!e3(this.#n))throw new TypeError("maxSize must be a positive integer if specified");if(!e3(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#T()}if(this.allowStale=!!M,this.noDeleteOnStaleGet=!!zr,this.updateAgeOnGet=!!D,this.updateAgeOnHas=!!A,this.ttlResolution=e3(m)||m===0?m:1,this.ttlAutopurge=!!b,this.ttl=_||0,this.ttl){if(!e3(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#D()}if(this.#r===0&&this.ttl===0&&this.#n===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#r&&!this.#n){let Is="LRU_CACHE_UNBOUNDED";bZt(Is)&&(qat.add(Is),Vat("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",Is,a))}}getRemainingTTL(s){return this.#c.has(s)?1/0:0}#D(){let s=new tM(this.#r),l=new tM(this.#r);this.#b=s,this.#x=l,this.#N=(b,D,A=eM.now())=>{if(l[b]=D!==0?A:0,s[b]=D,D!==0&&this.ttlAutopurge){let M=setTimeout(()=>{this.#S(b)&&this.#O(this.#l[b],"expire")},D+1);M.unref&&M.unref()}},this.#w=b=>{l[b]=s[b]!==0?eM.now():0},this.#o=(b,D)=>{if(s[D]){let A=s[D],M=l[D];if(!A||!M)return;b.ttl=A,b.start=M,b.now=_||m();let U=b.now-M;b.remainingTTL=A-U}};let _=0,m=t(()=>{let b=eM.now();if(this.ttlResolution>0){_=b;let D=setTimeout(()=>_=0,this.ttlResolution);D.unref&&D.unref()}return b},"getNow");this.getRemainingTTL=b=>{let D=this.#c.get(b);if(D===void 0)return 0;let A=s[D],M=l[D];if(!A||!M)return 1/0;let U=(_||m())-M;return A-U},this.#S=b=>{let D=l[b],A=s[b];return!!A&&!!D&&(_||m())-D>A}}#w=t(()=>{},"#updateItemAge");#o=t(()=>{},"#statusTTL");#N=t(()=>{},"#setItemTTL");#S=t(()=>!1,"#isStale");#T(){let s=new tM(this.#r);this.#_=0,this.#C=s,this.#I=l=>{this.#_-=s[l],s[l]=0},this.#L=(l,_,m,b)=>{if(this.#h(_))return 0;if(!e3(m))if(b){if(typeof b!="function")throw new TypeError("sizeCalculation must be a function");if(m=b(_,l),!e3(m))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return m},this.#F=(l,_,m)=>{if(s[l]=_,this.#n){let b=this.#n-s[l];for(;this.#_>b;)this.#M(!0)}this.#_+=s[l],m&&(m.entrySize=_,m.totalCalculatedSize=this.#_)}}#I=t(s=>{},"#removeItemSize");#F=t((s,l,_)=>{},"#addItemSize");#L=t((s,l,_,m)=>{if(_||m)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0},"#requireSize");*#P({allowStale:s=this.allowStale}={}){if(this.#a)for(let l=this.#u;!(!this.#R(l)||((s||!this.#S(l))&&(yield l),l===this.#d));)l=this.#v[l]}*#A({allowStale:s=this.allowStale}={}){if(this.#a)for(let l=this.#d;!(!this.#R(l)||((s||!this.#S(l))&&(yield l),l===this.#u));)l=this.#f[l]}#R(s){return s!==void 0&&this.#c.get(this.#l[s])===s}*entries(){for(let s of this.#P())this.#i[s]!==void 0&&this.#l[s]!==void 0&&!this.#h(this.#i[s])&&(yield[this.#l[s],this.#i[s]])}*rentries(){for(let s of this.#A())this.#i[s]!==void 0&&this.#l[s]!==void 0&&!this.#h(this.#i[s])&&(yield[this.#l[s],this.#i[s]])}*keys(){for(let s of this.#P()){let l=this.#l[s];l!==void 0&&!this.#h(this.#i[s])&&(yield l)}}*rkeys(){for(let s of this.#A()){let l=this.#l[s];l!==void 0&&!this.#h(this.#i[s])&&(yield l)}}*values(){for(let s of this.#P())this.#i[s]!==void 0&&!this.#h(this.#i[s])&&(yield this.#i[s])}*rvalues(){for(let s of this.#A())this.#i[s]!==void 0&&!this.#h(this.#i[s])&&(yield this.#i[s])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(s,l={}){for(let _ of this.#P()){let m=this.#i[_],b=this.#h(m)?m.__staleWhileFetching:m;if(b!==void 0&&s(b,this.#l[_],this))return this.get(this.#l[_],l)}}forEach(s,l=this){for(let _ of this.#P()){let m=this.#i[_],b=this.#h(m)?m.__staleWhileFetching:m;b!==void 0&&s.call(l,b,this.#l[_],this)}}rforEach(s,l=this){for(let _ of this.#A()){let m=this.#i[_],b=this.#h(m)?m.__staleWhileFetching:m;b!==void 0&&s.call(l,b,this.#l[_],this)}}purgeStale(){let s=!1;for(let l of this.#A({allowStale:!0}))this.#S(l)&&(this.#O(this.#l[l],"expire"),s=!0);return s}info(s){let l=this.#c.get(s);if(l===void 0)return;let _=this.#i[l],m=this.#h(_)?_.__staleWhileFetching:_;if(m===void 0)return;let b={value:m};if(this.#b&&this.#x){let D=this.#b[l],A=this.#x[l];if(D&&A){let M=D-(eM.now()-A);b.ttl=M,b.start=Date.now()}}return this.#C&&(b.size=this.#C[l]),b}dump(){let s=[];for(let l of this.#P({allowStale:!0})){let _=this.#l[l],m=this.#i[l],b=this.#h(m)?m.__staleWhileFetching:m;if(b===void 0||_===void 0)continue;let D={value:b};if(this.#b&&this.#x){D.ttl=this.#b[l];let A=eM.now()-this.#x[l];D.start=Math.floor(Date.now()-A)}this.#C&&(D.size=this.#C[l]),s.unshift([_,D])}return s}load(s){this.clear();for(let[l,_]of s){if(_.start){let m=Date.now()-_.start;_.start=eM.now()-m}this.set(l,_.value,_)}}set(s,l,_={}){if(l===void 0)return this.delete(s),this;let{ttl:m=this.ttl,start:b,noDisposeOnSet:D=this.noDisposeOnSet,sizeCalculation:A=this.sizeCalculation,status:M}=_,{noUpdateTTL:U=this.noUpdateTTL}=_,ie=this.#L(s,l,_.size||0,A);if(this.maxEntrySize&&ie>this.maxEntrySize)return M&&(M.set="miss",M.maxEntrySizeExceeded=!0),this.#O(s,"set"),this;let se=this.#a===0?void 0:this.#c.get(s);if(se===void 0)se=this.#a===0?this.#u:this.#m.length!==0?this.#m.pop():this.#a===this.#r?this.#M(!1):this.#a,this.#l[se]=s,this.#i[se]=l,this.#c.set(s,se),this.#f[this.#u]=se,this.#v[se]=this.#u,this.#u=se,this.#a++,this.#F(se,ie,M),M&&(M.set="add"),U=!1;else{this.#U(se);let Z=this.#i[se];if(l!==Z){if(this.#E&&this.#h(Z)){Z.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:Re}=Z;Re!==void 0&&!D&&(this.#k&&this.#e?.(Re,s,"set"),this.#y&&this.#g?.push([Re,s,"set"]))}else D||(this.#k&&this.#e?.(Z,s,"set"),this.#y&&this.#g?.push([Z,s,"set"]));if(this.#I(se),this.#F(se,ie,M),this.#i[se]=l,M){M.set="replace";let Re=Z&&this.#h(Z)?Z.__staleWhileFetching:Z;Re!==void 0&&(M.oldValue=Re)}}else M&&(M.set="update")}if(m!==0&&!this.#b&&this.#D(),this.#b&&(U||this.#N(se,m,b),M&&this.#o(M,se)),!D&&this.#y&&this.#g){let Z=this.#g,Re;for(;Re=Z?.shift();)this.#t?.(...Re)}return this}pop(){try{for(;this.#a;){let s=this.#i[this.#d];if(this.#M(!0),this.#h(s)){if(s.__staleWhileFetching)return s.__staleWhileFetching}else if(s!==void 0)return s}}finally{if(this.#y&&this.#g){let s=this.#g,l;for(;l=s?.shift();)this.#t?.(...l)}}}#M(s){let l=this.#d,_=this.#l[l],m=this.#i[l];return this.#E&&this.#h(m)?m.__abortController.abort(new Error("evicted")):(this.#k||this.#y)&&(this.#k&&this.#e?.(m,_,"evict"),this.#y&&this.#g?.push([m,_,"evict"])),this.#I(l),s&&(this.#l[l]=void 0,this.#i[l]=void 0,this.#m.push(l)),this.#a===1?(this.#d=this.#u=0,this.#m.length=0):this.#d=this.#f[l],this.#c.delete(_),this.#a--,l}has(s,l={}){let{updateAgeOnHas:_=this.updateAgeOnHas,status:m}=l,b=this.#c.get(s);if(b!==void 0){let D=this.#i[b];if(this.#h(D)&&D.__staleWhileFetching===void 0)return!1;if(this.#S(b))m&&(m.has="stale",this.#o(m,b));else return _&&this.#w(b),m&&(m.has="hit",this.#o(m,b)),!0}else m&&(m.has="miss");return!1}peek(s,l={}){let{allowStale:_=this.allowStale}=l,m=this.#c.get(s);if(m===void 0||!_&&this.#S(m))return;let b=this.#i[m];return this.#h(b)?b.__staleWhileFetching:b}#j(s,l,_,m){let b=l===void 0?void 0:this.#i[l];if(this.#h(b))return b;let D=new Dce,{signal:A}=_;A?.addEventListener("abort",()=>D.abort(A.reason),{signal:D.signal});let M={signal:D.signal,options:_,context:m},U=t((ke,wt=!1)=>{let{aborted:At}=D.signal,yr=_.ignoreFetchAbort&&ke!==void 0;if(_.status&&(At&&!wt?(_.status.fetchAborted=!0,_.status.fetchError=D.signal.reason,yr&&(_.status.fetchAbortIgnored=!0)):_.status.fetchResolved=!0),At&&!yr&&!wt)return se(D.signal.reason);let zr=Re;return this.#i[l]===Re&&(ke===void 0?zr.__staleWhileFetching?this.#i[l]=zr.__staleWhileFetching:this.#O(s,"fetch"):(_.status&&(_.status.fetchUpdated=!0),this.set(s,ke,M.options))),ke},"cb"),ie=t(ke=>(_.status&&(_.status.fetchRejected=!0,_.status.fetchError=ke),se(ke)),"eb"),se=t(ke=>{let{aborted:wt}=D.signal,At=wt&&_.allowStaleOnFetchAbort,yr=At||_.allowStaleOnFetchRejection,zr=yr||_.noDeleteOnFetchRejection,en=Re;if(this.#i[l]===Re&&(!zr||en.__staleWhileFetching===void 0?this.#O(s,"fetch"):At||(this.#i[l]=en.__staleWhileFetching)),yr)return _.status&&en.__staleWhileFetching!==void 0&&(_.status.returnedStale=!0),en.__staleWhileFetching;if(en.__returned===en)throw ke},"fetchFail"),Z=t((ke,wt)=>{let At=this.#s?.(s,b,M);At&&At instanceof Promise&&At.then(yr=>ke(yr===void 0?void 0:yr),wt),D.signal.addEventListener("abort",()=>{(!_.ignoreFetchAbort||_.allowStaleOnFetchAbort)&&(ke(void 0),_.allowStaleOnFetchAbort&&(ke=t(yr=>U(yr,!0),"res")))})},"pcall");_.status&&(_.status.fetchDispatched=!0);let Re=new Promise(Z).then(U,ie),Pe=Object.assign(Re,{__abortController:D,__staleWhileFetching:b,__returned:void 0});return l===void 0?(this.set(s,Pe,{...M.options,status:void 0}),l=this.#c.get(s)):this.#i[l]=Pe,Pe}#h(s){if(!this.#E)return!1;let l=s;return!!l&&l instanceof Promise&&l.hasOwnProperty("__staleWhileFetching")&&l.__abortController instanceof Dce}async fetch(s,l={}){let{allowStale:_=this.allowStale,updateAgeOnGet:m=this.updateAgeOnGet,noDeleteOnStaleGet:b=this.noDeleteOnStaleGet,ttl:D=this.ttl,noDisposeOnSet:A=this.noDisposeOnSet,size:M=0,sizeCalculation:U=this.sizeCalculation,noUpdateTTL:ie=this.noUpdateTTL,noDeleteOnFetchRejection:se=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:Z=this.allowStaleOnFetchRejection,ignoreFetchAbort:Re=this.ignoreFetchAbort,allowStaleOnFetchAbort:Pe=this.allowStaleOnFetchAbort,context:ke,forceRefresh:wt=!1,status:At,signal:yr}=l;if(!this.#E)return At&&(At.fetch="get"),this.get(s,{allowStale:_,updateAgeOnGet:m,noDeleteOnStaleGet:b,status:At});let zr={allowStale:_,updateAgeOnGet:m,noDeleteOnStaleGet:b,ttl:D,noDisposeOnSet:A,size:M,sizeCalculation:U,noUpdateTTL:ie,noDeleteOnFetchRejection:se,allowStaleOnFetchRejection:Z,allowStaleOnFetchAbort:Pe,ignoreFetchAbort:Re,status:At,signal:yr},en=this.#c.get(s);if(en===void 0){At&&(At.fetch="miss");let hn=this.#j(s,en,zr,ke);return hn.__returned=hn}else{let hn=this.#i[en];if(this.#h(hn)){let Po=_&&hn.__staleWhileFetching!==void 0;return At&&(At.fetch="inflight",Po&&(At.returnedStale=!0)),Po?hn.__staleWhileFetching:hn.__returned=hn}let br=this.#S(en);if(!wt&&!br)return At&&(At.fetch="hit"),this.#U(en),m&&this.#w(en),At&&this.#o(At,en),hn;let mr=this.#j(s,en,zr,ke),Pi=mr.__staleWhileFetching!==void 0&&_;return At&&(At.fetch=br?"stale":"refresh",Pi&&br&&(At.returnedStale=!0)),Pi?mr.__staleWhileFetching:mr.__returned=mr}}async forceFetch(s,l={}){let _=await this.fetch(s,l);if(_===void 0)throw new Error("fetch() returned undefined");return _}memo(s,l={}){let _=this.#p;if(!_)throw new Error("no memoMethod provided to constructor");let{context:m,forceRefresh:b,...D}=l,A=this.get(s,D);if(!b&&A!==void 0)return A;let M=_(s,A,{options:D,context:m});return this.set(s,M,D),M}get(s,l={}){let{allowStale:_=this.allowStale,updateAgeOnGet:m=this.updateAgeOnGet,noDeleteOnStaleGet:b=this.noDeleteOnStaleGet,status:D}=l,A=this.#c.get(s);if(A!==void 0){let M=this.#i[A],U=this.#h(M);return D&&this.#o(D,A),this.#S(A)?(D&&(D.get="stale"),U?(D&&_&&M.__staleWhileFetching!==void 0&&(D.returnedStale=!0),_?M.__staleWhileFetching:void 0):(b||this.#O(s,"expire"),D&&_&&(D.returnedStale=!0),_?M:void 0)):(D&&(D.get="hit"),U?M.__staleWhileFetching:(this.#U(A),m&&this.#w(A),M))}else D&&(D.get="miss")}#B(s,l){this.#v[l]=s,this.#f[s]=l}#U(s){s!==this.#u&&(s===this.#d?this.#d=this.#f[s]:this.#B(this.#v[s],this.#f[s]),this.#B(this.#u,s),this.#u=s)}delete(s){return this.#O(s,"delete")}#O(s,l){let _=!1;if(this.#a!==0){let m=this.#c.get(s);if(m!==void 0)if(_=!0,this.#a===1)this.#$(l);else{this.#I(m);let b=this.#i[m];if(this.#h(b)?b.__abortController.abort(new Error("deleted")):(this.#k||this.#y)&&(this.#k&&this.#e?.(b,s,l),this.#y&&this.#g?.push([b,s,l])),this.#c.delete(s),this.#l[m]=void 0,this.#i[m]=void 0,m===this.#u)this.#u=this.#v[m];else if(m===this.#d)this.#d=this.#f[m];else{let D=this.#v[m];this.#f[D]=this.#f[m];let A=this.#f[m];this.#v[A]=this.#v[m]}this.#a--,this.#m.push(m)}}if(this.#y&&this.#g?.length){let m=this.#g,b;for(;b=m?.shift();)this.#t?.(...b)}return _}clear(){return this.#$("delete")}#$(s){for(let l of this.#A({allowStale:!0})){let _=this.#i[l];if(this.#h(_))_.__abortController.abort(new Error("deleted"));else{let m=this.#l[l];this.#k&&this.#e?.(_,m,s),this.#y&&this.#g?.push([_,m,s])}}if(this.#c.clear(),this.#i.fill(void 0),this.#l.fill(void 0),this.#b&&this.#x&&(this.#b.fill(0),this.#x.fill(0)),this.#C&&this.#C.fill(0),this.#d=0,this.#u=0,this.#m.length=0,this.#_=0,this.#a=0,this.#y&&this.#g){let l=this.#g,_;for(;_=l?.shift();)this.#t?.(..._)}}};import{posix as NZt,win32 as y6e}from"path";import{fileURLToPath as IZt}from"url";import{lstatSync as OZt,readdir as FZt,readdirSync as LZt,readlinkSync as RZt,realpathSync as MZt}from"fs";import*as jZt from"fs";import{lstat as UZt,readdir as $Zt,readlink as JZt,realpath as zZt}from"fs/promises";import{EventEmitter as m6e}from"events";import Xat from"stream";import{StringDecoder as SZt}from"string_decoder";var Hat=typeof process=="object"&&process?process:{stdout:null,stderr:null},TZt=t(a=>!!a&&typeof a=="object"&&(a instanceof r3||a instanceof Xat||xZt(a)||EZt(a)),"isStream"),xZt=t(a=>!!a&&typeof a=="object"&&a instanceof m6e&&typeof a.pipe=="function"&&a.pipe!==Xat.Writable.prototype.pipe,"isReadable"),EZt=t(a=>!!a&&typeof a=="object"&&a instanceof m6e&&typeof a.write=="function"&&typeof a.end=="function","isWritable"),GP=Symbol("EOF"),KP=Symbol("maybeEmitEnd"),t3=Symbol("emittedEnd"),kce=Symbol("emittingEnd"),vH=Symbol("emittedError"),wce=Symbol("closed"),Gat=Symbol("read"),Pce=Symbol("flush"),Kat=Symbol("flushChunk"),wE=Symbol("encoding"),rM=Symbol("decoder"),Gg=Symbol("flowing"),bH=Symbol("paused"),nM=Symbol("resume"),Kg=Symbol("buffer"),B1=Symbol("pipes"),Yg=Symbol("bufferLength"),l6e=Symbol("bufferPush"),Ace=Symbol("bufferShift"),Ny=Symbol("objectMode"),Gm=Symbol("destroyed"),u6e=Symbol("error"),f6e=Symbol("emitData"),Yat=Symbol("emitEnd"),_6e=Symbol("emitEnd2"),HD=Symbol("async"),p6e=Symbol("abort"),Nce=Symbol("aborted"),SH=Symbol("signal"),TO=Symbol("dataListeners"),U2=Symbol("discarded"),TH=t(a=>Promise.resolve().then(a),"defer"),CZt=t(a=>a(),"nodefer"),DZt=t(a=>a==="end"||a==="finish"||a==="prefinish","isEndish"),kZt=t(a=>a instanceof ArrayBuffer||!!a&&typeof a=="object"&&a.constructor&&a.constructor.name==="ArrayBuffer"&&a.byteLength>=0,"isArrayBufferLike"),wZt=t(a=>!Buffer.isBuffer(a)&&ArrayBuffer.isView(a),"isArrayBufferView"),Ice=class{static{t(this,"Pipe")}src;dest;opts;ondrain;constructor(s,l,_){this.src=s,this.dest=l,this.opts=_,this.ondrain=()=>s[nM](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(s){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},d6e=class extends Ice{static{t(this,"PipeProxyErrors")}unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(s,l,_){super(s,l,_),this.proxyErrors=m=>l.emit("error",m),s.on("error",this.proxyErrors)}},PZt=t(a=>!!a.objectMode,"isObjectModeOptions"),AZt=t(a=>!a.objectMode&&!!a.encoding&&a.encoding!=="buffer","isEncodingOptions"),r3=class extends m6e{static{t(this,"Minipass")}[Gg]=!1;[bH]=!1;[B1]=[];[Kg]=[];[Ny];[wE];[HD];[rM];[GP]=!1;[t3]=!1;[kce]=!1;[wce]=!1;[vH]=null;[Yg]=0;[Gm]=!1;[SH];[Nce]=!1;[TO]=0;[U2]=!1;writable=!0;readable=!0;constructor(...s){let l=s[0]||{};if(super(),l.objectMode&&typeof l.encoding=="string")throw new TypeError("Encoding and objectMode may not be used together");PZt(l)?(this[Ny]=!0,this[wE]=null):AZt(l)?(this[wE]=l.encoding,this[Ny]=!1):(this[Ny]=!1,this[wE]=null),this[HD]=!!l.async,this[rM]=this[wE]?new SZt(this[wE]):null,l&&l.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:t(()=>this[Kg],"get")}),l&&l.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:t(()=>this[B1],"get")});let{signal:_}=l;_&&(this[SH]=_,_.aborted?this[p6e]():_.addEventListener("abort",()=>this[p6e]()))}get bufferLength(){return this[Yg]}get encoding(){return this[wE]}set encoding(s){throw new Error("Encoding must be set at instantiation time")}setEncoding(s){throw new Error("Encoding must be set at instantiation time")}get objectMode(){return this[Ny]}set objectMode(s){throw new Error("objectMode must be set at instantiation time")}get async(){return this[HD]}set async(s){this[HD]=this[HD]||!!s}[p6e](){this[Nce]=!0,this.emit("abort",this[SH]?.reason),this.destroy(this[SH]?.reason)}get aborted(){return this[Nce]}set aborted(s){}write(s,l,_){if(this[Nce])return!1;if(this[GP])throw new Error("write after end");if(this[Gm])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;typeof l=="function"&&(_=l,l="utf8"),l||(l="utf8");let m=this[HD]?TH:CZt;if(!this[Ny]&&!Buffer.isBuffer(s)){if(wZt(s))s=Buffer.from(s.buffer,s.byteOffset,s.byteLength);else if(kZt(s))s=Buffer.from(s);else if(typeof s!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[Ny]?(this[Gg]&&this[Yg]!==0&&this[Pce](!0),this[Gg]?this.emit("data",s):this[l6e](s),this[Yg]!==0&&this.emit("readable"),_&&m(_),this[Gg]):s.length?(typeof s=="string"&&!(l===this[wE]&&!this[rM]?.lastNeed)&&(s=Buffer.from(s,l)),Buffer.isBuffer(s)&&this[wE]&&(s=this[rM].write(s)),this[Gg]&&this[Yg]!==0&&this[Pce](!0),this[Gg]?this.emit("data",s):this[l6e](s),this[Yg]!==0&&this.emit("readable"),_&&m(_),this[Gg]):(this[Yg]!==0&&this.emit("readable"),_&&m(_),this[Gg])}read(s){if(this[Gm])return null;if(this[U2]=!1,this[Yg]===0||s===0||s&&s>this[Yg])return this[KP](),null;this[Ny]&&(s=null),this[Kg].length>1&&!this[Ny]&&(this[Kg]=[this[wE]?this[Kg].join(""):Buffer.concat(this[Kg],this[Yg])]);let l=this[Gat](s||null,this[Kg][0]);return this[KP](),l}[Gat](s,l){if(this[Ny])this[Ace]();else{let _=l;s===_.length||s===null?this[Ace]():typeof _=="string"?(this[Kg][0]=_.slice(s),l=_.slice(0,s),this[Yg]-=s):(this[Kg][0]=_.subarray(s),l=_.subarray(0,s),this[Yg]-=s)}return this.emit("data",l),!this[Kg].length&&!this[GP]&&this.emit("drain"),l}end(s,l,_){return typeof s=="function"&&(_=s,s=void 0),typeof l=="function"&&(_=l,l="utf8"),s!==void 0&&this.write(s,l),_&&this.once("end",_),this[GP]=!0,this.writable=!1,(this[Gg]||!this[bH])&&this[KP](),this}[nM](){this[Gm]||(!this[TO]&&!this[B1].length&&(this[U2]=!0),this[bH]=!1,this[Gg]=!0,this.emit("resume"),this[Kg].length?this[Pce]():this[GP]?this[KP]():this.emit("drain"))}resume(){return this[nM]()}pause(){this[Gg]=!1,this[bH]=!0,this[U2]=!1}get destroyed(){return this[Gm]}get flowing(){return this[Gg]}get paused(){return this[bH]}[l6e](s){this[Ny]?this[Yg]+=1:this[Yg]+=s.length,this[Kg].push(s)}[Ace](){return this[Ny]?this[Yg]-=1:this[Yg]-=this[Kg][0].length,this[Kg].shift()}[Pce](s=!1){do;while(this[Kat](this[Ace]())&&this[Kg].length);!s&&!this[Kg].length&&!this[GP]&&this.emit("drain")}[Kat](s){return this.emit("data",s),this[Gg]}pipe(s,l){if(this[Gm])return s;this[U2]=!1;let _=this[t3];return l=l||{},s===Hat.stdout||s===Hat.stderr?l.end=!1:l.end=l.end!==!1,l.proxyErrors=!!l.proxyErrors,_?l.end&&s.end():(this[B1].push(l.proxyErrors?new d6e(this,s,l):new Ice(this,s,l)),this[HD]?TH(()=>this[nM]()):this[nM]()),s}unpipe(s){let l=this[B1].find(_=>_.dest===s);l&&(this[B1].length===1?(this[Gg]&&this[TO]===0&&(this[Gg]=!1),this[B1]=[]):this[B1].splice(this[B1].indexOf(l),1),l.unpipe())}addListener(s,l){return this.on(s,l)}on(s,l){let _=super.on(s,l);if(s==="data")this[U2]=!1,this[TO]++,!this[B1].length&&!this[Gg]&&this[nM]();else if(s==="readable"&&this[Yg]!==0)super.emit("readable");else if(DZt(s)&&this[t3])super.emit(s),this.removeAllListeners(s);else if(s==="error"&&this[vH]){let m=l;this[HD]?TH(()=>m.call(this,this[vH])):m.call(this,this[vH])}return _}removeListener(s,l){return this.off(s,l)}off(s,l){let _=super.off(s,l);return s==="data"&&(this[TO]=this.listeners("data").length,this[TO]===0&&!this[U2]&&!this[B1].length&&(this[Gg]=!1)),_}removeAllListeners(s){let l=super.removeAllListeners(s);return(s==="data"||s===void 0)&&(this[TO]=0,!this[U2]&&!this[B1].length&&(this[Gg]=!1)),l}get emittedEnd(){return this[t3]}[KP](){!this[kce]&&!this[t3]&&!this[Gm]&&this[Kg].length===0&&this[GP]&&(this[kce]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[wce]&&this.emit("close"),this[kce]=!1)}emit(s,...l){let _=l[0];if(s!=="error"&&s!=="close"&&s!==Gm&&this[Gm])return!1;if(s==="data")return!this[Ny]&&!_?!1:this[HD]?(TH(()=>this[f6e](_)),!0):this[f6e](_);if(s==="end")return this[Yat]();if(s==="close"){if(this[wce]=!0,!this[t3]&&!this[Gm])return!1;let b=super.emit("close");return this.removeAllListeners("close"),b}else if(s==="error"){this[vH]=_,super.emit(u6e,_);let b=!this[SH]||this.listeners("error").length?super.emit("error",_):!1;return this[KP](),b}else if(s==="resume"){let b=super.emit("resume");return this[KP](),b}else if(s==="finish"||s==="prefinish"){let b=super.emit(s);return this.removeAllListeners(s),b}let m=super.emit(s,...l);return this[KP](),m}[f6e](s){for(let _ of this[B1])_.dest.write(s)===!1&&this.pause();let l=this[U2]?!1:super.emit("data",s);return this[KP](),l}[Yat](){return this[t3]?!1:(this[t3]=!0,this.readable=!1,this[HD]?(TH(()=>this[_6e]()),!0):this[_6e]())}[_6e](){if(this[rM]){let l=this[rM].end();if(l){for(let _ of this[B1])_.dest.write(l);this[U2]||super.emit("data",l)}}for(let l of this[B1])l.end();let s=super.emit("end");return this.removeAllListeners("end"),s}async collect(){let s=Object.assign([],{dataLength:0});this[Ny]||(s.dataLength=0);let l=this.promise();return this.on("data",_=>{s.push(_),this[Ny]||(s.dataLength+=_.length)}),await l,s}async concat(){if(this[Ny])throw new Error("cannot concat in objectMode");let s=await this.collect();return this[wE]?s.join(""):Buffer.concat(s,s.dataLength)}async promise(){return new Promise((s,l)=>{this.on(Gm,()=>l(new Error("stream destroyed"))),this.on("error",_=>l(_)),this.on("end",()=>s())})}[Symbol.asyncIterator](){this[U2]=!1;let s=!1,l=t(async()=>(this.pause(),s=!0,{value:void 0,done:!0}),"stop");return{next:t(()=>{if(s)return l();let m=this.read();if(m!==null)return Promise.resolve({done:!1,value:m});if(this[GP])return l();let b,D,A=t(se=>{this.off("data",M),this.off("end",U),this.off(Gm,ie),l(),D(se)},"onerr"),M=t(se=>{this.off("error",A),this.off("end",U),this.off(Gm,ie),this.pause(),b({value:se,done:!!this[GP]})},"ondata"),U=t(()=>{this.off("error",A),this.off("data",M),this.off(Gm,ie),l(),b({done:!0,value:void 0})},"onend"),ie=t(()=>A(new Error("stream destroyed")),"ondestroy");return new Promise((se,Z)=>{D=Z,b=se,this.once(Gm,ie),this.once("error",A),this.once("end",U),this.once("data",M)})},"next"),throw:l,return:l,[Symbol.asyncIterator](){return this}}}[Symbol.iterator](){this[U2]=!1;let s=!1,l=t(()=>(this.pause(),this.off(u6e,l),this.off(Gm,l),this.off("end",l),s=!0,{done:!0,value:void 0}),"stop"),_=t(()=>{if(s)return l();let m=this.read();return m===null?l():{done:!1,value:m}},"next");return this.once("end",l),this.once(u6e,l),this.once(Gm,l),{next:_,throw:l,return:l,[Symbol.iterator](){return this}}}destroy(s){if(this[Gm])return s?this.emit("error",s):this.emit(Gm),this;this[Gm]=!0,this[U2]=!0,this[Kg].length=0,this[Yg]=0;let l=this;return typeof l.close=="function"&&!this[wce]&&l.close(),s?this.emit("error",s):this.emit(Gm),this}static get isStream(){return TZt}};var BZt=MZt.native,EH={lstatSync:OZt,readdir:FZt,readdirSync:LZt,readlinkSync:RZt,realpathSync:BZt,promises:{lstat:UZt,readdir:$Zt,readlink:JZt,realpath:zZt}},rot=t(a=>!a||a===EH||a===jZt?EH:{...EH,...a,promises:{...EH.promises,...a.promises||{}}},"fsFromOption"),not=/^\\\\\?\\([a-z]:)\\?$/i,qZt=t(a=>a.replace(/\//g,"\\").replace(not,"$1\\"),"uncToDrive"),VZt=/[\\\/]/,bT=0,iot=1,sot=2,GD=4,aot=6,oot=8,xO=10,cot=12,vT=15,xH=~vT,h6e=16,Qat=32,CH=64,PE=128,Oce=256,Lce=512,Zat=CH|PE|Lce,WZt=1023,g6e=t(a=>a.isFile()?oot:a.isDirectory()?GD:a.isSymbolicLink()?xO:a.isCharacterDevice()?sot:a.isBlockDevice()?aot:a.isSocket()?cot:a.isFIFO()?iot:bT,"entToType"),eot=new Map,DH=t(a=>{let s=eot.get(a);if(s)return s;let l=a.normalize("NFKD");return eot.set(a,l),l},"normalize"),tot=new Map,Fce=t(a=>{let s=tot.get(a);if(s)return s;let l=DH(a.toLowerCase());return tot.set(a,l),l},"normalizeNocase"),Rce=class extends yH{static{t(this,"ResolveCache")}constructor(){super({max:256})}},v6e=class extends yH{static{t(this,"ChildrenCache")}constructor(s=16*1024){super({maxSize:s,sizeCalculation:t(l=>l.length+1,"sizeCalculation")})}},lot=Symbol("PathScurry setAsCwd"),Iy=class{static{t(this,"PathBase")}name;root;roots;parent;nocase;isCWD=!1;#r;#n;get dev(){return this.#n}#e;get mode(){return this.#e}#t;get nlink(){return this.#t}#s;get uid(){return this.#s}#p;get gid(){return this.#p}#a;get rdev(){return this.#a}#_;get blksize(){return this.#_}#c;get ino(){return this.#c}#l;get size(){return this.#l}#i;get blocks(){return this.#i}#f;get atimeMs(){return this.#f}#v;get mtimeMs(){return this.#v}#d;get ctimeMs(){return this.#d}#u;get birthtimeMs(){return this.#u}#m;get atime(){return this.#m}#g;get mtime(){return this.#g}#C;get ctime(){return this.#C}#x;get birthtime(){return this.#x}#b;#k;#E;#y;#D;#w;#o;#N;#S;#T;get parentPath(){return(this.parent||this).fullpath()}get path(){return this.parentPath}constructor(s,l=bT,_,m,b,D,A){this.name=s,this.#b=b?Fce(s):DH(s),this.#o=l&WZt,this.nocase=b,this.roots=m,this.root=_||this,this.#N=D,this.#E=A.fullpath,this.#D=A.relative,this.#w=A.relativePosix,this.parent=A.parent,this.parent?this.#r=this.parent.#r:this.#r=rot(A.fs)}depth(){return this.#k!==void 0?this.#k:this.parent?this.#k=this.parent.depth()+1:this.#k=0}childrenCache(){return this.#N}resolve(s){if(!s)return this;let l=this.getRootString(s),m=s.substring(l.length).split(this.splitSep);return l?this.getRoot(l).#I(m):this.#I(m)}#I(s){let l=this;for(let _ of s)l=l.child(_);return l}children(){let s=this.#N.get(this);if(s)return s;let l=Object.assign([],{provisional:0});return this.#N.set(this,l),this.#o&=~h6e,l}child(s,l){if(s===""||s===".")return this;if(s==="..")return this.parent||this;let _=this.children(),m=this.nocase?Fce(s):DH(s);for(let M of _)if(M.#b===m)return M;let b=this.parent?this.sep:"",D=this.#E?this.#E+b+s:void 0,A=this.newChild(s,bT,{...l,parent:this,fullpath:D});return this.canReaddir()||(A.#o|=PE),_.push(A),A}relative(){if(this.isCWD)return"";if(this.#D!==void 0)return this.#D;let s=this.name,l=this.parent;if(!l)return this.#D=this.name;let _=l.relative();return _+(!_||!l.parent?"":this.sep)+s}relativePosix(){if(this.sep==="/")return this.relative();if(this.isCWD)return"";if(this.#w!==void 0)return this.#w;let s=this.name,l=this.parent;if(!l)return this.#w=this.fullpathPosix();let _=l.relativePosix();return _+(!_||!l.parent?"":"/")+s}fullpath(){if(this.#E!==void 0)return this.#E;let s=this.name,l=this.parent;if(!l)return this.#E=this.name;let m=l.fullpath()+(l.parent?this.sep:"")+s;return this.#E=m}fullpathPosix(){if(this.#y!==void 0)return this.#y;if(this.sep==="/")return this.#y=this.fullpath();if(!this.parent){let m=this.fullpath().replace(/\\/g,"/");return/^[a-z]:\//i.test(m)?this.#y=`//?/${m}`:this.#y=m}let s=this.parent,l=s.fullpathPosix(),_=l+(!l||!s.parent?"":"/")+this.name;return this.#y=_}isUnknown(){return(this.#o&vT)===bT}isType(s){return this[`is${s}`]()}getType(){return this.isUnknown()?"Unknown":this.isDirectory()?"Directory":this.isFile()?"File":this.isSymbolicLink()?"SymbolicLink":this.isFIFO()?"FIFO":this.isCharacterDevice()?"CharacterDevice":this.isBlockDevice()?"BlockDevice":this.isSocket()?"Socket":"Unknown"}isFile(){return(this.#o&vT)===oot}isDirectory(){return(this.#o&vT)===GD}isCharacterDevice(){return(this.#o&vT)===sot}isBlockDevice(){return(this.#o&vT)===aot}isFIFO(){return(this.#o&vT)===iot}isSocket(){return(this.#o&vT)===cot}isSymbolicLink(){return(this.#o&xO)===xO}lstatCached(){return this.#o&Qat?this:void 0}readlinkCached(){return this.#S}realpathCached(){return this.#T}readdirCached(){let s=this.children();return s.slice(0,s.provisional)}canReadlink(){if(this.#S)return!0;if(!this.parent)return!1;let s=this.#o&vT;return!(s!==bT&&s!==xO||this.#o&Oce||this.#o&PE)}calledReaddir(){return!!(this.#o&h6e)}isENOENT(){return!!(this.#o&PE)}isNamed(s){return this.nocase?this.#b===Fce(s):this.#b===DH(s)}async readlink(){let s=this.#S;if(s)return s;if(this.canReadlink()&&this.parent)try{let l=await this.#r.promises.readlink(this.fullpath()),_=(await this.parent.realpath())?.resolve(l);if(_)return this.#S=_}catch(l){this.#h(l.code);return}}readlinkSync(){let s=this.#S;if(s)return s;if(this.canReadlink()&&this.parent)try{let l=this.#r.readlinkSync(this.fullpath()),_=this.parent.realpathSync()?.resolve(l);if(_)return this.#S=_}catch(l){this.#h(l.code);return}}#F(s){this.#o|=h6e;for(let l=s.provisional;l<s.length;l++){let _=s[l];_&&_.#L()}}#L(){this.#o&PE||(this.#o=(this.#o|PE)&xH,this.#P())}#P(){let s=this.children();s.provisional=0;for(let l of s)l.#L()}#A(){this.#o|=Lce,this.#R()}#R(){if(this.#o&CH)return;let s=this.#o;(s&vT)===GD&&(s&=xH),this.#o=s|CH,this.#P()}#M(s=""){s==="ENOTDIR"||s==="EPERM"?this.#R():s==="ENOENT"?this.#L():this.children().provisional=0}#j(s=""){s==="ENOTDIR"?this.parent.#R():s==="ENOENT"&&this.#L()}#h(s=""){let l=this.#o;l|=Oce,s==="ENOENT"&&(l|=PE),(s==="EINVAL"||s==="UNKNOWN")&&(l&=xH),this.#o=l,s==="ENOTDIR"&&this.parent&&this.parent.#R()}#B(s,l){return this.#O(s,l)||this.#U(s,l)}#U(s,l){let _=g6e(s),m=this.newChild(s.name,_,{parent:this}),b=m.#o&vT;return b!==GD&&b!==xO&&b!==bT&&(m.#o|=CH),l.unshift(m),l.provisional++,m}#O(s,l){for(let _=l.provisional;_<l.length;_++){let m=l[_];if((this.nocase?Fce(s.name):DH(s.name))===m.#b)return this.#$(s,m,_,l)}}#$(s,l,_,m){let b=l.name;return l.#o=l.#o&xH|g6e(s),b!==s.name&&(l.name=s.name),_!==m.provisional&&(_===m.length-1?m.pop():m.splice(_,1),m.unshift(l)),m.provisional++,l}async lstat(){if(!(this.#o&PE))try{return this.#V(await this.#r.promises.lstat(this.fullpath())),this}catch(s){this.#j(s.code)}}lstatSync(){if(!(this.#o&PE))try{return this.#V(this.#r.lstatSync(this.fullpath())),this}catch(s){this.#j(s.code)}}#V(s){let{atime:l,atimeMs:_,birthtime:m,birthtimeMs:b,blksize:D,blocks:A,ctime:M,ctimeMs:U,dev:ie,gid:se,ino:Z,mode:Re,mtime:Pe,mtimeMs:ke,nlink:wt,rdev:At,size:yr,uid:zr}=s;this.#m=l,this.#f=_,this.#x=m,this.#u=b,this.#_=D,this.#i=A,this.#C=M,this.#d=U,this.#n=ie,this.#p=se,this.#c=Z,this.#e=Re,this.#g=Pe,this.#v=ke,this.#t=wt,this.#a=At,this.#l=yr,this.#s=zr;let en=g6e(s);this.#o=this.#o&xH|en|Qat,en!==bT&&en!==GD&&en!==xO&&(this.#o|=CH)}#z=[];#q=!1;#W(s){this.#q=!1;let l=this.#z.slice();this.#z.length=0,l.forEach(_=>_(null,s))}readdirCB(s,l=!1){if(!this.canReaddir()){l?s(null,[]):queueMicrotask(()=>s(null,[]));return}let _=this.children();if(this.calledReaddir()){let b=_.slice(0,_.provisional);l?s(null,b):queueMicrotask(()=>s(null,b));return}if(this.#z.push(s),this.#q)return;this.#q=!0;let m=this.fullpath();this.#r.readdir(m,{withFileTypes:!0},(b,D)=>{if(b)this.#M(b.code),_.provisional=0;else{for(let A of D)this.#B(A,_);this.#F(_)}this.#W(_.slice(0,_.provisional))})}#J;async readdir(){if(!this.canReaddir())return[];let s=this.children();if(this.calledReaddir())return s.slice(0,s.provisional);let l=this.fullpath();if(this.#J)await this.#J;else{let _=t(()=>{},"resolve");this.#J=new Promise(m=>_=m);try{for(let m of await this.#r.promises.readdir(l,{withFileTypes:!0}))this.#B(m,s);this.#F(s)}catch(m){this.#M(m.code),s.provisional=0}this.#J=void 0,_()}return s.slice(0,s.provisional)}readdirSync(){if(!this.canReaddir())return[];let s=this.children();if(this.calledReaddir())return s.slice(0,s.provisional);let l=this.fullpath();try{for(let _ of this.#r.readdirSync(l,{withFileTypes:!0}))this.#B(_,s);this.#F(s)}catch(_){this.#M(_.code),s.provisional=0}return s.slice(0,s.provisional)}canReaddir(){if(this.#o&Zat)return!1;let s=vT&this.#o;return s===bT||s===GD||s===xO}shouldWalk(s,l){return(this.#o&GD)===GD&&!(this.#o&Zat)&&!s.has(this)&&(!l||l(this))}async realpath(){if(this.#T)return this.#T;if(!((Lce|Oce|PE)&this.#o))try{let s=await this.#r.promises.realpath(this.fullpath());return this.#T=this.resolve(s)}catch{this.#A()}}realpathSync(){if(this.#T)return this.#T;if(!((Lce|Oce|PE)&this.#o))try{let s=this.#r.realpathSync(this.fullpath());return this.#T=this.resolve(s)}catch{this.#A()}}[lot](s){if(s===this)return;s.isCWD=!1,this.isCWD=!0;let l=new Set([]),_=[],m=this;for(;m&&m.parent;)l.add(m),m.#D=_.join(this.sep),m.#w=_.join("/"),m=m.parent,_.push("..");for(m=s;m&&m.parent&&!l.has(m);)m.#D=void 0,m.#w=void 0,m=m.parent}},Mce=class a extends Iy{static{t(this,"PathWin32")}sep="\\";splitSep=VZt;constructor(s,l=bT,_,m,b,D,A){super(s,l,_,m,b,D,A)}newChild(s,l=bT,_={}){return new a(s,l,this.root,this.roots,this.nocase,this.childrenCache(),_)}getRootString(s){return y6e.parse(s).root}getRoot(s){if(s=qZt(s.toUpperCase()),s===this.root.name)return this.root;for(let[l,_]of Object.entries(this.roots))if(this.sameRoot(s,l))return this.roots[s]=_;return this.roots[s]=new iM(s,this).root}sameRoot(s,l=this.root.name){return s=s.toUpperCase().replace(/\//g,"\\").replace(not,"$1\\"),s===l}},jce=class a extends Iy{static{t(this,"PathPosix")}splitSep="/";sep="/";constructor(s,l=bT,_,m,b,D,A){super(s,l,_,m,b,D,A)}getRootString(s){return s.startsWith("/")?"/":""}getRoot(s){return this.root}newChild(s,l=bT,_={}){return new a(s,l,this.root,this.roots,this.nocase,this.childrenCache(),_)}},Bce=class{static{t(this,"PathScurryBase")}root;rootPath;roots;cwd;#r;#n;#e;nocase;#t;constructor(s=process.cwd(),l,_,{nocase:m,childrenCacheSize:b=16*1024,fs:D=EH}={}){this.#t=rot(D),(s instanceof URL||s.startsWith("file://"))&&(s=IZt(s));let A=l.resolve(s);this.roots=Object.create(null),this.rootPath=this.parseRootPath(A),this.#r=new Rce,this.#n=new Rce,this.#e=new v6e(b);let M=A.substring(this.rootPath.length).split(_);if(M.length===1&&!M[0]&&M.pop(),m===void 0)throw new TypeError("must provide nocase setting to PathScurryBase ctor");this.nocase=m,this.root=this.newRoot(this.#t),this.roots[this.rootPath]=this.root;let U=this.root,ie=M.length-1,se=l.sep,Z=this.rootPath,Re=!1;for(let Pe of M){let ke=ie--;U=U.child(Pe,{relative:new Array(ke).fill("..").join(se),relativePosix:new Array(ke).fill("..").join("/"),fullpath:Z+=(Re?"":se)+Pe}),Re=!0}this.cwd=U}depth(s=this.cwd){return typeof s=="string"&&(s=this.cwd.resolve(s)),s.depth()}childrenCache(){return this.#e}resolve(...s){let l="";for(let b=s.length-1;b>=0;b--){let D=s[b];if(!(!D||D===".")&&(l=l?`${D}/${l}`:D,this.isAbsolute(D)))break}let _=this.#r.get(l);if(_!==void 0)return _;let m=this.cwd.resolve(l).fullpath();return this.#r.set(l,m),m}resolvePosix(...s){let l="";for(let b=s.length-1;b>=0;b--){let D=s[b];if(!(!D||D===".")&&(l=l?`${D}/${l}`:D,this.isAbsolute(D)))break}let _=this.#n.get(l);if(_!==void 0)return _;let m=this.cwd.resolve(l).fullpathPosix();return this.#n.set(l,m),m}relative(s=this.cwd){return typeof s=="string"&&(s=this.cwd.resolve(s)),s.relative()}relativePosix(s=this.cwd){return typeof s=="string"&&(s=this.cwd.resolve(s)),s.relativePosix()}basename(s=this.cwd){return typeof s=="string"&&(s=this.cwd.resolve(s)),s.name}dirname(s=this.cwd){return typeof s=="string"&&(s=this.cwd.resolve(s)),(s.parent||s).fullpath()}async readdir(s=this.cwd,l={withFileTypes:!0}){typeof s=="string"?s=this.cwd.resolve(s):s instanceof Iy||(l=s,s=this.cwd);let{withFileTypes:_}=l;if(s.canReaddir()){let m=await s.readdir();return _?m:m.map(b=>b.name)}else return[]}readdirSync(s=this.cwd,l={withFileTypes:!0}){typeof s=="string"?s=this.cwd.resolve(s):s instanceof Iy||(l=s,s=this.cwd);let{withFileTypes:_=!0}=l;return s.canReaddir()?_?s.readdirSync():s.readdirSync().map(m=>m.name):[]}async lstat(s=this.cwd){return typeof s=="string"&&(s=this.cwd.resolve(s)),s.lstat()}lstatSync(s=this.cwd){return typeof s=="string"&&(s=this.cwd.resolve(s)),s.lstatSync()}async readlink(s=this.cwd,{withFileTypes:l}={withFileTypes:!1}){typeof s=="string"?s=this.cwd.resolve(s):s instanceof Iy||(l=s.withFileTypes,s=this.cwd);let _=await s.readlink();return l?_:_?.fullpath()}readlinkSync(s=this.cwd,{withFileTypes:l}={withFileTypes:!1}){typeof s=="string"?s=this.cwd.resolve(s):s instanceof Iy||(l=s.withFileTypes,s=this.cwd);let _=s.readlinkSync();return l?_:_?.fullpath()}async realpath(s=this.cwd,{withFileTypes:l}={withFileTypes:!1}){typeof s=="string"?s=this.cwd.resolve(s):s instanceof Iy||(l=s.withFileTypes,s=this.cwd);let _=await s.realpath();return l?_:_?.fullpath()}realpathSync(s=this.cwd,{withFileTypes:l}={withFileTypes:!1}){typeof s=="string"?s=this.cwd.resolve(s):s instanceof Iy||(l=s.withFileTypes,s=this.cwd);let _=s.realpathSync();return l?_:_?.fullpath()}async walk(s=this.cwd,l={}){typeof s=="string"?s=this.cwd.resolve(s):s instanceof Iy||(l=s,s=this.cwd);let{withFileTypes:_=!0,follow:m=!1,filter:b,walkFilter:D}=l,A=[];(!b||b(s))&&A.push(_?s:s.fullpath());let M=new Set,U=t((se,Z)=>{M.add(se),se.readdirCB((Re,Pe)=>{if(Re)return Z(Re);let ke=Pe.length;if(!ke)return Z();let wt=t(()=>{--ke===0&&Z()},"next");for(let At of Pe)(!b||b(At))&&A.push(_?At:At.fullpath()),m&&At.isSymbolicLink()?At.realpath().then(yr=>yr?.isUnknown()?yr.lstat():yr).then(yr=>yr?.shouldWalk(M,D)?U(yr,wt):wt()):At.shouldWalk(M,D)?U(At,wt):wt()},!0)},"walk"),ie=s;return new Promise((se,Z)=>{U(ie,Re=>{if(Re)return Z(Re);se(A)})})}walkSync(s=this.cwd,l={}){typeof s=="string"?s=this.cwd.resolve(s):s instanceof Iy||(l=s,s=this.cwd);let{withFileTypes:_=!0,follow:m=!1,filter:b,walkFilter:D}=l,A=[];(!b||b(s))&&A.push(_?s:s.fullpath());let M=new Set([s]);for(let U of M){let ie=U.readdirSync();for(let se of ie){(!b||b(se))&&A.push(_?se:se.fullpath());let Z=se;if(se.isSymbolicLink()){if(!(m&&(Z=se.realpathSync())))continue;Z.isUnknown()&&Z.lstatSync()}Z.shouldWalk(M,D)&&M.add(Z)}}return A}[Symbol.asyncIterator](){return this.iterate()}iterate(s=this.cwd,l={}){return typeof s=="string"?s=this.cwd.resolve(s):s instanceof Iy||(l=s,s=this.cwd),this.stream(s,l)[Symbol.asyncIterator]()}[Symbol.iterator](){return this.iterateSync()}*iterateSync(s=this.cwd,l={}){typeof s=="string"?s=this.cwd.resolve(s):s instanceof Iy||(l=s,s=this.cwd);let{withFileTypes:_=!0,follow:m=!1,filter:b,walkFilter:D}=l;(!b||b(s))&&(yield _?s:s.fullpath());let A=new Set([s]);for(let M of A){let U=M.readdirSync();for(let ie of U){(!b||b(ie))&&(yield _?ie:ie.fullpath());let se=ie;if(ie.isSymbolicLink()){if(!(m&&(se=ie.realpathSync())))continue;se.isUnknown()&&se.lstatSync()}se.shouldWalk(A,D)&&A.add(se)}}}stream(s=this.cwd,l={}){typeof s=="string"?s=this.cwd.resolve(s):s instanceof Iy||(l=s,s=this.cwd);let{withFileTypes:_=!0,follow:m=!1,filter:b,walkFilter:D}=l,A=new r3({objectMode:!0});(!b||b(s))&&A.write(_?s:s.fullpath());let M=new Set,U=[s],ie=0,se=t(()=>{let Z=!1;for(;!Z;){let Re=U.shift();if(!Re){ie===0&&A.end();return}ie++,M.add(Re);let Pe=t((wt,At,yr=!1)=>{if(wt)return A.emit("error",wt);if(m&&!yr){let zr=[];for(let en of At)en.isSymbolicLink()&&zr.push(en.realpath().then(hn=>hn?.isUnknown()?hn.lstat():hn));if(zr.length){Promise.all(zr).then(()=>Pe(null,At,!0));return}}for(let zr of At)zr&&(!b||b(zr))&&(A.write(_?zr:zr.fullpath())||(Z=!0));ie--;for(let zr of At){let en=zr.realpathCached()||zr;en.shouldWalk(M,D)&&U.push(en)}Z&&!A.flowing?A.once("drain",se):ke||se()},"onReaddir"),ke=!0;Re.readdirCB(Pe,!0),ke=!1}},"process");return se(),A}streamSync(s=this.cwd,l={}){typeof s=="string"?s=this.cwd.resolve(s):s instanceof Iy||(l=s,s=this.cwd);let{withFileTypes:_=!0,follow:m=!1,filter:b,walkFilter:D}=l,A=new r3({objectMode:!0}),M=new Set;(!b||b(s))&&A.write(_?s:s.fullpath());let U=[s],ie=0,se=t(()=>{let Z=!1;for(;!Z;){let Re=U.shift();if(!Re){ie===0&&A.end();return}ie++,M.add(Re);let Pe=Re.readdirSync();for(let ke of Pe)(!b||b(ke))&&(A.write(_?ke:ke.fullpath())||(Z=!0));ie--;for(let ke of Pe){let wt=ke;if(ke.isSymbolicLink()){if(!(m&&(wt=ke.realpathSync())))continue;wt.isUnknown()&&wt.lstatSync()}wt.shouldWalk(M,D)&&U.push(wt)}}Z&&!A.flowing&&A.once("drain",se)},"process");return se(),A}chdir(s=this.cwd){let l=this.cwd;this.cwd=typeof s=="string"?this.cwd.resolve(s):s,this.cwd[lot](l)}},iM=class extends Bce{static{t(this,"PathScurryWin32")}sep="\\";constructor(s=process.cwd(),l={}){let{nocase:_=!0}=l;super(s,y6e,"\\",{...l,nocase:_}),this.nocase=_;for(let m=this.cwd;m;m=m.parent)m.nocase=this.nocase}parseRootPath(s){return y6e.parse(s).root.toUpperCase()}newRoot(s){return new Mce(this.rootPath,GD,void 0,this.roots,this.nocase,this.childrenCache(),{fs:s})}isAbsolute(s){return s.startsWith("/")||s.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(s)}},sM=class extends Bce{static{t(this,"PathScurryPosix")}sep="/";constructor(s=process.cwd(),l={}){let{nocase:_=!1}=l;super(s,NZt,"/",{...l,nocase:_}),this.nocase=_}parseRootPath(s){return"/"}newRoot(s){return new jce(this.rootPath,GD,void 0,this.roots,this.nocase,this.childrenCache(),{fs:s})}isAbsolute(s){return s.startsWith("/")}},kH=class extends sM{static{t(this,"PathScurryDarwin")}constructor(s=process.cwd(),l={}){let{nocase:_=!0}=l;super(s,{...l,nocase:_})}},x4r=process.platform==="win32"?Mce:jce,uot=process.platform==="win32"?iM:process.platform==="darwin"?kH:sM;var HZt=t(a=>a.length>=1,"isPatternList"),GZt=t(a=>a.length>=1,"isGlobList"),aM=class a{static{t(this,"Pattern")}#r;#n;#e;length;#t;#s;#p;#a;#_;#c;#l=!0;constructor(s,l,_,m){if(!HZt(s))throw new TypeError("empty pattern list");if(!GZt(l))throw new TypeError("empty glob list");if(l.length!==s.length)throw new TypeError("mismatched pattern list and glob list lengths");if(this.length=s.length,_<0||_>=this.length)throw new TypeError("index out of range");if(this.#r=s,this.#n=l,this.#e=_,this.#t=m,this.#e===0){if(this.isUNC()){let[b,D,A,M,...U]=this.#r,[ie,se,Z,Re,...Pe]=this.#n;U[0]===""&&(U.shift(),Pe.shift());let ke=[b,D,A,M,""].join("/"),wt=[ie,se,Z,Re,""].join("/");this.#r=[ke,...U],this.#n=[wt,...Pe],this.length=this.#r.length}else if(this.isDrive()||this.isAbsolute()){let[b,...D]=this.#r,[A,...M]=this.#n;D[0]===""&&(D.shift(),M.shift());let U=b+"/",ie=A+"/";this.#r=[U,...D],this.#n=[ie,...M],this.length=this.#r.length}}}pattern(){return this.#r[this.#e]}isString(){return typeof this.#r[this.#e]=="string"}isGlobstar(){return this.#r[this.#e]===F0}isRegExp(){return this.#r[this.#e]instanceof RegExp}globString(){return this.#p=this.#p||(this.#e===0?this.isAbsolute()?this.#n[0]+this.#n.slice(1).join("/"):this.#n.join("/"):this.#n.slice(this.#e).join("/"))}hasMore(){return this.length>this.#e+1}rest(){return this.#s!==void 0?this.#s:this.hasMore()?(this.#s=new a(this.#r,this.#n,this.#e+1,this.#t),this.#s.#c=this.#c,this.#s.#_=this.#_,this.#s.#a=this.#a,this.#s):this.#s=null}isUNC(){let s=this.#r;return this.#_!==void 0?this.#_:this.#_=this.#t==="win32"&&this.#e===0&&s[0]===""&&s[1]===""&&typeof s[2]=="string"&&!!s[2]&&typeof s[3]=="string"&&!!s[3]}isDrive(){let s=this.#r;return this.#a!==void 0?this.#a:this.#a=this.#t==="win32"&&this.#e===0&&this.length>1&&typeof s[0]=="string"&&/^[a-z]:$/i.test(s[0])}isAbsolute(){let s=this.#r;return this.#c!==void 0?this.#c:this.#c=s[0]===""&&s.length>1||this.isDrive()||this.isUNC()}root(){let s=this.#r[0];return typeof s=="string"&&this.isAbsolute()&&this.#e===0?s:""}checkFollowGlobstar(){return!(this.#e===0||!this.isGlobstar()||!this.#l)}markFollowGlobstar(){return this.#e===0||!this.isGlobstar()||!this.#l?!1:(this.#l=!1,!0)}};var KZt=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",oM=class{static{t(this,"Ignore")}relative;relativeChildren;absolute;absoluteChildren;platform;mmopts;constructor(s,{nobrace:l,nocase:_,noext:m,noglobstar:b,platform:D=KZt}){this.relative=[],this.absolute=[],this.relativeChildren=[],this.absoluteChildren=[],this.platform=D,this.mmopts={dot:!0,nobrace:l,nocase:_,noext:m,noglobstar:b,optimizationLevel:2,platform:D,nocomment:!0,nonegate:!0};for(let A of s)this.add(A)}add(s){let l=new B2(s,this.mmopts);for(let _=0;_<l.set.length;_++){let m=l.set[_],b=l.globParts[_];if(!m||!b)throw new Error("invalid pattern object");for(;m[0]==="."&&b[0]===".";)m.shift(),b.shift();let D=new aM(m,b,0,this.platform),A=new B2(D.globString(),this.mmopts),M=b[b.length-1]==="**",U=D.isAbsolute();U?this.absolute.push(A):this.relative.push(A),M&&(U?this.absoluteChildren.push(A):this.relativeChildren.push(A))}}ignored(s){let l=s.fullpath(),_=`${l}/`,m=s.relative()||".",b=`${m}/`;for(let D of this.relative)if(D.match(m)||D.match(b))return!0;for(let D of this.absolute)if(D.match(l)||D.match(_))return!0;return!1}childrenIgnored(s){let l=s.fullpath()+"/",_=(s.relative()||".")+"/";for(let m of this.relativeChildren)if(m.match(_))return!0;for(let m of this.absoluteChildren)if(m.match(l))return!0;return!1}};var b6e=class a{static{t(this,"HasWalkedCache")}store;constructor(s=new Map){this.store=s}copy(){return new a(new Map(this.store))}hasWalked(s,l){return this.store.get(s.fullpath())?.has(l.globString())}storeWalked(s,l){let _=s.fullpath(),m=this.store.get(_);m?m.add(l.globString()):this.store.set(_,new Set([l.globString()]))}},S6e=class{static{t(this,"MatchRecord")}store=new Map;add(s,l,_){let m=(l?2:0)|(_?1:0),b=this.store.get(s);this.store.set(s,b===void 0?m:m&b)}entries(){return[...this.store.entries()].map(([s,l])=>[s,!!(l&2),!!(l&1)])}},T6e=class{static{t(this,"SubWalks")}store=new Map;add(s,l){if(!s.canReaddir())return;let _=this.store.get(s);_?_.find(m=>m.globString()===l.globString())||_.push(l):this.store.set(s,[l])}get(s){let l=this.store.get(s);if(!l)throw new Error("attempting to walk unknown path");return l}entries(){return this.keys().map(s=>[s,this.store.get(s)])}keys(){return[...this.store.keys()].filter(s=>s.canReaddir())}},wH=class a{static{t(this,"Processor")}hasWalkedCache;matches=new S6e;subwalks=new T6e;patterns;follow;dot;opts;constructor(s,l){this.opts=s,this.follow=!!s.follow,this.dot=!!s.dot,this.hasWalkedCache=l?l.copy():new b6e}processPatterns(s,l){this.patterns=l;let _=l.map(m=>[s,m]);for(let[m,b]of _){this.hasWalkedCache.storeWalked(m,b);let D=b.root(),A=b.isAbsolute()&&this.opts.absolute!==!1;if(D){m=m.resolve(D==="/"&&this.opts.root!==void 0?this.opts.root:D);let se=b.rest();if(se)b=se;else{this.matches.add(m,!0,!1);continue}}if(m.isENOENT())continue;let M,U,ie=!1;for(;typeof(M=b.pattern())=="string"&&(U=b.rest());)m=m.resolve(M),b=U,ie=!0;if(M=b.pattern(),U=b.rest(),ie){if(this.hasWalkedCache.hasWalked(m,b))continue;this.hasWalkedCache.storeWalked(m,b)}if(typeof M=="string"){let se=M===".."||M===""||M===".";this.matches.add(m.resolve(M),A,se);continue}else if(M===F0){(!m.isSymbolicLink()||this.follow||b.checkFollowGlobstar())&&this.subwalks.add(m,b);let se=U?.pattern(),Z=U?.rest();if(!U||(se===""||se===".")&&!Z)this.matches.add(m,A,se===""||se===".");else if(se===".."){let Re=m.parent||m;Z?this.hasWalkedCache.hasWalked(Re,Z)||this.subwalks.add(Re,Z):this.matches.add(Re,A,!0)}}else M instanceof RegExp&&this.subwalks.add(m,b)}return this}subwalkTargets(){return this.subwalks.keys()}child(){return new a(this.opts,this.hasWalkedCache)}filterEntries(s,l){let _=this.subwalks.get(s),m=this.child();for(let b of l)for(let D of _){let A=D.isAbsolute(),M=D.pattern(),U=D.rest();M===F0?m.testGlobstar(b,D,U,A):M instanceof RegExp?m.testRegExp(b,M,U,A):m.testString(b,M,U,A)}return m}testGlobstar(s,l,_,m){if((this.dot||!s.name.startsWith("."))&&(l.hasMore()||this.matches.add(s,m,!1),s.canReaddir()&&(this.follow||!s.isSymbolicLink()?this.subwalks.add(s,l):s.isSymbolicLink()&&(_&&l.checkFollowGlobstar()?this.subwalks.add(s,_):l.markFollowGlobstar()&&this.subwalks.add(s,l)))),_){let b=_.pattern();if(typeof b=="string"&&b!==".."&&b!==""&&b!==".")this.testString(s,b,_.rest(),m);else if(b===".."){let D=s.parent||s;this.subwalks.add(D,_)}else b instanceof RegExp&&this.testRegExp(s,b,_.rest(),m)}}testRegExp(s,l,_,m){l.test(s.name)&&(_?this.subwalks.add(s,_):this.matches.add(s,m,!1))}testString(s,l,_,m){s.isNamed(l)&&(_?this.subwalks.add(s,_):this.matches.add(s,m,!1))}};var YZt=t((a,s)=>typeof a=="string"?new oM([a],s):Array.isArray(a)?new oM(a,s):a,"makeIgnore"),Uce=class{static{t(this,"GlobUtil")}path;patterns;opts;seen=new Set;paused=!1;aborted=!1;#r=[];#n;#e;signal;maxDepth;includeChildMatches;constructor(s,l,_){if(this.patterns=s,this.path=l,this.opts=_,this.#e=!_.posix&&_.platform==="win32"?"\\":"/",this.includeChildMatches=_.includeChildMatches!==!1,(_.ignore||!this.includeChildMatches)&&(this.#n=YZt(_.ignore??[],_),!this.includeChildMatches&&typeof this.#n.add!="function")){let m="cannot ignore child matches, ignore lacks add() method.";throw new Error(m)}this.maxDepth=_.maxDepth||1/0,_.signal&&(this.signal=_.signal,this.signal.addEventListener("abort",()=>{this.#r.length=0}))}#t(s){return this.seen.has(s)||!!this.#n?.ignored?.(s)}#s(s){return!!this.#n?.childrenIgnored?.(s)}pause(){this.paused=!0}resume(){if(this.signal?.aborted)return;this.paused=!1;let s;for(;!this.paused&&(s=this.#r.shift());)s()}onResume(s){this.signal?.aborted||(this.paused?this.#r.push(s):s())}async matchCheck(s,l){if(l&&this.opts.nodir)return;let _;if(this.opts.realpath){if(_=s.realpathCached()||await s.realpath(),!_)return;s=_}let b=s.isUnknown()||this.opts.stat?await s.lstat():s;if(this.opts.follow&&this.opts.nodir&&b?.isSymbolicLink()){let D=await b.realpath();D&&(D.isUnknown()||this.opts.stat)&&await D.lstat()}return this.matchCheckTest(b,l)}matchCheckTest(s,l){return s&&(this.maxDepth===1/0||s.depth()<=this.maxDepth)&&(!l||s.canReaddir())&&(!this.opts.nodir||!s.isDirectory())&&(!this.opts.nodir||!this.opts.follow||!s.isSymbolicLink()||!s.realpathCached()?.isDirectory())&&!this.#t(s)?s:void 0}matchCheckSync(s,l){if(l&&this.opts.nodir)return;let _;if(this.opts.realpath){if(_=s.realpathCached()||s.realpathSync(),!_)return;s=_}let b=s.isUnknown()||this.opts.stat?s.lstatSync():s;if(this.opts.follow&&this.opts.nodir&&b?.isSymbolicLink()){let D=b.realpathSync();D&&(D?.isUnknown()||this.opts.stat)&&D.lstatSync()}return this.matchCheckTest(b,l)}matchFinish(s,l){if(this.#t(s))return;if(!this.includeChildMatches&&this.#n?.add){let b=`${s.relativePosix()}/**`;this.#n.add(b)}let _=this.opts.absolute===void 0?l:this.opts.absolute;this.seen.add(s);let m=this.opts.mark&&s.isDirectory()?this.#e:"";if(this.opts.withFileTypes)this.matchEmit(s);else if(_){let b=this.opts.posix?s.fullpathPosix():s.fullpath();this.matchEmit(b+m)}else{let b=this.opts.posix?s.relativePosix():s.relative(),D=this.opts.dotRelative&&!b.startsWith(".."+this.#e)?"."+this.#e:"";this.matchEmit(b?D+b+m:"."+m)}}async match(s,l,_){let m=await this.matchCheck(s,_);m&&this.matchFinish(m,l)}matchSync(s,l,_){let m=this.matchCheckSync(s,_);m&&this.matchFinish(m,l)}walkCB(s,l,_){this.signal?.aborted&&_(),this.walkCB2(s,l,new wH(this.opts),_)}walkCB2(s,l,_,m){if(this.#s(s))return m();if(this.signal?.aborted&&m(),this.paused){this.onResume(()=>this.walkCB2(s,l,_,m));return}_.processPatterns(s,l);let b=1,D=t(()=>{--b===0&&m()},"next");for(let[A,M,U]of _.matches.entries())this.#t(A)||(b++,this.match(A,M,U).then(()=>D()));for(let A of _.subwalkTargets()){if(this.maxDepth!==1/0&&A.depth()>=this.maxDepth)continue;b++;let M=A.readdirCached();A.calledReaddir()?this.walkCB3(A,M,_,D):A.readdirCB((U,ie)=>this.walkCB3(A,ie,_,D),!0)}D()}walkCB3(s,l,_,m){_=_.filterEntries(s,l);let b=1,D=t(()=>{--b===0&&m()},"next");for(let[A,M,U]of _.matches.entries())this.#t(A)||(b++,this.match(A,M,U).then(()=>D()));for(let[A,M]of _.subwalks.entries())b++,this.walkCB2(A,M,_.child(),D);D()}walkCBSync(s,l,_){this.signal?.aborted&&_(),this.walkCB2Sync(s,l,new wH(this.opts),_)}walkCB2Sync(s,l,_,m){if(this.#s(s))return m();if(this.signal?.aborted&&m(),this.paused){this.onResume(()=>this.walkCB2Sync(s,l,_,m));return}_.processPatterns(s,l);let b=1,D=t(()=>{--b===0&&m()},"next");for(let[A,M,U]of _.matches.entries())this.#t(A)||this.matchSync(A,M,U);for(let A of _.subwalkTargets()){if(this.maxDepth!==1/0&&A.depth()>=this.maxDepth)continue;b++;let M=A.readdirSync();this.walkCB3Sync(A,M,_,D)}D()}walkCB3Sync(s,l,_,m){_=_.filterEntries(s,l);let b=1,D=t(()=>{--b===0&&m()},"next");for(let[A,M,U]of _.matches.entries())this.#t(A)||this.matchSync(A,M,U);for(let[A,M]of _.subwalks.entries())b++,this.walkCB2Sync(A,M,_.child(),D);D()}},PH=class extends Uce{static{t(this,"GlobWalker")}matches=new Set;constructor(s,l,_){super(s,l,_)}matchEmit(s){this.matches.add(s)}async walk(){if(this.signal?.aborted)throw this.signal.reason;return this.path.isUnknown()&&await this.path.lstat(),await new Promise((s,l)=>{this.walkCB(this.path,this.patterns,()=>{this.signal?.aborted?l(this.signal.reason):s(this.matches)})}),this.matches}walkSync(){if(this.signal?.aborted)throw this.signal.reason;return this.path.isUnknown()&&this.path.lstatSync(),this.walkCBSync(this.path,this.patterns,()=>{if(this.signal?.aborted)throw this.signal.reason}),this.matches}},AH=class extends Uce{static{t(this,"GlobStream")}results;constructor(s,l,_){super(s,l,_),this.results=new r3({signal:this.signal,objectMode:!0}),this.results.on("drain",()=>this.resume()),this.results.on("resume",()=>this.resume())}matchEmit(s){this.results.write(s),this.results.flowing||this.pause()}stream(){let s=this.path;return s.isUnknown()?s.lstat().then(()=>{this.walkCB(s,this.patterns,()=>this.results.end())}):this.walkCB(s,this.patterns,()=>this.results.end()),this.results}streamSync(){return this.path.isUnknown()&&this.path.lstatSync(),this.walkCBSync(this.path,this.patterns,()=>this.results.end()),this.results}};var QZt=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",AE=class{static{t(this,"Glob")}absolute;cwd;root;dot;dotRelative;follow;ignore;magicalBraces;mark;matchBase;maxDepth;nobrace;nocase;nodir;noext;noglobstar;pattern;platform;realpath;scurry;stat;signal;windowsPathsNoEscape;withFileTypes;includeChildMatches;opts;patterns;constructor(s,l){if(!l)throw new TypeError("glob options required");if(this.withFileTypes=!!l.withFileTypes,this.signal=l.signal,this.follow=!!l.follow,this.dot=!!l.dot,this.dotRelative=!!l.dotRelative,this.nodir=!!l.nodir,this.mark=!!l.mark,l.cwd?(l.cwd instanceof URL||l.cwd.startsWith("file://"))&&(l.cwd=XZt(l.cwd)):this.cwd="",this.cwd=l.cwd||"",this.root=l.root,this.magicalBraces=!!l.magicalBraces,this.nobrace=!!l.nobrace,this.noext=!!l.noext,this.realpath=!!l.realpath,this.absolute=l.absolute,this.includeChildMatches=l.includeChildMatches!==!1,this.noglobstar=!!l.noglobstar,this.matchBase=!!l.matchBase,this.maxDepth=typeof l.maxDepth=="number"?l.maxDepth:1/0,this.stat=!!l.stat,this.ignore=l.ignore,this.withFileTypes&&this.absolute!==void 0)throw new Error("cannot set absolute and withFileTypes:true");if(typeof s=="string"&&(s=[s]),this.windowsPathsNoEscape=!!l.windowsPathsNoEscape||l.allowWindowsEscape===!1,this.windowsPathsNoEscape&&(s=s.map(M=>M.replace(/\\/g,"/"))),this.matchBase){if(l.noglobstar)throw new TypeError("base matching requires globstar");s=s.map(M=>M.includes("/")?M:`./**/${M}`)}if(this.pattern=s,this.platform=l.platform||QZt,this.opts={...l,platform:this.platform},l.scurry){if(this.scurry=l.scurry,l.nocase!==void 0&&l.nocase!==l.scurry.nocase)throw new Error("nocase option contradicts provided scurry option")}else{let M=l.platform==="win32"?iM:l.platform==="darwin"?kH:l.platform?sM:uot;this.scurry=new M(this.cwd,{nocase:l.nocase,fs:l.fs})}this.nocase=this.scurry.nocase;let _=this.platform==="darwin"||this.platform==="win32",m={...l,dot:this.dot,matchBase:this.matchBase,nobrace:this.nobrace,nocase:this.nocase,nocaseMagicOnly:_,nocomment:!0,noext:this.noext,nonegate:!0,optimizationLevel:2,platform:this.platform,windowsPathsNoEscape:this.windowsPathsNoEscape,debug:!!this.opts.debug},b=this.pattern.map(M=>new B2(M,m)),[D,A]=b.reduce((M,U)=>(M[0].push(...U.set),M[1].push(...U.globParts),M),[[],[]]);this.patterns=D.map((M,U)=>{let ie=A[U];if(!ie)throw new Error("invalid pattern object");return new aM(M,ie,0,this.platform)})}async walk(){return[...await new PH(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walk()]}walkSync(){return[...new PH(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walkSync()]}stream(){return new AH(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).stream()}streamSync(){return new AH(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).streamSync()}iterateSync(){return this.streamSync()[Symbol.iterator]()}[Symbol.iterator](){return this.iterateSync()}iterate(){return this.stream()[Symbol.asyncIterator]()}[Symbol.asyncIterator](){return this.iterate()}};var x6e=t((a,s={})=>{Array.isArray(a)||(a=[a]);for(let l of a)if(new B2(l,s).hasMagic())return!0;return!1},"hasMagic");function $ce(a,s={}){return new AE(a,s).streamSync()}t($ce,"globStreamSync");function _ot(a,s={}){return new AE(a,s).stream()}t(_ot,"globStream");function pot(a,s={}){return new AE(a,s).walkSync()}t(pot,"globSync");async function fot(a,s={}){return new AE(a,s).walk()}t(fot,"glob_");function Jce(a,s={}){return new AE(a,s).iterateSync()}t(Jce,"globIterateSync");function dot(a,s={}){return new AE(a,s).iterate()}t(dot,"globIterate");var ZZt=$ce,eer=Object.assign(_ot,{sync:$ce}),ter=Jce,rer=Object.assign(dot,{sync:Jce}),ner=Object.assign(pot,{stream:$ce,iterate:Jce}),NH=Object.assign(fot,{glob:fot,globSync:pot,sync:ner,globStream:_ot,stream:eer,globStreamSync:$ce,streamSync:ZZt,globIterate:dot,iterate:rer,globIterateSync:Jce,iterateSync:ter,Glob:AE,hasMagic:x6e,escape:ZR,unescape:kE});NH.glob=NH;import Jfe from"fs";import e7e from"path";var U1=class extends Error{static{t(this,"CompilationError")}buildMessages;constructor(s){super("An error occurred during compilation."),this.buildMessages=Array.isArray(s)?s:[s]}toBuildResult(){return{content:"",errors:this.buildMessages}}};var ier="[",ser="]",aer="{",oer="}",cer=":",ler=",",uer="true",fer="false",_er="null",per="NaN",der="Infinity",C6e='"',IH=new Map([[34,C6e],[92,"\\"],[47,"/"],[98,"\b"],[110,`
558
558
  `],[102,"\f"],[114,"\r"],[116," "]]),Vce=new Map([...IH,[118,"\v"],[48,"\0"]]),mer=new Map([[C6e,C6e],["\\","\\"],["/","/"],["\b","b"],[`
559
559
  `,"n"],["\f","f"],["\r","r"],[" ","t"]]),c3r=new Map([...mer,["\v","v"],["\0","0"],["\u2028","u2028"],["\u2029","u2029"]]),qce=new Map([[ier,"LBracket"],[ser,"RBracket"],[aer,"LBrace"],[oer,"RBrace"],[cer,"Colon"],[ler,"Comma"],[uer,"Boolean"],[fer,"Boolean"],[_er,"Null"]]),zce=new Map([...qce,[per,"Number"],[der,"Number"]]),D6e=new Set([10,13,8232,8233]),XP=class extends Error{static{t(this,"ErrorWithLocation")}constructor(s,{line:l,column:_,offset:m}){super(`${s} (${l}:${_})`),this.line=l,this.column=_,this.offset=m}},k6e=class extends XP{static{t(this,"UnexpectedChar")}constructor(s,l){super(`Unexpected character '${String.fromCharCode(s)}' found.`,l)}},w6e=class extends XP{static{t(this,"UnexpectedIdentifier")}constructor(s,l){super(`Unexpected identifier '${s}' found.`,l)}},EO=class extends XP{static{t(this,"UnexpectedToken")}constructor(s){super(`Unexpected token ${s.type} found.`,s.loc.start)}},Wce=class extends XP{static{t(this,"UnexpectedEOF")}constructor(s){super("Unexpected end of input found.",s)}},her=/[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCA0-\uDCDF\uDCFF\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE83\uDE86-\uDE89\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]/,ger=/[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u08D4-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u09FC\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9-\u0AFF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C80-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D00-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1CD0-\u1CD2\u1CD4-\u1CF9\u1D00-\u1DF9\u1DFB-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDCA-\uDDCC\uDDD0-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE3E\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC00-\uDC4A\uDC50-\uDC59\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9\uDF00-\uDF19\uDF1D-\uDF2B\uDF30-\uDF39]|\uD806[\uDCA0-\uDCE9\uDCFF\uDE00-\uDE3E\uDE47\uDE50-\uDE83\uDE86-\uDE99\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC36\uDC38-\uDC40\uDC50-\uDC59\uDC72-\uDC8F\uDC92-\uDCA7\uDCA9-\uDCB6\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD47\uDD50-\uDD59]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6\uDD00-\uDD4A\uDD50-\uDD59]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]/,yer=13,mot=10,P6e=class{static{t(this,"CharCodeReader")}#r="";#n=1;#e=0;#t=-1;#s=!1;#p=-1;#a=!1;constructor(s){this.#r=s}#_(){this.#a||(this.#e++,this.#t++,this.#p=-1,this.#a=!0)}locate(){return{line:this.#n,column:this.#e,offset:this.#t}}next(){if(this.#t>=this.#r.length-1)return this.#_(),-1;this.#t++;let s=this.#r.charCodeAt(this.#t);return this.#s?(this.#n++,this.#e=1,this.#s=!1):this.#e++,s===yer?(this.#s=!0,this.peek()===mot&&this.#t++):s===mot&&(this.#s=!0),this.#p=s,s}peek(){return this.#t===this.#r.length-1?-1:this.#r.charCodeAt(this.#t+1)}match(s){return s(this.peek())?(this.next(),!0):!1}current(){return this.#p}},ver="Infinity",ber="NaN",Ser=new Set([116,102,110]),A6e=new Set([32,9,10,13]),hot=new Set([...A6e,11,12,160,8232,8233,65279,160,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288]),Ter={mode:"json",ranges:!1},xer=new Set(["true","false","null"]),x_={EOF:0,Number:1,String:2,Boolean:3,Null:4,NaN:5,Infinity:6,Identifier:7,Colon:20,LBrace:21,RBrace:22,LBracket:23,RBracket:24,Comma:25,LineComment:40,BlockComment:41};function YP(a){return a>=48&&a<=57}t(YP,"isDigit");function E6e(a){return YP(a)||a>=65&&a<=70||a>=97&&a<=102}t(E6e,"isHexDigit");function Eer(a){return a>=49&&a<=57}t(Eer,"isPositiveDigit");function Cer(a){return Ser.has(a)}t(Cer,"isKeywordStart");function yot(a){return YP(a)||a===46||a===45}t(yot,"isNumberStart");function Der(a){return yot(a)||a===43}t(Der,"isJSON5NumberStart");function got(a,s){return a===34||s&&a===39}t(got,"isStringStart");function vot(a){if(a===36||a===95||a===92||a>=97&&a<=122||a>=65&&a<=90||a===8204||a===8205)return!0;let s=String.fromCharCode(a);return her.test(s)}t(vot,"isJSON5IdentifierStart");function ker(a){if(vot(a)||YP(a))return!0;let s=String.fromCharCode(a);return ger.test(s)}t(ker,"isJSON5IdentifierPart");var N6e=class{static{t(this,"Tokenizer")}#r;#n;#e;#t;#s;#p;#a;#_;#c;#l;#i;constructor(s,l){this.#n=s,this.#r={...Ter,...l},this.#e=new P6e(s),this.#t=this.#r.mode==="json5",this.#s=this.#r.mode!=="json",this.#p=this.#r.ranges,this.#_=this.#t?Vce.has.bind(Vce):IH.has.bind(IH),this.#c=this.#t?D6e.has.bind(D6e):()=>!1,this.#l=this.#t?_=>_===120:()=>!1,this.#i=this.#t?hot.has.bind(hot):A6e.has.bind(A6e)}#f(s,l=this.#e.locate()){throw new k6e(s,l)}#v(s,l=this.#e.locate()){throw new w6e(s,l)}#d(){throw new Wce(this.#e.locate())}#u(s,l,_,m){let b=_.offset+l,D=this.#r.ranges?{range:[_.offset,b]}:void 0;return{type:s,loc:{start:_,end:m||{line:_.line,column:_.column+l,offset:b}},...D}}#m(s){let l="",_;for(let m=0;m<s;m++){if(_=this.#e.peek(),E6e(_)){this.#e.next(),l+=String.fromCharCode(_);continue}this.#f(_)}return l}#g(s){let l="";do{if(l+=String.fromCharCode(s),s===92&&(s=this.#e.next(),s!==117&&this.#f(s),l+=String.fromCharCode(s),l+=this.#m(4)),s=this.#e.peek(),!ker(s))break;this.#e.next()}while(!0);return l}#C(s){let l=s,_=1;for(s=this.#e.peek();s!==-1&&s!==l;){if(this.#e.next(),_++,s===92)if(s=this.#e.peek(),this.#_(s)||this.#c(s))this.#e.next(),_++;else if(s===117){this.#e.next(),_++;let m=this.#m(4);_+=m.length}else if(this.#l(s)){this.#e.next(),_++;let m=this.#m(2);_+=m.length}else this.#t?(this.#e.next(),_++):this.#f(s);s=this.#e.peek()}return s===-1&&(this.#e.next(),this.#d()),this.#e.next(),_++,_}#x(s){let l=1;if(s===45||this.#t&&s===43){if(s=this.#e.peek(),this.#t&&(s===73||s===78)){this.#e.next();let _=this.#g(s);return _!==ver&&_!==ber&&this.#f(s),l+_.length}YP(s)||this.#f(s),this.#e.next(),l++}if(s===48)if(s=this.#e.peek(),this.#t&&(s===120||s===88)){this.#e.next(),l++,s=this.#e.peek(),E6e(s)||(this.#e.next(),this.#f(s));do this.#e.next(),l++,s=this.#e.peek();while(E6e(s))}else YP(s)&&this.#f(s);else if(!this.#t||s!==46)for(Eer(s)||this.#f(s),s=this.#e.peek();YP(s);)this.#e.next(),l++,s=this.#e.peek();if(s===46){let _=-1;for(this.#e.next(),l++,_++,s=this.#e.peek();YP(s);)this.#e.next(),l++,_++,s=this.#e.peek();!this.#t&&_===0&&(this.#e.next(),s?this.#f(s):this.#d())}if(s===101||s===69)for(this.#e.next(),l++,s=this.#e.peek(),(s===43||s===45)&&(this.#e.next(),l++,s=this.#e.peek()),s===-1&&(this.#e.next(),this.#d()),YP(s)||(this.#e.next(),this.#f(s));YP(s);)this.#e.next(),l++,s=this.#e.peek();return l}#b(s){let l=1;if(s=this.#e.peek(),s===47){do this.#e.next(),l+=1,s=this.#e.peek();while(s>-1&&s!==13&&s!==10);return{length:l,multiline:!1}}if(s===42){for(this.#e.next(),l+=1;s>-1;)if(s=this.#e.peek(),s===42){if(this.#e.next(),l+=1,s=this.#e.peek(),s===47)return this.#e.next(),l+=1,{length:l,multiline:!0}}else this.#e.next(),l+=1;this.#e.next(),this.#d()}this.#e.next(),this.#f(s)}next(){let s=this.#e.next();for(;this.#i(s);)s=this.#e.next();if(s===-1)return x_.EOF;let l=this.#e.locate(),_=String.fromCharCode(s);if(this.#t)if(zce.has(_))this.#a=this.#u(zce.get(_),1,l);else if(vot(s)){let m=this.#g(s);zce.has(m)?this.#a=this.#u(zce.get(m),m.length,l):this.#a=this.#u("Identifier",m.length,l)}else if(Der(s)){let m=this.#x(s);this.#a=this.#u("Number",m,l)}else if(got(s,this.#t)){let m=this.#C(s),b=this.#e.locate();this.#a=this.#u("String",m,l,{line:b.line,column:b.column+1,offset:b.offset+1})}else if(s===47&&this.#s){let m=this.#b(s),b=this.#e.locate();this.#a=this.#u(m.multiline?"BlockComment":"LineComment",m.length,l,{line:b.line,column:b.column+1,offset:b.offset+1})}else this.#f(s);else if(qce.has(_))this.#a=this.#u(qce.get(_),1,l);else if(Cer(s)){let m=this.#g(s);xer.has(m)||this.#v(m,l),this.#a=this.#u(qce.get(m),m.length,l)}else if(yot(s)){let m=this.#x(s);this.#a=this.#u("Number",m,l)}else if(got(s,this.#t)){let m=this.#C(s);this.#a=this.#u("String",m,l)}else if(s===47&&this.#s){let m=this.#b(s),b=this.#e.locate();this.#a=this.#u(m.multiline?"BlockComment":"LineComment",m.length,l,{line:b.line,column:b.column+1,offset:b.offset+1})}else this.#f(s);return x_[this.#a.type]}get token(){return this.#a}};var ST={document(a,s={}){return{type:"Document",body:a,loc:s.loc,...s}},string(a,s={}){return{type:"String",value:a,loc:s.loc,...s}},number(a,s={}){return{type:"Number",value:a,loc:s.loc,...s}},boolean(a,s={}){return{type:"Boolean",value:a,loc:s.loc,...s}},null(a={}){return{type:"Null",loc:a.loc,...a}},array(a,s={}){return{type:"Array",elements:a,loc:s.loc,...s}},element(a,s={}){return{type:"Element",value:a,loc:s.loc,...s}},object(a,s={}){return{type:"Object",members:a,loc:s.loc,...s}},member(a,s,l={}){return{type:"Member",name:a,value:s,loc:l.loc,...l}},identifier(a,s={}){return{type:"Identifier",name:a,loc:s.loc,...s}},nan(a="",s={}){return{type:"NaN",sign:a,loc:s.loc,...s}},infinity(a="",s={}){return{type:"Infinity",sign:a,loc:s.loc,...s}}},wer={mode:"json",ranges:!1,tokens:!1,allowTrailingCommas:!1};function Per(a,s,l=!1){let _="",m=a.indexOf("\\"),b=0;for(;m>=0;){_+=a.slice(b,m);let D=a.charAt(m+1),A=D.charCodeAt(0);if(l&&Vce.has(A))_+=Vce.get(A),b=m+2;else if(IH.has(A))_+=IH.get(A),b=m+2;else if(D==="u"){let M=a.slice(m+2,m+6);if(M.length<4||/[^0-9a-f]/i.test(M))throw new XP(`Invalid unicode escape \\u${M}.`,{line:s.loc.start.line,column:s.loc.start.column+m,offset:s.loc.start.offset+m});_+=String.fromCharCode(parseInt(M,16)),b=m+6}else if(l&&D==="x"){let M=a.slice(m+2,m+4);if(M.length<2||/[^0-9a-f]/i.test(M))throw new XP(`Invalid hex escape \\x${M}.`,{line:s.loc.start.line,column:s.loc.start.column+m,offset:s.loc.start.offset+m});_+=String.fromCharCode(parseInt(M,16)),b=m+4}else if(l&&D6e.has(A))b=m+2,D==="\r"&&a.charAt(b)===`
560
- `&&b++;else if(l)_+=D,b=m+2;else throw new XP(`Invalid escape \\${D}.`,{line:s.loc.start.line,column:s.loc.start.column+m,offset:s.loc.start.offset+m});m=a.indexOf("\\",b)}return _+=a.slice(b),_}t(Per,"getStringValue");function Aer(a,s,l=!1){switch(s.type){case"Boolean":return a==="true";case"Number":return Number(a);case"String":return Per(a.slice(1,-1),s,l);default:throw new TypeError(`Unknown token type "${s.type}.`)}}t(Aer,"getLiteralValue");function bot(a,s){s=Object.freeze({...wer,...s});let l=[],_=new N6e(a,{mode:s.mode,ranges:s.ranges}),m=s.mode==="json5",b=s.allowTrailingCommas||m;function D(){let br=_.next();return br&&s.tokens&&l.push(_.token),br}t(D,"nextNoComments");function A(){let br=_.next();return br&&s.tokens&&l.push(_.token),br>=x_.LineComment?A():br}t(A,"nextSkipComments");let M=s.mode==="json"?D:A;function U(br,mr){if(br!==mr)throw new EO(_.token)}t(U,"assertTokenType");function ie(br,mr){if(!mr.includes(br))throw new EO(_.token)}t(ie,"assertTokenTypes");function se(br,mr){return s.ranges?{range:[br.offset,mr.offset]}:void 0}t(se,"createRange");function Z(br){let mr=_.token,Is=se(mr.loc.start,mr.loc.end),Pi=Aer(a.slice(mr.loc.start.offset,mr.loc.end.offset),mr,m),Ti={loc:{start:{...mr.loc.start},end:{...mr.loc.end}},...Is};switch(br){case x_.String:return ST.string(Pi,Ti);case x_.Number:return ST.number(Pi,Ti);case x_.Boolean:return ST.boolean(Pi,Ti);default:throw new TypeError(`Unknown token type ${mr.type}.`)}}t(Z,"createLiteralNode");function Re(br){let mr=se(br.loc.start,br.loc.end),Is=a.slice(br.loc.start.offset,br.loc.end.offset),Po={loc:{start:{...br.loc.start},end:{...br.loc.end}},...mr};if(br.type!=="Identifier"){let Ti="";return(Is[0]==="+"||Is[0]==="-")&&(Ti=Is[0]),ST[Is.includes("NaN")?"nan":"infinity"](Ti,Po)}return ST.identifier(Is,Po)}t(Re,"createJSON5IdentifierNode");function Pe(br){let mr=se(br.loc.start,br.loc.end);return ST.null({loc:{start:{...br.loc.start},end:{...br.loc.end}},...mr})}t(Pe,"createNullNode");function ke(br){m?ie(br,[x_.String,x_.Identifier,x_.Number]):U(br,x_.String);let mr=_.token,Is=br===x_.String?Z(br):Re(mr);if(m&&(Is.type==="NaN"||Is.type==="Infinity")){if(Is.sign!=="")throw new EO(_.token);Is=ST.identifier(Is.type,{loc:Is.loc,...se(Is.loc.start,Is.loc.end)})}br=M(),U(br,x_.Colon);let Pi=yr(),Po=se(Is.loc.start,Pi.loc.end);return ST.member(Is,Pi,{loc:{start:{...Is.loc.start},end:{...Pi.loc.end}},...Po})}t(ke,"parseProperty");function wt(br){U(br,x_.LBrace);let mr=_.token,Is=[],Pi=M();if(Pi!==x_.RBrace)do{if(Is.push(ke(Pi)),Pi=M(),!Pi)throw new Wce(Is[Is.length-1].loc.end);if(Pi===x_.Comma){if(Pi=M(),b&&Pi===x_.RBrace)break}else break}while(Pi);U(Pi,x_.RBrace);let Po=_.token,Ti=se(mr.loc.start,Po.loc.end);return ST.object(Is,{loc:{start:{...mr.loc.start},end:{...Po.loc.end}},...Ti})}t(wt,"parseObject");function At(br){U(br,x_.LBracket);let mr=_.token,Is=[],Pi=M();if(Pi!==x_.RBracket)do{let _p=yr(Pi);if(Is.push(ST.element(_p,{loc:_p.loc})),Pi=M(),Pi===x_.Comma){if(Pi=M(),b&&Pi===x_.RBracket)break}else break}while(Pi);U(Pi,x_.RBracket);let Po=_.token,Ti=se(mr.loc.start,Po.loc.end);return ST.array(Is,{loc:{start:{...mr.loc.start},end:{...Po.loc.end}},...Ti})}t(At,"parseArray");function yr(br){br=br??M();let mr=_.token;switch(br){case x_.String:case x_.Boolean:return Z(br);case x_.Number:if(m){let Is=a.slice(mr.loc.start.offset,mr.loc.end.offset);if((Is[0]==="+"||Is[0]==="-")&&(Is=Is.slice(1)),Is==="NaN"||Is==="Infinity")return Re(mr)}return Z(br);case x_.Null:return Pe(mr);case x_.LBrace:return wt(br);case x_.LBracket:return At(br);default:throw new EO(mr)}}t(yr,"parseValue");let zr=yr();if(M())throw new EO(_.token);let hn={loc:{start:{line:1,column:1,offset:0},end:{...zr.loc.end}}};return s.tokens&&(hn.tokens=l),s.ranges&&(hn.range=[hn.loc.start.offset,hn.loc.end.offset]),ST.document(zr,hn)}t(bot,"parse");var Ner=new Map([["Document",["body"]],["Object",["members"]],["Member",["name","value"]],["Element",["value"]],["Array",["elements"]],["String",[]],["Number",[]],["Boolean",[]],["Null",[]],["NaN",[]],["Infinity",[]],["Identifier",[]]]);function Sot(a){return a&&typeof a=="object"}t(Sot,"isObject");function Ier(a){return Sot(a)&&typeof a.type=="string"}t(Ier,"isNode");function Oer(a,s){function l(_,m){typeof s.enter=="function"&&s.enter(_,m);for(let b of Ner.get(_.type)){let D=_[b];Sot(D)&&(Array.isArray(D)?D.forEach(A=>l(A,_)):Ier(D)&&l(D,_))}typeof s.exit=="function"&&s.exit(_,m)}t(l,"visitNode"),l(a)}t(Oer,"traverse");function Tot(a,s=()=>!0){let l=[];return Oer(a,{enter(_,m){l.push({node:_,parent:m,phase:"enter"})},exit(_,m){l.push({node:_,parent:m,phase:"exit"})}}),l.filter(s).values()}t(Tot,"iterator");import Fer from"fs/promises";var OH=t((a,s)=>a.split(/\r?\n/)[s-1],"getFileLineContent"),Hce=t(async a=>{try{return await Fer.readFile(a,"utf-8")}catch{return}},"getSchemaContent"),FH=t(async a=>{try{return bot(a)}catch(s){if(s.column&&s.line&&s.message){let l=OH(a,s.line);return{column:s.column,line:s.line,length:void 0,lineText:l}}return}},"getSchemaAST");var xot=t(async(a,s,l)=>{try{if(a.length===0)return;for(let _ of a){let m=await Hce(_),b=await Ler(m,_,s,l);if(b)return b}}catch{}},"getRouteLocationByValue"),Ler=t(async(a,s,l,_)=>{try{if(!a)return;let m=null,b=await FH(a);if(b){for(let{node:D}of Tot(b))if(D.value&&D.value===l){m=D.loc;break}if(m!==null){let D=OH(a,m.start.line);return{file:s,line:m.start.line,column:m.start.column,length:m.end.column-m.start.column,lineText:D,suggestion:_}}}}catch{}},"getRouteLocationByValueFromSchema");import Eot from"fs/promises";import Gce from"path";var I6e="schemas",O6e=".oas.json";var CO=t(async a=>(await Eot.readdir(a)).map(l=>`${a}/${l}`).filter(l=>l.endsWith(O6e)).sort(),"getOpenApiFilesByAlphabetical"),cM=t(async a=>{let s=Gce.resolve(a,"config");return(await Eot.readdir(s)).filter(_=>_.endsWith(O6e)).length>=1},"oasFileInProject");function LH(a,s,l,_,m,b,D){if(b.has(l))return;let A;try{A=_.get(l)}catch(M){throw new M1({text:`Failed to resolve reference: ${l}`,detail:M.message,severity:"error",message:"Failed to resolve reference",location:{file:a,column:0,line:0,length:0,lineText:l,namespace:s,suggestion:"Check the reference and try again."}})}b.set(l,m.length),m.push(l),F6e(L6e(l),s,A,_,m,b,D)}t(LH,"chaseRefs");function F6e(a,s,l,_,m,b,D){if(Array.isArray(l))for(let A of l)F6e(a,s,A,_,m,b,D);else if(typeof l=="object")for(let A in l){if(A==="$ref"){let M=l[A];D&&(l[A]=D(s,M)),LH(a,s,n3(a,M),_,m,b,D)}F6e(a,s,l[A],_,m,b,D)}}t(F6e,"lookForRefs");function n3(a,s){let l=s.indexOf("#");return l>=0?`${Gce.resolve(a,s.substring(0,l))}${s.substring(l)}`:Gce.resolve(Gce.dirname(a),s)}t(n3,"getFullyQualifiedRefName");function L6e(a){let s=a.indexOf("#");return s>=0?a.substring(0,s):a}t(L6e,"getFilePathNameFromRefName");var R6e=class{static{t(this,"Environment")}get WORKING_COPY_ENVIRONMENT(){return process.env.WORKING_COPY_ENVIRONMENT??"staging"}get ZUP_HOSTNAME(){return process.env.ZUP_HOSTNAME??"zuplo.app"}get ZUP_WORKING_COPY_HOSTNAME(){return process.env.ZUP_WORKING_COPY_HOSTNAME?process.env.ZUP_WORKING_COPY_HOSTNAME:this.WORKING_COPY_ENVIRONMENT==="staging"?"d1.zuplo.dev":"d2.zuplo.dev"}},Rer=new R6e,M6e=Rer;var QH=S_(Q4e(),1);var Z4e={};yst(Z4e,{UnsafePathError:()=>Sle,deleteFile:()=>Ssr,deleteFolder:()=>Asr,dirExists:()=>Tle,ensureDirectoryExists:()=>Csr,fileExists:()=>bsr,getParentDirFilename:()=>ksr,isNotFileOrDirectory:()=>Tsr,listFolderContents:()=>Qlt,listFolders:()=>Esr,mkdirForFilePathIfNotExits:()=>eut,mkdirIfNotExists:()=>Zlt,safePath:()=>Dsr,tarFolderContent:()=>wsr,untar:()=>Psr});import Ylt from"child_process";import f3 from"fs/promises";import u3 from"path";var Xlt=[".git","node_modules",".yarn",".DS_Store"];async function bsr(a){try{return(await f3.stat(a)).isFile()}catch{return!1}}t(bsr,"fileExists");async function Ssr(a,s){return await f3.rm(a,s)}t(Ssr,"deleteFile");async function Tle(a){try{return(await f3.stat(a)).isDirectory()}catch{return!1}}t(Tle,"dirExists");async function Tsr(a){try{return await f3.stat(a),!1}catch{return!0}}t(Tsr,"isNotFileOrDirectory");function xsr(a,s){let l=new RegExp(`(.*)(\\/${s})$|(.*)(${s}\\/)`),_=a.match(l);if(!_)return"";let m=a.split(_[0]);return m[1]===""?"":`/${m[1]}`}t(xsr,"getParentDirectory");async function Esr(a){if(!await Tle(a))return[];let s=await f3.readdir(a,{withFileTypes:!0}),l=[];for await(let _ of s)Xlt.includes(_.name)||_.isDirectory()&&l.push(_.name);return l}t(Esr,"listFolders");async function Qlt(a,s,l=!0){let _=xsr(a,s),m=await f3.readdir(a,{withFileTypes:!0}),b=[];for await(let D of m)if(!Xlt.includes(D.name)||!l)if(D.isDirectory()){let A=await Qlt(u3.join(a,D.name),s,l);b.push(...A)}else b.push(u3.join(_,D.name));return b}t(Qlt,"listFolderContents");var Zlt=t(async a=>{if(await Tle(a))return!0;await f3.mkdir(a,{recursive:!0})},"mkdirIfNotExists"),eut=t(async a=>{let s=u3.dirname(a);return Zlt(s)},"mkdirForFilePathIfNotExits"),Csr=eut,Sle=class extends Error{static{t(this,"UnsafePathError")}constructor(s){super(s)}};function Dsr(a){let s=t(l=>{if(!l.startsWith(a))throw new Sle("Resolved path is not part of the project.");return l},"ensureSafePath");return{resolve:t((...l)=>s(u3.resolve(...l)),"resolve")}}t(Dsr,"safePath");function ksr(a){return`${u3.basename(u3.dirname(a))}/${u3.basename(a)}`}t(ksr,"getParentDirFilename");function wsr(a,s,l,_){let m=u3.join(_,l);return Ylt.execSync(`tar --exclude='.git/' --exclude='dist/' -czf ${m} ${s}`,{cwd:a}),m}t(wsr,"tarFolderContent");function Psr(a,s,l,_=!1){Ylt.execSync(`tar -xf ${s} ${_?"--strip-components=1 ":""}-C ${l}`,{cwd:a})}t(Psr,"untar");async function Asr(a){if(await Tle(a))return await f3.rm(a,{recursive:!0})}t(Asr,"deleteFolder");var wl=Z4e;var CT=S_(Q4e(),1);import{readFile as Nsr}from"fs/promises";var FO=class extends Error{static{t(this,"CustomResolveError")}},_3=class{static{t(this,"RefParser")}sourceDirectory;logger;constructor(s,l){this.sourceDirectory=s,this.logger=l}dereference(s,l){return QH.$RefParser.dereference(s,{resolve:{json:!0,file:xle(this.sourceDirectory,this.logger),external:!0,http:!1},dereference:{circular:"ignore",onDereference:l?.onDereference}})}bundle(s){return QH.$RefParser.bundle(s,{resolve:{file:xle(this.sourceDirectory,this.logger),external:!0,http:!1}})}parse(s){return QH.$RefParser.parse(s,{resolve:{file:xle(this.sourceDirectory,this.logger),external:!0,http:!1}})}resolve(s){return QH.$RefParser.resolve(s,{resolve:{file:xle(this.sourceDirectory,this.logger),external:!0,http:!1}})}};function xle(a,s){return{order:100,canRead(l){let _=Fsr(l.url);if(!(_===void 0||_==="file"))return!1;let b;try{b=tut(l.url)}catch(D){throw new FO(`Malformed URI: ${l.url}`,{cause:D})}try{wl.safePath(a).resolve(b)}catch(D){return s?.warn(D),!1}return!0},async read(l){let _;try{_=tut(l.url)}catch(m){throw new FO(`Malformed URI: ${l.url}`,{cause:m})}try{return await Nsr(_)}catch(m){throw new FO(`Error opening file "${_}"`,{cause:m})}}}}t(xle,"customResolver");var e3e=/^win/.test(globalThis.process?globalThis.process.platform:""),Isr=/\//g,Osr=/^(\w{2,}):\/\//i,t3e=[/%23/g,"#",/%24/g,"$",/%26/g,"&",/%2C/g,",",/%40/g,"@"];function Fsr(a){let s=Osr.exec(a);if(s)return s[1].toLowerCase()}t(Fsr,"getProtocol");function tut(a,s){a=decodeURI(a);for(let _=0;_<t3e.length;_+=2)a=a.replace(t3e[_],t3e[_+1]);let l=a.substr(0,7).toLowerCase()==="file://";return l&&(a=a[7]==="/"?a.substr(8):a.substr(7),e3e&&a[1]==="/"&&(a=a[0]+":"+a.substr(1)),s?a="file:///"+a:(l=!1,a=e3e?a:"/"+a)),e3e&&!l&&(a=a.replace(Isr,"\\"),a.substr(1,2)===":\\"&&(a=a[0].toUpperCase()+a.substr(1))),a}t(tut,"toFileSystemPath");var rut="YOUR_KEY_HERE";async function nut(a){let l=await new _3(a.sourceDirectory,a.logger).bundle(a.openApiDocPath),_=a.openApiDocPath.replace(a.sourceDirectory,"");return Lsr({...a,relativeOpenApiPath:_},l)}t(nut,"buildPublicOpenApiFile");async function Lsr(a,s){Bsr({relativeOpenApiPath:a.relativeOpenApiPath},s);let l=s;return l=Msr(l),Rsr(l,a),l=jsr(l,a),iut(l,"x-zuplo"),l}t(Lsr,"buildRawOpenApiFile");function Rsr(a,{customDomain:s,deploymentName:l,environmentType:_}){let m;s?m=s:_&&l&&(m=_===dce.WORKING_COPY?`${l}.${M6e.ZUP_WORKING_COPY_HOSTNAME}`:`${l}.${M6e.ZUP_HOSTNAME}`),m?a.servers=[{url:`https://${m}`}]:a.servers=void 0}t(Rsr,"addServerHost");function Msr(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,A])=>(KR in A&&mce(A[KR])&&(b.push(D),l.parameters&&delete l.parameters[D]),b),[]));let m=Object.entries(a.paths).reduce((b,[D,A])=>{if(!A)return b;let M={...A},U=["delete","get","head","patch","post","put","trace","options"];return U.forEach(ie=>{let se=A[ie];if(!se)return;if(mce(se[KR])){delete M[ie];return}let{parameters:Z}=se;if(!Z)return;let Re=Z.filter(Pe=>{if(KR in Pe&&mce(Pe[KR]))return!1;if("$ref"in Pe){let ke=Pe.$ref.split("/").pop();return ke?!_.includes(ke):!0}return!0});M[ie]={...se,parameters:Re}}),U.some(ie=>!!M[ie])&&(b[D]=M),b},{});return{...a,paths:m,components:l}}t(Msr,"removeHiddenRoutesAndParams");function jsr(a,{policiesConfig:s}){if(!a.paths)return a;let l=Object.entries(a.paths).reduce((_,[m,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(A=>{if(!A)return;let M=A["x-zuplo-route"]?.policies?.inbound?.reduce((se,Z)=>{let Re=s.policies?.find(({name:wt})=>wt===Z);if(!Re)return se;if(!(Re.handler.export==="CompositeInboundPolicy"))return se.concat(Z);let ke=Re.handler.options?.policies;return ke?se.concat(ke):se},[]),U=[];if(M&&M.forEach(se=>{s.policies?.forEach(Z=>{Z.name===se&&(Z.handler.export==="ApiAuthKeyInboundPolicy"||Z.handler.export==="ApiKeyInboundPolicy")&&!Z.handler.options?.disableAutomaticallyAddingKeyHeaderToOpenApi&&U.push(Z)})}),U.length>0){let se=U.length>0&&U[0].handler&&U[0].handler.options&&U[0].handler.options.authHeader?U[0].handler.options.authHeader:"Authorization",Z=U.length>0&&U[0].handler&&U[0].handler.options&&(U[0].handler.options.authScheme||U[0].handler.options.authScheme==="")?U[0].handler.options.authScheme:"Bearer",Re=Z!==""?`${Z} ${rut}`:rut,Pe={name:se,in:"header",required:!0,example:Re,schema:{type:"string"},description:`The \`${se}\` header is used to authenticate with the API using your API key. Value is of the format \`${Re}\`.`};A.parameters?A.parameters.some(yr=>"name"in yr&&yr.name===Pe.name)||A.parameters.unshift(Pe):A.parameters=[Pe];let ke={type:"http",scheme:Z.toLowerCase()},wt="api_key";a.components?.securitySchemes?Object.values(a.components?.securitySchemes).some(yr=>"name"in yr&&yr.type==="apiKey"||"type"in yr&&yr.type==="http"&&yr.scheme===Z)||(a.components.securitySchemes={...a.components.securitySchemes,[wt]:ke}):(a.components||(a.components={}),a.components.securitySchemes={[wt]:ke});let At={[wt]:[]};A.security?A.security.some(yr=>yr[wt]!==void 0)||A.security.unshift(At):A.security=[At]}let ie=[];if(M&&M.forEach(se=>{s.policies?.forEach(Z=>{Z.name===se&&(Z.handler.export==="RateLimitInboundPolicy"||Z.handler.export==="ComplexRateLimitInboundPolicy")&&ie.push(Z)})}),ie.length>0){let se={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"}}}}}},Z={...se,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:se,RateLimitWithRetryAfter:Z},A.responses||(A.responses={});let Re=ie.some(Pe=>Pe.handler.options?.headerMode!=="none");A.responses[429]||(A.responses[429]={$ref:Re?"#/components/responses/RateLimitWithRetryAfter":"#/components/responses/RateLimitNoRetryAfter"})}}),_[m]=D,_},{});return{...a,paths:l}}t(jsr,"enrichSpecWithZuploData");function iut(a,s){for(let l in a)l.startsWith(s)?delete a[l]:typeof a[l]=="object"&&iut(a[l],s)}t(iut,"removePropertiesByPrefix");function Bsr({relativeOpenApiPath:a},s){if(!s||typeof s!="object")throw new M1({message:"The OpenAPI Document could not be parsed.",severity:"error"});if(!("info"in s)||typeof s.info!="object"||!s.info)throw new M1({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 M1({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(Bsr,"assertIsZuploOpenApiSpec");function Usr(a){if(a.length>=255)throw new TypeError("Alphabet too long");let s=new Uint8Array(256);for(let U=0;U<s.length;U++)s[U]=255;for(let U=0;U<a.length;U++){let ie=a.charAt(U),se=ie.charCodeAt(0);if(s[se]!==255)throw new TypeError(ie+" is ambiguous");s[se]=U}let l=a.length,_=a.charAt(0),m=Math.log(l)/Math.log(256),b=Math.log(256)/Math.log(l);function D(U){if(U instanceof Uint8Array||(ArrayBuffer.isView(U)?U=new Uint8Array(U.buffer,U.byteOffset,U.byteLength):Array.isArray(U)&&(U=Uint8Array.from(U))),!(U instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(U.length===0)return"";let ie=0,se=0,Z=0,Re=U.length;for(;Z!==Re&&U[Z]===0;)Z++,ie++;let Pe=(Re-Z)*b+1>>>0,ke=new Uint8Array(Pe);for(;Z!==Re;){let yr=U[Z],zr=0;for(let en=Pe-1;(yr!==0||zr<se)&&en!==-1;en--,zr++)yr+=256*ke[en]>>>0,ke[en]=yr%l>>>0,yr=yr/l>>>0;if(yr!==0)throw new Error("Non-zero carry");se=zr,Z++}let wt=Pe-se;for(;wt!==Pe&&ke[wt]===0;)wt++;let At=_.repeat(ie);for(;wt<Pe;++wt)At+=a.charAt(ke[wt]);return At}t(D,"encode");function A(U){if(typeof U!="string")throw new TypeError("Expected String");if(U.length===0)return new Uint8Array;let ie=0,se=0,Z=0;for(;U[ie]===_;)se++,ie++;let Re=(U.length-ie)*m+1>>>0,Pe=new Uint8Array(Re);for(;U[ie];){let yr=s[U.charCodeAt(ie)];if(yr===255)return;let zr=0;for(let en=Re-1;(yr!==0||zr<Z)&&en!==-1;en--,zr++)yr+=l*Pe[en]>>>0,Pe[en]=yr%256>>>0,yr=yr/256>>>0;if(yr!==0)throw new Error("Non-zero carry");Z=zr,ie++}let ke=Re-Z;for(;ke!==Re&&Pe[ke]===0;)ke++;let wt=new Uint8Array(se+(Re-ke)),At=se;for(;ke!==Re;)wt[At++]=Pe[ke++];return wt}t(A,"decodeUnsafe");function M(U){let ie=A(U);if(ie)return ie;throw new Error("Non-base"+l+" character")}return t(M,"decode"),{encode:D,decodeUnsafe:A,decode:M}}t(Usr,"base");var sut=Usr;var $sr="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",Ele=sut($sr);var r3e="2024-09-02",aut=Object.freeze({none:{runOutboundPoliciesOnHandlerOnAllStatuses:!1,doNotRunHooksOnSystemRoutes:!1,removeAllVendorHeadersExceptListed:!1,allowCustomPorts:!1},"2023-03-14":{runOutboundPoliciesOnHandlerOnAllStatuses:!1,doNotRunHooksOnSystemRoutes:!1,removeAllVendorHeadersExceptListed:!1,allowCustomPorts:!1},"2024-01-15":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!1},"2024-03-14":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!1},"2024-09-02":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!0}});function out(){return new DT({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:r3e,ENVIRONMENT_TYPE:"mock-environment-type",GIT_SHA:void 0,IS_LOCAL_DEVELOPMENT:!1,COMPATIBILITY_FLAGS:aut[r3e]},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(out,"getMockEnvironment");var DT=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=out()),this.#r}constructor({build:s,runtime:l}){let _;try{if(l.__ZUPLO_CONFIG){let m=atob(l.__ZUPLO_CONFIG);_=JSON.parse(m)}if(l.ZUPLO_SYSTEM_CONFIGURATIONS){let m=new TextDecoder().decode(Ele.decode(l.ZUPLO_SYSTEM_CONFIGURATIONS)),b=JSON.parse(m);for(let D of Object.keys(b))l[D]=b[D]}}catch(m){console.error("Failed to parse runtime configuration",m)}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 zudokuHostUrl(){return this.runtime.__ZUPLO_ZUDOKU_HOST_URL??this.config.zudoku_host_url??"https://zudoku.zuploedge.com"}get buildAssetsUrl(){return this.runtime.__ZUPLO_BUILD_ASSETS_URL??this.config.build_assets_url??"https://build-assets.zuplo.com"}get zuploEdgeApiUrl(){return this.config.zuplo_edge_api_url??"https://api.zuploedge.com"}get remoteLogToken(){return this.runtime.__ZUPLO_REMOTE_LOG_TOKEN??this.config.remote_log_token??void 0}get zuploClientAuthBucketId(){return this.config.zuplo_auth_client_bucket_id??"auth_o8PUdhKxSTOiB794GWPwLQCD"}get managementApiURL(){return this.runtime.__ZUPLO_MANAGEMENT_API_URL??this.config.management_api_url??"https://api.zuplo.com"}get developerApiUrl(){return this.config.developer_api_url??"https://dev.zuplo.com"}get cdnURL(){return this.runtime.__ZUPLO_CDN_URL??this.config.cdn_url??"https://cdn.zuplo.com"}get remoteLogURL(){return this.runtime.__ZUPLO_REMOTE_LOG_URL??this.config.log_event_api??"https://ellie.zuploedge.com"}get loggingId(){return this.runtime.__ZUPLO_LOGGING_ID??this.config.logging_id??void 0}get redisURL(){return this.runtime.__ZUPLO_REDIS_URL??this.config.redis_proxy_url??"https://redis-proxy.zuploedge.com"}get apiKeyServiceUrl(){return this.runtime.__ZUPLO_API_KEY_SERVICE_URL??this.config.api_key_service_url??"https://apikey.zuploedge.com"}get meteringServiceUrl(){return this.config.metering_service_url??"https://meters.zuploedge.com"}get authApiJWT(){return this.runtime.__ZUPLO_AUTH_API_JWT??void 0}get authClientId(){return this.runtime.__ZUPLO_AUTH_CLIENT_ID}get authClientSecret(){return this.runtime.__ZUPLO_AUTH_CLIENT_SECRET}get userLogLevel(){return this.runtime.ZUPLO_LOG_LEVEL??this.runtime.__ZUPLO_LOG_LEVEL??this.config.user_log_level??"debug"}get systemLogLevel(){return this.runtime.__ZUPLO_LOG_LEVEL??this.config.system_log_level??"debug"}get logFormat(){return this.runtime.__ZUPLO_LOG_FORMAT??this.config.log_format??"cloudflare"}get isCloudflare(){return this.runtime.__ZUPLO_RUNTIME_TYPE?this.runtime.__ZUPLO_RUNTIME_TYPE==="cloudflare":this.config.runtime_type?this.config.runtime_type==="cloudflare":typeof WebSocketPair=="function"}get isDeno(){return this.runtime.__ZUPLO_RUNTIME_TYPE?this.runtime.__ZUPLO_RUNTIME_TYPE==="deno":this.config.runtime_type?this.config.runtime_type==="deno":typeof WebSocketPair!="function"}get isLocalDevelopment(){return this.build.IS_LOCAL_DEVELOPMENT}get isTestMode(){return!!this.runtime.__ZUPLO_TEST_MODE}get systemUserAgent(){return`Zuplo/${this.build.ZUPLO_VERSION}`}get loggingEnvironmentType(){return this.isCloudflare?"edge":this.isLocalDevelopment?"local":this.isDeno?"working-copy":"unknown"}get loggingEnvironmentStage(){return this.build.ENVIRONMENT_TYPE==="PRODUCTION"?"production":this.build.ENVIRONMENT_TYPE==="PREVIEW"?"preview":this.isLocalDevelopment?"local":this.isWorkingCopy?"working-copy":"unknown"}get isWorkingCopy(){return this.build.ENVIRONMENT_TYPE==="WORKING_COPY"}};var Jsr=["ZUPLO_USER_LOGGER_DATA_DOG_API_KEY","ZUPLO_USER_LOGGER_DATA_DOG_URL","ZUPLO_LOG_LEVEL","ZUPLO_HANDLER_WRITE_LOG_LEVEL"];function cut(a){return a.startsWith("__ZUPLO")||a.startsWith("ZUPLO_")?!Jsr.includes(a)&&!a.startsWith("ZUPLO_PUBLIC_"):!1}t(cut,"isRestrictedEnvVariableName");function lut(a){return!!a.startsWith("ZUPLO_")}t(lut,"isZuploReadableEnvVariableName");var e8r=new Proxy({},{get(a,s){let l=String(s);switch(l){case"ZUPLO_ENVIRONMENT_TYPE":return DT.instance.loggingEnvironmentType;case"ZUPLO_ENVIRONMENT_STAGE":return DT.instance.loggingEnvironmentStage;case"ZUPLO_ENVIRONMENT_NAME":return DT.instance.runtime.__ZUPLO_DEPLOYMENT_NAME;case"ZUPLO_ACCOUNT_NAME":return DT.instance.build.ACCOUNT_NAME;case"ZUPLO_PROJECT_NAME":return DT.instance.build.PROJECT_NAME;case"ZUPLO_BUILD_ID":return DT.instance.build.BUILD_ID}if(!(cut(l)&&!lut(l)))return DT.instance.runtime[l]}});function ZH(a,s,l){return`_${rA(`${a}_${s}_${l}`)}`}t(ZH,"getRawOperationDataIdentifierName");function n3e(a,s,l,_){return`_${rA(a.toLowerCase())}_${s.toLowerCase()}_${l.toLowerCase()}_${_.toLowerCase()}`}t(n3e,"getIdForParameterSchema");function i3e(a,s,l){return`_${rA(a.toLowerCase())}_${s.toLowerCase()}_rb_${rA(l.toLowerCase())}`}t(i3e,"getIdForRequestBodySchema");function eG(a,s){return`_${rA(a)}_${rA(s)}`}t(eG,"getIdForRefSchema");function rA(a){return a.replace(/[^a-zA-Z0-9]/g,"_")}t(rA,"sanitizedIdentifierName");var $mt=S_(Zft(),1);import Yue from"path";var hG=class{static{t(this,"R")}type=3;name="";prefix="";value="";suffix="";modifier=3;constructor(a,s,l,_,m,b){this.type=a,this.name=s,this.prefix=l,this.value=_,this.suffix=m,this.modifier=b}hasCustomName(){return this.name!==""&&typeof this.name!="number"}},Rcr=/[$_\p{ID_Start}]/u,Mcr=/[$_\u200C\u200D\p{ID_Continue}]/u,Q3e=".*";function jcr(a,s){return(s?/^[\x00-\xFF]*$/:/^[\x00-\x7F]*$/).test(a)}t(jcr,"Re");function r_t(a,s=!1){let l=[],_=0;for(;_<a.length;){let m=a[_],b=t(function(D){if(!s)throw new TypeError(D);l.push({type:"INVALID_CHAR",index:_,value:a[_++]})},"c");if(m==="*"){l.push({type:"ASTERISK",index:_,value:a[_++]});continue}if(m==="+"||m==="?"){l.push({type:"OTHER_MODIFIER",index:_,value:a[_++]});continue}if(m==="\\"){l.push({type:"ESCAPED_CHAR",index:_++,value:a[_++]});continue}if(m==="{"){l.push({type:"OPEN",index:_,value:a[_++]});continue}if(m==="}"){l.push({type:"CLOSE",index:_,value:a[_++]});continue}if(m===":"){let D="",A=_+1;for(;A<a.length;){let M=a.substr(A,1);if(A===_+1&&Rcr.test(M)||A!==_+1&&Mcr.test(M)){D+=a[A++];continue}break}if(!D){b(`Missing parameter name at ${_}`);continue}l.push({type:"NAME",index:_,value:D}),_=A;continue}if(m==="("){let D=1,A="",M=_+1,U=!1;if(a[M]==="?"){b(`Pattern cannot start with "?" at ${M}`);continue}for(;M<a.length;){if(!jcr(a[M],!1)){b(`Invalid character '${a[M]}' at ${M}.`),U=!0;break}if(a[M]==="\\"){A+=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}`),U=!0;break}A+=a[M++]}if(U)continue;if(D){b(`Unbalanced pattern at ${_}`);continue}if(!A){b(`Missing pattern at ${_}`);continue}l.push({type:"REGEX",index:_,value:A}),_=M;continue}l.push({type:"CHAR",index:_,value:a[_++]})}return l.push({type:"END",index:_,value:""}),l}t(r_t,"v");function n_t(a,s={}){let l=r_t(a);s.delimiter??="/#?",s.prefixes??="./";let _=`[^${AT(s.delimiter)}]+?`,m=[],b=0,D=0,A="",M=new Set,U=t(zr=>{if(D<l.length&&l[D].type===zr)return l[D++].value},"a"),ie=t(()=>U("OTHER_MODIFIER")??U("ASTERISK"),"f"),se=t(zr=>{let en=U(zr);if(en!==void 0)return en;let{type:hn,index:br}=l[D];throw new TypeError(`Unexpected ${hn} at ${br}, expected ${zr}`)},"d"),Z=t(()=>{let zr="",en;for(;en=U("CHAR")??U("ESCAPED_CHAR");)zr+=en;return zr},"T"),Re=t(zr=>zr,"Se"),Pe=s.encodePart||Re,ke="",wt=t(zr=>{ke+=zr},"U"),At=t(()=>{ke.length&&(m.push(new hG(3,"","",Pe(ke),"",3)),ke="")},"$"),yr=t((zr,en,hn,br,mr)=>{let Is=3;switch(mr){case"?":Is=1;break;case"*":Is=0;break;case"+":Is=2;break}if(!en&&!hn&&Is===3){wt(zr);return}if(At(),!en&&!hn){if(!zr)return;m.push(new hG(3,"","",Pe(zr),"",Is));return}let Pi;hn?hn==="*"?Pi=Q3e:Pi=hn:Pi=_;let Po=2;Pi===_?(Po=1,Pi=""):Pi===Q3e&&(Po=0,Pi="");let Ti;if(en?Ti=en:hn&&(Ti=b++),M.has(Ti))throw new TypeError(`Duplicate name '${Ti}'.`);M.add(Ti),m.push(new hG(Po,Ti,Pe(zr),Pi,Pe(br),Is))},"V");for(;D<l.length;){let zr=U("CHAR"),en=U("NAME"),hn=U("REGEX");if(!en&&!hn&&(hn=U("ASTERISK")),en||hn){let mr=zr??"";s.prefixes.indexOf(mr)===-1&&(wt(mr),mr=""),At();let Is=ie();yr(mr,en,hn,"",Is);continue}let br=zr??U("ESCAPED_CHAR");if(br){wt(br);continue}if(U("OPEN")){let mr=Z(),Is=U("NAME"),Pi=U("REGEX");!Is&&!Pi&&(Pi=U("ASTERISK"));let Po=Z();se("CLOSE");let Ti=ie();yr(mr,Is,Pi,Po,Ti);continue}At(),se("END")}return m}t(n_t,"D");function AT(a){return a.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}t(AT,"S");function e_t(a){return a&&a.ignoreCase?"ui":"u"}t(e_t,"X");function Bcr(a,s,l){return i_t(n_t(a,l),s,l)}t(Bcr,"Z");function IM(a){switch(a){case 0:return"*";case 1:return"?";case 2:return"+";case 3:return""}}t(IM,"k");function i_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 A of a){if(A.type===3){A.modifier===3?_+=AT(A.value):_+=`(?:${AT(A.value)})${IM(A.modifier)}`;continue}s&&s.push(A.name);let M=`[^${AT(l.delimiter)}]+?`,U=A.value;if(A.type===1?U=M:A.type===0&&(U=Q3e),!A.prefix.length&&!A.suffix.length){A.modifier===3||A.modifier===1?_+=`(${U})${IM(A.modifier)}`:_+=`((?:${U})${IM(A.modifier)})`;continue}if(A.modifier===3||A.modifier===1){_+=`(?:${AT(A.prefix)}(${U})${AT(A.suffix)})`,_+=IM(A.modifier);continue}_+=`(?:${AT(A.prefix)}`,_+=`((?:${U})(?:`,_+=AT(A.suffix),_+=AT(A.prefix),_+=`(?:${U}))*)${AT(A.suffix)})`,A.modifier===0&&(_+="?")}let m=`[${AT(l.endsWith)}]|$`,b=`[${AT(l.delimiter)}]`;if(l.end)return l.strict||(_+=`${b}?`),l.endsWith.length?_+=`(?=${m})`:_+="$",new RegExp(_,e_t(l));l.strict||(_+=`(?:${b}(?=${m}))?`);let D=!1;if(a.length){let A=a[a.length-1];A.type===3&&A.modifier===3&&(D=l.delimiter.indexOf(A)>-1)}return D||(_+=`(?=${b}|${m})`),new RegExp(_,e_t(l))}t(i_t,"F");var h3={delimiter:"",prefixes:"",sensitive:!0,strict:!0},Ucr={delimiter:".",prefixes:"",sensitive:!0,strict:!0},$cr={delimiter:"/",prefixes:"/",sensitive:!0,strict:!0};function Jcr(a,s){return a.length?a[0]==="/"?!0:!s||a.length<2?!1:(a[0]=="\\"||a[0]=="{")&&a[1]=="/":!1}t(Jcr,"J");function s_t(a,s){return a.startsWith(s)?a.substring(s.length,a.length):a}t(s_t,"Q");function zcr(a,s){return a.endsWith(s)?a.substr(0,a.length-s.length):a}t(zcr,"Ee");function a_t(a){return!a||a.length<2?!1:a[0]==="["||(a[0]==="\\"||a[0]==="{")&&a[1]==="["}t(a_t,"W");var o_t=["ftp","file","http","https","ws","wss"];function c_t(a){if(!a)return!0;for(let s of o_t)if(a.test(s))return!0;return!1}t(c_t,"N");function qcr(a,s){if(a=s_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(qcr,"te");function Vcr(a,s){if(a=s_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(Vcr,"re");function Wcr(a,s){return s||a===""?a:a_t(a)?f_t(a):u_t(a)}t(Wcr,"ne");function Hcr(a,s){if(s||a==="")return a;let l=new URL("https://example.com");return l.password=a,l.password}t(Hcr,"se");function Gcr(a,s){if(s||a==="")return a;let l=new URL("https://example.com");return l.username=a,l.username}t(Gcr,"ie");function Kcr(a,s,l){if(l||a==="")return a;if(s&&!o_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(Kcr,"ae");function Ycr(a,s,l){return l_t(s)===a&&(a=""),l||a===""?a:__t(a)}t(Ycr,"oe");function Xcr(a,s){return a=zcr(a,":"),s||a===""?a:Z3e(a)}t(Xcr,"ce");function l_t(a){switch(a){case"ws":case"http":return"80";case"wws":case"https":return"443";case"ftp":return"21";default:return""}}t(l_t,"_");function Z3e(a){if(a==="")return a;if(/^[-+.A-Za-z0-9]*$/.test(a))return a.toLowerCase();throw new TypeError(`Invalid protocol '${a}'.`)}t(Z3e,"y");function Qcr(a){if(a==="")return a;let s=new URL("https://example.com");return s.username=a,s.username}t(Qcr,"le");function Zcr(a){if(a==="")return a;let s=new URL("https://example.com");return s.password=a,s.password}t(Zcr,"fe");function u_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(u_t,"z");function f_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(f_t,"j");function __t(a){if(a===""||/^[0-9]*$/.test(a)&&parseInt(a)<=65535)return a;throw new TypeError(`Invalid port '${a}'.`)}t(__t,"K");function elr(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(elr,"he");function tlr(a){return a===""?a:new URL(`data:${a}`).pathname}t(tlr,"ue");function rlr(a){if(a==="")return a;let s=new URL("https://example.com");return s.search=a,s.search.substring(1,s.search.length)}t(rlr,"de");function nlr(a){if(a==="")return a;let s=new URL("https://example.com");return s.hash=a,s.hash.substring(1,s.hash.length)}t(nlr,"pe");var ilr=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=r_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.#C()?(a=2,s=3):this.#l&&(a=2),this.#i(a,s)}break;case 2:this.#x()?this.#d(3):(this.#E()||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.#E()?this.#i(7,0):this.#y()?this.#i(8,1):this.#D()&&this.#i(9,1);break;case 6:this.#E()?this.#i(7,0):this.#y()?this.#i(8,1):this.#D()&&this.#i(9,1);break;case 7:this.#y()?this.#i(8,1):this.#D()&&this.#i(9,1);break;case 8:this.#D()&&this.#i(9,1);break;case 9:break;case 10:break}}this.#e.hostname!==void 0&&this.#e.port===void 0&&(this.#e.port="")}#i(a,s){switch(this.#a){case 0:break;case 1:this.#e.protocol=this.#T();break;case 2:break;case 3:this.#e.username=this.#T();break;case 4:this.#e.password=this.#T();break;case 5:this.#e.hostname=this.#T();break;case 6:this.#e.port=this.#T();break;case 7:this.#e.pathname=this.#T();break;case 8:this.#e.search=this.#T();break;case 9:this.#e.hash=this.#T();break;case 10:break}this.#a!==0&&a!==10&&([1,2,3,4].includes(this.#a)&&[6,7,8,9].includes(a)&&(this.#e.hostname??=""),[1,2,3,4,5,6].includes(this.#a)&&[8,9].includes(a)&&(this.#e.pathname??=this.#l?"/":""),[1,2,3,4,5,6,7].includes(this.#a)&&a===9&&(this.#e.search??="")),this.#f(a,s)}#f(a,s){this.#a=a,this.#p=this.#t+s,this.#t+=s,this.#s=0}#v(){this.#t=this.#p,this.#s=0}#d(a){this.#v(),this.#a=a}#u(a){return a<0&&(a=this.#n.length-a),a<this.#n.length?this.#n[a]:this.#n[this.#n.length-1]}#m(a,s){let 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,":")}#C(){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,":")}#E(){return this.#m(this.#t,"/")}#y(){if(this.#m(this.#t,"?"))return!0;if(this.#n[this.#t].value!=="?")return!1;let a=this.#u(this.#t-1);return a.type!=="NAME"&&a.type!=="REGEX"&&a.type!=="CLOSE"&&a.type!=="ASTERISK"}#D(){return this.#m(this.#t,"#")}#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,h3),a.encodePart=Z3e;let s=Bcr(this.#T(),void 0,a);this.#l=c_t(s)}},X3e=["protocol","username","password","hostname","port","pathname","search","hash"],m3="*";function t_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(t_t,"ge");function oA(a,s){return s?mG(a):a}t(oA,"b");function dG(a,s,l){let _;if(typeof s.baseURL=="string")try{_=new URL(s.baseURL),s.protocol===void 0&&(a.protocol=oA(_.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=oA(_.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=oA(_.password,l)),s.protocol===void 0&&s.hostname===void 0&&(a.hostname=oA(_.hostname,l)),s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&(a.port=oA(_.port,l)),s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.pathname===void 0&&(a.pathname=oA(_.pathname,l)),s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.pathname===void 0&&s.search===void 0&&(a.search=oA(_.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=oA(_.hash.substring(1,_.hash.length),l))}catch{throw new TypeError(`invalid baseURL '${s.baseURL}'.`)}if(typeof s.protocol=="string"&&(a.protocol=Xcr(s.protocol,l)),typeof s.username=="string"&&(a.username=Gcr(s.username,l)),typeof s.password=="string"&&(a.password=Hcr(s.password,l)),typeof s.hostname=="string"&&(a.hostname=Wcr(s.hostname,l)),typeof s.port=="string"&&(a.port=Ycr(s.port,a.protocol,l)),typeof s.pathname=="string"){if(a.pathname=s.pathname,_&&!Jcr(a.pathname,l)){let m=_.pathname.lastIndexOf("/");m>=0&&(a.pathname=oA(_.pathname.substring(0,m+1),l)+a.pathname)}a.pathname=Kcr(a.pathname,a.protocol,l)}return typeof s.search=="string"&&(a.search=Vcr(s.search,l)),typeof s.hash=="string"&&(a.hash=qcr(s.hash,l)),a}t(dG,"w");function mG(a){return a.replace(/([+*?:{}()\\])/g,"\\$1")}t(mG,"C");function slr(a){return a.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}t(slr,"Oe");function alr(a,s){s.delimiter??="/#?",s.prefixes??="./",s.sensitive??=!1,s.strict??=!1,s.end??=!0,s.start??=!0,s.endsWith="";let l=".*",_=`[^${slr(s.delimiter)}]+?`,m=/[$_\u200C\u200D\p{ID_Continue}]/u,b="";for(let D=0;D<a.length;++D){let A=a[D];if(A.type===3){if(A.modifier===3){b+=mG(A.value);continue}b+=`{${mG(A.value)}}${IM(A.modifier)}`;continue}let M=A.hasCustomName(),U=!!A.suffix.length||!!A.prefix.length&&(A.prefix.length!==1||!s.prefixes.includes(A.prefix)),ie=D>0?a[D-1]:null,se=D<a.length-1?a[D+1]:null;if(!U&&M&&A.type===1&&A.modifier===3&&se&&!se.prefix.length&&!se.suffix.length)if(se.type===3){let Z=se.value.length>0?se.value[0]:"";U=m.test(Z)}else U=!se.hasCustomName();if(!U&&!A.prefix.length&&ie&&ie.type===3){let Z=ie.value[ie.value.length-1];U=s.prefixes.includes(Z)}U&&(b+="{"),b+=mG(A.prefix),M&&(b+=`:${A.name}`),A.type===2?b+=`(${A.value})`:A.type===1?M||(b+=`(${_})`):A.type===0&&(!M&&(!ie||ie.type===3||ie.modifier!==3||U||A.prefix!=="")?b+="*":b+=`(${l})`),A.type===1&&M&&A.suffix.length&&m.test(A.suffix[0])&&(b+="\\"),b+=mG(A.suffix),U&&(b+="}"),A.modifier!==3&&(b+=IM(A.modifier))}return b}t(alr,"ke");var p_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 A=new ilr(a);if(A.parse(),a=A.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 m={ignoreCase:l.ignoreCase===!0},b={pathname:m3,protocol:m3,username:m3,password:m3,hostname:m3,port:m3,search:m3,hash:m3};this.#r=dG(b,a,!0),l_t(this.#r.protocol)===this.#r.port&&(this.#r.port="");let D;for(D of X3e){if(!(D in this.#r))continue;let A={},M=this.#r[D];switch(this.#e[D]=[],D){case"protocol":Object.assign(A,h3),A.encodePart=Z3e;break;case"username":Object.assign(A,h3),A.encodePart=Qcr;break;case"password":Object.assign(A,h3),A.encodePart=Zcr;break;case"hostname":Object.assign(A,Ucr),a_t(M)?A.encodePart=f_t:A.encodePart=u_t;break;case"port":Object.assign(A,h3),A.encodePart=__t;break;case"pathname":c_t(this.#n.protocol)?(Object.assign(A,$cr,m),A.encodePart=elr):(Object.assign(A,h3,m),A.encodePart=tlr);break;case"search":Object.assign(A,h3,m),A.encodePart=rlr;break;case"hash":Object.assign(A,h3,m),A.encodePart=nlr;break}try{this.#s[D]=n_t(M,A),this.#n[D]=i_t(this.#s[D],this.#e[D],A),this.#t[D]=alr(this.#s[D],A),this.#p=this.#p||this.#s[D].some(U=>U.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=dG(l,a,!1):l=dG(l,t_t(a,s),!1)}catch{return!1}let _;for(_ of X3e)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=dG(l,a,!1):l=dG(l,t_t(a,s),!1)}catch{return null}let _={};s?_.inputs=[a,s]:_.inputs=[a];let m;for(m of X3e){let b=this.#n[m].exec(l[m]);if(!b)return null;let D={};for(let[A,M]of this.#e[m].entries())if(typeof M=="string"||typeof M=="number"){let U=b[A+1];D[M]=U}_[m]={input:l[m]??"",groups:D}}return _}static compareComponent(a,s,l){let _=t((A,M)=>{for(let U of["type","modifier","prefix","value","suffix"]){if(A[U]<M[U])return-1;if(A[U]!==M[U])return 1}return 0},"o"),m=new hG(3,"","","","",3),b=new hG(0,"","","","",3),D=t((A,M)=>{let U=0;for(;U<Math.min(A.length,M.length);++U){let ie=_(A[U],M[U]);if(ie)return ie}return A.length===M.length?0:_(A[U]??m,M[U]??m)},"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=p_t);import{AssertionError as olr}from"assert";function cA(a,s){if(a===!1)throw new olr({message:s})}t(cA,"assert");var Ac;(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"})(Ac||(Ac={}));function OM(a){return a.type===Ac.Object}t(OM,"isAstObject");function lA(a){return a.type===Ac.Property}t(lA,"isAstProperty");function d_t(a){return a.type===Ac.Array}t(d_t,"isAstArray");function FM(a){return a.type===Ac.Literal}t(FM,"isAstLiteral");function $O(a){if(a===void 0)throw new Error("Node is undefined");if(!OM(a))throw new Error("Node is not object")}t($O,"assertAstObject");import{findNodeAtLocation as clr,getNodeValue as llr,printParseErrorCode as ulr,visit as flr}from"jsonc-parser";var _lr={DEFAULT:{allowTrailingComma:!1}};function gG(a,s=[],l=_lr.DEFAULT){let _={type:"array",offset:-1,length:-1,line:-1,column:-1,children:[],parent:void 0};function m(M){_.type==="property"&&(_.length=M-_.offset,_=_.parent)}t(m,"ensurePropertyComplete");function b(M){return _.children?.push(M),M}t(b,"onValue"),flr(a,{onObjectBegin:t((M,U,ie)=>{_=b({type:"object",offset:M,length:-1,line:U+1,column:ie+1,parent:_,children:[]})},"onObjectBegin"),onObjectProperty:t((M,U,ie,se,Z)=>{_=b({type:"property",offset:U,length:-1,line:se+1,column:Z+1,parent:_,children:[]}),_.children?.push({type:"string",value:M,offset:U,length:ie,line:se,column:Z,parent:_})},"onObjectProperty"),onObjectEnd:t((M,U)=>{m(M+U),_.length=M+U-_.offset,_=_.parent,m(M+U)},"onObjectEnd"),onArrayBegin:t((M,U,ie,se)=>{_=b({type:"array",offset:M,length:-1,line:ie+1,column:se+1,parent:_,children:[]})},"onArrayBegin"),onArrayEnd:t((M,U)=>{_.length=M+U-_.offset,_=_.parent,m(M+U)},"onArrayEnd"),onLiteralValue:t((M,U,ie,se,Z)=>{b({type:plr(M),offset:U,length:ie,line:se+1,column:Z+1,parent:_,value:M}),m(U+ie)},"onLiteralValue"),onSeparator:t((M,U)=>{_.type==="property"&&(M===":"?_.colonOffset=U:M===","&&m(U))},"onSeparator"),onError:t((M,U,ie,se,Z)=>{s.push({error:M,offset:U,length:ie,line:se+1,column:Z+1})},"onError")},l);let A=_.children[0];return A&&delete A.parent,A}t(gG,"parse");function plr(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(plr,"getNodeType");function eNe(a,s){return clr(a,s)}t(eNe,"findNodeAtLocation");function yG(a){return llr(a)}t(yG,"getNodeValue");function m_t(a){return ulr(a)}t(m_t,"printParseErrorCode");var vG=class{static{t(this,"AstAdapter")}parse(s){let _=gG(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:Ac.Literal,location:{line:s.line,column:s.column},parent:l,value:s.type==="null"?null:s.value}}createObject(s,l){let _={type:Ac.Object,children:[],parent:l,location:{line:s.line,column:s.column}};return s.children?.forEach(m=>{_.children.push(this.parseNode(m,_))}),_}createProperty(s,l){cA(s.children?.length===2,"Invalid property node");let _={type:Ac.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:Ac.Identifier,parent:_},_.value=this.parseNode(s.children[1],_),_}createArray(s,l){let _={type:Ac.Array,location:{line:s.line,column:s.column},parent:l,children:[]};return s.children?.forEach(m=>_.children.push(this.parseNode(m,_))),_}};var $E={createLiteral:t((a,s)=>({type:Ac.Literal,parent:s,value:a}),"createLiteral"),createTemplateString:t((a,s)=>({type:Ac.TemplateString,parent:s,value:a}),"createTemplateString"),createIdentifier:t((a,s)=>({type:Ac.Identifier,value:a,parent:s}),"createIdentifier"),createProperty:t((a,s,l)=>{let _={type:Ac.Property,parent:l,name:null,value:s};return _.name={value:a,type:Ac.Identifier,parent:_},_.value.parent=_,_},"createProperty"),createArrayOfLiterals:t((a,s)=>{let l={type:Ac.Array,parent:s,children:[]};for(let _ of a)l.children.push($E.createLiteral(_,l));return l},"createArrayOfLiterals")};var dlr=/^[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 Ac.Array:return this.generateArray(s,l);case Ac.Object:return this.generateObject(s,l);case Ac.Property:return this.generateProperty(s,l);case Ac.Literal:return this.generateLiteral(s,l);case Ac.FunctionCall:return this.generateFunctionCall(s,l);case Ac.Identifier:return this.generateIdentifier(s,l);case Ac.Raw:return this.generateRaw(s,l);case Ac.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((_,m,b)=>{this.generateSource(s,_),m<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,m=JSON.stringify(_);return s.push(`${m}`)}}}generateIdentifier(s,l){let _=dlr.test(l.value)?l.value:`'${l.value}'`;s.push(_)}};import{parse as mlr}from"@swc/core";import hlr from"fs/promises";var h_t=t(async a=>{let s=new Set;try{let l=await hlr.readFile(a,"utf-8");(await mlr(l,{syntax:"typescript"})).body.forEach(m=>{m.type==="ExportDefaultDeclaration"||m.type==="ExportDefaultExpression"?s.add("default"):m.type==="ExportDeclaration"&&m.declaration.type==="FunctionDeclaration"?s.add(m.declaration.identifier.value):m.type==="ExportDeclaration"&&m.declaration.type==="VariableDeclaration"&&m.declaration.declarations[0].id.type==="Identifier"&&s.add(m.declaration.declarations[0].id.value)})}catch{return null}return s},"getJSFileExports");var g_t={$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 tNe={$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 y_t={$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 rNe={$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 nNe={$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 Nmt=S_(emt(),1),Imt=S_(Amt(),1);var Jue=class a{static{t(this,"JsonValidator")}static#r=new a;static get instance(){return a.#r}ajv;constructor(){this.ajv=new Imt.Ajv2020({allErrors:!0,allowUnionTypes:!0}),this.ajv.addKeyword("faker"),(0,Nmt.default)(this.ajv,{mode:"fast"})}addSchema(s,l){this.ajv.addSchema(s,l)}compile(s){let l=this.ajv.compile(s);return t(m=>({isValid:l(m),errors:this.toSimpleErrors(l.errors,m),warnings:[]}),"validator")}toSimpleErrors(s,l){let _=[];return s?.forEach(m=>{m.keyword==="enum"&&m.params.allowedValues&&Array.isArray(m.params.allowedValues)&&(m.message+=`; ${m.params.allowedValues.join(", ")}`),m.instancePath&&(m.instancePath=m.instancePath.replaceAll(/(\/)?(~1)(\/)?/gm,"/"));let b={details:{}},D=m.instancePath.split("/");if(D.length>2){let M=D[1],U=D[2]?parseInt(D[2]):0,ie=D[3],se=isNaN(U)?void 0:l[M][U][ie];b={details:{property:M,index:U,field:ie,fieldValue:se}}}if(m.keyword==="required"&&m.params.missingProperty&&m.instancePath&&(m.message=`A 'path' is missing required property '${m.params.missingProperty}'`),m.keyword==="additionalProperties"&&m.params.additionalProperty&&m.instancePath&&(m.message=`A 'path' should NOT include property '${m.params.additionalProperty}'`),m.keyword==="type"&&m.params.type&&m.instancePath){let M=m.instancePath.split("/"),U=M[M.length-1];m.message=`Value of property '${U}' must be '${m.params.type}'`}let A=Object.assign(m,b);_.push(A)}),_}};var D3=Jue.instance;D3.addSchema(nNe,"route-configuration.schema.json");D3.addSchema(y_t,"policy-configuration.schema.json");D3.addSchema(tNe,"policies.schema.json");D3.addSchema(rNe,"open-api-route-configuration.schema.json");D3.addSchema(g_t,"fragments.schema.json");var Z5r=D3.compile(nNe),Omt=D3.compile(rNe),y8e=D3.compile(tNe);var zue=class{static{t(this,"PoliciesConfigurationValidator")}results;validate(s){return this.results=y8e(s),this.results}};var que=class{static{t(this,"OpenAPILocalizedValidator")}results;validate(s){return this.results=Omt(s),this.results}};import Thr from"path";var v8e=/\$import\((.*)\)/,Vue=/\$env\((.*?)\)/g;var dA=class extends Error{static{t(this,"CodeGenError")}location;constructor(s,l,_,m){super(s),this.location={file:l,namespace:"",line:_?_.line:0,column:_?_.column:0,length:0,lineText:m??"",suggestion:""}}},Shr=t(a=>{let s=[],l=a;for(;l.parent;)s.push(l),l=l.parent;return s.reverse()},"invertTree"),k3=t((a,s)=>{if(!a)return!1;let l=Shr(a);return s.split("/").every((b,D)=>{let A=l[D];return A?b==="*"||lA(A)&&A.name.value===b?!0:b==="{}"?A.type===Ac.Object:b==="[]"?A.type===Ac.Array:!1:!1})},"testPosition");var Wue=class{static{t(this,"AstTransformer")}errors=[];transform(s){return this.visitor(s),s}visitor(s){this.visit(s),OM(s)?s.children.forEach(l=>{this.visitor(l)}):d_t(s)?s.children.forEach(l=>{this.visitor(l)}):lA(s)&&this.visitor(s.value)}},Fmt=t((a,s,l)=>_=>{if(!lA(_)||!FM(_.value)||typeof _.value.value!="string")return;if(!a.some(b=>k3(_,b))){Vue.test(_.value.value)&&s.push(new dA("An $env() statement is not expected at this location.",l,_.location,_.value.value));return}let m=new RegExp(Vue).exec(_.value.value);if(m?.length===2&&m[0]===_.value.value){let b={type:Ac.Raw,parent:null,value:`environment["${m[1]}"]`};_.value=b}else{let b=_.value.value.replaceAll(new RegExp(Vue),(D,A)=>`\${environment["${A}"] ? environment["${A}"] : ""}`);b!==_.value.value&&(_.value=$E.createTemplateString(b,_))}},"getEnvStatementTransformer");var ZG="config/routes.json",xhr=["handler/{}/options/*","policies/[]/{}/handler/{}/options/*","corsPolicies/[]/{}/*"],Ehr=["handler/{}/module","handler/{}/options/{}/policies/{}/inbound/[]/{}/module","handler/{}/options/{}/policies/{}/outbound/[]/{}/module","policies/[]/{}/handler/{}/module","policies/[]/{}/handler/{}/options/{}/identifier/{}/module","policies/[]/{}/handler/{}/options/{}/validator"],Lmt=["handler/{}/options/*","policies/[]/{}/handler/{}/options/*"],Chr="handler/{}/options/{}/rewritePattern",Dhr="handler/{}/options/{}/baseUrl",Hue=class extends Wue{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(!(!lA(s)||!FM(s.value)||typeof s.value.value!="string")&&k3(s,Chr)){if(!s.parent||!OM(s.parent)){this.errors.push(new dA("Invalid node, expected object",ZG,s.parent?s.parent.location:s.location,void 0));return}let l=s.value.value,_={type:Ac.Raw,parent:null,value:Rmt(l)},m=$E.createProperty("__rewriteFunction",_,s);s.parent.children.push(m)}}rewriteForwardFunction(s){if(!(!lA(s)||!FM(s.value)||typeof s.value.value!="string")&&k3(s,Dhr)){if(!s.parent||!OM(s.parent)){this.errors.push(new dA("Invalid node, expected object",ZG,s.parent?s.parent.location:s.location,void 0));return}let l=s.value.value,_={type:Ac.Raw,parent:null,value:Rmt(l)},m=$E.createProperty("__rewriteFunction",_,s);s.parent.children.push(m)}}replaceImportStatements(s){if(!lA(s)||!FM(s.value))return;let l=s.value.value;if(typeof l!="string")return;if(!Ehr.some(A=>k3(s,A))&&!Lmt.some(A=>k3(s,A))){if(v8e.test(l)){if(s.name.value==="$ref")return;this.errors.push(new dA("An $import() statement is not expected at this location.",ZG,s.location,l))}return}let _=v8e.exec(l);if(Lmt.some(A=>k3(s,A))&&!_)return;if(!_){this.errors.push(new dA("Invalid $import() statement",ZG,s.location,l));return}let m=_[1];m.startsWith(".")&&(m=Thr.join("..",m));let b=this.getImportName(m),D={type:Ac.Identifier,parent:s.parent,value:b};s.value=D}replaceEnvStatements=Fmt(xhr,this.errors,ZG)};function Rmt(a){return`(request, context) => {
560
+ `&&b++;else if(l)_+=D,b=m+2;else throw new XP(`Invalid escape \\${D}.`,{line:s.loc.start.line,column:s.loc.start.column+m,offset:s.loc.start.offset+m});m=a.indexOf("\\",b)}return _+=a.slice(b),_}t(Per,"getStringValue");function Aer(a,s,l=!1){switch(s.type){case"Boolean":return a==="true";case"Number":return Number(a);case"String":return Per(a.slice(1,-1),s,l);default:throw new TypeError(`Unknown token type "${s.type}.`)}}t(Aer,"getLiteralValue");function bot(a,s){s=Object.freeze({...wer,...s});let l=[],_=new N6e(a,{mode:s.mode,ranges:s.ranges}),m=s.mode==="json5",b=s.allowTrailingCommas||m;function D(){let br=_.next();return br&&s.tokens&&l.push(_.token),br}t(D,"nextNoComments");function A(){let br=_.next();return br&&s.tokens&&l.push(_.token),br>=x_.LineComment?A():br}t(A,"nextSkipComments");let M=s.mode==="json"?D:A;function U(br,mr){if(br!==mr)throw new EO(_.token)}t(U,"assertTokenType");function ie(br,mr){if(!mr.includes(br))throw new EO(_.token)}t(ie,"assertTokenTypes");function se(br,mr){return s.ranges?{range:[br.offset,mr.offset]}:void 0}t(se,"createRange");function Z(br){let mr=_.token,Is=se(mr.loc.start,mr.loc.end),Pi=Aer(a.slice(mr.loc.start.offset,mr.loc.end.offset),mr,m),Ti={loc:{start:{...mr.loc.start},end:{...mr.loc.end}},...Is};switch(br){case x_.String:return ST.string(Pi,Ti);case x_.Number:return ST.number(Pi,Ti);case x_.Boolean:return ST.boolean(Pi,Ti);default:throw new TypeError(`Unknown token type ${mr.type}.`)}}t(Z,"createLiteralNode");function Re(br){let mr=se(br.loc.start,br.loc.end),Is=a.slice(br.loc.start.offset,br.loc.end.offset),Po={loc:{start:{...br.loc.start},end:{...br.loc.end}},...mr};if(br.type!=="Identifier"){let Ti="";return(Is[0]==="+"||Is[0]==="-")&&(Ti=Is[0]),ST[Is.includes("NaN")?"nan":"infinity"](Ti,Po)}return ST.identifier(Is,Po)}t(Re,"createJSON5IdentifierNode");function Pe(br){let mr=se(br.loc.start,br.loc.end);return ST.null({loc:{start:{...br.loc.start},end:{...br.loc.end}},...mr})}t(Pe,"createNullNode");function ke(br){m?ie(br,[x_.String,x_.Identifier,x_.Number]):U(br,x_.String);let mr=_.token,Is=br===x_.String?Z(br):Re(mr);if(m&&(Is.type==="NaN"||Is.type==="Infinity")){if(Is.sign!=="")throw new EO(_.token);Is=ST.identifier(Is.type,{loc:Is.loc,...se(Is.loc.start,Is.loc.end)})}br=M(),U(br,x_.Colon);let Pi=yr(),Po=se(Is.loc.start,Pi.loc.end);return ST.member(Is,Pi,{loc:{start:{...Is.loc.start},end:{...Pi.loc.end}},...Po})}t(ke,"parseProperty");function wt(br){U(br,x_.LBrace);let mr=_.token,Is=[],Pi=M();if(Pi!==x_.RBrace)do{if(Is.push(ke(Pi)),Pi=M(),!Pi)throw new Wce(Is[Is.length-1].loc.end);if(Pi===x_.Comma){if(Pi=M(),b&&Pi===x_.RBrace)break}else break}while(Pi);U(Pi,x_.RBrace);let Po=_.token,Ti=se(mr.loc.start,Po.loc.end);return ST.object(Is,{loc:{start:{...mr.loc.start},end:{...Po.loc.end}},...Ti})}t(wt,"parseObject");function At(br){U(br,x_.LBracket);let mr=_.token,Is=[],Pi=M();if(Pi!==x_.RBracket)do{let _p=yr(Pi);if(Is.push(ST.element(_p,{loc:_p.loc})),Pi=M(),Pi===x_.Comma){if(Pi=M(),b&&Pi===x_.RBracket)break}else break}while(Pi);U(Pi,x_.RBracket);let Po=_.token,Ti=se(mr.loc.start,Po.loc.end);return ST.array(Is,{loc:{start:{...mr.loc.start},end:{...Po.loc.end}},...Ti})}t(At,"parseArray");function yr(br){br=br??M();let mr=_.token;switch(br){case x_.String:case x_.Boolean:return Z(br);case x_.Number:if(m){let Is=a.slice(mr.loc.start.offset,mr.loc.end.offset);if((Is[0]==="+"||Is[0]==="-")&&(Is=Is.slice(1)),Is==="NaN"||Is==="Infinity")return Re(mr)}return Z(br);case x_.Null:return Pe(mr);case x_.LBrace:return wt(br);case x_.LBracket:return At(br);default:throw new EO(mr)}}t(yr,"parseValue");let zr=yr();if(M())throw new EO(_.token);let hn={loc:{start:{line:1,column:1,offset:0},end:{...zr.loc.end}}};return s.tokens&&(hn.tokens=l),s.ranges&&(hn.range=[hn.loc.start.offset,hn.loc.end.offset]),ST.document(zr,hn)}t(bot,"parse");var Ner=new Map([["Document",["body"]],["Object",["members"]],["Member",["name","value"]],["Element",["value"]],["Array",["elements"]],["String",[]],["Number",[]],["Boolean",[]],["Null",[]],["NaN",[]],["Infinity",[]],["Identifier",[]]]);function Sot(a){return a&&typeof a=="object"}t(Sot,"isObject");function Ier(a){return Sot(a)&&typeof a.type=="string"}t(Ier,"isNode");function Oer(a,s){function l(_,m){typeof s.enter=="function"&&s.enter(_,m);for(let b of Ner.get(_.type)){let D=_[b];Sot(D)&&(Array.isArray(D)?D.forEach(A=>l(A,_)):Ier(D)&&l(D,_))}typeof s.exit=="function"&&s.exit(_,m)}t(l,"visitNode"),l(a)}t(Oer,"traverse");function Tot(a,s=()=>!0){let l=[];return Oer(a,{enter(_,m){l.push({node:_,parent:m,phase:"enter"})},exit(_,m){l.push({node:_,parent:m,phase:"exit"})}}),l.filter(s).values()}t(Tot,"iterator");import Fer from"fs/promises";var OH=t((a,s)=>a.split(/\r?\n/)[s-1],"getFileLineContent"),Hce=t(async a=>{try{return await Fer.readFile(a,"utf-8")}catch{return}},"getSchemaContent"),FH=t(async a=>{try{return bot(a)}catch(s){if(s.column&&s.line&&s.message){let l=OH(a,s.line);return{column:s.column,line:s.line,length:void 0,lineText:l}}return}},"getSchemaAST");var xot=t(async(a,s,l)=>{try{if(a.length===0)return;for(let _ of a){let m=await Hce(_),b=await Ler(m,_,s,l);if(b)return b}}catch{}},"getRouteLocationByValue"),Ler=t(async(a,s,l,_)=>{try{if(!a)return;let m=null,b=await FH(a);if(b){for(let{node:D}of Tot(b))if(D.value&&D.value===l){m=D.loc;break}if(m!==null){let D=OH(a,m.start.line);return{file:s,line:m.start.line,column:m.start.column,length:m.end.column-m.start.column,lineText:D,suggestion:_}}}}catch{}},"getRouteLocationByValueFromSchema");import Eot from"fs/promises";import Gce from"path";var I6e="schemas",O6e=".oas.json";var CO=t(async a=>(await Eot.readdir(a)).map(l=>`${a}/${l}`).filter(l=>l.endsWith(O6e)).sort(),"getOpenApiFilesByAlphabetical"),cM=t(async a=>{let s=Gce.resolve(a,"config");return(await Eot.readdir(s)).filter(_=>_.endsWith(O6e)).length>=1},"oasFileInProject");function LH(a,s,l,_,m,b,D){if(b.has(l))return;let A;try{A=_.get(l)}catch(M){throw new M1({text:`Failed to resolve reference: ${l}`,detail:M.message,severity:"error",message:"Failed to resolve reference",location:{file:a,column:0,line:0,length:0,lineText:l,namespace:s,suggestion:"Check the reference and try again."}})}b.set(l,m.length),m.push(l),F6e(L6e(l),s,A,_,m,b,D)}t(LH,"chaseRefs");function F6e(a,s,l,_,m,b,D){if(Array.isArray(l))for(let A of l)F6e(a,s,A,_,m,b,D);else if(typeof l=="object")for(let A in l){if(A==="$ref"){let M=l[A];D&&(l[A]=D(s,M)),LH(a,s,n3(a,M),_,m,b,D)}F6e(a,s,l[A],_,m,b,D)}}t(F6e,"lookForRefs");function n3(a,s){let l=s.indexOf("#");return l>=0?`${Gce.resolve(a,s.substring(0,l))}${s.substring(l)}`:Gce.resolve(Gce.dirname(a),s)}t(n3,"getFullyQualifiedRefName");function L6e(a){let s=a.indexOf("#");return s>=0?a.substring(0,s):a}t(L6e,"getFilePathNameFromRefName");var R6e=class{static{t(this,"Environment")}get WORKING_COPY_ENVIRONMENT(){return process.env.WORKING_COPY_ENVIRONMENT??"staging"}get ZUP_HOSTNAME(){return process.env.ZUP_HOSTNAME??"zuplo.app"}get ZUP_WORKING_COPY_HOSTNAME(){return process.env.ZUP_WORKING_COPY_HOSTNAME?process.env.ZUP_WORKING_COPY_HOSTNAME:this.WORKING_COPY_ENVIRONMENT==="staging"?"d1.zuplo.dev":"d2.zuplo.dev"}},Rer=new R6e,M6e=Rer;var QH=S_(Q4e(),1);var Z4e={};yst(Z4e,{UnsafePathError:()=>Sle,deleteFile:()=>Ssr,deleteFolder:()=>Asr,dirExists:()=>Tle,ensureDirectoryExists:()=>Csr,fileExists:()=>bsr,getParentDirFilename:()=>ksr,isNotFileOrDirectory:()=>Tsr,listFolderContents:()=>Qlt,listFolders:()=>Esr,mkdirForFilePathIfNotExits:()=>eut,mkdirIfNotExists:()=>Zlt,safePath:()=>Dsr,tarFolderContent:()=>wsr,untar:()=>Psr});import Ylt from"child_process";import f3 from"fs/promises";import u3 from"path";var Xlt=[".git","node_modules",".yarn",".DS_Store"];async function bsr(a){try{return(await f3.stat(a)).isFile()}catch{return!1}}t(bsr,"fileExists");async function Ssr(a,s){return await f3.rm(a,s)}t(Ssr,"deleteFile");async function Tle(a){try{return(await f3.stat(a)).isDirectory()}catch{return!1}}t(Tle,"dirExists");async function Tsr(a){try{return await f3.stat(a),!1}catch{return!0}}t(Tsr,"isNotFileOrDirectory");function xsr(a,s){let l=new RegExp(`(.*)(\\/${s})$|(.*)(${s}\\/)`),_=a.match(l);if(!_)return"";let m=a.split(_[0]);return m[1]===""?"":`/${m[1]}`}t(xsr,"getParentDirectory");async function Esr(a){if(!await Tle(a))return[];let s=await f3.readdir(a,{withFileTypes:!0}),l=[];for await(let _ of s)Xlt.includes(_.name)||_.isDirectory()&&l.push(_.name);return l}t(Esr,"listFolders");async function Qlt(a,s,l=!0){let _=xsr(a,s),m=await f3.readdir(a,{withFileTypes:!0}),b=[];for await(let D of m)if(!Xlt.includes(D.name)||!l)if(D.isDirectory()){let A=await Qlt(u3.join(a,D.name),s,l);b.push(...A)}else b.push(u3.join(_,D.name));return b}t(Qlt,"listFolderContents");var Zlt=t(async a=>{if(await Tle(a))return!0;await f3.mkdir(a,{recursive:!0})},"mkdirIfNotExists"),eut=t(async a=>{let s=u3.dirname(a);return Zlt(s)},"mkdirForFilePathIfNotExits"),Csr=eut,Sle=class extends Error{static{t(this,"UnsafePathError")}constructor(s){super(s)}};function Dsr(a){let s=t(l=>{if(!l.startsWith(a))throw new Sle("Resolved path is not part of the project.");return l},"ensureSafePath");return{resolve:t((...l)=>s(u3.resolve(...l)),"resolve")}}t(Dsr,"safePath");function ksr(a){return`${u3.basename(u3.dirname(a))}/${u3.basename(a)}`}t(ksr,"getParentDirFilename");function wsr(a,s,l,_){let m=u3.join(_,l);return Ylt.execSync(`tar --exclude='.git/' --exclude='dist/' -czf ${m} ${s}`,{cwd:a}),m}t(wsr,"tarFolderContent");function Psr(a,s,l,_=!1){Ylt.execSync(`tar -xf ${s} ${_?"--strip-components=1 ":""}-C ${l}`,{cwd:a})}t(Psr,"untar");async function Asr(a){if(await Tle(a))return await f3.rm(a,{recursive:!0})}t(Asr,"deleteFolder");var wl=Z4e;var CT=S_(Q4e(),1);import{readFile as Nsr}from"fs/promises";var FO=class extends Error{static{t(this,"CustomResolveError")}},_3=class{static{t(this,"RefParser")}sourceDirectory;logger;constructor(s,l){this.sourceDirectory=s,this.logger=l}dereference(s,l){return QH.$RefParser.dereference(s,{resolve:{json:!0,file:xle(this.sourceDirectory,this.logger),external:!0,http:!1},dereference:{circular:"ignore",onDereference:l?.onDereference}})}bundle(s){return QH.$RefParser.bundle(s,{resolve:{file:xle(this.sourceDirectory,this.logger),external:!0,http:!1}})}parse(s){return QH.$RefParser.parse(s,{resolve:{file:xle(this.sourceDirectory,this.logger),external:!0,http:!1}})}resolve(s){return QH.$RefParser.resolve(s,{resolve:{file:xle(this.sourceDirectory,this.logger),external:!0,http:!1}})}};function xle(a,s){return{order:100,canRead(l){let _=Fsr(l.url);if(!(_===void 0||_==="file"))return!1;let b;try{b=tut(l.url)}catch(D){throw new FO(`Malformed URI: ${l.url}`,{cause:D})}try{wl.safePath(a).resolve(b)}catch(D){return s?.warn(D),!1}return!0},async read(l){let _;try{_=tut(l.url)}catch(m){throw new FO(`Malformed URI: ${l.url}`,{cause:m})}try{return await Nsr(_)}catch(m){throw new FO(`Error opening file "${_}"`,{cause:m})}}}}t(xle,"customResolver");var e3e=/^win/.test(globalThis.process?globalThis.process.platform:""),Isr=/\//g,Osr=/^(\w{2,}):\/\//i,t3e=[/%23/g,"#",/%24/g,"$",/%26/g,"&",/%2C/g,",",/%40/g,"@"];function Fsr(a){let s=Osr.exec(a);if(s)return s[1].toLowerCase()}t(Fsr,"getProtocol");function tut(a,s){a=decodeURI(a);for(let _=0;_<t3e.length;_+=2)a=a.replace(t3e[_],t3e[_+1]);let l=a.substr(0,7).toLowerCase()==="file://";return l&&(a=a[7]==="/"?a.substr(8):a.substr(7),e3e&&a[1]==="/"&&(a=a[0]+":"+a.substr(1)),s?a="file:///"+a:(l=!1,a=e3e?a:"/"+a)),e3e&&!l&&(a=a.replace(Isr,"\\"),a.substr(1,2)===":\\"&&(a=a[0].toUpperCase()+a.substr(1))),a}t(tut,"toFileSystemPath");var rut="YOUR_KEY_HERE";async function nut(a){let l=await new _3(a.sourceDirectory,a.logger).bundle(a.openApiDocPath),_=a.openApiDocPath.replace(a.sourceDirectory,"");return Lsr({...a,relativeOpenApiPath:_},l)}t(nut,"buildPublicOpenApiFile");async function Lsr(a,s){Bsr({relativeOpenApiPath:a.relativeOpenApiPath},s);let l=s;return l=Msr(l),Rsr(l,a),l=jsr(l,a),iut(l,"x-zuplo"),l}t(Lsr,"buildRawOpenApiFile");function Rsr(a,{customDomain:s,deploymentName:l,environmentType:_}){let m;s?m=s:_&&l&&(m=_===dce.WORKING_COPY?`${l}.${M6e.ZUP_WORKING_COPY_HOSTNAME}`:`${l}.${M6e.ZUP_HOSTNAME}`),m?a.servers=[{url:`https://${m}`}]:a.servers=void 0}t(Rsr,"addServerHost");function Msr(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,A])=>(KR in A&&mce(A[KR])&&(b.push(D),l.parameters&&delete l.parameters[D]),b),[]));let m=Object.entries(a.paths).reduce((b,[D,A])=>{if(!A)return b;let M={...A},U=["delete","get","head","patch","post","put","trace","options"];return U.forEach(ie=>{let se=A[ie];if(!se)return;if(mce(se[KR])){delete M[ie];return}let{parameters:Z}=se;if(!Z)return;let Re=Z.filter(Pe=>{if(KR in Pe&&mce(Pe[KR]))return!1;if("$ref"in Pe){let ke=Pe.$ref.split("/").pop();return ke?!_.includes(ke):!0}return!0});M[ie]={...se,parameters:Re}}),U.some(ie=>!!M[ie])&&(b[D]=M),b},{});return{...a,paths:m,components:l}}t(Msr,"removeHiddenRoutesAndParams");function jsr(a,{policiesConfig:s}){if(!a.paths)return a;let l=Object.entries(a.paths).reduce((_,[m,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(A=>{if(!A)return;let M=A["x-zuplo-route"]?.policies?.inbound?.reduce((se,Z)=>{let Re=s.policies?.find(({name:wt})=>wt===Z);if(!Re)return se;if(!(Re.handler.export==="CompositeInboundPolicy"))return se.concat(Z);let ke=Re.handler.options?.policies;return ke?se.concat(ke):se},[]),U=[];if(M&&M.forEach(se=>{s.policies?.forEach(Z=>{Z.name===se&&(Z.handler.export==="ApiAuthKeyInboundPolicy"||Z.handler.export==="ApiKeyInboundPolicy")&&!Z.handler.options?.disableAutomaticallyAddingKeyHeaderToOpenApi&&U.push(Z)})}),U.length>0){let se=U.length>0&&U[0].handler&&U[0].handler.options&&U[0].handler.options.authHeader?U[0].handler.options.authHeader:"Authorization",Z=U.length>0&&U[0].handler&&U[0].handler.options&&(U[0].handler.options.authScheme||U[0].handler.options.authScheme==="")?U[0].handler.options.authScheme:"Bearer",Re=Z!==""?`${Z} ${rut}`:rut,Pe={name:se,in:"header",required:!0,example:Re,schema:{type:"string"},description:`The \`${se}\` header is used to authenticate with the API using your API key. Value is of the format \`${Re}\`.`};A.parameters?A.parameters.some(yr=>"name"in yr&&yr.name===Pe.name)||A.parameters.unshift(Pe):A.parameters=[Pe];let ke={type:"http",scheme:Z.toLowerCase()},wt="api_key";a.components?.securitySchemes?Object.values(a.components?.securitySchemes).some(yr=>"name"in yr&&yr.type==="apiKey"||"type"in yr&&yr.type==="http"&&yr.scheme===Z)||(a.components.securitySchemes={...a.components.securitySchemes,[wt]:ke}):(a.components||(a.components={}),a.components.securitySchemes={[wt]:ke});let At={[wt]:[]};A.security?A.security.some(yr=>yr[wt]!==void 0)||A.security.unshift(At):A.security=[At]}let ie=[];if(M&&M.forEach(se=>{s.policies?.forEach(Z=>{Z.name===se&&(Z.handler.export==="RateLimitInboundPolicy"||Z.handler.export==="ComplexRateLimitInboundPolicy")&&ie.push(Z)})}),ie.length>0){let se={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"}}}}}},Z={...se,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:se,RateLimitWithRetryAfter:Z},A.responses||(A.responses={});let Re=ie.some(Pe=>Pe.handler.options?.headerMode!=="none");A.responses[429]||(A.responses[429]={$ref:Re?"#/components/responses/RateLimitWithRetryAfter":"#/components/responses/RateLimitNoRetryAfter"})}}),_[m]=D,_},{});return{...a,paths:l}}t(jsr,"enrichSpecWithZuploData");function iut(a,s){for(let l in a)l.startsWith(s)?delete a[l]:typeof a[l]=="object"&&iut(a[l],s)}t(iut,"removePropertiesByPrefix");function Bsr({relativeOpenApiPath:a},s){if(!s||typeof s!="object")throw new M1({message:"The OpenAPI Document could not be parsed.",severity:"error"});if(!("info"in s)||typeof s.info!="object"||!s.info)throw new M1({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 M1({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(Bsr,"assertIsZuploOpenApiSpec");function Usr(a){if(a.length>=255)throw new TypeError("Alphabet too long");let s=new Uint8Array(256);for(let U=0;U<s.length;U++)s[U]=255;for(let U=0;U<a.length;U++){let ie=a.charAt(U),se=ie.charCodeAt(0);if(s[se]!==255)throw new TypeError(ie+" is ambiguous");s[se]=U}let l=a.length,_=a.charAt(0),m=Math.log(l)/Math.log(256),b=Math.log(256)/Math.log(l);function D(U){if(U instanceof Uint8Array||(ArrayBuffer.isView(U)?U=new Uint8Array(U.buffer,U.byteOffset,U.byteLength):Array.isArray(U)&&(U=Uint8Array.from(U))),!(U instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(U.length===0)return"";let ie=0,se=0,Z=0,Re=U.length;for(;Z!==Re&&U[Z]===0;)Z++,ie++;let Pe=(Re-Z)*b+1>>>0,ke=new Uint8Array(Pe);for(;Z!==Re;){let yr=U[Z],zr=0;for(let en=Pe-1;(yr!==0||zr<se)&&en!==-1;en--,zr++)yr+=256*ke[en]>>>0,ke[en]=yr%l>>>0,yr=yr/l>>>0;if(yr!==0)throw new Error("Non-zero carry");se=zr,Z++}let wt=Pe-se;for(;wt!==Pe&&ke[wt]===0;)wt++;let At=_.repeat(ie);for(;wt<Pe;++wt)At+=a.charAt(ke[wt]);return At}t(D,"encode");function A(U){if(typeof U!="string")throw new TypeError("Expected String");if(U.length===0)return new Uint8Array;let ie=0,se=0,Z=0;for(;U[ie]===_;)se++,ie++;let Re=(U.length-ie)*m+1>>>0,Pe=new Uint8Array(Re);for(;U[ie];){let yr=s[U.charCodeAt(ie)];if(yr===255)return;let zr=0;for(let en=Re-1;(yr!==0||zr<Z)&&en!==-1;en--,zr++)yr+=l*Pe[en]>>>0,Pe[en]=yr%256>>>0,yr=yr/256>>>0;if(yr!==0)throw new Error("Non-zero carry");Z=zr,ie++}let ke=Re-Z;for(;ke!==Re&&Pe[ke]===0;)ke++;let wt=new Uint8Array(se+(Re-ke)),At=se;for(;ke!==Re;)wt[At++]=Pe[ke++];return wt}t(A,"decodeUnsafe");function M(U){let ie=A(U);if(ie)return ie;throw new Error("Non-base"+l+" character")}return t(M,"decode"),{encode:D,decodeUnsafe:A,decode:M}}t(Usr,"base");var sut=Usr;var $sr="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",Ele=sut($sr);var r3e="2024-09-02",aut=Object.freeze({none:{runOutboundPoliciesOnHandlerOnAllStatuses:!1,doNotRunHooksOnSystemRoutes:!1,removeAllVendorHeadersExceptListed:!1,allowCustomPorts:!1},"2023-03-14":{runOutboundPoliciesOnHandlerOnAllStatuses:!1,doNotRunHooksOnSystemRoutes:!1,removeAllVendorHeadersExceptListed:!1,allowCustomPorts:!1},"2024-01-15":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!1},"2024-03-14":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!1},"2024-09-02":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!0}});function out(){return new DT({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:r3e,ENVIRONMENT_TYPE:"mock-environment-type",GIT_SHA:void 0,IS_LOCAL_DEVELOPMENT:!1,COMPATIBILITY_FLAGS:aut[r3e]},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(out,"getMockEnvironment");var DT=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=out()),this.#r}constructor({build:s,runtime:l}){let _;try{if(l.__ZUPLO_CONFIG){let m=atob(l.__ZUPLO_CONFIG);_=JSON.parse(m)}if(l.ZUPLO_SYSTEM_CONFIGURATIONS){let m=new TextDecoder().decode(Ele.decode(l.ZUPLO_SYSTEM_CONFIGURATIONS)),b=JSON.parse(m);for(let D of Object.keys(b))l[D]||(l[D]=b[D])}}catch(m){console.error("Failed to parse runtime configuration",m)}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 zudokuHostUrl(){return this.runtime.__ZUPLO_ZUDOKU_HOST_URL??this.config.zudoku_host_url??"https://zudoku.zuploedge.com"}get buildAssetsUrl(){return this.runtime.__ZUPLO_BUILD_ASSETS_URL??this.config.build_assets_url??"https://build-assets.zuplo.com"}get zuploEdgeApiUrl(){return this.config.zuplo_edge_api_url??"https://api.zuploedge.com"}get remoteLogToken(){return this.runtime.__ZUPLO_REMOTE_LOG_TOKEN??this.config.remote_log_token??void 0}get zuploClientAuthBucketId(){return this.config.zuplo_auth_client_bucket_id??"auth_o8PUdhKxSTOiB794GWPwLQCD"}get managementApiURL(){return this.runtime.__ZUPLO_MANAGEMENT_API_URL??this.config.management_api_url??"https://api.zuplo.com"}get developerApiUrl(){return this.config.developer_api_url??"https://dev.zuplo.com"}get cdnURL(){return this.runtime.__ZUPLO_CDN_URL??this.config.cdn_url??"https://cdn.zuplo.com"}get remoteLogURL(){return this.runtime.__ZUPLO_REMOTE_LOG_URL??this.config.log_event_api??"https://ellie.zuploedge.com"}get loggingId(){return this.runtime.__ZUPLO_LOGGING_ID??this.config.logging_id??void 0}get redisURL(){return this.runtime.__ZUPLO_REDIS_URL??this.config.redis_proxy_url??"https://redis-proxy.zuploedge.com"}get apiKeyServiceUrl(){return this.runtime.__ZUPLO_API_KEY_SERVICE_URL??this.config.api_key_service_url??"https://apikey.zuploedge.com"}get meteringServiceUrl(){return this.config.metering_service_url??"https://meters.zuploedge.com"}get authApiJWT(){return this.runtime.__ZUPLO_AUTH_API_JWT??void 0}get authClientId(){return this.runtime.__ZUPLO_AUTH_CLIENT_ID}get authClientSecret(){return this.runtime.__ZUPLO_AUTH_CLIENT_SECRET}get userLogLevel(){return this.runtime.ZUPLO_LOG_LEVEL??this.runtime.__ZUPLO_LOG_LEVEL??this.config.user_log_level??"debug"}get systemLogLevel(){return this.runtime.__ZUPLO_LOG_LEVEL??this.config.system_log_level??"debug"}get logFormat(){return this.runtime.__ZUPLO_LOG_FORMAT??this.config.log_format??"cloudflare"}get isCloudflare(){return this.runtime.__ZUPLO_RUNTIME_TYPE?this.runtime.__ZUPLO_RUNTIME_TYPE==="cloudflare":this.config.runtime_type?this.config.runtime_type==="cloudflare":typeof WebSocketPair=="function"}get isDeno(){return this.runtime.__ZUPLO_RUNTIME_TYPE?this.runtime.__ZUPLO_RUNTIME_TYPE==="deno":this.config.runtime_type?this.config.runtime_type==="deno":typeof WebSocketPair!="function"}get isLocalDevelopment(){return this.build.IS_LOCAL_DEVELOPMENT}get isTestMode(){return!!this.runtime.__ZUPLO_TEST_MODE}get systemUserAgent(){return`Zuplo/${this.build.ZUPLO_VERSION}`}get loggingEnvironmentType(){return this.isCloudflare?"edge":this.isLocalDevelopment?"local":this.isDeno?"working-copy":"unknown"}get loggingEnvironmentStage(){return this.build.ENVIRONMENT_TYPE==="PRODUCTION"?"production":this.build.ENVIRONMENT_TYPE==="PREVIEW"?"preview":this.isLocalDevelopment?"local":this.isWorkingCopy?"working-copy":"unknown"}get isWorkingCopy(){return this.build.ENVIRONMENT_TYPE==="WORKING_COPY"}};var Jsr=["ZUPLO_USER_LOGGER_DATA_DOG_API_KEY","ZUPLO_USER_LOGGER_DATA_DOG_URL","ZUPLO_LOG_LEVEL","ZUPLO_HANDLER_WRITE_LOG_LEVEL"];function cut(a){return a.startsWith("__ZUPLO")||a.startsWith("ZUPLO_")?!Jsr.includes(a)&&!a.startsWith("ZUPLO_PUBLIC_"):!1}t(cut,"isRestrictedEnvVariableName");function lut(a){return!!a.startsWith("ZUPLO_")}t(lut,"isZuploReadableEnvVariableName");var e8r=new Proxy({},{get(a,s){let l=String(s);switch(l){case"ZUPLO_ENVIRONMENT_TYPE":return DT.instance.loggingEnvironmentType;case"ZUPLO_ENVIRONMENT_STAGE":return DT.instance.loggingEnvironmentStage;case"ZUPLO_ENVIRONMENT_NAME":return DT.instance.runtime.__ZUPLO_DEPLOYMENT_NAME;case"ZUPLO_ACCOUNT_NAME":return DT.instance.build.ACCOUNT_NAME;case"ZUPLO_PROJECT_NAME":return DT.instance.build.PROJECT_NAME;case"ZUPLO_BUILD_ID":return DT.instance.build.BUILD_ID}if(!(cut(l)&&!lut(l)))return DT.instance.runtime[l]}});function ZH(a,s,l){return`_${rA(`${a}_${s}_${l}`)}`}t(ZH,"getRawOperationDataIdentifierName");function n3e(a,s,l,_){return`_${rA(a.toLowerCase())}_${s.toLowerCase()}_${l.toLowerCase()}_${_.toLowerCase()}`}t(n3e,"getIdForParameterSchema");function i3e(a,s,l){return`_${rA(a.toLowerCase())}_${s.toLowerCase()}_rb_${rA(l.toLowerCase())}`}t(i3e,"getIdForRequestBodySchema");function eG(a,s){return`_${rA(a)}_${rA(s)}`}t(eG,"getIdForRefSchema");function rA(a){return a.replace(/[^a-zA-Z0-9]/g,"_")}t(rA,"sanitizedIdentifierName");var $mt=S_(Zft(),1);import Yue from"path";var hG=class{static{t(this,"R")}type=3;name="";prefix="";value="";suffix="";modifier=3;constructor(a,s,l,_,m,b){this.type=a,this.name=s,this.prefix=l,this.value=_,this.suffix=m,this.modifier=b}hasCustomName(){return this.name!==""&&typeof this.name!="number"}},Rcr=/[$_\p{ID_Start}]/u,Mcr=/[$_\u200C\u200D\p{ID_Continue}]/u,Q3e=".*";function jcr(a,s){return(s?/^[\x00-\xFF]*$/:/^[\x00-\x7F]*$/).test(a)}t(jcr,"Re");function r_t(a,s=!1){let l=[],_=0;for(;_<a.length;){let m=a[_],b=t(function(D){if(!s)throw new TypeError(D);l.push({type:"INVALID_CHAR",index:_,value:a[_++]})},"c");if(m==="*"){l.push({type:"ASTERISK",index:_,value:a[_++]});continue}if(m==="+"||m==="?"){l.push({type:"OTHER_MODIFIER",index:_,value:a[_++]});continue}if(m==="\\"){l.push({type:"ESCAPED_CHAR",index:_++,value:a[_++]});continue}if(m==="{"){l.push({type:"OPEN",index:_,value:a[_++]});continue}if(m==="}"){l.push({type:"CLOSE",index:_,value:a[_++]});continue}if(m===":"){let D="",A=_+1;for(;A<a.length;){let M=a.substr(A,1);if(A===_+1&&Rcr.test(M)||A!==_+1&&Mcr.test(M)){D+=a[A++];continue}break}if(!D){b(`Missing parameter name at ${_}`);continue}l.push({type:"NAME",index:_,value:D}),_=A;continue}if(m==="("){let D=1,A="",M=_+1,U=!1;if(a[M]==="?"){b(`Pattern cannot start with "?" at ${M}`);continue}for(;M<a.length;){if(!jcr(a[M],!1)){b(`Invalid character '${a[M]}' at ${M}.`),U=!0;break}if(a[M]==="\\"){A+=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}`),U=!0;break}A+=a[M++]}if(U)continue;if(D){b(`Unbalanced pattern at ${_}`);continue}if(!A){b(`Missing pattern at ${_}`);continue}l.push({type:"REGEX",index:_,value:A}),_=M;continue}l.push({type:"CHAR",index:_,value:a[_++]})}return l.push({type:"END",index:_,value:""}),l}t(r_t,"v");function n_t(a,s={}){let l=r_t(a);s.delimiter??="/#?",s.prefixes??="./";let _=`[^${AT(s.delimiter)}]+?`,m=[],b=0,D=0,A="",M=new Set,U=t(zr=>{if(D<l.length&&l[D].type===zr)return l[D++].value},"a"),ie=t(()=>U("OTHER_MODIFIER")??U("ASTERISK"),"f"),se=t(zr=>{let en=U(zr);if(en!==void 0)return en;let{type:hn,index:br}=l[D];throw new TypeError(`Unexpected ${hn} at ${br}, expected ${zr}`)},"d"),Z=t(()=>{let zr="",en;for(;en=U("CHAR")??U("ESCAPED_CHAR");)zr+=en;return zr},"T"),Re=t(zr=>zr,"Se"),Pe=s.encodePart||Re,ke="",wt=t(zr=>{ke+=zr},"U"),At=t(()=>{ke.length&&(m.push(new hG(3,"","",Pe(ke),"",3)),ke="")},"$"),yr=t((zr,en,hn,br,mr)=>{let Is=3;switch(mr){case"?":Is=1;break;case"*":Is=0;break;case"+":Is=2;break}if(!en&&!hn&&Is===3){wt(zr);return}if(At(),!en&&!hn){if(!zr)return;m.push(new hG(3,"","",Pe(zr),"",Is));return}let Pi;hn?hn==="*"?Pi=Q3e:Pi=hn:Pi=_;let Po=2;Pi===_?(Po=1,Pi=""):Pi===Q3e&&(Po=0,Pi="");let Ti;if(en?Ti=en:hn&&(Ti=b++),M.has(Ti))throw new TypeError(`Duplicate name '${Ti}'.`);M.add(Ti),m.push(new hG(Po,Ti,Pe(zr),Pi,Pe(br),Is))},"V");for(;D<l.length;){let zr=U("CHAR"),en=U("NAME"),hn=U("REGEX");if(!en&&!hn&&(hn=U("ASTERISK")),en||hn){let mr=zr??"";s.prefixes.indexOf(mr)===-1&&(wt(mr),mr=""),At();let Is=ie();yr(mr,en,hn,"",Is);continue}let br=zr??U("ESCAPED_CHAR");if(br){wt(br);continue}if(U("OPEN")){let mr=Z(),Is=U("NAME"),Pi=U("REGEX");!Is&&!Pi&&(Pi=U("ASTERISK"));let Po=Z();se("CLOSE");let Ti=ie();yr(mr,Is,Pi,Po,Ti);continue}At(),se("END")}return m}t(n_t,"D");function AT(a){return a.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}t(AT,"S");function e_t(a){return a&&a.ignoreCase?"ui":"u"}t(e_t,"X");function Bcr(a,s,l){return i_t(n_t(a,l),s,l)}t(Bcr,"Z");function IM(a){switch(a){case 0:return"*";case 1:return"?";case 2:return"+";case 3:return""}}t(IM,"k");function i_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 A of a){if(A.type===3){A.modifier===3?_+=AT(A.value):_+=`(?:${AT(A.value)})${IM(A.modifier)}`;continue}s&&s.push(A.name);let M=`[^${AT(l.delimiter)}]+?`,U=A.value;if(A.type===1?U=M:A.type===0&&(U=Q3e),!A.prefix.length&&!A.suffix.length){A.modifier===3||A.modifier===1?_+=`(${U})${IM(A.modifier)}`:_+=`((?:${U})${IM(A.modifier)})`;continue}if(A.modifier===3||A.modifier===1){_+=`(?:${AT(A.prefix)}(${U})${AT(A.suffix)})`,_+=IM(A.modifier);continue}_+=`(?:${AT(A.prefix)}`,_+=`((?:${U})(?:`,_+=AT(A.suffix),_+=AT(A.prefix),_+=`(?:${U}))*)${AT(A.suffix)})`,A.modifier===0&&(_+="?")}let m=`[${AT(l.endsWith)}]|$`,b=`[${AT(l.delimiter)}]`;if(l.end)return l.strict||(_+=`${b}?`),l.endsWith.length?_+=`(?=${m})`:_+="$",new RegExp(_,e_t(l));l.strict||(_+=`(?:${b}(?=${m}))?`);let D=!1;if(a.length){let A=a[a.length-1];A.type===3&&A.modifier===3&&(D=l.delimiter.indexOf(A)>-1)}return D||(_+=`(?=${b}|${m})`),new RegExp(_,e_t(l))}t(i_t,"F");var h3={delimiter:"",prefixes:"",sensitive:!0,strict:!0},Ucr={delimiter:".",prefixes:"",sensitive:!0,strict:!0},$cr={delimiter:"/",prefixes:"/",sensitive:!0,strict:!0};function Jcr(a,s){return a.length?a[0]==="/"?!0:!s||a.length<2?!1:(a[0]=="\\"||a[0]=="{")&&a[1]=="/":!1}t(Jcr,"J");function s_t(a,s){return a.startsWith(s)?a.substring(s.length,a.length):a}t(s_t,"Q");function zcr(a,s){return a.endsWith(s)?a.substr(0,a.length-s.length):a}t(zcr,"Ee");function a_t(a){return!a||a.length<2?!1:a[0]==="["||(a[0]==="\\"||a[0]==="{")&&a[1]==="["}t(a_t,"W");var o_t=["ftp","file","http","https","ws","wss"];function c_t(a){if(!a)return!0;for(let s of o_t)if(a.test(s))return!0;return!1}t(c_t,"N");function qcr(a,s){if(a=s_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(qcr,"te");function Vcr(a,s){if(a=s_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(Vcr,"re");function Wcr(a,s){return s||a===""?a:a_t(a)?f_t(a):u_t(a)}t(Wcr,"ne");function Hcr(a,s){if(s||a==="")return a;let l=new URL("https://example.com");return l.password=a,l.password}t(Hcr,"se");function Gcr(a,s){if(s||a==="")return a;let l=new URL("https://example.com");return l.username=a,l.username}t(Gcr,"ie");function Kcr(a,s,l){if(l||a==="")return a;if(s&&!o_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(Kcr,"ae");function Ycr(a,s,l){return l_t(s)===a&&(a=""),l||a===""?a:__t(a)}t(Ycr,"oe");function Xcr(a,s){return a=zcr(a,":"),s||a===""?a:Z3e(a)}t(Xcr,"ce");function l_t(a){switch(a){case"ws":case"http":return"80";case"wws":case"https":return"443";case"ftp":return"21";default:return""}}t(l_t,"_");function Z3e(a){if(a==="")return a;if(/^[-+.A-Za-z0-9]*$/.test(a))return a.toLowerCase();throw new TypeError(`Invalid protocol '${a}'.`)}t(Z3e,"y");function Qcr(a){if(a==="")return a;let s=new URL("https://example.com");return s.username=a,s.username}t(Qcr,"le");function Zcr(a){if(a==="")return a;let s=new URL("https://example.com");return s.password=a,s.password}t(Zcr,"fe");function u_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(u_t,"z");function f_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(f_t,"j");function __t(a){if(a===""||/^[0-9]*$/.test(a)&&parseInt(a)<=65535)return a;throw new TypeError(`Invalid port '${a}'.`)}t(__t,"K");function elr(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(elr,"he");function tlr(a){return a===""?a:new URL(`data:${a}`).pathname}t(tlr,"ue");function rlr(a){if(a==="")return a;let s=new URL("https://example.com");return s.search=a,s.search.substring(1,s.search.length)}t(rlr,"de");function nlr(a){if(a==="")return a;let s=new URL("https://example.com");return s.hash=a,s.hash.substring(1,s.hash.length)}t(nlr,"pe");var ilr=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=r_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.#C()?(a=2,s=3):this.#l&&(a=2),this.#i(a,s)}break;case 2:this.#x()?this.#d(3):(this.#E()||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.#E()?this.#i(7,0):this.#y()?this.#i(8,1):this.#D()&&this.#i(9,1);break;case 6:this.#E()?this.#i(7,0):this.#y()?this.#i(8,1):this.#D()&&this.#i(9,1);break;case 7:this.#y()?this.#i(8,1):this.#D()&&this.#i(9,1);break;case 8:this.#D()&&this.#i(9,1);break;case 9:break;case 10:break}}this.#e.hostname!==void 0&&this.#e.port===void 0&&(this.#e.port="")}#i(a,s){switch(this.#a){case 0:break;case 1:this.#e.protocol=this.#T();break;case 2:break;case 3:this.#e.username=this.#T();break;case 4:this.#e.password=this.#T();break;case 5:this.#e.hostname=this.#T();break;case 6:this.#e.port=this.#T();break;case 7:this.#e.pathname=this.#T();break;case 8:this.#e.search=this.#T();break;case 9:this.#e.hash=this.#T();break;case 10:break}this.#a!==0&&a!==10&&([1,2,3,4].includes(this.#a)&&[6,7,8,9].includes(a)&&(this.#e.hostname??=""),[1,2,3,4,5,6].includes(this.#a)&&[8,9].includes(a)&&(this.#e.pathname??=this.#l?"/":""),[1,2,3,4,5,6,7].includes(this.#a)&&a===9&&(this.#e.search??="")),this.#f(a,s)}#f(a,s){this.#a=a,this.#p=this.#t+s,this.#t+=s,this.#s=0}#v(){this.#t=this.#p,this.#s=0}#d(a){this.#v(),this.#a=a}#u(a){return a<0&&(a=this.#n.length-a),a<this.#n.length?this.#n[a]:this.#n[this.#n.length-1]}#m(a,s){let 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,":")}#C(){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,":")}#E(){return this.#m(this.#t,"/")}#y(){if(this.#m(this.#t,"?"))return!0;if(this.#n[this.#t].value!=="?")return!1;let a=this.#u(this.#t-1);return a.type!=="NAME"&&a.type!=="REGEX"&&a.type!=="CLOSE"&&a.type!=="ASTERISK"}#D(){return this.#m(this.#t,"#")}#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,h3),a.encodePart=Z3e;let s=Bcr(this.#T(),void 0,a);this.#l=c_t(s)}},X3e=["protocol","username","password","hostname","port","pathname","search","hash"],m3="*";function t_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(t_t,"ge");function oA(a,s){return s?mG(a):a}t(oA,"b");function dG(a,s,l){let _;if(typeof s.baseURL=="string")try{_=new URL(s.baseURL),s.protocol===void 0&&(a.protocol=oA(_.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=oA(_.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=oA(_.password,l)),s.protocol===void 0&&s.hostname===void 0&&(a.hostname=oA(_.hostname,l)),s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&(a.port=oA(_.port,l)),s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.pathname===void 0&&(a.pathname=oA(_.pathname,l)),s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.pathname===void 0&&s.search===void 0&&(a.search=oA(_.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=oA(_.hash.substring(1,_.hash.length),l))}catch{throw new TypeError(`invalid baseURL '${s.baseURL}'.`)}if(typeof s.protocol=="string"&&(a.protocol=Xcr(s.protocol,l)),typeof s.username=="string"&&(a.username=Gcr(s.username,l)),typeof s.password=="string"&&(a.password=Hcr(s.password,l)),typeof s.hostname=="string"&&(a.hostname=Wcr(s.hostname,l)),typeof s.port=="string"&&(a.port=Ycr(s.port,a.protocol,l)),typeof s.pathname=="string"){if(a.pathname=s.pathname,_&&!Jcr(a.pathname,l)){let m=_.pathname.lastIndexOf("/");m>=0&&(a.pathname=oA(_.pathname.substring(0,m+1),l)+a.pathname)}a.pathname=Kcr(a.pathname,a.protocol,l)}return typeof s.search=="string"&&(a.search=Vcr(s.search,l)),typeof s.hash=="string"&&(a.hash=qcr(s.hash,l)),a}t(dG,"w");function mG(a){return a.replace(/([+*?:{}()\\])/g,"\\$1")}t(mG,"C");function slr(a){return a.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}t(slr,"Oe");function alr(a,s){s.delimiter??="/#?",s.prefixes??="./",s.sensitive??=!1,s.strict??=!1,s.end??=!0,s.start??=!0,s.endsWith="";let l=".*",_=`[^${slr(s.delimiter)}]+?`,m=/[$_\u200C\u200D\p{ID_Continue}]/u,b="";for(let D=0;D<a.length;++D){let A=a[D];if(A.type===3){if(A.modifier===3){b+=mG(A.value);continue}b+=`{${mG(A.value)}}${IM(A.modifier)}`;continue}let M=A.hasCustomName(),U=!!A.suffix.length||!!A.prefix.length&&(A.prefix.length!==1||!s.prefixes.includes(A.prefix)),ie=D>0?a[D-1]:null,se=D<a.length-1?a[D+1]:null;if(!U&&M&&A.type===1&&A.modifier===3&&se&&!se.prefix.length&&!se.suffix.length)if(se.type===3){let Z=se.value.length>0?se.value[0]:"";U=m.test(Z)}else U=!se.hasCustomName();if(!U&&!A.prefix.length&&ie&&ie.type===3){let Z=ie.value[ie.value.length-1];U=s.prefixes.includes(Z)}U&&(b+="{"),b+=mG(A.prefix),M&&(b+=`:${A.name}`),A.type===2?b+=`(${A.value})`:A.type===1?M||(b+=`(${_})`):A.type===0&&(!M&&(!ie||ie.type===3||ie.modifier!==3||U||A.prefix!=="")?b+="*":b+=`(${l})`),A.type===1&&M&&A.suffix.length&&m.test(A.suffix[0])&&(b+="\\"),b+=mG(A.suffix),U&&(b+="}"),A.modifier!==3&&(b+=IM(A.modifier))}return b}t(alr,"ke");var p_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 A=new ilr(a);if(A.parse(),a=A.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 m={ignoreCase:l.ignoreCase===!0},b={pathname:m3,protocol:m3,username:m3,password:m3,hostname:m3,port:m3,search:m3,hash:m3};this.#r=dG(b,a,!0),l_t(this.#r.protocol)===this.#r.port&&(this.#r.port="");let D;for(D of X3e){if(!(D in this.#r))continue;let A={},M=this.#r[D];switch(this.#e[D]=[],D){case"protocol":Object.assign(A,h3),A.encodePart=Z3e;break;case"username":Object.assign(A,h3),A.encodePart=Qcr;break;case"password":Object.assign(A,h3),A.encodePart=Zcr;break;case"hostname":Object.assign(A,Ucr),a_t(M)?A.encodePart=f_t:A.encodePart=u_t;break;case"port":Object.assign(A,h3),A.encodePart=__t;break;case"pathname":c_t(this.#n.protocol)?(Object.assign(A,$cr,m),A.encodePart=elr):(Object.assign(A,h3,m),A.encodePart=tlr);break;case"search":Object.assign(A,h3,m),A.encodePart=rlr;break;case"hash":Object.assign(A,h3,m),A.encodePart=nlr;break}try{this.#s[D]=n_t(M,A),this.#n[D]=i_t(this.#s[D],this.#e[D],A),this.#t[D]=alr(this.#s[D],A),this.#p=this.#p||this.#s[D].some(U=>U.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=dG(l,a,!1):l=dG(l,t_t(a,s),!1)}catch{return!1}let _;for(_ of X3e)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=dG(l,a,!1):l=dG(l,t_t(a,s),!1)}catch{return null}let _={};s?_.inputs=[a,s]:_.inputs=[a];let m;for(m of X3e){let b=this.#n[m].exec(l[m]);if(!b)return null;let D={};for(let[A,M]of this.#e[m].entries())if(typeof M=="string"||typeof M=="number"){let U=b[A+1];D[M]=U}_[m]={input:l[m]??"",groups:D}}return _}static compareComponent(a,s,l){let _=t((A,M)=>{for(let U of["type","modifier","prefix","value","suffix"]){if(A[U]<M[U])return-1;if(A[U]!==M[U])return 1}return 0},"o"),m=new hG(3,"","","","",3),b=new hG(0,"","","","",3),D=t((A,M)=>{let U=0;for(;U<Math.min(A.length,M.length);++U){let ie=_(A[U],M[U]);if(ie)return ie}return A.length===M.length?0:_(A[U]??m,M[U]??m)},"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=p_t);import{AssertionError as olr}from"assert";function cA(a,s){if(a===!1)throw new olr({message:s})}t(cA,"assert");var Ac;(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"})(Ac||(Ac={}));function OM(a){return a.type===Ac.Object}t(OM,"isAstObject");function lA(a){return a.type===Ac.Property}t(lA,"isAstProperty");function d_t(a){return a.type===Ac.Array}t(d_t,"isAstArray");function FM(a){return a.type===Ac.Literal}t(FM,"isAstLiteral");function $O(a){if(a===void 0)throw new Error("Node is undefined");if(!OM(a))throw new Error("Node is not object")}t($O,"assertAstObject");import{findNodeAtLocation as clr,getNodeValue as llr,printParseErrorCode as ulr,visit as flr}from"jsonc-parser";var _lr={DEFAULT:{allowTrailingComma:!1}};function gG(a,s=[],l=_lr.DEFAULT){let _={type:"array",offset:-1,length:-1,line:-1,column:-1,children:[],parent:void 0};function m(M){_.type==="property"&&(_.length=M-_.offset,_=_.parent)}t(m,"ensurePropertyComplete");function b(M){return _.children?.push(M),M}t(b,"onValue"),flr(a,{onObjectBegin:t((M,U,ie)=>{_=b({type:"object",offset:M,length:-1,line:U+1,column:ie+1,parent:_,children:[]})},"onObjectBegin"),onObjectProperty:t((M,U,ie,se,Z)=>{_=b({type:"property",offset:U,length:-1,line:se+1,column:Z+1,parent:_,children:[]}),_.children?.push({type:"string",value:M,offset:U,length:ie,line:se,column:Z,parent:_})},"onObjectProperty"),onObjectEnd:t((M,U)=>{m(M+U),_.length=M+U-_.offset,_=_.parent,m(M+U)},"onObjectEnd"),onArrayBegin:t((M,U,ie,se)=>{_=b({type:"array",offset:M,length:-1,line:ie+1,column:se+1,parent:_,children:[]})},"onArrayBegin"),onArrayEnd:t((M,U)=>{_.length=M+U-_.offset,_=_.parent,m(M+U)},"onArrayEnd"),onLiteralValue:t((M,U,ie,se,Z)=>{b({type:plr(M),offset:U,length:ie,line:se+1,column:Z+1,parent:_,value:M}),m(U+ie)},"onLiteralValue"),onSeparator:t((M,U)=>{_.type==="property"&&(M===":"?_.colonOffset=U:M===","&&m(U))},"onSeparator"),onError:t((M,U,ie,se,Z)=>{s.push({error:M,offset:U,length:ie,line:se+1,column:Z+1})},"onError")},l);let A=_.children[0];return A&&delete A.parent,A}t(gG,"parse");function plr(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(plr,"getNodeType");function eNe(a,s){return clr(a,s)}t(eNe,"findNodeAtLocation");function yG(a){return llr(a)}t(yG,"getNodeValue");function m_t(a){return ulr(a)}t(m_t,"printParseErrorCode");var vG=class{static{t(this,"AstAdapter")}parse(s){let _=gG(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:Ac.Literal,location:{line:s.line,column:s.column},parent:l,value:s.type==="null"?null:s.value}}createObject(s,l){let _={type:Ac.Object,children:[],parent:l,location:{line:s.line,column:s.column}};return s.children?.forEach(m=>{_.children.push(this.parseNode(m,_))}),_}createProperty(s,l){cA(s.children?.length===2,"Invalid property node");let _={type:Ac.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:Ac.Identifier,parent:_},_.value=this.parseNode(s.children[1],_),_}createArray(s,l){let _={type:Ac.Array,location:{line:s.line,column:s.column},parent:l,children:[]};return s.children?.forEach(m=>_.children.push(this.parseNode(m,_))),_}};var $E={createLiteral:t((a,s)=>({type:Ac.Literal,parent:s,value:a}),"createLiteral"),createTemplateString:t((a,s)=>({type:Ac.TemplateString,parent:s,value:a}),"createTemplateString"),createIdentifier:t((a,s)=>({type:Ac.Identifier,value:a,parent:s}),"createIdentifier"),createProperty:t((a,s,l)=>{let _={type:Ac.Property,parent:l,name:null,value:s};return _.name={value:a,type:Ac.Identifier,parent:_},_.value.parent=_,_},"createProperty"),createArrayOfLiterals:t((a,s)=>{let l={type:Ac.Array,parent:s,children:[]};for(let _ of a)l.children.push($E.createLiteral(_,l));return l},"createArrayOfLiterals")};var dlr=/^[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 Ac.Array:return this.generateArray(s,l);case Ac.Object:return this.generateObject(s,l);case Ac.Property:return this.generateProperty(s,l);case Ac.Literal:return this.generateLiteral(s,l);case Ac.FunctionCall:return this.generateFunctionCall(s,l);case Ac.Identifier:return this.generateIdentifier(s,l);case Ac.Raw:return this.generateRaw(s,l);case Ac.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((_,m,b)=>{this.generateSource(s,_),m<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,m=JSON.stringify(_);return s.push(`${m}`)}}}generateIdentifier(s,l){let _=dlr.test(l.value)?l.value:`'${l.value}'`;s.push(_)}};import{parse as mlr}from"@swc/core";import hlr from"fs/promises";var h_t=t(async a=>{let s=new Set;try{let l=await hlr.readFile(a,"utf-8");(await mlr(l,{syntax:"typescript"})).body.forEach(m=>{m.type==="ExportDefaultDeclaration"||m.type==="ExportDefaultExpression"?s.add("default"):m.type==="ExportDeclaration"&&m.declaration.type==="FunctionDeclaration"?s.add(m.declaration.identifier.value):m.type==="ExportDeclaration"&&m.declaration.type==="VariableDeclaration"&&m.declaration.declarations[0].id.type==="Identifier"&&s.add(m.declaration.declarations[0].id.value)})}catch{return null}return s},"getJSFileExports");var g_t={$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 tNe={$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 y_t={$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 rNe={$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 nNe={$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 Nmt=S_(emt(),1),Imt=S_(Amt(),1);var Jue=class a{static{t(this,"JsonValidator")}static#r=new a;static get instance(){return a.#r}ajv;constructor(){this.ajv=new Imt.Ajv2020({allErrors:!0,allowUnionTypes:!0}),this.ajv.addKeyword("faker"),(0,Nmt.default)(this.ajv,{mode:"fast"})}addSchema(s,l){this.ajv.addSchema(s,l)}compile(s){let l=this.ajv.compile(s);return t(m=>({isValid:l(m),errors:this.toSimpleErrors(l.errors,m),warnings:[]}),"validator")}toSimpleErrors(s,l){let _=[];return s?.forEach(m=>{m.keyword==="enum"&&m.params.allowedValues&&Array.isArray(m.params.allowedValues)&&(m.message+=`; ${m.params.allowedValues.join(", ")}`),m.instancePath&&(m.instancePath=m.instancePath.replaceAll(/(\/)?(~1)(\/)?/gm,"/"));let b={details:{}},D=m.instancePath.split("/");if(D.length>2){let M=D[1],U=D[2]?parseInt(D[2]):0,ie=D[3],se=isNaN(U)?void 0:l[M][U][ie];b={details:{property:M,index:U,field:ie,fieldValue:se}}}if(m.keyword==="required"&&m.params.missingProperty&&m.instancePath&&(m.message=`A 'path' is missing required property '${m.params.missingProperty}'`),m.keyword==="additionalProperties"&&m.params.additionalProperty&&m.instancePath&&(m.message=`A 'path' should NOT include property '${m.params.additionalProperty}'`),m.keyword==="type"&&m.params.type&&m.instancePath){let M=m.instancePath.split("/"),U=M[M.length-1];m.message=`Value of property '${U}' must be '${m.params.type}'`}let A=Object.assign(m,b);_.push(A)}),_}};var D3=Jue.instance;D3.addSchema(nNe,"route-configuration.schema.json");D3.addSchema(y_t,"policy-configuration.schema.json");D3.addSchema(tNe,"policies.schema.json");D3.addSchema(rNe,"open-api-route-configuration.schema.json");D3.addSchema(g_t,"fragments.schema.json");var Z5r=D3.compile(nNe),Omt=D3.compile(rNe),y8e=D3.compile(tNe);var zue=class{static{t(this,"PoliciesConfigurationValidator")}results;validate(s){return this.results=y8e(s),this.results}};var que=class{static{t(this,"OpenAPILocalizedValidator")}results;validate(s){return this.results=Omt(s),this.results}};import Thr from"path";var v8e=/\$import\((.*)\)/,Vue=/\$env\((.*?)\)/g;var dA=class extends Error{static{t(this,"CodeGenError")}location;constructor(s,l,_,m){super(s),this.location={file:l,namespace:"",line:_?_.line:0,column:_?_.column:0,length:0,lineText:m??"",suggestion:""}}},Shr=t(a=>{let s=[],l=a;for(;l.parent;)s.push(l),l=l.parent;return s.reverse()},"invertTree"),k3=t((a,s)=>{if(!a)return!1;let l=Shr(a);return s.split("/").every((b,D)=>{let A=l[D];return A?b==="*"||lA(A)&&A.name.value===b?!0:b==="{}"?A.type===Ac.Object:b==="[]"?A.type===Ac.Array:!1:!1})},"testPosition");var Wue=class{static{t(this,"AstTransformer")}errors=[];transform(s){return this.visitor(s),s}visitor(s){this.visit(s),OM(s)?s.children.forEach(l=>{this.visitor(l)}):d_t(s)?s.children.forEach(l=>{this.visitor(l)}):lA(s)&&this.visitor(s.value)}},Fmt=t((a,s,l)=>_=>{if(!lA(_)||!FM(_.value)||typeof _.value.value!="string")return;if(!a.some(b=>k3(_,b))){Vue.test(_.value.value)&&s.push(new dA("An $env() statement is not expected at this location.",l,_.location,_.value.value));return}let m=new RegExp(Vue).exec(_.value.value);if(m?.length===2&&m[0]===_.value.value){let b={type:Ac.Raw,parent:null,value:`environment["${m[1]}"]`};_.value=b}else{let b=_.value.value.replaceAll(new RegExp(Vue),(D,A)=>`\${environment["${A}"] ? environment["${A}"] : ""}`);b!==_.value.value&&(_.value=$E.createTemplateString(b,_))}},"getEnvStatementTransformer");var ZG="config/routes.json",xhr=["handler/{}/options/*","policies/[]/{}/handler/{}/options/*","corsPolicies/[]/{}/*"],Ehr=["handler/{}/module","handler/{}/options/{}/policies/{}/inbound/[]/{}/module","handler/{}/options/{}/policies/{}/outbound/[]/{}/module","policies/[]/{}/handler/{}/module","policies/[]/{}/handler/{}/options/{}/identifier/{}/module","policies/[]/{}/handler/{}/options/{}/validator"],Lmt=["handler/{}/options/*","policies/[]/{}/handler/{}/options/*"],Chr="handler/{}/options/{}/rewritePattern",Dhr="handler/{}/options/{}/baseUrl",Hue=class extends Wue{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(!(!lA(s)||!FM(s.value)||typeof s.value.value!="string")&&k3(s,Chr)){if(!s.parent||!OM(s.parent)){this.errors.push(new dA("Invalid node, expected object",ZG,s.parent?s.parent.location:s.location,void 0));return}let l=s.value.value,_={type:Ac.Raw,parent:null,value:Rmt(l)},m=$E.createProperty("__rewriteFunction",_,s);s.parent.children.push(m)}}rewriteForwardFunction(s){if(!(!lA(s)||!FM(s.value)||typeof s.value.value!="string")&&k3(s,Dhr)){if(!s.parent||!OM(s.parent)){this.errors.push(new dA("Invalid node, expected object",ZG,s.parent?s.parent.location:s.location,void 0));return}let l=s.value.value,_={type:Ac.Raw,parent:null,value:Rmt(l)},m=$E.createProperty("__rewriteFunction",_,s);s.parent.children.push(m)}}replaceImportStatements(s){if(!lA(s)||!FM(s.value))return;let l=s.value.value;if(typeof l!="string")return;if(!Ehr.some(A=>k3(s,A))&&!Lmt.some(A=>k3(s,A))){if(v8e.test(l)){if(s.name.value==="$ref")return;this.errors.push(new dA("An $import() statement is not expected at this location.",ZG,s.location,l))}return}let _=v8e.exec(l);if(Lmt.some(A=>k3(s,A))&&!_)return;if(!_){this.errors.push(new dA("Invalid $import() statement",ZG,s.location,l));return}let m=_[1];m.startsWith(".")&&(m=Thr.join("..",m));let b=this.getImportName(m),D={type:Ac.Identifier,parent:s.parent,value:b};s.value=D}replaceEnvStatements=Fmt(xhr,this.errors,ZG)};function Rmt(a){return`(request, context) => {
561
561
  const { params, url, query, method, headers } = request;
562
562
  const { host, hostname, origin, pathname, port, search } = new URL(url);
563
563
  const e = encodeURIComponent;
@@ -589,16 +589,16 @@ globstar while`,s,Z,l,Re,Pe),this.matchOne(s.slice(Z),l.slice(Re),_))return this
589
589
  `?(A=0,M++):A++;this.column=A,this.line=M;return}}let{length:_}=s,{lineEnd:m}=this;_>0&&(this.lineEndSize>0&&(m.length===1?s[_-1]===m:s.endsWith(m))?(this.line+=this.lineEndSize,this.column=0):this.column+=_)}toString(){return this.output}};function Ymt(a,s){let l=new x8e(s);return l.generator[a.type](a,l),l.output}t(Ymt,"generate");import Yhr from"fs/promises";import Xhr from"path";async function E8e({oasFiles:a,sourceDirectory:s,logger:l}){let _=await Qhr({oasFiles:a,sourceDirectory:s,logger:l});return Ymt(_)}t(E8e,"generateRawRouteSource");async function Qhr({oasFiles:a,sourceDirectory:s,logger:l}){let _=new _3(s,l),m=[];for(let D of a){let A=Xhr.basename(D,".oas.json"),M=await _.resolve(D),U=[],ie=new Map,se=await Yhr.readFile(D,"utf-8"),Z=JSON.parse(se);for(let Re in Z.paths){let Pe=Z.paths[Re];for(let ke in Pe){if(ke.startsWith("x-"))continue;let{description:wt,...At}=Pe[ke],yr=ZH(A,Re,ke),zr=Zue(D,A,At,M,U,ie);m.unshift(Qmt(yr,zr))}}m.unshift(...Zhr(A,M,U,ie).reverse())}return{type:"Program",body:m,sourceType:"module"}}t(Qhr,"generateAst");function Zue(a,s,l,_,m,b){let D=[];for(let A in l){let M=l[A];if(A==="$ref")return LH(a,s,n3(a,M),_,m,b),{type:"Identifier",name:Zmt(s,b.get(n3(a,M)))};let U;switch(typeof M){case"string":case"number":case"boolean":U={type:"Literal",value:M};break;default:Array.isArray(M)?U=Xmt(M,a,s,_,m,b):typeof M=="object"&&M!==null&&(U={type:"ObjectExpression",properties:Zue(a,s,M,_,m,b).properties||[]});break}if(U){let ie=/^[a-zA-Z_$][0-9a-zA-Z_$]*$/.test(A),se=ie?{type:"Identifier",name:A}:{type:"Literal",value:A};D.push({type:"Property",key:se,value:U,kind:"init",method:!1,shorthand:!1,computed:!ie})}}return{type:"ObjectExpression",properties:D}}t(Zue,"processNode");function Xmt(a,s,l,_,m,b){return{type:"ArrayExpression",elements:a.map(D=>{if(Array.isArray(D))return Xmt(D,s,l,_,m,b);if(typeof D=="object"&&D!==null){let A=Zue(s,l,D,_,m,b);return A.type==="Identifier"?A:{type:"ObjectExpression",properties:A.properties||[]}}else return{type:"Literal",value:D}})}}t(Xmt,"processArray");function Qmt(a,s){return{type:"ExportNamedDeclaration",declaration:{type:"VariableDeclaration",declarations:[{type:"VariableDeclarator",id:{type:"Identifier",name:a},init:s}],kind:"var"},specifiers:[],source:null}}t(Qmt,"createExportedConstAssignment");function Zhr(a,s,l,_){let m=[];for(let b=0;b<l.length;b++){let D=Zmt(a,b),A=s.get(l[b]),M=Zue(L6e(l[b]),a,A,s,l,_);m.push(Qmt(D,M))}return m}t(Zhr,"generateRefs");function Zmt(a,s){return`${rA(a)}__ref__${s}`}t(Zmt,"getRefIdentifierName");import eht from"path";var tht=t(a=>{let s=null;if(a.value.type==="Object"&&a.value.members.length>0)for(let l of a.value.members){let _=tht(l);if(_!==null&&(s=_),l.name.value==="enum"&&l.value.type==="Array"&&l.value.elements.length===0){let m=l.value,b=m.loc.start.line,D=m.loc.start.column,A=m.loc.end.column;s={line:b,column:D,length:A-D,lineText:""}}}return s},"findEmptyEnums"),egr=t(a=>{if(a.startsWith("schema with key or id")&&a.endsWith("already exists"))return"Update your schema's '$id' to be unique across your project.";if(a.includes("All JSON schemas must use version 2020-12"))return"All JSON schemas must use version 2020-12. See release notes for changes: https://json-schema.org/draft/2020-12/release-notes.html";if(a==='"nullable" cannot be used without "type"')return'Property "nullable" can only be used when property "type" value is "object".';if(a==='NOT SUPPORTED: keyword "id", use "$id" for schema ID')return'Replace keyword "id" with "$id" when defining a schema Id.';if(a.startsWith("can't resolve reference http"))return"Cannot resolve remote references, try adding them directly to the schema file or as a schema file in the project.";if(a.startsWith("can't resolve reference"))return"Make sure all references are defined in the schema.";if(a.includes("oneOf must NOT have fewer than 1 items"))return'Property "oneOf" must have at least 1 item configured.';if(a.includes("enum must have non-empty array"))return'Property "enum" must be configured with at least one value.';if(a.includes("Unexpected")&&a.includes("in JSON at position"))return"Update your schema to only use valid properties."},"getSuggestions"),C8e=t(async(a,s,l)=>{if(!a)return null;let _={file:eht.join(I6e,a),suggestion:egr(l)},m=eht.join(s,I6e),b=wl.safePath(s).resolve(m,a),D=await Hce(b);if(l.includes("enum must have non-empty array")){if(D){let A=await FH(D);if(A&&A.body.members!==null)for(let M of A.body.members){let U=tht(M);U&&U!==null&&(_=Object.assign(_??{},U))}if(_){let M=_.line?_.line:0;_.lineText=OH(D,M)}}}else if(l.includes("Unexpected")&&l.includes("in JSON at position")&&D){let A=await FH(D);A&&"lineText"in A&&(_=Object.assign(_??{},A))}return _},"getLocation");import*as Wyt from"esbuild";import{performance as efe,PerformanceObserver as tgr}from"perf_hooks";var D8e=[];async function rgr(a,s){let l=efe.timerify(s),_=new tgr(m=>{let b=m.getEntries()[0];D8e.push({name:a,duration:b.duration}),_.disconnect()});return _.observe({entryTypes:["function"]}),l()}t(rgr,"timeFn");var ngr={mark:t(a=>{efe.mark(a)},"mark"),measure:t((a,s,l)=>{efe.measure(a,s,l)},"measure"),timeFn:rgr,report:t(()=>{D8e.length>0&&console.table(D8e)},"report"),getDuration:t(a=>{let s=efe.getEntriesByName(a);return s.length===0?0:s[0].duration},"getDuration")},zf=ngr;var igr=!1;function rj(a,s){return{open:`\x1B[${a.join(";")}m`,close:`\x1B[${s}m`,regexp:new RegExp(`\\x1b\\[${s}m`,"g")}}t(rj,"code");function nj(a,s){return igr?`${s.open}${a.replace(s.regexp,s.open)}${s.close}`:a}t(nj,"run");function sgr(a){return nj(a,rj([31],39))}t(sgr,"red");function agr(a){return nj(a,rj([32],39))}t(agr,"green");function ogr(a){return nj(a,rj([33],39))}t(ogr,"yellow");function cgr(a){return nj(a,rj([34],39))}t(cgr,"blue");function lgr(a){return nj(a,rj([35],39))}t(lgr,"magenta");function ugr(a){return nj(a,rj([36],39))}t(ugr,"cyan");var hLr=new RegExp(["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"].join("|"),"g");var rht=[sgr,agr,ogr,cgr,lgr,ugr];function fgr(a){let s=0,l=a.length,_=0;if(l>0)for(;_<l;)s=(s<<5)-s+a.charCodeAt(_++)|0;return s}t(fgr,"hashCode");function nht(a){let s=Math.abs(fgr(a));return rht[s%rht.length]}t(nht,"generateColor");import{inspect as _gr}from"util";function iht(a,s,...l){let _=0,m=l.length,b=String(s).replace(/%[sdjoO%]/g,D=>{if(D==="%%")return"%";if(_>=m)return D;switch(D){case"%s":return String(l[_++]);case"%d":return Number(l[_++]).toString();case"%o":return a(l[_++]).split(`
590
590
  `).map(A=>A.trim()).join(" ");case"%O":return a(l[_++]);case"%j":try{return JSON.stringify(l[_++])}catch{return"[Circular]"}default:return D}});for(let D of l.splice(_))D===null||!(typeof D=="object"&&D!==null)?b+=" "+D:b+=" "+a(D);return b}t(iht,"format");var sht=t((a,...s)=>iht(_gr,a,s),"format");var k8e=class{static{t(this,"Debugger")}manager;ns;color;last;enabled;constructor(s,l){this.manager=s,this.ns=l,this.color=nht(l),this.last=0,this.enabled=s.enabled.some(_=>_.test(l))}log(...s){if(!this.enabled)return;let l,_=s[0];typeof _=="function"?l=_():l=String(_);let m=Date.now()-(this.last||Date.now());l=sht(l,...s);let b=`${this.color(this.ns)} ${l} ${this.color(`+${m}ms`)}`;console.log(b),this.last=Date.now()}},w8e=class{static{t(this,"DebugManager")}debuggers;enabled;constructor(s){this.debuggers=new Map,this.enabled=s??[]}};function pgr(a){return!a||a.length===0?[]:(a=a.replace(/\s/g,"").replace(/\*/g,".+"),a.split(",").map(s=>new RegExp(`^${s}$`)))}t(pgr,"extract");var tfe;function aht(a){tfe||(tfe=new w8e(pgr(process.env.DEBUG)));let s=new k8e(tfe,a);return tfe.debuggers.set(a,s),Object.assign(s.log.bind(s),{self:s})}t(aht,"debug");import QFe,{dirname as zyt}from"path";import{fileURLToPath as qyt}from"url";var P8e=class{static{t(this,"Environment")}get DEV_SERVER_PORT(){return process.env.DEV_SERVER_PORT?parseInt(process.env.DEV_SERVER_PORT):3e3}get DEBUG_BUILD_MODE(){return!!process.env.DEBUG_BUILD_MODE}get USE_MONOREPO_PACKAGES(){return process.env.USE_MONOREPO_PACKAGES==="true"}get EXPERIMENTAL_CODEGEN(){return!!process.env.EXPERIMENTAL_CODEGEN}get NODE_ENV(){return process.env.NODE_ENV}isProduction(){return this.NODE_ENV==="production"}isLocalDevelopment(){return process.env.ZUPLO_IS_LOCAL_DEVELOPMENT==="true"}},dgr=new P8e,Ym=dgr;var A8e="no-remote-module";function oht({logger:a}){return{name:A8e,async setup(s){s.onResolve({filter:/^https?:\/\//},l=>(a.error(l,"User attempted to load a remote module"),{errors:[{text:`Remote modules are not supported. Attempted to load module ${l.path}`,detail:"InvalidRemoteModule",pluginName:A8e,location:{line:0,column:0,file:""}}],pluginName:A8e}))}}}t(oht,"blockRemoteModulePlugin");import ggr from"fs/promises";import rfe from"path";import{writeFile as mgr}from"fs/promises";async function ak(a,s){await wl.mkdirForFilePathIfNotExits(a);let l=await import("prettier"),_=s;try{_=await l.format(s,{parser:"babel"})}catch{}await mgr(a,_,"utf-8")}t(ak,"writeDebugSourceFile");import cht from"path";var hgr=["zudoku.config.ts","zudoku.config.tsx","zudoku.config.js","zudoku.config.jsx","zudoku.config.mjs"];async function N8e(a){if(await wl.fileExists(`${a}/config/dev-portal.json`))return"dev-portal";for(let s of hgr)if(await wl.fileExists(`${a}/docs/${s}`))return"zudoku"}t(N8e,"getDevPortalType");function ij(a,s){let l=cht.relative(process.cwd(),cht.join(a,bO));return Object.keys(s?.outputs??{}).map(m=>`.${m.replace(l,"")}`)}t(ij,"getBuildModules");var lht="/docs",ygr="/__zuplo/dev-portal";function vgr(a){let s=a.trim().toLowerCase();return s.endsWith("/")&&(s=s.slice(0,-1)),s}t(vgr,"normalizePathname");function bgr(a){let s={sitePathname:a?.sitePathname===ygr?lht:a?.sitePathname?vgr(a.sitePathname):lht,enabled:a?a.enabled??!0:!1,version:a?.version??"legacy"};return`const devPortal = ${JSON.stringify(s)};
591
591
  export default devPortal;`}t(bgr,"generateSource");function uht(a){return{name:"dev-portal-config",setup(s){s.onResolve({filter:/dev-portal.json$/},l=>({namespace:"dev-portal-json",path:rfe.isAbsolute(l.path)?l.path:rfe.join(l.resolveDir,l.path),pluginName:"dev-portal"})),s.onLoad({filter:/.*/,namespace:"dev-portal-json"},async l=>zf.timeFn("Generating dev-portal.json data",async()=>{let _,m,b=[],D=await N8e(a.sourceDirectory);if(D==="zudoku")_={version:"zudoku",enabled:!0,sitePathname:"/docs"};else if(D==="dev-portal"){m=await ggr.readFile(l.path,"utf-8");try{_=JSON.parse(m)}catch{b.push({id:"dev-portal-build-error",text:"Could not parse dev-portal.json. Ensure that the file is valid JSON.",location:{file:"dev-portal.json",namespace:"dev-portal-json",line:1,column:0,length:0,lineText:"",suggestion:""},detail:"DevPortalValidationError",pluginName:"dev-portal",notes:[{text:"Could not parse dev-portal.json. Ensure that the file is valid JSON.",location:null}]})}}if(b&&b.length>0)throw b;let A;try{if(A=bgr(_),Ym.DEBUG_BUILD_MODE&&A){let M=rfe.join(a.sourceDirectory,".zuplo","dev-portal.js");await ak(M,A)}if(b&&b.length>0)throw b}catch(M){M.length>0?M.forEach(U=>{let ie={id:"dev-portal-build-error",text:U.message,location:{file:"dev-portal.json",namespace:"dev-portal-json",line:1,column:0,length:0,lineText:"issue",suggestion:""},detail:"DevPortalValidationError",pluginName:"dev-portal",notes:[{text:U.message,location:null}]};b.push(ie)}):b.push({id:"dev-portal-build-error",text:M.message,location:{file:"dev-portal.json",namespace:"dev-portal-json",line:1,column:0,length:0,lineText:"issue",suggestion:""},detail:"DevPortalValidationError",pluginName:"dev-portal",notes:[{text:M.message,location:null}]})}return{contents:A,errors:b,pluginName:"dev-portal",loader:"js",resolveDir:rfe.dirname(l.path),watchFiles:[l.path]}}))}}}t(uht,"devPortalConfigPlugin");import fht from"path";var _ht="legacy-environment",pht="legacy-environment",Sgr=`import { environment } from "@zuplo/runtime";
592
- export default environment;`;function dht(a){return{name:"environment",setup(s){s.onResolve({filter:/@app\/environment$/},()=>({namespace:pht,pluginName:_ht,path:fht.join(a.sourceDirectory,Z4,"environment.js")})),s.onLoad({filter:/.*/,namespace:pht},async l=>({contents:Sgr,loader:"ts",resolveDir:fht.dirname(l.path),pluginName:_ht}))}}}t(dht,"environmentPlugin");var Cyt=S_(bFe(),1),Dyt=S_(H0t(),1),kyt=S_(VFe(),1),wyt=S_(WFe(),1);import bSr from"fs/promises";import z2 from"path";var pk="schemas",jfe="json-schema";function Pyt(a){return{name:pk,async setup(s){let l=new kyt.Ajv2020({code:{source:!0},allErrors:!0,strict:!1,verbose:!0,meta:!0});(0,Dyt.default)(l,{mode:"fast"}),l.opts.code.formats=Cyt._`require("ajv-formats/dist/formats").fastFormats`;let _=z2.join(a.sourceDirectory,lH),m,b=[],D=[];if(await wl.dirExists(_)&&(l.addKeyword("faker"),m=await wl.listFolderContents(_,lH),await Promise.all(m.map(async A=>{try{let M=wl.safePath(a.sourceDirectory).resolve(_,A);if(!M.startsWith(_))throw new Error("All schemas must be in the schemas directory");let U=await bSr.readFile(M,"utf-8");if(U===""||U===void 0)throw new Error(`Schema 'schemas/${A}' is empty and will be ignored.`);let ie=JSON.parse(U);if(ie.$schema&&ie.$schema!=="https://json-schema.org/draft/2020-12/schema")throw new Error(`Error in ${A}: All JSON schemas must use version 2020-12. See release notes for changes: https://json-schema.org/draft/2020-12/release-notes.html`);if(l.$dataMetaSchema,l.addSchema(ie,A),l.errors?.length){let se=l.errors[0];b.push({id:"json-schema-validation-error",pluginName:pk,text:`Error: ${se.message}`,location:{file:z2.join(lH,A)},detail:{params:se.params,propertyName:se.propertyName,schemaPath:se.schemaPath,data:se.data}})}}catch(M){if(M.message.endsWith("is empty and will be ignored.")){D.push({id:"empty-json-schema-file",pluginName:pk,text:`Schema 'schemas/${A}' is empty and will be ignored.`,location:{file:`schemas/${A}`,suggestion:"Add schema details or remove the file from the project."},detail:"EmptyJSONSchemaFile",notes:[{text:`Schema 'schemas/${A}' is empty and will be ignored.`,location:{file:`schemas/${A}`,suggestion:"Add schema details or remove the file from the project."}}]});return}let U=await C8e(A,a.sourceDirectory,M.message);b.push({id:"json-schema-add-error",pluginName:pk,text:`Error: ${M.message}`,location:U,detail:"InvalidAddSchemaError",notes:[{text:M.message}]})}})),await Promise.all(m.map(async A=>{try{let M=l.getSchema(A);M&&l.compile(M.schema).errors?.forEach(ie=>{b.push({text:`Failed to compile ${A}: ${ie.message}`})})}catch(M){let U=await C8e(A,a.sourceDirectory,M.message);b.push({id:"json-schema-compile-error",pluginName:pk,text:`The schema file '${A}' is not valid. Error: ${M.message}`,location:U,detail:"InvalidSchemaError",notes:[{text:M.message}]})}})),Ym.DEBUG_BUILD_MODE)){let A=z2.resolve(a.outputDirectory,lH);await wl.mkdirIfNotExists(A)}s.onStart(async()=>{if(m)return{errors:b,warnings:D}}),s.onResolve({filter:/schemas\/.*\.json$/},async A=>{let M=z2.isAbsolute(A.path)?A.path:z2.join(A.resolveDir,A.path);if(A.importer&&A.importer!==z2.join(a.sourceDirectory,"config/routes.json"))return{path:M};if(!await wl.fileExists(M)){let U="policies.json";return{errors:[{id:"json-schema-build-error",text:`Unable to resolve reference to '${A.path}' from ${U}`,location:{file:z2.join(A.resolveDir,U),namespace:jfe,line:1,column:0,length:0,lineText:`Invalid JSON schema reference in ${U}`,suggestion:""},detail:"RouteReferenceError",pluginName:pk,notes:[{text:`Unable to resolve reference to '${A.path}' from ${U}`,location:null}]}],namespace:jfe,path:M,pluginName:pk}}return{path:M,namespace:jfe,pluginName:pk}}),s.onLoad({filter:/.*/,namespace:jfe},async A=>zf.timeFn(`Generating json schema data: ${z2.basename(A.path)}`,async()=>{let M=[],U;try{let ie=z2.relative(_,A.path),se=l.getSchema(ie);if(!se)throw new Error(`Could not load schema at ${A.path}`);U=se.source?.validateCode;let Z=l.compile(se.schema);U=(0,wyt.default)(l,Z)}catch(ie){M.push({pluginName:pk,text:`Cannot parse project's schemas/${z2.basename(A.path)} file. Error: ${ie.message}`,location:null,notes:[{text:ie.message,location:null}],detail:ie})}if(Ym.DEBUG_BUILD_MODE&&U){let ie=z2.relative(_,A.path),se=z2.join(a.sourceDirectory,".zuplo",`${ie}.js`);await ak(se,U)}return{contents:U,errors:M,pluginName:pk,resolveDir:z2.dirname(A.path),watchFiles:[A.path]}}))}}}t(Pyt,"jsonSchemaPlugin");import{relative as SSr}from"path";var Ayt=["node:assert","node:async_hooks","node:buffer","node:crypto","node:diagnostics_channel","node:events","node:path","node:process","node:stream","node:string_decoder","node:util"],TSr="nodejs-compat-plugin";function Nyt({sourceDirectory:a}){return{name:TSr,setup(s){let l=new Set;s.onStart(()=>{l.clear()}),s.onResolve({filter:/node:.*/},async({path:_,kind:m,resolveDir:b,...D})=>{let A=`${_}:${m}:${b}:${D.importer}`;if(l.has(A))return;l.add(A);let M=await s.resolve(_,{kind:m,resolveDir:b,importer:D.importer});return M.errors.length>0?Ayt.includes(_)||_.includes("/")&&Ayt.includes(_.split("/")[0])?{external:!0}:{external:!0,warnings:M.errors.map(ie=>({...ie,location:{file:SSr(a,D.importer),line:0,column:0,namespace:"",length:0,lineText:"",suggestion:"Remove the imported node module"},detail:`The package "${_}" wasn't found on the file system but is built into node. If this code is executed it will fail.`}))}:M})}}}t(Nyt,"nodejsCompatPlugin");import Iyt from"fs/promises";import eC from"path";var Dj="open-api-routes-plugin",Bfe="open-api-routes-json";function Oyt(a){return{name:"open-api-routes-plugin",setup(s){s.onResolve({filter:/routes.json$/},l=>({watchFiles:[...HFe(eC.join(a.sourceDirectory,Zv),[".oas.json"],!0),eC.join(a.sourceDirectory,Zv,hce)],namespace:Bfe,path:eC.isAbsolute(l.path)?l.path:eC.join(l.resolveDir,l.path),pluginName:Dj})),s.onResolve({filter:/^\.\.\/modules\/.*/,namespace:Bfe},async l=>{let _=eC.join(l.resolveDir,`${l.path}.ts`);if(!await wl.fileExists(_)){let m=`$import(.${l.path.replace(/^../,"")})`,b=eC.resolve(a.sourceDirectory,"config"),D=await CO(b),A=await xot(D,m,"Update your route configuration to use code from the 'modules' folder");return{errors:[{id:"route-build-error",text:`Invalid handler reference in routes.json. Unable to resolve reference to '${m}' from routes.json`,location:A,detail:"RouteReferenceError",pluginName:Dj}],namespace:Bfe,path:l.path,pluginName:Dj}}}),s.onLoad({filter:/.*/,namespace:Bfe},async l=>zf.timeFn("Generating route.json data",async()=>{let _=eC.resolve(a.sourceDirectory,"config"),m=await CO(_),b=await Promise.all(m.map(async U=>({content:await Iyt.readFile(U,"utf-8"),fileName:U}))),D=eC.resolve(_,"policies.json");if(!await wl.fileExists(D))return{errors:[{text:"The project must include a policies file ('/config/policies.json')",detail:"OASPoliciesFileMissing",pluginName:Dj,location:{line:0,column:0,file:"/config/policies.json"}}],pluginName:Dj};let A={content:await Iyt.readFile(D,"utf-8"),fileName:D},M;try{M=await S8e({sourceDirectory:a.sourceDirectory,oasContent:b,policiesContent:A})}catch(U){throw new Error("Error compiling routes: "+U.message)}if(Ym.DEBUG_BUILD_MODE&&M.content){let U=eC.join(a.sourceDirectory,".zuplo"),ie=eC.resolve(U,"routes.js");await ak(ie,M.content)}return{contents:M.content,errors:M.errors,pluginName:Dj,resolveDir:eC.dirname(l.path),watchFiles:[l.path]}}))}}}t(Oyt,"openApiRoutesPlugin");import Ufe from"path";var IK="raw-route-plugin",Fyt="raw-route";function Lyt(a){return{name:"raw-route-plugin",setup(s){s.onResolve({filter:/raw.json$/},l=>({namespace:Fyt,path:l.path,pluginName:IK})),s.onLoad({filter:/.*/,namespace:Fyt},async l=>{let _=Ufe.resolve(a.sourceDirectory,Zv);if(!await wl.dirExists(_))return{loader:"js",resolveDir:Ufe.dirname(l.path),pluginName:IK};let m=await CO(_);try{let b=await E8e({oasFiles:m,sourceDirectory:a.sourceDirectory,logger:a.logger});if(Ym.DEBUG_BUILD_MODE&&b){let D=Ufe.join(a.sourceDirectory,".zuplo","raw-routes.js");await ak(D,b)}return{contents:b,loader:"js",resolveDir:Ufe.dirname(l.path),pluginName:IK}}catch(b){if(b instanceof M1)return{contents:"",loader:"ts",errors:[{id:"route-build-error",text:b.issue.text,location:b.issue.location,detail:b.issue.detail,pluginName:IK}],pluginName:IK};throw b}})}}}t(Lyt,"rawRoutePlugin");import xSr from"fs/promises";import GFe from"path";var $fe="runtime-config",Ryt="runtime-config-plugin";function Myt(){return{name:$fe,setup(a){a.onResolve({filter:/^\.\.\/modules\/zuplo.runtime.ts$/},s=>({namespace:Ryt,path:GFe.isAbsolute(s.path)?s.path:GFe.join(s.resolveDir,s.path),pluginName:$fe})),a.onLoad({filter:/.*/,namespace:Ryt},async s=>zf.timeFn("Generating zuplo.runtime.ts data",async()=>{let l="export const runtimeInit = undefined;",_=[];return await wl.fileExists(s.path)?(l=await xSr.readFile(s.path,"utf-8"),{contents:l,loader:"ts",resolveDir:GFe.dirname(s.path),errors:_,pluginName:$fe,watchFiles:[s.path]}):{contents:l,loader:"ts",errors:_,pluginName:$fe}}))}}}t(Myt,"runtimeConfigPlugin");var Byt=S_(VFe(),1),Uyt=S_(WFe(),1);import XFe from"fs/promises";import uF from"path";var KFe="schema-validation-plugin",jyt="schema-validation",ESr="module.exports = {}";function $yt(a){return{name:"schema-validation-plugin",setup(s){s.onResolve({filter:/ajv-schema.json$/},l=>({namespace:jyt,path:l.path,pluginName:KFe})),s.onLoad({filter:/.*/,namespace:jyt},async l=>{let _=uF.resolve(a.sourceDirectory,Zv,"policies.json");if(!await wl.fileExists(_))return{contents:ESr,loader:"js",resolveDir:uF.dirname(l.path),pluginName:KFe};let m=await DSr(a.sourceDirectory),b=uF.resolve(a.sourceDirectory,Zv),D=await CO(b),A=await ASr(D,m),M=await CSr({oasFiles:D,routesWithSchemaValidation:A,sourceDirectory:a.sourceDirectory,logger:a.logger});if(Ym.DEBUG_BUILD_MODE&&M){let U=uF.join(a.sourceDirectory,".zuplo","schema-validation.js");await ak(U,M)}return{contents:M,loader:"js",resolveDir:uF.dirname(l.path),pluginName:KFe}})}}}t($yt,"schemaValidationPlugin");async function CSr({oasFiles:a,routesWithSchemaValidation:s,sourceDirectory:l,logger:_}){let m="",b=new _3(l,_);if(s.length===0)return m;let D=new Byt.Ajv2020({code:{source:!0},allErrors:!0,strict:!1,verbose:!0,meta:!0});for(let A of a){let M=await XFe.readFile(A,"utf-8"),U=uF.basename(A,".oas.json"),ie=s.filter(ke=>ke.fileName===U),se=await b.resolve(A),Z=JSON.parse(M),Re=[],Pe=new Map;ie.forEach(ke=>{let wt=Z.paths[ke.path][ke.method];if(wt.requestBody){let At;if(wt.requestBody.$ref){let yr=wt.requestBody.$ref;At=se.get(yr)?.content}else wt.requestBody.content&&(At=wt.requestBody.content);if(At)for(let yr in At){let zr=At[yr].schema,en=i3e(ke.path,ke.method,yr);zr.$id=en,D.addSchema(zr),YFe(zr,A,U,D,se,Re,Pe)}}if(wt.parameters)for(let At of wt.parameters){let yr=At.$ref?se.get(At.$ref):At,zr=yr.schema.$ref?se.get(yr.schema.$ref):yr.schema,en=n3e(ke.path,ke.method,yr.in,yr.name);zr.$id=en,D.addSchema(zr),YFe(yr,A,U,D,se,Re,Pe)}});for(let ke of Re){let wt=se.get(ke),At=eG(U,ke);D.addSchema(wt,At)}}return m=(0,Uyt.default)(D),m}t(CSr,"schemaValidationSource");function YFe(a,s,l,_,m,b,D){for(let A in a){let M=a[A];if(A==="$ref"){let U=eG(l,n3(s,M));a[A]=U,LH(s,l,n3(s,M),m,b,D,(ie,se)=>eG(ie,n3(s,se)))}else typeof M=="object"&&YFe(M,s,l,_,m,b,D)}}t(YFe,"addRefsToSchema");async function DSr(a){let s=new Set(["RequestValidationInboundPolicy"]),l=await XFe.readFile(`${a}/config/policies.json`,"utf-8"),_=JSON.parse(l);return kSr(_,s)}t(DSr,"getPolicyNamesUsingSchemaValidationPolicies");function kSr(a,s){let l=new Set;a.policies?.forEach(m=>{m.handler?.export&&s.has(m.handler.export)&&m.handler.module==="$import(@zuplo/runtime)"&&l.add(m.name)});let _=wSr(a,l);return new Set([...l,..._])}t(kSr,"getPolicyNamesReferencingPolicyHandlers");function wSr(a,s){let l=new Set;return a.policies?.forEach(_=>{_.handler?.export==="CompositeInboundPolicy"&&_.handler?.options?.policies?.forEach(m=>{s.has(m)&&l.add(_.name)})}),l}t(wSr,"getCompositePoliciesContainingPolicy");function PSr(a,s){if(!a["x-zuplo-route"]||!a["x-zuplo-route"].policies)return!1;let l=a["x-zuplo-route"].policies.inbound;if(l){for(let m of l)if(s.has(m))return!0}let _=a["x-zuplo-route"].policies.outbound;if(_){for(let m of _)if(s.has(m))return!0}return!1}t(PSr,"isPolicyPresentInOperation");async function ASr(a,s){let l=[];for(let _ of a){let m=await XFe.readFile(_,"utf-8"),D=JSON.parse(m).paths;for(let A in D){let M=D[A];for(let U in M){let ie=M[U];PSr(ie,s)&&l.push({fileName:uF.basename(_,".oas.json"),path:A,method:U})}}}return l}t(ASr,"getRoutesContainingPolicies");import{mkdirSync as NSr,writeFileSync as ISr}from"fs";import OSr from"path";function Jyt(a){return{name:"write-modules-plugin",setup(s){s.onEnd(async l=>{if(l){let _=ij(a.sourceDirectory,l.metafile);NSr(a.outputDirectory,{recursive:!0}),ISr(OSr.join(a.outputDirectory,"modules.json"),JSON.stringify(_,null,2))}})}}}t(Jyt,"writeModulesPlugin");var FSr=aht("zuplo:core:build"),LSr=["workerd","worker","browser"],Vyt=[...process.env.GLOBAL_MODULE_LOCATION?[process.env.GLOBAL_MODULE_LOCATION]:[],QFe.resolve(zyt(qyt(import.meta.url)),"..","..","..","node_modules"),QFe.resolve(zyt(qyt(import.meta.url)),"..","..","..","..","..","node_modules")];async function OK({systemDirectory:a,outputDirectory:s,sourceDirectory:l,cacheDirectory:_,logger:m,minify:b=!0,command:D,flags:A}){let M=QFe.join(a,yce);FSr(`Building with node paths: ${Vyt.join(", ")}`);let U=b&&D!=="dev"&&!process.env.DEBUG_BUILD_DISABLE_MINIFY?{minify:!0,chunkNames:"[hash]"}:{minify:!1,keepNames:!0,chunkNames:"[name]-[hash]"},ie={sourceDirectory:l,outputDirectory:s,cacheDirectory:_,logger:m,debugMode:Ym.DEBUG_BUILD_MODE,flags:A};return{platform:"browser",target:"es2022",outdir:s,splitting:!0,metafile:!0,format:"esm",nodePaths:Vyt,entryPoints:[M],sourcemap:"linked",legalComments:"none",treeShaking:!0,bundle:!0,...U,external:[],logLevel:"silent",conditions:LSr,plugins:[dht(ie),oht(ie),Oyt(ie),Lyt(ie),$yt(ie),Myt(),uht(ie),Pyt(ie),Nyt(ie),Jyt(ie)]}}t(OK,"getBaseESBuildConfig");var fF="run-esbuild",Hyt=t(async function({systemDirectory:a,outputDirectory:s,sourceDirectory:l,cacheDirectory:_,buildId:m,logger:b,config:D,command:A,minify:M},U){return zf.timeFn("Running esbuild",async()=>{b.info(`Running build_id: ${m}`);let ie=await OK({command:A,minify:M,systemDirectory:a,outputDirectory:s,cacheDirectory:_,sourceDirectory:l,logger:b,flags:D.flags}),se;try{if(!await cM(l))throw new Error("Failed to build project because no open-api file was found on the 'config' folder");se=await Wyt.build(ie),U.set("metafile",se.metafile)}catch(Pe){if(b.error(Pe),Pe.errors||Pe.warnings)se=Pe;else if(Pe.message.includes("Failed to build project because no open-api file was found on the 'config' folder"))se={warnings:[],errors:[{id:"missing-open-api-file",text:"Failed to build project because no open-api file was found on the 'config' folder",pluginName:fF,location:null,notes:[],detail:"Failed to build project because no open-api file was found on the 'config' folder"}],outputFiles:void 0,metafile:void 0,mangleCache:void 0};else throw Pe}se.errors.length>0&&se.errors.length>1&&(se.errors.length=1);let{errors:Z,warnings:Re}=ZFe({buildId:m,result:se});return{errors:Z,warnings:Re}})},"runEsbuild");function ZFe({buildId:a,result:s}){return{status:s.errors.length>0?"Failed":s.warnings.length>0?"Warnings":"Good",runtimeVersion:"0.0.0",buildTime:"",buildTimeMs:0,buildId:a,warnings:s.warnings.map(_=>_.text==="Using direct eval with a bundler is not recommended and may cause problems"?{location:_.location,detail:_.detail,id:_.id,notes:_.notes,message:"We do not support the use of 'eval' or 'new Function(...)'",severity:_ce,pluginName:_.pluginName||fF}:{location:_.location,detail:_.detail,id:_.id,notes:_.notes,message:_.text,severity:_ce,pluginName:_.pluginName||fF}),errors:s.errors.map(_=>({location:_.location,detail:_.detail,id:_.id,notes:_.notes,message:_.text,severity:VAe,pluginName:_.pluginName||fF})),metafile:s.metafile}}t(ZFe,"esbuildResultToBuildResult");var RSr=t((a,s)=>{let l=s;if(s.includes(a)){let _=new RegExp(`.*(${a})`,"g");l=s.replace(_,"")}return l.match(/^(\/)?(\.\.(\/)?)+/)&&(l=l.replace(/^(\/)?(\.\.(\/)?)+/,"/")),l},"removePrefixFromString"),MSr=t((a,s)=>{let l=s;if(l.includes(a)){let _=new RegExp(`[a-zA-Z0-9-_.\\/]+(${a})`,"g");l=l.replace(_,"")}return l},"cleanFilePathsInMessage"),Gyt=t((a,s,l)=>{if(!a||a.length<=0)return a;let _=a.filter(m=>m.message!=='Could not resolve "@zuplo/runtime"');return _&&_.length>0&&_.forEach(m=>{try{m.location&&m.location.file&&(m.location.file=RSr(s,m.location.file)),m.location&&m.location.lineText&&m.location.lineText.includes("@zuplo/core/index.minified.js")&&(m.location.lineText=m.location.lineText.substring(0,200)+"...<Truncated>"),m.message=MSr(s,m.message),m.notes&&m.notes.length>0&&delete m.notes,m.text&&delete m.text,m.pluginName===""&&(m.pluginName=l)}catch{}}),_},"cleanDataOnBuildIssue");function Kyt(a,s){let l=e7e.basename(s);a.errors&&(a.errors=Gyt(a.errors,l,fF)),a.warnings&&(a.warnings=Gyt(a.warnings,l,fF))}t(Kyt,"formatBuildResult");var jSr=t(a=>e7e.basename(a).startsWith("."),"isHiddenOnUnix"),BSr=t((a,s=[])=>s.map(l=>l.startsWith(".")?l:`.${l}`).some(l=>a.endsWith(l)),"hasMatchingExtname");function HFe(a,s=[],l=!1){let _=[],m;if(!Jfe.existsSync(a)){let b;if(NH.hasMagic(a))b=a;else{let D=s.map(A=>A.startsWith(".")?A:`.${A}`).join("|");b=`${a}+(${D})`}if(_.push(...NH.sync(b,{nodir:!0})),!_.length)throw Error(`Cannot find any files matching pattern "${a}"`);return _}try{if(m=Jfe.statSync(a),m.isFile())return[a]}catch{return[]}return Jfe.readdirSync(a).forEach(b=>{let D=e7e.join(a,b),A;try{if(A=Jfe.statSync(D),A.isDirectory()){l&&_.push(...HFe(D,s,l));return}}catch{return}if(!s.length)throw Error(`Argument '${s}' required when argument '${a}' is a directory`);!A.isFile()||!BSr(D,s)||jSr(D)||_.push(D)}),_}t(HFe,"lookupFiles");var $T=new xce({level:process.env.FORCE_BUILD_COLORS?2:void 0}),R3=` ${$T.gray("|")} `;function CUr(a,s){a.info($T.green(s))}t(CUr,"outputSuccess");function DUr(a,s){a.warn($T.yellow(s))}t(DUr,"outputWarning");function kUr(a,s){a.error(`
593
- ${$T.red(s)}`)}t(kUr,"outputCritical");function wUr(a,s,l){let _=l.sort((D,A)=>{let M=D.path.split("/").length,U=A.path.split("/").length;return M!==U?M-U:D.path.localeCompare(A.path)}),m=Math.max(..._.map(D=>D.path.length)),b=`${s}
592
+ export default environment;`;function dht(a){return{name:"environment",setup(s){s.onResolve({filter:/@app\/environment$/},()=>({namespace:pht,pluginName:_ht,path:fht.join(a.sourceDirectory,Z4,"environment.js")})),s.onLoad({filter:/.*/,namespace:pht},async l=>({contents:Sgr,loader:"ts",resolveDir:fht.dirname(l.path),pluginName:_ht}))}}}t(dht,"environmentPlugin");var Cyt=S_(bFe(),1),Dyt=S_(H0t(),1),kyt=S_(VFe(),1),wyt=S_(WFe(),1);import bSr from"fs/promises";import z2 from"path";var pk="schemas",jfe="json-schema";function Pyt(a){return{name:pk,async setup(s){let l=new kyt.Ajv2020({code:{source:!0},allErrors:!0,strict:!1,verbose:!0,meta:!0});(0,Dyt.default)(l,{mode:"fast"}),l.opts.code.formats=Cyt._`require("ajv-formats/dist/formats").fastFormats`;let _=z2.join(a.sourceDirectory,lH),m,b=[],D=[];if(await wl.dirExists(_)&&(l.addKeyword("faker"),m=await wl.listFolderContents(_,lH),await Promise.all(m.map(async A=>{try{let M=wl.safePath(a.sourceDirectory).resolve(_,A);if(!M.startsWith(_))throw new Error("All schemas must be in the schemas directory");let U=await bSr.readFile(M,"utf-8");if(U===""||U===void 0)throw new Error(`Schema 'schemas/${A}' is empty and will be ignored.`);let ie=JSON.parse(U);if(ie.$schema&&ie.$schema!=="https://json-schema.org/draft/2020-12/schema")throw new Error(`Error in ${A}: All JSON schemas must use version 2020-12. See release notes for changes: https://json-schema.org/draft/2020-12/release-notes.html`);if(l.$dataMetaSchema,l.addSchema(ie,A),l.errors?.length){let se=l.errors[0];b.push({id:"json-schema-validation-error",pluginName:pk,text:`Error: ${se.message}`,location:{file:z2.join(lH,A)},detail:{params:se.params,propertyName:se.propertyName,schemaPath:se.schemaPath,data:se.data}})}}catch(M){if(M.message.endsWith("is empty and will be ignored.")){D.push({id:"empty-json-schema-file",pluginName:pk,text:`Schema 'schemas/${A}' is empty and will be ignored.`,location:{file:`schemas/${A}`,suggestion:"Add schema details or remove the file from the project."},detail:"EmptyJSONSchemaFile",notes:[{text:`Schema 'schemas/${A}' is empty and will be ignored.`,location:{file:`schemas/${A}`,suggestion:"Add schema details or remove the file from the project."}}]});return}let U=await C8e(A,a.sourceDirectory,M.message);b.push({id:"json-schema-add-error",pluginName:pk,text:`Error: ${M.message}`,location:U,detail:"InvalidAddSchemaError",notes:[{text:M.message}]})}})),await Promise.all(m.map(async A=>{try{let M=l.getSchema(A);M&&l.compile(M.schema).errors?.forEach(ie=>{b.push({text:`Failed to compile ${A}: ${ie.message}`})})}catch(M){let U=await C8e(A,a.sourceDirectory,M.message);b.push({id:"json-schema-compile-error",pluginName:pk,text:`The schema file '${A}' is not valid. Error: ${M.message}`,location:U,detail:"InvalidSchemaError",notes:[{text:M.message}]})}})),Ym.DEBUG_BUILD_MODE)){let A=z2.resolve(a.outputDirectory,lH);await wl.mkdirIfNotExists(A)}s.onStart(async()=>{if(m)return{errors:b,warnings:D}}),s.onResolve({filter:/schemas\/.*\.json$/},async A=>{let M=z2.isAbsolute(A.path)?A.path:z2.join(A.resolveDir,A.path);if(A.importer&&A.importer!==z2.join(a.sourceDirectory,"config/routes.json"))return{path:M};if(!await wl.fileExists(M)){let U="policies.json";return{errors:[{id:"json-schema-build-error",text:`Unable to resolve reference to '${A.path}' from ${U}`,location:{file:z2.join(A.resolveDir,U),namespace:jfe,line:1,column:0,length:0,lineText:`Invalid JSON schema reference in ${U}`,suggestion:""},detail:"RouteReferenceError",pluginName:pk,notes:[{text:`Unable to resolve reference to '${A.path}' from ${U}`,location:null}]}],namespace:jfe,path:M,pluginName:pk}}return{path:M,namespace:jfe,pluginName:pk}}),s.onLoad({filter:/.*/,namespace:jfe},async A=>zf.timeFn(`Generating json schema data: ${z2.basename(A.path)}`,async()=>{let M=[],U;try{let ie=z2.relative(_,A.path),se=l.getSchema(ie);if(!se)throw new Error(`Could not load schema at ${A.path}`);U=se.source?.validateCode;let Z=l.compile(se.schema);U=(0,wyt.default)(l,Z)}catch(ie){M.push({pluginName:pk,text:`Cannot parse project's schemas/${z2.basename(A.path)} file. Error: ${ie.message}`,location:null,notes:[{text:ie.message,location:null}],detail:ie})}if(Ym.DEBUG_BUILD_MODE&&U){let ie=z2.relative(_,A.path),se=z2.join(a.sourceDirectory,".zuplo",`${ie}.js`);await ak(se,U)}return{contents:U,errors:M,pluginName:pk,resolveDir:z2.dirname(A.path),watchFiles:[A.path]}}))}}}t(Pyt,"jsonSchemaPlugin");import{relative as SSr}from"path";var Ayt=["node:assert","node:async_hooks","node:buffer","node:crypto","node:diagnostics_channel","node:events","node:path","node:process","node:stream","node:string_decoder","node:util"],TSr="nodejs-compat-plugin";function Nyt({sourceDirectory:a}){return{name:TSr,setup(s){let l=new Set;s.onStart(()=>{l.clear()}),s.onResolve({filter:/node:.*/},async({path:_,kind:m,resolveDir:b,...D})=>{let A=`${_}:${m}:${b}:${D.importer}`;if(l.has(A))return;l.add(A);let M=await s.resolve(_,{kind:m,resolveDir:b,importer:D.importer});return M.errors.length>0?Ayt.includes(_)||_.includes("/")&&Ayt.includes(_.split("/")[0])?{external:!0}:{external:!0,warnings:M.errors.map(ie=>({...ie,location:{file:SSr(a,D.importer),line:0,column:0,namespace:"",length:0,lineText:"",suggestion:"Remove the imported node module"},detail:`The package "${_}" wasn't found on the file system but is built into node. If this code is executed it will fail.`}))}:M})}}}t(Nyt,"nodejsCompatPlugin");import Iyt from"fs/promises";import eC from"path";var Dj="open-api-routes-plugin",Bfe="open-api-routes-json";function Oyt(a){return{name:"open-api-routes-plugin",setup(s){s.onResolve({filter:/routes.json$/},l=>({watchFiles:[...HFe(eC.join(a.sourceDirectory,Zv),[".oas.json"],!0),eC.join(a.sourceDirectory,Zv,hce)],namespace:Bfe,path:eC.isAbsolute(l.path)?l.path:eC.join(l.resolveDir,l.path),pluginName:Dj})),s.onResolve({filter:/^\.\.\/modules\/.*/,namespace:Bfe},async l=>{let _=eC.join(l.resolveDir,`${l.path}.ts`);if(!await wl.fileExists(_)){let m=`$import(.${l.path.replace(/^../,"")})`,b=eC.resolve(a.sourceDirectory,"config"),D=await CO(b),A=await xot(D,m,"Update your route configuration to use code from the 'modules' folder");return{errors:[{id:"route-build-error",text:`Invalid handler reference in routes.json. Unable to resolve reference to '${m}' from routes.json`,location:A,detail:"RouteReferenceError",pluginName:Dj}],namespace:Bfe,path:l.path,pluginName:Dj}}}),s.onLoad({filter:/.*/,namespace:Bfe},async l=>zf.timeFn("Generating route.json data",async()=>{let _=eC.resolve(a.sourceDirectory,"config"),m=await CO(_),b=await Promise.all(m.map(async U=>({content:await Iyt.readFile(U,"utf-8"),fileName:U}))),D=eC.resolve(_,"policies.json");if(!await wl.fileExists(D))return{errors:[{text:"The project must include a policies file ('/config/policies.json')",detail:"OASPoliciesFileMissing",pluginName:Dj,location:{line:0,column:0,file:"/config/policies.json"}}],pluginName:Dj};let A={content:await Iyt.readFile(D,"utf-8"),fileName:D},M;try{M=await S8e({sourceDirectory:a.sourceDirectory,oasContent:b,policiesContent:A})}catch(U){throw new Error("Error compiling routes: "+U.message)}if(Ym.DEBUG_BUILD_MODE&&M.content){let U=eC.join(a.sourceDirectory,".zuplo"),ie=eC.resolve(U,"routes.js");await ak(ie,M.content)}return{contents:M.content,errors:M.errors,pluginName:Dj,resolveDir:eC.dirname(l.path),watchFiles:[l.path]}}))}}}t(Oyt,"openApiRoutesPlugin");import Ufe from"path";var IK="raw-route-plugin",Fyt="raw-route";function Lyt(a){return{name:"raw-route-plugin",setup(s){s.onResolve({filter:/raw.json$/},l=>({namespace:Fyt,path:l.path,pluginName:IK})),s.onLoad({filter:/.*/,namespace:Fyt},async l=>{let _=Ufe.resolve(a.sourceDirectory,Zv);if(!await wl.dirExists(_))return{loader:"js",resolveDir:Ufe.dirname(l.path),pluginName:IK};let m=await CO(_);try{let b=await E8e({oasFiles:m,sourceDirectory:a.sourceDirectory,logger:a.logger});if(Ym.DEBUG_BUILD_MODE&&b){let D=Ufe.join(a.sourceDirectory,".zuplo","raw-routes.js");await ak(D,b)}return{contents:b,loader:"js",resolveDir:Ufe.dirname(l.path),pluginName:IK}}catch(b){if(b instanceof M1)return{contents:"",loader:"ts",errors:[{id:"route-build-error",text:b.issue.text,location:b.issue.location,detail:b.issue.detail,pluginName:IK}],pluginName:IK};throw b}})}}}t(Lyt,"rawRoutePlugin");import xSr from"fs/promises";import GFe from"path";var $fe="runtime-config",Ryt="runtime-config-plugin";function Myt(){return{name:$fe,setup(a){a.onResolve({filter:/^\.\.\/modules\/zuplo.runtime.ts$/},s=>({namespace:Ryt,path:GFe.isAbsolute(s.path)?s.path:GFe.join(s.resolveDir,s.path),pluginName:$fe})),a.onLoad({filter:/.*/,namespace:Ryt},async s=>zf.timeFn("Generating zuplo.runtime.ts data",async()=>{let l="export const runtimeInit = undefined;",_=[];return await wl.fileExists(s.path)?(l=await xSr.readFile(s.path,"utf-8"),{contents:l,loader:"ts",resolveDir:GFe.dirname(s.path),errors:_,pluginName:$fe,watchFiles:[s.path]}):{contents:l,loader:"ts",errors:_,pluginName:$fe}}))}}}t(Myt,"runtimeConfigPlugin");var Byt=S_(VFe(),1),Uyt=S_(WFe(),1);import XFe from"fs/promises";import uF from"path";var KFe="schema-validation-plugin",jyt="schema-validation",ESr="module.exports = {}";function $yt(a){return{name:"schema-validation-plugin",setup(s){s.onResolve({filter:/ajv-schema.json$/},l=>({namespace:jyt,path:l.path,pluginName:KFe})),s.onLoad({filter:/.*/,namespace:jyt},async l=>{let _=uF.resolve(a.sourceDirectory,Zv,"policies.json");if(!await wl.fileExists(_))return{contents:ESr,loader:"js",resolveDir:uF.dirname(l.path),pluginName:KFe};let m=await DSr(a.sourceDirectory),b=uF.resolve(a.sourceDirectory,Zv),D=await CO(b),A=await ASr(D,m),M=await CSr({oasFiles:D,routesWithSchemaValidation:A,sourceDirectory:a.sourceDirectory,logger:a.logger});if(Ym.DEBUG_BUILD_MODE&&M){let U=uF.join(a.sourceDirectory,".zuplo","schema-validation.js");await ak(U,M)}return{contents:M,loader:"js",resolveDir:uF.dirname(l.path),pluginName:KFe}})}}}t($yt,"schemaValidationPlugin");async function CSr({oasFiles:a,routesWithSchemaValidation:s,sourceDirectory:l,logger:_}){let m="",b=new _3(l,_);if(s.length===0)return m;let D=new Byt.Ajv2020({code:{source:!0},allErrors:!0,strict:!1,verbose:!0,meta:!0});for(let A of a){let M=await XFe.readFile(A,"utf-8"),U=uF.basename(A,".oas.json"),ie=s.filter(ke=>ke.fileName===U),se=await b.resolve(A),Z=JSON.parse(M),Re=[],Pe=new Map;ie.forEach(ke=>{let wt=Z.paths[ke.path][ke.method];if(wt.requestBody){let At;if(wt.requestBody.$ref){let yr=wt.requestBody.$ref;At=se.get(yr)?.content}else wt.requestBody.content&&(At=wt.requestBody.content);if(At)for(let yr in At){let zr=At[yr].schema,en=i3e(ke.path,ke.method,yr);zr.$id=en,D.addSchema(zr),YFe(zr,A,U,D,se,Re,Pe)}}if(wt.parameters)for(let At of wt.parameters){let yr=At.$ref?se.get(At.$ref):At,zr=yr.schema.$ref?se.get(yr.schema.$ref):yr.schema,en=n3e(ke.path,ke.method,yr.in,yr.name);zr.$id=en,D.addSchema(zr),YFe(yr,A,U,D,se,Re,Pe)}});for(let ke of Re){let wt=se.get(ke),At=eG(U,ke);D.addSchema(wt,At)}}return m=(0,Uyt.default)(D),m}t(CSr,"schemaValidationSource");function YFe(a,s,l,_,m,b,D){for(let A in a){let M=a[A];if(A==="$ref"){let U=eG(l,n3(s,M));a[A]=U,LH(s,l,n3(s,M),m,b,D,(ie,se)=>eG(ie,n3(s,se)))}else typeof M=="object"&&YFe(M,s,l,_,m,b,D)}}t(YFe,"addRefsToSchema");async function DSr(a){let s=new Set(["RequestValidationInboundPolicy"]),l=await XFe.readFile(`${a}/config/policies.json`,"utf-8"),_=JSON.parse(l);return kSr(_,s)}t(DSr,"getPolicyNamesUsingSchemaValidationPolicies");function kSr(a,s){let l=new Set;a.policies?.forEach(m=>{m.handler?.export&&s.has(m.handler.export)&&m.handler.module==="$import(@zuplo/runtime)"&&l.add(m.name)});let _=wSr(a,l);return new Set([...l,..._])}t(kSr,"getPolicyNamesReferencingPolicyHandlers");function wSr(a,s){let l=new Set;return a.policies?.forEach(_=>{_.handler?.export==="CompositeInboundPolicy"&&_.handler?.options?.policies?.forEach(m=>{s.has(m)&&l.add(_.name)})}),l}t(wSr,"getCompositePoliciesContainingPolicy");function PSr(a,s){if(!a["x-zuplo-route"]||!a["x-zuplo-route"].policies)return!1;let l=a["x-zuplo-route"].policies.inbound;if(l){for(let m of l)if(s.has(m))return!0}let _=a["x-zuplo-route"].policies.outbound;if(_){for(let m of _)if(s.has(m))return!0}return!1}t(PSr,"isPolicyPresentInOperation");async function ASr(a,s){let l=[];for(let _ of a){let m=await XFe.readFile(_,"utf-8"),D=JSON.parse(m).paths;for(let A in D){let M=D[A];for(let U in M){let ie=M[U];PSr(ie,s)&&l.push({fileName:uF.basename(_,".oas.json"),path:A,method:U})}}}return l}t(ASr,"getRoutesContainingPolicies");import{mkdirSync as NSr,writeFileSync as ISr}from"fs";import OSr from"path";function Jyt(a){return{name:"write-modules-plugin",setup(s){s.onEnd(async l=>{if(l){let _=ij(a.sourceDirectory,l.metafile);NSr(a.outputDirectory,{recursive:!0}),ISr(OSr.join(a.outputDirectory,"modules.json"),JSON.stringify(_,null,2))}})}}}t(Jyt,"writeModulesPlugin");var FSr=aht("zuplo:core:build"),LSr=["workerd","worker","browser"],Vyt=[...process.env.GLOBAL_MODULE_LOCATION?[process.env.GLOBAL_MODULE_LOCATION]:[],QFe.resolve(zyt(qyt(import.meta.url)),"..","..","..","node_modules"),QFe.resolve(zyt(qyt(import.meta.url)),"..","..","..","..","..","node_modules")];async function OK({systemDirectory:a,outputDirectory:s,sourceDirectory:l,cacheDirectory:_,logger:m,minify:b=!0,command:D,flags:A}){let M=QFe.join(a,yce);FSr(`Building with node paths: ${Vyt.join(", ")}`);let U=b&&D!=="dev"&&!process.env.DEBUG_BUILD_DISABLE_MINIFY?{minify:!0,chunkNames:"[hash]"}:{minify:!1,keepNames:!0,chunkNames:"[name]-[hash]"},ie={sourceDirectory:l,outputDirectory:s,cacheDirectory:_,logger:m,debugMode:Ym.DEBUG_BUILD_MODE,flags:A};return{platform:"browser",target:"es2022",outdir:s,splitting:!0,metafile:!0,format:"esm",nodePaths:Vyt,entryPoints:[M],sourcemap:"linked",legalComments:"none",treeShaking:!0,bundle:!0,...U,external:[],logLevel:"silent",conditions:LSr,plugins:[dht(ie),oht(ie),Oyt(ie),Lyt(ie),$yt(ie),Myt(),uht(ie),Pyt(ie),Nyt(ie),Jyt(ie)]}}t(OK,"getBaseESBuildConfig");var fF="run-esbuild",Hyt=t(async function({systemDirectory:a,outputDirectory:s,sourceDirectory:l,cacheDirectory:_,buildId:m,logger:b,config:D,command:A,minify:M},U){return zf.timeFn("Running esbuild",async()=>{b.info(`Running build_id: ${m}`);let ie=await OK({command:A,minify:M,systemDirectory:a,outputDirectory:s,cacheDirectory:_,sourceDirectory:l,logger:b,flags:D.flags}),se;try{if(!await cM(l))throw new Error("Failed to build project because no open-api file was found on the 'config' folder");se=await Wyt.build(ie),U.set("metafile",se.metafile)}catch(Pe){if(b.error(Pe),Pe.errors||Pe.warnings)se=Pe;else if(Pe.message.includes("Failed to build project because no open-api file was found on the 'config' folder"))se={warnings:[],errors:[{id:"missing-open-api-file",text:"Failed to build project because no open-api file was found on the 'config' folder",pluginName:fF,location:null,notes:[],detail:"Failed to build project because no open-api file was found on the 'config' folder"}],outputFiles:void 0,metafile:void 0,mangleCache:void 0};else throw Pe}se.errors.length>0&&se.errors.length>1&&(se.errors.length=1);let{errors:Z,warnings:Re}=ZFe({buildId:m,result:se});return{errors:Z,warnings:Re}})},"runEsbuild");function ZFe({buildId:a,result:s}){return{status:s.errors.length>0?"Failed":s.warnings.length>0?"Warnings":"Good",runtimeVersion:"0.0.0",buildTime:"",buildTimeMs:0,buildId:a,warnings:s.warnings.map(_=>_.text==="Using direct eval with a bundler is not recommended and may cause problems"?{location:_.location,detail:_.detail,id:_.id,notes:_.notes,message:"We do not support the use of 'eval' or 'new Function(...)'",severity:_ce,pluginName:_.pluginName||fF}:{location:_.location,detail:_.detail,id:_.id,notes:_.notes,message:_.text,severity:_ce,pluginName:_.pluginName||fF}),errors:s.errors.map(_=>({location:_.location,detail:_.detail,id:_.id,notes:_.notes,message:_.text,severity:VAe,pluginName:_.pluginName||fF})),metafile:s.metafile}}t(ZFe,"esbuildResultToBuildResult");var RSr=t((a,s)=>{let l=s;if(s.includes(a)){let _=new RegExp(`.*(${a})`,"g");l=s.replace(_,"")}return l.match(/^(\/)?(\.\.(\/)?)+/)&&(l=l.replace(/^(\/)?(\.\.(\/)?)+/,"/")),l},"removePrefixFromString"),MSr=t((a,s)=>{let l=s;if(l.includes(a)){let _=new RegExp(`[a-zA-Z0-9-_.\\/]+(${a})`,"g");l=l.replace(_,"")}return l},"cleanFilePathsInMessage"),Gyt=t((a,s,l)=>{if(!a||a.length<=0)return a;let _=a.filter(m=>m.message!=='Could not resolve "@zuplo/runtime"');return _&&_.length>0&&_.forEach(m=>{try{m.location&&m.location.file&&(m.location.file=RSr(s,m.location.file)),m.location&&m.location.lineText&&m.location.lineText.includes("@zuplo/core/index.minified.js")&&(m.location.lineText=m.location.lineText.substring(0,200)+"...<Truncated>"),m.message=MSr(s,m.message),m.notes&&m.notes.length>0&&delete m.notes,m.text&&delete m.text,m.pluginName===""&&(m.pluginName=l)}catch{}}),_},"cleanDataOnBuildIssue");function Kyt(a,s){let l=e7e.basename(s);a.errors&&(a.errors=Gyt(a.errors,l,fF)),a.warnings&&(a.warnings=Gyt(a.warnings,l,fF))}t(Kyt,"formatBuildResult");var jSr=t(a=>e7e.basename(a).startsWith("."),"isHiddenOnUnix"),BSr=t((a,s=[])=>s.map(l=>l.startsWith(".")?l:`.${l}`).some(l=>a.endsWith(l)),"hasMatchingExtname");function HFe(a,s=[],l=!1){let _=[],m;if(!Jfe.existsSync(a)){let b;if(NH.hasMagic(a))b=a;else{let D=s.map(A=>A.startsWith(".")?A:`.${A}`).join("|");b=`${a}+(${D})`}if(_.push(...NH.sync(b,{nodir:!0})),!_.length)throw Error(`Cannot find any files matching pattern "${a}"`);return _}try{if(m=Jfe.statSync(a),m.isFile())return[a]}catch{return[]}return Jfe.readdirSync(a).forEach(b=>{let D=e7e.join(a,b),A;try{if(A=Jfe.statSync(D),A.isDirectory()){l&&_.push(...HFe(D,s,l));return}}catch{return}if(!s.length)throw Error(`Argument '${s}' required when argument '${a}' is a directory`);!A.isFile()||!BSr(D,s)||jSr(D)||_.push(D)}),_}t(HFe,"lookupFiles");var $T=new xce({level:process.env.FORCE_BUILD_COLORS?2:void 0}),R3=` ${$T.gray("|")} `;function CUr(a,s,l){a.child("api").info($T.green(s),l)}t(CUr,"outputSuccess");function DUr(a,s,l){a.child("api").warn($T.yellow(s),l)}t(DUr,"outputWarning");function kUr(a,s,l){a.child("api").error(`
593
+ ${$T.red(s)}`,l)}t(kUr,"outputCritical");function wUr(a,s,l){let _=l.sort((D,A)=>{let M=D.path.split("/").length,U=A.path.split("/").length;return M!==U?M-U:D.path.localeCompare(A.path)}),m=Math.max(..._.map(D=>D.path.length)),b=`${s}
594
594
  `;_.forEach(D=>{let A=" ".repeat(m-D.path.length),M=D.bytes/1024,U=` ${D.path}${A} ${M.toFixed(2)} KB
595
- `;b+=M>1024?$T.red(U):M>300?$T.yellow(U):U}),a.info(b)}t(wUr,"outputFileTree");function PUr(a,s){if(s.length===0)return"";let l=Object.keys(s[0]).length,_=Array.from({length:l},(D,A)=>Math.max(...s.map(M=>String(Object.values(M)[A]).length))),b=s.map(D=>Object.values(D).map((A,M)=>String(A).padEnd(_[M])).join(" ")).join(`
596
- `);a.info(b)}t(PUr,"outputTable");function t7e({output:a,buildId:s,runtimeVersion:l,compatibilityDate:_}){let m=["Building Zuplo API...",`${R3}Build ID: ${s}`,`${R3}Runtime Version: ${l}`];_&&m.push(`${R3}Compatibility Date: ${_}`),a.info(m.join(`
597
- `))}t(t7e,"outputBuildStart");async function zfe(a,s,l){Kyt(l,a),await Promise.all(l.warnings.map(async _=>Yyt(a,s,_))),await Promise.all(l.errors.map(async _=>Yyt(a,s,_))),l.status==="Good"?s.info($T.green("Build succeeded"),{status:"success"}):l.status==="Warnings"?s.warn($T.yellow("Build succeeded with warnings"),{status:"success"}):l.status==="Failed"&&s.error($T.red("Failed to build API"),{status:"failed"})}t(zfe,"outputBuildResult");async function Yyt(a,s,l){let _=[],m=l.severity??"error",b=m==="error"?$T.red:$T.yellow,D=b(`${m.toUpperCase()}: ${l.message}${l.detail?`
595
+ `;b+=M>1024?$T.red(U):M>300?$T.yellow(U):U}),a.child("api").info(b)}t(wUr,"outputFileTree");function PUr(a,s){if(s.length===0)return"";let l=Object.keys(s[0]).length,_=Array.from({length:l},(D,A)=>Math.max(...s.map(M=>String(Object.values(M)[A]).length))),b=s.map(D=>Object.values(D).map((A,M)=>String(A).padEnd(_[M])).join(" ")).join(`
596
+ `);a.child("api").info(b)}t(PUr,"outputTable");function t7e({output:a,buildId:s,runtimeVersion:l,compatibilityDate:_}){let m=["Building Zuplo API...",`${R3}Build ID: ${s}`,`${R3}Runtime Version: ${l}`];_&&m.push(`${R3}Compatibility Date: ${_}`),a.child("api").info(m.join(`
597
+ `))}t(t7e,"outputBuildStart");async function zfe(a,s,l){Kyt(l,a),await Promise.all(l.warnings.map(async _=>Yyt(a,s,_))),await Promise.all(l.errors.map(async _=>Yyt(a,s,_))),l.status==="Good"?s.child("api").info($T.green("Build succeeded"),{status:"success"}):l.status==="Warnings"?s.child("api").warn($T.yellow("Build succeeded with warnings"),{status:"success"}):l.status==="Failed"&&s.child("api").error($T.red("Failed to build API"),{status:"failed"})}t(zfe,"outputBuildResult");async function Yyt(a,s,l){let _=[],m=l.severity??"error",b=m==="error"?$T.red:$T.yellow,D=b(`${m.toUpperCase()}: ${l.message}${l.detail?`
598
598
  ${R3}${l.detail.toString().split(`
599
599
  `).join(`
600
- ${R3}`)}`:""}`);_.push(D);let A=JSr(l.location??void 0);if(A&&_.push(`${R3}${b(`The error was found in the file: ${A}`)}`),l.location&&l.location.file&&l.location.column!==0&&l.location.line!==0)try{let M=$Sr.join(a,l.location.file),U=await USr(M,"utf-8"),ie=(0,Xyt.codeFrameColumns)(U,{start:{line:l.location.line,column:l.location.column}},{highlightCode:!0,forceColor:!!process.env.FORCE_BUILD_COLORS,message:l.message,linesAbove:3,linesBelow:3});_.push(R3),_.push(ie)}catch{}else l.location&&l.location.file&&_.push($T.red(`${R3}File: ${l.location.file}:${l.location.line}:${l.location.column}`));_.push(""),l.severity==="warning"?s.warn(_.join(`
601
- `)):s.error(_.join(`
600
+ ${R3}`)}`:""}`);_.push(D);let A=JSr(l.location??void 0);if(A&&_.push(`${R3}${b(`The error was found in the file: ${A}`)}`),l.location&&l.location.file&&l.location.column!==0&&l.location.line!==0)try{let M=$Sr.join(a,l.location.file),U=await USr(M,"utf-8"),ie=(0,Xyt.codeFrameColumns)(U,{start:{line:l.location.line,column:l.location.column}},{highlightCode:!0,forceColor:!!process.env.FORCE_BUILD_COLORS,message:l.message,linesAbove:3,linesBelow:3});_.push(R3),_.push(ie)}catch{}else l.location&&l.location.file&&_.push($T.red(`${R3}File: ${l.location.file}:${l.location.line}:${l.location.column}`));_.push(""),l.severity==="warning"?s.child("api").warn(_.join(`
601
+ `)):s.child("api").error(_.join(`
602
602
  `))}t(Yyt,"logIssue");function JSr(a){if(a&&a.file){let s=a.file;if(a.line)return`${s}:${a.line}`;if(a.column)return`${s}:${a.column}`}}t(JSr,"getFileLocation");var JT=class{static{t(this,"PluginResult")}errors=[];warnings=[];constructor(s){s&&this.errors.push(s)}};async function Qyt(a,s){let l=[],_=[],m=new Map;for await(let b of a)try{let D=await b(s,m);if(_.push(...D.errors.map(A=>(A.pluginName===""&&(A.pluginName=b.name),A))),l.push(...D.warnings),D.errors.length>0)break}catch(D){D instanceof M1?_.push({...D.issue,pluginName:D.pluginName??"unknown"}):_.push(D);break}return{errors:_,warnings:l,data:m}}t(Qyt,"runPlugins");import{parse as zSr}from"jsonc-parser";import{readFile as qSr}from"fs/promises";import Zyt from"path";async function qfe(a){let s=Zyt.join(a,WAe),l=Zyt.join(a,HAe),_=!1,m=s;await wl.fileExists(s)?(_=!0,m=s):await wl.fileExists(l)&&(_=!0,m=l);let b,D;if(_){let M=await qSr(m,"utf-8"),ie=zSr(M,[]);if(typeof ie!="object")return{status:vO,errors:[{message:"Invalid zuplo.jsonc file.",detail:"The zuplo.jsonc file is not a valid JSON object",pluginName:"buildData",severity:"error"}]};if("version"in ie&&ie.version!==1)return{status:vO,errors:[{message:"Invalid version set in zuplo.jsonc file.",detail:"version in zuplo.jsonc must be set to 1",pluginName:"buildData",severity:"error"}]};if("compatibilityDate"in ie&&GR&&typeof ie.compatibilityDate=="string"){if(!GR.includes(ie.compatibilityDate)){let se={message:"Invalid compatibilityDate set in zuplo.jsonc file.",detail:`compatibilityDate was set to ${ie.compatibilityDate}. Valid compatibility dates are ${GR.join(", ")}`,pluginName:"buildData",severity:"error"};return{status:vO,errors:[se]}}b=ie.compatibilityDate}D=fce(b,ie.flags)}else D=fce(void 0,void 0);return{status:yO,config:{version:1,compatibilityDate:b,flags:D}}}t(qfe,"getZuploConfig");import{mkdir as e1t,readFile as VSr,readdir as WSr,writeFile as HSr}from"fs/promises";import FK from"path";var t1t=t(async function({sourceDirectory:a,logger:s,outputDirectory:l,deploymentName:_,environmentType:m,customDomain:b}){return zf.timeFn("Building OpenAPI files to build output",async()=>{s.debug("Building OpenAPI files to build output");let D=FK.join(a,Zv),A=FK.join(D,hce),M=FK.join(l,Fst,Zv);try{if(await wl.dirExists(l)||await e1t(l),await wl.dirExists(M)||await e1t(M,{recursive:!0}),!await cM(a))return new JT({message:"Failed to build project because no OpenAPI file was found on the 'config' folder",pluginName:"build-open-api-files",severity:"error"});let se=(await WSr(D)).filter(Pe=>Pe.endsWith(".oas.json"));if(!await wl.fileExists(A))return new JT({message:"The project must include a policies file ('/config/policies.json')",pluginName:"build-open-api-files",severity:"error"});let Z=await VSr(A,"utf-8"),Re=JSON.parse(Z);for await(let Pe of se){let ke=FK.join(D,Pe),wt;try{wt=await nut({sourceDirectory:a,openApiDocPath:ke,policiesConfig:Re,logger:s,environmentType:m,deploymentName:_,customDomain:b})}catch(zr){if(s.error(zr),zr instanceof SyntaxError||zr instanceof CT.ResolverError||zr instanceof CT.JSONParserError||zr instanceof CT.ParserError||zr instanceof CT.MissingPointerError||zr instanceof FO)return new JT({message:zr.message,location:{file:Pe,column:0,length:0,line:0,lineText:"",namespace:"",suggestion:""},pluginName:"build-open-api-files",severity:"error"});if(zr instanceof M1)return new JT({...zr.issue,pluginName:"build-open-api-files"});throw zr}let At=JSON.stringify(wt,null,2),yr=FK.join(M,Pe);await HSr(yr,At,"utf-8")}}catch(U){return s.error(U),new JT({message:"Error building OpenAPI files",pluginName:"build-open-api-files",severity:"error"})}return new JT})},"buildOpenApiFiles");import GSr from"fs/promises";import KSr from"path";var r1t=t(async function({outputDirectory:a,systemDirectory:s,cacheDirectory:l,logger:_}){return zf.timeFn("Cleaning output",async()=>{_.debug("Cleaning output");let m=KSr.join(l,"routes"),b=[a,s,m];for await(let D of b)try{await GSr.rm(D,{recursive:!0,force:!0})}catch(A){_.error(A)}return{warnings:[],errors:[]}})},"cleanOutput");import n1t from"fs/promises";var i1t=t(async function({systemDirectory:a,cacheDirectory:s,logger:l}){return zf.timeFn("Creating system directory",async()=>{l.debug("Creating system directory");try{return await wl.dirExists(a)?l.debug("System directory already exists, skipping"):await n1t.mkdir(a),await wl.dirExists(s)?l.debug("Cache directory already exists, skipping"):await n1t.mkdir(s,{recursive:!0}),{warnings:[],errors:[]}}catch(_){return l.error(_),{warnings:[],errors:[]}}return{warnings:[],errors:[]}})},"createSystemDir");var s1t=t(async function({logger:a}){return zf.timeFn("Checking for breaking changes",async()=>(a.debug("Checking for breaking changes"),{warnings:[],errors:[]}))},"checkForDeprecations");import{readFile as YSr,writeFile as XSr}from"fs/promises";import a1t,{dirname as QSr}from"path";import{fileURLToPath as ZSr}from"url";var o1t=t(async function({systemDirectory:a,buildId:s,logger:l,config:_,publicZuploEnvironmentVariables:m}){return zf.timeFn("Generating build data",async()=>{l.debug("Generating build data");let b=await YSr(a1t.resolve(QSr(ZSr(import.meta.url)),"../../../package.json"),"utf-8"),D=JSON.parse(b),A={BUILD_ID:s??"",GIT_SHA:process.env.GIT_SHA,TIMESTAMP:new Date().toISOString(),BUILD_ENV:Ym.NODE_ENV,ZUPLO_VERSION:D.version,API_VERSION:process.env.API_VERSION,COMPATIBILITY_DATE:_?.compatibilityDate,ACCOUNT_NAME:m?.ZUPLO_ACCOUNT_NAME,PROJECT_NAME:m?.ZUPLO_PROJECT_NAME,ENVIRONMENT_TYPE:m?.ZUPLO_ENVIRONMENT_TYPE,IS_LOCAL_DEVELOPMENT:Ym.isLocalDevelopment(),COMPATIBILITY_FLAGS:pce?pce[_?.compatibilityDate??"none"]:{runOutboundPoliciesOnHandlerOnAllStatuses:!1,doNotRunHooksOnSystemRoutes:!1,removeAllVendorHeadersExceptListed:!1,allowCustomPorts:!1}},M=JSON.stringify(A,void 0,2),U=a1t.join(a,gce);try{await XSr(U,M.trimStart(),"utf-8")}catch(ie){l.error(ie);let se={message:`Error creating file at ${U}`,pluginName:"buildData",severity:"error"};return{warnings:[],errors:[se]}}return{warnings:[],errors:[]}})},"generateBuildData");import eTr from"fs/promises";import tTr from"path";var rTr=`import { Handler, ServiceProviderImpl } from "@zuplo/runtime";
603
603
  import routeLoader from "../config/routes.json";
604
604
  import * as schemaValidations from "./ajv-schema.json";
@@ -634,7 +634,7 @@ export default {
634
634
  `:10,l=typeof a=="string"?"\r":13;return a[a.length-1]===s&&(a=a.slice(0,-1)),a[a.length-1]===l&&(a=a.slice(0,-1)),a}t(B5e,"stripFinalNewline");import xpe from"process";import XK from"path";import{fileURLToPath as USt}from"url";function Tpe(a={}){let{env:s=process.env,platform:l=process.platform}=a;return l!=="win32"?"PATH":Object.keys(s).reverse().find(_=>_.toUpperCase()==="PATH")||"Path"}t(Tpe,"pathKey");var ewr=t(({cwd:a=xpe.cwd(),path:s=xpe.env[Tpe()],preferLocal:l=!0,execPath:_=xpe.execPath,addExecPath:m=!0}={})=>{let b=a instanceof URL?USt(a):a,D=XK.resolve(b),A=[];return l&&twr(A,D),m&&rwr(A,_,D),[...A,s].join(XK.delimiter)},"npmRunPath"),twr=t((a,s)=>{let l;for(;l!==s;)a.push(XK.join(s,"node_modules/.bin")),l=s,s=XK.resolve(s,"..")},"applyPreferLocal"),rwr=t((a,s,l)=>{let _=s instanceof URL?USt(s):s;a.push(XK.resolve(l,_,".."))},"applyExecPath"),$St=t(({env:a=xpe.env,...s}={})=>{a={...a};let l=Tpe({env:a});return s.path=a[l],a[l]=ewr(s),a},"npmRunPathEnv");var nwr=t((a,s,l,_)=>{if(l==="length"||l==="prototype"||l==="arguments"||l==="caller")return;let m=Object.getOwnPropertyDescriptor(a,l),b=Object.getOwnPropertyDescriptor(s,l);!iwr(m,b)&&_||Object.defineProperty(a,l,b)},"copyProperty"),iwr=t(function(a,s){return a===void 0||a.configurable||a.writable===s.writable&&a.enumerable===s.enumerable&&a.configurable===s.configurable&&(a.writable||a.value===s.value)},"canCopyProperty"),swr=t((a,s)=>{let l=Object.getPrototypeOf(s);l!==Object.getPrototypeOf(a)&&Object.setPrototypeOf(a,l)},"changePrototype"),awr=t((a,s)=>`/* Wrapped ${a}*/
635
635
  ${s}`,"wrappedToString"),owr=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),cwr=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),lwr=t((a,s,l)=>{let _=l===""?"":`with ${l.trim()}() `,m=awr.bind(null,_,s.toString());Object.defineProperty(m,"name",cwr),Object.defineProperty(a,"toString",{...owr,value:m})},"changeToString");function U5e(a,s,{ignoreNonConfigurable:l=!1}={}){let{name:_}=a;for(let m of Reflect.ownKeys(s))nwr(a,s,m,l);return swr(a,s),lwr(a,s,_),a}t(U5e,"mimicFunction");var Epe=new WeakMap,JSt=t((a,s={})=>{if(typeof a!="function")throw new TypeError("Expected a function");let l,_=0,m=a.displayName||a.name||"<anonymous>",b=t(function(...D){if(Epe.set(b,++_),_===1)l=a.apply(this,D),a=null;else if(s.throw===!0)throw new Error(`Function \`${m}\` can only be called once`);return l},"onetime");return U5e(b,a),Epe.set(b,_),b},"onetime");JSt.callCount=a=>{if(!Epe.has(a))throw new Error(`The given function \`${a.name}\` is not wrapped by the \`onetime\` package`);return Epe.get(a)};var zSt=JSt;import{constants as pwr}from"os";var qSt=t(function(){let a=$5e-VSt+1;return Array.from({length:a},uwr)},"getRealtimeSignals"),uwr=t(function(a,s){return{name:`SIGRT${s+1}`,number:VSt+s,action:"terminate",description:"Application-specific signal (realtime)",standard:"posix"}},"getRealtimeSignal"),VSt=34,$5e=64;import{constants as fwr}from"os";var WSt=[{name:"SIGHUP",number:1,action:"terminate",description:"Terminal closed",standard:"posix"},{name:"SIGINT",number:2,action:"terminate",description:"User interruption with CTRL-C",standard:"ansi"},{name:"SIGQUIT",number:3,action:"core",description:"User interruption with CTRL-\\",standard:"posix"},{name:"SIGILL",number:4,action:"core",description:"Invalid machine instruction",standard:"ansi"},{name:"SIGTRAP",number:5,action:"core",description:"Debugger breakpoint",standard:"posix"},{name:"SIGABRT",number:6,action:"core",description:"Aborted",standard:"ansi"},{name:"SIGIOT",number:6,action:"core",description:"Aborted",standard:"bsd"},{name:"SIGBUS",number:7,action:"core",description:"Bus error due to misaligned, non-existing address or paging error",standard:"bsd"},{name:"SIGEMT",number:7,action:"terminate",description:"Command should be emulated but is not implemented",standard:"other"},{name:"SIGFPE",number:8,action:"core",description:"Floating point arithmetic error",standard:"ansi"},{name:"SIGKILL",number:9,action:"terminate",description:"Forced termination",standard:"posix",forced:!0},{name:"SIGUSR1",number:10,action:"terminate",description:"Application-specific signal",standard:"posix"},{name:"SIGSEGV",number:11,action:"core",description:"Segmentation fault",standard:"ansi"},{name:"SIGUSR2",number:12,action:"terminate",description:"Application-specific signal",standard:"posix"},{name:"SIGPIPE",number:13,action:"terminate",description:"Broken pipe or socket",standard:"posix"},{name:"SIGALRM",number:14,action:"terminate",description:"Timeout or timer",standard:"posix"},{name:"SIGTERM",number:15,action:"terminate",description:"Termination",standard:"ansi"},{name:"SIGSTKFLT",number:16,action:"terminate",description:"Stack is empty or overflowed",standard:"other"},{name:"SIGCHLD",number:17,action:"ignore",description:"Child process terminated, paused or unpaused",standard:"posix"},{name:"SIGCLD",number:17,action:"ignore",description:"Child process terminated, paused or unpaused",standard:"other"},{name:"SIGCONT",number:18,action:"unpause",description:"Unpaused",standard:"posix",forced:!0},{name:"SIGSTOP",number:19,action:"pause",description:"Paused",standard:"posix",forced:!0},{name:"SIGTSTP",number:20,action:"pause",description:'Paused using CTRL-Z or "suspend"',standard:"posix"},{name:"SIGTTIN",number:21,action:"pause",description:"Background process cannot read terminal input",standard:"posix"},{name:"SIGBREAK",number:21,action:"terminate",description:"User interruption with CTRL-BREAK",standard:"other"},{name:"SIGTTOU",number:22,action:"pause",description:"Background process cannot write to terminal output",standard:"posix"},{name:"SIGURG",number:23,action:"ignore",description:"Socket received out-of-band data",standard:"bsd"},{name:"SIGXCPU",number:24,action:"core",description:"Process timed out",standard:"bsd"},{name:"SIGXFSZ",number:25,action:"core",description:"File too big",standard:"bsd"},{name:"SIGVTALRM",number:26,action:"terminate",description:"Timeout or timer",standard:"bsd"},{name:"SIGPROF",number:27,action:"terminate",description:"Timeout or timer",standard:"bsd"},{name:"SIGWINCH",number:28,action:"ignore",description:"Terminal window size changed",standard:"bsd"},{name:"SIGIO",number:29,action:"terminate",description:"I/O is available",standard:"other"},{name:"SIGPOLL",number:29,action:"terminate",description:"Watched event",standard:"other"},{name:"SIGINFO",number:29,action:"ignore",description:"Request for process information",standard:"other"},{name:"SIGPWR",number:30,action:"terminate",description:"Device running out of power",standard:"systemv"},{name:"SIGSYS",number:31,action:"core",description:"Invalid system call",standard:"other"},{name:"SIGUNUSED",number:31,action:"terminate",description:"Invalid system call",standard:"other"}];var J5e=t(function(){let a=qSt();return[...WSt,...a].map(_wr)},"getSignals"),_wr=t(function({name:a,number:s,description:l,action:_,forced:m=!1,standard:b}){let{signals:{[a]:D}}=fwr,A=D!==void 0;return{name:a,number:A?D:s,description:l,supported:A,action:_,forced:m,standard:b}},"normalizeSignal");var dwr=t(function(){return J5e().reduce(mwr,{})},"getSignalsByName"),mwr=t(function(a,{name:s,number:l,description:_,supported:m,action:b,forced:D,standard:A}){return{...a,[s]:{name:s,number:l,description:_,supported:m,action:b,forced:D,standard:A}}},"getSignalByName"),HSt=dwr(),hwr=t(function(){let a=J5e(),s=$5e+1,l=Array.from({length:s},(_,m)=>gwr(m,a));return Object.assign({},...l)},"getSignalsByNumber"),gwr=t(function(a,s){let l=ywr(a,s);if(l===void 0)return{};let{name:_,description:m,supported:b,action:D,forced:A,standard:M}=l;return{[a]:{name:_,number:a,description:m,supported:b,action:D,forced:A,standard:M}}},"getSignalByNumber"),ywr=t(function(a,s){let l=s.find(({name:_})=>pwr.signals[_]===a);return l!==void 0?l:s.find(_=>_.number===a)},"findSignalByNumber"),sWr=hwr();var vwr=t(({timedOut:a,timeout:s,errorCode:l,signal:_,signalDescription:m,exitCode:b,isCanceled:D})=>a?`timed out after ${s} milliseconds`:D?"was canceled":l!==void 0?`failed with ${l}`:_!==void 0?`was killed with ${_} (${m})`:b!==void 0?`failed with exit code ${b}`:"failed","getErrorPrefix"),z5e=t(({stdout:a,stderr:s,all:l,error:_,signal:m,exitCode:b,command:D,escapedCommand:A,timedOut:M,isCanceled:U,killed:ie,parsed:{options:{timeout:se}}})=>{b=b===null?void 0:b,m=m===null?void 0:m;let Z=m===void 0?void 0:HSt[m].description,Re=_&&_.code,ke=`Command ${vwr({timedOut:M,timeout:se,errorCode:Re,signal:m,signalDescription:Z,exitCode:b,isCanceled:U})}: ${D}`,wt=Object.prototype.toString.call(_)==="[object Error]",At=wt?`${ke}
636
636
  ${_.message}`:ke,yr=[At,s,a].filter(Boolean).join(`
637
- `);return wt?(_.originalMessage=_.message,_.message=yr):_=new Error(yr),_.shortMessage=At,_.command=D,_.escapedCommand=A,_.exitCode=b,_.signal=m,_.signalDescription=Z,_.stdout=a,_.stderr=s,l!==void 0&&(_.all=l),"bufferedData"in _&&delete _.bufferedData,_.failed=!0,_.timedOut=!!M,_.isCanceled=U,_.killed=ie&&!M,_},"makeError");var Cpe=["stdin","stdout","stderr"],bwr=t(a=>Cpe.some(s=>a[s]!==void 0),"hasAlias"),GSt=t(a=>{if(!a)return;let{stdio:s}=a;if(s===void 0)return Cpe.map(_=>a[_]);if(bwr(a))throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${Cpe.map(_=>`\`${_}\``).join(", ")}`);if(typeof s=="string")return s;if(!Array.isArray(s))throw new TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof s}\``);let l=Math.max(s.length,Cpe.length);return Array.from({length:l},(_,m)=>s[m])},"normalizeStdio");var tTt=S_(eTt(),1);import Swr from"os";var Twr=1e3*5,rTt=t((a,s="SIGTERM",l={})=>{let _=a(s);return xwr(a,s,l,_),_},"spawnedKill"),xwr=t((a,s,l,_)=>{if(!Ewr(s,l,_))return;let m=Dwr(l),b=setTimeout(()=>{a("SIGKILL")},m);b.unref&&b.unref()},"setKillTimeout"),Ewr=t((a,{forceKillAfterTimeout:s},l)=>Cwr(a)&&s!==!1&&l,"shouldForceKill"),Cwr=t(a=>a===Swr.constants.signals.SIGTERM||typeof a=="string"&&a.toUpperCase()==="SIGTERM","isSigterm"),Dwr=t(({forceKillAfterTimeout:a=!0})=>{if(a===!0)return Twr;if(!Number.isFinite(a)||a<0)throw new TypeError(`Expected the \`forceKillAfterTimeout\` option to be a non-negative integer, got \`${a}\` (${typeof a})`);return a},"getForceKillAfterTimeout"),nTt=t((a,s)=>{a.kill()&&(s.isCanceled=!0)},"spawnedCancel"),kwr=t((a,s,l)=>{a.kill(s),l(Object.assign(new Error("Timed out"),{timedOut:!0,signal:s}))},"timeoutKill"),iTt=t((a,{timeout:s,killSignal:l="SIGTERM"},_)=>{if(s===0||s===void 0)return _;let m,b=new Promise((A,M)=>{m=setTimeout(()=>{kwr(a,l,M)},s)}),D=_.finally(()=>{clearTimeout(m)});return Promise.race([b,D])},"setupTimeout"),sTt=t(({timeout:a})=>{if(a!==void 0&&(!Number.isFinite(a)||a<0))throw new TypeError(`Expected the \`timeout\` option to be a non-negative integer, got \`${a}\` (${typeof a})`)},"validateTimeout"),aTt=t(async(a,{cleanup:s,detached:l},_)=>{if(!s||l)return _;let m=(0,tTt.default)(()=>{a.kill()});return _.finally(()=>{m()})},"setExitHandler");function oTt(a){return a!==null&&typeof a=="object"&&typeof a.pipe=="function"}t(oTt,"isStream");var K5e=S_(uTt(),1),pTt=S_(_Tt(),1);var dTt=t((a,s)=>{s===void 0||a.stdin===void 0||(oTt(s)?s.pipe(a.stdin):a.stdin.end(s))},"handleInput"),mTt=t((a,{all:s})=>{if(!s||!a.stdout&&!a.stderr)return;let l=(0,pTt.default)();return a.stdout&&l.add(a.stdout),a.stderr&&l.add(a.stderr),l},"makeAllStream"),H5e=t(async(a,s)=>{if(a){a.destroy();try{return await s}catch(l){return l.bufferedData}}},"getBufferedData"),G5e=t((a,{encoding:s,buffer:l,maxBuffer:_})=>{if(!(!a||!l))return s?(0,K5e.default)(a,{encoding:s,maxBuffer:_}):K5e.default.buffer(a,{maxBuffer:_})},"getStreamPromise"),hTt=t(async({stdout:a,stderr:s,all:l},{encoding:_,buffer:m,maxBuffer:b},D)=>{let A=G5e(a,{encoding:_,buffer:m,maxBuffer:b}),M=G5e(s,{encoding:_,buffer:m,maxBuffer:b}),U=G5e(l,{encoding:_,buffer:m,maxBuffer:b*2});try{return await Promise.all([D,A,M,U])}catch(ie){return Promise.all([{error:ie,signal:ie.signal,timedOut:ie.timedOut},H5e(a,A),H5e(s,M),H5e(l,U)])}},"getSpawnedResult");var Lwr=(async()=>{})().constructor.prototype,Rwr=["then","catch","finally"].map(a=>[a,Reflect.getOwnPropertyDescriptor(Lwr,a)]),Y5e=t((a,s)=>{for(let[l,_]of Rwr){let m=typeof s=="function"?(...b)=>Reflect.apply(_.value,s(),b):_.value.bind(s);Reflect.defineProperty(a,l,{..._,value:m})}return a},"mergePromise"),gTt=t(a=>new Promise((s,l)=>{a.on("exit",(_,m)=>{s({exitCode:_,signal:m})}),a.on("error",_=>{l(_)}),a.stdin&&a.stdin.on("error",_=>{l(_)})}),"getSpawnedPromise");var yTt=t((a,s=[])=>Array.isArray(s)?[a,...s]:[a],"normalizeArgs"),Mwr=/^[\w.-]+$/,jwr=/"/g,Bwr=t(a=>typeof a!="string"||Mwr.test(a)?a:`"${a.replace(jwr,'\\"')}"`,"escapeArg"),vTt=t((a,s)=>yTt(a,s).join(" "),"joinCommand"),bTt=t((a,s)=>yTt(a,s).map(l=>Bwr(l)).join(" "),"getEscapedCommand");var Jwr=1e3*1e3*100,zwr=t(({env:a,extendEnv:s,preferLocal:l,localDir:_,execPath:m})=>{let b=s?{...Npe.env,...a}:a;return l?$St({env:b,cwd:_,execPath:m}):b},"getEnv"),qwr=t((a,s,l={})=>{let _=TTt.default._parse(a,s,l);return a=_.command,s=_.args,l=_.options,l={maxBuffer:Jwr,buffer:!0,stripFinalNewline:!0,extendEnv:!0,preferLocal:!1,localDir:l.cwd||Npe.cwd(),execPath:Npe.execPath,encoding:"utf8",reject:!0,cleanup:!0,all:!1,windowsHide:!0,...l},l.env=zwr(l),l.stdio=GSt(l),Npe.platform==="win32"&&$wr.basename(a,".exe")==="cmd"&&s.unshift("/q"),{file:a,args:s,options:l,parsed:_}},"handleArguments"),X5e=t((a,s,l)=>typeof s!="string"&&!Uwr.isBuffer(s)?l===void 0?void 0:"":a.stripFinalNewline?B5e(s):s,"handleOutput");function xTt(a,s,l){let _=qwr(a,s,l),m=vTt(a,s),b=bTt(a,s);sTt(_.options);let D;try{D=STt.spawn(_.file,_.args,_.options)}catch(Re){let Pe=new STt.ChildProcess,ke=Promise.reject(z5e({error:Re,stdout:"",stderr:"",all:"",command:m,escapedCommand:b,parsed:_,timedOut:!1,isCanceled:!1,killed:!1}));return Y5e(Pe,ke)}let A=gTt(D),M=iTt(D,_.options,A),U=aTt(D,_.options,M),ie={isCanceled:!1};D.kill=rTt.bind(null,D.kill.bind(D)),D.cancel=nTt.bind(null,D,ie);let Z=zSt(t(async()=>{let[{error:Re,exitCode:Pe,signal:ke,timedOut:wt},At,yr,zr]=await hTt(D,_.options,U),en=X5e(_.options,At),hn=X5e(_.options,yr),br=X5e(_.options,zr);if(Re||Pe!==0||ke!==null){let mr=z5e({error:Re,exitCode:Pe,signal:ke,stdout:en,stderr:hn,all:br,command:m,escapedCommand:b,parsed:_,timedOut:wt,isCanceled:ie.isCanceled||(_.options.signal?_.options.signal.aborted:!1),killed:D.killed});if(!_.options.reject)return mr;throw mr}return{command:m,escapedCommand:b,exitCode:0,stdout:en,stderr:hn,all:br,failed:!1,timedOut:!1,isCanceled:!1,killed:!1}},"handlePromise"));return dTt(D,_.options.input),D.all=mTt(D,_.options),Y5e(D,Z)}t(xTt,"execa");import{existsSync as ETt,readFileSync as CTt}from"fs";import Ipe from"path";async function Ope(a,s){if(a.__ZUPLO_LOG_LEVEL=process.env.__ZUPLO_LOG_LEVEL??process.env.LOG_LEVEL,a.__ZUPLO_LOG_FORMAT=process.env.__ZUPLO_LOG_FORMAT??process.env.LOG_FORMAT,a.LOG_LEVEL=process.env.LOG_LEVEL??process.env.LOG_LEVEL,a.LOG_FORMAT=process.env.LOG_FORMAT??process.env.LOG_FORMAT,a.GIT_SHA=process.env.GIT_SHA??await Vwr(s),process.env.__ZUPLO_CONFIG&&(a.__ZUPLO_CONFIG=process.env.__ZUPLO_CONFIG),ETt(Ipe.join(s,".env.zuplo"))){let l=CTt(Ipe.join(s,".env.zuplo"),"utf8"),_=Q5e.default.parse(l);for(let m of Object.keys(_))if(a[m]=_[m],m==="ZUPLO_SYSTEM_CONFIGURATIONS"){let b=Buffer.from(Ele.decode(_[m])).toString(),D=JSON.parse(b);for(let A of Object.keys(D))a[A]=D[A]}}if(ETt(Ipe.join(s,".env"))){let l=CTt(Ipe.join(s,".env"),"utf8"),_=Q5e.default.parse(l);for(let m of Object.keys(_))a[m]=_[m]}for(let l of Object.keys(a))a[l]===void 0&&delete a[l];return a}t(Ope,"setEnvironment");async function Vwr(a){let s="unknown";try{let{stdout:l}=await xTt("git",["rev-parse","HEAD"],{cwd:a});l.trim().length===40&&(s=l.trim())}catch{}return s}t(Vwr,"getGitSha");async function Kwr({buildId:a,output:s,sourceDirectory:l,bundledDir:_,port:m,binaryName:b,publicZuploEnvironmentVariables:D,logger:A,handleRuntimeStdio:M}){if(_){let ie=eY.join(l,_,"modules.json");if(!Wwr(ie))throw new Error("The bundled-dir does not contain a modules.json file.");let se=await Gwr(ie,"utf-8").then(JSON.parse),Z=await qfe(l);return Z.status===yO?new Promise((Re,Pe)=>{U(Z.config.compatibilityDate,eY.join(l,_),se,Re,M)().catch(ke=>{A.error(ke),Pe(ke)})}):(A.warn("Failed to get Zuplo config. Using default compatibility date."),new Promise((Re,Pe)=>{U(void 0,l,se,Re,M)().catch(ke=>{A.error(ke),Pe(ke)})}))}else{let ie=new mF({buildId:a,output:s,sourceDirectory:l,command:"dev",logger:A,publicZuploEnvironmentVariables:D??{ZUPLO_ENVIRONMENT_TYPE:"LOCAL_DEVELOPMENT"}});try{await ie.start()}catch{A.info("Ran into irrecoverable error while building. Fix the error and rerun the command."),process.exit(1)}return new Promise((se,Z)=>{ie.onReload((Re,Pe)=>{(Pe||Re&&Re.errors&&Re.errors.length>0)&&Z(Pe??Re?.errors),U(Re?.compatibilityDate,eY.join(l,"dist"),ij(l,Re?.metafile),se,M)().catch(ke=>{A.error(ke),Z(ke)})})})}function U(ie,se,Z,Re,Pe){return async()=>{let ke={};await Ope(ke,l);let wt=new DTt.ZuploWorkerd({compatibilityDate:ie,scriptDirectory:se,modules:Z,port:m??Ym.DEV_SERVER_PORT,bindings:ke,handleRuntimeStdio:Pe}),At=b??"compiled-zup",yr=eY.join(l,"dist");await Hwr(yr,{recursive:!0}),await wt.compileBinary({binaryPath:eY.join(l,"dist",At)}),await wt.dispose(),Re(void 0)}}t(U,"compile")}t(Kwr,"compileWorkerdServer");var wTt=S_(P5e(),1);import Xwr from"path";import Ywr from"net";function kTt(a,s){return new Promise(l=>{let _=new Ywr.Socket;_.connect(s,a),_.on("connect",()=>{_.destroy(),l(!1)}),_.on("error",()=>{_.destroy(),l(!0)})})}t(kTt,"isPortAvailable");var Fpe=class{static{t(this,"WorkerdServer")}sourceDirectory;port;debugPort;buildWatcher;workerd;logger;output;handleRuntimeStdio;onReload;constructor(s){this.sourceDirectory=s.sourceDirectory,this.port=s.port??Ym.DEV_SERVER_PORT,this.debugPort=s.debugPort,this.logger=s.logger,this.output=s.output,this.handleRuntimeStdio=s.handleRuntimeStdio,this.onReload=s.onReload,s.zupTestMode||(this.buildWatcher=new mF({...s,logger:this.logger,publicZuploEnvironmentVariables:s.publicZuploEnvironmentVariables??{ZUPLO_ENVIRONMENT_TYPE:"LOCAL_DEVELOPMENT"}}),this.buildWatcher.watchEnvFiles())}async start(){if(!await kTt("localhost",this.port))throw new Error(`Port ${this.port} is currently in use. Please use a different port.`);if(this.buildWatcher)try{await this.buildWatcher.start()}catch(l){this.output.error(l.toString());let _="Ran into irrecoverable error while starting watcher. Fix the error and restart the server.";this.output.error(_),this.logger?.info(_),process.exit(1)}await this.startOrReload(),this.buildWatcher?.onReload((l,_)=>{_||l&&l.errors&&l.errors.length>0||(this.onReload(l,_),this.startOrReload(l).catch(m=>{this.output.error(m.toString()),this.logger?.error(m)}))})}async startOrReload(s){try{let l={};await Ope(l,this.sourceDirectory),await this.workerd?.dispose(),this.workerd=new wTt.ZuploWorkerd({compatibilityDate:s?.compatibilityDate,scriptDirectory:Xwr.join(this.sourceDirectory,"dist"),modules:ij(this.sourceDirectory,s?.metafile),port:this.port,inspectorPort:this.debugPort??void 0,bindings:l,handleRuntimeStdio:this.handleRuntimeStdio}),await this.workerd.serve()}catch{}}async stop(){await this.buildWatcher?.close(),await this.workerd?.dispose()}};async function Qwr({sourceDirectory:a,port:s,debugPort:l,publicZuploEnvironmentVariables:_,logger:m,output:b,buildId:D,onReload:A,handleRuntimeStdio:M}){process.env.ZUPLO_IS_LOCAL_DEVELOPMENT="true";let U=new Fpe({sourceDirectory:a,command:"dev",port:s,debugPort:l,publicZuploEnvironmentVariables:_,logger:m,output:b,buildId:D,onReload:A,handleRuntimeStdio:M});await U.start();async function ie(){await U.stop()}t(ie,"handle"),process.on("SIGTERM",ie),process.on("SIGINT",ie)}t(Qwr,"startDevServer");var rxt=S_(NTt(),1),nxt=S_(ext(),1);import{readFile as OPr}from"fs/promises";var NPr=new RegExp("^((https|http)://)?[a-zA-Z0-9]{3}\\.[a-zA-Z0-9][a-zA-Z0-9]{0,61}?[a-zA-Z0-9]\\.(com|net|cn|cc)(:[0-9]{1,4})?/$"),IPr={concat(a,s){let l=a.endsWith("/"),_=s.startsWith("/");return a+(l||_?"":"/")+(l&&_?s.slice(1):s)},resolve(a){return this.isAbsolute(a)?this.normalize(a):this.normalize(this.concat(process.cwd(),a))},normalize(a){let s=[],l=0;return a.split("/").reverse().filter(m=>m!==".").forEach(m=>{m===".."?l++:l===0?s.push(m):l--}),s.reverse().join("/")},isData(a){return a.startsWith("data:")},isURL(a){return NPr.test(a)},isAbsolute(a){return a.startsWith("/")||/^[^/]*:/.test(a)},relativeToFile(a,s){return this.isData(a)||this.isAbsolute(s)?this.normalize(s):this.normalize(this.concat(a.split("/").slice(0,-1).join("/"),s))}},qpe=IPr;var txt=t(a=>{let s=t(l=>l in s.cache?s.cache[l]:s.cache[l]=a(l),"m");return s.forgetEverything=()=>{s.cache=Object.create(null)},s.cache=Object.create(null),s},"memoize");function u9e(a){let s=txt(async D=>await l(D,await a(D)));async function l(D,A){if(A===void 0)return s(qpe.resolve(D));let M,U,ie=t(async Z=>(U=U||await _(se))(Z),"_resolve"),se={path:D,text:A,get lines(){return M=M||A.split(`
637
+ `);return wt?(_.originalMessage=_.message,_.message=yr):_=new Error(yr),_.shortMessage=At,_.command=D,_.escapedCommand=A,_.exitCode=b,_.signal=m,_.signalDescription=Z,_.stdout=a,_.stderr=s,l!==void 0&&(_.all=l),"bufferedData"in _&&delete _.bufferedData,_.failed=!0,_.timedOut=!!M,_.isCanceled=U,_.killed=ie&&!M,_},"makeError");var Cpe=["stdin","stdout","stderr"],bwr=t(a=>Cpe.some(s=>a[s]!==void 0),"hasAlias"),GSt=t(a=>{if(!a)return;let{stdio:s}=a;if(s===void 0)return Cpe.map(_=>a[_]);if(bwr(a))throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${Cpe.map(_=>`\`${_}\``).join(", ")}`);if(typeof s=="string")return s;if(!Array.isArray(s))throw new TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof s}\``);let l=Math.max(s.length,Cpe.length);return Array.from({length:l},(_,m)=>s[m])},"normalizeStdio");var tTt=S_(eTt(),1);import Swr from"os";var Twr=1e3*5,rTt=t((a,s="SIGTERM",l={})=>{let _=a(s);return xwr(a,s,l,_),_},"spawnedKill"),xwr=t((a,s,l,_)=>{if(!Ewr(s,l,_))return;let m=Dwr(l),b=setTimeout(()=>{a("SIGKILL")},m);b.unref&&b.unref()},"setKillTimeout"),Ewr=t((a,{forceKillAfterTimeout:s},l)=>Cwr(a)&&s!==!1&&l,"shouldForceKill"),Cwr=t(a=>a===Swr.constants.signals.SIGTERM||typeof a=="string"&&a.toUpperCase()==="SIGTERM","isSigterm"),Dwr=t(({forceKillAfterTimeout:a=!0})=>{if(a===!0)return Twr;if(!Number.isFinite(a)||a<0)throw new TypeError(`Expected the \`forceKillAfterTimeout\` option to be a non-negative integer, got \`${a}\` (${typeof a})`);return a},"getForceKillAfterTimeout"),nTt=t((a,s)=>{a.kill()&&(s.isCanceled=!0)},"spawnedCancel"),kwr=t((a,s,l)=>{a.kill(s),l(Object.assign(new Error("Timed out"),{timedOut:!0,signal:s}))},"timeoutKill"),iTt=t((a,{timeout:s,killSignal:l="SIGTERM"},_)=>{if(s===0||s===void 0)return _;let m,b=new Promise((A,M)=>{m=setTimeout(()=>{kwr(a,l,M)},s)}),D=_.finally(()=>{clearTimeout(m)});return Promise.race([b,D])},"setupTimeout"),sTt=t(({timeout:a})=>{if(a!==void 0&&(!Number.isFinite(a)||a<0))throw new TypeError(`Expected the \`timeout\` option to be a non-negative integer, got \`${a}\` (${typeof a})`)},"validateTimeout"),aTt=t(async(a,{cleanup:s,detached:l},_)=>{if(!s||l)return _;let m=(0,tTt.default)(()=>{a.kill()});return _.finally(()=>{m()})},"setExitHandler");function oTt(a){return a!==null&&typeof a=="object"&&typeof a.pipe=="function"}t(oTt,"isStream");var K5e=S_(uTt(),1),pTt=S_(_Tt(),1);var dTt=t((a,s)=>{s===void 0||a.stdin===void 0||(oTt(s)?s.pipe(a.stdin):a.stdin.end(s))},"handleInput"),mTt=t((a,{all:s})=>{if(!s||!a.stdout&&!a.stderr)return;let l=(0,pTt.default)();return a.stdout&&l.add(a.stdout),a.stderr&&l.add(a.stderr),l},"makeAllStream"),H5e=t(async(a,s)=>{if(a){a.destroy();try{return await s}catch(l){return l.bufferedData}}},"getBufferedData"),G5e=t((a,{encoding:s,buffer:l,maxBuffer:_})=>{if(!(!a||!l))return s?(0,K5e.default)(a,{encoding:s,maxBuffer:_}):K5e.default.buffer(a,{maxBuffer:_})},"getStreamPromise"),hTt=t(async({stdout:a,stderr:s,all:l},{encoding:_,buffer:m,maxBuffer:b},D)=>{let A=G5e(a,{encoding:_,buffer:m,maxBuffer:b}),M=G5e(s,{encoding:_,buffer:m,maxBuffer:b}),U=G5e(l,{encoding:_,buffer:m,maxBuffer:b*2});try{return await Promise.all([D,A,M,U])}catch(ie){return Promise.all([{error:ie,signal:ie.signal,timedOut:ie.timedOut},H5e(a,A),H5e(s,M),H5e(l,U)])}},"getSpawnedResult");var Lwr=(async()=>{})().constructor.prototype,Rwr=["then","catch","finally"].map(a=>[a,Reflect.getOwnPropertyDescriptor(Lwr,a)]),Y5e=t((a,s)=>{for(let[l,_]of Rwr){let m=typeof s=="function"?(...b)=>Reflect.apply(_.value,s(),b):_.value.bind(s);Reflect.defineProperty(a,l,{..._,value:m})}return a},"mergePromise"),gTt=t(a=>new Promise((s,l)=>{a.on("exit",(_,m)=>{s({exitCode:_,signal:m})}),a.on("error",_=>{l(_)}),a.stdin&&a.stdin.on("error",_=>{l(_)})}),"getSpawnedPromise");var yTt=t((a,s=[])=>Array.isArray(s)?[a,...s]:[a],"normalizeArgs"),Mwr=/^[\w.-]+$/,jwr=/"/g,Bwr=t(a=>typeof a!="string"||Mwr.test(a)?a:`"${a.replace(jwr,'\\"')}"`,"escapeArg"),vTt=t((a,s)=>yTt(a,s).join(" "),"joinCommand"),bTt=t((a,s)=>yTt(a,s).map(l=>Bwr(l)).join(" "),"getEscapedCommand");var Jwr=1e3*1e3*100,zwr=t(({env:a,extendEnv:s,preferLocal:l,localDir:_,execPath:m})=>{let b=s?{...Npe.env,...a}:a;return l?$St({env:b,cwd:_,execPath:m}):b},"getEnv"),qwr=t((a,s,l={})=>{let _=TTt.default._parse(a,s,l);return a=_.command,s=_.args,l=_.options,l={maxBuffer:Jwr,buffer:!0,stripFinalNewline:!0,extendEnv:!0,preferLocal:!1,localDir:l.cwd||Npe.cwd(),execPath:Npe.execPath,encoding:"utf8",reject:!0,cleanup:!0,all:!1,windowsHide:!0,...l},l.env=zwr(l),l.stdio=GSt(l),Npe.platform==="win32"&&$wr.basename(a,".exe")==="cmd"&&s.unshift("/q"),{file:a,args:s,options:l,parsed:_}},"handleArguments"),X5e=t((a,s,l)=>typeof s!="string"&&!Uwr.isBuffer(s)?l===void 0?void 0:"":a.stripFinalNewline?B5e(s):s,"handleOutput");function xTt(a,s,l){let _=qwr(a,s,l),m=vTt(a,s),b=bTt(a,s);sTt(_.options);let D;try{D=STt.spawn(_.file,_.args,_.options)}catch(Re){let Pe=new STt.ChildProcess,ke=Promise.reject(z5e({error:Re,stdout:"",stderr:"",all:"",command:m,escapedCommand:b,parsed:_,timedOut:!1,isCanceled:!1,killed:!1}));return Y5e(Pe,ke)}let A=gTt(D),M=iTt(D,_.options,A),U=aTt(D,_.options,M),ie={isCanceled:!1};D.kill=rTt.bind(null,D.kill.bind(D)),D.cancel=nTt.bind(null,D,ie);let Z=zSt(t(async()=>{let[{error:Re,exitCode:Pe,signal:ke,timedOut:wt},At,yr,zr]=await hTt(D,_.options,U),en=X5e(_.options,At),hn=X5e(_.options,yr),br=X5e(_.options,zr);if(Re||Pe!==0||ke!==null){let mr=z5e({error:Re,exitCode:Pe,signal:ke,stdout:en,stderr:hn,all:br,command:m,escapedCommand:b,parsed:_,timedOut:wt,isCanceled:ie.isCanceled||(_.options.signal?_.options.signal.aborted:!1),killed:D.killed});if(!_.options.reject)return mr;throw mr}return{command:m,escapedCommand:b,exitCode:0,stdout:en,stderr:hn,all:br,failed:!1,timedOut:!1,isCanceled:!1,killed:!1}},"handlePromise"));return dTt(D,_.options.input),D.all=mTt(D,_.options),Y5e(D,Z)}t(xTt,"execa");import{existsSync as ETt,readFileSync as CTt}from"fs";import Ipe from"path";async function Ope(a,s){if(a.__ZUPLO_LOG_LEVEL=process.env.__ZUPLO_LOG_LEVEL??process.env.LOG_LEVEL,a.__ZUPLO_LOG_FORMAT=process.env.__ZUPLO_LOG_FORMAT??process.env.LOG_FORMAT,a.LOG_LEVEL=process.env.LOG_LEVEL??process.env.LOG_LEVEL,a.LOG_FORMAT=process.env.LOG_FORMAT??process.env.LOG_FORMAT,a.GIT_SHA=process.env.GIT_SHA??await Vwr(s),process.env.__ZUPLO_CONFIG&&(a.__ZUPLO_CONFIG=process.env.__ZUPLO_CONFIG),ETt(Ipe.join(s,".env.zuplo"))){let l=CTt(Ipe.join(s,".env.zuplo"),"utf8"),_=Q5e.default.parse(l);for(let m of Object.keys(_))if(a[m]=_[m],m==="ZUPLO_SYSTEM_CONFIGURATIONS"){let b=Buffer.from(Ele.decode(_[m])).toString(),D=JSON.parse(b);for(let A of Object.keys(D))a[A]=D[A]}}if(ETt(Ipe.join(s,".env"))){let l=CTt(Ipe.join(s,".env"),"utf8"),_=Q5e.default.parse(l);for(let m of Object.keys(_))a[m]=_[m]}for(let l of Object.keys(a))a[l]===void 0&&delete a[l];return a}t(Ope,"setEnvironment");async function Vwr(a){let s="unknown";try{let{stdout:l}=await xTt("git",["rev-parse","HEAD"],{cwd:a});l.trim().length===40&&(s=l.trim())}catch{}return s}t(Vwr,"getGitSha");async function Kwr({buildId:a,output:s,sourceDirectory:l,bundledDir:_,port:m,binaryName:b,publicZuploEnvironmentVariables:D,logger:A,handleRuntimeStdio:M}){if(_){let ie=eY.join(l,_,"modules.json");if(!Wwr(ie))throw new Error("The bundled-dir does not contain a modules.json file.");let se=await Gwr(ie,"utf-8").then(JSON.parse),Z=await qfe(l);return Z.status===yO?new Promise((Re,Pe)=>{U(Z.config.compatibilityDate,eY.join(l,_),se,Re,M)().catch(ke=>{A.error(ke),Pe(ke)})}):(A.warn("Failed to get Zuplo config. Using default compatibility date."),new Promise((Re,Pe)=>{U(void 0,l,se,Re,M)().catch(ke=>{A.error(ke),Pe(ke)})}))}else{let ie=new mF({buildId:a,output:s,sourceDirectory:l,command:"dev",logger:A,publicZuploEnvironmentVariables:D??{ZUPLO_ENVIRONMENT_TYPE:"LOCAL_DEVELOPMENT"}});try{await ie.start()}catch{A.info("Ran into irrecoverable error while building. Fix the error and rerun the command."),process.exit(1)}return new Promise((se,Z)=>{ie.onReload((Re,Pe)=>{(Pe||Re&&Re.errors&&Re.errors.length>0)&&Z(Pe??Re?.errors),U(Re?.compatibilityDate,eY.join(l,"dist"),ij(l,Re?.metafile),se,M)().catch(ke=>{A.error(ke),Z(ke)})})})}function U(ie,se,Z,Re,Pe){return async()=>{let ke={};await Ope(ke,l);let wt=new DTt.ZuploWorkerd({compatibilityDate:ie,scriptDirectory:se,modules:Z,port:m??Ym.DEV_SERVER_PORT,bindings:ke,handleRuntimeStdio:Pe}),At=b??"compiled-zup",yr=eY.join(l,"dist");await Hwr(yr,{recursive:!0}),await wt.compileBinary({binaryPath:eY.join(l,"dist",At)}),await wt.dispose(),Re(void 0)}}t(U,"compile")}t(Kwr,"compileWorkerdServer");var wTt=S_(P5e(),1);import Xwr from"path";import Ywr from"net";function kTt(a,s){return new Promise(l=>{let _=new Ywr.Socket;_.connect(s,a),_.on("connect",()=>{_.destroy(),l(!1)}),_.on("error",()=>{_.destroy(),l(!0)})})}t(kTt,"isPortAvailable");var Fpe=class{static{t(this,"WorkerdServer")}sourceDirectory;port;debugPort;buildWatcher;workerd;logger;output;handleRuntimeStdio;onReload;constructor(s){this.sourceDirectory=s.sourceDirectory,this.port=s.port??Ym.DEV_SERVER_PORT,this.debugPort=s.debugPort,this.logger=s.logger,this.output=s.output,this.handleRuntimeStdio=s.handleRuntimeStdio,this.onReload=s.onReload,s.zupTestMode||(this.buildWatcher=new mF({...s,logger:this.logger,publicZuploEnvironmentVariables:s.publicZuploEnvironmentVariables??{ZUPLO_ENVIRONMENT_TYPE:"LOCAL_DEVELOPMENT"}}),this.buildWatcher.watchEnvFiles())}async start(){if(!await kTt("localhost",this.port))throw new Error(`Port ${this.port} is currently in use. Please use a different port.`);if(this.buildWatcher)try{await this.buildWatcher.start()}catch(l){this.output.child("api").error(l.toString());let _="Ran into irrecoverable error while starting watcher. Fix the error and restart the server.";this.output.child("api").error(_),this.logger?.info(_),process.exit(1)}await this.startOrReload(),this.buildWatcher?.onReload((l,_)=>{_||l&&l.errors&&l.errors.length>0||(this.onReload(l,_),this.startOrReload(l).catch(m=>{this.output.child("api").error(m.toString()),this.logger?.error(m)}))})}async startOrReload(s){try{let l={};await Ope(l,this.sourceDirectory),await this.workerd?.dispose(),this.workerd=new wTt.ZuploWorkerd({compatibilityDate:s?.compatibilityDate,scriptDirectory:Xwr.join(this.sourceDirectory,"dist"),modules:ij(this.sourceDirectory,s?.metafile),port:this.port,inspectorPort:this.debugPort??void 0,bindings:l,handleRuntimeStdio:this.handleRuntimeStdio}),await this.workerd.serve()}catch{}}async stop(){await this.buildWatcher?.close(),await this.workerd?.dispose()}};async function Qwr({sourceDirectory:a,port:s,debugPort:l,publicZuploEnvironmentVariables:_,logger:m,output:b,buildId:D,onReload:A,handleRuntimeStdio:M}){process.env.ZUPLO_IS_LOCAL_DEVELOPMENT="true";let U=new Fpe({sourceDirectory:a,command:"dev",port:s,debugPort:l,publicZuploEnvironmentVariables:_,logger:m,output:b,buildId:D,onReload:A,handleRuntimeStdio:M});await U.start();async function ie(){await U.stop()}t(ie,"handle"),process.on("SIGTERM",ie),process.on("SIGINT",ie)}t(Qwr,"startDevServer");var rxt=S_(NTt(),1),nxt=S_(ext(),1);import{readFile as OPr}from"fs/promises";var NPr=new RegExp("^((https|http)://)?[a-zA-Z0-9]{3}\\.[a-zA-Z0-9][a-zA-Z0-9]{0,61}?[a-zA-Z0-9]\\.(com|net|cn|cc)(:[0-9]{1,4})?/$"),IPr={concat(a,s){let l=a.endsWith("/"),_=s.startsWith("/");return a+(l||_?"":"/")+(l&&_?s.slice(1):s)},resolve(a){return this.isAbsolute(a)?this.normalize(a):this.normalize(this.concat(process.cwd(),a))},normalize(a){let s=[],l=0;return a.split("/").reverse().filter(m=>m!==".").forEach(m=>{m===".."?l++:l===0?s.push(m):l--}),s.reverse().join("/")},isData(a){return a.startsWith("data:")},isURL(a){return NPr.test(a)},isAbsolute(a){return a.startsWith("/")||/^[^/]*:/.test(a)},relativeToFile(a,s){return this.isData(a)||this.isAbsolute(s)?this.normalize(s):this.normalize(this.concat(a.split("/").slice(0,-1).join("/"),s))}},qpe=IPr;var txt=t(a=>{let s=t(l=>l in s.cache?s.cache[l]:s.cache[l]=a(l),"m");return s.forgetEverything=()=>{s.cache=Object.create(null)},s.cache=Object.create(null),s},"memoize");function u9e(a){let s=txt(async D=>await l(D,await a(D)));async function l(D,A){if(A===void 0)return s(qpe.resolve(D));let M,U,ie=t(async Z=>(U=U||await _(se))(Z),"_resolve"),se={path:D,text:A,get lines(){return M=M||A.split(`
638
638
  `)},async resolve(Z){try{return await ie(Z)}catch(Re){return Object.assign({},Z,{error:Re})}},_resolve:ie};return se}t(l,"SourceFile");async function _(D){let A=/\u0023 sourceMappingURL=(.+)\n?/g,M;for(;;){let se=A.exec(D.text);if(se)M=se;else break}let U=M&&M[1],ie=t(async se=>Object.assign({},se,{sourceFile:D,sourceLine:D.lines[se.line-1]||""}),"defaultResolver");return U?await m(D.path,U,ie):ie}t(_,"SourceMapResolverFromFetchedFile");async function m(D,A,M){let U=A.startsWith("data:")?await l(D,(0,rxt.dataUriToBuffer)(A).toString()):await l(qpe.relativeToFile(D,A)),ie=await new nxt.SourceMapConsumer(JSON.parse(U.text)),se=txt(async Z=>{let Re=qpe.relativeToFile(U.path,Z),Pe=ie.sourceContentFor(Z,!0)||void 0;return await l(Re,Pe)});return async Z=>{try{let Re=ie.originalPositionFor(Z);return Re.source?await(await se(Re.source))._resolve(Object.assign({},Z,{line:Re.line,column:(Re.column??0)+1,name:Re.name})):M(Z)}catch(Re){return Object.assign(M(Z),{sourceMapError:Re})}}}t(m,"SourceMapResolver");let b=t(async function(A){try{return await l(A)}catch(M){let U={path:A,text:"",lines:[],error:M,async resolve(ie){return Object.assign({},ie,{error:M,sourceLine:"",sourceFile:U})},_resolve(ie){return this.resolve(ie)}};return U}},"getSource");return b.resetCache=()=>s.forgetEverything(),b.getCache=()=>s.cache,b}t(u9e,"buildGetSourceFunction");var FPr=t(async a=>OPr(a,{encoding:"utf8"}),"fetchFile"),ixt=u9e(FPr);import LPr from"path";import RPr from"util";var sxt=t(a=>a[a.length-1],"lastOf"),aY=t(a=>a.replace(/\\/g,"/"),"nixSlashes"),MPr=t((a,s)=>{let l=a||[],_=[],m={label:void 0,items:[l[0]]};return l.forEach(b=>{let D=s(b);m.label!==D&&m.items.length?_.push(m={label:D,items:[b]}):m.items.push(b)}),_},"partition"),oY=class a{static{t(this,"StackTracey")}items;getSource;pathRoot;constructor(s,{offset:l,getSource:_}){this.getSource=_,this.pathRoot=`${aY(process.cwd())}/`;let m=s,b=s instanceof SyntaxError;if(l=l||0,s instanceof Error&&(s=s.stack||""),typeof s=="string"&&(s=this.rawParse(s).slice(l).map(D=>this.extractEntryMetadata(D))),Array.isArray(s)){if(b){let D=RPr.inspect(m).split(`
639
639
  `),A=D[0].split(":"),M=A.pop(),U=A.join(":");U&&s.unshift({file:aY(U),line:parseInt(M||"0",10),column:(D[2]||"").indexOf("^")+1,sourceLine:D[1],callee:"(syntax error)",syntaxError:!0,beforeParse:"",index:!1,native:!1,calleeShort:"",fileRelative:"",fileShort:"",fileName:"",thirdParty:!1})}this.items=s}else this.items=[]}extractEntryMetadata(s){let l=this.decomposePath(s.file||""),_=l[0],m=l[1];return Object.assign(s,{calleeShort:s.calleeShort||sxt((s.callee||"").split(".")),fileRelative:_,fileShort:this.shortenPath(_),fileName:sxt((s.file||"").split("/")),thirdParty:this.isThirdParty(_,m)&&!s.index,externalDomain:m})}shortenPath(s){return s.replace(/^node_modules\//,"").replace(/^webpack\/bootstrap\//,"").replace(/^__parcel_source_root\//,"")}decomposePath(s){let l=s,_=l.match(/^(http|https):\/\/([^\/]+)\/(.*)/),m=_?_[2]:void 0;return l=_?_[3]:l,l=LPr.relative(this.pathRoot,l),[aY(l).replace(/^.*:\/\/?\/?/,""),m]}isThirdParty(s,l){return!!l||s[0]==="~"||s[0]==="/"||s.indexOf("node_modules")===0||s.indexOf("webpack/bootstrap")===0}rawParse(s){return(s||"").split(`
640
640
  `).map(m=>{m=m.trim();let b,D=[],A,M,U;if((M=m.match(/at (.+) \(eval at .+ \((.+)\), .+\)/))||(M=m.match(/at (.+) \((.+)\)/))||m.slice(0,3)!=="at "&&(M=m.match(/(.*)@(.*)/)))b=M[1],A=M[2]==="native",D=(M[2].match(/(.*):(\d+):(\d+)/)||M[2].match(/(.*):(\d+)/)||[]).slice(1);else if(U=m.match(/^(at\s+)*(.+):(\d+):(\d+)/))D=U.slice(2);else return;return b&&!D[0]&&b.split(".")[0]==="Array"&&(A=!0),{beforeParse:m,callee:b||"",index:D[0]==="/",native:A||!1,file:aY(D[0]||""),line:parseInt(D[1]||"",10)||void 0,column:parseInt(D[2]||"",10)||void 0,calleeShort:"",fileRelative:"",fileShort:"",fileName:"",thirdParty:!1}}).filter(m=>m!==void 0)}async withSourceAsyncAt(s){return this.items[s]&&this.withSourceAsync(this.items[s])}async withSourceAsync(s){if(this.shouldSkipResolving(s))return s;{let l=(s.file||"").replace("file://","");try{let m=await(await this.getSource(l)).resolve(s);return this.withSourceResolved(s,m)}catch(_){return this.withSourceResolved(s,{error:_,sourceLine:""})}}}shouldSkipResolving(s){return!!s.sourceFile||!!s.error||!!s.file&&s.file.indexOf("<")>=0}withSourceResolved(s,l){return l.sourceFile&&!l.sourceFile.error&&(l.file=aY(l.sourceFile.path),l=this.extractEntryMetadata(l)),l.sourceLine?.includes("// @hide")&&(l.sourceLine=l.sourceLine.replace("// @hide",""),l.hide=!0),(l.sourceLine?.includes("__webpack_require__")||l.sourceLine?.includes("/******/ ({"))&&(l.thirdParty=!0),Object.assign({sourceLine:""},s,l)}async withSourcesAsync(){let s=await Promise.all(this.items.map(l=>this.withSourceAsync(l)));return new a(s,{getSource:this.getSource})}mergeRepeatedLines(){return new a(MPr(this.items,s=>s.file+s.line).map(s=>s.items.slice(1).reduce((l,_)=>(l.callee=(l.callee||"<anonymous>")+" \u2192 "+(_.callee||"<anonymous>"),l.calleeShort=(l.calleeShort||"<anonymous>")+" \u2192 "+(_.calleeShort||"<anonymous>"),l),Object.assign({},s.items[0]))),{getSource:this.getSource})}async cleanAsync(){let s=await this.withSourcesAsync();return s.mergeRepeatedLines().filter((l,_)=>s.isClean(l,_))}isClean(s,l){return l===0||!(s.thirdParty||s.hide||s.native)}at(s){return Object.assign({beforeParse:"",callee:"<???>",index:!1,native:!1,file:"<???>",line:0,column:0},this.items[s])}map(s,l){return new a(this.items.map(s,l),{getSource:this.getSource})}filter(s,l){return new a(this.items.filter(s,l),{getSource:this.getSource})}slice(s,l){return new a(this.items.slice(s,l),{getSource:this.getSource})}concat(...s){return new a(this.items.concat(...s),{getSource:this.getSource})}maxColumnWidths(){return{callee:30,file:60,sourceLine:80}}static locationsEqual(s,l){return s.file===l.file&&s.line===l.line&&s.column===l.column}};import{relative as zPr}from"path";import{fileURLToPath as qPr}from"url";import{inspect as VPr}from"util";function f9e({onlyFirst:a=!1}={}){let l=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");return new RegExp(l,a?void 0:"g")}t(f9e,"ansiRegex");var jPr=f9e();function _9e(a){if(typeof a!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof a}\``);return a.replace(jPr,"")}t(_9e,"stripAnsi");function axt(a){return a===161||a===164||a===167||a===168||a===170||a===173||a===174||a>=176&&a<=180||a>=182&&a<=186||a>=188&&a<=191||a===198||a===208||a===215||a===216||a>=222&&a<=225||a===230||a>=232&&a<=234||a===236||a===237||a===240||a===242||a===243||a>=247&&a<=250||a===252||a===254||a===257||a===273||a===275||a===283||a===294||a===295||a===299||a>=305&&a<=307||a===312||a>=319&&a<=322||a===324||a>=328&&a<=331||a===333||a===338||a===339||a===358||a===359||a===363||a===462||a===464||a===466||a===468||a===470||a===472||a===474||a===476||a===593||a===609||a===708||a===711||a>=713&&a<=715||a===717||a===720||a>=728&&a<=731||a===733||a===735||a>=768&&a<=879||a>=913&&a<=929||a>=931&&a<=937||a>=945&&a<=961||a>=963&&a<=969||a===1025||a>=1040&&a<=1103||a===1105||a===8208||a>=8211&&a<=8214||a===8216||a===8217||a===8220||a===8221||a>=8224&&a<=8226||a>=8228&&a<=8231||a===8240||a===8242||a===8243||a===8245||a===8251||a===8254||a===8308||a===8319||a>=8321&&a<=8324||a===8364||a===8451||a===8453||a===8457||a===8467||a===8470||a===8481||a===8482||a===8486||a===8491||a===8531||a===8532||a>=8539&&a<=8542||a>=8544&&a<=8555||a>=8560&&a<=8569||a===8585||a>=8592&&a<=8601||a===8632||a===8633||a===8658||a===8660||a===8679||a===8704||a===8706||a===8707||a===8711||a===8712||a===8715||a===8719||a===8721||a===8725||a===8730||a>=8733&&a<=8736||a===8739||a===8741||a>=8743&&a<=8748||a===8750||a>=8756&&a<=8759||a===8764||a===8765||a===8776||a===8780||a===8786||a===8800||a===8801||a>=8804&&a<=8807||a===8810||a===8811||a===8814||a===8815||a===8834||a===8835||a===8838||a===8839||a===8853||a===8857||a===8869||a===8895||a===8978||a>=9312&&a<=9449||a>=9451&&a<=9547||a>=9552&&a<=9587||a>=9600&&a<=9615||a>=9618&&a<=9621||a===9632||a===9633||a>=9635&&a<=9641||a===9650||a===9651||a===9654||a===9655||a===9660||a===9661||a===9664||a===9665||a>=9670&&a<=9672||a===9675||a>=9678&&a<=9681||a>=9698&&a<=9701||a===9711||a===9733||a===9734||a===9737||a===9742||a===9743||a===9756||a===9758||a===9792||a===9794||a===9824||a===9825||a>=9827&&a<=9829||a>=9831&&a<=9834||a===9836||a===9837||a===9839||a===9886||a===9887||a===9919||a>=9926&&a<=9933||a>=9935&&a<=9939||a>=9941&&a<=9953||a===9955||a===9960||a===9961||a>=9963&&a<=9969||a===9972||a>=9974&&a<=9977||a===9979||a===9980||a===9982||a===9983||a===10045||a>=10102&&a<=10111||a>=11094&&a<=11097||a>=12872&&a<=12879||a>=57344&&a<=63743||a>=65024&&a<=65039||a===65533||a>=127232&&a<=127242||a>=127248&&a<=127277||a>=127280&&a<=127337||a>=127344&&a<=127373||a===127375||a===127376||a>=127387&&a<=127404||a>=917760&&a<=917999||a>=983040&&a<=1048573||a>=1048576&&a<=1114109}t(axt,"isAmbiguous");function oxt(a){return a===12288||a>=65281&&a<=65376||a>=65504&&a<=65510}t(oxt,"isFullWidth");function cxt(a){return a>=4352&&a<=4447||a===8986||a===8987||a===9001||a===9002||a>=9193&&a<=9196||a===9200||a===9203||a===9725||a===9726||a===9748||a===9749||a>=9800&&a<=9811||a===9855||a===9875||a===9889||a===9898||a===9899||a===9917||a===9918||a===9924||a===9925||a===9934||a===9940||a===9962||a===9970||a===9971||a===9973||a===9978||a===9981||a===9989||a===9994||a===9995||a===10024||a===10060||a===10062||a>=10067&&a<=10069||a===10071||a>=10133&&a<=10135||a===10160||a===10175||a===11035||a===11036||a===11088||a===11093||a>=11904&&a<=11929||a>=11931&&a<=12019||a>=12032&&a<=12245||a>=12272&&a<=12287||a>=12289&&a<=12350||a>=12353&&a<=12438||a>=12441&&a<=12543||a>=12549&&a<=12591||a>=12593&&a<=12686||a>=12688&&a<=12771||a>=12783&&a<=12830||a>=12832&&a<=12871||a>=12880&&a<=19903||a>=19968&&a<=42124||a>=42128&&a<=42182||a>=43360&&a<=43388||a>=44032&&a<=55203||a>=63744&&a<=64255||a>=65040&&a<=65049||a>=65072&&a<=65106||a>=65108&&a<=65126||a>=65128&&a<=65131||a>=94176&&a<=94180||a===94192||a===94193||a>=94208&&a<=100343||a>=100352&&a<=101589||a>=101632&&a<=101640||a>=110576&&a<=110579||a>=110581&&a<=110587||a===110589||a===110590||a>=110592&&a<=110882||a===110898||a>=110928&&a<=110930||a===110933||a>=110948&&a<=110951||a>=110960&&a<=111355||a===126980||a===127183||a===127374||a>=127377&&a<=127386||a>=127488&&a<=127490||a>=127504&&a<=127547||a>=127552&&a<=127560||a===127568||a===127569||a>=127584&&a<=127589||a>=127744&&a<=127776||a>=127789&&a<=127797||a>=127799&&a<=127868||a>=127870&&a<=127891||a>=127904&&a<=127946||a>=127951&&a<=127955||a>=127968&&a<=127984||a===127988||a>=127992&&a<=128062||a===128064||a>=128066&&a<=128252||a>=128255&&a<=128317||a>=128331&&a<=128334||a>=128336&&a<=128359||a===128378||a===128405||a===128406||a===128420||a>=128507&&a<=128591||a>=128640&&a<=128709||a===128716||a>=128720&&a<=128722||a>=128725&&a<=128727||a>=128732&&a<=128735||a===128747||a===128748||a>=128756&&a<=128764||a>=128992&&a<=129003||a===129008||a>=129292&&a<=129338||a>=129340&&a<=129349||a>=129351&&a<=129535||a>=129648&&a<=129660||a>=129664&&a<=129672||a>=129680&&a<=129725||a>=129727&&a<=129733||a>=129742&&a<=129755||a>=129760&&a<=129768||a>=129776&&a<=129784||a>=131072&&a<=196605||a>=196608&&a<=262141}t(cxt,"isWide");function BPr(a){if(!Number.isSafeInteger(a))throw new TypeError(`Expected a code point, got \`${typeof a}\`.`)}t(BPr,"validate");function lxt(a,{ambiguousAsWide:s=!1}={}){return BPr(a),oxt(a)||cxt(a)||s&&axt(a)?2:1}t(lxt,"eastAsianWidth");var _xt=S_(fxt(),1);var UPr=new Intl.Segmenter,$Pr=/^\p{Default_Ignorable_Code_Point}$/u;function Vpe(a,s={}){if(typeof a!="string"||a.length===0)return 0;let{ambiguousIsNarrow:l=!0,countAnsiEscapeCodes:_=!1}=s;if(_||(a=_9e(a)),a.length===0)return 0;let m=0,b={ambiguousAsWide:!l};for(let{segment:D}of UPr.segment(a)){let A=D.codePointAt(0);if(!(A<=31||A>=127&&A<=159)&&!(A>=8203&&A<=8207||A===65279)&&!(A>=768&&A<=879||A>=6832&&A<=6911||A>=7616&&A<=7679||A>=8400&&A<=8447||A>=65056&&A<=65071)&&!(A>=55296&&A<=57343)&&!(A>=65024&&A<=65039)&&!$Pr.test(D)){if((0,_xt.default)().test(D)){m+=2;continue}m+=lxt(A,b)}}return m}t(Vpe,"stringWidth");var m9e=S_(dxt(),1);var{platform:mxt,cwd:JPr}=process,{red:vB,yellow:hxt,green:Hpe,cyan:cY,dim:p9e}=T_,gxt=process.stdout.columns,WPr=mxt==="win32"&&!process.env.WT_SESSION?">":"\u276F",HPr=(mxt==="win32"&&!process.env.WT_SESSION,"\u2043"),GPr=JPr();function yxt(a){return a=a.replace("async file:","file:"),zPr(GPr,a.startsWith("file:")?qPr(a):a)}t(yxt,"getRelativePath");function KPr(a){return a.find(s=>s.isApp)||null}t(KPr,"mainFrame");function YPr(a,s){return a.filter(l=>(l.isApp||l.isModule)&&(!s||l.file!==s.file||l.line!==s.line))}t(YPr,"filterNativeFrames");function vxt(a){return a.callee||"anonymous"}t(vxt,"frameMethod");function bxt(a,s){let l="",_=a.length-s.length;for(let m=0;m<=_;m++)l+=" ";return l}t(bxt,"whiteSpace");function d9e(a,s,l,_,m){let b=bxt(String(l),String(s));return _?`${m}${vB(WPr)}${b}${vB(s)}${vB("|")}${b} ${vB(a)}`:`${m} ${b}${p9e(s)}${p9e("|")}${b} ${p9e(a)}`}t(d9e,"codeLine");function XPr(a,s,l){let _,m=(0,m9e.default)(Vpe(s)+2,gxt);return l?_=`${s} ${vB(m(`${a.message}`).trim())}`:_=`${s} ${vB(m(`${a.name}: ${a.message}`).trim())}`,[_,s]}t(XPr,"getMessage");function QPr(a,s){let l=a.help;if(!l)return[];let _=(0,m9e.default)(Vpe(s)+4,gxt);return Array.isArray(l)?l.map(m=>`${s} ${cY(_(`- ${m}`).trim())}`).concat([s]):[`${s} ${cY(l)}`,s]}t(QPr,"getHelpText");function ZPr(a,s,l){if(!a)return[];let _=l?yxt(a.filePath):a.filePath;return[`${s} at ${hxt(`${vxt(a)}`)} ${Hpe(_)}:${Hpe(a.line)}`]}t(ZPr,"getMainFrameLocation");function eAr(a,s){if(!a||!a.context||!a.context.line)return[];let l=a.context.start-1,_=a.context.pre.split(`