UNPKG

bit-ship

Version:

Bit-Ship CLI is tool that analyses your code and generates a custom environment for your needs You can use if to local development, CI/CD or even production.

1 lines 126 kB
import t,{createServer as e}from"node:http";import i from"node:https";import{EventEmitter as s}from"node:events";import{fileURLToPath as n}from"node:url";import{win32 as r,posix as o}from"node:path";import{realpathSync as a,readlinkSync as h,readdirSync as l,readdir as c,lstatSync as p}from"fs";import*as u from"node:fs";import{realpath as d,readlink as f,readdir as g,lstat as m}from"node:fs/promises";import w from"node:stream";import{StringDecoder as y}from"node:string_decoder";import{readFile as b}from"fs/promises";var v=function(){return v=Object.assign||function(t){for(var e,i=1,s=arguments.length;i<s;i++)for(var n in e=arguments[i])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t},v.apply(this,arguments)};function S(t,e,i,s){return new(i||(i=Promise))((function(n,r){function o(t){try{h(s.next(t))}catch(t){r(t)}}function a(t){try{h(s.throw(t))}catch(t){r(t)}}function h(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,a)}h((s=s.apply(t,e||[])).next())}))}function k(t,e){var i,s,n,r={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return o.next=a(0),o.throw=a(1),o.return=a(2),"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(h){return function(a){if(i)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(r=0)),r;)try{if(i=1,s&&(n=2&a[0]?s.return:a[0]?s.throw||((n=s.return)&&n.call(s),0):s.next)&&!(n=n.call(s,a[1])).done)return n;switch(s=0,n&&(a=[2&a[0],n.value]),a[0]){case 0:case 1:n=a;break;case 4:return r.label++,{value:a[1],done:!1};case 5:r.label++,s=a[1],a=[0];continue;case 7:a=r.ops.pop(),r.trys.pop();continue;default:if(!(n=r.trys,(n=n.length>0&&n[n.length-1])||6!==a[0]&&2!==a[0])){r=0;continue}if(3===a[0]&&(!n||a[1]>n[0]&&a[1]<n[3])){r.label=a[1];break}if(6===a[0]&&r.label<n[1]){r.label=n[1],n=a;break}if(n&&r.label<n[2]){r.label=n[2],r.ops.push(a);break}n[2]&&r.ops.pop(),r.trys.pop();continue}a=e.call(t,r)}catch(t){a=[6,t],s=0}finally{i=n=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,h])}}}"function"==typeof SuppressedError&&SuppressedError;const x=/(^|,)\s*upgrade\s*($|,)/i,A=/^https|wss/;function C(t,e,i,s){t.port=e[s||"target"].port||(A.test(e[s||"target"].protocol)?443:80);for(const i of["host","hostname","socketPath","pfx","key","passphrase","cert","ca","ciphers","secureProtocol"])t[i]=e[s||"target"][i];t.method=e.method||i.method,t.headers={...i.headers},e.headers&&(t.headers={...t.headers,...e.headers}),e.auth&&(t.auth=e.auth),e.ca&&(t.ca=e.ca),A.test(e[s||"target"].protocol)&&(t.rejectUnauthorized=void 0===e.secure||e.secure),t.agent=e.agent||!1,t.localAddress=e.localAddress,t.agent||(t.headers=t.headers||{},"string"==typeof t.headers.connection&&x.test(t.headers.connection)||(t.headers.connection="close"));const n=e[s||"target"],r=n&&!1!==e.prependPath&&(n.pathname||n.path)||"",o=new URL(i.url,"http://localhost");let a=e.toProxy?i.url:o.pathname+o.search||"";return a=e.ignorePath?"":a,t.path=function(t,e){if(!t||"/"===t)return e||"/";if(!e||"/"===e)return t||"/";const i="/"===t[t.length-1],s="/"===e[0];if(i&&s)return t+e.slice(1);if(!i&&!s)return t+"/"+e;return t+e}(r,a),e.changeOrigin&&(t.headers.host=function(t,e){const i=e.split(":")[0],s=+t;if(!s)return!1;switch(i){case"http":case"ws":return 80!==s;case"https":case"wss":return 443!==s;case"ftp":return 21!==s;case"gopher":return 70!==s;case"file":return!1}return 0!==s}(t.port,e[s||"target"].protocol)&&!~t.host.indexOf(":")?t.host+":"+t.port:t.host),t}function E(t){return t.setTimeout(0),t.setNoDelay(!0),t.setKeepAlive(!0,0),t}function T(t){const e=t.headers.host?t.headers.host.match(/:(\d+)/):"";return e?e[1]:L(t)?"443":"80"}function L(t){return Boolean(t.connection.encrypted||t.connection.pair)}function O(t,e,i){return Array.isArray(t)?t.map((function(t){return O(t,e,i)})):t.replace(new RegExp(String.raw`(;\s*`+i+"=)([^;]+)","i"),(function(t,i,s){let n;if(s in e)n=e[s];else{if(!("*"in e))return t;n=e["*"]}return n?i+n:""}))}const M=/^201|30([1278])$/,F=[(t,e,i)=>{"1.0"===t.httpVersion&&delete i.headers["transfer-encoding"]},(t,e,i)=>{"1.0"===t.httpVersion?i.headers.connection=t.headers.connection||"close":"2.0"===t.httpVersion||i.headers.connection||(i.headers.connection=t.headers.connection||"keep-alive")},(t,e,i,s)=>{if((s.hostRewrite||s.autoRewrite||s.protocolRewrite)&&i.headers.location&&M.test(String(i.statusCode))){const e=new URL(s.target),n=new URL(i.headers.location);if(e.host!==n.host)return;s.hostRewrite?n.host=s.hostRewrite:s.autoRewrite&&(n.host=t.headers.host),s.protocolRewrite&&(n.protocol=s.protocolRewrite),i.headers.location=n.toString()}},(t,e,i,s)=>{let n=s.cookieDomainRewrite,r=s.cookiePathRewrite;const o=s.preserveHeaderKeyCase;let a;const h=function(t,i){void 0!==i&&(n&&"set-cookie"===t.toLowerCase()&&(i=O(i,n,"domain")),r&&"set-cookie"===t.toLowerCase()&&(i=O(i,r,"path")),e.setHeader(String(t).trim(),i))};if("string"==typeof n&&(n={"*":n}),"string"==typeof r&&(r={"*":r}),o&&void 0!==i.rawHeaders){a={};for(let t=0;t<i.rawHeaders.length;t+=2){const e=i.rawHeaders[t];a[e.toLowerCase()]=e}}for(let t of Object.keys(i.headers)){const e=i.headers[t];o&&a&&(t=a[t]||t),h(t,e)}},(t,e,i)=>{i.statusMessage?(e.statusCode=i.statusCode,e.statusMessage=i.statusMessage):e.statusCode=i.statusCode}],R={http:t,https:i},N=(t,e,i,s,n,r)=>{s.emit("start",t,e,i.target||i.forward);const o=R.http,a=R.https;if(i.forward){const s=("https:"===i.forward.protocol?a:o).request(C(i.ssl||{},i,t,"forward")),n=c(s,i.forward);if(t.on("error",n),s.on("error",n),(i.buffer||t).pipe(s),!i.target)return void e.end()}const h=("https:"===i.target.protocol?a:o).request(C(i.ssl||{},i,t));h.on("socket",(n=>{s&&!h.getHeader("expect")&&s.emit("proxyReq",h,t,e,i)})),i.proxyTimeout&&h.setTimeout(i.proxyTimeout,(function(){h.abort()})),t.on("aborted",(function(){h.abort()}));const l=c(h,i.target);function c(i,n){return function(o){if(t.socket.destroyed&&"ECONNRESET"===o.code)return s.emit("econnreset",o,t,e,n),i.abort();r?r(o,t,e,n):s.emit("error",o,t,e,n)}}t.on("error",l),h.on("error",l),(i.buffer||t).pipe(h),h.on("response",(function(n){if(s&&s.emit("proxyRes",n,t,e),!e.headersSent&&!i.selfHandleResponse)for(const s of F)if(s(t,e,n,i))break;e.finished?s&&s.emit("end",t,e,n):(e.on("close",(function(){n.destroy()})),n.on("end",(function(){s&&s.emit("end",t,e,n)})),i.selfHandleResponse||n.pipe(e))}))},j=[t=>{"DELETE"!==t.method&&"OPTIONS"!==t.method||t.headers["content-length"]||(t.headers["content-length"]="0",delete t.headers["transfer-encoding"])},(t,e,i)=>{i.timeout&&t.socket.setTimeout(i.timeout)},(t,e,i)=>{if(!i.xfwd)return;const s=t.isSpdy||L(t),n={for:t.connection.remoteAddress||t.socket.remoteAddress,port:T(t),proto:s?"https":"http"};for(const e of["for","port","proto"])t.headers["x-forwarded-"+e]=(t.headers["x-forwarded-"+e]||"")+(t.headers["x-forwarded-"+e]?",":"")+n[e];t.headers["x-forwarded-host"]=t.headers["x-forwarded-host"]||t.headers.host||""},N],I=[(t,e)=>"GET"===t.method&&t.headers.upgrade?"websocket"!==t.headers.upgrade.toLowerCase()?(e.destroy(),!0):void 0:(e.destroy(),!0),(t,e,i)=>{if(!i.xfwd)return;const s={for:t.connection.remoteAddress||t.socket.remoteAddress,port:T(t),proto:L(t)?"wss":"ws"};for(const e of["for","port","proto"])t.headers["x-forwarded-"+e]=(t.headers["x-forwarded-"+e]||"")+(t.headers["x-forwarded-"+e]?",":"")+s[e]},(e,s,n,r,o,a)=>{const h=function(t,e){return Object.keys(e).reduce((function(t,i){const s=e[i];if(!Array.isArray(s))return t.push(i+": "+s),t;for(const e of s)t.push(i+": "+e);return t}),[t]).join("\r\n")+"\r\n\r\n"};E(s),o&&o.length>0&&s.unshift(o);const l=(A.test(n.target.protocol)?i:t).request(C(n.ssl||{},n,e));function c(t){a?a(t,e,s):r.emit("error",t,e,s),s.end()}r&&r.emit("proxyReqWs",l,e,s,n,o),l.on("error",c),l.on("response",(function(t){t.upgrade||(s.write(h("HTTP/"+t.httpVersion+" "+t.statusCode+" "+t.statusMessage,t.headers)),t.pipe(s))})),l.on("upgrade",(function(t,e,i){e.on("error",c),e.on("end",(function(){r.emit("close",t,e,i)})),s.on("error",(function(){e.end()})),E(e),i&&i.length>0&&e.unshift(i),s.write(h("HTTP/1.1 101 Switching Protocols",t.headers)),e.pipe(s).pipe(e),r.emit("open",e),r.emit("proxySocket",e)})),l.end()}];class z extends s{_server;_webPasses=[...j];_wsPasses=[...I];options;web;ws;constructor(t={}){super(),this.options=t||{},this.options.prependPath=!1!==t.prependPath,this.web=P("web",this),this.ws=P("ws",this)}listen(e,s){const n=(t,e)=>{this.web(t,e)};return this._server=this.options.ssl?i.createServer(this.options.ssl,n):t.createServer(n),this.options.ws&&this._server.on("upgrade",((t,e,i)=>{this._ws(t,e,i)})),this._server.listen(e,s),this}close(t){this._server&&this._server.close(((...e)=>{this._server=void 0,t&&Reflect.apply(t,void 0,e)}))}before(t,e,i){if("ws"!==t&&"web"!==t)throw new Error("type must be `web` or `ws`");const s="ws"===t?this._wsPasses:this._webPasses;let n=!1;for(const[t,i]of s.entries())i.name===e&&(n=t);if(!1===n)throw new Error("No such pass");s.splice(n,0,i)}after(t,e,i){if("ws"!==t&&"web"!==t)throw new Error("type must be `web` or `ws`");const s="ws"===t?this._wsPasses:this._webPasses;let n=!1;for(const[t,i]of s.entries())i.name===e&&(n=t);if(!1===n)throw new Error("No such pass");s.splice(n++,0,i)}}function P(t,e){return function(i,s,n,r){const o={...n,...e.options};for(const t of["target","forward"])"string"==typeof o[t]&&(o[t]=new URL(o[t]));if(!o.target&&!o.forward)return this.emit("error",new Error("Must provide a proper URL as target"));let a,h;const l=new Promise(((t,e)=>{a=t,h=e}));s.on("close",(()=>{a()})),s.on("error",(t=>{h(t)}));for(const n of"ws"===t?e._wsPasses:e._webPasses){if(n(i,s,o,e,r,(t=>{h(t)}))){a();break}}return l}}var _,D,B,W,U=function(t){return Object.entries(t).map((function(t){var e=t[0],i=t[1];return'<div class="project">\n <h2>'.concat(e,"</h2>\n ").concat(i.expose.map((function(t){return'\n <a href="http://'.concat(t.localHost,'">').concat(t.localHost,"</a>\n <p>port: ").concat(t.port,"</p>\n <p>access: ").concat(t.access,"</p>\n ")})),"\n </div>")}))||""};function $(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var G=function(){if(W)return B;W=1;var t=function(){if(D)return _;function t(t,s,n){t instanceof RegExp&&(t=e(t,n)),s instanceof RegExp&&(s=e(s,n));var r=i(t,s,n);return r&&{start:r[0],end:r[1],pre:n.slice(0,r[0]),body:n.slice(r[0]+t.length,r[1]),post:n.slice(r[1]+s.length)}}function e(t,e){var i=e.match(t);return i?i[0]:null}function i(t,e,i){var s,n,r,o,a,h=i.indexOf(t),l=i.indexOf(e,h+1),c=h;if(h>=0&&l>0){if(t===e)return[h,l];for(s=[],r=i.length;c>=0&&!a;)c==h?(s.push(c),h=i.indexOf(t,c+1)):1==s.length?a=[s.pop(),l]:((n=s.pop())<r&&(r=n,o=l),l=i.indexOf(e,c+1)),c=h<l&&h>=0?h:l;s.length&&(a=[r,o])}return a}return D=1,_=t,t.range=i,_}();B=function(t){if(!t)return[];"{}"===t.substr(0,2)&&(t="\\{\\}"+t.substr(2));return d(function(t){return t.split("\\\\").join(e).split("\\{").join(i).split("\\}").join(s).split("\\,").join(n).split("\\.").join(r)}(t),!0).map(a)};var e="\0SLASH"+Math.random()+"\0",i="\0OPEN"+Math.random()+"\0",s="\0CLOSE"+Math.random()+"\0",n="\0COMMA"+Math.random()+"\0",r="\0PERIOD"+Math.random()+"\0";function o(t){return parseInt(t,10)==t?parseInt(t,10):t.charCodeAt(0)}function a(t){return t.split(e).join("\\").split(i).join("{").split(s).join("}").split(n).join(",").split(r).join(".")}function h(e){if(!e)return[""];var i=[],s=t("{","}",e);if(!s)return e.split(",");var n=s.pre,r=s.body,o=s.post,a=n.split(",");a[a.length-1]+="{"+r+"}";var l=h(o);return o.length&&(a[a.length-1]+=l.shift(),a.push.apply(a,l)),i.push.apply(i,a),i}function l(t){return"{"+t+"}"}function c(t){return/^-?0\d/.test(t)}function p(t,e){return t<=e}function u(t,e){return t>=e}function d(e,i){var n=[],r=t("{","}",e);if(!r)return[e];var a=r.pre,f=r.post.length?d(r.post,!1):[""];if(/\$$/.test(r.pre))for(var g=0;g<f.length;g++){var m=a+"{"+r.body+"}"+f[g];n.push(m)}else{var w,y,b=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(r.body),v=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(r.body),S=b||v,k=r.body.indexOf(",")>=0;if(!S&&!k)return r.post.match(/,.*\}/)?d(e=r.pre+"{"+r.body+s+r.post):[e];if(S)w=r.body.split(/\.\./);else if(1===(w=h(r.body)).length&&1===(w=d(w[0],!1).map(l)).length)return f.map((function(t){return r.pre+w[0]+t}));if(S){var x=o(w[0]),A=o(w[1]),C=Math.max(w[0].length,w[1].length),E=3==w.length?Math.abs(o(w[2])):1,T=p;A<x&&(E*=-1,T=u);var L=w.some(c);y=[];for(var O=x;T(O,A);O+=E){var M;if(v)"\\"===(M=String.fromCharCode(O))&&(M="");else if(M=String(O),L){var F=C-M.length;if(F>0){var R=new Array(F+1).join("0");M=O<0?"-"+R+M.slice(1):R+M}}y.push(M)}}else{y=[];for(var N=0;N<w.length;N++)y.push.apply(y,d(w[N],!1))}for(N=0;N<y.length;N++)for(g=0;g<f.length;g++){m=a+y[N]+f[g];(!i||S||m)&&n.push(m)}}return n}return B}(),H=$(G);const q=t=>{if("string"!=typeof t)throw new TypeError("invalid pattern");if(t.length>65536)throw new TypeError("pattern is too long")},Y={"[: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]},V=t=>t.replace(/[[\]\\-]/g,"\\$&"),Z=t=>t.join(""),K=(t,e)=>{const i=e;if("["!==t.charAt(i))throw new Error("not in a brace expression");const s=[],n=[];let r=i+1,o=!1,a=!1,h=!1,l=!1,c=i,p="";t:for(;r<t.length;){const e=t.charAt(r);if("!"!==e&&"^"!==e||r!==i+1){if("]"===e&&o&&!h){c=r+1;break}if(o=!0,"\\"!==e||h){if("["===e&&!h)for(const[e,[o,h,l]]of Object.entries(Y))if(t.startsWith(e,r)){if(p)return["$.",!1,t.length-i,!0];r+=e.length,l?n.push(o):s.push(o),a=a||h;continue t}h=!1,p?(e>p?s.push(V(p)+"-"+V(e)):e===p&&s.push(V(e)),p="",r++):t.startsWith("-]",r+1)?(s.push(V(e+"-")),r+=2):t.startsWith("-",r+1)?(p=e,r+=2):(s.push(V(e)),r++)}else h=!0,r++}else l=!0,r++}if(c<r)return["",!1,0,!1];if(!s.length&&!n.length)return["$.",!1,t.length-i,!0];if(0===n.length&&1===s.length&&/^\\?.$/.test(s[0])&&!l){const t=2===s[0].length?s[0].slice(-1):s[0];return[(u=t,u.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")),!1,c-i,!1]}var u;const d="["+(l?"^":"")+Z(s)+"]",f="["+(l?"":"^")+Z(n)+"]";return[s.length&&n.length?"("+d+"|"+f+")":s.length?d:f,a,c-i,!0]},J=(t,{windowsPathsNoEscape:e=!1}={})=>e?t.replace(/\[([^\/\\])\]/g,"$1"):t.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1"),X=new Set(["!","?","+","*","@"]),Q=t=>X.has(t),tt="(?!\\.)",et=new Set(["[","."]),it=new Set(["..","."]),st=new Set("().*{}+?[]^$\\!"),nt="[^/]",rt=nt+"*?",ot=nt+"+?";class at{type;#t;#e;#i=!1;#s=[];#n;#r;#o;#a=!1;#h;#l;#c=!1;constructor(t,e,i={}){this.type=t,t&&(this.#e=!0),this.#n=e,this.#t=this.#n?this.#n.#t:this,this.#h=this.#t===this?i:this.#t.#h,this.#o=this.#t===this?[]:this.#t.#o,"!"!==t||this.#t.#a||this.#o.push(this),this.#r=this.#n?this.#n.#s.length:0}get hasMagic(){if(void 0!==this.#e)return this.#e;for(const t of this.#s)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.#s.map((t=>String(t))).join("|")+")":this.#l=this.#s.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,i=e.#n;for(;i;){for(let s=e.#r+1;!i.type&&s<i.#s.length;s++)for(const e of t.#s){if("string"==typeof e)throw new Error("string part in extglob AST??");e.copyIn(i.#s[s])}e=i,i=e.#n}}return this}push(...t){for(const e of t)if(""!==e){if("string"!=typeof e&&!(e instanceof at&&e.#n===this))throw new Error("invalid part: "+e);this.#s.push(e)}}toJSON(){const t=null===this.type?this.#s.slice().map((t=>"string"==typeof t?t:t.toJSON())):[this.type,...this.#s.map((t=>t.toJSON()))];return this.isStart()&&!this.type&&t.unshift([]),this.isEnd()&&(this===this.#t||this.#t.#a&&"!"===this.#n?.type)&&t.push({}),t}isStart(){if(this.#t===this)return!0;if(!this.#n?.isStart())return!1;if(0===this.#r)return!0;const t=this.#n;for(let e=0;e<this.#r;e++){const i=t.#s[e];if(!(i instanceof at&&"!"===i.type))return!1}return!0}isEnd(){if(this.#t===this)return!0;if("!"===this.#n?.type)return!0;if(!this.#n?.isEnd())return!1;if(!this.type)return this.#n?.isEnd();const t=this.#n?this.#n.#s.length:0;return this.#r===t-1}copyIn(t){"string"==typeof t?this.push(t):this.push(t.clone(this))}clone(t){const e=new at(this.type,t);for(const t of this.#s)e.copyIn(t);return e}static#u(t,e,i,s){let n=!1,r=!1,o=-1,a=!1;if(null===e.type){let h=i,l="";for(;h<t.length;){const i=t.charAt(h++);if(n||"\\"===i)n=!n,l+=i;else if(r)h===o+1?"^"!==i&&"!"!==i||(a=!0):"]"!==i||h===o+2&&a||(r=!1),l+=i;else if("["!==i)if(s.noext||!Q(i)||"("!==t.charAt(h))l+=i;else{e.push(l),l="";const n=new at(i,e);h=at.#u(t,n,h,s),e.push(n)}else r=!0,o=h,a=!1,l+=i}return e.push(l),h}let h=i+1,l=new at(null,e);const c=[];let p="";for(;h<t.length;){const i=t.charAt(h++);if(n||"\\"===i)n=!n,p+=i;else if(r)h===o+1?"^"!==i&&"!"!==i||(a=!0):"]"!==i||h===o+2&&a||(r=!1),p+=i;else if("["!==i)if(Q(i)&&"("===t.charAt(h)){l.push(p),p="";const e=new at(i,l);l.push(e),h=at.#u(t,e,h,s)}else if("|"!==i){if(")"===i)return""===p&&0===e.#s.length&&(e.#c=!0),l.push(p),p="",e.push(...c,l),h;p+=i}else l.push(p),p="",c.push(l),l=new at(null,e);else r=!0,o=h,a=!1,p+=i}return e.type=null,e.#e=void 0,e.#s=[t.substring(i-1)],h}static fromGlob(t,e={}){const i=new at(null,void 0,e);return at.#u(t,i,0,e),i}toMMPattern(){if(this!==this.#t)return this.#t.toMMPattern();const t=this.toString(),[e,i,s,n]=this.toRegExpSource();if(!(s||this.#e||this.#h.nocase&&!this.#h.nocaseMagicOnly&&t.toUpperCase()!==t.toLowerCase()))return i;const r=(this.#h.nocase?"i":"")+(n?"u":"");return Object.assign(new RegExp(`^${e}$`,r),{_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 i=this.isStart()&&this.isEnd(),s=this.#s.map((e=>{const[s,n,r,o]="string"==typeof e?at.#d(e,this.#e,i):e.toRegExpSource(t);return this.#e=this.#e||r,this.#i=this.#i||o,s})).join("");let n="";if(this.isStart()&&"string"==typeof this.#s[0]){if(!(1===this.#s.length&&it.has(this.#s[0]))){const i=et,r=e&&i.has(s.charAt(0))||s.startsWith("\\.")&&i.has(s.charAt(2))||s.startsWith("\\.\\.")&&i.has(s.charAt(4)),o=!e&&!t&&i.has(s.charAt(0));n=r?"(?!(?:^|/)\\.\\.?(?:$|/))":o?tt:""}}let r="";this.isEnd()&&this.#t.#a&&"!"===this.#n?.type&&(r="(?:$|\\/)");return[n+s+r,J(s),this.#e=!!this.#e,this.#i]}const i="*"===this.type||"+"===this.type,s="!"===this.type?"(?:(?!(?:":"(?:";let n=this.#f(e);if(this.isStart()&&this.isEnd()&&!n&&"!"!==this.type){const t=this.toString();return this.#s=[t],this.type=null,this.#e=void 0,[t,J(this.toString()),!1,!1]}let r=!i||t||e?"":this.#f(!0);r===n&&(r=""),r&&(n=`(?:${n})(?:${r})*?`);let o="";if("!"===this.type&&this.#c)o=(this.isStart()&&!e?tt:"")+ot;else{o=s+n+("!"===this.type?"))"+(!this.isStart()||e||t?"":tt)+rt+")":"@"===this.type?")":"?"===this.type?")?":"+"===this.type&&r?")":"*"===this.type&&r?")?":`)${this.type}`)}return[o,J(n),this.#e=!!this.#e,this.#i]}#f(t){return this.#s.map((e=>{if("string"==typeof e)throw new Error("string type in extglob ast??");const[i,s,n,r]=e.toRegExpSource(t);return this.#i=this.#i||r,i})).filter((t=>!(this.isStart()&&this.isEnd()&&!t))).join("|")}static#d(t,e,i=!1){let s=!1,n="",r=!1;for(let o=0;o<t.length;o++){const a=t.charAt(o);if(s)s=!1,n+=(st.has(a)?"\\":"")+a;else if("\\"!==a){if("["===a){const[i,s,a,h]=K(t,o);if(a){n+=i,r=r||s,o+=a-1,e=e||h;continue}}"*"!==a?"?"!==a?n+=a.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"):(n+=nt,e=!0):(n+=i&&"*"===t?ot:rt,e=!0)}else o===t.length-1?n+="\\\\":s=!0}return[n,J(t),!!e,r]}}const ht=(t,{windowsPathsNoEscape:e=!1}={})=>e?t.replace(/[?*()[\]]/g,"[$&]"):t.replace(/[?*()[\]\\]/g,"\\$&"),lt=(t,e,i={})=>(q(e),!(!i.nocomment&&"#"===e.charAt(0))&&new It(e,i).match(t)),ct=/^\*+([^+@!?\*\[\(]*)$/,pt=t=>e=>!e.startsWith(".")&&e.endsWith(t),ut=t=>e=>e.endsWith(t),dt=t=>(t=t.toLowerCase(),e=>!e.startsWith(".")&&e.toLowerCase().endsWith(t)),ft=t=>(t=t.toLowerCase(),e=>e.toLowerCase().endsWith(t)),gt=/^\*+\.\*+$/,mt=t=>!t.startsWith(".")&&t.includes("."),wt=t=>"."!==t&&".."!==t&&t.includes("."),yt=/^\.\*+$/,bt=t=>"."!==t&&".."!==t&&t.startsWith("."),vt=/^\*+$/,St=t=>0!==t.length&&!t.startsWith("."),kt=t=>0!==t.length&&"."!==t&&".."!==t,xt=/^\?+([^+@!?\*\[\(]*)?$/,At=([t,e=""])=>{const i=Lt([t]);return e?(e=e.toLowerCase(),t=>i(t)&&t.toLowerCase().endsWith(e)):i},Ct=([t,e=""])=>{const i=Ot([t]);return e?(e=e.toLowerCase(),t=>i(t)&&t.toLowerCase().endsWith(e)):i},Et=([t,e=""])=>{const i=Ot([t]);return e?t=>i(t)&&t.endsWith(e):i},Tt=([t,e=""])=>{const i=Lt([t]);return e?t=>i(t)&&t.endsWith(e):i},Lt=([t])=>{const e=t.length;return t=>t.length===e&&!t.startsWith(".")},Ot=([t])=>{const e=t.length;return t=>t.length===e&&"."!==t&&".."!==t},Mt="object"==typeof process&&process?"object"==typeof process.env&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix";lt.sep="win32"===Mt?{sep:"\\"}.sep:{sep:"/"}.sep;const Ft=Symbol("globstar **");lt.GLOBSTAR=Ft;lt.filter=(t,e={})=>i=>lt(i,t,e);const Rt=(t,e={})=>Object.assign({},t,e);lt.defaults=t=>{if(!t||"object"!=typeof t||!Object.keys(t).length)return lt;const e=lt;return Object.assign(((i,s,n={})=>e(i,s,Rt(t,n))),{Minimatch:class extends e.Minimatch{constructor(e,i={}){super(e,Rt(t,i))}static defaults(i){return e.defaults(Rt(t,i)).Minimatch}},AST:class extends e.AST{constructor(e,i,s={}){super(e,i,Rt(t,s))}static fromGlob(i,s={}){return e.AST.fromGlob(i,Rt(t,s))}},unescape:(i,s={})=>e.unescape(i,Rt(t,s)),escape:(i,s={})=>e.escape(i,Rt(t,s)),filter:(i,s={})=>e.filter(i,Rt(t,s)),defaults:i=>e.defaults(Rt(t,i)),makeRe:(i,s={})=>e.makeRe(i,Rt(t,s)),braceExpand:(i,s={})=>e.braceExpand(i,Rt(t,s)),match:(i,s,n={})=>e.match(i,s,Rt(t,n)),sep:e.sep,GLOBSTAR:Ft})};const Nt=(t,e={})=>(q(t),e.nobrace||!/\{(?:(?!\{).)*\}/.test(t)?[t]:H(t));lt.braceExpand=Nt;lt.makeRe=(t,e={})=>new It(t,e).makeRe();lt.match=(t,e,i={})=>{const s=new It(e,i);return t=t.filter((t=>s.match(t))),s.options.nonull&&!t.length&&t.push(e),t};const jt=/[?*]|[+@!]\(.*?\)|\[|\]/;class It{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;regexp;constructor(t,e={}){q(t),e=e||{},this.options=e,this.pattern=t,this.platform=e.platform||Mt,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 i=this.globSet.map((t=>this.slashSplit(t)));this.globParts=this.preprocess(i),this.debug(this.pattern,this.globParts);let s=this.globParts.map(((t,e,i)=>{if(this.isWindows&&this.windowsNoMagicRoot){const e=!(""!==t[0]||""!==t[1]||"?"!==t[2]&&jt.test(t[2])||jt.test(t[3])),i=/^[a-z]:/i.test(t[0]);if(e)return[...t.slice(0,4),...t.slice(4).map((t=>this.parse(t)))];if(i)return[t[0],...t.slice(1).map((t=>this.parse(t)))]}return t.map((t=>this.parse(t)))}));if(this.debug(this.pattern,s),this.set=s.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 i=0;i<t[e].length;i++)"**"===t[e][i]&&(t[e][i]="*");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 i=e;for(;"**"===t[i+1];)i++;i!==e&&t.splice(e,i-e)}return t}))}levelOneOptimize(t){return t.map((t=>0===(t=t.reduce(((t,e)=>{const i=t[t.length-1];return"**"===e&&"**"===i?t:".."===e&&i&&".."!==i&&"."!==i&&"**"!==i?(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 i=1;i<t.length-1;i++){const s=t[i];1===i&&""===s&&""===t[0]||("."!==s&&""!==s||(e=!0,t.splice(i,1),i--))}"."!==t[0]||2!==t.length||"."!==t[1]&&""!==t[1]||(e=!0,t.pop())}let i=0;for(;-1!==(i=t.indexOf("..",i+1));){const s=t[i-1];s&&"."!==s&&".."!==s&&"**"!==s&&(e=!0,t.splice(i-1,2),i-=2)}}while(e);return 0===t.length?[""]:t}firstPhasePreProcess(t){let e=!1;do{e=!1;for(let i of t){let s=-1;for(;-1!==(s=i.indexOf("**",s+1));){let n=s;for(;"**"===i[n+1];)n++;n>s&&i.splice(s+1,n-s);let r=i[s+1];const o=i[s+2],a=i[s+3];if(".."!==r)continue;if(!o||"."===o||".."===o||!a||"."===a||".."===a)continue;e=!0,i.splice(s,1);const h=i.slice(0);h[s]="**",t.push(h),s--}if(!this.preserveMultipleSlashes){for(let t=1;t<i.length-1;t++){const s=i[t];1===t&&""===s&&""===i[0]||("."!==s&&""!==s||(e=!0,i.splice(t,1),t--))}"."!==i[0]||2!==i.length||"."!==i[1]&&""!==i[1]||(e=!0,i.pop())}let n=0;for(;-1!==(n=i.indexOf("..",n+1));){const t=i[n-1];if(t&&"."!==t&&".."!==t&&"**"!==t){e=!0;const t=1===n&&"**"===i[n+1]?["."]:[];i.splice(n-1,2,...t),0===i.length&&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++){const s=this.partsMatch(t[e],t[i],!this.preserveMultipleSlashes);if(s){t[e]=[],t[i]=s;break}}return t.filter((t=>t.length))}partsMatch(t,e,i=!1){let s=0,n=0,r=[],o="";for(;s<t.length&&n<e.length;)if(t[s]===e[n])r.push("b"===o?e[n]:t[s]),s++,n++;else if(i&&"**"===t[s]&&e[n]===t[s+1])r.push(t[s]),s++;else if(i&&"**"===e[n]&&t[s]===e[n+1])r.push(e[n]),n++;else if("*"!==t[s]||!e[n]||!this.options.dot&&e[n].startsWith(".")||"**"===e[n]){if("*"!==e[n]||!t[s]||!this.options.dot&&t[s].startsWith(".")||"**"===t[s])return!1;if("a"===o)return!1;o="b",r.push(e[n]),s++,n++}else{if("b"===o)return!1;o="a",r.push(t[s]),s++,n++}return t.length===e.length&&r}parseNegate(){if(this.nonegate)return;const t=this.pattern;let e=!1,i=0;for(let s=0;s<t.length&&"!"===t.charAt(s);s++)e=!e,i++;i&&(this.pattern=t.slice(i)),this.negate=e}matchOne(t,e,i=!1){const s=this.options;if(this.isWindows){const i="string"==typeof t[0]&&/^[a-z]:$/i.test(t[0]),s=!i&&""===t[0]&&""===t[1]&&"?"===t[2]&&/^[a-z]:$/i.test(t[3]),n="string"==typeof e[0]&&/^[a-z]:$/i.test(e[0]),r=s?3:i?0:void 0,o=!n&&""===e[0]&&""===e[1]&&"?"===e[2]&&"string"==typeof e[3]&&/^[a-z]:$/i.test(e[3])?3:n?0:void 0;if("number"==typeof r&&"number"==typeof o){const[i,s]=[t[r],e[o]];i.toLowerCase()===s.toLowerCase()&&(e[o]=i,o>r?e=e.slice(o):r>o&&(t=t.slice(r)))}}const{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 r=0,o=0,a=t.length,h=e.length;r<a&&o<h;r++,o++){this.debug("matchOne loop");var l=e[o],c=t[r];if(this.debug(e,l,c),!1===l)return!1;if(l===Ft){this.debug("GLOBSTAR",[e,l,c]);var p=r,u=o+1;if(u===h){for(this.debug("** at the end");r<a;r++)if("."===t[r]||".."===t[r]||!s.dot&&"."===t[r].charAt(0))return!1;return!0}for(;p<a;){var d=t[p];if(this.debug("\nglobstar while",t,p,e,u,d),this.matchOne(t.slice(p),e.slice(u),i))return this.debug("globstar found match!",p,a,d),!0;if("."===d||".."===d||!s.dot&&"."===d.charAt(0)){this.debug("dot detected!",t,p,e,u);break}this.debug("globstar swallow a segment, and continue"),p++}return!(!i||(this.debug("\n>>> no match, partial?",t,p,e,u),p!==a))}let n;if("string"==typeof l?(n=c===l,this.debug("string match",l,c,n)):(n=l.test(c),this.debug("pattern match",l,c,n)),!n)return!1}if(r===a&&o===h)return!0;if(r===a)return i;if(o===h)return r===a-1&&""===t[r];throw new Error("wtf?")}braceExpand(){return Nt(this.pattern,this.options)}parse(t){q(t);const e=this.options;if("**"===t)return Ft;if(""===t)return"";let i,s=null;(i=t.match(vt))?s=e.dot?kt:St:(i=t.match(ct))?s=(e.nocase?e.dot?ft:dt:e.dot?ut:pt)(i[1]):(i=t.match(xt))?s=(e.nocase?e.dot?Ct:At:e.dot?Et:Tt)(i):(i=t.match(gt))?s=e.dot?wt:mt:(i=t.match(yt))&&(s=bt);const n=at.fromGlob(t,this.options).toMMPattern();return s&&"object"==typeof n&&Reflect.defineProperty(n,"test",{value:s}),n}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,i=e.noglobstar?"[^/]*?":e.dot?"(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?":"(?:(?!(?:\\/|^)\\.).)*?",s=new Set(e.nocase?["i"]:[]);let n=t.map((t=>{const e=t.map((t=>{if(t instanceof RegExp)for(const e of t.flags.split(""))s.add(e);return"string"==typeof t?t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"):t===Ft?Ft:t._src}));return e.forEach(((t,s)=>{const n=e[s+1],r=e[s-1];t===Ft&&r!==Ft&&(void 0===r?void 0!==n&&n!==Ft?e[s+1]="(?:\\/|"+i+"\\/)?"+n:e[s]=i:void 0===n?e[s-1]=r+"(?:\\/|"+i+")?":n!==Ft&&(e[s-1]=r+"(?:\\/|\\/"+i+"\\/)"+n,e[s+1]=Ft))})),e.filter((t=>t!==Ft)).join("/")})).join("|");const[r,o]=t.length>1?["(?:",")"]:["",""];n="^"+r+n+o+"$",this.negate&&(n="^(?!"+n+").+$");try{this.regexp=new RegExp(n,[...s].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 i=this.options;this.isWindows&&(t=t.split("\\").join("/"));const s=this.slashSplit(t);this.debug(this.pattern,"split",s);const n=this.set;this.debug(this.pattern,"set",n);let r=s[s.length-1];if(!r)for(let t=s.length-2;!r&&t>=0;t--)r=s[t];for(let t=0;t<n.length;t++){const o=n[t];let a=s;i.matchBase&&1===o.length&&(a=[r]);if(this.matchOne(a,o,e))return!!i.flipNegate||!this.negate}return!i.flipNegate&&this.negate}static defaults(t){return lt.defaults(t).Minimatch}}lt.AST=at,lt.Minimatch=It,lt.escape=ht,lt.unescape=J;const zt="object"==typeof performance&&performance&&"function"==typeof performance.now?performance:Date,Pt=new Set,_t="object"==typeof process&&process?process:{},Dt=(t,e,i,s)=>{"function"==typeof _t.emitWarning?_t.emitWarning(t,e,i,s):console.error(`[${i}] ${e}: ${t}`)};let Bt=globalThis.AbortController,Wt=globalThis.AbortSignal;if(void 0===Bt){Wt=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(t,e){this._onabort.push(e)}},Bt=class{constructor(){e()}signal=new Wt;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"!==_t.env?.LRU_CACHE_IGNORE_AC_WARNING;const e=()=>{t&&(t=!1,Dt("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 Ut=t=>t&&t===Math.floor(t)&&t>0&&isFinite(t),$t=t=>Ut(t)?t<=Math.pow(2,8)?Uint8Array:t<=Math.pow(2,16)?Uint16Array:t<=Math.pow(2,32)?Uint32Array:t<=Number.MAX_SAFE_INTEGER?Gt:null:null;class Gt extends Array{constructor(t){super(t),this.fill(0)}}class Ht{heap;length;static#g=!1;static create(t){const e=$t(t);if(!e)return[];Ht.#g=!0;const i=new Ht(t,e);return Ht.#g=!1,i}constructor(t,e){if(!Ht.#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 qt{#m;#w;#y;#b;#v;#S;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#k;#x;#A;#C;#E;#T;#L;#O;#M;#F;#R;#N;#j;#I;#z;#P;#_;static unsafeExposeInternals(t){return{starts:t.#j,ttls:t.#I,sizes:t.#N,keyMap:t.#A,keyList:t.#C,valList:t.#E,next:t.#T,prev:t.#L,get head(){return t.#O},get tail(){return t.#M},free:t.#F,isBackgroundFetch:e=>t.#D(e),backgroundFetch:(e,i,s,n)=>t.#B(e,i,s,n),moveToTail:e=>t.#W(e),indexes:e=>t.#U(e),rindexes:e=>t.#$(e),isStale:e=>t.#G(e)}}get max(){return this.#m}get maxSize(){return this.#w}get calculatedSize(){return this.#x}get size(){return this.#k}get fetchMethod(){return this.#v}get memoMethod(){return this.#S}get dispose(){return this.#y}get disposeAfter(){return this.#b}constructor(t){const{max:e=0,ttl:i,ttlResolution:s=1,ttlAutopurge:n,updateAgeOnGet:r,updateAgeOnHas:o,allowStale:a,dispose:h,disposeAfter:l,noDisposeOnSet:c,noUpdateTTL:p,maxSize:u=0,maxEntrySize:d=0,sizeCalculation:f,fetchMethod:g,memoMethod:m,noDeleteOnFetchRejection:w,noDeleteOnStaleGet:y,allowStaleOnFetchRejection:b,allowStaleOnFetchAbort:v,ignoreFetchAbort:S}=t;if(0!==e&&!Ut(e))throw new TypeError("max option must be a nonnegative integer");const k=e?$t(e):Array;if(!k)throw new Error("invalid max value: "+e);if(this.#m=e,this.#w=u,this.maxEntrySize=d||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!==m&&"function"!=typeof m)throw new TypeError("memoMethod must be a function if defined");if(this.#S=m,void 0!==g&&"function"!=typeof g)throw new TypeError("fetchMethod must be a function if specified");if(this.#v=g,this.#P=!!g,this.#A=new Map,this.#C=new Array(e).fill(void 0),this.#E=new Array(e).fill(void 0),this.#T=new k(e),this.#L=new k(e),this.#O=0,this.#M=0,this.#F=Ht.create(e),this.#k=0,this.#x=0,"function"==typeof h&&(this.#y=h),"function"==typeof l?(this.#b=l,this.#R=[]):(this.#b=void 0,this.#R=void 0),this.#z=!!this.#y,this.#_=!!this.#b,this.noDisposeOnSet=!!c,this.noUpdateTTL=!!p,this.noDeleteOnFetchRejection=!!w,this.allowStaleOnFetchRejection=!!b,this.allowStaleOnFetchAbort=!!v,this.ignoreFetchAbort=!!S,0!==this.maxEntrySize){if(0!==this.#w&&!Ut(this.#w))throw new TypeError("maxSize must be a positive integer if specified");if(!Ut(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#H()}if(this.allowStale=!!a,this.noDeleteOnStaleGet=!!y,this.updateAgeOnGet=!!r,this.updateAgeOnHas=!!o,this.ttlResolution=Ut(s)||0===s?s:1,this.ttlAutopurge=!!n,this.ttl=i||0,this.ttl){if(!Ut(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#q()}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=>!Pt.has(t))(t)){Pt.add(t);Dt("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",t,qt)}}}getRemainingTTL(t){return this.#A.has(t)?1/0:0}#q(){const t=new Gt(this.#m),e=new Gt(this.#m);this.#I=t,this.#j=e,this.#Y=(i,s,n=zt.now())=>{if(e[i]=0!==s?n:0,t[i]=s,0!==s&&this.ttlAutopurge){const t=setTimeout((()=>{this.#G(i)&&this.#V(this.#C[i],"expire")}),s+1);t.unref&&t.unref()}},this.#Z=i=>{e[i]=0!==t[i]?zt.now():0},this.#K=(n,r)=>{if(t[r]){const o=t[r],a=e[r];if(!o||!a)return;n.ttl=o,n.start=a,n.now=i||s();const h=n.now-a;n.remainingTTL=o-h}};let i=0;const s=()=>{const t=zt.now();if(this.ttlResolution>0){i=t;const e=setTimeout((()=>i=0),this.ttlResolution);e.unref&&e.unref()}return t};this.getRemainingTTL=n=>{const r=this.#A.get(n);if(void 0===r)return 0;const o=t[r],a=e[r];if(!o||!a)return 1/0;return o-((i||s())-a)},this.#G=n=>{const r=e[n],o=t[n];return!!o&&!!r&&(i||s())-r>o}}#Z=()=>{};#K=()=>{};#Y=()=>{};#G=()=>!1;#H(){const t=new Gt(this.#m);this.#x=0,this.#N=t,this.#J=e=>{this.#x-=t[e],t[e]=0},this.#X=(t,e,i,s)=>{if(this.#D(e))return 0;if(!Ut(i)){if(!s)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 s)throw new TypeError("sizeCalculation must be a function");if(i=s(e,t),!Ut(i))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}return i},this.#Q=(e,i,s)=>{if(t[e]=i,this.#w){const i=this.#w-t[e];for(;this.#x>i;)this.#tt(!0)}this.#x+=t[e],s&&(s.entrySize=i,s.totalCalculatedSize=this.#x)}}#J=t=>{};#Q=(t,e,i)=>{};#X=(t,e,i,s)=>{if(i||s)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#U({allowStale:t=this.allowStale}={}){if(this.#k)for(let e=this.#M;this.#et(e)&&(!t&&this.#G(e)||(yield e),e!==this.#O);)e=this.#L[e]}*#$({allowStale:t=this.allowStale}={}){if(this.#k)for(let e=this.#O;this.#et(e)&&(!t&&this.#G(e)||(yield e),e!==this.#M);)e=this.#T[e]}#et(t){return void 0!==t&&this.#A.get(this.#C[t])===t}*entries(){for(const t of this.#U())void 0===this.#E[t]||void 0===this.#C[t]||this.#D(this.#E[t])||(yield[this.#C[t],this.#E[t]])}*rentries(){for(const t of this.#$())void 0===this.#E[t]||void 0===this.#C[t]||this.#D(this.#E[t])||(yield[this.#C[t],this.#E[t]])}*keys(){for(const t of this.#U()){const e=this.#C[t];void 0===e||this.#D(this.#E[t])||(yield e)}}*rkeys(){for(const t of this.#$()){const e=this.#C[t];void 0===e||this.#D(this.#E[t])||(yield e)}}*values(){for(const t of this.#U()){void 0===this.#E[t]||this.#D(this.#E[t])||(yield this.#E[t])}}*rvalues(){for(const t of this.#$()){void 0===this.#E[t]||this.#D(this.#E[t])||(yield this.#E[t])}}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(t,e={}){for(const i of this.#U()){const s=this.#E[i],n=this.#D(s)?s.__staleWhileFetching:s;if(void 0!==n&&t(n,this.#C[i],this))return this.get(this.#C[i],e)}}forEach(t,e=this){for(const i of this.#U()){const s=this.#E[i],n=this.#D(s)?s.__staleWhileFetching:s;void 0!==n&&t.call(e,n,this.#C[i],this)}}rforEach(t,e=this){for(const i of this.#$()){const s=this.#E[i],n=this.#D(s)?s.__staleWhileFetching:s;void 0!==n&&t.call(e,n,this.#C[i],this)}}purgeStale(){let t=!1;for(const e of this.#$({allowStale:!0}))this.#G(e)&&(this.#V(this.#C[e],"expire"),t=!0);return t}info(t){const e=this.#A.get(t);if(void 0===e)return;const i=this.#E[e],s=this.#D(i)?i.__staleWhileFetching:i;if(void 0===s)return;const n={value:s};if(this.#I&&this.#j){const t=this.#I[e],i=this.#j[e];if(t&&i){const e=t-(zt.now()-i);n.ttl=e,n.start=Date.now()}}return this.#N&&(n.size=this.#N[e]),n}dump(){const t=[];for(const e of this.#U({allowStale:!0})){const i=this.#C[e],s=this.#E[e],n=this.#D(s)?s.__staleWhileFetching:s;if(void 0===n||void 0===i)continue;const r={value:n};if(this.#I&&this.#j){r.ttl=this.#I[e];const t=zt.now()-this.#j[e];r.start=Math.floor(Date.now()-t)}this.#N&&(r.size=this.#N[e]),t.unshift([i,r])}return t}load(t){this.clear();for(const[e,i]of t){if(i.start){const t=Date.now()-i.start;i.start=zt.now()-t}this.set(e,i.value,i)}}set(t,e,i={}){if(void 0===e)return this.delete(t),this;const{ttl:s=this.ttl,start:n,noDisposeOnSet:r=this.noDisposeOnSet,sizeCalculation:o=this.sizeCalculation,status:a}=i;let{noUpdateTTL:h=this.noUpdateTTL}=i;const l=this.#X(t,e,i.size||0,o);if(this.maxEntrySize&&l>this.maxEntrySize)return a&&(a.set="miss",a.maxEntrySizeExceeded=!0),this.#V(t,"set"),this;let c=0===this.#k?void 0:this.#A.get(t);if(void 0===c)c=0===this.#k?this.#M:0!==this.#F.length?this.#F.pop():this.#k===this.#m?this.#tt(!1):this.#k,this.#C[c]=t,this.#E[c]=e,this.#A.set(t,c),this.#T[this.#M]=c,this.#L[c]=this.#M,this.#M=c,this.#k++,this.#Q(c,l,a),a&&(a.set="add"),h=!1;else{this.#W(c);const i=this.#E[c];if(e!==i){if(this.#P&&this.#D(i)){i.__abortController.abort(new Error("replaced"));const{__staleWhileFetching:e}=i;void 0===e||r||(this.#z&&this.#y?.(e,t,"set"),this.#_&&this.#R?.push([e,t,"set"]))}else r||(this.#z&&this.#y?.(i,t,"set"),this.#_&&this.#R?.push([i,t,"set"]));if(this.#J(c),this.#Q(c,l,a),this.#E[c]=e,a){a.set="replace";const t=i&&this.#D(i)?i.__staleWhileFetching:i;void 0!==t&&(a.oldValue=t)}}else a&&(a.set="update")}if(0===s||this.#I||this.#q(),this.#I&&(h||this.#Y(c,s,n),a&&this.#K(a,c)),!r&&this.#_&&this.#R){const t=this.#R;let e;for(;e=t?.shift();)this.#b?.(...e)}return this}pop(){try{for(;this.#k;){const t=this.#E[this.#O];if(this.#tt(!0),this.#D(t)){if(t.__staleWhileFetching)return t.__staleWhileFetching}else if(void 0!==t)return t}}finally{if(this.#_&&this.#R){const t=this.#R;let e;for(;e=t?.shift();)this.#b?.(...e)}}}#tt(t){const e=this.#O,i=this.#C[e],s=this.#E[e];return this.#P&&this.#D(s)?s.__abortController.abort(new Error("evicted")):(this.#z||this.#_)&&(this.#z&&this.#y?.(s,i,"evict"),this.#_&&this.#R?.push([s,i,"evict"])),this.#J(e),t&&(this.#C[e]=void 0,this.#E[e]=void 0,this.#F.push(e)),1===this.#k?(this.#O=this.#M=0,this.#F.length=0):this.#O=this.#T[e],this.#A.delete(i),this.#k--,e}has(t,e={}){const{updateAgeOnHas:i=this.updateAgeOnHas,status:s}=e,n=this.#A.get(t);if(void 0!==n){const t=this.#E[n];if(this.#D(t)&&void 0===t.__staleWhileFetching)return!1;if(!this.#G(n))return i&&this.#Z(n),s&&(s.has="hit",this.#K(s,n)),!0;s&&(s.has="stale",this.#K(s,n))}else s&&(s.has="miss");return!1}peek(t,e={}){const{allowStale:i=this.allowStale}=e,s=this.#A.get(t);if(void 0===s||!i&&this.#G(s))return;const n=this.#E[s];return this.#D(n)?n.__staleWhileFetching:n}#B(t,e,i,s){const n=void 0===e?void 0:this.#E[e];if(this.#D(n))return n;const r=new Bt,{signal:o}=i;o?.addEventListener("abort",(()=>r.abort(o.reason)),{signal:r.signal});const a={signal:r.signal,options:i,context:s},h=(s,n=!1)=>{const{aborted:o}=r.signal,h=i.ignoreFetchAbort&&void 0!==s;if(i.status&&(o&&!n?(i.status.fetchAborted=!0,i.status.fetchError=r.signal.reason,h&&(i.status.fetchAbortIgnored=!0)):i.status.fetchResolved=!0),o&&!h&&!n)return l(r.signal.reason);const p=c;return this.#E[e]===c&&(void 0===s?p.__staleWhileFetching?this.#E[e]=p.__staleWhileFetching:this.#V(t,"fetch"):(i.status&&(i.status.fetchUpdated=!0),this.set(t,s,a.options))),s},l=s=>{const{aborted:n}=r.signal,o=n&&i.allowStaleOnFetchAbort,a=o||i.allowStaleOnFetchRejection,h=a||i.noDeleteOnFetchRejection,l=c;if(this.#E[e]===c){!h||void 0===l.__staleWhileFetching?this.#V(t,"fetch"):o||(this.#E[e]=l.__staleWhileFetching)}if(a)return i.status&&void 0!==l.__staleWhileFetching&&(i.status.returnedStale=!0),l.__staleWhileFetching;if(l.__returned===l)throw s};i.status&&(i.status.fetchDispatched=!0);const c=new Promise(((e,s)=>{const o=this.#v?.(t,n,a);o&&o instanceof Promise&&o.then((t=>e(void 0===t?void 0:t)),s),r.signal.addEventListener("abort",(()=>{i.ignoreFetchAbort&&!i.allowStaleOnFetchAbort||(e(void 0),i.allowStaleOnFetchAbort&&(e=t=>h(t,!0)))}))})).then(h,(t=>(i.status&&(i.status.fetchRejected=!0,i.status.fetchError=t),l(t)))),p=Object.assign(c,{__abortController:r,__staleWhileFetching:n,__returned:void 0});return void 0===e?(this.set(t,p,{...a.options,status:void 0}),e=this.#A.get(t)):this.#E[e]=p,p}#D(t){if(!this.#P)return!1;const e=t;return!!e&&e instanceof Promise&&e.hasOwnProperty("__staleWhileFetching")&&e.__abortController instanceof Bt}async fetch(t,e={}){const{allowStale:i=this.allowStale,updateAgeOnGet:s=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,ttl:r=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:u=this.ignoreFetchAbort,allowStaleOnFetchAbort:d=this.allowStaleOnFetchAbort,context:f,forceRefresh:g=!1,status:m,signal:w}=e;if(!this.#P)return m&&(m.fetch="get"),this.get(t,{allowStale:i,updateAgeOnGet:s,noDeleteOnStaleGet:n,status:m});const y={allowStale:i,updateAgeOnGet:s,noDeleteOnStaleGet:n,ttl:r,noDisposeOnSet:o,size:a,sizeCalculation:h,noUpdateTTL:l,noDeleteOnFetchRejection:c,allowStaleOnFetchRejection:p,allowStaleOnFetchAbort:d,ignoreFetchAbort:u,status:m,signal:w};let b=this.#A.get(t);if(void 0===b){m&&(m.fetch="miss");const e=this.#B(t,b,y,f);return e.__returned=e}{const e=this.#E[b];if(this.#D(e)){const t=i&&void 0!==e.__staleWhileFetching;return m&&(m.fetch="inflight",t&&(m.returnedStale=!0)),t?e.__staleWhileFetching:e.__returned=e}const n=this.#G(b);if(!g&&!n)return m&&(m.fetch="hit"),this.#W(b),s&&this.#Z(b),m&&this.#K(m,b),e;const r=this.#B(t,b,y,f),o=void 0!==r.__staleWhileFetching&&i;return m&&(m.fetch=n?"stale":"refresh",o&&n&&(m.returnedStale=!0)),o?r.__staleWhileFetching:r.__returned=r}}async forceFetch(t,e={}){const i=await this.fetch(t,e);if(void 0===i)throw new Error("fetch() returned undefined");return i}memo(t,e={}){const i=this.#S;if(!i)throw new Error("no memoMethod provided to constructor");const{context:s,forceRefresh:n,...r}=e,o=this.get(t,r);if(!n&&void 0!==o)return o;const a=i(t,o,{options:r,context:s});return this.set(t,a,r),a}get(t,e={}){const{allowStale:i=this.allowStale,updateAgeOnGet:s=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,status:r}=e,o=this.#A.get(t);if(void 0!==o){const e=this.#E[o],a=this.#D(e);return r&&this.#K(r,o),this.#G(o)?(r&&(r.get="stale"),a?(r&&i&&void 0!==e.__staleWhileFetching&&(r.returnedStale=!0),i?e.__staleWhileFetching:void 0):(n||this.#V(t,"expire"),r&&i&&(r.returnedStale=!0),i?e:void 0)):(r&&(r.get="hit"),a?e.__staleWhileFetching:(this.#W(o),s&&this.#Z(o),e))}r&&(r.get="miss")}#it(t,e){this.#L[e]=t,this.#T[t]=e}#W(t){t!==this.#M&&(t===this.#O?this.#O=this.#T[t]:this.#it(this.#L[t],this.#T[t]),this.#it(this.#M,t),this.#M=t)}delete(t){return this.#V(t,"delete")}#V(t,e){let i=!1;if(0!==this.#k){const s=this.#A.get(t);if(void 0!==s)if(i=!0,1===this.#k)this.#st(e);else{this.#J(s);const i=this.#E[s];if(this.#D(i)?i.__abortController.abort(new Error("deleted")):(this.#z||this.#_)&&(this.#z&&this.#y?.(i,t,e),this.#_&&this.#R?.push([i,t,e])),this.#A.delete(t),this.#C[s]=void 0,this.#E[s]=void 0,s===this.#M)this.#M=this.#L[s];else if(s===this.#O)this.#O=this.#T[s];else{const t=this.#L[s];this.#T[t]=this.#T[s];const e=this.#T[s];this.#L[e]=this.#L[s]}this.#k--,this.#F.push(s)}}if(this.#_&&this.#R?.length){const t=this.#R;let e;for(;e=t?.shift();)this.#b?.(...e)}return i}clear(){return this.#st("delete")}#st(t){for(const e of this.#$({allowStale:!0})){const i=this.#E[e];if(this.#D(i))i.__abortController.abort(new Error("deleted"));else{const s=this.#C[e];this.#z&&this.#y?.(i,s,t),this.#_&&this.#R?.push([i,s,t])}}if(this.#A.clear(),this.#E.fill(void 0),this.#C.fill(void 0),this.#I&&this.#j&&(this.#I.fill(0),this.#j.fill(0)),this.#N&&this.#N.fill(0),this.#O=0,this.#M=0,this.#F.length=0,this.#x=0,this.#k=0,this.#_&&this.#R){const t=this.#R;let e;for(;e=t?.shift();)this.#b?.(...e)}}}const Yt="object"==typeof process&&process?process:{stdout:null,stderr:null},Vt=t=>!!t&&"object"==typeof t&&(t instanceof Re||t instanceof w||Zt(t)||Kt(t)),Zt=t=>!!t&&"object"==typeof t&&t instanceof s&&"function"==typeof t.pipe&&t.pipe!==w.Writable.prototype.pipe,Kt=t=>!!t&&"object"==typeof t&&t instanceof s&&"function"==typeof t.write&&"function"==typeof t.end,Jt=Symbol("EOF"),Xt=Symbol("maybeEmitEnd"),Qt=Symbol("emittedEnd"),te=Symbol("emittingEnd"),ee=Symbol("emittedError"),ie=Symbol("closed"),se=Symbol("read"),ne=Symbol("flush"),re=Symbol("flushChunk"),oe=Symbol("encoding"),ae=Symbol("decoder"),he=Symbol("flowing"),le=Symbol("paused"),ce=Symbol("resume"),pe=Symbol("buffer"),ue=Symbol("pipes"),de=Symbol("bufferLength"),fe=Symbol("bufferPush"),ge=Symbol("bufferShift"),me=Symbol("objectMode"),we=Symbol("destroyed"),ye=Symbol("error"),be=Symbol("emitData"),ve=Symbol("emitEnd"),Se=Symbol("emitEnd2"),ke=Symbol("async"),xe=Symbol("abort"),Ae=Symbol("aborted"),Ce=Symbol("signal"),Ee=Symbol("dataListeners"),Te=Symbol("discarded"),Le=t=>Promise.resolve().then(t),Oe=t=>t();class Me{src;dest;opts;ondrain;constructor(t,e,i){this.src=t,this.dest=e,this.opts=i,this.ondrain=()=>t[ce](),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 Fe extends Me{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(t,e,i){super(t,e,i),this.proxyErrors=t=>e.emit("error",t),t.on("error",this.proxyErrors)}}class Re extends s{[he]=!1;[le]=!1;[ue]=[];[pe]=[];[me];[oe];[ke];[ae];[Jt]=!1;[Qt]=!1;[te]=!1;[ie]=!1;[ee]=null;[de]=0;[we]=!1;[Ce];[Ae]=!1;[Ee]=0;[Te]=!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[me]=!0,this[oe]=null):(t=>!t.objectMode&&!!t.encoding&&"buffer"!==t.encoding)(e)?(this[oe]=e.encoding,this[me]=!1):(this[me]=!1,this[oe]=null),this[ke]=!!e.async,this[ae]=th