var Se = Object.defineProperty;
var Ee = Object.getPrototypeOf;
var Ae = Reflect.get;
var K = (e) => {
  throw TypeError(e);
};
var Ie = (e, r, t) => r in e ? Se(e, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[r] = t;
var Y = (e, r, t) => Ie(e, typeof r != "symbol" ? r + "" : r, t), j = (e, r, t) => r.has(e) || K("Cannot " + t);
var m = (e, r, t) => (j(e, r, "read from private field"), t ? t.call(e) : r.get(e)), k = (e, r, t) => r.has(e) ? K("Cannot add the same private member more than once") : r instanceof WeakSet ? r.add(e) : r.set(e, t), b = (e, r, t, s) => (j(e, r, "write to private field"), s ? s.call(e, t) : r.set(e, t), t), V = (e, r, t) => (j(e, r, "access private method"), t);
var ee = (e, r, t) => Ae(Ee(e), t, r);
import { parse as ue, createCharacter as ce, createGroup as E, createAlternative as D, slug as le, createLookaroundAssertion as N, createCharacterSet as re, createUnicodeProperty as G, createCharacterClass as ve, createAssertion as te, createQuantifier as xe, createCapturingGroup as Me, createBackreference as Fe, createSubroutine as ke } from "../../../../../oniguruma-parser@0.12.1/node_modules/oniguruma-parser/dist/parser/parse.js";
import { traverse as R } from "../../../../../oniguruma-parser@0.12.1/node_modules/oniguruma-parser/dist/traverser/traverse.js";
import { possessive as Le, atomic as $e } from "../../../../../regex@6.1.0/node_modules/regex/src/atomic.js";
import { recursion as Pe } from "../../../../../regex-recursion@6.0.2/node_modules/regex-recursion/src/index.js";
import { hasOnlyChild as fe } from "../../../../../oniguruma-parser@0.12.1/node_modules/oniguruma-parser/dist/parser/node-utils.js";
var C = String.fromCodePoint, p = String.raw, A = {
  flagGroups: (() => {
    try {
      new RegExp("(?i:)");
    } catch {
      return !1;
    }
    return !0;
  })(),
  unicodeSets: (() => {
    try {
      new RegExp("[[]]", "v");
    } catch {
      return !1;
    }
    return !0;
  })()
};
A.bugFlagVLiteralHyphenIsRange = A.unicodeSets ? (() => {
  try {
    new RegExp(p`[\d\-a]`, "v");
  } catch {
    return !0;
  }
  return !1;
})() : !1;
A.bugNestedClassIgnoresNegation = A.unicodeSets && new RegExp("[[^a]]", "v").test("a");
function B(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 O(e, r, t) {
  return e.has(r) || e.set(r, t), e.get(r);
}
function q(e, r) {
  return se[e] >= se[r];
}
function Ne(e, r) {
  if (e == null)
    throw new Error(r ?? "Value expected");
  return e;
}
var se = {
  ES2025: 2025,
  ES2024: 2024,
  ES2018: 2018
}, Ge = (
  /** @type {const} */
  {
    auto: "auto",
    ES2025: "ES2025",
    ES2024: "ES2024",
    ES2018: "ES2018"
  }
);
function pe(e = {}) {
  if ({}.toString.call(e) !== "[object Object]")
    throw new Error("Unexpected options");
  if (e.target !== void 0 && !Ge[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 = A.flagGroups ? "ES2025" : A.unicodeSets ? "ES2024" : "ES2018"), r;
}
var Re = "[	-\r ]", Oe = /* @__PURE__ */ new Set([
  C(304),
  // İ
  C(305)
  // ı
]), w = p`[\p{L}\p{M}\p{N}\p{Pc}]`;
function ge(e) {
  if (Oe.has(e))
    return [e];
  const r = /* @__PURE__ */ new Set(), t = e.toLowerCase(), s = t.toUpperCase(), n = Be.get(t), a = Ue.get(t), i = De.get(t);
  return [...s].length === 1 && r.add(s), i && r.add(i), n && r.add(n), r.add(t), a && r.add(a), [...r];
}
var J = /* @__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) => [le(e), e])
), Ue = /* @__PURE__ */ new Map([
  ["s", C(383)],
  // s, ſ
  [C(383), "s"]
  // ſ, s
]), De = /* @__PURE__ */ new Map([
  [C(223), C(7838)],
  // ß, ẞ
  [C(107), C(8490)],
  // k, K (Kelvin)
  [C(229), C(8491)],
  // å, Å (Angstrom)
  [C(969), C(8486)]
  // ω, Ω (Ohm)
]), Be = new Map([
  I(453),
  I(456),
  I(459),
  I(498),
  ...H(8072, 8079),
  ...H(8088, 8095),
  ...H(8104, 8111),
  I(8124),
  I(8140),
  I(8188)
]), Te = /* @__PURE__ */ new Map([
  ["alnum", p`[\p{Alpha}\p{Nd}]`],
  ["alpha", p`\p{Alpha}`],
  ["ascii", p`\p{ASCII}`],
  ["blank", p`[\p{Zs}\t]`],
  ["cntrl", p`\p{Cc}`],
  ["digit", p`\p{Nd}`],
  ["graph", p`[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]`],
  ["lower", p`\p{Lower}`],
  ["print", p`[[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]\p{Zs}]`],
  ["punct", p`[\p{P}\p{S}]`],
  // Updated value from Onig 6.9.9; changed from Unicode `\p{punct}`
  ["space", p`\p{space}`],
  ["upper", p`\p{Upper}`],
  ["word", p`[\p{Alpha}\p{M}\p{Nd}\p{Pc}]`],
  ["xdigit", p`\p{AHex}`]
]);
function je(e, r) {
  const t = [];
  for (let s = e; s <= r; s++)
    t.push(s);
  return t;
}
function I(e) {
  const r = C(e);
  return [r.toLowerCase(), r];
}
function H(e, r) {
  return je(e, r).map((t) => I(t));
}
var de = /* @__PURE__ */ new Set([
  "Lower",
  "Lowercase",
  "Upper",
  "Uppercase",
  "Ll",
  "Lowercase_Letter",
  "Lt",
  "Titlecase_Letter",
  "Lu",
  "Uppercase_Letter"
  // The `Changes_When_*` properties (and their aliases) could be included, but they're very rare.
  // Some other properties include a handful of chars with specific cases only, but these chars are
  // generally extreme edge cases and using such properties case insensitively generally produces
  // undesired behavior anyway
]);
function Ve(e, r) {
  const t = {
    // A couple edge cases exist where options `accuracy` and `bestEffortTarget` are used:
    // - `CharacterSet` kind `text_segment` (`\X`): An exact representation would require heavy
    //   Unicode data; a best-effort approximation requires knowing the target.
    // - `CharacterSet` kind `posix` with values `graph` and `print`: Their complex Unicode
    //   representations would be hard to change to ASCII versions after the fact in the generator
    //   based on `target`/`accuracy`, so produce the appropriate structure here.
    accuracy: "default",
    asciiWordBoundaries: !1,
    avoidSubclass: !1,
    bestEffortTarget: "ES2025",
    ...r
  };
  he(e);
  const s = {
    accuracy: t.accuracy,
    asciiWordBoundaries: t.asciiWordBoundaries,
    avoidSubclass: t.avoidSubclass,
    flagDirectivesByAlt: /* @__PURE__ */ new Map(),
    jsGroupNameMap: /* @__PURE__ */ new Map(),
    minTargetEs2024: q(t.bestEffortTarget, "ES2024"),
    passedLookbehind: !1,
    strategy: null,
    // Subroutines can appear before the groups they ref, so collect reffed nodes for a second pass 
    subroutineRefMap: /* @__PURE__ */ new Map(),
    supportedGNodes: /* @__PURE__ */ new Set(),
    digitIsAscii: e.flags.digitIsAscii,
    spaceIsAscii: e.flags.spaceIsAscii,
    wordIsAscii: e.flags.wordIsAscii
  };
  R(e, He, s);
  const n = {
    dotAll: e.flags.dotAll,
    ignoreCase: e.flags.ignoreCase
  }, a = {
    currentFlags: n,
    prevFlags: null,
    globalFlags: n,
    groupOriginByCopy: /* @__PURE__ */ new Map(),
    groupsByName: /* @__PURE__ */ new Map(),
    multiplexCapturesToLeftByRef: /* @__PURE__ */ new Map(),
    openRefs: /* @__PURE__ */ new Map(),
    reffedNodesByReferencer: /* @__PURE__ */ new Map(),
    subroutineRefMap: s.subroutineRefMap
  };
  R(e, ze, a);
  const i = {
    groupsByName: a.groupsByName,
    highestOrphanBackref: 0,
    numCapturesToLeft: 0,
    reffedNodesByReferencer: a.reffedNodesByReferencer
  };
  return R(e, We, i), e._originMap = a.groupOriginByCopy, e._strategy = s.strategy, e;
}
var He = {
  AbsenceFunction({ node: e, parent: r, replaceWith: t }) {
    const { body: s, kind: n } = e;
    if (n === "repeater") {
      const a = E();
      a.body[0].body.push(
        // Insert own alts as `body`
        N({ negate: !0, body: s }),
        G("Any")
      );
      const i = E();
      i.body[0].body.push(
        xe("greedy", 0, 1 / 0, a)
      ), t(h(i, r), { traverse: !0 });
    } else
      throw new Error('Unsupported absence function "(?~|"');
  },
  Alternative: {
    enter({ node: e, parent: r, key: t }, { flagDirectivesByAlt: s }) {
      const n = e.body.filter((a) => a.kind === "flags");
      for (let a = t + 1; a < r.body.length; a++) {
        const i = r.body[a];
        O(s, i, []).push(...n);
      }
    },
    exit({ node: e }, { flagDirectivesByAlt: r }) {
      var t;
      if ((t = r.get(e)) != null && t.length) {
        const s = ye(r.get(e));
        if (s) {
          const n = E({ flags: s });
          n.body[0].body = e.body, e.body = [h(n, e)];
        }
      }
    }
  },
  Assertion({ node: e, parent: r, key: t, container: s, root: n, remove: a, replaceWith: i }, o) {
    const { kind: u, negate: c } = e, { asciiWordBoundaries: l, avoidSubclass: f, supportedGNodes: g, wordIsAscii: d } = o;
    if (u === "text_segment_boundary")
      throw new Error(`Unsupported text segment boundary "\\${c ? "Y" : "y"}"`);
    if (u === "line_end")
      i(h(N({ body: [
        D({ body: [te("string_end")] }),
        D({ body: [ce(10)] })
        // `\n`
      ] }), r));
    else if (u === "line_start")
      i(h(_(p`(?<=\A|\n(?!\z))`, { skipLookbehindValidation: !0 }), r));
    else if (u === "search_start")
      if (g.has(e))
        n.flags.sticky = !0, a();
      else {
        const y = s[t - 1];
        if (y && Ke(y))
          i(h(N({ negate: !0 }), r));
        else {
          if (f)
            throw new Error(p`Uses "\G" in a way that requires a subclass`);
          i(v(te("string_start"), r)), o.strategy = "clip_search";
        }
      }
    else if (!(u === "string_end" || u === "string_start")) if (u === "string_end_newline")
      i(h(_(p`(?=\n?\z)`), r));
    else if (u === "word_boundary") {
      if (!d && !l) {
        const y = `(?:(?<=${w})(?!${w})|(?<!${w})(?=${w}))`, T = `(?:(?<=${w})(?=${w})|(?<!${w})(?!${w}))`;
        i(h(_(c ? T : y), r));
      }
    } else
      throw new Error(`Unexpected assertion kind "${u}"`);
  },
  Backreference({ node: e }, { jsGroupNameMap: r }) {
    let { ref: t } = e;
    typeof t == "string" && !W(t) && (t = z(t, r), e.ref = t);
  },
  CapturingGroup({ node: e }, { jsGroupNameMap: r, subroutineRefMap: t }) {
    let { name: s } = e;
    s && !W(s) && (s = z(s, r), e.name = s), t.set(e.number, e), s && t.set(s, e);
  },
  CharacterClassRange({ node: e, parent: r, replaceWith: t }) {
    if (r.kind === "intersection") {
      const s = ve({ body: [e] });
      t(h(s, r), { traverse: !0 });
    }
  },
  CharacterSet({ node: e, parent: r, replaceWith: t }, { accuracy: s, minTargetEs2024: n, digitIsAscii: a, spaceIsAscii: i, wordIsAscii: o }) {
    const { kind: u, negate: c, value: l } = e;
    if (a && (u === "digit" || l === "digit")) {
      t(v(re("digit", { negate: c }), r));
      return;
    }
    if (i && (u === "space" || l === "space")) {
      t(h(Q(_(Re), c), r));
      return;
    }
    if (o && (u === "word" || l === "word")) {
      t(v(re("word", { negate: c }), r));
      return;
    }
    if (u === "any")
      t(v(G("Any"), r));
    else if (u === "digit")
      t(v(G("Nd", { negate: c }), r));
    else if (u !== "dot") if (u === "text_segment") {
      if (s === "strict")
        throw new Error(p`Use of "\X" requires non-strict accuracy`);
      const f = "\\p{Emoji}(?:\\p{EMod}|\\uFE0F\\u20E3?|[\\x{E0020}-\\x{E007E}]+\\x{E007F})?", g = p`\p{RI}{2}|${f}(?:\u200D${f})*`;
      t(h(_(
        // Close approximation of an extended grapheme cluster; see <unicode.org/reports/tr29/>
        p`(?>\r\n|${n ? p`\p{RGI_Emoji}` : g}|\P{M}\p{M}*)`,
        // Allow JS property `RGI_Emoji` through
        { skipPropertyNameValidation: !0 }
      ), r));
    } else if (u === "hex")
      t(v(G("AHex", { negate: c }), r));
    else if (u === "newline")
      t(h(_(c ? `[^
]` : `(?>\r
?|[
\v\f\u2028\u2029])`), r));
    else if (u === "posix")
      if (!n && (l === "graph" || l === "print")) {
        if (s === "strict")
          throw new Error(`POSIX class "${l}" requires min target ES2024 or non-strict accuracy`);
        let f = {
          graph: "!-~",
          print: " -~"
        }[l];
        c && (f = `\0-${C(f.codePointAt(0) - 1)}${C(f.codePointAt(2) + 1)}-􏿿`), t(h(_(`[${f}]`), r));
      } else
        t(h(Q(_(Te.get(l)), c), r));
    else if (u === "property")
      J.has(le(l)) || (e.key = "sc");
    else if (u === "space")
      t(v(G("space", { negate: c }), r));
    else if (u === "word")
      t(h(Q(_(w), c), r));
    else
      throw new Error(`Unexpected character set kind "${u}"`);
  },
  Directive({ node: e, parent: r, root: t, remove: s, replaceWith: n, removeAllPrevSiblings: a, removeAllNextSiblings: i }) {
    const { kind: o, flags: u } = e;
    if (o === "flags")
      if (!u.enable && !u.disable)
        s();
      else {
        const c = E({ flags: u });
        c.body[0].body = i(), n(h(c, r), { traverse: !0 });
      }
    else if (o === "keep") {
      const c = t.body[0], f = t.body.length === 1 && // Not emulatable if within a `CapturingGroup`
      fe(c, { type: "Group" }) && c.body[0].body.length === 1 ? c.body[0] : t;
      if (r.parent !== f || f.body.length > 1)
        throw new Error(p`Uses "\K" in a way that's unsupported`);
      const g = N({ behind: !0 });
      g.body[0].body = a(), n(h(g, r));
    } else
      throw new Error(`Unexpected directive kind "${o}"`);
  },
  Flags({ node: e, parent: r }) {
    if (e.posixIsAscii)
      throw new Error('Unsupported flag "P"');
    if (e.textSegmentMode === "word")
      throw new Error('Unsupported flag "y{w}"');
    [
      "digitIsAscii",
      // Flag D
      "extended",
      // Flag x
      "posixIsAscii",
      // Flag P
      "spaceIsAscii",
      // Flag S
      "wordIsAscii",
      // Flag W
      "textSegmentMode"
      // Flag y{g} or y{w}
    ].forEach((t) => delete e[t]), Object.assign(e, {
      // JS flag g; no Onig equiv
      global: !1,
      // JS flag d; no Onig equiv
      hasIndices: !1,
      // JS flag m; no Onig equiv but its behavior is always on in Onig. Onig's only line break
      // char is line feed, unlike JS, so this flag isn't used since it would produce inaccurate
      // results (also allows `^` and `$` to be used in the generator for string start and end)
      multiline: !1,
      // JS flag y; no Onig equiv, but used for `\G` emulation
      sticky: e.sticky ?? !1
      // Note: Regex+ doesn't allow explicitly adding flags it handles implicitly, so leave out
      // properties `unicode` (JS flag u) and `unicodeSets` (JS flag v). Keep the existing values
      // for `ignoreCase` (flag i) and `dotAll` (JS flag s, but Onig flag m)
    }), r.options = {
      disable: {
        // Onig uses different rules for flag x than Regex+, so disable the implicit flag
        x: !0,
        // Onig has no flag to control "named capture only" mode but contextually applies its
        // behavior when named capturing is used, so disable Regex+'s implicit flag for it
        n: !0
      },
      force: {
        // Always add flag v because we're generating an AST that relies on it (it enables JS
        // support for Onig features nested classes, intersection, Unicode properties, etc.).
        // However, the generator might disable flag v based on its `target` option
        v: !0
      }
    };
  },
  Group({ node: e }) {
    if (!e.flags)
      return;
    const { enable: r, disable: t } = e.flags;
    r != null && r.extended && delete r.extended, t != null && t.extended && delete t.extended, r != null && r.dotAll && (t != null && t.dotAll) && delete r.dotAll, r != null && r.ignoreCase && (t != null && t.ignoreCase) && delete r.ignoreCase, r && !Object.keys(r).length && delete e.flags.enable, t && !Object.keys(t).length && delete e.flags.disable, !e.flags.enable && !e.flags.disable && delete e.flags;
  },
  LookaroundAssertion({ node: e }, r) {
    const { kind: t } = e;
    t === "lookbehind" && (r.passedLookbehind = !0);
  },
  NamedCallout({ node: e, parent: r, replaceWith: t }) {
    const { kind: s } = e;
    if (s === "fail")
      t(h(N({ negate: !0 }), r));
    else
      throw new Error(`Unsupported named callout "(*${s.toUpperCase()}"`);
  },
  Quantifier({ node: e }) {
    if (e.body.type === "Quantifier") {
      const r = E();
      r.body[0].body.push(e.body), e.body = h(r, e);
    }
  },
  Regex: {
    enter({ node: e }, { supportedGNodes: r }) {
      const t = [];
      let s = !1, n = !1;
      for (const a of e.body)
        if (a.body.length === 1 && a.body[0].kind === "search_start")
          a.body.pop();
        else {
          const i = be(a.body);
          i ? (s = !0, Array.isArray(i) ? t.push(...i) : t.push(i)) : n = !0;
        }
      s && !n && t.forEach((a) => r.add(a));
    },
    exit(e, { accuracy: r, passedLookbehind: t, strategy: s }) {
      if (r === "strict" && t && s)
        throw new Error(p`Uses "\G" in a way that requires non-strict accuracy`);
    }
  },
  Subroutine({ node: e }, { jsGroupNameMap: r }) {
    let { ref: t } = e;
    typeof t == "string" && !W(t) && (t = z(t, r), e.ref = t);
  }
}, ze = {
  Backreference({ node: e }, { multiplexCapturesToLeftByRef: r, reffedNodesByReferencer: t }) {
    const { orphan: s, ref: n } = e;
    s || t.set(e, [...r.get(n).map(({ node: a }) => a)]);
  },
  CapturingGroup: {
    enter({
      node: e,
      parent: r,
      replaceWith: t,
      skip: s
    }, {
      groupOriginByCopy: n,
      groupsByName: a,
      multiplexCapturesToLeftByRef: i,
      openRefs: o,
      reffedNodesByReferencer: u
    }) {
      const c = n.get(e);
      if (c && o.has(e.number)) {
        const f = v(ne(e.number), r);
        u.set(f, o.get(e.number)), t(f);
        return;
      }
      o.set(e.number, e), i.set(e.number, []), e.name && O(i, e.name, []);
      const l = i.get(e.name ?? e.number);
      for (let f = 0; f < l.length; f++) {
        const g = l[f];
        if (
          // This group is from subroutine expansion, and there's a multiplex value from either the
          // origin node or a prior subroutine expansion group with the same origin
          c === g.node || c && c === g.origin || // This group is not from subroutine expansion, and it comes after a subroutine expansion
          // group that refers to this group
          e === g.origin
        ) {
          l.splice(f, 1);
          break;
        }
      }
      if (i.get(e.number).push({ node: e, origin: c }), e.name && i.get(e.name).push({ node: e, origin: c }), e.name) {
        const f = O(a, e.name, /* @__PURE__ */ new Map());
        let g = !1;
        if (c)
          g = !0;
        else
          for (const d of f.values())
            if (!d.hasDuplicateNameToRemove) {
              g = !0;
              break;
            }
        a.get(e.name).set(e, { node: e, hasDuplicateNameToRemove: g });
      }
    },
    exit({ node: e }, { openRefs: r }) {
      r.delete(e.number);
    }
  },
  Group: {
    enter({ node: e }, r) {
      r.prevFlags = r.currentFlags, e.flags && (r.currentFlags = B(r.currentFlags, e.flags));
    },
    exit(e, r) {
      r.currentFlags = r.prevFlags;
    }
  },
  Subroutine({ node: e, parent: r, replaceWith: t }, s) {
    const { isRecursive: n, ref: a } = e;
    if (n) {
      let l = r;
      for (; (l = l.parent) && !(l.type === "CapturingGroup" && (l.name === a || l.number === a)); )
        ;
      s.reffedNodesByReferencer.set(e, l);
      return;
    }
    const i = s.subroutineRefMap.get(a), o = a === 0, u = o ? ne(0) : (
      // The reffed group might itself contain subroutines, which are expanded during sub-traversal
      Ce(i, s.groupOriginByCopy, null)
    );
    let c = u;
    if (!o) {
      const l = ye(Ze(
        i,
        (g) => g.type === "Group" && !!g.flags
      )), f = l ? B(s.globalFlags, l) : s.globalFlags;
      Qe(f, s.currentFlags) || (c = E({
        flags: Je(f)
      }), c.body[0].body.push(u));
    }
    t(h(c, r), { traverse: !o });
  }
}, We = {
  Backreference({ node: e, parent: r, replaceWith: t }, s) {
    if (e.orphan) {
      s.highestOrphanBackref = Math.max(s.highestOrphanBackref, e.ref);
      return;
    }
    const a = s.reffedNodesByReferencer.get(e).filter((i) => qe(i, e));
    if (!a.length)
      t(h(N({ negate: !0 }), r));
    else if (a.length > 1) {
      const i = E({
        atomic: !0,
        body: a.reverse().map((o) => D({
          body: [Fe(o.number)]
        }))
      });
      t(h(i, r));
    } else
      e.ref = a[0].number;
  },
  CapturingGroup({ node: e }, r) {
    e.number = ++r.numCapturesToLeft, e.name && r.groupsByName.get(e.name).get(e).hasDuplicateNameToRemove && delete e.name;
  },
  Regex: {
    exit({ node: e }, r) {
      const t = Math.max(r.highestOrphanBackref - r.numCapturesToLeft, 0);
      for (let s = 0; s < t; s++) {
        const n = Me();
        e.body.at(-1).body.push(n);
      }
    }
  },
  Subroutine({ node: e }, r) {
    !e.isRecursive || e.ref === 0 || (e.ref = r.reffedNodesByReferencer.get(e).number);
  }
};
function he(e) {
  R(e, {
    "*"({ node: r, parent: t }) {
      r.parent = t;
    }
  });
}
function Qe(e, r) {
  return e.dotAll === r.dotAll && e.ignoreCase === r.ignoreCase;
}
function qe(e, r) {
  let t = r;
  do {
    if (t.type === "Regex")
      return !1;
    if (t.type === "Alternative")
      continue;
    if (t === e)
      return !1;
    const s = me(t.parent);
    for (const n of s) {
      if (n === t)
        break;
      if (n === e || we(n, e))
        return !0;
    }
  } while (t = t.parent);
  throw new Error("Unexpected path");
}
function Ce(e, r, t, s) {
  const n = Array.isArray(e) ? [] : {};
  for (const [a, i] of Object.entries(e))
    a === "parent" ? n.parent = Array.isArray(t) ? s : t : i && typeof i == "object" ? n[a] = Ce(i, r, n, t) : (a === "type" && i === "CapturingGroup" && r.set(n, r.get(e) ?? e), n[a] = i);
  return n;
}
function ne(e) {
  const r = ke(e);
  return r.isRecursive = !0, r;
}
function Ze(e, r) {
  const t = [];
  for (; e = e.parent; )
    (!r || r(e)) && t.push(e);
  return t;
}
function z(e, r) {
  if (r.has(e))
    return r.get(e);
  const t = `$${r.size}_${e.replace(/^[^$_\p{IDS}]|[^$\u200C\u200D\p{IDC}]/ug, "_")}`;
  return r.set(e, t), t;
}
function ye(e) {
  const r = ["dotAll", "ignoreCase"], t = { enable: {}, disable: {} };
  return e.forEach(({ flags: s }) => {
    r.forEach((n) => {
      var a, i;
      (a = s.enable) != null && a[n] && (delete t.disable[n], t.enable[n] = !0), (i = s.disable) != null && i[n] && (t.disable[n] = !0);
    });
  }), Object.keys(t.enable).length || delete t.enable, Object.keys(t.disable).length || delete t.disable, t.enable || t.disable ? t : null;
}
function Je({ dotAll: e, ignoreCase: r }) {
  const t = {};
  return (e || r) && (t.enable = {}, e && (t.enable.dotAll = !0), r && (t.enable.ignoreCase = !0)), (!e || !r) && (t.disable = {}, !e && (t.disable.dotAll = !0), !r && (t.disable.ignoreCase = !0)), t;
}
function me(e) {
  if (!e)
    throw new Error("Node expected");
  const { body: r } = e;
  return Array.isArray(r) ? r : r ? [r] : null;
}
function be(e) {
  const r = e.find((t) => t.kind === "search_start" || Ye(t, { negate: !1 }) || !Xe(t));
  if (!r)
    return null;
  if (r.kind === "search_start")
    return r;
  if (r.type === "LookaroundAssertion")
    return r.body[0].body[0];
  if (r.type === "CapturingGroup" || r.type === "Group") {
    const t = [];
    for (const s of r.body) {
      const n = be(s.body);
      if (!n)
        return null;
      Array.isArray(n) ? t.push(...n) : t.push(n);
    }
    return t;
  }
  return null;
}
function we(e, r) {
  const t = me(e) ?? [];
  for (const s of t)
    if (s === r || we(s, r))
      return !0;
  return !1;
}
function Xe({ type: e }) {
  return e === "Assertion" || e === "Directive" || e === "LookaroundAssertion";
}
function Ke(e) {
  const r = [
    "Character",
    "CharacterClass",
    "CharacterSet"
  ];
  return r.includes(e.type) || e.type === "Quantifier" && e.min && r.includes(e.body.type);
}
function Ye(e, r) {
  const t = {
    negate: null,
    ...r
  };
  return e.type === "LookaroundAssertion" && (t.negate === null || e.negate === t.negate) && e.body.length === 1 && fe(e.body[0], {
    type: "Assertion",
    kind: "search_start"
  });
}
function W(e) {
  return /^[$_\p{IDS}][$\u200C\u200D\p{IDC}]*$/u.test(e);
}
function _(e, r) {
  const s = ue(e, {
    ...r,
    // Providing a custom set of Unicode property names avoids converting some JS Unicode
    // properties (ex: `\p{Alpha}`) to Onig POSIX classes
    unicodePropertyMap: J
  }).body;
  return s.length > 1 || s[0].body.length > 1 ? E({ body: s }) : s[0].body[0];
}
function Q(e, r) {
  return e.negate = r, e;
}
function v(e, r) {
  return e.parent = r, e;
}
function h(e, r) {
  return he(e), e.parent = r, e;
}
function er(e, r) {
  const t = pe(r), s = q(t.target, "ES2024"), n = q(t.target, "ES2025"), a = t.rules.recursionLimit;
  if (!Number.isInteger(a) || a < 2 || a > 20)
    throw new Error("Invalid recursionLimit; use 2-20");
  let i = null, o = null;
  if (!n) {
    const d = [e.flags.ignoreCase];
    R(e, rr, {
      getCurrentModI: () => d.at(-1),
      popModI() {
        d.pop();
      },
      pushModI(y) {
        d.push(y);
      },
      setHasCasedChar() {
        d.at(-1) ? i = !0 : o = !0;
      }
    });
  }
  const u = {
    dotAll: e.flags.dotAll,
    // - Turn global flag i on if a case insensitive node was used and no case sensitive nodes were
    //   used (to avoid unnecessary node expansion).
    // - Turn global flag i off if a case sensitive node was used (since case sensitivity can't be
    //   forced without the use of ES2025 flag groups)
    ignoreCase: !!((e.flags.ignoreCase || i) && !o)
  };
  let c = e;
  const l = {
    accuracy: t.accuracy,
    appliedGlobalFlags: u,
    captureMap: /* @__PURE__ */ new Map(),
    currentFlags: {
      dotAll: e.flags.dotAll,
      ignoreCase: e.flags.ignoreCase
    },
    inCharClass: !1,
    lastNode: c,
    originMap: e._originMap,
    recursionLimit: a,
    useAppliedIgnoreCase: !!(!n && i && o),
    useFlagMods: n,
    useFlagV: s,
    verbose: t.verbose
  };
  function f(d) {
    return l.lastNode = c, c = d, Ne(tr[d.type], `Unexpected node type "${d.type}"`)(d, l, f);
  }
  const g = {
    pattern: e.body.map(f).join("|"),
    // Could reset `lastNode` at this point via `lastNode = ast`, but it isn't needed by flags
    flags: f(e.flags),
    options: { ...e.options }
  };
  return s || (delete g.options.force.v, g.options.disable.v = !0, g.options.unicodeSetsPlugin = null), g._captureTransfers = /* @__PURE__ */ new Map(), g._hiddenCaptures = [], l.captureMap.forEach((d, y) => {
    d.hidden && g._hiddenCaptures.push(y), d.transferTo && O(g._captureTransfers, d.transferTo, []).push(y);
  }), g;
}
var rr = {
  "*": {
    enter({ node: e }, r) {
      if (ie(e)) {
        const t = r.getCurrentModI();
        r.pushModI(
          e.flags ? B({ ignoreCase: t }, e.flags).ignoreCase : t
        );
      }
    },
    exit({ node: e }, r) {
      ie(e) && r.popModI();
    }
  },
  Backreference(e, r) {
    r.setHasCasedChar();
  },
  Character({ node: e }, r) {
    X(C(e.value)) && r.setHasCasedChar();
  },
  CharacterClassRange({ node: e, skip: r }, t) {
    r(), _e(e, { firstOnly: !0 }).length && t.setHasCasedChar();
  },
  CharacterSet({ node: e }, r) {
    e.kind === "property" && de.has(e.value) && r.setHasCasedChar();
  }
}, tr = {
  /**
  @param {AlternativeNode} node
  */
  Alternative({ body: e }, r, t) {
    return e.map(t).join("");
  },
  /**
  @param {AssertionNode} node
  */
  Assertion({ kind: e, negate: r }) {
    if (e === "string_end")
      return "$";
    if (e === "string_start")
      return "^";
    if (e === "word_boundary")
      return r ? p`\B` : p`\b`;
    throw new Error(`Unexpected assertion kind "${e}"`);
  },
  /**
  @param {BackreferenceNode} node
  */
  Backreference({ ref: e }, r) {
    if (typeof e != "number")
      throw new Error("Unexpected named backref in transformed AST");
    if (!r.useFlagMods && r.accuracy === "strict" && r.currentFlags.ignoreCase && !r.captureMap.get(e).ignoreCase)
      throw new Error("Use of case-insensitive backref to case-sensitive group requires target ES2025 or non-strict accuracy");
    return "\\" + e;
  },
  /**
  @param {CapturingGroupNode} node
  */
  CapturingGroup(e, r, t) {
    const { body: s, name: n, number: a } = e, i = { ignoreCase: r.currentFlags.ignoreCase }, o = r.originMap.get(e);
    return o && (i.hidden = !0, a > o.number && (i.transferTo = o.number)), r.captureMap.set(a, i), `(${n ? `?<${n}>` : ""}${s.map(t).join("|")})`;
  },
  /**
  @param {CharacterNode} node
  */
  Character({ value: e }, r) {
    const t = C(e), s = P(e, {
      escDigit: r.lastNode.type === "Backreference",
      inCharClass: r.inCharClass,
      useFlagV: r.useFlagV
    });
    if (s !== t)
      return s;
    if (r.useAppliedIgnoreCase && r.currentFlags.ignoreCase && X(t)) {
      const n = ge(t);
      return r.inCharClass ? n.join("") : n.length > 1 ? `[${n.join("")}]` : n[0];
    }
    return t;
  },
  /**
  @param {CharacterClassNode} node
  */
  CharacterClass(e, r, t) {
    const { kind: s, negate: n, parent: a } = e;
    let { body: i } = e;
    if (s === "intersection" && !r.useFlagV)
      throw new Error("Use of character class intersection requires min target ES2024");
    A.bugFlagVLiteralHyphenIsRange && r.useFlagV && i.some(oe) && (i = [ce(45), ...i.filter((c) => !oe(c))]);
    const o = () => `[${n ? "^" : ""}${i.map(t).join(s === "intersection" ? "&&" : "")}]`;
    if (!r.inCharClass) {
      if (
        // Already established `kind !== 'intersection'` if `!state.useFlagV`; don't check again
        (!r.useFlagV || A.bugNestedClassIgnoresNegation) && !n
      ) {
        const l = i.filter(
          (f) => f.type === "CharacterClass" && f.kind === "union" && f.negate
        );
        if (l.length) {
          const f = E(), g = f.body[0];
          return f.parent = a, g.parent = f, i = i.filter((d) => !l.includes(d)), e.body = i, i.length ? (e.parent = g, g.body.push(e)) : f.body.pop(), l.forEach((d) => {
            const y = D({ body: [d] });
            d.parent = y, y.parent = f, f.body.push(y);
          }), t(f);
        }
      }
      r.inCharClass = !0;
      const c = o();
      return r.inCharClass = !1, c;
    }
    const u = i[0];
    if (
      // Already established that the parent is a char class via `inCharClass`; don't check again
      s === "union" && !n && u && // Allows many nested classes to work with `target` ES2018 which doesn't support nesting
      ((!r.useFlagV || !r.verbose) && a.kind === "union" && !(A.bugFlagVLiteralHyphenIsRange && r.useFlagV) || !r.verbose && a.kind === "intersection" && // JS doesn't allow intersection with union or ranges
      i.length === 1 && u.type !== "CharacterClassRange")
    )
      return i.map(t).join("");
    if (!r.useFlagV && a.type === "CharacterClass")
      throw new Error("Uses nested character class in a way that requires min target ES2024");
    return o();
  },
  /**
  @param {CharacterClassRangeNode} node
  */
  CharacterClassRange(e, r) {
    const t = e.min.value, s = e.max.value, n = {
      escDigit: !1,
      inCharClass: !0,
      useFlagV: r.useFlagV
    }, a = P(t, n), i = P(s, n), o = /* @__PURE__ */ new Set();
    if (r.useAppliedIgnoreCase && r.currentFlags.ignoreCase) {
      const u = _e(e);
      or(u).forEach((l) => {
        o.add(
          Array.isArray(l) ? `${P(l[0], n)}-${P(l[1], n)}` : P(l, n)
        );
      });
    }
    return `${a}-${i}${[...o].join("")}`;
  },
  /**
  @param {CharacterSetNode} node
  */
  CharacterSet({ kind: e, negate: r, value: t, key: s }, n) {
    if (e === "dot")
      return n.currentFlags.dotAll ? n.appliedGlobalFlags.dotAll || n.useFlagMods ? "." : "[^]" : (
        // Onig's only line break char is line feed, unlike JS
        p`[^\n]`
      );
    if (e === "digit")
      return r ? p`\D` : p`\d`;
    if (e === "property") {
      if (n.useAppliedIgnoreCase && n.currentFlags.ignoreCase && de.has(t))
        throw new Error(`Unicode property "${t}" can't be case-insensitive when other chars have specific case`);
      return `${r ? p`\P` : p`\p`}{${s ? `${s}=` : ""}${t}}`;
    }
    if (e === "word")
      return r ? p`\W` : p`\w`;
    throw new Error(`Unexpected character set kind "${e}"`);
  },
  /**
  @param {FlagsNode} node
  */
  Flags(e, r) {
    return (
      // The transformer should never turn on the properties for flags d, g, m since Onig doesn't
      // have equivs. Flag m is never used since Onig uses different line break chars than JS
      // (node.hasIndices ? 'd' : '') +
      // (node.global ? 'g' : '') +
      // (node.multiline ? 'm' : '') +
      (r.appliedGlobalFlags.ignoreCase ? "i" : "") + (e.dotAll ? "s" : "") + (e.sticky ? "y" : "")
    );
  },
  /**
  @param {GroupNode} node
  */
  Group({ atomic: e, body: r, flags: t, parent: s }, n, a) {
    const i = n.currentFlags;
    t && (n.currentFlags = B(i, t));
    const o = r.map(a).join("|"), u = !n.verbose && r.length === 1 && // Single alt
    s.type !== "Quantifier" && !e && (!n.useFlagMods || !t) ? o : `(?${ur(e, t, n.useFlagMods)}${o})`;
    return n.currentFlags = i, u;
  },
  /**
  @param {LookaroundAssertionNode} node
  */
  LookaroundAssertion({ body: e, kind: r, negate: t }, s, n) {
    return `(?${`${r === "lookahead" ? "" : "<"}${t ? "!" : "="}`}${e.map(n).join("|")})`;
  },
  /**
  @param {QuantifierNode} node
  */
  Quantifier(e, r, t) {
    return t(e.body) + cr(e);
  },
  /**
  @param {SubroutineNode & {isRecursive: true}} node
  */
  Subroutine({ isRecursive: e, ref: r }, t) {
    if (!e)
      throw new Error("Unexpected non-recursive subroutine in transformed AST");
    const s = t.recursionLimit;
    return r === 0 ? `(?R=${s})` : p`\g<${r}&R=${s}>`;
  }
}, sr = /* @__PURE__ */ new Set([
  "$",
  "(",
  ")",
  "*",
  "+",
  ".",
  "?",
  "[",
  "\\",
  "]",
  "^",
  "{",
  "|",
  "}"
]), nr = /* @__PURE__ */ new Set([
  "-",
  "\\",
  "]",
  "^",
  // Literal `[` doesn't require escaping with flag u, but this can help work around regex source
  // linters and regex syntax processors that expect unescaped `[` to create a nested class
  "["
]), ar = /* @__PURE__ */ new Set([
  "(",
  ")",
  "-",
  "/",
  "[",
  "\\",
  "]",
  "^",
  "{",
  "|",
  "}",
  // Double punctuators; also includes already-listed `-` and `^`
  "!",
  "#",
  "$",
  "%",
  "&",
  "*",
  "+",
  ",",
  ".",
  ":",
  ";",
  "<",
  "=",
  ">",
  "?",
  "@",
  "`",
  "~"
]), ae = /* @__PURE__ */ new Map([
  [9, p`\t`],
  // horizontal tab
  [10, p`\n`],
  // line feed
  [11, p`\v`],
  // vertical tab
  [12, p`\f`],
  // form feed
  [13, p`\r`],
  // carriage return
  [8232, p`\u2028`],
  // line separator
  [8233, p`\u2029`],
  // paragraph separator
  [65279, p`\uFEFF`]
  // ZWNBSP/BOM
]), ir = new RegExp("^\\p{Cased}$", "u");
function X(e) {
  return ir.test(e);
}
function _e(e, r) {
  const t = !!(r != null && r.firstOnly), s = e.min.value, n = e.max.value, a = [];
  if (s < 65 && (n === 65535 || n >= 131071) || s === 65536 && n >= 131071)
    return a;
  for (let i = s; i <= n; i++) {
    const o = C(i);
    if (!X(o))
      continue;
    const u = ge(o).filter((c) => {
      const l = c.codePointAt(0);
      return l < s || l > n;
    });
    if (u.length && (a.push(...u), t))
      break;
  }
  return a;
}
function P(e, { escDigit: r, inCharClass: t, useFlagV: s }) {
  if (ae.has(e))
    return ae.get(e);
  if (
    // Control chars, etc.; condition modeled on the Chrome developer console's display for strings
    e < 32 || e > 126 && e < 160 || // Unicode planes 4-16; unassigned, special purpose, and private use area
    e > 262143 || // Avoid corrupting a preceding backref by immediately following it with a literal digit
    r && lr(e)
  )
    return e > 255 ? `\\u{${e.toString(16).toUpperCase()}}` : `\\x${e.toString(16).toUpperCase().padStart(2, "0")}`;
  const n = t ? s ? ar : nr : sr, a = C(e);
  return (n.has(a) ? "\\" : "") + a;
}
function or(e) {
  const r = e.map((n) => n.codePointAt(0)).sort((n, a) => n - a), t = [];
  let s = null;
  for (let n = 0; n < r.length; n++)
    r[n + 1] === r[n] + 1 ? s ?? (s = r[n]) : s === null ? t.push(r[n]) : (t.push([s, r[n]]), s = null);
  return t;
}
function ur(e, r, t) {
  if (e)
    return ">";
  let s = "";
  if (r && t) {
    const { enable: n, disable: a } = r;
    s = (n != null && n.ignoreCase ? "i" : "") + (n != null && n.dotAll ? "s" : "") + (a ? "-" : "") + (a != null && a.ignoreCase ? "i" : "") + (a != null && a.dotAll ? "s" : "");
  }
  return `${s}:`;
}
function cr({ kind: e, max: r, min: t }) {
  let s;
  return !t && r === 1 ? s = "?" : !t && r === 1 / 0 ? s = "*" : t === 1 && r === 1 / 0 ? s = "+" : t === r ? s = `{${t}}` : s = `{${t},${r === 1 / 0 ? "" : r}}`, s + {
    greedy: "",
    lazy: "?",
    possessive: "+"
  }[e];
}
function ie({ type: e }) {
  return e === "CapturingGroup" || e === "Group" || e === "LookaroundAssertion";
}
function lr(e) {
  return e > 47 && e < 58;
}
function oe({ type: e, value: r }) {
  return e === "Character" && r === 45;
}
var x, S, L, M, $, U, Z, F, fr = (F = class extends RegExp {
  /**
  @overload
  @param {string} pattern
  @param {string} [flags]
  @param {EmulatedRegExpOptions} [options]
  */
  /**
  @overload
  @param {EmulatedRegExp} pattern
  @param {string} [flags]
  */
  constructor(t, s, n) {
    var r = (...Ar) => (super(...Ar), k(this, U), /**
    @type {Map<number, {
      hidden?: true;
      transferTo?: number;
    }>}
    */
    k(this, x, /* @__PURE__ */ new Map()), /**
    @type {RegExp | EmulatedRegExp | null}
    */
    k(this, S, null), /**
    @type {string}
    */
    k(this, L), /**
    @type {Map<number, string>?}
    */
    k(this, M, null), /**
    @type {string?}
    */
    k(this, $, null), /**
    Can be used to serialize the instance.
    @type {EmulatedRegExpOptions}
    */
    Y(this, "rawOptions", {}), this);
    const a = !!(n != null && n.lazyCompile);
    if (t instanceof RegExp) {
      if (n)
        throw new Error("Cannot provide options when copying a regexp");
      const i = t;
      r(i, s), b(this, L, i.source), i instanceof F && (b(this, x, m(i, x)), b(this, M, m(i, M)), b(this, $, m(i, $)), this.rawOptions = i.rawOptions);
    } else {
      const i = {
        hiddenCaptures: [],
        strategy: null,
        transfers: [],
        ...n
      };
      r(a ? "" : t, s), b(this, L, t), b(this, x, gr(i.hiddenCaptures, i.transfers)), b(this, $, i.strategy), this.rawOptions = n ?? {};
    }
    a || b(this, S, this);
  }
  // Override the getter with one that works with lazy-compiled regexes
  get source() {
    return m(this, L) || "(?:)";
  }
  /**
  Called internally by all String/RegExp methods that use regexes.
  @override
  @param {string} str
  @returns {RegExpExecArray?}
  */
  exec(t) {
    if (!m(this, S)) {
      const { lazyCompile: a, ...i } = this.rawOptions;
      b(this, S, new F(m(this, L), this.flags, i));
    }
    const s = this.global || this.sticky, n = this.lastIndex;
    if (m(this, $) === "clip_search" && s && n) {
      this.lastIndex = 0;
      const a = V(this, U, Z).call(this, t.slice(n));
      return a && (pr(a, n, t, this.hasIndices), this.lastIndex += n), a;
    }
    return V(this, U, Z).call(this, t);
  }
}, x = new WeakMap(), S = new WeakMap(), L = new WeakMap(), M = new WeakMap(), $ = new WeakMap(), U = new WeakSet(), /**
Adds support for hidden and transfer captures.
@param {string} str
@returns
*/
Z = function(t) {
  m(this, S).lastIndex = this.lastIndex;
  const s = ee(F.prototype, this, "exec").call(m(this, S), t);
  if (this.lastIndex = m(this, S).lastIndex, !s || !m(this, x).size)
    return s;
  const n = [...s];
  s.length = 1;
  let a;
  this.hasIndices && (a = [...s.indices], s.indices.length = 1);
  const i = [0];
  for (let o = 1; o < n.length; o++) {
    const { hidden: u, transferTo: c } = m(this, x).get(o) ?? {};
    if (u ? i.push(null) : (i.push(s.length), s.push(n[o]), this.hasIndices && s.indices.push(a[o])), c && n[o] !== void 0) {
      const l = i[c];
      if (!l)
        throw new Error(`Invalid capture transfer to "${l}"`);
      if (s[l] = n[o], this.hasIndices && (s.indices[l] = a[o]), s.groups) {
        m(this, M) || b(this, M, dr(this.source));
        const f = m(this, M).get(c);
        f && (s.groups[f] = n[o], this.hasIndices && (s.indices.groups[f] = a[o]));
      }
    }
  }
  return s;
}, F);
function pr(e, r, t, s) {
  if (e.index += r, e.input = t, s) {
    const n = e.indices;
    for (let i = 0; i < n.length; i++) {
      const o = n[i];
      o && (n[i] = [o[0] + r, o[1] + r]);
    }
    const a = n.groups;
    a && Object.keys(a).forEach((i) => {
      const o = a[i];
      o && (a[i] = [o[0] + r, o[1] + r]);
    });
  }
}
function gr(e, r) {
  const t = /* @__PURE__ */ new Map();
  for (const s of e)
    t.set(s, {
      hidden: !0
    });
  for (const [s, n] of r)
    for (const a of n)
      O(t, a, {}).transferTo = s;
  return t;
}
function dr(e) {
  const r = /(?<capture>\((?:\?<(?![=!])(?<name>[^>]+)>|(?!\?)))|\\?./gsu, t = /* @__PURE__ */ new Map();
  let s = 0, n = 0, a;
  for (; a = r.exec(e); ) {
    const { 0: i, groups: { capture: o, name: u } } = a;
    i === "[" ? s++ : s ? i === "]" && s-- : o && (n++, u && t.set(n, u));
  }
  return t;
}
function Sr(e, r) {
  const t = hr(e, r);
  return t.options ? new fr(t.pattern, t.flags, t.options) : new RegExp(t.pattern, t.flags);
}
function hr(e, r) {
  const t = pe(r), s = ue(e, {
    flags: t.flags,
    normalizeUnknownPropertyNames: !0,
    rules: {
      captureGroup: t.rules.captureGroup,
      singleline: t.rules.singleline
    },
    skipBackrefValidation: t.rules.allowOrphanBackrefs,
    unicodePropertyMap: J
  }), n = Ve(s, {
    accuracy: t.accuracy,
    asciiWordBoundaries: t.rules.asciiWordBoundaries,
    avoidSubclass: t.avoidSubclass,
    bestEffortTarget: t.target
  }), a = er(n, t), i = Pe(a.pattern, {
    captureTransfers: a._captureTransfers,
    hiddenCaptures: a._hiddenCaptures,
    mode: "external"
  }), o = Le(i.pattern), u = $e(o.pattern, {
    captureTransfers: i.captureTransfers,
    hiddenCaptures: i.hiddenCaptures
  }), c = {
    pattern: u.pattern,
    flags: `${t.hasIndices ? "d" : ""}${t.global ? "g" : ""}${a.flags}${a.options.disable.v ? "u" : "v"}`
  };
  if (t.avoidSubclass) {
    if (t.lazyCompileLength !== 1 / 0)
      throw new Error("Lazy compilation requires subclass");
  } else {
    const l = u.hiddenCaptures.sort((y, T) => y - T), f = Array.from(u.captureTransfers), g = n._strategy, d = c.pattern.length >= t.lazyCompileLength;
    (l.length || f.length || g || d) && (c.options = {
      ...l.length && { hiddenCaptures: l },
      ...f.length && { transfers: f },
      ...g && { strategy: g },
      ...d && { lazyCompile: d }
    });
  }
  return c;
}
export {
  fr as EmulatedRegExp,
  Sr as toRegExp,
  hr as toRegExpDetails
};
