storybook
Version:
Storybook: Develop, document, and test UI components in isolation
1,165 lines (1,152 loc) • 179 kB
JavaScript
import CJS_COMPAT_NODE_URL_yr66iw5gef from 'node:url';
import CJS_COMPAT_NODE_PATH_yr66iw5gef from 'node:path';
import CJS_COMPAT_NODE_MODULE_yr66iw5gef from "node:module";
var __filename = CJS_COMPAT_NODE_URL_yr66iw5gef.fileURLToPath(import.meta.url);
var __dirname = CJS_COMPAT_NODE_PATH_yr66iw5gef.dirname(__filename);
var require = CJS_COMPAT_NODE_MODULE_yr66iw5gef.createRequire(import.meta.url);
// ------------------------------------------------------------
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
// ------------------------------------------------------------
import {
__commonJS,
__toESM
} from "./chunk-J4VC4I2M.js";
// ../node_modules/balanced-match/index.js
var require_balanced_match = __commonJS({
"../node_modules/balanced-match/index.js"(exports, module) {
"use strict";
module.exports = balanced;
function balanced(a, b, str) {
a instanceof RegExp && (a = maybeMatch(a, str)), b instanceof RegExp && (b = maybeMatch(b, str));
var r = range(a, b, str);
return r && {
start: r[0],
end: r[1],
pre: str.slice(0, r[0]),
body: str.slice(r[0] + a.length, r[1]),
post: str.slice(r[1] + b.length)
};
}
function maybeMatch(reg, str) {
var m = str.match(reg);
return m ? m[0] : null;
}
balanced.range = range;
function range(a, b, str) {
var begs, beg, left, right, result, ai = str.indexOf(a), bi = str.indexOf(b, ai + 1), i = ai;
if (ai >= 0 && bi > 0) {
if (a === b)
return [ai, bi];
for (begs = [], left = str.length; i >= 0 && !result; )
i == ai ? (begs.push(i), ai = str.indexOf(a, i + 1)) : begs.length == 1 ? result = [begs.pop(), bi] : (beg = begs.pop(), beg < left && (left = beg, right = bi), bi = str.indexOf(b, i + 1)), i = ai < bi && ai >= 0 ? ai : bi;
begs.length && (result = [left, right]);
}
return result;
}
}
});
// ../node_modules/brace-expansion/index.js
var require_brace_expansion = __commonJS({
"../node_modules/brace-expansion/index.js"(exports, module) {
var balanced = require_balanced_match();
module.exports = expandTop;
var escSlash = "\0SLASH" + Math.random() + "\0", escOpen = "\0OPEN" + Math.random() + "\0", escClose = "\0CLOSE" + Math.random() + "\0", escComma = "\0COMMA" + Math.random() + "\0", escPeriod = "\0PERIOD" + Math.random() + "\0";
function numeric(str) {
return parseInt(str, 10) == str ? parseInt(str, 10) : str.charCodeAt(0);
}
function escapeBraces(str) {
return str.split("\\\\").join(escSlash).split("\\{").join(escOpen).split("\\}").join(escClose).split("\\,").join(escComma).split("\\.").join(escPeriod);
}
function unescapeBraces(str) {
return str.split(escSlash).join("\\").split(escOpen).join("{").split(escClose).join("}").split(escComma).join(",").split(escPeriod).join(".");
}
function parseCommaParts(str) {
if (!str)
return [""];
var parts = [], m = balanced("{", "}", str);
if (!m)
return str.split(",");
var pre = m.pre, body = m.body, post = m.post, p = pre.split(",");
p[p.length - 1] += "{" + body + "}";
var postParts = parseCommaParts(post);
return post.length && (p[p.length - 1] += postParts.shift(), p.push.apply(p, postParts)), parts.push.apply(parts, p), parts;
}
function expandTop(str) {
return str ? (str.substr(0, 2) === "{}" && (str = "\\{\\}" + str.substr(2)), expand2(escapeBraces(str), !0).map(unescapeBraces)) : [];
}
function embrace(str) {
return "{" + str + "}";
}
function isPadded(el) {
return /^-?0\d/.test(el);
}
function lte(i, y) {
return i <= y;
}
function gte(i, y) {
return i >= y;
}
function expand2(str, isTop) {
var expansions = [], m = balanced("{", "}", str);
if (!m) return [str];
var pre = m.pre, post = m.post.length ? expand2(m.post, !1) : [""];
if (/\$$/.test(m.pre))
for (var k = 0; k < post.length; k++) {
var expansion = pre + "{" + m.body + "}" + post[k];
expansions.push(expansion);
}
else {
var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body), isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body), isSequence = isNumericSequence || isAlphaSequence, isOptions = m.body.indexOf(",") >= 0;
if (!isSequence && !isOptions)
return m.post.match(/,(?!,).*\}/) ? (str = m.pre + "{" + m.body + escClose + m.post, expand2(str)) : [str];
var n;
if (isSequence)
n = m.body.split(/\.\./);
else if (n = parseCommaParts(m.body), n.length === 1 && (n = expand2(n[0], !1).map(embrace), n.length === 1))
return post.map(function(p) {
return m.pre + n[0] + p;
});
var N;
if (isSequence) {
var x = numeric(n[0]), y = numeric(n[1]), width = Math.max(n[0].length, n[1].length), incr = n.length == 3 ? Math.abs(numeric(n[2])) : 1, test = lte, reverse = y < x;
reverse && (incr *= -1, test = gte);
var pad = n.some(isPadded);
N = [];
for (var i = x; test(i, y); i += incr) {
var c;
if (isAlphaSequence)
c = String.fromCharCode(i), c === "\\" && (c = "");
else if (c = String(i), pad) {
var need = width - c.length;
if (need > 0) {
var z = new Array(need + 1).join("0");
i < 0 ? c = "-" + z + c.slice(1) : c = z + c;
}
}
N.push(c);
}
} else {
N = [];
for (var j = 0; j < n.length; j++)
N.push.apply(N, expand2(n[j], !1));
}
for (var j = 0; j < N.length; j++)
for (var k = 0; k < post.length; k++) {
var expansion = pre + N[j] + post[k];
(!isTop || isSequence || expansion) && expansions.push(expansion);
}
}
return expansions;
}
}
});
// ../node_modules/glob/node_modules/minimatch/dist/esm/index.js
var import_brace_expansion = __toESM(require_brace_expansion(), 1);
// ../node_modules/glob/node_modules/minimatch/dist/esm/assert-valid-pattern.js
var assertValidPattern = (pattern) => {
if (typeof pattern != "string")
throw new TypeError("invalid pattern");
if (pattern.length > 65536)
throw new TypeError("pattern is too long");
};
// ../node_modules/glob/node_modules/minimatch/dist/esm/brace-expressions.js
var posixClasses = {
"[: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]
}, braceEscape = (s) => s.replace(/[[\]\\-]/g, "\\$&"), regexpEscape = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), rangesToString = (ranges) => ranges.join(""), parseClass = (glob2, position) => {
let pos = position;
if (glob2.charAt(pos) !== "[")
throw new Error("not in a brace expression");
let ranges = [], negs = [], i = pos + 1, sawStart = !1, uflag = !1, escaping = !1, negate = !1, endPos = pos, rangeStart = "";
WHILE: for (; i < glob2.length; ) {
let c = glob2.charAt(i);
if ((c === "!" || c === "^") && i === pos + 1) {
negate = !0, i++;
continue;
}
if (c === "]" && sawStart && !escaping) {
endPos = i + 1;
break;
}
if (sawStart = !0, c === "\\" && !escaping) {
escaping = !0, i++;
continue;
}
if (c === "[" && !escaping) {
for (let [cls, [unip, u, neg]] of Object.entries(posixClasses))
if (glob2.startsWith(cls, i)) {
if (rangeStart)
return ["$.", !1, glob2.length - pos, !0];
i += cls.length, neg ? negs.push(unip) : ranges.push(unip), uflag = uflag || u;
continue WHILE;
}
}
if (escaping = !1, rangeStart) {
c > rangeStart ? ranges.push(braceEscape(rangeStart) + "-" + braceEscape(c)) : c === rangeStart && ranges.push(braceEscape(c)), rangeStart = "", i++;
continue;
}
if (glob2.startsWith("-]", i + 1)) {
ranges.push(braceEscape(c + "-")), i += 2;
continue;
}
if (glob2.startsWith("-", i + 1)) {
rangeStart = c, i += 2;
continue;
}
ranges.push(braceEscape(c)), i++;
}
if (endPos < i)
return ["", !1, 0, !1];
if (!ranges.length && !negs.length)
return ["$.", !1, glob2.length - pos, !0];
if (negs.length === 0 && ranges.length === 1 && /^\\?.$/.test(ranges[0]) && !negate) {
let r = ranges[0].length === 2 ? ranges[0].slice(-1) : ranges[0];
return [regexpEscape(r), !1, endPos - pos, !1];
}
let sranges = "[" + (negate ? "^" : "") + rangesToString(ranges) + "]", snegs = "[" + (negate ? "" : "^") + rangesToString(negs) + "]";
return [ranges.length && negs.length ? "(" + sranges + "|" + snegs + ")" : ranges.length ? sranges : snegs, uflag, endPos - pos, !0];
};
// ../node_modules/glob/node_modules/minimatch/dist/esm/unescape.js
var unescape = (s, { windowsPathsNoEscape = !1 } = {}) => windowsPathsNoEscape ? s.replace(/\[([^\/\\])\]/g, "$1") : s.replace(/((?!\\).|^)\[([^\/\\])\]/g, "$1$2").replace(/\\([^\/])/g, "$1");
// ../node_modules/glob/node_modules/minimatch/dist/esm/ast.js
var types = /* @__PURE__ */ new Set(["!", "?", "+", "*", "@"]), isExtglobType = (c) => types.has(c), startNoTraversal = "(?!(?:^|/)\\.\\.?(?:$|/))", startNoDot = "(?!\\.)", addPatternStart = /* @__PURE__ */ new Set(["[", "."]), justDots = /* @__PURE__ */ new Set(["..", "."]), reSpecials = new Set("().*{}+?[]^$\\!"), regExpEscape = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), qmark = "[^/]", star = qmark + "*?", starNoEmpty = qmark + "+?", AST = class _AST {
type;
#root;
#hasMagic;
#uflag = !1;
#parts = [];
#parent;
#parentIndex;
#negs;
#filledNegs = !1;
#options;
#toString;
// set to true if it's an extglob with no children
// (which really means one child of '')
#emptyExt = !1;
constructor(type, parent, options = {}) {
this.type = type, type && (this.#hasMagic = !0), this.#parent = parent, this.#root = this.#parent ? this.#parent.#root : this, this.#options = this.#root === this ? options : this.#root.#options, this.#negs = this.#root === this ? [] : this.#root.#negs, type === "!" && !this.#root.#filledNegs && this.#negs.push(this), this.#parentIndex = this.#parent ? this.#parent.#parts.length : 0;
}
get hasMagic() {
if (this.#hasMagic !== void 0)
return this.#hasMagic;
for (let p of this.#parts)
if (typeof p != "string" && (p.type || p.hasMagic))
return this.#hasMagic = !0;
return this.#hasMagic;
}
// reconstructs the pattern
toString() {
return this.#toString !== void 0 ? this.#toString : this.type ? this.#toString = this.type + "(" + this.#parts.map((p) => String(p)).join("|") + ")" : this.#toString = this.#parts.map((p) => String(p)).join("");
}
#fillNegs() {
if (this !== this.#root)
throw new Error("should only call on root");
if (this.#filledNegs)
return this;
this.toString(), this.#filledNegs = !0;
let n;
for (; n = this.#negs.pop(); ) {
if (n.type !== "!")
continue;
let p = n, pp = p.#parent;
for (; pp; ) {
for (let i = p.#parentIndex + 1; !pp.type && i < pp.#parts.length; i++)
for (let part of n.#parts) {
if (typeof part == "string")
throw new Error("string part in extglob AST??");
part.copyIn(pp.#parts[i]);
}
p = pp, pp = p.#parent;
}
}
return this;
}
push(...parts) {
for (let p of parts)
if (p !== "") {
if (typeof p != "string" && !(p instanceof _AST && p.#parent === this))
throw new Error("invalid part: " + p);
this.#parts.push(p);
}
}
toJSON() {
let ret = this.type === null ? this.#parts.slice().map((p) => typeof p == "string" ? p : p.toJSON()) : [this.type, ...this.#parts.map((p) => p.toJSON())];
return this.isStart() && !this.type && ret.unshift([]), this.isEnd() && (this === this.#root || this.#root.#filledNegs && this.#parent?.type === "!") && ret.push({}), ret;
}
isStart() {
if (this.#root === this)
return !0;
if (!this.#parent?.isStart())
return !1;
if (this.#parentIndex === 0)
return !0;
let p = this.#parent;
for (let i = 0; i < this.#parentIndex; i++) {
let pp = p.#parts[i];
if (!(pp instanceof _AST && pp.type === "!"))
return !1;
}
return !0;
}
isEnd() {
if (this.#root === this || this.#parent?.type === "!")
return !0;
if (!this.#parent?.isEnd())
return !1;
if (!this.type)
return this.#parent?.isEnd();
let pl = this.#parent ? this.#parent.#parts.length : 0;
return this.#parentIndex === pl - 1;
}
copyIn(part) {
typeof part == "string" ? this.push(part) : this.push(part.clone(this));
}
clone(parent) {
let c = new _AST(this.type, parent);
for (let p of this.#parts)
c.copyIn(p);
return c;
}
static #parseAST(str, ast, pos, opt) {
let escaping = !1, inBrace = !1, braceStart = -1, braceNeg = !1;
if (ast.type === null) {
let i2 = pos, acc2 = "";
for (; i2 < str.length; ) {
let c = str.charAt(i2++);
if (escaping || c === "\\") {
escaping = !escaping, acc2 += c;
continue;
}
if (inBrace) {
i2 === braceStart + 1 ? (c === "^" || c === "!") && (braceNeg = !0) : c === "]" && !(i2 === braceStart + 2 && braceNeg) && (inBrace = !1), acc2 += c;
continue;
} else if (c === "[") {
inBrace = !0, braceStart = i2, braceNeg = !1, acc2 += c;
continue;
}
if (!opt.noext && isExtglobType(c) && str.charAt(i2) === "(") {
ast.push(acc2), acc2 = "";
let ext2 = new _AST(c, ast);
i2 = _AST.#parseAST(str, ext2, i2, opt), ast.push(ext2);
continue;
}
acc2 += c;
}
return ast.push(acc2), i2;
}
let i = pos + 1, part = new _AST(null, ast), parts = [], acc = "";
for (; i < str.length; ) {
let c = str.charAt(i++);
if (escaping || c === "\\") {
escaping = !escaping, acc += c;
continue;
}
if (inBrace) {
i === braceStart + 1 ? (c === "^" || c === "!") && (braceNeg = !0) : c === "]" && !(i === braceStart + 2 && braceNeg) && (inBrace = !1), acc += c;
continue;
} else if (c === "[") {
inBrace = !0, braceStart = i, braceNeg = !1, acc += c;
continue;
}
if (isExtglobType(c) && str.charAt(i) === "(") {
part.push(acc), acc = "";
let ext2 = new _AST(c, part);
part.push(ext2), i = _AST.#parseAST(str, ext2, i, opt);
continue;
}
if (c === "|") {
part.push(acc), acc = "", parts.push(part), part = new _AST(null, ast);
continue;
}
if (c === ")")
return acc === "" && ast.#parts.length === 0 && (ast.#emptyExt = !0), part.push(acc), acc = "", ast.push(...parts, part), i;
acc += c;
}
return ast.type = null, ast.#hasMagic = void 0, ast.#parts = [str.substring(pos - 1)], i;
}
static fromGlob(pattern, options = {}) {
let ast = new _AST(null, void 0, options);
return _AST.#parseAST(pattern, ast, 0, options), ast;
}
// returns the regular expression if there's magic, or the unescaped
// string if not.
toMMPattern() {
if (this !== this.#root)
return this.#root.toMMPattern();
let glob2 = this.toString(), [re, body, hasMagic2, uflag] = this.toRegExpSource();
if (!(hasMagic2 || this.#hasMagic || this.#options.nocase && !this.#options.nocaseMagicOnly && glob2.toUpperCase() !== glob2.toLowerCase()))
return body;
let flags = (this.#options.nocase ? "i" : "") + (uflag ? "u" : "");
return Object.assign(new RegExp(`^${re}$`, flags), {
_src: re,
_glob: glob2
});
}
get options() {
return this.#options;
}
// returns the string match, the regexp source, whether there's magic
// in the regexp (so a regular expression is required) and whether or
// not the uflag is needed for the regular expression (for posix classes)
// TODO: instead of injecting the start/end at this point, just return
// the BODY of the regexp, along with the start/end portions suitable
// for binding the start/end in either a joined full-path makeRe context
// (where we bind to (^|/), or a standalone matchPart context (where
// we bind to ^, and not /). Otherwise slashes get duped!
//
// In part-matching mode, the start is:
// - if not isStart: nothing
// - if traversal possible, but not allowed: ^(?!\.\.?$)
// - if dots allowed or not possible: ^
// - if dots possible and not allowed: ^(?!\.)
// end is:
// - if not isEnd(): nothing
// - else: $
//
// In full-path matching mode, we put the slash at the START of the
// pattern, so start is:
// - if first pattern: same as part-matching mode
// - if not isStart(): nothing
// - if traversal possible, but not allowed: /(?!\.\.?(?:$|/))
// - if dots allowed or not possible: /
// - if dots possible and not allowed: /(?!\.)
// end is:
// - if last pattern, same as part-matching mode
// - else nothing
//
// Always put the (?:$|/) on negated tails, though, because that has to be
// there to bind the end of the negated pattern portion, and it's easier to
// just stick it in now rather than try to inject it later in the middle of
// the pattern.
//
// We can just always return the same end, and leave it up to the caller
// to know whether it's going to be used joined or in parts.
// And, if the start is adjusted slightly, can do the same there:
// - if not isStart: nothing
// - if traversal possible, but not allowed: (?:/|^)(?!\.\.?$)
// - if dots allowed or not possible: (?:/|^)
// - if dots possible and not allowed: (?:/|^)(?!\.)
//
// But it's better to have a simpler binding without a conditional, for
// performance, so probably better to return both start options.
//
// Then the caller just ignores the end if it's not the first pattern,
// and the start always gets applied.
//
// But that's always going to be $ if it's the ending pattern, or nothing,
// so the caller can just attach $ at the end of the pattern when building.
//
// So the todo is:
// - better detect what kind of start is needed
// - return both flavors of starting pattern
// - attach $ at the end of the pattern when creating the actual RegExp
//
// Ah, but wait, no, that all only applies to the root when the first pattern
// is not an extglob. If the first pattern IS an extglob, then we need all
// that dot prevention biz to live in the extglob portions, because eg
// +(*|.x*) can match .xy but not .yx.
//
// So, return the two flavors if it's #root and the first child is not an
// AST, otherwise leave it to the child AST to handle it, and there,
// use the (?:^|/) style of start binding.
//
// Even simplified further:
// - Since the start for a join is eg /(?!\.) and the start for a part
// is ^(?!\.), we can just prepend (?!\.) to the pattern (either root
// or start or whatever) and prepend ^ or / at the Regexp construction.
toRegExpSource(allowDot) {
let dot = allowDot ?? !!this.#options.dot;
if (this.#root === this && this.#fillNegs(), !this.type) {
let noEmpty = this.isStart() && this.isEnd(), src = this.#parts.map((p) => {
let [re, _, hasMagic2, uflag] = typeof p == "string" ? _AST.#parseGlob(p, this.#hasMagic, noEmpty) : p.toRegExpSource(allowDot);
return this.#hasMagic = this.#hasMagic || hasMagic2, this.#uflag = this.#uflag || uflag, re;
}).join(""), start2 = "";
if (this.isStart() && typeof this.#parts[0] == "string" && !(this.#parts.length === 1 && justDots.has(this.#parts[0]))) {
let aps = addPatternStart, needNoTrav = (
// dots are allowed, and the pattern starts with [ or .
dot && aps.has(src.charAt(0)) || // the pattern starts with \., and then [ or .
src.startsWith("\\.") && aps.has(src.charAt(2)) || // the pattern starts with \.\., and then [ or .
src.startsWith("\\.\\.") && aps.has(src.charAt(4))
), needNoDot = !dot && !allowDot && aps.has(src.charAt(0));
start2 = needNoTrav ? startNoTraversal : needNoDot ? startNoDot : "";
}
let end = "";
return this.isEnd() && this.#root.#filledNegs && this.#parent?.type === "!" && (end = "(?:$|\\/)"), [
start2 + src + end,
unescape(src),
this.#hasMagic = !!this.#hasMagic,
this.#uflag
];
}
let repeated = this.type === "*" || this.type === "+", start = this.type === "!" ? "(?:(?!(?:" : "(?:", body = this.#partsToRegExp(dot);
if (this.isStart() && this.isEnd() && !body && this.type !== "!") {
let s = this.toString();
return this.#parts = [s], this.type = null, this.#hasMagic = void 0, [s, unescape(this.toString()), !1, !1];
}
let bodyDotAllowed = !repeated || allowDot || dot || !startNoDot ? "" : this.#partsToRegExp(!0);
bodyDotAllowed === body && (bodyDotAllowed = ""), bodyDotAllowed && (body = `(?:${body})(?:${bodyDotAllowed})*?`);
let final = "";
if (this.type === "!" && this.#emptyExt)
final = (this.isStart() && !dot ? startNoDot : "") + starNoEmpty;
else {
let close = this.type === "!" ? (
// !() must match something,but !(x) can match ''
"))" + (this.isStart() && !dot && !allowDot ? startNoDot : "") + star + ")"
) : this.type === "@" ? ")" : this.type === "?" ? ")?" : this.type === "+" && bodyDotAllowed ? ")" : this.type === "*" && bodyDotAllowed ? ")?" : `)${this.type}`;
final = start + body + close;
}
return [
final,
unescape(body),
this.#hasMagic = !!this.#hasMagic,
this.#uflag
];
}
#partsToRegExp(dot) {
return this.#parts.map((p) => {
if (typeof p == "string")
throw new Error("string type in extglob ast??");
let [re, _, _hasMagic, uflag] = p.toRegExpSource(dot);
return this.#uflag = this.#uflag || uflag, re;
}).filter((p) => !(this.isStart() && this.isEnd()) || !!p).join("|");
}
static #parseGlob(glob2, hasMagic2, noEmpty = !1) {
let escaping = !1, re = "", uflag = !1;
for (let i = 0; i < glob2.length; i++) {
let c = glob2.charAt(i);
if (escaping) {
escaping = !1, re += (reSpecials.has(c) ? "\\" : "") + c;
continue;
}
if (c === "\\") {
i === glob2.length - 1 ? re += "\\\\" : escaping = !0;
continue;
}
if (c === "[") {
let [src, needUflag, consumed, magic] = parseClass(glob2, i);
if (consumed) {
re += src, uflag = uflag || needUflag, i += consumed - 1, hasMagic2 = hasMagic2 || magic;
continue;
}
}
if (c === "*") {
noEmpty && glob2 === "*" ? re += starNoEmpty : re += star, hasMagic2 = !0;
continue;
}
if (c === "?") {
re += qmark, hasMagic2 = !0;
continue;
}
re += regExpEscape(c);
}
return [re, unescape(glob2), !!hasMagic2, uflag];
}
};
// ../node_modules/glob/node_modules/minimatch/dist/esm/escape.js
var escape = (s, { windowsPathsNoEscape = !1 } = {}) => windowsPathsNoEscape ? s.replace(/[?*()[\]]/g, "[$&]") : s.replace(/[?*()[\]\\]/g, "\\$&");
// ../node_modules/glob/node_modules/minimatch/dist/esm/index.js
var minimatch = (p, pattern, options = {}) => (assertValidPattern(pattern), !options.nocomment && pattern.charAt(0) === "#" ? !1 : new Minimatch(pattern, options).match(p)), starDotExtRE = /^\*+([^+@!?\*\[\(]*)$/, starDotExtTest = (ext2) => (f) => !f.startsWith(".") && f.endsWith(ext2), starDotExtTestDot = (ext2) => (f) => f.endsWith(ext2), starDotExtTestNocase = (ext2) => (ext2 = ext2.toLowerCase(), (f) => !f.startsWith(".") && f.toLowerCase().endsWith(ext2)), starDotExtTestNocaseDot = (ext2) => (ext2 = ext2.toLowerCase(), (f) => f.toLowerCase().endsWith(ext2)), starDotStarRE = /^\*+\.\*+$/, starDotStarTest = (f) => !f.startsWith(".") && f.includes("."), starDotStarTestDot = (f) => f !== "." && f !== ".." && f.includes("."), dotStarRE = /^\.\*+$/, dotStarTest = (f) => f !== "." && f !== ".." && f.startsWith("."), starRE = /^\*+$/, starTest = (f) => f.length !== 0 && !f.startsWith("."), starTestDot = (f) => f.length !== 0 && f !== "." && f !== "..", qmarksRE = /^\?+([^+@!?\*\[\(]*)?$/, qmarksTestNocase = ([$0, ext2 = ""]) => {
let noext = qmarksTestNoExt([$0]);
return ext2 ? (ext2 = ext2.toLowerCase(), (f) => noext(f) && f.toLowerCase().endsWith(ext2)) : noext;
}, qmarksTestNocaseDot = ([$0, ext2 = ""]) => {
let noext = qmarksTestNoExtDot([$0]);
return ext2 ? (ext2 = ext2.toLowerCase(), (f) => noext(f) && f.toLowerCase().endsWith(ext2)) : noext;
}, qmarksTestDot = ([$0, ext2 = ""]) => {
let noext = qmarksTestNoExtDot([$0]);
return ext2 ? (f) => noext(f) && f.endsWith(ext2) : noext;
}, qmarksTest = ([$0, ext2 = ""]) => {
let noext = qmarksTestNoExt([$0]);
return ext2 ? (f) => noext(f) && f.endsWith(ext2) : noext;
}, qmarksTestNoExt = ([$0]) => {
let len = $0.length;
return (f) => f.length === len && !f.startsWith(".");
}, qmarksTestNoExtDot = ([$0]) => {
let len = $0.length;
return (f) => f.length === len && f !== "." && f !== "..";
}, defaultPlatform = typeof process == "object" && process ? typeof process.env == "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix", path = {
win32: { sep: "\\" },
posix: { sep: "/" }
}, sep = defaultPlatform === "win32" ? path.win32.sep : path.posix.sep;
minimatch.sep = sep;
var GLOBSTAR = Symbol("globstar **");
minimatch.GLOBSTAR = GLOBSTAR;
var qmark2 = "[^/]", star2 = qmark2 + "*?", twoStarDot = "(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?", twoStarNoDot = "(?:(?!(?:\\/|^)\\.).)*?", filter = (pattern, options = {}) => (p) => minimatch(p, pattern, options);
minimatch.filter = filter;
var ext = (a, b = {}) => Object.assign({}, a, b), defaults = (def) => {
if (!def || typeof def != "object" || !Object.keys(def).length)
return minimatch;
let orig = minimatch;
return Object.assign((p, pattern, options = {}) => orig(p, pattern, ext(def, options)), {
Minimatch: class extends orig.Minimatch {
constructor(pattern, options = {}) {
super(pattern, ext(def, options));
}
static defaults(options) {
return orig.defaults(ext(def, options)).Minimatch;
}
},
AST: class extends orig.AST {
/* c8 ignore start */
constructor(type, parent, options = {}) {
super(type, parent, ext(def, options));
}
/* c8 ignore stop */
static fromGlob(pattern, options = {}) {
return orig.AST.fromGlob(pattern, ext(def, options));
}
},
unescape: (s, options = {}) => orig.unescape(s, ext(def, options)),
escape: (s, options = {}) => orig.escape(s, ext(def, options)),
filter: (pattern, options = {}) => orig.filter(pattern, ext(def, options)),
defaults: (options) => orig.defaults(ext(def, options)),
makeRe: (pattern, options = {}) => orig.makeRe(pattern, ext(def, options)),
braceExpand: (pattern, options = {}) => orig.braceExpand(pattern, ext(def, options)),
match: (list, pattern, options = {}) => orig.match(list, pattern, ext(def, options)),
sep: orig.sep,
GLOBSTAR
});
};
minimatch.defaults = defaults;
var braceExpand = (pattern, options = {}) => (assertValidPattern(pattern), options.nobrace || !/\{(?:(?!\{).)*\}/.test(pattern) ? [pattern] : (0, import_brace_expansion.default)(pattern));
minimatch.braceExpand = braceExpand;
var makeRe = (pattern, options = {}) => new Minimatch(pattern, options).makeRe();
minimatch.makeRe = makeRe;
var match = (list, pattern, options = {}) => {
let mm = new Minimatch(pattern, options);
return list = list.filter((f) => mm.match(f)), mm.options.nonull && !list.length && list.push(pattern), list;
};
minimatch.match = match;
var globMagic = /[?*]|[+@!]\(.*?\)|\[|\]/, regExpEscape2 = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), Minimatch = class {
options;
set;
pattern;
windowsPathsNoEscape;
nonegate;
negate;
comment;
empty;
preserveMultipleSlashes;
partial;
globSet;
globParts;
nocase;
isWindows;
platform;
windowsNoMagicRoot;
regexp;
constructor(pattern, options = {}) {
assertValidPattern(pattern), options = options || {}, this.options = options, this.pattern = pattern, this.platform = options.platform || defaultPlatform, this.isWindows = this.platform === "win32", this.windowsPathsNoEscape = !!options.windowsPathsNoEscape || options.allowWindowsEscape === !1, this.windowsPathsNoEscape && (this.pattern = this.pattern.replace(/\\/g, "/")), this.preserveMultipleSlashes = !!options.preserveMultipleSlashes, this.regexp = null, this.negate = !1, this.nonegate = !!options.nonegate, this.comment = !1, this.empty = !1, this.partial = !!options.partial, this.nocase = !!this.options.nocase, this.windowsNoMagicRoot = options.windowsNoMagicRoot !== void 0 ? options.windowsNoMagicRoot : !!(this.isWindows && this.nocase), this.globSet = [], this.globParts = [], this.set = [], this.make();
}
hasMagic() {
if (this.options.magicalBraces && this.set.length > 1)
return !0;
for (let pattern of this.set)
for (let part of pattern)
if (typeof part != "string")
return !0;
return !1;
}
debug(..._) {
}
make() {
let pattern = this.pattern, options = this.options;
if (!options.nocomment && pattern.charAt(0) === "#") {
this.comment = !0;
return;
}
if (!pattern) {
this.empty = !0;
return;
}
this.parseNegate(), this.globSet = [...new Set(this.braceExpand())], options.debug && (this.debug = (...args) => console.error(...args)), this.debug(this.pattern, this.globSet);
let rawGlobParts = this.globSet.map((s) => this.slashSplit(s));
this.globParts = this.preprocess(rawGlobParts), this.debug(this.pattern, this.globParts);
let set = this.globParts.map((s, _, __) => {
if (this.isWindows && this.windowsNoMagicRoot) {
let isUNC = s[0] === "" && s[1] === "" && (s[2] === "?" || !globMagic.test(s[2])) && !globMagic.test(s[3]), isDrive = /^[a-z]:/i.test(s[0]);
if (isUNC)
return [...s.slice(0, 4), ...s.slice(4).map((ss) => this.parse(ss))];
if (isDrive)
return [s[0], ...s.slice(1).map((ss) => this.parse(ss))];
}
return s.map((ss) => this.parse(ss));
});
if (this.debug(this.pattern, set), this.set = set.filter((s) => s.indexOf(!1) === -1), this.isWindows)
for (let i = 0; i < this.set.length; i++) {
let p = this.set[i];
p[0] === "" && p[1] === "" && this.globParts[i][2] === "?" && typeof p[3] == "string" && /^[a-z]:$/i.test(p[3]) && (p[2] = "?");
}
this.debug(this.pattern, this.set);
}
// various transforms to equivalent pattern sets that are
// faster to process in a filesystem walk. The goal is to
// eliminate what we can, and push all ** patterns as far
// to the right as possible, even if it increases the number
// of patterns that we have to process.
preprocess(globParts) {
if (this.options.noglobstar)
for (let i = 0; i < globParts.length; i++)
for (let j = 0; j < globParts[i].length; j++)
globParts[i][j] === "**" && (globParts[i][j] = "*");
let { optimizationLevel = 1 } = this.options;
return optimizationLevel >= 2 ? (globParts = this.firstPhasePreProcess(globParts), globParts = this.secondPhasePreProcess(globParts)) : optimizationLevel >= 1 ? globParts = this.levelOneOptimize(globParts) : globParts = this.adjascentGlobstarOptimize(globParts), globParts;
}
// just get rid of adjascent ** portions
adjascentGlobstarOptimize(globParts) {
return globParts.map((parts) => {
let gs = -1;
for (; (gs = parts.indexOf("**", gs + 1)) !== -1; ) {
let i = gs;
for (; parts[i + 1] === "**"; )
i++;
i !== gs && parts.splice(gs, i - gs);
}
return parts;
});
}
// get rid of adjascent ** and resolve .. portions
levelOneOptimize(globParts) {
return globParts.map((parts) => (parts = parts.reduce((set, part) => {
let prev = set[set.length - 1];
return part === "**" && prev === "**" ? set : part === ".." && prev && prev !== ".." && prev !== "." && prev !== "**" ? (set.pop(), set) : (set.push(part), set);
}, []), parts.length === 0 ? [""] : parts));
}
levelTwoFileOptimize(parts) {
Array.isArray(parts) || (parts = this.slashSplit(parts));
let didSomething = !1;
do {
if (didSomething = !1, !this.preserveMultipleSlashes) {
for (let i = 1; i < parts.length - 1; i++) {
let p = parts[i];
i === 1 && p === "" && parts[0] === "" || (p === "." || p === "") && (didSomething = !0, parts.splice(i, 1), i--);
}
parts[0] === "." && parts.length === 2 && (parts[1] === "." || parts[1] === "") && (didSomething = !0, parts.pop());
}
let dd = 0;
for (; (dd = parts.indexOf("..", dd + 1)) !== -1; ) {
let p = parts[dd - 1];
p && p !== "." && p !== ".." && p !== "**" && (didSomething = !0, parts.splice(dd - 1, 2), dd -= 2);
}
} while (didSomething);
return parts.length === 0 ? [""] : parts;
}
// First phase: single-pattern processing
// <pre> is 1 or more portions
// <rest> is 1 or more portions
// <p> is any portion other than ., .., '', or **
// <e> is . or ''
//
// **/.. is *brutal* for filesystem walking performance, because
// it effectively resets the recursive walk each time it occurs,
// and ** cannot be reduced out by a .. pattern part like a regexp
// or most strings (other than .., ., and '') can be.
//
// <pre>/**/../<p>/<p>/<rest> -> {<pre>/../<p>/<p>/<rest>,<pre>/**/<p>/<p>/<rest>}
// <pre>/<e>/<rest> -> <pre>/<rest>
// <pre>/<p>/../<rest> -> <pre>/<rest>
// **/**/<rest> -> **/<rest>
//
// **/*/<rest> -> */**/<rest> <== not valid because ** doesn't follow
// this WOULD be allowed if ** did follow symlinks, or * didn't
firstPhasePreProcess(globParts) {
let didSomething = !1;
do {
didSomething = !1;
for (let parts of globParts) {
let gs = -1;
for (; (gs = parts.indexOf("**", gs + 1)) !== -1; ) {
let gss = gs;
for (; parts[gss + 1] === "**"; )
gss++;
gss > gs && parts.splice(gs + 1, gss - gs);
let next = parts[gs + 1], p = parts[gs + 2], p2 = parts[gs + 3];
if (next !== ".." || !p || p === "." || p === ".." || !p2 || p2 === "." || p2 === "..")
continue;
didSomething = !0, parts.splice(gs, 1);
let other = parts.slice(0);
other[gs] = "**", globParts.push(other), gs--;
}
if (!this.preserveMultipleSlashes) {
for (let i = 1; i < parts.length - 1; i++) {
let p = parts[i];
i === 1 && p === "" && parts[0] === "" || (p === "." || p === "") && (didSomething = !0, parts.splice(i, 1), i--);
}
parts[0] === "." && parts.length === 2 && (parts[1] === "." || parts[1] === "") && (didSomething = !0, parts.pop());
}
let dd = 0;
for (; (dd = parts.indexOf("..", dd + 1)) !== -1; ) {
let p = parts[dd - 1];
if (p && p !== "." && p !== ".." && p !== "**") {
didSomething = !0;
let splin = dd === 1 && parts[dd + 1] === "**" ? ["."] : [];
parts.splice(dd - 1, 2, ...splin), parts.length === 0 && parts.push(""), dd -= 2;
}
}
}
} while (didSomething);
return globParts;
}
// second phase: multi-pattern dedupes
// {<pre>/*/<rest>,<pre>/<p>/<rest>} -> <pre>/*/<rest>
// {<pre>/<rest>,<pre>/<rest>} -> <pre>/<rest>
// {<pre>/**/<rest>,<pre>/<rest>} -> <pre>/**/<rest>
//
// {<pre>/**/<rest>,<pre>/**/<p>/<rest>} -> <pre>/**/<rest>
// ^-- not valid because ** doens't follow symlinks
secondPhasePreProcess(globParts) {
for (let i = 0; i < globParts.length - 1; i++)
for (let j = i + 1; j < globParts.length; j++) {
let matched = this.partsMatch(globParts[i], globParts[j], !this.preserveMultipleSlashes);
if (matched) {
globParts[i] = [], globParts[j] = matched;
break;
}
}
return globParts.filter((gs) => gs.length);
}
partsMatch(a, b, emptyGSMatch = !1) {
let ai = 0, bi = 0, result = [], which = "";
for (; ai < a.length && bi < b.length; )
if (a[ai] === b[bi])
result.push(which === "b" ? b[bi] : a[ai]), ai++, bi++;
else if (emptyGSMatch && a[ai] === "**" && b[bi] === a[ai + 1])
result.push(a[ai]), ai++;
else if (emptyGSMatch && b[bi] === "**" && a[ai] === b[bi + 1])
result.push(b[bi]), bi++;
else if (a[ai] === "*" && b[bi] && (this.options.dot || !b[bi].startsWith(".")) && b[bi] !== "**") {
if (which === "b")
return !1;
which = "a", result.push(a[ai]), ai++, bi++;
} else if (b[bi] === "*" && a[ai] && (this.options.dot || !a[ai].startsWith(".")) && a[ai] !== "**") {
if (which === "a")
return !1;
which = "b", result.push(b[bi]), ai++, bi++;
} else
return !1;
return a.length === b.length && result;
}
parseNegate() {
if (this.nonegate)
return;
let pattern = this.pattern, negate = !1, negateOffset = 0;
for (let i = 0; i < pattern.length && pattern.charAt(i) === "!"; i++)
negate = !negate, negateOffset++;
negateOffset && (this.pattern = pattern.slice(negateOffset)), this.negate = negate;
}
// set partial to true to test if, for example,
// "/a/b" matches the start of "/*/b/*/d"
// Partial means, if you run out of file before you run
// out of pattern, then that's fine, as long as all
// the parts match.
matchOne(file, pattern, partial = !1) {
let options = this.options;
if (this.isWindows) {
let fileDrive = typeof file[0] == "string" && /^[a-z]:$/i.test(file[0]), fileUNC = !fileDrive && file[0] === "" && file[1] === "" && file[2] === "?" && /^[a-z]:$/i.test(file[3]), patternDrive = typeof pattern[0] == "string" && /^[a-z]:$/i.test(pattern[0]), patternUNC = !patternDrive && pattern[0] === "" && pattern[1] === "" && pattern[2] === "?" && typeof pattern[3] == "string" && /^[a-z]:$/i.test(pattern[3]), fdi = fileUNC ? 3 : fileDrive ? 0 : void 0, pdi = patternUNC ? 3 : patternDrive ? 0 : void 0;
if (typeof fdi == "number" && typeof pdi == "number") {
let [fd, pd] = [file[fdi], pattern[pdi]];
fd.toLowerCase() === pd.toLowerCase() && (pattern[pdi] = fd, pdi > fdi ? pattern = pattern.slice(pdi) : fdi > pdi && (file = file.slice(fdi)));
}
}
let { optimizationLevel = 1 } = this.options;
optimizationLevel >= 2 && (file = this.levelTwoFileOptimize(file)), this.debug("matchOne", this, { file, pattern }), this.debug("matchOne", file.length, pattern.length);
for (var fi = 0, pi = 0, fl = file.length, pl = pattern.length; fi < fl && pi < pl; fi++, pi++) {
this.debug("matchOne loop");
var p = pattern[pi], f = file[fi];
if (this.debug(pattern, p, f), p === !1)
return !1;
if (p === GLOBSTAR) {
this.debug("GLOBSTAR", [pattern, p, f]);
var fr = fi, pr = pi + 1;
if (pr === pl) {
for (this.debug("** at the end"); fi < fl; fi++)
if (file[fi] === "." || file[fi] === ".." || !options.dot && file[fi].charAt(0) === ".")
return !1;
return !0;
}
for (; fr < fl; ) {
var swallowee = file[fr];
if (this.debug(`
globstar while`, file, fr, pattern, pr, swallowee), this.matchOne(file.slice(fr), pattern.slice(pr), partial))
return this.debug("globstar found match!", fr, fl, swallowee), !0;
if (swallowee === "." || swallowee === ".." || !options.dot && swallowee.charAt(0) === ".") {
this.debug("dot detected!", file, fr, pattern, pr);
break;
}
this.debug("globstar swallow a segment, and continue"), fr++;
}
return !!(partial && (this.debug(`
>>> no match, partial?`, file, fr, pattern, pr), fr === fl));
}
let hit;
if (typeof p == "string" ? (hit = f === p, this.debug("string match", p, f, hit)) : (hit = p.test(f), this.debug("pattern match", p, f, hit)), !hit)
return !1;
}
if (fi === fl && pi === pl)
return !0;
if (fi === fl)
return partial;
if (pi === pl)
return fi === fl - 1 && file[fi] === "";
throw new Error("wtf?");
}
braceExpand() {
return braceExpand(this.pattern, this.options);
}
parse(pattern) {
assertValidPattern(pattern);
let options = this.options;
if (pattern === "**")
return GLOBSTAR;
if (pattern === "")
return "";
let m, fastTest = null;
(m = pattern.match(starRE)) ? fastTest = options.dot ? starTestDot : starTest : (m = pattern.match(starDotExtRE)) ? fastTest = (options.nocase ? options.dot ? starDotExtTestNocaseDot : starDotExtTestNocase : options.dot ? starDotExtTestDot : starDotExtTest)(m[1]) : (m = pattern.match(qmarksRE)) ? fastTest = (options.nocase ? options.dot ? qmarksTestNocaseDot : qmarksTestNocase : options.dot ? qmarksTestDot : qmarksTest)(m) : (m = pattern.match(starDotStarRE)) ? fastTest = options.dot ? starDotStarTestDot : starDotStarTest : (m = pattern.match(dotStarRE)) && (fastTest = dotStarTest);
let re = AST.fromGlob(pattern, this.options).toMMPattern();
return fastTest && typeof re == "object" && Reflect.defineProperty(re, "test", { value: fastTest }), re;
}
makeRe() {
if (this.regexp || this.regexp === !1)
return this.regexp;
let set = this.set;
if (!set.length)
return this.regexp = !1, this.regexp;
let options = this.options, twoStar = options.noglobstar ? star2 : options.dot ? twoStarDot : twoStarNoDot, flags = new Set(options.nocase ? ["i"] : []), re = set.map((pattern) => {
let pp = pattern.map((p) => {
if (p instanceof RegExp)
for (let f of p.flags.split(""))
flags.add(f);
return typeof p == "string" ? regExpEscape2(p) : p === GLOBSTAR ? GLOBSTAR : p._src;
});
return pp.forEach((p, i) => {
let next = pp[i + 1], prev = pp[i - 1];
p !== GLOBSTAR || prev === GLOBSTAR || (prev === void 0 ? next !== void 0 && next !== GLOBSTAR ? pp[i + 1] = "(?:\\/|" + twoStar + "\\/)?" + next : pp[i] = twoStar : next === void 0 ? pp[i - 1] = prev + "(?:\\/|" + twoStar + ")?" : next !== GLOBSTAR && (pp[i - 1] = prev + "(?:\\/|\\/" + twoStar + "\\/)" + next, pp[i + 1] = GLOBSTAR));
}), pp.filter((p) => p !== GLOBSTAR).join("/");
}).join("|"), [open, close] = set.length > 1 ? ["(?:", ")"] : ["", ""];
re = "^" + open + re + close + "$", this.negate && (re = "^(?!" + re + ").+$");
try {
this.regexp = new RegExp(re, [...flags].join(""));
} catch {
this.regexp = !1;
}
return this.regexp;
}
slashSplit(p) {
return this.preserveMultipleSlashes ? p.split("/") : this.isWindows && /^\/\/[^\/]+/.test(p) ? ["", ...p.split(/\/+/)] : p.split(/\/+/);
}
match(f, partial = this.partial) {
if (this.debug("match", f, this.pattern), this.comment)
return !1;
if (this.empty)
return f === "";
if (f === "/" && partial)
return !0;
let options = this.options;
this.isWindows && (f = f.split("\\").join("/"));
let ff = this.slashSplit(f);
this.debug(this.pattern, "split", ff);
let set = this.set;
this.debug(this.pattern, "set", set);
let filename = ff[ff.length - 1];
if (!filename)
for (let i = ff.length - 2; !filename && i >= 0; i--)
filename = ff[i];
for (let i = 0; i < set.length; i++) {
let pattern = set[i], file = ff;
if (options.matchBase && pattern.length === 1 && (file = [filename]), this.matchOne(file, pattern, partial))
return options.flipNegate ? !0 : !this.negate;
}
return options.flipNegate ? !1 : this.negate;
}
static defaults(def) {
return minimatch.defaults(def).Minimatch;
}
};
minimatch.AST = AST;
minimatch.Minimatch = Minimatch;
minimatch.escape = escape;
minimatch.unescape = unescape;
// ../node_modules/glob/dist/esm/glob.js
import { fileURLToPath as fileURLToPath2 } from "node:url";
// ../node_modules/glob/node_modules/lru-cache/dist/esm/index.js
var perf = typeof performance == "object" && performance && typeof performance.now == "function" ? performance : Date, warned = /* @__PURE__ */ new Set(), PROCESS = typeof process == "object" && process ? process : {}, emitWarning = (msg, type, code, fn) => {
typeof PROCESS.emitWarning == "function" ? PROCESS.emitWarning(msg, type, code, fn) : console.error(`[${code}] ${type}: ${msg}`);
}, AC = globalThis.AbortController, AS = globalThis.AbortSignal;
if (typeof AC > "u") {
AS = class {
onabort;
_onabort = [];
reason;
aborted = !1;
addEventListener(_, fn) {
this._onabort.push(fn);
}
}, AC = class {
constructor() {
warnACPolyfill();
}
signal = new AS();
abort(reason) {
if (!this.signal.aborted) {
this.signal.reason = reason, this.signal.aborted = !0;
for (let fn of this.signal._onabort)
fn(reason);
this.signal.onabort?.(reason);
}
}
};
let printACPolyfillWarning = PROCESS.env?.LRU_CACHE_IGNORE_AC_WARNING !== "1", warnACPolyfill = () => {
printACPolyfillWarning && (printACPolyfillWarning = !1, emitWarning("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", warnACPolyfill));
};
}
var shouldWarn = (code) => !warned.has(code), TYPE = Symbol("type"), isPosInt = (n) => n && n === Math.floor(n) && n > 0 && isFinite(n), getUintArray = (max) => isPosInt(max) ? max <= Math.pow(2, 8) ? Uint8Array : max <= Math.pow(2, 16) ? Uint16Array : max <= Math.pow(2, 32) ? Uint32Array : max <= Number.MAX_SAFE_INTEGER ? ZeroArray : null : null, ZeroArray = class extends Array {
constructor(size) {
super(size), this.fill(0);
}
}, Stack = class _Stack {
heap;
length;
// private constructor
static #constructing = !1;
static create(max) {
let HeapCls = getUintArray(max);
if (!HeapCls)
return [];
_Stack.#constructing = !0;
let s = new _Stack(max, HeapCls);
return _Stack.#constructing = !1, s;
}
constructor(max, HeapCls) {
if (!_Stack.#constructing)
throw new TypeError("instantiate Stack using Stack.create(n)");
this.heap = new HeapCls(max), this.length = 0;
}
push(n) {
this.heap[this.length++] = n;
}
pop() {
return this.heap[--this.length];
}
}, LRUCache = class _LRUCache {
// options that cannot be changed without disaster
#max;
#maxSize;
#dispose;
#disposeAfter;
#fetchMethod;
#memoMethod;
/**
* {@link LRUCache.OptionsBase.ttl}
*/
ttl;
/**
* {@link LRUCache.OptionsBase.ttlResolution}
*/
ttlResolution;
/**
* {@link LRUCache.OptionsBase.ttlAutopurge}
*/
ttlAutopurge;
/**
* {@link LRUCache.OptionsBase.updateAgeOnGet}
*/
updateAgeOnGet;
/**
* {@link LRUCache.OptionsBase.updateAgeOnHas}
*/
updateAgeOnHas;
/**
* {@link LRUCache.OptionsBase.allowStale}
*/
allowStale;
/**
* {@link LRUCache.OptionsBase.noDisposeOnSet}
*/
noDisposeOnSet;
/**
* {@link LRUCache.OptionsBase.noUpdateTTL}
*/
noUpdateTTL;
/**
* {@link LRUCache.OptionsBase.maxEntrySize}
*/
maxEntrySize;
/**
* {@link LRUCache.OptionsBase.sizeCalculation}
*/
sizeCalculation;
/**
* {@link LRUCache.OptionsBase.noDeleteOnFetchRejection}
*/
noDeleteOnFetchRejection;
/**
* {@link LRUCache.OptionsBase.noDeleteOnStaleGet}
*/
noDeleteOnStaleGet;
/**
* {@link LRUCache.OptionsBase.allowStaleOnFetchAbort}
*/
allowStaleOnFetchAbort;
/**
* {@link LRUCache.OptionsBase.allowStaleOnFetchRejection}
*/
allowStaleOnFetchRejection;
/**
* {@link LRUCache.OptionsBase.ignoreFetchAbort}
*/
ignoreFetchAbort;
// computed properties
#size;
#calculatedSize;
#keyMap;
#keyList;
#valList;
#next;
#prev;
#head;
#tail;
#free;
#disposed;
#sizes;
#starts;
#ttls;
#hasDispose;
#hasFetchMethod;
#hasDisposeAfter;
/**
* Do not call this method unless you need to inspect the
* inner workings of the cache. If anything returned by this
* object is modified in any way, strange breakage may occur.
*
* These fields are private for a reason!
*
* @internal
*/
static unsafeExposeInternals(c) {
return {
// properties
starts: c.#starts,
ttls: c.#ttls,
sizes: c.#sizes,
keyMap: c.#keyMap,
keyList: c.#keyList,
valList: c.#valList,
next: c.#next,
prev: c.#prev,
get head() {
return c.#head;
},
get tail() {
retu