@latticexyz/world 3.0.0-main-570086e7b → 3.0.0-main-93749bdb6

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/dist/node.js CHANGED
@@ -33,5 +33,5 @@ import{a as Pe,b as Ys,c as je,d as p,e as O,f as x,g as rt,m as ze}from"./chunk
33
33
  }
34
34
  `}import Ks from"node:fs/promises";import j from"node:path";import{formatAndWriteSolidity as Vs,contractToInterface as Fr}from"@latticexyz/common/codegen";import{isHex as Or}from"viem";import Yt from"node:path";import Us from"node:path";var us=Ys(ss(),1);var Nt=n=>{if(typeof n!="string")throw new TypeError("invalid pattern");if(n.length>65536)throw new TypeError("pattern is too long")};var li={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}",!0],"[:alpha:]":["\\p{L}\\p{Nl}",!0],"[:ascii:]":["\\x00-\\x7f",!1],"[:blank:]":["\\p{Zs}\\t",!0],"[:cntrl:]":["\\p{Cc}",!0],"[:digit:]":["\\p{Nd}",!0],"[:graph:]":["\\p{Z}\\p{C}",!0,!0],"[:lower:]":["\\p{Ll}",!0],"[:print:]":["\\p{C}",!0],"[:punct:]":["\\p{P}",!0],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f",!0],"[:upper:]":["\\p{Lu}",!0],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}",!0],"[:xdigit:]":["A-Fa-f0-9",!1]},_t=n=>n.replace(/[[\]\\-]/g,"\\$&"),ci=n=>n.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),is=n=>n.join(""),rs=(n,t)=>{let e=t;if(n.charAt(e)!=="[")throw new Error("not in a brace expression");let s=[],i=[],r=e+1,o=!1,h=!1,a=!1,l=!1,c=e,f="";t:for(;r<n.length;){let d=n.charAt(r);if((d==="!"||d==="^")&&r===e+1){l=!0,r++;continue}if(d==="]"&&o&&!a){c=r+1;break}if(o=!0,d==="\\"&&!a){a=!0,r++;continue}if(d==="["&&!a){for(let[w,[g,b,E]]of Object.entries(li))if(n.startsWith(w,r)){if(f)return["$.",!1,n.length-e,!0];r+=w.length,E?i.push(g):s.push(g),h=h||b;continue t}}if(a=!1,f){d>f?s.push(_t(f)+"-"+_t(d)):d===f&&s.push(_t(d)),f="",r++;continue}if(n.startsWith("-]",r+1)){s.push(_t(d+"-")),r+=2;continue}if(n.startsWith("-",r+1)){f=d,r+=2;continue}s.push(_t(d)),r++}if(c<r)return["",!1,0,!1];if(!s.length&&!i.length)return["$.",!1,n.length-e,!0];if(i.length===0&&s.length===1&&/^\\?.$/.test(s[0])&&!l){let d=s[0].length===2?s[0].slice(-1):s[0];return[ci(d),!1,c-e,!1]}let u="["+(l?"^":"")+is(s)+"]",m="["+(l?"":"^")+is(i)+"]";return[s.length&&i.length?"("+u+"|"+m+")":s.length?u:m,h,c-e,!0]};var V=(n,{windowsPathsNoEscape:t=!1}={})=>t?n.replace(/\[([^\/\\])\]/g,"$1"):n.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1");var fi=new Set(["!","?","+","*","@"]),ns=n=>fi.has(n),ui="(?!(?:^|/)\\.\\.?(?:$|/))",Zt="(?!\\.)",di=new Set(["[","."]),pi=new Set(["..","."]),mi=new Set("().*{}+?[]^$\\!"),gi=n=>n.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),ve="[^/]",os=ve+"*?",hs=ve+"+?",R,D,et,C,A,nt,dt,ot,X,pt,Lt,Qt,as,bt,Xt,It,Ee,te,ls,z=class{constructor(t,e,s={}){O(this,Qt);O(this,It);je(this,"type");O(this,R,void 0);O(this,D,void 0);O(this,et,!1);O(this,C,[]);O(this,A,void 0);O(this,nt,void 0);O(this,dt,void 0);O(this,ot,!1);O(this,X,void 0);O(this,pt,void 0);O(this,Lt,!1);this.type=t,t&&x(this,D,!0),x(this,A,e),x(this,R,p(this,A)?p(p(this,A),R):this),x(this,X,p(this,R)===this?s:p(p(this,R),X)),x(this,dt,p(this,R)===this?[]:p(p(this,R),dt)),t==="!"&&!p(p(this,R),ot)&&p(this,dt).push(this),x(this,nt,p(this,A)?p(p(this,A),C).length:0)}get hasMagic(){if(p(this,D)!==void 0)return p(this,D);for(let t of p(this,C))if(typeof t!="string"&&(t.type||t.hasMagic))return x(this,D,!0);return p(this,D)}toString(){return p(this,pt)!==void 0?p(this,pt):this.type?x(this,pt,this.type+"("+p(this,C).map(t=>String(t)).join("|")+")"):x(this,pt,p(this,C).map(t=>String(t)).join(""))}push(...t){for(let e of t)if(e!==""){if(typeof e!="string"&&!(e instanceof z&&p(e,A)===this))throw new Error("invalid part: "+e);p(this,C).push(e)}}toJSON(){let t=this.type===null?p(this,C).slice().map(e=>typeof e=="string"?e:e.toJSON()):[this.type,...p(this,C).map(e=>e.toJSON())];return this.isStart()&&!this.type&&t.unshift([]),this.isEnd()&&(this===p(this,R)||p(p(this,R),ot)&&p(this,A)?.type==="!")&&t.push({}),t}isStart(){if(p(this,R)===this)return!0;if(!p(this,A)?.isStart())return!1;if(p(this,nt)===0)return!0;let t=p(this,A);for(let e=0;e<p(this,nt);e++){let s=p(t,C)[e];if(!(s instanceof z&&s.type==="!"))return!1}return!0}isEnd(){if(p(this,R)===this||p(this,A)?.type==="!")return!0;if(!p(this,A)?.isEnd())return!1;if(!this.type)return p(this,A)?.isEnd();let t=p(this,A)?p(p(this,A),C).length:0;return p(this,nt)===t-1}copyIn(t){typeof t=="string"?this.push(t):this.push(t.clone(this))}clone(t){let e=new z(this.type,t);for(let s of p(this,C))e.copyIn(s);return e}static fromGlob(t,e={}){var i;let s=new z(null,void 0,e);return rt(i=z,bt,Xt).call(i,t,s,0,e),s}toMMPattern(){if(this!==p(this,R))return p(this,R).toMMPattern();let t=this.toString(),[e,s,i,r]=this.toRegExpSource();if(!(i||p(this,D)||p(this,X).nocase&&!p(this,X).nocaseMagicOnly&&t.toUpperCase()!==t.toLowerCase()))return s;let h=(p(this,X).nocase?"i":"")+(r?"u":"");return Object.assign(new RegExp(`^${e}$`,h),{_src:e,_glob:t})}get options(){return p(this,X)}toRegExpSource(t){let e=t??!!p(this,X).dot;if(p(this,R)===this&&rt(this,Qt,as).call(this),!this.type){let a=this.isStart()&&this.isEnd(),l=p(this,C).map(m=>{var b;let[y,d,w,g]=typeof m=="string"?rt(b=z,te,ls).call(b,m,p(this,D),a):m.toRegExpSource(t);return x(this,D,p(this,D)||w),x(this,et,p(this,et)||g),y}).join(""),c="";if(this.isStart()&&typeof p(this,C)[0]=="string"&&!(p(this,C).length===1&&pi.has(p(this,C)[0]))){let y=di,d=e&&y.has(l.charAt(0))||l.startsWith("\\.")&&y.has(l.charAt(2))||l.startsWith("\\.\\.")&&y.has(l.charAt(4)),w=!e&&!t&&y.has(l.charAt(0));c=d?ui:w?Zt:""}let f="";return this.isEnd()&&p(p(this,R),ot)&&p(this,A)?.type==="!"&&(f="(?:$|\\/)"),[c+l+f,V(l),x(this,D,!!p(this,D)),p(this,et)]}let s=this.type==="*"||this.type==="+",i=this.type==="!"?"(?:(?!(?:":"(?:",r=rt(this,It,Ee).call(this,e);if(this.isStart()&&this.isEnd()&&!r&&this.type!=="!"){let a=this.toString();return x(this,C,[a]),this.type=null,x(this,D,void 0),[a,V(this.toString()),!1,!1]}let o=!s||t||e||!Zt?"":rt(this,It,Ee).call(this,!0);o===r&&(o=""),o&&(r=`(?:${r})(?:${o})*?`);let h="";if(this.type==="!"&&p(this,Lt))h=(this.isStart()&&!e?Zt:"")+hs;else{let a=this.type==="!"?"))"+(this.isStart()&&!e&&!t?Zt:"")+os+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&o?")":this.type==="*"&&o?")?":`)${this.type}`;h=i+r+a}return[h,V(r),x(this,D,!!p(this,D)),p(this,et)]}},ht=z;R=new WeakMap,D=new WeakMap,et=new WeakMap,C=new WeakMap,A=new WeakMap,nt=new WeakMap,dt=new WeakMap,ot=new WeakMap,X=new WeakMap,pt=new WeakMap,Lt=new WeakMap,Qt=new WeakSet,as=function(){if(this!==p(this,R))throw new Error("should only call on root");if(p(this,ot))return this;this.toString(),x(this,ot,!0);let t;for(;t=p(this,dt).pop();){if(t.type!=="!")continue;let e=t,s=p(e,A);for(;s;){for(let i=p(e,nt)+1;!s.type&&i<p(s,C).length;i++)for(let r of p(t,C)){if(typeof r=="string")throw new Error("string part in extglob AST??");r.copyIn(p(s,C)[i])}e=s,s=p(e,A)}}return this},bt=new WeakSet,Xt=function(t,e,s,i){var m,y;let r=!1,o=!1,h=-1,a=!1;if(e.type===null){let d=s,w="";for(;d<t.length;){let g=t.charAt(d++);if(r||g==="\\"){r=!r,w+=g;continue}if(o){d===h+1?(g==="^"||g==="!")&&(a=!0):g==="]"&&!(d===h+2&&a)&&(o=!1),w+=g;continue}else if(g==="["){o=!0,h=d,a=!1,w+=g;continue}if(!i.noext&&ns(g)&&t.charAt(d)==="("){e.push(w),w="";let b=new z(g,e);d=rt(m=z,bt,Xt).call(m,t,b,d,i),e.push(b);continue}w+=g}return e.push(w),d}let l=s+1,c=new z(null,e),f=[],u="";for(;l<t.length;){let d=t.charAt(l++);if(r||d==="\\"){r=!r,u+=d;continue}if(o){l===h+1?(d==="^"||d==="!")&&(a=!0):d==="]"&&!(l===h+2&&a)&&(o=!1),u+=d;continue}else if(d==="["){o=!0,h=l,a=!1,u+=d;continue}if(ns(d)&&t.charAt(l)==="("){c.push(u),u="";let w=new z(d,c);c.push(w),l=rt(y=z,bt,Xt).call(y,t,w,l,i);continue}if(d==="|"){c.push(u),u="",f.push(c),c=new z(null,e);continue}if(d===")")return u===""&&p(e,C).length===0&&x(e,Lt,!0),c.push(u),u="",e.push(...f,c),l;u+=d}return e.type=null,x(e,D,void 0),x(e,C,[t.substring(s-1)]),l},It=new WeakSet,Ee=function(t){return p(this,C).map(e=>{if(typeof e=="string")throw new Error("string type in extglob ast??");let[s,i,r,o]=e.toRegExpSource(t);return x(this,et,p(this,et)||o),s}).filter(e=>!(this.isStart()&&this.isEnd())||!!e).join("|")},te=new WeakSet,ls=function(t,e,s=!1){let i=!1,r="",o=!1;for(let h=0;h<t.length;h++){let a=t.charAt(h);if(i){i=!1,r+=(mi.has(a)?"\\":"")+a;continue}if(a==="\\"){h===t.length-1?r+="\\\\":i=!0;continue}if(a==="["){let[l,c,f,u]=rs(t,h);if(f){r+=l,o=o||c,h+=f-1,e=e||u;continue}}if(a==="*"){s&&t==="*"?r+=hs:r+=os,e=!0;continue}if(a==="?"){r+=ve,e=!0;continue}r+=gi(a)}return[r,V(t),!!e,o]},O(ht,bt),O(ht,te);var St=(n,{windowsPathsNoEscape:t=!1}={})=>t?n.replace(/[?*()[\]]/g,"[$&]"):n.replace(/[?*()[\]\\]/g,"\\$&");var W=(n,t,e={})=>(Nt(t),!e.nocomment&&t.charAt(0)==="#"?!1:new $(t,e).match(n)),wi=/^\*+([^+@!?\*\[\(]*)$/,yi=n=>t=>!t.startsWith(".")&&t.endsWith(n),bi=n=>t=>t.endsWith(n),Si=n=>(n=n.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(n)),Ei=n=>(n=n.toLowerCase(),t=>t.toLowerCase().endsWith(n)),vi=/^\*+\.\*+$/,xi=n=>!n.startsWith(".")&&n.includes("."),Ci=n=>n!=="."&&n!==".."&&n.includes("."),Ti=/^\.\*+$/,Ai=n=>n!=="."&&n!==".."&&n.startsWith("."),Ri=/^\*+$/,ki=n=>n.length!==0&&!n.startsWith("."),Oi=n=>n.length!==0&&n!=="."&&n!=="..",Di=/^\?+([^+@!?\*\[\(]*)?$/,Fi=([n,t=""])=>{let e=ds([n]);return t?(t=t.toLowerCase(),s=>e(s)&&s.toLowerCase().endsWith(t)):e},Mi=([n,t=""])=>{let e=ps([n]);return t?(t=t.toLowerCase(),s=>e(s)&&s.toLowerCase().endsWith(t)):e},Ni=([n,t=""])=>{let e=ps([n]);return t?s=>e(s)&&s.endsWith(t):e},_i=([n,t=""])=>{let e=ds([n]);return t?s=>e(s)&&s.endsWith(t):e},ds=([n])=>{let t=n.length;return e=>e.length===t&&!e.startsWith(".")},ps=([n])=>{let t=n.length;return e=>e.length===t&&e!=="."&&e!==".."},ms=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",cs={win32:{sep:"\\"},posix:{sep:"/"}},Li=ms==="win32"?cs.win32.sep:cs.posix.sep;W.sep=Li;var _=Symbol("globstar **");W.GLOBSTAR=_;var Ii="[^/]",Wi=Ii+"*?",Pi="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",ji="(?:(?!(?:\\/|^)\\.).)*?",zi=(n,t={})=>e=>W(e,n,t);W.filter=zi;var U=(n,t={})=>Object.assign({},n,t),$i=n=>{if(!n||typeof n!="object"||!Object.keys(n).length)return W;let t=W;return Object.assign((s,i,r={})=>t(s,i,U(n,r)),{Minimatch:class extends t.Minimatch{constructor(i,r={}){super(i,U(n,r))}static defaults(i){return t.defaults(U(n,i)).Minimatch}},AST:class extends t.AST{constructor(i,r,o={}){super(i,r,U(n,o))}static fromGlob(i,r={}){return t.AST.fromGlob(i,U(n,r))}},unescape:(s,i={})=>t.unescape(s,U(n,i)),escape:(s,i={})=>t.escape(s,U(n,i)),filter:(s,i={})=>t.filter(s,U(n,i)),defaults:s=>t.defaults(U(n,s)),makeRe:(s,i={})=>t.makeRe(s,U(n,i)),braceExpand:(s,i={})=>t.braceExpand(s,U(n,i)),match:(s,i,r={})=>t.match(s,i,U(n,r)),sep:t.sep,GLOBSTAR:_})};W.defaults=$i;var gs=(n,t={})=>(Nt(n),t.nobrace||!/\{(?:(?!\{).)*\}/.test(n)?[n]:(0,us.default)(n));W.braceExpand=gs;var Bi=(n,t={})=>new $(n,t).makeRe();W.makeRe=Bi;var Ui=(n,t,e={})=>{let s=new $(t,e);return n=n.filter(i=>s.match(i)),s.options.nonull&&!n.length&&n.push(t),n};W.match=Ui;var fs=/[?*]|[+@!]\(.*?\)|\[|\]/,Gi=n=>n.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),$=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;regexp;constructor(t,e={}){Nt(t),e=e||{},this.options=e,this.pattern=t,this.platform=e.platform||ms,this.isWindows=this.platform==="win32",this.windowsPathsNoEscape=!!e.windowsPathsNoEscape||e.allowWindowsEscape===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!e.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!e.nonegate,this.comment=!1,this.empty=!1,this.partial=!!e.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=e.windowsNoMagicRoot!==void 0?e.windowsNoMagicRoot:!!(this.isWindows&&this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let t of this.set)for(let e of t)if(typeof e!="string")return!0;return!1}debug(...t){}make(){let t=this.pattern,e=this.options;if(!e.nocomment&&t.charAt(0)==="#"){this.comment=!0;return}if(!t){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],e.debug&&(this.debug=(...r)=>console.error(...r)),this.debug(this.pattern,this.globSet);let s=this.globSet.map(r=>this.slashSplit(r));this.globParts=this.preprocess(s),this.debug(this.pattern,this.globParts);let i=this.globParts.map((r,o,h)=>{if(this.isWindows&&this.windowsNoMagicRoot){let a=r[0]===""&&r[1]===""&&(r[2]==="?"||!fs.test(r[2]))&&!fs.test(r[3]),l=/^[a-z]:/i.test(r[0]);if(a)return[...r.slice(0,4),...r.slice(4).map(c=>this.parse(c))];if(l)return[r[0],...r.slice(1).map(c=>this.parse(c))]}return r.map(a=>this.parse(a))});if(this.debug(this.pattern,i),this.set=i.filter(r=>r.indexOf(!1)===-1),this.isWindows)for(let r=0;r<this.set.length;r++){let o=this.set[r];o[0]===""&&o[1]===""&&this.globParts[r][2]==="?"&&typeof o[3]=="string"&&/^[a-z]:$/i.test(o[3])&&(o[2]="?")}this.debug(this.pattern,this.set)}preprocess(t){if(this.options.noglobstar)for(let s=0;s<t.length;s++)for(let i=0;i<t[s].length;i++)t[s][i]==="**"&&(t[s][i]="*");let{optimizationLevel:e=1}=this.options;return e>=2?(t=this.firstPhasePreProcess(t),t=this.secondPhasePreProcess(t)):e>=1?t=this.levelOneOptimize(t):t=this.adjascentGlobstarOptimize(t),t}adjascentGlobstarOptimize(t){return t.map(e=>{let s=-1;for(;(s=e.indexOf("**",s+1))!==-1;){let i=s;for(;e[i+1]==="**";)i++;i!==s&&e.splice(s,i-s)}return e})}levelOneOptimize(t){return t.map(e=>(e=e.reduce((s,i)=>{let r=s[s.length-1];return i==="**"&&r==="**"?s:i===".."&&r&&r!==".."&&r!=="."&&r!=="**"?(s.pop(),s):(s.push(i),s)},[]),e.length===0?[""]:e))}levelTwoFileOptimize(t){Array.isArray(t)||(t=this.slashSplit(t));let e=!1;do{if(e=!1,!this.preserveMultipleSlashes){for(let i=1;i<t.length-1;i++){let r=t[i];i===1&&r===""&&t[0]===""||(r==="."||r==="")&&(e=!0,t.splice(i,1),i--)}t[0]==="."&&t.length===2&&(t[1]==="."||t[1]==="")&&(e=!0,t.pop())}let s=0;for(;(s=t.indexOf("..",s+1))!==-1;){let i=t[s-1];i&&i!=="."&&i!==".."&&i!=="**"&&(e=!0,t.splice(s-1,2),s-=2)}}while(e);return t.length===0?[""]:t}firstPhasePreProcess(t){let e=!1;do{e=!1;for(let s of t){let i=-1;for(;(i=s.indexOf("**",i+1))!==-1;){let o=i;for(;s[o+1]==="**";)o++;o>i&&s.splice(i+1,o-i);let h=s[i+1],a=s[i+2],l=s[i+3];if(h!==".."||!a||a==="."||a===".."||!l||l==="."||l==="..")continue;e=!0,s.splice(i,1);let c=s.slice(0);c[i]="**",t.push(c),i--}if(!this.preserveMultipleSlashes){for(let o=1;o<s.length-1;o++){let h=s[o];o===1&&h===""&&s[0]===""||(h==="."||h==="")&&(e=!0,s.splice(o,1),o--)}s[0]==="."&&s.length===2&&(s[1]==="."||s[1]==="")&&(e=!0,s.pop())}let r=0;for(;(r=s.indexOf("..",r+1))!==-1;){let o=s[r-1];if(o&&o!=="."&&o!==".."&&o!=="**"){e=!0;let a=r===1&&s[r+1]==="**"?["."]:[];s.splice(r-1,2,...a),s.length===0&&s.push(""),r-=2}}}}while(e);return t}secondPhasePreProcess(t){for(let e=0;e<t.length-1;e++)for(let s=e+1;s<t.length;s++){let i=this.partsMatch(t[e],t[s],!this.preserveMultipleSlashes);if(i){t[e]=[],t[s]=i;break}}return t.filter(e=>e.length)}partsMatch(t,e,s=!1){let i=0,r=0,o=[],h="";for(;i<t.length&&r<e.length;)if(t[i]===e[r])o.push(h==="b"?e[r]:t[i]),i++,r++;else if(s&&t[i]==="**"&&e[r]===t[i+1])o.push(t[i]),i++;else if(s&&e[r]==="**"&&t[i]===e[r+1])o.push(e[r]),r++;else if(t[i]==="*"&&e[r]&&(this.options.dot||!e[r].startsWith("."))&&e[r]!=="**"){if(h==="b")return!1;h="a",o.push(t[i]),i++,r++}else if(e[r]==="*"&&t[i]&&(this.options.dot||!t[i].startsWith("."))&&t[i]!=="**"){if(h==="a")return!1;h="b",o.push(e[r]),i++,r++}else return!1;return t.length===e.length&&o}parseNegate(){if(this.nonegate)return;let t=this.pattern,e=!1,s=0;for(let i=0;i<t.length&&t.charAt(i)==="!";i++)e=!e,s++;s&&(this.pattern=t.slice(s)),this.negate=e}matchOne(t,e,s=!1){let i=this.options;if(this.isWindows){let d=typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]),w=!d&&t[0]===""&&t[1]===""&&t[2]==="?"&&/^[a-z]:$/i.test(t[3]),g=typeof e[0]=="string"&&/^[a-z]:$/i.test(e[0]),b=!g&&e[0]===""&&e[1]===""&&e[2]==="?"&&typeof e[3]=="string"&&/^[a-z]:$/i.test(e[3]),E=w?3:d?0:void 0,S=b?3:g?0:void 0;if(typeof E=="number"&&typeof S=="number"){let[v,k]=[t[E],e[S]];v.toLowerCase()===k.toLowerCase()&&(e[S]=v,S>E?e=e.slice(S):E>S&&(t=t.slice(E)))}}let{optimizationLevel:r=1}=this.options;r>=2&&(t=this.levelTwoFileOptimize(t)),this.debug("matchOne",this,{file:t,pattern:e}),this.debug("matchOne",t.length,e.length);for(var o=0,h=0,a=t.length,l=e.length;o<a&&h<l;o++,h++){this.debug("matchOne loop");var c=e[h],f=t[o];if(this.debug(e,c,f),c===!1)return!1;if(c===_){this.debug("GLOBSTAR",[e,c,f]);var u=o,m=h+1;if(m===l){for(this.debug("** at the end");o<a;o++)if(t[o]==="."||t[o]===".."||!i.dot&&t[o].charAt(0)===".")return!1;return!0}for(;u<a;){var y=t[u];if(this.debug(`
