@drfed/web 0.0.0-stage → 0.1.0-dev.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 (128) hide show
  1. package/.output/nitro.json +17 -0
  2. package/.output/public/.vite/manifest.json +493 -0
  3. package/.output/public/_build/assets/ActorDetailQuery.graphql-D96mwq1k.js +60 -0
  4. package/.output/public/_build/assets/ActorDetailQuery.graphql-DrxSNh1X.js +60 -0
  5. package/.output/public/_build/assets/CompleteLoginChallenge.graphql-C5Zq3wNh.js +10 -0
  6. package/.output/public/_build/assets/CopyButton-B2l484wE.js +1 -0
  7. package/.output/public/_build/assets/CopyButton-Bi-ZR8x9.css +1 -0
  8. package/.output/public/_build/assets/CreateInstanceMutation.graphql-B4CRy6cl.js +19 -0
  9. package/.output/public/_build/assets/CreateObjectMutation.graphql-B4A01dgV.js +23 -0
  10. package/.output/public/_build/assets/GenerateActorsMutation.graphql-mlHJNIbe.js +23 -0
  11. package/.output/public/_build/assets/GetHostQuery.graphql-CuzDdOdW.js +17 -0
  12. package/.output/public/_build/assets/GetHostQuery.graphql-o9K0Qkg0.js +17 -0
  13. package/.output/public/_build/assets/HomeViewerQuery.graphql-B903WWKs.js +8 -0
  14. package/.output/public/_build/assets/HttpStatusCode-bgaVzuLy.js +1 -0
  15. package/.output/public/_build/assets/InstanceActorListQuery.graphql-DmNwiEhM.js +24 -0
  16. package/.output/public/_build/assets/InstanceActorListQuery.graphql-paa7teUO.js +24 -0
  17. package/.output/public/_build/assets/InstanceDetailQuery.graphql-B52nR132.js +66 -0
  18. package/.output/public/_build/assets/InstanceDetailQuery.graphql-DSA2BcAV.js +66 -0
  19. package/.output/public/_build/assets/InstanceSummary_instance.graphql-BoQAa5Od.js +1 -0
  20. package/.output/public/_build/assets/JNCCF6MP-CNMywyiC.js +1 -0
  21. package/.output/public/_build/assets/LP6E37CW-Cwv6G3n1.js +1 -0
  22. package/.output/public/_build/assets/SignInMutation.graphql-BalZYNFu.js +9 -0
  23. package/.output/public/_build/assets/TSB6MOZK-CpiH97G1.js +1 -0
  24. package/.output/public/_build/assets/Toast-3-eXCAKc.css +1 -0
  25. package/.output/public/_build/assets/Toast-C1zr9crB.js +1 -0
  26. package/.output/public/_build/assets/WorkspaceQuery.graphql-UoI7QDs4.js +23 -0
  27. package/.output/public/_build/assets/_...404_-WZ8kAljY.js +1 -0
  28. package/.output/public/_build/assets/_challengeId_-BgL-Berz.js +1 -0
  29. package/.output/public/_build/assets/_id_-YcZZShAv.css +1 -0
  30. package/.output/public/_build/assets/_id_-bpxdclBj.js +1 -0
  31. package/.output/public/_build/assets/_slug_-CyTA2aW7.css +1 -0
  32. package/.output/public/_build/assets/_slug_-DXfRknzJ.js +200 -0
  33. package/.output/public/_build/assets/about-DIrbzRsi.js +1 -0
  34. package/.output/public/_build/assets/actors-HfZh_afh.js +24 -0
  35. package/.output/public/_build/assets/client-CGFoRcqH.js +3 -0
  36. package/.output/public/_build/assets/components-5MVu7IcD.js +1 -0
  37. package/.output/public/_build/assets/dist-BrJ_B8nU.js +1 -0
  38. package/.output/public/_build/assets/dist-DVo0HS5G.js +1 -0
  39. package/.output/public/_build/assets/dist-WrlGlK67.js +1 -0
  40. package/.output/public/_build/assets/entry-client-BurSTYr9.css +1 -0
  41. package/.output/public/_build/assets/entry-client-RIC5nXxX.js +8 -0
  42. package/.output/public/_build/assets/form-BxigYd7J.css +1 -0
  43. package/.output/public/_build/assets/form.module-BecmEfV_.js +1 -0
  44. package/.output/public/_build/assets/index-BHn6sAgH.js +23 -0
  45. package/.output/public/_build/assets/index-BSLqnqN7.js +8 -0
  46. package/.output/public/_build/assets/index-B_xLBDOo.css +1 -0
  47. package/.output/public/_build/assets/instance-tpMrvJNZ.js +35 -0
  48. package/.output/public/_build/assets/label-Mv8GZ4jc.js +1 -0
  49. package/.output/public/_build/assets/objects-DPb8DI8A.css +1 -0
  50. package/.output/public/_build/assets/objects-DR9TfL-V.js +25 -0
  51. package/.output/public/_build/assets/relay-runtime-BX3uubtA.js +7 -0
  52. package/.output/public/_build/assets/routing-DMN2NHu6.js +1 -0
  53. package/.output/public/_build/assets/sign-in-B67sv7z8.js +10 -0
  54. package/.output/public/_build/assets/web-DB_Nkq2D.js +1 -0
  55. package/.output/public/apple-touch-icon.png +0 -0
  56. package/.output/public/favicon.ico +0 -0
  57. package/.output/public/icon-192.png +0 -0
  58. package/.output/public/icon-512.png +0 -0
  59. package/.output/public/icon-mask.png +0 -0
  60. package/.output/public/icon.svg +395 -0
  61. package/.output/public/manifest.webmanifest +13 -0
  62. package/.output/server/_...404_-DDEH5apf.mjs +16 -0
  63. package/.output/server/_challengeId_-C7BBdG0r.mjs +100 -0
  64. package/.output/server/_chunks/ssr-renderer.mjs +26 -0
  65. package/.output/server/_id_-DqytvZEf.mjs +505 -0
  66. package/.output/server/_libs/@shikijs/core+[...].mjs +7173 -0
  67. package/.output/server/_libs/@shikijs/engine-javascript+[...].mjs +3110 -0
  68. package/.output/server/_libs/babel__runtime.mjs +243 -0
  69. package/.output/server/_libs/dequal.mjs +25 -0
  70. package/.output/server/_libs/faker-js__faker.mjs +13150 -0
  71. package/.output/server/_libs/fbjs.mjs +115 -0
  72. package/.output/server/_libs/h3+rou3+srvx.mjs +650 -0
  73. package/.output/server/_libs/hookable.mjs +41 -0
  74. package/.output/server/_libs/invariant.mjs +36 -0
  75. package/.output/server/_libs/relay-runtime.mjs +9704 -0
  76. package/.output/server/_libs/seroval-plugins.mjs +563 -0
  77. package/.output/server/_libs/seroval.mjs +2956 -0
  78. package/.output/server/_libs/shikijs__langs.mjs +3 -0
  79. package/.output/server/_libs/shikijs__themes.mjs +7 -0
  80. package/.output/server/_libs/solid-js.mjs +1248 -0
  81. package/.output/server/_libs/solid-relay+tiny-invariant.mjs +1029 -0
  82. package/.output/server/_libs/ufo.mjs +64 -0
  83. package/.output/server/_libs/valibot.mjs +711 -0
  84. package/.output/server/_runtime.mjs +33 -0
  85. package/.output/server/_slug_-CBOaSqoF.mjs +978 -0
  86. package/.output/server/_ssr/ActorDetailQuery.graphql-C1mWRP1B.mjs +283 -0
  87. package/.output/server/_ssr/CompleteLoginChallenge.graphql-CM7o_Md1.mjs +78 -0
  88. package/.output/server/_ssr/CopyButton-CQNR5D1y.mjs +43 -0
  89. package/.output/server/_ssr/CreateInstanceMutation.graphql-C-h2lGxz.mjs +116 -0
  90. package/.output/server/_ssr/CreateObjectMutation.graphql-C393Hp7q.mjs +166 -0
  91. package/.output/server/_ssr/GenerateActorsMutation.graphql-D2ADtn1j.mjs +163 -0
  92. package/.output/server/_ssr/GetHostQuery.graphql-C45XQo1i.mjs +127 -0
  93. package/.output/server/_ssr/HomeViewerQuery.graphql-Dote4Pkz.mjs +81 -0
  94. package/.output/server/_ssr/InstanceActorListQuery.graphql-DgItgN5t.mjs +167 -0
  95. package/.output/server/_ssr/InstanceDetailQuery.graphql-DP5wWWjX.mjs +367 -0
  96. package/.output/server/_ssr/InstanceSummary_instance.graphql-10tilF-Z.mjs +34 -0
  97. package/.output/server/_ssr/JNCCF6MP-BAZlBnvx.mjs +419 -0
  98. package/.output/server/_ssr/LP6E37CW-D2Ih_b_K.mjs +163 -0
  99. package/.output/server/_ssr/SignInMutation.graphql-BBXmiay6.mjs +72 -0
  100. package/.output/server/_ssr/TSB6MOZK-D06WZb6o.mjs +166 -0
  101. package/.output/server/_ssr/Toast-Bb1gcxED.mjs +947 -0
  102. package/.output/server/_ssr/WorkspaceQuery.graphql-DnCO8t-4.mjs +153 -0
  103. package/.output/server/_ssr/about-CD3QIgf_.mjs +14 -0
  104. package/.output/server/_ssr/actors-CMWf-xQU.mjs +1160 -0
  105. package/.output/server/_ssr/dist-D6rgyh-L.mjs +81 -0
  106. package/.output/server/_ssr/dist-I7KRMRbA.mjs +432 -0
  107. package/.output/server/_ssr/form.module-CTvIl1lm.mjs +192 -0
  108. package/.output/server/_ssr/index-C4crD6q-.mjs +347 -0
  109. package/.output/server/_ssr/index-yuhuc6-X.mjs +111 -0
  110. package/.output/server/_ssr/instance-ZYWGeWd3.mjs +280 -0
  111. package/.output/server/_ssr/label-DAXzanI9.mjs +9 -0
  112. package/.output/server/_ssr/objects-D5MVukzB.mjs +4316 -0
  113. package/.output/server/_ssr/routing-DKTLkkbY.mjs +620 -0
  114. package/.output/server/_ssr/sign-in-CNHZb_zL.mjs +264 -0
  115. package/.output/server/_ssr/ssr.mjs +6138 -0
  116. package/.output/server/index.mjs +691 -0
  117. package/LICENSE +661 -0
  118. package/README.md +143 -2
  119. package/dist/bridge.d.mts +39 -0
  120. package/dist/bridge.mjs +104 -0
  121. package/dist/bridge.mjs.map +1 -0
  122. package/dist/request-policy.d.mts +8 -0
  123. package/dist/request-policy.mjs +94 -0
  124. package/dist/request-policy.mjs.map +1 -0
  125. package/dist/runtime.d.mts +14 -0
  126. package/dist/runtime.mjs +44 -0
  127. package/dist/runtime.mjs.map +1 -0
  128. package/package.json +111 -3
