@code0-tech/pictor 0.0.0-mvp.40 → 0.0.0-mvp.42

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 (56) hide show
  1. package/dist/assets/components/data-table/DataTable.style.css +1 -0
  2. package/dist/assets/components/menu/Menu.style.css +1 -1
  3. package/dist/components/d-flow/DFlow.service.js +80 -100
  4. package/dist/components/d-flow-data-type/DFlowDataType.service.js +6 -7
  5. package/dist/components/d-flow-data-type/rules/DFlowDataTypeContainsKeyRule.d.ts +1 -1
  6. package/dist/components/d-flow-data-type/rules/DFlowDataTypeContainsKeyRule.js +15 -15
  7. package/dist/components/d-flow-data-type/rules/DFlowDataTypeContainsTypeRule.d.ts +1 -1
  8. package/dist/components/d-flow-data-type/rules/DFlowDataTypeContainsTypeRule.js +17 -17
  9. package/dist/components/d-flow-data-type/rules/DFlowDataTypeParentRule.d.ts +1 -1
  10. package/dist/components/d-flow-data-type/rules/DFlowDataTypeParentRule.js +1 -1
  11. package/dist/components/d-flow-data-type/rules/DFlowDataTypeReturnTypeRule.d.ts +2 -1
  12. package/dist/components/d-flow-data-type/rules/DFlowDataTypeReturnTypeRule.js +87 -85
  13. package/dist/components/d-flow-data-type/rules/DFlowDataTypeRule.d.ts +2 -1
  14. package/dist/components/d-flow-function/DFlowFunction.input.hook.d.ts +2 -1
  15. package/dist/components/d-flow-function/DFlowFunction.input.hook.js +5 -5
  16. package/dist/components/d-flow-function/DFlowFunction.return.hook.d.ts +2 -1
  17. package/dist/components/d-flow-function/DFlowFunction.return.hook.js +5 -5
  18. package/dist/components/d-flow-input/DFlowInputDataTypeEditDialog.js +1 -1
  19. package/dist/components/d-flow-input/DFlowInputReferenceBadge.js +17 -17
  20. package/dist/components/d-flow-node/DFlowNode.return.hook.d.ts +5 -0
  21. package/dist/components/d-flow-node/DFlowNode.return.hook.js +27 -0
  22. package/dist/components/d-flow-suggestion/DFlowReferenceSuggestions.hook.js +90 -91
  23. package/dist/components/d-flow-validation/DDataTypeValidation.hook.js +1 -1
  24. package/dist/components/d-flow-validation/DNodeValidation.hook.js +33 -33
  25. package/dist/components/d-flow-validation/DValueValidation.hook.d.ts +2 -1
  26. package/dist/components/d-flow-validation/DValueValidation.hook.js +5 -5
  27. package/dist/components/d-project/DNamespaceProject.service.d.ts +2 -1
  28. package/dist/components/data-table/DataTable.d.ts +23 -0
  29. package/dist/components/data-table/DataTable.js +41 -0
  30. package/dist/components/data-table/DataTableColumn.d.ts +6 -0
  31. package/dist/components/data-table/DataTableColumn.js +22 -0
  32. package/dist/components/data-table/DataTableFilterInput.d.ts +18 -0
  33. package/dist/components/data-table/DataTableFilterInput.js +210 -0
  34. package/dist/components/data-table/DataTableFilterSuggestionMenu.d.ts +7 -0
  35. package/dist/components/data-table/DataTableFilterSuggestionMenu.js +53 -0
  36. package/dist/components/data-table/index.d.ts +4 -0
  37. package/dist/components/data-table/index.js +11 -0
  38. package/dist/components/editor/Editor.d.ts +9 -3
  39. package/dist/components/editor/Editor.js +249 -174
  40. package/dist/components/menu/Menu.d.ts +5 -1
  41. package/dist/components/menu/Menu.js +73 -57
  42. package/dist/index.d.ts +1 -0
  43. package/dist/index.js +182 -171
  44. package/dist/node_modules/@lezer/highlight/dist/index.js +132 -169
  45. package/dist/utils/generics.d.ts +2 -1
  46. package/dist/utils/generics.js +84 -80
  47. package/package.json +32 -21
  48. package/dist/node_modules/@codemirror/language/dist/index.js +0 -429
  49. package/dist/node_modules/@codemirror/lint/dist/index.js +0 -515
  50. package/dist/node_modules/@codemirror/state/dist/index.js +0 -2614
  51. package/dist/node_modules/@codemirror/view/dist/index.js +0 -6227
  52. package/dist/node_modules/@lezer/common/dist/index.js +0 -1357
  53. package/dist/node_modules/@marijn/find-cluster-break/src/index.js +0 -69
  54. package/dist/node_modules/crelt/index.js +0 -27
  55. package/dist/node_modules/style-mod/src/style-mod.js +0 -109
  56. package/dist/node_modules/w3c-keyname/index.js +0 -88
