@pierre/diffs 1.3.0-beta.2 → 1.3.0-beta.4

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 (158) hide show
  1. package/dist/components/CodeView.d.ts +4 -0
  2. package/dist/components/CodeView.d.ts.map +1 -1
  3. package/dist/components/CodeView.js +38 -0
  4. package/dist/components/CodeView.js.map +1 -1
  5. package/dist/components/File.d.ts +2 -2
  6. package/dist/components/File.d.ts.map +1 -1
  7. package/dist/components/File.js +13 -13
  8. package/dist/components/File.js.map +1 -1
  9. package/dist/components/FileDiff.d.ts +7 -4
  10. package/dist/components/FileDiff.d.ts.map +1 -1
  11. package/dist/components/FileDiff.js +57 -47
  12. package/dist/components/FileDiff.js.map +1 -1
  13. package/dist/components/UnresolvedFile.d.ts.map +1 -1
  14. package/dist/components/UnresolvedFile.js +1 -1
  15. package/dist/components/VirtualizedFile.d.ts +1 -1
  16. package/dist/components/VirtualizedFile.d.ts.map +1 -1
  17. package/dist/components/VirtualizedFile.js +13 -4
  18. package/dist/components/VirtualizedFile.js.map +1 -1
  19. package/dist/components/VirtualizedFileDiff.d.ts +2 -1
  20. package/dist/components/VirtualizedFileDiff.d.ts.map +1 -1
  21. package/dist/components/VirtualizedFileDiff.js +36 -42
  22. package/dist/components/VirtualizedFileDiff.js.map +1 -1
  23. package/dist/components/Virtualizer.js +5 -3
  24. package/dist/components/Virtualizer.js.map +1 -1
  25. package/dist/components/VirtulizerDevelopment.d.ts.map +1 -1
  26. package/dist/editor/editStack.d.ts +1 -1
  27. package/dist/editor/editor.d.ts +14 -6
  28. package/dist/editor/editor.d.ts.map +1 -1
  29. package/dist/editor/editor.js +745 -553
  30. package/dist/editor/editor.js.map +1 -1
  31. package/dist/editor/editor2.js +6 -0
  32. package/dist/editor/editor2.js.map +1 -0
  33. package/dist/editor/lineAnnotations.d.ts +2 -1
  34. package/dist/editor/lineAnnotations.d.ts.map +1 -1
  35. package/dist/editor/lineAnnotations.js +111 -1
  36. package/dist/editor/lineAnnotations.js.map +1 -1
  37. package/dist/editor/marker.d.ts +33 -0
  38. package/dist/editor/marker.d.ts.map +1 -0
  39. package/dist/editor/marker.js +185 -0
  40. package/dist/editor/marker.js.map +1 -0
  41. package/dist/editor/pieceTable.d.ts +3 -3
  42. package/dist/editor/pieceTable.d.ts.map +1 -1
  43. package/dist/editor/pieceTable.js +44 -33
  44. package/dist/editor/pieceTable.js.map +1 -1
  45. package/dist/editor/searchPanel.d.ts +6 -7
  46. package/dist/editor/searchPanel.d.ts.map +1 -1
  47. package/dist/editor/searchPanel.js +103 -138
  48. package/dist/editor/searchPanel.js.map +1 -1
  49. package/dist/editor/selection.d.ts +19 -3
  50. package/dist/editor/selection.d.ts.map +1 -1
  51. package/dist/editor/selection.js +196 -39
  52. package/dist/editor/selection.js.map +1 -1
  53. package/dist/editor/{quickEdit.d.ts → selectionAction.d.ts} +8 -8
  54. package/dist/editor/selectionAction.d.ts.map +1 -0
  55. package/dist/editor/{quickEdit.js → selectionAction.js} +19 -21
  56. package/dist/editor/selectionAction.js.map +1 -0
  57. package/dist/editor/sprite.d.ts +8 -0
  58. package/dist/editor/sprite.d.ts.map +1 -0
  59. package/dist/editor/sprite.js +45 -0
  60. package/dist/editor/sprite.js.map +1 -0
  61. package/dist/editor/textDocument.d.ts +5 -5
  62. package/dist/editor/textDocument.d.ts.map +1 -1
  63. package/dist/editor/textDocument.js +9 -9
  64. package/dist/editor/textDocument.js.map +1 -1
  65. package/dist/editor/textMeasure.js +3 -3
  66. package/dist/editor/textMeasure.js.map +1 -1
  67. package/dist/editor/tokenzier.d.ts +6 -2
  68. package/dist/editor/tokenzier.d.ts.map +1 -1
  69. package/dist/editor/tokenzier.js +135 -85
  70. package/dist/editor/tokenzier.js.map +1 -1
  71. package/dist/editor/utils.d.ts +3 -1
  72. package/dist/editor/utils.d.ts.map +1 -1
  73. package/dist/editor/utils.js +16 -1
  74. package/dist/editor/utils.js.map +1 -1
  75. package/dist/highlighter/shared_highlighter.js +3 -29
  76. package/dist/highlighter/shared_highlighter.js.map +1 -1
  77. package/dist/highlighter/themes/attachResolvedThemes.js +4 -3
  78. package/dist/highlighter/themes/attachResolvedThemes.js.map +1 -1
  79. package/dist/highlighter/themes/cleanUpResolvedThemes.js +3 -2
  80. package/dist/highlighter/themes/cleanUpResolvedThemes.js.map +1 -1
  81. package/dist/highlighter/themes/constants.d.ts +1 -7
  82. package/dist/highlighter/themes/constants.d.ts.map +1 -1
  83. package/dist/highlighter/themes/constants.js +1 -4
  84. package/dist/highlighter/themes/constants.js.map +1 -1
  85. package/dist/highlighter/themes/getResolvedOrResolveTheme.js +2 -2
  86. package/dist/highlighter/themes/getResolvedOrResolveTheme.js.map +1 -1
  87. package/dist/highlighter/themes/getResolvedThemes.js +2 -8
  88. package/dist/highlighter/themes/getResolvedThemes.js.map +1 -1
  89. package/dist/highlighter/themes/hasResolvedThemes.js +2 -3
  90. package/dist/highlighter/themes/hasResolvedThemes.js.map +1 -1
  91. package/dist/highlighter/themes/registerCustomCSSVariableTheme.js +1 -1
  92. package/dist/highlighter/themes/registerCustomTheme.d.ts +5 -3
  93. package/dist/highlighter/themes/registerCustomTheme.d.ts.map +1 -1
  94. package/dist/highlighter/themes/registerCustomTheme.js +15 -5
  95. package/dist/highlighter/themes/registerCustomTheme.js.map +1 -1
  96. package/dist/highlighter/themes/resolveTheme.js +6 -27
  97. package/dist/highlighter/themes/resolveTheme.js.map +1 -1
  98. package/dist/highlighter/themes/resolveThemes.js +5 -12
  99. package/dist/highlighter/themes/resolveThemes.js.map +1 -1
  100. package/dist/highlighter/themes/themeResolution.d.ts +8 -0
  101. package/dist/highlighter/themes/themeResolution.d.ts.map +1 -0
  102. package/dist/highlighter/themes/themeResolution.js +22 -0
  103. package/dist/highlighter/themes/themeResolution.js.map +1 -0
  104. package/dist/highlighter/themes/themeResolver.d.ts +8 -0
  105. package/dist/highlighter/themes/themeResolver.d.ts.map +1 -0
  106. package/dist/highlighter/themes/themeResolver.js +8 -0
  107. package/dist/highlighter/themes/themeResolver.js.map +1 -0
  108. package/dist/index.d.ts +4 -4
  109. package/dist/index.js +3 -3
  110. package/dist/react/index.d.ts +2 -2
  111. package/dist/react/jsx.d.ts.map +1 -1
  112. package/dist/react/utils/useFileDiffInstance.js +1 -0
  113. package/dist/react/utils/useFileDiffInstance.js.map +1 -1
  114. package/dist/renderers/DiffHunksRenderer.d.ts +4 -1
  115. package/dist/renderers/DiffHunksRenderer.d.ts.map +1 -1
  116. package/dist/renderers/DiffHunksRenderer.js +139 -19
  117. package/dist/renderers/DiffHunksRenderer.js.map +1 -1
  118. package/dist/renderers/FileRenderer.d.ts +2 -2
  119. package/dist/renderers/FileRenderer.d.ts.map +1 -1
  120. package/dist/renderers/FileRenderer.js +5 -5
  121. package/dist/renderers/FileRenderer.js.map +1 -1
  122. package/dist/ssr/index.d.ts +2 -2
  123. package/dist/style.js +1 -1
  124. package/dist/style.js.map +1 -1
  125. package/dist/types.d.ts +19 -16
  126. package/dist/types.d.ts.map +1 -1
  127. package/dist/utils/computeEstimatedDiffHeights.js +9 -20
  128. package/dist/utils/computeEstimatedDiffHeights.js.map +1 -1
  129. package/dist/utils/getHighlighterThemeStyles.js +16 -12
  130. package/dist/utils/getHighlighterThemeStyles.js.map +1 -1
  131. package/dist/utils/iterateOverDiff.js +147 -182
  132. package/dist/utils/iterateOverDiff.js.map +1 -1
  133. package/dist/utils/parsePatchFiles.js +93 -4
  134. package/dist/utils/parsePatchFiles.js.map +1 -1
  135. package/dist/utils/updateDiffHunks.d.ts +13 -0
  136. package/dist/utils/updateDiffHunks.d.ts.map +1 -0
  137. package/dist/utils/updateDiffHunks.js +171 -0
  138. package/dist/utils/updateDiffHunks.js.map +1 -0
  139. package/dist/utils/virtualDiffLayout.d.ts +24 -2
  140. package/dist/utils/virtualDiffLayout.d.ts.map +1 -1
  141. package/dist/utils/virtualDiffLayout.js +49 -1
  142. package/dist/utils/virtualDiffLayout.js.map +1 -1
  143. package/dist/worker/WorkerPoolManager.js +1 -1
  144. package/dist/worker/WorkerPoolManager.js.map +1 -1
  145. package/dist/worker/{wasm-D4DU5jgR.js → wasm-BaDzIkIn.js} +2 -2
  146. package/dist/worker/wasm-BaDzIkIn.js.map +1 -0
  147. package/dist/worker/worker-portable.js +1021 -314
  148. package/dist/worker/worker-portable.js.map +1 -1
  149. package/dist/worker/worker.js +202 -196
  150. package/dist/worker/worker.js.map +1 -1
  151. package/package.json +4 -2
  152. package/dist/editor/css.d.ts +0 -6
  153. package/dist/editor/css.d.ts.map +0 -1
  154. package/dist/editor/css.js +0 -218
  155. package/dist/editor/css.js.map +0 -1
  156. package/dist/editor/quickEdit.d.ts.map +0 -1
  157. package/dist/editor/quickEdit.js.map +0 -1
  158. package/dist/worker/wasm-D4DU5jgR.js.map +0 -1
@@ -10,7 +10,7 @@ var __export = (all$1) => {
10
10
  };
11
11
 
12
12
  //#endregion
13
- //#region ../../node_modules/shiki/dist/chunk-CtajNgzt.mjs
13
+ //#region ../../node_modules/.bun/shiki@4.0.2/node_modules/shiki/dist/chunk-CtajNgzt.mjs
14
14
  var __defProp$1 = Object.defineProperty;
