@kitnai/chat 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (138) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +314 -0
  3. package/dist/bash-InADTalH.js +6 -0
  4. package/dist/core-AYMC6_lb.js +5874 -0
  5. package/dist/engine-javascript-vq0WuIJl.js +2643 -0
  6. package/dist/github-dark-dimmed-DUshB20C.js +4 -0
  7. package/dist/github-light-JYsPkUQd.js +4 -0
  8. package/dist/javascript-C25yR2R2.js +6 -0
  9. package/dist/json-DxJze_jm.js +6 -0
  10. package/dist/kitn-chat.es.js +6632 -0
  11. package/dist/tsx-B8rCNbgL.js +6 -0
  12. package/dist/typescript-RycA9KXf.js +6 -0
  13. package/package.json +80 -0
  14. package/src/components/attachments.stories.tsx +304 -0
  15. package/src/components/attachments.tsx +394 -0
  16. package/src/components/chain-of-thought.stories.tsx +212 -0
  17. package/src/components/chain-of-thought.tsx +139 -0
  18. package/src/components/chat-container.stories.tsx +188 -0
  19. package/src/components/chat-container.tsx +78 -0
  20. package/src/components/chat-scope-picker.tsx +47 -0
  21. package/src/components/checkpoint.stories.tsx +103 -0
  22. package/src/components/checkpoint.tsx +81 -0
  23. package/src/components/code-block.stories.tsx +151 -0
  24. package/src/components/code-block.tsx +99 -0
  25. package/src/components/context.stories.tsx +180 -0
  26. package/src/components/context.tsx +323 -0
  27. package/src/components/conversation-item.stories.tsx +126 -0
  28. package/src/components/conversation-item.tsx +18 -0
  29. package/src/components/conversation-list.stories.tsx +134 -0
  30. package/src/components/conversation-list.tsx +100 -0
  31. package/src/components/empty.stories.tsx +435 -0
  32. package/src/components/empty.tsx +166 -0
  33. package/src/components/feedback-bar.stories.tsx +101 -0
  34. package/src/components/feedback-bar.tsx +58 -0
  35. package/src/components/file-upload.stories.tsx +157 -0
  36. package/src/components/file-upload.tsx +161 -0
  37. package/src/components/image.stories.tsx +90 -0
  38. package/src/components/image.tsx +67 -0
  39. package/src/components/loader.stories.tsx +182 -0
  40. package/src/components/loader.tsx +333 -0
  41. package/src/components/markdown.stories.tsx +181 -0
  42. package/src/components/markdown.tsx +81 -0
  43. package/src/components/message-narrow.stories.tsx +330 -0
  44. package/src/components/message-skills.stories.tsx +212 -0
  45. package/src/components/message-skills.tsx +36 -0
  46. package/src/components/message.stories.tsx +282 -0
  47. package/src/components/message.tsx +149 -0
  48. package/src/components/model-switcher.stories.tsx +98 -0
  49. package/src/components/model-switcher.tsx +36 -0
  50. package/src/components/prompt-input.stories.tsx +223 -0
  51. package/src/components/prompt-input.tsx +190 -0
  52. package/src/components/prompt-suggestion.stories.tsx +143 -0
  53. package/src/components/prompt-suggestion.tsx +115 -0
  54. package/src/components/reasoning.stories.tsx +141 -0
  55. package/src/components/reasoning.tsx +157 -0
  56. package/src/components/response-stream.tsx +103 -0
  57. package/src/components/scroll-button.stories.tsx +101 -0
  58. package/src/components/scroll-button.tsx +33 -0
  59. package/src/components/slash-command.stories.tsx +164 -0
  60. package/src/components/slash-command.tsx +223 -0
  61. package/src/components/source.stories.tsx +125 -0
  62. package/src/components/source.tsx +129 -0
  63. package/src/components/text-shimmer.stories.tsx +88 -0
  64. package/src/components/text-shimmer.tsx +37 -0
  65. package/src/components/thinking-bar.stories.tsx +88 -0
  66. package/src/components/thinking-bar.tsx +50 -0
  67. package/src/components/tool.stories.tsx +154 -0
  68. package/src/components/tool.tsx +173 -0
  69. package/src/components/voice-input.stories.tsx +84 -0
  70. package/src/components/voice-input.tsx +103 -0
  71. package/src/elements/chat-types.ts +14 -0
  72. package/src/elements/chat.tsx +111 -0
  73. package/src/elements/compiled.css +2 -0
  74. package/src/elements/conversation-list.tsx +26 -0
  75. package/src/elements/css.ts +5 -0
  76. package/src/elements/default-input.tsx +53 -0
  77. package/src/elements/define.tsx +54 -0
  78. package/src/elements/kitn-chat.stories.tsx +105 -0
  79. package/src/elements/kitn-conversation-list.stories.tsx +177 -0
  80. package/src/elements/kitn-prompt-input.stories.tsx +123 -0
  81. package/src/elements/prompt-input.tsx +39 -0
  82. package/src/elements/register.ts +9 -0
  83. package/src/elements/styles.css +12 -0
  84. package/src/index.ts +128 -0
  85. package/src/primitives/chat-config.tsx +76 -0
  86. package/src/primitives/highlighter.ts +150 -0
  87. package/src/primitives/use-auto-resize.ts +31 -0
  88. package/src/primitives/use-stick-to-bottom.ts +43 -0
  89. package/src/primitives/use-text-stream.ts +112 -0
  90. package/src/primitives/use-voice-recorder.ts +50 -0
  91. package/src/stories/chat-panel-layout.stories.tsx +144 -0
  92. package/src/stories/chat-scene.tsx +570 -0
  93. package/src/stories/checkpoint-restore.stories.tsx +224 -0
  94. package/src/stories/context-usage.stories.tsx +155 -0
  95. package/src/stories/conversation-with-reasoning.stories.tsx +151 -0
  96. package/src/stories/conversation-with-sources.stories.tsx +165 -0
  97. package/src/stories/docs/GettingStarted.mdx +76 -0
  98. package/src/stories/docs/Installation.mdx +48 -0
  99. package/src/stories/docs/Integrations.mdx +110 -0
  100. package/src/stories/docs/Introduction.mdx +29 -0
  101. package/src/stories/docs/Theming.mdx +87 -0
  102. package/src/stories/docs/theme-editor/canvas.tsx +32 -0
  103. package/src/stories/docs/theme-editor/inspector.tsx +66 -0
  104. package/src/stories/docs/theme-editor/presets.test.ts +32 -0
  105. package/src/stories/docs/theme-editor/presets.ts +64 -0
  106. package/src/stories/docs/theme-editor/theme-css.test.ts +19 -0
  107. package/src/stories/docs/theme-editor/theme-css.ts +15 -0
  108. package/src/stories/docs/theme-editor/theme-editor.tsx +145 -0
  109. package/src/stories/docs/theme-tokens.tsx +174 -0
  110. package/src/stories/full-chat.stories.tsx +18 -0
  111. package/src/stories/message-actions.stories.tsx +167 -0
  112. package/src/stories/prompt-input-variants.stories.tsx +179 -0
  113. package/src/stories/streaming-response.stories.tsx +234 -0
  114. package/src/stories/theme-editor.stories.tsx +16 -0
  115. package/src/stories/token-reference.stories.tsx +18 -0
  116. package/src/types.ts +41 -0
  117. package/src/ui/avatar.stories.tsx +104 -0
  118. package/src/ui/avatar.tsx +23 -0
  119. package/src/ui/badge.stories.tsx +87 -0
  120. package/src/ui/badge.tsx +21 -0
  121. package/src/ui/button.stories.tsx +146 -0
  122. package/src/ui/button.tsx +37 -0
  123. package/src/ui/collapsible.tsx +14 -0
  124. package/src/ui/dialog.tsx +21 -0
  125. package/src/ui/dropdown.tsx +26 -0
  126. package/src/ui/hover-card.tsx +48 -0
  127. package/src/ui/resizable.stories.tsx +171 -0
  128. package/src/ui/resizable.tsx +219 -0
  129. package/src/ui/scroll-area.tsx +13 -0
  130. package/src/ui/separator.stories.tsx +82 -0
  131. package/src/ui/separator.tsx +10 -0
  132. package/src/ui/skeleton.stories.tsx +338 -0
  133. package/src/ui/skeleton.tsx +16 -0
  134. package/src/ui/textarea.tsx +21 -0
  135. package/src/ui/tooltip.stories.tsx +75 -0
  136. package/src/ui/tooltip.tsx +22 -0
  137. package/src/utils/cn.ts +6 -0
  138. package/theme.css +115 -0
