likec4 1.48.0 → 1.50.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/README.md +11 -1
  2. package/__app__/src/likec4.js +5941 -4496
  3. package/__app__/src/routes/index.js +3 -153
  4. package/__app__/src/routes/projects.js +21 -1087
  5. package/__app__/src/routes/single.js +1228 -16
  6. package/__app__/src/style.css +1 -1
  7. package/__app__/src/vendors.js +4649 -1897
  8. package/__app__/src/webcomponent.js +1 -1
  9. package/config/schema.json +169 -141
  10. package/dist/THIRD-PARTY-LICENSES.md +1769 -0
  11. package/dist/_chunks/LikeC4.mjs +1154 -202
  12. package/dist/_chunks/binary.mjs +72 -0
  13. package/dist/_chunks/index.d.mts +234 -140
  14. package/dist/_chunks/index2.d.mts +2043 -1828
  15. package/dist/_chunks/libs/@chevrotain/cst-dts-gen.mjs +30 -0
  16. package/dist/_chunks/libs/@chevrotain/regexp-to-ast.mjs +9 -785
  17. package/dist/_chunks/libs/@chevrotain/utils.mjs +1 -37
  18. package/dist/_chunks/libs/@hono/mcp.mjs +34 -0
  19. package/dist/_chunks/libs/@hono/node-server.mjs +1 -436
  20. package/dist/_chunks/libs/@logtape/logtape.d.mts +741 -0
  21. package/dist/_chunks/libs/@logtape/logtape.mjs +6 -1354
  22. package/dist/_chunks/libs/@lume/kiwi.mjs +1 -1355
  23. package/dist/_chunks/libs/@modelcontextprotocol/sdk.d.mts +114 -14
  24. package/dist/_chunks/libs/@modelcontextprotocol/sdk.mjs +12 -25105
  25. package/dist/_chunks/libs/@msgpack/msgpack.mjs +1 -1503
  26. package/dist/_chunks/libs/@nanostores/react.d.mts +61 -1
  27. package/dist/_chunks/libs/@nanostores/react.mjs +1 -30
  28. package/dist/_chunks/libs/@smithy/is-array-buffer.mjs +1 -10
  29. package/dist/_chunks/libs/@smithy/util-base64.mjs +1 -100
  30. package/dist/_chunks/libs/ajv.mjs +1 -777
  31. package/dist/_chunks/libs/atomically.mjs +1 -362
  32. package/dist/_chunks/libs/birpc.mjs +1 -201
  33. package/dist/_chunks/libs/chevrotain-allstar.mjs +2 -850
  34. package/dist/_chunks/libs/chevrotain.mjs +55 -6229
  35. package/dist/_chunks/libs/conf.mjs +1 -2258
  36. package/dist/_chunks/libs/defu.mjs +1 -42
  37. package/dist/_chunks/libs/esm-env.mjs +1 -5
  38. package/dist/_chunks/libs/eventemitter3.mjs +1 -243
  39. package/dist/_chunks/libs/fast-equals.mjs +1 -446
  40. package/dist/_chunks/libs/find-up-simple.mjs +1 -24
  41. package/dist/_chunks/libs/get-port.mjs +1 -107
  42. package/dist/_chunks/libs/is-docker.mjs +1 -26
  43. package/dist/_chunks/libs/is-error-instance.mjs +1 -26
  44. package/dist/_chunks/libs/is-inside-container.mjs +1 -20
  45. package/dist/_chunks/libs/is-plain-obj.mjs +1 -9
  46. package/dist/_chunks/libs/isexe.mjs +1 -127
  47. package/dist/_chunks/libs/json5.mjs +14 -959
  48. package/dist/_chunks/libs/khroma.mjs +1 -605
  49. package/dist/_chunks/libs/ky.mjs +2 -807
  50. package/dist/_chunks/libs/langium.d.mts +2913 -2876
  51. package/dist/_chunks/libs/langium.mjs +33 -20351
  52. package/dist/_chunks/libs/merge-error-cause.mjs +2 -746
  53. package/dist/_chunks/libs/p-limit.mjs +1 -120
  54. package/dist/_chunks/libs/p-queue.mjs +1 -449
  55. package/dist/_chunks/libs/package-manager-detector.mjs +1 -559
  56. package/dist/_chunks/libs/package-up.mjs +1 -10
  57. package/dist/_chunks/libs/pako.mjs +1 -0
  58. package/dist/_chunks/libs/parse-ms.mjs +1 -36
  59. package/dist/_chunks/libs/pathe.mjs +1 -0
  60. package/dist/_chunks/libs/picomatch.mjs +1 -1673
  61. package/dist/_chunks/libs/pretty-ms.mjs +1 -80
  62. package/dist/_chunks/libs/remeda.mjs +2 -690
  63. package/dist/_chunks/libs/safe-stringify.mjs +1 -21
  64. package/dist/_chunks/libs/strip-indent.mjs +1 -15
  65. package/dist/_chunks/libs/tinyrainbow.mjs +1 -88
  66. package/dist/_chunks/libs/ts-graphviz.mjs +4 -725
  67. package/dist/_chunks/libs/ufo.mjs +1 -240
  68. package/dist/_chunks/libs/which.mjs +1 -84
  69. package/dist/_chunks/libs/word-wrap.mjs +12 -43
  70. package/dist/_chunks/rolldown-runtime.mjs +1 -48
  71. package/dist/_chunks/sequence.mjs +1 -0
  72. package/dist/_chunks/src.mjs +15 -0
  73. package/dist/_chunks/src2.mjs +499 -0
  74. package/dist/cli/index.mjs +77 -1952
  75. package/dist/config/index.d.mts +2 -2
  76. package/dist/config/index.mjs +1 -6
  77. package/dist/index.d.mts +150 -7
  78. package/dist/index.mjs +1 -21
  79. package/dist/model/builder.mjs +1 -3
  80. package/dist/model/index.d.mts +57 -3
  81. package/dist/model/index.mjs +1 -5
  82. package/dist/vite-plugin/index.d.mts +7 -3
  83. package/dist/vite-plugin/index.mjs +1 -22
  84. package/dist/vite-plugin/internal.d.mts +6 -7
  85. package/dist/vite-plugin/internal.mjs +1 -68
  86. package/package.json +64 -45
  87. package/react/{index.d.ts → index.d.mts} +114 -72
  88. package/react/{index.js → index.mjs} +21320 -22041
  89. package/react/package.json +2 -5
  90. package/vite-plugin-modules.d.ts +10 -5
  91. package/dist/_chunks/LikeC4.d.mts +0 -121
  92. package/dist/_chunks/config-app.prod.d.mts +0 -18
  93. package/dist/_chunks/config-app.prod.mjs +0 -188
  94. package/dist/_chunks/config-webcomponent.prod.mjs +0 -71
  95. package/dist/_chunks/define-config.mjs +0 -409
  96. package/dist/_chunks/index3.d.mts +0 -60
  97. package/dist/_chunks/libs/@chevrotain/gast.mjs +0 -3969
  98. package/dist/_chunks/libs/hono.mjs +0 -1829
  99. package/dist/_chunks/libs/nanoid.mjs +0 -29
  100. package/dist/_chunks/libs/nanostores.d.mts +0 -63
  101. package/dist/_chunks/libs/nanostores.mjs +0 -198
  102. package/dist/_chunks/model.mjs +0 -12
  103. package/dist/_chunks/module.d.mts +0 -71
  104. package/dist/_chunks/module.mjs +0 -18657
  105. package/dist/_chunks/plugin.mjs +0 -996
  106. package/dist/_chunks/sequence-view.mjs +0 -575
  107. package/dist/_chunks/vite-build.mjs +0 -69
  108. package/dist/_chunks/vite-dev.mjs +0 -79
  109. package/dist/_chunks/vite-preview.mjs +0 -27
  110. package/dist/language/module.d.mts +0 -5
  111. package/dist/language/module.mjs +0 -20
  112. package/dist/vite/vite-build.d.mts +0 -26
  113. package/dist/vite/vite-build.mjs +0 -27
  114. package/dist/vite/vite-dev.d.mts +0 -34
  115. package/dist/vite/vite-dev.mjs +0 -29
  116. package/dist/vite/vite-preview.d.mts +0 -20
  117. package/dist/vite/vite-preview.mjs +0 -26
  118. /package/dist/_chunks/{index4.d.mts → libs/@chevrotain/types.d.mts} +0 -0