@@ -1,1357 +0,0 @@
1
- const ke = 1024;
2
- let ce = 0;
3
- class Z {
4
- constructor(e, t) {
5
- this.from = e, this.to = t;
6
- }
7
- }
8
- class k {
9
- /**
10
- Create a new node prop type.
11
- */
12
- constructor(e = {}) {
13
- this.id = ce++, this.perNode = !!e.perNode, this.deserialize = e.deserialize || (() => {
14
- throw new Error("This node type doesn't define a deserialize function");
15
- }), this.combine = e.combine || null;
16
- }
17
- /**
18
- This is meant to be used with
19
- [`NodeSet.extend`](#common.NodeSet.extend) or
20
- [`LRParser.configure`](#lr.ParserConfig.props) to compute
21
- prop values for each node type in the set. Takes a [match
22
- object](#common.NodeType^match) or function that returns undefined
23
- if the node type doesn't get this prop, and the prop's value if
24
- it does.
25
- */
26
- add(e) {
27
- if (this.perNode)
28
- throw new RangeError("Can't add per-node props to node types");
29
- return typeof e != "function" && (e = j.match(e)), (t) => {
30
- let r = e(t);
31
- return r === void 0 ? null : [this, r];
32
- };
33
- }
34
- }
35
- k.closedBy = new k({ deserialize: (l) => l.split(" ") });
36
- k.openedBy = new k({ deserialize: (l) => l.split(" ") });
37
- k.group = new k({ deserialize: (l) => l.split(" ") });
38
- k.isolate = new k({ deserialize: (l) => {
39
- if (l && l != "rtl" && l != "ltr" && l != "auto")
40
- throw new RangeError("Invalid value for isolate: " + l);
41
- return l || "auto";
42
- } });
43
- k.contextHash = new k({ perNode: !0 });
44
- k.lookAhead = new k({ perNode: !0 });
45
- k.mounted = new k({ perNode: !0 });
46
- class G {
47
- constructor(e, t, r, n = !1) {
48
- this.tree = e, this.overlay = t, this.parser = r, this.bracketed = n;
49
- }
50
- /**
51
- @internal
52
- */
53
- static get(e) {
54
- return e && e.props && e.props[k.mounted.id];
55
- }
56
- }
57
- const ge = /* @__PURE__ */ Object.create(null);
58
- class j {
59
- /**
60
- @internal
61
- */
62
- constructor(e, t, r, n = 0) {
63
- this.name = e, this.props = t, this.id = r, this.flags = n;
64
- }
65
- /**
66
- Define a node type.
67
- */
68
- static define(e) {
69
- let t = e.props && e.props.length ? /* @__PURE__ */ Object.create(null) : ge, r = (e.top ? 1 : 0) | (e.skipped ? 2 : 0) | (e.error ? 4 : 0) | (e.name == null ? 8 : 0), n = new j(e.name || "", t, e.id, r);
70
- if (e.props) {
71
- for (let i of e.props)
72
- if (Array.isArray(i) || (i = i(n)), i) {
73
- if (i[0].perNode)
74
- throw new RangeError("Can't store a per-node prop on a node type");
75
- t[i[0].id] = i[1];
76
- }
77
- }
78
- return n;
79
- }
80
- /**
81
- Retrieves a node prop for this type. Will return `undefined` if
82
- the prop isn't present on this node.
83
- */
84
- prop(e) {
85
- return this.props[e.id];
86
- }
87
- /**
88
- True when this is the top node of a grammar.
89
- */
90
- get isTop() {
91
- return (this.flags & 1) > 0;
92
- }
93
- /**
94
- True when this node is produced by a skip rule.
95
- */
96
- get isSkipped() {
97
- return (this.flags & 2) > 0;
98
- }
99
- /**
100
- Indicates whether this is an error node.
101
- */
102
- get isError() {
103
- return (this.flags & 4) > 0;
104
- }
105
- /**
106
- When true, this node type doesn't correspond to a user-declared
107
- named node, for example because it is used to cache repetition.
108
- */
109
- get isAnonymous() {
110
- return (this.flags & 8) > 0;
111
- }
112
- /**
113
- Returns true when this node's name or one of its
114
- [groups](#common.NodeProp^group) matches the given string.
115
- */
116
- is(e) {
117
- if (typeof e == "string") {
118
- if (this.name == e)
119
- return !0;
120
- let t = this.prop(k.group);
121
- return t ? t.indexOf(e) > -1 : !1;
122
- }
123
- return this.id == e;
124
- }
125
- /**
126
- Create a function from node types to arbitrary values by
127
- specifying an object whose property names are node or
128
- [group](#common.NodeProp^group) names. Often useful with
129
- [`NodeProp.add`](#common.NodeProp.add). You can put multiple
130
- names, separated by spaces, in a single property name to map
131
- multiple node names to a single value.
132
- */
133
- static match(e) {
134
- let t = /* @__PURE__ */ Object.create(null);
135
- for (let r in e)
136
- for (let n of r.split(" "))
137
- t[n] = e[r];
138
- return (r) => {
139
- for (let n = r.prop(k.group), i = -1; i < (n ? n.length : 0); i++) {
140
- let s = t[i < 0 ? r.name : n[i]];
141
- if (s)
142
- return s;
143
- }
144
- };
145
- }
146
- }
147
- j.none = new j(
148
- "",
149
- /* @__PURE__ */ Object.create(null),
150
- 0,
151
- 8
152
- /* NodeFlag.Anonymous */
153
- );
154
- const Q = /* @__PURE__ */ new WeakMap(), fe = /* @__PURE__ */ new WeakMap();
155
- var _;
156
- (function(l) {
157
- l[l.ExcludeBuffers = 1] = "ExcludeBuffers", l[l.IncludeAnonymous = 2] = "IncludeAnonymous", l[l.IgnoreMounts = 4] = "IgnoreMounts", l[l.IgnoreOverlays = 8] = "IgnoreOverlays", l[l.EnterBracketed = 16] = "EnterBracketed";
158
- })(_ || (_ = {}));
159
- class P {
160
- /**
161
- Construct a new tree. See also [`Tree.build`](#common.Tree^build).
162
- */
163
- constructor(e, t, r, n, i) {
164
- if (this.type = e, this.children = t, this.positions = r, this.length = n, this.props = null, i && i.length) {
165
- this.props = /* @__PURE__ */ Object.create(null);
166
- for (let [s, h] of i)
167
- this.props[typeof s == "number" ? s : s.id] = h;
168
- }
169
- }
170
- /**
171
- @internal
172
- */
173
- toString() {
174
- let e = G.get(this);
175
- if (e && !e.overlay)
176
- return e.tree.toString();
177
- let t = "";
178
- for (let r of this.children) {
179
- let n = r.toString();
180
- n && (t && (t += ","), t += n);
181
- }
182
- return this.type.name ? (/\W/.test(this.type.name) && !this.type.isError ? JSON.stringify(this.type.name) : this.type.name) + (t.length ? "(" + t + ")" : "") : t;
183
- }
184
- /**
185
- Get a [tree cursor](#common.TreeCursor) positioned at the top of
186
- the tree. Mode can be used to [control](#common.IterMode) which
187
- nodes the cursor visits.
188
- */
189
- cursor(e = 0) {
190
- return new te(this.topNode, e);
191
- }
192
- /**
193
- Get a [tree cursor](#common.TreeCursor) pointing into this tree
194
- at the given position and side (see
195
- [`moveTo`](#common.TreeCursor.moveTo).
196
- */
197
- cursorAt(e, t = 0, r = 0) {
198
- let n = Q.get(this) || this.topNode, i = new te(n);
199
- return i.moveTo(e, t), Q.set(this, i._tree), i;
200
- }
201
- /**
202
- Get a [syntax node](#common.SyntaxNode) object for the top of the
203
- tree.
204
- */
205
- get topNode() {
206
- return new I(this, 0, 0, null);
207
- }
208
- /**
209
- Get the [syntax node](#common.SyntaxNode) at the given position.
210
- If `side` is -1, this will move into nodes that end at the
211
- position. If 1, it'll move into nodes that start at the
212
- position. With 0, it'll only enter nodes that cover the position
213
- from both sides.
214
-
215
- Note that this will not enter
216
- [overlays](#common.MountedTree.overlay), and you often want
217
- [`resolveInner`](#common.Tree.resolveInner) instead.
218
- */
219
- resolve(e, t = 0) {
220
- let r = $(Q.get(this) || this.topNode, e, t, !1);
221
- return Q.set(this, r), r;
222
- }
223
- /**
224
- Like [`resolve`](#common.Tree.resolve), but will enter
225
- [overlaid](#common.MountedTree.overlay) nodes, producing a syntax node
226
- pointing into the innermost overlaid tree at the given position
227
- (with parent links going through all parent structure, including
228
- the host trees).
229
- */
230
- resolveInner(e, t = 0) {
231
- let r = $(fe.get(this) || this.topNode, e, t, !0);
232
- return fe.set(this, r), r;
233
- }
234
- /**
235
- In some situations, it can be useful to iterate through all
236
- nodes around a position, including those in overlays that don't
237
- directly cover the position. This method gives you an iterator
238
- that will produce all nodes, from small to big, around the given
239
- position.
240
- */
241
- resolveStack(e, t = 0) {
242
- return be(this, e, t);
243
- }
244
- /**
245
- Iterate over the tree and its children, calling `enter` for any
246
- node that touches the `from`/`to` region (if given) before
247
- running over such a node's children, and `leave` (if given) when
248
- leaving the node. When `enter` returns `false`, that node will
249
- not have its children iterated over (or `leave` called).
250
- */
251
- iterate(e) {
252
- let { enter: t, leave: r, from: n = 0, to: i = this.length } = e, s = e.mode || 0, h = (s & _.IncludeAnonymous) > 0;
253
- for (let o = this.cursor(s | _.IncludeAnonymous); ; ) {
254
- let C = !1;
255
- if (o.from <= i && o.to >= n && (!h && o.type.isAnonymous || t(o) !== !1)) {
256
- if (o.firstChild())
257
- continue;
258
- C = !0;
259
- }
260
- for (; C && r && (h || !o.type.isAnonymous) && r(o), !o.nextSibling(); ) {
261
- if (!o.parent())
262
- return;
263
- C = !0;
264
- }
265
- }
266
- }
267
- /**
268
- Get the value of the given [node prop](#common.NodeProp) for this
269
- node. Works with both per-node and per-type props.
270
- */
271
- prop(e) {
272
- return e.perNode ? this.props ? this.props[e.id] : void 0 : this.type.prop(e);
273
- }
274
- /**
275
- Returns the node's [per-node props](#common.NodeProp.perNode) in a
276
- format that can be passed to the [`Tree`](#common.Tree)
277
- constructor.
278
- */
279
- get propValues() {
280
- let e = [];
281
- if (this.props)
282
- for (let t in this.props)
283
- e.push([+t, this.props[t]]);
284
- return e;
285
- }
286
- /**
287
- Balance the direct children of this tree, producing a copy of
288
- which may have children grouped into subtrees with type
289
- [`NodeType.none`](#common.NodeType^none).
290
- */
291
- balance(e = {}) {
292
- return this.children.length <= 8 ? this : se(j.none, this.children, this.positions, 0, this.children.length, 0, this.length, (t, r, n) => new P(this.type, t, r, n, this.propValues), e.makeTree || ((t, r, n) => new P(j.none, t, r, n)));
293
- }
294
- /**
295
- Build a tree from a postfix-ordered buffer of node information,
296
- or a cursor over such a buffer.
297
- */
298
- static build(e) {
299
- return me(e);
300
- }
301
- }
302
- P.empty = new P(j.none, [], [], 0);
303
- class ne {
304
- constructor(e, t) {
305
- this.buffer = e, this.index = t;
306
- }
307
- get id() {
308
- return this.buffer[this.index - 4];
309
- }
310
- get start() {
311
- return this.buffer[this.index - 3];
312
- }
313
- get end() {
314
- return this.buffer[this.index - 2];
315
- }
316
- get size() {
317
- return this.buffer[this.index - 1];
318
- }
319
- get pos() {
320
- return this.index;
321
- }
322
- next() {
323
- this.index -= 4;
324
- }
325
- fork() {
326
- return new ne(this.buffer, this.index);
327
- }
328
- }
329
- class W {
330
- /**
331
- Create a tree buffer.
332
- */
333
- constructor(e, t, r) {
334
- this.buffer = e, this.length = t, this.set = r;
335
- }
336
- /**
337
- @internal
338
- */
339
- get type() {
340
- return j.none;
341
- }
342
- /**
343
- @internal
344
- */
345
- toString() {
346
- let e = [];
347
- for (let t = 0; t < this.buffer.length; )
348
- e.push(this.childString(t)), t = this.buffer[t + 3];
349
- return e.join(",");
350
- }
351
- /**
352
- @internal
353
- */
354
- childString(e) {
355
- let t = this.buffer[e], r = this.buffer[e + 3], n = this.set.types[t], i = n.name;
356
- if (/\W/.test(i) && !n.isError && (i = JSON.stringify(i)), e += 4, r == e)
357
- return i;
358
- let s = [];
359
- for (; e < r; )
360
- s.push(this.childString(e)), e = this.buffer[e + 3];
361
- return i + "(" + s.join(",") + ")";
362
- }
363
- /**
364
- @internal
365
- */
366
- findChild(e, t, r, n, i) {
367
- let { buffer: s } = this, h = -1;
368
- for (let o = e; o != t && !(ae(i, n, s[o + 1], s[o + 2]) && (h = o, r > 0)); o = s[o + 3])
369
- ;
370
- return h;
371
- }
372
- /**
373
- @internal
374
- */
375
- slice(e, t, r) {
376
- let n = this.buffer, i = new Uint16Array(t - e), s = 0;
377
- for (let h = e, o = 0; h < t; ) {
378
- i[o++] = n[h++], i[o++] = n[h++] - r;
379
- let C = i[o++] = n[h++] - r;
380
- i[o++] = n[h++] - e, s = Math.max(s, C);
381
- }
382
- return new W(i, s, this.set);
383
- }
384
- }
385
- function ae(l, e, t, r) {
386
- switch (l) {
387
- case -2:
388
- return t < e;
389
- case -1:
390
- return r >= e && t < e;
391
- case 0:
392
- return t < e && r > e;
393
- case 1:
394
- return t <= e && r > e;
395
- case 2:
396
- return r > e;
397
- case 4:
398
- return !0;
399
- }
400
- }
401
- function $(l, e, t, r) {
402
- for (var n; l.from == l.to || (t < 1 ? l.from >= e : l.from > e) || (t > -1 ? l.to <= e : l.to < e); ) {
403
- let s = !r && l instanceof I && l.index < 0 ? null : l.parent;
404
- if (!s)
405
- return l;
406
- l = s;
407
- }
408
- let i = r ? 0 : _.IgnoreOverlays;
409
- if (r)
410
- for (let s = l, h = s.parent; h; s = h, h = s.parent)
411
- s instanceof I && s.index < 0 && ((n = h.enter(e, t, i)) === null || n === void 0 ? void 0 : n.from) != s.from && (l = h);
412
- for (; ; ) {
413
- let s = l.enter(e, t, i);
414
- if (!s)
415
- return l;
416
- l = s;
417
- }
418
- }
419
- class de {
420
- cursor(e = 0) {
421
- return new te(this, e);
422
- }
423
- getChild(e, t = null, r = null) {
424
- let n = ue(this, e, t, r);
425
- return n.length ? n[0] : null;
426
- }
427
- getChildren(e, t = null, r = null) {
428
- return ue(this, e, t, r);
429
- }
430
- resolve(e, t = 0) {
431
- return $(this, e, t, !1);
432
- }
433
- resolveInner(e, t = 0) {
434
- return $(this, e, t, !0);
435
- }
436
- matchContext(e) {
437
- return ee(this.parent, e);
438
- }
439
- enterUnfinishedNodesBefore(e) {
440
- let t = this.childBefore(e), r = this;
441
- for (; t; ) {
442
- let n = t.lastChild;
443
- if (!n || n.to != t.to)
444
- break;
445
- n.type.isError && n.from == n.to ? (r = t, t = n.prevSibling) : t = n;
446
- }
447
- return r;
448
- }
449
- get node() {
450
- return this;
451
- }
452
- get next() {
453
- return this.parent;
454
- }
455
- }
456
- class I extends de {
457
- constructor(e, t, r, n) {
458
- super(), this._tree = e, this.from = t, this.index = r, this._parent = n;
459
- }
460
- get type() {
461
- return this._tree.type;
462
- }
463
- get name() {
464
- return this._tree.type.name;
465
- }
466
- get to() {
467
- return this.from + this._tree.length;
468
- }
469
- nextChild(e, t, r, n, i = 0) {
470
- for (let s = this; ; ) {
471
- for (let { children: h, positions: o } = s._tree, C = t > 0 ? h.length : -1; e != C; e += t) {
472
- let d = h[e], w = o[e] + s.from, A;
473
- if (!(!(i & _.EnterBracketed && d instanceof P && (A = G.get(d)) && !A.overlay && A.bracketed && r >= w && r <= w + d.length) && !ae(n, r, w, w + d.length))) {
474
- if (d instanceof W) {
475
- if (i & _.ExcludeBuffers)
476
- continue;
477
- let B = d.findChild(0, d.buffer.length, t, r - w, n);
478
- if (B > -1)
479
- return new U(new xe(s, d, e, w), null, B);
480
- } else if (i & _.IncludeAnonymous || !d.type.isAnonymous || ie(d)) {
481
- let B;
482
- if (!(i & _.IgnoreMounts) && (B = G.get(d)) && !B.overlay)
483
- return new I(B.tree, w, e, s);
484
- let S = new I(d, w, e, s);
485
- return i & _.IncludeAnonymous || !S.type.isAnonymous ? S : S.nextChild(t < 0 ? d.children.length - 1 : 0, t, r, n, i);
486
- }
487
- }
488
- }
489
- if (i & _.IncludeAnonymous || !s.type.isAnonymous || (s.index >= 0 ? e = s.index + t : e = t < 0 ? -1 : s._parent._tree.children.length, s = s._parent, !s))
490
- return null;
491
- }
492
- }
493
- get firstChild() {
494
- return this.nextChild(
495
- 0,
496
- 1,
497
- 0,
498
- 4
499
- /* Side.DontCare */
500
- );
501
- }
502
- get lastChild() {
503
- return this.nextChild(
504
- this._tree.children.length - 1,
505
- -1,
506
- 0,
507
- 4
508
- /* Side.DontCare */
509
- );
510
- }
511
- childAfter(e) {
512
- return this.nextChild(
513
- 0,
514
- 1,
515
- e,
516
- 2
517
- /* Side.After */
518
- );
519
- }
520
- childBefore(e) {
521
- return this.nextChild(
522
- this._tree.children.length - 1,
523
- -1,
524
- e,
525
- -2
526
- /* Side.Before */
527
- );
528
- }
529
- prop(e) {
530
- return this._tree.prop(e);
531
- }
532
- enter(e, t, r = 0) {
533
- let n;
534
- if (!(r & _.IgnoreOverlays) && (n = G.get(this._tree)) && n.overlay) {
535
- let i = e - this.from, s = r & _.EnterBracketed && n.bracketed;
536
- for (let { from: h, to: o } of n.overlay)
537
- if ((t > 0 || s ? h <= i : h < i) && (t < 0 || s ? o >= i : o > i))
538
- return new I(n.tree, n.overlay[0].from + this.from, -1, this);
539
- }
540
- return this.nextChild(0, 1, e, t, r);
541
- }
542
- nextSignificantParent() {
543
- let e = this;
544
- for (; e.type.isAnonymous && e._parent; )
545
- e = e._parent;
546
- return e;
547
- }
548
- get parent() {
549
- return this._parent ? this._parent.nextSignificantParent() : null;
550
- }
551
- get nextSibling() {
552
- return this._parent && this.index >= 0 ? this._parent.nextChild(
553
- this.index + 1,
554
- 1,
555
- 0,
556
- 4
557
- /* Side.DontCare */
558
- ) : null;
559
- }
560
- get prevSibling() {
561
- return this._parent && this.index >= 0 ? this._parent.nextChild(
562
- this.index - 1,
563
- -1,
564
- 0,
565
- 4
566
- /* Side.DontCare */
567
- ) : null;
568
- }
569
- get tree() {
570
- return this._tree;
571
- }
572
- toTree() {
573
- return this._tree;
574
- }
575
- /**
576
- @internal
577
- */
578
- toString() {
579
- return this._tree.toString();
580
- }
581
- }
582
- function ue(l, e, t, r) {
583
- let n = l.cursor(), i = [];
584
- if (!n.firstChild())
585
- return i;
586
- if (t != null) {
587
- for (let s = !1; !s; )
588
- if (s = n.type.is(t), !n.nextSibling())
589
- return i;
590
- }
591
- for (; ; ) {
592
- if (r != null && n.type.is(r))
593
- return i;
594
- if (n.type.is(e) && i.push(n.node), !n.nextSibling())
595
- return r == null ? i : [];
596
- }
597
- }
598
- function ee(l, e, t = e.length - 1) {
599
- for (let r = l; t >= 0; r = r.parent) {
600
- if (!r)
601
- return !1;
602
- if (!r.type.isAnonymous) {
603
- if (e[t] && e[t] != r.name)
604
- return !1;
605
- t--;
606
- }
607
- }
608
- return !0;
609
- }
610
- class xe {
611
- constructor(e, t, r, n) {
612
- this.parent = e, this.buffer = t, this.index = r, this.start = n;
613
- }
614
- }
615
- class U extends de {
616
- get name() {
617
- return this.type.name;
618
- }
619
- get from() {
620
- return this.context.start + this.context.buffer.buffer[this.index + 1];
621
- }
622
- get to() {
623
- return this.context.start + this.context.buffer.buffer[this.index + 2];
624
- }
625
- constructor(e, t, r) {
626
- super(), this.context = e, this._parent = t, this.index = r, this.type = e.buffer.set.types[e.buffer.buffer[r]];
627
- }
628
- child(e, t, r) {
629
- let { buffer: n } = this.context, i = n.findChild(this.index + 4, n.buffer[this.index + 3], e, t - this.context.start, r);
630
- return i < 0 ? null : new U(this.context, this, i);
631
- }
632
- get firstChild() {
633
- return this.child(
634
- 1,
635
- 0,
636
- 4
637
- /* Side.DontCare */
638
- );
639
- }
640
- get lastChild() {
641
- return this.child(
642
- -1,
643
- 0,
644
- 4
645
- /* Side.DontCare */
646
- );
647
- }
648
- childAfter(e) {
649
- return this.child(
650
- 1,
651
- e,
652
- 2
653
- /* Side.After */
654
- );
655
- }
656
- childBefore(e) {
657
- return this.child(
658
- -1,
659
- e,
660
- -2
661
- /* Side.Before */
662
- );
663
- }
664
- prop(e) {
665
- return this.type.prop(e);
666
- }
667
- enter(e, t, r = 0) {
668
- if (r & _.ExcludeBuffers)
669
- return null;
670
- let { buffer: n } = this.context, i = n.findChild(this.index + 4, n.buffer[this.index + 3], t > 0 ? 1 : -1, e - this.context.start, t);
671
- return i < 0 ? null : new U(this.context, this, i);
672
- }
673
- get parent() {
674
- return this._parent || this.context.parent.nextSignificantParent();
675
- }
676
- externalSibling(e) {
677
- return this._parent ? null : this.context.parent.nextChild(
678
- this.context.index + e,
679
- e,
680
- 0,
681
- 4
682
- /* Side.DontCare */
683
- );
684
- }
685
- get nextSibling() {
686
- let { buffer: e } = this.context, t = e.buffer[this.index + 3];
687
- return t < (this._parent ? e.buffer[this._parent.index + 3] : e.buffer.length) ? new U(this.context, this._parent, t) : this.externalSibling(1);
688
- }
689
- get prevSibling() {
690
- let { buffer: e } = this.context, t = this._parent ? this._parent.index + 4 : 0;
691
- return this.index == t ? this.externalSibling(-1) : new U(this.context, this._parent, e.findChild(
692
- t,
693
- this.index,
694
- -1,
695
- 0,
696
- 4
697
- /* Side.DontCare */
698
- ));
699
- }
700
- get tree() {
701
- return null;
702
- }
703
- toTree() {
704
- let e = [], t = [], { buffer: r } = this.context, n = this.index + 4, i = r.buffer[this.index + 3];
705
- if (i > n) {
706
- let s = r.buffer[this.index + 1];
707
- e.push(r.slice(n, i, s)), t.push(0);
708
- }
709
- return new P(this.type, e, t, this.to - this.from);
710
- }
711
- /**
712
- @internal
713
- */
714
- toString() {
715
- return this.context.buffer.childString(this.index);
716
- }
717
- }
718
- function pe(l) {
719
- if (!l.length)
720
- return null;
721
- let e = 0, t = l[0];
722
- for (let i = 1; i < l.length; i++) {
723
- let s = l[i];
724
- (s.from > t.from || s.to < t.to) && (t = s, e = i);
725
- }
726
- let r = t instanceof I && t.index < 0 ? null : t.parent, n = l.slice();
727
- return r ? n[e] = r : n.splice(e, 1), new ye(n, t);
728
- }
729
- class ye {
730
- constructor(e, t) {
731
- this.heads = e, this.node = t;
732
- }
733
- get next() {
734
- return pe(this.heads);
735
- }
736
- }
737
- function be(l, e, t) {
738
- let r = l.resolveInner(e, t), n = null;
739
- for (let i = r instanceof I ? r : r.context.parent; i; i = i.parent)
740
- if (i.index < 0) {
741
- let s = i.parent;
742
- (n || (n = [r])).push(s.resolve(e, t)), i = s;
743
- } else {
744
- let s = G.get(i.tree);
745
- if (s && s.overlay && s.overlay[0].from <= e && s.overlay[s.overlay.length - 1].to >= e) {
746
- let h = new I(s.tree, s.overlay[0].from + i.from, -1, i);
747
- (n || (n = [r])).push($(h, e, t, !1));
748
- }
749
- }
750
- return n ? pe(n) : r;
751
- }
752
- class te {
753
- /**
754
- Shorthand for `.type.name`.
755
- */
756
- get name() {
757
- return this.type.name;
758
- }
759
- /**
760
- @internal
761
- */
762
- constructor(e, t = 0) {
763
- if (this.buffer = null, this.stack = [], this.index = 0, this.bufferNode = null, this.mode = t & ~_.EnterBracketed, e instanceof I)
764
- this.yieldNode(e);
765
- else {
766
- this._tree = e.context.parent, this.buffer = e.context;
767
- for (let r = e._parent; r; r = r._parent)
768
- this.stack.unshift(r.index);
769
- this.bufferNode = e, this.yieldBuf(e.index);
770
- }
771
- }
772
- yieldNode(e) {
773
- return e ? (this._tree = e, this.type = e.type, this.from = e.from, this.to = e.to, !0) : !1;
774
- }
775
- yieldBuf(e, t) {
776
- this.index = e;
777
- let { start: r, buffer: n } = this.buffer;
778
- return this.type = t || n.set.types[n.buffer[e]], this.from = r + n.buffer[e + 1], this.to = r + n.buffer[e + 2], !0;
779
- }
780
- /**
781
- @internal
782
- */
783
- yield(e) {
784
- return e ? e instanceof I ? (this.buffer = null, this.yieldNode(e)) : (this.buffer = e.context, this.yieldBuf(e.index, e.type)) : !1;
785
- }
786
- /**
787
- @internal
788
- */
789
- toString() {
790
- return this.buffer ? this.buffer.buffer.childString(this.index) : this._tree.toString();
791
- }
792
- /**
793
- @internal
794
- */
795
- enterChild(e, t, r) {
796
- if (!this.buffer)
797
- return this.yield(this._tree.nextChild(e < 0 ? this._tree._tree.children.length - 1 : 0, e, t, r, this.mode));
798
- let { buffer: n } = this.buffer, i = n.findChild(this.index + 4, n.buffer[this.index + 3], e, t - this.buffer.start, r);
799
- return i < 0 ? !1 : (this.stack.push(this.index), this.yieldBuf(i));
800
- }
801
- /**
802
- Move the cursor to this node's first child. When this returns
803
- false, the node has no child, and the cursor has not been moved.
804
- */
805
- firstChild() {
806
- return this.enterChild(
807
- 1,
808
- 0,
809
- 4
810
- /* Side.DontCare */
811
- );
812
- }
813
- /**
814
- Move the cursor to this node's last child.
815
- */
816
- lastChild() {
817
- return this.enterChild(
818
- -1,
819
- 0,
820
- 4
821
- /* Side.DontCare */
822
- );
823
- }
824
- /**
825
- Move the cursor to the first child that ends after `pos`.
826
- */
827
- childAfter(e) {
828
- return this.enterChild(
829
- 1,
830
- e,
831
- 2
832
- /* Side.After */
833
- );
834
- }
835
- /**
836
- Move to the last child that starts before `pos`.
837
- */
838
- childBefore(e) {
839
- return this.enterChild(
840
- -1,
841
- e,
842
- -2
843
- /* Side.Before */
844
- );
845
- }
846
- /**
847
- Move the cursor to the child around `pos`. If side is -1 the
848
- child may end at that position, when 1 it may start there. This
849
- will also enter [overlaid](#common.MountedTree.overlay)
850
- [mounted](#common.NodeProp^mounted) trees unless `overlays` is
851
- set to false.
852
- */
853
- enter(e, t, r = this.mode) {
854
- return this.buffer ? r & _.ExcludeBuffers ? !1 : this.enterChild(1, e, t) : this.yield(this._tree.enter(e, t, r));
855
- }
856
- /**
857
- Move to the node's parent node, if this isn't the top node.
858
- */
859
- parent() {
860
- if (!this.buffer)
861
- return this.yieldNode(this.mode & _.IncludeAnonymous ? this._tree._parent : this._tree.parent);
862
- if (this.stack.length)
863
- return this.yieldBuf(this.stack.pop());
864
- let e = this.mode & _.IncludeAnonymous ? this.buffer.parent : this.buffer.parent.nextSignificantParent();
865
- return this.buffer = null, this.yieldNode(e);
866
- }
867
- /**
868
- @internal
869
- */
870
- sibling(e) {
871
- if (!this.buffer)
872
- return this._tree._parent ? this.yield(this._tree.index < 0 ? null : this._tree._parent.nextChild(this._tree.index + e, e, 0, 4, this.mode)) : !1;
873
- let { buffer: t } = this.buffer, r = this.stack.length - 1;
874
- if (e < 0) {
875
- let n = r < 0 ? 0 : this.stack[r] + 4;
876
- if (this.index != n)
877
- return this.yieldBuf(t.findChild(
878
- n,
879
- this.index,
880
- -1,
881
- 0,
882
- 4
883
- /* Side.DontCare */
884
- ));
885
- } else {
886
- let n = t.buffer[this.index + 3];
887
- if (n < (r < 0 ? t.buffer.length : t.buffer[this.stack[r] + 3]))
888
- return this.yieldBuf(n);
889
- }
890
- return r < 0 ? this.yield(this.buffer.parent.nextChild(this.buffer.index + e, e, 0, 4, this.mode)) : !1;
891
- }
892
- /**
893
- Move to this node's next sibling, if any.
894
- */
895
- nextSibling() {
896
- return this.sibling(1);
897
- }
898
- /**
899
- Move to this node's previous sibling, if any.
900
- */
901
- prevSibling() {
902
- return this.sibling(-1);
903
- }
904
- atLastNode(e) {
905
- let t, r, { buffer: n } = this;
906
- if (n) {
907
- if (e > 0) {
908
- if (this.index < n.buffer.buffer.length)
909
- return !1;
910
- } else
911
- for (let i = 0; i < this.index; i++)
912
- if (n.buffer.buffer[i + 3] < this.index)
913
- return !1;
914
- ({ index: t, parent: r } = n);
915
- } else
916
- ({ index: t, _parent: r } = this._tree);
917
- for (; r; { index: t, _parent: r } = r)
918
- if (t > -1)
919
- for (let i = t + e, s = e < 0 ? -1 : r._tree.children.length; i != s; i += e) {
920
- let h = r._tree.children[i];
921
- if (this.mode & _.IncludeAnonymous || h instanceof W || !h.type.isAnonymous || ie(h))
922
- return !1;
923
- }
924
- return !0;
925
- }
926
- move(e, t) {
927
- if (t && this.enterChild(
928
- e,
929
- 0,
930
- 4
931
- /* Side.DontCare */
932
- ))
933
- return !0;
934
- for (; ; ) {
935
- if (this.sibling(e))
936
- return !0;
937
- if (this.atLastNode(e) || !this.parent())
938
- return !1;
939
- }
940
- }
941
- /**
942
- Move to the next node in a
943
- [pre-order](https://en.wikipedia.org/wiki/Tree_traversal#Pre-order,_NLR)
944
- traversal, going from a node to its first child or, if the
945
- current node is empty or `enter` is false, its next sibling or
946
- the next sibling of the first parent node that has one.
947
- */
948
- next(e = !0) {
949
- return this.move(1, e);
950
- }
951
- /**
952
- Move to the next node in a last-to-first pre-order traversal. A
953
- node is followed by its last child or, if it has none, its
954
- previous sibling or the previous sibling of the first parent
955
- node that has one.
956
- */
957
- prev(e = !0) {
958
- return this.move(-1, e);
959
- }
960
- /**
961
- Move the cursor to the innermost node that covers `pos`. If
962
- `side` is -1, it will enter nodes that end at `pos`. If it is 1,
963
- it will enter nodes that start at `pos`.
964
- */
965
- moveTo(e, t = 0) {
966
- for (; (this.from == this.to || (t < 1 ? this.from >= e : this.from > e) || (t > -1 ? this.to <= e : this.to < e)) && this.parent(); )
967
- ;
968
- for (; this.enterChild(1, e, t); )
969
- ;
970
- return this;
971
- }
972
- /**
973
- Get a [syntax node](#common.SyntaxNode) at the cursor's current
974
- position.
975
- */
976
- get node() {
977
- if (!this.buffer)
978
- return this._tree;
979
- let e = this.bufferNode, t = null, r = 0;
980
- if (e && e.context == this.buffer)
981
- e: for (let n = this.index, i = this.stack.length; i >= 0; ) {
982
- for (let s = e; s; s = s._parent)
983
- if (s.index == n) {
984
- if (n == this.index)
985
- return s;
986
- t = s, r = i + 1;
987
- break e;
988
- }
989
- n = this.stack[--i];
990
- }
991
- for (let n = r; n < this.stack.length; n++)
992
- t = new U(this.buffer, t, this.stack[n]);
993
- return this.bufferNode = new U(this.buffer, t, this.index);
994
- }
995
- /**
996
- Get the [tree](#common.Tree) that represents the current node, if
997
- any. Will return null when the node is in a [tree
998
- buffer](#common.TreeBuffer).
999
- */
1000
- get tree() {
1001
- return this.buffer ? null : this._tree._tree;
1002
- }
1003
- /**
1004
- Iterate over the current node and all its descendants, calling
1005
- `enter` when entering a node and `leave`, if given, when leaving
1006
- one. When `enter` returns `false`, any children of that node are
1007
- skipped, and `leave` isn't called for it.
1008
- */
1009
- iterate(e, t) {
1010
- for (let r = 0; ; ) {
1011
- let n = !1;
1012
- if (this.type.isAnonymous || e(this) !== !1) {
1013
- if (this.firstChild()) {
1014
- r++;
1015
- continue;
1016
- }
1017
- this.type.isAnonymous || (n = !0);
1018
- }
1019
- for (; ; ) {
1020
- if (n && t && t(this), n = this.type.isAnonymous, !r)
1021
- return;
1022
- if (this.nextSibling())
1023
- break;
1024
- this.parent(), r--, n = !0;
1025
- }
1026
- }
1027
- }
1028
- /**
1029
- Test whether the current node matches a given context—a sequence
1030
- of direct parent node names. Empty strings in the context array
1031
- are treated as wildcards.
1032
- */
1033
- matchContext(e) {
1034
- if (!this.buffer)
1035
- return ee(this.node.parent, e);
1036
- let { buffer: t } = this.buffer, { types: r } = t.set;
1037
- for (let n = e.length - 1, i = this.stack.length - 1; n >= 0; i--) {
1038
- if (i < 0)
1039
- return ee(this._tree, e, n);
1040
- let s = r[t.buffer[this.stack[i]]];
1041
- if (!s.isAnonymous) {
1042
- if (e[n] && e[n] != s.name)
1043
- return !1;
1044
- n--;
1045
- }
1046
- }
1047
- return !0;
1048
- }
1049
- }
1050
- function ie(l) {
1051
- return l.children.some((e) => e instanceof W || !e.type.isAnonymous || ie(e));
1052
- }
1053
- function me(l) {
1054
- var e;
1055
- let { buffer: t, nodeSet: r, maxBufferLength: n = 1024, reused: i = [], minRepeatType: s = r.types.length } = l, h = Array.isArray(t) ? new ne(t, t.length) : t, o = r.types, C = 0, d = 0;
1056
- function w(c, x, f, b, p, m) {
1057
- let { id: a, start: u, end: g, size: y } = h, v = d, L = C;
1058
- if (y < 0)
1059
- if (h.next(), y == -1) {
1060
- let O = i[a];
1061
- f.push(O), b.push(u - c);
1062
- return;
1063
- } else if (y == -3) {
1064
- C = a;
1065
- return;
1066
- } else if (y == -4) {
1067
- d = a;
1068
- return;
1069
- } else
1070
- throw new RangeError(`Unrecognized record size: ${y}`);
1071
- let V = o[a], q, F, le = u - c;
1072
- if (g - u <= n && (F = Y(h.pos - x, p))) {
1073
- let O = new Uint16Array(F.size - F.skip), N = h.pos - F.size, E = O.length;
1074
- for (; h.pos > N; )
1075
- E = J(F.start, O, E);
1076
- q = new W(O, g - F.start, r), le = F.start - c;
1077
- } else {
1078
- let O = h.pos - y;
1079
- h.next();
1080
- let N = [], E = [], H = a >= s ? a : -1, M = 0, K = g;
1081
- for (; h.pos > O; )
1082
- H >= 0 && h.id == H && h.size >= 0 ? (h.end <= K - n && (S(N, E, u, M, h.end, K, H, v, L), M = N.length, K = h.end), h.next()) : m > 2500 ? A(u, O, N, E) : w(u, O, N, E, H, m + 1);
1083
- if (H >= 0 && M > 0 && M < N.length && S(N, E, u, M, u, K, H, v, L), N.reverse(), E.reverse(), H > -1 && M > 0) {
1084
- let he = B(V, L);
1085
- q = se(V, N, E, 0, N.length, 0, g - u, he, he);
1086
- } else
1087
- q = R(V, N, E, g - u, v - g, L);
1088
- }
1089
- f.push(q), b.push(le);
1090
- }
1091
- function A(c, x, f, b) {
1092
- let p = [], m = 0, a = -1;
1093
- for (; h.pos > x; ) {
1094
- let { id: u, start: g, end: y, size: v } = h;
1095
- if (v > 4)
1096
- h.next();
1097
- else {
1098
- if (a > -1 && g < a)
1099
- break;
1100
- a < 0 && (a = y - n), p.push(u, g, y), m++, h.next();
1101
- }
1102
- }
1103
- if (m) {
1104
- let u = new Uint16Array(m * 4), g = p[p.length - 2];
1105
- for (let y = p.length - 3, v = 0; y >= 0; y -= 3)
1106
- u[v++] = p[y], u[v++] = p[y + 1] - g, u[v++] = p[y + 2] - g, u[v++] = v;
1107
- f.push(new W(u, p[2] - g, r)), b.push(g - c);
1108
- }
1109
- }
1110
- function B(c, x) {
1111
- return (f, b, p) => {
1112
- let m = 0, a = f.length - 1, u, g;
1113
- if (a >= 0 && (u = f[a]) instanceof P) {
1114
- if (!a && u.type == c && u.length == p)
1115
- return u;
1116
- (g = u.prop(k.lookAhead)) && (m = b[a] + u.length + g);
1117
- }
1118
- return R(c, f, b, p, m, x);
1119
- };
1120
- }
1121
- function S(c, x, f, b, p, m, a, u, g) {
1122
- let y = [], v = [];
1123
- for (; c.length > b; )
1124
- y.push(c.pop()), v.push(x.pop() + f - p);
1125
- c.push(R(r.types[a], y, v, m - p, u - m, g)), x.push(p - f);
1126
- }
1127
- function R(c, x, f, b, p, m, a) {
1128
- if (m) {
1129
- let u = [k.contextHash, m];
1130
- a = a ? [u].concat(a) : [u];
1131
- }
1132
- if (p > 25) {
1133
- let u = [k.lookAhead, p];
1134
- a = a ? [u].concat(a) : [u];
1135
- }
1136
- return new P(c, x, f, b, a);
1137
- }
1138
- function Y(c, x) {
1139
- let f = h.fork(), b = 0, p = 0, m = 0, a = f.end - n, u = { size: 0, start: 0, skip: 0 };
1140
- e: for (let g = f.pos - c; f.pos > g; ) {
1141
- let y = f.size;
1142
- if (f.id == x && y >= 0) {
1143
- u.size = b, u.start = p, u.skip = m, m += 4, b += 4, f.next();
1144
- continue;
1145
- }
1146
- let v = f.pos - y;
1147
- if (y < 0 || v < g || f.start < a)
1148
- break;
1149
- let L = f.id >= s ? 4 : 0, V = f.start;
1150
- for (f.next(); f.pos > v; ) {
1151
- if (f.size < 0)
1152
- if (f.size == -3 || f.size == -4)
1153
- L += 4;
1154
- else
1155
- break e;
1156
- else f.id >= s && (L += 4);
1157
- f.next();
1158
- }
1159
- p = V, b += y, m += L;
1160
- }
1161
- return (x < 0 || b == c) && (u.size = b, u.start = p, u.skip = m), u.size > 4 ? u : void 0;
1162
- }
1163
- function J(c, x, f) {
1164
- let { id: b, start: p, end: m, size: a } = h;
1165
- if (h.next(), a >= 0 && b < s) {
1166
- let u = f;
1167
- if (a > 4) {
1168
- let g = h.pos - (a - 4);
1169
- for (; h.pos > g; )
1170
- f = J(c, x, f);
1171
- }
1172
- x[--f] = u, x[--f] = m - c, x[--f] = p - c, x[--f] = b;
1173
- } else a == -3 ? C = b : a == -4 && (d = b);
1174
- return f;
1175
- }
1176
- let D = [], z = [];
1177
- for (; h.pos > 0; )
1178
- w(l.start || 0, l.bufferStart || 0, D, z, -1, 0);
1179
- let T = (e = l.length) !== null && e !== void 0 ? e : D.length ? z[0] + D[0].length : 0;
1180
- return new P(o[l.topID], D.reverse(), z.reverse(), T);
1181
- }
1182
- const oe = /* @__PURE__ */ new WeakMap();
1183
- function X(l, e) {
1184
- if (!l.isAnonymous || e instanceof W || e.type != l)
1185
- return 1;
1186
- let t = oe.get(e);
1187
- if (t == null) {
1188
- t = 1;
1189
- for (let r of e.children) {
1190
- if (r.type != l || !(r instanceof P)) {
1191
- t = 1;
1192
- break;
1193
- }
1194
- t += X(l, r);
1195
- }
1196
- oe.set(e, t);
1197
- }
1198
- return t;
1199
- }
1200
- function se(l, e, t, r, n, i, s, h, o) {
1201
- let C = 0;
1202
- for (let S = r; S < n; S++)
1203
- C += X(l, e[S]);
1204
- let d = Math.ceil(
1205
- C * 1.5 / 8
1206
- /* Balance.BranchFactor */
1207
- ), w = [], A = [];
1208
- function B(S, R, Y, J, D) {
1209
- for (let z = Y; z < J; ) {
1210
- let T = z, c = R[z], x = X(l, S[z]);
1211
- for (z++; z < J; z++) {
1212
- let f = X(l, S[z]);
1213
- if (x + f >= d)
1214
- break;
1215
- x += f;
1216
- }
1217
- if (z == T + 1) {
1218
- if (x > d) {
1219
- let f = S[T];
1220
- B(f.children, f.positions, 0, f.children.length, R[T] + D);
1221
- continue;
1222
- }
1223
- w.push(S[T]);
1224
- } else {
1225
- let f = R[z - 1] + S[z - 1].length - c;
1226
- w.push(se(l, S, R, T, z, c, f, null, o));
1227
- }
1228
- A.push(c + D - i);
1229
- }
1230
- }
1231
- return B(e, t, r, n, 0), (h || o)(w, A, s);
1232
- }
1233
- class re {
1234
- /**
1235
- Construct a tree fragment. You'll usually want to use
1236
- [`addTree`](#common.TreeFragment^addTree) and
1237
- [`applyChanges`](#common.TreeFragment^applyChanges) instead of
1238
- calling this directly.
1239
- */
1240
- constructor(e, t, r, n, i = !1, s = !1) {
1241
- this.from = e, this.to = t, this.tree = r, this.offset = n, this.open = (i ? 1 : 0) | (s ? 2 : 0);
1242
- }
1243
- /**
1244
- Whether the start of the fragment represents the start of a
1245
- parse, or the end of a change. (In the second case, it may not
1246
- be safe to reuse some nodes at the start, depending on the
1247
- parsing algorithm.)
1248
- */
1249
- get openStart() {
1250
- return (this.open & 1) > 0;
1251
- }
1252
- /**
1253
- Whether the end of the fragment represents the end of a
1254
- full-document parse, or the start of a change.
1255
- */
1256
- get openEnd() {
1257
- return (this.open & 2) > 0;
1258
- }
1259
- /**
1260
- Create a set of fragments from a freshly parsed tree, or update
1261
- an existing set of fragments by replacing the ones that overlap
1262
- with a tree with content from the new tree. When `partial` is
1263
- true, the parse is treated as incomplete, and the resulting
1264
- fragment has [`openEnd`](#common.TreeFragment.openEnd) set to
1265
- true.
1266
- */
1267
- static addTree(e, t = [], r = !1) {
1268
- let n = [new re(0, e.length, e, 0, !1, r)];
1269
- for (let i of t)
1270
- i.to > e.length && n.push(i);
1271
- return n;
1272
- }
1273
- /**
1274
- Apply a set of edits to an array of fragments, removing or
1275
- splitting fragments as necessary to remove edited ranges, and
1276
- adjusting offsets for fragments that moved.
1277
- */
1278
- static applyChanges(e, t, r = 128) {
1279
- if (!t.length)
1280
- return e;
1281
- let n = [], i = 1, s = e.length ? e[0] : null;
1282
- for (let h = 0, o = 0, C = 0; ; h++) {
1283
- let d = h < t.length ? t[h] : null, w = d ? d.fromA : 1e9;
1284
- if (w - o >= r)
1285
- for (; s && s.from < w; ) {
1286
- let A = s;
1287
- if (o >= A.from || w <= A.to || C) {
1288
- let B = Math.max(A.from, o) - C, S = Math.min(A.to, w) - C;
1289
- A = B >= S ? null : new re(B, S, A.tree, A.offset + C, h > 0, !!d);
1290
- }
1291
- if (A && n.push(A), s.to > w)
1292
- break;
1293
- s = i < e.length ? e[i++] : null;
1294
- }
1295
- if (!d)
1296
- break;
1297
- o = d.toA, C = d.toA - d.toB;
1298
- }
1299
- return n;
1300
- }
1301
- }
1302
- class Ce {
1303
- /**
1304
- Start a parse, returning a [partial parse](#common.PartialParse)
1305
- object. [`fragments`](#common.TreeFragment) can be passed in to
1306
- make the parse incremental.
1307
-
1308
- By default, the entire input is parsed. You can pass `ranges`,
1309
- which should be a sorted array of non-empty, non-overlapping
1310
- ranges, to parse only those ranges. The tree returned in that
1311
- case will start at `ranges[0].from`.
1312
- */
1313
- startParse(e, t, r) {
1314
- return typeof e == "string" && (e = new we(e)), r = r ? r.length ? r.map((n) => new Z(n.from, n.to)) : [new Z(0, 0)] : [new Z(0, e.length)], this.createParse(e, t || [], r);
1315
- }
1316
- /**
1317
- Run a full parse, returning the resulting tree.
1318
- */
1319
- parse(e, t, r) {
1320
- let n = this.startParse(e, t, r);
1321
- for (; ; ) {
1322
- let i = n.advance();
1323
- if (i)
1324
- return i;
1325
- }
1326
- }
1327
- }
1328
- class we {
1329
- constructor(e) {
1330
- this.string = e;
1331
- }
1332
- get length() {
1333
- return this.string.length;
1334
- }
1335
- chunk(e) {
1336
- return this.string.slice(e);
1337
- }
1338
- get lineChunks() {
1339
- return !1;
1340
- }
1341
- read(e, t) {
1342
- return this.string.slice(e, t);
1343
- }
1344
- }
1345
- new k({ perNode: !0 });
1346
- export {
1347
- ke as DefaultBufferLength,
1348
- _ as IterMode,
1349
- G as MountedTree,
1350
- k as NodeProp,
1351
- j as NodeType,
1352
- Ce as Parser,
1353
- P as Tree,
1354
- W as TreeBuffer,
1355
- te as TreeCursor,
1356
- re as TreeFragment
1357
- };