@latticexyz/world 3.0.0-main-560fd6a0c → 3.0.0-main-69e23a36b

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
@@ -1,4 +1,4 @@
1
- import{a as We,b as Vs,c as Pe,d as p,e as O,f as x,g as it,h as je}from"./chunk-JEHHYC6A.js";var Ze=We((en,Je)=>{"use strict";Je.exports=Ve;function Ve(n,t,e){n instanceof RegExp&&(n=Ke(n,e)),t instanceof RegExp&&(t=Ke(t,e));var s=Ye(n,t,e);return s&&{start:s[0],end:s[1],pre:e.slice(0,s[0]),body:e.slice(s[0]+n.length,s[1]),post:e.slice(s[1]+t.length)}}function Ke(n,t){var e=t.match(n);return e?e[0]:null}Ve.range=Ye;function Ye(n,t,e){var s,i,r,o,h,a=e.indexOf(n),l=e.indexOf(t,a+1),c=a;if(a>=0&&l>0){if(n===t)return[a,l];for(s=[],r=e.length;c>=0&&!h;)c==a?(s.push(c),a=e.indexOf(n,c+1)):s.length==1?h=[s.pop(),l]:(i=s.pop(),i<r&&(r=i,o=l),l=e.indexOf(t,c+1)),c=a<l&&a>=0?a:l;s.length&&(h=[r,o])}return h}});var ns=We((sn,rs)=>{var Xe=Ze();rs.exports=hi;var Qe="\0SLASH"+Math.random()+"\0",ts="\0OPEN"+Math.random()+"\0",be="\0CLOSE"+Math.random()+"\0",es="\0COMMA"+Math.random()+"\0",ss="\0PERIOD"+Math.random()+"\0";function ye(n){return parseInt(n,10)==n?parseInt(n,10):n.charCodeAt(0)}function ni(n){return n.split("\\\\").join(Qe).split("\\{").join(ts).split("\\}").join(be).split("\\,").join(es).split("\\.").join(ss)}function oi(n){return n.split(Qe).join("\\").split(ts).join("{").split(be).join("}").split(es).join(",").split(ss).join(".")}function is(n){if(!n)return[""];var t=[],e=Xe("{","}",n);if(!e)return n.split(",");var s=e.pre,i=e.body,r=e.post,o=s.split(",");o[o.length-1]+="{"+i+"}";var h=is(r);return r.length&&(o[o.length-1]+=h.shift(),o.push.apply(o,h)),t.push.apply(t,o),t}function hi(n){return n?(n.substr(0,2)==="{}"&&(n="\\{\\}"+n.substr(2)),Mt(ni(n),!0).map(oi)):[]}function ai(n){return"{"+n+"}"}function li(n){return/^-?0\d/.test(n)}function ci(n,t){return n<=t}function fi(n,t){return n>=t}function Mt(n,t){var e=[],s=Xe("{","}",n);if(!s)return[n];var i=s.pre,r=s.post.length?Mt(s.post,!1):[""];if(/\$$/.test(s.pre))for(var o=0;o<r.length;o++){var h=i+"{"+s.body+"}"+r[o];e.push(h)}else{var a=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(s.body),l=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(s.body),c=a||l,f=s.body.indexOf(",")>=0;if(!c&&!f)return s.post.match(/,.*\}/)?(n=s.pre+"{"+s.body+be+s.post,Mt(n)):[n];var u;if(c)u=s.body.split(/\.\./);else if(u=is(s.body),u.length===1&&(u=Mt(u[0],!1).map(ai),u.length===1))return r.map(function(Yt){return s.pre+u[0]+Yt});var m;if(c){var y=ye(u[0]),d=ye(u[1]),w=Math.max(u[0].length,u[1].length),g=u.length==3?Math.abs(ye(u[2])):1,b=ci,E=d<y;E&&(g*=-1,b=fi);var S=u.some(li);m=[];for(var v=y;b(v,d);v+=g){var k;if(l)k=String.fromCharCode(v),k==="\\"&&(k="");else if(k=String(v),S){var H=w-k.length;if(H>0){var ft=new Array(H+1).join("0");v<0?k="-"+ft+k.slice(1):k=ft+k}}m.push(k)}}else{m=[];for(var q=0;q<u.length;q++)m.push.apply(m,Mt(u[q],!1))}for(var q=0;q<m.length;q++)for(var o=0;o<r.length;o++){var h=i+m[q]+r[o];(!t||c||h)&&e.push(h)}}return e}});import{renderArguments as we,renderList as ze,renderedSolidityHeader as Ys,renderImports as Js}from"@latticexyz/common/codegen";function $e(n){let{imports:t,name:e,functionPrefix:s,functions:i,errors:r}=n;return`
1
+ import{a as We,b as Vs,c as Pe,d as p,e as O,f as x,g as it,m as je}from"./chunk-DK3XOTC2.js";var Ke=We((Ir,qe)=>{"use strict";qe.exports=Ge;function Ge(n,t,e){n instanceof RegExp&&(n=Ue(n,e)),t instanceof RegExp&&(t=Ue(t,e));var s=He(n,t,e);return s&&{start:s[0],end:s[1],pre:e.slice(0,s[0]),body:e.slice(s[0]+n.length,s[1]),post:e.slice(s[1]+t.length)}}function Ue(n,t){var e=t.match(n);return e?e[0]:null}Ge.range=He;function He(n,t,e){var s,i,r,o,h,a=e.indexOf(n),l=e.indexOf(t,a+1),c=a;if(a>=0&&l>0){if(n===t)return[a,l];for(s=[],r=e.length;c>=0&&!h;)c==a?(s.push(c),a=e.indexOf(n,c+1)):s.length==1?h=[s.pop(),l]:(i=s.pop(),i<r&&(r=i,o=l),l=e.indexOf(t,c+1)),c=a<l&&a>=0?a:l;s.length&&(h=[r,o])}return h}});var es=We((Lr,ts)=>{var Ve=Ke();ts.exports=ri;var Ye="\0SLASH"+Math.random()+"\0",Je="\0OPEN"+Math.random()+"\0",be="\0CLOSE"+Math.random()+"\0",Ze="\0COMMA"+Math.random()+"\0",Xe="\0PERIOD"+Math.random()+"\0";function ye(n){return parseInt(n,10)==n?parseInt(n,10):n.charCodeAt(0)}function si(n){return n.split("\\\\").join(Ye).split("\\{").join(Je).split("\\}").join(be).split("\\,").join(Ze).split("\\.").join(Xe)}function ii(n){return n.split(Ye).join("\\").split(Je).join("{").split(be).join("}").split(Ze).join(",").split(Xe).join(".")}function Qe(n){if(!n)return[""];var t=[],e=Ve("{","}",n);if(!e)return n.split(",");var s=e.pre,i=e.body,r=e.post,o=s.split(",");o[o.length-1]+="{"+i+"}";var h=Qe(r);return r.length&&(o[o.length-1]+=h.shift(),o.push.apply(o,h)),t.push.apply(t,o),t}function ri(n){return n?(n.substr(0,2)==="{}"&&(n="\\{\\}"+n.substr(2)),Ft(si(n),!0).map(ii)):[]}function ni(n){return"{"+n+"}"}function oi(n){return/^-?0\d/.test(n)}function hi(n,t){return n<=t}function ai(n,t){return n>=t}function Ft(n,t){var e=[],s=Ve("{","}",n);if(!s)return[n];var i=s.pre,r=s.post.length?Ft(s.post,!1):[""];if(/\$$/.test(s.pre))for(var o=0;o<r.length;o++){var h=i+"{"+s.body+"}"+r[o];e.push(h)}else{var a=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(s.body),l=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(s.body),c=a||l,f=s.body.indexOf(",")>=0;if(!c&&!f)return s.post.match(/,.*\}/)?(n=s.pre+"{"+s.body+be+s.post,Ft(n)):[n];var u;if(c)u=s.body.split(/\.\./);else if(u=Qe(s.body),u.length===1&&(u=Ft(u[0],!1).map(ni),u.length===1))return r.map(function(Yt){return s.pre+u[0]+Yt});var m;if(c){var y=ye(u[0]),d=ye(u[1]),w=Math.max(u[0].length,u[1].length),g=u.length==3?Math.abs(ye(u[2])):1,b=hi,E=d<y;E&&(g*=-1,b=ai);var S=u.some(oi);m=[];for(var v=y;b(v,d);v+=g){var k;if(l)k=String.fromCharCode(v),k==="\\"&&(k="");else if(k=String(v),S){var H=w-k.length;if(H>0){var ft=new Array(H+1).join("0");v<0?k="-"+ft+k.slice(1):k=ft+k}}m.push(k)}}else{m=[];for(var q=0;q<u.length;q++)m.push.apply(m,Ft(u[q],!1))}for(var q=0;q<m.length;q++)for(var o=0;o<r.length;o++){var h=i+m[q]+r[o];(!t||c||h)&&e.push(h)}}return e}});import{renderArguments as we,renderList as ze,renderedSolidityHeader as Ys,renderImports as Js}from"@latticexyz/common/codegen";function $e(n){let{imports:t,name:e,functionPrefix:s,functions:i,errors:r}=n;return`
2
2
  ${Ys}
3
3
 
4
4
  ${Js(t)}
@@ -33,7 +33,7 @@ import{a as We,b as Vs,c as Pe,d as p,e as O,f as x,g as it,h as je}from"./chunk
33
33
  */
34
34
  interface ${t} is ${Xs(o)} {
35
35
  }
36
- `}import He from"fs";import Ft from"path";import{formatAndWriteSolidity as qe,contractToInterface as ri}from"@latticexyz/common/codegen";import{isHex as si}from"viem";import{resourceToHex as ii}from"@latticexyz/common";async function Ue({rootDir:n,config:t}){let e=await Ge({rootDir:n,config:t}),s=e.map(h=>h.name),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.name]??{...je,name:h.name},label:h.name,systemId:ii({type:"system",namespace:t.namespace,name:h.name}),namespace:t.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(!si(a)&&!o.includes(a))throw new Error(`Access list item (${a}) for system (${h.label}) had no matching system contract.`);return r}async function Vr({rootDir:n,config:t,clean:e=!0}){let s=Ft.join(t.sourceDirectory,t.codegen.outputDirectory,t.codegen.worldgenDirectory);e&&He.rmSync(s,{recursive:!0,force:!0});let i=await Ue({rootDir:n,config:t}),r=[];for(let a of i){let l=He.readFileSync(a.sourcePath,"utf8"),{functions:c,errors:f,symbolImports:u}=ri(l,a.label),m=u.map(g=>g.path[0]==="."?{symbol:g.symbol,fromPath:Ft.join(Ft.dirname(a.sourcePath),g.path),usedInPath:s}:{symbol:g.symbol,path:g.path}),y=`I${a.label}`,d=$e({name:y,functionPrefix:a.namespace===""?"":`${a.namespace}__`,functions:c,errors:f,imports:m}),w=Ft.join(n,s,y+".sol");await qe(d,w,"Generated system interface"),r.push({symbol:y,fromPath:`${y}.sol`,usedInPath:"./"})}let o=Be({interfaceName:t.codegen.worldInterfaceName,imports:r,storeImportPath:t.codegen.storeImportPath,worldImportPath:t.codegen.worldImportPath}),h=Ft.join(n,s,t.codegen.worldInterfaceName+".sol");await qe(o,h,"Generated world interface")}import qs from"node:path";var ms=Vs(ns(),1);var _t=n=>{if(typeof n!="string")throw new TypeError("invalid pattern");if(n.length>65536)throw new TypeError("pattern is too long")};var ui={"[: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]},Nt=n=>n.replace(/[[\]\\-]/g,"\\$&"),di=n=>n.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),os=n=>n.join(""),hs=(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(ui))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(Nt(f)+"-"+Nt(d)):d===f&&s.push(Nt(d)),f="",r++;continue}if(n.startsWith("-]",r+1)){s.push(Nt(d+"-")),r+=2;continue}if(n.startsWith("-",r+1)){f=d,r+=2;continue}s.push(Nt(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[di(d),!1,c-e,!1]}let u="["+(l?"^":"")+os(s)+"]",m="["+(l?"":"^")+os(i)+"]";return[s.length&&i.length?"("+u+"|"+m+")":s.length?u:m,h,c-e,!0]};var K=(n,{windowsPathsNoEscape:t=!1}={})=>t?n.replace(/\[([^\/\\])\]/g,"$1"):n.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1");var pi=new Set(["!","?","+","*","@"]),as=n=>pi.has(n),mi="(?!(?:^|/)\\.\\.?(?:$|/))",Jt="(?!\\.)",gi=new Set(["[","."]),wi=new Set(["..","."]),yi=new Set("().*{}+?[]^$\\!"),bi=n=>n.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Ee="[^/]",ls=Ee+"*?",cs=Ee+"+?",R,D,tt,C,A,rt,ut,nt,Z,dt,It,Xt,fs,yt,Zt,Lt,Se,Qt,us,j=class{constructor(t,e,s={}){O(this,Xt);O(this,Lt);Pe(this,"type");O(this,R,void 0);O(this,D,void 0);O(this,tt,!1);O(this,C,[]);O(this,A,void 0);O(this,rt,void 0);O(this,ut,void 0);O(this,nt,!1);O(this,Z,void 0);O(this,dt,void 0);O(this,It,!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,Z,p(this,R)===this?s:p(p(this,R),Z)),x(this,ut,p(this,R)===this?[]:p(p(this,R),ut)),t==="!"&&!p(p(this,R),nt)&&p(this,ut).push(this),x(this,rt,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,dt)!==void 0?p(this,dt):this.type?x(this,dt,this.type+"("+p(this,C).map(t=>String(t)).join("|")+")"):x(this,dt,p(this,C).map(t=>String(t)).join(""))}push(...t){for(let e of t)if(e!==""){if(typeof e!="string"&&!(e instanceof j&&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),nt)&&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,rt)===0)return!0;let t=p(this,A);for(let e=0;e<p(this,rt);e++){let s=p(t,C)[e];if(!(s instanceof j&&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,rt)===t-1}copyIn(t){typeof t=="string"?this.push(t):this.push(t.clone(this))}clone(t){let e=new j(this.type,t);for(let s of p(this,C))e.copyIn(s);return e}static fromGlob(t,e={}){var i;let s=new j(null,void 0,e);return it(i=j,yt,Zt).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,Z).nocase&&!p(this,Z).nocaseMagicOnly&&t.toUpperCase()!==t.toLowerCase()))return s;let h=(p(this,Z).nocase?"i":"")+(r?"u":"");return Object.assign(new RegExp(`^${e}$`,h),{_src:e,_glob:t})}get options(){return p(this,Z)}toRegExpSource(t){let e=t??!!p(this,Z).dot;if(p(this,R)===this&&it(this,Xt,fs).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"?it(b=j,Qt,us).call(b,m,p(this,D),a):m.toRegExpSource(t);return x(this,D,p(this,D)||w),x(this,tt,p(this,tt)||g),y}).join(""),c="";if(this.isStart()&&typeof p(this,C)[0]=="string"&&!(p(this,C).length===1&&wi.has(p(this,C)[0]))){let y=gi,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?mi:w?Jt:""}let f="";return this.isEnd()&&p(p(this,R),nt)&&p(this,A)?.type==="!"&&(f="(?:$|\\/)"),[c+l+f,K(l),x(this,D,!!p(this,D)),p(this,tt)]}let s=this.type==="*"||this.type==="+",i=this.type==="!"?"(?:(?!(?:":"(?:",r=it(this,Lt,Se).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,K(this.toString()),!1,!1]}let o=!s||t||e||!Jt?"":it(this,Lt,Se).call(this,!0);o===r&&(o=""),o&&(r=`(?:${r})(?:${o})*?`);let h="";if(this.type==="!"&&p(this,It))h=(this.isStart()&&!e?Jt:"")+cs;else{let a=this.type==="!"?"))"+(this.isStart()&&!e&&!t?Jt:"")+ls+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&o?")":this.type==="*"&&o?")?":`)${this.type}`;h=i+r+a}return[h,K(r),x(this,D,!!p(this,D)),p(this,tt)]}},ot=j;R=new WeakMap,D=new WeakMap,tt=new WeakMap,C=new WeakMap,A=new WeakMap,rt=new WeakMap,ut=new WeakMap,nt=new WeakMap,Z=new WeakMap,dt=new WeakMap,It=new WeakMap,Xt=new WeakSet,fs=function(){if(this!==p(this,R))throw new Error("should only call on root");if(p(this,nt))return this;this.toString(),x(this,nt,!0);let t;for(;t=p(this,ut).pop();){if(t.type!=="!")continue;let e=t,s=p(e,A);for(;s;){for(let i=p(e,rt)+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},yt=new WeakSet,Zt=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&&as(g)&&t.charAt(d)==="("){e.push(w),w="";let b=new j(g,e);d=it(m=j,yt,Zt).call(m,t,b,d,i),e.push(b);continue}w+=g}return e.push(w),d}let l=s+1,c=new j(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(as(d)&&t.charAt(l)==="("){c.push(u),u="";let w=new j(d,c);c.push(w),l=it(y=j,yt,Zt).call(y,t,w,l,i);continue}if(d==="|"){c.push(u),u="",f.push(c),c=new j(null,e);continue}if(d===")")return u===""&&p(e,C).length===0&&x(e,It,!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},Lt=new WeakSet,Se=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,tt,p(this,tt)||o),s}).filter(e=>!(this.isStart()&&this.isEnd())||!!e).join("|")},Qt=new WeakSet,us=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+=(yi.has(a)?"\\":"")+a;continue}if(a==="\\"){h===t.length-1?r+="\\\\":i=!0;continue}if(a==="["){let[l,c,f,u]=hs(t,h);if(f){r+=l,o=o||c,h+=f-1,e=e||u;continue}}if(a==="*"){s&&t==="*"?r+=cs:r+=ls,e=!0;continue}if(a==="?"){r+=Ee,e=!0;continue}r+=bi(a)}return[r,K(t),!!e,o]},O(ot,yt),O(ot,Qt);var bt=(n,{windowsPathsNoEscape:t=!1}={})=>t?n.replace(/[?*()[\]]/g,"[$&]"):n.replace(/[?*()[\]\\]/g,"\\$&");var W=(n,t,e={})=>(_t(t),!e.nocomment&&t.charAt(0)==="#"?!1:new z(t,e).match(n)),Si=/^\*+([^+@!?\*\[\(]*)$/,Ei=n=>t=>!t.startsWith(".")&&t.endsWith(n),vi=n=>t=>t.endsWith(n),xi=n=>(n=n.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(n)),Ci=n=>(n=n.toLowerCase(),t=>t.toLowerCase().endsWith(n)),Ti=/^\*+\.\*+$/,Ai=n=>!n.startsWith(".")&&n.includes("."),Ri=n=>n!=="."&&n!==".."&&n.includes("."),ki=/^\.\*+$/,Oi=n=>n!=="."&&n!==".."&&n.startsWith("."),Di=/^\*+$/,Fi=n=>n.length!==0&&!n.startsWith("."),Mi=n=>n.length!==0&&n!=="."&&n!=="..",_i=/^\?+([^+@!?\*\[\(]*)?$/,Ni=([n,t=""])=>{let e=gs([n]);return t?(t=t.toLowerCase(),s=>e(s)&&s.toLowerCase().endsWith(t)):e},Ii=([n,t=""])=>{let e=ws([n]);return t?(t=t.toLowerCase(),s=>e(s)&&s.toLowerCase().endsWith(t)):e},Li=([n,t=""])=>{let e=ws([n]);return t?s=>e(s)&&s.endsWith(t):e},Wi=([n,t=""])=>{let e=gs([n]);return t?s=>e(s)&&s.endsWith(t):e},gs=([n])=>{let t=n.length;return e=>e.length===t&&!e.startsWith(".")},ws=([n])=>{let t=n.length;return e=>e.length===t&&e!=="."&&e!==".."},ys=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",ds={win32:{sep:"\\"},posix:{sep:"/"}},Pi=ys==="win32"?ds.win32.sep:ds.posix.sep;W.sep=Pi;var N=Symbol("globstar **");W.GLOBSTAR=N;var ji="[^/]",zi=ji+"*?",$i="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",Bi="(?:(?!(?:\\/|^)\\.).)*?",Ui=(n,t={})=>e=>W(e,n,t);W.filter=Ui;var B=(n,t={})=>Object.assign({},n,t),Gi=n=>{if(!n||typeof n!="object"||!Object.keys(n).length)return W;let t=W;return Object.assign((s,i,r={})=>t(s,i,B(n,r)),{Minimatch:class extends t.Minimatch{constructor(i,r={}){super(i,B(n,r))}static defaults(i){return t.defaults(B(n,i)).Minimatch}},AST:class extends t.AST{constructor(i,r,o={}){super(i,r,B(n,o))}static fromGlob(i,r={}){return t.AST.fromGlob(i,B(n,r))}},unescape:(s,i={})=>t.unescape(s,B(n,i)),escape:(s,i={})=>t.escape(s,B(n,i)),filter:(s,i={})=>t.filter(s,B(n,i)),defaults:s=>t.defaults(B(n,s)),makeRe:(s,i={})=>t.makeRe(s,B(n,i)),braceExpand:(s,i={})=>t.braceExpand(s,B(n,i)),match:(s,i,r={})=>t.match(s,i,B(n,r)),sep:t.sep,GLOBSTAR:N})};W.defaults=Gi;var bs=(n,t={})=>(_t(n),t.nobrace||!/\{(?:(?!\{).)*\}/.test(n)?[n]:(0,ms.default)(n));W.braceExpand=bs;var Hi=(n,t={})=>new z(n,t).makeRe();W.makeRe=Hi;var qi=(n,t,e={})=>{let s=new z(t,e);return n=n.filter(i=>s.match(i)),s.options.nonull&&!n.length&&n.push(t),n};W.match=qi;var ps=/[?*]|[+@!]\(.*?\)|\[|\]/,Ki=n=>n.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),z=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;regexp;constructor(t,e={}){_t(t),e=e||{},this.options=e,this.pattern=t,this.platform=e.platform||ys,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]==="?"||!ps.test(r[2]))&&!ps.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===N){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(`
36
+ `}import qs from"fs";import Vt from"path";import{formatAndWriteSolidity as Ks,contractToInterface as Dr}from"@latticexyz/common/codegen";import{isHex as Or}from"viem";import Bs from"node:path";var fs=Vs(es(),1);var Mt=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,"\\$&"),ss=n=>n.join(""),is=(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?"^":"")+ss(s)+"]",m="["+(l?"":"^")+ss(i)+"]";return[s.length&&i.length?"("+u+"|"+m+")":s.length?u:m,h,c-e,!0]};var K=(n,{windowsPathsNoEscape:t=!1}={})=>t?n.replace(/\[([^\/\\])\]/g,"$1"):n.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1");var fi=new Set(["!","?","+","*","@"]),rs=n=>fi.has(n),ui="(?!(?:^|/)\\.\\.?(?:$|/))",Jt="(?!\\.)",di=new Set(["[","."]),pi=new Set(["..","."]),mi=new Set("().*{}+?[]^$\\!"),gi=n=>n.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Ee="[^/]",ns=Ee+"*?",os=Ee+"+?",R,D,tt,C,A,rt,ut,nt,Z,dt,Nt,Xt,hs,yt,Zt,It,Se,Qt,as,j=class{constructor(t,e,s={}){O(this,Xt);O(this,It);Pe(this,"type");O(this,R,void 0);O(this,D,void 0);O(this,tt,!1);O(this,C,[]);O(this,A,void 0);O(this,rt,void 0);O(this,ut,void 0);O(this,nt,!1);O(this,Z,void 0);O(this,dt,void 0);O(this,Nt,!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,Z,p(this,R)===this?s:p(p(this,R),Z)),x(this,ut,p(this,R)===this?[]:p(p(this,R),ut)),t==="!"&&!p(p(this,R),nt)&&p(this,ut).push(this),x(this,rt,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,dt)!==void 0?p(this,dt):this.type?x(this,dt,this.type+"("+p(this,C).map(t=>String(t)).join("|")+")"):x(this,dt,p(this,C).map(t=>String(t)).join(""))}push(...t){for(let e of t)if(e!==""){if(typeof e!="string"&&!(e instanceof j&&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),nt)&&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,rt)===0)return!0;let t=p(this,A);for(let e=0;e<p(this,rt);e++){let s=p(t,C)[e];if(!(s instanceof j&&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,rt)===t-1}copyIn(t){typeof t=="string"?this.push(t):this.push(t.clone(this))}clone(t){let e=new j(this.type,t);for(let s of p(this,C))e.copyIn(s);return e}static fromGlob(t,e={}){var i;let s=new j(null,void 0,e);return it(i=j,yt,Zt).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,Z).nocase&&!p(this,Z).nocaseMagicOnly&&t.toUpperCase()!==t.toLowerCase()))return s;let h=(p(this,Z).nocase?"i":"")+(r?"u":"");return Object.assign(new RegExp(`^${e}$`,h),{_src:e,_glob:t})}get options(){return p(this,Z)}toRegExpSource(t){let e=t??!!p(this,Z).dot;if(p(this,R)===this&&it(this,Xt,hs).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"?it(b=j,Qt,as).call(b,m,p(this,D),a):m.toRegExpSource(t);return x(this,D,p(this,D)||w),x(this,tt,p(this,tt)||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?Jt:""}let f="";return this.isEnd()&&p(p(this,R),nt)&&p(this,A)?.type==="!"&&(f="(?:$|\\/)"),[c+l+f,K(l),x(this,D,!!p(this,D)),p(this,tt)]}let s=this.type==="*"||this.type==="+",i=this.type==="!"?"(?:(?!(?:":"(?:",r=it(this,It,Se).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,K(this.toString()),!1,!1]}let o=!s||t||e||!Jt?"":it(this,It,Se).call(this,!0);o===r&&(o=""),o&&(r=`(?:${r})(?:${o})*?`);let h="";if(this.type==="!"&&p(this,Nt))h=(this.isStart()&&!e?Jt:"")+os;else{let a=this.type==="!"?"))"+(this.isStart()&&!e&&!t?Jt:"")+ns+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&o?")":this.type==="*"&&o?")?":`)${this.type}`;h=i+r+a}return[h,K(r),x(this,D,!!p(this,D)),p(this,tt)]}},ot=j;R=new WeakMap,D=new WeakMap,tt=new WeakMap,C=new WeakMap,A=new WeakMap,rt=new WeakMap,ut=new WeakMap,nt=new WeakMap,Z=new WeakMap,dt=new WeakMap,Nt=new WeakMap,Xt=new WeakSet,hs=function(){if(this!==p(this,R))throw new Error("should only call on root");if(p(this,nt))return this;this.toString(),x(this,nt,!0);let t;for(;t=p(this,ut).pop();){if(t.type!=="!")continue;let e=t,s=p(e,A);for(;s;){for(let i=p(e,rt)+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},yt=new WeakSet,Zt=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&&rs(g)&&t.charAt(d)==="("){e.push(w),w="";let b=new j(g,e);d=it(m=j,yt,Zt).call(m,t,b,d,i),e.push(b);continue}w+=g}return e.push(w),d}let l=s+1,c=new j(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(rs(d)&&t.charAt(l)==="("){c.push(u),u="";let w=new j(d,c);c.push(w),l=it(y=j,yt,Zt).call(y,t,w,l,i);continue}if(d==="|"){c.push(u),u="",f.push(c),c=new j(null,e);continue}if(d===")")return u===""&&p(e,C).length===0&&x(e,Nt,!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,Se=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,tt,p(this,tt)||o),s}).filter(e=>!(this.isStart()&&this.isEnd())||!!e).join("|")},Qt=new WeakSet,as=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]=is(t,h);if(f){r+=l,o=o||c,h+=f-1,e=e||u;continue}}if(a==="*"){s&&t==="*"?r+=os:r+=ns,e=!0;continue}if(a==="?"){r+=Ee,e=!0;continue}r+=gi(a)}return[r,K(t),!!e,o]},O(ot,yt),O(ot,Qt);var bt=(n,{windowsPathsNoEscape:t=!1}={})=>t?n.replace(/[?*()[\]]/g,"[$&]"):n.replace(/[?*()[\]\\]/g,"\\$&");var W=(n,t,e={})=>(Mt(t),!e.nocomment&&t.charAt(0)==="#"?!1:new z(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=us([n]);return t?(t=t.toLowerCase(),s=>e(s)&&s.toLowerCase().endsWith(t)):e},Mi=([n,t=""])=>{let e=ds([n]);return t?(t=t.toLowerCase(),s=>e(s)&&s.toLowerCase().endsWith(t)):e},_i=([n,t=""])=>{let e=ds([n]);return t?s=>e(s)&&s.endsWith(t):e},Ni=([n,t=""])=>{let e=us([n]);return t?s=>e(s)&&s.endsWith(t):e},us=([n])=>{let t=n.length;return e=>e.length===t&&!e.startsWith(".")},ds=([n])=>{let t=n.length;return e=>e.length===t&&e!=="."&&e!==".."},ps=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",ls={win32:{sep:"\\"},posix:{sep:"/"}},Ii=ps==="win32"?ls.win32.sep:ls.posix.sep;W.sep=Ii;var N=Symbol("globstar **");W.GLOBSTAR=N;var Li="[^/]",Wi=Li+"*?",Pi="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",ji="(?:(?!(?:\\/|^)\\.).)*?",zi=(n,t={})=>e=>W(e,n,t);W.filter=zi;var B=(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,B(n,r)),{Minimatch:class extends t.Minimatch{constructor(i,r={}){super(i,B(n,r))}static defaults(i){return t.defaults(B(n,i)).Minimatch}},AST:class extends t.AST{constructor(i,r,o={}){super(i,r,B(n,o))}static fromGlob(i,r={}){return t.AST.fromGlob(i,B(n,r))}},unescape:(s,i={})=>t.unescape(s,B(n,i)),escape:(s,i={})=>t.escape(s,B(n,i)),filter:(s,i={})=>t.filter(s,B(n,i)),defaults:s=>t.defaults(B(n,s)),makeRe:(s,i={})=>t.makeRe(s,B(n,i)),braceExpand:(s,i={})=>t.braceExpand(s,B(n,i)),match:(s,i,r={})=>t.match(s,i,B(n,r)),sep:t.sep,GLOBSTAR:N})};W.defaults=$i;var ms=(n,t={})=>(Mt(n),t.nobrace||!/\{(?:(?!\{).)*\}/.test(n)?[n]:(0,fs.default)(n));W.braceExpand=ms;var Bi=(n,t={})=>new z(n,t).makeRe();W.makeRe=Bi;var Ui=(n,t,e={})=>{let s=new z(t,e);return n=n.filter(i=>s.match(i)),s.options.nonull&&!n.length&&n.push(t),n};W.match=Ui;var cs=/[?*]|[+@!]\(.*?\)|\[|\]/,Gi=n=>n.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),z=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;regexp;constructor(t,e={}){Mt(t),e=e||{},this.options=e,this.pattern=t,this.platform=e.platform||ps,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]==="?"||!cs.test(r[2]))&&!cs.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===N){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(`
37
37
  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(`
38
- >>> 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 bs(this.pattern,this.options)}parse(t){_t(t);let e=this.options;if(t==="**")return N;if(t==="")return"";let s,i=null;(s=t.match(Di))?i=e.dot?Mi:Fi:(s=t.match(Si))?i=(e.nocase?e.dot?Ci:xi:e.dot?vi:Ei)(s[1]):(s=t.match(_i))?i=(e.nocase?e.dot?Ii:Ni:e.dot?Li:Wi)(s):(s=t.match(Ti))?i=e.dot?Ri:Ai:(s=t.match(ki))&&(i=Oi);let r=ot.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?zi:e.dot?$i:Bi,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"?Ki(c):c===N?N:c._src});return l.forEach((c,f)=>{let u=l[f+1],m=l[f-1];c!==N||m===N||(m===void 0?u!==void 0&&u!==N?l[f+1]="(?:\\/|"+s+"\\/)?"+u:l[f]=s:u===void 0?l[f-1]=m+"(?:\\/|"+s+")?":u!==N&&(l[f-1]=m+"(?:\\/|\\/"+s+"\\/)"+u,l[f+1]=N))}),l.filter(c=>c!==N).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=ot;W.Minimatch=z;W.escape=bt;W.unescape=K;import{fileURLToPath as Tr}from"node:url";var St=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,Es=new Set,ve=typeof process=="object"&&process?process:{},vs=(n,t,e,s)=>{typeof ve.emitWarning=="function"?ve.emitWarning(n,t,e,s):console.error(`[${e}] ${t}: ${n}`)},ee=globalThis.AbortController,Ss=globalThis.AbortSignal;if(typeof ee>"u"){Ss=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(s,i){this._onabort.push(i)}},ee=class{constructor(){t()}signal=new Ss;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=ve.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",t=()=>{n&&(n=!1,vs("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 Vi=n=>!Es.has(n),Cn=Symbol("type"),ht=n=>n&&n===Math.floor(n)&&n>0&&isFinite(n),xs=n=>ht(n)?n<=Math.pow(2,8)?Uint8Array:n<=Math.pow(2,16)?Uint16Array:n<=Math.pow(2,32)?Uint32Array:n<=Number.MAX_SAFE_INTEGER?vt:null:null,vt=class extends Array{constructor(t){super(t),this.fill(0)}},xt,Et=class{heap;length;static create(t){let e=xs(t);if(!e)return[];x(Et,xt,!0);let s=new Et(t,e);return x(Et,xt,!1),s}constructor(t,e){if(!p(Et,xt))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]}},te=Et;xt=new WeakMap,O(te,xt,!1);var pt=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&&!ht(e))throw new TypeError("max option must be a nonnegative integer");let H=e?xs(e):Array;if(!H)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 H(e),this.#b=new H(e),this.#g=0,this.#u=0,this.#v=te.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&&!ht(this.#i))throw new TypeError("maxSize must be a positive integer if specified");if(!ht(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=ht(i)||i===0?i:1,this.ttlAutopurge=!!r,this.ttl=s||0,this.ttl){if(!ht(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 ft="LRU_CACHE_UNBOUNDED";Vi(ft)&&(Es.add(ft),vs("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",ft,pt))}}getRemainingTTL(t){return this.#a.has(t)?1/0:0}#O(){let t=new vt(this.#e),e=new vt(this.#e);this.#w=t,this.#C=e,this.#M=(r,o,h=St.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?St.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=St.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 vt(this.#e);this.#p=0,this.#x=t,this.#_=e=>{this.#p-=t[e],t[e]=0},this.#I=(e,s,i,r)=>{if(this.#o(s))return 0;if(!ht(i))if(r){if(typeof r!="function")throw new TypeError("sizeCalculation must be a function");if(i=r(s,e),!ht(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.#N=(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)}}#_=t=>{};#N=(t,e,s)=>{};#I=(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.#L(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.#L(e)||((t||!this.#m(e))&&(yield e),e===this.#u));)e=this.#y[e]}#L(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-(St.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=St.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=St.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.#I(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.#N(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.#_(f),this.#N(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.#_(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 ee,{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 ee}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 Yt=s&&v.__staleWhileFetching!==void 0;return g&&(g.fetch="inflight",Yt&&(g.returnedStale=!0)),Yt?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 H=this.#P(t,S,E,d),q=H.__staleWhileFetching!==void 0&&s;return g&&(g.fetch=k?"stale":"refresh",q&&k&&(g.returnedStale=!0)),q?H.__staleWhileFetching:H.__returned=H}}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.#_(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 nr,win32 as Me}from"node:path";import{fileURLToPath as or}from"node:url";import{lstatSync as hr,readdir as ar,readdirSync as lr,readlinkSync as cr,realpathSync as fr}from"fs";import*as ur from"node:fs";import{lstat as pr,readdir as mr,readlink as gr,realpath as wr}from"node:fs/promises";import{EventEmitter as Oe}from"node:events";import ks from"node:stream";import{StringDecoder as Yi}from"node:string_decoder";var Cs=typeof process=="object"&&process?process:{stdout:null,stderr:null},Ji=n=>!!n&&typeof n=="object"&&(n instanceof lt||n instanceof ks||Zi(n)||Xi(n)),Zi=n=>!!n&&typeof n=="object"&&n instanceof Oe&&typeof n.pipe=="function"&&n.pipe!==ks.Writable.prototype.pipe,Xi=n=>!!n&&typeof n=="object"&&n instanceof Oe&&typeof n.write=="function"&&typeof n.end=="function",et=Symbol("EOF"),st=Symbol("maybeEmitEnd"),at=Symbol("emittedEnd"),se=Symbol("emittingEnd"),Wt=Symbol("emittedError"),ie=Symbol("closed"),Ts=Symbol("read"),re=Symbol("flush"),As=Symbol("flushChunk"),V=Symbol("encoding"),Ct=Symbol("decoder"),F=Symbol("flowing"),Pt=Symbol("paused"),Tt=Symbol("resume"),M=Symbol("buffer"),P=Symbol("pipes"),_=Symbol("bufferLength"),xe=Symbol("bufferPush"),ne=Symbol("bufferShift"),I=Symbol("objectMode"),T=Symbol("destroyed"),Ce=Symbol("error"),Te=Symbol("emitData"),Rs=Symbol("emitEnd"),Ae=Symbol("emitEnd2"),X=Symbol("async"),Re=Symbol("abort"),oe=Symbol("aborted"),jt=Symbol("signal"),mt=Symbol("dataListeners"),$=Symbol("discarded"),zt=n=>Promise.resolve().then(n),Qi=n=>n(),tr=n=>n==="end"||n==="finish"||n==="prefinish",er=n=>n instanceof ArrayBuffer||!!n&&typeof n=="object"&&n.constructor&&n.constructor.name==="ArrayBuffer"&&n.byteLength>=0,sr=n=>!Buffer.isBuffer(n)&&ArrayBuffer.isView(n),he=class{src;dest;opts;ondrain;constructor(t,e,s){this.src=t,this.dest=e,this.opts=s,this.ondrain=()=>t[Tt](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(t){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},ke=class extends he{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)}},ir=n=>!!n.objectMode,rr=n=>!n.objectMode&&!!n.encoding&&n.encoding!=="buffer",lt=class extends Oe{[F]=!1;[Pt]=!1;[P]=[];[M]=[];[I];[V];[X];[Ct];[et]=!1;[at]=!1;[se]=!1;[ie]=!1;[Wt]=null;[_]=0;[T]=!1;[jt];[oe]=!1;[mt]=0;[$]=!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");ir(e)?(this[I]=!0,this[V]=null):rr(e)?(this[V]=e.encoding,this[I]=!1):(this[I]=!1,this[V]=null),this[X]=!!e.async,this[Ct]=this[V]?new Yi(this[V]):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[Re]():s.addEventListener("abort",()=>this[Re]()))}get bufferLength(){return this[_]}get encoding(){return this[V]}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[I]}set objectMode(t){throw new Error("objectMode must be set at instantiation time")}get async(){return this[X]}set async(t){this[X]=this[X]||!!t}[Re](){this[oe]=!0,this.emit("abort",this[jt]?.reason),this.destroy(this[jt]?.reason)}get aborted(){return this[oe]}set aborted(t){}write(t,e,s){if(this[oe])return!1;if(this[et])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[X]?zt:Qi;if(!this[I]&&!Buffer.isBuffer(t)){if(sr(t))t=Buffer.from(t.buffer,t.byteOffset,t.byteLength);else if(er(t))t=Buffer.from(t);else if(typeof t!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[I]?(this[F]&&this[_]!==0&&this[re](!0),this[F]?this.emit("data",t):this[xe](t),this[_]!==0&&this.emit("readable"),s&&i(s),this[F]):t.length?(typeof t=="string"&&!(e===this[V]&&!this[Ct]?.lastNeed)&&(t=Buffer.from(t,e)),Buffer.isBuffer(t)&&this[V]&&(t=this[Ct].write(t)),this[F]&&this[_]!==0&&this[re](!0),this[F]?this.emit("data",t):this[xe](t),this[_]!==0&&this.emit("readable"),s&&i(s),this[F]):(this[_]!==0&&this.emit("readable"),s&&i(s),this[F])}read(t){if(this[T])return null;if(this[$]=!1,this[_]===0||t===0||t&&t>this[_])return this[st](),null;this[I]&&(t=null),this[M].length>1&&!this[I]&&(this[M]=[this[V]?this[M].join(""):Buffer.concat(this[M],this[_])]);let e=this[Ts](t||null,this[M][0]);return this[st](),e}[Ts](t,e){if(this[I])this[ne]();else{let s=e;t===s.length||t===null?this[ne]():typeof s=="string"?(this[M][0]=s.slice(t),e=s.slice(0,t),this[_]-=t):(this[M][0]=s.subarray(t),e=s.subarray(0,t),this[_]-=t)}return this.emit("data",e),!this[M].length&&!this[et]&&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[et]=!0,this.writable=!1,(this[F]||!this[Pt])&&this[st](),this}[Tt](){this[T]||(!this[mt]&&!this[P].length&&(this[$]=!0),this[Pt]=!1,this[F]=!0,this.emit("resume"),this[M].length?this[re]():this[et]?this[st]():this.emit("drain"))}resume(){return this[Tt]()}pause(){this[F]=!1,this[Pt]=!0,this[$]=!1}get destroyed(){return this[T]}get flowing(){return this[F]}get paused(){return this[Pt]}[xe](t){this[I]?this[_]+=1:this[_]+=t.length,this[M].push(t)}[ne](){return this[I]?this[_]-=1:this[_]-=this[M][0].length,this[M].shift()}[re](t=!1){do;while(this[As](this[ne]())&&this[M].length);!t&&!this[M].length&&!this[et]&&this.emit("drain")}[As](t){return this.emit("data",t),this[F]}pipe(t,e){if(this[T])return t;this[$]=!1;let s=this[at];return e=e||{},t===Cs.stdout||t===Cs.stderr?e.end=!1:e.end=e.end!==!1,e.proxyErrors=!!e.proxyErrors,s?e.end&&t.end():(this[P].push(e.proxyErrors?new ke(this,t,e):new he(this,t,e)),this[X]?zt(()=>this[Tt]()):this[Tt]()),t}unpipe(t){let e=this[P].find(s=>s.dest===t);e&&(this[P].length===1?(this[F]&&this[mt]===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[$]=!1,this[mt]++,!this[P].length&&!this[F]&&this[Tt]();else if(t==="readable"&&this[_]!==0)super.emit("readable");else if(tr(t)&&this[at])super.emit(t),this.removeAllListeners(t);else if(t==="error"&&this[Wt]){let i=e;this[X]?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[mt]=this.listeners("data").length,this[mt]===0&&!this[$]&&!this[P].length&&(this[F]=!1)),s}removeAllListeners(t){let e=super.removeAllListeners(t);return(t==="data"||t===void 0)&&(this[mt]=0,!this[$]&&!this[P].length&&(this[F]=!1)),e}get emittedEnd(){return this[at]}[st](){!this[se]&&!this[at]&&!this[T]&&this[M].length===0&&this[et]&&(this[se]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[ie]&&this.emit("close"),this[se]=!1)}emit(t,...e){let s=e[0];if(t!=="error"&&t!=="close"&&t!==T&&this[T])return!1;if(t==="data")return!this[I]&&!s?!1:this[X]?(zt(()=>this[Te](s)),!0):this[Te](s);if(t==="end")return this[Rs]();if(t==="close"){if(this[ie]=!0,!this[at]&&!this[T])return!1;let r=super.emit("close");return this.removeAllListeners("close"),r}else if(t==="error"){this[Wt]=s,super.emit(Ce,s);let r=!this[jt]||this.listeners("error").length?super.emit("error",s):!1;return this[st](),r}else if(t==="resume"){let r=super.emit("resume");return this[st](),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[st](),i}[Te](t){for(let s of this[P])s.dest.write(t)===!1&&this.pause();let e=this[$]?!1:super.emit("data",t);return this[st](),e}[Rs](){return this[at]?!1:(this[at]=!0,this.readable=!1,this[X]?(zt(()=>this[Ae]()),!0):this[Ae]())}[Ae](){if(this[Ct]){let e=this[Ct].end();if(e){for(let s of this[P])s.dest.write(e);this[$]||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[I]||(t.dataLength=0);let e=this.promise();return this.on("data",s=>{t.push(s),this[I]||(t.dataLength+=s.length)}),await e,t}async concat(){if(this[I])throw new Error("cannot concat in objectMode");let t=await this.collect();return this[V]?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[$]=!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[et])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[et]})},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[$]=!1;let t=!1,e=()=>(this.pause(),this.off(Ce,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(Ce,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[$]=!0,this[M].length=0,this[_]=0;let e=this;return typeof e.close=="function"&&!this[ie]&&e.close(),t?this.emit("error",t):this.emit(T),this}static get isStream(){return Ji}};var dr=fr.native,Bt={lstatSync:hr,readdir:ar,readdirSync:lr,readlinkSync:cr,realpathSync:dr,promises:{lstat:pr,readdir:mr,readlink:gr,realpath:wr}},_s=n=>!n||n===Bt||n===ur?Bt:{...Bt,...n,promises:{...Bt.promises,...n.promises||{}}},Ns=/^\\\\\?\\([a-z]:)\\?$/i,yr=n=>n.replace(/\//g,"\\").replace(Ns,"$1\\"),br=/[\\\/]/,G=0,Is=1,Ls=2,Q=4,Ws=6,Ps=8,gt=10,js=12,U=15,$t=~U,De=16,Os=32,Ut=64,Y=128,ae=256,ce=512,Ds=Ut|Y|ce,Sr=1023,Fe=n=>n.isFile()?Ps:n.isDirectory()?Q:n.isSymbolicLink()?gt:n.isCharacterDevice()?Ls:n.isBlockDevice()?Ws:n.isSocket()?js:n.isFIFO()?Is:G,Fs=new Map,Gt=n=>{let t=Fs.get(n);if(t)return t;let e=n.normalize("NFKD");return Fs.set(n,e),e},Ms=new Map,le=n=>{let t=Ms.get(n);if(t)return t;let e=Gt(n.toLowerCase());return Ms.set(n,e),e},fe=class extends pt{constructor(){super({max:256})}},_e=class extends pt{constructor(t=16*1024){super({maxSize:t,sizeCalculation:e=>e.length+1})}},zs=Symbol("PathScurry setAsCwd"),L=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=G,s,i,r,o,h){this.name=t,this.#w=r?le(t):Gt(t),this.#t=e&Sr,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=_s(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).#_(i):this.#_(i)}#_(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&=~De,e}child(t,e){if(t===""||t===".")return this;if(t==="..")return this.parent||this;let s=this.children(),i=this.nocase?le(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,G,{...e,parent:this,fullpath:o});return this.canReaddir()||(h.#t|=Y),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&U)===G}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&U)===Ps}isDirectory(){return(this.#t&U)===Q}isCharacterDevice(){return(this.#t&U)===Ls}isBlockDevice(){return(this.#t&U)===Ws}isFIFO(){return(this.#t&U)===Is}isSocket(){return(this.#t&U)===js}isSymbolicLink(){return(this.#t&gt)===gt}lstatCached(){return this.#t&Os?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&U;return!(t!==G&&t!==gt||this.#t&ae||this.#t&Y)}calledReaddir(){return!!(this.#t&De)}isENOENT(){return!!(this.#t&Y)}isNamed(t){return this.nocase?this.#w===le(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}}#N(t){this.#t|=De;for(let e=t.provisional;e<t.length;e++){let s=t[e];s&&s.#I()}}#I(){this.#t&Y||(this.#t=(this.#t|Y)&$t,this.#A())}#A(){let t=this.children();t.provisional=0;for(let e of t)e.#I()}#R(){this.#t|=ce,this.#L()}#L(){if(this.#t&Ut)return;let t=this.#t;(t&U)===Q&&(t&=$t),this.#t=t|Ut,this.#A()}#W(t=""){t==="ENOTDIR"||t==="EPERM"?this.#L():t==="ENOENT"?this.#I():this.children().provisional=0}#P(t=""){t==="ENOTDIR"?this.parent.#L():t==="ENOENT"&&this.#I()}#o(t=""){let e=this.#t;e|=ae,t==="ENOENT"&&(e|=Y),(t==="EINVAL"||t==="UNKNOWN")&&(e&=$t),this.#t=e,t==="ENOTDIR"&&this.parent&&this.parent.#L()}#j(t,e){return this.#F(t,e)||this.#z(t,e)}#z(t,e){let s=Fe(t),i=this.newChild(t.name,s,{parent:this}),r=i.#t&U;return r!==Q&&r!==gt&&r!==G&&(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?le(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|Fe(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&Y))try{return this.#H(await this.#e.promises.lstat(this.fullpath())),this}catch(t){this.#P(t.code)}}lstatSync(){if(!(this.#t&Y))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=Fe(t);this.#t=this.#t&$t|S|Os,S!==G&&S!==Q&&S!==gt&&(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.#N(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.#N(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.#N(t)}catch(s){this.#W(s.code),t.provisional=0}return t.slice(0,t.provisional)}canReaddir(){if(this.#t&Ds)return!1;let t=U&this.#t;return t===G||t===Q||t===gt}shouldWalk(t,e){return(this.#t&Q)===Q&&!(this.#t&Ds)&&!t.has(this)&&(!e||e(this))}async realpath(){if(this.#D)return this.#D;if(!((ce|ae|Y)&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(!((ce|ae|Y)&this.#t))try{let t=this.#e.realpathSync(this.fullpath());return this.#D=this.resolve(t)}catch{this.#R()}}[zs](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}},At=class extends L{sep="\\";splitSep=br;constructor(t,e=G,s,i,r,o,h){super(t,e,s,i,r,o,h)}newChild(t,e=G,s={}){return new At(t,e,this.root,this.roots,this.nocase,this.childrenCache(),s)}getRootString(t){return Me.parse(t).root}getRoot(t){if(t=yr(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 kt(t,this).root}sameRoot(t,e=this.root.name){return t=t.toUpperCase().replace(/\//g,"\\").replace(Ns,"$1\\"),t===e}},Rt=class extends L{splitSep="/";sep="/";constructor(t,e=G,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=G,s={}){return new Rt(t,e,this.root,this.roots,this.nocase,this.childrenCache(),s)}},ue=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=_s(o),(t instanceof URL||t.startsWith("file://"))&&(t=or(t));let h=e.resolve(t);this.roots=Object.create(null),this.rootPath=this.parseRootPath(h),this.#e=new fe,this.#i=new fe,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 L||(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 L||(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 L||(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 L||(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 L||(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 L||(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 L||(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 L||(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 L||(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 L||(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 L||(e=t,t=this.cwd);let{withFileTypes:s=!0,follow:i=!1,filter:r,walkFilter:o}=e,h=new lt({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 L||(e=t,t=this.cwd);let{withFileTypes:s=!0,follow:i=!1,filter:r,walkFilter:o}=e,h=new lt({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[zs](e)}},kt=class extends ue{sep="\\";constructor(t=process.cwd(),e={}){let{nocase:s=!0}=e;super(t,Me,"\\",{...e,nocase:s}),this.nocase=s;for(let i=this.cwd;i;i=i.parent)i.nocase=this.nocase}parseRootPath(t){return Me.parse(t).root.toUpperCase()}newRoot(t){return new At(this.rootPath,Q,void 0,this.roots,this.nocase,this.childrenCache(),{fs:t})}isAbsolute(t){return t.startsWith("/")||t.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(t)}},Ot=class extends ue{sep="/";constructor(t=process.cwd(),e={}){let{nocase:s=!1}=e;super(t,nr,"/",{...e,nocase:s}),this.nocase=s}parseRootPath(t){return"/"}newRoot(t){return new Rt(this.rootPath,Q,void 0,this.roots,this.nocase,this.childrenCache(),{fs:t})}isAbsolute(t){return t.startsWith("/")}},Ht=class extends Ot{constructor(t=process.cwd(),e={}){let{nocase:s=!0}=e;super(t,{...e,nocase:s})}},Wn=process.platform==="win32"?At:Rt,$s=process.platform==="win32"?kt:process.platform==="darwin"?Ht:Ot;var Er=n=>n.length>=1,vr=n=>n.length>=1,ct=class{#e;#i;#r;length;#h;#f;#k;#l;#p;#a;#n=!0;constructor(t,e,s,i){if(!Er(t))throw new TypeError("empty pattern list");if(!vr(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]===N}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 ct(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 xr=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",Dt=class{relative;relativeChildren;absolute;absoluteChildren;platform;mmopts;constructor(t,{nobrace:e,nocase:s,noext:i,noglobstar:r,platform:o=xr}){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 z(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 ct(i,r,0,this.platform),h=new z(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()]))}},Ne=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())}},wt=class{hasWalkedCache;matches=new Ne;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===N){(!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 wt(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===N?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 Cr=(n,t)=>typeof n=="string"?new Dt([n],t):Array.isArray(n)?new Dt(n,t):n,de=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=Cr(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 wt(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 wt(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 de{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 de{results;constructor(t,e,s){super(t,e,s),this.results=new lt({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 Ar=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",J=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=Tr(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||Ar,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"?kt:e.platform==="darwin"?Ht:e.platform?Ot:$s;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 z(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 ct(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 Le=(n,t={})=>{Array.isArray(n)||(n=[n]);for(let e of n)if(new z(e,t).hasMagic())return!0;return!1};function me(n,t={}){return new J(n,t).streamSync()}function Us(n,t={}){return new J(n,t).stream()}function Gs(n,t={}){return new J(n,t).walkSync()}async function Bs(n,t={}){return new J(n,t).walk()}function ge(n,t={}){return new J(n,t).iterateSync()}function Hs(n,t={}){return new J(n,t).iterate()}var Rr=me,kr=Object.assign(Us,{sync:me}),Or=ge,Dr=Object.assign(Hs,{sync:ge}),Fr=Object.assign(Gs,{stream:me,iterate:ge}),pe=Object.assign(Bs,{glob:Bs,globSync:Gs,sync:Fr,globStream:Us,stream:kr,globStreamSync:me,streamSync:Rr,globIterate:Hs,iterate:Dr,globIterateSync:ge,iterateSync:Or,Glob:J,hasMagic:Le,escape:bt,unescape:K});pe.glob=pe;async function Ks({rootDir:n,config:t}){return(await pe(qs.join(t.sourceDirectory,"**","*.sol"),{cwd:n})).sort().map(s=>({filename:s,basename:qs.basename(s,".sol")}))}async function Ge({rootDir:n,config:t}){return(await Ks({rootDir:n,config:t})).map(s=>({sourcePath:s.filename,name:s.basename})).filter(s=>s.name.endsWith("System")&&s.name!=="System"&&!/^I[A-Z]/.test(s.name))}export{Ks as findSolidityFiles,Ge as getSystemContracts,$e as renderSystemInterface,Be as renderWorldInterface,Ue as resolveSystems,Vr as worldgen};
38
+ >>> 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 ms(this.pattern,this.options)}parse(t){Mt(t);let e=this.options;if(t==="**")return N;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?_i:Ni)(s):(s=t.match(vi))?i=e.dot?Ci:xi:(s=t.match(Ti))&&(i=Ai);let r=ot.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===N?N:c._src});return l.forEach((c,f)=>{let u=l[f+1],m=l[f-1];c!==N||m===N||(m===void 0?u!==void 0&&u!==N?l[f+1]="(?:\\/|"+s+"\\/)?"+u:l[f]=s:u===void 0?l[f-1]=m+"(?:\\/|"+s+")?":u!==N&&(l[f-1]=m+"(?:\\/|\\/"+s+"\\/)"+u,l[f+1]=N))}),l.filter(c=>c!==N).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=ot;W.Minimatch=z;W.escape=bt;W.unescape=K;import{fileURLToPath as vr}from"node:url";var St=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,ws=new Set,ve=typeof process=="object"&&process?process:{},ys=(n,t,e,s)=>{typeof ve.emitWarning=="function"?ve.emitWarning(n,t,e,s):console.error(`[${e}] ${t}: ${n}`)},ee=globalThis.AbortController,gs=globalThis.AbortSignal;if(typeof ee>"u"){gs=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(s,i){this._onabort.push(i)}},ee=class{constructor(){t()}signal=new gs;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=ve.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",t=()=>{n&&(n=!1,ys("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=>!ws.has(n),rn=Symbol("type"),ht=n=>n&&n===Math.floor(n)&&n>0&&isFinite(n),bs=n=>ht(n)?n<=Math.pow(2,8)?Uint8Array:n<=Math.pow(2,16)?Uint16Array:n<=Math.pow(2,32)?Uint32Array:n<=Number.MAX_SAFE_INTEGER?vt:null:null,vt=class extends Array{constructor(t){super(t),this.fill(0)}},xt,Et=class{heap;length;static create(t){let e=bs(t);if(!e)return[];x(Et,xt,!0);let s=new Et(t,e);return x(Et,xt,!1),s}constructor(t,e){if(!p(Et,xt))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]}},te=Et;xt=new WeakMap,O(te,xt,!1);var pt=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&&!ht(e))throw new TypeError("max option must be a nonnegative integer");let H=e?bs(e):Array;if(!H)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 H(e),this.#b=new H(e),this.#g=0,this.#u=0,this.#v=te.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&&!ht(this.#i))throw new TypeError("maxSize must be a positive integer if specified");if(!ht(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=ht(i)||i===0?i:1,this.ttlAutopurge=!!r,this.ttl=s||0,this.ttl){if(!ht(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 ft="LRU_CACHE_UNBOUNDED";Hi(ft)&&(ws.add(ft),ys("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",ft,pt))}}getRemainingTTL(t){return this.#a.has(t)?1/0:0}#O(){let t=new vt(this.#e),e=new vt(this.#e);this.#w=t,this.#C=e,this.#M=(r,o,h=St.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?St.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=St.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 vt(this.#e);this.#p=0,this.#x=t,this.#_=e=>{this.#p-=t[e],t[e]=0},this.#I=(e,s,i,r)=>{if(this.#o(s))return 0;if(!ht(i))if(r){if(typeof r!="function")throw new TypeError("sizeCalculation must be a function");if(i=r(s,e),!ht(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.#N=(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)}}#_=t=>{};#N=(t,e,s)=>{};#I=(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.#L(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.#L(e)||((t||!this.#m(e))&&(yield e),e===this.#u));)e=this.#y[e]}#L(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-(St.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=St.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=St.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.#I(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.#N(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.#_(f),this.#N(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.#_(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 ee,{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 ee}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 Yt=s&&v.__staleWhileFetching!==void 0;return g&&(g.fetch="inflight",Yt&&(g.returnedStale=!0)),Yt?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 H=this.#P(t,S,E,d),q=H.__staleWhileFetching!==void 0&&s;return g&&(g.fetch=k?"stale":"refresh",q&&k&&(g.returnedStale=!0)),q?H.__staleWhileFetching:H.__returned=H}}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.#_(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 Me}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 Oe}from"node:events";import Cs from"node:stream";import{StringDecoder as qi}from"node:string_decoder";var Ss=typeof process=="object"&&process?process:{stdout:null,stderr:null},Ki=n=>!!n&&typeof n=="object"&&(n instanceof lt||n instanceof Cs||Vi(n)||Yi(n)),Vi=n=>!!n&&typeof n=="object"&&n instanceof Oe&&typeof n.pipe=="function"&&n.pipe!==Cs.Writable.prototype.pipe,Yi=n=>!!n&&typeof n=="object"&&n instanceof Oe&&typeof n.write=="function"&&typeof n.end=="function",et=Symbol("EOF"),st=Symbol("maybeEmitEnd"),at=Symbol("emittedEnd"),se=Symbol("emittingEnd"),Lt=Symbol("emittedError"),ie=Symbol("closed"),Es=Symbol("read"),re=Symbol("flush"),vs=Symbol("flushChunk"),V=Symbol("encoding"),Ct=Symbol("decoder"),F=Symbol("flowing"),Wt=Symbol("paused"),Tt=Symbol("resume"),M=Symbol("buffer"),P=Symbol("pipes"),_=Symbol("bufferLength"),xe=Symbol("bufferPush"),ne=Symbol("bufferShift"),I=Symbol("objectMode"),T=Symbol("destroyed"),Ce=Symbol("error"),Te=Symbol("emitData"),xs=Symbol("emitEnd"),Ae=Symbol("emitEnd2"),X=Symbol("async"),Re=Symbol("abort"),oe=Symbol("aborted"),Pt=Symbol("signal"),mt=Symbol("dataListeners"),$=Symbol("discarded"),jt=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),he=class{src;dest;opts;ondrain;constructor(t,e,s){this.src=t,this.dest=e,this.opts=s,this.ondrain=()=>t[Tt](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(t){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},ke=class extends he{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",lt=class extends Oe{[F]=!1;[Wt]=!1;[P]=[];[M]=[];[I];[V];[X];[Ct];[et]=!1;[at]=!1;[se]=!1;[ie]=!1;[Lt]=null;[_]=0;[T]=!1;[Pt];[oe]=!1;[mt]=0;[$]=!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[I]=!0,this[V]=null):er(e)?(this[V]=e.encoding,this[I]=!1):(this[I]=!1,this[V]=null),this[X]=!!e.async,this[Ct]=this[V]?new qi(this[V]):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[Pt]=s,s.aborted?this[Re]():s.addEventListener("abort",()=>this[Re]()))}get bufferLength(){return this[_]}get encoding(){return this[V]}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[I]}set objectMode(t){throw new Error("objectMode must be set at instantiation time")}get async(){return this[X]}set async(t){this[X]=this[X]||!!t}[Re](){this[oe]=!0,this.emit("abort",this[Pt]?.reason),this.destroy(this[Pt]?.reason)}get aborted(){return this[oe]}set aborted(t){}write(t,e,s){if(this[oe])return!1;if(this[et])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[X]?jt:Ji;if(!this[I]&&!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[I]?(this[F]&&this[_]!==0&&this[re](!0),this[F]?this.emit("data",t):this[xe](t),this[_]!==0&&this.emit("readable"),s&&i(s),this[F]):t.length?(typeof t=="string"&&!(e===this[V]&&!this[Ct]?.lastNeed)&&(t=Buffer.from(t,e)),Buffer.isBuffer(t)&&this[V]&&(t=this[Ct].write(t)),this[F]&&this[_]!==0&&this[re](!0),this[F]?this.emit("data",t):this[xe](t),this[_]!==0&&this.emit("readable"),s&&i(s),this[F]):(this[_]!==0&&this.emit("readable"),s&&i(s),this[F])}read(t){if(this[T])return null;if(this[$]=!1,this[_]===0||t===0||t&&t>this[_])return this[st](),null;this[I]&&(t=null),this[M].length>1&&!this[I]&&(this[M]=[this[V]?this[M].join(""):Buffer.concat(this[M],this[_])]);let e=this[Es](t||null,this[M][0]);return this[st](),e}[Es](t,e){if(this[I])this[ne]();else{let s=e;t===s.length||t===null?this[ne]():typeof s=="string"?(this[M][0]=s.slice(t),e=s.slice(0,t),this[_]-=t):(this[M][0]=s.subarray(t),e=s.subarray(0,t),this[_]-=t)}return this.emit("data",e),!this[M].length&&!this[et]&&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[et]=!0,this.writable=!1,(this[F]||!this[Wt])&&this[st](),this}[Tt](){this[T]||(!this[mt]&&!this[P].length&&(this[$]=!0),this[Wt]=!1,this[F]=!0,this.emit("resume"),this[M].length?this[re]():this[et]?this[st]():this.emit("drain"))}resume(){return this[Tt]()}pause(){this[F]=!1,this[Wt]=!0,this[$]=!1}get destroyed(){return this[T]}get flowing(){return this[F]}get paused(){return this[Wt]}[xe](t){this[I]?this[_]+=1:this[_]+=t.length,this[M].push(t)}[ne](){return this[I]?this[_]-=1:this[_]-=this[M][0].length,this[M].shift()}[re](t=!1){do;while(this[vs](this[ne]())&&this[M].length);!t&&!this[M].length&&!this[et]&&this.emit("drain")}[vs](t){return this.emit("data",t),this[F]}pipe(t,e){if(this[T])return t;this[$]=!1;let s=this[at];return e=e||{},t===Ss.stdout||t===Ss.stderr?e.end=!1:e.end=e.end!==!1,e.proxyErrors=!!e.proxyErrors,s?e.end&&t.end():(this[P].push(e.proxyErrors?new ke(this,t,e):new he(this,t,e)),this[X]?jt(()=>this[Tt]()):this[Tt]()),t}unpipe(t){let e=this[P].find(s=>s.dest===t);e&&(this[P].length===1?(this[F]&&this[mt]===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[$]=!1,this[mt]++,!this[P].length&&!this[F]&&this[Tt]();else if(t==="readable"&&this[_]!==0)super.emit("readable");else if(Zi(t)&&this[at])super.emit(t),this.removeAllListeners(t);else if(t==="error"&&this[Lt]){let i=e;this[X]?jt(()=>i.call(this,this[Lt])):i.call(this,this[Lt])}return s}removeListener(t,e){return this.off(t,e)}off(t,e){let s=super.off(t,e);return t==="data"&&(this[mt]=this.listeners("data").length,this[mt]===0&&!this[$]&&!this[P].length&&(this[F]=!1)),s}removeAllListeners(t){let e=super.removeAllListeners(t);return(t==="data"||t===void 0)&&(this[mt]=0,!this[$]&&!this[P].length&&(this[F]=!1)),e}get emittedEnd(){return this[at]}[st](){!this[se]&&!this[at]&&!this[T]&&this[M].length===0&&this[et]&&(this[se]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[ie]&&this.emit("close"),this[se]=!1)}emit(t,...e){let s=e[0];if(t!=="error"&&t!=="close"&&t!==T&&this[T])return!1;if(t==="data")return!this[I]&&!s?!1:this[X]?(jt(()=>this[Te](s)),!0):this[Te](s);if(t==="end")return this[xs]();if(t==="close"){if(this[ie]=!0,!this[at]&&!this[T])return!1;let r=super.emit("close");return this.removeAllListeners("close"),r}else if(t==="error"){this[Lt]=s,super.emit(Ce,s);let r=!this[Pt]||this.listeners("error").length?super.emit("error",s):!1;return this[st](),r}else if(t==="resume"){let r=super.emit("resume");return this[st](),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[st](),i}[Te](t){for(let s of this[P])s.dest.write(t)===!1&&this.pause();let e=this[$]?!1:super.emit("data",t);return this[st](),e}[xs](){return this[at]?!1:(this[at]=!0,this.readable=!1,this[X]?(jt(()=>this[Ae]()),!0):this[Ae]())}[Ae](){if(this[Ct]){let e=this[Ct].end();if(e){for(let s of this[P])s.dest.write(e);this[$]||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[I]||(t.dataLength=0);let e=this.promise();return this.on("data",s=>{t.push(s),this[I]||(t.dataLength+=s.length)}),await e,t}async concat(){if(this[I])throw new Error("cannot concat in objectMode");let t=await this.collect();return this[V]?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[$]=!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[et])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[et]})},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[$]=!1;let t=!1,e=()=>(this.pause(),this.off(Ce,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(Ce,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[$]=!0,this[M].length=0,this[_]=0;let e=this;return typeof e.close=="function"&&!this[ie]&&e.close(),t?this.emit("error",t):this.emit(T),this}static get isStream(){return Ki}};var cr=ar.native,$t={lstatSync:rr,readdir:nr,readdirSync:or,readlinkSync:hr,realpathSync:cr,promises:{lstat:fr,readdir:ur,readlink:dr,realpath:pr}},Os=n=>!n||n===$t||n===lr?$t:{...$t,...n,promises:{...$t.promises,...n.promises||{}}},Ds=/^\\\\\?\\([a-z]:)\\?$/i,mr=n=>n.replace(/\//g,"\\").replace(Ds,"$1\\"),gr=/[\\\/]/,G=0,Fs=1,Ms=2,Q=4,_s=6,Ns=8,gt=10,Is=12,U=15,zt=~U,De=16,Ts=32,Bt=64,Y=128,ae=256,ce=512,As=Bt|Y|ce,wr=1023,Fe=n=>n.isFile()?Ns:n.isDirectory()?Q:n.isSymbolicLink()?gt:n.isCharacterDevice()?Ms:n.isBlockDevice()?_s:n.isSocket()?Is:n.isFIFO()?Fs:G,Rs=new Map,Ut=n=>{let t=Rs.get(n);if(t)return t;let e=n.normalize("NFKD");return Rs.set(n,e),e},ks=new Map,le=n=>{let t=ks.get(n);if(t)return t;let e=Ut(n.toLowerCase());return ks.set(n,e),e},fe=class extends pt{constructor(){super({max:256})}},_e=class extends pt{constructor(t=16*1024){super({maxSize:t,sizeCalculation:e=>e.length+1})}},Ls=Symbol("PathScurry setAsCwd"),L=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=G,s,i,r,o,h){this.name=t,this.#w=r?le(t):Ut(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=Os(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).#_(i):this.#_(i)}#_(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&=~De,e}child(t,e){if(t===""||t===".")return this;if(t==="..")return this.parent||this;let s=this.children(),i=this.nocase?le(t):Ut(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,G,{...e,parent:this,fullpath:o});return this.canReaddir()||(h.#t|=Y),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&U)===G}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&U)===Ns}isDirectory(){return(this.#t&U)===Q}isCharacterDevice(){return(this.#t&U)===Ms}isBlockDevice(){return(this.#t&U)===_s}isFIFO(){return(this.#t&U)===Fs}isSocket(){return(this.#t&U)===Is}isSymbolicLink(){return(this.#t&gt)===gt}lstatCached(){return this.#t&Ts?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&U;return!(t!==G&&t!==gt||this.#t&ae||this.#t&Y)}calledReaddir(){return!!(this.#t&De)}isENOENT(){return!!(this.#t&Y)}isNamed(t){return this.nocase?this.#w===le(t):this.#w===Ut(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}}#N(t){this.#t|=De;for(let e=t.provisional;e<t.length;e++){let s=t[e];s&&s.#I()}}#I(){this.#t&Y||(this.#t=(this.#t|Y)&zt,this.#A())}#A(){let t=this.children();t.provisional=0;for(let e of t)e.#I()}#R(){this.#t|=ce,this.#L()}#L(){if(this.#t&Bt)return;let t=this.#t;(t&U)===Q&&(t&=zt),this.#t=t|Bt,this.#A()}#W(t=""){t==="ENOTDIR"||t==="EPERM"?this.#L():t==="ENOENT"?this.#I():this.children().provisional=0}#P(t=""){t==="ENOTDIR"?this.parent.#L():t==="ENOENT"&&this.#I()}#o(t=""){let e=this.#t;e|=ae,t==="ENOENT"&&(e|=Y),(t==="EINVAL"||t==="UNKNOWN")&&(e&=zt),this.#t=e,t==="ENOTDIR"&&this.parent&&this.parent.#L()}#j(t,e){return this.#F(t,e)||this.#z(t,e)}#z(t,e){let s=Fe(t),i=this.newChild(t.name,s,{parent:this}),r=i.#t&U;return r!==Q&&r!==gt&&r!==G&&(i.#t|=Bt),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?le(t.name):Ut(t.name))===i.#w)return this.#$(t,i,s,e)}}#$(t,e,s,i){let r=e.name;return e.#t=e.#t&zt|Fe(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&Y))try{return this.#H(await this.#e.promises.lstat(this.fullpath())),this}catch(t){this.#P(t.code)}}lstatSync(){if(!(this.#t&Y))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=Fe(t);this.#t=this.#t&zt|S|Ts,S!==G&&S!==Q&&S!==gt&&(this.#t|=Bt)}#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.#N(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.#N(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.#N(t)}catch(s){this.#W(s.code),t.provisional=0}return t.slice(0,t.provisional)}canReaddir(){if(this.#t&As)return!1;let t=U&this.#t;return t===G||t===Q||t===gt}shouldWalk(t,e){return(this.#t&Q)===Q&&!(this.#t&As)&&!t.has(this)&&(!e||e(this))}async realpath(){if(this.#D)return this.#D;if(!((ce|ae|Y)&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(!((ce|ae|Y)&this.#t))try{let t=this.#e.realpathSync(this.fullpath());return this.#D=this.resolve(t)}catch{this.#R()}}[Ls](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}},At=class extends L{sep="\\";splitSep=gr;constructor(t,e=G,s,i,r,o,h){super(t,e,s,i,r,o,h)}newChild(t,e=G,s={}){return new At(t,e,this.root,this.roots,this.nocase,this.childrenCache(),s)}getRootString(t){return Me.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 kt(t,this).root}sameRoot(t,e=this.root.name){return t=t.toUpperCase().replace(/\//g,"\\").replace(Ds,"$1\\"),t===e}},Rt=class extends L{splitSep="/";sep="/";constructor(t,e=G,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=G,s={}){return new Rt(t,e,this.root,this.roots,this.nocase,this.childrenCache(),s)}},ue=class{root;rootPath;roots;cwd;#e;#i;#r;nocase;#h;constructor(t=process.cwd(),e,s,{nocase:i,childrenCacheSize:r=16*1024,fs:o=$t}={}){this.#h=Os(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 fe,this.#i=new fe,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 L||(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 L||(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 L||(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 L||(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 L||(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 L||(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 L||(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 L||(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 L||(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 L||(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 L||(e=t,t=this.cwd);let{withFileTypes:s=!0,follow:i=!1,filter:r,walkFilter:o}=e,h=new lt({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 L||(e=t,t=this.cwd);let{withFileTypes:s=!0,follow:i=!1,filter:r,walkFilter:o}=e,h=new lt({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[Ls](e)}},kt=class extends ue{sep="\\";constructor(t=process.cwd(),e={}){let{nocase:s=!0}=e;super(t,Me,"\\",{...e,nocase:s}),this.nocase=s;for(let i=this.cwd;i;i=i.parent)i.nocase=this.nocase}parseRootPath(t){return Me.parse(t).root.toUpperCase()}newRoot(t){return new At(this.rootPath,Q,void 0,this.roots,this.nocase,this.childrenCache(),{fs:t})}isAbsolute(t){return t.startsWith("/")||t.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(t)}},Ot=class extends ue{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 Rt(this.rootPath,Q,void 0,this.roots,this.nocase,this.childrenCache(),{fs:t})}isAbsolute(t){return t.startsWith("/")}},Gt=class extends Ot{constructor(t=process.cwd(),e={}){let{nocase:s=!0}=e;super(t,{...e,nocase:s})}},wn=process.platform==="win32"?At:Rt,Ws=process.platform==="win32"?kt:process.platform==="darwin"?Gt:Ot;var yr=n=>n.length>=1,br=n=>n.length>=1,ct=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]===N}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 ct(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",Dt=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 z(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 ct(i,r,0,this.platform),h=new z(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 Ht=class{store;constructor(t=new Map){this.store=t}copy(){return new Ht(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()]))}},Ne=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())}},wt=class{hasWalkedCache;matches=new Ne;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 Ht}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===N){(!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 wt(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===N?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 Dt([n],t):Array.isArray(n)?new Dt(n,t):n,de=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 wt(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 wt(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()}},qt=class extends de{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}},Kt=class extends de{results;constructor(t,e,s){super(t,e,s),this.results=new lt({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",J=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"?kt:e.platform==="darwin"?Gt:e.platform?Ot:Ws;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 z(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 ct(a,c,0,this.platform)})}async walk(){return[...await new qt(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 qt(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 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}).stream()}streamSync(){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}).streamSync()}iterateSync(){return this.streamSync()[Symbol.iterator]()}[Symbol.iterator](){return this.iterateSync()}iterate(){return this.stream()[Symbol.asyncIterator]()}[Symbol.asyncIterator](){return this.iterate()}};var Le=(n,t={})=>{Array.isArray(n)||(n=[n]);for(let e of n)if(new z(e,t).hasMagic())return!0;return!1};function me(n,t={}){return new J(n,t).streamSync()}function js(n,t={}){return new J(n,t).stream()}function zs(n,t={}){return new J(n,t).walkSync()}async function Ps(n,t={}){return new J(n,t).walk()}function ge(n,t={}){return new J(n,t).iterateSync()}function $s(n,t={}){return new J(n,t).iterate()}var Cr=me,Tr=Object.assign(js,{sync:me}),Ar=ge,Rr=Object.assign($s,{sync:ge}),kr=Object.assign(zs,{stream:me,iterate:ge}),pe=Object.assign(Ps,{glob:Ps,globSync:zs,sync:kr,globStream:js,stream:Tr,globStreamSync:me,streamSync:Cr,globIterate:$s,iterate:Rr,globIterateSync:ge,iterateSync:Ar,Glob:J,hasMagic:Le,escape:bt,unescape:K});pe.glob=pe;async function Us({rootDir:n,config:t}){return(await pe(Bs.join(t.sourceDirectory,"**","*.sol"),{cwd:n})).sort().map(s=>({filename:s,basename:Bs.basename(s,".sol")}))}async function Gs({rootDir:n,config:t}){return(await Us({rootDir:n,config:t})).map(s=>({sourcePath:s.filename,name:s.basename})).filter(s=>s.name.endsWith("System")&&s.name!=="System"&&!/^I[A-Z]/.test(s.name))}async function Hs({rootDir:n,config:t}){let e=await Gs({rootDir:n,config:t}),s=e.map(h=>h.name),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.name]??je({label:h.name,namespace:t.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 ho({rootDir:n,config:t,clean:e=!0}){let s=Vt.join(t.sourceDirectory,t.codegen.outputDirectory,t.codegen.worldgenDirectory);e&&qs.rmSync(s,{recursive:!0,force:!0});let i=await Hs({rootDir:n,config:t}),r=[];for(let a of i){let l=qs.readFileSync(a.sourcePath,"utf8"),{functions:c,errors:f,symbolImports:u}=Dr(l,a.label),m=u.map(g=>g.path[0]==="."?{symbol:g.symbol,fromPath:Vt.join(Vt.dirname(a.sourcePath),g.path),usedInPath:s}:{symbol:g.symbol,path:g.path}),y=`I${a.label}`,d=$e({name:y,functionPrefix:a.namespace===""?"":`${a.namespace}__`,functions:c,errors:f,imports:m}),w=Vt.join(n,s,y+".sol");await Ks(d,w,"Generated system interface"),r.push({symbol:y,fromPath:`${y}.sol`,usedInPath:"./"})}let o=Be({interfaceName:t.codegen.worldInterfaceName,imports:r,storeImportPath:t.codegen.storeImportPath,worldImportPath:t.codegen.worldImportPath}),h=Vt.join(n,s,t.codegen.worldInterfaceName+".sol");await Ks(o,h,"Generated world interface")}export{Us as findSolidityFiles,Gs as getSystemContracts,$e as renderSystemInterface,Be as renderWorldInterface,Hs as resolveSystems,ho as worldgen};
39
39
  //# sourceMappingURL=node.js.map