UNPKG

snyk-policy

Version:

Snyk's policy parser and matching logic

1,283 lines 157 kB
import Ko from "url"; import wi, { statSync as jr, lstatSync as zo, promises as Pr } from "fs"; import * as Q from "path"; import Oi from "path"; import Jo from "util"; var Pt = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}; function er(e) { return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e; } var Mr = { exports: {} }, Ar, Dn; function Zo() { if (Dn) return Ar; Dn = 1; var e = 1e3, t = e * 60, r = t * 60, n = r * 24, i = n * 7, s = n * 365.25; Ar = function(c, f) { f = f || {}; var d = typeof c; if (d === "string" && c.length > 0) return o(c); if (d === "number" && isFinite(c)) return f.long ? l(c) : u(c); throw new Error( "val is not a non-empty string or a valid number. val=" + JSON.stringify(c) ); }; function o(c) { if (c = String(c), !(c.length > 100)) { var f = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec( c ); if (f) { var d = parseFloat(f[1]), m = (f[2] || "ms").toLowerCase(); switch (m) { case "years": case "year": case "yrs": case "yr": case "y": return d * s; case "weeks": case "week": case "w": return d * i; case "days": case "day": case "d": return d * n; case "hours": case "hour": case "hrs": case "hr": case "h": return d * r; case "minutes": case "minute": case "mins": case "min": case "m": return d * t; case "seconds": case "second": case "secs": case "sec": case "s": return d * e; case "milliseconds": case "millisecond": case "msecs": case "msec": case "ms": return d; default: return; } } } } function u(c) { var f = Math.abs(c); return f >= n ? Math.round(c / n) + "d" : f >= r ? Math.round(c / r) + "h" : f >= t ? Math.round(c / t) + "m" : f >= e ? Math.round(c / e) + "s" : c + "ms"; } function l(c) { var f = Math.abs(c); return f >= n ? p(c, f, n, "day") : f >= r ? p(c, f, r, "hour") : f >= t ? p(c, f, t, "minute") : f >= e ? p(c, f, e, "second") : c + " ms"; } function p(c, f, d, m) { var w = f >= d * 1.5; return Math.round(c / d) + " " + m + (w ? "s" : ""); } return Ar; } function Qo(e) { r.debug = r, r.default = r, r.coerce = l, r.disable = o, r.enable = i, r.enabled = u, r.humanize = Zo(), r.destroy = p, Object.keys(e).forEach((c) => { r[c] = e[c]; }), r.names = [], r.skips = [], r.formatters = {}; function t(c) { let f = 0; for (let d = 0; d < c.length; d++) f = (f << 5) - f + c.charCodeAt(d), f |= 0; return r.colors[Math.abs(f) % r.colors.length]; } r.selectColor = t; function r(c) { let f, d = null, m, w; function v(...$) { if (!v.enabled) return; const D = v, V = Number(/* @__PURE__ */ new Date()), j = V - (f || V); D.diff = j, D.prev = f, D.curr = V, f = V, $[0] = r.coerce($[0]), typeof $[0] != "string" && $.unshift("%O"); let B = 0; $[0] = $[0].replace(/%([a-zA-Z%])/g, (se, Pe) => { if (se === "%%") return "%"; B++; const Ae = r.formatters[Pe]; if (typeof Ae == "function") { const Me = $[B]; se = Ae.call(D, Me), $.splice(B, 1), B--; } return se; }), r.formatArgs.call(D, $), (D.log || r.log).apply(D, $); } return v.namespace = c, v.useColors = r.useColors(), v.color = r.selectColor(c), v.extend = n, v.destroy = r.destroy, Object.defineProperty(v, "enabled", { enumerable: !0, configurable: !1, get: () => d !== null ? d : (m !== r.namespaces && (m = r.namespaces, w = r.enabled(c)), w), set: ($) => { d = $; } }), typeof r.init == "function" && r.init(v), v; } function n(c, f) { const d = r(this.namespace + (typeof f > "u" ? ":" : f) + c); return d.log = this.log, d; } function i(c) { r.save(c), r.namespaces = c, r.names = [], r.skips = []; const f = (typeof c == "string" ? c : "").trim().replace(/\s+/g, ",").split(",").filter(Boolean); for (const d of f) d[0] === "-" ? r.skips.push(d.slice(1)) : r.names.push(d); } function s(c, f) { let d = 0, m = 0, w = -1, v = 0; for (; d < c.length; ) if (m < f.length && (f[m] === c[d] || f[m] === "*")) f[m] === "*" ? (w = m, v = d, m++) : (d++, m++); else if (w !== -1) m = w + 1, v++, d = v; else return !1; for (; m < f.length && f[m] === "*"; ) m++; return m === f.length; } function o() { const c = [ ...r.names, ...r.skips.map((f) => "-" + f) ].join(","); return r.enable(""), c; } function u(c) { for (const f of r.skips) if (s(c, f)) return !1; for (const f of r.names) if (s(c, f)) return !0; return !1; } function l(c) { return c instanceof Error ? c.stack || c.message : c; } function p() { console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."); } return r.enable(r.load()), r; } var ea = Qo; (function(e, t) { t.formatArgs = n, t.save = i, t.load = s, t.useColors = r, t.storage = o(), t.destroy = /* @__PURE__ */ (() => { let l = !1; return () => { l || (l = !0, console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")); }; })(), t.colors = [ "#0000CC", "#0000FF", "#0033CC", "#0033FF", "#0066CC", "#0066FF", "#0099CC", "#0099FF", "#00CC00", "#00CC33", "#00CC66", "#00CC99", "#00CCCC", "#00CCFF", "#3300CC", "#3300FF", "#3333CC", "#3333FF", "#3366CC", "#3366FF", "#3399CC", "#3399FF", "#33CC00", "#33CC33", "#33CC66", "#33CC99", "#33CCCC", "#33CCFF", "#6600CC", "#6600FF", "#6633CC", "#6633FF", "#66CC00", "#66CC33", "#9900CC", "#9900FF", "#9933CC", "#9933FF", "#99CC00", "#99CC33", "#CC0000", "#CC0033", "#CC0066", "#CC0099", "#CC00CC", "#CC00FF", "#CC3300", "#CC3333", "#CC3366", "#CC3399", "#CC33CC", "#CC33FF", "#CC6600", "#CC6633", "#CC9900", "#CC9933", "#CCCC00", "#CCCC33", "#FF0000", "#FF0033", "#FF0066", "#FF0099", "#FF00CC", "#FF00FF", "#FF3300", "#FF3333", "#FF3366", "#FF3399", "#FF33CC", "#FF33FF", "#FF6600", "#FF6633", "#FF9900", "#FF9933", "#FFCC00", "#FFCC33" ]; function r() { if (typeof window < "u" && window.process && (window.process.type === "renderer" || window.process.__nwjs)) return !0; if (typeof navigator < "u" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) return !1; let l; return typeof document < "u" && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || // Is firebug? http://stackoverflow.com/a/398120/376773 typeof window < "u" && window.console && (window.console.firebug || window.console.exception && window.console.table) || // Is firefox >= v31? // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages typeof navigator < "u" && navigator.userAgent && (l = navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)) && parseInt(l[1], 10) >= 31 || // Double check webkit in userAgent just in case we are in a worker typeof navigator < "u" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/); } function n(l) { if (l[0] = (this.useColors ? "%c" : "") + this.namespace + (this.useColors ? " %c" : " ") + l[0] + (this.useColors ? "%c " : " ") + "+" + e.exports.humanize(this.diff), !this.useColors) return; const p = "color: " + this.color; l.splice(1, 0, p, "color: inherit"); let c = 0, f = 0; l[0].replace(/%[a-zA-Z%]/g, (d) => { d !== "%%" && (c++, d === "%c" && (f = c)); }), l.splice(f, 0, p); } t.log = console.debug || console.log || (() => { }); function i(l) { try { l ? t.storage.setItem("debug", l) : t.storage.removeItem("debug"); } catch { } } function s() { let l; try { l = t.storage.getItem("debug") || t.storage.getItem("DEBUG"); } catch { } return !l && typeof process < "u" && "env" in process && (l = process.env.DEBUG), l; } function o() { try { return localStorage; } catch { } } e.exports = ea(t); const { formatters: u } = e.exports; u.j = function(l) { try { return JSON.stringify(l); } catch (p) { return "[UnexpectedJSONParseError]: " + p.message; } }; })(Mr, Mr.exports); var tr = Mr.exports; const xe = /* @__PURE__ */ er(tr); var Ur = { exports: {} }; const ta = "2.0.0", Si = 256, ra = Number.MAX_SAFE_INTEGER || /* istanbul ignore next */ 9007199254740991, na = 16, ia = Si - 6, sa = [ "major", "premajor", "minor", "preminor", "patch", "prepatch", "prerelease" ]; var rr = { MAX_LENGTH: Si, MAX_SAFE_COMPONENT_LENGTH: na, MAX_SAFE_BUILD_LENGTH: ia, MAX_SAFE_INTEGER: ra, RELEASE_TYPES: sa, SEMVER_SPEC_VERSION: ta, FLAG_INCLUDE_PRERELEASE: 1, FLAG_LOOSE: 2 }; const oa = typeof process == "object" && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG) ? (...e) => console.error("SEMVER", ...e) : () => { }; var nr = oa; (function(e, t) { const { MAX_SAFE_COMPONENT_LENGTH: r, MAX_SAFE_BUILD_LENGTH: n, MAX_LENGTH: i } = rr, s = nr; t = e.exports = {}; const o = t.re = [], u = t.safeRe = [], l = t.src = [], p = t.safeSrc = [], c = t.t = {}; let f = 0; const d = "[a-zA-Z0-9-]", m = [ ["\\s", 1], ["\\d", i], [d, n] ], w = ($) => { for (const [D, V] of m) $ = $.split(`${D}*`).join(`${D}{0,${V}}`).split(`${D}+`).join(`${D}{1,${V}}`); return $; }, v = ($, D, V) => { const j = w(D), B = f++; s($, B, D), c[$] = B, l[B] = D, p[B] = j, o[B] = new RegExp(D, V ? "g" : void 0), u[B] = new RegExp(j, V ? "g" : void 0); }; v("NUMERICIDENTIFIER", "0|[1-9]\\d*"), v("NUMERICIDENTIFIERLOOSE", "\\d+"), v("NONNUMERICIDENTIFIER", `\\d*[a-zA-Z-]${d}*`), v("MAINVERSION", `(${l[c.NUMERICIDENTIFIER]})\\.(${l[c.NUMERICIDENTIFIER]})\\.(${l[c.NUMERICIDENTIFIER]})`), v("MAINVERSIONLOOSE", `(${l[c.NUMERICIDENTIFIERLOOSE]})\\.(${l[c.NUMERICIDENTIFIERLOOSE]})\\.(${l[c.NUMERICIDENTIFIERLOOSE]})`), v("PRERELEASEIDENTIFIER", `(?:${l[c.NONNUMERICIDENTIFIER]}|${l[c.NUMERICIDENTIFIER]})`), v("PRERELEASEIDENTIFIERLOOSE", `(?:${l[c.NONNUMERICIDENTIFIER]}|${l[c.NUMERICIDENTIFIERLOOSE]})`), v("PRERELEASE", `(?:-(${l[c.PRERELEASEIDENTIFIER]}(?:\\.${l[c.PRERELEASEIDENTIFIER]})*))`), v("PRERELEASELOOSE", `(?:-?(${l[c.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${l[c.PRERELEASEIDENTIFIERLOOSE]})*))`), v("BUILDIDENTIFIER", `${d}+`), v("BUILD", `(?:\\+(${l[c.BUILDIDENTIFIER]}(?:\\.${l[c.BUILDIDENTIFIER]})*))`), v("FULLPLAIN", `v?${l[c.MAINVERSION]}${l[c.PRERELEASE]}?${l[c.BUILD]}?`), v("FULL", `^${l[c.FULLPLAIN]}$`), v("LOOSEPLAIN", `[v=\\s]*${l[c.MAINVERSIONLOOSE]}${l[c.PRERELEASELOOSE]}?${l[c.BUILD]}?`), v("LOOSE", `^${l[c.LOOSEPLAIN]}$`), v("GTLT", "((?:<|>)?=?)"), v("XRANGEIDENTIFIERLOOSE", `${l[c.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`), v("XRANGEIDENTIFIER", `${l[c.NUMERICIDENTIFIER]}|x|X|\\*`), v("XRANGEPLAIN", `[v=\\s]*(${l[c.XRANGEIDENTIFIER]})(?:\\.(${l[c.XRANGEIDENTIFIER]})(?:\\.(${l[c.XRANGEIDENTIFIER]})(?:${l[c.PRERELEASE]})?${l[c.BUILD]}?)?)?`), v("XRANGEPLAINLOOSE", `[v=\\s]*(${l[c.XRANGEIDENTIFIERLOOSE]})(?:\\.(${l[c.XRANGEIDENTIFIERLOOSE]})(?:\\.(${l[c.XRANGEIDENTIFIERLOOSE]})(?:${l[c.PRERELEASELOOSE]})?${l[c.BUILD]}?)?)?`), v("XRANGE", `^${l[c.GTLT]}\\s*${l[c.XRANGEPLAIN]}$`), v("XRANGELOOSE", `^${l[c.GTLT]}\\s*${l[c.XRANGEPLAINLOOSE]}$`), v("COERCEPLAIN", `(^|[^\\d])(\\d{1,${r}})(?:\\.(\\d{1,${r}}))?(?:\\.(\\d{1,${r}}))?`), v("COERCE", `${l[c.COERCEPLAIN]}(?:$|[^\\d])`), v("COERCEFULL", l[c.COERCEPLAIN] + `(?:${l[c.PRERELEASE]})?(?:${l[c.BUILD]})?(?:$|[^\\d])`), v("COERCERTL", l[c.COERCE], !0), v("COERCERTLFULL", l[c.COERCEFULL], !0), v("LONETILDE", "(?:~>?)"), v("TILDETRIM", `(\\s*)${l[c.LONETILDE]}\\s+`, !0), t.tildeTrimReplace = "$1~", v("TILDE", `^${l[c.LONETILDE]}${l[c.XRANGEPLAIN]}$`), v("TILDELOOSE", `^${l[c.LONETILDE]}${l[c.XRANGEPLAINLOOSE]}$`), v("LONECARET", "(?:\\^)"), v("CARETTRIM", `(\\s*)${l[c.LONECARET]}\\s+`, !0), t.caretTrimReplace = "$1^", v("CARET", `^${l[c.LONECARET]}${l[c.XRANGEPLAIN]}$`), v("CARETLOOSE", `^${l[c.LONECARET]}${l[c.XRANGEPLAINLOOSE]}$`), v("COMPARATORLOOSE", `^${l[c.GTLT]}\\s*(${l[c.LOOSEPLAIN]})$|^$`), v("COMPARATOR", `^${l[c.GTLT]}\\s*(${l[c.FULLPLAIN]})$|^$`), v("COMPARATORTRIM", `(\\s*)${l[c.GTLT]}\\s*(${l[c.LOOSEPLAIN]}|${l[c.XRANGEPLAIN]})`, !0), t.comparatorTrimReplace = "$1$2$3", v("HYPHENRANGE", `^\\s*(${l[c.XRANGEPLAIN]})\\s+-\\s+(${l[c.XRANGEPLAIN]})\\s*$`), v("HYPHENRANGELOOSE", `^\\s*(${l[c.XRANGEPLAINLOOSE]})\\s+-\\s+(${l[c.XRANGEPLAINLOOSE]})\\s*$`), v("STAR", "(<|>)?=?\\s*\\*"), v("GTE0", "^\\s*>=\\s*0\\.0\\.0\\s*$"), v("GTE0PRE", "^\\s*>=\\s*0\\.0\\.0-0\\s*$"); })(Ur, Ur.exports); var Et = Ur.exports; const aa = Object.freeze({ loose: !0 }), la = Object.freeze({}), ca = (e) => e ? typeof e != "object" ? aa : e : la; var qr = ca; const jn = /^[0-9]+$/, _i = (e, t) => { if (typeof e == "number" && typeof t == "number") return e === t ? 0 : e < t ? -1 : 1; const r = jn.test(e), n = jn.test(t); return r && n && (e = +e, t = +t), e === t ? 0 : r && !n ? -1 : n && !r ? 1 : e < t ? -1 : 1; }, ua = (e, t) => _i(t, e); var Ti = { compareIdentifiers: _i, rcompareIdentifiers: ua }; const Mt = nr, { MAX_LENGTH: Pn, MAX_SAFE_INTEGER: Ut } = rr, { safeRe: kt, t: Gt } = Et, fa = qr, { compareIdentifiers: $r } = Ti; let ha = class oe { constructor(t, r) { if (r = fa(r), t instanceof oe) { if (t.loose === !!r.loose && t.includePrerelease === !!r.includePrerelease) return t; t = t.version; } else if (typeof t != "string") throw new TypeError(`Invalid version. Must be a string. Got type "${typeof t}".`); if (t.length > Pn) throw new TypeError( `version is longer than ${Pn} characters` ); Mt("SemVer", t, r), this.options = r, this.loose = !!r.loose, this.includePrerelease = !!r.includePrerelease; const n = t.trim().match(r.loose ? kt[Gt.LOOSE] : kt[Gt.FULL]); if (!n) throw new TypeError(`Invalid Version: ${t}`); if (this.raw = t, this.major = +n[1], this.minor = +n[2], this.patch = +n[3], this.major > Ut || this.major < 0) throw new TypeError("Invalid major version"); if (this.minor > Ut || this.minor < 0) throw new TypeError("Invalid minor version"); if (this.patch > Ut || this.patch < 0) throw new TypeError("Invalid patch version"); n[4] ? this.prerelease = n[4].split(".").map((i) => { if (/^[0-9]+$/.test(i)) { const s = +i; if (s >= 0 && s < Ut) return s; } return i; }) : this.prerelease = [], this.build = n[5] ? n[5].split(".") : [], this.format(); } format() { return this.version = `${this.major}.${this.minor}.${this.patch}`, this.prerelease.length && (this.version += `-${this.prerelease.join(".")}`), this.version; } toString() { return this.version; } compare(t) { if (Mt("SemVer.compare", this.version, this.options, t), !(t instanceof oe)) { if (typeof t == "string" && t === this.version) return 0; t = new oe(t, this.options); } return t.version === this.version ? 0 : this.compareMain(t) || this.comparePre(t); } compareMain(t) { return t instanceof oe || (t = new oe(t, this.options)), this.major < t.major ? -1 : this.major > t.major ? 1 : this.minor < t.minor ? -1 : this.minor > t.minor ? 1 : this.patch < t.patch ? -1 : this.patch > t.patch ? 1 : 0; } comparePre(t) { if (t instanceof oe || (t = new oe(t, this.options)), this.prerelease.length && !t.prerelease.length) return -1; if (!this.prerelease.length && t.prerelease.length) return 1; if (!this.prerelease.length && !t.prerelease.length) return 0; let r = 0; do { const n = this.prerelease[r], i = t.prerelease[r]; if (Mt("prerelease compare", r, n, i), n === void 0 && i === void 0) return 0; if (i === void 0) return 1; if (n === void 0) return -1; if (n === i) continue; return $r(n, i); } while (++r); } compareBuild(t) { t instanceof oe || (t = new oe(t, this.options)); let r = 0; do { const n = this.build[r], i = t.build[r]; if (Mt("build compare", r, n, i), n === void 0 && i === void 0) return 0; if (i === void 0) return 1; if (n === void 0) return -1; if (n === i) continue; return $r(n, i); } while (++r); } // preminor will bump the version up to the next minor release, and immediately // down to pre-release. premajor and prepatch work the same way. inc(t, r, n) { if (t.startsWith("pre")) { if (!r && n === !1) throw new Error("invalid increment argument: identifier is empty"); if (r) { const i = `-${r}`.match(this.options.loose ? kt[Gt.PRERELEASELOOSE] : kt[Gt.PRERELEASE]); if (!i || i[1] !== r) throw new Error(`invalid identifier: ${r}`); } } switch (t) { case "premajor": this.prerelease.length = 0, this.patch = 0, this.minor = 0, this.major++, this.inc("pre", r, n); break; case "preminor": this.prerelease.length = 0, this.patch = 0, this.minor++, this.inc("pre", r, n); break; case "prepatch": this.prerelease.length = 0, this.inc("patch", r, n), this.inc("pre", r, n); break; case "prerelease": this.prerelease.length === 0 && this.inc("patch", r, n), this.inc("pre", r, n); break; case "release": if (this.prerelease.length === 0) throw new Error(`version ${this.raw} is not a prerelease`); this.prerelease.length = 0; break; case "major": (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) && this.major++, this.minor = 0, this.patch = 0, this.prerelease = []; break; case "minor": (this.patch !== 0 || this.prerelease.length === 0) && this.minor++, this.patch = 0, this.prerelease = []; break; case "patch": this.prerelease.length === 0 && this.patch++, this.prerelease = []; break; case "pre": { const i = Number(n) ? 1 : 0; if (this.prerelease.length === 0) this.prerelease = [i]; else { let s = this.prerelease.length; for (; --s >= 0; ) typeof this.prerelease[s] == "number" && (this.prerelease[s]++, s = -2); if (s === -1) { if (r === this.prerelease.join(".") && n === !1) throw new Error("invalid increment argument: identifier already exists"); this.prerelease.push(i); } } if (r) { let s = [r, i]; n === !1 && (s = [r]), $r(this.prerelease[0], r) === 0 ? isNaN(this.prerelease[1]) && (this.prerelease = s) : this.prerelease = s; } break; } default: throw new Error(`invalid increment argument: ${t}`); } return this.raw = this.format(), this.build.length && (this.raw += `+${this.build.join(".")}`), this; } }; var yt = ha; const Mn = yt, pa = (e, t, r = !1) => { if (e instanceof Mn) return e; try { return new Mn(e, t); } catch (n) { if (!r) return null; throw n; } }; var da = pa; const ga = da, ma = (e, t) => { const r = ga(e, t); return r ? r.version : null; }; var va = ma; const Ea = yt, ya = (e, t) => new Ea(e, t).major; var xa = ya; const Un = yt, Aa = (e, t, r) => new Un(e, r).compare(new Un(t, r)); var nt = Aa; const $a = nt, ba = (e, t, r) => $a(e, t, r) > 0; var Ca = ba; const wa = nt, Oa = (e, t, r) => wa(e, t, r) < 0; var Sa = Oa; const _a = nt, Ta = (e, t, r) => _a(e, t, r) === 0; var Ia = Ta; const Ra = nt, Fa = (e, t, r) => Ra(e, t, r) !== 0; var Na = Fa; const La = nt, Da = (e, t, r) => La(e, t, r) >= 0; var ja = Da; const Pa = nt, Ma = (e, t, r) => Pa(e, t, r) <= 0; var Ua = Ma; const ka = Ia, Ga = Na, Ha = Ca, Ba = ja, Ya = Sa, Xa = Ua, qa = (e, t, r, n) => { switch (t) { case "===": return typeof e == "object" && (e = e.version), typeof r == "object" && (r = r.version), e === r; case "!==": return typeof e == "object" && (e = e.version), typeof r == "object" && (r = r.version), e !== r; case "": case "=": case "==": return ka(e, r, n); case "!=": return Ga(e, r, n); case ">": return Ha(e, r, n); case ">=": return Ba(e, r, n); case "<": return Ya(e, r, n); case "<=": return Xa(e, r, n); default: throw new TypeError(`Invalid operator: ${t}`); } }; var Wa = qa; const { safeRe: qh, t: Wh } = Et; let Va = class { constructor() { this.max = 1e3, this.map = /* @__PURE__ */ new Map(); } get(t) { const r = this.map.get(t); if (r !== void 0) return this.map.delete(t), this.map.set(t, r), r; } delete(t) { return this.map.delete(t); } set(t, r) { if (!this.delete(t) && r !== void 0) { if (this.map.size >= this.max) { const i = this.map.keys().next().value; this.delete(i); } this.map.set(t, r); } return this; } }; var Ka = Va, br, kn; function ie() { if (kn) return br; kn = 1; const e = /\s+/g; class t { constructor(E, S) { if (S = i(S), E instanceof t) return E.loose === !!S.loose && E.includePrerelease === !!S.includePrerelease ? E : new t(E.raw, S); if (E instanceof s) return this.raw = E.value, this.set = [[E]], this.formatted = void 0, this; if (this.options = S, this.loose = !!S.loose, this.includePrerelease = !!S.includePrerelease, this.raw = E.trim().replace(e, " "), this.set = this.raw.split("||").map((b) => this.parseRange(b.trim())).filter((b) => b.length), !this.set.length) throw new TypeError(`Invalid SemVer Range: ${this.raw}`); if (this.set.length > 1) { const b = this.set[0]; if (this.set = this.set.filter((_) => !v(_[0])), this.set.length === 0) this.set = [b]; else if (this.set.length > 1) { for (const _ of this.set) if (_.length === 1 && $(_[0])) { this.set = [_]; break; } } } this.formatted = void 0; } get range() { if (this.formatted === void 0) { this.formatted = ""; for (let E = 0; E < this.set.length; E++) { E > 0 && (this.formatted += "||"); const S = this.set[E]; for (let b = 0; b < S.length; b++) b > 0 && (this.formatted += " "), this.formatted += S[b].toString().trim(); } } return this.formatted; } format() { return this.range; } toString() { return this.range; } parseRange(E) { const b = ((this.options.includePrerelease && m) | (this.options.loose && w)) + ":" + E, _ = n.get(b); if (_) return _; const C = this.options.loose, x = C ? l[p.HYPHENRANGELOOSE] : l[p.HYPHENRANGE]; E = E.replace(x, Tt(this.options.includePrerelease)), o("hyphen replace", E), E = E.replace(l[p.COMPARATORTRIM], c), o("comparator trim", E), E = E.replace(l[p.TILDETRIM], f), o("tilde trim", E), E = E.replace(l[p.CARETTRIM], d), o("caret trim", E); let N = E.split(" ").map((P) => V(P, this.options)).join(" ").split(/\s+/).map((P) => _t(P, this.options)); C && (N = N.filter((P) => (o("loose invalid filter", P, this.options), !!P.match(l[p.COMPARATORLOOSE])))), o("range list", N); const T = /* @__PURE__ */ new Map(), I = N.map((P) => new s(P, this.options)); for (const P of I) { if (v(P)) return [P]; T.set(P.value, P); } T.size > 1 && T.has("") && T.delete(""); const q = [...T.values()]; return n.set(b, q), q; } intersects(E, S) { if (!(E instanceof t)) throw new TypeError("a Range is required"); return this.set.some((b) => D(b, S) && E.set.some((_) => D(_, S) && b.every((C) => _.every((x) => C.intersects(x, S))))); } // if ANY of the sets match ALL of its comparators, then pass test(E) { if (!E) return !1; if (typeof E == "string") try { E = new u(E, this.options); } catch { return !1; } for (let S = 0; S < this.set.length; S++) if (It(this.set[S], E, this.options)) return !0; return !1; } } br = t; const r = Ka, n = new r(), i = qr, s = ir(), o = nr, u = yt, { safeRe: l, t: p, comparatorTrimReplace: c, tildeTrimReplace: f, caretTrimReplace: d } = Et, { FLAG_INCLUDE_PRERELEASE: m, FLAG_LOOSE: w } = rr, v = (y) => y.value === "<0.0.0-0", $ = (y) => y.value === "", D = (y, E) => { let S = !0; const b = y.slice(); let _ = b.pop(); for (; S && b.length; ) S = b.every((C) => _.intersects(C, E)), _ = b.pop(); return S; }, V = (y, E) => (y = y.replace(l[p.BUILD], ""), o("comp", y, E), y = se(y, E), o("caret", y), y = B(y, E), o("tildes", y), y = Ae(y, E), o("xrange", y), y = St(y, E), o("stars", y), y), j = (y) => !y || y.toLowerCase() === "x" || y === "*", B = (y, E) => y.trim().split(/\s+/).map((S) => ot(S, E)).join(" "), ot = (y, E) => { const S = E.loose ? l[p.TILDELOOSE] : l[p.TILDE]; return y.replace(S, (b, _, C, x, N) => { o("tilde", y, b, _, C, x, N); let T; return j(_) ? T = "" : j(C) ? T = `>=${_}.0.0 <${+_ + 1}.0.0-0` : j(x) ? T = `>=${_}.${C}.0 <${_}.${+C + 1}.0-0` : N ? (o("replaceTilde pr", N), T = `>=${_}.${C}.${x}-${N} <${_}.${+C + 1}.0-0`) : T = `>=${_}.${C}.${x} <${_}.${+C + 1}.0-0`, o("tilde return", T), T; }); }, se = (y, E) => y.trim().split(/\s+/).map((S) => Pe(S, E)).join(" "), Pe = (y, E) => { o("caret", y, E); const S = E.loose ? l[p.CARETLOOSE] : l[p.CARET], b = E.includePrerelease ? "-0" : ""; return y.replace(S, (_, C, x, N, T) => { o("caret", y, _, C, x, N, T); let I; return j(C) ? I = "" : j(x) ? I = `>=${C}.0.0${b} <${+C + 1}.0.0-0` : j(N) ? C === "0" ? I = `>=${C}.${x}.0${b} <${C}.${+x + 1}.0-0` : I = `>=${C}.${x}.0${b} <${+C + 1}.0.0-0` : T ? (o("replaceCaret pr", T), C === "0" ? x === "0" ? I = `>=${C}.${x}.${N}-${T} <${C}.${x}.${+N + 1}-0` : I = `>=${C}.${x}.${N}-${T} <${C}.${+x + 1}.0-0` : I = `>=${C}.${x}.${N}-${T} <${+C + 1}.0.0-0`) : (o("no pr"), C === "0" ? x === "0" ? I = `>=${C}.${x}.${N}${b} <${C}.${x}.${+N + 1}-0` : I = `>=${C}.${x}.${N}${b} <${C}.${+x + 1}.0-0` : I = `>=${C}.${x}.${N} <${+C + 1}.0.0-0`), o("caret return", I), I; }); }, Ae = (y, E) => (o("replaceXRanges", y, E), y.split(/\s+/).map((S) => Me(S, E)).join(" ")), Me = (y, E) => { y = y.trim(); const S = E.loose ? l[p.XRANGELOOSE] : l[p.XRANGE]; return y.replace(S, (b, _, C, x, N, T) => { o("xRange", y, b, _, C, x, N, T); const I = j(C), q = I || j(x), P = q || j(N), $e = P; return _ === "=" && $e && (_ = ""), T = E.includePrerelease ? "-0" : "", I ? _ === ">" || _ === "<" ? b = "<0.0.0-0" : b = "*" : _ && $e ? (q && (x = 0), N = 0, _ === ">" ? (_ = ">=", q ? (C = +C + 1, x = 0, N = 0) : (x = +x + 1, N = 0)) : _ === "<=" && (_ = "<", q ? C = +C + 1 : x = +x + 1), _ === "<" && (T = "-0"), b = `${_ + C}.${x}.${N}${T}`) : q ? b = `>=${C}.0.0${T} <${+C + 1}.0.0-0` : P && (b = `>=${C}.${x}.0${T} <${C}.${+x + 1}.0-0`), o("xRange return", b), b; }); }, St = (y, E) => (o("replaceStars", y, E), y.trim().replace(l[p.STAR], "")), _t = (y, E) => (o("replaceGTE0", y, E), y.trim().replace(l[E.includePrerelease ? p.GTE0PRE : p.GTE0], "")), Tt = (y) => (E, S, b, _, C, x, N, T, I, q, P, $e) => (j(b) ? S = "" : j(_) ? S = `>=${b}.0.0${y ? "-0" : ""}` : j(C) ? S = `>=${b}.${_}.0${y ? "-0" : ""}` : x ? S = `>=${S}` : S = `>=${S}${y ? "-0" : ""}`, j(I) ? T = "" : j(q) ? T = `<${+I + 1}.0.0-0` : j(P) ? T = `<${I}.${+q + 1}.0-0` : $e ? T = `<=${I}.${q}.${P}-${$e}` : y ? T = `<${I}.${q}.${+P + 1}-0` : T = `<=${T}`, `${S} ${T}`.trim()), It = (y, E, S) => { for (let b = 0; b < y.length; b++) if (!y[b].test(E)) return !1; if (E.prerelease.length && !S.includePrerelease) { for (let b = 0; b < y.length; b++) if (o(y[b].semver), y[b].semver !== s.ANY && y[b].semver.prerelease.length > 0) { const _ = y[b].semver; if (_.major === E.major && _.minor === E.minor && _.patch === E.patch) return !0; } return !1; } return !0; }; return br; } var Cr, Gn; function ir() { if (Gn) return Cr; Gn = 1; const e = Symbol("SemVer ANY"); class t { static get ANY() { return e; } constructor(c, f) { if (f = r(f), c instanceof t) { if (c.loose === !!f.loose) return c; c = c.value; } c = c.trim().split(/\s+/).join(" "), o("comparator", c, f), this.options = f, this.loose = !!f.loose, this.parse(c), this.semver === e ? this.value = "" : this.value = this.operator + this.semver.version, o("comp", this); } parse(c) { const f = this.options.loose ? n[i.COMPARATORLOOSE] : n[i.COMPARATOR], d = c.match(f); if (!d) throw new TypeError(`Invalid comparator: ${c}`); this.operator = d[1] !== void 0 ? d[1] : "", this.operator === "=" && (this.operator = ""), d[2] ? this.semver = new u(d[2], this.options.loose) : this.semver = e; } toString() { return this.value; } test(c) { if (o("Comparator.test", c, this.options.loose), this.semver === e || c === e) return !0; if (typeof c == "string") try { c = new u(c, this.options); } catch { return !1; } return s(c, this.operator, this.semver, this.options); } intersects(c, f) { if (!(c instanceof t)) throw new TypeError("a Comparator is required"); return this.operator === "" ? this.value === "" ? !0 : new l(c.value, f).test(this.value) : c.operator === "" ? c.value === "" ? !0 : new l(this.value, f).test(c.semver) : (f = r(f), f.includePrerelease && (this.value === "<0.0.0-0" || c.value === "<0.0.0-0") || !f.includePrerelease && (this.value.startsWith("<0.0.0") || c.value.startsWith("<0.0.0")) ? !1 : !!(this.operator.startsWith(">") && c.operator.startsWith(">") || this.operator.startsWith("<") && c.operator.startsWith("<") || this.semver.version === c.semver.version && this.operator.includes("=") && c.operator.includes("=") || s(this.semver, "<", c.semver, f) && this.operator.startsWith(">") && c.operator.startsWith("<") || s(this.semver, ">", c.semver, f) && this.operator.startsWith("<") && c.operator.startsWith(">"))); } } Cr = t; const r = qr, { safeRe: n, t: i } = Et, s = Wa, o = nr, u = yt, l = ie(); return Cr; } const za = ie(), Ja = (e, t, r) => { try { t = new za(t, r); } catch { return !1; } return t.test(e); }; var Za = Ja; ie(); ie(); ie(); ie(); ie(); const Qa = ir(), { ANY: Kh } = Qa; ie(); ie(); ie(); const Wr = ir(), { ANY: zh } = Wr; new Wr(">=0.0.0-0"); new Wr(">=0.0.0"); const wr = Et, Hn = rr, Bn = Ti, el = va, tl = xa; ir(); ie(); const rl = Za; var kr = { valid: el, major: tl, satisfies: rl, re: wr.re, src: wr.src, tokens: wr.t, SEMVER_SPEC_VERSION: Hn.SEMVER_SPEC_VERSION, RELEASE_TYPES: Hn.RELEASE_TYPES, compareIdentifiers: Bn.compareIdentifiers, rcompareIdentifiers: Bn.rcompareIdentifiers }, Qe = {}, Vr = { exports: {} }; const L = (...e) => e.every((t) => t) ? e.join("") : "", X = (e) => e ? encodeURIComponent(e) : "", xt = { sshtemplate: ({ domain: e, user: t, project: r, committish: n }) => `git@${e}:${t}/${r}.git${L("#", n)}`, sshurltemplate: ({ domain: e, user: t, project: r, committish: n }) => `git+ssh://git@${e}/${t}/${r}.git${L("#", n)}`, browsetemplate: ({ domain: e, user: t, project: r, committish: n, treepath: i }) => `https://${e}/${t}/${r}${L("/", i, "/", X(n))}`, browsefiletemplate: ({ domain: e, user: t, project: r, committish: n, treepath: i, path: s, fragment: o, hashformat: u }) => `https://${e}/${t}/${r}/${i}/${X(n || "master")}/${s}${L("#", u(o || ""))}`, docstemplate: ({ domain: e, user: t, project: r, treepath: n, committish: i }) => `https://${e}/${t}/${r}${L("/", n, "/", X(i))}#readme`, httpstemplate: ({ auth: e, domain: t, user: r, project: n, committish: i }) => `git+https://${L(e, "@")}${t}/${r}/${n}.git${L("#", i)}`, filetemplate: ({ domain: e, user: t, project: r, committish: n, path: i }) => `https://${e}/${t}/${r}/raw/${X(n) || "master"}/${i}`, shortcuttemplate: ({ type: e, user: t, project: r, committish: n }) => `${e}:${t}/${r}${L("#", n)}`, pathtemplate: ({ user: e, project: t, committish: r }) => `${e}/${t}${L("#", r)}`, bugstemplate: ({ domain: e, user: t, project: r }) => `https://${e}/${t}/${r}/issues`, hashformat: Ii }, ee = {}; ee.github = Object.assign({}, xt, { // First two are insecure and generally shouldn't be used any more, but // they are still supported. protocols: ["git:", "http:", "git+ssh:", "git+https:", "ssh:", "https:"], domain: "github.com", treepath: "tree", filetemplate: ({ auth: e, user: t, project: r, committish: n, path: i }) => `https://${L(e, "@")}raw.githubusercontent.com/${t}/${r}/${X(n) || "master"}/${i}`, gittemplate: ({ auth: e, domain: t, user: r, project: n, committish: i }) => `git://${L(e, "@")}${t}/${r}/${n}.git${L("#", i)}`, tarballtemplate: ({ domain: e, user: t, project: r, committish: n }) => `https://codeload.${e}/${t}/${r}/tar.gz/${X(n) || "master"}`, extract: (e) => { let [, t, r, n, i] = e.pathname.split("/", 5); if (!(n && n !== "tree") && (n || (i = e.hash.slice(1)), r && r.endsWith(".git") && (r = r.slice(0, -4)), !(!t || !r))) return { user: t, project: r, committish: i }; } }); ee.bitbucket = Object.assign({}, xt, { protocols: ["git+ssh:", "git+https:", "ssh:", "https:"], domain: "bitbucket.org", treepath: "src", tarballtemplate: ({ domain: e, user: t, project: r, committish: n }) => `https://${e}/${t}/${r}/get/${X(n) || "master"}.tar.gz`, extract: (e) => { let [, t, r, n] = e.pathname.split("/", 4); if (!["get"].includes(n) && (r && r.endsWith(".git") && (r = r.slice(0, -4)), !(!t || !r))) return { user: t, project: r, committish: e.hash.slice(1) }; } }); ee.gitlab = Object.assign({}, xt, { protocols: ["git+ssh:", "git+https:", "ssh:", "https:"], domain: "gitlab.com", treepath: "tree", httpstemplate: ({ auth: e, domain: t, user: r, project: n, committish: i }) => `git+https://${L(e, "@")}${t}/${r}/${n}.git${L("#", i)}`, tarballtemplate: ({ domain: e, user: t, project: r, committish: n }) => `https://${e}/${t}/${r}/repository/archive.tar.gz?ref=${X(n) || "master"}`, extract: (e) => { const t = e.pathname.slice(1); if (t.includes("/-/") || t.includes("/archive.tar.gz")) return; const r = t.split("/"); let n = r.pop(); n.endsWith(".git") && (n = n.slice(0, -4)); const i = r.join("/"); if (!(!i || !n)) return { user: i, project: n, committish: e.hash.slice(1) }; } }); ee.gist = Object.assign({}, xt, { protocols: ["git:", "git+ssh:", "git+https:", "ssh:", "https:"], domain: "gist.github.com", sshtemplate: ({ domain: e, project: t, committish: r }) => `git@${e}:${t}.git${L("#", r)}`, sshurltemplate: ({ domain: e, project: t, committish: r }) => `git+ssh://git@${e}/${t}.git${L("#", r)}`, browsetemplate: ({ domain: e, project: t, committish: r }) => `https://${e}/${t}${L("/", X(r))}`, browsefiletemplate: ({ domain: e, project: t, committish: r, path: n, hashformat: i }) => `https://${e}/${t}${L("/", X(r))}${L("#", i(n))}`, docstemplate: ({ domain: e, project: t, committish: r }) => `https://${e}/${t}${L("/", X(r))}`, httpstemplate: ({ domain: e, project: t, committish: r }) => `git+https://${e}/${t}.git${L("#", r)}`, filetemplate: ({ user: e, project: t, committish: r, path: n }) => `https://gist.githubusercontent.com/${e}/${t}/raw${L("/", X(r))}/${n}`, shortcuttemplate: ({ type: e, project: t, committish: r }) => `${e}:${t}${L("#", r)}`, pathtemplate: ({ project: e, committish: t }) => `${e}${L("#", t)}`, bugstemplate: ({ domain: e, project: t }) => `https://${e}/${t}`, gittemplate: ({ domain: e, project: t, committish: r }) => `git://${e}/${t}.git${L("#", r)}`, tarballtemplate: ({ project: e, committish: t }) => `https://codeload.github.com/gist/${e}/tar.gz/${X(t) || "master"}`, extract: (e) => { let [, t, r, n] = e.pathname.split("/", 4); if (n !== "raw") { if (!r) { if (!t) return; r = t, t = null; } return r.endsWith(".git") && (r = r.slice(0, -4)), { user: t, project: r, committish: e.hash.slice(1) }; } }, hashformat: function(e) { return e && "file-" + Ii(e); } }); ee.sourcehut = Object.assign({}, xt, { protocols: ["git+ssh:", "https:"], domain: "git.sr.ht", treepath: "tree", browsefiletemplate: ({ domain: e, user: t, project: r, committish: n, treepath: i, path: s, fragment: o, hashformat: u }) => `https://${e}/${t}/${r}/${i}/${X(n || "main")}/${s}${L("#", u(o || ""))}`, filetemplate: ({ domain: e, user: t, project: r, committish: n, path: i }) => `https://${e}/${t}/${r}/blob/${X(n) || "main"}/${i}`, httpstemplate: ({ domain: e, user: t, project: r, committish: n }) => `https://${e}/${t}/${r}.git${L("#", n)}`, tarballtemplate: ({ domain: e, user: t, project: r, committish: n }) => `https://${e}/${t}/${r}/archive/${X(n) || "main"}.tar.gz`, bugstemplate: ({ domain: e, user: t, project: r }) => `https://todo.sr.ht/${t}/${r}`, docstemplate: ({ domain: e, user: t, project: r, treepath: n, committish: i }) => `https://${e}/${t}/${r}${L("/", n, "/", X(i))}#readme`, extract: (e) => { let [, t, r, n] = e.pathname.split("/", 4); if (!["archive"].includes(n) && (r && r.endsWith(".git") && (r = r.slice(0, -4)), !(!t || !r))) return { user: t, project: r, committish: e.hash.slice(1) }; } }); const nl = Object.keys(ee); ee.byShortcut = {}; ee.byDomain = {}; for (const e of nl) ee.byShortcut[`${e}:`] = e, ee.byDomain[ee[e].domain] = e; function Ii(e) { return e.toLowerCase().replace(/^\W+|\/|\W+$/g, "").replace(/\W+/g, "-"); } var Ri = ee; const il = Ri; let sl = class { constructor(t, r, n, i, s, o, u = {}) { Object.assign(this, il[t]), this.type = t, this.user = r, this.auth = n, this.project = i, this.committish = s, this.default = o, this.opts = u; } hash() { return this.committish ? `#${this.committish}` : ""; } ssh(t) { return this._fill(this.sshtemplate, t); } _fill(t, r) { if (typeof t == "function") { const n = { ...this, ...this.opts, ...r }; n.path || (n.path = ""), n.path.startsWith("/") && (n.path = n.path.slice(1)), n.noCommittish && (n.committish = null); const i = t(n); return n.noGitPlus && i.startsWith("git+") ? i.slice(4) : i; } return null; } sshurl(t) { return this._fill(this.sshurltemplate, t); } browse(t, r, n) { return typeof t != "string" ? this._fill(this.browsetemplate, t) : (typeof r != "string" && (n = r, r = null), this._fill(this.browsefiletemplate, { ...n, fragment: r, path: t })); } docs(t) { return this._fill(this.docstemplate, t); } bugs(t) { return this._fill(this.bugstemplate, t); } https(t) { return this._fill(this.httpstemplate, t); } git(t) { return this._fill(this.gittemplate, t); } shortcut(t) { return this._fill(this.shortcuttemplate, t); } path(t) { return this._fill(this.pathtemplate, t); } tarball(t) { return this._fill(this.tarballtemplate, { ...t, noCommittish: !1 }); } file(t, r) { return this._fill(this.filetemplate, { ...r, path: t }); } getDefaultRepresentation() { return this.default; } toString(t) { return this.default && typeof this[this.default] == "function" ? this[this.default](t) : this.sshurl(t); } }; var ol = sl, Or, Yn; function al() { return Yn || (Yn = 1, Or = function(e) { e.prototype[Symbol.iterator] = function* () { for (let t = this.head; t; t = t.next) yield t.value; }; }), Or; } var ll = R; R.Node = Le; R.create = R; function R(e) { var t = this; if (t instanceof R || (t = new R()), t.tail = null, t.head = null, t.length = 0, e && typeof e.forEach == "function") e.forEach(function(i) { t.push(i); }); else if (arguments.length > 0) for (var r = 0, n = arguments.length; r < n; r++) t.push(arguments[r]); return t; } R.prototype.removeNode = function(e) { if (e.list !== this) throw new Error("removing node which does not belong to this list"); var t = e.next, r = e.prev; return t && (t.prev = r), r && (r.next = t), e === this.head && (this.head = t), e === this.tail && (this.tail = r), e.list.length--, e.next = null, e.prev = null, e.list = null, t; }; R.prototype.unshiftNode = function(e) { if (e !== this.head) { e.list && e.list.removeNode(e); var t = this.head; e.list = this, e.next = t, t && (t.prev = e), this.head = e, this.tail || (this.tail = e), this.length++; } }; R.prototype.pushNode = function(e) { if (e !== this.tail) { e.list && e.list.removeNode(e); var t = this.tail; e.list = this, e.prev = t, t && (t.next = e), this.tail = e, this.head || (this.head = e), this.length++; } }; R.prototype.push = function() { for (var e = 0, t = arguments.length; e < t; e++) ul(this, arguments[e]); return this.length; }; R.prototype.unshift = function() { for (var e = 0, t = arguments.length; e < t; e++) fl(this, arguments[e]); return this.length; }; R.prototype.pop = function() { if (this.tail) { var e = this.tail.value; return this.tail = this.tail.prev, this.tail ? this.tail.next = null : this.head = null, this.length--, e; } }; R.prototype.shift = function() { if (this.head) { var e = this.head.value; return this.head = this.head.next, this.head ? this.head.prev = null : this.tail = null, this.length--, e; } }; R.prototype.forEach = function(e, t) { t = t || this; for (var r = this.head, n = 0; r !== null; n++) e.call(t, r.value, n, this), r = r.next; }; R.prototype.forEachReverse = function(e, t) { t = t || this; for (var r = this.tail, n = this.length - 1; r !== null; n--) e.call(t, r.value, n, this), r = r.prev; }; R.prototype.get = function(e) { for (var t = 0, r = this.head; r !== null && t < e; t++) r = r.next; if (t === e && r !== null) return r.value; }; R.prototype.getReverse = function(e) { for (var t = 0, r = this.tail; r !== null && t < e; t++) r = r.prev; if (t === e && r !== null) return r.value; }; R.prototype.map = function(e, t) { t = t || this; for (var r = new R(), n = this.head; n !== null; ) r.push(e.call(t, n.value, this)), n = n.next; return r; }; R.prototype.mapReverse = function(e, t) { t = t || this; for (var r = new R(), n = this.tail; n !== null; ) r.push(e.call(t, n.value, this)), n = n.prev; return r; }; R.prototype.reduce = function(e, t) { var r, n = this.head; if (arguments.length > 1) r = t; else if (this.head) n = this.head.next, r = this.head.value; else throw new TypeError("Reduce of empty list with no initial value"); for (var i = 0; n !== null; i++) r = e(r, n.value, i), n = n.next; return r; }; R.prototype.reduceReverse = function(e, t) { var r, n = this.tail; if (arguments.length > 1) r = t; else if (this.tail) n = this.tail.prev, r = this.tail.value; else throw new TypeError("Reduce of empty list with no initial value"); for (var i = this.length - 1; n !== null; i--) r = e(r, n.value, i), n = n.prev; return r; }; R.prototype.toArray = function() { for (var e = new Array(this.length), t = 0, r = this.head; r !== null; t++) e[t] = r.value, r = r.next; return e; }; R.prototype.toArrayReverse = function() { for (var e = new Array(this.length), t = 0, r = this.tail; r !== null; t++) e[t] = r.value, r = r.prev; return e; }; R.prototype.slice = function(e, t) { t = t || this.length, t < 0 && (t += this.length), e = e || 0, e < 0 && (e += this.length); var r = new R(); if (t < e || t < 0) return r; e < 0 && (e = 0), t > this.length && (t = this.length); for (var n = 0, i = this.head; i !== null && n < e; n++) i = i.next; for (; i !== null && n < t; n++, i = i.next) r.push(i.value); return r; }; R.prototype.sliceReverse = function(e, t) { t = t || this.length, t < 0 && (t += this.length), e = e || 0, e < 0 && (e += this.length); var r = new R(); if (t < e || t < 0) return r; e < 0 && (e = 0), t > this.length && (t = this.length); for (var n = this.length, i = this.tail; i !== null && n > t; n--) i = i.prev; for (; i !== null && n > e; n--, i = i.prev) r.push(i.value); return r; }; R.prototype.splice = function(e, t, ...r) { e > this.length && (e = this.length - 1), e < 0 && (e = this.length + e); for (var n = 0, i = this.head; i !== null && n < e; n++) i = i.next; for (var s = [], n = 0; i && n < t; n++) s.push(i.value), i = this.removeNode(i); i === null && (i = this.tail), i !== this.head && i !== this.tail && (i = i.prev); for (var n = 0; n < r.length; n++) i = cl(this, i, r[n]); return s; }; R.prototype.reverse = function() { for (var e = this.head, t = this.tail, r = e; r !== null; r = r.prev) { var n = r.prev; r.prev = r.next, r.next = n; } return this.head = t, this.tail = e, this; }; function cl(e, t, r) { var n = t === e.head ? new Le(r, null, t, e) : new Le(r, t, t.next, e); return n.next === null && (e.tail = n), n.prev === null && (e.head = n), e.length++, n; } function ul(e, t) { e.tail = new Le(t, e.tail, null, e), e.head || (e.head = e.tail), e.length++; } function fl(e, t) { e.head = new Le(t, null, e.head, e), e.tail || (e.tail = e.head), e.length++; } function Le(e, t, r, n) { if (!(this instanceof Le)) return new Le(e, t, r, n); this.list = n, this.value = e, t ? (t.next = this, this.prev = t) : this.prev = null, r ? (r.prev = this, this.next = r) : this.next = null; } try { al()(R); } catch { } const hl = ll, _e = Symbol("max"), pe = Symbol("length"), Be = Symbol("lengthCalculator"), pt = Symbol("allowStale"), Ie = Symbol("maxAge"), fe = Symbol("dispose"), Xn = Symbol("noDisposeOnSet"), k = Symbol("lruList"), re = Symbol("cache"), Fi = Symbol("updateAgeOnGet"), Sr = () => 1; let pl = class { constructor(t) { if (typeof t == "number" && (t = { max: t }), t || (t = {}), t.max && (typeof t.max != "number" || t.max < 0)) throw new TypeError("max must be a non-negative number"); this[_e] = t.max || 1 / 0; const r = t.length || Sr; if (this[Be] = typeof r != "function" ? Sr : r, this[pt] = t.stale || !1, t.maxAge && typeof t.maxAge != "number") throw new TypeError("maxAge must be a number"); this[Ie] = t.maxAge || 0, this[fe] = t.dispose, this[Xn] = t.noDisposeOnSet || !1, this[Fi] = t.updateAgeOnGet || !1, this.reset(); } // resize the cache when the max changes. set max(t) { if (typeof t != "number" || t < 0) throw new TypeError("max must be a non-negative number"); this[_e] = t || 1 / 0, ct(this); } get max() { return this[_e]; } set allowStale(t) { this[pt] = !!t; } get allowStale() { return this[pt]; } set maxAge(t) { if (typeof t != "number") throw new TypeError("maxAge must be a non-negative number"); this[Ie] = t, ct(this); } get maxAge() { return this[Ie]; } // resize the cache when the lengthCalculator changes. set lengthCalculator(t) { typeof t != "function" && (t = Sr), t !== this[Be] && (this[Be] = t, this[pe] = 0, this[k].forEach((r) => { r.length = this[Be](r.value, r.key), this[pe] += r.length; })), ct(this); } get lengthCalculator() { return this[Be]; } get length() { return this[pe]; } get itemCount() { return this[k].length; } rforEach(t, r) { r = r || this; for (let n = this[k].tail; n !== null; ) { const i = n.prev; qn(this, t, n, r), n = i; } } forEach(t, r) { r = r || this; for (let n = this[k].head; n !== null; ) { const i = n.next; qn(this, t, n, r), n = i; } } keys() { return this[k].toArray().map((t) => t.key); } values() { return this[k].toArray().map((t) => t.value); } reset() { this[fe] && this[k] && this[k].length && this[k].forEach((t) => this[fe](t.key, t.value)), this[re] = /* @__PURE__ */ new Map(), this[k] = new hl(), this[pe] = 0; } dump() { return this[k].map((t) => Wt(this, t) ? !1 : { k: t.key, v: t.value, e: t.now + (t.maxAge || 0) }).toArray().filter((t) => t); } dumpLru() { return this[k]; } set(t, r, n) { if (n = n || this[Ie], n && typeof n != "number") throw new TypeError("maxAg