@marimo-team/islands 0.25.3-dev209 → 0.25.3-dev210

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 (140) hide show
  1. package/dist/{ConnectedDataExplorerComponent-ApTYh0V3.js → ConnectedDataExplorerComponent-D6RHJV8D.js} +114 -112
  2. package/dist/{ErrorBoundary-B1QlXN-y.js → ErrorBoundary-VruaQLnK.js} +10 -10
  3. package/dist/{abnfDiagram-VCTEODGH-uo9xhZY0.js → abnfDiagram-VCTEODGH-0q7Lbmii.js} +2 -2
  4. package/dist/{any-language-editor-BVFHDDQ3.js → any-language-editor-jGaR0EAo.js} +5 -5
  5. package/dist/{architectureDiagram-5GKGNRK7-Hz6eyeOD.js → architectureDiagram-5GKGNRK7-1PydKPmE.js} +1 -1
  6. package/dist/{button-BQRdqQi1.js → button-B6RjDKJx.js} +54 -51
  7. package/dist/{capabilities-C2QUNRXi.js → capabilities-CkVzWJEX.js} +1 -1
  8. package/dist/{chat-ui-BTA1I5i1.js → chat-ui-B5pH_aXk.js} +414 -413
  9. package/dist/{check-C9Mp9eCK.js → check-Z_vtI3OL.js} +1 -1
  10. package/dist/{chunk-IMKFNOWR-DBM2i23k.js → chunk-IMKFNOWR-DEzZZ1Zc.js} +1 -1
  11. package/dist/{chunk-SHT3W25Y-L8KQLLBy.js → chunk-SHT3W25Y-CuHj-hnn.js} +1 -1
  12. package/dist/{chunk-SVP7TREG-BOUJKJEP.js → chunk-SVP7TREG-BPiZK2bA.js} +1 -1
  13. package/dist/{chunk-TICWLB2K-DY3CzFjX.js → chunk-TICWLB2K-DF6XcIjM.js} +1 -1
  14. package/dist/{classDiagram-ZZMXUADV-s9iwW-q4.js → classDiagram-ZZMXUADV-CMdR-cP4.js} +2 -2
  15. package/dist/{classDiagram-v2-VYDZK3BY-2GI5CjGB.js → classDiagram-v2-VYDZK3BY-DRvc3_7Y.js} +2 -2
  16. package/dist/{code-visibility-CCGlDSq4.js → code-visibility-BdFhHfIC.js} +28 -28
  17. package/dist/{common-C1PmVtVW.js → common-Ce1SgsX1.js} +8034 -8027
  18. package/dist/{toDate-BZZ64K_m.js → config-DbjzjwxX.js} +98 -164
  19. package/dist/{copy-icon-De584pZ4.js → copy-icon-CG57cxwb.js} +3 -3
  20. package/dist/createReducer-DePYJ0F3.js +63 -0
  21. package/dist/{cynefinDiagram-5FMLGOSQ-DOxnhBK2.js → cynefinDiagram-5FMLGOSQ-BkBjEY9l.js} +1 -1
  22. package/dist/{dagre-GXQ25YYZ-D1AhEfpM.js → dagre-GXQ25YYZ-D-HEaW4I.js} +1 -1
  23. package/dist/{data-grid-overlay-editor-B3KXkZvo.js → data-grid-overlay-editor-Bps1p6jQ.js} +1 -1
  24. package/dist/{diagram-S7CK7UJ4-DV_GebF_.js → diagram-S7CK7UJ4-Bn-oF-rB.js} +1 -1
  25. package/dist/{diagram-UQ7AKVKN-6dNzGFfD.js → diagram-UQ7AKVKN-BpzzXWBj.js} +1 -1
  26. package/dist/{diagram-VX7I27RA-DUh9jsfi.js → diagram-VX7I27RA-COOtvfBP.js} +1 -1
  27. package/dist/{diagram-Z3DM3KII-Cug-qcQ8.js → diagram-Z3DM3KII-K5cXvbrl.js} +1 -1
  28. package/dist/{dialog-DVRfQuhD.js → dialog-DsZ49mmU.js} +26 -26
  29. package/dist/{dist-BJtmSgcE.js → dist-11T5wq3_.js} +41 -40
  30. package/dist/{dist-B1M0bGO3.js → dist-17ugwGZc.js} +59 -58
  31. package/dist/{dist-D7mrh5sO.js → dist-7cRjf--y.js} +135 -134
  32. package/dist/{dist-Ck_C32ye.js → dist-B8pkfkzc.js} +31 -30
  33. package/dist/{dist-Ba2VIn1K.js → dist-B9UoM_wq.js} +54 -53
  34. package/dist/{dist-KN80qWCP.js → dist-BGuMTs1i.js} +118 -117
  35. package/dist/{dist-T5rh6JvL.js → dist-BHW11fni.js} +18 -17
  36. package/dist/dist-BLY4m1Wi.js +850 -0
  37. package/dist/{dist-Bj4bmwUm.js → dist-BNlcVoxs.js} +31 -30
  38. package/dist/{dist-BA13RJj5.js → dist-BQYe5Bju.js} +47 -46
  39. package/dist/{dist-OUle2RT7.js → dist-BX1mn8na.js} +297 -297
  40. package/dist/{dist-CTi5FTiV.js → dist-Bh0PTKUW.js} +108 -107
  41. package/dist/{dist-D9Q3xjiP.js → dist-CKaXK92p.js} +56 -55
  42. package/dist/{dist-DYXM73-k.js → dist-CLhwfhpJ.js} +58 -57
  43. package/dist/{dist-BmS-ZGjl.js → dist-CYeqK4Xw.js} +1854 -2702
  44. package/dist/{dist-D1fnFp1J.js → dist-Cxlp3WH6.js} +16 -15
  45. package/dist/{dist-DVVwOfrD.js → dist-DSJPGj42.js} +64 -63
  46. package/dist/{dist-Bzogh7CW.js → dist-DU9ICsWZ.js} +93 -92
  47. package/dist/{dist-DjeybPOb.js → dist-DWv0ALBi.js} +47 -46
  48. package/dist/{dist-D3x9__Fu.js → dist-DiBpWEsB.js} +39 -38
  49. package/dist/{dist-DtGn9N4h.js → dist-DiLFTlnl.js} +165 -165
  50. package/dist/{dist-DTv9KkpW.js → dist-cVDV5IuI.js} +26 -25
  51. package/dist/{dist-DP60Ubh8.js → dist-fRfaOoq8.js} +44 -43
  52. package/dist/{dist-O0qFpEJh.js → dist-gTTI-9Px.js} +66 -65
  53. package/dist/{dropdown-menu-dlEm41Bt.js → dropdown-menu-CSNdPSnS.js} +2886 -1529
  54. package/dist/{ebnfDiagram-PWID7BFC-d5LKx7Vb.js → ebnfDiagram-PWID7BFC-BI1ZmjVm.js} +2 -2
  55. package/dist/{erDiagram-RLTQ6QDP-BwvlkcID.js → erDiagram-RLTQ6QDP-BtWjj9xy.js} +1 -1
  56. package/dist/{error-banner-DxJ3s8YO.js → error-banner-IsonnvA0.js} +47 -46
  57. package/dist/error-entries-CRPfxMqm.js +2505 -0
  58. package/dist/{esm-Bbw_Njjx.js → esm-BgKjMvWw.js} +389 -388
  59. package/dist/{esm-mDQNEFe_.js → esm-CHjVSexr.js} +305 -306
  60. package/dist/{feedback-button-UsovT9sL.js → feedback-button-2ycmR9GG.js} +112 -112
  61. package/dist/{flowDiagram-HODETNUW-CJcSoFer.js → flowDiagram-HODETNUW-DQvZh96A.js} +2 -2
  62. package/dist/{formats-Ry7c-aIV.js → formats-BK4VefeF.js} +6 -6
  63. package/dist/{glide-data-editor-CRd8kBSp.js → glide-data-editor-Buj2OZjL.js} +99 -99
  64. package/dist/{glide-utils-D98laidb.js → glide-utils-CQddGpa-.js} +3 -3
  65. package/dist/{globals-BDWrOstF.js → globals-B-14fUeb.js} +3 -3
  66. package/dist/{error-entries-CVUHA5r_.js → html-to-image-CgAnxFi8.js} +26314 -25474
  67. package/dist/{infoDiagram-27XIBGKW-Cezgppw3.js → infoDiagram-27XIBGKW-BdAObnc_.js} +1 -1
  68. package/dist/{ishikawaDiagram-5VMMS53U-BahZQwJz.js → ishikawaDiagram-5VMMS53U-DP-jE8dw.js} +1 -1
  69. package/dist/{kanban-definition-UXKFOSKX-Cvfn_Obm.js → kanban-definition-UXKFOSKX-BkMgPjfm.js} +1 -1
  70. package/dist/{loader-DOVB0Syl.js → loader-BisjOLiW.js} +1 -1
  71. package/dist/main.js +2996 -2992
  72. package/dist/{mermaid-BrdwbArF.js → mermaid-B-OFqheA.js} +36 -36
  73. package/dist/{mindmap-definition-YA3MSWOX-uB4B2d-J.js → mindmap-definition-YA3MSWOX-Du7toAZX.js} +1 -1
  74. package/dist/{number-overlay-editor-Bp9a4z5Q.js → number-overlay-editor-ZVFcJ7_u.js} +1 -1
  75. package/dist/{dist-CThPVKaP.js → objectWithoutPropertiesLoose-ai5NUqGa.js} +1139 -1120
  76. package/dist/{pegDiagram-XKGWAZYB-CYaIwAmH.js → pegDiagram-XKGWAZYB-CX_729j0.js} +2 -2
  77. package/dist/{pieDiagram-E7YTZNPT-BJ1oUxVv.js → pieDiagram-E7YTZNPT-dtTFJcVI.js} +1 -1
  78. package/dist/{process-output-SjJxB1wh.js → process-output-Bmev5azU.js} +5 -5
  79. package/dist/{railroadDiagram-O6MQD6OU-BqKSaBux.js → railroadDiagram-O6MQD6OU-Dsc2Cf4c.js} +2 -2
  80. package/dist/{requirementDiagram-BXWQKSXE-DwFhgDhH.js → requirementDiagram-BXWQKSXE-D3g0c60I.js} +1 -1
  81. package/dist/{reveal-component-ov3pS-oO.js → reveal-component-BWz1KjWe.js} +725 -725
  82. package/dist/schemas-CdscWNy_.js +4747 -0
  83. package/dist/select-BSxlITBo.js +1200 -0
  84. package/dist/{sequenceDiagram-WJ2MYXX4-L7ENjfKF.js → sequenceDiagram-WJ2MYXX4-w1pWbIpk.js} +1 -1
  85. package/dist/{spec-BcJ9ncAY.js → spec-Dq8RNplp.js} +4 -4
  86. package/dist/{stateDiagram-D77RDMKH-CVf88u-p.js → stateDiagram-D77RDMKH-BCv7kP4H.js} +2 -2
  87. package/dist/{stateDiagram-v2-MP3YSRHH-DvpkQ1V6.js → stateDiagram-v2-MP3YSRHH-D1cTOt0x.js} +2 -2
  88. package/dist/static-state-BldGd99T.js +72 -0
  89. package/dist/strings-BGW-fXVJ.js +507 -0
  90. package/dist/{swimlanes-42K2YHIH-DIuFHbVE.js → swimlanes-42K2YHIH-DNO6jDnd.js} +1 -1
  91. package/dist/{swimlanesDiagram-VR7AAH4N-CAqHAziW.js → swimlanesDiagram-VR7AAH4N-CkSWsxYJ.js} +2 -2
  92. package/dist/{swiper-component-BVfnhbnt.js → swiper-component-Dir1o8ml.js} +2 -2
  93. package/dist/{timeline-definition-24CTP7MA-xO4EQqBm.js → timeline-definition-24CTP7MA-DQvqGFM9.js} +1 -1
  94. package/dist/toast-BWIPi3aF.js +491 -0
  95. package/dist/{tooltip-s4zZxwKe.js → tooltip-C3UnvsRe.js} +58 -58
  96. package/dist/use-restore-focus-BWO0z1lo.js +1672 -0
  97. package/dist/{useAsyncData-Dqw22wZQ.js → useAsyncData-DsZMvNXn.js} +1 -1
  98. package/dist/{useDateFormatter-D3Tkfzej.js → useDateFormatter-ChB4eyim.js} +2 -2
  99. package/dist/{useDeepCompareMemoize-D3gozcjJ.js → useDeepCompareMemoize-KMBBux8C.js} +1 -1
  100. package/dist/{useIframeCapabilities-6a_yDNXp.js → useIframeCapabilities-cMNQ80CK.js} +1 -1
  101. package/dist/useLifecycle-BquH9ET-.js +112 -0
  102. package/dist/useTheme-B9C1JIy9.js +307 -0
  103. package/dist/utils-DXkj82sK.js +813 -0
  104. package/dist/{vega-component-Blvspl7v.js → vega-component-9NOEITbg.js} +55 -54
  105. package/dist/{vennDiagram-4TSXK5OY-DzCi-lRh.js → vennDiagram-4TSXK5OY-BfzXp4SH.js} +1 -1
  106. package/dist/{wardleyDiagram-VM6X3IG4-CW48xa0n.js → wardleyDiagram-VM6X3IG4-CiqEE8eq.js} +1 -1
  107. package/dist/{xychartDiagram-S5SC5T6Z-UPxGGI2B.js → xychartDiagram-S5SC5T6Z-BTIHCVOI.js} +1 -1
  108. package/package.json +1 -1
  109. package/src/components/editor/cell/__tests__/StagedAICell.test.tsx +1 -1
  110. package/src/components/editor/cell/code/cell-editor.tsx +13 -36
  111. package/src/components/editor/chrome/wrapper/__tests__/pending-ai-cells.test.tsx +1 -1
  112. package/src/components/editor/errors/__tests__/send-error-report-button.test.tsx +11 -5
  113. package/src/components/editor/notebook-cell.tsx +0 -1
  114. package/src/components/scratchpad/scratchpad.test.tsx +3 -11
  115. package/src/components/scratchpad/scratchpad.tsx +24 -22
  116. package/src/components/scratchpad/state.ts +7 -0
  117. package/src/core/ai/__tests__/staged-cells.test.ts +6 -8
  118. package/src/core/ai/staged-cells.ts +4 -2
  119. package/src/core/cells/__tests__/cells.test.ts +44 -60
  120. package/src/core/cells/__tests__/document.test.ts +1 -139
  121. package/src/core/cells/__tests__/notebook-outline.test.ts +8 -6
  122. package/src/core/cells/actions.ts +39 -0
  123. package/src/core/cells/cells.ts +15 -35
  124. package/src/core/cells/document.ts +9 -84
  125. package/src/core/codemirror/__tests__/format.test.ts +0 -34
  126. package/src/core/codemirror/cells/extensions.ts +20 -18
  127. package/src/core/codemirror/cells/state.ts +0 -5
  128. package/src/core/codemirror/format.ts +1 -19
  129. package/src/core/codemirror/misc/__tests__/paste.test.ts +3 -1
  130. package/src/core/codemirror/misc/paste.ts +1 -1
  131. package/src/core/notebook/document/__tests__/codemirror.test.ts +172 -0
  132. package/src/stories/layout/vertical/one-column.stories.tsx +26 -18
  133. package/dist/html-to-image--E3uFbJ9.js +0 -3348
  134. package/dist/label-Qvw1E97W.js +0 -281
  135. package/dist/objectWithoutPropertiesLoose-BRDcTsfB.js +0 -23
  136. package/dist/select-2KOiReNY.js +0 -1423
  137. package/dist/toast-B5t9o6s_.js +0 -1848
  138. package/dist/use-restore-focus-BgDTd2tc.js +0 -6418
  139. package/dist/useLifecycle-CaZi4wTw.js +0 -172
  140. package/dist/useTheme-TzPgWXwB.js +0 -1114