@@ -0,0 +1,3110 @@
1
+ //#region ../../node_modules/.pnpm/@shikijs+engine-javascript@4.4.1/node_modules/@shikijs/engine-javascript/dist/scanner-DX8LRFGE.mjs
2
+ var MAX = 4294967295;
3
+ var JavaScriptScanner = class {
4
+ patterns;
5
+ options;
6
+ regexps;
7
+ constructor(patterns, options = {}) {
8
+ this.patterns = patterns;
9
+ this.options = options;
10
+ const { forgiving = false, cache, regexConstructor } = options;
11
+ if (!regexConstructor) throw new Error("Option `regexConstructor` is not provided");
12
+ this.regexps = patterns.map((p) => {
13
+ if (typeof p !== "string") return p;
14
+ const cached = cache?.get(p);
15
+ if (cached) {
16
+ if (cached instanceof RegExp) return cached;
17
+ if (forgiving) return null;
18
+ throw cached;
19
+ }
20
+ try {
21
+ const regex = regexConstructor(p);
22
+ cache?.set(p, regex);
23
+ return regex;
24
+ } catch (e) {
25
+ cache?.set(p, e);
26
+ if (forgiving) return null;
27
+ throw e;
28
+ }
29
+ });
30
+ }
31
+ findNextMatchSync(string, startPosition, _options) {
32
+ const str = typeof string === "string" ? string : string.content;
33
+ const pending = [];
34
+ function toResult(index, match, offset = 0) {
35
+ return {
36
+ index,
37
+ captureIndices: match.indices.map((indice) => {
38
+ if (indice == null) return {
39
+ start: MAX,
40
+ end: MAX,
41
+ length: 0
42
+ };
43
+ return {
44
+ start: indice[0] + offset,
45
+ end: indice[1] + offset,
46
+ length: indice[1] - indice[0]
47
+ };
48
+ })
49
+ };
50
+ }
51
+ for (let i = 0; i < this.regexps.length; i++) {
52
+ const regexp = this.regexps[i];
53
+ if (!regexp) continue;
54
+ try {
55
+ regexp.lastIndex = startPosition;
56
+ const match = regexp.exec(str);
57
+ if (!match) continue;
58
+ if (match.index === startPosition) return toResult(i, match, 0);
59
+ pending.push([
60
+ i,
61
+ match,
62
+ 0
63
+ ]);
64
+ } catch (e) {
65
+ if (this.options.forgiving) continue;
66
+ throw e;
67
+ }
68
+ }
69
+ if (pending.length) {
70
+ const minIndex = Math.min(...pending.map((m) => m[1].index));
71
+ for (const [i, match, offset] of pending) if (match.index === minIndex) return toResult(i, match, offset);
72
+ }
73
+ return null;
74
+ }
75
+ };
76
+ //#endregion
77
+ //#region ../../node_modules/.pnpm/oniguruma-parser@0.12.2/node_modules/oniguruma-parser/dist/utils.js
78
+ function r$2(e) {
79
+ if ([...e].length !== 1) throw new Error(`Expected "${e}" to be a single code point`);
80
+ return e.codePointAt(0);
81
+ }
82
+ function l$1(e, t, n) {
83
+ return e.has(t) || e.set(t, n), e.get(t);
84
+ }
85
+ var i = /* @__PURE__ */ new Set([
86
+ "alnum",
87
+ "alpha",
88
+ "ascii",
89
+ "blank",
90
+ "cntrl",
91
+ "digit",
92
+ "graph",
93
+ "lower",
94
+ "print",
95
+ "punct",
96
+ "space",
97
+ "upper",
98
+ "word",
99
+ "xdigit"
100
+ ]);
101
+ var o$1 = String.raw;
102
+ function u(e, t) {
103
+ if (e == null) throw new Error(t ?? "Value expected");
104
+ return e;
105
+ }
106
+ //#endregion
107
+ //#region ../../node_modules/.pnpm/oniguruma-parser@0.12.2/node_modules/oniguruma-parser/dist/tokenizer/tokenize.js
108
+ var m$1 = o$1`\[\^?`;
109
+ var b$1 = `c.? | C(?:-.?)?|${o$1`[pP]\{(?:\^?[-\x20_]*[A-Za-z][-\x20\w]*\})?`}|${o$1`x[89A-Fa-f]\p{AHex}(?:\\x[89A-Fa-f]\p{AHex})*`}|${o$1`u(?:\p{AHex}{4})? | x\{[^\}]*\}? | x\p{AHex}{0,2}`}|${o$1`o\{[^\}]*\}?`}|${o$1`\d{1,3}`}`;
110
+ var y$1 = /[?*+][?+]?|\{(?:\d+(?:,\d*)?|,\d+)\}\??/;
111
+ var C$1 = new RegExp(o$1`
112
+ \\ (?:
113
+ ${b$1}
114
+ | [gk]<[^>]*>?
115
+ | [gk]'[^']*'?
116
+ | .
117
+ )
118
+ | \( (?:
119
+ \? (?:
120
+ [:=!>({]
121
+ | <[=!]
122
+ | <[^>]*>
123
+ | '[^']*'
124
+ | ~\|?
125
+ | #(?:[^)\\]|\\.?)*
126
+ | [^:)]*[:)]
127
+ )?
128
+ | \*[^\)]*\)?
129
+ )?
130
+ | (?:${y$1.source})+
131
+ | ${m$1}
132
+ | .
133
+ `.replace(/\s+/g, ""), "gsu");
134
+ var T$1 = new RegExp(o$1`
135
+ \\ (?:
136
+ ${b$1}
137
+ | .
138
+ )
139
+ | \[:(?:\^?\p{Alpha}+|\^):\]
140
+ | ${m$1}
141
+ | &&
142
+ | .
143
+ `.replace(/\s+/g, ""), "gsu");
144
+ function M$1(e, n = {}) {
145
+ const t = {
146
+ flags: "",
147
+ ...n,
148
+ rules: {
149
+ captureGroup: !1,
150
+ singleline: !1,
151
+ ...n.rules
152
+ }
153
+ };
154
+ if (typeof e != "string") throw new Error("String expected as pattern");
155
+ const o = Y(t.flags), s = [o.extended], a = {
156
+ captureGroup: t.rules.captureGroup,
157
+ getCurrentModX() {
158
+ return s.at(-1);
159
+ },
160
+ numOpenGroups: 0,
161
+ popModX() {
162
+ s.pop();
163
+ },
164
+ pushModX(u) {
165
+ s.push(u);
166
+ },
167
+ replaceCurrentModX(u) {
168
+ s[s.length - 1] = u;
169
+ },
170
+ singleline: t.rules.singleline
171
+ };
172
+ let r = [], i;
173
+ for (C$1.lastIndex = 0; i = C$1.exec(e);) {
174
+ const u = F$1(a, e, i[0], C$1.lastIndex);
175
+ u.tokens ? r.push(...u.tokens) : u.token && r.push(u.token), u.lastIndex !== void 0 && (C$1.lastIndex = u.lastIndex);
176
+ }
177
+ const l = [];
178
+ let c = 0;
179
+ r.filter((u) => u.type === "GroupOpen").forEach((u) => {
180
+ u.kind === "capturing" ? u.number = ++c : u.raw === "(" && l.push(u);
181
+ }), c || l.forEach((u, S) => {
182
+ u.kind = "capturing", u.number = S + 1;
183
+ });
184
+ const g = c || l.length;
185
+ return {
186
+ tokens: r.map((u) => u.type === "EscapedNumber" ? ee$1(u, g) : u).flat(),
187
+ flags: o
188
+ };
189
+ }
190
+ function F$1(e, n, t, o) {
191
+ const [s, a] = t;
192
+ if (t === "[" || t === "[^") {
193
+ const r = K$1(n, t, o);
194
+ return {
195
+ tokens: r.tokens,
196
+ lastIndex: r.lastIndex
197
+ };
198
+ }
199
+ if (s === "\\") {
200
+ if ("AbBGyYzZ".includes(a)) return { token: w$1(t, t) };
201
+ if (/^\\g[<']/.test(t)) {
202
+ if (!/^\\g(?:<[^>]+>|'[^']+')$/.test(t)) throw new Error(`Invalid group name "${t}"`);
203
+ return { token: R$1(t) };
204
+ }
205
+ if (/^\\k[<']/.test(t)) {
206
+ if (!/^\\k(?:<[^>]+>|'[^']+')$/.test(t)) throw new Error(`Invalid group name "${t}"`);
207
+ return { token: A$1(t) };
208
+ }
209
+ if (a === "K") return { token: I$1("keep", t) };
210
+ if (a === "N" || a === "R") return { token: k$1("newline", t, { negate: a === "N" }) };
211
+ if (a === "O") return { token: k$1("any", t) };
212
+ if (a === "X") return { token: k$1("text_segment", t) };
213
+ const r = x$1(t, { inCharClass: !1 });
214
+ return Array.isArray(r) ? { tokens: r } : { token: r };
215
+ }
216
+ if (s === "(") {
217
+ if (a === "*") return { token: j(t) };
218
+ if (t === "(?{") throw new Error(`Unsupported callout "${t}"`);
219
+ if (t.startsWith("(?#")) {
220
+ if (n[o] !== ")") throw new Error("Unclosed comment group \"(?#\"");
221
+ return { lastIndex: o + 1 };
222
+ }
223
+ if (/^\(\?[-imx]+[:)]$/.test(t)) return { token: L$1(t, e) };
224
+ if (e.pushModX(e.getCurrentModX()), e.numOpenGroups++, t === "(" && !e.captureGroup || t === "(?:") return { token: f("group", t) };
225
+ if (t === "(?>") return { token: f("atomic", t) };
226
+ if (t === "(?=" || t === "(?!" || t === "(?<=" || t === "(?<!") return { token: f(t[2] === "<" ? "lookbehind" : "lookahead", t, { negate: t.endsWith("!") }) };
227
+ if (t === "(" && e.captureGroup || t.startsWith("(?<") && t.endsWith(">") || t.startsWith("(?'") && t.endsWith("'")) return { token: f("capturing", t, { ...t !== "(" && { name: t.slice(3, -1) } }) };
228
+ if (t.startsWith("(?~")) {
229
+ if (t === "(?~|") throw new Error(`Unsupported absence function kind "${t}"`);
230
+ return { token: f("absence_repeater", t) };
231
+ }
232
+ throw t === "(?(" ? /* @__PURE__ */ new Error(`Unsupported conditional "${t}"`) : /* @__PURE__ */ new Error(`Invalid or unsupported group option "${t}"`);
233
+ }
234
+ if (t === ")") {
235
+ if (e.popModX(), e.numOpenGroups--, e.numOpenGroups < 0) throw new Error("Unmatched \")\"");
236
+ return { token: Q$1(t) };
237
+ }
238
+ if (e.getCurrentModX()) {
239
+ if (t === "#") {
240
+ const r = n.indexOf(`
241
+ `, o);
242
+ return { lastIndex: r === -1 ? n.length : r };
243
+ }
244
+ if (/^\s$/.test(t)) {
245
+ const r = /\s+/y;
246
+ return r.lastIndex = o, { lastIndex: r.exec(n) ? r.lastIndex : o };
247
+ }
248
+ }
249
+ if (t === ".") return { token: k$1("dot", t) };
250
+ if (t === "^" || t === "$") return { token: w$1(e.singleline ? {
251
+ "^": o$1`\A`,
252
+ $: o$1`\Z`
253
+ }[t] : t, t) };
254
+ return t === "|" ? { token: P$1(t) } : y$1.test(t) ? { tokens: te$1(t) } : { token: d(r$2(t), t) };
255
+ }
256
+ function K$1(e, n, t) {
257
+ const o = [E$1(n[1] === "^", n)];
258
+ let s = 1, a;
259
+ for (T$1.lastIndex = t; a = T$1.exec(e);) {
260
+ const r = a[0];
261
+ if (r[0] === "[" && r[1] !== ":") s++, o.push(E$1(r[1] === "^", r));
262
+ else if (r === "]") {
263
+ if (o.at(-1).type === "CharacterClassOpen") o.push(d(93, r));
264
+ else if (s--, o.push(z$1(r)), !s) break;
265
+ } else {
266
+ const i = X$1(r);
267
+ Array.isArray(i) ? o.push(...i) : o.push(i);
268
+ }
269
+ }
270
+ return {
271
+ tokens: o,
272
+ lastIndex: T$1.lastIndex || e.length
273
+ };
274
+ }
275
+ function X$1(e) {
276
+ if (e[0] === "\\") return x$1(e, { inCharClass: !0 });
277
+ if (e[0] === "[") {
278
+ const n = /\[:(?<negate>\^?)(?<name>[a-z]+):\]/.exec(e);
279
+ if (!n || !i.has(n.groups.name)) throw new Error(`Invalid POSIX class "${e}"`);
280
+ return k$1("posix", e, {
281
+ value: n.groups.name,
282
+ negate: !!n.groups.negate
283
+ });
284
+ }
285
+ return e === "-" ? U$1(e) : e === "&&" ? H(e) : d(r$2(e), e);
286
+ }
287
+ function x$1(e, { inCharClass: n }) {
288
+ const t = e[1];
289
+ if (t === "c" || t === "C") return Z(e);
290
+ if ("dDhHsSwW".includes(t)) return q(e);
291
+ if (e.startsWith(o$1`\o{`)) throw new Error(`Incomplete, invalid, or unsupported octal code point "${e}"`);
292
+ if (/^\\[pP]\{/.test(e)) {
293
+ if (e.length === 3) throw new Error(`Incomplete or invalid Unicode property "${e}"`);
294
+ return V$1(e);
295
+ }
296
+ if (/^\\x[89A-Fa-f]\p{AHex}/u.test(e)) try {
297
+ const o = e.split(/\\x/).slice(1).map((i) => parseInt(i, 16)), s = new TextDecoder("utf-8", {
298
+ ignoreBOM: !0,
299
+ fatal: !0
300
+ }).decode(new Uint8Array(o)), a = new TextEncoder();
301
+ return [...s].map((i) => {
302
+ const l = [...a.encode(i)].map((c) => `\\x${c.toString(16)}`).join("");
303
+ return d(r$2(i), l);
304
+ });
305
+ } catch {
306
+ throw new Error(`Multibyte code "${e}" incomplete or invalid in Oniguruma`);
307
+ }
308
+ if (t === "u" || t === "x") return d(J$1(e), e);
309
+ if ($$1.has(t)) return d($$1.get(t), e);
310
+ if (/\d/.test(t)) return W$1(n, e);
311
+ if (e === "\\") throw new Error(o$1`Incomplete escape "\"`);
312
+ if (t === "M") throw new Error(`Unsupported meta "${e}"`);
313
+ if ([...e].length === 2) return d(e.codePointAt(1), e);
314
+ throw new Error(`Unexpected escape "${e}"`);
315
+ }
316
+ function P$1(e) {
317
+ return {
318
+ type: "Alternator",
319
+ raw: e
320
+ };
321
+ }
322
+ function w$1(e, n) {
323
+ return {
324
+ type: "Assertion",
325
+ kind: e,
326
+ raw: n
327
+ };
328
+ }
329
+ function A$1(e) {
330
+ return {
331
+ type: "Backreference",
332
+ raw: e
333
+ };
334
+ }
335
+ function d(e, n) {
336
+ return {
337
+ type: "Character",
338
+ value: e,
339
+ raw: n
340
+ };
341
+ }
342
+ function z$1(e) {
343
+ return {
344
+ type: "CharacterClassClose",
345
+ raw: e
346
+ };
347
+ }
348
+ function U$1(e) {
349
+ return {
350
+ type: "CharacterClassHyphen",
351
+ raw: e
352
+ };
353
+ }
354
+ function H(e) {
355
+ return {
356
+ type: "CharacterClassIntersector",
357
+ raw: e
358
+ };
359
+ }
360
+ function E$1(e, n) {
361
+ return {
362
+ type: "CharacterClassOpen",
363
+ negate: e,
364
+ raw: n
365
+ };
366
+ }
367
+ function k$1(e, n, t = {}) {
368
+ return {
369
+ type: "CharacterSet",
370
+ kind: e,
371
+ ...t,
372
+ raw: n
373
+ };
374
+ }
375
+ function I$1(e, n, t = {}) {
376
+ return e === "keep" ? {
377
+ type: "Directive",
378
+ kind: e,
379
+ raw: n
380
+ } : {
381
+ type: "Directive",
382
+ kind: e,
383
+ flags: u(t.flags),
384
+ raw: n
385
+ };
386
+ }
387
+ function W$1(e, n) {
388
+ return {
389
+ type: "EscapedNumber",
390
+ inCharClass: e,
391
+ raw: n
392
+ };
393
+ }
394
+ function Q$1(e) {
395
+ return {
396
+ type: "GroupClose",
397
+ raw: e
398
+ };
399
+ }
400
+ function f(e, n, t = {}) {
401
+ return {
402
+ type: "GroupOpen",
403
+ kind: e,
404
+ ...t,
405
+ raw: n
406
+ };
407
+ }
408
+ function D$1(e, n, t, o) {
409
+ return {
410
+ type: "NamedCallout",
411
+ kind: e,
412
+ tag: n,
413
+ arguments: t,
414
+ raw: o
415
+ };
416
+ }
417
+ function _$1(e, n, t, o) {
418
+ return {
419
+ type: "Quantifier",
420
+ kind: e,
421
+ min: n,
422
+ max: t,
423
+ raw: o
424
+ };
425
+ }
426
+ function R$1(e) {
427
+ return {
428
+ type: "Subroutine",
429
+ raw: e
430
+ };
431
+ }
432
+ var B$1 = /* @__PURE__ */ new Set([
433
+ "COUNT",
434
+ "CMP",
435
+ "ERROR",
436
+ "FAIL",
437
+ "MAX",
438
+ "MISMATCH",
439
+ "SKIP",
440
+ "TOTAL_COUNT"
441
+ ]);
442
+ var $$1 = /* @__PURE__ */ new Map([
443
+ ["a", 7],
444
+ ["b", 8],
445
+ ["e", 27],
446
+ ["f", 12],
447
+ ["n", 10],
448
+ ["r", 13],
449
+ ["t", 9],
450
+ ["v", 11]
451
+ ]);
452
+ function Z(e) {
453
+ const n = e[1] === "c" ? e[2] : e[3];
454
+ if (!n || !/[A-Za-z]/.test(n)) throw new Error(`Unsupported control character "${e}"`);
455
+ return d(r$2(n.toUpperCase()) - 64, e);
456
+ }
457
+ function L$1(e, n) {
458
+ let { on: t, off: o } = /^\(\?(?<on>[imx]*)(?:-(?<off>[-imx]*))?/.exec(e).groups;
459
+ o ??= "";
460
+ const s = (n.getCurrentModX() || t.includes("x")) && !o.includes("x"), a = v(t), r = v(o), i = {};
461
+ if (a && (i.enable = a), r && (i.disable = r), e.endsWith(")")) return n.replaceCurrentModX(s), I$1("flags", e, { flags: i });
462
+ if (e.endsWith(":")) return n.pushModX(s), n.numOpenGroups++, f("group", e, { ...(a || r) && { flags: i } });
463
+ throw new Error(`Unexpected flag modifier "${e}"`);
464
+ }
465
+ function j(e) {
466
+ const n = /\(\*(?<name>[A-Za-z_]\w*)?(?:\[(?<tag>(?:[A-Za-z_]\w*)?)\])?(?:\{(?<args>[^}]*)\})?\)/.exec(e);
467
+ if (!n) throw new Error(`Incomplete or invalid named callout "${e}"`);
468
+ const { name: t, tag: o, args: s } = n.groups;
469
+ if (!t) throw new Error(`Invalid named callout "${e}"`);
470
+ if (o === "") throw new Error(`Named callout tag with empty value not allowed "${e}"`);
471
+ const a = s ? s.split(",").filter((g) => g !== "").map((g) => /^[+-]?\d+$/.test(g) ? +g : g) : [], [r, i, l] = a, c = B$1.has(t) ? t.toLowerCase() : "custom";
472
+ switch (c) {
473
+ case "fail":
474
+ case "mismatch":
475
+ case "skip":
476
+ if (a.length > 0) throw new Error(`Named callout arguments not allowed "${a}"`);
477
+ break;
478
+ case "error":
479
+ if (a.length > 1) throw new Error(`Named callout allows only one argument "${a}"`);
480
+ if (typeof r == "string") throw new Error(`Named callout argument must be a number "${r}"`);
481
+ break;
482
+ case "max":
483
+ if (!a.length || a.length > 2) throw new Error(`Named callout must have one or two arguments "${a}"`);
484
+ if (typeof r == "string" && !/^[A-Za-z_]\w*$/.test(r)) throw new Error(`Named callout argument one must be a tag or number "${r}"`);
485
+ if (a.length === 2 && (typeof i == "number" || !/^[<>X]$/.test(i))) throw new Error(`Named callout optional argument two must be '<', '>', or 'X' "${i}"`);
486
+ break;
487
+ case "count":
488
+ case "total_count":
489
+ if (a.length > 1) throw new Error(`Named callout allows only one argument "${a}"`);
490
+ if (a.length === 1 && (typeof r == "number" || !/^[<>X]$/.test(r))) throw new Error(`Named callout optional argument must be '<', '>', or 'X' "${r}"`);
491
+ break;
492
+ case "cmp":
493
+ if (a.length !== 3) throw new Error(`Named callout must have three arguments "${a}"`);
494
+ if (typeof r == "string" && !/^[A-Za-z_]\w*$/.test(r)) throw new Error(`Named callout argument one must be a tag or number "${r}"`);
495
+ if (typeof i == "number" || !/^(?:[<>!=]=|[<>])$/.test(i)) throw new Error(`Named callout argument two must be '==', '!=', '>', '<', '>=', or '<=' "${i}"`);
496
+ if (typeof l == "string" && !/^[A-Za-z_]\w*$/.test(l)) throw new Error(`Named callout argument three must be a tag or number "${l}"`);
497
+ break;
498
+ case "custom": throw new Error(`Undefined callout name "${t}"`);
499
+ default: throw new Error(`Unexpected named callout kind "${c}"`);
500
+ }
501
+ return D$1(c, o ?? null, s?.split(",") ?? null, e);
502
+ }
503
+ function O$1(e) {
504
+ let n = null, t, o;
505
+ if (e[0] === "{") {
506
+ const { minStr: s, maxStr: a } = /^\{(?<minStr>\d*)(?:,(?<maxStr>\d*))?/.exec(e).groups, r = 1e5;
507
+ if (+s > r || a && +a > r) throw new Error("Quantifier value unsupported in Oniguruma");
508
+ if (t = +s, o = a === void 0 ? +s : a === "" ? Infinity : +a, t > o && (n = "possessive", [t, o] = [o, t]), e.endsWith("?")) {
509
+ if (n === "possessive") throw new Error("Unsupported possessive interval quantifier chain with \"?\"");
510
+ n = "lazy";
511
+ } else n || (n = "greedy");
512
+ } else t = e[0] === "+" ? 1 : 0, o = e[0] === "?" ? 1 : Infinity, n = e[1] === "+" ? "possessive" : e[1] === "?" ? "lazy" : "greedy";
513
+ return _$1(n, t, o, e);
514
+ }
515
+ function q(e) {
516
+ const n = e[1].toLowerCase();
517
+ return k$1({
518
+ d: "digit",
519
+ h: "hex",
520
+ s: "space",
521
+ w: "word"
522
+ }[n], e, { negate: e[1] !== n });
523
+ }
524
+ function V$1(e) {
525
+ const { p: n, neg: t, value: o } = /^\\(?<p>[pP])\{(?<neg>\^?)(?<value>[^}]+)/.exec(e).groups;
526
+ return k$1("property", e, {
527
+ value: o,
528
+ negate: n === "P" && !t || n === "p" && !!t
529
+ });
530
+ }
531
+ function v(e) {
532
+ const n = {};
533
+ return e.includes("i") && (n.ignoreCase = !0), e.includes("m") && (n.dotAll = !0), e.includes("x") && (n.extended = !0), Object.keys(n).length ? n : null;
534
+ }
535
+ function Y(e) {
536
+ const n = {
537
+ ignoreCase: !1,
538
+ dotAll: !1,
539
+ extended: !1,
540
+ digitIsAscii: !1,
541
+ posixIsAscii: !1,
542
+ spaceIsAscii: !1,
543
+ wordIsAscii: !1,
544
+ textSegmentMode: null
545
+ };
546
+ for (let t = 0; t < e.length; t++) {
547
+ const o = e[t];
548
+ if (!"imxDPSWy".includes(o)) throw new Error(`Invalid flag "${o}"`);
549
+ if (o === "y") {
550
+ if (!/^y{[gw]}/.test(e.slice(t))) throw new Error("Invalid or unspecified flag \"y\" mode");
551
+ n.textSegmentMode = e[t + 2] === "g" ? "grapheme" : "word", t += 3;
552
+ continue;
553
+ }
554
+ n[{
555
+ i: "ignoreCase",
556
+ m: "dotAll",
557
+ x: "extended",
558
+ D: "digitIsAscii",
559
+ P: "posixIsAscii",
560
+ S: "spaceIsAscii",
561
+ W: "wordIsAscii"
562
+ }[o]] = !0;
563
+ }
564
+ return n;
565
+ }
566
+ function J$1(e) {
567
+ if (/^(?:\\u(?!\p{AHex}{4})|\\x(?!\p{AHex}{1,2}|\{\p{AHex}{1,8}\}))/u.test(e)) throw new Error(`Incomplete or invalid escape "${e}"`);
568
+ const n = e[2] === "{" ? /^\\x\{\s*(?<hex>\p{AHex}+)/u.exec(e).groups.hex : e.slice(2);
569
+ return parseInt(n, 16);
570
+ }
571
+ function ee$1(e, n) {
572
+ const { raw: t, inCharClass: o } = e, s = t.slice(1);
573
+ if (!o && (s !== "0" && s.length === 1 || s[0] !== "0" && +s <= n)) return [A$1(t)];
574
+ const a = [], r = s.match(/^[0-7]+|\d/g);
575
+ for (let i = 0; i < r.length; i++) {
576
+ const l = r[i];
577
+ let c;
578
+ if (i === 0 && l !== "8" && l !== "9") {
579
+ if (c = parseInt(l, 8), c > 127) throw new Error(o$1`Octal encoded byte above 177 unsupported "${t}"`);
580
+ } else c = r$2(l);
581
+ a.push(d(c, (i === 0 ? "\\" : "") + l));
582
+ }
583
+ return a;
584
+ }
585
+ function te$1(e) {
586
+ const n = [], t = new RegExp(y$1, "gy");
587
+ let o;
588
+ for (; o = t.exec(e);) {
589
+ const s = o[0];
590
+ if (s[0] === "{") {
591
+ const a = /^\{(?<min>\d+),(?<max>\d+)\}\??$/.exec(s);
592
+ if (a) {
593
+ const { min: r, max: i } = a.groups;
594
+ if (+r > +i && s.endsWith("?")) {
595
+ t.lastIndex--, n.push(O$1(s.slice(0, -1)));
596
+ continue;
597
+ }
598
+ }
599
+ }
600
+ n.push(O$1(s));
601
+ }
602
+ return n;
603
+ }
604
+ //#endregion
605
+ //#region ../../node_modules/.pnpm/oniguruma-parser@0.12.2/node_modules/oniguruma-parser/dist/parser/node-utils.js
606
+ function o(e, t) {
607
+ if (!Array.isArray(e.body)) throw new Error("Expected node with body array");
608
+ if (e.body.length !== 1) return !1;
609
+ const r = e.body[0];
610
+ return !t || Object.keys(t).every((n) => t[n] === r[n]);
611
+ }
612
+ function s(e) {
613
+ return y.has(e.type);
614
+ }
615
+ var y = /* @__PURE__ */ new Set([
616
+ "AbsenceFunction",
617
+ "Backreference",
618
+ "CapturingGroup",
619
+ "Character",
620
+ "CharacterClass",
621
+ "CharacterSet",
622
+ "Group",
623
+ "Quantifier",
624
+ "Subroutine"
625
+ ]);
626
+ //#endregion
627
+ //#region ../../node_modules/.pnpm/oniguruma-parser@0.12.2/node_modules/oniguruma-parser/dist/parser/parse.js
628
+ function J(e, r = {}) {
629
+ const n = {
630
+ flags: "",
631
+ normalizeUnknownPropertyNames: !1,
632
+ skipBackrefValidation: !1,
633
+ skipLookbehindValidation: !1,
634
+ skipPropertyNameValidation: !1,
635
+ unicodePropertyMap: null,
636
+ ...r,
637
+ rules: {
638
+ captureGroup: !1,
639
+ singleline: !1,
640
+ ...r.rules
641
+ }
642
+ }, o = M$1(e, {
643
+ flags: n.flags,
644
+ rules: {
645
+ captureGroup: n.rules.captureGroup,
646
+ singleline: n.rules.singleline
647
+ }
648
+ }), i = (p, N) => {
649
+ const u = o.tokens[t.nextIndex];
650
+ switch (t.parent = p, t.nextIndex++, u.type) {
651
+ case "Alternator": return b();
652
+ case "Assertion": return W(u);
653
+ case "Backreference": return X(u, t);
654
+ case "Character": return m(u.value, { useLastValid: !!N.isCheckingRangeEnd });
655
+ case "CharacterClassHyphen": return ee(u, t, N);
656
+ case "CharacterClassOpen": return re(u, t, N);
657
+ case "CharacterSet": return ne(u, t);
658
+ case "Directive": return I(u.kind, { flags: u.flags });
659
+ case "GroupOpen": return te(u, t, N);
660
+ case "NamedCallout": return U(u.kind, u.tag, u.arguments);
661
+ case "Quantifier": return oe(u, t);
662
+ case "Subroutine": return ae(u, t);
663
+ default: throw new Error(`Unexpected token type "${u.type}"`);
664
+ }
665
+ }, t = {
666
+ capturingGroups: [],
667
+ hasNumberedRef: !1,
668
+ namedGroupsByName: /* @__PURE__ */ new Map(),
669
+ nextIndex: 0,
670
+ normalizeUnknownPropertyNames: n.normalizeUnknownPropertyNames,
671
+ parent: null,
672
+ skipBackrefValidation: n.skipBackrefValidation,
673
+ skipLookbehindValidation: n.skipLookbehindValidation,
674
+ skipPropertyNameValidation: n.skipPropertyNameValidation,
675
+ subroutines: [],
676
+ tokens: o.tokens,
677
+ unicodePropertyMap: n.unicodePropertyMap,
678
+ walk: i
679
+ }, d = B(T(o.flags));
680
+ let s = d.body[0];
681
+ for (; t.nextIndex < o.tokens.length;) {
682
+ const p = i(s, {});
683
+ p.type === "Alternative" ? (d.body.push(p), s = p) : s.body.push(p);
684
+ }
685
+ const { capturingGroups: a, hasNumberedRef: l, namedGroupsByName: c, subroutines: f } = t;
686
+ if (l && c.size && !n.rules.captureGroup) throw new Error("Numbered backref/subroutine not allowed when using named capture");
687
+ for (const { ref: p } of f) if (typeof p == "number") {
688
+ if (p > a.length) throw new Error("Subroutine uses a group number that's not defined");
689
+ p && (a[p - 1].isSubroutined = !0);
690
+ } else if (c.has(p)) {
691
+ if (c.get(p).length > 1) throw new Error(o$1`Subroutine uses a duplicate group name "\g<${p}>"`);
692
+ c.get(p)[0].isSubroutined = !0;
693
+ } else throw new Error(o$1`Subroutine uses a group name that's not defined "\g<${p}>"`);
694
+ return d;
695
+ }
696
+ function W({ kind: e }) {
697
+ return F(u({
698
+ "^": "line_start",
699
+ $: "line_end",
700
+ "\\A": "string_start",
701
+ "\\b": "word_boundary",
702
+ "\\B": "word_boundary",
703
+ "\\G": "search_start",
704
+ "\\y": "text_segment_boundary",
705
+ "\\Y": "text_segment_boundary",
706
+ "\\z": "string_end",
707
+ "\\Z": "string_end_newline"
708
+ }[e], `Unexpected assertion kind "${e}"`), { negate: e === o$1`\B` || e === o$1`\Y` });
709
+ }
710
+ function X({ raw: e }, r) {
711
+ const n = /^\\k[<']/.test(e), o = n ? e.slice(3, -1) : e.slice(1), i = (t, d = !1) => {
712
+ const s = r.capturingGroups.length;
713
+ let a = !1;
714
+ if (t > s) if (r.skipBackrefValidation) a = !0;
715
+ else throw new Error(`Not enough capturing groups defined to the left "${e}"`);
716
+ return r.hasNumberedRef = !0, k(d ? s + 1 - t : t, { orphan: a });
717
+ };
718
+ if (n) {
719
+ const t = /^(?<sign>-?)0*(?<num>[1-9]\d*)$/.exec(o);
720
+ if (t) return i(+t.groups.num, !!t.groups.sign);
721
+ if (/[-+]/.test(o)) throw new Error(`Invalid backref name "${e}"`);
722
+ if (!r.namedGroupsByName.has(o)) throw new Error(`Group name not defined to the left "${e}"`);
723
+ return k(o);
724
+ }
725
+ return i(+o);
726
+ }
727
+ function ee(e, r, n) {
728
+ const { tokens: o, walk: i } = r, t = r.parent, d = t.body.at(-1), s = o[r.nextIndex];
729
+ if (!n.isCheckingRangeEnd && d && d.type !== "CharacterClass" && d.type !== "CharacterClassRange" && s && s.type !== "CharacterClassOpen" && s.type !== "CharacterClassClose" && s.type !== "CharacterClassIntersector") {
730
+ const a = i(t, {
731
+ ...n,
732
+ isCheckingRangeEnd: !0
733
+ });
734
+ if (d.type === "Character" && a.type === "Character") return t.body.pop(), L(d, a);
735
+ throw new Error("Invalid character class range");
736
+ }
737
+ return m(r$2("-"));
738
+ }
739
+ function re({ negate: e }, r, n) {
740
+ const { tokens: o, walk: i } = r, t = [C()], d = o[r.nextIndex];
741
+ let s = z(d);
742
+ for (; s.type !== "CharacterClassClose";) {
743
+ if (s.type === "CharacterClassIntersector") t.push(C()), r.nextIndex++;
744
+ else {
745
+ const l = t.at(-1);
746
+ l.body.push(i(l, n));
747
+ }
748
+ s = z(o[r.nextIndex], d);
749
+ }
750
+ const a = C({ negate: e });
751
+ return t.length === 1 ? a.body = t[0].body : (a.kind = "intersection", a.body = t.map((l) => l.body.length === 1 ? l.body[0] : l)), r.nextIndex++, a;
752
+ }
753
+ function ne({ kind: e, negate: r, value: n }, o) {
754
+ const { normalizeUnknownPropertyNames: i$1, skipPropertyNameValidation: t, unicodePropertyMap: d } = o;
755
+ if (e === "property") {
756
+ const s = w(n);
757
+ if (i.has(s) && !d?.has(s)) e = "posix", n = s;
758
+ else return Q(n, {
759
+ negate: r,
760
+ normalizeUnknownPropertyNames: i$1,
761
+ skipPropertyNameValidation: t,
762
+ unicodePropertyMap: d
763
+ });
764
+ }
765
+ return e === "posix" ? R(n, { negate: r }) : E(e, { negate: r });
766
+ }
767
+ function te(e, r, n) {
768
+ const { tokens: o, capturingGroups: i, namedGroupsByName: t, skipLookbehindValidation: d, walk: s } = r, a = ie(e), l = a.type === "AbsenceFunction", c = $(a), f = c && a.negate;
769
+ if (a.type === "CapturingGroup" && (i.push(a), a.name && l$1(t, a.name, []).push(a)), l && n.isInAbsenceFunction) throw new Error("Nested absence function not supported by Oniguruma");
770
+ let p = D(o[r.nextIndex]);
771
+ for (; p.type !== "GroupClose";) {
772
+ if (p.type === "Alternator") a.body.push(b()), r.nextIndex++;
773
+ else {
774
+ const N = a.body.at(-1), u = s(N, {
775
+ ...n,
776
+ isInAbsenceFunction: n.isInAbsenceFunction || l,
777
+ isInLookbehind: n.isInLookbehind || c,
778
+ isInNegLookbehind: n.isInNegLookbehind || f
779
+ });
780
+ if (N.body.push(u), (c || n.isInLookbehind) && !d) {
781
+ const v = "Lookbehind includes a pattern not allowed by Oniguruma";
782
+ if (f || n.isInNegLookbehind) {
783
+ if (M(u) || u.type === "CapturingGroup") throw new Error(v);
784
+ } else if (M(u) || $(u) && u.negate) throw new Error(v);
785
+ }
786
+ }
787
+ p = D(o[r.nextIndex]);
788
+ }
789
+ return r.nextIndex++, a;
790
+ }
791
+ function oe({ kind: e, min: r, max: n }, o) {
792
+ const i = o.parent, t = i.body.at(-1);
793
+ if (!t || !s(t)) throw new Error("Quantifier requires a repeatable token");
794
+ const d = _(e, r, n, t);
795
+ return i.body.pop(), d;
796
+ }
797
+ function ae({ raw: e }, r) {
798
+ const { capturingGroups: n, subroutines: o } = r;
799
+ let i = e.slice(3, -1);
800
+ const t = /^(?<sign>[-+]?)0*(?<num>[1-9]\d*)$/.exec(i);
801
+ if (t) {
802
+ const s = +t.groups.num, a = n.length;
803
+ if (r.hasNumberedRef = !0, i = {
804
+ "": s,
805
+ "+": a + s,
806
+ "-": a + 1 - s
807
+ }[t.groups.sign], i < 1) throw new Error("Invalid subroutine number");
808
+ } else i === "0" && (i = 0);
809
+ const d = O(i);
810
+ return o.push(d), d;
811
+ }
812
+ function G(e, r) {
813
+ if (e !== "repeater") throw new Error(`Unexpected absence function kind "${e}"`);
814
+ return {
815
+ type: "AbsenceFunction",
816
+ kind: e,
817
+ body: h(r?.body)
818
+ };
819
+ }
820
+ function b(e) {
821
+ return {
822
+ type: "Alternative",
823
+ body: V(e?.body)
824
+ };
825
+ }
826
+ function F(e, r) {
827
+ const n = {
828
+ type: "Assertion",
829
+ kind: e
830
+ };
831
+ return (e === "word_boundary" || e === "text_segment_boundary") && (n.negate = !!r?.negate), n;
832
+ }
833
+ function k(e, r) {
834
+ const n = !!r?.orphan;
835
+ return {
836
+ type: "Backreference",
837
+ ref: e,
838
+ ...n && { orphan: n }
839
+ };
840
+ }
841
+ function P(e, r) {
842
+ const n = {
843
+ name: void 0,
844
+ isSubroutined: !1,
845
+ ...r
846
+ };
847
+ if (n.name !== void 0 && !se(n.name)) throw new Error(`Group name "${n.name}" invalid in Oniguruma`);
848
+ return {
849
+ type: "CapturingGroup",
850
+ number: e,
851
+ ...n.name && { name: n.name },
852
+ ...n.isSubroutined && { isSubroutined: n.isSubroutined },
853
+ body: h(r?.body)
854
+ };
855
+ }
856
+ function m(e, r) {
857
+ const n = {
858
+ useLastValid: !1,
859
+ ...r
860
+ };
861
+ if (e > 1114111) {
862
+ const o = e.toString(16);
863
+ if (n.useLastValid) e = 1114111;
864
+ else throw e > 1310719 ? /* @__PURE__ */ new Error(`Invalid code point out of range "\\x{${o}}"`) : /* @__PURE__ */ new Error(`Invalid code point out of range in JS "\\x{${o}}"`);
865
+ }
866
+ return {
867
+ type: "Character",
868
+ value: e
869
+ };
870
+ }
871
+ function C(e) {
872
+ const r = {
873
+ kind: "union",
874
+ negate: !1,
875
+ ...e
876
+ };
877
+ return {
878
+ type: "CharacterClass",
879
+ kind: r.kind,
880
+ negate: r.negate,
881
+ body: V(e?.body)
882
+ };
883
+ }
884
+ function L(e, r) {
885
+ if (r.value < e.value) throw new Error("Character class range out of order");
886
+ return {
887
+ type: "CharacterClassRange",
888
+ min: e,
889
+ max: r
890
+ };
891
+ }
892
+ function E(e, r) {
893
+ const n = !!r?.negate, o = {
894
+ type: "CharacterSet",
895
+ kind: e
896
+ };
897
+ return (e === "digit" || e === "hex" || e === "newline" || e === "space" || e === "word") && (o.negate = n), (e === "text_segment" || e === "newline" && !n) && (o.variableLength = !0), o;
898
+ }
899
+ function I(e, r = {}) {
900
+ if (e === "keep") return {
901
+ type: "Directive",
902
+ kind: e
903
+ };
904
+ if (e === "flags") return {
905
+ type: "Directive",
906
+ kind: e,
907
+ flags: u(r.flags)
908
+ };
909
+ throw new Error(`Unexpected directive kind "${e}"`);
910
+ }
911
+ function T(e) {
912
+ return {
913
+ type: "Flags",
914
+ ...e
915
+ };
916
+ }
917
+ function A(e) {
918
+ const r = e?.atomic, n = e?.flags;
919
+ if (r && n) throw new Error("Atomic group cannot have flags");
920
+ return {
921
+ type: "Group",
922
+ ...r && { atomic: r },
923
+ ...n && { flags: n },
924
+ body: h(e?.body)
925
+ };
926
+ }
927
+ function K(e) {
928
+ const r = {
929
+ behind: !1,
930
+ negate: !1,
931
+ ...e
932
+ };
933
+ return {
934
+ type: "LookaroundAssertion",
935
+ kind: r.behind ? "lookbehind" : "lookahead",
936
+ negate: r.negate,
937
+ body: h(e?.body)
938
+ };
939
+ }
940
+ function U(e, r, n) {
941
+ return {
942
+ type: "NamedCallout",
943
+ kind: e,
944
+ tag: r,
945
+ arguments: n
946
+ };
947
+ }
948
+ function R(e, r) {
949
+ const n = !!r?.negate;
950
+ if (!i.has(e)) throw new Error(`Invalid POSIX class "${e}"`);
951
+ return {
952
+ type: "CharacterSet",
953
+ kind: "posix",
954
+ value: e,
955
+ negate: n
956
+ };
957
+ }
958
+ function _(e, r, n, o) {
959
+ if (r > n) throw new Error("Invalid reversed quantifier range");
960
+ return {
961
+ type: "Quantifier",
962
+ kind: e,
963
+ min: r,
964
+ max: n,
965
+ body: o
966
+ };
967
+ }
968
+ function B(e, r) {
969
+ return {
970
+ type: "Regex",
971
+ body: h(r?.body),
972
+ flags: e
973
+ };
974
+ }
975
+ function O(e) {
976
+ return {
977
+ type: "Subroutine",
978
+ ref: e
979
+ };
980
+ }
981
+ function Q(e, r) {
982
+ const n = {
983
+ negate: !1,
984
+ normalizeUnknownPropertyNames: !1,
985
+ skipPropertyNameValidation: !1,
986
+ unicodePropertyMap: null,
987
+ ...r
988
+ };
989
+ let o = n.unicodePropertyMap?.get(w(e));
990
+ if (!o) {
991
+ if (n.normalizeUnknownPropertyNames) o = de(e);
992
+ else if (n.unicodePropertyMap && !n.skipPropertyNameValidation) throw new Error(o$1`Invalid Unicode property "\p{${e}}"`);
993
+ }
994
+ return {
995
+ type: "CharacterSet",
996
+ kind: "property",
997
+ value: o ?? e,
998
+ negate: n.negate
999
+ };
1000
+ }
1001
+ function ie({ flags: e, kind: r, name: n, negate: o, number: i }) {
1002
+ switch (r) {
1003
+ case "absence_repeater": return G("repeater");
1004
+ case "atomic": return A({ atomic: !0 });
1005
+ case "capturing": return P(i, { name: n });
1006
+ case "group": return A({ flags: e });
1007
+ case "lookahead":
1008
+ case "lookbehind": return K({
1009
+ behind: r === "lookbehind",
1010
+ negate: o
1011
+ });
1012
+ default: throw new Error(`Unexpected group kind "${r}"`);
1013
+ }
1014
+ }
1015
+ function h(e) {
1016
+ if (e === void 0) e = [b()];
1017
+ 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");
1018
+ return e;
1019
+ }
1020
+ function V(e) {
1021
+ if (e === void 0) e = [];
1022
+ else if (!Array.isArray(e) || !e.every((r) => !!r.type)) throw new Error("Invalid body; expected array of nodes");
1023
+ return e;
1024
+ }
1025
+ function M(e) {
1026
+ return e.type === "LookaroundAssertion" && e.kind === "lookahead";
1027
+ }
1028
+ function $(e) {
1029
+ return e.type === "LookaroundAssertion" && e.kind === "lookbehind";
1030
+ }
1031
+ function se(e) {
1032
+ return /^[\p{Alpha}\p{Pc}][^)]*$/u.test(e);
1033
+ }
1034
+ function de(e) {
1035
+ 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());
1036
+ }
1037
+ function w(e) {
1038
+ return e.replace(/[- _]+/g, "").toLowerCase();
1039
+ }
1040
+ function z(e, r) {
1041
+ const n = r;
1042
+ return u(e, `Unclosed character class${n?.type === "Character" && n.value === 93 && n.raw === "]" ? " (started with \"]\")" : ""}`);
1043
+ }
1044
+ function D(e) {
1045
+ return u(e, "Unclosed group");
1046
+ }
1047
+ //#endregion
1048
+ //#region ../../node_modules/.pnpm/oniguruma-parser@0.12.2/node_modules/oniguruma-parser/dist/traverser/traverse.js
1049
+ function S(a, v, N = null) {
1050
+ function b(e, s) {
1051
+ for (let t = 0; t < e.length; t++) {
1052
+ const r = n(e[t], s, t, e);
1053
+ t = Math.max(-1, t + r);
1054
+ }
1055
+ }
1056
+ function n(e, s = null, t = null, r = null) {
1057
+ let i = 0, c = !1;
1058
+ const d = {
1059
+ node: e,
1060
+ parent: s,
1061
+ key: t,
1062
+ container: r,
1063
+ root: a,
1064
+ remove() {
1065
+ x(r).splice(Math.max(0, l(t) + i), 1), i--, c = !0;
1066
+ },
1067
+ removeAllNextSiblings() {
1068
+ return x(r).splice(l(t) + 1);
1069
+ },
1070
+ removeAllPrevSiblings() {
1071
+ const o = l(t) + i;
1072
+ return i -= o, x(r).splice(0, Math.max(0, o));
1073
+ },
1074
+ replaceWith(o, m = {}) {
1075
+ const y = !!m.traverse;
1076
+ r ? r[Math.max(0, l(t) + i)] = o : u(s, "Can't replace root node")[t] = o, y && n(o, s, t, r), c = !0;
1077
+ },
1078
+ replaceWithMultiple(o, m = {}) {
1079
+ const y = !!m.traverse;
1080
+ if (x(r).splice(Math.max(0, l(t) + i), 1, ...o), i += o.length - 1, y) {
1081
+ let g = 0;
1082
+ for (let p = 0; p < o.length; p++) g += n(o[p], s, l(t) + p + g, r);
1083
+ }
1084
+ c = !0;
1085
+ },
1086
+ skip() {
1087
+ c = !0;
1088
+ }
1089
+ }, { type: f } = e, u$1 = v["*"], h = v[f], R = typeof u$1 == "function" ? u$1 : u$1?.enter, P = typeof h == "function" ? h : h?.enter;
1090
+ if (R?.(d, N), P?.(d, N), !c) switch (f) {
1091
+ case "AbsenceFunction":
1092
+ case "Alternative":
1093
+ case "CapturingGroup":
1094
+ case "CharacterClass":
1095
+ case "Group":
1096
+ case "LookaroundAssertion":
1097
+ b(e.body, e);
1098
+ break;
1099
+ case "Assertion":
1100
+ case "Backreference":
1101
+ case "Character":
1102
+ case "CharacterSet":
1103
+ case "Directive":
1104
+ case "Flags":
1105
+ case "NamedCallout":
1106
+ case "Subroutine": break;
1107
+ case "CharacterClassRange":
1108
+ n(e.min, e, "min"), n(e.max, e, "max");
1109
+ break;
1110
+ case "Quantifier":
1111
+ n(e.body, e, "body");
1112
+ break;
1113
+ case "Regex":
1114
+ b(e.body, e), n(e.flags, e, "flags");
1115
+ break;
1116
+ default: throw new Error(`Unexpected node type "${f}"`);
1117
+ }
1118
+ return h?.exit?.(d, N), u$1?.exit?.(d, N), i;
1119
+ }
1120
+ return n(a), a;
1121
+ }
1122
+ function x(a) {
1123
+ if (!Array.isArray(a)) throw new Error("Container expected");
1124
+ return a;
1125
+ }
1126
+ function l(a) {
1127
+ if (typeof a != "number") throw new Error("Numeric key expected");
1128
+ return a;
1129
+ }
1130
+ //#endregion
1131
+ //#region ../../node_modules/.pnpm/regex@6.1.0/node_modules/regex/src/utils-internals.js
1132
+ var noncapturingDelim = String.raw`\(\?(?:[:=!>A-Za-z\-]|<[=!]|\(DEFINE\))`;
1133
+ /**
1134
+ Updates the array in place by incrementing each value greater than or equal to the threshold.
1135
+ @param {Array<number>} arr
1136
+ @param {number} threshold
1137
+ */
1138
+ function incrementIfAtLeast$1(arr, threshold) {
1139
+ for (let i = 0; i < arr.length; i++) if (arr[i] >= threshold) arr[i]++;
1140
+ }
1141
+ /**
1142
+ @param {string} str
1143
+ @param {number} pos
1144
+ @param {string} oldValue
1145
+ @param {string} newValue
1146
+ @returns {string}
1147
+ */
1148
+ function spliceStr(str, pos, oldValue, newValue) {
1149
+ return str.slice(0, pos) + newValue + str.slice(pos + oldValue.length);
1150
+ }
1151
+ //#endregion
1152
+ //#region ../../node_modules/.pnpm/regex-utilities@2.3.0/node_modules/regex-utilities/src/index.js
1153
+ var Context = Object.freeze({
1154
+ DEFAULT: "DEFAULT",
1155
+ CHAR_CLASS: "CHAR_CLASS"
1156
+ });
1157
+ /**
1158
+ Replaces all unescaped instances of a regex pattern in the given context, using a replacement
1159
+ string or callback.
1160
+
1161
+ Doesn't skip over complete multicharacter tokens (only `\` plus its folowing char) so must be used
1162
+ with knowledge of what's safe to do given regex syntax. Assumes UnicodeSets-mode syntax.
1163
+ @param {string} expression Search target
1164
+ @param {string} needle Search as a regex pattern, with flags `su` applied
1165
+ @param {string | (match: RegExpExecArray, details: {
1166
+ context: 'DEFAULT' | 'CHAR_CLASS';
1167
+ negated: boolean;
1168
+ }) => string} replacement
1169
+ @param {'DEFAULT' | 'CHAR_CLASS'} [context] All contexts if not specified
1170
+ @returns {string} Updated expression
1171
+ @example
1172
+ const str = '.\\.\\\\.[[\\.].].';
1173
+ replaceUnescaped(str, '\\.', '@');
1174
+ // → '@\\.\\\\@[[\\.]@]@'
1175
+ replaceUnescaped(str, '\\.', '@', Context.DEFAULT);
1176
+ // → '@\\.\\\\@[[\\.].]@'
1177
+ replaceUnescaped(str, '\\.', '@', Context.CHAR_CLASS);
1178
+ // → '.\\.\\\\.[[\\.]@].'
1179
+ */
1180
+ function replaceUnescaped(expression, needle, replacement, context) {
1181
+ const re = new RegExp(String.raw`${needle}|(?<$skip>\[\^?|\\?.)`, "gsu");
1182
+ const negated = [false];
1183
+ let numCharClassesOpen = 0;
1184
+ let result = "";
1185
+ for (const match of expression.matchAll(re)) {
1186
+ const { 0: m, groups: { $skip } } = match;
1187
+ if (!$skip && (!context || context === Context.DEFAULT === !numCharClassesOpen)) {
1188
+ if (replacement instanceof Function) result += replacement(match, {
1189
+ context: numCharClassesOpen ? Context.CHAR_CLASS : Context.DEFAULT,
1190
+ negated: negated[negated.length - 1]
1191
+ });
1192
+ else result += replacement;
1193
+ continue;
1194
+ }
1195
+ if (m[0] === "[") {
1196
+ numCharClassesOpen++;
1197
+ negated.push(m[1] === "^");
1198
+ } else if (m === "]" && numCharClassesOpen) {
1199
+ numCharClassesOpen--;
1200
+ negated.pop();
1201
+ }
1202
+ result += m;
1203
+ }
1204
+ return result;
1205
+ }
1206
+ /**
1207
+ Runs a callback for each unescaped instance of a regex pattern in the given context.
1208
+
1209
+ Doesn't skip over complete multicharacter tokens (only `\` plus its folowing char) so must be used
1210
+ with knowledge of what's safe to do given regex syntax. Assumes UnicodeSets-mode syntax.
1211
+ @param {string} expression Search target
1212
+ @param {string} needle Search as a regex pattern, with flags `su` applied
1213
+ @param {(match: RegExpExecArray, details: {
1214
+ context: 'DEFAULT' | 'CHAR_CLASS';
1215
+ negated: boolean;
1216
+ }) => void} callback
1217
+ @param {'DEFAULT' | 'CHAR_CLASS'} [context] All contexts if not specified
1218
+ */
1219
+ function forEachUnescaped(expression, needle, callback, context) {
1220
+ replaceUnescaped(expression, needle, callback, context);
1221
+ }
1222
+ /**
1223
+ Returns a match object for the first unescaped instance of a regex pattern in the given context, or
1224
+ `null`.
1225
+
1226
+ Doesn't skip over complete multicharacter tokens (only `\` plus its folowing char) so must be used
1227
+ with knowledge of what's safe to do given regex syntax. Assumes UnicodeSets-mode syntax.
1228
+ @param {string} expression Search target
1229
+ @param {string} needle Search as a regex pattern, with flags `su` applied
1230
+ @param {number} [pos] Offset to start the search
1231
+ @param {'DEFAULT' | 'CHAR_CLASS'} [context] All contexts if not specified
1232
+ @returns {RegExpExecArray | null}
1233
+ */
1234
+ function execUnescaped(expression, needle, pos = 0, context) {
1235
+ if (!new RegExp(needle, "su").test(expression)) return null;
1236
+ const re = new RegExp(`${needle}|(?<$skip>\\\\?.)`, "gsu");
1237
+ re.lastIndex = pos;
1238
+ let numCharClassesOpen = 0;
1239
+ let match;
1240
+ while (match = re.exec(expression)) {
1241
+ const { 0: m, groups: { $skip } } = match;
1242
+ if (!$skip && (!context || context === Context.DEFAULT === !numCharClassesOpen)) return match;
1243
+ if (m === "[") numCharClassesOpen++;
1244
+ else if (m === "]" && numCharClassesOpen) numCharClassesOpen--;
1245
+ if (re.lastIndex == match.index) re.lastIndex++;
1246
+ }
1247
+ return null;
1248
+ }
1249
+ /**
1250
+ Checks whether an unescaped instance of a regex pattern appears in the given context.
1251
+
1252
+ Doesn't skip over complete multicharacter tokens (only `\` plus its folowing char) so must be used
1253
+ with knowledge of what's safe to do given regex syntax. Assumes UnicodeSets-mode syntax.
1254
+ @param {string} expression Search target
1255
+ @param {string} needle Search as a regex pattern, with flags `su` applied
1256
+ @param {'DEFAULT' | 'CHAR_CLASS'} [context] All contexts if not specified
1257
+ @returns {boolean} Whether the pattern was found
1258
+ */
1259
+ function hasUnescaped(expression, needle, context) {
1260
+ return !!execUnescaped(expression, needle, 0, context);
1261
+ }
1262
+ /**
1263
+ Extracts the full contents of a group (subpattern) from the given expression, accounting for
1264
+ escaped characters, nested groups, and character classes. The group is identified by the position
1265
+ where its contents start (the string index just after the group's opening delimiter). Returns the
1266
+ rest of the string if the group is unclosed.
1267
+
1268
+ Assumes UnicodeSets-mode syntax.
1269
+ @param {string} expression Search target
1270
+ @param {number} contentsStartPos
1271
+ @returns {string}
1272
+ */
1273
+ function getGroupContents(expression, contentsStartPos) {
1274
+ const token = /\\?./gsu;
1275
+ token.lastIndex = contentsStartPos;
1276
+ let contentsEndPos = expression.length;
1277
+ let numCharClassesOpen = 0;
1278
+ let numGroupsOpen = 1;
1279
+ let match;
1280
+ while (match = token.exec(expression)) {
1281
+ const [m] = match;
1282
+ if (m === "[") numCharClassesOpen++;
1283
+ else if (!numCharClassesOpen) {
1284
+ if (m === "(") numGroupsOpen++;
1285
+ else if (m === ")") {
1286
+ numGroupsOpen--;
1287
+ if (!numGroupsOpen) {
1288
+ contentsEndPos = match.index;
1289
+ break;
1290
+ }
1291
+ }
1292
+ } else if (m === "]") numCharClassesOpen--;
1293
+ }
1294
+ return expression.slice(contentsStartPos, contentsEndPos);
1295
+ }
1296
+ //#endregion
1297
+ //#region ../../node_modules/.pnpm/regex@6.1.0/node_modules/regex/src/atomic.js
1298
+ /**
1299
+ @import {PluginData, PluginResult} from './regex.js';
1300
+ */
1301
+ var atomicPluginToken = new RegExp(String.raw`(?<noncapturingStart>${noncapturingDelim})|(?<capturingStart>\((?:\?<[^>]+>)?)|\\?.`, "gsu");
1302
+ /**
1303
+ Apply transformations for atomic groups: `(?>…)`.
1304
+ @param {string} expression
1305
+ @param {PluginData} [data]
1306
+ @returns {Required<PluginResult>}
1307
+ */
1308
+ function atomic(expression, data) {
1309
+ const hiddenCaptures = data?.hiddenCaptures ?? [];
1310
+ let captureTransfers = data?.captureTransfers ?? /* @__PURE__ */ new Map();
1311
+ if (!/\(\?>/.test(expression)) return {
1312
+ pattern: expression,
1313
+ captureTransfers,
1314
+ hiddenCaptures
1315
+ };
1316
+ const aGDelim = "(?>";
1317
+ const emulatedAGDelim = "(?:(?=(";
1318
+ const captureNumMap = [0];
1319
+ const addedHiddenCaptures = [];
1320
+ let numCapturesBeforeAG = 0;
1321
+ let numAGs = 0;
1322
+ let aGPos = NaN;
1323
+ let hasProcessedAG;
1324
+ do {
1325
+ hasProcessedAG = false;
1326
+ let numCharClassesOpen = 0;
1327
+ let numGroupsOpenInAG = 0;
1328
+ let inAG = false;
1329
+ let match;
1330
+ atomicPluginToken.lastIndex = Number.isNaN(aGPos) ? 0 : aGPos + 7;
1331
+ while (match = atomicPluginToken.exec(expression)) {
1332
+ const { 0: m, index, groups: { capturingStart, noncapturingStart } } = match;
1333
+ if (m === "[") numCharClassesOpen++;
1334
+ else if (!numCharClassesOpen) {
1335
+ if (m === aGDelim && !inAG) {
1336
+ aGPos = index;
1337
+ inAG = true;
1338
+ } else if (inAG && noncapturingStart) numGroupsOpenInAG++;
1339
+ else if (capturingStart) if (inAG) numGroupsOpenInAG++;
1340
+ else {
1341
+ numCapturesBeforeAG++;
1342
+ captureNumMap.push(numCapturesBeforeAG + numAGs);
1343
+ }
1344
+ else if (m === ")" && inAG) {
1345
+ if (!numGroupsOpenInAG) {
1346
+ numAGs++;
1347
+ const addedCaptureNum = numCapturesBeforeAG + numAGs;
1348
+ expression = `${expression.slice(0, aGPos)}${emulatedAGDelim}${expression.slice(aGPos + 3, index)}))<$$${addedCaptureNum}>)${expression.slice(index + 1)}`;
1349
+ hasProcessedAG = true;
1350
+ addedHiddenCaptures.push(addedCaptureNum);
1351
+ incrementIfAtLeast$1(hiddenCaptures, addedCaptureNum);
1352
+ if (captureTransfers.size) {
1353
+ const newCaptureTransfers = /* @__PURE__ */ new Map();
1354
+ captureTransfers.forEach((from, to) => {
1355
+ newCaptureTransfers.set(to >= addedCaptureNum ? to + 1 : to, from.map((f) => f >= addedCaptureNum ? f + 1 : f));
1356
+ });
1357
+ captureTransfers = newCaptureTransfers;
1358
+ }
1359
+ break;
1360
+ }
1361
+ numGroupsOpenInAG--;
1362
+ }
1363
+ } else if (m === "]") numCharClassesOpen--;
1364
+ }
1365
+ } while (hasProcessedAG);
1366
+ hiddenCaptures.push(...addedHiddenCaptures);
1367
+ expression = replaceUnescaped(expression, String.raw`\\(?<backrefNum>[1-9]\d*)|<\$\$(?<wrappedBackrefNum>\d+)>`, ({ 0: m, groups: { backrefNum, wrappedBackrefNum } }) => {
1368
+ if (backrefNum) {
1369
+ const bNum = +backrefNum;
1370
+ if (bNum > captureNumMap.length - 1) throw new Error(`Backref "${m}" greater than number of captures`);
1371
+ return `\\${captureNumMap[bNum]}`;
1372
+ }
1373
+ return `\\${wrappedBackrefNum}`;
1374
+ }, Context.DEFAULT);
1375
+ return {
1376
+ pattern: expression,
1377
+ captureTransfers,
1378
+ hiddenCaptures
1379
+ };
1380
+ }
1381
+ var baseQuantifier = String.raw`(?:[?*+]|\{\d+(?:,\d*)?\})`;
1382
+ var possessivePluginToken = new RegExp(String.raw`
1383
+ \\(?: \d+
1384
+ | c[A-Za-z]
1385
+ | [gk]<[^>]+>
1386
+ | [pPu]\{[^\}]+\}
1387
+ | u[A-Fa-f\d]{4}
1388
+ | x[A-Fa-f\d]{2}
1389
+ )
1390
+ | \((?: \? (?: [:=!>]
1391
+ | <(?:[=!]|[^>]+>)
1392
+ | [A-Za-z\-]+:
1393
+ | \(DEFINE\)
1394
+ ))?
1395
+ | (?<qBase>${baseQuantifier})(?<qMod>[?+]?)(?<invalidQ>[?*+\{]?)
1396
+ | \\?.
1397
+ `.replace(/\s+/g, ""), "gsu");
1398
+ /**
1399
+ Transform posessive quantifiers into atomic groups. The posessessive quantifiers are:
1400
+ `?+`, `*+`, `++`, `{N}+`, `{N,}+`, `{N,N}+`.
1401
+ This follows Java, PCRE, Perl, and Python.
1402
+ Possessive quantifiers in Oniguruma and Onigmo are only: `?+`, `*+`, `++`.
1403
+ @param {string} expression
1404
+ @returns {PluginResult}
1405
+ */
1406
+ function possessive(expression) {
1407
+ if (!new RegExp(`${baseQuantifier}\\+`).test(expression)) return { pattern: expression };
1408
+ const openGroupIndices = [];
1409
+ let lastGroupIndex = null;
1410
+ let lastCharClassIndex = null;
1411
+ let lastToken = "";
1412
+ let numCharClassesOpen = 0;
1413
+ let match;
1414
+ possessivePluginToken.lastIndex = 0;
1415
+ while (match = possessivePluginToken.exec(expression)) {
1416
+ const { 0: m, index, groups: { qBase, qMod, invalidQ } } = match;
1417
+ if (m === "[") {
1418
+ if (!numCharClassesOpen) lastCharClassIndex = index;
1419
+ numCharClassesOpen++;
1420
+ } else if (m === "]") if (numCharClassesOpen) numCharClassesOpen--;
1421
+ else lastCharClassIndex = null;
1422
+ else if (!numCharClassesOpen) {
1423
+ if (qMod === "+" && lastToken && !lastToken.startsWith("(")) {
1424
+ if (invalidQ) throw new Error(`Invalid quantifier "${m}"`);
1425
+ let charsAdded = -1;
1426
+ if (/^\{\d+\}$/.test(qBase)) expression = spliceStr(expression, index + qBase.length, qMod, "");
1427
+ else {
1428
+ if (lastToken === ")" || lastToken === "]") {
1429
+ const nodeIndex = lastToken === ")" ? lastGroupIndex : lastCharClassIndex;
1430
+ if (nodeIndex === null) throw new Error(`Invalid unmatched "${lastToken}"`);
1431
+ expression = `${expression.slice(0, nodeIndex)}(?>${expression.slice(nodeIndex, index)}${qBase})${expression.slice(index + m.length)}`;
1432
+ } else expression = `${expression.slice(0, index - lastToken.length)}(?>${lastToken}${qBase})${expression.slice(index + m.length)}`;
1433
+ charsAdded += 4;
1434
+ }
1435
+ possessivePluginToken.lastIndex += charsAdded;
1436
+ } else if (m[0] === "(") openGroupIndices.push(index);
1437
+ else if (m === ")") lastGroupIndex = openGroupIndices.length ? openGroupIndices.pop() : null;
1438
+ }
1439
+ lastToken = m;
1440
+ }
1441
+ return { pattern: expression };
1442
+ }
1443
+ //#endregion
1444
+ //#region ../../node_modules/.pnpm/regex-recursion@6.0.2/node_modules/regex-recursion/src/index.js
1445
+ var r$1 = String.raw;
1446
+ var recursiveToken = r$1`\(\?R=(?<rDepth>[^\)]+)\)|${r$1`\\g<(?<gRNameOrNum>[^>&]+)&R=(?<gRDepth>[^>]+)>`}`;
1447
+ var namedCaptureDelim = r$1`\(\?<(?![=!])(?<captureName>[^>]+)>`;
1448
+ var captureDelim = r$1`${namedCaptureDelim}|(?<unnamed>\()(?!\?)`;
1449
+ var token = new RegExp(r$1`${namedCaptureDelim}|${recursiveToken}|\(\?|\\?.`, "gsu");
1450
+ var overlappingRecursionMsg = "Cannot use multiple overlapping recursions";
1451
+ /**
1452
+ @param {string} pattern
1453
+ @param {{
1454
+ flags?: string;
1455
+ captureTransfers?: Map<number, Array<number>>;
1456
+ hiddenCaptures?: Array<number>;
1457
+ mode?: 'plugin' | 'external';
1458
+ }} [data]
1459
+ @returns {{
1460
+ pattern: string;
1461
+ captureTransfers: Map<number, Array<number>>;
1462
+ hiddenCaptures: Array<number>;
1463
+ }}
1464
+ */
1465
+ function recursion(pattern, data) {
1466
+ const { hiddenCaptures, mode } = {
1467
+ hiddenCaptures: [],
1468
+ mode: "plugin",
1469
+ ...data
1470
+ };
1471
+ let captureTransfers = data?.captureTransfers ?? /* @__PURE__ */ new Map();
1472
+ if (!new RegExp(recursiveToken, "su").test(pattern)) return {
1473
+ pattern,
1474
+ captureTransfers,
1475
+ hiddenCaptures
1476
+ };
1477
+ if (mode === "plugin" && hasUnescaped(pattern, r$1`\(\?\(DEFINE\)`, Context.DEFAULT)) throw new Error("DEFINE groups cannot be used with recursion");
1478
+ const addedHiddenCaptures = [];
1479
+ const hasNumberedBackref = hasUnescaped(pattern, r$1`\\[1-9]`, Context.DEFAULT);
1480
+ const groupContentsStartPos = /* @__PURE__ */ new Map();
1481
+ const openGroups = [];
1482
+ let hasRecursed = false;
1483
+ let numCharClassesOpen = 0;
1484
+ let numCapturesPassed = 0;
1485
+ let match;
1486
+ token.lastIndex = 0;
1487
+ while (match = token.exec(pattern)) {
1488
+ const { 0: m, groups: { captureName, rDepth, gRNameOrNum, gRDepth } } = match;
1489
+ if (m === "[") numCharClassesOpen++;
1490
+ else if (!numCharClassesOpen) {
1491
+ if (rDepth) {
1492
+ assertMaxInBounds(rDepth);
1493
+ if (hasRecursed) throw new Error(overlappingRecursionMsg);
1494
+ if (hasNumberedBackref) throw new Error(`${mode === "external" ? "Backrefs" : "Numbered backrefs"} cannot be used with global recursion`);
1495
+ const left = pattern.slice(0, match.index);
1496
+ const right = pattern.slice(token.lastIndex);
1497
+ if (hasUnescaped(right, recursiveToken, Context.DEFAULT)) throw new Error(overlappingRecursionMsg);
1498
+ const reps = +rDepth - 1;
1499
+ pattern = makeRecursive(left, right, reps, false, hiddenCaptures, addedHiddenCaptures, numCapturesPassed);
1500
+ captureTransfers = mapCaptureTransfers(captureTransfers, left, reps, addedHiddenCaptures.length, 0, numCapturesPassed);
1501
+ break;
1502
+ } else if (gRNameOrNum) {
1503
+ assertMaxInBounds(gRDepth);
1504
+ let isWithinReffedGroup = false;
1505
+ for (const g of openGroups) if (g.name === gRNameOrNum || g.num === +gRNameOrNum) {
1506
+ isWithinReffedGroup = true;
1507
+ if (g.hasRecursedWithin) throw new Error(overlappingRecursionMsg);
1508
+ break;
1509
+ }
1510
+ if (!isWithinReffedGroup) throw new Error(r$1`Recursive \g cannot be used outside the referenced group "${mode === "external" ? gRNameOrNum : r$1`\g<${gRNameOrNum}&R=${gRDepth}>`}"`);
1511
+ const startPos = groupContentsStartPos.get(gRNameOrNum);
1512
+ const groupContents = getGroupContents(pattern, startPos);
1513
+ if (hasNumberedBackref && hasUnescaped(groupContents, r$1`${namedCaptureDelim}|\((?!\?)`, Context.DEFAULT)) throw new Error(`${mode === "external" ? "Backrefs" : "Numbered backrefs"} cannot be used with recursion of capturing groups`);
1514
+ const groupContentsLeft = pattern.slice(startPos, match.index);
1515
+ const groupContentsRight = groupContents.slice(groupContentsLeft.length + m.length);
1516
+ const numAddedHiddenCapturesPreExpansion = addedHiddenCaptures.length;
1517
+ const reps = +gRDepth - 1;
1518
+ const expansion = makeRecursive(groupContentsLeft, groupContentsRight, reps, true, hiddenCaptures, addedHiddenCaptures, numCapturesPassed);
1519
+ captureTransfers = mapCaptureTransfers(captureTransfers, groupContentsLeft, reps, addedHiddenCaptures.length - numAddedHiddenCapturesPreExpansion, numAddedHiddenCapturesPreExpansion, numCapturesPassed);
1520
+ pattern = `${pattern.slice(0, startPos)}${expansion}${pattern.slice(startPos + groupContents.length)}`;
1521
+ token.lastIndex += expansion.length - m.length - groupContentsLeft.length - groupContentsRight.length;
1522
+ openGroups.forEach((g) => g.hasRecursedWithin = true);
1523
+ hasRecursed = true;
1524
+ } else if (captureName) {
1525
+ numCapturesPassed++;
1526
+ groupContentsStartPos.set(String(numCapturesPassed), token.lastIndex);
1527
+ groupContentsStartPos.set(captureName, token.lastIndex);
1528
+ openGroups.push({
1529
+ num: numCapturesPassed,
1530
+ name: captureName
1531
+ });
1532
+ } else if (m[0] === "(") {
1533
+ const isUnnamedCapture = m === "(";
1534
+ if (isUnnamedCapture) {
1535
+ numCapturesPassed++;
1536
+ groupContentsStartPos.set(String(numCapturesPassed), token.lastIndex);
1537
+ }
1538
+ openGroups.push(isUnnamedCapture ? { num: numCapturesPassed } : {});
1539
+ } else if (m === ")") openGroups.pop();
1540
+ } else if (m === "]") numCharClassesOpen--;
1541
+ }
1542
+ hiddenCaptures.push(...addedHiddenCaptures);
1543
+ return {
1544
+ pattern,
1545
+ captureTransfers,
1546
+ hiddenCaptures
1547
+ };
1548
+ }
1549
+ /**
1550
+ @param {string} max
1551
+ */
1552
+ function assertMaxInBounds(max) {
1553
+ const errMsg = `Max depth must be integer between 2 and 100; used ${max}`;
1554
+ if (!/^[1-9]\d*$/.test(max)) throw new Error(errMsg);
1555
+ max = +max;
1556
+ if (max < 2 || max > 100) throw new Error(errMsg);
1557
+ }
1558
+ /**
1559
+ @param {string} left
1560
+ @param {string} right
1561
+ @param {number} reps
1562
+ @param {boolean} isSubpattern
1563
+ @param {Array<number>} hiddenCaptures
1564
+ @param {Array<number>} addedHiddenCaptures
1565
+ @param {number} numCapturesPassed
1566
+ @returns {string}
1567
+ */
1568
+ function makeRecursive(left, right, reps, isSubpattern, hiddenCaptures, addedHiddenCaptures, numCapturesPassed) {
1569
+ const namesInRecursed = /* @__PURE__ */ new Set();
1570
+ if (isSubpattern) forEachUnescaped(left + right, namedCaptureDelim, ({ groups: { captureName } }) => {
1571
+ namesInRecursed.add(captureName);
1572
+ }, Context.DEFAULT);
1573
+ const rest = [
1574
+ reps,
1575
+ isSubpattern ? namesInRecursed : null,
1576
+ hiddenCaptures,
1577
+ addedHiddenCaptures,
1578
+ numCapturesPassed
1579
+ ];
1580
+ return `${left}${repeatWithDepth(`(?:${left}`, "forward", ...rest)}(?:)${repeatWithDepth(`${right})`, "backward", ...rest)}${right}`;
1581
+ }
1582
+ /**
1583
+ @param {string} pattern
1584
+ @param {'forward' | 'backward'} direction
1585
+ @param {number} reps
1586
+ @param {Set<string> | null} namesInRecursed
1587
+ @param {Array<number>} hiddenCaptures
1588
+ @param {Array<number>} addedHiddenCaptures
1589
+ @param {number} numCapturesPassed
1590
+ @returns {string}
1591
+ */
1592
+ function repeatWithDepth(pattern, direction, reps, namesInRecursed, hiddenCaptures, addedHiddenCaptures, numCapturesPassed) {
1593
+ const startNum = 2;
1594
+ const getDepthNum = (i) => direction === "forward" ? i + startNum : reps - i + startNum - 1;
1595
+ let result = "";
1596
+ for (let i = 0; i < reps; i++) {
1597
+ const depthNum = getDepthNum(i);
1598
+ result += replaceUnescaped(pattern, r$1`${captureDelim}|\\k<(?<backref>[^>]+)>`, ({ 0: m, groups: { captureName, unnamed, backref } }) => {
1599
+ if (backref && namesInRecursed && !namesInRecursed.has(backref)) return m;
1600
+ const suffix = `_$${depthNum}`;
1601
+ if (unnamed || captureName) {
1602
+ const addedCaptureNum = numCapturesPassed + addedHiddenCaptures.length + 1;
1603
+ addedHiddenCaptures.push(addedCaptureNum);
1604
+ incrementIfAtLeast(hiddenCaptures, addedCaptureNum);
1605
+ return unnamed ? m : `(?<${captureName}${suffix}>`;
1606
+ }
1607
+ return r$1`\k<${backref}${suffix}>`;
1608
+ }, Context.DEFAULT);
1609
+ }
1610
+ return result;
1611
+ }
1612
+ /**
1613
+ Updates the array in place by incrementing each value greater than or equal to the threshold.
1614
+ @param {Array<number>} arr
1615
+ @param {number} threshold
1616
+ */
1617
+ function incrementIfAtLeast(arr, threshold) {
1618
+ for (let i = 0; i < arr.length; i++) if (arr[i] >= threshold) arr[i]++;
1619
+ }
1620
+ /**
1621
+ @param {Map<number, Array<number>>} captureTransfers
1622
+ @param {string} left
1623
+ @param {number} reps
1624
+ @param {number} numCapturesAddedInExpansion
1625
+ @param {number} numAddedHiddenCapturesPreExpansion
1626
+ @param {number} numCapturesPassed
1627
+ @returns {Map<number, Array<number>>}
1628
+ */
1629
+ function mapCaptureTransfers(captureTransfers, left, reps, numCapturesAddedInExpansion, numAddedHiddenCapturesPreExpansion, numCapturesPassed) {
1630
+ if (captureTransfers.size && numCapturesAddedInExpansion) {
1631
+ let numCapturesInLeft = 0;
1632
+ forEachUnescaped(left, captureDelim, () => numCapturesInLeft++, Context.DEFAULT);
1633
+ const recursionDelimCaptureNum = numCapturesPassed - numCapturesInLeft + numAddedHiddenCapturesPreExpansion;
1634
+ const newCaptureTransfers = /* @__PURE__ */ new Map();
1635
+ captureTransfers.forEach((from, to) => {
1636
+ const numCapturesInRight = (numCapturesAddedInExpansion - numCapturesInLeft * reps) / reps;
1637
+ const numCapturesAddedInLeft = numCapturesInLeft * reps;
1638
+ const newTo = to > recursionDelimCaptureNum + numCapturesInLeft ? to + numCapturesAddedInExpansion : to;
1639
+ const newFrom = [];
1640
+ for (const f of from) if (f <= recursionDelimCaptureNum) newFrom.push(f);
1641
+ else if (f > recursionDelimCaptureNum + numCapturesInLeft + numCapturesInRight) newFrom.push(f + numCapturesAddedInExpansion);
1642
+ else if (f <= recursionDelimCaptureNum + numCapturesInLeft) for (let i = 0; i <= reps; i++) newFrom.push(f + numCapturesInLeft * i);
1643
+ else for (let i = 0; i <= reps; i++) newFrom.push(f + numCapturesAddedInLeft + numCapturesInRight * i);
1644
+ newCaptureTransfers.set(newTo, newFrom);
1645
+ });
1646
+ return newCaptureTransfers;
1647
+ }
1648
+ return captureTransfers;
1649
+ }
1650
+ //#endregion
1651
+ //#region ../../node_modules/.pnpm/oniguruma-to-es@4.3.6/node_modules/oniguruma-to-es/dist/esm/index.js
1652
+ var cp = String.fromCodePoint;
1653
+ var r = String.raw;
1654
+ var envFlags = {};
1655
+ var globalRegExp = globalThis.RegExp;
1656
+ envFlags.flagGroups = (() => {
1657
+ try {
1658
+ new globalRegExp("(?i:)");
1659
+ } catch {
1660
+ return false;
1661
+ }
1662
+ return true;
1663
+ })();
1664
+ envFlags.unicodeSets = (() => {
1665
+ try {
1666
+ new globalRegExp("[[]]", "v");
1667
+ } catch {
1668
+ return false;
1669
+ }
1670
+ return true;
1671
+ })();
1672
+ envFlags.bugFlagVLiteralHyphenIsRange = envFlags.unicodeSets ? (() => {
1673
+ try {
1674
+ new globalRegExp(r`[\d\-a]`, "v");
1675
+ } catch {
1676
+ return true;
1677
+ }
1678
+ return false;
1679
+ })() : false;
1680
+ envFlags.bugNestedClassIgnoresNegation = envFlags.unicodeSets && new globalRegExp("[[^a]]", "v").test("a");
1681
+ function getNewCurrentFlags(current, { enable, disable }) {
1682
+ return {
1683
+ dotAll: !disable?.dotAll && !!(enable?.dotAll || current.dotAll),
1684
+ ignoreCase: !disable?.ignoreCase && !!(enable?.ignoreCase || current.ignoreCase)
1685
+ };
1686
+ }
1687
+ function getOrInsert(map, key, defaultValue) {
1688
+ if (!map.has(key)) map.set(key, defaultValue);
1689
+ return map.get(key);
1690
+ }
1691
+ function isMinTarget(target, min) {
1692
+ return EsVersion[target] >= EsVersion[min];
1693
+ }
1694
+ function throwIfNullish(value, msg) {
1695
+ if (value == null) throw new Error(msg ?? "Value expected");
1696
+ return value;
1697
+ }
1698
+ var EsVersion = {
1699
+ ES2025: 2025,
1700
+ ES2024: 2024,
1701
+ ES2018: 2018
1702
+ };
1703
+ var Target = {
1704
+ auto: "auto",
1705
+ ES2025: "ES2025",
1706
+ ES2024: "ES2024",
1707
+ ES2018: "ES2018"
1708
+ };
1709
+ function getOptions(options = {}) {
1710
+ if ({}.toString.call(options) !== "[object Object]") throw new Error("Unexpected options");
1711
+ if (options.target !== void 0 && !Target[options.target]) throw new Error(`Unexpected target "${options.target}"`);
1712
+ const opts = {
1713
+ accuracy: "default",
1714
+ avoidSubclass: false,
1715
+ flags: "",
1716
+ global: false,
1717
+ hasIndices: false,
1718
+ lazyCompileLength: Infinity,
1719
+ target: "auto",
1720
+ verbose: false,
1721
+ ...options,
1722
+ rules: {
1723
+ allowOrphanBackrefs: false,
1724
+ asciiWordBoundaries: false,
1725
+ captureGroup: false,
1726
+ recursionLimit: 20,
1727
+ singleline: false,
1728
+ ...options.rules
1729
+ }
1730
+ };
1731
+ if (opts.target === "auto") opts.target = envFlags.flagGroups ? "ES2025" : envFlags.unicodeSets ? "ES2024" : "ES2018";
1732
+ return opts;
1733
+ }
1734
+ var asciiSpaceChar = "[ -\r ]";
1735
+ var CharsWithoutIgnoreCaseExpansion = /* @__PURE__ */ new Set([cp(304), cp(305)]);
1736
+ var defaultWordChar = r`[\p{L}\p{M}\p{N}\p{Pc}]`;
1737
+ function getIgnoreCaseMatchChars(char) {
1738
+ if (CharsWithoutIgnoreCaseExpansion.has(char)) return [char];
1739
+ const set = /* @__PURE__ */ new Set();
1740
+ const lower = char.toLowerCase();
1741
+ const upper = lower.toUpperCase();
1742
+ const title = LowerToTitleCaseMap.get(lower);
1743
+ const altLower = LowerToAlternativeLowerCaseMap.get(lower);
1744
+ const altUpper = LowerToAlternativeUpperCaseMap.get(lower);
1745
+ if ([...upper].length === 1) set.add(upper);
1746
+ altUpper && set.add(altUpper);
1747
+ title && set.add(title);
1748
+ set.add(lower);
1749
+ altLower && set.add(altLower);
1750
+ return [...set];
1751
+ }
1752
+ var JsUnicodePropertyMap = /* @__PURE__ */ new Map(`C Other
1753
+ Cc Control cntrl
1754
+ Cf Format
1755
+ Cn Unassigned
1756
+ Co Private_Use
1757
+ Cs Surrogate
1758
+ L Letter
1759
+ LC Cased_Letter
1760
+ Ll Lowercase_Letter
1761
+ Lm Modifier_Letter
1762
+ Lo Other_Letter
1763
+ Lt Titlecase_Letter
1764
+ Lu Uppercase_Letter
1765
+ M Mark Combining_Mark
1766
+ Mc Spacing_Mark
1767
+ Me Enclosing_Mark
1768
+ Mn Nonspacing_Mark
1769
+ N Number
1770
+ Nd Decimal_Number digit
1771
+ Nl Letter_Number
1772
+ No Other_Number
1773
+ P Punctuation punct
1774
+ Pc Connector_Punctuation
1775
+ Pd Dash_Punctuation
1776
+ Pe Close_Punctuation
1777
+ Pf Final_Punctuation
1778
+ Pi Initial_Punctuation
1779
+ Po Other_Punctuation
1780
+ Ps Open_Punctuation
1781
+ S Symbol
1782
+ Sc Currency_Symbol
1783
+ Sk Modifier_Symbol
1784
+ Sm Math_Symbol
1785
+ So Other_Symbol
1786
+ Z Separator
1787
+ Zl Line_Separator
1788
+ Zp Paragraph_Separator
1789
+ Zs Space_Separator
1790
+ ASCII
1791
+ ASCII_Hex_Digit AHex
1792
+ Alphabetic Alpha
1793
+ Any
1794
+ Assigned
1795
+ Bidi_Control Bidi_C
1796
+ Bidi_Mirrored Bidi_M
1797
+ Case_Ignorable CI
1798
+ Cased
1799
+ Changes_When_Casefolded CWCF
1800
+ Changes_When_Casemapped CWCM
1801
+ Changes_When_Lowercased CWL
1802
+ Changes_When_NFKC_Casefolded CWKCF
1803
+ Changes_When_Titlecased CWT
1804
+ Changes_When_Uppercased CWU
1805
+ Dash
1806
+ Default_Ignorable_Code_Point DI
1807
+ Deprecated Dep
1808
+ Diacritic Dia
1809
+ Emoji
1810
+ Emoji_Component EComp
1811
+ Emoji_Modifier EMod
1812
+ Emoji_Modifier_Base EBase
1813
+ Emoji_Presentation EPres
1814
+ Extended_Pictographic ExtPict
1815
+ Extender Ext
1816
+ Grapheme_Base Gr_Base
1817
+ Grapheme_Extend Gr_Ext
1818
+ Hex_Digit Hex
1819
+ IDS_Binary_Operator IDSB
1820
+ IDS_Trinary_Operator IDST
1821
+ ID_Continue IDC
1822
+ ID_Start IDS
1823
+ Ideographic Ideo
1824
+ Join_Control Join_C
1825
+ Logical_Order_Exception LOE
1826
+ Lowercase Lower
1827
+ Math
1828
+ Noncharacter_Code_Point NChar
1829
+ Pattern_Syntax Pat_Syn
1830
+ Pattern_White_Space Pat_WS
1831
+ Quotation_Mark QMark
1832
+ Radical
1833
+ Regional_Indicator RI
1834
+ Sentence_Terminal STerm
1835
+ Soft_Dotted SD
1836
+ Terminal_Punctuation Term
1837
+ Unified_Ideograph UIdeo
1838
+ Uppercase Upper
1839
+ Variation_Selector VS
1840
+ White_Space space
1841
+ XID_Continue XIDC
1842
+ XID_Start XIDS`.split(/\s/).map((p) => [w(p), p]));
1843
+ var LowerToAlternativeLowerCaseMap = /* @__PURE__ */ new Map([["s", cp(383)], [cp(383), "s"]]);
1844
+ var LowerToAlternativeUpperCaseMap = /* @__PURE__ */ new Map([
1845
+ [cp(223), cp(7838)],
1846
+ [cp(107), cp(8490)],
1847
+ [cp(229), cp(8491)],
1848
+ [cp(969), cp(8486)]
1849
+ ]);
1850
+ var LowerToTitleCaseMap = new Map([
1851
+ titleEntry(453),
1852
+ titleEntry(456),
1853
+ titleEntry(459),
1854
+ titleEntry(498),
1855
+ ...titleRange(8072, 8079),
1856
+ ...titleRange(8088, 8095),
1857
+ ...titleRange(8104, 8111),
1858
+ titleEntry(8124),
1859
+ titleEntry(8140),
1860
+ titleEntry(8188)
1861
+ ]);
1862
+ var PosixClassMap = /* @__PURE__ */ new Map([
1863
+ ["alnum", r`[\p{Alpha}\p{Nd}]`],
1864
+ ["alpha", r`\p{Alpha}`],
1865
+ ["ascii", r`\p{ASCII}`],
1866
+ ["blank", r`[\p{Zs}\t]`],
1867
+ ["cntrl", r`\p{Cc}`],
1868
+ ["digit", r`\p{Nd}`],
1869
+ ["graph", r`[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]`],
1870
+ ["lower", r`\p{Lower}`],
1871
+ ["print", r`[[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]\p{Zs}]`],
1872
+ ["punct", r`[\p{P}\p{S}]`],
1873
+ ["space", r`\p{space}`],
1874
+ ["upper", r`\p{Upper}`],
1875
+ ["word", r`[\p{Alpha}\p{M}\p{Nd}\p{Pc}]`],
1876
+ ["xdigit", r`\p{AHex}`]
1877
+ ]);
1878
+ function range(start, end) {
1879
+ const range2 = [];
1880
+ for (let i = start; i <= end; i++) range2.push(i);
1881
+ return range2;
1882
+ }
1883
+ function titleEntry(codePoint) {
1884
+ const char = cp(codePoint);
1885
+ return [char.toLowerCase(), char];
1886
+ }
1887
+ function titleRange(start, end) {
1888
+ return range(start, end).map((codePoint) => titleEntry(codePoint));
1889
+ }
1890
+ var UnicodePropertiesWithSpecificCase = /* @__PURE__ */ new Set([
1891
+ "Lower",
1892
+ "Lowercase",
1893
+ "Upper",
1894
+ "Uppercase",
1895
+ "Ll",
1896
+ "Lowercase_Letter",
1897
+ "Lt",
1898
+ "Titlecase_Letter",
1899
+ "Lu",
1900
+ "Uppercase_Letter"
1901
+ ]);
1902
+ function transform(ast, options) {
1903
+ const opts = {
1904
+ accuracy: "default",
1905
+ asciiWordBoundaries: false,
1906
+ avoidSubclass: false,
1907
+ bestEffortTarget: "ES2025",
1908
+ ...options
1909
+ };
1910
+ addParentProperties(ast);
1911
+ const firstPassState = {
1912
+ accuracy: opts.accuracy,
1913
+ asciiWordBoundaries: opts.asciiWordBoundaries,
1914
+ avoidSubclass: opts.avoidSubclass,
1915
+ flagDirectivesByAlt: /* @__PURE__ */ new Map(),
1916
+ jsGroupNameMap: /* @__PURE__ */ new Map(),
1917
+ minTargetEs2024: isMinTarget(opts.bestEffortTarget, "ES2024"),
1918
+ passedLookbehind: false,
1919
+ strategy: null,
1920
+ subroutineRefMap: /* @__PURE__ */ new Map(),
1921
+ supportedGNodes: /* @__PURE__ */ new Set(),
1922
+ digitIsAscii: ast.flags.digitIsAscii,
1923
+ spaceIsAscii: ast.flags.spaceIsAscii,
1924
+ wordIsAscii: ast.flags.wordIsAscii
1925
+ };
1926
+ S(ast, FirstPassVisitor, firstPassState);
1927
+ const globalFlags = {
1928
+ dotAll: ast.flags.dotAll,
1929
+ ignoreCase: ast.flags.ignoreCase
1930
+ };
1931
+ const secondPassState = {
1932
+ currentFlags: globalFlags,
1933
+ prevFlags: null,
1934
+ globalFlags,
1935
+ groupOriginByCopy: /* @__PURE__ */ new Map(),
1936
+ groupsByName: /* @__PURE__ */ new Map(),
1937
+ multiplexCapturesToLeftByRef: /* @__PURE__ */ new Map(),
1938
+ openRefs: /* @__PURE__ */ new Map(),
1939
+ reffedNodesByReferencer: /* @__PURE__ */ new Map(),
1940
+ subroutineRefMap: firstPassState.subroutineRefMap
1941
+ };
1942
+ S(ast, SecondPassVisitor, secondPassState);
1943
+ S(ast, ThirdPassVisitor, {
1944
+ groupsByName: secondPassState.groupsByName,
1945
+ highestOrphanBackref: 0,
1946
+ numCapturesToLeft: 0,
1947
+ reffedNodesByReferencer: secondPassState.reffedNodesByReferencer
1948
+ });
1949
+ ast._originMap = secondPassState.groupOriginByCopy;
1950
+ ast._strategy = firstPassState.strategy;
1951
+ return ast;
1952
+ }
1953
+ var FirstPassVisitor = {
1954
+ AbsenceFunction({ node, parent, replaceWith }) {
1955
+ const { body, kind } = node;
1956
+ if (kind === "repeater") {
1957
+ const innerGroup = A();
1958
+ innerGroup.body[0].body.push(K({
1959
+ negate: true,
1960
+ body
1961
+ }), Q("Any"));
1962
+ const outerGroup = A();
1963
+ outerGroup.body[0].body.push(_("greedy", 0, Infinity, innerGroup));
1964
+ replaceWith(setParentDeep(outerGroup, parent), { traverse: true });
1965
+ } else throw new Error(`Unsupported absence function "(?~|"`);
1966
+ },
1967
+ Alternative: {
1968
+ enter({ node, parent, key }, { flagDirectivesByAlt }) {
1969
+ const flagDirectives = node.body.filter((el) => el.kind === "flags");
1970
+ for (let i = key + 1; i < parent.body.length; i++) {
1971
+ const forwardSiblingAlt = parent.body[i];
1972
+ getOrInsert(flagDirectivesByAlt, forwardSiblingAlt, []).push(...flagDirectives);
1973
+ }
1974
+ },
1975
+ exit({ node }, { flagDirectivesByAlt }) {
1976
+ if (flagDirectivesByAlt.get(node)?.length) {
1977
+ const flags = getCombinedFlagModsFromFlagNodes(flagDirectivesByAlt.get(node));
1978
+ if (flags) {
1979
+ const flagGroup = A({ flags });
1980
+ flagGroup.body[0].body = node.body;
1981
+ node.body = [setParentDeep(flagGroup, node)];
1982
+ }
1983
+ }
1984
+ }
1985
+ },
1986
+ Assertion({ node, parent, key, container, root, remove, replaceWith }, state) {
1987
+ const { kind, negate } = node;
1988
+ const { asciiWordBoundaries, avoidSubclass, supportedGNodes, wordIsAscii } = state;
1989
+ if (kind === "text_segment_boundary") throw new Error(`Unsupported text segment boundary "\\${negate ? "Y" : "y"}"`);
1990
+ else if (kind === "line_end") replaceWith(setParentDeep(K({ body: [b({ body: [F("string_end")] }), b({ body: [m(10)] })] }), parent));
1991
+ else if (kind === "line_start") replaceWith(setParentDeep(parseFragment(r`(?<=\A|\n(?!\z))`, { skipLookbehindValidation: true }), parent));
1992
+ else if (kind === "search_start") if (supportedGNodes.has(node)) {
1993
+ root.flags.sticky = true;
1994
+ remove();
1995
+ } else {
1996
+ const prev = container[key - 1];
1997
+ if (prev && isAlwaysNonZeroLength(prev)) replaceWith(setParentDeep(K({ negate: true }), parent));
1998
+ else if (avoidSubclass) throw new Error(r`Uses "\G" in a way that requires a subclass`);
1999
+ else {
2000
+ replaceWith(setParent(F("string_start"), parent));
2001
+ state.strategy = "clip_search";
2002
+ }
2003
+ }
2004
+ else if (kind === "string_end" || kind === "string_start") {} else if (kind === "string_end_newline") replaceWith(setParentDeep(parseFragment(r`(?=\n?\z)`), parent));
2005
+ else if (kind === "word_boundary") {
2006
+ if (!wordIsAscii && !asciiWordBoundaries) {
2007
+ const b = `(?:(?<=${defaultWordChar})(?!${defaultWordChar})|(?<!${defaultWordChar})(?=${defaultWordChar}))`;
2008
+ const B = `(?:(?<=${defaultWordChar})(?=${defaultWordChar})|(?<!${defaultWordChar})(?!${defaultWordChar}))`;
2009
+ replaceWith(setParentDeep(parseFragment(negate ? B : b), parent));
2010
+ }
2011
+ } else throw new Error(`Unexpected assertion kind "${kind}"`);
2012
+ },
2013
+ Backreference({ node }, { jsGroupNameMap }) {
2014
+ let { ref } = node;
2015
+ if (typeof ref === "string" && !isValidJsGroupName(ref)) {
2016
+ ref = getAndStoreJsGroupName(ref, jsGroupNameMap);
2017
+ node.ref = ref;
2018
+ }
2019
+ },
2020
+ CapturingGroup({ node }, { jsGroupNameMap, subroutineRefMap }) {
2021
+ let { name } = node;
2022
+ if (name && !isValidJsGroupName(name)) {
2023
+ name = getAndStoreJsGroupName(name, jsGroupNameMap);
2024
+ node.name = name;
2025
+ }
2026
+ subroutineRefMap.set(node.number, node);
2027
+ if (name) subroutineRefMap.set(name, node);
2028
+ },
2029
+ CharacterClassRange({ node, parent, replaceWith }) {
2030
+ if (parent.kind === "intersection") replaceWith(setParentDeep(C({ body: [node] }), parent), { traverse: true });
2031
+ },
2032
+ CharacterSet({ node, parent, replaceWith }, { accuracy, minTargetEs2024, digitIsAscii, spaceIsAscii, wordIsAscii }) {
2033
+ const { kind, negate, value } = node;
2034
+ if (digitIsAscii && (kind === "digit" || value === "digit")) {
2035
+ replaceWith(setParent(E("digit", { negate }), parent));
2036
+ return;
2037
+ }
2038
+ if (spaceIsAscii && (kind === "space" || value === "space")) {
2039
+ replaceWith(setParentDeep(setNegate(parseFragment(asciiSpaceChar), negate), parent));
2040
+ return;
2041
+ }
2042
+ if (wordIsAscii && (kind === "word" || value === "word")) {
2043
+ replaceWith(setParent(E("word", { negate }), parent));
2044
+ return;
2045
+ }
2046
+ if (kind === "any") replaceWith(setParent(Q("Any"), parent));
2047
+ else if (kind === "digit") replaceWith(setParent(Q("Nd", { negate }), parent));
2048
+ else if (kind === "dot") {} else if (kind === "text_segment") {
2049
+ if (accuracy === "strict") throw new Error(r`Use of "\X" requires non-strict accuracy`);
2050
+ const eBase = "\\p{Emoji}(?:\\p{EMod}|\\uFE0F\\u20E3?|[\\x{E0020}-\\x{E007E}]+\\x{E007F})?";
2051
+ const emoji = r`\p{RI}{2}|${eBase}(?:\u200D${eBase})*`;
2052
+ replaceWith(setParentDeep(parseFragment(r`(?>\r\n|${minTargetEs2024 ? r`\p{RGI_Emoji}` : emoji}|\P{M}\p{M}*)`, { skipPropertyNameValidation: true }), parent));
2053
+ } else if (kind === "hex") replaceWith(setParent(Q("AHex", { negate }), parent));
2054
+ else if (kind === "newline") replaceWith(setParentDeep(parseFragment(negate ? "[^\n]" : "(?>\r\n?|[\n\v\f…\u2028\u2029])"), parent));
2055
+ else if (kind === "posix") if (!minTargetEs2024 && (value === "graph" || value === "print")) {
2056
+ if (accuracy === "strict") throw new Error(`POSIX class "${value}" requires min target ES2024 or non-strict accuracy`);
2057
+ let ascii = {
2058
+ graph: "!-~",
2059
+ print: " -~"
2060
+ }[value];
2061
+ if (negate) ascii = `\0-${cp(ascii.codePointAt(0) - 1)}${cp(ascii.codePointAt(2) + 1)}-\u{10FFFF}`;
2062
+ replaceWith(setParentDeep(parseFragment(`[${ascii}]`), parent));
2063
+ } else replaceWith(setParentDeep(setNegate(parseFragment(PosixClassMap.get(value)), negate), parent));
2064
+ else if (kind === "property") {
2065
+ if (!JsUnicodePropertyMap.has(w(value))) node.key = "sc";
2066
+ } else if (kind === "space") replaceWith(setParent(Q("space", { negate }), parent));
2067
+ else if (kind === "word") replaceWith(setParentDeep(setNegate(parseFragment(defaultWordChar), negate), parent));
2068
+ else throw new Error(`Unexpected character set kind "${kind}"`);
2069
+ },
2070
+ Directive({ node, parent, root, remove, replaceWith, removeAllPrevSiblings, removeAllNextSiblings }) {
2071
+ const { kind, flags } = node;
2072
+ if (kind === "flags") if (!flags.enable && !flags.disable) remove();
2073
+ else {
2074
+ const flagGroup = A({ flags });
2075
+ flagGroup.body[0].body = removeAllNextSiblings();
2076
+ replaceWith(setParentDeep(flagGroup, parent), { traverse: true });
2077
+ }
2078
+ else if (kind === "keep") {
2079
+ const firstAlt = root.body[0];
2080
+ const topLevel = root.body.length === 1 && o(firstAlt, { type: "Group" }) && firstAlt.body[0].body.length === 1 ? firstAlt.body[0] : root;
2081
+ if (parent.parent !== topLevel || topLevel.body.length > 1) throw new Error(r`Uses "\K" in a way that's unsupported`);
2082
+ const lookbehind = K({ behind: true });
2083
+ lookbehind.body[0].body = removeAllPrevSiblings();
2084
+ replaceWith(setParentDeep(lookbehind, parent));
2085
+ } else throw new Error(`Unexpected directive kind "${kind}"`);
2086
+ },
2087
+ Flags({ node, parent }) {
2088
+ if (node.posixIsAscii) throw new Error("Unsupported flag \"P\"");
2089
+ if (node.textSegmentMode === "word") throw new Error("Unsupported flag \"y{w}\"");
2090
+ [
2091
+ "digitIsAscii",
2092
+ "extended",
2093
+ "posixIsAscii",
2094
+ "spaceIsAscii",
2095
+ "wordIsAscii",
2096
+ "textSegmentMode"
2097
+ ].forEach((f) => delete node[f]);
2098
+ Object.assign(node, {
2099
+ global: false,
2100
+ hasIndices: false,
2101
+ multiline: false,
2102
+ sticky: node.sticky ?? false
2103
+ });
2104
+ parent.options = {
2105
+ disable: {
2106
+ x: true,
2107
+ n: true
2108
+ },
2109
+ force: { v: true }
2110
+ };
2111
+ },
2112
+ Group({ node }) {
2113
+ if (!node.flags) return;
2114
+ const { enable, disable } = node.flags;
2115
+ enable?.extended && delete enable.extended;
2116
+ disable?.extended && delete disable.extended;
2117
+ enable?.dotAll && disable?.dotAll && delete enable.dotAll;
2118
+ enable?.ignoreCase && disable?.ignoreCase && delete enable.ignoreCase;
2119
+ enable && !Object.keys(enable).length && delete node.flags.enable;
2120
+ disable && !Object.keys(disable).length && delete node.flags.disable;
2121
+ !node.flags.enable && !node.flags.disable && delete node.flags;
2122
+ },
2123
+ LookaroundAssertion({ node }, state) {
2124
+ const { kind } = node;
2125
+ if (kind === "lookbehind") state.passedLookbehind = true;
2126
+ },
2127
+ NamedCallout({ node, parent, replaceWith }) {
2128
+ const { kind } = node;
2129
+ if (kind === "fail") replaceWith(setParentDeep(K({ negate: true }), parent));
2130
+ else throw new Error(`Unsupported named callout "(*${kind.toUpperCase()}"`);
2131
+ },
2132
+ Quantifier({ node }) {
2133
+ if (node.body.type === "Quantifier") {
2134
+ const group = A();
2135
+ group.body[0].body.push(node.body);
2136
+ node.body = setParentDeep(group, node);
2137
+ }
2138
+ },
2139
+ Regex: {
2140
+ enter({ node }, { supportedGNodes }) {
2141
+ const leadingGs = [];
2142
+ let hasAltWithLeadG = false;
2143
+ let hasAltWithoutLeadG = false;
2144
+ for (const alt of node.body) if (alt.body.length === 1 && alt.body[0].kind === "search_start") alt.body.pop();
2145
+ else {
2146
+ const leadingG = getLeadingG(alt.body);
2147
+ if (leadingG) {
2148
+ hasAltWithLeadG = true;
2149
+ Array.isArray(leadingG) ? leadingGs.push(...leadingG) : leadingGs.push(leadingG);
2150
+ } else hasAltWithoutLeadG = true;
2151
+ }
2152
+ if (hasAltWithLeadG && !hasAltWithoutLeadG) leadingGs.forEach((g) => supportedGNodes.add(g));
2153
+ },
2154
+ exit(_, { accuracy, passedLookbehind, strategy }) {
2155
+ if (accuracy === "strict" && passedLookbehind && strategy) throw new Error(r`Uses "\G" in a way that requires non-strict accuracy`);
2156
+ }
2157
+ },
2158
+ Subroutine({ node }, { jsGroupNameMap }) {
2159
+ let { ref } = node;
2160
+ if (typeof ref === "string" && !isValidJsGroupName(ref)) {
2161
+ ref = getAndStoreJsGroupName(ref, jsGroupNameMap);
2162
+ node.ref = ref;
2163
+ }
2164
+ }
2165
+ };
2166
+ var SecondPassVisitor = {
2167
+ Backreference({ node }, { multiplexCapturesToLeftByRef, reffedNodesByReferencer }) {
2168
+ const { orphan, ref } = node;
2169
+ if (!orphan) reffedNodesByReferencer.set(node, [...multiplexCapturesToLeftByRef.get(ref).map(({ node: node2 }) => node2)]);
2170
+ },
2171
+ CapturingGroup: {
2172
+ enter({ node, parent, replaceWith, skip }, { groupOriginByCopy, groupsByName, multiplexCapturesToLeftByRef, openRefs, reffedNodesByReferencer }) {
2173
+ const origin = groupOriginByCopy.get(node);
2174
+ if (origin && openRefs.has(node.number)) {
2175
+ const recursion2 = setParent(createRecursion(node.number), parent);
2176
+ reffedNodesByReferencer.set(recursion2, openRefs.get(node.number));
2177
+ replaceWith(recursion2);
2178
+ return;
2179
+ }
2180
+ openRefs.set(node.number, node);
2181
+ multiplexCapturesToLeftByRef.set(node.number, []);
2182
+ if (node.name) getOrInsert(multiplexCapturesToLeftByRef, node.name, []);
2183
+ const multiplexNodes = multiplexCapturesToLeftByRef.get(node.name ?? node.number);
2184
+ for (let i = 0; i < multiplexNodes.length; i++) {
2185
+ const multiplex = multiplexNodes[i];
2186
+ if (origin === multiplex.node || origin && origin === multiplex.origin || node === multiplex.origin) {
2187
+ multiplexNodes.splice(i, 1);
2188
+ break;
2189
+ }
2190
+ }
2191
+ multiplexCapturesToLeftByRef.get(node.number).push({
2192
+ node,
2193
+ origin
2194
+ });
2195
+ if (node.name) multiplexCapturesToLeftByRef.get(node.name).push({
2196
+ node,
2197
+ origin
2198
+ });
2199
+ if (node.name) {
2200
+ const groupsWithSameName = getOrInsert(groupsByName, node.name, /* @__PURE__ */ new Map());
2201
+ let hasDuplicateNameToRemove = false;
2202
+ if (origin) hasDuplicateNameToRemove = true;
2203
+ else for (const groupInfo of groupsWithSameName.values()) if (!groupInfo.hasDuplicateNameToRemove) {
2204
+ hasDuplicateNameToRemove = true;
2205
+ break;
2206
+ }
2207
+ groupsByName.get(node.name).set(node, {
2208
+ node,
2209
+ hasDuplicateNameToRemove
2210
+ });
2211
+ }
2212
+ },
2213
+ exit({ node }, { openRefs }) {
2214
+ if (openRefs.get(node.number) === node) openRefs.delete(node.number);
2215
+ }
2216
+ },
2217
+ Group: {
2218
+ enter({ node }, state) {
2219
+ state.prevFlags = state.currentFlags;
2220
+ if (node.flags) state.currentFlags = getNewCurrentFlags(state.currentFlags, node.flags);
2221
+ },
2222
+ exit(_, state) {
2223
+ state.currentFlags = state.prevFlags;
2224
+ }
2225
+ },
2226
+ Subroutine({ node, parent, replaceWith }, state) {
2227
+ const { isRecursive, ref } = node;
2228
+ if (isRecursive) {
2229
+ let reffed = parent;
2230
+ while (reffed = reffed.parent) if (reffed.type === "CapturingGroup" && (reffed.name === ref || reffed.number === ref)) break;
2231
+ state.reffedNodesByReferencer.set(node, reffed);
2232
+ return;
2233
+ }
2234
+ const reffedGroupNode = state.subroutineRefMap.get(ref);
2235
+ const isGlobalRecursion = ref === 0;
2236
+ const expandedSubroutine = isGlobalRecursion ? createRecursion(0) : cloneCapturingGroup(reffedGroupNode, state.groupOriginByCopy, null);
2237
+ let replacement = expandedSubroutine;
2238
+ if (!isGlobalRecursion) {
2239
+ const reffedGroupFlagMods = getCombinedFlagModsFromFlagNodes(getAllParents(reffedGroupNode, (p) => p.type === "Group" && !!p.flags));
2240
+ const reffedGroupFlags = reffedGroupFlagMods ? getNewCurrentFlags(state.globalFlags, reffedGroupFlagMods) : state.globalFlags;
2241
+ if (!areFlagsEqual(reffedGroupFlags, state.currentFlags)) {
2242
+ replacement = A({ flags: getFlagModsFromFlags(reffedGroupFlags) });
2243
+ replacement.body[0].body.push(expandedSubroutine);
2244
+ }
2245
+ }
2246
+ replaceWith(setParentDeep(replacement, parent), { traverse: !isGlobalRecursion });
2247
+ }
2248
+ };
2249
+ var ThirdPassVisitor = {
2250
+ Backreference({ node, parent, replaceWith }, state) {
2251
+ if (node.orphan) {
2252
+ state.highestOrphanBackref = Math.max(state.highestOrphanBackref, node.ref);
2253
+ return;
2254
+ }
2255
+ const participants = state.reffedNodesByReferencer.get(node).filter((reffed) => canParticipateWithNode(reffed, node));
2256
+ if (!participants.length) replaceWith(setParentDeep(K({ negate: true }), parent));
2257
+ else if (participants.length > 1) replaceWith(setParentDeep(A({
2258
+ atomic: true,
2259
+ body: participants.reverse().map((reffed) => b({ body: [k(reffed.number)] }))
2260
+ }), parent));
2261
+ else node.ref = participants[0].number;
2262
+ },
2263
+ CapturingGroup({ node }, state) {
2264
+ node.number = ++state.numCapturesToLeft;
2265
+ if (node.name) {
2266
+ if (state.groupsByName.get(node.name).get(node).hasDuplicateNameToRemove) delete node.name;
2267
+ }
2268
+ },
2269
+ Regex: { exit({ node }, state) {
2270
+ const numCapsNeeded = Math.max(state.highestOrphanBackref - state.numCapturesToLeft, 0);
2271
+ for (let i = 0; i < numCapsNeeded; i++) {
2272
+ const emptyCapture = P();
2273
+ node.body.at(-1).body.push(emptyCapture);
2274
+ }
2275
+ } },
2276
+ Subroutine({ node }, state) {
2277
+ if (!node.isRecursive || node.ref === 0) return;
2278
+ node.ref = state.reffedNodesByReferencer.get(node).number;
2279
+ }
2280
+ };
2281
+ function addParentProperties(root) {
2282
+ S(root, { "*"({ node, parent }) {
2283
+ node.parent = parent;
2284
+ } });
2285
+ }
2286
+ function areFlagsEqual(a, b) {
2287
+ return a.dotAll === b.dotAll && a.ignoreCase === b.ignoreCase;
2288
+ }
2289
+ function canParticipateWithNode(capture, node) {
2290
+ let rightmostPoint = node;
2291
+ do {
2292
+ if (rightmostPoint.type === "Regex") return false;
2293
+ if (rightmostPoint.type === "Alternative") continue;
2294
+ if (rightmostPoint === capture) return false;
2295
+ const kidsOfParent = getKids(rightmostPoint.parent);
2296
+ for (const kid of kidsOfParent) {
2297
+ if (kid === rightmostPoint) break;
2298
+ if (kid === capture || isAncestorOf(kid, capture)) return true;
2299
+ }
2300
+ } while (rightmostPoint = rightmostPoint.parent);
2301
+ throw new Error("Unexpected path");
2302
+ }
2303
+ function cloneCapturingGroup(obj, originMap, up, up2) {
2304
+ const store = Array.isArray(obj) ? [] : {};
2305
+ for (const [key, value] of Object.entries(obj)) if (key === "parent") store.parent = Array.isArray(up) ? up2 : up;
2306
+ else if (value && typeof value === "object") store[key] = cloneCapturingGroup(value, originMap, store, up);
2307
+ else {
2308
+ if (key === "type" && value === "CapturingGroup") originMap.set(store, originMap.get(obj) ?? obj);
2309
+ store[key] = value;
2310
+ }
2311
+ return store;
2312
+ }
2313
+ function createRecursion(ref) {
2314
+ const node = O(ref);
2315
+ node.isRecursive = true;
2316
+ return node;
2317
+ }
2318
+ function getAllParents(node, filterFn) {
2319
+ const results = [];
2320
+ while (node = node.parent) if (!filterFn || filterFn(node)) results.push(node);
2321
+ return results;
2322
+ }
2323
+ function getAndStoreJsGroupName(name, map) {
2324
+ if (map.has(name)) return map.get(name);
2325
+ const jsName = `$${map.size}_${name.replace(/^[^$_\p{IDS}]|[^$\u200C\u200D\p{IDC}]/gu, "_")}`;
2326
+ map.set(name, jsName);
2327
+ return jsName;
2328
+ }
2329
+ function getCombinedFlagModsFromFlagNodes(flagNodes) {
2330
+ const flagProps = ["dotAll", "ignoreCase"];
2331
+ const combinedFlags = {
2332
+ enable: {},
2333
+ disable: {}
2334
+ };
2335
+ flagNodes.forEach(({ flags }) => {
2336
+ flagProps.forEach((prop) => {
2337
+ if (flags.enable?.[prop]) {
2338
+ delete combinedFlags.disable[prop];
2339
+ combinedFlags.enable[prop] = true;
2340
+ }
2341
+ if (flags.disable?.[prop]) combinedFlags.disable[prop] = true;
2342
+ });
2343
+ });
2344
+ if (!Object.keys(combinedFlags.enable).length) delete combinedFlags.enable;
2345
+ if (!Object.keys(combinedFlags.disable).length) delete combinedFlags.disable;
2346
+ if (combinedFlags.enable || combinedFlags.disable) return combinedFlags;
2347
+ return null;
2348
+ }
2349
+ function getFlagModsFromFlags({ dotAll, ignoreCase }) {
2350
+ const mods = {};
2351
+ if (dotAll || ignoreCase) {
2352
+ mods.enable = {};
2353
+ dotAll && (mods.enable.dotAll = true);
2354
+ ignoreCase && (mods.enable.ignoreCase = true);
2355
+ }
2356
+ if (!dotAll || !ignoreCase) {
2357
+ mods.disable = {};
2358
+ !dotAll && (mods.disable.dotAll = true);
2359
+ !ignoreCase && (mods.disable.ignoreCase = true);
2360
+ }
2361
+ return mods;
2362
+ }
2363
+ function getKids(node) {
2364
+ if (!node) throw new Error("Node expected");
2365
+ const { body } = node;
2366
+ return Array.isArray(body) ? body : body ? [body] : null;
2367
+ }
2368
+ function getLeadingG(els) {
2369
+ const firstToConsider = els.find((el) => el.kind === "search_start" || isLoneGLookaround(el, { negate: false }) || !isAlwaysZeroLength(el));
2370
+ if (!firstToConsider) return null;
2371
+ if (firstToConsider.kind === "search_start") return firstToConsider;
2372
+ if (firstToConsider.type === "LookaroundAssertion") return firstToConsider.body[0].body[0];
2373
+ if (firstToConsider.type === "CapturingGroup" || firstToConsider.type === "Group") {
2374
+ const gNodesForGroup = [];
2375
+ for (const alt of firstToConsider.body) {
2376
+ const leadingG = getLeadingG(alt.body);
2377
+ if (!leadingG) return null;
2378
+ Array.isArray(leadingG) ? gNodesForGroup.push(...leadingG) : gNodesForGroup.push(leadingG);
2379
+ }
2380
+ return gNodesForGroup;
2381
+ }
2382
+ return null;
2383
+ }
2384
+ function isAncestorOf(node, descendant) {
2385
+ const kids = getKids(node) ?? [];
2386
+ for (const kid of kids) if (kid === descendant || isAncestorOf(kid, descendant)) return true;
2387
+ return false;
2388
+ }
2389
+ function isAlwaysZeroLength({ type }) {
2390
+ return type === "Assertion" || type === "Directive" || type === "LookaroundAssertion";
2391
+ }
2392
+ function isAlwaysNonZeroLength(node) {
2393
+ const types = [
2394
+ "Character",
2395
+ "CharacterClass",
2396
+ "CharacterSet"
2397
+ ];
2398
+ return types.includes(node.type) || node.type === "Quantifier" && node.min && types.includes(node.body.type);
2399
+ }
2400
+ function isLoneGLookaround(node, options) {
2401
+ const opts = {
2402
+ negate: null,
2403
+ ...options
2404
+ };
2405
+ return node.type === "LookaroundAssertion" && (opts.negate === null || node.negate === opts.negate) && node.body.length === 1 && o(node.body[0], {
2406
+ type: "Assertion",
2407
+ kind: "search_start"
2408
+ });
2409
+ }
2410
+ function isValidJsGroupName(name) {
2411
+ return /^[$_\p{IDS}][$\u200C\u200D\p{IDC}]*$/u.test(name);
2412
+ }
2413
+ function parseFragment(pattern, options) {
2414
+ const alts = J(pattern, {
2415
+ ...options,
2416
+ unicodePropertyMap: JsUnicodePropertyMap
2417
+ }).body;
2418
+ if (alts.length > 1 || alts[0].body.length > 1) return A({ body: alts });
2419
+ return alts[0].body[0];
2420
+ }
2421
+ function setNegate(node, negate) {
2422
+ node.negate = negate;
2423
+ return node;
2424
+ }
2425
+ function setParent(node, parent) {
2426
+ node.parent = parent;
2427
+ return node;
2428
+ }
2429
+ function setParentDeep(node, parent) {
2430
+ addParentProperties(node);
2431
+ node.parent = parent;
2432
+ return node;
2433
+ }
2434
+ function generate(ast, options) {
2435
+ const opts = getOptions(options);
2436
+ const minTargetEs2024 = isMinTarget(opts.target, "ES2024");
2437
+ const minTargetEs2025 = isMinTarget(opts.target, "ES2025");
2438
+ const recursionLimit = opts.rules.recursionLimit;
2439
+ if (!Number.isInteger(recursionLimit) || recursionLimit < 2 || recursionLimit > 20) throw new Error("Invalid recursionLimit; use 2-20");
2440
+ let hasCaseInsensitiveNode = null;
2441
+ let hasCaseSensitiveNode = null;
2442
+ if (!minTargetEs2025) {
2443
+ const iStack = [ast.flags.ignoreCase];
2444
+ S(ast, FlagModifierVisitor, {
2445
+ getCurrentModI: () => iStack.at(-1),
2446
+ popModI() {
2447
+ iStack.pop();
2448
+ },
2449
+ pushModI(isIOn) {
2450
+ iStack.push(isIOn);
2451
+ },
2452
+ setHasCasedChar() {
2453
+ if (iStack.at(-1)) hasCaseInsensitiveNode = true;
2454
+ else hasCaseSensitiveNode = true;
2455
+ }
2456
+ });
2457
+ }
2458
+ const appliedGlobalFlags = {
2459
+ dotAll: ast.flags.dotAll,
2460
+ ignoreCase: !!((ast.flags.ignoreCase || hasCaseInsensitiveNode) && !hasCaseSensitiveNode)
2461
+ };
2462
+ let lastNode = ast;
2463
+ const state = {
2464
+ accuracy: opts.accuracy,
2465
+ appliedGlobalFlags,
2466
+ captureMap: /* @__PURE__ */ new Map(),
2467
+ currentFlags: {
2468
+ dotAll: ast.flags.dotAll,
2469
+ ignoreCase: ast.flags.ignoreCase
2470
+ },
2471
+ inCharClass: false,
2472
+ lastNode,
2473
+ originMap: ast._originMap,
2474
+ recursionLimit,
2475
+ useAppliedIgnoreCase: !!(!minTargetEs2025 && hasCaseInsensitiveNode && hasCaseSensitiveNode),
2476
+ useFlagMods: minTargetEs2025,
2477
+ useFlagV: minTargetEs2024,
2478
+ verbose: opts.verbose
2479
+ };
2480
+ function gen(node) {
2481
+ state.lastNode = lastNode;
2482
+ lastNode = node;
2483
+ return throwIfNullish(generator[node.type], `Unexpected node type "${node.type}"`)(node, state, gen);
2484
+ }
2485
+ const result = {
2486
+ pattern: ast.body.map(gen).join("|"),
2487
+ flags: gen(ast.flags),
2488
+ options: { ...ast.options }
2489
+ };
2490
+ if (!minTargetEs2024) {
2491
+ delete result.options.force.v;
2492
+ result.options.disable.v = true;
2493
+ result.options.unicodeSetsPlugin = null;
2494
+ }
2495
+ result._captureTransfers = /* @__PURE__ */ new Map();
2496
+ result._hiddenCaptures = [];
2497
+ state.captureMap.forEach((value, key) => {
2498
+ if (value.hidden) result._hiddenCaptures.push(key);
2499
+ if (value.transferTo) getOrInsert(result._captureTransfers, value.transferTo, []).push(key);
2500
+ });
2501
+ return result;
2502
+ }
2503
+ var FlagModifierVisitor = {
2504
+ "*": {
2505
+ enter({ node }, state) {
2506
+ if (isAnyGroup(node)) {
2507
+ const currentModI = state.getCurrentModI();
2508
+ state.pushModI(node.flags ? getNewCurrentFlags({ ignoreCase: currentModI }, node.flags).ignoreCase : currentModI);
2509
+ }
2510
+ },
2511
+ exit({ node }, state) {
2512
+ if (isAnyGroup(node)) state.popModI();
2513
+ }
2514
+ },
2515
+ Backreference(_, state) {
2516
+ state.setHasCasedChar();
2517
+ },
2518
+ Character({ node }, state) {
2519
+ if (charHasCase(cp(node.value))) state.setHasCasedChar();
2520
+ },
2521
+ CharacterClassRange({ node, skip }, state) {
2522
+ skip();
2523
+ if (getCasesOutsideCharClassRange(node, { firstOnly: true }).length) state.setHasCasedChar();
2524
+ },
2525
+ CharacterSet({ node }, state) {
2526
+ if (node.kind === "property" && UnicodePropertiesWithSpecificCase.has(node.value)) state.setHasCasedChar();
2527
+ }
2528
+ };
2529
+ var generator = {
2530
+ /**
2531
+ @param {AlternativeNode} node
2532
+ */
2533
+ Alternative({ body }, _, gen) {
2534
+ return body.map(gen).join("");
2535
+ },
2536
+ /**
2537
+ @param {AssertionNode} node
2538
+ */
2539
+ Assertion({ kind, negate }) {
2540
+ if (kind === "string_end") return "$";
2541
+ if (kind === "string_start") return "^";
2542
+ if (kind === "word_boundary") return negate ? r`\B` : r`\b`;
2543
+ throw new Error(`Unexpected assertion kind "${kind}"`);
2544
+ },
2545
+ /**
2546
+ @param {BackreferenceNode} node
2547
+ */
2548
+ Backreference({ ref }, state) {
2549
+ if (typeof ref !== "number") throw new Error("Unexpected named backref in transformed AST");
2550
+ if (!state.useFlagMods && state.accuracy === "strict" && state.currentFlags.ignoreCase && !state.captureMap.get(ref).ignoreCase) throw new Error("Use of case-insensitive backref to case-sensitive group requires target ES2025 or non-strict accuracy");
2551
+ return "\\" + ref;
2552
+ },
2553
+ /**
2554
+ @param {CapturingGroupNode} node
2555
+ */
2556
+ CapturingGroup(node, state, gen) {
2557
+ const { body, name, number } = node;
2558
+ const data = { ignoreCase: state.currentFlags.ignoreCase };
2559
+ const origin = state.originMap.get(node);
2560
+ if (origin) {
2561
+ data.hidden = true;
2562
+ if (number > origin.number) data.transferTo = origin.number;
2563
+ }
2564
+ state.captureMap.set(number, data);
2565
+ return `(${name ? `?<${name}>` : ""}${body.map(gen).join("|")})`;
2566
+ },
2567
+ /**
2568
+ @param {CharacterNode} node
2569
+ */
2570
+ Character({ value }, state) {
2571
+ const char = cp(value);
2572
+ const escaped = getCharEscape(value, {
2573
+ escDigit: state.lastNode.type === "Backreference",
2574
+ inCharClass: state.inCharClass,
2575
+ useFlagV: state.useFlagV
2576
+ });
2577
+ if (escaped !== char) return escaped;
2578
+ if (state.useAppliedIgnoreCase && state.currentFlags.ignoreCase && charHasCase(char)) {
2579
+ const cases = getIgnoreCaseMatchChars(char);
2580
+ return state.inCharClass ? cases.join("") : cases.length > 1 ? `[${cases.join("")}]` : cases[0];
2581
+ }
2582
+ return char;
2583
+ },
2584
+ /**
2585
+ @param {CharacterClassNode} node
2586
+ */
2587
+ CharacterClass(node, state, gen) {
2588
+ const { kind, negate, parent } = node;
2589
+ let { body } = node;
2590
+ if (kind === "intersection" && !state.useFlagV) throw new Error("Use of character class intersection requires min target ES2024");
2591
+ if (envFlags.bugFlagVLiteralHyphenIsRange && state.useFlagV && body.some(isLiteralHyphen)) body = [m(45), ...body.filter((kid) => !isLiteralHyphen(kid))];
2592
+ const genClass = () => `[${negate ? "^" : ""}${body.map(gen).join(kind === "intersection" ? "&&" : "")}]`;
2593
+ if (!state.inCharClass) {
2594
+ if ((!state.useFlagV || envFlags.bugNestedClassIgnoresNegation) && !negate) {
2595
+ const negatedChildClasses = body.filter((kid) => kid.type === "CharacterClass" && kid.kind === "union" && kid.negate);
2596
+ if (negatedChildClasses.length) {
2597
+ const group = A();
2598
+ const groupFirstAlt = group.body[0];
2599
+ group.parent = parent;
2600
+ groupFirstAlt.parent = group;
2601
+ body = body.filter((kid) => !negatedChildClasses.includes(kid));
2602
+ node.body = body;
2603
+ if (body.length) {
2604
+ node.parent = groupFirstAlt;
2605
+ groupFirstAlt.body.push(node);
2606
+ } else group.body.pop();
2607
+ negatedChildClasses.forEach((cc) => {
2608
+ const newAlt = b({ body: [cc] });
2609
+ cc.parent = newAlt;
2610
+ newAlt.parent = group;
2611
+ group.body.push(newAlt);
2612
+ });
2613
+ return gen(group);
2614
+ }
2615
+ }
2616
+ state.inCharClass = true;
2617
+ const result = genClass();
2618
+ state.inCharClass = false;
2619
+ return result;
2620
+ }
2621
+ const firstEl = body[0];
2622
+ if (kind === "union" && !negate && firstEl && ((!state.useFlagV || !state.verbose) && parent.kind === "union" && !(envFlags.bugFlagVLiteralHyphenIsRange && state.useFlagV) || !state.verbose && parent.kind === "intersection" && body.length === 1 && firstEl.type !== "CharacterClassRange")) return body.map(gen).join("");
2623
+ if (!state.useFlagV && parent.type === "CharacterClass") throw new Error("Uses nested character class in a way that requires min target ES2024");
2624
+ return genClass();
2625
+ },
2626
+ /**
2627
+ @param {CharacterClassRangeNode} node
2628
+ */
2629
+ CharacterClassRange(node, state) {
2630
+ const min = node.min.value;
2631
+ const max = node.max.value;
2632
+ const escOpts = {
2633
+ escDigit: false,
2634
+ inCharClass: true,
2635
+ useFlagV: state.useFlagV
2636
+ };
2637
+ const minStr = getCharEscape(min, escOpts);
2638
+ const maxStr = getCharEscape(max, escOpts);
2639
+ const extraChars = /* @__PURE__ */ new Set();
2640
+ if (state.useAppliedIgnoreCase && state.currentFlags.ignoreCase) getCodePointRangesFromChars(getCasesOutsideCharClassRange(node)).forEach((value) => {
2641
+ extraChars.add(Array.isArray(value) ? `${getCharEscape(value[0], escOpts)}-${getCharEscape(value[1], escOpts)}` : getCharEscape(value, escOpts));
2642
+ });
2643
+ return `${minStr}-${maxStr}${[...extraChars].join("")}`;
2644
+ },
2645
+ /**
2646
+ @param {CharacterSetNode} node
2647
+ */
2648
+ CharacterSet({ kind, negate, value, key }, state) {
2649
+ if (kind === "dot") return state.currentFlags.dotAll ? state.appliedGlobalFlags.dotAll || state.useFlagMods ? "." : "[^]" : r`[^\n]`;
2650
+ if (kind === "digit") return negate ? r`\D` : r`\d`;
2651
+ if (kind === "property") {
2652
+ if (state.useAppliedIgnoreCase && state.currentFlags.ignoreCase && UnicodePropertiesWithSpecificCase.has(value)) throw new Error(`Unicode property "${value}" can't be case-insensitive when other chars have specific case`);
2653
+ return `${negate ? r`\P` : r`\p`}{${key ? `${key}=` : ""}${value}}`;
2654
+ }
2655
+ if (kind === "word") return negate ? r`\W` : r`\w`;
2656
+ throw new Error(`Unexpected character set kind "${kind}"`);
2657
+ },
2658
+ /**
2659
+ @param {FlagsNode} node
2660
+ */
2661
+ Flags(node, state) {
2662
+ return (state.appliedGlobalFlags.ignoreCase ? "i" : "") + (node.dotAll ? "s" : "") + (node.sticky ? "y" : "");
2663
+ },
2664
+ /**
2665
+ @param {GroupNode} node
2666
+ */
2667
+ Group({ atomic: atomic2, body, flags, parent }, state, gen) {
2668
+ const currentFlags = state.currentFlags;
2669
+ if (flags) state.currentFlags = getNewCurrentFlags(currentFlags, flags);
2670
+ const contents = body.map(gen).join("|");
2671
+ const result = !state.verbose && body.length === 1 && parent.type !== "Quantifier" && !atomic2 && (!state.useFlagMods || !flags) ? contents : `(?${getGroupPrefix(atomic2, flags, state.useFlagMods)}${contents})`;
2672
+ state.currentFlags = currentFlags;
2673
+ return result;
2674
+ },
2675
+ /**
2676
+ @param {LookaroundAssertionNode} node
2677
+ */
2678
+ LookaroundAssertion({ body, kind, negate }, _, gen) {
2679
+ return `(?${`${kind === "lookahead" ? "" : "<"}${negate ? "!" : "="}`}${body.map(gen).join("|")})`;
2680
+ },
2681
+ /**
2682
+ @param {QuantifierNode} node
2683
+ */
2684
+ Quantifier(node, _, gen) {
2685
+ return gen(node.body) + getQuantifierStr(node);
2686
+ },
2687
+ /**
2688
+ @param {SubroutineNode & {isRecursive: true}} node
2689
+ */
2690
+ Subroutine({ isRecursive, ref }, state) {
2691
+ if (!isRecursive) throw new Error("Unexpected non-recursive subroutine in transformed AST");
2692
+ const limit = state.recursionLimit;
2693
+ return ref === 0 ? `(?R=${limit})` : r`\g<${ref}&R=${limit}>`;
2694
+ }
2695
+ };
2696
+ var BaseEscapeChars = /* @__PURE__ */ new Set([
2697
+ "$",
2698
+ "(",
2699
+ ")",
2700
+ "*",
2701
+ "+",
2702
+ ".",
2703
+ "?",
2704
+ "[",
2705
+ "\\",
2706
+ "]",
2707
+ "^",
2708
+ "{",
2709
+ "|",
2710
+ "}"
2711
+ ]);
2712
+ var CharClassEscapeChars = /* @__PURE__ */ new Set([
2713
+ "-",
2714
+ "\\",
2715
+ "]",
2716
+ "^",
2717
+ "["
2718
+ ]);
2719
+ var CharClassEscapeCharsFlagV = /* @__PURE__ */ new Set([
2720
+ "(",
2721
+ ")",
2722
+ "-",
2723
+ "/",
2724
+ "[",
2725
+ "\\",
2726
+ "]",
2727
+ "^",
2728
+ "{",
2729
+ "|",
2730
+ "}",
2731
+ "!",
2732
+ "#",
2733
+ "$",
2734
+ "%",
2735
+ "&",
2736
+ "*",
2737
+ "+",
2738
+ ",",
2739
+ ".",
2740
+ ":",
2741
+ ";",
2742
+ "<",
2743
+ "=",
2744
+ ">",
2745
+ "?",
2746
+ "@",
2747
+ "`",
2748
+ "~"
2749
+ ]);
2750
+ var CharCodeEscapeMap = /* @__PURE__ */ new Map([
2751
+ [9, r`\t`],
2752
+ [10, r`\n`],
2753
+ [11, r`\v`],
2754
+ [12, r`\f`],
2755
+ [13, r`\r`],
2756
+ [8232, r`\u2028`],
2757
+ [8233, r`\u2029`],
2758
+ [65279, r`\uFEFF`]
2759
+ ]);
2760
+ var casedRe = /^\p{Cased}$/u;
2761
+ function charHasCase(char) {
2762
+ return casedRe.test(char);
2763
+ }
2764
+ function getCasesOutsideCharClassRange(node, options) {
2765
+ const firstOnly = !!options?.firstOnly;
2766
+ const min = node.min.value;
2767
+ const max = node.max.value;
2768
+ const found = [];
2769
+ if (min < 65 && (max === 65535 || max >= 131071) || min === 65536 && max >= 131071) return found;
2770
+ for (let i = min; i <= max; i++) {
2771
+ const char = cp(i);
2772
+ if (!charHasCase(char)) continue;
2773
+ const charsOutsideRange = getIgnoreCaseMatchChars(char).filter((caseOfChar) => {
2774
+ const num = caseOfChar.codePointAt(0);
2775
+ return num < min || num > max;
2776
+ });
2777
+ if (charsOutsideRange.length) {
2778
+ found.push(...charsOutsideRange);
2779
+ if (firstOnly) break;
2780
+ }
2781
+ }
2782
+ return found;
2783
+ }
2784
+ function getCharEscape(codePoint, { escDigit, inCharClass, useFlagV }) {
2785
+ if (CharCodeEscapeMap.has(codePoint)) return CharCodeEscapeMap.get(codePoint);
2786
+ if (codePoint < 32 || codePoint > 126 && codePoint < 160 || codePoint > 262143 || escDigit && isDigitCharCode(codePoint)) return codePoint > 255 ? `\\u{${codePoint.toString(16).toUpperCase()}}` : `\\x${codePoint.toString(16).toUpperCase().padStart(2, "0")}`;
2787
+ const escapeChars = inCharClass ? useFlagV ? CharClassEscapeCharsFlagV : CharClassEscapeChars : BaseEscapeChars;
2788
+ const char = cp(codePoint);
2789
+ return (escapeChars.has(char) ? "\\" : "") + char;
2790
+ }
2791
+ function getCodePointRangesFromChars(chars) {
2792
+ const codePoints = chars.map((char) => char.codePointAt(0)).sort((a, b) => a - b);
2793
+ const values = [];
2794
+ let start = null;
2795
+ for (let i = 0; i < codePoints.length; i++) if (codePoints[i + 1] === codePoints[i] + 1) start ??= codePoints[i];
2796
+ else if (start === null) values.push(codePoints[i]);
2797
+ else {
2798
+ values.push([start, codePoints[i]]);
2799
+ start = null;
2800
+ }
2801
+ return values;
2802
+ }
2803
+ function getGroupPrefix(atomic2, flagMods, useFlagMods) {
2804
+ if (atomic2) return ">";
2805
+ let mods = "";
2806
+ if (flagMods && useFlagMods) {
2807
+ const { enable, disable } = flagMods;
2808
+ mods = (enable?.ignoreCase ? "i" : "") + (enable?.dotAll ? "s" : "") + (disable ? "-" : "") + (disable?.ignoreCase ? "i" : "") + (disable?.dotAll ? "s" : "");
2809
+ }
2810
+ return `${mods}:`;
2811
+ }
2812
+ function getQuantifierStr({ kind, max, min }) {
2813
+ let base;
2814
+ if (!min && max === 1) base = "?";
2815
+ else if (!min && max === Infinity) base = "*";
2816
+ else if (min === 1 && max === Infinity) base = "+";
2817
+ else if (min === max) base = `{${min}}`;
2818
+ else base = `{${min},${max === Infinity ? "" : max}}`;
2819
+ return base + {
2820
+ greedy: "",
2821
+ lazy: "?",
2822
+ possessive: "+"
2823
+ }[kind];
2824
+ }
2825
+ function isAnyGroup({ type }) {
2826
+ return type === "CapturingGroup" || type === "Group" || type === "LookaroundAssertion";
2827
+ }
2828
+ function isDigitCharCode(value) {
2829
+ return value > 47 && value < 58;
2830
+ }
2831
+ function isLiteralHyphen({ type, value }) {
2832
+ return type === "Character" && value === 45;
2833
+ }
2834
+ var EmulatedRegExp = class _EmulatedRegExp extends RegExp {
2835
+ /**
2836
+ @type {Map<number, {
2837
+ hidden?: true;
2838
+ transferTo?: number;
2839
+ }>}
2840
+ */
2841
+ #captureMap = /* @__PURE__ */ new Map();
2842
+ /**
2843
+ @type {RegExp | EmulatedRegExp | null}
2844
+ */
2845
+ #compiled = null;
2846
+ /**
2847
+ @type {string}
2848
+ */
2849
+ #pattern;
2850
+ /**
2851
+ @type {Map<number, string>?}
2852
+ */
2853
+ #nameMap = null;
2854
+ /**
2855
+ @type {string?}
2856
+ */
2857
+ #strategy = null;
2858
+ /**
2859
+ Can be used to serialize the instance.
2860
+ @type {EmulatedRegExpOptions}
2861
+ */
2862
+ rawOptions = {};
2863
+ get source() {
2864
+ return this.#pattern || "(?:)";
2865
+ }
2866
+ /**
2867
+ @overload
2868
+ @param {string} pattern
2869
+ @param {string} [flags]
2870
+ @param {EmulatedRegExpOptions} [options]
2871
+ */
2872
+ /**
2873
+ @overload
2874
+ @param {EmulatedRegExp} pattern
2875
+ @param {string} [flags]
2876
+ */
2877
+ constructor(pattern, flags, options) {
2878
+ const lazyCompile = !!options?.lazyCompile;
2879
+ if (pattern instanceof RegExp) {
2880
+ if (options) throw new Error("Cannot provide options when copying a regexp");
2881
+ const re = pattern;
2882
+ super(re, flags);
2883
+ this.#pattern = re.source;
2884
+ if (re instanceof _EmulatedRegExp) {
2885
+ this.#captureMap = re.#captureMap;
2886
+ this.#nameMap = re.#nameMap;
2887
+ this.#strategy = re.#strategy;
2888
+ this.rawOptions = re.rawOptions;
2889
+ }
2890
+ } else {
2891
+ const opts = {
2892
+ hiddenCaptures: [],
2893
+ strategy: null,
2894
+ transfers: [],
2895
+ ...options
2896
+ };
2897
+ super(lazyCompile ? "" : pattern, flags);
2898
+ this.#pattern = pattern;
2899
+ this.#captureMap = createCaptureMap(opts.hiddenCaptures, opts.transfers);
2900
+ this.#strategy = opts.strategy;
2901
+ this.rawOptions = options ?? {};
2902
+ }
2903
+ if (!lazyCompile) this.#compiled = this;
2904
+ }
2905
+ /**
2906
+ Called internally by all String/RegExp methods that use regexes.
2907
+ @override
2908
+ @param {string} str
2909
+ @returns {RegExpExecArray?}
2910
+ */
2911
+ exec(str) {
2912
+ if (!this.#compiled) {
2913
+ const { lazyCompile, ...rest } = this.rawOptions;
2914
+ this.#compiled = new _EmulatedRegExp(this.#pattern, this.flags, rest);
2915
+ }
2916
+ const useLastIndex = this.global || this.sticky;
2917
+ const pos = this.lastIndex;
2918
+ if (this.#strategy === "clip_search" && useLastIndex && pos) {
2919
+ this.lastIndex = 0;
2920
+ const match = this.#execCore(str.slice(pos));
2921
+ if (match) {
2922
+ adjustMatchDetailsForOffset(match, pos, str, this.hasIndices);
2923
+ this.lastIndex += pos;
2924
+ }
2925
+ return match;
2926
+ }
2927
+ return this.#execCore(str);
2928
+ }
2929
+ /**
2930
+ Adds support for hidden and transfer captures.
2931
+ @param {string} str
2932
+ @returns
2933
+ */
2934
+ #execCore(str) {
2935
+ this.#compiled.lastIndex = this.lastIndex;
2936
+ const match = super.exec.call(this.#compiled, str);
2937
+ this.lastIndex = this.#compiled.lastIndex;
2938
+ if (!match || !this.#captureMap.size) return match;
2939
+ const matchCopy = [...match];
2940
+ match.length = 1;
2941
+ let indicesCopy;
2942
+ if (this.hasIndices) {
2943
+ indicesCopy = [...match.indices];
2944
+ match.indices.length = 1;
2945
+ }
2946
+ const mappedNums = [0];
2947
+ for (let i = 1; i < matchCopy.length; i++) {
2948
+ const { hidden, transferTo } = this.#captureMap.get(i) ?? {};
2949
+ if (hidden) mappedNums.push(null);
2950
+ else {
2951
+ mappedNums.push(match.length);
2952
+ match.push(matchCopy[i]);
2953
+ if (this.hasIndices) match.indices.push(indicesCopy[i]);
2954
+ }
2955
+ if (transferTo && matchCopy[i] !== void 0) {
2956
+ const to = mappedNums[transferTo];
2957
+ if (!to) throw new Error(`Invalid capture transfer to "${to}"`);
2958
+ match[to] = matchCopy[i];
2959
+ if (this.hasIndices) match.indices[to] = indicesCopy[i];
2960
+ if (match.groups) {
2961
+ if (!this.#nameMap) this.#nameMap = createNameMap(this.source);
2962
+ const name = this.#nameMap.get(transferTo);
2963
+ if (name) {
2964
+ match.groups[name] = matchCopy[i];
2965
+ if (this.hasIndices) match.indices.groups[name] = indicesCopy[i];
2966
+ }
2967
+ }
2968
+ }
2969
+ }
2970
+ return match;
2971
+ }
2972
+ };
2973
+ function adjustMatchDetailsForOffset(match, offset, input, hasIndices) {
2974
+ match.index += offset;
2975
+ match.input = input;
2976
+ if (hasIndices) {
2977
+ const indices = match.indices;
2978
+ for (let i = 0; i < indices.length; i++) {
2979
+ const arr = indices[i];
2980
+ if (arr) indices[i] = [arr[0] + offset, arr[1] + offset];
2981
+ }
2982
+ const groupIndices = indices.groups;
2983
+ if (groupIndices) Object.keys(groupIndices).forEach((key) => {
2984
+ const arr = groupIndices[key];
2985
+ if (arr) groupIndices[key] = [arr[0] + offset, arr[1] + offset];
2986
+ });
2987
+ }
2988
+ }
2989
+ function createCaptureMap(hiddenCaptures, transfers) {
2990
+ const captureMap = /* @__PURE__ */ new Map();
2991
+ for (const num of hiddenCaptures) captureMap.set(num, { hidden: true });
2992
+ for (const [to, from] of transfers) for (const num of from) getOrInsert(captureMap, num, {}).transferTo = to;
2993
+ return captureMap;
2994
+ }
2995
+ function createNameMap(pattern) {
2996
+ const re = /(?<capture>\((?:\?<(?![=!])(?<name>[^>]+)>|(?!\?)))|\\?./gsu;
2997
+ const map = /* @__PURE__ */ new Map();
2998
+ let numCharClassesOpen = 0;
2999
+ let numCaptures = 0;
3000
+ let match;
3001
+ while (match = re.exec(pattern)) {
3002
+ const { 0: m, groups: { capture, name } } = match;
3003
+ if (m === "[") numCharClassesOpen++;
3004
+ else if (!numCharClassesOpen) {
3005
+ if (capture) {
3006
+ numCaptures++;
3007
+ if (name) map.set(numCaptures, name);
3008
+ }
3009
+ } else if (m === "]") numCharClassesOpen--;
3010
+ }
3011
+ return map;
3012
+ }
3013
+ function toRegExp(pattern, options) {
3014
+ const d = toRegExpDetails(pattern, options);
3015
+ if (d.options) return new EmulatedRegExp(d.pattern, d.flags, d.options);
3016
+ return new RegExp(d.pattern, d.flags);
3017
+ }
3018
+ function toRegExpDetails(pattern, options) {
3019
+ const opts = getOptions(options);
3020
+ const regexPlusAst = transform(J(pattern, {
3021
+ flags: opts.flags,
3022
+ normalizeUnknownPropertyNames: true,
3023
+ rules: {
3024
+ captureGroup: opts.rules.captureGroup,
3025
+ singleline: opts.rules.singleline
3026
+ },
3027
+ skipBackrefValidation: opts.rules.allowOrphanBackrefs,
3028
+ unicodePropertyMap: JsUnicodePropertyMap
3029
+ }), {
3030
+ accuracy: opts.accuracy,
3031
+ asciiWordBoundaries: opts.rules.asciiWordBoundaries,
3032
+ avoidSubclass: opts.avoidSubclass,
3033
+ bestEffortTarget: opts.target
3034
+ });
3035
+ const generated = generate(regexPlusAst, opts);
3036
+ const recursionResult = recursion(generated.pattern, {
3037
+ captureTransfers: generated._captureTransfers,
3038
+ hiddenCaptures: generated._hiddenCaptures,
3039
+ mode: "external"
3040
+ });
3041
+ const atomicResult = atomic(possessive(recursionResult.pattern).pattern, {
3042
+ captureTransfers: recursionResult.captureTransfers,
3043
+ hiddenCaptures: recursionResult.hiddenCaptures
3044
+ });
3045
+ const details = {
3046
+ pattern: atomicResult.pattern,
3047
+ flags: `${opts.hasIndices ? "d" : ""}${opts.global ? "g" : ""}${generated.flags}${generated.options.disable.v ? "u" : "v"}`
3048
+ };
3049
+ if (opts.avoidSubclass) {
3050
+ if (opts.lazyCompileLength !== Infinity) throw new Error("Lazy compilation requires subclass");
3051
+ } else {
3052
+ const hiddenCaptures = atomicResult.hiddenCaptures.sort((a, b) => a - b);
3053
+ const transfers = Array.from(atomicResult.captureTransfers);
3054
+ const strategy = regexPlusAst._strategy;
3055
+ const lazyCompile = details.pattern.length >= opts.lazyCompileLength;
3056
+ if (hiddenCaptures.length || transfers.length || strategy || lazyCompile) details.options = {
3057
+ ...hiddenCaptures.length && { hiddenCaptures },
3058
+ ...transfers.length && { transfers },
3059
+ ...strategy && { strategy },
3060
+ ...lazyCompile && { lazyCompile }
3061
+ };
3062
+ }
3063
+ return details;
3064
+ }
3065
+ //#endregion
3066
+ //#region ../../node_modules/.pnpm/@shikijs+engine-javascript@4.4.1/node_modules/@shikijs/engine-javascript/dist/engine-compile.mjs
3067
+ /**
3068
+ * The default regex constructor for the JavaScript RegExp engine.
3069
+ */
3070
+ function defaultJavaScriptRegexConstructor(pattern, options) {
3071
+ return toRegExp(pattern, {
3072
+ global: true,
3073
+ hasIndices: true,
3074
+ lazyCompileLength: 3e3,
3075
+ rules: {
3076
+ allowOrphanBackrefs: true,
3077
+ asciiWordBoundaries: true,
3078
+ captureGroup: true,
3079
+ recursionLimit: 5,
3080
+ singleline: true
3081
+ },
3082
+ ...options
3083
+ });
3084
+ }
3085
+ /**
3086
+ * Use the modern JavaScript RegExp engine to implement the OnigScanner.
3087
+ *
3088
+ * As Oniguruma supports some features that can't be emulated using native JavaScript regexes, some
3089
+ * patterns are not supported. Errors will be thrown when parsing TextMate grammars with
3090
+ * unsupported patterns, and when the grammar includes patterns that use invalid Oniguruma syntax.
3091
+ * Set `forgiving` to `true` to ignore these errors and skip any unsupported or invalid patterns.
3092
+ */
3093
+ function createJavaScriptRegexEngine(options = {}) {
3094
+ const _options = {
3095
+ target: "auto",
3096
+ cache: /* @__PURE__ */ new Map(),
3097
+ ...options
3098
+ };
3099
+ _options.regexConstructor ||= (pattern) => defaultJavaScriptRegexConstructor(pattern, { target: _options.target });
3100
+ return {
3101
+ createScanner(patterns) {
3102
+ return new JavaScriptScanner(patterns, _options);
3103
+ },
3104
+ createString(s) {
3105
+ return { content: s };
3106
+ }
3107
+ };
3108
+ }
3109
+ //#endregion
3110
+ export { createJavaScriptRegexEngine as t };