@notmrabhi/flowforge 0.1.21 → 0.1.22

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 (53) hide show
  1. package/dist/GatewayBranchEdge-9YF32wwN.js +1 -0
  2. package/dist/GatewayBranchEdge-Dxoy5B1A.js +1264 -0
  3. package/dist/SchemaBuilderDrawer-157p-2Vj.js +1136 -0
  4. package/dist/SchemaBuilderDrawer-Wje7pVrn.js +1 -0
  5. package/dist/bpmn-CcuE2X_Q.js +2 -0
  6. package/dist/bpmn-CtfWDaOY.js +33 -0
  7. package/dist/canvas.cjs +1 -0
  8. package/dist/canvas.d.ts +809 -0
  9. package/dist/canvas.js +28 -0
  10. package/dist/canvasTokens-CAD6G24b.js +32 -0
  11. package/dist/canvasTokens-gKNYrPl4.js +1 -0
  12. package/dist/core.cjs +1 -0
  13. package/dist/core.d.ts +374 -0
  14. package/dist/core.js +24 -0
  15. package/dist/defaultUi.cjs +1 -0
  16. package/dist/defaultUi.d.ts +83 -0
  17. package/dist/defaultUi.js +18 -0
  18. package/dist/form.cjs +1 -0
  19. package/dist/form.d.ts +857 -0
  20. package/dist/form.js +44 -0
  21. package/dist/index-B31-Y5uO.js +11 -0
  22. package/dist/index-B3aHpb84.js +13 -0
  23. package/dist/index-BU09HbVh.js +10176 -0
  24. package/dist/index-BnzttJ4w.js +13758 -0
  25. package/dist/index-BysKSEtZ.js +1 -0
  26. package/dist/index-CQ0cVcHp.js +2 -0
  27. package/dist/index-CkjEllpd.js +1 -0
  28. package/dist/index-Codx5QwP.js +41 -0
  29. package/dist/index-Cw9DC-tf.js +76 -0
  30. package/dist/index-CzPi8KQC.js +1310 -0
  31. package/dist/index-D14V8rKX.js +1 -0
  32. package/dist/index-Da5NHCS2.js +8132 -0
  33. package/dist/index-a1IOaYsW.js +9 -0
  34. package/dist/index-a3QMaedZ.js +2553 -0
  35. package/dist/index-gtgq_241.js +3 -0
  36. package/dist/index-l6kvDx-m.js +1360 -0
  37. package/dist/index-lcviy90e.js +613 -0
  38. package/dist/index-wOnYb3DO.js +567 -0
  39. package/dist/index.cjs +1 -0
  40. package/dist/index.d.ts +1409 -0
  41. package/dist/index.js +107 -0
  42. package/dist/messages-CO299wPN.js +22 -0
  43. package/dist/messages-O9Tw_XXR.js +1 -0
  44. package/dist/nodeRegistry.cjs +1 -0
  45. package/dist/nodeRegistry.d.ts +334 -0
  46. package/dist/nodeRegistry.js +555 -0
  47. package/dist/style.css +6 -0
  48. package/dist/templateRegistry.cjs +1 -0
  49. package/dist/templateRegistry.d.ts +83 -0
  50. package/dist/templateRegistry.js +43 -0
  51. package/dist/templateSkeletons-D2ecxpVH.js +2954 -0
  52. package/dist/templateSkeletons-D5dYuslG.js +1 -0
  53. package/package.json +1 -1