@@ -0,0 +1,850 @@
1
+ import { Bt as e, Ht as t, It as n, Lt as r, Rt as i, Ut as a, zt as o } from "./dist-CYeqK4Xw.js";
2
+ //#region ../node_modules/.pnpm/@lezer+lr@1.4.10/node_modules/@lezer/lr/dist/index.js
3
+ var s = class e {
4
+ constructor(e, t, n, r, i, a, o, s, c, l = 0, u) {
5
+ this.p = e, this.stack = t, this.state = n, this.reducePos = r, this.pos = i, this.score = a, this.buffer = o, this.bufferBase = s, this.curContext = c, this.lookAhead = l, this.parent = u;
6
+ }
7
+ toString() {
8
+ return `[${this.stack.filter((e, t) => t % 3 == 0).concat(this.state)}]@${this.pos}${this.score ? "!" + this.score : ""}`;
9
+ }
10
+ static start(t, n, r = 0) {
11
+ let i = t.parser.context;
12
+ return new e(t, [], n, r, r, 0, [], 0, i ? new c(i, i.start) : null, 0, null);
13
+ }
14
+ get context() {
15
+ return this.curContext ? this.curContext.context : null;
16
+ }
17
+ pushState(e, t) {
18
+ this.stack.push(this.state, t, this.bufferBase + this.buffer.length), this.state = e;
19
+ }
20
+ reduce(e) {
21
+ let t = e >> 19, n = e & 65535, { parser: r } = this.p, i = this.reducePos < this.pos - 25 && this.setLookAhead(this.pos), a = r.dynamicPrecedence(n);
22
+ if (a && (this.score += a), t == 0) {
23
+ n < r.minRepeatTerm && this.reducePos < this.pos && (this.reducePos = this.pos), this.pushState(r.getGoto(this.state, n, !0), this.reducePos), n < r.minRepeatTerm && this.storeNode(n, this.reducePos, this.reducePos, i ? 8 : 4, !0), this.reduceContext(n, this.reducePos);
24
+ return;
25
+ }
26
+ let o = this.stack.length - (t - 1) * 3 - (e & 262144 ? 6 : 0), s = o ? this.stack[o - 2] : this.p.ranges[0].from;
27
+ n < r.minRepeatTerm && s == this.reducePos && this.reducePos < this.pos && (this.reducePos = this.pos);
28
+ let c = this.reducePos - s;
29
+ c >= 2e3 && !this.p.parser.nodeSet.types[n]?.isAnonymous && (s == this.p.lastBigReductionStart ? (this.p.bigReductionCount++, this.p.lastBigReductionSize = c) : this.p.lastBigReductionSize < c && (this.p.bigReductionCount = 1, this.p.lastBigReductionStart = s, this.p.lastBigReductionSize = c));
30
+ let l = o ? this.stack[o - 1] : 0, u = this.bufferBase + this.buffer.length - l;
31
+ if (n < r.minRepeatTerm || e & 131072) {
32
+ let e = r.stateFlag(this.state, 1) ? this.pos : this.reducePos;
33
+ this.storeNode(n, s, e, u + 4, !0);
34
+ }
35
+ if (e & 262144) this.state = this.stack[o];
36
+ else {
37
+ let e = this.stack[o - 3];
38
+ this.state = r.getGoto(e, n, !0);
39
+ }
40
+ for (; this.stack.length > o;) this.stack.pop();
41
+ this.reduceContext(n, s);
42
+ }
43
+ storeNode(e, t, n, r = 4, i = !1) {
44
+ if (e == 0 && (!this.stack.length || this.stack[this.stack.length - 1] < this.buffer.length + this.bufferBase)) {
45
+ let e = this.buffer.length;
46
+ if (e > 0 && this.buffer[e - 4] == 0 && this.buffer[e - 1] > -1) {
47
+ if (t == n) return;
48
+ if (this.buffer[e - 2] >= t) {
49
+ this.buffer[e - 2] = n;
50
+ return;
51
+ }
52
+ }
53
+ }
54
+ if (!i || this.pos == n) this.buffer.push(e, t, n, r);
55
+ else {
56
+ let i = this.buffer.length;
57
+ if (i > 0 && (this.buffer[i - 4] != 0 || this.buffer[i - 1] < 0)) {
58
+ let e = !1;
59
+ for (let t = i; t > 0 && this.buffer[t - 2] > n; t -= 4) if (this.buffer[t - 1] >= 0) {
60
+ e = !0;
61
+ break;
62
+ }
63
+ if (e) for (; i > 0 && this.buffer[i - 2] > n;) this.buffer[i] = this.buffer[i - 4], this.buffer[i + 1] = this.buffer[i - 3], this.buffer[i + 2] = this.buffer[i - 2], this.buffer[i + 3] = this.buffer[i - 1], i -= 4, r > 4 && (r -= 4);
64
+ }
65
+ this.buffer[i] = e, this.buffer[i + 1] = t, this.buffer[i + 2] = n, this.buffer[i + 3] = r;
66
+ }
67
+ }
68
+ shift(e, t, n, r) {
69
+ if (e & 131072) this.pushState(e & 65535, this.pos);
70
+ else if (e & 262144) this.pos = r, this.shiftContext(t, n), t <= this.p.parser.maxNode && this.buffer.push(t, n, r, 4);
71
+ else {
72
+ let i = e, { parser: a } = this.p;
73
+ this.pos = r;
74
+ let o = a.stateFlag(i, 1);
75
+ !o && (r > n || t <= a.maxNode) && (this.reducePos = r), this.pushState(i, o ? n : Math.min(n, this.reducePos)), this.shiftContext(t, n), t <= a.maxNode && this.buffer.push(t, n, r, 4);
76
+ }
77
+ }
78
+ apply(e, t, n, r) {
79
+ e & 65536 ? this.reduce(e) : this.shift(e, t, n, r);
80
+ }
81
+ useNode(e, t) {
82
+ let n = this.p.reused.length - 1;
83
+ (n < 0 || this.p.reused[n] != e) && (this.p.reused.push(e), n++);
84
+ let r = this.pos;
85
+ this.reducePos = this.pos = r + e.length, this.pushState(t, r), this.buffer.push(n, r, this.reducePos, -1), this.curContext && this.updateContext(this.curContext.tracker.reuse(this.curContext.context, e, this, this.p.stream.reset(this.pos - e.length)));
86
+ }
87
+ split() {
88
+ let t = this, n = t.buffer.length;
89
+ for (n && t.buffer[n - 4] == 0 && (n -= 4); n > 0 && t.buffer[n - 2] > t.reducePos;) n -= 4;
90
+ let r = t.buffer.slice(n), i = t.bufferBase + n;
91
+ for (; t && i == t.bufferBase;) t = t.parent;
92
+ return new e(this.p, this.stack.slice(), this.state, this.reducePos, this.pos, this.score, r, i, this.curContext, this.lookAhead, t);
93
+ }
94
+ recoverByDelete(e, t) {
95
+ let n = e <= this.p.parser.maxNode;
96
+ n && this.storeNode(e, this.pos, t, 4), this.storeNode(0, this.pos, t, n ? 8 : 4), this.pos = this.reducePos = t, this.score -= 190;
97
+ }
98
+ canShift(e) {
99
+ for (let t = new l(this);;) {
100
+ let n = this.p.parser.stateSlot(t.state, 4) || this.p.parser.hasAction(t.state, e);
101
+ if (n == 0) return !1;
102
+ if (!(n & 65536)) return !0;
103
+ t.reduce(n);
104
+ }
105
+ }
106
+ recoverByInsert(e) {
107
+ if (this.stack.length >= 300) return [];
108
+ let t = this.p.parser.nextStates(this.state);
109
+ if (t.length > 8 || this.stack.length >= 120) {
110
+ let n = [];
111
+ for (let r = 0, i; r < t.length; r += 2) (i = t[r + 1]) != this.state && this.p.parser.hasAction(i, e) && n.push(t[r], i);
112
+ if (this.stack.length < 120) for (let e = 0; n.length < 8 && e < t.length; e += 2) {
113
+ let r = t[e + 1];
114
+ n.some((e, t) => t & 1 && e == r) || n.push(t[e], r);
115
+ }
116
+ t = n;
117
+ }
118
+ let n = [];
119
+ for (let e = 0; e < t.length && n.length < 4; e += 2) {
120
+ let r = t[e + 1];
121
+ if (r == this.state) continue;
122
+ let i = this.split();
123
+ i.pushState(r, this.pos), i.storeNode(0, i.pos, i.pos, 4, !0), i.shiftContext(t[e], this.pos), i.reducePos = this.pos, i.score -= 200, n.push(i);
124
+ }
125
+ return n;
126
+ }
127
+ forceReduce() {
128
+ let { parser: e } = this.p, t = e.stateSlot(this.state, 5);
129
+ if (!(t & 65536)) return !1;
130
+ if (!e.validAction(this.state, t)) {
131
+ let n = t >> 19, r = t & 65535, i = this.stack.length - n * 3;
132
+ if (i < 0 || e.getGoto(this.stack[i], r, !1) < 0) {
133
+ let e = this.findForcedReduction();
134
+ if (e == null) return !1;
135
+ t = e;
136
+ }
137
+ this.storeNode(0, this.pos, this.pos, 4, !0), this.score -= 100;
138
+ }
139
+ return this.reducePos = this.pos, this.reduce(t), !0;
140
+ }
141
+ findForcedReduction() {
142
+ let { parser: e } = this.p, t = [], n = (r, i) => {
143
+ if (!t.includes(r)) return t.push(r), e.allActions(r, (t) => {
144
+ if (!(t & 393216)) {
145
+ if (t & 65536) {
146
+ let n = (t >> 19) - i;
147
+ if (n > 1) {
148
+ let r = t & 65535, i = this.stack.length - n * 3;
149
+ if (i >= 0 && e.getGoto(this.stack[i], r, !1) >= 0) return n << 19 | 65536 | r;
150
+ }
151
+ } else {
152
+ let e = n(t, i + 1);
153
+ if (e != null) return e;
154
+ }
155
+ }
156
+ });
157
+ };
158
+ return n(this.state, 0);
159
+ }
160
+ forceAll() {
161
+ for (; !this.p.parser.stateFlag(this.state, 2);) if (!this.forceReduce()) {
162
+ this.storeNode(0, this.pos, this.pos, 4, !0);
163
+ break;
164
+ }
165
+ return this;
166
+ }
167
+ get deadEnd() {
168
+ if (this.stack.length != 3) return !1;
169
+ let { parser: e } = this.p;
170
+ return e.data[e.stateSlot(this.state, 1)] == 65535 && !e.stateSlot(this.state, 4);
171
+ }
172
+ restart() {
173
+ this.storeNode(0, this.pos, this.pos, 4, !0), this.state = this.stack[0], this.stack.length = 0;
174
+ }
175
+ sameState(e) {
176
+ if (this.state != e.state || this.stack.length != e.stack.length) return !1;
177
+ for (let t = 0; t < this.stack.length; t += 3) if (this.stack[t] != e.stack[t]) return !1;
178
+ return !0;
179
+ }
180
+ get parser() {
181
+ return this.p.parser;
182
+ }
183
+ dialectEnabled(e) {
184
+ return this.p.parser.dialect.flags[e];
185
+ }
186
+ shiftContext(e, t) {
187
+ this.curContext && this.updateContext(this.curContext.tracker.shift(this.curContext.context, e, this, this.p.stream.reset(t)));
188
+ }
189
+ reduceContext(e, t) {
190
+ this.curContext && this.updateContext(this.curContext.tracker.reduce(this.curContext.context, e, this, this.p.stream.reset(t)));
191
+ }
192
+ emitContext() {
193
+ let e = this.buffer.length - 1;
194
+ (e < 0 || this.buffer[e] != -3) && this.buffer.push(this.curContext.hash, this.pos, this.pos, -3);
195
+ }
196
+ emitLookAhead() {
197
+ let e = this.buffer.length - 1;
198
+ (e < 0 || this.buffer[e] != -4) && this.buffer.push(this.lookAhead, this.pos, this.pos, -4);
199
+ }
200
+ updateContext(e) {
201
+ if (e != this.curContext.context) {
202
+ let t = new c(this.curContext.tracker, e);
203
+ t.hash != this.curContext.hash && this.emitContext(), this.curContext = t;
204
+ }
205
+ }
206
+ setLookAhead(e) {
207
+ return e <= this.lookAhead ? !1 : (this.emitLookAhead(), this.lookAhead = e, !0);
208
+ }
209
+ close() {
210
+ this.curContext && this.curContext.tracker.strict && this.emitContext(), this.lookAhead > 0 && this.emitLookAhead();
211
+ }
212
+ }, c = class {
213
+ constructor(e, t) {
214
+ this.tracker = e, this.context = t, this.hash = e.strict ? e.hash(t) : 0;
215
+ }
216
+ }, l = class {
217
+ constructor(e) {
218
+ this.start = e, this.state = e.state, this.stack = e.stack, this.base = this.stack.length;
219
+ }
220
+ reduce(e) {
221
+ let t = e & 65535, n = e >> 19;
222
+ n == 0 ? (this.stack == this.start.stack && (this.stack = this.stack.slice()), this.stack.push(this.state, 0, 0), this.base += 3) : this.base -= (n - 1) * 3;
223
+ let r = this.start.p.parser.getGoto(this.stack[this.base - 3], t, !0);
224
+ this.state = r;
225
+ }
226
+ }, u = class e {
227
+ constructor(e, t, n) {
228
+ this.stack = e, this.pos = t, this.index = n, this.buffer = e.buffer, this.index == 0 && this.maybeNext();
229
+ }
230
+ static create(t, n = t.bufferBase + t.buffer.length) {
231
+ return new e(t, n, n - t.bufferBase);
232
+ }
233
+ maybeNext() {
234
+ let e = this.stack.parent;
235
+ e != null && (this.index = this.stack.bufferBase - e.bufferBase, this.stack = e, this.buffer = e.buffer);
236
+ }
237
+ get id() {
238
+ return this.buffer[this.index - 4];
239
+ }
240
+ get start() {
241
+ return this.buffer[this.index - 3];
242
+ }
243
+ get end() {
244
+ return this.buffer[this.index - 2];
245
+ }
246
+ get size() {
247
+ return this.buffer[this.index - 1];
248
+ }
249
+ next() {
250
+ this.index -= 4, this.pos -= 4, this.index == 0 && this.maybeNext();
251
+ }
252
+ fork() {
253
+ return new e(this.stack, this.pos, this.index);
254
+ }
255
+ };
256
+ function d(e, t = Uint16Array) {
257
+ if (typeof e != "string") return e;
258
+ let n = null;
259
+ for (let r = 0, i = 0; r < e.length;) {
260
+ let a = 0;
261
+ for (;;) {
262
+ let t = e.charCodeAt(r++), n = !1;
263
+ if (t == 126) {
264
+ a = 65535;
265
+ break;
266
+ }
267
+ t >= 92 && t--, t >= 34 && t--;
268
+ let i = t - 32;
269
+ if (i >= 46 && (i -= 46, n = !0), a += i, n) break;
270
+ a *= 46;
271
+ }
272
+ n ? n[i++] = a : n = new t(a);
273
+ }
274
+ return n;
275
+ }
276
+ var f = class {
277
+ constructor() {
278
+ this.start = -1, this.value = -1, this.end = -1, this.extended = -1, this.lookAhead = 0, this.mask = 0, this.context = 0;
279
+ }
280
+ }, p = new f(), m = class {
281
+ constructor(e, t) {
282
+ this.input = e, this.ranges = t, this.chunk = "", this.chunkOff = 0, this.chunk2 = "", this.chunk2Pos = 0, this.next = -1, this.token = p, this.rangeIndex = 0, this.pos = this.chunkPos = t[0].from, this.range = t[0], this.end = t[t.length - 1].to, this.readNext();
283
+ }
284
+ resolveOffset(e, t) {
285
+ let n = this.range, r = this.rangeIndex, i = this.pos + e;
286
+ for (; i < n.from;) {
287
+ if (!r) return null;
288
+ let e = this.ranges[--r];
289
+ i -= n.from - e.to, n = e;
290
+ }
291
+ for (; t < 0 ? i > n.to : i >= n.to;) {
292
+ if (r == this.ranges.length - 1) return null;
293
+ let e = this.ranges[++r];
294
+ i += e.from - n.to, n = e;
295
+ }
296
+ return i;
297
+ }
298
+ clipPos(e) {
299
+ if (e >= this.range.from && e < this.range.to) return e;
300
+ for (let t of this.ranges) if (t.to > e) return Math.max(e, t.from);
301
+ return this.end;
302
+ }
303
+ peek(e) {
304
+ let t = this.chunkOff + e, n, r;
305
+ if (t >= 0 && t < this.chunk.length) n = this.pos + e, r = this.chunk.charCodeAt(t);
306
+ else {
307
+ let t = this.resolveOffset(e, 1);
308
+ if (t == null) return -1;
309
+ if (n = t, n >= this.chunk2Pos && n < this.chunk2Pos + this.chunk2.length) r = this.chunk2.charCodeAt(n - this.chunk2Pos);
310
+ else {
311
+ let e = this.rangeIndex, t = this.range;
312
+ for (; t.to <= n;) t = this.ranges[++e];
313
+ this.chunk2 = this.input.chunk(this.chunk2Pos = n), n + this.chunk2.length > t.to && (this.chunk2 = this.chunk2.slice(0, t.to - n)), r = this.chunk2.charCodeAt(0);
314
+ }
315
+ }
316
+ return n >= this.token.lookAhead && (this.token.lookAhead = n + 1), r;
317
+ }
318
+ acceptToken(e, t = 0) {
319
+ let n = t ? this.resolveOffset(t, -1) : this.pos;
320
+ if (n == null || n < this.token.start) throw RangeError("Token end out of bounds");
321
+ this.token.value = e, this.token.end = n;
322
+ }
323
+ acceptTokenTo(e, t) {
324
+ this.token.value = e, this.token.end = t;
325
+ }
326
+ getChunk() {
327
+ if (this.pos >= this.chunk2Pos && this.pos < this.chunk2Pos + this.chunk2.length) {
328
+ let { chunk: e, chunkPos: t } = this;
329
+ this.chunk = this.chunk2, this.chunkPos = this.chunk2Pos, this.chunk2 = e, this.chunk2Pos = t, this.chunkOff = this.pos - this.chunkPos;
330
+ } else {
331
+ this.chunk2 = this.chunk, this.chunk2Pos = this.chunkPos;
332
+ let e = this.input.chunk(this.pos), t = this.pos + e.length;
333
+ this.chunk = t > this.range.to ? e.slice(0, this.range.to - this.pos) : e, this.chunkPos = this.pos, this.chunkOff = 0;
334
+ }
335
+ }
336
+ readNext() {
337
+ return this.next = this.chunkOff >= this.chunk.length && (this.getChunk(), this.chunkOff == this.chunk.length) ? -1 : this.chunk.charCodeAt(this.chunkOff);
338
+ }
339
+ advance(e = 1) {
340
+ for (this.chunkOff += e; this.pos + e >= this.range.to;) {
341
+ if (this.rangeIndex == this.ranges.length - 1) return this.setDone();
342
+ e -= this.range.to - this.pos, this.range = this.ranges[++this.rangeIndex], this.pos = this.range.from;
343
+ }
344
+ return this.pos += e, this.pos >= this.token.lookAhead && (this.token.lookAhead = this.pos + 1), this.readNext();
345
+ }
346
+ setDone() {
347
+ return this.pos = this.chunkPos = this.end, this.range = this.ranges[this.rangeIndex = this.ranges.length - 1], this.chunk = "", this.next = -1;
348
+ }
349
+ reset(e, t) {
350
+ if (t ? (this.token = t, t.start = e, t.lookAhead = e + 1, t.value = t.extended = -1) : this.token = p, this.pos != e) {
351
+ if (this.pos = e, e == this.end) return this.setDone(), this;
352
+ for (; e < this.range.from;) this.range = this.ranges[--this.rangeIndex];
353
+ for (; e >= this.range.to;) this.range = this.ranges[++this.rangeIndex];
354
+ e >= this.chunkPos && e < this.chunkPos + this.chunk.length ? this.chunkOff = e - this.chunkPos : (this.chunk = "", this.chunkOff = 0), this.readNext();
355
+ }
356
+ return this;
357
+ }
358
+ read(e, t) {
359
+ if (e >= this.chunkPos && t <= this.chunkPos + this.chunk.length) return this.chunk.slice(e - this.chunkPos, t - this.chunkPos);
360
+ if (e >= this.chunk2Pos && t <= this.chunk2Pos + this.chunk2.length) return this.chunk2.slice(e - this.chunk2Pos, t - this.chunk2Pos);
361
+ if (e >= this.range.from && t <= this.range.to) return this.input.read(e, t);
362
+ let n = "";
363
+ for (let r of this.ranges) {
364
+ if (r.from >= t) break;
365
+ r.to > e && (n += this.input.read(Math.max(r.from, e), Math.min(r.to, t)));
366
+ }
367
+ return n;
368
+ }
369
+ }, h = class {
370
+ constructor(e, t) {
371
+ this.data = e, this.id = t;
372
+ }
373
+ token(e, t) {
374
+ let { parser: n } = t.p;
375
+ v(this.data, e, t, this.id, n.data, n.tokenPrecTable);
376
+ }
377
+ };
378
+ h.prototype.contextual = h.prototype.fallback = h.prototype.extend = !1;
379
+ var g = class {
380
+ constructor(e, t, n) {
381
+ this.precTable = t, this.elseToken = n, this.data = typeof e == "string" ? d(e) : e;
382
+ }
383
+ token(e, t) {
384
+ let n = e.pos, r = 0;
385
+ for (;;) {
386
+ let n = e.next < 0, i = e.resolveOffset(1, 1);
387
+ if (v(this.data, e, t, 0, this.data, this.precTable), e.token.value > -1) break;
388
+ if (this.elseToken == null) return;
389
+ if (n || r++, i == null) break;
390
+ e.reset(i, e.token);
391
+ }
392
+ r && (e.reset(n, e.token), e.acceptToken(this.elseToken, r));
393
+ }
394
+ };
395
+ g.prototype.contextual = h.prototype.fallback = h.prototype.extend = !1;
396
+ var _ = class {
397
+ constructor(e, t = {}) {
398
+ this.token = e, this.contextual = !!t.contextual, this.fallback = !!t.fallback, this.extend = !!t.extend;
399
+ }
400
+ };
401
+ function v(e, t, n, r, i, a) {
402
+ let o = 0, s = 1 << r, { dialect: c } = n.p.parser;
403
+ scan: for (; (s & e[o]) != 0;) {
404
+ let n = e[o + 1];
405
+ for (let r = o + 3; r < n; r += 2) if ((e[r + 1] & s) > 0) {
406
+ let n = e[r];
407
+ if (c.allows(n) && (t.token.value == -1 || t.token.value == n || b(n, t.token.value, i, a))) {
408
+ t.acceptToken(n);
409
+ break;
410
+ }
411
+ }
412
+ let r = t.next, l = 0, u = e[o + 2];
413
+ if (t.next < 0 && u > l && e[n + u * 3 - 3] == 65535) {
414
+ o = e[n + u * 3 - 1];
415
+ continue scan;
416
+ }
417
+ for (; l < u;) {
418
+ let i = l + u >> 1, a = n + i + (i << 1), s = e[a], c = e[a + 1] || 65536;
419
+ if (r < s) u = i;
420
+ else if (r >= c) l = i + 1;
421
+ else {
422
+ o = e[a + 2], t.advance();
423
+ continue scan;
424
+ }
425
+ }
426
+ break;
427
+ }
428
+ }
429
+ function y(e, t, n) {
430
+ for (let r = t, i; (i = e[r]) != 65535; r++) if (i == n) return r - t;
431
+ return -1;
432
+ }
433
+ function b(e, t, n, r) {
434
+ let i = y(n, r, t);
435
+ return i < 0 || y(n, r, e) < i;
436
+ }
437
+ var x = typeof process < "u" && process.env && /\bparse\b/.test(""), S = null;
438
+ function C(e, t, n) {
439
+ let i = e.cursor(r.IncludeAnonymous);
440
+ for (i.moveTo(t);;) if (!(n < 0 ? i.childBefore(t) : i.childAfter(t))) for (;;) {
441
+ if ((n < 0 ? i.to < t : i.from > t) && !i.type.isError) return n < 0 ? Math.max(0, Math.min(i.to - 1, t - 25)) : Math.min(e.length, Math.max(i.from + 1, t + 25));
442
+ if (n < 0 ? i.prevSibling() : i.nextSibling()) break;
443
+ if (!i.parent()) return n < 0 ? 0 : e.length;
444
+ }
445
+ }
446
+ var w = class {
447
+ constructor(e, t) {
448
+ this.fragments = e, this.nodeSet = t, this.i = 0, this.fragment = null, this.safeFrom = -1, this.safeTo = -1, this.trees = [], this.start = [], this.index = [], this.nextFragment();
449
+ }
450
+ nextFragment() {
451
+ let e = this.fragment = this.i == this.fragments.length ? null : this.fragments[this.i++];
452
+ if (e) {
453
+ for (this.safeFrom = e.openStart ? C(e.tree, e.from + e.offset, 1) - e.offset : e.from, this.safeTo = e.openEnd ? C(e.tree, e.to + e.offset, -1) - e.offset : e.to; this.trees.length;) this.trees.pop(), this.start.pop(), this.index.pop();
454
+ this.trees.push(e.tree), this.start.push(-e.offset), this.index.push(0), this.nextStart = this.safeFrom;
455
+ } else this.nextStart = 1e9;
456
+ }
457
+ nodeAt(e) {
458
+ if (e < this.nextStart) return null;
459
+ for (; this.fragment && this.safeTo <= e;) this.nextFragment();
460
+ if (!this.fragment) return null;
461
+ for (;;) {
462
+ let t = this.trees.length - 1;
463
+ if (t < 0) return this.nextFragment(), null;
464
+ let n = this.trees[t], r = this.index[t];
465
+ if (r == n.children.length) {
466
+ this.trees.pop(), this.start.pop(), this.index.pop();
467
+ continue;
468
+ }
469
+ let o = n.children[r], s = this.start[t] + n.positions[r];
470
+ if (s > e) return this.nextStart = s, null;
471
+ if (o instanceof a) {
472
+ if (s == e) {
473
+ if (s < this.safeFrom) return null;
474
+ let e = s + o.length;
475
+ if (e <= this.safeTo) {
476
+ let t = o.prop(i.lookAhead);
477
+ if (!t || e + t < this.fragment.to) return o;
478
+ }
479
+ }
480
+ this.index[t]++, s + o.length >= Math.max(this.safeFrom, e) && (this.trees.push(o), this.start.push(s), this.index.push(0));
481
+ } else this.index[t]++, this.nextStart = s + o.length;
482
+ }
483
+ }
484
+ }, T = class {
485
+ constructor(e, t) {
486
+ this.stream = t, this.tokens = [], this.mainToken = null, this.actions = [], this.tokens = e.tokenizers.map((e) => new f());
487
+ }
488
+ getActions(e) {
489
+ let t = 0, n = null, { parser: r } = e.p, { tokenizers: i } = r, a = r.stateSlot(e.state, 3), o = e.curContext ? e.curContext.hash : 0, s = 0;
490
+ for (let r = 0; r < i.length; r++) {
491
+ if (!(1 << r & a)) continue;
492
+ let c = i[r], l = this.tokens[r];
493
+ if (!(n && !c.fallback) && ((c.contextual || l.start != e.pos || l.mask != a || l.context != o) && (this.updateCachedToken(l, c, e), l.mask = a, l.context = o), l.lookAhead > l.end + 25 && (s = Math.max(l.lookAhead, s)), l.value != 0)) {
494
+ let r = t;
495
+ if (l.extended > -1 && (t = this.addActions(e, l.extended, l.end, t)), t = this.addActions(e, l.value, l.end, t), !c.extend && (n = l, t > r)) break;
496
+ }
497
+ }
498
+ for (; this.actions.length > t;) this.actions.pop();
499
+ return s && e.setLookAhead(s), !n && e.pos == this.stream.end && (n = new f(), n.value = e.p.parser.eofTerm, n.start = n.end = e.pos, t = this.addActions(e, n.value, n.end, t)), this.mainToken = n, this.actions;
500
+ }
501
+ getMainToken(e) {
502
+ if (this.mainToken) return this.mainToken;
503
+ let t = new f(), { pos: n, p: r } = e;
504
+ return t.start = n, t.end = Math.min(n + 1, r.stream.end), t.value = n == r.stream.end ? r.parser.eofTerm : 0, t;
505
+ }
506
+ updateCachedToken(e, t, n) {
507
+ let r = this.stream.clipPos(n.pos);
508
+ if (t.token(this.stream.reset(r, e), n), e.value > -1) {
509
+ let { parser: t } = n.p;
510
+ for (let r = 0; r < t.specialized.length; r++) if (t.specialized[r] == e.value) {
511
+ let i = t.specializers[r](this.stream.read(e.start, e.end), n);
512
+ if (i >= 0 && n.p.parser.dialect.allows(i >> 1)) {
513
+ i & 1 ? e.extended = i >> 1 : e.value = i >> 1;
514
+ break;
515
+ }
516
+ }
517
+ } else e.value = 0, e.end = this.stream.clipPos(r + 1);
518
+ }
519
+ putAction(e, t, n, r) {
520
+ for (let t = 0; t < r; t += 3) if (this.actions[t] == e) return r;
521
+ return this.actions[r++] = e, this.actions[r++] = t, this.actions[r++] = n, r;
522
+ }
523
+ addActions(e, t, n, r) {
524
+ let { state: i } = e, { parser: a } = e.p, { data: o } = a;
525
+ for (let e = 0; e < 2; e++) for (let s = a.stateSlot(i, e ? 2 : 1);; s += 3) {
526
+ if (o[s] == 65535) {
527
+ if (o[s + 1] == 1) s = M(o, s + 2);
528
+ else {
529
+ r == 0 && o[s + 1] == 2 && (r = this.putAction(M(o, s + 2), t, n, r));
530
+ break;
531
+ }
532
+ }
533
+ o[s] == t && (r = this.putAction(M(o, s + 1), t, n, r));
534
+ }
535
+ return r;
536
+ }
537
+ }, E = class {
538
+ constructor(e, t, n, r) {
539
+ this.parser = e, this.input = t, this.ranges = r, 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 m(t, r), this.tokens = new T(e, this.stream), this.topTerm = e.top[1];
540
+ let { from: i } = r[0];
541
+ this.stacks = [s.start(this, e.top[0], i)], this.fragments = n.length && this.stream.end - i > e.bufferLength * 4 ? new w(n, e.nodeSet) : null;
542
+ }
543
+ get parsedPos() {
544
+ return this.minStackPos;
545
+ }
546
+ advance() {
547
+ let e = this.stacks, t = this.minStackPos, n = this.stacks = [], r, i;
548
+ if (this.bigReductionCount > 300 && e.length == 1) {
549
+ let [t] = e;
550
+ for (; t.forceReduce() && t.stack.length && t.stack[t.stack.length - 2] >= this.lastBigReductionStart;);
551
+ this.bigReductionCount = this.lastBigReductionSize = 0;
552
+ }
553
+ for (let a = 0; a < e.length; a++) {
554
+ let o = e[a];
555
+ for (;;) {
556
+ if (this.tokens.mainToken = null, o.pos > t) n.push(o);
557
+ else if (this.advanceStack(o, n, e)) continue;
558
+ else {
559
+ r || (r = [], i = []), r.push(o);
560
+ let e = this.tokens.getMainToken(o);
561
+ i.push(e.value, e.end);
562
+ }
563
+ break;
564
+ }
565
+ }
566
+ if (!n.length) {
567
+ let e = r && N(r);
568
+ if (e) return x && console.log("Finish with " + this.stackID(e)), this.stackToTree(e);
569
+ if (this.parser.strict) throw x && r && console.log("Stuck with token " + (this.tokens.mainToken ? this.parser.getName(this.tokens.mainToken.value) : "none")), SyntaxError("No parse at " + t);
570
+ this.recovering ||= 5;
571
+ }
572
+ if (this.recovering && r) {
573
+ let e = this.stoppedAt != null && r[0].pos > this.stoppedAt ? r[0] : this.runRecovery(r, i, n);
574
+ if (e) return x && console.log("Force-finish " + this.stackID(e)), this.stackToTree(e.forceAll());
575
+ }
576
+ if (this.recovering) {
577
+ let e = this.recovering == 1 ? 1 : this.recovering * 3;
578
+ if (n.length > e) for (n.sort((e, t) => t.score - e.score); n.length > e;) n.pop();
579
+ n.some((e) => e.reducePos > t) && this.recovering--;
580
+ } else if (n.length > 1) {
581
+ outer: for (let e = 0; e < n.length - 1; e++) {
582
+ let t = n[e];
583
+ for (let r = e + 1; r < n.length; r++) {
584
+ let i = n[r];
585
+ if (t.sameState(i) || t.buffer.length > 500 && i.buffer.length > 500) {
586
+ if ((t.score - i.score || t.buffer.length - i.buffer.length) > 0) n.splice(r--, 1);
587
+ else {
588
+ n.splice(e--, 1);
589
+ continue outer;
590
+ }
591
+ }
592
+ }
593
+ }
594
+ n.length > 12 && (n.sort((e, t) => t.score - e.score), n.splice(12, n.length - 12));
595
+ }
596
+ this.minStackPos = n[0].pos;
597
+ for (let e = 1; e < n.length; e++) n[e].pos < this.minStackPos && (this.minStackPos = n[e].pos);
598
+ return null;
599
+ }
600
+ stopAt(e) {
601
+ if (this.stoppedAt != null && this.stoppedAt < e) throw RangeError("Can't move stoppedAt forward");
602
+ this.stoppedAt = e;
603
+ }
604
+ advanceStack(e, t, n) {
605
+ let r = e.pos, { parser: o } = this, s = x ? this.stackID(e) + " -> " : "";
606
+ if (this.stoppedAt != null && r > this.stoppedAt) return e.forceReduce() ? e : null;
607
+ if (this.fragments) {
608
+ let t = e.curContext && e.curContext.tracker.strict, n = t ? e.curContext.hash : 0;
609
+ for (let c = this.fragments.nodeAt(r); c;) {
610
+ let r = this.parser.nodeSet.types[c.type.id] == c.type ? o.getGoto(e.state, c.type.id) : -1;
611
+ if (r > -1 && c.length && (!t || (c.prop(i.contextHash) || 0) == n)) return e.useNode(c, r), x && console.log(s + this.stackID(e) + ` (via reuse of ${o.getName(c.type.id)})`), !0;
612
+ if (!(c instanceof a) || c.children.length == 0 || c.positions[0] > 0) break;
613
+ let l = c.children[0];
614
+ if (l instanceof a && c.positions[0] == 0) c = l;
615
+ else break;
616
+ }
617
+ }
618
+ let c = o.stateSlot(e.state, 4);
619
+ if (c > 0) return e.reduce(c), x && console.log(s + this.stackID(e) + ` (via always-reduce ${o.getName(c & 65535)})`), !0;
620
+ if (e.stack.length >= 8400) for (; e.stack.length > 6e3 && e.forceReduce(););
621
+ let l = this.tokens.getActions(e);
622
+ for (let i = 0; i < l.length;) {
623
+ let a = l[i++], c = l[i++], u = l[i++], d = i == l.length || !n, f = d ? e : e.split(), p = this.tokens.mainToken;
624
+ if (f.apply(a, c, p ? p.start : f.pos, u), x && console.log(s + this.stackID(f) + ` (via ${a & 65536 ? `reduce of ${o.getName(a & 65535)}` : "shift"} for ${o.getName(c)} @ ${r}${f == e ? "" : ", split"})`), d) return !0;
625
+ f.pos > r ? t.push(f) : n.push(f);
626
+ }
627
+ return !1;
628
+ }
629
+ advanceFully(e, t) {
630
+ let n = e.pos;
631
+ for (;;) {
632
+ if (!this.advanceStack(e, null, null)) return !1;
633
+ if (e.pos > n) return D(e, t), !0;
634
+ }
635
+ }
636
+ runRecovery(e, t, n) {
637
+ let r = null, i = !1;
638
+ for (let a = 0; a < e.length; a++) {
639
+ let o = e[a], s = t[a << 1], c = t[(a << 1) + 1], l = x ? this.stackID(o) + " -> " : "";
640
+ if (o.deadEnd && (i || (i = !0, o.restart(), x && console.log(l + this.stackID(o) + " (restarted)"), this.advanceFully(o, n)))) continue;
641
+ let u = o.split(), d = l;
642
+ for (let e = 0; e < 10 && u.forceReduce() && (x && console.log(d + this.stackID(u) + " (via force-reduce)"), !this.advanceFully(u, n)); e++) x && (d = this.stackID(u) + " -> ");
643
+ for (let e of o.recoverByInsert(s)) x && console.log(l + this.stackID(e) + " (via recover-insert)"), this.advanceFully(e, n);
644
+ this.stream.end > o.pos ? (c == o.pos && (c++, s = 0), o.recoverByDelete(s, c), x && console.log(l + this.stackID(o) + ` (via recover-delete ${this.parser.getName(s)})`), D(o, n)) : (!r || r.score < u.score) && (r = u);
645
+ }
646
+ return r;
647
+ }
648
+ stackToTree(e) {
649
+ return e.close(), a.build({
650
+ buffer: u.create(e),
651
+ nodeSet: this.parser.nodeSet,
652
+ topID: this.topTerm,
653
+ maxBufferLength: this.parser.bufferLength,
654
+ reused: this.reused,
655
+ start: this.ranges[0].from,
656
+ length: e.pos - this.ranges[0].from,
657
+ minRepeatType: this.parser.minRepeatTerm
658
+ });
659
+ }
660
+ stackID(e) {
661
+ let t = (S ||= /* @__PURE__ */ new WeakMap()).get(e);
662
+ return t || S.set(e, t = String.fromCodePoint(this.nextStackID++)), t + e;
663
+ }
664
+ };
665
+ function D(e, t) {
666
+ for (let n = 0; n < t.length; n++) {
667
+ let r = t[n];
668
+ if (r.pos == e.pos && r.sameState(e)) {
669
+ t[n].score < e.score && (t[n] = e);
670
+ return;
671
+ }
672
+ }
673
+ t.push(e);
674
+ }
675
+ var O = class {
676
+ constructor(e, t, n) {
677
+ this.source = e, this.flags = t, this.disabled = n;
678
+ }
679
+ allows(e) {
680
+ return !this.disabled || this.disabled[e] == 0;
681
+ }
682
+ }, k = (e) => e, A = class {
683
+ constructor(e) {
684
+ this.start = e.start, this.shift = e.shift || k, this.reduce = e.reduce || k, this.reuse = e.reuse || k, this.hash = e.hash || (() => 0), this.strict = e.strict !== !1;
685
+ }
686
+ }, j = class r extends t {
687
+ constructor(t) {
688
+ if (super(), this.wrappers = [], t.version != 14) throw RangeError(`Parser version (${t.version}) doesn't match runtime version (14)`);
689
+ let r = t.nodeNames.split(" ");
690
+ this.minRepeatTerm = r.length;
691
+ for (let e = 0; e < t.repeatNodeCount; e++) r.push("");
692
+ let a = Object.keys(t.topRules).map((e) => t.topRules[e][1]), s = [];
693
+ for (let e = 0; e < r.length; e++) s.push([]);
694
+ function c(e, t, n) {
695
+ s[e].push([t, t.deserialize(String(n))]);
696
+ }
697
+ if (t.nodeProps) for (let e of t.nodeProps) {
698
+ let t = e[0];
699
+ typeof t == "string" && (t = i[t]);
700
+ for (let n = 1; n < e.length;) {
701
+ let r = e[n++];
702
+ if (r >= 0) c(r, t, e[n++]);
703
+ else {
704
+ let i = e[n + -r];
705
+ for (let a = -r; a > 0; a--) c(e[n++], t, i);
706
+ n++;
707
+ }
708
+ }
709
+ }
710
+ this.nodeSet = new o(r.map((n, r) => e.define({
711
+ name: r >= this.minRepeatTerm ? void 0 : n,
712
+ id: r,
713
+ props: s[r],
714
+ top: a.indexOf(r) > -1,
715
+ error: r == 0,
716
+ skipped: t.skippedNodes && t.skippedNodes.indexOf(r) > -1
717
+ }))), t.propSources && (this.nodeSet = this.nodeSet.extend(...t.propSources)), this.strict = !1, this.bufferLength = n;
718
+ let l = d(t.tokenData);
719
+ this.context = t.context, this.specializerSpecs = t.specialized || [], this.specialized = new Uint16Array(this.specializerSpecs.length);
720
+ for (let e = 0; e < this.specializerSpecs.length; e++) this.specialized[e] = this.specializerSpecs[e].term;
721
+ this.specializers = this.specializerSpecs.map(P), this.states = d(t.states, Uint32Array), this.data = d(t.stateData), this.goto = d(t.goto), this.maxTerm = t.maxTerm, this.tokenizers = t.tokenizers.map((e) => typeof e == "number" ? new h(l, e) : e), 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]];
722
+ }
723
+ createParse(e, t, n) {
724
+ let r = new E(this, e, t, n);
725
+ for (let i of this.wrappers) r = i(r, e, t, n);
726
+ return r;
727
+ }
728
+ getGoto(e, t, n = !1) {
729
+ let r = this.goto;
730
+ if (t >= r[0]) return -1;
731
+ for (let i = r[t + 1];;) {
732
+ let t = r[i++], a = t & 1, o = r[i++];
733
+ if (a && n) return o;
734
+ for (let n = i + (t >> 1); i < n; i++) if (r[i] == e) return o;
735
+ if (a) return -1;
736
+ }
737
+ }
738
+ hasAction(e, t) {
739
+ let n = this.data;
740
+ for (let r = 0; r < 2; r++) for (let i = this.stateSlot(e, r ? 2 : 1), a;; i += 3) {
741
+ if ((a = n[i]) == 65535) {
742
+ if (n[i + 1] == 1) a = n[i = M(n, i + 2)];
743
+ else if (n[i + 1] == 2) return M(n, i + 2);
744
+ else break;
745
+ }
746
+ if (a == t || a == 0) return M(n, i + 1);
747
+ }
748
+ return 0;
749
+ }
750
+ stateSlot(e, t) {
751
+ return this.states[e * 6 + t];
752
+ }
753
+ stateFlag(e, t) {
754
+ return (this.stateSlot(e, 0) & t) > 0;
755
+ }
756
+ validAction(e, t) {
757
+ return !!this.allActions(e, (e) => e == t || null);
758
+ }
759
+ allActions(e, t) {
760
+ let n = this.stateSlot(e, 4), r = n ? t(n) : void 0;
761
+ for (let n = this.stateSlot(e, 1); r == null; n += 3) {
762
+ if (this.data[n] == 65535) {
763
+ if (this.data[n + 1] == 1) n = M(this.data, n + 2);
764
+ else break;
765
+ }
766
+ r = t(M(this.data, n + 1));
767
+ }
768
+ return r;
769
+ }
770
+ nextStates(e) {
771
+ let t = [];
772
+ for (let n = this.stateSlot(e, 1);; n += 3) {
773
+ if (this.data[n] == 65535) {
774
+ if (this.data[n + 1] == 1) n = M(this.data, n + 2);
775
+ else break;
776
+ }
777
+ if (!(this.data[n + 2] & 1)) {
778
+ let e = this.data[n + 1];
779
+ t.some((t, n) => n & 1 && t == e) || t.push(this.data[n], e);
780
+ }
781
+ }
782
+ return t;
783
+ }
784
+ configure(e) {
785
+ let t = Object.assign(Object.create(r.prototype), this);
786
+ if (e.props && (t.nodeSet = this.nodeSet.extend(...e.props)), e.top) {
787
+ let n = this.topRules[e.top];
788
+ if (!n) throw RangeError(`Invalid top rule name ${e.top}`);
789
+ t.top = n;
790
+ }
791
+ return e.tokenizers && (t.tokenizers = this.tokenizers.map((t) => {
792
+ let n = e.tokenizers.find((e) => e.from == t);
793
+ return n ? n.to : t;
794
+ })), e.specializers && (t.specializers = this.specializers.slice(), t.specializerSpecs = this.specializerSpecs.map((n, r) => {
795
+ let i = e.specializers.find((e) => e.from == n.external);
796
+ if (!i) return n;
797
+ let a = Object.assign(Object.assign({}, n), { external: i.to });
798
+ return t.specializers[r] = P(a), a;
799
+ })), e.contextTracker && (t.context = e.contextTracker), e.dialect && (t.dialect = this.parseDialect(e.dialect)), e.strict != null && (t.strict = e.strict), e.wrap && (t.wrappers = t.wrappers.concat(e.wrap)), e.bufferLength != null && (t.bufferLength = e.bufferLength), t;
800
+ }
801
+ hasWrappers() {
802
+ return this.wrappers.length > 0;
803
+ }
804
+ getName(e) {
805
+ return this.termNames ? this.termNames[e] : String(e <= this.maxNode && this.nodeSet.types[e].name || e);
806
+ }
807
+ get eofTerm() {
808
+ return this.maxNode + 1;
809
+ }
810
+ get topNode() {
811
+ return this.nodeSet.types[this.top[1]];
812
+ }
813
+ dynamicPrecedence(e) {
814
+ let t = this.dynamicPrecedences;
815
+ return t == null ? 0 : t[e] || 0;
816
+ }
817
+ parseDialect(e) {
818
+ let t = Object.keys(this.dialects), n = t.map(() => !1);
819
+ if (e) for (let r of e.split(" ")) {
820
+ let e = t.indexOf(r);
821
+ e >= 0 && (n[e] = !0);
822
+ }
823
+ let r = null;
824
+ for (let e = 0; e < t.length; e++) if (!n[e]) for (let n = this.dialects[t[e]], i; (i = this.data[n++]) != 65535;) (r ||= new Uint8Array(this.maxTerm + 1))[i] = 1;
825
+ return new O(e, n, r);
826
+ }
827
+ static deserialize(e) {
828
+ return new r(e);
829
+ }
830
+ };
831
+ function M(e, t) {
832
+ return e[t] | e[t + 1] << 16;
833
+ }
834
+ function N(e) {
835
+ let t = null;
836
+ for (let n of e) {
837
+ let e = n.p.stoppedAt;
838
+ (n.pos == n.p.stream.end || e != null && n.pos > e) && n.p.parser.stateFlag(n.state, 2) && (!t || t.score < n.score) && (t = n);
839
+ }
840
+ return t;
841
+ }
842
+ function P(e) {
843
+ if (e.external) {
844
+ let t = +!!e.extend;
845
+ return (n, r) => e.external(n, r) << 1 | t;
846
+ }
847
+ return e.get;
848
+ }
849
+ //#endregion
850
+ export { g as i, _ as n, j as r, A as t };