@stream-mdx/react 0.4.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. package/CHANGELOG.md +385 -4
  2. package/README.md +141 -16
  3. package/dist/blocks-renderer-DAOBFBfi.d.ts +29 -0
  4. package/dist/blocks-renderer-DQEL1kJW.d.cts +29 -0
  5. package/dist/components/bottom-stick-scroll-area.cjs +268 -0
  6. package/dist/components/bottom-stick-scroll-area.d.cts +36 -0
  7. package/dist/components/bottom-stick-scroll-area.d.ts +36 -0
  8. package/dist/components/bottom-stick-scroll-area.mjs +249 -0
  9. package/dist/components/diff-renderer.cjs +86 -0
  10. package/dist/components/diff-renderer.d.cts +11 -0
  11. package/dist/components/diff-renderer.d.ts +11 -0
  12. package/dist/components/diff-renderer.mjs +66 -0
  13. package/dist/components/index.cjs +2879 -1295
  14. package/dist/components/index.d.cts +9 -2
  15. package/dist/components/index.d.ts +9 -2
  16. package/dist/components/index.mjs +2842 -1277
  17. package/dist/components/katex-math.cjs +220 -0
  18. package/dist/components/katex-math.d.cts +10 -0
  19. package/dist/components/katex-math.d.ts +10 -0
  20. package/dist/components/katex-math.mjs +188 -0
  21. package/dist/contexts/math-tracker.cjs +240 -521
  22. package/dist/contexts/math-tracker.mjs +235 -513
  23. package/dist/index-Cmne1yUK.d.cts +723 -0
  24. package/dist/index-D7dyyu3q.d.ts +723 -0
  25. package/dist/index.cjs +13180 -5640
  26. package/dist/index.d.cts +72 -40
  27. package/dist/index.d.ts +72 -40
  28. package/dist/index.mjs +12587 -5038
  29. package/dist/math/display-wrapper.cjs +7 -15
  30. package/dist/math/display-wrapper.d.cts +2 -2
  31. package/dist/math/display-wrapper.d.ts +2 -2
  32. package/dist/math/display-wrapper.mjs +2 -6
  33. package/dist/node-views-Bpc6Gkgl.d.cts +13 -0
  34. package/dist/node-views-DpnYdaAS.d.ts +13 -0
  35. package/dist/renderer/hooks.cjs +35 -20
  36. package/dist/renderer/hooks.d.cts +22 -1
  37. package/dist/renderer/hooks.d.ts +22 -1
  38. package/dist/renderer/hooks.mjs +27 -12
  39. package/dist/renderer/patch-batching.cjs +7 -8
  40. package/dist/renderer/patch-batching.d.cts +1 -1
  41. package/dist/renderer/patch-batching.d.ts +1 -1
  42. package/dist/renderer/patch-batching.mjs +2 -1
  43. package/dist/renderer/patch-coalescing.cjs +5 -8
  44. package/dist/renderer/patch-commit-scheduler.cjs +160 -326
  45. package/dist/renderer/patch-commit-scheduler.d.cts +28 -4
  46. package/dist/renderer/patch-commit-scheduler.d.ts +28 -4
  47. package/dist/renderer/patch-commit-scheduler.mjs +157 -318
  48. package/dist/renderer/store.cjs +3847 -1099
  49. package/dist/renderer/store.d.cts +111 -3
  50. package/dist/renderer/store.d.ts +111 -3
  51. package/dist/renderer/store.mjs +3847 -1085
  52. package/dist/renderer/virtualized-code.cjs +415 -71
  53. package/dist/renderer/virtualized-code.d.cts +24 -23
  54. package/dist/renderer/virtualized-code.d.ts +24 -23
  55. package/dist/renderer/virtualized-code.mjs +409 -62
  56. package/dist/renderer.cjs +10939 -3974
  57. package/dist/renderer.d.cts +100 -29
  58. package/dist/renderer.d.ts +100 -29
  59. package/dist/renderer.mjs +10711 -3697
  60. package/dist/server-regions-CPLHGli0.d.cts +32 -0
  61. package/dist/server-regions-mUhyoKi7.d.ts +32 -0
  62. package/dist/server.cjs +10286 -3365
  63. package/dist/server.d.cts +17 -247
  64. package/dist/server.d.ts +17 -247
  65. package/dist/server.mjs +10565 -3619
  66. package/dist/{streaming-markdown-DOc2uLiP.d.ts → streaming-markdown-yELbJxyH.d.ts} +51 -55
  67. package/dist/{streaming-markdown-D-JcByd9.d.cts → streaming-markdown-zVwFuaJG.d.cts} +51 -55
  68. package/dist/streaming-markdown.cjs +11828 -4879
  69. package/dist/streaming-markdown.d.cts +9 -2
  70. package/dist/streaming-markdown.d.ts +9 -2
  71. package/dist/streaming-markdown.mjs +11820 -4821
  72. package/dist/trusted-mdx/index.cjs +833 -0
  73. package/dist/trusted-mdx/index.d.cts +11 -0
  74. package/dist/trusted-mdx/index.d.ts +11 -0
  75. package/dist/trusted-mdx/index.mjs +807 -0
  76. package/dist/trusted-mdx/native-children-slot.cjs +45 -0
  77. package/dist/trusted-mdx/native-children-slot.d.cts +11 -0
  78. package/dist/trusted-mdx/native-children-slot.d.ts +11 -0
  79. package/dist/trusted-mdx/native-children-slot.mjs +24 -0
  80. package/dist/trusted-mdx/server.cjs +752 -0
  81. package/dist/trusted-mdx/server.d.cts +24 -0
  82. package/dist/trusted-mdx/server.d.ts +24 -0
  83. package/dist/trusted-mdx/server.mjs +724 -0
  84. package/dist/trusted-mdx-contract-ElKpkDI5.d.cts +113 -0
  85. package/dist/trusted-mdx-contract-ElKpkDI5.d.ts +113 -0
  86. package/dist/utils/inline-html.cjs +246 -147
  87. package/dist/utils/inline-html.d.cts +39 -6
  88. package/dist/utils/inline-html.d.ts +39 -6
  89. package/dist/utils/inline-html.mjs +237 -134
  90. package/package.json +52 -18
  91. package/shadcn/README.md +28 -0
  92. package/shadcn/bottom-stick-scroll-area.tsx +358 -0
  93. package/dist/index-D2MYusAM.d.cts +0 -248
  94. package/dist/index-D2MYusAM.d.ts +0 -248
  95. package/dist/mdx-client.cjs +0 -408
  96. package/dist/mdx-client.d.cts +0 -113
  97. package/dist/mdx-client.d.ts +0 -113
  98. package/dist/mdx-client.mjs +0 -369
  99. package/dist/mdx-coordinator.cjs +0 -563
  100. package/dist/mdx-coordinator.d.cts +0 -21
  101. package/dist/mdx-coordinator.d.ts +0 -21
  102. package/dist/mdx-coordinator.mjs +0 -529
  103. package/dist/renderer/node-views.cjs +0 -1642
  104. package/dist/renderer/node-views.d.cts +0 -12
  105. package/dist/renderer/node-views.d.ts +0 -12
  106. package/dist/renderer/node-views.mjs +0 -1616
@@ -1,19 +1,15 @@
1
1
  "use client";
2
2
 
3
3
  // ../../node_modules/@lezer/common/dist/index.js
4
- var DefaultBufferLength = 1024;
5
4
  var nextPropID = 0;
