directus-extension-schema-sync
Version:
Sync schema and data betwreen Directus instances
1 lines • 97.7 kB
JavaScript
import t,{readdir as e,readFile as s,writeFile as i,access as r,mkdir as n,rm as o}from"fs/promises";import a,{resolve as h}from"path";import{fileURLToPath as l,pathToFileURL as c}from"url";import{createHash as p}from"crypto";import{fileURLToPath as d}from"node:url";import{win32 as u,posix as f}from"node:path";import{realpathSync as g,lstatSync as m,readdir as w,readdirSync as y,readlinkSync as b}from"fs";import*as v from"node:fs";import{lstat as S,readdir as x,readlink as k,realpath as E}from"node:fs/promises";import{EventEmitter as C}from"node:events";import A from"node:stream";import{StringDecoder as _}from"node:string_decoder";function F(t){let e=!1,s=!1;return new Proxy(t,{async apply(t,i,r){if(e)s=!0;else do{e=!0,s=!1;try{return await Reflect.apply(t,i,r)}catch(t){console.error("Error in condensed action:",t)}finally{e=!1}}while(s)}})}const T={role:"",admin:!0};function L(t,e){return import(c(h(t,e)).href)}class O{static get schemaDir(){return h(process.cwd(),"schema-sync")}static get dataDir(){return h(O.schemaDir,"data")}static get hashFile(){return h(O.schemaDir,"hash.txt")}static utcTS(t=(new Date).toISOString()){return t.replace("T"," ").replace(/\.\d*Z/,"")}static async updateExportMeta(){const t=p("sha256"),r=await e(O.dataDir);for(const e of r)if(e.endsWith(".json")){const i=await s(`${O.dataDir}/${e}`,{encoding:"utf8"});t.update(i)}const n=t.digest("hex"),{hash:o}=await O.getExportMeta()||{};if(n===o)return!1;const a=O.utcTS(),h=n+"@"+a;return await i(this.hashFile,h),{hash:n,ts:a}}static async fileExists(t){try{return await r(t),!0}catch{return!1}}static async getExportMeta(){try{const t=await s(this.hashFile,{encoding:"utf8"}),[e,i]=t.split("@");if(e&&i&&"Invalid Date"!==new Date(i).toString())return{hash:e,ts:i}}catch{}return null}}function M(t,e){if(t===e)return!0;if("object"!=typeof t||null===t||"object"!=typeof e||null===e)return!1;const s=Object.keys(t),i=Object.keys(e);if(s.length!==i.length)return!1;for(let r of s){if(!i.includes(r))return!1;if(!M(t[r],e[r]))return!1}return!0}function D(t,e){if(!e)return t;const s={};let i=!1;return Object.keys(t).forEach((r=>{M(t[r],e[r])||(s[r]=t[r],i=!0)})),i?s:null}function N(t){if("object"!=typeof t||null===t)return t;if(Array.isArray(t))return t.map(N);const e={};return Object.keys(t).sort().forEach((s=>{e[s]=N(t[s])})),e}function z(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var R=P;function P(t,e,s){t instanceof RegExp&&(t=j(t,s)),e instanceof RegExp&&(e=j(e,s));var i=I(t,e,s);return i&&{start:i[0],end:i[1],pre:s.slice(0,i[0]),body:s.slice(i[0]+t.length,i[1]),post:s.slice(i[1]+e.length)}}function j(t,e){var s=e.match(t);return s?s[0]:null}function I(t,e,s){var i,r,n,o,a,h=s.indexOf(t),l=s.indexOf(e,h+1),c=h;if(h>=0&&l>0){if(t===e)return[h,l];for(i=[],n=s.length;c>=0&&!a;)c==h?(i.push(c),h=s.indexOf(t,c+1)):1==i.length?a=[i.pop(),l]:((r=i.pop())<n&&(n=r,o=l),l=s.indexOf(e,c+1)),c=h<l&&h>=0?h:l;i.length&&(a=[n,o])}return a}P.range=I;var B=R,$=function(t){if(!t)return[];"{}"===t.substr(0,2)&&(t="\\{\\}"+t.substr(2));return tt(function(t){return t.split("\\\\").join(W).split("\\{").join(U).split("\\}").join(G).split("\\,").join(H).split("\\.").join(q)}(t),!0).map(J)},W="\0SLASH"+Math.random()+"\0",U="\0OPEN"+Math.random()+"\0",G="\0CLOSE"+Math.random()+"\0",H="\0COMMA"+Math.random()+"\0",q="\0PERIOD"+Math.random()+"\0";function Y(t){return parseInt(t,10)==t?parseInt(t,10):t.charCodeAt(0)}function J(t){return t.split(W).join("\\").split(U).join("{").split(G).join("}").split(H).join(",").split(q).join(".")}function K(t){if(!t)return[""];var e=[],s=B("{","}",t);if(!s)return t.split(",");var i=s.pre,r=s.body,n=s.post,o=i.split(",");o[o.length-1]+="{"+r+"}";var a=K(n);return n.length&&(o[o.length-1]+=a.shift(),o.push.apply(o,a)),e.push.apply(e,o),e}function V(t){return"{"+t+"}"}function Z(t){return/^-?0\d/.test(t)}function Q(t,e){return t<=e}function X(t,e){return t>=e}function tt(t,e){var s=[],i=B("{","}",t);if(!i)return[t];var r=i.pre,n=i.post.length?tt(i.post,!1):[""];if(/\$$/.test(i.pre))for(var o=0;o<n.length;o++){var a=r+"{"+i.body+"}"+n[o];s.push(a)}else{var h,l,c=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(i.body),p=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(i.body),d=c||p,u=i.body.indexOf(",")>=0;if(!d&&!u)return i.post.match(/,.*\}/)?tt(t=i.pre+"{"+i.body+G+i.post):[t];if(d)h=i.body.split(/\.\./);else if(1===(h=K(i.body)).length&&1===(h=tt(h[0],!1).map(V)).length)return n.map((function(t){return i.pre+h[0]+t}));if(d){var f=Y(h[0]),g=Y(h[1]),m=Math.max(h[0].length,h[1].length),w=3==h.length?Math.abs(Y(h[2])):1,y=Q;g<f&&(w*=-1,y=X);var b=h.some(Z);l=[];for(var v=f;y(v,g);v+=w){var S;if(p)"\\"===(S=String.fromCharCode(v))&&(S="");else if(S=String(v),b){var x=m-S.length;if(x>0){var k=new Array(x+1).join("0");S=v<0?"-"+k+S.slice(1):k+S}}l.push(S)}}else{l=[];for(var E=0;E<h.length;E++)l.push.apply(l,tt(h[E],!1))}for(E=0;E<l.length;E++)for(o=0;o<n.length;o++){a=r+l[E]+n[o];(!e||d||a)&&s.push(a)}}return s}var et=z($);const st=t=>{if("string"!=typeof t)throw new TypeError("invalid pattern");if(t.length>65536)throw new TypeError("pattern is too long")},it={"[: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]},rt=t=>t.replace(/[[\]\\-]/g,"\\$&"),nt=t=>t.join(""),ot=(t,e)=>{const s=e;if("["!==t.charAt(s))throw new Error("not in a brace expression");const i=[],r=[];let n=s+1,o=!1,a=!1,h=!1,l=!1,c=s,p="";t:for(;n<t.length;){const e=t.charAt(n);if("!"!==e&&"^"!==e||n!==s+1){if("]"===e&&o&&!h){c=n+1;break}if(o=!0,"\\"!==e||h){if("["===e&&!h)for(const[e,[o,h,l]]of Object.entries(it))if(t.startsWith(e,n)){if(p)return["$.",!1,t.length-s,!0];n+=e.length,l?r.push(o):i.push(o),a=a||h;continue t}h=!1,p?(e>p?i.push(rt(p)+"-"+rt(e)):e===p&&i.push(rt(e)),p="",n++):t.startsWith("-]",n+1)?(i.push(rt(e+"-")),n+=2):t.startsWith("-",n+1)?(p=e,n+=2):(i.push(rt(e)),n++)}else h=!0,n++}else l=!0,n++}if(c<n)return["",!1,0,!1];if(!i.length&&!r.length)return["$.",!1,t.length-s,!0];if(0===r.length&&1===i.length&&/^\\?.$/.test(i[0])&&!l){const t=2===i[0].length?i[0].slice(-1):i[0];return[(d=t,d.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")),!1,c-s,!1]}var d;const u="["+(l?"^":"")+nt(i)+"]",f="["+(l?"":"^")+nt(r)+"]";return[i.length&&r.length?"("+u+"|"+f+")":i.length?u:f,a,c-s,!0]},at=(t,{windowsPathsNoEscape:e=!1}={})=>e?t.replace(/\[([^\/\\])\]/g,"$1"):t.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1"),ht=new Set(["!","?","+","*","@"]),lt=t=>ht.has(t),ct="(?!\\.)",pt=new Set(["[","."]),dt=new Set(["..","."]),ut=new Set("().*{}+?[]^$\\!"),ft="[^/]",gt=ft+"*?",mt=ft+"+?";class wt{type;#t;#e;#s=!1;#i=[];#r;#n;#o;#a=!1;#h;#l;#c=!1;constructor(t,e,s={}){this.type=t,t&&(this.#e=!0),this.#r=e,this.#t=this.#r?this.#r.#t:this,this.#h=this.#t===this?s:this.#t.#h,this.#o=this.#t===this?[]:this.#t.#o,"!"!==t||this.#t.#a||this.#o.push(this),this.#n=this.#r?this.#r.#i.length:0}get hasMagic(){if(void 0!==this.#e)return this.#e;for(const t of this.#i)if("string"!=typeof t&&(t.type||t.hasMagic))return this.#e=!0;return this.#e}toString(){return void 0!==this.#l?this.#l:this.type?this.#l=this.type+"("+this.#i.map((t=>String(t))).join("|")+")":this.#l=this.#i.map((t=>String(t))).join("")}#p(){if(this!==this.#t)throw new Error("should only call on root");if(this.#a)return this;let t;for(this.toString(),this.#a=!0;t=this.#o.pop();){if("!"!==t.type)continue;let e=t,s=e.#r;for(;s;){for(let i=e.#n+1;!s.type&&i<s.#i.length;i++)for(const e of t.#i){if("string"==typeof e)throw new Error("string part in extglob AST??");e.copyIn(s.#i[i])}e=s,s=e.#r}}return this}push(...t){for(const e of t)if(""!==e){if("string"!=typeof e&&!(e instanceof wt&&e.#r===this))throw new Error("invalid part: "+e);this.#i.push(e)}}toJSON(){const t=null===this.type?this.#i.slice().map((t=>"string"==typeof t?t:t.toJSON())):[this.type,...this.#i.map((t=>t.toJSON()))];return this.isStart()&&!this.type&&t.unshift([]),this.isEnd()&&(this===this.#t||this.#t.#a&&"!"===this.#r?.type)&&t.push({}),t}isStart(){if(this.#t===this)return!0;if(!this.#r?.isStart())return!1;if(0===this.#n)return!0;const t=this.#r;for(let e=0;e<this.#n;e++){const s=t.#i[e];if(!(s instanceof wt&&"!"===s.type))return!1}return!0}isEnd(){if(this.#t===this)return!0;if("!"===this.#r?.type)return!0;if(!this.#r?.isEnd())return!1;if(!this.type)return this.#r?.isEnd();const t=this.#r?this.#r.#i.length:0;return this.#n===t-1}copyIn(t){"string"==typeof t?this.push(t):this.push(t.clone(this))}clone(t){const e=new wt(this.type,t);for(const t of this.#i)e.copyIn(t);return e}static#d(t,e,s,i){let r=!1,n=!1,o=-1,a=!1;if(null===e.type){let h=s,l="";for(;h<t.length;){const s=t.charAt(h++);if(r||"\\"===s)r=!r,l+=s;else if(n)h===o+1?"^"!==s&&"!"!==s||(a=!0):"]"!==s||h===o+2&&a||(n=!1),l+=s;else if("["!==s)if(i.noext||!lt(s)||"("!==t.charAt(h))l+=s;else{e.push(l),l="";const r=new wt(s,e);h=wt.#d(t,r,h,i),e.push(r)}else n=!0,o=h,a=!1,l+=s}return e.push(l),h}let h=s+1,l=new wt(null,e);const c=[];let p="";for(;h<t.length;){const s=t.charAt(h++);if(r||"\\"===s)r=!r,p+=s;else if(n)h===o+1?"^"!==s&&"!"!==s||(a=!0):"]"!==s||h===o+2&&a||(n=!1),p+=s;else if("["!==s)if(lt(s)&&"("===t.charAt(h)){l.push(p),p="";const e=new wt(s,l);l.push(e),h=wt.#d(t,e,h,i)}else if("|"!==s){if(")"===s)return""===p&&0===e.#i.length&&(e.#c=!0),l.push(p),p="",e.push(...c,l),h;p+=s}else l.push(p),p="",c.push(l),l=new wt(null,e);else n=!0,o=h,a=!1,p+=s}return e.type=null,e.#e=void 0,e.#i=[t.substring(s-1)],h}static fromGlob(t,e={}){const s=new wt(null,void 0,e);return wt.#d(t,s,0,e),s}toMMPattern(){if(this!==this.#t)return this.#t.toMMPattern();const t=this.toString(),[e,s,i,r]=this.toRegExpSource();if(!(i||this.#e||this.#h.nocase&&!this.#h.nocaseMagicOnly&&t.toUpperCase()!==t.toLowerCase()))return s;const n=(this.#h.nocase?"i":"")+(r?"u":"");return Object.assign(new RegExp(`^${e}$`,n),{_src:e,_glob:t})}get options(){return this.#h}toRegExpSource(t){const e=t??!!this.#h.dot;if(this.#t===this&&this.#p(),!this.type){const s=this.isStart()&&this.isEnd(),i=this.#i.map((e=>{const[i,r,n,o]="string"==typeof e?wt.#u(e,this.#e,s):e.toRegExpSource(t);return this.#e=this.#e||n,this.#s=this.#s||o,i})).join("");let r="";if(this.isStart()&&"string"==typeof this.#i[0]){if(!(1===this.#i.length&&dt.has(this.#i[0]))){const s=pt,n=e&&s.has(i.charAt(0))||i.startsWith("\\.")&&s.has(i.charAt(2))||i.startsWith("\\.\\.")&&s.has(i.charAt(4)),o=!e&&!t&&s.has(i.charAt(0));r=n?"(?!(?:^|/)\\.\\.?(?:$|/))":o?ct:""}}let n="";this.isEnd()&&this.#t.#a&&"!"===this.#r?.type&&(n="(?:$|\\/)");return[r+i+n,at(i),this.#e=!!this.#e,this.#s]}const s="*"===this.type||"+"===this.type,i="!"===this.type?"(?:(?!(?:":"(?:";let r=this.#f(e);if(this.isStart()&&this.isEnd()&&!r&&"!"!==this.type){const t=this.toString();return this.#i=[t],this.type=null,this.#e=void 0,[t,at(this.toString()),!1,!1]}let n=!s||t||e?"":this.#f(!0);n===r&&(n=""),n&&(r=`(?:${r})(?:${n})*?`);let o="";if("!"===this.type&&this.#c)o=(this.isStart()&&!e?ct:"")+mt;else{o=i+r+("!"===this.type?"))"+(!this.isStart()||e||t?"":ct)+gt+")":"@"===this.type?")":"?"===this.type?")?":"+"===this.type&&n?")":"*"===this.type&&n?")?":`)${this.type}`)}return[o,at(r),this.#e=!!this.#e,this.#s]}#f(t){return this.#i.map((e=>{if("string"==typeof e)throw new Error("string type in extglob ast??");const[s,i,r,n]=e.toRegExpSource(t);return this.#s=this.#s||n,s})).filter((t=>!(this.isStart()&&this.isEnd()&&!t))).join("|")}static#u(t,e,s=!1){let i=!1,r="",n=!1;for(let o=0;o<t.length;o++){const a=t.charAt(o);if(i)i=!1,r+=(ut.has(a)?"\\":"")+a;else if("\\"!==a){if("["===a){const[s,i,a,h]=ot(t,o);if(a){r+=s,n=n||i,o+=a-1,e=e||h;continue}}"*"!==a?"?"!==a?r+=a.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"):(r+=ft,e=!0):(r+=s&&"*"===t?mt:gt,e=!0)}else o===t.length-1?r+="\\\\":i=!0}return[r,at(t),!!e,n]}}const yt=(t,{windowsPathsNoEscape:e=!1}={})=>e?t.replace(/[?*()[\]]/g,"[$&]"):t.replace(/[?*()[\]\\]/g,"\\$&"),bt=(t,e,s={})=>(st(e),!(!s.nocomment&&"#"===e.charAt(0))&&new Ht(e,s).match(t)),vt=/^\*+([^+@!?\*\[\(]*)$/,St=t=>e=>!e.startsWith(".")&&e.endsWith(t),xt=t=>e=>e.endsWith(t),kt=t=>(t=t.toLowerCase(),e=>!e.startsWith(".")&&e.toLowerCase().endsWith(t)),Et=t=>(t=t.toLowerCase(),e=>e.toLowerCase().endsWith(t)),Ct=/^\*+\.\*+$/,At=t=>!t.startsWith(".")&&t.includes("."),_t=t=>"."!==t&&".."!==t&&t.includes("."),Ft=/^\.\*+$/,Tt=t=>"."!==t&&".."!==t&&t.startsWith("."),Lt=/^\*+$/,Ot=t=>0!==t.length&&!t.startsWith("."),Mt=t=>0!==t.length&&"."!==t&&".."!==t,Dt=/^\?+([^+@!?\*\[\(]*)?$/,Nt=([t,e=""])=>{const s=jt([t]);return e?(e=e.toLowerCase(),t=>s(t)&&t.toLowerCase().endsWith(e)):s},zt=([t,e=""])=>{const s=It([t]);return e?(e=e.toLowerCase(),t=>s(t)&&t.toLowerCase().endsWith(e)):s},Rt=([t,e=""])=>{const s=It([t]);return e?t=>s(t)&&t.endsWith(e):s},Pt=([t,e=""])=>{const s=jt([t]);return e?t=>s(t)&&t.endsWith(e):s},jt=([t])=>{const e=t.length;return t=>t.length===e&&!t.startsWith(".")},It=([t])=>{const e=t.length;return t=>t.length===e&&"."!==t&&".."!==t},Bt="object"==typeof process&&process?"object"==typeof process.env&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix";bt.sep="win32"===Bt?{sep:"\\"}.sep:{sep:"/"}.sep;const $t=Symbol("globstar **");bt.GLOBSTAR=$t;bt.filter=(t,e={})=>s=>bt(s,t,e);const Wt=(t,e={})=>Object.assign({},t,e);bt.defaults=t=>{if(!t||"object"!=typeof t||!Object.keys(t).length)return bt;const e=bt;return Object.assign(((s,i,r={})=>e(s,i,Wt(t,r))),{Minimatch:class extends e.Minimatch{constructor(e,s={}){super(e,Wt(t,s))}static defaults(s){return e.defaults(Wt(t,s)).Minimatch}},AST:class extends e.AST{constructor(e,s,i={}){super(e,s,Wt(t,i))}static fromGlob(s,i={}){return e.AST.fromGlob(s,Wt(t,i))}},unescape:(s,i={})=>e.unescape(s,Wt(t,i)),escape:(s,i={})=>e.escape(s,Wt(t,i)),filter:(s,i={})=>e.filter(s,Wt(t,i)),defaults:s=>e.defaults(Wt(t,s)),makeRe:(s,i={})=>e.makeRe(s,Wt(t,i)),braceExpand:(s,i={})=>e.braceExpand(s,Wt(t,i)),match:(s,i,r={})=>e.match(s,i,Wt(t,r)),sep:e.sep,GLOBSTAR:$t})};const Ut=(t,e={})=>(st(t),e.nobrace||!/\{(?:(?!\{).)*\}/.test(t)?[t]:et(t));bt.braceExpand=Ut;bt.makeRe=(t,e={})=>new Ht(t,e).makeRe();bt.match=(t,e,s={})=>{const i=new Ht(e,s);return t=t.filter((t=>i.match(t))),i.options.nonull&&!t.length&&t.push(e),t};const Gt=/[?*]|[+@!]\(.*?\)|\[|\]/;class Ht{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;regexp;constructor(t,e={}){st(t),e=e||{},this.options=e,this.pattern=t,this.platform=e.platform||Bt,this.isWindows="win32"===this.platform,this.windowsPathsNoEscape=!!e.windowsPathsNoEscape||!1===e.allowWindowsEscape,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=void 0!==e.windowsNoMagicRoot?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(const t of this.set)for(const e of t)if("string"!=typeof e)return!0;return!1}debug(...t){}make(){const t=this.pattern,e=this.options;if(!e.nocomment&&"#"===t.charAt(0))return void(this.comment=!0);if(!t)return void(this.empty=!0);this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],e.debug&&(this.debug=(...t)=>console.error(...t)),this.debug(this.pattern,this.globSet);const s=this.globSet.map((t=>this.slashSplit(t)));this.globParts=this.preprocess(s),this.debug(this.pattern,this.globParts);let i=this.globParts.map(((t,e,s)=>{if(this.isWindows&&this.windowsNoMagicRoot){const e=!(""!==t[0]||""!==t[1]||"?"!==t[2]&&Gt.test(t[2])||Gt.test(t[3])),s=/^[a-z]:/i.test(t[0]);if(e)return[...t.slice(0,4),...t.slice(4).map((t=>this.parse(t)))];if(s)return[t[0],...t.slice(1).map((t=>this.parse(t)))]}return t.map((t=>this.parse(t)))}));if(this.debug(this.pattern,i),this.set=i.filter((t=>-1===t.indexOf(!1))),this.isWindows)for(let t=0;t<this.set.length;t++){const e=this.set[t];""===e[0]&&""===e[1]&&"?"===this.globParts[t][2]&&"string"==typeof e[3]&&/^[a-z]:$/i.test(e[3])&&(e[2]="?")}this.debug(this.pattern,this.set)}preprocess(t){if(this.options.noglobstar)for(let e=0;e<t.length;e++)for(let s=0;s<t[e].length;s++)"**"===t[e][s]&&(t[e][s]="*");const{optimizationLevel:e=1}=this.options;return e>=2?(t=this.firstPhasePreProcess(t),t=this.secondPhasePreProcess(t)):t=e>=1?this.levelOneOptimize(t):this.adjascentGlobstarOptimize(t),t}adjascentGlobstarOptimize(t){return t.map((t=>{let e=-1;for(;-1!==(e=t.indexOf("**",e+1));){let s=e;for(;"**"===t[s+1];)s++;s!==e&&t.splice(e,s-e)}return t}))}levelOneOptimize(t){return t.map((t=>0===(t=t.reduce(((t,e)=>{const s=t[t.length-1];return"**"===e&&"**"===s?t:".."===e&&s&&".."!==s&&"."!==s&&"**"!==s?(t.pop(),t):(t.push(e),t)}),[])).length?[""]:t))}levelTwoFileOptimize(t){Array.isArray(t)||(t=this.slashSplit(t));let e=!1;do{if(e=!1,!this.preserveMultipleSlashes){for(let s=1;s<t.length-1;s++){const i=t[s];1===s&&""===i&&""===t[0]||("."!==i&&""!==i||(e=!0,t.splice(s,1),s--))}"."!==t[0]||2!==t.length||"."!==t[1]&&""!==t[1]||(e=!0,t.pop())}let s=0;for(;-1!==(s=t.indexOf("..",s+1));){const i=t[s-1];i&&"."!==i&&".."!==i&&"**"!==i&&(e=!0,t.splice(s-1,2),s-=2)}}while(e);return 0===t.length?[""]:t}firstPhasePreProcess(t){let e=!1;do{e=!1;for(let s of t){let i=-1;for(;-1!==(i=s.indexOf("**",i+1));){let r=i;for(;"**"===s[r+1];)r++;r>i&&s.splice(i+1,r-i);let n=s[i+1];const o=s[i+2],a=s[i+3];if(".."!==n)continue;if(!o||"."===o||".."===o||!a||"."===a||".."===a)continue;e=!0,s.splice(i,1);const h=s.slice(0);h[i]="**",t.push(h),i--}if(!this.preserveMultipleSlashes){for(let t=1;t<s.length-1;t++){const i=s[t];1===t&&""===i&&""===s[0]||("."!==i&&""!==i||(e=!0,s.splice(t,1),t--))}"."!==s[0]||2!==s.length||"."!==s[1]&&""!==s[1]||(e=!0,s.pop())}let r=0;for(;-1!==(r=s.indexOf("..",r+1));){const t=s[r-1];if(t&&"."!==t&&".."!==t&&"**"!==t){e=!0;const t=1===r&&"**"===s[r+1]?["."]:[];s.splice(r-1,2,...t),0===s.length&&s.push(""),r-=2}}}}while(e);return t}secondPhasePreProcess(t){for(let e=0;e<t.length-1;e++)for(let s=e+1;s<t.length;s++){const i=this.partsMatch(t[e],t[s],!this.preserveMultipleSlashes);if(i){t[e]=[],t[s]=i;break}}return t.filter((t=>t.length))}partsMatch(t,e,s=!1){let i=0,r=0,n=[],o="";for(;i<t.length&&r<e.length;)if(t[i]===e[r])n.push("b"===o?e[r]:t[i]),i++,r++;else if(s&&"**"===t[i]&&e[r]===t[i+1])n.push(t[i]),i++;else if(s&&"**"===e[r]&&t[i]===e[r+1])n.push(e[r]),r++;else if("*"!==t[i]||!e[r]||!this.options.dot&&e[r].startsWith(".")||"**"===e[r]){if("*"!==e[r]||!t[i]||!this.options.dot&&t[i].startsWith(".")||"**"===t[i])return!1;if("a"===o)return!1;o="b",n.push(e[r]),i++,r++}else{if("b"===o)return!1;o="a",n.push(t[i]),i++,r++}return t.length===e.length&&n}parseNegate(){if(this.nonegate)return;const t=this.pattern;let e=!1,s=0;for(let i=0;i<t.length&&"!"===t.charAt(i);i++)e=!e,s++;s&&(this.pattern=t.slice(s)),this.negate=e}matchOne(t,e,s=!1){const i=this.options;if(this.isWindows){const s="string"==typeof t[0]&&/^[a-z]:$/i.test(t[0]),i=!s&&""===t[0]&&""===t[1]&&"?"===t[2]&&/^[a-z]:$/i.test(t[3]),r="string"==typeof e[0]&&/^[a-z]:$/i.test(e[0]),n=i?3:s?0:void 0,o=!r&&""===e[0]&&""===e[1]&&"?"===e[2]&&"string"==typeof e[3]&&/^[a-z]:$/i.test(e[3])?3:r?0:void 0;if("number"==typeof n&&"number"==typeof o){const[s,i]=[t[n],e[o]];s.toLowerCase()===i.toLowerCase()&&(e[o]=s,o>n?e=e.slice(o):n>o&&(t=t.slice(n)))}}const{optimizationLevel:r=1}=this.options;r>=2&&(t=this.levelTwoFileOptimize(t)),this.debug("matchOne",this,{file:t,pattern:e}),this.debug("matchOne",t.length,e.length);for(var n=0,o=0,a=t.length,h=e.length;n<a&&o<h;n++,o++){this.debug("matchOne loop");var l=e[o],c=t[n];if(this.debug(e,l,c),!1===l)return!1;if(l===$t){this.debug("GLOBSTAR",[e,l,c]);var p=n,d=o+1;if(d===h){for(this.debug("** at the end");n<a;n++)if("."===t[n]||".."===t[n]||!i.dot&&"."===t[n].charAt(0))return!1;return!0}for(;p<a;){var u=t[p];if(this.debug("\nglobstar while",t,p,e,d,u),this.matchOne(t.slice(p),e.slice(d),s))return this.debug("globstar found match!",p,a,u),!0;if("."===u||".."===u||!i.dot&&"."===u.charAt(0)){this.debug("dot detected!",t,p,e,d);break}this.debug("globstar swallow a segment, and continue"),p++}return!(!s||(this.debug("\n>>> no match, partial?",t,p,e,d),p!==a))}let r;if("string"==typeof l?(r=c===l,this.debug("string match",l,c,r)):(r=l.test(c),this.debug("pattern match",l,c,r)),!r)return!1}if(n===a&&o===h)return!0;if(n===a)return s;if(o===h)return n===a-1&&""===t[n];throw new Error("wtf?")}braceExpand(){return Ut(this.pattern,this.options)}parse(t){st(t);const e=this.options;if("**"===t)return $t;if(""===t)return"";let s,i=null;(s=t.match(Lt))?i=e.dot?Mt:Ot:(s=t.match(vt))?i=(e.nocase?e.dot?Et:kt:e.dot?xt:St)(s[1]):(s=t.match(Dt))?i=(e.nocase?e.dot?zt:Nt:e.dot?Rt:Pt)(s):(s=t.match(Ct))?i=e.dot?_t:At:(s=t.match(Ft))&&(i=Tt);const r=wt.fromGlob(t,this.options).toMMPattern();return i&&"object"==typeof r&&Reflect.defineProperty(r,"test",{value:i}),r}makeRe(){if(this.regexp||!1===this.regexp)return this.regexp;const t=this.set;if(!t.length)return this.regexp=!1,this.regexp;const e=this.options,s=e.noglobstar?"[^/]*?":e.dot?"(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?":"(?:(?!(?:\\/|^)\\.).)*?",i=new Set(e.nocase?["i"]:[]);let r=t.map((t=>{const e=t.map((t=>{if(t instanceof RegExp)for(const e of t.flags.split(""))i.add(e);return"string"==typeof t?t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"):t===$t?$t:t._src}));return e.forEach(((t,i)=>{const r=e[i+1],n=e[i-1];t===$t&&n!==$t&&(void 0===n?void 0!==r&&r!==$t?e[i+1]="(?:\\/|"+s+"\\/)?"+r:e[i]=s:void 0===r?e[i-1]=n+"(?:\\/|"+s+")?":r!==$t&&(e[i-1]=n+"(?:\\/|\\/"+s+"\\/)"+r,e[i+1]=$t))})),e.filter((t=>t!==$t)).join("/")})).join("|");const[n,o]=t.length>1?["(?:",")"]:["",""];r="^"+n+r+o+"$",this.negate&&(r="^(?!"+r+").+$");try{this.regexp=new RegExp(r,[...i].join(""))}catch(t){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;const s=this.options;this.isWindows&&(t=t.split("\\").join("/"));const i=this.slashSplit(t);this.debug(this.pattern,"split",i);const r=this.set;this.debug(this.pattern,"set",r);let n=i[i.length-1];if(!n)for(let t=i.length-2;!n&&t>=0;t--)n=i[t];for(let t=0;t<r.length;t++){const o=r[t];let a=i;s.matchBase&&1===o.length&&(a=[n]);if(this.matchOne(a,o,e))return!!s.flipNegate||!this.negate}return!s.flipNegate&&this.negate}static defaults(t){return bt.defaults(t).Minimatch}}bt.AST=wt,bt.Minimatch=Ht,bt.escape=yt,bt.unescape=at;const qt="object"==typeof performance&&performance&&"function"==typeof performance.now?performance:Date,Yt=new Set,Jt="object"==typeof process&&process?process:{},Kt=(t,e,s,i)=>{"function"==typeof Jt.emitWarning?Jt.emitWarning(t,e,s,i):console.error(`[${s}] ${e}: ${t}`)};let Vt=globalThis.AbortController,Zt=globalThis.AbortSignal;if(void 0===Vt){Zt=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(t,e){this._onabort.push(e)}},Vt=class{constructor(){e()}signal=new Zt;abort(t){if(!this.signal.aborted){this.signal.reason=t,this.signal.aborted=!0;for(const e of this.signal._onabort)e(t);this.signal.onabort?.(t)}}};let t="1"!==Jt.env?.LRU_CACHE_IGNORE_AC_WARNING;const e=()=>{t&&(t=!1,Kt("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",e))}}const Qt=t=>t&&t===Math.floor(t)&&t>0&&isFinite(t),Xt=t=>Qt(t)?t<=Math.pow(2,8)?Uint8Array:t<=Math.pow(2,16)?Uint16Array:t<=Math.pow(2,32)?Uint32Array:t<=Number.MAX_SAFE_INTEGER?te:null:null;class te extends Array{constructor(t){super(t),this.fill(0)}}class ee{heap;length;static#g=!1;static create(t){const e=Xt(t);if(!e)return[];ee.#g=!0;const s=new ee(t,e);return ee.#g=!1,s}constructor(t,e){if(!ee.#g)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]}}class se{#m;#w;#y;#b;#v;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#S;#x;#k;#E;#C;#A;#_;#F;#T;#L;#O;#M;#D;#N;#z;#R;#P;static unsafeExposeInternals(t){return{starts:t.#D,ttls:t.#N,sizes:t.#M,keyMap:t.#k,keyList:t.#E,valList:t.#C,next:t.#A,prev:t.#_,get head(){return t.#F},get tail(){return t.#T},free:t.#L,isBackgroundFetch:e=>t.#j(e),backgroundFetch:(e,s,i,r)=>t.#I(e,s,i,r),moveToTail:e=>t.#B(e),indexes:e=>t.#$(e),rindexes:e=>t.#W(e),isStale:e=>t.#U(e)}}get max(){return this.#m}get maxSize(){return this.#w}get calculatedSize(){return this.#x}get size(){return this.#S}get fetchMethod(){return this.#v}get dispose(){return this.#y}get disposeAfter(){return this.#b}constructor(t){const{max:e=0,ttl:s,ttlResolution:i=1,ttlAutopurge:r,updateAgeOnGet:n,updateAgeOnHas:o,allowStale:a,dispose:h,disposeAfter:l,noDisposeOnSet:c,noUpdateTTL:p,maxSize:d=0,maxEntrySize:u=0,sizeCalculation:f,fetchMethod:g,noDeleteOnFetchRejection:m,noDeleteOnStaleGet:w,allowStaleOnFetchRejection:y,allowStaleOnFetchAbort:b,ignoreFetchAbort:v}=t;if(0!==e&&!Qt(e))throw new TypeError("max option must be a nonnegative integer");const S=e?Xt(e):Array;if(!S)throw new Error("invalid max value: "+e);if(this.#m=e,this.#w=d,this.maxEntrySize=u||this.#w,this.sizeCalculation=f,this.sizeCalculation){if(!this.#w&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if("function"!=typeof this.sizeCalculation)throw new TypeError("sizeCalculation set to non-function")}if(void 0!==g&&"function"!=typeof g)throw new TypeError("fetchMethod must be a function if specified");if(this.#v=g,this.#R=!!g,this.#k=new Map,this.#E=new Array(e).fill(void 0),this.#C=new Array(e).fill(void 0),this.#A=new S(e),this.#_=new S(e),this.#F=0,this.#T=0,this.#L=ee.create(e),this.#S=0,this.#x=0,"function"==typeof h&&(this.#y=h),"function"==typeof l?(this.#b=l,this.#O=[]):(this.#b=void 0,this.#O=void 0),this.#z=!!this.#y,this.#P=!!this.#b,this.noDisposeOnSet=!!c,this.noUpdateTTL=!!p,this.noDeleteOnFetchRejection=!!m,this.allowStaleOnFetchRejection=!!y,this.allowStaleOnFetchAbort=!!b,this.ignoreFetchAbort=!!v,0!==this.maxEntrySize){if(0!==this.#w&&!Qt(this.#w))throw new TypeError("maxSize must be a positive integer if specified");if(!Qt(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#G()}if(this.allowStale=!!a,this.noDeleteOnStaleGet=!!w,this.updateAgeOnGet=!!n,this.updateAgeOnHas=!!o,this.ttlResolution=Qt(i)||0===i?i:1,this.ttlAutopurge=!!r,this.ttl=s||0,this.ttl){if(!Qt(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#H()}if(0===this.#m&&0===this.ttl&&0===this.#w)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#m&&!this.#w){const t="LRU_CACHE_UNBOUNDED";if((t=>!Yt.has(t))(t)){Yt.add(t);Kt("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",t,se)}}}getRemainingTTL(t){return this.#k.has(t)?1/0:0}#H(){const t=new te(this.#m),e=new te(this.#m);this.#N=t,this.#D=e,this.#q=(s,i,r=qt.now())=>{if(e[s]=0!==i?r:0,t[s]=i,0!==i&&this.ttlAutopurge){const t=setTimeout((()=>{this.#U(s)&&this.delete(this.#E[s])}),i+1);t.unref&&t.unref()}},this.#Y=s=>{e[s]=0!==t[s]?qt.now():0},this.#J=(r,n)=>{if(t[n]){const o=t[n],a=e[n];if(!o||!a)return;r.ttl=o,r.start=a,r.now=s||i();const h=r.now-a;r.remainingTTL=o-h}};let s=0;const i=()=>{const t=qt.now();if(this.ttlResolution>0){s=t;const e=setTimeout((()=>s=0),this.ttlResolution);e.unref&&e.unref()}return t};this.getRemainingTTL=r=>{const n=this.#k.get(r);if(void 0===n)return 0;const o=t[n],a=e[n];if(!o||!a)return 1/0;return o-((s||i())-a)},this.#U=r=>{const n=e[r],o=t[r];return!!o&&!!n&&(s||i())-n>o}}#Y=()=>{};#J=()=>{};#q=()=>{};#U=()=>!1;#G(){const t=new te(this.#m);this.#x=0,this.#M=t,this.#K=e=>{this.#x-=t[e],t[e]=0},this.#V=(t,e,s,i)=>{if(this.#j(e))return 0;if(!Qt(s)){if(!i)throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");if("function"!=typeof i)throw new TypeError("sizeCalculation must be a function");if(s=i(e,t),!Qt(s))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}return s},this.#Z=(e,s,i)=>{if(t[e]=s,this.#w){const s=this.#w-t[e];for(;this.#x>s;)this.#Q(!0)}this.#x+=t[e],i&&(i.entrySize=s,i.totalCalculatedSize=this.#x)}}#K=t=>{};#Z=(t,e,s)=>{};#V=(t,e,s,i)=>{if(s||i)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#$({allowStale:t=this.allowStale}={}){if(this.#S)for(let e=this.#T;this.#X(e)&&(!t&&this.#U(e)||(yield e),e!==this.#F);)e=this.#_[e]}*#W({allowStale:t=this.allowStale}={}){if(this.#S)for(let e=this.#F;this.#X(e)&&(!t&&this.#U(e)||(yield e),e!==this.#T);)e=this.#A[e]}#X(t){return void 0!==t&&this.#k.get(this.#E[t])===t}*entries(){for(const t of this.#$())void 0===this.#C[t]||void 0===this.#E[t]||this.#j(this.#C[t])||(yield[this.#E[t],this.#C[t]])}*rentries(){for(const t of this.#W())void 0===this.#C[t]||void 0===this.#E[t]||this.#j(this.#C[t])||(yield[this.#E[t],this.#C[t]])}*keys(){for(const t of this.#$()){const e=this.#E[t];void 0===e||this.#j(this.#C[t])||(yield e)}}*rkeys(){for(const t of this.#W()){const e=this.#E[t];void 0===e||this.#j(this.#C[t])||(yield e)}}*values(){for(const t of this.#$()){void 0===this.#C[t]||this.#j(this.#C[t])||(yield this.#C[t])}}*rvalues(){for(const t of this.#W()){void 0===this.#C[t]||this.#j(this.#C[t])||(yield this.#C[t])}}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(t,e={}){for(const s of this.#$()){const i=this.#C[s],r=this.#j(i)?i.__staleWhileFetching:i;if(void 0!==r&&t(r,this.#E[s],this))return this.get(this.#E[s],e)}}forEach(t,e=this){for(const s of this.#$()){const i=this.#C[s],r=this.#j(i)?i.__staleWhileFetching:i;void 0!==r&&t.call(e,r,this.#E[s],this)}}rforEach(t,e=this){for(const s of this.#W()){const i=this.#C[s],r=this.#j(i)?i.__staleWhileFetching:i;void 0!==r&&t.call(e,r,this.#E[s],this)}}purgeStale(){let t=!1;for(const e of this.#W({allowStale:!0}))this.#U(e)&&(this.delete(this.#E[e]),t=!0);return t}info(t){const e=this.#k.get(t);if(void 0===e)return;const s=this.#C[e],i=this.#j(s)?s.__staleWhileFetching:s;if(void 0===i)return;const r={value:i};if(this.#N&&this.#D){const t=this.#N[e],s=this.#D[e];if(t&&s){const e=t-(qt.now()-s);r.ttl=e,r.start=Date.now()}}return this.#M&&(r.size=this.#M[e]),r}dump(){const t=[];for(const e of this.#$({allowStale:!0})){const s=this.#E[e],i=this.#C[e],r=this.#j(i)?i.__staleWhileFetching:i;if(void 0===r||void 0===s)continue;const n={value:r};if(this.#N&&this.#D){n.ttl=this.#N[e];const t=qt.now()-this.#D[e];n.start=Math.floor(Date.now()-t)}this.#M&&(n.size=this.#M[e]),t.unshift([s,n])}return t}load(t){this.clear();for(const[e,s]of t){if(s.start){const t=Date.now()-s.start;s.start=qt.now()-t}this.set(e,s.value,s)}}set(t,e,s={}){if(void 0===e)return this.delete(t),this;const{ttl:i=this.ttl,start:r,noDisposeOnSet:n=this.noDisposeOnSet,sizeCalculation:o=this.sizeCalculation,status:a}=s;let{noUpdateTTL:h=this.noUpdateTTL}=s;const l=this.#V(t,e,s.size||0,o);if(this.maxEntrySize&&l>this.maxEntrySize)return a&&(a.set="miss",a.maxEntrySizeExceeded=!0),this.delete(t),this;let c=0===this.#S?void 0:this.#k.get(t);if(void 0===c)c=0===this.#S?this.#T:0!==this.#L.length?this.#L.pop():this.#S===this.#m?this.#Q(!1):this.#S,this.#E[c]=t,this.#C[c]=e,this.#k.set(t,c),this.#A[this.#T]=c,this.#_[c]=this.#T,this.#T=c,this.#S++,this.#Z(c,l,a),a&&(a.set="add"),h=!1;else{this.#B(c);const s=this.#C[c];if(e!==s){if(this.#R&&this.#j(s)){s.__abortController.abort(new Error("replaced"));const{__staleWhileFetching:e}=s;void 0===e||n||(this.#z&&this.#y?.(e,t,"set"),this.#P&&this.#O?.push([e,t,"set"]))}else n||(this.#z&&this.#y?.(s,t,"set"),this.#P&&this.#O?.push([s,t,"set"]));if(this.#K(c),this.#Z(c,l,a),this.#C[c]=e,a){a.set="replace";const t=s&&this.#j(s)?s.__staleWhileFetching:s;void 0!==t&&(a.oldValue=t)}}else a&&(a.set="update")}if(0===i||this.#N||this.#H(),this.#N&&(h||this.#q(c,i,r),a&&this.#J(a,c)),!n&&this.#P&&this.#O){const t=this.#O;let e;for(;e=t?.shift();)this.#b?.(...e)}return this}pop(){try{for(;this.#S;){const t=this.#C[this.#F];if(this.#Q(!0),this.#j(t)){if(t.__staleWhileFetching)return t.__staleWhileFetching}else if(void 0!==t)return t}}finally{if(this.#P&&this.#O){const t=this.#O;let e;for(;e=t?.shift();)this.#b?.(...e)}}}#Q(t){const e=this.#F,s=this.#E[e],i=this.#C[e];return this.#R&&this.#j(i)?i.__abortController.abort(new Error("evicted")):(this.#z||this.#P)&&(this.#z&&this.#y?.(i,s,"evict"),this.#P&&this.#O?.push([i,s,"evict"])),this.#K(e),t&&(this.#E[e]=void 0,this.#C[e]=void 0,this.#L.push(e)),1===this.#S?(this.#F=this.#T=0,this.#L.length=0):this.#F=this.#A[e],this.#k.delete(s),this.#S--,e}has(t,e={}){const{updateAgeOnHas:s=this.updateAgeOnHas,status:i}=e,r=this.#k.get(t);if(void 0!==r){const t=this.#C[r];if(this.#j(t)&&void 0===t.__staleWhileFetching)return!1;if(!this.#U(r))return s&&this.#Y(r),i&&(i.has="hit",this.#J(i,r)),!0;i&&(i.has="stale",this.#J(i,r))}else i&&(i.has="miss");return!1}peek(t,e={}){const{allowStale:s=this.allowStale}=e,i=this.#k.get(t);if(void 0===i||!s&&this.#U(i))return;const r=this.#C[i];return this.#j(r)?r.__staleWhileFetching:r}#I(t,e,s,i){const r=void 0===e?void 0:this.#C[e];if(this.#j(r))return r;const n=new Vt,{signal:o}=s;o?.addEventListener("abort",(()=>n.abort(o.reason)),{signal:n.signal});const a={signal:n.signal,options:s,context:i},h=(i,r=!1)=>{const{aborted:o}=n.signal,h=s.ignoreFetchAbort&&void 0!==i;if(s.status&&(o&&!r?(s.status.fetchAborted=!0,s.status.fetchError=n.signal.reason,h&&(s.status.fetchAbortIgnored=!0)):s.status.fetchResolved=!0),o&&!h&&!r)return l(n.signal.reason);const p=c;return this.#C[e]===c&&(void 0===i?p.__staleWhileFetching?this.#C[e]=p.__staleWhileFetching:this.delete(t):(s.status&&(s.status.fetchUpdated=!0),this.set(t,i,a.options))),i},l=i=>{const{aborted:r}=n.signal,o=r&&s.allowStaleOnFetchAbort,a=o||s.allowStaleOnFetchRejection,h=a||s.noDeleteOnFetchRejection,l=c;if(this.#C[e]===c){!h||void 0===l.__staleWhileFetching?this.delete(t):o||(this.#C[e]=l.__staleWhileFetching)}if(a)return s.status&&void 0!==l.__staleWhileFetching&&(s.status.returnedStale=!0),l.__staleWhileFetching;if(l.__returned===l)throw i};s.status&&(s.status.fetchDispatched=!0);const c=new Promise(((e,i)=>{const o=this.#v?.(t,r,a);o&&o instanceof Promise&&o.then((t=>e(void 0===t?void 0:t)),i),n.signal.addEventListener("abort",(()=>{s.ignoreFetchAbort&&!s.allowStaleOnFetchAbort||(e(void 0),s.allowStaleOnFetchAbort&&(e=t=>h(t,!0)))}))})).then(h,(t=>(s.status&&(s.status.fetchRejected=!0,s.status.fetchError=t),l(t)))),p=Object.assign(c,{__abortController:n,__staleWhileFetching:r,__returned:void 0});return void 0===e?(this.set(t,p,{...a.options,status:void 0}),e=this.#k.get(t)):this.#C[e]=p,p}#j(t){if(!this.#R)return!1;const e=t;return!!e&&e instanceof Promise&&e.hasOwnProperty("__staleWhileFetching")&&e.__abortController instanceof Vt}async fetch(t,e={}){const{allowStale:s=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:r=this.noDeleteOnStaleGet,ttl:n=this.ttl,noDisposeOnSet:o=this.noDisposeOnSet,size:a=0,sizeCalculation:h=this.sizeCalculation,noUpdateTTL:l=this.noUpdateTTL,noDeleteOnFetchRejection:c=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:p=this.allowStaleOnFetchRejection,ignoreFetchAbort:d=this.ignoreFetchAbort,allowStaleOnFetchAbort:u=this.allowStaleOnFetchAbort,context:f,forceRefresh:g=!1,status:m,signal:w}=e;if(!this.#R)return m&&(m.fetch="get"),this.get(t,{allowStale:s,updateAgeOnGet:i,noDeleteOnStaleGet:r,status:m});const y={allowStale:s,updateAgeOnGet:i,noDeleteOnStaleGet:r,ttl:n,noDisposeOnSet:o,size:a,sizeCalculation:h,noUpdateTTL:l,noDeleteOnFetchRejection:c,allowStaleOnFetchRejection:p,allowStaleOnFetchAbort:u,ignoreFetchAbort:d,status:m,signal:w};let b=this.#k.get(t);if(void 0===b){m&&(m.fetch="miss");const e=this.#I(t,b,y,f);return e.__returned=e}{const e=this.#C[b];if(this.#j(e)){const t=s&&void 0!==e.__staleWhileFetching;return m&&(m.fetch="inflight",t&&(m.returnedStale=!0)),t?e.__staleWhileFetching:e.__returned=e}const r=this.#U(b);if(!g&&!r)return m&&(m.fetch="hit"),this.#B(b),i&&this.#Y(b),m&&this.#J(m,b),e;const n=this.#I(t,b,y,f),o=void 0!==n.__staleWhileFetching&&s;return m&&(m.fetch=r?"stale":"refresh",o&&r&&(m.returnedStale=!0)),o?n.__staleWhileFetching:n.__returned=n}}get(t,e={}){const{allowStale:s=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:r=this.noDeleteOnStaleGet,status:n}=e,o=this.#k.get(t);if(void 0!==o){const e=this.#C[o],a=this.#j(e);return n&&this.#J(n,o),this.#U(o)?(n&&(n.get="stale"),a?(n&&s&&void 0!==e.__staleWhileFetching&&(n.returnedStale=!0),s?e.__staleWhileFetching:void 0):(r||this.delete(t),n&&s&&(n.returnedStale=!0),s?e:void 0)):(n&&(n.get="hit"),a?e.__staleWhileFetching:(this.#B(o),i&&this.#Y(o),e))}n&&(n.get="miss")}#tt(t,e){this.#_[e]=t,this.#A[t]=e}#B(t){t!==this.#T&&(t===this.#F?this.#F=this.#A[t]:this.#tt(this.#_[t],this.#A[t]),this.#tt(this.#T,t),this.#T=t)}delete(t){let e=!1;if(0!==this.#S){const s=this.#k.get(t);if(void 0!==s)if(e=!0,1===this.#S)this.clear();else{this.#K(s);const e=this.#C[s];if(this.#j(e)?e.__abortController.abort(new Error("deleted")):(this.#z||this.#P)&&(this.#z&&this.#y?.(e,t,"delete"),this.#P&&this.#O?.push([e,t,"delete"])),this.#k.delete(t),this.#E[s]=void 0,this.#C[s]=void 0,s===this.#T)this.#T=this.#_[s];else if(s===this.#F)this.#F=this.#A[s];else{const t=this.#_[s];this.#A[t]=this.#A[s];const e=this.#A[s];this.#_[e]=this.#_[s]}this.#S--,this.#L.push(s)}}if(this.#P&&this.#O?.length){const t=this.#O;let e;for(;e=t?.shift();)this.#b?.(...e)}return e}clear(){for(const t of this.#W({allowStale:!0})){const e=this.#C[t];if(this.#j(e))e.__abortController.abort(new Error("deleted"));else{const s=this.#E[t];this.#z&&this.#y?.(e,s,"delete"),this.#P&&this.#O?.push([e,s,"delete"])}}if(this.#k.clear(),this.#C.fill(void 0),this.#E.fill(void 0),this.#N&&this.#D&&(this.#N.fill(0),this.#D.fill(0)),this.#M&&this.#M.fill(0),this.#F=0,this.#T=0,this.#L.length=0,this.#x=0,this.#S=0,this.#P&&this.#O){const t=this.#O;let e;for(;e=t?.shift();)this.#b?.(...e)}}}const ie="object"==typeof process&&process?process:{stdout:null,stderr:null},re=t=>!!t&&"object"==typeof t&&(t instanceof We||t instanceof A||ne(t)||oe(t)),ne=t=>!!t&&"object"==typeof t&&t instanceof C&&"function"==typeof t.pipe&&t.pipe!==A.Writable.prototype.pipe,oe=t=>!!t&&"object"==typeof t&&t instanceof C&&"function"==typeof t.write&&"function"==typeof t.end,ae=Symbol("EOF"),he=Symbol("maybeEmitEnd"),le=Symbol("emittedEnd"),ce=Symbol("emittingEnd"),pe=Symbol("emittedError"),de=Symbol("closed"),ue=Symbol("read"),fe=Symbol("flush"),ge=Symbol("flushChunk"),me=Symbol("encoding"),we=Symbol("decoder"),ye=Symbol("flowing"),be=Symbol("paused"),ve=Symbol("resume"),Se=Symbol("buffer"),xe=Symbol("pipes"),ke=Symbol("bufferLength"),Ee=Symbol("bufferPush"),Ce=Symbol("bufferShift"),Ae=Symbol("objectMode"),_e=Symbol("destroyed"),Fe=Symbol("error"),Te=Symbol("emitData"),Le=Symbol("emitEnd"),Oe=Symbol("emitEnd2"),Me=Symbol("async"),De=Symbol("abort"),Ne=Symbol("aborted"),ze=Symbol("signal"),Re=Symbol("dataListeners"),Pe=Symbol("discarded"),je=t=>Promise.resolve().then(t),Ie=t=>t();class Be{src;dest;opts;ondrain;constructor(t,e,s){this.src=t,this.dest=e,this.opts=s,this.ondrain=()=>t[ve](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(t){}end(){this.unpipe(),this.opts.end&&this.dest.end()}}class $e extends Be{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(t,e,s){super(t,e,s),this.proxyErrors=t=>e.emit("error",t),t.on("error",this.proxyErrors)}}class We extends C{[ye]=!1;[be]=!1;[xe]=[];[Se]=[];[Ae];[me];[Me];[we];[ae]=!1;[le]=!1;[ce]=!1;[de]=!1;[pe]=null;[ke]=0;[_e]=!1;[ze];[Ne]=!1;[Re]=0;[Pe]=!1;writable=!0;readable=!0;constructor(...t){const e=t[0]||{};if(super(),e.objectMode&&"string"==typeof e.encoding)throw new TypeError("Encoding and objectMode may not be used together");e.objectMode?(this[Ae]=!0,this[me]=null):(t=>!t.objectMode&&!!t.encoding&&"buffer"!==t.encoding)(e)?(this[me]=e.encoding,this[Ae]=!1):(this[Ae]=!1,this[me]=null),this[Me]=!!e.async,this[we]=this[me]?new _(this[me]):null,e&&!0===e.debugExposeBuffer&&Object.defineProperty(this,"buffer",{get:()=>this[Se]}),e&&!0===e.debugExposePipes&&Object.defineProperty(this,"pipes",{get:()=>this[xe]});const{signal:s}=e;s&&(this[ze]=s,s.aborted?this[De]():s.addEventListener("abort",(()=>this[De]())))}get bufferLength(){return this[ke]}get encoding(){return this[me]}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[Ae]}set objectMode(t){throw new Error("objectMode must be set at instantiation time")}get async(){return this[Me]}set async(t){this[Me]=this[Me]||!!t}[De](){this[Ne]=!0,this.emit("abort",this[ze]?.reason),this.destroy(this[ze]?.reason)}get aborted(){return this[Ne]}set aborted(t){}write(t,e,s){if(this[Ne])return!1;if(this[ae])throw new Error("write after end");if(this[_e])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;"function"==typeof e&&(s=e,e="utf8"),e||(e="utf8");const i=this[Me]?je:Ie;if(!this[Ae]&&!Buffer.isBuffer(t))if(r=t,!Buffer.isBuffer(r)&&ArrayBuffer.isView(r))t=Buffer.from(t.buffer,t.byteOffset,t.byteLength);else if((t=>t instanceof ArrayBuffer||!!t&&"object"==typeof t&&t.constructor&&"ArrayBuffer"===t.constructor.name&&t.byteLength>=0)(t))t=Buffer.from(t);else if("string"!=typeof t)throw new Error("Non-contiguous data written to non-objectMode stream");var r;return this[Ae]?(this[ye]&&0!==this[ke]&&this[fe](!0),this[ye]?this.emit("data",t):this[Ee](t),0!==this[ke]&&this.emit("readable"),s&&i(s),this[ye]):t.length?("string"!=typeof t||e===this[me]&&!this[we]?.lastNeed||(t=Buffer.from(t,e)),Buffer.isBuffer(t)&&this[me]&&(t=this[we].write(t)),this[ye]&&0!==this[ke]&&this[fe](!0),this[ye]?this.emit("data",t):this[Ee](t),0!==this[ke]&&this.emit("readable"),s&&i(s),this[ye]):(0!==this[ke]&&this.emit("readable"),s&&i(s),this[ye])}read(t){if(this[_e])return null;if(this[Pe]=!1,0===this[ke]||0===t||t&&t>this[ke])return this[he](),null;this[Ae]&&(t=null),this[Se].length>1&&!this[Ae]&&(this[Se]=[this[me]?this[Se].join(""):Buffer.concat(this[Se],this[ke])]);const e=this[ue](t||null,this[Se][0]);return this[he](),e}[ue](t,e){if(this[Ae])this[Ce]();else{const s=e;t===s.length||null===t?this[Ce]():"string"==typeof s?(this[Se][0]=s.slice(t),e=s.slice(0,t),this[ke]-=t):(this[Se][0]=s.subarray(t),e=s.subarray(0,t),this[ke]-=t)}return this.emit("data",e),this[Se].length||this[ae]||this.emit("drain"),e}end(t,e,s){return"function"==typeof t&&(s=t,t=void 0),"function"==typeof e&&(s=e,e="utf8"),void 0!==t&&this.write(t,e),s&&this.once("end",s),this[ae]=!0,this.writable=!1,!this[ye]&&this[be]||this[he](),this}[ve](){this[_e]||(this[Re]||this[xe].length||(this[Pe]=!0),this[be]=!1,this[ye]=!0,this.emit("resume"),this[Se].length?this[fe]():this[ae]?this[he]():this.emit("drain"))}resume(){return this[ve]()}pause(){this[ye]=!1,this[be]=!0,this[Pe]=!1}get destroyed(){return this[_e]}get flowing(){return this[ye]}get paused(){return this[be]}[Ee](t){this[Ae]?this[ke]+=1:this[ke]+=t.length,this[Se].push(t)}[Ce](){return this[Ae]?this[ke]-=1:this[ke]-=this[Se][0].length,this[Se].shift()}[fe](t=!1){do{}while(this[ge](this[Ce]())&&this[Se].length);t||this[Se].length||this[ae]||this.emit("drain")}[ge](t){return this.emit("data",t),this[ye]}pipe(t,e){if(this[_e])return t;this[Pe]=!1;const s=this[le];return e=e||{},t===ie.stdout||t===ie.stderr?e.end=!1:e.end=!1!==e.end,e.proxyErrors=!!e.proxyErrors,s?e.end&&t.end():(this[xe].push(e.proxyErrors?new $e(this,t,e):new Be(this,t,e)),this[Me]?je((()=>this[ve]())):this[ve]()),t}unpipe(t){const e=this[xe].find((e=>e.dest===t));e&&(1===this[xe].length?(this[ye]&&0===this[Re]&&(this[ye]=!1),this[xe]=[]):this[xe].splice(this[xe].indexOf(e),1),e.unpipe())}addListener(t,e){return this.on(t,e)}on(t,e){const s=super.on(t,e);if("data"===t)this[Pe]=!1,this[Re]++,this[xe].length||this[ye]||this[ve]();else if("readable"===t&&0!==this[ke])super.emit("readable");else if((t=>"end"===t||"finish"===t||"prefinish"===t)(t)&&this[le])super.emit(t),this.removeAllListeners(t);else if("error"===t&&this[pe]){const t=e;this[Me]?je((()=>t.call(this,this[pe]))):t.call(this,this[pe])}return s}removeListener(t,e){return this.off(t,e)}off(t,e){const s=super.off(t,e);return"data"===t&&(this[Re]=this.listeners("data").length,0!==this[Re]||this[Pe]||this[xe].length||(this[ye]=!1)),s}removeAllListeners(t){const e=super.removeAllListeners(t);return"data"!==t&&void 0!==t||(this[Re]=0,this[Pe]||this[xe].length||(this[ye]=!1)),e}get emittedEnd(){return this[le]}[he](){this[ce]||this[le]||this[_e]||0!==this[Se].length||!this[ae]||(this[ce]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[de]&&this.emit("close"),this[ce]=!1)}emit(t,...e){const s=e[0];if("error"!==t&&"close"!==t&&t!==_e&&this[_e])return!1;if("data"===t)return!(!this[Ae]&&!s)&&(this[Me]?(je((()=>this[Te](s))),!0):this[Te](s));if("end"===t)return this[Le]();if("close"===t){if(this[de]=!0,!this[le]&&!this[_e])return!1;const t=super.emit("close");return this.removeAllListeners("close"),t}if("error"===t){this[pe]=s,super.emit(Fe,s);const t=!(this[ze]&&!this.listeners("error").length)&&super.emit("error",s);return this[he](),t}if("resume"===t){const t=super.emit("resume");return this[he](),t}if("finish"===t||"prefinish"===t){const e=super.emit(t);return this.removeAllListeners(t),e}const i=super.emit(t,...e);return this[he](),i}[Te](t){for(const e of this[xe])!1===e.dest.write(t)&&this.pause();const e=!this[Pe]&&super.emit("data",t);return this[he](),e}[Le](){return!this[le]&&(this[le]=!0,this.readable=!1,this[Me]?(je((()=>this[Oe]())),!0):this[Oe]())}[Oe](){if(this[we]){const t=this[we].end();if(t){for(const e of this[xe])e.dest.write(t);this[Pe]||super.emit("data",t)}}for(const t of this[xe])t.end();const t=super.emit("end");return this.removeAllListeners("end"),t}async collect(){const t=Object.assign([],{dataLength:0});this[Ae]||(t.dataLength=0);const e=this.promise();return this.on("data",(e=>{t.push(e),this[Ae]||(t.dataLength+=e.length)})),await e,t}async concat(){if(this[Ae])throw new Error("cannot concat in objectMode");const t=await this.collect();return this[me]?t.join(""):Buffer.concat(t,t.dataLength)}async promise(){return new Promise(((t,e)=>{this.on(_e,(()=>e(new Error("stream destroyed")))),this.on("error",(t=>e(t))),this.on("end",(()=>t()))}))}[Symbol.asyncIterator](){this[Pe]=!1;let t=!1;const e=async()=>(this.pause(),t=!0,{value:void 0,done:!0});return{next:()=>{if(t)return e();const s=this.read();if(null!==s)return Promise.resolve({done:!1,value:s});if(this[ae])return e();let i,r;const n=t=>{this.off("data",o),this.off("end",a),this.off(_e,h),e(),r(t)},o=t=>{this.off("error",n),this.off("end",a),this.off(_e,h),this.pause(),i({value:t,done:!!this[ae]})},a=()=>{this.off("error",n),this.off("data",o),this.off(_e,h),e(),i({done:!0,value:void 0})},h=()=>n(new Error("stream destroyed"));return new Promise(((t,e)=>{r=e,i=t,this.once(_e,h),this.once("error",n),this.once("end",a),this.once("data",o)}))},throw:e,return:e,[Symbol.asyncIterator](){return this}}}[Symbol.iterator](){this[Pe]=!1;let t=!1;const e=()=>(this.pause(),this.off(Fe,e),this.off(_e,e),this.off("end",e),t=!0,{done:!0,value:void 0});return this.once("end",e),this.once(Fe,e),this.once(_e,e),{next:()=>{if(t)return e();const s=this.read();return null===s?e():{done:!1,value:s}},throw:e,return:e,[Symbol.iterator](){return this}}}destroy(t){if(this[_e])return t?this.emit("error",t):this.emit(_e),this;this[_e]=!0,this[Pe]=!0,this[Se].length=0,this[ke]=0;return"function"!=typeof this.close||this[de]||this.close(),t?this.emit("error",t):this.emit(_e),this}static get isStream(){return re}}const Ue={lstatSync:m,readdir:w,readdirSync:y,readlinkSync:b,realpathSync:g.native,promises:{lstat:S,readdir:x,readlink:k,realpath:E}},Ge=t=>t&&t!==Ue&&t!==v?{...Ue,...t,promises:{...Ue.promises,...t.promises||{}}}:Ue,He=/^\\\\\?\\([a-z]:)\\?$/i,qe=/[\\\/]/,Ye=10,Je=15,Ke=-16,Ve=128,Ze=256,Qe=512,Xe=t=>t.isFile()?8:t.isDirectory()?4:t.isSymbolicLink()?Ye:t.isCharacterDevice()?2:t.isBlockDevice()?6:t.isSocket()?12:t.isFIFO()?1:0,ts=new Map,es=t=>{const e=ts.get(t);if(e)return e;const s=t.normalize("NFKD");return ts.set(t,s),s},ss=new Map,is=t=>{const e=ss.get(t);if(e)return e;const s=es(t.toLowerCase());return ss.set(t,s),s};class rs extends se{constructor(){super({max:256})}}class ns extends se{constructor(t=16384){supe