@pierre/diffs 1.3.0-beta.3 → 1.3.0-beta.5

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 (161) hide show
  1. package/README.md +6 -6
  2. package/dist/components/CodeView.js +6 -6
  3. package/dist/components/CodeView.js.map +1 -1
  4. package/dist/components/File.d.ts +3 -2
  5. package/dist/components/File.d.ts.map +1 -1
  6. package/dist/components/File.js +35 -21
  7. package/dist/components/File.js.map +1 -1
  8. package/dist/components/FileDiff.d.ts +8 -4
  9. package/dist/components/FileDiff.d.ts.map +1 -1
  10. package/dist/components/FileDiff.js +66 -56
  11. package/dist/components/FileDiff.js.map +1 -1
  12. package/dist/components/FileStream.js +4 -2
  13. package/dist/components/FileStream.js.map +1 -1
  14. package/dist/components/UnresolvedFile.js +1 -1
  15. package/dist/components/VirtualizedFile.d.ts +6 -2
  16. package/dist/components/VirtualizedFile.d.ts.map +1 -1
  17. package/dist/components/VirtualizedFile.js +89 -24
  18. package/dist/components/VirtualizedFile.js.map +1 -1
  19. package/dist/components/VirtualizedFileDiff.d.ts +8 -2
  20. package/dist/components/VirtualizedFileDiff.d.ts.map +1 -1
  21. package/dist/components/VirtualizedFileDiff.js +91 -15
  22. package/dist/components/VirtualizedFileDiff.js.map +1 -1
  23. package/dist/editor/command.d.ts +1 -1
  24. package/dist/editor/command.d.ts.map +1 -1
  25. package/dist/editor/command.js +3 -3
  26. package/dist/editor/command.js.map +1 -1
  27. package/dist/editor/editStack.d.ts +1 -1
  28. package/dist/editor/editor.d.ts +37 -9
  29. package/dist/editor/editor.d.ts.map +1 -1
  30. package/dist/editor/editor.js +558 -449
  31. package/dist/editor/editor.js.map +1 -1
  32. package/dist/editor/editor2.js +1 -1
  33. package/dist/editor/editor2.js.map +1 -1
  34. package/dist/editor/index.d.ts +2 -2
  35. package/dist/editor/lineAnnotations.d.ts +2 -1
  36. package/dist/editor/lineAnnotations.d.ts.map +1 -1
  37. package/dist/editor/lineAnnotations.js +111 -1
  38. package/dist/editor/lineAnnotations.js.map +1 -1
  39. package/dist/editor/marker.d.ts +33 -0
  40. package/dist/editor/marker.d.ts.map +1 -0
  41. package/dist/editor/marker.js +185 -0
  42. package/dist/editor/marker.js.map +1 -0
  43. package/dist/editor/pieceTable.d.ts +8 -3
  44. package/dist/editor/pieceTable.d.ts.map +1 -1
  45. package/dist/editor/pieceTable.js +74 -12
  46. package/dist/editor/pieceTable.js.map +1 -1
  47. package/dist/editor/searchPanel.d.ts +12 -3
  48. package/dist/editor/searchPanel.d.ts.map +1 -1
  49. package/dist/editor/searchPanel.js +168 -54
  50. package/dist/editor/searchPanel.js.map +1 -1
  51. package/dist/editor/selection.d.ts +19 -3
  52. package/dist/editor/selection.d.ts.map +1 -1
  53. package/dist/editor/selection.js +188 -37
  54. package/dist/editor/selection.js.map +1 -1
  55. package/dist/editor/{quickEdit.d.ts → selectionAction.d.ts} +8 -8
  56. package/dist/editor/selectionAction.d.ts.map +1 -0
  57. package/dist/editor/{quickEdit.js → selectionAction.js} +18 -18
  58. package/dist/editor/selectionAction.js.map +1 -0
  59. package/dist/editor/sprite.d.ts +4 -3
  60. package/dist/editor/sprite.d.ts.map +1 -1
  61. package/dist/editor/sprite.js +19 -5
  62. package/dist/editor/sprite.js.map +1 -1
  63. package/dist/editor/textDocument.d.ts +4 -4
  64. package/dist/editor/textDocument.d.ts.map +1 -1
  65. package/dist/editor/textDocument.js +7 -7
  66. package/dist/editor/textDocument.js.map +1 -1
  67. package/dist/editor/textMeasure.d.ts +1 -0
  68. package/dist/editor/textMeasure.d.ts.map +1 -1
  69. package/dist/editor/textMeasure.js +6 -0
  70. package/dist/editor/textMeasure.js.map +1 -1
  71. package/dist/editor/tokenzier.js +20 -9
  72. package/dist/editor/tokenzier.js.map +1 -1
  73. package/dist/editor/utils.d.ts +3 -1
  74. package/dist/editor/utils.d.ts.map +1 -1
  75. package/dist/editor/utils.js +16 -1
  76. package/dist/editor/utils.js.map +1 -1
  77. package/dist/highlighter/shared_highlighter.js +3 -29
  78. package/dist/highlighter/shared_highlighter.js.map +1 -1
  79. package/dist/highlighter/themes/attachResolvedThemes.js +4 -3
  80. package/dist/highlighter/themes/attachResolvedThemes.js.map +1 -1
  81. package/dist/highlighter/themes/cleanUpResolvedThemes.js +3 -2
  82. package/dist/highlighter/themes/cleanUpResolvedThemes.js.map +1 -1
  83. package/dist/highlighter/themes/constants.d.ts +1 -7
  84. package/dist/highlighter/themes/constants.d.ts.map +1 -1
  85. package/dist/highlighter/themes/constants.js +1 -4
  86. package/dist/highlighter/themes/constants.js.map +1 -1
  87. package/dist/highlighter/themes/getResolvedOrResolveTheme.js +2 -2
  88. package/dist/highlighter/themes/getResolvedOrResolveTheme.js.map +1 -1
  89. package/dist/highlighter/themes/getResolvedThemes.js +2 -8
  90. package/dist/highlighter/themes/getResolvedThemes.js.map +1 -1
  91. package/dist/highlighter/themes/hasResolvedThemes.js +2 -3
  92. package/dist/highlighter/themes/hasResolvedThemes.js.map +1 -1
  93. package/dist/highlighter/themes/registerCustomCSSVariableTheme.js +1 -1
  94. package/dist/highlighter/themes/registerCustomTheme.d.ts +5 -3
  95. package/dist/highlighter/themes/registerCustomTheme.d.ts.map +1 -1
  96. package/dist/highlighter/themes/registerCustomTheme.js +15 -5
  97. package/dist/highlighter/themes/registerCustomTheme.js.map +1 -1
  98. package/dist/highlighter/themes/resolveTheme.js +6 -27
  99. package/dist/highlighter/themes/resolveTheme.js.map +1 -1
  100. package/dist/highlighter/themes/resolveThemes.js +5 -12
  101. package/dist/highlighter/themes/resolveThemes.js.map +1 -1
  102. package/dist/highlighter/themes/themeResolution.d.ts +8 -0
  103. package/dist/highlighter/themes/themeResolution.d.ts.map +1 -0
  104. package/dist/highlighter/themes/themeResolution.js +22 -0
  105. package/dist/highlighter/themes/themeResolution.js.map +1 -0
  106. package/dist/highlighter/themes/themeResolver.d.ts +8 -0
  107. package/dist/highlighter/themes/themeResolver.d.ts.map +1 -0
  108. package/dist/highlighter/themes/themeResolver.js +8 -0
  109. package/dist/highlighter/themes/themeResolver.js.map +1 -0
  110. package/dist/index.d.ts +4 -4
  111. package/dist/index.js +3 -3
  112. package/dist/managers/InteractionManager.js +1 -1
  113. package/dist/managers/InteractionManager.js.map +1 -1
  114. package/dist/managers/ResizeManager.js +1 -1
  115. package/dist/managers/ResizeManager.js.map +1 -1
  116. package/dist/react/CodeView.js +1 -1
  117. package/dist/react/index.d.ts +2 -2
  118. package/dist/react/utils/useFileDiffInstance.js +1 -0
  119. package/dist/react/utils/useFileDiffInstance.js.map +1 -1
  120. package/dist/renderers/DiffHunksRenderer.d.ts +6 -2
  121. package/dist/renderers/DiffHunksRenderer.d.ts.map +1 -1
  122. package/dist/renderers/DiffHunksRenderer.js +183 -12
  123. package/dist/renderers/DiffHunksRenderer.js.map +1 -1
  124. package/dist/renderers/FileRenderer.d.ts +2 -2
  125. package/dist/renderers/FileRenderer.d.ts.map +1 -1
  126. package/dist/renderers/FileRenderer.js +17 -5
  127. package/dist/renderers/FileRenderer.js.map +1 -1
  128. package/dist/ssr/FileDiffReact.js +1 -1
  129. package/dist/ssr/index.d.ts +2 -2
  130. package/dist/types.d.ts +25 -8
  131. package/dist/types.d.ts.map +1 -1
  132. package/dist/utils/getHighlighterThemeStyles.js +16 -12
  133. package/dist/utils/getHighlighterThemeStyles.js.map +1 -1
  134. package/dist/utils/includesFileAnnotations.d.ts +17 -0
  135. package/dist/utils/includesFileAnnotations.d.ts.map +1 -0
  136. package/dist/utils/includesFileAnnotations.js +19 -0
  137. package/dist/utils/includesFileAnnotations.js.map +1 -0
  138. package/dist/utils/parseMergeConflictDiffFromFile.js.map +1 -1
  139. package/dist/utils/parsePatchFiles.js +93 -4
  140. package/dist/utils/parsePatchFiles.js.map +1 -1
  141. package/dist/utils/renderDiffWithHighlighter.js +4 -2
  142. package/dist/utils/renderDiffWithHighlighter.js.map +1 -1
  143. package/dist/utils/renderFileWithHighlighter.js +4 -2
  144. package/dist/utils/renderFileWithHighlighter.js.map +1 -1
  145. package/dist/utils/updateDiffHunks.d.ts +13 -0
  146. package/dist/utils/updateDiffHunks.d.ts.map +1 -0
  147. package/dist/utils/updateDiffHunks.js +171 -0
  148. package/dist/utils/updateDiffHunks.js.map +1 -0
  149. package/dist/utils/virtualDiffLayout.d.ts +2 -1
  150. package/dist/utils/virtualDiffLayout.d.ts.map +1 -1
  151. package/dist/utils/virtualDiffLayout.js +9 -1
  152. package/dist/utils/virtualDiffLayout.js.map +1 -1
  153. package/dist/worker/{wasm-BaDzIkIn.js → wasm-qE0LgnY3.js} +2 -2
  154. package/dist/worker/{wasm-BaDzIkIn.js.map → wasm-qE0LgnY3.js.map} +1 -1
  155. package/dist/worker/worker-portable.js +1016 -275
  156. package/dist/worker/worker-portable.js.map +1 -1
  157. package/dist/worker/worker.js +31 -19
  158. package/dist/worker/worker.js.map +1 -1
  159. package/package.json +5 -10
  160. package/dist/editor/quickEdit.d.ts.map +0 -1
  161. package/dist/editor/quickEdit.js.map +0 -1
@@ -10,42 +10,34 @@ var __export = (all$1) => {
10
10
  };
11
11
 
12
12
  //#endregion
13
- //#region ../../node_modules/.bun/shiki@4.0.2/node_modules/shiki/dist/chunk-CtajNgzt.mjs
13
+ //#region ../../node_modules/.bun/shiki@4.2.0/node_modules/shiki/dist/chunk-BBjsoOtd.mjs
14
14
  var __defProp$1 = Object.defineProperty;
15
15
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
16
16
  var __getOwnPropNames = Object.getOwnPropertyNames;
17
17
  var __hasOwnProp = Object.prototype.hasOwnProperty;
18
18
  var __exportAll = (all$1, no_symbols) => {
19
19
  let target = {};
20
- for (var name in all$1) {
21
- __defProp$1(target, name, {
22
- get: all$1[name],
23
- enumerable: true
24
- });
25
- }
26
- if (!no_symbols) {
27
- __defProp$1(target, Symbol.toStringTag, { value: "Module" });
28
- }
20
+ for (var name in all$1) __defProp$1(target, name, {
21
+ get: all$1[name],
22
+ enumerable: true
23
+ });
24
+ if (!no_symbols) __defProp$1(target, Symbol.toStringTag, { value: "Module" });
29
25
  return target;
30
26
  };
31
27
  var __copyProps = (to, from, except, desc) => {
32
- if (from && typeof from === "object" || typeof from === "function") {
33
- for (var keys = __getOwnPropNames(from), i$2 = 0, n = keys.length, key$1; i$2 < n; i$2++) {
34
- key$1 = keys[i$2];
35
- if (!__hasOwnProp.call(to, key$1) && key$1 !== except) {
36
- __defProp$1(to, key$1, {
37
- get: ((k$2) => from[k$2]).bind(null, key$1),
38
- enumerable: !(desc = __getOwnPropDesc(from, key$1)) || desc.enumerable
39
- });
40
- }
41
- }
28
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i$2 = 0, n = keys.length, key$1; i$2 < n; i$2++) {
29
+ key$1 = keys[i$2];
30
+ if (!__hasOwnProp.call(to, key$1) && key$1 !== except) __defProp$1(to, key$1, {
31
+ get: ((k$2) => from[k$2]).bind(null, key$1),
32
+ enumerable: !(desc = __getOwnPropDesc(from, key$1)) || desc.enumerable
33
+ });
42
34
  }
43
35
  return to;
44
36
  };
45
37
  var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
46
38
 
47
39
  //#endregion