@@ -1,850 +1,2 @@
1
- import { C as map_default, D as _baseIteratee_default, T as forEach_default, c as NonTerminal, d as RepetitionMandatory, f as RepetitionMandatoryWithSeparator, h as Terminal, ht as isSymbol_default, l as Option, o as Alternation, p as RepetitionWithSeparator, u as Repetition, ut as identity_default } from "./@chevrotain/gast.mjs";
2
- import { c as tokenMatcher, d as _baseUniq_default, f as reduce_default, g as flatten_default, h as filter_default, i as getLookaheadPaths, m as flatMap_default, p as isEmpty_default, r as LLkLookaheadStrategy, s as tokenLabel } from "./chevrotain.mjs";
3
-
4
- //#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseLt.js
5
- /**
6
- * The base implementation of `_.lt` which doesn't coerce arguments.
7
- *
8
- * @private
9
- * @param {*} value The value to compare.
10
- * @param {*} other The other value to compare.
11
- * @returns {boolean} Returns `true` if `value` is less than `other`,
12
- * else `false`.
13
- */
14
- function baseLt(value, other) {
15
- return value < other;
16
- }
17
- var _baseLt_default = baseLt;
18
-
19
- //#endregion
20
- //#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseExtremum.js
21
- /**
22
- * The base implementation of methods like `_.max` and `_.min` which accepts a
23
- * `comparator` to determine the extremum value.
24
- *
25
- * @private
26
- * @param {Array} array The array to iterate over.
27
- * @param {Function} iteratee The iteratee invoked per iteration.
28
- * @param {Function} comparator The comparator used to compare values.
29
- * @returns {*} Returns the extremum value.
30
- */
31
- function baseExtremum(array, iteratee, comparator) {
32
- var index = -1, length = array.length;
33
- while (++index < length) {
34
- var value = array[index], current = iteratee(value);
35
- if (current != null && (computed === void 0 ? current === current && !isSymbol_default(current) : comparator(current, computed))) var computed = current, result = value;
36
- }
37
- return result;
38
- }
39
- var _baseExtremum_default = baseExtremum;
40
-
41
- //#endregion
42
- //#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/min.js
43
- /**
44
- * Computes the minimum value of `array`. If `array` is empty or falsey,
45
- * `undefined` is returned.
46
- *
47
- * @static
48
- * @since 0.1.0
49
- * @memberOf _
50
- * @category Math
51
- * @param {Array} array The array to iterate over.
52
- * @returns {*} Returns the minimum value.
53
- * @example
54
- *
55
- * _.min([4, 2, 8, 6]);
56
- * // => 2
57
- *
58
- * _.min([]);
59
- * // => undefined
60
- */
61
- function min(array) {
62
- return array && array.length ? _baseExtremum_default(array, identity_default, _baseLt_default) : void 0;
63
- }
64
- var min_default = min;
65
-
66
- //#endregion
67
- //#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/uniqBy.js
68
- /**
69
- * This method is like `_.uniq` except that it accepts `iteratee` which is
70
- * invoked for each element in `array` to generate the criterion by which
71
- * uniqueness is computed. The order of result values is determined by the
72
- * order they occur in the array. The iteratee is invoked with one argument:
73
- * (value).
74
- *
75
- * @static
76
- * @memberOf _
77
- * @since 4.0.0
78
- * @category Array
79
- * @param {Array} array The array to inspect.
80
- * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
81
- * @returns {Array} Returns the new duplicate free array.
82
- * @example
83
- *
84
- * _.uniqBy([2.1, 1.2, 2.3], Math.floor);
85
- * // => [2.1, 1.2]
86
- *
87
- * // The `_.property` iteratee shorthand.
88
- * _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');
89
- * // => [{ 'x': 1 }, { 'x': 2 }]
90
- */
91
- function uniqBy(array, iteratee) {
92
- return array && array.length ? _baseUniq_default(array, _baseIteratee_default(iteratee, 2)) : [];
93
- }
94
- var uniqBy_default = uniqBy;
95
-
96
- //#endregion
97
- //#region ../../node_modules/.pnpm/chevrotain-allstar@0.3.1_chevrotain@11.0.3/node_modules/chevrotain-allstar/lib/atn.js
98
- /******************************************************************************
99
- * Copyright 2022 TypeFox GmbH
100
- * This program and the accompanying materials are made available under the
101
- * terms of the MIT License, which is available in the project root.
102
- ******************************************************************************/
103
- function buildATNKey(rule, type, occurrence) {
104
- return `${rule.name}_${type}_${occurrence}`;
105
- }
106
- const ATN_BASIC = 1;
107
- const ATN_RULE_START = 2;
108
- const ATN_PLUS_BLOCK_START = 4;
109
- const ATN_STAR_BLOCK_START = 5;
110
- const ATN_RULE_STOP = 7;
111
- const ATN_BLOCK_END = 8;
112
- const ATN_STAR_LOOP_BACK = 9;
113
- const ATN_STAR_LOOP_ENTRY = 10;
114
- const ATN_PLUS_LOOP_BACK = 11;
115
- const ATN_LOOP_END = 12;
116
- var AbstractTransition = class {
117
- constructor(target) {
118
- this.target = target;
119
- }
120
- isEpsilon() {
121
- return false;
122
- }
123
- };
124
- var AtomTransition = class extends AbstractTransition {
125
- constructor(target, tokenType) {
126
- super(target);
127
- this.tokenType = tokenType;
128
- }
129
- };
130
- var EpsilonTransition = class extends AbstractTransition {
131
- constructor(target) {
132
- super(target);
133
- }
134
- isEpsilon() {
135
- return true;
136
- }
137
- };
138
- var RuleTransition = class extends AbstractTransition {
139
- constructor(ruleStart, rule, followState) {
140
- super(ruleStart);
141
- this.rule = rule;
142
- this.followState = followState;
143
- }
144
- isEpsilon() {
145
- return true;
146
- }
147
- };
148
- function createATN(rules) {
149
- const atn = {
150
- decisionMap: {},
151
- decisionStates: [],
152
- ruleToStartState: /* @__PURE__ */ new Map(),
153
- ruleToStopState: /* @__PURE__ */ new Map(),
154
- states: []
155
- };
156
- createRuleStartAndStopATNStates(atn, rules);
157
- const ruleLength = rules.length;
158
- for (let i = 0; i < ruleLength; i++) {
159
- const rule = rules[i];
160
- const ruleBlock = block(atn, rule, rule);
161
- if (ruleBlock === void 0) continue;
162
- buildRuleHandle(atn, rule, ruleBlock);
163
- }
164
- return atn;
165
- }
166
- function createRuleStartAndStopATNStates(atn, rules) {
167
- const ruleLength = rules.length;
168
- for (let i = 0; i < ruleLength; i++) {
169
- const rule = rules[i];
170
- const start = newState(atn, rule, void 0, { type: ATN_RULE_START });
171
- const stop = newState(atn, rule, void 0, { type: ATN_RULE_STOP });
172
- start.stop = stop;
173
- atn.ruleToStartState.set(rule, start);
174
- atn.ruleToStopState.set(rule, stop);
175
- }
176
- }
177
- function atom(atn, rule, production) {
178
- if (production instanceof Terminal) return tokenRef(atn, rule, production.terminalType, production);
179
- else if (production instanceof NonTerminal) return ruleRef(atn, rule, production);
180
- else if (production instanceof Alternation) return alternation(atn, rule, production);
181
- else if (production instanceof Option) return option(atn, rule, production);
182
- else if (production instanceof Repetition) return repetition(atn, rule, production);
183
- else if (production instanceof RepetitionWithSeparator) return repetitionSep(atn, rule, production);
184
- else if (production instanceof RepetitionMandatory) return repetitionMandatory(atn, rule, production);
185
- else if (production instanceof RepetitionMandatoryWithSeparator) return repetitionMandatorySep(atn, rule, production);
186
- else return block(atn, rule, production);
187
- }
188
- function repetition(atn, rule, repetition) {
189
- const starState = newState(atn, rule, repetition, { type: ATN_STAR_BLOCK_START });
190
- defineDecisionState(atn, starState);
191
- return star(atn, rule, repetition, makeAlts(atn, rule, starState, repetition, block(atn, rule, repetition)));
192
- }
193
- function repetitionSep(atn, rule, repetition) {
194
- const starState = newState(atn, rule, repetition, { type: ATN_STAR_BLOCK_START });
195
- defineDecisionState(atn, starState);
196
- return star(atn, rule, repetition, makeAlts(atn, rule, starState, repetition, block(atn, rule, repetition)), tokenRef(atn, rule, repetition.separator, repetition));
197
- }
198
- function repetitionMandatory(atn, rule, repetition) {
199
- const plusState = newState(atn, rule, repetition, { type: ATN_PLUS_BLOCK_START });
200
- defineDecisionState(atn, plusState);
201
- return plus(atn, rule, repetition, makeAlts(atn, rule, plusState, repetition, block(atn, rule, repetition)));
202
- }
203
- function repetitionMandatorySep(atn, rule, repetition) {
204
- const plusState = newState(atn, rule, repetition, { type: ATN_PLUS_BLOCK_START });
205
- defineDecisionState(atn, plusState);
206
- return plus(atn, rule, repetition, makeAlts(atn, rule, plusState, repetition, block(atn, rule, repetition)), tokenRef(atn, rule, repetition.separator, repetition));
207
- }
208
- function alternation(atn, rule, alternation) {
209
- const start = newState(atn, rule, alternation, { type: ATN_BASIC });
210
- defineDecisionState(atn, start);
211
- return makeAlts(atn, rule, start, alternation, ...map_default(alternation.definition, (e) => atom(atn, rule, e)));
212
- }
213
- function option(atn, rule, option) {
214
- const start = newState(atn, rule, option, { type: ATN_BASIC });
215
- defineDecisionState(atn, start);
216
- return optional(atn, rule, option, makeAlts(atn, rule, start, option, block(atn, rule, option)));
217
- }
218
- function block(atn, rule, block) {
219
- const handles = filter_default(map_default(block.definition, (e) => atom(atn, rule, e)), (e) => e !== void 0);
220
- if (handles.length === 1) return handles[0];
221
- else if (handles.length === 0) return;
222
- else return makeBlock(atn, handles);
223
- }
224
- function plus(atn, rule, plus, handle, sep) {
225
- const blkStart = handle.left;
226
- const blkEnd = handle.right;
227
- const loop = newState(atn, rule, plus, { type: ATN_PLUS_LOOP_BACK });
228
- defineDecisionState(atn, loop);
229
- const end = newState(atn, rule, plus, { type: ATN_LOOP_END });
230
- blkStart.loopback = loop;
231
- end.loopback = loop;
232
- atn.decisionMap[buildATNKey(rule, sep ? "RepetitionMandatoryWithSeparator" : "RepetitionMandatory", plus.idx)] = loop;
233
- epsilon(blkEnd, loop);
234
- if (sep === void 0) {
235
- epsilon(loop, blkStart);
236
- epsilon(loop, end);
237
- } else {
238
- epsilon(loop, end);
239
- epsilon(loop, sep.left);
240
- epsilon(sep.right, blkStart);
241
- }
242
- return {
243
- left: blkStart,
244
- right: end
245
- };
246
- }
247
- function star(atn, rule, star, handle, sep) {
248
- const start = handle.left;
249
- const end = handle.right;
250
- const entry = newState(atn, rule, star, { type: ATN_STAR_LOOP_ENTRY });
251
- defineDecisionState(atn, entry);
252
- const loopEnd = newState(atn, rule, star, { type: ATN_LOOP_END });
253
- const loop = newState(atn, rule, star, { type: ATN_STAR_LOOP_BACK });
254
- entry.loopback = loop;
255
- loopEnd.loopback = loop;
256
- epsilon(entry, start);
257
- epsilon(entry, loopEnd);
258
- epsilon(end, loop);
259
- if (sep !== void 0) {
260
- epsilon(loop, loopEnd);
261
- epsilon(loop, sep.left);
262
- epsilon(sep.right, start);
263
- } else epsilon(loop, entry);
264
- atn.decisionMap[buildATNKey(rule, sep ? "RepetitionWithSeparator" : "Repetition", star.idx)] = entry;
265
- return {
266
- left: entry,
267
- right: loopEnd
268
- };
269
- }
270
- function optional(atn, rule, optional, handle) {
271
- const start = handle.left;
272
- const end = handle.right;
273
- epsilon(start, end);
274
- atn.decisionMap[buildATNKey(rule, "Option", optional.idx)] = start;
275
- return handle;
276
- }
277
- function defineDecisionState(atn, state) {
278
- atn.decisionStates.push(state);
279
- state.decision = atn.decisionStates.length - 1;
280
- return state.decision;
281
- }
282
- function makeAlts(atn, rule, start, production, ...alts) {
283
- const end = newState(atn, rule, production, {
284
- type: ATN_BLOCK_END,
285
- start
286
- });
287
- start.end = end;
288
- for (const alt of alts) if (alt !== void 0) {
289
- epsilon(start, alt.left);
290
- epsilon(alt.right, end);
291
- } else epsilon(start, end);
292
- const handle = {
293
- left: start,
294
- right: end
295
- };
296
- atn.decisionMap[buildATNKey(rule, getProdType(production), production.idx)] = start;
297
- return handle;
298
- }
299
- function getProdType(production) {
300
- if (production instanceof Alternation) return "Alternation";
301
- else if (production instanceof Option) return "Option";
302
- else if (production instanceof Repetition) return "Repetition";
303
- else if (production instanceof RepetitionWithSeparator) return "RepetitionWithSeparator";
304
- else if (production instanceof RepetitionMandatory) return "RepetitionMandatory";
305
- else if (production instanceof RepetitionMandatoryWithSeparator) return "RepetitionMandatoryWithSeparator";
306
- else throw new Error("Invalid production type encountered");
307
- }
308
- function makeBlock(atn, alts) {
309
- const altsLength = alts.length;
310
- for (let i = 0; i < altsLength - 1; i++) {
311
- const handle = alts[i];
312
- let transition;
313
- if (handle.left.transitions.length === 1) transition = handle.left.transitions[0];
314
- const isRuleTransition = transition instanceof RuleTransition;
315
- const ruleTransition = transition;
316
- const next = alts[i + 1].left;
317
- if (handle.left.type === ATN_BASIC && handle.right.type === ATN_BASIC && transition !== void 0 && (isRuleTransition && ruleTransition.followState === handle.right || transition.target === handle.right)) {
318
- if (isRuleTransition) ruleTransition.followState = next;
319
- else transition.target = next;
320
- removeState(atn, handle.right);
321
- } else epsilon(handle.right, next);
322
- }
323
- const first = alts[0];
324
- const last = alts[altsLength - 1];
325
- return {
326
- left: first.left,
327
- right: last.right
328
- };
329
- }
330
- function tokenRef(atn, rule, tokenType, production) {
331
- const left = newState(atn, rule, production, { type: ATN_BASIC });
332
- const right = newState(atn, rule, production, { type: ATN_BASIC });
333
- addTransition(left, new AtomTransition(right, tokenType));
334
- return {
335
- left,
336
- right
337
- };
338
- }
339
- function ruleRef(atn, currentRule, nonTerminal) {
340
- const rule = nonTerminal.referencedRule;
341
- const start = atn.ruleToStartState.get(rule);
342
- const left = newState(atn, currentRule, nonTerminal, { type: ATN_BASIC });
343
- const right = newState(atn, currentRule, nonTerminal, { type: ATN_BASIC });
344
- addTransition(left, new RuleTransition(start, rule, right));
345
- return {
346
- left,
347
- right
348
- };
349
- }
350
- function buildRuleHandle(atn, rule, block) {
351
- const start = atn.ruleToStartState.get(rule);
352
- epsilon(start, block.left);
353
- const stop = atn.ruleToStopState.get(rule);
354
- epsilon(block.right, stop);
355
- return {
356
- left: start,
357
- right: stop
358
- };
359
- }
360
- function epsilon(a, b) {
361
- addTransition(a, new EpsilonTransition(b));
362
- }
363
- function newState(atn, rule, production, partial) {
364
- const t = Object.assign({
365
- atn,
366
- production,
367
- epsilonOnlyTransitions: false,
368
- rule,
369
- transitions: [],
370
- nextTokenWithinRule: [],
371
- stateNumber: atn.states.length
372
- }, partial);
373
- atn.states.push(t);
374
- return t;
375
- }
376
- function addTransition(state, transition) {
377
- if (state.transitions.length === 0) state.epsilonOnlyTransitions = transition.isEpsilon();
378
- state.transitions.push(transition);
379
- }
380
- function removeState(atn, state) {
381
- atn.states.splice(atn.states.indexOf(state), 1);
382
- }
383
-
384
- //#endregion
385
- //#region ../../node_modules/.pnpm/chevrotain-allstar@0.3.1_chevrotain@11.0.3/node_modules/chevrotain-allstar/lib/dfa.js
386
- /******************************************************************************
387
- * Copyright 2022 TypeFox GmbH
388
- * This program and the accompanying materials are made available under the
389
- * terms of the MIT License, which is available in the project root.
390
- ******************************************************************************/
391
- const DFA_ERROR = {};
392
- var ATNConfigSet = class {
393
- constructor() {
394
- this.map = {};
395
- this.configs = [];
396
- }
397
- get size() {
398
- return this.configs.length;
399
- }
400
- finalize() {
401
- this.map = {};
402
- }
403
- add(config) {
404
- const key = getATNConfigKey(config);
405
- if (!(key in this.map)) {
406
- this.map[key] = this.configs.length;
407
- this.configs.push(config);
408
- }
409
- }
410
- get elements() {
411
- return this.configs;
412
- }
413
- get alts() {
414
- return map_default(this.configs, (e) => e.alt);
415
- }
416
- get key() {
417
- let value = "";
418
- for (const k in this.map) value += k + ":";
419
- return value;
420
- }
421
- };
422
- function getATNConfigKey(config, alt = true) {
423
- return `${alt ? `a${config.alt}` : ""}s${config.state.stateNumber}:${config.stack.map((e) => e.stateNumber.toString()).join("_")}`;
424
- }
425
-
426
- //#endregion
427
- //#region ../../node_modules/.pnpm/chevrotain-allstar@0.3.1_chevrotain@11.0.3/node_modules/chevrotain-allstar/lib/all-star-lookahead.js
428
- /******************************************************************************
429
- * Copyright 2022 TypeFox GmbH
430
- * This program and the accompanying materials are made available under the
431
- * terms of the MIT License, which is available in the project root.
432
- ******************************************************************************/
433
- function createDFACache(startState, decision) {
434
- const map = {};
435
- return (predicateSet) => {
436
- const key = predicateSet.toString();
437
- let existing = map[key];
438
- if (existing !== void 0) return existing;
439
- else {
440
- existing = {
441
- atnStartState: startState,
442
- decision,
443
- states: {}
444
- };
445
- map[key] = existing;
446
- return existing;
447
- }
448
- };
449
- }
450
- var PredicateSet = class {
451
- constructor() {
452
- this.predicates = [];
453
- }
454
- is(index) {
455
- return index >= this.predicates.length || this.predicates[index];
456
- }
457
- set(index, value) {
458
- this.predicates[index] = value;
459
- }
460
- toString() {
461
- let value = "";
462
- const size = this.predicates.length;
463
- for (let i = 0; i < size; i++) value += this.predicates[i] === true ? "1" : "0";
464
- return value;
465
- }
466
- };
467
- const EMPTY_PREDICATES = new PredicateSet();
468
- var LLStarLookaheadStrategy = class extends LLkLookaheadStrategy {
469
- constructor(options) {
470
- var _a;
471
- super();
472
- this.logging = (_a = options === null || options === void 0 ? void 0 : options.logging) !== null && _a !== void 0 ? _a : ((message) => console.log(message));
473
- }
474
- initialize(options) {
475
- this.atn = createATN(options.rules);
476
- this.dfas = initATNSimulator(this.atn);
477
- }
478
- validateAmbiguousAlternationAlternatives() {
479
- return [];
480
- }
481
- validateEmptyOrAlternatives() {
482
- return [];
483
- }
484
- buildLookaheadForAlternation(options) {
485
- const { prodOccurrence, rule, hasPredicates, dynamicTokensEnabled } = options;
486
- const dfas = this.dfas;
487
- const logging = this.logging;
488
- const key = buildATNKey(rule, "Alternation", prodOccurrence);
489
- const decisionIndex = this.atn.decisionMap[key].decision;
490
- const partialAlts = map_default(getLookaheadPaths({
491
- maxLookahead: 1,
492
- occurrence: prodOccurrence,
493
- prodType: "Alternation",
494
- rule
495
- }), (currAlt) => map_default(currAlt, (path) => path[0]));
496
- if (isLL1Sequence(partialAlts, false) && !dynamicTokensEnabled) {
497
- const choiceToAlt = reduce_default(partialAlts, (result, currAlt, idx) => {
498
- forEach_default(currAlt, (currTokType) => {
499
- if (currTokType) {
500
- result[currTokType.tokenTypeIdx] = idx;
501
- forEach_default(currTokType.categoryMatches, (currExtendingType) => {
502
- result[currExtendingType] = idx;
503
- });
504
- }
505
- });
506
- return result;
507
- }, {});
508
- if (hasPredicates) return function(orAlts) {
509
- var _a;
510
- const prediction = choiceToAlt[this.LA(1).tokenTypeIdx];
511
- if (orAlts !== void 0 && prediction !== void 0) {
512
- const gate = (_a = orAlts[prediction]) === null || _a === void 0 ? void 0 : _a.GATE;
513
- if (gate !== void 0 && gate.call(this) === false) return;
514
- }
515
- return prediction;
516
- };
517
- else return function() {
518
- return choiceToAlt[this.LA(1).tokenTypeIdx];
519
- };
520
- } else if (hasPredicates) return function(orAlts) {
521
- const predicates = new PredicateSet();
522
- const length = orAlts === void 0 ? 0 : orAlts.length;
523
- for (let i = 0; i < length; i++) {
524
- const gate = orAlts === null || orAlts === void 0 ? void 0 : orAlts[i].GATE;
525
- predicates.set(i, gate === void 0 || gate.call(this));
526
- }
527
- const result = adaptivePredict.call(this, dfas, decisionIndex, predicates, logging);
528
- return typeof result === "number" ? result : void 0;
529
- };
530
- else return function() {
531
- const result = adaptivePredict.call(this, dfas, decisionIndex, EMPTY_PREDICATES, logging);
532
- return typeof result === "number" ? result : void 0;
533
- };
534
- }
535
- buildLookaheadForOptional(options) {
536
- const { prodOccurrence, rule, prodType, dynamicTokensEnabled } = options;
537
- const dfas = this.dfas;
538
- const logging = this.logging;
539
- const key = buildATNKey(rule, prodType, prodOccurrence);
540
- const decisionIndex = this.atn.decisionMap[key].decision;
541
- const alts = map_default(getLookaheadPaths({
542
- maxLookahead: 1,
543
- occurrence: prodOccurrence,
544
- prodType,
545
- rule
546
- }), (e) => {
547
- return map_default(e, (g) => g[0]);
548
- });
549
- if (isLL1Sequence(alts) && alts[0][0] && !dynamicTokensEnabled) {
550
- const alt = alts[0];
551
- const singleTokensTypes = flatten_default(alt);
552
- if (singleTokensTypes.length === 1 && isEmpty_default(singleTokensTypes[0].categoryMatches)) {
553
- const expectedTokenUniqueKey = singleTokensTypes[0].tokenTypeIdx;
554
- return function() {
555
- return this.LA(1).tokenTypeIdx === expectedTokenUniqueKey;
556
- };
557
- } else {
558
- const choiceToAlt = reduce_default(singleTokensTypes, (result, currTokType) => {
559
- if (currTokType !== void 0) {
560
- result[currTokType.tokenTypeIdx] = true;
561
- forEach_default(currTokType.categoryMatches, (currExtendingType) => {
562
- result[currExtendingType] = true;
563
- });
564
- }
565
- return result;
566
- }, {});
567
- return function() {
568
- return choiceToAlt[this.LA(1).tokenTypeIdx] === true;
569
- };
570
- }
571
- }
572
- return function() {
573
- const result = adaptivePredict.call(this, dfas, decisionIndex, EMPTY_PREDICATES, logging);
574
- return typeof result === "object" ? false : result === 0;
575
- };
576
- }
577
- };
578
- function isLL1Sequence(sequences, allowEmpty = true) {
579
- const fullSet = /* @__PURE__ */ new Set();
580
- for (const alt of sequences) {
581
- const altSet = /* @__PURE__ */ new Set();
582
- for (const tokType of alt) {
583
- if (tokType === void 0) if (allowEmpty) break;
584
- else return false;
585
- const indices = [tokType.tokenTypeIdx].concat(tokType.categoryMatches);
586
- for (const index of indices) if (fullSet.has(index)) {
587
- if (!altSet.has(index)) return false;
588
- } else {
589
- fullSet.add(index);
590
- altSet.add(index);
591
- }
592
- }
593
- }
594
- return true;
595
- }
596
- function initATNSimulator(atn) {
597
- const decisionLength = atn.decisionStates.length;
598
- const decisionToDFA = Array(decisionLength);
599
- for (let i = 0; i < decisionLength; i++) decisionToDFA[i] = createDFACache(atn.decisionStates[i], i);
600
- return decisionToDFA;
601
- }
602
- function adaptivePredict(dfaCaches, decision, predicateSet, logging) {
603
- const dfa = dfaCaches[decision](predicateSet);
604
- let start = dfa.start;
605
- if (start === void 0) {
606
- start = addDFAState(dfa, newDFAState(computeStartState(dfa.atnStartState)));
607
- dfa.start = start;
608
- }
609
- return performLookahead.apply(this, [
610
- dfa,
611
- start,
612
- predicateSet,
613
- logging
614
- ]);
615
- }
616
- function performLookahead(dfa, s0, predicateSet, logging) {
617
- let previousD = s0;
618
- let i = 1;
619
- const path = [];
620
- let t = this.LA(i++);
621
- while (true) {
622
- let d = getExistingTargetState(previousD, t);
623
- if (d === void 0) d = computeLookaheadTarget.apply(this, [
624
- dfa,
625
- previousD,
626
- t,
627
- i,
628
- predicateSet,
629
- logging
630
- ]);
631
- if (d === DFA_ERROR) return buildAdaptivePredictError(path, previousD, t);
632
- if (d.isAcceptState === true) return d.prediction;
633
- previousD = d;
634
- path.push(t);
635
- t = this.LA(i++);
636
- }
637
- }
638
- function computeLookaheadTarget(dfa, previousD, token, lookahead, predicateSet, logging) {
639
- const reach = computeReachSet(previousD.configs, token, predicateSet);
640
- if (reach.size === 0) {
641
- addDFAEdge(dfa, previousD, token, DFA_ERROR);
642
- return DFA_ERROR;
643
- }
644
- let newState = newDFAState(reach);
645
- const predictedAlt = getUniqueAlt(reach, predicateSet);
646
- if (predictedAlt !== void 0) {
647
- newState.isAcceptState = true;
648
- newState.prediction = predictedAlt;
649
- newState.configs.uniqueAlt = predictedAlt;
650
- } else if (hasConflictTerminatingPrediction(reach)) {
651
- const prediction = min_default(reach.alts);
652
- newState.isAcceptState = true;
653
- newState.prediction = prediction;
654
- newState.configs.uniqueAlt = prediction;
655
- reportLookaheadAmbiguity.apply(this, [
656
- dfa,
657
- lookahead,
658
- reach.alts,
659
- logging
660
- ]);
661
- }
662
- newState = addDFAEdge(dfa, previousD, token, newState);
663
- return newState;
664
- }
665
- function reportLookaheadAmbiguity(dfa, lookahead, ambiguityIndices, logging) {
666
- const prefixPath = [];
667
- for (let i = 1; i <= lookahead; i++) prefixPath.push(this.LA(i).tokenType);
668
- const atnState = dfa.atnStartState;
669
- const topLevelRule = atnState.rule;
670
- const production = atnState.production;
671
- logging(buildAmbiguityError({
672
- topLevelRule,
673
- ambiguityIndices,
674
- production,
675
- prefixPath
676
- }));
677
- }
678
- function buildAmbiguityError(options) {
679
- const pathMsg = map_default(options.prefixPath, (currtok) => tokenLabel(currtok)).join(", ");
680
- const occurrence = options.production.idx === 0 ? "" : options.production.idx;
681
- let currMessage = `Ambiguous Alternatives Detected: <${options.ambiguityIndices.join(", ")}> in <${getProductionDslName(options.production)}${occurrence}> inside <${options.topLevelRule.name}> Rule,\n<${pathMsg}> may appears as a prefix path in all these alternatives.\n`;
682
- currMessage = currMessage + "See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#AMBIGUOUS_ALTERNATIVES\nFor Further details.";
683
- return currMessage;
684
- }
685
- function getProductionDslName(prod) {
686
- if (prod instanceof NonTerminal) return "SUBRULE";
687
- else if (prod instanceof Option) return "OPTION";
688
- else if (prod instanceof Alternation) return "OR";
689
- else if (prod instanceof RepetitionMandatory) return "AT_LEAST_ONE";
690
- else if (prod instanceof RepetitionMandatoryWithSeparator) return "AT_LEAST_ONE_SEP";
691
- else if (prod instanceof RepetitionWithSeparator) return "MANY_SEP";
692
- else if (prod instanceof Repetition) return "MANY";
693
- else if (prod instanceof Terminal) return "CONSUME";
694
- else throw Error("non exhaustive match");
695
- }
696
- function buildAdaptivePredictError(path, previous, current) {
697
- return {
698
- actualToken: current,
699
- possibleTokenTypes: uniqBy_default(flatMap_default(previous.configs.elements, (e) => e.state.transitions).filter((e) => e instanceof AtomTransition).map((e) => e.tokenType), (e) => e.tokenTypeIdx),
700
- tokenPath: path
701
- };
702
- }
703
- function getExistingTargetState(state, token) {
704
- return state.edges[token.tokenTypeIdx];
705
- }
706
- function computeReachSet(configs, token, predicateSet) {
707
- const intermediate = new ATNConfigSet();
708
- const skippedStopStates = [];
709
- for (const c of configs.elements) {
710
- if (predicateSet.is(c.alt) === false) continue;
711
- if (c.state.type === ATN_RULE_STOP) {
712
- skippedStopStates.push(c);
713
- continue;
714
- }
715
- const transitionLength = c.state.transitions.length;
716
- for (let i = 0; i < transitionLength; i++) {
717
- const transition = c.state.transitions[i];
718
- const target = getReachableTarget(transition, token);
719
- if (target !== void 0) intermediate.add({
720
- state: target,
721
- alt: c.alt,
722
- stack: c.stack
723
- });
724
- }
725
- }
726
- let reach;
727
- if (skippedStopStates.length === 0 && intermediate.size === 1) reach = intermediate;
728
- if (reach === void 0) {
729
- reach = new ATNConfigSet();
730
- for (const c of intermediate.elements) closure(c, reach);
731
- }
732
- if (skippedStopStates.length > 0 && !hasConfigInRuleStopState(reach)) for (const c of skippedStopStates) reach.add(c);
733
- return reach;
734
- }
735
- function getReachableTarget(transition, token) {
736
- if (transition instanceof AtomTransition && tokenMatcher(token, transition.tokenType)) return transition.target;
737
- }
738
- function getUniqueAlt(configs, predicateSet) {
739
- let alt;
740
- for (const c of configs.elements) if (predicateSet.is(c.alt) === true) {
741
- if (alt === void 0) alt = c.alt;
742
- else if (alt !== c.alt) return;
743
- }
744
- return alt;
745
- }
746
- function newDFAState(closure) {
747
- return {
748
- configs: closure,
749
- edges: {},
750
- isAcceptState: false,
751
- prediction: -1
752
- };
753
- }
754
- function addDFAEdge(dfa, from, token, to) {
755
- to = addDFAState(dfa, to);
756
- from.edges[token.tokenTypeIdx] = to;
757
- return to;
758
- }
759
- function addDFAState(dfa, state) {
760
- if (state === DFA_ERROR) return state;
761
- const mapKey = state.configs.key;
762
- const existing = dfa.states[mapKey];
763
- if (existing !== void 0) return existing;
764
- state.configs.finalize();
765
- dfa.states[mapKey] = state;
766
- return state;
767
- }
768
- function computeStartState(atnState) {
769
- const configs = new ATNConfigSet();
770
- const numberOfTransitions = atnState.transitions.length;
771
- for (let i = 0; i < numberOfTransitions; i++) closure({
772
- state: atnState.transitions[i].target,
773
- alt: i,
774
- stack: []
775
- }, configs);
776
- return configs;
777
- }
778
- function closure(config, configs) {
779
- const p = config.state;
780
- if (p.type === ATN_RULE_STOP) {
781
- if (config.stack.length > 0) {
782
- const atnStack = [...config.stack];
783
- closure({
784
- state: atnStack.pop(),
785
- alt: config.alt,
786
- stack: atnStack
787
- }, configs);
788
- } else configs.add(config);
789
- return;
790
- }
791
- if (!p.epsilonOnlyTransitions) configs.add(config);
792
- const transitionLength = p.transitions.length;
793
- for (let i = 0; i < transitionLength; i++) {
794
- const transition = p.transitions[i];
795
- const c = getEpsilonTarget(config, transition);
796
- if (c !== void 0) closure(c, configs);
797
- }
798
- }
799
- function getEpsilonTarget(config, transition) {
800
- if (transition instanceof EpsilonTransition) return {
801
- state: transition.target,
802
- alt: config.alt,
803
- stack: config.stack
804
- };
805
- else if (transition instanceof RuleTransition) {
806
- const stack = [...config.stack, transition.followState];
807
- return {
808
- state: transition.target,
809
- alt: config.alt,
810
- stack
811
- };
812
- }
813
- }
814
- function hasConfigInRuleStopState(configs) {
815
- for (const c of configs.elements) if (c.state.type === ATN_RULE_STOP) return true;
816
- return false;
817
- }
818
- function allConfigsInRuleStopStates(configs) {
819
- for (const c of configs.elements) if (c.state.type !== ATN_RULE_STOP) return false;
820
- return true;
821
- }
822
- function hasConflictTerminatingPrediction(configs) {
823
- if (allConfigsInRuleStopStates(configs)) return true;
824
- const altSets = getConflictingAltSets(configs.elements);
825
- return hasConflictingAltSet(altSets) && !hasStateAssociatedWithOneAlt(altSets);
826
- }
827
- function getConflictingAltSets(configs) {
828
- const configToAlts = /* @__PURE__ */ new Map();
829
- for (const c of configs) {
830
- const key = getATNConfigKey(c, false);
831
- let alts = configToAlts.get(key);
832
- if (alts === void 0) {
833
- alts = {};
834
- configToAlts.set(key, alts);
835
- }
836
- alts[c.alt] = true;
837
- }
838
- return configToAlts;
839
- }
840
- function hasConflictingAltSet(altSets) {
841
- for (const value of Array.from(altSets.values())) if (Object.keys(value).length > 1) return true;
842
- return false;
843
- }
844
- function hasStateAssociatedWithOneAlt(altSets) {
845
- for (const value of Array.from(altSets.values())) if (Object.keys(value).length === 1) return true;
846
- return false;
847
- }
848
-
849
- //#endregion
850
- export { LLStarLookaheadStrategy as t };
1
+ import{i as e,l as t,r as n,u as r}from"./chevrotain.mjs";import{C as i,E as a,L as o,N as s,P as c,_ as l,c as u,d,f,h as p,l as m,o as h,p as g,q as _,u as v,x as y,z as b}from"./@chevrotain/cst-dts-gen.mjs";function x(e,t,n){return`${e.name}_${t}_${n}`}var S=class{constructor(e){this.target=e}isEpsilon(){return!1}},C=class extends S{constructor(e,t){super(e),this.tokenType=t}},w=class extends S{constructor(e){super(e)}isEpsilon(){return!0}},T=class extends S{constructor(e,t,n){super(e),this.rule=t,this.followState=n}isEpsilon(){return!0}};function ee(e){let t={decisionMap:{},decisionStates:[],ruleToStartState:new Map,ruleToStopState:new Map,states:[]};te(t,e);let n=e.length;for(let r=0;r<n;r++){let n=e[r],i=k(t,n,n);i!==void 0&&ce(t,n,i)}return t}function te(e,t){let n=t.length;for(let r=0;r<n;r++){let n=t[r],i=R(e,n,void 0,{type:2}),a=R(e,n,void 0,{type:7});i.stop=a,e.ruleToStartState.set(n,i),e.ruleToStopState.set(n,a)}}function E(e,t,n){return n instanceof p?I(e,t,n.terminalType,n):n instanceof u?se(e,t,n):n instanceof h?ie(e,t,n):n instanceof m?ae(e,t,n):n instanceof v?D(e,t,n):n instanceof g?O(e,t,n):n instanceof d?ne(e,t,n):n instanceof f?re(e,t,n):k(e,t,n)}function D(e,t,n){let r=R(e,t,n,{type:5});return M(e,r),j(e,t,n,N(e,t,r,n,k(e,t,n)))}function O(e,t,n){let r=R(e,t,n,{type:5});return M(e,r),j(e,t,n,N(e,t,r,n,k(e,t,n)),I(e,t,n.separator,n))}function ne(e,t,n){let r=R(e,t,n,{type:4});return M(e,r),A(e,t,n,N(e,t,r,n,k(e,t,n)))}function re(e,t,n){let r=R(e,t,n,{type:4});return M(e,r),A(e,t,n,N(e,t,r,n,k(e,t,n)),I(e,t,n.separator,n))}function ie(e,t,n){let r=R(e,t,n,{type:1});return M(e,r),N(e,t,r,n,...c(n.definition,n=>E(e,t,n)))}function ae(e,t,n){let r=R(e,t,n,{type:1});return M(e,r),oe(e,t,n,N(e,t,r,n,k(e,t,n)))}function k(e,t,n){let r=o(c(n.definition,n=>E(e,t,n)),e=>e!==void 0);return r.length===1?r[0]:r.length===0?void 0:F(e,r)}function A(e,t,n,r,i){let a=r.left,o=r.right,s=R(e,t,n,{type:11});M(e,s);let c=R(e,t,n,{type:12});return a.loopback=s,c.loopback=s,e.decisionMap[x(t,i?`RepetitionMandatoryWithSeparator`:`RepetitionMandatory`,n.idx)]=s,L(o,s),i===void 0?(L(s,a),L(s,c)):(L(s,c),L(s,i.left),L(i.right,a)),{left:a,right:c}}function j(e,t,n,r,i){let a=r.left,o=r.right,s=R(e,t,n,{type:10});M(e,s);let c=R(e,t,n,{type:12}),l=R(e,t,n,{type:9});return s.loopback=l,c.loopback=l,L(s,a),L(s,c),L(o,l),i===void 0?L(l,s):(L(l,c),L(l,i.left),L(i.right,a)),e.decisionMap[x(t,i?`RepetitionWithSeparator`:`Repetition`,n.idx)]=s,{left:s,right:c}}function oe(e,t,n,r){let i=r.left,a=r.right;return L(i,a),e.decisionMap[x(t,`Option`,n.idx)]=i,r}function M(e,t){return e.decisionStates.push(t),t.decision=e.decisionStates.length-1,t.decision}function N(e,t,n,r,...i){let a=R(e,t,r,{type:8,start:n});n.end=a;for(let e of i)e===void 0?L(n,a):(L(n,e.left),L(e.right,a));let o={left:n,right:a};return e.decisionMap[x(t,P(r),r.idx)]=n,o}function P(e){if(e instanceof h)return`Alternation`;if(e instanceof m)return`Option`;if(e instanceof v)return`Repetition`;if(e instanceof g)return`RepetitionWithSeparator`;if(e instanceof d)return`RepetitionMandatory`;if(e instanceof f)return`RepetitionMandatoryWithSeparator`;throw Error(`Invalid production type encountered`)}function F(e,t){let n=t.length;for(let r=0;r<n-1;r++){let n=t[r],i;n.left.transitions.length===1&&(i=n.left.transitions[0]);let a=i instanceof T,o=i,s=t[r+1].left;n.left.type===1&&n.right.type===1&&i!==void 0&&(a&&o.followState===n.right||i.target===n.right)?(a?o.followState=s:i.target=s,B(e,n.right)):L(n.right,s)}let r=t[0],i=t[n-1];return{left:r.left,right:i.right}}function I(e,t,n,r){let i=R(e,t,r,{type:1}),a=R(e,t,r,{type:1});return z(i,new C(a,n)),{left:i,right:a}}function se(e,t,n){let r=n.referencedRule,i=e.ruleToStartState.get(r),a=R(e,t,n,{type:1}),o=R(e,t,n,{type:1});return z(a,new T(i,r,o)),{left:a,right:o}}function ce(e,t,n){let r=e.ruleToStartState.get(t);L(r,n.left);let i=e.ruleToStopState.get(t);return L(n.right,i),{left:r,right:i}}function L(e,t){z(e,new w(t))}function R(e,t,n,r){let i=Object.assign({atn:e,production:n,epsilonOnlyTransitions:!1,rule:t,transitions:[],nextTokenWithinRule:[],stateNumber:e.states.length},r);return e.states.push(i),i}function z(e,t){e.transitions.length===0&&(e.epsilonOnlyTransitions=t.isEpsilon()),e.transitions.push(t)}function B(e,t){e.states.splice(e.states.indexOf(t),1)}const V={};var H=class{constructor(){this.map={},this.configs=[]}get size(){return this.configs.length}finalize(){this.map={}}add(e){let t=U(e);t in this.map||(this.map[t]=this.configs.length,this.configs.push(e))}get elements(){return this.configs}get alts(){return c(this.configs,e=>e.alt)}get key(){let e=``;for(let t in this.map)e+=t+`:`;return e}};function U(e,t=!0){return`${t?`a${e.alt}`:``}s${e.state.stateNumber}:${e.stack.map(e=>e.stateNumber.toString()).join(`_`)}`}function W(e,t){let n={};return r=>{let i=r.toString(),a=n[i];return a===void 0?(a={atnStartState:e,decision:t,states:{}},n[i]=a,a):a}}var G=class{constructor(){this.predicates=[]}is(e){return e>=this.predicates.length||this.predicates[e]}set(e,t){this.predicates[e]=t}toString(){let e=``,t=this.predicates.length;for(let n=0;n<t;n++)e+=this.predicates[n]===!0?`1`:`0`;return e}};const K=new G;var le=class extends n{constructor(e){super(),this.logging=e?.logging??(e=>console.log(e))}initialize(e){this.atn=ee(e.rules),this.dfas=J(this.atn)}validateAmbiguousAlternationAlternatives(){return[]}validateEmptyOrAlternatives(){return[]}buildLookaheadForAlternation(t){let{prodOccurrence:n,rule:r,hasPredicates:i,dynamicTokensEnabled:a}=t,o=this.dfas,s=this.logging,l=x(r,`Alternation`,n),u=this.atn.decisionMap[l].decision,d=c(e({maxLookahead:1,occurrence:n,prodType:`Alternation`,rule:r}),e=>c(e,e=>e[0]));if(q(d,!1)&&!a){let e=y(d,(e,t,n)=>(b(t,t=>{t&&(e[t.tokenTypeIdx]=n,b(t.categoryMatches,t=>{e[t]=n}))}),e),{});return i?function(t){let n=e[this.LA(1).tokenTypeIdx];if(t!==void 0&&n!==void 0){let e=t[n]?.GATE;if(e!==void 0&&e.call(this)===!1)return}return n}:function(){return e[this.LA(1).tokenTypeIdx]}}else if(i)return function(e){let t=new G,n=e===void 0?0:e.length;for(let r=0;r<n;r++){let n=e?.[r].GATE;t.set(r,n===void 0||n.call(this))}let r=Y.call(this,o,u,t,s);return typeof r==`number`?r:void 0};else return function(){let e=Y.call(this,o,u,K,s);return typeof e==`number`?e:void 0}}buildLookaheadForOptional(t){let{prodOccurrence:n,rule:r,prodType:i,dynamicTokensEnabled:o}=t,s=this.dfas,l=this.logging,u=x(r,i,n),d=this.atn.decisionMap[u].decision,f=c(e({maxLookahead:1,occurrence:n,prodType:i,rule:r}),e=>c(e,e=>e[0]));if(q(f)&&f[0][0]&&!o){let e=f[0],t=_(e);if(t.length===1&&a(t[0].categoryMatches)){let e=t[0].tokenTypeIdx;return function(){return this.LA(1).tokenTypeIdx===e}}else{let e=y(t,(e,t)=>(t!==void 0&&(e[t.tokenTypeIdx]=!0,b(t.categoryMatches,t=>{e[t]=!0})),e),{});return function(){return e[this.LA(1).tokenTypeIdx]===!0}}}return function(){let e=Y.call(this,s,d,K,l);return typeof e==`object`?!1:e===0}}};function q(e,t=!0){let n=new Set;for(let r of e){let e=new Set;for(let i of r){if(i===void 0){if(t)break;return!1}let r=[i.tokenTypeIdx].concat(i.categoryMatches);for(let t of r)if(n.has(t)){if(!e.has(t))return!1}else n.add(t),e.add(t)}}return!0}function J(e){let t=e.decisionStates.length,n=Array(t);for(let r=0;r<t;r++)n[r]=W(e.decisionStates[r],r);return n}function Y(e,t,n,r){let i=e[t](n),a=i.start;return a===void 0&&(a=Q(i,X(be(i.atnStartState))),i.start=a),ue.apply(this,[i,a,n,r])}function ue(e,t,n,r){let i=t,a=1,o=[],s=this.LA(a++);for(;;){let t=ge(i,s);if(t===void 0&&(t=de.apply(this,[e,i,s,a,n,r])),t===V)return he(o,i,s);if(t.isAcceptState===!0)return t.prediction;i=t,o.push(s),s=this.LA(a++)}}function de(e,t,n,r,a,o){let s=_e(t.configs,n,a);if(s.size===0)return Z(e,t,n,V),V;let c=X(s),l=ye(s,a);if(l!==void 0)c.isAcceptState=!0,c.prediction=l,c.configs.uniqueAlt=l;else if(we(s)){let t=i(s.alts);c.isAcceptState=!0,c.prediction=t,c.configs.uniqueAlt=t,fe.apply(this,[e,r,s.alts,o])}return c=Z(e,t,n,c),c}function fe(e,t,n,r){let i=[];for(let e=1;e<=t;e++)i.push(this.LA(e).tokenType);let a=e.atnStartState,o=a.rule,s=a.production;r(pe({topLevelRule:o,ambiguityIndices:n,production:s,prefixPath:i}))}function pe(e){let n=c(e.prefixPath,e=>t(e)).join(`, `),r=e.production.idx===0?``:e.production.idx,i=`Ambiguous Alternatives Detected: <${e.ambiguityIndices.join(`, `)}> in <${me(e.production)}${r}> inside <${e.topLevelRule.name}> Rule,\n<${n}> may appears as a prefix path in all these alternatives.\n`;return i+=`See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#AMBIGUOUS_ALTERNATIVES
2
+ For Further details.`,i}function me(e){if(e instanceof u)return`SUBRULE`;if(e instanceof m)return`OPTION`;if(e instanceof h)return`OR`;if(e instanceof d)return`AT_LEAST_ONE`;if(e instanceof f)return`AT_LEAST_ONE_SEP`;if(e instanceof g)return`MANY_SEP`;if(e instanceof v)return`MANY`;if(e instanceof p)return`CONSUME`;throw Error(`non exhaustive match`)}function he(e,t,n){return{actualToken:n,possibleTokenTypes:l(s(t.configs.elements,e=>e.state.transitions).filter(e=>e instanceof C).map(e=>e.tokenType),e=>e.tokenTypeIdx),tokenPath:e}}function ge(e,t){return e.edges[t.tokenTypeIdx]}function _e(e,t,n){let r=new H,i=[];for(let a of e.elements){if(n.is(a.alt)===!1)continue;if(a.state.type===7){i.push(a);continue}let e=a.state.transitions.length;for(let n=0;n<e;n++){let e=a.state.transitions[n],i=ve(e,t);i!==void 0&&r.add({state:i,alt:a.alt,stack:a.stack})}}let a;if(i.length===0&&r.size===1&&(a=r),a===void 0){a=new H;for(let e of r.elements)$(e,a)}if(i.length>0&&!Se(a))for(let e of i)a.add(e);return a}function ve(e,t){if(e instanceof C&&r(t,e.tokenType))return e.target}function ye(e,t){let n;for(let r of e.elements)if(t.is(r.alt)===!0){if(n===void 0)n=r.alt;else if(n!==r.alt)return}return n}function X(e){return{configs:e,edges:{},isAcceptState:!1,prediction:-1}}function Z(e,t,n,r){return r=Q(e,r),t.edges[n.tokenTypeIdx]=r,r}function Q(e,t){if(t===V)return t;let n=t.configs.key,r=e.states[n];return r===void 0?(t.configs.finalize(),e.states[n]=t,t):r}function be(e){let t=new H,n=e.transitions.length;for(let r=0;r<n;r++)$({state:e.transitions[r].target,alt:r,stack:[]},t);return t}function $(e,t){let n=e.state;if(n.type===7){if(e.stack.length>0){let n=[...e.stack];$({state:n.pop(),alt:e.alt,stack:n},t)}else t.add(e);return}n.epsilonOnlyTransitions||t.add(e);let r=n.transitions.length;for(let i=0;i<r;i++){let r=n.transitions[i],a=xe(e,r);a!==void 0&&$(a,t)}}function xe(e,t){if(t instanceof w)return{state:t.target,alt:e.alt,stack:e.stack};if(t instanceof T){let n=[...e.stack,t.followState];return{state:t.target,alt:e.alt,stack:n}}}function Se(e){for(let t of e.elements)if(t.state.type===7)return!0;return!1}function Ce(e){for(let t of e.elements)if(t.state.type!==7)return!1;return!0}function we(e){if(Ce(e))return!0;let t=Te(e.elements);return Ee(t)&&!De(t)}function Te(e){let t=new Map;for(let n of e){let e=U(n,!1),r=t.get(e);r===void 0&&(r={},t.set(e,r)),r[n.alt]=!0}return t}function Ee(e){for(let t of Array.from(e.values()))if(Object.keys(t).length>1)return!0;return!1}function De(e){for(let t of Array.from(e.values()))if(Object.keys(t).length===1)return!0;return!1}export{le as t};