@progressive-development/pd-content 1.0.3 → 1.1.1

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 (84) hide show
  1. package/dist/index.d.ts +2 -4
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +0 -4
  4. package/dist/node_modules/.pnpm/@codemirror_autocomplete@6.20.1/node_modules/@codemirror/autocomplete/dist/index.js +550 -0
  5. package/dist/node_modules/.pnpm/@codemirror_lang-css@6.3.1/node_modules/@codemirror/lang-css/dist/index.js +264 -0
  6. package/dist/node_modules/.pnpm/@codemirror_lang-html@6.4.11/node_modules/@codemirror/lang-html/dist/index.js +661 -0
  7. package/dist/node_modules/.pnpm/@codemirror_lang-java@6.0.2/node_modules/@codemirror/lang-java/dist/index.js +44 -0
  8. package/dist/node_modules/.pnpm/@codemirror_lang-javascript@6.2.5/node_modules/@codemirror/lang-javascript/dist/index.js +346 -0
  9. package/dist/node_modules/.pnpm/@codemirror_lang-json@6.0.2/node_modules/@codemirror/lang-json/dist/index.js +32 -0
  10. package/dist/node_modules/.pnpm/@codemirror_lang-markdown@6.5.0/node_modules/@codemirror/lang-markdown/dist/index.js +492 -0
  11. package/dist/node_modules/.pnpm/@codemirror_lang-python@6.2.1/node_modules/@codemirror/lang-python/dist/index.js +308 -0
  12. package/dist/node_modules/.pnpm/@codemirror_language@6.12.3/node_modules/@codemirror/language/dist/index.js +1572 -0
  13. package/dist/node_modules/.pnpm/@codemirror_state@6.6.0/node_modules/@codemirror/state/dist/index.js +3881 -0
  14. package/dist/node_modules/.pnpm/@codemirror_view@6.40.0/node_modules/@codemirror/view/dist/index.js +9657 -0
  15. package/dist/node_modules/.pnpm/@lezer_common@1.5.1/node_modules/@lezer/common/dist/index.js +2196 -0
  16. package/dist/node_modules/.pnpm/@lezer_css@1.3.3/node_modules/@lezer/css/dist/index.js +147 -0
  17. package/dist/node_modules/.pnpm/@lezer_highlight@1.2.3/node_modules/@lezer/highlight/dist/index.js +898 -0
  18. package/dist/node_modules/.pnpm/@lezer_html@1.3.13/node_modules/@lezer/html/dist/index.js +349 -0
  19. package/dist/node_modules/.pnpm/@lezer_java@1.1.3/node_modules/@lezer/java/dist/index.js +67 -0
  20. package/dist/node_modules/.pnpm/@lezer_javascript@1.5.4/node_modules/@lezer/javascript/dist/index.js +192 -0
  21. package/dist/node_modules/.pnpm/@lezer_json@1.0.3/node_modules/@lezer/json/dist/index.js +37 -0
  22. package/dist/node_modules/.pnpm/@lezer_lr@1.4.8/node_modules/@lezer/lr/dist/index.js +1884 -0
  23. package/dist/node_modules/.pnpm/@lezer_markdown@1.6.3/node_modules/@lezer/markdown/dist/index.js +2335 -0
  24. package/dist/node_modules/.pnpm/@lezer_python@1.1.18/node_modules/@lezer/python/dist/index.js +326 -0
  25. package/dist/node_modules/.pnpm/@marijn_find-cluster-break@1.0.2/node_modules/@marijn/find-cluster-break/src/index.js +82 -0
  26. package/dist/node_modules/.pnpm/style-mod@4.1.3/node_modules/style-mod/src/style-mod.js +174 -0
  27. package/dist/node_modules/.pnpm/w3c-keyname@2.2.8/node_modules/w3c-keyname/index.js +121 -0
  28. package/dist/pd-badge-order/PdBadgeItem.d.ts +11 -0
  29. package/dist/pd-badge-order/PdBadgeItem.d.ts.map +1 -1
  30. package/dist/pd-badge-order/PdBadgeItem.js +162 -10
  31. package/dist/pd-badge-order/PdBadgeOrder.d.ts +56 -17
  32. package/dist/pd-badge-order/PdBadgeOrder.d.ts.map +1 -1
  33. package/dist/pd-badge-order/PdBadgeOrder.js +308 -153
  34. package/dist/pd-badge-order/types.js +3 -1
  35. package/dist/pd-code-snippet/PdCodeSnippet.d.ts +29 -0
  36. package/dist/pd-code-snippet/PdCodeSnippet.d.ts.map +1 -1
  37. package/dist/pd-code-snippet/PdCodeSnippet.js +117 -67
  38. package/dist/pd-code-snippet/codemirror-setup.d.ts +10 -0
  39. package/dist/pd-code-snippet/codemirror-setup.d.ts.map +1 -0
  40. package/dist/pd-code-snippet/codemirror-setup.js +101 -0
  41. package/dist/pd-loading-state/PdLoadingState.d.ts +4 -1
  42. package/dist/pd-loading-state/PdLoadingState.d.ts.map +1 -1
  43. package/dist/pd-loading-state/pd-loading-state.d.ts +1 -1
  44. package/dist/pd-loading-state/pd-loading-state.d.ts.map +1 -1
  45. package/dist/pd-loading-state/pd-logo-loader.js +2 -2
  46. package/dist/pd-more-info/PdMoreInfo.d.ts +52 -4
  47. package/dist/pd-more-info/PdMoreInfo.d.ts.map +1 -1
  48. package/dist/pd-more-info/PdMoreInfo.js +146 -24
  49. package/dist/pd-notice-box/PdNoticeBox.d.ts +8 -1
  50. package/dist/pd-notice-box/PdNoticeBox.d.ts.map +1 -1
  51. package/dist/pd-notice-box/PdNoticeBox.js +41 -2
  52. package/dist/pd-panel-viewer/PdPanel.d.ts +3 -0
  53. package/dist/pd-panel-viewer/PdPanel.d.ts.map +1 -1
  54. package/dist/pd-panel-viewer/PdPanel.js +8 -1
  55. package/dist/pd-panel-viewer/PdPanelViewer.d.ts +3 -0
  56. package/dist/pd-panel-viewer/PdPanelViewer.d.ts.map +1 -1
  57. package/dist/pd-panel-viewer/PdPanelViewer.js +59 -26
  58. package/dist/pd-tab/PdTab.d.ts +8 -5
  59. package/dist/pd-tab/PdTab.d.ts.map +1 -1
  60. package/dist/pd-tab/PdTab.js +110 -56
  61. package/dist/pd-timeline/PdTimeline.d.ts +2 -0
  62. package/dist/pd-timeline/PdTimeline.d.ts.map +1 -1
  63. package/dist/pd-timeline/PdTimeline.js +50 -19
  64. package/dist/types.d.ts +2 -2
  65. package/dist/types.d.ts.map +1 -1
  66. package/package.json +16 -8
  67. package/dist/pd-gallery/PdGallery.d.ts +0 -72
  68. package/dist/pd-gallery/PdGallery.d.ts.map +0 -1
  69. package/dist/pd-gallery/PdGallery.js +0 -660
  70. package/dist/pd-gallery/PdGalleryLightbox.d.ts +0 -53
  71. package/dist/pd-gallery/PdGalleryLightbox.d.ts.map +0 -1
  72. package/dist/pd-gallery/PdGalleryLightbox.js +0 -530
  73. package/dist/pd-gallery/index.d.ts +0 -4
  74. package/dist/pd-gallery/index.d.ts.map +0 -1
  75. package/dist/pd-gallery/pd-gallery-lightbox.d.ts +0 -3
  76. package/dist/pd-gallery/pd-gallery-lightbox.d.ts.map +0 -1
  77. package/dist/pd-gallery/pd-gallery.d.ts +0 -3
  78. package/dist/pd-gallery/pd-gallery.d.ts.map +0 -1
  79. package/dist/pd-gallery/types.d.ts +0 -23
  80. package/dist/pd-gallery/types.d.ts.map +0 -1
  81. package/dist/pd-gallery-lightbox.d.ts +0 -2
  82. package/dist/pd-gallery-lightbox.js +0 -8
  83. package/dist/pd-gallery.d.ts +0 -2
  84. package/dist/pd-gallery.js +0 -8