@@ -0,0 +1,1310 @@
1
+ import { o as M, N as L, p as $, q as E, r as y, t as S, I as j } from "./index-BnzttJ4w.js";
2
+ class v {
3
+ /**
4
+ @internal
5
+ */
6
+ constructor(t, e, s, i, h, r, n, o, a, u = 0, f) {
7
+ this.p = t, this.stack = e, this.state = s, this.reducePos = i, this.pos = h, this.score = r, this.buffer = n, this.bufferBase = o, this.curContext = a, this.lookAhead = u, this.parent = f;
8
+ }
9
+ /**
10
+ @internal
11
+ */
12
+ toString() {
13
+ return `[${this.stack.filter((t, e) => e % 3 == 0).concat(this.state)}]@${this.pos}${this.score ? "!" + this.score : ""}`;
14
+ }
15
+ // Start an empty stack
16
+ /**
17
+ @internal
18
+ */
19
+ static start(t, e, s = 0) {
20
+ let i = t.parser.context;
21
+ return new v(t, [], e, s, s, 0, [], 0, i ? new N(i, i.start) : null, 0, null);
22
+ }
23
+ /**
24
+ The stack's current [context](#lr.ContextTracker) value, if
25
+ any. Its type will depend on the context tracker's type
26
+ parameter, or it will be `null` if there is no context
27
+ tracker.
28
+ */
29
+ get context() {
30
+ return this.curContext ? this.curContext.context : null;
31
+ }
32
+ // Push a state onto the stack, tracking its start position as well
33
+ // as the buffer base at that point.
34
+ /**
35
+ @internal
36
+ */
37
+ pushState(t, e) {
38
+ this.stack.push(this.state, e, this.bufferBase + this.buffer.length), this.state = t;
39
+ }
40
+ // Apply a reduce action
41
+ /**
42
+ @internal
43
+ */
44
+ reduce(t) {
45
+ var e;
46
+ let s = t >> 19, i = t & 65535, { parser: h } = this.p, r = this.reducePos < this.pos - 25 && this.setLookAhead(this.pos), n = h.dynamicPrecedence(i);
47
+ if (n && (this.score += n), s == 0) {
48
+ i < h.minRepeatTerm && this.reducePos < this.pos && (this.reducePos = this.pos), this.pushState(h.getGoto(this.state, i, !0), this.reducePos), i < h.minRepeatTerm && this.storeNode(i, this.reducePos, this.reducePos, r ? 8 : 4, !0), this.reduceContext(i, this.reducePos);
49
+ return;
50
+ }
51
+ let o = this.stack.length - (s - 1) * 3 - (t & 262144 ? 6 : 0), a = o ? this.stack[o - 2] : this.p.ranges[0].from;
52
+ i < h.minRepeatTerm && a == this.reducePos && this.reducePos < this.pos && (this.reducePos = this.pos);
53
+ let u = this.reducePos - a;
54
+ u >= 2e3 && !(!((e = this.p.parser.nodeSet.types[i]) === null || e === void 0) && e.isAnonymous) && (a == this.p.lastBigReductionStart ? (this.p.bigReductionCount++, this.p.lastBigReductionSize = u) : this.p.lastBigReductionSize < u && (this.p.bigReductionCount = 1, this.p.lastBigReductionStart = a, this.p.lastBigReductionSize = u));
55
+ let f = o ? this.stack[o - 1] : 0, p = this.bufferBase + this.buffer.length - f;
56
+ if (i < h.minRepeatTerm || t & 131072) {
57
+ let c = h.stateFlag(
58
+ this.state,
59
+ 1
60
+ /* StateFlag.Skipped */
61
+ ) ? this.pos : this.reducePos;
62
+ this.storeNode(i, a, c, p + 4, !0);
63
+ }
64
+ if (t & 262144)
65
+ this.state = this.stack[o];
66
+ else {
67
+ let c = this.stack[o - 3];
68
+ this.state = h.getGoto(c, i, !0);
69
+ }
70
+ for (; this.stack.length > o; )
71
+ this.stack.pop();
72
+ this.reduceContext(i, a);
73
+ }
74
+ // Shift a value into the buffer
75
+ /**
76
+ @internal
77
+ */
78
+ storeNode(t, e, s, i = 4, h = !1) {
79
+ if (t == 0 && (!this.stack.length || this.stack[this.stack.length - 1] < this.buffer.length + this.bufferBase)) {
80
+ let r = this.buffer.length;
81
+ if (r > 0 && this.buffer[r - 4] == 0 && this.buffer[r - 1] > -1) {
82
+ if (e == s)
83
+ return;
84
+ if (this.buffer[r - 2] >= e) {
85
+ this.buffer[r - 2] = s;
86
+ return;
87
+ }
88
+ }
89
+ }
90
+ if (!h || this.pos == s)
91
+ this.buffer.push(t, e, s, i);
92
+ else {
93
+ let r = this.buffer.length;
94
+ if (r > 0 && (this.buffer[r - 4] != 0 || this.buffer[r - 1] < 0)) {
95
+ let n = !1;
96
+ for (let o = r; o > 0 && this.buffer[o - 2] > s; o -= 4)
97
+ if (this.buffer[o - 1] >= 0) {
98
+ n = !0;
99
+ break;
100
+ }
101
+ if (n)
102
+ for (; r > 0 && this.buffer[r - 2] > s; )
103
+ this.buffer[r] = this.buffer[r - 4], this.buffer[r + 1] = this.buffer[r - 3], this.buffer[r + 2] = this.buffer[r - 2], this.buffer[r + 3] = this.buffer[r - 1], r -= 4, i > 4 && (i -= 4);
104
+ }
105
+ this.buffer[r] = t, this.buffer[r + 1] = e, this.buffer[r + 2] = s, this.buffer[r + 3] = i;
106
+ }
107
+ }
108
+ // Apply a shift action
109
+ /**
110
+ @internal
111
+ */
112
+ shift(t, e, s, i) {
113
+ if (t & 131072)
114
+ this.pushState(t & 65535, this.pos);
115
+ else if (t & 262144)
116
+ this.pos = i, this.shiftContext(e, s), e <= this.p.parser.maxNode && this.buffer.push(e, s, i, 4);
117
+ else {
118
+ let h = t, { parser: r } = this.p;
119
+ this.pos = i;
120
+ let n = r.stateFlag(
121
+ h,
122
+ 1
123
+ /* StateFlag.Skipped */
124
+ );
125
+ !n && (i > s || e <= r.maxNode) && (this.reducePos = i), this.pushState(h, n ? s : Math.min(s, this.reducePos)), this.shiftContext(e, s), e <= r.maxNode && this.buffer.push(e, s, i, 4);
126
+ }
127
+ }
128
+ // Apply an action
129
+ /**
130
+ @internal
131
+ */
132
+ apply(t, e, s, i) {
133
+ t & 65536 ? this.reduce(t) : this.shift(t, e, s, i);
134
+ }
135
+ // Add a prebuilt (reused) node into the buffer.
136
+ /**
137
+ @internal
138
+ */
139
+ useNode(t, e) {
140
+ let s = this.p.reused.length - 1;
141
+ (s < 0 || this.p.reused[s] != t) && (this.p.reused.push(t), s++);
142
+ let i = this.pos;
143
+ this.reducePos = this.pos = i + t.length, this.pushState(e, i), this.buffer.push(
144
+ s,
145
+ i,
146
+ this.reducePos,
147
+ -1
148
+ /* size == -1 means this is a reused value */
149
+ ), this.curContext && this.updateContext(this.curContext.tracker.reuse(this.curContext.context, t, this, this.p.stream.reset(this.pos - t.length)));
150
+ }
151
+ // Split the stack. Due to the buffer sharing and the fact
152
+ // that `this.stack` tends to stay quite shallow, this isn't very
153
+ // expensive.
154
+ /**
155
+ @internal
156
+ */
157
+ split() {
158
+ let t = this, e = t.buffer.length;
159
+ for (e && t.buffer[e - 4] == 0 && (e -= 4); e > 0 && t.buffer[e - 2] > t.reducePos; )
160
+ e -= 4;
161
+ let s = t.buffer.slice(e), i = t.bufferBase + e;
162
+ for (; t && i == t.bufferBase; )
163
+ t = t.parent;
164
+ return new v(this.p, this.stack.slice(), this.state, this.reducePos, this.pos, this.score, s, i, this.curContext, this.lookAhead, t);
165
+ }
166
+ // Try to recover from an error by 'deleting' (ignoring) one token.
167
+ /**
168
+ @internal
169
+ */
170
+ recoverByDelete(t, e) {
171
+ let s = t <= this.p.parser.maxNode;
172
+ s && this.storeNode(t, this.pos, e, 4), this.storeNode(0, this.pos, e, s ? 8 : 4), this.pos = this.reducePos = e, this.score -= 190;
173
+ }
174
+ /**
175
+ Check if the given term would be able to be shifted (optionally
176
+ after some reductions) on this stack. This can be useful for
177
+ external tokenizers that want to make sure they only provide a
178
+ given token when it applies.
179
+ */
180
+ canShift(t) {
181
+ for (let e = new G(this); ; ) {
182
+ let s = this.p.parser.stateSlot(
183
+ e.state,
184
+ 4
185
+ /* ParseState.DefaultReduce */
186
+ ) || this.p.parser.hasAction(e.state, t);
187
+ if (s == 0)
188
+ return !1;
189
+ if (!(s & 65536))
190
+ return !0;
191
+ e.reduce(s);
192
+ }
193
+ }
194
+ // Apply up to Recover.MaxNext recovery actions that conceptually
195
+ // inserts some missing token or rule.
196
+ /**
197
+ @internal
198
+ */
199
+ recoverByInsert(t) {
200
+ if (this.stack.length >= 300)
201
+ return [];
202
+ let e = this.p.parser.nextStates(this.state);
203
+ if (e.length > 8 || this.stack.length >= 120) {
204
+ let i = [];
205
+ for (let h = 0, r; h < e.length; h += 2)
206
+ (r = e[h + 1]) != this.state && this.p.parser.hasAction(r, t) && i.push(e[h], r);
207
+ if (this.stack.length < 120)
208
+ for (let h = 0; i.length < 8 && h < e.length; h += 2) {
209
+ let r = e[h + 1];
210
+ i.some((n, o) => o & 1 && n == r) || i.push(e[h], r);
211
+ }
212
+ e = i;
213
+ }
214
+ let s = [];
215
+ for (let i = 0; i < e.length && s.length < 4; i += 2) {
216
+ let h = e[i + 1];
217
+ if (h == this.state)
218
+ continue;
219
+ let r = this.split();
220
+ r.pushState(h, this.pos), r.storeNode(0, r.pos, r.pos, 4, !0), r.shiftContext(e[i], this.pos), r.reducePos = this.pos, r.score -= 200, s.push(r);
221
+ }
222
+ return s;
223
+ }
224
+ // Force a reduce, if possible. Return false if that can't
225
+ // be done.
226
+ /**
227
+ @internal
228
+ */
229
+ forceReduce() {
230
+ let { parser: t } = this.p, e = t.stateSlot(
231
+ this.state,
232
+ 5
233
+ /* ParseState.ForcedReduce */
234
+ );
235
+ if (!(e & 65536))
236
+ return !1;
237
+ if (!t.validAction(this.state, e)) {
238
+ let s = e >> 19, i = e & 65535, h = this.stack.length - s * 3;
239
+ if (h < 0 || t.getGoto(this.stack[h], i, !1) < 0) {
240
+ let r = this.findForcedReduction();
241
+ if (r == null)
242
+ return !1;
243
+ e = r;
244
+ }
245
+ this.storeNode(0, this.pos, this.pos, 4, !0), this.score -= 100;
246
+ }
247
+ return this.reducePos = this.pos, this.reduce(e), !0;
248
+ }
249
+ /**
250
+ Try to scan through the automaton to find some kind of reduction
251
+ that can be applied. Used when the regular ForcedReduce field
252
+ isn't a valid action. @internal
253
+ */
254
+ findForcedReduction() {
255
+ let { parser: t } = this.p, e = [], s = (i, h) => {
256
+ if (!e.includes(i))
257
+ return e.push(i), t.allActions(i, (r) => {
258
+ if (!(r & 393216)) if (r & 65536) {
259
+ let n = (r >> 19) - h;
260
+ if (n > 1) {
261
+ let o = r & 65535, a = this.stack.length - n * 3;
262
+ if (a >= 0 && t.getGoto(this.stack[a], o, !1) >= 0)
263
+ return n << 19 | 65536 | o;
264
+ }
265
+ } else {
266
+ let n = s(r, h + 1);
267
+ if (n != null)
268
+ return n;
269
+ }
270
+ });
271
+ };
272
+ return s(this.state, 0);
273
+ }
274
+ /**
275
+ @internal
276
+ */
277
+ forceAll() {
278
+ for (; !this.p.parser.stateFlag(
279
+ this.state,
280
+ 2
281
+ /* StateFlag.Accepting */
282
+ ); )
283
+ if (!this.forceReduce()) {
284
+ this.storeNode(0, this.pos, this.pos, 4, !0);
285
+ break;
286
+ }
287
+ return this;
288
+ }
289
+ /**
290
+ Check whether this state has no further actions (assumed to be a direct descendant of the
291
+ top state, since any other states must be able to continue
292
+ somehow). @internal
293
+ */
294
+ get deadEnd() {
295
+ if (this.stack.length != 3)
296
+ return !1;
297
+ let { parser: t } = this.p;
298
+ return t.data[t.stateSlot(
299
+ this.state,
300
+ 1
301
+ /* ParseState.Actions */
302
+ )] == 65535 && !t.stateSlot(
303
+ this.state,
304
+ 4
305
+ /* ParseState.DefaultReduce */
306
+ );
307
+ }
308
+ /**
309
+ Restart the stack (put it back in its start state). Only safe
310
+ when this.stack.length == 3 (state is directly below the top
311
+ state). @internal
312
+ */
313
+ restart() {
314
+ this.storeNode(0, this.pos, this.pos, 4, !0), this.state = this.stack[0], this.stack.length = 0;
315
+ }
316
+ /**
317
+ @internal
318
+ */
319
+ sameState(t) {
320
+ if (this.state != t.state || this.stack.length != t.stack.length)
321
+ return !1;
322
+ for (let e = 0; e < this.stack.length; e += 3)
323
+ if (this.stack[e] != t.stack[e])
324
+ return !1;
325
+ return !0;
326
+ }
327
+ /**
328
+ Get the parser used by this stack.
329
+ */
330
+ get parser() {
331
+ return this.p.parser;
332
+ }
333
+ /**
334
+ Test whether a given dialect (by numeric ID, as exported from
335
+ the terms file) is enabled.
336
+ */
337
+ dialectEnabled(t) {
338
+ return this.p.parser.dialect.flags[t];
339
+ }
340
+ shiftContext(t, e) {
341
+ this.curContext && this.updateContext(this.curContext.tracker.shift(this.curContext.context, t, this, this.p.stream.reset(e)));
342
+ }
343
+ reduceContext(t, e) {
344
+ this.curContext && this.updateContext(this.curContext.tracker.reduce(this.curContext.context, t, this, this.p.stream.reset(e)));
345
+ }
346
+ /**
347
+ @internal
348
+ */
349
+ emitContext() {
350
+ let t = this.buffer.length - 1;
351
+ (t < 0 || this.buffer[t] != -3) && this.buffer.push(this.curContext.hash, this.pos, this.pos, -3);
352
+ }
353
+ /**
354
+ @internal
355
+ */
356
+ emitLookAhead() {
357
+ let t = this.buffer.length - 1;
358
+ (t < 0 || this.buffer[t] != -4) && this.buffer.push(this.lookAhead, this.pos, this.pos, -4);
359
+ }
360
+ updateContext(t) {
361
+ if (t != this.curContext.context) {
362
+ let e = new N(this.curContext.tracker, t);
363
+ e.hash != this.curContext.hash && this.emitContext(), this.curContext = e;
364
+ }
365
+ }
366
+ /**
367
+ @internal
368
+ */
369
+ setLookAhead(t) {
370
+ return t <= this.lookAhead ? !1 : (this.emitLookAhead(), this.lookAhead = t, !0);
371
+ }
372
+ /**
373
+ @internal
374
+ */
375
+ close() {
376
+ this.curContext && this.curContext.tracker.strict && this.emitContext(), this.lookAhead > 0 && this.emitLookAhead();
377
+ }
378
+ }
379
+ class N {
380
+ constructor(t, e) {
381
+ this.tracker = t, this.context = e, this.hash = t.strict ? t.hash(e) : 0;
382
+ }
383
+ }
384
+ class G {
385
+ constructor(t) {
386
+ this.start = t, this.state = t.state, this.stack = t.stack, this.base = this.stack.length;
387
+ }
388
+ reduce(t) {
389
+ let e = t & 65535, s = t >> 19;
390
+ s == 0 ? (this.stack == this.start.stack && (this.stack = this.stack.slice()), this.stack.push(this.state, 0, 0), this.base += 3) : this.base -= (s - 1) * 3;
391
+ let i = this.start.p.parser.getGoto(this.stack[this.base - 3], e, !0);
392
+ this.state = i;
393
+ }
394
+ }
395
+ class A {
396
+ constructor(t, e, s) {
397
+ this.stack = t, this.pos = e, this.index = s, this.buffer = t.buffer, this.index == 0 && this.maybeNext();
398
+ }
399
+ static create(t, e = t.bufferBase + t.buffer.length) {
400
+ return new A(t, e, e - t.bufferBase);
401
+ }
402
+ maybeNext() {
403
+ let t = this.stack.parent;
404
+ t != null && (this.index = this.stack.bufferBase - t.bufferBase, this.stack = t, this.buffer = t.buffer);
405
+ }
406
+ get id() {
407
+ return this.buffer[this.index - 4];
408
+ }
409
+ get start() {
410
+ return this.buffer[this.index - 3];
411
+ }
412
+ get end() {
413
+ return this.buffer[this.index - 2];
414
+ }
415
+ get size() {
416
+ return this.buffer[this.index - 1];
417
+ }
418
+ next() {
419
+ this.index -= 4, this.pos -= 4, this.index == 0 && this.maybeNext();
420
+ }
421
+ fork() {
422
+ return new A(this.stack, this.pos, this.index);
423
+ }
424
+ }
425
+ function x(l, t = Uint16Array) {
426
+ if (typeof l != "string")
427
+ return l;
428
+ let e = null;
429
+ for (let s = 0, i = 0; s < l.length; ) {
430
+ let h = 0;
431
+ for (; ; ) {
432
+ let r = l.charCodeAt(s++), n = !1;
433
+ if (r == 126) {
434
+ h = 65535;
435
+ break;
436
+ }
437
+ r >= 92 && r--, r >= 34 && r--;
438
+ let o = r - 32;
439
+ if (o >= 46 && (o -= 46, n = !0), h += o, n)
440
+ break;
441
+ h *= 46;
442
+ }
443
+ e ? e[i++] = h : e = new t(h);
444
+ }
445
+ return e;
446
+ }
447
+ class P {
448
+ constructor() {
449
+ this.start = -1, this.value = -1, this.end = -1, this.extended = -1, this.lookAhead = 0, this.mask = 0, this.context = 0;
450
+ }
451
+ }
452
+ const R = new P();
453
+ class U {
454
+ /**
455
+ @internal
456
+ */
457
+ constructor(t, e) {
458
+ this.input = t, this.ranges = e, this.chunk = "", this.chunkOff = 0, this.chunk2 = "", this.chunk2Pos = 0, this.next = -1, this.token = R, this.rangeIndex = 0, this.pos = this.chunkPos = e[0].from, this.range = e[0], this.end = e[e.length - 1].to, this.readNext();
459
+ }
460
+ /**
461
+ @internal
462
+ */
463
+ resolveOffset(t, e) {
464
+ let s = this.range, i = this.rangeIndex, h = this.pos + t;
465
+ for (; h < s.from; ) {
466
+ if (!i)
467
+ return null;
468
+ let r = this.ranges[--i];
469
+ h -= s.from - r.to, s = r;
470
+ }
471
+ for (; e < 0 ? h > s.to : h >= s.to; ) {
472
+ if (i == this.ranges.length - 1)
473
+ return null;
474
+ let r = this.ranges[++i];
475
+ h += r.from - s.to, s = r;
476
+ }
477
+ return h;
478
+ }
479
+ /**
480
+ @internal
481
+ */
482
+ clipPos(t) {
483
+ if (t >= this.range.from && t < this.range.to)
484
+ return t;
485
+ for (let e of this.ranges)
486
+ if (e.to > t)
487
+ return Math.max(t, e.from);
488
+ return this.end;
489
+ }
490
+ /**
491
+ Look at a code unit near the stream position. `.peek(0)` equals
492
+ `.next`, `.peek(-1)` gives you the previous character, and so
493
+ on.
494
+
495
+ Note that looking around during tokenizing creates dependencies
496
+ on potentially far-away content, which may reduce the
497
+ effectiveness incremental parsing—when looking forward—or even
498
+ cause invalid reparses when looking backward more than 25 code
499
+ units, since the library does not track lookbehind.
500
+ */
501
+ peek(t) {
502
+ let e = this.chunkOff + t, s, i;
503
+ if (e >= 0 && e < this.chunk.length)
504
+ s = this.pos + t, i = this.chunk.charCodeAt(e);
505
+ else {
506
+ let h = this.resolveOffset(t, 1);
507
+ if (h == null)
508
+ return -1;
509
+ if (s = h, s >= this.chunk2Pos && s < this.chunk2Pos + this.chunk2.length)
510
+ i = this.chunk2.charCodeAt(s - this.chunk2Pos);
511
+ else {
512
+ let r = this.rangeIndex, n = this.range;
513
+ for (; n.to <= s; )
514
+ n = this.ranges[++r];
515
+ this.chunk2 = this.input.chunk(this.chunk2Pos = s), s + this.chunk2.length > n.to && (this.chunk2 = this.chunk2.slice(0, n.to - s)), i = this.chunk2.charCodeAt(0);
516
+ }
517
+ }
518
+ return s >= this.token.lookAhead && (this.token.lookAhead = s + 1), i;
519
+ }
520
+ /**
521
+ Accept a token. By default, the end of the token is set to the
522
+ current stream position, but you can pass an offset (relative to
523
+ the stream position) to change that.
524
+ */
525
+ acceptToken(t, e = 0) {
526
+ let s = e ? this.resolveOffset(e, -1) : this.pos;
527
+ if (s == null || s < this.token.start)
528
+ throw new RangeError("Token end out of bounds");
529
+ this.token.value = t, this.token.end = s;
530
+ }
531
+ /**
532
+ Accept a token ending at a specific given position.
533
+ */
534
+ acceptTokenTo(t, e) {
535
+ this.token.value = t, this.token.end = e;
536
+ }
537
+ getChunk() {
538
+ if (this.pos >= this.chunk2Pos && this.pos < this.chunk2Pos + this.chunk2.length) {
539
+ let { chunk: t, chunkPos: e } = this;
540
+ this.chunk = this.chunk2, this.chunkPos = this.chunk2Pos, this.chunk2 = t, this.chunk2Pos = e, this.chunkOff = this.pos - this.chunkPos;
541
+ } else {
542
+ this.chunk2 = this.chunk, this.chunk2Pos = this.chunkPos;
543
+ let t = this.input.chunk(this.pos), e = this.pos + t.length;
544
+ this.chunk = e > this.range.to ? t.slice(0, this.range.to - this.pos) : t, this.chunkPos = this.pos, this.chunkOff = 0;
545
+ }
546
+ }
547
+ readNext() {
548
+ return this.chunkOff >= this.chunk.length && (this.getChunk(), this.chunkOff == this.chunk.length) ? this.next = -1 : this.next = this.chunk.charCodeAt(this.chunkOff);
549
+ }
550
+ /**
551
+ Move the stream forward N (defaults to 1) code units. Returns
552
+ the new value of [`next`](#lr.InputStream.next).
553
+ */
554
+ advance(t = 1) {
555
+ for (this.chunkOff += t; this.pos + t >= this.range.to; ) {
556
+ if (this.rangeIndex == this.ranges.length - 1)
557
+ return this.setDone();
558
+ t -= this.range.to - this.pos, this.range = this.ranges[++this.rangeIndex], this.pos = this.range.from;
559
+ }
560
+ return this.pos += t, this.pos >= this.token.lookAhead && (this.token.lookAhead = this.pos + 1), this.readNext();
561
+ }
562
+ setDone() {
563
+ return this.pos = this.chunkPos = this.end, this.range = this.ranges[this.rangeIndex = this.ranges.length - 1], this.chunk = "", this.next = -1;
564
+ }
565
+ /**
566
+ @internal
567
+ */
568
+ reset(t, e) {
569
+ if (e ? (this.token = e, e.start = t, e.lookAhead = t + 1, e.value = e.extended = -1) : this.token = R, this.pos != t) {
570
+ if (this.pos = t, t == this.end)
571
+ return this.setDone(), this;
572
+ for (; t < this.range.from; )
573
+ this.range = this.ranges[--this.rangeIndex];
574
+ for (; t >= this.range.to; )
575
+ this.range = this.ranges[++this.rangeIndex];
576
+ t >= this.chunkPos && t < this.chunkPos + this.chunk.length ? this.chunkOff = t - this.chunkPos : (this.chunk = "", this.chunkOff = 0), this.readNext();
577
+ }
578
+ return this;
579
+ }
580
+ /**
581
+ @internal
582
+ */
583
+ read(t, e) {
584
+ if (t >= this.chunkPos && e <= this.chunkPos + this.chunk.length)
585
+ return this.chunk.slice(t - this.chunkPos, e - this.chunkPos);
586
+ if (t >= this.chunk2Pos && e <= this.chunk2Pos + this.chunk2.length)
587
+ return this.chunk2.slice(t - this.chunk2Pos, e - this.chunk2Pos);
588
+ if (t >= this.range.from && e <= this.range.to)
589
+ return this.input.read(t, e);
590
+ let s = "";
591
+ for (let i of this.ranges) {
592
+ if (i.from >= e)
593
+ break;
594
+ i.to > t && (s += this.input.read(Math.max(i.from, t), Math.min(i.to, e)));
595
+ }
596
+ return s;
597
+ }
598
+ }
599
+ class m {
600
+ constructor(t, e) {
601
+ this.data = t, this.id = e;
602
+ }
603
+ token(t, e) {
604
+ let { parser: s } = e.p;
605
+ F(this.data, t, e, this.id, s.data, s.tokenPrecTable);
606
+ }
607
+ }
608
+ m.prototype.contextual = m.prototype.fallback = m.prototype.extend = !1;
609
+ class H {
610
+ constructor(t, e, s) {
611
+ this.precTable = e, this.elseToken = s, this.data = typeof t == "string" ? x(t) : t;
612
+ }
613
+ token(t, e) {
614
+ let s = t.pos, i = 0;
615
+ for (; ; ) {
616
+ let h = t.next < 0, r = t.resolveOffset(1, 1);
617
+ if (F(this.data, t, e, 0, this.data, this.precTable), t.token.value > -1)
618
+ break;
619
+ if (this.elseToken == null)
620
+ return;
621
+ if (h || i++, r == null)
622
+ break;
623
+ t.reset(r, t.token);
624
+ }
625
+ i && (t.reset(s, t.token), t.acceptToken(this.elseToken, i));
626
+ }
627
+ }
628
+ H.prototype.contextual = m.prototype.fallback = m.prototype.extend = !1;
629
+ class Y {
630
+ /**
631
+ Create a tokenizer. The first argument is the function that,
632
+ given an input stream, scans for the types of tokens it
633
+ recognizes at the stream's position, and calls
634
+ [`acceptToken`](#lr.InputStream.acceptToken) when it finds
635
+ one.
636
+ */
637
+ constructor(t, e = {}) {
638
+ this.token = t, this.contextual = !!e.contextual, this.fallback = !!e.fallback, this.extend = !!e.extend;
639
+ }
640
+ }
641
+ function F(l, t, e, s, i, h) {
642
+ let r = 0, n = 1 << s, { dialect: o } = e.p.parser;
643
+ t: for (; n & l[r]; ) {
644
+ let a = l[r + 1];
645
+ for (let c = r + 3; c < a; c += 2)
646
+ if ((l[c + 1] & n) > 0) {
647
+ let d = l[c];
648
+ if (o.allows(d) && (t.token.value == -1 || t.token.value == d || W(d, t.token.value, i, h))) {
649
+ t.acceptToken(d);
650
+ break;
651
+ }
652
+ }
653
+ let u = t.next, f = 0, p = l[r + 2];
654
+ if (t.next < 0 && p > f && l[a + p * 3 - 3] == 65535) {
655
+ r = l[a + p * 3 - 1];
656
+ continue t;
657
+ }
658
+ for (; f < p; ) {
659
+ let c = f + p >> 1, d = a + c + (c << 1), b = l[d], O = l[d + 1] || 65536;
660
+ if (u < b)
661
+ p = c;
662
+ else if (u >= O)
663
+ f = c + 1;
664
+ else {
665
+ r = l[d + 2], t.advance();
666
+ continue t;
667
+ }
668
+ }
669
+ break;
670
+ }
671
+ }
672
+ function z(l, t, e) {
673
+ for (let s = t, i; (i = l[s]) != 65535; s++)
674
+ if (i == e)
675
+ return s - t;
676
+ return -1;
677
+ }
678
+ function W(l, t, e, s) {
679
+ let i = z(e, s, t);
680
+ return i < 0 || z(e, s, l) < i;
681
+ }
682
+ const g = typeof process < "u" && process.env && /\bparse\b/.test(process.env.LOG);
683
+ let T = null;
684
+ function I(l, t, e) {
685
+ let s = l.cursor(j.IncludeAnonymous);
686
+ for (s.moveTo(t); ; )
687
+ if (!(e < 0 ? s.childBefore(t) : s.childAfter(t)))
688
+ for (; ; ) {
689
+ if ((e < 0 ? s.to < t : s.from > t) && !s.type.isError)
690
+ return e < 0 ? Math.max(0, Math.min(
691
+ s.to - 1,
692
+ t - 25
693
+ /* Lookahead.Margin */
694
+ )) : Math.min(l.length, Math.max(
695
+ s.from + 1,
696
+ t + 25
697
+ /* Lookahead.Margin */
698
+ ));
699
+ if (e < 0 ? s.prevSibling() : s.nextSibling())
700
+ break;
701
+ if (!s.parent())
702
+ return e < 0 ? 0 : l.length;
703
+ }
704
+ }
705
+ class q {
706
+ constructor(t, e) {
707
+ this.fragments = t, this.nodeSet = e, this.i = 0, this.fragment = null, this.safeFrom = -1, this.safeTo = -1, this.trees = [], this.start = [], this.index = [], this.nextFragment();
708
+ }
709
+ nextFragment() {
710
+ let t = this.fragment = this.i == this.fragments.length ? null : this.fragments[this.i++];
711
+ if (t) {
712
+ for (this.safeFrom = t.openStart ? I(t.tree, t.from + t.offset, 1) - t.offset : t.from, this.safeTo = t.openEnd ? I(t.tree, t.to + t.offset, -1) - t.offset : t.to; this.trees.length; )
713
+ this.trees.pop(), this.start.pop(), this.index.pop();
714
+ this.trees.push(t.tree), this.start.push(-t.offset), this.index.push(0), this.nextStart = this.safeFrom;
715
+ } else
716
+ this.nextStart = 1e9;
717
+ }
718
+ // `pos` must be >= any previously given `pos` for this cursor
719
+ nodeAt(t) {
720
+ if (t < this.nextStart)
721
+ return null;
722
+ for (; this.fragment && this.safeTo <= t; )
723
+ this.nextFragment();
724
+ if (!this.fragment)
725
+ return null;
726
+ for (; ; ) {
727
+ let e = this.trees.length - 1;
728
+ if (e < 0)
729
+ return this.nextFragment(), null;
730
+ let s = this.trees[e], i = this.index[e];
731
+ if (i == s.children.length) {
732
+ this.trees.pop(), this.start.pop(), this.index.pop();
733
+ continue;
734
+ }
735
+ let h = s.children[i], r = this.start[e] + s.positions[i];
736
+ if (r > t)
737
+ return this.nextStart = r, null;
738
+ if (h instanceof S) {
739
+ if (r == t) {
740
+ if (r < this.safeFrom)
741
+ return null;
742
+ let n = r + h.length;
743
+ if (n <= this.safeTo) {
744
+ let o = h.prop(y.lookAhead);
745
+ if (!o || n + o < this.fragment.to)
746
+ return h;
747
+ }
748
+ }
749
+ this.index[e]++, r + h.length >= Math.max(this.safeFrom, t) && (this.trees.push(h), this.start.push(r), this.index.push(0));
750
+ } else
751
+ this.index[e]++, this.nextStart = r + h.length;
752
+ }
753
+ }
754
+ }
755
+ class J {
756
+ constructor(t, e) {
757
+ this.stream = e, this.tokens = [], this.mainToken = null, this.actions = [], this.tokens = t.tokenizers.map((s) => new P());
758
+ }
759
+ getActions(t) {
760
+ let e = 0, s = null, { parser: i } = t.p, { tokenizers: h } = i, r = i.stateSlot(
761
+ t.state,
762
+ 3
763
+ /* ParseState.TokenizerMask */
764
+ ), n = t.curContext ? t.curContext.hash : 0, o = 0;
765
+ for (let a = 0; a < h.length; a++) {
766
+ if (!(1 << a & r))
767
+ continue;
768
+ let u = h[a], f = this.tokens[a];
769
+ if (!(s && !u.fallback) && ((u.contextual || f.start != t.pos || f.mask != r || f.context != n) && (this.updateCachedToken(f, u, t), f.mask = r, f.context = n), f.lookAhead > f.end + 25 && (o = Math.max(f.lookAhead, o)), f.value != 0)) {
770
+ let p = e;
771
+ if (f.extended > -1 && (e = this.addActions(t, f.extended, f.end, e)), e = this.addActions(t, f.value, f.end, e), !u.extend && (s = f, e > p))
772
+ break;
773
+ }
774
+ }
775
+ for (; this.actions.length > e; )
776
+ this.actions.pop();
777
+ return o && t.setLookAhead(o), !s && t.pos == this.stream.end && (s = new P(), s.value = t.p.parser.eofTerm, s.start = s.end = t.pos, e = this.addActions(t, s.value, s.end, e)), this.mainToken = s, this.actions;
778
+ }
779
+ getMainToken(t) {
780
+ if (this.mainToken)
781
+ return this.mainToken;
782
+ let e = new P(), { pos: s, p: i } = t;
783
+ return e.start = s, e.end = Math.min(s + 1, i.stream.end), e.value = s == i.stream.end ? i.parser.eofTerm : 0, e;
784
+ }
785
+ updateCachedToken(t, e, s) {
786
+ let i = this.stream.clipPos(s.pos);
787
+ if (e.token(this.stream.reset(i, t), s), t.value > -1) {
788
+ let { parser: h } = s.p;
789
+ for (let r = 0; r < h.specialized.length; r++)
790
+ if (h.specialized[r] == t.value) {
791
+ let n = h.specializers[r](this.stream.read(t.start, t.end), s);
792
+ if (n >= 0 && s.p.parser.dialect.allows(n >> 1)) {
793
+ n & 1 ? t.extended = n >> 1 : t.value = n >> 1;
794
+ break;
795
+ }
796
+ }
797
+ } else
798
+ t.value = 0, t.end = this.stream.clipPos(i + 1);
799
+ }
800
+ putAction(t, e, s, i) {
801
+ for (let h = 0; h < i; h += 3)
802
+ if (this.actions[h] == t)
803
+ return i;
804
+ return this.actions[i++] = t, this.actions[i++] = e, this.actions[i++] = s, i;
805
+ }
806
+ addActions(t, e, s, i) {
807
+ let { state: h } = t, { parser: r } = t.p, { data: n } = r;
808
+ for (let o = 0; o < 2; o++)
809
+ for (let a = r.stateSlot(
810
+ h,
811
+ o ? 2 : 1
812
+ /* ParseState.Actions */
813
+ ); ; a += 3) {
814
+ if (n[a] == 65535)
815
+ if (n[a + 1] == 1)
816
+ a = k(n, a + 2);
817
+ else {
818
+ i == 0 && n[a + 1] == 2 && (i = this.putAction(k(n, a + 2), e, s, i));
819
+ break;
820
+ }
821
+ n[a] == e && (i = this.putAction(k(n, a + 1), e, s, i));
822
+ }
823
+ return i;
824
+ }
825
+ }
826
+ class K {
827
+ constructor(t, e, s, i) {
828
+ this.parser = t, this.input = e, this.ranges = i, this.recovering = 0, this.nextStackID = 9812, this.minStackPos = 0, this.reused = [], this.stoppedAt = null, this.lastBigReductionStart = -1, this.lastBigReductionSize = 0, this.bigReductionCount = 0, this.stream = new U(e, i), this.tokens = new J(t, this.stream), this.topTerm = t.top[1];
829
+ let { from: h } = i[0];
830
+ this.stacks = [v.start(this, t.top[0], h)], this.fragments = s.length && this.stream.end - h > t.bufferLength * 4 ? new q(s, t.nodeSet) : null;
831
+ }
832
+ get parsedPos() {
833
+ return this.minStackPos;
834
+ }
835
+ // Move the parser forward. This will process all parse stacks at
836
+ // `this.pos` and try to advance them to a further position. If no
837
+ // stack for such a position is found, it'll start error-recovery.
838
+ //
839
+ // When the parse is finished, this will return a syntax tree. When
840
+ // not, it returns `null`.
841
+ advance() {
842
+ let t = this.stacks, e = this.minStackPos, s = this.stacks = [], i, h;
843
+ if (this.bigReductionCount > 300 && t.length == 1) {
844
+ let [r] = t;
845
+ for (; r.forceReduce() && r.stack.length && r.stack[r.stack.length - 2] >= this.lastBigReductionStart; )
846
+ ;
847
+ this.bigReductionCount = this.lastBigReductionSize = 0;
848
+ }
849
+ for (let r = 0; r < t.length; r++) {
850
+ let n = t[r];
851
+ for (; ; ) {
852
+ if (this.tokens.mainToken = null, n.pos > e)
853
+ s.push(n);
854
+ else {
855
+ if (this.advanceStack(n, s, t))
856
+ continue;
857
+ {
858
+ i || (i = [], h = []), i.push(n);
859
+ let o = this.tokens.getMainToken(n);
860
+ h.push(o.value, o.end);
861
+ }
862
+ }
863
+ break;
864
+ }
865
+ }
866
+ if (!s.length) {
867
+ let r = i && V(i);
868
+ if (r)
869
+ return g && console.log("Finish with " + this.stackID(r)), this.stackToTree(r);
870
+ if (this.parser.strict)
871
+ throw g && i && console.log("Stuck with token " + (this.tokens.mainToken ? this.parser.getName(this.tokens.mainToken.value) : "none")), new SyntaxError("No parse at " + e);
872
+ this.recovering || (this.recovering = 5);
873
+ }
874
+ if (this.recovering && i) {
875
+ let r = this.stoppedAt != null && i[0].pos > this.stoppedAt ? i[0] : this.runRecovery(i, h, s);
876
+ if (r)
877
+ return g && console.log("Force-finish " + this.stackID(r)), this.stackToTree(r.forceAll());
878
+ }
879
+ if (this.recovering) {
880
+ let r = this.recovering == 1 ? 1 : this.recovering * 3;
881
+ if (s.length > r)
882
+ for (s.sort((n, o) => o.score - n.score); s.length > r; )
883
+ s.pop();
884
+ s.some((n) => n.reducePos > e) && this.recovering--;
885
+ } else if (s.length > 1) {
886
+ t: for (let r = 0; r < s.length - 1; r++) {
887
+ let n = s[r];
888
+ for (let o = r + 1; o < s.length; o++) {
889
+ let a = s[o];
890
+ if (n.sameState(a) || n.buffer.length > 500 && a.buffer.length > 500)
891
+ if ((n.score - a.score || n.buffer.length - a.buffer.length) > 0)
892
+ s.splice(o--, 1);
893
+ else {
894
+ s.splice(r--, 1);
895
+ continue t;
896
+ }
897
+ }
898
+ }
899
+ s.length > 12 && (s.sort((r, n) => n.score - r.score), s.splice(
900
+ 12,
901
+ s.length - 12
902
+ /* Rec.MaxStackCount */
903
+ ));
904
+ }
905
+ this.minStackPos = s[0].pos;
906
+ for (let r = 1; r < s.length; r++)
907
+ s[r].pos < this.minStackPos && (this.minStackPos = s[r].pos);
908
+ return null;
909
+ }
910
+ stopAt(t) {
911
+ if (this.stoppedAt != null && this.stoppedAt < t)
912
+ throw new RangeError("Can't move stoppedAt forward");
913
+ this.stoppedAt = t;
914
+ }
915
+ // Returns an updated version of the given stack, or null if the
916
+ // stack can't advance normally. When `split` and `stacks` are
917
+ // given, stacks split off by ambiguous operations will be pushed to
918
+ // `split`, or added to `stacks` if they move `pos` forward.
919
+ advanceStack(t, e, s) {
920
+ let i = t.pos, { parser: h } = this, r = g ? this.stackID(t) + " -> " : "";
921
+ if (this.stoppedAt != null && i > this.stoppedAt)
922
+ return t.forceReduce() ? t : null;
923
+ if (this.fragments) {
924
+ let a = t.curContext && t.curContext.tracker.strict, u = a ? t.curContext.hash : 0;
925
+ for (let f = this.fragments.nodeAt(i); f; ) {
926
+ let p = this.parser.nodeSet.types[f.type.id] == f.type ? h.getGoto(t.state, f.type.id) : -1;
927
+ if (p > -1 && f.length && (!a || (f.prop(y.contextHash) || 0) == u))
928
+ return t.useNode(f, p), g && console.log(r + this.stackID(t) + ` (via reuse of ${h.getName(f.type.id)})`), !0;
929
+ if (!(f instanceof S) || f.children.length == 0 || f.positions[0] > 0)
930
+ break;
931
+ let c = f.children[0];
932
+ if (c instanceof S && f.positions[0] == 0)
933
+ f = c;
934
+ else
935
+ break;
936
+ }
937
+ }
938
+ let n = h.stateSlot(
939
+ t.state,
940
+ 4
941
+ /* ParseState.DefaultReduce */
942
+ );
943
+ if (n > 0)
944
+ return t.reduce(n), g && console.log(r + this.stackID(t) + ` (via always-reduce ${h.getName(
945
+ n & 65535
946
+ /* Action.ValueMask */
947
+ )})`), !0;
948
+ if (t.stack.length >= 8400)
949
+ for (; t.stack.length > 6e3 && t.forceReduce(); )
950
+ ;
951
+ let o = this.tokens.getActions(t);
952
+ for (let a = 0; a < o.length; ) {
953
+ let u = o[a++], f = o[a++], p = o[a++], c = a == o.length || !s, d = c ? t : t.split(), b = this.tokens.mainToken;
954
+ if (d.apply(u, f, b ? b.start : d.pos, p), g && console.log(r + this.stackID(d) + ` (via ${u & 65536 ? `reduce of ${h.getName(
955
+ u & 65535
956
+ /* Action.ValueMask */
957
+ )}` : "shift"} for ${h.getName(f)} @ ${i}${d == t ? "" : ", split"})`), c)
958
+ return !0;
959
+ d.pos > i ? e.push(d) : s.push(d);
960
+ }
961
+ return !1;
962
+ }
963
+ // Advance a given stack forward as far as it will go. Returns the
964
+ // (possibly updated) stack if it got stuck, or null if it moved
965
+ // forward and was given to `pushStackDedup`.
966
+ advanceFully(t, e) {
967
+ let s = t.pos;
968
+ for (; ; ) {
969
+ if (!this.advanceStack(t, null, null))
970
+ return !1;
971
+ if (t.pos > s)
972
+ return D(t, e), !0;
973
+ }
974
+ }
975
+ runRecovery(t, e, s) {
976
+ let i = null, h = !1;
977
+ for (let r = 0; r < t.length; r++) {
978
+ let n = t[r], o = e[r << 1], a = e[(r << 1) + 1], u = g ? this.stackID(n) + " -> " : "";
979
+ if (n.deadEnd && (h || (h = !0, n.restart(), g && console.log(u + this.stackID(n) + " (restarted)"), this.advanceFully(n, s))))
980
+ continue;
981
+ let f = n.split(), p = u;
982
+ for (let c = 0; c < 10 && f.forceReduce() && (g && console.log(p + this.stackID(f) + " (via force-reduce)"), !this.advanceFully(f, s)); c++)
983
+ g && (p = this.stackID(f) + " -> ");
984
+ for (let c of n.recoverByInsert(o))
985
+ g && console.log(u + this.stackID(c) + " (via recover-insert)"), this.advanceFully(c, s);
986
+ this.stream.end > n.pos ? (a == n.pos && (a++, o = 0), n.recoverByDelete(o, a), g && console.log(u + this.stackID(n) + ` (via recover-delete ${this.parser.getName(o)})`), D(n, s)) : (!i || i.score < f.score) && (i = f);
987
+ }
988
+ return i;
989
+ }
990
+ // Convert the stack's buffer to a syntax tree.
991
+ stackToTree(t) {
992
+ return t.close(), S.build({
993
+ buffer: A.create(t),
994
+ nodeSet: this.parser.nodeSet,
995
+ topID: this.topTerm,
996
+ maxBufferLength: this.parser.bufferLength,
997
+ reused: this.reused,
998
+ start: this.ranges[0].from,
999
+ length: t.pos - this.ranges[0].from,
1000
+ minRepeatType: this.parser.minRepeatTerm
1001
+ });
1002
+ }
1003
+ stackID(t) {
1004
+ let e = (T || (T = /* @__PURE__ */ new WeakMap())).get(t);
1005
+ return e || T.set(t, e = String.fromCodePoint(this.nextStackID++)), e + t;
1006
+ }
1007
+ }
1008
+ function D(l, t) {
1009
+ for (let e = 0; e < t.length; e++) {
1010
+ let s = t[e];
1011
+ if (s.pos == l.pos && s.sameState(l)) {
1012
+ t[e].score < l.score && (t[e] = l);
1013
+ return;
1014
+ }
1015
+ }
1016
+ t.push(l);
1017
+ }
1018
+ class Q {
1019
+ constructor(t, e, s) {
1020
+ this.source = t, this.flags = e, this.disabled = s;
1021
+ }
1022
+ allows(t) {
1023
+ return !this.disabled || this.disabled[t] == 0;
1024
+ }
1025
+ }
1026
+ const C = (l) => l;
1027
+ class Z {
1028
+ /**
1029
+ Define a context tracker.
1030
+ */
1031
+ constructor(t) {
1032
+ this.start = t.start, this.shift = t.shift || C, this.reduce = t.reduce || C, this.reuse = t.reuse || C, this.hash = t.hash || (() => 0), this.strict = t.strict !== !1;
1033
+ }
1034
+ }
1035
+ class w extends M {
1036
+ /**
1037
+ @internal
1038
+ */
1039
+ constructor(t) {
1040
+ if (super(), this.wrappers = [], t.version != 14)
1041
+ throw new RangeError(`Parser version (${t.version}) doesn't match runtime version (14)`);
1042
+ let e = t.nodeNames.split(" ");
1043
+ this.minRepeatTerm = e.length;
1044
+ for (let n = 0; n < t.repeatNodeCount; n++)
1045
+ e.push("");
1046
+ let s = Object.keys(t.topRules).map((n) => t.topRules[n][1]), i = [];
1047
+ for (let n = 0; n < e.length; n++)
1048
+ i.push([]);
1049
+ function h(n, o, a) {
1050
+ i[n].push([o, o.deserialize(String(a))]);
1051
+ }
1052
+ if (t.nodeProps)
1053
+ for (let n of t.nodeProps) {
1054
+ let o = n[0];
1055
+ typeof o == "string" && (o = y[o]);
1056
+ for (let a = 1; a < n.length; ) {
1057
+ let u = n[a++];
1058
+ if (u >= 0)
1059
+ h(u, o, n[a++]);
1060
+ else {
1061
+ let f = n[a + -u];
1062
+ for (let p = -u; p > 0; p--)
1063
+ h(n[a++], o, f);
1064
+ a++;
1065
+ }
1066
+ }
1067
+ }
1068
+ this.nodeSet = new L(e.map((n, o) => $.define({
1069
+ name: o >= this.minRepeatTerm ? void 0 : n,
1070
+ id: o,
1071
+ props: i[o],
1072
+ top: s.indexOf(o) > -1,
1073
+ error: o == 0,
1074
+ skipped: t.skippedNodes && t.skippedNodes.indexOf(o) > -1
1075
+ }))), t.propSources && (this.nodeSet = this.nodeSet.extend(...t.propSources)), this.strict = !1, this.bufferLength = E;
1076
+ let r = x(t.tokenData);
1077
+ this.context = t.context, this.specializerSpecs = t.specialized || [], this.specialized = new Uint16Array(this.specializerSpecs.length);
1078
+ for (let n = 0; n < this.specializerSpecs.length; n++)
1079
+ this.specialized[n] = this.specializerSpecs[n].term;
1080
+ this.specializers = this.specializerSpecs.map(B), this.states = x(t.states, Uint32Array), this.data = x(t.stateData), this.goto = x(t.goto), this.maxTerm = t.maxTerm, this.tokenizers = t.tokenizers.map((n) => typeof n == "number" ? new m(r, n) : n), this.topRules = t.topRules, this.dialects = t.dialects || {}, this.dynamicPrecedences = t.dynamicPrecedences || null, this.tokenPrecTable = t.tokenPrec, this.termNames = t.termNames || null, this.maxNode = this.nodeSet.types.length - 1, this.dialect = this.parseDialect(), this.top = this.topRules[Object.keys(this.topRules)[0]];
1081
+ }
1082
+ createParse(t, e, s) {
1083
+ let i = new K(this, t, e, s);
1084
+ for (let h of this.wrappers)
1085
+ i = h(i, t, e, s);
1086
+ return i;
1087
+ }
1088
+ /**
1089
+ Get a goto table entry @internal
1090
+ */
1091
+ getGoto(t, e, s = !1) {
1092
+ let i = this.goto;
1093
+ if (e >= i[0])
1094
+ return -1;
1095
+ for (let h = i[e + 1]; ; ) {
1096
+ let r = i[h++], n = r & 1, o = i[h++];
1097
+ if (n && s)
1098
+ return o;
1099
+ for (let a = h + (r >> 1); h < a; h++)
1100
+ if (i[h] == t)
1101
+ return o;
1102
+ if (n)
1103
+ return -1;
1104
+ }
1105
+ }
1106
+ /**
1107
+ Check if this state has an action for a given terminal @internal
1108
+ */
1109
+ hasAction(t, e) {
1110
+ let s = this.data;
1111
+ for (let i = 0; i < 2; i++)
1112
+ for (let h = this.stateSlot(
1113
+ t,
1114
+ i ? 2 : 1
1115
+ /* ParseState.Actions */
1116
+ ), r; ; h += 3) {
1117
+ if ((r = s[h]) == 65535)
1118
+ if (s[h + 1] == 1)
1119
+ r = s[h = k(s, h + 2)];
1120
+ else {
1121
+ if (s[h + 1] == 2)
1122
+ return k(s, h + 2);
1123
+ break;
1124
+ }
1125
+ if (r == e || r == 0)
1126
+ return k(s, h + 1);
1127
+ }
1128
+ return 0;
1129
+ }
1130
+ /**
1131
+ @internal
1132
+ */
1133
+ stateSlot(t, e) {
1134
+ return this.states[t * 6 + e];
1135
+ }
1136
+ /**
1137
+ @internal
1138
+ */
1139
+ stateFlag(t, e) {
1140
+ return (this.stateSlot(
1141
+ t,
1142
+ 0
1143
+ /* ParseState.Flags */
1144
+ ) & e) > 0;
1145
+ }
1146
+ /**
1147
+ @internal
1148
+ */
1149
+ validAction(t, e) {
1150
+ return !!this.allActions(t, (s) => s == e ? !0 : null);
1151
+ }
1152
+ /**
1153
+ @internal
1154
+ */
1155
+ allActions(t, e) {
1156
+ let s = this.stateSlot(
1157
+ t,
1158
+ 4
1159
+ /* ParseState.DefaultReduce */
1160
+ ), i = s ? e(s) : void 0;
1161
+ for (let h = this.stateSlot(
1162
+ t,
1163
+ 1
1164
+ /* ParseState.Actions */
1165
+ ); i == null; h += 3) {
1166
+ if (this.data[h] == 65535)
1167
+ if (this.data[h + 1] == 1)
1168
+ h = k(this.data, h + 2);
1169
+ else
1170
+ break;
1171
+ i = e(k(this.data, h + 1));
1172
+ }
1173
+ return i;
1174
+ }
1175
+ /**
1176
+ Get the states that can follow this one through shift actions or
1177
+ goto jumps. @internal
1178
+ */
1179
+ nextStates(t) {
1180
+ let e = [];
1181
+ for (let s = this.stateSlot(
1182
+ t,
1183
+ 1
1184
+ /* ParseState.Actions */
1185
+ ); ; s += 3) {
1186
+ if (this.data[s] == 65535)
1187
+ if (this.data[s + 1] == 1)
1188
+ s = k(this.data, s + 2);
1189
+ else
1190
+ break;
1191
+ if (!(this.data[s + 2] & 1)) {
1192
+ let i = this.data[s + 1];
1193
+ e.some((h, r) => r & 1 && h == i) || e.push(this.data[s], i);
1194
+ }
1195
+ }
1196
+ return e;
1197
+ }
1198
+ /**
1199
+ Configure the parser. Returns a new parser instance that has the
1200
+ given settings modified. Settings not provided in `config` are
1201
+ kept from the original parser.
1202
+ */
1203
+ configure(t) {
1204
+ let e = Object.assign(Object.create(w.prototype), this);
1205
+ if (t.props && (e.nodeSet = this.nodeSet.extend(...t.props)), t.top) {
1206
+ let s = this.topRules[t.top];
1207
+ if (!s)
1208
+ throw new RangeError(`Invalid top rule name ${t.top}`);
1209
+ e.top = s;
1210
+ }
1211
+ return t.tokenizers && (e.tokenizers = this.tokenizers.map((s) => {
1212
+ let i = t.tokenizers.find((h) => h.from == s);
1213
+ return i ? i.to : s;
1214
+ })), t.specializers && (e.specializers = this.specializers.slice(), e.specializerSpecs = this.specializerSpecs.map((s, i) => {
1215
+ let h = t.specializers.find((n) => n.from == s.external);
1216
+ if (!h)
1217
+ return s;
1218
+ let r = Object.assign(Object.assign({}, s), { external: h.to });
1219
+ return e.specializers[i] = B(r), r;
1220
+ })), t.contextTracker && (e.context = t.contextTracker), t.dialect && (e.dialect = this.parseDialect(t.dialect)), t.strict != null && (e.strict = t.strict), t.wrap && (e.wrappers = e.wrappers.concat(t.wrap)), t.bufferLength != null && (e.bufferLength = t.bufferLength), e;
1221
+ }
1222
+ /**
1223
+ Tells you whether any [parse wrappers](#lr.ParserConfig.wrap)
1224
+ are registered for this parser.
1225
+ */
1226
+ hasWrappers() {
1227
+ return this.wrappers.length > 0;
1228
+ }
1229
+ /**
1230
+ Returns the name associated with a given term. This will only
1231
+ work for all terms when the parser was generated with the
1232
+ `--names` option. By default, only the names of tagged terms are
1233
+ stored.
1234
+ */
1235
+ getName(t) {
1236
+ return this.termNames ? this.termNames[t] : String(t <= this.maxNode && this.nodeSet.types[t].name || t);
1237
+ }
1238
+ /**
1239
+ The eof term id is always allocated directly after the node
1240
+ types. @internal
1241
+ */
1242
+ get eofTerm() {
1243
+ return this.maxNode + 1;
1244
+ }
1245
+ /**
1246
+ The type of top node produced by the parser.
1247
+ */
1248
+ get topNode() {
1249
+ return this.nodeSet.types[this.top[1]];
1250
+ }
1251
+ /**
1252
+ @internal
1253
+ */
1254
+ dynamicPrecedence(t) {
1255
+ let e = this.dynamicPrecedences;
1256
+ return e == null ? 0 : e[t] || 0;
1257
+ }
1258
+ /**
1259
+ @internal
1260
+ */
1261
+ parseDialect(t) {
1262
+ let e = Object.keys(this.dialects), s = e.map(() => !1);
1263
+ if (t)
1264
+ for (let h of t.split(" ")) {
1265
+ let r = e.indexOf(h);
1266
+ r >= 0 && (s[r] = !0);
1267
+ }
1268
+ let i = null;
1269
+ for (let h = 0; h < e.length; h++)
1270
+ if (!s[h])
1271
+ for (let r = this.dialects[e[h]], n; (n = this.data[r++]) != 65535; )
1272
+ (i || (i = new Uint8Array(this.maxTerm + 1)))[n] = 1;
1273
+ return new Q(t, s, i);
1274
+ }
1275
+ /**
1276
+ Used by the output of the parser generator. Not available to
1277
+ user code. @hide
1278
+ */
1279
+ static deserialize(t) {
1280
+ return new w(t);
1281
+ }
1282
+ }
1283
+ function k(l, t) {
1284
+ return l[t] | l[t + 1] << 16;
1285
+ }
1286
+ function V(l) {
1287
+ let t = null;
1288
+ for (let e of l) {
1289
+ let s = e.p.stoppedAt;
1290
+ (e.pos == e.p.stream.end || s != null && e.pos > s) && e.p.parser.stateFlag(
1291
+ e.state,
1292
+ 2
1293
+ /* StateFlag.Accepting */
1294
+ ) && (!t || t.score < e.score) && (t = e);
1295
+ }
1296
+ return t;
1297
+ }
1298
+ function B(l) {
1299
+ if (l.external) {
1300
+ let t = l.extend ? 1 : 0;
1301
+ return (e, s) => l.external(e, s) << 1 | t;
1302
+ }
1303
+ return l.get;
1304
+ }
1305
+ export {
1306
+ Z as C,
1307
+ Y as E,
1308
+ w as L,
1309
+ H as a
1310
+ };