@nldd/design-system 0.10.0 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (267) hide show
  1. package/custom-elements.json +3084 -784
  2. package/dist/components/actions/button/button.d.ts +10 -0
  3. package/dist/components/actions/button/button.d.ts.map +1 -1
  4. package/dist/components/actions/button/button.js +23 -0
  5. package/dist/components/actions/button/button.js.map +1 -1
  6. package/dist/components/actions/button/button.styles.d.ts.map +1 -1
  7. package/dist/components/actions/button/button.styles.js +22 -0
  8. package/dist/components/actions/button/button.styles.js.map +1 -1
  9. package/dist/components/actions/button/button.template.d.ts +1 -0
  10. package/dist/components/actions/button/button.template.d.ts.map +1 -1
  11. package/dist/components/actions/button/button.template.js +20 -2
  12. package/dist/components/actions/button/button.template.js.map +1 -1
  13. package/dist/components/actions/icon-button/icon-button.d.ts +10 -0
  14. package/dist/components/actions/icon-button/icon-button.d.ts.map +1 -1
  15. package/dist/components/actions/icon-button/icon-button.js +23 -0
  16. package/dist/components/actions/icon-button/icon-button.js.map +1 -1
  17. package/dist/components/actions/icon-button/icon-button.template.d.ts.map +1 -1
  18. package/dist/components/actions/icon-button/icon-button.template.js +10 -3
  19. package/dist/components/actions/icon-button/icon-button.template.js.map +1 -1
  20. package/dist/components/actions/menu/menu.styles.js +1 -1
  21. package/dist/components/actions/split-button/split-button.d.ts +8 -0
  22. package/dist/components/actions/split-button/split-button.d.ts.map +1 -1
  23. package/dist/components/actions/split-button/split-button.js +20 -0
  24. package/dist/components/actions/split-button/split-button.js.map +1 -1
  25. package/dist/components/actions/split-button/split-button.template.d.ts.map +1 -1
  26. package/dist/components/actions/split-button/split-button.template.js +4 -0
  27. package/dist/components/actions/split-button/split-button.template.js.map +1 -1
  28. package/dist/components/components.js +2857 -1993
  29. package/dist/components/content/code-viewer/code-viewer.d.ts +14 -1
  30. package/dist/components/content/code-viewer/code-viewer.d.ts.map +1 -1
  31. package/dist/components/content/code-viewer/code-viewer.diff.d.ts +40 -0
  32. package/dist/components/content/code-viewer/code-viewer.diff.d.ts.map +1 -0
  33. package/dist/components/content/code-viewer/code-viewer.diff.js +261 -0
  34. package/dist/components/content/code-viewer/code-viewer.diff.js.map +1 -0
  35. package/dist/components/content/code-viewer/code-viewer.i18n.d.ts +5 -0
  36. package/dist/components/content/code-viewer/code-viewer.i18n.d.ts.map +1 -1
  37. package/dist/components/content/code-viewer/code-viewer.i18n.js +9 -0
  38. package/dist/components/content/code-viewer/code-viewer.i18n.js.map +1 -1
  39. package/dist/components/content/code-viewer/code-viewer.js +98 -6
  40. package/dist/components/content/code-viewer/code-viewer.js.map +1 -1
  41. package/dist/components/content/code-viewer/code-viewer.styles.d.ts.map +1 -1
  42. package/dist/components/content/code-viewer/code-viewer.styles.js +134 -1
  43. package/dist/components/content/code-viewer/code-viewer.styles.js.map +1 -1
  44. package/dist/components/content/code-viewer/code-viewer.template.d.ts.map +1 -1
  45. package/dist/components/content/code-viewer/code-viewer.template.js +5 -4
  46. package/dist/components/content/code-viewer/code-viewer.template.js.map +1 -1
  47. package/dist/components/content/icon/icon-aliases.d.ts.map +1 -1
  48. package/dist/components/content/icon/icon-aliases.js +13 -4
  49. package/dist/components/content/icon/icon-aliases.js.map +1 -1
  50. package/dist/components/content/icon/icon-gallery-status.d.ts.map +1 -1
  51. package/dist/components/content/icon/icon-gallery-status.js +9 -0
  52. package/dist/components/content/icon/icon-gallery-status.js.map +1 -1
  53. package/dist/components/content/icon/icon-registry.d.ts.map +1 -1
  54. package/dist/components/content/icon/icon-registry.js +9 -2
  55. package/dist/components/content/icon/icon-registry.js.map +1 -1
  56. package/dist/components/content/keyboard-shortcut/keyboard-shortcut.d.ts +3 -3
  57. package/dist/components/content/keyboard-shortcut/keyboard-shortcut.d.ts.map +1 -1
  58. package/dist/components/content/keyboard-shortcut/keyboard-shortcut.js +6 -21
  59. package/dist/components/content/keyboard-shortcut/keyboard-shortcut.js.map +1 -1
  60. package/dist/components/content/keyboard-shortcut/keyboard-shortcut.styles.d.ts.map +1 -1
  61. package/dist/components/content/keyboard-shortcut/keyboard-shortcut.styles.js +3 -0
  62. package/dist/components/content/keyboard-shortcut/keyboard-shortcut.styles.js.map +1 -1
  63. package/dist/components/content/rich-text/rich-text.d.ts +10 -0
  64. package/dist/components/content/rich-text/rich-text.d.ts.map +1 -1
  65. package/dist/components/content/rich-text/rich-text.js +10 -0
  66. package/dist/components/content/rich-text/rich-text.js.map +1 -1
  67. package/dist/components/content/tooltip/tooltip.d.ts +14 -0
  68. package/dist/components/content/tooltip/tooltip.d.ts.map +1 -1
  69. package/dist/components/content/tooltip/tooltip.js +45 -6
  70. package/dist/components/content/tooltip/tooltip.js.map +1 -1
  71. package/dist/components/content/tooltip/tooltip.styles.d.ts.map +1 -1
  72. package/dist/components/content/tooltip/tooltip.styles.js +13 -0
  73. package/dist/components/content/tooltip/tooltip.styles.js.map +1 -1
  74. package/dist/components/content/tooltip/tooltip.template.d.ts.map +1 -1
  75. package/dist/components/content/tooltip/tooltip.template.js +18 -2
  76. package/dist/components/content/tooltip/tooltip.template.js.map +1 -1
  77. package/dist/components/{dist-Bo5Jeyfn.js → dist-B5E3q-ea.js} +2 -1
  78. package/dist/components/{dist-DbNhCpS5.js → dist-BFw_yEMS.js} +2 -1
  79. package/dist/components/{dist-DnZmcpbQ.js → dist-BNLAXAyO.js} +2 -1
  80. package/dist/components/{dist-DkqAbJH8.js → dist-BOVSVPSz.js} +1 -1
  81. package/dist/components/{dist-Ch3gNAuT.js → dist-BPB3rWnd.js} +2 -1
  82. package/dist/components/{dist-Bud_7w5g.js → dist-BWlUmyq3.js} +34 -2869
  83. package/dist/components/dist-CC8oiVtm.js +366 -0
  84. package/dist/components/dist-COKR0tYU.js +2860 -0
  85. package/dist/components/{dist-CaxHkqR2.js → dist-Co-tsc9S.js} +4 -3
  86. package/dist/components/{dist-iC2RTM0V.js → dist-D_9ZyZ5v.js} +3 -2
  87. package/dist/components/{dist-BB5mlo7D.js → dist-Dn9pjiud.js} +3 -2
  88. package/dist/components/{dist-B2QcygzG.js → dist-Dz28se9B.js} +2 -1
  89. package/dist/components/{dist-CA0yDFIt.js → dist-IPm8ilWf.js} +3 -2
  90. package/dist/components/{icon-D_ZGezHx.js → icon-DFhgRf3P.js} +19 -7
  91. package/dist/components/{icon-button-BVhiOwX9.js → icon-button-Sxkh5cVr.js} +526 -61
  92. package/dist/components/inputs/code-editor/code-editor.d.ts +4 -54
  93. package/dist/components/inputs/code-editor/code-editor.d.ts.map +1 -1
  94. package/dist/components/inputs/code-editor/code-editor.js +22 -262
  95. package/dist/components/inputs/code-editor/code-editor.js.map +1 -1
  96. package/dist/components/inputs/code-editor/code-editor.styles.d.ts.map +1 -1
  97. package/dist/components/inputs/code-editor/code-editor.styles.js +9 -1
  98. package/dist/components/inputs/code-editor/code-editor.styles.js.map +1 -1
  99. package/dist/components/inputs/date-picker/date-picker.styles.d.ts.map +1 -1
  100. package/dist/components/inputs/date-picker/date-picker.styles.js +29 -5
  101. package/dist/components/inputs/date-picker/date-picker.styles.js.map +1 -1
  102. package/dist/components/inputs/search-field/search-field.d.ts +11 -0
  103. package/dist/components/inputs/search-field/search-field.d.ts.map +1 -1
  104. package/dist/components/inputs/search-field/search-field.js +30 -1
  105. package/dist/components/inputs/search-field/search-field.js.map +1 -1
  106. package/dist/components/inputs/search-field/search-field.styles.d.ts.map +1 -1
  107. package/dist/components/inputs/search-field/search-field.styles.js +18 -0
  108. package/dist/components/inputs/search-field/search-field.styles.js.map +1 -1
  109. package/dist/components/inputs/search-field/search-field.template.d.ts.map +1 -1
  110. package/dist/components/inputs/search-field/search-field.template.js +12 -0
  111. package/dist/components/inputs/search-field/search-field.template.js.map +1 -1
  112. package/dist/components/inputs/segmented-control/segmented-control.d.ts +10 -0
  113. package/dist/components/inputs/segmented-control/segmented-control.d.ts.map +1 -1
  114. package/dist/components/inputs/segmented-control/segmented-control.js +25 -1
  115. package/dist/components/inputs/segmented-control/segmented-control.js.map +1 -1
  116. package/dist/components/inputs/segmented-control/segmented-control.template.d.ts.map +1 -1
  117. package/dist/components/inputs/segmented-control/segmented-control.template.js +20 -3
  118. package/dist/components/inputs/segmented-control/segmented-control.template.js.map +1 -1
  119. package/dist/components/inputs/text-editor/text-editor.annotation-sentinels.d.ts.map +1 -1
  120. package/dist/components/inputs/text-editor/text-editor.annotation-sentinels.js +9 -7
  121. package/dist/components/inputs/text-editor/text-editor.annotation-sentinels.js.map +1 -1
  122. package/dist/components/inputs/text-editor/text-editor.annotations.js +1 -1
  123. package/dist/components/inputs/text-editor/text-editor.annotations.js.map +1 -1
  124. package/dist/components/inputs/text-editor/text-editor.clipboard.d.ts +16 -0
  125. package/dist/components/inputs/text-editor/text-editor.clipboard.d.ts.map +1 -0
  126. package/dist/components/inputs/text-editor/text-editor.clipboard.js +50 -0
  127. package/dist/components/inputs/text-editor/text-editor.clipboard.js.map +1 -0
  128. package/dist/components/inputs/text-editor/text-editor.commands.d.ts.map +1 -1
  129. package/dist/components/inputs/text-editor/text-editor.commands.js +31 -58
  130. package/dist/components/inputs/text-editor/text-editor.commands.js.map +1 -1
  131. package/dist/components/inputs/text-editor/text-editor.d.ts +17 -64
  132. package/dist/components/inputs/text-editor/text-editor.d.ts.map +1 -1
  133. package/dist/components/inputs/text-editor/text-editor.drag.d.ts.map +1 -1
  134. package/dist/components/inputs/text-editor/text-editor.drag.js +2 -1
  135. package/dist/components/inputs/text-editor/text-editor.drag.js.map +1 -1
  136. package/dist/components/inputs/text-editor/text-editor.focus-selection.d.ts +3 -0
  137. package/dist/components/inputs/text-editor/text-editor.focus-selection.d.ts.map +1 -0
  138. package/dist/components/inputs/text-editor/text-editor.focus-selection.js +55 -0
  139. package/dist/components/inputs/text-editor/text-editor.focus-selection.js.map +1 -0
  140. package/dist/components/inputs/text-editor/text-editor.hidden-syntax.d.ts +6 -0
  141. package/dist/components/inputs/text-editor/text-editor.hidden-syntax.d.ts.map +1 -0
  142. package/dist/components/inputs/text-editor/text-editor.hidden-syntax.js +257 -0
  143. package/dist/components/inputs/text-editor/text-editor.hidden-syntax.js.map +1 -0
  144. package/dist/components/inputs/text-editor/text-editor.js +93 -313
  145. package/dist/components/inputs/text-editor/text-editor.js.map +1 -1
  146. package/dist/components/inputs/text-editor/text-editor.keymap.d.ts +6 -0
  147. package/dist/components/inputs/text-editor/text-editor.keymap.d.ts.map +1 -0
  148. package/dist/components/inputs/text-editor/text-editor.keymap.js +38 -0
  149. package/dist/components/inputs/text-editor/text-editor.keymap.js.map +1 -0
  150. package/dist/components/inputs/text-editor/text-editor.links.d.ts.map +1 -1
  151. package/dist/components/inputs/text-editor/text-editor.links.js +11 -9
  152. package/dist/components/inputs/text-editor/text-editor.links.js.map +1 -1
  153. package/dist/components/inputs/text-editor/text-editor.markdown.d.ts +1 -17
  154. package/dist/components/inputs/text-editor/text-editor.markdown.d.ts.map +1 -1
  155. package/dist/components/inputs/text-editor/text-editor.markdown.js +26 -186
  156. package/dist/components/inputs/text-editor/text-editor.markdown.js.map +1 -1
  157. package/dist/components/inputs/text-editor/text-editor.mention.d.ts +52 -0
  158. package/dist/components/inputs/text-editor/text-editor.mention.d.ts.map +1 -0
  159. package/dist/components/inputs/text-editor/text-editor.mention.js +186 -0
  160. package/dist/components/inputs/text-editor/text-editor.mention.js.map +1 -0
  161. package/dist/components/inputs/text-editor/text-editor.mentions.d.ts +0 -16
  162. package/dist/components/inputs/text-editor/text-editor.mentions.d.ts.map +1 -1
  163. package/dist/components/inputs/text-editor/text-editor.mentions.js +1 -41
  164. package/dist/components/inputs/text-editor/text-editor.mentions.js.map +1 -1
  165. package/dist/components/inputs/text-editor/text-editor.selection.d.ts +13 -0
  166. package/dist/components/inputs/text-editor/text-editor.selection.d.ts.map +1 -0
  167. package/dist/components/inputs/text-editor/text-editor.selection.js +62 -0
  168. package/dist/components/inputs/text-editor/text-editor.selection.js.map +1 -0
  169. package/dist/components/inputs/text-editor/text-editor.spellcheck.d.ts.map +1 -1
  170. package/dist/components/inputs/text-editor/text-editor.spellcheck.js +4 -6
  171. package/dist/components/inputs/text-editor/text-editor.spellcheck.js.map +1 -1
  172. package/dist/components/inputs/text-editor/text-editor.styles.d.ts.map +1 -1
  173. package/dist/components/inputs/text-editor/text-editor.styles.js +185 -64
  174. package/dist/components/inputs/text-editor/text-editor.styles.js.map +1 -1
  175. package/dist/components/inputs/text-editor/text-editor.syntax.d.ts +22 -0
  176. package/dist/components/inputs/text-editor/text-editor.syntax.d.ts.map +1 -1
  177. package/dist/components/inputs/text-editor/text-editor.syntax.js +44 -0
  178. package/dist/components/inputs/text-editor/text-editor.syntax.js.map +1 -1
  179. package/dist/components/inputs/toggle-button/toggle-button.d.ts +10 -0
  180. package/dist/components/inputs/toggle-button/toggle-button.d.ts.map +1 -1
  181. package/dist/components/inputs/toggle-button/toggle-button.js +25 -1
  182. package/dist/components/inputs/toggle-button/toggle-button.js.map +1 -1
  183. package/dist/components/inputs/toggle-button/toggle-button.template.d.ts.map +1 -1
  184. package/dist/components/inputs/toggle-button/toggle-button.template.js +21 -7
  185. package/dist/components/inputs/toggle-button/toggle-button.template.js.map +1 -1
  186. package/dist/components/layout/card/card.styles.js +4 -4
  187. package/dist/components/layout/container/container.d.ts +2 -0
  188. package/dist/components/layout/container/container.d.ts.map +1 -1
  189. package/dist/components/layout/container/container.js +9 -0
  190. package/dist/components/layout/container/container.js.map +1 -1
  191. package/dist/components/layout/container/container.styles.d.ts.map +1 -1
  192. package/dist/components/layout/container/container.styles.js +13 -0
  193. package/dist/components/layout/container/container.styles.js.map +1 -1
  194. package/dist/components/lists-and-tables/cells/step-cell/step-cell.styles.d.ts.map +1 -1
  195. package/dist/components/lists-and-tables/cells/step-cell/step-cell.styles.js +9 -5
  196. package/dist/components/lists-and-tables/cells/step-cell/step-cell.styles.js.map +1 -1
  197. package/dist/components/navigation/document-tab-bar/document-tab-bar.styles.d.ts.map +1 -1
  198. package/dist/components/navigation/document-tab-bar/document-tab-bar.styles.js +16 -15
  199. package/dist/components/navigation/document-tab-bar/document-tab-bar.styles.js.map +1 -1
  200. package/dist/components/navigation/menu-bar-item/menu-bar-item.styles.js +2 -2
  201. package/dist/components/navigation/tab-bar/tab-bar.styles.js +9 -9
  202. package/dist/components/status-and-feedback/activity-indicator/activity-indicator.d.ts +16 -9
  203. package/dist/components/status-and-feedback/activity-indicator/activity-indicator.d.ts.map +1 -1
  204. package/dist/components/status-and-feedback/activity-indicator/activity-indicator.js +16 -9
  205. package/dist/components/status-and-feedback/activity-indicator/activity-indicator.js.map +1 -1
  206. package/dist/components/status-and-feedback/activity-indicator/activity-indicator.styles.d.ts.map +1 -1
  207. package/dist/components/status-and-feedback/activity-indicator/activity-indicator.styles.js +23 -18
  208. package/dist/components/status-and-feedback/activity-indicator/activity-indicator.styles.js.map +1 -1
  209. package/dist/components/status-and-feedback/activity-indicator/activity-indicator.template.d.ts.map +1 -1
  210. package/dist/components/status-and-feedback/activity-indicator/activity-indicator.template.js +19 -21
  211. package/dist/components/status-and-feedback/activity-indicator/activity-indicator.template.js.map +1 -1
  212. package/dist/components/status-and-feedback/inline-dialog/inline-dialog.styles.js +1 -1
  213. package/dist/components/status-and-feedback/notification/notification.d.ts +2 -1
  214. package/dist/components/status-and-feedback/notification/notification.d.ts.map +1 -1
  215. package/dist/components/status-and-feedback/notification/notification.js +5 -2
  216. package/dist/components/status-and-feedback/notification/notification.js.map +1 -1
  217. package/dist/components/status-and-feedback/notification/notification.styles.d.ts.map +1 -1
  218. package/dist/components/status-and-feedback/notification/notification.styles.js +19 -1
  219. package/dist/components/status-and-feedback/notification/notification.styles.js.map +1 -1
  220. package/dist/components/status-and-feedback/notification/notifications-area.d.ts.map +1 -1
  221. package/dist/components/status-and-feedback/notification/notifications-area.js +14 -0
  222. package/dist/components/status-and-feedback/notification/notifications-area.js.map +1 -1
  223. package/dist/components/status-and-feedback/progress-bar/progress-bar.styles.js +4 -4
  224. package/dist/components/status-and-feedback/progress-circle/progress-circle.styles.js +3 -3
  225. package/dist/components/status-and-feedback/progress-circle/progress-circle.template.js +1 -1
  226. package/dist/components/status-and-feedback/progress-circle/progress-circle.template.js.map +1 -1
  227. package/dist/components/status-and-feedback/step-bar/step-bar.styles.d.ts.map +1 -1
  228. package/dist/components/status-and-feedback/step-bar/step-bar.styles.js +7 -5
  229. package/dist/components/status-and-feedback/step-bar/step-bar.styles.js.map +1 -1
  230. package/dist/css/rich-text.css +61 -1
  231. package/dist/css/themes/bruin.css +108 -64
  232. package/dist/css/themes/donkerblauw.css +108 -64
  233. package/dist/css/themes/donkerbruin.css +88 -64
  234. package/dist/css/themes/donkergeel.css +149 -94
  235. package/dist/css/themes/donkergroen.css +93 -64
  236. package/dist/css/themes/geel.css +149 -94
  237. package/dist/css/themes/groen.css +108 -64
  238. package/dist/css/themes/hemelblauw.css +108 -64
  239. package/dist/css/themes/lichtblauw.css +111 -64
  240. package/dist/css/themes/mintgroen.css +111 -64
  241. package/dist/css/themes/mosgroen.css +108 -64
  242. package/dist/css/themes/oranje.css +162 -99
  243. package/dist/css/themes/paars.css +115 -64
  244. package/dist/css/themes/robijnrood.css +159 -96
  245. package/dist/css/themes/rood.css +159 -96
  246. package/dist/css/themes/roze.css +118 -64
  247. package/dist/css/themes/violet.css +93 -64
  248. package/dist/css/themes.css +2047 -1247
  249. package/dist/css/variables.css +142 -70
  250. package/dist/nldd.min.js +1468 -998
  251. package/dist/translations/en-US.d.ts.map +1 -1
  252. package/dist/translations/en-US.js +5 -0
  253. package/dist/translations/en-US.js.map +1 -1
  254. package/dist/translations/nl.generated.d.ts +5 -0
  255. package/dist/translations/nl.generated.d.ts.map +1 -1
  256. package/dist/types/vue.d.ts +138 -32
  257. package/dist/utilities/codemirror/codemirror-input.d.ts +90 -0
  258. package/dist/utilities/codemirror/codemirror-input.d.ts.map +1 -0
  259. package/dist/utilities/codemirror/codemirror-input.js +250 -0
  260. package/dist/utilities/codemirror/codemirror-input.js.map +1 -0
  261. package/dist/utilities/codemirror/theme.js +1 -1
  262. package/dist/utilities/codemirror/theme.js.map +1 -1
  263. package/dist/utilities/shortcut.d.ts +50 -0
  264. package/dist/utilities/shortcut.d.ts.map +1 -0
  265. package/dist/utilities/shortcut.js +77 -0
  266. package/dist/utilities/shortcut.js.map +1 -0
  267. package/package.json +2 -1