6
5
  var NodeProp = class {
7
6
  /**
8
7
  Create a new node prop type.
9
8
  */
10
9
  constructor(config = {}) {
11
- this.id = nextPropID++;
12
- this.perNode = !!config.perNode;
13
- this.deserialize = config.deserialize || (() => {
10
+ this.id = nextPropID++, this.perNode = !!config.perNode, this.deserialize = config.deserialize || (() => {
14
11
  throw new Error("This node type doesn't define a deserialize function");
15
- });
16
- this.combine = config.combine || null;
12
+ }), this.combine = config.combine || null;
17
13
  }
18
14
  /**
19
15
  This is meant to be used with
@@ -27,9 +23,7 @@ var NodeProp = class {
27
23
  add(match) {
28
24
  if (this.perNode)
29
25
  throw new RangeError("Can't add per-node props to node types");
30
- if (typeof match != "function")
31
- match = NodeType.match(match);
32
- return (type) => {
26
+ return typeof match != "function" && (match = NodeType.match(match)), (type) => {
33
27
  let result = match(type);
34
28
  return result === void 0 ? null : [this, result];
35
29
  };
@@ -43,14 +37,12 @@ NodeProp.isolate = new NodeProp({ deserialize: (value) => {
43
37
  throw new RangeError("Invalid value for isolate: " + value);
44
38
  return value || "auto";
45
39
  } });
46
- NodeProp.contextHash = new NodeProp({ perNode: true });
47
- NodeProp.lookAhead = new NodeProp({ perNode: true });
48
- NodeProp.mounted = new NodeProp({ perNode: true });
40
+ NodeProp.contextHash = new NodeProp({ perNode: !0 });
41
+ NodeProp.lookAhead = new NodeProp({ perNode: !0 });
42
+ NodeProp.mounted = new NodeProp({ perNode: !0 });
49
43
  var MountedTree = class {
50
44
  constructor(tree, overlay, parser) {
51
- this.tree = tree;
52
- this.overlay = overlay;
53
- this.parser = parser;
45
+ this.tree = tree, this.overlay = overlay, this.parser = parser;
54
46
  }
55
47
  /**
56
48
  @internal
@@ -58,35 +50,26 @@ var MountedTree = class {
58
50
  static get(tree) {
59
51
  return tree && tree.props && tree.props[NodeProp.mounted.id];
60
52
  }
61
- };
62
- var noProps = /* @__PURE__ */ Object.create(null);
63
- var NodeType = class _NodeType {
53
+ }, noProps = /* @__PURE__ */ Object.create(null), NodeType = class _NodeType {
64
54
  /**
65
55
  @internal
66
56
  */
67
57
  constructor(name, props, id2, flags = 0) {
68
- this.name = name;
69
- this.props = props;
70
- this.id = id2;
71
- this.flags = flags;
58
+ this.name = name, this.props = props, this.id = id2, this.flags = flags;
72
59
  }
73
60
  /**
74
61
  Define a node type.
75
62
  */
76
63
  static define(spec) {
77
- let props = spec.props && spec.props.length ? /* @__PURE__ */ Object.create(null) : noProps;
78
- let flags = (spec.top ? 1 : 0) | (spec.skipped ? 2 : 0) | (spec.error ? 4 : 0) | (spec.name == null ? 8 : 0);
79
- let type = new _NodeType(spec.name || "", props, spec.id, flags);
80
- if (spec.props)
81
- for (let src of spec.props) {
82
- if (!Array.isArray(src))
83
- src = src(type);
84
- if (src) {
64
+ let props = spec.props && spec.props.length ? /* @__PURE__ */ Object.create(null) : noProps, flags = (spec.top ? 1 : 0) | (spec.skipped ? 2 : 0) | (spec.error ? 4 : 0) | (spec.name == null ? 8 : 0), type = new _NodeType(spec.name || "", props, spec.id, flags);
65
+ if (spec.props) {
66
+ for (let src of spec.props)
67
+ if (Array.isArray(src) || (src = src(type)), src) {
85
68
  if (src[0].perNode)
86
69
  throw new RangeError("Can't store a per-node prop on a node type");
87
70
  props[src[0].id] = src[1];
88
71
  }
89
- }
72
+ }
90
73
  return type;
91
74
  }
92
75
  /**
@@ -128,9 +111,9 @@ var NodeType = class _NodeType {
128
111
  is(name) {
129
112
  if (typeof name == "string") {
130
113
  if (this.name == name)
131
- return true;
114
+ return !0;
132
115
  let group = this.prop(NodeProp.group);
133
- return group ? group.indexOf(name) > -1 : false;
116
+ return group ? group.indexOf(name) > -1 : !1;
134
117
  }
135
118
  return this.id == name;
136
119
  }
@@ -163,26 +146,16 @@ NodeType.none = new NodeType(
163
146
  8
164
147
  /* NodeFlag.Anonymous */
165
148
  );
166
- var CachedNode = /* @__PURE__ */ new WeakMap();
167
- var CachedInnerNode = /* @__PURE__ */ new WeakMap();
168
- var IterMode;
149
+ var CachedNode = /* @__PURE__ */ new WeakMap(), CachedInnerNode = /* @__PURE__ */ new WeakMap(), IterMode;
169
150
  (function(IterMode2) {
170
- IterMode2[IterMode2["ExcludeBuffers"] = 1] = "ExcludeBuffers";
171
- IterMode2[IterMode2["IncludeAnonymous"] = 2] = "IncludeAnonymous";
172
- IterMode2[IterMode2["IgnoreMounts"] = 4] = "IgnoreMounts";
173
- IterMode2[IterMode2["IgnoreOverlays"] = 8] = "IgnoreOverlays";
151
+ IterMode2[IterMode2.ExcludeBuffers = 1] = "ExcludeBuffers", IterMode2[IterMode2.IncludeAnonymous = 2] = "IncludeAnonymous", IterMode2[IterMode2.IgnoreMounts = 4] = "IgnoreMounts", IterMode2[IterMode2.IgnoreOverlays = 8] = "IgnoreOverlays";
174
152
  })(IterMode || (IterMode = {}));
175
153
  var Tree = class _Tree {
176
154
  /**
177
155
  Construct a new tree. See also [`Tree.build`](#common.Tree^build).
178
156
  */
179
157
  constructor(type, children, positions, length, props) {
180
- this.type = type;
181
- this.children = children;
182
- this.positions = positions;
183
- this.length = length;
184
- this.props = null;
185
- if (props && props.length) {
158
+ if (this.type = type, this.children = children, this.positions = positions, this.length = length, this.props = null, props && props.length) {
186
159
  this.props = /* @__PURE__ */ Object.create(null);
187
160
  for (let [prop, value] of props)
188
161
  this.props[typeof prop == "number" ? prop : prop.id] = value;
@@ -198,13 +171,9 @@ var Tree = class _Tree {
198
171
  let children = "";
199
172
  for (let ch of this.children) {
200
173
  let str = ch.toString();
201
- if (str) {
202
- if (children)
203
- children += ",";
204
- children += str;
205
- }
174
+ str && (children && (children += ","), children += str);
206
175
  }
207
- return !this.type.name ? children : (/\W/.test(this.type.name) && !this.type.isError ? JSON.stringify(this.type.name) : this.type.name) + (children.length ? "(" + children + ")" : "");
176
+ return this.type.name ? (/\W/.test(this.type.name) && !this.type.isError ? JSON.stringify(this.type.name) : this.type.name) + (children.length ? "(" + children + ")" : "") : children;
208
177
  }
209
178
  /**
210
179
  Get a [tree cursor](#common.TreeCursor) positioned at the top of
@@ -220,11 +189,8 @@ var Tree = class _Tree {
220
189
  [`moveTo`](#common.TreeCursor.moveTo).
221
190
  */
222
191
  cursorAt(pos, side = 0, mode = 0) {
223
- let scope = CachedNode.get(this) || this.topNode;
224
- let cursor = new TreeCursor(scope);
225
- cursor.moveTo(pos, side);
226
- CachedNode.set(this, cursor._tree);
227
- return cursor;
192
+ let scope = CachedNode.get(this) || this.topNode, cursor = new TreeCursor(scope);
193
+ return cursor.moveTo(pos, side), CachedNode.set(this, cursor._tree), cursor;
228
194
  }
229
195
  /**
230
196
  Get a [syntax node](#common.SyntaxNode) object for the top of the
@@ -245,9 +211,8 @@ var Tree = class _Tree {
245
211
  [`resolveInner`](#common.Tree.resolveInner) instead.
246
212
  */
247
213
  resolve(pos, side = 0) {
248
- let node = resolveNode(CachedNode.get(this) || this.topNode, pos, side, false);
249
- CachedNode.set(this, node);
250
- return node;
214
+ let node = resolveNode(CachedNode.get(this) || this.topNode, pos, side, !1);
215
+ return CachedNode.set(this, node), node;
251
216
  }
252
217
  /**
253
218
  Like [`resolve`](#common.Tree.resolve), but will enter
@@ -257,9 +222,8 @@ var Tree = class _Tree {
257
222
  the host trees).
258
223
  */
259
224
  resolveInner(pos, side = 0) {
260
- let node = resolveNode(CachedInnerNode.get(this) || this.topNode, pos, side, true);
261
- CachedInnerNode.set(this, node);
262
- return node;
225
+ let node = resolveNode(CachedInnerNode.get(this) || this.topNode, pos, side, !0);
226
+ return CachedInnerNode.set(this, node), node;
263
227
  }
264
228
  /**
265
229
  In some situations, it can be useful to iterate through all
@@ -279,23 +243,18 @@ var Tree = class _Tree {
279
243
  not have its children iterated over (or `leave` called).
280
244
  */
281
245
  iterate(spec) {
282
- let { enter, leave, from = 0, to = this.length } = spec;
283
- let mode = spec.mode || 0, anon = (mode & IterMode.IncludeAnonymous) > 0;
246
+ let { enter, leave, from = 0, to = this.length } = spec, mode = spec.mode || 0, anon = (mode & IterMode.IncludeAnonymous) > 0;
284
247
  for (let c = this.cursor(mode | IterMode.IncludeAnonymous); ; ) {
285
- let entered = false;
286
- if (c.from <= to && c.to >= from && (!anon && c.type.isAnonymous || enter(c) !== false)) {
248
+ let entered = !1;
249
+ if (c.from <= to && c.to >= from && (!anon && c.type.isAnonymous || enter(c) !== !1)) {
287
250
  if (c.firstChild())
288
251
  continue;
289
- entered = true;
252
+ entered = !0;
290
253
  }
291
- for (; ; ) {
292
- if (entered && leave && (anon || !c.type.isAnonymous))
293
- leave(c);
294
- if (c.nextSibling())
295
- break;
254
+ for (; entered && leave && (anon || !c.type.isAnonymous) && leave(c), !c.nextSibling(); ) {
296
255
  if (!c.parent())
297
256
  return;
298
- entered = true;
257
+ entered = !0;
299
258
  }
300
259
  }
301
260
  }
@@ -304,7 +263,7 @@ var Tree = class _Tree {
304
263
  node. Works with both per-node and per-type props.
305
264
  */
306
265
  prop(prop) {
307
- return !prop.perNode ? this.type.prop(prop) : this.props ? this.props[prop.id] : void 0;
266
+ return prop.perNode ? this.props ? this.props[prop.id] : void 0 : this.type.prop(prop);
308
267
  }
309
268
  /**
310
269
  Returns the node's [per-node props](#common.NodeProp.perNode) in a
@@ -337,8 +296,7 @@ var Tree = class _Tree {
337
296
  Tree.empty = new Tree(NodeType.none, [], [], 0);
338
297
  var FlatBufferCursor = class _FlatBufferCursor {
339
298
  constructor(buffer, index) {
340
- this.buffer = buffer;
341
- this.index = index;
299
+ this.buffer = buffer, this.index = index;
342
300
  }
343
301
  get id() {
344
302
  return this.buffer[this.index - 4];
@@ -361,15 +319,12 @@ var FlatBufferCursor = class _FlatBufferCursor {
361
319
  fork() {
362
320
  return new _FlatBufferCursor(this.buffer, this.index);
363
321
  }
364
- };
365
- var TreeBuffer = class _TreeBuffer {
322
+ }, TreeBuffer = class _TreeBuffer {
366
323
  /**
367
324
  Create a tree buffer.
368
325
  */
369
326
  constructor(buffer, length, set) {
370
- this.buffer = buffer;
371
- this.length = length;
372
- this.set = set;
327
+ this.buffer = buffer, this.length = length, this.set = set;
373
328
  }
374
329
  /**
375
330
  @internal
@@ -382,28 +337,20 @@ var TreeBuffer = class _TreeBuffer {
382
337
  */
383
338
  toString() {
384
339
  let result = [];
385
- for (let index = 0; index < this.buffer.length; ) {
386
- result.push(this.childString(index));
387
- index = this.buffer[index + 3];
388
- }
340
+ for (let index = 0; index < this.buffer.length; )
341
+ result.push(this.childString(index)), index = this.buffer[index + 3];
389
342
  return result.join(",");
390
343
  }
391
344
  /**
392
345
  @internal
393
346
  */
394
347
  childString(index) {
395
- let id2 = this.buffer[index], endIndex = this.buffer[index + 3];
396
- let type = this.set.types[id2], result = type.name;
397
- if (/\W/.test(result) && !type.isError)
398
- result = JSON.stringify(result);
399
- index += 4;
400
- if (endIndex == index)
348
+ let id2 = this.buffer[index], endIndex = this.buffer[index + 3], type = this.set.types[id2], result = type.name;
349
+ if (/\W/.test(result) && !type.isError && (result = JSON.stringify(result)), index += 4, endIndex == index)
401
350
  return result;
402
351
  let children = [];
403
- while (index < endIndex) {
404
- children.push(this.childString(index));
405
- index = this.buffer[index + 3];
406
- }
352
+ for (; index < endIndex; )
353
+ children.push(this.childString(index)), index = this.buffer[index + 3];
407
354
  return result + "(" + children.join(",") + ")";
408
355
  }
409
356
  /**
@@ -411,27 +358,19 @@ var TreeBuffer = class _TreeBuffer {
411
358
  */
412
359
  findChild(startIndex, endIndex, dir, pos, side) {
413
360
  let { buffer } = this, pick = -1;
414
- for (let i = startIndex; i != endIndex; i = buffer[i + 3]) {
415
- if (checkSide(side, pos, buffer[i + 1], buffer[i + 2])) {
416
- pick = i;
417
- if (dir > 0)
418
- break;
419
- }
420
- }
361
+ for (let i = startIndex; i != endIndex && !(checkSide(side, pos, buffer[i + 1], buffer[i + 2]) && (pick = i, dir > 0)); i = buffer[i + 3])
362
+ ;
421
363
  return pick;
422
364
  }
423
365
  /**
424
366
  @internal
425
367
  */
426
368
  slice(startI, endI, from) {
427
- let b = this.buffer;
428
- let copy = new Uint16Array(endI - startI), len = 0;
369
+ let b = this.buffer, copy = new Uint16Array(endI - startI), len = 0;
429
370
  for (let i = startI, j = 0; i < endI; ) {
430
- copy[j++] = b[i++];
431
- copy[j++] = b[i++] - from;
371
+ copy[j++] = b[i++], copy[j++] = b[i++] - from;
432
372
  let to = copy[j++] = b[i++] - from;
433
- copy[j++] = b[i++] - startI;
434
- len = Math.max(len, to);
373
+ copy[j++] = b[i++] - startI, len = Math.max(len, to);
435
374
  }
436
375
  return new _TreeBuffer(copy, len, this.set);
437
376
  }
@@ -449,12 +388,11 @@ function checkSide(side, pos, from, to) {
449
388
  case 2:
450
389
  return to > pos;
451
390
  case 4:
452
- return true;
391
+ return !0;
453
392
  }
454
393
  }
455
394
  function resolveNode(node, pos, side, overlays) {
456
- var _a;
457
- while (node.from == node.to || (side < 1 ? node.from >= pos : node.from > pos) || (side > -1 ? node.to <= pos : node.to < pos)) {
395
+ for (var _a; node.from == node.to || (side < 1 ? node.from >= pos : node.from > pos) || (side > -1 ? node.to <= pos : node.to < pos); ) {
458
396
  let parent = !overlays && node instanceof TreeNode && node.index < 0 ? null : node.parent;
459
397
  if (!parent)
460
398
  return node;
@@ -462,10 +400,8 @@ function resolveNode(node, pos, side, overlays) {
462
400
  }
463
401
  let mode = overlays ? 0 : IterMode.IgnoreOverlays;
464
402
  if (overlays)
465
- for (let scan = node, parent = scan.parent; parent; scan = parent, parent = scan.parent) {
466
- if (scan instanceof TreeNode && scan.index < 0 && ((_a = parent.enter(pos, side, mode)) === null || _a === void 0 ? void 0 : _a.from) != scan.from)
467
- node = parent;
468
- }
403
+ for (let scan = node, parent = scan.parent; parent; scan = parent, parent = scan.parent)
404
+ scan instanceof TreeNode && scan.index < 0 && ((_a = parent.enter(pos, side, mode)) === null || _a === void 0 ? void 0 : _a.from) != scan.from && (node = parent);
469
405
  for (; ; ) {
470
406
  let inner = node.enter(pos, side, mode);
471
407
  if (!inner)
@@ -485,26 +421,21 @@ var BaseNode = class {
485
421
  return getChildren(this, type, before, after);
486
422
  }
487
423
  resolve(pos, side = 0) {
488
- return resolveNode(this, pos, side, false);
424
+ return resolveNode(this, pos, side, !1);
489
425
  }
490
426
  resolveInner(pos, side = 0) {
491
- return resolveNode(this, pos, side, true);
427
+ return resolveNode(this, pos, side, !0);
492
428
  }
493
429
  matchContext(context) {
494
430
  return matchNodeContext(this.parent, context);
495
431
  }
496
432
  enterUnfinishedNodesBefore(pos) {
497
433
  let scan = this.childBefore(pos), node = this;
498
- while (scan) {
434
+ for (; scan; ) {
499
435
  let last = scan.lastChild;
500
436
  if (!last || last.to != scan.to)
501
437
  break;
502
- if (last.type.isError && last.from == last.to) {
503
- node = scan;
504
- scan = last.prevSibling;
505
- } else {
506
- scan = last;
507
- }
438
+ last.type.isError && last.from == last.to ? (node = scan, scan = last.prevSibling) : scan = last;
508
439
  }
509
440
  return node;
510
441
  }
@@ -514,14 +445,9 @@ var BaseNode = class {
514
445
  get next() {
515
446
  return this.parent;
516
447
  }
517
- };
518
- var TreeNode = class _TreeNode extends BaseNode {
448
+ }, TreeNode = class _TreeNode extends BaseNode {
519
449
  constructor(_tree, from, index, _parent) {
520
- super();
521
- this._tree = _tree;
522
- this.from = from;
523
- this.index = index;
524
- this._parent = _parent;
450
+ super(), this._tree = _tree, this.from = from, this.index = index, this._parent = _parent;
525
451
  }
526
452
  get type() {
527
453
  return this._tree.type;
@@ -536,30 +462,23 @@ var TreeNode = class _TreeNode extends BaseNode {
536
462
  for (let parent = this; ; ) {
537
463
  for (let { children, positions } = parent._tree, e = dir > 0 ? children.length : -1; i != e; i += dir) {
538
464
  let next = children[i], start = positions[i] + parent.from;
539
- if (!checkSide(side, pos, start, start + next.length))
540
- continue;
541
- if (next instanceof TreeBuffer) {
542
- if (mode & IterMode.ExcludeBuffers)
543
- continue;
544
- let index = next.findChild(0, next.buffer.length, dir, pos - start, side);
545
- if (index > -1)
546
- return new BufferNode(new BufferContext(parent, next, i, start), null, index);
547
- } else if (mode & IterMode.IncludeAnonymous || (!next.type.isAnonymous || hasChild(next))) {
548
- let mounted;
549
- if (!(mode & IterMode.IgnoreMounts) && (mounted = MountedTree.get(next)) && !mounted.overlay)
550
- return new _TreeNode(mounted.tree, start, i, parent);
551
- let inner = new _TreeNode(next, start, i, parent);
552
- return mode & IterMode.IncludeAnonymous || !inner.type.isAnonymous ? inner : inner.nextChild(dir < 0 ? next.children.length - 1 : 0, dir, pos, side);
465
+ if (checkSide(side, pos, start, start + next.length)) {
466
+ if (next instanceof TreeBuffer) {
467
+ if (mode & IterMode.ExcludeBuffers)
468
+ continue;
469
+ let index = next.findChild(0, next.buffer.length, dir, pos - start, side);
470
+ if (index > -1)
471
+ return new BufferNode(new BufferContext(parent, next, i, start), null, index);
472
+ } else if (mode & IterMode.IncludeAnonymous || !next.type.isAnonymous || hasChild(next)) {
473
+ let mounted;
474
+ if (!(mode & IterMode.IgnoreMounts) && (mounted = MountedTree.get(next)) && !mounted.overlay)
475
+ return new _TreeNode(mounted.tree, start, i, parent);
476
+ let inner = new _TreeNode(next, start, i, parent);
477
+ return mode & IterMode.IncludeAnonymous || !inner.type.isAnonymous ? inner : inner.nextChild(dir < 0 ? next.children.length - 1 : 0, dir, pos, side);
478
+ }
553
479
  }
554
480
  }
555
- if (mode & IterMode.IncludeAnonymous || !parent.type.isAnonymous)
556
- return null;
557
- if (parent.index >= 0)
558
- i = parent.index + dir;
559
- else
560
- i = dir < 0 ? -1 : parent._parent._tree.children.length;
561
- parent = parent._parent;
562
- if (!parent)
481
+ if (mode & IterMode.IncludeAnonymous || !parent.type.isAnonymous || (parent.index >= 0 ? i = parent.index + dir : i = dir < 0 ? -1 : parent._parent._tree.children.length, parent = parent._parent, !parent))
563
482
  return null;
564
483
  }
565
484
  }
@@ -606,16 +525,15 @@ var TreeNode = class _TreeNode extends BaseNode {
606
525
  let mounted;
607
526
  if (!(mode & IterMode.IgnoreOverlays) && (mounted = MountedTree.get(this._tree)) && mounted.overlay) {
608
527
  let rPos = pos - this.from;
609
- for (let { from, to } of mounted.overlay) {
528
+ for (let { from, to } of mounted.overlay)
610
529
  if ((side > 0 ? from <= rPos : from < rPos) && (side < 0 ? to >= rPos : to > rPos))
611
530
  return new _TreeNode(mounted.tree, mounted.overlay[0].from + this.from, -1, this);
612
- }
613
531
  }
614
532
  return this.nextChild(0, 1, pos, side, mode);
615
533
  }
616
534
  nextSignificantParent() {
617
535
  let val = this;
618
- while (val.type.isAnonymous && val._parent)
536
+ for (; val.type.isAnonymous && val._parent; )
619
537
  val = val._parent;
620
538
  return val;
621
539
  }
@@ -657,42 +575,35 @@ function getChildren(node, type, before, after) {
657
575
  let cur = node.cursor(), result = [];
658
576
  if (!cur.firstChild())
659
577
  return result;
660
- if (before != null)
661
- for (let found = false; !found; ) {
662
- found = cur.type.is(before);
663
- if (!cur.nextSibling())
578
+ if (before != null) {
579
+ for (let found = !1; !found; )
580
+ if (found = cur.type.is(before), !cur.nextSibling())
664
581
  return result;
665
- }
582
+ }
666
583
  for (; ; ) {
667
584
  if (after != null && cur.type.is(after))
668
585
  return result;
669
- if (cur.type.is(type))
670
- result.push(cur.node);
671
- if (!cur.nextSibling())
586
+ if (cur.type.is(type) && result.push(cur.node), !cur.nextSibling())
672
587
  return after == null ? result : [];
673
588
  }
674
589
  }
675
590
  function matchNodeContext(node, context, i = context.length - 1) {
676
591
  for (let p = node; i >= 0; p = p.parent) {
677
592
  if (!p)
678
- return false;
593
+ return !1;
679
594
  if (!p.type.isAnonymous) {
680
595
  if (context[i] && context[i] != p.name)
681
- return false;
596
+ return !1;
682
597
  i--;
683
598
  }
684
599
  }
685
- return true;
600
+ return !0;
686
601
  }
687
602
  var BufferContext = class {
688
603
  constructor(parent, buffer, index, start) {
689
- this.parent = parent;
690
- this.buffer = buffer;
691
- this.index = index;
692
- this.start = start;
604
+ this.parent = parent, this.buffer = buffer, this.index = index, this.start = start;
693
605
  }
694
- };
695
- var BufferNode = class _BufferNode extends BaseNode {
606
+ }, BufferNode = class _BufferNode extends BaseNode {
696
607
  get name() {
697
608
  return this.type.name;
698
609
  }
@@ -703,15 +614,10 @@ var BufferNode = class _BufferNode extends BaseNode {
703
614
  return this.context.start + this.context.buffer.buffer[this.index + 2];
704
615
  }
705
616
  constructor(context, _parent, index) {
706
- super();
707
- this.context = context;
708
- this._parent = _parent;
709
- this.index = index;
710
- this.type = context.buffer.set.types[context.buffer.buffer[index]];
617
+ super(), this.context = context, this._parent = _parent, this.index = index, this.type = context.buffer.set.types[context.buffer.buffer[index]];
711
618
  }
712
619
  child(dir, pos, side) {
713
- let { buffer } = this.context;
714
- let index = buffer.findChild(this.index + 4, buffer.buffer[this.index + 3], dir, pos - this.context.start, side);
620
+ let { buffer } = this.context, index = buffer.findChild(this.index + 4, buffer.buffer[this.index + 3], dir, pos - this.context.start, side);
715
621
  return index < 0 ? null : new _BufferNode(this.context, this, index);
716
622
  }
717
623
  get firstChild() {
@@ -752,8 +658,7 @@ var BufferNode = class _BufferNode extends BaseNode {
752
658
  enter(pos, side, mode = 0) {
753
659
  if (mode & IterMode.ExcludeBuffers)
754
660
  return null;
755
- let { buffer } = this.context;
756
- let index = buffer.findChild(this.index + 4, buffer.buffer[this.index + 3], side > 0 ? 1 : -1, pos - this.context.start, side);
661
+ let { buffer } = this.context, index = buffer.findChild(this.index + 4, buffer.buffer[this.index + 3], side > 0 ? 1 : -1, pos - this.context.start, side);
757
662
  return index < 0 ? null : new _BufferNode(this.context, this, index);
758
663
  }
759
664
  get parent() {
@@ -769,18 +674,12 @@ var BufferNode = class _BufferNode extends BaseNode {
769
674
  );
770
675
  }
771
676
  get nextSibling() {
772
- let { buffer } = this.context;
773
- let after = buffer.buffer[this.index + 3];
774
- if (after < (this._parent ? buffer.buffer[this._parent.index + 3] : buffer.buffer.length))
775
- return new _BufferNode(this.context, this._parent, after);
776
- return this.externalSibling(1);
677
+ let { buffer } = this.context, after = buffer.buffer[this.index + 3];
678
+ return after < (this._parent ? buffer.buffer[this._parent.index + 3] : buffer.buffer.length) ? new _BufferNode(this.context, this._parent, after) : this.externalSibling(1);
777
679
  }
778
680
  get prevSibling() {
779
- let { buffer } = this.context;
780
- let parentStart = this._parent ? this._parent.index + 4 : 0;
781
- if (this.index == parentStart)
782
- return this.externalSibling(-1);
783
- return new _BufferNode(this.context, this._parent, buffer.findChild(
681
+ let { buffer } = this.context, parentStart = this._parent ? this._parent.index + 4 : 0;
682
+ return this.index == parentStart ? this.externalSibling(-1) : new _BufferNode(this.context, this._parent, buffer.findChild(
784
683
  parentStart,
785
684
  this.index,
786
685
  -1,
@@ -793,13 +692,10 @@ var BufferNode = class _BufferNode extends BaseNode {
793
692
  return null;
794
693
  }
795
694
  toTree() {
796
- let children = [], positions = [];
797
- let { buffer } = this.context;
798
- let startI = this.index + 4, endI = buffer.buffer[this.index + 3];
695
+ let children = [], positions = [], { buffer } = this.context, startI = this.index + 4, endI = buffer.buffer[this.index + 3];
799
696
  if (endI > startI) {
800
697
  let from = buffer.buffer[this.index + 1];
801
- children.push(buffer.slice(startI, endI, from));
802
- positions.push(0);
698
+ children.push(buffer.slice(startI, endI, from)), positions.push(0);
803
699
  }
804
700
  return new Tree(this.type, children, positions, this.to - this.from);
805
701
  }
@@ -816,23 +712,14 @@ function iterStack(heads) {
816
712
  let pick = 0, picked = heads[0];
817
713
  for (let i = 1; i < heads.length; i++) {
818
714
  let node = heads[i];
819
- if (node.from > picked.from || node.to < picked.to) {
820
- picked = node;
821
- pick = i;
822
- }
715
+ (node.from > picked.from || node.to < picked.to) && (picked = node, pick = i);
823
716
  }
824
- let next = picked instanceof TreeNode && picked.index < 0 ? null : picked.parent;
825
- let newHeads = heads.slice();
826
- if (next)
827
- newHeads[pick] = next;
828
- else
829
- newHeads.splice(pick, 1);
830
- return new StackIterator(newHeads, picked);
717
+ let next = picked instanceof TreeNode && picked.index < 0 ? null : picked.parent, newHeads = heads.slice();
718
+ return next ? newHeads[pick] = next : newHeads.splice(pick, 1), new StackIterator(newHeads, picked);
831
719
  }
832
720
  var StackIterator = class {
833
721
  constructor(heads, node) {
834
- this.heads = heads;
835
- this.node = node;
722
+ this.heads = heads, this.node = node;
836
723
  }
837
724
  get next() {
838
725
  return iterStack(this.heads);
@@ -840,19 +727,17 @@ var StackIterator = class {
840
727
  };
841
728
  function stackIterator(tree, pos, side) {
842
729
  let inner = tree.resolveInner(pos, side), layers = null;
843
- for (let scan = inner instanceof TreeNode ? inner : inner.context.parent; scan; scan = scan.parent) {
730
+ for (let scan = inner instanceof TreeNode ? inner : inner.context.parent; scan; scan = scan.parent)
844
731
  if (scan.index < 0) {
845
732
  let parent = scan.parent;
846
- (layers || (layers = [inner])).push(parent.resolve(pos, side));
847
- scan = parent;
733
+ (layers || (layers = [inner])).push(parent.resolve(pos, side)), scan = parent;
848
734
  } else {
849
735
  let mount = MountedTree.get(scan.tree);
850
736
  if (mount && mount.overlay && mount.overlay[0].from <= pos && mount.overlay[mount.overlay.length - 1].to >= pos) {
851
737
  let root = new TreeNode(mount.tree, mount.overlay[0].from + scan.from, -1, scan);
852
- (layers || (layers = [inner])).push(resolveNode(root, pos, side, false));
738
+ (layers || (layers = [inner])).push(resolveNode(root, pos, side, !1));
853
739
  }
854
740
  }
855
- }
856
741
  return layers ? iterStack(layers) : inner;
857
742
  }
858
743
  var TreeCursor = class {
@@ -866,51 +751,28 @@ var TreeCursor = class {
866
751
  @internal
867
752
  */
868
753
  constructor(node, mode = 0) {
869
- this.mode = mode;
870
- this.buffer = null;
871
- this.stack = [];
872
- this.index = 0;
873
- this.bufferNode = null;
874
- if (node instanceof TreeNode) {
754
+ if (this.mode = mode, this.buffer = null, this.stack = [], this.index = 0, this.bufferNode = null, node instanceof TreeNode)
875
755
  this.yieldNode(node);
876
- } else {
877
- this._tree = node.context.parent;
878
- this.buffer = node.context;
756
+ else {
757
+ this._tree = node.context.parent, this.buffer = node.context;
879
758
  for (let n = node._parent; n; n = n._parent)
880
759
  this.stack.unshift(n.index);
881
- this.bufferNode = node;
882
- this.yieldBuf(node.index);
760
+ this.bufferNode = node, this.yieldBuf(node.index);
883
761
  }
884
762
  }
885
763
  yieldNode(node) {
886
- if (!node)
887
- return false;
888
- this._tree = node;
889
- this.type = node.type;
890
- this.from = node.from;
891
- this.to = node.to;
892
- return true;
764
+ return node ? (this._tree = node, this.type = node.type, this.from = node.from, this.to = node.to, !0) : !1;
893
765
  }
894
766
  yieldBuf(index, type) {
895
767
  this.index = index;
896
768
  let { start, buffer } = this.buffer;
897
- this.type = type || buffer.set.types[buffer.buffer[index]];
898
- this.from = start + buffer.buffer[index + 1];
899
- this.to = start + buffer.buffer[index + 2];
900
- return true;
769
+ return this.type = type || buffer.set.types[buffer.buffer[index]], this.from = start + buffer.buffer[index + 1], this.to = start + buffer.buffer[index + 2], !0;
901
770
  }
902
771
  /**
903
772
  @internal
904
773
  */
905
774
  yield(node) {
906
- if (!node)
907
- return false;
908
- if (node instanceof TreeNode) {
909
- this.buffer = null;
910
- return this.yieldNode(node);
911
- }
912
- this.buffer = node.context;
913
- return this.yieldBuf(node.index, node.type);
775
+ return node ? node instanceof TreeNode ? (this.buffer = null, this.yieldNode(node)) : (this.buffer = node.context, this.yieldBuf(node.index, node.type)) : !1;
914
776
  }
915
777
  /**
916
778
  @internal
@@ -924,12 +786,8 @@ var TreeCursor = class {
924
786
  enterChild(dir, pos, side) {
925
787
  if (!this.buffer)
926
788
  return this.yield(this._tree.nextChild(dir < 0 ? this._tree._tree.children.length - 1 : 0, dir, pos, side, this.mode));
927
- let { buffer } = this.buffer;
928
- let index = buffer.findChild(this.index + 4, buffer.buffer[this.index + 3], dir, pos - this.buffer.start, side);
929
- if (index < 0)
930
- return false;
931
- this.stack.push(this.index);
932
- return this.yieldBuf(index);
789
+ let { buffer } = this.buffer, index = buffer.findChild(this.index + 4, buffer.buffer[this.index + 3], dir, pos - this.buffer.start, side);
790
+ return index < 0 ? !1 : (this.stack.push(this.index), this.yieldBuf(index));
933
791
  }
934
792
  /**
935
793
  Move the cursor to this node's first child. When this returns
@@ -984,9 +842,7 @@ var TreeCursor = class {
984
842
  set to false.
985
843
  */
986
844
  enter(pos, side, mode = this.mode) {
987
- if (!this.buffer)
988
- return this.yield(this._tree.enter(pos, side, mode));
989
- return mode & IterMode.ExcludeBuffers ? false : this.enterChild(1, pos, side);
845
+ return this.buffer ? mode & IterMode.ExcludeBuffers ? !1 : this.enterChild(1, pos, side) : this.yield(this._tree.enter(pos, side, mode));
990
846
  }
991
847
  /**
992
848
  Move to the node's parent node, if this isn't the top node.
@@ -997,15 +853,14 @@ var TreeCursor = class {
997
853
  if (this.stack.length)
998
854
  return this.yieldBuf(this.stack.pop());
999
855
  let parent = this.mode & IterMode.IncludeAnonymous ? this.buffer.parent : this.buffer.parent.nextSignificantParent();
1000
- this.buffer = null;
1001
- return this.yieldNode(parent);
856
+ return this.buffer = null, this.yieldNode(parent);
1002
857
  }
1003
858
  /**
1004
859
  @internal
1005
860
  */
1006
861
  sibling(dir) {
1007
862
  if (!this.buffer)
1008
- return !this._tree._parent ? false : this.yield(this._tree.index < 0 ? null : this._tree._parent.nextChild(this._tree.index + dir, dir, 0, 4, this.mode));
863
+ return this._tree._parent ? this.yield(this._tree.index < 0 ? null : this._tree._parent.nextChild(this._tree.index + dir, dir, 0, 4, this.mode)) : !1;
1009
864
  let { buffer } = this.buffer, d = this.stack.length - 1;
1010
865
  if (dir < 0) {
1011
866
  let parentStart = d < 0 ? 0 : this.stack[d] + 4;
@@ -1023,7 +878,7 @@ var TreeCursor = class {
1023
878
  if (after < (d < 0 ? buffer.buffer.length : buffer.buffer[this.stack[d] + 3]))
1024
879
  return this.yieldBuf(after);
1025
880
  }
1026
- return d < 0 ? this.yield(this.buffer.parent.nextChild(this.buffer.index + dir, dir, 0, 4, this.mode)) : false;
881
+ return d < 0 ? this.yield(this.buffer.parent.nextChild(this.buffer.index + dir, dir, 0, 4, this.mode)) : !1;
1027
882
  }
1028
883
  /**
1029
884
  Move to this node's next sibling, if any.
@@ -1042,25 +897,22 @@ var TreeCursor = class {
1042
897
  if (buffer) {
1043
898
  if (dir > 0) {
1044
899
  if (this.index < buffer.buffer.buffer.length)
1045
- return false;
1046
- } else {
900
+ return !1;
901
+ } else
1047
902
  for (let i = 0; i < this.index; i++)
1048
903
  if (buffer.buffer.buffer[i + 3] < this.index)
1049
- return false;
1050
- }
904
+ return !1;
1051
905
  ({ index, parent } = buffer);
1052
- } else {
906
+ } else
1053
907
  ({ index, _parent: parent } = this._tree);
1054
- }
1055
- for (; parent; { index, _parent: parent } = parent) {
908
+ for (; parent; { index, _parent: parent } = parent)
1056
909
  if (index > -1)
1057
910
  for (let i = index + dir, e = dir < 0 ? -1 : parent._tree.children.length; i != e; i += dir) {
1058
911
  let child = parent._tree.children[i];
1059
912
  if (this.mode & IterMode.IncludeAnonymous || child instanceof TreeBuffer || !child.type.isAnonymous || hasChild(child))
1060
- return false;
913
+ return !1;
1061
914
  }
1062
- }
1063
- return true;
915
+ return !0;
1064
916
  }
1065
917
  move(dir, enter) {
1066
918
  if (enter && this.enterChild(
@@ -1069,12 +921,12 @@ var TreeCursor = class {
1069
921
  4
1070
922
  /* Side.DontCare */
1071
923
  ))
1072
- return true;
924
+ return !0;
1073
925
  for (; ; ) {
1074
926
  if (this.sibling(dir))
1075
- return true;
927
+ return !0;
1076
928
  if (this.atLastNode(dir) || !this.parent())
1077
- return false;
929
+ return !1;
1078
930
  }
1079
931
  }
1080
932
  /**
@@ -1084,7 +936,7 @@ var TreeCursor = class {
1084
936
  current node is empty or `enter` is false, its next sibling or
1085
937
  the next sibling of the first parent node that has one.
1086
938
  */
1087
- next(enter = true) {
939
+ next(enter = !0) {
1088
940
  return this.move(1, enter);
1089
941
  }
1090
942
  /**
@@ -1093,7 +945,7 @@ var TreeCursor = class {
1093
945
  previous sibling or the previous sibling of the first parent
1094
946
  node that has one.
1095
947
  */
1096
- prev(enter = true) {
948
+ prev(enter = !0) {
1097
949
  return this.move(-1, enter);
1098
950
  }
1099
951
  /**
@@ -1102,11 +954,10 @@ var TreeCursor = class {
1102
954
  it will enter nodes that start at `pos`.
1103
955
  */
1104
956
  moveTo(pos, side = 0) {
1105
- while (this.from == this.to || (side < 1 ? this.from >= pos : this.from > pos) || (side > -1 ? this.to <= pos : this.to < pos))
1106
- if (!this.parent())
1107
- break;
1108
- while (this.enterChild(1, pos, side)) {
1109
- }
957
+ for (; (this.from == this.to || (side < 1 ? this.from >= pos : this.from > pos) || (side > -1 ? this.to <= pos : this.to < pos)) && this.parent(); )
958
+ ;
959
+ for (; this.enterChild(1, pos, side); )
960
+ ;
1110
961
  return this;
1111
962
  }
1112
963
  /**
@@ -1117,19 +968,17 @@ var TreeCursor = class {
1117
968
  if (!this.buffer)
1118
969
  return this._tree;
1119
970
  let cache = this.bufferNode, result = null, depth = 0;
1120
- if (cache && cache.context == this.buffer) {
971
+ if (cache && cache.context == this.buffer)
1121
972
  scan: for (let index = this.index, d = this.stack.length; d >= 0; ) {
1122
973
  for (let c = cache; c; c = c._parent)
1123
974
  if (c.index == index) {
1124
975
  if (index == this.index)
1125
976
  return c;
1126
- result = c;
1127
- depth = d + 1;
977
+ result = c, depth = d + 1;
1128
978
  break scan;
1129
979
  }
1130
980
  index = this.stack[--d];
1131
981
  }
1132
- }
1133
982
  for (let i = depth; i < this.stack.length; i++)
1134
983
  result = new BufferNode(this.buffer, result, this.stack[i]);
1135
984
  return this.bufferNode = new BufferNode(this.buffer, result, this.index);
@@ -1150,26 +999,20 @@ var TreeCursor = class {
1150
999
  */
1151
1000
  iterate(enter, leave) {
1152
1001
  for (let depth = 0; ; ) {
1153
- let mustLeave = false;
1154
- if (this.type.isAnonymous || enter(this) !== false) {
1002
+ let mustLeave = !1;
1003
+ if (this.type.isAnonymous || enter(this) !== !1) {
1155
1004
  if (this.firstChild()) {
1156
1005
  depth++;
1157
1006
  continue;
1158
1007
  }
1159
- if (!this.type.isAnonymous)
1160
- mustLeave = true;
1008
+ this.type.isAnonymous || (mustLeave = !0);
1161
1009
  }
1162
1010
  for (; ; ) {
1163
- if (mustLeave && leave)
1164
- leave(this);
1165
- mustLeave = this.type.isAnonymous;
1166
- if (!depth)
1011
+ if (mustLeave && leave && leave(this), mustLeave = this.type.isAnonymous, !depth)
1167
1012
  return;
1168
1013
  if (this.nextSibling())
1169
1014
  break;
1170
- this.parent();
1171
- depth--;
1172
- mustLeave = true;
1015
+ this.parent(), depth--, mustLeave = !0;
1173
1016
  }
1174
1017
  }
1175
1018
  }
@@ -1188,11 +1031,11 @@ var TreeCursor = class {
1188
1031
  let type = types[buffer.buffer[this.stack[d]]];
1189
1032
  if (!type.isAnonymous) {
1190
1033
  if (context[i] && context[i] != type.name)
1191
- return false;
1034
+ return !1;
1192
1035
  i--;
1193
1036
  }
1194
1037
  }
1195
- return true;
1038
+ return !0;
1196
1039
  }
1197
1040
  };
1198
1041
  function hasChild(tree) {
@@ -1200,19 +1043,13 @@ function hasChild(tree) {
1200
1043
  }
1201
1044
  function buildTree(data) {
1202
1045
  var _a;
1203
- let { buffer, nodeSet, maxBufferLength = DefaultBufferLength, reused = [], minRepeatType = nodeSet.types.length } = data;
1204
- let cursor = Array.isArray(buffer) ? new FlatBufferCursor(buffer, buffer.length) : buffer;
1205
- let types = nodeSet.types;
1206
- let contextHash = 0, lookAhead = 0;
1046
+ let { buffer, nodeSet, maxBufferLength = 1024, reused = [], minRepeatType = nodeSet.types.length } = data, cursor = Array.isArray(buffer) ? new FlatBufferCursor(buffer, buffer.length) : buffer, types = nodeSet.types, contextHash = 0, lookAhead = 0;
1207
1047
  function takeNode(parentStart, minPos, children2, positions2, inRepeat, depth) {
1208
- let { id: id2, start, end, size } = cursor;
1209
- let lookAheadAtStart = lookAhead, contextAtStart = contextHash;
1210
- if (size < 0) {
1211
- cursor.next();
1212
- if (size == -1) {
1048
+ let { id: id2, start, end, size } = cursor, lookAheadAtStart = lookAhead, contextAtStart = contextHash;
1049
+ if (size < 0)
1050
+ if (cursor.next(), size == -1) {
1213
1051
  let node2 = reused[id2];
1214
- children2.push(node2);
1215
- positions2.push(start - parentStart);
1052
+ children2.push(node2), positions2.push(start - parentStart);
1216
1053
  return;
1217
1054
  } else if (size == -3) {
1218
1055
  contextHash = id2;
@@ -1220,81 +1057,45 @@ function buildTree(data) {
1220
1057
  } else if (size == -4) {
1221
1058
  lookAhead = id2;
1222
1059
  return;
1223
- } else {
1060
+ } else
1224
1061
  throw new RangeError(`Unrecognized record size: ${size}`);
1225
- }
1226
- }
1227
- let type = types[id2], node, buffer2;
1228
- let startPos = start - parentStart;
1062
+ let type = types[id2], node, buffer2, startPos = start - parentStart;
1229
1063
  if (end - start <= maxBufferLength && (buffer2 = findBufferSize(cursor.pos - minPos, inRepeat))) {
1230
- let data2 = new Uint16Array(buffer2.size - buffer2.skip);
1231
- let endPos = cursor.pos - buffer2.size, index = data2.length;
1232
- while (cursor.pos > endPos)
1064
+ let data2 = new Uint16Array(buffer2.size - buffer2.skip), endPos = cursor.pos - buffer2.size, index = data2.length;
1065
+ for (; cursor.pos > endPos; )
1233
1066
  index = copyToBuffer(buffer2.start, data2, index);
1234
- node = new TreeBuffer(data2, end - buffer2.start, nodeSet);
1235
- startPos = buffer2.start - parentStart;
1067
+ node = new TreeBuffer(data2, end - buffer2.start, nodeSet), startPos = buffer2.start - parentStart;
1236
1068
  } else {
1237
1069
  let endPos = cursor.pos - size;
1238
1070
  cursor.next();
1239
- let localChildren = [], localPositions = [];
1240
- let localInRepeat = id2 >= minRepeatType ? id2 : -1;
1241
- let lastGroup = 0, lastEnd = end;
1242
- while (cursor.pos > endPos) {
1243
- if (localInRepeat >= 0 && cursor.id == localInRepeat && cursor.size >= 0) {
1244
- if (cursor.end <= lastEnd - maxBufferLength) {
1245
- makeRepeatLeaf(localChildren, localPositions, start, lastGroup, cursor.end, lastEnd, localInRepeat, lookAheadAtStart, contextAtStart);
1246
- lastGroup = localChildren.length;
1247
- lastEnd = cursor.end;
1248
- }
1249
- cursor.next();
1250
- } else if (depth > 2500) {
1251
- takeFlatNode(start, endPos, localChildren, localPositions);
1252
- } else {
1253
- takeNode(start, endPos, localChildren, localPositions, localInRepeat, depth + 1);
1254
- }
1255
- }
1256
- if (localInRepeat >= 0 && lastGroup > 0 && lastGroup < localChildren.length)
1257
- makeRepeatLeaf(localChildren, localPositions, start, lastGroup, start, lastEnd, localInRepeat, lookAheadAtStart, contextAtStart);
1258
- localChildren.reverse();
1259
- localPositions.reverse();
1260
- if (localInRepeat > -1 && lastGroup > 0) {
1071
+ let localChildren = [], localPositions = [], localInRepeat = id2 >= minRepeatType ? id2 : -1, lastGroup = 0, lastEnd = end;
1072
+ for (; cursor.pos > endPos; )
1073
+ localInRepeat >= 0 && cursor.id == localInRepeat && cursor.size >= 0 ? (cursor.end <= lastEnd - maxBufferLength && (makeRepeatLeaf(localChildren, localPositions, start, lastGroup, cursor.end, lastEnd, localInRepeat, lookAheadAtStart, contextAtStart), lastGroup = localChildren.length, lastEnd = cursor.end), cursor.next()) : depth > 2500 ? takeFlatNode(start, endPos, localChildren, localPositions) : takeNode(start, endPos, localChildren, localPositions, localInRepeat, depth + 1);
1074
+ if (localInRepeat >= 0 && lastGroup > 0 && lastGroup < localChildren.length && makeRepeatLeaf(localChildren, localPositions, start, lastGroup, start, lastEnd, localInRepeat, lookAheadAtStart, contextAtStart), localChildren.reverse(), localPositions.reverse(), localInRepeat > -1 && lastGroup > 0) {
1261
1075
  let make = makeBalanced(type, contextAtStart);
1262
1076
  node = balanceRange(type, localChildren, localPositions, 0, localChildren.length, 0, end - start, make, make);
1263
- } else {
1077
+ } else
1264
1078
  node = makeTree(type, localChildren, localPositions, end - start, lookAheadAtStart - end, contextAtStart);
1265
- }
1266
1079
  }
1267
- children2.push(node);
1268
- positions2.push(startPos);
1080
+ children2.push(node), positions2.push(startPos);
1269
1081
  }
1270
1082
  function takeFlatNode(parentStart, minPos, children2, positions2) {
1271
- let nodes = [];
1272
- let nodeCount = 0, stopAt = -1;
1273
- while (cursor.pos > minPos) {
1083
+ let nodes = [], nodeCount = 0, stopAt = -1;
1084
+ for (; cursor.pos > minPos; ) {
1274
1085
  let { id: id2, start, end, size } = cursor;
1275
- if (size > 4) {
1276
- cursor.next();
1277
- } else if (stopAt > -1 && start < stopAt) {
1278
- break;
1279
- } else {
1280
- if (stopAt < 0)
1281
- stopAt = end - maxBufferLength;
1282
- nodes.push(id2, start, end);
1283
- nodeCount++;
1086
+ if (size > 4)
1284
1087
  cursor.next();
1088
+ else {
1089
+ if (stopAt > -1 && start < stopAt)
1090
+ break;
1091
+ stopAt < 0 && (stopAt = end - maxBufferLength), nodes.push(id2, start, end), nodeCount++, cursor.next();
1285
1092
  }
1286
1093
  }
1287
1094
  if (nodeCount) {
1288
- let buffer2 = new Uint16Array(nodeCount * 4);
1289
- let start = nodes[nodes.length - 2];
1290
- for (let i = nodes.length - 3, j = 0; i >= 0; i -= 3) {
1291
- buffer2[j++] = nodes[i];
1292
- buffer2[j++] = nodes[i + 1] - start;
1293
- buffer2[j++] = nodes[i + 2] - start;
1294
- buffer2[j++] = j;
1295
- }
1296
- children2.push(new TreeBuffer(buffer2, nodes[2] - start, nodeSet));
1297
- positions2.push(start - parentStart);
1095
+ let buffer2 = new Uint16Array(nodeCount * 4), start = nodes[nodes.length - 2];
1096
+ for (let i = nodes.length - 3, j = 0; i >= 0; i -= 3)
1097
+ buffer2[j++] = nodes[i], buffer2[j++] = nodes[i + 1] - start, buffer2[j++] = nodes[i + 2] - start, buffer2[j++] = j;
1098
+ children2.push(new TreeBuffer(buffer2, nodes[2] - start, nodeSet)), positions2.push(start - parentStart);
1298
1099
  }
1299
1100
  }
1300
1101
  function makeBalanced(type, contextHash2) {
@@ -1303,20 +1104,16 @@ function buildTree(data) {
1303
1104
  if (lastI >= 0 && (last = children2[lastI]) instanceof Tree) {
1304
1105
  if (!lastI && last.type == type && last.length == length2)
1305
1106
  return last;
1306
- if (lookAheadProp = last.prop(NodeProp.lookAhead))
1307
- lookAhead2 = positions2[lastI] + last.length + lookAheadProp;
1107
+ (lookAheadProp = last.prop(NodeProp.lookAhead)) && (lookAhead2 = positions2[lastI] + last.length + lookAheadProp);
1308
1108
  }
1309
1109
  return makeTree(type, children2, positions2, length2, lookAhead2, contextHash2);
1310
1110
  };
1311
1111
  }
1312
1112
  function makeRepeatLeaf(children2, positions2, base, i, from, to, type, lookAhead2, contextHash2) {
1313
1113
  let localChildren = [], localPositions = [];
1314
- while (children2.length > i) {
1315
- localChildren.push(children2.pop());
1316
- localPositions.push(positions2.pop() + base - from);
1317
- }
1318
- children2.push(makeTree(nodeSet.types[type], localChildren, localPositions, to - from, lookAhead2 - to, contextHash2));
1319
- positions2.push(from - base);
1114
+ for (; children2.length > i; )
1115
+ localChildren.push(children2.pop()), localPositions.push(positions2.pop() + base - from);
1116
+ children2.push(makeTree(nodeSet.types[type], localChildren, localPositions, to - from, lookAhead2 - to, contextHash2)), positions2.push(from - base);
1320
1117
  }
1321
1118
  function makeTree(type, children2, positions2, length2, lookAhead2, contextHash2, props) {
1322
1119
  if (contextHash2) {
@@ -1330,71 +1127,45 @@ function buildTree(data) {
1330
1127
  return new Tree(type, children2, positions2, length2, props);
1331
1128
  }
1332
1129
  function findBufferSize(maxSize, inRepeat) {
1333
- let fork = cursor.fork();
1334
- let size = 0, start = 0, skip = 0, minStart = fork.end - maxBufferLength;
1335
- let result = { size: 0, start: 0, skip: 0 };
1130
+ let fork = cursor.fork(), size = 0, start = 0, skip = 0, minStart = fork.end - maxBufferLength, result = { size: 0, start: 0, skip: 0 };
1336
1131
  scan: for (let minPos = fork.pos - maxSize; fork.pos > minPos; ) {
1337
1132
  let nodeSize2 = fork.size;
1338
1133
  if (fork.id == inRepeat && nodeSize2 >= 0) {
1339
- result.size = size;
1340
- result.start = start;
1341
- result.skip = skip;
1342
- skip += 4;
1343
- size += 4;
1344
- fork.next();
1134
+ result.size = size, result.start = start, result.skip = skip, skip += 4, size += 4, fork.next();
1345
1135
  continue;
1346
1136
  }
1347
1137
  let startPos = fork.pos - nodeSize2;
1348
1138
  if (nodeSize2 < 0 || startPos < minPos || fork.start < minStart)
1349
1139
  break;
1350
- let localSkipped = fork.id >= minRepeatType ? 4 : 0;
1351
- let nodeStart = fork.start;
1352
- fork.next();
1353
- while (fork.pos > startPos) {
1354
- if (fork.size < 0) {
1140
+ let localSkipped = fork.id >= minRepeatType ? 4 : 0, nodeStart = fork.start;
1141
+ for (fork.next(); fork.pos > startPos; ) {
1142
+ if (fork.size < 0)
1355
1143
  if (fork.size == -3 || fork.size == -4)
1356
1144
  localSkipped += 4;
1357
1145
  else
1358
1146
  break scan;
1359
- } else if (fork.id >= minRepeatType) {
1360
- localSkipped += 4;
1361
- }
1147
+ else fork.id >= minRepeatType && (localSkipped += 4);
1362
1148
  fork.next();
1363
1149
  }
1364
- start = nodeStart;
1365
- size += nodeSize2;
1366
- skip += localSkipped;
1150
+ start = nodeStart, size += nodeSize2, skip += localSkipped;
1367
1151
  }
1368
- if (inRepeat < 0 || size == maxSize) {
1369
- result.size = size;
1370
- result.start = start;
1371
- result.skip = skip;
1372
- }
1373
- return result.size > 4 ? result : void 0;
1152
+ return (inRepeat < 0 || size == maxSize) && (result.size = size, result.start = start, result.skip = skip), result.size > 4 ? result : void 0;
1374
1153
  }
1375
1154
  function copyToBuffer(bufferStart, buffer2, index) {
1376
1155
  let { id: id2, start, end, size } = cursor;
1377
- cursor.next();
1378
- if (size >= 0 && id2 < minRepeatType) {
1156
+ if (cursor.next(), size >= 0 && id2 < minRepeatType) {
1379
1157
  let startIndex = index;
1380
1158
  if (size > 4) {
1381
1159
  let endPos = cursor.pos - (size - 4);
1382
- while (cursor.pos > endPos)
1160
+ for (; cursor.pos > endPos; )
1383
1161
  index = copyToBuffer(bufferStart, buffer2, index);
1384
1162
  }
1385
- buffer2[--index] = startIndex;
1386
- buffer2[--index] = end - bufferStart;
1387
- buffer2[--index] = start - bufferStart;
1388
- buffer2[--index] = id2;
1389
- } else if (size == -3) {
1390
- contextHash = id2;
1391
- } else if (size == -4) {
1392
- lookAhead = id2;
1393
- }
1163
+ buffer2[--index] = startIndex, buffer2[--index] = end - bufferStart, buffer2[--index] = start - bufferStart, buffer2[--index] = id2;
1164
+ } else size == -3 ? contextHash = id2 : size == -4 && (lookAhead = id2);
1394
1165
  return index;
1395
1166
  }
1396
1167
  let children = [], positions = [];
1397
- while (cursor.pos > 0)
1168
+ for (; cursor.pos > 0; )
1398
1169
  takeNode(data.start || 0, data.bufferStart || 0, children, positions, -1, 0);
1399
1170
  let length = (_a = data.length) !== null && _a !== void 0 ? _a : children.length ? positions[0] + children[0].length : 0;
1400
1171
  return new Tree(types[data.topID], children.reverse(), positions.reverse(), length);
@@ -1424,13 +1195,11 @@ function balanceRange(balanceType, children, positions, from, to, start, length,
1424
1195
  let maxChild = Math.ceil(
1425
1196
  total * 1.5 / 8
1426
1197
  /* Balance.BranchFactor */
1427
- );
1428
- let localChildren = [], localPositions = [];
1198
+ ), localChildren = [], localPositions = [];
1429
1199
  function divide(children2, positions2, from2, to2, offset) {
1430
1200
  for (let i = from2; i < to2; ) {
1431
1201
  let groupFrom = i, groupStart = positions2[i], groupSize = nodeSize(balanceType, children2[i]);
1432
- i++;
1433
- for (; i < to2; i++) {
1202
+ for (i++; i < to2; i++) {
1434
1203
  let nextSize = nodeSize(balanceType, children2[i]);
1435
1204
  if (groupSize + nextSize >= maxChild)
1436
1205
  break;
@@ -1450,10 +1219,9 @@ function balanceRange(balanceType, children, positions, from, to, start, length,
1450
1219
  localPositions.push(groupStart + offset - start);
1451
1220
  }
1452
1221
  }
1453
- divide(children, positions, from, to, 0);
1454
- return (mkTop || mkTree)(localChildren, localPositions, length);
1222
+ return divide(children, positions, from, to, 0), (mkTop || mkTree)(localChildren, localPositions, length);
1455
1223
  }
1456
- var stoppedInner = new NodeProp({ perNode: true });
1224
+ var stoppedInner = new NodeProp({ perNode: !0 });
1457
1225
 
1458
1226
  // ../../node_modules/@lezer/lr/dist/index.js
1459
1227
  function decodeArray(input, Type = Uint16Array) {
@@ -1463,88 +1231,59 @@ function decodeArray(input, Type = Uint16Array) {
1463
1231
  for (let pos = 0, out = 0; pos < input.length; ) {
1464
1232
  let value = 0;
1465
1233
  for (; ; ) {
1466
- let next = input.charCodeAt(pos++), stop = false;
1234
+ let next = input.charCodeAt(pos++), stop = !1;
1467
1235
  if (next == 126) {
1468
1236
  value = 65535;
1469
1237
  break;
1470
1238
  }
1471
- if (next >= 92)
1472
- next--;
1473
- if (next >= 34)
1474
- next--;
1239
+ next >= 92 && next--, next >= 34 && next--;
1475
1240
  let digit = next - 32;
1476
- if (digit >= 46) {
1477
- digit -= 46;
1478
- stop = true;
1479
- }
1480
- value += digit;
1481
- if (stop)
1241
+ if (digit >= 46 && (digit -= 46, stop = !0), value += digit, stop)
1482
1242
  break;
1483
1243
  value *= 46;
1484
1244
  }
1485
- if (array)
1486
- array[out++] = value;
1487
- else
1488
- array = new Type(value);
1245
+ array ? array[out++] = value : array = new Type(value);
1489
1246
  }
1490
1247
  return array;
1491
1248
  }
1492
1249
  var CachedToken = class {
1493
1250
  constructor() {
1494
- this.start = -1;
1495
- this.value = -1;
1496
- this.end = -1;
1497
- this.extended = -1;
1498
- this.lookAhead = 0;
1499
- this.mask = 0;
1500
- this.context = 0;
1251
+ this.start = -1, this.value = -1, this.end = -1, this.extended = -1, this.lookAhead = 0, this.mask = 0, this.context = 0;
1501
1252
  }
1502
- };
1503
- var nullToken = new CachedToken();
1253
+ }, nullToken = new CachedToken();
1504
1254
  var TokenGroup = class {
1505
1255
  constructor(data, id2) {
1506
- this.data = data;
1507
- this.id = id2;
1256
+ this.data = data, this.id = id2;
1508
1257
  }
1509
1258
  token(input, stack) {
1510
1259
  let { parser } = stack.p;
1511
1260
  readToken(this.data, input, stack, this.id, parser.data, parser.tokenPrecTable);
1512
1261
  }
1513
1262
  };
1514
- TokenGroup.prototype.contextual = TokenGroup.prototype.fallback = TokenGroup.prototype.extend = false;
1263
+ TokenGroup.prototype.contextual = TokenGroup.prototype.fallback = TokenGroup.prototype.extend = !1;
1515
1264
  var LocalTokenGroup = class {
1516
1265
  constructor(data, precTable, elseToken) {
1517
- this.precTable = precTable;
1518
- this.elseToken = elseToken;
1519
- this.data = typeof data == "string" ? decodeArray(data) : data;
1266
+ this.precTable = precTable, this.elseToken = elseToken, this.data = typeof data == "string" ? decodeArray(data) : data;
1520
1267
  }
1521
1268
  token(input, stack) {
1522
1269
  let start = input.pos, skipped = 0;
1523
1270
  for (; ; ) {
1524
1271
  let atEof = input.next < 0, nextPos = input.resolveOffset(1, 1);
1525
- readToken(this.data, input, stack, 0, this.data, this.precTable);
1526
- if (input.token.value > -1)
1272
+ if (readToken(this.data, input, stack, 0, this.data, this.precTable), input.token.value > -1)
1527
1273
  break;
1528
1274
  if (this.elseToken == null)
1529
1275
  return;
1530
- if (!atEof)
1531
- skipped++;
1532
- if (nextPos == null)
1276
+ if (atEof || skipped++, nextPos == null)
1533
1277
  break;
1534
1278
  input.reset(nextPos, input.token);
1535
1279
  }
1536
- if (skipped) {
1537
- input.reset(start, input.token);
1538
- input.acceptToken(this.elseToken, skipped);
1539
- }
1280
+ skipped && (input.reset(start, input.token), input.acceptToken(this.elseToken, skipped));
1540
1281
  }
1541
1282
  };
1542
- LocalTokenGroup.prototype.contextual = TokenGroup.prototype.fallback = TokenGroup.prototype.extend = false;
1283
+ LocalTokenGroup.prototype.contextual = TokenGroup.prototype.fallback = TokenGroup.prototype.extend = !1;
1543
1284
  function readToken(data, input, stack, group, precTable, precOffset) {
1544
1285
  let state = 0, groupMask = 1 << group, { dialect } = stack.p.parser;
1545
- scan: for (; ; ) {
1546
- if ((groupMask & data[state]) == 0)
1547
- break;
1286
+ scan: for (; (groupMask & data[state]) != 0; ) {
1548
1287
  let accEnd = data[state + 1];
1549
1288
  for (let i = state + 3; i < accEnd; i += 2)
1550
1289
  if ((data[i + 1] & groupMask) > 0) {
@@ -1560,16 +1299,13 @@ function readToken(data, input, stack, group, precTable, precOffset) {
1560
1299
  continue scan;
1561
1300
  }
1562
1301
  for (; low < high; ) {
1563
- let mid = low + high >> 1;
1564
- let index = accEnd + mid + (mid << 1);
1565
- let from = data[index], to = data[index + 1] || 65536;
1302
+ let mid = low + high >> 1, index = accEnd + mid + (mid << 1), from = data[index], to = data[index + 1] || 65536;
1566
1303
  if (next < from)
1567
1304
  high = mid;
1568
1305
  else if (next >= to)
1569
1306
  low = mid + 1;
1570
1307
  else {
1571
- state = data[index + 2];
1572
- input.advance();
1308
+ state = data[index + 2], input.advance();
1573
1309
  continue scan;
1574
1310
  }
1575
1311
  }
@@ -1586,19 +1322,13 @@ function overrides(token, prev, tableData, tableOffset) {
1586
1322
  let iPrev = findOffset(tableData, tableOffset, prev);
1587
1323
  return iPrev < 0 || findOffset(tableData, tableOffset, token) < iPrev;
1588
1324
  }
1589
- var verbose = typeof process != "undefined" && process.env && /\bparse\b/.test(process.env.LOG);
1590
- var id = (x) => x;
1591
- var ContextTracker = class {
1325
+ var verbose = typeof process < "u" && process.env && /\bparse\b/.test(process.env.LOG);
1326
+ var id = (x) => x, ContextTracker = class {
1592
1327
  /**
1593
1328
  Define a context tracker.
1594
1329
  */
1595
1330
  constructor(spec) {
1596
- this.start = spec.start;
1597
- this.shift = spec.shift || id;
1598
- this.reduce = spec.reduce || id;
1599
- this.reuse = spec.reuse || id;
1600
- this.hash = spec.hash || (() => 0);
1601
- this.strict = spec.strict !== false;
1331
+ this.start = spec.start, this.shift = spec.shift || id, this.reduce = spec.reduce || id, this.reuse = spec.reuse || id, this.hash = spec.hash || (() => 0), this.strict = spec.strict !== !1;
1602
1332
  }
1603
1333
  };
1604
1334
 
@@ -1616,74 +1346,68 @@ var MATH_TOKENS = {
1616
1346
  CLOSE_PAREN: 10,
1617
1347
  BACKSLASH: 11,
1618
1348
  NEWLINE: 12
1619
- };
1620
- var mathContextTracker = new ContextTracker({
1349
+ }, mathContextTracker = new ContextTracker({
1621
1350
  start: {
1622
- inMath: false,
1351
+ inMath: !1,
1623
1352
  mathType: null,
1624
1353
  depth: 0,
1625
1354
  startPos: -1,
1626
- isComplete: false,
1627
- hasError: false
1355
+ isComplete: !1,
1356
+ hasError: !1
1628
1357
  },
1629
1358
  shift(context, term, stack) {
1630
- const pos = stack.pos;
1359
+ let pos = stack.pos;
1631
1360
  switch (term) {
1632
1361
  case MATH_TOKENS.INLINE_MATH:
1633
- if (!context.inMath) {
1362
+ if (!context.inMath)
1634
1363
  return {
1635
1364
  ...context,
1636
- inMath: true,
1365
+ inMath: !0,
1637
1366
  mathType: "inline",
1638
1367
  startPos: pos,
1639
- isComplete: false,
1640
- hasError: false
1368
+ isComplete: !1,
1369
+ hasError: !1
1641
1370
  };
1642
- }
1643
- if (context.mathType === "inline") {
1371
+ if (context.mathType === "inline")
1644
1372
  return {
1645
1373
  ...context,
1646
- inMath: false,
1374
+ inMath: !1,
1647
1375
  mathType: null,
1648
- isComplete: true
1376
+ isComplete: !0
1649
1377
  };
1650
- }
1651
1378
  break;
1652
1379
  case MATH_TOKENS.DISPLAY_MATH:
1653
- if (!context.inMath) {
1380
+ if (!context.inMath)
1654
1381
  return {
1655
1382
  ...context,
1656
- inMath: true,
1383
+ inMath: !0,
1657
1384
  mathType: "display",
1658
1385
  startPos: pos,
1659
- isComplete: false,
1660
- hasError: false
1386
+ isComplete: !1,
1387
+ hasError: !1
1661
1388
  };
1662
- }
1663
- if (context.mathType === "display") {
1389
+ if (context.mathType === "display")
1664
1390
  return {
1665
1391
  ...context,
1666
- inMath: false,
1392
+ inMath: !1,
1667
1393
  mathType: null,
1668
- isComplete: true
1394
+ isComplete: !0
1669
1395
  };
1670
- }
1671
1396
  break;
1672
1397
  case MATH_TOKENS.OPEN_BRACE:
1673
1398
  case MATH_TOKENS.OPEN_BRACKET:
1674
1399
  case MATH_TOKENS.OPEN_PAREN:
1675
- if (context.inMath) {
1400
+ if (context.inMath)
1676
1401
  return {
1677
1402
  ...context,
1678
1403
  depth: context.depth + 1
1679
1404
  };
1680
- }
1681
1405
  break;
1682
1406
  case MATH_TOKENS.CLOSE_BRACE:
1683
1407
  case MATH_TOKENS.CLOSE_BRACKET:
1684
1408
  case MATH_TOKENS.CLOSE_PAREN:
1685
1409
  if (context.inMath) {
1686
- const newDepth = Math.max(0, context.depth - 1);
1410
+ let newDepth = Math.max(0, context.depth - 1);
1687
1411
  return {
1688
1412
  ...context,
1689
1413
  depth: newDepth,
@@ -1693,12 +1417,11 @@ var mathContextTracker = new ContextTracker({
1693
1417
  }
1694
1418
  break;
1695
1419
  case MATH_TOKENS.NEWLINE:
1696
- if (context.inMath && context.mathType === "inline") {
1420
+ if (context.inMath && context.mathType === "inline")
1697
1421
  return {
1698
1422
  ...context,
1699
- hasError: true
1423
+ hasError: !0
1700
1424
  };
1701
- }
1702
1425
  break;
1703
1426
  }
1704
1427
  return context;
@@ -1707,12 +1430,11 @@ var mathContextTracker = new ContextTracker({
1707
1430
  switch (term) {
1708
1431
  case MATH_TOKENS.INLINE_MATH:
1709
1432
  case MATH_TOKENS.DISPLAY_MATH:
1710
- if (context.inMath && context.depth > 0) {
1433
+ if (context.inMath && context.depth > 0)
1711
1434
  return {
1712
1435
  ...context,
1713
- hasError: true
1436
+ hasError: !0
1714
1437
  };
1715
- }
1716
1438
  break;
1717
1439
  }
1718
1440
  return context;
@@ -1756,7 +1478,7 @@ var MathContextUtils = {
1756
1478
  createErrorContext(baseContext) {
1757
1479
  return {
1758
1480
  ...baseContext,
1759
- hasError: true
1481
+ hasError: !0
1760
1482
  };
1761
1483
  },
1762
1484
  /**
@@ -1764,12 +1486,12 @@ var MathContextUtils = {
1764
1486
  */
1765
1487
  resetContext() {
1766
1488
  return {
1767
- inMath: false,
1489
+ inMath: !1,
1768
1490
  mathType: null,
1769
1491
  depth: 0,
1770
1492
  startPos: -1,
1771
- isComplete: false,
1772
- hasError: false
1493
+ isComplete: !1,
1494
+ hasError: !1
1773
1495
  };
1774
1496
  }
1775
1497
  };