@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/customer.cli.minified.js +6 -6
- package/index.minified.js +9 -9
- package/package.json +4 -4
package/customer.cli.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 Rat(this.pattern,this.options)}parse(s){hH(s);let l=this.options;if(s==="**")return F0;if(s==="")return"";let _,m=null;(_=s.match(NQt))?m=l.dot?OQt:IQt:(_=s.match(SQt))?m=(l.nocase?l.dot?CQt:EQt:l.dot?xQt:TQt)(_[1]):(_=s.match(FQt))?m=(l.nocase?l.dot?RQt:LQt:l.dot?MQt:jQt)(_):(_=s.match(DQt))?m=l.dot?wQt:kQt:(_=s.match(PQt))&&(m=AQt);let b=XR.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?$Qt:l.dot?JQt:zQt,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"?GQt(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=XR;j1.Minimatch=B2;j1.escape=QR;j1.unescape=DE;import{fileURLToPath as DZt}from"url";var ZR=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,jat=new Set,t6e=typeof process=="object"&&process?process:{},Bat=t((a,s,l,_)=>{typeof t6e.emitWarning=="function"?t6e.emitWarning(a,s,l,_):console.error(`[${l}] ${s}: ${a}`)},"emitWarning"),Cce=globalThis.AbortController,Mat=globalThis.AbortSignal;if(typeof Cce>"u"){Mat=class{static{t(this,"AbortSignal")}onabort;_onabort=[];reason;aborted=!1;addEventListener(_,m){this._onabort.push(m)}},Cce=class{static{t(this,"AbortController")}constructor(){s()}signal=new Mat;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=t6e.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",s=t(()=>{a&&(a=!1,Bat("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 KQt=t(a=>!jat.has(a),"shouldWarn"),U6r=Symbol("type"),Z4=t(a=>a&&a===Math.floor(a)&&a>0&&isFinite(a),"isPosInt"),Uat=t(a=>Z4(a)?a<=Math.pow(2,8)?Uint8Array:a<=Math.pow(2,16)?Uint16Array:a<=Math.pow(2,32)?Uint32Array:a<=Number.MAX_SAFE_INTEGER?eM:null:null,"getUintArray"),eM=class extends Array{static{t(this,"ZeroArray")}constructor(s){super(s),this.fill(0)}},r6e=class a{static{t(this,"Stack")}heap;length;static#r=!1;static create(s){let l=Uat(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&&!Z4(l))throw new TypeError("max option must be a nonnegative integer");let mr=l?Uat(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=r6e.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&&!Z4(this.#n))throw new TypeError("maxSize must be a positive integer if specified");if(!Z4(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=Z4(m)||m===0?m:1,this.ttlAutopurge=!!b,this.ttl=_||0,this.ttl){if(!Z4(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";KQt(Is)&&(jat.add(Is),Bat("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 eM(this.#r),l=new eM(this.#r);this.#b=s,this.#x=l,this.#N=(b,D,A=ZR.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?ZR.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=ZR.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 eM(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(!Z4(m))if(b){if(typeof b!="function")throw new TypeError("sizeCalculation must be a function");if(m=b(_,l),!Z4(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-(ZR.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=ZR.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=ZR.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 Cce,{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 Cce}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 aZt,win32 as _6e}from"path";import{fileURLToPath as oZt}from"url";import{lstatSync as cZt,readdir as lZt,readdirSync as uZt,readlinkSync as fZt,realpathSync as _Zt}from"fs";import*as pZt from"fs";import{lstat as mZt,readdir as hZt,readlink as gZt,realpath as yZt}from"fs/promises";import{EventEmitter as l6e}from"events";import Vat from"stream";import{StringDecoder as YQt}from"string_decoder";var $at=typeof process=="object"&&process?process:{stdout:null,stderr:null},XQt=t(a=>!!a&&typeof a=="object"&&(a instanceof t3||a instanceof Vat||QQt(a)||ZQt(a)),"isStream"),QQt=t(a=>!!a&&typeof a=="object"&&a instanceof l6e&&typeof a.pipe=="function"&&a.pipe!==Vat.Writable.prototype.pipe,"isReadable"),ZQt=t(a=>!!a&&typeof a=="object"&&a instanceof l6e&&typeof a.write=="function"&&typeof a.end=="function","isWritable"),WP=Symbol("EOF"),HP=Symbol("maybeEmitEnd"),e3=Symbol("emittedEnd"),Dce=Symbol("emittingEnd"),vH=Symbol("emittedError"),kce=Symbol("closed"),Jat=Symbol("read"),wce=Symbol("flush"),zat=Symbol("flushChunk"),kE=Symbol("encoding"),tM=Symbol("decoder"),Gg=Symbol("flowing"),bH=Symbol("paused"),rM=Symbol("resume"),Kg=Symbol("buffer"),B1=Symbol("pipes"),Yg=Symbol("bufferLength"),n6e=Symbol("bufferPush"),Pce=Symbol("bufferShift"),Ny=Symbol("objectMode"),Gm=Symbol("destroyed"),i6e=Symbol("error"),s6e=Symbol("emitData"),qat=Symbol("emitEnd"),a6e=Symbol("emitEnd2"),WD=Symbol("async"),o6e=Symbol("abort"),Ace=Symbol("aborted"),SH=Symbol("signal"),bO=Symbol("dataListeners"),U2=Symbol("discarded"),TH=t(a=>Promise.resolve().then(a),"defer"),eZt=t(a=>a(),"nodefer"),tZt=t(a=>a==="end"||a==="finish"||a==="prefinish","isEndish"),rZt=t(a=>a instanceof ArrayBuffer||!!a&&typeof a=="object"&&a.constructor&&a.constructor.name==="ArrayBuffer"&&a.byteLength>=0,"isArrayBufferLike"),nZt=t(a=>!Buffer.isBuffer(a)&&ArrayBuffer.isView(a),"isArrayBufferView"),Nce=class{static{t(this,"Pipe")}src;dest;opts;ondrain;constructor(s,l,_){this.src=s,this.dest=l,this.opts=_,this.ondrain=()=>s[rM](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(s){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},c6e=class extends Nce{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)}},iZt=t(a=>!!a.objectMode,"isObjectModeOptions"),sZt=t(a=>!a.objectMode&&!!a.encoding&&a.encoding!=="buffer","isEncodingOptions"),t3=class extends l6e{static{t(this,"Minipass")}[Gg]=!1;[bH]=!1;[B1]=[];[Kg]=[];[Ny];[kE];[WD];[tM];[WP]=!1;[e3]=!1;[Dce]=!1;[kce]=!1;[vH]=null;[Yg]=0;[Gm]=!1;[SH];[Ace]=!1;[bO]=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");iZt(l)?(this[Ny]=!0,this[kE]=null):sZt(l)?(this[kE]=l.encoding,this[Ny]=!1):(this[Ny]=!1,this[kE]=null),this[WD]=!!l.async,this[tM]=this[kE]?new YQt(this[kE]):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[o6e]():_.addEventListener("abort",()=>this[o6e]()))}get bufferLength(){return this[Yg]}get encoding(){return this[kE]}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[WD]}set async(s){this[WD]=this[WD]||!!s}[o6e](){this[Ace]=!0,this.emit("abort",this[SH]?.reason),this.destroy(this[SH]?.reason)}get aborted(){return this[Ace]}set aborted(s){}write(s,l,_){if(this[Ace])return!1;if(this[WP])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[WD]?TH:eZt;if(!this[Ny]&&!Buffer.isBuffer(s)){if(nZt(s))s=Buffer.from(s.buffer,s.byteOffset,s.byteLength);else if(rZt(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[wce](!0),this[Gg]?this.emit("data",s):this[n6e](s),this[Yg]!==0&&this.emit("readable"),_&&m(_),this[Gg]):s.length?(typeof s=="string"&&!(l===this[kE]&&!this[tM]?.lastNeed)&&(s=Buffer.from(s,l)),Buffer.isBuffer(s)&&this[kE]&&(s=this[tM].write(s)),this[Gg]&&this[Yg]!==0&&this[wce](!0),this[Gg]?this.emit("data",s):this[n6e](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[HP](),null;this[Ny]&&(s=null),this[Kg].length>1&&!this[Ny]&&(this[Kg]=[this[kE]?this[Kg].join(""):Buffer.concat(this[Kg],this[Yg])]);let l=this[Jat](s||null,this[Kg][0]);return this[HP](),l}[Jat](s,l){if(this[Ny])this[Pce]();else{let _=l;s===_.length||s===null?this[Pce]():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[WP]&&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[WP]=!0,this.writable=!1,(this[Gg]||!this[bH])&&this[HP](),this}[rM](){this[Gm]||(!this[bO]&&!this[B1].length&&(this[U2]=!0),this[bH]=!1,this[Gg]=!0,this.emit("resume"),this[Kg].length?this[wce]():this[WP]?this[HP]():this.emit("drain"))}resume(){return this[rM]()}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]}[n6e](s){this[Ny]?this[Yg]+=1:this[Yg]+=s.length,this[Kg].push(s)}[Pce](){return this[Ny]?this[Yg]-=1:this[Yg]-=this[Kg][0].length,this[Kg].shift()}[wce](s=!1){do;while(this[zat](this[Pce]())&&this[Kg].length);!s&&!this[Kg].length&&!this[WP]&&this.emit("drain")}[zat](s){return this.emit("data",s),this[Gg]}pipe(s,l){if(this[Gm])return s;this[U2]=!1;let _=this[e3];return l=l||{},s===$at.stdout||s===$at.stderr?l.end=!1:l.end=l.end!==!1,l.proxyErrors=!!l.proxyErrors,_?l.end&&s.end():(this[B1].push(l.proxyErrors?new c6e(this,s,l):new Nce(this,s,l)),this[WD]?TH(()=>this[rM]()):this[rM]()),s}unpipe(s){let l=this[B1].find(_=>_.dest===s);l&&(this[B1].length===1?(this[Gg]&&this[bO]===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[bO]++,!this[B1].length&&!this[Gg]&&this[rM]();else if(s==="readable"&&this[Yg]!==0)super.emit("readable");else if(tZt(s)&&this[e3])super.emit(s),this.removeAllListeners(s);else if(s==="error"&&this[vH]){let m=l;this[WD]?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[bO]=this.listeners("data").length,this[bO]===0&&!this[U2]&&!this[B1].length&&(this[Gg]=!1)),_}removeAllListeners(s){let l=super.removeAllListeners(s);return(s==="data"||s===void 0)&&(this[bO]=0,!this[U2]&&!this[B1].length&&(this[Gg]=!1)),l}get emittedEnd(){return this[e3]}[HP](){!this[Dce]&&!this[e3]&&!this[Gm]&&this[Kg].length===0&&this[WP]&&(this[Dce]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[kce]&&this.emit("close"),this[Dce]=!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[WD]?(TH(()=>this[s6e](_)),!0):this[s6e](_);if(s==="end")return this[qat]();if(s==="close"){if(this[kce]=!0,!this[e3]&&!this[Gm])return!1;let b=super.emit("close");return this.removeAllListeners("close"),b}else if(s==="error"){this[vH]=_,super.emit(i6e,_);let b=!this[SH]||this.listeners("error").length?super.emit("error",_):!1;return this[HP](),b}else if(s==="resume"){let b=super.emit("resume");return this[HP](),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[HP](),m}[s6e](s){for(let _ of this[B1])_.dest.write(s)===!1&&this.pause();let l=this[U2]?!1:super.emit("data",s);return this[HP](),l}[qat](){return this[e3]?!1:(this[e3]=!0,this.readable=!1,this[WD]?(TH(()=>this[a6e]()),!0):this[a6e]())}[a6e](){if(this[tM]){let l=this[tM].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[kE]?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[WP])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[WP]})},"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(i6e,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(i6e,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[kce]&&l.close(),s?this.emit("error",s):this.emit(Gm),this}static get isStream(){return XQt}};var dZt=_Zt.native,EH={lstatSync:cZt,readdir:lZt,readdirSync:uZt,readlinkSync:fZt,realpathSync:dZt,promises:{lstat:mZt,readdir:hZt,readlink:gZt,realpath:yZt}},Yat=t(a=>!a||a===EH||a===pZt?EH:{...EH,...a,promises:{...EH.promises,...a.promises||{}}},"fsFromOption"),Xat=/^\\\\\?\\([a-z]:)\\?$/i,vZt=t(a=>a.replace(/\//g,"\\").replace(Xat,"$1\\"),"uncToDrive"),bZt=/[\\\/]/,bT=0,Qat=1,Zat=2,HD=4,eot=6,tot=8,SO=10,rot=12,vT=15,xH=~vT,u6e=16,Wat=32,CH=64,wE=128,Ice=256,Fce=512,Hat=CH|wE|Fce,SZt=1023,f6e=t(a=>a.isFile()?tot:a.isDirectory()?HD:a.isSymbolicLink()?SO:a.isCharacterDevice()?Zat:a.isBlockDevice()?eot:a.isSocket()?rot:a.isFIFO()?Qat:bT,"entToType"),Gat=new Map,DH=t(a=>{let s=Gat.get(a);if(s)return s;let l=a.normalize("NFKD");return Gat.set(a,l),l},"normalize"),Kat=new Map,Oce=t(a=>{let s=Kat.get(a);if(s)return s;let l=DH(a.toLowerCase());return Kat.set(a,l),l},"normalizeNocase"),Lce=class extends yH{static{t(this,"ResolveCache")}constructor(){super({max:256})}},p6e=class extends yH{static{t(this,"ChildrenCache")}constructor(s=16*1024){super({maxSize:s,sizeCalculation:t(l=>l.length+1,"sizeCalculation")})}},not=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?Oce(s):DH(s),this.#o=l&SZt,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=Yat(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&=~u6e,l}child(s,l){if(s===""||s===".")return this;if(s==="..")return this.parent||this;let _=this.children(),m=this.nocase?Oce(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|=wE),_.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)===tot}isDirectory(){return(this.#o&vT)===HD}isCharacterDevice(){return(this.#o&vT)===Zat}isBlockDevice(){return(this.#o&vT)===eot}isFIFO(){return(this.#o&vT)===Qat}isSocket(){return(this.#o&vT)===rot}isSymbolicLink(){return(this.#o&SO)===SO}lstatCached(){return this.#o&Wat?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!==SO||this.#o&Ice||this.#o&wE)}calledReaddir(){return!!(this.#o&u6e)}isENOENT(){return!!(this.#o&wE)}isNamed(s){return this.nocase?this.#b===Oce(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|=u6e;for(let l=s.provisional;l<s.length;l++){let _=s[l];_&&_.#L()}}#L(){this.#o&wE||(this.#o=(this.#o|wE)&xH,this.#P())}#P(){let s=this.children();s.provisional=0;for(let l of s)l.#L()}#A(){this.#o|=Fce,this.#R()}#R(){if(this.#o&CH)return;let s=this.#o;(s&vT)===HD&&(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|=Ice,s==="ENOENT"&&(l|=wE),(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 _=f6e(s),m=this.newChild(s.name,_,{parent:this}),b=m.#o&vT;return b!==HD&&b!==SO&&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?Oce(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|f6e(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&wE))try{return this.#V(await this.#r.promises.lstat(this.fullpath())),this}catch(s){this.#j(s.code)}}lstatSync(){if(!(this.#o&wE))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=f6e(s);this.#o=this.#o&xH|en|Wat,en!==bT&&en!==HD&&en!==SO&&(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&Hat)return!1;let s=vT&this.#o;return s===bT||s===HD||s===SO}shouldWalk(s,l){return(this.#o&HD)===HD&&!(this.#o&Hat)&&!s.has(this)&&(!l||l(this))}async realpath(){if(this.#T)return this.#T;if(!((Fce|Ice|wE)&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(!((Fce|Ice|wE)&this.#o))try{let s=this.#r.realpathSync(this.fullpath());return this.#T=this.resolve(s)}catch{this.#A()}}[not](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}},Rce=class a extends Iy{static{t(this,"PathWin32")}sep="\\";splitSep=bZt;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 _6e.parse(s).root}getRoot(s){if(s=vZt(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 nM(s,this).root}sameRoot(s,l=this.root.name){return s=s.toUpperCase().replace(/\//g,"\\").replace(Xat,"$1\\"),s===l}},Mce=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(),_)}},jce=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=Yat(D),(s instanceof URL||s.startsWith("file://"))&&(s=oZt(s));let A=l.resolve(s);this.roots=Object.create(null),this.rootPath=this.parseRootPath(A),this.#r=new Lce,this.#n=new Lce,this.#e=new p6e(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 t3({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 t3({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[not](l)}},nM=class extends jce{static{t(this,"PathScurryWin32")}sep="\\";constructor(s=process.cwd(),l={}){let{nocase:_=!0}=l;super(s,_6e,"\\",{...l,nocase:_}),this.nocase=_;for(let m=this.cwd;m;m=m.parent)m.nocase=this.nocase}parseRootPath(s){return _6e.parse(s).root.toUpperCase()}newRoot(s){return new Rce(this.rootPath,HD,void 0,this.roots,this.nocase,this.childrenCache(),{fs:s})}isAbsolute(s){return s.startsWith("/")||s.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(s)}},iM=class extends jce{static{t(this,"PathScurryPosix")}sep="/";constructor(s=process.cwd(),l={}){let{nocase:_=!1}=l;super(s,aZt,"/",{...l,nocase:_}),this.nocase=_}parseRootPath(s){return"/"}newRoot(s){return new Mce(this.rootPath,HD,void 0,this.roots,this.nocase,this.childrenCache(),{fs:s})}isAbsolute(s){return s.startsWith("/")}},kH=class extends iM{static{t(this,"PathScurryDarwin")}constructor(s=process.cwd(),l={}){let{nocase:_=!0}=l;super(s,{...l,nocase:_})}},e4r=process.platform==="win32"?Rce:Mce,iot=process.platform==="win32"?nM:process.platform==="darwin"?kH:iM;var TZt=t(a=>a.length>=1,"isPatternList"),xZt=t(a=>a.length>=1,"isGlobList"),sM=class a{static{t(this,"Pattern")}#r;#n;#e;length;#t;#s;#p;#a;#_;#c;#l=!0;constructor(s,l,_,m){if(!TZt(s))throw new TypeError("empty pattern list");if(!xZt(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 EZt=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",aM=class{static{t(this,"Ignore")}relative;relativeChildren;absolute;absoluteChildren;platform;mmopts;constructor(s,{nobrace:l,nocase:_,noext:m,noglobstar:b,platform:D=EZt}){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 sM(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 d6e=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()]))}},m6e=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)])}},h6e=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 m6e;subwalks=new h6e;patterns;follow;dot;opts;constructor(s,l){this.opts=s,this.follow=!!s.follow,this.dot=!!s.dot,this.hasWalkedCache=l?l.copy():new d6e}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 CZt=t((a,s)=>typeof a=="string"?new aM([a],s):Array.isArray(a)?new aM(a,s):a,"makeIgnore"),Bce=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=CZt(_.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 Bce{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 Bce{static{t(this,"GlobStream")}results;constructor(s,l,_){super(s,l,_),this.results=new t3({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 kZt=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",PE=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=DZt(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||kZt,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"?nM:l.platform==="darwin"?kH:l.platform?iM:iot;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 sM(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 g6e=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 Uce(a,s={}){return new PE(a,s).streamSync()}t(Uce,"globStreamSync");function aot(a,s={}){return new PE(a,s).stream()}t(aot,"globStream");function oot(a,s={}){return new PE(a,s).walkSync()}t(oot,"globSync");async function sot(a,s={}){return new PE(a,s).walk()}t(sot,"glob_");function $ce(a,s={}){return new PE(a,s).iterateSync()}t($ce,"globIterateSync");function cot(a,s={}){return new PE(a,s).iterate()}t(cot,"globIterate");var wZt=Uce,PZt=Object.assign(aot,{sync:Uce}),AZt=$ce,NZt=Object.assign(cot,{sync:$ce}),IZt=Object.assign(oot,{stream:Uce,iterate:$ce}),NH=Object.assign(sot,{glob:sot,globSync:oot,sync:IZt,globStream:aot,stream:PZt,globStreamSync:Uce,streamSync:wZt,globIterate:cot,iterate:NZt,globIterateSync:$ce,iterateSync:AZt,Glob:PE,hasMagic:g6e,escape:QR,unescape:DE});NH.glob=NH;import $fe from"fs";import HFe 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 OZt="[",FZt="]",LZt="{",RZt="}",MZt=":",jZt=",",BZt="true",UZt="false",$Zt="null",JZt="NaN",zZt="Infinity",v6e='"',IH=new Map([[34,v6e],[92,"\\"],[47,"/"],[98,"\b"],[110,`
|
|
558
558
|
`],[102,"\f"],[114,"\r"],[116," "]]),qce=new Map([...IH,[118,"\v"],[48,"\0"]]),qZt=new Map([[v6e,v6e],["\\","\\"],["/","/"],["\b","b"],[`
|
|
559
559
|
`,"n"],["\f","f"],["\r","r"],[" ","t"]]),B4r=new Map([...qZt,["\v","v"],["\0","0"],["\u2028","u2028"],["\u2029","u2029"]]),zce=new Map([[OZt,"LBracket"],[FZt,"RBracket"],[LZt,"LBrace"],[RZt,"RBrace"],[MZt,"Colon"],[jZt,"Comma"],[BZt,"Boolean"],[UZt,"Boolean"],[$Zt,"Null"]]),Jce=new Map([...zce,[JZt,"Number"],[zZt,"Number"]]),b6e=new Set([10,13,8232,8233]),KP=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}},S6e=class extends KP{static{t(this,"UnexpectedChar")}constructor(s,l){super(`Unexpected character '${String.fromCharCode(s)}' found.`,l)}},T6e=class extends KP{static{t(this,"UnexpectedIdentifier")}constructor(s,l){super(`Unexpected identifier '${s}' found.`,l)}},TO=class extends KP{static{t(this,"UnexpectedToken")}constructor(s){super(`Unexpected token ${s.type} found.`,s.loc.start)}},Vce=class extends KP{static{t(this,"UnexpectedEOF")}constructor(s){super("Unexpected end of input found.",s)}},VZt=/[\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]/,WZt=/[\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]/,HZt=13,lot=10,x6e=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===HZt?(this.#s=!0,this.peek()===lot&&this.#t++):s===lot&&(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}},GZt="Infinity",KZt="NaN",YZt=new Set([116,102,110]),E6e=new Set([32,9,10,13]),uot=new Set([...E6e,11,12,160,8232,8233,65279,160,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288]),XZt={mode:"json",ranges:!1},QZt=new Set(["true","false","null"]),T_={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 GP(a){return a>=48&&a<=57}t(GP,"isDigit");function y6e(a){return GP(a)||a>=65&&a<=70||a>=97&&a<=102}t(y6e,"isHexDigit");function ZZt(a){return a>=49&&a<=57}t(ZZt,"isPositiveDigit");function eer(a){return YZt.has(a)}t(eer,"isKeywordStart");function _ot(a){return GP(a)||a===46||a===45}t(_ot,"isNumberStart");function ter(a){return _ot(a)||a===43}t(ter,"isJSON5NumberStart");function fot(a,s){return a===34||s&&a===39}t(fot,"isStringStart");function pot(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 VZt.test(s)}t(pot,"isJSON5IdentifierStart");function rer(a){if(pot(a)||GP(a))return!0;let s=String.fromCharCode(a);return WZt.test(s)}t(rer,"isJSON5IdentifierPart");var C6e=class{static{t(this,"Tokenizer")}#r;#n;#e;#t;#s;#p;#a;#_;#c;#l;#i;constructor(s,l){this.#n=s,this.#r={...XZt,...l},this.#e=new x6e(s),this.#t=this.#r.mode==="json5",this.#s=this.#r.mode!=="json",this.#p=this.#r.ranges,this.#_=this.#t?qce.has.bind(qce):IH.has.bind(IH),this.#c=this.#t?b6e.has.bind(b6e):()=>!1,this.#l=this.#t?_=>_===120:()=>!1,this.#i=this.#t?uot.has.bind(uot):E6e.has.bind(E6e)}#f(s,l=this.#e.locate()){throw new S6e(s,l)}#v(s,l=this.#e.locate()){throw new T6e(s,l)}#d(){throw new Vce(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(),y6e(_)){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(),!rer(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 _!==GZt&&_!==KZt&&this.#f(s),l+_.length}GP(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(),y6e(s)||(this.#e.next(),this.#f(s));do this.#e.next(),l++,s=this.#e.peek();while(y6e(s))}else GP(s)&&this.#f(s);else if(!this.#t||s!==46)for(ZZt(s)||this.#f(s),s=this.#e.peek();GP(s);)this.#e.next(),l++,s=this.#e.peek();if(s===46){let _=-1;for(this.#e.next(),l++,_++,s=this.#e.peek();GP(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()),GP(s)||(this.#e.next(),this.#f(s));GP(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 T_.EOF;let l=this.#e.locate(),_=String.fromCharCode(s);if(this.#t)if(Jce.has(_))this.#a=this.#u(Jce.get(_),1,l);else if(pot(s)){let m=this.#g(s);Jce.has(m)?this.#a=this.#u(Jce.get(m),m.length,l):this.#a=this.#u("Identifier",m.length,l)}else if(ter(s)){let m=this.#x(s);this.#a=this.#u("Number",m,l)}else if(fot(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(zce.has(_))this.#a=this.#u(zce.get(_),1,l);else if(eer(s)){let m=this.#g(s);QZt.has(m)||this.#v(m,l),this.#a=this.#u(zce.get(m),m.length,l)}else if(_ot(s)){let m=this.#x(s);this.#a=this.#u("Number",m,l)}else if(fot(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 T_[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}}},ner={mode:"json",ranges:!1,tokens:!1,allowTrailingCommas:!1};function ier(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&&qce.has(A))_+=qce.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 KP(`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 KP(`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&&b6e.has(A))b=m+2,D==="\r"&&a.charAt(b)===`
|
|
560
|
-
`&&b++;else if(l)_+=D,b=m+2;else throw new KP(`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(ier,"getStringValue");function ser(a,s,l=!1){switch(s.type){case"Boolean":return a==="true";case"Number":return Number(a);case"String":return ier(a.slice(1,-1),s,l);default:throw new TypeError(`Unknown token type "${s.type}.`)}}t(ser,"getLiteralValue");function dot(a,s){s=Object.freeze({...ner,...s});let l=[],_=new C6e(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>=T_.LineComment?A():br}t(A,"nextSkipComments");let M=s.mode==="json"?D:A;function U(br,mr){if(br!==mr)throw new TO(_.token)}t(U,"assertTokenType");function ie(br,mr){if(!mr.includes(br))throw new TO(_.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=ser(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 T_.String:return ST.string(Pi,Ti);case T_.Number:return ST.number(Pi,Ti);case T_.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,[T_.String,T_.Identifier,T_.Number]):U(br,T_.String);let mr=_.token,Is=br===T_.String?Z(br):Re(mr);if(m&&(Is.type==="NaN"||Is.type==="Infinity")){if(Is.sign!=="")throw new TO(_.token);Is=ST.identifier(Is.type,{loc:Is.loc,...se(Is.loc.start,Is.loc.end)})}br=M(),U(br,T_.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,T_.LBrace);let mr=_.token,Is=[],Pi=M();if(Pi!==T_.RBrace)do{if(Is.push(ke(Pi)),Pi=M(),!Pi)throw new Vce(Is[Is.length-1].loc.end);if(Pi===T_.Comma){if(Pi=M(),b&&Pi===T_.RBrace)break}else break}while(Pi);U(Pi,T_.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,T_.LBracket);let mr=_.token,Is=[],Pi=M();if(Pi!==T_.RBracket)do{let _p=yr(Pi);if(Is.push(ST.element(_p,{loc:_p.loc})),Pi=M(),Pi===T_.Comma){if(Pi=M(),b&&Pi===T_.RBracket)break}else break}while(Pi);U(Pi,T_.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 T_.String:case T_.Boolean:return Z(br);case T_.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 T_.Null:return Pe(mr);case T_.LBrace:return wt(br);case T_.LBracket:return At(br);default:throw new TO(mr)}}t(yr,"parseValue");let zr=yr();if(M())throw new TO(_.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(dot,"parse");var aer=new Map([["Document",["body"]],["Object",["members"]],["Member",["name","value"]],["Element",["value"]],["Array",["elements"]],["String",[]],["Number",[]],["Boolean",[]],["Null",[]],["NaN",[]],["Infinity",[]],["Identifier",[]]]);function mot(a){return a&&typeof a=="object"}t(mot,"isObject");function oer(a){return mot(a)&&typeof a.type=="string"}t(oer,"isNode");function cer(a,s){function l(_,m){typeof s.enter=="function"&&s.enter(_,m);for(let b of aer.get(_.type)){let D=_[b];mot(D)&&(Array.isArray(D)?D.forEach(A=>l(A,_)):oer(D)&&l(D,_))}typeof s.exit=="function"&&s.exit(_,m)}t(l,"visitNode"),l(a)}t(cer,"traverse");function hot(a,s=()=>!0){let l=[];return cer(a,{enter(_,m){l.push({node:_,parent:m,phase:"enter"})},exit(_,m){l.push({node:_,parent:m,phase:"exit"})}}),l.filter(s).values()}t(hot,"iterator");import ler from"fs/promises";var OH=t((a,s)=>a.split(/\r?\n/)[s-1],"getFileLineContent"),Wce=t(async a=>{try{return await ler.readFile(a,"utf-8")}catch{return}},"getSchemaContent"),FH=t(async a=>{try{return dot(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 got=t(async(a,s,l)=>{try{if(a.length===0)return;for(let _ of a){let m=await Wce(_),b=await uer(m,_,s,l);if(b)return b}}catch{}},"getRouteLocationByValue"),uer=t(async(a,s,l,_)=>{try{if(!a)return;let m=null,b=await FH(a);if(b){for(let{node:D}of hot(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 yot from"fs/promises";import Hce from"path";var D6e="schemas",k6e=".oas.json";var xO=t(async a=>(await yot.readdir(a)).map(l=>`${a}/${l}`).filter(l=>l.endsWith(k6e)).sort(),"getOpenApiFilesByAlphabetical"),oM=t(async a=>{let s=Hce.resolve(a,"config");return(await yot.readdir(s)).filter(_=>_.endsWith(k6e)).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),w6e(P6e(l),s,A,_,m,b,D)}t(LH,"chaseRefs");function w6e(a,s,l,_,m,b,D){if(Array.isArray(l))for(let A of l)w6e(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,r3(a,M),_,m,b,D)}w6e(a,s,l[A],_,m,b,D)}}t(w6e,"lookForRefs");function r3(a,s){let l=s.indexOf("#");return l>=0?`${Hce.resolve(a,s.substring(0,l))}${s.substring(l)}`:Hce.resolve(Hce.dirname(a),s)}t(r3,"getFullyQualifiedRefName");function P6e(a){let s=a.indexOf("#");return s>=0?a.substring(0,s):a}t(P6e,"getFilePathNameFromRefName");var A6e=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"}},fer=new A6e,N6e=fer;var QH=up(W4e(),1);var H4e={};dst(H4e,{UnsafePathError:()=>ble,deleteFile:()=>Yir,deleteFolder:()=>ssr,dirExists:()=>Sle,ensureDirectoryExists:()=>esr,fileExists:()=>Kir,getParentDirFilename:()=>rsr,isNotFileOrDirectory:()=>Xir,listFolderContents:()=>Wlt,listFolders:()=>Zir,mkdirForFilePathIfNotExits:()=>Glt,mkdirIfNotExists:()=>Hlt,safePath:()=>tsr,tarFolderContent:()=>nsr,untar:()=>isr});import qlt from"child_process";import u3 from"fs/promises";import l3 from"path";var Vlt=[".git","node_modules",".yarn",".DS_Store"];async function Kir(a){try{return(await u3.stat(a)).isFile()}catch{return!1}}t(Kir,"fileExists");async function Yir(a,s){return await u3.rm(a,s)}t(Yir,"deleteFile");async function Sle(a){try{return(await u3.stat(a)).isDirectory()}catch{return!1}}t(Sle,"dirExists");async function Xir(a){try{return await u3.stat(a),!1}catch{return!0}}t(Xir,"isNotFileOrDirectory");function Qir(a,s){let l=new RegExp(`(.*)(\\/${s})$|(.*)(${s}\\/)`),_=a.match(l);if(!_)return"";let m=a.split(_[0]);return m[1]===""?"":`/${m[1]}`}t(Qir,"getParentDirectory");async function Zir(a){if(!await Sle(a))return[];let s=await u3.readdir(a,{withFileTypes:!0}),l=[];for await(let _ of s)Vlt.includes(_.name)||_.isDirectory()&&l.push(_.name);return l}t(Zir,"listFolders");async function Wlt(a,s,l=!0){let _=Qir(a,s),m=await u3.readdir(a,{withFileTypes:!0}),b=[];for await(let D of m)if(!Vlt.includes(D.name)||!l)if(D.isDirectory()){let A=await Wlt(l3.join(a,D.name),s,l);b.push(...A)}else b.push(l3.join(_,D.name));return b}t(Wlt,"listFolderContents");var Hlt=t(async a=>{if(await Sle(a))return!0;await u3.mkdir(a,{recursive:!0})},"mkdirIfNotExists"),Glt=t(async a=>{let s=l3.dirname(a);return Hlt(s)},"mkdirForFilePathIfNotExits"),esr=Glt,ble=class extends Error{static{t(this,"UnsafePathError")}constructor(s){super(s)}};function tsr(a){let s=t(l=>{if(!l.startsWith(a))throw new ble("Resolved path is not part of the project.");return l},"ensureSafePath");return{resolve:t((...l)=>s(l3.resolve(...l)),"resolve")}}t(tsr,"safePath");function rsr(a){return`${l3.basename(l3.dirname(a))}/${l3.basename(a)}`}t(rsr,"getParentDirFilename");function nsr(a,s,l,_){let m=l3.join(_,l);return qlt.execSync(`tar --exclude='.git/' --exclude='dist/' -czf ${m} ${s}`,{cwd:a}),m}t(nsr,"tarFolderContent");function isr(a,s,l,_=!1){qlt.execSync(`tar -xf ${s} ${_?"--strip-components=1 ":""}-C ${l}`,{cwd:a})}t(isr,"untar");async function ssr(a){if(await Sle(a))return await u3.rm(a,{recursive:!0})}t(ssr,"deleteFolder");var wl=H4e;var CT=up(W4e(),1);import{readFile as asr}from"fs/promises";var IO=class extends Error{static{t(this,"CustomResolveError")}},f3=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:Tle(this.sourceDirectory,this.logger),external:!0,http:!1},dereference:{circular:"ignore",onDereference:l?.onDereference}})}bundle(s){return QH.$RefParser.bundle(s,{resolve:{file:Tle(this.sourceDirectory,this.logger),external:!0,http:!1}})}parse(s){return QH.$RefParser.parse(s,{resolve:{file:Tle(this.sourceDirectory,this.logger),external:!0,http:!1}})}resolve(s){return QH.$RefParser.resolve(s,{resolve:{file:Tle(this.sourceDirectory,this.logger),external:!0,http:!1}})}};function Tle(a,s){return{order:100,canRead(l){let _=lsr(l.url);if(!(_===void 0||_==="file"))return!1;let b;try{b=Klt(l.url)}catch(D){throw new IO(`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{_=Klt(l.url)}catch(m){throw new IO(`Malformed URI: ${l.url}`,{cause:m})}try{return await asr(_)}catch(m){throw new IO(`Error opening file "${_}"`,{cause:m})}}}}t(Tle,"customResolver");var G4e=/^win/.test(globalThis.process?globalThis.process.platform:""),osr=/\//g,csr=/^(\w{2,}):\/\//i,K4e=[/%23/g,"#",/%24/g,"$",/%26/g,"&",/%2C/g,",",/%40/g,"@"];function lsr(a){let s=csr.exec(a);if(s)return s[1].toLowerCase()}t(lsr,"getProtocol");function Klt(a,s){a=decodeURI(a);for(let _=0;_<K4e.length;_+=2)a=a.replace(K4e[_],K4e[_+1]);let l=a.substr(0,7).toLowerCase()==="file://";return l&&(a=a[7]==="/"?a.substr(8):a.substr(7),G4e&&a[1]==="/"&&(a=a[0]+":"+a.substr(1)),s?a="file:///"+a:(l=!1,a=G4e?a:"/"+a)),G4e&&!l&&(a=a.replace(osr,"\\"),a.substr(1,2)===":\\"&&(a=a[0].toUpperCase()+a.substr(1))),a}t(Klt,"toFileSystemPath");var Ylt="YOUR_KEY_HERE";async function Xlt(a){let l=await new f3(a.sourceDirectory,a.logger).bundle(a.openApiDocPath),_=a.openApiDocPath.replace(a.sourceDirectory,"");return usr({...a,relativeOpenApiPath:_},l)}t(Xlt,"buildPublicOpenApiFile");async function usr(a,s){dsr({relativeOpenApiPath:a.relativeOpenApiPath},s);let l=s;return l=_sr(l),fsr(l,a),l=psr(l,a),Qlt(l,"x-zuplo"),l}t(usr,"buildRawOpenApiFile");function fsr(a,{customDomain:s,deploymentName:l,environmentType:_}){let m;s?m=s:_&&l&&(m=_===pce.WORKING_COPY?`${l}.${N6e.ZUP_WORKING_COPY_HOSTNAME}`:`${l}.${N6e.ZUP_HOSTNAME}`),m?a.servers=[{url:`https://${m}`}]:a.servers=void 0}t(fsr,"addServerHost");function _sr(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])=>(HR in A&&dce(A[HR])&&(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(dce(se[HR])){delete M[ie];return}let{parameters:Z}=se;if(!Z)return;let Re=Z.filter(Pe=>{if(HR in Pe&&dce(Pe[HR]))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(_sr,"removeHiddenRoutesAndParams");function psr(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} ${Ylt}`:Ylt,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(psr,"enrichSpecWithZuploData");function Qlt(a,s){for(let l in a)l.startsWith(s)?delete a[l]:typeof a[l]=="object"&&Qlt(a[l],s)}t(Qlt,"removePropertiesByPrefix");function dsr({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(dsr,"assertIsZuploOpenApiSpec");function msr(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(msr,"base");var Zlt=msr;var hsr="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",xle=Zlt(hsr);var Y4e="2024-09-02",eut=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 tut(){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:Y4e,ENVIRONMENT_TYPE:"mock-environment-type",GIT_SHA:void 0,IS_LOCAL_DEVELOPMENT:!1,COMPATIBILITY_FLAGS:eut[Y4e]},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(tut,"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=tut()),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(xle.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 gsr=["ZUPLO_USER_LOGGER_DATA_DOG_API_KEY","ZUPLO_USER_LOGGER_DATA_DOG_URL","ZUPLO_LOG_LEVEL","ZUPLO_HANDLER_WRITE_LOG_LEVEL"];function rut(a){return a.startsWith("__ZUPLO")||a.startsWith("ZUPLO_")?!gsr.includes(a)&&!a.startsWith("ZUPLO_PUBLIC_"):!1}t(rut,"isRestrictedEnvVariableName");function nut(a){return!!a.startsWith("ZUPLO_")}t(nut,"isZuploReadableEnvVariableName");var NIr=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(!(rut(l)&&!nut(l)))return DT.instance.runtime[l]}});function ZH(a,s,l){return`_${eA(`${a}_${s}_${l}`)}`}t(ZH,"getRawOperationDataIdentifierName");function X4e(a,s,l,_){return`_${eA(a.toLowerCase())}_${s.toLowerCase()}_${l.toLowerCase()}_${_.toLowerCase()}`}t(X4e,"getIdForParameterSchema");function Q4e(a,s,l){return`_${eA(a.toLowerCase())}_${s.toLowerCase()}_rb_${eA(l.toLowerCase())}`}t(Q4e,"getIdForRequestBodySchema");function eG(a,s){return`_${eA(a)}_${eA(s)}`}t(eG,"getIdForRefSchema");function eA(a){return a.replace(/[^a-zA-Z0-9]/g,"_")}t(eA,"sanitizedIdentifierName");var Lmt=up(Hft(),1);import Kue 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"}},fcr=/[$_\p{ID_Start}]/u,_cr=/[$_\u200C\u200D\p{ID_Continue}]/u,W3e=".*";function pcr(a,s){return(s?/^[\x00-\xFF]*$/:/^[\x00-\x7F]*$/).test(a)}t(pcr,"Re");function Yft(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&&fcr.test(M)||A!==_+1&&_cr.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(!pcr(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(Yft,"v");function Xft(a,s={}){let l=Yft(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=W3e:Pi=hn:Pi=_;let Po=2;Pi===_?(Po=1,Pi=""):Pi===W3e&&(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(Xft,"D");function AT(a){return a.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}t(AT,"S");function Gft(a){return a&&a.ignoreCase?"ui":"u"}t(Gft,"X");function dcr(a,s,l){return Qft(Xft(a,l),s,l)}t(dcr,"Z");function NM(a){switch(a){case 0:return"*";case 1:return"?";case 2:return"+";case 3:return""}}t(NM,"k");function Qft(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)})${NM(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=W3e),!A.prefix.length&&!A.suffix.length){A.modifier===3||A.modifier===1?_+=`(${U})${NM(A.modifier)}`:_+=`((?:${U})${NM(A.modifier)})`;continue}if(A.modifier===3||A.modifier===1){_+=`(?:${AT(A.prefix)}(${U})${AT(A.suffix)})`,_+=NM(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(_,Gft(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(_,Gft(l))}t(Qft,"F");var m3={delimiter:"",prefixes:"",sensitive:!0,strict:!0},mcr={delimiter:".",prefixes:"",sensitive:!0,strict:!0},hcr={delimiter:"/",prefixes:"/",sensitive:!0,strict:!0};function gcr(a,s){return a.length?a[0]==="/"?!0:!s||a.length<2?!1:(a[0]=="\\"||a[0]=="{")&&a[1]=="/":!1}t(gcr,"J");function Zft(a,s){return a.startsWith(s)?a.substring(s.length,a.length):a}t(Zft,"Q");function ycr(a,s){return a.endsWith(s)?a.substr(0,a.length-s.length):a}t(ycr,"Ee");function e_t(a){return!a||a.length<2?!1:a[0]==="["||(a[0]==="\\"||a[0]==="{")&&a[1]==="["}t(e_t,"W");var t_t=["ftp","file","http","https","ws","wss"];function r_t(a){if(!a)return!0;for(let s of t_t)if(a.test(s))return!0;return!1}t(r_t,"N");function vcr(a,s){if(a=Zft(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(vcr,"te");function bcr(a,s){if(a=Zft(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(bcr,"re");function Scr(a,s){return s||a===""?a:e_t(a)?s_t(a):i_t(a)}t(Scr,"ne");function Tcr(a,s){if(s||a==="")return a;let l=new URL("https://example.com");return l.password=a,l.password}t(Tcr,"se");function xcr(a,s){if(s||a==="")return a;let l=new URL("https://example.com");return l.username=a,l.username}t(xcr,"ie");function Ecr(a,s,l){if(l||a==="")return a;if(s&&!t_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(Ecr,"ae");function Ccr(a,s,l){return n_t(s)===a&&(a=""),l||a===""?a:a_t(a)}t(Ccr,"oe");function Dcr(a,s){return a=ycr(a,":"),s||a===""?a:H3e(a)}t(Dcr,"ce");function n_t(a){switch(a){case"ws":case"http":return"80";case"wws":case"https":return"443";case"ftp":return"21";default:return""}}t(n_t,"_");function H3e(a){if(a==="")return a;if(/^[-+.A-Za-z0-9]*$/.test(a))return a.toLowerCase();throw new TypeError(`Invalid protocol '${a}'.`)}t(H3e,"y");function kcr(a){if(a==="")return a;let s=new URL("https://example.com");return s.username=a,s.username}t(kcr,"le");function wcr(a){if(a==="")return a;let s=new URL("https://example.com");return s.password=a,s.password}t(wcr,"fe");function i_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(i_t,"z");function s_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(s_t,"j");function a_t(a){if(a===""||/^[0-9]*$/.test(a)&&parseInt(a)<=65535)return a;throw new TypeError(`Invalid port '${a}'.`)}t(a_t,"K");function Pcr(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(Pcr,"he");function Acr(a){return a===""?a:new URL(`data:${a}`).pathname}t(Acr,"ue");function Ncr(a){if(a==="")return a;let s=new URL("https://example.com");return s.search=a,s.search.substring(1,s.search.length)}t(Ncr,"de");function Icr(a){if(a==="")return a;let s=new URL("https://example.com");return s.hash=a,s.hash.substring(1,s.hash.length)}t(Icr,"pe");var Ocr=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=Yft(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,m3),a.encodePart=H3e;let s=dcr(this.#T(),void 0,a);this.#l=r_t(s)}},V3e=["protocol","username","password","hostname","port","pathname","search","hash"],d3="*";function Kft(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(Kft,"ge");function sA(a,s){return s?mG(a):a}t(sA,"b");function dG(a,s,l){let _;if(typeof s.baseURL=="string")try{_=new URL(s.baseURL),s.protocol===void 0&&(a.protocol=sA(_.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=sA(_.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=sA(_.password,l)),s.protocol===void 0&&s.hostname===void 0&&(a.hostname=sA(_.hostname,l)),s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&(a.port=sA(_.port,l)),s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.pathname===void 0&&(a.pathname=sA(_.pathname,l)),s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.pathname===void 0&&s.search===void 0&&(a.search=sA(_.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=sA(_.hash.substring(1,_.hash.length),l))}catch{throw new TypeError(`invalid baseURL '${s.baseURL}'.`)}if(typeof s.protocol=="string"&&(a.protocol=Dcr(s.protocol,l)),typeof s.username=="string"&&(a.username=xcr(s.username,l)),typeof s.password=="string"&&(a.password=Tcr(s.password,l)),typeof s.hostname=="string"&&(a.hostname=Scr(s.hostname,l)),typeof s.port=="string"&&(a.port=Ccr(s.port,a.protocol,l)),typeof s.pathname=="string"){if(a.pathname=s.pathname,_&&!gcr(a.pathname,l)){let m=_.pathname.lastIndexOf("/");m>=0&&(a.pathname=sA(_.pathname.substring(0,m+1),l)+a.pathname)}a.pathname=Ecr(a.pathname,a.protocol,l)}return typeof s.search=="string"&&(a.search=bcr(s.search,l)),typeof s.hash=="string"&&(a.hash=vcr(s.hash,l)),a}t(dG,"w");function mG(a){return a.replace(/([+*?:{}()\\])/g,"\\$1")}t(mG,"C");function Fcr(a){return a.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}t(Fcr,"Oe");function Lcr(a,s){s.delimiter??="/#?",s.prefixes??="./",s.sensitive??=!1,s.strict??=!1,s.end??=!0,s.start??=!0,s.endsWith="";let l=".*",_=`[^${Fcr(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)}}${NM(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+=NM(A.modifier))}return b}t(Lcr,"ke");var o_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 Ocr(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:d3,protocol:d3,username:d3,password:d3,hostname:d3,port:d3,search:d3,hash:d3};this.#r=dG(b,a,!0),n_t(this.#r.protocol)===this.#r.port&&(this.#r.port="");let D;for(D of V3e){if(!(D in this.#r))continue;let A={},M=this.#r[D];switch(this.#e[D]=[],D){case"protocol":Object.assign(A,m3),A.encodePart=H3e;break;case"username":Object.assign(A,m3),A.encodePart=kcr;break;case"password":Object.assign(A,m3),A.encodePart=wcr;break;case"hostname":Object.assign(A,mcr),e_t(M)?A.encodePart=s_t:A.encodePart=i_t;break;case"port":Object.assign(A,m3),A.encodePart=a_t;break;case"pathname":r_t(this.#n.protocol)?(Object.assign(A,hcr,m),A.encodePart=Pcr):(Object.assign(A,m3,m),A.encodePart=Acr);break;case"search":Object.assign(A,m3,m),A.encodePart=Ncr;break;case"hash":Object.assign(A,m3,m),A.encodePart=Icr;break}try{this.#s[D]=Xft(M,A),this.#n[D]=Qft(this.#s[D],this.#e[D],A),this.#t[D]=Lcr(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,Kft(a,s),!1)}catch{return!1}let _;for(_ of V3e)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,Kft(a,s),!1)}catch{return null}let _={};s?_.inputs=[a,s]:_.inputs=[a];let m;for(m of V3e){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=o_t);import{AssertionError as Rcr}from"assert";function aA(a,s){if(a===!1)throw new Rcr({message:s})}t(aA,"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 IM(a){return a.type===Ac.Object}t(IM,"isAstObject");function oA(a){return a.type===Ac.Property}t(oA,"isAstProperty");function c_t(a){return a.type===Ac.Array}t(c_t,"isAstArray");function OM(a){return a.type===Ac.Literal}t(OM,"isAstLiteral");function BO(a){if(a===void 0)throw new Error("Node is undefined");if(!IM(a))throw new Error("Node is not object")}t(BO,"assertAstObject");import{findNodeAtLocation as Mcr,getNodeValue as jcr,printParseErrorCode as Bcr,visit as Ucr}from"jsonc-parser";var $cr={DEFAULT:{allowTrailingComma:!1}};function gG(a,s=[],l=$cr.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"),Ucr(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:Jcr(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 Jcr(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(Jcr,"getNodeType");function G3e(a,s){return Mcr(a,s)}t(G3e,"findNodeAtLocation");function yG(a){return jcr(a)}t(yG,"getNodeValue");function l_t(a){return Bcr(a)}t(l_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){aA(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 UE={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(UE.createLiteral(_,l));return l},"createArrayOfLiterals")};var zcr=/^[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 _=zcr.test(l.value)?l.value:`'${l.value}'`;s.push(_)}};import{parse as qcr}from"@swc/core";import Vcr from"fs/promises";var u_t=t(async a=>{let s=new Set;try{let l=await Vcr.readFile(a,"utf-8");(await qcr(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 f_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 K3e={$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 __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 Y3e={$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 X3e={$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 Cmt=up(Gdt(),1),Dmt=up(Emt(),1);var $ue=class a{static{t(this,"JsonValidator")}static#r=new a;static get instance(){return a.#r}ajv;constructor(){this.ajv=new Dmt.Ajv2020({allErrors:!0,allowUnionTypes:!0}),this.ajv.addKeyword("faker"),(0,Cmt.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 C3=$ue.instance;C3.addSchema(X3e,"route-configuration.schema.json");C3.addSchema(__t,"policy-configuration.schema.json");C3.addSchema(K3e,"policies.schema.json");C3.addSchema(Y3e,"open-api-route-configuration.schema.json");C3.addSchema(f_t,"fragments.schema.json");var A5r=C3.compile(X3e),kmt=C3.compile(Y3e),_8e=C3.compile(K3e);var Jue=class{static{t(this,"PoliciesConfigurationValidator")}results;validate(s){return this.results=_8e(s),this.results}};var zue=class{static{t(this,"OpenAPILocalizedValidator")}results;validate(s){return this.results=kmt(s),this.results}};import Xmr from"path";var p8e=/\$import\((.*)\)/,que=/\$env\((.*?)\)/g;var _A=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:""}}},Ymr=t(a=>{let s=[],l=a;for(;l.parent;)s.push(l),l=l.parent;return s.reverse()},"invertTree"),D3=t((a,s)=>{if(!a)return!1;let l=Ymr(a);return s.split("/").every((b,D)=>{let A=l[D];return A?b==="*"||oA(A)&&A.name.value===b?!0:b==="{}"?A.type===Ac.Object:b==="[]"?A.type===Ac.Array:!1:!1})},"testPosition");var Vue=class{static{t(this,"AstTransformer")}errors=[];transform(s){return this.visitor(s),s}visitor(s){this.visit(s),IM(s)?s.children.forEach(l=>{this.visitor(l)}):c_t(s)?s.children.forEach(l=>{this.visitor(l)}):oA(s)&&this.visitor(s.value)}},wmt=t((a,s,l)=>_=>{if(!oA(_)||!OM(_.value)||typeof _.value.value!="string")return;if(!a.some(b=>D3(_,b))){que.test(_.value.value)&&s.push(new _A("An $env() statement is not expected at this location.",l,_.location,_.value.value));return}let m=new RegExp(que).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(que),(D,A)=>`\${environment["${A}"] ? environment["${A}"] : ""}`);b!==_.value.value&&(_.value=UE.createTemplateString(b,_))}},"getEnvStatementTransformer");var ZG="config/routes.json",Qmr=["handler/{}/options/*","policies/[]/{}/handler/{}/options/*","corsPolicies/[]/{}/*"],Zmr=["handler/{}/module","handler/{}/options/{}/policies/{}/inbound/[]/{}/module","handler/{}/options/{}/policies/{}/outbound/[]/{}/module","policies/[]/{}/handler/{}/module","policies/[]/{}/handler/{}/options/{}/identifier/{}/module","policies/[]/{}/handler/{}/options/{}/validator"],Pmt=["handler/{}/options/*","policies/[]/{}/handler/{}/options/*"],ehr="handler/{}/options/{}/rewritePattern",thr="handler/{}/options/{}/baseUrl",Wue=class extends Vue{static{t(this,"OpenAPIRoutesFragmentAstTransformer")}importCount=0;addedImports=new Map;getImportName(s){this.addedImports.has(s)||this.addedImports.set(s,`__import${this.importCount++}`);let l=this.addedImports.get(s);if(!l)throw new Error("Import name is undefined. This should not happen.");return l}getImports(){let s=[];return this.addedImports.forEach((l,_)=>{s.push({name:l,path:_})}),s}visit(s){this.rewriteHandlerFunction(s),this.rewriteForwardFunction(s),this.replaceImportStatements(s),this.replaceEnvStatements(s)}rewriteHandlerFunction(s){if(!(!oA(s)||!OM(s.value)||typeof s.value.value!="string")&&D3(s,ehr)){if(!s.parent||!IM(s.parent)){this.errors.push(new _A("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:Amt(l)},m=UE.createProperty("__rewriteFunction",_,s);s.parent.children.push(m)}}rewriteForwardFunction(s){if(!(!oA(s)||!OM(s.value)||typeof s.value.value!="string")&&D3(s,thr)){if(!s.parent||!IM(s.parent)){this.errors.push(new _A("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:Amt(l)},m=UE.createProperty("__rewriteFunction",_,s);s.parent.children.push(m)}}replaceImportStatements(s){if(!oA(s)||!OM(s.value))return;let l=s.value.value;if(typeof l!="string")return;if(!Zmr.some(A=>D3(s,A))&&!Pmt.some(A=>D3(s,A))){if(p8e.test(l)){if(s.name.value==="$ref")return;this.errors.push(new _A("An $import() statement is not expected at this location.",ZG,s.location,l))}return}let _=p8e.exec(l);if(Pmt.some(A=>D3(s,A))&&!_)return;if(!_){this.errors.push(new _A("Invalid $import() statement",ZG,s.location,l));return}let m=_[1];m.startsWith(".")&&(m=Xmr.join("..",m));let b=this.getImportName(m),D={type:Ac.Identifier,parent:s.parent,value:b};s.value=D}replaceEnvStatements=wmt(Qmr,this.errors,ZG)};function Amt(a){return`(request, context) => {
|
|
560
|
+
`&&b++;else if(l)_+=D,b=m+2;else throw new KP(`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(ier,"getStringValue");function ser(a,s,l=!1){switch(s.type){case"Boolean":return a==="true";case"Number":return Number(a);case"String":return ier(a.slice(1,-1),s,l);default:throw new TypeError(`Unknown token type "${s.type}.`)}}t(ser,"getLiteralValue");function dot(a,s){s=Object.freeze({...ner,...s});let l=[],_=new C6e(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>=T_.LineComment?A():br}t(A,"nextSkipComments");let M=s.mode==="json"?D:A;function U(br,mr){if(br!==mr)throw new TO(_.token)}t(U,"assertTokenType");function ie(br,mr){if(!mr.includes(br))throw new TO(_.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=ser(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 T_.String:return ST.string(Pi,Ti);case T_.Number:return ST.number(Pi,Ti);case T_.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,[T_.String,T_.Identifier,T_.Number]):U(br,T_.String);let mr=_.token,Is=br===T_.String?Z(br):Re(mr);if(m&&(Is.type==="NaN"||Is.type==="Infinity")){if(Is.sign!=="")throw new TO(_.token);Is=ST.identifier(Is.type,{loc:Is.loc,...se(Is.loc.start,Is.loc.end)})}br=M(),U(br,T_.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,T_.LBrace);let mr=_.token,Is=[],Pi=M();if(Pi!==T_.RBrace)do{if(Is.push(ke(Pi)),Pi=M(),!Pi)throw new Vce(Is[Is.length-1].loc.end);if(Pi===T_.Comma){if(Pi=M(),b&&Pi===T_.RBrace)break}else break}while(Pi);U(Pi,T_.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,T_.LBracket);let mr=_.token,Is=[],Pi=M();if(Pi!==T_.RBracket)do{let _p=yr(Pi);if(Is.push(ST.element(_p,{loc:_p.loc})),Pi=M(),Pi===T_.Comma){if(Pi=M(),b&&Pi===T_.RBracket)break}else break}while(Pi);U(Pi,T_.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 T_.String:case T_.Boolean:return Z(br);case T_.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 T_.Null:return Pe(mr);case T_.LBrace:return wt(br);case T_.LBracket:return At(br);default:throw new TO(mr)}}t(yr,"parseValue");let zr=yr();if(M())throw new TO(_.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(dot,"parse");var aer=new Map([["Document",["body"]],["Object",["members"]],["Member",["name","value"]],["Element",["value"]],["Array",["elements"]],["String",[]],["Number",[]],["Boolean",[]],["Null",[]],["NaN",[]],["Infinity",[]],["Identifier",[]]]);function mot(a){return a&&typeof a=="object"}t(mot,"isObject");function oer(a){return mot(a)&&typeof a.type=="string"}t(oer,"isNode");function cer(a,s){function l(_,m){typeof s.enter=="function"&&s.enter(_,m);for(let b of aer.get(_.type)){let D=_[b];mot(D)&&(Array.isArray(D)?D.forEach(A=>l(A,_)):oer(D)&&l(D,_))}typeof s.exit=="function"&&s.exit(_,m)}t(l,"visitNode"),l(a)}t(cer,"traverse");function hot(a,s=()=>!0){let l=[];return cer(a,{enter(_,m){l.push({node:_,parent:m,phase:"enter"})},exit(_,m){l.push({node:_,parent:m,phase:"exit"})}}),l.filter(s).values()}t(hot,"iterator");import ler from"fs/promises";var OH=t((a,s)=>a.split(/\r?\n/)[s-1],"getFileLineContent"),Wce=t(async a=>{try{return await ler.readFile(a,"utf-8")}catch{return}},"getSchemaContent"),FH=t(async a=>{try{return dot(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 got=t(async(a,s,l)=>{try{if(a.length===0)return;for(let _ of a){let m=await Wce(_),b=await uer(m,_,s,l);if(b)return b}}catch{}},"getRouteLocationByValue"),uer=t(async(a,s,l,_)=>{try{if(!a)return;let m=null,b=await FH(a);if(b){for(let{node:D}of hot(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 yot from"fs/promises";import Hce from"path";var D6e="schemas",k6e=".oas.json";var xO=t(async a=>(await yot.readdir(a)).map(l=>`${a}/${l}`).filter(l=>l.endsWith(k6e)).sort(),"getOpenApiFilesByAlphabetical"),oM=t(async a=>{let s=Hce.resolve(a,"config");return(await yot.readdir(s)).filter(_=>_.endsWith(k6e)).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),w6e(P6e(l),s,A,_,m,b,D)}t(LH,"chaseRefs");function w6e(a,s,l,_,m,b,D){if(Array.isArray(l))for(let A of l)w6e(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,r3(a,M),_,m,b,D)}w6e(a,s,l[A],_,m,b,D)}}t(w6e,"lookForRefs");function r3(a,s){let l=s.indexOf("#");return l>=0?`${Hce.resolve(a,s.substring(0,l))}${s.substring(l)}`:Hce.resolve(Hce.dirname(a),s)}t(r3,"getFullyQualifiedRefName");function P6e(a){let s=a.indexOf("#");return s>=0?a.substring(0,s):a}t(P6e,"getFilePathNameFromRefName");var A6e=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"}},fer=new A6e,N6e=fer;var QH=up(W4e(),1);var H4e={};dst(H4e,{UnsafePathError:()=>ble,deleteFile:()=>Yir,deleteFolder:()=>ssr,dirExists:()=>Sle,ensureDirectoryExists:()=>esr,fileExists:()=>Kir,getParentDirFilename:()=>rsr,isNotFileOrDirectory:()=>Xir,listFolderContents:()=>Wlt,listFolders:()=>Zir,mkdirForFilePathIfNotExits:()=>Glt,mkdirIfNotExists:()=>Hlt,safePath:()=>tsr,tarFolderContent:()=>nsr,untar:()=>isr});import qlt from"child_process";import u3 from"fs/promises";import l3 from"path";var Vlt=[".git","node_modules",".yarn",".DS_Store"];async function Kir(a){try{return(await u3.stat(a)).isFile()}catch{return!1}}t(Kir,"fileExists");async function Yir(a,s){return await u3.rm(a,s)}t(Yir,"deleteFile");async function Sle(a){try{return(await u3.stat(a)).isDirectory()}catch{return!1}}t(Sle,"dirExists");async function Xir(a){try{return await u3.stat(a),!1}catch{return!0}}t(Xir,"isNotFileOrDirectory");function Qir(a,s){let l=new RegExp(`(.*)(\\/${s})$|(.*)(${s}\\/)`),_=a.match(l);if(!_)return"";let m=a.split(_[0]);return m[1]===""?"":`/${m[1]}`}t(Qir,"getParentDirectory");async function Zir(a){if(!await Sle(a))return[];let s=await u3.readdir(a,{withFileTypes:!0}),l=[];for await(let _ of s)Vlt.includes(_.name)||_.isDirectory()&&l.push(_.name);return l}t(Zir,"listFolders");async function Wlt(a,s,l=!0){let _=Qir(a,s),m=await u3.readdir(a,{withFileTypes:!0}),b=[];for await(let D of m)if(!Vlt.includes(D.name)||!l)if(D.isDirectory()){let A=await Wlt(l3.join(a,D.name),s,l);b.push(...A)}else b.push(l3.join(_,D.name));return b}t(Wlt,"listFolderContents");var Hlt=t(async a=>{if(await Sle(a))return!0;await u3.mkdir(a,{recursive:!0})},"mkdirIfNotExists"),Glt=t(async a=>{let s=l3.dirname(a);return Hlt(s)},"mkdirForFilePathIfNotExits"),esr=Glt,ble=class extends Error{static{t(this,"UnsafePathError")}constructor(s){super(s)}};function tsr(a){let s=t(l=>{if(!l.startsWith(a))throw new ble("Resolved path is not part of the project.");return l},"ensureSafePath");return{resolve:t((...l)=>s(l3.resolve(...l)),"resolve")}}t(tsr,"safePath");function rsr(a){return`${l3.basename(l3.dirname(a))}/${l3.basename(a)}`}t(rsr,"getParentDirFilename");function nsr(a,s,l,_){let m=l3.join(_,l);return qlt.execSync(`tar --exclude='.git/' --exclude='dist/' -czf ${m} ${s}`,{cwd:a}),m}t(nsr,"tarFolderContent");function isr(a,s,l,_=!1){qlt.execSync(`tar -xf ${s} ${_?"--strip-components=1 ":""}-C ${l}`,{cwd:a})}t(isr,"untar");async function ssr(a){if(await Sle(a))return await u3.rm(a,{recursive:!0})}t(ssr,"deleteFolder");var wl=H4e;var CT=up(W4e(),1);import{readFile as asr}from"fs/promises";var IO=class extends Error{static{t(this,"CustomResolveError")}},f3=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:Tle(this.sourceDirectory,this.logger),external:!0,http:!1},dereference:{circular:"ignore",onDereference:l?.onDereference}})}bundle(s){return QH.$RefParser.bundle(s,{resolve:{file:Tle(this.sourceDirectory,this.logger),external:!0,http:!1}})}parse(s){return QH.$RefParser.parse(s,{resolve:{file:Tle(this.sourceDirectory,this.logger),external:!0,http:!1}})}resolve(s){return QH.$RefParser.resolve(s,{resolve:{file:Tle(this.sourceDirectory,this.logger),external:!0,http:!1}})}};function Tle(a,s){return{order:100,canRead(l){let _=lsr(l.url);if(!(_===void 0||_==="file"))return!1;let b;try{b=Klt(l.url)}catch(D){throw new IO(`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{_=Klt(l.url)}catch(m){throw new IO(`Malformed URI: ${l.url}`,{cause:m})}try{return await asr(_)}catch(m){throw new IO(`Error opening file "${_}"`,{cause:m})}}}}t(Tle,"customResolver");var G4e=/^win/.test(globalThis.process?globalThis.process.platform:""),osr=/\//g,csr=/^(\w{2,}):\/\//i,K4e=[/%23/g,"#",/%24/g,"$",/%26/g,"&",/%2C/g,",",/%40/g,"@"];function lsr(a){let s=csr.exec(a);if(s)return s[1].toLowerCase()}t(lsr,"getProtocol");function Klt(a,s){a=decodeURI(a);for(let _=0;_<K4e.length;_+=2)a=a.replace(K4e[_],K4e[_+1]);let l=a.substr(0,7).toLowerCase()==="file://";return l&&(a=a[7]==="/"?a.substr(8):a.substr(7),G4e&&a[1]==="/"&&(a=a[0]+":"+a.substr(1)),s?a="file:///"+a:(l=!1,a=G4e?a:"/"+a)),G4e&&!l&&(a=a.replace(osr,"\\"),a.substr(1,2)===":\\"&&(a=a[0].toUpperCase()+a.substr(1))),a}t(Klt,"toFileSystemPath");var Ylt="YOUR_KEY_HERE";async function Xlt(a){let l=await new f3(a.sourceDirectory,a.logger).bundle(a.openApiDocPath),_=a.openApiDocPath.replace(a.sourceDirectory,"");return usr({...a,relativeOpenApiPath:_},l)}t(Xlt,"buildPublicOpenApiFile");async function usr(a,s){dsr({relativeOpenApiPath:a.relativeOpenApiPath},s);let l=s;return l=_sr(l),fsr(l,a),l=psr(l,a),Qlt(l,"x-zuplo"),l}t(usr,"buildRawOpenApiFile");function fsr(a,{customDomain:s,deploymentName:l,environmentType:_}){let m;s?m=s:_&&l&&(m=_===pce.WORKING_COPY?`${l}.${N6e.ZUP_WORKING_COPY_HOSTNAME}`:`${l}.${N6e.ZUP_HOSTNAME}`),m?a.servers=[{url:`https://${m}`}]:a.servers=void 0}t(fsr,"addServerHost");function _sr(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])=>(HR in A&&dce(A[HR])&&(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(dce(se[HR])){delete M[ie];return}let{parameters:Z}=se;if(!Z)return;let Re=Z.filter(Pe=>{if(HR in Pe&&dce(Pe[HR]))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(_sr,"removeHiddenRoutesAndParams");function psr(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} ${Ylt}`:Ylt,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(psr,"enrichSpecWithZuploData");function Qlt(a,s){for(let l in a)l.startsWith(s)?delete a[l]:typeof a[l]=="object"&&Qlt(a[l],s)}t(Qlt,"removePropertiesByPrefix");function dsr({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(dsr,"assertIsZuploOpenApiSpec");function msr(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(msr,"base");var Zlt=msr;var hsr="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",xle=Zlt(hsr);var Y4e="2024-09-02",eut=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 tut(){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:Y4e,ENVIRONMENT_TYPE:"mock-environment-type",GIT_SHA:void 0,IS_LOCAL_DEVELOPMENT:!1,COMPATIBILITY_FLAGS:eut[Y4e]},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(tut,"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=tut()),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(xle.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 gsr=["ZUPLO_USER_LOGGER_DATA_DOG_API_KEY","ZUPLO_USER_LOGGER_DATA_DOG_URL","ZUPLO_LOG_LEVEL","ZUPLO_HANDLER_WRITE_LOG_LEVEL"];function rut(a){return a.startsWith("__ZUPLO")||a.startsWith("ZUPLO_")?!gsr.includes(a)&&!a.startsWith("ZUPLO_PUBLIC_"):!1}t(rut,"isRestrictedEnvVariableName");function nut(a){return!!a.startsWith("ZUPLO_")}t(nut,"isZuploReadableEnvVariableName");var NIr=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(!(rut(l)&&!nut(l)))return DT.instance.runtime[l]}});function ZH(a,s,l){return`_${eA(`${a}_${s}_${l}`)}`}t(ZH,"getRawOperationDataIdentifierName");function X4e(a,s,l,_){return`_${eA(a.toLowerCase())}_${s.toLowerCase()}_${l.toLowerCase()}_${_.toLowerCase()}`}t(X4e,"getIdForParameterSchema");function Q4e(a,s,l){return`_${eA(a.toLowerCase())}_${s.toLowerCase()}_rb_${eA(l.toLowerCase())}`}t(Q4e,"getIdForRequestBodySchema");function eG(a,s){return`_${eA(a)}_${eA(s)}`}t(eG,"getIdForRefSchema");function eA(a){return a.replace(/[^a-zA-Z0-9]/g,"_")}t(eA,"sanitizedIdentifierName");var Lmt=up(Hft(),1);import Kue 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"}},fcr=/[$_\p{ID_Start}]/u,_cr=/[$_\u200C\u200D\p{ID_Continue}]/u,W3e=".*";function pcr(a,s){return(s?/^[\x00-\xFF]*$/:/^[\x00-\x7F]*$/).test(a)}t(pcr,"Re");function Yft(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&&fcr.test(M)||A!==_+1&&_cr.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(!pcr(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(Yft,"v");function Xft(a,s={}){let l=Yft(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=W3e:Pi=hn:Pi=_;let Po=2;Pi===_?(Po=1,Pi=""):Pi===W3e&&(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(Xft,"D");function AT(a){return a.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}t(AT,"S");function Gft(a){return a&&a.ignoreCase?"ui":"u"}t(Gft,"X");function dcr(a,s,l){return Qft(Xft(a,l),s,l)}t(dcr,"Z");function NM(a){switch(a){case 0:return"*";case 1:return"?";case 2:return"+";case 3:return""}}t(NM,"k");function Qft(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)})${NM(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=W3e),!A.prefix.length&&!A.suffix.length){A.modifier===3||A.modifier===1?_+=`(${U})${NM(A.modifier)}`:_+=`((?:${U})${NM(A.modifier)})`;continue}if(A.modifier===3||A.modifier===1){_+=`(?:${AT(A.prefix)}(${U})${AT(A.suffix)})`,_+=NM(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(_,Gft(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(_,Gft(l))}t(Qft,"F");var m3={delimiter:"",prefixes:"",sensitive:!0,strict:!0},mcr={delimiter:".",prefixes:"",sensitive:!0,strict:!0},hcr={delimiter:"/",prefixes:"/",sensitive:!0,strict:!0};function gcr(a,s){return a.length?a[0]==="/"?!0:!s||a.length<2?!1:(a[0]=="\\"||a[0]=="{")&&a[1]=="/":!1}t(gcr,"J");function Zft(a,s){return a.startsWith(s)?a.substring(s.length,a.length):a}t(Zft,"Q");function ycr(a,s){return a.endsWith(s)?a.substr(0,a.length-s.length):a}t(ycr,"Ee");function e_t(a){return!a||a.length<2?!1:a[0]==="["||(a[0]==="\\"||a[0]==="{")&&a[1]==="["}t(e_t,"W");var t_t=["ftp","file","http","https","ws","wss"];function r_t(a){if(!a)return!0;for(let s of t_t)if(a.test(s))return!0;return!1}t(r_t,"N");function vcr(a,s){if(a=Zft(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(vcr,"te");function bcr(a,s){if(a=Zft(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(bcr,"re");function Scr(a,s){return s||a===""?a:e_t(a)?s_t(a):i_t(a)}t(Scr,"ne");function Tcr(a,s){if(s||a==="")return a;let l=new URL("https://example.com");return l.password=a,l.password}t(Tcr,"se");function xcr(a,s){if(s||a==="")return a;let l=new URL("https://example.com");return l.username=a,l.username}t(xcr,"ie");function Ecr(a,s,l){if(l||a==="")return a;if(s&&!t_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(Ecr,"ae");function Ccr(a,s,l){return n_t(s)===a&&(a=""),l||a===""?a:a_t(a)}t(Ccr,"oe");function Dcr(a,s){return a=ycr(a,":"),s||a===""?a:H3e(a)}t(Dcr,"ce");function n_t(a){switch(a){case"ws":case"http":return"80";case"wws":case"https":return"443";case"ftp":return"21";default:return""}}t(n_t,"_");function H3e(a){if(a==="")return a;if(/^[-+.A-Za-z0-9]*$/.test(a))return a.toLowerCase();throw new TypeError(`Invalid protocol '${a}'.`)}t(H3e,"y");function kcr(a){if(a==="")return a;let s=new URL("https://example.com");return s.username=a,s.username}t(kcr,"le");function wcr(a){if(a==="")return a;let s=new URL("https://example.com");return s.password=a,s.password}t(wcr,"fe");function i_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(i_t,"z");function s_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(s_t,"j");function a_t(a){if(a===""||/^[0-9]*$/.test(a)&&parseInt(a)<=65535)return a;throw new TypeError(`Invalid port '${a}'.`)}t(a_t,"K");function Pcr(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(Pcr,"he");function Acr(a){return a===""?a:new URL(`data:${a}`).pathname}t(Acr,"ue");function Ncr(a){if(a==="")return a;let s=new URL("https://example.com");return s.search=a,s.search.substring(1,s.search.length)}t(Ncr,"de");function Icr(a){if(a==="")return a;let s=new URL("https://example.com");return s.hash=a,s.hash.substring(1,s.hash.length)}t(Icr,"pe");var Ocr=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=Yft(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,m3),a.encodePart=H3e;let s=dcr(this.#T(),void 0,a);this.#l=r_t(s)}},V3e=["protocol","username","password","hostname","port","pathname","search","hash"],d3="*";function Kft(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(Kft,"ge");function sA(a,s){return s?mG(a):a}t(sA,"b");function dG(a,s,l){let _;if(typeof s.baseURL=="string")try{_=new URL(s.baseURL),s.protocol===void 0&&(a.protocol=sA(_.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=sA(_.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=sA(_.password,l)),s.protocol===void 0&&s.hostname===void 0&&(a.hostname=sA(_.hostname,l)),s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&(a.port=sA(_.port,l)),s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.pathname===void 0&&(a.pathname=sA(_.pathname,l)),s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.pathname===void 0&&s.search===void 0&&(a.search=sA(_.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=sA(_.hash.substring(1,_.hash.length),l))}catch{throw new TypeError(`invalid baseURL '${s.baseURL}'.`)}if(typeof s.protocol=="string"&&(a.protocol=Dcr(s.protocol,l)),typeof s.username=="string"&&(a.username=xcr(s.username,l)),typeof s.password=="string"&&(a.password=Tcr(s.password,l)),typeof s.hostname=="string"&&(a.hostname=Scr(s.hostname,l)),typeof s.port=="string"&&(a.port=Ccr(s.port,a.protocol,l)),typeof s.pathname=="string"){if(a.pathname=s.pathname,_&&!gcr(a.pathname,l)){let m=_.pathname.lastIndexOf("/");m>=0&&(a.pathname=sA(_.pathname.substring(0,m+1),l)+a.pathname)}a.pathname=Ecr(a.pathname,a.protocol,l)}return typeof s.search=="string"&&(a.search=bcr(s.search,l)),typeof s.hash=="string"&&(a.hash=vcr(s.hash,l)),a}t(dG,"w");function mG(a){return a.replace(/([+*?:{}()\\])/g,"\\$1")}t(mG,"C");function Fcr(a){return a.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}t(Fcr,"Oe");function Lcr(a,s){s.delimiter??="/#?",s.prefixes??="./",s.sensitive??=!1,s.strict??=!1,s.end??=!0,s.start??=!0,s.endsWith="";let l=".*",_=`[^${Fcr(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)}}${NM(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+=NM(A.modifier))}return b}t(Lcr,"ke");var o_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 Ocr(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:d3,protocol:d3,username:d3,password:d3,hostname:d3,port:d3,search:d3,hash:d3};this.#r=dG(b,a,!0),n_t(this.#r.protocol)===this.#r.port&&(this.#r.port="");let D;for(D of V3e){if(!(D in this.#r))continue;let A={},M=this.#r[D];switch(this.#e[D]=[],D){case"protocol":Object.assign(A,m3),A.encodePart=H3e;break;case"username":Object.assign(A,m3),A.encodePart=kcr;break;case"password":Object.assign(A,m3),A.encodePart=wcr;break;case"hostname":Object.assign(A,mcr),e_t(M)?A.encodePart=s_t:A.encodePart=i_t;break;case"port":Object.assign(A,m3),A.encodePart=a_t;break;case"pathname":r_t(this.#n.protocol)?(Object.assign(A,hcr,m),A.encodePart=Pcr):(Object.assign(A,m3,m),A.encodePart=Acr);break;case"search":Object.assign(A,m3,m),A.encodePart=Ncr;break;case"hash":Object.assign(A,m3,m),A.encodePart=Icr;break}try{this.#s[D]=Xft(M,A),this.#n[D]=Qft(this.#s[D],this.#e[D],A),this.#t[D]=Lcr(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,Kft(a,s),!1)}catch{return!1}let _;for(_ of V3e)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,Kft(a,s),!1)}catch{return null}let _={};s?_.inputs=[a,s]:_.inputs=[a];let m;for(m of V3e){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=o_t);import{AssertionError as Rcr}from"assert";function aA(a,s){if(a===!1)throw new Rcr({message:s})}t(aA,"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 IM(a){return a.type===Ac.Object}t(IM,"isAstObject");function oA(a){return a.type===Ac.Property}t(oA,"isAstProperty");function c_t(a){return a.type===Ac.Array}t(c_t,"isAstArray");function OM(a){return a.type===Ac.Literal}t(OM,"isAstLiteral");function BO(a){if(a===void 0)throw new Error("Node is undefined");if(!IM(a))throw new Error("Node is not object")}t(BO,"assertAstObject");import{findNodeAtLocation as Mcr,getNodeValue as jcr,printParseErrorCode as Bcr,visit as Ucr}from"jsonc-parser";var $cr={DEFAULT:{allowTrailingComma:!1}};function gG(a,s=[],l=$cr.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"),Ucr(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:Jcr(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 Jcr(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(Jcr,"getNodeType");function G3e(a,s){return Mcr(a,s)}t(G3e,"findNodeAtLocation");function yG(a){return jcr(a)}t(yG,"getNodeValue");function l_t(a){return Bcr(a)}t(l_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){aA(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 UE={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(UE.createLiteral(_,l));return l},"createArrayOfLiterals")};var zcr=/^[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 _=zcr.test(l.value)?l.value:`'${l.value}'`;s.push(_)}};import{parse as qcr}from"@swc/core";import Vcr from"fs/promises";var u_t=t(async a=>{let s=new Set;try{let l=await Vcr.readFile(a,"utf-8");(await qcr(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 f_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 K3e={$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 __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 Y3e={$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 X3e={$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 Cmt=up(Gdt(),1),Dmt=up(Emt(),1);var $ue=class a{static{t(this,"JsonValidator")}static#r=new a;static get instance(){return a.#r}ajv;constructor(){this.ajv=new Dmt.Ajv2020({allErrors:!0,allowUnionTypes:!0}),this.ajv.addKeyword("faker"),(0,Cmt.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 C3=$ue.instance;C3.addSchema(X3e,"route-configuration.schema.json");C3.addSchema(__t,"policy-configuration.schema.json");C3.addSchema(K3e,"policies.schema.json");C3.addSchema(Y3e,"open-api-route-configuration.schema.json");C3.addSchema(f_t,"fragments.schema.json");var A5r=C3.compile(X3e),kmt=C3.compile(Y3e),_8e=C3.compile(K3e);var Jue=class{static{t(this,"PoliciesConfigurationValidator")}results;validate(s){return this.results=_8e(s),this.results}};var zue=class{static{t(this,"OpenAPILocalizedValidator")}results;validate(s){return this.results=kmt(s),this.results}};import Xmr from"path";var p8e=/\$import\((.*)\)/,que=/\$env\((.*?)\)/g;var _A=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:""}}},Ymr=t(a=>{let s=[],l=a;for(;l.parent;)s.push(l),l=l.parent;return s.reverse()},"invertTree"),D3=t((a,s)=>{if(!a)return!1;let l=Ymr(a);return s.split("/").every((b,D)=>{let A=l[D];return A?b==="*"||oA(A)&&A.name.value===b?!0:b==="{}"?A.type===Ac.Object:b==="[]"?A.type===Ac.Array:!1:!1})},"testPosition");var Vue=class{static{t(this,"AstTransformer")}errors=[];transform(s){return this.visitor(s),s}visitor(s){this.visit(s),IM(s)?s.children.forEach(l=>{this.visitor(l)}):c_t(s)?s.children.forEach(l=>{this.visitor(l)}):oA(s)&&this.visitor(s.value)}},wmt=t((a,s,l)=>_=>{if(!oA(_)||!OM(_.value)||typeof _.value.value!="string")return;if(!a.some(b=>D3(_,b))){que.test(_.value.value)&&s.push(new _A("An $env() statement is not expected at this location.",l,_.location,_.value.value));return}let m=new RegExp(que).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(que),(D,A)=>`\${environment["${A}"] ? environment["${A}"] : ""}`);b!==_.value.value&&(_.value=UE.createTemplateString(b,_))}},"getEnvStatementTransformer");var ZG="config/routes.json",Qmr=["handler/{}/options/*","policies/[]/{}/handler/{}/options/*","corsPolicies/[]/{}/*"],Zmr=["handler/{}/module","handler/{}/options/{}/policies/{}/inbound/[]/{}/module","handler/{}/options/{}/policies/{}/outbound/[]/{}/module","policies/[]/{}/handler/{}/module","policies/[]/{}/handler/{}/options/{}/identifier/{}/module","policies/[]/{}/handler/{}/options/{}/validator"],Pmt=["handler/{}/options/*","policies/[]/{}/handler/{}/options/*"],ehr="handler/{}/options/{}/rewritePattern",thr="handler/{}/options/{}/baseUrl",Wue=class extends Vue{static{t(this,"OpenAPIRoutesFragmentAstTransformer")}importCount=0;addedImports=new Map;getImportName(s){this.addedImports.has(s)||this.addedImports.set(s,`__import${this.importCount++}`);let l=this.addedImports.get(s);if(!l)throw new Error("Import name is undefined. This should not happen.");return l}getImports(){let s=[];return this.addedImports.forEach((l,_)=>{s.push({name:l,path:_})}),s}visit(s){this.rewriteHandlerFunction(s),this.rewriteForwardFunction(s),this.replaceImportStatements(s),this.replaceEnvStatements(s)}rewriteHandlerFunction(s){if(!(!oA(s)||!OM(s.value)||typeof s.value.value!="string")&&D3(s,ehr)){if(!s.parent||!IM(s.parent)){this.errors.push(new _A("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:Amt(l)},m=UE.createProperty("__rewriteFunction",_,s);s.parent.children.push(m)}}rewriteForwardFunction(s){if(!(!oA(s)||!OM(s.value)||typeof s.value.value!="string")&&D3(s,thr)){if(!s.parent||!IM(s.parent)){this.errors.push(new _A("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:Amt(l)},m=UE.createProperty("__rewriteFunction",_,s);s.parent.children.push(m)}}replaceImportStatements(s){if(!oA(s)||!OM(s.value))return;let l=s.value.value;if(typeof l!="string")return;if(!Zmr.some(A=>D3(s,A))&&!Pmt.some(A=>D3(s,A))){if(p8e.test(l)){if(s.name.value==="$ref")return;this.errors.push(new _A("An $import() statement is not expected at this location.",ZG,s.location,l))}return}let _=p8e.exec(l);if(Pmt.some(A=>D3(s,A))&&!_)return;if(!_){this.errors.push(new _A("Invalid $import() statement",ZG,s.location,l));return}let m=_[1];m.startsWith(".")&&(m=Xmr.join("..",m));let b=this.getImportName(m),D={type:Ac.Identifier,parent:s.parent,value:b};s.value=D}replaceEnvStatements=wmt(Qmr,this.errors,ZG)};function Amt(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,12 +589,12 @@ 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 qmt(a,s){let l=new g8e(s);return l.generator[a.type](a,l),l.output}t(qmt,"generate");import Chr from"fs/promises";import Dhr from"path";async function y8e({oasFiles:a,sourceDirectory:s,logger:l}){let _=await khr({oasFiles:a,sourceDirectory:s,logger:l});return qmt(_)}t(y8e,"generateRawRouteSource");async function khr({oasFiles:a,sourceDirectory:s,logger:l}){let _=new f3(s,l),m=[];for(let D of a){let A=Dhr.basename(D,".oas.json"),M=await _.resolve(D),U=[],ie=new Map,se=await Chr.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=Que(D,A,At,M,U,ie);m.unshift(Wmt(yr,zr))}}m.unshift(...whr(A,M,U,ie).reverse())}return{type:"Program",body:m,sourceType:"module"}}t(khr,"generateAst");function Que(a,s,l,_,m,b){let D=[];for(let A in l){let M=l[A];if(A==="$ref")return LH(a,s,r3(a,M),_,m,b),{type:"Identifier",name:Hmt(s,b.get(r3(a,M)))};let U;switch(typeof M){case"string":case"number":case"boolean":U={type:"Literal",value:M};break;default:Array.isArray(M)?U=Vmt(M,a,s,_,m,b):typeof M=="object"&&M!==null&&(U={type:"ObjectExpression",properties:Que(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(Que,"processNode");function Vmt(a,s,l,_,m,b){return{type:"ArrayExpression",elements:a.map(D=>{if(Array.isArray(D))return Vmt(D,s,l,_,m,b);if(typeof D=="object"&&D!==null){let A=Que(s,l,D,_,m,b);return A.type==="Identifier"?A:{type:"ObjectExpression",properties:A.properties||[]}}else return{type:"Literal",value:D}})}}t(Vmt,"processArray");function Wmt(a,s){return{type:"ExportNamedDeclaration",declaration:{type:"VariableDeclaration",declarations:[{type:"VariableDeclarator",id:{type:"Identifier",name:a},init:s}],kind:"var"},specifiers:[],source:null}}t(Wmt,"createExportedConstAssignment");function whr(a,s,l,_){let m=[];for(let b=0;b<l.length;b++){let D=Hmt(a,b),A=s.get(l[b]),M=Que(P6e(l[b]),a,A,s,l,_);m.push(Wmt(D,M))}return m}t(whr,"generateRefs");function Hmt(a,s){return`${eA(a)}__ref__${s}`}t(Hmt,"getRefIdentifierName");import Gmt from"path";var Kmt=t(a=>{let s=null;if(a.value.type==="Object"&&a.value.members.length>0)for(let l of a.value.members){let _=Kmt(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"),Phr=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"),v8e=t(async(a,s,l)=>{if(!a)return null;let _={file:Gmt.join(D6e,a),suggestion:Phr(l)},m=Gmt.join(s,D6e),b=wl.safePath(s).resolve(m,a),D=await Wce(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=Kmt(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 $yt from"esbuild";import{performance as Zue,PerformanceObserver as Ahr}from"perf_hooks";var b8e=[];async function Nhr(a,s){let l=Zue.timerify(s),_=new Ahr(m=>{let b=m.getEntries()[0];b8e.push({name:a,duration:b.duration}),_.disconnect()});return _.observe({entryTypes:["function"]}),l()}t(Nhr,"timeFn");var Ihr={mark:t(a=>{Zue.mark(a)},"mark"),measure:t((a,s,l)=>{Zue.measure(a,s,l)},"measure"),timeFn:Nhr,report:t(()=>{b8e.length>0&&console.table(b8e)},"report"),getDuration:t(a=>{let s=Zue.getEntriesByName(a);return s.length===0?0:s[0].duration},"getDuration")},zf=Ihr;var Ohr=!1;function tj(a,s){return{open:`\x1B[${a.join(";")}m`,close:`\x1B[${s}m`,regexp:new RegExp(`\\x1b\\[${s}m`,"g")}}t(tj,"code");function rj(a,s){return Ohr?`${s.open}${a.replace(s.regexp,s.open)}${s.close}`:a}t(rj,"run");function Fhr(a){return rj(a,tj([31],39))}t(Fhr,"red");function Lhr(a){return rj(a,tj([32],39))}t(Lhr,"green");function Rhr(a){return rj(a,tj([33],39))}t(Rhr,"yellow");function Mhr(a){return rj(a,tj([34],39))}t(Mhr,"blue");function jhr(a){return rj(a,tj([35],39))}t(jhr,"magenta");function Bhr(a){return rj(a,tj([36],39))}t(Bhr,"cyan");var H9r=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 Ymt=[Fhr,Lhr,Rhr,Mhr,jhr,Bhr];function Uhr(a){let s=0,l=a.length,_=0;if(l>0)for(;_<l;)s=(s<<5)-s+a.charCodeAt(_++)|0;return s}t(Uhr,"hashCode");function Xmt(a){let s=Math.abs(Uhr(a));return Ymt[s%Ymt.length]}t(Xmt,"generateColor");import{inspect as $hr}from"util";function Qmt(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(Qmt,"format");var Zmt=t((a,...s)=>Qmt($hr,a,s),"format");var S8e=class{static{t(this,"Debugger")}manager;ns;color;last;enabled;constructor(s,l){this.manager=s,this.ns=l,this.color=Xmt(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=Zmt(l,...s);let b=`${this.color(this.ns)} ${l} ${this.color(`+${m}ms`)}`;console.log(b),this.last=Date.now()}},T8e=class{static{t(this,"DebugManager")}debuggers;enabled;constructor(s){this.debuggers=new Map,this.enabled=s??[]}};function Jhr(a){return!a||a.length===0?[]:(a=a.replace(/\s/g,"").replace(/\*/g,".+"),a.split(",").map(s=>new RegExp(`^${s}$`)))}t(Jhr,"extract");var efe;function eht(a){efe||(efe=new T8e(Jhr(process.env.DEBUG)));let s=new S8e(efe,a);return efe.debuggers.set(a,s),Object.assign(s.log.bind(s),{self:s})}t(eht,"debug");import VFe,{dirname as jyt}from"path";import{fileURLToPath as Byt}from"url";var x8e=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"}},zhr=new x8e,ph=zhr;var E8e="no-remote-module";function tht({logger:a}){return{name:E8e,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:E8e,location:{line:0,column:0,file:""}}],pluginName:E8e}))}}}t(tht,"blockRemoteModulePlugin");import Whr from"fs/promises";import tfe from"path";import{writeFile as qhr}from"fs/promises";async function sk(a,s){await wl.mkdirForFilePathIfNotExits(a);let l=await import("prettier"),_=s;try{_=await l.format(s,{parser:"babel"})}catch{}await qhr(a,_,"utf-8")}t(sk,"writeDebugSourceFile");import rht from"path";var Vhr=["zudoku.config.ts","zudoku.config.tsx","zudoku.config.js","zudoku.config.jsx","zudoku.config.mjs"];async function nht(a){if(await wl.fileExists(`${a}/config/dev-portal.json`))return"dev-portal";for(let s of Vhr)if(await wl.fileExists(`${a}/docs/${s}`))return"zudoku"}t(nht,"getDevPortalType");function nj(a,s){let l=rht.relative(process.cwd(),rht.join(a,GR));return Object.keys(s?.outputs??{}).map(m=>`.${m.replace(l,"")}`)}t(nj,"getBuildModules");var iht="/docs",Hhr="/__zuplo/dev-portal";function Ghr(a){let s=a.trim().toLowerCase();return s.endsWith("/")&&(s=s.slice(0,-1)),s}t(Ghr,"normalizePathname");function Khr(a){let s={sitePathname:a?.sitePathname===Hhr?iht:a?.sitePathname?Ghr(a.sitePathname):iht,enabled:a?a.enabled??!0:!1,version:a?.version??"legacy"};return`const devPortal = ${JSON.stringify(s)};
|
|
591
591
|
export default devPortal;`}t(Khr,"generateSource");function sht(a){return{name:"dev-portal-config",setup(s){s.onResolve({filter:/dev-portal.json$/},l=>({namespace:"dev-portal-json",path:tfe.isAbsolute(l.path)?l.path:tfe.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 nht(a.sourceDirectory);if(D==="zudoku")_={version:"zudoku",enabled:!0,sitePathname:"/docs"};else if(D==="dev-portal"){m=await Whr.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=Khr(_),ph.DEBUG_BUILD_MODE&&A){let M=tfe.join(a.sourceDirectory,".zuplo","dev-portal.js");await sk(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:tfe.dirname(l.path),watchFiles:[l.path]}}))}}}t(sht,"devPortalConfigPlugin");import aht from"path";var oht="legacy-environment",cht="legacy-environment",Yhr=`import { environment } from "@zuplo/runtime";
|
|
592
|
-
export default environment;`;function lht(a){return{name:"environment",setup(s){s.onResolve({filter:/@app\/environment$/},()=>({namespace:cht,pluginName:oht,path:aht.join(a.sourceDirectory,Q4,"environment.js")})),s.onLoad({filter:/.*/,namespace:cht},async l=>({contents:Yhr,loader:"ts",resolveDir:aht.dirname(l.path),pluginName:oht}))}}}t(lht,"environmentPlugin");var byt=up(pFe(),1),Syt=up(J0t(),1),Tyt=up(jFe(),1),xyt=up(BFe(),1);import K2r from"fs/promises";import z2 from"path";var _k="schemas",Mfe="json-schema";function Eyt(a){return{name:_k,async setup(s){let l=new Tyt.Ajv2020({code:{source:!0},allErrors:!0,strict:!1,verbose:!0,meta:!0});(0,Syt.default)(l,{mode:"fast"}),l.opts.code.formats=byt._`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 K2r.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:_k,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:_k,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 v8e(A,a.sourceDirectory,M.message);b.push({id:"json-schema-add-error",pluginName:_k,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 v8e(A,a.sourceDirectory,M.message);b.push({id:"json-schema-compile-error",pluginName:_k,text:`The schema file '${A}' is not valid. Error: ${M.message}`,location:U,detail:"InvalidSchemaError",notes:[{text:M.message}]})}})),ph.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:Mfe,line:1,column:0,length:0,lineText:`Invalid JSON schema reference in ${U}`,suggestion:""},detail:"RouteReferenceError",pluginName:_k,notes:[{text:`Unable to resolve reference to '${A.path}' from ${U}`,location:null}]}],namespace:Mfe,path:M,pluginName:_k}}return{path:M,namespace:Mfe,pluginName:_k}}),s.onLoad({filter:/.*/,namespace:Mfe},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,xyt.default)(l,Z)}catch(ie){M.push({pluginName:_k,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(ph.DEBUG_BUILD_MODE&&U){let ie=z2.relative(_,A.path),se=z2.join(a.sourceDirectory,".zuplo",`${ie}.js`);await sk(se,U)}return{contents:U,errors:M,pluginName:_k,resolveDir:z2.dirname(A.path),watchFiles:[A.path]}}))}}}t(Eyt,"jsonSchemaPlugin");import{relative as Y2r}from"path";var Cyt=["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"],X2r="nodejs-compat-plugin";function Dyt({sourceDirectory:a}){return{name:X2r,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?Cyt.includes(_)||_.includes("/")&&Cyt.includes(_.split("/")[0])?{external:!0}:{external:!0,warnings:M.errors.map(ie=>({...ie,location:{file:Y2r(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(Dyt,"nodejsCompatPlugin");import kyt from"fs/promises";import ZE from"path";var Cj="open-api-routes-plugin",jfe="open-api-routes-json";function wyt(a){return{name:"open-api-routes-plugin",setup(s){s.onResolve({filter:/routes.json$/},l=>({watchFiles:[...UFe(ZE.join(a.sourceDirectory,j2),[".oas.json"],!0),ZE.join(a.sourceDirectory,j2,mce)],namespace:jfe,path:ZE.isAbsolute(l.path)?l.path:ZE.join(l.resolveDir,l.path),pluginName:Cj})),s.onResolve({filter:/^\.\.\/modules\/.*/,namespace:jfe},async l=>{let _=ZE.join(l.resolveDir,`${l.path}.ts`);if(!await wl.fileExists(_)){let m=`$import(.${l.path.replace(/^../,"")})`,b=ZE.resolve(a.sourceDirectory,"config"),D=await xO(b),A=await got(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:Cj}],namespace:jfe,path:l.path,pluginName:Cj}}}),s.onLoad({filter:/.*/,namespace:jfe},async l=>zf.timeFn("Generating route.json data",async()=>{let _=ZE.resolve(a.sourceDirectory,"config"),m=await xO(_),b=await Promise.all(m.map(async U=>({content:await kyt.readFile(U,"utf-8"),fileName:U}))),D=ZE.resolve(_,"policies.json");if(!await wl.fileExists(D))return{errors:[{text:"The project must include a policies file ('/config/policies.json')",detail:"OASPoliciesFileMissing",pluginName:Cj,location:{line:0,column:0,file:"/config/policies.json"}}],pluginName:Cj};let A={content:await kyt.readFile(D,"utf-8"),fileName:D},M;try{M=await m8e({sourceDirectory:a.sourceDirectory,oasContent:b,policiesContent:A})}catch(U){throw new Error("Error compiling routes: "+U.message)}if(ph.DEBUG_BUILD_MODE&&M.content){let U=ZE.join(a.sourceDirectory,".zuplo"),ie=ZE.resolve(U,"routes.js");await sk(ie,M.content)}return{contents:M.content,errors:M.errors,pluginName:Cj,resolveDir:ZE.dirname(l.path),watchFiles:[l.path]}}))}}}t(wyt,"openApiRoutesPlugin");import Bfe from"path";var IK="raw-route-plugin",Pyt="raw-route";function Ayt(a){return{name:"raw-route-plugin",setup(s){s.onResolve({filter:/raw.json$/},l=>({namespace:Pyt,path:l.path,pluginName:IK})),s.onLoad({filter:/.*/,namespace:Pyt},async l=>{let _=Bfe.resolve(a.sourceDirectory,j2);if(!await wl.dirExists(_))return{loader:"js",resolveDir:Bfe.dirname(l.path),pluginName:IK};let m=await xO(_);try{let b=await y8e({oasFiles:m,sourceDirectory:a.sourceDirectory,logger:a.logger});if(ph.DEBUG_BUILD_MODE&&b){let D=Bfe.join(a.sourceDirectory,".zuplo","raw-routes.js");await sk(D,b)}return{contents:b,loader:"js",resolveDir:Bfe.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(Ayt,"rawRoutePlugin");import Q2r from"fs/promises";import $Fe from"path";var Ufe="runtime-config",Nyt="runtime-config-plugin";function Iyt(){return{name:Ufe,setup(a){a.onResolve({filter:/^\.\.\/modules\/zuplo.runtime.ts$/},s=>({namespace:Nyt,path:$Fe.isAbsolute(s.path)?s.path:$Fe.join(s.resolveDir,s.path),pluginName:Ufe})),a.onLoad({filter:/.*/,namespace:Nyt},async s=>zf.timeFn("Generating zuplo.runtime.ts data",async()=>{let l="export const runtimeInit = undefined;",_=[];return await wl.fileExists(s.path)?(l=await Q2r.readFile(s.path,"utf-8"),{contents:l,loader:"ts",resolveDir:$Fe.dirname(s.path),errors:_,pluginName:Ufe,watchFiles:[s.path]}):{contents:l,loader:"ts",errors:_,pluginName:Ufe}}))}}}t(Iyt,"runtimeConfigPlugin");var Fyt=up(jFe(),1),Lyt=up(BFe(),1);import qFe from"fs/promises";import cF from"path";var JFe="schema-validation-plugin",Oyt="schema-validation",Z2r="module.exports = {}";function Ryt(a){return{name:"schema-validation-plugin",setup(s){s.onResolve({filter:/ajv-schema.json$/},l=>({namespace:Oyt,path:l.path,pluginName:JFe})),s.onLoad({filter:/.*/,namespace:Oyt},async l=>{let _=cF.resolve(a.sourceDirectory,j2,"policies.json");if(!await wl.fileExists(_))return{contents:Z2r,loader:"js",resolveDir:cF.dirname(l.path),pluginName:JFe};let m=await tSr(a.sourceDirectory),b=cF.resolve(a.sourceDirectory,j2),D=await xO(b),A=await sSr(D,m),M=await eSr({oasFiles:D,routesWithSchemaValidation:A,sourceDirectory:a.sourceDirectory,logger:a.logger});if(ph.DEBUG_BUILD_MODE&&M){let U=cF.join(a.sourceDirectory,".zuplo","schema-validation.js");await sk(U,M)}return{contents:M,loader:"js",resolveDir:cF.dirname(l.path),pluginName:JFe}})}}}t(Ryt,"schemaValidationPlugin");async function eSr({oasFiles:a,routesWithSchemaValidation:s,sourceDirectory:l,logger:_}){let m="",b=new f3(l,_);if(s.length===0)return m;let D=new Fyt.Ajv2020({code:{source:!0},allErrors:!0,strict:!1,verbose:!0,meta:!0});for(let A of a){let M=await qFe.readFile(A,"utf-8"),U=cF.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=Q4e(ke.path,ke.method,yr);zr.$id=en,D.addSchema(zr),zFe(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=X4e(ke.path,ke.method,yr.in,yr.name);zr.$id=en,D.addSchema(zr),zFe(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,Lyt.default)(D),m}t(eSr,"schemaValidationSource");function zFe(a,s,l,_,m,b,D){for(let A in a){let M=a[A];if(A==="$ref"){let U=eG(l,r3(s,M));a[A]=U,LH(s,l,r3(s,M),m,b,D,(ie,se)=>eG(ie,r3(s,se)))}else typeof M=="object"&&zFe(M,s,l,_,m,b,D)}}t(zFe,"addRefsToSchema");async function tSr(a){let s=new Set(["RequestValidationInboundPolicy"]),l=await qFe.readFile(`${a}/config/policies.json`,"utf-8"),_=JSON.parse(l);return rSr(_,s)}t(tSr,"getPolicyNamesUsingSchemaValidationPolicies");function rSr(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 _=nSr(a,l);return new Set([...l,..._])}t(rSr,"getPolicyNamesReferencingPolicyHandlers");function nSr(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(nSr,"getCompositePoliciesContainingPolicy");function iSr(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(iSr,"isPolicyPresentInOperation");async function sSr(a,s){let l=[];for(let _ of a){let m=await qFe.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];iSr(ie,s)&&l.push({fileName:cF.basename(_,".oas.json"),path:A,method:U})}}}return l}t(sSr,"getRoutesContainingPolicies");import{mkdirSync as aSr,writeFileSync as oSr}from"fs";import cSr from"path";function Myt(a){return{name:"write-modules-plugin",setup(s){s.onEnd(async l=>{if(l){let _=nj(a.sourceDirectory,l.metafile);aSr(a.outputDirectory,{recursive:!0}),oSr(cSr.join(a.outputDirectory,"modules.json"),JSON.stringify(_,null,2))}})}}}t(Myt,"writeModulesPlugin");var lSr=eht("zuplo:core:build"),uSr=["workerd","worker","browser"],Uyt=[...process.env.GLOBAL_MODULE_LOCATION?[process.env.GLOBAL_MODULE_LOCATION]:[],VFe.resolve(jyt(Byt(import.meta.url)),"..","..","..","node_modules"),VFe.resolve(jyt(Byt(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=VFe.join(a,gce);lSr(`Building with node paths: ${Uyt.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:ph.DEBUG_BUILD_MODE,flags:A};return{platform:"browser",target:"es2022",outdir:s,splitting:!0,metafile:!0,format:"esm",nodePaths:Uyt,entryPoints:[M],sourcemap:"linked",legalComments:"none",treeShaking:!0,bundle:!0,...U,external:[],logLevel:"silent",conditions:uSr,plugins:[lht(ie),tht(ie),wyt(ie),Ayt(ie),Ryt(ie),Iyt(),sht(ie),Eyt(ie),Dyt(ie),Myt(ie)]}}t(OK,"getBaseESBuildConfig");var lF="run-esbuild",Jyt=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 oM(l))throw new Error("Failed to build project because no open-api file was found on the 'config' folder");se=await $yt.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:lF,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}=WFe({buildId:m,result:se});return{errors:Z,warnings:Re}})},"runEsbuild");function WFe({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:fce,pluginName:_.pluginName||lF}:{location:_.location,detail:_.detail,id:_.id,notes:_.notes,message:_.text,severity:fce,pluginName:_.pluginName||lF}),errors:s.errors.map(_=>({location:_.location,detail:_.detail,id:_.id,notes:_.notes,message:_.text,severity:$Ae,pluginName:_.pluginName||lF})),metafile:s.metafile}}t(WFe,"esbuildResultToBuildResult");var fSr=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"),_Sr=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"),zyt=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=fSr(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=_Sr(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 qyt(a,s){let l=HFe.basename(s);a.errors&&(a.errors=zyt(a.errors,l,lF)),a.warnings&&(a.warnings=zyt(a.warnings,l,lF))}t(qyt,"formatBuildResult");var pSr=t(a=>HFe.basename(a).startsWith("."),"isHiddenOnUnix"),dSr=t((a,s=[])=>s.map(l=>l.startsWith(".")?l:`.${l}`).some(l=>a.endsWith(l)),"hasMatchingExtname");function UFe(a,s=[],l=!1){let _=[],m;if(!$fe.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=$fe.statSync(a),m.isFile())return[a]}catch{return[]}return $fe.readdirSync(a).forEach(b=>{let D=HFe.join(a,b),A;try{if(A=$fe.statSync(D),A.isDirectory()){l&&_.push(...UFe(D,s,l));return}}catch{return}if(!s.length)throw Error(`Argument '${s}' required when argument '${a}' is a directory`);!A.isFile()||!dSr(D,s)||pSr(D)||_.push(D)}),_}t(UFe,"lookupFiles");var uF=new Tce({level:process.env.FORCE_BUILD_COLORS?2:void 0}),L3=` ${uF.gray("|")} `;function GFe({output:a,buildId:s,runtimeVersion:l,compatibilityDate:_}){let m=["Building Zuplo API...",`${L3}Build ID: ${s}`,`${L3}Runtime Version: ${l}`];_&&m.push(`${L3}Compatibility Date: ${_}`),a.info(m.join(`
|
|
593
|
-
`))}t(GFe,"outputBuildStart");async function Jfe(a,s,l){qyt(l,a),await Promise.all(l.warnings.map(async _=>Vyt(a,s,_))),await Promise.all(l.errors.map(async _=>Vyt(a,s,_))),l.status==="Good"?s.info(uF.green("Build succeeded"),{status:"success"}):l.status==="Warnings"?s.warn(uF.yellow("Build succeeded with warnings"),{status:"success"}):l.status==="Failed"&&s.error(uF.red("Failed to build API"),{status:"failed"})}t(Jfe,"outputBuildResult");async function Vyt(a,s,l){let _=[],m=l.severity??"error",b=m==="error"?uF.red:uF.yellow,D=b(`${m.toUpperCase()}: ${l.message}${l.detail?`
|
|
592
|
+
export default environment;`;function lht(a){return{name:"environment",setup(s){s.onResolve({filter:/@app\/environment$/},()=>({namespace:cht,pluginName:oht,path:aht.join(a.sourceDirectory,Q4,"environment.js")})),s.onLoad({filter:/.*/,namespace:cht},async l=>({contents:Yhr,loader:"ts",resolveDir:aht.dirname(l.path),pluginName:oht}))}}}t(lht,"environmentPlugin");var byt=up(pFe(),1),Syt=up(J0t(),1),Tyt=up(jFe(),1),xyt=up(BFe(),1);import K2r from"fs/promises";import z2 from"path";var _k="schemas",Mfe="json-schema";function Eyt(a){return{name:_k,async setup(s){let l=new Tyt.Ajv2020({code:{source:!0},allErrors:!0,strict:!1,verbose:!0,meta:!0});(0,Syt.default)(l,{mode:"fast"}),l.opts.code.formats=byt._`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 K2r.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:_k,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:_k,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 v8e(A,a.sourceDirectory,M.message);b.push({id:"json-schema-add-error",pluginName:_k,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 v8e(A,a.sourceDirectory,M.message);b.push({id:"json-schema-compile-error",pluginName:_k,text:`The schema file '${A}' is not valid. Error: ${M.message}`,location:U,detail:"InvalidSchemaError",notes:[{text:M.message}]})}})),ph.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:Mfe,line:1,column:0,length:0,lineText:`Invalid JSON schema reference in ${U}`,suggestion:""},detail:"RouteReferenceError",pluginName:_k,notes:[{text:`Unable to resolve reference to '${A.path}' from ${U}`,location:null}]}],namespace:Mfe,path:M,pluginName:_k}}return{path:M,namespace:Mfe,pluginName:_k}}),s.onLoad({filter:/.*/,namespace:Mfe},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,xyt.default)(l,Z)}catch(ie){M.push({pluginName:_k,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(ph.DEBUG_BUILD_MODE&&U){let ie=z2.relative(_,A.path),se=z2.join(a.sourceDirectory,".zuplo",`${ie}.js`);await sk(se,U)}return{contents:U,errors:M,pluginName:_k,resolveDir:z2.dirname(A.path),watchFiles:[A.path]}}))}}}t(Eyt,"jsonSchemaPlugin");import{relative as Y2r}from"path";var Cyt=["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"],X2r="nodejs-compat-plugin";function Dyt({sourceDirectory:a}){return{name:X2r,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?Cyt.includes(_)||_.includes("/")&&Cyt.includes(_.split("/")[0])?{external:!0}:{external:!0,warnings:M.errors.map(ie=>({...ie,location:{file:Y2r(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(Dyt,"nodejsCompatPlugin");import kyt from"fs/promises";import ZE from"path";var Cj="open-api-routes-plugin",jfe="open-api-routes-json";function wyt(a){return{name:"open-api-routes-plugin",setup(s){s.onResolve({filter:/routes.json$/},l=>({watchFiles:[...UFe(ZE.join(a.sourceDirectory,j2),[".oas.json"],!0),ZE.join(a.sourceDirectory,j2,mce)],namespace:jfe,path:ZE.isAbsolute(l.path)?l.path:ZE.join(l.resolveDir,l.path),pluginName:Cj})),s.onResolve({filter:/^\.\.\/modules\/.*/,namespace:jfe},async l=>{let _=ZE.join(l.resolveDir,`${l.path}.ts`);if(!await wl.fileExists(_)){let m=`$import(.${l.path.replace(/^../,"")})`,b=ZE.resolve(a.sourceDirectory,"config"),D=await xO(b),A=await got(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:Cj}],namespace:jfe,path:l.path,pluginName:Cj}}}),s.onLoad({filter:/.*/,namespace:jfe},async l=>zf.timeFn("Generating route.json data",async()=>{let _=ZE.resolve(a.sourceDirectory,"config"),m=await xO(_),b=await Promise.all(m.map(async U=>({content:await kyt.readFile(U,"utf-8"),fileName:U}))),D=ZE.resolve(_,"policies.json");if(!await wl.fileExists(D))return{errors:[{text:"The project must include a policies file ('/config/policies.json')",detail:"OASPoliciesFileMissing",pluginName:Cj,location:{line:0,column:0,file:"/config/policies.json"}}],pluginName:Cj};let A={content:await kyt.readFile(D,"utf-8"),fileName:D},M;try{M=await m8e({sourceDirectory:a.sourceDirectory,oasContent:b,policiesContent:A})}catch(U){throw new Error("Error compiling routes: "+U.message)}if(ph.DEBUG_BUILD_MODE&&M.content){let U=ZE.join(a.sourceDirectory,".zuplo"),ie=ZE.resolve(U,"routes.js");await sk(ie,M.content)}return{contents:M.content,errors:M.errors,pluginName:Cj,resolveDir:ZE.dirname(l.path),watchFiles:[l.path]}}))}}}t(wyt,"openApiRoutesPlugin");import Bfe from"path";var IK="raw-route-plugin",Pyt="raw-route";function Ayt(a){return{name:"raw-route-plugin",setup(s){s.onResolve({filter:/raw.json$/},l=>({namespace:Pyt,path:l.path,pluginName:IK})),s.onLoad({filter:/.*/,namespace:Pyt},async l=>{let _=Bfe.resolve(a.sourceDirectory,j2);if(!await wl.dirExists(_))return{loader:"js",resolveDir:Bfe.dirname(l.path),pluginName:IK};let m=await xO(_);try{let b=await y8e({oasFiles:m,sourceDirectory:a.sourceDirectory,logger:a.logger});if(ph.DEBUG_BUILD_MODE&&b){let D=Bfe.join(a.sourceDirectory,".zuplo","raw-routes.js");await sk(D,b)}return{contents:b,loader:"js",resolveDir:Bfe.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(Ayt,"rawRoutePlugin");import Q2r from"fs/promises";import $Fe from"path";var Ufe="runtime-config",Nyt="runtime-config-plugin";function Iyt(){return{name:Ufe,setup(a){a.onResolve({filter:/^\.\.\/modules\/zuplo.runtime.ts$/},s=>({namespace:Nyt,path:$Fe.isAbsolute(s.path)?s.path:$Fe.join(s.resolveDir,s.path),pluginName:Ufe})),a.onLoad({filter:/.*/,namespace:Nyt},async s=>zf.timeFn("Generating zuplo.runtime.ts data",async()=>{let l="export const runtimeInit = undefined;",_=[];return await wl.fileExists(s.path)?(l=await Q2r.readFile(s.path,"utf-8"),{contents:l,loader:"ts",resolveDir:$Fe.dirname(s.path),errors:_,pluginName:Ufe,watchFiles:[s.path]}):{contents:l,loader:"ts",errors:_,pluginName:Ufe}}))}}}t(Iyt,"runtimeConfigPlugin");var Fyt=up(jFe(),1),Lyt=up(BFe(),1);import qFe from"fs/promises";import cF from"path";var JFe="schema-validation-plugin",Oyt="schema-validation",Z2r="module.exports = {}";function Ryt(a){return{name:"schema-validation-plugin",setup(s){s.onResolve({filter:/ajv-schema.json$/},l=>({namespace:Oyt,path:l.path,pluginName:JFe})),s.onLoad({filter:/.*/,namespace:Oyt},async l=>{let _=cF.resolve(a.sourceDirectory,j2,"policies.json");if(!await wl.fileExists(_))return{contents:Z2r,loader:"js",resolveDir:cF.dirname(l.path),pluginName:JFe};let m=await tSr(a.sourceDirectory),b=cF.resolve(a.sourceDirectory,j2),D=await xO(b),A=await sSr(D,m),M=await eSr({oasFiles:D,routesWithSchemaValidation:A,sourceDirectory:a.sourceDirectory,logger:a.logger});if(ph.DEBUG_BUILD_MODE&&M){let U=cF.join(a.sourceDirectory,".zuplo","schema-validation.js");await sk(U,M)}return{contents:M,loader:"js",resolveDir:cF.dirname(l.path),pluginName:JFe}})}}}t(Ryt,"schemaValidationPlugin");async function eSr({oasFiles:a,routesWithSchemaValidation:s,sourceDirectory:l,logger:_}){let m="",b=new f3(l,_);if(s.length===0)return m;let D=new Fyt.Ajv2020({code:{source:!0},allErrors:!0,strict:!1,verbose:!0,meta:!0});for(let A of a){let M=await qFe.readFile(A,"utf-8"),U=cF.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=Q4e(ke.path,ke.method,yr);zr.$id=en,D.addSchema(zr),zFe(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=X4e(ke.path,ke.method,yr.in,yr.name);zr.$id=en,D.addSchema(zr),zFe(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,Lyt.default)(D),m}t(eSr,"schemaValidationSource");function zFe(a,s,l,_,m,b,D){for(let A in a){let M=a[A];if(A==="$ref"){let U=eG(l,r3(s,M));a[A]=U,LH(s,l,r3(s,M),m,b,D,(ie,se)=>eG(ie,r3(s,se)))}else typeof M=="object"&&zFe(M,s,l,_,m,b,D)}}t(zFe,"addRefsToSchema");async function tSr(a){let s=new Set(["RequestValidationInboundPolicy"]),l=await qFe.readFile(`${a}/config/policies.json`,"utf-8"),_=JSON.parse(l);return rSr(_,s)}t(tSr,"getPolicyNamesUsingSchemaValidationPolicies");function rSr(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 _=nSr(a,l);return new Set([...l,..._])}t(rSr,"getPolicyNamesReferencingPolicyHandlers");function nSr(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(nSr,"getCompositePoliciesContainingPolicy");function iSr(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(iSr,"isPolicyPresentInOperation");async function sSr(a,s){let l=[];for(let _ of a){let m=await qFe.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];iSr(ie,s)&&l.push({fileName:cF.basename(_,".oas.json"),path:A,method:U})}}}return l}t(sSr,"getRoutesContainingPolicies");import{mkdirSync as aSr,writeFileSync as oSr}from"fs";import cSr from"path";function Myt(a){return{name:"write-modules-plugin",setup(s){s.onEnd(async l=>{if(l){let _=nj(a.sourceDirectory,l.metafile);aSr(a.outputDirectory,{recursive:!0}),oSr(cSr.join(a.outputDirectory,"modules.json"),JSON.stringify(_,null,2))}})}}}t(Myt,"writeModulesPlugin");var lSr=eht("zuplo:core:build"),uSr=["workerd","worker","browser"],Uyt=[...process.env.GLOBAL_MODULE_LOCATION?[process.env.GLOBAL_MODULE_LOCATION]:[],VFe.resolve(jyt(Byt(import.meta.url)),"..","..","..","node_modules"),VFe.resolve(jyt(Byt(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=VFe.join(a,gce);lSr(`Building with node paths: ${Uyt.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:ph.DEBUG_BUILD_MODE,flags:A};return{platform:"browser",target:"es2022",outdir:s,splitting:!0,metafile:!0,format:"esm",nodePaths:Uyt,entryPoints:[M],sourcemap:"linked",legalComments:"none",treeShaking:!0,bundle:!0,...U,external:[],logLevel:"silent",conditions:uSr,plugins:[lht(ie),tht(ie),wyt(ie),Ayt(ie),Ryt(ie),Iyt(),sht(ie),Eyt(ie),Dyt(ie),Myt(ie)]}}t(OK,"getBaseESBuildConfig");var lF="run-esbuild",Jyt=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 oM(l))throw new Error("Failed to build project because no open-api file was found on the 'config' folder");se=await $yt.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:lF,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}=WFe({buildId:m,result:se});return{errors:Z,warnings:Re}})},"runEsbuild");function WFe({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:fce,pluginName:_.pluginName||lF}:{location:_.location,detail:_.detail,id:_.id,notes:_.notes,message:_.text,severity:fce,pluginName:_.pluginName||lF}),errors:s.errors.map(_=>({location:_.location,detail:_.detail,id:_.id,notes:_.notes,message:_.text,severity:$Ae,pluginName:_.pluginName||lF})),metafile:s.metafile}}t(WFe,"esbuildResultToBuildResult");var fSr=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"),_Sr=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"),zyt=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=fSr(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=_Sr(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 qyt(a,s){let l=HFe.basename(s);a.errors&&(a.errors=zyt(a.errors,l,lF)),a.warnings&&(a.warnings=zyt(a.warnings,l,lF))}t(qyt,"formatBuildResult");var pSr=t(a=>HFe.basename(a).startsWith("."),"isHiddenOnUnix"),dSr=t((a,s=[])=>s.map(l=>l.startsWith(".")?l:`.${l}`).some(l=>a.endsWith(l)),"hasMatchingExtname");function UFe(a,s=[],l=!1){let _=[],m;if(!$fe.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=$fe.statSync(a),m.isFile())return[a]}catch{return[]}return $fe.readdirSync(a).forEach(b=>{let D=HFe.join(a,b),A;try{if(A=$fe.statSync(D),A.isDirectory()){l&&_.push(...UFe(D,s,l));return}}catch{return}if(!s.length)throw Error(`Argument '${s}' required when argument '${a}' is a directory`);!A.isFile()||!dSr(D,s)||pSr(D)||_.push(D)}),_}t(UFe,"lookupFiles");var uF=new Tce({level:process.env.FORCE_BUILD_COLORS?2:void 0}),L3=` ${uF.gray("|")} `;function GFe({output:a,buildId:s,runtimeVersion:l,compatibilityDate:_}){let m=["Building Zuplo API...",`${L3}Build ID: ${s}`,`${L3}Runtime Version: ${l}`];_&&m.push(`${L3}Compatibility Date: ${_}`),a.child("api").info(m.join(`
|
|
593
|
+
`))}t(GFe,"outputBuildStart");async function Jfe(a,s,l){qyt(l,a),await Promise.all(l.warnings.map(async _=>Vyt(a,s,_))),await Promise.all(l.errors.map(async _=>Vyt(a,s,_))),l.status==="Good"?s.child("api").info(uF.green("Build succeeded"),{status:"success"}):l.status==="Warnings"?s.child("api").warn(uF.yellow("Build succeeded with warnings"),{status:"success"}):l.status==="Failed"&&s.child("api").error(uF.red("Failed to build API"),{status:"failed"})}t(Jfe,"outputBuildResult");async function Vyt(a,s,l){let _=[],m=l.severity??"error",b=m==="error"?uF.red:uF.yellow,D=b(`${m.toUpperCase()}: ${l.message}${l.detail?`
|
|
594
594
|
${L3}${l.detail.toString().split(`
|
|
595
595
|
`).join(`
|
|
596
|
-
${L3}`)}`:""}`);_.push(D);let A=gSr(l.location??void 0);if(A&&_.push(`${L3}${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=hSr.join(a,l.location.file),U=await mSr(M,"utf-8"),ie=(0,Wyt.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(L3),_.push(ie)}catch{}else l.location&&l.location.file&&_.push(uF.red(`${L3}File: ${l.location.file}:${l.location.line}:${l.location.column}`));_.push(""),l.severity==="warning"?s.warn(_.join(`
|
|
597
|
-
`)):s.error(_.join(`
|
|
596
|
+
${L3}`)}`:""}`);_.push(D);let A=gSr(l.location??void 0);if(A&&_.push(`${L3}${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=hSr.join(a,l.location.file),U=await mSr(M,"utf-8"),ie=(0,Wyt.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(L3),_.push(ie)}catch{}else l.location&&l.location.file&&_.push(uF.red(`${L3}File: ${l.location.file}:${l.location.line}:${l.location.column}`));_.push(""),l.severity==="warning"?s.child("api").warn(_.join(`
|
|
597
|
+
`)):s.child("api").error(_.join(`
|
|
598
598
|
`))}t(Vyt,"logIssue");function gSr(a){if(a&&a.file){let s=a.file;if(a.line)return`${s}:${a.line}`;if(a.column)return`${s}:${a.column}`}}t(gSr,"getFileLocation");var $T=class{static{t(this,"PluginResult")}errors=[];warnings=[];constructor(s){s&&this.errors.push(s)}};async function Hyt(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(Hyt,"runPlugins");import{parse as ySr}from"jsonc-parser";import{readFile as vSr}from"fs/promises";import Gyt from"path";async function zfe(a){let s=Gyt.join(a,wst),l=Gyt.join(a,Pst),_=!1,m=s;await wl.fileExists(s)?(_=!0,m=s):await wl.fileExists(l)&&(_=!0,m=l);let b,D;if(_){let M=await vSr(m,"utf-8"),ie=ySr(M,[]);if(typeof ie!="object")return{status:yO,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:yO,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&&WR&&typeof ie.compatibilityDate=="string"){if(!WR.includes(ie.compatibilityDate)){let se={message:"Invalid compatibilityDate set in zuplo.jsonc file.",detail:`compatibilityDate was set to ${ie.compatibilityDate}. Valid compatibility dates are ${WR.join(", ")}`,pluginName:"buildData",severity:"error"};return{status:yO,errors:[se]}}b=ie.compatibilityDate}D=uce(b,ie.flags)}else D=uce(void 0,void 0);return{status:gO,config:{version:1,compatibilityDate:b,flags:D}}}t(zfe,"getZuploConfig");import{mkdir as Kyt,readFile as bSr,readdir as SSr,writeFile as TSr}from"fs/promises";import FK from"path";var Yyt=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,j2),A=FK.join(D,mce),M=FK.join(l,Dst,j2);try{if(await wl.dirExists(l)||await Kyt(l),await wl.dirExists(M)||await Kyt(M,{recursive:!0}),!await oM(a))return new $T({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 SSr(D)).filter(Pe=>Pe.endsWith(".oas.json"));if(!await wl.fileExists(A))return new $T({message:"The project must include a policies file ('/config/policies.json')",pluginName:"build-open-api-files",severity:"error"});let Z=await bSr(A,"utf-8"),Re=JSON.parse(Z);for await(let Pe of se){let ke=FK.join(D,Pe),wt;try{wt=await Xlt({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 IO)return new $T({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 $T({...zr.issue,pluginName:"build-open-api-files"});throw zr}let At=JSON.stringify(wt,null,2),yr=FK.join(M,Pe);await TSr(yr,At,"utf-8")}}catch(U){return s.error(U),new $T({message:"Error building OpenAPI files",pluginName:"build-open-api-files",severity:"error"})}return new $T})},"buildOpenApiFiles");import xSr from"fs/promises";import ESr from"path";var Xyt=t(async function({outputDirectory:a,systemDirectory:s,cacheDirectory:l,logger:_}){return zf.timeFn("Cleaning output",async()=>{_.debug("Cleaning output");let m=ESr.join(l,"routes"),b=[a,s,m];for await(let D of b)try{await xSr.rm(D,{recursive:!0,force:!0})}catch(A){_.error(A)}return{warnings:[],errors:[]}})},"cleanOutput");import Qyt from"fs/promises";var Zyt=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 Qyt.mkdir(a),await wl.dirExists(s)?l.debug("Cache directory already exists, skipping"):await Qyt.mkdir(s,{recursive:!0}),{warnings:[],errors:[]}}catch(_){return l.error(_),{warnings:[],errors:[]}}return{warnings:[],errors:[]}})},"createSystemDir");var e1t=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 CSr,writeFile as DSr}from"fs/promises";import t1t,{dirname as kSr}from"path";import{fileURLToPath as wSr}from"url";var r1t=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 CSr(t1t.resolve(kSr(wSr(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:ph.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:ph.isLocalDevelopment(),COMPATIBILITY_FLAGS:_ce?_ce[_?.compatibilityDate??"none"]:{runOutboundPoliciesOnHandlerOnAllStatuses:!1,doNotRunHooksOnSystemRoutes:!1,removeAllVendorHeadersExceptListed:!1,allowCustomPorts:!1}},M=JSON.stringify(A,void 0,2),U=t1t.join(a,hce);try{await DSr(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 PSr from"fs/promises";import ASr from"path";var NSr=`import { Handler, ServiceProviderImpl } from "@zuplo/runtime";
|
|
599
599
|
import routeLoader from "../config/routes.json";
|
|
600
600
|
import * as schemaValidations from "./ajv-schema.json";
|
|
@@ -630,7 +630,7 @@ export default {
|
|
|
630
630
|
`: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(L5e,"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 qkr=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&&Vkr(A,D),m&&Wkr(A,_,D),[...A,s].join(XK.delimiter)},"npmRunPath"),Vkr=t((a,s)=>{let l;for(;l!==s;)a.push(XK.join(s,"node_modules/.bin")),l=s,s=XK.resolve(s,"..")},"applyPreferLocal"),Wkr=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]=qkr(s),a},"npmRunPathEnv");var Hkr=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);!Gkr(m,b)&&_||Object.defineProperty(a,l,b)},"copyProperty"),Gkr=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"),Kkr=t((a,s)=>{let l=Object.getPrototypeOf(s);l!==Object.getPrototypeOf(a)&&Object.setPrototypeOf(a,l)},"changePrototype"),Ykr=t((a,s)=>`/* Wrapped ${a}*/
|
|
631
631
|
${s}`,"wrappedToString"),Xkr=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),Qkr=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),Zkr=t((a,s,l)=>{let _=l===""?"":`with ${l.trim()}() `,m=Ykr.bind(null,_,s.toString());Object.defineProperty(m,"name",Qkr),Object.defineProperty(a,"toString",{...Xkr,value:m})},"changeToString");function R5e(a,s,{ignoreNonConfigurable:l=!1}={}){let{name:_}=a;for(let m of Reflect.ownKeys(s))Hkr(a,s,m,l);return Kkr(a,s),Zkr(a,s,_),a}t(R5e,"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 R5e(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 nwr}from"os";var qSt=t(function(){let a=M5e-VSt+1;return Array.from({length:a},ewr)},"getRealtimeSignals"),ewr=t(function(a,s){return{name:`SIGRT${s+1}`,number:VSt+s,action:"terminate",description:"Application-specific signal (realtime)",standard:"posix"}},"getRealtimeSignal"),VSt=34,M5e=64;import{constants as twr}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(rwr)},"getSignals"),rwr=t(function({name:a,number:s,description:l,action:_,forced:m=!1,standard:b}){let{signals:{[a]:D}}=twr,A=D!==void 0;return{name:a,number:A?D:s,description:l,supported:A,action:_,forced:m,standard:b}},"normalizeSignal");var iwr=t(function(){return j5e().reduce(swr,{})},"getSignalsByName"),swr=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=iwr(),awr=t(function(){let a=j5e(),s=M5e+1,l=Array.from({length:s},(_,m)=>owr(m,a));return Object.assign({},...l)},"getSignalsByNumber"),owr=t(function(a,s){let l=cwr(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"),cwr=t(function(a,s){let l=s.find(({name:_})=>nwr.signals[_]===a);return l!==void 0?l:s.find(_=>_.number===a)},"findSignalByNumber"),FVr=awr();var lwr=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"),B5e=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 ${lwr({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}
|
|
632
632
|
${_.message}`:ke,yr=[At,s,a].filter(Boolean).join(`
|
|
633
|
-
`);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"],uwr=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(uwr(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=up(eTt(),1);import fwr from"os";var _wr=1e3*5,rTt=t((a,s="SIGTERM",l={})=>{let _=a(s);return pwr(a,s,l,_),_},"spawnedKill"),pwr=t((a,s,l,_)=>{if(!dwr(s,l,_))return;let m=hwr(l),b=setTimeout(()=>{a("SIGKILL")},m);b.unref&&b.unref()},"setKillTimeout"),dwr=t((a,{forceKillAfterTimeout:s},l)=>mwr(a)&&s!==!1&&l,"shouldForceKill"),mwr=t(a=>a===fwr.constants.signals.SIGTERM||typeof a=="string"&&a.toUpperCase()==="SIGTERM","isSigterm"),hwr=t(({forceKillAfterTimeout:a=!0})=>{if(a===!0)return _wr;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"),gwr=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(()=>{gwr(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 V5e=up(uTt(),1),pTt=up(_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"),z5e=t(async(a,s)=>{if(a){a.destroy();try{return await s}catch(l){return l.bufferedData}}},"getBufferedData"),q5e=t((a,{encoding:s,buffer:l,maxBuffer:_})=>{if(!(!a||!l))return s?(0,V5e.default)(a,{encoding:s,maxBuffer:_}):V5e.default.buffer(a,{maxBuffer:_})},"getStreamPromise"),hTt=t(async({stdout:a,stderr:s,all:l},{encoding:_,buffer:m,maxBuffer:b},D)=>{let A=q5e(a,{encoding:_,buffer:m,maxBuffer:b}),M=q5e(s,{encoding:_,buffer:m,maxBuffer:b}),U=q5e(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},z5e(a,A),z5e(s,M),z5e(l,U)])}},"getSpawnedResult");var Cwr=(async()=>{})().constructor.prototype,Dwr=["then","catch","finally"].map(a=>[a,Reflect.getOwnPropertyDescriptor(Cwr,a)]),W5e=t((a,s)=>{for(let[l,_]of Dwr){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"),kwr=/^[\w.-]+$/,wwr=/"/g,Pwr=t(a=>typeof a!="string"||kwr.test(a)?a:`"${a.replace(wwr,'\\"')}"`,"escapeArg"),vTt=t((a,s)=>yTt(a,s).join(" "),"joinCommand"),bTt=t((a,s)=>yTt(a,s).map(l=>Pwr(l)).join(" "),"getEscapedCommand");var Iwr=1e3*1e3*100,Owr=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"),Fwr=t((a,s,l={})=>{let _=TTt.default._parse(a,s,l);return a=_.command,s=_.args,l=_.options,l={maxBuffer:Iwr,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=Owr(l),l.stdio=GSt(l),Npe.platform==="win32"&&Nwr.basename(a,".exe")==="cmd"&&s.unshift("/q"),{file:a,args:s,options:l,parsed:_}},"handleArguments"),H5e=t((a,s,l)=>typeof s!="string"&&!Awr.isBuffer(s)?l===void 0?void 0:"":a.stripFinalNewline?L5e(s):s,"handleOutput");function xTt(a,s,l){let _=Fwr(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(B5e({error:Re,stdout:"",stderr:"",all:"",command:m,escapedCommand:b,parsed:_,timedOut:!1,isCanceled:!1,killed:!1}));return W5e(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=H5e(_.options,At),hn=H5e(_.options,yr),br=H5e(_.options,zr);if(Re||Pe!==0||ke!==null){let mr=B5e({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),W5e(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 Lwr(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"),_=G5e.default.parse(l);for(let m of Object.keys(_))if(a[m]=_[m],m==="ZUPLO_SYSTEM_CONFIGURATIONS"){let b=Buffer.from(xle.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"),_=G5e.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 Lwr(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(Lwr,"getGitSha");async function Bwr({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(!Rwr(ie))throw new Error("The bundled-dir does not contain a modules.json file.");let se=await jwr(ie,"utf-8").then(JSON.parse),Z=await zfe(l);return Z.status===gO?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 lB({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"),nj(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??ph.DEV_SERVER_PORT,bindings:ke,handleRuntimeStdio:Pe}),At=b??"compiled-zup",yr=eY.join(l,"dist");await Mwr(yr,{recursive:!0}),await wt.compileBinary({binaryPath:eY.join(l,"dist",At)}),await wt.dispose(),Re(void 0)}}t(U,"compile")}t(Bwr,"compileWorkerdServer");var wTt=up(S5e(),1);import $wr from"path";import Uwr from"net";function kTt(a,s){return new Promise(l=>{let _=new Uwr.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??ph.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 lB({...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:$wr.join(this.sourceDirectory,"dist"),modules:nj(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 Jwr({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(Jwr,"startDevServer");var rxt=up(NTt(),1),nxt=up(ext(),1);import{readFile as xPr}from"fs/promises";var SPr=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})?/$"),TPr={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 SPr.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=TPr;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 a9e(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(`
|
|
633
|
+
`);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"],uwr=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(uwr(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=up(eTt(),1);import fwr from"os";var _wr=1e3*5,rTt=t((a,s="SIGTERM",l={})=>{let _=a(s);return pwr(a,s,l,_),_},"spawnedKill"),pwr=t((a,s,l,_)=>{if(!dwr(s,l,_))return;let m=hwr(l),b=setTimeout(()=>{a("SIGKILL")},m);b.unref&&b.unref()},"setKillTimeout"),dwr=t((a,{forceKillAfterTimeout:s},l)=>mwr(a)&&s!==!1&&l,"shouldForceKill"),mwr=t(a=>a===fwr.constants.signals.SIGTERM||typeof a=="string"&&a.toUpperCase()==="SIGTERM","isSigterm"),hwr=t(({forceKillAfterTimeout:a=!0})=>{if(a===!0)return _wr;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"),gwr=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(()=>{gwr(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 V5e=up(uTt(),1),pTt=up(_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"),z5e=t(async(a,s)=>{if(a){a.destroy();try{return await s}catch(l){return l.bufferedData}}},"getBufferedData"),q5e=t((a,{encoding:s,buffer:l,maxBuffer:_})=>{if(!(!a||!l))return s?(0,V5e.default)(a,{encoding:s,maxBuffer:_}):V5e.default.buffer(a,{maxBuffer:_})},"getStreamPromise"),hTt=t(async({stdout:a,stderr:s,all:l},{encoding:_,buffer:m,maxBuffer:b},D)=>{let A=q5e(a,{encoding:_,buffer:m,maxBuffer:b}),M=q5e(s,{encoding:_,buffer:m,maxBuffer:b}),U=q5e(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},z5e(a,A),z5e(s,M),z5e(l,U)])}},"getSpawnedResult");var Cwr=(async()=>{})().constructor.prototype,Dwr=["then","catch","finally"].map(a=>[a,Reflect.getOwnPropertyDescriptor(Cwr,a)]),W5e=t((a,s)=>{for(let[l,_]of Dwr){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"),kwr=/^[\w.-]+$/,wwr=/"/g,Pwr=t(a=>typeof a!="string"||kwr.test(a)?a:`"${a.replace(wwr,'\\"')}"`,"escapeArg"),vTt=t((a,s)=>yTt(a,s).join(" "),"joinCommand"),bTt=t((a,s)=>yTt(a,s).map(l=>Pwr(l)).join(" "),"getEscapedCommand");var Iwr=1e3*1e3*100,Owr=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"),Fwr=t((a,s,l={})=>{let _=TTt.default._parse(a,s,l);return a=_.command,s=_.args,l=_.options,l={maxBuffer:Iwr,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=Owr(l),l.stdio=GSt(l),Npe.platform==="win32"&&Nwr.basename(a,".exe")==="cmd"&&s.unshift("/q"),{file:a,args:s,options:l,parsed:_}},"handleArguments"),H5e=t((a,s,l)=>typeof s!="string"&&!Awr.isBuffer(s)?l===void 0?void 0:"":a.stripFinalNewline?L5e(s):s,"handleOutput");function xTt(a,s,l){let _=Fwr(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(B5e({error:Re,stdout:"",stderr:"",all:"",command:m,escapedCommand:b,parsed:_,timedOut:!1,isCanceled:!1,killed:!1}));return W5e(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=H5e(_.options,At),hn=H5e(_.options,yr),br=H5e(_.options,zr);if(Re||Pe!==0||ke!==null){let mr=B5e({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),W5e(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 Lwr(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"),_=G5e.default.parse(l);for(let m of Object.keys(_))if(a[m]=_[m],m==="ZUPLO_SYSTEM_CONFIGURATIONS"){let b=Buffer.from(xle.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"),_=G5e.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 Lwr(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(Lwr,"getGitSha");async function Bwr({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(!Rwr(ie))throw new Error("The bundled-dir does not contain a modules.json file.");let se=await jwr(ie,"utf-8").then(JSON.parse),Z=await zfe(l);return Z.status===gO?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 lB({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"),nj(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??ph.DEV_SERVER_PORT,bindings:ke,handleRuntimeStdio:Pe}),At=b??"compiled-zup",yr=eY.join(l,"dist");await Mwr(yr,{recursive:!0}),await wt.compileBinary({binaryPath:eY.join(l,"dist",At)}),await wt.dispose(),Re(void 0)}}t(U,"compile")}t(Bwr,"compileWorkerdServer");var wTt=up(S5e(),1);import $wr from"path";import Uwr from"net";function kTt(a,s){return new Promise(l=>{let _=new Uwr.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??ph.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 lB({...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:$wr.join(this.sourceDirectory,"dist"),modules:nj(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 Jwr({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(Jwr,"startDevServer");var rxt=up(NTt(),1),nxt=up(ext(),1);import{readFile as xPr}from"fs/promises";var SPr=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})?/$"),TPr={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 SPr.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=TPr;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 a9e(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(`
|
|
634
634
|
`)},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(a9e,"buildGetSourceFunction");var EPr=t(async a=>xPr(a,{encoding:"utf8"}),"fetchFile"),ixt=a9e(EPr);import CPr from"path";import DPr from"util";var sxt=t(a=>a[a.length-1],"lastOf"),aY=t(a=>a.replace(/\\/g,"/"),"nixSlashes"),kPr=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=DPr.inspect(m).split(`
|
|
635
635
|
`),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=CPr.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(`
|
|
636
636
|
`).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(kPr(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 OPr}from"path";import{fileURLToPath as FPr}from"url";import{inspect as LPr}from"util";function o9e({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(o9e,"ansiRegex");var wPr=o9e();function c9e(a){if(typeof a!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof a}\``);return a.replace(wPr,"")}t(c9e,"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 PPr(a){if(!Number.isSafeInteger(a))throw new TypeError(`Expected a code point, got \`${typeof a}\`.`)}t(PPr,"validate");function lxt(a,{ambiguousAsWide:s=!1}={}){return PPr(a),oxt(a)||cxt(a)||s&&axt(a)?2:1}t(lxt,"eastAsianWidth");var _xt=up(fxt(),1);var APr=new Intl.Segmenter,NPr=/^\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=c9e(a)),a.length===0)return 0;let m=0,b={ambiguousAsWide:!l};for(let{segment:D}of APr.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)&&!NPr.test(D)){if((0,_xt.default)().test(D)){m+=2;continue}m+=lxt(A,b)}}return m}t(Vpe,"stringWidth");var f9e=up(dxt(),1);var{platform:mxt,cwd:IPr}=process,{red:vB,yellow:hxt,green:Hpe,cyan:cY,dim:l9e}=S_,gxt=process.stdout.columns,RPr=mxt==="win32"&&!process.env.WT_SESSION?">":"\u276F",MPr=(mxt==="win32"&&!process.env.WT_SESSION,"\u2043"),jPr=IPr();function yxt(a){return a=a.replace("async file:","file:"),OPr(jPr,a.startsWith("file:")?FPr(a):a)}t(yxt,"getRelativePath");function BPr(a){return a.find(s=>s.isApp)||null}t(BPr,"mainFrame");function UPr(a,s){return a.filter(l=>(l.isApp||l.isModule)&&(!s||l.file!==s.file||l.line!==s.line))}t(UPr,"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 u9e(a,s,l,_,m){let b=bxt(String(l),String(s));return _?`${m}${vB(RPr)}${b}${vB(s)}${vB("|")}${b} ${vB(a)}`:`${m} ${b}${l9e(s)}${l9e("|")}${b} ${l9e(a)}`}t(u9e,"codeLine");function $Pr(a,s,l){let _,m=(0,f9e.default)(Vpe(s)+2,gxt);return l?_=`${s} ${vB(m(`${a.message}`).trim())}`:_=`${s} ${vB(m(`${a.name}: ${a.message}`).trim())}`,[_,s]}t($Pr,"getMessage");function JPr(a,s){let l=a.help;if(!l)return[];let _=(0,f9e.default)(Vpe(s)+4,gxt);return Array.isArray(l)?l.map(m=>`${s} ${cY(_(`- ${m}`).trim())}`).concat([s]):[`${s} ${cY(l)}`,s]}t(JPr,"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 qPr(a,s){if(!a||!a.context||!a.context.line)return[];let l=a.context.start-1,_=a.context.pre.split(`
|