@@ -0,0 +1,2860 @@
1
+ //#region node_modules/style-mod/src/style-mod.js
2
+ var C = "ͼ";
3
+ var COUNT = typeof Symbol == "undefined" ? "__ͼ" : Symbol.for(C);
4
+ var SET = typeof Symbol == "undefined" ? "__styleSet" + Math.floor(Math.random() * 1e8) : Symbol("styleSet");
5
+ var top = typeof globalThis != "undefined" ? globalThis : typeof window != "undefined" ? window : {};
6
+ var StyleModule = class {
7
+ constructor(spec, options) {
8
+ this.rules = [];
9
+ let { finish } = options || {};
10
+ function splitSelector(selector) {
11
+ return /^@/.test(selector) ? [selector] : selector.split(/,\s*/);
12
+ }
13
+ function render(selectors, spec, target, isKeyframes) {
14
+ let local = [], isAt = /^@(\w+)\b/.exec(selectors[0]), keyframes = isAt && isAt[1] == "keyframes";
15
+ if (isAt && spec == null) return target.push(selectors[0] + ";");
16
+ for (let prop in spec) {
17
+ let value = spec[prop];
18
+ if (/&/.test(prop)) render(prop.split(/,\s*/).map((part) => selectors.map((sel) => part.replace(/&/, sel))).reduce((a, b) => a.concat(b)), value, target);
19
+ else if (value && typeof value == "object") {
20
+ if (!isAt) throw new RangeError("The value of a property (" + prop + ") should be a primitive value.");
21
+ render(splitSelector(prop), value, local, keyframes);
22
+ } else if (value != null) local.push(prop.replace(/_.*/, "").replace(/[A-Z]/g, (l) => "-" + l.toLowerCase()) + ": " + value + ";");
23
+ }
24
+ if (local.length || keyframes) target.push((finish && !isAt && !isKeyframes ? selectors.map(finish) : selectors).join(", ") + " {" + local.join(" ") + "}");
25
+ }
26
+ for (let prop in spec) render(splitSelector(prop), spec[prop], this.rules);
27
+ }
28
+ getRules() {
29
+ return this.rules.join("\n");
30
+ }
31
+ static newName() {
32
+ let id = top[COUNT] || 1;
33
+ top[COUNT] = id + 1;
34
+ return C + id.toString(36);
35
+ }
36
+ static mount(root, modules, options) {
37
+ let set = root[SET], nonce = options && options.nonce;
38
+ if (!set) set = new StyleSet(root, nonce);
39
+ else if (nonce) set.setNonce(nonce);
40
+ set.mount(Array.isArray(modules) ? modules : [modules], root);
41
+ }
42
+ };
43
+ var adoptedSet = /* @__PURE__ */ new Map();
44
+ var StyleSet = class {
45
+ constructor(root, nonce) {
46
+ let doc = root.ownerDocument || root, win = doc.defaultView;
47
+ if (!root.head && root.adoptedStyleSheets && win.CSSStyleSheet) {
48
+ let adopted = adoptedSet.get(doc);
49
+ if (adopted) return root[SET] = adopted;
50
+ this.sheet = new win.CSSStyleSheet();
51
+ adoptedSet.set(doc, this);
52
+ } else {
53
+ this.styleTag = doc.createElement("style");
54
+ if (nonce) this.styleTag.setAttribute("nonce", nonce);
55
+ }
56
+ this.modules = [];
57
+ root[SET] = this;
58
+ }
59
+ mount(modules, root) {
60
+ let sheet = this.sheet;
61
+ let pos = 0, j = 0;
62
+ for (let i = 0; i < modules.length; i++) {
63
+ let mod = modules[i], index = this.modules.indexOf(mod);
64
+ if (index < j && index > -1) {
65
+ this.modules.splice(index, 1);
66
+ j--;
67
+ index = -1;
68
+ }
69
+ if (index == -1) {
70
+ this.modules.splice(j++, 0, mod);
71
+ if (sheet) for (let k = 0; k < mod.rules.length; k++) sheet.insertRule(mod.rules[k], pos++);
72
+ } else {
73
+ while (j < index) pos += this.modules[j++].rules.length;
74
+ pos += mod.rules.length;
75
+ j++;
76
+ }
77
+ }
78
+ if (sheet) {
79
+ if (root.adoptedStyleSheets.indexOf(this.sheet) < 0) root.adoptedStyleSheets = [this.sheet, ...root.adoptedStyleSheets];
80
+ } else {
81
+ let text = "";
82
+ for (let i = 0; i < this.modules.length; i++) text += this.modules[i].getRules() + "\n";
83
+ this.styleTag.textContent = text;
84
+ let target = root.head || root;
85
+ if (this.styleTag.parentNode != target) target.insertBefore(this.styleTag, target.firstChild);
86
+ }
87
+ }
88
+ setNonce(nonce) {
89
+ if (this.styleTag && this.styleTag.getAttribute("nonce") != nonce) this.styleTag.setAttribute("nonce", nonce);
90
+ }
91
+ };
92
+ //#endregion
93
+ //#region node_modules/@lezer/common/dist/index.js
94
+ /**
95
+ The default maximum length of a `TreeBuffer` node.
96
+ */
97
+ var DefaultBufferLength = 1024;
98
+ var nextPropID = 0;
99
+ var Range = class {
100
+ constructor(from, to) {
101
+ this.from = from;
102
+ this.to = to;
103
+ }
104
+ };
105
+ /**
106
+ Each [node type](#common.NodeType) or [individual tree](#common.Tree)
107
+ can have metadata associated with it in props. Instances of this
108
+ class represent prop names.
109
+ */
110
+ var NodeProp = class {
111
+ /**
112
+ Create a new node prop type.
113
+ */
114
+ constructor(config = {}) {
115
+ this.id = nextPropID++;
116
+ this.perNode = !!config.perNode;
117
+ this.deserialize = config.deserialize || (() => {
118
+ throw new Error("This node type doesn't define a deserialize function");
119
+ });
120
+ this.combine = config.combine || null;
121
+ }
122
+ /**
123
+ This is meant to be used with
124
+ [`NodeSet.extend`](#common.NodeSet.extend) or
125
+ [`LRParser.configure`](#lr.ParserConfig.props) to compute
126
+ prop values for each node type in the set. Takes a [match
127
+ object](#common.NodeType^match) or function that returns undefined
128
+ if the node type doesn't get this prop, and the prop's value if
129
+ it does.
130
+ */
131
+ add(match) {
132
+ if (this.perNode) throw new RangeError("Can't add per-node props to node types");
133
+ if (typeof match != "function") match = NodeType.match(match);
134
+ return (type) => {
135
+ let result = match(type);
136
+ return result === void 0 ? null : [this, result];
137
+ };
138
+ }
139
+ };
140
+ /**
141
+ Prop that is used to describe matching delimiters. For opening
142
+ delimiters, this holds an array of node names (written as a
143
+ space-separated string when declaring this prop in a grammar)
144
+ for the node types of closing delimiters that match it.
145
+ */
146
+ NodeProp.closedBy = new NodeProp({ deserialize: (str) => str.split(" ") });
147
+ /**
148
+ The inverse of [`closedBy`](#common.NodeProp^closedBy). This is
149
+ attached to closing delimiters, holding an array of node names
150
+ of types of matching opening delimiters.
151
+ */
152
+ NodeProp.openedBy = new NodeProp({ deserialize: (str) => str.split(" ") });
153
+ /**
154
+ Used to assign node types to groups (for example, all node
155
+ types that represent an expression could be tagged with an
156
+ `"Expression"` group).
157
+ */
158
+ NodeProp.group = new NodeProp({ deserialize: (str) => str.split(" ") });
159
+ /**
160
+ Attached to nodes to indicate these should be
161
+ [displayed](https://codemirror.net/docs/ref/#language.syntaxTree)
162
+ in a bidirectional text isolate, so that direction-neutral
163
+ characters on their sides don't incorrectly get associated with
164
+ surrounding text. You'll generally want to set this for nodes
165
+ that contain arbitrary text, like strings and comments, and for
166
+ nodes that appear _inside_ arbitrary text, like HTML tags. When
167
+ not given a value, in a grammar declaration, defaults to
168
+ `"auto"`.
169
+ */
170
+ NodeProp.isolate = new NodeProp({ deserialize: (value) => {
171
+ if (value && value != "rtl" && value != "ltr" && value != "auto") throw new RangeError("Invalid value for isolate: " + value);
172
+ return value || "auto";
173
+ } });
174
+ /**
175
+ The hash of the [context](#lr.ContextTracker.constructor)
176
+ that the node was parsed in, if any. Used to limit reuse of
177
+ contextual nodes.
178
+ */
179
+ NodeProp.contextHash = new NodeProp({ perNode: true });
180
+ /**
181
+ The distance beyond the end of the node that the tokenizer
182
+ looked ahead for any of the tokens inside the node. (The LR
183
+ parser only stores this when it is larger than 25, for
184
+ efficiency reasons.)
185
+ */
186
+ NodeProp.lookAhead = new NodeProp({ perNode: true });
187
+ /**
188
+ This per-node prop is used to replace a given node, or part of a
189
+ node, with another tree. This is useful to include trees from
190
+ different languages in mixed-language parsers.
191
+ */
192
+ NodeProp.mounted = new NodeProp({ perNode: true });
193
+ /**
194
+ A mounted tree, which can be [stored](#common.NodeProp^mounted) on
195
+ a tree node to indicate that parts of its content are
196
+ represented by another tree.
197
+ */
198
+ var MountedTree = class {
199
+ constructor(tree, overlay, parser, bracketed = false) {
200
+ this.tree = tree;
201
+ this.overlay = overlay;
202
+ this.parser = parser;
203
+ this.bracketed = bracketed;
204
+ }
205
+ /**
206
+ @internal
207
+ */
208
+ static get(tree) {
209
+ return tree && tree.props && tree.props[NodeProp.mounted.id];
210
+ }
211
+ };
212
+ var noProps = Object.create(null);
213
+ /**
214
+ Each node in a syntax tree has a node type associated with it.
215
+ */
216
+ var NodeType = class NodeType {
217
+ /**
218
+ @internal
219
+ */
220
+ constructor(name, props, id, flags = 0) {
221
+ this.name = name;
222
+ this.props = props;
223
+ this.id = id;
224
+ this.flags = flags;
225
+ }
226
+ /**
227
+ Define a node type.
228
+ */
229
+ static define(spec) {
230
+ let props = spec.props && spec.props.length ? Object.create(null) : noProps;
231
+ let flags = (spec.top ? 1 : 0) | (spec.skipped ? 2 : 0) | (spec.error ? 4 : 0) | (spec.name == null ? 8 : 0);
232
+ let type = new NodeType(spec.name || "", props, spec.id, flags);
233
+ if (spec.props) for (let src of spec.props) {
234
+ if (!Array.isArray(src)) src = src(type);
235
+ if (src) {
236
+ if (src[0].perNode) throw new RangeError("Can't store a per-node prop on a node type");
237
+ props[src[0].id] = src[1];
238
+ }
239
+ }
240
+ return type;
241
+ }
242
+ /**
243
+ Retrieves a node prop for this type. Will return `undefined` if
244
+ the prop isn't present on this node.
245
+ */
246
+ prop(prop) {
247
+ return this.props[prop.id];
248
+ }
249
+ /**
250
+ True when this is the top node of a grammar.
251
+ */
252
+ get isTop() {
253
+ return (this.flags & 1) > 0;
254
+ }
255
+ /**
256
+ True when this node is produced by a skip rule.
257
+ */
258
+ get isSkipped() {
259
+ return (this.flags & 2) > 0;
260
+ }
261
+ /**
262
+ Indicates whether this is an error node.
263
+ */
264
+ get isError() {
265
+ return (this.flags & 4) > 0;
266
+ }
267
+ /**
268
+ When true, this node type doesn't correspond to a user-declared
269
+ named node, for example because it is used to cache repetition.
270
+ */
271
+ get isAnonymous() {
272
+ return (this.flags & 8) > 0;
273
+ }
274
+ /**
275
+ Returns true when this node's name or one of its
276
+ [groups](#common.NodeProp^group) matches the given string.
277
+ */
278
+ is(name) {
279
+ if (typeof name == "string") {
280
+ if (this.name == name) return true;
281
+ let group = this.prop(NodeProp.group);
282
+ return group ? group.indexOf(name) > -1 : false;
283
+ }
284
+ return this.id == name;
285
+ }
286
+ /**
287
+ Create a function from node types to arbitrary values by
288
+ specifying an object whose property names are node or
289
+ [group](#common.NodeProp^group) names. Often useful with
290
+ [`NodeProp.add`](#common.NodeProp.add). You can put multiple
291
+ names, separated by spaces, in a single property name to map
292
+ multiple node names to a single value.
293
+ */
294
+ static match(map) {
295
+ let direct = Object.create(null);
296
+ for (let prop in map) for (let name of prop.split(" ")) direct[name] = map[prop];
297
+ return (node) => {
298
+ for (let groups = node.prop(NodeProp.group), i = -1; i < (groups ? groups.length : 0); i++) {
299
+ let found = direct[i < 0 ? node.name : groups[i]];
300
+ if (found) return found;
301
+ }
302
+ };
303
+ }
304
+ };
305
+ /**
306
+ An empty dummy node type to use when no actual type is available.
307
+ */
308
+ NodeType.none = new NodeType("", Object.create(null), 0, 8);
309
+ /**
310
+ A node set holds a collection of node types. It is used to
311
+ compactly represent trees by storing their type ids, rather than a
312
+ full pointer to the type object, in a numeric array. Each parser
313
+ [has](#lr.LRParser.nodeSet) a node set, and [tree
314
+ buffers](#common.TreeBuffer) can only store collections of nodes
315
+ from the same set. A set can have a maximum of 2**16 (65536) node
316
+ types in it, so that the ids fit into 16-bit typed array slots.
317
+ */
318
+ var NodeSet = class NodeSet {
319
+ /**
320
+ Create a set with the given types. The `id` property of each
321
+ type should correspond to its position within the array.
322
+ */
323
+ constructor(types) {
324
+ this.types = types;
325
+ for (let i = 0; i < types.length; i++) if (types[i].id != i) throw new RangeError("Node type ids should correspond to array positions when creating a node set");
326
+ }
327
+ /**
328
+ Create a copy of this set with some node properties added. The
329
+ arguments to this method can be created with
330
+ [`NodeProp.add`](#common.NodeProp.add).
331
+ */
332
+ extend(...props) {
333
+ let newTypes = [];
334
+ for (let type of this.types) {
335
+ let newProps = null;
336
+ for (let source of props) {
337
+ let add = source(type);
338
+ if (add) {
339
+ if (!newProps) newProps = Object.assign({}, type.props);
340
+ let value = add[1], prop = add[0];
341
+ if (prop.combine && prop.id in newProps) value = prop.combine(newProps[prop.id], value);
342
+ newProps[prop.id] = value;
343
+ }
344
+ }
345
+ newTypes.push(newProps ? new NodeType(type.name, newProps, type.id, type.flags) : type);
346
+ }
347
+ return new NodeSet(newTypes);
348
+ }
349
+ };
350
+ var CachedNode = /* @__PURE__ */ new WeakMap();
351
+ var CachedInnerNode = /* @__PURE__ */ new WeakMap();
352
+ /**
353
+ Options that control iteration. Can be combined with the `|`
354
+ operator to enable multiple ones.
355
+ */
356
+ var IterMode;
357
+ (function(IterMode) {
358
+ /**
359
+ When enabled, iteration will only visit [`Tree`](#common.Tree)
360
+ objects, not nodes packed into
361
+ [`TreeBuffer`](#common.TreeBuffer)s.
362
+ */
363
+ IterMode[IterMode["ExcludeBuffers"] = 1] = "ExcludeBuffers";
364
+ /**
365
+ Enable this to make iteration include anonymous nodes (such as
366
+ the nodes that wrap repeated grammar constructs into a balanced
367
+ tree).
368
+ */
369
+ IterMode[IterMode["IncludeAnonymous"] = 2] = "IncludeAnonymous";
370
+ /**
371
+ By default, regular [mounted](#common.NodeProp^mounted) nodes
372
+ replace their base node in iteration. Enable this to ignore them
373
+ instead.
374
+ */
375
+ IterMode[IterMode["IgnoreMounts"] = 4] = "IgnoreMounts";
376
+ /**
377
+ This option only applies in
378
+ [`enter`](#common.SyntaxNode.enter)-style methods. It tells the
379
+ library to not enter mounted overlays if one covers the given
380
+ position.
381
+ */
382
+ IterMode[IterMode["IgnoreOverlays"] = 8] = "IgnoreOverlays";
383
+ /**
384
+ When set, positions on the boundary of a mounted overlay tree
385
+ that has its [`bracketed`](#common.NestedParse.bracketed) flag
386
+ set will enter that tree regardless of side. Only supported in
387
+ [`enter`](#common.SyntaxNode.enter), not in cursors.
388
+ */
389
+ IterMode[IterMode["EnterBracketed"] = 16] = "EnterBracketed";
390
+ })(IterMode || (IterMode = {}));
391
+ /**
392
+ A piece of syntax tree. There are two ways to approach these
393
+ trees: the way they are actually stored in memory, and the
394
+ convenient way.
395
+
396
+ Syntax trees are stored as a tree of `Tree` and `TreeBuffer`
397
+ objects. By packing detail information into `TreeBuffer` leaf
398
+ nodes, the representation is made a lot more memory-efficient.
399
+
400
+ However, when you want to actually work with tree nodes, this
401
+ representation is very awkward, so most client code will want to
402
+ use the [`TreeCursor`](#common.TreeCursor) or
403
+ [`SyntaxNode`](#common.SyntaxNode) interface instead, which provides
404
+ a view on some part of this data structure, and can be used to
405
+ move around to adjacent nodes.
406
+ */
407
+ var Tree = class Tree {
408
+ /**
409
+ Construct a new tree. See also [`Tree.build`](#common.Tree^build).
410
+ */
411
+ constructor(type, children, positions, length, props) {
412
+ this.type = type;
413
+ this.children = children;
414
+ this.positions = positions;
415
+ this.length = length;
416
+ /**
417
+ @internal
418
+ */
419
+ this.props = null;
420
+ if (props && props.length) {
421
+ this.props = Object.create(null);
422
+ for (let [prop, value] of props) this.props[typeof prop == "number" ? prop : prop.id] = value;
423
+ }
424
+ }
425
+ /**
426
+ @internal
427
+ */
428
+ toString() {
429
+ let mounted = MountedTree.get(this);
430
+ if (mounted && !mounted.overlay) return mounted.tree.toString();
431
+ let children = "";
432
+ for (let ch of this.children) {
433
+ let str = ch.toString();
434
+ if (str) {
435
+ if (children) children += ",";
436
+ children += str;
437
+ }
438
+ }
439
+ return !this.type.name ? children : (/\W/.test(this.type.name) && !this.type.isError ? JSON.stringify(this.type.name) : this.type.name) + (children.length ? "(" + children + ")" : "");
440
+ }
441
+ /**
442
+ Get a [tree cursor](#common.TreeCursor) positioned at the top of
443
+ the tree. Mode can be used to [control](#common.IterMode) which
444
+ nodes the cursor visits.
445
+ */
446
+ cursor(mode = 0) {
447
+ return new TreeCursor(this.topNode, mode);
448
+ }
449
+ /**
450
+ Get a [tree cursor](#common.TreeCursor) pointing into this tree
451
+ at the given position and side (see
452
+ [`moveTo`](#common.TreeCursor.moveTo).
453
+ */
454
+ cursorAt(pos, side = 0, mode = 0) {
455
+ let cursor = new TreeCursor(CachedNode.get(this) || this.topNode);
456
+ cursor.moveTo(pos, side);
457
+ CachedNode.set(this, cursor._tree);
458
+ return cursor;
459
+ }
460
+ /**
461
+ Get a [syntax node](#common.SyntaxNode) object for the top of the
462
+ tree.
463
+ */
464
+ get topNode() {
465
+ return new TreeNode(this, 0, 0, null);
466
+ }
467
+ /**
468
+ Get the [syntax node](#common.SyntaxNode) at the given position.
469
+ If `side` is -1, this will move into nodes that end at the
470
+ position. If 1, it'll move into nodes that start at the
471
+ position. With 0, it'll only enter nodes that cover the position
472
+ from both sides.
473
+
474
+ Note that this will not enter
475
+ [overlays](#common.MountedTree.overlay), and you often want
476
+ [`resolveInner`](#common.Tree.resolveInner) instead.
477
+ */
478
+ resolve(pos, side = 0) {
479
+ let node = resolveNode(CachedNode.get(this) || this.topNode, pos, side, false);
480
+ CachedNode.set(this, node);
481
+ return node;
482
+ }
483
+ /**
484
+ Like [`resolve`](#common.Tree.resolve), but will enter
485
+ [overlaid](#common.MountedTree.overlay) nodes, producing a syntax node
486
+ pointing into the innermost overlaid tree at the given position
487
+ (with parent links going through all parent structure, including
488
+ the host trees).
489
+ */
490
+ resolveInner(pos, side = 0) {
491
+ let node = resolveNode(CachedInnerNode.get(this) || this.topNode, pos, side, true);
492
+ CachedInnerNode.set(this, node);
493
+ return node;
494
+ }
495
+ /**
496
+ In some situations, it can be useful to iterate through all
497
+ nodes around a position, including those in overlays that don't
498
+ directly cover the position. This method gives you an iterator
499
+ that will produce all nodes, from small to big, around the given
500
+ position.
501
+ */
502
+ resolveStack(pos, side = 0) {
503
+ return stackIterator(this, pos, side);
504
+ }
505
+ /**
506
+ Iterate over the tree and its children, calling `enter` for any
507
+ node that touches the `from`/`to` region (if given) before
508
+ running over such a node's children, and `leave` (if given) when
509
+ leaving the node. When `enter` returns `false`, that node will
510
+ not have its children iterated over (or `leave` called).
511
+ */
512
+ iterate(spec) {
513
+ let { enter, leave, from = 0, to = this.length } = spec;
514
+ let mode = spec.mode || 0, anon = (mode & IterMode.IncludeAnonymous) > 0;
515
+ for (let c = this.cursor(mode | IterMode.IncludeAnonymous);;) {
516
+ let entered = false;
517
+ if (c.from <= to && c.to >= from && (!anon && c.type.isAnonymous || enter(c) !== false)) {
518
+ if (c.firstChild()) continue;
519
+ entered = true;
520
+ }
521
+ for (;;) {
522
+ if (entered && leave && (anon || !c.type.isAnonymous)) leave(c);
523
+ if (c.nextSibling()) break;
524
+ if (!c.parent()) return;
525
+ entered = true;
526
+ }
527
+ }
528
+ }
529
+ /**
530
+ Get the value of the given [node prop](#common.NodeProp) for this
531
+ node. Works with both per-node and per-type props.
532
+ */
533
+ prop(prop) {
534
+ return !prop.perNode ? this.type.prop(prop) : this.props ? this.props[prop.id] : void 0;
535
+ }
536
+ /**
537
+ Returns the node's [per-node props](#common.NodeProp.perNode) in a
538
+ format that can be passed to the [`Tree`](#common.Tree)
539
+ constructor.
540
+ */
541
+ get propValues() {
542
+ let result = [];
543
+ if (this.props) for (let id in this.props) result.push([+id, this.props[id]]);
544
+ return result;
545
+ }
546
+ /**
547
+ Balance the direct children of this tree, producing a copy of
548
+ which may have children grouped into subtrees with type
549
+ [`NodeType.none`](#common.NodeType^none).
550
+ */
551
+ balance(config = {}) {
552
+ return this.children.length <= 8 ? this : balanceRange(NodeType.none, this.children, this.positions, 0, this.children.length, 0, this.length, (children, positions, length) => new Tree(this.type, children, positions, length, this.propValues), config.makeTree || ((children, positions, length) => new Tree(NodeType.none, children, positions, length)));
553
+ }
554
+ /**
555
+ Build a tree from a postfix-ordered buffer of node information,
556
+ or a cursor over such a buffer.
557
+ */
558
+ static build(data) {
559
+ return buildTree(data);
560
+ }
561
+ };
562
+ /**
563
+ The empty tree
564
+ */
565
+ Tree.empty = new Tree(NodeType.none, [], [], 0);
566
+ var FlatBufferCursor = class FlatBufferCursor {
567
+ constructor(buffer, index) {
568
+ this.buffer = buffer;
569
+ this.index = index;
570
+ }
571
+ get id() {
572
+ return this.buffer[this.index - 4];
573
+ }
574
+ get start() {
575
+ return this.buffer[this.index - 3];
576
+ }
577
+ get end() {
578
+ return this.buffer[this.index - 2];
579
+ }
580
+ get size() {
581
+ return this.buffer[this.index - 1];
582
+ }
583
+ get pos() {
584
+ return this.index;
585
+ }
586
+ next() {
587
+ this.index -= 4;
588
+ }
589
+ fork() {
590
+ return new FlatBufferCursor(this.buffer, this.index);
591
+ }
592
+ };
593
+ /**
594
+ Tree buffers contain (type, start, end, endIndex) quads for each
595
+ node. In such a buffer, nodes are stored in prefix order (parents
596
+ before children, with the endIndex of the parent indicating which
597
+ children belong to it).
598
+ */
599
+ var TreeBuffer = class TreeBuffer {
600
+ /**
601
+ Create a tree buffer.
602
+ */
603
+ constructor(buffer, length, set) {
604
+ this.buffer = buffer;
605
+ this.length = length;
606
+ this.set = set;
607
+ }
608
+ /**
609
+ @internal
610
+ */
611
+ get type() {
612
+ return NodeType.none;
613
+ }
614
+ /**
615
+ @internal
616
+ */
617
+ toString() {
618
+ let result = [];
619
+ for (let index = 0; index < this.buffer.length;) {
620
+ result.push(this.childString(index));
621
+ index = this.buffer[index + 3];
622
+ }
623
+ return result.join(",");
624
+ }
625
+ /**
626
+ @internal
627
+ */
628
+ childString(index) {
629
+ let id = this.buffer[index], endIndex = this.buffer[index + 3];
630
+ let type = this.set.types[id], result = type.name;
631
+ if (/\W/.test(result) && !type.isError) result = JSON.stringify(result);
632
+ index += 4;
633
+ if (endIndex == index) return result;
634
+ let children = [];
635
+ while (index < endIndex) {
636
+ children.push(this.childString(index));
637
+ index = this.buffer[index + 3];
638
+ }
639
+ return result + "(" + children.join(",") + ")";
640
+ }
641
+ /**
642
+ @internal
643
+ */
644
+ findChild(startIndex, endIndex, dir, pos, side) {
645
+ let { buffer } = this, pick = -1;
646
+ for (let i = startIndex; i != endIndex; i = buffer[i + 3]) if (checkSide(side, pos, buffer[i + 1], buffer[i + 2])) {
647
+ pick = i;
648
+ if (dir > 0) break;
649
+ }
650
+ return pick;
651
+ }
652
+ /**
653
+ @internal
654
+ */
655
+ slice(startI, endI, from) {
656
+ let b = this.buffer;
657
+ let copy = new Uint16Array(endI - startI), len = 0;
658
+ for (let i = startI, j = 0; i < endI;) {
659
+ copy[j++] = b[i++];
660
+ copy[j++] = b[i++] - from;
661
+ let to = copy[j++] = b[i++] - from;
662
+ copy[j++] = b[i++] - startI;
663
+ len = Math.max(len, to);
664
+ }
665
+ return new TreeBuffer(copy, len, this.set);
666
+ }
667
+ };
668
+ function checkSide(side, pos, from, to) {
669
+ switch (side) {
670
+ case -2: return from < pos;
671
+ case -1: return to >= pos && from < pos;
672
+ case 0: return from < pos && to > pos;
673
+ case 1: return from <= pos && to > pos;
674
+ case 2: return to > pos;
675
+ case 4: return true;
676
+ }
677
+ }
678
+ function resolveNode(node, pos, side, overlays) {
679
+ var _a;
680
+ while (node.from == node.to || (side < 1 ? node.from >= pos : node.from > pos) || (side > -1 ? node.to <= pos : node.to < pos)) {
681
+ let parent = !overlays && node instanceof TreeNode && node.index < 0 ? null : node.parent;
682
+ if (!parent) return node;
683
+ node = parent;
684
+ }
685
+ let mode = overlays ? 0 : IterMode.IgnoreOverlays;
686
+ if (overlays) {
687
+ for (let scan = node, parent = scan.parent; parent; scan = parent, parent = scan.parent) if (scan instanceof TreeNode && scan.index < 0 && ((_a = parent.enter(pos, side, mode)) === null || _a === void 0 ? void 0 : _a.from) != scan.from) node = parent;
688
+ }
689
+ for (;;) {
690
+ let inner = node.enter(pos, side, mode);
691
+ if (!inner) return node;
692
+ node = inner;
693
+ }
694
+ }
695
+ var BaseNode = class {
696
+ cursor(mode = 0) {
697
+ return new TreeCursor(this, mode);
698
+ }
699
+ getChild(type, before = null, after = null) {
700
+ let r = getChildren(this, type, before, after);
701
+ return r.length ? r[0] : null;
702
+ }
703
+ getChildren(type, before = null, after = null) {
704
+ return getChildren(this, type, before, after);
705
+ }
706
+ resolve(pos, side = 0) {
707
+ return resolveNode(this, pos, side, false);
708
+ }
709
+ resolveInner(pos, side = 0) {
710
+ return resolveNode(this, pos, side, true);
711
+ }
712
+ matchContext(context) {
713
+ return matchNodeContext(this.parent, context);
714
+ }
715
+ enterUnfinishedNodesBefore(pos) {
716
+ let scan = this.childBefore(pos), node = this;
717
+ while (scan) {
718
+ let last = scan.lastChild;
719
+ if (!last || last.to != scan.to) break;
720
+ if (last.type.isError && last.from == last.to) {
721
+ node = scan;
722
+ scan = last.prevSibling;
723
+ } else scan = last;
724
+ }
725
+ return node;
726
+ }
727
+ get node() {
728
+ return this;
729
+ }
730
+ get next() {
731
+ return this.parent;
732
+ }
733
+ };
734
+ var TreeNode = class TreeNode extends BaseNode {
735
+ constructor(_tree, from, index, _parent) {
736
+ super();
737
+ this._tree = _tree;
738
+ this.from = from;
739
+ this.index = index;
740
+ this._parent = _parent;
741
+ }
742
+ get type() {
743
+ return this._tree.type;
744
+ }
745
+ get name() {
746
+ return this._tree.type.name;
747
+ }
748
+ get to() {
749
+ return this.from + this._tree.length;
750
+ }
751
+ nextChild(i, dir, pos, side, mode = 0) {
752
+ for (let parent = this;;) {
753
+ for (let { children, positions } = parent._tree, e = dir > 0 ? children.length : -1; i != e; i += dir) {
754
+ let next = children[i], start = positions[i] + parent.from, mounted;
755
+ if (!(mode & IterMode.EnterBracketed && next instanceof Tree && (mounted = MountedTree.get(next)) && !mounted.overlay && mounted.bracketed && pos >= start && pos <= start + next.length) && !checkSide(side, pos, start, start + next.length)) continue;
756
+ if (next instanceof TreeBuffer) {
757
+ if (mode & IterMode.ExcludeBuffers) continue;
758
+ let index = next.findChild(0, next.buffer.length, dir, pos - start, side);
759
+ if (index > -1) return new BufferNode(new BufferContext(parent, next, i, start), null, index);
760
+ } else if (mode & IterMode.IncludeAnonymous || !next.type.isAnonymous || hasChild(next)) {
761
+ let mounted;
762
+ if (!(mode & IterMode.IgnoreMounts) && (mounted = MountedTree.get(next)) && !mounted.overlay) return new TreeNode(mounted.tree, start, i, parent);
763
+ let inner = new TreeNode(next, start, i, parent);
764
+ return mode & IterMode.IncludeAnonymous || !inner.type.isAnonymous ? inner : inner.nextChild(dir < 0 ? next.children.length - 1 : 0, dir, pos, side, mode);
765
+ }
766
+ }
767
+ if (mode & IterMode.IncludeAnonymous || !parent.type.isAnonymous) return null;
768
+ if (parent.index >= 0) i = parent.index + dir;
769
+ else i = dir < 0 ? -1 : parent._parent._tree.children.length;
770
+ parent = parent._parent;
771
+ if (!parent) return null;
772
+ }
773
+ }
774
+ get firstChild() {
775
+ return this.nextChild(0, 1, 0, 4);
776
+ }
777
+ get lastChild() {
778
+ return this.nextChild(this._tree.children.length - 1, -1, 0, 4);
779
+ }
780
+ childAfter(pos) {
781
+ return this.nextChild(0, 1, pos, 2);
782
+ }
783
+ childBefore(pos) {
784
+ return this.nextChild(this._tree.children.length - 1, -1, pos, -2);
785
+ }
786
+ prop(prop) {
787
+ return this._tree.prop(prop);
788
+ }
789
+ enter(pos, side, mode = 0) {
790
+ let mounted;
791
+ if (!(mode & IterMode.IgnoreOverlays) && (mounted = MountedTree.get(this._tree)) && mounted.overlay) {
792
+ let rPos = pos - this.from, enterBracketed = mode & IterMode.EnterBracketed && mounted.bracketed;
793
+ for (let { from, to } of mounted.overlay) if ((side > 0 || enterBracketed ? from <= rPos : from < rPos) && (side < 0 || enterBracketed ? to >= rPos : to > rPos)) return new TreeNode(mounted.tree, mounted.overlay[0].from + this.from, -1, this);
794
+ }
795
+ return this.nextChild(0, 1, pos, side, mode);
796
+ }
797
+ nextSignificantParent() {
798
+ let val = this;
799
+ while (val.type.isAnonymous && val._parent) val = val._parent;
800
+ return val;
801
+ }
802
+ get parent() {
803
+ return this._parent ? this._parent.nextSignificantParent() : null;
804
+ }
805
+ get nextSibling() {
806
+ return this._parent && this.index >= 0 ? this._parent.nextChild(this.index + 1, 1, 0, 4) : null;
807
+ }
808
+ get prevSibling() {
809
+ return this._parent && this.index >= 0 ? this._parent.nextChild(this.index - 1, -1, 0, 4) : null;
810
+ }
811
+ get tree() {
812
+ return this._tree;
813
+ }
814
+ toTree() {
815
+ return this._tree;
816
+ }
817
+ /**
818
+ @internal
819
+ */
820
+ toString() {
821
+ return this._tree.toString();
822
+ }
823
+ };
824
+ function getChildren(node, type, before, after) {
825
+ let cur = node.cursor(), result = [];
826
+ if (!cur.firstChild()) return result;
827
+ if (before != null) for (let found = false; !found;) {
828
+ found = cur.type.is(before);
829
+ if (!cur.nextSibling()) return result;
830
+ }
831
+ for (;;) {
832
+ if (after != null && cur.type.is(after)) return result;
833
+ if (cur.type.is(type)) result.push(cur.node);
834
+ if (!cur.nextSibling()) return after == null ? result : [];
835
+ }
836
+ }
837
+ function matchNodeContext(node, context, i = context.length - 1) {
838
+ for (let p = node; i >= 0; p = p.parent) {
839
+ if (!p) return false;
840
+ if (!p.type.isAnonymous) {
841
+ if (context[i] && context[i] != p.name) return false;
842
+ i--;
843
+ }
844
+ }
845
+ return true;
846
+ }
847
+ var BufferContext = class {
848
+ constructor(parent, buffer, index, start) {
849
+ this.parent = parent;
850
+ this.buffer = buffer;
851
+ this.index = index;
852
+ this.start = start;
853
+ }
854
+ };
855
+ var BufferNode = class BufferNode extends BaseNode {
856
+ get name() {
857
+ return this.type.name;
858
+ }
859
+ get from() {
860
+ return this.context.start + this.context.buffer.buffer[this.index + 1];
861
+ }
862
+ get to() {
863
+ return this.context.start + this.context.buffer.buffer[this.index + 2];
864
+ }
865
+ constructor(context, _parent, index) {
866
+ super();
867
+ this.context = context;
868
+ this._parent = _parent;
869
+ this.index = index;
870
+ this.type = context.buffer.set.types[context.buffer.buffer[index]];
871
+ }
872
+ child(dir, pos, side) {
873
+ let { buffer } = this.context;
874
+ let index = buffer.findChild(this.index + 4, buffer.buffer[this.index + 3], dir, pos - this.context.start, side);
875
+ return index < 0 ? null : new BufferNode(this.context, this, index);
876
+ }
877
+ get firstChild() {
878
+ return this.child(1, 0, 4);
879
+ }
880
+ get lastChild() {
881
+ return this.child(-1, 0, 4);
882
+ }
883
+ childAfter(pos) {
884
+ return this.child(1, pos, 2);
885
+ }
886
+ childBefore(pos) {
887
+ return this.child(-1, pos, -2);
888
+ }
889
+ prop(prop) {
890
+ return this.type.prop(prop);
891
+ }
892
+ enter(pos, side, mode = 0) {
893
+ if (mode & IterMode.ExcludeBuffers) return null;
894
+ let { buffer } = this.context;
895
+ let index = buffer.findChild(this.index + 4, buffer.buffer[this.index + 3], side > 0 ? 1 : -1, pos - this.context.start, side);
896
+ return index < 0 ? null : new BufferNode(this.context, this, index);
897
+ }
898
+ get parent() {
899
+ return this._parent || this.context.parent.nextSignificantParent();
900
+ }
901
+ externalSibling(dir) {
902
+ return this._parent ? null : this.context.parent.nextChild(this.context.index + dir, dir, 0, 4);
903
+ }
904
+ get nextSibling() {
905
+ let { buffer } = this.context;
906
+ let after = buffer.buffer[this.index + 3];
907
+ if (after < (this._parent ? buffer.buffer[this._parent.index + 3] : buffer.buffer.length)) return new BufferNode(this.context, this._parent, after);
908
+ return this.externalSibling(1);
909
+ }
910
+ get prevSibling() {
911
+ let { buffer } = this.context;
912
+ let parentStart = this._parent ? this._parent.index + 4 : 0;
913
+ if (this.index == parentStart) return this.externalSibling(-1);
914
+ return new BufferNode(this.context, this._parent, buffer.findChild(parentStart, this.index, -1, 0, 4));
915
+ }
916
+ get tree() {
917
+ return null;
918
+ }
919
+ toTree() {
920
+ let children = [], positions = [];
921
+ let { buffer } = this.context;
922
+ let startI = this.index + 4, endI = buffer.buffer[this.index + 3];
923
+ if (endI > startI) {
924
+ let from = buffer.buffer[this.index + 1];
925
+ children.push(buffer.slice(startI, endI, from));
926
+ positions.push(0);
927
+ }
928
+ return new Tree(this.type, children, positions, this.to - this.from);
929
+ }
930
+ /**
931
+ @internal
932
+ */
933
+ toString() {
934
+ return this.context.buffer.childString(this.index);
935
+ }
936
+ };
937
+ function iterStack(heads) {
938
+ if (!heads.length) return null;
939
+ let pick = 0, picked = heads[0];
940
+ for (let i = 1; i < heads.length; i++) {
941
+ let node = heads[i];
942
+ if (node.from > picked.from || node.to < picked.to) {
943
+ picked = node;
944
+ pick = i;
945
+ }
946
+ }
947
+ let next = picked instanceof TreeNode && picked.index < 0 ? null : picked.parent;
948
+ let newHeads = heads.slice();
949
+ if (next) newHeads[pick] = next;
950
+ else newHeads.splice(pick, 1);
951
+ return new StackIterator(newHeads, picked);
952
+ }
953
+ var StackIterator = class {
954
+ constructor(heads, node) {
955
+ this.heads = heads;
956
+ this.node = node;
957
+ }
958
+ get next() {
959
+ return iterStack(this.heads);
960
+ }
961
+ };
962
+ function stackIterator(tree, pos, side) {
963
+ let inner = tree.resolveInner(pos, side), layers = null;
964
+ for (let scan = inner instanceof TreeNode ? inner : inner.context.parent; scan; scan = scan.parent) if (scan.index < 0) {
965
+ let parent = scan.parent;
966
+ (layers || (layers = [inner])).push(parent.resolve(pos, side));
967
+ scan = parent;
968
+ } else {
969
+ let mount = MountedTree.get(scan.tree);
970
+ if (mount && mount.overlay && mount.overlay[0].from <= pos && mount.overlay[mount.overlay.length - 1].to >= pos) {
971
+ let root = new TreeNode(mount.tree, mount.overlay[0].from + scan.from, -1, scan);
972
+ (layers || (layers = [inner])).push(resolveNode(root, pos, side, false));
973
+ }
974
+ }
975
+ return layers ? iterStack(layers) : inner;
976
+ }
977
+ /**
978
+ A tree cursor object focuses on a given node in a syntax tree, and
979
+ allows you to move to adjacent nodes.
980
+ */
981
+ var TreeCursor = class {
982
+ /**
983
+ Shorthand for `.type.name`.
984
+ */
985
+ get name() {
986
+ return this.type.name;
987
+ }
988
+ /**
989
+ @internal
990
+ */
991
+ constructor(node, mode = 0) {
992
+ /**
993
+ @internal
994
+ */
995
+ this.buffer = null;
996
+ this.stack = [];
997
+ /**
998
+ @internal
999
+ */
1000
+ this.index = 0;
1001
+ this.bufferNode = null;
1002
+ this.mode = mode & ~IterMode.EnterBracketed;
1003
+ if (node instanceof TreeNode) this.yieldNode(node);
1004
+ else {
1005
+ this._tree = node.context.parent;
1006
+ this.buffer = node.context;
1007
+ for (let n = node._parent; n; n = n._parent) this.stack.unshift(n.index);
1008
+ this.bufferNode = node;
1009
+ this.yieldBuf(node.index);
1010
+ }
1011
+ }
1012
+ yieldNode(node) {
1013
+ if (!node) return false;
1014
+ this._tree = node;
1015
+ this.type = node.type;
1016
+ this.from = node.from;
1017
+ this.to = node.to;
1018
+ return true;
1019
+ }
1020
+ yieldBuf(index, type) {
1021
+ this.index = index;
1022
+ let { start, buffer } = this.buffer;
1023
+ this.type = type || buffer.set.types[buffer.buffer[index]];
1024
+ this.from = start + buffer.buffer[index + 1];
1025
+ this.to = start + buffer.buffer[index + 2];
1026
+ return true;
1027
+ }
1028
+ /**
1029
+ @internal
1030
+ */
1031
+ yield(node) {
1032
+ if (!node) return false;
1033
+ if (node instanceof TreeNode) {
1034
+ this.buffer = null;
1035
+ return this.yieldNode(node);
1036
+ }
1037
+ this.buffer = node.context;
1038
+ return this.yieldBuf(node.index, node.type);
1039
+ }
1040
+ /**
1041
+ @internal
1042
+ */
1043
+ toString() {
1044
+ return this.buffer ? this.buffer.buffer.childString(this.index) : this._tree.toString();
1045
+ }
1046
+ /**
1047
+ @internal
1048
+ */
1049
+ enterChild(dir, pos, side) {
1050
+ if (!this.buffer) return this.yield(this._tree.nextChild(dir < 0 ? this._tree._tree.children.length - 1 : 0, dir, pos, side, this.mode));
1051
+ let { buffer } = this.buffer;
1052
+ let index = buffer.findChild(this.index + 4, buffer.buffer[this.index + 3], dir, pos - this.buffer.start, side);
1053
+ if (index < 0) return false;
1054
+ this.stack.push(this.index);
1055
+ return this.yieldBuf(index);
1056
+ }
1057
+ /**
1058
+ Move the cursor to this node's first child. When this returns
1059
+ false, the node has no child, and the cursor has not been moved.
1060
+ */
1061
+ firstChild() {
1062
+ return this.enterChild(1, 0, 4);
1063
+ }
1064
+ /**
1065
+ Move the cursor to this node's last child.
1066
+ */
1067
+ lastChild() {
1068
+ return this.enterChild(-1, 0, 4);
1069
+ }
1070
+ /**
1071
+ Move the cursor to the first child that ends after `pos`.
1072
+ */
1073
+ childAfter(pos) {
1074
+ return this.enterChild(1, pos, 2);
1075
+ }
1076
+ /**
1077
+ Move to the last child that starts before `pos`.
1078
+ */
1079
+ childBefore(pos) {
1080
+ return this.enterChild(-1, pos, -2);
1081
+ }
1082
+ /**
1083
+ Move the cursor to the child around `pos`. If side is -1 the
1084
+ child may end at that position, when 1 it may start there. This
1085
+ will also enter [overlaid](#common.MountedTree.overlay)
1086
+ [mounted](#common.NodeProp^mounted) trees unless `overlays` is
1087
+ set to false.
1088
+ */
1089
+ enter(pos, side, mode = this.mode) {
1090
+ if (!this.buffer) return this.yield(this._tree.enter(pos, side, mode));
1091
+ return mode & IterMode.ExcludeBuffers ? false : this.enterChild(1, pos, side);
1092
+ }
1093
+ /**
1094
+ Move to the node's parent node, if this isn't the top node.
1095
+ */
1096
+ parent() {
1097
+ if (!this.buffer) return this.yieldNode(this.mode & IterMode.IncludeAnonymous ? this._tree._parent : this._tree.parent);
1098
+ if (this.stack.length) return this.yieldBuf(this.stack.pop());
1099
+ let parent = this.mode & IterMode.IncludeAnonymous ? this.buffer.parent : this.buffer.parent.nextSignificantParent();
1100
+ this.buffer = null;
1101
+ return this.yieldNode(parent);
1102
+ }
1103
+ /**
1104
+ @internal
1105
+ */
1106
+ sibling(dir) {
1107
+ if (!this.buffer) return !this._tree._parent ? false : this.yield(this._tree.index < 0 ? null : this._tree._parent.nextChild(this._tree.index + dir, dir, 0, 4, this.mode));
1108
+ let { buffer } = this.buffer, d = this.stack.length - 1;
1109
+ if (dir < 0) {
1110
+ let parentStart = d < 0 ? 0 : this.stack[d] + 4;
1111
+ if (this.index != parentStart) return this.yieldBuf(buffer.findChild(parentStart, this.index, -1, 0, 4));
1112
+ } else {
1113
+ let after = buffer.buffer[this.index + 3];
1114
+ if (after < (d < 0 ? buffer.buffer.length : buffer.buffer[this.stack[d] + 3])) return this.yieldBuf(after);
1115
+ }
1116
+ return d < 0 ? this.yield(this.buffer.parent.nextChild(this.buffer.index + dir, dir, 0, 4, this.mode)) : false;
1117
+ }
1118
+ /**
1119
+ Move to this node's next sibling, if any.
1120
+ */
1121
+ nextSibling() {
1122
+ return this.sibling(1);
1123
+ }
1124
+ /**
1125
+ Move to this node's previous sibling, if any.
1126
+ */
1127
+ prevSibling() {
1128
+ return this.sibling(-1);
1129
+ }
1130
+ atLastNode(dir) {
1131
+ let index, parent, { buffer } = this;
1132
+ if (buffer) {
1133
+ if (dir > 0) {
1134
+ if (this.index < buffer.buffer.buffer.length) return false;
1135
+ } else for (let i = 0; i < this.index; i++) if (buffer.buffer.buffer[i + 3] < this.index) return false;
1136
+ ({index, parent} = buffer);
1137
+ } else ({index, _parent: parent} = this._tree);
1138
+ for (; parent; {index, _parent: parent} = parent) if (index > -1) for (let i = index + dir, e = dir < 0 ? -1 : parent._tree.children.length; i != e; i += dir) {
1139
+ let child = parent._tree.children[i];
1140
+ if (this.mode & IterMode.IncludeAnonymous || child instanceof TreeBuffer || !child.type.isAnonymous || hasChild(child)) return false;
1141
+ }
1142
+ return true;
1143
+ }
1144
+ move(dir, enter) {
1145
+ if (enter && this.enterChild(dir, 0, 4)) return true;
1146
+ for (;;) {
1147
+ if (this.sibling(dir)) return true;
1148
+ if (this.atLastNode(dir) || !this.parent()) return false;
1149
+ }
1150
+ }
1151
+ /**
1152
+ Move to the next node in a
1153
+ [pre-order](https://en.wikipedia.org/wiki/Tree_traversal#Pre-order,_NLR)
1154
+ traversal, going from a node to its first child or, if the
1155
+ current node is empty or `enter` is false, its next sibling or
1156
+ the next sibling of the first parent node that has one.
1157
+ */
1158
+ next(enter = true) {
1159
+ return this.move(1, enter);
1160
+ }
1161
+ /**
1162
+ Move to the next node in a last-to-first pre-order traversal. A
1163
+ node is followed by its last child or, if it has none, its
1164
+ previous sibling or the previous sibling of the first parent
1165
+ node that has one.
1166
+ */
1167
+ prev(enter = true) {
1168
+ return this.move(-1, enter);
1169
+ }
1170
+ /**
1171
+ Move the cursor to the innermost node that covers `pos`. If
1172
+ `side` is -1, it will enter nodes that end at `pos`. If it is 1,
1173
+ it will enter nodes that start at `pos`.
1174
+ */
1175
+ moveTo(pos, side = 0) {
1176
+ while (this.from == this.to || (side < 1 ? this.from >= pos : this.from > pos) || (side > -1 ? this.to <= pos : this.to < pos)) if (!this.parent()) break;
1177
+ while (this.enterChild(1, pos, side));
1178
+ return this;
1179
+ }
1180
+ /**
1181
+ Get a [syntax node](#common.SyntaxNode) at the cursor's current
1182
+ position.
1183
+ */
1184
+ get node() {
1185
+ if (!this.buffer) return this._tree;
1186
+ let cache = this.bufferNode, result = null, depth = 0;
1187
+ if (cache && cache.context == this.buffer) scan: for (let index = this.index, d = this.stack.length; d >= 0;) {
1188
+ for (let c = cache; c; c = c._parent) if (c.index == index) {
1189
+ if (index == this.index) return c;
1190
+ result = c;
1191
+ depth = d + 1;
1192
+ break scan;
1193
+ }
1194
+ index = this.stack[--d];
1195
+ }
1196
+ for (let i = depth; i < this.stack.length; i++) result = new BufferNode(this.buffer, result, this.stack[i]);
1197
+ return this.bufferNode = new BufferNode(this.buffer, result, this.index);
1198
+ }
1199
+ /**
1200
+ Get the [tree](#common.Tree) that represents the current node, if
1201
+ any. Will return null when the node is in a [tree
1202
+ buffer](#common.TreeBuffer).
1203
+ */
1204
+ get tree() {
1205
+ return this.buffer ? null : this._tree._tree;
1206
+ }
1207
+ /**
1208
+ Iterate over the current node and all its descendants, calling
1209
+ `enter` when entering a node and `leave`, if given, when leaving
1210
+ one. When `enter` returns `false`, any children of that node are
1211
+ skipped, and `leave` isn't called for it.
1212
+ */
1213
+ iterate(enter, leave) {
1214
+ for (let depth = 0;;) {
1215
+ let mustLeave = false;
1216
+ if (this.type.isAnonymous || enter(this) !== false) {
1217
+ if (this.firstChild()) {
1218
+ depth++;
1219
+ continue;
1220
+ }
1221
+ if (!this.type.isAnonymous) mustLeave = true;
1222
+ }
1223
+ for (;;) {
1224
+ if (mustLeave && leave) leave(this);
1225
+ mustLeave = this.type.isAnonymous;
1226
+ if (!depth) return;
1227
+ if (this.nextSibling()) break;
1228
+ this.parent();
1229
+ depth--;
1230
+ mustLeave = true;
1231
+ }
1232
+ }
1233
+ }
1234
+ /**
1235
+ Test whether the current node matches a given context—a sequence
1236
+ of direct parent node names. Empty strings in the context array
1237
+ are treated as wildcards.
1238
+ */
1239
+ matchContext(context) {
1240
+ if (!this.buffer) return matchNodeContext(this.node.parent, context);
1241
+ let { buffer } = this.buffer, { types } = buffer.set;
1242
+ for (let i = context.length - 1, d = this.stack.length - 1; i >= 0; d--) {
1243
+ if (d < 0) return matchNodeContext(this._tree, context, i);
1244
+ let type = types[buffer.buffer[this.stack[d]]];
1245
+ if (!type.isAnonymous) {
1246
+ if (context[i] && context[i] != type.name) return false;
1247
+ i--;
1248
+ }
1249
+ }
1250
+ return true;
1251
+ }
1252
+ };
1253
+ function hasChild(tree) {
1254
+ return tree.children.some((ch) => ch instanceof TreeBuffer || !ch.type.isAnonymous || hasChild(ch));
1255
+ }
1256
+ function buildTree(data) {
1257
+ var _a;
1258
+ let { buffer, nodeSet, maxBufferLength = DefaultBufferLength, reused = [], minRepeatType = nodeSet.types.length } = data;
1259
+ let cursor = Array.isArray(buffer) ? new FlatBufferCursor(buffer, buffer.length) : buffer;
1260
+ let types = nodeSet.types;
1261
+ let contextHash = 0, lookAhead = 0;
1262
+ function takeNode(parentStart, minPos, children, positions, inRepeat, depth) {
1263
+ let { id, start, end, size } = cursor;
1264
+ let lookAheadAtStart = lookAhead, contextAtStart = contextHash;
1265
+ if (size < 0) {
1266
+ cursor.next();
1267
+ if (size == -1) {
1268
+ let node = reused[id];
1269
+ children.push(node);
1270
+ positions.push(start - parentStart);
1271
+ return;
1272
+ } else if (size == -3) {
1273
+ contextHash = id;
1274
+ return;
1275
+ } else if (size == -4) {
1276
+ lookAhead = id;
1277
+ return;
1278
+ } else throw new RangeError(`Unrecognized record size: ${size}`);
1279
+ }
1280
+ let type = types[id], node, buffer;
1281
+ let startPos = start - parentStart;
1282
+ if (end - start <= maxBufferLength && (buffer = findBufferSize(cursor.pos - minPos, inRepeat))) {
1283
+ let data = new Uint16Array(buffer.size - buffer.skip);
1284
+ let endPos = cursor.pos - buffer.size, index = data.length;
1285
+ while (cursor.pos > endPos) index = copyToBuffer(buffer.start, data, index);
1286
+ node = new TreeBuffer(data, end - buffer.start, nodeSet);
1287
+ startPos = buffer.start - parentStart;
1288
+ } else {
1289
+ let endPos = cursor.pos - size;
1290
+ cursor.next();
1291
+ let localChildren = [], localPositions = [];
1292
+ let localInRepeat = id >= minRepeatType ? id : -1;
1293
+ let lastGroup = 0, lastEnd = end;
1294
+ while (cursor.pos > endPos) if (localInRepeat >= 0 && cursor.id == localInRepeat && cursor.size >= 0) {
1295
+ if (cursor.end <= lastEnd - maxBufferLength) {
1296
+ makeRepeatLeaf(localChildren, localPositions, start, lastGroup, cursor.end, lastEnd, localInRepeat, lookAheadAtStart, contextAtStart);
1297
+ lastGroup = localChildren.length;
1298
+ lastEnd = cursor.end;
1299
+ }
1300
+ cursor.next();
1301
+ } else if (depth > 2500) takeFlatNode(start, endPos, localChildren, localPositions);
1302
+ else takeNode(start, endPos, localChildren, localPositions, localInRepeat, depth + 1);
1303
+ if (localInRepeat >= 0 && lastGroup > 0 && lastGroup < localChildren.length) makeRepeatLeaf(localChildren, localPositions, start, lastGroup, start, lastEnd, localInRepeat, lookAheadAtStart, contextAtStart);
1304
+ localChildren.reverse();
1305
+ localPositions.reverse();
1306
+ if (localInRepeat > -1 && lastGroup > 0) {
1307
+ let make = makeBalanced(type, contextAtStart);
1308
+ node = balanceRange(type, localChildren, localPositions, 0, localChildren.length, 0, end - start, make, make);
1309
+ } else node = makeTree(type, localChildren, localPositions, end - start, lookAheadAtStart - end, contextAtStart);
1310
+ }
1311
+ children.push(node);
1312
+ positions.push(startPos);
1313
+ }
1314
+ function takeFlatNode(parentStart, minPos, children, positions) {
1315
+ let nodes = [];
1316
+ let nodeCount = 0, stopAt = -1;
1317
+ while (cursor.pos > minPos) {
1318
+ let { id, start, end, size } = cursor;
1319
+ if (size > 4) cursor.next();
1320
+ else if (stopAt > -1 && start < stopAt) break;
1321
+ else {
1322
+ if (stopAt < 0) stopAt = end - maxBufferLength;
1323
+ nodes.push(id, start, end);
1324
+ nodeCount++;
1325
+ cursor.next();
1326
+ }
1327
+ }
1328
+ if (nodeCount) {
1329
+ let buffer = new Uint16Array(nodeCount * 4);
1330
+ let start = nodes[nodes.length - 2];
1331
+ for (let i = nodes.length - 3, j = 0; i >= 0; i -= 3) {
1332
+ buffer[j++] = nodes[i];
1333
+ buffer[j++] = nodes[i + 1] - start;
1334
+ buffer[j++] = nodes[i + 2] - start;
1335
+ buffer[j++] = j;
1336
+ }
1337
+ children.push(new TreeBuffer(buffer, nodes[2] - start, nodeSet));
1338
+ positions.push(start - parentStart);
1339
+ }
1340
+ }
1341
+ function makeBalanced(type, contextHash) {
1342
+ return (children, positions, length) => {
1343
+ let lookAhead = 0, lastI = children.length - 1, last, lookAheadProp;
1344
+ if (lastI >= 0 && (last = children[lastI]) instanceof Tree) {
1345
+ if (!lastI && last.type == type && last.length == length) return last;
1346
+ if (lookAheadProp = last.prop(NodeProp.lookAhead)) lookAhead = positions[lastI] + last.length + lookAheadProp;
1347
+ }
1348
+ return makeTree(type, children, positions, length, lookAhead, contextHash);
1349
+ };
1350
+ }
1351
+ function makeRepeatLeaf(children, positions, base, i, from, to, type, lookAhead, contextHash) {
1352
+ let localChildren = [], localPositions = [];
1353
+ while (children.length > i) {
1354
+ localChildren.push(children.pop());
1355
+ localPositions.push(positions.pop() + base - from);
1356
+ }
1357
+ children.push(makeTree(nodeSet.types[type], localChildren, localPositions, to - from, lookAhead - to, contextHash));
1358
+ positions.push(from - base);
1359
+ }
1360
+ function makeTree(type, children, positions, length, lookAhead, contextHash, props) {
1361
+ if (contextHash) {
1362
+ let pair = [NodeProp.contextHash, contextHash];
1363
+ props = props ? [pair].concat(props) : [pair];
1364
+ }
1365
+ if (lookAhead > 25) {
1366
+ let pair = [NodeProp.lookAhead, lookAhead];
1367
+ props = props ? [pair].concat(props) : [pair];
1368
+ }
1369
+ return new Tree(type, children, positions, length, props);
1370
+ }
1371
+ function findBufferSize(maxSize, inRepeat) {
1372
+ let fork = cursor.fork();
1373
+ let size = 0, start = 0, skip = 0, minStart = fork.end - maxBufferLength;
1374
+ let result = {
1375
+ size: 0,
1376
+ start: 0,
1377
+ skip: 0
1378
+ };
1379
+ scan: for (let minPos = fork.pos - maxSize; fork.pos > minPos;) {
1380
+ let nodeSize = fork.size;
1381
+ if (fork.id == inRepeat && nodeSize >= 0) {
1382
+ result.size = size;
1383
+ result.start = start;
1384
+ result.skip = skip;
1385
+ skip += 4;
1386
+ size += 4;
1387
+ fork.next();
1388
+ continue;
1389
+ }
1390
+ let startPos = fork.pos - nodeSize;
1391
+ if (nodeSize < 0 || startPos < minPos || fork.start < minStart) break;
1392
+ let localSkipped = fork.id >= minRepeatType ? 4 : 0;
1393
+ let nodeStart = fork.start;
1394
+ fork.next();
1395
+ while (fork.pos > startPos) {
1396
+ if (fork.size < 0) {
1397
+ if (fork.size == -3 || fork.size == -4) localSkipped += 4;
1398
+ else break scan;
1399
+ } else if (fork.id >= minRepeatType) localSkipped += 4;
1400
+ fork.next();
1401
+ }
1402
+ start = nodeStart;
1403
+ size += nodeSize;
1404
+ skip += localSkipped;
1405
+ }
1406
+ if (inRepeat < 0 || size == maxSize) {
1407
+ result.size = size;
1408
+ result.start = start;
1409
+ result.skip = skip;
1410
+ }
1411
+ return result.size > 4 ? result : void 0;
1412
+ }
1413
+ function copyToBuffer(bufferStart, buffer, index) {
1414
+ let { id, start, end, size } = cursor;
1415
+ cursor.next();
1416
+ if (size >= 0 && id < minRepeatType) {
1417
+ let startIndex = index;
1418
+ if (size > 4) {
1419
+ let endPos = cursor.pos - (size - 4);
1420
+ while (cursor.pos > endPos) index = copyToBuffer(bufferStart, buffer, index);
1421
+ }
1422
+ buffer[--index] = startIndex;
1423
+ buffer[--index] = end - bufferStart;
1424
+ buffer[--index] = start - bufferStart;
1425
+ buffer[--index] = id;
1426
+ } else if (size == -3) contextHash = id;
1427
+ else if (size == -4) lookAhead = id;
1428
+ return index;
1429
+ }
1430
+ let children = [], positions = [];
1431
+ while (cursor.pos > 0) takeNode(data.start || 0, data.bufferStart || 0, children, positions, -1, 0);
1432
+ let length = (_a = data.length) !== null && _a !== void 0 ? _a : children.length ? positions[0] + children[0].length : 0;
1433
+ return new Tree(types[data.topID], children.reverse(), positions.reverse(), length);
1434
+ }
1435
+ var nodeSizeCache = /* @__PURE__ */ new WeakMap();
1436
+ function nodeSize(balanceType, node) {
1437
+ if (!balanceType.isAnonymous || node instanceof TreeBuffer || node.type != balanceType) return 1;
1438
+ let size = nodeSizeCache.get(node);
1439
+ if (size == null) {
1440
+ size = 1;
1441
+ for (let child of node.children) {
1442
+ if (child.type != balanceType || !(child instanceof Tree)) {
1443
+ size = 1;
1444
+ break;
1445
+ }
1446
+ size += nodeSize(balanceType, child);
1447
+ }
1448
+ nodeSizeCache.set(node, size);
1449
+ }
1450
+ return size;
1451
+ }
1452
+ function balanceRange(balanceType, children, positions, from, to, start, length, mkTop, mkTree) {
1453
+ let total = 0;
1454
+ for (let i = from; i < to; i++) total += nodeSize(balanceType, children[i]);
1455
+ let maxChild = Math.ceil(total * 1.5 / 8);
1456
+ let localChildren = [], localPositions = [];
1457
+ function divide(children, positions, from, to, offset) {
1458
+ for (let i = from; i < to;) {
1459
+ let groupFrom = i, groupStart = positions[i], groupSize = nodeSize(balanceType, children[i]);
1460
+ i++;
1461
+ for (; i < to; i++) {
1462
+ let nextSize = nodeSize(balanceType, children[i]);
1463
+ if (groupSize + nextSize >= maxChild) break;
1464
+ groupSize += nextSize;
1465
+ }
1466
+ if (i == groupFrom + 1) {
1467
+ if (groupSize > maxChild) {
1468
+ let only = children[groupFrom];
1469
+ divide(only.children, only.positions, 0, only.children.length, positions[groupFrom] + offset);
1470
+ continue;
1471
+ }
1472
+ localChildren.push(children[groupFrom]);
1473
+ } else {
1474
+ let length = positions[i - 1] + children[i - 1].length - groupStart;
1475
+ localChildren.push(balanceRange(balanceType, children, positions, groupFrom, i, groupStart, length, null, mkTree));
1476
+ }
1477
+ localPositions.push(groupStart + offset - start);
1478
+ }
1479
+ }
1480
+ divide(children, positions, from, to, 0);
1481
+ return (mkTop || mkTree)(localChildren, localPositions, length);
1482
+ }
1483
+ /**
1484
+ Provides a way to associate values with pieces of trees. As long
1485
+ as that part of the tree is reused, the associated values can be
1486
+ retrieved from an updated tree.
1487
+ */
1488
+ var NodeWeakMap = class {
1489
+ constructor() {
1490
+ this.map = /* @__PURE__ */ new WeakMap();
1491
+ }
1492
+ setBuffer(buffer, index, value) {
1493
+ let inner = this.map.get(buffer);
1494
+ if (!inner) this.map.set(buffer, inner = /* @__PURE__ */ new Map());
1495
+ inner.set(index, value);
1496
+ }
1497
+ getBuffer(buffer, index) {
1498
+ let inner = this.map.get(buffer);
1499
+ return inner && inner.get(index);
1500
+ }
1501
+ /**
1502
+ Set the value for this syntax node.
1503
+ */
1504
+ set(node, value) {
1505
+ if (node instanceof BufferNode) this.setBuffer(node.context.buffer, node.index, value);
1506
+ else if (node instanceof TreeNode) this.map.set(node.tree, value);
1507
+ }
1508
+ /**
1509
+ Retrieve value for this syntax node, if it exists in the map.
1510
+ */
1511
+ get(node) {
1512
+ return node instanceof BufferNode ? this.getBuffer(node.context.buffer, node.index) : node instanceof TreeNode ? this.map.get(node.tree) : void 0;
1513
+ }
1514
+ /**
1515
+ Set the value for the node that a cursor currently points to.
1516
+ */
1517
+ cursorSet(cursor, value) {
1518
+ if (cursor.buffer) this.setBuffer(cursor.buffer.buffer, cursor.index, value);
1519
+ else this.map.set(cursor.tree, value);
1520
+ }
1521
+ /**
1522
+ Retrieve the value for the node that a cursor currently points
1523
+ to.
1524
+ */
1525
+ cursorGet(cursor) {
1526
+ return cursor.buffer ? this.getBuffer(cursor.buffer.buffer, cursor.index) : this.map.get(cursor.tree);
1527
+ }
1528
+ };
1529
+ /**
1530
+ Tree fragments are used during [incremental
1531
+ parsing](#common.Parser.startParse) to track parts of old trees
1532
+ that can be reused in a new parse. An array of fragments is used
1533
+ to track regions of an old tree whose nodes might be reused in new
1534
+ parses. Use the static
1535
+ [`applyChanges`](#common.TreeFragment^applyChanges) method to
1536
+ update fragments for document changes.
1537
+ */
1538
+ var TreeFragment = class TreeFragment {
1539
+ /**
1540
+ Construct a tree fragment. You'll usually want to use
1541
+ [`addTree`](#common.TreeFragment^addTree) and
1542
+ [`applyChanges`](#common.TreeFragment^applyChanges) instead of
1543
+ calling this directly.
1544
+ */
1545
+ constructor(from, to, tree, offset, openStart = false, openEnd = false) {
1546
+ this.from = from;
1547
+ this.to = to;
1548
+ this.tree = tree;
1549
+ this.offset = offset;
1550
+ this.open = (openStart ? 1 : 0) | (openEnd ? 2 : 0);
1551
+ }
1552
+ /**
1553
+ Whether the start of the fragment represents the start of a
1554
+ parse, or the end of a change. (In the second case, it may not
1555
+ be safe to reuse some nodes at the start, depending on the
1556
+ parsing algorithm.)
1557
+ */
1558
+ get openStart() {
1559
+ return (this.open & 1) > 0;
1560
+ }
1561
+ /**
1562
+ Whether the end of the fragment represents the end of a
1563
+ full-document parse, or the start of a change.
1564
+ */
1565
+ get openEnd() {
1566
+ return (this.open & 2) > 0;
1567
+ }
1568
+ /**
1569
+ Create a set of fragments from a freshly parsed tree, or update
1570
+ an existing set of fragments by replacing the ones that overlap
1571
+ with a tree with content from the new tree. When `partial` is
1572
+ true, the parse is treated as incomplete, and the resulting
1573
+ fragment has [`openEnd`](#common.TreeFragment.openEnd) set to
1574
+ true.
1575
+ */
1576
+ static addTree(tree, fragments = [], partial = false) {
1577
+ let result = [new TreeFragment(0, tree.length, tree, 0, false, partial)];
1578
+ for (let f of fragments) if (f.to > tree.length) result.push(f);
1579
+ return result;
1580
+ }
1581
+ /**
1582
+ Apply a set of edits to an array of fragments, removing or
1583
+ splitting fragments as necessary to remove edited ranges, and
1584
+ adjusting offsets for fragments that moved.
1585
+ */
1586
+ static applyChanges(fragments, changes, minGap = 128) {
1587
+ if (!changes.length) return fragments;
1588
+ let result = [];
1589
+ let fI = 1, nextF = fragments.length ? fragments[0] : null;
1590
+ for (let cI = 0, pos = 0, off = 0;; cI++) {
1591
+ let nextC = cI < changes.length ? changes[cI] : null;
1592
+ let nextPos = nextC ? nextC.fromA : 1e9;
1593
+ if (nextPos - pos >= minGap) while (nextF && nextF.from < nextPos) {
1594
+ let cut = nextF;
1595
+ if (pos >= cut.from || nextPos <= cut.to || off) {
1596
+ let fFrom = Math.max(cut.from, pos) - off, fTo = Math.min(cut.to, nextPos) - off;
1597
+ cut = fFrom >= fTo ? null : new TreeFragment(fFrom, fTo, cut.tree, cut.offset + off, cI > 0, !!nextC);
1598
+ }
1599
+ if (cut) result.push(cut);
1600
+ if (nextF.to > nextPos) break;
1601
+ nextF = fI < fragments.length ? fragments[fI++] : null;
1602
+ }
1603
+ if (!nextC) break;
1604
+ pos = nextC.toA;
1605
+ off = nextC.toA - nextC.toB;
1606
+ }
1607
+ return result;
1608
+ }
1609
+ };
1610
+ /**
1611
+ A superclass that parsers should extend.
1612
+ */
1613
+ var Parser = class {
1614
+ /**
1615
+ Start a parse, returning a [partial parse](#common.PartialParse)
1616
+ object. [`fragments`](#common.TreeFragment) can be passed in to
1617
+ make the parse incremental.
1618
+
1619
+ By default, the entire input is parsed. You can pass `ranges`,
1620
+ which should be a sorted array of non-empty, non-overlapping
1621
+ ranges, to parse only those ranges. The tree returned in that
1622
+ case will start at `ranges[0].from`.
1623
+ */
1624
+ startParse(input, fragments, ranges) {
1625
+ if (typeof input == "string") input = new StringInput(input);
1626
+ ranges = !ranges ? [new Range(0, input.length)] : ranges.length ? ranges.map((r) => new Range(r.from, r.to)) : [new Range(0, 0)];
1627
+ return this.createParse(input, fragments || [], ranges);
1628
+ }
1629
+ /**
1630
+ Run a full parse, returning the resulting tree.
1631
+ */
1632
+ parse(input, fragments, ranges) {
1633
+ let parse = this.startParse(input, fragments, ranges);
1634
+ for (;;) {
1635
+ let done = parse.advance();
1636
+ if (done) return done;
1637
+ }
1638
+ }
1639
+ };
1640
+ var StringInput = class {
1641
+ constructor(string) {
1642
+ this.string = string;
1643
+ }
1644
+ get length() {
1645
+ return this.string.length;
1646
+ }
1647
+ chunk(from) {
1648
+ return this.string.slice(from);
1649
+ }
1650
+ get lineChunks() {
1651
+ return false;
1652
+ }
1653
+ read(from, to) {
1654
+ return this.string.slice(from, to);
1655
+ }
1656
+ };
1657
+ /**
1658
+ Create a parse wrapper that, after the inner parse completes,
1659
+ scans its tree for mixed language regions with the `nest`
1660
+ function, runs the resulting [inner parses](#common.NestedParse),
1661
+ and then [mounts](#common.NodeProp^mounted) their results onto the
1662
+ tree.
1663
+ */
1664
+ function parseMixed(nest) {
1665
+ return (parse, input, fragments, ranges) => new MixedParse(parse, nest, input, fragments, ranges);
1666
+ }
1667
+ var InnerParse = class {
1668
+ constructor(parser, parse, overlay, bracketed, target, from) {
1669
+ this.parser = parser;
1670
+ this.parse = parse;
1671
+ this.overlay = overlay;
1672
+ this.bracketed = bracketed;
1673
+ this.target = target;
1674
+ this.from = from;
1675
+ }
1676
+ };
1677
+ function checkRanges(ranges) {
1678
+ if (!ranges.length || ranges.some((r) => r.from >= r.to)) throw new RangeError("Invalid inner parse ranges given: " + JSON.stringify(ranges));
1679
+ }
1680
+ var ActiveOverlay = class {
1681
+ constructor(parser, predicate, mounts, index, start, bracketed, target, prev) {
1682
+ this.parser = parser;
1683
+ this.predicate = predicate;
1684
+ this.mounts = mounts;
1685
+ this.index = index;
1686
+ this.start = start;
1687
+ this.bracketed = bracketed;
1688
+ this.target = target;
1689
+ this.prev = prev;
1690
+ this.depth = 0;
1691
+ this.ranges = [];
1692
+ }
1693
+ };
1694
+ var stoppedInner = new NodeProp({ perNode: true });
1695
+ var MixedParse = class {
1696
+ constructor(base, nest, input, fragments, ranges) {
1697
+ this.nest = nest;
1698
+ this.input = input;
1699
+ this.fragments = fragments;
1700
+ this.ranges = ranges;
1701
+ this.inner = [];
1702
+ this.innerDone = 0;
1703
+ this.baseTree = null;
1704
+ this.stoppedAt = null;
1705
+ this.baseParse = base;
1706
+ }
1707
+ advance() {
1708
+ if (this.baseParse) {
1709
+ let done = this.baseParse.advance();
1710
+ if (!done) return null;
1711
+ this.baseParse = null;
1712
+ this.baseTree = done;
1713
+ this.startInner();
1714
+ if (this.stoppedAt != null) for (let inner of this.inner) inner.parse.stopAt(this.stoppedAt);
1715
+ }
1716
+ if (this.innerDone == this.inner.length) {
1717
+ let result = this.baseTree;
1718
+ if (this.stoppedAt != null) result = new Tree(result.type, result.children, result.positions, result.length, result.propValues.concat([[stoppedInner, this.stoppedAt]]));
1719
+ return result;
1720
+ }
1721
+ let inner = this.inner[this.innerDone], done = inner.parse.advance();
1722
+ if (done) {
1723
+ this.innerDone++;
1724
+ let props = Object.assign(Object.create(null), inner.target.props);
1725
+ props[NodeProp.mounted.id] = new MountedTree(done, inner.overlay, inner.parser, inner.bracketed);
1726
+ inner.target.props = props;
1727
+ }
1728
+ return null;
1729
+ }
1730
+ get parsedPos() {
1731
+ if (this.baseParse) return 0;
1732
+ let pos = this.input.length;
1733
+ for (let i = this.innerDone; i < this.inner.length; i++) if (this.inner[i].from < pos) pos = Math.min(pos, this.inner[i].parse.parsedPos);
1734
+ return pos;
1735
+ }
1736
+ stopAt(pos) {
1737
+ this.stoppedAt = pos;
1738
+ if (this.baseParse) this.baseParse.stopAt(pos);
1739
+ else for (let i = this.innerDone; i < this.inner.length; i++) this.inner[i].parse.stopAt(pos);
1740
+ }
1741
+ startInner() {
1742
+ let fragmentCursor = new FragmentCursor(this.fragments);
1743
+ let overlay = null;
1744
+ let covered = null;
1745
+ let cursor = new TreeCursor(new TreeNode(this.baseTree, this.ranges[0].from, 0, null), IterMode.IncludeAnonymous | IterMode.IgnoreMounts);
1746
+ scan: for (let nest, isCovered;;) {
1747
+ let enter = true, range;
1748
+ if (this.stoppedAt != null && cursor.from >= this.stoppedAt) enter = false;
1749
+ else if (fragmentCursor.hasNode(cursor)) {
1750
+ if (overlay) {
1751
+ let match = overlay.mounts.find((m) => m.frag.from <= cursor.from && m.frag.to >= cursor.to && m.mount.overlay);
1752
+ if (match) for (let r of match.mount.overlay) {
1753
+ let from = r.from + match.pos, to = r.to + match.pos;
1754
+ if (from >= cursor.from && to <= cursor.to && !overlay.ranges.some((r) => r.from < to && r.to > from)) overlay.ranges.push({
1755
+ from,
1756
+ to
1757
+ });
1758
+ }
1759
+ }
1760
+ enter = false;
1761
+ } else if (covered && (isCovered = checkCover(covered.ranges, cursor.from, cursor.to))) enter = isCovered != 2;
1762
+ else if (!cursor.type.isAnonymous && (nest = this.nest(cursor, this.input)) && (cursor.from < cursor.to || !nest.overlay)) {
1763
+ if (!cursor.tree) {
1764
+ materialize(cursor);
1765
+ if (overlay) overlay.depth++;
1766
+ if (covered) covered.depth++;
1767
+ }
1768
+ let oldMounts = fragmentCursor.findMounts(cursor.from, nest.parser);
1769
+ if (typeof nest.overlay == "function") overlay = new ActiveOverlay(nest.parser, nest.overlay, oldMounts, this.inner.length, cursor.from, !!nest.bracketed, cursor.tree, overlay);
1770
+ else {
1771
+ let ranges = punchRanges(this.ranges, nest.overlay || (cursor.from < cursor.to ? [new Range(cursor.from, cursor.to)] : []));
1772
+ if (ranges.length) checkRanges(ranges);
1773
+ if (ranges.length || !nest.overlay) this.inner.push(new InnerParse(nest.parser, ranges.length ? nest.parser.startParse(this.input, enterFragments(oldMounts, ranges), ranges) : nest.parser.startParse(""), nest.overlay ? nest.overlay.map((r) => new Range(r.from - cursor.from, r.to - cursor.from)) : null, !!nest.bracketed, cursor.tree, ranges.length ? ranges[0].from : cursor.from));
1774
+ if (!nest.overlay) enter = false;
1775
+ else if (ranges.length) covered = {
1776
+ ranges,
1777
+ depth: 0,
1778
+ prev: covered
1779
+ };
1780
+ }
1781
+ } else if (overlay && (range = overlay.predicate(cursor))) {
1782
+ if (range === true) range = new Range(cursor.from, cursor.to);
1783
+ if (range.from < range.to) {
1784
+ let last = overlay.ranges.length - 1;
1785
+ if (last >= 0 && overlay.ranges[last].to == range.from) overlay.ranges[last] = {
1786
+ from: overlay.ranges[last].from,
1787
+ to: range.to
1788
+ };
1789
+ else overlay.ranges.push(range);
1790
+ }
1791
+ }
1792
+ if (enter && cursor.firstChild()) {
1793
+ if (overlay) overlay.depth++;
1794
+ if (covered) covered.depth++;
1795
+ } else for (;;) {
1796
+ if (cursor.nextSibling()) break;
1797
+ if (!cursor.parent()) break scan;
1798
+ if (overlay && !--overlay.depth) {
1799
+ let ranges = punchRanges(this.ranges, overlay.ranges);
1800
+ if (ranges.length) {
1801
+ checkRanges(ranges);
1802
+ this.inner.splice(overlay.index, 0, new InnerParse(overlay.parser, overlay.parser.startParse(this.input, enterFragments(overlay.mounts, ranges), ranges), overlay.ranges.map((r) => new Range(r.from - overlay.start, r.to - overlay.start)), overlay.bracketed, overlay.target, ranges[0].from));
1803
+ }
1804
+ overlay = overlay.prev;
1805
+ }
1806
+ if (covered && !--covered.depth) covered = covered.prev;
1807
+ }
1808
+ }
1809
+ }
1810
+ };
1811
+ function checkCover(covered, from, to) {
1812
+ for (let range of covered) {
1813
+ if (range.from >= to) break;
1814
+ if (range.to > from) return range.from <= from && range.to >= to ? 2 : 1;
1815
+ }
1816
+ return 0;
1817
+ }
1818
+ function sliceBuf(buf, startI, endI, nodes, positions, off) {
1819
+ if (startI < endI) {
1820
+ let from = buf.buffer[startI + 1];
1821
+ nodes.push(buf.slice(startI, endI, from));
1822
+ positions.push(from - off);
1823
+ }
1824
+ }
1825
+ function materialize(cursor) {
1826
+ let { node } = cursor, stack = [];
1827
+ let buffer = node.context.buffer;
1828
+ do {
1829
+ stack.push(cursor.index);
1830
+ cursor.parent();
1831
+ } while (!cursor.tree);
1832
+ let base = cursor.tree, i = base.children.indexOf(buffer);
1833
+ let buf = base.children[i], b = buf.buffer, newStack = [i];
1834
+ function split(startI, endI, type, innerOffset, length, stackPos) {
1835
+ let targetI = stack[stackPos];
1836
+ let children = [], positions = [];
1837
+ sliceBuf(buf, startI, targetI, children, positions, innerOffset);
1838
+ let from = b[targetI + 1], to = b[targetI + 2];
1839
+ newStack.push(children.length);
1840
+ let child = stackPos ? split(targetI + 4, b[targetI + 3], buf.set.types[b[targetI]], from, to - from, stackPos - 1) : node.toTree();
1841
+ children.push(child);
1842
+ positions.push(from - innerOffset);
1843
+ sliceBuf(buf, b[targetI + 3], endI, children, positions, innerOffset);
1844
+ return new Tree(type, children, positions, length);
1845
+ }
1846
+ base.children[i] = split(0, b.length, NodeType.none, 0, buf.length, stack.length - 1);
1847
+ for (let index of newStack) {
1848
+ let tree = cursor.tree.children[index], pos = cursor.tree.positions[index];
1849
+ cursor.yield(new TreeNode(tree, pos + cursor.from, index, cursor._tree));
1850
+ }
1851
+ }
1852
+ var StructureCursor = class {
1853
+ constructor(root, offset) {
1854
+ this.offset = offset;
1855
+ this.done = false;
1856
+ this.cursor = root.cursor(IterMode.IncludeAnonymous | IterMode.IgnoreMounts);
1857
+ }
1858
+ moveTo(pos) {
1859
+ let { cursor } = this, p = pos - this.offset;
1860
+ while (!this.done && cursor.from < p) if (cursor.to >= pos && cursor.enter(p, 1, IterMode.IgnoreOverlays | IterMode.ExcludeBuffers));
1861
+ else if (cursor.to <= pos) {
1862
+ if (!cursor.next(false)) this.done = true;
1863
+ } else break;
1864
+ }
1865
+ hasNode(cursor) {
1866
+ this.moveTo(cursor.from);
1867
+ if (!this.done && this.cursor.from + this.offset == cursor.from && this.cursor.tree) for (let tree = this.cursor.tree;;) {
1868
+ if (tree == cursor.tree) return true;
1869
+ if (tree.children.length && tree.positions[0] == 0 && tree.children[0] instanceof Tree) tree = tree.children[0];
1870
+ else break;
1871
+ }
1872
+ return false;
1873
+ }
1874
+ };
1875
+ var FragmentCursor = class {
1876
+ constructor(fragments) {
1877
+ var _a;
1878
+ this.fragments = fragments;
1879
+ this.curTo = 0;
1880
+ this.fragI = 0;
1881
+ if (fragments.length) {
1882
+ let first = this.curFrag = fragments[0];
1883
+ this.curTo = (_a = first.tree.prop(stoppedInner)) !== null && _a !== void 0 ? _a : first.to;
1884
+ this.inner = new StructureCursor(first.tree, -first.offset);
1885
+ } else this.curFrag = this.inner = null;
1886
+ }
1887
+ hasNode(node) {
1888
+ while (this.curFrag && node.from >= this.curTo) this.nextFrag();
1889
+ return this.curFrag && this.curFrag.from <= node.from && this.curTo >= node.to && this.inner.hasNode(node);
1890
+ }
1891
+ nextFrag() {
1892
+ var _a;
1893
+ this.fragI++;
1894
+ if (this.fragI == this.fragments.length) this.curFrag = this.inner = null;
1895
+ else {
1896
+ let frag = this.curFrag = this.fragments[this.fragI];
1897
+ this.curTo = (_a = frag.tree.prop(stoppedInner)) !== null && _a !== void 0 ? _a : frag.to;
1898
+ this.inner = new StructureCursor(frag.tree, -frag.offset);
1899
+ }
1900
+ }
1901
+ findMounts(pos, parser) {
1902
+ var _a;
1903
+ let result = [];
1904
+ if (this.inner) {
1905
+ this.inner.cursor.moveTo(pos, 1);
1906
+ for (let pos = this.inner.cursor.node; pos; pos = pos.parent) {
1907
+ let mount = (_a = pos.tree) === null || _a === void 0 ? void 0 : _a.prop(NodeProp.mounted);
1908
+ if (mount && mount.parser == parser) for (let i = this.fragI; i < this.fragments.length; i++) {
1909
+ let frag = this.fragments[i];
1910
+ if (frag.from >= pos.to) break;
1911
+ if (frag.tree == this.curFrag.tree) result.push({
1912
+ frag,
1913
+ pos: pos.from - frag.offset,
1914
+ mount
1915
+ });
1916
+ }
1917
+ }
1918
+ }
1919
+ return result;
1920
+ }
1921
+ };
1922
+ function punchRanges(outer, ranges) {
1923
+ let copy = null, current = ranges;
1924
+ for (let i = 1, j = 0; i < outer.length; i++) {
1925
+ let gapFrom = outer[i - 1].to, gapTo = outer[i].from;
1926
+ for (; j < current.length; j++) {
1927
+ let r = current[j];
1928
+ if (r.from >= gapTo) break;
1929
+ if (r.to <= gapFrom) continue;
1930
+ if (!copy) current = copy = ranges.slice();
1931
+ if (r.from < gapFrom) {
1932
+ copy[j] = new Range(r.from, gapFrom);
1933
+ if (r.to > gapTo) copy.splice(j + 1, 0, new Range(gapTo, r.to));
1934
+ } else if (r.to > gapTo) copy[j--] = new Range(gapTo, r.to);
1935
+ else copy.splice(j--, 1);
1936
+ }
1937
+ }
1938
+ return current;
1939
+ }
1940
+ function findCoverChanges(a, b, from, to) {
1941
+ let iA = 0, iB = 0, inA = false, inB = false, pos = -1e9;
1942
+ let result = [];
1943
+ for (;;) {
1944
+ let nextA = iA == a.length ? 1e9 : inA ? a[iA].to : a[iA].from;
1945
+ let nextB = iB == b.length ? 1e9 : inB ? b[iB].to : b[iB].from;
1946
+ if (inA != inB) {
1947
+ let start = Math.max(pos, from), end = Math.min(nextA, nextB, to);
1948
+ if (start < end) result.push(new Range(start, end));
1949
+ }
1950
+ pos = Math.min(nextA, nextB);
1951
+ if (pos == 1e9) break;
1952
+ if (nextA == pos) {
1953
+ if (!inA) inA = true;
1954
+ else {
1955
+ inA = false;
1956
+ iA++;
1957
+ }
1958
+ }
1959
+ if (nextB == pos) {
1960
+ if (!inB) inB = true;
1961
+ else {
1962
+ inB = false;
1963
+ iB++;
1964
+ }
1965
+ }
1966
+ }
1967
+ return result;
1968
+ }
1969
+ function enterFragments(mounts, ranges) {
1970
+ let result = [];
1971
+ for (let { pos, mount, frag } of mounts) {
1972
+ let startPos = pos + (mount.overlay ? mount.overlay[0].from : 0), endPos = startPos + mount.tree.length;
1973
+ let from = Math.max(frag.from, startPos), to = Math.min(frag.to, endPos);
1974
+ if (mount.overlay) {
1975
+ let changes = findCoverChanges(ranges, mount.overlay.map((r) => new Range(r.from + pos, r.to + pos)), from, to);
1976
+ for (let i = 0, pos = from;; i++) {
1977
+ let last = i == changes.length, end = last ? to : changes[i].from;
1978
+ if (end > pos) result.push(new TreeFragment(pos, end, mount.tree, -startPos, frag.from >= pos || frag.openStart, frag.to <= end || frag.openEnd));
1979
+ if (last) break;
1980
+ pos = changes[i].to;
1981
+ }
1982
+ } else result.push(new TreeFragment(from, to, mount.tree, -startPos, frag.from >= startPos || frag.openStart, frag.to <= endPos || frag.openEnd));
1983
+ }
1984
+ return result;
1985
+ }
1986
+ //#endregion
1987
+ //#region node_modules/@lezer/highlight/dist/index.js
1988
+ var nextTagID = 0;
1989
+ /**
1990
+ Highlighting tags are markers that denote a highlighting category.
1991
+ They are [associated](#highlight.styleTags) with parts of a syntax
1992
+ tree by a language mode, and then mapped to an actual CSS style by
1993
+ a [highlighter](#highlight.Highlighter).
1994
+
1995
+ Because syntax tree node types and highlight styles have to be
1996
+ able to talk the same language, CodeMirror uses a mostly _closed_
1997
+ [vocabulary](#highlight.tags) of syntax tags (as opposed to
1998
+ traditional open string-based systems, which make it hard for
1999
+ highlighting themes to cover all the tokens produced by the
2000
+ various languages).
2001
+
2002
+ It _is_ possible to [define](#highlight.Tag^define) your own
2003
+ highlighting tags for system-internal use (where you control both
2004
+ the language package and the highlighter), but such tags will not
2005
+ be picked up by regular highlighters (though you can derive them
2006
+ from standard tags to allow highlighters to fall back to those).
2007
+ */
2008
+ var Tag = class Tag {
2009
+ /**
2010
+ @internal
2011
+ */
2012
+ constructor(name, set, base, modified) {
2013
+ this.name = name;
2014
+ this.set = set;
2015
+ this.base = base;
2016
+ this.modified = modified;
2017
+ /**
2018
+ @internal
2019
+ */
2020
+ this.id = nextTagID++;
2021
+ }
2022
+ toString() {
2023
+ let { name } = this;
2024
+ for (let mod of this.modified) if (mod.name) name = `${mod.name}(${name})`;
2025
+ return name;
2026
+ }
2027
+ static define(nameOrParent, parent) {
2028
+ let name = typeof nameOrParent == "string" ? nameOrParent : "?";
2029
+ if (nameOrParent instanceof Tag) parent = nameOrParent;
2030
+ if (parent === null || parent === void 0 ? void 0 : parent.base) throw new Error("Can not derive from a modified tag");
2031
+ let tag = new Tag(name, [], null, []);
2032
+ tag.set.push(tag);
2033
+ if (parent) for (let t of parent.set) tag.set.push(t);
2034
+ return tag;
2035
+ }
2036
+ /**
2037
+ Define a tag _modifier_, which is a function that, given a tag,
2038
+ will return a tag that is a subtag of the original. Applying the
2039
+ same modifier to a twice tag will return the same value (`m1(t1)
2040
+ == m1(t1)`) and applying multiple modifiers will, regardless or
2041
+ order, produce the same tag (`m1(m2(t1)) == m2(m1(t1))`).
2042
+
2043
+ When multiple modifiers are applied to a given base tag, each
2044
+ smaller set of modifiers is registered as a parent, so that for
2045
+ example `m1(m2(m3(t1)))` is a subtype of `m1(m2(t1))`,
2046
+ `m1(m3(t1)`, and so on.
2047
+ */
2048
+ static defineModifier(name) {
2049
+ let mod = new Modifier(name);
2050
+ return (tag) => {
2051
+ if (tag.modified.indexOf(mod) > -1) return tag;
2052
+ return Modifier.get(tag.base || tag, tag.modified.concat(mod).sort((a, b) => a.id - b.id));
2053
+ };
2054
+ }
2055
+ };
2056
+ var nextModifierID = 0;
2057
+ var Modifier = class Modifier {
2058
+ constructor(name) {
2059
+ this.name = name;
2060
+ this.instances = [];
2061
+ this.id = nextModifierID++;
2062
+ }
2063
+ static get(base, mods) {
2064
+ if (!mods.length) return base;
2065
+ let exists = mods[0].instances.find((t) => t.base == base && sameArray(mods, t.modified));
2066
+ if (exists) return exists;
2067
+ let set = [], tag = new Tag(base.name, set, base, mods);
2068
+ for (let m of mods) m.instances.push(tag);
2069
+ let configs = powerSet(mods);
2070
+ for (let parent of base.set) if (!parent.modified.length) for (let config of configs) set.push(Modifier.get(parent, config));
2071
+ return tag;
2072
+ }
2073
+ };
2074
+ function sameArray(a, b) {
2075
+ return a.length == b.length && a.every((x, i) => x == b[i]);
2076
+ }
2077
+ function powerSet(array) {
2078
+ let sets = [[]];
2079
+ for (let i = 0; i < array.length; i++) for (let j = 0, e = sets.length; j < e; j++) sets.push(sets[j].concat(array[i]));
2080
+ return sets.sort((a, b) => b.length - a.length);
2081
+ }
2082
+ /**
2083
+ This function is used to add a set of tags to a language syntax
2084
+ via [`NodeSet.extend`](#common.NodeSet.extend) or
2085
+ [`LRParser.configure`](#lr.LRParser.configure).
2086
+
2087
+ The argument object maps node selectors to [highlighting
2088
+ tags](#highlight.Tag) or arrays of tags.
2089
+
2090
+ Node selectors may hold one or more (space-separated) node paths.
2091
+ Such a path can be a [node name](#common.NodeType.name), or
2092
+ multiple node names (or `*` wildcards) separated by slash
2093
+ characters, as in `"Block/Declaration/VariableName"`. Such a path
2094
+ matches the final node but only if its direct parent nodes are the
2095
+ other nodes mentioned. A `*` in such a path matches any parent,
2096
+ but only a single level—wildcards that match multiple parents
2097
+ aren't supported, both for efficiency reasons and because Lezer
2098
+ trees make it rather hard to reason about what they would match.)
2099
+
2100
+ A path can be ended with `/...` to indicate that the tag assigned
2101
+ to the node should also apply to all child nodes, even if they
2102
+ match their own style (by default, only the innermost style is
2103
+ used).
2104
+
2105
+ When a path ends in `!`, as in `Attribute!`, no further matching
2106
+ happens for the node's child nodes, and the entire node gets the
2107
+ given style.
2108
+
2109
+ In this notation, node names that contain `/`, `!`, `*`, or `...`
2110
+ must be quoted as JSON strings.
2111
+
2112
+ For example:
2113
+
2114
+ ```javascript
2115
+ parser.configure({props: [
2116
+ styleTags({
2117
+ // Style Number and BigNumber nodes
2118
+ "Number BigNumber": tags.number,
2119
+ // Style Escape nodes whose parent is String
2120
+ "String/Escape": tags.escape,
2121
+ // Style anything inside Attributes nodes
2122
+ "Attributes!": tags.meta,
2123
+ // Add a style to all content inside Italic nodes
2124
+ "Italic/...": tags.emphasis,
2125
+ // Style InvalidString nodes as both `string` and `invalid`
2126
+ "InvalidString": [tags.string, tags.invalid],
2127
+ // Style the node named "/" as punctuation
2128
+ '"/"': tags.punctuation
2129
+ })
2130
+ ]})
2131
+ ```
2132
+ */
2133
+ function styleTags(spec) {
2134
+ let byName = Object.create(null);
2135
+ for (let prop in spec) {
2136
+ let tags = spec[prop];
2137
+ if (!Array.isArray(tags)) tags = [tags];
2138
+ for (let part of prop.split(" ")) if (part) {
2139
+ let pieces = [], mode = 2, rest = part;
2140
+ for (let pos = 0;;) {
2141
+ if (rest == "..." && pos > 0 && pos + 3 == part.length) {
2142
+ mode = 1;
2143
+ break;
2144
+ }
2145
+ let m = /^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(rest);
2146
+ if (!m) throw new RangeError("Invalid path: " + part);
2147
+ pieces.push(m[0] == "*" ? "" : m[0][0] == "\"" ? JSON.parse(m[0]) : m[0]);
2148
+ pos += m[0].length;
2149
+ if (pos == part.length) break;
2150
+ let next = part[pos++];
2151
+ if (pos == part.length && next == "!") {
2152
+ mode = 0;
2153
+ break;
2154
+ }
2155
+ if (next != "/") throw new RangeError("Invalid path: " + part);
2156
+ rest = part.slice(pos);
2157
+ }
2158
+ let last = pieces.length - 1, inner = pieces[last];
2159
+ if (!inner) throw new RangeError("Invalid path: " + part);
2160
+ byName[inner] = new Rule(tags, mode, last > 0 ? pieces.slice(0, last) : null).sort(byName[inner]);
2161
+ }
2162
+ }
2163
+ return ruleNodeProp.add(byName);
2164
+ }
2165
+ var ruleNodeProp = new NodeProp({ combine(a, b) {
2166
+ let cur, root, take;
2167
+ while (a || b) {
2168
+ if (!a || b && a.depth <= b.depth) {
2169
+ take = b;
2170
+ b = b.next;
2171
+ } else {
2172
+ take = a;
2173
+ a = a.next;
2174
+ }
2175
+ if (cur && cur.mode == take.mode && !take.context && !cur.context) continue;
2176
+ let copy = new Rule(take.tags, take.mode, take.context);
2177
+ if (cur) cur.next = copy;
2178
+ else root = copy;
2179
+ cur = copy;
2180
+ }
2181
+ return root;
2182
+ } });
2183
+ var Rule = class {
2184
+ constructor(tags, mode, context, next) {
2185
+ this.tags = tags;
2186
+ this.mode = mode;
2187
+ this.context = context;
2188
+ this.next = next;
2189
+ }
2190
+ get opaque() {
2191
+ return this.mode == 0;
2192
+ }
2193
+ get inherit() {
2194
+ return this.mode == 1;
2195
+ }
2196
+ sort(other) {
2197
+ if (!other || other.depth < this.depth) {
2198
+ this.next = other;
2199
+ return this;
2200
+ }
2201
+ other.next = this.sort(other.next);
2202
+ return other;
2203
+ }
2204
+ get depth() {
2205
+ return this.context ? this.context.length : 0;
2206
+ }
2207
+ };
2208
+ Rule.empty = new Rule([], 2, null);
2209
+ /**
2210
+ Define a [highlighter](#highlight.Highlighter) from an array of
2211
+ tag/class pairs. Classes associated with more specific tags will
2212
+ take precedence.
2213
+ */
2214
+ function tagHighlighter(tags, options) {
2215
+ let map = Object.create(null);
2216
+ for (let style of tags) if (!Array.isArray(style.tag)) map[style.tag.id] = style.class;
2217
+ else for (let tag of style.tag) map[tag.id] = style.class;
2218
+ let { scope, all = null } = options || {};
2219
+ return {
2220
+ style: (tags) => {
2221
+ let cls = all;
2222
+ for (let tag of tags) for (let sub of tag.set) {
2223
+ let tagClass = map[sub.id];
2224
+ if (tagClass) {
2225
+ cls = cls ? cls + " " + tagClass : tagClass;
2226
+ break;
2227
+ }
2228
+ }
2229
+ return cls;
2230
+ },
2231
+ scope
2232
+ };
2233
+ }
2234
+ function highlightTags(highlighters, tags) {
2235
+ let result = null;
2236
+ for (let highlighter of highlighters) {
2237
+ let value = highlighter.style(tags);
2238
+ if (value) result = result ? result + " " + value : value;
2239
+ }
2240
+ return result;
2241
+ }
2242
+ /**
2243
+ Highlight the given [tree](#common.Tree) with the given
2244
+ [highlighter](#highlight.Highlighter). Often, the higher-level
2245
+ [`highlightCode`](#highlight.highlightCode) function is easier to
2246
+ use.
2247
+ */
2248
+ function highlightTree(tree, highlighter, putStyle, from = 0, to = tree.length) {
2249
+ let builder = new HighlightBuilder(from, Array.isArray(highlighter) ? highlighter : [highlighter], putStyle);
2250
+ builder.highlightRange(tree.cursor(), from, to, "", builder.highlighters);
2251
+ builder.flush(to);
2252
+ }
2253
+ var HighlightBuilder = class {
2254
+ constructor(at, highlighters, span) {
2255
+ this.at = at;
2256
+ this.highlighters = highlighters;
2257
+ this.span = span;
2258
+ this.class = "";
2259
+ }
2260
+ startSpan(at, cls) {
2261
+ if (cls != this.class) {
2262
+ this.flush(at);
2263
+ if (at > this.at) this.at = at;
2264
+ this.class = cls;
2265
+ }
2266
+ }
2267
+ flush(to) {
2268
+ if (to > this.at && this.class) this.span(this.at, to, this.class);
2269
+ }
2270
+ highlightRange(cursor, from, to, inheritedClass, highlighters) {
2271
+ let { type, from: start, to: end } = cursor;
2272
+ if (start >= to || end <= from) return;
2273
+ if (type.isTop) highlighters = this.highlighters.filter((h) => !h.scope || h.scope(type));
2274
+ let cls = inheritedClass;
2275
+ let rule = getStyleTags(cursor) || Rule.empty;
2276
+ let tagCls = highlightTags(highlighters, rule.tags);
2277
+ if (tagCls) {
2278
+ if (cls) cls += " ";
2279
+ cls += tagCls;
2280
+ if (rule.mode == 1) inheritedClass += (inheritedClass ? " " : "") + tagCls;
2281
+ }
2282
+ this.startSpan(Math.max(from, start), cls);
2283
+ if (rule.opaque) return;
2284
+ let mounted = cursor.tree && cursor.tree.prop(NodeProp.mounted);
2285
+ if (mounted && mounted.overlay) {
2286
+ let inner = cursor.node.enter(mounted.overlay[0].from + start, 1);
2287
+ let innerHighlighters = this.highlighters.filter((h) => !h.scope || h.scope(mounted.tree.type));
2288
+ let hasChild = cursor.firstChild();
2289
+ for (let i = 0, pos = start;; i++) {
2290
+ let next = i < mounted.overlay.length ? mounted.overlay[i] : null;
2291
+ let nextPos = next ? next.from + start : end;
2292
+ let rangeFrom = Math.max(from, pos), rangeTo = Math.min(to, nextPos);
2293
+ if (rangeFrom < rangeTo && hasChild) while (cursor.from < rangeTo) {
2294
+ this.highlightRange(cursor, rangeFrom, rangeTo, inheritedClass, highlighters);
2295
+ this.startSpan(Math.min(rangeTo, cursor.to), cls);
2296
+ if (cursor.to >= nextPos || !cursor.nextSibling()) break;
2297
+ }
2298
+ if (!next || nextPos > to) break;
2299
+ pos = next.to + start;
2300
+ if (pos > from) {
2301
+ this.highlightRange(inner.cursor(), Math.max(from, next.from + start), Math.min(to, pos), "", innerHighlighters);
2302
+ this.startSpan(Math.min(to, pos), cls);
2303
+ }
2304
+ }
2305
+ if (hasChild) cursor.parent();
2306
+ } else if (cursor.firstChild()) {
2307
+ if (mounted) inheritedClass = "";
2308
+ do {
2309
+ if (cursor.to <= from) continue;
2310
+ if (cursor.from >= to) break;
2311
+ this.highlightRange(cursor, from, to, inheritedClass, highlighters);
2312
+ this.startSpan(Math.min(to, cursor.to), cls);
2313
+ } while (cursor.nextSibling());
2314
+ cursor.parent();
2315
+ }
2316
+ }
2317
+ };
2318
+ /**
2319
+ Match a syntax node's [highlight rules](#highlight.styleTags). If
2320
+ there's a match, return its set of tags, and whether it is
2321
+ opaque (uses a `!`) or applies to all child nodes (`/...`).
2322
+ */
2323
+ function getStyleTags(node) {
2324
+ let rule = node.type.prop(ruleNodeProp);
2325
+ while (rule && rule.context && !node.matchContext(rule.context)) rule = rule.next;
2326
+ return rule || null;
2327
+ }
2328
+ var t = Tag.define;
2329
+ var comment = t();
2330
+ var name = t();
2331
+ var typeName = t(name);
2332
+ var propertyName = t(name);
2333
+ var literal = t();
2334
+ var string = t(literal);
2335
+ var number = t(literal);
2336
+ var content = t();
2337
+ var heading = t(content);
2338
+ var keyword = t();
2339
+ var operator = t();
2340
+ var punctuation = t();
2341
+ var bracket = t(punctuation);
2342
+ var meta = t();
2343
+ /**
2344
+ The default set of highlighting [tags](#highlight.Tag).
2345
+
2346
+ This collection is heavily biased towards programming languages,
2347
+ and necessarily incomplete. A full ontology of syntactic
2348
+ constructs would fill a stack of books, and be impractical to
2349
+ write themes for. So try to make do with this set. If all else
2350
+ fails, [open an
2351
+ issue](https://code.haverbeke.berlin/codemirror/dev/issues) to propose a
2352
+ new tag, or [define](#highlight.Tag^define) a local custom tag for
2353
+ your use case.
2354
+
2355
+ Note that it is not obligatory to always attach the most specific
2356
+ tag possible to an element—if your grammar can't easily
2357
+ distinguish a certain type of element (such as a local variable),
2358
+ it is okay to style it as its more general variant (a variable).
2359
+
2360
+ For tags that extend some parent tag, the documentation links to
2361
+ the parent.
2362
+ */
2363
+ var tags = {
2364
+ /**
2365
+ A comment.
2366
+ */
2367
+ comment,
2368
+ /**
2369
+ A line [comment](#highlight.tags.comment).
2370
+ */
2371
+ lineComment: t(comment),
2372
+ /**
2373
+ A block [comment](#highlight.tags.comment).
2374
+ */
2375
+ blockComment: t(comment),
2376
+ /**
2377
+ A documentation [comment](#highlight.tags.comment).
2378
+ */
2379
+ docComment: t(comment),
2380
+ /**
2381
+ Any kind of identifier.
2382
+ */
2383
+ name,
2384
+ /**
2385
+ The [name](#highlight.tags.name) of a variable.
2386
+ */
2387
+ variableName: t(name),
2388
+ /**
2389
+ A type [name](#highlight.tags.name).
2390
+ */
2391
+ typeName,
2392
+ /**
2393
+ A tag name (subtag of [`typeName`](#highlight.tags.typeName)).
2394
+ */
2395
+ tagName: t(typeName),
2396
+ /**
2397
+ A property or field [name](#highlight.tags.name).
2398
+ */
2399
+ propertyName,
2400
+ /**
2401
+ An attribute name (subtag of [`propertyName`](#highlight.tags.propertyName)).
2402
+ */
2403
+ attributeName: t(propertyName),
2404
+ /**
2405
+ The [name](#highlight.tags.name) of a class.
2406
+ */
2407
+ className: t(name),
2408
+ /**
2409
+ A label [name](#highlight.tags.name).
2410
+ */
2411
+ labelName: t(name),
2412
+ /**
2413
+ A namespace [name](#highlight.tags.name).
2414
+ */
2415
+ namespace: t(name),
2416
+ /**
2417
+ The [name](#highlight.tags.name) of a macro.
2418
+ */
2419
+ macroName: t(name),
2420
+ /**
2421
+ A literal value.
2422
+ */
2423
+ literal,
2424
+ /**
2425
+ A string [literal](#highlight.tags.literal).
2426
+ */
2427
+ string,
2428
+ /**
2429
+ A documentation [string](#highlight.tags.string).
2430
+ */
2431
+ docString: t(string),
2432
+ /**
2433
+ A character literal (subtag of [string](#highlight.tags.string)).
2434
+ */
2435
+ character: t(string),
2436
+ /**
2437
+ An attribute value (subtag of [string](#highlight.tags.string)).
2438
+ */
2439
+ attributeValue: t(string),
2440
+ /**
2441
+ A number [literal](#highlight.tags.literal).
2442
+ */
2443
+ number,
2444
+ /**
2445
+ An integer [number](#highlight.tags.number) literal.
2446
+ */
2447
+ integer: t(number),
2448
+ /**
2449
+ A floating-point [number](#highlight.tags.number) literal.
2450
+ */
2451
+ float: t(number),
2452
+ /**
2453
+ A boolean [literal](#highlight.tags.literal).
2454
+ */
2455
+ bool: t(literal),
2456
+ /**
2457
+ Regular expression [literal](#highlight.tags.literal).
2458
+ */
2459
+ regexp: t(literal),
2460
+ /**
2461
+ An escape [literal](#highlight.tags.literal), for example a
2462
+ backslash escape in a string.
2463
+ */
2464
+ escape: t(literal),
2465
+ /**
2466
+ A color [literal](#highlight.tags.literal).
2467
+ */
2468
+ color: t(literal),
2469
+ /**
2470
+ A URL [literal](#highlight.tags.literal).
2471
+ */
2472
+ url: t(literal),
2473
+ /**
2474
+ A language keyword.
2475
+ */
2476
+ keyword,
2477
+ /**
2478
+ The [keyword](#highlight.tags.keyword) for the self or this
2479
+ object.
2480
+ */
2481
+ self: t(keyword),
2482
+ /**
2483
+ The [keyword](#highlight.tags.keyword) for null.
2484
+ */
2485
+ null: t(keyword),
2486
+ /**
2487
+ A [keyword](#highlight.tags.keyword) denoting some atomic value.
2488
+ */
2489
+ atom: t(keyword),
2490
+ /**
2491
+ A [keyword](#highlight.tags.keyword) that represents a unit.
2492
+ */
2493
+ unit: t(keyword),
2494
+ /**
2495
+ A modifier [keyword](#highlight.tags.keyword).
2496
+ */
2497
+ modifier: t(keyword),
2498
+ /**
2499
+ A [keyword](#highlight.tags.keyword) that acts as an operator.
2500
+ */
2501
+ operatorKeyword: t(keyword),
2502
+ /**
2503
+ A control-flow related [keyword](#highlight.tags.keyword).
2504
+ */
2505
+ controlKeyword: t(keyword),
2506
+ /**
2507
+ A [keyword](#highlight.tags.keyword) that defines something.
2508
+ */
2509
+ definitionKeyword: t(keyword),
2510
+ /**
2511
+ A [keyword](#highlight.tags.keyword) related to defining or
2512
+ interfacing with modules.
2513
+ */
2514
+ moduleKeyword: t(keyword),
2515
+ /**
2516
+ An operator.
2517
+ */
2518
+ operator,
2519
+ /**
2520
+ An [operator](#highlight.tags.operator) that dereferences something.
2521
+ */
2522
+ derefOperator: t(operator),
2523
+ /**
2524
+ Arithmetic-related [operator](#highlight.tags.operator).
2525
+ */
2526
+ arithmeticOperator: t(operator),
2527
+ /**
2528
+ Logical [operator](#highlight.tags.operator).
2529
+ */
2530
+ logicOperator: t(operator),
2531
+ /**
2532
+ Bit [operator](#highlight.tags.operator).
2533
+ */
2534
+ bitwiseOperator: t(operator),
2535
+ /**
2536
+ Comparison [operator](#highlight.tags.operator).
2537
+ */
2538
+ compareOperator: t(operator),
2539
+ /**
2540
+ [Operator](#highlight.tags.operator) that updates its operand.
2541
+ */
2542
+ updateOperator: t(operator),
2543
+ /**
2544
+ [Operator](#highlight.tags.operator) that defines something.
2545
+ */
2546
+ definitionOperator: t(operator),
2547
+ /**
2548
+ Type-related [operator](#highlight.tags.operator).
2549
+ */
2550
+ typeOperator: t(operator),
2551
+ /**
2552
+ Control-flow [operator](#highlight.tags.operator).
2553
+ */
2554
+ controlOperator: t(operator),
2555
+ /**
2556
+ Program or markup punctuation.
2557
+ */
2558
+ punctuation,
2559
+ /**
2560
+ [Punctuation](#highlight.tags.punctuation) that separates
2561
+ things.
2562
+ */
2563
+ separator: t(punctuation),
2564
+ /**
2565
+ Bracket-style [punctuation](#highlight.tags.punctuation).
2566
+ */
2567
+ bracket,
2568
+ /**
2569
+ Angle [brackets](#highlight.tags.bracket) (usually `<` and `>`
2570
+ tokens).
2571
+ */
2572
+ angleBracket: t(bracket),
2573
+ /**
2574
+ Square [brackets](#highlight.tags.bracket) (usually `[` and `]`
2575
+ tokens).
2576
+ */
2577
+ squareBracket: t(bracket),
2578
+ /**
2579
+ Parentheses (usually `(` and `)` tokens). Subtag of
2580
+ [bracket](#highlight.tags.bracket).
2581
+ */
2582
+ paren: t(bracket),
2583
+ /**
2584
+ Braces (usually `{` and `}` tokens). Subtag of
2585
+ [bracket](#highlight.tags.bracket).
2586
+ */
2587
+ brace: t(bracket),
2588
+ /**
2589
+ Content, for example plain text in XML or markup documents.
2590
+ */
2591
+ content,
2592
+ /**
2593
+ [Content](#highlight.tags.content) that represents a heading.
2594
+ */
2595
+ heading,
2596
+ /**
2597
+ A level 1 [heading](#highlight.tags.heading).
2598
+ */
2599
+ heading1: t(heading),
2600
+ /**
2601
+ A level 2 [heading](#highlight.tags.heading).
2602
+ */
2603
+ heading2: t(heading),
2604
+ /**
2605
+ A level 3 [heading](#highlight.tags.heading).
2606
+ */
2607
+ heading3: t(heading),
2608
+ /**
2609
+ A level 4 [heading](#highlight.tags.heading).
2610
+ */
2611
+ heading4: t(heading),
2612
+ /**
2613
+ A level 5 [heading](#highlight.tags.heading).
2614
+ */
2615
+ heading5: t(heading),
2616
+ /**
2617
+ A level 6 [heading](#highlight.tags.heading).
2618
+ */
2619
+ heading6: t(heading),
2620
+ /**
2621
+ A prose [content](#highlight.tags.content) separator (such as a horizontal rule).
2622
+ */
2623
+ contentSeparator: t(content),
2624
+ /**
2625
+ [Content](#highlight.tags.content) that represents a list.
2626
+ */
2627
+ list: t(content),
2628
+ /**
2629
+ [Content](#highlight.tags.content) that represents a quote.
2630
+ */
2631
+ quote: t(content),
2632
+ /**
2633
+ [Content](#highlight.tags.content) that is emphasized.
2634
+ */
2635
+ emphasis: t(content),
2636
+ /**
2637
+ [Content](#highlight.tags.content) that is styled strong.
2638
+ */
2639
+ strong: t(content),
2640
+ /**
2641
+ [Content](#highlight.tags.content) that is part of a link.
2642
+ */
2643
+ link: t(content),
2644
+ /**
2645
+ [Content](#highlight.tags.content) that is styled as code or
2646
+ monospace.
2647
+ */
2648
+ monospace: t(content),
2649
+ /**
2650
+ [Content](#highlight.tags.content) that has a strike-through
2651
+ style.
2652
+ */
2653
+ strikethrough: t(content),
2654
+ /**
2655
+ Inserted text in a change-tracking format.
2656
+ */
2657
+ inserted: t(),
2658
+ /**
2659
+ Deleted text.
2660
+ */
2661
+ deleted: t(),
2662
+ /**
2663
+ Changed text.
2664
+ */
2665
+ changed: t(),
2666
+ /**
2667
+ An invalid or unsyntactic element.
2668
+ */
2669
+ invalid: t(),
2670
+ /**
2671
+ Metadata or meta-instruction.
2672
+ */
2673
+ meta,
2674
+ /**
2675
+ [Metadata](#highlight.tags.meta) that applies to the entire
2676
+ document.
2677
+ */
2678
+ documentMeta: t(meta),
2679
+ /**
2680
+ [Metadata](#highlight.tags.meta) that annotates or adds
2681
+ attributes to a given syntactic element.
2682
+ */
2683
+ annotation: t(meta),
2684
+ /**
2685
+ Processing instruction or preprocessor directive. Subtag of
2686
+ [meta](#highlight.tags.meta).
2687
+ */
2688
+ processingInstruction: t(meta),
2689
+ /**
2690
+ [Modifier](#highlight.Tag^defineModifier) that indicates that a
2691
+ given element is being defined. Expected to be used with the
2692
+ various [name](#highlight.tags.name) tags.
2693
+ */
2694
+ definition: Tag.defineModifier("definition"),
2695
+ /**
2696
+ [Modifier](#highlight.Tag^defineModifier) that indicates that
2697
+ something is constant. Mostly expected to be used with
2698
+ [variable names](#highlight.tags.variableName).
2699
+ */
2700
+ constant: Tag.defineModifier("constant"),
2701
+ /**
2702
+ [Modifier](#highlight.Tag^defineModifier) used to indicate that
2703
+ a [variable](#highlight.tags.variableName) or [property
2704
+ name](#highlight.tags.propertyName) is being called or defined
2705
+ as a function.
2706
+ */
2707
+ function: Tag.defineModifier("function"),
2708
+ /**
2709
+ [Modifier](#highlight.Tag^defineModifier) that can be applied to
2710
+ [names](#highlight.tags.name) to indicate that they belong to
2711
+ the language's standard environment.
2712
+ */
2713
+ standard: Tag.defineModifier("standard"),
2714
+ /**
2715
+ [Modifier](#highlight.Tag^defineModifier) that indicates a given
2716
+ [names](#highlight.tags.name) is local to some scope.
2717
+ */
2718
+ local: Tag.defineModifier("local"),
2719
+ /**
2720
+ A generic variant [modifier](#highlight.Tag^defineModifier) that
2721
+ can be used to tag language-specific alternative variants of
2722
+ some common tag. It is recommended for themes to define special
2723
+ forms of at least the [string](#highlight.tags.string) and
2724
+ [variable name](#highlight.tags.variableName) tags, since those
2725
+ come up a lot.
2726
+ */
2727
+ special: Tag.defineModifier("special")
2728
+ };
2729
+ for (let name in tags) {
2730
+ let val = tags[name];
2731
+ if (val instanceof Tag) val.name = name;
2732
+ }
2733
+ tagHighlighter([
2734
+ {
2735
+ tag: tags.link,
2736
+ class: "tok-link"
2737
+ },
2738
+ {
2739
+ tag: tags.heading,
2740
+ class: "tok-heading"
2741
+ },
2742
+ {
2743
+ tag: tags.emphasis,
2744
+ class: "tok-emphasis"
2745
+ },
2746
+ {
2747
+ tag: tags.strong,
2748
+ class: "tok-strong"
2749
+ },
2750
+ {
2751
+ tag: tags.keyword,
2752
+ class: "tok-keyword"
2753
+ },
2754
+ {
2755
+ tag: tags.atom,
2756
+ class: "tok-atom"
2757
+ },
2758
+ {
2759
+ tag: tags.bool,
2760
+ class: "tok-bool"
2761
+ },
2762
+ {
2763
+ tag: tags.url,
2764
+ class: "tok-url"
2765
+ },
2766
+ {
2767
+ tag: tags.labelName,
2768
+ class: "tok-labelName"
2769
+ },
2770
+ {
2771
+ tag: tags.inserted,
2772
+ class: "tok-inserted"
2773
+ },
2774
+ {
2775
+ tag: tags.deleted,
2776
+ class: "tok-deleted"
2777
+ },
2778
+ {
2779
+ tag: tags.literal,
2780
+ class: "tok-literal"
2781
+ },
2782
+ {
2783
+ tag: tags.string,
2784
+ class: "tok-string"
2785
+ },
2786
+ {
2787
+ tag: tags.number,
2788
+ class: "tok-number"
2789
+ },
2790
+ {
2791
+ tag: [
2792
+ tags.regexp,
2793
+ tags.escape,
2794
+ tags.special(tags.string)
2795
+ ],
2796
+ class: "tok-string2"
2797
+ },
2798
+ {
2799
+ tag: tags.variableName,
2800
+ class: "tok-variableName"
2801
+ },
2802
+ {
2803
+ tag: tags.local(tags.variableName),
2804
+ class: "tok-variableName tok-local"
2805
+ },
2806
+ {
2807
+ tag: tags.definition(tags.variableName),
2808
+ class: "tok-variableName tok-definition"
2809
+ },
2810
+ {
2811
+ tag: tags.special(tags.variableName),
2812
+ class: "tok-variableName2"
2813
+ },
2814
+ {
2815
+ tag: tags.definition(tags.propertyName),
2816
+ class: "tok-propertyName tok-definition"
2817
+ },
2818
+ {
2819
+ tag: tags.typeName,
2820
+ class: "tok-typeName"
2821
+ },
2822
+ {
2823
+ tag: tags.namespace,
2824
+ class: "tok-namespace"
2825
+ },
2826
+ {
2827
+ tag: tags.className,
2828
+ class: "tok-className"
2829
+ },
2830
+ {
2831
+ tag: tags.macroName,
2832
+ class: "tok-macroName"
2833
+ },
2834
+ {
2835
+ tag: tags.propertyName,
2836
+ class: "tok-propertyName"
2837
+ },
2838
+ {
2839
+ tag: tags.operator,
2840
+ class: "tok-operator"
2841
+ },
2842
+ {
2843
+ tag: tags.comment,
2844
+ class: "tok-comment"
2845
+ },
2846
+ {
2847
+ tag: tags.meta,
2848
+ class: "tok-meta"
2849
+ },
2850
+ {
2851
+ tag: tags.invalid,
2852
+ class: "tok-invalid"
2853
+ },
2854
+ {
2855
+ tag: tags.punctuation,
2856
+ class: "tok-punctuation"
2857
+ }
2858
+ ]);
2859
+ //#endregion
2860
+ export { tags as a, NodeProp as c, NodeWeakMap as d, Parser as f, StyleModule as g, parseMixed as h, tagHighlighter as i, NodeSet as l, TreeFragment as m, highlightTree as n, DefaultBufferLength as o, Tree as p, styleTags as r, IterMode as s, Tag as t, NodeType as u };