tshy 3.2.0 → 3.2.1
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/esm/bin-min.mjs
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var an=(s=0)=>t=>`\x1B[${t+s}m`,cn=(s=0)=>t=>`\x1B[${38+s};5;${t}m`,ln=(s=0)=>(t,e,i)=>`\x1B[${38+s};2;${t};${e};${i}m`,O={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},xp=Object.keys(O.modifier),Vc=Object.keys(O.color),Jc=Object.keys(O.bgColor),vp=[...Vc,...Jc];function Kc(){let s=new Map;for(let[t,e]of Object.entries(O)){for(let[i,r]of Object.entries(e))O[i]={open:`\x1B[${r[0]}m`,close:`\x1B[${r[1]}m`},e[i]=O[i],s.set(r[0],r[1]);Object.defineProperty(O,t,{value:e,enumerable:!1})}return Object.defineProperty(O,"codes",{value:s,enumerable:!1}),O.color.close="\x1B[39m",O.bgColor.close="\x1B[49m",O.color.ansi=an(),O.color.ansi256=cn(),O.color.ansi16m=ln(),O.bgColor.ansi=an(10),O.bgColor.ansi256=cn(10),O.bgColor.ansi16m=ln(10),Object.defineProperties(O,{rgbToAnsi256:{value(t,e,i){return t===e&&e===i?t<8?16:t>248?231:Math.round((t-8)/247*24)+232:16+36*Math.round(t/255*5)+6*Math.round(e/255*5)+Math.round(i/255*5)},enumerable:!1},hexToRgb:{value(t){let e=/[a-f\d]{6}|[a-f\d]{3}/i.exec(t.toString(16));if(!e)return[0,0,0];let[i]=e;i.length===3&&(i=[...i].map(n=>n+n).join(""));let r=Number.parseInt(i,16);return[r>>16&255,r>>8&255,r&255]},enumerable:!1},hexToAnsi256:{value:t=>O.rgbToAnsi256(...O.hexToRgb(t)),enumerable:!1},ansi256ToAnsi:{value(t){if(t<8)return 30+t;if(t<16)return 90+(t-8);let e,i,r;if(t>=232)e=((t-232)*10+8)/255,i=e,r=e;else{t-=16;let a=t%36;e=Math.floor(t/36)/5,i=Math.floor(a/6)/5,r=a%6/5}let n=Math.max(e,i,r)*2;if(n===0)return 30;let o=30+(Math.round(r)<<2|Math.round(i)<<1|Math.round(e));return n===2&&(o+=60),o},enumerable:!1},rgbToAnsi:{value:(t,e,i)=>O.ansi256ToAnsi(O.rgbToAnsi256(t,e,i)),enumerable:!1},hexToAnsi:{value:t=>O.ansi256ToAnsi(O.hexToAnsi256(t)),enumerable:!1}}),O}var Xc=Kc(),pt=Xc;import
|
|
2
|
+
var an=(s=0)=>t=>`\x1B[${t+s}m`,cn=(s=0)=>t=>`\x1B[${38+s};5;${t}m`,ln=(s=0)=>(t,e,i)=>`\x1B[${38+s};2;${t};${e};${i}m`,O={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},xp=Object.keys(O.modifier),Vc=Object.keys(O.color),Jc=Object.keys(O.bgColor),vp=[...Vc,...Jc];function Kc(){let s=new Map;for(let[t,e]of Object.entries(O)){for(let[i,r]of Object.entries(e))O[i]={open:`\x1B[${r[0]}m`,close:`\x1B[${r[1]}m`},e[i]=O[i],s.set(r[0],r[1]);Object.defineProperty(O,t,{value:e,enumerable:!1})}return Object.defineProperty(O,"codes",{value:s,enumerable:!1}),O.color.close="\x1B[39m",O.bgColor.close="\x1B[49m",O.color.ansi=an(),O.color.ansi256=cn(),O.color.ansi16m=ln(),O.bgColor.ansi=an(10),O.bgColor.ansi256=cn(10),O.bgColor.ansi16m=ln(10),Object.defineProperties(O,{rgbToAnsi256:{value(t,e,i){return t===e&&e===i?t<8?16:t>248?231:Math.round((t-8)/247*24)+232:16+36*Math.round(t/255*5)+6*Math.round(e/255*5)+Math.round(i/255*5)},enumerable:!1},hexToRgb:{value(t){let e=/[a-f\d]{6}|[a-f\d]{3}/i.exec(t.toString(16));if(!e)return[0,0,0];let[i]=e;i.length===3&&(i=[...i].map(n=>n+n).join(""));let r=Number.parseInt(i,16);return[r>>16&255,r>>8&255,r&255]},enumerable:!1},hexToAnsi256:{value:t=>O.rgbToAnsi256(...O.hexToRgb(t)),enumerable:!1},ansi256ToAnsi:{value(t){if(t<8)return 30+t;if(t<16)return 90+(t-8);let e,i,r;if(t>=232)e=((t-232)*10+8)/255,i=e,r=e;else{t-=16;let a=t%36;e=Math.floor(t/36)/5,i=Math.floor(a/6)/5,r=a%6/5}let n=Math.max(e,i,r)*2;if(n===0)return 30;let o=30+(Math.round(r)<<2|Math.round(i)<<1|Math.round(e));return n===2&&(o+=60),o},enumerable:!1},rgbToAnsi:{value:(t,e,i)=>O.ansi256ToAnsi(O.rgbToAnsi256(t,e,i)),enumerable:!1},hexToAnsi:{value:t=>O.ansi256ToAnsi(O.hexToAnsi256(t)),enumerable:!1}}),O}var Xc=Kc(),pt=Xc;import ji from"node:process";import Zc from"node:os";import fn from"node:tty";function ot(s,t=globalThis.Deno?globalThis.Deno.args:ji.argv){let e=s.startsWith("-")?"":s.length===1?"-":"--",i=t.indexOf(e+s),r=t.indexOf("--");return i!==-1&&(r===-1||i<r)}var{env:R}=ji,bs;ot("no-color")||ot("no-colors")||ot("color=false")||ot("color=never")?bs=0:(ot("color")||ot("colors")||ot("color=true")||ot("color=always"))&&(bs=1);function Qc(){if("FORCE_COLOR"in R)return R.FORCE_COLOR==="true"?1:R.FORCE_COLOR==="false"?0:R.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(R.FORCE_COLOR,10),3)}function tl(s){return s===0?!1:{level:s,hasBasic:!0,has256:s>=2,has16m:s>=3}}function el(s,{streamIsTTY:t,sniffFlags:e=!0}={}){let i=Qc();i!==void 0&&(bs=i);let r=e?bs:i;if(r===0)return 0;if(e){if(ot("color=16m")||ot("color=full")||ot("color=truecolor"))return 3;if(ot("color=256"))return 2}if("TF_BUILD"in R&&"AGENT_NAME"in R)return 1;if(s&&!t&&r===void 0)return 0;let n=r||0;if(R.TERM==="dumb")return n;if(ji.platform==="win32"){let o=Zc.release().split(".");return Number(o[0])>=10&&Number(o[2])>=10586?Number(o[2])>=14931?3:2:1}if("CI"in R)return["GITHUB_ACTIONS","GITEA_ACTIONS","CIRCLECI"].some(o=>o in R)?3:["TRAVIS","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some(o=>o in R)||R.CI_NAME==="codeship"?1:n;if("TEAMCITY_VERSION"in R)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(R.TEAMCITY_VERSION)?1:0;if(R.COLORTERM==="truecolor"||R.TERM==="xterm-kitty"||R.TERM==="xterm-ghostty"||R.TERM==="wezterm")return 3;if("TERM_PROGRAM"in R){let o=Number.parseInt((R.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(R.TERM_PROGRAM){case"iTerm.app":return o>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(R.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(R.TERM)||"COLORTERM"in R?1:n}function hn(s,t={}){let e=el(s,{streamIsTTY:s&&s.isTTY,...t});return tl(e)}var sl={stdout:hn({isTTY:fn.isatty(1)}),stderr:hn({isTTY:fn.isatty(2)})},un=sl;function dn(s,t,e){let i=s.indexOf(t);if(i===-1)return s;let r=t.length,n=0,o="";do o+=s.slice(n,i)+t+e,n=i+r,i=s.indexOf(t,n);while(i!==-1);return o+=s.slice(n),o}function mn(s,t,e,i){let r=0,n="";do{let o=s[i-1]==="\r";n+=s.slice(r,o?i-1:i)+t+(o?`\r
|
|
3
3
|
`:`
|
|
4
4
|
`)+e,r=i+1,i=s.indexOf(`
|
|
5
|
-
`,r)}while(i!==-1);return n+=s.slice(r),n}var{stdout:pn,stderr:gn}=un,
|
|
6
|
-
`);return n!==-1&&(t=mn(t,r,i,n)),i+t+r};Object.defineProperties(Fe.prototype,oe);var cl=Fe(),jp=Fe({level:gn?gn.level:0});var E=cl;var Fi=(s,t,e)=>{let i=s instanceof RegExp?wn(s,e):s,r=t instanceof RegExp?wn(t,e):t,n=i!==null&&r!=null&&ll(i,r,e);return n&&{start:n[0],end:n[1],pre:e.slice(0,n[0]),body:e.slice(n[0]+i.length,n[1]),post:e.slice(n[1]+r.length)}},wn=(s,t)=>{let e=t.match(s);return e?e[0]:null},ll=(s,t,e)=>{let i,r,n,o,a,c=e.indexOf(s),l=e.indexOf(t,c+1),h=c;if(c>=0&&l>0){if(s===t)return[c,l];for(i=[],n=e.length;h>=0&&!a;){if(h===c)i.push(h),c=e.indexOf(s,h+1);else if(i.length===1){let f=i.pop();f!==void 0&&(a=[f,l])}else r=i.pop(),r!==void 0&&r<n&&(n=r,o=l),l=e.indexOf(t,h+1);h=c<l&&c>=0?c:l}i.length&&o!==void 0&&(a=[n,o])}return a};var bn="\0SLASH"+Math.random()+"\0",Sn="\0OPEN"+Math.random()+"\0",Mi="\0CLOSE"+Math.random()+"\0",En="\0COMMA"+Math.random()+"\0",xn="\0PERIOD"+Math.random()+"\0",fl=new RegExp(bn,"g"),hl=new RegExp(Sn,"g"),ul=new RegExp(Mi,"g"),dl=new RegExp(En,"g"),ml=new RegExp(xn,"g"),pl=/\\\\/g,gl=/\\{/g,yl=/\\}/g,wl=/\\,/g,bl=/\\./g,Sl=1e5;function Ii(s){return isNaN(s)?s.charCodeAt(0):parseInt(s,10)}function El(s){return s.replace(pl,bn).replace(gl,Sn).replace(yl,Mi).replace(wl,En).replace(bl,xn)}function xl(s){return s.replace(fl,"\\").replace(hl,"{").replace(ul,"}").replace(dl,",").replace(ml,".")}function vn(s){if(!s)return[""];let t=[],e=Fi("{","}",s);if(!e)return s.split(",");let{pre:i,body:r,post:n}=e,o=i.split(",");o[o.length-1]+="{"+r+"}";let a=vn(n);return n.length&&(o[o.length-1]+=a.shift(),o.push.apply(o,a)),t.push.apply(t,o),t}function _n(s,t={}){if(!s)return[];let{max:e=Sl}=t;return s.slice(0,2)==="{}"&&(s="\\{\\}"+s.slice(2)),Ie(El(s),e,!0).map(xl)}function vl(s){return"{"+s+"}"}function _l(s){return/^-?0\d/.test(s)}function Tl(s,t){return s<=t}function kl(s,t){return s>=t}function Ie(s,t,e){let i=[],r=Fi("{","}",s);if(!r)return[s];let n=r.pre,o=r.post.length?Ie(r.post,t,!1):[""];if(/\$$/.test(r.pre))for(let a=0;a<o.length&&a<t;a++){let c=n+"{"+r.body+"}"+o[a];i.push(c)}else{let a=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(r.body),c=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(r.body),l=a||c,h=r.body.indexOf(",")>=0;if(!l&&!h)return r.post.match(/,(?!,).*\}/)?(s=r.pre+"{"+r.body+Mi+r.post,Ie(s,t,!0)):[s];let f;if(l)f=r.body.split(/\.\./);else if(f=vn(r.body),f.length===1&&f[0]!==void 0&&(f=Ie(f[0],t,!1).map(vl),f.length===1))return o.map(d=>r.pre+f[0]+d);let u;if(l&&f[0]!==void 0&&f[1]!==void 0){let d=Ii(f[0]),m=Ii(f[1]),p=Math.max(f[0].length,f[1].length),y=f.length===3&&f[2]!==void 0?Math.abs(Ii(f[2])):1,g=Tl;m<d&&(y*=-1,g=kl);let x=f.some(_l);u=[];for(let w=d;g(w,m);w+=y){let b;if(c)b=String.fromCharCode(w),b==="\\"&&(b="");else if(b=String(w),x){let I=p-b.length;if(I>0){let it=new Array(I+1).join("0");w<0?b="-"+it+b.slice(1):b=it+b}}u.push(b)}}else{u=[];for(let d=0;d<f.length;d++)u.push.apply(u,Ie(f[d],t,!1))}for(let d=0;d<u.length;d++)for(let m=0;m<o.length&&i.length<t;m++){let p=n+u[d]+o[m];(!e||l||p)&&i.push(p)}}return i}var Me=s=>{if(typeof s!="string")throw new TypeError("invalid pattern");if(s.length>65536)throw new TypeError("pattern is too long")};var Al={"[: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]},$e=s=>s.replace(/[[\]\\-]/g,"\\$&"),Ol=s=>s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Tn=s=>s.join(""),kn=(s,t)=>{let e=t;if(s.charAt(e)!=="[")throw new Error("not in a brace expression");let i=[],r=[],n=e+1,o=!1,a=!1,c=!1,l=!1,h=e,f="";t:for(;n<s.length;){let p=s.charAt(n);if((p==="!"||p==="^")&&n===e+1){l=!0,n++;continue}if(p==="]"&&o&&!c){h=n+1;break}if(o=!0,p==="\\"&&!c){c=!0,n++;continue}if(p==="["&&!c){for(let[y,[g,S,x]]of Object.entries(Al))if(s.startsWith(y,n)){if(f)return["$.",!1,s.length-e,!0];n+=y.length,x?r.push(g):i.push(g),a=a||S;continue t}}if(c=!1,f){p>f?i.push($e(f)+"-"+$e(p)):p===f&&i.push($e(p)),f="",n++;continue}if(s.startsWith("-]",n+1)){i.push($e(p+"-")),n+=2;continue}if(s.startsWith("-",n+1)){f=p,n+=2;continue}i.push($e(p)),n++}if(h<n)return["",!1,0,!1];if(!i.length&&!r.length)return["$.",!1,s.length-e,!0];if(r.length===0&&i.length===1&&/^\\?.$/.test(i[0])&&!l){let p=i[0].length===2?i[0].slice(-1):i[0];return[Ol(p),!1,h-e,!1]}let u="["+(l?"^":"")+Tn(i)+"]",d="["+(l?"":"^")+Tn(r)+"]";return[i.length&&r.length?"("+u+"|"+d+")":i.length?u:d,a,h-e,!0]};var gt=(s,{windowsPathsNoEscape:t=!1,magicalBraces:e=!0}={})=>e?t?s.replace(/\[([^\/\\])\]/g,"$1"):s.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1"):t?s.replace(/\[([^\/\\{}])\]/g,"$1"):s.replace(/((?!\\).|^)\[([^\/\\{}])\]/g,"$1$2").replace(/\\([^\/{}])/g,"$1");var Rl=new Set(["!","?","+","*","@"]),An=s=>Rl.has(s),Cl="(?!(?:^|/)\\.\\.?(?:$|/))",Ss="(?!\\.)",Nl=new Set(["[","."]),Pl=new Set(["..","."]),jl=new Set("().*{}+?[]^$\\!"),Dl=s=>s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),$i="[^/]",On=$i+"*?",Rn=$i+"+?",ae=class s{type;#t;#s;#n=!1;#r=[];#o;#S;#y;#f=!1;#a;#u;#h=!1;constructor(t,e,i={}){this.type=t,t&&(this.#s=!0),this.#o=e,this.#t=this.#o?this.#o.#t:this,this.#a=this.#t===this?i:this.#t.#a,this.#y=this.#t===this?[]:this.#t.#y,t==="!"&&!this.#t.#f&&this.#y.push(this),this.#S=this.#o?this.#o.#r.length:0}get hasMagic(){if(this.#s!==void 0)return this.#s;for(let t of this.#r)if(typeof t!="string"&&(t.type||t.hasMagic))return this.#s=!0;return this.#s}toString(){return this.#u!==void 0?this.#u:this.type?this.#u=this.type+"("+this.#r.map(t=>String(t)).join("|")+")":this.#u=this.#r.map(t=>String(t)).join("")}#c(){if(this!==this.#t)throw new Error("should only call on root");if(this.#f)return this;this.toString(),this.#f=!0;let t;for(;t=this.#y.pop();){if(t.type!=="!")continue;let e=t,i=e.#o;for(;i;){for(let r=e.#S+1;!i.type&&r<i.#r.length;r++)for(let n of t.#r){if(typeof n=="string")throw new Error("string part in extglob AST??");n.copyIn(i.#r[r])}e=i,i=e.#o}}return this}push(...t){for(let e of t)if(e!==""){if(typeof e!="string"&&!(e instanceof s&&e.#o===this))throw new Error("invalid part: "+e);this.#r.push(e)}}toJSON(){let t=this.type===null?this.#r.slice().map(e=>typeof e=="string"?e:e.toJSON()):[this.type,...this.#r.map(e=>e.toJSON())];return this.isStart()&&!this.type&&t.unshift([]),this.isEnd()&&(this===this.#t||this.#t.#f&&this.#o?.type==="!")&&t.push({}),t}isStart(){if(this.#t===this)return!0;if(!this.#o?.isStart())return!1;if(this.#S===0)return!0;let t=this.#o;for(let e=0;e<this.#S;e++){let i=t.#r[e];if(!(i instanceof s&&i.type==="!"))return!1}return!0}isEnd(){if(this.#t===this||this.#o?.type==="!")return!0;if(!this.#o?.isEnd())return!1;if(!this.type)return this.#o?.isEnd();let t=this.#o?this.#o.#r.length:0;return this.#S===t-1}copyIn(t){typeof t=="string"?this.push(t):this.push(t.clone(this))}clone(t){let e=new s(this.type,t);for(let i of this.#r)e.copyIn(i);return e}static#i(t,e,i,r){let n=!1,o=!1,a=-1,c=!1;if(e.type===null){let d=i,m="";for(;d<t.length;){let p=t.charAt(d++);if(n||p==="\\"){n=!n,m+=p;continue}if(o){d===a+1?(p==="^"||p==="!")&&(c=!0):p==="]"&&!(d===a+2&&c)&&(o=!1),m+=p;continue}else if(p==="["){o=!0,a=d,c=!1,m+=p;continue}if(!r.noext&&An(p)&&t.charAt(d)==="("){e.push(m),m="";let y=new s(p,e);d=s.#i(t,y,d,r),e.push(y);continue}m+=p}return e.push(m),d}let l=i+1,h=new s(null,e),f=[],u="";for(;l<t.length;){let d=t.charAt(l++);if(n||d==="\\"){n=!n,u+=d;continue}if(o){l===a+1?(d==="^"||d==="!")&&(c=!0):d==="]"&&!(l===a+2&&c)&&(o=!1),u+=d;continue}else if(d==="["){o=!0,a=l,c=!1,u+=d;continue}if(An(d)&&t.charAt(l)==="("){h.push(u),u="";let m=new s(d,h);h.push(m),l=s.#i(t,m,l,r);continue}if(d==="|"){h.push(u),u="",f.push(h),h=new s(null,e);continue}if(d===")")return u===""&&e.#r.length===0&&(e.#h=!0),h.push(u),u="",e.push(...f,h),l;u+=d}return e.type=null,e.#s=void 0,e.#r=[t.substring(i-1)],l}static fromGlob(t,e={}){let i=new s(null,void 0,e);return s.#i(t,i,0,e),i}toMMPattern(){if(this!==this.#t)return this.#t.toMMPattern();let t=this.toString(),[e,i,r,n]=this.toRegExpSource();if(!(r||this.#s||this.#a.nocase&&!this.#a.nocaseMagicOnly&&t.toUpperCase()!==t.toLowerCase()))return i;let a=(this.#a.nocase?"i":"")+(n?"u":"");return Object.assign(new RegExp(`^${e}$`,a),{_src:e,_glob:t})}get options(){return this.#a}toRegExpSource(t){let e=t??!!this.#a.dot;if(this.#t===this&&this.#c(),!this.type){let c=this.isStart()&&this.isEnd()&&!this.#r.some(d=>typeof d!="string"),l=this.#r.map(d=>{let[m,p,y,g]=typeof d=="string"?s.#E(d,this.#s,c):d.toRegExpSource(t);return this.#s=this.#s||y,this.#n=this.#n||g,m}).join(""),h="";if(this.isStart()&&typeof this.#r[0]=="string"&&!(this.#r.length===1&&Pl.has(this.#r[0]))){let m=Nl,p=e&&m.has(l.charAt(0))||l.startsWith("\\.")&&m.has(l.charAt(2))||l.startsWith("\\.\\.")&&m.has(l.charAt(4)),y=!e&&!t&&m.has(l.charAt(0));h=p?Cl:y?Ss:""}let f="";return this.isEnd()&&this.#t.#f&&this.#o?.type==="!"&&(f="(?:$|\\/)"),[h+l+f,gt(l),this.#s=!!this.#s,this.#n]}let i=this.type==="*"||this.type==="+",r=this.type==="!"?"(?:(?!(?:":"(?:",n=this.#d(e);if(this.isStart()&&this.isEnd()&&!n&&this.type!=="!"){let c=this.toString();return this.#r=[c],this.type=null,this.#s=void 0,[c,gt(this.toString()),!1,!1]}let o=!i||t||e||!Ss?"":this.#d(!0);o===n&&(o=""),o&&(n=`(?:${n})(?:${o})*?`);let a="";if(this.type==="!"&&this.#h)a=(this.isStart()&&!e?Ss:"")+Rn;else{let c=this.type==="!"?"))"+(this.isStart()&&!e&&!t?Ss:"")+On+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&o?")":this.type==="*"&&o?")?":`)${this.type}`;a=r+n+c}return[a,gt(n),this.#s=!!this.#s,this.#n]}#d(t){return this.#r.map(e=>{if(typeof e=="string")throw new Error("string type in extglob ast??");let[i,r,n,o]=e.toRegExpSource(t);return this.#n=this.#n||o,i}).filter(e=>!(this.isStart()&&this.isEnd())||!!e).join("|")}static#E(t,e,i=!1){let r=!1,n="",o=!1;for(let a=0;a<t.length;a++){let c=t.charAt(a);if(r){r=!1,n+=(jl.has(c)?"\\":"")+c;continue}if(c==="\\"){a===t.length-1?n+="\\\\":r=!0;continue}if(c==="["){let[l,h,f,u]=kn(t,a);if(f){n+=l,o=o||h,a+=f-1,e=e||u;continue}}if(c==="*"){n+=i&&t==="*"?Rn:On,e=!0;continue}if(c==="?"){n+=$i,e=!0;continue}n+=Dl(c)}return[n,gt(t),!!e,o]}};var At=(s,{windowsPathsNoEscape:t=!1,magicalBraces:e=!1}={})=>e?t?s.replace(/[?*()[\]{}]/g,"[$&]"):s.replace(/[?*()[\]\\{}]/g,"\\$&"):t?s.replace(/[?*()[\]]/g,"[$&]"):s.replace(/[?*()[\]\\]/g,"\\$&");var K=(s,t,e={})=>(Me(t),!e.nocomment&&t.charAt(0)==="#"?!1:new X(t,e).match(s)),Fl=/^\*+([^+@!?\*\[\(]*)$/,Il=s=>t=>!t.startsWith(".")&&t.endsWith(s),Ml=s=>t=>t.endsWith(s),$l=s=>(s=s.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(s)),Ll=s=>(s=s.toLowerCase(),t=>t.toLowerCase().endsWith(s)),Wl=/^\*+\.\*+$/,Bl=s=>!s.startsWith(".")&&s.includes("."),Ul=s=>s!=="."&&s!==".."&&s.includes("."),zl=/^\.\*+$/,Gl=s=>s!=="."&&s!==".."&&s.startsWith("."),Hl=/^\*+$/,Yl=s=>s.length!==0&&!s.startsWith("."),ql=s=>s.length!==0&&s!=="."&&s!=="..",Vl=/^\?+([^+@!?\*\[\(]*)?$/,Jl=([s,t=""])=>{let e=Pn([s]);return t?(t=t.toLowerCase(),i=>e(i)&&i.toLowerCase().endsWith(t)):e},Kl=([s,t=""])=>{let e=jn([s]);return t?(t=t.toLowerCase(),i=>e(i)&&i.toLowerCase().endsWith(t)):e},Xl=([s,t=""])=>{let e=jn([s]);return t?i=>e(i)&&i.endsWith(t):e},Zl=([s,t=""])=>{let e=Pn([s]);return t?i=>e(i)&&i.endsWith(t):e},Pn=([s])=>{let t=s.length;return e=>e.length===t&&!e.startsWith(".")},jn=([s])=>{let t=s.length;return e=>e.length===t&&e!=="."&&e!==".."},Dn=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",Cn={win32:{sep:"\\"},posix:{sep:"/"}},Ql=Dn==="win32"?Cn.win32.sep:Cn.posix.sep;K.sep=Ql;var U=Symbol("globstar **");K.GLOBSTAR=U;var tf="[^/]",ef=tf+"*?",sf="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",rf="(?:(?!(?:\\/|^)\\.).)*?",nf=(s,t={})=>e=>K(e,s,t);K.filter=nf;var at=(s,t={})=>Object.assign({},s,t),of=s=>{if(!s||typeof s!="object"||!Object.keys(s).length)return K;let t=K;return Object.assign((i,r,n={})=>t(i,r,at(s,n)),{Minimatch:class extends t.Minimatch{constructor(r,n={}){super(r,at(s,n))}static defaults(r){return t.defaults(at(s,r)).Minimatch}},AST:class extends t.AST{constructor(r,n,o={}){super(r,n,at(s,o))}static fromGlob(r,n={}){return t.AST.fromGlob(r,at(s,n))}},unescape:(i,r={})=>t.unescape(i,at(s,r)),escape:(i,r={})=>t.escape(i,at(s,r)),filter:(i,r={})=>t.filter(i,at(s,r)),defaults:i=>t.defaults(at(s,i)),makeRe:(i,r={})=>t.makeRe(i,at(s,r)),braceExpand:(i,r={})=>t.braceExpand(i,at(s,r)),match:(i,r,n={})=>t.match(i,r,at(s,n)),sep:t.sep,GLOBSTAR:U})};K.defaults=of;var Fn=(s,t={})=>(Me(s),t.nobrace||!/\{(?:(?!\{).)*\}/.test(s)?[s]:_n(s));K.braceExpand=Fn;var af=(s,t={})=>new X(s,t).makeRe();K.makeRe=af;var cf=(s,t,e={})=>{let i=new X(t,e);return s=s.filter(r=>i.match(r)),i.options.nonull&&!s.length&&s.push(t),s};K.match=cf;var Nn=/[?*]|[+@!]\(.*?\)|\[|\]/,lf=s=>s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),X=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;regexp;constructor(t,e={}){Me(t),e=e||{},this.options=e,this.pattern=t,this.platform=e.platform||Dn,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=(...n)=>console.error(...n)),this.debug(this.pattern,this.globSet);let i=this.globSet.map(n=>this.slashSplit(n));this.globParts=this.preprocess(i),this.debug(this.pattern,this.globParts);let r=this.globParts.map((n,o,a)=>{if(this.isWindows&&this.windowsNoMagicRoot){let c=n[0]===""&&n[1]===""&&(n[2]==="?"||!Nn.test(n[2]))&&!Nn.test(n[3]),l=/^[a-z]:/i.test(n[0]);if(c)return[...n.slice(0,4),...n.slice(4).map(h=>this.parse(h))];if(l)return[n[0],...n.slice(1).map(h=>this.parse(h))]}return n.map(c=>this.parse(c))});if(this.debug(this.pattern,r),this.set=r.filter(n=>n.indexOf(!1)===-1),this.isWindows)for(let n=0;n<this.set.length;n++){let o=this.set[n];o[0]===""&&o[1]===""&&this.globParts[n][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 i=0;i<t.length;i++)for(let r=0;r<t[i].length;r++)t[i][r]==="**"&&(t[i][r]="*");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 i=-1;for(;(i=e.indexOf("**",i+1))!==-1;){let r=i;for(;e[r+1]==="**";)r++;r!==i&&e.splice(i,r-i)}return e})}levelOneOptimize(t){return t.map(e=>(e=e.reduce((i,r)=>{let n=i[i.length-1];return r==="**"&&n==="**"?i:r===".."&&n&&n!==".."&&n!=="."&&n!=="**"?(i.pop(),i):(i.push(r),i)},[]),e.length===0?[""]:e))}levelTwoFileOptimize(t){Array.isArray(t)||(t=this.slashSplit(t));let e=!1;do{if(e=!1,!this.preserveMultipleSlashes){for(let r=1;r<t.length-1;r++){let n=t[r];r===1&&n===""&&t[0]===""||(n==="."||n==="")&&(e=!0,t.splice(r,1),r--)}t[0]==="."&&t.length===2&&(t[1]==="."||t[1]==="")&&(e=!0,t.pop())}let i=0;for(;(i=t.indexOf("..",i+1))!==-1;){let r=t[i-1];r&&r!=="."&&r!==".."&&r!=="**"&&(e=!0,t.splice(i-1,2),i-=2)}}while(e);return t.length===0?[""]:t}firstPhasePreProcess(t){let e=!1;do{e=!1;for(let i of t){let r=-1;for(;(r=i.indexOf("**",r+1))!==-1;){let o=r;for(;i[o+1]==="**";)o++;o>r&&i.splice(r+1,o-r);let a=i[r+1],c=i[r+2],l=i[r+3];if(a!==".."||!c||c==="."||c===".."||!l||l==="."||l==="..")continue;e=!0,i.splice(r,1);let h=i.slice(0);h[r]="**",t.push(h),r--}if(!this.preserveMultipleSlashes){for(let o=1;o<i.length-1;o++){let a=i[o];o===1&&a===""&&i[0]===""||(a==="."||a==="")&&(e=!0,i.splice(o,1),o--)}i[0]==="."&&i.length===2&&(i[1]==="."||i[1]==="")&&(e=!0,i.pop())}let n=0;for(;(n=i.indexOf("..",n+1))!==-1;){let o=i[n-1];if(o&&o!=="."&&o!==".."&&o!=="**"){e=!0;let c=n===1&&i[n+1]==="**"?["."]:[];i.splice(n-1,2,...c),i.length===0&&i.push(""),n-=2}}}}while(e);return t}secondPhasePreProcess(t){for(let e=0;e<t.length-1;e++)for(let i=e+1;i<t.length;i++){let r=this.partsMatch(t[e],t[i],!this.preserveMultipleSlashes);if(r){t[e]=[],t[i]=r;break}}return t.filter(e=>e.length)}partsMatch(t,e,i=!1){let r=0,n=0,o=[],a="";for(;r<t.length&&n<e.length;)if(t[r]===e[n])o.push(a==="b"?e[n]:t[r]),r++,n++;else if(i&&t[r]==="**"&&e[n]===t[r+1])o.push(t[r]),r++;else if(i&&e[n]==="**"&&t[r]===e[n+1])o.push(e[n]),n++;else if(t[r]==="*"&&e[n]&&(this.options.dot||!e[n].startsWith("."))&&e[n]!=="**"){if(a==="b")return!1;a="a",o.push(t[r]),r++,n++}else if(e[n]==="*"&&t[r]&&(this.options.dot||!t[r].startsWith("."))&&t[r]!=="**"){if(a==="a")return!1;a="b",o.push(e[n]),r++,n++}else return!1;return t.length===e.length&&o}parseNegate(){if(this.nonegate)return;let t=this.pattern,e=!1,i=0;for(let r=0;r<t.length&&t.charAt(r)==="!";r++)e=!e,i++;i&&(this.pattern=t.slice(i)),this.negate=e}matchOne(t,e,i=!1){let r=this.options;if(this.isWindows){let p=typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]),y=!p&&t[0]===""&&t[1]===""&&t[2]==="?"&&/^[a-z]:$/i.test(t[3]),g=typeof e[0]=="string"&&/^[a-z]:$/i.test(e[0]),S=!g&&e[0]===""&&e[1]===""&&e[2]==="?"&&typeof e[3]=="string"&&/^[a-z]:$/i.test(e[3]),x=y?3:p?0:void 0,w=S?3:g?0:void 0;if(typeof x=="number"&&typeof w=="number"){let[b,I]=[t[x],e[w]];b.toLowerCase()===I.toLowerCase()&&(e[w]=b,w>x?e=e.slice(w):x>w&&(t=t.slice(x)))}}let{optimizationLevel:n=1}=this.options;n>=2&&(t=this.levelTwoFileOptimize(t)),this.debug("matchOne",this,{file:t,pattern:e}),this.debug("matchOne",t.length,e.length);for(var o=0,a=0,c=t.length,l=e.length;o<c&&a<l;o++,a++){this.debug("matchOne loop");var h=e[a],f=t[o];if(this.debug(e,h,f),h===!1)return!1;if(h===U){this.debug("GLOBSTAR",[e,h,f]);var u=o,d=a+1;if(d===l){for(this.debug("** at the end");o<c;o++)if(t[o]==="."||t[o]===".."||!r.dot&&t[o].charAt(0)===".")return!1;return!0}for(;u<c;){var m=t[u];if(this.debug(`
|
|
5
|
+
`,r)}while(i!==-1);return n+=s.slice(r),n}var{stdout:pn,stderr:gn}=un,Di=Symbol("GENERATOR"),ne=Symbol("STYLER"),Fe=Symbol("IS_EMPTY"),yn=["ansi","ansi","ansi256","ansi16m"],oe=Object.create(null),il=(s,t={})=>{if(t.level&&!(Number.isInteger(t.level)&&t.level>=0&&t.level<=3))throw new Error("The `level` option should be an integer from 0 to 3");let e=pn?pn.level:0;s.level=t.level===void 0?e:t.level};var rl=s=>{let t=(...e)=>e.join(" ");return il(t,s),Object.setPrototypeOf(t,Ie.prototype),t};function Ie(s){return rl(s)}Object.setPrototypeOf(Ie.prototype,Function.prototype);for(let[s,t]of Object.entries(pt))oe[s]={get(){let e=Ss(this,Ii(t.open,t.close,this[ne]),this[Fe]);return Object.defineProperty(this,s,{value:e}),e}};oe.visible={get(){let s=Ss(this,this[ne],!0);return Object.defineProperty(this,"visible",{value:s}),s}};var Fi=(s,t,e,...i)=>s==="rgb"?t==="ansi16m"?pt[e].ansi16m(...i):t==="ansi256"?pt[e].ansi256(pt.rgbToAnsi256(...i)):pt[e].ansi(pt.rgbToAnsi(...i)):s==="hex"?Fi("rgb",t,e,...pt.hexToRgb(...i)):pt[e][s](...i),nl=["rgb","hex","ansi256"];for(let s of nl){oe[s]={get(){let{level:e}=this;return function(...i){let r=Ii(Fi(s,yn[e],"color",...i),pt.color.close,this[ne]);return Ss(this,r,this[Fe])}}};let t="bg"+s[0].toUpperCase()+s.slice(1);oe[t]={get(){let{level:e}=this;return function(...i){let r=Ii(Fi(s,yn[e],"bgColor",...i),pt.bgColor.close,this[ne]);return Ss(this,r,this[Fe])}}}}var ol=Object.defineProperties(()=>{},{...oe,level:{enumerable:!0,get(){return this[Di].level},set(s){this[Di].level=s}}}),Ii=(s,t,e)=>{let i,r;return e===void 0?(i=s,r=t):(i=e.openAll+s,r=t+e.closeAll),{open:s,close:t,openAll:i,closeAll:r,parent:e}},Ss=(s,t,e)=>{let i=(...r)=>al(i,r.length===1?""+r[0]:r.join(" "));return Object.setPrototypeOf(i,ol),i[Di]=s,i[ne]=t,i[Fe]=e,i},al=(s,t)=>{if(s.level<=0||!t)return s[Fe]?"":t;let e=s[ne];if(e===void 0)return t;let{openAll:i,closeAll:r}=e;if(t.includes("\x1B"))for(;e!==void 0;)t=dn(t,e.close,e.open),e=e.parent;let n=t.indexOf(`
|
|
6
|
+
`);return n!==-1&&(t=mn(t,r,i,n)),i+t+r};Object.defineProperties(Ie.prototype,oe);var cl=Ie(),jp=Ie({level:gn?gn.level:0});var E=cl;var Mi=(s,t,e)=>{let i=s instanceof RegExp?wn(s,e):s,r=t instanceof RegExp?wn(t,e):t,n=i!==null&&r!=null&&ll(i,r,e);return n&&{start:n[0],end:n[1],pre:e.slice(0,n[0]),body:e.slice(n[0]+i.length,n[1]),post:e.slice(n[1]+r.length)}},wn=(s,t)=>{let e=t.match(s);return e?e[0]:null},ll=(s,t,e)=>{let i,r,n,o,a,c=e.indexOf(s),l=e.indexOf(t,c+1),h=c;if(c>=0&&l>0){if(s===t)return[c,l];for(i=[],n=e.length;h>=0&&!a;){if(h===c)i.push(h),c=e.indexOf(s,h+1);else if(i.length===1){let f=i.pop();f!==void 0&&(a=[f,l])}else r=i.pop(),r!==void 0&&r<n&&(n=r,o=l),l=e.indexOf(t,h+1);h=c<l&&c>=0?c:l}i.length&&o!==void 0&&(a=[n,o])}return a};var bn="\0SLASH"+Math.random()+"\0",Sn="\0OPEN"+Math.random()+"\0",Li="\0CLOSE"+Math.random()+"\0",En="\0COMMA"+Math.random()+"\0",xn="\0PERIOD"+Math.random()+"\0",fl=new RegExp(bn,"g"),hl=new RegExp(Sn,"g"),ul=new RegExp(Li,"g"),dl=new RegExp(En,"g"),ml=new RegExp(xn,"g"),pl=/\\\\/g,gl=/\\{/g,yl=/\\}/g,wl=/\\,/g,bl=/\\./g,Sl=1e5;function $i(s){return isNaN(s)?s.charCodeAt(0):parseInt(s,10)}function El(s){return s.replace(pl,bn).replace(gl,Sn).replace(yl,Li).replace(wl,En).replace(bl,xn)}function xl(s){return s.replace(fl,"\\").replace(hl,"{").replace(ul,"}").replace(dl,",").replace(ml,".")}function vn(s){if(!s)return[""];let t=[],e=Mi("{","}",s);if(!e)return s.split(",");let{pre:i,body:r,post:n}=e,o=i.split(",");o[o.length-1]+="{"+r+"}";let a=vn(n);return n.length&&(o[o.length-1]+=a.shift(),o.push.apply(o,a)),t.push.apply(t,o),t}function _n(s,t={}){if(!s)return[];let{max:e=Sl}=t;return s.slice(0,2)==="{}"&&(s="\\{\\}"+s.slice(2)),Me(El(s),e,!0).map(xl)}function vl(s){return"{"+s+"}"}function _l(s){return/^-?0\d/.test(s)}function Tl(s,t){return s<=t}function kl(s,t){return s>=t}function Me(s,t,e){let i=[],r=Mi("{","}",s);if(!r)return[s];let n=r.pre,o=r.post.length?Me(r.post,t,!1):[""];if(/\$$/.test(r.pre))for(let a=0;a<o.length&&a<t;a++){let c=n+"{"+r.body+"}"+o[a];i.push(c)}else{let a=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(r.body),c=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(r.body),l=a||c,h=r.body.indexOf(",")>=0;if(!l&&!h)return r.post.match(/,(?!,).*\}/)?(s=r.pre+"{"+r.body+Li+r.post,Me(s,t,!0)):[s];let f;if(l)f=r.body.split(/\.\./);else if(f=vn(r.body),f.length===1&&f[0]!==void 0&&(f=Me(f[0],t,!1).map(vl),f.length===1))return o.map(d=>r.pre+f[0]+d);let u;if(l&&f[0]!==void 0&&f[1]!==void 0){let d=$i(f[0]),m=$i(f[1]),p=Math.max(f[0].length,f[1].length),y=f.length===3&&f[2]!==void 0?Math.abs($i(f[2])):1,g=Tl;m<d&&(y*=-1,g=kl);let x=f.some(_l);u=[];for(let w=d;g(w,m);w+=y){let b;if(c)b=String.fromCharCode(w),b==="\\"&&(b="");else if(b=String(w),x){let I=p-b.length;if(I>0){let it=new Array(I+1).join("0");w<0?b="-"+it+b.slice(1):b=it+b}}u.push(b)}}else{u=[];for(let d=0;d<f.length;d++)u.push.apply(u,Me(f[d],t,!1))}for(let d=0;d<u.length;d++)for(let m=0;m<o.length&&i.length<t;m++){let p=n+u[d]+o[m];(!e||l||p)&&i.push(p)}}return i}var $e=s=>{if(typeof s!="string")throw new TypeError("invalid pattern");if(s.length>65536)throw new TypeError("pattern is too long")};var Al={"[: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]},Le=s=>s.replace(/[[\]\\-]/g,"\\$&"),Ol=s=>s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Tn=s=>s.join(""),kn=(s,t)=>{let e=t;if(s.charAt(e)!=="[")throw new Error("not in a brace expression");let i=[],r=[],n=e+1,o=!1,a=!1,c=!1,l=!1,h=e,f="";t:for(;n<s.length;){let p=s.charAt(n);if((p==="!"||p==="^")&&n===e+1){l=!0,n++;continue}if(p==="]"&&o&&!c){h=n+1;break}if(o=!0,p==="\\"&&!c){c=!0,n++;continue}if(p==="["&&!c){for(let[y,[g,S,x]]of Object.entries(Al))if(s.startsWith(y,n)){if(f)return["$.",!1,s.length-e,!0];n+=y.length,x?r.push(g):i.push(g),a=a||S;continue t}}if(c=!1,f){p>f?i.push(Le(f)+"-"+Le(p)):p===f&&i.push(Le(p)),f="",n++;continue}if(s.startsWith("-]",n+1)){i.push(Le(p+"-")),n+=2;continue}if(s.startsWith("-",n+1)){f=p,n+=2;continue}i.push(Le(p)),n++}if(h<n)return["",!1,0,!1];if(!i.length&&!r.length)return["$.",!1,s.length-e,!0];if(r.length===0&&i.length===1&&/^\\?.$/.test(i[0])&&!l){let p=i[0].length===2?i[0].slice(-1):i[0];return[Ol(p),!1,h-e,!1]}let u="["+(l?"^":"")+Tn(i)+"]",d="["+(l?"":"^")+Tn(r)+"]";return[i.length&&r.length?"("+u+"|"+d+")":i.length?u:d,a,h-e,!0]};var gt=(s,{windowsPathsNoEscape:t=!1,magicalBraces:e=!0}={})=>e?t?s.replace(/\[([^\/\\])\]/g,"$1"):s.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1"):t?s.replace(/\[([^\/\\{}])\]/g,"$1"):s.replace(/((?!\\).|^)\[([^\/\\{}])\]/g,"$1$2").replace(/\\([^\/{}])/g,"$1");var Rl=new Set(["!","?","+","*","@"]),An=s=>Rl.has(s),Cl="(?!(?:^|/)\\.\\.?(?:$|/))",Es="(?!\\.)",Nl=new Set(["[","."]),Pl=new Set(["..","."]),jl=new Set("().*{}+?[]^$\\!"),Dl=s=>s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Wi="[^/]",On=Wi+"*?",Rn=Wi+"+?",ae=class s{type;#t;#s;#n=!1;#r=[];#o;#S;#y;#f=!1;#a;#u;#h=!1;constructor(t,e,i={}){this.type=t,t&&(this.#s=!0),this.#o=e,this.#t=this.#o?this.#o.#t:this,this.#a=this.#t===this?i:this.#t.#a,this.#y=this.#t===this?[]:this.#t.#y,t==="!"&&!this.#t.#f&&this.#y.push(this),this.#S=this.#o?this.#o.#r.length:0}get hasMagic(){if(this.#s!==void 0)return this.#s;for(let t of this.#r)if(typeof t!="string"&&(t.type||t.hasMagic))return this.#s=!0;return this.#s}toString(){return this.#u!==void 0?this.#u:this.type?this.#u=this.type+"("+this.#r.map(t=>String(t)).join("|")+")":this.#u=this.#r.map(t=>String(t)).join("")}#c(){if(this!==this.#t)throw new Error("should only call on root");if(this.#f)return this;this.toString(),this.#f=!0;let t;for(;t=this.#y.pop();){if(t.type!=="!")continue;let e=t,i=e.#o;for(;i;){for(let r=e.#S+1;!i.type&&r<i.#r.length;r++)for(let n of t.#r){if(typeof n=="string")throw new Error("string part in extglob AST??");n.copyIn(i.#r[r])}e=i,i=e.#o}}return this}push(...t){for(let e of t)if(e!==""){if(typeof e!="string"&&!(e instanceof s&&e.#o===this))throw new Error("invalid part: "+e);this.#r.push(e)}}toJSON(){let t=this.type===null?this.#r.slice().map(e=>typeof e=="string"?e:e.toJSON()):[this.type,...this.#r.map(e=>e.toJSON())];return this.isStart()&&!this.type&&t.unshift([]),this.isEnd()&&(this===this.#t||this.#t.#f&&this.#o?.type==="!")&&t.push({}),t}isStart(){if(this.#t===this)return!0;if(!this.#o?.isStart())return!1;if(this.#S===0)return!0;let t=this.#o;for(let e=0;e<this.#S;e++){let i=t.#r[e];if(!(i instanceof s&&i.type==="!"))return!1}return!0}isEnd(){if(this.#t===this||this.#o?.type==="!")return!0;if(!this.#o?.isEnd())return!1;if(!this.type)return this.#o?.isEnd();let t=this.#o?this.#o.#r.length:0;return this.#S===t-1}copyIn(t){typeof t=="string"?this.push(t):this.push(t.clone(this))}clone(t){let e=new s(this.type,t);for(let i of this.#r)e.copyIn(i);return e}static#i(t,e,i,r){let n=!1,o=!1,a=-1,c=!1;if(e.type===null){let d=i,m="";for(;d<t.length;){let p=t.charAt(d++);if(n||p==="\\"){n=!n,m+=p;continue}if(o){d===a+1?(p==="^"||p==="!")&&(c=!0):p==="]"&&!(d===a+2&&c)&&(o=!1),m+=p;continue}else if(p==="["){o=!0,a=d,c=!1,m+=p;continue}if(!r.noext&&An(p)&&t.charAt(d)==="("){e.push(m),m="";let y=new s(p,e);d=s.#i(t,y,d,r),e.push(y);continue}m+=p}return e.push(m),d}let l=i+1,h=new s(null,e),f=[],u="";for(;l<t.length;){let d=t.charAt(l++);if(n||d==="\\"){n=!n,u+=d;continue}if(o){l===a+1?(d==="^"||d==="!")&&(c=!0):d==="]"&&!(l===a+2&&c)&&(o=!1),u+=d;continue}else if(d==="["){o=!0,a=l,c=!1,u+=d;continue}if(An(d)&&t.charAt(l)==="("){h.push(u),u="";let m=new s(d,h);h.push(m),l=s.#i(t,m,l,r);continue}if(d==="|"){h.push(u),u="",f.push(h),h=new s(null,e);continue}if(d===")")return u===""&&e.#r.length===0&&(e.#h=!0),h.push(u),u="",e.push(...f,h),l;u+=d}return e.type=null,e.#s=void 0,e.#r=[t.substring(i-1)],l}static fromGlob(t,e={}){let i=new s(null,void 0,e);return s.#i(t,i,0,e),i}toMMPattern(){if(this!==this.#t)return this.#t.toMMPattern();let t=this.toString(),[e,i,r,n]=this.toRegExpSource();if(!(r||this.#s||this.#a.nocase&&!this.#a.nocaseMagicOnly&&t.toUpperCase()!==t.toLowerCase()))return i;let a=(this.#a.nocase?"i":"")+(n?"u":"");return Object.assign(new RegExp(`^${e}$`,a),{_src:e,_glob:t})}get options(){return this.#a}toRegExpSource(t){let e=t??!!this.#a.dot;if(this.#t===this&&this.#c(),!this.type){let c=this.isStart()&&this.isEnd()&&!this.#r.some(d=>typeof d!="string"),l=this.#r.map(d=>{let[m,p,y,g]=typeof d=="string"?s.#E(d,this.#s,c):d.toRegExpSource(t);return this.#s=this.#s||y,this.#n=this.#n||g,m}).join(""),h="";if(this.isStart()&&typeof this.#r[0]=="string"&&!(this.#r.length===1&&Pl.has(this.#r[0]))){let m=Nl,p=e&&m.has(l.charAt(0))||l.startsWith("\\.")&&m.has(l.charAt(2))||l.startsWith("\\.\\.")&&m.has(l.charAt(4)),y=!e&&!t&&m.has(l.charAt(0));h=p?Cl:y?Es:""}let f="";return this.isEnd()&&this.#t.#f&&this.#o?.type==="!"&&(f="(?:$|\\/)"),[h+l+f,gt(l),this.#s=!!this.#s,this.#n]}let i=this.type==="*"||this.type==="+",r=this.type==="!"?"(?:(?!(?:":"(?:",n=this.#d(e);if(this.isStart()&&this.isEnd()&&!n&&this.type!=="!"){let c=this.toString();return this.#r=[c],this.type=null,this.#s=void 0,[c,gt(this.toString()),!1,!1]}let o=!i||t||e||!Es?"":this.#d(!0);o===n&&(o=""),o&&(n=`(?:${n})(?:${o})*?`);let a="";if(this.type==="!"&&this.#h)a=(this.isStart()&&!e?Es:"")+Rn;else{let c=this.type==="!"?"))"+(this.isStart()&&!e&&!t?Es:"")+On+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&o?")":this.type==="*"&&o?")?":`)${this.type}`;a=r+n+c}return[a,gt(n),this.#s=!!this.#s,this.#n]}#d(t){return this.#r.map(e=>{if(typeof e=="string")throw new Error("string type in extglob ast??");let[i,r,n,o]=e.toRegExpSource(t);return this.#n=this.#n||o,i}).filter(e=>!(this.isStart()&&this.isEnd())||!!e).join("|")}static#E(t,e,i=!1){let r=!1,n="",o=!1;for(let a=0;a<t.length;a++){let c=t.charAt(a);if(r){r=!1,n+=(jl.has(c)?"\\":"")+c;continue}if(c==="\\"){a===t.length-1?n+="\\\\":r=!0;continue}if(c==="["){let[l,h,f,u]=kn(t,a);if(f){n+=l,o=o||h,a+=f-1,e=e||u;continue}}if(c==="*"){n+=i&&t==="*"?Rn:On,e=!0;continue}if(c==="?"){n+=Wi,e=!0;continue}n+=Dl(c)}return[n,gt(t),!!e,o]}};var At=(s,{windowsPathsNoEscape:t=!1,magicalBraces:e=!1}={})=>e?t?s.replace(/[?*()[\]{}]/g,"[$&]"):s.replace(/[?*()[\]\\{}]/g,"\\$&"):t?s.replace(/[?*()[\]]/g,"[$&]"):s.replace(/[?*()[\]\\]/g,"\\$&");var K=(s,t,e={})=>($e(t),!e.nocomment&&t.charAt(0)==="#"?!1:new X(t,e).match(s)),Fl=/^\*+([^+@!?\*\[\(]*)$/,Il=s=>t=>!t.startsWith(".")&&t.endsWith(s),Ml=s=>t=>t.endsWith(s),$l=s=>(s=s.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(s)),Ll=s=>(s=s.toLowerCase(),t=>t.toLowerCase().endsWith(s)),Wl=/^\*+\.\*+$/,Bl=s=>!s.startsWith(".")&&s.includes("."),Ul=s=>s!=="."&&s!==".."&&s.includes("."),zl=/^\.\*+$/,Gl=s=>s!=="."&&s!==".."&&s.startsWith("."),Hl=/^\*+$/,Yl=s=>s.length!==0&&!s.startsWith("."),ql=s=>s.length!==0&&s!=="."&&s!=="..",Vl=/^\?+([^+@!?\*\[\(]*)?$/,Jl=([s,t=""])=>{let e=Pn([s]);return t?(t=t.toLowerCase(),i=>e(i)&&i.toLowerCase().endsWith(t)):e},Kl=([s,t=""])=>{let e=jn([s]);return t?(t=t.toLowerCase(),i=>e(i)&&i.toLowerCase().endsWith(t)):e},Xl=([s,t=""])=>{let e=jn([s]);return t?i=>e(i)&&i.endsWith(t):e},Zl=([s,t=""])=>{let e=Pn([s]);return t?i=>e(i)&&i.endsWith(t):e},Pn=([s])=>{let t=s.length;return e=>e.length===t&&!e.startsWith(".")},jn=([s])=>{let t=s.length;return e=>e.length===t&&e!=="."&&e!==".."},Dn=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",Cn={win32:{sep:"\\"},posix:{sep:"/"}},Ql=Dn==="win32"?Cn.win32.sep:Cn.posix.sep;K.sep=Ql;var U=Symbol("globstar **");K.GLOBSTAR=U;var tf="[^/]",ef=tf+"*?",sf="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",rf="(?:(?!(?:\\/|^)\\.).)*?",nf=(s,t={})=>e=>K(e,s,t);K.filter=nf;var at=(s,t={})=>Object.assign({},s,t),of=s=>{if(!s||typeof s!="object"||!Object.keys(s).length)return K;let t=K;return Object.assign((i,r,n={})=>t(i,r,at(s,n)),{Minimatch:class extends t.Minimatch{constructor(r,n={}){super(r,at(s,n))}static defaults(r){return t.defaults(at(s,r)).Minimatch}},AST:class extends t.AST{constructor(r,n,o={}){super(r,n,at(s,o))}static fromGlob(r,n={}){return t.AST.fromGlob(r,at(s,n))}},unescape:(i,r={})=>t.unescape(i,at(s,r)),escape:(i,r={})=>t.escape(i,at(s,r)),filter:(i,r={})=>t.filter(i,at(s,r)),defaults:i=>t.defaults(at(s,i)),makeRe:(i,r={})=>t.makeRe(i,at(s,r)),braceExpand:(i,r={})=>t.braceExpand(i,at(s,r)),match:(i,r,n={})=>t.match(i,r,at(s,n)),sep:t.sep,GLOBSTAR:U})};K.defaults=of;var Fn=(s,t={})=>($e(s),t.nobrace||!/\{(?:(?!\{).)*\}/.test(s)?[s]:_n(s));K.braceExpand=Fn;var af=(s,t={})=>new X(s,t).makeRe();K.makeRe=af;var cf=(s,t,e={})=>{let i=new X(t,e);return s=s.filter(r=>i.match(r)),i.options.nonull&&!s.length&&s.push(t),s};K.match=cf;var Nn=/[?*]|[+@!]\(.*?\)|\[|\]/,lf=s=>s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),X=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;regexp;constructor(t,e={}){$e(t),e=e||{},this.options=e,this.pattern=t,this.platform=e.platform||Dn,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=(...n)=>console.error(...n)),this.debug(this.pattern,this.globSet);let i=this.globSet.map(n=>this.slashSplit(n));this.globParts=this.preprocess(i),this.debug(this.pattern,this.globParts);let r=this.globParts.map((n,o,a)=>{if(this.isWindows&&this.windowsNoMagicRoot){let c=n[0]===""&&n[1]===""&&(n[2]==="?"||!Nn.test(n[2]))&&!Nn.test(n[3]),l=/^[a-z]:/i.test(n[0]);if(c)return[...n.slice(0,4),...n.slice(4).map(h=>this.parse(h))];if(l)return[n[0],...n.slice(1).map(h=>this.parse(h))]}return n.map(c=>this.parse(c))});if(this.debug(this.pattern,r),this.set=r.filter(n=>n.indexOf(!1)===-1),this.isWindows)for(let n=0;n<this.set.length;n++){let o=this.set[n];o[0]===""&&o[1]===""&&this.globParts[n][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 i=0;i<t.length;i++)for(let r=0;r<t[i].length;r++)t[i][r]==="**"&&(t[i][r]="*");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 i=-1;for(;(i=e.indexOf("**",i+1))!==-1;){let r=i;for(;e[r+1]==="**";)r++;r!==i&&e.splice(i,r-i)}return e})}levelOneOptimize(t){return t.map(e=>(e=e.reduce((i,r)=>{let n=i[i.length-1];return r==="**"&&n==="**"?i:r===".."&&n&&n!==".."&&n!=="."&&n!=="**"?(i.pop(),i):(i.push(r),i)},[]),e.length===0?[""]:e))}levelTwoFileOptimize(t){Array.isArray(t)||(t=this.slashSplit(t));let e=!1;do{if(e=!1,!this.preserveMultipleSlashes){for(let r=1;r<t.length-1;r++){let n=t[r];r===1&&n===""&&t[0]===""||(n==="."||n==="")&&(e=!0,t.splice(r,1),r--)}t[0]==="."&&t.length===2&&(t[1]==="."||t[1]==="")&&(e=!0,t.pop())}let i=0;for(;(i=t.indexOf("..",i+1))!==-1;){let r=t[i-1];r&&r!=="."&&r!==".."&&r!=="**"&&(e=!0,t.splice(i-1,2),i-=2)}}while(e);return t.length===0?[""]:t}firstPhasePreProcess(t){let e=!1;do{e=!1;for(let i of t){let r=-1;for(;(r=i.indexOf("**",r+1))!==-1;){let o=r;for(;i[o+1]==="**";)o++;o>r&&i.splice(r+1,o-r);let a=i[r+1],c=i[r+2],l=i[r+3];if(a!==".."||!c||c==="."||c===".."||!l||l==="."||l==="..")continue;e=!0,i.splice(r,1);let h=i.slice(0);h[r]="**",t.push(h),r--}if(!this.preserveMultipleSlashes){for(let o=1;o<i.length-1;o++){let a=i[o];o===1&&a===""&&i[0]===""||(a==="."||a==="")&&(e=!0,i.splice(o,1),o--)}i[0]==="."&&i.length===2&&(i[1]==="."||i[1]==="")&&(e=!0,i.pop())}let n=0;for(;(n=i.indexOf("..",n+1))!==-1;){let o=i[n-1];if(o&&o!=="."&&o!==".."&&o!=="**"){e=!0;let c=n===1&&i[n+1]==="**"?["."]:[];i.splice(n-1,2,...c),i.length===0&&i.push(""),n-=2}}}}while(e);return t}secondPhasePreProcess(t){for(let e=0;e<t.length-1;e++)for(let i=e+1;i<t.length;i++){let r=this.partsMatch(t[e],t[i],!this.preserveMultipleSlashes);if(r){t[e]=[],t[i]=r;break}}return t.filter(e=>e.length)}partsMatch(t,e,i=!1){let r=0,n=0,o=[],a="";for(;r<t.length&&n<e.length;)if(t[r]===e[n])o.push(a==="b"?e[n]:t[r]),r++,n++;else if(i&&t[r]==="**"&&e[n]===t[r+1])o.push(t[r]),r++;else if(i&&e[n]==="**"&&t[r]===e[n+1])o.push(e[n]),n++;else if(t[r]==="*"&&e[n]&&(this.options.dot||!e[n].startsWith("."))&&e[n]!=="**"){if(a==="b")return!1;a="a",o.push(t[r]),r++,n++}else if(e[n]==="*"&&t[r]&&(this.options.dot||!t[r].startsWith("."))&&t[r]!=="**"){if(a==="a")return!1;a="b",o.push(e[n]),r++,n++}else return!1;return t.length===e.length&&o}parseNegate(){if(this.nonegate)return;let t=this.pattern,e=!1,i=0;for(let r=0;r<t.length&&t.charAt(r)==="!";r++)e=!e,i++;i&&(this.pattern=t.slice(i)),this.negate=e}matchOne(t,e,i=!1){let r=this.options;if(this.isWindows){let p=typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]),y=!p&&t[0]===""&&t[1]===""&&t[2]==="?"&&/^[a-z]:$/i.test(t[3]),g=typeof e[0]=="string"&&/^[a-z]:$/i.test(e[0]),S=!g&&e[0]===""&&e[1]===""&&e[2]==="?"&&typeof e[3]=="string"&&/^[a-z]:$/i.test(e[3]),x=y?3:p?0:void 0,w=S?3:g?0:void 0;if(typeof x=="number"&&typeof w=="number"){let[b,I]=[t[x],e[w]];b.toLowerCase()===I.toLowerCase()&&(e[w]=b,w>x?e=e.slice(w):x>w&&(t=t.slice(x)))}}let{optimizationLevel:n=1}=this.options;n>=2&&(t=this.levelTwoFileOptimize(t)),this.debug("matchOne",this,{file:t,pattern:e}),this.debug("matchOne",t.length,e.length);for(var o=0,a=0,c=t.length,l=e.length;o<c&&a<l;o++,a++){this.debug("matchOne loop");var h=e[a],f=t[o];if(this.debug(e,h,f),h===!1)return!1;if(h===U){this.debug("GLOBSTAR",[e,h,f]);var u=o,d=a+1;if(d===l){for(this.debug("** at the end");o<c;o++)if(t[o]==="."||t[o]===".."||!r.dot&&t[o].charAt(0)===".")return!1;return!0}for(;u<c;){var m=t[u];if(this.debug(`
|
|
7
7
|
globstar while`,t,u,e,d,m),this.matchOne(t.slice(u),e.slice(d),i))return this.debug("globstar found match!",u,c,m),!0;if(m==="."||m===".."||!r.dot&&m.charAt(0)==="."){this.debug("dot detected!",t,u,e,d);break}this.debug("globstar swallow a segment, and continue"),u++}return!!(i&&(this.debug(`
|
|
8
|
-
>>> no match, partial?`,t,u,e,d),u===c))}let p;if(typeof h=="string"?(p=f===h,this.debug("string match",h,f,p)):(p=h.test(f),this.debug("pattern match",h,f,p)),!p)return!1}if(o===c&&a===l)return!0;if(o===c)return i;if(a===l)return o===c-1&&t[o]==="";throw new Error("wtf?")}braceExpand(){return Fn(this.pattern,this.options)}parse(t){
|
|
9
|
-
`,n=" "]=i.match(df)||i.match(uf)||[,"",""],o=JSON.parse(i,t);return o&&typeof o=="object"&&(o[$n]=r,o[Mn]=n),o}catch(r){if(typeof s!="string"&&!Buffer.isBuffer(s)){let n=Array.isArray(s)&&s.length===0;throw Object.assign(new TypeError(`Cannot parse ${n?"an empty array":String(s)}`),{code:"EJSONPARSE",systemError:r})}throw new
|
|
8
|
+
>>> no match, partial?`,t,u,e,d),u===c))}let p;if(typeof h=="string"?(p=f===h,this.debug("string match",h,f,p)):(p=h.test(f),this.debug("pattern match",h,f,p)),!p)return!1}if(o===c&&a===l)return!0;if(o===c)return i;if(a===l)return o===c-1&&t[o]==="";throw new Error("wtf?")}braceExpand(){return Fn(this.pattern,this.options)}parse(t){$e(t);let e=this.options;if(t==="**")return U;if(t==="")return"";let i,r=null;(i=t.match(Hl))?r=e.dot?ql:Yl:(i=t.match(Fl))?r=(e.nocase?e.dot?Ll:$l:e.dot?Ml:Il)(i[1]):(i=t.match(Vl))?r=(e.nocase?e.dot?Kl:Jl:e.dot?Xl:Zl)(i):(i=t.match(Wl))?r=e.dot?Ul:Bl:(i=t.match(zl))&&(r=Gl);let n=ae.fromGlob(t,this.options).toMMPattern();return r&&typeof n=="object"&&Reflect.defineProperty(n,"test",{value:r}),n}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,i=e.noglobstar?ef:e.dot?sf:rf,r=new Set(e.nocase?["i"]:[]),n=t.map(c=>{let l=c.map(f=>{if(f instanceof RegExp)for(let u of f.flags.split(""))r.add(u);return typeof f=="string"?lf(f):f===U?U:f._src});l.forEach((f,u)=>{let d=l[u+1],m=l[u-1];f!==U||m===U||(m===void 0?d!==void 0&&d!==U?l[u+1]="(?:\\/|"+i+"\\/)?"+d:l[u]=i:d===void 0?l[u-1]=m+"(?:\\/|\\/"+i+")?":d!==U&&(l[u-1]=m+"(?:\\/|\\/"+i+"\\/)"+d,l[u+1]=U))});let h=l.filter(f=>f!==U);if(this.partial&&h.length>=1){let f=[];for(let u=1;u<=h.length;u++)f.push(h.slice(0,u).join("/"));return"(?:"+f.join("|")+")"}return h.join("/")}).join("|"),[o,a]=t.length>1?["(?:",")"]:["",""];n="^"+o+n+a+"$",this.partial&&(n="^(?:\\/|"+o+n.slice(1,-1)+a+")$"),this.negate&&(n="^(?!"+n+").+$");try{this.regexp=new RegExp(n,[...r].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 i=this.options;this.isWindows&&(t=t.split("\\").join("/"));let r=this.slashSplit(t);this.debug(this.pattern,"split",r);let n=this.set;this.debug(this.pattern,"set",n);let o=r[r.length-1];if(!o)for(let a=r.length-2;!o&&a>=0;a--)o=r[a];for(let a=0;a<n.length;a++){let c=n[a],l=r;if(i.matchBase&&c.length===1&&(l=[o]),this.matchOne(l,c,e))return i.flipNegate?!0:!this.negate}return i.flipNegate?!1:this.negate}static defaults(t){return K.defaults(t).Minimatch}};K.AST=ae;K.Minimatch=X;K.escape=At;K.unescape=gt;var Bi=parseInt(process.env.TSHY_VERBOSE||"0"),xs=[],F=(...s)=>{Bi>=1?console.error(...s):xs.push(s)},_=(...s)=>{Bi>=2?console.error(...s):xs.push(s)},In=(...s)=>{Bi>=1&&console.log(...s)},ce=()=>{for(let s of xs)console.error(...s);xs.length=0};var T=(s,t)=>{F(E.red.bold(s)),t&&F(t.message),ce()};import{readFileSync as pf}from"fs";var ff=s=>Array.from(s).map(t=>"0x"+t.charCodeAt(0).toString(16).toUpperCase().padStart(2,"0")).join(""),hf=(s,t,e)=>{if(!t)return{message:s.message+" while parsing empty string",position:0};let i=s.message.match(/^Unexpected (?:token (.*?))?/i),r=s.message.match(/at positions? (\d+)/),n=/^Unexpected end of JSON|Unterminated string in JSON/i.test(s.message)?t.length-1:r&&r[1]?+r[1]:/is not valid JSON$/.test(s.message)?0:null,o=i&&i[1]?s.message.replace(/^Unexpected token ./,`Unexpected token ${JSON.stringify(i[1])} (${ff(i[1])})`):s.message;if(n!=null){let a=n<=e?0:n-e,c=n+e>=t.length?t.length:n+e,l=(a===0?"":"...")+t.slice(a,c)+(c===t.length?"":"...");return{message:o+` while parsing ${t===l?"":"near "}${JSON.stringify(l)}`,position:n}}else return{message:o+` while parsing '${t.slice(0,e*2)}'`,position:0}},Ui=class extends SyntaxError{code;cause;position;constructor(t,e,i=20,r){let{message:n,position:o}=hf(t,e,i);super(n),this.cause=t,this.position=o,this.code="EJSONPARSE",Error.captureStackTrace(this,r||this.constructor)}get name(){return this.constructor.name}set name(t){}get[Symbol.toStringTag](){return this.constructor.name}},Mn=Symbol.for("indent"),$n=Symbol.for("newline"),uf=/^\s*[{\[]((?:\r?\n)+)([\s\t]*)/,df=/^(?:\{\}|\[\])((?:\r?\n)+)?$/,zi=(s,t,e)=>{let i=mf(String(s));t||(t=void 0),e=e||20;try{let[,r=`
|
|
9
|
+
`,n=" "]=i.match(df)||i.match(uf)||[,"",""],o=JSON.parse(i,t);return o&&typeof o=="object"&&(o[$n]=r,o[Mn]=n),o}catch(r){if(typeof s!="string"&&!Buffer.isBuffer(s)){let n=Array.isArray(s)&&s.length===0;throw Object.assign(new TypeError(`Cannot parse ${n?"an empty array":String(s)}`),{code:"EJSONPARSE",systemError:r})}throw new Ui(r,i,e,zi)}};var mf=s=>String(s).replace(/^\uFEFF/,""),vs=(s,t,e)=>{let i=e===void 0?s[Mn]:e,r=JSON.stringify(s,t,i),n=s[$n]||`
|
|
10
10
|
`;return i?(n===`
|
|
11
11
|
`?r:r.split(`
|
|
12
|
-
`).join(n))+n:r};var gf=s=>!!s&&typeof s=="object"&&!Array.isArray(s),yf=()=>{try{let s=Bi(pf("package.json","utf8"));if(gf(s))return Object.assign(s,{type:s.type==="commonjs"?"commonjs":"module"});throw new Error("Invalid package.json contents: "+xs(s))}catch(s){T("failed to read package.json",s),process.exit(1)}},k=yf();import{readdirSync as wf}from"fs";import{join as bf}from"path/posix";var Ln=(s="src")=>{let t=[],e=wf(s,{withFileTypes:!0});for(let i of e){let r=`./${bf(s,i.name)}`;i.isFile()?t.push(r):i.isDirectory()&&t.push(...Ln(r))}return t},Sf=new Set(Ln()),Ot=Sf;var Ef=s=>s==="commonjs"||s==="esm",Wn=s=>s&&Array.isArray(s)&&s.length&&!s.some(t=>!Ef(t))?!0:(T(`tshy.dialects must be an array including "esm" and/or "commonjs", got: ${JSON.stringify(s)}`),process.exit(1));var Bn=s=>s&&Array.isArray(s)&&s.length&&!s.some(t=>typeof t!="string")?!0:(T(`tshy.exclude must be an array of string glob patterns if defined, got: ${JSON.stringify(s)}`),process.exit(1));import{join as xf}from"node:path/posix";var Un=s=>`./${xf(s)}`;import{join as zn}from"path/posix";var xt=(s,t)=>{if(typeof s=="string")return s;if(typeof s!="object")return;if(s===null)return s;if(Array.isArray(s)){for(let i of s){let r=xt(i,t);if(r||r===null)return r}return}let e=[...t,"node","default"];for(let[i,r]of Object.entries(s))if(e.includes(i)){let n=xt(r,t);if(n||n===null)return n}};var vs=s=>{let t=xt(s,["import"]),e=xt(s,["require"]);return!(t&&zn(t).startsWith("src/")||e&&zn(e).startsWith("src/"))};var Ui=s=>{if(!s||typeof s!="object"||Array.isArray(s))return!1;for(let[t,e]of Object.entries(s)){if(t!=="."&&!t.startsWith("./"))return T(`tshy.exports key must be "." or start with "./", got: ${t}`),process.exit(1);if(typeof e=="string"){s[t]=Un(e);continue}if(typeof e!="object")return T(`tshy.exports ${t} value must be valid package.json exports value, got: ${JSON.stringify(e)}`),process.exit(1);if(!vs(e))return T(`tshy.exports ${t} unbuilt exports must not be in ./src, and exports in src must be string values. got: ${JSON.stringify(e)}`),process.exit(1);s[t]=e}return!0};var vf=(s,t)=>{if(!s||!t)return!1;for(let e of s)if(t.includes(e))return e;return!1},zi=(s,t)=>{for(let e of s){if(typeof e!="string")return T(`${t} must be an array of strings, got: ${e}`),process.exit(1);if(e==="commonjs"||e==="cjs"||e==="esm"||e==="require"||e==="import"||e==="node"||e==="source"||e==="default")return T(`tshy.${t}Dialects must not contain ${JSON.stringify(e)}`),process.exit(1)}return!0},Gn=({commonjsDialects:s,esmDialects:t,sourceDialects:e})=>{if(s===void 0&&t===void 0&&e===void 0)return!0;if(s&&!zi(s,"commonjs")||t&&!zi(t,"esm")||e&&!zi(e,"source"))return!1;for(let[i,r,n,o]of[["commonjsDialects","esmDialects",s,t],["commonjsDialects","sourceDialects",s,e],["esmDialects","sourceDialects",t,e]]){let a=vf(n,o);if(a)return T(`${i} and ${r} must be unique, found ${a} in both lists`),process.exit(1)}return!0};var Hn=s=>{let{imports:t}=s;if(t===void 0)return!0;if(Array.isArray(t)||typeof t!="object")return T(`invalid imports object, must be Record<string, Import>, got: ${JSON.stringify(t)}`),process.exit(1);for(let[e,i]of Object.entries(t)){if(!e.startsWith("#")||e==="#"||e.startsWith("#/"))return T("invalid imports module specifier: "+e),process.exit(1);if(typeof i!="string"&&!vs(i))return T(`unbuilt package.imports ${e} must not be in ./src, and imports in ./src must be string values. got: `+JSON.stringify(i)),process.exit(1)}return!0};import{resolve as _f}from"path";import{readFileSync as Tf}from"node:fs";var Yn=s=>{if(typeof s=="string")try{return Tf(_f(s),"utf8"),!0}catch{}return T(`tshy.project must point to a tsconfig file on disk, got: ${JSON.stringify(s)}`),process.exit(1)};var Gi=(s,t)=>{let e=s[t];return e===void 0||typeof e=="boolean"?!0:(T(`tshy.${t} must be a boolean value if specified, got: `+e),process.exit(1))},kf=s=>!!s&&Array.isArray(s)&&!s.some(t=>typeof t!="string"),Af=s=>!!s&&typeof s=="object"&&(s.exports===void 0||typeof s.exports=="string"||kf(s.exports)||Ui(s.exports))&&(s.dialects===void 0||Wn(s.dialects))&&(s.project===void 0||Yn(s.project))&&(s.exclude===void 0||Bn(s.exclude))&&Gn(s)&&Gi(s,"selfLink")&&Gi(s,"main")&&Gi(s,"liveDev"),Of=(s,t)=>t.some(e=>e.match(s)),qn=s=>Array.isArray(s)?s.map(t=>new X(t.replace(/^\.\//,""))):qn([s]),Rf=(s,t)=>{let e=Af(s.tshy)?s.tshy:{},i=e.exports;if(typeof i=="string"||Array.isArray(i)){let o={},c=qn(i);for(let l of t){if(!Of(l.replace(/^\.\//,""),c))continue;let h=/^\.\/src\/index.([mc]?[jt]s|[jt]sx)$/.test(l)?".":"./"+l.replace(/^\.\/src\//,"").replace(/\.([mc]?[tj]s|[jt]sx)$/,"");o[h]=`./${l}`}Ui(o)?(o["./package.json"]="./package.json",e.exports=o):(F("invalid exports pattern, using default exports"),delete e.exports,i=void 0)}let r={...e},n=r;if(n.imports&&(_(E.cyan.dim("imports")+" moving from tshy config to top level"),s.imports={...s.imports,...n.imports},delete n.imports),Hn(s),!i){let o={"./package.json":"./package.json"};for(let a of t)if(/^\.\/src\/index\.[^\.]+$/.test(a)){o["."]=a;break}r.exports=o,e.exports=o,i=o}return s.tshy={...e,exports:i},r},Cf=Rf(k,Ot),A=Cf;import{fileURLToPath as lh}from"node:url";var Nf=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,Jn=new Set,Hi=typeof process=="object"&&process?process:{},Kn=(s,t,e,i)=>{typeof Hi.emitWarning=="function"?Hi.emitWarning(s,t,e,i):console.error(`[${e}] ${t}: ${s}`)},_s=globalThis.AbortController,Vn=globalThis.AbortSignal;if(typeof _s>"u"){Vn=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(i,r){this._onabort.push(r)}},_s=class{constructor(){t()}signal=new Vn;abort(i){if(!this.signal.aborted){this.signal.reason=i,this.signal.aborted=!0;for(let r of this.signal._onabort)r(i);this.signal.onabort?.(i)}}};let s=Hi.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",t=()=>{s&&(s=!1,Kn("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 Pf=s=>!Jn.has(s);var It=s=>s&&s===Math.floor(s)&&s>0&&isFinite(s),Xn=s=>It(s)?s<=Math.pow(2,8)?Uint8Array:s<=Math.pow(2,16)?Uint16Array:s<=Math.pow(2,32)?Uint32Array:s<=Number.MAX_SAFE_INTEGER?le:null:null,le=class extends Array{constructor(t){super(t),this.fill(0)}},Yi=class s{heap;length;static#t=!1;static create(t){let e=Xn(t);if(!e)return[];s.#t=!0;let i=new s(t,e);return s.#t=!1,i}constructor(t,e){if(!s.#t)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]}},Vt=class s{#t;#s;#n;#r;#o;#S;#y;#f;get perf(){return this.#f}ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#a;#u;#h;#c;#i;#d;#E;#b;#m;#O;#p;#_;#T;#g;#w;#x;#k;#e;#D;static unsafeExposeInternals(t){return{starts:t.#T,ttls:t.#g,autopurgeTimers:t.#w,sizes:t.#_,keyMap:t.#h,keyList:t.#c,valList:t.#i,next:t.#d,prev:t.#E,get head(){return t.#b},get tail(){return t.#m},free:t.#O,isBackgroundFetch:e=>t.#l(e),backgroundFetch:(e,i,r,n)=>t.#U(e,i,r,n),moveToTail:e=>t.#I(e),indexes:e=>t.#C(e),rindexes:e=>t.#N(e),isStale:e=>t.#v(e)}}get max(){return this.#t}get maxSize(){return this.#s}get calculatedSize(){return this.#u}get size(){return this.#a}get fetchMethod(){return this.#S}get memoMethod(){return this.#y}get dispose(){return this.#n}get onInsert(){return this.#r}get disposeAfter(){return this.#o}constructor(t){let{max:e=0,ttl:i,ttlResolution:r=1,ttlAutopurge:n,updateAgeOnGet:o,updateAgeOnHas:a,allowStale:c,dispose:l,onInsert:h,disposeAfter:f,noDisposeOnSet:u,noUpdateTTL:d,maxSize:m=0,maxEntrySize:p=0,sizeCalculation:y,fetchMethod:g,memoMethod:S,noDeleteOnFetchRejection:x,noDeleteOnStaleGet:w,allowStaleOnFetchRejection:b,allowStaleOnFetchAbort:I,ignoreFetchAbort:it,perf:qt}=t;if(qt!==void 0&&typeof qt?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(this.#f=qt??Nf,e!==0&&!It(e))throw new TypeError("max option must be a nonnegative integer");let Dt=e?Xn(e):Array;if(!Dt)throw new Error("invalid max value: "+e);if(this.#t=e,this.#s=m,this.maxEntrySize=p||this.#s,this.sizeCalculation=y,this.sizeCalculation){if(!this.#s&&!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(S!==void 0&&typeof S!="function")throw new TypeError("memoMethod must be a function if defined");if(this.#y=S,g!==void 0&&typeof g!="function")throw new TypeError("fetchMethod must be a function if specified");if(this.#S=g,this.#k=!!g,this.#h=new Map,this.#c=new Array(e).fill(void 0),this.#i=new Array(e).fill(void 0),this.#d=new Dt(e),this.#E=new Dt(e),this.#b=0,this.#m=0,this.#O=Yi.create(e),this.#a=0,this.#u=0,typeof l=="function"&&(this.#n=l),typeof h=="function"&&(this.#r=h),typeof f=="function"?(this.#o=f,this.#p=[]):(this.#o=void 0,this.#p=void 0),this.#x=!!this.#n,this.#D=!!this.#r,this.#e=!!this.#o,this.noDisposeOnSet=!!u,this.noUpdateTTL=!!d,this.noDeleteOnFetchRejection=!!x,this.allowStaleOnFetchRejection=!!b,this.allowStaleOnFetchAbort=!!I,this.ignoreFetchAbort=!!it,this.maxEntrySize!==0){if(this.#s!==0&&!It(this.#s))throw new TypeError("maxSize must be a positive integer if specified");if(!It(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#G()}if(this.allowStale=!!c,this.noDeleteOnStaleGet=!!w,this.updateAgeOnGet=!!o,this.updateAgeOnHas=!!a,this.ttlResolution=It(r)||r===0?r:1,this.ttlAutopurge=!!n,this.ttl=i||0,this.ttl){if(!It(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#P()}if(this.#t===0&&this.ttl===0&&this.#s===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#t&&!this.#s){let Ft="LRU_CACHE_UNBOUNDED";Pf(Ft)&&(Jn.add(Ft),Kn("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",Ft,s))}}getRemainingTTL(t){return this.#h.has(t)?1/0:0}#P(){let t=new le(this.#t),e=new le(this.#t);this.#g=t,this.#T=e;let i=this.ttlAutopurge?new Array(this.#t):void 0;this.#w=i,this.#$=(o,a,c=this.#f.now())=>{if(e[o]=a!==0?c:0,t[o]=a,i?.[o]&&(clearTimeout(i[o]),i[o]=void 0),a!==0&&i){let l=setTimeout(()=>{this.#v(o)&&this.#R(this.#c[o],"expire")},a+1);l.unref&&l.unref(),i[o]=l}},this.#A=o=>{e[o]=t[o]!==0?this.#f.now():0},this.#j=(o,a)=>{if(t[a]){let c=t[a],l=e[a];if(!c||!l)return;o.ttl=c,o.start=l,o.now=r||n();let h=o.now-l;o.remainingTTL=c-h}};let r=0,n=()=>{let o=this.#f.now();if(this.ttlResolution>0){r=o;let a=setTimeout(()=>r=0,this.ttlResolution);a.unref&&a.unref()}return o};this.getRemainingTTL=o=>{let a=this.#h.get(o);if(a===void 0)return 0;let c=t[a],l=e[a];if(!c||!l)return 1/0;let h=(r||n())-l;return c-h},this.#v=o=>{let a=e[o],c=t[o];return!!c&&!!a&&(r||n())-a>c}}#A=()=>{};#j=()=>{};#$=()=>{};#v=()=>!1;#G(){let t=new le(this.#t);this.#u=0,this.#_=t,this.#M=e=>{this.#u-=t[e],t[e]=0},this.#L=(e,i,r,n)=>{if(this.#l(i))return 0;if(!It(r))if(n){if(typeof n!="function")throw new TypeError("sizeCalculation must be a function");if(r=n(i,e),!It(r))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 r},this.#F=(e,i,r)=>{if(t[e]=i,this.#s){let n=this.#s-t[e];for(;this.#u>n;)this.#B(!0)}this.#u+=t[e],r&&(r.entrySize=i,r.totalCalculatedSize=this.#u)}}#M=t=>{};#F=(t,e,i)=>{};#L=(t,e,i,r)=>{if(i||r)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#C({allowStale:t=this.allowStale}={}){if(this.#a)for(let e=this.#m;!(!this.#W(e)||((t||!this.#v(e))&&(yield e),e===this.#b));)e=this.#E[e]}*#N({allowStale:t=this.allowStale}={}){if(this.#a)for(let e=this.#b;!(!this.#W(e)||((t||!this.#v(e))&&(yield e),e===this.#m));)e=this.#d[e]}#W(t){return t!==void 0&&this.#h.get(this.#c[t])===t}*entries(){for(let t of this.#C())this.#i[t]!==void 0&&this.#c[t]!==void 0&&!this.#l(this.#i[t])&&(yield[this.#c[t],this.#i[t]])}*rentries(){for(let t of this.#N())this.#i[t]!==void 0&&this.#c[t]!==void 0&&!this.#l(this.#i[t])&&(yield[this.#c[t],this.#i[t]])}*keys(){for(let t of this.#C()){let e=this.#c[t];e!==void 0&&!this.#l(this.#i[t])&&(yield e)}}*rkeys(){for(let t of this.#N()){let e=this.#c[t];e!==void 0&&!this.#l(this.#i[t])&&(yield e)}}*values(){for(let t of this.#C())this.#i[t]!==void 0&&!this.#l(this.#i[t])&&(yield this.#i[t])}*rvalues(){for(let t of this.#N())this.#i[t]!==void 0&&!this.#l(this.#i[t])&&(yield this.#i[t])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(t,e={}){for(let i of this.#C()){let r=this.#i[i],n=this.#l(r)?r.__staleWhileFetching:r;if(n!==void 0&&t(n,this.#c[i],this))return this.get(this.#c[i],e)}}forEach(t,e=this){for(let i of this.#C()){let r=this.#i[i],n=this.#l(r)?r.__staleWhileFetching:r;n!==void 0&&t.call(e,n,this.#c[i],this)}}rforEach(t,e=this){for(let i of this.#N()){let r=this.#i[i],n=this.#l(r)?r.__staleWhileFetching:r;n!==void 0&&t.call(e,n,this.#c[i],this)}}purgeStale(){let t=!1;for(let e of this.#N({allowStale:!0}))this.#v(e)&&(this.#R(this.#c[e],"expire"),t=!0);return t}info(t){let e=this.#h.get(t);if(e===void 0)return;let i=this.#i[e],r=this.#l(i)?i.__staleWhileFetching:i;if(r===void 0)return;let n={value:r};if(this.#g&&this.#T){let o=this.#g[e],a=this.#T[e];if(o&&a){let c=o-(this.#f.now()-a);n.ttl=c,n.start=Date.now()}}return this.#_&&(n.size=this.#_[e]),n}dump(){let t=[];for(let e of this.#C({allowStale:!0})){let i=this.#c[e],r=this.#i[e],n=this.#l(r)?r.__staleWhileFetching:r;if(n===void 0||i===void 0)continue;let o={value:n};if(this.#g&&this.#T){o.ttl=this.#g[e];let a=this.#f.now()-this.#T[e];o.start=Math.floor(Date.now()-a)}this.#_&&(o.size=this.#_[e]),t.unshift([i,o])}return t}load(t){this.clear();for(let[e,i]of t){if(i.start){let r=Date.now()-i.start;i.start=this.#f.now()-r}this.set(e,i.value,i)}}set(t,e,i={}){if(e===void 0)return this.delete(t),this;let{ttl:r=this.ttl,start:n,noDisposeOnSet:o=this.noDisposeOnSet,sizeCalculation:a=this.sizeCalculation,status:c}=i,{noUpdateTTL:l=this.noUpdateTTL}=i,h=this.#L(t,e,i.size||0,a);if(this.maxEntrySize&&h>this.maxEntrySize)return c&&(c.set="miss",c.maxEntrySizeExceeded=!0),this.#R(t,"set"),this;let f=this.#a===0?void 0:this.#h.get(t);if(f===void 0)f=this.#a===0?this.#m:this.#O.length!==0?this.#O.pop():this.#a===this.#t?this.#B(!1):this.#a,this.#c[f]=t,this.#i[f]=e,this.#h.set(t,f),this.#d[this.#m]=f,this.#E[f]=this.#m,this.#m=f,this.#a++,this.#F(f,h,c),c&&(c.set="add"),l=!1,this.#D&&this.#r?.(e,t,"add");else{this.#I(f);let u=this.#i[f];if(e!==u){if(this.#k&&this.#l(u)){u.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:d}=u;d!==void 0&&!o&&(this.#x&&this.#n?.(d,t,"set"),this.#e&&this.#p?.push([d,t,"set"]))}else o||(this.#x&&this.#n?.(u,t,"set"),this.#e&&this.#p?.push([u,t,"set"]));if(this.#M(f),this.#F(f,h,c),this.#i[f]=e,c){c.set="replace";let d=u&&this.#l(u)?u.__staleWhileFetching:u;d!==void 0&&(c.oldValue=d)}}else c&&(c.set="update");this.#D&&this.onInsert?.(e,t,e===u?"update":"replace")}if(r!==0&&!this.#g&&this.#P(),this.#g&&(l||this.#$(f,r,n),c&&this.#j(c,f)),!o&&this.#e&&this.#p){let u=this.#p,d;for(;d=u?.shift();)this.#o?.(...d)}return this}pop(){try{for(;this.#a;){let t=this.#i[this.#b];if(this.#B(!0),this.#l(t)){if(t.__staleWhileFetching)return t.__staleWhileFetching}else if(t!==void 0)return t}}finally{if(this.#e&&this.#p){let t=this.#p,e;for(;e=t?.shift();)this.#o?.(...e)}}}#B(t){let e=this.#b,i=this.#c[e],r=this.#i[e];return this.#k&&this.#l(r)?r.__abortController.abort(new Error("evicted")):(this.#x||this.#e)&&(this.#x&&this.#n?.(r,i,"evict"),this.#e&&this.#p?.push([r,i,"evict"])),this.#M(e),this.#w?.[e]&&(clearTimeout(this.#w[e]),this.#w[e]=void 0),t&&(this.#c[e]=void 0,this.#i[e]=void 0,this.#O.push(e)),this.#a===1?(this.#b=this.#m=0,this.#O.length=0):this.#b=this.#d[e],this.#h.delete(i),this.#a--,e}has(t,e={}){let{updateAgeOnHas:i=this.updateAgeOnHas,status:r}=e,n=this.#h.get(t);if(n!==void 0){let o=this.#i[n];if(this.#l(o)&&o.__staleWhileFetching===void 0)return!1;if(this.#v(n))r&&(r.has="stale",this.#j(r,n));else return i&&this.#A(n),r&&(r.has="hit",this.#j(r,n)),!0}else r&&(r.has="miss");return!1}peek(t,e={}){let{allowStale:i=this.allowStale}=e,r=this.#h.get(t);if(r===void 0||!i&&this.#v(r))return;let n=this.#i[r];return this.#l(n)?n.__staleWhileFetching:n}#U(t,e,i,r){let n=e===void 0?void 0:this.#i[e];if(this.#l(n))return n;let o=new _s,{signal:a}=i;a?.addEventListener("abort",()=>o.abort(a.reason),{signal:o.signal});let c={signal:o.signal,options:i,context:r},l=(p,y=!1)=>{let{aborted:g}=o.signal,S=i.ignoreFetchAbort&&p!==void 0,x=i.ignoreFetchAbort||!!(i.allowStaleOnFetchAbort&&p!==void 0);if(i.status&&(g&&!y?(i.status.fetchAborted=!0,i.status.fetchError=o.signal.reason,S&&(i.status.fetchAbortIgnored=!0)):i.status.fetchResolved=!0),g&&!S&&!y)return f(o.signal.reason,x);let w=d,b=this.#i[e];return(b===d||S&&y&&b===void 0)&&(p===void 0?w.__staleWhileFetching!==void 0?this.#i[e]=w.__staleWhileFetching:this.#R(t,"fetch"):(i.status&&(i.status.fetchUpdated=!0),this.set(t,p,c.options))),p},h=p=>(i.status&&(i.status.fetchRejected=!0,i.status.fetchError=p),f(p,!1)),f=(p,y)=>{let{aborted:g}=o.signal,S=g&&i.allowStaleOnFetchAbort,x=S||i.allowStaleOnFetchRejection,w=x||i.noDeleteOnFetchRejection,b=d;if(this.#i[e]===d&&(!w||!y&&b.__staleWhileFetching===void 0?this.#R(t,"fetch"):S||(this.#i[e]=b.__staleWhileFetching)),x)return i.status&&b.__staleWhileFetching!==void 0&&(i.status.returnedStale=!0),b.__staleWhileFetching;if(b.__returned===b)throw p},u=(p,y)=>{let g=this.#S?.(t,n,c);g&&g instanceof Promise&&g.then(S=>p(S===void 0?void 0:S),y),o.signal.addEventListener("abort",()=>{(!i.ignoreFetchAbort||i.allowStaleOnFetchAbort)&&(p(void 0),i.allowStaleOnFetchAbort&&(p=S=>l(S,!0)))})};i.status&&(i.status.fetchDispatched=!0);let d=new Promise(u).then(l,h),m=Object.assign(d,{__abortController:o,__staleWhileFetching:n,__returned:void 0});return e===void 0?(this.set(t,m,{...c.options,status:void 0}),e=this.#h.get(t)):this.#i[e]=m,m}#l(t){if(!this.#k)return!1;let e=t;return!!e&&e instanceof Promise&&e.hasOwnProperty("__staleWhileFetching")&&e.__abortController instanceof _s}async fetch(t,e={}){let{allowStale:i=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,ttl:o=this.ttl,noDisposeOnSet:a=this.noDisposeOnSet,size:c=0,sizeCalculation:l=this.sizeCalculation,noUpdateTTL:h=this.noUpdateTTL,noDeleteOnFetchRejection:f=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:u=this.allowStaleOnFetchRejection,ignoreFetchAbort:d=this.ignoreFetchAbort,allowStaleOnFetchAbort:m=this.allowStaleOnFetchAbort,context:p,forceRefresh:y=!1,status:g,signal:S}=e;if(!this.#k)return g&&(g.fetch="get"),this.get(t,{allowStale:i,updateAgeOnGet:r,noDeleteOnStaleGet:n,status:g});let x={allowStale:i,updateAgeOnGet:r,noDeleteOnStaleGet:n,ttl:o,noDisposeOnSet:a,size:c,sizeCalculation:l,noUpdateTTL:h,noDeleteOnFetchRejection:f,allowStaleOnFetchRejection:u,allowStaleOnFetchAbort:m,ignoreFetchAbort:d,status:g,signal:S},w=this.#h.get(t);if(w===void 0){g&&(g.fetch="miss");let b=this.#U(t,w,x,p);return b.__returned=b}else{let b=this.#i[w];if(this.#l(b)){let Ft=i&&b.__staleWhileFetching!==void 0;return g&&(g.fetch="inflight",Ft&&(g.returnedStale=!0)),Ft?b.__staleWhileFetching:b.__returned=b}let I=this.#v(w);if(!y&&!I)return g&&(g.fetch="hit"),this.#I(w),r&&this.#A(w),g&&this.#j(g,w),b;let it=this.#U(t,w,x,p),Dt=it.__staleWhileFetching!==void 0&&i;return g&&(g.fetch=I?"stale":"refresh",Dt&&I&&(g.returnedStale=!0)),Dt?it.__staleWhileFetching:it.__returned=it}}async forceFetch(t,e={}){let i=await this.fetch(t,e);if(i===void 0)throw new Error("fetch() returned undefined");return i}memo(t,e={}){let i=this.#y;if(!i)throw new Error("no memoMethod provided to constructor");let{context:r,forceRefresh:n,...o}=e,a=this.get(t,o);if(!n&&a!==void 0)return a;let c=i(t,a,{options:o,context:r});return this.set(t,c,o),c}get(t,e={}){let{allowStale:i=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,status:o}=e,a=this.#h.get(t);if(a!==void 0){let c=this.#i[a],l=this.#l(c);return o&&this.#j(o,a),this.#v(a)?(o&&(o.get="stale"),l?(o&&i&&c.__staleWhileFetching!==void 0&&(o.returnedStale=!0),i?c.__staleWhileFetching:void 0):(n||this.#R(t,"expire"),o&&i&&(o.returnedStale=!0),i?c:void 0)):(o&&(o.get="hit"),l?c.__staleWhileFetching:(this.#I(a),r&&this.#A(a),c))}else o&&(o.get="miss")}#z(t,e){this.#E[e]=t,this.#d[t]=e}#I(t){t!==this.#m&&(t===this.#b?this.#b=this.#d[t]:this.#z(this.#E[t],this.#d[t]),this.#z(this.#m,t),this.#m=t)}delete(t){return this.#R(t,"delete")}#R(t,e){let i=!1;if(this.#a!==0){let r=this.#h.get(t);if(r!==void 0)if(this.#w?.[r]&&(clearTimeout(this.#w?.[r]),this.#w[r]=void 0),i=!0,this.#a===1)this.#H(e);else{this.#M(r);let n=this.#i[r];if(this.#l(n)?n.__abortController.abort(new Error("deleted")):(this.#x||this.#e)&&(this.#x&&this.#n?.(n,t,e),this.#e&&this.#p?.push([n,t,e])),this.#h.delete(t),this.#c[r]=void 0,this.#i[r]=void 0,r===this.#m)this.#m=this.#E[r];else if(r===this.#b)this.#b=this.#d[r];else{let o=this.#E[r];this.#d[o]=this.#d[r];let a=this.#d[r];this.#E[a]=this.#E[r]}this.#a--,this.#O.push(r)}}if(this.#e&&this.#p?.length){let r=this.#p,n;for(;n=r?.shift();)this.#o?.(...n)}return i}clear(){return this.#H("delete")}#H(t){for(let e of this.#N({allowStale:!0})){let i=this.#i[e];if(this.#l(i))i.__abortController.abort(new Error("deleted"));else{let r=this.#c[e];this.#x&&this.#n?.(i,r,t),this.#e&&this.#p?.push([i,r,t])}}if(this.#h.clear(),this.#i.fill(void 0),this.#c.fill(void 0),this.#g&&this.#T){this.#g.fill(0),this.#T.fill(0);for(let e of this.#w??[])e!==void 0&&clearTimeout(e);this.#w?.fill(void 0)}if(this.#_&&this.#_.fill(0),this.#b=0,this.#m=0,this.#O.length=0,this.#u=0,this.#a=0,this.#e&&this.#p){let e=this.#p,i;for(;i=e?.shift();)this.#o?.(...i)}}};import{posix as zf,win32 as sr}from"node:path";import{fileURLToPath as Gf}from"node:url";import{lstatSync as Hf,readdir as Yf,readdirSync as qf,readlinkSync as Vf,realpathSync as Jf}from"fs";import*as Kf from"node:fs";import{lstat as Zf,readdir as Qf,readlink as th,realpath as eh}from"node:fs/promises";import{EventEmitter as Qi}from"node:events";import so from"node:stream";import{StringDecoder as jf}from"node:string_decoder";var Zn=typeof process=="object"&&process?process:{stdout:null,stderr:null},Df=s=>!!s&&typeof s=="object"&&(s instanceof $t||s instanceof so||Ff(s)||If(s)),Ff=s=>!!s&&typeof s=="object"&&s instanceof Qi&&typeof s.pipe=="function"&&s.pipe!==so.Writable.prototype.pipe,If=s=>!!s&&typeof s=="object"&&s instanceof Qi&&typeof s.write=="function"&&typeof s.end=="function",Rt=Symbol("EOF"),Ct=Symbol("maybeEmitEnd"),Mt=Symbol("emittedEnd"),Ts=Symbol("emittingEnd"),Le=Symbol("emittedError"),ks=Symbol("closed"),Qn=Symbol("read"),As=Symbol("flush"),to=Symbol("flushChunk"),yt=Symbol("encoding"),fe=Symbol("decoder"),M=Symbol("flowing"),We=Symbol("paused"),he=Symbol("resume"),$=Symbol("buffer"),Z=Symbol("pipes"),L=Symbol("bufferLength"),qi=Symbol("bufferPush"),Os=Symbol("bufferShift"),H=Symbol("objectMode"),j=Symbol("destroyed"),Vi=Symbol("error"),Ji=Symbol("emitData"),eo=Symbol("emitEnd"),Ki=Symbol("emitEnd2"),vt=Symbol("async"),Xi=Symbol("abort"),Rs=Symbol("aborted"),Be=Symbol("signal"),Jt=Symbol("dataListeners"),rt=Symbol("discarded"),Ue=s=>Promise.resolve().then(s),Mf=s=>s(),$f=s=>s==="end"||s==="finish"||s==="prefinish",Lf=s=>s instanceof ArrayBuffer||!!s&&typeof s=="object"&&s.constructor&&s.constructor.name==="ArrayBuffer"&&s.byteLength>=0,Wf=s=>!Buffer.isBuffer(s)&&ArrayBuffer.isView(s),Cs=class{src;dest;opts;ondrain;constructor(t,e,i){this.src=t,this.dest=e,this.opts=i,this.ondrain=()=>t[he](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(t){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},Zi=class extends Cs{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(t,e,i){super(t,e,i),this.proxyErrors=r=>e.emit("error",r),t.on("error",this.proxyErrors)}},Bf=s=>!!s.objectMode,Uf=s=>!s.objectMode&&!!s.encoding&&s.encoding!=="buffer",$t=class extends Qi{[M]=!1;[We]=!1;[Z]=[];[$]=[];[H];[yt];[vt];[fe];[Rt]=!1;[Mt]=!1;[Ts]=!1;[ks]=!1;[Le]=null;[L]=0;[j]=!1;[Be];[Rs]=!1;[Jt]=0;[rt]=!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");Bf(e)?(this[H]=!0,this[yt]=null):Uf(e)?(this[yt]=e.encoding,this[H]=!1):(this[H]=!1,this[yt]=null),this[vt]=!!e.async,this[fe]=this[yt]?new jf(this[yt]):null,e&&e.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[$]}),e&&e.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[Z]});let{signal:i}=e;i&&(this[Be]=i,i.aborted?this[Xi]():i.addEventListener("abort",()=>this[Xi]()))}get bufferLength(){return this[L]}get encoding(){return this[yt]}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[H]}set objectMode(t){throw new Error("objectMode must be set at instantiation time")}get async(){return this[vt]}set async(t){this[vt]=this[vt]||!!t}[Xi](){this[Rs]=!0,this.emit("abort",this[Be]?.reason),this.destroy(this[Be]?.reason)}get aborted(){return this[Rs]}set aborted(t){}write(t,e,i){if(this[Rs])return!1;if(this[Rt])throw new Error("write after end");if(this[j])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;typeof e=="function"&&(i=e,e="utf8"),e||(e="utf8");let r=this[vt]?Ue:Mf;if(!this[H]&&!Buffer.isBuffer(t)){if(Wf(t))t=Buffer.from(t.buffer,t.byteOffset,t.byteLength);else if(Lf(t))t=Buffer.from(t);else if(typeof t!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[H]?(this[M]&&this[L]!==0&&this[As](!0),this[M]?this.emit("data",t):this[qi](t),this[L]!==0&&this.emit("readable"),i&&r(i),this[M]):t.length?(typeof t=="string"&&!(e===this[yt]&&!this[fe]?.lastNeed)&&(t=Buffer.from(t,e)),Buffer.isBuffer(t)&&this[yt]&&(t=this[fe].write(t)),this[M]&&this[L]!==0&&this[As](!0),this[M]?this.emit("data",t):this[qi](t),this[L]!==0&&this.emit("readable"),i&&r(i),this[M]):(this[L]!==0&&this.emit("readable"),i&&r(i),this[M])}read(t){if(this[j])return null;if(this[rt]=!1,this[L]===0||t===0||t&&t>this[L])return this[Ct](),null;this[H]&&(t=null),this[$].length>1&&!this[H]&&(this[$]=[this[yt]?this[$].join(""):Buffer.concat(this[$],this[L])]);let e=this[Qn](t||null,this[$][0]);return this[Ct](),e}[Qn](t,e){if(this[H])this[Os]();else{let i=e;t===i.length||t===null?this[Os]():typeof i=="string"?(this[$][0]=i.slice(t),e=i.slice(0,t),this[L]-=t):(this[$][0]=i.subarray(t),e=i.subarray(0,t),this[L]-=t)}return this.emit("data",e),!this[$].length&&!this[Rt]&&this.emit("drain"),e}end(t,e,i){return typeof t=="function"&&(i=t,t=void 0),typeof e=="function"&&(i=e,e="utf8"),t!==void 0&&this.write(t,e),i&&this.once("end",i),this[Rt]=!0,this.writable=!1,(this[M]||!this[We])&&this[Ct](),this}[he](){this[j]||(!this[Jt]&&!this[Z].length&&(this[rt]=!0),this[We]=!1,this[M]=!0,this.emit("resume"),this[$].length?this[As]():this[Rt]?this[Ct]():this.emit("drain"))}resume(){return this[he]()}pause(){this[M]=!1,this[We]=!0,this[rt]=!1}get destroyed(){return this[j]}get flowing(){return this[M]}get paused(){return this[We]}[qi](t){this[H]?this[L]+=1:this[L]+=t.length,this[$].push(t)}[Os](){return this[H]?this[L]-=1:this[L]-=this[$][0].length,this[$].shift()}[As](t=!1){do;while(this[to](this[Os]())&&this[$].length);!t&&!this[$].length&&!this[Rt]&&this.emit("drain")}[to](t){return this.emit("data",t),this[M]}pipe(t,e){if(this[j])return t;this[rt]=!1;let i=this[Mt];return e=e||{},t===Zn.stdout||t===Zn.stderr?e.end=!1:e.end=e.end!==!1,e.proxyErrors=!!e.proxyErrors,i?e.end&&t.end():(this[Z].push(e.proxyErrors?new Zi(this,t,e):new Cs(this,t,e)),this[vt]?Ue(()=>this[he]()):this[he]()),t}unpipe(t){let e=this[Z].find(i=>i.dest===t);e&&(this[Z].length===1?(this[M]&&this[Jt]===0&&(this[M]=!1),this[Z]=[]):this[Z].splice(this[Z].indexOf(e),1),e.unpipe())}addListener(t,e){return this.on(t,e)}on(t,e){let i=super.on(t,e);if(t==="data")this[rt]=!1,this[Jt]++,!this[Z].length&&!this[M]&&this[he]();else if(t==="readable"&&this[L]!==0)super.emit("readable");else if($f(t)&&this[Mt])super.emit(t),this.removeAllListeners(t);else if(t==="error"&&this[Le]){let r=e;this[vt]?Ue(()=>r.call(this,this[Le])):r.call(this,this[Le])}return i}removeListener(t,e){return this.off(t,e)}off(t,e){let i=super.off(t,e);return t==="data"&&(this[Jt]=this.listeners("data").length,this[Jt]===0&&!this[rt]&&!this[Z].length&&(this[M]=!1)),i}removeAllListeners(t){let e=super.removeAllListeners(t);return(t==="data"||t===void 0)&&(this[Jt]=0,!this[rt]&&!this[Z].length&&(this[M]=!1)),e}get emittedEnd(){return this[Mt]}[Ct](){!this[Ts]&&!this[Mt]&&!this[j]&&this[$].length===0&&this[Rt]&&(this[Ts]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[ks]&&this.emit("close"),this[Ts]=!1)}emit(t,...e){let i=e[0];if(t!=="error"&&t!=="close"&&t!==j&&this[j])return!1;if(t==="data")return!this[H]&&!i?!1:this[vt]?(Ue(()=>this[Ji](i)),!0):this[Ji](i);if(t==="end")return this[eo]();if(t==="close"){if(this[ks]=!0,!this[Mt]&&!this[j])return!1;let n=super.emit("close");return this.removeAllListeners("close"),n}else if(t==="error"){this[Le]=i,super.emit(Vi,i);let n=!this[Be]||this.listeners("error").length?super.emit("error",i):!1;return this[Ct](),n}else if(t==="resume"){let n=super.emit("resume");return this[Ct](),n}else if(t==="finish"||t==="prefinish"){let n=super.emit(t);return this.removeAllListeners(t),n}let r=super.emit(t,...e);return this[Ct](),r}[Ji](t){for(let i of this[Z])i.dest.write(t)===!1&&this.pause();let e=this[rt]?!1:super.emit("data",t);return this[Ct](),e}[eo](){return this[Mt]?!1:(this[Mt]=!0,this.readable=!1,this[vt]?(Ue(()=>this[Ki]()),!0):this[Ki]())}[Ki](){if(this[fe]){let e=this[fe].end();if(e){for(let i of this[Z])i.dest.write(e);this[rt]||super.emit("data",e)}}for(let e of this[Z])e.end();let t=super.emit("end");return this.removeAllListeners("end"),t}async collect(){let t=Object.assign([],{dataLength:0});this[H]||(t.dataLength=0);let e=this.promise();return this.on("data",i=>{t.push(i),this[H]||(t.dataLength+=i.length)}),await e,t}async concat(){if(this[H])throw new Error("cannot concat in objectMode");let t=await this.collect();return this[yt]?t.join(""):Buffer.concat(t,t.dataLength)}async promise(){return new Promise((t,e)=>{this.on(j,()=>e(new Error("stream destroyed"))),this.on("error",i=>e(i)),this.on("end",()=>t())})}[Symbol.asyncIterator](){this[rt]=!1;let t=!1,e=async()=>(this.pause(),t=!0,{value:void 0,done:!0});return{next:()=>{if(t)return e();let r=this.read();if(r!==null)return Promise.resolve({done:!1,value:r});if(this[Rt])return e();let n,o,a=f=>{this.off("data",c),this.off("end",l),this.off(j,h),e(),o(f)},c=f=>{this.off("error",a),this.off("end",l),this.off(j,h),this.pause(),n({value:f,done:!!this[Rt]})},l=()=>{this.off("error",a),this.off("data",c),this.off(j,h),e(),n({done:!0,value:void 0})},h=()=>a(new Error("stream destroyed"));return new Promise((f,u)=>{o=u,n=f,this.once(j,h),this.once("error",a),this.once("end",l),this.once("data",c)})},throw:e,return:e,[Symbol.asyncIterator](){return this}}}[Symbol.iterator](){this[rt]=!1;let t=!1,e=()=>(this.pause(),this.off(Vi,e),this.off(j,e),this.off("end",e),t=!0,{done:!0,value:void 0}),i=()=>{if(t)return e();let r=this.read();return r===null?e():{done:!1,value:r}};return this.once("end",e),this.once(Vi,e),this.once(j,e),{next:i,throw:e,return:e,[Symbol.iterator](){return this}}}destroy(t){if(this[j])return t?this.emit("error",t):this.emit(j),this;this[j]=!0,this[rt]=!0,this[$].length=0,this[L]=0;let e=this;return typeof e.close=="function"&&!this[ks]&&e.close(),t?this.emit("error",t):this.emit(j),this}static get isStream(){return Df}};var Xf=Jf.native,Ge={lstatSync:Hf,readdir:Yf,readdirSync:qf,readlinkSync:Vf,realpathSync:Xf,promises:{lstat:Zf,readdir:Qf,readlink:th,realpath:eh}},ao=s=>!s||s===Ge||s===Kf?Ge:{...Ge,...s,promises:{...Ge.promises,...s.promises||{}}},co=/^\\\\\?\\([a-z]:)\\?$/i,sh=s=>s.replace(/\//g,"\\").replace(co,"$1\\"),ih=/[\\\/]/,lt=0,lo=1,fo=2,_t=4,ho=6,uo=8,Kt=10,mo=12,ct=15,ze=~ct,tr=16,io=32,He=64,wt=128,Ns=256,js=512,ro=He|wt|js,rh=1023,er=s=>s.isFile()?uo:s.isDirectory()?_t:s.isSymbolicLink()?Kt:s.isCharacterDevice()?fo:s.isBlockDevice()?ho:s.isSocket()?mo:s.isFIFO()?lo:lt,no=new Vt({max:2**12}),Ye=s=>{let t=no.get(s);if(t)return t;let e=s.normalize("NFKD");return no.set(s,e),e},oo=new Vt({max:2**12}),Ps=s=>{let t=oo.get(s);if(t)return t;let e=Ye(s.toLowerCase());return oo.set(s,e),e},Ds=class extends Vt{constructor(){super({max:256})}},ir=class extends Vt{constructor(t=16*1024){super({maxSize:t,sizeCalculation:e=>e.length+1})}},po=Symbol("PathScurry setAsCwd"),Y=class{name;root;roots;parent;nocase;isCWD=!1;#t;#s;get dev(){return this.#s}#n;get mode(){return this.#n}#r;get nlink(){return this.#r}#o;get uid(){return this.#o}#S;get gid(){return this.#S}#y;get rdev(){return this.#y}#f;get blksize(){return this.#f}#a;get ino(){return this.#a}#u;get size(){return this.#u}#h;get blocks(){return this.#h}#c;get atimeMs(){return this.#c}#i;get mtimeMs(){return this.#i}#d;get ctimeMs(){return this.#d}#E;get birthtimeMs(){return this.#E}#b;get atime(){return this.#b}#m;get mtime(){return this.#m}#O;get ctime(){return this.#O}#p;get birthtime(){return this.#p}#_;#T;#g;#w;#x;#k;#e;#D;#P;#A;get parentPath(){return(this.parent||this).fullpath()}get path(){return this.parentPath}constructor(t,e=lt,i,r,n,o,a){this.name=t,this.#_=n?Ps(t):Ye(t),this.#e=e&rh,this.nocase=n,this.roots=r,this.root=i||this,this.#D=o,this.#g=a.fullpath,this.#x=a.relative,this.#k=a.relativePosix,this.parent=a.parent,this.parent?this.#t=this.parent.#t:this.#t=ao(a.fs)}depth(){return this.#T!==void 0?this.#T:this.parent?this.#T=this.parent.depth()+1:this.#T=0}childrenCache(){return this.#D}resolve(t){if(!t)return this;let e=this.getRootString(t),r=t.substring(e.length).split(this.splitSep);return e?this.getRoot(e).#j(r):this.#j(r)}#j(t){let e=this;for(let i of t)e=e.child(i);return e}children(){let t=this.#D.get(this);if(t)return t;let e=Object.assign([],{provisional:0});return this.#D.set(this,e),this.#e&=~tr,e}child(t,e){if(t===""||t===".")return this;if(t==="..")return this.parent||this;let i=this.children(),r=this.nocase?Ps(t):Ye(t);for(let c of i)if(c.#_===r)return c;let n=this.parent?this.sep:"",o=this.#g?this.#g+n+t:void 0,a=this.newChild(t,lt,{...e,parent:this,fullpath:o});return this.canReaddir()||(a.#e|=wt),i.push(a),a}relative(){if(this.isCWD)return"";if(this.#x!==void 0)return this.#x;let t=this.name,e=this.parent;if(!e)return this.#x=this.name;let i=e.relative();return i+(!i||!e.parent?"":this.sep)+t}relativePosix(){if(this.sep==="/")return this.relative();if(this.isCWD)return"";if(this.#k!==void 0)return this.#k;let t=this.name,e=this.parent;if(!e)return this.#k=this.fullpathPosix();let i=e.relativePosix();return i+(!i||!e.parent?"":"/")+t}fullpath(){if(this.#g!==void 0)return this.#g;let t=this.name,e=this.parent;if(!e)return this.#g=this.name;let r=e.fullpath()+(e.parent?this.sep:"")+t;return this.#g=r}fullpathPosix(){if(this.#w!==void 0)return this.#w;if(this.sep==="/")return this.#w=this.fullpath();if(!this.parent){let r=this.fullpath().replace(/\\/g,"/");return/^[a-z]:\//i.test(r)?this.#w=`//?/${r}`:this.#w=r}let t=this.parent,e=t.fullpathPosix(),i=e+(!e||!t.parent?"":"/")+this.name;return this.#w=i}isUnknown(){return(this.#e&ct)===lt}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.#e&ct)===uo}isDirectory(){return(this.#e&ct)===_t}isCharacterDevice(){return(this.#e&ct)===fo}isBlockDevice(){return(this.#e&ct)===ho}isFIFO(){return(this.#e&ct)===lo}isSocket(){return(this.#e&ct)===mo}isSymbolicLink(){return(this.#e&Kt)===Kt}lstatCached(){return this.#e&io?this:void 0}readlinkCached(){return this.#P}realpathCached(){return this.#A}readdirCached(){let t=this.children();return t.slice(0,t.provisional)}canReadlink(){if(this.#P)return!0;if(!this.parent)return!1;let t=this.#e&ct;return!(t!==lt&&t!==Kt||this.#e&Ns||this.#e&wt)}calledReaddir(){return!!(this.#e&tr)}isENOENT(){return!!(this.#e&wt)}isNamed(t){return this.nocase?this.#_===Ps(t):this.#_===Ye(t)}async readlink(){let t=this.#P;if(t)return t;if(this.canReadlink()&&this.parent)try{let e=await this.#t.promises.readlink(this.fullpath()),i=(await this.parent.realpath())?.resolve(e);if(i)return this.#P=i}catch(e){this.#N(e.code);return}}readlinkSync(){let t=this.#P;if(t)return t;if(this.canReadlink()&&this.parent)try{let e=this.#t.readlinkSync(this.fullpath()),i=this.parent.realpathSync()?.resolve(e);if(i)return this.#P=i}catch(e){this.#N(e.code);return}}#$(t){this.#e|=tr;for(let e=t.provisional;e<t.length;e++){let i=t[e];i&&i.#v()}}#v(){this.#e&wt||(this.#e=(this.#e|wt)&ze,this.#G())}#G(){let t=this.children();t.provisional=0;for(let e of t)e.#v()}#M(){this.#e|=js,this.#F()}#F(){if(this.#e&He)return;let t=this.#e;(t&ct)===_t&&(t&=ze),this.#e=t|He,this.#G()}#L(t=""){t==="ENOTDIR"||t==="EPERM"?this.#F():t==="ENOENT"?this.#v():this.children().provisional=0}#C(t=""){t==="ENOTDIR"?this.parent.#F():t==="ENOENT"&&this.#v()}#N(t=""){let e=this.#e;e|=Ns,t==="ENOENT"&&(e|=wt),(t==="EINVAL"||t==="UNKNOWN")&&(e&=ze),this.#e=e,t==="ENOTDIR"&&this.parent&&this.parent.#F()}#W(t,e){return this.#U(t,e)||this.#B(t,e)}#B(t,e){let i=er(t),r=this.newChild(t.name,i,{parent:this}),n=r.#e&ct;return n!==_t&&n!==Kt&&n!==lt&&(r.#e|=He),e.unshift(r),e.provisional++,r}#U(t,e){for(let i=e.provisional;i<e.length;i++){let r=e[i];if((this.nocase?Ps(t.name):Ye(t.name))===r.#_)return this.#l(t,r,i,e)}}#l(t,e,i,r){let n=e.name;return e.#e=e.#e&ze|er(t),n!==t.name&&(e.name=t.name),i!==r.provisional&&(i===r.length-1?r.pop():r.splice(i,1),r.unshift(e)),r.provisional++,e}async lstat(){if((this.#e&wt)===0)try{return this.#z(await this.#t.promises.lstat(this.fullpath())),this}catch(t){this.#C(t.code)}}lstatSync(){if((this.#e&wt)===0)try{return this.#z(this.#t.lstatSync(this.fullpath())),this}catch(t){this.#C(t.code)}}#z(t){let{atime:e,atimeMs:i,birthtime:r,birthtimeMs:n,blksize:o,blocks:a,ctime:c,ctimeMs:l,dev:h,gid:f,ino:u,mode:d,mtime:m,mtimeMs:p,nlink:y,rdev:g,size:S,uid:x}=t;this.#b=e,this.#c=i,this.#p=r,this.#E=n,this.#f=o,this.#h=a,this.#O=c,this.#d=l,this.#s=h,this.#S=f,this.#a=u,this.#n=d,this.#m=m,this.#i=p,this.#r=y,this.#y=g,this.#u=S,this.#o=x;let w=er(t);this.#e=this.#e&ze|w|io,w!==lt&&w!==_t&&w!==Kt&&(this.#e|=He)}#I=[];#R=!1;#H(t){this.#R=!1;let e=this.#I.slice();this.#I.length=0,e.forEach(i=>i(null,t))}readdirCB(t,e=!1){if(!this.canReaddir()){e?t(null,[]):queueMicrotask(()=>t(null,[]));return}let i=this.children();if(this.calledReaddir()){let n=i.slice(0,i.provisional);e?t(null,n):queueMicrotask(()=>t(null,n));return}if(this.#I.push(t),this.#R)return;this.#R=!0;let r=this.fullpath();this.#t.readdir(r,{withFileTypes:!0},(n,o)=>{if(n)this.#L(n.code),i.provisional=0;else{for(let a of o)this.#W(a,i);this.#$(i)}this.#H(i.slice(0,i.provisional))})}#Y;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.#Y)await this.#Y;else{let i=()=>{};this.#Y=new Promise(r=>i=r);try{for(let r of await this.#t.promises.readdir(e,{withFileTypes:!0}))this.#W(r,t);this.#$(t)}catch(r){this.#L(r.code),t.provisional=0}this.#Y=void 0,i()}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 i of this.#t.readdirSync(e,{withFileTypes:!0}))this.#W(i,t);this.#$(t)}catch(i){this.#L(i.code),t.provisional=0}return t.slice(0,t.provisional)}canReaddir(){if(this.#e&ro)return!1;let t=ct&this.#e;return t===lt||t===_t||t===Kt}shouldWalk(t,e){return(this.#e&_t)===_t&&!(this.#e&ro)&&!t.has(this)&&(!e||e(this))}async realpath(){if(this.#A)return this.#A;if(!((js|Ns|wt)&this.#e))try{let t=await this.#t.promises.realpath(this.fullpath());return this.#A=this.resolve(t)}catch{this.#M()}}realpathSync(){if(this.#A)return this.#A;if(!((js|Ns|wt)&this.#e))try{let t=this.#t.realpathSync(this.fullpath());return this.#A=this.resolve(t)}catch{this.#M()}}[po](t){if(t===this)return;t.isCWD=!1,this.isCWD=!0;let e=new Set([]),i=[],r=this;for(;r&&r.parent;)e.add(r),r.#x=i.join(this.sep),r.#k=i.join("/"),r=r.parent,i.push("..");for(r=t;r&&r.parent&&!e.has(r);)r.#x=void 0,r.#k=void 0,r=r.parent}},Fs=class s extends Y{sep="\\";splitSep=ih;constructor(t,e=lt,i,r,n,o,a){super(t,e,i,r,n,o,a)}newChild(t,e=lt,i={}){return new s(t,e,this.root,this.roots,this.nocase,this.childrenCache(),i)}getRootString(t){return sr.parse(t).root}getRoot(t){if(t=sh(t.toUpperCase()),t===this.root.name)return this.root;for(let[e,i]of Object.entries(this.roots))if(this.sameRoot(t,e))return this.roots[t]=i;return this.roots[t]=new ue(t,this).root}sameRoot(t,e=this.root.name){return t=t.toUpperCase().replace(/\//g,"\\").replace(co,"$1\\"),t===e}},Is=class s extends Y{splitSep="/";sep="/";constructor(t,e=lt,i,r,n,o,a){super(t,e,i,r,n,o,a)}getRootString(t){return t.startsWith("/")?"/":""}getRoot(t){return this.root}newChild(t,e=lt,i={}){return new s(t,e,this.root,this.roots,this.nocase,this.childrenCache(),i)}},Ms=class{root;rootPath;roots;cwd;#t;#s;#n;nocase;#r;constructor(t=process.cwd(),e,i,{nocase:r,childrenCacheSize:n=16*1024,fs:o=Ge}={}){this.#r=ao(o),(t instanceof URL||t.startsWith("file://"))&&(t=Gf(t));let a=e.resolve(t);this.roots=Object.create(null),this.rootPath=this.parseRootPath(a),this.#t=new Ds,this.#s=new Ds,this.#n=new ir(n);let c=a.substring(this.rootPath.length).split(i);if(c.length===1&&!c[0]&&c.pop(),r===void 0)throw new TypeError("must provide nocase setting to PathScurryBase ctor");this.nocase=r,this.root=this.newRoot(this.#r),this.roots[this.rootPath]=this.root;let l=this.root,h=c.length-1,f=e.sep,u=this.rootPath,d=!1;for(let m of c){let p=h--;l=l.child(m,{relative:new Array(p).fill("..").join(f),relativePosix:new Array(p).fill("..").join("/"),fullpath:u+=(d?"":f)+m}),d=!0}this.cwd=l}depth(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.depth()}childrenCache(){return this.#n}resolve(...t){let e="";for(let n=t.length-1;n>=0;n--){let o=t[n];if(!(!o||o===".")&&(e=e?`${o}/${e}`:o,this.isAbsolute(o)))break}let i=this.#t.get(e);if(i!==void 0)return i;let r=this.cwd.resolve(e).fullpath();return this.#t.set(e,r),r}resolvePosix(...t){let e="";for(let n=t.length-1;n>=0;n--){let o=t[n];if(!(!o||o===".")&&(e=e?`${o}/${e}`:o,this.isAbsolute(o)))break}let i=this.#s.get(e);if(i!==void 0)return i;let r=this.cwd.resolve(e).fullpathPosix();return this.#s.set(e,r),r}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 Y||(e=t,t=this.cwd);let{withFileTypes:i}=e;if(t.canReaddir()){let r=await t.readdir();return i?r:r.map(n=>n.name)}else return[]}readdirSync(t=this.cwd,e={withFileTypes:!0}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof Y||(e=t,t=this.cwd);let{withFileTypes:i=!0}=e;return t.canReaddir()?i?t.readdirSync():t.readdirSync().map(r=>r.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 Y||(e=t.withFileTypes,t=this.cwd);let i=await t.readlink();return e?i:i?.fullpath()}readlinkSync(t=this.cwd,{withFileTypes:e}={withFileTypes:!1}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof Y||(e=t.withFileTypes,t=this.cwd);let i=t.readlinkSync();return e?i:i?.fullpath()}async realpath(t=this.cwd,{withFileTypes:e}={withFileTypes:!1}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof Y||(e=t.withFileTypes,t=this.cwd);let i=await t.realpath();return e?i:i?.fullpath()}realpathSync(t=this.cwd,{withFileTypes:e}={withFileTypes:!1}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof Y||(e=t.withFileTypes,t=this.cwd);let i=t.realpathSync();return e?i:i?.fullpath()}async walk(t=this.cwd,e={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof Y||(e=t,t=this.cwd);let{withFileTypes:i=!0,follow:r=!1,filter:n,walkFilter:o}=e,a=[];(!n||n(t))&&a.push(i?t:t.fullpath());let c=new Set,l=(f,u)=>{c.add(f),f.readdirCB((d,m)=>{if(d)return u(d);let p=m.length;if(!p)return u();let y=()=>{--p===0&&u()};for(let g of m)(!n||n(g))&&a.push(i?g:g.fullpath()),r&&g.isSymbolicLink()?g.realpath().then(S=>S?.isUnknown()?S.lstat():S).then(S=>S?.shouldWalk(c,o)?l(S,y):y()):g.shouldWalk(c,o)?l(g,y):y()},!0)},h=t;return new Promise((f,u)=>{l(h,d=>{if(d)return u(d);f(a)})})}walkSync(t=this.cwd,e={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof Y||(e=t,t=this.cwd);let{withFileTypes:i=!0,follow:r=!1,filter:n,walkFilter:o}=e,a=[];(!n||n(t))&&a.push(i?t:t.fullpath());let c=new Set([t]);for(let l of c){let h=l.readdirSync();for(let f of h){(!n||n(f))&&a.push(i?f:f.fullpath());let u=f;if(f.isSymbolicLink()){if(!(r&&(u=f.realpathSync())))continue;u.isUnknown()&&u.lstatSync()}u.shouldWalk(c,o)&&c.add(u)}}return a}[Symbol.asyncIterator](){return this.iterate()}iterate(t=this.cwd,e={}){return typeof t=="string"?t=this.cwd.resolve(t):t instanceof Y||(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 Y||(e=t,t=this.cwd);let{withFileTypes:i=!0,follow:r=!1,filter:n,walkFilter:o}=e;(!n||n(t))&&(yield i?t:t.fullpath());let a=new Set([t]);for(let c of a){let l=c.readdirSync();for(let h of l){(!n||n(h))&&(yield i?h:h.fullpath());let f=h;if(h.isSymbolicLink()){if(!(r&&(f=h.realpathSync())))continue;f.isUnknown()&&f.lstatSync()}f.shouldWalk(a,o)&&a.add(f)}}}stream(t=this.cwd,e={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof Y||(e=t,t=this.cwd);let{withFileTypes:i=!0,follow:r=!1,filter:n,walkFilter:o}=e,a=new $t({objectMode:!0});(!n||n(t))&&a.write(i?t:t.fullpath());let c=new Set,l=[t],h=0,f=()=>{let u=!1;for(;!u;){let d=l.shift();if(!d){h===0&&a.end();return}h++,c.add(d);let m=(y,g,S=!1)=>{if(y)return a.emit("error",y);if(r&&!S){let x=[];for(let w of g)w.isSymbolicLink()&&x.push(w.realpath().then(b=>b?.isUnknown()?b.lstat():b));if(x.length){Promise.all(x).then(()=>m(null,g,!0));return}}for(let x of g)x&&(!n||n(x))&&(a.write(i?x:x.fullpath())||(u=!0));h--;for(let x of g){let w=x.realpathCached()||x;w.shouldWalk(c,o)&&l.push(w)}u&&!a.flowing?a.once("drain",f):p||f()},p=!0;d.readdirCB(m,!0),p=!1}};return f(),a}streamSync(t=this.cwd,e={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof Y||(e=t,t=this.cwd);let{withFileTypes:i=!0,follow:r=!1,filter:n,walkFilter:o}=e,a=new $t({objectMode:!0}),c=new Set;(!n||n(t))&&a.write(i?t:t.fullpath());let l=[t],h=0,f=()=>{let u=!1;for(;!u;){let d=l.shift();if(!d){h===0&&a.end();return}h++,c.add(d);let m=d.readdirSync();for(let p of m)(!n||n(p))&&(a.write(i?p:p.fullpath())||(u=!0));h--;for(let p of m){let y=p;if(p.isSymbolicLink()){if(!(r&&(y=p.realpathSync())))continue;y.isUnknown()&&y.lstatSync()}y.shouldWalk(c,o)&&l.push(y)}}u&&!a.flowing&&a.once("drain",f)};return f(),a}chdir(t=this.cwd){let e=this.cwd;this.cwd=typeof t=="string"?this.cwd.resolve(t):t,this.cwd[po](e)}},ue=class extends Ms{sep="\\";constructor(t=process.cwd(),e={}){let{nocase:i=!0}=e;super(t,sr,"\\",{...e,nocase:i}),this.nocase=i;for(let r=this.cwd;r;r=r.parent)r.nocase=this.nocase}parseRootPath(t){return sr.parse(t).root.toUpperCase()}newRoot(t){return new Fs(this.rootPath,_t,void 0,this.roots,this.nocase,this.childrenCache(),{fs:t})}isAbsolute(t){return t.startsWith("/")||t.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(t)}},de=class extends Ms{sep="/";constructor(t=process.cwd(),e={}){let{nocase:i=!1}=e;super(t,zf,"/",{...e,nocase:i}),this.nocase=i}parseRootPath(t){return"/"}newRoot(t){return new Is(this.rootPath,_t,void 0,this.roots,this.nocase,this.childrenCache(),{fs:t})}isAbsolute(t){return t.startsWith("/")}},qe=class extends de{constructor(t=process.cwd(),e={}){let{nocase:i=!0}=e;super(t,{...e,nocase:i})}},oy=process.platform==="win32"?Fs:Is,$s=process.platform==="win32"?ue:process.platform==="darwin"?qe:de;var nh=s=>s.length>=1,oh=s=>s.length>=1,me=class s{#t;#s;#n;length;#r;#o;#S;#y;#f;#a;#u=!0;constructor(t,e,i,r){if(!nh(t))throw new TypeError("empty pattern list");if(!oh(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,i<0||i>=this.length)throw new TypeError("index out of range");if(this.#t=t,this.#s=e,this.#n=i,this.#r=r,this.#n===0){if(this.isUNC()){let[n,o,a,c,...l]=this.#t,[h,f,u,d,...m]=this.#s;l[0]===""&&(l.shift(),m.shift());let p=[n,o,a,c,""].join("/"),y=[h,f,u,d,""].join("/");this.#t=[p,...l],this.#s=[y,...m],this.length=this.#t.length}else if(this.isDrive()||this.isAbsolute()){let[n,...o]=this.#t,[a,...c]=this.#s;o[0]===""&&(o.shift(),c.shift());let l=n+"/",h=a+"/";this.#t=[l,...o],this.#s=[h,...c],this.length=this.#t.length}}}pattern(){return this.#t[this.#n]}isString(){return typeof this.#t[this.#n]=="string"}isGlobstar(){return this.#t[this.#n]===U}isRegExp(){return this.#t[this.#n]instanceof RegExp}globString(){return this.#S=this.#S||(this.#n===0?this.isAbsolute()?this.#s[0]+this.#s.slice(1).join("/"):this.#s.join("/"):this.#s.slice(this.#n).join("/"))}hasMore(){return this.length>this.#n+1}rest(){return this.#o!==void 0?this.#o:this.hasMore()?(this.#o=new s(this.#t,this.#s,this.#n+1,this.#r),this.#o.#a=this.#a,this.#o.#f=this.#f,this.#o.#y=this.#y,this.#o):this.#o=null}isUNC(){let t=this.#t;return this.#f!==void 0?this.#f:this.#f=this.#r==="win32"&&this.#n===0&&t[0]===""&&t[1]===""&&typeof t[2]=="string"&&!!t[2]&&typeof t[3]=="string"&&!!t[3]}isDrive(){let t=this.#t;return this.#y!==void 0?this.#y:this.#y=this.#r==="win32"&&this.#n===0&&this.length>1&&typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0])}isAbsolute(){let t=this.#t;return this.#a!==void 0?this.#a:this.#a=t[0]===""&&t.length>1||this.isDrive()||this.isUNC()}root(){let t=this.#t[0];return typeof t=="string"&&this.isAbsolute()&&this.#n===0?t:""}checkFollowGlobstar(){return!(this.#n===0||!this.isGlobstar()||!this.#u)}markFollowGlobstar(){return this.#n===0||!this.isGlobstar()||!this.#u?!1:(this.#u=!1,!0)}};var ah=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",pe=class{relative;relativeChildren;absolute;absoluteChildren;platform;mmopts;constructor(t,{nobrace:e,nocase:i,noext:r,noglobstar:n,platform:o=ah}){this.relative=[],this.absolute=[],this.relativeChildren=[],this.absoluteChildren=[],this.platform=o,this.mmopts={dot:!0,nobrace:e,nocase:i,noext:r,noglobstar:n,optimizationLevel:2,platform:o,nocomment:!0,nonegate:!0};for(let a of t)this.add(a)}add(t){let e=new X(t,this.mmopts);for(let i=0;i<e.set.length;i++){let r=e.set[i],n=e.globParts[i];if(!r||!n)throw new Error("invalid pattern object");for(;r[0]==="."&&n[0]===".";)r.shift(),n.shift();let o=new me(r,n,0,this.platform),a=new X(o.globString(),this.mmopts),c=n[n.length-1]==="**",l=o.isAbsolute();l?this.absolute.push(a):this.relative.push(a),c&&(l?this.absoluteChildren.push(a):this.relativeChildren.push(a))}}ignored(t){let e=t.fullpath(),i=`${e}/`,r=t.relative()||".",n=`${r}/`;for(let o of this.relative)if(o.match(r)||o.match(n))return!0;for(let o of this.absolute)if(o.match(e)||o.match(i))return!0;return!1}childrenIgnored(t){let e=t.fullpath()+"/",i=(t.relative()||".")+"/";for(let r of this.relativeChildren)if(r.match(i))return!0;for(let r of this.absoluteChildren)if(r.match(e))return!0;return!1}};var rr=class s{store;constructor(t=new Map){this.store=t}copy(){return new s(new Map(this.store))}hasWalked(t,e){return this.store.get(t.fullpath())?.has(e.globString())}storeWalked(t,e){let i=t.fullpath(),r=this.store.get(i);r?r.add(e.globString()):this.store.set(i,new Set([e.globString()]))}},nr=class{store=new Map;add(t,e,i){let r=(e?2:0)|(i?1:0),n=this.store.get(t);this.store.set(t,n===void 0?r:r&n)}entries(){return[...this.store.entries()].map(([t,e])=>[t,!!(e&2),!!(e&1)])}},or=class{store=new Map;add(t,e){if(!t.canReaddir())return;let i=this.store.get(t);i?i.find(r=>r.globString()===e.globString())||i.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())}},Ve=class s{hasWalkedCache;matches=new nr;subwalks=new or;patterns;follow;dot;opts;constructor(t,e){this.opts=t,this.follow=!!t.follow,this.dot=!!t.dot,this.hasWalkedCache=e?e.copy():new rr}processPatterns(t,e){this.patterns=e;let i=e.map(r=>[t,r]);for(let[r,n]of i){this.hasWalkedCache.storeWalked(r,n);let o=n.root(),a=n.isAbsolute()&&this.opts.absolute!==!1;if(o){r=r.resolve(o==="/"&&this.opts.root!==void 0?this.opts.root:o);let f=n.rest();if(f)n=f;else{this.matches.add(r,!0,!1);continue}}if(r.isENOENT())continue;let c,l,h=!1;for(;typeof(c=n.pattern())=="string"&&(l=n.rest());)r=r.resolve(c),n=l,h=!0;if(c=n.pattern(),l=n.rest(),h){if(this.hasWalkedCache.hasWalked(r,n))continue;this.hasWalkedCache.storeWalked(r,n)}if(typeof c=="string"){let f=c===".."||c===""||c===".";this.matches.add(r.resolve(c),a,f);continue}else if(c===U){(!r.isSymbolicLink()||this.follow||n.checkFollowGlobstar())&&this.subwalks.add(r,n);let f=l?.pattern(),u=l?.rest();if(!l||(f===""||f===".")&&!u)this.matches.add(r,a,f===""||f===".");else if(f===".."){let d=r.parent||r;u?this.hasWalkedCache.hasWalked(d,u)||this.subwalks.add(d,u):this.matches.add(d,a,!0)}}else c instanceof RegExp&&this.subwalks.add(r,n)}return this}subwalkTargets(){return this.subwalks.keys()}child(){return new s(this.opts,this.hasWalkedCache)}filterEntries(t,e){let i=this.subwalks.get(t),r=this.child();for(let n of e)for(let o of i){let a=o.isAbsolute(),c=o.pattern(),l=o.rest();c===U?r.testGlobstar(n,o,l,a):c instanceof RegExp?r.testRegExp(n,c,l,a):r.testString(n,c,l,a)}return r}testGlobstar(t,e,i,r){if((this.dot||!t.name.startsWith("."))&&(e.hasMore()||this.matches.add(t,r,!1),t.canReaddir()&&(this.follow||!t.isSymbolicLink()?this.subwalks.add(t,e):t.isSymbolicLink()&&(i&&e.checkFollowGlobstar()?this.subwalks.add(t,i):e.markFollowGlobstar()&&this.subwalks.add(t,e)))),i){let n=i.pattern();if(typeof n=="string"&&n!==".."&&n!==""&&n!==".")this.testString(t,n,i.rest(),r);else if(n===".."){let o=t.parent||t;this.subwalks.add(o,i)}else n instanceof RegExp&&this.testRegExp(t,n,i.rest(),r)}}testRegExp(t,e,i,r){e.test(t.name)&&(i?this.subwalks.add(t,i):this.matches.add(t,r,!1))}testString(t,e,i,r){t.isNamed(e)&&(i?this.subwalks.add(t,i):this.matches.add(t,r,!1))}};var ch=(s,t)=>typeof s=="string"?new pe([s],t):Array.isArray(s)?new pe(s,t):s,Ls=class{path;patterns;opts;seen=new Set;paused=!1;aborted=!1;#t=[];#s;#n;signal;maxDepth;includeChildMatches;constructor(t,e,i){if(this.patterns=t,this.path=e,this.opts=i,this.#n=!i.posix&&i.platform==="win32"?"\\":"/",this.includeChildMatches=i.includeChildMatches!==!1,(i.ignore||!this.includeChildMatches)&&(this.#s=ch(i.ignore??[],i),!this.includeChildMatches&&typeof this.#s.add!="function")){let r="cannot ignore child matches, ignore lacks add() method.";throw new Error(r)}this.maxDepth=i.maxDepth||1/0,i.signal&&(this.signal=i.signal,this.signal.addEventListener("abort",()=>{this.#t.length=0}))}#r(t){return this.seen.has(t)||!!this.#s?.ignored?.(t)}#o(t){return!!this.#s?.childrenIgnored?.(t)}pause(){this.paused=!0}resume(){if(this.signal?.aborted)return;this.paused=!1;let t;for(;!this.paused&&(t=this.#t.shift());)t()}onResume(t){this.signal?.aborted||(this.paused?this.#t.push(t):t())}async matchCheck(t,e){if(e&&this.opts.nodir)return;let i;if(this.opts.realpath){if(i=t.realpathCached()||await t.realpath(),!i)return;t=i}let n=t.isUnknown()||this.opts.stat?await t.lstat():t;if(this.opts.follow&&this.opts.nodir&&n?.isSymbolicLink()){let o=await n.realpath();o&&(o.isUnknown()||this.opts.stat)&&await o.lstat()}return this.matchCheckTest(n,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.#r(t)?t:void 0}matchCheckSync(t,e){if(e&&this.opts.nodir)return;let i;if(this.opts.realpath){if(i=t.realpathCached()||t.realpathSync(),!i)return;t=i}let n=t.isUnknown()||this.opts.stat?t.lstatSync():t;if(this.opts.follow&&this.opts.nodir&&n?.isSymbolicLink()){let o=n.realpathSync();o&&(o?.isUnknown()||this.opts.stat)&&o.lstatSync()}return this.matchCheckTest(n,e)}matchFinish(t,e){if(this.#r(t))return;if(!this.includeChildMatches&&this.#s?.add){let n=`${t.relativePosix()}/**`;this.#s.add(n)}let i=this.opts.absolute===void 0?e:this.opts.absolute;this.seen.add(t);let r=this.opts.mark&&t.isDirectory()?this.#n:"";if(this.opts.withFileTypes)this.matchEmit(t);else if(i){let n=this.opts.posix?t.fullpathPosix():t.fullpath();this.matchEmit(n+r)}else{let n=this.opts.posix?t.relativePosix():t.relative(),o=this.opts.dotRelative&&!n.startsWith(".."+this.#n)?"."+this.#n:"";this.matchEmit(n?o+n+r:"."+r)}}async match(t,e,i){let r=await this.matchCheck(t,i);r&&this.matchFinish(r,e)}matchSync(t,e,i){let r=this.matchCheckSync(t,i);r&&this.matchFinish(r,e)}walkCB(t,e,i){this.signal?.aborted&&i(),this.walkCB2(t,e,new Ve(this.opts),i)}walkCB2(t,e,i,r){if(this.#o(t))return r();if(this.signal?.aborted&&r(),this.paused){this.onResume(()=>this.walkCB2(t,e,i,r));return}i.processPatterns(t,e);let n=1,o=()=>{--n===0&&r()};for(let[a,c,l]of i.matches.entries())this.#r(a)||(n++,this.match(a,c,l).then(()=>o()));for(let a of i.subwalkTargets()){if(this.maxDepth!==1/0&&a.depth()>=this.maxDepth)continue;n++;let c=a.readdirCached();a.calledReaddir()?this.walkCB3(a,c,i,o):a.readdirCB((l,h)=>this.walkCB3(a,h,i,o),!0)}o()}walkCB3(t,e,i,r){i=i.filterEntries(t,e);let n=1,o=()=>{--n===0&&r()};for(let[a,c,l]of i.matches.entries())this.#r(a)||(n++,this.match(a,c,l).then(()=>o()));for(let[a,c]of i.subwalks.entries())n++,this.walkCB2(a,c,i.child(),o);o()}walkCBSync(t,e,i){this.signal?.aborted&&i(),this.walkCB2Sync(t,e,new Ve(this.opts),i)}walkCB2Sync(t,e,i,r){if(this.#o(t))return r();if(this.signal?.aborted&&r(),this.paused){this.onResume(()=>this.walkCB2Sync(t,e,i,r));return}i.processPatterns(t,e);let n=1,o=()=>{--n===0&&r()};for(let[a,c,l]of i.matches.entries())this.#r(a)||this.matchSync(a,c,l);for(let a of i.subwalkTargets()){if(this.maxDepth!==1/0&&a.depth()>=this.maxDepth)continue;n++;let c=a.readdirSync();this.walkCB3Sync(a,c,i,o)}o()}walkCB3Sync(t,e,i,r){i=i.filterEntries(t,e);let n=1,o=()=>{--n===0&&r()};for(let[a,c,l]of i.matches.entries())this.#r(a)||this.matchSync(a,c,l);for(let[a,c]of i.subwalks.entries())n++,this.walkCB2Sync(a,c,i.child(),o);o()}},Je=class extends Ls{matches=new Set;constructor(t,e,i){super(t,e,i)}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}},Ke=class extends Ls{results;constructor(t,e,i){super(t,e,i),this.results=new $t({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 fh=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",bt=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=lh(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(c=>c.replace(/\\/g,"/"))),this.matchBase){if(e.noglobstar)throw new TypeError("base matching requires globstar");t=t.map(c=>c.includes("/")?c:`./**/${c}`)}if(this.pattern=t,this.platform=e.platform||fh,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 c=e.platform==="win32"?ue:e.platform==="darwin"?qe:e.platform?de:$s;this.scurry=new c(this.cwd,{nocase:e.nocase,fs:e.fs})}this.nocase=this.scurry.nocase;let i=this.platform==="darwin"||this.platform==="win32",r={...e,dot:this.dot,matchBase:this.matchBase,nobrace:this.nobrace,nocase:this.nocase,nocaseMagicOnly:i,nocomment:!0,noext:this.noext,nonegate:!0,optimizationLevel:2,platform:this.platform,windowsPathsNoEscape:this.windowsPathsNoEscape,debug:!!this.opts.debug},n=this.pattern.map(c=>new X(c,r)),[o,a]=n.reduce((c,l)=>(c[0].push(...l.set),c[1].push(...l.globParts),c),[[],[]]);this.patterns=o.map((c,l)=>{let h=a[l];if(!h)throw new Error("invalid pattern object");return new me(c,h,0,this.platform)})}async walk(){return[...await new Je(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 Je(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 Ke(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 Ke(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 ar=(s,t={})=>{Array.isArray(s)||(s=[s]);for(let e of s)if(new X(e,t).hasMagic())return!0;return!1};function Ws(s,t={}){return new bt(s,t).streamSync()}function yo(s,t={}){return new bt(s,t).stream()}function Zt(s,t={}){return new bt(s,t).walkSync()}async function go(s,t={}){return new bt(s,t).walk()}function Bs(s,t={}){return new bt(s,t).iterateSync()}function wo(s,t={}){return new bt(s,t).iterate()}var hh=Ws,uh=Object.assign(yo,{sync:Ws}),dh=Bs,mh=Object.assign(wo,{sync:Bs}),ph=Object.assign(Zt,{stream:Ws,iterate:Bs}),Xt=Object.assign(go,{glob:go,globSync:Zt,sync:ph,globStream:yo,stream:uh,globStreamSync:Ws,streamSync:hh,globIterate:wo,iterate:mh,globIterateSync:Bs,iterateSync:dh,Glob:bt,hasMagic:ar,escape:At,unescape:gt});Xt.glob=Xt;import{dirname as bo}from"path";import{mkdir as gh,mkdirSync as yh,stat as wh,statSync as bh}from"fs";var ft=s=>{if(!s)s={mode:511};else if(typeof s=="object")s={mode:511,...s};else if(typeof s=="number")s={mode:s};else if(typeof s=="string")s={mode:parseInt(s,8)};else throw new TypeError("invalid options argument");let t=s,e=s.fs||{};return s.mkdir=s.mkdir||e.mkdir||gh,s.mkdirAsync=s.mkdirAsync?s.mkdirAsync:async(i,r)=>new Promise((n,o)=>t.mkdir(i,r,(a,c)=>a?o(a):n(c))),s.stat=s.stat||e.stat||wh,s.statAsync=s.statAsync?s.statAsync:async i=>new Promise((r,n)=>t.stat(i,(o,a)=>o?n(o):r(a))),s.statSync=s.statSync||e.statSync||bh,s.mkdirSync=s.mkdirSync||e.mkdirSync||yh,t};var Tt=(s,t,e)=>{let i=bo(s),r={...ft(t),recursive:!1};if(i===s)try{return r.mkdirSync(s,r)}catch(n){let o=n;if(o&&o.code!=="EISDIR")throw n;return}try{return r.mkdirSync(s,r),e||s}catch(n){let o=n;if(o&&o.code==="ENOENT")return Tt(s,r,Tt(i,r,e));if(o&&o.code!=="EEXIST"&&o&&o.code!=="EROFS")throw n;try{if(!r.statSync(s).isDirectory())throw n}catch{throw n}}},Nt=Object.assign(async(s,t,e)=>{let i=ft(t);i.recursive=!1;let r=bo(s);return r===s?i.mkdirAsync(s,i).catch(n=>{let o=n;if(o&&o.code!=="EISDIR")throw n}):i.mkdirAsync(s,i).then(()=>e||s,async n=>{let o=n;if(o&&o.code==="ENOENT")return Nt(r,i).then(a=>Nt(s,i,a));if(o&&o.code!=="EEXIST"&&o.code!=="EROFS")throw n;return i.statAsync(s).then(a=>{if(a.isDirectory())return e;throw n},()=>{throw n})})},{sync:Tt});import{dirname as Eo}from"path";import{dirname as So}from"path";var cr=async(s,t,e)=>{if(e!==t)return s.statAsync(t).then(i=>i.isDirectory()?e:void 0,i=>{let r=i;return r&&r.code==="ENOENT"?cr(s,So(t),t):void 0})},lr=(s,t,e)=>{if(e!==t)try{return s.statSync(t).isDirectory()?e:void 0}catch(i){let r=i;return r&&r.code==="ENOENT"?lr(s,So(t),t):void 0}};var ge=(s,t)=>{let e=ft(t);if(e.recursive=!0,Eo(s)===s)return e.mkdirSync(s,e);let r=lr(e,s);try{return e.mkdirSync(s,e),r}catch(n){let o=n;if(o&&o.code==="ENOENT")return Tt(s,e);throw n}},Xe=Object.assign(async(s,t)=>{let e={...ft(t),recursive:!0};return Eo(s)===s?await e.mkdirAsync(s,e):cr(e,s).then(r=>e.mkdirAsync(s,e).then(n=>r||n).catch(n=>{let o=n;if(o&&o.code==="ENOENT")return Nt(s,e);throw n}))},{sync:ge});import{parse as Eh,resolve as xh}from"path";var Sh=process.env.__TESTING_MKDIRP_PLATFORM__||process.platform,fr=s=>{if(/\0/.test(s))throw Object.assign(new TypeError("path must be a string without null bytes"),{path:s,code:"ERR_INVALID_ARG_VALUE"});if(s=xh(s),Sh==="win32"){let t=/[*|"<>?:]/,{root:e}=Eh(s);if(t.test(s.substring(e.length)))throw Object.assign(new Error("Illegal characters in path."),{path:s,code:"EINVAL"})}return s};import{mkdir as vh,mkdirSync as _h}from"fs";var Th=process.env.__TESTING_MKDIRP_NODE_VERSION__||process.version,hr=Th.replace(/^v/,"").split("."),xo=+hr[0]>10||+hr[0]==10&&+hr[1]>=12,Ze=xo?s=>ft(s).mkdirSync===_h:()=>!1,Us=Object.assign(xo?s=>ft(s).mkdir===vh:()=>!1,{sync:Ze});var Pt=(s,t)=>{s=fr(s);let e=ft(t);return Ze(e)?ge(s,e):Tt(s,e)};var ur=Object.assign(async(s,t)=>{s=fr(s);let e=ft(t);return Us(e)?Xe(s,e):Nt(s,e)},{mkdirpSync:Pt,mkdirpNative:Xe,mkdirpNativeSync:ge,mkdirpManual:Nt,mkdirpManualSync:Tt,sync:Pt,native:Xe,nativeSync:ge,manual:Nt,manualSync:Tt,useNative:Us,useNativeSync:Ze});import mu from"node:constants";import{createHash as oa}from"node:crypto";import{chmodSync as aa,copyFileSync as pu,linkSync as gu,readFileSync as ca,readlinkSync as la,symlinkSync as yu,unlinkSync as wu}from"node:fs";import{dirname as is,relative as fa,resolve as ti,sep as bu}from"node:path";var Lt=(s,t)=>typeof s>"u"||typeof s===t,vo=s=>!!s&&typeof s=="object"&&Lt(s.preserveRoot,"boolean")&&Lt(s.tmp,"string")&&Lt(s.maxRetries,"number")&&Lt(s.retryDelay,"number")&&Lt(s.backoff,"number")&&Lt(s.maxBackoff,"number")&&(Lt(s.glob,"boolean")||s.glob&&typeof s.glob=="object")&&Lt(s.filter,"function"),_o=s=>{if(!vo(s))throw new Error("invalid rimraf options")},To=s=>{_o(s);let{glob:t,...e}=s;if(!t)return e;let i=t===!0?s.signal?{signal:s.signal}:{}:s.signal?{signal:s.signal,...t}:t;return{...e,glob:{...i,absolute:!0,withFileTypes:!1}}},ko=(s={})=>To(s),Ao=(s={})=>To(s);import{parse as Oo,resolve as kh}from"path";import{inspect as Ah}from"util";var Oh=(s,t={})=>{let e=typeof s;if(e!=="string"){let r=s&&e==="object"&&s.constructor,o=`The "path" argument must be of type string. Received ${r&&r.name?`an instance of ${r.name}`:e==="object"?Ah(s):`type ${e} ${s}`}`;throw Object.assign(new TypeError(o),{path:s,code:"ERR_INVALID_ARG_TYPE"})}if(/\0/.test(s)){let r="path must be a string without null bytes";throw Object.assign(new TypeError(r),{path:s,code:"ERR_INVALID_ARG_VALUE"})}s=kh(s);let{root:i}=Oo(s);if(s===i&&t.preserveRoot!==!1){let r="refusing to remove root directory without preserveRoot:false";throw Object.assign(new Error(r),{path:s,code:"ERR_PRESERVE_ROOT"})}if(process.platform==="win32"){let r=/[*|"<>?:]/,{root:n}=Oo(s);if(r.test(s.substring(n.length)))throw Object.assign(new Error("Illegal characters in path."),{path:s,code:"EINVAL"})}return s},Qe=Oh;import{readdirSync as Rh}from"fs";import jt from"fs/promises";import{chmodSync as Co,mkdirSync as pw,renameSync as No,rmdirSync as ye,rmSync as Po,statSync as jo,lstatSync as we,unlinkSync as be}from"fs";var Ro=s=>Rh(s,{withFileTypes:!0}),et={chmod:jt.chmod,mkdir:jt.mkdir,readdir:s=>jt.readdir(s,{withFileTypes:!0}),rename:jt.rename,rm:jt.rm,rmdir:jt.rmdir,stat:jt.stat,lstat:jt.lstat,unlink:jt.unlink};import{parse as Fo,resolve as Io}from"path";var{readdir:Ch}=et,Se=s=>Ch(s).catch(t=>t),Ee=s=>{try{return Ro(s)}catch(t){return t}};var Do=s=>!!s&&typeof s=="object",dr=(s,t)=>t in s&&typeof s[t]=="string",mr=s=>Do(s)&&dr(s,"code")&&dr(s,"path"),N=s=>Do(s)&&dr(s,"code")?s.code:null;var Q=async(s,t)=>s.catch(e=>{if(N(e)!=="ENOENT")throw t??e}),tt=(s,t)=>{try{return s()}catch(e){if(N(e)==="ENOENT")return;throw t??e}};var{lstat:Nh,rmdir:Ph,unlink:jh}=et,zs=async(s,t)=>(t?.signal?.throwIfAborted(),await Q(Nh(s).then(e=>Mo(s,t,e)))??!0),Gs=(s,t)=>(t?.signal?.throwIfAborted(),tt(()=>$o(s,t,we(s)))??!0),Mo=async(s,t,e)=>{t?.signal?.throwIfAborted();let i=e.isDirectory()?await Se(s):null;if(!Array.isArray(i)){if(i){if(N(i)==="ENOENT")return!0;if(N(i)!=="ENOTDIR")throw i}return t.filter&&!await t.filter(s,e)?!1:(await Q(jh(s)),!0)}return!(await Promise.all(i.map(n=>Mo(Io(s,n.name),t,n)))).every(n=>n===!0)||t.preserveRoot===!1&&s===Fo(s).root||t.filter&&!await t.filter(s,e)?!1:(await Q(Ph(s)),!0)},$o=(s,t,e)=>{t?.signal?.throwIfAborted();let i=e.isDirectory()?Ee(s):null;if(!Array.isArray(i)){if(i){if(N(i)==="ENOENT")return!0;if(N(i)!=="ENOTDIR")throw i}return t.filter&&!t.filter(s,e)?!1:(tt(()=>be(s)),!0)}let r=!0;for(let n of i){let o=Io(s,n.name);r=$o(o,t,n)&&r}return t.preserveRoot===!1&&s===Fo(s).root||!r||t.filter&&!t.filter(s,e)?!1:(tt(()=>ye(s)),!0)};import{parse as qo,resolve as Vo}from"path";var{chmod:Dh}=et,ts=s=>async t=>{try{return void await Q(s(t))}catch(e){if(N(e)==="EPERM")return await Q(Dh(t,438).then(()=>!0),e)?void await s(t):void 0;throw e}},es=s=>t=>{try{return void tt(()=>s(t))}catch(e){if(N(e)==="EPERM")return tt(()=>(Co(t,438),!0),e)?void s(t):void 0;throw e}};import{setTimeout as Fh}from"timers/promises";var Ih=200,Mh=1.2,Lo=10,Wo=new Set(["EMFILE","ENFILE","EBUSY"]),pr=s=>{let t=async(e,i,r=1,n=0)=>{let o=i.maxBackoff||Ih,a=i.backoff||Mh,c=i.maxRetries||Lo,l=0;for(;;)try{return await s(e)}catch(h){if(mr(h)&&h.path===e&&Wo.has(h.code)){if(r=Math.ceil(r*a),n=r+n,n<o)return await Fh(r),t(e,i,r,n);if(l<c){l++;continue}}throw h}};return t},gr=s=>(e,i)=>{let r=i.maxRetries||Lo,n=0;for(;;)try{return s(e)}catch(o){if(mr(o)&&o.path===e&&Wo.has(o.code)&&n<r){n++;continue}throw o}};import{basename as Hh,parse as qs,resolve as Vs}from"path";import{tmpdir as Ys}from"os";import{parse as Hs,resolve as Bo}from"path";var{stat:$h}=et,Lh=s=>{try{return jo(s).isDirectory()}catch{return!1}},Wh=s=>$h(s).then(t=>t.isDirectory(),()=>!1),Bh=async s=>{let{root:t}=Hs(s),e=Ys(),{root:i}=Hs(e);if(t.toLowerCase()===i.toLowerCase())return e;let r=Bo(t,"/temp");return await Wh(r)?r:t},Uh=s=>{let{root:t}=Hs(s),e=Ys(),{root:i}=Hs(e);if(t.toLowerCase()===i.toLowerCase())return e;let r=Bo(t,"/temp");return Lh(r)?r:t},zh=async()=>Ys(),Gh=()=>Ys(),Uo=process.platform==="win32"?Bh:zh,zo=process.platform==="win32"?Uh:Gh;var{lstat:Yh,rename:qh,unlink:Vh,rmdir:Jh}=et,Yo=s=>`.${Hh(s)}.${Math.random()}`,Kh=ts(Vh),Xh=es(be),Js=async(s,t)=>(t?.signal?.throwIfAborted(),await Q(Yh(s).then(e=>yr(s,t,e)))??!0),yr=async(s,t,e)=>{if(t?.signal?.throwIfAborted(),!t.tmp)return yr(s,{...t,tmp:await Uo(s)},e);if(s===t.tmp&&qs(s).root!==s)throw new Error("cannot delete temp directory used for deletion");let i=e.isDirectory()?await Se(s):null;if(!Array.isArray(i)){if(i){if(N(i)==="ENOENT")return!0;if(N(i)!=="ENOTDIR")throw i}return t.filter&&!await t.filter(s,e)?!1:(await Q(Go(s,t.tmp,Kh)),!0)}return!(await Promise.all(i.map(n=>yr(Vs(s,n.name),t,n)))).every(n=>n===!0)||t.preserveRoot===!1&&s===qs(s).root||t.filter&&!await t.filter(s,e)?!1:(await Q(Go(s,t.tmp,Jh)),!0)},Go=async(s,t,e)=>{let i=Vs(t,Yo(s));return await qh(s,i),await e(i)},Ks=(s,t)=>(t?.signal?.throwIfAborted(),tt(()=>wr(s,t,we(s)))??!0),wr=(s,t,e)=>{if(t?.signal?.throwIfAborted(),!t.tmp)return wr(s,{...t,tmp:zo(s)},e);let i=t.tmp;if(s===t.tmp&&qs(s).root!==s)throw new Error("cannot delete temp directory used for deletion");let r=e.isDirectory()?Ee(s):null;if(!Array.isArray(r)){if(r){if(N(r)==="ENOENT")return!0;if(N(r)!=="ENOTDIR")throw r}return t.filter&&!t.filter(s,e)?!1:(tt(()=>Ho(s,i,Xh)),!0)}let n=!0;for(let o of r){let a=Vs(s,o.name);n=wr(a,t,o)&&n}return!n||t.preserveRoot===!1&&s===qs(s).root||t.filter&&!t.filter(s,e)?!1:(tt(()=>Ho(s,i,ye)),!0)},Ho=(s,t,e)=>{let i=Vs(t,Yo(s));return No(s,i),e(i)};var{unlink:Zh,rmdir:Qh,lstat:tu}=et,eu=pr(ts(Zh)),su=gr(es(be)),iu=pr(ts(Qh)),ru=gr(es(ye)),nu=async(s,{filter:t,...e})=>{e?.signal?.throwIfAborted();try{return await iu(s,e),!0}catch(i){if(N(i)==="ENOTEMPTY")return Js(s,e);throw i}},ou=(s,{filter:t,...e})=>{e?.signal?.throwIfAborted();try{return ru(s,e),!0}catch(i){if(N(i)==="ENOTEMPTY")return Ks(s,e);throw i}},Wt=Symbol("start"),Jo=Symbol("child"),Xs=Symbol("finish"),Zs=async(s,t)=>(t?.signal?.throwIfAborted(),await Q(tu(s).then(e=>br(s,t,e,Wt)))??!0),Qs=(s,t)=>(t?.signal?.throwIfAborted(),tt(()=>Sr(s,t,we(s),Wt))??!0),br=async(s,t,e,i=Wt)=>{t?.signal?.throwIfAborted();let r=e.isDirectory()?await Se(s):null;if(!Array.isArray(r)){if(r){if(N(r)==="ENOENT")return!0;if(N(r)!=="ENOTDIR")throw r}return t.filter&&!await t.filter(s,e)?!1:(await Q(eu(s,t)),!0)}let n=i===Wt?Jo:i,o=(await Promise.all(r.map(a=>br(Vo(s,a.name),t,a,n)))).every(a=>a===!0);if(i===Wt)return br(s,t,e,Xs);if(i===Xs){if(t.preserveRoot===!1&&s===qo(s).root||!o||t.filter&&!await t.filter(s,e))return!1;await Q(nu(s,t))}return!0},Sr=(s,t,e,i=Wt)=>{let r=e.isDirectory()?Ee(s):null;if(!Array.isArray(r)){if(r){if(N(r)==="ENOENT")return!0;if(N(r)!=="ENOTDIR")throw r}return t.filter&&!t.filter(s,e)?!1:(tt(()=>su(s,t)),!0)}let n=!0;for(let o of r){let a=i===Wt?Jo:i,c=Vo(s,o.name);n=Sr(c,t,o,a)&&n}if(i===Wt)return Sr(s,t,e,Xs);if(i===Xs){if(t.preserveRoot===!1&&s===qo(s).root||!n||t.filter&&!t.filter(s,e))return!1;tt(()=>ou(s,t))}return!0};var Er=process.platform==="win32"?Zs:zs,xr=process.platform==="win32"?Qs:Gs;var{rm:au}=et,vr=async(s,t)=>(await au(s,{...t,force:!0,recursive:!0}),!0),_r=(s,t)=>(Po(s,{...t,force:!0,recursive:!0}),!0);var[Ko=0,cu=0]=process.version.replace(/^v/,"").split(".").map(s=>parseInt(s,10)),Xo=Ko>14||Ko===14&&cu>=14,Zo=!Xo||process.platform==="win32"?()=>!1:s=>!s?.signal&&!s?.filter,Qo=!Xo||process.platform==="win32"?()=>!1:s=>!s?.signal&&!s?.filter;var xe=s=>async(t,e)=>{let i=ko(e);return i.glob&&(t=await Xt(t,i.glob)),Array.isArray(t)?!!(await Promise.all(t.map(r=>s(Qe(r,i),i)))).reduce((r,n)=>r&&n,!0):!!await s(Qe(t,i),i)},ve=s=>(t,e)=>{let i=Ao(e);return i.glob&&(t=Zt(t,i.glob)),Array.isArray(t)?!!t.map(r=>s(Qe(r,i),i)).reduce((r,n)=>r&&n,!0):!!s(Qe(t,i),i)},ea=ve(_r),lu=Object.assign(xe(vr),{sync:ea}),sa=ve(xr),fu=Object.assign(xe(Er),{sync:sa}),ia=ve(Qs),hu=Object.assign(xe(Zs),{sync:ia}),ra=ve(Gs),uu=Object.assign(xe(zs),{sync:ra}),na=ve(Ks),du=Object.assign(xe(Js),{sync:na}),st=ve((s,t)=>Qo(t)?_r(s,t):xr(s,t));var ta=xe((s,t)=>Zo(t)?vr(s,t):Er(s,t)),ht=Object.assign(ta,{rimraf:ta,sync:st,rimrafSync:st,manual:fu,manualSync:sa,native:lu,nativeSync:ea,posix:uu,posixSync:ra,windows:hu,windowsSync:ia,moveRemove:du,moveRemoveSync:na});ht.rimraf=ht;var ss=s=>{try{return Pt(s)}catch{return ss(is(s)),st(s),Pt(s)}};var Su=(s,t)=>{if(!(s.isSymbolicLink()||s.isDirectory()||s.isFile())){t.isENOENT()||st(t.fullpath());return}if(s.isSymbolicLink()){let i=la(s.fullpath());if(!t.isENOENT()){if((t.isSymbolicLink()&&la(t.fullpath()))===i)return;st(t.fullpath())}if(ss(is(t.fullpath())),yu(i,t.fullpath()),mu.O_SYMLINK&&s.mode)try{aa(t.fullpath(),s.mode)}catch{}return}if(s.isDirectory())t.isDirectory()||ss(t.fullpath());else{let i=!0;if(!t.isENOENT()&&!t.isFile()?st(t.fullpath()):Eu(s,t)&&(i=!1),i){ss(is(t.fullpath()));try{gu(s.fullpath(),t.fullpath())}catch{pu(s.fullpath(),t.fullpath())}}}let e=s.mode;e&&aa(t.fullpath(),e)};var Eu=(s,t)=>{try{return oa("sha512").update(ca(s.fullpath())).digest("hex")===oa("sha512").update(ca(t.fullpath())).digest("hex")}catch{return!1}},ha=`..${bu}`,xu=(s,t)=>{if(s===t)return!0;let e=fa(s,t),i=fa(s,t);return!e.startsWith(ha)||!i.startsWith(ha)};var ua=(s,t)=>{let e=new $s(s),i=ti(s),r=ti(t);if(is(i)===i||is(r)===r)throw new Error("cannot sync root directory");if(xu(r,i))throw new Error("cannot copy directory into itself or its parent");let[n,o]=[Zt("**",{scurry:e,withFileTypes:!0}),Zt("**",{cwd:r,withFileTypes:!0})];for(let a of n){if(!a.parent)throw new Error("cannot sync root directory");let c=a.resolve(ti(r,a.relative())),l=c.parent;if(!l)throw new Error("cannot sync root directory");c.lstatSync(),ss(l.fullpath()),Su(a,c)}for(let a of o){let c=e.cwd.resolve(ti(i,a.relative()));if(c.lstatSync(),c.isENOENT())try{st(a.fullpath()),wu(a.fullpath())}catch{}}};import{chmodSync as da}from"fs";import{resolve as ma}from"path";var pa=()=>{let{bin:s}=k;if(s)if(typeof s=="string")da(ma(s),493);else for(let t of Object.values(s))da(ma(t),493)};import{spawnSync as Kd}from"node:child_process";import{relative as ac,resolve as Ce}from"node:path/posix";import{writeFileSync as vu}from"fs";var ga=s=>{let{imports:t}=s;if(t)return Object.fromEntries(Object.entries(t).map(([e,i])=>[e,typeof i=="string"&&i.startsWith("./src/")?"./"+i.substring(6).replace(/\.([cm]?)ts$/,".$1js").replace(/\.tsx$/,".js"):i]))};var _u=(s,t)=>{if(!t)return st(`${s}/package.json`);let e={type:t==="commonjs"?"commonjs":"module",imports:ga(k)};vu(`${s}/package.json`,JSON.stringify(e,null,2)+`
|
|
13
|
-
`)},q=(s,t)=>{t&&_(E.cyan.dim("set dialect"),{where:s,mode:t}),_u(s,t)};import{existsSync as sd,readdirSync as id,unlinkSync as rd,writeFileSync as nd}from"node:fs";import{resolve as od}from"node:path";import{join as Da}from"node:path/posix";var{esmDialects:Tu=[],commonjsDialects:ku=[]}=A,
|
|
14
|
-
`&&(m==="|"&&l.length?l=l.alternation=[]:m===")"&&l.length?(a=null,(l=o.pop())||
|
|
12
|
+
`).join(n))+n:r};var gf=s=>!!s&&typeof s=="object"&&!Array.isArray(s),yf=()=>{try{let s=zi(pf("package.json","utf8"));if(gf(s))return Object.assign(s,{type:s.type==="commonjs"?"commonjs":"module"});throw new Error("Invalid package.json contents: "+vs(s))}catch(s){T("failed to read package.json",s),process.exit(1)}},k=yf();import{readdirSync as wf}from"fs";import{join as bf}from"path/posix";var Ln=(s="src")=>{let t=[],e=wf(s,{withFileTypes:!0});for(let i of e){let r=`./${bf(s,i.name)}`;i.isFile()?t.push(r):i.isDirectory()&&t.push(...Ln(r))}return t},Sf=new Set(Ln()),Ot=Sf;var Ef=s=>s==="commonjs"||s==="esm",Wn=s=>s&&Array.isArray(s)&&s.length&&!s.some(t=>!Ef(t))?!0:(T(`tshy.dialects must be an array including "esm" and/or "commonjs", got: ${JSON.stringify(s)}`),process.exit(1));var Bn=s=>s&&Array.isArray(s)&&s.length&&!s.some(t=>typeof t!="string")?!0:(T(`tshy.exclude must be an array of string glob patterns if defined, got: ${JSON.stringify(s)}`),process.exit(1));import{join as xf}from"node:path/posix";var Un=s=>`./${xf(s)}`;import{join as zn}from"path/posix";var xt=(s,t)=>{if(typeof s=="string")return s;if(typeof s!="object")return;if(s===null)return s;if(Array.isArray(s)){for(let i of s){let r=xt(i,t);if(r||r===null)return r}return}let e=[...t,"node","default"];for(let[i,r]of Object.entries(s))if(e.includes(i)){let n=xt(r,t);if(n||n===null)return n}};var _s=s=>{let t=xt(s,["import"]),e=xt(s,["require"]);return!(t&&zn(t).startsWith("src/")||e&&zn(e).startsWith("src/"))};var Gi=s=>{if(!s||typeof s!="object"||Array.isArray(s))return!1;for(let[t,e]of Object.entries(s)){if(t!=="."&&!t.startsWith("./"))return T(`tshy.exports key must be "." or start with "./", got: ${t}`),process.exit(1);if(typeof e=="string"){s[t]=Un(e);continue}if(typeof e!="object")return T(`tshy.exports ${t} value must be valid package.json exports value, got: ${JSON.stringify(e)}`),process.exit(1);if(!_s(e))return T(`tshy.exports ${t} unbuilt exports must not be in ./src, and exports in src must be string values. got: ${JSON.stringify(e)}`),process.exit(1);s[t]=e}return!0};var vf=(s,t)=>{if(!s||!t)return!1;for(let e of s)if(t.includes(e))return e;return!1},Hi=(s,t)=>{for(let e of s){if(typeof e!="string")return T(`${t} must be an array of strings, got: ${e}`),process.exit(1);if(e==="commonjs"||e==="cjs"||e==="esm"||e==="require"||e==="import"||e==="node"||e==="source"||e==="default")return T(`tshy.${t}Dialects must not contain ${JSON.stringify(e)}`),process.exit(1)}return!0},Gn=({commonjsDialects:s,esmDialects:t,sourceDialects:e})=>{if(s===void 0&&t===void 0&&e===void 0)return!0;if(s&&!Hi(s,"commonjs")||t&&!Hi(t,"esm")||e&&!Hi(e,"source"))return!1;for(let[i,r,n,o]of[["commonjsDialects","esmDialects",s,t],["commonjsDialects","sourceDialects",s,e],["esmDialects","sourceDialects",t,e]]){let a=vf(n,o);if(a)return T(`${i} and ${r} must be unique, found ${a} in both lists`),process.exit(1)}return!0};var Hn=s=>{let{imports:t}=s;if(t===void 0)return!0;if(Array.isArray(t)||typeof t!="object")return T(`invalid imports object, must be Record<string, Import>, got: ${JSON.stringify(t)}`),process.exit(1);for(let[e,i]of Object.entries(t)){if(!e.startsWith("#")||e==="#"||e.startsWith("#/"))return T("invalid imports module specifier: "+e),process.exit(1);if(typeof i!="string"&&!_s(i))return T(`unbuilt package.imports ${e} must not be in ./src, and imports in ./src must be string values. got: `+JSON.stringify(i)),process.exit(1)}return!0};import{resolve as _f}from"path";import{readFileSync as Tf}from"node:fs";var Yn=s=>{if(typeof s=="string")try{return Tf(_f(s),"utf8"),!0}catch{}return T(`tshy.project must point to a tsconfig file on disk, got: ${JSON.stringify(s)}`),process.exit(1)};var Yi=(s,t)=>{let e=s[t];return e===void 0||typeof e=="boolean"?!0:(T(`tshy.${t} must be a boolean value if specified, got: `+e),process.exit(1))},kf=s=>!!s&&Array.isArray(s)&&!s.some(t=>typeof t!="string"),Af=s=>!!s&&typeof s=="object"&&(s.exports===void 0||typeof s.exports=="string"||kf(s.exports)||Gi(s.exports))&&(s.dialects===void 0||Wn(s.dialects))&&(s.project===void 0||Yn(s.project))&&(s.exclude===void 0||Bn(s.exclude))&&Gn(s)&&Yi(s,"selfLink")&&Yi(s,"main")&&Yi(s,"liveDev"),Of=(s,t)=>t.some(e=>e.match(s)),qn=s=>Array.isArray(s)?s.map(t=>new X(t.replace(/^\.\//,""))):qn([s]),Rf=(s,t)=>{let e=Af(s.tshy)?s.tshy:{},i=e.exports;if(typeof i=="string"||Array.isArray(i)){let o={},c=qn(i);for(let l of t){if(!Of(l.replace(/^\.\//,""),c))continue;let h=/^\.\/src\/index.([mc]?[jt]s|[jt]sx)$/.test(l)?".":"./"+l.replace(/^\.\/src\//,"").replace(/\.([mc]?[tj]s|[jt]sx)$/,"");o[h]=`./${l}`}Gi(o)?(o["./package.json"]="./package.json",e.exports=o):(F("invalid exports pattern, using default exports"),delete e.exports,i=void 0)}let r={...e},n=r;if(n.imports&&(_(E.cyan.dim("imports")+" moving from tshy config to top level"),s.imports={...s.imports,...n.imports},delete n.imports),Hn(s),!i){let o={"./package.json":"./package.json"};for(let a of t)if(/^\.\/src\/index\.[^\.]+$/.test(a)){o["."]=a;break}r.exports=o,e.exports=o,i=o}return s.tshy={...e,exports:i},r},Cf=Rf(k,Ot),A=Cf;import{fileURLToPath as lh}from"node:url";var Nf=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,Jn=new Set,qi=typeof process=="object"&&process?process:{},Kn=(s,t,e,i)=>{typeof qi.emitWarning=="function"?qi.emitWarning(s,t,e,i):console.error(`[${e}] ${t}: ${s}`)},Ts=globalThis.AbortController,Vn=globalThis.AbortSignal;if(typeof Ts>"u"){Vn=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(i,r){this._onabort.push(r)}},Ts=class{constructor(){t()}signal=new Vn;abort(i){if(!this.signal.aborted){this.signal.reason=i,this.signal.aborted=!0;for(let r of this.signal._onabort)r(i);this.signal.onabort?.(i)}}};let s=qi.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",t=()=>{s&&(s=!1,Kn("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 Pf=s=>!Jn.has(s);var It=s=>s&&s===Math.floor(s)&&s>0&&isFinite(s),Xn=s=>It(s)?s<=Math.pow(2,8)?Uint8Array:s<=Math.pow(2,16)?Uint16Array:s<=Math.pow(2,32)?Uint32Array:s<=Number.MAX_SAFE_INTEGER?le:null:null,le=class extends Array{constructor(t){super(t),this.fill(0)}},Vi=class s{heap;length;static#t=!1;static create(t){let e=Xn(t);if(!e)return[];s.#t=!0;let i=new s(t,e);return s.#t=!1,i}constructor(t,e){if(!s.#t)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]}},Vt=class s{#t;#s;#n;#r;#o;#S;#y;#f;get perf(){return this.#f}ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#a;#u;#h;#c;#i;#d;#E;#b;#m;#O;#p;#_;#T;#g;#w;#x;#k;#e;#D;static unsafeExposeInternals(t){return{starts:t.#T,ttls:t.#g,autopurgeTimers:t.#w,sizes:t.#_,keyMap:t.#h,keyList:t.#c,valList:t.#i,next:t.#d,prev:t.#E,get head(){return t.#b},get tail(){return t.#m},free:t.#O,isBackgroundFetch:e=>t.#l(e),backgroundFetch:(e,i,r,n)=>t.#U(e,i,r,n),moveToTail:e=>t.#I(e),indexes:e=>t.#C(e),rindexes:e=>t.#N(e),isStale:e=>t.#v(e)}}get max(){return this.#t}get maxSize(){return this.#s}get calculatedSize(){return this.#u}get size(){return this.#a}get fetchMethod(){return this.#S}get memoMethod(){return this.#y}get dispose(){return this.#n}get onInsert(){return this.#r}get disposeAfter(){return this.#o}constructor(t){let{max:e=0,ttl:i,ttlResolution:r=1,ttlAutopurge:n,updateAgeOnGet:o,updateAgeOnHas:a,allowStale:c,dispose:l,onInsert:h,disposeAfter:f,noDisposeOnSet:u,noUpdateTTL:d,maxSize:m=0,maxEntrySize:p=0,sizeCalculation:y,fetchMethod:g,memoMethod:S,noDeleteOnFetchRejection:x,noDeleteOnStaleGet:w,allowStaleOnFetchRejection:b,allowStaleOnFetchAbort:I,ignoreFetchAbort:it,perf:qt}=t;if(qt!==void 0&&typeof qt?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(this.#f=qt??Nf,e!==0&&!It(e))throw new TypeError("max option must be a nonnegative integer");let Dt=e?Xn(e):Array;if(!Dt)throw new Error("invalid max value: "+e);if(this.#t=e,this.#s=m,this.maxEntrySize=p||this.#s,this.sizeCalculation=y,this.sizeCalculation){if(!this.#s&&!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(S!==void 0&&typeof S!="function")throw new TypeError("memoMethod must be a function if defined");if(this.#y=S,g!==void 0&&typeof g!="function")throw new TypeError("fetchMethod must be a function if specified");if(this.#S=g,this.#k=!!g,this.#h=new Map,this.#c=new Array(e).fill(void 0),this.#i=new Array(e).fill(void 0),this.#d=new Dt(e),this.#E=new Dt(e),this.#b=0,this.#m=0,this.#O=Vi.create(e),this.#a=0,this.#u=0,typeof l=="function"&&(this.#n=l),typeof h=="function"&&(this.#r=h),typeof f=="function"?(this.#o=f,this.#p=[]):(this.#o=void 0,this.#p=void 0),this.#x=!!this.#n,this.#D=!!this.#r,this.#e=!!this.#o,this.noDisposeOnSet=!!u,this.noUpdateTTL=!!d,this.noDeleteOnFetchRejection=!!x,this.allowStaleOnFetchRejection=!!b,this.allowStaleOnFetchAbort=!!I,this.ignoreFetchAbort=!!it,this.maxEntrySize!==0){if(this.#s!==0&&!It(this.#s))throw new TypeError("maxSize must be a positive integer if specified");if(!It(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#G()}if(this.allowStale=!!c,this.noDeleteOnStaleGet=!!w,this.updateAgeOnGet=!!o,this.updateAgeOnHas=!!a,this.ttlResolution=It(r)||r===0?r:1,this.ttlAutopurge=!!n,this.ttl=i||0,this.ttl){if(!It(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#P()}if(this.#t===0&&this.ttl===0&&this.#s===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#t&&!this.#s){let Ft="LRU_CACHE_UNBOUNDED";Pf(Ft)&&(Jn.add(Ft),Kn("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",Ft,s))}}getRemainingTTL(t){return this.#h.has(t)?1/0:0}#P(){let t=new le(this.#t),e=new le(this.#t);this.#g=t,this.#T=e;let i=this.ttlAutopurge?new Array(this.#t):void 0;this.#w=i,this.#$=(o,a,c=this.#f.now())=>{if(e[o]=a!==0?c:0,t[o]=a,i?.[o]&&(clearTimeout(i[o]),i[o]=void 0),a!==0&&i){let l=setTimeout(()=>{this.#v(o)&&this.#R(this.#c[o],"expire")},a+1);l.unref&&l.unref(),i[o]=l}},this.#A=o=>{e[o]=t[o]!==0?this.#f.now():0},this.#j=(o,a)=>{if(t[a]){let c=t[a],l=e[a];if(!c||!l)return;o.ttl=c,o.start=l,o.now=r||n();let h=o.now-l;o.remainingTTL=c-h}};let r=0,n=()=>{let o=this.#f.now();if(this.ttlResolution>0){r=o;let a=setTimeout(()=>r=0,this.ttlResolution);a.unref&&a.unref()}return o};this.getRemainingTTL=o=>{let a=this.#h.get(o);if(a===void 0)return 0;let c=t[a],l=e[a];if(!c||!l)return 1/0;let h=(r||n())-l;return c-h},this.#v=o=>{let a=e[o],c=t[o];return!!c&&!!a&&(r||n())-a>c}}#A=()=>{};#j=()=>{};#$=()=>{};#v=()=>!1;#G(){let t=new le(this.#t);this.#u=0,this.#_=t,this.#M=e=>{this.#u-=t[e],t[e]=0},this.#L=(e,i,r,n)=>{if(this.#l(i))return 0;if(!It(r))if(n){if(typeof n!="function")throw new TypeError("sizeCalculation must be a function");if(r=n(i,e),!It(r))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 r},this.#F=(e,i,r)=>{if(t[e]=i,this.#s){let n=this.#s-t[e];for(;this.#u>n;)this.#B(!0)}this.#u+=t[e],r&&(r.entrySize=i,r.totalCalculatedSize=this.#u)}}#M=t=>{};#F=(t,e,i)=>{};#L=(t,e,i,r)=>{if(i||r)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#C({allowStale:t=this.allowStale}={}){if(this.#a)for(let e=this.#m;!(!this.#W(e)||((t||!this.#v(e))&&(yield e),e===this.#b));)e=this.#E[e]}*#N({allowStale:t=this.allowStale}={}){if(this.#a)for(let e=this.#b;!(!this.#W(e)||((t||!this.#v(e))&&(yield e),e===this.#m));)e=this.#d[e]}#W(t){return t!==void 0&&this.#h.get(this.#c[t])===t}*entries(){for(let t of this.#C())this.#i[t]!==void 0&&this.#c[t]!==void 0&&!this.#l(this.#i[t])&&(yield[this.#c[t],this.#i[t]])}*rentries(){for(let t of this.#N())this.#i[t]!==void 0&&this.#c[t]!==void 0&&!this.#l(this.#i[t])&&(yield[this.#c[t],this.#i[t]])}*keys(){for(let t of this.#C()){let e=this.#c[t];e!==void 0&&!this.#l(this.#i[t])&&(yield e)}}*rkeys(){for(let t of this.#N()){let e=this.#c[t];e!==void 0&&!this.#l(this.#i[t])&&(yield e)}}*values(){for(let t of this.#C())this.#i[t]!==void 0&&!this.#l(this.#i[t])&&(yield this.#i[t])}*rvalues(){for(let t of this.#N())this.#i[t]!==void 0&&!this.#l(this.#i[t])&&(yield this.#i[t])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(t,e={}){for(let i of this.#C()){let r=this.#i[i],n=this.#l(r)?r.__staleWhileFetching:r;if(n!==void 0&&t(n,this.#c[i],this))return this.get(this.#c[i],e)}}forEach(t,e=this){for(let i of this.#C()){let r=this.#i[i],n=this.#l(r)?r.__staleWhileFetching:r;n!==void 0&&t.call(e,n,this.#c[i],this)}}rforEach(t,e=this){for(let i of this.#N()){let r=this.#i[i],n=this.#l(r)?r.__staleWhileFetching:r;n!==void 0&&t.call(e,n,this.#c[i],this)}}purgeStale(){let t=!1;for(let e of this.#N({allowStale:!0}))this.#v(e)&&(this.#R(this.#c[e],"expire"),t=!0);return t}info(t){let e=this.#h.get(t);if(e===void 0)return;let i=this.#i[e],r=this.#l(i)?i.__staleWhileFetching:i;if(r===void 0)return;let n={value:r};if(this.#g&&this.#T){let o=this.#g[e],a=this.#T[e];if(o&&a){let c=o-(this.#f.now()-a);n.ttl=c,n.start=Date.now()}}return this.#_&&(n.size=this.#_[e]),n}dump(){let t=[];for(let e of this.#C({allowStale:!0})){let i=this.#c[e],r=this.#i[e],n=this.#l(r)?r.__staleWhileFetching:r;if(n===void 0||i===void 0)continue;let o={value:n};if(this.#g&&this.#T){o.ttl=this.#g[e];let a=this.#f.now()-this.#T[e];o.start=Math.floor(Date.now()-a)}this.#_&&(o.size=this.#_[e]),t.unshift([i,o])}return t}load(t){this.clear();for(let[e,i]of t){if(i.start){let r=Date.now()-i.start;i.start=this.#f.now()-r}this.set(e,i.value,i)}}set(t,e,i={}){if(e===void 0)return this.delete(t),this;let{ttl:r=this.ttl,start:n,noDisposeOnSet:o=this.noDisposeOnSet,sizeCalculation:a=this.sizeCalculation,status:c}=i,{noUpdateTTL:l=this.noUpdateTTL}=i,h=this.#L(t,e,i.size||0,a);if(this.maxEntrySize&&h>this.maxEntrySize)return c&&(c.set="miss",c.maxEntrySizeExceeded=!0),this.#R(t,"set"),this;let f=this.#a===0?void 0:this.#h.get(t);if(f===void 0)f=this.#a===0?this.#m:this.#O.length!==0?this.#O.pop():this.#a===this.#t?this.#B(!1):this.#a,this.#c[f]=t,this.#i[f]=e,this.#h.set(t,f),this.#d[this.#m]=f,this.#E[f]=this.#m,this.#m=f,this.#a++,this.#F(f,h,c),c&&(c.set="add"),l=!1,this.#D&&this.#r?.(e,t,"add");else{this.#I(f);let u=this.#i[f];if(e!==u){if(this.#k&&this.#l(u)){u.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:d}=u;d!==void 0&&!o&&(this.#x&&this.#n?.(d,t,"set"),this.#e&&this.#p?.push([d,t,"set"]))}else o||(this.#x&&this.#n?.(u,t,"set"),this.#e&&this.#p?.push([u,t,"set"]));if(this.#M(f),this.#F(f,h,c),this.#i[f]=e,c){c.set="replace";let d=u&&this.#l(u)?u.__staleWhileFetching:u;d!==void 0&&(c.oldValue=d)}}else c&&(c.set="update");this.#D&&this.onInsert?.(e,t,e===u?"update":"replace")}if(r!==0&&!this.#g&&this.#P(),this.#g&&(l||this.#$(f,r,n),c&&this.#j(c,f)),!o&&this.#e&&this.#p){let u=this.#p,d;for(;d=u?.shift();)this.#o?.(...d)}return this}pop(){try{for(;this.#a;){let t=this.#i[this.#b];if(this.#B(!0),this.#l(t)){if(t.__staleWhileFetching)return t.__staleWhileFetching}else if(t!==void 0)return t}}finally{if(this.#e&&this.#p){let t=this.#p,e;for(;e=t?.shift();)this.#o?.(...e)}}}#B(t){let e=this.#b,i=this.#c[e],r=this.#i[e];return this.#k&&this.#l(r)?r.__abortController.abort(new Error("evicted")):(this.#x||this.#e)&&(this.#x&&this.#n?.(r,i,"evict"),this.#e&&this.#p?.push([r,i,"evict"])),this.#M(e),this.#w?.[e]&&(clearTimeout(this.#w[e]),this.#w[e]=void 0),t&&(this.#c[e]=void 0,this.#i[e]=void 0,this.#O.push(e)),this.#a===1?(this.#b=this.#m=0,this.#O.length=0):this.#b=this.#d[e],this.#h.delete(i),this.#a--,e}has(t,e={}){let{updateAgeOnHas:i=this.updateAgeOnHas,status:r}=e,n=this.#h.get(t);if(n!==void 0){let o=this.#i[n];if(this.#l(o)&&o.__staleWhileFetching===void 0)return!1;if(this.#v(n))r&&(r.has="stale",this.#j(r,n));else return i&&this.#A(n),r&&(r.has="hit",this.#j(r,n)),!0}else r&&(r.has="miss");return!1}peek(t,e={}){let{allowStale:i=this.allowStale}=e,r=this.#h.get(t);if(r===void 0||!i&&this.#v(r))return;let n=this.#i[r];return this.#l(n)?n.__staleWhileFetching:n}#U(t,e,i,r){let n=e===void 0?void 0:this.#i[e];if(this.#l(n))return n;let o=new Ts,{signal:a}=i;a?.addEventListener("abort",()=>o.abort(a.reason),{signal:o.signal});let c={signal:o.signal,options:i,context:r},l=(p,y=!1)=>{let{aborted:g}=o.signal,S=i.ignoreFetchAbort&&p!==void 0,x=i.ignoreFetchAbort||!!(i.allowStaleOnFetchAbort&&p!==void 0);if(i.status&&(g&&!y?(i.status.fetchAborted=!0,i.status.fetchError=o.signal.reason,S&&(i.status.fetchAbortIgnored=!0)):i.status.fetchResolved=!0),g&&!S&&!y)return f(o.signal.reason,x);let w=d,b=this.#i[e];return(b===d||S&&y&&b===void 0)&&(p===void 0?w.__staleWhileFetching!==void 0?this.#i[e]=w.__staleWhileFetching:this.#R(t,"fetch"):(i.status&&(i.status.fetchUpdated=!0),this.set(t,p,c.options))),p},h=p=>(i.status&&(i.status.fetchRejected=!0,i.status.fetchError=p),f(p,!1)),f=(p,y)=>{let{aborted:g}=o.signal,S=g&&i.allowStaleOnFetchAbort,x=S||i.allowStaleOnFetchRejection,w=x||i.noDeleteOnFetchRejection,b=d;if(this.#i[e]===d&&(!w||!y&&b.__staleWhileFetching===void 0?this.#R(t,"fetch"):S||(this.#i[e]=b.__staleWhileFetching)),x)return i.status&&b.__staleWhileFetching!==void 0&&(i.status.returnedStale=!0),b.__staleWhileFetching;if(b.__returned===b)throw p},u=(p,y)=>{let g=this.#S?.(t,n,c);g&&g instanceof Promise&&g.then(S=>p(S===void 0?void 0:S),y),o.signal.addEventListener("abort",()=>{(!i.ignoreFetchAbort||i.allowStaleOnFetchAbort)&&(p(void 0),i.allowStaleOnFetchAbort&&(p=S=>l(S,!0)))})};i.status&&(i.status.fetchDispatched=!0);let d=new Promise(u).then(l,h),m=Object.assign(d,{__abortController:o,__staleWhileFetching:n,__returned:void 0});return e===void 0?(this.set(t,m,{...c.options,status:void 0}),e=this.#h.get(t)):this.#i[e]=m,m}#l(t){if(!this.#k)return!1;let e=t;return!!e&&e instanceof Promise&&e.hasOwnProperty("__staleWhileFetching")&&e.__abortController instanceof Ts}async fetch(t,e={}){let{allowStale:i=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,ttl:o=this.ttl,noDisposeOnSet:a=this.noDisposeOnSet,size:c=0,sizeCalculation:l=this.sizeCalculation,noUpdateTTL:h=this.noUpdateTTL,noDeleteOnFetchRejection:f=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:u=this.allowStaleOnFetchRejection,ignoreFetchAbort:d=this.ignoreFetchAbort,allowStaleOnFetchAbort:m=this.allowStaleOnFetchAbort,context:p,forceRefresh:y=!1,status:g,signal:S}=e;if(!this.#k)return g&&(g.fetch="get"),this.get(t,{allowStale:i,updateAgeOnGet:r,noDeleteOnStaleGet:n,status:g});let x={allowStale:i,updateAgeOnGet:r,noDeleteOnStaleGet:n,ttl:o,noDisposeOnSet:a,size:c,sizeCalculation:l,noUpdateTTL:h,noDeleteOnFetchRejection:f,allowStaleOnFetchRejection:u,allowStaleOnFetchAbort:m,ignoreFetchAbort:d,status:g,signal:S},w=this.#h.get(t);if(w===void 0){g&&(g.fetch="miss");let b=this.#U(t,w,x,p);return b.__returned=b}else{let b=this.#i[w];if(this.#l(b)){let Ft=i&&b.__staleWhileFetching!==void 0;return g&&(g.fetch="inflight",Ft&&(g.returnedStale=!0)),Ft?b.__staleWhileFetching:b.__returned=b}let I=this.#v(w);if(!y&&!I)return g&&(g.fetch="hit"),this.#I(w),r&&this.#A(w),g&&this.#j(g,w),b;let it=this.#U(t,w,x,p),Dt=it.__staleWhileFetching!==void 0&&i;return g&&(g.fetch=I?"stale":"refresh",Dt&&I&&(g.returnedStale=!0)),Dt?it.__staleWhileFetching:it.__returned=it}}async forceFetch(t,e={}){let i=await this.fetch(t,e);if(i===void 0)throw new Error("fetch() returned undefined");return i}memo(t,e={}){let i=this.#y;if(!i)throw new Error("no memoMethod provided to constructor");let{context:r,forceRefresh:n,...o}=e,a=this.get(t,o);if(!n&&a!==void 0)return a;let c=i(t,a,{options:o,context:r});return this.set(t,c,o),c}get(t,e={}){let{allowStale:i=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,status:o}=e,a=this.#h.get(t);if(a!==void 0){let c=this.#i[a],l=this.#l(c);return o&&this.#j(o,a),this.#v(a)?(o&&(o.get="stale"),l?(o&&i&&c.__staleWhileFetching!==void 0&&(o.returnedStale=!0),i?c.__staleWhileFetching:void 0):(n||this.#R(t,"expire"),o&&i&&(o.returnedStale=!0),i?c:void 0)):(o&&(o.get="hit"),l?c.__staleWhileFetching:(this.#I(a),r&&this.#A(a),c))}else o&&(o.get="miss")}#z(t,e){this.#E[e]=t,this.#d[t]=e}#I(t){t!==this.#m&&(t===this.#b?this.#b=this.#d[t]:this.#z(this.#E[t],this.#d[t]),this.#z(this.#m,t),this.#m=t)}delete(t){return this.#R(t,"delete")}#R(t,e){let i=!1;if(this.#a!==0){let r=this.#h.get(t);if(r!==void 0)if(this.#w?.[r]&&(clearTimeout(this.#w?.[r]),this.#w[r]=void 0),i=!0,this.#a===1)this.#H(e);else{this.#M(r);let n=this.#i[r];if(this.#l(n)?n.__abortController.abort(new Error("deleted")):(this.#x||this.#e)&&(this.#x&&this.#n?.(n,t,e),this.#e&&this.#p?.push([n,t,e])),this.#h.delete(t),this.#c[r]=void 0,this.#i[r]=void 0,r===this.#m)this.#m=this.#E[r];else if(r===this.#b)this.#b=this.#d[r];else{let o=this.#E[r];this.#d[o]=this.#d[r];let a=this.#d[r];this.#E[a]=this.#E[r]}this.#a--,this.#O.push(r)}}if(this.#e&&this.#p?.length){let r=this.#p,n;for(;n=r?.shift();)this.#o?.(...n)}return i}clear(){return this.#H("delete")}#H(t){for(let e of this.#N({allowStale:!0})){let i=this.#i[e];if(this.#l(i))i.__abortController.abort(new Error("deleted"));else{let r=this.#c[e];this.#x&&this.#n?.(i,r,t),this.#e&&this.#p?.push([i,r,t])}}if(this.#h.clear(),this.#i.fill(void 0),this.#c.fill(void 0),this.#g&&this.#T){this.#g.fill(0),this.#T.fill(0);for(let e of this.#w??[])e!==void 0&&clearTimeout(e);this.#w?.fill(void 0)}if(this.#_&&this.#_.fill(0),this.#b=0,this.#m=0,this.#O.length=0,this.#u=0,this.#a=0,this.#e&&this.#p){let e=this.#p,i;for(;i=e?.shift();)this.#o?.(...i)}}};import{posix as zf,win32 as rr}from"node:path";import{fileURLToPath as Gf}from"node:url";import{lstatSync as Hf,readdir as Yf,readdirSync as qf,readlinkSync as Vf,realpathSync as Jf}from"fs";import*as Kf from"node:fs";import{lstat as Zf,readdir as Qf,readlink as th,realpath as eh}from"node:fs/promises";import{EventEmitter as er}from"node:events";import so from"node:stream";import{StringDecoder as jf}from"node:string_decoder";var Zn=typeof process=="object"&&process?process:{stdout:null,stderr:null},Df=s=>!!s&&typeof s=="object"&&(s instanceof $t||s instanceof so||Ff(s)||If(s)),Ff=s=>!!s&&typeof s=="object"&&s instanceof er&&typeof s.pipe=="function"&&s.pipe!==so.Writable.prototype.pipe,If=s=>!!s&&typeof s=="object"&&s instanceof er&&typeof s.write=="function"&&typeof s.end=="function",Rt=Symbol("EOF"),Ct=Symbol("maybeEmitEnd"),Mt=Symbol("emittedEnd"),ks=Symbol("emittingEnd"),We=Symbol("emittedError"),As=Symbol("closed"),Qn=Symbol("read"),Os=Symbol("flush"),to=Symbol("flushChunk"),yt=Symbol("encoding"),fe=Symbol("decoder"),M=Symbol("flowing"),Be=Symbol("paused"),he=Symbol("resume"),$=Symbol("buffer"),Z=Symbol("pipes"),L=Symbol("bufferLength"),Ji=Symbol("bufferPush"),Rs=Symbol("bufferShift"),H=Symbol("objectMode"),j=Symbol("destroyed"),Ki=Symbol("error"),Xi=Symbol("emitData"),eo=Symbol("emitEnd"),Zi=Symbol("emitEnd2"),vt=Symbol("async"),Qi=Symbol("abort"),Cs=Symbol("aborted"),Ue=Symbol("signal"),Jt=Symbol("dataListeners"),rt=Symbol("discarded"),ze=s=>Promise.resolve().then(s),Mf=s=>s(),$f=s=>s==="end"||s==="finish"||s==="prefinish",Lf=s=>s instanceof ArrayBuffer||!!s&&typeof s=="object"&&s.constructor&&s.constructor.name==="ArrayBuffer"&&s.byteLength>=0,Wf=s=>!Buffer.isBuffer(s)&&ArrayBuffer.isView(s),Ns=class{src;dest;opts;ondrain;constructor(t,e,i){this.src=t,this.dest=e,this.opts=i,this.ondrain=()=>t[he](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(t){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},tr=class extends Ns{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(t,e,i){super(t,e,i),this.proxyErrors=r=>e.emit("error",r),t.on("error",this.proxyErrors)}},Bf=s=>!!s.objectMode,Uf=s=>!s.objectMode&&!!s.encoding&&s.encoding!=="buffer",$t=class extends er{[M]=!1;[Be]=!1;[Z]=[];[$]=[];[H];[yt];[vt];[fe];[Rt]=!1;[Mt]=!1;[ks]=!1;[As]=!1;[We]=null;[L]=0;[j]=!1;[Ue];[Cs]=!1;[Jt]=0;[rt]=!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");Bf(e)?(this[H]=!0,this[yt]=null):Uf(e)?(this[yt]=e.encoding,this[H]=!1):(this[H]=!1,this[yt]=null),this[vt]=!!e.async,this[fe]=this[yt]?new jf(this[yt]):null,e&&e.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[$]}),e&&e.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[Z]});let{signal:i}=e;i&&(this[Ue]=i,i.aborted?this[Qi]():i.addEventListener("abort",()=>this[Qi]()))}get bufferLength(){return this[L]}get encoding(){return this[yt]}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[H]}set objectMode(t){throw new Error("objectMode must be set at instantiation time")}get async(){return this[vt]}set async(t){this[vt]=this[vt]||!!t}[Qi](){this[Cs]=!0,this.emit("abort",this[Ue]?.reason),this.destroy(this[Ue]?.reason)}get aborted(){return this[Cs]}set aborted(t){}write(t,e,i){if(this[Cs])return!1;if(this[Rt])throw new Error("write after end");if(this[j])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;typeof e=="function"&&(i=e,e="utf8"),e||(e="utf8");let r=this[vt]?ze:Mf;if(!this[H]&&!Buffer.isBuffer(t)){if(Wf(t))t=Buffer.from(t.buffer,t.byteOffset,t.byteLength);else if(Lf(t))t=Buffer.from(t);else if(typeof t!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[H]?(this[M]&&this[L]!==0&&this[Os](!0),this[M]?this.emit("data",t):this[Ji](t),this[L]!==0&&this.emit("readable"),i&&r(i),this[M]):t.length?(typeof t=="string"&&!(e===this[yt]&&!this[fe]?.lastNeed)&&(t=Buffer.from(t,e)),Buffer.isBuffer(t)&&this[yt]&&(t=this[fe].write(t)),this[M]&&this[L]!==0&&this[Os](!0),this[M]?this.emit("data",t):this[Ji](t),this[L]!==0&&this.emit("readable"),i&&r(i),this[M]):(this[L]!==0&&this.emit("readable"),i&&r(i),this[M])}read(t){if(this[j])return null;if(this[rt]=!1,this[L]===0||t===0||t&&t>this[L])return this[Ct](),null;this[H]&&(t=null),this[$].length>1&&!this[H]&&(this[$]=[this[yt]?this[$].join(""):Buffer.concat(this[$],this[L])]);let e=this[Qn](t||null,this[$][0]);return this[Ct](),e}[Qn](t,e){if(this[H])this[Rs]();else{let i=e;t===i.length||t===null?this[Rs]():typeof i=="string"?(this[$][0]=i.slice(t),e=i.slice(0,t),this[L]-=t):(this[$][0]=i.subarray(t),e=i.subarray(0,t),this[L]-=t)}return this.emit("data",e),!this[$].length&&!this[Rt]&&this.emit("drain"),e}end(t,e,i){return typeof t=="function"&&(i=t,t=void 0),typeof e=="function"&&(i=e,e="utf8"),t!==void 0&&this.write(t,e),i&&this.once("end",i),this[Rt]=!0,this.writable=!1,(this[M]||!this[Be])&&this[Ct](),this}[he](){this[j]||(!this[Jt]&&!this[Z].length&&(this[rt]=!0),this[Be]=!1,this[M]=!0,this.emit("resume"),this[$].length?this[Os]():this[Rt]?this[Ct]():this.emit("drain"))}resume(){return this[he]()}pause(){this[M]=!1,this[Be]=!0,this[rt]=!1}get destroyed(){return this[j]}get flowing(){return this[M]}get paused(){return this[Be]}[Ji](t){this[H]?this[L]+=1:this[L]+=t.length,this[$].push(t)}[Rs](){return this[H]?this[L]-=1:this[L]-=this[$][0].length,this[$].shift()}[Os](t=!1){do;while(this[to](this[Rs]())&&this[$].length);!t&&!this[$].length&&!this[Rt]&&this.emit("drain")}[to](t){return this.emit("data",t),this[M]}pipe(t,e){if(this[j])return t;this[rt]=!1;let i=this[Mt];return e=e||{},t===Zn.stdout||t===Zn.stderr?e.end=!1:e.end=e.end!==!1,e.proxyErrors=!!e.proxyErrors,i?e.end&&t.end():(this[Z].push(e.proxyErrors?new tr(this,t,e):new Ns(this,t,e)),this[vt]?ze(()=>this[he]()):this[he]()),t}unpipe(t){let e=this[Z].find(i=>i.dest===t);e&&(this[Z].length===1?(this[M]&&this[Jt]===0&&(this[M]=!1),this[Z]=[]):this[Z].splice(this[Z].indexOf(e),1),e.unpipe())}addListener(t,e){return this.on(t,e)}on(t,e){let i=super.on(t,e);if(t==="data")this[rt]=!1,this[Jt]++,!this[Z].length&&!this[M]&&this[he]();else if(t==="readable"&&this[L]!==0)super.emit("readable");else if($f(t)&&this[Mt])super.emit(t),this.removeAllListeners(t);else if(t==="error"&&this[We]){let r=e;this[vt]?ze(()=>r.call(this,this[We])):r.call(this,this[We])}return i}removeListener(t,e){return this.off(t,e)}off(t,e){let i=super.off(t,e);return t==="data"&&(this[Jt]=this.listeners("data").length,this[Jt]===0&&!this[rt]&&!this[Z].length&&(this[M]=!1)),i}removeAllListeners(t){let e=super.removeAllListeners(t);return(t==="data"||t===void 0)&&(this[Jt]=0,!this[rt]&&!this[Z].length&&(this[M]=!1)),e}get emittedEnd(){return this[Mt]}[Ct](){!this[ks]&&!this[Mt]&&!this[j]&&this[$].length===0&&this[Rt]&&(this[ks]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[As]&&this.emit("close"),this[ks]=!1)}emit(t,...e){let i=e[0];if(t!=="error"&&t!=="close"&&t!==j&&this[j])return!1;if(t==="data")return!this[H]&&!i?!1:this[vt]?(ze(()=>this[Xi](i)),!0):this[Xi](i);if(t==="end")return this[eo]();if(t==="close"){if(this[As]=!0,!this[Mt]&&!this[j])return!1;let n=super.emit("close");return this.removeAllListeners("close"),n}else if(t==="error"){this[We]=i,super.emit(Ki,i);let n=!this[Ue]||this.listeners("error").length?super.emit("error",i):!1;return this[Ct](),n}else if(t==="resume"){let n=super.emit("resume");return this[Ct](),n}else if(t==="finish"||t==="prefinish"){let n=super.emit(t);return this.removeAllListeners(t),n}let r=super.emit(t,...e);return this[Ct](),r}[Xi](t){for(let i of this[Z])i.dest.write(t)===!1&&this.pause();let e=this[rt]?!1:super.emit("data",t);return this[Ct](),e}[eo](){return this[Mt]?!1:(this[Mt]=!0,this.readable=!1,this[vt]?(ze(()=>this[Zi]()),!0):this[Zi]())}[Zi](){if(this[fe]){let e=this[fe].end();if(e){for(let i of this[Z])i.dest.write(e);this[rt]||super.emit("data",e)}}for(let e of this[Z])e.end();let t=super.emit("end");return this.removeAllListeners("end"),t}async collect(){let t=Object.assign([],{dataLength:0});this[H]||(t.dataLength=0);let e=this.promise();return this.on("data",i=>{t.push(i),this[H]||(t.dataLength+=i.length)}),await e,t}async concat(){if(this[H])throw new Error("cannot concat in objectMode");let t=await this.collect();return this[yt]?t.join(""):Buffer.concat(t,t.dataLength)}async promise(){return new Promise((t,e)=>{this.on(j,()=>e(new Error("stream destroyed"))),this.on("error",i=>e(i)),this.on("end",()=>t())})}[Symbol.asyncIterator](){this[rt]=!1;let t=!1,e=async()=>(this.pause(),t=!0,{value:void 0,done:!0});return{next:()=>{if(t)return e();let r=this.read();if(r!==null)return Promise.resolve({done:!1,value:r});if(this[Rt])return e();let n,o,a=f=>{this.off("data",c),this.off("end",l),this.off(j,h),e(),o(f)},c=f=>{this.off("error",a),this.off("end",l),this.off(j,h),this.pause(),n({value:f,done:!!this[Rt]})},l=()=>{this.off("error",a),this.off("data",c),this.off(j,h),e(),n({done:!0,value:void 0})},h=()=>a(new Error("stream destroyed"));return new Promise((f,u)=>{o=u,n=f,this.once(j,h),this.once("error",a),this.once("end",l),this.once("data",c)})},throw:e,return:e,[Symbol.asyncIterator](){return this}}}[Symbol.iterator](){this[rt]=!1;let t=!1,e=()=>(this.pause(),this.off(Ki,e),this.off(j,e),this.off("end",e),t=!0,{done:!0,value:void 0}),i=()=>{if(t)return e();let r=this.read();return r===null?e():{done:!1,value:r}};return this.once("end",e),this.once(Ki,e),this.once(j,e),{next:i,throw:e,return:e,[Symbol.iterator](){return this}}}destroy(t){if(this[j])return t?this.emit("error",t):this.emit(j),this;this[j]=!0,this[rt]=!0,this[$].length=0,this[L]=0;let e=this;return typeof e.close=="function"&&!this[As]&&e.close(),t?this.emit("error",t):this.emit(j),this}static get isStream(){return Df}};var Xf=Jf.native,He={lstatSync:Hf,readdir:Yf,readdirSync:qf,readlinkSync:Vf,realpathSync:Xf,promises:{lstat:Zf,readdir:Qf,readlink:th,realpath:eh}},ao=s=>!s||s===He||s===Kf?He:{...He,...s,promises:{...He.promises,...s.promises||{}}},co=/^\\\\\?\\([a-z]:)\\?$/i,sh=s=>s.replace(/\//g,"\\").replace(co,"$1\\"),ih=/[\\\/]/,lt=0,lo=1,fo=2,_t=4,ho=6,uo=8,Kt=10,mo=12,ct=15,Ge=~ct,sr=16,io=32,Ye=64,wt=128,Ps=256,Ds=512,ro=Ye|wt|Ds,rh=1023,ir=s=>s.isFile()?uo:s.isDirectory()?_t:s.isSymbolicLink()?Kt:s.isCharacterDevice()?fo:s.isBlockDevice()?ho:s.isSocket()?mo:s.isFIFO()?lo:lt,no=new Vt({max:2**12}),qe=s=>{let t=no.get(s);if(t)return t;let e=s.normalize("NFKD");return no.set(s,e),e},oo=new Vt({max:2**12}),js=s=>{let t=oo.get(s);if(t)return t;let e=qe(s.toLowerCase());return oo.set(s,e),e},Fs=class extends Vt{constructor(){super({max:256})}},nr=class extends Vt{constructor(t=16*1024){super({maxSize:t,sizeCalculation:e=>e.length+1})}},po=Symbol("PathScurry setAsCwd"),Y=class{name;root;roots;parent;nocase;isCWD=!1;#t;#s;get dev(){return this.#s}#n;get mode(){return this.#n}#r;get nlink(){return this.#r}#o;get uid(){return this.#o}#S;get gid(){return this.#S}#y;get rdev(){return this.#y}#f;get blksize(){return this.#f}#a;get ino(){return this.#a}#u;get size(){return this.#u}#h;get blocks(){return this.#h}#c;get atimeMs(){return this.#c}#i;get mtimeMs(){return this.#i}#d;get ctimeMs(){return this.#d}#E;get birthtimeMs(){return this.#E}#b;get atime(){return this.#b}#m;get mtime(){return this.#m}#O;get ctime(){return this.#O}#p;get birthtime(){return this.#p}#_;#T;#g;#w;#x;#k;#e;#D;#P;#A;get parentPath(){return(this.parent||this).fullpath()}get path(){return this.parentPath}constructor(t,e=lt,i,r,n,o,a){this.name=t,this.#_=n?js(t):qe(t),this.#e=e&rh,this.nocase=n,this.roots=r,this.root=i||this,this.#D=o,this.#g=a.fullpath,this.#x=a.relative,this.#k=a.relativePosix,this.parent=a.parent,this.parent?this.#t=this.parent.#t:this.#t=ao(a.fs)}depth(){return this.#T!==void 0?this.#T:this.parent?this.#T=this.parent.depth()+1:this.#T=0}childrenCache(){return this.#D}resolve(t){if(!t)return this;let e=this.getRootString(t),r=t.substring(e.length).split(this.splitSep);return e?this.getRoot(e).#j(r):this.#j(r)}#j(t){let e=this;for(let i of t)e=e.child(i);return e}children(){let t=this.#D.get(this);if(t)return t;let e=Object.assign([],{provisional:0});return this.#D.set(this,e),this.#e&=~sr,e}child(t,e){if(t===""||t===".")return this;if(t==="..")return this.parent||this;let i=this.children(),r=this.nocase?js(t):qe(t);for(let c of i)if(c.#_===r)return c;let n=this.parent?this.sep:"",o=this.#g?this.#g+n+t:void 0,a=this.newChild(t,lt,{...e,parent:this,fullpath:o});return this.canReaddir()||(a.#e|=wt),i.push(a),a}relative(){if(this.isCWD)return"";if(this.#x!==void 0)return this.#x;let t=this.name,e=this.parent;if(!e)return this.#x=this.name;let i=e.relative();return i+(!i||!e.parent?"":this.sep)+t}relativePosix(){if(this.sep==="/")return this.relative();if(this.isCWD)return"";if(this.#k!==void 0)return this.#k;let t=this.name,e=this.parent;if(!e)return this.#k=this.fullpathPosix();let i=e.relativePosix();return i+(!i||!e.parent?"":"/")+t}fullpath(){if(this.#g!==void 0)return this.#g;let t=this.name,e=this.parent;if(!e)return this.#g=this.name;let r=e.fullpath()+(e.parent?this.sep:"")+t;return this.#g=r}fullpathPosix(){if(this.#w!==void 0)return this.#w;if(this.sep==="/")return this.#w=this.fullpath();if(!this.parent){let r=this.fullpath().replace(/\\/g,"/");return/^[a-z]:\//i.test(r)?this.#w=`//?/${r}`:this.#w=r}let t=this.parent,e=t.fullpathPosix(),i=e+(!e||!t.parent?"":"/")+this.name;return this.#w=i}isUnknown(){return(this.#e&ct)===lt}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.#e&ct)===uo}isDirectory(){return(this.#e&ct)===_t}isCharacterDevice(){return(this.#e&ct)===fo}isBlockDevice(){return(this.#e&ct)===ho}isFIFO(){return(this.#e&ct)===lo}isSocket(){return(this.#e&ct)===mo}isSymbolicLink(){return(this.#e&Kt)===Kt}lstatCached(){return this.#e&io?this:void 0}readlinkCached(){return this.#P}realpathCached(){return this.#A}readdirCached(){let t=this.children();return t.slice(0,t.provisional)}canReadlink(){if(this.#P)return!0;if(!this.parent)return!1;let t=this.#e&ct;return!(t!==lt&&t!==Kt||this.#e&Ps||this.#e&wt)}calledReaddir(){return!!(this.#e&sr)}isENOENT(){return!!(this.#e&wt)}isNamed(t){return this.nocase?this.#_===js(t):this.#_===qe(t)}async readlink(){let t=this.#P;if(t)return t;if(this.canReadlink()&&this.parent)try{let e=await this.#t.promises.readlink(this.fullpath()),i=(await this.parent.realpath())?.resolve(e);if(i)return this.#P=i}catch(e){this.#N(e.code);return}}readlinkSync(){let t=this.#P;if(t)return t;if(this.canReadlink()&&this.parent)try{let e=this.#t.readlinkSync(this.fullpath()),i=this.parent.realpathSync()?.resolve(e);if(i)return this.#P=i}catch(e){this.#N(e.code);return}}#$(t){this.#e|=sr;for(let e=t.provisional;e<t.length;e++){let i=t[e];i&&i.#v()}}#v(){this.#e&wt||(this.#e=(this.#e|wt)&Ge,this.#G())}#G(){let t=this.children();t.provisional=0;for(let e of t)e.#v()}#M(){this.#e|=Ds,this.#F()}#F(){if(this.#e&Ye)return;let t=this.#e;(t&ct)===_t&&(t&=Ge),this.#e=t|Ye,this.#G()}#L(t=""){t==="ENOTDIR"||t==="EPERM"?this.#F():t==="ENOENT"?this.#v():this.children().provisional=0}#C(t=""){t==="ENOTDIR"?this.parent.#F():t==="ENOENT"&&this.#v()}#N(t=""){let e=this.#e;e|=Ps,t==="ENOENT"&&(e|=wt),(t==="EINVAL"||t==="UNKNOWN")&&(e&=Ge),this.#e=e,t==="ENOTDIR"&&this.parent&&this.parent.#F()}#W(t,e){return this.#U(t,e)||this.#B(t,e)}#B(t,e){let i=ir(t),r=this.newChild(t.name,i,{parent:this}),n=r.#e&ct;return n!==_t&&n!==Kt&&n!==lt&&(r.#e|=Ye),e.unshift(r),e.provisional++,r}#U(t,e){for(let i=e.provisional;i<e.length;i++){let r=e[i];if((this.nocase?js(t.name):qe(t.name))===r.#_)return this.#l(t,r,i,e)}}#l(t,e,i,r){let n=e.name;return e.#e=e.#e&Ge|ir(t),n!==t.name&&(e.name=t.name),i!==r.provisional&&(i===r.length-1?r.pop():r.splice(i,1),r.unshift(e)),r.provisional++,e}async lstat(){if((this.#e&wt)===0)try{return this.#z(await this.#t.promises.lstat(this.fullpath())),this}catch(t){this.#C(t.code)}}lstatSync(){if((this.#e&wt)===0)try{return this.#z(this.#t.lstatSync(this.fullpath())),this}catch(t){this.#C(t.code)}}#z(t){let{atime:e,atimeMs:i,birthtime:r,birthtimeMs:n,blksize:o,blocks:a,ctime:c,ctimeMs:l,dev:h,gid:f,ino:u,mode:d,mtime:m,mtimeMs:p,nlink:y,rdev:g,size:S,uid:x}=t;this.#b=e,this.#c=i,this.#p=r,this.#E=n,this.#f=o,this.#h=a,this.#O=c,this.#d=l,this.#s=h,this.#S=f,this.#a=u,this.#n=d,this.#m=m,this.#i=p,this.#r=y,this.#y=g,this.#u=S,this.#o=x;let w=ir(t);this.#e=this.#e&Ge|w|io,w!==lt&&w!==_t&&w!==Kt&&(this.#e|=Ye)}#I=[];#R=!1;#H(t){this.#R=!1;let e=this.#I.slice();this.#I.length=0,e.forEach(i=>i(null,t))}readdirCB(t,e=!1){if(!this.canReaddir()){e?t(null,[]):queueMicrotask(()=>t(null,[]));return}let i=this.children();if(this.calledReaddir()){let n=i.slice(0,i.provisional);e?t(null,n):queueMicrotask(()=>t(null,n));return}if(this.#I.push(t),this.#R)return;this.#R=!0;let r=this.fullpath();this.#t.readdir(r,{withFileTypes:!0},(n,o)=>{if(n)this.#L(n.code),i.provisional=0;else{for(let a of o)this.#W(a,i);this.#$(i)}this.#H(i.slice(0,i.provisional))})}#Y;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.#Y)await this.#Y;else{let i=()=>{};this.#Y=new Promise(r=>i=r);try{for(let r of await this.#t.promises.readdir(e,{withFileTypes:!0}))this.#W(r,t);this.#$(t)}catch(r){this.#L(r.code),t.provisional=0}this.#Y=void 0,i()}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 i of this.#t.readdirSync(e,{withFileTypes:!0}))this.#W(i,t);this.#$(t)}catch(i){this.#L(i.code),t.provisional=0}return t.slice(0,t.provisional)}canReaddir(){if(this.#e&ro)return!1;let t=ct&this.#e;return t===lt||t===_t||t===Kt}shouldWalk(t,e){return(this.#e&_t)===_t&&!(this.#e&ro)&&!t.has(this)&&(!e||e(this))}async realpath(){if(this.#A)return this.#A;if(!((Ds|Ps|wt)&this.#e))try{let t=await this.#t.promises.realpath(this.fullpath());return this.#A=this.resolve(t)}catch{this.#M()}}realpathSync(){if(this.#A)return this.#A;if(!((Ds|Ps|wt)&this.#e))try{let t=this.#t.realpathSync(this.fullpath());return this.#A=this.resolve(t)}catch{this.#M()}}[po](t){if(t===this)return;t.isCWD=!1,this.isCWD=!0;let e=new Set([]),i=[],r=this;for(;r&&r.parent;)e.add(r),r.#x=i.join(this.sep),r.#k=i.join("/"),r=r.parent,i.push("..");for(r=t;r&&r.parent&&!e.has(r);)r.#x=void 0,r.#k=void 0,r=r.parent}},Is=class s extends Y{sep="\\";splitSep=ih;constructor(t,e=lt,i,r,n,o,a){super(t,e,i,r,n,o,a)}newChild(t,e=lt,i={}){return new s(t,e,this.root,this.roots,this.nocase,this.childrenCache(),i)}getRootString(t){return rr.parse(t).root}getRoot(t){if(t=sh(t.toUpperCase()),t===this.root.name)return this.root;for(let[e,i]of Object.entries(this.roots))if(this.sameRoot(t,e))return this.roots[t]=i;return this.roots[t]=new ue(t,this).root}sameRoot(t,e=this.root.name){return t=t.toUpperCase().replace(/\//g,"\\").replace(co,"$1\\"),t===e}},Ms=class s extends Y{splitSep="/";sep="/";constructor(t,e=lt,i,r,n,o,a){super(t,e,i,r,n,o,a)}getRootString(t){return t.startsWith("/")?"/":""}getRoot(t){return this.root}newChild(t,e=lt,i={}){return new s(t,e,this.root,this.roots,this.nocase,this.childrenCache(),i)}},$s=class{root;rootPath;roots;cwd;#t;#s;#n;nocase;#r;constructor(t=process.cwd(),e,i,{nocase:r,childrenCacheSize:n=16*1024,fs:o=He}={}){this.#r=ao(o),(t instanceof URL||t.startsWith("file://"))&&(t=Gf(t));let a=e.resolve(t);this.roots=Object.create(null),this.rootPath=this.parseRootPath(a),this.#t=new Fs,this.#s=new Fs,this.#n=new nr(n);let c=a.substring(this.rootPath.length).split(i);if(c.length===1&&!c[0]&&c.pop(),r===void 0)throw new TypeError("must provide nocase setting to PathScurryBase ctor");this.nocase=r,this.root=this.newRoot(this.#r),this.roots[this.rootPath]=this.root;let l=this.root,h=c.length-1,f=e.sep,u=this.rootPath,d=!1;for(let m of c){let p=h--;l=l.child(m,{relative:new Array(p).fill("..").join(f),relativePosix:new Array(p).fill("..").join("/"),fullpath:u+=(d?"":f)+m}),d=!0}this.cwd=l}depth(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.depth()}childrenCache(){return this.#n}resolve(...t){let e="";for(let n=t.length-1;n>=0;n--){let o=t[n];if(!(!o||o===".")&&(e=e?`${o}/${e}`:o,this.isAbsolute(o)))break}let i=this.#t.get(e);if(i!==void 0)return i;let r=this.cwd.resolve(e).fullpath();return this.#t.set(e,r),r}resolvePosix(...t){let e="";for(let n=t.length-1;n>=0;n--){let o=t[n];if(!(!o||o===".")&&(e=e?`${o}/${e}`:o,this.isAbsolute(o)))break}let i=this.#s.get(e);if(i!==void 0)return i;let r=this.cwd.resolve(e).fullpathPosix();return this.#s.set(e,r),r}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 Y||(e=t,t=this.cwd);let{withFileTypes:i}=e;if(t.canReaddir()){let r=await t.readdir();return i?r:r.map(n=>n.name)}else return[]}readdirSync(t=this.cwd,e={withFileTypes:!0}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof Y||(e=t,t=this.cwd);let{withFileTypes:i=!0}=e;return t.canReaddir()?i?t.readdirSync():t.readdirSync().map(r=>r.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 Y||(e=t.withFileTypes,t=this.cwd);let i=await t.readlink();return e?i:i?.fullpath()}readlinkSync(t=this.cwd,{withFileTypes:e}={withFileTypes:!1}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof Y||(e=t.withFileTypes,t=this.cwd);let i=t.readlinkSync();return e?i:i?.fullpath()}async realpath(t=this.cwd,{withFileTypes:e}={withFileTypes:!1}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof Y||(e=t.withFileTypes,t=this.cwd);let i=await t.realpath();return e?i:i?.fullpath()}realpathSync(t=this.cwd,{withFileTypes:e}={withFileTypes:!1}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof Y||(e=t.withFileTypes,t=this.cwd);let i=t.realpathSync();return e?i:i?.fullpath()}async walk(t=this.cwd,e={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof Y||(e=t,t=this.cwd);let{withFileTypes:i=!0,follow:r=!1,filter:n,walkFilter:o}=e,a=[];(!n||n(t))&&a.push(i?t:t.fullpath());let c=new Set,l=(f,u)=>{c.add(f),f.readdirCB((d,m)=>{if(d)return u(d);let p=m.length;if(!p)return u();let y=()=>{--p===0&&u()};for(let g of m)(!n||n(g))&&a.push(i?g:g.fullpath()),r&&g.isSymbolicLink()?g.realpath().then(S=>S?.isUnknown()?S.lstat():S).then(S=>S?.shouldWalk(c,o)?l(S,y):y()):g.shouldWalk(c,o)?l(g,y):y()},!0)},h=t;return new Promise((f,u)=>{l(h,d=>{if(d)return u(d);f(a)})})}walkSync(t=this.cwd,e={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof Y||(e=t,t=this.cwd);let{withFileTypes:i=!0,follow:r=!1,filter:n,walkFilter:o}=e,a=[];(!n||n(t))&&a.push(i?t:t.fullpath());let c=new Set([t]);for(let l of c){let h=l.readdirSync();for(let f of h){(!n||n(f))&&a.push(i?f:f.fullpath());let u=f;if(f.isSymbolicLink()){if(!(r&&(u=f.realpathSync())))continue;u.isUnknown()&&u.lstatSync()}u.shouldWalk(c,o)&&c.add(u)}}return a}[Symbol.asyncIterator](){return this.iterate()}iterate(t=this.cwd,e={}){return typeof t=="string"?t=this.cwd.resolve(t):t instanceof Y||(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 Y||(e=t,t=this.cwd);let{withFileTypes:i=!0,follow:r=!1,filter:n,walkFilter:o}=e;(!n||n(t))&&(yield i?t:t.fullpath());let a=new Set([t]);for(let c of a){let l=c.readdirSync();for(let h of l){(!n||n(h))&&(yield i?h:h.fullpath());let f=h;if(h.isSymbolicLink()){if(!(r&&(f=h.realpathSync())))continue;f.isUnknown()&&f.lstatSync()}f.shouldWalk(a,o)&&a.add(f)}}}stream(t=this.cwd,e={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof Y||(e=t,t=this.cwd);let{withFileTypes:i=!0,follow:r=!1,filter:n,walkFilter:o}=e,a=new $t({objectMode:!0});(!n||n(t))&&a.write(i?t:t.fullpath());let c=new Set,l=[t],h=0,f=()=>{let u=!1;for(;!u;){let d=l.shift();if(!d){h===0&&a.end();return}h++,c.add(d);let m=(y,g,S=!1)=>{if(y)return a.emit("error",y);if(r&&!S){let x=[];for(let w of g)w.isSymbolicLink()&&x.push(w.realpath().then(b=>b?.isUnknown()?b.lstat():b));if(x.length){Promise.all(x).then(()=>m(null,g,!0));return}}for(let x of g)x&&(!n||n(x))&&(a.write(i?x:x.fullpath())||(u=!0));h--;for(let x of g){let w=x.realpathCached()||x;w.shouldWalk(c,o)&&l.push(w)}u&&!a.flowing?a.once("drain",f):p||f()},p=!0;d.readdirCB(m,!0),p=!1}};return f(),a}streamSync(t=this.cwd,e={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof Y||(e=t,t=this.cwd);let{withFileTypes:i=!0,follow:r=!1,filter:n,walkFilter:o}=e,a=new $t({objectMode:!0}),c=new Set;(!n||n(t))&&a.write(i?t:t.fullpath());let l=[t],h=0,f=()=>{let u=!1;for(;!u;){let d=l.shift();if(!d){h===0&&a.end();return}h++,c.add(d);let m=d.readdirSync();for(let p of m)(!n||n(p))&&(a.write(i?p:p.fullpath())||(u=!0));h--;for(let p of m){let y=p;if(p.isSymbolicLink()){if(!(r&&(y=p.realpathSync())))continue;y.isUnknown()&&y.lstatSync()}y.shouldWalk(c,o)&&l.push(y)}}u&&!a.flowing&&a.once("drain",f)};return f(),a}chdir(t=this.cwd){let e=this.cwd;this.cwd=typeof t=="string"?this.cwd.resolve(t):t,this.cwd[po](e)}},ue=class extends $s{sep="\\";constructor(t=process.cwd(),e={}){let{nocase:i=!0}=e;super(t,rr,"\\",{...e,nocase:i}),this.nocase=i;for(let r=this.cwd;r;r=r.parent)r.nocase=this.nocase}parseRootPath(t){return rr.parse(t).root.toUpperCase()}newRoot(t){return new Is(this.rootPath,_t,void 0,this.roots,this.nocase,this.childrenCache(),{fs:t})}isAbsolute(t){return t.startsWith("/")||t.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(t)}},de=class extends $s{sep="/";constructor(t=process.cwd(),e={}){let{nocase:i=!1}=e;super(t,zf,"/",{...e,nocase:i}),this.nocase=i}parseRootPath(t){return"/"}newRoot(t){return new Ms(this.rootPath,_t,void 0,this.roots,this.nocase,this.childrenCache(),{fs:t})}isAbsolute(t){return t.startsWith("/")}},Ve=class extends de{constructor(t=process.cwd(),e={}){let{nocase:i=!0}=e;super(t,{...e,nocase:i})}},oy=process.platform==="win32"?Is:Ms,Ls=process.platform==="win32"?ue:process.platform==="darwin"?Ve:de;var nh=s=>s.length>=1,oh=s=>s.length>=1,me=class s{#t;#s;#n;length;#r;#o;#S;#y;#f;#a;#u=!0;constructor(t,e,i,r){if(!nh(t))throw new TypeError("empty pattern list");if(!oh(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,i<0||i>=this.length)throw new TypeError("index out of range");if(this.#t=t,this.#s=e,this.#n=i,this.#r=r,this.#n===0){if(this.isUNC()){let[n,o,a,c,...l]=this.#t,[h,f,u,d,...m]=this.#s;l[0]===""&&(l.shift(),m.shift());let p=[n,o,a,c,""].join("/"),y=[h,f,u,d,""].join("/");this.#t=[p,...l],this.#s=[y,...m],this.length=this.#t.length}else if(this.isDrive()||this.isAbsolute()){let[n,...o]=this.#t,[a,...c]=this.#s;o[0]===""&&(o.shift(),c.shift());let l=n+"/",h=a+"/";this.#t=[l,...o],this.#s=[h,...c],this.length=this.#t.length}}}pattern(){return this.#t[this.#n]}isString(){return typeof this.#t[this.#n]=="string"}isGlobstar(){return this.#t[this.#n]===U}isRegExp(){return this.#t[this.#n]instanceof RegExp}globString(){return this.#S=this.#S||(this.#n===0?this.isAbsolute()?this.#s[0]+this.#s.slice(1).join("/"):this.#s.join("/"):this.#s.slice(this.#n).join("/"))}hasMore(){return this.length>this.#n+1}rest(){return this.#o!==void 0?this.#o:this.hasMore()?(this.#o=new s(this.#t,this.#s,this.#n+1,this.#r),this.#o.#a=this.#a,this.#o.#f=this.#f,this.#o.#y=this.#y,this.#o):this.#o=null}isUNC(){let t=this.#t;return this.#f!==void 0?this.#f:this.#f=this.#r==="win32"&&this.#n===0&&t[0]===""&&t[1]===""&&typeof t[2]=="string"&&!!t[2]&&typeof t[3]=="string"&&!!t[3]}isDrive(){let t=this.#t;return this.#y!==void 0?this.#y:this.#y=this.#r==="win32"&&this.#n===0&&this.length>1&&typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0])}isAbsolute(){let t=this.#t;return this.#a!==void 0?this.#a:this.#a=t[0]===""&&t.length>1||this.isDrive()||this.isUNC()}root(){let t=this.#t[0];return typeof t=="string"&&this.isAbsolute()&&this.#n===0?t:""}checkFollowGlobstar(){return!(this.#n===0||!this.isGlobstar()||!this.#u)}markFollowGlobstar(){return this.#n===0||!this.isGlobstar()||!this.#u?!1:(this.#u=!1,!0)}};var ah=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",pe=class{relative;relativeChildren;absolute;absoluteChildren;platform;mmopts;constructor(t,{nobrace:e,nocase:i,noext:r,noglobstar:n,platform:o=ah}){this.relative=[],this.absolute=[],this.relativeChildren=[],this.absoluteChildren=[],this.platform=o,this.mmopts={dot:!0,nobrace:e,nocase:i,noext:r,noglobstar:n,optimizationLevel:2,platform:o,nocomment:!0,nonegate:!0};for(let a of t)this.add(a)}add(t){let e=new X(t,this.mmopts);for(let i=0;i<e.set.length;i++){let r=e.set[i],n=e.globParts[i];if(!r||!n)throw new Error("invalid pattern object");for(;r[0]==="."&&n[0]===".";)r.shift(),n.shift();let o=new me(r,n,0,this.platform),a=new X(o.globString(),this.mmopts),c=n[n.length-1]==="**",l=o.isAbsolute();l?this.absolute.push(a):this.relative.push(a),c&&(l?this.absoluteChildren.push(a):this.relativeChildren.push(a))}}ignored(t){let e=t.fullpath(),i=`${e}/`,r=t.relative()||".",n=`${r}/`;for(let o of this.relative)if(o.match(r)||o.match(n))return!0;for(let o of this.absolute)if(o.match(e)||o.match(i))return!0;return!1}childrenIgnored(t){let e=t.fullpath()+"/",i=(t.relative()||".")+"/";for(let r of this.relativeChildren)if(r.match(i))return!0;for(let r of this.absoluteChildren)if(r.match(e))return!0;return!1}};var or=class s{store;constructor(t=new Map){this.store=t}copy(){return new s(new Map(this.store))}hasWalked(t,e){return this.store.get(t.fullpath())?.has(e.globString())}storeWalked(t,e){let i=t.fullpath(),r=this.store.get(i);r?r.add(e.globString()):this.store.set(i,new Set([e.globString()]))}},ar=class{store=new Map;add(t,e,i){let r=(e?2:0)|(i?1:0),n=this.store.get(t);this.store.set(t,n===void 0?r:r&n)}entries(){return[...this.store.entries()].map(([t,e])=>[t,!!(e&2),!!(e&1)])}},cr=class{store=new Map;add(t,e){if(!t.canReaddir())return;let i=this.store.get(t);i?i.find(r=>r.globString()===e.globString())||i.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())}},Je=class s{hasWalkedCache;matches=new ar;subwalks=new cr;patterns;follow;dot;opts;constructor(t,e){this.opts=t,this.follow=!!t.follow,this.dot=!!t.dot,this.hasWalkedCache=e?e.copy():new or}processPatterns(t,e){this.patterns=e;let i=e.map(r=>[t,r]);for(let[r,n]of i){this.hasWalkedCache.storeWalked(r,n);let o=n.root(),a=n.isAbsolute()&&this.opts.absolute!==!1;if(o){r=r.resolve(o==="/"&&this.opts.root!==void 0?this.opts.root:o);let f=n.rest();if(f)n=f;else{this.matches.add(r,!0,!1);continue}}if(r.isENOENT())continue;let c,l,h=!1;for(;typeof(c=n.pattern())=="string"&&(l=n.rest());)r=r.resolve(c),n=l,h=!0;if(c=n.pattern(),l=n.rest(),h){if(this.hasWalkedCache.hasWalked(r,n))continue;this.hasWalkedCache.storeWalked(r,n)}if(typeof c=="string"){let f=c===".."||c===""||c===".";this.matches.add(r.resolve(c),a,f);continue}else if(c===U){(!r.isSymbolicLink()||this.follow||n.checkFollowGlobstar())&&this.subwalks.add(r,n);let f=l?.pattern(),u=l?.rest();if(!l||(f===""||f===".")&&!u)this.matches.add(r,a,f===""||f===".");else if(f===".."){let d=r.parent||r;u?this.hasWalkedCache.hasWalked(d,u)||this.subwalks.add(d,u):this.matches.add(d,a,!0)}}else c instanceof RegExp&&this.subwalks.add(r,n)}return this}subwalkTargets(){return this.subwalks.keys()}child(){return new s(this.opts,this.hasWalkedCache)}filterEntries(t,e){let i=this.subwalks.get(t),r=this.child();for(let n of e)for(let o of i){let a=o.isAbsolute(),c=o.pattern(),l=o.rest();c===U?r.testGlobstar(n,o,l,a):c instanceof RegExp?r.testRegExp(n,c,l,a):r.testString(n,c,l,a)}return r}testGlobstar(t,e,i,r){if((this.dot||!t.name.startsWith("."))&&(e.hasMore()||this.matches.add(t,r,!1),t.canReaddir()&&(this.follow||!t.isSymbolicLink()?this.subwalks.add(t,e):t.isSymbolicLink()&&(i&&e.checkFollowGlobstar()?this.subwalks.add(t,i):e.markFollowGlobstar()&&this.subwalks.add(t,e)))),i){let n=i.pattern();if(typeof n=="string"&&n!==".."&&n!==""&&n!==".")this.testString(t,n,i.rest(),r);else if(n===".."){let o=t.parent||t;this.subwalks.add(o,i)}else n instanceof RegExp&&this.testRegExp(t,n,i.rest(),r)}}testRegExp(t,e,i,r){e.test(t.name)&&(i?this.subwalks.add(t,i):this.matches.add(t,r,!1))}testString(t,e,i,r){t.isNamed(e)&&(i?this.subwalks.add(t,i):this.matches.add(t,r,!1))}};var ch=(s,t)=>typeof s=="string"?new pe([s],t):Array.isArray(s)?new pe(s,t):s,Ws=class{path;patterns;opts;seen=new Set;paused=!1;aborted=!1;#t=[];#s;#n;signal;maxDepth;includeChildMatches;constructor(t,e,i){if(this.patterns=t,this.path=e,this.opts=i,this.#n=!i.posix&&i.platform==="win32"?"\\":"/",this.includeChildMatches=i.includeChildMatches!==!1,(i.ignore||!this.includeChildMatches)&&(this.#s=ch(i.ignore??[],i),!this.includeChildMatches&&typeof this.#s.add!="function")){let r="cannot ignore child matches, ignore lacks add() method.";throw new Error(r)}this.maxDepth=i.maxDepth||1/0,i.signal&&(this.signal=i.signal,this.signal.addEventListener("abort",()=>{this.#t.length=0}))}#r(t){return this.seen.has(t)||!!this.#s?.ignored?.(t)}#o(t){return!!this.#s?.childrenIgnored?.(t)}pause(){this.paused=!0}resume(){if(this.signal?.aborted)return;this.paused=!1;let t;for(;!this.paused&&(t=this.#t.shift());)t()}onResume(t){this.signal?.aborted||(this.paused?this.#t.push(t):t())}async matchCheck(t,e){if(e&&this.opts.nodir)return;let i;if(this.opts.realpath){if(i=t.realpathCached()||await t.realpath(),!i)return;t=i}let n=t.isUnknown()||this.opts.stat?await t.lstat():t;if(this.opts.follow&&this.opts.nodir&&n?.isSymbolicLink()){let o=await n.realpath();o&&(o.isUnknown()||this.opts.stat)&&await o.lstat()}return this.matchCheckTest(n,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.#r(t)?t:void 0}matchCheckSync(t,e){if(e&&this.opts.nodir)return;let i;if(this.opts.realpath){if(i=t.realpathCached()||t.realpathSync(),!i)return;t=i}let n=t.isUnknown()||this.opts.stat?t.lstatSync():t;if(this.opts.follow&&this.opts.nodir&&n?.isSymbolicLink()){let o=n.realpathSync();o&&(o?.isUnknown()||this.opts.stat)&&o.lstatSync()}return this.matchCheckTest(n,e)}matchFinish(t,e){if(this.#r(t))return;if(!this.includeChildMatches&&this.#s?.add){let n=`${t.relativePosix()}/**`;this.#s.add(n)}let i=this.opts.absolute===void 0?e:this.opts.absolute;this.seen.add(t);let r=this.opts.mark&&t.isDirectory()?this.#n:"";if(this.opts.withFileTypes)this.matchEmit(t);else if(i){let n=this.opts.posix?t.fullpathPosix():t.fullpath();this.matchEmit(n+r)}else{let n=this.opts.posix?t.relativePosix():t.relative(),o=this.opts.dotRelative&&!n.startsWith(".."+this.#n)?"."+this.#n:"";this.matchEmit(n?o+n+r:"."+r)}}async match(t,e,i){let r=await this.matchCheck(t,i);r&&this.matchFinish(r,e)}matchSync(t,e,i){let r=this.matchCheckSync(t,i);r&&this.matchFinish(r,e)}walkCB(t,e,i){this.signal?.aborted&&i(),this.walkCB2(t,e,new Je(this.opts),i)}walkCB2(t,e,i,r){if(this.#o(t))return r();if(this.signal?.aborted&&r(),this.paused){this.onResume(()=>this.walkCB2(t,e,i,r));return}i.processPatterns(t,e);let n=1,o=()=>{--n===0&&r()};for(let[a,c,l]of i.matches.entries())this.#r(a)||(n++,this.match(a,c,l).then(()=>o()));for(let a of i.subwalkTargets()){if(this.maxDepth!==1/0&&a.depth()>=this.maxDepth)continue;n++;let c=a.readdirCached();a.calledReaddir()?this.walkCB3(a,c,i,o):a.readdirCB((l,h)=>this.walkCB3(a,h,i,o),!0)}o()}walkCB3(t,e,i,r){i=i.filterEntries(t,e);let n=1,o=()=>{--n===0&&r()};for(let[a,c,l]of i.matches.entries())this.#r(a)||(n++,this.match(a,c,l).then(()=>o()));for(let[a,c]of i.subwalks.entries())n++,this.walkCB2(a,c,i.child(),o);o()}walkCBSync(t,e,i){this.signal?.aborted&&i(),this.walkCB2Sync(t,e,new Je(this.opts),i)}walkCB2Sync(t,e,i,r){if(this.#o(t))return r();if(this.signal?.aborted&&r(),this.paused){this.onResume(()=>this.walkCB2Sync(t,e,i,r));return}i.processPatterns(t,e);let n=1,o=()=>{--n===0&&r()};for(let[a,c,l]of i.matches.entries())this.#r(a)||this.matchSync(a,c,l);for(let a of i.subwalkTargets()){if(this.maxDepth!==1/0&&a.depth()>=this.maxDepth)continue;n++;let c=a.readdirSync();this.walkCB3Sync(a,c,i,o)}o()}walkCB3Sync(t,e,i,r){i=i.filterEntries(t,e);let n=1,o=()=>{--n===0&&r()};for(let[a,c,l]of i.matches.entries())this.#r(a)||this.matchSync(a,c,l);for(let[a,c]of i.subwalks.entries())n++,this.walkCB2Sync(a,c,i.child(),o);o()}},Ke=class extends Ws{matches=new Set;constructor(t,e,i){super(t,e,i)}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}},Xe=class extends Ws{results;constructor(t,e,i){super(t,e,i),this.results=new $t({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 fh=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",bt=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=lh(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(c=>c.replace(/\\/g,"/"))),this.matchBase){if(e.noglobstar)throw new TypeError("base matching requires globstar");t=t.map(c=>c.includes("/")?c:`./**/${c}`)}if(this.pattern=t,this.platform=e.platform||fh,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 c=e.platform==="win32"?ue:e.platform==="darwin"?Ve:e.platform?de:Ls;this.scurry=new c(this.cwd,{nocase:e.nocase,fs:e.fs})}this.nocase=this.scurry.nocase;let i=this.platform==="darwin"||this.platform==="win32",r={...e,dot:this.dot,matchBase:this.matchBase,nobrace:this.nobrace,nocase:this.nocase,nocaseMagicOnly:i,nocomment:!0,noext:this.noext,nonegate:!0,optimizationLevel:2,platform:this.platform,windowsPathsNoEscape:this.windowsPathsNoEscape,debug:!!this.opts.debug},n=this.pattern.map(c=>new X(c,r)),[o,a]=n.reduce((c,l)=>(c[0].push(...l.set),c[1].push(...l.globParts),c),[[],[]]);this.patterns=o.map((c,l)=>{let h=a[l];if(!h)throw new Error("invalid pattern object");return new me(c,h,0,this.platform)})}async walk(){return[...await new Ke(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 Ke(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 Xe(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 Xe(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 lr=(s,t={})=>{Array.isArray(s)||(s=[s]);for(let e of s)if(new X(e,t).hasMagic())return!0;return!1};function Bs(s,t={}){return new bt(s,t).streamSync()}function yo(s,t={}){return new bt(s,t).stream()}function Zt(s,t={}){return new bt(s,t).walkSync()}async function go(s,t={}){return new bt(s,t).walk()}function Us(s,t={}){return new bt(s,t).iterateSync()}function wo(s,t={}){return new bt(s,t).iterate()}var hh=Bs,uh=Object.assign(yo,{sync:Bs}),dh=Us,mh=Object.assign(wo,{sync:Us}),ph=Object.assign(Zt,{stream:Bs,iterate:Us}),Xt=Object.assign(go,{glob:go,globSync:Zt,sync:ph,globStream:yo,stream:uh,globStreamSync:Bs,streamSync:hh,globIterate:wo,iterate:mh,globIterateSync:Us,iterateSync:dh,Glob:bt,hasMagic:lr,escape:At,unescape:gt});Xt.glob=Xt;import{dirname as bo}from"path";import{mkdir as gh,mkdirSync as yh,stat as wh,statSync as bh}from"fs";var ft=s=>{if(!s)s={mode:511};else if(typeof s=="object")s={mode:511,...s};else if(typeof s=="number")s={mode:s};else if(typeof s=="string")s={mode:parseInt(s,8)};else throw new TypeError("invalid options argument");let t=s,e=s.fs||{};return s.mkdir=s.mkdir||e.mkdir||gh,s.mkdirAsync=s.mkdirAsync?s.mkdirAsync:async(i,r)=>new Promise((n,o)=>t.mkdir(i,r,(a,c)=>a?o(a):n(c))),s.stat=s.stat||e.stat||wh,s.statAsync=s.statAsync?s.statAsync:async i=>new Promise((r,n)=>t.stat(i,(o,a)=>o?n(o):r(a))),s.statSync=s.statSync||e.statSync||bh,s.mkdirSync=s.mkdirSync||e.mkdirSync||yh,t};var Tt=(s,t,e)=>{let i=bo(s),r={...ft(t),recursive:!1};if(i===s)try{return r.mkdirSync(s,r)}catch(n){let o=n;if(o&&o.code!=="EISDIR")throw n;return}try{return r.mkdirSync(s,r),e||s}catch(n){let o=n;if(o&&o.code==="ENOENT")return Tt(s,r,Tt(i,r,e));if(o&&o.code!=="EEXIST"&&o&&o.code!=="EROFS")throw n;try{if(!r.statSync(s).isDirectory())throw n}catch{throw n}}},Nt=Object.assign(async(s,t,e)=>{let i=ft(t);i.recursive=!1;let r=bo(s);return r===s?i.mkdirAsync(s,i).catch(n=>{let o=n;if(o&&o.code!=="EISDIR")throw n}):i.mkdirAsync(s,i).then(()=>e||s,async n=>{let o=n;if(o&&o.code==="ENOENT")return Nt(r,i).then(a=>Nt(s,i,a));if(o&&o.code!=="EEXIST"&&o.code!=="EROFS")throw n;return i.statAsync(s).then(a=>{if(a.isDirectory())return e;throw n},()=>{throw n})})},{sync:Tt});import{dirname as Eo}from"path";import{dirname as So}from"path";var fr=async(s,t,e)=>{if(e!==t)return s.statAsync(t).then(i=>i.isDirectory()?e:void 0,i=>{let r=i;return r&&r.code==="ENOENT"?fr(s,So(t),t):void 0})},hr=(s,t,e)=>{if(e!==t)try{return s.statSync(t).isDirectory()?e:void 0}catch(i){let r=i;return r&&r.code==="ENOENT"?hr(s,So(t),t):void 0}};var ge=(s,t)=>{let e=ft(t);if(e.recursive=!0,Eo(s)===s)return e.mkdirSync(s,e);let r=hr(e,s);try{return e.mkdirSync(s,e),r}catch(n){let o=n;if(o&&o.code==="ENOENT")return Tt(s,e);throw n}},Ze=Object.assign(async(s,t)=>{let e={...ft(t),recursive:!0};return Eo(s)===s?await e.mkdirAsync(s,e):fr(e,s).then(r=>e.mkdirAsync(s,e).then(n=>r||n).catch(n=>{let o=n;if(o&&o.code==="ENOENT")return Nt(s,e);throw n}))},{sync:ge});import{parse as Eh,resolve as xh}from"path";var Sh=process.env.__TESTING_MKDIRP_PLATFORM__||process.platform,ur=s=>{if(/\0/.test(s))throw Object.assign(new TypeError("path must be a string without null bytes"),{path:s,code:"ERR_INVALID_ARG_VALUE"});if(s=xh(s),Sh==="win32"){let t=/[*|"<>?:]/,{root:e}=Eh(s);if(t.test(s.substring(e.length)))throw Object.assign(new Error("Illegal characters in path."),{path:s,code:"EINVAL"})}return s};import{mkdir as vh,mkdirSync as _h}from"fs";var Th=process.env.__TESTING_MKDIRP_NODE_VERSION__||process.version,dr=Th.replace(/^v/,"").split("."),xo=+dr[0]>10||+dr[0]==10&&+dr[1]>=12,Qe=xo?s=>ft(s).mkdirSync===_h:()=>!1,zs=Object.assign(xo?s=>ft(s).mkdir===vh:()=>!1,{sync:Qe});var Pt=(s,t)=>{s=ur(s);let e=ft(t);return Qe(e)?ge(s,e):Tt(s,e)};var mr=Object.assign(async(s,t)=>{s=ur(s);let e=ft(t);return zs(e)?Ze(s,e):Nt(s,e)},{mkdirpSync:Pt,mkdirpNative:Ze,mkdirpNativeSync:ge,mkdirpManual:Nt,mkdirpManualSync:Tt,sync:Pt,native:Ze,nativeSync:ge,manual:Nt,manualSync:Tt,useNative:zs,useNativeSync:Qe});import mu from"node:constants";import{createHash as oa}from"node:crypto";import{chmodSync as aa,copyFileSync as pu,linkSync as gu,readFileSync as ca,readlinkSync as la,symlinkSync as yu,unlinkSync as wu}from"node:fs";import{dirname as rs,relative as fa,resolve as ei,sep as bu}from"node:path";var Lt=(s,t)=>typeof s>"u"||typeof s===t,vo=s=>!!s&&typeof s=="object"&&Lt(s.preserveRoot,"boolean")&&Lt(s.tmp,"string")&&Lt(s.maxRetries,"number")&&Lt(s.retryDelay,"number")&&Lt(s.backoff,"number")&&Lt(s.maxBackoff,"number")&&(Lt(s.glob,"boolean")||s.glob&&typeof s.glob=="object")&&Lt(s.filter,"function"),_o=s=>{if(!vo(s))throw new Error("invalid rimraf options")},To=s=>{_o(s);let{glob:t,...e}=s;if(!t)return e;let i=t===!0?s.signal?{signal:s.signal}:{}:s.signal?{signal:s.signal,...t}:t;return{...e,glob:{...i,absolute:!0,withFileTypes:!1}}},ko=(s={})=>To(s),Ao=(s={})=>To(s);import{parse as Oo,resolve as kh}from"path";import{inspect as Ah}from"util";var Oh=(s,t={})=>{let e=typeof s;if(e!=="string"){let r=s&&e==="object"&&s.constructor,o=`The "path" argument must be of type string. Received ${r&&r.name?`an instance of ${r.name}`:e==="object"?Ah(s):`type ${e} ${s}`}`;throw Object.assign(new TypeError(o),{path:s,code:"ERR_INVALID_ARG_TYPE"})}if(/\0/.test(s)){let r="path must be a string without null bytes";throw Object.assign(new TypeError(r),{path:s,code:"ERR_INVALID_ARG_VALUE"})}s=kh(s);let{root:i}=Oo(s);if(s===i&&t.preserveRoot!==!1){let r="refusing to remove root directory without preserveRoot:false";throw Object.assign(new Error(r),{path:s,code:"ERR_PRESERVE_ROOT"})}if(process.platform==="win32"){let r=/[*|"<>?:]/,{root:n}=Oo(s);if(r.test(s.substring(n.length)))throw Object.assign(new Error("Illegal characters in path."),{path:s,code:"EINVAL"})}return s},ts=Oh;import{readdirSync as Rh}from"fs";import jt from"fs/promises";import{chmodSync as Co,mkdirSync as pw,renameSync as No,rmdirSync as ye,rmSync as Po,statSync as jo,lstatSync as we,unlinkSync as be}from"fs";var Ro=s=>Rh(s,{withFileTypes:!0}),et={chmod:jt.chmod,mkdir:jt.mkdir,readdir:s=>jt.readdir(s,{withFileTypes:!0}),rename:jt.rename,rm:jt.rm,rmdir:jt.rmdir,stat:jt.stat,lstat:jt.lstat,unlink:jt.unlink};import{parse as Fo,resolve as Io}from"path";var{readdir:Ch}=et,Se=s=>Ch(s).catch(t=>t),Ee=s=>{try{return Ro(s)}catch(t){return t}};var Do=s=>!!s&&typeof s=="object",pr=(s,t)=>t in s&&typeof s[t]=="string",gr=s=>Do(s)&&pr(s,"code")&&pr(s,"path"),N=s=>Do(s)&&pr(s,"code")?s.code:null;var Q=async(s,t)=>s.catch(e=>{if(N(e)!=="ENOENT")throw t??e}),tt=(s,t)=>{try{return s()}catch(e){if(N(e)==="ENOENT")return;throw t??e}};var{lstat:Nh,rmdir:Ph,unlink:jh}=et,Gs=async(s,t)=>(t?.signal?.throwIfAborted(),await Q(Nh(s).then(e=>Mo(s,t,e)))??!0),Hs=(s,t)=>(t?.signal?.throwIfAborted(),tt(()=>$o(s,t,we(s)))??!0),Mo=async(s,t,e)=>{t?.signal?.throwIfAborted();let i=e.isDirectory()?await Se(s):null;if(!Array.isArray(i)){if(i){if(N(i)==="ENOENT")return!0;if(N(i)!=="ENOTDIR")throw i}return t.filter&&!await t.filter(s,e)?!1:(await Q(jh(s)),!0)}return!(await Promise.all(i.map(n=>Mo(Io(s,n.name),t,n)))).every(n=>n===!0)||t.preserveRoot===!1&&s===Fo(s).root||t.filter&&!await t.filter(s,e)?!1:(await Q(Ph(s)),!0)},$o=(s,t,e)=>{t?.signal?.throwIfAborted();let i=e.isDirectory()?Ee(s):null;if(!Array.isArray(i)){if(i){if(N(i)==="ENOENT")return!0;if(N(i)!=="ENOTDIR")throw i}return t.filter&&!t.filter(s,e)?!1:(tt(()=>be(s)),!0)}let r=!0;for(let n of i){let o=Io(s,n.name);r=$o(o,t,n)&&r}return t.preserveRoot===!1&&s===Fo(s).root||!r||t.filter&&!t.filter(s,e)?!1:(tt(()=>ye(s)),!0)};import{parse as qo,resolve as Vo}from"path";var{chmod:Dh}=et,es=s=>async t=>{try{return void await Q(s(t))}catch(e){if(N(e)==="EPERM")return await Q(Dh(t,438).then(()=>!0),e)?void await s(t):void 0;throw e}},ss=s=>t=>{try{return void tt(()=>s(t))}catch(e){if(N(e)==="EPERM")return tt(()=>(Co(t,438),!0),e)?void s(t):void 0;throw e}};import{setTimeout as Fh}from"timers/promises";var Ih=200,Mh=1.2,Lo=10,Wo=new Set(["EMFILE","ENFILE","EBUSY"]),yr=s=>{let t=async(e,i,r=1,n=0)=>{let o=i.maxBackoff||Ih,a=i.backoff||Mh,c=i.maxRetries||Lo,l=0;for(;;)try{return await s(e)}catch(h){if(gr(h)&&h.path===e&&Wo.has(h.code)){if(r=Math.ceil(r*a),n=r+n,n<o)return await Fh(r),t(e,i,r,n);if(l<c){l++;continue}}throw h}};return t},wr=s=>(e,i)=>{let r=i.maxRetries||Lo,n=0;for(;;)try{return s(e)}catch(o){if(gr(o)&&o.path===e&&Wo.has(o.code)&&n<r){n++;continue}throw o}};import{basename as Hh,parse as Vs,resolve as Js}from"path";import{tmpdir as qs}from"os";import{parse as Ys,resolve as Bo}from"path";var{stat:$h}=et,Lh=s=>{try{return jo(s).isDirectory()}catch{return!1}},Wh=s=>$h(s).then(t=>t.isDirectory(),()=>!1),Bh=async s=>{let{root:t}=Ys(s),e=qs(),{root:i}=Ys(e);if(t.toLowerCase()===i.toLowerCase())return e;let r=Bo(t,"/temp");return await Wh(r)?r:t},Uh=s=>{let{root:t}=Ys(s),e=qs(),{root:i}=Ys(e);if(t.toLowerCase()===i.toLowerCase())return e;let r=Bo(t,"/temp");return Lh(r)?r:t},zh=async()=>qs(),Gh=()=>qs(),Uo=process.platform==="win32"?Bh:zh,zo=process.platform==="win32"?Uh:Gh;var{lstat:Yh,rename:qh,unlink:Vh,rmdir:Jh}=et,Yo=s=>`.${Hh(s)}.${Math.random()}`,Kh=es(Vh),Xh=ss(be),Ks=async(s,t)=>(t?.signal?.throwIfAborted(),await Q(Yh(s).then(e=>br(s,t,e)))??!0),br=async(s,t,e)=>{if(t?.signal?.throwIfAborted(),!t.tmp)return br(s,{...t,tmp:await Uo(s)},e);if(s===t.tmp&&Vs(s).root!==s)throw new Error("cannot delete temp directory used for deletion");let i=e.isDirectory()?await Se(s):null;if(!Array.isArray(i)){if(i){if(N(i)==="ENOENT")return!0;if(N(i)!=="ENOTDIR")throw i}return t.filter&&!await t.filter(s,e)?!1:(await Q(Go(s,t.tmp,Kh)),!0)}return!(await Promise.all(i.map(n=>br(Js(s,n.name),t,n)))).every(n=>n===!0)||t.preserveRoot===!1&&s===Vs(s).root||t.filter&&!await t.filter(s,e)?!1:(await Q(Go(s,t.tmp,Jh)),!0)},Go=async(s,t,e)=>{let i=Js(t,Yo(s));return await qh(s,i),await e(i)},Xs=(s,t)=>(t?.signal?.throwIfAborted(),tt(()=>Sr(s,t,we(s)))??!0),Sr=(s,t,e)=>{if(t?.signal?.throwIfAborted(),!t.tmp)return Sr(s,{...t,tmp:zo(s)},e);let i=t.tmp;if(s===t.tmp&&Vs(s).root!==s)throw new Error("cannot delete temp directory used for deletion");let r=e.isDirectory()?Ee(s):null;if(!Array.isArray(r)){if(r){if(N(r)==="ENOENT")return!0;if(N(r)!=="ENOTDIR")throw r}return t.filter&&!t.filter(s,e)?!1:(tt(()=>Ho(s,i,Xh)),!0)}let n=!0;for(let o of r){let a=Js(s,o.name);n=Sr(a,t,o)&&n}return!n||t.preserveRoot===!1&&s===Vs(s).root||t.filter&&!t.filter(s,e)?!1:(tt(()=>Ho(s,i,ye)),!0)},Ho=(s,t,e)=>{let i=Js(t,Yo(s));return No(s,i),e(i)};var{unlink:Zh,rmdir:Qh,lstat:tu}=et,eu=yr(es(Zh)),su=wr(ss(be)),iu=yr(es(Qh)),ru=wr(ss(ye)),nu=async(s,{filter:t,...e})=>{e?.signal?.throwIfAborted();try{return await iu(s,e),!0}catch(i){if(N(i)==="ENOTEMPTY")return Ks(s,e);throw i}},ou=(s,{filter:t,...e})=>{e?.signal?.throwIfAborted();try{return ru(s,e),!0}catch(i){if(N(i)==="ENOTEMPTY")return Xs(s,e);throw i}},Wt=Symbol("start"),Jo=Symbol("child"),Zs=Symbol("finish"),Qs=async(s,t)=>(t?.signal?.throwIfAborted(),await Q(tu(s).then(e=>Er(s,t,e,Wt)))??!0),ti=(s,t)=>(t?.signal?.throwIfAborted(),tt(()=>xr(s,t,we(s),Wt))??!0),Er=async(s,t,e,i=Wt)=>{t?.signal?.throwIfAborted();let r=e.isDirectory()?await Se(s):null;if(!Array.isArray(r)){if(r){if(N(r)==="ENOENT")return!0;if(N(r)!=="ENOTDIR")throw r}return t.filter&&!await t.filter(s,e)?!1:(await Q(eu(s,t)),!0)}let n=i===Wt?Jo:i,o=(await Promise.all(r.map(a=>Er(Vo(s,a.name),t,a,n)))).every(a=>a===!0);if(i===Wt)return Er(s,t,e,Zs);if(i===Zs){if(t.preserveRoot===!1&&s===qo(s).root||!o||t.filter&&!await t.filter(s,e))return!1;await Q(nu(s,t))}return!0},xr=(s,t,e,i=Wt)=>{let r=e.isDirectory()?Ee(s):null;if(!Array.isArray(r)){if(r){if(N(r)==="ENOENT")return!0;if(N(r)!=="ENOTDIR")throw r}return t.filter&&!t.filter(s,e)?!1:(tt(()=>su(s,t)),!0)}let n=!0;for(let o of r){let a=i===Wt?Jo:i,c=Vo(s,o.name);n=xr(c,t,o,a)&&n}if(i===Wt)return xr(s,t,e,Zs);if(i===Zs){if(t.preserveRoot===!1&&s===qo(s).root||!n||t.filter&&!t.filter(s,e))return!1;tt(()=>ou(s,t))}return!0};var vr=process.platform==="win32"?Qs:Gs,_r=process.platform==="win32"?ti:Hs;var{rm:au}=et,Tr=async(s,t)=>(await au(s,{...t,force:!0,recursive:!0}),!0),kr=(s,t)=>(Po(s,{...t,force:!0,recursive:!0}),!0);var[Ko=0,cu=0]=process.version.replace(/^v/,"").split(".").map(s=>parseInt(s,10)),Xo=Ko>14||Ko===14&&cu>=14,Zo=!Xo||process.platform==="win32"?()=>!1:s=>!s?.signal&&!s?.filter,Qo=!Xo||process.platform==="win32"?()=>!1:s=>!s?.signal&&!s?.filter;var xe=s=>async(t,e)=>{let i=ko(e);return i.glob&&(t=await Xt(t,i.glob)),Array.isArray(t)?!!(await Promise.all(t.map(r=>s(ts(r,i),i)))).reduce((r,n)=>r&&n,!0):!!await s(ts(t,i),i)},ve=s=>(t,e)=>{let i=Ao(e);return i.glob&&(t=Zt(t,i.glob)),Array.isArray(t)?!!t.map(r=>s(ts(r,i),i)).reduce((r,n)=>r&&n,!0):!!s(ts(t,i),i)},ea=ve(kr),lu=Object.assign(xe(Tr),{sync:ea}),sa=ve(_r),fu=Object.assign(xe(vr),{sync:sa}),ia=ve(ti),hu=Object.assign(xe(Qs),{sync:ia}),ra=ve(Hs),uu=Object.assign(xe(Gs),{sync:ra}),na=ve(Xs),du=Object.assign(xe(Ks),{sync:na}),st=ve((s,t)=>Qo(t)?kr(s,t):_r(s,t));var ta=xe((s,t)=>Zo(t)?Tr(s,t):vr(s,t)),ht=Object.assign(ta,{rimraf:ta,sync:st,rimrafSync:st,manual:fu,manualSync:sa,native:lu,nativeSync:ea,posix:uu,posixSync:ra,windows:hu,windowsSync:ia,moveRemove:du,moveRemoveSync:na});ht.rimraf=ht;var is=s=>{try{return Pt(s)}catch{return is(rs(s)),st(s),Pt(s)}};var Su=(s,t)=>{if(!(s.isSymbolicLink()||s.isDirectory()||s.isFile())){t.isENOENT()||st(t.fullpath());return}if(s.isSymbolicLink()){let i=la(s.fullpath());if(!t.isENOENT()){if((t.isSymbolicLink()&&la(t.fullpath()))===i)return;st(t.fullpath())}if(is(rs(t.fullpath())),yu(i,t.fullpath()),mu.O_SYMLINK&&s.mode)try{aa(t.fullpath(),s.mode)}catch{}return}if(s.isDirectory())t.isDirectory()||is(t.fullpath());else{let i=!0;if(!t.isENOENT()&&!t.isFile()?st(t.fullpath()):Eu(s,t)&&(i=!1),i){is(rs(t.fullpath()));try{gu(s.fullpath(),t.fullpath())}catch{pu(s.fullpath(),t.fullpath())}}}let e=s.mode;e&&aa(t.fullpath(),e)};var Eu=(s,t)=>{try{return oa("sha512").update(ca(s.fullpath())).digest("hex")===oa("sha512").update(ca(t.fullpath())).digest("hex")}catch{return!1}},ha=`..${bu}`,xu=(s,t)=>{if(s===t)return!0;let e=fa(s,t),i=fa(s,t);return!e.startsWith(ha)||!i.startsWith(ha)};var ua=(s,t)=>{let e=new Ls(s),i=ei(s),r=ei(t);if(rs(i)===i||rs(r)===r)throw new Error("cannot sync root directory");if(xu(r,i))throw new Error("cannot copy directory into itself or its parent");let[n,o]=[Zt("**",{scurry:e,withFileTypes:!0}),Zt("**",{cwd:r,withFileTypes:!0})];for(let a of n){if(!a.parent)throw new Error("cannot sync root directory");let c=a.resolve(ei(r,a.relative())),l=c.parent;if(!l)throw new Error("cannot sync root directory");c.lstatSync(),is(l.fullpath()),Su(a,c)}for(let a of o){let c=e.cwd.resolve(ei(i,a.relative()));if(c.lstatSync(),c.isENOENT())try{st(a.fullpath()),wu(a.fullpath())}catch{}}};import{chmodSync as da}from"fs";import{resolve as ma}from"path";var pa=()=>{let{bin:s}=k;if(s)if(typeof s=="string")da(ma(s),493);else for(let t of Object.values(s))da(ma(t),493)};import{spawnSync as Kd}from"node:child_process";import{relative as ac,resolve as Ne}from"node:path/posix";import{writeFileSync as vu}from"fs";var ga=s=>{let{imports:t}=s;if(t)return Object.fromEntries(Object.entries(t).map(([e,i])=>[e,typeof i=="string"&&i.startsWith("./src/")?"./"+i.substring(6).replace(/\.([cm]?)ts$/,".$1js").replace(/\.tsx$/,".js"):i]))};var _u=(s,t)=>{if(!t)return st(`${s}/package.json`);let e={type:t==="commonjs"?"commonjs":"module",imports:ga(k)};vu(`${s}/package.json`,JSON.stringify(e,null,2)+`
|
|
13
|
+
`)},q=(s,t)=>{t&&_(E.cyan.dim("set dialect"),{where:s,mode:t}),_u(s,t)};import{existsSync as sd,readdirSync as id,unlinkSync as rd,writeFileSync as nd}from"node:fs";import{resolve as od}from"node:path";import{join as Da}from"node:path/posix";var{esmDialects:Tu=[],commonjsDialects:ku=[]}=A,ns=class{type;name;map=new Map;constructor(t,e){this.type=t,this.name=e}addFile(t,e){let i=this.type==="commonjs"?"cts":"mts",r=`-${this.name}.${i}`;if(!t.endsWith(r))return;let n=t.substring(0,t.length-r.length)+".ts",o=n+"x";e.has(n)?this.map.set(t,n):e.has(o)&&this.map.set(t,o)}[Symbol.for("nodejs.util.inspect.custom")](){return[this.name,this.map]}},Bt=new Map([["cjs",new ns("commonjs","cjs")]]);for(let s of ku)Bt.set(s,new ns("commonjs",s));for(let s of Tu)Bt.set(s,new ns("esm",s));for(let s of Ot)for(let t of Bt.values())t.addFile(s,Ot);for(let[s,t]of Bt.entries())t.map.size===0&&Bt.delete(s);Bt.size&&_(E.cyan.dim("polyfills detected"),Bt);var W=Bt;import{dirname as Xu,isAbsolute as Zu,resolve as li}from"node:path";import{readFileSync as Qu,statSync as td}from"node:fs";import{dirname as Au,resolve as Ou}from"path";var Ut=function*(s){for(s=Ou(s);s;){yield s;let t=Au(s);if(t===s)break;s=t}};var ya=s=>"source"in s?s.source:s.children.map(ya).join(""),_e=ya;var Ar={offset:0,offsetMax:1/0,init:(s=1/0)=>{Ar.offset=0,Ar.offsetMax=s}},ut=Ar;function ii(s){var t={},e;for(e in s)t[e]=s[e];return t}function Qt(s){return" var y"+(s+("=state.y,x"+(s+"=state.x;")))}function Or(s){return"state.y=y"+(s+(";state.x=x"+(s+";")))}function os(s,t,e){if(s.expression){t=!!e.capture&&!s.capture;var i=e.length&&e.abort&&"node.length=ln"+(e.length+";")||"";s=" if((x = "+(s.expression.id+"(state)) "+(t?"!=":"==")+" null)"+((t?"{node.push(x);}else ":"")+("{"+(Or(e.index)+(i+(e.abort+"}"))))))}else i=!!e.capture&&!s.capture,e=ii(e),e.capture=i,!e.length&&i?(e.length=t,s="var ln"+(t+"=node.length;")+(Rr(s.sequence,t+1,e)+"")):s=Rr(s.sequence,t+1,e);return s}function ba(s,t,e){var i=e.index,r=e.abort,n="inv_"+t,o="group_"+t;return e=ii(e),s.capture==="!"&&(e.index=t,e.abort="break "+(n+"")),s.quantifier==="+"?(o=ii(s),o.quantifier="*",e=os(s,t,e)+(ba(o,t,e)+"")):s.quantifier==="*"?(e.length=0,e.index=t,e.abort="break "+(o+";"),e=o+(":for(;;){"+(Qt(t)+(os(s,t,e)+"}")))):s.quantifier==="?"&&s.expression?(e.index=t,e.abort="",e=Qt(t)+(os(s,t,e)+"")):s.quantifier==="?"?(e.index=t,e.abort="break "+(o+""),e=o+(":{"+(Qt(t)+(os(s,t,e)+"}")))):e=os(s,t,e),s.capture==="!"?n+(":{"+(Qt(t)+(e+(Or(i)+(r+"}"))))):s.capture==="="?Qt(t)+(e+(Or(t)+"")):e}function Rr(s,t,e){for(var i=s.alternation?"alt_"+t:"",r="";s;s=s.alternation){var n="block_"+t,o=e;s.alternation&&(o=ii(e),o.index=t,o.abort="break "+(n+";"));for(var a="",c=0;c<s.length;c++)a+=ba(s[c],t,o);r=s.alternation?r+(n+(":{"+(Qt(t)+(a+(" break "+(i+";}")))))):r+a}return i?i+(":{"+(r+"}")):r}function si(s){throw new SyntaxError('Unexpected token "'+s+'"')}var wa=typeof/./g.sticky=="boolean";function Ru(s){return s.length?s:function(t){return s()(t)}}function Cu(s){return function(t){if(t.x<t.quasis.length){for(var e=t.quasis[t.x],i=0,r=s.length;i<r;i++)if(e.charCodeAt(t.y+i)!==s.charCodeAt(i))return null;return t.y+=s.length,s}}}function Nu(s){return s=wa?new RegExp(s.source,"y"):new RegExp(s.source+"|()","g"),function(t){if(t.x<t.quasis.length){var e=t.quasis[t.x];s.lastIndex=t.y;var i;return wa?s.test(e)&&(i=e.slice(t.y,s.lastIndex)):(e=s.exec(e),e[1]==null&&(i=e[0])),t.y=s.lastIndex,i}}}function Pu(s){return typeof s=="function"?Ru(s):typeof s=="string"?Cu(s):Nu(s)}function ju(s,t){return{id:"_"+t}}function Du(s,t){return"_"+t}function Sa(s,t){return function(e){for(var i=[],r=arguments.length-1;0<r--;)i[r]=arguments[r+1];var n=i.map(ju),o=[];r=[];for(var a=null,c,l=r,h,f,u=0;u<e.length+n.length;u++){u%2!==0&&(f=n[u++>>1],l.push({expression:f,capture:h}),h=void 0);var d=e[u>>1];for(f=0;f<d.length;){var m=d[f++];m!==" "&&m!==" "&&m!=="\r"&&m!==`
|
|
14
|
+
`&&(m==="|"&&l.length?l=l.alternation=[]:m===")"&&l.length?(a=null,(l=o.pop())||si(m)):m==="("?(o.push(l),l.push(a={sequence:[],capture:h}),l=a.sequence,h=void 0):m===":"||m==="="||m==="!"?(h=m,d[f]&&d[f]!=="("&&si(m)):m==="?"&&!l.length&&a?(h=d[f++],h===":"||h==="="||h==="!"?(a.capture=h,h=void 0):si(m)):m!=="?"&&m!=="+"&&m!=="*"||!(c=l[l.length-1])?si(m):c.quantifier=m)}}return c=[s,t].concat(i.map(Pu)),h=Function,i="_n,_t,"+i.map(Du).join(","),n=t?"_t":null,r="(function(state){"+(Qt(1)+(" var node=[];var x;"+(Rr(r,2,{index:1,length:0,abort:"return;",capture:!0})+(" if(_n)node.tag=_n;return "+((n?"("+(n+")(node)"):"node")+";})"))))),new h(i,"return "+r).apply(void 0,c)}}function ri(s){return function(t){for(var e=[],i=arguments.length-1;0<i--;)e[i]=arguments[i+1];return typeof t=="string"&&(t=[t]),s({quasis:t,expressions:e,x:0,y:0})}}var Te={tokenDelimiterTypes:new Set(["ArrayOpen","ArrayClose","ObjectOpen","ObjectClose"]),tokenIgnoredTypes:new Set(["Newline","Whitespace","CommentLine","CommentBlock","Comma","CommaTrailing","Colon"]),tokenLiteralTypes:new Set(["Null","True","False","Number","String","Array","Object"]),isEven:s=>!(s%2),isOdd:s=>!Te.isEven(s),isString:s=>typeof s=="string",isToken:s=>!Te.isString(s),isTokenDelimiter:s=>Te.tokenDelimiterTypes.has(s.type),isTokenIgnored:s=>Te.tokenIgnoredTypes.has(s.type),isTokenLiteral:s=>Te.tokenLiteralTypes.has(s.type),tokens2matchers:s=>{let t=new Map;return Object.keys(s).reduce((e,i)=>{let r=s[i],n=r.unwrapped?r:t.get(r)||Sa(i,r);return t.set(r,n),e[i]=n,e},{})}},B=Te;var Fu=s=>{let t=B.tokens2matchers(s),e=t.EarlyReturn`${""}`,i=t.Insufficient`${/[^]?/}`,r=t.Invalid`${/[^]/}`,n=t.Newline`${/\r?\n|\r/}`,o=t.Whitespace`${/[ \t]+/}`,a=t.CommentLine`${/\/\/.*/}`,c=t.CommentBlock`${/\/\*[^]*?\*\//}`,l=t.Passthrough`${n} | ${o} | ${a} | ${c}`,h=t.Passthrough`${l}*`,f=t.Whitespace`${/(?:[ \t\r\n]|\/\/.*|\/\*[^]*?\*\/)*/}`,u=t.Newline===t.Whitespace&&t.Whitespace===t.CommentLine&&t.CommentLine===t.CommentBlock?f:h,d=t.Comma`${","}`,m=t.CommaTrailing`${","}`,p=t.Colon`${":"}`,y=t.Null`${"null"}`,g=t.True`${"true"}`,S=t.False`${"false"}`,x=t.Passthrough`${g} | ${S}`,w=t.Number`${/-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][-+]?\d+)?/}`,b=t.String`${/"(?:[^\u0000-\u001F\\"]|\\["bfnrt\\/]|\\u[0-9a-fA-F]{4})*"/}`,I=t.ArrayOpen`${"["}`,it=t.ArrayClose`${"]"}`,qt=t.Passthrough`${u} ${()=>Pi} ${u}`,Dt=t.Passthrough`${qt} (!${e} ${d} ${qt})* ${m}?`,Ft=t.Array`${I} ${u} ${Dt}? ${u} (${e} | ${it})`,nn=t.ObjectOpen`${"{"}`,Hc=t.ObjectClose`${"}"}`,on=t.Passthrough`${u} ${b} (${e} | ${u} ${p} ${u} ${()=>Pi} ${u})`,Yc=t.Passthrough`${on} (!${e} ${d} ${on})* ${m}?`,qc=t.Object`${nn} ${u} ${Yc}? ${u} (${e} | ${Hc})`,Pi=t.Passthrough`${y} | ${x} | ${w} | ${b} | ${qc} | ${Ft}`;return t.Root`${u} (${Pi} | ${i}) (${e} | ${u} ${r}?)`},ni=Fu;var V=s=>t=>{let e=t[0];return ut.offset+=e.length,{type:s,source:e}},Cr=s=>t=>{let e=t.flat();return{type:s,children:e}},Ea={EarlyReturn:()=>{if(ut.offset>ut.offsetMax)return[]},Insufficient:s=>{throw s[0].length&&Ea.Invalid(s),new SyntaxError("Unexpected end of JSONC input")},Invalid:s=>{throw new SyntaxError(`Unexpected token ${s[0]} in JSONC at position ${ut.offset}`)},Passthrough:s=>s.flat().filter(B.isToken),Newline:V("Newline"),Whitespace:V("Whitespace"),CommentLine:V("CommentLine"),CommentBlock:V("CommentBlock"),Comma:V("Comma"),CommaTrailing:V("CommaTrailing"),Colon:V("Colon"),Null:V("Null"),True:V("True"),False:V("False"),Number:V("Number"),String:V("String"),ArrayOpen:V("ArrayOpen"),ArrayClose:V("ArrayClose"),Array:Cr("Array"),ObjectOpen:V("ObjectOpen"),ObjectClose:V("ObjectClose"),Object:Cr("Object"),Root:Cr("Root")},oi=Ea;var as=s=>(ut.offset+=s[0].length,""),ai=s=>{let t=s.join("");return ut.offset+=t.length,t},dt=(s,t)=>t;dt.unwrapped=!0;var Iu={...oi,Passthrough:ai,Newline:as,Whitespace:as,CommentLine:as,CommentBlock:as,Comma:dt,CommaTrailing:as,Colon:dt,Null:dt,True:dt,False:dt,Number:dt,String:dt,ArrayOpen:dt,ArrayClose:dt,Array:ai,ObjectOpen:dt,ObjectClose:dt,Object:ai,Root:ai},xa=Iu;var Mu=ri(ni(xa)),va=Mu;var $u=s=>(ut.init(),va(s)),cs=$u;var Nr=JSON.parse,Lu=(s,t)=>{if(s=`${s}`,t)return Nr(cs(s),t);try{return Nr(s)}catch(e){let i=cs(s);if(s===i)throw e;return Nr(i)}},zt=Lu;var Wu=ri(ni(oi)),_a=Wu;var Bu=(s,t)=>(ut.init(t),_a(s)),ci=Bu;var Uu=(s,t)=>{let e=null,i=0,r=c=>{c.start>t||c.end<=t-1||e&&B.isTokenLiteral(e)||e&&B.isTokenIgnored(c)||(e=c)},n=(c,l,h,f)=>{let{type:u,source:d}=c,m=i,p=i+=d.length,y={type:u,source:d,token:c,parent:l,depth:h,index:f,start:m,end:p};return r(y),y},o=(c,l,h,f)=>{let{type:u}=c,d={type:u,children:[],token:c,parent:l,depth:h,index:f};return d.children=c.children.map((m,p)=>a(m,d,h+1,p)).filter(B.isTokenLiteral),d.children.forEach((m,p)=>m.index=p),d},a=(c,l,h,f)=>"children"in c?o(c,l,h,f):n(c,l,h,f);return a(s,null,-1,-1),e},zu=s=>{if(!s)return[];let t=[];for(;s;){let e=s.parent;if(!e)break;B.isTokenLiteral(s)&&(e.type==="Object"?B.isEven(s.index)?t.unshift(JSON.parse(s.source)):t.unshift(JSON.parse(e.children[s.index-1].source)):e.type==="Array"&&t.unshift(s.index)),s=e}return t},Gu=s=>{if(!s)return!1;let t=s.parent?.type;return t==="Object"?B.isTokenLiteral(s)?B.isEven(s.index):s.parent?.parent?.type==="Array":t==="Array"?B.isTokenLiteral(s)||s.parent?.parent?.type==="Array":!1},Hu=s=>{if(!s)return!1;let t=!s.parent?.children.length,e=s.parent?.type;return e==="Object"?t||B.isTokenDelimiter(s)||B.isTokenLiteral(s)&&B.isOdd(s.index):e==="Array"?s.depth>1:!1},Yu=(s,t)=>{if(!t||!s)return;let e=s.parent?.type;if(B.isTokenLiteral(s))return e==="Array"?s.index:zt(_e(s));if(e==="Array")return s.parent?.index},qu=(s,t,e)=>{if(!t||!s)return;if(B.isTokenLiteral(s))return zt(_e(s));if(e)return;let{parent:i}=s;if(!(!i||!i.token)&&!(i.type!=="Array"&&i.type!=="Object"))return zt(_e(i.token))},Vu=(s,t,e=!0)=>{let r=ci(s,e?t:1/0),n=Uu(r,t),o=zu(n),a=Gu(n),c=Hu(n),l=Yu(n,a),h=qu(n,c,e),f=n?{type:n.type,start:n.start,end:n.end,source:n.source}:void 0;return{path:o,property:l,value:h,token:f,isInsideProperty:a,isInsideValue:c}},Ta=Vu;var ka=JSON.stringify;var Ju=s=>{try{return zt(s),!0}catch{return!1}},Aa=Ju;var Ku={ast:{parse:ci,stringify:_e},lookup:Ta,parse:zt,stringify:ka,strip:cs,validate:Aa},Oa=Ku;var ke=s=>{try{return td(s).isFile()}catch{return!1}},ed,Ae=()=>{let s=A.project??"tsconfig.json";return ed??=Ca(Pr(s))},Pr=(s,t=process.cwd())=>{if(Zu(s))return s;let e=li(t,s);if(!ke(e)&&ke(e+".json")&&(e+=".json"),ke(e)||s.startsWith(".\\")||s.startsWith("./"))return e;for(let i of Ut(t)){let r=li(i,"node_modules",s);if(ke(r))return r;let n=li(i,"node_modules",s),o=li(n,"tsconfig.json");if(ke(o))return o;if(ke(n+".json"))return n+".json"}throw new Error("Could not resolve tsconfig file location",{cause:{target:s,from:t}})},Ra=(s,t)=>{for(let[e,i]of Object.entries(t))typeof i!="object"||Array.isArray(i)?s[e]??=i:e in s?typeof s[e]=="object"&&!Array.isArray(s[e])&&(s[e]=Ra(s[e],i)):s[e]=i;return s},Ca=(s,t=new Set)=>{try{let e=Oa.parse(Qu(Pr(s),"utf8"));if(!e||typeof e!="object"||Array.isArray(e))throw new Error("invalid data, expected object",{cause:e});if(e.compilerOptions||(e.compilerOptions={}),typeof e.extends=="string"){let i=Pr(e.extends,Xu(s));t.has(i)||(t.add(i),Ra(e,Ca(i,t)))}return e}catch(e){throw new Error("Invalid tsconfig file",{cause:e})}};var Na=()=>{Ae().compilerOptions.verbatimModuleSyntax&&(T("verbatimModuleSyntax detected"),F(`verbatimModuleSyntax is incompatible with multi-dialect builds. Either remove
|
|
15
15
|
this field from tsconfig.json, or set a single dialect in the "dialects"
|
|
16
16
|
field in package.json, for example:
|
|
17
17
|
|
|
@@ -28,8 +28,8 @@ or
|
|
|
28
28
|
"dialects": ["commonjs"]
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
|
-
`),ce(),process.exit(1))};var{dialects:jr=["esm","commonjs"],esmDialects:ad=[],commonjsDialects:cd=[],exclude:ld=[]}=A,Fa=ld.map(s=>`../${s.replace(/^\.\//,"")}`),fd={compilerOptions:{declaration:!0,declarationMap:!0,esModuleInterop:!0,forceConsistentCasingInFileNames:!0,inlineSources:!0,jsx:"react",module:"nodenext",moduleResolution:"nodenext",noUncheckedIndexedAccess:!0,resolveJsonModule:!0,skipLibCheck:!0,sourceMap:!0,strict:!0,target:"es2022"}},hd=()=>({extends:A.project===void 0?"../tsconfig.json":Da("..",A.project),compilerOptions:{target:
|
|
32
|
-
`);_(E.cyan.dim("writing tsconfig files..."));A.project===void 0&&!sd("tsconfig.json")?(_("using recommended tsconfig.json"),
|
|
31
|
+
`),ce(),process.exit(1))};var{dialects:jr=["esm","commonjs"],esmDialects:ad=[],commonjsDialects:cd=[],exclude:ld=[]}=A,Fa=ld.map(s=>`../${s.replace(/^\.\//,"")}`),fd={compilerOptions:{declaration:!0,declarationMap:!0,esModuleInterop:!0,forceConsistentCasingInFileNames:!0,inlineSources:!0,jsx:"react",module:"nodenext",moduleResolution:"nodenext",noUncheckedIndexedAccess:!0,resolveJsonModule:!0,skipLibCheck:!0,sourceMap:!0,strict:!0,target:"es2022"}},hd=()=>({extends:A.project===void 0?"../tsconfig.json":Da("..",A.project),compilerOptions:{target:Ae().compilerOptions.target===void 0?"es2022":void 0,rootDir:"../src",module:"nodenext",moduleResolution:"nodenext"}}),Pa=s=>{let t=[...Fa,"../src/**/*.mts","../src/package.json"];for(let[e,i]of W)if(e!==s)for(let r of i.map.keys())t.push(`../${Da(r)}`);return{extends:"./build.json",include:["../src/**/*.ts","../src/**/*.cts","../src/**/*.tsx","../src/**/*.json"],exclude:t,compilerOptions:{outDir:"../.tshy-build/"+(s==="cjs"?"commonjs":s)}}},ja=s=>{let t=[...Fa,"../src/package.json"];for(let[e,i]of W)if(e!==s)for(let r of i.map.keys())t.push(`../${r.replace(/^\.\//,"")}`);return{extends:"./build.json",include:["../src/**/*.ts","../src/**/*.mts","../src/**/*.tsx","../src/**/*.json"],exclude:t,compilerOptions:{outDir:"../.tshy-build/"+s}}};Pt(".tshy");var Oe=(s,t)=>nd(`.tshy/${s}.json`,JSON.stringify(t,null,2)+`
|
|
32
|
+
`);_(E.cyan.dim("writing tsconfig files..."));A.project===void 0&&!sd("tsconfig.json")?(_("using recommended tsconfig.json"),Oe("../tsconfig",fd)):(jr.length>1&&Na(),_("using existing tsconfig.json"));for(let s of id(".tshy"))rd(od(".tshy",s));Oe("build",hd());if(jr.includes("commonjs")){Oe("commonjs",Pa("cjs"));for(let s of cd)Oe(s,Pa(s))}if(jr.includes("esm")){Oe("esm",ja("esm"));for(let s of ad)Oe(s,ja(s))}import{writeFileSync as Wd}from"fs";import{symlink as Bd}from"fs/promises";import{dirname as Lr,relative as Ja,resolve as Wr,sep as $r}from"path";var fi=s=>{if(s&&typeof s=="object"&&!Array.isArray(s)){let t,e=[];for(let[i,r]of Object.entries(s))if(i){if(t===void 0){if(!i.startsWith("#")&&i!=="."&&!i.startsWith("./"))return ls(s).map(n=>[".",...n]);t=i.charAt(0)}if(t==="#"&&(i==="#"||!i.startsWith("#"))||t==="."&&i!=="."&&!i.startsWith("./"))throw new Error(`invalid ${t==="."?"exports":"imports"} object, all keys must start with ${t}. Found ${i}.`);e.push(...ls(r).map(n=>[i,...n]))}return e}return ls(s).map(t=>[".",...t])},ud=(s,t)=>{if(s.size>t.size)return!1;for(let e of s)if(!t.has(e))return!1;return!0},ls=(s,t=[],e=[])=>{if(s===void 0)return e;if(s===null||typeof s=="string")return e.push([new Set(t),s]),e;if(Array.isArray(s)){for(let i of s)if(ls(i,t,e),!i||typeof i=="string")break;return e}for(let[i,r]of Object.entries(s)){if(i.startsWith("#")||i==="."||i.startsWith("./"))throw new Error(`Expected valid import condition, got: ${i}`);let n=i==="default"?t:t.concat(i),o=new Set(n);if(e.some(([c])=>ud(c,o))||ls(r,n,e),i==="default")break}return e};var Ia=s=>[...new Set(fi(s).map(([t,e,i])=>i).filter(t=>!!t))];var Ma=s=>{let t=fi(s),e=[];for(let[i,r]of t)e.some(n=>dd(n,r))||e.push([...r]);return e},dd=(s,t)=>{if(s.length!==t.size)return!1;for(let e of s)if(!t.has(e))return!1;return!0};var $a=typeof process=="object"&&process&&process.platform==="win32";var La=s=>/^\.\.?\//.test(s)||$a&&/^\.\.?\\/.test(s);import{dirname as Dd,resolve as Fd}from"path";import{pathToFileURL as Va}from"url";import{realpath as ms}from"fs/promises";import mi from"module";import{basename as Ad,dirname as Od,isAbsolute as Rd,resolve as Ha}from"path";import{fileURLToPath as Cd,pathToFileURL as Fr}from"url";import{stat as md}from"fs/promises";var J=async s=>md(s).then(t=>t.isFile(),()=>!1);import{resolve as hs}from"path";import{pathToFileURL as te}from"url";import{realpath as pd,stat as gd}from"fs/promises";import{dirname as yd,resolve as Wa,sep as Dr}from"path";var wd=async s=>gd(s).then(t=>t.isDirectory(),()=>!1),hi=async(s,t)=>{for(let e of Ut(yd(t))){let i=Wa(e,"node_modules")+Dr,r=s===null?i:(s?Wa(i,s):i)+Dr;if(await wd(r))try{return await pd(r)+Dr}catch{}}};import{readFile as bd}from"node:fs/promises";var Ba=async s=>bd(s,"utf8").then(t=>JSON.parse(t)).catch(()=>null);var Sd=s=>!!s&&(typeof s=="object"||typeof s=="string"),Ed=s=>{if(!s||typeof s!="object"||Array.isArray(s))return!1;for(let t in s)if(!t.startsWith("#"))return!1;return!0},xd=s=>!!s&&typeof s=="object"&&(typeof s.name=="string"||typeof s.name>"u")&&(typeof s.main=="string"||typeof s.main>"u")&&(typeof s.module=="string"||typeof s.module>"u")&&(typeof s.exports>"u"||Sd(s.exports))&&(typeof s.imports>"u"||Ed(s.imports)),Gt=async s=>{let t=await Ba(s);return xd(t)?t:null};var ui=(s,t)=>{let e=Object.keys(t).filter(i=>i.length<=s.length).sort((i,r)=>r.length-i.length).map(i=>[i,i.split("*")]).filter(([,i])=>i.length===2);for(let[i,[r,n]]of e)if(s.startsWith(r)&&s.endsWith(n)){let o=s.substring(r.length,s.length-n.length);return[i,o]}return null};var mt=(s,t)=>{if(s===null||typeof s=="string")return s;if(Array.isArray(s)){for(let i of s){let r=mt(i,t);if(r)return r}return null}let e=new Set(["default"]);for(let i of t.conditions??["import","node"])i.startsWith("!")?e.delete(i.slice(1)):e.add(i);for(let[i,r]of Object.entries(s))if(e.has(i))return mt(r,t);return null};var Re=(s,t,e,i,r)=>{let n=s?s==="."||s.startsWith("./")?s:`./${s}`:".";if(typeof t=="string"||Array.isArray(t)){let l=n==="."&&mt(t,r);if(!l)throw fs(n,e,i);return l}if(n==="."){let l=mt(t,r);if(l)return l}let o=t,a=o[n];if(a!==void 0){let l=mt(a,r);if(!l)throw fs(n,e,i);return l}let c=ui(n,o);if(c){let[l,h]=c,f=mt(o[l],r);if(!f)throw fs(n,e,i);return f.replace(/\*/g,h)}throw fs(n,e,i)};var Ce=async(s,t,e)=>{let{originalParent:i}=e,r=s?.match(/^(@[^\/]+\/[^\/]+|[^\/]+)(?:\/(.*))?$/),[,n,o]=s===null?[,null,""]:r||["","",""],a=await hi(n,t);if(!a)throw us(n,i);let c=hs(a,"index.js"),l=hs(a,"package.json"),h=await Gt(l),f=o?hs(a,o):!1;if(!h)if(f){if(await J(f))return te(f);throw kt(f,i)}else{if(await J(c))return te(c);throw us(a,i)}if(h.exports){let u=Re(o,h.exports,l,i,e),d=hs(a,u);if(await J(d))return te(d);throw kt(d,i)}else if(f){if(await J(f))return te(f);throw kt(f,i)}else if(h.main){let u=hs(a,h.main);if(await J(u))return te(u);if(await J(c))return te(c);throw us(a,i)}else{if(await J(c))return te(c);throw us(a,i)}};import{dirname as vd,resolve as Ua}from"path";import{pathToFileURL as _d}from"url";var za=async(s,t,e)=>{let{originalParent:i}=e,r=s.match(/^(@[^\/]+\/[^\/]+|[^\/]+)(?:\/(.*))?$/);if(!r)throw Ga(s);for(let n of Ut(vd(t))){let o=Ua(n,"package.json"),a=await Gt(o);if(a){if(a.name&&a.exports){let[,c,l]=r;if(c===a.name){let h=Re(l,a.exports,o,i,e),f=Ua(n,h);if(await J(f))return _d(f);throw kt(f,i)}}if(s.startsWith("#")){if(!a.imports)throw ds(s,o,i);let c=a.imports[s];if(c!==void 0){let p=mt(c,e);if(!p)throw ds(s,o,i);return p.startsWith("#")?Ce(null,t,e):z(p,o,e)}let l=ui(s,a.imports);if(!l)throw ds(s,o,i);let[h,f]=l,u=a.imports[h],d=mt(u,e);if(!d)throw ds(s,o,i);if(d.startsWith("#"))return Ce(null,t,e);let m=d.replace(/\*/g,f);return z(m,o,e)}break}}return Ce(s,t,e)};import{pathToFileURL as Td}from"url";var di=s=>typeof s=="object"?s:s.startsWith("file://")?new URL(s):Td(s);import{fileURLToPath as kd}from"url";var Ht=s=>typeof s=="object"||s.startsWith("file://")?kd(s):s;typeof mi.isBuiltin!="function"&&(mi.isBuiltin=s=>(s.startsWith("node:")&&(s=s.substring(5)),mi.builtinModules.includes(s)));var Nd=async s=>(s=Ht(s),Ha(await ms(Od(s)),Ad(s))),z=async(s,t=void 0,e={})=>{if(typeof s=="string"&&s.startsWith("file://")&&(s=new URL(s)),typeof s=="object"){if(!await J(s))throw kt(String(s),String(t));let o=await ms(Ht(s));return o!==Cd(s)?Fr(o):s}let i=t?di(await Nd(t)):void 0;if(La(s)){if(!i)throw Ya(s,t);let o=new URL(s,i);if(!await J(o))throw kt(s,String(t));return Fr(await ms(new URL(s,i)))}if(Rd(s)){if(!await J(s))throw kt(s,String(t));return Fr(await ms(s))}if(mi.isBuiltin(String(s)))return String(s);let r=Ht(t||Ha(await ms(process.cwd()),"x")),n={...e,originalParent:String(e.originalParent||r)};return s?za(s,r,n):Ce(s,r,n)};var Ga=(s,t=z)=>{let e=new Error("invalid import() specifier: "+s);return Error.captureStackTrace(e,t),e},pi=(s,t=z)=>{let e=new Error(`Not a valid package: ${s}`);return Error.captureStackTrace(e,t),e},Ya=(s,t,e=z)=>{let i=Object.assign(new Error("relative import without parentURL"),{url:s,parentURL:t});return Error.captureStackTrace(i,e),i},fs=(s,t,e,i=z)=>{let r=s==="."?'No "exports" main defined':`Package subpath '${s}' is not defined by "exports"`,n=Object.assign(new Error(`${r} in ${t} imported from ${e}`),{code:"ERR_PACKAGE_PATH_NOT_EXPORTED"});return Error.captureStackTrace(n,i),n},us=(s,t,e=z)=>{let i=Object.assign(new Error(`Cannot find package '${s}' imported from ${t}`),{code:"ERR_MODULE_NOT_FOUND"});return Error.captureStackTrace(i,e),i},kt=(s,t,e=z)=>{let i=Object.assign(new Error(`Cannot find module '${s}' imported from ${t}`),{code:"ERR_MODULE_NOT_FOUND"});return Error.captureStackTrace(i,e),i},ds=(s,t,e,i=z)=>{let r=Object.assign(new Error(`Package import specifier "${s}" is not defined in package ${t} imported from ${e}`),{code:"ERR_PACKAGE_IMPORT_NOT_DEFINED"});return Error.captureStackTrace(r,i),r};var qa=s=>s?Pd(s)?Object.keys(s).filter(t=>t==="."||t.startsWith("./")):["."]:[],Pd=s=>{if(!s||typeof s!="object"||Array.isArray(s))return!1;for(let t in s)if(t!=="."&&!t.startsWith("./"))return!1;return!0};import{resolve as jd}from"path";var gi=async(s,t)=>{let e=At(s[0])+(s[0].endsWith("/")?"":"*/")+"**"+(s[1].startsWith("/")?"":"/*")+At(s[1]);return(await Xt(e,{posix:!0,absolute:!1,nodir:!0,cwd:t,dotRelative:!0})).map(r=>[r.substring(s[0].length,r.length-s[1].length),jd(t,r)])};var Ir=async(s,t={})=>{let e=Ht(s),i=Dd(e),r=await Gt(e);if(!r)throw pi(s,Ir);let n={},{exports:o}=r;for(let a of qa(o)){let c;try{c=Re(a,o,e,e,t)}catch{}if(!c)continue;let l=c.split("*"),h=a.split("*");if(l.length===2&&h.length===2)for(let[f,u]of await gi(l,i))n[h[0]+f+h[1]]=Va(u);else n[a]=Va(Fd(i,c))}return n};import{dirname as Id,resolve as Md}from"path";import{pathToFileURL as $d}from"url";var Mr=async(s,t={})=>{let e=Ht(s),i=Id(e),r=di(s),n=await Gt(e);if(!n)throw pi(s,Mr);let o={};for(let[a,c]of Ld(n,t)){let l=c.match(/^(@[^\/]+\/[^\/]+|[^\/]+)/),h=n.name;if(!l)continue;let f=a.split("*"),u=c.split("*");if(!(f.length===2&&u.length===2)){try{o[a]=await z(c,r)}catch{}continue}let m=l[1]===".";if(m){for(let[w,b]of await gi(u,i))o[f[0]+w+f[1]]=$d(b);continue}let p=l[1]===h,y=!m&&!p?l[1]:null,g=y?await hi(y,i):i;if(!g)continue;let S=Md(g,"package.json");if(!await J(S))continue;let x=await Ir(S);for(let[w,b]of Object.entries(x)){if(w==="."||w==="./")continue;let I=y+w.substring(1);if(I.startsWith(u[0])&&I.endsWith(u[1])){let it=f[0]+I.substring(u[0].length,I.length-u[1].length)+f[1];try{o[it]=await z(b,r)}catch{}}}}return o},Ld=(s,t)=>{let e=[],{imports:i}=s;if(!i||typeof i!="object")return e;for(let[r,n]of Object.entries(i)){let o=mt(n,t);o&&!o.startsWith("#")&&e.push([r,o])}return e};import{fileURLToPath as Ud}from"url";var Ka=new Set,Xa=s=>{let t=[...Qa.entries()];if(!t.length)return!1;let e=new Set(t.map(([i])=>Lr(i)));return _("save import linker",s),Wd(s,`import { mkdirSync } from 'node:fs'
|
|
33
33
|
import { symlink } from 'node:fs/promises'
|
|
34
34
|
const dirs = ${JSON.stringify([...e])}
|
|
35
35
|
const links = [
|
|
@@ -38,13 +38,13 @@ ${t.map(i=>` ${JSON.stringify(i)},
|
|
|
38
38
|
const e = (er) => { if (er.code !== 'EEXIST') throw er }
|
|
39
39
|
for (const d of dirs) mkdirSync(d, { recursive: true })
|
|
40
40
|
Promise.all(links.map(([dest, src]) => symlink(src, dest).catch(e)))
|
|
41
|
-
`),!0},St,Za=async s=>{let t=Ia(s).filter(n=>!n.startsWith("./src/"));if(!t.some(n=>n.includes("*")))return St=t.filter(n=>n.startsWith("./"));let e=Ma(s),i=new Set,r=Wr("package.json");for(let n of e){let o=await Mr(r,{conditions:n});for(let a of Object.values(o)){if(typeof a=="string")continue;let c=Ud(a),l=Ja(process.cwd(),c);!l||l.startsWith(".."+$r)||l.startsWith("src"+$r)||l.startsWith("node_modules"+$r)||i.add("./"+l.replace(/\\/g,"/"))}}return St=[...i]},Qa=new Map,
|
|
41
|
+
`),!0},St,Za=async s=>{let t=Ia(s).filter(n=>!n.startsWith("./src/"));if(!t.some(n=>n.includes("*")))return St=t.filter(n=>n.startsWith("./"));let e=Ma(s),i=new Set,r=Wr("package.json");for(let n of e){let o=await Mr(r,{conditions:n});for(let a of Object.values(o)){if(typeof a=="string")continue;let c=Ud(a),l=Ja(process.cwd(),c);!l||l.startsWith(".."+$r)||l.startsWith("src"+$r)||l.startsWith("node_modules"+$r)||i.add("./"+l.replace(/\\/g,"/"))}}return St=[...i]},Qa=new Map,yi=async(s,t,e=!1)=>{let{imports:i}=s;if(!i||(St||(St=await Za(i)),!St.length))return;_(`link import targets in ${t}`,St);let r=Ja(Wr(t),process.cwd()),n=[];for(let o of St){let a=o.replace(/^\.\//,""),c=Lr(a),l=c==="."?"":c.split("/").map(()=>"../").join(""),h=t+"/"+a,f=r+"/"+l+a;e&&Qa.set(h,f),n.push(mr(Lr(h)).then(u=>(!e&&u&&Ka.add(u),ht(h))).then(()=>Bd(f,h)))}await Promise.all(n)},wi=async(s,t)=>{let{imports:e}=s;if(!e)return;St||(St=await Za(e)),_(`unlink import targets in ${t}`,St);let i=[];for(let r of St){let n=Wr(t,r);i.push(ht(n))}for(let r of Ka)i.push(ht(r));await Promise.all(i)};import{readlinkSync as zd,symlinkSync as tc}from"fs";import{dirname as sc,relative as ic,resolve as bi,sep as ec}from"path";var rc=new Map,ps,nc=s=>{if(ps!==void 0)return ps;let t=process.cwd(),e=`${ec}node_modules${ec}${s.name}`.toLowerCase();if(t.toLowerCase().endsWith(e))return ps=!0;for(let i of Ut(t)){let r=bi(i,"node_modules",s.name);try{let n=bi(sc(r),zd(r));if(ic(n,t)==="")return ps=!0}catch{}}return ps=!1},Br=(s,t)=>{let e=s?.tshy?.selfLink;if(!s.name||e===!1||nc(s))return;let i=bi(t,"node_modules",s.name),r=sc(i),n=ic(r,process.cwd()),o=Pt(r);o&&rc.set(i,o);try{tc(n,i)}catch{st(i);let a=!0;try{tc(n,i),a=!1}finally{if(a&&e===void 0)return}}},Si=(s,t)=>{if(!s.name||s?.tshy?.selfLink===!1||nc(s))return;let e=bi(t,"node_modules",s.name);st(e);let i=rc.get(e);i&&st(i)};var Ei=s=>{q("src"),wi(k,"src"),Si(k,"src"),T("build failed"),F(s),process.exit(1)};import{existsSync as oc,renameSync as Gd,unlinkSync as Hd}from"fs";var Yd=s=>oc(s)&&Hd(s),qd=(s,t)=>oc(s)&&Gd(s,t),D={unlink:Yd,rename:qd};import{fileURLToPath as Vd}from"url";var Jd=async()=>await z("typescript",process.cwd()+"/x").catch(()=>z("typescript",import.meta.url)),xi=Vd(new URL("../bin/tsc",await Jd()));var Xd=process.execPath,{commonjsDialects:Zd=[]}=A,cc=()=>{q("src","commonjs");for(let s of["commonjs",...Zd]){let t=W.get(s==="commonjs"?"cjs":s);_(E.cyan.dim("building "+s));let e=Kd(Xd,[xi,"-p",`.tshy/${s}.json`],{stdio:"inherit"});if(e.status||e.signal)return q("src"),Ei(e);q(".tshy-build/"+s,"commonjs");for(let[i,r]of t?.map.entries()??[]){let n=Ne(`.tshy-build/${s}`,ac(Ne("src"),Ne(i))).replace(/\.cts$/,""),o=Ne(`.tshy-build/${s}`,ac(Ne("src"),Ne(r))).replace(/\.tsx?$/,""),a=`${o}.js.map`,c=`${o}.d.ts.map`;D.unlink(a),D.unlink(c),D.rename(`${n}.cjs`,`${o}.js`),D.rename(`${n}.d.cts`,`${o}.d.ts`)}F(E.cyan.bold("built commonjs"))}q("src")};import{spawnSync as Qd}from"node:child_process";import{relative as lc,resolve as Pe}from"node:path";var tm=process.execPath,{esmDialects:em=[]}=A,fc=()=>{q("src","esm");for(let s of["esm",...em]){let t=W.get(s);_(E.cyan.dim("building "+s));let e=Qd(tm,[xi,"-p",`.tshy/${s}.json`],{stdio:"inherit"});if(e.status||e.signal)return q("src"),Ei(e);q(".tshy-build/"+s,"esm");for(let[i,r]of t?.map.entries()??[]){let n=Pe(`.tshy-build/${s}`,lc(Pe("src"),Pe(i))).replace(/\.mts$/,""),o=Pe(`.tshy-build/${s}`,lc(Pe("src"),Pe(r))).replace(/\.tsx?$/,"");D.unlink(`${o}.js.map`),D.unlink(`${o}.d.ts.map`),D.rename(`${n}.mjs`,`${o}.js`),D.rename(`${n}.d.mts`,`${o}.d.ts`)}F(E.cyan.bold("built "+s))}q("src")};import{readdirSync as vi}from"fs";import{parse as sm}from"path";var hc=async(s,t)=>{let e=vi(`${t}/${s}`,{withFileTypes:!0}),i;try{i=new Set(vi(`src/${s}`))}catch{}if(!i)return await ht(`${t}/${s}`);for(let r of e){let n=`${s}/${r.name}`;if(r.isDirectory()){await hc(n,t);continue}let{ext:o,name:a}=sm(n);if(o===".map")continue;a.endsWith(".d")&&o.endsWith("ts")&&(o=".d"+o,a=a.substring(0,a.length-2));let c=o===".js"||o===".d.ts"?[".tsx",".ts"]:o===".mjs"||o===".d.mts"?[".mts"]:o===".cjs"||o===".d.cts"?[".cts"]:[];c.push(o);let l=!0;for(let h of c)if(i.has(`${a}${h}`)){l=!1;break}l&&(_("removing output file",n),await ht([`${t}/${n}`,`${t}/${n}.map`]))}},Ur=async()=>{let s=Ae();if(s.compilerOptions.incremental!==!0&&s.compilerOptions.composite!==!0)return await ht(".tshy-build");let t;try{t=vi(".tshy-build/.tshy")}catch{}if(!t?.length)return await ht(".tshy-build");for(let e of vi(".tshy-build"))e!==".tshy"&&await hc(".",`.tshy-build/${e}`)};var ee=A.dialects||["esm","commonjs"];import{writeFileSync as im}from"fs";var uc=()=>im("package.json",vs(k));import{linkSync as rm,mkdirSync as nm}from"node:fs";import{dirname as om,relative as dc,resolve as se}from"node:path";var{esmDialects:am=[]}=A,mc=()=>{for(let s of["esm",...am]){let t=W.get(s);_(E.cyan.dim("linking "+s));for(let e of Ot){let i=e.substring(6),r=se(`.tshy-build/${s}/${i}`);nm(om(r),{recursive:!0}),rm(e,r)}q(".tshy-build/"+s,"esm");for(let[e,i]of t?.map.entries()??[]){let r=se(`.tshy-build/${s}`,dc(se("src"),se(e))).replace(/\.mts$/,""),n=se(`.tshy-build/${s}`,dc(se("src"),se(i))).replace(/\.tsx?$/,"");D.unlink(`${n}.js.map`),D.unlink(`${n}.d.ts.map`),D.rename(`${r}.mjs`,`${n}.js`),D.rename(`${r}.d.mts`,`${n}.d.ts`)}F(E.cyan.bold("linked "+s))}};import{linkSync as cm,mkdirSync as lm}from"node:fs";import{dirname as fm}from"node:path";import{relative as pc,resolve as ie}from"node:path/posix";var{commonjsDialects:hm=[]}=A,gc=()=>{for(let s of["commonjs",...hm]){let t=W.get(s==="commonjs"?"cjs":s);_(E.cyan.dim("linking "+s));for(let e of Ot){let i=e.substring(6),r=ie(`.tshy-build/${s}/${i}`);lm(fm(r),{recursive:!0}),cm(e,r)}q(".tshy-build/"+s,"commonjs");for(let[e,i]of t?.map.entries()??[]){let r=ie(`.tshy-build/${s}`,pc(ie("src"),ie(e))).replace(/\.cts$/,""),n=ie(`.tshy-build/${s}`,pc(ie("src"),ie(i))).replace(/\.tsx?$/,"");D.unlink(`${n}.js.map`),D.unlink(`${n}.d.ts.map`),D.rename(`${r}.cjs`,`${n}.js`),D.rename(`${r}.d.cts`,`${n}.d.ts`)}F(E.cyan.bold("linked commonjs"))}};var yc=async()=>{await Ur(),Br(k,"src"),await yi(k,"src");let s=A.liveDev&&process.env.npm_command!=="publish"&&process.env.npm_command!=="pack",t=s?mc:fc,e=s?gc:cc;ee.includes("esm")&&t(),ee.includes("commonjs")&&e(),await wi(k,"src"),Si(k,"src"),_(E.cyan.dim("moving to ./dist")),ua(".tshy-build","dist"),_(E.cyan.dim("cleaning build temp dir")),await Ur(),Br(k,"dist"),k.imports&&(_("linking package imports",k.imports),ee.includes("commonjs")&&await yi(k,"dist/commonjs",!0),ee.includes("esm")&&await yi(k,"dist/esm",!0),Xa("dist/.tshy-link-imports.mjs")&&(k.scripts=k.scripts||{},k.scripts.preinstall='node -e "import(process.argv[1]).catch(()=>{})" dist/.tshy-link-imports.mjs')),_(E.cyan.dim("chmod bins")),pa(),_(E.cyan.dim("write package.json")),uc()};import{relative as um,resolve as wc}from"node:path/posix";var{esmDialects:dm=[],commonjsDialects:mm=[]}=A,gs=A.liveDev&&process.env.npm_command!=="publish"&&process.env.npm_command!=="pack",_i=(s,t,e,i,r=new Map)=>{if(s!==void 0){if(typeof s=="string"){let n=i==="commonjs"?".mts":".cts";if(s.endsWith(n))return;let o=t==="commonjs"?"cjs":t,a=um(wc("./src"),wc(r.get(o)?.map.get(s)??s)),c=gs?a:a.replace(/\.([mc]?)tsx?$/,".$1js");return!s||!s.startsWith("./src/")?s:ee.includes(i)?`./dist/${t}/${c}`:void 0}return xt(s,[e])}},pm=(s,t=new Map)=>_i(s,"esm","import","esm",t),gm=(s,t=new Map)=>_i(s,"commonjs","require","commonjs",t),ym=(s,t)=>{if(!s.exports)return T("no exports on tshy config (is there code in ./src?)"),process.exit(1);let e={};for(let[i,r]of Object.entries(s.exports)){if(r!==null&&(typeof r!="string"||!r.startsWith("./src/"))){e[i]=r;continue}if(r===null)continue;let n=pm(r,W),o=gm(r,W);if(!n&&!o)continue;let a=e[i]={};if(n)for(let c of dm){let l=r&&(W.get(c)?.map.get(r)??r),h=_i(r,c,c,"esm",W);h&&(a[c]=gs?{...t==="commonjs"?Yt(l,s):{},default:h}:{...t==="commonjs"?Yt(l,s):{},types:h.replace(/\.js$/,".d.ts"),default:h})}if(o)for(let c of mm){let l=r&&(W.get(c)?.map.get(r)??r),h=_i(r,c,c,"commonjs",W);h&&(a[c]=gs?{...t==="module"?Yt(l,s):{},default:h}:{...t==="module"?Yt(l,s):{},types:h.replace(/\.js$/,".d.ts"),default:h})}n&&(a.import=gs?{...t==="module"?Yt(r,s):{},default:n}:{...t==="module"?Yt(r,s):{},types:n.replace(/\.(m?)js$/,".d.$1ts"),default:n}),o&&(a.require=gs?{...t==="commonjs"?Yt(r,s):{},default:o}:{...t==="commonjs"?Yt(r,s):{},types:o.replace(/\.(c?)js$/,".d.$1ts"),default:o})}return e},Yt=(s,t)=>{let{sourceDialects:e}=t;return e?Object.fromEntries(e.map(i=>[i,s])):{}},wm=(s,t)=>{t.type=t.type==="commonjs"?"commonjs":"module";let e=xt(t.exports["."],["require"]);if(s?.main??!!e){if(!e)return T("could not resolve exports['.'] for tshy.main 'require'"),process.exit(1);let o=xt(t.exports["."],["require","types"]);t.main=e,o&&o!==e?t.types=o:delete t.types}else s&&s.main!==!1&&delete s.main,delete t.main,delete t.types;let r=xt(t.exports["."],["import"]);if(s?.module??!!r){if(!r)return T("could not resolve exports['.'] for tshy.module 'import'"),process.exit(1);t.module=r}else s&&s.module!==!1&&delete s.module,delete t.module};k.exports=ym(A,k.type);wm(A,k);var $0=k.exports;var zr=s=>{let t="https://github.com/isaacs/tshy",e=E.level>0?`\x1B]8;;${t}\x1B\\${t}\x1B]8;;\x1B\\`:t;console[s?"error":"log"](`Usage: tshy [--help]
|
|
42
42
|
--help -h Print this message and exit.
|
|
43
43
|
--watch -w Watch files in ./src and build when they change.
|
|
44
44
|
|
|
45
45
|
Default behavior: build project according to tshy config in package.json
|
|
46
46
|
|
|
47
|
-
See the docs for more information: ${e}`),s&&T(s),process.exit(s?1:0)};import{spawn as hp}from"child_process";import{stat as Vm}from"fs";import{stat as Jm,readdir as Km}from"fs/promises";import{EventEmitter as Xm}from"events";import*as v from"path";import{stat as bm,lstat as bc,readdir as Sm,realpath as Em}from"node:fs/promises";import{Readable as xm}from"node:stream";import{resolve as Sc,relative as vm,join as _m,sep as Tm}from"node:path";var nt={FILE_TYPE:"files",DIR_TYPE:"directories",FILE_DIR_TYPE:"files_directories",EVERYTHING_TYPE:"all"},Gr={root:".",fileFilter:s=>!0,directoryFilter:s=>!0,type:nt.FILE_TYPE,lstat:!1,depth:2147483648,alwaysStat:!1,highWaterMark:4096};Object.freeze(Gr);var _c="READDIRP_RECURSIVE_ERROR",km=new Set(["ENOENT","EPERM","EACCES","ELOOP",_c]),Ec=[nt.DIR_TYPE,nt.EVERYTHING_TYPE,nt.FILE_DIR_TYPE,nt.FILE_TYPE],Am=new Set([nt.DIR_TYPE,nt.EVERYTHING_TYPE,nt.FILE_DIR_TYPE]),Om=new Set([nt.EVERYTHING_TYPE,nt.FILE_DIR_TYPE,nt.FILE_TYPE]),Rm=s=>km.has(s.code),Cm=process.platform==="win32",xc=s=>!0,vc=s=>{if(s===void 0)return xc;if(typeof s=="function")return s;if(typeof s=="string"){let t=s.trim();return e=>e.basename===t}if(Array.isArray(s)){let t=s.map(e=>e.trim());return e=>t.some(i=>e.basename===i)}return xc},Hr=class extends xm{constructor(t={}){super({objectMode:!0,autoDestroy:!0,highWaterMark:t.highWaterMark});let e={...Gr,...t},{root:i,type:r}=e;this._fileFilter=vc(e.fileFilter),this._directoryFilter=vc(e.directoryFilter);let n=e.lstat?bc:bm;Cm?this._stat=o=>n(o,{bigint:!0}):this._stat=n,this._maxDepth=e.depth??Gr.depth,this._wantsDir=r?Am.has(r):!1,this._wantsFile=r?Om.has(r):!1,this._wantsEverything=r===nt.EVERYTHING_TYPE,this._root=Sc(i),this._isDirent=!e.alwaysStat,this._statsProp=this._isDirent?"dirent":"stats",this._rdOptions={encoding:"utf8",withFileTypes:this._isDirent},this.parents=[this._exploreDir(i,1)],this.reading=!1,this.parent=void 0}async _read(t){if(!this.reading){this.reading=!0;try{for(;!this.destroyed&&t>0;){let e=this.parent,i=e&&e.files;if(i&&i.length>0){let{path:r,depth:n}=e,o=i.splice(0,t).map(c=>this._formatEntry(c,r)),a=await Promise.all(o);for(let c of a){if(!c)continue;if(this.destroyed)return;let l=await this._getEntryType(c);l==="directory"&&this._directoryFilter(c)?(n<=this._maxDepth&&this.parents.push(this._exploreDir(c.fullPath,n+1)),this._wantsDir&&(this.push(c),t--)):(l==="file"||this._includeAsFile(c))&&this._fileFilter(c)&&this._wantsFile&&(this.push(c),t--)}}else{let r=this.parents.pop();if(!r){this.push(null);break}if(this.parent=await r,this.destroyed)return}}}catch(e){this.destroy(e)}finally{this.reading=!1}}}async _exploreDir(t,e){let i;try{i=await Sm(t,this._rdOptions)}catch(r){this._onError(r)}return{files:i,depth:e,path:t}}async _formatEntry(t,e){let i,r=this._isDirent?t.name:t;try{let n=Sc(_m(e,r));i={path:vm(this._root,n),fullPath:n,basename:r},i[this._statsProp]=this._isDirent?t:await this._stat(n)}catch(n){this._onError(n);return}return i}_onError(t){Rm(t)&&!this.destroyed?this.emit("warn",t):this.destroy(t)}async _getEntryType(t){if(!t&&this._statsProp in t)return"";let e=t[this._statsProp];if(e.isFile())return"file";if(e.isDirectory())return"directory";if(e&&e.isSymbolicLink()){let i=t.fullPath;try{let r=await Em(i),n=await bc(r);if(n.isFile())return"file";if(n.isDirectory()){let o=r.length;if(i.startsWith(r)&&i.substr(o,1)===Tm){let a=new Error(`Circular symlink detected: "${i}" points to "${r}"`);return a.code=_c,this._onError(a)}return"directory"}}catch(r){return this._onError(r),""}}}_includeAsFile(t){let e=t&&t[this._statsProp];return e&&this._wantsEverything&&!e.isDirectory()}};function Tc(s,t={}){let e=t.entryType||t.type;if(e==="both"&&(e=nt.FILE_DIR_TYPE),e&&(t.type=e),s){if(typeof s!="string")throw new TypeError("readdirp: root argument must be a string. Usage: readdirp(root, options)");if(e&&!Ec.includes(e))throw new Error(`readdirp: Invalid type passed. Use one of ${Ec.join(", ")}`)}else throw new Error("readdirp: root argument is required. Usage: readdirp(root, options)");return t.root=s,new Hr(t)}import{watchFile as Nm,unwatchFile as kc,watch as Pm}from"fs";import{open as jm,stat as Oc,lstat as Dm,realpath as Yr}from"fs/promises";import*as C from"path";import{type as Fm}from"os";var Im="data",Jr="end",Rc="close",Ai=()=>{};var Oi=process.platform,Kr=Oi==="win32",Mm=Oi==="darwin",$m=Oi==="linux",Lm=Oi==="freebsd",Cc=Fm()==="OS400",P={ALL:"all",READY:"ready",ADD:"add",CHANGE:"change",ADD_DIR:"addDir",UNLINK:"unlink",UNLINK_DIR:"unlinkDir",RAW:"raw",ERROR:"error"},Et=P,Wm="watch",Bm={lstat:Dm,stat:Oc},re="listeners",vi="errHandlers",Pe="rawEmitters",Um=[re,vi,Pe],zm=new Set(["3dm","3ds","3g2","3gp","7z","a","aac","adp","afdesign","afphoto","afpub","ai","aif","aiff","alz","ape","apk","appimage","ar","arj","asf","au","avi","bak","baml","bh","bin","bk","bmp","btif","bz2","bzip2","cab","caf","cgm","class","cmx","cpio","cr2","cur","dat","dcm","deb","dex","djvu","dll","dmg","dng","doc","docm","docx","dot","dotm","dra","DS_Store","dsk","dts","dtshd","dvb","dwg","dxf","ecelp4800","ecelp7470","ecelp9600","egg","eol","eot","epub","exe","f4v","fbs","fh","fla","flac","flatpak","fli","flv","fpx","fst","fvt","g3","gh","gif","graffle","gz","gzip","h261","h263","h264","icns","ico","ief","img","ipa","iso","jar","jpeg","jpg","jpgv","jpm","jxr","key","ktx","lha","lib","lvp","lz","lzh","lzma","lzo","m3u","m4a","m4v","mar","mdi","mht","mid","midi","mj2","mka","mkv","mmr","mng","mobi","mov","movie","mp3","mp4","mp4a","mpeg","mpg","mpga","mxu","nef","npx","numbers","nupkg","o","odp","ods","odt","oga","ogg","ogv","otf","ott","pages","pbm","pcx","pdb","pdf","pea","pgm","pic","png","pnm","pot","potm","potx","ppa","ppam","ppm","pps","ppsm","ppsx","ppt","pptm","pptx","psd","pya","pyc","pyo","pyv","qt","rar","ras","raw","resources","rgb","rip","rlc","rmf","rmvb","rpm","rtf","rz","s3m","s7z","scpt","sgi","shar","snap","sil","sketch","slk","smv","snk","so","stl","suo","sub","swf","tar","tbz","tbz2","tga","tgz","thmx","tif","tiff","tlz","ttc","ttf","txz","udf","uvh","uvi","uvm","uvp","uvs","uvu","viv","vob","war","wav","wax","wbmp","wdp","weba","webm","webp","whl","wim","wm","wma","wmv","wmx","woff","woff2","wrm","wvx","xbm","xif","xla","xlam","xls","xlsb","xlsm","xlsx","xlt","xltm","xltx","xm","xmind","xpi","xpm","xwd","xz","z","zip","zipx"]),Gm=s=>zm.has(C.extname(s).slice(1).toLowerCase()),Vr=(s,t)=>{s instanceof Set?s.forEach(t):t(s)},gs=(s,t,e)=>{let i=s[t];i instanceof Set||(s[t]=i=new Set([i])),i.add(e)},Hm=s=>t=>{let e=s[t];e instanceof Set?e.clear():delete s[t]},ys=(s,t,e)=>{let i=s[t];i instanceof Set?i.delete(e):i===e&&delete s[t]},Nc=s=>s instanceof Set?s.size===0:!s,_i=new Map;function Ac(s,t,e,i,r){let n=(o,a)=>{e(s),r(o,a,{watchedPath:s}),a&&s!==a&&Ti(C.resolve(s,a),re,C.join(s,a))};try{return Pm(s,{persistent:t.persistent},n)}catch(o){i(o);return}}var Ti=(s,t,e,i,r)=>{let n=_i.get(s);n&&Vr(n[t],o=>{o(e,i,r)})},Ym=(s,t,e,i)=>{let{listener:r,errHandler:n,rawEmitter:o}=i,a=_i.get(t),c;if(!e.persistent)return c=Ac(s,e,r,n,o),c?c.close.bind(c):void 0;if(a)gs(a,re,r),gs(a,vi,n),gs(a,Pe,o);else{if(c=Ac(s,e,Ti.bind(null,t,re),n,Ti.bind(null,t,Pe)),!c)return;c.on(Et.ERROR,async l=>{let h=Ti.bind(null,t,vi);if(a&&(a.watcherUnusable=!0),Kr&&l.code==="EPERM")try{await(await jm(s,"r")).close(),h(l)}catch{}else h(l)}),a={listeners:r,errHandlers:n,rawEmitters:o,watcher:c},_i.set(t,a)}return()=>{ys(a,re,r),ys(a,vi,n),ys(a,Pe,o),Nc(a.listeners)&&(a.watcher.close(),_i.delete(t),Um.forEach(Hm(a)),a.watcher=void 0,Object.freeze(a))}},qr=new Map,qm=(s,t,e,i)=>{let{listener:r,rawEmitter:n}=i,o=qr.get(t),a=o&&o.options;return a&&(a.persistent<e.persistent||a.interval>e.interval)&&(kc(t),o=void 0),o?(gs(o,re,r),gs(o,Pe,n)):(o={listeners:r,rawEmitters:n,options:e,watcher:Nm(t,e,(c,l)=>{Vr(o.rawEmitters,f=>{f(Et.CHANGE,t,{curr:c,prev:l})});let h=c.mtimeMs;(c.size!==l.size||h>l.mtimeMs||h===0)&&Vr(o.listeners,f=>f(s,c))})},qr.set(t,o)),()=>{ys(o,re,r),ys(o,Pe,n),Nc(o.listeners)&&(qr.delete(t),kc(t),o.options=o.watcher=void 0,Object.freeze(o))}},ki=class{constructor(t){this.fsw=t,this._boundHandleError=e=>t._handleError(e)}_watchWithNodeFs(t,e){let i=this.fsw.options,r=C.dirname(t),n=C.basename(t);this.fsw._getWatchedDir(r).add(n);let a=C.resolve(t),c={persistent:i.persistent};e||(e=Ai);let l;if(i.usePolling){let h=i.interval!==i.binaryInterval;c.interval=h&&Gm(n)?i.binaryInterval:i.interval,l=qm(t,a,c,{listener:e,rawEmitter:this.fsw._emitRaw})}else l=Ym(t,a,c,{listener:e,errHandler:this._boundHandleError,rawEmitter:this.fsw._emitRaw});return l}_handleFile(t,e,i){if(this.fsw.closed)return;let r=C.dirname(t),n=C.basename(t),o=this.fsw._getWatchedDir(r),a=e;if(o.has(n))return;let c=async(h,f)=>{if(this.fsw._throttle(Wm,t,5)){if(!f||f.mtimeMs===0)try{let u=await Oc(t);if(this.fsw.closed)return;let d=u.atimeMs,m=u.mtimeMs;if((!d||d<=m||m!==a.mtimeMs)&&this.fsw._emit(Et.CHANGE,t,u),(Mm||$m||Lm)&&a.ino!==u.ino){this.fsw._closeFile(h),a=u;let p=this._watchWithNodeFs(t,c);p&&this.fsw._addPathCloser(h,p)}else a=u}catch{this.fsw._remove(r,n)}else if(o.has(n)){let u=f.atimeMs,d=f.mtimeMs;(!u||u<=d||d!==a.mtimeMs)&&this.fsw._emit(Et.CHANGE,t,f),a=f}}},l=this._watchWithNodeFs(t,c);if(!(i&&this.fsw.options.ignoreInitial)&&this.fsw._isntIgnored(t)){if(!this.fsw._throttle(Et.ADD,t,0))return;this.fsw._emit(Et.ADD,t,e)}return l}async _handleSymlink(t,e,i,r){if(this.fsw.closed)return;let n=t.fullPath,o=this.fsw._getWatchedDir(e);if(!this.fsw.options.followSymlinks){this.fsw._incrReadyCount();let a;try{a=await Yr(i)}catch{return this.fsw._emitReady(),!0}return this.fsw.closed?void 0:(o.has(r)?this.fsw._symlinkPaths.get(n)!==a&&(this.fsw._symlinkPaths.set(n,a),this.fsw._emit(Et.CHANGE,i,t.stats)):(o.add(r),this.fsw._symlinkPaths.set(n,a),this.fsw._emit(Et.ADD,i,t.stats)),this.fsw._emitReady(),!0)}if(this.fsw._symlinkPaths.has(n))return!0;this.fsw._symlinkPaths.set(n,!0)}_handleRead(t,e,i,r,n,o,a){if(t=C.join(t,""),a=this.fsw._throttle("readdir",t,1e3),!a)return;let c=this.fsw._getWatchedDir(i.path),l=new Set,h=this.fsw._readdirp(t,{fileFilter:f=>i.filterPath(f),directoryFilter:f=>i.filterDir(f)});if(h)return h.on(Im,async f=>{if(this.fsw.closed){h=void 0;return}let u=f.path,d=C.join(t,u);if(l.add(u),!(f.stats.isSymbolicLink()&&await this._handleSymlink(f,t,d,u))){if(this.fsw.closed){h=void 0;return}(u===r||!r&&!c.has(u))&&(this.fsw._incrReadyCount(),d=C.join(n,C.relative(n,d)),this._addToNodeFs(d,e,i,o+1))}}).on(Et.ERROR,this._boundHandleError),new Promise((f,u)=>{if(!h)return u();h.once(Jr,()=>{if(this.fsw.closed){h=void 0;return}let d=a?a.clear():!1;f(void 0),c.getChildren().filter(m=>m!==t&&!l.has(m)).forEach(m=>{this.fsw._remove(t,m)}),h=void 0,d&&this._handleRead(t,!1,i,r,n,o,a)})})}async _handleDir(t,e,i,r,n,o,a){let c=this.fsw._getWatchedDir(C.dirname(t)),l=c.has(C.basename(t));!(i&&this.fsw.options.ignoreInitial)&&!n&&!l&&this.fsw._emit(Et.ADD_DIR,t,e),c.add(C.basename(t)),this.fsw._getWatchedDir(t);let h,f,u=this.fsw.options.depth;if((u==null||r<=u)&&!this.fsw._symlinkPaths.has(a)){if(!n&&(await this._handleRead(t,i,o,n,t,r,h),this.fsw.closed))return;f=this._watchWithNodeFs(t,(d,m)=>{m&&m.mtimeMs===0||this._handleRead(d,!1,o,n,t,r,h)})}return f}async _addToNodeFs(t,e,i,r,n){let o=this.fsw._emitReady;if(this.fsw._isIgnored(t)||this.fsw.closed)return o(),!1;let a=this.fsw._getWatchHelpers(t);i&&(a.filterPath=c=>i.filterPath(c),a.filterDir=c=>i.filterDir(c));try{let c=await Bm[a.statMethod](a.watchPath);if(this.fsw.closed)return;if(this.fsw._isIgnored(a.watchPath,c))return o(),!1;let l=this.fsw.options.followSymlinks,h;if(c.isDirectory()){let f=C.resolve(t),u=l?await Yr(t):t;if(this.fsw.closed||(h=await this._handleDir(a.watchPath,c,e,r,n,a,u),this.fsw.closed))return;f!==u&&u!==void 0&&this.fsw._symlinkPaths.set(f,u)}else if(c.isSymbolicLink()){let f=l?await Yr(t):t;if(this.fsw.closed)return;let u=C.dirname(a.watchPath);if(this.fsw._getWatchedDir(u).add(a.watchPath),this.fsw._emit(Et.ADD,a.watchPath,c),h=await this._handleDir(u,c,e,r,t,a,f),this.fsw.closed)return;f!==void 0&&this.fsw._symlinkPaths.set(C.resolve(t),f)}else h=this._handleFile(a.watchPath,c,e);return o(),h&&this.fsw._addPathCloser(t,h),!1}catch(c){if(this.fsw._handleError(c))return o(),t}}};var Xr="/",Zm="//",Mc=".",Qm="..",tp="string",ep=/\\/g,Pc=/\/\//,sp=/\..*\.(sw[px])$|~$|\.subl.*\.tmp/,ip=/^\.[/\\]/;function Ri(s){return Array.isArray(s)?s:[s]}var Zr=s=>typeof s=="object"&&s!==null&&!(s instanceof RegExp);function rp(s){return typeof s=="function"?s:typeof s=="string"?t=>s===t:s instanceof RegExp?t=>s.test(t):typeof s=="object"&&s!==null?t=>{if(s.path===t)return!0;if(s.recursive){let e=v.relative(s.path,t);return e?!e.startsWith("..")&&!v.isAbsolute(e):!1}return!1}:()=>!1}function np(s){if(typeof s!="string")throw new Error("string expected");s=v.normalize(s),s=s.replace(/\\/g,"/");let t=!1;s.startsWith("//")&&(t=!0);let e=/\/\//;for(;s.match(e);)s=s.replace(e,"/");return t&&(s="/"+s),s}function jc(s,t,e){let i=np(t);for(let r=0;r<s.length;r++){let n=s[r];if(n(i,e))return!0}return!1}function op(s,t){if(s==null)throw new TypeError("anymatch: specify first argument");let i=Ri(s).map(r=>rp(r));return t==null?(r,n)=>jc(i,r,n):jc(i,t)}var Dc=s=>{let t=Ri(s).flat();if(!t.every(e=>typeof e===tp))throw new TypeError(`Non-string provided as watch path: ${t}`);return t.map($c)},Fc=s=>{let t=s.replace(ep,Xr),e=!1;for(t.startsWith(Zm)&&(e=!0);t.match(Pc);)t=t.replace(Pc,Xr);return e&&(t=Xr+t),t},$c=s=>Fc(v.normalize(Fc(s))),Ic=(s="")=>t=>typeof t=="string"?$c(v.isAbsolute(t)?t:v.join(s,t)):t,ap=(s,t)=>v.isAbsolute(s)?s:v.join(t,s),cp=Object.freeze(new Set),Qr=class{constructor(t,e){this.path=t,this._removeWatcher=e,this.items=new Set}add(t){let{items:e}=this;e&&t!==Mc&&t!==Qm&&e.add(t)}async remove(t){let{items:e}=this;if(!e||(e.delete(t),e.size>0))return;let i=this.path;try{await Km(i)}catch{this._removeWatcher&&this._removeWatcher(v.dirname(i),v.basename(i))}}has(t){let{items:e}=this;if(e)return e.has(t)}getChildren(){let{items:t}=this;return t?[...t.values()]:[]}dispose(){this.items.clear(),this.path="",this._removeWatcher=Ai,this.items=cp,Object.freeze(this)}},lp="stat",fp="lstat",tn=class{constructor(t,e,i){this.fsw=i;let r=t;this.path=t=t.replace(ip,""),this.watchPath=r,this.fullWatchPath=v.resolve(r),this.dirParts=[],this.dirParts.forEach(n=>{n.length>1&&n.pop()}),this.followSymlinks=e,this.statMethod=e?lp:fp}entryPath(t){return v.join(this.watchPath,v.relative(this.watchPath,t.fullPath))}filterPath(t){let{stats:e}=t;if(e&&e.isSymbolicLink())return this.filterDir(t);let i=this.entryPath(t);return this.fsw._isntIgnored(i,e)&&this.fsw._hasReadPermissions(e)}filterDir(t){return this.fsw._isntIgnored(this.entryPath(t),t.stats)}},en=class extends Xm{constructor(t={}){super(),this.closed=!1,this._closers=new Map,this._ignoredPaths=new Set,this._throttled=new Map,this._streams=new Set,this._symlinkPaths=new Map,this._watched=new Map,this._pendingWrites=new Map,this._pendingUnlinks=new Map,this._readyCount=0,this._readyEmitted=!1;let e=t.awaitWriteFinish,i={stabilityThreshold:2e3,pollInterval:100},r={persistent:!0,ignoreInitial:!1,ignorePermissionErrors:!1,interval:100,binaryInterval:300,followSymlinks:!0,usePolling:!1,atomic:!0,...t,ignored:t.ignored?Ri(t.ignored):Ri([]),awaitWriteFinish:e===!0?i:typeof e=="object"?{...i,...e}:!1};Cc&&(r.usePolling=!0),r.atomic===void 0&&(r.atomic=!r.usePolling);let n=process.env.CHOKIDAR_USEPOLLING;if(n!==void 0){let c=n.toLowerCase();c==="false"||c==="0"?r.usePolling=!1:c==="true"||c==="1"?r.usePolling=!0:r.usePolling=!!c}let o=process.env.CHOKIDAR_INTERVAL;o&&(r.interval=Number.parseInt(o,10));let a=0;this._emitReady=()=>{a++,a>=this._readyCount&&(this._emitReady=Ai,this._readyEmitted=!0,process.nextTick(()=>this.emit(P.READY)))},this._emitRaw=(...c)=>this.emit(P.RAW,...c),this._boundRemove=this._remove.bind(this),this.options=r,this._nodeFsHandler=new ki(this),Object.freeze(r)}_addIgnoredPath(t){if(Zr(t)){for(let e of this._ignoredPaths)if(Zr(e)&&e.path===t.path&&e.recursive===t.recursive)return}this._ignoredPaths.add(t)}_removeIgnoredPath(t){if(this._ignoredPaths.delete(t),typeof t=="string")for(let e of this._ignoredPaths)Zr(e)&&e.path===t&&this._ignoredPaths.delete(e)}add(t,e,i){let{cwd:r}=this.options;this.closed=!1,this._closePromise=void 0;let n=Dc(t);return r&&(n=n.map(o=>ap(o,r))),n.forEach(o=>{this._removeIgnoredPath(o)}),this._userIgnored=void 0,this._readyCount||(this._readyCount=0),this._readyCount+=n.length,Promise.all(n.map(async o=>{let a=await this._nodeFsHandler._addToNodeFs(o,!i,void 0,0,e);return a&&this._emitReady(),a})).then(o=>{this.closed||o.forEach(a=>{a&&this.add(v.dirname(a),v.basename(e||a))})}),this}unwatch(t){if(this.closed)return this;let e=Dc(t),{cwd:i}=this.options;return e.forEach(r=>{!v.isAbsolute(r)&&!this._closers.has(r)&&(i&&(r=v.join(i,r)),r=v.resolve(r)),this._closePath(r),this._addIgnoredPath(r),this._watched.has(r)&&this._addIgnoredPath({path:r,recursive:!0}),this._userIgnored=void 0}),this}close(){if(this._closePromise)return this._closePromise;this.closed=!0,this.removeAllListeners();let t=[];return this._closers.forEach(e=>e.forEach(i=>{let r=i();r instanceof Promise&&t.push(r)})),this._streams.forEach(e=>e.destroy()),this._userIgnored=void 0,this._readyCount=0,this._readyEmitted=!1,this._watched.forEach(e=>e.dispose()),this._closers.clear(),this._watched.clear(),this._streams.clear(),this._symlinkPaths.clear(),this._throttled.clear(),this._closePromise=t.length?Promise.all(t).then(()=>{}):Promise.resolve(),this._closePromise}getWatched(){let t={};return this._watched.forEach((e,i)=>{let n=(this.options.cwd?v.relative(this.options.cwd,i):i)||Mc;t[n]=e.getChildren().sort()}),t}emitWithAll(t,e){this.emit(t,...e),t!==P.ERROR&&this.emit(P.ALL,t,...e)}async _emit(t,e,i){if(this.closed)return;let r=this.options;Kr&&(e=v.normalize(e)),r.cwd&&(e=v.relative(r.cwd,e));let n=[e];i!=null&&n.push(i);let o=r.awaitWriteFinish,a;if(o&&(a=this._pendingWrites.get(e)))return a.lastChange=new Date,this;if(r.atomic){if(t===P.UNLINK)return this._pendingUnlinks.set(e,[t,...n]),setTimeout(()=>{this._pendingUnlinks.forEach((c,l)=>{this.emit(...c),this.emit(P.ALL,...c),this._pendingUnlinks.delete(l)})},typeof r.atomic=="number"?r.atomic:100),this;t===P.ADD&&this._pendingUnlinks.has(e)&&(t=P.CHANGE,this._pendingUnlinks.delete(e))}if(o&&(t===P.ADD||t===P.CHANGE)&&this._readyEmitted){let c=(l,h)=>{l?(t=P.ERROR,n[0]=l,this.emitWithAll(t,n)):h&&(n.length>1?n[1]=h:n.push(h),this.emitWithAll(t,n))};return this._awaitWriteFinish(e,o.stabilityThreshold,t,c),this}if(t===P.CHANGE&&!this._throttle(P.CHANGE,e,50))return this;if(r.alwaysStat&&i===void 0&&(t===P.ADD||t===P.ADD_DIR||t===P.CHANGE)){let c=r.cwd?v.join(r.cwd,e):e,l;try{l=await Jm(c)}catch{}if(!l||this.closed)return;n.push(l)}return this.emitWithAll(t,n),this}_handleError(t){let e=t&&t.code;return t&&e!=="ENOENT"&&e!=="ENOTDIR"&&(!this.options.ignorePermissionErrors||e!=="EPERM"&&e!=="EACCES")&&this.emit(P.ERROR,t),t||this.closed}_throttle(t,e,i){this._throttled.has(t)||this._throttled.set(t,new Map);let r=this._throttled.get(t);if(!r)throw new Error("invalid throttle");let n=r.get(e);if(n)return n.count++,!1;let o,a=()=>{let l=r.get(e),h=l?l.count:0;return r.delete(e),clearTimeout(o),l&&clearTimeout(l.timeoutObject),h};o=setTimeout(a,i);let c={timeoutObject:o,clear:a,count:0};return r.set(e,c),c}_incrReadyCount(){return this._readyCount++}_awaitWriteFinish(t,e,i,r){let n=this.options.awaitWriteFinish;if(typeof n!="object")return;let o=n.pollInterval,a,c=t;this.options.cwd&&!v.isAbsolute(t)&&(c=v.join(this.options.cwd,t));let l=new Date,h=this._pendingWrites;function f(u){Vm(c,(d,m)=>{if(d||!h.has(t)){d&&d.code!=="ENOENT"&&r(d);return}let p=Number(new Date);u&&m.size!==u.size&&(h.get(t).lastChange=p);let y=h.get(t);p-y.lastChange>=e?(h.delete(t),r(void 0,m)):a=setTimeout(f,o,m)})}h.has(t)||(h.set(t,{lastChange:l,cancelWait:()=>(h.delete(t),clearTimeout(a),i)}),a=setTimeout(f,o))}_isIgnored(t,e){if(this.options.atomic&&sp.test(t))return!0;if(!this._userIgnored){let{cwd:i}=this.options,n=(this.options.ignored||[]).map(Ic(i)),a=[...[...this._ignoredPaths].map(Ic(i)),...n];this._userIgnored=op(a,void 0)}return this._userIgnored(t,e)}_isntIgnored(t,e){return!this._isIgnored(t,e)}_getWatchHelpers(t){return new tn(t,this.options.followSymlinks,this)}_getWatchedDir(t){let e=v.resolve(t);return this._watched.has(e)||this._watched.set(e,new Qr(e,this._boundRemove)),this._watched.get(e)}_hasReadPermissions(t){return this.options.ignorePermissionErrors?!0:!!(Number(t.mode)&256)}_remove(t,e,i){let r=v.join(t,e),n=v.resolve(r);if(i=i??(this._watched.has(r)||this._watched.has(n)),!this._throttle("remove",r,100))return;!i&&this._watched.size===1&&this.add(t,e,!0),this._getWatchedDir(r).getChildren().forEach(u=>this._remove(r,u));let c=this._getWatchedDir(t),l=c.has(e);c.remove(e),this._symlinkPaths.has(n)&&this._symlinkPaths.delete(n);let h=r;if(this.options.cwd&&(h=v.relative(this.options.cwd,r)),this.options.awaitWriteFinish&&this._pendingWrites.has(h)&&this._pendingWrites.get(h).cancelWait()===P.ADD)return;this._watched.delete(r),this._watched.delete(n);let f=i?P.UNLINK_DIR:P.UNLINK;l&&!this._isIgnored(r)&&this._emit(f,r),this._closePath(r)}_closePath(t){this._closeFile(t);let e=v.dirname(t);this._getWatchedDir(e).remove(v.basename(t))}_closeFile(t){let e=this._closers.get(t);e&&(e.forEach(i=>i()),this._closers.delete(t))}_addPathCloser(t,e){if(!e)return;let i=this._closers.get(t);i||(i=[],this._closers.set(t,i)),i.push(e)}_readdirp(t,e){if(this.closed)return;let i={type:P.ALL,alwaysStat:!0,lstat:!0,...e,depth:0},r=Tc(t,i);return this._streams.add(r),r.once(Rc,()=>{r=void 0}),r.once(Jr,()=>{r&&(this._streams.delete(r),r=void 0)}),r}};function Lc(s,t={}){let e=new en(t);return e.add(s),e}import{readFileSync as up}from"fs";import{resolve as je,sep as dp}from"path";import{fileURLToPath as mp}from"url";var Wc=()=>{try{return JSON.stringify(JSON.parse(up("./package.json","utf8")))}catch{return"null"}},sn="null",pp={persistent:!0,ignoreInitial:!0,ignorePermissionErrors:!0,ignored:s=>{let t=je(s);return!!(t===Uc||t===Bc||t.startsWith(Bc+dp))}},Uc=je("./src/package.json"),Bc=je("./src/node_modules"),zc=je("./src"),rn=je("./package.json"),gp=[zc,rn],yp=mp(new URL("./index.js",import.meta.url)),Gc=()=>{let s=!1,t=!1,e=Lc(gp,pp),i=()=>{s=!0,t=!1,hp(process.execPath,[yp],{stdio:"inherit"}).on("close",(n,o)=>{n||o?(F(E.red("build failure"),{code:n,signal:o}),ce()):console.log(E.green("build success"),{code:n,signal:o}),t?i():s=!1})};e.on("all",(r,n)=>{if(r==="addDir"&&n===zc)return;let o=je(n);if(o!==Uc){if(o===rn){let a=Wc();if(a===sn)return;sn=a}if(s){o!==rn&&(t=!0);return}_(E.cyan.dim(r),n),i()}}),sn=Wc(),i()};var{exports:wp,tshy:bp}=k,Sp=async()=>{for(let s of process.argv.slice(2))switch(s){case"--help":case"-h":return zr();case"--watch":case"-w":return Gc();default:return zr(`Unknown argument: ${s}`)}_(E.yellow.bold("building"),process.cwd()),_(E.cyan.dim("tshy config"),bp),_(E.cyan.dim("exports"),wp),await yc(),In(E.bold.green("success!"))};await Sp();
|
|
47
|
+
See the docs for more information: ${e}`),s&&T(s),process.exit(s?1:0)};import{spawn as hp}from"child_process";import{stat as Vm}from"fs";import{stat as Jm,readdir as Km}from"fs/promises";import{EventEmitter as Xm}from"events";import*as v from"path";import{stat as bm,lstat as bc,readdir as Sm,realpath as Em}from"node:fs/promises";import{Readable as xm}from"node:stream";import{resolve as Sc,relative as vm,join as _m,sep as Tm}from"node:path";var nt={FILE_TYPE:"files",DIR_TYPE:"directories",FILE_DIR_TYPE:"files_directories",EVERYTHING_TYPE:"all"},Gr={root:".",fileFilter:s=>!0,directoryFilter:s=>!0,type:nt.FILE_TYPE,lstat:!1,depth:2147483648,alwaysStat:!1,highWaterMark:4096};Object.freeze(Gr);var _c="READDIRP_RECURSIVE_ERROR",km=new Set(["ENOENT","EPERM","EACCES","ELOOP",_c]),Ec=[nt.DIR_TYPE,nt.EVERYTHING_TYPE,nt.FILE_DIR_TYPE,nt.FILE_TYPE],Am=new Set([nt.DIR_TYPE,nt.EVERYTHING_TYPE,nt.FILE_DIR_TYPE]),Om=new Set([nt.EVERYTHING_TYPE,nt.FILE_DIR_TYPE,nt.FILE_TYPE]),Rm=s=>km.has(s.code),Cm=process.platform==="win32",xc=s=>!0,vc=s=>{if(s===void 0)return xc;if(typeof s=="function")return s;if(typeof s=="string"){let t=s.trim();return e=>e.basename===t}if(Array.isArray(s)){let t=s.map(e=>e.trim());return e=>t.some(i=>e.basename===i)}return xc},Hr=class extends xm{constructor(t={}){super({objectMode:!0,autoDestroy:!0,highWaterMark:t.highWaterMark});let e={...Gr,...t},{root:i,type:r}=e;this._fileFilter=vc(e.fileFilter),this._directoryFilter=vc(e.directoryFilter);let n=e.lstat?bc:bm;Cm?this._stat=o=>n(o,{bigint:!0}):this._stat=n,this._maxDepth=e.depth??Gr.depth,this._wantsDir=r?Am.has(r):!1,this._wantsFile=r?Om.has(r):!1,this._wantsEverything=r===nt.EVERYTHING_TYPE,this._root=Sc(i),this._isDirent=!e.alwaysStat,this._statsProp=this._isDirent?"dirent":"stats",this._rdOptions={encoding:"utf8",withFileTypes:this._isDirent},this.parents=[this._exploreDir(i,1)],this.reading=!1,this.parent=void 0}async _read(t){if(!this.reading){this.reading=!0;try{for(;!this.destroyed&&t>0;){let e=this.parent,i=e&&e.files;if(i&&i.length>0){let{path:r,depth:n}=e,o=i.splice(0,t).map(c=>this._formatEntry(c,r)),a=await Promise.all(o);for(let c of a){if(!c)continue;if(this.destroyed)return;let l=await this._getEntryType(c);l==="directory"&&this._directoryFilter(c)?(n<=this._maxDepth&&this.parents.push(this._exploreDir(c.fullPath,n+1)),this._wantsDir&&(this.push(c),t--)):(l==="file"||this._includeAsFile(c))&&this._fileFilter(c)&&this._wantsFile&&(this.push(c),t--)}}else{let r=this.parents.pop();if(!r){this.push(null);break}if(this.parent=await r,this.destroyed)return}}}catch(e){this.destroy(e)}finally{this.reading=!1}}}async _exploreDir(t,e){let i;try{i=await Sm(t,this._rdOptions)}catch(r){this._onError(r)}return{files:i,depth:e,path:t}}async _formatEntry(t,e){let i,r=this._isDirent?t.name:t;try{let n=Sc(_m(e,r));i={path:vm(this._root,n),fullPath:n,basename:r},i[this._statsProp]=this._isDirent?t:await this._stat(n)}catch(n){this._onError(n);return}return i}_onError(t){Rm(t)&&!this.destroyed?this.emit("warn",t):this.destroy(t)}async _getEntryType(t){if(!t&&this._statsProp in t)return"";let e=t[this._statsProp];if(e.isFile())return"file";if(e.isDirectory())return"directory";if(e&&e.isSymbolicLink()){let i=t.fullPath;try{let r=await Em(i),n=await bc(r);if(n.isFile())return"file";if(n.isDirectory()){let o=r.length;if(i.startsWith(r)&&i.substr(o,1)===Tm){let a=new Error(`Circular symlink detected: "${i}" points to "${r}"`);return a.code=_c,this._onError(a)}return"directory"}}catch(r){return this._onError(r),""}}}_includeAsFile(t){let e=t&&t[this._statsProp];return e&&this._wantsEverything&&!e.isDirectory()}};function Tc(s,t={}){let e=t.entryType||t.type;if(e==="both"&&(e=nt.FILE_DIR_TYPE),e&&(t.type=e),s){if(typeof s!="string")throw new TypeError("readdirp: root argument must be a string. Usage: readdirp(root, options)");if(e&&!Ec.includes(e))throw new Error(`readdirp: Invalid type passed. Use one of ${Ec.join(", ")}`)}else throw new Error("readdirp: root argument is required. Usage: readdirp(root, options)");return t.root=s,new Hr(t)}import{watchFile as Nm,unwatchFile as kc,watch as Pm}from"fs";import{open as jm,stat as Oc,lstat as Dm,realpath as Yr}from"fs/promises";import*as C from"path";import{type as Fm}from"os";var Im="data",Jr="end",Rc="close",Ri=()=>{};var Ci=process.platform,Kr=Ci==="win32",Mm=Ci==="darwin",$m=Ci==="linux",Lm=Ci==="freebsd",Cc=Fm()==="OS400",P={ALL:"all",READY:"ready",ADD:"add",CHANGE:"change",ADD_DIR:"addDir",UNLINK:"unlink",UNLINK_DIR:"unlinkDir",RAW:"raw",ERROR:"error"},Et=P,Wm="watch",Bm={lstat:Dm,stat:Oc},re="listeners",Ti="errHandlers",je="rawEmitters",Um=[re,Ti,je],zm=new Set(["3dm","3ds","3g2","3gp","7z","a","aac","adp","afdesign","afphoto","afpub","ai","aif","aiff","alz","ape","apk","appimage","ar","arj","asf","au","avi","bak","baml","bh","bin","bk","bmp","btif","bz2","bzip2","cab","caf","cgm","class","cmx","cpio","cr2","cur","dat","dcm","deb","dex","djvu","dll","dmg","dng","doc","docm","docx","dot","dotm","dra","DS_Store","dsk","dts","dtshd","dvb","dwg","dxf","ecelp4800","ecelp7470","ecelp9600","egg","eol","eot","epub","exe","f4v","fbs","fh","fla","flac","flatpak","fli","flv","fpx","fst","fvt","g3","gh","gif","graffle","gz","gzip","h261","h263","h264","icns","ico","ief","img","ipa","iso","jar","jpeg","jpg","jpgv","jpm","jxr","key","ktx","lha","lib","lvp","lz","lzh","lzma","lzo","m3u","m4a","m4v","mar","mdi","mht","mid","midi","mj2","mka","mkv","mmr","mng","mobi","mov","movie","mp3","mp4","mp4a","mpeg","mpg","mpga","mxu","nef","npx","numbers","nupkg","o","odp","ods","odt","oga","ogg","ogv","otf","ott","pages","pbm","pcx","pdb","pdf","pea","pgm","pic","png","pnm","pot","potm","potx","ppa","ppam","ppm","pps","ppsm","ppsx","ppt","pptm","pptx","psd","pya","pyc","pyo","pyv","qt","rar","ras","raw","resources","rgb","rip","rlc","rmf","rmvb","rpm","rtf","rz","s3m","s7z","scpt","sgi","shar","snap","sil","sketch","slk","smv","snk","so","stl","suo","sub","swf","tar","tbz","tbz2","tga","tgz","thmx","tif","tiff","tlz","ttc","ttf","txz","udf","uvh","uvi","uvm","uvp","uvs","uvu","viv","vob","war","wav","wax","wbmp","wdp","weba","webm","webp","whl","wim","wm","wma","wmv","wmx","woff","woff2","wrm","wvx","xbm","xif","xla","xlam","xls","xlsb","xlsm","xlsx","xlt","xltm","xltx","xm","xmind","xpi","xpm","xwd","xz","z","zip","zipx"]),Gm=s=>zm.has(C.extname(s).slice(1).toLowerCase()),Vr=(s,t)=>{s instanceof Set?s.forEach(t):t(s)},ys=(s,t,e)=>{let i=s[t];i instanceof Set||(s[t]=i=new Set([i])),i.add(e)},Hm=s=>t=>{let e=s[t];e instanceof Set?e.clear():delete s[t]},ws=(s,t,e)=>{let i=s[t];i instanceof Set?i.delete(e):i===e&&delete s[t]},Nc=s=>s instanceof Set?s.size===0:!s,ki=new Map;function Ac(s,t,e,i,r){let n=(o,a)=>{e(s),r(o,a,{watchedPath:s}),a&&s!==a&&Ai(C.resolve(s,a),re,C.join(s,a))};try{return Pm(s,{persistent:t.persistent},n)}catch(o){i(o);return}}var Ai=(s,t,e,i,r)=>{let n=ki.get(s);n&&Vr(n[t],o=>{o(e,i,r)})},Ym=(s,t,e,i)=>{let{listener:r,errHandler:n,rawEmitter:o}=i,a=ki.get(t),c;if(!e.persistent)return c=Ac(s,e,r,n,o),c?c.close.bind(c):void 0;if(a)ys(a,re,r),ys(a,Ti,n),ys(a,je,o);else{if(c=Ac(s,e,Ai.bind(null,t,re),n,Ai.bind(null,t,je)),!c)return;c.on(Et.ERROR,async l=>{let h=Ai.bind(null,t,Ti);if(a&&(a.watcherUnusable=!0),Kr&&l.code==="EPERM")try{await(await jm(s,"r")).close(),h(l)}catch{}else h(l)}),a={listeners:r,errHandlers:n,rawEmitters:o,watcher:c},ki.set(t,a)}return()=>{ws(a,re,r),ws(a,Ti,n),ws(a,je,o),Nc(a.listeners)&&(a.watcher.close(),ki.delete(t),Um.forEach(Hm(a)),a.watcher=void 0,Object.freeze(a))}},qr=new Map,qm=(s,t,e,i)=>{let{listener:r,rawEmitter:n}=i,o=qr.get(t),a=o&&o.options;return a&&(a.persistent<e.persistent||a.interval>e.interval)&&(kc(t),o=void 0),o?(ys(o,re,r),ys(o,je,n)):(o={listeners:r,rawEmitters:n,options:e,watcher:Nm(t,e,(c,l)=>{Vr(o.rawEmitters,f=>{f(Et.CHANGE,t,{curr:c,prev:l})});let h=c.mtimeMs;(c.size!==l.size||h>l.mtimeMs||h===0)&&Vr(o.listeners,f=>f(s,c))})},qr.set(t,o)),()=>{ws(o,re,r),ws(o,je,n),Nc(o.listeners)&&(qr.delete(t),kc(t),o.options=o.watcher=void 0,Object.freeze(o))}},Oi=class{constructor(t){this.fsw=t,this._boundHandleError=e=>t._handleError(e)}_watchWithNodeFs(t,e){let i=this.fsw.options,r=C.dirname(t),n=C.basename(t);this.fsw._getWatchedDir(r).add(n);let a=C.resolve(t),c={persistent:i.persistent};e||(e=Ri);let l;if(i.usePolling){let h=i.interval!==i.binaryInterval;c.interval=h&&Gm(n)?i.binaryInterval:i.interval,l=qm(t,a,c,{listener:e,rawEmitter:this.fsw._emitRaw})}else l=Ym(t,a,c,{listener:e,errHandler:this._boundHandleError,rawEmitter:this.fsw._emitRaw});return l}_handleFile(t,e,i){if(this.fsw.closed)return;let r=C.dirname(t),n=C.basename(t),o=this.fsw._getWatchedDir(r),a=e;if(o.has(n))return;let c=async(h,f)=>{if(this.fsw._throttle(Wm,t,5)){if(!f||f.mtimeMs===0)try{let u=await Oc(t);if(this.fsw.closed)return;let d=u.atimeMs,m=u.mtimeMs;if((!d||d<=m||m!==a.mtimeMs)&&this.fsw._emit(Et.CHANGE,t,u),(Mm||$m||Lm)&&a.ino!==u.ino){this.fsw._closeFile(h),a=u;let p=this._watchWithNodeFs(t,c);p&&this.fsw._addPathCloser(h,p)}else a=u}catch{this.fsw._remove(r,n)}else if(o.has(n)){let u=f.atimeMs,d=f.mtimeMs;(!u||u<=d||d!==a.mtimeMs)&&this.fsw._emit(Et.CHANGE,t,f),a=f}}},l=this._watchWithNodeFs(t,c);if(!(i&&this.fsw.options.ignoreInitial)&&this.fsw._isntIgnored(t)){if(!this.fsw._throttle(Et.ADD,t,0))return;this.fsw._emit(Et.ADD,t,e)}return l}async _handleSymlink(t,e,i,r){if(this.fsw.closed)return;let n=t.fullPath,o=this.fsw._getWatchedDir(e);if(!this.fsw.options.followSymlinks){this.fsw._incrReadyCount();let a;try{a=await Yr(i)}catch{return this.fsw._emitReady(),!0}return this.fsw.closed?void 0:(o.has(r)?this.fsw._symlinkPaths.get(n)!==a&&(this.fsw._symlinkPaths.set(n,a),this.fsw._emit(Et.CHANGE,i,t.stats)):(o.add(r),this.fsw._symlinkPaths.set(n,a),this.fsw._emit(Et.ADD,i,t.stats)),this.fsw._emitReady(),!0)}if(this.fsw._symlinkPaths.has(n))return!0;this.fsw._symlinkPaths.set(n,!0)}_handleRead(t,e,i,r,n,o,a){if(t=C.join(t,""),a=this.fsw._throttle("readdir",t,1e3),!a)return;let c=this.fsw._getWatchedDir(i.path),l=new Set,h=this.fsw._readdirp(t,{fileFilter:f=>i.filterPath(f),directoryFilter:f=>i.filterDir(f)});if(h)return h.on(Im,async f=>{if(this.fsw.closed){h=void 0;return}let u=f.path,d=C.join(t,u);if(l.add(u),!(f.stats.isSymbolicLink()&&await this._handleSymlink(f,t,d,u))){if(this.fsw.closed){h=void 0;return}(u===r||!r&&!c.has(u))&&(this.fsw._incrReadyCount(),d=C.join(n,C.relative(n,d)),this._addToNodeFs(d,e,i,o+1))}}).on(Et.ERROR,this._boundHandleError),new Promise((f,u)=>{if(!h)return u();h.once(Jr,()=>{if(this.fsw.closed){h=void 0;return}let d=a?a.clear():!1;f(void 0),c.getChildren().filter(m=>m!==t&&!l.has(m)).forEach(m=>{this.fsw._remove(t,m)}),h=void 0,d&&this._handleRead(t,!1,i,r,n,o,a)})})}async _handleDir(t,e,i,r,n,o,a){let c=this.fsw._getWatchedDir(C.dirname(t)),l=c.has(C.basename(t));!(i&&this.fsw.options.ignoreInitial)&&!n&&!l&&this.fsw._emit(Et.ADD_DIR,t,e),c.add(C.basename(t)),this.fsw._getWatchedDir(t);let h,f,u=this.fsw.options.depth;if((u==null||r<=u)&&!this.fsw._symlinkPaths.has(a)){if(!n&&(await this._handleRead(t,i,o,n,t,r,h),this.fsw.closed))return;f=this._watchWithNodeFs(t,(d,m)=>{m&&m.mtimeMs===0||this._handleRead(d,!1,o,n,t,r,h)})}return f}async _addToNodeFs(t,e,i,r,n){let o=this.fsw._emitReady;if(this.fsw._isIgnored(t)||this.fsw.closed)return o(),!1;let a=this.fsw._getWatchHelpers(t);i&&(a.filterPath=c=>i.filterPath(c),a.filterDir=c=>i.filterDir(c));try{let c=await Bm[a.statMethod](a.watchPath);if(this.fsw.closed)return;if(this.fsw._isIgnored(a.watchPath,c))return o(),!1;let l=this.fsw.options.followSymlinks,h;if(c.isDirectory()){let f=C.resolve(t),u=l?await Yr(t):t;if(this.fsw.closed||(h=await this._handleDir(a.watchPath,c,e,r,n,a,u),this.fsw.closed))return;f!==u&&u!==void 0&&this.fsw._symlinkPaths.set(f,u)}else if(c.isSymbolicLink()){let f=l?await Yr(t):t;if(this.fsw.closed)return;let u=C.dirname(a.watchPath);if(this.fsw._getWatchedDir(u).add(a.watchPath),this.fsw._emit(Et.ADD,a.watchPath,c),h=await this._handleDir(u,c,e,r,t,a,f),this.fsw.closed)return;f!==void 0&&this.fsw._symlinkPaths.set(C.resolve(t),f)}else h=this._handleFile(a.watchPath,c,e);return o(),h&&this.fsw._addPathCloser(t,h),!1}catch(c){if(this.fsw._handleError(c))return o(),t}}};var Xr="/",Zm="//",Mc=".",Qm="..",tp="string",ep=/\\/g,Pc=/\/\//,sp=/\..*\.(sw[px])$|~$|\.subl.*\.tmp/,ip=/^\.[/\\]/;function Ni(s){return Array.isArray(s)?s:[s]}var Zr=s=>typeof s=="object"&&s!==null&&!(s instanceof RegExp);function rp(s){return typeof s=="function"?s:typeof s=="string"?t=>s===t:s instanceof RegExp?t=>s.test(t):typeof s=="object"&&s!==null?t=>{if(s.path===t)return!0;if(s.recursive){let e=v.relative(s.path,t);return e?!e.startsWith("..")&&!v.isAbsolute(e):!1}return!1}:()=>!1}function np(s){if(typeof s!="string")throw new Error("string expected");s=v.normalize(s),s=s.replace(/\\/g,"/");let t=!1;s.startsWith("//")&&(t=!0);let e=/\/\//;for(;s.match(e);)s=s.replace(e,"/");return t&&(s="/"+s),s}function jc(s,t,e){let i=np(t);for(let r=0;r<s.length;r++){let n=s[r];if(n(i,e))return!0}return!1}function op(s,t){if(s==null)throw new TypeError("anymatch: specify first argument");let i=Ni(s).map(r=>rp(r));return t==null?(r,n)=>jc(i,r,n):jc(i,t)}var Dc=s=>{let t=Ni(s).flat();if(!t.every(e=>typeof e===tp))throw new TypeError(`Non-string provided as watch path: ${t}`);return t.map($c)},Fc=s=>{let t=s.replace(ep,Xr),e=!1;for(t.startsWith(Zm)&&(e=!0);t.match(Pc);)t=t.replace(Pc,Xr);return e&&(t=Xr+t),t},$c=s=>Fc(v.normalize(Fc(s))),Ic=(s="")=>t=>typeof t=="string"?$c(v.isAbsolute(t)?t:v.join(s,t)):t,ap=(s,t)=>v.isAbsolute(s)?s:v.join(t,s),cp=Object.freeze(new Set),Qr=class{constructor(t,e){this.path=t,this._removeWatcher=e,this.items=new Set}add(t){let{items:e}=this;e&&t!==Mc&&t!==Qm&&e.add(t)}async remove(t){let{items:e}=this;if(!e||(e.delete(t),e.size>0))return;let i=this.path;try{await Km(i)}catch{this._removeWatcher&&this._removeWatcher(v.dirname(i),v.basename(i))}}has(t){let{items:e}=this;if(e)return e.has(t)}getChildren(){let{items:t}=this;return t?[...t.values()]:[]}dispose(){this.items.clear(),this.path="",this._removeWatcher=Ri,this.items=cp,Object.freeze(this)}},lp="stat",fp="lstat",tn=class{constructor(t,e,i){this.fsw=i;let r=t;this.path=t=t.replace(ip,""),this.watchPath=r,this.fullWatchPath=v.resolve(r),this.dirParts=[],this.dirParts.forEach(n=>{n.length>1&&n.pop()}),this.followSymlinks=e,this.statMethod=e?lp:fp}entryPath(t){return v.join(this.watchPath,v.relative(this.watchPath,t.fullPath))}filterPath(t){let{stats:e}=t;if(e&&e.isSymbolicLink())return this.filterDir(t);let i=this.entryPath(t);return this.fsw._isntIgnored(i,e)&&this.fsw._hasReadPermissions(e)}filterDir(t){return this.fsw._isntIgnored(this.entryPath(t),t.stats)}},en=class extends Xm{constructor(t={}){super(),this.closed=!1,this._closers=new Map,this._ignoredPaths=new Set,this._throttled=new Map,this._streams=new Set,this._symlinkPaths=new Map,this._watched=new Map,this._pendingWrites=new Map,this._pendingUnlinks=new Map,this._readyCount=0,this._readyEmitted=!1;let e=t.awaitWriteFinish,i={stabilityThreshold:2e3,pollInterval:100},r={persistent:!0,ignoreInitial:!1,ignorePermissionErrors:!1,interval:100,binaryInterval:300,followSymlinks:!0,usePolling:!1,atomic:!0,...t,ignored:t.ignored?Ni(t.ignored):Ni([]),awaitWriteFinish:e===!0?i:typeof e=="object"?{...i,...e}:!1};Cc&&(r.usePolling=!0),r.atomic===void 0&&(r.atomic=!r.usePolling);let n=process.env.CHOKIDAR_USEPOLLING;if(n!==void 0){let c=n.toLowerCase();c==="false"||c==="0"?r.usePolling=!1:c==="true"||c==="1"?r.usePolling=!0:r.usePolling=!!c}let o=process.env.CHOKIDAR_INTERVAL;o&&(r.interval=Number.parseInt(o,10));let a=0;this._emitReady=()=>{a++,a>=this._readyCount&&(this._emitReady=Ri,this._readyEmitted=!0,process.nextTick(()=>this.emit(P.READY)))},this._emitRaw=(...c)=>this.emit(P.RAW,...c),this._boundRemove=this._remove.bind(this),this.options=r,this._nodeFsHandler=new Oi(this),Object.freeze(r)}_addIgnoredPath(t){if(Zr(t)){for(let e of this._ignoredPaths)if(Zr(e)&&e.path===t.path&&e.recursive===t.recursive)return}this._ignoredPaths.add(t)}_removeIgnoredPath(t){if(this._ignoredPaths.delete(t),typeof t=="string")for(let e of this._ignoredPaths)Zr(e)&&e.path===t&&this._ignoredPaths.delete(e)}add(t,e,i){let{cwd:r}=this.options;this.closed=!1,this._closePromise=void 0;let n=Dc(t);return r&&(n=n.map(o=>ap(o,r))),n.forEach(o=>{this._removeIgnoredPath(o)}),this._userIgnored=void 0,this._readyCount||(this._readyCount=0),this._readyCount+=n.length,Promise.all(n.map(async o=>{let a=await this._nodeFsHandler._addToNodeFs(o,!i,void 0,0,e);return a&&this._emitReady(),a})).then(o=>{this.closed||o.forEach(a=>{a&&this.add(v.dirname(a),v.basename(e||a))})}),this}unwatch(t){if(this.closed)return this;let e=Dc(t),{cwd:i}=this.options;return e.forEach(r=>{!v.isAbsolute(r)&&!this._closers.has(r)&&(i&&(r=v.join(i,r)),r=v.resolve(r)),this._closePath(r),this._addIgnoredPath(r),this._watched.has(r)&&this._addIgnoredPath({path:r,recursive:!0}),this._userIgnored=void 0}),this}close(){if(this._closePromise)return this._closePromise;this.closed=!0,this.removeAllListeners();let t=[];return this._closers.forEach(e=>e.forEach(i=>{let r=i();r instanceof Promise&&t.push(r)})),this._streams.forEach(e=>e.destroy()),this._userIgnored=void 0,this._readyCount=0,this._readyEmitted=!1,this._watched.forEach(e=>e.dispose()),this._closers.clear(),this._watched.clear(),this._streams.clear(),this._symlinkPaths.clear(),this._throttled.clear(),this._closePromise=t.length?Promise.all(t).then(()=>{}):Promise.resolve(),this._closePromise}getWatched(){let t={};return this._watched.forEach((e,i)=>{let n=(this.options.cwd?v.relative(this.options.cwd,i):i)||Mc;t[n]=e.getChildren().sort()}),t}emitWithAll(t,e){this.emit(t,...e),t!==P.ERROR&&this.emit(P.ALL,t,...e)}async _emit(t,e,i){if(this.closed)return;let r=this.options;Kr&&(e=v.normalize(e)),r.cwd&&(e=v.relative(r.cwd,e));let n=[e];i!=null&&n.push(i);let o=r.awaitWriteFinish,a;if(o&&(a=this._pendingWrites.get(e)))return a.lastChange=new Date,this;if(r.atomic){if(t===P.UNLINK)return this._pendingUnlinks.set(e,[t,...n]),setTimeout(()=>{this._pendingUnlinks.forEach((c,l)=>{this.emit(...c),this.emit(P.ALL,...c),this._pendingUnlinks.delete(l)})},typeof r.atomic=="number"?r.atomic:100),this;t===P.ADD&&this._pendingUnlinks.has(e)&&(t=P.CHANGE,this._pendingUnlinks.delete(e))}if(o&&(t===P.ADD||t===P.CHANGE)&&this._readyEmitted){let c=(l,h)=>{l?(t=P.ERROR,n[0]=l,this.emitWithAll(t,n)):h&&(n.length>1?n[1]=h:n.push(h),this.emitWithAll(t,n))};return this._awaitWriteFinish(e,o.stabilityThreshold,t,c),this}if(t===P.CHANGE&&!this._throttle(P.CHANGE,e,50))return this;if(r.alwaysStat&&i===void 0&&(t===P.ADD||t===P.ADD_DIR||t===P.CHANGE)){let c=r.cwd?v.join(r.cwd,e):e,l;try{l=await Jm(c)}catch{}if(!l||this.closed)return;n.push(l)}return this.emitWithAll(t,n),this}_handleError(t){let e=t&&t.code;return t&&e!=="ENOENT"&&e!=="ENOTDIR"&&(!this.options.ignorePermissionErrors||e!=="EPERM"&&e!=="EACCES")&&this.emit(P.ERROR,t),t||this.closed}_throttle(t,e,i){this._throttled.has(t)||this._throttled.set(t,new Map);let r=this._throttled.get(t);if(!r)throw new Error("invalid throttle");let n=r.get(e);if(n)return n.count++,!1;let o,a=()=>{let l=r.get(e),h=l?l.count:0;return r.delete(e),clearTimeout(o),l&&clearTimeout(l.timeoutObject),h};o=setTimeout(a,i);let c={timeoutObject:o,clear:a,count:0};return r.set(e,c),c}_incrReadyCount(){return this._readyCount++}_awaitWriteFinish(t,e,i,r){let n=this.options.awaitWriteFinish;if(typeof n!="object")return;let o=n.pollInterval,a,c=t;this.options.cwd&&!v.isAbsolute(t)&&(c=v.join(this.options.cwd,t));let l=new Date,h=this._pendingWrites;function f(u){Vm(c,(d,m)=>{if(d||!h.has(t)){d&&d.code!=="ENOENT"&&r(d);return}let p=Number(new Date);u&&m.size!==u.size&&(h.get(t).lastChange=p);let y=h.get(t);p-y.lastChange>=e?(h.delete(t),r(void 0,m)):a=setTimeout(f,o,m)})}h.has(t)||(h.set(t,{lastChange:l,cancelWait:()=>(h.delete(t),clearTimeout(a),i)}),a=setTimeout(f,o))}_isIgnored(t,e){if(this.options.atomic&&sp.test(t))return!0;if(!this._userIgnored){let{cwd:i}=this.options,n=(this.options.ignored||[]).map(Ic(i)),a=[...[...this._ignoredPaths].map(Ic(i)),...n];this._userIgnored=op(a,void 0)}return this._userIgnored(t,e)}_isntIgnored(t,e){return!this._isIgnored(t,e)}_getWatchHelpers(t){return new tn(t,this.options.followSymlinks,this)}_getWatchedDir(t){let e=v.resolve(t);return this._watched.has(e)||this._watched.set(e,new Qr(e,this._boundRemove)),this._watched.get(e)}_hasReadPermissions(t){return this.options.ignorePermissionErrors?!0:!!(Number(t.mode)&256)}_remove(t,e,i){let r=v.join(t,e),n=v.resolve(r);if(i=i??(this._watched.has(r)||this._watched.has(n)),!this._throttle("remove",r,100))return;!i&&this._watched.size===1&&this.add(t,e,!0),this._getWatchedDir(r).getChildren().forEach(u=>this._remove(r,u));let c=this._getWatchedDir(t),l=c.has(e);c.remove(e),this._symlinkPaths.has(n)&&this._symlinkPaths.delete(n);let h=r;if(this.options.cwd&&(h=v.relative(this.options.cwd,r)),this.options.awaitWriteFinish&&this._pendingWrites.has(h)&&this._pendingWrites.get(h).cancelWait()===P.ADD)return;this._watched.delete(r),this._watched.delete(n);let f=i?P.UNLINK_DIR:P.UNLINK;l&&!this._isIgnored(r)&&this._emit(f,r),this._closePath(r)}_closePath(t){this._closeFile(t);let e=v.dirname(t);this._getWatchedDir(e).remove(v.basename(t))}_closeFile(t){let e=this._closers.get(t);e&&(e.forEach(i=>i()),this._closers.delete(t))}_addPathCloser(t,e){if(!e)return;let i=this._closers.get(t);i||(i=[],this._closers.set(t,i)),i.push(e)}_readdirp(t,e){if(this.closed)return;let i={type:P.ALL,alwaysStat:!0,lstat:!0,...e,depth:0},r=Tc(t,i);return this._streams.add(r),r.once(Rc,()=>{r=void 0}),r.once(Jr,()=>{r&&(this._streams.delete(r),r=void 0)}),r}};function Lc(s,t={}){let e=new en(t);return e.add(s),e}import{readFileSync as up}from"fs";import{resolve as De,sep as dp}from"path";import{fileURLToPath as mp}from"url";var Wc=()=>{try{return JSON.stringify(JSON.parse(up("./package.json","utf8")))}catch{return"null"}},sn="null",pp={persistent:!0,ignoreInitial:!0,ignorePermissionErrors:!0,ignored:s=>{let t=De(s);return!!(t===Uc||t===Bc||t.startsWith(Bc+dp))}},Uc=De("./src/package.json"),Bc=De("./src/node_modules"),zc=De("./src"),rn=De("./package.json"),gp=[zc,rn],yp=mp(new URL("./index.js",import.meta.url)),Gc=()=>{let s=!1,t=!1,e=Lc(gp,pp),i=()=>{s=!0,t=!1,hp(process.execPath,[yp],{stdio:"inherit"}).on("close",(n,o)=>{n||o?(F(E.red("build failure"),{code:n,signal:o}),ce()):console.log(E.green("build success"),{code:n,signal:o}),t?i():s=!1})};e.on("all",(r,n)=>{if(r==="addDir"&&n===zc)return;let o=De(n);if(o!==Uc){if(o===rn){let a=Wc();if(a===sn)return;sn=a}if(s){o!==rn&&(t=!0);return}_(E.cyan.dim(r),n),i()}}),sn=Wc(),i()};var{exports:wp,tshy:bp}=k,Sp=async()=>{for(let s of process.argv.slice(2))switch(s){case"--help":case"-h":return zr();case"--watch":case"-w":return Gc();default:return zr(`Unknown argument: ${s}`)}_(E.yellow.bold("building"),process.cwd()),_(E.cyan.dim("tshy config"),bp),_(E.cyan.dim("exports"),wp),await yc(),In(E.bold.green("success!"))};await Sp();
|
|
48
48
|
/*! Bundled license information:
|
|
49
49
|
|
|
50
50
|
chokidar/esm/index.js:
|