@@ -0,0 +1,2643 @@
1
+ var Fr = Object.defineProperty;
2
+ var Gr = Object.getPrototypeOf;
3
+ var Pr = Reflect.get;
4
+ var De = (e) => {
5
+ throw TypeError(e);
6
+ };
7
+ var Rr = (e, r, t) => r in e ? Fr(e, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[r] = t;
8
+ var se = (e, r, t) => Rr(e, typeof r != "symbol" ? r + "" : r, t), ye = (e, r, t) => r.has(e) || De("Cannot " + t);
9
+ 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);
10
+ var Te = (e, r, t) => Pr(Gr(e), t, r);
11
+ var ar = class {
12
+ constructor(e, r = {}) {
13
+ se(this, "patterns");
14
+ se(this, "options");
15
+ se(this, "regexps");
16
+ this.patterns = e, this.options = r;
17
+ const { forgiving: t = !1, cache: n, regexConstructor: s } = r;
18
+ if (!s) throw new Error("Option `regexConstructor` is not provided");
19
+ this.regexps = e.map((o) => {
20
+ if (typeof o != "string") return o;
21
+ const a = n == null ? void 0 : n.get(o);
22
+ if (a) {
23
+ if (a instanceof RegExp) return a;
24
+ if (t) return null;
25
+ throw a;
26
+ }
27
+ try {
28
+ const i = s(o);
29
+ return n == null || n.set(o, i), i;
30
+ } catch (i) {
31
+ if (n == null || n.set(o, i), t) return null;
32
+ throw i;
33
+ }
34
+ });
35
+ }
36
+ findNextMatchSync(e, r, t) {
37
+ const n = typeof e == "string" ? e : e.content, s = [];
38
+ function o(a, i, u = 0) {
39
+ return {
40
+ index: a,
41
+ captureIndices: i.indices.map((c) => c == null ? {
42
+ start: 4294967295,
43
+ end: 4294967295,
44
+ length: 0
45
+ } : {
46
+ start: c[0] + u,
47
+ end: c[1] + u,
48
+ length: c[1] - c[0]
49
+ })
50
+ };
51
+ }
52
+ for (let a = 0; a < this.regexps.length; a++) {
53
+ const i = this.regexps[a];
54
+ if (i)
55
+ try {
56
+ i.lastIndex = r;
57
+ const u = i.exec(n);
58
+ if (!u) continue;
59
+ if (u.index === r) return o(a, u, 0);
60
+ s.push([
61
+ a,
62
+ u,
63
+ 0
64
+ ]);
65
+ } catch (u) {
66
+ if (this.options.forgiving) continue;
67
+ throw u;
68
+ }
69
+ }
70
+ if (s.length) {
71
+ const a = Math.min(...s.map((i) => i[1].index));
72
+ for (const [i, u, c] of s) if (u.index === a) return o(i, u, c);
73
+ }
74
+ return null;
75
+ }
76
+ };
77
+ function re(e) {
78
+ if ([...e].length !== 1) throw new Error(`Expected "${e}" to be a single code point`);
79
+ return e.codePointAt(0);
80
+ }
81
+ function Ur(e, r, t) {
82
+ return e.has(r) || e.set(r, t), e.get(r);
83
+ }
84
+ const Fe = /* @__PURE__ */ new Set(["alnum", "alpha", "ascii", "blank", "cntrl", "digit", "graph", "lower", "print", "punct", "space", "upper", "word", "xdigit"]), x = String.raw;
85
+ function te(e, r) {
86
+ if (e == null) throw new Error(r ?? "Value expected");
87
+ return e;
88
+ }
89
+ 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`
90
+ \\ (?:
91
+ ${ur}
92
+ | [gk]<[^>]*>?
93
+ | [gk]'[^']*'?
94
+ | .
95
+ )
96
+ | \( (?:
97
+ \? (?:
98
+ [:=!>({]
99
+ | <[=!]
100
+ | <[^>]*>
101
+ | '[^']*'
102
+ | ~\|?
103
+ | #(?:[^)\\]|\\.?)*
104
+ | [^:)]*[:)]
105
+ )?
106
+ | \*[^\)]*\)?
107
+ )?
108
+ | (?:${Ge.source})+
109
+ | ${ir}
110
+ | .
111
+ `.replace(/\s+/g, ""), "gsu"), be = new RegExp(x`
112
+ \\ (?:
113
+ ${ur}
114
+ | .
115
+ )
116
+ | \[:(?:\^?\p{Alpha}+|\^):\]
117
+ | ${ir}
118
+ | &&
119
+ | .
120
+ `.replace(/\s+/g, ""), "gsu");
121
+ function Or(e, r = {}) {
122
+ const t = { flags: "", ...r, rules: { captureGroup: !1, singleline: !1, ...r.rules } };
123
+ if (typeof e != "string") throw new Error("String expected as pattern");
124
+ const n = nt(t.flags), s = [n.extended], o = { captureGroup: t.rules.captureGroup, getCurrentModX() {
125
+ return s.at(-1);
126
+ }, numOpenGroups: 0, popModX() {
127
+ s.pop();
128
+ }, pushModX(l) {
129
+ s.push(l);
130
+ }, replaceCurrentModX(l) {
131
+ s[s.length - 1] = l;
132
+ }, singleline: t.rules.singleline };
133
+ let a = [], i;
134
+ for (ce.lastIndex = 0; i = ce.exec(e); ) {
135
+ const l = Dr(o, e, i[0], ce.lastIndex);
136
+ l.tokens ? a.push(...l.tokens) : l.token && a.push(l.token), l.lastIndex !== void 0 && (ce.lastIndex = l.lastIndex);
137
+ }
138
+ const u = [];
139
+ let c = 0;
140
+ a.filter((l) => l.type === "GroupOpen").forEach((l) => {
141
+ l.kind === "capturing" ? l.number = ++c : l.raw === "(" && u.push(l);
142
+ }), c || u.forEach((l, f) => {
143
+ l.kind = "capturing", l.number = f + 1;
144
+ });
145
+ const p = c || u.length;
146
+ return { tokens: a.map((l) => l.type === "EscapedNumber" ? ot(l, p) : l).flat(), flags: n };
147
+ }
148
+ function Dr(e, r, t, n) {
149
+ const [s, o] = t;
150
+ if (t === "[" || t === "[^") {
151
+ const a = Tr(r, t, n);
152
+ return { tokens: a.tokens, lastIndex: a.lastIndex };
153
+ }
154
+ if (s === "\\") {
155
+ if ("AbBGyYzZ".includes(o)) return { token: Be(t, t) };
156
+ if (/^\\g[<']/.test(t)) {
157
+ if (!/^\\g(?:<[^>]+>|'[^']+')$/.test(t)) throw new Error(`Invalid group name "${t}"`);
158
+ return { token: qr(t) };
159
+ }
160
+ if (/^\\k[<']/.test(t)) {
161
+ if (!/^\\k(?:<[^>]+>|'[^']+')$/.test(t)) throw new Error(`Invalid group name "${t}"`);
162
+ return { token: lr(t) };
163
+ }
164
+ if (o === "K") return { token: pr("keep", t) };
165
+ if (o === "N" || o === "R") return { token: j("newline", t, { negate: o === "N" }) };
166
+ if (o === "O") return { token: j("any", t) };
167
+ if (o === "X") return { token: j("text_segment", t) };
168
+ const a = cr(t, { inCharClass: !1 });
169
+ return Array.isArray(a) ? { tokens: a } : { token: a };
170
+ }
171
+ if (s === "(") {
172
+ if (o === "*") return { token: et(t) };
173
+ if (t === "(?{") throw new Error(`Unsupported callout "${t}"`);
174
+ if (t.startsWith("(?#")) {
175
+ if (r[n] !== ")") throw new Error('Unclosed comment group "(?#"');
176
+ return { lastIndex: n + 1 };
177
+ }
178
+ if (/^\(\?[-imx]+[:)]$/.test(t)) return { token: Yr(t, e) };
179
+ if (e.pushModX(e.getCurrentModX()), e.numOpenGroups++, t === "(" && !e.captureGroup || t === "(?:") return { token: Y("group", t) };
180
+ if (t === "(?>") return { token: Y("atomic", t) };
181
+ if (t === "(?=" || t === "(?!" || t === "(?<=" || t === "(?<!") return { token: Y(t[2] === "<" ? "lookbehind" : "lookahead", t, { negate: t.endsWith("!") }) };
182
+ if (t === "(" && e.captureGroup || t.startsWith("(?<") && t.endsWith(">") || t.startsWith("(?'") && t.endsWith("'")) return { token: Y("capturing", t, { ...t !== "(" && { name: t.slice(3, -1) } }) };
183
+ if (t.startsWith("(?~")) {
184
+ if (t === "(?~|") throw new Error(`Unsupported absence function kind "${t}"`);
185
+ return { token: Y("absence_repeater", t) };
186
+ }
187
+ throw t === "(?(" ? new Error(`Unsupported conditional "${t}"`) : new Error(`Invalid or unsupported group option "${t}"`);
188
+ }
189
+ if (t === ")") {
190
+ if (e.popModX(), e.numOpenGroups--, e.numOpenGroups < 0) throw new Error('Unmatched ")"');
191
+ return { token: Xr(t) };
192
+ }
193
+ if (e.getCurrentModX()) {
194
+ if (t === "#") {
195
+ const a = r.indexOf(`
196
+ `, n);
197
+ return { lastIndex: a === -1 ? r.length : a };
198
+ }
199
+ if (/^\s$/.test(t)) {
200
+ const a = /\s+/y;
201
+ return a.lastIndex = n, { lastIndex: a.exec(r) ? a.lastIndex : n };
202
+ }
203
+ }
204
+ if (t === ".") return { token: j("dot", t) };
205
+ if (t === "^" || t === "$") {
206
+ const a = e.singleline ? { "^": x`\A`, $: x`\Z` }[t] : t;
207
+ return { token: Be(a, t) };
208
+ }
209
+ return t === "|" ? { token: Vr(t) } : Ge.test(t) ? { tokens: at(t) } : { token: R(re(t), t) };
210
+ }
211
+ function Tr(e, r, t) {
212
+ const n = [Ve(r[1] === "^", r)];
213
+ let s = 1, o;
214
+ for (be.lastIndex = t; o = be.exec(e); ) {
215
+ const a = o[0];
216
+ if (a[0] === "[" && a[1] !== ":") s++, n.push(Ve(a[1] === "^", a));
217
+ else if (a === "]") {
218
+ if (n.at(-1).type === "CharacterClassOpen") n.push(R(93, a));
219
+ else if (s--, n.push(zr(a)), !s) break;
220
+ } else {
221
+ const i = Br(a);
222
+ Array.isArray(i) ? n.push(...i) : n.push(i);
223
+ }
224
+ }
225
+ return { tokens: n, lastIndex: be.lastIndex || e.length };
226
+ }
227
+ function Br(e) {
228
+ if (e[0] === "\\") return cr(e, { inCharClass: !0 });
229
+ if (e[0] === "[") {
230
+ const r = /\[:(?<negate>\^?)(?<name>[a-z]+):\]/.exec(e);
231
+ if (!r || !Fe.has(r.groups.name)) throw new Error(`Invalid POSIX class "${e}"`);
232
+ return j("posix", e, { value: r.groups.name, negate: !!r.groups.negate });
233
+ }
234
+ return e === "-" ? Wr(e) : e === "&&" ? Hr(e) : R(re(e), e);
235
+ }
236
+ function cr(e, { inCharClass: r }) {
237
+ const t = e[1];
238
+ if (t === "c" || t === "C") return Kr(e);
239
+ if ("dDhHsSwW".includes(t)) return rt(e);
240
+ if (e.startsWith(x`\o{`)) throw new Error(`Incomplete, invalid, or unsupported octal code point "${e}"`);
241
+ if (/^\\[pP]\{/.test(e)) {
242
+ if (e.length === 3) throw new Error(`Incomplete or invalid Unicode property "${e}"`);
243
+ return tt(e);
244
+ }
245
+ if (new RegExp("^\\\\x[89A-Fa-f]\\p{AHex}", "u").test(e)) try {
246
+ 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();
247
+ return [...s].map((a) => {
248
+ const i = [...o.encode(a)].map((u) => `\\x${u.toString(16)}`).join("");
249
+ return R(re(a), i);
250
+ });
251
+ } catch {
252
+ throw new Error(`Multibyte code "${e}" incomplete or invalid in Oniguruma`);
253
+ }
254
+ if (t === "u" || t === "x") return R(st(e), e);
255
+ if (ze.has(t)) return R(ze.get(t), e);
256
+ if (/\d/.test(t)) return jr(r, e);
257
+ if (e === "\\") throw new Error(x`Incomplete escape "\"`);
258
+ if (t === "M") throw new Error(`Unsupported meta "${e}"`);
259
+ if ([...e].length === 2) return R(e.codePointAt(1), e);
260
+ throw new Error(`Unexpected escape "${e}"`);
261
+ }
262
+ function Vr(e) {
263
+ return { type: "Alternator", raw: e };
264
+ }
265
+ function Be(e, r) {
266
+ return { type: "Assertion", kind: e, raw: r };
267
+ }
268
+ function lr(e) {
269
+ return { type: "Backreference", raw: e };
270
+ }
271
+ function R(e, r) {
272
+ return { type: "Character", value: e, raw: r };
273
+ }
274
+ function zr(e) {
275
+ return { type: "CharacterClassClose", raw: e };
276
+ }
277
+ function Wr(e) {
278
+ return { type: "CharacterClassHyphen", raw: e };
279
+ }
280
+ function Hr(e) {
281
+ return { type: "CharacterClassIntersector", raw: e };
282
+ }
283
+ function Ve(e, r) {
284
+ return { type: "CharacterClassOpen", negate: e, raw: r };
285
+ }
286
+ function j(e, r, t = {}) {
287
+ return { type: "CharacterSet", kind: e, ...t, raw: r };
288
+ }
289
+ function pr(e, r, t = {}) {
290
+ return e === "keep" ? { type: "Directive", kind: e, raw: r } : { type: "Directive", kind: e, flags: te(t.flags), raw: r };
291
+ }
292
+ function jr(e, r) {
293
+ return { type: "EscapedNumber", inCharClass: e, raw: r };
294
+ }
295
+ function Xr(e) {
296
+ return { type: "GroupClose", raw: e };
297
+ }
298
+ function Y(e, r, t = {}) {
299
+ return { type: "GroupOpen", kind: e, ...t, raw: r };
300
+ }
301
+ function Zr(e, r, t, n) {
302
+ return { type: "NamedCallout", kind: e, tag: r, arguments: t, raw: n };
303
+ }
304
+ function Qr(e, r, t, n) {
305
+ return { type: "Quantifier", kind: e, min: r, max: t, raw: n };
306
+ }
307
+ function qr(e) {
308
+ return { type: "Subroutine", raw: e };
309
+ }
310
+ 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]]);
311
+ function Kr(e) {
312
+ const r = e[1] === "c" ? e[2] : e[3];
313
+ if (!r || !/[A-Za-z]/.test(r)) throw new Error(`Unsupported control character "${e}"`);
314
+ return R(re(r.toUpperCase()) - 64, e);
315
+ }
316
+ function Yr(e, r) {
317
+ let { on: t, off: n } = /^\(\?(?<on>[imx]*)(?:-(?<off>[-imx]*))?/.exec(e).groups;
318
+ n ?? (n = "");
319
+ const s = (r.getCurrentModX() || t.includes("x")) && !n.includes("x"), o = He(t), a = He(n), i = {};
320
+ if (o && (i.enable = o), a && (i.disable = a), e.endsWith(")")) return r.replaceCurrentModX(s), pr("flags", e, { flags: i });
321
+ if (e.endsWith(":")) return r.pushModX(s), r.numOpenGroups++, Y("group", e, { ...(o || a) && { flags: i } });
322
+ throw new Error(`Unexpected flag modifier "${e}"`);
323
+ }
324
+ function et(e) {
325
+ const r = /\(\*(?<name>[A-Za-z_]\w*)?(?:\[(?<tag>(?:[A-Za-z_]\w*)?)\])?(?:\{(?<args>[^}]*)\})?\)/.exec(e);
326
+ if (!r) throw new Error(`Incomplete or invalid named callout "${e}"`);
327
+ const { name: t, tag: n, args: s } = r.groups;
328
+ if (!t) throw new Error(`Invalid named callout "${e}"`);
329
+ if (n === "") throw new Error(`Named callout tag with empty value not allowed "${e}"`);
330
+ 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";
331
+ switch (c) {
332
+ case "fail":
333
+ case "mismatch":
334
+ case "skip":
335
+ if (o.length > 0) throw new Error(`Named callout arguments not allowed "${o}"`);
336
+ break;
337
+ case "error":
338
+ if (o.length > 1) throw new Error(`Named callout allows only one argument "${o}"`);
339
+ if (typeof a == "string") throw new Error(`Named callout argument must be a number "${a}"`);
340
+ break;
341
+ case "max":
342
+ if (!o.length || o.length > 2) throw new Error(`Named callout must have one or two arguments "${o}"`);
343
+ if (typeof a == "string" && !/^[A-Za-z_]\w*$/.test(a)) throw new Error(`Named callout argument one must be a tag or number "${a}"`);
344
+ if (o.length === 2 && (typeof i == "number" || !/^[<>X]$/.test(i))) throw new Error(`Named callout optional argument two must be '<', '>', or 'X' "${i}"`);
345
+ break;
346
+ case "count":
347
+ case "total_count":
348
+ if (o.length > 1) throw new Error(`Named callout allows only one argument "${o}"`);
349
+ if (o.length === 1 && (typeof a == "number" || !/^[<>X]$/.test(a))) throw new Error(`Named callout optional argument must be '<', '>', or 'X' "${a}"`);
350
+ break;
351
+ case "cmp":
352
+ if (o.length !== 3) throw new Error(`Named callout must have three arguments "${o}"`);
353
+ if (typeof a == "string" && !/^[A-Za-z_]\w*$/.test(a)) throw new Error(`Named callout argument one must be a tag or number "${a}"`);
354
+ if (typeof i == "number" || !/^(?:[<>!=]=|[<>])$/.test(i)) throw new Error(`Named callout argument two must be '==', '!=', '>', '<', '>=', or '<=' "${i}"`);
355
+ if (typeof u == "string" && !/^[A-Za-z_]\w*$/.test(u)) throw new Error(`Named callout argument three must be a tag or number "${u}"`);
356
+ break;
357
+ case "custom":
358
+ throw new Error(`Undefined callout name "${t}"`);
359
+ default:
360
+ throw new Error(`Unexpected named callout kind "${c}"`);
361
+ }
362
+ return Zr(c, n ?? null, (s == null ? void 0 : s.split(",")) ?? null, e);
363
+ }
364
+ function We(e) {
365
+ let r = null, t, n;
366
+ if (e[0] === "{") {
367
+ const { minStr: s, maxStr: o } = /^\{(?<minStr>\d*)(?:,(?<maxStr>\d*))?/.exec(e).groups, a = 1e5;
368
+ if (+s > a || o && +o > a) throw new Error("Quantifier value unsupported in Oniguruma");
369
+ if (t = +s, n = o === void 0 ? +s : o === "" ? 1 / 0 : +o, t > n && (r = "possessive", [t, n] = [n, t]), e.endsWith("?")) {
370
+ if (r === "possessive") throw new Error('Unsupported possessive interval quantifier chain with "?"');
371
+ r = "lazy";
372
+ } else r || (r = "greedy");
373
+ } else t = e[0] === "+" ? 1 : 0, n = e[0] === "?" ? 1 : 1 / 0, r = e[1] === "+" ? "possessive" : e[1] === "?" ? "lazy" : "greedy";
374
+ return Qr(r, t, n, e);
375
+ }
376
+ function rt(e) {
377
+ const r = e[1].toLowerCase();
378
+ return j({ d: "digit", h: "hex", s: "space", w: "word" }[r], e, { negate: e[1] !== r });
379
+ }
380
+ function tt(e) {
381
+ const { p: r, neg: t, value: n } = /^\\(?<p>[pP])\{(?<neg>\^?)(?<value>[^}]+)/.exec(e).groups;
382
+ return j("property", e, { value: n, negate: r === "P" && !t || r === "p" && !!t });
383
+ }
384
+ function He(e) {
385
+ const r = {};
386
+ 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;
387
+ }
388
+ function nt(e) {
389
+ const r = { ignoreCase: !1, dotAll: !1, extended: !1, digitIsAscii: !1, posixIsAscii: !1, spaceIsAscii: !1, wordIsAscii: !1, textSegmentMode: null };
390
+ for (let t = 0; t < e.length; t++) {
391
+ const n = e[t];
392
+ if (!"imxDPSWy".includes(n)) throw new Error(`Invalid flag "${n}"`);
393
+ if (n === "y") {
394
+ if (!/^y{[gw]}/.test(e.slice(t))) throw new Error('Invalid or unspecified flag "y" mode');
395
+ r.textSegmentMode = e[t + 2] === "g" ? "grapheme" : "word", t += 3;
396
+ continue;
397
+ }
398
+ r[{ i: "ignoreCase", m: "dotAll", x: "extended", D: "digitIsAscii", P: "posixIsAscii", S: "spaceIsAscii", W: "wordIsAscii" }[n]] = !0;
399
+ }
400
+ return r;
401
+ }
402
+ function st(e) {
403
+ 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}"`);
404
+ const r = e[2] === "{" ? new RegExp("^\\\\x\\{\\s*(?<hex>\\p{AHex}+)", "u").exec(e).groups.hex : e.slice(2);
405
+ return parseInt(r, 16);
406
+ }
407
+ function ot(e, r) {
408
+ const { raw: t, inCharClass: n } = e, s = t.slice(1);
409
+ if (!n && (s !== "0" && s.length === 1 || s[0] !== "0" && +s <= r)) return [lr(t)];
410
+ const o = [], a = s.match(/^[0-7]+|\d/g);
411
+ for (let i = 0; i < a.length; i++) {
412
+ const u = a[i];
413
+ let c;
414
+ if (i === 0 && u !== "8" && u !== "9") {
415
+ if (c = parseInt(u, 8), c > 127) throw new Error(x`Octal encoded byte above 177 unsupported "${t}"`);
416
+ } else c = re(u);
417
+ o.push(R(c, (i === 0 ? "\\" : "") + u));
418
+ }
419
+ return o;
420
+ }
421
+ function at(e) {
422
+ const r = [], t = new RegExp(Ge, "gy");
423
+ let n;
424
+ for (; n = t.exec(e); ) {
425
+ const s = n[0];
426
+ if (s[0] === "{") {
427
+ const o = /^\{(?<min>\d+),(?<max>\d+)\}\??$/.exec(s);
428
+ if (o) {
429
+ const { min: a, max: i } = o.groups;
430
+ if (+a > +i && s.endsWith("?")) {
431
+ t.lastIndex--, r.push(We(s.slice(0, -1)));
432
+ continue;
433
+ }
434
+ }
435
+ }
436
+ r.push(We(s));
437
+ }
438
+ return r;
439
+ }
440
+ function fr(e, r) {
441
+ if (!Array.isArray(e.body)) throw new Error("Expected node with body array");
442
+ if (e.body.length !== 1) return !1;
443
+ const t = e.body[0];
444
+ return !r || Object.keys(r).every((n) => r[n] === t[n]);
445
+ }
446
+ function it(e) {
447
+ return ut.has(e.type);
448
+ }
449
+ const ut = /* @__PURE__ */ new Set(["AbsenceFunction", "Backreference", "CapturingGroup", "Character", "CharacterClass", "CharacterSet", "Group", "Quantifier", "Subroutine"]);
450
+ function dr(e, r = {}) {
451
+ 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) => {
452
+ const d = n.tokens[o.nextIndex];
453
+ switch (o.parent = f, o.nextIndex++, d.type) {
454
+ case "Alternator":
455
+ return Q();
456
+ case "Assertion":
457
+ return ct(d);
458
+ case "Backreference":
459
+ return lt(d, o);
460
+ case "Character":
461
+ return ge(d.value, { useLastValid: !!g.isCheckingRangeEnd });
462
+ case "CharacterClassHyphen":
463
+ return pt(d, o, g);
464
+ case "CharacterClassOpen":
465
+ return ft(d, o, g);
466
+ case "CharacterSet":
467
+ return dt(d, o);
468
+ case "Directive":
469
+ return Ct(d.kind, { flags: d.flags });
470
+ case "GroupOpen":
471
+ return gt(d, o, g);
472
+ case "NamedCallout":
473
+ return xt(d.kind, d.tag, d.arguments);
474
+ case "Quantifier":
475
+ return ht(d, o);
476
+ case "Subroutine":
477
+ return wt(d, o);
478
+ default:
479
+ throw new Error(`Unexpected token type "${d.type}"`);
480
+ }
481
+ }, 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));
482
+ let i = a.body[0];
483
+ for (; o.nextIndex < n.tokens.length; ) {
484
+ const f = s(i, {});
485
+ f.type === "Alternative" ? (a.body.push(f), i = f) : i.body.push(f);
486
+ }
487
+ const { capturingGroups: u, hasNumberedRef: c, namedGroupsByName: p, subroutines: l } = o;
488
+ if (c && p.size && !t.rules.captureGroup) throw new Error("Numbered backref/subroutine not allowed when using named capture");
489
+ for (const { ref: f } of l) if (typeof f == "number") {
490
+ if (f > u.length) throw new Error("Subroutine uses a group number that's not defined");
491
+ f && (u[f - 1].isSubroutined = !0);
492
+ } else if (p.has(f)) {
493
+ if (p.get(f).length > 1) throw new Error(x`Subroutine uses a duplicate group name "\g<${f}>"`);
494
+ p.get(f)[0].isSubroutined = !0;
495
+ } else throw new Error(x`Subroutine uses a group name that's not defined "\g<${f}>"`);
496
+ return a;
497
+ }
498
+ function ct({ kind: e }) {
499
+ 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` });
500
+ }
501
+ function lt({ raw: e }, r) {
502
+ const t = /^\\k[<']/.test(e), n = t ? e.slice(3, -1) : e.slice(1), s = (o, a = !1) => {
503
+ const i = r.capturingGroups.length;
504
+ let u = !1;
505
+ if (o > i) if (r.skipBackrefValidation) u = !0;
506
+ else throw new Error(`Not enough capturing groups defined to the left "${e}"`);
507
+ return r.hasNumberedRef = !0, ve(a ? i + 1 - o : o, { orphan: u });
508
+ };
509
+ if (t) {
510
+ const o = /^(?<sign>-?)0*(?<num>[1-9]\d*)$/.exec(n);
511
+ if (o) return s(+o.groups.num, !!o.groups.sign);
512
+ if (/[-+]/.test(n)) throw new Error(`Invalid backref name "${e}"`);
513
+ if (!r.namedGroupsByName.has(n)) throw new Error(`Group name not defined to the left "${e}"`);
514
+ return ve(n);
515
+ }
516
+ return s(+n);
517
+ }
518
+ function pt(e, r, t) {
519
+ const { tokens: n, walk: s } = r, o = r.parent, a = o.body.at(-1), i = n[r.nextIndex];
520
+ if (!t.isCheckingRangeEnd && a && a.type !== "CharacterClass" && a.type !== "CharacterClassRange" && i && i.type !== "CharacterClassOpen" && i.type !== "CharacterClassClose" && i.type !== "CharacterClassIntersector") {
521
+ const u = s(o, { ...t, isCheckingRangeEnd: !0 });
522
+ if (a.type === "Character" && u.type === "Character") return o.body.pop(), yt(a, u);
523
+ throw new Error("Invalid character class range");
524
+ }
525
+ return ge(re("-"));
526
+ }
527
+ function ft({ negate: e }, r, t) {
528
+ const { tokens: n, walk: s } = r, o = [fe()], a = n[r.nextIndex];
529
+ let i = Ze(a);
530
+ for (; i.type !== "CharacterClassClose"; ) {
531
+ if (i.type === "CharacterClassIntersector") o.push(fe()), r.nextIndex++;
532
+ else {
533
+ const c = o.at(-1);
534
+ c.body.push(s(c, t));
535
+ }
536
+ i = Ze(n[r.nextIndex], a);
537
+ }
538
+ const u = fe({ negate: e });
539
+ 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;
540
+ }
541
+ function dt({ kind: e, negate: r, value: t }, n) {
542
+ const { normalizeUnknownPropertyNames: s, skipPropertyNameValidation: o, unicodePropertyMap: a } = n;
543
+ if (e === "property") {
544
+ const i = he(t);
545
+ if (Fe.has(i) && !(a != null && a.has(i))) e = "posix", t = i;
546
+ else return ee(t, { negate: r, normalizeUnknownPropertyNames: s, skipPropertyNameValidation: o, unicodePropertyMap: a });
547
+ }
548
+ return e === "posix" ? kt(t, { negate: r }) : _e(e, { negate: r });
549
+ }
550
+ function gt(e, r, t) {
551
+ 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;
552
+ 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");
553
+ let f = Qe(n[r.nextIndex]);
554
+ for (; f.type !== "GroupClose"; ) {
555
+ if (f.type === "Alternator") u.body.push(Q()), r.nextIndex++;
556
+ else {
557
+ const g = u.body.at(-1), d = i(g, { ...t, isInAbsenceFunction: t.isInAbsenceFunction || c, isInLookbehind: t.isInLookbehind || p, isInNegLookbehind: t.isInNegLookbehind || l });
558
+ if (g.body.push(d), (p || t.isInLookbehind) && !a) {
559
+ const w = "Lookbehind includes a pattern not allowed by Oniguruma";
560
+ if (l || t.isInNegLookbehind) {
561
+ if (je(d) || d.type === "CapturingGroup") throw new Error(w);
562
+ } else if (je(d) || Xe(d) && d.negate) throw new Error(w);
563
+ }
564
+ }
565
+ f = Qe(n[r.nextIndex]);
566
+ }
567
+ return r.nextIndex++, u;
568
+ }
569
+ function ht({ kind: e, min: r, max: t }, n) {
570
+ const s = n.parent, o = s.body.at(-1);
571
+ if (!o || !it(o)) throw new Error("Quantifier requires a repeatable token");
572
+ const a = hr(e, r, t, o);
573
+ return s.body.pop(), a;
574
+ }
575
+ function wt({ raw: e }, r) {
576
+ const { capturingGroups: t, subroutines: n } = r;
577
+ let s = e.slice(3, -1);
578
+ const o = /^(?<sign>[-+]?)0*(?<num>[1-9]\d*)$/.exec(s);
579
+ if (o) {
580
+ const i = +o.groups.num, u = t.length;
581
+ if (r.hasNumberedRef = !0, s = { "": i, "+": u + i, "-": u + 1 - i }[o.groups.sign], s < 1) throw new Error("Invalid subroutine number");
582
+ } else s === "0" && (s = 0);
583
+ const a = wr(s);
584
+ return n.push(a), a;
585
+ }
586
+ function mt(e, r) {
587
+ return { type: "AbsenceFunction", kind: e, body: ue(r == null ? void 0 : r.body) };
588
+ }
589
+ function Q(e) {
590
+ return { type: "Alternative", body: mr(e == null ? void 0 : e.body) };
591
+ }
592
+ function Se(e, r) {
593
+ const t = { type: "Assertion", kind: e };
594
+ return (e === "word_boundary" || e === "text_segment_boundary") && (t.negate = !!(r != null && r.negate)), t;
595
+ }
596
+ function ve(e, r) {
597
+ const t = !!(r != null && r.orphan);
598
+ return { type: "Backreference", ref: e, ...t && { orphan: t } };
599
+ }
600
+ function gr(e, r) {
601
+ const t = { name: void 0, isSubroutined: !1, ...r };
602
+ if (t.name !== void 0 && !At(t.name)) throw new Error(`Group name "${t.name}" invalid in Oniguruma`);
603
+ return { type: "CapturingGroup", number: e, ...t.name && { name: t.name }, ...t.isSubroutined && { isSubroutined: t.isSubroutined }, body: ue(r == null ? void 0 : r.body) };
604
+ }
605
+ function ge(e, r) {
606
+ const t = { useLastValid: !1, ...r };
607
+ if (e > 1114111) {
608
+ const n = e.toString(16);
609
+ if (t.useLastValid) e = 1114111;
610
+ 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}}"`);
611
+ }
612
+ return { type: "Character", value: e };
613
+ }
614
+ function fe(e) {
615
+ const r = { kind: "union", negate: !1, ...e };
616
+ return { type: "CharacterClass", kind: r.kind, negate: r.negate, body: mr(e == null ? void 0 : e.body) };
617
+ }
618
+ function yt(e, r) {
619
+ if (r.value < e.value) throw new Error("Character class range out of order");
620
+ return { type: "CharacterClassRange", min: e, max: r };
621
+ }
622
+ function _e(e, r) {
623
+ const t = !!(r != null && r.negate), n = { type: "CharacterSet", kind: e };
624
+ return (e === "digit" || e === "hex" || e === "newline" || e === "space" || e === "word") && (n.negate = t), (e === "text_segment" || e === "newline" && !t) && (n.variableLength = !0), n;
625
+ }
626
+ function Ct(e, r = {}) {
627
+ if (e === "keep") return { type: "Directive", kind: e };
628
+ if (e === "flags") return { type: "Directive", kind: e, flags: te(r.flags) };
629
+ throw new Error(`Unexpected directive kind "${e}"`);
630
+ }
631
+ function bt(e) {
632
+ return { type: "Flags", ...e };
633
+ }
634
+ function N(e) {
635
+ const r = e == null ? void 0 : e.atomic, t = e == null ? void 0 : e.flags;
636
+ if (r && t) throw new Error("Atomic group cannot have flags");
637
+ return { type: "Group", ...r && { atomic: r }, ...t && { flags: t }, body: ue(e == null ? void 0 : e.body) };
638
+ }
639
+ function H(e) {
640
+ const r = { behind: !1, negate: !1, ...e };
641
+ return { type: "LookaroundAssertion", kind: r.behind ? "lookbehind" : "lookahead", negate: r.negate, body: ue(e == null ? void 0 : e.body) };
642
+ }
643
+ function xt(e, r, t) {
644
+ return { type: "NamedCallout", kind: e, tag: r, arguments: t };
645
+ }
646
+ function kt(e, r) {
647
+ const t = !!(r != null && r.negate);
648
+ if (!Fe.has(e)) throw new Error(`Invalid POSIX class "${e}"`);
649
+ return { type: "CharacterSet", kind: "posix", value: e, negate: t };
650
+ }
651
+ function hr(e, r, t, n) {
652
+ if (r > t) throw new Error("Invalid reversed quantifier range");
653
+ return { type: "Quantifier", kind: e, min: r, max: t, body: n };
654
+ }
655
+ function Et(e, r) {
656
+ return { type: "Regex", body: ue(r == null ? void 0 : r.body), flags: e };
657
+ }
658
+ function wr(e) {
659
+ return { type: "Subroutine", ref: e };
660
+ }
661
+ function ee(e, r) {
662
+ var s;
663
+ const t = { negate: !1, normalizeUnknownPropertyNames: !1, skipPropertyNameValidation: !1, unicodePropertyMap: null, ...r };
664
+ let n = (s = t.unicodePropertyMap) == null ? void 0 : s.get(he(e));
665
+ if (!n) {
666
+ if (t.normalizeUnknownPropertyNames) n = It(e);
667
+ else if (t.unicodePropertyMap && !t.skipPropertyNameValidation) throw new Error(x`Invalid Unicode property "\p{${e}}"`);
668
+ }
669
+ return { type: "CharacterSet", kind: "property", value: n ?? e, negate: t.negate };
670
+ }
671
+ function $t({ flags: e, kind: r, name: t, negate: n, number: s }) {
672
+ switch (r) {
673
+ case "absence_repeater":
674
+ return mt("repeater");
675
+ case "atomic":
676
+ return N({ atomic: !0 });
677
+ case "capturing":
678
+ return gr(s, { name: t });
679
+ case "group":
680
+ return N({ flags: e });
681
+ case "lookahead":
682
+ case "lookbehind":
683
+ return H({ behind: r === "lookbehind", negate: n });
684
+ default:
685
+ throw new Error(`Unexpected group kind "${r}"`);
686
+ }
687
+ }
688
+ function ue(e) {
689
+ if (e === void 0) e = [Q()];
690
+ 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");
691
+ return e;
692
+ }
693
+ function mr(e) {
694
+ if (e === void 0) e = [];
695
+ else if (!Array.isArray(e) || !e.every((r) => !!r.type)) throw new Error("Invalid body; expected array of nodes");
696
+ return e;
697
+ }
698
+ function je(e) {
699
+ return e.type === "LookaroundAssertion" && e.kind === "lookahead";
700
+ }
701
+ function Xe(e) {
702
+ return e.type === "LookaroundAssertion" && e.kind === "lookbehind";
703
+ }
704
+ function At(e) {
705
+ return /^[\p{Alpha}\p{Pc}][^)]*$/u.test(e);
706
+ }
707
+ function It(e) {
708
+ 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());
709
+ }
710
+ function he(e) {
711
+ return e.replace(/[- _]+/g, "").toLowerCase();
712
+ }
713
+ function Ze(e, r) {
714
+ const t = r;
715
+ return te(e, `Unclosed character class${(t == null ? void 0 : t.type) === "Character" && t.value === 93 && t.raw === "]" ? ' (started with "]")' : ""}`);
716
+ }
717
+ function Qe(e) {
718
+ return te(e, "Unclosed group");
719
+ }
720
+ function oe(e, r, t = null) {
721
+ function n(o, a) {
722
+ for (let i = 0; i < o.length; i++) {
723
+ const u = s(o[i], a, i, o);
724
+ i = Math.max(-1, i + u);
725
+ }
726
+ }
727
+ function s(o, a = null, i = null, u = null) {
728
+ var $, A;
729
+ let c = 0, p = !1;
730
+ const l = { node: o, parent: a, key: i, container: u, root: e, remove() {
731
+ le(u).splice(Math.max(0, J(i) + c), 1), c--, p = !0;
732
+ }, removeAllNextSiblings() {
733
+ return le(u).splice(J(i) + 1);
734
+ }, removeAllPrevSiblings() {
735
+ const y = J(i) + c;
736
+ return c -= y, le(u).splice(0, Math.max(0, y));
737
+ }, replaceWith(y, k = {}) {
738
+ const v = !!k.traverse;
739
+ 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;
740
+ }, replaceWithMultiple(y, k = {}) {
741
+ const v = !!k.traverse;
742
+ if (le(u).splice(Math.max(0, J(i) + c), 1, ...y), c += y.length - 1, v) {
743
+ let V = 0;
744
+ for (let _ = 0; _ < y.length; _++) V += s(y[_], a, J(i) + _ + V, u);
745
+ }
746
+ p = !0;
747
+ }, skip() {
748
+ p = !0;
749
+ } }, { 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;
750
+ if (w == null || w(l, t), m == null || m(l, t), !p) switch (f) {
751
+ case "AbsenceFunction":
752
+ case "Alternative":
753
+ case "CapturingGroup":
754
+ case "CharacterClass":
755
+ case "Group":
756
+ case "LookaroundAssertion":
757
+ n(o.body, o);
758
+ break;
759
+ case "Assertion":
760
+ case "Backreference":
761
+ case "Character":
762
+ case "CharacterSet":
763
+ case "Directive":
764
+ case "Flags":
765
+ case "NamedCallout":
766
+ case "Subroutine":
767
+ break;
768
+ case "CharacterClassRange":
769
+ s(o.min, o, "min"), s(o.max, o, "max");
770
+ break;
771
+ case "Quantifier":
772
+ s(o.body, o, "body");
773
+ break;
774
+ case "Regex":
775
+ n(o.body, o), s(o.flags, o, "flags");
776
+ break;
777
+ default:
778
+ throw new Error(`Unexpected node type "${f}"`);
779
+ }
780
+ 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;
781
+ }
782
+ return s(e), e;
783
+ }
784
+ function le(e) {
785
+ if (!Array.isArray(e)) throw new Error("Container expected");
786
+ return e;
787
+ }
788
+ function J(e) {
789
+ if (typeof e != "number") throw new Error("Numeric key expected");
790
+ return e;
791
+ }
792
+ const St = String.raw`\(\?(?:[:=!>A-Za-z\-]|<[=!]|\(DEFINE\))`;
793
+ function vt(e, r) {
794
+ for (let t = 0; t < e.length; t++)
795
+ e[t] >= r && e[t]++;
796
+ }
797
+ function _t(e, r, t, n) {
798
+ return e.slice(0, r) + n + e.slice(r + t.length);
799
+ }
800
+ const S = Object.freeze({
801
+ DEFAULT: "DEFAULT",
802
+ CHAR_CLASS: "CHAR_CLASS"
803
+ });
804
+ function Pe(e, r, t, n) {
805
+ const s = new RegExp(String.raw`${r}|(?<$skip>\[\^?|\\?.)`, "gsu"), o = [!1];
806
+ let a = 0, i = "";
807
+ for (const u of e.matchAll(s)) {
808
+ const { 0: c, groups: { $skip: p } } = u;
809
+ if (!p && (!n || n === S.DEFAULT == !a)) {
810
+ t instanceof Function ? i += t(u, {
811
+ context: a ? S.CHAR_CLASS : S.DEFAULT,
812
+ negated: o[o.length - 1]
813
+ }) : i += t;
814
+ continue;
815
+ }
816
+ c[0] === "[" ? (a++, o.push(c[1] === "^")) : c === "]" && a && (a--, o.pop()), i += c;
817
+ }
818
+ return i;
819
+ }
820
+ function yr(e, r, t, n) {
821
+ Pe(e, r, t, n);
822
+ }
823
+ function Mt(e, r, t = 0, n) {
824
+ if (!new RegExp(r, "su").test(e))
825
+ return null;
826
+ const s = new RegExp(`${r}|(?<$skip>\\\\?.)`, "gsu");
827
+ s.lastIndex = t;
828
+ let o = 0, a;
829
+ for (; a = s.exec(e); ) {
830
+ const { 0: i, groups: { $skip: u } } = a;
831
+ if (!u && (!n || n === S.DEFAULT == !o))
832
+ return a;
833
+ i === "[" ? o++ : i === "]" && o && o--, s.lastIndex == a.index && s.lastIndex++;
834
+ }
835
+ return null;
836
+ }
837
+ function pe(e, r, t) {
838
+ return !!Mt(e, r, 0, t);
839
+ }
840
+ function Nt(e, r) {
841
+ const t = /\\?./gsu;
842
+ t.lastIndex = r;
843
+ let n = e.length, s = 0, o = 1, a;
844
+ for (; a = t.exec(e); ) {
845
+ const [i] = a;
846
+ if (i === "[")
847
+ s++;
848
+ else if (s)
849
+ i === "]" && s--;
850
+ else if (i === "(")
851
+ o++;
852
+ else if (i === ")" && (o--, !o)) {
853
+ n = a.index;
854
+ break;
855
+ }
856
+ }
857
+ return e.slice(r, n);
858
+ }
859
+ const qe = new RegExp(String.raw`(?<noncapturingStart>${St})|(?<capturingStart>\((?:\?<[^>]+>)?)|\\?.`, "gsu");
860
+ function Lt(e, r) {
861
+ const t = (r == null ? void 0 : r.hiddenCaptures) ?? [];
862
+ let n = (r == null ? void 0 : r.captureTransfers) ?? /* @__PURE__ */ new Map();
863
+ if (!/\(\?>/.test(e))
864
+ return {
865
+ pattern: e,
866
+ captureTransfers: n,
867
+ hiddenCaptures: t
868
+ };
869
+ const s = "(?>", o = "(?:(?=(", a = [0], i = [];
870
+ let u = 0, c = 0, p = NaN, l;
871
+ do {
872
+ l = !1;
873
+ let f = 0, g = 0, d = !1, w;
874
+ for (qe.lastIndex = Number.isNaN(p) ? 0 : p + o.length; w = qe.exec(e); ) {
875
+ const { 0: m, index: $, groups: { capturingStart: A, noncapturingStart: y } } = w;
876
+ if (m === "[")
877
+ f++;
878
+ else if (f)
879
+ m === "]" && f--;
880
+ else if (m === s && !d)
881
+ p = $, d = !0;
882
+ else if (d && y)
883
+ g++;
884
+ else if (A)
885
+ d ? g++ : (u++, a.push(u + c));
886
+ else if (m === ")" && d) {
887
+ if (!g) {
888
+ c++;
889
+ const k = u + c;
890
+ 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) {
891
+ const v = /* @__PURE__ */ new Map();
892
+ n.forEach((V, _) => {
893
+ v.set(
894
+ _ >= k ? _ + 1 : _,
895
+ V.map((q) => q >= k ? q + 1 : q)
896
+ );
897
+ }), n = v;
898
+ }
899
+ break;
900
+ }
901
+ g--;
902
+ }
903
+ }
904
+ } while (l);
905
+ return t.push(...i), e = Pe(
906
+ e,
907
+ String.raw`\\(?<backrefNum>[1-9]\d*)|<\$\$(?<wrappedBackrefNum>\d+)>`,
908
+ ({ 0: f, groups: { backrefNum: g, wrappedBackrefNum: d } }) => {
909
+ if (g) {
910
+ const w = +g;
911
+ if (w > a.length - 1)
912
+ throw new Error(`Backref "${f}" greater than number of captures`);
913
+ return `\\${a[w]}`;
914
+ }
915
+ return `\\${d}`;
916
+ },
917
+ S.DEFAULT
918
+ ), {
919
+ pattern: e,
920
+ captureTransfers: n,
921
+ hiddenCaptures: t
922
+ };
923
+ }
924
+ const Cr = String.raw`(?:[?*+]|\{\d+(?:,\d*)?\})`, xe = new RegExp(String.raw`
925
+ \\(?: \d+
926
+ | c[A-Za-z]
927
+ | [gk]<[^>]+>
928
+ | [pPu]\{[^\}]+\}
929
+ | u[A-Fa-f\d]{4}
930
+ | x[A-Fa-f\d]{2}
931
+ )
932
+ | \((?: \? (?: [:=!>]
933
+ | <(?:[=!]|[^>]+>)
934
+ | [A-Za-z\-]+:
935
+ | \(DEFINE\)
936
+ ))?
937
+ | (?<qBase>${Cr})(?<qMod>[?+]?)(?<invalidQ>[?*+\{]?)
938
+ | \\?.
939
+ `.replace(/\s+/g, ""), "gsu");
940
+ function Ft(e) {
941
+ if (!new RegExp(`${Cr}\\+`).test(e))
942
+ return {
943
+ pattern: e
944
+ };
945
+ const r = [];
946
+ let t = null, n = null, s = "", o = 0, a;
947
+ for (xe.lastIndex = 0; a = xe.exec(e); ) {
948
+ const { 0: i, index: u, groups: { qBase: c, qMod: p, invalidQ: l } } = a;
949
+ if (i === "[")
950
+ o || (n = u), o++;
951
+ else if (i === "]")
952
+ o ? o-- : n = null;
953
+ else if (!o)
954
+ if (p === "+" && s && !s.startsWith("(")) {
955
+ if (l)
956
+ throw new Error(`Invalid quantifier "${i}"`);
957
+ let f = -1;
958
+ if (/^\{\d+\}$/.test(c))
959
+ e = _t(e, u + c.length, p, "");
960
+ else {
961
+ if (s === ")" || s === "]") {
962
+ const g = s === ")" ? t : n;
963
+ if (g === null)
964
+ throw new Error(`Invalid unmatched "${s}"`);
965
+ e = `${e.slice(0, g)}(?>${e.slice(g, u)}${c})${e.slice(u + i.length)}`;
966
+ } else
967
+ e = `${e.slice(0, u - s.length)}(?>${s}${c})${e.slice(u + i.length)}`;
968
+ f += 4;
969
+ }
970
+ xe.lastIndex += f;
971
+ } else i[0] === "(" ? r.push(u) : i === ")" && (t = r.length ? r.pop() : null);
972
+ s = i;
973
+ }
974
+ return {
975
+ pattern: e
976
+ };
977
+ }
978
+ 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";
979
+ function Pt(e, r) {
980
+ const { hiddenCaptures: t, mode: n } = {
981
+ hiddenCaptures: [],
982
+ mode: "plugin",
983
+ ...r
984
+ };
985
+ let s = (r == null ? void 0 : r.captureTransfers) ?? /* @__PURE__ */ new Map();
986
+ if (!new RegExp(Me, "su").test(e))
987
+ return {
988
+ pattern: e,
989
+ captureTransfers: s,
990
+ hiddenCaptures: t
991
+ };
992
+ if (n === "plugin" && pe(e, I`\(\?\(DEFINE\)`, S.DEFAULT))
993
+ throw new Error("DEFINE groups cannot be used with recursion");
994
+ const o = [], a = pe(e, I`\\[1-9]`, S.DEFAULT), i = /* @__PURE__ */ new Map(), u = [];
995
+ let c = !1, p = 0, l = 0, f;
996
+ for (W.lastIndex = 0; f = W.exec(e); ) {
997
+ const { 0: g, groups: { captureName: d, rDepth: w, gRNameOrNum: m, gRDepth: $ } } = f;
998
+ if (g === "[")
999
+ p++;
1000
+ else if (p)
1001
+ g === "]" && p--;
1002
+ else if (w) {
1003
+ if (Je(w), c)
1004
+ throw new Error(ke);
1005
+ if (a)
1006
+ throw new Error(
1007
+ // When used in `external` mode by transpilers other than Regex+, backrefs might have
1008
+ // gone through conversion from named to numbered, so avoid a misleading error
1009
+ `${n === "external" ? "Backrefs" : "Numbered backrefs"} cannot be used with global recursion`
1010
+ );
1011
+ const A = e.slice(0, f.index), y = e.slice(W.lastIndex);
1012
+ if (pe(y, Me, S.DEFAULT))
1013
+ throw new Error(ke);
1014
+ const k = +w - 1;
1015
+ e = Ke(
1016
+ A,
1017
+ y,
1018
+ k,
1019
+ !1,
1020
+ t,
1021
+ o,
1022
+ l
1023
+ ), s = er(
1024
+ s,
1025
+ A,
1026
+ k,
1027
+ o.length,
1028
+ 0,
1029
+ l
1030
+ );
1031
+ break;
1032
+ } else if (m) {
1033
+ Je($);
1034
+ let A = !1;
1035
+ for (const ne of u)
1036
+ if (ne.name === m || ne.num === +m) {
1037
+ if (A = !0, ne.hasRecursedWithin)
1038
+ throw new Error(ke);
1039
+ break;
1040
+ }
1041
+ if (!A)
1042
+ throw new Error(I`Recursive \g cannot be used outside the referenced group "${n === "external" ? m : I`\g<${m}&R=${$}>`}"`);
1043
+ const y = i.get(m), k = Nt(e, y);
1044
+ if (a && pe(k, I`${we}|\((?!\?)`, S.DEFAULT))
1045
+ throw new Error(
1046
+ // When used in `external` mode by transpilers other than Regex+, backrefs might have
1047
+ // gone through conversion from named to numbered, so avoid a misleading error
1048
+ `${n === "external" ? "Backrefs" : "Numbered backrefs"} cannot be used with recursion of capturing groups`
1049
+ );
1050
+ const v = e.slice(y, f.index), V = k.slice(v.length + g.length), _ = o.length, q = +$ - 1, Oe = Ke(
1051
+ v,
1052
+ V,
1053
+ q,
1054
+ !0,
1055
+ t,
1056
+ o,
1057
+ l
1058
+ );
1059
+ s = er(
1060
+ s,
1061
+ v,
1062
+ q,
1063
+ o.length - _,
1064
+ _,
1065
+ l
1066
+ );
1067
+ const Nr = e.slice(0, y), Lr = e.slice(y + k.length);
1068
+ e = `${Nr}${Oe}${Lr}`, W.lastIndex += Oe.length - g.length - v.length - V.length, u.forEach((ne) => ne.hasRecursedWithin = !0), c = !0;
1069
+ } else if (d)
1070
+ l++, i.set(String(l), W.lastIndex), i.set(d, W.lastIndex), u.push({
1071
+ num: l,
1072
+ name: d
1073
+ });
1074
+ else if (g[0] === "(") {
1075
+ const A = g === "(";
1076
+ A && (l++, i.set(String(l), W.lastIndex)), u.push(A ? { num: l } : {});
1077
+ } else g === ")" && u.pop();
1078
+ }
1079
+ return t.push(...o), {
1080
+ pattern: e,
1081
+ captureTransfers: s,
1082
+ hiddenCaptures: t
1083
+ };
1084
+ }
1085
+ function Je(e) {
1086
+ const r = `Max depth must be integer between 2 and 100; used ${e}`;
1087
+ if (!/^[1-9]\d*$/.test(e))
1088
+ throw new Error(r);
1089
+ if (e = +e, e < 2 || e > 100)
1090
+ throw new Error(r);
1091
+ }
1092
+ function Ke(e, r, t, n, s, o, a) {
1093
+ const i = /* @__PURE__ */ new Set();
1094
+ n && yr(e + r, we, ({ groups: { captureName: c } }) => {
1095
+ i.add(c);
1096
+ }, S.DEFAULT);
1097
+ const u = [
1098
+ t,
1099
+ n ? i : null,
1100
+ s,
1101
+ o,
1102
+ a
1103
+ ];
1104
+ return `${e}${Ye(`(?:${e}`, "forward", ...u)}(?:)${Ye(`${r})`, "backward", ...u)}${r}`;
1105
+ }
1106
+ function Ye(e, r, t, n, s, o, a) {
1107
+ const u = (p) => r === "forward" ? p + 2 : t - p + 2 - 1;
1108
+ let c = "";
1109
+ for (let p = 0; p < t; p++) {
1110
+ const l = u(p);
1111
+ c += Pe(
1112
+ e,
1113
+ I`${br}|\\k<(?<backref>[^>]+)>`,
1114
+ ({ 0: f, groups: { captureName: g, unnamed: d, backref: w } }) => {
1115
+ if (w && n && !n.has(w))
1116
+ return f;
1117
+ const m = `_$${l}`;
1118
+ if (d || g) {
1119
+ const $ = a + o.length + 1;
1120
+ return o.push($), Rt(s, $), d ? f : `(?<${g}${m}>`;
1121
+ }
1122
+ return I`\k<${w}${m}>`;
1123
+ },
1124
+ S.DEFAULT
1125
+ );
1126
+ }
1127
+ return c;
1128
+ }
1129
+ function Rt(e, r) {
1130
+ for (let t = 0; t < e.length; t++)
1131
+ e[t] >= r && e[t]++;
1132
+ }
1133
+ function er(e, r, t, n, s, o) {
1134
+ if (e.size && n) {
1135
+ let a = 0;
1136
+ yr(r, br, () => a++, S.DEFAULT);
1137
+ const i = o - a + s, u = /* @__PURE__ */ new Map();
1138
+ return e.forEach((c, p) => {
1139
+ const l = (n - a * t) / t, f = a * t, g = p > i + a ? p + n : p, d = [];
1140
+ for (const w of c)
1141
+ if (w <= i)
1142
+ d.push(w);
1143
+ else if (w > i + a + l)
1144
+ d.push(w + n);
1145
+ else if (w <= i + a)
1146
+ for (let m = 0; m <= t; m++)
1147
+ d.push(w + a * m);
1148
+ else
1149
+ for (let m = 0; m <= t; m++)
1150
+ d.push(w + f + l * m);
1151
+ u.set(g, d);
1152
+ }), u;
1153
+ }
1154
+ return e;
1155
+ }
1156
+ var b = String.fromCodePoint, h = String.raw, L = {}, me = globalThis.RegExp;
1157
+ L.flagGroups = (() => {
1158
+ try {
1159
+ new me("(?i:)");
1160
+ } catch {
1161
+ return !1;
1162
+ }
1163
+ return !0;
1164
+ })();
1165
+ L.unicodeSets = (() => {
1166
+ try {
1167
+ new me("[[]]", "v");
1168
+ } catch {
1169
+ return !1;
1170
+ }
1171
+ return !0;
1172
+ })();
1173
+ L.bugFlagVLiteralHyphenIsRange = L.unicodeSets ? (() => {
1174
+ try {
1175
+ new me(h`[\d\-a]`, "v");
1176
+ } catch {
1177
+ return !0;
1178
+ }
1179
+ return !1;
1180
+ })() : !1;
1181
+ L.bugNestedClassIgnoresNegation = L.unicodeSets && new me("[[^a]]", "v").test("a");
1182
+ function de(e, { enable: r, disable: t }) {
1183
+ return {
1184
+ dotAll: !(t != null && t.dotAll) && !!(r != null && r.dotAll || e.dotAll),
1185
+ ignoreCase: !(t != null && t.ignoreCase) && !!(r != null && r.ignoreCase || e.ignoreCase)
1186
+ };
1187
+ }
1188
+ function ae(e, r, t) {
1189
+ return e.has(r) || e.set(r, t), e.get(r);
1190
+ }
1191
+ function Ne(e, r) {
1192
+ return rr[e] >= rr[r];
1193
+ }
1194
+ function Ut(e, r) {
1195
+ if (e == null)
1196
+ throw new Error(r ?? "Value expected");
1197
+ return e;
1198
+ }
1199
+ var rr = {
1200
+ ES2025: 2025,
1201
+ ES2024: 2024,
1202
+ ES2018: 2018
1203
+ }, Ot = (
1204
+ /** @type {const} */
1205
+ {
1206
+ auto: "auto",
1207
+ ES2025: "ES2025",
1208
+ ES2024: "ES2024",
1209
+ ES2018: "ES2018"
1210
+ }
1211
+ );
1212
+ function xr(e = {}) {
1213
+ if ({}.toString.call(e) !== "[object Object]")
1214
+ throw new Error("Unexpected options");
1215
+ if (e.target !== void 0 && !Ot[e.target])
1216
+ throw new Error(`Unexpected target "${e.target}"`);
1217
+ const r = {
1218
+ // Sets the level of emulation rigor/strictness.
1219
+ accuracy: "default",
1220
+ // Disables advanced emulation that relies on returning a `RegExp` subclass, resulting in
1221
+ // certain patterns not being emulatable.
1222
+ avoidSubclass: !1,
1223
+ // Oniguruma flags; a string with `i`, `m`, `x`, `D`, `S`, `W`, `y{g}` in any order (all
1224
+ // optional). Oniguruma's `m` is equivalent to JavaScript's `s` (`dotAll`).
1225
+ flags: "",
1226
+ // Include JavaScript flag `g` (`global`) in the result.
1227
+ global: !1,
1228
+ // Include JavaScript flag `d` (`hasIndices`) in the result.
1229
+ hasIndices: !1,
1230
+ // Delay regex construction until first use if the transpiled pattern is at least this length.
1231
+ lazyCompileLength: 1 / 0,
1232
+ // JavaScript version used for generated regexes. Using `auto` detects the best value based on
1233
+ // your environment. Later targets allow faster processing, simpler generated source, and
1234
+ // support for additional features.
1235
+ target: "auto",
1236
+ // Disables minifications that simplify the pattern without changing the meaning.
1237
+ verbose: !1,
1238
+ ...e,
1239
+ // Advanced options that override standard behavior, error checking, and flags when enabled.
1240
+ rules: {
1241
+ // Useful with TextMate grammars that merge backreferences across patterns.
1242
+ allowOrphanBackrefs: !1,
1243
+ // Use ASCII `\b` and `\B`, which increases search performance of generated regexes.
1244
+ asciiWordBoundaries: !1,
1245
+ // Allow unnamed captures and numbered calls (backreferences and subroutines) when using
1246
+ // named capture. This is Oniguruma option `ONIG_OPTION_CAPTURE_GROUP`; on by default in
1247
+ // `vscode-oniguruma`.
1248
+ captureGroup: !1,
1249
+ // Change the recursion depth limit from Oniguruma's `20` to an integer `2`–`20`.
1250
+ recursionLimit: 20,
1251
+ // `^` as `\A`; `$` as`\Z`. Improves search performance of generated regexes without changing
1252
+ // the meaning if searching line by line. This is Oniguruma option `ONIG_OPTION_SINGLELINE`.
1253
+ singleline: !1,
1254
+ ...e.rules
1255
+ }
1256
+ };
1257
+ return r.target === "auto" && (r.target = L.flagGroups ? "ES2025" : L.unicodeSets ? "ES2024" : "ES2018"), r;
1258
+ }
1259
+ var Dt = "[ -\r ]", Tt = /* @__PURE__ */ new Set([
1260
+ b(304),
1261
+ // İ
1262
+ b(305)
1263
+ // ı
1264
+ ]), F = h`[\p{L}\p{M}\p{N}\p{Pc}]`;
1265
+ function kr(e) {
1266
+ if (Tt.has(e))
1267
+ return [e];
1268
+ const r = /* @__PURE__ */ new Set(), t = e.toLowerCase(), n = t.toUpperCase(), s = zt.get(t), o = Bt.get(t), a = Vt.get(t);
1269
+ return [...n].length === 1 && r.add(n), a && r.add(a), s && r.add(s), r.add(t), o && r.add(o), [...r];
1270
+ }
1271
+ var Re = /* @__PURE__ */ new Map(
1272
+ `C Other
1273
+ Cc Control cntrl
1274
+ Cf Format
1275
+ Cn Unassigned
1276
+ Co Private_Use
1277
+ Cs Surrogate
1278
+ L Letter
1279
+ LC Cased_Letter
1280
+ Ll Lowercase_Letter
1281
+ Lm Modifier_Letter
1282
+ Lo Other_Letter
1283
+ Lt Titlecase_Letter
1284
+ Lu Uppercase_Letter
1285
+ M Mark Combining_Mark
1286
+ Mc Spacing_Mark
1287
+ Me Enclosing_Mark
1288
+ Mn Nonspacing_Mark
1289
+ N Number
1290
+ Nd Decimal_Number digit
1291
+ Nl Letter_Number
1292
+ No Other_Number
1293
+ P Punctuation punct
1294
+ Pc Connector_Punctuation
1295
+ Pd Dash_Punctuation
1296
+ Pe Close_Punctuation
1297
+ Pf Final_Punctuation
1298
+ Pi Initial_Punctuation
1299
+ Po Other_Punctuation
1300
+ Ps Open_Punctuation
1301
+ S Symbol
1302
+ Sc Currency_Symbol
1303
+ Sk Modifier_Symbol
1304
+ Sm Math_Symbol
1305
+ So Other_Symbol
1306
+ Z Separator
1307
+ Zl Line_Separator
1308
+ Zp Paragraph_Separator
1309
+ Zs Space_Separator
1310
+ ASCII
1311
+ ASCII_Hex_Digit AHex
1312
+ Alphabetic Alpha
1313
+ Any
1314
+ Assigned
1315
+ Bidi_Control Bidi_C
1316
+ Bidi_Mirrored Bidi_M
1317
+ Case_Ignorable CI
1318
+ Cased
1319
+ Changes_When_Casefolded CWCF
1320
+ Changes_When_Casemapped CWCM
1321
+ Changes_When_Lowercased CWL
1322
+ Changes_When_NFKC_Casefolded CWKCF
1323
+ Changes_When_Titlecased CWT
1324
+ Changes_When_Uppercased CWU
1325
+ Dash
1326
+ Default_Ignorable_Code_Point DI
1327
+ Deprecated Dep
1328
+ Diacritic Dia
1329
+ Emoji
1330
+ Emoji_Component EComp
1331
+ Emoji_Modifier EMod
1332
+ Emoji_Modifier_Base EBase
1333
+ Emoji_Presentation EPres
1334
+ Extended_Pictographic ExtPict
1335
+ Extender Ext
1336
+ Grapheme_Base Gr_Base
1337
+ Grapheme_Extend Gr_Ext
1338
+ Hex_Digit Hex
1339
+ IDS_Binary_Operator IDSB
1340
+ IDS_Trinary_Operator IDST
1341
+ ID_Continue IDC
1342
+ ID_Start IDS
1343
+ Ideographic Ideo
1344
+ Join_Control Join_C
1345
+ Logical_Order_Exception LOE
1346
+ Lowercase Lower
1347
+ Math
1348
+ Noncharacter_Code_Point NChar
1349
+ Pattern_Syntax Pat_Syn
1350
+ Pattern_White_Space Pat_WS
1351
+ Quotation_Mark QMark
1352
+ Radical
1353
+ Regional_Indicator RI
1354
+ Sentence_Terminal STerm
1355
+ Soft_Dotted SD
1356
+ Terminal_Punctuation Term
1357
+ Unified_Ideograph UIdeo
1358
+ Uppercase Upper
1359
+ Variation_Selector VS
1360
+ White_Space space
1361
+ XID_Continue XIDC
1362
+ XID_Start XIDS`.split(/\s/).map((e) => [he(e), e])
1363
+ ), Bt = /* @__PURE__ */ new Map([
1364
+ ["s", b(383)],
1365
+ // s, ſ
1366
+ [b(383), "s"]
1367
+ // ſ, s
1368
+ ]), Vt = /* @__PURE__ */ new Map([
1369
+ [b(223), b(7838)],
1370
+ // ß, ẞ
1371
+ [b(107), b(8490)],
1372
+ // k, K (Kelvin)
1373
+ [b(229), b(8491)],
1374
+ // å, Å (Angstrom)
1375
+ [b(969), b(8486)]
1376
+ // ω, Ω (Ohm)
1377
+ ]), zt = new Map([
1378
+ U(453),
1379
+ U(456),
1380
+ U(459),
1381
+ U(498),
1382
+ ...Ee(8072, 8079),
1383
+ ...Ee(8088, 8095),
1384
+ ...Ee(8104, 8111),
1385
+ U(8124),
1386
+ U(8140),
1387
+ U(8188)
1388
+ ]), Wt = /* @__PURE__ */ new Map([
1389
+ ["alnum", h`[\p{Alpha}\p{Nd}]`],
1390
+ ["alpha", h`\p{Alpha}`],
1391
+ ["ascii", h`\p{ASCII}`],
1392
+ ["blank", h`[\p{Zs}\t]`],
1393
+ ["cntrl", h`\p{Cc}`],
1394
+ ["digit", h`\p{Nd}`],
1395
+ ["graph", h`[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]`],
1396
+ ["lower", h`\p{Lower}`],
1397
+ ["print", h`[[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]\p{Zs}]`],
1398
+ ["punct", h`[\p{P}\p{S}]`],
1399
+ // Updated value from Onig 6.9.9; changed from Unicode `\p{punct}`
1400
+ ["space", h`\p{space}`],
1401
+ ["upper", h`\p{Upper}`],
1402
+ ["word", h`[\p{Alpha}\p{M}\p{Nd}\p{Pc}]`],
1403
+ ["xdigit", h`\p{AHex}`]
1404
+ ]);
1405
+ function Ht(e, r) {
1406
+ const t = [];
1407
+ for (let n = e; n <= r; n++)
1408
+ t.push(n);
1409
+ return t;
1410
+ }
1411
+ function U(e) {
1412
+ const r = b(e);
1413
+ return [r.toLowerCase(), r];
1414
+ }
1415
+ function Ee(e, r) {
1416
+ return Ht(e, r).map((t) => U(t));
1417
+ }
1418
+ var Er = /* @__PURE__ */ new Set([
1419
+ "Lower",
1420
+ "Lowercase",
1421
+ "Upper",
1422
+ "Uppercase",
1423
+ "Ll",
1424
+ "Lowercase_Letter",
1425
+ "Lt",
1426
+ "Titlecase_Letter",
1427
+ "Lu",
1428
+ "Uppercase_Letter"
1429
+ // The `Changes_When_*` properties (and their aliases) could be included, but they're very rare.
1430
+ // Some other properties include a handful of chars with specific cases only, but these chars are
1431
+ // generally extreme edge cases and using such properties case insensitively generally produces
1432
+ // undesired behavior anyway
1433
+ ]);
1434
+ function jt(e, r) {
1435
+ const t = {
1436
+ // A couple edge cases exist where options `accuracy` and `bestEffortTarget` are used:
1437
+ // - `CharacterSet` kind `text_segment` (`\X`): An exact representation would require heavy
1438
+ // Unicode data; a best-effort approximation requires knowing the target.
1439
+ // - `CharacterSet` kind `posix` with values `graph` and `print`: Their complex Unicode
1440
+ // representations would be hard to change to ASCII versions after the fact in the generator
1441
+ // based on `target`/`accuracy`, so produce the appropriate structure here.
1442
+ accuracy: "default",
1443
+ asciiWordBoundaries: !1,
1444
+ avoidSubclass: !1,
1445
+ bestEffortTarget: "ES2025",
1446
+ ...r
1447
+ };
1448
+ $r(e);
1449
+ const n = {
1450
+ accuracy: t.accuracy,
1451
+ asciiWordBoundaries: t.asciiWordBoundaries,
1452
+ avoidSubclass: t.avoidSubclass,
1453
+ flagDirectivesByAlt: /* @__PURE__ */ new Map(),
1454
+ jsGroupNameMap: /* @__PURE__ */ new Map(),
1455
+ minTargetEs2024: Ne(t.bestEffortTarget, "ES2024"),
1456
+ passedLookbehind: !1,
1457
+ strategy: null,
1458
+ // Subroutines can appear before the groups they ref, so collect reffed nodes for a second pass
1459
+ subroutineRefMap: /* @__PURE__ */ new Map(),
1460
+ supportedGNodes: /* @__PURE__ */ new Set(),
1461
+ digitIsAscii: e.flags.digitIsAscii,
1462
+ spaceIsAscii: e.flags.spaceIsAscii,
1463
+ wordIsAscii: e.flags.wordIsAscii
1464
+ };
1465
+ oe(e, Xt, n);
1466
+ const s = {
1467
+ dotAll: e.flags.dotAll,
1468
+ ignoreCase: e.flags.ignoreCase
1469
+ }, o = {
1470
+ currentFlags: s,
1471
+ prevFlags: null,
1472
+ globalFlags: s,
1473
+ groupOriginByCopy: /* @__PURE__ */ new Map(),
1474
+ groupsByName: /* @__PURE__ */ new Map(),
1475
+ multiplexCapturesToLeftByRef: /* @__PURE__ */ new Map(),
1476
+ openRefs: /* @__PURE__ */ new Map(),
1477
+ reffedNodesByReferencer: /* @__PURE__ */ new Map(),
1478
+ subroutineRefMap: n.subroutineRefMap
1479
+ };
1480
+ oe(e, Zt, o);
1481
+ const a = {
1482
+ groupsByName: o.groupsByName,
1483
+ highestOrphanBackref: 0,
1484
+ numCapturesToLeft: 0,
1485
+ reffedNodesByReferencer: o.reffedNodesByReferencer
1486
+ };
1487
+ return oe(e, Qt, a), e._originMap = o.groupOriginByCopy, e._strategy = n.strategy, e;
1488
+ }
1489
+ var Xt = {
1490
+ AbsenceFunction({ node: e, parent: r, replaceWith: t }) {
1491
+ const { body: n, kind: s } = e;
1492
+ if (s === "repeater") {
1493
+ const o = N();
1494
+ o.body[0].body.push(
1495
+ // Insert own alts as `body`
1496
+ H({ negate: !0, body: n }),
1497
+ ee("Any")
1498
+ );
1499
+ const a = N();
1500
+ a.body[0].body.push(
1501
+ hr("greedy", 0, 1 / 0, o)
1502
+ ), t(C(a, r), { traverse: !0 });
1503
+ } else
1504
+ throw new Error('Unsupported absence function "(?~|"');
1505
+ },
1506
+ Alternative: {
1507
+ enter({ node: e, parent: r, key: t }, { flagDirectivesByAlt: n }) {
1508
+ const s = e.body.filter((o) => o.kind === "flags");
1509
+ for (let o = t + 1; o < r.body.length; o++) {
1510
+ const a = r.body[o];
1511
+ ae(n, a, []).push(...s);
1512
+ }
1513
+ },
1514
+ exit({ node: e }, { flagDirectivesByAlt: r }) {
1515
+ var t;
1516
+ if ((t = r.get(e)) != null && t.length) {
1517
+ const n = Ir(r.get(e));
1518
+ if (n) {
1519
+ const s = N({ flags: n });
1520
+ s.body[0].body = e.body, e.body = [C(s, e)];
1521
+ }
1522
+ }
1523
+ }
1524
+ },
1525
+ Assertion({ node: e, parent: r, key: t, container: n, root: s, remove: o, replaceWith: a }, i) {
1526
+ const { kind: u, negate: c } = e, { asciiWordBoundaries: p, avoidSubclass: l, supportedGNodes: f, wordIsAscii: g } = i;
1527
+ if (u === "text_segment_boundary")
1528
+ throw new Error(`Unsupported text segment boundary "\\${c ? "Y" : "y"}"`);
1529
+ if (u === "line_end")
1530
+ a(C(H({ body: [
1531
+ Q({ body: [Se("string_end")] }),
1532
+ Q({ body: [ge(10)] })
1533
+ // `\n`
1534
+ ] }), r));
1535
+ else if (u === "line_start")
1536
+ a(C(G(h`(?<=\A|\n(?!\z))`, { skipLookbehindValidation: !0 }), r));
1537
+ else if (u === "search_start")
1538
+ if (f.has(e))
1539
+ s.flags.sticky = !0, o();
1540
+ else {
1541
+ const d = n[t - 1];
1542
+ if (d && rn(d))
1543
+ a(C(H({ negate: !0 }), r));
1544
+ else {
1545
+ if (l)
1546
+ throw new Error(h`Uses "\G" in a way that requires a subclass`);
1547
+ a(O(Se("string_start"), r)), i.strategy = "clip_search";
1548
+ }
1549
+ }
1550
+ else if (!(u === "string_end" || u === "string_start")) if (u === "string_end_newline")
1551
+ a(C(G(h`(?=\n?\z)`), r));
1552
+ else if (u === "word_boundary") {
1553
+ if (!g && !p) {
1554
+ const d = `(?:(?<=${F})(?!${F})|(?<!${F})(?=${F}))`, w = `(?:(?<=${F})(?=${F})|(?<!${F})(?!${F}))`;
1555
+ a(C(G(c ? w : d), r));
1556
+ }
1557
+ } else
1558
+ throw new Error(`Unexpected assertion kind "${u}"`);
1559
+ },
1560
+ Backreference({ node: e }, { jsGroupNameMap: r }) {
1561
+ let { ref: t } = e;
1562
+ typeof t == "string" && !Ae(t) && (t = $e(t, r), e.ref = t);
1563
+ },
1564
+ CapturingGroup({ node: e }, { jsGroupNameMap: r, subroutineRefMap: t }) {
1565
+ let { name: n } = e;
1566
+ n && !Ae(n) && (n = $e(n, r), e.name = n), t.set(e.number, e), n && t.set(n, e);
1567
+ },
1568
+ CharacterClassRange({ node: e, parent: r, replaceWith: t }) {
1569
+ if (r.kind === "intersection") {
1570
+ const n = fe({ body: [e] });
1571
+ t(C(n, r), { traverse: !0 });
1572
+ }
1573
+ },
1574
+ CharacterSet({ node: e, parent: r, replaceWith: t }, { accuracy: n, minTargetEs2024: s, digitIsAscii: o, spaceIsAscii: a, wordIsAscii: i }) {
1575
+ const { kind: u, negate: c, value: p } = e;
1576
+ if (o && (u === "digit" || p === "digit")) {
1577
+ t(O(_e("digit", { negate: c }), r));
1578
+ return;
1579
+ }
1580
+ if (a && (u === "space" || p === "space")) {
1581
+ t(C(Ie(G(Dt), c), r));
1582
+ return;
1583
+ }
1584
+ if (i && (u === "word" || p === "word")) {
1585
+ t(O(_e("word", { negate: c }), r));
1586
+ return;
1587
+ }
1588
+ if (u === "any")
1589
+ t(O(ee("Any"), r));
1590
+ else if (u === "digit")
1591
+ t(O(ee("Nd", { negate: c }), r));
1592
+ else if (u !== "dot") if (u === "text_segment") {
1593
+ if (n === "strict")
1594
+ throw new Error(h`Use of "\X" requires non-strict accuracy`);
1595
+ const l = "\\p{Emoji}(?:\\p{EMod}|\\uFE0F\\u20E3?|[\\x{E0020}-\\x{E007E}]+\\x{E007F})?", f = h`\p{RI}{2}|${l}(?:\u200D${l})*`;
1596
+ t(C(G(
1597
+ // Close approximation of an extended grapheme cluster; see <unicode.org/reports/tr29/>
1598
+ h`(?>\r\n|${s ? h`\p{RGI_Emoji}` : f}|\P{M}\p{M}*)`,
1599
+ // Allow JS property `RGI_Emoji` through
1600
+ { skipPropertyNameValidation: !0 }
1601
+ ), r));
1602
+ } else if (u === "hex")
1603
+ t(O(ee("AHex", { negate: c }), r));
1604
+ else if (u === "newline")
1605
+ t(C(G(c ? `[^
1606
+ ]` : `(?>\r
1607
+ ?|[
1608
+ \v\f…\u2028\u2029])`), r));
1609
+ else if (u === "posix")
1610
+ if (!s && (p === "graph" || p === "print")) {
1611
+ if (n === "strict")
1612
+ throw new Error(`POSIX class "${p}" requires min target ES2024 or non-strict accuracy`);
1613
+ let l = {
1614
+ graph: "!-~",
1615
+ print: " -~"
1616
+ }[p];
1617
+ c && (l = `\0-${b(l.codePointAt(0) - 1)}${b(l.codePointAt(2) + 1)}-􏿿`), t(C(G(`[${l}]`), r));
1618
+ } else
1619
+ t(C(Ie(G(Wt.get(p)), c), r));
1620
+ else if (u === "property")
1621
+ Re.has(he(p)) || (e.key = "sc");
1622
+ else if (u === "space")
1623
+ t(O(ee("space", { negate: c }), r));
1624
+ else if (u === "word")
1625
+ t(C(Ie(G(F), c), r));
1626
+ else
1627
+ throw new Error(`Unexpected character set kind "${u}"`);
1628
+ },
1629
+ Directive({ node: e, parent: r, root: t, remove: n, replaceWith: s, removeAllPrevSiblings: o, removeAllNextSiblings: a }) {
1630
+ const { kind: i, flags: u } = e;
1631
+ if (i === "flags")
1632
+ if (!u.enable && !u.disable)
1633
+ n();
1634
+ else {
1635
+ const c = N({ flags: u });
1636
+ c.body[0].body = a(), s(C(c, r), { traverse: !0 });
1637
+ }
1638
+ else if (i === "keep") {
1639
+ const c = t.body[0], l = t.body.length === 1 && // Not emulatable if within a `CapturingGroup`
1640
+ fr(c, { type: "Group" }) && c.body[0].body.length === 1 ? c.body[0] : t;
1641
+ if (r.parent !== l || l.body.length > 1)
1642
+ throw new Error(h`Uses "\K" in a way that's unsupported`);
1643
+ const f = H({ behind: !0 });
1644
+ f.body[0].body = o(), s(C(f, r));
1645
+ } else
1646
+ throw new Error(`Unexpected directive kind "${i}"`);
1647
+ },
1648
+ Flags({ node: e, parent: r }) {
1649
+ if (e.posixIsAscii)
1650
+ throw new Error('Unsupported flag "P"');
1651
+ if (e.textSegmentMode === "word")
1652
+ throw new Error('Unsupported flag "y{w}"');
1653
+ [
1654
+ "digitIsAscii",
1655
+ // Flag D
1656
+ "extended",
1657
+ // Flag x
1658
+ "posixIsAscii",
1659
+ // Flag P
1660
+ "spaceIsAscii",
1661
+ // Flag S
1662
+ "wordIsAscii",
1663
+ // Flag W
1664
+ "textSegmentMode"
1665
+ // Flag y{g} or y{w}
1666
+ ].forEach((t) => delete e[t]), Object.assign(e, {
1667
+ // JS flag g; no Onig equiv
1668
+ global: !1,
1669
+ // JS flag d; no Onig equiv
1670
+ hasIndices: !1,
1671
+ // JS flag m; no Onig equiv but its behavior is always on in Onig. Onig's only line break
1672
+ // char is line feed, unlike JS, so this flag isn't used since it would produce inaccurate
1673
+ // results (also allows `^` and `$` to be used in the generator for string start and end)
1674
+ multiline: !1,
1675
+ // JS flag y; no Onig equiv, but used for `\G` emulation
1676
+ sticky: e.sticky ?? !1
1677
+ // Note: Regex+ doesn't allow explicitly adding flags it handles implicitly, so leave out
1678
+ // properties `unicode` (JS flag u) and `unicodeSets` (JS flag v). Keep the existing values
1679
+ // for `ignoreCase` (flag i) and `dotAll` (JS flag s, but Onig flag m)
1680
+ }), r.options = {
1681
+ disable: {
1682
+ // Onig uses different rules for flag x than Regex+, so disable the implicit flag
1683
+ x: !0,
1684
+ // Onig has no flag to control "named capture only" mode but contextually applies its
1685
+ // behavior when named capturing is used, so disable Regex+'s implicit flag for it
1686
+ n: !0
1687
+ },
1688
+ force: {
1689
+ // Always add flag v because we're generating an AST that relies on it (it enables JS
1690
+ // support for Onig features nested classes, intersection, Unicode properties, etc.).
1691
+ // However, the generator might disable flag v based on its `target` option
1692
+ v: !0
1693
+ }
1694
+ };
1695
+ },
1696
+ Group({ node: e }) {
1697
+ if (!e.flags)
1698
+ return;
1699
+ const { enable: r, disable: t } = e.flags;
1700
+ 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;
1701
+ },
1702
+ LookaroundAssertion({ node: e }, r) {
1703
+ const { kind: t } = e;
1704
+ t === "lookbehind" && (r.passedLookbehind = !0);
1705
+ },
1706
+ NamedCallout({ node: e, parent: r, replaceWith: t }) {
1707
+ const { kind: n } = e;
1708
+ if (n === "fail")
1709
+ t(C(H({ negate: !0 }), r));
1710
+ else
1711
+ throw new Error(`Unsupported named callout "(*${n.toUpperCase()}"`);
1712
+ },
1713
+ Quantifier({ node: e }) {
1714
+ if (e.body.type === "Quantifier") {
1715
+ const r = N();
1716
+ r.body[0].body.push(e.body), e.body = C(r, e);
1717
+ }
1718
+ },
1719
+ Regex: {
1720
+ enter({ node: e }, { supportedGNodes: r }) {
1721
+ const t = [];
1722
+ let n = !1, s = !1;
1723
+ for (const o of e.body)
1724
+ if (o.body.length === 1 && o.body[0].kind === "search_start")
1725
+ o.body.pop();
1726
+ else {
1727
+ const a = vr(o.body);
1728
+ a ? (n = !0, Array.isArray(a) ? t.push(...a) : t.push(a)) : s = !0;
1729
+ }
1730
+ n && !s && t.forEach((o) => r.add(o));
1731
+ },
1732
+ exit(e, { accuracy: r, passedLookbehind: t, strategy: n }) {
1733
+ if (r === "strict" && t && n)
1734
+ throw new Error(h`Uses "\G" in a way that requires non-strict accuracy`);
1735
+ }
1736
+ },
1737
+ Subroutine({ node: e }, { jsGroupNameMap: r }) {
1738
+ let { ref: t } = e;
1739
+ typeof t == "string" && !Ae(t) && (t = $e(t, r), e.ref = t);
1740
+ }
1741
+ }, Zt = {
1742
+ Backreference({ node: e }, { multiplexCapturesToLeftByRef: r, reffedNodesByReferencer: t }) {
1743
+ const { orphan: n, ref: s } = e;
1744
+ n || t.set(e, [...r.get(s).map(({ node: o }) => o)]);
1745
+ },
1746
+ CapturingGroup: {
1747
+ enter({
1748
+ node: e,
1749
+ parent: r,
1750
+ replaceWith: t,
1751
+ skip: n
1752
+ }, {
1753
+ groupOriginByCopy: s,
1754
+ groupsByName: o,
1755
+ multiplexCapturesToLeftByRef: a,
1756
+ openRefs: i,
1757
+ reffedNodesByReferencer: u
1758
+ }) {
1759
+ const c = s.get(e);
1760
+ if (c && i.has(e.number)) {
1761
+ const l = O(tr(e.number), r);
1762
+ u.set(l, i.get(e.number)), t(l);
1763
+ return;
1764
+ }
1765
+ i.set(e.number, e), a.set(e.number, []), e.name && ae(a, e.name, []);
1766
+ const p = a.get(e.name ?? e.number);
1767
+ for (let l = 0; l < p.length; l++) {
1768
+ const f = p[l];
1769
+ if (
1770
+ // This group is from subroutine expansion, and there's a multiplex value from either the
1771
+ // origin node or a prior subroutine expansion group with the same origin
1772
+ c === f.node || c && c === f.origin || // This group is not from subroutine expansion, and it comes after a subroutine expansion
1773
+ // group that refers to this group
1774
+ e === f.origin
1775
+ ) {
1776
+ p.splice(l, 1);
1777
+ break;
1778
+ }
1779
+ }
1780
+ if (a.get(e.number).push({ node: e, origin: c }), e.name && a.get(e.name).push({ node: e, origin: c }), e.name) {
1781
+ const l = ae(o, e.name, /* @__PURE__ */ new Map());
1782
+ let f = !1;
1783
+ if (c)
1784
+ f = !0;
1785
+ else
1786
+ for (const g of l.values())
1787
+ if (!g.hasDuplicateNameToRemove) {
1788
+ f = !0;
1789
+ break;
1790
+ }
1791
+ o.get(e.name).set(e, { node: e, hasDuplicateNameToRemove: f });
1792
+ }
1793
+ },
1794
+ exit({ node: e }, { openRefs: r }) {
1795
+ r.get(e.number) === e && r.delete(e.number);
1796
+ }
1797
+ },
1798
+ Group: {
1799
+ enter({ node: e }, r) {
1800
+ r.prevFlags = r.currentFlags, e.flags && (r.currentFlags = de(r.currentFlags, e.flags));
1801
+ },
1802
+ exit(e, r) {
1803
+ r.currentFlags = r.prevFlags;
1804
+ }
1805
+ },
1806
+ Subroutine({ node: e, parent: r, replaceWith: t }, n) {
1807
+ const { isRecursive: s, ref: o } = e;
1808
+ if (s) {
1809
+ let p = r;
1810
+ for (; (p = p.parent) && !(p.type === "CapturingGroup" && (p.name === o || p.number === o)); )
1811
+ ;
1812
+ n.reffedNodesByReferencer.set(e, p);
1813
+ return;
1814
+ }
1815
+ const a = n.subroutineRefMap.get(o), i = o === 0, u = i ? tr(0) : (
1816
+ // The reffed group might itself contain subroutines, which are expanded during sub-traversal
1817
+ Ar(a, n.groupOriginByCopy, null)
1818
+ );
1819
+ let c = u;
1820
+ if (!i) {
1821
+ const p = Ir(Kt(
1822
+ a,
1823
+ (f) => f.type === "Group" && !!f.flags
1824
+ )), l = p ? de(n.globalFlags, p) : n.globalFlags;
1825
+ qt(l, n.currentFlags) || (c = N({
1826
+ flags: Yt(l)
1827
+ }), c.body[0].body.push(u));
1828
+ }
1829
+ t(C(c, r), { traverse: !i });
1830
+ }
1831
+ }, Qt = {
1832
+ Backreference({ node: e, parent: r, replaceWith: t }, n) {
1833
+ if (e.orphan) {
1834
+ n.highestOrphanBackref = Math.max(n.highestOrphanBackref, e.ref);
1835
+ return;
1836
+ }
1837
+ const o = n.reffedNodesByReferencer.get(e).filter((a) => Jt(a, e));
1838
+ if (!o.length)
1839
+ t(C(H({ negate: !0 }), r));
1840
+ else if (o.length > 1) {
1841
+ const a = N({
1842
+ atomic: !0,
1843
+ body: o.reverse().map((i) => Q({
1844
+ body: [ve(i.number)]
1845
+ }))
1846
+ });
1847
+ t(C(a, r));
1848
+ } else
1849
+ e.ref = o[0].number;
1850
+ },
1851
+ CapturingGroup({ node: e }, r) {
1852
+ e.number = ++r.numCapturesToLeft, e.name && r.groupsByName.get(e.name).get(e).hasDuplicateNameToRemove && delete e.name;
1853
+ },
1854
+ Regex: {
1855
+ exit({ node: e }, r) {
1856
+ const t = Math.max(r.highestOrphanBackref - r.numCapturesToLeft, 0);
1857
+ for (let n = 0; n < t; n++) {
1858
+ const s = gr();
1859
+ e.body.at(-1).body.push(s);
1860
+ }
1861
+ }
1862
+ },
1863
+ Subroutine({ node: e }, r) {
1864
+ !e.isRecursive || e.ref === 0 || (e.ref = r.reffedNodesByReferencer.get(e).number);
1865
+ }
1866
+ };
1867
+ function $r(e) {
1868
+ oe(e, {
1869
+ "*"({ node: r, parent: t }) {
1870
+ r.parent = t;
1871
+ }
1872
+ });
1873
+ }
1874
+ function qt(e, r) {
1875
+ return e.dotAll === r.dotAll && e.ignoreCase === r.ignoreCase;
1876
+ }
1877
+ function Jt(e, r) {
1878
+ let t = r;
1879
+ do {
1880
+ if (t.type === "Regex")
1881
+ return !1;
1882
+ if (t.type === "Alternative")
1883
+ continue;
1884
+ if (t === e)
1885
+ return !1;
1886
+ const n = Sr(t.parent);
1887
+ for (const s of n) {
1888
+ if (s === t)
1889
+ break;
1890
+ if (s === e || _r(s, e))
1891
+ return !0;
1892
+ }
1893
+ } while (t = t.parent);
1894
+ throw new Error("Unexpected path");
1895
+ }
1896
+ function Ar(e, r, t, n) {
1897
+ const s = Array.isArray(e) ? [] : {};
1898
+ for (const [o, a] of Object.entries(e))
1899
+ o === "parent" ? s.parent = Array.isArray(t) ? n : t : a && typeof a == "object" ? s[o] = Ar(a, r, s, t) : (o === "type" && a === "CapturingGroup" && r.set(s, r.get(e) ?? e), s[o] = a);
1900
+ return s;
1901
+ }
1902
+ function tr(e) {
1903
+ const r = wr(e);
1904
+ return r.isRecursive = !0, r;
1905
+ }
1906
+ function Kt(e, r) {
1907
+ const t = [];
1908
+ for (; e = e.parent; )
1909
+ (!r || r(e)) && t.push(e);
1910
+ return t;
1911
+ }
1912
+ function $e(e, r) {
1913
+ if (r.has(e))
1914
+ return r.get(e);
1915
+ const t = `$${r.size}_${e.replace(/^[^$_\p{IDS}]|[^$\u200C\u200D\p{IDC}]/ug, "_")}`;
1916
+ return r.set(e, t), t;
1917
+ }
1918
+ function Ir(e) {
1919
+ const r = ["dotAll", "ignoreCase"], t = { enable: {}, disable: {} };
1920
+ return e.forEach(({ flags: n }) => {
1921
+ r.forEach((s) => {
1922
+ var o, a;
1923
+ (o = n.enable) != null && o[s] && (delete t.disable[s], t.enable[s] = !0), (a = n.disable) != null && a[s] && (t.disable[s] = !0);
1924
+ });
1925
+ }), Object.keys(t.enable).length || delete t.enable, Object.keys(t.disable).length || delete t.disable, t.enable || t.disable ? t : null;
1926
+ }
1927
+ function Yt({ dotAll: e, ignoreCase: r }) {
1928
+ const t = {};
1929
+ 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;
1930
+ }
1931
+ function Sr(e) {
1932
+ if (!e)
1933
+ throw new Error("Node expected");
1934
+ const { body: r } = e;
1935
+ return Array.isArray(r) ? r : r ? [r] : null;
1936
+ }
1937
+ function vr(e) {
1938
+ const r = e.find((t) => t.kind === "search_start" || tn(t, { negate: !1 }) || !en(t));
1939
+ if (!r)
1940
+ return null;
1941
+ if (r.kind === "search_start")
1942
+ return r;
1943
+ if (r.type === "LookaroundAssertion")
1944
+ return r.body[0].body[0];
1945
+ if (r.type === "CapturingGroup" || r.type === "Group") {
1946
+ const t = [];
1947
+ for (const n of r.body) {
1948
+ const s = vr(n.body);
1949
+ if (!s)
1950
+ return null;
1951
+ Array.isArray(s) ? t.push(...s) : t.push(s);
1952
+ }
1953
+ return t;
1954
+ }
1955
+ return null;
1956
+ }
1957
+ function _r(e, r) {
1958
+ const t = Sr(e) ?? [];
1959
+ for (const n of t)
1960
+ if (n === r || _r(n, r))
1961
+ return !0;
1962
+ return !1;
1963
+ }
1964
+ function en({ type: e }) {
1965
+ return e === "Assertion" || e === "Directive" || e === "LookaroundAssertion";
1966
+ }
1967
+ function rn(e) {
1968
+ const r = [
1969
+ "Character",
1970
+ "CharacterClass",
1971
+ "CharacterSet"
1972
+ ];
1973
+ return r.includes(e.type) || e.type === "Quantifier" && e.min && r.includes(e.body.type);
1974
+ }
1975
+ function tn(e, r) {
1976
+ const t = {
1977
+ negate: null,
1978
+ ...r
1979
+ };
1980
+ return e.type === "LookaroundAssertion" && (t.negate === null || e.negate === t.negate) && e.body.length === 1 && fr(e.body[0], {
1981
+ type: "Assertion",
1982
+ kind: "search_start"
1983
+ });
1984
+ }
1985
+ function Ae(e) {
1986
+ return /^[$_\p{IDS}][$\u200C\u200D\p{IDC}]*$/u.test(e);
1987
+ }
1988
+ function G(e, r) {
1989
+ const n = dr(e, {
1990
+ ...r,
1991
+ // Providing a custom set of Unicode property names avoids converting some JS Unicode
1992
+ // properties (ex: `\p{Alpha}`) to Onig POSIX classes
1993
+ unicodePropertyMap: Re
1994
+ }).body;
1995
+ return n.length > 1 || n[0].body.length > 1 ? N({ body: n }) : n[0].body[0];
1996
+ }
1997
+ function Ie(e, r) {
1998
+ return e.negate = r, e;
1999
+ }
2000
+ function O(e, r) {
2001
+ return e.parent = r, e;
2002
+ }
2003
+ function C(e, r) {
2004
+ return $r(e), e.parent = r, e;
2005
+ }
2006
+ function nn(e, r) {
2007
+ const t = xr(r), n = Ne(t.target, "ES2024"), s = Ne(t.target, "ES2025"), o = t.rules.recursionLimit;
2008
+ if (!Number.isInteger(o) || o < 2 || o > 20)
2009
+ throw new Error("Invalid recursionLimit; use 2-20");
2010
+ let a = null, i = null;
2011
+ if (!s) {
2012
+ const g = [e.flags.ignoreCase];
2013
+ oe(e, sn, {
2014
+ getCurrentModI: () => g.at(-1),
2015
+ popModI() {
2016
+ g.pop();
2017
+ },
2018
+ pushModI(d) {
2019
+ g.push(d);
2020
+ },
2021
+ setHasCasedChar() {
2022
+ g.at(-1) ? a = !0 : i = !0;
2023
+ }
2024
+ });
2025
+ }
2026
+ const u = {
2027
+ dotAll: e.flags.dotAll,
2028
+ // - Turn global flag i on if a case insensitive node was used and no case sensitive nodes were
2029
+ // used (to avoid unnecessary node expansion).
2030
+ // - Turn global flag i off if a case sensitive node was used (since case sensitivity can't be
2031
+ // forced without the use of ES2025 flag groups)
2032
+ ignoreCase: !!((e.flags.ignoreCase || a) && !i)
2033
+ };
2034
+ let c = e;
2035
+ const p = {
2036
+ accuracy: t.accuracy,
2037
+ appliedGlobalFlags: u,
2038
+ captureMap: /* @__PURE__ */ new Map(),
2039
+ currentFlags: {
2040
+ dotAll: e.flags.dotAll,
2041
+ ignoreCase: e.flags.ignoreCase
2042
+ },
2043
+ inCharClass: !1,
2044
+ lastNode: c,
2045
+ originMap: e._originMap,
2046
+ recursionLimit: o,
2047
+ useAppliedIgnoreCase: !!(!s && a && i),
2048
+ useFlagMods: s,
2049
+ useFlagV: n,
2050
+ verbose: t.verbose
2051
+ };
2052
+ function l(g) {
2053
+ return p.lastNode = c, c = g, Ut(on[g.type], `Unexpected node type "${g.type}"`)(g, p, l);
2054
+ }
2055
+ const f = {
2056
+ pattern: e.body.map(l).join("|"),
2057
+ // Could reset `lastNode` at this point via `lastNode = ast`, but it isn't needed by flags
2058
+ flags: l(e.flags),
2059
+ options: { ...e.options }
2060
+ };
2061
+ return n || (delete f.options.force.v, f.options.disable.v = !0, f.options.unicodeSetsPlugin = null), f._captureTransfers = /* @__PURE__ */ new Map(), f._hiddenCaptures = [], p.captureMap.forEach((g, d) => {
2062
+ g.hidden && f._hiddenCaptures.push(d), g.transferTo && ae(f._captureTransfers, g.transferTo, []).push(d);
2063
+ }), f;
2064
+ }
2065
+ var sn = {
2066
+ "*": {
2067
+ enter({ node: e }, r) {
2068
+ if (sr(e)) {
2069
+ const t = r.getCurrentModI();
2070
+ r.pushModI(
2071
+ e.flags ? de({ ignoreCase: t }, e.flags).ignoreCase : t
2072
+ );
2073
+ }
2074
+ },
2075
+ exit({ node: e }, r) {
2076
+ sr(e) && r.popModI();
2077
+ }
2078
+ },
2079
+ Backreference(e, r) {
2080
+ r.setHasCasedChar();
2081
+ },
2082
+ Character({ node: e }, r) {
2083
+ Ue(b(e.value)) && r.setHasCasedChar();
2084
+ },
2085
+ CharacterClassRange({ node: e, skip: r }, t) {
2086
+ r(), Mr(e, { firstOnly: !0 }).length && t.setHasCasedChar();
2087
+ },
2088
+ CharacterSet({ node: e }, r) {
2089
+ e.kind === "property" && Er.has(e.value) && r.setHasCasedChar();
2090
+ }
2091
+ }, on = {
2092
+ /**
2093
+ @param {AlternativeNode} node
2094
+ */
2095
+ Alternative({ body: e }, r, t) {
2096
+ return e.map(t).join("");
2097
+ },
2098
+ /**
2099
+ @param {AssertionNode} node
2100
+ */
2101
+ Assertion({ kind: e, negate: r }) {
2102
+ if (e === "string_end")
2103
+ return "$";
2104
+ if (e === "string_start")
2105
+ return "^";
2106
+ if (e === "word_boundary")
2107
+ return r ? h`\B` : h`\b`;
2108
+ throw new Error(`Unexpected assertion kind "${e}"`);
2109
+ },
2110
+ /**
2111
+ @param {BackreferenceNode} node
2112
+ */
2113
+ Backreference({ ref: e }, r) {
2114
+ if (typeof e != "number")
2115
+ throw new Error("Unexpected named backref in transformed AST");
2116
+ if (!r.useFlagMods && r.accuracy === "strict" && r.currentFlags.ignoreCase && !r.captureMap.get(e).ignoreCase)
2117
+ throw new Error("Use of case-insensitive backref to case-sensitive group requires target ES2025 or non-strict accuracy");
2118
+ return "\\" + e;
2119
+ },
2120
+ /**
2121
+ @param {CapturingGroupNode} node
2122
+ */
2123
+ CapturingGroup(e, r, t) {
2124
+ const { body: n, name: s, number: o } = e, a = { ignoreCase: r.currentFlags.ignoreCase }, i = r.originMap.get(e);
2125
+ return i && (a.hidden = !0, o > i.number && (a.transferTo = i.number)), r.captureMap.set(o, a), `(${s ? `?<${s}>` : ""}${n.map(t).join("|")})`;
2126
+ },
2127
+ /**
2128
+ @param {CharacterNode} node
2129
+ */
2130
+ Character({ value: e }, r) {
2131
+ const t = b(e), n = K(e, {
2132
+ escDigit: r.lastNode.type === "Backreference",
2133
+ inCharClass: r.inCharClass,
2134
+ useFlagV: r.useFlagV
2135
+ });
2136
+ if (n !== t)
2137
+ return n;
2138
+ if (r.useAppliedIgnoreCase && r.currentFlags.ignoreCase && Ue(t)) {
2139
+ const s = kr(t);
2140
+ return r.inCharClass ? s.join("") : s.length > 1 ? `[${s.join("")}]` : s[0];
2141
+ }
2142
+ return t;
2143
+ },
2144
+ /**
2145
+ @param {CharacterClassNode} node
2146
+ */
2147
+ CharacterClass(e, r, t) {
2148
+ const { kind: n, negate: s, parent: o } = e;
2149
+ let { body: a } = e;
2150
+ if (n === "intersection" && !r.useFlagV)
2151
+ throw new Error("Use of character class intersection requires min target ES2024");
2152
+ L.bugFlagVLiteralHyphenIsRange && r.useFlagV && a.some(or) && (a = [ge(45), ...a.filter((c) => !or(c))]);
2153
+ const i = () => `[${s ? "^" : ""}${a.map(t).join(n === "intersection" ? "&&" : "")}]`;
2154
+ if (!r.inCharClass) {
2155
+ if (
2156
+ // Already established `kind !== 'intersection'` if `!state.useFlagV`; don't check again
2157
+ (!r.useFlagV || L.bugNestedClassIgnoresNegation) && !s
2158
+ ) {
2159
+ const p = a.filter(
2160
+ (l) => l.type === "CharacterClass" && l.kind === "union" && l.negate
2161
+ );
2162
+ if (p.length) {
2163
+ const l = N(), f = l.body[0];
2164
+ return l.parent = o, f.parent = l, a = a.filter((g) => !p.includes(g)), e.body = a, a.length ? (e.parent = f, f.body.push(e)) : l.body.pop(), p.forEach((g) => {
2165
+ const d = Q({ body: [g] });
2166
+ g.parent = d, d.parent = l, l.body.push(d);
2167
+ }), t(l);
2168
+ }
2169
+ }
2170
+ r.inCharClass = !0;
2171
+ const c = i();
2172
+ return r.inCharClass = !1, c;
2173
+ }
2174
+ const u = a[0];
2175
+ if (
2176
+ // Already established that the parent is a char class via `inCharClass`; don't check again
2177
+ n === "union" && !s && u && // Allows many nested classes to work with `target` ES2018 which doesn't support nesting
2178
+ ((!r.useFlagV || !r.verbose) && o.kind === "union" && !(L.bugFlagVLiteralHyphenIsRange && r.useFlagV) || !r.verbose && o.kind === "intersection" && // JS doesn't allow intersection with union or ranges
2179
+ a.length === 1 && u.type !== "CharacterClassRange")
2180
+ )
2181
+ return a.map(t).join("");
2182
+ if (!r.useFlagV && o.type === "CharacterClass")
2183
+ throw new Error("Uses nested character class in a way that requires min target ES2024");
2184
+ return i();
2185
+ },
2186
+ /**
2187
+ @param {CharacterClassRangeNode} node
2188
+ */
2189
+ CharacterClassRange(e, r) {
2190
+ const t = e.min.value, n = e.max.value, s = {
2191
+ escDigit: !1,
2192
+ inCharClass: !0,
2193
+ useFlagV: r.useFlagV
2194
+ }, o = K(t, s), a = K(n, s), i = /* @__PURE__ */ new Set();
2195
+ if (r.useAppliedIgnoreCase && r.currentFlags.ignoreCase) {
2196
+ const u = Mr(e);
2197
+ pn(u).forEach((p) => {
2198
+ i.add(
2199
+ Array.isArray(p) ? `${K(p[0], s)}-${K(p[1], s)}` : K(p, s)
2200
+ );
2201
+ });
2202
+ }
2203
+ return `${o}-${a}${[...i].join("")}`;
2204
+ },
2205
+ /**
2206
+ @param {CharacterSetNode} node
2207
+ */
2208
+ CharacterSet({ kind: e, negate: r, value: t, key: n }, s) {
2209
+ if (e === "dot")
2210
+ return s.currentFlags.dotAll ? s.appliedGlobalFlags.dotAll || s.useFlagMods ? "." : "[^]" : (
2211
+ // Onig's only line break char is line feed, unlike JS
2212
+ h`[^\n]`
2213
+ );
2214
+ if (e === "digit")
2215
+ return r ? h`\D` : h`\d`;
2216
+ if (e === "property") {
2217
+ if (s.useAppliedIgnoreCase && s.currentFlags.ignoreCase && Er.has(t))
2218
+ throw new Error(`Unicode property "${t}" can't be case-insensitive when other chars have specific case`);
2219
+ return `${r ? h`\P` : h`\p`}{${n ? `${n}=` : ""}${t}}`;
2220
+ }
2221
+ if (e === "word")
2222
+ return r ? h`\W` : h`\w`;
2223
+ throw new Error(`Unexpected character set kind "${e}"`);
2224
+ },
2225
+ /**
2226
+ @param {FlagsNode} node
2227
+ */
2228
+ Flags(e, r) {
2229
+ return (
2230
+ // The transformer should never turn on the properties for flags d, g, m since Onig doesn't
2231
+ // have equivs. Flag m is never used since Onig uses different line break chars than JS
2232
+ // (node.hasIndices ? 'd' : '') +
2233
+ // (node.global ? 'g' : '') +
2234
+ // (node.multiline ? 'm' : '') +
2235
+ (r.appliedGlobalFlags.ignoreCase ? "i" : "") + (e.dotAll ? "s" : "") + (e.sticky ? "y" : "")
2236
+ );
2237
+ },
2238
+ /**
2239
+ @param {GroupNode} node
2240
+ */
2241
+ Group({ atomic: e, body: r, flags: t, parent: n }, s, o) {
2242
+ const a = s.currentFlags;
2243
+ t && (s.currentFlags = de(a, t));
2244
+ const i = r.map(o).join("|"), u = !s.verbose && r.length === 1 && // Single alt
2245
+ n.type !== "Quantifier" && !e && (!s.useFlagMods || !t) ? i : `(?${fn(e, t, s.useFlagMods)}${i})`;
2246
+ return s.currentFlags = a, u;
2247
+ },
2248
+ /**
2249
+ @param {LookaroundAssertionNode} node
2250
+ */
2251
+ LookaroundAssertion({ body: e, kind: r, negate: t }, n, s) {
2252
+ return `(?${`${r === "lookahead" ? "" : "<"}${t ? "!" : "="}`}${e.map(s).join("|")})`;
2253
+ },
2254
+ /**
2255
+ @param {QuantifierNode} node
2256
+ */
2257
+ Quantifier(e, r, t) {
2258
+ return t(e.body) + dn(e);
2259
+ },
2260
+ /**
2261
+ @param {SubroutineNode & {isRecursive: true}} node
2262
+ */
2263
+ Subroutine({ isRecursive: e, ref: r }, t) {
2264
+ if (!e)
2265
+ throw new Error("Unexpected non-recursive subroutine in transformed AST");
2266
+ const n = t.recursionLimit;
2267
+ return r === 0 ? `(?R=${n})` : h`\g<${r}&R=${n}>`;
2268
+ }
2269
+ }, an = /* @__PURE__ */ new Set([
2270
+ "$",
2271
+ "(",
2272
+ ")",
2273
+ "*",
2274
+ "+",
2275
+ ".",
2276
+ "?",
2277
+ "[",
2278
+ "\\",
2279
+ "]",
2280
+ "^",
2281
+ "{",
2282
+ "|",
2283
+ "}"
2284
+ ]), un = /* @__PURE__ */ new Set([
2285
+ "-",
2286
+ "\\",
2287
+ "]",
2288
+ "^",
2289
+ // Literal `[` doesn't require escaping with flag u, but this can help work around regex source
2290
+ // linters and regex syntax processors that expect unescaped `[` to create a nested class
2291
+ "["
2292
+ ]), cn = /* @__PURE__ */ new Set([
2293
+ "(",
2294
+ ")",
2295
+ "-",
2296
+ "/",
2297
+ "[",
2298
+ "\\",
2299
+ "]",
2300
+ "^",
2301
+ "{",
2302
+ "|",
2303
+ "}",
2304
+ // Double punctuators; also includes already-listed `-` and `^`
2305
+ "!",
2306
+ "#",
2307
+ "$",
2308
+ "%",
2309
+ "&",
2310
+ "*",
2311
+ "+",
2312
+ ",",
2313
+ ".",
2314
+ ":",
2315
+ ";",
2316
+ "<",
2317
+ "=",
2318
+ ">",
2319
+ "?",
2320
+ "@",
2321
+ "`",
2322
+ "~"
2323
+ ]), nr = /* @__PURE__ */ new Map([
2324
+ [9, h`\t`],
2325
+ // horizontal tab
2326
+ [10, h`\n`],
2327
+ // line feed
2328
+ [11, h`\v`],
2329
+ // vertical tab
2330
+ [12, h`\f`],
2331
+ // form feed
2332
+ [13, h`\r`],
2333
+ // carriage return
2334
+ [8232, h`\u2028`],
2335
+ // line separator
2336
+ [8233, h`\u2029`],
2337
+ // paragraph separator
2338
+ [65279, h`\uFEFF`]
2339
+ // ZWNBSP/BOM
2340
+ ]), ln = new RegExp("^\\p{Cased}$", "u");
2341
+ function Ue(e) {
2342
+ return ln.test(e);
2343
+ }
2344
+ function Mr(e, r) {
2345
+ const t = !!(r != null && r.firstOnly), n = e.min.value, s = e.max.value, o = [];
2346
+ if (n < 65 && (s === 65535 || s >= 131071) || n === 65536 && s >= 131071)
2347
+ return o;
2348
+ for (let a = n; a <= s; a++) {
2349
+ const i = b(a);
2350
+ if (!Ue(i))
2351
+ continue;
2352
+ const u = kr(i).filter((c) => {
2353
+ const p = c.codePointAt(0);
2354
+ return p < n || p > s;
2355
+ });
2356
+ if (u.length && (o.push(...u), t))
2357
+ break;
2358
+ }
2359
+ return o;
2360
+ }
2361
+ function K(e, { escDigit: r, inCharClass: t, useFlagV: n }) {
2362
+ if (nr.has(e))
2363
+ return nr.get(e);
2364
+ if (
2365
+ // Control chars, etc.; condition modeled on the Chrome developer console's display for strings
2366
+ e < 32 || e > 126 && e < 160 || // Unicode planes 4-16; unassigned, special purpose, and private use area
2367
+ e > 262143 || // Avoid corrupting a preceding backref by immediately following it with a literal digit
2368
+ r && gn(e)
2369
+ )
2370
+ return e > 255 ? `\\u{${e.toString(16).toUpperCase()}}` : `\\x${e.toString(16).toUpperCase().padStart(2, "0")}`;
2371
+ const s = t ? n ? cn : un : an, o = b(e);
2372
+ return (s.has(o) ? "\\" : "") + o;
2373
+ }
2374
+ function pn(e) {
2375
+ const r = e.map((s) => s.codePointAt(0)).sort((s, o) => s - o), t = [];
2376
+ let n = null;
2377
+ for (let s = 0; s < r.length; s++)
2378
+ r[s + 1] === r[s] + 1 ? n ?? (n = r[s]) : n === null ? t.push(r[s]) : (t.push([n, r[s]]), n = null);
2379
+ return t;
2380
+ }
2381
+ function fn(e, r, t) {
2382
+ if (e)
2383
+ return ">";
2384
+ let n = "";
2385
+ if (r && t) {
2386
+ const { enable: s, disable: o } = r;
2387
+ n = (s != null && s.ignoreCase ? "i" : "") + (s != null && s.dotAll ? "s" : "") + (o ? "-" : "") + (o != null && o.ignoreCase ? "i" : "") + (o != null && o.dotAll ? "s" : "");
2388
+ }
2389
+ return `${n}:`;
2390
+ }
2391
+ function dn({ kind: e, max: r, min: t }) {
2392
+ let n;
2393
+ return !t && r === 1 ? n = "?" : !t && r === 1 / 0 ? n = "*" : t === 1 && r === 1 / 0 ? n = "+" : t === r ? n = `{${t}}` : n = `{${t},${r === 1 / 0 ? "" : r}}`, n + {
2394
+ greedy: "",
2395
+ lazy: "?",
2396
+ possessive: "+"
2397
+ }[e];
2398
+ }
2399
+ function sr({ type: e }) {
2400
+ return e === "CapturingGroup" || e === "Group" || e === "LookaroundAssertion";
2401
+ }
2402
+ function gn(e) {
2403
+ return e > 47 && e < 58;
2404
+ }
2405
+ function or({ type: e, value: r }) {
2406
+ return e === "Character" && r === 45;
2407
+ }
2408
+ var D, P, X, T, Z, ie, Le, B, hn = (B = class extends RegExp {
2409
+ /**
2410
+ @overload
2411
+ @param {string} pattern
2412
+ @param {string} [flags]
2413
+ @param {EmulatedRegExpOptions} [options]
2414
+ */
2415
+ /**
2416
+ @overload
2417
+ @param {EmulatedRegExp} pattern
2418
+ @param {string} [flags]
2419
+ */
2420
+ constructor(t, n, s) {
2421
+ var r = (...Sn) => (super(...Sn), z(this, ie), /**
2422
+ @type {Map<number, {
2423
+ hidden?: true;
2424
+ transferTo?: number;
2425
+ }>}
2426
+ */
2427
+ z(this, D, /* @__PURE__ */ new Map()), /**
2428
+ @type {RegExp | EmulatedRegExp | null}
2429
+ */
2430
+ z(this, P, null), /**
2431
+ @type {string}
2432
+ */
2433
+ z(this, X), /**
2434
+ @type {Map<number, string>?}
2435
+ */
2436
+ z(this, T, null), /**
2437
+ @type {string?}
2438
+ */
2439
+ z(this, Z, null), /**
2440
+ Can be used to serialize the instance.
2441
+ @type {EmulatedRegExpOptions}
2442
+ */
2443
+ se(this, "rawOptions", {}), this);
2444
+ const o = !!(s != null && s.lazyCompile);
2445
+ if (t instanceof RegExp) {
2446
+ if (s)
2447
+ throw new Error("Cannot provide options when copying a regexp");
2448
+ const a = t;
2449
+ r(a, n), M(this, X, a.source), a instanceof B && (M(this, D, E(a, D)), M(this, T, E(a, T)), M(this, Z, E(a, Z)), this.rawOptions = a.rawOptions);
2450
+ } else {
2451
+ const a = {
2452
+ hiddenCaptures: [],
2453
+ strategy: null,
2454
+ transfers: [],
2455
+ ...s
2456
+ };
2457
+ r(o ? "" : t, n), M(this, X, t), M(this, D, mn(a.hiddenCaptures, a.transfers)), M(this, Z, a.strategy), this.rawOptions = s ?? {};
2458
+ }
2459
+ o || M(this, P, this);
2460
+ }
2461
+ // Override the getter with one that works with lazy-compiled regexes
2462
+ get source() {
2463
+ return E(this, X) || "(?:)";
2464
+ }
2465
+ /**
2466
+ Called internally by all String/RegExp methods that use regexes.
2467
+ @override
2468
+ @param {string} str
2469
+ @returns {RegExpExecArray?}
2470
+ */
2471
+ exec(t) {
2472
+ if (!E(this, P)) {
2473
+ const { lazyCompile: o, ...a } = this.rawOptions;
2474
+ M(this, P, new B(E(this, X), this.flags, a));
2475
+ }
2476
+ const n = this.global || this.sticky, s = this.lastIndex;
2477
+ if (E(this, Z) === "clip_search" && n && s) {
2478
+ this.lastIndex = 0;
2479
+ const o = Ce(this, ie, Le).call(this, t.slice(s));
2480
+ return o && (wn(o, s, t, this.hasIndices), this.lastIndex += s), o;
2481
+ }
2482
+ return Ce(this, ie, Le).call(this, t);
2483
+ }
2484
+ }, D = new WeakMap(), P = new WeakMap(), X = new WeakMap(), T = new WeakMap(), Z = new WeakMap(), ie = new WeakSet(), /**
2485
+ Adds support for hidden and transfer captures.
2486
+ @param {string} str
2487
+ @returns
2488
+ */
2489
+ Le = function(t) {
2490
+ E(this, P).lastIndex = this.lastIndex;
2491
+ const n = Te(B.prototype, this, "exec").call(E(this, P), t);
2492
+ if (this.lastIndex = E(this, P).lastIndex, !n || !E(this, D).size)
2493
+ return n;
2494
+ const s = [...n];
2495
+ n.length = 1;
2496
+ let o;
2497
+ this.hasIndices && (o = [...n.indices], n.indices.length = 1);
2498
+ const a = [0];
2499
+ for (let i = 1; i < s.length; i++) {
2500
+ const { hidden: u, transferTo: c } = E(this, D).get(i) ?? {};
2501
+ if (u ? a.push(null) : (a.push(n.length), n.push(s[i]), this.hasIndices && n.indices.push(o[i])), c && s[i] !== void 0) {
2502
+ const p = a[c];
2503
+ if (!p)
2504
+ throw new Error(`Invalid capture transfer to "${p}"`);
2505
+ if (n[p] = s[i], this.hasIndices && (n.indices[p] = o[i]), n.groups) {
2506
+ E(this, T) || M(this, T, yn(this.source));
2507
+ const l = E(this, T).get(c);
2508
+ l && (n.groups[l] = s[i], this.hasIndices && (n.indices.groups[l] = o[i]));
2509
+ }
2510
+ }
2511
+ }
2512
+ return n;
2513
+ }, B);
2514
+ function wn(e, r, t, n) {
2515
+ if (e.index += r, e.input = t, n) {
2516
+ const s = e.indices;
2517
+ for (let a = 0; a < s.length; a++) {
2518
+ const i = s[a];
2519
+ i && (s[a] = [i[0] + r, i[1] + r]);
2520
+ }
2521
+ const o = s.groups;
2522
+ o && Object.keys(o).forEach((a) => {
2523
+ const i = o[a];
2524
+ i && (o[a] = [i[0] + r, i[1] + r]);
2525
+ });
2526
+ }
2527
+ }
2528
+ function mn(e, r) {
2529
+ const t = /* @__PURE__ */ new Map();
2530
+ for (const n of e)
2531
+ t.set(n, {
2532
+ hidden: !0
2533
+ });
2534
+ for (const [n, s] of r)
2535
+ for (const o of s)
2536
+ ae(t, o, {}).transferTo = n;
2537
+ return t;
2538
+ }
2539
+ function yn(e) {
2540
+ const r = /(?<capture>\((?:\?<(?![=!])(?<name>[^>]+)>|(?!\?)))|\\?./gsu, t = /* @__PURE__ */ new Map();
2541
+ let n = 0, s = 0, o;
2542
+ for (; o = r.exec(e); ) {
2543
+ const { 0: a, groups: { capture: i, name: u } } = o;
2544
+ a === "[" ? n++ : n ? a === "]" && n-- : i && (s++, u && t.set(s, u));
2545
+ }
2546
+ return t;
2547
+ }
2548
+ function Cn(e, r) {
2549
+ const t = bn(e, r);
2550
+ return t.options ? new hn(t.pattern, t.flags, t.options) : new RegExp(t.pattern, t.flags);
2551
+ }
2552
+ function bn(e, r) {
2553
+ const t = xr(r), n = dr(e, {
2554
+ flags: t.flags,
2555
+ normalizeUnknownPropertyNames: !0,
2556
+ rules: {
2557
+ captureGroup: t.rules.captureGroup,
2558
+ singleline: t.rules.singleline
2559
+ },
2560
+ skipBackrefValidation: t.rules.allowOrphanBackrefs,
2561
+ unicodePropertyMap: Re
2562
+ }), s = jt(n, {
2563
+ accuracy: t.accuracy,
2564
+ asciiWordBoundaries: t.rules.asciiWordBoundaries,
2565
+ avoidSubclass: t.avoidSubclass,
2566
+ bestEffortTarget: t.target
2567
+ }), o = nn(s, t), a = Pt(o.pattern, {
2568
+ captureTransfers: o._captureTransfers,
2569
+ hiddenCaptures: o._hiddenCaptures,
2570
+ mode: "external"
2571
+ }), i = Ft(a.pattern), u = Lt(i.pattern, {
2572
+ captureTransfers: a.captureTransfers,
2573
+ hiddenCaptures: a.hiddenCaptures
2574
+ }), c = {
2575
+ pattern: u.pattern,
2576
+ flags: `${t.hasIndices ? "d" : ""}${t.global ? "g" : ""}${o.flags}${o.options.disable.v ? "u" : "v"}`
2577
+ };
2578
+ if (t.avoidSubclass) {
2579
+ if (t.lazyCompileLength !== 1 / 0)
2580
+ throw new Error("Lazy compilation requires subclass");
2581
+ } else {
2582
+ const p = u.hiddenCaptures.sort((d, w) => d - w), l = Array.from(u.captureTransfers), f = s._strategy, g = c.pattern.length >= t.lazyCompileLength;
2583
+ (p.length || l.length || f || g) && (c.options = {
2584
+ ...p.length && { hiddenCaptures: p },
2585
+ ...l.length && { transfers: l },
2586
+ ...f && { strategy: f },
2587
+ ...g && { lazyCompile: g }
2588
+ });
2589
+ }
2590
+ return c;
2591
+ }
2592
+ function xn(e, r) {
2593
+ return Cn(e, {
2594
+ global: !0,
2595
+ hasIndices: !0,
2596
+ lazyCompileLength: 3e3,
2597
+ rules: {
2598
+ allowOrphanBackrefs: !0,
2599
+ asciiWordBoundaries: !0,
2600
+ captureGroup: !0,
2601
+ recursionLimit: 5,
2602
+ singleline: !0
2603
+ },
2604
+ ...r
2605
+ });
2606
+ }
2607
+ function En(e = {}) {
2608
+ const r = {
2609
+ target: "auto",
2610
+ cache: /* @__PURE__ */ new Map(),
2611
+ ...e
2612
+ };
2613
+ return r.regexConstructor || (r.regexConstructor = (t) => xn(t, { target: r.target })), {
2614
+ createScanner(t) {
2615
+ return new ar(t, r);
2616
+ },
2617
+ createString(t) {
2618
+ return { content: t };
2619
+ }
2620
+ };
2621
+ }
2622
+ function $n() {
2623
+ const e = {
2624
+ cache: /* @__PURE__ */ new Map(),
2625
+ regexConstructor: () => {
2626
+ throw new Error("JavaScriptRawEngine: only support precompiled grammar");
2627
+ }
2628
+ };
2629
+ return {
2630
+ createScanner(r) {
2631
+ return new ar(r, e);
2632
+ },
2633
+ createString(r) {
2634
+ return { content: r };
2635
+ }
2636
+ };
2637
+ }
2638
+ export {
2639
+ ar as JavaScriptScanner,
2640
+ $n as createJavaScriptRawEngine,
2641
+ En as createJavaScriptRegexEngine,
2642
+ xn as defaultJavaScriptRegexConstructor
2643
+ };