@@ -0,0 +1,1572 @@
1
+ import { NodeProp, Tree, IterMode, TreeFragment, Parser, NodeType } from '../../../../../@lezer_common@1.5.1/node_modules/@lezer/common/dist/index.js';
2
+ import { EditorState, Facet, combineConfig, Prec, countColumn, RangeSetBuilder, StateEffect, StateField } from '../../../../../@codemirror_state@6.6.0/node_modules/@codemirror/state/dist/index.js';
3
+ import { EditorView, ViewPlugin, Decoration, logException, Direction } from '../../../../../@codemirror_view@6.40.0/node_modules/@codemirror/view/dist/index.js';
4
+ import { tagHighlighter, tags, highlightTree, styleTags } from '../../../../../@lezer_highlight@1.2.3/node_modules/@lezer/highlight/dist/index.js';
5
+ import { StyleModule } from '../../../../../style-mod@4.1.3/node_modules/style-mod/src/style-mod.js';
6
+
7
+ var _a;
8
+ /**
9
+ Node prop stored in a parser's top syntax node to provide the
10
+ facet that stores language-specific data for that language.
11
+ */
12
+ const languageDataProp = /*@__PURE__*/new NodeProp();
13
+ /**
14
+ Helper function to define a facet (to be added to the top syntax
15
+ node(s) for a language via
16
+ [`languageDataProp`](https://codemirror.net/6/docs/ref/#language.languageDataProp)), that will be
17
+ used to associate language data with the language. You
18
+ probably only need this when subclassing
19
+ [`Language`](https://codemirror.net/6/docs/ref/#language.Language).
20
+ */
21
+ function defineLanguageFacet(baseData) {
22
+ return Facet.define({
23
+ combine: baseData ? values => values.concat(baseData) : undefined
24
+ });
25
+ }
26
+ /**
27
+ Syntax node prop used to register sublanguages. Should be added to
28
+ the top level node type for the language.
29
+ */
30
+ const sublanguageProp = /*@__PURE__*/new NodeProp();
31
+ /**
32
+ A language object manages parsing and per-language
33
+ [metadata](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt). Parse data is
34
+ managed as a [Lezer](https://lezer.codemirror.net) tree. The class
35
+ can be used directly, via the [`LRLanguage`](https://codemirror.net/6/docs/ref/#language.LRLanguage)
36
+ subclass for [Lezer](https://lezer.codemirror.net/) LR parsers, or
37
+ via the [`StreamLanguage`](https://codemirror.net/6/docs/ref/#language.StreamLanguage) subclass
38
+ for stream parsers.
39
+ */
40
+ class Language {
41
+ /**
42
+ Construct a language object. If you need to invoke this
43
+ directly, first define a data facet with
44
+ [`defineLanguageFacet`](https://codemirror.net/6/docs/ref/#language.defineLanguageFacet), and then
45
+ configure your parser to [attach](https://codemirror.net/6/docs/ref/#language.languageDataProp) it
46
+ to the language's outer syntax node.
47
+ */
48
+ constructor(
49
+ /**
50
+ The [language data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt) facet
51
+ used for this language.
52
+ */
53
+ data, parser, extraExtensions = [],
54
+ /**
55
+ A language name.
56
+ */
57
+ name = "") {
58
+ this.data = data;
59
+ this.name = name;
60
+ // Kludge to define EditorState.tree as a debugging helper,
61
+ // without the EditorState package actually knowing about
62
+ // languages and lezer trees.
63
+ if (!EditorState.prototype.hasOwnProperty("tree"))
64
+ Object.defineProperty(EditorState.prototype, "tree", { get() { return syntaxTree(this); } });
65
+ this.parser = parser;
66
+ this.extension = [
67
+ language.of(this),
68
+ EditorState.languageData.of((state, pos, side) => {
69
+ let top = topNodeAt(state, pos, side), data = top.type.prop(languageDataProp);
70
+ if (!data)
71
+ return [];
72
+ let base = state.facet(data), sub = top.type.prop(sublanguageProp);
73
+ if (sub) {
74
+ let innerNode = top.resolve(pos - top.from, side);
75
+ for (let sublang of sub)
76
+ if (sublang.test(innerNode, state)) {
77
+ let data = state.facet(sublang.facet);
78
+ return sublang.type == "replace" ? data : data.concat(base);
79
+ }
80
+ }
81
+ return base;
82
+ })
83
+ ].concat(extraExtensions);
84
+ }
85
+ /**
86
+ Query whether this language is active at the given position.
87
+ */
88
+ isActiveAt(state, pos, side = -1) {
89
+ return topNodeAt(state, pos, side).type.prop(languageDataProp) == this.data;
90
+ }
91
+ /**
92
+ Find the document regions that were parsed using this language.
93
+ The returned regions will _include_ any nested languages rooted
94
+ in this language, when those exist.
95
+ */
96
+ findRegions(state) {
97
+ let lang = state.facet(language);
98
+ if ((lang === null || lang === void 0 ? void 0 : lang.data) == this.data)
99
+ return [{ from: 0, to: state.doc.length }];
100
+ if (!lang || !lang.allowsNesting)
101
+ return [];
102
+ let result = [];
103
+ let explore = (tree, from) => {
104
+ if (tree.prop(languageDataProp) == this.data) {
105
+ result.push({ from, to: from + tree.length });
106
+ return;
107
+ }
108
+ let mount = tree.prop(NodeProp.mounted);
109
+ if (mount) {
110
+ if (mount.tree.prop(languageDataProp) == this.data) {
111
+ if (mount.overlay)
112
+ for (let r of mount.overlay)
113
+ result.push({ from: r.from + from, to: r.to + from });
114
+ else
115
+ result.push({ from: from, to: from + tree.length });
116
+ return;
117
+ }
118
+ else if (mount.overlay) {
119
+ let size = result.length;
120
+ explore(mount.tree, mount.overlay[0].from + from);
121
+ if (result.length > size)
122
+ return;
123
+ }
124
+ }
125
+ for (let i = 0; i < tree.children.length; i++) {
126
+ let ch = tree.children[i];
127
+ if (ch instanceof Tree)
128
+ explore(ch, tree.positions[i] + from);
129
+ }
130
+ };
131
+ explore(syntaxTree(state), 0);
132
+ return result;
133
+ }
134
+ /**
135
+ Indicates whether this language allows nested languages. The
136
+ default implementation returns true.
137
+ */
138
+ get allowsNesting() { return true; }
139
+ }
140
+ /**
141
+ @internal
142
+ */
143
+ Language.setState = /*@__PURE__*/StateEffect.define();
144
+ function topNodeAt(state, pos, side) {
145
+ let topLang = state.facet(language), tree = syntaxTree(state).topNode;
146
+ if (!topLang || topLang.allowsNesting) {
147
+ for (let node = tree; node; node = node.enter(pos, side, IterMode.ExcludeBuffers | IterMode.EnterBracketed))
148
+ if (node.type.isTop)
149
+ tree = node;
150
+ }
151
+ return tree;
152
+ }
153
+ /**
154
+ A subclass of [`Language`](https://codemirror.net/6/docs/ref/#language.Language) for use with Lezer
155
+ [LR parsers](https://lezer.codemirror.net/docs/ref#lr.LRParser)
156
+ parsers.
157
+ */
158
+ class LRLanguage extends Language {
159
+ constructor(data, parser, name) {
160
+ super(data, parser, [], name);
161
+ this.parser = parser;
162
+ }
163
+ /**
164
+ Define a language from a parser.
165
+ */
166
+ static define(spec) {
167
+ let data = defineLanguageFacet(spec.languageData);
168
+ return new LRLanguage(data, spec.parser.configure({
169
+ props: [languageDataProp.add(type => type.isTop ? data : undefined)]
170
+ }), spec.name);
171
+ }
172
+ /**
173
+ Create a new instance of this language with a reconfigured
174
+ version of its parser and optionally a new name.
175
+ */
176
+ configure(options, name) {
177
+ return new LRLanguage(this.data, this.parser.configure(options), name || this.name);
178
+ }
179
+ get allowsNesting() { return this.parser.hasWrappers(); }
180
+ }
181
+ /**
182
+ Get the syntax tree for a state, which is the current (possibly
183
+ incomplete) parse tree of the active
184
+ [language](https://codemirror.net/6/docs/ref/#language.Language), or the empty tree if there is no
185
+ language available.
186
+ */
187
+ function syntaxTree(state) {
188
+ let field = state.field(Language.state, false);
189
+ return field ? field.tree : Tree.empty;
190
+ }
191
+ /**
192
+ Lezer-style
193
+ [`Input`](https://lezer.codemirror.net/docs/ref#common.Input)
194
+ object for a [`Text`](https://codemirror.net/6/docs/ref/#state.Text) object.
195
+ */
196
+ class DocInput {
197
+ /**
198
+ Create an input object for the given document.
199
+ */
200
+ constructor(doc) {
201
+ this.doc = doc;
202
+ this.cursorPos = 0;
203
+ this.string = "";
204
+ this.cursor = doc.iter();
205
+ }
206
+ get length() { return this.doc.length; }
207
+ syncTo(pos) {
208
+ this.string = this.cursor.next(pos - this.cursorPos).value;
209
+ this.cursorPos = pos + this.string.length;
210
+ return this.cursorPos - this.string.length;
211
+ }
212
+ chunk(pos) {
213
+ this.syncTo(pos);
214
+ return this.string;
215
+ }
216
+ get lineChunks() { return true; }
217
+ read(from, to) {
218
+ let stringStart = this.cursorPos - this.string.length;
219
+ if (from < stringStart || to >= this.cursorPos)
220
+ return this.doc.sliceString(from, to);
221
+ else
222
+ return this.string.slice(from - stringStart, to - stringStart);
223
+ }
224
+ }
225
+ let currentContext = null;
226
+ /**
227
+ A parse context provided to parsers working on the editor content.
228
+ */
229
+ class ParseContext {
230
+ constructor(parser,
231
+ /**
232
+ The current editor state.
233
+ */
234
+ state,
235
+ /**
236
+ Tree fragments that can be reused by incremental re-parses.
237
+ */
238
+ fragments = [],
239
+ /**
240
+ @internal
241
+ */
242
+ tree,
243
+ /**
244
+ @internal
245
+ */
246
+ treeLen,
247
+ /**
248
+ The current editor viewport (or some overapproximation
249
+ thereof). Intended to be used for opportunistically avoiding
250
+ work (in which case
251
+ [`skipUntilInView`](https://codemirror.net/6/docs/ref/#language.ParseContext.skipUntilInView)
252
+ should be called to make sure the parser is restarted when the
253
+ skipped region becomes visible).
254
+ */
255
+ viewport,
256
+ /**
257
+ @internal
258
+ */
259
+ skipped,
260
+ /**
261
+ This is where skipping parsers can register a promise that,
262
+ when resolved, will schedule a new parse. It is cleared when
263
+ the parse worker picks up the promise. @internal
264
+ */
265
+ scheduleOn) {
266
+ this.parser = parser;
267
+ this.state = state;
268
+ this.fragments = fragments;
269
+ this.tree = tree;
270
+ this.treeLen = treeLen;
271
+ this.viewport = viewport;
272
+ this.skipped = skipped;
273
+ this.scheduleOn = scheduleOn;
274
+ this.parse = null;
275
+ /**
276
+ @internal
277
+ */
278
+ this.tempSkipped = [];
279
+ }
280
+ /**
281
+ @internal
282
+ */
283
+ static create(parser, state, viewport) {
284
+ return new ParseContext(parser, state, [], Tree.empty, 0, viewport, [], null);
285
+ }
286
+ startParse() {
287
+ return this.parser.startParse(new DocInput(this.state.doc), this.fragments);
288
+ }
289
+ /**
290
+ @internal
291
+ */
292
+ work(until, upto) {
293
+ if (upto != null && upto >= this.state.doc.length)
294
+ upto = undefined;
295
+ if (this.tree != Tree.empty && this.isDone(upto !== null && upto !== void 0 ? upto : this.state.doc.length)) {
296
+ this.takeTree();
297
+ return true;
298
+ }
299
+ return this.withContext(() => {
300
+ var _a;
301
+ if (typeof until == "number") {
302
+ let endTime = Date.now() + until;
303
+ until = () => Date.now() > endTime;
304
+ }
305
+ if (!this.parse)
306
+ this.parse = this.startParse();
307
+ if (upto != null && (this.parse.stoppedAt == null || this.parse.stoppedAt > upto) &&
308
+ upto < this.state.doc.length)
309
+ this.parse.stopAt(upto);
310
+ for (;;) {
311
+ let done = this.parse.advance();
312
+ if (done) {
313
+ this.fragments = this.withoutTempSkipped(TreeFragment.addTree(done, this.fragments, this.parse.stoppedAt != null));
314
+ this.treeLen = (_a = this.parse.stoppedAt) !== null && _a !== void 0 ? _a : this.state.doc.length;
315
+ this.tree = done;
316
+ this.parse = null;
317
+ if (this.treeLen < (upto !== null && upto !== void 0 ? upto : this.state.doc.length))
318
+ this.parse = this.startParse();
319
+ else
320
+ return true;
321
+ }
322
+ if (until())
323
+ return false;
324
+ }
325
+ });
326
+ }
327
+ /**
328
+ @internal
329
+ */
330
+ takeTree() {
331
+ let pos, tree;
332
+ if (this.parse && (pos = this.parse.parsedPos) >= this.treeLen) {
333
+ if (this.parse.stoppedAt == null || this.parse.stoppedAt > pos)
334
+ this.parse.stopAt(pos);
335
+ this.withContext(() => { while (!(tree = this.parse.advance())) { } });
336
+ this.treeLen = pos;
337
+ this.tree = tree;
338
+ this.fragments = this.withoutTempSkipped(TreeFragment.addTree(this.tree, this.fragments, true));
339
+ this.parse = null;
340
+ }
341
+ }
342
+ withContext(f) {
343
+ let prev = currentContext;
344
+ currentContext = this;
345
+ try {
346
+ return f();
347
+ }
348
+ finally {
349
+ currentContext = prev;
350
+ }
351
+ }
352
+ withoutTempSkipped(fragments) {
353
+ for (let r; r = this.tempSkipped.pop();)
354
+ fragments = cutFragments(fragments, r.from, r.to);
355
+ return fragments;
356
+ }
357
+ /**
358
+ @internal
359
+ */
360
+ changes(changes, newState) {
361
+ let { fragments, tree, treeLen, viewport, skipped } = this;
362
+ this.takeTree();
363
+ if (!changes.empty) {
364
+ let ranges = [];
365
+ changes.iterChangedRanges((fromA, toA, fromB, toB) => ranges.push({ fromA, toA, fromB, toB }));
366
+ fragments = TreeFragment.applyChanges(fragments, ranges);
367
+ tree = Tree.empty;
368
+ treeLen = 0;
369
+ viewport = { from: changes.mapPos(viewport.from, -1), to: changes.mapPos(viewport.to, 1) };
370
+ if (this.skipped.length) {
371
+ skipped = [];
372
+ for (let r of this.skipped) {
373
+ let from = changes.mapPos(r.from, 1), to = changes.mapPos(r.to, -1);
374
+ if (from < to)
375
+ skipped.push({ from, to });
376
+ }
377
+ }
378
+ }
379
+ return new ParseContext(this.parser, newState, fragments, tree, treeLen, viewport, skipped, this.scheduleOn);
380
+ }
381
+ /**
382
+ @internal
383
+ */
384
+ updateViewport(viewport) {
385
+ if (this.viewport.from == viewport.from && this.viewport.to == viewport.to)
386
+ return false;
387
+ this.viewport = viewport;
388
+ let startLen = this.skipped.length;
389
+ for (let i = 0; i < this.skipped.length; i++) {
390
+ let { from, to } = this.skipped[i];
391
+ if (from < viewport.to && to > viewport.from) {
392
+ this.fragments = cutFragments(this.fragments, from, to);
393
+ this.skipped.splice(i--, 1);
394
+ }
395
+ }
396
+ if (this.skipped.length >= startLen)
397
+ return false;
398
+ this.reset();
399
+ return true;
400
+ }
401
+ /**
402
+ @internal
403
+ */
404
+ reset() {
405
+ if (this.parse) {
406
+ this.takeTree();
407
+ this.parse = null;
408
+ }
409
+ }
410
+ /**
411
+ Notify the parse scheduler that the given region was skipped
412
+ because it wasn't in view, and the parse should be restarted
413
+ when it comes into view.
414
+ */
415
+ skipUntilInView(from, to) {
416
+ this.skipped.push({ from, to });
417
+ }
418
+ /**
419
+ Returns a parser intended to be used as placeholder when
420
+ asynchronously loading a nested parser. It'll skip its input and
421
+ mark it as not-really-parsed, so that the next update will parse
422
+ it again.
423
+
424
+ When `until` is given, a reparse will be scheduled when that
425
+ promise resolves.
426
+ */
427
+ static getSkippingParser(until) {
428
+ return new class extends Parser {
429
+ createParse(input, fragments, ranges) {
430
+ let from = ranges[0].from, to = ranges[ranges.length - 1].to;
431
+ let parser = {
432
+ parsedPos: from,
433
+ advance() {
434
+ let cx = currentContext;
435
+ if (cx) {
436
+ for (let r of ranges)
437
+ cx.tempSkipped.push(r);
438
+ if (until)
439
+ cx.scheduleOn = cx.scheduleOn ? Promise.all([cx.scheduleOn, until]) : until;
440
+ }
441
+ this.parsedPos = to;
442
+ return new Tree(NodeType.none, [], [], to - from);
443
+ },
444
+ stoppedAt: null,
445
+ stopAt() { }
446
+ };
447
+ return parser;
448
+ }
449
+ };
450
+ }
451
+ /**
452
+ @internal
453
+ */
454
+ isDone(upto) {
455
+ upto = Math.min(upto, this.state.doc.length);
456
+ let frags = this.fragments;
457
+ return this.treeLen >= upto && frags.length && frags[0].from == 0 && frags[0].to >= upto;
458
+ }
459
+ /**
460
+ Get the context for the current parse, or `null` if no editor
461
+ parse is in progress.
462
+ */
463
+ static get() { return currentContext; }
464
+ }
465
+ function cutFragments(fragments, from, to) {
466
+ return TreeFragment.applyChanges(fragments, [{ fromA: from, toA: to, fromB: from, toB: to }]);
467
+ }
468
+ class LanguageState {
469
+ constructor(
470
+ // A mutable parse state that is used to preserve work done during
471
+ // the lifetime of a state when moving to the next state.
472
+ context) {
473
+ this.context = context;
474
+ this.tree = context.tree;
475
+ }
476
+ apply(tr) {
477
+ if (!tr.docChanged && this.tree == this.context.tree)
478
+ return this;
479
+ let newCx = this.context.changes(tr.changes, tr.state);
480
+ // If the previous parse wasn't done, go forward only up to its
481
+ // end position or the end of the viewport, to avoid slowing down
482
+ // state updates with parse work beyond the viewport.
483
+ let upto = this.context.treeLen == tr.startState.doc.length ? undefined
484
+ : Math.max(tr.changes.mapPos(this.context.treeLen), newCx.viewport.to);
485
+ if (!newCx.work(20 /* Work.Apply */, upto))
486
+ newCx.takeTree();
487
+ return new LanguageState(newCx);
488
+ }
489
+ static init(state) {
490
+ let vpTo = Math.min(3000 /* Work.InitViewport */, state.doc.length);
491
+ let parseState = ParseContext.create(state.facet(language).parser, state, { from: 0, to: vpTo });
492
+ if (!parseState.work(20 /* Work.Apply */, vpTo))
493
+ parseState.takeTree();
494
+ return new LanguageState(parseState);
495
+ }
496
+ }
497
+ Language.state = /*@__PURE__*/StateField.define({
498
+ create: LanguageState.init,
499
+ update(value, tr) {
500
+ for (let e of tr.effects)
501
+ if (e.is(Language.setState))
502
+ return e.value;
503
+ if (tr.startState.facet(language) != tr.state.facet(language))
504
+ return LanguageState.init(tr.state);
505
+ return value.apply(tr);
506
+ }
507
+ });
508
+ let requestIdle = (callback) => {
509
+ let timeout = setTimeout(() => callback(), 500 /* Work.MaxPause */);
510
+ return () => clearTimeout(timeout);
511
+ };
512
+ if (typeof requestIdleCallback != "undefined")
513
+ requestIdle = (callback) => {
514
+ let idle = -1, timeout = setTimeout(() => {
515
+ idle = requestIdleCallback(callback, { timeout: 500 /* Work.MaxPause */ - 100 /* Work.MinPause */ });
516
+ }, 100 /* Work.MinPause */);
517
+ return () => idle < 0 ? clearTimeout(timeout) : cancelIdleCallback(idle);
518
+ };
519
+ const isInputPending = typeof navigator != "undefined" && ((_a = navigator.scheduling) === null || _a === void 0 ? void 0 : _a.isInputPending)
520
+ ? () => navigator.scheduling.isInputPending() : null;
521
+ const parseWorker = /*@__PURE__*/ViewPlugin.fromClass(class ParseWorker {
522
+ constructor(view) {
523
+ this.view = view;
524
+ this.working = null;
525
+ this.workScheduled = 0;
526
+ // End of the current time chunk
527
+ this.chunkEnd = -1;
528
+ // Milliseconds of budget left for this chunk
529
+ this.chunkBudget = -1;
530
+ this.work = this.work.bind(this);
531
+ this.scheduleWork();
532
+ }
533
+ update(update) {
534
+ let cx = this.view.state.field(Language.state).context;
535
+ if (cx.updateViewport(update.view.viewport) || this.view.viewport.to > cx.treeLen)
536
+ this.scheduleWork();
537
+ if (update.docChanged || update.selectionSet) {
538
+ if (this.view.hasFocus)
539
+ this.chunkBudget += 50 /* Work.ChangeBonus */;
540
+ this.scheduleWork();
541
+ }
542
+ this.checkAsyncSchedule(cx);
543
+ }
544
+ scheduleWork() {
545
+ if (this.working)
546
+ return;
547
+ let { state } = this.view, field = state.field(Language.state);
548
+ if (field.tree != field.context.tree || !field.context.isDone(state.doc.length))
549
+ this.working = requestIdle(this.work);
550
+ }
551
+ work(deadline) {
552
+ this.working = null;
553
+ let now = Date.now();
554
+ if (this.chunkEnd < now && (this.chunkEnd < 0 || this.view.hasFocus)) { // Start a new chunk
555
+ this.chunkEnd = now + 30000 /* Work.ChunkTime */;
556
+ this.chunkBudget = 3000 /* Work.ChunkBudget */;
557
+ }
558
+ if (this.chunkBudget <= 0)
559
+ return; // No more budget
560
+ let { state, viewport: { to: vpTo } } = this.view, field = state.field(Language.state);
561
+ if (field.tree == field.context.tree && field.context.isDone(vpTo + 100000 /* Work.MaxParseAhead */))
562
+ return;
563
+ let endTime = Date.now() + Math.min(this.chunkBudget, 100 /* Work.Slice */, deadline && !isInputPending ? Math.max(25 /* Work.MinSlice */, deadline.timeRemaining() - 5) : 1e9);
564
+ let viewportFirst = field.context.treeLen < vpTo && state.doc.length > vpTo + 1000;
565
+ let done = field.context.work(() => {
566
+ return isInputPending && isInputPending() || Date.now() > endTime;
567
+ }, vpTo + (viewportFirst ? 0 : 100000 /* Work.MaxParseAhead */));
568
+ this.chunkBudget -= Date.now() - now;
569
+ if (done || this.chunkBudget <= 0) {
570
+ field.context.takeTree();
571
+ this.view.dispatch({ effects: Language.setState.of(new LanguageState(field.context)) });
572
+ }
573
+ if (this.chunkBudget > 0 && !(done && !viewportFirst))
574
+ this.scheduleWork();
575
+ this.checkAsyncSchedule(field.context);
576
+ }
577
+ checkAsyncSchedule(cx) {
578
+ if (cx.scheduleOn) {
579
+ this.workScheduled++;
580
+ cx.scheduleOn
581
+ .then(() => this.scheduleWork())
582
+ .catch(err => logException(this.view.state, err))
583
+ .then(() => this.workScheduled--);
584
+ cx.scheduleOn = null;
585
+ }
586
+ }
587
+ destroy() {
588
+ if (this.working)
589
+ this.working();
590
+ }
591
+ isWorking() {
592
+ return !!(this.working || this.workScheduled > 0);
593
+ }
594
+ }, {
595
+ eventHandlers: { focus() { this.scheduleWork(); } }
596
+ });
597
+ /**
598
+ The facet used to associate a language with an editor state. Used
599
+ by `Language` object's `extension` property (so you don't need to
600
+ manually wrap your languages in this). Can be used to access the
601
+ current language on a state.
602
+ */
603
+ const language = /*@__PURE__*/Facet.define({
604
+ combine(languages) { return languages.length ? languages[0] : null; },
605
+ enables: language => [
606
+ Language.state,
607
+ parseWorker,
608
+ EditorView.contentAttributes.compute([language], state => {
609
+ let lang = state.facet(language);
610
+ return lang && lang.name ? { "data-language": lang.name } : {};
611
+ })
612
+ ]
613
+ });
614
+ /**
615
+ This class bundles a [language](https://codemirror.net/6/docs/ref/#language.Language) with an
616
+ optional set of supporting extensions. Language packages are
617
+ encouraged to export a function that optionally takes a
618
+ configuration object and returns a `LanguageSupport` instance, as
619
+ the main way for client code to use the package.
620
+ */
621
+ class LanguageSupport {
622
+ /**
623
+ Create a language support object.
624
+ */
625
+ constructor(
626
+ /**
627
+ The language object.
628
+ */
629
+ language,
630
+ /**
631
+ An optional set of supporting extensions. When nesting a
632
+ language in another language, the outer language is encouraged
633
+ to include the supporting extensions for its inner languages
634
+ in its own set of support extensions.
635
+ */
636
+ support = []) {
637
+ this.language = language;
638
+ this.support = support;
639
+ this.extension = [language, support];
640
+ }
641
+ }
642
+ /**
643
+ Language descriptions are used to store metadata about languages
644
+ and to dynamically load them. Their main role is finding the
645
+ appropriate language for a filename or dynamically loading nested
646
+ parsers.
647
+ */
648
+ class LanguageDescription {
649
+ constructor(
650
+ /**
651
+ The name of this language.
652
+ */
653
+ name,
654
+ /**
655
+ Alternative names for the mode (lowercased, includes `this.name`).
656
+ */
657
+ alias,
658
+ /**
659
+ File extensions associated with this language.
660
+ */
661
+ extensions,
662
+ /**
663
+ Optional filename pattern that should be associated with this
664
+ language.
665
+ */
666
+ filename, loadFunc,
667
+ /**
668
+ If the language has been loaded, this will hold its value.
669
+ */
670
+ support = undefined) {
671
+ this.name = name;
672
+ this.alias = alias;
673
+ this.extensions = extensions;
674
+ this.filename = filename;
675
+ this.loadFunc = loadFunc;
676
+ this.support = support;
677
+ this.loading = null;
678
+ }
679
+ /**
680
+ Start loading the the language. Will return a promise that
681
+ resolves to a [`LanguageSupport`](https://codemirror.net/6/docs/ref/#language.LanguageSupport)
682
+ object when the language successfully loads.
683
+ */
684
+ load() {
685
+ return this.loading || (this.loading = this.loadFunc().then(support => this.support = support, err => { this.loading = null; throw err; }));
686
+ }
687
+ /**
688
+ Create a language description.
689
+ */
690
+ static of(spec) {
691
+ let { load, support } = spec;
692
+ if (!load) {
693
+ if (!support)
694
+ throw new RangeError("Must pass either 'load' or 'support' to LanguageDescription.of");
695
+ load = () => Promise.resolve(support);
696
+ }
697
+ return new LanguageDescription(spec.name, (spec.alias || []).concat(spec.name).map(s => s.toLowerCase()), spec.extensions || [], spec.filename, load, support);
698
+ }
699
+ /**
700
+ Look for a language in the given array of descriptions that
701
+ matches the filename. Will first match
702
+ [`filename`](https://codemirror.net/6/docs/ref/#language.LanguageDescription.filename) patterns,
703
+ and then [extensions](https://codemirror.net/6/docs/ref/#language.LanguageDescription.extensions),
704
+ and return the first language that matches.
705
+ */
706
+ static matchFilename(descs, filename) {
707
+ for (let d of descs)
708
+ if (d.filename && d.filename.test(filename))
709
+ return d;
710
+ let ext = /\.([^.]+)$/.exec(filename);
711
+ if (ext)
712
+ for (let d of descs)
713
+ if (d.extensions.indexOf(ext[1]) > -1)
714
+ return d;
715
+ return null;
716
+ }
717
+ /**
718
+ Look for a language whose name or alias matches the the given
719
+ name (case-insensitively). If `fuzzy` is true, and no direct
720
+ matchs is found, this'll also search for a language whose name
721
+ or alias occurs in the string (for names shorter than three
722
+ characters, only when surrounded by non-word characters).
723
+ */
724
+ static matchLanguageName(descs, name, fuzzy = true) {
725
+ name = name.toLowerCase();
726
+ for (let d of descs)
727
+ if (d.alias.some(a => a == name))
728
+ return d;
729
+ if (fuzzy)
730
+ for (let d of descs)
731
+ for (let a of d.alias) {
732
+ let found = name.indexOf(a);
733
+ if (found > -1 && (a.length > 2 || !/\w/.test(name[found - 1]) && !/\w/.test(name[found + a.length])))
734
+ return d;
735
+ }
736
+ return null;
737
+ }
738
+ }
739
+
740
+ /**
741
+ Facet that defines a way to provide a function that computes the
742
+ appropriate indentation depth, as a column number (see
743
+ [`indentString`](https://codemirror.net/6/docs/ref/#language.indentString)), at the start of a given
744
+ line. A return value of `null` indicates no indentation can be
745
+ determined, and the line should inherit the indentation of the one
746
+ above it. A return value of `undefined` defers to the next indent
747
+ service.
748
+ */
749
+ const indentService = /*@__PURE__*/Facet.define();
750
+ /**
751
+ Facet for overriding the unit by which indentation happens. Should
752
+ be a string consisting entirely of the same whitespace character.
753
+ When not set, this defaults to 2 spaces.
754
+ */
755
+ const indentUnit = /*@__PURE__*/Facet.define({
756
+ combine: values => {
757
+ if (!values.length)
758
+ return " ";
759
+ let unit = values[0];
760
+ if (!unit || /\S/.test(unit) || Array.from(unit).some(e => e != unit[0]))
761
+ throw new Error("Invalid indent unit: " + JSON.stringify(values[0]));
762
+ return unit;
763
+ }
764
+ });
765
+ /**
766
+ Return the _column width_ of an indent unit in the state.
767
+ Determined by the [`indentUnit`](https://codemirror.net/6/docs/ref/#language.indentUnit)
768
+ facet, and [`tabSize`](https://codemirror.net/6/docs/ref/#state.EditorState^tabSize) when that
769
+ contains tabs.
770
+ */
771
+ function getIndentUnit(state) {
772
+ let unit = state.facet(indentUnit);
773
+ return unit.charCodeAt(0) == 9 ? state.tabSize * unit.length : unit.length;
774
+ }
775
+ /**
776
+ Create an indentation string that covers columns 0 to `cols`.
777
+ Will use tabs for as much of the columns as possible when the
778
+ [`indentUnit`](https://codemirror.net/6/docs/ref/#language.indentUnit) facet contains
779
+ tabs.
780
+ */
781
+ function indentString(state, cols) {
782
+ let result = "", ts = state.tabSize, ch = state.facet(indentUnit)[0];
783
+ if (ch == "\t") {
784
+ while (cols >= ts) {
785
+ result += "\t";
786
+ cols -= ts;
787
+ }
788
+ ch = " ";
789
+ }
790
+ for (let i = 0; i < cols; i++)
791
+ result += ch;
792
+ return result;
793
+ }
794
+ /**
795
+ Get the indentation, as a column number, at the given position.
796
+ Will first consult any [indent services](https://codemirror.net/6/docs/ref/#language.indentService)
797
+ that are registered, and if none of those return an indentation,
798
+ this will check the syntax tree for the [indent node
799
+ prop](https://codemirror.net/6/docs/ref/#language.indentNodeProp) and use that if found. Returns a
800
+ number when an indentation could be determined, and null
801
+ otherwise.
802
+ */
803
+ function getIndentation(context, pos) {
804
+ if (context instanceof EditorState)
805
+ context = new IndentContext(context);
806
+ for (let service of context.state.facet(indentService)) {
807
+ let result = service(context, pos);
808
+ if (result !== undefined)
809
+ return result;
810
+ }
811
+ let tree = syntaxTree(context.state);
812
+ return tree.length >= pos ? syntaxIndentation(context, tree, pos) : null;
813
+ }
814
+ /**
815
+ Indentation contexts are used when calling [indentation
816
+ services](https://codemirror.net/6/docs/ref/#language.indentService). They provide helper utilities
817
+ useful in indentation logic, and can selectively override the
818
+ indentation reported for some lines.
819
+ */
820
+ class IndentContext {
821
+ /**
822
+ Create an indent context.
823
+ */
824
+ constructor(
825
+ /**
826
+ The editor state.
827
+ */
828
+ state,
829
+ /**
830
+ @internal
831
+ */
832
+ options = {}) {
833
+ this.state = state;
834
+ this.options = options;
835
+ this.unit = getIndentUnit(state);
836
+ }
837
+ /**
838
+ Get a description of the line at the given position, taking
839
+ [simulated line
840
+ breaks](https://codemirror.net/6/docs/ref/#language.IndentContext.constructor^options.simulateBreak)
841
+ into account. If there is such a break at `pos`, the `bias`
842
+ argument determines whether the part of the line line before or
843
+ after the break is used.
844
+ */
845
+ lineAt(pos, bias = 1) {
846
+ let line = this.state.doc.lineAt(pos);
847
+ let { simulateBreak, simulateDoubleBreak } = this.options;
848
+ if (simulateBreak != null && simulateBreak >= line.from && simulateBreak <= line.to) {
849
+ if (simulateDoubleBreak && simulateBreak == pos)
850
+ return { text: "", from: pos };
851
+ else if (bias < 0 ? simulateBreak < pos : simulateBreak <= pos)
852
+ return { text: line.text.slice(simulateBreak - line.from), from: simulateBreak };
853
+ else
854
+ return { text: line.text.slice(0, simulateBreak - line.from), from: line.from };
855
+ }
856
+ return line;
857
+ }
858
+ /**
859
+ Get the text directly after `pos`, either the entire line
860
+ or the next 100 characters, whichever is shorter.
861
+ */
862
+ textAfterPos(pos, bias = 1) {
863
+ if (this.options.simulateDoubleBreak && pos == this.options.simulateBreak)
864
+ return "";
865
+ let { text, from } = this.lineAt(pos, bias);
866
+ return text.slice(pos - from, Math.min(text.length, pos + 100 - from));
867
+ }
868
+ /**
869
+ Find the column for the given position.
870
+ */
871
+ column(pos, bias = 1) {
872
+ let { text, from } = this.lineAt(pos, bias);
873
+ let result = this.countColumn(text, pos - from);
874
+ let override = this.options.overrideIndentation ? this.options.overrideIndentation(from) : -1;
875
+ if (override > -1)
876
+ result += override - this.countColumn(text, text.search(/\S|$/));
877
+ return result;
878
+ }
879
+ /**
880
+ Find the column position (taking tabs into account) of the given
881
+ position in the given string.
882
+ */
883
+ countColumn(line, pos = line.length) {
884
+ return countColumn(line, this.state.tabSize, pos);
885
+ }
886
+ /**
887
+ Find the indentation column of the line at the given point.
888
+ */
889
+ lineIndent(pos, bias = 1) {
890
+ let { text, from } = this.lineAt(pos, bias);
891
+ let override = this.options.overrideIndentation;
892
+ if (override) {
893
+ let overriden = override(from);
894
+ if (overriden > -1)
895
+ return overriden;
896
+ }
897
+ return this.countColumn(text, text.search(/\S|$/));
898
+ }
899
+ /**
900
+ Returns the [simulated line
901
+ break](https://codemirror.net/6/docs/ref/#language.IndentContext.constructor^options.simulateBreak)
902
+ for this context, if any.
903
+ */
904
+ get simulatedBreak() {
905
+ return this.options.simulateBreak || null;
906
+ }
907
+ }
908
+ /**
909
+ A syntax tree node prop used to associate indentation strategies
910
+ with node types. Such a strategy is a function from an indentation
911
+ context to a column number (see also
912
+ [`indentString`](https://codemirror.net/6/docs/ref/#language.indentString)) or null, where null
913
+ indicates that no definitive indentation can be determined.
914
+ */
915
+ const indentNodeProp = /*@__PURE__*/new NodeProp();
916
+ // Compute the indentation for a given position from the syntax tree.
917
+ function syntaxIndentation(cx, ast, pos) {
918
+ let stack = ast.resolveStack(pos);
919
+ let inner = ast.resolveInner(pos, -1).resolve(pos, 0).enterUnfinishedNodesBefore(pos);
920
+ if (inner != stack.node) {
921
+ let add = [];
922
+ for (let cur = inner; cur && !(cur.from < stack.node.from || cur.to > stack.node.to ||
923
+ cur.from == stack.node.from && cur.type == stack.node.type); cur = cur.parent)
924
+ add.push(cur);
925
+ for (let i = add.length - 1; i >= 0; i--)
926
+ stack = { node: add[i], next: stack };
927
+ }
928
+ return indentFor(stack, cx, pos);
929
+ }
930
+ function indentFor(stack, cx, pos) {
931
+ for (let cur = stack; cur; cur = cur.next) {
932
+ let strategy = indentStrategy(cur.node);
933
+ if (strategy)
934
+ return strategy(TreeIndentContext.create(cx, pos, cur));
935
+ }
936
+ return 0;
937
+ }
938
+ function ignoreClosed(cx) {
939
+ return cx.pos == cx.options.simulateBreak && cx.options.simulateDoubleBreak;
940
+ }
941
+ function indentStrategy(tree) {
942
+ let strategy = tree.type.prop(indentNodeProp);
943
+ if (strategy)
944
+ return strategy;
945
+ let first = tree.firstChild, close;
946
+ if (first && (close = first.type.prop(NodeProp.closedBy))) {
947
+ let last = tree.lastChild, closed = last && close.indexOf(last.name) > -1;
948
+ return cx => delimitedStrategy(cx, true, 1, undefined, closed && !ignoreClosed(cx) ? last.from : undefined);
949
+ }
950
+ return tree.parent == null ? topIndent : null;
951
+ }
952
+ function topIndent() { return 0; }
953
+ /**
954
+ Objects of this type provide context information and helper
955
+ methods to indentation functions registered on syntax nodes.
956
+ */
957
+ class TreeIndentContext extends IndentContext {
958
+ constructor(base,
959
+ /**
960
+ The position at which indentation is being computed.
961
+ */
962
+ pos,
963
+ /**
964
+ @internal
965
+ */
966
+ context) {
967
+ super(base.state, base.options);
968
+ this.base = base;
969
+ this.pos = pos;
970
+ this.context = context;
971
+ }
972
+ /**
973
+ The syntax tree node to which the indentation strategy
974
+ applies.
975
+ */
976
+ get node() { return this.context.node; }
977
+ /**
978
+ @internal
979
+ */
980
+ static create(base, pos, context) {
981
+ return new TreeIndentContext(base, pos, context);
982
+ }
983
+ /**
984
+ Get the text directly after `this.pos`, either the entire line
985
+ or the next 100 characters, whichever is shorter.
986
+ */
987
+ get textAfter() {
988
+ return this.textAfterPos(this.pos);
989
+ }
990
+ /**
991
+ Get the indentation at the reference line for `this.node`, which
992
+ is the line on which it starts, unless there is a node that is
993
+ _not_ a parent of this node covering the start of that line. If
994
+ so, the line at the start of that node is tried, again skipping
995
+ on if it is covered by another such node.
996
+ */
997
+ get baseIndent() {
998
+ return this.baseIndentFor(this.node);
999
+ }
1000
+ /**
1001
+ Get the indentation for the reference line of the given node
1002
+ (see [`baseIndent`](https://codemirror.net/6/docs/ref/#language.TreeIndentContext.baseIndent)).
1003
+ */
1004
+ baseIndentFor(node) {
1005
+ let line = this.state.doc.lineAt(node.from);
1006
+ // Skip line starts that are covered by a sibling (or cousin, etc)
1007
+ for (;;) {
1008
+ let atBreak = node.resolve(line.from);
1009
+ while (atBreak.parent && atBreak.parent.from == atBreak.from)
1010
+ atBreak = atBreak.parent;
1011
+ if (isParent(atBreak, node))
1012
+ break;
1013
+ line = this.state.doc.lineAt(atBreak.from);
1014
+ }
1015
+ return this.lineIndent(line.from);
1016
+ }
1017
+ /**
1018
+ Continue looking for indentations in the node's parent nodes,
1019
+ and return the result of that.
1020
+ */
1021
+ continue() {
1022
+ return indentFor(this.context.next, this.base, this.pos);
1023
+ }
1024
+ }
1025
+ function isParent(parent, of) {
1026
+ for (let cur = of; cur; cur = cur.parent)
1027
+ if (parent == cur)
1028
+ return true;
1029
+ return false;
1030
+ }
1031
+ // Check whether a delimited node is aligned (meaning there are
1032
+ // non-skipped nodes on the same line as the opening delimiter). And
1033
+ // if so, return the opening token.
1034
+ function bracketedAligned(context) {
1035
+ let tree = context.node;
1036
+ let openToken = tree.childAfter(tree.from), last = tree.lastChild;
1037
+ if (!openToken)
1038
+ return null;
1039
+ let sim = context.options.simulateBreak;
1040
+ let openLine = context.state.doc.lineAt(openToken.from);
1041
+ let lineEnd = sim == null || sim <= openLine.from ? openLine.to : Math.min(openLine.to, sim);
1042
+ for (let pos = openToken.to;;) {
1043
+ let next = tree.childAfter(pos);
1044
+ if (!next || next == last)
1045
+ return null;
1046
+ if (!next.type.isSkipped) {
1047
+ if (next.from >= lineEnd)
1048
+ return null;
1049
+ let space = /^ */.exec(openLine.text.slice(openToken.to - openLine.from))[0].length;
1050
+ return { from: openToken.from, to: openToken.to + space };
1051
+ }
1052
+ pos = next.to;
1053
+ }
1054
+ }
1055
+ /**
1056
+ An indentation strategy for delimited (usually bracketed) nodes.
1057
+ Will, by default, indent one unit more than the parent's base
1058
+ indent unless the line starts with a closing token. When `align`
1059
+ is true and there are non-skipped nodes on the node's opening
1060
+ line, the content of the node will be aligned with the end of the
1061
+ opening node, like this:
1062
+
1063
+ foo(bar,
1064
+ baz)
1065
+ */
1066
+ function delimitedIndent({ closing, align = true, units = 1 }) {
1067
+ return (context) => delimitedStrategy(context, align, units, closing);
1068
+ }
1069
+ function delimitedStrategy(context, align, units, closing, closedAt) {
1070
+ let after = context.textAfter, space = after.match(/^\s*/)[0].length;
1071
+ let closed = closing && after.slice(space, space + closing.length) == closing || closedAt == context.pos + space;
1072
+ let aligned = align ? bracketedAligned(context) : null;
1073
+ if (aligned)
1074
+ return closed ? context.column(aligned.from) : context.column(aligned.to);
1075
+ return context.baseIndent + (closed ? 0 : context.unit * units);
1076
+ }
1077
+ /**
1078
+ An indentation strategy that aligns a node's content to its base
1079
+ indentation.
1080
+ */
1081
+ const flatIndent = (context) => context.baseIndent;
1082
+ /**
1083
+ Creates an indentation strategy that, by default, indents
1084
+ continued lines one unit more than the node's base indentation.
1085
+ You can provide `except` to prevent indentation of lines that
1086
+ match a pattern (for example `/^else\b/` in `if`/`else`
1087
+ constructs), and you can change the amount of units used with the
1088
+ `units` option.
1089
+ */
1090
+ function continuedIndent({ except, units = 1 } = {}) {
1091
+ return (context) => {
1092
+ let matchExcept = except && except.test(context.textAfter);
1093
+ return context.baseIndent + (matchExcept ? 0 : units * context.unit);
1094
+ };
1095
+ }
1096
+ const DontIndentBeyond = 200;
1097
+ /**
1098
+ Enables reindentation on input. When a language defines an
1099
+ `indentOnInput` field in its [language
1100
+ data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt), which must hold a regular
1101
+ expression, the line at the cursor will be reindented whenever new
1102
+ text is typed and the input from the start of the line up to the
1103
+ cursor matches that regexp.
1104
+
1105
+ To avoid unneccesary reindents, it is recommended to start the
1106
+ regexp with `^` (usually followed by `\s*`), and end it with `$`.
1107
+ For example, `/^\s*\}$/` will reindent when a closing brace is
1108
+ added at the start of a line.
1109
+ */
1110
+ function indentOnInput() {
1111
+ return EditorState.transactionFilter.of(tr => {
1112
+ if (!tr.docChanged || !tr.isUserEvent("input.type") && !tr.isUserEvent("input.complete"))
1113
+ return tr;
1114
+ let rules = tr.startState.languageDataAt("indentOnInput", tr.startState.selection.main.head);
1115
+ if (!rules.length)
1116
+ return tr;
1117
+ let doc = tr.newDoc, { head } = tr.newSelection.main, line = doc.lineAt(head);
1118
+ if (head > line.from + DontIndentBeyond)
1119
+ return tr;
1120
+ let lineStart = doc.sliceString(line.from, head);
1121
+ if (!rules.some(r => r.test(lineStart)))
1122
+ return tr;
1123
+ let { state } = tr, last = -1, changes = [];
1124
+ for (let { head } of state.selection.ranges) {
1125
+ let line = state.doc.lineAt(head);
1126
+ if (line.from == last)
1127
+ continue;
1128
+ last = line.from;
1129
+ let indent = getIndentation(state, line.from);
1130
+ if (indent == null)
1131
+ continue;
1132
+ let cur = /^\s*/.exec(line.text)[0];
1133
+ let norm = indentString(state, indent);
1134
+ if (cur != norm)
1135
+ changes.push({ from: line.from, to: line.from + cur.length, insert: norm });
1136
+ }
1137
+ return changes.length ? [tr, { changes, sequential: true }] : tr;
1138
+ });
1139
+ }
1140
+
1141
+ /**
1142
+ A facet that registers a code folding service. When called with
1143
+ the extent of a line, such a function should return a foldable
1144
+ range that starts on that line (but continues beyond it), if one
1145
+ can be found.
1146
+ */
1147
+ const foldService = /*@__PURE__*/Facet.define();
1148
+ /**
1149
+ This node prop is used to associate folding information with
1150
+ syntax node types. Given a syntax node, it should check whether
1151
+ that tree is foldable and return the range that can be collapsed
1152
+ when it is.
1153
+ */
1154
+ const foldNodeProp = /*@__PURE__*/new NodeProp();
1155
+ /**
1156
+ [Fold](https://codemirror.net/6/docs/ref/#language.foldNodeProp) function that folds everything but
1157
+ the first and the last child of a syntax node. Useful for nodes
1158
+ that start and end with delimiters.
1159
+ */
1160
+ function foldInside(node) {
1161
+ let first = node.firstChild, last = node.lastChild;
1162
+ return first && first.to < last.from ? { from: first.to, to: last.type.isError ? node.to : last.from } : null;
1163
+ }
1164
+
1165
+ /**
1166
+ A highlight style associates CSS styles with highlighting
1167
+ [tags](https://lezer.codemirror.net/docs/ref#highlight.Tag).
1168
+ */
1169
+ class HighlightStyle {
1170
+ constructor(
1171
+ /**
1172
+ The tag styles used to create this highlight style.
1173
+ */
1174
+ specs, options) {
1175
+ this.specs = specs;
1176
+ let modSpec;
1177
+ function def(spec) {
1178
+ let cls = StyleModule.newName();
1179
+ (modSpec || (modSpec = Object.create(null)))["." + cls] = spec;
1180
+ return cls;
1181
+ }
1182
+ const all = typeof options.all == "string" ? options.all : options.all ? def(options.all) : undefined;
1183
+ const scopeOpt = options.scope;
1184
+ this.scope = scopeOpt instanceof Language ? (type) => type.prop(languageDataProp) == scopeOpt.data
1185
+ : scopeOpt ? (type) => type == scopeOpt : undefined;
1186
+ this.style = tagHighlighter(specs.map(style => ({
1187
+ tag: style.tag,
1188
+ class: style.class || def(Object.assign({}, style, { tag: null }))
1189
+ })), {
1190
+ all,
1191
+ }).style;
1192
+ this.module = modSpec ? new StyleModule(modSpec) : null;
1193
+ this.themeType = options.themeType;
1194
+ }
1195
+ /**
1196
+ Create a highlighter style that associates the given styles to
1197
+ the given tags. The specs must be objects that hold a style tag
1198
+ or array of tags in their `tag` property, and either a single
1199
+ `class` property providing a static CSS class (for highlighter
1200
+ that rely on external styling), or a
1201
+ [`style-mod`](https://github.com/marijnh/style-mod#documentation)-style
1202
+ set of CSS properties (which define the styling for those tags).
1203
+
1204
+ The CSS rules created for a highlighter will be emitted in the
1205
+ order of the spec's properties. That means that for elements that
1206
+ have multiple tags associated with them, styles defined further
1207
+ down in the list will have a higher CSS precedence than styles
1208
+ defined earlier.
1209
+ */
1210
+ static define(specs, options) {
1211
+ return new HighlightStyle(specs, options || {});
1212
+ }
1213
+ }
1214
+ const highlighterFacet = /*@__PURE__*/Facet.define();
1215
+ const fallbackHighlighter = /*@__PURE__*/Facet.define({
1216
+ combine(values) { return values.length ? [values[0]] : null; }
1217
+ });
1218
+ function getHighlighters(state) {
1219
+ let main = state.facet(highlighterFacet);
1220
+ return main.length ? main : state.facet(fallbackHighlighter);
1221
+ }
1222
+ /**
1223
+ Wrap a highlighter in an editor extension that uses it to apply
1224
+ syntax highlighting to the editor content.
1225
+
1226
+ When multiple (non-fallback) styles are provided, the styling
1227
+ applied is the union of the classes they emit.
1228
+ */
1229
+ function syntaxHighlighting(highlighter, options) {
1230
+ let ext = [treeHighlighter], themeType;
1231
+ if (highlighter instanceof HighlightStyle) {
1232
+ if (highlighter.module)
1233
+ ext.push(EditorView.styleModule.of(highlighter.module));
1234
+ themeType = highlighter.themeType;
1235
+ }
1236
+ if (themeType)
1237
+ ext.push(highlighterFacet.computeN([EditorView.darkTheme], state => {
1238
+ return state.facet(EditorView.darkTheme) == (themeType == "dark") ? [highlighter] : [];
1239
+ }));
1240
+ else
1241
+ ext.push(highlighterFacet.of(highlighter));
1242
+ return ext;
1243
+ }
1244
+ class TreeHighlighter {
1245
+ constructor(view) {
1246
+ this.markCache = Object.create(null);
1247
+ this.tree = syntaxTree(view.state);
1248
+ this.decorations = this.buildDeco(view, getHighlighters(view.state));
1249
+ this.decoratedTo = view.viewport.to;
1250
+ }
1251
+ update(update) {
1252
+ let tree = syntaxTree(update.state), highlighters = getHighlighters(update.state);
1253
+ let styleChange = highlighters != getHighlighters(update.startState);
1254
+ let { viewport } = update.view, decoratedToMapped = update.changes.mapPos(this.decoratedTo, 1);
1255
+ if (tree.length < viewport.to && !styleChange && tree.type == this.tree.type && decoratedToMapped >= viewport.to) {
1256
+ this.decorations = this.decorations.map(update.changes);
1257
+ this.decoratedTo = decoratedToMapped;
1258
+ }
1259
+ else if (tree != this.tree || update.viewportChanged || styleChange) {
1260
+ this.tree = tree;
1261
+ this.decorations = this.buildDeco(update.view, highlighters);
1262
+ this.decoratedTo = viewport.to;
1263
+ }
1264
+ }
1265
+ buildDeco(view, highlighters) {
1266
+ if (!highlighters || !this.tree.length)
1267
+ return Decoration.none;
1268
+ let builder = new RangeSetBuilder();
1269
+ for (let { from, to } of view.visibleRanges) {
1270
+ highlightTree(this.tree, highlighters, (from, to, style) => {
1271
+ builder.add(from, to, this.markCache[style] || (this.markCache[style] = Decoration.mark({ class: style })));
1272
+ }, from, to);
1273
+ }
1274
+ return builder.finish();
1275
+ }
1276
+ }
1277
+ const treeHighlighter = /*@__PURE__*/Prec.high(/*@__PURE__*/ViewPlugin.fromClass(TreeHighlighter, {
1278
+ decorations: v => v.decorations
1279
+ }));
1280
+ /**
1281
+ A default highlight style (works well with light themes).
1282
+ */
1283
+ const defaultHighlightStyle = /*@__PURE__*/HighlightStyle.define([
1284
+ { tag: tags.meta,
1285
+ color: "#404740" },
1286
+ { tag: tags.link,
1287
+ textDecoration: "underline" },
1288
+ { tag: tags.heading,
1289
+ textDecoration: "underline",
1290
+ fontWeight: "bold" },
1291
+ { tag: tags.emphasis,
1292
+ fontStyle: "italic" },
1293
+ { tag: tags.strong,
1294
+ fontWeight: "bold" },
1295
+ { tag: tags.strikethrough,
1296
+ textDecoration: "line-through" },
1297
+ { tag: tags.keyword,
1298
+ color: "#708" },
1299
+ { tag: [tags.atom, tags.bool, tags.url, tags.contentSeparator, tags.labelName],
1300
+ color: "#219" },
1301
+ { tag: [tags.literal, tags.inserted],
1302
+ color: "#164" },
1303
+ { tag: [tags.string, tags.deleted],
1304
+ color: "#a11" },
1305
+ { tag: [tags.regexp, tags.escape, /*@__PURE__*/tags.special(tags.string)],
1306
+ color: "#e40" },
1307
+ { tag: /*@__PURE__*/tags.definition(tags.variableName),
1308
+ color: "#00f" },
1309
+ { tag: /*@__PURE__*/tags.local(tags.variableName),
1310
+ color: "#30a" },
1311
+ { tag: [tags.typeName, tags.namespace],
1312
+ color: "#085" },
1313
+ { tag: tags.className,
1314
+ color: "#167" },
1315
+ { tag: [/*@__PURE__*/tags.special(tags.variableName), tags.macroName],
1316
+ color: "#256" },
1317
+ { tag: /*@__PURE__*/tags.definition(tags.propertyName),
1318
+ color: "#00c" },
1319
+ { tag: tags.comment,
1320
+ color: "#940" },
1321
+ { tag: tags.invalid,
1322
+ color: "#f00" }
1323
+ ]);
1324
+
1325
+ const baseTheme = /*@__PURE__*/EditorView.baseTheme({
1326
+ "&.cm-focused .cm-matchingBracket": { backgroundColor: "#328c8252" },
1327
+ "&.cm-focused .cm-nonmatchingBracket": { backgroundColor: "#bb555544" }
1328
+ });
1329
+ const DefaultScanDist = 10000, DefaultBrackets = "()[]{}";
1330
+ const bracketMatchingConfig = /*@__PURE__*/Facet.define({
1331
+ combine(configs) {
1332
+ return combineConfig(configs, {
1333
+ afterCursor: true,
1334
+ brackets: DefaultBrackets,
1335
+ maxScanDistance: DefaultScanDist,
1336
+ renderMatch: defaultRenderMatch
1337
+ });
1338
+ }
1339
+ });
1340
+ const matchingMark = /*@__PURE__*/Decoration.mark({ class: "cm-matchingBracket" }), nonmatchingMark = /*@__PURE__*/Decoration.mark({ class: "cm-nonmatchingBracket" });
1341
+ function defaultRenderMatch(match) {
1342
+ let decorations = [];
1343
+ let mark = match.matched ? matchingMark : nonmatchingMark;
1344
+ decorations.push(mark.range(match.start.from, match.start.to));
1345
+ if (match.end)
1346
+ decorations.push(mark.range(match.end.from, match.end.to));
1347
+ return decorations;
1348
+ }
1349
+ function bracketDeco(state) {
1350
+ let decorations = [];
1351
+ let config = state.facet(bracketMatchingConfig);
1352
+ for (let range of state.selection.ranges) {
1353
+ if (!range.empty)
1354
+ continue;
1355
+ let match = matchBrackets(state, range.head, -1, config)
1356
+ || (range.head > 0 && matchBrackets(state, range.head - 1, 1, config))
1357
+ || (config.afterCursor &&
1358
+ (matchBrackets(state, range.head, 1, config) ||
1359
+ (range.head < state.doc.length && matchBrackets(state, range.head + 1, -1, config))));
1360
+ if (match)
1361
+ decorations = decorations.concat(config.renderMatch(match, state));
1362
+ }
1363
+ return Decoration.set(decorations, true);
1364
+ }
1365
+ const bracketMatcher = /*@__PURE__*/ViewPlugin.fromClass(class {
1366
+ constructor(view) {
1367
+ this.paused = false;
1368
+ this.decorations = bracketDeco(view.state);
1369
+ }
1370
+ update(update) {
1371
+ if (update.docChanged || update.selectionSet || this.paused) {
1372
+ if (update.view.composing) {
1373
+ this.decorations = this.decorations.map(update.changes);
1374
+ this.paused = true;
1375
+ }
1376
+ else {
1377
+ this.decorations = bracketDeco(update.state);
1378
+ this.paused = false;
1379
+ }
1380
+ }
1381
+ }
1382
+ }, {
1383
+ decorations: v => v.decorations
1384
+ });
1385
+ const bracketMatchingUnique = [
1386
+ bracketMatcher,
1387
+ baseTheme
1388
+ ];
1389
+ /**
1390
+ Create an extension that enables bracket matching. Whenever the
1391
+ cursor is next to a bracket, that bracket and the one it matches
1392
+ are highlighted. Or, when no matching bracket is found, another
1393
+ highlighting style is used to indicate this.
1394
+ */
1395
+ function bracketMatching(config = {}) {
1396
+ return [bracketMatchingConfig.of(config), bracketMatchingUnique];
1397
+ }
1398
+ /**
1399
+ When larger syntax nodes, such as HTML tags, are marked as
1400
+ opening/closing, it can be a bit messy to treat the whole node as
1401
+ a matchable bracket. This node prop allows you to define, for such
1402
+ a node, a ‘handle’—the part of the node that is highlighted, and
1403
+ that the cursor must be on to activate highlighting in the first
1404
+ place.
1405
+ */
1406
+ const bracketMatchingHandle = /*@__PURE__*/new NodeProp();
1407
+ function matchingNodes(node, dir, brackets) {
1408
+ let byProp = node.prop(dir < 0 ? NodeProp.openedBy : NodeProp.closedBy);
1409
+ if (byProp)
1410
+ return byProp;
1411
+ if (node.name.length == 1) {
1412
+ let index = brackets.indexOf(node.name);
1413
+ if (index > -1 && index % 2 == (dir < 0 ? 1 : 0))
1414
+ return [brackets[index + dir]];
1415
+ }
1416
+ return null;
1417
+ }
1418
+ function findHandle(node) {
1419
+ let hasHandle = node.type.prop(bracketMatchingHandle);
1420
+ return hasHandle ? hasHandle(node.node) : node;
1421
+ }
1422
+ /**
1423
+ Find the matching bracket for the token at `pos`, scanning
1424
+ direction `dir`. Only the `brackets` and `maxScanDistance`
1425
+ properties are used from `config`, if given. Returns null if no
1426
+ bracket was found at `pos`, or a match result otherwise.
1427
+ */
1428
+ function matchBrackets(state, pos, dir, config = {}) {
1429
+ let maxScanDistance = config.maxScanDistance || DefaultScanDist, brackets = config.brackets || DefaultBrackets;
1430
+ let tree = syntaxTree(state), node = tree.resolveInner(pos, dir);
1431
+ for (let cur = node; cur; cur = cur.parent) {
1432
+ let matches = matchingNodes(cur.type, dir, brackets);
1433
+ if (matches && cur.from < cur.to) {
1434
+ let handle = findHandle(cur);
1435
+ if (handle && (dir > 0 ? pos >= handle.from && pos < handle.to : pos > handle.from && pos <= handle.to))
1436
+ return matchMarkedBrackets(state, pos, dir, cur, handle, matches, brackets);
1437
+ }
1438
+ }
1439
+ return matchPlainBrackets(state, pos, dir, tree, node.type, maxScanDistance, brackets);
1440
+ }
1441
+ function matchMarkedBrackets(_state, _pos, dir, token, handle, matching, brackets) {
1442
+ let parent = token.parent, firstToken = { from: handle.from, to: handle.to };
1443
+ let depth = 0, cursor = parent === null || parent === void 0 ? void 0 : parent.cursor();
1444
+ if (cursor && (dir < 0 ? cursor.childBefore(token.from) : cursor.childAfter(token.to)))
1445
+ do {
1446
+ if (dir < 0 ? cursor.to <= token.from : cursor.from >= token.to) {
1447
+ if (depth == 0 && matching.indexOf(cursor.type.name) > -1 && cursor.from < cursor.to) {
1448
+ let endHandle = findHandle(cursor);
1449
+ return { start: firstToken, end: endHandle ? { from: endHandle.from, to: endHandle.to } : undefined, matched: true };
1450
+ }
1451
+ else if (matchingNodes(cursor.type, dir, brackets)) {
1452
+ depth++;
1453
+ }
1454
+ else if (matchingNodes(cursor.type, -dir, brackets)) {
1455
+ if (depth == 0) {
1456
+ let endHandle = findHandle(cursor);
1457
+ return {
1458
+ start: firstToken,
1459
+ end: endHandle && endHandle.from < endHandle.to ? { from: endHandle.from, to: endHandle.to } : undefined,
1460
+ matched: false
1461
+ };
1462
+ }
1463
+ depth--;
1464
+ }
1465
+ }
1466
+ } while (dir < 0 ? cursor.prevSibling() : cursor.nextSibling());
1467
+ return { start: firstToken, matched: false };
1468
+ }
1469
+ function matchPlainBrackets(state, pos, dir, tree, tokenType, maxScanDistance, brackets) {
1470
+ if (dir < 0 ? !pos : pos == state.doc.length)
1471
+ return null;
1472
+ let startCh = dir < 0 ? state.sliceDoc(pos - 1, pos) : state.sliceDoc(pos, pos + 1);
1473
+ let bracket = brackets.indexOf(startCh);
1474
+ if (bracket < 0 || (bracket % 2 == 0) != (dir > 0))
1475
+ return null;
1476
+ let startToken = { from: dir < 0 ? pos - 1 : pos, to: dir > 0 ? pos + 1 : pos };
1477
+ let iter = state.doc.iterRange(pos, dir > 0 ? state.doc.length : 0), depth = 0;
1478
+ for (let distance = 0; !(iter.next()).done && distance <= maxScanDistance;) {
1479
+ let text = iter.value;
1480
+ if (dir < 0)
1481
+ distance += text.length;
1482
+ let basePos = pos + distance * dir;
1483
+ for (let pos = dir > 0 ? 0 : text.length - 1, end = dir > 0 ? text.length : -1; pos != end; pos += dir) {
1484
+ let found = brackets.indexOf(text[pos]);
1485
+ if (found < 0 || tree.resolveInner(basePos + pos, 1).type != tokenType)
1486
+ continue;
1487
+ if ((found % 2 == 0) == (dir > 0)) {
1488
+ depth++;
1489
+ }
1490
+ else if (depth == 1) { // Closing
1491
+ return { start: startToken, end: { from: basePos + pos, to: basePos + pos + 1 }, matched: (found >> 1) == (bracket >> 1) };
1492
+ }
1493
+ else {
1494
+ depth--;
1495
+ }
1496
+ }
1497
+ if (dir > 0)
1498
+ distance += text.length;
1499
+ }
1500
+ return iter.done ? { start: startToken, matched: false } : null;
1501
+ }
1502
+ const noTokens = /*@__PURE__*/Object.create(null);
1503
+ const typeArray = [NodeType.none];
1504
+ const warned = [];
1505
+ // Cache of node types by name and tags
1506
+ const byTag = /*@__PURE__*/Object.create(null);
1507
+ const defaultTable = /*@__PURE__*/Object.create(null);
1508
+ for (let [legacyName, name] of [
1509
+ ["variable", "variableName"],
1510
+ ["variable-2", "variableName.special"],
1511
+ ["string-2", "string.special"],
1512
+ ["def", "variableName.definition"],
1513
+ ["tag", "tagName"],
1514
+ ["attribute", "attributeName"],
1515
+ ["type", "typeName"],
1516
+ ["builtin", "variableName.standard"],
1517
+ ["qualifier", "modifier"],
1518
+ ["error", "invalid"],
1519
+ ["header", "heading"],
1520
+ ["property", "propertyName"]
1521
+ ])
1522
+ defaultTable[legacyName] = /*@__PURE__*/createTokenType(noTokens, name);
1523
+ function warnForPart(part, msg) {
1524
+ if (warned.indexOf(part) > -1)
1525
+ return;
1526
+ warned.push(part);
1527
+ console.warn(msg);
1528
+ }
1529
+ function createTokenType(extra, tagStr) {
1530
+ let tags$1 = [];
1531
+ for (let name of tagStr.split(" ")) {
1532
+ let found = [];
1533
+ for (let part of name.split(".")) {
1534
+ let value = (extra[part] || tags[part]);
1535
+ if (!value) {
1536
+ warnForPart(part, `Unknown highlighting tag ${part}`);
1537
+ }
1538
+ else if (typeof value == "function") {
1539
+ if (!found.length)
1540
+ warnForPart(part, `Modifier ${part} used at start of tag`);
1541
+ else
1542
+ found = found.map(value);
1543
+ }
1544
+ else {
1545
+ if (found.length)
1546
+ warnForPart(part, `Tag ${part} used as modifier`);
1547
+ else
1548
+ found = Array.isArray(value) ? value : [value];
1549
+ }
1550
+ }
1551
+ for (let tag of found)
1552
+ tags$1.push(tag);
1553
+ }
1554
+ if (!tags$1.length)
1555
+ return 0;
1556
+ let name = tagStr.replace(/ /g, "_"), key = name + " " + tags$1.map(t => t.id);
1557
+ let known = byTag[key];
1558
+ if (known)
1559
+ return known.id;
1560
+ let type = byTag[key] = NodeType.define({
1561
+ id: typeArray.length,
1562
+ name,
1563
+ props: [styleTags({ [name]: tags$1 })]
1564
+ });
1565
+ typeArray.push(type);
1566
+ return type.id;
1567
+ }
1568
+ ({
1569
+ rtl: /*@__PURE__*/Decoration.mark({ class: "cm-iso", inclusive: true, attributes: { dir: "rtl" }, bidiIsolate: Direction.RTL }),
1570
+ ltr: /*@__PURE__*/Decoration.mark({ class: "cm-iso", inclusive: true, attributes: { dir: "ltr" }, bidiIsolate: Direction.LTR })});
1571
+
1572
+ export { DocInput, HighlightStyle, IndentContext, LRLanguage, Language, LanguageDescription, LanguageSupport, ParseContext, TreeIndentContext, bracketMatching, bracketMatchingHandle, continuedIndent, defaultHighlightStyle, defineLanguageFacet, delimitedIndent, flatIndent, foldInside, foldNodeProp, foldService, getIndentUnit, getIndentation, indentNodeProp, indentOnInput, indentService, indentString, indentUnit, language, languageDataProp, matchBrackets, sublanguageProp, syntaxHighlighting, syntaxTree };