@kitn.ai/ui
Version:
Framework-agnostic, Shadow-DOM web components for building AI chat interfaces — works in React, Vue, Angular, Svelte, or plain HTML. Authored in SolidJS.
1,402 lines • 89.4 kB
JavaScript
var Fr = Object.defineProperty;
var Gr = Object.getPrototypeOf;
var Pr = Reflect.get;
var De = (e) => {
throw TypeError(e);
};
var Rr = (e, r, t) => r in e ? Fr(e, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[r] = t;
var se = (e, r, t) => Rr(e, typeof r != "symbol" ? r + "" : r, t), ye = (e, r, t) => r.has(e) || De("Cannot " + t);
var E = (e, r, t) => (ye(e, r, "read from private field"), t ? t.call(e) : r.get(e)), z = (e, r, t) => r.has(e) ? De("Cannot add the same private member more than once") : r instanceof WeakSet ? r.add(e) : r.set(e, t), M = (e, r, t, n) => (ye(e, r, "write to private field"), n ? n.call(e, t) : r.set(e, t), t), Ce = (e, r, t) => (ye(e, r, "access private method"), t);
var Te = (e, r, t) => Pr(Gr(e), t, r);
var ar = class {
constructor(e, r = {}) {
se(this, "patterns");
se(this, "options");
se(this, "regexps");
this.patterns = e, this.options = r;
const { forgiving: t = !1, cache: n, regexConstructor: s } = r;
if (!s) throw new Error("Option `regexConstructor` is not provided");
this.regexps = e.map((o) => {
if (typeof o != "string") return o;
const a = n == null ? void 0 : n.get(o);
if (a) {
if (a instanceof RegExp) return a;
if (t) return null;
throw a;
}
try {
const i = s(o);
return n == null || n.set(o, i), i;
} catch (i) {
if (n == null || n.set(o, i), t) return null;
throw i;
}
});
}
findNextMatchSync(e, r, t) {
const n = typeof e == "string" ? e : e.content, s = [];
function o(a, i, u = 0) {
return {
index: a,
captureIndices: i.indices.map((c) => c == null ? {
start: 4294967295,
end: 4294967295,
length: 0
} : {
start: c[0] + u,
end: c[1] + u,
length: c[1] - c[0]
})
};
}
for (let a = 0; a < this.regexps.length; a++) {
const i = this.regexps[a];
if (i)
try {
i.lastIndex = r;
const u = i.exec(n);
if (!u) continue;
if (u.index === r) return o(a, u, 0);
s.push([
a,
u,
0
]);
} catch (u) {
if (this.options.forgiving) continue;
throw u;
}
}
if (s.length) {
const a = Math.min(...s.map((i) => i[1].index));
for (const [i, u, c] of s) if (u.index === a) return o(i, u, c);
}
return null;
}
};
function re(e) {
if ([...e].length !== 1) throw new Error(`Expected "${e}" to be a single code point`);
return e.codePointAt(0);
}
function Ur(e, r, t) {
return e.has(r) || e.set(r, t), e.get(r);
}
const Fe = /* @__PURE__ */ new Set(["alnum", "alpha", "ascii", "blank", "cntrl", "digit", "graph", "lower", "print", "punct", "space", "upper", "word", "xdigit"]), x = String.raw;
function te(e, r) {
if (e == null) throw new Error(r ?? "Value expected");
return e;
}
const ir = x`\[\^?`, ur = `c.? | C(?:-.?)?|${x`[pP]\{(?:\^?[-\x20_]*[A-Za-z][-\x20\w]*\})?`}|${x`x[89A-Fa-f]\p{AHex}(?:\\x[89A-Fa-f]\p{AHex})*`}|${x`u(?:\p{AHex}{4})? | x\{[^\}]*\}? | x\p{AHex}{0,2}`}|${x`o\{[^\}]*\}?`}|${x`\d{1,3}`}`, Ge = /[?*+][?+]?|\{(?:\d+(?:,\d*)?|,\d+)\}\??/, ce = new RegExp(x`
\\ (?:
${ur}
| [gk]<[^>]*>?
| [gk]'[^']*'?
| .
)
| \( (?:
\? (?:
[:=!>({]
| <[=!]
| <[^>]*>
| '[^']*'
| ~\|?
| #(?:[^)\\]|\\.?)*
| [^:)]*[:)]
)?
| \*[^\)]*\)?
)?
| (?:${Ge.source})+
| ${ir}
| .
`.replace(/\s+/g, ""), "gsu"), be = new RegExp(x`
\\ (?:
${ur}
| .
)
| \[:(?:\^?\p{Alpha}+|\^):\]
| ${ir}
| &&
| .
`.replace(/\s+/g, ""), "gsu");
function Or(e, r = {}) {
const t = { flags: "", ...r, rules: { captureGroup: !1, singleline: !1, ...r.rules } };
if (typeof e != "string") throw new Error("String expected as pattern");
const n = nt(t.flags), s = [n.extended], o = { captureGroup: t.rules.captureGroup, getCurrentModX() {
return s.at(-1);
}, numOpenGroups: 0, popModX() {
s.pop();
}, pushModX(l) {
s.push(l);
}, replaceCurrentModX(l) {
s[s.length - 1] = l;
}, singleline: t.rules.singleline };
let a = [], i;
for (ce.lastIndex = 0; i = ce.exec(e); ) {
const l = Dr(o, e, i[0], ce.lastIndex);
l.tokens ? a.push(...l.tokens) : l.token && a.push(l.token), l.lastIndex !== void 0 && (ce.lastIndex = l.lastIndex);
}
const u = [];
let c = 0;
a.filter((l) => l.type === "GroupOpen").forEach((l) => {
l.kind === "capturing" ? l.number = ++c : l.raw === "(" && u.push(l);
}), c || u.forEach((l, f) => {
l.kind = "capturing", l.number = f + 1;
});
const p = c || u.length;
return { tokens: a.map((l) => l.type === "EscapedNumber" ? ot(l, p) : l).flat(), flags: n };
}
function Dr(e, r, t, n) {
const [s, o] = t;
if (t === "[" || t === "[^") {
const a = Tr(r, t, n);
return { tokens: a.tokens, lastIndex: a.lastIndex };
}
if (s === "\\") {
if ("AbBGyYzZ".includes(o)) return { token: Be(t, t) };
if (/^\\g[<']/.test(t)) {
if (!/^\\g(?:<[^>]+>|'[^']+')$/.test(t)) throw new Error(`Invalid group name "${t}"`);
return { token: qr(t) };
}
if (/^\\k[<']/.test(t)) {
if (!/^\\k(?:<[^>]+>|'[^']+')$/.test(t)) throw new Error(`Invalid group name "${t}"`);
return { token: lr(t) };
}
if (o === "K") return { token: pr("keep", t) };
if (o === "N" || o === "R") return { token: j("newline", t, { negate: o === "N" }) };
if (o === "O") return { token: j("any", t) };
if (o === "X") return { token: j("text_segment", t) };
const a = cr(t, { inCharClass: !1 });
return Array.isArray(a) ? { tokens: a } : { token: a };
}
if (s === "(") {
if (o === "*") return { token: et(t) };
if (t === "(?{") throw new Error(`Unsupported callout "${t}"`);
if (t.startsWith("(?#")) {
if (r[n] !== ")") throw new Error('Unclosed comment group "(?#"');
return { lastIndex: n + 1 };
}
if (/^\(\?[-imx]+[:)]$/.test(t)) return { token: Yr(t, e) };
if (e.pushModX(e.getCurrentModX()), e.numOpenGroups++, t === "(" && !e.captureGroup || t === "(?:") return { token: Y("group", t) };
if (t === "(?>") return { token: Y("atomic", t) };
if (t === "(?=" || t === "(?!" || t === "(?<=" || t === "(?<!") return { token: Y(t[2] === "<" ? "lookbehind" : "lookahead", t, { negate: t.endsWith("!") }) };
if (t === "(" && e.captureGroup || t.startsWith("(?<") && t.endsWith(">") || t.startsWith("(?'") && t.endsWith("'")) return { token: Y("capturing", t, { ...t !== "(" && { name: t.slice(3, -1) } }) };
if (t.startsWith("(?~")) {
if (t === "(?~|") throw new Error(`Unsupported absence function kind "${t}"`);
return { token: Y("absence_repeater", t) };
}
throw t === "(?(" ? new Error(`Unsupported conditional "${t}"`) : new Error(`Invalid or unsupported group option "${t}"`);
}
if (t === ")") {
if (e.popModX(), e.numOpenGroups--, e.numOpenGroups < 0) throw new Error('Unmatched ")"');
return { token: Xr(t) };
}
if (e.getCurrentModX()) {
if (t === "#") {
const a = r.indexOf(`
`, n);
return { lastIndex: a === -1 ? r.length : a };
}
if (/^\s$/.test(t)) {
const a = /\s+/y;
return a.lastIndex = n, { lastIndex: a.exec(r) ? a.lastIndex : n };
}
}
if (t === ".") return { token: j("dot", t) };
if (t === "^" || t === "$") {
const a = e.singleline ? { "^": x`\A`, $: x`\Z` }[t] : t;
return { token: Be(a, t) };
}
return t === "|" ? { token: Vr(t) } : Ge.test(t) ? { tokens: at(t) } : { token: R(re(t), t) };
}
function Tr(e, r, t) {
const n = [Ve(r[1] === "^", r)];
let s = 1, o;
for (be.lastIndex = t; o = be.exec(e); ) {
const a = o[0];
if (a[0] === "[" && a[1] !== ":") s++, n.push(Ve(a[1] === "^", a));
else if (a === "]") {
if (n.at(-1).type === "CharacterClassOpen") n.push(R(93, a));
else if (s--, n.push(zr(a)), !s) break;
} else {
const i = Br(a);
Array.isArray(i) ? n.push(...i) : n.push(i);
}
}
return { tokens: n, lastIndex: be.lastIndex || e.length };
}
function Br(e) {
if (e[0] === "\\") return cr(e, { inCharClass: !0 });
if (e[0] === "[") {
const r = /\[:(?<negate>\^?)(?<name>[a-z]+):\]/.exec(e);
if (!r || !Fe.has(r.groups.name)) throw new Error(`Invalid POSIX class "${e}"`);
return j("posix", e, { value: r.groups.name, negate: !!r.groups.negate });
}
return e === "-" ? Wr(e) : e === "&&" ? Hr(e) : R(re(e), e);
}
function cr(e, { inCharClass: r }) {
const t = e[1];
if (t === "c" || t === "C") return Kr(e);
if ("dDhHsSwW".includes(t)) return rt(e);
if (e.startsWith(x`\o{`)) throw new Error(`Incomplete, invalid, or unsupported octal code point "${e}"`);
if (/^\\[pP]\{/.test(e)) {
if (e.length === 3) throw new Error(`Incomplete or invalid Unicode property "${e}"`);
return tt(e);
}
if (new RegExp("^\\\\x[89A-Fa-f]\\p{AHex}", "u").test(e)) try {
const n = e.split(/\\x/).slice(1).map((a) => parseInt(a, 16)), s = new TextDecoder("utf-8", { ignoreBOM: !0, fatal: !0 }).decode(new Uint8Array(n)), o = new TextEncoder();
return [...s].map((a) => {
const i = [...o.encode(a)].map((u) => `\\x${u.toString(16)}`).join("");
return R(re(a), i);
});
} catch {
throw new Error(`Multibyte code "${e}" incomplete or invalid in Oniguruma`);
}
if (t === "u" || t === "x") return R(st(e), e);
if (ze.has(t)) return R(ze.get(t), e);
if (/\d/.test(t)) return jr(r, e);
if (e === "\\") throw new Error(x`Incomplete escape "\"`);
if (t === "M") throw new Error(`Unsupported meta "${e}"`);
if ([...e].length === 2) return R(e.codePointAt(1), e);
throw new Error(`Unexpected escape "${e}"`);
}
function Vr(e) {
return { type: "Alternator", raw: e };
}
function Be(e, r) {
return { type: "Assertion", kind: e, raw: r };
}
function lr(e) {
return { type: "Backreference", raw: e };
}
function R(e, r) {
return { type: "Character", value: e, raw: r };
}
function zr(e) {
return { type: "CharacterClassClose", raw: e };
}
function Wr(e) {
return { type: "CharacterClassHyphen", raw: e };
}
function Hr(e) {
return { type: "CharacterClassIntersector", raw: e };
}
function Ve(e, r) {
return { type: "CharacterClassOpen", negate: e, raw: r };
}
function j(e, r, t = {}) {
return { type: "CharacterSet", kind: e, ...t, raw: r };
}
function pr(e, r, t = {}) {
return e === "keep" ? { type: "Directive", kind: e, raw: r } : { type: "Directive", kind: e, flags: te(t.flags), raw: r };
}
function jr(e, r) {
return { type: "EscapedNumber", inCharClass: e, raw: r };
}
function Xr(e) {
return { type: "GroupClose", raw: e };
}
function Y(e, r, t = {}) {
return { type: "GroupOpen", kind: e, ...t, raw: r };
}
function Zr(e, r, t, n) {
return { type: "NamedCallout", kind: e, tag: r, arguments: t, raw: n };
}
function Qr(e, r, t, n) {
return { type: "Quantifier", kind: e, min: r, max: t, raw: n };
}
function qr(e) {
return { type: "Subroutine", raw: e };
}
const Jr = /* @__PURE__ */ new Set(["COUNT", "CMP", "ERROR", "FAIL", "MAX", "MISMATCH", "SKIP", "TOTAL_COUNT"]), ze = /* @__PURE__ */ new Map([["a", 7], ["b", 8], ["e", 27], ["f", 12], ["n", 10], ["r", 13], ["t", 9], ["v", 11]]);
function Kr(e) {
const r = e[1] === "c" ? e[2] : e[3];
if (!r || !/[A-Za-z]/.test(r)) throw new Error(`Unsupported control character "${e}"`);
return R(re(r.toUpperCase()) - 64, e);
}
function Yr(e, r) {
let { on: t, off: n } = /^\(\?(?<on>[imx]*)(?:-(?<off>[-imx]*))?/.exec(e).groups;
n ?? (n = "");
const s = (r.getCurrentModX() || t.includes("x")) && !n.includes("x"), o = He(t), a = He(n), i = {};
if (o && (i.enable = o), a && (i.disable = a), e.endsWith(")")) return r.replaceCurrentModX(s), pr("flags", e, { flags: i });
if (e.endsWith(":")) return r.pushModX(s), r.numOpenGroups++, Y("group", e, { ...(o || a) && { flags: i } });
throw new Error(`Unexpected flag modifier "${e}"`);
}
function et(e) {
const r = /\(\*(?<name>[A-Za-z_]\w*)?(?:\[(?<tag>(?:[A-Za-z_]\w*)?)\])?(?:\{(?<args>[^}]*)\})?\)/.exec(e);
if (!r) throw new Error(`Incomplete or invalid named callout "${e}"`);
const { name: t, tag: n, args: s } = r.groups;
if (!t) throw new Error(`Invalid named callout "${e}"`);
if (n === "") throw new Error(`Named callout tag with empty value not allowed "${e}"`);
const o = s ? s.split(",").filter((p) => p !== "").map((p) => /^[+-]?\d+$/.test(p) ? +p : p) : [], [a, i, u] = o, c = Jr.has(t) ? t.toLowerCase() : "custom";
switch (c) {
case "fail":
case "mismatch":
case "skip":
if (o.length > 0) throw new Error(`Named callout arguments not allowed "${o}"`);
break;
case "error":
if (o.length > 1) throw new Error(`Named callout allows only one argument "${o}"`);
if (typeof a == "string") throw new Error(`Named callout argument must be a number "${a}"`);
break;
case "max":
if (!o.length || o.length > 2) throw new Error(`Named callout must have one or two arguments "${o}"`);
if (typeof a == "string" && !/^[A-Za-z_]\w*$/.test(a)) throw new Error(`Named callout argument one must be a tag or number "${a}"`);
if (o.length === 2 && (typeof i == "number" || !/^[<>X]$/.test(i))) throw new Error(`Named callout optional argument two must be '<', '>', or 'X' "${i}"`);
break;
case "count":
case "total_count":
if (o.length > 1) throw new Error(`Named callout allows only one argument "${o}"`);
if (o.length === 1 && (typeof a == "number" || !/^[<>X]$/.test(a))) throw new Error(`Named callout optional argument must be '<', '>', or 'X' "${a}"`);
break;
case "cmp":
if (o.length !== 3) throw new Error(`Named callout must have three arguments "${o}"`);
if (typeof a == "string" && !/^[A-Za-z_]\w*$/.test(a)) throw new Error(`Named callout argument one must be a tag or number "${a}"`);
if (typeof i == "number" || !/^(?:[<>!=]=|[<>])$/.test(i)) throw new Error(`Named callout argument two must be '==', '!=', '>', '<', '>=', or '<=' "${i}"`);
if (typeof u == "string" && !/^[A-Za-z_]\w*$/.test(u)) throw new Error(`Named callout argument three must be a tag or number "${u}"`);
break;
case "custom":
throw new Error(`Undefined callout name "${t}"`);
default:
throw new Error(`Unexpected named callout kind "${c}"`);
}
return Zr(c, n ?? null, (s == null ? void 0 : s.split(",")) ?? null, e);
}
function We(e) {
let r = null, t, n;
if (e[0] === "{") {
const { minStr: s, maxStr: o } = /^\{(?<minStr>\d*)(?:,(?<maxStr>\d*))?/.exec(e).groups, a = 1e5;
if (+s > a || o && +o > a) throw new Error("Quantifier value unsupported in Oniguruma");
if (t = +s, n = o === void 0 ? +s : o === "" ? 1 / 0 : +o, t > n && (r = "possessive", [t, n] = [n, t]), e.endsWith("?")) {
if (r === "possessive") throw new Error('Unsupported possessive interval quantifier chain with "?"');
r = "lazy";
} else r || (r = "greedy");
} else t = e[0] === "+" ? 1 : 0, n = e[0] === "?" ? 1 : 1 / 0, r = e[1] === "+" ? "possessive" : e[1] === "?" ? "lazy" : "greedy";
return Qr(r, t, n, e);
}
function rt(e) {
const r = e[1].toLowerCase();
return j({ d: "digit", h: "hex", s: "space", w: "word" }[r], e, { negate: e[1] !== r });
}
function tt(e) {
const { p: r, neg: t, value: n } = /^\\(?<p>[pP])\{(?<neg>\^?)(?<value>[^}]+)/.exec(e).groups;
return j("property", e, { value: n, negate: r === "P" && !t || r === "p" && !!t });
}
function He(e) {
const r = {};
return e.includes("i") && (r.ignoreCase = !0), e.includes("m") && (r.dotAll = !0), e.includes("x") && (r.extended = !0), Object.keys(r).length ? r : null;
}
function nt(e) {
const r = { ignoreCase: !1, dotAll: !1, extended: !1, digitIsAscii: !1, posixIsAscii: !1, spaceIsAscii: !1, wordIsAscii: !1, textSegmentMode: null };
for (let t = 0; t < e.length; t++) {
const n = e[t];
if (!"imxDPSWy".includes(n)) throw new Error(`Invalid flag "${n}"`);
if (n === "y") {
if (!/^y{[gw]}/.test(e.slice(t))) throw new Error('Invalid or unspecified flag "y" mode');
r.textSegmentMode = e[t + 2] === "g" ? "grapheme" : "word", t += 3;
continue;
}
r[{ i: "ignoreCase", m: "dotAll", x: "extended", D: "digitIsAscii", P: "posixIsAscii", S: "spaceIsAscii", W: "wordIsAscii" }[n]] = !0;
}
return r;
}
function st(e) {
if (new RegExp("^(?:\\\\u(?!\\p{AHex}{4})|\\\\x(?!\\p{AHex}{1,2}|\\{\\p{AHex}{1,8}\\}))", "u").test(e)) throw new Error(`Incomplete or invalid escape "${e}"`);
const r = e[2] === "{" ? new RegExp("^\\\\x\\{\\s*(?<hex>\\p{AHex}+)", "u").exec(e).groups.hex : e.slice(2);
return parseInt(r, 16);
}
function ot(e, r) {
const { raw: t, inCharClass: n } = e, s = t.slice(1);
if (!n && (s !== "0" && s.length === 1 || s[0] !== "0" && +s <= r)) return [lr(t)];
const o = [], a = s.match(/^[0-7]+|\d/g);
for (let i = 0; i < a.length; i++) {
const u = a[i];
let c;
if (i === 0 && u !== "8" && u !== "9") {
if (c = parseInt(u, 8), c > 127) throw new Error(x`Octal encoded byte above 177 unsupported "${t}"`);
} else c = re(u);
o.push(R(c, (i === 0 ? "\\" : "") + u));
}
return o;
}
function at(e) {
const r = [], t = new RegExp(Ge, "gy");
let n;
for (; n = t.exec(e); ) {
const s = n[0];
if (s[0] === "{") {
const o = /^\{(?<min>\d+),(?<max>\d+)\}\??$/.exec(s);
if (o) {
const { min: a, max: i } = o.groups;
if (+a > +i && s.endsWith("?")) {
t.lastIndex--, r.push(We(s.slice(0, -1)));
continue;
}
}
}
r.push(We(s));
}
return r;
}
function fr(e, r) {
if (!Array.isArray(e.body)) throw new Error("Expected node with body array");
if (e.body.length !== 1) return !1;
const t = e.body[0];
return !r || Object.keys(r).every((n) => r[n] === t[n]);
}
function it(e) {
return ut.has(e.type);
}
const ut = /* @__PURE__ */ new Set(["AbsenceFunction", "Backreference", "CapturingGroup", "Character", "CharacterClass", "CharacterSet", "Group", "Quantifier", "Subroutine"]);
function dr(e, r = {}) {
const t = { flags: "", normalizeUnknownPropertyNames: !1, skipBackrefValidation: !1, skipLookbehindValidation: !1, skipPropertyNameValidation: !1, unicodePropertyMap: null, ...r, rules: { captureGroup: !1, singleline: !1, ...r.rules } }, n = Or(e, { flags: t.flags, rules: { captureGroup: t.rules.captureGroup, singleline: t.rules.singleline } }), s = (f, g) => {
const d = n.tokens[o.nextIndex];
switch (o.parent = f, o.nextIndex++, d.type) {
case "Alternator":
return Q();
case "Assertion":
return ct(d);
case "Backreference":
return lt(d, o);
case "Character":
return ge(d.value, { useLastValid: !!g.isCheckingRangeEnd });
case "CharacterClassHyphen":
return pt(d, o, g);
case "CharacterClassOpen":
return ft(d, o, g);
case "CharacterSet":
return dt(d, o);
case "Directive":
return Ct(d.kind, { flags: d.flags });
case "GroupOpen":
return gt(d, o, g);
case "NamedCallout":
return xt(d.kind, d.tag, d.arguments);
case "Quantifier":
return ht(d, o);
case "Subroutine":
return wt(d, o);
default:
throw new Error(`Unexpected token type "${d.type}"`);
}
}, o = { capturingGroups: [], hasNumberedRef: !1, namedGroupsByName: /* @__PURE__ */ new Map(), nextIndex: 0, normalizeUnknownPropertyNames: t.normalizeUnknownPropertyNames, parent: null, skipBackrefValidation: t.skipBackrefValidation, skipLookbehindValidation: t.skipLookbehindValidation, skipPropertyNameValidation: t.skipPropertyNameValidation, subroutines: [], tokens: n.tokens, unicodePropertyMap: t.unicodePropertyMap, walk: s }, a = Et(bt(n.flags));
let i = a.body[0];
for (; o.nextIndex < n.tokens.length; ) {
const f = s(i, {});
f.type === "Alternative" ? (a.body.push(f), i = f) : i.body.push(f);
}
const { capturingGroups: u, hasNumberedRef: c, namedGroupsByName: p, subroutines: l } = o;
if (c && p.size && !t.rules.captureGroup) throw new Error("Numbered backref/subroutine not allowed when using named capture");
for (const { ref: f } of l) if (typeof f == "number") {
if (f > u.length) throw new Error("Subroutine uses a group number that's not defined");
f && (u[f - 1].isSubroutined = !0);
} else if (p.has(f)) {
if (p.get(f).length > 1) throw new Error(x`Subroutine uses a duplicate group name "\g<${f}>"`);
p.get(f)[0].isSubroutined = !0;
} else throw new Error(x`Subroutine uses a group name that's not defined "\g<${f}>"`);
return a;
}
function ct({ kind: e }) {
return Se(te({ "^": "line_start", $: "line_end", "\\A": "string_start", "\\b": "word_boundary", "\\B": "word_boundary", "\\G": "search_start", "\\y": "text_segment_boundary", "\\Y": "text_segment_boundary", "\\z": "string_end", "\\Z": "string_end_newline" }[e], `Unexpected assertion kind "${e}"`), { negate: e === x`\B` || e === x`\Y` });
}
function lt({ raw: e }, r) {
const t = /^\\k[<']/.test(e), n = t ? e.slice(3, -1) : e.slice(1), s = (o, a = !1) => {
const i = r.capturingGroups.length;
let u = !1;
if (o > i) if (r.skipBackrefValidation) u = !0;
else throw new Error(`Not enough capturing groups defined to the left "${e}"`);
return r.hasNumberedRef = !0, ve(a ? i + 1 - o : o, { orphan: u });
};
if (t) {
const o = /^(?<sign>-?)0*(?<num>[1-9]\d*)$/.exec(n);
if (o) return s(+o.groups.num, !!o.groups.sign);
if (/[-+]/.test(n)) throw new Error(`Invalid backref name "${e}"`);
if (!r.namedGroupsByName.has(n)) throw new Error(`Group name not defined to the left "${e}"`);
return ve(n);
}
return s(+n);
}
function pt(e, r, t) {
const { tokens: n, walk: s } = r, o = r.parent, a = o.body.at(-1), i = n[r.nextIndex];
if (!t.isCheckingRangeEnd && a && a.type !== "CharacterClass" && a.type !== "CharacterClassRange" && i && i.type !== "CharacterClassOpen" && i.type !== "CharacterClassClose" && i.type !== "CharacterClassIntersector") {
const u = s(o, { ...t, isCheckingRangeEnd: !0 });
if (a.type === "Character" && u.type === "Character") return o.body.pop(), yt(a, u);
throw new Error("Invalid character class range");
}
return ge(re("-"));
}
function ft({ negate: e }, r, t) {
const { tokens: n, walk: s } = r, o = [fe()], a = n[r.nextIndex];
let i = Ze(a);
for (; i.type !== "CharacterClassClose"; ) {
if (i.type === "CharacterClassIntersector") o.push(fe()), r.nextIndex++;
else {
const c = o.at(-1);
c.body.push(s(c, t));
}
i = Ze(n[r.nextIndex], a);
}
const u = fe({ negate: e });
return o.length === 1 ? u.body = o[0].body : (u.kind = "intersection", u.body = o.map((c) => c.body.length === 1 ? c.body[0] : c)), r.nextIndex++, u;
}
function dt({ kind: e, negate: r, value: t }, n) {
const { normalizeUnknownPropertyNames: s, skipPropertyNameValidation: o, unicodePropertyMap: a } = n;
if (e === "property") {
const i = he(t);
if (Fe.has(i) && !(a != null && a.has(i))) e = "posix", t = i;
else return ee(t, { negate: r, normalizeUnknownPropertyNames: s, skipPropertyNameValidation: o, unicodePropertyMap: a });
}
return e === "posix" ? kt(t, { negate: r }) : _e(e, { negate: r });
}
function gt(e, r, t) {
const { tokens: n, capturingGroups: s, namedGroupsByName: o, skipLookbehindValidation: a, walk: i } = r, u = $t(e), c = u.type === "AbsenceFunction", p = Xe(u), l = p && u.negate;
if (u.type === "CapturingGroup" && (s.push(u), u.name && Ur(o, u.name, []).push(u)), c && t.isInAbsenceFunction) throw new Error("Nested absence function not supported by Oniguruma");
let f = Qe(n[r.nextIndex]);
for (; f.type !== "GroupClose"; ) {
if (f.type === "Alternator") u.body.push(Q()), r.nextIndex++;
else {
const g = u.body.at(-1), d = i(g, { ...t, isInAbsenceFunction: t.isInAbsenceFunction || c, isInLookbehind: t.isInLookbehind || p, isInNegLookbehind: t.isInNegLookbehind || l });
if (g.body.push(d), (p || t.isInLookbehind) && !a) {
const w = "Lookbehind includes a pattern not allowed by Oniguruma";
if (l || t.isInNegLookbehind) {
if (je(d) || d.type === "CapturingGroup") throw new Error(w);
} else if (je(d) || Xe(d) && d.negate) throw new Error(w);
}
}
f = Qe(n[r.nextIndex]);
}
return r.nextIndex++, u;
}
function ht({ kind: e, min: r, max: t }, n) {
const s = n.parent, o = s.body.at(-1);
if (!o || !it(o)) throw new Error("Quantifier requires a repeatable token");
const a = hr(e, r, t, o);
return s.body.pop(), a;
}
function wt({ raw: e }, r) {
const { capturingGroups: t, subroutines: n } = r;
let s = e.slice(3, -1);
const o = /^(?<sign>[-+]?)0*(?<num>[1-9]\d*)$/.exec(s);
if (o) {
const i = +o.groups.num, u = t.length;
if (r.hasNumberedRef = !0, s = { "": i, "+": u + i, "-": u + 1 - i }[o.groups.sign], s < 1) throw new Error("Invalid subroutine number");
} else s === "0" && (s = 0);
const a = wr(s);
return n.push(a), a;
}
function mt(e, r) {
return { type: "AbsenceFunction", kind: e, body: ue(r == null ? void 0 : r.body) };
}
function Q(e) {
return { type: "Alternative", body: mr(e == null ? void 0 : e.body) };
}
function Se(e, r) {
const t = { type: "Assertion", kind: e };
return (e === "word_boundary" || e === "text_segment_boundary") && (t.negate = !!(r != null && r.negate)), t;
}
function ve(e, r) {
const t = !!(r != null && r.orphan);
return { type: "Backreference", ref: e, ...t && { orphan: t } };
}
function gr(e, r) {
const t = { name: void 0, isSubroutined: !1, ...r };
if (t.name !== void 0 && !At(t.name)) throw new Error(`Group name "${t.name}" invalid in Oniguruma`);
return { type: "CapturingGroup", number: e, ...t.name && { name: t.name }, ...t.isSubroutined && { isSubroutined: t.isSubroutined }, body: ue(r == null ? void 0 : r.body) };
}
function ge(e, r) {
const t = { useLastValid: !1, ...r };
if (e > 1114111) {
const n = e.toString(16);
if (t.useLastValid) e = 1114111;
else throw e > 1310719 ? new Error(`Invalid code point out of range "\\x{${n}}"`) : new Error(`Invalid code point out of range in JS "\\x{${n}}"`);
}
return { type: "Character", value: e };
}
function fe(e) {
const r = { kind: "union", negate: !1, ...e };
return { type: "CharacterClass", kind: r.kind, negate: r.negate, body: mr(e == null ? void 0 : e.body) };
}
function yt(e, r) {
if (r.value < e.value) throw new Error("Character class range out of order");
return { type: "CharacterClassRange", min: e, max: r };
}
function _e(e, r) {
const t = !!(r != null && r.negate), n = { type: "CharacterSet", kind: e };
return (e === "digit" || e === "hex" || e === "newline" || e === "space" || e === "word") && (n.negate = t), (e === "text_segment" || e === "newline" && !t) && (n.variableLength = !0), n;
}
function Ct(e, r = {}) {
if (e === "keep") return { type: "Directive", kind: e };
if (e === "flags") return { type: "Directive", kind: e, flags: te(r.flags) };
throw new Error(`Unexpected directive kind "${e}"`);
}
function bt(e) {
return { type: "Flags", ...e };
}
function N(e) {
const r = e == null ? void 0 : e.atomic, t = e == null ? void 0 : e.flags;
if (r && t) throw new Error("Atomic group cannot have flags");
return { type: "Group", ...r && { atomic: r }, ...t && { flags: t }, body: ue(e == null ? void 0 : e.body) };
}
function H(e) {
const r = { behind: !1, negate: !1, ...e };
return { type: "LookaroundAssertion", kind: r.behind ? "lookbehind" : "lookahead", negate: r.negate, body: ue(e == null ? void 0 : e.body) };
}
function xt(e, r, t) {
return { type: "NamedCallout", kind: e, tag: r, arguments: t };
}
function kt(e, r) {
const t = !!(r != null && r.negate);
if (!Fe.has(e)) throw new Error(`Invalid POSIX class "${e}"`);
return { type: "CharacterSet", kind: "posix", value: e, negate: t };
}
function hr(e, r, t, n) {
if (r > t) throw new Error("Invalid reversed quantifier range");
return { type: "Quantifier", kind: e, min: r, max: t, body: n };
}
function Et(e, r) {
return { type: "Regex", body: ue(r == null ? void 0 : r.body), flags: e };
}
function wr(e) {
return { type: "Subroutine", ref: e };
}
function ee(e, r) {
var s;
const t = { negate: !1, normalizeUnknownPropertyNames: !1, skipPropertyNameValidation: !1, unicodePropertyMap: null, ...r };
let n = (s = t.unicodePropertyMap) == null ? void 0 : s.get(he(e));
if (!n) {
if (t.normalizeUnknownPropertyNames) n = It(e);
else if (t.unicodePropertyMap && !t.skipPropertyNameValidation) throw new Error(x`Invalid Unicode property "\p{${e}}"`);
}
return { type: "CharacterSet", kind: "property", value: n ?? e, negate: t.negate };
}
function $t({ flags: e, kind: r, name: t, negate: n, number: s }) {
switch (r) {
case "absence_repeater":
return mt("repeater");
case "atomic":
return N({ atomic: !0 });
case "capturing":
return gr(s, { name: t });
case "group":
return N({ flags: e });
case "lookahead":
case "lookbehind":
return H({ behind: r === "lookbehind", negate: n });
default:
throw new Error(`Unexpected group kind "${r}"`);
}
}
function ue(e) {
if (e === void 0) e = [Q()];
else if (!Array.isArray(e) || !e.length || !e.every((r) => r.type === "Alternative")) throw new Error("Invalid body; expected array of one or more Alternative nodes");
return e;
}
function mr(e) {
if (e === void 0) e = [];
else if (!Array.isArray(e) || !e.every((r) => !!r.type)) throw new Error("Invalid body; expected array of nodes");
return e;
}
function je(e) {
return e.type === "LookaroundAssertion" && e.kind === "lookahead";
}
function Xe(e) {
return e.type === "LookaroundAssertion" && e.kind === "lookbehind";
}
function At(e) {
return /^[\p{Alpha}\p{Pc}][^)]*$/u.test(e);
}
function It(e) {
return e.trim().replace(/[- _]+/g, "_").replace(/[A-Z][a-z]+(?=[A-Z])/g, "$&_").replace(/[A-Za-z]+/g, (r) => r[0].toUpperCase() + r.slice(1).toLowerCase());
}
function he(e) {
return e.replace(/[- _]+/g, "").toLowerCase();
}
function Ze(e, r) {
const t = r;
return te(e, `Unclosed character class${(t == null ? void 0 : t.type) === "Character" && t.value === 93 && t.raw === "]" ? ' (started with "]")' : ""}`);
}
function Qe(e) {
return te(e, "Unclosed group");
}
function oe(e, r, t = null) {
function n(o, a) {
for (let i = 0; i < o.length; i++) {
const u = s(o[i], a, i, o);
i = Math.max(-1, i + u);
}
}
function s(o, a = null, i = null, u = null) {
var $, A;
let c = 0, p = !1;
const l = { node: o, parent: a, key: i, container: u, root: e, remove() {
le(u).splice(Math.max(0, J(i) + c), 1), c--, p = !0;
}, removeAllNextSiblings() {
return le(u).splice(J(i) + 1);
}, removeAllPrevSiblings() {
const y = J(i) + c;
return c -= y, le(u).splice(0, Math.max(0, y));
}, replaceWith(y, k = {}) {
const v = !!k.traverse;
u ? u[Math.max(0, J(i) + c)] = y : te(a, "Can't replace root node")[i] = y, v && s(y, a, i, u), p = !0;
}, replaceWithMultiple(y, k = {}) {
const v = !!k.traverse;
if (le(u).splice(Math.max(0, J(i) + c), 1, ...y), c += y.length - 1, v) {
let V = 0;
for (let _ = 0; _ < y.length; _++) V += s(y[_], a, J(i) + _ + V, u);
}
p = !0;
}, skip() {
p = !0;
} }, { type: f } = o, g = r["*"], d = r[f], w = typeof g == "function" ? g : g == null ? void 0 : g.enter, m = typeof d == "function" ? d : d == null ? void 0 : d.enter;
if (w == null || w(l, t), m == null || m(l, t), !p) switch (f) {
case "AbsenceFunction":
case "Alternative":
case "CapturingGroup":
case "CharacterClass":
case "Group":
case "LookaroundAssertion":
n(o.body, o);
break;
case "Assertion":
case "Backreference":
case "Character":
case "CharacterSet":
case "Directive":
case "Flags":
case "NamedCallout":
case "Subroutine":
break;
case "CharacterClassRange":
s(o.min, o, "min"), s(o.max, o, "max");
break;
case "Quantifier":
s(o.body, o, "body");
break;
case "Regex":
n(o.body, o), s(o.flags, o, "flags");
break;
default:
throw new Error(`Unexpected node type "${f}"`);
}
return ($ = d == null ? void 0 : d.exit) == null || $.call(d, l, t), (A = g == null ? void 0 : g.exit) == null || A.call(g, l, t), c;
}
return s(e), e;
}
function le(e) {
if (!Array.isArray(e)) throw new Error("Container expected");
return e;
}
function J(e) {
if (typeof e != "number") throw new Error("Numeric key expected");
return e;
}
const St = String.raw`\(\?(?:[:=!>A-Za-z\-]|<[=!]|\(DEFINE\))`;
function vt(e, r) {
for (let t = 0; t < e.length; t++)
e[t] >= r && e[t]++;
}
function _t(e, r, t, n) {
return e.slice(0, r) + n + e.slice(r + t.length);
}
const S = Object.freeze({
DEFAULT: "DEFAULT",
CHAR_CLASS: "CHAR_CLASS"
});
function Pe(e, r, t, n) {
const s = new RegExp(String.raw`${r}|(?<$skip>\[\^?|\\?.)`, "gsu"), o = [!1];
let a = 0, i = "";
for (const u of e.matchAll(s)) {
const { 0: c, groups: { $skip: p } } = u;
if (!p && (!n || n === S.DEFAULT == !a)) {
t instanceof Function ? i += t(u, {
context: a ? S.CHAR_CLASS : S.DEFAULT,
negated: o[o.length - 1]
}) : i += t;
continue;
}
c[0] === "[" ? (a++, o.push(c[1] === "^")) : c === "]" && a && (a--, o.pop()), i += c;
}
return i;
}
function yr(e, r, t, n) {
Pe(e, r, t, n);
}
function Mt(e, r, t = 0, n) {
if (!new RegExp(r, "su").test(e))
return null;
const s = new RegExp(`${r}|(?<$skip>\\\\?.)`, "gsu");
s.lastIndex = t;
let o = 0, a;
for (; a = s.exec(e); ) {
const { 0: i, groups: { $skip: u } } = a;
if (!u && (!n || n === S.DEFAULT == !o))
return a;
i === "[" ? o++ : i === "]" && o && o--, s.lastIndex == a.index && s.lastIndex++;
}
return null;
}
function pe(e, r, t) {
return !!Mt(e, r, 0, t);
}
function Nt(e, r) {
const t = /\\?./gsu;
t.lastIndex = r;
let n = e.length, s = 0, o = 1, a;
for (; a = t.exec(e); ) {
const [i] = a;
if (i === "[")
s++;
else if (s)
i === "]" && s--;
else if (i === "(")
o++;
else if (i === ")" && (o--, !o)) {
n = a.index;
break;
}
}
return e.slice(r, n);
}
const qe = new RegExp(String.raw`(?<noncapturingStart>${St})|(?<capturingStart>\((?:\?<[^>]+>)?)|\\?.`, "gsu");
function Lt(e, r) {
const t = (r == null ? void 0 : r.hiddenCaptures) ?? [];
let n = (r == null ? void 0 : r.captureTransfers) ?? /* @__PURE__ */ new Map();
if (!/\(\?>/.test(e))
return {
pattern: e,
captureTransfers: n,
hiddenCaptures: t
};
const s = "(?>", o = "(?:(?=(", a = [0], i = [];
let u = 0, c = 0, p = NaN, l;
do {
l = !1;
let f = 0, g = 0, d = !1, w;
for (qe.lastIndex = Number.isNaN(p) ? 0 : p + o.length; w = qe.exec(e); ) {
const { 0: m, index: $, groups: { capturingStart: A, noncapturingStart: y } } = w;
if (m === "[")
f++;
else if (f)
m === "]" && f--;
else if (m === s && !d)
p = $, d = !0;
else if (d && y)
g++;
else if (A)
d ? g++ : (u++, a.push(u + c));
else if (m === ")" && d) {
if (!g) {
c++;
const k = u + c;
if (e = `${e.slice(0, p)}${o}${e.slice(p + s.length, $)}))<$$${k}>)${e.slice($ + 1)}`, l = !0, i.push(k), vt(t, k), n.size) {
const v = /* @__PURE__ */ new Map();
n.forEach((V, _) => {
v.set(
_ >= k ? _ + 1 : _,
V.map((q) => q >= k ? q + 1 : q)
);
}), n = v;
}
break;
}
g--;
}
}
} while (l);
return t.push(...i), e = Pe(
e,
String.raw`\\(?<backrefNum>[1-9]\d*)|<\$\$(?<wrappedBackrefNum>\d+)>`,
({ 0: f, groups: { backrefNum: g, wrappedBackrefNum: d } }) => {
if (g) {
const w = +g;
if (w > a.length - 1)
throw new Error(`Backref "${f}" greater than number of captures`);
return `\\${a[w]}`;
}
return `\\${d}`;
},
S.DEFAULT
), {
pattern: e,
captureTransfers: n,
hiddenCaptures: t
};
}
const Cr = String.raw`(?:[?*+]|\{\d+(?:,\d*)?\})`, xe = new RegExp(String.raw`
\\(?: \d+
| c[A-Za-z]
| [gk]<[^>]+>
| [pPu]\{[^\}]+\}
| u[A-Fa-f\d]{4}
| x[A-Fa-f\d]{2}
)
| \((?: \? (?: [:=!>]
| <(?:[=!]|[^>]+>)
| [A-Za-z\-]+:
| \(DEFINE\)
))?
| (?<qBase>${Cr})(?<qMod>[?+]?)(?<invalidQ>[?*+\{]?)
| \\?.
`.replace(/\s+/g, ""), "gsu");
function Ft(e) {
if (!new RegExp(`${Cr}\\+`).test(e))
return {
pattern: e
};
const r = [];
let t = null, n = null, s = "", o = 0, a;
for (xe.lastIndex = 0; a = xe.exec(e); ) {
const { 0: i, index: u, groups: { qBase: c, qMod: p, invalidQ: l } } = a;
if (i === "[")
o || (n = u), o++;
else if (i === "]")
o ? o-- : n = null;
else if (!o)
if (p === "+" && s && !s.startsWith("(")) {
if (l)
throw new Error(`Invalid quantifier "${i}"`);
let f = -1;
if (/^\{\d+\}$/.test(c))
e = _t(e, u + c.length, p, "");
else {
if (s === ")" || s === "]") {
const g = s === ")" ? t : n;
if (g === null)
throw new Error(`Invalid unmatched "${s}"`);
e = `${e.slice(0, g)}(?>${e.slice(g, u)}${c})${e.slice(u + i.length)}`;
} else
e = `${e.slice(0, u - s.length)}(?>${s}${c})${e.slice(u + i.length)}`;
f += 4;
}
xe.lastIndex += f;
} else i[0] === "(" ? r.push(u) : i === ")" && (t = r.length ? r.pop() : null);
s = i;
}
return {
pattern: e
};
}
const I = String.raw, Gt = I`\\g<(?<gRNameOrNum>[^>&]+)&R=(?<gRDepth>[^>]+)>`, Me = I`\(\?R=(?<rDepth>[^\)]+)\)|${Gt}`, we = I`\(\?<(?![=!])(?<captureName>[^>]+)>`, br = I`${we}|(?<unnamed>\()(?!\?)`, W = new RegExp(I`${we}|${Me}|\(\?|\\?.`, "gsu"), ke = "Cannot use multiple overlapping recursions";
function Pt(e, r) {
const { hiddenCaptures: t, mode: n } = {
hiddenCaptures: [],
mode: "plugin",
...r
};
let s = (r == null ? void 0 : r.captureTransfers) ?? /* @__PURE__ */ new Map();
if (!new RegExp(Me, "su").test(e))
return {
pattern: e,
captureTransfers: s,
hiddenCaptures: t
};
if (n === "plugin" && pe(e, I`\(\?\(DEFINE\)`, S.DEFAULT))
throw new Error("DEFINE groups cannot be used with recursion");
const o = [], a = pe(e, I`\\[1-9]`, S.DEFAULT), i = /* @__PURE__ */ new Map(), u = [];
let c = !1, p = 0, l = 0, f;
for (W.lastIndex = 0; f = W.exec(e); ) {
const { 0: g, groups: { captureName: d, rDepth: w, gRNameOrNum: m, gRDepth: $ } } = f;
if (g === "[")
p++;
else if (p)
g === "]" && p--;
else if (w) {
if (Je(w), c)
throw new Error(ke);
if (a)
throw new Error(
// When used in `external` mode by transpilers other than Regex+, backrefs might have
// gone through conversion from named to numbered, so avoid a misleading error
`${n === "external" ? "Backrefs" : "Numbered backrefs"} cannot be used with global recursion`
);
const A = e.slice(0, f.index), y = e.slice(W.lastIndex);
if (pe(y, Me, S.DEFAULT))
throw new Error(ke);
const k = +w - 1;
e = Ke(
A,
y,
k,
!1,
t,
o,
l
), s = er(
s,
A,
k,
o.length,
0,
l
);
break;
} else if (m) {
Je($);
let A = !1;
for (const ne of u)
if (ne.name === m || ne.num === +m) {
if (A = !0, ne.hasRecursedWithin)
throw new Error(ke);
break;
}
if (!A)
throw new Error(I`Recursive \g cannot be used outside the referenced group "${n === "external" ? m : I`\g<${m}&R=${$}>`}"`);
const y = i.get(m), k = Nt(e, y);
if (a && pe(k, I`${we}|\((?!\?)`, S.DEFAULT))
throw new Error(
// When used in `external` mode by transpilers other than Regex+, backrefs might have
// gone through conversion from named to numbered, so avoid a misleading error
`${n === "external" ? "Backrefs" : "Numbered backrefs"} cannot be used with recursion of capturing groups`
);
const v = e.slice(y, f.index), V = k.slice(v.length + g.length), _ = o.length, q = +$ - 1, Oe = Ke(
v,
V,
q,
!0,
t,
o,
l
);
s = er(
s,
v,
q,
o.length - _,
_,
l
);
const Nr = e.slice(0, y), Lr = e.slice(y + k.length);
e = `${Nr}${Oe}${Lr}`, W.lastIndex += Oe.length - g.length - v.length - V.length, u.forEach((ne) => ne.hasRecursedWithin = !0), c = !0;
} else if (d)
l++, i.set(String(l), W.lastIndex), i.set(d, W.lastIndex), u.push({
num: l,
name: d
});
else if (g[0] === "(") {
const A = g === "(";
A && (l++, i.set(String(l), W.lastIndex)), u.push(A ? { num: l } : {});
} else g === ")" && u.pop();
}
return t.push(...o), {
pattern: e,
captureTransfers: s,
hiddenCaptures: t
};
}
function Je(e) {
const r = `Max depth must be integer between 2 and 100; used ${e}`;
if (!/^[1-9]\d*$/.test(e))
throw new Error(r);
if (e = +e, e < 2 || e > 100)
throw new Error(r);
}
function Ke(e, r, t, n, s, o, a) {
const i = /* @__PURE__ */ new Set();
n && yr(e + r, we, ({ groups: { captureName: c } }) => {
i.add(c);
}, S.DEFAULT);
const u = [
t,
n ? i : null,
s,
o,
a
];
return `${e}${Ye(`(?:${e}`, "forward", ...u)}(?:)${Ye(`${r})`, "backward", ...u)}${r}`;
}
function Ye(e, r, t, n, s, o, a) {
const u = (p) => r === "forward" ? p + 2 : t - p + 2 - 1;
let c = "";
for (let p = 0; p < t; p++) {
const l = u(p);
c += Pe(
e,
I`${br}|\\k<(?<backref>[^>]+)>`,
({ 0: f, groups: { captureName: g, unnamed: d, backref: w } }) => {
if (w && n && !n.has(w))
return f;
const m = `_$${l}`;
if (d || g) {
const $ = a + o.length + 1;
return o.push($), Rt(s, $), d ? f : `(?<${g}${m}>`;
}
return I`\k<${w}${m}>`;
},
S.DEFAULT
);
}
return c;
}
function Rt(e, r) {
for (let t = 0; t < e.length; t++)
e[t] >= r && e[t]++;
}
function er(e, r, t, n, s, o) {
if (e.size && n) {
let a = 0;
yr(r, br, () => a++, S.DEFAULT);
const i = o - a + s, u = /* @__PURE__ */ new Map();
return e.forEach((c, p) => {
const l = (n - a * t) / t, f = a * t, g = p > i + a ? p + n : p, d = [];
for (const w of c)
if (w <= i)
d.push(w);
else if (w > i + a + l)
d.push(w + n);
else if (w <= i + a)
for (let m = 0; m <= t; m++)
d.push(w + a * m);
else
for (let m = 0; m <= t; m++)
d.push(w + f + l * m);
u.set(g, d);
}), u;
}
return e;
}
var b = String.fromCodePoint, h = String.raw, L = {}, me = globalThis.RegExp;
L.flagGroups = (() => {
try {
new me("(?i:)");
} catch {
return !1;
}
return !0;
})();
L.unicodeSets = (() => {
try {
new me("[[]]", "v");
} catch {
return !1;
}
return !0;
})();
L.bugFlagVLiteralHyphenIsRange = L.unicodeSets ? (() => {
try {
new me(h`[\d\-a]`, "v");
} catch {
return !0;
}
return !1;
})() : !1;
L.bugNestedClassIgnoresNegation = L.unicodeSets && new me("[[^a]]", "v").test("a");
function de(e, { enable: r, disable: t }) {
return {
dotAll: !(t != null && t.dotAll) && !!(r != null && r.dotAll || e.dotAll),
ignoreCase: !(t != null && t.ignoreCase) && !!(r != null && r.ignoreCase || e.ignoreCase)
};
}
function ae(e, r, t) {
return e.has(r) || e.set(r, t), e.get(r);
}
function Ne(e, r) {
return rr[e] >= rr[r];
}
function Ut(e, r) {
if (e == null)
throw new Error(r ?? "Value expected");
return e;
}
var rr = {
ES2025: 2025,
ES2024: 2024,
ES2018: 2018
}, Ot = (
/** @type {const} */
{
auto: "auto",
ES2025: "ES2025",
ES2024: "ES2024",
ES2018: "ES2018"
}
);
function xr(e = {}) {
if ({}.toString.call(e) !== "[object Object]")
throw new Error("Unexpected options");
if (e.target !== void 0 && !Ot[e.target])
throw new Error(`Unexpected target "${e.target}"`);
const r = {
// Sets the level of emulation rigor/strictness.
accuracy: "default",
// Disables advanced emulation that relies on returning a `RegExp` subclass, resulting in
// certain patterns not being emulatable.
avoidSubclass: !1,
// Oniguruma flags; a string with `i`, `m`, `x`, `D`, `S`, `W`, `y{g}` in any order (all
// optional). Oniguruma's `m` is equivalent to JavaScript's `s` (`dotAll`).
flags: "",
// Include JavaScript flag `g` (`global`) in the result.
global: !1,
// Include JavaScript flag `d` (`hasIndices`) in the result.
hasIndices: !1,
// Delay regex construction until first use if the transpiled pattern is at least this length.
lazyCompileLength: 1 / 0,
// JavaScript version used for generated regexes. Using `auto` detects the best value based on
// your environment. Later targets allow faster processing, simpler generated source, and
// support for additional features.
target: "auto",
// Disables minifications that simplify the pattern without changing the meaning.
verbose: !1,
...e,
// Advanced options that override standard behavior, error checking, and flags when enabled.
rules: {
// Useful with TextMate grammars that merge backreferences across patterns.
allowOrphanBackrefs: !1,
// Use ASCII `\b` and `\B`, which increases search performance of generated regexes.
asciiWordBoundaries: !1,
// Allow unnamed captures and numbered calls (backreferences and subroutines) when using
// named capture. This is Oniguruma option `ONIG_OPTION_CAPTURE_GROUP`; on by default in
// `vscode-oniguruma`.
captureGroup: !1,
// Change the recursion depth limit from Oniguruma's `20` to an integer `2`–`20`.
recursionLimit: 20,
// `^` as `\A`; `$` as`\Z`. Improves search performance of generated regexes without changing
// the meaning if searching line by line. This is Oniguruma option `ONIG_OPTION_SINGLELINE`.
singleline: !1,
...e.rules
}
};
return r.target === "auto" && (r.target = L.flagGroups ? "ES2025" : L.unicodeSets ? "ES2024" : "ES2018"), r;
}
var Dt = "[ -\r ]", Tt = /* @__PURE__ */ new Set([
b(304),
// İ
b(305)
// ı
]), F = h`[\p{L}\p{M}\p{N}\p{Pc}]`;
function kr(e) {
if (Tt.has(e))
return [e];
const r = /* @__PURE__ */ new Set(), t = e.toLowerCase(), n = t.toUpperCase(), s = zt.get(t), o = Bt.get(t), a = Vt.get(t);
return [...n].length === 1 && r.add(n), a && r.add(a), s && r.add(s), r.add(t), o && r.add(o), [...r];
}
var Re = /* @__PURE__ */ new Map(
`C Other
Cc Control cntrl
Cf Format
Cn Unassigned
Co Private_Use
Cs Surrogate
L Letter
LC Cased_Letter
Ll Lowercase_Letter
Lm Modifier_Letter
Lo Other_Letter
Lt Titlecase_Letter
Lu Uppercase_Letter
M Mark Combining_Mark
Mc Spacing_Mark
Me Enclosing_Mark
Mn Nonspacing_Mark
N Number
Nd Decimal_Number digit
Nl Letter_Number
No Other_Number
P Punctuation punct
Pc Connector_Punctuation
Pd Dash_Punctuation
Pe Close_Punctuation
Pf Final_Punctuation
Pi Initial_Punctuation
Po Other_Punctuation
Ps Open_Punctuation
S Symbol
Sc Currency_Symbol
Sk Modifier_Symbol
Sm Math_Symbol
So Other_Symbol
Z Separator
Zl Line_Separator
Zp Paragraph_Separator
Zs Space_Separator
ASCII
ASCII_Hex_Digit AHex
Alphabetic Alpha
Any
Assigned
Bidi_Control Bidi_C
Bidi_Mirrored Bidi_M
Case_Ignorable CI
Cased
Changes_When_Casefolded CWCF
Changes_When_Casemapped CWCM
Changes_When_Lowercased CWL
Changes_When_NFKC_Casefolded CWKCF
Changes_When_Titlecased CWT
Changes_When_Uppercased CWU
Dash
Default_Ignorable_Code_Point DI
Deprecated Dep
Diacritic Dia
Emoji
Emoji_Component EComp
Emoji_Modifier EMod
Emoji_Modifier_Base EBase
Emoji_Presentation EPres
Extended_Pictographic ExtPict
Extender Ext
Grapheme_Base Gr_Base
Grapheme_Extend Gr_Ext
Hex_Digit Hex
IDS_Binary_Operator IDSB
IDS_Trinary_Operator IDST
ID_Continue IDC
ID_Start IDS
Ideographic Ideo
Join_Control Join_C
Logical_Order_Exception LOE
Lowercase Lower
Math
Noncharacter_Code_Point NChar
Pattern_Syntax Pat_Syn
Pattern_White_Space Pat_WS
Quotation_Mark QMark
Radical
Regional_Indicator RI
Sentence_Terminal STerm
Soft_Dotted SD
Terminal_Punctuation Term
Unified_Ideograph UIdeo
Uppercase Upper
Variation_Selector VS
White_Space space
XID_Continue XIDC
XID_Start XIDS`.split(/\s/).map((e) => [he(e), e])
), Bt = /* @__PURE__ */ new Map([
["s", b(383)],
// s, ſ
[b(383), "s"]
// ſ, s
]), Vt = /* @__PURE__ */ new Map([
[b(223), b(7838)],
// ß, ẞ
[b(107), b(8490)],
// k, K (Kelvin)
[b(229), b(8491)],
// å, Å (Angstrom)
[b(969), b(8486)]
// ω, Ω (Ohm)
]), zt = new Map([
U(453),
U(456),
U(459),
U(498),
...Ee(8072, 8079),
...Ee(8088, 8095),
...Ee(8104, 8111),
U(8124),
U(8140),
U(8188)
]), Wt = /* @__PURE__ */ new Map([
["alnum", h`[\p{Alpha}\p{Nd}]`],
["alpha", h`\p{Alpha}`],
["ascii", h`\p{ASCII}`],
["blank", h`[\p{Zs}\t]`],
["cntrl", h`\p{Cc}`],
["digit", h`\p{Nd}`],
["graph", h`[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]`],
["lower", h`\p{Lower}`],
["print", h`[[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]\p{Zs}]`],
["punct", h`[\p{P}\p{S}]`],
// Updated value from Onig 6.9.9; changed from Unicode `\p{punct}`
["space", h`\p{space}`],
["upper", h`\p{Upper}`],
["word", h`[\p{Alpha}\p{M}\p{Nd}\p{Pc}]`],