35
35
  globstar while`,t,u,e,m,y),this.matchOne(t.slice(u),e.slice(m),s))return this.debug("globstar found match!",u,a,y),!0;if(y==="."||y===".."||!i.dot&&y.charAt(0)==="."){this.debug("dot detected!",t,u,e,m);break}this.debug("globstar swallow a segment, and continue"),u++}return!!(s&&(this.debug(`
36
- >>> no match, partial?`,t,u,e,m),u===a))}let d;if(typeof c=="string"?(d=f===c,this.debug("string match",c,f,d)):(d=c.test(f),this.debug("pattern match",c,f,d)),!d)return!1}if(o===a&&h===l)return!0;if(o===a)return s;if(h===l)return o===a-1&&t[o]==="";throw new Error("wtf?")}braceExpand(){return gs(this.pattern,this.options)}parse(t){Nt(t);let e=this.options;if(t==="**")return _;if(t==="")return"";let s,i=null;(s=t.match(Ri))?i=e.dot?Oi:ki:(s=t.match(wi))?i=(e.nocase?e.dot?Ei:Si:e.dot?bi:yi)(s[1]):(s=t.match(Di))?i=(e.nocase?e.dot?Mi:Fi:e.dot?Ni:_i)(s):(s=t.match(vi))?i=e.dot?Ci:xi:(s=t.match(Ti))&&(i=Ai);let r=ht.fromGlob(t,this.options).toMMPattern();return i&&typeof r=="object"&&Reflect.defineProperty(r,"test",{value:i}),r}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let t=this.set;if(!t.length)return this.regexp=!1,this.regexp;let e=this.options,s=e.noglobstar?Wi:e.dot?Pi:ji,i=new Set(e.nocase?["i"]:[]),r=t.map(a=>{let l=a.map(c=>{if(c instanceof RegExp)for(let f of c.flags.split(""))i.add(f);return typeof c=="string"?Gi(c):c===_?_:c._src});return l.forEach((c,f)=>{let u=l[f+1],m=l[f-1];c!==_||m===_||(m===void 0?u!==void 0&&u!==_?l[f+1]="(?:\\/|"+s+"\\/)?"+u:l[f]=s:u===void 0?l[f-1]=m+"(?:\\/|"+s+")?":u!==_&&(l[f-1]=m+"(?:\\/|\\/"+s+"\\/)"+u,l[f+1]=_))}),l.filter(c=>c!==_).join("/")}).join("|"),[o,h]=t.length>1?["(?:",")"]:["",""];r="^"+o+r+h+"$",this.negate&&(r="^(?!"+r+").+$");try{this.regexp=new RegExp(r,[...i].join(""))}catch{this.regexp=!1}return this.regexp}slashSplit(t){return this.preserveMultipleSlashes?t.split("/"):this.isWindows&&/^\/\/[^\/]+/.test(t)?["",...t.split(/\/+/)]:t.split(/\/+/)}match(t,e=this.partial){if(this.debug("match",t,this.pattern),this.comment)return!1;if(this.empty)return t==="";if(t==="/"&&e)return!0;let s=this.options;this.isWindows&&(t=t.split("\\").join("/"));let i=this.slashSplit(t);this.debug(this.pattern,"split",i);let r=this.set;this.debug(this.pattern,"set",r);let o=i[i.length-1];if(!o)for(let h=i.length-2;!o&&h>=0;h--)o=i[h];for(let h=0;h<r.length;h++){let a=r[h],l=i;if(s.matchBase&&a.length===1&&(l=[o]),this.matchOne(l,a,e))return s.flipNegate?!0:!this.negate}return s.flipNegate?!1:this.negate}static defaults(t){return W.defaults(t).Minimatch}};W.AST=ht;W.Minimatch=$;W.escape=St;W.unescape=V;import{fileURLToPath as vr}from"node:url";var Et=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,ys=new Set,xe=typeof process=="object"&&process?process:{},bs=(n,t,e,s)=>{typeof xe.emitWarning=="function"?xe.emitWarning(n,t,e,s):console.error(`[${e}] ${t}: ${n}`)},se=globalThis.AbortController,ws=globalThis.AbortSignal;if(typeof se>"u"){ws=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(s,i){this._onabort.push(i)}},se=class{constructor(){t()}signal=new ws;abort(s){if(!this.signal.aborted){this.signal.reason=s,this.signal.aborted=!0;for(let i of this.signal._onabort)i(s);this.signal.onabort?.(s)}}};let n=xe.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",t=()=>{n&&(n=!1,bs("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",t))}}var Hi=n=>!ys.has(n),nn=Symbol("type"),at=n=>n&&n===Math.floor(n)&&n>0&&isFinite(n),Ss=n=>at(n)?n<=Math.pow(2,8)?Uint8Array:n<=Math.pow(2,16)?Uint16Array:n<=Math.pow(2,32)?Uint32Array:n<=Number.MAX_SAFE_INTEGER?xt:null:null,xt=class extends Array{constructor(t){super(t),this.fill(0)}},Ct,vt=class{heap;length;static create(t){let e=Ss(t);if(!e)return[];x(vt,Ct,!0);let s=new vt(t,e);return x(vt,Ct,!1),s}constructor(t,e){if(!p(vt,Ct))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new e(t),this.length=0}push(t){this.heap[this.length++]=t}pop(){return this.heap[--this.length]}},ee=vt;Ct=new WeakMap,O(ee,Ct,!1);var mt=class{#e;#i;#r;#h;#f;#k;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#l;#p;#a;#n;#s;#y;#b;#g;#u;#v;#d;#x;#C;#w;#S;#E;#c;static unsafeExposeInternals(t){return{starts:t.#C,ttls:t.#w,sizes:t.#x,keyMap:t.#a,keyList:t.#n,valList:t.#s,next:t.#y,prev:t.#b,get head(){return t.#g},get tail(){return t.#u},free:t.#v,isBackgroundFetch:e=>t.#o(e),backgroundFetch:(e,s,i,r)=>t.#P(e,s,i,r),moveToTail:e=>t.#z(e),indexes:e=>t.#A(e),rindexes:e=>t.#R(e),isStale:e=>t.#m(e)}}get max(){return this.#e}get maxSize(){return this.#i}get calculatedSize(){return this.#p}get size(){return this.#l}get fetchMethod(){return this.#f}get memoMethod(){return this.#k}get dispose(){return this.#r}get disposeAfter(){return this.#h}constructor(t){let{max:e=0,ttl:s,ttlResolution:i=1,ttlAutopurge:r,updateAgeOnGet:o,updateAgeOnHas:h,allowStale:a,dispose:l,disposeAfter:c,noDisposeOnSet:f,noUpdateTTL:u,maxSize:m=0,maxEntrySize:y=0,sizeCalculation:d,fetchMethod:w,memoMethod:g,noDeleteOnFetchRejection:b,noDeleteOnStaleGet:E,allowStaleOnFetchRejection:S,allowStaleOnFetchAbort:v,ignoreFetchAbort:k}=t;if(e!==0&&!at(e))throw new TypeError("max option must be a nonnegative integer");let q=e?Ss(e):Array;if(!q)throw new Error("invalid max value: "+e);if(this.#e=e,this.#i=m,this.maxEntrySize=y||this.#i,this.sizeCalculation=d,this.sizeCalculation){if(!this.#i&&!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(g!==void 0&&typeof g!="function")throw new TypeError("memoMethod must be a function if defined");if(this.#k=g,w!==void 0&&typeof w!="function")throw new TypeError("fetchMethod must be a function if specified");if(this.#f=w,this.#E=!!w,this.#a=new Map,this.#n=new Array(e).fill(void 0),this.#s=new Array(e).fill(void 0),this.#y=new q(e),this.#b=new q(e),this.#g=0,this.#u=0,this.#v=ee.create(e),this.#l=0,this.#p=0,typeof l=="function"&&(this.#r=l),typeof c=="function"?(this.#h=c,this.#d=[]):(this.#h=void 0,this.#d=void 0),this.#S=!!this.#r,this.#c=!!this.#h,this.noDisposeOnSet=!!f,this.noUpdateTTL=!!u,this.noDeleteOnFetchRejection=!!b,this.allowStaleOnFetchRejection=!!S,this.allowStaleOnFetchAbort=!!v,this.ignoreFetchAbort=!!k,this.maxEntrySize!==0){if(this.#i!==0&&!at(this.#i))throw new TypeError("maxSize must be a positive integer if specified");if(!at(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#D()}if(this.allowStale=!!a,this.noDeleteOnStaleGet=!!E,this.updateAgeOnGet=!!o,this.updateAgeOnHas=!!h,this.ttlResolution=at(i)||i===0?i:1,this.ttlAutopurge=!!r,this.ttl=s||0,this.ttl){if(!at(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#O()}if(this.#e===0&&this.ttl===0&&this.#i===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#e&&!this.#i){let ut="LRU_CACHE_UNBOUNDED";Hi(ut)&&(ys.add(ut),bs("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",ut,mt))}}getRemainingTTL(t){return this.#a.has(t)?1/0:0}#O(){let t=new xt(this.#e),e=new xt(this.#e);this.#w=t,this.#C=e,this.#M=(r,o,h=Et.now())=>{if(e[r]=o!==0?h:0,t[r]=o,o!==0&&this.ttlAutopurge){let a=setTimeout(()=>{this.#m(r)&&this.#F(this.#n[r],"expire")},o+1);a.unref&&a.unref()}},this.#T=r=>{e[r]=t[r]!==0?Et.now():0},this.#t=(r,o)=>{if(t[o]){let h=t[o],a=e[o];if(!h||!a)return;r.ttl=h,r.start=a,r.now=s||i();let l=r.now-a;r.remainingTTL=h-l}};let s=0,i=()=>{let r=Et.now();if(this.ttlResolution>0){s=r;let o=setTimeout(()=>s=0,this.ttlResolution);o.unref&&o.unref()}return r};this.getRemainingTTL=r=>{let o=this.#a.get(r);if(o===void 0)return 0;let h=t[o],a=e[o];if(!h||!a)return 1/0;let l=(s||i())-a;return h-l},this.#m=r=>{let o=e[r],h=t[r];return!!h&&!!o&&(s||i())-o>h}}#T=()=>{};#t=()=>{};#M=()=>{};#m=()=>!1;#D(){let t=new xt(this.#e);this.#p=0,this.#x=t,this.#N=e=>{this.#p-=t[e],t[e]=0},this.#L=(e,s,i,r)=>{if(this.#o(s))return 0;if(!at(i))if(r){if(typeof r!="function")throw new TypeError("sizeCalculation must be a function");if(i=r(s,e),!at(i))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 i},this.#_=(e,s,i)=>{if(t[e]=s,this.#i){let r=this.#i-t[e];for(;this.#p>r;)this.#W(!0)}this.#p+=t[e],i&&(i.entrySize=s,i.totalCalculatedSize=this.#p)}}#N=t=>{};#_=(t,e,s)=>{};#L=(t,e,s,i)=>{if(s||i)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#A({allowStale:t=this.allowStale}={}){if(this.#l)for(let e=this.#u;!(!this.#I(e)||((t||!this.#m(e))&&(yield e),e===this.#g));)e=this.#b[e]}*#R({allowStale:t=this.allowStale}={}){if(this.#l)for(let e=this.#g;!(!this.#I(e)||((t||!this.#m(e))&&(yield e),e===this.#u));)e=this.#y[e]}#I(t){return t!==void 0&&this.#a.get(this.#n[t])===t}*entries(){for(let t of this.#A())this.#s[t]!==void 0&&this.#n[t]!==void 0&&!this.#o(this.#s[t])&&(yield[this.#n[t],this.#s[t]])}*rentries(){for(let t of this.#R())this.#s[t]!==void 0&&this.#n[t]!==void 0&&!this.#o(this.#s[t])&&(yield[this.#n[t],this.#s[t]])}*keys(){for(let t of this.#A()){let e=this.#n[t];e!==void 0&&!this.#o(this.#s[t])&&(yield e)}}*rkeys(){for(let t of this.#R()){let e=this.#n[t];e!==void 0&&!this.#o(this.#s[t])&&(yield e)}}*values(){for(let t of this.#A())this.#s[t]!==void 0&&!this.#o(this.#s[t])&&(yield this.#s[t])}*rvalues(){for(let t of this.#R())this.#s[t]!==void 0&&!this.#o(this.#s[t])&&(yield this.#s[t])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(t,e={}){for(let s of this.#A()){let i=this.#s[s],r=this.#o(i)?i.__staleWhileFetching:i;if(r!==void 0&&t(r,this.#n[s],this))return this.get(this.#n[s],e)}}forEach(t,e=this){for(let s of this.#A()){let i=this.#s[s],r=this.#o(i)?i.__staleWhileFetching:i;r!==void 0&&t.call(e,r,this.#n[s],this)}}rforEach(t,e=this){for(let s of this.#R()){let i=this.#s[s],r=this.#o(i)?i.__staleWhileFetching:i;r!==void 0&&t.call(e,r,this.#n[s],this)}}purgeStale(){let t=!1;for(let e of this.#R({allowStale:!0}))this.#m(e)&&(this.#F(this.#n[e],"expire"),t=!0);return t}info(t){let e=this.#a.get(t);if(e===void 0)return;let s=this.#s[e],i=this.#o(s)?s.__staleWhileFetching:s;if(i===void 0)return;let r={value:i};if(this.#w&&this.#C){let o=this.#w[e],h=this.#C[e];if(o&&h){let a=o-(Et.now()-h);r.ttl=a,r.start=Date.now()}}return this.#x&&(r.size=this.#x[e]),r}dump(){let t=[];for(let e of this.#A({allowStale:!0})){let s=this.#n[e],i=this.#s[e],r=this.#o(i)?i.__staleWhileFetching:i;if(r===void 0||s===void 0)continue;let o={value:r};if(this.#w&&this.#C){o.ttl=this.#w[e];let h=Et.now()-this.#C[e];o.start=Math.floor(Date.now()-h)}this.#x&&(o.size=this.#x[e]),t.unshift([s,o])}return t}load(t){this.clear();for(let[e,s]of t){if(s.start){let i=Date.now()-s.start;s.start=Et.now()-i}this.set(e,s.value,s)}}set(t,e,s={}){if(e===void 0)return this.delete(t),this;let{ttl:i=this.ttl,start:r,noDisposeOnSet:o=this.noDisposeOnSet,sizeCalculation:h=this.sizeCalculation,status:a}=s,{noUpdateTTL:l=this.noUpdateTTL}=s,c=this.#L(t,e,s.size||0,h);if(this.maxEntrySize&&c>this.maxEntrySize)return a&&(a.set="miss",a.maxEntrySizeExceeded=!0),this.#F(t,"set"),this;let f=this.#l===0?void 0:this.#a.get(t);if(f===void 0)f=this.#l===0?this.#u:this.#v.length!==0?this.#v.pop():this.#l===this.#e?this.#W(!1):this.#l,this.#n[f]=t,this.#s[f]=e,this.#a.set(t,f),this.#y[this.#u]=f,this.#b[f]=this.#u,this.#u=f,this.#l++,this.#_(f,c,a),a&&(a.set="add"),l=!1;else{this.#z(f);let u=this.#s[f];if(e!==u){if(this.#E&&this.#o(u)){u.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:m}=u;m!==void 0&&!o&&(this.#S&&this.#r?.(m,t,"set"),this.#c&&this.#d?.push([m,t,"set"]))}else o||(this.#S&&this.#r?.(u,t,"set"),this.#c&&this.#d?.push([u,t,"set"]));if(this.#N(f),this.#_(f,c,a),this.#s[f]=e,a){a.set="replace";let m=u&&this.#o(u)?u.__staleWhileFetching:u;m!==void 0&&(a.oldValue=m)}}else a&&(a.set="update")}if(i!==0&&!this.#w&&this.#O(),this.#w&&(l||this.#M(f,i,r),a&&this.#t(a,f)),!o&&this.#c&&this.#d){let u=this.#d,m;for(;m=u?.shift();)this.#h?.(...m)}return this}pop(){try{for(;this.#l;){let t=this.#s[this.#g];if(this.#W(!0),this.#o(t)){if(t.__staleWhileFetching)return t.__staleWhileFetching}else if(t!==void 0)return t}}finally{if(this.#c&&this.#d){let t=this.#d,e;for(;e=t?.shift();)this.#h?.(...e)}}}#W(t){let e=this.#g,s=this.#n[e],i=this.#s[e];return this.#E&&this.#o(i)?i.__abortController.abort(new Error("evicted")):(this.#S||this.#c)&&(this.#S&&this.#r?.(i,s,"evict"),this.#c&&this.#d?.push([i,s,"evict"])),this.#N(e),t&&(this.#n[e]=void 0,this.#s[e]=void 0,this.#v.push(e)),this.#l===1?(this.#g=this.#u=0,this.#v.length=0):this.#g=this.#y[e],this.#a.delete(s),this.#l--,e}has(t,e={}){let{updateAgeOnHas:s=this.updateAgeOnHas,status:i}=e,r=this.#a.get(t);if(r!==void 0){let o=this.#s[r];if(this.#o(o)&&o.__staleWhileFetching===void 0)return!1;if(this.#m(r))i&&(i.has="stale",this.#t(i,r));else return s&&this.#T(r),i&&(i.has="hit",this.#t(i,r)),!0}else i&&(i.has="miss");return!1}peek(t,e={}){let{allowStale:s=this.allowStale}=e,i=this.#a.get(t);if(i===void 0||!s&&this.#m(i))return;let r=this.#s[i];return this.#o(r)?r.__staleWhileFetching:r}#P(t,e,s,i){let r=e===void 0?void 0:this.#s[e];if(this.#o(r))return r;let o=new se,{signal:h}=s;h?.addEventListener("abort",()=>o.abort(h.reason),{signal:o.signal});let a={signal:o.signal,options:s,context:i},l=(d,w=!1)=>{let{aborted:g}=o.signal,b=s.ignoreFetchAbort&&d!==void 0;if(s.status&&(g&&!w?(s.status.fetchAborted=!0,s.status.fetchError=o.signal.reason,b&&(s.status.fetchAbortIgnored=!0)):s.status.fetchResolved=!0),g&&!b&&!w)return f(o.signal.reason);let E=m;return this.#s[e]===m&&(d===void 0?E.__staleWhileFetching?this.#s[e]=E.__staleWhileFetching:this.#F(t,"fetch"):(s.status&&(s.status.fetchUpdated=!0),this.set(t,d,a.options))),d},c=d=>(s.status&&(s.status.fetchRejected=!0,s.status.fetchError=d),f(d)),f=d=>{let{aborted:w}=o.signal,g=w&&s.allowStaleOnFetchAbort,b=g||s.allowStaleOnFetchRejection,E=b||s.noDeleteOnFetchRejection,S=m;if(this.#s[e]===m&&(!E||S.__staleWhileFetching===void 0?this.#F(t,"fetch"):g||(this.#s[e]=S.__staleWhileFetching)),b)return s.status&&S.__staleWhileFetching!==void 0&&(s.status.returnedStale=!0),S.__staleWhileFetching;if(S.__returned===S)throw d},u=(d,w)=>{let g=this.#f?.(t,r,a);g&&g instanceof Promise&&g.then(b=>d(b===void 0?void 0:b),w),o.signal.addEventListener("abort",()=>{(!s.ignoreFetchAbort||s.allowStaleOnFetchAbort)&&(d(void 0),s.allowStaleOnFetchAbort&&(d=b=>l(b,!0)))})};s.status&&(s.status.fetchDispatched=!0);let m=new Promise(u).then(l,c),y=Object.assign(m,{__abortController:o,__staleWhileFetching:r,__returned:void 0});return e===void 0?(this.set(t,y,{...a.options,status:void 0}),e=this.#a.get(t)):this.#s[e]=y,y}#o(t){if(!this.#E)return!1;let e=t;return!!e&&e instanceof Promise&&e.hasOwnProperty("__staleWhileFetching")&&e.__abortController instanceof se}async fetch(t,e={}){let{allowStale:s=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:r=this.noDeleteOnStaleGet,ttl:o=this.ttl,noDisposeOnSet:h=this.noDisposeOnSet,size:a=0,sizeCalculation:l=this.sizeCalculation,noUpdateTTL:c=this.noUpdateTTL,noDeleteOnFetchRejection:f=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:u=this.allowStaleOnFetchRejection,ignoreFetchAbort:m=this.ignoreFetchAbort,allowStaleOnFetchAbort:y=this.allowStaleOnFetchAbort,context:d,forceRefresh:w=!1,status:g,signal:b}=e;if(!this.#E)return g&&(g.fetch="get"),this.get(t,{allowStale:s,updateAgeOnGet:i,noDeleteOnStaleGet:r,status:g});let E={allowStale:s,updateAgeOnGet:i,noDeleteOnStaleGet:r,ttl:o,noDisposeOnSet:h,size:a,sizeCalculation:l,noUpdateTTL:c,noDeleteOnFetchRejection:f,allowStaleOnFetchRejection:u,allowStaleOnFetchAbort:y,ignoreFetchAbort:m,status:g,signal:b},S=this.#a.get(t);if(S===void 0){g&&(g.fetch="miss");let v=this.#P(t,S,E,d);return v.__returned=v}else{let v=this.#s[S];if(this.#o(v)){let Jt=s&&v.__staleWhileFetching!==void 0;return g&&(g.fetch="inflight",Jt&&(g.returnedStale=!0)),Jt?v.__staleWhileFetching:v.__returned=v}let k=this.#m(S);if(!w&&!k)return g&&(g.fetch="hit"),this.#z(S),i&&this.#T(S),g&&this.#t(g,S),v;let q=this.#P(t,S,E,d),K=q.__staleWhileFetching!==void 0&&s;return g&&(g.fetch=k?"stale":"refresh",K&&k&&(g.returnedStale=!0)),K?q.__staleWhileFetching:q.__returned=q}}async forceFetch(t,e={}){let s=await this.fetch(t,e);if(s===void 0)throw new Error("fetch() returned undefined");return s}memo(t,e={}){let s=this.#k;if(!s)throw new Error("no memoMethod provided to constructor");let{context:i,forceRefresh:r,...o}=e,h=this.get(t,o);if(!r&&h!==void 0)return h;let a=s(t,h,{options:o,context:i});return this.set(t,a,o),a}get(t,e={}){let{allowStale:s=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:r=this.noDeleteOnStaleGet,status:o}=e,h=this.#a.get(t);if(h!==void 0){let a=this.#s[h],l=this.#o(a);return o&&this.#t(o,h),this.#m(h)?(o&&(o.get="stale"),l?(o&&s&&a.__staleWhileFetching!==void 0&&(o.returnedStale=!0),s?a.__staleWhileFetching:void 0):(r||this.#F(t,"expire"),o&&s&&(o.returnedStale=!0),s?a:void 0)):(o&&(o.get="hit"),l?a.__staleWhileFetching:(this.#z(h),i&&this.#T(h),a))}else o&&(o.get="miss")}#j(t,e){this.#b[e]=t,this.#y[t]=e}#z(t){t!==this.#u&&(t===this.#g?this.#g=this.#y[t]:this.#j(this.#b[t],this.#y[t]),this.#j(this.#u,t),this.#u=t)}delete(t){return this.#F(t,"delete")}#F(t,e){let s=!1;if(this.#l!==0){let i=this.#a.get(t);if(i!==void 0)if(s=!0,this.#l===1)this.#$(e);else{this.#N(i);let r=this.#s[i];if(this.#o(r)?r.__abortController.abort(new Error("deleted")):(this.#S||this.#c)&&(this.#S&&this.#r?.(r,t,e),this.#c&&this.#d?.push([r,t,e])),this.#a.delete(t),this.#n[i]=void 0,this.#s[i]=void 0,i===this.#u)this.#u=this.#b[i];else if(i===this.#g)this.#g=this.#y[i];else{let o=this.#b[i];this.#y[o]=this.#y[i];let h=this.#y[i];this.#b[h]=this.#b[i]}this.#l--,this.#v.push(i)}}if(this.#c&&this.#d?.length){let i=this.#d,r;for(;r=i?.shift();)this.#h?.(...r)}return s}clear(){return this.#$("delete")}#$(t){for(let e of this.#R({allowStale:!0})){let s=this.#s[e];if(this.#o(s))s.__abortController.abort(new Error("deleted"));else{let i=this.#n[e];this.#S&&this.#r?.(s,i,t),this.#c&&this.#d?.push([s,i,t])}}if(this.#a.clear(),this.#s.fill(void 0),this.#n.fill(void 0),this.#w&&this.#C&&(this.#w.fill(0),this.#C.fill(0)),this.#x&&this.#x.fill(0),this.#g=0,this.#u=0,this.#v.length=0,this.#p=0,this.#l=0,this.#c&&this.#d){let e=this.#d,s;for(;s=e?.shift();)this.#h?.(...s)}}};import{posix as sr,win32 as Ne}from"node:path";import{fileURLToPath as ir}from"node:url";import{lstatSync as rr,readdir as nr,readdirSync as or,readlinkSync as hr,realpathSync as ar}from"fs";import*as lr from"node:fs";import{lstat as fr,readdir as ur,readlink as dr,realpath as pr}from"node:fs/promises";import{EventEmitter as De}from"node:events";import Ts from"node:stream";import{StringDecoder as qi}from"node:string_decoder";var Es=typeof process=="object"&&process?process:{stdout:null,stderr:null},Ki=n=>!!n&&typeof n=="object"&&(n instanceof ct||n instanceof Ts||Vi(n)||Yi(n)),Vi=n=>!!n&&typeof n=="object"&&n instanceof De&&typeof n.pipe=="function"&&n.pipe!==Ts.Writable.prototype.pipe,Yi=n=>!!n&&typeof n=="object"&&n instanceof De&&typeof n.write=="function"&&typeof n.end=="function",st=Symbol("EOF"),it=Symbol("maybeEmitEnd"),lt=Symbol("emittedEnd"),ie=Symbol("emittingEnd"),Wt=Symbol("emittedError"),re=Symbol("closed"),vs=Symbol("read"),ne=Symbol("flush"),xs=Symbol("flushChunk"),Y=Symbol("encoding"),Tt=Symbol("decoder"),F=Symbol("flowing"),Pt=Symbol("paused"),At=Symbol("resume"),M=Symbol("buffer"),P=Symbol("pipes"),N=Symbol("bufferLength"),Ce=Symbol("bufferPush"),oe=Symbol("bufferShift"),L=Symbol("objectMode"),T=Symbol("destroyed"),Te=Symbol("error"),Ae=Symbol("emitData"),Cs=Symbol("emitEnd"),Re=Symbol("emitEnd2"),Q=Symbol("async"),ke=Symbol("abort"),he=Symbol("aborted"),jt=Symbol("signal"),gt=Symbol("dataListeners"),B=Symbol("discarded"),zt=n=>Promise.resolve().then(n),Ji=n=>n(),Zi=n=>n==="end"||n==="finish"||n==="prefinish",Xi=n=>n instanceof ArrayBuffer||!!n&&typeof n=="object"&&n.constructor&&n.constructor.name==="ArrayBuffer"&&n.byteLength>=0,Qi=n=>!Buffer.isBuffer(n)&&ArrayBuffer.isView(n),ae=class{src;dest;opts;ondrain;constructor(t,e,s){this.src=t,this.dest=e,this.opts=s,this.ondrain=()=>t[At](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(t){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},Oe=class extends ae{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(t,e,s){super(t,e,s),this.proxyErrors=i=>e.emit("error",i),t.on("error",this.proxyErrors)}},tr=n=>!!n.objectMode,er=n=>!n.objectMode&&!!n.encoding&&n.encoding!=="buffer",ct=class extends De{[F]=!1;[Pt]=!1;[P]=[];[M]=[];[L];[Y];[Q];[Tt];[st]=!1;[lt]=!1;[ie]=!1;[re]=!1;[Wt]=null;[N]=0;[T]=!1;[jt];[he]=!1;[gt]=0;[B]=!1;writable=!0;readable=!0;constructor(...t){let e=t[0]||{};if(super(),e.objectMode&&typeof e.encoding=="string")throw new TypeError("Encoding and objectMode may not be used together");tr(e)?(this[L]=!0,this[Y]=null):er(e)?(this[Y]=e.encoding,this[L]=!1):(this[L]=!1,this[Y]=null),this[Q]=!!e.async,this[Tt]=this[Y]?new qi(this[Y]):null,e&&e.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[M]}),e&&e.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[P]});let{signal:s}=e;s&&(this[jt]=s,s.aborted?this[ke]():s.addEventListener("abort",()=>this[ke]()))}get bufferLength(){return this[N]}get encoding(){return this[Y]}set encoding(t){throw new Error("Encoding must be set at instantiation time")}setEncoding(t){throw new Error("Encoding must be set at instantiation time")}get objectMode(){return this[L]}set objectMode(t){throw new Error("objectMode must be set at instantiation time")}get async(){return this[Q]}set async(t){this[Q]=this[Q]||!!t}[ke](){this[he]=!0,this.emit("abort",this[jt]?.reason),this.destroy(this[jt]?.reason)}get aborted(){return this[he]}set aborted(t){}write(t,e,s){if(this[he])return!1;if(this[st])throw new Error("write after end");if(this[T])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;typeof e=="function"&&(s=e,e="utf8"),e||(e="utf8");let i=this[Q]?zt:Ji;if(!this[L]&&!Buffer.isBuffer(t)){if(Qi(t))t=Buffer.from(t.buffer,t.byteOffset,t.byteLength);else if(Xi(t))t=Buffer.from(t);else if(typeof t!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[L]?(this[F]&&this[N]!==0&&this[ne](!0),this[F]?this.emit("data",t):this[Ce](t),this[N]!==0&&this.emit("readable"),s&&i(s),this[F]):t.length?(typeof t=="string"&&!(e===this[Y]&&!this[Tt]?.lastNeed)&&(t=Buffer.from(t,e)),Buffer.isBuffer(t)&&this[Y]&&(t=this[Tt].write(t)),this[F]&&this[N]!==0&&this[ne](!0),this[F]?this.emit("data",t):this[Ce](t),this[N]!==0&&this.emit("readable"),s&&i(s),this[F]):(this[N]!==0&&this.emit("readable"),s&&i(s),this[F])}read(t){if(this[T])return null;if(this[B]=!1,this[N]===0||t===0||t&&t>this[N])return this[it](),null;this[L]&&(t=null),this[M].length>1&&!this[L]&&(this[M]=[this[Y]?this[M].join(""):Buffer.concat(this[M],this[N])]);let e=this[vs](t||null,this[M][0]);return this[it](),e}[vs](t,e){if(this[L])this[oe]();else{let s=e;t===s.length||t===null?this[oe]():typeof s=="string"?(this[M][0]=s.slice(t),e=s.slice(0,t),this[N]-=t):(this[M][0]=s.subarray(t),e=s.subarray(0,t),this[N]-=t)}return this.emit("data",e),!this[M].length&&!this[st]&&this.emit("drain"),e}end(t,e,s){return typeof t=="function"&&(s=t,t=void 0),typeof e=="function"&&(s=e,e="utf8"),t!==void 0&&this.write(t,e),s&&this.once("end",s),this[st]=!0,this.writable=!1,(this[F]||!this[Pt])&&this[it](),this}[At](){this[T]||(!this[gt]&&!this[P].length&&(this[B]=!0),this[Pt]=!1,this[F]=!0,this.emit("resume"),this[M].length?this[ne]():this[st]?this[it]():this.emit("drain"))}resume(){return this[At]()}pause(){this[F]=!1,this[Pt]=!0,this[B]=!1}get destroyed(){return this[T]}get flowing(){return this[F]}get paused(){return this[Pt]}[Ce](t){this[L]?this[N]+=1:this[N]+=t.length,this[M].push(t)}[oe](){return this[L]?this[N]-=1:this[N]-=this[M][0].length,this[M].shift()}[ne](t=!1){do;while(this[xs](this[oe]())&&this[M].length);!t&&!this[M].length&&!this[st]&&this.emit("drain")}[xs](t){return this.emit("data",t),this[F]}pipe(t,e){if(this[T])return t;this[B]=!1;let s=this[lt];return e=e||{},t===Es.stdout||t===Es.stderr?e.end=!1:e.end=e.end!==!1,e.proxyErrors=!!e.proxyErrors,s?e.end&&t.end():(this[P].push(e.proxyErrors?new Oe(this,t,e):new ae(this,t,e)),this[Q]?zt(()=>this[At]()):this[At]()),t}unpipe(t){let e=this[P].find(s=>s.dest===t);e&&(this[P].length===1?(this[F]&&this[gt]===0&&(this[F]=!1),this[P]=[]):this[P].splice(this[P].indexOf(e),1),e.unpipe())}addListener(t,e){return this.on(t,e)}on(t,e){let s=super.on(t,e);if(t==="data")this[B]=!1,this[gt]++,!this[P].length&&!this[F]&&this[At]();else if(t==="readable"&&this[N]!==0)super.emit("readable");else if(Zi(t)&&this[lt])super.emit(t),this.removeAllListeners(t);else if(t==="error"&&this[Wt]){let i=e;this[Q]?zt(()=>i.call(this,this[Wt])):i.call(this,this[Wt])}return s}removeListener(t,e){return this.off(t,e)}off(t,e){let s=super.off(t,e);return t==="data"&&(this[gt]=this.listeners("data").length,this[gt]===0&&!this[B]&&!this[P].length&&(this[F]=!1)),s}removeAllListeners(t){let e=super.removeAllListeners(t);return(t==="data"||t===void 0)&&(this[gt]=0,!this[B]&&!this[P].length&&(this[F]=!1)),e}get emittedEnd(){return this[lt]}[it](){!this[ie]&&!this[lt]&&!this[T]&&this[M].length===0&&this[st]&&(this[ie]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[re]&&this.emit("close"),this[ie]=!1)}emit(t,...e){let s=e[0];if(t!=="error"&&t!=="close"&&t!==T&&this[T])return!1;if(t==="data")return!this[L]&&!s?!1:this[Q]?(zt(()=>this[Ae](s)),!0):this[Ae](s);if(t==="end")return this[Cs]();if(t==="close"){if(this[re]=!0,!this[lt]&&!this[T])return!1;let r=super.emit("close");return this.removeAllListeners("close"),r}else if(t==="error"){this[Wt]=s,super.emit(Te,s);let r=!this[jt]||this.listeners("error").length?super.emit("error",s):!1;return this[it](),r}else if(t==="resume"){let r=super.emit("resume");return this[it](),r}else if(t==="finish"||t==="prefinish"){let r=super.emit(t);return this.removeAllListeners(t),r}let i=super.emit(t,...e);return this[it](),i}[Ae](t){for(let s of this[P])s.dest.write(t)===!1&&this.pause();let e=this[B]?!1:super.emit("data",t);return this[it](),e}[Cs](){return this[lt]?!1:(this[lt]=!0,this.readable=!1,this[Q]?(zt(()=>this[Re]()),!0):this[Re]())}[Re](){if(this[Tt]){let e=this[Tt].end();if(e){for(let s of this[P])s.dest.write(e);this[B]||super.emit("data",e)}}for(let e of this[P])e.end();let t=super.emit("end");return this.removeAllListeners("end"),t}async collect(){let t=Object.assign([],{dataLength:0});this[L]||(t.dataLength=0);let e=this.promise();return this.on("data",s=>{t.push(s),this[L]||(t.dataLength+=s.length)}),await e,t}async concat(){if(this[L])throw new Error("cannot concat in objectMode");let t=await this.collect();return this[Y]?t.join(""):Buffer.concat(t,t.dataLength)}async promise(){return new Promise((t,e)=>{this.on(T,()=>e(new Error("stream destroyed"))),this.on("error",s=>e(s)),this.on("end",()=>t())})}[Symbol.asyncIterator](){this[B]=!1;let t=!1,e=async()=>(this.pause(),t=!0,{value:void 0,done:!0});return{next:()=>{if(t)return e();let i=this.read();if(i!==null)return Promise.resolve({done:!1,value:i});if(this[st])return e();let r,o,h=f=>{this.off("data",a),this.off("end",l),this.off(T,c),e(),o(f)},a=f=>{this.off("error",h),this.off("end",l),this.off(T,c),this.pause(),r({value:f,done:!!this[st]})},l=()=>{this.off("error",h),this.off("data",a),this.off(T,c),e(),r({done:!0,value:void 0})},c=()=>h(new Error("stream destroyed"));return new Promise((f,u)=>{o=u,r=f,this.once(T,c),this.once("error",h),this.once("end",l),this.once("data",a)})},throw:e,return:e,[Symbol.asyncIterator](){return this}}}[Symbol.iterator](){this[B]=!1;let t=!1,e=()=>(this.pause(),this.off(Te,e),this.off(T,e),this.off("end",e),t=!0,{done:!0,value:void 0}),s=()=>{if(t)return e();let i=this.read();return i===null?e():{done:!1,value:i}};return this.once("end",e),this.once(Te,e),this.once(T,e),{next:s,throw:e,return:e,[Symbol.iterator](){return this}}}destroy(t){if(this[T])return t?this.emit("error",t):this.emit(T),this;this[T]=!0,this[B]=!0,this[M].length=0,this[N]=0;let e=this;return typeof e.close=="function"&&!this[re]&&e.close(),t?this.emit("error",t):this.emit(T),this}static get isStream(){return Ki}};var cr=ar.native,Bt={lstatSync:rr,readdir:nr,readdirSync:or,readlinkSync:hr,realpathSync:cr,promises:{lstat:fr,readdir:ur,readlink:dr,realpath:pr}},Ds=n=>!n||n===Bt||n===lr?Bt:{...Bt,...n,promises:{...Bt.promises,...n.promises||{}}},Fs=/^\\\\\?\\([a-z]:)\\?$/i,mr=n=>n.replace(/\//g,"\\").replace(Fs,"$1\\"),gr=/[\\\/]/,H=0,Ms=1,Ns=2,tt=4,_s=6,Ls=8,wt=10,Is=12,G=15,$t=~G,Fe=16,As=32,Ut=64,J=128,le=256,fe=512,Rs=Ut|J|fe,wr=1023,Me=n=>n.isFile()?Ls:n.isDirectory()?tt:n.isSymbolicLink()?wt:n.isCharacterDevice()?Ns:n.isBlockDevice()?_s:n.isSocket()?Is:n.isFIFO()?Ms:H,ks=new Map,Gt=n=>{let t=ks.get(n);if(t)return t;let e=n.normalize("NFKD");return ks.set(n,e),e},Os=new Map,ce=n=>{let t=Os.get(n);if(t)return t;let e=Gt(n.toLowerCase());return Os.set(n,e),e},ue=class extends mt{constructor(){super({max:256})}},_e=class extends mt{constructor(t=16*1024){super({maxSize:t,sizeCalculation:e=>e.length+1})}},Ws=Symbol("PathScurry setAsCwd"),I=class{name;root;roots;parent;nocase;isCWD=!1;#e;#i;get dev(){return this.#i}#r;get mode(){return this.#r}#h;get nlink(){return this.#h}#f;get uid(){return this.#f}#k;get gid(){return this.#k}#l;get rdev(){return this.#l}#p;get blksize(){return this.#p}#a;get ino(){return this.#a}#n;get size(){return this.#n}#s;get blocks(){return this.#s}#y;get atimeMs(){return this.#y}#b;get mtimeMs(){return this.#b}#g;get ctimeMs(){return this.#g}#u;get birthtimeMs(){return this.#u}#v;get atime(){return this.#v}#d;get mtime(){return this.#d}#x;get ctime(){return this.#x}#C;get birthtime(){return this.#C}#w;#S;#E;#c;#O;#T;#t;#M;#m;#D;get parentPath(){return(this.parent||this).fullpath()}get path(){return this.parentPath}constructor(t,e=H,s,i,r,o,h){this.name=t,this.#w=r?ce(t):Gt(t),this.#t=e&wr,this.nocase=r,this.roots=i,this.root=s||this,this.#M=o,this.#E=h.fullpath,this.#O=h.relative,this.#T=h.relativePosix,this.parent=h.parent,this.parent?this.#e=this.parent.#e:this.#e=Ds(h.fs)}depth(){return this.#S!==void 0?this.#S:this.parent?this.#S=this.parent.depth()+1:this.#S=0}childrenCache(){return this.#M}resolve(t){if(!t)return this;let e=this.getRootString(t),i=t.substring(e.length).split(this.splitSep);return e?this.getRoot(e).#N(i):this.#N(i)}#N(t){let e=this;for(let s of t)e=e.child(s);return e}children(){let t=this.#M.get(this);if(t)return t;let e=Object.assign([],{provisional:0});return this.#M.set(this,e),this.#t&=~Fe,e}child(t,e){if(t===""||t===".")return this;if(t==="..")return this.parent||this;let s=this.children(),i=this.nocase?ce(t):Gt(t);for(let a of s)if(a.#w===i)return a;let r=this.parent?this.sep:"",o=this.#E?this.#E+r+t:void 0,h=this.newChild(t,H,{...e,parent:this,fullpath:o});return this.canReaddir()||(h.#t|=J),s.push(h),h}relative(){if(this.isCWD)return"";if(this.#O!==void 0)return this.#O;let t=this.name,e=this.parent;if(!e)return this.#O=this.name;let s=e.relative();return s+(!s||!e.parent?"":this.sep)+t}relativePosix(){if(this.sep==="/")return this.relative();if(this.isCWD)return"";if(this.#T!==void 0)return this.#T;let t=this.name,e=this.parent;if(!e)return this.#T=this.fullpathPosix();let s=e.relativePosix();return s+(!s||!e.parent?"":"/")+t}fullpath(){if(this.#E!==void 0)return this.#E;let t=this.name,e=this.parent;if(!e)return this.#E=this.name;let i=e.fullpath()+(e.parent?this.sep:"")+t;return this.#E=i}fullpathPosix(){if(this.#c!==void 0)return this.#c;if(this.sep==="/")return this.#c=this.fullpath();if(!this.parent){let i=this.fullpath().replace(/\\/g,"/");return/^[a-z]:\//i.test(i)?this.#c=`//?/${i}`:this.#c=i}let t=this.parent,e=t.fullpathPosix(),s=e+(!e||!t.parent?"":"/")+this.name;return this.#c=s}isUnknown(){return(this.#t&G)===H}isType(t){return this[`is${t}`]()}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.#t&G)===Ls}isDirectory(){return(this.#t&G)===tt}isCharacterDevice(){return(this.#t&G)===Ns}isBlockDevice(){return(this.#t&G)===_s}isFIFO(){return(this.#t&G)===Ms}isSocket(){return(this.#t&G)===Is}isSymbolicLink(){return(this.#t&wt)===wt}lstatCached(){return this.#t&As?this:void 0}readlinkCached(){return this.#m}realpathCached(){return this.#D}readdirCached(){let t=this.children();return t.slice(0,t.provisional)}canReadlink(){if(this.#m)return!0;if(!this.parent)return!1;let t=this.#t&G;return!(t!==H&&t!==wt||this.#t&le||this.#t&J)}calledReaddir(){return!!(this.#t&Fe)}isENOENT(){return!!(this.#t&J)}isNamed(t){return this.nocase?this.#w===ce(t):this.#w===Gt(t)}async readlink(){let t=this.#m;if(t)return t;if(this.canReadlink()&&this.parent)try{let e=await this.#e.promises.readlink(this.fullpath()),s=(await this.parent.realpath())?.resolve(e);if(s)return this.#m=s}catch(e){this.#o(e.code);return}}readlinkSync(){let t=this.#m;if(t)return t;if(this.canReadlink()&&this.parent)try{let e=this.#e.readlinkSync(this.fullpath()),s=this.parent.realpathSync()?.resolve(e);if(s)return this.#m=s}catch(e){this.#o(e.code);return}}#_(t){this.#t|=Fe;for(let e=t.provisional;e<t.length;e++){let s=t[e];s&&s.#L()}}#L(){this.#t&J||(this.#t=(this.#t|J)&$t,this.#A())}#A(){let t=this.children();t.provisional=0;for(let e of t)e.#L()}#R(){this.#t|=fe,this.#I()}#I(){if(this.#t&Ut)return;let t=this.#t;(t&G)===tt&&(t&=$t),this.#t=t|Ut,this.#A()}#W(t=""){t==="ENOTDIR"||t==="EPERM"?this.#I():t==="ENOENT"?this.#L():this.children().provisional=0}#P(t=""){t==="ENOTDIR"?this.parent.#I():t==="ENOENT"&&this.#L()}#o(t=""){let e=this.#t;e|=le,t==="ENOENT"&&(e|=J),(t==="EINVAL"||t==="UNKNOWN")&&(e&=$t),this.#t=e,t==="ENOTDIR"&&this.parent&&this.parent.#I()}#j(t,e){return this.#F(t,e)||this.#z(t,e)}#z(t,e){let s=Me(t),i=this.newChild(t.name,s,{parent:this}),r=i.#t&G;return r!==tt&&r!==wt&&r!==H&&(i.#t|=Ut),e.unshift(i),e.provisional++,i}#F(t,e){for(let s=e.provisional;s<e.length;s++){let i=e[s];if((this.nocase?ce(t.name):Gt(t.name))===i.#w)return this.#$(t,i,s,e)}}#$(t,e,s,i){let r=e.name;return e.#t=e.#t&$t|Me(t),r!==t.name&&(e.name=t.name),s!==i.provisional&&(s===i.length-1?i.pop():i.splice(s,1),i.unshift(e)),i.provisional++,e}async lstat(){if(!(this.#t&J))try{return this.#H(await this.#e.promises.lstat(this.fullpath())),this}catch(t){this.#P(t.code)}}lstatSync(){if(!(this.#t&J))try{return this.#H(this.#e.lstatSync(this.fullpath())),this}catch(t){this.#P(t.code)}}#H(t){let{atime:e,atimeMs:s,birthtime:i,birthtimeMs:r,blksize:o,blocks:h,ctime:a,ctimeMs:l,dev:c,gid:f,ino:u,mode:m,mtime:y,mtimeMs:d,nlink:w,rdev:g,size:b,uid:E}=t;this.#v=e,this.#y=s,this.#C=i,this.#u=r,this.#p=o,this.#s=h,this.#x=a,this.#g=l,this.#i=c,this.#k=f,this.#a=u,this.#r=m,this.#d=y,this.#b=d,this.#h=w,this.#l=g,this.#n=b,this.#f=E;let S=Me(t);this.#t=this.#t&$t|S|As,S!==H&&S!==tt&&S!==wt&&(this.#t|=Ut)}#U=[];#G=!1;#q(t){this.#G=!1;let e=this.#U.slice();this.#U.length=0,e.forEach(s=>s(null,t))}readdirCB(t,e=!1){if(!this.canReaddir()){e?t(null,[]):queueMicrotask(()=>t(null,[]));return}let s=this.children();if(this.calledReaddir()){let r=s.slice(0,s.provisional);e?t(null,r):queueMicrotask(()=>t(null,r));return}if(this.#U.push(t),this.#G)return;this.#G=!0;let i=this.fullpath();this.#e.readdir(i,{withFileTypes:!0},(r,o)=>{if(r)this.#W(r.code),s.provisional=0;else{for(let h of o)this.#j(h,s);this.#_(s)}this.#q(s.slice(0,s.provisional))})}#B;async readdir(){if(!this.canReaddir())return[];let t=this.children();if(this.calledReaddir())return t.slice(0,t.provisional);let e=this.fullpath();if(this.#B)await this.#B;else{let s=()=>{};this.#B=new Promise(i=>s=i);try{for(let i of await this.#e.promises.readdir(e,{withFileTypes:!0}))this.#j(i,t);this.#_(t)}catch(i){this.#W(i.code),t.provisional=0}this.#B=void 0,s()}return t.slice(0,t.provisional)}readdirSync(){if(!this.canReaddir())return[];let t=this.children();if(this.calledReaddir())return t.slice(0,t.provisional);let e=this.fullpath();try{for(let s of this.#e.readdirSync(e,{withFileTypes:!0}))this.#j(s,t);this.#_(t)}catch(s){this.#W(s.code),t.provisional=0}return t.slice(0,t.provisional)}canReaddir(){if(this.#t&Rs)return!1;let t=G&this.#t;return t===H||t===tt||t===wt}shouldWalk(t,e){return(this.#t&tt)===tt&&!(this.#t&Rs)&&!t.has(this)&&(!e||e(this))}async realpath(){if(this.#D)return this.#D;if(!((fe|le|J)&this.#t))try{let t=await this.#e.promises.realpath(this.fullpath());return this.#D=this.resolve(t)}catch{this.#R()}}realpathSync(){if(this.#D)return this.#D;if(!((fe|le|J)&this.#t))try{let t=this.#e.realpathSync(this.fullpath());return this.#D=this.resolve(t)}catch{this.#R()}}[Ws](t){if(t===this)return;t.isCWD=!1,this.isCWD=!0;let e=new Set([]),s=[],i=this;for(;i&&i.parent;)e.add(i),i.#O=s.join(this.sep),i.#T=s.join("/"),i=i.parent,s.push("..");for(i=t;i&&i.parent&&!e.has(i);)i.#O=void 0,i.#T=void 0,i=i.parent}},Rt=class extends I{sep="\\";splitSep=gr;constructor(t,e=H,s,i,r,o,h){super(t,e,s,i,r,o,h)}newChild(t,e=H,s={}){return new Rt(t,e,this.root,this.roots,this.nocase,this.childrenCache(),s)}getRootString(t){return Ne.parse(t).root}getRoot(t){if(t=mr(t.toUpperCase()),t===this.root.name)return this.root;for(let[e,s]of Object.entries(this.roots))if(this.sameRoot(t,e))return this.roots[t]=s;return this.roots[t]=new Ot(t,this).root}sameRoot(t,e=this.root.name){return t=t.toUpperCase().replace(/\//g,"\\").replace(Fs,"$1\\"),t===e}},kt=class extends I{splitSep="/";sep="/";constructor(t,e=H,s,i,r,o,h){super(t,e,s,i,r,o,h)}getRootString(t){return t.startsWith("/")?"/":""}getRoot(t){return this.root}newChild(t,e=H,s={}){return new kt(t,e,this.root,this.roots,this.nocase,this.childrenCache(),s)}},de=class{root;rootPath;roots;cwd;#e;#i;#r;nocase;#h;constructor(t=process.cwd(),e,s,{nocase:i,childrenCacheSize:r=16*1024,fs:o=Bt}={}){this.#h=Ds(o),(t instanceof URL||t.startsWith("file://"))&&(t=ir(t));let h=e.resolve(t);this.roots=Object.create(null),this.rootPath=this.parseRootPath(h),this.#e=new ue,this.#i=new ue,this.#r=new _e(r);let a=h.substring(this.rootPath.length).split(s);if(a.length===1&&!a[0]&&a.pop(),i===void 0)throw new TypeError("must provide nocase setting to PathScurryBase ctor");this.nocase=i,this.root=this.newRoot(this.#h),this.roots[this.rootPath]=this.root;let l=this.root,c=a.length-1,f=e.sep,u=this.rootPath,m=!1;for(let y of a){let d=c--;l=l.child(y,{relative:new Array(d).fill("..").join(f),relativePosix:new Array(d).fill("..").join("/"),fullpath:u+=(m?"":f)+y}),m=!0}this.cwd=l}depth(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.depth()}childrenCache(){return this.#r}resolve(...t){let e="";for(let r=t.length-1;r>=0;r--){let o=t[r];if(!(!o||o===".")&&(e=e?`${o}/${e}`:o,this.isAbsolute(o)))break}let s=this.#e.get(e);if(s!==void 0)return s;let i=this.cwd.resolve(e).fullpath();return this.#e.set(e,i),i}resolvePosix(...t){let e="";for(let r=t.length-1;r>=0;r--){let o=t[r];if(!(!o||o===".")&&(e=e?`${o}/${e}`:o,this.isAbsolute(o)))break}let s=this.#i.get(e);if(s!==void 0)return s;let i=this.cwd.resolve(e).fullpathPosix();return this.#i.set(e,i),i}relative(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.relative()}relativePosix(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.relativePosix()}basename(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.name}dirname(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),(t.parent||t).fullpath()}async readdir(t=this.cwd,e={withFileTypes:!0}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof I||(e=t,t=this.cwd);let{withFileTypes:s}=e;if(t.canReaddir()){let i=await t.readdir();return s?i:i.map(r=>r.name)}else return[]}readdirSync(t=this.cwd,e={withFileTypes:!0}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof I||(e=t,t=this.cwd);let{withFileTypes:s=!0}=e;return t.canReaddir()?s?t.readdirSync():t.readdirSync().map(i=>i.name):[]}async lstat(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.lstat()}lstatSync(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.lstatSync()}async readlink(t=this.cwd,{withFileTypes:e}={withFileTypes:!1}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof I||(e=t.withFileTypes,t=this.cwd);let s=await t.readlink();return e?s:s?.fullpath()}readlinkSync(t=this.cwd,{withFileTypes:e}={withFileTypes:!1}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof I||(e=t.withFileTypes,t=this.cwd);let s=t.readlinkSync();return e?s:s?.fullpath()}async realpath(t=this.cwd,{withFileTypes:e}={withFileTypes:!1}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof I||(e=t.withFileTypes,t=this.cwd);let s=await t.realpath();return e?s:s?.fullpath()}realpathSync(t=this.cwd,{withFileTypes:e}={withFileTypes:!1}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof I||(e=t.withFileTypes,t=this.cwd);let s=t.realpathSync();return e?s:s?.fullpath()}async walk(t=this.cwd,e={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof I||(e=t,t=this.cwd);let{withFileTypes:s=!0,follow:i=!1,filter:r,walkFilter:o}=e,h=[];(!r||r(t))&&h.push(s?t:t.fullpath());let a=new Set,l=(f,u)=>{a.add(f),f.readdirCB((m,y)=>{if(m)return u(m);let d=y.length;if(!d)return u();let w=()=>{--d===0&&u()};for(let g of y)(!r||r(g))&&h.push(s?g:g.fullpath()),i&&g.isSymbolicLink()?g.realpath().then(b=>b?.isUnknown()?b.lstat():b).then(b=>b?.shouldWalk(a,o)?l(b,w):w()):g.shouldWalk(a,o)?l(g,w):w()},!0)},c=t;return new Promise((f,u)=>{l(c,m=>{if(m)return u(m);f(h)})})}walkSync(t=this.cwd,e={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof I||(e=t,t=this.cwd);let{withFileTypes:s=!0,follow:i=!1,filter:r,walkFilter:o}=e,h=[];(!r||r(t))&&h.push(s?t:t.fullpath());let a=new Set([t]);for(let l of a){let c=l.readdirSync();for(let f of c){(!r||r(f))&&h.push(s?f:f.fullpath());let u=f;if(f.isSymbolicLink()){if(!(i&&(u=f.realpathSync())))continue;u.isUnknown()&&u.lstatSync()}u.shouldWalk(a,o)&&a.add(u)}}return h}[Symbol.asyncIterator](){return this.iterate()}iterate(t=this.cwd,e={}){return typeof t=="string"?t=this.cwd.resolve(t):t instanceof I||(e=t,t=this.cwd),this.stream(t,e)[Symbol.asyncIterator]()}[Symbol.iterator](){return this.iterateSync()}*iterateSync(t=this.cwd,e={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof I||(e=t,t=this.cwd);let{withFileTypes:s=!0,follow:i=!1,filter:r,walkFilter:o}=e;(!r||r(t))&&(yield s?t:t.fullpath());let h=new Set([t]);for(let a of h){let l=a.readdirSync();for(let c of l){(!r||r(c))&&(yield s?c:c.fullpath());let f=c;if(c.isSymbolicLink()){if(!(i&&(f=c.realpathSync())))continue;f.isUnknown()&&f.lstatSync()}f.shouldWalk(h,o)&&h.add(f)}}}stream(t=this.cwd,e={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof I||(e=t,t=this.cwd);let{withFileTypes:s=!0,follow:i=!1,filter:r,walkFilter:o}=e,h=new ct({objectMode:!0});(!r||r(t))&&h.write(s?t:t.fullpath());let a=new Set,l=[t],c=0,f=()=>{let u=!1;for(;!u;){let m=l.shift();if(!m){c===0&&h.end();return}c++,a.add(m);let y=(w,g,b=!1)=>{if(w)return h.emit("error",w);if(i&&!b){let E=[];for(let S of g)S.isSymbolicLink()&&E.push(S.realpath().then(v=>v?.isUnknown()?v.lstat():v));if(E.length){Promise.all(E).then(()=>y(null,g,!0));return}}for(let E of g)E&&(!r||r(E))&&(h.write(s?E:E.fullpath())||(u=!0));c--;for(let E of g){let S=E.realpathCached()||E;S.shouldWalk(a,o)&&l.push(S)}u&&!h.flowing?h.once("drain",f):d||f()},d=!0;m.readdirCB(y,!0),d=!1}};return f(),h}streamSync(t=this.cwd,e={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof I||(e=t,t=this.cwd);let{withFileTypes:s=!0,follow:i=!1,filter:r,walkFilter:o}=e,h=new ct({objectMode:!0}),a=new Set;(!r||r(t))&&h.write(s?t:t.fullpath());let l=[t],c=0,f=()=>{let u=!1;for(;!u;){let m=l.shift();if(!m){c===0&&h.end();return}c++,a.add(m);let y=m.readdirSync();for(let d of y)(!r||r(d))&&(h.write(s?d:d.fullpath())||(u=!0));c--;for(let d of y){let w=d;if(d.isSymbolicLink()){if(!(i&&(w=d.realpathSync())))continue;w.isUnknown()&&w.lstatSync()}w.shouldWalk(a,o)&&l.push(w)}}u&&!h.flowing&&h.once("drain",f)};return f(),h}chdir(t=this.cwd){let e=this.cwd;this.cwd=typeof t=="string"?this.cwd.resolve(t):t,this.cwd[Ws](e)}},Ot=class extends de{sep="\\";constructor(t=process.cwd(),e={}){let{nocase:s=!0}=e;super(t,Ne,"\\",{...e,nocase:s}),this.nocase=s;for(let i=this.cwd;i;i=i.parent)i.nocase=this.nocase}parseRootPath(t){return Ne.parse(t).root.toUpperCase()}newRoot(t){return new Rt(this.rootPath,tt,void 0,this.roots,this.nocase,this.childrenCache(),{fs:t})}isAbsolute(t){return t.startsWith("/")||t.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(t)}},Dt=class extends de{sep="/";constructor(t=process.cwd(),e={}){let{nocase:s=!1}=e;super(t,sr,"/",{...e,nocase:s}),this.nocase=s}parseRootPath(t){return"/"}newRoot(t){return new kt(this.rootPath,tt,void 0,this.roots,this.nocase,this.childrenCache(),{fs:t})}isAbsolute(t){return t.startsWith("/")}},Ht=class extends Dt{constructor(t=process.cwd(),e={}){let{nocase:s=!0}=e;super(t,{...e,nocase:s})}},yn=process.platform==="win32"?Rt:kt,Ps=process.platform==="win32"?Ot:process.platform==="darwin"?Ht:Dt;var yr=n=>n.length>=1,br=n=>n.length>=1,ft=class{#e;#i;#r;length;#h;#f;#k;#l;#p;#a;#n=!0;constructor(t,e,s,i){if(!yr(t))throw new TypeError("empty pattern list");if(!br(e))throw new TypeError("empty glob list");if(e.length!==t.length)throw new TypeError("mismatched pattern list and glob list lengths");if(this.length=t.length,s<0||s>=this.length)throw new TypeError("index out of range");if(this.#e=t,this.#i=e,this.#r=s,this.#h=i,this.#r===0){if(this.isUNC()){let[r,o,h,a,...l]=this.#e,[c,f,u,m,...y]=this.#i;l[0]===""&&(l.shift(),y.shift());let d=[r,o,h,a,""].join("/"),w=[c,f,u,m,""].join("/");this.#e=[d,...l],this.#i=[w,...y],this.length=this.#e.length}else if(this.isDrive()||this.isAbsolute()){let[r,...o]=this.#e,[h,...a]=this.#i;o[0]===""&&(o.shift(),a.shift());let l=r+"/",c=h+"/";this.#e=[l,...o],this.#i=[c,...a],this.length=this.#e.length}}}pattern(){return this.#e[this.#r]}isString(){return typeof this.#e[this.#r]=="string"}isGlobstar(){return this.#e[this.#r]===_}isRegExp(){return this.#e[this.#r]instanceof RegExp}globString(){return this.#k=this.#k||(this.#r===0?this.isAbsolute()?this.#i[0]+this.#i.slice(1).join("/"):this.#i.join("/"):this.#i.slice(this.#r).join("/"))}hasMore(){return this.length>this.#r+1}rest(){return this.#f!==void 0?this.#f:this.hasMore()?(this.#f=new ft(this.#e,this.#i,this.#r+1,this.#h),this.#f.#a=this.#a,this.#f.#p=this.#p,this.#f.#l=this.#l,this.#f):this.#f=null}isUNC(){let t=this.#e;return this.#p!==void 0?this.#p:this.#p=this.#h==="win32"&&this.#r===0&&t[0]===""&&t[1]===""&&typeof t[2]=="string"&&!!t[2]&&typeof t[3]=="string"&&!!t[3]}isDrive(){let t=this.#e;return this.#l!==void 0?this.#l:this.#l=this.#h==="win32"&&this.#r===0&&this.length>1&&typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0])}isAbsolute(){let t=this.#e;return this.#a!==void 0?this.#a:this.#a=t[0]===""&&t.length>1||this.isDrive()||this.isUNC()}root(){let t=this.#e[0];return typeof t=="string"&&this.isAbsolute()&&this.#r===0?t:""}checkFollowGlobstar(){return!(this.#r===0||!this.isGlobstar()||!this.#n)}markFollowGlobstar(){return this.#r===0||!this.isGlobstar()||!this.#n?!1:(this.#n=!1,!0)}};var Sr=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",Ft=class{relative;relativeChildren;absolute;absoluteChildren;platform;mmopts;constructor(t,{nobrace:e,nocase:s,noext:i,noglobstar:r,platform:o=Sr}){this.relative=[],this.absolute=[],this.relativeChildren=[],this.absoluteChildren=[],this.platform=o,this.mmopts={dot:!0,nobrace:e,nocase:s,noext:i,noglobstar:r,optimizationLevel:2,platform:o,nocomment:!0,nonegate:!0};for(let h of t)this.add(h)}add(t){let e=new $(t,this.mmopts);for(let s=0;s<e.set.length;s++){let i=e.set[s],r=e.globParts[s];if(!i||!r)throw new Error("invalid pattern object");for(;i[0]==="."&&r[0]===".";)i.shift(),r.shift();let o=new ft(i,r,0,this.platform),h=new $(o.globString(),this.mmopts),a=r[r.length-1]==="**",l=o.isAbsolute();l?this.absolute.push(h):this.relative.push(h),a&&(l?this.absoluteChildren.push(h):this.relativeChildren.push(h))}}ignored(t){let e=t.fullpath(),s=`${e}/`,i=t.relative()||".",r=`${i}/`;for(let o of this.relative)if(o.match(i)||o.match(r))return!0;for(let o of this.absolute)if(o.match(e)||o.match(s))return!0;return!1}childrenIgnored(t){let e=t.fullpath()+"/",s=(t.relative()||".")+"/";for(let i of this.relativeChildren)if(i.match(s))return!0;for(let i of this.absoluteChildren)if(i.match(e))return!0;return!1}};var qt=class{store;constructor(t=new Map){this.store=t}copy(){return new qt(new Map(this.store))}hasWalked(t,e){return this.store.get(t.fullpath())?.has(e.globString())}storeWalked(t,e){let s=t.fullpath(),i=this.store.get(s);i?i.add(e.globString()):this.store.set(s,new Set([e.globString()]))}},Le=class{store=new Map;add(t,e,s){let i=(e?2:0)|(s?1:0),r=this.store.get(t);this.store.set(t,r===void 0?i:i&r)}entries(){return[...this.store.entries()].map(([t,e])=>[t,!!(e&2),!!(e&1)])}},Ie=class{store=new Map;add(t,e){if(!t.canReaddir())return;let s=this.store.get(t);s?s.find(i=>i.globString()===e.globString())||s.push(e):this.store.set(t,[e])}get(t){let e=this.store.get(t);if(!e)throw new Error("attempting to walk unknown path");return e}entries(){return this.keys().map(t=>[t,this.store.get(t)])}keys(){return[...this.store.keys()].filter(t=>t.canReaddir())}},yt=class{hasWalkedCache;matches=new Le;subwalks=new Ie;patterns;follow;dot;opts;constructor(t,e){this.opts=t,this.follow=!!t.follow,this.dot=!!t.dot,this.hasWalkedCache=e?e.copy():new qt}processPatterns(t,e){this.patterns=e;let s=e.map(i=>[t,i]);for(let[i,r]of s){this.hasWalkedCache.storeWalked(i,r);let o=r.root(),h=r.isAbsolute()&&this.opts.absolute!==!1;if(o){i=i.resolve(o==="/"&&this.opts.root!==void 0?this.opts.root:o);let f=r.rest();if(f)r=f;else{this.matches.add(i,!0,!1);continue}}if(i.isENOENT())continue;let a,l,c=!1;for(;typeof(a=r.pattern())=="string"&&(l=r.rest());)i=i.resolve(a),r=l,c=!0;if(a=r.pattern(),l=r.rest(),c){if(this.hasWalkedCache.hasWalked(i,r))continue;this.hasWalkedCache.storeWalked(i,r)}if(typeof a=="string"){let f=a===".."||a===""||a===".";this.matches.add(i.resolve(a),h,f);continue}else if(a===_){(!i.isSymbolicLink()||this.follow||r.checkFollowGlobstar())&&this.subwalks.add(i,r);let f=l?.pattern(),u=l?.rest();if(!l||(f===""||f===".")&&!u)this.matches.add(i,h,f===""||f===".");else if(f===".."){let m=i.parent||i;u?this.hasWalkedCache.hasWalked(m,u)||this.subwalks.add(m,u):this.matches.add(m,h,!0)}}else a instanceof RegExp&&this.subwalks.add(i,r)}return this}subwalkTargets(){return this.subwalks.keys()}child(){return new yt(this.opts,this.hasWalkedCache)}filterEntries(t,e){let s=this.subwalks.get(t),i=this.child();for(let r of e)for(let o of s){let h=o.isAbsolute(),a=o.pattern(),l=o.rest();a===_?i.testGlobstar(r,o,l,h):a instanceof RegExp?i.testRegExp(r,a,l,h):i.testString(r,a,l,h)}return i}testGlobstar(t,e,s,i){if((this.dot||!t.name.startsWith("."))&&(e.hasMore()||this.matches.add(t,i,!1),t.canReaddir()&&(this.follow||!t.isSymbolicLink()?this.subwalks.add(t,e):t.isSymbolicLink()&&(s&&e.checkFollowGlobstar()?this.subwalks.add(t,s):e.markFollowGlobstar()&&this.subwalks.add(t,e)))),s){let r=s.pattern();if(typeof r=="string"&&r!==".."&&r!==""&&r!==".")this.testString(t,r,s.rest(),i);else if(r===".."){let o=t.parent||t;this.subwalks.add(o,s)}else r instanceof RegExp&&this.testRegExp(t,r,s.rest(),i)}}testRegExp(t,e,s,i){e.test(t.name)&&(s?this.subwalks.add(t,s):this.matches.add(t,i,!1))}testString(t,e,s,i){t.isNamed(e)&&(s?this.subwalks.add(t,s):this.matches.add(t,i,!1))}};var Er=(n,t)=>typeof n=="string"?new Ft([n],t):Array.isArray(n)?new Ft(n,t):n,pe=class{path;patterns;opts;seen=new Set;paused=!1;aborted=!1;#e=[];#i;#r;signal;maxDepth;includeChildMatches;constructor(t,e,s){if(this.patterns=t,this.path=e,this.opts=s,this.#r=!s.posix&&s.platform==="win32"?"\\":"/",this.includeChildMatches=s.includeChildMatches!==!1,(s.ignore||!this.includeChildMatches)&&(this.#i=Er(s.ignore??[],s),!this.includeChildMatches&&typeof this.#i.add!="function")){let i="cannot ignore child matches, ignore lacks add() method.";throw new Error(i)}this.maxDepth=s.maxDepth||1/0,s.signal&&(this.signal=s.signal,this.signal.addEventListener("abort",()=>{this.#e.length=0}))}#h(t){return this.seen.has(t)||!!this.#i?.ignored?.(t)}#f(t){return!!this.#i?.childrenIgnored?.(t)}pause(){this.paused=!0}resume(){if(this.signal?.aborted)return;this.paused=!1;let t;for(;!this.paused&&(t=this.#e.shift());)t()}onResume(t){this.signal?.aborted||(this.paused?this.#e.push(t):t())}async matchCheck(t,e){if(e&&this.opts.nodir)return;let s;if(this.opts.realpath){if(s=t.realpathCached()||await t.realpath(),!s)return;t=s}let r=t.isUnknown()||this.opts.stat?await t.lstat():t;if(this.opts.follow&&this.opts.nodir&&r?.isSymbolicLink()){let o=await r.realpath();o&&(o.isUnknown()||this.opts.stat)&&await o.lstat()}return this.matchCheckTest(r,e)}matchCheckTest(t,e){return t&&(this.maxDepth===1/0||t.depth()<=this.maxDepth)&&(!e||t.canReaddir())&&(!this.opts.nodir||!t.isDirectory())&&(!this.opts.nodir||!this.opts.follow||!t.isSymbolicLink()||!t.realpathCached()?.isDirectory())&&!this.#h(t)?t:void 0}matchCheckSync(t,e){if(e&&this.opts.nodir)return;let s;if(this.opts.realpath){if(s=t.realpathCached()||t.realpathSync(),!s)return;t=s}let r=t.isUnknown()||this.opts.stat?t.lstatSync():t;if(this.opts.follow&&this.opts.nodir&&r?.isSymbolicLink()){let o=r.realpathSync();o&&(o?.isUnknown()||this.opts.stat)&&o.lstatSync()}return this.matchCheckTest(r,e)}matchFinish(t,e){if(this.#h(t))return;if(!this.includeChildMatches&&this.#i?.add){let r=`${t.relativePosix()}/**`;this.#i.add(r)}let s=this.opts.absolute===void 0?e:this.opts.absolute;this.seen.add(t);let i=this.opts.mark&&t.isDirectory()?this.#r:"";if(this.opts.withFileTypes)this.matchEmit(t);else if(s){let r=this.opts.posix?t.fullpathPosix():t.fullpath();this.matchEmit(r+i)}else{let r=this.opts.posix?t.relativePosix():t.relative(),o=this.opts.dotRelative&&!r.startsWith(".."+this.#r)?"."+this.#r:"";this.matchEmit(r?o+r+i:"."+i)}}async match(t,e,s){let i=await this.matchCheck(t,s);i&&this.matchFinish(i,e)}matchSync(t,e,s){let i=this.matchCheckSync(t,s);i&&this.matchFinish(i,e)}walkCB(t,e,s){this.signal?.aborted&&s(),this.walkCB2(t,e,new yt(this.opts),s)}walkCB2(t,e,s,i){if(this.#f(t))return i();if(this.signal?.aborted&&i(),this.paused){this.onResume(()=>this.walkCB2(t,e,s,i));return}s.processPatterns(t,e);let r=1,o=()=>{--r===0&&i()};for(let[h,a,l]of s.matches.entries())this.#h(h)||(r++,this.match(h,a,l).then(()=>o()));for(let h of s.subwalkTargets()){if(this.maxDepth!==1/0&&h.depth()>=this.maxDepth)continue;r++;let a=h.readdirCached();h.calledReaddir()?this.walkCB3(h,a,s,o):h.readdirCB((l,c)=>this.walkCB3(h,c,s,o),!0)}o()}walkCB3(t,e,s,i){s=s.filterEntries(t,e);let r=1,o=()=>{--r===0&&i()};for(let[h,a,l]of s.matches.entries())this.#h(h)||(r++,this.match(h,a,l).then(()=>o()));for(let[h,a]of s.subwalks.entries())r++,this.walkCB2(h,a,s.child(),o);o()}walkCBSync(t,e,s){this.signal?.aborted&&s(),this.walkCB2Sync(t,e,new yt(this.opts),s)}walkCB2Sync(t,e,s,i){if(this.#f(t))return i();if(this.signal?.aborted&&i(),this.paused){this.onResume(()=>this.walkCB2Sync(t,e,s,i));return}s.processPatterns(t,e);let r=1,o=()=>{--r===0&&i()};for(let[h,a,l]of s.matches.entries())this.#h(h)||this.matchSync(h,a,l);for(let h of s.subwalkTargets()){if(this.maxDepth!==1/0&&h.depth()>=this.maxDepth)continue;r++;let a=h.readdirSync();this.walkCB3Sync(h,a,s,o)}o()}walkCB3Sync(t,e,s,i){s=s.filterEntries(t,e);let r=1,o=()=>{--r===0&&i()};for(let[h,a,l]of s.matches.entries())this.#h(h)||this.matchSync(h,a,l);for(let[h,a]of s.subwalks.entries())r++,this.walkCB2Sync(h,a,s.child(),o);o()}},Kt=class extends pe{matches=new Set;constructor(t,e,s){super(t,e,s)}matchEmit(t){this.matches.add(t)}async walk(){if(this.signal?.aborted)throw this.signal.reason;return this.path.isUnknown()&&await this.path.lstat(),await new Promise((t,e)=>{this.walkCB(this.path,this.patterns,()=>{this.signal?.aborted?e(this.signal.reason):t(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}},Vt=class extends pe{results;constructor(t,e,s){super(t,e,s),this.results=new ct({signal:this.signal,objectMode:!0}),this.results.on("drain",()=>this.resume()),this.results.on("resume",()=>this.resume())}matchEmit(t){this.results.write(t),this.results.flowing||this.pause()}stream(){let t=this.path;return t.isUnknown()?t.lstat().then(()=>{this.walkCB(t,this.patterns,()=>this.results.end())}):this.walkCB(t,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 xr=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",Z=class{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(t,e){if(!e)throw new TypeError("glob options required");if(this.withFileTypes=!!e.withFileTypes,this.signal=e.signal,this.follow=!!e.follow,this.dot=!!e.dot,this.dotRelative=!!e.dotRelative,this.nodir=!!e.nodir,this.mark=!!e.mark,e.cwd?(e.cwd instanceof URL||e.cwd.startsWith("file://"))&&(e.cwd=vr(e.cwd)):this.cwd="",this.cwd=e.cwd||"",this.root=e.root,this.magicalBraces=!!e.magicalBraces,this.nobrace=!!e.nobrace,this.noext=!!e.noext,this.realpath=!!e.realpath,this.absolute=e.absolute,this.includeChildMatches=e.includeChildMatches!==!1,this.noglobstar=!!e.noglobstar,this.matchBase=!!e.matchBase,this.maxDepth=typeof e.maxDepth=="number"?e.maxDepth:1/0,this.stat=!!e.stat,this.ignore=e.ignore,this.withFileTypes&&this.absolute!==void 0)throw new Error("cannot set absolute and withFileTypes:true");if(typeof t=="string"&&(t=[t]),this.windowsPathsNoEscape=!!e.windowsPathsNoEscape||e.allowWindowsEscape===!1,this.windowsPathsNoEscape&&(t=t.map(a=>a.replace(/\\/g,"/"))),this.matchBase){if(e.noglobstar)throw new TypeError("base matching requires globstar");t=t.map(a=>a.includes("/")?a:`./**/${a}`)}if(this.pattern=t,this.platform=e.platform||xr,this.opts={...e,platform:this.platform},e.scurry){if(this.scurry=e.scurry,e.nocase!==void 0&&e.nocase!==e.scurry.nocase)throw new Error("nocase option contradicts provided scurry option")}else{let a=e.platform==="win32"?Ot:e.platform==="darwin"?Ht:e.platform?Dt:Ps;this.scurry=new a(this.cwd,{nocase:e.nocase,fs:e.fs})}this.nocase=this.scurry.nocase;let s=this.platform==="darwin"||this.platform==="win32",i={...e,dot:this.dot,matchBase:this.matchBase,nobrace:this.nobrace,nocase:this.nocase,nocaseMagicOnly:s,nocomment:!0,noext:this.noext,nonegate:!0,optimizationLevel:2,platform:this.platform,windowsPathsNoEscape:this.windowsPathsNoEscape,debug:!!this.opts.debug},r=this.pattern.map(a=>new $(a,i)),[o,h]=r.reduce((a,l)=>(a[0].push(...l.set),a[1].push(...l.globParts),a),[[],[]]);this.patterns=o.map((a,l)=>{let c=h[l];if(!c)throw new Error("invalid pattern object");return new ft(a,c,0,this.platform)})}async walk(){return[...await new Kt(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 Kt(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 Vt(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 Vt(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 We=(n,t={})=>{Array.isArray(n)||(n=[n]);for(let e of n)if(new $(e,t).hasMagic())return!0;return!1};function ge(n,t={}){return new Z(n,t).streamSync()}function zs(n,t={}){return new Z(n,t).stream()}function $s(n,t={}){return new Z(n,t).walkSync()}async function js(n,t={}){return new Z(n,t).walk()}function we(n,t={}){return new Z(n,t).iterateSync()}function Bs(n,t={}){return new Z(n,t).iterate()}var Cr=ge,Tr=Object.assign(zs,{sync:ge}),Ar=we,Rr=Object.assign(Bs,{sync:we}),kr=Object.assign($s,{stream:ge,iterate:we}),me=Object.assign(js,{glob:js,globSync:$s,sync:kr,globStream:zs,stream:Tr,globStreamSync:ge,streamSync:Cr,globIterate:Bs,iterate:Rr,globIterateSync:we,iterateSync:Ar,Glob:Z,hasMagic:We,escape:St,unescape:V});me.glob=me;async function Gs({cwd:n,pattern:t="**"}){return(await me(Us.join(t,"*.sol"),{cwd:n})).sort().map(s=>({filename:s,basename:Us.basename(s,".sol")}))}async function Hs({rootDir:n,config:t}){return(await Gs({cwd:n,pattern:Yt.join(t.sourceDirectory,"**")})).filter(i=>i.basename.endsWith("System")&&i.basename!=="System"&&!/^I[A-Z]/.test(i.basename)).map(i=>{let r=(()=>t.namespace)();return{sourcePath:i.filename,namespaceLabel:r,systemLabel:i.basename}})}import{resolveNamespace as Dr}from"@latticexyz/store/config/v2";async function qs({rootDir:n,config:t}){let e=await Hs({rootDir:n,config:t}),s=e.map(h=>h.systemLabel),i=Object.keys(t.systems).filter(h=>!s.includes(h));if(i.length>0)throw new Error(`Found systems in config with no corresponding system contract: ${i.join(", ")}`);let r=e.map(h=>({...t.systems[h.systemLabel]??ze({label:h.systemLabel,namespace:Dr({label:h.namespaceLabel}).namespace}),sourcePath:h.sourcePath})).filter(h=>!t.excludeSystems.includes(h.label)),o=r.map(h=>h.label);for(let h of r)for(let a of h.accessList)if(!Or(a)&&!o.includes(a))throw new Error(`Access list item (${a}) for system (${h.label}) had no matching system contract.`);return r}async function co({rootDir:n,config:t,clean:e=!0}){let s=j.join(n,t.sourceDirectory,t.codegen.outputDirectory,t.codegen.worldgenDirectory);e&&await Ks.rm(s,{recursive:!0,force:!0});let i=j.join(s,t.codegen.worldInterfaceName+".sol"),r=(await qs({rootDir:n,config:t})).map(a=>{let l=`I${a.label}`;return{...a,interfaceName:l,interfacePath:j.join(j.dirname(i),`${l}.sol`)}}),o=r.map(a=>({symbol:a.interfaceName,path:"./"+j.relative(j.dirname(i),a.interfacePath)}));await Promise.all(r.map(async a=>{let l=await Ks.readFile(a.sourcePath,"utf8"),{functions:c,errors:f,symbolImports:u}=Fr(l,a.label),m=u.map(({symbol:d,path:w})=>({symbol:d,path:w.startsWith(".")?"./"+j.relative(s,j.join(n,j.dirname(a.sourcePath),w)):w})),y=Be({name:a.interfaceName,functionPrefix:a.namespace===""?"":`${a.namespace}__`,functions:c,errors:f,imports:m});await Vs(y,a.interfacePath,"Generated system interface")}));let h=Ue({interfaceName:t.codegen.worldInterfaceName,imports:o,storeImportPath:t.codegen.storeImportPath.startsWith(".")?"./"+j.relative(j.dirname(i),j.join(n,t.codegen.storeImportPath)):t.codegen.storeImportPath,worldImportPath:t.codegen.worldImportPath.startsWith(".")?"./"+j.relative(j.dirname(i),j.join(n,t.codegen.worldImportPath)):t.codegen.worldImportPath});await Vs(h,i,"Generated world interface")}export{Gs as findSolidityFiles,Hs as getSystemContracts,Be as renderSystemInterface,Ue as renderWorldInterface,qs as resolveSystems,co as worldgen};
36
+ >>> no match, partial?`,t,u,e,m),u===a))}let d;if(typeof c=="string"?(d=f===c,this.debug("string match",c,f,d)):(d=c.test(f),this.debug("pattern match",c,f,d)),!d)return!1}if(o===a&&h===l)return!0;if(o===a)return s;if(h===l)return o===a-1&&t[o]==="";throw new Error("wtf?")}braceExpand(){return gs(this.pattern,this.options)}parse(t){Nt(t);let e=this.options;if(t==="**")return _;if(t==="")return"";let s,i=null;(s=t.match(Ri))?i=e.dot?Oi:ki:(s=t.match(wi))?i=(e.nocase?e.dot?Ei:Si:e.dot?bi:yi)(s[1]):(s=t.match(Di))?i=(e.nocase?e.dot?Mi:Fi:e.dot?Ni:_i)(s):(s=t.match(vi))?i=e.dot?Ci:xi:(s=t.match(Ti))&&(i=Ai);let r=ht.fromGlob(t,this.options).toMMPattern();return i&&typeof r=="object"&&Reflect.defineProperty(r,"test",{value:i}),r}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let t=this.set;if(!t.length)return this.regexp=!1,this.regexp;let e=this.options,s=e.noglobstar?Wi:e.dot?Pi:ji,i=new Set(e.nocase?["i"]:[]),r=t.map(a=>{let l=a.map(c=>{if(c instanceof RegExp)for(let f of c.flags.split(""))i.add(f);return typeof c=="string"?Gi(c):c===_?_:c._src});return l.forEach((c,f)=>{let u=l[f+1],m=l[f-1];c!==_||m===_||(m===void 0?u!==void 0&&u!==_?l[f+1]="(?:\\/|"+s+"\\/)?"+u:l[f]=s:u===void 0?l[f-1]=m+"(?:\\/|"+s+")?":u!==_&&(l[f-1]=m+"(?:\\/|\\/"+s+"\\/)"+u,l[f+1]=_))}),l.filter(c=>c!==_).join("/")}).join("|"),[o,h]=t.length>1?["(?:",")"]:["",""];r="^"+o+r+h+"$",this.negate&&(r="^(?!"+r+").+$");try{this.regexp=new RegExp(r,[...i].join(""))}catch{this.regexp=!1}return this.regexp}slashSplit(t){return this.preserveMultipleSlashes?t.split("/"):this.isWindows&&/^\/\/[^\/]+/.test(t)?["",...t.split(/\/+/)]:t.split(/\/+/)}match(t,e=this.partial){if(this.debug("match",t,this.pattern),this.comment)return!1;if(this.empty)return t==="";if(t==="/"&&e)return!0;let s=this.options;this.isWindows&&(t=t.split("\\").join("/"));let i=this.slashSplit(t);this.debug(this.pattern,"split",i);let r=this.set;this.debug(this.pattern,"set",r);let o=i[i.length-1];if(!o)for(let h=i.length-2;!o&&h>=0;h--)o=i[h];for(let h=0;h<r.length;h++){let a=r[h],l=i;if(s.matchBase&&a.length===1&&(l=[o]),this.matchOne(l,a,e))return s.flipNegate?!0:!this.negate}return s.flipNegate?!1:this.negate}static defaults(t){return W.defaults(t).Minimatch}};W.AST=ht;W.Minimatch=$;W.escape=St;W.unescape=V;import{fileURLToPath as vr}from"node:url";var Et=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,ys=new Set,xe=typeof process=="object"&&process?process:{},bs=(n,t,e,s)=>{typeof xe.emitWarning=="function"?xe.emitWarning(n,t,e,s):console.error(`[${e}] ${t}: ${n}`)},se=globalThis.AbortController,ws=globalThis.AbortSignal;if(typeof se>"u"){ws=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(s,i){this._onabort.push(i)}},se=class{constructor(){t()}signal=new ws;abort(s){if(!this.signal.aborted){this.signal.reason=s,this.signal.aborted=!0;for(let i of this.signal._onabort)i(s);this.signal.onabort?.(s)}}};let n=xe.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",t=()=>{n&&(n=!1,bs("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",t))}}var Hi=n=>!ys.has(n),nn=Symbol("type"),at=n=>n&&n===Math.floor(n)&&n>0&&isFinite(n),Ss=n=>at(n)?n<=Math.pow(2,8)?Uint8Array:n<=Math.pow(2,16)?Uint16Array:n<=Math.pow(2,32)?Uint32Array:n<=Number.MAX_SAFE_INTEGER?xt:null:null,xt=class extends Array{constructor(t){super(t),this.fill(0)}},Ct,vt=class{heap;length;static create(t){let e=Ss(t);if(!e)return[];x(vt,Ct,!0);let s=new vt(t,e);return x(vt,Ct,!1),s}constructor(t,e){if(!p(vt,Ct))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new e(t),this.length=0}push(t){this.heap[this.length++]=t}pop(){return this.heap[--this.length]}},ee=vt;Ct=new WeakMap,O(ee,Ct,!1);var mt=class{#e;#i;#r;#h;#f;#k;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#l;#p;#a;#n;#s;#y;#b;#g;#u;#v;#d;#x;#C;#w;#S;#E;#c;static unsafeExposeInternals(t){return{starts:t.#C,ttls:t.#w,sizes:t.#x,keyMap:t.#a,keyList:t.#n,valList:t.#s,next:t.#y,prev:t.#b,get head(){return t.#g},get tail(){return t.#u},free:t.#v,isBackgroundFetch:e=>t.#o(e),backgroundFetch:(e,s,i,r)=>t.#P(e,s,i,r),moveToTail:e=>t.#z(e),indexes:e=>t.#A(e),rindexes:e=>t.#R(e),isStale:e=>t.#m(e)}}get max(){return this.#e}get maxSize(){return this.#i}get calculatedSize(){return this.#p}get size(){return this.#l}get fetchMethod(){return this.#f}get memoMethod(){return this.#k}get dispose(){return this.#r}get disposeAfter(){return this.#h}constructor(t){let{max:e=0,ttl:s,ttlResolution:i=1,ttlAutopurge:r,updateAgeOnGet:o,updateAgeOnHas:h,allowStale:a,dispose:l,disposeAfter:c,noDisposeOnSet:f,noUpdateTTL:u,maxSize:m=0,maxEntrySize:y=0,sizeCalculation:d,fetchMethod:w,memoMethod:g,noDeleteOnFetchRejection:b,noDeleteOnStaleGet:E,allowStaleOnFetchRejection:S,allowStaleOnFetchAbort:v,ignoreFetchAbort:k}=t;if(e!==0&&!at(e))throw new TypeError("max option must be a nonnegative integer");let q=e?Ss(e):Array;if(!q)throw new Error("invalid max value: "+e);if(this.#e=e,this.#i=m,this.maxEntrySize=y||this.#i,this.sizeCalculation=d,this.sizeCalculation){if(!this.#i&&!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(g!==void 0&&typeof g!="function")throw new TypeError("memoMethod must be a function if defined");if(this.#k=g,w!==void 0&&typeof w!="function")throw new TypeError("fetchMethod must be a function if specified");if(this.#f=w,this.#E=!!w,this.#a=new Map,this.#n=new Array(e).fill(void 0),this.#s=new Array(e).fill(void 0),this.#y=new q(e),this.#b=new q(e),this.#g=0,this.#u=0,this.#v=ee.create(e),this.#l=0,this.#p=0,typeof l=="function"&&(this.#r=l),typeof c=="function"?(this.#h=c,this.#d=[]):(this.#h=void 0,this.#d=void 0),this.#S=!!this.#r,this.#c=!!this.#h,this.noDisposeOnSet=!!f,this.noUpdateTTL=!!u,this.noDeleteOnFetchRejection=!!b,this.allowStaleOnFetchRejection=!!S,this.allowStaleOnFetchAbort=!!v,this.ignoreFetchAbort=!!k,this.maxEntrySize!==0){if(this.#i!==0&&!at(this.#i))throw new TypeError("maxSize must be a positive integer if specified");if(!at(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#D()}if(this.allowStale=!!a,this.noDeleteOnStaleGet=!!E,this.updateAgeOnGet=!!o,this.updateAgeOnHas=!!h,this.ttlResolution=at(i)||i===0?i:1,this.ttlAutopurge=!!r,this.ttl=s||0,this.ttl){if(!at(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#O()}if(this.#e===0&&this.ttl===0&&this.#i===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#e&&!this.#i){let ut="LRU_CACHE_UNBOUNDED";Hi(ut)&&(ys.add(ut),bs("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",ut,mt))}}getRemainingTTL(t){return this.#a.has(t)?1/0:0}#O(){let t=new xt(this.#e),e=new xt(this.#e);this.#w=t,this.#C=e,this.#M=(r,o,h=Et.now())=>{if(e[r]=o!==0?h:0,t[r]=o,o!==0&&this.ttlAutopurge){let a=setTimeout(()=>{this.#m(r)&&this.#F(this.#n[r],"expire")},o+1);a.unref&&a.unref()}},this.#T=r=>{e[r]=t[r]!==0?Et.now():0},this.#t=(r,o)=>{if(t[o]){let h=t[o],a=e[o];if(!h||!a)return;r.ttl=h,r.start=a,r.now=s||i();let l=r.now-a;r.remainingTTL=h-l}};let s=0,i=()=>{let r=Et.now();if(this.ttlResolution>0){s=r;let o=setTimeout(()=>s=0,this.ttlResolution);o.unref&&o.unref()}return r};this.getRemainingTTL=r=>{let o=this.#a.get(r);if(o===void 0)return 0;let h=t[o],a=e[o];if(!h||!a)return 1/0;let l=(s||i())-a;return h-l},this.#m=r=>{let o=e[r],h=t[r];return!!h&&!!o&&(s||i())-o>h}}#T=()=>{};#t=()=>{};#M=()=>{};#m=()=>!1;#D(){let t=new xt(this.#e);this.#p=0,this.#x=t,this.#N=e=>{this.#p-=t[e],t[e]=0},this.#L=(e,s,i,r)=>{if(this.#o(s))return 0;if(!at(i))if(r){if(typeof r!="function")throw new TypeError("sizeCalculation must be a function");if(i=r(s,e),!at(i))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 i},this.#_=(e,s,i)=>{if(t[e]=s,this.#i){let r=this.#i-t[e];for(;this.#p>r;)this.#W(!0)}this.#p+=t[e],i&&(i.entrySize=s,i.totalCalculatedSize=this.#p)}}#N=t=>{};#_=(t,e,s)=>{};#L=(t,e,s,i)=>{if(s||i)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#A({allowStale:t=this.allowStale}={}){if(this.#l)for(let e=this.#u;!(!this.#I(e)||((t||!this.#m(e))&&(yield e),e===this.#g));)e=this.#b[e]}*#R({allowStale:t=this.allowStale}={}){if(this.#l)for(let e=this.#g;!(!this.#I(e)||((t||!this.#m(e))&&(yield e),e===this.#u));)e=this.#y[e]}#I(t){return t!==void 0&&this.#a.get(this.#n[t])===t}*entries(){for(let t of this.#A())this.#s[t]!==void 0&&this.#n[t]!==void 0&&!this.#o(this.#s[t])&&(yield[this.#n[t],this.#s[t]])}*rentries(){for(let t of this.#R())this.#s[t]!==void 0&&this.#n[t]!==void 0&&!this.#o(this.#s[t])&&(yield[this.#n[t],this.#s[t]])}*keys(){for(let t of this.#A()){let e=this.#n[t];e!==void 0&&!this.#o(this.#s[t])&&(yield e)}}*rkeys(){for(let t of this.#R()){let e=this.#n[t];e!==void 0&&!this.#o(this.#s[t])&&(yield e)}}*values(){for(let t of this.#A())this.#s[t]!==void 0&&!this.#o(this.#s[t])&&(yield this.#s[t])}*rvalues(){for(let t of this.#R())this.#s[t]!==void 0&&!this.#o(this.#s[t])&&(yield this.#s[t])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(t,e={}){for(let s of this.#A()){let i=this.#s[s],r=this.#o(i)?i.__staleWhileFetching:i;if(r!==void 0&&t(r,this.#n[s],this))return this.get(this.#n[s],e)}}forEach(t,e=this){for(let s of this.#A()){let i=this.#s[s],r=this.#o(i)?i.__staleWhileFetching:i;r!==void 0&&t.call(e,r,this.#n[s],this)}}rforEach(t,e=this){for(let s of this.#R()){let i=this.#s[s],r=this.#o(i)?i.__staleWhileFetching:i;r!==void 0&&t.call(e,r,this.#n[s],this)}}purgeStale(){let t=!1;for(let e of this.#R({allowStale:!0}))this.#m(e)&&(this.#F(this.#n[e],"expire"),t=!0);return t}info(t){let e=this.#a.get(t);if(e===void 0)return;let s=this.#s[e],i=this.#o(s)?s.__staleWhileFetching:s;if(i===void 0)return;let r={value:i};if(this.#w&&this.#C){let o=this.#w[e],h=this.#C[e];if(o&&h){let a=o-(Et.now()-h);r.ttl=a,r.start=Date.now()}}return this.#x&&(r.size=this.#x[e]),r}dump(){let t=[];for(let e of this.#A({allowStale:!0})){let s=this.#n[e],i=this.#s[e],r=this.#o(i)?i.__staleWhileFetching:i;if(r===void 0||s===void 0)continue;let o={value:r};if(this.#w&&this.#C){o.ttl=this.#w[e];let h=Et.now()-this.#C[e];o.start=Math.floor(Date.now()-h)}this.#x&&(o.size=this.#x[e]),t.unshift([s,o])}return t}load(t){this.clear();for(let[e,s]of t){if(s.start){let i=Date.now()-s.start;s.start=Et.now()-i}this.set(e,s.value,s)}}set(t,e,s={}){if(e===void 0)return this.delete(t),this;let{ttl:i=this.ttl,start:r,noDisposeOnSet:o=this.noDisposeOnSet,sizeCalculation:h=this.sizeCalculation,status:a}=s,{noUpdateTTL:l=this.noUpdateTTL}=s,c=this.#L(t,e,s.size||0,h);if(this.maxEntrySize&&c>this.maxEntrySize)return a&&(a.set="miss",a.maxEntrySizeExceeded=!0),this.#F(t,"set"),this;let f=this.#l===0?void 0:this.#a.get(t);if(f===void 0)f=this.#l===0?this.#u:this.#v.length!==0?this.#v.pop():this.#l===this.#e?this.#W(!1):this.#l,this.#n[f]=t,this.#s[f]=e,this.#a.set(t,f),this.#y[this.#u]=f,this.#b[f]=this.#u,this.#u=f,this.#l++,this.#_(f,c,a),a&&(a.set="add"),l=!1;else{this.#z(f);let u=this.#s[f];if(e!==u){if(this.#E&&this.#o(u)){u.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:m}=u;m!==void 0&&!o&&(this.#S&&this.#r?.(m,t,"set"),this.#c&&this.#d?.push([m,t,"set"]))}else o||(this.#S&&this.#r?.(u,t,"set"),this.#c&&this.#d?.push([u,t,"set"]));if(this.#N(f),this.#_(f,c,a),this.#s[f]=e,a){a.set="replace";let m=u&&this.#o(u)?u.__staleWhileFetching:u;m!==void 0&&(a.oldValue=m)}}else a&&(a.set="update")}if(i!==0&&!this.#w&&this.#O(),this.#w&&(l||this.#M(f,i,r),a&&this.#t(a,f)),!o&&this.#c&&this.#d){let u=this.#d,m;for(;m=u?.shift();)this.#h?.(...m)}return this}pop(){try{for(;this.#l;){let t=this.#s[this.#g];if(this.#W(!0),this.#o(t)){if(t.__staleWhileFetching)return t.__staleWhileFetching}else if(t!==void 0)return t}}finally{if(this.#c&&this.#d){let t=this.#d,e;for(;e=t?.shift();)this.#h?.(...e)}}}#W(t){let e=this.#g,s=this.#n[e],i=this.#s[e];return this.#E&&this.#o(i)?i.__abortController.abort(new Error("evicted")):(this.#S||this.#c)&&(this.#S&&this.#r?.(i,s,"evict"),this.#c&&this.#d?.push([i,s,"evict"])),this.#N(e),t&&(this.#n[e]=void 0,this.#s[e]=void 0,this.#v.push(e)),this.#l===1?(this.#g=this.#u=0,this.#v.length=0):this.#g=this.#y[e],this.#a.delete(s),this.#l--,e}has(t,e={}){let{updateAgeOnHas:s=this.updateAgeOnHas,status:i}=e,r=this.#a.get(t);if(r!==void 0){let o=this.#s[r];if(this.#o(o)&&o.__staleWhileFetching===void 0)return!1;if(this.#m(r))i&&(i.has="stale",this.#t(i,r));else return s&&this.#T(r),i&&(i.has="hit",this.#t(i,r)),!0}else i&&(i.has="miss");return!1}peek(t,e={}){let{allowStale:s=this.allowStale}=e,i=this.#a.get(t);if(i===void 0||!s&&this.#m(i))return;let r=this.#s[i];return this.#o(r)?r.__staleWhileFetching:r}#P(t,e,s,i){let r=e===void 0?void 0:this.#s[e];if(this.#o(r))return r;let o=new se,{signal:h}=s;h?.addEventListener("abort",()=>o.abort(h.reason),{signal:o.signal});let a={signal:o.signal,options:s,context:i},l=(d,w=!1)=>{let{aborted:g}=o.signal,b=s.ignoreFetchAbort&&d!==void 0;if(s.status&&(g&&!w?(s.status.fetchAborted=!0,s.status.fetchError=o.signal.reason,b&&(s.status.fetchAbortIgnored=!0)):s.status.fetchResolved=!0),g&&!b&&!w)return f(o.signal.reason);let E=m;return this.#s[e]===m&&(d===void 0?E.__staleWhileFetching?this.#s[e]=E.__staleWhileFetching:this.#F(t,"fetch"):(s.status&&(s.status.fetchUpdated=!0),this.set(t,d,a.options))),d},c=d=>(s.status&&(s.status.fetchRejected=!0,s.status.fetchError=d),f(d)),f=d=>{let{aborted:w}=o.signal,g=w&&s.allowStaleOnFetchAbort,b=g||s.allowStaleOnFetchRejection,E=b||s.noDeleteOnFetchRejection,S=m;if(this.#s[e]===m&&(!E||S.__staleWhileFetching===void 0?this.#F(t,"fetch"):g||(this.#s[e]=S.__staleWhileFetching)),b)return s.status&&S.__staleWhileFetching!==void 0&&(s.status.returnedStale=!0),S.__staleWhileFetching;if(S.__returned===S)throw d},u=(d,w)=>{let g=this.#f?.(t,r,a);g&&g instanceof Promise&&g.then(b=>d(b===void 0?void 0:b),w),o.signal.addEventListener("abort",()=>{(!s.ignoreFetchAbort||s.allowStaleOnFetchAbort)&&(d(void 0),s.allowStaleOnFetchAbort&&(d=b=>l(b,!0)))})};s.status&&(s.status.fetchDispatched=!0);let m=new Promise(u).then(l,c),y=Object.assign(m,{__abortController:o,__staleWhileFetching:r,__returned:void 0});return e===void 0?(this.set(t,y,{...a.options,status:void 0}),e=this.#a.get(t)):this.#s[e]=y,y}#o(t){if(!this.#E)return!1;let e=t;return!!e&&e instanceof Promise&&e.hasOwnProperty("__staleWhileFetching")&&e.__abortController instanceof se}async fetch(t,e={}){let{allowStale:s=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:r=this.noDeleteOnStaleGet,ttl:o=this.ttl,noDisposeOnSet:h=this.noDisposeOnSet,size:a=0,sizeCalculation:l=this.sizeCalculation,noUpdateTTL:c=this.noUpdateTTL,noDeleteOnFetchRejection:f=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:u=this.allowStaleOnFetchRejection,ignoreFetchAbort:m=this.ignoreFetchAbort,allowStaleOnFetchAbort:y=this.allowStaleOnFetchAbort,context:d,forceRefresh:w=!1,status:g,signal:b}=e;if(!this.#E)return g&&(g.fetch="get"),this.get(t,{allowStale:s,updateAgeOnGet:i,noDeleteOnStaleGet:r,status:g});let E={allowStale:s,updateAgeOnGet:i,noDeleteOnStaleGet:r,ttl:o,noDisposeOnSet:h,size:a,sizeCalculation:l,noUpdateTTL:c,noDeleteOnFetchRejection:f,allowStaleOnFetchRejection:u,allowStaleOnFetchAbort:y,ignoreFetchAbort:m,status:g,signal:b},S=this.#a.get(t);if(S===void 0){g&&(g.fetch="miss");let v=this.#P(t,S,E,d);return v.__returned=v}else{let v=this.#s[S];if(this.#o(v)){let Jt=s&&v.__staleWhileFetching!==void 0;return g&&(g.fetch="inflight",Jt&&(g.returnedStale=!0)),Jt?v.__staleWhileFetching:v.__returned=v}let k=this.#m(S);if(!w&&!k)return g&&(g.fetch="hit"),this.#z(S),i&&this.#T(S),g&&this.#t(g,S),v;let q=this.#P(t,S,E,d),K=q.__staleWhileFetching!==void 0&&s;return g&&(g.fetch=k?"stale":"refresh",K&&k&&(g.returnedStale=!0)),K?q.__staleWhileFetching:q.__returned=q}}async forceFetch(t,e={}){let s=await this.fetch(t,e);if(s===void 0)throw new Error("fetch() returned undefined");return s}memo(t,e={}){let s=this.#k;if(!s)throw new Error("no memoMethod provided to constructor");let{context:i,forceRefresh:r,...o}=e,h=this.get(t,o);if(!r&&h!==void 0)return h;let a=s(t,h,{options:o,context:i});return this.set(t,a,o),a}get(t,e={}){let{allowStale:s=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:r=this.noDeleteOnStaleGet,status:o}=e,h=this.#a.get(t);if(h!==void 0){let a=this.#s[h],l=this.#o(a);return o&&this.#t(o,h),this.#m(h)?(o&&(o.get="stale"),l?(o&&s&&a.__staleWhileFetching!==void 0&&(o.returnedStale=!0),s?a.__staleWhileFetching:void 0):(r||this.#F(t,"expire"),o&&s&&(o.returnedStale=!0),s?a:void 0)):(o&&(o.get="hit"),l?a.__staleWhileFetching:(this.#z(h),i&&this.#T(h),a))}else o&&(o.get="miss")}#j(t,e){this.#b[e]=t,this.#y[t]=e}#z(t){t!==this.#u&&(t===this.#g?this.#g=this.#y[t]:this.#j(this.#b[t],this.#y[t]),this.#j(this.#u,t),this.#u=t)}delete(t){return this.#F(t,"delete")}#F(t,e){let s=!1;if(this.#l!==0){let i=this.#a.get(t);if(i!==void 0)if(s=!0,this.#l===1)this.#$(e);else{this.#N(i);let r=this.#s[i];if(this.#o(r)?r.__abortController.abort(new Error("deleted")):(this.#S||this.#c)&&(this.#S&&this.#r?.(r,t,e),this.#c&&this.#d?.push([r,t,e])),this.#a.delete(t),this.#n[i]=void 0,this.#s[i]=void 0,i===this.#u)this.#u=this.#b[i];else if(i===this.#g)this.#g=this.#y[i];else{let o=this.#b[i];this.#y[o]=this.#y[i];let h=this.#y[i];this.#b[h]=this.#b[i]}this.#l--,this.#v.push(i)}}if(this.#c&&this.#d?.length){let i=this.#d,r;for(;r=i?.shift();)this.#h?.(...r)}return s}clear(){return this.#$("delete")}#$(t){for(let e of this.#R({allowStale:!0})){let s=this.#s[e];if(this.#o(s))s.__abortController.abort(new Error("deleted"));else{let i=this.#n[e];this.#S&&this.#r?.(s,i,t),this.#c&&this.#d?.push([s,i,t])}}if(this.#a.clear(),this.#s.fill(void 0),this.#n.fill(void 0),this.#w&&this.#C&&(this.#w.fill(0),this.#C.fill(0)),this.#x&&this.#x.fill(0),this.#g=0,this.#u=0,this.#v.length=0,this.#p=0,this.#l=0,this.#c&&this.#d){let e=this.#d,s;for(;s=e?.shift();)this.#h?.(...s)}}};import{posix as sr,win32 as Ne}from"node:path";import{fileURLToPath as ir}from"node:url";import{lstatSync as rr,readdir as nr,readdirSync as or,readlinkSync as hr,realpathSync as ar}from"fs";import*as lr from"node:fs";import{lstat as fr,readdir as ur,readlink as dr,realpath as pr}from"node:fs/promises";import{EventEmitter as De}from"node:events";import Ts from"node:stream";import{StringDecoder as qi}from"node:string_decoder";var Es=typeof process=="object"&&process?process:{stdout:null,stderr:null},Ki=n=>!!n&&typeof n=="object"&&(n instanceof ct||n instanceof Ts||Vi(n)||Yi(n)),Vi=n=>!!n&&typeof n=="object"&&n instanceof De&&typeof n.pipe=="function"&&n.pipe!==Ts.Writable.prototype.pipe,Yi=n=>!!n&&typeof n=="object"&&n instanceof De&&typeof n.write=="function"&&typeof n.end=="function",st=Symbol("EOF"),it=Symbol("maybeEmitEnd"),lt=Symbol("emittedEnd"),ie=Symbol("emittingEnd"),Wt=Symbol("emittedError"),re=Symbol("closed"),vs=Symbol("read"),ne=Symbol("flush"),xs=Symbol("flushChunk"),Y=Symbol("encoding"),Tt=Symbol("decoder"),F=Symbol("flowing"),Pt=Symbol("paused"),At=Symbol("resume"),M=Symbol("buffer"),P=Symbol("pipes"),N=Symbol("bufferLength"),Ce=Symbol("bufferPush"),oe=Symbol("bufferShift"),L=Symbol("objectMode"),T=Symbol("destroyed"),Te=Symbol("error"),Ae=Symbol("emitData"),Cs=Symbol("emitEnd"),Re=Symbol("emitEnd2"),Q=Symbol("async"),ke=Symbol("abort"),he=Symbol("aborted"),jt=Symbol("signal"),gt=Symbol("dataListeners"),B=Symbol("discarded"),zt=n=>Promise.resolve().then(n),Ji=n=>n(),Zi=n=>n==="end"||n==="finish"||n==="prefinish",Xi=n=>n instanceof ArrayBuffer||!!n&&typeof n=="object"&&n.constructor&&n.constructor.name==="ArrayBuffer"&&n.byteLength>=0,Qi=n=>!Buffer.isBuffer(n)&&ArrayBuffer.isView(n),ae=class{src;dest;opts;ondrain;constructor(t,e,s){this.src=t,this.dest=e,this.opts=s,this.ondrain=()=>t[At](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(t){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},Oe=class extends ae{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(t,e,s){super(t,e,s),this.proxyErrors=i=>e.emit("error",i),t.on("error",this.proxyErrors)}},tr=n=>!!n.objectMode,er=n=>!n.objectMode&&!!n.encoding&&n.encoding!=="buffer",ct=class extends De{[F]=!1;[Pt]=!1;[P]=[];[M]=[];[L];[Y];[Q];[Tt];[st]=!1;[lt]=!1;[ie]=!1;[re]=!1;[Wt]=null;[N]=0;[T]=!1;[jt];[he]=!1;[gt]=0;[B]=!1;writable=!0;readable=!0;constructor(...t){let e=t[0]||{};if(super(),e.objectMode&&typeof e.encoding=="string")throw new TypeError("Encoding and objectMode may not be used together");tr(e)?(this[L]=!0,this[Y]=null):er(e)?(this[Y]=e.encoding,this[L]=!1):(this[L]=!1,this[Y]=null),this[Q]=!!e.async,this[Tt]=this[Y]?new qi(this[Y]):null,e&&e.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[M]}),e&&e.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[P]});let{signal:s}=e;s&&(this[jt]=s,s.aborted?this[ke]():s.addEventListener("abort",()=>this[ke]()))}get bufferLength(){return this[N]}get encoding(){return this[Y]}set encoding(t){throw new Error("Encoding must be set at instantiation time")}setEncoding(t){throw new Error("Encoding must be set at instantiation time")}get objectMode(){return this[L]}set objectMode(t){throw new Error("objectMode must be set at instantiation time")}get async(){return this[Q]}set async(t){this[Q]=this[Q]||!!t}[ke](){this[he]=!0,this.emit("abort",this[jt]?.reason),this.destroy(this[jt]?.reason)}get aborted(){return this[he]}set aborted(t){}write(t,e,s){if(this[he])return!1;if(this[st])throw new Error("write after end");if(this[T])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;typeof e=="function"&&(s=e,e="utf8"),e||(e="utf8");let i=this[Q]?zt:Ji;if(!this[L]&&!Buffer.isBuffer(t)){if(Qi(t))t=Buffer.from(t.buffer,t.byteOffset,t.byteLength);else if(Xi(t))t=Buffer.from(t);else if(typeof t!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[L]?(this[F]&&this[N]!==0&&this[ne](!0),this[F]?this.emit("data",t):this[Ce](t),this[N]!==0&&this.emit("readable"),s&&i(s),this[F]):t.length?(typeof t=="string"&&!(e===this[Y]&&!this[Tt]?.lastNeed)&&(t=Buffer.from(t,e)),Buffer.isBuffer(t)&&this[Y]&&(t=this[Tt].write(t)),this[F]&&this[N]!==0&&this[ne](!0),this[F]?this.emit("data",t):this[Ce](t),this[N]!==0&&this.emit("readable"),s&&i(s),this[F]):(this[N]!==0&&this.emit("readable"),s&&i(s),this[F])}read(t){if(this[T])return null;if(this[B]=!1,this[N]===0||t===0||t&&t>this[N])return this[it](),null;this[L]&&(t=null),this[M].length>1&&!this[L]&&(this[M]=[this[Y]?this[M].join(""):Buffer.concat(this[M],this[N])]);let e=this[vs](t||null,this[M][0]);return this[it](),e}[vs](t,e){if(this[L])this[oe]();else{let s=e;t===s.length||t===null?this[oe]():typeof s=="string"?(this[M][0]=s.slice(t),e=s.slice(0,t),this[N]-=t):(this[M][0]=s.subarray(t),e=s.subarray(0,t),this[N]-=t)}return this.emit("data",e),!this[M].length&&!this[st]&&this.emit("drain"),e}end(t,e,s){return typeof t=="function"&&(s=t,t=void 0),typeof e=="function"&&(s=e,e="utf8"),t!==void 0&&this.write(t,e),s&&this.once("end",s),this[st]=!0,this.writable=!1,(this[F]||!this[Pt])&&this[it](),this}[At](){this[T]||(!this[gt]&&!this[P].length&&(this[B]=!0),this[Pt]=!1,this[F]=!0,this.emit("resume"),this[M].length?this[ne]():this[st]?this[it]():this.emit("drain"))}resume(){return this[At]()}pause(){this[F]=!1,this[Pt]=!0,this[B]=!1}get destroyed(){return this[T]}get flowing(){return this[F]}get paused(){return this[Pt]}[Ce](t){this[L]?this[N]+=1:this[N]+=t.length,this[M].push(t)}[oe](){return this[L]?this[N]-=1:this[N]-=this[M][0].length,this[M].shift()}[ne](t=!1){do;while(this[xs](this[oe]())&&this[M].length);!t&&!this[M].length&&!this[st]&&this.emit("drain")}[xs](t){return this.emit("data",t),this[F]}pipe(t,e){if(this[T])return t;this[B]=!1;let s=this[lt];return e=e||{},t===Es.stdout||t===Es.stderr?e.end=!1:e.end=e.end!==!1,e.proxyErrors=!!e.proxyErrors,s?e.end&&t.end():(this[P].push(e.proxyErrors?new Oe(this,t,e):new ae(this,t,e)),this[Q]?zt(()=>this[At]()):this[At]()),t}unpipe(t){let e=this[P].find(s=>s.dest===t);e&&(this[P].length===1?(this[F]&&this[gt]===0&&(this[F]=!1),this[P]=[]):this[P].splice(this[P].indexOf(e),1),e.unpipe())}addListener(t,e){return this.on(t,e)}on(t,e){let s=super.on(t,e);if(t==="data")this[B]=!1,this[gt]++,!this[P].length&&!this[F]&&this[At]();else if(t==="readable"&&this[N]!==0)super.emit("readable");else if(Zi(t)&&this[lt])super.emit(t),this.removeAllListeners(t);else if(t==="error"&&this[Wt]){let i=e;this[Q]?zt(()=>i.call(this,this[Wt])):i.call(this,this[Wt])}return s}removeListener(t,e){return this.off(t,e)}off(t,e){let s=super.off(t,e);return t==="data"&&(this[gt]=this.listeners("data").length,this[gt]===0&&!this[B]&&!this[P].length&&(this[F]=!1)),s}removeAllListeners(t){let e=super.removeAllListeners(t);return(t==="data"||t===void 0)&&(this[gt]=0,!this[B]&&!this[P].length&&(this[F]=!1)),e}get emittedEnd(){return this[lt]}[it](){!this[ie]&&!this[lt]&&!this[T]&&this[M].length===0&&this[st]&&(this[ie]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[re]&&this.emit("close"),this[ie]=!1)}emit(t,...e){let s=e[0];if(t!=="error"&&t!=="close"&&t!==T&&this[T])return!1;if(t==="data")return!this[L]&&!s?!1:this[Q]?(zt(()=>this[Ae](s)),!0):this[Ae](s);if(t==="end")return this[Cs]();if(t==="close"){if(this[re]=!0,!this[lt]&&!this[T])return!1;let r=super.emit("close");return this.removeAllListeners("close"),r}else if(t==="error"){this[Wt]=s,super.emit(Te,s);let r=!this[jt]||this.listeners("error").length?super.emit("error",s):!1;return this[it](),r}else if(t==="resume"){let r=super.emit("resume");return this[it](),r}else if(t==="finish"||t==="prefinish"){let r=super.emit(t);return this.removeAllListeners(t),r}let i=super.emit(t,...e);return this[it](),i}[Ae](t){for(let s of this[P])s.dest.write(t)===!1&&this.pause();let e=this[B]?!1:super.emit("data",t);return this[it](),e}[Cs](){return this[lt]?!1:(this[lt]=!0,this.readable=!1,this[Q]?(zt(()=>this[Re]()),!0):this[Re]())}[Re](){if(this[Tt]){let e=this[Tt].end();if(e){for(let s of this[P])s.dest.write(e);this[B]||super.emit("data",e)}}for(let e of this[P])e.end();let t=super.emit("end");return this.removeAllListeners("end"),t}async collect(){let t=Object.assign([],{dataLength:0});this[L]||(t.dataLength=0);let e=this.promise();return this.on("data",s=>{t.push(s),this[L]||(t.dataLength+=s.length)}),await e,t}async concat(){if(this[L])throw new Error("cannot concat in objectMode");let t=await this.collect();return this[Y]?t.join(""):Buffer.concat(t,t.dataLength)}async promise(){return new Promise((t,e)=>{this.on(T,()=>e(new Error("stream destroyed"))),this.on("error",s=>e(s)),this.on("end",()=>t())})}[Symbol.asyncIterator](){this[B]=!1;let t=!1,e=async()=>(this.pause(),t=!0,{value:void 0,done:!0});return{next:()=>{if(t)return e();let i=this.read();if(i!==null)return Promise.resolve({done:!1,value:i});if(this[st])return e();let r,o,h=f=>{this.off("data",a),this.off("end",l),this.off(T,c),e(),o(f)},a=f=>{this.off("error",h),this.off("end",l),this.off(T,c),this.pause(),r({value:f,done:!!this[st]})},l=()=>{this.off("error",h),this.off("data",a),this.off(T,c),e(),r({done:!0,value:void 0})},c=()=>h(new Error("stream destroyed"));return new Promise((f,u)=>{o=u,r=f,this.once(T,c),this.once("error",h),this.once("end",l),this.once("data",a)})},throw:e,return:e,[Symbol.asyncIterator](){return this}}}[Symbol.iterator](){this[B]=!1;let t=!1,e=()=>(this.pause(),this.off(Te,e),this.off(T,e),this.off("end",e),t=!0,{done:!0,value:void 0}),s=()=>{if(t)return e();let i=this.read();return i===null?e():{done:!1,value:i}};return this.once("end",e),this.once(Te,e),this.once(T,e),{next:s,throw:e,return:e,[Symbol.iterator](){return this}}}destroy(t){if(this[T])return t?this.emit("error",t):this.emit(T),this;this[T]=!0,this[B]=!0,this[M].length=0,this[N]=0;let e=this;return typeof e.close=="function"&&!this[re]&&e.close(),t?this.emit("error",t):this.emit(T),this}static get isStream(){return Ki}};var cr=ar.native,Bt={lstatSync:rr,readdir:nr,readdirSync:or,readlinkSync:hr,realpathSync:cr,promises:{lstat:fr,readdir:ur,readlink:dr,realpath:pr}},Ds=n=>!n||n===Bt||n===lr?Bt:{...Bt,...n,promises:{...Bt.promises,...n.promises||{}}},Fs=/^\\\\\?\\([a-z]:)\\?$/i,mr=n=>n.replace(/\//g,"\\").replace(Fs,"$1\\"),gr=/[\\\/]/,H=0,Ms=1,Ns=2,tt=4,_s=6,Ls=8,wt=10,Is=12,G=15,$t=~G,Fe=16,As=32,Ut=64,J=128,le=256,fe=512,Rs=Ut|J|fe,wr=1023,Me=n=>n.isFile()?Ls:n.isDirectory()?tt:n.isSymbolicLink()?wt:n.isCharacterDevice()?Ns:n.isBlockDevice()?_s:n.isSocket()?Is:n.isFIFO()?Ms:H,ks=new Map,Gt=n=>{let t=ks.get(n);if(t)return t;let e=n.normalize("NFKD");return ks.set(n,e),e},Os=new Map,ce=n=>{let t=Os.get(n);if(t)return t;let e=Gt(n.toLowerCase());return Os.set(n,e),e},ue=class extends mt{constructor(){super({max:256})}},_e=class extends mt{constructor(t=16*1024){super({maxSize:t,sizeCalculation:e=>e.length+1})}},Ws=Symbol("PathScurry setAsCwd"),I=class{name;root;roots;parent;nocase;isCWD=!1;#e;#i;get dev(){return this.#i}#r;get mode(){return this.#r}#h;get nlink(){return this.#h}#f;get uid(){return this.#f}#k;get gid(){return this.#k}#l;get rdev(){return this.#l}#p;get blksize(){return this.#p}#a;get ino(){return this.#a}#n;get size(){return this.#n}#s;get blocks(){return this.#s}#y;get atimeMs(){return this.#y}#b;get mtimeMs(){return this.#b}#g;get ctimeMs(){return this.#g}#u;get birthtimeMs(){return this.#u}#v;get atime(){return this.#v}#d;get mtime(){return this.#d}#x;get ctime(){return this.#x}#C;get birthtime(){return this.#C}#w;#S;#E;#c;#O;#T;#t;#M;#m;#D;get parentPath(){return(this.parent||this).fullpath()}get path(){return this.parentPath}constructor(t,e=H,s,i,r,o,h){this.name=t,this.#w=r?ce(t):Gt(t),this.#t=e&wr,this.nocase=r,this.roots=i,this.root=s||this,this.#M=o,this.#E=h.fullpath,this.#O=h.relative,this.#T=h.relativePosix,this.parent=h.parent,this.parent?this.#e=this.parent.#e:this.#e=Ds(h.fs)}depth(){return this.#S!==void 0?this.#S:this.parent?this.#S=this.parent.depth()+1:this.#S=0}childrenCache(){return this.#M}resolve(t){if(!t)return this;let e=this.getRootString(t),i=t.substring(e.length).split(this.splitSep);return e?this.getRoot(e).#N(i):this.#N(i)}#N(t){let e=this;for(let s of t)e=e.child(s);return e}children(){let t=this.#M.get(this);if(t)return t;let e=Object.assign([],{provisional:0});return this.#M.set(this,e),this.#t&=~Fe,e}child(t,e){if(t===""||t===".")return this;if(t==="..")return this.parent||this;let s=this.children(),i=this.nocase?ce(t):Gt(t);for(let a of s)if(a.#w===i)return a;let r=this.parent?this.sep:"",o=this.#E?this.#E+r+t:void 0,h=this.newChild(t,H,{...e,parent:this,fullpath:o});return this.canReaddir()||(h.#t|=J),s.push(h),h}relative(){if(this.isCWD)return"";if(this.#O!==void 0)return this.#O;let t=this.name,e=this.parent;if(!e)return this.#O=this.name;let s=e.relative();return s+(!s||!e.parent?"":this.sep)+t}relativePosix(){if(this.sep==="/")return this.relative();if(this.isCWD)return"";if(this.#T!==void 0)return this.#T;let t=this.name,e=this.parent;if(!e)return this.#T=this.fullpathPosix();let s=e.relativePosix();return s+(!s||!e.parent?"":"/")+t}fullpath(){if(this.#E!==void 0)return this.#E;let t=this.name,e=this.parent;if(!e)return this.#E=this.name;let i=e.fullpath()+(e.parent?this.sep:"")+t;return this.#E=i}fullpathPosix(){if(this.#c!==void 0)return this.#c;if(this.sep==="/")return this.#c=this.fullpath();if(!this.parent){let i=this.fullpath().replace(/\\/g,"/");return/^[a-z]:\//i.test(i)?this.#c=`//?/${i}`:this.#c=i}let t=this.parent,e=t.fullpathPosix(),s=e+(!e||!t.parent?"":"/")+this.name;return this.#c=s}isUnknown(){return(this.#t&G)===H}isType(t){return this[`is${t}`]()}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.#t&G)===Ls}isDirectory(){return(this.#t&G)===tt}isCharacterDevice(){return(this.#t&G)===Ns}isBlockDevice(){return(this.#t&G)===_s}isFIFO(){return(this.#t&G)===Ms}isSocket(){return(this.#t&G)===Is}isSymbolicLink(){return(this.#t&wt)===wt}lstatCached(){return this.#t&As?this:void 0}readlinkCached(){return this.#m}realpathCached(){return this.#D}readdirCached(){let t=this.children();return t.slice(0,t.provisional)}canReadlink(){if(this.#m)return!0;if(!this.parent)return!1;let t=this.#t&G;return!(t!==H&&t!==wt||this.#t&le||this.#t&J)}calledReaddir(){return!!(this.#t&Fe)}isENOENT(){return!!(this.#t&J)}isNamed(t){return this.nocase?this.#w===ce(t):this.#w===Gt(t)}async readlink(){let t=this.#m;if(t)return t;if(this.canReadlink()&&this.parent)try{let e=await this.#e.promises.readlink(this.fullpath()),s=(await this.parent.realpath())?.resolve(e);if(s)return this.#m=s}catch(e){this.#o(e.code);return}}readlinkSync(){let t=this.#m;if(t)return t;if(this.canReadlink()&&this.parent)try{let e=this.#e.readlinkSync(this.fullpath()),s=this.parent.realpathSync()?.resolve(e);if(s)return this.#m=s}catch(e){this.#o(e.code);return}}#_(t){this.#t|=Fe;for(let e=t.provisional;e<t.length;e++){let s=t[e];s&&s.#L()}}#L(){this.#t&J||(this.#t=(this.#t|J)&$t,this.#A())}#A(){let t=this.children();t.provisional=0;for(let e of t)e.#L()}#R(){this.#t|=fe,this.#I()}#I(){if(this.#t&Ut)return;let t=this.#t;(t&G)===tt&&(t&=$t),this.#t=t|Ut,this.#A()}#W(t=""){t==="ENOTDIR"||t==="EPERM"?this.#I():t==="ENOENT"?this.#L():this.children().provisional=0}#P(t=""){t==="ENOTDIR"?this.parent.#I():t==="ENOENT"&&this.#L()}#o(t=""){let e=this.#t;e|=le,t==="ENOENT"&&(e|=J),(t==="EINVAL"||t==="UNKNOWN")&&(e&=$t),this.#t=e,t==="ENOTDIR"&&this.parent&&this.parent.#I()}#j(t,e){return this.#F(t,e)||this.#z(t,e)}#z(t,e){let s=Me(t),i=this.newChild(t.name,s,{parent:this}),r=i.#t&G;return r!==tt&&r!==wt&&r!==H&&(i.#t|=Ut),e.unshift(i),e.provisional++,i}#F(t,e){for(let s=e.provisional;s<e.length;s++){let i=e[s];if((this.nocase?ce(t.name):Gt(t.name))===i.#w)return this.#$(t,i,s,e)}}#$(t,e,s,i){let r=e.name;return e.#t=e.#t&$t|Me(t),r!==t.name&&(e.name=t.name),s!==i.provisional&&(s===i.length-1?i.pop():i.splice(s,1),i.unshift(e)),i.provisional++,e}async lstat(){if(!(this.#t&J))try{return this.#H(await this.#e.promises.lstat(this.fullpath())),this}catch(t){this.#P(t.code)}}lstatSync(){if(!(this.#t&J))try{return this.#H(this.#e.lstatSync(this.fullpath())),this}catch(t){this.#P(t.code)}}#H(t){let{atime:e,atimeMs:s,birthtime:i,birthtimeMs:r,blksize:o,blocks:h,ctime:a,ctimeMs:l,dev:c,gid:f,ino:u,mode:m,mtime:y,mtimeMs:d,nlink:w,rdev:g,size:b,uid:E}=t;this.#v=e,this.#y=s,this.#C=i,this.#u=r,this.#p=o,this.#s=h,this.#x=a,this.#g=l,this.#i=c,this.#k=f,this.#a=u,this.#r=m,this.#d=y,this.#b=d,this.#h=w,this.#l=g,this.#n=b,this.#f=E;let S=Me(t);this.#t=this.#t&$t|S|As,S!==H&&S!==tt&&S!==wt&&(this.#t|=Ut)}#U=[];#G=!1;#q(t){this.#G=!1;let e=this.#U.slice();this.#U.length=0,e.forEach(s=>s(null,t))}readdirCB(t,e=!1){if(!this.canReaddir()){e?t(null,[]):queueMicrotask(()=>t(null,[]));return}let s=this.children();if(this.calledReaddir()){let r=s.slice(0,s.provisional);e?t(null,r):queueMicrotask(()=>t(null,r));return}if(this.#U.push(t),this.#G)return;this.#G=!0;let i=this.fullpath();this.#e.readdir(i,{withFileTypes:!0},(r,o)=>{if(r)this.#W(r.code),s.provisional=0;else{for(let h of o)this.#j(h,s);this.#_(s)}this.#q(s.slice(0,s.provisional))})}#B;async readdir(){if(!this.canReaddir())return[];let t=this.children();if(this.calledReaddir())return t.slice(0,t.provisional);let e=this.fullpath();if(this.#B)await this.#B;else{let s=()=>{};this.#B=new Promise(i=>s=i);try{for(let i of await this.#e.promises.readdir(e,{withFileTypes:!0}))this.#j(i,t);this.#_(t)}catch(i){this.#W(i.code),t.provisional=0}this.#B=void 0,s()}return t.slice(0,t.provisional)}readdirSync(){if(!this.canReaddir())return[];let t=this.children();if(this.calledReaddir())return t.slice(0,t.provisional);let e=this.fullpath();try{for(let s of this.#e.readdirSync(e,{withFileTypes:!0}))this.#j(s,t);this.#_(t)}catch(s){this.#W(s.code),t.provisional=0}return t.slice(0,t.provisional)}canReaddir(){if(this.#t&Rs)return!1;let t=G&this.#t;return t===H||t===tt||t===wt}shouldWalk(t,e){return(this.#t&tt)===tt&&!(this.#t&Rs)&&!t.has(this)&&(!e||e(this))}async realpath(){if(this.#D)return this.#D;if(!((fe|le|J)&this.#t))try{let t=await this.#e.promises.realpath(this.fullpath());return this.#D=this.resolve(t)}catch{this.#R()}}realpathSync(){if(this.#D)return this.#D;if(!((fe|le|J)&this.#t))try{let t=this.#e.realpathSync(this.fullpath());return this.#D=this.resolve(t)}catch{this.#R()}}[Ws](t){if(t===this)return;t.isCWD=!1,this.isCWD=!0;let e=new Set([]),s=[],i=this;for(;i&&i.parent;)e.add(i),i.#O=s.join(this.sep),i.#T=s.join("/"),i=i.parent,s.push("..");for(i=t;i&&i.parent&&!e.has(i);)i.#O=void 0,i.#T=void 0,i=i.parent}},Rt=class extends I{sep="\\";splitSep=gr;constructor(t,e=H,s,i,r,o,h){super(t,e,s,i,r,o,h)}newChild(t,e=H,s={}){return new Rt(t,e,this.root,this.roots,this.nocase,this.childrenCache(),s)}getRootString(t){return Ne.parse(t).root}getRoot(t){if(t=mr(t.toUpperCase()),t===this.root.name)return this.root;for(let[e,s]of Object.entries(this.roots))if(this.sameRoot(t,e))return this.roots[t]=s;return this.roots[t]=new Ot(t,this).root}sameRoot(t,e=this.root.name){return t=t.toUpperCase().replace(/\//g,"\\").replace(Fs,"$1\\"),t===e}},kt=class extends I{splitSep="/";sep="/";constructor(t,e=H,s,i,r,o,h){super(t,e,s,i,r,o,h)}getRootString(t){return t.startsWith("/")?"/":""}getRoot(t){return this.root}newChild(t,e=H,s={}){return new kt(t,e,this.root,this.roots,this.nocase,this.childrenCache(),s)}},de=class{root;rootPath;roots;cwd;#e;#i;#r;nocase;#h;constructor(t=process.cwd(),e,s,{nocase:i,childrenCacheSize:r=16*1024,fs:o=Bt}={}){this.#h=Ds(o),(t instanceof URL||t.startsWith("file://"))&&(t=ir(t));let h=e.resolve(t);this.roots=Object.create(null),this.rootPath=this.parseRootPath(h),this.#e=new ue,this.#i=new ue,this.#r=new _e(r);let a=h.substring(this.rootPath.length).split(s);if(a.length===1&&!a[0]&&a.pop(),i===void 0)throw new TypeError("must provide nocase setting to PathScurryBase ctor");this.nocase=i,this.root=this.newRoot(this.#h),this.roots[this.rootPath]=this.root;let l=this.root,c=a.length-1,f=e.sep,u=this.rootPath,m=!1;for(let y of a){let d=c--;l=l.child(y,{relative:new Array(d).fill("..").join(f),relativePosix:new Array(d).fill("..").join("/"),fullpath:u+=(m?"":f)+y}),m=!0}this.cwd=l}depth(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.depth()}childrenCache(){return this.#r}resolve(...t){let e="";for(let r=t.length-1;r>=0;r--){let o=t[r];if(!(!o||o===".")&&(e=e?`${o}/${e}`:o,this.isAbsolute(o)))break}let s=this.#e.get(e);if(s!==void 0)return s;let i=this.cwd.resolve(e).fullpath();return this.#e.set(e,i),i}resolvePosix(...t){let e="";for(let r=t.length-1;r>=0;r--){let o=t[r];if(!(!o||o===".")&&(e=e?`${o}/${e}`:o,this.isAbsolute(o)))break}let s=this.#i.get(e);if(s!==void 0)return s;let i=this.cwd.resolve(e).fullpathPosix();return this.#i.set(e,i),i}relative(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.relative()}relativePosix(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.relativePosix()}basename(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.name}dirname(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),(t.parent||t).fullpath()}async readdir(t=this.cwd,e={withFileTypes:!0}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof I||(e=t,t=this.cwd);let{withFileTypes:s}=e;if(t.canReaddir()){let i=await t.readdir();return s?i:i.map(r=>r.name)}else return[]}readdirSync(t=this.cwd,e={withFileTypes:!0}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof I||(e=t,t=this.cwd);let{withFileTypes:s=!0}=e;return t.canReaddir()?s?t.readdirSync():t.readdirSync().map(i=>i.name):[]}async lstat(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.lstat()}lstatSync(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.lstatSync()}async readlink(t=this.cwd,{withFileTypes:e}={withFileTypes:!1}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof I||(e=t.withFileTypes,t=this.cwd);let s=await t.readlink();return e?s:s?.fullpath()}readlinkSync(t=this.cwd,{withFileTypes:e}={withFileTypes:!1}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof I||(e=t.withFileTypes,t=this.cwd);let s=t.readlinkSync();return e?s:s?.fullpath()}async realpath(t=this.cwd,{withFileTypes:e}={withFileTypes:!1}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof I||(e=t.withFileTypes,t=this.cwd);let s=await t.realpath();return e?s:s?.fullpath()}realpathSync(t=this.cwd,{withFileTypes:e}={withFileTypes:!1}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof I||(e=t.withFileTypes,t=this.cwd);let s=t.realpathSync();return e?s:s?.fullpath()}async walk(t=this.cwd,e={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof I||(e=t,t=this.cwd);let{withFileTypes:s=!0,follow:i=!1,filter:r,walkFilter:o}=e,h=[];(!r||r(t))&&h.push(s?t:t.fullpath());let a=new Set,l=(f,u)=>{a.add(f),f.readdirCB((m,y)=>{if(m)return u(m);let d=y.length;if(!d)return u();let w=()=>{--d===0&&u()};for(let g of y)(!r||r(g))&&h.push(s?g:g.fullpath()),i&&g.isSymbolicLink()?g.realpath().then(b=>b?.isUnknown()?b.lstat():b).then(b=>b?.shouldWalk(a,o)?l(b,w):w()):g.shouldWalk(a,o)?l(g,w):w()},!0)},c=t;return new Promise((f,u)=>{l(c,m=>{if(m)return u(m);f(h)})})}walkSync(t=this.cwd,e={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof I||(e=t,t=this.cwd);let{withFileTypes:s=!0,follow:i=!1,filter:r,walkFilter:o}=e,h=[];(!r||r(t))&&h.push(s?t:t.fullpath());let a=new Set([t]);for(let l of a){let c=l.readdirSync();for(let f of c){(!r||r(f))&&h.push(s?f:f.fullpath());let u=f;if(f.isSymbolicLink()){if(!(i&&(u=f.realpathSync())))continue;u.isUnknown()&&u.lstatSync()}u.shouldWalk(a,o)&&a.add(u)}}return h}[Symbol.asyncIterator](){return this.iterate()}iterate(t=this.cwd,e={}){return typeof t=="string"?t=this.cwd.resolve(t):t instanceof I||(e=t,t=this.cwd),this.stream(t,e)[Symbol.asyncIterator]()}[Symbol.iterator](){return this.iterateSync()}*iterateSync(t=this.cwd,e={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof I||(e=t,t=this.cwd);let{withFileTypes:s=!0,follow:i=!1,filter:r,walkFilter:o}=e;(!r||r(t))&&(yield s?t:t.fullpath());let h=new Set([t]);for(let a of h){let l=a.readdirSync();for(let c of l){(!r||r(c))&&(yield s?c:c.fullpath());let f=c;if(c.isSymbolicLink()){if(!(i&&(f=c.realpathSync())))continue;f.isUnknown()&&f.lstatSync()}f.shouldWalk(h,o)&&h.add(f)}}}stream(t=this.cwd,e={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof I||(e=t,t=this.cwd);let{withFileTypes:s=!0,follow:i=!1,filter:r,walkFilter:o}=e,h=new ct({objectMode:!0});(!r||r(t))&&h.write(s?t:t.fullpath());let a=new Set,l=[t],c=0,f=()=>{let u=!1;for(;!u;){let m=l.shift();if(!m){c===0&&h.end();return}c++,a.add(m);let y=(w,g,b=!1)=>{if(w)return h.emit("error",w);if(i&&!b){let E=[];for(let S of g)S.isSymbolicLink()&&E.push(S.realpath().then(v=>v?.isUnknown()?v.lstat():v));if(E.length){Promise.all(E).then(()=>y(null,g,!0));return}}for(let E of g)E&&(!r||r(E))&&(h.write(s?E:E.fullpath())||(u=!0));c--;for(let E of g){let S=E.realpathCached()||E;S.shouldWalk(a,o)&&l.push(S)}u&&!h.flowing?h.once("drain",f):d||f()},d=!0;m.readdirCB(y,!0),d=!1}};return f(),h}streamSync(t=this.cwd,e={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof I||(e=t,t=this.cwd);let{withFileTypes:s=!0,follow:i=!1,filter:r,walkFilter:o}=e,h=new ct({objectMode:!0}),a=new Set;(!r||r(t))&&h.write(s?t:t.fullpath());let l=[t],c=0,f=()=>{let u=!1;for(;!u;){let m=l.shift();if(!m){c===0&&h.end();return}c++,a.add(m);let y=m.readdirSync();for(let d of y)(!r||r(d))&&(h.write(s?d:d.fullpath())||(u=!0));c--;for(let d of y){let w=d;if(d.isSymbolicLink()){if(!(i&&(w=d.realpathSync())))continue;w.isUnknown()&&w.lstatSync()}w.shouldWalk(a,o)&&l.push(w)}}u&&!h.flowing&&h.once("drain",f)};return f(),h}chdir(t=this.cwd){let e=this.cwd;this.cwd=typeof t=="string"?this.cwd.resolve(t):t,this.cwd[Ws](e)}},Ot=class extends de{sep="\\";constructor(t=process.cwd(),e={}){let{nocase:s=!0}=e;super(t,Ne,"\\",{...e,nocase:s}),this.nocase=s;for(let i=this.cwd;i;i=i.parent)i.nocase=this.nocase}parseRootPath(t){return Ne.parse(t).root.toUpperCase()}newRoot(t){return new Rt(this.rootPath,tt,void 0,this.roots,this.nocase,this.childrenCache(),{fs:t})}isAbsolute(t){return t.startsWith("/")||t.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(t)}},Dt=class extends de{sep="/";constructor(t=process.cwd(),e={}){let{nocase:s=!1}=e;super(t,sr,"/",{...e,nocase:s}),this.nocase=s}parseRootPath(t){return"/"}newRoot(t){return new kt(this.rootPath,tt,void 0,this.roots,this.nocase,this.childrenCache(),{fs:t})}isAbsolute(t){return t.startsWith("/")}},Ht=class extends Dt{constructor(t=process.cwd(),e={}){let{nocase:s=!0}=e;super(t,{...e,nocase:s})}},yn=process.platform==="win32"?Rt:kt,Ps=process.platform==="win32"?Ot:process.platform==="darwin"?Ht:Dt;var yr=n=>n.length>=1,br=n=>n.length>=1,ft=class{#e;#i;#r;length;#h;#f;#k;#l;#p;#a;#n=!0;constructor(t,e,s,i){if(!yr(t))throw new TypeError("empty pattern list");if(!br(e))throw new TypeError("empty glob list");if(e.length!==t.length)throw new TypeError("mismatched pattern list and glob list lengths");if(this.length=t.length,s<0||s>=this.length)throw new TypeError("index out of range");if(this.#e=t,this.#i=e,this.#r=s,this.#h=i,this.#r===0){if(this.isUNC()){let[r,o,h,a,...l]=this.#e,[c,f,u,m,...y]=this.#i;l[0]===""&&(l.shift(),y.shift());let d=[r,o,h,a,""].join("/"),w=[c,f,u,m,""].join("/");this.#e=[d,...l],this.#i=[w,...y],this.length=this.#e.length}else if(this.isDrive()||this.isAbsolute()){let[r,...o]=this.#e,[h,...a]=this.#i;o[0]===""&&(o.shift(),a.shift());let l=r+"/",c=h+"/";this.#e=[l,...o],this.#i=[c,...a],this.length=this.#e.length}}}pattern(){return this.#e[this.#r]}isString(){return typeof this.#e[this.#r]=="string"}isGlobstar(){return this.#e[this.#r]===_}isRegExp(){return this.#e[this.#r]instanceof RegExp}globString(){return this.#k=this.#k||(this.#r===0?this.isAbsolute()?this.#i[0]+this.#i.slice(1).join("/"):this.#i.join("/"):this.#i.slice(this.#r).join("/"))}hasMore(){return this.length>this.#r+1}rest(){return this.#f!==void 0?this.#f:this.hasMore()?(this.#f=new ft(this.#e,this.#i,this.#r+1,this.#h),this.#f.#a=this.#a,this.#f.#p=this.#p,this.#f.#l=this.#l,this.#f):this.#f=null}isUNC(){let t=this.#e;return this.#p!==void 0?this.#p:this.#p=this.#h==="win32"&&this.#r===0&&t[0]===""&&t[1]===""&&typeof t[2]=="string"&&!!t[2]&&typeof t[3]=="string"&&!!t[3]}isDrive(){let t=this.#e;return this.#l!==void 0?this.#l:this.#l=this.#h==="win32"&&this.#r===0&&this.length>1&&typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0])}isAbsolute(){let t=this.#e;return this.#a!==void 0?this.#a:this.#a=t[0]===""&&t.length>1||this.isDrive()||this.isUNC()}root(){let t=this.#e[0];return typeof t=="string"&&this.isAbsolute()&&this.#r===0?t:""}checkFollowGlobstar(){return!(this.#r===0||!this.isGlobstar()||!this.#n)}markFollowGlobstar(){return this.#r===0||!this.isGlobstar()||!this.#n?!1:(this.#n=!1,!0)}};var Sr=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",Ft=class{relative;relativeChildren;absolute;absoluteChildren;platform;mmopts;constructor(t,{nobrace:e,nocase:s,noext:i,noglobstar:r,platform:o=Sr}){this.relative=[],this.absolute=[],this.relativeChildren=[],this.absoluteChildren=[],this.platform=o,this.mmopts={dot:!0,nobrace:e,nocase:s,noext:i,noglobstar:r,optimizationLevel:2,platform:o,nocomment:!0,nonegate:!0};for(let h of t)this.add(h)}add(t){let e=new $(t,this.mmopts);for(let s=0;s<e.set.length;s++){let i=e.set[s],r=e.globParts[s];if(!i||!r)throw new Error("invalid pattern object");for(;i[0]==="."&&r[0]===".";)i.shift(),r.shift();let o=new ft(i,r,0,this.platform),h=new $(o.globString(),this.mmopts),a=r[r.length-1]==="**",l=o.isAbsolute();l?this.absolute.push(h):this.relative.push(h),a&&(l?this.absoluteChildren.push(h):this.relativeChildren.push(h))}}ignored(t){let e=t.fullpath(),s=`${e}/`,i=t.relative()||".",r=`${i}/`;for(let o of this.relative)if(o.match(i)||o.match(r))return!0;for(let o of this.absolute)if(o.match(e)||o.match(s))return!0;return!1}childrenIgnored(t){let e=t.fullpath()+"/",s=(t.relative()||".")+"/";for(let i of this.relativeChildren)if(i.match(s))return!0;for(let i of this.absoluteChildren)if(i.match(e))return!0;return!1}};var qt=class{store;constructor(t=new Map){this.store=t}copy(){return new qt(new Map(this.store))}hasWalked(t,e){return this.store.get(t.fullpath())?.has(e.globString())}storeWalked(t,e){let s=t.fullpath(),i=this.store.get(s);i?i.add(e.globString()):this.store.set(s,new Set([e.globString()]))}},Le=class{store=new Map;add(t,e,s){let i=(e?2:0)|(s?1:0),r=this.store.get(t);this.store.set(t,r===void 0?i:i&r)}entries(){return[...this.store.entries()].map(([t,e])=>[t,!!(e&2),!!(e&1)])}},Ie=class{store=new Map;add(t,e){if(!t.canReaddir())return;let s=this.store.get(t);s?s.find(i=>i.globString()===e.globString())||s.push(e):this.store.set(t,[e])}get(t){let e=this.store.get(t);if(!e)throw new Error("attempting to walk unknown path");return e}entries(){return this.keys().map(t=>[t,this.store.get(t)])}keys(){return[...this.store.keys()].filter(t=>t.canReaddir())}},yt=class{hasWalkedCache;matches=new Le;subwalks=new Ie;patterns;follow;dot;opts;constructor(t,e){this.opts=t,this.follow=!!t.follow,this.dot=!!t.dot,this.hasWalkedCache=e?e.copy():new qt}processPatterns(t,e){this.patterns=e;let s=e.map(i=>[t,i]);for(let[i,r]of s){this.hasWalkedCache.storeWalked(i,r);let o=r.root(),h=r.isAbsolute()&&this.opts.absolute!==!1;if(o){i=i.resolve(o==="/"&&this.opts.root!==void 0?this.opts.root:o);let f=r.rest();if(f)r=f;else{this.matches.add(i,!0,!1);continue}}if(i.isENOENT())continue;let a,l,c=!1;for(;typeof(a=r.pattern())=="string"&&(l=r.rest());)i=i.resolve(a),r=l,c=!0;if(a=r.pattern(),l=r.rest(),c){if(this.hasWalkedCache.hasWalked(i,r))continue;this.hasWalkedCache.storeWalked(i,r)}if(typeof a=="string"){let f=a===".."||a===""||a===".";this.matches.add(i.resolve(a),h,f);continue}else if(a===_){(!i.isSymbolicLink()||this.follow||r.checkFollowGlobstar())&&this.subwalks.add(i,r);let f=l?.pattern(),u=l?.rest();if(!l||(f===""||f===".")&&!u)this.matches.add(i,h,f===""||f===".");else if(f===".."){let m=i.parent||i;u?this.hasWalkedCache.hasWalked(m,u)||this.subwalks.add(m,u):this.matches.add(m,h,!0)}}else a instanceof RegExp&&this.subwalks.add(i,r)}return this}subwalkTargets(){return this.subwalks.keys()}child(){return new yt(this.opts,this.hasWalkedCache)}filterEntries(t,e){let s=this.subwalks.get(t),i=this.child();for(let r of e)for(let o of s){let h=o.isAbsolute(),a=o.pattern(),l=o.rest();a===_?i.testGlobstar(r,o,l,h):a instanceof RegExp?i.testRegExp(r,a,l,h):i.testString(r,a,l,h)}return i}testGlobstar(t,e,s,i){if((this.dot||!t.name.startsWith("."))&&(e.hasMore()||this.matches.add(t,i,!1),t.canReaddir()&&(this.follow||!t.isSymbolicLink()?this.subwalks.add(t,e):t.isSymbolicLink()&&(s&&e.checkFollowGlobstar()?this.subwalks.add(t,s):e.markFollowGlobstar()&&this.subwalks.add(t,e)))),s){let r=s.pattern();if(typeof r=="string"&&r!==".."&&r!==""&&r!==".")this.testString(t,r,s.rest(),i);else if(r===".."){let o=t.parent||t;this.subwalks.add(o,s)}else r instanceof RegExp&&this.testRegExp(t,r,s.rest(),i)}}testRegExp(t,e,s,i){e.test(t.name)&&(s?this.subwalks.add(t,s):this.matches.add(t,i,!1))}testString(t,e,s,i){t.isNamed(e)&&(s?this.subwalks.add(t,s):this.matches.add(t,i,!1))}};var Er=(n,t)=>typeof n=="string"?new Ft([n],t):Array.isArray(n)?new Ft(n,t):n,pe=class{path;patterns;opts;seen=new Set;paused=!1;aborted=!1;#e=[];#i;#r;signal;maxDepth;includeChildMatches;constructor(t,e,s){if(this.patterns=t,this.path=e,this.opts=s,this.#r=!s.posix&&s.platform==="win32"?"\\":"/",this.includeChildMatches=s.includeChildMatches!==!1,(s.ignore||!this.includeChildMatches)&&(this.#i=Er(s.ignore??[],s),!this.includeChildMatches&&typeof this.#i.add!="function")){let i="cannot ignore child matches, ignore lacks add() method.";throw new Error(i)}this.maxDepth=s.maxDepth||1/0,s.signal&&(this.signal=s.signal,this.signal.addEventListener("abort",()=>{this.#e.length=0}))}#h(t){return this.seen.has(t)||!!this.#i?.ignored?.(t)}#f(t){return!!this.#i?.childrenIgnored?.(t)}pause(){this.paused=!0}resume(){if(this.signal?.aborted)return;this.paused=!1;let t;for(;!this.paused&&(t=this.#e.shift());)t()}onResume(t){this.signal?.aborted||(this.paused?this.#e.push(t):t())}async matchCheck(t,e){if(e&&this.opts.nodir)return;let s;if(this.opts.realpath){if(s=t.realpathCached()||await t.realpath(),!s)return;t=s}let r=t.isUnknown()||this.opts.stat?await t.lstat():t;if(this.opts.follow&&this.opts.nodir&&r?.isSymbolicLink()){let o=await r.realpath();o&&(o.isUnknown()||this.opts.stat)&&await o.lstat()}return this.matchCheckTest(r,e)}matchCheckTest(t,e){return t&&(this.maxDepth===1/0||t.depth()<=this.maxDepth)&&(!e||t.canReaddir())&&(!this.opts.nodir||!t.isDirectory())&&(!this.opts.nodir||!this.opts.follow||!t.isSymbolicLink()||!t.realpathCached()?.isDirectory())&&!this.#h(t)?t:void 0}matchCheckSync(t,e){if(e&&this.opts.nodir)return;let s;if(this.opts.realpath){if(s=t.realpathCached()||t.realpathSync(),!s)return;t=s}let r=t.isUnknown()||this.opts.stat?t.lstatSync():t;if(this.opts.follow&&this.opts.nodir&&r?.isSymbolicLink()){let o=r.realpathSync();o&&(o?.isUnknown()||this.opts.stat)&&o.lstatSync()}return this.matchCheckTest(r,e)}matchFinish(t,e){if(this.#h(t))return;if(!this.includeChildMatches&&this.#i?.add){let r=`${t.relativePosix()}/**`;this.#i.add(r)}let s=this.opts.absolute===void 0?e:this.opts.absolute;this.seen.add(t);let i=this.opts.mark&&t.isDirectory()?this.#r:"";if(this.opts.withFileTypes)this.matchEmit(t);else if(s){let r=this.opts.posix?t.fullpathPosix():t.fullpath();this.matchEmit(r+i)}else{let r=this.opts.posix?t.relativePosix():t.relative(),o=this.opts.dotRelative&&!r.startsWith(".."+this.#r)?"."+this.#r:"";this.matchEmit(r?o+r+i:"."+i)}}async match(t,e,s){let i=await this.matchCheck(t,s);i&&this.matchFinish(i,e)}matchSync(t,e,s){let i=this.matchCheckSync(t,s);i&&this.matchFinish(i,e)}walkCB(t,e,s){this.signal?.aborted&&s(),this.walkCB2(t,e,new yt(this.opts),s)}walkCB2(t,e,s,i){if(this.#f(t))return i();if(this.signal?.aborted&&i(),this.paused){this.onResume(()=>this.walkCB2(t,e,s,i));return}s.processPatterns(t,e);let r=1,o=()=>{--r===0&&i()};for(let[h,a,l]of s.matches.entries())this.#h(h)||(r++,this.match(h,a,l).then(()=>o()));for(let h of s.subwalkTargets()){if(this.maxDepth!==1/0&&h.depth()>=this.maxDepth)continue;r++;let a=h.readdirCached();h.calledReaddir()?this.walkCB3(h,a,s,o):h.readdirCB((l,c)=>this.walkCB3(h,c,s,o),!0)}o()}walkCB3(t,e,s,i){s=s.filterEntries(t,e);let r=1,o=()=>{--r===0&&i()};for(let[h,a,l]of s.matches.entries())this.#h(h)||(r++,this.match(h,a,l).then(()=>o()));for(let[h,a]of s.subwalks.entries())r++,this.walkCB2(h,a,s.child(),o);o()}walkCBSync(t,e,s){this.signal?.aborted&&s(),this.walkCB2Sync(t,e,new yt(this.opts),s)}walkCB2Sync(t,e,s,i){if(this.#f(t))return i();if(this.signal?.aborted&&i(),this.paused){this.onResume(()=>this.walkCB2Sync(t,e,s,i));return}s.processPatterns(t,e);let r=1,o=()=>{--r===0&&i()};for(let[h,a,l]of s.matches.entries())this.#h(h)||this.matchSync(h,a,l);for(let h of s.subwalkTargets()){if(this.maxDepth!==1/0&&h.depth()>=this.maxDepth)continue;r++;let a=h.readdirSync();this.walkCB3Sync(h,a,s,o)}o()}walkCB3Sync(t,e,s,i){s=s.filterEntries(t,e);let r=1,o=()=>{--r===0&&i()};for(let[h,a,l]of s.matches.entries())this.#h(h)||this.matchSync(h,a,l);for(let[h,a]of s.subwalks.entries())r++,this.walkCB2Sync(h,a,s.child(),o);o()}},Kt=class extends pe{matches=new Set;constructor(t,e,s){super(t,e,s)}matchEmit(t){this.matches.add(t)}async walk(){if(this.signal?.aborted)throw this.signal.reason;return this.path.isUnknown()&&await this.path.lstat(),await new Promise((t,e)=>{this.walkCB(this.path,this.patterns,()=>{this.signal?.aborted?e(this.signal.reason):t(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}},Vt=class extends pe{results;constructor(t,e,s){super(t,e,s),this.results=new ct({signal:this.signal,objectMode:!0}),this.results.on("drain",()=>this.resume()),this.results.on("resume",()=>this.resume())}matchEmit(t){this.results.write(t),this.results.flowing||this.pause()}stream(){let t=this.path;return t.isUnknown()?t.lstat().then(()=>{this.walkCB(t,this.patterns,()=>this.results.end())}):this.walkCB(t,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 xr=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",Z=class{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(t,e){if(!e)throw new TypeError("glob options required");if(this.withFileTypes=!!e.withFileTypes,this.signal=e.signal,this.follow=!!e.follow,this.dot=!!e.dot,this.dotRelative=!!e.dotRelative,this.nodir=!!e.nodir,this.mark=!!e.mark,e.cwd?(e.cwd instanceof URL||e.cwd.startsWith("file://"))&&(e.cwd=vr(e.cwd)):this.cwd="",this.cwd=e.cwd||"",this.root=e.root,this.magicalBraces=!!e.magicalBraces,this.nobrace=!!e.nobrace,this.noext=!!e.noext,this.realpath=!!e.realpath,this.absolute=e.absolute,this.includeChildMatches=e.includeChildMatches!==!1,this.noglobstar=!!e.noglobstar,this.matchBase=!!e.matchBase,this.maxDepth=typeof e.maxDepth=="number"?e.maxDepth:1/0,this.stat=!!e.stat,this.ignore=e.ignore,this.withFileTypes&&this.absolute!==void 0)throw new Error("cannot set absolute and withFileTypes:true");if(typeof t=="string"&&(t=[t]),this.windowsPathsNoEscape=!!e.windowsPathsNoEscape||e.allowWindowsEscape===!1,this.windowsPathsNoEscape&&(t=t.map(a=>a.replace(/\\/g,"/"))),this.matchBase){if(e.noglobstar)throw new TypeError("base matching requires globstar");t=t.map(a=>a.includes("/")?a:`./**/${a}`)}if(this.pattern=t,this.platform=e.platform||xr,this.opts={...e,platform:this.platform},e.scurry){if(this.scurry=e.scurry,e.nocase!==void 0&&e.nocase!==e.scurry.nocase)throw new Error("nocase option contradicts provided scurry option")}else{let a=e.platform==="win32"?Ot:e.platform==="darwin"?Ht:e.platform?Dt:Ps;this.scurry=new a(this.cwd,{nocase:e.nocase,fs:e.fs})}this.nocase=this.scurry.nocase;let s=this.platform==="darwin"||this.platform==="win32",i={...e,dot:this.dot,matchBase:this.matchBase,nobrace:this.nobrace,nocase:this.nocase,nocaseMagicOnly:s,nocomment:!0,noext:this.noext,nonegate:!0,optimizationLevel:2,platform:this.platform,windowsPathsNoEscape:this.windowsPathsNoEscape,debug:!!this.opts.debug},r=this.pattern.map(a=>new $(a,i)),[o,h]=r.reduce((a,l)=>(a[0].push(...l.set),a[1].push(...l.globParts),a),[[],[]]);this.patterns=o.map((a,l)=>{let c=h[l];if(!c)throw new Error("invalid pattern object");return new ft(a,c,0,this.platform)})}async walk(){return[...await new Kt(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 Kt(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 Vt(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 Vt(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 We=(n,t={})=>{Array.isArray(n)||(n=[n]);for(let e of n)if(new $(e,t).hasMagic())return!0;return!1};function ge(n,t={}){return new Z(n,t).streamSync()}function zs(n,t={}){return new Z(n,t).stream()}function $s(n,t={}){return new Z(n,t).walkSync()}async function js(n,t={}){return new Z(n,t).walk()}function we(n,t={}){return new Z(n,t).iterateSync()}function Bs(n,t={}){return new Z(n,t).iterate()}var Cr=ge,Tr=Object.assign(zs,{sync:ge}),Ar=we,Rr=Object.assign(Bs,{sync:we}),kr=Object.assign($s,{stream:ge,iterate:we}),me=Object.assign(js,{glob:js,globSync:$s,sync:kr,globStream:zs,stream:Tr,globStreamSync:ge,streamSync:Cr,globIterate:Bs,iterate:Rr,globIterateSync:we,iterateSync:Ar,Glob:Z,hasMagic:We,escape:St,unescape:V});me.glob=me;async function Gs({cwd:n,pattern:t="**"}){return(await me(Us.join(t,"*.sol"),{cwd:n,windowsPathsNoEscape:!0})).sort().map(s=>({filename:s,basename:Us.basename(s,".sol")}))}async function Hs({rootDir:n,config:t}){return(await Gs({cwd:n,pattern:Yt.join(t.sourceDirectory,"**")})).filter(i=>i.basename.endsWith("System")&&i.basename!=="System"&&!/^I[A-Z]/.test(i.basename)).map(i=>{let r=(()=>t.namespace)();return{sourcePath:i.filename,namespaceLabel:r,systemLabel:i.basename}})}import{resolveNamespace as Dr}from"@latticexyz/store/config/v2";async function qs({rootDir:n,config:t}){let e=await Hs({rootDir:n,config:t}),s=e.map(h=>h.systemLabel),i=Object.keys(t.systems).filter(h=>!s.includes(h));if(i.length>0)throw new Error(`Found systems in config with no corresponding system contract: ${i.join(", ")}`);let r=e.map(h=>({...t.systems[h.systemLabel]??ze({label:h.systemLabel,namespace:Dr({label:h.namespaceLabel}).namespace}),sourcePath:h.sourcePath})).filter(h=>!t.excludeSystems.includes(h.label)),o=r.map(h=>h.label);for(let h of r)for(let a of h.accessList)if(!Or(a)&&!o.includes(a))throw new Error(`Access list item (${a}) for system (${h.label}) had no matching system contract.`);return r}async function co({rootDir:n,config:t,clean:e=!0}){let s=j.join(n,t.sourceDirectory,t.codegen.outputDirectory,t.codegen.worldgenDirectory);e&&await Ks.rm(s,{recursive:!0,force:!0});let i=j.join(s,t.codegen.worldInterfaceName+".sol"),r=(await qs({rootDir:n,config:t})).map(a=>{let l=`I${a.label}`;return{...a,interfaceName:l,interfacePath:j.join(j.dirname(i),`${l}.sol`)}}),o=r.map(a=>({symbol:a.interfaceName,path:"./"+j.relative(j.dirname(i),a.interfacePath)}));await Promise.all(r.map(async a=>{let l=await Ks.readFile(a.sourcePath,"utf8"),{functions:c,errors:f,symbolImports:u}=Fr(l,a.label),m=u.map(({symbol:d,path:w})=>({symbol:d,path:w.startsWith(".")?"./"+j.relative(s,j.join(n,j.dirname(a.sourcePath),w)):w})),y=Be({name:a.interfaceName,functionPrefix:a.namespace===""?"":`${a.namespace}__`,functions:c,errors:f,imports:m});await Vs(y,a.interfacePath,"Generated system interface")}));let h=Ue({interfaceName:t.codegen.worldInterfaceName,imports:o,storeImportPath:t.codegen.storeImportPath.startsWith(".")?"./"+j.relative(j.dirname(i),j.join(n,t.codegen.storeImportPath)):t.codegen.storeImportPath,worldImportPath:t.codegen.worldImportPath.startsWith(".")?"./"+j.relative(j.dirname(i),j.join(n,t.codegen.worldImportPath)):t.codegen.worldImportPath});await Vs(h,i,"Generated world interface")}export{Gs as findSolidityFiles,Hs as getSystemContracts,Be as renderSystemInterface,Ue as renderWorldInterface,qs as resolveSystems,co as worldgen};
37
37
  //# sourceMappingURL=node.js.map