15
15
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
16
16
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -45,7 +45,7 @@ var __copyProps = (to, from, except, desc) => {
45
45
  var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
46
46
 
47
47
  //#endregion
48
- //#region ../../node_modules/@shikijs/types/dist/index.mjs
48
+ //#region ../../node_modules/.bun/@shikijs+types@4.0.2/node_modules/@shikijs/types/dist/index.mjs
49
49
  var ShikiError$1 = class extends Error {
50
50
  constructor(message) {
51
51
  super(message);
@@ -54,7 +54,7 @@ var ShikiError$1 = class extends Error {
54
54
  };
55
55
 
56
56
  //#endregion
57
- //#region ../../node_modules/@shikijs/vscode-textmate/dist/index.js
57
+ //#region ../../node_modules/.bun/@shikijs+vscode-textmate@10.0.2/node_modules/@shikijs/vscode-textmate/dist/index.js
58
58
  function clone(something) {
59
59
  return doClone(something);
60
60
  }
@@ -2911,7 +2911,7 @@ var Registry = class {
2911
2911
  var INITIAL = StateStackImpl.NULL;
2912
2912
 
2913
2913
  //#endregion
2914
- //#region ../../node_modules/@shikijs/primitive/dist/index.mjs
2914
+ //#region ../../node_modules/.bun/@shikijs+primitive@4.0.2/node_modules/@shikijs/primitive/dist/index.mjs
2915
2915
  function resolveColorReplacements(theme, options) {
2916
2916
  const replacements = typeof theme === "string" ? {} : { ...theme.colorReplacements };
2917
2917
  const themeName = typeof theme === "string" ? theme : theme.name;
@@ -3710,7 +3710,7 @@ function alignThemesTokenization(...themes) {
3710
3710
  }
3711
3711
 
3712
3712
  //#endregion
3713
- //#region ../../node_modules/html-void-elements/index.js
3713
+ //#region ../../node_modules/.bun/html-void-elements@3.0.0/node_modules/html-void-elements/index.js
3714
3714
  /**
3715
3715
  * List of HTML void tag names.
3716
3716
  *
@@ -3740,7 +3740,7 @@ const htmlVoidElements = [
3740
3740
  ];
3741
3741
 
3742
3742
  //#endregion
3743
- //#region ../../node_modules/property-information/lib/util/schema.js
3743
+ //#region ../../node_modules/.bun/property-information@7.1.0/node_modules/property-information/lib/util/schema.js
3744
3744
  /**
3745
3745
  * @import {Schema as SchemaType, Space} from 'property-information'
3746
3746
  */
@@ -3769,7 +3769,7 @@ Schema.prototype.property = {};
3769
3769
  Schema.prototype.space = undefined;
3770
3770
 
3771
3771
  //#endregion
3772
- //#region ../../node_modules/property-information/lib/util/merge.js
3772
+ //#region ../../node_modules/.bun/property-information@7.1.0/node_modules/property-information/lib/util/merge.js
3773
3773
  /**
3774
3774
  * @param {ReadonlyArray<Schema>} definitions
3775
3775
  * Definitions.
@@ -3791,7 +3791,7 @@ function merge(definitions, space) {
3791
3791
  }
3792
3792
 
3793
3793
  //#endregion
3794
- //#region ../../node_modules/property-information/lib/normalize.js
3794
+ //#region ../../node_modules/.bun/property-information@7.1.0/node_modules/property-information/lib/normalize.js
3795
3795
  /**
3796
3796
  * Get the cleaned case insensitive form of an attribute or property.
3797
3797
  *
@@ -3806,7 +3806,7 @@ function normalize(value) {
3806
3806
  }
3807
3807
 
3808
3808
  //#endregion
3809
- //#region ../../node_modules/property-information/lib/util/info.js
3809
+ //#region ../../node_modules/.bun/property-information@7.1.0/node_modules/property-information/lib/util/info.js
3810
3810
  /**
3811
3811
  * @import {Info as InfoType} from 'property-information'
3812
3812
  */
@@ -3839,7 +3839,7 @@ Info.prototype.spaceSeparated = false;
3839
3839
  Info.prototype.space = undefined;
3840
3840
 
3841
3841
  //#endregion
3842
- //#region ../../node_modules/property-information/lib/util/types.js
3842
+ //#region ../../node_modules/.bun/property-information@7.1.0/node_modules/property-information/lib/util/types.js
3843
3843
  var types_exports = /* @__PURE__ */ __export({
3844
3844
  boolean: () => boolean,
3845
3845
  booleanish: () => booleanish,
@@ -3862,7 +3862,7 @@ function increment() {
3862
3862
  }
3863
3863
 
3864
3864
  //#endregion
3865
- //#region ../../node_modules/property-information/lib/util/defined-info.js
3865
+ //#region ../../node_modules/.bun/property-information@7.1.0/node_modules/property-information/lib/util/defined-info.js
3866
3866
  const checks = Object.keys(types_exports);
3867
3867
  var DefinedInfo = class extends Info {
3868
3868
  /**
@@ -3910,7 +3910,7 @@ function mark(values, key$1, value) {
3910
3910
  }
3911
3911
 
3912
3912
  //#endregion
3913
- //#region ../../node_modules/property-information/lib/util/create.js
3913
+ //#region ../../node_modules/.bun/property-information@7.1.0/node_modules/property-information/lib/util/create.js
3914
3914
  /**
3915
3915
  * @param {Definition} definition
3916
3916
  * Definition.
@@ -3935,7 +3935,7 @@ function create(definition) {
3935
3935
  }
3936
3936
 
3937
3937
  //#endregion
3938
- //#region ../../node_modules/property-information/lib/aria.js
3938
+ //#region ../../node_modules/.bun/property-information@7.1.0/node_modules/property-information/lib/aria.js
3939
3939
  const aria = create({
3940
3940
  properties: {
3941
3941
  ariaActiveDescendant: null,
@@ -3994,7 +3994,7 @@ const aria = create({
3994
3994
  });
3995
3995
 
3996
3996
  //#endregion
3997
- //#region ../../node_modules/property-information/lib/util/case-sensitive-transform.js
3997
+ //#region ../../node_modules/.bun/property-information@7.1.0/node_modules/property-information/lib/util/case-sensitive-transform.js
3998
3998
  /**
3999
3999
  * @param {Record<string, string>} attributes
4000
4000
  * Attributes.
@@ -4008,7 +4008,7 @@ function caseSensitiveTransform(attributes, attribute) {
4008
4008
  }
4009
4009
 
4010
4010
  //#endregion
4011
- //#region ../../node_modules/property-information/lib/util/case-insensitive-transform.js
4011
+ //#region ../../node_modules/.bun/property-information@7.1.0/node_modules/property-information/lib/util/case-insensitive-transform.js
4012
4012
  /**
4013
4013
  * @param {Record<string, string>} attributes
4014
4014
  * Attributes.
@@ -4022,7 +4022,7 @@ function caseInsensitiveTransform(attributes, property) {
4022
4022
  }
4023
4023
 
4024
4024
  //#endregion
4025
- //#region ../../node_modules/property-information/lib/html.js
4025
+ //#region ../../node_modules/.bun/property-information@7.1.0/node_modules/property-information/lib/html.js
4026
4026
  const html$3 = create({
4027
4027
  attributes: {
4028
4028
  acceptcharset: "accept-charset",
@@ -4335,7 +4335,7 @@ const html$3 = create({
4335
4335
  });
4336
4336
 
4337
4337
  //#endregion
4338
- //#region ../../node_modules/property-information/lib/svg.js
4338
+ //#region ../../node_modules/.bun/property-information@7.1.0/node_modules/property-information/lib/svg.js
4339
4339
  const svg$1 = create({
4340
4340
  attributes: {
4341
4341
  accentHeight: "accent-height",
@@ -4894,7 +4894,7 @@ const svg$1 = create({
4894
4894
  });
4895
4895
 
4896
4896
  //#endregion
4897
- //#region ../../node_modules/property-information/lib/xlink.js
4897
+ //#region ../../node_modules/.bun/property-information@7.1.0/node_modules/property-information/lib/xlink.js
4898
4898
  const xlink = create({
4899
4899
  properties: {
4900
4900
  xLinkActuate: null,
@@ -4912,7 +4912,7 @@ const xlink = create({
4912
4912
  });
4913
4913
 
4914
4914
  //#endregion
4915
- //#region ../../node_modules/property-information/lib/xmlns.js
4915
+ //#region ../../node_modules/.bun/property-information@7.1.0/node_modules/property-information/lib/xmlns.js
4916
4916
  const xmlns = create({
4917
4917
  attributes: { xmlnsxlink: "xmlns:xlink" },
4918
4918
  properties: {
@@ -4924,7 +4924,7 @@ const xmlns = create({
4924
4924
  });
4925
4925
 
4926
4926
  //#endregion
4927
- //#region ../../node_modules/property-information/lib/xml.js
4927
+ //#region ../../node_modules/.bun/property-information@7.1.0/node_modules/property-information/lib/xml.js
4928
4928
  const xml = create({
4929
4929
  properties: {
4930
4930
  xmlBase: null,
@@ -4938,7 +4938,7 @@ const xml = create({
4938
4938
  });
4939
4939
 
4940
4940
  //#endregion
4941
- //#region ../../node_modules/property-information/lib/hast-to-react.js
4941
+ //#region ../../node_modules/.bun/property-information@7.1.0/node_modules/property-information/lib/hast-to-react.js
4942
4942
  /**
4943
4943
  * Special cases for React (`Record<string, string>`).
4944
4944
  *
@@ -4971,7 +4971,7 @@ const hastToReact = {
4971
4971
  };
4972
4972
 
4973
4973
  //#endregion
4974
- //#region ../../node_modules/property-information/lib/find.js
4974
+ //#region ../../node_modules/.bun/property-information@7.1.0/node_modules/property-information/lib/find.js
4975
4975
  const cap = /[A-Z]/g;
4976
4976
  const dash = /-[a-z]/g;
4977
4977
  const valid = /^data[-\w.:]+$/i;
@@ -5050,7 +5050,7 @@ function camelcase($0) {
5050
5050
  }
5051
5051
 
5052
5052
  //#endregion
5053
- //#region ../../node_modules/property-information/index.js
5053
+ //#region ../../node_modules/.bun/property-information@7.1.0/node_modules/property-information/index.js
5054
5054
  const html = merge([
5055
5055
  aria,
5056
5056
  html$3,
@@ -5067,7 +5067,7 @@ const svg = merge([
5067
5067
  ], "svg");
5068
5068
 
5069
5069
  //#endregion
5070
- //#region ../../node_modules/zwitch/index.js
5070
+ //#region ../../node_modules/.bun/zwitch@2.0.4/node_modules/zwitch/index.js
5071
5071
  /**
5072
5072
  * @callback Handler
5073
5073
  * Handle a value, with a certain ID field set to a certain value.
@@ -5175,7 +5175,7 @@ function zwitch(key$1, options) {
5175
5175
  }
5176
5176
 
5177
5177
  //#endregion
5178
- //#region ../../node_modules/stringify-entities/lib/core.js
5178
+ //#region ../../node_modules/.bun/stringify-entities@4.0.4/node_modules/stringify-entities/lib/core.js
5179
5179
  /**
5180
5180
  * @typedef CoreOptions
5181
5181
  * @property {ReadonlyArray<string>} [subset=[]]
@@ -5257,7 +5257,7 @@ function charactersToExpression(subset) {
5257
5257
  }
5258
5258
 
5259
5259
  //#endregion
5260
- //#region ../../node_modules/stringify-entities/lib/util/to-hexadecimal.js
5260
+ //#region ../../node_modules/.bun/stringify-entities@4.0.4/node_modules/stringify-entities/lib/util/to-hexadecimal.js
5261
5261
  const hexadecimalRegex = /[\dA-Fa-f]/;
5262
5262
  /**
5263
5263
  * Configurable ways to encode characters as hexadecimal references.
@@ -5273,7 +5273,7 @@ function toHexadecimal(code, next, omit) {
5273
5273
  }
5274
5274
 
5275
5275
  //#endregion
5276
- //#region ../../node_modules/stringify-entities/lib/util/to-decimal.js
5276
+ //#region ../../node_modules/.bun/stringify-entities@4.0.4/node_modules/stringify-entities/lib/util/to-decimal.js
5277
5277
  const decimalRegex = /\d/;
5278
5278
  /**
5279
5279
  * Configurable ways to encode characters as decimal references.
@@ -5289,7 +5289,7 @@ function toDecimal(code, next, omit) {
5289
5289
  }
5290
5290
 
5291
5291
  //#endregion
5292
- //#region ../../node_modules/character-entities-legacy/index.js
5292
+ //#region ../../node_modules/.bun/character-entities-legacy@3.0.0/node_modules/character-entities-legacy/index.js
5293
5293
  /**
5294
5294
  * List of legacy HTML named character references that don’t need a trailing semicolon.
5295
5295
  *
@@ -5405,7 +5405,7 @@ const characterEntitiesLegacy = [
5405
5405
  ];
5406
5406
 
5407
5407
  //#endregion
5408
- //#region ../../node_modules/character-entities-html4/index.js
5408
+ //#region ../../node_modules/.bun/character-entities-html4@2.1.0/node_modules/character-entities-html4/index.js
5409
5409
  /**
5410
5410
  * Map of named character references from HTML 4.
5411
5411
  *
@@ -5667,7 +5667,7 @@ const characterEntitiesHtml4 = {
5667
5667
  };
5668
5668
 
5669
5669
  //#endregion
5670
- //#region ../../node_modules/stringify-entities/lib/constant/dangerous.js
5670
+ //#region ../../node_modules/.bun/stringify-entities@4.0.4/node_modules/stringify-entities/lib/constant/dangerous.js
5671
5671
  /**
5672
5672
  * List of legacy (that don’t need a trailing `;`) named references which could,
5673
5673
  * depending on what follows them, turn into a different meaning
@@ -5686,7 +5686,7 @@ const dangerous = [
5686
5686
  ];
5687
5687
 
5688
5688
  //#endregion
5689
- //#region ../../node_modules/stringify-entities/lib/util/to-named.js
5689
+ //#region ../../node_modules/.bun/stringify-entities@4.0.4/node_modules/stringify-entities/lib/util/to-named.js
5690
5690
  const own$1 = {}.hasOwnProperty;
5691
5691
  /**
5692
5692
  * `characterEntitiesHtml4` but inverted.
@@ -5725,7 +5725,7 @@ function toNamed(code, next, omit, attribute) {
5725
5725
  }
5726
5726
 
5727
5727
  //#endregion
5728
- //#region ../../node_modules/stringify-entities/lib/util/format-smart.js
5728
+ //#region ../../node_modules/.bun/stringify-entities@4.0.4/node_modules/stringify-entities/lib/util/format-smart.js
5729
5729
  /**
5730
5730
  * Configurable ways to encode a character yielding pretty or small results.
5731
5731
  *
@@ -5751,7 +5751,7 @@ function formatSmart(code, next, options) {
5751
5751
  }
5752
5752
 
5753
5753
  //#endregion
5754
- //#region ../../node_modules/stringify-entities/lib/util/format-basic.js
5754
+ //#region ../../node_modules/.bun/stringify-entities@4.0.4/node_modules/stringify-entities/lib/util/format-basic.js
5755
5755
  /**
5756
5756
  * The smallest way to encode a character.
5757
5757
  *
@@ -5763,7 +5763,7 @@ function formatBasic(code) {
5763
5763
  }
5764
5764
 
5765
5765
  //#endregion
5766
- //#region ../../node_modules/stringify-entities/lib/index.js
5766
+ //#region ../../node_modules/.bun/stringify-entities@4.0.4/node_modules/stringify-entities/lib/index.js
5767
5767
  /**
5768
5768
  * Encode special characters in `value`.
5769
5769
  *
@@ -5792,7 +5792,7 @@ function stringifyEntitiesLight(value, options) {
5792
5792
  }
5793
5793
 
5794
5794
  //#endregion
5795
- //#region ../../node_modules/hast-util-to-html/lib/handle/comment.js
5795
+ //#region ../../node_modules/.bun/hast-util-to-html@9.0.5/node_modules/hast-util-to-html/lib/handle/comment.js
5796
5796
  const htmlCommentRegex = /^>|^->|<!--|-->|--!>|<!-$/g;
5797
5797
  const bogusCommentEntitySubset = [">"];
5798
5798
  const commentEntitySubset = ["<", ">"];
@@ -5821,7 +5821,7 @@ function comment(node, _1, _2, state) {
5821
5821
  }
5822
5822
 
5823
5823
  //#endregion
5824
- //#region ../../node_modules/hast-util-to-html/lib/handle/doctype.js
5824
+ //#region ../../node_modules/.bun/hast-util-to-html@9.0.5/node_modules/hast-util-to-html/lib/handle/doctype.js
5825
5825
  /**
5826
5826
  * @import {Doctype, Parents} from 'hast'
5827
5827
  * @import {State} from '../index.js'
@@ -5845,7 +5845,7 @@ function doctype(_1, _2, _3, state) {
5845
5845
  }
5846
5846
 
5847
5847
  //#endregion
5848
- //#region ../../node_modules/ccount/index.js
5848
+ //#region ../../node_modules/.bun/ccount@2.0.1/node_modules/ccount/index.js
5849
5849
  /**
5850
5850
  * Count how often a character (or substring) is used in a string.
5851
5851
  *
@@ -5871,7 +5871,7 @@ function ccount(value, character) {
5871
5871
  }
5872
5872
 
5873
5873
  //#endregion
5874
- //#region ../../node_modules/comma-separated-tokens/index.js
5874
+ //#region ../../node_modules/.bun/comma-separated-tokens@2.0.3/node_modules/comma-separated-tokens/index.js
5875
5875
  /**
5876
5876
  * @typedef Options
5877
5877
  * Configuration for `stringify`.
@@ -5931,7 +5931,7 @@ function stringify$1(values, options) {
5931
5931
  }
5932
5932
 
5933
5933
  //#endregion
5934
- //#region ../../node_modules/space-separated-tokens/index.js
5934
+ //#region ../../node_modules/.bun/space-separated-tokens@2.0.2/node_modules/space-separated-tokens/index.js
5935
5935
  /**
5936
5936
  * Parse space-separated tokens to an array of strings.
5937
5937
  *
@@ -5957,7 +5957,7 @@ function stringify$2(values) {
5957
5957
  }
5958
5958
 
5959
5959
  //#endregion
5960
- //#region ../../node_modules/hast-util-whitespace/lib/index.js
5960
+ //#region ../../node_modules/.bun/hast-util-whitespace@3.0.0/node_modules/hast-util-whitespace/lib/index.js
5961
5961
  /**
5962
5962
  * @typedef {import('hast').Nodes} Nodes
5963
5963
  */
@@ -5985,7 +5985,7 @@ function empty(value) {
5985
5985
  }
5986
5986
 
5987
5987
  //#endregion
5988
- //#region ../../node_modules/hast-util-to-html/lib/omission/util/siblings.js
5988
+ //#region ../../node_modules/.bun/hast-util-to-html@9.0.5/node_modules/hast-util-to-html/lib/omission/util/siblings.js
5989
5989
  const siblingAfter = siblings(1);
5990
5990
  const siblingBefore = siblings(-1);
5991
5991
  /** @type {Array<RootContent>} */
@@ -6026,7 +6026,7 @@ function siblings(increment$1) {
6026
6026
  }
6027
6027
 
6028
6028
  //#endregion
6029
- //#region ../../node_modules/hast-util-to-html/lib/omission/omission.js
6029
+ //#region ../../node_modules/.bun/hast-util-to-html@9.0.5/node_modules/hast-util-to-html/lib/omission/omission.js
6030
6030
  /**
6031
6031
  * @import {Element, Parents} from 'hast'
6032
6032
  */
@@ -6066,7 +6066,7 @@ function omission(handlers) {
6066
6066
  }
6067
6067
 
6068
6068
  //#endregion
6069
- //#region ../../node_modules/hast-util-to-html/lib/omission/closing.js
6069
+ //#region ../../node_modules/.bun/hast-util-to-html@9.0.5/node_modules/hast-util-to-html/lib/omission/closing.js
6070
6070
  const closing = omission({
6071
6071
  body: body$1,
6072
6072
  caption: headOrColgroupOrCaption,
@@ -6329,7 +6329,7 @@ function cells(_$2, index, parent) {
6329
6329
  }
6330
6330
 
6331
6331
  //#endregion
6332
- //#region ../../node_modules/hast-util-to-html/lib/omission/opening.js
6332
+ //#region ../../node_modules/.bun/hast-util-to-html@9.0.5/node_modules/hast-util-to-html/lib/omission/opening.js
6333
6333
  const opening = omission({
6334
6334
  body,
6335
6335
  colgroup,
@@ -6426,7 +6426,7 @@ function tbody(node, index, parent) {
6426
6426
  }
6427
6427
 
6428
6428
  //#endregion
6429
- //#region ../../node_modules/hast-util-to-html/lib/handle/element.js
6429
+ //#region ../../node_modules/.bun/hast-util-to-html@9.0.5/node_modules/hast-util-to-html/lib/handle/element.js
6430
6430
  /**
6431
6431
  * Maps of subsets.
6432
6432
  *
@@ -6559,7 +6559,7 @@ function serializeAttribute(state, key$1, value) {
6559
6559
  }
6560
6560
 
6561
6561
  //#endregion
6562
- //#region ../../node_modules/hast-util-to-html/lib/handle/text.js
6562
+ //#region ../../node_modules/.bun/hast-util-to-html@9.0.5/node_modules/hast-util-to-html/lib/handle/text.js
6563
6563
  const textEntitySubset = ["<", "&"];
6564
6564
  /**
6565
6565
  * Serialize a text node.
@@ -6580,7 +6580,7 @@ function text(node, _$2, parent, state) {
6580
6580
  }
6581
6581
 
6582
6582
  //#endregion
6583
- //#region ../../node_modules/hast-util-to-html/lib/handle/raw.js
6583
+ //#region ../../node_modules/.bun/hast-util-to-html@9.0.5/node_modules/hast-util-to-html/lib/handle/raw.js
6584
6584
  /**
6585
6585
  * Serialize a raw node.
6586
6586
  *
@@ -6600,7 +6600,7 @@ function raw(node, index, parent, state) {
6600
6600
  }
6601
6601
 
6602
6602
  //#endregion
6603
- //#region ../../node_modules/hast-util-to-html/lib/handle/root.js
6603
+ //#region ../../node_modules/.bun/hast-util-to-html@9.0.5/node_modules/hast-util-to-html/lib/handle/root.js
6604
6604
  /**
6605
6605
  * @import {Parents, Root} from 'hast'
6606
6606
  * @import {State} from '../index.js'
@@ -6624,7 +6624,7 @@ function root(node, _1, _2, state) {
6624
6624
  }
6625
6625
 
6626
6626
  //#endregion
6627
- //#region ../../node_modules/hast-util-to-html/lib/handle/index.js
6627
+ //#region ../../node_modules/.bun/hast-util-to-html@9.0.5/node_modules/hast-util-to-html/lib/handle/index.js
6628
6628
  /**
6629
6629
  * @type {(node: Nodes, index: number | undefined, parent: Parents | undefined, state: State) => string}
6630
6630
  */
@@ -6665,7 +6665,7 @@ function unknown(node_) {
6665
6665
  }
6666
6666
 
6667
6667
  //#endregion
6668
- //#region ../../node_modules/hast-util-to-html/lib/index.js
6668
+ //#region ../../node_modules/.bun/hast-util-to-html@9.0.5/node_modules/hast-util-to-html/lib/index.js
6669
6669
  /** @type {Options} */
6670
6670
  const emptyOptions = {};
6671
6671
  /** @type {CharacterReferences} */
@@ -6759,7 +6759,7 @@ function all(parent) {
6759
6759
  }
6760
6760
 
6761
6761
  //#endregion
6762
- //#region ../../node_modules/@shikijs/core/dist/index.mjs
6762
+ //#region ../../node_modules/.bun/@shikijs+core@4.0.2/node_modules/@shikijs/core/dist/index.mjs
6763
6763
  /**
6764
6764
  * Utility to append class to a hast node
6765
6765
  *
@@ -8126,18 +8126,18 @@ function createCssVariablesTheme(options = {}) {
8126
8126
  }
8127
8127
 
8128
8128
  //#endregion
8129
- //#region ../../node_modules/@shikijs/engine-javascript/dist/scanner-BFcBmQR1.mjs
8129
+ //#region ../../node_modules/.bun/@shikijs+engine-javascript@4.0.2/node_modules/@shikijs/engine-javascript/dist/scanner-BFcBmQR1.mjs
8130
8130
  const MAX = 4294967295;
8131
8131
  var JavaScriptScanner = class {
8132
8132
  regexps;
8133
8133
  constructor(patterns, options = {}) {
8134
8134
  this.patterns = patterns;
8135
8135
  this.options = options;
8136
- const { forgiving = false, cache, regexConstructor } = options;
8136
+ const { forgiving = false, cache: cache$1, regexConstructor } = options;
8137
8137
  if (!regexConstructor) throw new Error("Option `regexConstructor` is not provided");
8138
8138
  this.regexps = patterns.map((p$1) => {
8139
8139
  if (typeof p$1 !== "string") return p$1;
8140
- const cached = cache?.get(p$1);
8140
+ const cached = cache$1?.get(p$1);
8141
8141
  if (cached) {
8142
8142
  if (cached instanceof RegExp) return cached;
8143
8143
  if (forgiving) return null;
@@ -8145,10 +8145,10 @@ var JavaScriptScanner = class {
8145
8145
  }
8146
8146
  try {
8147
8147
  const regex = regexConstructor(p$1);
8148
- cache?.set(p$1, regex);
8148
+ cache$1?.set(p$1, regex);
8149
8149
  return regex;
8150
8150
  } catch (e) {
8151
- cache?.set(p$1, e);
8151
+ cache$1?.set(p$1, e);
8152
8152
  if (forgiving) return null;
8153
8153
  throw e;
8154
8154
  }
@@ -8201,7 +8201,7 @@ var JavaScriptScanner = class {
8201
8201
  };
8202
8202
 
8203
8203
  //#endregion
8204
- //#region ../../node_modules/oniguruma-parser/dist/utils.js
8204
+ //#region ../../node_modules/.bun/oniguruma-parser@0.12.1/node_modules/oniguruma-parser/dist/utils.js
8205
8205
  function r$2(e) {
8206
8206
  if ([...e].length !== 1) throw new Error(`Expected "${e}" to be a single code point`);
8207
8207
  return e.codePointAt(0);
@@ -8231,7 +8231,7 @@ function u(e, t) {
8231
8231
  }
8232
8232
 
8233
8233
  //#endregion
8234
- //#region ../../node_modules/oniguruma-parser/dist/tokenizer/tokenize.js
8234
+ //#region ../../node_modules/.bun/oniguruma-parser@0.12.1/node_modules/oniguruma-parser/dist/tokenizer/tokenize.js
8235
8235
  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
8236
  \\ (?:
8237
8237
  ${b$1}
@@ -8728,7 +8728,7 @@ function te$1(e) {
8728
8728
  }
8729
8729
 
8730
8730
  //#endregion
8731
- //#region ../../node_modules/oniguruma-parser/dist/parser/node-utils.js
8731
+ //#region ../../node_modules/.bun/oniguruma-parser@0.12.1/node_modules/oniguruma-parser/dist/parser/node-utils.js
8732
8732
  function o(e, t) {
8733
8733
  if (!Array.isArray(e.body)) throw new Error("Expected node with body array");
8734
8734
  if (e.body.length !== 1) return !1;
@@ -8761,7 +8761,7 @@ const y = new Set([
8761
8761
  ]);
8762
8762
 
8763
8763
  //#endregion
8764
- //#region ../../node_modules/oniguruma-parser/dist/parser/parse.js
8764
+ //#region ../../node_modules/.bun/oniguruma-parser@0.12.1/node_modules/oniguruma-parser/dist/parser/parse.js
8765
8765
  function J(e, r$3 = {}) {
8766
8766
  const n = {
8767
8767
  flags: "",
@@ -9182,7 +9182,7 @@ function D(e) {
9182
9182
  }
9183
9183
 
9184
9184
  //#endregion
9185
- //#region ../../node_modules/oniguruma-parser/dist/traverser/traverse.js
9185
+ //#region ../../node_modules/.bun/oniguruma-parser@0.12.1/node_modules/oniguruma-parser/dist/traverser/traverse.js
9186
9186
  function S(a$1, v$1, N = null) {
9187
9187
  function u$1(e, s$1) {
9188
9188
  for (let t = 0; t < e.length; t++) {
@@ -9270,7 +9270,7 @@ function l(a$1) {
9270
9270
  }
9271
9271
 
9272
9272
  //#endregion
9273
- //#region ../../node_modules/regex/src/utils-internals.js
9273
+ //#region ../../node_modules/.bun/regex@6.1.0/node_modules/regex/src/utils-internals.js
9274
9274
  const noncapturingDelim = String.raw`\(\?(?:[:=!>A-Za-z\-]|<[=!]|\(DEFINE\))`;
9275
9275
  /**
9276
9276
  Updates the array in place by incrementing each value greater than or equal to the threshold.
@@ -9296,7 +9296,7 @@ function spliceStr(str, pos, oldValue, newValue) {
9296
9296
  }
9297
9297
 
9298
9298
  //#endregion
9299
- //#region ../../node_modules/regex-utilities/src/index.js
9299
+ //#region ../../node_modules/.bun/regex-utilities@2.3.0/node_modules/regex-utilities/src/index.js
9300
9300
  const Context = Object.freeze({
9301
9301
  DEFAULT: "DEFAULT",
9302
9302
  CHAR_CLASS: "CHAR_CLASS"
@@ -9458,7 +9458,7 @@ function getGroupContents(expression, contentsStartPos) {
9458
9458
  }
9459
9459
 
9460
9460
  //#endregion
9461
- //#region ../../node_modules/regex/src/atomic.js
9461
+ //#region ../../node_modules/.bun/regex@6.1.0/node_modules/regex/src/atomic.js
9462
9462
  /**
9463
9463
  @import {PluginData, PluginResult} from './regex.js';
9464
9464
  */
@@ -9634,7 +9634,7 @@ function possessive(expression) {
9634
9634
  }
9635
9635
 
9636
9636
  //#endregion
9637
- //#region ../../node_modules/regex/src/subclass.js
9637
+ //#region ../../node_modules/.bun/regex@6.1.0/node_modules/regex/src/subclass.js
9638
9638
  /**
9639
9639
  Works the same as JavaScript's native `RegExp` constructor in all contexts, but automatically
9640
9640
  adjusts subpattern matches and indices (with flag `d`) to account for captures added as part of
@@ -9724,7 +9724,7 @@ function createCaptureMap$1(hiddenCaptures) {
9724
9724
  }
9725
9725
 
9726
9726
  //#endregion
9727
- //#region ../../node_modules/regex-recursion/src/index.js
9727
+ //#region ../../node_modules/.bun/regex-recursion@6.0.2/node_modules/regex-recursion/src/index.js
9728
9728
  const r$1 = String.raw;
9729
9729
  const gRToken = r$1`\\g<(?<gRNameOrNum>[^>&]+)&R=(?<gRDepth>[^>]+)>`;
9730
9730
  const recursiveToken = r$1`\(\?R=(?<rDepth>[^\)]+)\)|${gRToken}`;
@@ -9981,7 +9981,7 @@ function mapCaptureTransfers(captureTransfers, left, reps, numCapturesAddedInExp
9981
9981
  }
9982
9982
 
9983
9983
  //#endregion
9984
- //#region ../../node_modules/oniguruma-to-es/dist/esm/index.js
9984
+ //#region ../../node_modules/.bun/oniguruma-to-es@4.3.4/node_modules/oniguruma-to-es/dist/esm/index.js
9985
9985
  var cp = String.fromCodePoint;
9986
9986
  var r = String.raw;
9987
9987
  var envFlags = {
@@ -11636,7 +11636,7 @@ function toRegExpDetails(pattern, options) {
11636
11636
  }
11637
11637
 
11638
11638
  //#endregion
11639
- //#region ../../node_modules/@shikijs/engine-javascript/dist/engine-compile.mjs
11639
+ //#region ../../node_modules/.bun/@shikijs+engine-javascript@4.0.2/node_modules/@shikijs/engine-javascript/dist/engine-compile.mjs
11640
11640
  /**
11641
11641
  * The default regex constructor for the JavaScript RegExp engine.
11642
11642
  */
@@ -11680,7 +11680,7 @@ function createJavaScriptRegexEngine(options = {}) {
11680
11680
  }
11681
11681
 
11682
11682
  //#endregion
11683
- //#region ../../node_modules/@shikijs/engine-javascript/dist/engine-raw.mjs
11683
+ //#region ../../node_modules/.bun/@shikijs+engine-javascript@4.0.2/node_modules/@shikijs/engine-javascript/dist/engine-raw.mjs
11684
11684
  /**
11685
11685
  * Raw JavaScript regex engine that only supports precompiled grammars.
11686
11686
  *
@@ -11706,7 +11706,7 @@ function createJavaScriptRawEngine() {
11706
11706
  }
11707
11707
 
11708
11708
  //#endregion
11709
- //#region ../../node_modules/@shikijs/engine-oniguruma/dist/index.mjs
11709
+ //#region ../../node_modules/.bun/@shikijs+engine-oniguruma@4.0.2/node_modules/@shikijs/engine-oniguruma/dist/index.mjs
11710
11710
  var dist_exports = /* @__PURE__ */ __export({
11711
11711
  createOnigurumaEngine: () => createOnigurumaEngine,
11712
11712
  getDefaultWasmLoader: () => getDefaultWasmLoader,
@@ -12130,7 +12130,7 @@ async function createOnigurumaEngine(options) {
12130
12130
  }
12131
12131
 
12132
12132
  //#endregion
12133
- //#region ../../node_modules/shiki/dist/engine-oniguruma.mjs
12133
+ //#region ../../node_modules/.bun/shiki@4.0.2/node_modules/shiki/dist/engine-oniguruma.mjs
12134
12134
  var engine_oniguruma_exports = /* @__PURE__ */ __exportAll({});
12135
12135
  __reExport(engine_oniguruma_exports, dist_exports);
12136
12136
 
@@ -12234,11 +12234,500 @@ function attachResolvedLanguages(resolvedLanguages, highlighter$1) {
12234
12234
 
12235
12235
  //#endregion
12236
12236
  //#region src/highlighter/themes/constants.ts
12237
- const ResolvedThemes = new Map();
12238
- const ResolvingThemes = new Map();
12239
- const RegisteredCustomThemes = new Map();
12240
12237
  const AttachedThemes = new Set();
12241
12238
 
12239
+ //#endregion
12240
+ //#region ../theming/dist/modules/createThemeCollection.js
12241
+ function createThemeCollection(options) {
12242
+ const descriptors = [];
12243
+ const seen = /* @__PURE__ */ new Set();
12244
+ for (const entry of getCollectionEntries(options.themes)) {
12245
+ const themes = isThemeCollectionSource(entry) ? entry.getThemes() : [entry];
12246
+ for (const descriptor of themes) {
12247
+ if (seen.has(descriptor.name)) throw new Error(`Theme collection already contains theme "${descriptor.name}"`);
12248
+ seen.add(descriptor.name);
12249
+ descriptors.push(descriptor);
12250
+ }
12251
+ }
12252
+ const allThemes = Object.freeze([...descriptors]);
12253
+ const lightThemes = Object.freeze(allThemes.filter((descriptor) => descriptor.colorScheme === "light"));
12254
+ const darkThemes = Object.freeze(allThemes.filter((descriptor) => descriptor.colorScheme === "dark"));
12255
+ const themesByName = new Map(allThemes.map((descriptor) => [descriptor.name, descriptor]));
12256
+ const allNames = Object.freeze(allThemes.map((descriptor) => descriptor.name));
12257
+ const lightNames = Object.freeze(lightThemes.map((descriptor) => descriptor.name));
12258
+ const darkNames = Object.freeze(darkThemes.map((descriptor) => descriptor.name));
12259
+ function filteredThemes(filterOptions) {
12260
+ if (filterOptions == null) return allThemes;
12261
+ const { colorScheme, collection } = filterOptions;
12262
+ if (collection == null) {
12263
+ if (colorScheme === "light") return lightThemes;
12264
+ if (colorScheme === "dark") return darkThemes;
12265
+ return allThemes;
12266
+ }
12267
+ return allThemes.filter((descriptor) => {
12268
+ if (descriptor.collection !== collection) return false;
12269
+ return colorScheme == null || descriptor.colorScheme === colorScheme;
12270
+ });
12271
+ }
12272
+ return {
12273
+ getTheme(name) {
12274
+ return themesByName.get(name);
12275
+ },
12276
+ getThemes(themeOptions) {
12277
+ return filteredThemes(themeOptions);
12278
+ },
12279
+ getThemeNames(namesOptions) {
12280
+ if (namesOptions?.collection == null) {
12281
+ if (namesOptions?.colorScheme === "light") return lightNames;
12282
+ if (namesOptions?.colorScheme === "dark") return darkNames;
12283
+ return allNames;
12284
+ }
12285
+ return filteredThemes(namesOptions).map((descriptor) => descriptor.name);
12286
+ },
12287
+ hasTheme(name) {
12288
+ return themesByName.has(name);
12289
+ },
12290
+ orderBy(compare) {
12291
+ return createThemeCollection({ themes: allThemes.map((descriptor, index) => ({
12292
+ descriptor,
12293
+ index
12294
+ })).sort((a$1, b$2) => {
12295
+ const result = compare(a$1.descriptor, b$2.descriptor);
12296
+ if (result !== 0) return result;
12297
+ return a$1.index - b$2.index;
12298
+ }).map((entry) => entry.descriptor) });
12299
+ },
12300
+ pick(names) {
12301
+ const picked = [];
12302
+ const pickedNames = /* @__PURE__ */ new Set();
12303
+ for (const name of names) {
12304
+ if (pickedNames.has(name)) throw new Error(`Theme collection pick already includes theme "${name}"`);
12305
+ pickedNames.add(name);
12306
+ const descriptor = themesByName.get(name);
12307
+ if (descriptor == null) throw new Error(`Theme collection does not contain theme "${name}"`);
12308
+ picked.push(descriptor);
12309
+ }
12310
+ return createThemeCollection({ themes: picked });
12311
+ },
12312
+ registerInto(resolver) {
12313
+ for (const descriptor of allThemes) resolver.registerThemeIfAbsent(descriptor.name, descriptor.load);
12314
+ }
12315
+ };
12316
+ }
12317
+ function getCollectionEntries(input) {
12318
+ if (isThemeCollectionEntry(input)) return [input];
12319
+ return input;
12320
+ }
12321
+ function isThemeCollectionEntry(input) {
12322
+ return isThemeCollectionSource(input) || isThemeDescriptor(input);
12323
+ }
12324
+ function isThemeDescriptor(input) {
12325
+ return typeof input.name === "string" && typeof input.load === "function";
12326
+ }
12327
+ function isThemeCollectionSource(entry) {
12328
+ return typeof entry.getThemes === "function";
12329
+ }
12330
+
12331
+ //#endregion
12332
+ //#region ../theming/dist/modules/createThemeCatalog.js
12333
+ function createThemeCatalog(options) {
12334
+ const collection = createThemeCollection({ themes: options.themes });
12335
+ if (!collection.hasTheme(options.defaultLightThemeName)) throw new Error(`Default light theme "${options.defaultLightThemeName}" is not in the catalog`);
12336
+ if (!collection.hasTheme(options.defaultDarkThemeName)) throw new Error(`Default dark theme "${options.defaultDarkThemeName}" is not in the catalog`);
12337
+ return {
12338
+ ...collection,
12339
+ defaultLightThemeName: options.defaultLightThemeName,
12340
+ defaultDarkThemeName: options.defaultDarkThemeName
12341
+ };
12342
+ }
12343
+
12344
+ //#endregion
12345
+ //#region ../theming/dist/modules/unwrapDefault.js
12346
+ function unwrapDefault(value) {
12347
+ return value !== null && typeof value === "object" && "default" in value ? value.default : value;
12348
+ }
12349
+
12350
+ //#endregion
12351
+ //#region ../theming/dist/modules/createThemeResolver.js
12352
+ var DuplicateThemeError = class extends Error {
12353
+ constructor(name) {
12354
+ super(`Theme "${name}" is already registered`);
12355
+ this.name = "DuplicateThemeError";
12356
+ }
12357
+ };
12358
+ var UnregisteredThemeError = class extends Error {
12359
+ constructor(name) {
12360
+ super(`No loader registered for theme "${name}"`);
12361
+ this.name = "UnregisteredThemeError";
12362
+ }
12363
+ };
12364
+ var UnresolvedThemeError = class extends Error {
12365
+ constructor(name) {
12366
+ super(`Theme "${name}" has not been resolved`);
12367
+ this.name = "UnresolvedThemeError";
12368
+ }
12369
+ };
12370
+ function createThemeResolver() {
12371
+ const loaders = /* @__PURE__ */ new Map();
12372
+ const resolved = /* @__PURE__ */ new Map();
12373
+ const inflight = /* @__PURE__ */ new Map();
12374
+ let cacheGeneration = 0;
12375
+ function registerTheme(name, loader) {
12376
+ if (loaders.has(name)) throw new DuplicateThemeError(name);
12377
+ loaders.set(name, loader);
12378
+ }
12379
+ function registerThemeIfAbsent(name, loader) {
12380
+ if (loaders.has(name)) return false;
12381
+ loaders.set(name, loader);
12382
+ return true;
12383
+ }
12384
+ function hasRegisteredTheme(name) {
12385
+ return loaders.has(name);
12386
+ }
12387
+ function resolveTheme(name) {
12388
+ const cached = resolved.get(name);
12389
+ if (cached !== void 0) return Promise.resolve(cached);
12390
+ const existing = inflight.get(name);
12391
+ if (existing !== void 0) return existing;
12392
+ const loader = loaders.get(name);
12393
+ if (loader === void 0) return Promise.reject(new UnregisteredThemeError(name));
12394
+ const generation = cacheGeneration;
12395
+ const promise = loader().then((result) => {
12396
+ const theme = unwrapDefault(result);
12397
+ if (generation === cacheGeneration) resolved.set(name, theme);
12398
+ if (inflight.get(name) === promise) inflight.delete(name);
12399
+ return theme;
12400
+ }).catch((err) => {
12401
+ if (inflight.get(name) === promise) inflight.delete(name);
12402
+ throw err;
12403
+ });
12404
+ inflight.set(name, promise);
12405
+ return promise;
12406
+ }
12407
+ function resolveThemes$1(names) {
12408
+ return Promise.all(names.map((name) => resolveTheme(name)));
12409
+ }
12410
+ function seedResolvedTheme(name, theme) {
12411
+ resolved.set(name, theme);
12412
+ }
12413
+ function seedResolvedThemes(entries) {
12414
+ for (const [name, theme] of entries) seedResolvedTheme(name, theme);
12415
+ }
12416
+ function getResolvedTheme(name) {
12417
+ return resolved.get(name);
12418
+ }
12419
+ function getResolvedThemes(names) {
12420
+ const themes = [];
12421
+ for (const name of names) {
12422
+ const theme = resolved.get(name);
12423
+ if (theme === void 0) throw new UnresolvedThemeError(name);
12424
+ themes.push(theme);
12425
+ }
12426
+ return themes;
12427
+ }
12428
+ function hasResolvedTheme(name) {
12429
+ return resolved.has(name);
12430
+ }
12431
+ function hasResolvedThemes(names) {
12432
+ for (const name of names) if (!resolved.has(name)) return false;
12433
+ return true;
12434
+ }
12435
+ function getResolvedOrResolveTheme(name) {
12436
+ const cached = resolved.get(name);
12437
+ if (cached !== void 0) return cached;
12438
+ return resolveTheme(name);
12439
+ }
12440
+ function clearResolvedThemes() {
12441
+ cacheGeneration++;
12442
+ resolved.clear();
12443
+ inflight.clear();
12444
+ }
12445
+ return {
12446
+ clearResolvedThemes,
12447
+ getResolvedOrResolveTheme,
12448
+ getResolvedTheme,
12449
+ getResolvedThemes,
12450
+ hasRegisteredTheme,
12451
+ hasResolvedTheme,
12452
+ hasResolvedThemes,
12453
+ registerTheme,
12454
+ registerThemeIfAbsent,
12455
+ resolveTheme,
12456
+ resolveThemes: resolveThemes$1,
12457
+ seedResolvedTheme,
12458
+ seedResolvedThemes
12459
+ };
12460
+ }
12461
+
12462
+ //#endregion
12463
+ //#region ../theming/dist/modules/createThemeController.js
12464
+ const FALLBACK_LIGHT_THEME = "pierre-light";
12465
+ const FALLBACK_DARK_THEME = "pierre-dark";
12466
+ function getStorage() {
12467
+ try {
12468
+ if (typeof globalThis !== "undefined" && globalThis.localStorage != null) return globalThis.localStorage;
12469
+ } catch {}
12470
+ }
12471
+ function createLocalStorageAdapter(storageKey, defaults) {
12472
+ return {
12473
+ load() {
12474
+ const raw$1 = getStorage()?.getItem(storageKey);
12475
+ if (raw$1 == null) return null;
12476
+ try {
12477
+ const parsed = JSON.parse(raw$1);
12478
+ if (parsed.mode == null) return null;
12479
+ return {
12480
+ darkThemeName: parsed.darkThemeName ?? defaults.darkThemeName,
12481
+ lightThemeName: parsed.lightThemeName ?? defaults.lightThemeName,
12482
+ mode: parsed.mode
12483
+ };
12484
+ } catch {
12485
+ return null;
12486
+ }
12487
+ },
12488
+ save(selection) {
12489
+ const storage = getStorage();
12490
+ try {
12491
+ storage?.setItem(storageKey, JSON.stringify(selection));
12492
+ } catch {}
12493
+ }
12494
+ };
12495
+ }
12496
+ function systemPrefersDark() {
12497
+ try {
12498
+ if (typeof globalThis !== "undefined" && globalThis.matchMedia != null) return globalThis.matchMedia("(prefers-color-scheme: dark)").matches;
12499
+ } catch {}
12500
+ return false;
12501
+ }
12502
+ function resolveColorScheme(mode) {
12503
+ if (mode === "dark") return "dark";
12504
+ if (mode === "light") return "light";
12505
+ return systemPrefersDark() ? "dark" : "light";
12506
+ }
12507
+ function createThemeController(options) {
12508
+ const { storageKey, preloadInactive = false } = options;
12509
+ const catalog = "catalog" in options && options.catalog != null ? options.catalog : void 0;
12510
+ const selectedResolver = options.resolver ?? (catalog != null ? createThemeResolver() : void 0);
12511
+ if (selectedResolver == null) throw new Error("createThemeController requires a catalog or resolver");
12512
+ const resolver = selectedResolver;
12513
+ catalog?.registerInto(resolver);
12514
+ const defaultDarkThemeName = options.defaultDarkThemeName ?? catalog?.defaultDarkThemeName ?? FALLBACK_DARK_THEME;
12515
+ const defaultLightThemeName = options.defaultLightThemeName ?? catalog?.defaultLightThemeName ?? FALLBACK_LIGHT_THEME;
12516
+ const persistence = options.persistence ?? (storageKey != null ? createLocalStorageAdapter(storageKey, {
12517
+ darkThemeName: defaultDarkThemeName,
12518
+ lightThemeName: defaultLightThemeName
12519
+ }) : void 0);
12520
+ const initialMode = options.defaultMode ?? "system";
12521
+ let state = {
12522
+ darkThemeName: defaultDarkThemeName,
12523
+ lightThemeName: defaultLightThemeName,
12524
+ mode: initialMode,
12525
+ resolvedTheme: void 0,
12526
+ resolvedColorScheme: resolveColorScheme(initialMode)
12527
+ };
12528
+ const listeners = /* @__PURE__ */ new Set();
12529
+ let activeResolutionId = 0;
12530
+ let pendingSelectionPatch;
12531
+ function notify() {
12532
+ for (const listener of listeners) listener();
12533
+ }
12534
+ function hydrateFromStorage() {
12535
+ const loaded = persistence?.load();
12536
+ if (loaded == null) return;
12537
+ state = {
12538
+ ...state,
12539
+ darkThemeName: loaded.darkThemeName,
12540
+ lightThemeName: loaded.lightThemeName,
12541
+ mode: loaded.mode,
12542
+ resolvedColorScheme: resolveColorScheme(loaded.mode)
12543
+ };
12544
+ }
12545
+ function persist() {
12546
+ persistence?.save({
12547
+ darkThemeName: state.darkThemeName,
12548
+ lightThemeName: state.lightThemeName,
12549
+ mode: state.mode
12550
+ });
12551
+ }
12552
+ function activeThemeNameFor(selection) {
12553
+ return selection.resolvedColorScheme === "dark" ? selection.darkThemeName : selection.lightThemeName;
12554
+ }
12555
+ function intendedState(patch = {}) {
12556
+ return {
12557
+ ...state,
12558
+ ...pendingSelectionPatch,
12559
+ ...patch
12560
+ };
12561
+ }
12562
+ function reportResolutionError(error, context) {
12563
+ if (options.onResolutionError != null) {
12564
+ options.onResolutionError(error, context);
12565
+ return;
12566
+ }
12567
+ console.error(`[theming] Failed to resolve theme "${context.name}" for ${context.colorScheme} color scheme`, error);
12568
+ }
12569
+ function preloadInactiveFor(selection) {
12570
+ if (!preloadInactive) return;
12571
+ const activeName = activeThemeNameFor(selection);
12572
+ const inactive = selection.resolvedColorScheme === "dark" ? selection.lightThemeName : selection.darkThemeName;
12573
+ if (inactive !== activeName && resolver.getResolvedTheme(inactive) === void 0) resolver.resolveTheme(inactive).catch(() => {});
12574
+ }
12575
+ function resolveActive(patch = {}, { notifyPending = false, persistOnSuccess = false } = {}) {
12576
+ const selectionPatch = {
12577
+ ...pendingSelectionPatch,
12578
+ ...patch
12579
+ };
12580
+ const next = intendedState(patch);
12581
+ const name = activeThemeNameFor(next);
12582
+ const colorScheme = next.resolvedColorScheme;
12583
+ const cached = resolver.getResolvedTheme(name);
12584
+ if (cached !== void 0) {
12585
+ activeResolutionId++;
12586
+ pendingSelectionPatch = void 0;
12587
+ state = {
12588
+ ...state,
12589
+ ...selectionPatch,
12590
+ pendingThemeResolution: void 0,
12591
+ resolutionError: void 0,
12592
+ resolvedTheme: cached
12593
+ };
12594
+ if (persistOnSuccess) persist();
12595
+ notify();
12596
+ preloadInactiveFor(state);
12597
+ return;
12598
+ }
12599
+ const resolutionId = ++activeResolutionId;
12600
+ pendingSelectionPatch = selectionPatch;
12601
+ state = {
12602
+ ...state,
12603
+ pendingThemeResolution: {
12604
+ colorScheme,
12605
+ name
12606
+ },
12607
+ resolutionError: void 0
12608
+ };
12609
+ if (notifyPending) notify();
12610
+ resolver.resolveTheme(name).then((theme) => {
12611
+ if (resolutionId !== activeResolutionId) return;
12612
+ const latestIntended = intendedState();
12613
+ if (latestIntended.resolvedColorScheme !== colorScheme || activeThemeNameFor(latestIntended) !== name) return;
12614
+ const patchToCommit = pendingSelectionPatch ?? {};
12615
+ pendingSelectionPatch = void 0;
12616
+ state = {
12617
+ ...state,
12618
+ ...patchToCommit,
12619
+ pendingThemeResolution: void 0,
12620
+ resolutionError: void 0,
12621
+ resolvedTheme: theme
12622
+ };
12623
+ if (persistOnSuccess) persist();
12624
+ notify();
12625
+ preloadInactiveFor(state);
12626
+ }).catch((error) => {
12627
+ if (resolutionId !== activeResolutionId) return;
12628
+ pendingSelectionPatch = void 0;
12629
+ state = {
12630
+ ...state,
12631
+ pendingThemeResolution: void 0,
12632
+ resolutionError: {
12633
+ colorScheme,
12634
+ error,
12635
+ name
12636
+ }
12637
+ };
12638
+ reportResolutionError(error, {
12639
+ colorScheme,
12640
+ name
12641
+ });
12642
+ notify();
12643
+ });
12644
+ }
12645
+ function updateInactiveThemeName(key$1, name) {
12646
+ state = {
12647
+ ...state,
12648
+ [key$1]: name,
12649
+ resolutionError: void 0
12650
+ };
12651
+ persist();
12652
+ notify();
12653
+ preloadInactiveFor(state);
12654
+ }
12655
+ function isSchemeActiveInIntendedState(scheme, patch = {}) {
12656
+ return intendedState(patch).resolvedColorScheme === scheme;
12657
+ }
12658
+ function setActiveSelection(patch) {
12659
+ resolveActive(patch, {
12660
+ notifyPending: true,
12661
+ persistOnSuccess: true
12662
+ });
12663
+ }
12664
+ function setInactiveThemeName(scheme, key$1, name) {
12665
+ if (isSchemeActiveInIntendedState(scheme, { [key$1]: name })) setActiveSelection({ [key$1]: name });
12666
+ else updateInactiveThemeName(key$1, name);
12667
+ }
12668
+ function setMode(mode) {
12669
+ setActiveSelection({
12670
+ mode,
12671
+ resolvedColorScheme: resolveColorScheme(mode)
12672
+ });
12673
+ }
12674
+ function maybeUpdateSystemColorScheme() {
12675
+ if (intendedState().mode !== "system") return;
12676
+ const next = resolveColorScheme("system");
12677
+ if (next !== intendedState().resolvedColorScheme) resolveActive({ resolvedColorScheme: next }, { notifyPending: true });
12678
+ }
12679
+ function isSelectedValue(key$1, value) {
12680
+ return intendedState()[key$1] === value;
12681
+ }
12682
+ let mediaQuery;
12683
+ const handleMediaChange = () => {
12684
+ maybeUpdateSystemColorScheme();
12685
+ };
12686
+ function attachMediaListener() {
12687
+ try {
12688
+ if (typeof globalThis !== "undefined" && globalThis.matchMedia != null) {
12689
+ mediaQuery = globalThis.matchMedia("(prefers-color-scheme: dark)");
12690
+ mediaQuery.addEventListener("change", handleMediaChange);
12691
+ }
12692
+ } catch {}
12693
+ }
12694
+ hydrateFromStorage();
12695
+ attachMediaListener();
12696
+ resolveActive();
12697
+ return {
12698
+ resolver,
12699
+ destroy() {
12700
+ if (mediaQuery != null) {
12701
+ mediaQuery.removeEventListener("change", handleMediaChange);
12702
+ mediaQuery = void 0;
12703
+ }
12704
+ listeners.clear();
12705
+ },
12706
+ getState() {
12707
+ return state;
12708
+ },
12709
+ setColorMode(mode) {
12710
+ if (isSelectedValue("mode", mode)) return;
12711
+ setMode(mode);
12712
+ },
12713
+ setThemeNameForScheme(scheme, name) {
12714
+ const key$1 = scheme === "light" ? "lightThemeName" : "darkThemeName";
12715
+ if (isSelectedValue(key$1, name)) return;
12716
+ setInactiveThemeName(scheme, key$1, name);
12717
+ },
12718
+ subscribe(listener) {
12719
+ listeners.add(listener);
12720
+ return () => {
12721
+ listeners.delete(listener);
12722
+ };
12723
+ }
12724
+ };
12725
+ }
12726
+
12727
+ //#endregion
12728
+ //#region src/highlighter/themes/themeResolver.ts
12729
+ const themeResolver = createThemeResolver();
12730
+
12242
12731
  //#endregion
12243
12732
  //#region src/highlighter/themes/attachResolvedThemes.ts
12244
12733
  function attachResolvedThemes(themes, highlighter$1) {
@@ -12246,15 +12735,15 @@ function attachResolvedThemes(themes, highlighter$1) {
12246
12735
  for (let themeRef of themes) {
12247
12736
  let resolvedTheme;
12248
12737
  if (typeof themeRef === "string") {
12249
- resolvedTheme = ResolvedThemes.get(themeRef);
12738
+ resolvedTheme = themeResolver.getResolvedTheme(themeRef);
12250
12739
  if (resolvedTheme == null) {
12251
12740
  throw new Error(`loadResolvedThemes: ${themeRef} is not resolved, you must resolve it before calling loadResolvedThemes`);
12252
12741
  }
12253
12742
  } else {
12254
12743
  resolvedTheme = themeRef;
12255
12744
  themeRef = themeRef.name;
12256
- if (!ResolvedThemes.has(themeRef)) {
12257
- ResolvedThemes.set(themeRef, resolvedTheme);
12745
+ if (themeResolver.getResolvedTheme(themeRef) == null) {
12746
+ themeResolver.seedResolvedTheme(themeRef, resolvedTheme);
12258
12747
  }
12259
12748
  }
12260
12749
  if (AttachedThemes.has(themeRef)) continue;
@@ -12668,7 +13157,7 @@ function getCustomExtensionsMap() {
12668
13157
  }
12669
13158
 
12670
13159
  //#endregion
12671
- //#region ../../node_modules/diff/libesm/diff/base.js
13160
+ //#region ../../node_modules/.bun/diff@8.0.3/node_modules/diff/libesm/diff/base.js
12672
13161
  var Diff = class {
12673
13162
  diff(oldStr, newStr, options = {}) {
12674
13163
  let callback;
@@ -12892,7 +13381,7 @@ var Diff = class {
12892
13381
  };
12893
13382
 
12894
13383
  //#endregion
12895
- //#region ../../node_modules/diff/libesm/diff/character.js
13384
+ //#region ../../node_modules/.bun/diff@8.0.3/node_modules/diff/libesm/diff/character.js
12896
13385
  var CharacterDiff = class extends Diff {};
12897
13386
  const characterDiff = new CharacterDiff();
12898
13387
  function diffChars(oldStr, newStr, options) {
@@ -12900,7 +13389,7 @@ function diffChars(oldStr, newStr, options) {
12900
13389
  }
12901
13390
 
12902
13391
  //#endregion
12903
- //#region ../../node_modules/diff/libesm/util/string.js
13392
+ //#region ../../node_modules/.bun/diff@8.0.3/node_modules/diff/libesm/util/string.js
12904
13393
  function longestCommonPrefix(str1, str2) {
12905
13394
  let i$2;
12906
13395
  for (i$2 = 0; i$2 < str1.length && i$2 < str2.length; i$2++) {
@@ -13009,7 +13498,7 @@ function leadingWs(string) {
13009
13498
  }
13010
13499
 
13011
13500
  //#endregion
13012
- //#region ../../node_modules/diff/libesm/diff/word.js
13501
+ //#region ../../node_modules/.bun/diff@8.0.3/node_modules/diff/libesm/diff/word.js
13013
13502
  const extendedWordChars = "a-zA-Z0-9_\\u{AD}\\u{C0}-\\u{D6}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}";
13014
13503
  const tokenizeIncludingWhitespace = new RegExp(`[${extendedWordChars}]+|\\s+|[^${extendedWordChars}]`, "ug");
13015
13504
  var WordDiff = class extends Diff {
@@ -13163,7 +13652,7 @@ function diffWordsWithSpace(oldStr, newStr, options) {
13163
13652
  }
13164
13653
 
13165
13654
  //#endregion
13166
- //#region ../../node_modules/diff/libesm/util/params.js
13655
+ //#region ../../node_modules/.bun/diff@8.0.3/node_modules/diff/libesm/util/params.js
13167
13656
  function generateOptions(options, defaults) {
13168
13657
  if (typeof options === "function") {
13169
13658
  defaults.callback = options;
@@ -13179,7 +13668,7 @@ function generateOptions(options, defaults) {
13179
13668
  }
13180
13669
 
13181
13670
  //#endregion
13182
- //#region ../../node_modules/diff/libesm/diff/line.js
13671
+ //#region ../../node_modules/.bun/diff@8.0.3/node_modules/diff/libesm/diff/line.js
13183
13672
  var LineDiff = class extends Diff {
13184
13673
  constructor() {
13185
13674
  super(...arguments);
@@ -13232,7 +13721,7 @@ function tokenize(value, options) {
13232
13721
  }
13233
13722
 
13234
13723
  //#endregion
13235
- //#region ../../node_modules/diff/libesm/diff/sentence.js
13724
+ //#region ../../node_modules/.bun/diff@8.0.3/node_modules/diff/libesm/diff/sentence.js
13236
13725
  function isSentenceEndPunct(char) {
13237
13726
  return char == "." || char == "!" || char == "?";
13238
13727
  }
@@ -13265,7 +13754,7 @@ function diffSentences(oldStr, newStr, options) {
13265
13754
  }
13266
13755
 
13267
13756
  //#endregion
13268
- //#region ../../node_modules/diff/libesm/diff/css.js
13757
+ //#region ../../node_modules/.bun/diff@8.0.3/node_modules/diff/libesm/diff/css.js
13269
13758
  var CssDiff = class extends Diff {
13270
13759
  tokenize(value) {
13271
13760
  return value.split(/([{}:;,]|\s+)/);
@@ -13277,7 +13766,7 @@ function diffCss(oldStr, newStr, options) {
13277
13766
  }
13278
13767
 
13279
13768
  //#endregion
13280
- //#region ../../node_modules/diff/libesm/diff/json.js
13769
+ //#region ../../node_modules/.bun/diff@8.0.3/node_modules/diff/libesm/diff/json.js
13281
13770
  var JsonDiff = class extends Diff {
13282
13771
  constructor() {
13283
13772
  super(...arguments);
@@ -13351,7 +13840,7 @@ function canonicalize(obj, stack, replacementStack, replacer, key$1) {
13351
13840
  }
13352
13841
 
13353
13842
  //#endregion
13354
- //#region ../../node_modules/diff/libesm/diff/array.js
13843
+ //#region ../../node_modules/.bun/diff@8.0.3/node_modules/diff/libesm/diff/array.js
13355
13844
  var ArrayDiff = class extends Diff {
13356
13845
  tokenize(value) {
13357
13846
  return value.slice();
@@ -13369,7 +13858,7 @@ function diffArrays(oldArr, newArr, options) {
13369
13858
  }
13370
13859
 
13371
13860
  //#endregion
13372
- //#region ../../node_modules/diff/libesm/patch/line-endings.js
13861
+ //#region ../../node_modules/.bun/diff@8.0.3/node_modules/diff/libesm/patch/line-endings.js
13373
13862
  function unixToWin(patch) {
13374
13863
  if (Array.isArray(patch)) {
13375
13864
  return patch.map((p$1) => unixToWin(p$1));
@@ -13409,7 +13898,7 @@ function isWin(patch) {
13409
13898
  }
13410
13899
 
13411
13900
  //#endregion
13412
- //#region ../../node_modules/diff/libesm/patch/parse.js
13901
+ //#region ../../node_modules/.bun/diff@8.0.3/node_modules/diff/libesm/patch/parse.js
13413
13902
  /**
13414
13903
  * Parses a patch into structured data, in the same structure returned by `structuredPatch`.
13415
13904
  *
@@ -13520,7 +14009,7 @@ function parsePatch(uniDiff) {
13520
14009
  }
13521
14010
 
13522
14011
  //#endregion
13523
- //#region ../../node_modules/diff/libesm/util/distance-iterator.js
14012
+ //#region ../../node_modules/.bun/diff@8.0.3/node_modules/diff/libesm/util/distance-iterator.js
13524
14013
  function distance_iterator_default(start, minLine, maxLine) {
13525
14014
  let wantForward = true, backwardExhausted = false, forwardExhausted = false, localOffset = 1;
13526
14015
  return function iterator() {
@@ -13550,7 +14039,7 @@ function distance_iterator_default(start, minLine, maxLine) {
13550
14039
  }
13551
14040
 
13552
14041
  //#endregion
13553
- //#region ../../node_modules/diff/libesm/patch/apply.js
14042
+ //#region ../../node_modules/.bun/diff@8.0.3/node_modules/diff/libesm/patch/apply.js
13554
14043
  /**
13555
14044
  * attempts to apply a unified diff patch.
13556
14045
  *
@@ -13769,7 +14258,7 @@ function applyPatches(uniDiff, options) {
13769
14258
  }
13770
14259
 
13771
14260
  //#endregion
13772
- //#region ../../node_modules/diff/libesm/patch/reverse.js
14261
+ //#region ../../node_modules/.bun/diff@8.0.3/node_modules/diff/libesm/patch/reverse.js
13773
14262
  function reversePatch(structuredPatch$1) {
13774
14263
  if (Array.isArray(structuredPatch$1)) {
13775
14264
  return structuredPatch$1.map((patch) => reversePatch(patch)).reverse();
@@ -13800,7 +14289,7 @@ function reversePatch(structuredPatch$1) {
13800
14289
  }
13801
14290
 
13802
14291
  //#endregion
13803
- //#region ../../node_modules/diff/libesm/patch/create.js
14292
+ //#region ../../node_modules/.bun/diff@8.0.3/node_modules/diff/libesm/patch/create.js
13804
14293
  const INCLUDE_HEADERS = {
13805
14294
  includeIndex: true,
13806
14295
  includeUnderline: true,
@@ -14004,7 +14493,7 @@ function splitLines(text$1) {
14004
14493
  }
14005
14494
 
14006
14495
  //#endregion
14007
- //#region ../../node_modules/diff/libesm/convert/dmp.js
14496
+ //#region ../../node_modules/.bun/diff@8.0.3/node_modules/diff/libesm/convert/dmp.js
14008
14497
  /**
14009
14498
  * converts a list of change objects to the format returned by Google's [diff-match-patch](https://github.com/google/diff-match-patch) library
14010
14499
  */
@@ -14026,7 +14515,7 @@ function convertChangesToDMP(changes) {
14026
14515
  }
14027
14516
 
14028
14517
  //#endregion
14029
- //#region ../../node_modules/diff/libesm/convert/xml.js
14518
+ //#region ../../node_modules/.bun/diff@8.0.3/node_modules/diff/libesm/convert/xml.js
14030
14519
  /**
14031
14520
  * converts a list of change objects to a serialized XML format
14032
14521
  */
@@ -14071,7 +14560,7 @@ function cleanLastNewline(contents) {
14071
14560
  }
14072
14561
 
14073
14562
  //#endregion
14074
- //#region ../../node_modules/@shikijs/transformers/dist/index.mjs
14563
+ //#region ../../node_modules/.bun/@shikijs+transformers@4.0.2/node_modules/@shikijs/transformers/dist/index.mjs
14075
14564
  /**
14076
14565
  * some comment formats have to be located at the end of line
14077
14566
  * hence we can skip matching them for other tokens
@@ -15069,30 +15558,234 @@ function formatCSSVariablePrefix(type) {
15069
15558
  return `--${type === "token" ? "diffs-token" : "diffs"}-`;
15070
15559
  }
15071
15560
 
15561
+ //#endregion
15562
+ //#region ../theming/dist/modules/color.js
15563
+ /**
15564
+ * Canonical color/contrast primitives
15565
+ */
15566
+ const MIN_READABLE_RATIO = 3;
15567
+ const MIN_MUTED_RATIO = 4.5;
15568
+ const HEX_TRANSPARENT_RE = /^#(?:[0-9a-f]{3}0|[0-9a-f]{6}00)$/i;
15569
+ const ALPHA_ZERO_RE = /^0(?:\.0+)?%?$/;
15570
+ function getFunctionalAlpha(color) {
15571
+ const openParen = color.indexOf("(");
15572
+ if (openParen <= 0 || !color.endsWith(")")) return;
15573
+ const fn = color.slice(0, openParen).trim();
15574
+ if (!/^(?:rgb|rgba|hsl|hsla|hwb|lab|lch|oklab|oklch|color)$/i.test(fn)) return;
15575
+ const inner = color.slice(openParen + 1, -1).trim();
15576
+ if (inner.length === 0) return;
15577
+ const slashIndex = inner.lastIndexOf("/");
15578
+ if (slashIndex !== -1) return inner.slice(slashIndex + 1).trim();
15579
+ if (/^(?:rgba|hsla)$/i.test(fn)) {
15580
+ const parts = inner.split(",");
15581
+ if (parts.length === 4) return parts[3]?.trim();
15582
+ }
15583
+ }
15584
+ function parseHexRgba(color) {
15585
+ const match = /^#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})\b/i.exec(color.trim());
15586
+ if (match == null) return null;
15587
+ const hex = match[1];
15588
+ let expanded;
15589
+ let alpha = 1;
15590
+ if (hex.length === 3) expanded = hex.split("").map((c) => c + c).join("");
15591
+ else if (hex.length === 6) expanded = hex;
15592
+ else {
15593
+ expanded = hex.slice(0, 6);
15594
+ alpha = parseInt(hex.slice(6, 8), 16) / 255;
15595
+ }
15596
+ return [
15597
+ parseInt(expanded.slice(0, 2), 16),
15598
+ parseInt(expanded.slice(2, 4), 16),
15599
+ parseInt(expanded.slice(4, 6), 16),
15600
+ alpha
15601
+ ];
15602
+ }
15603
+ function relativeLuminance(color) {
15604
+ if (color == null) return null;
15605
+ const rgba = parseHexRgba(color);
15606
+ if (rgba == null) return null;
15607
+ const r$3 = rgba[0] / 255;
15608
+ const g = rgba[1] / 255;
15609
+ const b$2 = rgba[2] / 255;
15610
+ const channel = (v$1) => v$1 <= .03928 ? v$1 / 12.92 : ((v$1 + .055) / 1.055) ** 2.4;
15611
+ return .2126 * channel(r$3) + .7152 * channel(g) + .0722 * channel(b$2);
15612
+ }
15613
+ function contrastRatio(a$1, b$2) {
15614
+ const [hi, lo] = a$1 > b$2 ? [a$1, b$2] : [b$2, a$1];
15615
+ return (hi + .05) / (lo + .05);
15616
+ }
15617
+ function compositeOverBg(fgColor, bgColor) {
15618
+ if (bgColor == null) return void 0;
15619
+ const fgParts = parseHexRgba(fgColor);
15620
+ const bgParts = parseHexRgba(bgColor);
15621
+ if (fgParts == null || bgParts == null) return void 0;
15622
+ const [fr, fg, fb, fa] = fgParts;
15623
+ const [br, bg, bb] = bgParts;
15624
+ return "#" + [
15625
+ Math.round(fr * fa + br * (1 - fa)),
15626
+ Math.round(fg * fa + bg * (1 - fa)),
15627
+ Math.round(fb * fa + bb * (1 - fa))
15628
+ ].map((v$1) => v$1.toString(16).padStart(2, "0")).join("");
15629
+ }
15630
+ function isFullyTransparent(color) {
15631
+ if (color == null) return false;
15632
+ const normalized = color.trim().toLowerCase();
15633
+ if (normalized === "transparent") return true;
15634
+ if (HEX_TRANSPARENT_RE.test(normalized)) return true;
15635
+ const alpha = getFunctionalAlpha(normalized);
15636
+ return alpha != null && ALPHA_ZERO_RE.test(alpha);
15637
+ }
15638
+ function isDarkSurface(bg, fgHint) {
15639
+ const fromBg = relativeLuminance(bg);
15640
+ if (fromBg != null) return fromBg < .4;
15641
+ const fromFg = relativeLuminance(fgHint);
15642
+ return fromFg != null ? fromFg > .6 : false;
15643
+ }
15644
+ function surfacesMatch(a$1, b$2) {
15645
+ if (a$1 == null || b$2 == null) return false;
15646
+ if (a$1.trim().toLowerCase() === b$2.trim().toLowerCase()) return true;
15647
+ const la = relativeLuminance(a$1);
15648
+ const lb = relativeLuminance(b$2);
15649
+ if (la == null || lb == null) return false;
15650
+ return Math.abs(la - lb) < .06;
15651
+ }
15652
+ function hoverWouldEraseText(hover, bg, fg) {
15653
+ if (bg == null || fg == null) return false;
15654
+ const hoverL = relativeLuminance(hover);
15655
+ const bgL = relativeLuminance(bg);
15656
+ const fgL = relativeLuminance(fg);
15657
+ if (hoverL == null || bgL == null || fgL == null) return false;
15658
+ return Math.abs(hoverL - fgL) < Math.abs(hoverL - bgL);
15659
+ }
15660
+ function pickReadableForeground(bg, candidates) {
15661
+ const bgL = relativeLuminance(bg);
15662
+ const firstDefined = candidates.find((candidate) => candidate != null && candidate !== "");
15663
+ if (bgL == null) return firstDefined;
15664
+ let best;
15665
+ let bestRatio = -1;
15666
+ for (const candidate of candidates) {
15667
+ if (candidate == null || candidate === "") continue;
15668
+ const candidateL = relativeLuminance(candidate);
15669
+ if (candidateL == null) continue;
15670
+ const ratio = contrastRatio(bgL, candidateL);
15671
+ if (ratio >= MIN_READABLE_RATIO) return candidate;
15672
+ if (ratio > bestRatio) {
15673
+ best = candidate;
15674
+ bestRatio = ratio;
15675
+ }
15676
+ }
15677
+ return best ?? firstDefined;
15678
+ }
15679
+ function deriveMutedFg(primaryFg, bg) {
15680
+ if (bg == null) return primaryFg;
15681
+ const fgParts = parseHexRgba(primaryFg);
15682
+ const bgParts = parseHexRgba(bg);
15683
+ const bgL = relativeLuminance(bg);
15684
+ if (fgParts == null || bgParts == null || bgL == null) return `color-mix(in srgb, ${primaryFg} 70%, ${bg})`;
15685
+ const [fr, fg2, fb] = fgParts;
15686
+ const [br, bg3, bb] = bgParts;
15687
+ for (const weight of [
15688
+ .6,
15689
+ .7,
15690
+ .8,
15691
+ .9
15692
+ ]) {
15693
+ const hex = "#" + [
15694
+ Math.round(fr * weight + br * (1 - weight)),
15695
+ Math.round(fg2 * weight + bg3 * (1 - weight)),
15696
+ Math.round(fb * weight + bb * (1 - weight))
15697
+ ].map((v$1) => v$1.toString(16).padStart(2, "0")).join("");
15698
+ const L$2 = relativeLuminance(hex);
15699
+ if (L$2 != null && contrastRatio(bgL, L$2) >= MIN_MUTED_RATIO) return hex;
15700
+ }
15701
+ return primaryFg;
15702
+ }
15703
+
15704
+ //#endregion
15705
+ //#region ../theming/dist/modules/normalizeThemeColors.js
15706
+ const cache = /* @__PURE__ */ new WeakMap();
15707
+ function normalizeThemeColors(theme) {
15708
+ const cached = cache.get(theme);
15709
+ if (cached != null) return cached;
15710
+ const originalColors = theme.colors ?? {};
15711
+ const colors = { ...originalColors };
15712
+ const editorBackground = originalColors["editor.background"] ?? theme.bg;
15713
+ const editorForeground = originalColors["editor.foreground"] ?? theme.fg;
15714
+ const sidebarBackground = originalColors["sideBar.background"] ?? editorBackground;
15715
+ const sidebarForeground = originalColors["sideBar.foreground"] ?? editorForeground;
15716
+ fill(colors, "editor.background", editorBackground);
15717
+ fill(colors, "editor.foreground", editorForeground);
15718
+ fill(colors, "sideBar.background", sidebarBackground);
15719
+ fill(colors, "sideBar.foreground", sidebarForeground);
15720
+ fill(colors, "input.background", originalColors["input.background"] ?? sidebarBackground);
15721
+ fill(colors, "sideBarSectionHeader.foreground", originalColors["sideBarSectionHeader.foreground"] ?? sidebarForeground);
15722
+ fill(colors, "list.activeSelectionForeground", originalColors["list.activeSelectionForeground"] ?? sidebarForeground);
15723
+ fill(colors, "gitDecoration.addedResourceForeground", firstColor(originalColors["gitDecoration.addedResourceForeground"], originalColors["terminal.ansiGreen"], originalColors["editorGutter.addedBackground"]));
15724
+ fill(colors, "gitDecoration.modifiedResourceForeground", firstColor(originalColors["gitDecoration.modifiedResourceForeground"], originalColors["terminal.ansiBlue"], originalColors["editorGutter.modifiedBackground"]));
15725
+ fill(colors, "gitDecoration.deletedResourceForeground", firstColor(originalColors["gitDecoration.deletedResourceForeground"], originalColors["terminal.ansiRed"], originalColors["editorGutter.deletedBackground"]));
15726
+ const focusRing = (isFullyTransparent(originalColors["list.focusOutline"]) ? void 0 : originalColors["list.focusOutline"]) ?? (isFullyTransparent(originalColors["focusBorder"]) ? void 0 : originalColors["focusBorder"]);
15727
+ if (focusRing != null) colors["list.focusOutline"] = focusRing;
15728
+ else delete colors["list.focusOutline"];
15729
+ const hover = originalColors["list.hoverBackground"];
15730
+ if (hover != null && (matchesSurface(hover, sidebarBackground) || hoverWouldEraseText(hover, sidebarBackground, sidebarForeground))) delete colors["list.hoverBackground"];
15731
+ const result = Object.freeze({
15732
+ ...theme,
15733
+ colors: Object.freeze(colors)
15734
+ });
15735
+ cache.set(theme, result);
15736
+ return result;
15737
+ }
15738
+ function fill(colors, key$1, value) {
15739
+ if (value != null && value !== "") colors[key$1] = value;
15740
+ }
15741
+ function firstColor(...candidates) {
15742
+ for (const candidate of candidates) if (candidate != null && candidate !== "") return candidate;
15743
+ }
15744
+ function matchesSurface(color, surface) {
15745
+ return surface != null && color.toLowerCase() === surface.toLowerCase();
15746
+ }
15747
+
15748
+ //#endregion
15749
+ //#region ../theming/dist/color.js
15750
+ const colorUtils = {
15751
+ compositeOverBg,
15752
+ contrastRatio,
15753
+ deriveMutedFg,
15754
+ hoverWouldEraseText,
15755
+ isDarkSurface,
15756
+ isFullyTransparent,
15757
+ pickReadableForeground,
15758
+ relativeLuminance,
15759
+ surfacesMatch
15760
+ };
15761
+
15072
15762
  //#endregion
15073
15763
  //#region src/utils/getHighlighterThemeStyles.ts
15074
15764
  function getHighlighterThemeStyles({ theme = DEFAULT_THEMES, highlighter: highlighter$1, prefix }) {
15075
15765
  let styles = "";
15076
15766
  if (typeof theme === "string") {
15077
15767
  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);
15768
+ const normalized = normalizeThemeColors(themeData);
15769
+ styles += `color:${normalized.fg};`;
15770
+ styles += `background-color:${normalized.bg};`;
15771
+ styles += `${formatCSSVariablePrefix("global")}fg:${normalized.fg};`;
15772
+ styles += `${formatCSSVariablePrefix("global")}bg:${normalized.bg};`;
15773
+ styles += getGitVariables(themeData, prefix);
15083
15774
  } else {
15084
15775
  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");
15776
+ let normalized = normalizeThemeColors(themeData);
15777
+ styles += `${formatCSSVariablePrefix("global")}dark:${normalized.fg};`;
15778
+ styles += `${formatCSSVariablePrefix("global")}dark-bg:${normalized.bg};`;
15779
+ styles += getGitVariables(themeData, "dark");
15088
15780
  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");
15781
+ normalized = normalizeThemeColors(themeData);
15782
+ styles += `${formatCSSVariablePrefix("global")}light:${normalized.fg};`;
15783
+ styles += `${formatCSSVariablePrefix("global")}light-bg:${normalized.bg};`;
15784
+ styles += getGitVariables(themeData, "light");
15092
15785
  }
15093
15786
  return styles;
15094
15787
  }
15095
- function getThemeVariables(themeData, modePrefix) {
15788
+ function getGitVariables(themeData, modePrefix) {
15096
15789
  modePrefix = modePrefix != null ? `${modePrefix}-` : "";
15097
15790
  let styles = "";
15098
15791
  const additionGreen = themeData.colors?.["gitDecoration.addedResourceForeground"] ?? themeData.colors?.["terminal.ansiGreen"];
@@ -15191,6 +15884,72 @@ function getExpandedRegion({ isPartial, rangeSize, expandedHunks, hunkIndex, col
15191
15884
  renderAll
15192
15885
  };
15193
15886
  }
15887
+ function hasTrailingContext(fileDiff) {
15888
+ const lastHunk = fileDiff.hunks[fileDiff.hunks.length - 1];
15889
+ if (lastHunk == null || fileDiff.isPartial || fileDiff.additionLines.length === 0 || fileDiff.deletionLines.length === 0) {
15890
+ return false;
15891
+ }
15892
+ const additionRemaining = fileDiff.additionLines.length - (lastHunk.additionLineIndex + lastHunk.additionCount);
15893
+ const deletionRemaining = fileDiff.deletionLines.length - (lastHunk.deletionLineIndex + lastHunk.deletionCount);
15894
+ return additionRemaining > 0 || deletionRemaining > 0;
15895
+ }
15896
+ function hasTrailingContextMismatch(fileDiff) {
15897
+ const lastHunk = fileDiff.hunks[fileDiff.hunks.length - 1];
15898
+ if (lastHunk == null || fileDiff.isPartial || fileDiff.additionLines.length === 0 || fileDiff.deletionLines.length === 0) {
15899
+ return false;
15900
+ }
15901
+ const additionRemaining = fileDiff.additionLines.length - (lastHunk.additionLineIndex + lastHunk.additionCount);
15902
+ const deletionRemaining = fileDiff.deletionLines.length - (lastHunk.deletionLineIndex + lastHunk.deletionCount);
15903
+ if (additionRemaining <= 0 && deletionRemaining <= 0) {
15904
+ return false;
15905
+ }
15906
+ return additionRemaining !== deletionRemaining;
15907
+ }
15908
+ function getTrailingContextRangeSize({ fileDiff, errorPrefix }) {
15909
+ const lastHunk = fileDiff.hunks[fileDiff.hunks.length - 1];
15910
+ if (lastHunk == null || fileDiff.isPartial || fileDiff.additionLines.length === 0 || fileDiff.deletionLines.length === 0) {
15911
+ return 0;
15912
+ }
15913
+ const additionRemaining = fileDiff.additionLines.length - (lastHunk.additionLineIndex + lastHunk.additionCount);
15914
+ const deletionRemaining = fileDiff.deletionLines.length - (lastHunk.deletionLineIndex + lastHunk.deletionCount);
15915
+ if (additionRemaining <= 0 && deletionRemaining <= 0) {
15916
+ return 0;
15917
+ }
15918
+ if (additionRemaining !== deletionRemaining) {
15919
+ throw new Error(`${errorPrefix}: trailing context mismatch (additions=${additionRemaining}, deletions=${deletionRemaining}) for ${fileDiff.name}`);
15920
+ }
15921
+ return Math.min(additionRemaining, deletionRemaining);
15922
+ }
15923
+ function getTrailingExpandedRegion({ fileDiff, hunkIndex, expandedHunks, collapsedContextThreshold, errorPrefix }) {
15924
+ if (hunkIndex !== fileDiff.hunks.length - 1) {
15925
+ return undefined;
15926
+ }
15927
+ const trailingRangeSize = getTrailingContextRangeSize({
15928
+ fileDiff,
15929
+ errorPrefix
15930
+ });
15931
+ if (trailingRangeSize <= 0) {
15932
+ return undefined;
15933
+ }
15934
+ if (expandedHunks === true || trailingRangeSize <= collapsedContextThreshold) {
15935
+ return {
15936
+ fromStart: trailingRangeSize,
15937
+ fromEnd: 0,
15938
+ rangeSize: trailingRangeSize,
15939
+ collapsedLines: 0,
15940
+ renderAll: true
15941
+ };
15942
+ }
15943
+ const region = expandedHunks?.get(fileDiff.hunks.length);
15944
+ const fromStart = Math.min(Math.max(region?.fromStart ?? 0, 0), trailingRangeSize);
15945
+ return {
15946
+ fromStart,
15947
+ fromEnd: 0,
15948
+ rangeSize: trailingRangeSize,
15949
+ collapsedLines: trailingRangeSize - fromStart,
15950
+ renderAll: fromStart >= trailingRangeSize
15951
+ };
15952
+ }
15194
15953
  function getHunkSeparatorHeight({ type, metrics }) {
15195
15954
  return metrics.hunkSeparatorHeight ?? getDefaultHunkSeparatorHeight(type);
15196
15955
  }
@@ -15265,12 +16024,12 @@ function iterateOverDiff({ diff, diffStyle, startingLine = 0, totalLines = Infin
15265
16024
  collapsedContextThreshold
15266
16025
  });
15267
16026
  const state = {
15268
- finalHunk: diff.hunks.at(-1),
15269
16027
  viewportStart: startingLine,
15270
16028
  viewportEnd: startingLine + totalLines,
15271
16029
  isWindowedHighlight: startingLine > 0 || totalLines < Infinity,
15272
16030
  splitCount: iterationStart.splitCount,
15273
16031
  unifiedCount: iterationStart.unifiedCount,
16032
+ finalHunkIndex: diff.hunks.length - 1,
15274
16033
  shouldBreak() {
15275
16034
  if (!state.isWindowedHighlight) {
15276
16035
  return false;
@@ -15355,24 +16114,13 @@ function iterateOverDiff({ diff, diffStyle, startingLine = 0, totalLines = Infin
15355
16114
  hunkIndex,
15356
16115
  collapsedContextThreshold
15357
16116
  });
15358
- const trailingRegion = (() => {
15359
- if (hunk !== state.finalHunk || !hasFinalCollapsedHunk(diff)) {
15360
- return undefined;
15361
- }
15362
- const additionRemaining = diff.additionLines.length - (hunk.additionLineIndex + hunk.additionCount);
15363
- const deletionRemaining = diff.deletionLines.length - (hunk.deletionLineIndex + hunk.deletionCount);
15364
- if (additionRemaining !== deletionRemaining) {
15365
- throw new Error(`iterateOverDiff: trailing context mismatch (additions=${additionRemaining}, deletions=${deletionRemaining}) for ${diff.name}`);
15366
- }
15367
- const trailingRangeSize = Math.min(additionRemaining, deletionRemaining);
15368
- return getExpandedRegion({
15369
- isPartial: diff.isPartial,
15370
- rangeSize: trailingRangeSize,
15371
- expandedHunks,
15372
- hunkIndex: diff.hunks.length,
15373
- collapsedContextThreshold
15374
- });
15375
- })();
16117
+ const trailingRegion = hunkIndex === state.finalHunkIndex ? getTrailingExpandedRegion({
16118
+ fileDiff: diff,
16119
+ hunkIndex,
16120
+ expandedHunks,
16121
+ collapsedContextThreshold,
16122
+ errorPrefix: "iterateOverDiff"
16123
+ }) : undefined;
15376
16124
  const expandedLineCount = leadingRegion.fromStart + leadingRegion.fromEnd;
15377
16125
  function getTrailingCollapsedAfter(unifiedLineIndex$1, splitLineIndex$1) {
15378
16126
  if (trailingRegion == null || trailingRegion.collapsedLines <= 0 || trailingRegion.fromStart + trailingRegion.fromEnd > 0) {
@@ -15383,13 +16131,13 @@ function iterateOverDiff({ diff, diffStyle, startingLine = 0, totalLines = Infin
15383
16131
  }
15384
16132
  return splitLineIndex$1 === hunk.splitLineStart + hunk.splitLineCount - 1 ? trailingRegion.collapsedLines : 0;
15385
16133
  }
15386
- function getPendingCollapsed() {
15387
- if (leadingRegion.collapsedLines === 0) {
16134
+ let consumedCollapsed = leadingRegion.collapsedLines === 0;
16135
+ function consumePendingCollapsed() {
16136
+ if (consumedCollapsed) {
15388
16137
  return 0;
15389
16138
  }
15390
- const value = leadingRegion.collapsedLines;
15391
- leadingRegion.collapsedLines = 0;
15392
- return value;
16139
+ consumedCollapsed = true;
16140
+ return leadingRegion.collapsedLines;
15393
16141
  }
15394
16142
  if (!state.shouldSkip(expandedLineCount, expandedLineCount)) {
15395
16143
  let unifiedLineIndex$1 = hunk.unifiedLineStart - leadingRegion.rangeSize;
@@ -15398,44 +16146,30 @@ function iterateOverDiff({ diff, diffStyle, startingLine = 0, totalLines = Infin
15398
16146
  let additionLineIndex$1 = hunk.additionLineIndex - leadingRegion.rangeSize;
15399
16147
  let deletionLineNumber$1 = hunk.deletionStart - leadingRegion.rangeSize;
15400
16148
  let additionLineNumber$1 = hunk.additionStart - leadingRegion.rangeSize;
15401
- const [startIndex, endIndex] = getEqualLineIterationRange(state, leadingRegion.fromStart, diffStyle);
15402
- if (startIndex > 0) {
15403
- state.incrementCounts(startIndex, startIndex);
15404
- }
15405
- let index = startIndex;
15406
- while (index < leadingRegion.fromStart) {
15407
- if (index >= endIndex) {
15408
- state.incrementCounts(leadingRegion.fromStart - index, leadingRegion.fromStart - index);
15409
- break;
15410
- }
15411
- if (state.isInWindow(0, 0)) {
15412
- if (state.emit({
15413
- hunkIndex,
15414
- hunk,
15415
- collapsedBefore: 0,
15416
- collapsedAfter: 0,
15417
- type: "context-expanded",
15418
- deletionLine: {
15419
- lineNumber: deletionLineNumber$1 + index,
15420
- lineIndex: deletionLineIndex$1 + index,
15421
- noEOFCR: false,
15422
- unifiedLineIndex: unifiedLineIndex$1 + index,
15423
- splitLineIndex: splitLineIndex$1 + index
15424
- },
15425
- additionLine: {
15426
- unifiedLineIndex: unifiedLineIndex$1 + index,
15427
- splitLineIndex: splitLineIndex$1 + index,
15428
- lineIndex: additionLineIndex$1 + index,
15429
- lineNumber: additionLineNumber$1 + index,
15430
- noEOFCR: false
15431
- }
15432
- })) {
15433
- break hunkIterator;
16149
+ if (walkContextLines(state, leadingRegion.fromStart, diffStyle, (index) => {
16150
+ return state.emit({
16151
+ hunkIndex,
16152
+ hunk,
16153
+ collapsedBefore: 0,
16154
+ collapsedAfter: 0,
16155
+ type: "context-expanded",
16156
+ deletionLine: {
16157
+ lineNumber: deletionLineNumber$1 + index,
16158
+ lineIndex: deletionLineIndex$1 + index,
16159
+ noEOFCR: false,
16160
+ unifiedLineIndex: unifiedLineIndex$1 + index,
16161
+ splitLineIndex: splitLineIndex$1 + index
16162
+ },
16163
+ additionLine: {
16164
+ unifiedLineIndex: unifiedLineIndex$1 + index,
16165
+ splitLineIndex: splitLineIndex$1 + index,
16166
+ lineIndex: additionLineIndex$1 + index,
16167
+ lineNumber: additionLineNumber$1 + index,
16168
+ noEOFCR: false
15434
16169
  }
15435
- } else {
15436
- state.incrementCounts(1, 1);
15437
- }
15438
- index++;
16170
+ });
16171
+ })) {
16172
+ break hunkIterator;
15439
16173
  }
15440
16174
  unifiedLineIndex$1 = hunk.unifiedLineStart - leadingRegion.fromEnd;
15441
16175
  splitLineIndex$1 = hunk.splitLineStart - leadingRegion.fromEnd;
@@ -15443,48 +16177,36 @@ function iterateOverDiff({ diff, diffStyle, startingLine = 0, totalLines = Infin
15443
16177
  additionLineIndex$1 = hunk.additionLineIndex - leadingRegion.fromEnd;
15444
16178
  deletionLineNumber$1 = hunk.deletionStart - leadingRegion.fromEnd;
15445
16179
  additionLineNumber$1 = hunk.additionStart - leadingRegion.fromEnd;
15446
- const [fromEndStartIndex, fromEndEndIndex] = getEqualLineIterationRange(state, leadingRegion.fromEnd, diffStyle);
15447
- if (fromEndStartIndex > 0) {
15448
- state.incrementCounts(fromEndStartIndex, fromEndStartIndex);
15449
- }
15450
- index = fromEndStartIndex;
15451
- while (index < leadingRegion.fromEnd) {
15452
- if (index >= fromEndEndIndex) {
15453
- state.incrementCounts(leadingRegion.fromEnd - index, leadingRegion.fromEnd - index);
15454
- break;
15455
- }
15456
- if (state.isInWindow(0, 0)) {
15457
- if (state.emit({
15458
- hunkIndex,
15459
- hunk,
15460
- collapsedBefore: getPendingCollapsed(),
15461
- collapsedAfter: 0,
15462
- type: "context-expanded",
15463
- deletionLine: {
15464
- lineNumber: deletionLineNumber$1 + index,
15465
- lineIndex: deletionLineIndex$1 + index,
15466
- noEOFCR: false,
15467
- unifiedLineIndex: unifiedLineIndex$1 + index,
15468
- splitLineIndex: splitLineIndex$1 + index
15469
- },
15470
- additionLine: {
15471
- unifiedLineIndex: unifiedLineIndex$1 + index,
15472
- splitLineIndex: splitLineIndex$1 + index,
15473
- lineIndex: additionLineIndex$1 + index,
15474
- lineNumber: additionLineNumber$1 + index,
15475
- noEOFCR: false
15476
- }
15477
- })) {
15478
- break hunkIterator;
16180
+ if (walkContextLines(state, leadingRegion.fromEnd, diffStyle, (index) => {
16181
+ return state.emit({
16182
+ hunkIndex,
16183
+ hunk,
16184
+ collapsedBefore: consumePendingCollapsed(),
16185
+ collapsedAfter: 0,
16186
+ type: "context-expanded",
16187
+ deletionLine: {
16188
+ lineNumber: deletionLineNumber$1 + index,
16189
+ lineIndex: deletionLineIndex$1 + index,
16190
+ noEOFCR: false,
16191
+ unifiedLineIndex: unifiedLineIndex$1 + index,
16192
+ splitLineIndex: splitLineIndex$1 + index
16193
+ },
16194
+ additionLine: {
16195
+ unifiedLineIndex: unifiedLineIndex$1 + index,
16196
+ splitLineIndex: splitLineIndex$1 + index,
16197
+ lineIndex: additionLineIndex$1 + index,
16198
+ lineNumber: additionLineNumber$1 + index,
16199
+ noEOFCR: false
15479
16200
  }
15480
- } else {
15481
- state.incrementCounts(1, 1);
15482
- }
15483
- index++;
16201
+ });
16202
+ }, () => {
16203
+ consumePendingCollapsed();
16204
+ })) {
16205
+ break hunkIterator;
15484
16206
  }
15485
16207
  } else {
15486
16208
  state.incrementCounts(expandedLineCount, expandedLineCount);
15487
- getPendingCollapsed();
16209
+ consumePendingCollapsed();
15488
16210
  }
15489
16211
  let unifiedLineIndex = hunk.unifiedLineStart;
15490
16212
  let splitLineIndex = hunk.splitLineStart;
@@ -15500,51 +16222,39 @@ function iterateOverDiff({ diff, diffStyle, startingLine = 0, totalLines = Infin
15500
16222
  const isLastContent = content === lastContent;
15501
16223
  if (content.type === "context") {
15502
16224
  if (!state.shouldSkip(content.lines, content.lines)) {
15503
- const [startIndex, endIndex] = getEqualLineIterationRange(state, content.lines, diffStyle);
15504
- if (startIndex > 0) {
15505
- state.incrementCounts(startIndex, startIndex);
15506
- }
15507
- let index = startIndex;
15508
- while (index < content.lines) {
15509
- if (index >= endIndex) {
15510
- state.incrementCounts(content.lines - index, content.lines - index);
15511
- break;
15512
- }
15513
- if (state.isInWindow(0, 0)) {
15514
- const isLastLine = isLastContent && index === content.lines - 1;
15515
- const unifiedRowIndex = unifiedLineIndex + index;
15516
- const splitRowIndex = splitLineIndex + index;
15517
- if (state.emit({
15518
- hunkIndex,
15519
- hunk,
15520
- collapsedBefore: getPendingCollapsed(),
15521
- collapsedAfter: getTrailingCollapsedAfter(unifiedRowIndex, splitRowIndex),
15522
- type: "context",
15523
- deletionLine: {
15524
- lineNumber: deletionLineNumber + index,
15525
- lineIndex: deletionLineIndex + index,
15526
- noEOFCR: isLastLine && hunk.noEOFCRDeletions,
15527
- unifiedLineIndex: unifiedRowIndex,
15528
- splitLineIndex: splitRowIndex
15529
- },
15530
- additionLine: {
15531
- unifiedLineIndex: unifiedRowIndex,
15532
- splitLineIndex: splitRowIndex,
15533
- lineIndex: additionLineIndex + index,
15534
- lineNumber: additionLineNumber + index,
15535
- noEOFCR: isLastLine && hunk.noEOFCRAdditions
15536
- }
15537
- })) {
15538
- break hunkIterator;
16225
+ if (walkContextLines(state, content.lines, diffStyle, (index) => {
16226
+ const isLastLine = isLastContent && index === content.lines - 1;
16227
+ const unifiedRowIndex = unifiedLineIndex + index;
16228
+ const splitRowIndex = splitLineIndex + index;
16229
+ return state.emit({
16230
+ hunkIndex,
16231
+ hunk,
16232
+ collapsedBefore: consumePendingCollapsed(),
16233
+ collapsedAfter: getTrailingCollapsedAfter(unifiedRowIndex, splitRowIndex),
16234
+ type: "context",
16235
+ deletionLine: {
16236
+ lineNumber: deletionLineNumber + index,
16237
+ lineIndex: deletionLineIndex + index,
16238
+ noEOFCR: isLastLine && hunk.noEOFCRDeletions,
16239
+ unifiedLineIndex: unifiedRowIndex,
16240
+ splitLineIndex: splitRowIndex
16241
+ },
16242
+ additionLine: {
16243
+ unifiedLineIndex: unifiedRowIndex,
16244
+ splitLineIndex: splitRowIndex,
16245
+ lineIndex: additionLineIndex + index,
16246
+ lineNumber: additionLineNumber + index,
16247
+ noEOFCR: isLastLine && hunk.noEOFCRAdditions
15539
16248
  }
15540
- } else {
15541
- state.incrementCounts(1, 1);
15542
- }
15543
- index++;
16249
+ });
16250
+ }, () => {
16251
+ consumePendingCollapsed();
16252
+ })) {
16253
+ break hunkIterator;
15544
16254
  }
15545
16255
  } else {
15546
16256
  state.incrementCounts(content.lines, content.lines);
15547
- getPendingCollapsed();
16257
+ consumePendingCollapsed();
15548
16258
  }
15549
16259
  unifiedLineIndex += content.lines;
15550
16260
  splitLineIndex += content.lines;
@@ -15558,6 +16268,10 @@ function iterateOverDiff({ diff, diffStyle, startingLine = 0, totalLines = Infin
15558
16268
  const shouldSkipChange = state.shouldSkip(unifiedCount, splitCount);
15559
16269
  if (!shouldSkipChange) {
15560
16270
  const iterationRanges = getChangeIterationRanges(state, content, diffStyle);
16271
+ const firstRangeStart = iterationRanges[0]?.[0] ?? 0;
16272
+ if (firstRangeStart > 0) {
16273
+ consumePendingCollapsed();
16274
+ }
15561
16275
  for (const [rangeStart, rangeEnd] of iterationRanges) {
15562
16276
  for (let index = rangeStart; index < rangeEnd; index++) {
15563
16277
  const unifiedRowIndex = unifiedLineIndex + index;
@@ -15566,7 +16280,7 @@ function iterateOverDiff({ diff, diffStyle, startingLine = 0, totalLines = Infin
15566
16280
  if (state.emit(getChangeLineData({
15567
16281
  hunkIndex,
15568
16282
  hunk,
15569
- collapsedBefore: getPendingCollapsed(),
16283
+ collapsedBefore: consumePendingCollapsed(),
15570
16284
  collapsedAfter,
15571
16285
  diffStyle,
15572
16286
  index,
@@ -15586,7 +16300,7 @@ function iterateOverDiff({ diff, diffStyle, startingLine = 0, totalLines = Infin
15586
16300
  }
15587
16301
  }
15588
16302
  }
15589
- getPendingCollapsed();
16303
+ consumePendingCollapsed();
15590
16304
  state.incrementCounts(unifiedCount, splitCount);
15591
16305
  unifiedLineIndex += unifiedCount;
15592
16306
  splitLineIndex += splitCount;
@@ -15599,48 +16313,31 @@ function iterateOverDiff({ diff, diffStyle, startingLine = 0, totalLines = Infin
15599
16313
  if (trailingRegion != null) {
15600
16314
  const { collapsedLines, fromStart, fromEnd } = trailingRegion;
15601
16315
  const len = fromStart + fromEnd;
15602
- const [startIndex, endIndex] = getEqualLineIterationRange(state, len, diffStyle);
15603
- if (startIndex > 0) {
15604
- state.incrementCounts(startIndex, startIndex);
15605
- }
15606
- let index = startIndex;
15607
- while (index < len) {
15608
- if (state.shouldBreak()) {
15609
- break hunkIterator;
15610
- }
15611
- if (index >= endIndex) {
15612
- state.incrementCounts(len - index, len - index);
15613
- break;
15614
- }
15615
- if (state.isInWindow(0, 0)) {
15616
- const isLastLine = index === len - 1;
15617
- if (state.emit({
15618
- hunkIndex: diff.hunks.length,
15619
- hunk: undefined,
15620
- collapsedBefore: 0,
15621
- collapsedAfter: isLastLine ? collapsedLines : 0,
15622
- type: "context-expanded",
15623
- deletionLine: {
15624
- lineNumber: deletionLineNumber + index,
15625
- lineIndex: deletionLineIndex + index,
15626
- noEOFCR: false,
15627
- unifiedLineIndex: unifiedLineIndex + index,
15628
- splitLineIndex: splitLineIndex + index
15629
- },
15630
- additionLine: {
15631
- unifiedLineIndex: unifiedLineIndex + index,
15632
- splitLineIndex: splitLineIndex + index,
15633
- lineIndex: additionLineIndex + index,
15634
- lineNumber: additionLineNumber + index,
15635
- noEOFCR: false
15636
- }
15637
- })) {
15638
- break hunkIterator;
16316
+ if (walkContextLines(state, len, diffStyle, (index) => {
16317
+ const isLastLine = index === len - 1;
16318
+ return state.emit({
16319
+ hunkIndex: diff.hunks.length,
16320
+ hunk: undefined,
16321
+ collapsedBefore: 0,
16322
+ collapsedAfter: isLastLine ? collapsedLines : 0,
16323
+ type: "context-expanded",
16324
+ deletionLine: {
16325
+ lineNumber: deletionLineNumber + index,
16326
+ lineIndex: deletionLineIndex + index,
16327
+ noEOFCR: false,
16328
+ unifiedLineIndex: unifiedLineIndex + index,
16329
+ splitLineIndex: splitLineIndex + index
16330
+ },
16331
+ additionLine: {
16332
+ unifiedLineIndex: unifiedLineIndex + index,
16333
+ splitLineIndex: splitLineIndex + index,
16334
+ lineIndex: additionLineIndex + index,
16335
+ lineNumber: additionLineNumber + index,
16336
+ noEOFCR: false
15639
16337
  }
15640
- } else {
15641
- state.incrementCounts(1, 1);
15642
- }
15643
- index++;
16338
+ });
16339
+ }, undefined, () => state.shouldBreak())) {
16340
+ break hunkIterator;
15644
16341
  }
15645
16342
  }
15646
16343
  }
@@ -15719,15 +16416,14 @@ function getHunkPrefixCounts({ diff, expandedHunks, collapsedContextThreshold })
15719
16416
  const leadingCount = leadingRegion.fromStart + leadingRegion.fromEnd;
15720
16417
  splitCount += leadingCount + hunk.splitLineCount;
15721
16418
  unifiedCount += leadingCount + hunk.unifiedLineCount;
15722
- if (index === finalHunkIndex && hasFinalCollapsedHunk(diff)) {
15723
- const trailingRangeSize = getTrailingRangeSize(diff, hunk);
15724
- const trailingRegion = getExpandedRegion({
15725
- isPartial: diff.isPartial,
15726
- rangeSize: trailingRangeSize,
15727
- expandedHunks,
15728
- hunkIndex: diff.hunks.length,
15729
- collapsedContextThreshold
15730
- });
16419
+ const trailingRegion = index === finalHunkIndex ? getTrailingExpandedRegion({
16420
+ fileDiff: diff,
16421
+ hunkIndex: index,
16422
+ expandedHunks,
16423
+ collapsedContextThreshold,
16424
+ errorPrefix: "iterateOverDiff"
16425
+ }) : undefined;
16426
+ if (trailingRegion != null) {
15731
16427
  const trailingCount = trailingRegion.fromStart + trailingRegion.fromEnd;
15732
16428
  splitCount += trailingCount;
15733
16429
  unifiedCount += trailingCount;
@@ -15739,7 +16435,7 @@ function getHunkPrefixCounts({ diff, expandedHunks, collapsedContextThreshold })
15739
16435
  }
15740
16436
  return prefixCounts;
15741
16437
  }
15742
- function getEqualLineIterationRange(state, count, diffStyle) {
16438
+ function getContextLineIterationBounds(state, count, diffStyle) {
15743
16439
  if (!state.isWindowedHighlight || count <= 0) {
15744
16440
  return [0, count];
15745
16441
  }
@@ -15769,20 +16465,31 @@ function getEqualLineIterationRange(state, count, diffStyle) {
15769
16465
  }
15770
16466
  return [start, end];
15771
16467
  }
15772
- function getTrailingRangeSize(diff, hunk) {
15773
- const additionRemaining = diff.additionLines.length - (hunk.additionLineIndex + hunk.additionCount);
15774
- const deletionRemaining = diff.deletionLines.length - (hunk.deletionLineIndex + hunk.deletionCount);
15775
- if (additionRemaining !== deletionRemaining) {
15776
- throw new Error(`iterateOverDiff: trailing context mismatch (additions=${additionRemaining}, deletions=${deletionRemaining}) for ${diff.name}`);
16468
+ function walkContextLines(state, count, diffStyle, callback, onSkippedStart, shouldBreak) {
16469
+ const [startIndex, endIndex] = getContextLineIterationBounds(state, count, diffStyle);
16470
+ if (startIndex > 0) {
16471
+ state.incrementCounts(startIndex, startIndex);
16472
+ onSkippedStart?.();
15777
16473
  }
15778
- return Math.min(additionRemaining, deletionRemaining);
15779
- }
15780
- function hasFinalCollapsedHunk(diff) {
15781
- const lastHunk = diff.hunks.at(-1);
15782
- if (lastHunk == null || diff.isPartial || diff.additionLines.length === 0 || diff.deletionLines.length === 0) {
15783
- return false;
16474
+ let index = startIndex;
16475
+ while (index < count) {
16476
+ if (shouldBreak?.() === true) {
16477
+ return true;
16478
+ }
16479
+ if (index >= endIndex) {
16480
+ state.incrementCounts(count - index, count - index);
16481
+ break;
16482
+ }
16483
+ if (state.isInWindow(0, 0)) {
16484
+ if (callback(index) === true) {
16485
+ return true;
16486
+ }
16487
+ } else {
16488
+ state.incrementCounts(1, 1);
16489
+ }
16490
+ index++;
15784
16491
  }
15785
- return lastHunk.additionLineIndex + lastHunk.additionCount < diff.additionLines.length || lastHunk.deletionLineIndex + lastHunk.deletionCount < diff.deletionLines.length;
16492
+ return false;
15786
16493
  }
15787
16494
  function getChangeIterationRanges(state, content, diffStyle) {
15788
16495
  if (!state.isWindowedHighlight) {
@@ -16424,7 +17131,7 @@ function getHighlighter(preferredHighlighter = "shiki-js") {
16424
17131
  highlighter ??= createHighlighterCore({
16425
17132
  themes: [],
16426
17133
  langs: [],
16427
- engine: preferredHighlighter === "shiki-wasm" ? createOnigurumaEngine(import("./wasm-D4DU5jgR.js")) : createJavaScriptRegexEngine()
17134
+ engine: preferredHighlighter === "shiki-wasm" ? createOnigurumaEngine(import("./wasm-BaDzIkIn.js")) : createJavaScriptRegexEngine()
16428
17135
  });
16429
17136
  return highlighter;
16430
17137
  }