48
- //#region ../../node_modules/.bun/@shikijs+types@4.0.2/node_modules/@shikijs/types/dist/index.mjs
40
+ //#region ../../node_modules/.bun/@shikijs+types@4.2.0/node_modules/@shikijs/types/dist/index.mjs
49
41
  var ShikiError$1 = class extends Error {
50
42
  constructor(message) {
51
43
  super(message);
@@ -2911,7 +2903,7 @@ var Registry = class {
2911
2903
  var INITIAL = StateStackImpl.NULL;
2912
2904
 
2913
2905
  //#endregion
2914
- //#region ../../node_modules/.bun/@shikijs+primitive@4.0.2/node_modules/@shikijs/primitive/dist/index.mjs
2906
+ //#region ../../node_modules/.bun/@shikijs+primitive@4.2.0/node_modules/@shikijs/primitive/dist/index.mjs
2915
2907
  function resolveColorReplacements(theme, options) {
2916
2908
  const replacements = typeof theme === "string" ? {} : { ...theme.colorReplacements };
2917
2909
  const themeName = typeof theme === "string" ? theme : theme.name;
@@ -2923,8 +2915,8 @@ function applyColorReplacements(color, replacements) {
2923
2915
  if (!color) return color;
2924
2916
  return replacements?.[color?.toLowerCase()] || color;
2925
2917
  }
2926
- function toArray(x$1) {
2927
- return Array.isArray(x$1) ? x$1 : [x$1];
2918
+ function toArray(x$2) {
2919
+ return Array.isArray(x$2) ? x$2 : [x$2];
2928
2920
  }
2929
2921
  /**
2930
2922
  * Normalize a getter to a promise.
@@ -2985,9 +2977,10 @@ function isSpecialTheme(theme) {
2985
2977
  * // => [['hello\n', 0], ['world', 6]]
2986
2978
  * ```
2987
2979
  */
2980
+ const RE_NEWLINE = /(\r?\n)/g;
2988
2981
  function splitLines$1(code, preserveEnding = false) {
2989
2982
  if (code.length === 0) return [["", 0]];
2990
- const parts = code.split(/(\r?\n)/g);
2983
+ const parts = code.split(RE_NEWLINE);
2991
2984
  let index = 0;
2992
2985
  const lines = [];
2993
2986
  for (let i$2 = 0; i$2 < parts.length; i$2 += 2) {
@@ -3101,7 +3094,7 @@ function normalizeTheme(rawTheme) {
3101
3094
  * Resolve
3102
3095
  */
3103
3096
  async function resolveLangs(langs) {
3104
- return Array.from(new Set((await Promise.all(langs.filter((l$2) => !isSpecialLang(l$2)).map(async (lang) => await normalizeGetter(lang).then((r$3) => Array.isArray(r$3) ? r$3 : [r$3])))).flat()));
3097
+ return [...new Set((await Promise.all(langs.filter((l$2) => !isSpecialLang(l$2)).map(async (lang) => await normalizeGetter(lang).then((r$3) => Array.isArray(r$3) ? r$3 : [r$3])))).flat())];
3105
3098
  }
3106
3099
  async function resolveThemes(themes) {
3107
3100
  return (await Promise.all(themes.map(async (theme) => isSpecialTheme(theme) ? null : normalizeTheme(await normalizeGetter(theme))))).filter((i$2) => !!i$2);
@@ -3112,13 +3105,17 @@ function resolveLangAlias(name, alias) {
3112
3105
  const resolved = new Set([name]);
3113
3106
  while (alias[name]) {
3114
3107
  name = alias[name];
3115
- if (resolved.has(name)) throw new ShikiError$1(`Circular alias \`${Array.from(resolved).join(" -> ")} -> ${name}\``);
3108
+ if (resolved.has(name)) throw new ShikiError$1(`Circular alias \`${[...resolved].join(" -> ")} -> ${name}\``);
3116
3109
  resolved.add(name);
3117
3110
  }
3118
3111
  }
3119
3112
  return name;
3120
3113
  }
3121
3114
  var Registry$1 = class extends Registry {
3115
+ _resolver;
3116
+ _themes;
3117
+ _langs;
3118
+ _alias;
3122
3119
  _resolvedThemes = /* @__PURE__ */ new Map();
3123
3120
  _resolvedGrammars = /* @__PURE__ */ new Map();
3124
3121
  _langMap = /* @__PURE__ */ new Map();
@@ -3197,7 +3194,7 @@ var Registry$1 = class extends Registry {
3197
3194
  }
3198
3195
  loadLanguages(langs) {
3199
3196
  for (const lang of langs) this.resolveEmbeddedLanguages(lang);
3200
- const langsGraphArray = Array.from(this._langGraph.entries());
3197
+ const langsGraphArray = [...this._langGraph.entries()];
3201
3198
  const missingLangs = langsGraphArray.filter(([_$2, lang]) => !lang);
3202
3199
  if (missingLangs.length) {
3203
3200
  const dependents = langsGraphArray.filter(([_$2, lang]) => {
@@ -3463,6 +3460,8 @@ function getGrammarStack(state, theme) {
3463
3460
  if (!(state instanceof GrammarState)) throw new ShikiError$1("Invalid grammar state");
3464
3461
  return state.getInternalStack(theme);
3465
3462
  }
3463
+ const RE_COMMA = /,/;
3464
+ const RE_SPACE = / /;
3466
3465
  /**
3467
3466
  * Code to tokens, with a simple theme.
3468
3467
  */
@@ -3553,7 +3552,7 @@ function _tokenizeWithTheme(code, grammar, theme, colorMap, options) {
3553
3552
  let selectors;
3554
3553
  switch (typeof setting.scope) {
3555
3554
  case "string":
3556
- selectors = setting.scope.split(/,/).map((scope) => scope.trim());
3555
+ selectors = setting.scope.split(RE_COMMA).map((scope) => scope.trim());
3557
3556
  break;
3558
3557
  case "object":
3559
3558
  selectors = setting.scope;
@@ -3562,7 +3561,7 @@ function _tokenizeWithTheme(code, grammar, theme, colorMap, options) {
3562
3561
  }
3563
3562
  themeSettingsSelectors.push({
3564
3563
  settings: setting,
3565
- selectors: selectors.map((selector) => selector.split(/ /))
3564
+ selectors: selectors.map((selector) => selector.split(RE_SPACE))
3566
3565
  });
3567
3566
  }
3568
3567
  token$1.explanation = [];
@@ -3607,7 +3606,7 @@ function matchesOne(selector, scope) {
3607
3606
  return selector === scope || scope.substring(0, selector.length) === selector && scope[selector.length] === ".";
3608
3607
  }
3609
3608
  function matches(selectors, scope, parentScopes) {
3610
- if (!matchesOne(selectors[selectors.length - 1], scope)) return false;
3609
+ if (!matchesOne(selectors.at(-1), scope)) return false;
3611
3610
  let selectorParentIndex = selectors.length - 2;
3612
3611
  let parentIndex = parentScopes.length - 1;
3613
3612
  while (selectorParentIndex >= 0 && parentIndex >= 0) {
@@ -6523,7 +6522,7 @@ function serializeAttributes(state, properties) {
6523
6522
  */
6524
6523
  function serializeAttribute(state, key$1, value) {
6525
6524
  const info = find(state.schema, key$1);
6526
- const x$1 = state.settings.allowParseErrors && state.schema.space === "html" ? 0 : 1;
6525
+ const x$2 = state.settings.allowParseErrors && state.schema.space === "html" ? 0 : 1;
6527
6526
  const y$2 = state.settings.allowDangerousCharacters ? 0 : 1;
6528
6527
  let quote = state.quote;
6529
6528
  /** @type {string | undefined} */
@@ -6536,14 +6535,14 @@ function serializeAttribute(state, key$1, value) {
6536
6535
  if (value === null || value === undefined || value === false || typeof value === "number" && Number.isNaN(value)) {
6537
6536
  return "";
6538
6537
  }
6539
- const name = stringifyEntities(info.attribute, Object.assign({}, state.settings.characterReferences, { subset: constants.name[x$1][y$2] }));
6538
+ const name = stringifyEntities(info.attribute, Object.assign({}, state.settings.characterReferences, { subset: constants.name[x$2][y$2] }));
6540
6539
  if (value === true) return name;
6541
6540
  value = Array.isArray(value) ? (info.commaSeparated ? stringify$1 : stringify$2)(value, { padLeft: !state.settings.tightCommaSeparatedLists }) : String(value);
6542
6541
  if (state.settings.collapseEmptyAttributes && !value) return name;
6543
6542
  if (state.settings.preferUnquoted) {
6544
6543
  result = stringifyEntities(value, Object.assign({}, state.settings.characterReferences, {
6545
6544
  attribute: true,
6546
- subset: constants.unquoted[x$1][y$2]
6545
+ subset: constants.unquoted[x$2][y$2]
6547
6546
  }));
6548
6547
  }
6549
6548
  if (result !== value) {
@@ -6551,7 +6550,7 @@ function serializeAttribute(state, key$1, value) {
6551
6550
  quote = state.alternative;
6552
6551
  }
6553
6552
  result = quote + stringifyEntities(value, Object.assign({}, state.settings.characterReferences, {
6554
- subset: (quote === "'" ? constants.single : constants.double)[x$1][y$2],
6553
+ subset: (quote === "'" ? constants.single : constants.double)[x$2][y$2],
6555
6554
  attribute: true
6556
6555
  })) + quote;
6557
6556
  }
@@ -6759,7 +6758,8 @@ function all(parent) {
6759
6758
  }
6760
6759
 
6761
6760
  //#endregion
6762
- //#region ../../node_modules/.bun/@shikijs+core@4.0.2/node_modules/@shikijs/core/dist/index.mjs
6761
+ //#region ../../node_modules/.bun/@shikijs+core@4.2.0/node_modules/@shikijs/core/dist/index.mjs
6762
+ const RE_WHITESPACE = /\s+/g;
6763
6763
  /**
6764
6764
  * Utility to append class to a hast node
6765
6765
  *
@@ -6769,12 +6769,16 @@ function addClassToHast(node, className) {
6769
6769
  if (!className) return node;
6770
6770
  node.properties ||= {};
6771
6771
  node.properties.class ||= [];
6772
- if (typeof node.properties.class === "string") node.properties.class = node.properties.class.split(/\s+/g);
6772
+ if (typeof node.properties.class === "string") node.properties.class = node.properties.class.split(RE_WHITESPACE);
6773
6773
  if (!Array.isArray(node.properties.class)) node.properties.class = [];
6774
- const targets = Array.isArray(className) ? className : className.split(/\s+/g);
6774
+ const targets = Array.isArray(className) ? className : className.split(RE_WHITESPACE);
6775
6775
  for (const c of targets) if (c && !node.properties.class.includes(c)) node.properties.class.push(c);
6776
6776
  return node;
6777
6777
  }
6778
+ const RE_LANG_ATTR = /:?lang=["']([^"']+)["']/g;
6779
+ const RE_CODE_FENCE = /(?:```|~~~)([\w-]+)/g;
6780
+ const RE_LATEX_BEGIN = /\\begin\{([\w-]+)\}/g;
6781
+ const RE_SCRIPT_LANG = /<script\s+(?:type|lang)=["']([^"']+)["']/gi;
6778
6782
  /**
6779
6783
  * Creates a converter between index and position in a code block.
6780
6784
  *
@@ -6785,7 +6789,7 @@ function createPositionConverter(code) {
6785
6789
  function indexToPos(index) {
6786
6790
  if (index === code.length) return {
6787
6791
  line: lines.length - 1,
6788
- character: lines[lines.length - 1].length
6792
+ character: lines.at(-1).length
6789
6793
  };
6790
6794
  let character = index;
6791
6795
  let line = 0;
@@ -6832,28 +6836,27 @@ function createPositionConverter(code) {
6832
6836
  */
6833
6837
  function guessEmbeddedLanguages(code, _lang, highlighter$1) {
6834
6838
  const langs = /* @__PURE__ */ new Set();
6835
- for (const match of code.matchAll(/:?lang=["']([^"']+)["']/g)) {
6839
+ for (const match of code.matchAll(RE_LANG_ATTR)) {
6836
6840
  const lang = match[1].toLowerCase().trim();
6837
6841
  if (lang) langs.add(lang);
6838
6842
  }
6839
- for (const match of code.matchAll(/(?:```|~~~)([\w-]+)/g)) {
6843
+ for (const match of code.matchAll(RE_CODE_FENCE)) {
6840
6844
  const lang = match[1].toLowerCase().trim();
6841
6845
  if (lang) langs.add(lang);
6842
6846
  }
6843
- for (const match of code.matchAll(/\\begin\{([\w-]+)\}/g)) {
6847
+ for (const match of code.matchAll(RE_LATEX_BEGIN)) {
6844
6848
  const lang = match[1].toLowerCase().trim();
6845
6849
  if (lang) langs.add(lang);
6846
6850
  }
6847
- for (const match of code.matchAll(/<script\s+(?:type|lang)=["']([^"']+)["']/gi)) {
6851
+ for (const match of code.matchAll(RE_SCRIPT_LANG)) {
6848
6852
  const fullType = match[1].toLowerCase().trim();
6849
6853
  const lang = fullType.includes("/") ? fullType.split("/").pop() : fullType;
6850
6854
  if (lang) langs.add(lang);
6851
6855
  }
6852
- if (!highlighter$1) return Array.from(langs);
6856
+ if (!highlighter$1) return [...langs];
6853
6857
  const bundle = highlighter$1.getBundledLanguages();
6854
- return Array.from(langs).filter((l$2) => l$2 && bundle[l$2]);
6858
+ return [...langs].filter((l$2) => l$2 && bundle[l$2]);
6855
6859
  }
6856
- const DEFAULT_COLOR_LIGHT_DARK = "light-dark()";
6857
6860
  const COLOR_KEYS = ["color", "background-color"];
6858
6861
  /**
6859
6862
  * Split a token into multiple tokens by given offsets.
@@ -6882,7 +6885,7 @@ function splitToken(token$1, offsets) {
6882
6885
  * Split 2D tokens array by given breakpoints.
6883
6886
  */
6884
6887
  function splitTokens(tokens, breakpoints) {
6885
- const sorted = Array.from(breakpoints instanceof Set ? breakpoints : new Set(breakpoints)).sort((a$1, b$2) => a$1 - b$2);
6888
+ const sorted = [...breakpoints instanceof Set ? breakpoints : new Set(breakpoints)].sort((a$1, b$2) => a$1 - b$2);
6886
6889
  if (!sorted.length) return tokens;
6887
6890
  return tokens.map((line) => {
6888
6891
  return line.flatMap((token$1) => {
@@ -6908,7 +6911,7 @@ function flatTokenVariants(merged, variantsOrder, cssVariablePrefix, defaultColo
6908
6911
  styles.forEach((cur, idx) => {
6909
6912
  for (const key$1 of styleKeys) {
6910
6913
  const value = cur[key$1] || "inherit";
6911
- if (idx === 0 && defaultColor && COLOR_KEYS.includes(key$1)) if (defaultColor === DEFAULT_COLOR_LIGHT_DARK && styles.length > 1) {
6914
+ if (idx === 0 && defaultColor && COLOR_KEYS.includes(key$1)) if (defaultColor === "light-dark()" && styles.length > 1) {
6912
6915
  const lightIndex = variantsOrder.findIndex((t) => t === "light");
6913
6916
  const darkIndex = variantsOrder.findIndex((t) => t === "dark");
6914
6917
  if (lightIndex === -1 || darkIndex === -1) throw new ShikiError$1("When using `defaultColor: \"light-dark()\"`, you must provide both `light` and `dark` themes");
@@ -6990,7 +6993,7 @@ function transformerDecorations() {
6990
6993
  code(codeEl) {
6991
6994
  if (!this.options.decorations?.length) return;
6992
6995
  const ctx = getContext(this);
6993
- const lines = Array.from(codeEl.children).filter((i$2) => i$2.type === "element" && i$2.tagName === "span");
6996
+ const lines = [...codeEl.children].filter((i$2) => i$2.type === "element" && i$2.tagName === "span");
6994
6997
  if (lines.length !== ctx.converter.lines.length) throw new ShikiError$1(`Number of lines in code element (${lines.length}) does not match the number of lines in the source (${ctx.converter.lines.length}). Failed to apply decorations.`);
6995
6998
  function applyLineSection(line, start, end, decoration) {
6996
6999
  const lineEl = lines[line];
@@ -7150,8 +7153,8 @@ function findSequence(value, position) {
7150
7153
  function parseColor(sequence) {
7151
7154
  const colorMode = sequence.shift();
7152
7155
  if (colorMode === "2") {
7153
- const rgb = sequence.splice(0, 3).map((x$1) => Number.parseInt(x$1));
7154
- if (rgb.length !== 3 || rgb.some((x$1) => Number.isNaN(x$1))) return;
7156
+ const rgb = sequence.splice(0, 3).map((x$2) => Number.parseInt(x$2));
7157
+ if (rgb.length !== 3 || rgb.some((x$2) => Number.isNaN(x$2))) return;
7155
7158
  return {
7156
7159
  type: "rgb",
7157
7160
  rgb
@@ -7299,7 +7302,7 @@ function createColorPalette(namedColorsMap = defaultNamedColorsMap) {
7299
7302
  return namedColorsMap[name];
7300
7303
  }
7301
7304
  function rgbColor(rgb) {
7302
- return `#${rgb.map((x$1) => Math.max(0, Math.min(x$1, 255)).toString(16).padStart(2, "0")).join("")}`;
7305
+ return `#${rgb.map((x$2) => Math.max(0, Math.min(x$2, 255)).toString(16).padStart(2, "0")).join("")}`;
7303
7306
  }
7304
7307
  let colorTable;
7305
7308
  function getColorTable() {
@@ -7339,6 +7342,8 @@ function createColorPalette(namedColorsMap = defaultNamedColorsMap) {
7339
7342
  }
7340
7343
  return { value };
7341
7344
  }
7345
+ const RE_HEX_COLOR = /#([0-9a-f]{3,8})/i;
7346
+ const RE_CSS_VAR_ANSI = /var\((--[\w-]+-ansi-[\w-]+)\)/;
7342
7347
  /**
7343
7348
  * Default ANSI palette (VSCode compatible fallbacks)
7344
7349
  * Used when the theme does not define terminal.ansi* colors.
@@ -7400,7 +7405,7 @@ function tokenizeAnsiWithTheme(theme, fileContents, options) {
7400
7405
  * Adds 50% alpha to a hex color string or the "-dim" postfix to a CSS variable
7401
7406
  */
7402
7407
  function dimColor(color) {
7403
- const hexMatch = color.match(/#([0-9a-f]{3,8})/i);
7408
+ const hexMatch = color.match(RE_HEX_COLOR);
7404
7409
  if (hexMatch) {
7405
7410
  const hex = hexMatch[1];
7406
7411
  if (hex.length === 8) {
@@ -7420,7 +7425,7 @@ function dimColor(color) {
7420
7425
  return `#${r$3}${r$3}${g}${g}${b$2}${b$2}80`;
7421
7426
  }
7422
7427
  }
7423
- const cssVarMatch = color.match(/var\((--[\w-]+-ansi-[\w-]+)\)/);
7428
+ const cssVarMatch = color.match(RE_CSS_VAR_ANSI);
7424
7429
  if (cssVarMatch) return `var(${cssVarMatch[1]}-dim)`;
7425
7430
  return color;
7426
7431
  }
@@ -7458,7 +7463,7 @@ function codeToTokens(primitive, code, options) {
7458
7463
  if (themes.length === 0) throw new ShikiError$1("`themes` option must not be empty");
7459
7464
  const themeTokens = codeToTokensWithThemes(primitive, code, options, codeToTokensBase$1);
7460
7465
  grammarState = getLastGrammarStateFromMap(themeTokens);
7461
- if (defaultColor && DEFAULT_COLOR_LIGHT_DARK !== defaultColor && !themes.find((t) => t.color === defaultColor)) throw new ShikiError$1(`\`themes\` option must contain the defaultColor key \`${defaultColor}\``);
7466
+ if (defaultColor && "light-dark()" !== defaultColor && !themes.some((t) => t.color === defaultColor)) throw new ShikiError$1(`\`themes\` option must contain the defaultColor key \`${defaultColor}\``);
7462
7467
  const themeRegs = themes.map((t) => primitive.getTheme(t.theme));
7463
7468
  const themesOrder = themes.map((t) => t.color);
7464
7469
  tokens = themeTokens.map((line) => line.map((token$1) => flatTokenVariants(token$1, themesOrder, cssVariablePrefix, defaultColor, colorsRendering)));
@@ -7491,7 +7496,7 @@ function mapThemeColors(themes, themeRegs, themeColorReplacements, cssVariablePr
7491
7496
  const value = applyColorReplacements(themeRegs[idx][property], themeColorReplacements[idx]) || "inherit";
7492
7497
  const cssVar = `${cssVariablePrefix + t.color}${property === "bg" ? "-bg" : ""}:${value}`;
7493
7498
  if (idx === 0 && defaultColor) {
7494
- if (defaultColor === DEFAULT_COLOR_LIGHT_DARK && themes.length > 1) {
7499
+ if (defaultColor === "light-dark()" && themes.length > 1) {
7495
7500
  const lightIndex = themes.findIndex((t$1) => t$1.color === "light");
7496
7501
  const darkIndex = themes.findIndex((t$1) => t$1.color === "dark");
7497
7502
  if (lightIndex === -1 || darkIndex === -1) throw new ShikiError$1("When using `defaultColor: \"light-dark()\"`, you must provide both `light` and `dark` themes");
@@ -7503,6 +7508,8 @@ function mapThemeColors(themes, themeRegs, themeColorReplacements, cssVariablePr
7503
7508
  return null;
7504
7509
  }).filter((i$2) => !!i$2).join(";");
7505
7510
  }
7511
+ const RE_WHITESPACE_ONLY = /^\s+$/;
7512
+ const RE_LEADING_TRAILING_WHITESPACE = /^(\s*)(.*?)(\s*)$/;
7506
7513
  function codeToHast(primitive, code, options, transformerContext = {
7507
7514
  meta: {},
7508
7515
  options,
@@ -7681,7 +7688,7 @@ function mergeWhitespaceTokens(tokens) {
7681
7688
  let firstOffset;
7682
7689
  line.forEach((token$1, idx) => {
7683
7690
  const couldMerge = !(token$1.fontStyle && (token$1.fontStyle & FontStyle.Underline || token$1.fontStyle & FontStyle.Strikethrough));
7684
- if (couldMerge && token$1.content.match(/^\s+$/) && line[idx + 1]) {
7691
+ if (couldMerge && RE_WHITESPACE_ONLY.test(token$1.content) && line[idx + 1]) {
7685
7692
  if (firstOffset === void 0) firstOffset = token$1.offset;
7686
7693
  carryOnContent += token$1.content;
7687
7694
  } else if (carryOnContent) {
@@ -7704,8 +7711,8 @@ function mergeWhitespaceTokens(tokens) {
7704
7711
  function splitWhitespaceTokens(tokens) {
7705
7712
  return tokens.map((line) => {
7706
7713
  return line.flatMap((token$1) => {
7707
- if (token$1.content.match(/^\s+$/)) return token$1;
7708
- const match = token$1.content.match(/^(\s*)(.*?)(\s*)$/);
7714
+ if (RE_WHITESPACE_ONLY.test(token$1.content)) return token$1;
7715
+ const match = token$1.content.match(RE_LEADING_TRAILING_WHITESPACE);
7709
7716
  if (!match) return token$1;
7710
7717
  const [, leading, content, trailing] = match;
7711
7718
  if (!leading && !trailing) return token$1;
@@ -7734,7 +7741,7 @@ function mergeAdjacentStyledTokens(tokens) {
7734
7741
  newLine.push({ ...token$1 });
7735
7742
  continue;
7736
7743
  }
7737
- const prevToken = newLine[newLine.length - 1];
7744
+ const prevToken = newLine.at(-1);
7738
7745
  const prevStyle = stringifyTokenStyle(prevToken.htmlStyle || getTokenStyleObject(prevToken));
7739
7746
  const currentStyle = stringifyTokenStyle(token$1.htmlStyle || getTokenStyleObject(token$1));
7740
7747
  const isPrevDecorated = prevToken.fontStyle && (prevToken.fontStyle & FontStyle.Underline || prevToken.fontStyle & FontStyle.Strikethrough);
@@ -8126,18 +8133,20 @@ function createCssVariablesTheme(options = {}) {
8126
8133
  }
8127
8134
 
8128
8135
  //#endregion
8129
- //#region ../../node_modules/.bun/@shikijs+engine-javascript@4.0.2/node_modules/@shikijs/engine-javascript/dist/scanner-BFcBmQR1.mjs
8136
+ //#region ../../node_modules/.bun/@shikijs+engine-javascript@4.2.0/node_modules/@shikijs/engine-javascript/dist/scanner-DX8LRFGE.mjs
8130
8137
  const MAX = 4294967295;
8131
8138
  var JavaScriptScanner = class {
8139
+ patterns;
8140
+ options;
8132
8141
  regexps;
8133
8142
  constructor(patterns, options = {}) {
8134
8143
  this.patterns = patterns;
8135
8144
  this.options = options;
8136
- const { forgiving = false, cache, regexConstructor } = options;
8145
+ const { forgiving = false, cache: cache$1, regexConstructor } = options;
8137
8146
  if (!regexConstructor) throw new Error("Option `regexConstructor` is not provided");
8138
8147
  this.regexps = patterns.map((p$1) => {
8139
8148
  if (typeof p$1 !== "string") return p$1;
8140
- const cached = cache?.get(p$1);
8149
+ const cached = cache$1?.get(p$1);
8141
8150
  if (cached) {
8142
8151
  if (cached instanceof RegExp) return cached;
8143
8152
  if (forgiving) return null;
@@ -8145,10 +8154,10 @@ var JavaScriptScanner = class {
8145
8154
  }
8146
8155
  try {
8147
8156
  const regex = regexConstructor(p$1);
8148
- cache?.set(p$1, regex);
8157
+ cache$1?.set(p$1, regex);
8149
8158
  return regex;
8150
8159
  } catch (e) {
8151
- cache?.set(p$1, e);
8160
+ cache$1?.set(p$1, e);
8152
8161
  if (forgiving) return null;
8153
8162
  throw e;
8154
8163
  }
@@ -8201,7 +8210,7 @@ var JavaScriptScanner = class {
8201
8210
  };
8202
8211
 
8203
8212
  //#endregion
8204
- //#region ../../node_modules/.bun/oniguruma-parser@0.12.1/node_modules/oniguruma-parser/dist/utils.js
8213
+ //#region ../../node_modules/.bun/oniguruma-parser@0.12.2/node_modules/oniguruma-parser/dist/utils.js
8205
8214
  function r$2(e) {
8206
8215
  if ([...e].length !== 1) throw new Error(`Expected "${e}" to be a single code point`);
8207
8216
  return e.codePointAt(0);
@@ -8231,7 +8240,7 @@ function u(e, t) {
8231
8240
  }
8232
8241
 
8233
8242
  //#endregion
8234
- //#region ../../node_modules/.bun/oniguruma-parser@0.12.1/node_modules/oniguruma-parser/dist/tokenizer/tokenize.js
8243
+ //#region ../../node_modules/.bun/oniguruma-parser@0.12.2/node_modules/oniguruma-parser/dist/tokenizer/tokenize.js
8235
8244
  const m$1 = o$1`\[\^?`, 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}`}`, y$1 = /[?*+][?+]?|\{(?:\d+(?:,\d*)?|,\d+)\}\??/, C$1 = new RegExp(o$1`
8236
8245
  \\ (?:
8237
8246
  ${b$1}
@@ -8333,7 +8342,7 @@ function F$1(e, n, t, o$2) {
8333
8342
  if (a$1 === "N" || a$1 === "R") return { token: k$1("newline", t, { negate: a$1 === "N" }) };
8334
8343
  if (a$1 === "O") return { token: k$1("any", t) };
8335
8344
  if (a$1 === "X") return { token: k$1("text_segment", t) };
8336
- const r$3 = x(t, { inCharClass: !1 });
8345
+ const r$3 = x$1(t, { inCharClass: !1 });
8337
8346
  return Array.isArray(r$3) ? { tokens: r$3 } : { token: r$3 };
8338
8347
  }
8339
8348
  if (s$1 === "(") {
@@ -8344,13 +8353,13 @@ function F$1(e, n, t, o$2) {
8344
8353
  return { lastIndex: o$2 + 1 };
8345
8354
  }
8346
8355
  if (/^\(\?[-imx]+[:)]$/.test(t)) return { token: L$1(t, e) };
8347
- if (e.pushModX(e.getCurrentModX()), e.numOpenGroups++, t === "(" && !e.captureGroup || t === "(?:") return { token: f$1("group", t) };
8348
- if (t === "(?>") return { token: f$1("atomic", t) };
8349
- if (t === "(?=" || t === "(?!" || t === "(?<=" || t === "(?<!") return { token: f$1(t[2] === "<" ? "lookbehind" : "lookahead", t, { negate: t.endsWith("!") }) };
8350
- if (t === "(" && e.captureGroup || t.startsWith("(?<") && t.endsWith(">") || t.startsWith("(?'") && t.endsWith("'")) return { token: f$1("capturing", t, { ...t !== "(" && { name: t.slice(3, -1) } }) };
8356
+ if (e.pushModX(e.getCurrentModX()), e.numOpenGroups++, t === "(" && !e.captureGroup || t === "(?:") return { token: f("group", t) };
8357
+ if (t === "(?>") return { token: f("atomic", t) };
8358
+ if (t === "(?=" || t === "(?!" || t === "(?<=" || t === "(?<!") return { token: f(t[2] === "<" ? "lookbehind" : "lookahead", t, { negate: t.endsWith("!") }) };
8359
+ if (t === "(" && e.captureGroup || t.startsWith("(?<") && t.endsWith(">") || t.startsWith("(?'") && t.endsWith("'")) return { token: f("capturing", t, { ...t !== "(" && { name: t.slice(3, -1) } }) };
8351
8360
  if (t.startsWith("(?~")) {
8352
8361
  if (t === "(?~|") throw new Error(`Unsupported absence function kind "${t}"`);
8353
- return { token: f$1("absence_repeater", t) };
8362
+ return { token: f("absence_repeater", t) };
8354
8363
  }
8355
8364
  throw t === "(?(" ? new Error(`Unsupported conditional "${t}"`) : new Error(`Invalid or unsupported group option "${t}"`);
8356
8365
  }
@@ -8399,7 +8408,7 @@ function K$1(e, n, t) {
8399
8408
  };
8400
8409
  }
8401
8410
  function X$1(e) {
8402
- if (e[0] === "\\") return x(e, { inCharClass: !0 });
8411
+ if (e[0] === "\\") return x$1(e, { inCharClass: !0 });
8403
8412
  if (e[0] === "[") {
8404
8413
  const n = /\[:(?<negate>\^?)(?<name>[a-z]+):\]/.exec(e);
8405
8414
  if (!n || !i.has(n.groups.name)) throw new Error(`Invalid POSIX class "${e}"`);
@@ -8410,7 +8419,7 @@ function X$1(e) {
8410
8419
  }
8411
8420
  return e === "-" ? U$1(e) : e === "&&" ? H(e) : d(r$2(e), e);
8412
8421
  }
8413
- function x(e, { inCharClass: n }) {
8422
+ function x$1(e, { inCharClass: n }) {
8414
8423
  const t = e[1];
8415
8424
  if (t === "c" || t === "C") return Z(e);
8416
8425
  if ("dDhHsSwW".includes(t)) return q(e);
@@ -8523,7 +8532,7 @@ function Q$1(e) {
8523
8532
  raw: e
8524
8533
  };
8525
8534
  }
8526
- function f$1(e, n, t = {}) {
8535
+ function f(e, n, t = {}) {
8527
8536
  return {
8528
8537
  type: "GroupOpen",
8529
8538
  kind: e,
@@ -8584,7 +8593,7 @@ function L$1(e, n) {
8584
8593
  o$2 ??= "";
8585
8594
  const s$1 = (n.getCurrentModX() || t.includes("x")) && !o$2.includes("x"), a$1 = v(t), r$3 = v(o$2), i$2 = {};
8586
8595
  if (a$1 && (i$2.enable = a$1), r$3 && (i$2.disable = r$3), e.endsWith(")")) return n.replaceCurrentModX(s$1), I$1("flags", e, { flags: i$2 });
8587
- if (e.endsWith(":")) return n.pushModX(s$1), n.numOpenGroups++, f$1("group", e, { ...(a$1 || r$3) && { flags: i$2 } });
8596
+ if (e.endsWith(":")) return n.pushModX(s$1), n.numOpenGroups++, f("group", e, { ...(a$1 || r$3) && { flags: i$2 } });
8588
8597
  throw new Error(`Unexpected flag modifier "${e}"`);
8589
8598
  }
8590
8599
  function j(e) {
@@ -8728,7 +8737,7 @@ function te$1(e) {
8728
8737
  }
8729
8738
 
8730
8739
  //#endregion
8731
- //#region ../../node_modules/.bun/oniguruma-parser@0.12.1/node_modules/oniguruma-parser/dist/parser/node-utils.js
8740
+ //#region ../../node_modules/.bun/oniguruma-parser@0.12.2/node_modules/oniguruma-parser/dist/parser/node-utils.js
8732
8741
  function o(e, t) {
8733
8742
  if (!Array.isArray(e.body)) throw new Error("Expected node with body array");
8734
8743
  if (e.body.length !== 1) return !1;
@@ -8761,7 +8770,7 @@ const y = new Set([
8761
8770
  ]);
8762
8771
 
8763
8772
  //#endregion
8764
- //#region ../../node_modules/.bun/oniguruma-parser@0.12.1/node_modules/oniguruma-parser/dist/parser/parse.js
8773
+ //#region ../../node_modules/.bun/oniguruma-parser@0.12.2/node_modules/oniguruma-parser/dist/parser/parse.js
8765
8774
  function J(e, r$3 = {}) {
8766
8775
  const n = {
8767
8776
  flags: "",
@@ -8776,30 +8785,30 @@ function J(e, r$3 = {}) {
8776
8785
  singleline: !1,
8777
8786
  ...r$3.rules
8778
8787
  }
8779
- }, t = M(e, {
8788
+ }, o$2 = M(e, {
8780
8789
  flags: n.flags,
8781
8790
  rules: {
8782
8791
  captureGroup: n.rules.captureGroup,
8783
8792
  singleline: n.rules.singleline
8784
8793
  }
8785
- }), s$1 = (p$1, N) => {
8786
- const u$1 = t.tokens[o$2.nextIndex];
8787
- switch (o$2.parent = p$1, o$2.nextIndex++, u$1.type) {
8794
+ }), i$2 = (p$1, N) => {
8795
+ const u$1 = o$2.tokens[t.nextIndex];
8796
+ switch (t.parent = p$1, t.nextIndex++, u$1.type) {
8788
8797
  case "Alternator": return b();
8789
8798
  case "Assertion": return W(u$1);
8790
- case "Backreference": return X(u$1, o$2);
8799
+ case "Backreference": return X(u$1, t);
8791
8800
  case "Character": return m(u$1.value, { useLastValid: !!N.isCheckingRangeEnd });
8792
- case "CharacterClassHyphen": return ee(u$1, o$2, N);
8793
- case "CharacterClassOpen": return re(u$1, o$2, N);
8794
- case "CharacterSet": return ne(u$1, o$2);
8801
+ case "CharacterClassHyphen": return ee(u$1, t, N);
8802
+ case "CharacterClassOpen": return re(u$1, t, N);
8803
+ case "CharacterSet": return ne(u$1, t);
8795
8804
  case "Directive": return I(u$1.kind, { flags: u$1.flags });
8796
- case "GroupOpen": return te(u$1, o$2, N);
8805
+ case "GroupOpen": return te(u$1, t, N);
8797
8806
  case "NamedCallout": return U(u$1.kind, u$1.tag, u$1.arguments);
8798
- case "Quantifier": return oe(u$1, o$2);
8799
- case "Subroutine": return ae(u$1, o$2);
8807
+ case "Quantifier": return oe(u$1, t);
8808
+ case "Subroutine": return ae(u$1, t);
8800
8809
  default: throw new Error(`Unexpected token type "${u$1.type}"`);
8801
8810
  }
8802
- }, o$2 = {
8811
+ }, t = {
8803
8812
  capturingGroups: [],
8804
8813
  hasNumberedRef: !1,
8805
8814
  namedGroupsByName: new Map(),
@@ -8810,25 +8819,25 @@ function J(e, r$3 = {}) {
8810
8819
  skipLookbehindValidation: n.skipLookbehindValidation,
8811
8820
  skipPropertyNameValidation: n.skipPropertyNameValidation,
8812
8821
  subroutines: [],
8813
- tokens: t.tokens,
8822
+ tokens: o$2.tokens,
8814
8823
  unicodePropertyMap: n.unicodePropertyMap,
8815
- walk: s$1
8816
- }, i$2 = B(T(t.flags));
8817
- let d$1 = i$2.body[0];
8818
- for (; o$2.nextIndex < t.tokens.length;) {
8819
- const p$1 = s$1(d$1, {});
8820
- p$1.type === "Alternative" ? (i$2.body.push(p$1), d$1 = p$1) : d$1.body.push(p$1);
8821
- }
8822
- const { capturingGroups: a$1, hasNumberedRef: l$2, namedGroupsByName: c, subroutines: f$2 } = o$2;
8824
+ walk: i$2
8825
+ }, d$1 = B(T(o$2.flags));
8826
+ let s$1 = d$1.body[0];
8827
+ for (; t.nextIndex < o$2.tokens.length;) {
8828
+ const p$1 = i$2(s$1, {});
8829
+ p$1.type === "Alternative" ? (d$1.body.push(p$1), s$1 = p$1) : s$1.body.push(p$1);
8830
+ }
8831
+ const { capturingGroups: a$1, hasNumberedRef: l$2, namedGroupsByName: c, subroutines: f$1 } = t;
8823
8832
  if (l$2 && c.size && !n.rules.captureGroup) throw new Error("Numbered backref/subroutine not allowed when using named capture");
8824
- for (const { ref: p$1 } of f$2) if (typeof p$1 == "number") {
8833
+ for (const { ref: p$1 } of f$1) if (typeof p$1 == "number") {
8825
8834
  if (p$1 > a$1.length) throw new Error("Subroutine uses a group number that's not defined");
8826
8835
  p$1 && (a$1[p$1 - 1].isSubroutined = !0);
8827
8836
  } else if (c.has(p$1)) {
8828
8837
  if (c.get(p$1).length > 1) throw new Error(o$1`Subroutine uses a duplicate group name "\g<${p$1}>"`);
8829
8838
  c.get(p$1)[0].isSubroutined = !0;
8830
8839
  } else throw new Error(o$1`Subroutine uses a group name that's not defined "\g<${p$1}>"`);
8831
- return i$2;
8840
+ return d$1;
8832
8841
  }
8833
8842
  function W({ kind: e }) {
8834
8843
  return F(u({
@@ -8845,106 +8854,106 @@ function W({ kind: e }) {
8845
8854
  }[e], `Unexpected assertion kind "${e}"`), { negate: e === o$1`\B` || e === o$1`\Y` });
8846
8855
  }
8847
8856
  function X({ raw: e }, r$3) {
8848
- const n = /^\\k[<']/.test(e), t = n ? e.slice(3, -1) : e.slice(1), s$1 = (o$2, i$2 = !1) => {
8849
- const d$1 = r$3.capturingGroups.length;
8857
+ const n = /^\\k[<']/.test(e), o$2 = n ? e.slice(3, -1) : e.slice(1), i$2 = (t, d$1 = !1) => {
8858
+ const s$1 = r$3.capturingGroups.length;
8850
8859
  let a$1 = !1;
8851
- if (o$2 > d$1) if (r$3.skipBackrefValidation) a$1 = !0;
8860
+ if (t > s$1) if (r$3.skipBackrefValidation) a$1 = !0;
8852
8861
  else throw new Error(`Not enough capturing groups defined to the left "${e}"`);
8853
- return r$3.hasNumberedRef = !0, k(i$2 ? d$1 + 1 - o$2 : o$2, { orphan: a$1 });
8862
+ return r$3.hasNumberedRef = !0, k(d$1 ? s$1 + 1 - t : t, { orphan: a$1 });
8854
8863
  };
8855
8864
  if (n) {
8856
- const o$2 = /^(?<sign>-?)0*(?<num>[1-9]\d*)$/.exec(t);
8857
- if (o$2) return s$1(+o$2.groups.num, !!o$2.groups.sign);
8858
- if (/[-+]/.test(t)) throw new Error(`Invalid backref name "${e}"`);
8859
- if (!r$3.namedGroupsByName.has(t)) throw new Error(`Group name not defined to the left "${e}"`);
8860
- return k(t);
8865
+ const t = /^(?<sign>-?)0*(?<num>[1-9]\d*)$/.exec(o$2);
8866
+ if (t) return i$2(+t.groups.num, !!t.groups.sign);
8867
+ if (/[-+]/.test(o$2)) throw new Error(`Invalid backref name "${e}"`);
8868
+ if (!r$3.namedGroupsByName.has(o$2)) throw new Error(`Group name not defined to the left "${e}"`);
8869
+ return k(o$2);
8861
8870
  }
8862
- return s$1(+t);
8871
+ return i$2(+o$2);
8863
8872
  }
8864
8873
  function ee(e, r$3, n) {
8865
- const { tokens: t, walk: s$1 } = r$3, o$2 = r$3.parent, i$2 = o$2.body.at(-1), d$1 = t[r$3.nextIndex];
8866
- if (!n.isCheckingRangeEnd && i$2 && i$2.type !== "CharacterClass" && i$2.type !== "CharacterClassRange" && d$1 && d$1.type !== "CharacterClassOpen" && d$1.type !== "CharacterClassClose" && d$1.type !== "CharacterClassIntersector") {
8867
- const a$1 = s$1(o$2, {
8874
+ const { tokens: o$2, walk: i$2 } = r$3, t = r$3.parent, d$1 = t.body.at(-1), s$1 = o$2[r$3.nextIndex];
8875
+ if (!n.isCheckingRangeEnd && d$1 && d$1.type !== "CharacterClass" && d$1.type !== "CharacterClassRange" && s$1 && s$1.type !== "CharacterClassOpen" && s$1.type !== "CharacterClassClose" && s$1.type !== "CharacterClassIntersector") {
8876
+ const a$1 = i$2(t, {
8868
8877
  ...n,
8869
8878
  isCheckingRangeEnd: !0
8870
8879
  });
8871
- if (i$2.type === "Character" && a$1.type === "Character") return o$2.body.pop(), L(i$2, a$1);
8880
+ if (d$1.type === "Character" && a$1.type === "Character") return t.body.pop(), L(d$1, a$1);
8872
8881
  throw new Error("Invalid character class range");
8873
8882
  }
8874
8883
  return m(r$2("-"));
8875
8884
  }
8876
8885
  function re({ negate: e }, r$3, n) {
8877
- const { tokens: t, walk: s$1 } = r$3, o$2 = t[r$3.nextIndex], i$2 = [C()];
8878
- let d$1 = z(o$2);
8879
- for (; d$1.type !== "CharacterClassClose";) {
8880
- if (d$1.type === "CharacterClassIntersector") i$2.push(C()), r$3.nextIndex++;
8886
+ const { tokens: o$2, walk: i$2 } = r$3, t = [C()], d$1 = o$2[r$3.nextIndex];
8887
+ let s$1 = z(d$1);
8888
+ for (; s$1.type !== "CharacterClassClose";) {
8889
+ if (s$1.type === "CharacterClassIntersector") t.push(C()), r$3.nextIndex++;
8881
8890
  else {
8882
- const l$2 = i$2.at(-1);
8883
- l$2.body.push(s$1(l$2, n));
8891
+ const l$2 = t.at(-1);
8892
+ l$2.body.push(i$2(l$2, n));
8884
8893
  }
8885
- d$1 = z(t[r$3.nextIndex], o$2);
8894
+ s$1 = z(o$2[r$3.nextIndex], d$1);
8886
8895
  }
8887
8896
  const a$1 = C({ negate: e });
8888
- return i$2.length === 1 ? a$1.body = i$2[0].body : (a$1.kind = "intersection", a$1.body = i$2.map((l$2) => l$2.body.length === 1 ? l$2.body[0] : l$2)), r$3.nextIndex++, a$1;
8897
+ return t.length === 1 ? a$1.body = t[0].body : (a$1.kind = "intersection", a$1.body = t.map((l$2) => l$2.body.length === 1 ? l$2.body[0] : l$2)), r$3.nextIndex++, a$1;
8889
8898
  }
8890
- function ne({ kind: e, negate: r$3, value: n }, t) {
8891
- const { normalizeUnknownPropertyNames: s$1, skipPropertyNameValidation: o$2, unicodePropertyMap: i$2 } = t;
8899
+ function ne({ kind: e, negate: r$3, value: n }, o$2) {
8900
+ const { normalizeUnknownPropertyNames: i$2, skipPropertyNameValidation: t, unicodePropertyMap: d$1 } = o$2;
8892
8901
  if (e === "property") {
8893
- const d$1 = w(n);
8894
- if (i.has(d$1) && !i$2?.has(d$1)) e = "posix", n = d$1;
8902
+ const s$1 = w(n);
8903
+ if (i.has(s$1) && !d$1?.has(s$1)) e = "posix", n = s$1;
8895
8904
  else return Q(n, {
8896
8905
  negate: r$3,
8897
- normalizeUnknownPropertyNames: s$1,
8898
- skipPropertyNameValidation: o$2,
8899
- unicodePropertyMap: i$2
8906
+ normalizeUnknownPropertyNames: i$2,
8907
+ skipPropertyNameValidation: t,
8908
+ unicodePropertyMap: d$1
8900
8909
  });
8901
8910
  }
8902
8911
  return e === "posix" ? R(n, { negate: r$3 }) : E(e, { negate: r$3 });
8903
8912
  }
8904
8913
  function te(e, r$3, n) {
8905
- const { tokens: t, capturingGroups: s$1, namedGroupsByName: o$2, skipLookbehindValidation: i$2, walk: d$1 } = r$3, a$1 = ie(e), l$2 = a$1.type === "AbsenceFunction", c = $(a$1), f$2 = c && a$1.negate;
8906
- if (a$1.type === "CapturingGroup" && (s$1.push(a$1), a$1.name && l$1(o$2, a$1.name, []).push(a$1)), l$2 && n.isInAbsenceFunction) throw new Error("Nested absence function not supported by Oniguruma");
8907
- let p$1 = D(t[r$3.nextIndex]);
8914
+ const { tokens: o$2, capturingGroups: i$2, namedGroupsByName: t, skipLookbehindValidation: d$1, walk: s$1 } = r$3, a$1 = ie(e), l$2 = a$1.type === "AbsenceFunction", c = $(a$1), f$1 = c && a$1.negate;
8915
+ if (a$1.type === "CapturingGroup" && (i$2.push(a$1), a$1.name && l$1(t, a$1.name, []).push(a$1)), l$2 && n.isInAbsenceFunction) throw new Error("Nested absence function not supported by Oniguruma");
8916
+ let p$1 = D(o$2[r$3.nextIndex]);
8908
8917
  for (; p$1.type !== "GroupClose";) {
8909
8918
  if (p$1.type === "Alternator") a$1.body.push(b()), r$3.nextIndex++;
8910
8919
  else {
8911
- const N = a$1.body.at(-1), u$1 = d$1(N, {
8920
+ const N = a$1.body.at(-1), u$1 = s$1(N, {
8912
8921
  ...n,
8913
8922
  isInAbsenceFunction: n.isInAbsenceFunction || l$2,
8914
8923
  isInLookbehind: n.isInLookbehind || c,
8915
- isInNegLookbehind: n.isInNegLookbehind || f$2
8924
+ isInNegLookbehind: n.isInNegLookbehind || f$1
8916
8925
  });
8917
- if (N.body.push(u$1), (c || n.isInLookbehind) && !i$2) {
8926
+ if (N.body.push(u$1), (c || n.isInLookbehind) && !d$1) {
8918
8927
  const v$1 = "Lookbehind includes a pattern not allowed by Oniguruma";
8919
- if (f$2 || n.isInNegLookbehind) {
8928
+ if (f$1 || n.isInNegLookbehind) {
8920
8929
  if (M$1(u$1) || u$1.type === "CapturingGroup") throw new Error(v$1);
8921
8930
  } else if (M$1(u$1) || $(u$1) && u$1.negate) throw new Error(v$1);
8922
8931
  }
8923
8932
  }
8924
- p$1 = D(t[r$3.nextIndex]);
8933
+ p$1 = D(o$2[r$3.nextIndex]);
8925
8934
  }
8926
8935
  return r$3.nextIndex++, a$1;
8927
8936
  }
8928
- function oe({ kind: e, min: r$3, max: n }, t) {
8929
- const s$1 = t.parent, o$2 = s$1.body.at(-1);
8930
- if (!o$2 || !s(o$2)) throw new Error("Quantifier requires a repeatable token");
8931
- const i$2 = _(e, r$3, n, o$2);
8932
- return s$1.body.pop(), i$2;
8937
+ function oe({ kind: e, min: r$3, max: n }, o$2) {
8938
+ const i$2 = o$2.parent, t = i$2.body.at(-1);
8939
+ if (!t || !s(t)) throw new Error("Quantifier requires a repeatable token");
8940
+ const d$1 = _(e, r$3, n, t);
8941
+ return i$2.body.pop(), d$1;
8933
8942
  }
8934
8943
  function ae({ raw: e }, r$3) {
8935
- const { capturingGroups: n, subroutines: t } = r$3;
8936
- let s$1 = e.slice(3, -1);
8937
- const o$2 = /^(?<sign>[-+]?)0*(?<num>[1-9]\d*)$/.exec(s$1);
8938
- if (o$2) {
8939
- const d$1 = +o$2.groups.num, a$1 = n.length;
8940
- if (r$3.hasNumberedRef = !0, s$1 = {
8941
- "": d$1,
8942
- "+": a$1 + d$1,
8943
- "-": a$1 + 1 - d$1
8944
- }[o$2.groups.sign], s$1 < 1) throw new Error("Invalid subroutine number");
8945
- } else s$1 === "0" && (s$1 = 0);
8946
- const i$2 = O(s$1);
8947
- return t.push(i$2), i$2;
8944
+ const { capturingGroups: n, subroutines: o$2 } = r$3;
8945
+ let i$2 = e.slice(3, -1);
8946
+ const t = /^(?<sign>[-+]?)0*(?<num>[1-9]\d*)$/.exec(i$2);
8947
+ if (t) {
8948
+ const s$1 = +t.groups.num, a$1 = n.length;
8949
+ if (r$3.hasNumberedRef = !0, i$2 = {
8950
+ "": s$1,
8951
+ "+": a$1 + s$1,
8952
+ "-": a$1 + 1 - s$1
8953
+ }[t.groups.sign], i$2 < 1) throw new Error("Invalid subroutine number");
8954
+ } else i$2 === "0" && (i$2 = 0);
8955
+ const d$1 = O(i$2);
8956
+ return o$2.push(d$1), d$1;
8948
8957
  }
8949
8958
  function G(e, r$3) {
8950
8959
  if (e !== "repeater") throw new Error(`Unexpected absence function kind "${e}"`);
@@ -8996,9 +9005,9 @@ function m(e, r$3) {
8996
9005
  ...r$3
8997
9006
  };
8998
9007
  if (e > 1114111) {
8999
- const t = e.toString(16);
9008
+ const o$2 = e.toString(16);
9000
9009
  if (n.useLastValid) e = 1114111;
9001
- else throw e > 1310719 ? new Error(`Invalid code point out of range "\\x{${t}}"`) : new Error(`Invalid code point out of range in JS "\\x{${t}}"`);
9010
+ else throw e > 1310719 ? new Error(`Invalid code point out of range "\\x{${o$2}}"`) : new Error(`Invalid code point out of range in JS "\\x{${o$2}}"`);
9002
9011
  }
9003
9012
  return {
9004
9013
  type: "Character",
@@ -9027,11 +9036,11 @@ function L(e, r$3) {
9027
9036
  };
9028
9037
  }
9029
9038
  function E(e, r$3) {
9030
- const n = !!r$3?.negate, t = {
9039
+ const n = !!r$3?.negate, o$2 = {
9031
9040
  type: "CharacterSet",
9032
9041
  kind: e
9033
9042
  };
9034
- return (e === "digit" || e === "hex" || e === "newline" || e === "space" || e === "word") && (t.negate = n), (e === "text_segment" || e === "newline" && !n) && (t.variableLength = !0), t;
9043
+ return (e === "digit" || e === "hex" || e === "newline" || e === "space" || e === "word") && (o$2.negate = n), (e === "text_segment" || e === "newline" && !n) && (o$2.variableLength = !0), o$2;
9035
9044
  }
9036
9045
  function I(e, r$3 = {}) {
9037
9046
  if (e === "keep") return {
@@ -9092,14 +9101,14 @@ function R(e, r$3) {
9092
9101
  negate: n
9093
9102
  };
9094
9103
  }
9095
- function _(e, r$3, n, t) {
9104
+ function _(e, r$3, n, o$2) {
9096
9105
  if (r$3 > n) throw new Error("Invalid reversed quantifier range");
9097
9106
  return {
9098
9107
  type: "Quantifier",
9099
9108
  kind: e,
9100
9109
  min: r$3,
9101
9110
  max: n,
9102
- body: t
9111
+ body: o$2
9103
9112
  };
9104
9113
  }
9105
9114
  function B(e, r$3) {
@@ -9123,28 +9132,28 @@ function Q(e, r$3) {
9123
9132
  unicodePropertyMap: null,
9124
9133
  ...r$3
9125
9134
  };
9126
- let t = n.unicodePropertyMap?.get(w(e));
9127
- if (!t) {
9128
- if (n.normalizeUnknownPropertyNames) t = de(e);
9135
+ let o$2 = n.unicodePropertyMap?.get(w(e));
9136
+ if (!o$2) {
9137
+ if (n.normalizeUnknownPropertyNames) o$2 = de(e);
9129
9138
  else if (n.unicodePropertyMap && !n.skipPropertyNameValidation) throw new Error(o$1`Invalid Unicode property "\p{${e}}"`);
9130
9139
  }
9131
9140
  return {
9132
9141
  type: "CharacterSet",
9133
9142
  kind: "property",
9134
- value: t ?? e,
9143
+ value: o$2 ?? e,
9135
9144
  negate: n.negate
9136
9145
  };
9137
9146
  }
9138
- function ie({ flags: e, kind: r$3, name: n, negate: t, number: s$1 }) {
9147
+ function ie({ flags: e, kind: r$3, name: n, negate: o$2, number: i$2 }) {
9139
9148
  switch (r$3) {
9140
9149
  case "absence_repeater": return G("repeater");
9141
9150
  case "atomic": return A({ atomic: !0 });
9142
- case "capturing": return P(s$1, { name: n });
9151
+ case "capturing": return P(i$2, { name: n });
9143
9152
  case "group": return A({ flags: e });
9144
9153
  case "lookahead":
9145
9154
  case "lookbehind": return K({
9146
9155
  behind: r$3 === "lookbehind",
9147
- negate: t
9156
+ negate: o$2
9148
9157
  });
9149
9158
  default: throw new Error(`Unexpected group kind "${r$3}"`);
9150
9159
  }
@@ -9175,16 +9184,17 @@ function w(e) {
9175
9184
  return e.replace(/[- _]+/g, "").toLowerCase();
9176
9185
  }
9177
9186
  function z(e, r$3) {
9178
- return u(e, `${r$3?.type === "Character" && r$3.value === 93 ? "Empty" : "Unclosed"} character class`);
9187
+ const n = r$3;
9188
+ return u(e, `Unclosed character class${n?.type === "Character" && n.value === 93 && n.raw === "]" ? " (started with \"]\")" : ""}`);
9179
9189
  }
9180
9190
  function D(e) {
9181
9191
  return u(e, "Unclosed group");
9182
9192
  }
9183
9193
 
9184
9194
  //#endregion
9185
- //#region ../../node_modules/.bun/oniguruma-parser@0.12.1/node_modules/oniguruma-parser/dist/traverser/traverse.js
9195
+ //#region ../../node_modules/.bun/oniguruma-parser@0.12.2/node_modules/oniguruma-parser/dist/traverser/traverse.js
9186
9196
  function S(a$1, v$1, N = null) {
9187
- function u$1(e, s$1) {
9197
+ function b$2(e, s$1) {
9188
9198
  for (let t = 0; t < e.length; t++) {
9189
9199
  const r$3 = n(e[t], s$1, t, e);
9190
9200
  t = Math.max(-1, t + r$3);
@@ -9199,40 +9209,39 @@ function S(a$1, v$1, N = null) {
9199
9209
  container: r$3,
9200
9210
  root: a$1,
9201
9211
  remove() {
9202
- f(r$3).splice(Math.max(0, l(t) + i$2), 1), i$2--, c = !0;
9212
+ x(r$3).splice(Math.max(0, l(t) + i$2), 1), i$2--, c = !0;
9203
9213
  },
9204
9214
  removeAllNextSiblings() {
9205
- return f(r$3).splice(l(t) + 1);
9215
+ return x(r$3).splice(l(t) + 1);
9206
9216
  },
9207
9217
  removeAllPrevSiblings() {
9208
9218
  const o$2 = l(t) + i$2;
9209
- return i$2 -= o$2, f(r$3).splice(0, Math.max(0, o$2));
9219
+ return i$2 -= o$2, x(r$3).splice(0, Math.max(0, o$2));
9210
9220
  },
9211
- replaceWith(o$2, y$2 = {}) {
9212
- const b$2 = !!y$2.traverse;
9213
- r$3 ? r$3[Math.max(0, l(t) + i$2)] = o$2 : u(s$1, "Can't replace root node")[t] = o$2, b$2 && n(o$2, s$1, t, r$3), c = !0;
9221
+ replaceWith(o$2, m$2 = {}) {
9222
+ const y$2 = !!m$2.traverse;
9223
+ r$3 ? r$3[Math.max(0, l(t) + i$2)] = o$2 : u(s$1, "Can't replace root node")[t] = o$2, y$2 && n(o$2, s$1, t, r$3), c = !0;
9214
9224
  },
9215
- replaceWithMultiple(o$2, y$2 = {}) {
9216
- const b$2 = !!y$2.traverse;
9217
- if (f(r$3).splice(Math.max(0, l(t) + i$2), 1, ...o$2), i$2 += o$2.length - 1, b$2) {
9225
+ replaceWithMultiple(o$2, m$2 = {}) {
9226
+ const y$2 = !!m$2.traverse;
9227
+ if (x(r$3).splice(Math.max(0, l(t) + i$2), 1, ...o$2), i$2 += o$2.length - 1, y$2) {
9218
9228
  let g = 0;
9219
- for (let x$1 = 0; x$1 < o$2.length; x$1++) g += n(o$2[x$1], s$1, l(t) + x$1 + g, r$3);
9229
+ for (let p$1 = 0; p$1 < o$2.length; p$1++) g += n(o$2[p$1], s$1, l(t) + p$1 + g, r$3);
9220
9230
  }
9221
9231
  c = !0;
9222
9232
  },
9223
9233
  skip() {
9224
9234
  c = !0;
9225
9235
  }
9226
- }, { type: m$2 } = e, h$1 = v$1["*"], p$1 = v$1[m$2], R$2 = typeof h$1 == "function" ? h$1 : h$1?.enter, P$2 = typeof p$1 == "function" ? p$1 : p$1?.enter;
9227
- if (R$2?.(d$1, N), P$2?.(d$1, N), !c) switch (m$2) {
9236
+ }, { type: f$1 } = e, u$1 = v$1["*"], h$1 = v$1[f$1], R$2 = typeof u$1 == "function" ? u$1 : u$1?.enter, P$2 = typeof h$1 == "function" ? h$1 : h$1?.enter;
9237
+ if (R$2?.(d$1, N), P$2?.(d$1, N), !c) switch (f$1) {
9228
9238
  case "AbsenceFunction":
9229
- case "CapturingGroup":
9230
- case "Group":
9231
- u$1(e.body, e);
9232
- break;
9233
9239
  case "Alternative":
9240
+ case "CapturingGroup":
9234
9241
  case "CharacterClass":
9235
- u$1(e.body, e);
9242
+ case "Group":
9243
+ case "LookaroundAssertion":
9244
+ b$2(e.body, e);
9236
9245
  break;
9237
9246
  case "Assertion":
9238
9247
  case "Backreference":
@@ -9245,22 +9254,19 @@ function S(a$1, v$1, N = null) {
9245
9254
  case "CharacterClassRange":
9246
9255
  n(e.min, e, "min"), n(e.max, e, "max");
9247
9256
  break;
9248
- case "LookaroundAssertion":
9249
- u$1(e.body, e);
9250
- break;
9251
9257
  case "Quantifier":
9252
9258
  n(e.body, e, "body");
9253
9259
  break;
9254
9260
  case "Regex":
9255
- u$1(e.body, e), n(e.flags, e, "flags");
9261
+ b$2(e.body, e), n(e.flags, e, "flags");
9256
9262
  break;
9257
- default: throw new Error(`Unexpected node type "${m$2}"`);
9263
+ default: throw new Error(`Unexpected node type "${f$1}"`);
9258
9264
  }
9259
- return p$1?.exit?.(d$1, N), h$1?.exit?.(d$1, N), i$2;
9265
+ return h$1?.exit?.(d$1, N), u$1?.exit?.(d$1, N), i$2;
9260
9266
  }
9261
9267
  return n(a$1), a$1;
9262
9268
  }
9263
- function f(a$1) {
9269
+ function x(a$1) {
9264
9270
  if (!Array.isArray(a$1)) throw new Error("Container expected");
9265
9271
  return a$1;
9266
9272
  }
@@ -9522,7 +9528,7 @@ function atomic(expression, data) {
9522
9528
  if (captureTransfers.size) {
9523
9529
  const newCaptureTransfers = new Map();
9524
9530
  captureTransfers.forEach((from, to) => {
9525
- newCaptureTransfers.set(to >= addedCaptureNum ? to + 1 : to, from.map((f$2) => f$2 >= addedCaptureNum ? f$2 + 1 : f$2));
9531
+ newCaptureTransfers.set(to >= addedCaptureNum ? to + 1 : to, from.map((f$1) => f$1 >= addedCaptureNum ? f$1 + 1 : f$1));
9526
9532
  });
9527
9533
  captureTransfers = newCaptureTransfers;
9528
9534
  }
@@ -9958,18 +9964,18 @@ function mapCaptureTransfers(captureTransfers, left, reps, numCapturesAddedInExp
9958
9964
  const numCapturesAddedInLeft = numCapturesInLeft * reps;
9959
9965
  const newTo = to > recursionDelimCaptureNum + numCapturesInLeft ? to + numCapturesAddedInExpansion : to;
9960
9966
  const newFrom = [];
9961
- for (const f$2 of from) {
9962
- if (f$2 <= recursionDelimCaptureNum) {
9963
- newFrom.push(f$2);
9964
- } else if (f$2 > recursionDelimCaptureNum + numCapturesInLeft + numCapturesInRight) {
9965
- newFrom.push(f$2 + numCapturesAddedInExpansion);
9966
- } else if (f$2 <= recursionDelimCaptureNum + numCapturesInLeft) {
9967
+ for (const f$1 of from) {
9968
+ if (f$1 <= recursionDelimCaptureNum) {
9969
+ newFrom.push(f$1);
9970
+ } else if (f$1 > recursionDelimCaptureNum + numCapturesInLeft + numCapturesInRight) {
9971
+ newFrom.push(f$1 + numCapturesAddedInExpansion);
9972
+ } else if (f$1 <= recursionDelimCaptureNum + numCapturesInLeft) {
9967
9973
  for (let i$2 = 0; i$2 <= reps; i$2++) {
9968
- newFrom.push(f$2 + numCapturesInLeft * i$2);
9974
+ newFrom.push(f$1 + numCapturesInLeft * i$2);
9969
9975
  }
9970
9976
  } else {
9971
9977
  for (let i$2 = 0; i$2 <= reps; i$2++) {
9972
- newFrom.push(f$2 + numCapturesAddedInLeft + numCapturesInRight * i$2);
9978
+ newFrom.push(f$1 + numCapturesAddedInLeft + numCapturesInRight * i$2);
9973
9979
  }
9974
9980
  }
9975
9981
  }
@@ -9981,36 +9987,36 @@ function mapCaptureTransfers(captureTransfers, left, reps, numCapturesAddedInExp
9981
9987
  }
9982
9988
 
9983
9989
  //#endregion
9984
- //#region ../../node_modules/.bun/oniguruma-to-es@4.3.4/node_modules/oniguruma-to-es/dist/esm/index.js
9990
+ //#region ../../node_modules/.bun/oniguruma-to-es@4.3.6/node_modules/oniguruma-to-es/dist/esm/index.js
9985
9991
  var cp = String.fromCodePoint;
9986
9992
  var r = String.raw;
9987
- var envFlags = {
9988
- flagGroups: (() => {
9989
- try {
9990
- new RegExp("(?i:)");
9991
- } catch {
9992
- return false;
9993
- }
9994
- return true;
9995
- })(),
9996
- unicodeSets: (() => {
9997
- try {
9998
- new RegExp("[[]]", "v");
9999
- } catch {
10000
- return false;
10001
- }
10002
- return true;
10003
- })()
10004
- };
9993
+ var envFlags = {};
9994
+ var globalRegExp = globalThis.RegExp;
9995
+ envFlags.flagGroups = (() => {
9996
+ try {
9997
+ new globalRegExp("(?i:)");
9998
+ } catch {
9999
+ return false;
10000
+ }
10001
+ return true;
10002
+ })();
10003
+ envFlags.unicodeSets = (() => {
10004
+ try {
10005
+ new globalRegExp("[[]]", "v");
10006
+ } catch {
10007
+ return false;
10008
+ }
10009
+ return true;
10010
+ })();
10005
10011
  envFlags.bugFlagVLiteralHyphenIsRange = envFlags.unicodeSets ? (() => {
10006
10012
  try {
10007
- new RegExp(r`[\d\-a]`, "v");
10013
+ new globalRegExp(r`[\d\-a]`, "v");
10008
10014
  } catch {
10009
10015
  return true;
10010
10016
  }
10011
10017
  return false;
10012
10018
  })() : false;
10013
- envFlags.bugNestedClassIgnoresNegation = envFlags.unicodeSets && new RegExp("[[^a]]", "v").test("a");
10019
+ envFlags.bugNestedClassIgnoresNegation = envFlags.unicodeSets && new globalRegExp("[[^a]]", "v").test("a");
10014
10020
  function getNewCurrentFlags(current, { enable, disable }) {
10015
10021
  return {
10016
10022
  dotAll: !disable?.dotAll && !!(enable?.dotAll || current.dotAll),
@@ -10492,7 +10498,7 @@ var FirstPassVisitor = {
10492
10498
  "spaceIsAscii",
10493
10499
  "wordIsAscii",
10494
10500
  "textSegmentMode"
10495
- ].forEach((f$2) => delete node[f$2]);
10501
+ ].forEach((f$1) => delete node[f$1]);
10496
10502
  Object.assign(node, {
10497
10503
  global: false,
10498
10504
  hasIndices: false,
@@ -10636,7 +10642,9 @@ var SecondPassVisitor = {
10636
10642
  }
10637
10643
  },
10638
10644
  exit({ node }, { openRefs }) {
10639
- openRefs.delete(node.number);
10645
+ if (openRefs.get(node.number) === node) {
10646
+ openRefs.delete(node.number);
10647
+ }
10640
10648
  }
10641
10649
  },
10642
10650
  Group: {
@@ -11636,7 +11644,7 @@ function toRegExpDetails(pattern, options) {
11636
11644
  }
11637
11645
 
11638
11646
  //#endregion
11639
- //#region ../../node_modules/.bun/@shikijs+engine-javascript@4.0.2/node_modules/@shikijs/engine-javascript/dist/engine-compile.mjs
11647
+ //#region ../../node_modules/.bun/@shikijs+engine-javascript@4.2.0/node_modules/@shikijs/engine-javascript/dist/engine-compile.mjs
11640
11648
  /**
11641
11649
  * The default regex constructor for the JavaScript RegExp engine.
11642
11650
  */
@@ -11664,10 +11672,11 @@ function defaultJavaScriptRegexConstructor(pattern, options) {
11664
11672
  * Set `forgiving` to `true` to ignore these errors and skip any unsupported or invalid patterns.
11665
11673
  */
11666
11674
  function createJavaScriptRegexEngine(options = {}) {
11667
- const _options = Object.assign({
11675
+ const _options = {
11668
11676
  target: "auto",
11669
- cache: /* @__PURE__ */ new Map()
11670
- }, options);
11677
+ cache: /* @__PURE__ */ new Map(),
11678
+ ...options
11679
+ };
11671
11680
  _options.regexConstructor ||= (pattern) => defaultJavaScriptRegexConstructor(pattern, { target: _options.target });
11672
11681
  return {
11673
11682
  createScanner(patterns) {
@@ -11680,7 +11689,7 @@ function createJavaScriptRegexEngine(options = {}) {
11680
11689
  }
11681
11690
 
11682
11691
  //#endregion
11683
- //#region ../../node_modules/.bun/@shikijs+engine-javascript@4.0.2/node_modules/@shikijs/engine-javascript/dist/engine-raw.mjs
11692
+ //#region ../../node_modules/.bun/@shikijs+engine-javascript@4.2.0/node_modules/@shikijs/engine-javascript/dist/engine-raw.mjs
11684
11693
  /**
11685
11694
  * Raw JavaScript regex engine that only supports precompiled grammars.
11686
11695
  *
@@ -11706,7 +11715,7 @@ function createJavaScriptRawEngine() {
11706
11715
  }
11707
11716
 
11708
11717
  //#endregion
11709
- //#region ../../node_modules/.bun/@shikijs+engine-oniguruma@4.0.2/node_modules/@shikijs/engine-oniguruma/dist/index.mjs
11718
+ //#region ../../node_modules/.bun/@shikijs+engine-oniguruma@4.2.0/node_modules/@shikijs/engine-oniguruma/dist/index.mjs
11710
11719
  var dist_exports = /* @__PURE__ */ __export({
11711
11720
  createOnigurumaEngine: () => createOnigurumaEngine,
11712
11721
  getDefaultWasmLoader: () => getDefaultWasmLoader,
@@ -11725,7 +11734,7 @@ function getHeapMax() {
11725
11734
  function _emscripten_get_now() {
11726
11735
  return typeof performance !== "undefined" ? performance.now() : Date.now();
11727
11736
  }
11728
- const alignUp = (x$1, multiple) => x$1 + (multiple - x$1 % multiple) % multiple;
11737
+ const alignUp = (x$2, multiple) => x$2 + (multiple - x$2 % multiple) % multiple;
11729
11738
  async function main(init) {
11730
11739
  let wasmMemory;
11731
11740
  let buffer;
@@ -11808,10 +11817,10 @@ async function main(init) {
11808
11817
  env: asmLibraryArg,
11809
11818
  wasi_snapshot_preview1: asmLibraryArg
11810
11819
  };
11811
- const exports$1 = await init(info);
11812
- wasmMemory = exports$1.memory;
11820
+ const exports = await init(info);
11821
+ wasmMemory = exports.memory;
11813
11822
  updateGlobalBufferAndViews(wasmMemory.buffer);
11814
- Object.assign(binding, exports$1);
11823
+ Object.assign(binding, exports);
11815
11824
  binding.UTF8ToString = UTF8ToString;
11816
11825
  }
11817
11826
  await createWasm();
@@ -12130,7 +12139,7 @@ async function createOnigurumaEngine(options) {
12130
12139
  }
12131
12140
 
12132
12141
  //#endregion
12133
- //#region ../../node_modules/.bun/shiki@4.0.2/node_modules/shiki/dist/engine-oniguruma.mjs
12142
+ //#region ../../node_modules/.bun/shiki@4.2.0/node_modules/shiki/dist/engine-oniguruma.mjs
12134
12143
  var engine_oniguruma_exports = /* @__PURE__ */ __exportAll({});
12135
12144
  __reExport(engine_oniguruma_exports, dist_exports);
12136
12145
 
@@ -12234,11 +12243,500 @@ function attachResolvedLanguages(resolvedLanguages, highlighter$1) {
12234
12243
 
12235
12244
  //#endregion
12236
12245
  //#region src/highlighter/themes/constants.ts
12237
- const ResolvedThemes = new Map();
12238
- const ResolvingThemes = new Map();
12239
- const RegisteredCustomThemes = new Map();
12240
12246
  const AttachedThemes = new Set();
12241
12247
 
12248
+ //#endregion
12249
+ //#region ../theming/dist/modules/createThemeCollection.js
12250
+ function createThemeCollection(options) {
12251
+ const descriptors = [];
12252
+ const seen = /* @__PURE__ */ new Set();
12253
+ for (const entry of getCollectionEntries(options.themes)) {
12254
+ const themes = isThemeCollectionSource(entry) ? entry.getThemes() : [entry];
12255
+ for (const descriptor of themes) {
12256
+ if (seen.has(descriptor.name)) throw new Error(`Theme collection already contains theme "${descriptor.name}"`);
12257
+ seen.add(descriptor.name);
12258
+ descriptors.push(descriptor);
12259
+ }
12260
+ }
12261
+ const allThemes = Object.freeze([...descriptors]);
12262
+ const lightThemes = Object.freeze(allThemes.filter((descriptor) => descriptor.colorScheme === "light"));
12263
+ const darkThemes = Object.freeze(allThemes.filter((descriptor) => descriptor.colorScheme === "dark"));
12264
+ const themesByName = new Map(allThemes.map((descriptor) => [descriptor.name, descriptor]));
12265
+ const allNames = Object.freeze(allThemes.map((descriptor) => descriptor.name));
12266
+ const lightNames = Object.freeze(lightThemes.map((descriptor) => descriptor.name));
12267
+ const darkNames = Object.freeze(darkThemes.map((descriptor) => descriptor.name));
12268
+ function filteredThemes(filterOptions) {
12269
+ if (filterOptions == null) return allThemes;
12270
+ const { colorScheme, collection } = filterOptions;
12271
+ if (collection == null) {
12272
+ if (colorScheme === "light") return lightThemes;
12273
+ if (colorScheme === "dark") return darkThemes;
12274
+ return allThemes;
12275
+ }
12276
+ return allThemes.filter((descriptor) => {
12277
+ if (descriptor.collection !== collection) return false;
12278
+ return colorScheme == null || descriptor.colorScheme === colorScheme;
12279
+ });
12280
+ }
12281
+ return {
12282
+ getTheme(name) {
12283
+ return themesByName.get(name);
12284
+ },
12285
+ getThemes(themeOptions) {
12286
+ return filteredThemes(themeOptions);
12287
+ },
12288
+ getThemeNames(namesOptions) {
12289
+ if (namesOptions?.collection == null) {
12290
+ if (namesOptions?.colorScheme === "light") return lightNames;
12291
+ if (namesOptions?.colorScheme === "dark") return darkNames;
12292
+ return allNames;
12293
+ }
12294
+ return filteredThemes(namesOptions).map((descriptor) => descriptor.name);
12295
+ },
12296
+ hasTheme(name) {
12297
+ return themesByName.has(name);
12298
+ },
12299
+ orderBy(compare) {
12300
+ return createThemeCollection({ themes: allThemes.map((descriptor, index) => ({
12301
+ descriptor,
12302
+ index
12303
+ })).sort((a$1, b$2) => {
12304
+ const result = compare(a$1.descriptor, b$2.descriptor);
12305
+ if (result !== 0) return result;
12306
+ return a$1.index - b$2.index;
12307
+ }).map((entry) => entry.descriptor) });
12308
+ },
12309
+ pick(names) {
12310
+ const picked = [];
12311
+ const pickedNames = /* @__PURE__ */ new Set();
12312
+ for (const name of names) {
12313
+ if (pickedNames.has(name)) throw new Error(`Theme collection pick already includes theme "${name}"`);
12314
+ pickedNames.add(name);
12315
+ const descriptor = themesByName.get(name);
12316
+ if (descriptor == null) throw new Error(`Theme collection does not contain theme "${name}"`);
12317
+ picked.push(descriptor);
12318
+ }
12319
+ return createThemeCollection({ themes: picked });
12320
+ },
12321
+ registerInto(resolver) {
12322
+ for (const descriptor of allThemes) resolver.registerThemeIfAbsent(descriptor.name, descriptor.load);
12323
+ }
12324
+ };
12325
+ }
12326
+ function getCollectionEntries(input) {
12327
+ if (isThemeCollectionEntry(input)) return [input];
12328
+ return input;
12329
+ }
12330
+ function isThemeCollectionEntry(input) {
12331
+ return isThemeCollectionSource(input) || isThemeDescriptor(input);
12332
+ }
12333
+ function isThemeDescriptor(input) {
12334
+ return typeof input.name === "string" && typeof input.load === "function";
12335
+ }
12336
+ function isThemeCollectionSource(entry) {
12337
+ return typeof entry.getThemes === "function";
12338
+ }
12339
+
12340
+ //#endregion
12341
+ //#region ../theming/dist/modules/createThemeCatalog.js
12342
+ function createThemeCatalog(options) {
12343
+ const collection = createThemeCollection({ themes: options.themes });
12344
+ if (!collection.hasTheme(options.defaultLightThemeName)) throw new Error(`Default light theme "${options.defaultLightThemeName}" is not in the catalog`);
12345
+ if (!collection.hasTheme(options.defaultDarkThemeName)) throw new Error(`Default dark theme "${options.defaultDarkThemeName}" is not in the catalog`);
12346
+ return {
12347
+ ...collection,
12348
+ defaultLightThemeName: options.defaultLightThemeName,
12349
+ defaultDarkThemeName: options.defaultDarkThemeName
12350
+ };
12351
+ }
12352
+
12353
+ //#endregion
12354
+ //#region ../theming/dist/modules/unwrapDefault.js
12355
+ function unwrapDefault(value) {
12356
+ return value !== null && typeof value === "object" && "default" in value ? value.default : value;
12357
+ }
12358
+
12359
+ //#endregion
12360
+ //#region ../theming/dist/modules/createThemeResolver.js
12361
+ var DuplicateThemeError = class extends Error {
12362
+ constructor(name) {
12363
+ super(`Theme "${name}" is already registered`);
12364
+ this.name = "DuplicateThemeError";
12365
+ }
12366
+ };
12367
+ var UnregisteredThemeError = class extends Error {
12368
+ constructor(name) {
12369
+ super(`No loader registered for theme "${name}"`);
12370
+ this.name = "UnregisteredThemeError";
12371
+ }
12372
+ };
12373
+ var UnresolvedThemeError = class extends Error {
12374
+ constructor(name) {
12375
+ super(`Theme "${name}" has not been resolved`);
12376
+ this.name = "UnresolvedThemeError";
12377
+ }
12378
+ };
12379
+ function createThemeResolver() {
12380
+ const loaders = /* @__PURE__ */ new Map();
12381
+ const resolved = /* @__PURE__ */ new Map();
12382
+ const inflight = /* @__PURE__ */ new Map();
12383
+ let cacheGeneration = 0;
12384
+ function registerTheme(name, loader) {
12385
+ if (loaders.has(name)) throw new DuplicateThemeError(name);
12386
+ loaders.set(name, loader);
12387
+ }
12388
+ function registerThemeIfAbsent(name, loader) {
12389
+ if (loaders.has(name)) return false;
12390
+ loaders.set(name, loader);
12391
+ return true;
12392
+ }
12393
+ function hasRegisteredTheme(name) {
12394
+ return loaders.has(name);
12395
+ }
12396
+ function resolveTheme(name) {
12397
+ const cached = resolved.get(name);
12398
+ if (cached !== void 0) return Promise.resolve(cached);
12399
+ const existing = inflight.get(name);
12400
+ if (existing !== void 0) return existing;
12401
+ const loader = loaders.get(name);
12402
+ if (loader === void 0) return Promise.reject(new UnregisteredThemeError(name));
12403
+ const generation = cacheGeneration;
12404
+ const promise = loader().then((result) => {
12405
+ const theme = unwrapDefault(result);
12406
+ if (generation === cacheGeneration) resolved.set(name, theme);
12407
+ if (inflight.get(name) === promise) inflight.delete(name);
12408
+ return theme;
12409
+ }).catch((err) => {
12410
+ if (inflight.get(name) === promise) inflight.delete(name);
12411
+ throw err;
12412
+ });
12413
+ inflight.set(name, promise);
12414
+ return promise;
12415
+ }
12416
+ function resolveThemes$1(names) {
12417
+ return Promise.all(names.map((name) => resolveTheme(name)));
12418
+ }
12419
+ function seedResolvedTheme(name, theme) {
12420
+ resolved.set(name, theme);
12421
+ }
12422
+ function seedResolvedThemes(entries) {
12423
+ for (const [name, theme] of entries) seedResolvedTheme(name, theme);
12424
+ }
12425
+ function getResolvedTheme(name) {
12426
+ return resolved.get(name);
12427
+ }
12428
+ function getResolvedThemes(names) {
12429
+ const themes = [];
12430
+ for (const name of names) {
12431
+ const theme = resolved.get(name);
12432
+ if (theme === void 0) throw new UnresolvedThemeError(name);
12433
+ themes.push(theme);
12434
+ }
12435
+ return themes;
12436
+ }
12437
+ function hasResolvedTheme(name) {
12438
+ return resolved.has(name);
12439
+ }
12440
+ function hasResolvedThemes(names) {
12441
+ for (const name of names) if (!resolved.has(name)) return false;
12442
+ return true;
12443
+ }
12444
+ function getResolvedOrResolveTheme(name) {
12445
+ const cached = resolved.get(name);
12446
+ if (cached !== void 0) return cached;
12447
+ return resolveTheme(name);
12448
+ }
12449
+ function clearResolvedThemes() {
12450
+ cacheGeneration++;
12451
+ resolved.clear();
12452
+ inflight.clear();
12453
+ }
12454
+ return {
12455
+ clearResolvedThemes,
12456
+ getResolvedOrResolveTheme,
12457
+ getResolvedTheme,
12458
+ getResolvedThemes,
12459
+ hasRegisteredTheme,
12460
+ hasResolvedTheme,
12461
+ hasResolvedThemes,
12462
+ registerTheme,
12463
+ registerThemeIfAbsent,
12464
+ resolveTheme,
12465
+ resolveThemes: resolveThemes$1,
12466
+ seedResolvedTheme,
12467
+ seedResolvedThemes
12468
+ };
12469
+ }
12470
+
12471
+ //#endregion
12472
+ //#region ../theming/dist/modules/createThemeController.js
12473
+ const FALLBACK_LIGHT_THEME = "pierre-light";
12474
+ const FALLBACK_DARK_THEME = "pierre-dark";
12475
+ function getStorage() {
12476
+ try {
12477
+ if (typeof globalThis !== "undefined" && globalThis.localStorage != null) return globalThis.localStorage;
12478
+ } catch {}
12479
+ }
12480
+ function createLocalStorageAdapter(storageKey, defaults) {
12481
+ return {
12482
+ load() {
12483
+ const raw$1 = getStorage()?.getItem(storageKey);
12484
+ if (raw$1 == null) return null;
12485
+ try {
12486
+ const parsed = JSON.parse(raw$1);
12487
+ if (parsed.mode == null) return null;
12488
+ return {
12489
+ darkThemeName: parsed.darkThemeName ?? defaults.darkThemeName,
12490
+ lightThemeName: parsed.lightThemeName ?? defaults.lightThemeName,
12491
+ mode: parsed.mode
12492
+ };
12493
+ } catch {
12494
+ return null;
12495
+ }
12496
+ },
12497
+ save(selection) {
12498
+ const storage = getStorage();
12499
+ try {
12500
+ storage?.setItem(storageKey, JSON.stringify(selection));
12501
+ } catch {}
12502
+ }
12503
+ };
12504
+ }
12505
+ function systemPrefersDark() {
12506
+ try {
12507
+ if (typeof globalThis !== "undefined" && globalThis.matchMedia != null) return globalThis.matchMedia("(prefers-color-scheme: dark)").matches;
12508
+ } catch {}
12509
+ return false;
12510
+ }
12511
+ function resolveColorScheme(mode) {
12512
+ if (mode === "dark") return "dark";
12513
+ if (mode === "light") return "light";
12514
+ return systemPrefersDark() ? "dark" : "light";
12515
+ }
12516
+ function createThemeController(options) {
12517
+ const { storageKey, preloadInactive = false } = options;
12518
+ const catalog = "catalog" in options && options.catalog != null ? options.catalog : void 0;
12519
+ const selectedResolver = options.resolver ?? (catalog != null ? createThemeResolver() : void 0);
12520
+ if (selectedResolver == null) throw new Error("createThemeController requires a catalog or resolver");
12521
+ const resolver = selectedResolver;
12522
+ catalog?.registerInto(resolver);
12523
+ const defaultDarkThemeName = options.defaultDarkThemeName ?? catalog?.defaultDarkThemeName ?? FALLBACK_DARK_THEME;
12524
+ const defaultLightThemeName = options.defaultLightThemeName ?? catalog?.defaultLightThemeName ?? FALLBACK_LIGHT_THEME;
12525
+ const persistence = options.persistence ?? (storageKey != null ? createLocalStorageAdapter(storageKey, {
12526
+ darkThemeName: defaultDarkThemeName,
12527
+ lightThemeName: defaultLightThemeName
12528
+ }) : void 0);
12529
+ const initialMode = options.defaultMode ?? "system";
12530
+ let state = {
12531
+ darkThemeName: defaultDarkThemeName,
12532
+ lightThemeName: defaultLightThemeName,
12533
+ mode: initialMode,
12534
+ resolvedTheme: void 0,
12535
+ resolvedColorScheme: resolveColorScheme(initialMode)
12536
+ };
12537
+ const listeners = /* @__PURE__ */ new Set();
12538
+ let activeResolutionId = 0;
12539
+ let pendingSelectionPatch;
12540
+ function notify() {
12541
+ for (const listener of listeners) listener();
12542
+ }
12543
+ function hydrateFromStorage() {
12544
+ const loaded = persistence?.load();
12545
+ if (loaded == null) return;
12546
+ state = {
12547
+ ...state,
12548
+ darkThemeName: loaded.darkThemeName,
12549
+ lightThemeName: loaded.lightThemeName,
12550
+ mode: loaded.mode,
12551
+ resolvedColorScheme: resolveColorScheme(loaded.mode)
12552
+ };
12553
+ }
12554
+ function persist() {
12555
+ persistence?.save({
12556
+ darkThemeName: state.darkThemeName,
12557
+ lightThemeName: state.lightThemeName,
12558
+ mode: state.mode
12559
+ });
12560
+ }
12561
+ function activeThemeNameFor(selection) {
12562
+ return selection.resolvedColorScheme === "dark" ? selection.darkThemeName : selection.lightThemeName;
12563
+ }
12564
+ function intendedState(patch = {}) {
12565
+ return {
12566
+ ...state,
12567
+ ...pendingSelectionPatch,
12568
+ ...patch
12569
+ };
12570
+ }
12571
+ function reportResolutionError(error, context) {
12572
+ if (options.onResolutionError != null) {
12573
+ options.onResolutionError(error, context);
12574
+ return;
12575
+ }
12576
+ console.error(`[theming] Failed to resolve theme "${context.name}" for ${context.colorScheme} color scheme`, error);
12577
+ }
12578
+ function preloadInactiveFor(selection) {
12579
+ if (!preloadInactive) return;
12580
+ const activeName = activeThemeNameFor(selection);
12581
+ const inactive = selection.resolvedColorScheme === "dark" ? selection.lightThemeName : selection.darkThemeName;
12582
+ if (inactive !== activeName && resolver.getResolvedTheme(inactive) === void 0) resolver.resolveTheme(inactive).catch(() => {});
12583
+ }
12584
+ function resolveActive(patch = {}, { notifyPending = false, persistOnSuccess = false } = {}) {
12585
+ const selectionPatch = {
12586
+ ...pendingSelectionPatch,
12587
+ ...patch
12588
+ };
12589
+ const next = intendedState(patch);
12590
+ const name = activeThemeNameFor(next);
12591
+ const colorScheme = next.resolvedColorScheme;
12592
+ const cached = resolver.getResolvedTheme(name);
12593
+ if (cached !== void 0) {
12594
+ activeResolutionId++;
12595
+ pendingSelectionPatch = void 0;
12596
+ state = {
12597
+ ...state,
12598
+ ...selectionPatch,
12599
+ pendingThemeResolution: void 0,
12600
+ resolutionError: void 0,
12601
+ resolvedTheme: cached
12602
+ };
12603
+ if (persistOnSuccess) persist();
12604
+ notify();
12605
+ preloadInactiveFor(state);
12606
+ return;
12607
+ }
12608
+ const resolutionId = ++activeResolutionId;
12609
+ pendingSelectionPatch = selectionPatch;
12610
+ state = {
12611
+ ...state,
12612
+ pendingThemeResolution: {
12613
+ colorScheme,
12614
+ name
12615
+ },
12616
+ resolutionError: void 0
12617
+ };
12618
+ if (notifyPending) notify();
12619
+ resolver.resolveTheme(name).then((theme) => {
12620
+ if (resolutionId !== activeResolutionId) return;
12621
+ const latestIntended = intendedState();
12622
+ if (latestIntended.resolvedColorScheme !== colorScheme || activeThemeNameFor(latestIntended) !== name) return;
12623
+ const patchToCommit = pendingSelectionPatch ?? {};
12624
+ pendingSelectionPatch = void 0;
12625
+ state = {
12626
+ ...state,
12627
+ ...patchToCommit,
12628
+ pendingThemeResolution: void 0,
12629
+ resolutionError: void 0,
12630
+ resolvedTheme: theme
12631
+ };
12632
+ if (persistOnSuccess) persist();
12633
+ notify();
12634
+ preloadInactiveFor(state);
12635
+ }).catch((error) => {
12636
+ if (resolutionId !== activeResolutionId) return;
12637
+ pendingSelectionPatch = void 0;
12638
+ state = {
12639
+ ...state,
12640
+ pendingThemeResolution: void 0,
12641
+ resolutionError: {
12642
+ colorScheme,
12643
+ error,
12644
+ name
12645
+ }
12646
+ };
12647
+ reportResolutionError(error, {
12648
+ colorScheme,
12649
+ name
12650
+ });
12651
+ notify();
12652
+ });
12653
+ }
12654
+ function updateInactiveThemeName(key$1, name) {
12655
+ state = {
12656
+ ...state,
12657
+ [key$1]: name,
12658
+ resolutionError: void 0
12659
+ };
12660
+ persist();
12661
+ notify();
12662
+ preloadInactiveFor(state);
12663
+ }
12664
+ function isSchemeActiveInIntendedState(scheme, patch = {}) {
12665
+ return intendedState(patch).resolvedColorScheme === scheme;
12666
+ }
12667
+ function setActiveSelection(patch) {
12668
+ resolveActive(patch, {
12669
+ notifyPending: true,
12670
+ persistOnSuccess: true
12671
+ });
12672
+ }
12673
+ function setInactiveThemeName(scheme, key$1, name) {
12674
+ if (isSchemeActiveInIntendedState(scheme, { [key$1]: name })) setActiveSelection({ [key$1]: name });
12675
+ else updateInactiveThemeName(key$1, name);
12676
+ }
12677
+ function setMode(mode) {
12678
+ setActiveSelection({
12679
+ mode,
12680
+ resolvedColorScheme: resolveColorScheme(mode)
12681
+ });
12682
+ }
12683
+ function maybeUpdateSystemColorScheme() {
12684
+ if (intendedState().mode !== "system") return;
12685
+ const next = resolveColorScheme("system");
12686
+ if (next !== intendedState().resolvedColorScheme) resolveActive({ resolvedColorScheme: next }, { notifyPending: true });
12687
+ }
12688
+ function isSelectedValue(key$1, value) {
12689
+ return intendedState()[key$1] === value;
12690
+ }
12691
+ let mediaQuery;
12692
+ const handleMediaChange = () => {
12693
+ maybeUpdateSystemColorScheme();
12694
+ };
12695
+ function attachMediaListener() {
12696
+ try {
12697
+ if (typeof globalThis !== "undefined" && globalThis.matchMedia != null) {
12698
+ mediaQuery = globalThis.matchMedia("(prefers-color-scheme: dark)");
12699
+ mediaQuery.addEventListener("change", handleMediaChange);
12700
+ }
12701
+ } catch {}
12702
+ }
12703
+ hydrateFromStorage();
12704
+ attachMediaListener();
12705
+ resolveActive();
12706
+ return {
12707
+ resolver,
12708
+ destroy() {
12709
+ if (mediaQuery != null) {
12710
+ mediaQuery.removeEventListener("change", handleMediaChange);
12711
+ mediaQuery = void 0;
12712
+ }
12713
+ listeners.clear();
12714
+ },
12715
+ getState() {
12716
+ return state;
12717
+ },
12718
+ setColorMode(mode) {
12719
+ if (isSelectedValue("mode", mode)) return;
12720
+ setMode(mode);
12721
+ },
12722
+ setThemeNameForScheme(scheme, name) {
12723
+ const key$1 = scheme === "light" ? "lightThemeName" : "darkThemeName";
12724
+ if (isSelectedValue(key$1, name)) return;
12725
+ setInactiveThemeName(scheme, key$1, name);
12726
+ },
12727
+ subscribe(listener) {
12728
+ listeners.add(listener);
12729
+ return () => {
12730
+ listeners.delete(listener);
12731
+ };
12732
+ }
12733
+ };
12734
+ }
12735
+
12736
+ //#endregion
12737
+ //#region src/highlighter/themes/themeResolver.ts
12738
+ const themeResolver = createThemeResolver();
12739
+
12242
12740
  //#endregion
12243
12741
  //#region src/highlighter/themes/attachResolvedThemes.ts
12244
12742
  function attachResolvedThemes(themes, highlighter$1) {
@@ -12246,15 +12744,15 @@ function attachResolvedThemes(themes, highlighter$1) {
12246
12744
  for (let themeRef of themes) {
12247
12745
  let resolvedTheme;
12248
12746
  if (typeof themeRef === "string") {
12249
- resolvedTheme = ResolvedThemes.get(themeRef);
12747
+ resolvedTheme = themeResolver.getResolvedTheme(themeRef);
12250
12748
  if (resolvedTheme == null) {
12251
12749
  throw new Error(`loadResolvedThemes: ${themeRef} is not resolved, you must resolve it before calling loadResolvedThemes`);
12252
12750
  }
12253
12751
  } else {
12254
12752
  resolvedTheme = themeRef;
12255
12753
  themeRef = themeRef.name;
12256
- if (!ResolvedThemes.has(themeRef)) {
12257
- ResolvedThemes.set(themeRef, resolvedTheme);
12754
+ if (themeResolver.getResolvedTheme(themeRef) == null) {
12755
+ themeResolver.seedResolvedTheme(themeRef, resolvedTheme);
12258
12756
  }
12259
12757
  }
12260
12758
  if (AttachedThemes.has(themeRef)) continue;
@@ -14071,7 +14569,10 @@ function cleanLastNewline(contents) {
14071
14569
  }
14072
14570
 
14073
14571
  //#endregion
14074
- //#region ../../node_modules/.bun/@shikijs+transformers@4.0.2/node_modules/@shikijs/transformers/dist/index.mjs
14572
+ //#region ../../node_modules/.bun/@shikijs+transformers@4.2.0/node_modules/@shikijs/transformers/dist/index.mjs
14573
+ const RE_SPLIT_COMMENT = /(\s+\/\/)/;
14574
+ const RE_V1_END_COMMENT_PREFIX = /(?:\/\/|["'#]|;{1,2}|%{1,2}|--)(\s*)$/;
14575
+ const RE_V3_END_COMMENT_PREFIX = /(?:\/\/|#|;{1,2}|%{1,2}|--)(\s*)$/;
14075
14576
  /**
14076
14577
  * some comment formats have to be located at the end of line
14077
14578
  * hence we can skip matching them for other tokens
@@ -14097,7 +14598,7 @@ function parseComments(lines, jsx, matchAlgorithm) {
14097
14598
  if (token$1.type !== "text") return element$1;
14098
14599
  const isLast = idx === line.children.length - 1;
14099
14600
  if (!matchToken(token$1.value, isLast)) return element$1;
14100
- const rawSplits = token$1.value.split(/(\s+\/\/)/);
14601
+ const rawSplits = token$1.value.split(RE_SPLIT_COMMENT);
14101
14602
  if (rawSplits.length <= 1) return element$1;
14102
14603
  let splits = [rawSplits[0]];
14103
14604
  for (let i$2 = 1; i$2 < rawSplits.length; i$2 += 2) splits.push(rawSplits[i$2] + (rawSplits[i$2 + 1] || ""));
@@ -14203,12 +14704,22 @@ function matchToken(text$1, isLast) {
14203
14704
  * For matchAlgorithm v1
14204
14705
  */
14205
14706
  function v1ClearEndCommentPrefix(text$1) {
14206
- const match = text$1.match(/(?:\/\/|["'#]|;{1,2}|%{1,2}|--)(\s*)$/);
14707
+ const match = text$1.match(RE_V1_END_COMMENT_PREFIX);
14207
14708
  if (match && match[1].trim().length === 0) return text$1.slice(0, match.index);
14208
14709
  return text$1;
14209
14710
  }
14711
+ /**
14712
+ * Remove empty comment prefixes at line end, e.g. `// `
14713
+ *
14714
+ * For matchAlgorithm v3
14715
+ */
14716
+ function v3ClearEndCommentPrefix(text$1) {
14717
+ const match = text$1.match(RE_V3_END_COMMENT_PREFIX);
14718
+ if (match && match[1].trim().length === 0) return text$1.slice(0, match.index).trimEnd();
14719
+ return text$1;
14720
+ }
14210
14721
  function createCommentNotationTransformer(name, regex, onMatch, matchAlgorithm) {
14211
- if (matchAlgorithm == null) matchAlgorithm = "v3";
14722
+ matchAlgorithm ??= "v3";
14212
14723
  return {
14213
14724
  name,
14214
14725
  code(code) {
@@ -14232,6 +14743,7 @@ function createCommentNotationTransformer(name, regex, onMatch, matchAlgorithm)
14232
14743
  });
14233
14744
  if (!replaced) continue;
14234
14745
  if (matchAlgorithm === "v1") comment$1.info[1] = v1ClearEndCommentPrefix(comment$1.info[1]);
14746
+ else if (matchAlgorithm === "v3") comment$1.info[1] = v3ClearEndCommentPrefix(comment$1.info[1]);
14235
14747
  const isEmpty = comment$1.info[1].trim().length === 0;
14236
14748
  if (isEmpty) comment$1.info[1] = "";
14237
14749
  if (isEmpty && comment$1.isLineCommentOnly) linesToRemove.push(comment$1.line);
@@ -14277,9 +14789,10 @@ function transformerCompactLineOptions(lineOptions = []) {
14277
14789
  }
14278
14790
  };
14279
14791
  }
14792
+ const RE_HIGHLIGHT_LINES = /\{([\d,-]+)\}/;
14280
14793
  function parseMetaHighlightString(meta) {
14281
14794
  if (!meta) return null;
14282
- const match = meta.match(/\{([\d,-]+)\}/);
14795
+ const match = meta.match(RE_HIGHLIGHT_LINES);
14283
14796
  if (!match) return null;
14284
14797
  return match[1].split(",").flatMap((v$1) => {
14285
14798
  const range$1 = v$1.split("-").map((n) => Number.parseInt(n, 10));
@@ -14305,9 +14818,11 @@ function transformerMetaHighlight(options = {}) {
14305
14818
  }
14306
14819
  };
14307
14820
  }
14821
+ const RE_WORD_MATCH = /\/((?:\\.|[^/])+)\//g;
14822
+ const RE_ESCAPE_BACKSLASH = /\\(.)/g;
14308
14823
  function parseMetaHighlightWords(meta) {
14309
14824
  if (!meta) return [];
14310
- return Array.from(meta.matchAll(/\/((?:\\.|[^/])+)\//g)).map((v$1) => v$1[1].replace(/\\(.)/g, "$1"));
14825
+ return [...meta.matchAll(RE_WORD_MATCH)].map((v$1) => v$1[1].replace(RE_ESCAPE_BACKSLASH, "$1"));
14311
14826
  }
14312
14827
  /**
14313
14828
  * Allow using `/word/` in the code snippet meta to mark highlighted words.
@@ -14343,8 +14858,9 @@ function findAllSubstringIndexes(str, substr) {
14343
14858
  }
14344
14859
  return indexes;
14345
14860
  }
14861
+ const RE_ESCAPE_SPECIAL = /[.*+?^${}()|[\]\\]/g;
14346
14862
  function escapeRegExp(str) {
14347
- return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
14863
+ return str.replace(RE_ESCAPE_SPECIAL, "\\$&");
14348
14864
  }
14349
14865
  function transformerNotationMap(options = {}, name = "@shikijs/transformers:notation-map") {
14350
14866
  const { classMap = {}, classActivePre = void 0, classActiveCode = void 0 } = options;
@@ -14476,11 +14992,13 @@ function inheritElement(original, overrides) {
14476
14992
  ...overrides
14477
14993
  };
14478
14994
  }
14995
+ const RE_CODE_WORD = /\s*\[!code word:((?:\\.|[^:\]])+)(:\d+)?\]/;
14996
+ const RE_UNESCAPE = /\\(.)/g;
14479
14997
  function transformerNotationWordHighlight(options = {}) {
14480
14998
  const { classActiveWord = "highlighted-word", classActivePre = void 0 } = options;
14481
- return createCommentNotationTransformer("@shikijs/transformers:notation-highlight-word", /\s*\[!code word:((?:\\.|[^:\]])+)(:\d+)?\]/, function([_$2, word, range$1], _line, comment$1, lines, index) {
14999
+ return createCommentNotationTransformer("@shikijs/transformers:notation-highlight-word", RE_CODE_WORD, function([_$2, word, range$1], _line, comment$1, lines, index) {
14482
15000
  const lineNum = range$1 ? Number.parseInt(range$1.slice(1), 10) : lines.length;
14483
- word = word.replace(/\\(.)/g, "$1");
15001
+ word = word.replace(RE_UNESCAPE, "$1");
14484
15002
  for (let i$2 = index; i$2 < Math.min(index + lineNum, lines.length); i$2++) highlightWordInLine.call(this, lines[i$2], comment$1, word, classActiveWord);
14485
15003
  if (classActivePre) this.addClassToHast(this.pre, classActivePre);
14486
15004
  return true;
@@ -14542,6 +15060,8 @@ function transformerRemoveNotationEscape() {
14542
15060
  }
14543
15061
  };
14544
15062
  }
15063
+ const RE_INDENT_META = /\{indent:(\d+|false)\}/;
15064
+ const RE_NON_BLANK = /[^ \t]/;
14545
15065
  /**
14546
15066
  * Render indentations as separate tokens.
14547
15067
  * Apply with CSS, it can be used to render indent guides visually.
@@ -14550,7 +15070,7 @@ function transformerRenderIndentGuides(options = {}) {
14550
15070
  return {
14551
15071
  name: "@shikijs/transformers:render-indent-guides",
14552
15072
  code(hast) {
14553
- const indent = Number(this.options.meta?.indent ?? this.options.meta?.__raw?.match(/\{indent:(\d+|false)\}/)?.[1] ?? options.indent ?? 2);
15073
+ const indent = Number(this.options.meta?.indent ?? this.options.meta?.__raw?.match(RE_INDENT_META)?.[1] ?? options.indent ?? 2);
14554
15074
  if (Number.isNaN(indent) || indent <= 0) return hast;
14555
15075
  const indentRegex = new RegExp(` {${indent}}| {0,${indent - 1}}\t| {1,}$`, "g");
14556
15076
  const emptyLines = [];
@@ -14563,7 +15083,7 @@ function transformerRenderIndentGuides(options = {}) {
14563
15083
  continue;
14564
15084
  }
14565
15085
  const text$1 = first.children[0];
14566
- const blanks = text$1.value.split(/[^ \t]/, 1)[0];
15086
+ const blanks = text$1.value.split(RE_NON_BLANK, 1)[0];
14567
15087
  const ranges = [];
14568
15088
  for (const match of blanks.matchAll(indentRegex)) {
14569
15089
  const start = match.index;
@@ -14638,6 +15158,7 @@ function splitSpaces(parts, type, renderContinuousSpaces = true) {
14638
15158
  ...parts.slice(parts.length - rightCount)
14639
15159
  ];
14640
15160
  }
15161
+ const RE_SPACE_OR_TAB = /([ \t])/;
14641
15162
  /**
14642
15163
  * Render whitespaces as separate tokens.
14643
15164
  * Apply with CSS, it can be used to render tabs and spaces visually.
@@ -14665,7 +15186,7 @@ function transformerRenderWhitespace(options = {}) {
14665
15186
  if (position === "leading" && index !== 0) return token$1;
14666
15187
  const node = token$1.children[0];
14667
15188
  if (node.type !== "text" || !node.value) return token$1;
14668
- const parts = splitSpaces(node.value.split(/([ \t])/).filter((i$2) => i$2.length), position === "boundary" && index === last && last !== 0 ? "trailing" : position, position !== "trailing" && position !== "leading");
15189
+ const parts = splitSpaces(node.value.split(RE_SPACE_OR_TAB).filter((i$2) => i$2.length), position === "boundary" && index === last && last !== 0 ? "trailing" : position, position !== "trailing" && position !== "leading");
14669
15190
  if (parts.length <= 1) return token$1;
14670
15191
  return parts.map((part) => {
14671
15192
  const clone$1 = {
@@ -15069,30 +15590,234 @@ function formatCSSVariablePrefix(type) {
15069
15590
  return `--${type === "token" ? "diffs-token" : "diffs"}-`;
15070
15591
  }
15071
15592
 
15593
+ //#endregion
15594
+ //#region ../theming/dist/modules/color.js
15595
+ /**
15596
+ * Canonical color/contrast primitives
15597
+ */
15598
+ const MIN_READABLE_RATIO = 3;
15599
+ const MIN_MUTED_RATIO = 4.5;
15600
+ const HEX_TRANSPARENT_RE = /^#(?:[0-9a-f]{3}0|[0-9a-f]{6}00)$/i;
15601
+ const ALPHA_ZERO_RE = /^0(?:\.0+)?%?$/;
15602
+ function getFunctionalAlpha(color) {
15603
+ const openParen = color.indexOf("(");
15604
+ if (openParen <= 0 || !color.endsWith(")")) return;
15605
+ const fn = color.slice(0, openParen).trim();
15606
+ if (!/^(?:rgb|rgba|hsl|hsla|hwb|lab|lch|oklab|oklch|color)$/i.test(fn)) return;
15607
+ const inner = color.slice(openParen + 1, -1).trim();
15608
+ if (inner.length === 0) return;
15609
+ const slashIndex = inner.lastIndexOf("/");
15610
+ if (slashIndex !== -1) return inner.slice(slashIndex + 1).trim();
15611
+ if (/^(?:rgba|hsla)$/i.test(fn)) {
15612
+ const parts = inner.split(",");
15613
+ if (parts.length === 4) return parts[3]?.trim();
15614
+ }
15615
+ }
15616
+ function parseHexRgba(color) {
15617
+ const match = /^#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})\b/i.exec(color.trim());
15618
+ if (match == null) return null;
15619
+ const hex = match[1];
15620
+ let expanded;
15621
+ let alpha = 1;
15622
+ if (hex.length === 3) expanded = hex.split("").map((c) => c + c).join("");
15623
+ else if (hex.length === 6) expanded = hex;
15624
+ else {
15625
+ expanded = hex.slice(0, 6);
15626
+ alpha = parseInt(hex.slice(6, 8), 16) / 255;
15627
+ }
15628
+ return [
15629
+ parseInt(expanded.slice(0, 2), 16),
15630
+ parseInt(expanded.slice(2, 4), 16),
15631
+ parseInt(expanded.slice(4, 6), 16),
15632
+ alpha
15633
+ ];
15634
+ }
15635
+ function relativeLuminance(color) {
15636
+ if (color == null) return null;
15637
+ const rgba = parseHexRgba(color);
15638
+ if (rgba == null) return null;
15639
+ const r$3 = rgba[0] / 255;
15640
+ const g = rgba[1] / 255;
15641
+ const b$2 = rgba[2] / 255;
15642
+ const channel = (v$1) => v$1 <= .03928 ? v$1 / 12.92 : ((v$1 + .055) / 1.055) ** 2.4;
15643
+ return .2126 * channel(r$3) + .7152 * channel(g) + .0722 * channel(b$2);
15644
+ }
15645
+ function contrastRatio(a$1, b$2) {
15646
+ const [hi, lo] = a$1 > b$2 ? [a$1, b$2] : [b$2, a$1];
15647
+ return (hi + .05) / (lo + .05);
15648
+ }
15649
+ function compositeOverBg(fgColor, bgColor) {
15650
+ if (bgColor == null) return void 0;
15651
+ const fgParts = parseHexRgba(fgColor);
15652
+ const bgParts = parseHexRgba(bgColor);
15653
+ if (fgParts == null || bgParts == null) return void 0;
15654
+ const [fr, fg, fb, fa] = fgParts;
15655
+ const [br, bg, bb] = bgParts;
15656
+ return "#" + [
15657
+ Math.round(fr * fa + br * (1 - fa)),
15658
+ Math.round(fg * fa + bg * (1 - fa)),
15659
+ Math.round(fb * fa + bb * (1 - fa))
15660
+ ].map((v$1) => v$1.toString(16).padStart(2, "0")).join("");
15661
+ }
15662
+ function isFullyTransparent(color) {
15663
+ if (color == null) return false;
15664
+ const normalized = color.trim().toLowerCase();
15665
+ if (normalized === "transparent") return true;
15666
+ if (HEX_TRANSPARENT_RE.test(normalized)) return true;
15667
+ const alpha = getFunctionalAlpha(normalized);
15668
+ return alpha != null && ALPHA_ZERO_RE.test(alpha);
15669
+ }
15670
+ function isDarkSurface(bg, fgHint) {
15671
+ const fromBg = relativeLuminance(bg);
15672
+ if (fromBg != null) return fromBg < .4;
15673
+ const fromFg = relativeLuminance(fgHint);
15674
+ return fromFg != null ? fromFg > .6 : false;
15675
+ }
15676
+ function surfacesMatch(a$1, b$2) {
15677
+ if (a$1 == null || b$2 == null) return false;
15678
+ if (a$1.trim().toLowerCase() === b$2.trim().toLowerCase()) return true;
15679
+ const la = relativeLuminance(a$1);
15680
+ const lb = relativeLuminance(b$2);
15681
+ if (la == null || lb == null) return false;
15682
+ return Math.abs(la - lb) < .06;
15683
+ }
15684
+ function hoverWouldEraseText(hover, bg, fg) {
15685
+ if (bg == null || fg == null) return false;
15686
+ const hoverL = relativeLuminance(hover);
15687
+ const bgL = relativeLuminance(bg);
15688
+ const fgL = relativeLuminance(fg);
15689
+ if (hoverL == null || bgL == null || fgL == null) return false;
15690
+ return Math.abs(hoverL - fgL) < Math.abs(hoverL - bgL);
15691
+ }
15692
+ function pickReadableForeground(bg, candidates) {
15693
+ const bgL = relativeLuminance(bg);
15694
+ const firstDefined = candidates.find((candidate) => candidate != null && candidate !== "");
15695
+ if (bgL == null) return firstDefined;
15696
+ let best;
15697
+ let bestRatio = -1;
15698
+ for (const candidate of candidates) {
15699
+ if (candidate == null || candidate === "") continue;
15700
+ const candidateL = relativeLuminance(candidate);
15701
+ if (candidateL == null) continue;
15702
+ const ratio = contrastRatio(bgL, candidateL);
15703
+ if (ratio >= MIN_READABLE_RATIO) return candidate;
15704
+ if (ratio > bestRatio) {
15705
+ best = candidate;
15706
+ bestRatio = ratio;
15707
+ }
15708
+ }
15709
+ return best ?? firstDefined;
15710
+ }
15711
+ function deriveMutedFg(primaryFg, bg) {
15712
+ if (bg == null) return primaryFg;
15713
+ const fgParts = parseHexRgba(primaryFg);
15714
+ const bgParts = parseHexRgba(bg);
15715
+ const bgL = relativeLuminance(bg);
15716
+ if (fgParts == null || bgParts == null || bgL == null) return `color-mix(in srgb, ${primaryFg} 70%, ${bg})`;
15717
+ const [fr, fg2, fb] = fgParts;
15718
+ const [br, bg3, bb] = bgParts;
15719
+ for (const weight of [
15720
+ .6,
15721
+ .7,
15722
+ .8,
15723
+ .9
15724
+ ]) {
15725
+ const hex = "#" + [
15726
+ Math.round(fr * weight + br * (1 - weight)),
15727
+ Math.round(fg2 * weight + bg3 * (1 - weight)),
15728
+ Math.round(fb * weight + bb * (1 - weight))
15729
+ ].map((v$1) => v$1.toString(16).padStart(2, "0")).join("");
15730
+ const L$2 = relativeLuminance(hex);
15731
+ if (L$2 != null && contrastRatio(bgL, L$2) >= MIN_MUTED_RATIO) return hex;
15732
+ }
15733
+ return primaryFg;
15734
+ }
15735
+
15736
+ //#endregion
15737
+ //#region ../theming/dist/modules/normalizeThemeColors.js
15738
+ const cache = /* @__PURE__ */ new WeakMap();
15739
+ function normalizeThemeColors(theme) {
15740
+ const cached = cache.get(theme);
15741
+ if (cached != null) return cached;
15742
+ const originalColors = theme.colors ?? {};
15743
+ const colors = { ...originalColors };
15744
+ const editorBackground = originalColors["editor.background"] ?? theme.bg;
15745
+ const editorForeground = originalColors["editor.foreground"] ?? theme.fg;
15746
+ const sidebarBackground = originalColors["sideBar.background"] ?? editorBackground;
15747
+ const sidebarForeground = originalColors["sideBar.foreground"] ?? editorForeground;
15748
+ fill(colors, "editor.background", editorBackground);
15749
+ fill(colors, "editor.foreground", editorForeground);
15750
+ fill(colors, "sideBar.background", sidebarBackground);
15751
+ fill(colors, "sideBar.foreground", sidebarForeground);
15752
+ fill(colors, "input.background", originalColors["input.background"] ?? sidebarBackground);
15753
+ fill(colors, "sideBarSectionHeader.foreground", originalColors["sideBarSectionHeader.foreground"] ?? sidebarForeground);
15754
+ fill(colors, "list.activeSelectionForeground", originalColors["list.activeSelectionForeground"] ?? sidebarForeground);
15755
+ fill(colors, "gitDecoration.addedResourceForeground", firstColor(originalColors["gitDecoration.addedResourceForeground"], originalColors["terminal.ansiGreen"], originalColors["editorGutter.addedBackground"]));
15756
+ fill(colors, "gitDecoration.modifiedResourceForeground", firstColor(originalColors["gitDecoration.modifiedResourceForeground"], originalColors["terminal.ansiBlue"], originalColors["editorGutter.modifiedBackground"]));
15757
+ fill(colors, "gitDecoration.deletedResourceForeground", firstColor(originalColors["gitDecoration.deletedResourceForeground"], originalColors["terminal.ansiRed"], originalColors["editorGutter.deletedBackground"]));
15758
+ const focusRing = (isFullyTransparent(originalColors["list.focusOutline"]) ? void 0 : originalColors["list.focusOutline"]) ?? (isFullyTransparent(originalColors["focusBorder"]) ? void 0 : originalColors["focusBorder"]);
15759
+ if (focusRing != null) colors["list.focusOutline"] = focusRing;
15760
+ else delete colors["list.focusOutline"];
15761
+ const hover = originalColors["list.hoverBackground"];
15762
+ if (hover != null && (matchesSurface(hover, sidebarBackground) || hoverWouldEraseText(hover, sidebarBackground, sidebarForeground))) delete colors["list.hoverBackground"];
15763
+ const result = Object.freeze({
15764
+ ...theme,
15765
+ colors: Object.freeze(colors)
15766
+ });
15767
+ cache.set(theme, result);
15768
+ return result;
15769
+ }
15770
+ function fill(colors, key$1, value) {
15771
+ if (value != null && value !== "") colors[key$1] = value;
15772
+ }
15773
+ function firstColor(...candidates) {
15774
+ for (const candidate of candidates) if (candidate != null && candidate !== "") return candidate;
15775
+ }
15776
+ function matchesSurface(color, surface) {
15777
+ return surface != null && color.toLowerCase() === surface.toLowerCase();
15778
+ }
15779
+
15780
+ //#endregion
15781
+ //#region ../theming/dist/color.js
15782
+ const colorUtils = {
15783
+ compositeOverBg,
15784
+ contrastRatio,
15785
+ deriveMutedFg,
15786
+ hoverWouldEraseText,
15787
+ isDarkSurface,
15788
+ isFullyTransparent,
15789
+ pickReadableForeground,
15790
+ relativeLuminance,
15791
+ surfacesMatch
15792
+ };
15793
+
15072
15794
  //#endregion
15073
15795
  //#region src/utils/getHighlighterThemeStyles.ts
15074
15796
  function getHighlighterThemeStyles({ theme = DEFAULT_THEMES, highlighter: highlighter$1, prefix }) {
15075
15797
  let styles = "";
15076
15798
  if (typeof theme === "string") {
15077
15799
  const themeData = highlighter$1.getTheme(theme);
15078
- styles += `color:${themeData.fg};`;
15079
- styles += `background-color:${themeData.bg};`;
15080
- styles += `${formatCSSVariablePrefix("global")}fg:${themeData.fg};`;
15081
- styles += `${formatCSSVariablePrefix("global")}bg:${themeData.bg};`;
15082
- styles += getThemeVariables(themeData, prefix);
15800
+ const normalized = normalizeThemeColors(themeData);
15801
+ styles += `color:${normalized.fg};`;
15802
+ styles += `background-color:${normalized.bg};`;
15803
+ styles += `${formatCSSVariablePrefix("global")}fg:${normalized.fg};`;
15804
+ styles += `${formatCSSVariablePrefix("global")}bg:${normalized.bg};`;
15805
+ styles += getGitVariables(themeData, prefix);
15083
15806
  } else {
15084
15807
  let themeData = highlighter$1.getTheme(theme.dark);
15085
- styles += `${formatCSSVariablePrefix("global")}dark:${themeData.fg};`;
15086
- styles += `${formatCSSVariablePrefix("global")}dark-bg:${themeData.bg};`;
15087
- styles += getThemeVariables(themeData, "dark");
15808
+ let normalized = normalizeThemeColors(themeData);
15809
+ styles += `${formatCSSVariablePrefix("global")}dark:${normalized.fg};`;
15810
+ styles += `${formatCSSVariablePrefix("global")}dark-bg:${normalized.bg};`;
15811
+ styles += getGitVariables(themeData, "dark");
15088
15812
  themeData = highlighter$1.getTheme(theme.light);
15089
- styles += `${formatCSSVariablePrefix("global")}light:${themeData.fg};`;
15090
- styles += `${formatCSSVariablePrefix("global")}light-bg:${themeData.bg};`;
15091
- styles += getThemeVariables(themeData, "light");
15813
+ normalized = normalizeThemeColors(themeData);
15814
+ styles += `${formatCSSVariablePrefix("global")}light:${normalized.fg};`;
15815
+ styles += `${formatCSSVariablePrefix("global")}light-bg:${normalized.bg};`;
15816
+ styles += getGitVariables(themeData, "light");
15092
15817
  }
15093
15818
  return styles;
15094
15819
  }
15095
- function getThemeVariables(themeData, modePrefix) {
15820
+ function getGitVariables(themeData, modePrefix) {
15096
15821
  modePrefix = modePrefix != null ? `${modePrefix}-` : "";
15097
15822
  let styles = "";
15098
15823
  const additionGreen = themeData.colors?.["gitDecoration.addedResourceForeground"] ?? themeData.colors?.["terminal.ansiGreen"];
@@ -15200,6 +15925,18 @@ function hasTrailingContext(fileDiff) {
15200
15925
  const deletionRemaining = fileDiff.deletionLines.length - (lastHunk.deletionLineIndex + lastHunk.deletionCount);
15201
15926
  return additionRemaining > 0 || deletionRemaining > 0;
15202
15927
  }
15928
+ function hasTrailingContextMismatch(fileDiff) {
15929
+ const lastHunk = fileDiff.hunks[fileDiff.hunks.length - 1];
15930
+ if (lastHunk == null || fileDiff.isPartial || fileDiff.additionLines.length === 0 || fileDiff.deletionLines.length === 0) {
15931
+ return false;
15932
+ }
15933
+ const additionRemaining = fileDiff.additionLines.length - (lastHunk.additionLineIndex + lastHunk.additionCount);
15934
+ const deletionRemaining = fileDiff.deletionLines.length - (lastHunk.deletionLineIndex + lastHunk.deletionCount);
15935
+ if (additionRemaining <= 0 && deletionRemaining <= 0) {
15936
+ return false;
15937
+ }
15938
+ return additionRemaining !== deletionRemaining;
15939
+ }
15203
15940
  function getTrailingContextRangeSize({ fileDiff, errorPrefix }) {
15204
15941
  const lastHunk = fileDiff.hunks[fileDiff.hunks.length - 1];
15205
15942
  if (lastHunk == null || fileDiff.isPartial || fileDiff.additionLines.length === 0 || fileDiff.deletionLines.length === 0) {
@@ -16180,7 +16917,8 @@ function renderTwoFiles({ deletionFile, additionFile, deletionInfo, additionInfo
16180
16917
  transformers,
16181
16918
  decorations: undefined,
16182
16919
  defaultColor: false,
16183
- cssVariablePrefix: formatCSSVariablePrefix("token")
16920
+ cssVariablePrefix: formatCSSVariablePrefix("token"),
16921
+ tokenizeTimeLimit: 0
16184
16922
  } : {
16185
16923
  ...options,
16186
16924
  lang: "text",
@@ -16188,7 +16926,8 @@ function renderTwoFiles({ deletionFile, additionFile, deletionInfo, additionInfo
16188
16926
  transformers,
16189
16927
  decorations: undefined,
16190
16928
  defaultColor: false,
16191
- cssVariablePrefix: formatCSSVariablePrefix("token")
16929
+ cssVariablePrefix: formatCSSVariablePrefix("token"),
16930
+ tokenizeTimeLimit: 0
16192
16931
  };
16193
16932
  })();
16194
16933
  const deletionLines = (() => {
@@ -16281,7 +17020,8 @@ function renderFileWithHighlighter(file, highlighter$1, { theme = DEFAULT_THEMES
16281
17020
  transformers,
16282
17021
  defaultColor: false,
16283
17022
  cssVariablePrefix: formatCSSVariablePrefix("token"),
16284
- tokenizeMaxLineLength
17023
+ tokenizeMaxLineLength,
17024
+ tokenizeTimeLimit: 0
16285
17025
  };
16286
17026
  }
16287
17027
  return {
@@ -16290,7 +17030,8 @@ function renderFileWithHighlighter(file, highlighter$1, { theme = DEFAULT_THEMES
16290
17030
  transformers,
16291
17031
  defaultColor: false,
16292
17032
  cssVariablePrefix: formatCSSVariablePrefix("token"),
16293
- tokenizeMaxLineLength
17033
+ tokenizeMaxLineLength,
17034
+ tokenizeTimeLimit: 0
16294
17035
  };
16295
17036
  })();
16296
17037
  const highlightedLines = getLineNodes(highlighter$1.codeToHast(isWindowedHighlight ? extractWindowedFileContent(lines ?? linesFromFileContents(file.contents), startingLine, totalLines) : file.contents, hastConfig));
@@ -16426,7 +17167,7 @@ function getHighlighter(preferredHighlighter = "shiki-js") {
16426
17167
  highlighter ??= createHighlighterCore({
16427
17168
  themes: [],
16428
17169
  langs: [],
16429
- engine: preferredHighlighter === "shiki-wasm" ? createOnigurumaEngine(import("./wasm-BaDzIkIn.js")) : createJavaScriptRegexEngine()
17170
+ engine: preferredHighlighter === "shiki-wasm" ? createOnigurumaEngine(import("./wasm-qE0LgnY3.js")) : createJavaScriptRegexEngine()
16430
17171
  });
16431
17172
  return highlighter;
16432
17173
  }