@dbml/parse 3.9.5 → 3.9.7-alpha.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 (68) hide show
  1. package/LICENSE +0 -0
  2. package/dist/compiler.d.ts +0 -0
  3. package/dist/constants.d.ts +0 -0
  4. package/dist/dbml-parse.js +8 -8
  5. package/dist/dbml-parse.mjs +723 -699
  6. package/dist/index.d.ts +0 -0
  7. package/dist/lib/analyzer/analyzer.d.ts +0 -0
  8. package/dist/lib/analyzer/binder/binder.d.ts +0 -0
  9. package/dist/lib/analyzer/binder/elementBinder/custom.d.ts +0 -0
  10. package/dist/lib/analyzer/binder/elementBinder/elementBinder.d.ts +0 -0
  11. package/dist/lib/analyzer/binder/elementBinder/enum.d.ts +0 -0
  12. package/dist/lib/analyzer/binder/elementBinder/indexes.d.ts +0 -0
  13. package/dist/lib/analyzer/binder/elementBinder/note.d.ts +0 -0
  14. package/dist/lib/analyzer/binder/elementBinder/project.d.ts +0 -0
  15. package/dist/lib/analyzer/binder/elementBinder/ref.d.ts +0 -0
  16. package/dist/lib/analyzer/binder/elementBinder/table.d.ts +0 -0
  17. package/dist/lib/analyzer/binder/elementBinder/tableGroup.d.ts +0 -0
  18. package/dist/lib/analyzer/binder/types.d.ts +0 -0
  19. package/dist/lib/analyzer/binder/utils.d.ts +0 -0
  20. package/dist/lib/analyzer/symbol/factory.d.ts +0 -0
  21. package/dist/lib/analyzer/symbol/symbolIndex.d.ts +0 -0
  22. package/dist/lib/analyzer/symbol/symbolTable.d.ts +0 -0
  23. package/dist/lib/analyzer/symbol/symbols.d.ts +0 -0
  24. package/dist/lib/analyzer/symbol/utils.d.ts +0 -0
  25. package/dist/lib/analyzer/types.d.ts +0 -0
  26. package/dist/lib/analyzer/utils.d.ts +0 -0
  27. package/dist/lib/analyzer/validator/elementValidators/custom.d.ts +0 -0
  28. package/dist/lib/analyzer/validator/elementValidators/enum.d.ts +0 -0
  29. package/dist/lib/analyzer/validator/elementValidators/indexes.d.ts +0 -0
  30. package/dist/lib/analyzer/validator/elementValidators/note.d.ts +0 -0
  31. package/dist/lib/analyzer/validator/elementValidators/project.d.ts +0 -0
  32. package/dist/lib/analyzer/validator/elementValidators/ref.d.ts +0 -0
  33. package/dist/lib/analyzer/validator/elementValidators/table.d.ts +0 -0
  34. package/dist/lib/analyzer/validator/elementValidators/tableGroup.d.ts +0 -0
  35. package/dist/lib/analyzer/validator/types.d.ts +0 -0
  36. package/dist/lib/analyzer/validator/utils.d.ts +0 -0
  37. package/dist/lib/analyzer/validator/validator.d.ts +0 -0
  38. package/dist/lib/errors.d.ts +0 -0
  39. package/dist/lib/interpreter/elementInterpreter/enum.d.ts +0 -0
  40. package/dist/lib/interpreter/elementInterpreter/project.d.ts +0 -0
  41. package/dist/lib/interpreter/elementInterpreter/ref.d.ts +1 -0
  42. package/dist/lib/interpreter/elementInterpreter/sticky_note.d.ts +0 -0
  43. package/dist/lib/interpreter/elementInterpreter/table.d.ts +0 -0
  44. package/dist/lib/interpreter/elementInterpreter/tableGroup.d.ts +0 -0
  45. package/dist/lib/interpreter/interpreter.d.ts +0 -0
  46. package/dist/lib/interpreter/types.d.ts +1 -0
  47. package/dist/lib/interpreter/utils.d.ts +0 -0
  48. package/dist/lib/lexer/lexer.d.ts +0 -0
  49. package/dist/lib/lexer/tokens.d.ts +0 -0
  50. package/dist/lib/lexer/utils.d.ts +0 -0
  51. package/dist/lib/option.d.ts +0 -0
  52. package/dist/lib/parser/contextStack.d.ts +0 -0
  53. package/dist/lib/parser/factory.d.ts +0 -0
  54. package/dist/lib/parser/nodes.d.ts +0 -0
  55. package/dist/lib/parser/parser.d.ts +0 -0
  56. package/dist/lib/parser/utils.d.ts +0 -0
  57. package/dist/lib/report.d.ts +0 -0
  58. package/dist/lib/serialization/serialize.d.ts +0 -0
  59. package/dist/lib/types.d.ts +0 -0
  60. package/dist/lib/utils.d.ts +0 -0
  61. package/dist/services/definition/provider.d.ts +0 -0
  62. package/dist/services/index.d.ts +0 -0
  63. package/dist/services/references/provider.d.ts +0 -0
  64. package/dist/services/suggestions/provider.d.ts +0 -0
  65. package/dist/services/suggestions/utils.d.ts +0 -0
  66. package/dist/services/types.d.ts +0 -0
  67. package/dist/services/utils.d.ts +0 -0
  68. package/package.json +2 -2
@@ -1,6 +1,6 @@
1
- import I, { partition as Yt, findLastIndex as zt, last as rt } from "lodash";
1
+ import I, { last as Xe, partition as zt, findLastIndex as Qt } from "lodash";
2
2
  var u = /* @__PURE__ */ ((t) => (t.SPACE = "<space>", t.TAB = "<tab>", t.NEWLINE = "<newline>", t.COMMA = "<comma>", t.LPAREN = "<lparen>", t.RPAREN = "<rparen>", t.LBRACE = "<lbrace>", t.RBRACE = "<rbrace>", t.LBRACKET = "<lbracket>", t.RBRACKET = "<rbracket>", t.LANGLE = "<langle>", t.RANGLE = "<rangle>", t.OP = "<op>", t.EOF = "<eof>", t.NUMERIC_LITERAL = "<number>", t.STRING_LITERAL = "<string>", t.COLOR_LITERAL = "<color>", t.FUNCTION_EXPRESSION = "<function-expression>", t.QUOTED_STRING = "<variable>", t.IDENTIFIER = "<identifier>", t.SEMICOLON = "<semicolon>", t.COLON = "<colon>", t.SINGLE_LINE_COMMENT = "<single-line-comment>", t.MULTILINE_COMMENT = "<multiline-comment>", t))(u || {});
3
- function Qt(t) {
3
+ function qt(t) {
4
4
  switch (t.kind) {
5
5
  case "<newline>":
6
6
  case "<space>":
@@ -12,7 +12,7 @@ function Qt(t) {
12
12
  return !1;
13
13
  }
14
14
  }
15
- function at(t) {
15
+ function ot(t) {
16
16
  if (!t)
17
17
  return !1;
18
18
  switch (t) {
@@ -33,38 +33,38 @@ function at(t) {
33
33
  return !1;
34
34
  }
35
35
  }
36
- function ot(t) {
36
+ function lt(t) {
37
37
  return t !== void 0 && t.kind === "<op>";
38
38
  }
39
- class F {
39
+ class V {
40
40
  constructor(e, n, s, i, r) {
41
41
  this.kind = e, this.startPos = n, this.endPos = s, this.value = i, this.leadingTrivia = [], this.trailingTrivia = [], this.leadingInvalid = [], this.trailingInvalid = [], this.isInvalid = r, this.start = n.offset, this.end = s.offset;
42
42
  }
43
43
  static create(e, n, s, i, r) {
44
- return new F(e, n, s, i, r);
44
+ return new V(e, n, s, i, r);
45
45
  }
46
46
  }
47
- function It(t) {
47
+ function Lt(t) {
48
48
  return t.trailingTrivia.find(({ kind: e }) => e === u.NEWLINE) !== void 0;
49
49
  }
50
- function lt(t, e) {
51
- return e.leadingTrivia.find(({ kind: s }) => s === u.NEWLINE) !== void 0 || It(t);
52
- }
53
- function Ce(t) {
54
- return t.trailingTrivia.find(({ kind: e }) => e === u.SPACE) !== void 0;
50
+ function ct(t, e) {
51
+ return e.leadingTrivia.find(({ kind: s }) => s === u.NEWLINE) !== void 0 || Lt(t);
55
52
  }
56
- function Lt(t) {
57
- return t.trailingTrivia.length === 0 ? t.end : Lt(I.last(t.trailingTrivia));
53
+ function $e(t) {
54
+ return t.trailingTrivia.find(({ kind: e }) => [u.SPACE, u.TAB].includes(e)) !== void 0;
58
55
  }
59
56
  function gt(t) {
60
- return t.leadingTrivia.length === 0 ? t.start : gt(t.leadingTrivia[0]);
57
+ return t.trailingTrivia.length === 0 ? t.end : gt(Xe(t.trailingTrivia));
61
58
  }
62
- function qt(t) {
59
+ function _t(t) {
60
+ return t.leadingTrivia.length === 0 ? t.start : _t(t.leadingTrivia[0]);
61
+ }
62
+ function Ht(t) {
63
63
  return [u.SINGLE_LINE_COMMENT, u.MULTILINE_COMMENT].includes(
64
64
  t.kind
65
65
  );
66
66
  }
67
- class Ht {
67
+ class Jt {
68
68
  constructor() {
69
69
  this.id = 0;
70
70
  }
@@ -75,19 +75,19 @@ class Ht {
75
75
  return this.id++;
76
76
  }
77
77
  }
78
- class x {
78
+ class k {
79
79
  // The symbol that this syntax node refers to
80
80
  // args must be passed in order of appearance in the node
81
81
  constructor(e, n, s) {
82
82
  this.id = e, this.kind = n;
83
83
  const i = s.find((a) => a !== void 0 && !Number.isNaN(a.start));
84
- i ? (this.startPos = i.startPos, this.fullStart = i instanceof F ? gt(i) : i.fullStart) : (this.startPos = {
84
+ i ? (this.startPos = i.startPos, this.fullStart = i instanceof V ? _t(i) : i.fullStart) : (this.startPos = {
85
85
  offset: NaN,
86
86
  column: NaN,
87
87
  line: NaN
88
88
  }, this.fullStart = NaN);
89
89
  const r = [...s].reverse().find((a) => a !== void 0 && !Number.isNaN(a.end));
90
- r ? (this.endPos = r.endPos, this.fullEnd = r instanceof F ? Lt(r) : r.fullEnd) : (this.endPos = {
90
+ r ? (this.endPos = r.endPos, this.fullEnd = r instanceof V ? gt(r) : r.fullEnd) : (this.endPos = {
91
91
  offset: NaN,
92
92
  column: NaN,
93
93
  line: NaN
@@ -95,12 +95,12 @@ class x {
95
95
  }
96
96
  }
97
97
  var Ne = /* @__PURE__ */ ((t) => (t.PROGRAM = "<program>", t.ELEMENT_DECLARATION = "<element-declaration>", t.ATTRIBUTE = "<attribute>", t.IDENTIFIER_STREAM = "<identifer-stream>", t.LITERAL = "<literal>", t.VARIABLE = "<variable>", t.PREFIX_EXPRESSION = "<prefix-expression>", t.INFIX_EXPRESSION = "<infix-expression>", t.POSTFIX_EXPRESSION = "<postfix-expression>", t.FUNCTION_EXPRESSION = "<function-expression>", t.FUNCTION_APPLICATION = "<function-application>", t.BLOCK_EXPRESSION = "<block-expression>", t.LIST_EXPRESSION = "<list-expression>", t.TUPLE_EXPRESSION = "<tuple-expression>", t.CALL_EXPRESSION = "<call-expression>", t.PRIMARY_EXPRESSION = "<primary-expression>", t.GROUP_EXPRESSION = "<group-expression>", t.DUMMY = "<dummy>", t.ARRAY = "<array>", t))(Ne || {});
98
- class X extends x {
98
+ class $ extends k {
99
99
  constructor({ body: e = [], eof: n }, s) {
100
100
  super(s, "<program>", [...e, n]), this.body = e, this.eof = n;
101
101
  }
102
102
  }
103
- class v extends x {
103
+ class A extends k {
104
104
  constructor({
105
105
  type: e,
106
106
  name: n,
@@ -118,17 +118,17 @@ class v extends x {
118
118
  r,
119
119
  a,
120
120
  l
121
- ]), l && a && !(l instanceof w || l instanceof v))
121
+ ]), l && a && !(l instanceof v || l instanceof A))
122
122
  throw new Error("If an element has a simple body, it must be a function application node");
123
123
  this.type = e, this.name = n, this.as = s, this.alias = i, this.attributeList = r, this.bodyColon = a, this.body = l;
124
124
  }
125
125
  }
126
- class Y extends x {
126
+ class z extends k {
127
127
  constructor({ identifiers: e = [] }, n) {
128
128
  super(n, "<identifer-stream>", e || []), this.identifiers = e;
129
129
  }
130
130
  }
131
- class se extends x {
131
+ class ie extends k {
132
132
  constructor({
133
133
  name: e,
134
134
  colon: n,
@@ -137,12 +137,12 @@ class se extends x {
137
137
  super(i, "<attribute>", [e, n, s]), this.name = e, this.value = s, this.colon = n;
138
138
  }
139
139
  }
140
- class Q extends x {
140
+ class q extends k {
141
141
  constructor({ op: e, expression: n }, s) {
142
142
  super(s, "<prefix-expression>", [e, n]), this.op = e, this.expression = n;
143
143
  }
144
144
  }
145
- class q extends x {
145
+ class H extends k {
146
146
  constructor({
147
147
  op: e,
148
148
  leftExpression: n,
@@ -151,22 +151,22 @@ class q extends x {
151
151
  super(i, "<infix-expression>", [n, e, s]), this.op = e, this.leftExpression = n, this.rightExpression = s;
152
152
  }
153
153
  }
154
- class Ue extends x {
154
+ class Ue extends k {
155
155
  constructor({ op: e, expression: n }, s) {
156
156
  super(s, "<postfix-expression>", [n, e]), this.op = e, this.expression = n;
157
157
  }
158
158
  }
159
- class ne extends x {
159
+ class se extends k {
160
160
  constructor({ value: e }, n) {
161
161
  super(n, "<function-expression>", [e]), this.value = e;
162
162
  }
163
163
  }
164
- class w extends x {
164
+ class v extends k {
165
165
  constructor({ callee: e, args: n = [] }, s) {
166
166
  super(s, "<function-application>", [e, ...n]), this.callee = e, this.args = n;
167
167
  }
168
168
  }
169
- class J extends x {
169
+ class Z extends k {
170
170
  constructor({
171
171
  blockOpenBrace: e,
172
172
  body: n = [],
@@ -175,7 +175,7 @@ class J extends x {
175
175
  super(i, "<block-expression>", [e, ...n, s]), this.blockOpenBrace = e, this.body = n, this.blockCloseBrace = s;
176
176
  }
177
177
  }
178
- class R extends x {
178
+ class P extends k {
179
179
  constructor({
180
180
  listOpenBracket: e,
181
181
  elementList: n = [],
@@ -184,12 +184,12 @@ class R extends x {
184
184
  }, r) {
185
185
  super(r, "<list-expression>", [
186
186
  e,
187
- ..._t(n, s),
187
+ ...At(n, s),
188
188
  i
189
189
  ]), this.listOpenBracket = e, this.elementList = n, this.commaList = s, this.listCloseBracket = i;
190
190
  }
191
191
  }
192
- class Z extends x {
192
+ class K extends k {
193
193
  constructor({
194
194
  tupleOpenParen: e,
195
195
  elementList: n = [],
@@ -198,12 +198,12 @@ class Z extends x {
198
198
  }, r) {
199
199
  super(r, "<tuple-expression>", [
200
200
  e,
201
- ..._t(n, s),
201
+ ...At(n, s),
202
202
  i
203
203
  ]), this.tupleOpenParen = e, this.elementList = n, this.commaList = s, this.tupleCloseParen = i;
204
204
  }
205
205
  }
206
- class We extends Z {
206
+ class Ye extends K {
207
207
  constructor({
208
208
  groupOpenParen: e,
209
209
  expression: n,
@@ -220,7 +220,7 @@ class We extends Z {
220
220
  ), this.kind = "<group-expression>";
221
221
  }
222
222
  }
223
- class H extends x {
223
+ class J extends k {
224
224
  constructor({
225
225
  callee: e,
226
226
  argumentList: n
@@ -228,33 +228,33 @@ class H extends x {
228
228
  super(s, "<call-expression>", [e, n]), this.callee = e, this.argumentList = n;
229
229
  }
230
230
  }
231
- class be extends x {
231
+ class be extends k {
232
232
  constructor({ literal: e }, n) {
233
233
  super(n, "<literal>", [e]), this.literal = e;
234
234
  }
235
235
  }
236
- class K extends x {
236
+ class ee extends k {
237
237
  constructor({ variable: e }, n) {
238
238
  super(n, "<variable>", [e]), this.variable = e;
239
239
  }
240
240
  }
241
- class U extends x {
241
+ class F extends k {
242
242
  constructor({ expression: e }, n) {
243
243
  super(n, "<primary-expression>", [e]), this.expression = e;
244
244
  }
245
245
  }
246
- class xe extends x {
246
+ class xe extends k {
247
247
  constructor({ pre: e }, n) {
248
- const s = F.create(u.SPACE, e.endPos, e.endPos, " ", !1);
248
+ const s = V.create(u.SPACE, e.endPos, e.endPos, " ", !1);
249
249
  super(n, "<dummy>", [s]);
250
250
  }
251
251
  }
252
- class he extends x {
252
+ class he extends k {
253
253
  constructor({ expression: e, indexer: n }, s) {
254
254
  super(s, "<array>", [e, n]), this.array = e, this.indexer = n;
255
255
  }
256
256
  }
257
- function _t(t, e) {
257
+ function At(t, e) {
258
258
  if (!t || t.length === 0)
259
259
  return e || [];
260
260
  if (!e || e.length === 0)
@@ -264,12 +264,12 @@ function _t(t, e) {
264
264
  (i) => i !== null
265
265
  );
266
266
  }
267
- function us(t, e = !1) {
267
+ function hs(t, e = !1) {
268
268
  return JSON.stringify(
269
269
  t,
270
270
  function(n, s) {
271
271
  var i;
272
- return !(this instanceof X) && n === "symbol" ? s == null ? void 0 : s.id : (
272
+ return !(this instanceof $) && n === "symbol" ? s == null ? void 0 : s.id : (
273
273
  /* this instanceof SyntaxNode && */
274
274
  n === "symbol" ? {
275
275
  symbolTable: s == null ? void 0 : s.symbolTable,
@@ -290,7 +290,7 @@ function us(t, e = !1) {
290
290
  e ? 2 : 0
291
291
  );
292
292
  }
293
- class S {
293
+ class x {
294
294
  constructor(e) {
295
295
  this.value = e;
296
296
  }
@@ -305,14 +305,14 @@ class S {
305
305
  return e(this.value);
306
306
  }
307
307
  map(e) {
308
- return new S(e(this.value));
308
+ return new x(e(this.value));
309
309
  }
310
310
  // eslint-disable-next-line class-methods-use-this
311
311
  isOk() {
312
312
  return !0;
313
313
  }
314
314
  }
315
- class k {
315
+ class y {
316
316
  // eslint-disable-next-line class-methods-use-this
317
317
  unwrap() {
318
318
  throw new Error("Trying to unwrap a None value");
@@ -323,11 +323,11 @@ class k {
323
323
  }
324
324
  // eslint-disable-next-line @typescript-eslint/no-unused-vars, class-methods-use-this
325
325
  and_then(e) {
326
- return new k();
326
+ return new y();
327
327
  }
328
328
  // eslint-disable-next-line @typescript-eslint/no-unused-vars, class-methods-use-this
329
329
  map(e) {
330
- return new k();
330
+ return new y();
331
331
  }
332
332
  // eslint-disable-next-line class-methods-use-this
333
333
  isOk() {
@@ -335,73 +335,73 @@ class k {
335
335
  }
336
336
  }
337
337
  var T = /* @__PURE__ */ ((t) => (t.Schema = "Schema", t.Table = "Table", t.Column = "Column", t.TableGroup = "TableGroup", t.TableGroupField = "TableGroup field", t.Enum = "Enum", t.EnumField = "Enum field", t.Note = "Note", t))(T || {});
338
- function je(t) {
338
+ function ze(t) {
339
339
  return `Schema:${t}`;
340
340
  }
341
341
  function Oe(t) {
342
342
  return `Table:${t}`;
343
343
  }
344
- function Ye(t) {
344
+ function Qe(t) {
345
345
  return `Column:${t}`;
346
346
  }
347
- function ze(t) {
347
+ function qe(t) {
348
348
  return `Enum:${t}`;
349
349
  }
350
- function Qe(t) {
350
+ function He(t) {
351
351
  return `Enum field:${t}`;
352
352
  }
353
- function qe(t) {
353
+ function Je(t) {
354
354
  return `TableGroup:${t}`;
355
355
  }
356
- function He(t) {
356
+ function Ze(t) {
357
357
  return `TableGroup field:${t}`;
358
358
  }
359
- function Jt(t) {
359
+ function Zt(t) {
360
360
  return `Note:${t}`;
361
361
  }
362
- function Ve(t, e) {
362
+ function Ge(t, e) {
363
363
  switch (e) {
364
364
  case "Column":
365
- return Ye(t);
365
+ return Qe(t);
366
366
  case "Enum":
367
- return ze(t);
367
+ return qe(t);
368
368
  case "Enum field":
369
- return Qe(t);
369
+ return He(t);
370
370
  case "Schema":
371
- return je(t);
371
+ return ze(t);
372
372
  case "Table":
373
373
  return Oe(t);
374
374
  case "TableGroup":
375
- return qe(t);
375
+ return Je(t);
376
376
  case "TableGroup field":
377
- return He(t);
377
+ return Ze(t);
378
378
  default:
379
379
  throw new Error("Unreachable");
380
380
  }
381
381
  }
382
- function ie(t) {
382
+ function re(t) {
383
383
  const [e, n] = t.split(":");
384
- return Object.values(T).includes(e) ? new S({
384
+ return Object.values(T).includes(e) ? new x({
385
385
  name: n,
386
386
  kind: e
387
- }) : new k();
387
+ }) : new y();
388
388
  }
389
- function Zt(t) {
390
- const e = ie(t).unwrap_or(void 0);
389
+ function Kt(t) {
390
+ const e = re(t).unwrap_or(void 0);
391
391
  if (!e)
392
392
  return !1;
393
393
  const { kind: n, name: s } = e;
394
394
  return n === "Schema" && s === "public";
395
395
  }
396
- function Kt(t) {
396
+ function en(t) {
397
397
  return [
398
- je,
399
- Oe,
400
398
  ze,
399
+ Oe,
401
400
  qe,
402
- Ye,
401
+ Je,
403
402
  Qe,
404
- He
403
+ He,
404
+ Ze
405
405
  ].map((e) => e(t));
406
406
  }
407
407
  function Me(t) {
@@ -411,14 +411,14 @@ function De(t) {
411
411
  const [e] = t;
412
412
  return e >= "0" && e <= "9";
413
413
  }
414
- function en(t) {
414
+ function tn(t) {
415
415
  const [e] = t;
416
416
  return De(e) || Me(e) && e.toLowerCase() >= "a" && e.toLowerCase() <= "f";
417
417
  }
418
418
  function Ee(t) {
419
419
  return Me(t) || De(t);
420
420
  }
421
- function ct(t, e) {
421
+ function ut(t, e) {
422
422
  const n = [], s = Math.min(t.length, e.length);
423
423
  for (let i = 0; i < s; i += 1)
424
424
  n.push(t[i], e[i]);
@@ -427,7 +427,7 @@ function ct(t, e) {
427
427
  function ge(t, e) {
428
428
  return t >= e.start && t < e.end;
429
429
  }
430
- class tn {
430
+ class nn {
431
431
  constructor() {
432
432
  this.id = 0;
433
433
  }
@@ -438,37 +438,37 @@ class tn {
438
438
  return this.id++;
439
439
  }
440
440
  }
441
- class At {
441
+ class vt {
442
442
  constructor({ symbolTable: e }, n) {
443
443
  this.references = [], this.id = n, this.symbolTable = e;
444
444
  }
445
445
  }
446
- class nn {
446
+ class sn {
447
447
  constructor({ symbolTable: e, declaration: n }, s) {
448
448
  this.references = [], this.id = s, this.symbolTable = e, this.declaration = n;
449
449
  }
450
450
  }
451
- class sn {
451
+ class rn {
452
452
  constructor({ declaration: e }, n) {
453
453
  this.references = [], this.id = n, this.declaration = e;
454
454
  }
455
455
  }
456
- class vt {
456
+ class wt {
457
457
  constructor({ symbolTable: e, declaration: n }, s) {
458
458
  this.references = [], this.id = s, this.symbolTable = e, this.declaration = n;
459
459
  }
460
460
  }
461
- class rn {
461
+ class an {
462
462
  constructor({ declaration: e }, n) {
463
463
  this.references = [], this.id = n, this.declaration = e;
464
464
  }
465
465
  }
466
- class an {
466
+ class on {
467
467
  constructor({ symbolTable: e, declaration: n }, s) {
468
468
  this.references = [], this.id = s, this.symbolTable = e, this.declaration = n;
469
469
  }
470
470
  }
471
- class on {
471
+ class ln {
472
472
  constructor({ declaration: e }, n) {
473
473
  this.references = [], this.id = n, this.declaration = e;
474
474
  }
@@ -479,7 +479,7 @@ class c extends Error {
479
479
  super(n), this.code = e, this.diagnostic = n, this.nodeOrToken = s, this.start = s.start, this.end = s.end, this.name = this.constructor.name, Object.setPrototypeOf(this, c.prototype);
480
480
  }
481
481
  }
482
- class V {
482
+ class G {
483
483
  constructor(e, n) {
484
484
  this.value = e, this.errors = n === void 0 ? [] : n;
485
485
  }
@@ -491,97 +491,97 @@ class V {
491
491
  }
492
492
  chain(e) {
493
493
  const n = e(this.value), s = [...this.errors, ...n.errors];
494
- return new V(n.value, s);
494
+ return new G(n.value, s);
495
495
  }
496
496
  map(e) {
497
- return new V(e(this.value), this.errors);
497
+ return new G(e(this.value), this.errors);
498
498
  }
499
499
  }
500
- function ln(t, e, n) {
500
+ function cn(t, e, n) {
501
501
  if (!t || !me(t) || e.length === 0)
502
- return new k();
503
- const s = [...e], i = Ge(t).unwrap(), r = s.pop();
504
- if (!(r instanceof J))
505
- return new k();
506
- const a = I.last(s) instanceof R ? s.pop() : void 0;
507
- return s.length === 3 && Ge(s[1]).unwrap().value === "as" ? new S(
508
- n.create(v, {
502
+ return new y();
503
+ const s = [...e], i = Ce(t).unwrap(), r = s.pop();
504
+ if (!(r instanceof Z))
505
+ return new y();
506
+ const a = I.last(s) instanceof P ? s.pop() : void 0;
507
+ return s.length === 3 && Ce(s[1]).unwrap().value === "as" ? new x(
508
+ n.create(A, {
509
509
  type: i,
510
510
  name: s[0],
511
- as: Ge(s[1]).unwrap(),
511
+ as: Ce(s[1]).unwrap(),
512
512
  alias: s[2],
513
513
  attributeList: a,
514
514
  body: r
515
515
  })
516
- ) : s.length === 1 ? new S(
517
- n.create(v, {
516
+ ) : s.length === 1 ? new x(
517
+ n.create(A, {
518
518
  type: i,
519
519
  name: s[0],
520
520
  attributeList: a,
521
521
  body: r
522
522
  })
523
- ) : s.length === 0 ? new S(
524
- n.create(v, {
523
+ ) : s.length === 0 ? new x(
524
+ n.create(A, {
525
525
  type: i,
526
526
  attributeList: a,
527
527
  body: r
528
528
  })
529
- ) : new k();
529
+ ) : new y();
530
530
  }
531
- function ut(t) {
531
+ function ht(t) {
532
532
  return t.kind === u.IDENTIFIER && t.value === "as";
533
533
  }
534
534
  function N(t) {
535
- t && (t instanceof F ? cn(t) : un(t));
535
+ t && (t instanceof V ? un(t) : hn(t));
536
536
  }
537
- function cn(t) {
537
+ function un(t) {
538
538
  t.kind !== u.EOF && (t.isInvalid = !0);
539
539
  }
540
- function un(t) {
541
- if (t instanceof v)
540
+ function hn(t) {
541
+ if (t instanceof A)
542
542
  N(t.type), N(t.name), N(t.as), N(t.alias), N(t.bodyColon), N(t.attributeList), N(t.body);
543
- else if (t instanceof Y)
543
+ else if (t instanceof z)
544
544
  t.identifiers.forEach(N);
545
- else if (t instanceof se)
545
+ else if (t instanceof ie)
546
546
  N(t.name), N(t.colon), N(t.value);
547
- else if (t instanceof Q)
548
- N(t.op), N(t.expression);
549
547
  else if (t instanceof q)
548
+ N(t.op), N(t.expression);
549
+ else if (t instanceof H)
550
550
  N(t.leftExpression), N(t.op), N(t.rightExpression);
551
551
  else if (t instanceof Ue)
552
552
  N(t.op), N(t.expression);
553
- else if (t instanceof J)
553
+ else if (t instanceof Z)
554
554
  N(t.blockOpenBrace), t.body.forEach(N), N(t.blockCloseBrace);
555
- else if (t instanceof R)
555
+ else if (t instanceof P)
556
556
  N(t.listOpenBracket), t.commaList.forEach(N), t.elementList.forEach(N), N(t.listCloseBracket);
557
- else if (t instanceof Z)
557
+ else if (t instanceof K)
558
558
  N(t.tupleOpenParen), t.commaList.forEach(N), t.elementList.forEach(N), N(t.tupleCloseParen);
559
- else if (t instanceof H)
559
+ else if (t instanceof J)
560
560
  N(t.callee), N(t.argumentList);
561
- else if (t instanceof w)
561
+ else if (t instanceof v)
562
562
  N(t.callee), t.args.forEach(N);
563
- else if (t instanceof U)
563
+ else if (t instanceof F)
564
564
  N(t.expression);
565
- else if (t instanceof ne)
565
+ else if (t instanceof se)
566
566
  N(t.value);
567
- else if (t instanceof K)
567
+ else if (t instanceof ee)
568
568
  N(t.variable);
569
569
  else if (t instanceof be)
570
570
  N(t.literal);
571
571
  else
572
- throw t instanceof We ? new Error("This case is handled by the TupleExpressionNode case") : new Error("Unreachable case in markInvalidNode");
572
+ throw t instanceof Ye ? new Error("This case is handled by the TupleExpressionNode case") : new Error("Unreachable case in markInvalidNode");
573
573
  }
574
- function wt(t) {
574
+ function yt(t) {
575
575
  return !!(t != null && t.isInvalid);
576
576
  }
577
- function P(...t) {
577
+ function U(...t) {
578
578
  return t.filter((e) => e !== void 0);
579
579
  }
580
- function hn(t) {
581
- if (t instanceof X)
582
- return P(...t.body, t.eof);
583
- if (t instanceof v)
584
- return P(
580
+ function fn(t) {
581
+ if (t instanceof $)
582
+ return U(...t.body, t.eof);
583
+ if (t instanceof A)
584
+ return U(
585
585
  t.type,
586
586
  t.name,
587
587
  t.as,
@@ -590,74 +590,74 @@ function hn(t) {
590
590
  t.bodyColon,
591
591
  t.body
592
592
  );
593
- if (t instanceof se)
594
- return P(t.name, t.colon, t.value);
595
- if (t instanceof Y)
593
+ if (t instanceof ie)
594
+ return U(t.name, t.colon, t.value);
595
+ if (t instanceof z)
596
596
  return t.identifiers;
597
597
  if (t instanceof be)
598
598
  return t.literal ? [t.literal] : [];
599
- if (t instanceof K)
600
- return P(t.variable);
601
- if (t instanceof Q)
602
- return P(t.op, t.expression);
599
+ if (t instanceof ee)
600
+ return U(t.variable);
603
601
  if (t instanceof q)
604
- return P(t.leftExpression, t.op, t.rightExpression);
602
+ return U(t.op, t.expression);
603
+ if (t instanceof H)
604
+ return U(t.leftExpression, t.op, t.rightExpression);
605
605
  if (t instanceof Ue)
606
- return P(t.expression, t.op);
607
- if (t instanceof ne)
608
- return P(t.value);
609
- if (t instanceof w)
610
- return P(t.callee, ...t.args);
611
- if (t instanceof J)
612
- return P(t.blockOpenBrace, ...t.body, t.blockCloseBrace);
613
- if (t instanceof R)
614
- return P(
606
+ return U(t.expression, t.op);
607
+ if (t instanceof se)
608
+ return U(t.value);
609
+ if (t instanceof v)
610
+ return U(t.callee, ...t.args);
611
+ if (t instanceof Z)
612
+ return U(t.blockOpenBrace, ...t.body, t.blockCloseBrace);
613
+ if (t instanceof P)
614
+ return U(
615
615
  t.listOpenBracket,
616
- ...ct(t.elementList, t.commaList),
616
+ ...ut(t.elementList, t.commaList),
617
617
  t.listCloseBracket
618
618
  );
619
- if (t instanceof Z)
620
- return P(
619
+ if (t instanceof K)
620
+ return U(
621
621
  t.tupleOpenParen,
622
- ...ct(t.elementList, t.commaList),
622
+ ...ut(t.elementList, t.commaList),
623
623
  t.tupleCloseParen
624
624
  );
625
- if (t instanceof H)
626
- return P(t.callee, t.argumentList);
627
- if (t instanceof U)
628
- return P(t.expression);
625
+ if (t instanceof J)
626
+ return U(t.callee, t.argumentList);
627
+ if (t instanceof F)
628
+ return U(t.expression);
629
629
  if (t instanceof he)
630
- return P(
630
+ return U(
631
631
  t.array,
632
632
  t.indexer
633
633
  );
634
- throw t instanceof We ? new Error("This case is already handled by TupleExpressionNode") : new Error("Unreachable - no other possible cases");
634
+ throw t instanceof Ye ? new Error("This case is already handled by TupleExpressionNode") : new Error("Unreachable - no other possible cases");
635
635
  }
636
- function Ge(t) {
637
- return M(t) ? new S(t.expression.variable) : new k();
636
+ function Ce(t) {
637
+ return B(t) ? new x(t.expression.variable) : new y();
638
638
  }
639
- function $(t) {
639
+ function W(t) {
640
640
  var e;
641
- return t instanceof U && (t.expression instanceof K && t.expression.variable instanceof F && t.expression.variable.kind === u.QUOTED_STRING || t.expression instanceof be && ((e = t.expression.literal) == null ? void 0 : e.kind) === u.STRING_LITERAL);
641
+ return t instanceof F && (t.expression instanceof ee && t.expression.variable instanceof V && t.expression.variable.kind === u.QUOTED_STRING || t.expression instanceof be && ((e = t.expression.literal) == null ? void 0 : e.kind) === u.STRING_LITERAL);
642
642
  }
643
- function M(t) {
644
- return t instanceof U && t.expression instanceof K && t.expression.variable instanceof F;
643
+ function B(t) {
644
+ return t instanceof F && t.expression instanceof ee && t.expression.variable instanceof V;
645
645
  }
646
646
  function me(t) {
647
647
  var e;
648
- return t instanceof U && t.expression instanceof K && ((e = t.expression.variable) == null ? void 0 : e.kind) === u.IDENTIFIER;
648
+ return t instanceof F && t.expression instanceof ee && ((e = t.expression.variable) == null ? void 0 : e.kind) === u.IDENTIFIER;
649
649
  }
650
- function Je(t) {
650
+ function Ke(t) {
651
651
  var e;
652
- return t instanceof q && t.leftExpression instanceof x && t.rightExpression instanceof x && ((e = t.op) == null ? void 0 : e.value) === ".";
652
+ return t instanceof H && t.leftExpression instanceof k && t.rightExpression instanceof k && ((e = t.op) == null ? void 0 : e.value) === ".";
653
653
  }
654
654
  function Te(t) {
655
655
  if (t === void 0)
656
- return new k();
656
+ return new y();
657
657
  const e = t.identifiers.map((n) => n.value).join(" ");
658
- return e === "" ? new k() : new S(e);
658
+ return e === "" ? new y() : new x(e);
659
659
  }
660
- class fn {
660
+ class pn {
661
661
  // list of errors during lexing
662
662
  constructor(e) {
663
663
  this.start = {
@@ -697,7 +697,7 @@ class fn {
697
697
  this.tokens.push(this.createToken(e, n));
698
698
  }
699
699
  createToken(e, n = !1) {
700
- return F.create(
700
+ return V.create(
701
701
  e,
702
702
  this.start,
703
703
  this.current,
@@ -706,7 +706,7 @@ class fn {
706
706
  );
707
707
  }
708
708
  lex() {
709
- return this.scanTokens(), this.tokens.push(F.create(u.EOF, this.start, this.current, "", !1)), this.gatherTrivia(), this.gatherInvalid(), new V(this.tokens, this.errors);
709
+ return this.scanTokens(), this.tokens.push(V.create(u.EOF, this.start, this.current, "", !1)), this.gatherTrivia(), this.gatherInvalid(), new G(this.tokens, this.errors);
710
710
  }
711
711
  scanTokens() {
712
712
  for (; !this.isAtEnd(); ) {
@@ -767,7 +767,7 @@ class fn {
767
767
  this.match("/") ? this.singleLineComment() : this.match("*") ? this.multilineComment() : this.operator();
768
768
  break;
769
769
  default:
770
- if (at(e)) {
770
+ if (ot(e)) {
771
771
  this.operator();
772
772
  break;
773
773
  }
@@ -795,13 +795,13 @@ class fn {
795
795
  let e = !0, n = [], s;
796
796
  const i = [];
797
797
  for (const r of this.tokens)
798
- Qt(r) ? (n.push(r), r.kind === u.NEWLINE && s && (s.trailingTrivia = n, e = !0, s = void 0, n = [])) : (e ? r.leadingTrivia = n : s.trailingTrivia = n, i.push(r), n = [], s = r, e = !1);
798
+ qt(r) ? (n.push(r), r.kind === u.NEWLINE && s && (s.trailingTrivia = n, e = !0, s = void 0, n = [])) : (e ? r.leadingTrivia = n : s.trailingTrivia = n, i.push(r), n = [], s = r, e = !1);
799
799
  this.tokens = i;
800
800
  }
801
801
  gatherInvalid() {
802
802
  let e;
803
803
  const n = [], s = [];
804
- for (e = 0; e < this.tokens.length && wt(this.tokens[e]); e += 1)
804
+ for (e = 0; e < this.tokens.length && yt(this.tokens[e]); e += 1)
805
805
  s.push(this.tokens[e]);
806
806
  let i = this.tokens[e];
807
807
  for (i.leadingInvalid = [...s, ...i.leadingInvalid]; e < this.tokens.length; e += 1) {
@@ -843,7 +843,7 @@ class fn {
843
843
  );
844
844
  return;
845
845
  }
846
- a && this.match(n), this.tokens.push(F.create(e, this.start, this.current, l, !1));
846
+ a && this.match(n), this.tokens.push(V.create(e, this.start, this.current, l, !1));
847
847
  }
848
848
  singleLineStringLiteral() {
849
849
  this.consumeUntil(u.STRING_LITERAL, "'", {
@@ -895,7 +895,7 @@ class fn {
895
895
  this.addToken(u.IDENTIFIER);
896
896
  }
897
897
  operator() {
898
- for (; at(this.peek()); )
898
+ for (; ot(this.peek()); )
899
899
  this.advance();
900
900
  this.addToken(u.OP);
901
901
  }
@@ -971,7 +971,7 @@ class fn {
971
971
  let n = "";
972
972
  for (let s = 0; s <= 3; s += 1) {
973
973
  if (this.isAtEnd() || !Ee(this.peek()))
974
- return this.errors.push(new c(o.INVALID_ESCAPE_SEQUENCE, `Invalid unicode escape sequence '\\u${n}', only unicode escape sequences of the form '\\uHHHH' where H is a hexadecimal number are allowed`, F.create(u.STRING_LITERAL, e, this.current, `\\u${n}`, !0))), `\\u${n}`;
974
+ return this.errors.push(new c(o.INVALID_ESCAPE_SEQUENCE, `Invalid unicode escape sequence '\\u${n}', only unicode escape sequences of the form '\\uHHHH' where H is a hexadecimal number are allowed`, V.create(u.STRING_LITERAL, e, this.current, `\\u${n}`, !0))), `\\u${n}`;
975
975
  n += this.advance();
976
976
  }
977
977
  return String.fromCharCode(parseInt(n, 16));
@@ -982,7 +982,7 @@ class fn {
982
982
  }
983
983
  }
984
984
  var Se = /* @__PURE__ */ ((t) => (t[t.ListExpression = 0] = "ListExpression", t[t.GroupExpression = 1] = "GroupExpression", t[t.BlockExpression = 2] = "BlockExpression", t))(Se || {});
985
- class pn {
985
+ class dn {
986
986
  constructor() {
987
987
  this.stack = [], this.numberOfNestedLParens = 0, this.numberOfNestedLBrackets = 0, this.numberOfNestedLBraces = 0;
988
988
  }
@@ -1048,7 +1048,7 @@ class pn {
1048
1048
  }
1049
1049
  }
1050
1050
  }
1051
- class dn {
1051
+ class En {
1052
1052
  constructor(e) {
1053
1053
  this.generator = e;
1054
1054
  }
@@ -1061,15 +1061,15 @@ class d {
1061
1061
  this.token = e, this.partialNode = n, this.handlerContext = s;
1062
1062
  }
1063
1063
  }
1064
- class En {
1064
+ class Nn {
1065
1065
  constructor(e, n) {
1066
- this.current = 0, this.errors = [], this.contextStack = new pn(), this.synchronizeProgram = () => {
1066
+ this.current = 0, this.errors = [], this.contextStack = new dn(), this.synchronizeProgram = () => {
1067
1067
  const s = this.peek();
1068
1068
  s.kind !== u.EOF ? N(this.advance()) : (N(this.peek()), this.logError(s, o.UNEXPECTED_EOF, "Unexpected EOF"));
1069
1069
  }, this.synchronizeElementDeclarationName = () => {
1070
1070
  for (; !this.isAtEnd(); ) {
1071
1071
  const s = this.peek();
1072
- if (ut(s) || this.check(u.COLON, u.LBRACE, u.LBRACKET))
1072
+ if (ht(s) || this.check(u.COLON, u.LBRACE, u.LBRACKET))
1073
1073
  break;
1074
1074
  N(s), this.advance();
1075
1075
  }
@@ -1081,7 +1081,7 @@ class En {
1081
1081
  N(s), this.advance();
1082
1082
  }
1083
1083
  }, this.blockExpression = this.contextStack.withContextDo(Se.BlockExpression, () => {
1084
- const s = { body: [] }, i = () => this.nodeFactory.create(J, s);
1084
+ const s = { body: [] }, i = () => this.nodeFactory.create(Z, s);
1085
1085
  try {
1086
1086
  this.consume("Expect an opening brace '{'", u.LBRACE), s.blockOpenBrace = this.previous();
1087
1087
  } catch (r) {
@@ -1115,16 +1115,16 @@ class En {
1115
1115
  if (!this.check(u.RBRACE))
1116
1116
  for (N(this.advance()); !this.isAtEnd(); ) {
1117
1117
  const s = this.peek();
1118
- if (this.check(u.RBRACE) || lt(this.previous(), s))
1118
+ if (this.check(u.RBRACE) || ct(this.previous(), s))
1119
1119
  break;
1120
1120
  N(s), this.advance();
1121
1121
  }
1122
1122
  }, this.tupleExpression = this.contextStack.withContextDo(Se.GroupExpression, () => {
1123
- const s = { elementList: [], commaList: [] }, i = () => this.nodeFactory.create(We, {
1123
+ const s = { elementList: [], commaList: [] }, i = () => this.nodeFactory.create(Ye, {
1124
1124
  groupOpenParen: s.tupleOpenParen,
1125
1125
  groupCloseParen: s.tupleCloseParen,
1126
1126
  expression: s.elementList[0]
1127
- }), r = () => this.nodeFactory.create(Z, s);
1127
+ }), r = () => this.nodeFactory.create(K, s);
1128
1128
  try {
1129
1129
  this.consume("Expect an opening parenthesis '('", u.LPAREN), s.tupleOpenParen = this.previous();
1130
1130
  } catch (a) {
@@ -1150,7 +1150,7 @@ class En {
1150
1150
  } catch (a) {
1151
1151
  if (!(a instanceof d))
1152
1152
  throw a;
1153
- if (a.partialNode instanceof x && s.elementList.push(a.partialNode), !this.canHandle(a))
1153
+ if (a.partialNode instanceof k && s.elementList.push(a.partialNode), !this.canHandle(a))
1154
1154
  throw new d(a.token, r(), a.handlerContext);
1155
1155
  this.synchronizeTuple();
1156
1156
  }
@@ -1172,7 +1172,7 @@ class En {
1172
1172
  N(s), this.advance();
1173
1173
  }
1174
1174
  }, this.listExpression = this.contextStack.withContextDo(Se.ListExpression, () => {
1175
- const s = { elementList: [], commaList: [] }, i = () => this.nodeFactory.create(R, s);
1175
+ const s = { elementList: [], commaList: [] }, i = () => this.nodeFactory.create(P, s);
1176
1176
  try {
1177
1177
  this.consume("Expect an opening bracket '['", u.LBRACKET), s.listOpenBracket = this.previous();
1178
1178
  } catch (r) {
@@ -1198,7 +1198,7 @@ class En {
1198
1198
  } catch (r) {
1199
1199
  if (!(r instanceof d))
1200
1200
  throw r;
1201
- if (r.partialNode instanceof x && s.elementList.push(r.partialNode), !this.canHandle(r))
1201
+ if (r.partialNode instanceof k && s.elementList.push(r.partialNode), !this.canHandle(r))
1202
1202
  throw new d(r.token, i(), r.handlerContext);
1203
1203
  this.synchronizeList();
1204
1204
  }
@@ -1233,7 +1233,7 @@ class En {
1233
1233
  break;
1234
1234
  N(s), this.advance();
1235
1235
  }
1236
- }, this.tokens = e, this.nodeFactory = new dn(n);
1236
+ }, this.tokens = e, this.nodeFactory = new En(n);
1237
1237
  }
1238
1238
  isAtEnd() {
1239
1239
  return this.current >= this.tokens.length || this.tokens[this.current].kind === u.EOF;
@@ -1289,8 +1289,8 @@ class En {
1289
1289
  this.tokens = e;
1290
1290
  }
1291
1291
  parse() {
1292
- const e = this.program(), n = this.advance(), s = this.nodeFactory.create(X, { body: e, eof: n });
1293
- return this.gatherInvalid(), new V({ ast: s, tokens: this.tokens }, this.errors);
1292
+ const e = this.program(), n = this.advance(), s = this.nodeFactory.create($, { body: e, eof: n });
1293
+ return this.gatherInvalid(), new G({ ast: s, tokens: this.tokens }, this.errors);
1294
1294
  }
1295
1295
  /* Parsing and synchronizing ProgramNode */
1296
1296
  program() {
@@ -1308,7 +1308,7 @@ class En {
1308
1308
  }
1309
1309
  /* Parsing and synchronizing top-level ElementDeclarationNode */
1310
1310
  elementDeclaration() {
1311
- const e = {}, n = () => this.nodeFactory.create(v, e);
1311
+ const e = {}, n = () => this.nodeFactory.create(A, e);
1312
1312
  try {
1313
1313
  this.consume("Expect an identifier", u.IDENTIFIER), e.type = this.previous();
1314
1314
  } catch (s) {
@@ -1324,7 +1324,7 @@ class En {
1324
1324
  throw new d(s.token, n(), s.handlerContext);
1325
1325
  this.synchronizeElementDeclarationName();
1326
1326
  }
1327
- if (ut(this.peek()))
1327
+ if (ht(this.peek()))
1328
1328
  if (e.as = this.advance(), this.check(u.COLON, u.LBRACE, u.LBRACKET))
1329
1329
  this.logError(this.peek(), o.UNEXPECTED_TOKEN, "Expect an alias");
1330
1330
  else
@@ -1352,13 +1352,13 @@ class En {
1352
1352
  if (this.match(u.COLON)) {
1353
1353
  e.bodyColon = this.previous();
1354
1354
  const s = this.expression();
1355
- s instanceof v ? (N(s), this.logError(s, o.UNEXPECTED_ELEMENT_DECLARATION, "An element's simple body must not be an element declaration")) : e.body = s;
1355
+ s instanceof A ? (N(s), this.logError(s, o.UNEXPECTED_ELEMENT_DECLARATION, "An element's simple body must not be an element declaration")) : e.body = s;
1356
1356
  } else
1357
1357
  e.body = this.blockExpression();
1358
1358
  } catch (s) {
1359
1359
  throw s instanceof d ? (e.body = s.partialNode, new d(s.token, n(), s.handlerContext)) : s;
1360
1360
  }
1361
- return this.nodeFactory.create(v, e);
1361
+ return this.nodeFactory.create(A, e);
1362
1362
  }
1363
1363
  /* Parsing nested element declarations with simple body */
1364
1364
  // e.g
@@ -1367,7 +1367,7 @@ class En {
1367
1367
  // Note: 'This is a note' // fieldDeclaration() handles this
1368
1368
  // }
1369
1369
  fieldDeclaration() {
1370
- const e = {}, n = () => this.nodeFactory.create(v, e);
1370
+ const e = {}, n = () => this.nodeFactory.create(A, e);
1371
1371
  try {
1372
1372
  this.consume("Expect an identifier", u.IDENTIFIER), e.type = this.previous();
1373
1373
  } catch (s) {
@@ -1380,16 +1380,16 @@ class En {
1380
1380
  }
1381
1381
  try {
1382
1382
  const s = this.expression();
1383
- s instanceof v ? this.errors.push(new c(o.INVALID_ELEMENT_IN_SIMPLE_BODY, "Simple body cannot be an element declaration", s)) : e.body = s;
1383
+ s instanceof A ? this.errors.push(new c(o.INVALID_ELEMENT_IN_SIMPLE_BODY, "Simple body cannot be an element declaration", s)) : e.body = s;
1384
1384
  } catch (s) {
1385
1385
  throw s instanceof d ? (e.body = s.partialNode, new d(s.token, n(), s.handlerContext)) : s;
1386
1386
  }
1387
- return this.nodeFactory.create(v, e);
1387
+ return this.nodeFactory.create(A, e);
1388
1388
  }
1389
1389
  /* Parsing any ExpressionNode, including non-NormalExpression */
1390
1390
  expression() {
1391
- const e = { args: [] }, n = () => ln(e.callee, e.args, this.nodeFactory).unwrap_or(
1392
- this.nodeFactory.create(w, e)
1391
+ const e = { args: [] }, n = () => cn(e.callee, e.args, this.nodeFactory).unwrap_or(
1392
+ this.nodeFactory.create(v, e)
1393
1393
  );
1394
1394
  try {
1395
1395
  e.callee = this.normalExpression();
@@ -1400,7 +1400,7 @@ class En {
1400
1400
  return n();
1401
1401
  let s = e.callee;
1402
1402
  for (; !this.shouldStopExpression(); ) {
1403
- Ce(this.previous()) || this.logError(s, o.MISSING_SPACES, "Expect a following space");
1403
+ $e(this.previous()) || this.logError(s, o.MISSING_SPACES, "Expect a following space");
1404
1404
  try {
1405
1405
  s = this.normalExpression(), e.args.push(s);
1406
1406
  } catch (i) {
@@ -1410,7 +1410,7 @@ class En {
1410
1410
  return n();
1411
1411
  }
1412
1412
  shouldStopExpression() {
1413
- if (this.isAtEnd() || It(this.previous()))
1413
+ if (this.isAtEnd() || Lt(this.previous()))
1414
1414
  return !0;
1415
1415
  const e = this.peek().kind;
1416
1416
  return e === u.RBRACE || e === u.RBRACKET || e === u.RPAREN || e === u.COMMA || e === u.COLON;
@@ -1424,26 +1424,26 @@ class En {
1424
1424
  for (; !this.isAtEnd(); ) {
1425
1425
  const s = this.peek();
1426
1426
  if (s.kind === u.LPAREN) {
1427
- const { left: i } = ht(s);
1427
+ const { left: i } = ft(s);
1428
1428
  if (i < e || // When '(' is encountered,
1429
1429
  // consider it part of another expression if
1430
1430
  // it's at the start of a new line
1431
1431
  // and we're currently not having unmatched '(' or '['
1432
- lt(this.previous(), s) && !this.contextStack.isWithinGroupExpressionContext() && !this.contextStack.isWithinListExpressionContext())
1432
+ ct(this.previous(), s) && !this.contextStack.isWithinGroupExpressionContext() && !this.contextStack.isWithinListExpressionContext())
1433
1433
  break;
1434
1434
  try {
1435
- n = this.nodeFactory.create(H, {
1435
+ n = this.nodeFactory.create(J, {
1436
1436
  callee: n,
1437
1437
  argumentList: this.tupleExpression()
1438
1438
  });
1439
1439
  } catch (r) {
1440
- throw r instanceof d ? (n = this.nodeFactory.create(H, {
1440
+ throw r instanceof d ? (n = this.nodeFactory.create(J, {
1441
1441
  callee: n,
1442
1442
  argumentList: r.partialNode
1443
1443
  }), new d(r.token, n, r.handlerContext)) : r;
1444
1444
  }
1445
1445
  } else if (s.kind === u.LBRACKET) {
1446
- if (Ce(this.previous()))
1446
+ if ($e(this.previous()))
1447
1447
  break;
1448
1448
  try {
1449
1449
  n = this.nodeFactory.create(he, {
@@ -1456,8 +1456,8 @@ class En {
1456
1456
  indexer: i.partialNode
1457
1457
  }), new d(i.token, n, i.handlerContext)) : i;
1458
1458
  }
1459
- } else if (ot(s)) {
1460
- const i = s, r = ht(i);
1459
+ } else if (lt(s)) {
1460
+ const i = s, r = ft(i);
1461
1461
  if (r.left !== null) {
1462
1462
  if (r.left <= e)
1463
1463
  break;
@@ -1466,18 +1466,18 @@ class En {
1466
1466
  op: i
1467
1467
  });
1468
1468
  } else {
1469
- const a = mn(i);
1469
+ const a = Tn(i);
1470
1470
  if (a.left === null || a.left <= e)
1471
1471
  break;
1472
1472
  this.advance();
1473
1473
  try {
1474
- n = this.nodeFactory.create(q, {
1474
+ n = this.nodeFactory.create(H, {
1475
1475
  leftExpression: n,
1476
1476
  op: i,
1477
1477
  rightExpression: i.value === "." ? this.extractOperand() : this.expression_bp(a.right)
1478
1478
  });
1479
1479
  } catch (l) {
1480
- throw l instanceof d ? (n = this.nodeFactory.create(q, {
1480
+ throw l instanceof d ? (n = this.nodeFactory.create(H, {
1481
1481
  leftExpression: n,
1482
1482
  op: i,
1483
1483
  rightExpression: l.partialNode
@@ -1491,10 +1491,10 @@ class En {
1491
1491
  }
1492
1492
  leftExpression_bp() {
1493
1493
  let e;
1494
- if (ot(this.peek())) {
1494
+ if (lt(this.peek())) {
1495
1495
  const n = {};
1496
1496
  n.op = this.peek();
1497
- const s = bn(n.op);
1497
+ const s = In(n.op);
1498
1498
  if (s.right === null)
1499
1499
  throw this.logError(
1500
1500
  n.op,
@@ -1511,11 +1511,11 @@ class En {
1511
1511
  } catch (i) {
1512
1512
  throw i instanceof d ? (n.expression = i.partialNode, new d(
1513
1513
  i.token,
1514
- this.nodeFactory.create(Q, n),
1514
+ this.nodeFactory.create(q, n),
1515
1515
  i.handlerContext
1516
1516
  )) : i;
1517
1517
  }
1518
- e = this.nodeFactory.create(Q, n);
1518
+ e = this.nodeFactory.create(q, n);
1519
1519
  } else if (e = this.extractOperand(), e instanceof xe)
1520
1520
  throw new d(
1521
1521
  this.peek(),
@@ -1553,11 +1553,11 @@ class En {
1553
1553
  } catch (n) {
1554
1554
  throw n instanceof d ? (e.value = n.partialNode, new d(
1555
1555
  n.token,
1556
- this.nodeFactory.create(ne, e),
1556
+ this.nodeFactory.create(se, e),
1557
1557
  n.handlerContext
1558
1558
  )) : n;
1559
1559
  }
1560
- return this.nodeFactory.create(ne, e);
1560
+ return this.nodeFactory.create(se, e);
1561
1561
  }
1562
1562
  canBeField() {
1563
1563
  return this.peek().kind === u.IDENTIFIER && this.peek(1).kind === u.COLON;
@@ -1569,12 +1569,12 @@ class En {
1569
1569
  u.STRING_LITERAL,
1570
1570
  u.NUMERIC_LITERAL
1571
1571
  ))
1572
- return this.nodeFactory.create(U, {
1572
+ return this.nodeFactory.create(F, {
1573
1573
  expression: this.nodeFactory.create(be, { literal: this.previous() })
1574
1574
  });
1575
1575
  if (this.match(u.QUOTED_STRING, u.IDENTIFIER))
1576
- return this.nodeFactory.create(U, {
1577
- expression: this.nodeFactory.create(K, { variable: this.previous() })
1576
+ return this.nodeFactory.create(F, {
1577
+ expression: this.nodeFactory.create(ee, { variable: this.previous() })
1578
1578
  });
1579
1579
  throw this.logError(this.peek(), o.UNEXPECTED_TOKEN, "Expect a variable or literal"), new d(
1580
1580
  this.peek(),
@@ -1590,7 +1590,7 @@ class En {
1590
1590
  n,
1591
1591
  o.EMPTY_ATTRIBUTE_NAME,
1592
1592
  "Expect a non-empty attribute name"
1593
- ), e.name = this.nodeFactory.create(Y, { identifiers: [] });
1593
+ ), e.name = this.nodeFactory.create(z, { identifiers: [] });
1594
1594
  } else
1595
1595
  try {
1596
1596
  e.name = this.attributeName();
@@ -1600,12 +1600,12 @@ class En {
1600
1600
  if (e.name = n.partialNode, !this.canHandle(n))
1601
1601
  throw new d(
1602
1602
  n.token,
1603
- this.nodeFactory.create(se, e),
1603
+ this.nodeFactory.create(ie, e),
1604
1604
  n.handlerContext
1605
1605
  );
1606
1606
  this.synchronizeAttributeName();
1607
1607
  }
1608
- return this.match(u.COLON) && (e.colon = this.previous(), e.value = this.attributeValue()), this.nodeFactory.create(se, e);
1608
+ return this.match(u.COLON) && (e.colon = this.previous(), e.value = this.attributeValue()), this.nodeFactory.create(ie, e);
1609
1609
  }
1610
1610
  attributeValue() {
1611
1611
  let e;
@@ -1628,17 +1628,17 @@ class En {
1628
1628
  } catch (n) {
1629
1629
  throw n instanceof d ? new d(
1630
1630
  n.token,
1631
- this.nodeFactory.create(Y, { identifiers: e }),
1631
+ this.nodeFactory.create(z, { identifiers: e }),
1632
1632
  n.handlerContext
1633
1633
  ) : n;
1634
1634
  }
1635
- return this.nodeFactory.create(Y, { identifiers: e });
1635
+ return this.nodeFactory.create(z, { identifiers: e });
1636
1636
  }
1637
1637
  logError(e, n, s) {
1638
1638
  this.errors.push(new c(n, s, e));
1639
1639
  }
1640
1640
  }
1641
- const Nn = {
1641
+ const mn = {
1642
1642
  "+": { left: 9, right: 10 },
1643
1643
  "*": { left: 11, right: 12 },
1644
1644
  "-": { left: 9, right: 10 },
@@ -1654,10 +1654,10 @@ const Nn = {
1654
1654
  "!=": { left: 4, right: 5 },
1655
1655
  ".": { left: 16, right: 17 }
1656
1656
  };
1657
- function mn(t) {
1658
- return Nn[t.value] || { left: null, right: null };
1657
+ function Tn(t) {
1658
+ return mn[t.value] || { left: null, right: null };
1659
1659
  }
1660
- const Tn = {
1660
+ const bn = {
1661
1661
  "+": { left: null, right: 15 },
1662
1662
  "-": { left: null, right: 15 },
1663
1663
  "<": { left: null, right: 15 },
@@ -1665,14 +1665,14 @@ const Tn = {
1665
1665
  "<>": { left: null, right: 15 },
1666
1666
  "!": { left: null, right: 15 }
1667
1667
  };
1668
- function bn(t) {
1669
- return Tn[t.value] || { left: null, right: null };
1668
+ function In(t) {
1669
+ return bn[t.value] || { left: null, right: null };
1670
1670
  }
1671
- const In = {
1671
+ const Ln = {
1672
1672
  "(": { left: 14, right: null }
1673
1673
  };
1674
- function ht(t) {
1675
- return In[t.value] || { left: null, right: null };
1674
+ function ft(t) {
1675
+ return Ln[t.value] || { left: null, right: null };
1676
1676
  }
1677
1677
  var b = /* @__PURE__ */ ((t) => (t.Table = "table", t.Enum = "enum", t.Ref = "ref", t.Note = "note", t.Project = "project", t.Indexes = "indexes", t.TableGroup = "tablegroup", t))(b || {});
1678
1678
  function ve(t) {
@@ -1686,111 +1686,111 @@ function ve(t) {
1686
1686
  case b.Project:
1687
1687
  case b.Ref:
1688
1688
  case b.TableGroup:
1689
- return new S(e);
1689
+ return new x(e);
1690
1690
  default:
1691
- return new k();
1691
+ return new y();
1692
1692
  }
1693
1693
  }
1694
1694
  function pe(t) {
1695
- if (!Je(t))
1696
- return new S([t]);
1695
+ if (!Ke(t))
1696
+ return new x([t]);
1697
1697
  const e = pe(t.leftExpression).unwrap_or(void 0);
1698
- return e ? (e.push(t.rightExpression), new S(e)) : new k();
1698
+ return e ? (e.push(t.rightExpression), new x(e)) : new y();
1699
1699
  }
1700
- function W(t) {
1700
+ function j(t) {
1701
1701
  if (t === void 0)
1702
- return new k();
1702
+ return new y();
1703
1703
  const e = pe(t).unwrap_or(void 0);
1704
1704
  if (!e)
1705
- return new k();
1705
+ return new y();
1706
1706
  const n = [];
1707
1707
  for (const s of e) {
1708
- const i = j(s).unwrap_or(void 0);
1708
+ const i = Y(s).unwrap_or(void 0);
1709
1709
  if (!i)
1710
- return new k();
1710
+ return new y();
1711
1711
  n.push(i);
1712
1712
  }
1713
- return new S(n);
1713
+ return new x(n);
1714
1714
  }
1715
1715
  function _e(t) {
1716
1716
  if (t === void 0)
1717
- return new k();
1717
+ return new y();
1718
1718
  const e = pe(t).unwrap_or(void 0);
1719
1719
  if (!e || e.length === 0)
1720
- return new k();
1720
+ return new y();
1721
1721
  const n = [];
1722
1722
  let s;
1723
- if (!M(I.last(e))) {
1723
+ if (!B(I.last(e))) {
1724
1724
  const i = e.pop();
1725
1725
  if (Ot(i))
1726
1726
  s = i.elementList.map(
1727
- (r) => C(r).unwrap()
1727
+ (r) => X(r).unwrap()
1728
1728
  );
1729
1729
  else
1730
- return new k();
1730
+ return new y();
1731
1731
  }
1732
1732
  for (const i of e) {
1733
- const r = j(i).unwrap_or(void 0);
1733
+ const r = Y(i).unwrap_or(void 0);
1734
1734
  if (!r)
1735
- return new k();
1735
+ return new y();
1736
1736
  n.push(r);
1737
1737
  }
1738
- return new S({
1738
+ return new x({
1739
1739
  variables: n,
1740
1740
  tupleElements: s
1741
1741
  });
1742
1742
  }
1743
- function j(t) {
1744
- return M(t) ? new S(t.expression.variable.value) : new k();
1743
+ function Y(t) {
1744
+ return B(t) ? new x(t.expression.variable.value) : new y();
1745
1745
  }
1746
- function Xe(t) {
1747
- if (ft(t))
1748
- return t instanceof ne ? new S({ functional: [t], nonFunctional: [] }) : new S({ functional: [], nonFunctional: [t] });
1749
- if (t instanceof Z && t.elementList.every(ft)) {
1746
+ function We(t) {
1747
+ if (pt(t))
1748
+ return t instanceof se ? new x({ functional: [t], nonFunctional: [] }) : new x({ functional: [], nonFunctional: [t] });
1749
+ if (t instanceof K && t.elementList.every(pt)) {
1750
1750
  const e = t.elementList.filter(
1751
- (s) => s instanceof ne
1752
- ), n = t.elementList.filter(M);
1753
- return new S({ functional: e, nonFunctional: n });
1751
+ (s) => s instanceof se
1752
+ ), n = t.elementList.filter(B);
1753
+ return new x({ functional: e, nonFunctional: n });
1754
1754
  }
1755
- return new k();
1755
+ return new y();
1756
1756
  }
1757
- function C(t) {
1757
+ function X(t) {
1758
1758
  var n;
1759
1759
  const e = (n = t == null ? void 0 : t.expression.variable) == null ? void 0 : n.value;
1760
- return e === void 0 ? new k() : new S(e);
1760
+ return e === void 0 ? new y() : new x(e);
1761
1761
  }
1762
- function G(t) {
1763
- return $(t) ? t.expression instanceof K ? new S(t.expression.variable.value) : new S(t.expression.literal.value) : new k();
1762
+ function C(t) {
1763
+ return W(t) ? t.expression instanceof ee ? new x(t.expression.variable.value) : new x(t.expression.literal.value) : new y();
1764
1764
  }
1765
- function Ln(t) {
1765
+ function gn(t) {
1766
1766
  var e;
1767
- return !(t instanceof q) || !xt((e = t.op) == null ? void 0 : e.value) ? !1 : _e(t.leftExpression).and_then(() => _e(t.rightExpression)).unwrap_or(void 0) !== void 0;
1767
+ return !(t instanceof H) || !St((e = t.op) == null ? void 0 : e.value) ? !1 : _e(t.leftExpression).and_then(() => _e(t.rightExpression)).unwrap_or(void 0) !== void 0;
1768
1768
  }
1769
- function gn(t) {
1769
+ function _n(t) {
1770
1770
  const e = _e(t.leftExpression), n = _e(t.rightExpression);
1771
1771
  if (!e.isOk() || !n.isOk())
1772
1772
  return !1;
1773
1773
  const { tupleElements: s } = e.unwrap(), { tupleElements: i } = n.unwrap();
1774
1774
  return (s == null ? void 0 : s.length) === (i == null ? void 0 : i.length);
1775
1775
  }
1776
- function ft(t) {
1777
- return t instanceof U && t.expression instanceof K || t instanceof ne;
1776
+ function pt(t) {
1777
+ return t instanceof F && t.expression instanceof ee || t instanceof se;
1778
1778
  }
1779
- function _n(t, e) {
1779
+ function An(t, e) {
1780
1780
  var i, r, a, l;
1781
1781
  let n = e;
1782
- const s = Zt(t);
1782
+ const s = Kt(t);
1783
1783
  for (; n; ) {
1784
1784
  if ((r = (i = n.symbol) == null ? void 0 : i.symbolTable) != null && r.has(t))
1785
1785
  return (a = n.symbol.symbolTable) == null ? void 0 : a.get(t);
1786
- if (((l = n.symbol) == null ? void 0 : l.declaration) instanceof X && s)
1786
+ if (((l = n.symbol) == null ? void 0 : l.declaration) instanceof $ && s)
1787
1787
  return n.symbol;
1788
- if (n instanceof X)
1788
+ if (n instanceof $)
1789
1789
  return;
1790
1790
  n = n.parent;
1791
1791
  }
1792
1792
  }
1793
- class An {
1793
+ class vn {
1794
1794
  constructor(e, n, s) {
1795
1795
  this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
1796
1796
  }
@@ -1798,7 +1798,7 @@ class An {
1798
1798
  return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
1799
1799
  }
1800
1800
  validateContext() {
1801
- return this.declarationNode.parent instanceof X || ve(this.declarationNode.parent).unwrap_or(void 0) !== b.Project ? [new c(o.INVALID_CUSTOM_CONTEXT, "A custom element can only appear in a Project", this.declarationNode)] : [];
1801
+ return this.declarationNode.parent instanceof $ || ve(this.declarationNode.parent).unwrap_or(void 0) !== b.Project ? [new c(o.INVALID_CUSTOM_CONTEXT, "A custom element can only appear in a Project", this.declarationNode)] : [];
1802
1802
  }
1803
1803
  validateName(e) {
1804
1804
  return e ? [new c(o.UNEXPECTED_NAME, "A Custom element shouldn't have a name", e)] : [];
@@ -1812,10 +1812,10 @@ class An {
1812
1812
  validateBody(e) {
1813
1813
  if (!e)
1814
1814
  return [];
1815
- if (e instanceof J)
1815
+ if (e instanceof Z)
1816
1816
  return [new c(o.UNEXPECTED_COMPLEX_BODY, "A Custom element can only have an inline field", e)];
1817
1817
  const n = [];
1818
- return $(e.callee) || n.push(new c(o.INVALID_CUSTOM_ELEMENT_VALUE, "A Custom element value can only be a string", e)), e.args.length > 0 && n.push(...e.args.map((s) => new c(o.INVALID_CUSTOM_ELEMENT_VALUE, "A Custom element value can only be a string", s))), n;
1818
+ return W(e.callee) || n.push(new c(o.INVALID_CUSTOM_ELEMENT_VALUE, "A Custom element value can only be a string", e)), e.args.length > 0 && n.push(...e.args.map((s) => new c(o.INVALID_CUSTOM_ELEMENT_VALUE, "A Custom element value can only be a string", s))), n;
1819
1819
  }
1820
1820
  }
1821
1821
  class we {
@@ -1835,7 +1835,7 @@ class we {
1835
1835
  return this.table.entries();
1836
1836
  }
1837
1837
  }
1838
- class vn {
1838
+ class wn {
1839
1839
  constructor(e, n, s) {
1840
1840
  this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
1841
1841
  }
@@ -1843,20 +1843,20 @@ class vn {
1843
1843
  return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.registerElement(), ...this.validateBody(this.declarationNode.body)];
1844
1844
  }
1845
1845
  validateContext() {
1846
- return this.declarationNode.parent instanceof v ? [new c(o.INVALID_PROJECT_CONTEXT, "An Enum can only appear top-level", this.declarationNode)] : [];
1846
+ return this.declarationNode.parent instanceof A ? [new c(o.INVALID_PROJECT_CONTEXT, "An Enum can only appear top-level", this.declarationNode)] : [];
1847
1847
  }
1848
1848
  validateName(e) {
1849
- return e ? kt(e) ? [] : [new c(o.INVALID_NAME, "An Enum name must be of the form <enum> or <schema>.<enum>", e)] : [new c(o.NAME_NOT_FOUND, "An Enum must have a name", this.declarationNode)];
1849
+ return e ? xt(e) ? [] : [new c(o.INVALID_NAME, "An Enum name must be of the form <enum> or <schema>.<enum>", e)] : [new c(o.NAME_NOT_FOUND, "An Enum must have a name", this.declarationNode)];
1850
1850
  }
1851
1851
  validateAlias(e) {
1852
1852
  return e ? [new c(o.UNEXPECTED_ALIAS, "A Ref shouldn't have an alias", e)] : [];
1853
1853
  }
1854
1854
  registerElement() {
1855
1855
  const e = [];
1856
- this.declarationNode.symbol = this.symbolFactory.create(nn, { declaration: this.declarationNode, symbolTable: new we() });
1857
- const { name: n } = this.declarationNode, s = W(n);
1856
+ this.declarationNode.symbol = this.symbolFactory.create(sn, { declaration: this.declarationNode, symbolTable: new we() });
1857
+ const { name: n } = this.declarationNode, s = j(n);
1858
1858
  if (s.isOk()) {
1859
- const i = s.unwrap(), r = i.pop(), a = Ze(i, this.publicSymbolTable, this.symbolFactory), l = ze(r);
1859
+ const i = s.unwrap(), r = i.pop(), a = et(i, this.publicSymbolTable, this.symbolFactory), l = qe(r);
1860
1860
  a.has(l) && e.push(new c(o.DUPLICATE_NAME, `Enum name ${r} already exists in schema '${i.join(".") || "public"}'`, n)), a.set(l, this.declarationNode.symbol);
1861
1861
  }
1862
1862
  return e;
@@ -1867,27 +1867,27 @@ class vn {
1867
1867
  validateBody(e) {
1868
1868
  if (!e)
1869
1869
  return [];
1870
- if (e instanceof w)
1870
+ if (e instanceof v)
1871
1871
  return this.validateFields([e]);
1872
- const [n, s] = I.partition(e.body, (i) => i instanceof w);
1872
+ const [n, s] = I.partition(e.body, (i) => i instanceof v);
1873
1873
  return [...this.validateFields(n), ...this.validateSubElements(s)];
1874
1874
  }
1875
1875
  validateFields(e) {
1876
1876
  return e.length === 0 ? [new c(o.EMPTY_ENUM, "An Enum must have at least one element", this.declarationNode)] : e.flatMap((n) => {
1877
1877
  const s = [];
1878
- n.callee && !M(n.callee) && s.push(new c(o.INVALID_ENUM_ELEMENT_NAME, "An enum field must be an identifier or a quoted identifier", n.callee));
1878
+ n.callee && !B(n.callee) && s.push(new c(o.INVALID_ENUM_ELEMENT_NAME, "An enum field must be an identifier or a quoted identifier", n.callee));
1879
1879
  const i = [...n.args];
1880
- return I.last(i) instanceof R ? (s.push(...this.validateFieldSettings(I.last(i))), i.pop()) : i[0] instanceof R && (s.push(...this.validateFieldSettings(i[0])), i.shift()), i.length > 0 && s.push(...i.map((r) => new c(o.INVALID_ENUM_ELEMENT, "An Enum must have only a field and optionally a setting list", r))), s.push(...this.registerField(n)), s;
1880
+ return I.last(i) instanceof P ? (s.push(...this.validateFieldSettings(I.last(i))), i.pop()) : i[0] instanceof P && (s.push(...this.validateFieldSettings(i[0])), i.shift()), i.length > 0 && s.push(...i.map((r) => new c(o.INVALID_ENUM_ELEMENT, "An Enum must have only a field and optionally a setting list", r))), s.push(...this.registerField(n)), s;
1881
1881
  });
1882
1882
  }
1883
1883
  validateFieldSettings(e) {
1884
- const n = B(e), s = n.getErrors(), i = n.getValue();
1884
+ const n = M(e), s = n.getErrors(), i = n.getValue();
1885
1885
  for (const r in i) {
1886
1886
  const a = i[r];
1887
1887
  switch (r) {
1888
1888
  case "note":
1889
1889
  a.length > 1 && a.forEach((l) => s.push(new c(o.DUPLICATE_ENUM_ELEMENT_SETTING, "'note' can only appear once", l))), a.forEach((l) => {
1890
- $(l.value) || s.push(new c(o.INVALID_ENUM_ELEMENT_SETTING, "'note' must be a string", l));
1890
+ W(l.value) || s.push(new c(o.INVALID_ENUM_ELEMENT_SETTING, "'note' must be a string", l));
1891
1891
  });
1892
1892
  break;
1893
1893
  default:
@@ -1900,13 +1900,13 @@ class vn {
1900
1900
  return e.flatMap((n) => {
1901
1901
  if (n.parent = this.declarationNode, !n.type)
1902
1902
  return [];
1903
- const s = ae(n);
1903
+ const s = oe(n);
1904
1904
  return new s(n, this.publicSymbolTable, this.symbolFactory).validate();
1905
1905
  });
1906
1906
  }
1907
1907
  registerField(e) {
1908
- if (e.callee && M(e.callee)) {
1909
- const n = C(e.callee).unwrap(), s = Qe(n), i = this.symbolFactory.create(sn, { declaration: e });
1908
+ if (e.callee && B(e.callee)) {
1909
+ const n = X(e.callee).unwrap(), s = He(n), i = this.symbolFactory.create(rn, { declaration: e });
1910
1910
  e.symbol = i;
1911
1911
  const r = this.declarationNode.symbol.symbolTable;
1912
1912
  if (r.has(s)) {
@@ -1921,7 +1921,7 @@ class vn {
1921
1921
  return [];
1922
1922
  }
1923
1923
  }
1924
- class wn {
1924
+ class yn {
1925
1925
  constructor(e, n, s) {
1926
1926
  this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
1927
1927
  }
@@ -1929,7 +1929,7 @@ class wn {
1929
1929
  return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
1930
1930
  }
1931
1931
  validateContext() {
1932
- return this.declarationNode.parent instanceof X || ve(this.declarationNode.parent).unwrap_or(void 0) !== b.Table ? [new c(o.INVALID_NOTE_CONTEXT, "An Indexes can only appear inside a Table", this.declarationNode)] : [];
1932
+ return this.declarationNode.parent instanceof $ || ve(this.declarationNode.parent).unwrap_or(void 0) !== b.Table ? [new c(o.INVALID_NOTE_CONTEXT, "An Indexes can only appear inside a Table", this.declarationNode)] : [];
1933
1933
  }
1934
1934
  validateName(e) {
1935
1935
  return e ? [new c(o.UNEXPECTED_NAME, "An Indexes shouldn't have a name", e)] : [];
@@ -1943,9 +1943,9 @@ class wn {
1943
1943
  validateBody(e) {
1944
1944
  if (!e)
1945
1945
  return [];
1946
- if (e instanceof w)
1946
+ if (e instanceof v)
1947
1947
  return [new c(o.UNEXPECTED_SIMPLE_BODY, "An Indexes must have a complex body", e)];
1948
- const [n, s] = I.partition(e.body, (i) => i instanceof w);
1948
+ const [n, s] = I.partition(e.body, (i) => i instanceof v);
1949
1949
  return [...this.validateFields(n), ...this.validateSubElements(s)];
1950
1950
  }
1951
1951
  validateFields(e) {
@@ -1953,22 +1953,22 @@ class wn {
1953
1953
  if (!n.callee)
1954
1954
  return [];
1955
1955
  const s = [], i = [n.callee, ...n.args];
1956
- return I.last(i) instanceof R && s.push(...this.validateFieldSetting(i.pop())), i.forEach((r) => {
1957
- for (; r instanceof H; )
1958
- r.argumentList && !Xe(r.argumentList).isOk() && s.push(new c(o.INVALID_INDEXES_FIELD, "An index field must be an identifier, a quoted identifier, a functional expression or a tuple of such", r.argumentList)), r = r.callee;
1959
- Xe(r).isOk() || s.push(new c(o.INVALID_INDEXES_FIELD, "An index field must be an identifier, a quoted identifier, a functional expression or a tuple of such", r));
1956
+ return I.last(i) instanceof P && s.push(...this.validateFieldSetting(i.pop())), i.forEach((r) => {
1957
+ for (; r instanceof J; )
1958
+ r.argumentList && !We(r.argumentList).isOk() && s.push(new c(o.INVALID_INDEXES_FIELD, "An index field must be an identifier, a quoted identifier, a functional expression or a tuple of such", r.argumentList)), r = r.callee;
1959
+ We(r).isOk() || s.push(new c(o.INVALID_INDEXES_FIELD, "An index field must be an identifier, a quoted identifier, a functional expression or a tuple of such", r));
1960
1960
  }), s;
1961
1961
  });
1962
1962
  }
1963
1963
  validateFieldSetting(e) {
1964
- const n = B(e), s = n.getErrors(), i = n.getValue();
1964
+ const n = M(e), s = n.getErrors(), i = n.getValue();
1965
1965
  for (const r in i) {
1966
1966
  const a = i[r];
1967
1967
  switch (r) {
1968
1968
  case "note":
1969
1969
  case "name":
1970
1970
  a.length > 1 && a.forEach((l) => s.push(new c(o.DUPLICATE_INDEX_SETTING, `'${r}' can only appear once`, l))), a.forEach((l) => {
1971
- $(l.value) || s.push(new c(o.INVALID_INDEX_SETTING_VALUE, `'${r}' must be a string`, l));
1971
+ W(l.value) || s.push(new c(o.INVALID_INDEX_SETTING_VALUE, `'${r}' must be a string`, l));
1972
1972
  });
1973
1973
  break;
1974
1974
  case "unique":
@@ -1979,7 +1979,7 @@ class wn {
1979
1979
  break;
1980
1980
  case "type":
1981
1981
  a.length > 1 && a.forEach((l) => s.push(new c(o.DUPLICATE_INDEX_SETTING, "'type' can only appear once", l))), a.forEach((l) => {
1982
- M(l.value) || s.push(new c(o.INVALID_INDEX_SETTING_VALUE, `'type' must be "btree" or "hash"`, l));
1982
+ B(l.value) || s.push(new c(o.INVALID_INDEX_SETTING_VALUE, `'type' must be "btree" or "hash"`, l));
1983
1983
  });
1984
1984
  break;
1985
1985
  default:
@@ -1992,12 +1992,12 @@ class wn {
1992
1992
  return e.flatMap((n) => {
1993
1993
  if (n.parent = this.declarationNode, !n.type)
1994
1994
  return [];
1995
- const s = ae(n);
1995
+ const s = oe(n);
1996
1996
  return new s(n, this.publicSymbolTable, this.symbolFactory).validate();
1997
1997
  });
1998
1998
  }
1999
1999
  }
2000
- class yn {
2000
+ class kn {
2001
2001
  constructor(e, n, s) {
2002
2002
  this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
2003
2003
  }
@@ -2011,7 +2011,7 @@ class yn {
2011
2011
  ];
2012
2012
  }
2013
2013
  validateContext() {
2014
- return !(this.declarationNode.parent instanceof X) && ![
2014
+ return !(this.declarationNode.parent instanceof $) && ![
2015
2015
  b.Table,
2016
2016
  b.TableGroup,
2017
2017
  b.Project
@@ -2022,14 +2022,14 @@ class yn {
2022
2022
  )] : [];
2023
2023
  }
2024
2024
  validateName(e) {
2025
- if (!(this.declarationNode.parent instanceof X))
2025
+ if (!(this.declarationNode.parent instanceof $))
2026
2026
  return e ? [new c(o.UNEXPECTED_NAME, "A Note shouldn't have a name", e)] : [];
2027
2027
  if (!e)
2028
2028
  return [new c(o.INVALID_NAME, "Sticky note must have a name", this.declarationNode)];
2029
- const n = W(e);
2029
+ const n = j(e);
2030
2030
  if (!n.isOk())
2031
2031
  return [new c(o.INVALID_NAME, "Invalid name for sticky note ", this.declarationNode)];
2032
- const i = n.unwrap().join("."), r = Jt(i);
2032
+ const i = n.unwrap().join("."), r = Zt(i);
2033
2033
  return this.publicSymbolTable.has(r) ? [new c(o.DUPLICATE_NAME, `Sticky note "${i}" has already been defined`, e)] : (this.publicSymbolTable.set(r, this.declarationNode.symbol), []);
2034
2034
  }
2035
2035
  validateAlias(e) {
@@ -2041,25 +2041,25 @@ class yn {
2041
2041
  validateBody(e) {
2042
2042
  if (!e)
2043
2043
  return [];
2044
- if (e instanceof w)
2044
+ if (e instanceof v)
2045
2045
  return this.validateFields([e]);
2046
- const [n, s] = I.partition(e.body, (i) => i instanceof w);
2046
+ const [n, s] = I.partition(e.body, (i) => i instanceof v);
2047
2047
  return [...this.validateFields(n), ...this.validateSubElements(s)];
2048
2048
  }
2049
2049
  validateFields(e) {
2050
2050
  const n = [];
2051
- return e.length === 0 ? [new c(o.EMPTY_NOTE, "A Note must have a content", this.declarationNode)] : (e.length > 1 && e.slice(1).forEach((s) => n.push(new c(o.NOTE_CONTENT_REDEFINED, "A Note can only contain one string", s))), $(e[0].callee) || n.push(new c(o.INVALID_NOTE, "A Note content must be a quoted string", e[0])), e[0].args.length > 0 && n.push(...e[0].args.map((s) => new c(o.INVALID_NOTE, "A Note can only contain one quoted string", s))), n);
2051
+ return e.length === 0 ? [new c(o.EMPTY_NOTE, "A Note must have a content", this.declarationNode)] : (e.length > 1 && e.slice(1).forEach((s) => n.push(new c(o.NOTE_CONTENT_REDEFINED, "A Note can only contain one string", s))), W(e[0].callee) || n.push(new c(o.INVALID_NOTE, "A Note content must be a quoted string", e[0])), e[0].args.length > 0 && n.push(...e[0].args.map((s) => new c(o.INVALID_NOTE, "A Note can only contain one quoted string", s))), n);
2052
2052
  }
2053
2053
  validateSubElements(e) {
2054
2054
  return e.flatMap((n) => {
2055
2055
  if (n.parent = this.declarationNode, !n.type)
2056
2056
  return [];
2057
- const s = ae(n);
2057
+ const s = oe(n);
2058
2058
  return new s(n, this.publicSymbolTable, this.symbolFactory).validate();
2059
2059
  });
2060
2060
  }
2061
2061
  }
2062
- class kn {
2062
+ class xn {
2063
2063
  constructor(e, n, s) {
2064
2064
  this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
2065
2065
  }
@@ -2067,7 +2067,7 @@ class kn {
2067
2067
  return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
2068
2068
  }
2069
2069
  validateContext() {
2070
- return this.declarationNode.parent instanceof v ? [new c(o.INVALID_PROJECT_CONTEXT, "A Project can only appear top-level", this.declarationNode)] : [];
2070
+ return this.declarationNode.parent instanceof A ? [new c(o.INVALID_PROJECT_CONTEXT, "A Project can only appear top-level", this.declarationNode)] : [];
2071
2071
  }
2072
2072
  validateName(e) {
2073
2073
  return e ? ye(e) ? [] : [new c(o.INVALID_NAME, "A Project's name is optional or must be an identifier or a quoted identifer", e)] : [];
@@ -2081,9 +2081,9 @@ class kn {
2081
2081
  validateBody(e) {
2082
2082
  if (!e)
2083
2083
  return [];
2084
- if (e instanceof w)
2084
+ if (e instanceof v)
2085
2085
  return [new c(o.UNEXPECTED_SIMPLE_BODY, "A Project's body must be a block", e)];
2086
- const [n, s] = I.partition(e.body, (i) => i instanceof w);
2086
+ const [n, s] = I.partition(e.body, (i) => i instanceof v);
2087
2087
  return [
2088
2088
  ...n.map((i) => new c(o.INVALID_PROJECT_FIELD, "A Project can not have inline fields", i)),
2089
2089
  ...this.validateSubElements(s)
@@ -2093,12 +2093,12 @@ class kn {
2093
2093
  return e.flatMap((n) => {
2094
2094
  if (n.parent = this.declarationNode, !n.type)
2095
2095
  return [];
2096
- const s = ae(n);
2096
+ const s = oe(n);
2097
2097
  return new s(n, this.publicSymbolTable, this.symbolFactory).validate();
2098
2098
  });
2099
2099
  }
2100
2100
  }
2101
- class xn {
2101
+ class Sn {
2102
2102
  constructor(e, n, s) {
2103
2103
  this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
2104
2104
  }
@@ -2106,7 +2106,7 @@ class xn {
2106
2106
  return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
2107
2107
  }
2108
2108
  validateContext() {
2109
- return this.declarationNode.parent instanceof X ? [] : [new c(o.INVALID_REF_CONTEXT, "A Ref must appear top-level", this.declarationNode)];
2109
+ return this.declarationNode.parent instanceof $ ? [] : [new c(o.INVALID_REF_CONTEXT, "A Ref must appear top-level", this.declarationNode)];
2110
2110
  }
2111
2111
  validateName(e) {
2112
2112
  return e ? ye(e) ? [] : [new c(o.INVALID_NAME, "A Ref's name is optional or must be an identifier or a quoted identifer", e)] : [];
@@ -2115,14 +2115,29 @@ class xn {
2115
2115
  return e ? [new c(o.UNEXPECTED_ALIAS, "A Ref shouldn't have an alias", e)] : [];
2116
2116
  }
2117
2117
  validateSettingList(e) {
2118
- return e ? [new c(o.UNEXPECTED_SETTINGS, "A Ref shouldn't have a setting list", e)] : [];
2118
+ if (!e)
2119
+ return [];
2120
+ const n = M(e), s = n.getErrors(), i = n.getValue();
2121
+ for (const r in i) {
2122
+ const a = i[r];
2123
+ switch (r) {
2124
+ case "color":
2125
+ a.length > 1 && s.push(...a.map((l) => new c(o.DUPLICATE_REF_SETTING, "'color' can only appear once", l))), a.forEach((l) => {
2126
+ tt(l.value) || s.push(new c(o.INVALID_TABLE_SETTING, "'color' must be a color literal", l.value || l.name));
2127
+ });
2128
+ break;
2129
+ default:
2130
+ s.push(...a.map((l) => new c(o.INVALID_TABLE_SETTING, `Unknown '${r}' setting`, l)));
2131
+ }
2132
+ }
2133
+ return s;
2119
2134
  }
2120
2135
  validateBody(e) {
2121
2136
  if (!e)
2122
2137
  return [];
2123
- if (e instanceof w)
2138
+ if (e instanceof v)
2124
2139
  return this.validateFields([e]);
2125
- const [n, s] = I.partition(e.body, (i) => i instanceof w);
2140
+ const [n, s] = I.partition(e.body, (i) => i instanceof v);
2126
2141
  return [...this.validateFields(n), ...this.validateSubElements(s)];
2127
2142
  }
2128
2143
  validateFields(e) {
@@ -2130,20 +2145,20 @@ class xn {
2130
2145
  return [new c(o.EMPTY_REF, "A Ref must have at least one field", this.declarationNode)];
2131
2146
  const n = [];
2132
2147
  return e.length > 1 && n.push(...e.slice(1).map((s) => new c(o.REF_REDEFINED, "A Ref can only contain one binary relationship", s))), e.forEach((s) => {
2133
- s.callee && !Ln(s.callee) && n.push(new c(o.INVALID_REF_FIELD, "A Ref field must be a binary relationship", s.callee)), s.callee && !gn(s.callee) && n.push(new c(o.UNEQUAL_FIELDS_BINARY_REF, "Unequal fields in ref endpoints", s.callee));
2148
+ s.callee && !gn(s.callee) && n.push(new c(o.INVALID_REF_FIELD, "A Ref field must be a binary relationship", s.callee)), s.callee && !_n(s.callee) && n.push(new c(o.UNEQUAL_FIELDS_BINARY_REF, "Unequal fields in ref endpoints", s.callee));
2134
2149
  const i = [...s.args];
2135
- I.last(i) instanceof R ? (this.validateFieldSettings(I.last(i)), i.pop()) : i[0] instanceof R && (n.push(...this.validateFieldSettings(i[0])), i.shift()), i.length > 0 && n.push(...i.map((r) => new c(o.INVALID_REF_FIELD, "A Ref field should only have a single binary relationship", r)));
2150
+ I.last(i) instanceof P ? (this.validateFieldSettings(I.last(i)), i.pop()) : i[0] instanceof P && (n.push(...this.validateFieldSettings(i[0])), i.shift()), i.length > 0 && n.push(...i.map((r) => new c(o.INVALID_REF_FIELD, "A Ref field should only have a single binary relationship", r)));
2136
2151
  }), n;
2137
2152
  }
2138
2153
  validateFieldSettings(e) {
2139
- const n = B(e), s = n.getErrors(), i = n.getValue();
2154
+ const n = M(e), s = n.getErrors(), i = n.getValue();
2140
2155
  for (const r in i) {
2141
2156
  const a = i[r];
2142
2157
  switch (r) {
2143
2158
  case "delete":
2144
2159
  case "update":
2145
2160
  a.length > 1 && a.forEach((l) => s.push(new c(o.DUPLICATE_REF_SETTING, `'${r}' can only appear once`, l))), a.forEach((l) => {
2146
- Sn(l.value) || s.push(new c(o.INVALID_REF_SETTING_VALUE, `'${r}' can only have values "cascade", "no action", "set null", "set default" or "restrict"`, l));
2161
+ On(l.value) || s.push(new c(o.INVALID_REF_SETTING_VALUE, `'${r}' can only have values "cascade", "no action", "set null", "set default" or "restrict"`, l));
2147
2162
  });
2148
2163
  break;
2149
2164
  default:
@@ -2156,16 +2171,16 @@ class xn {
2156
2171
  return e.flatMap((n) => {
2157
2172
  if (n.parent = this.declarationNode, !n.type)
2158
2173
  return [];
2159
- const s = ae(n);
2174
+ const s = oe(n);
2160
2175
  return new s(n, this.publicSymbolTable, this.symbolFactory).validate();
2161
2176
  });
2162
2177
  }
2163
2178
  }
2164
- function Sn(t) {
2165
- if (!(M(t) && t.expression.variable.kind !== u.QUOTED_STRING) && !(t instanceof Y))
2179
+ function On(t) {
2180
+ if (!(B(t) && t.expression.variable.kind !== u.QUOTED_STRING) && !(t instanceof z))
2166
2181
  return !1;
2167
2182
  let e;
2168
- if (t instanceof Y ? e = Te(t).unwrap_or("") : e = t.expression.variable.value, e)
2183
+ if (t instanceof z ? e = Te(t).unwrap_or("") : e = t.expression.variable.value, e)
2169
2184
  switch (e.toLowerCase()) {
2170
2185
  case "cascade":
2171
2186
  case "no action":
@@ -2178,7 +2193,7 @@ function Sn(t) {
2178
2193
  }
2179
2194
  return !1;
2180
2195
  }
2181
- class On {
2196
+ class Dn {
2182
2197
  constructor(e, n, s) {
2183
2198
  this.declarationNode = e, this.symbolFactory = s, this.publicSymbolTable = n;
2184
2199
  }
@@ -2186,27 +2201,27 @@ class On {
2186
2201
  return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.registerElement(), ...this.validateBody(this.declarationNode.body)];
2187
2202
  }
2188
2203
  validateContext() {
2189
- return this.declarationNode.parent instanceof v ? [new c(o.INVALID_TABLE_CONTEXT, "Table must appear top-level", this.declarationNode)] : [];
2204
+ return this.declarationNode.parent instanceof A ? [new c(o.INVALID_TABLE_CONTEXT, "Table must appear top-level", this.declarationNode)] : [];
2190
2205
  }
2191
2206
  validateName(e) {
2192
- return e ? e instanceof he ? [new c(o.INVALID_NAME, "Invalid array as Table name, maybe you forget to add a space between the name and the setting list?", e)] : kt(e) ? [] : [new c(o.INVALID_NAME, "A Table name must be of the form <table> or <schema>.<table>", e)] : [new c(o.NAME_NOT_FOUND, "A Table must have a name", this.declarationNode)];
2207
+ return e ? e instanceof he ? [new c(o.INVALID_NAME, "Invalid array as Table name, maybe you forget to add a space between the name and the setting list?", e)] : xt(e) ? [] : [new c(o.INVALID_NAME, "A Table name must be of the form <table> or <schema>.<table>", e)] : [new c(o.NAME_NOT_FOUND, "A Table must have a name", this.declarationNode)];
2193
2208
  }
2194
2209
  validateAlias(e) {
2195
- return e ? Un(e) ? [] : [new c(o.INVALID_ALIAS, "Table aliases can only contains alphanumeric and underscore unless surrounded by double quotes", e)] : [];
2210
+ return e ? Mn(e) ? [] : [new c(o.INVALID_ALIAS, "Table aliases can only contains alphanumeric and underscore unless surrounded by double quotes", e)] : [];
2196
2211
  }
2197
2212
  validateSettingList(e) {
2198
- const n = B(e), s = n.getErrors(), i = n.getValue();
2213
+ const n = M(e), s = n.getErrors(), i = n.getValue();
2199
2214
  for (const r in i) {
2200
2215
  const a = i[r];
2201
2216
  switch (r) {
2202
2217
  case "headercolor":
2203
2218
  a.length > 1 && s.push(...a.map((l) => new c(o.DUPLICATE_TABLE_SETTING, "'headercolor' can only appear once", l))), a.forEach((l) => {
2204
- St(l.value) || s.push(new c(o.INVALID_TABLE_SETTING, "'headercolor' must be a color literal", l.value || l.name));
2219
+ tt(l.value) || s.push(new c(o.INVALID_TABLE_SETTING, "'headercolor' must be a color literal", l.value || l.name));
2205
2220
  });
2206
2221
  break;
2207
2222
  case "note":
2208
2223
  a.length > 1 && s.push(...a.map((l) => new c(o.DUPLICATE_TABLE_SETTING, "'note' can only appear once", l))), a.forEach((l) => {
2209
- $(l.value) || s.push(new c(o.INVALID_TABLE_SETTING, "'note' must be a string literal", l.value || l.name));
2224
+ W(l.value) || s.push(new c(o.INVALID_TABLE_SETTING, "'note' must be a string literal", l.value || l.name));
2210
2225
  });
2211
2226
  break;
2212
2227
  default:
@@ -2217,14 +2232,14 @@ class On {
2217
2232
  }
2218
2233
  registerElement() {
2219
2234
  const e = [];
2220
- this.declarationNode.symbol = this.symbolFactory.create(vt, { declaration: this.declarationNode, symbolTable: new we() });
2221
- const { name: n, alias: s } = this.declarationNode, i = W(n);
2235
+ this.declarationNode.symbol = this.symbolFactory.create(wt, { declaration: this.declarationNode, symbolTable: new we() });
2236
+ const { name: n, alias: s } = this.declarationNode, i = j(n);
2222
2237
  if (i.isOk()) {
2223
- const r = [...i.unwrap()], a = r.pop(), l = Ze(r, this.publicSymbolTable, this.symbolFactory), p = Oe(a);
2238
+ const r = [...i.unwrap()], a = r.pop(), l = et(r, this.publicSymbolTable, this.symbolFactory), p = Oe(a);
2224
2239
  l.has(p) && e.push(new c(o.DUPLICATE_NAME, `Table name '${a}' already exists in schema '${r.join(".") || "public"}'`, n)), l.set(p, this.declarationNode.symbol);
2225
2240
  }
2226
- if (s && ye(s) && !Rn(s.expression.variable.value, i.unwrap_or([]))) {
2227
- const r = C(s).unwrap(), a = Oe(r);
2241
+ if (s && ye(s) && !Pn(s.expression.variable.value, i.unwrap_or([]))) {
2242
+ const r = X(s).unwrap(), a = Oe(r);
2228
2243
  this.publicSymbolTable.has(a) && e.push(new c(o.DUPLICATE_NAME, `Table name '${r}' already exists`, n)), this.publicSymbolTable.set(a, this.declarationNode.symbol);
2229
2244
  }
2230
2245
  return e;
@@ -2232,9 +2247,9 @@ class On {
2232
2247
  validateBody(e) {
2233
2248
  if (!e)
2234
2249
  return [];
2235
- if (e instanceof w)
2250
+ if (e instanceof v)
2236
2251
  return [new c(o.UNEXPECTED_SIMPLE_BODY, "A Table's body must be a block", e)];
2237
- const [n, s] = I.partition(e.body, (i) => i instanceof w);
2252
+ const [n, s] = I.partition(e.body, (i) => i instanceof v);
2238
2253
  return [...this.validateFields(n), ...this.validateSubElements(s)];
2239
2254
  }
2240
2255
  validateFields(e) {
@@ -2242,14 +2257,14 @@ class On {
2242
2257
  if (!n.callee)
2243
2258
  return [];
2244
2259
  const s = [];
2245
- n.args.length === 0 && s.push(new c(o.INVALID_COLUMN, "A column must have a type", n.callee)), M(n.callee) || s.push(new c(o.INVALID_COLUMN_NAME, "A column name must be an identifier or a quoted identifier", n.callee)), n.args[0] && !Dn(n.args[0]) && s.push(new c(o.INVALID_COLUMN_TYPE, "Invalid column type", n.args[0]));
2260
+ n.args.length === 0 && s.push(new c(o.INVALID_COLUMN, "A column must have a type", n.callee)), B(n.callee) || s.push(new c(o.INVALID_COLUMN_NAME, "A column name must be an identifier or a quoted identifier", n.callee)), n.args[0] && !Rn(n.args[0]) && s.push(new c(o.INVALID_COLUMN_TYPE, "Invalid column type", n.args[0]));
2246
2261
  const i = n.args.slice(1);
2247
2262
  return s.push(...this.validateFieldSetting(i)), s.push(...this.registerField(n)), s;
2248
2263
  });
2249
2264
  }
2250
2265
  registerField(e) {
2251
- if (e.callee && M(e.callee)) {
2252
- const n = C(e.callee).unwrap(), s = Ye(n), i = this.symbolFactory.create(rn, { declaration: e });
2266
+ if (e.callee && B(e.callee)) {
2267
+ const n = X(e.callee).unwrap(), s = Qe(n), i = this.symbolFactory.create(an, { declaration: e });
2253
2268
  e.symbol = i;
2254
2269
  const r = this.declarationNode.symbol.symbolTable;
2255
2270
  if (r.has(s)) {
@@ -2265,15 +2280,15 @@ class On {
2265
2280
  }
2266
2281
  // This is needed to support legacy inline settings
2267
2282
  validateFieldSetting(e) {
2268
- if (!e.slice(0, -1).every(me) || !e.slice(-1).every((p) => me(p) || p instanceof R))
2283
+ if (!e.slice(0, -1).every(me) || !e.slice(-1).every((p) => me(p) || p instanceof P))
2269
2284
  return [...e.map((p) => new c(o.INVALID_COLUMN, "These fields must be some inline settings optionally ended with a setting list", p))];
2270
2285
  if (e.length === 0)
2271
2286
  return [];
2272
2287
  let n;
2273
- I.last(e) instanceof R && (n = e.pop());
2274
- const s = B(n), i = s.getErrors(), r = s.getValue();
2288
+ I.last(e) instanceof P && (n = e.pop());
2289
+ const s = M(n), i = s.getErrors(), r = s.getValue();
2275
2290
  for (const p of e) {
2276
- const f = C(p).unwrap_or("").toLowerCase();
2291
+ const f = X(p).unwrap_or("").toLowerCase();
2277
2292
  if (f !== "pk" && f !== "unique") {
2278
2293
  i.push(new c(o.INVALID_SETTINGS, "Inline column settings can only be `pk` or `unique`", p));
2279
2294
  continue;
@@ -2287,12 +2302,12 @@ class On {
2287
2302
  switch (p) {
2288
2303
  case "note":
2289
2304
  f.length > 1 && i.push(...f.map((h) => new c(o.DUPLICATE_COLUMN_SETTING, "note can only appear once", h))), f.forEach((h) => {
2290
- $(h.value) || i.push(new c(o.INVALID_COLUMN_SETTING_VALUE, "'note' must be a quoted string", h.value || h.name));
2305
+ W(h.value) || i.push(new c(o.INVALID_COLUMN_SETTING_VALUE, "'note' must be a quoted string", h.value || h.name));
2291
2306
  });
2292
2307
  break;
2293
2308
  case "ref":
2294
2309
  f.forEach((h) => {
2295
- Fn(h.value) || i.push(new c(o.INVALID_COLUMN_SETTING_VALUE, "'ref' must be a valid unary relationship", h.value || h.name));
2310
+ Bn(h.value) || i.push(new c(o.INVALID_COLUMN_SETTING_VALUE, "'ref' must be a valid unary relationship", h.value || h.name));
2296
2311
  });
2297
2312
  break;
2298
2313
  case "primary key":
@@ -2302,7 +2317,7 @@ class On {
2302
2317
  break;
2303
2318
  case "pk":
2304
2319
  f.length > 1 && i.push(...f.map((h) => new c(o.DUPLICATE_COLUMN_SETTING, "'pk' can only appear once", h))), f.forEach((h) => {
2305
- h instanceof se && !ue(h.value) && i.push(new c(o.INVALID_COLUMN_SETTING_VALUE, "'pk' must not have a value", h.value || h.name));
2320
+ h instanceof ie && !ue(h.value) && i.push(new c(o.INVALID_COLUMN_SETTING_VALUE, "'pk' must not have a value", h.value || h.name));
2306
2321
  });
2307
2322
  break;
2308
2323
  case "not null":
@@ -2319,17 +2334,17 @@ class On {
2319
2334
  break;
2320
2335
  case "unique":
2321
2336
  f.length > 1 && i.push(...f.map((h) => new c(o.DUPLICATE_COLUMN_SETTING, "'unique' can only appear once", h))), f.forEach((h) => {
2322
- h instanceof se && !ue(h.value) && i.push(new c(o.INVALID_COLUMN_SETTING_VALUE, "'unique' must not have a value", h.value || h.name));
2337
+ h instanceof ie && !ue(h.value) && i.push(new c(o.INVALID_COLUMN_SETTING_VALUE, "'unique' must not have a value", h.value || h.name));
2323
2338
  });
2324
2339
  break;
2325
2340
  case "increment":
2326
2341
  f.length > 1 && i.push(...f.map((h) => new c(o.DUPLICATE_COLUMN_SETTING, "'increment' can only appear once", h))), f.forEach((h) => {
2327
- h instanceof se && !ue(h.value) && i.push(new c(o.INVALID_COLUMN_SETTING_VALUE, "'increment' must not have a value", h.value || h.name));
2342
+ h instanceof ie && !ue(h.value) && i.push(new c(o.INVALID_COLUMN_SETTING_VALUE, "'increment' must not have a value", h.value || h.name));
2328
2343
  });
2329
2344
  break;
2330
2345
  case "default":
2331
2346
  f.length > 1 && i.push(...f.map((h) => new c(o.DUPLICATE_TABLE_SETTING, "'default' can only appear once", h))), f.forEach((h) => {
2332
- Mn(h.value) || i.push(new c(o.INVALID_TABLE_SETTING, "'default' must be a string literal, number literal, function expression, true, false or null", h.value || h.name));
2347
+ Fn(h.value) || i.push(new c(o.INVALID_TABLE_SETTING, "'default' must be a string literal, number literal, function expression, true, false or null", h.value || h.name));
2333
2348
  });
2334
2349
  break;
2335
2350
  default:
@@ -2342,7 +2357,7 @@ class On {
2342
2357
  const n = e.flatMap((i) => {
2343
2358
  if (i.parent = this.declarationNode, !i.type)
2344
2359
  return [];
2345
- const r = ae(i);
2360
+ const r = oe(i);
2346
2361
  return new r(i, this.publicSymbolTable, this.symbolFactory).validate();
2347
2362
  }), s = e.filter((i) => {
2348
2363
  var r;
@@ -2351,11 +2366,11 @@ class On {
2351
2366
  return s.length > 1 && n.push(...s.map((i) => new c(o.NOTE_REDEFINED, "Duplicate notes are defined", i))), n;
2352
2367
  }
2353
2368
  }
2354
- function Dn(t) {
2355
- if (!(t instanceof H || Je(t) || t instanceof U || t instanceof he))
2369
+ function Rn(t) {
2370
+ if (!(t instanceof J || Ke(t) || t instanceof F || t instanceof he))
2356
2371
  return !1;
2357
- if (t instanceof H) {
2358
- if (t.callee === void 0 || t.argumentList === void 0 || !t.argumentList.elementList.every((n) => fe(n) || $(n) || me(n)))
2372
+ if (t instanceof J) {
2373
+ if (t.callee === void 0 || t.argumentList === void 0 || !t.argumentList.elementList.every((n) => fe(n) || W(n) || me(n)))
2359
2374
  return !1;
2360
2375
  t = t.callee;
2361
2376
  }
@@ -2364,13 +2379,13 @@ function Dn(t) {
2364
2379
  return !1;
2365
2380
  t = t.array;
2366
2381
  }
2367
- const e = W(t).unwrap_or(void 0);
2382
+ const e = j(t).unwrap_or(void 0);
2368
2383
  return e !== void 0 && e.length > 0;
2369
2384
  }
2370
- function Rn(t, e) {
2385
+ function Pn(t, e) {
2371
2386
  return e.length === 1 && t === e[0];
2372
2387
  }
2373
- class Pn {
2388
+ class Un {
2374
2389
  constructor(e, n, s) {
2375
2390
  this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
2376
2391
  }
@@ -2385,7 +2400,7 @@ class Pn {
2385
2400
  ];
2386
2401
  }
2387
2402
  validateContext() {
2388
- return this.declarationNode.parent instanceof v ? [new c(
2403
+ return this.declarationNode.parent instanceof A ? [new c(
2389
2404
  o.INVALID_TABLEGROUP_CONTEXT,
2390
2405
  "TableGroup must appear top-level",
2391
2406
  this.declarationNode
@@ -2411,10 +2426,10 @@ class Pn {
2411
2426
  }
2412
2427
  registerElement() {
2413
2428
  const { name: e } = this.declarationNode;
2414
- this.declarationNode.symbol = this.symbolFactory.create(an, { declaration: this.declarationNode, symbolTable: new we() });
2415
- const n = W(e);
2429
+ this.declarationNode.symbol = this.symbolFactory.create(on, { declaration: this.declarationNode, symbolTable: new we() });
2430
+ const n = j(e);
2416
2431
  if (n.isOk()) {
2417
- const s = n.unwrap(), i = s.pop(), r = Ze(s, this.publicSymbolTable, this.symbolFactory), a = qe(i);
2432
+ const s = n.unwrap(), i = s.pop(), r = et(s, this.publicSymbolTable, this.symbolFactory), a = Je(i);
2418
2433
  if (r.has(a))
2419
2434
  return [new c(o.DUPLICATE_NAME, `TableGroup name '${i}' already exists`, e)];
2420
2435
  r.set(a, this.declarationNode.symbol);
@@ -2422,7 +2437,7 @@ class Pn {
2422
2437
  return [];
2423
2438
  }
2424
2439
  validateSettingList(e) {
2425
- const n = B(e), s = n.getErrors(), i = n.getValue();
2440
+ const n = M(e), s = n.getErrors(), i = n.getValue();
2426
2441
  return I.forIn(i, (r, a) => {
2427
2442
  switch (a) {
2428
2443
  case "color":
@@ -2431,7 +2446,7 @@ class Pn {
2431
2446
  "'color' can only appear once",
2432
2447
  l
2433
2448
  ))), r.forEach((l) => {
2434
- St(l.value) || s.push(new c(
2449
+ tt(l.value) || s.push(new c(
2435
2450
  o.INVALID_TABLE_SETTING,
2436
2451
  "'color' must be a color literal",
2437
2452
  l.value || l.name
@@ -2443,7 +2458,7 @@ class Pn {
2443
2458
  o.DUPLICATE_TABLE_SETTING,
2444
2459
  "'note' can only appear once",
2445
2460
  l
2446
- ))), r.filter((l) => !$(l.value)).forEach((l) => {
2461
+ ))), r.filter((l) => !W(l.value)).forEach((l) => {
2447
2462
  s.push(new c(
2448
2463
  o.INVALID_TABLE_SETTING,
2449
2464
  "'note' must be a string literal",
@@ -2464,13 +2479,13 @@ class Pn {
2464
2479
  validateBody(e) {
2465
2480
  if (!e)
2466
2481
  return [];
2467
- if (e instanceof w)
2482
+ if (e instanceof v)
2468
2483
  return [new c(
2469
2484
  o.UNEXPECTED_SIMPLE_BODY,
2470
2485
  "A TableGroup's body must be a block",
2471
2486
  e
2472
2487
  )];
2473
- const [n, s] = I.partition(e.body, (i) => i instanceof w);
2488
+ const [n, s] = I.partition(e.body, (i) => i instanceof v);
2474
2489
  return [
2475
2490
  ...this.validateFields(n),
2476
2491
  ...this.validateSubElements(s)
@@ -2479,14 +2494,14 @@ class Pn {
2479
2494
  validateFields(e) {
2480
2495
  return e.flatMap((n) => {
2481
2496
  const s = [];
2482
- return n.callee && !W(n.callee).isOk() && s.push(new c(o.INVALID_TABLEGROUP_FIELD, "A TableGroup field must be of the form <table> or <schema>.<table>", n.callee)), this.registerField(n), n.args.length > 0 && s.push(...n.args.map((i) => new c(o.INVALID_TABLEGROUP_FIELD, "A TableGroup field should only have a single Table name", i))), s;
2497
+ return n.callee && !j(n.callee).isOk() && s.push(new c(o.INVALID_TABLEGROUP_FIELD, "A TableGroup field must be of the form <table> or <schema>.<table>", n.callee)), this.registerField(n), n.args.length > 0 && s.push(...n.args.map((i) => new c(o.INVALID_TABLEGROUP_FIELD, "A TableGroup field should only have a single Table name", i))), s;
2483
2498
  });
2484
2499
  }
2485
2500
  validateSubElements(e) {
2486
2501
  const n = e.flatMap((i) => {
2487
2502
  if (i.parent = this.declarationNode, !i.type)
2488
2503
  return [];
2489
- const r = ae(i);
2504
+ const r = oe(i);
2490
2505
  return new r(i, this.publicSymbolTable, this.symbolFactory).validate();
2491
2506
  }), s = e.filter((i) => {
2492
2507
  var r;
@@ -2495,8 +2510,8 @@ class Pn {
2495
2510
  return s.length > 1 && n.push(...s.map((i) => new c(o.NOTE_REDEFINED, "Duplicate notes are defined", i))), n;
2496
2511
  }
2497
2512
  registerField(e) {
2498
- if (e.callee && M(e.callee)) {
2499
- const n = C(e.callee).unwrap(), s = He(n), i = this.symbolFactory.create(on, { declaration: e });
2513
+ if (e.callee && B(e.callee)) {
2514
+ const n = X(e.callee).unwrap(), s = Ze(n), i = this.symbolFactory.create(ln, { declaration: e });
2500
2515
  e.symbol = i;
2501
2516
  const r = this.declarationNode.symbol.symbolTable;
2502
2517
  if (r.has(s)) {
@@ -2511,111 +2526,111 @@ class Pn {
2511
2526
  return [];
2512
2527
  }
2513
2528
  }
2514
- const yt = ["-", "+"];
2515
- function ae(t) {
2529
+ const kt = ["-", "+"];
2530
+ function oe(t) {
2516
2531
  switch (t.type.value.toLowerCase()) {
2517
2532
  case b.Enum:
2518
- return vn;
2533
+ return wn;
2519
2534
  case b.Table:
2520
- return On;
2535
+ return Dn;
2521
2536
  case b.TableGroup:
2522
- return Pn;
2537
+ return Un;
2523
2538
  case b.Project:
2524
- return kn;
2525
- case b.Ref:
2526
2539
  return xn;
2540
+ case b.Ref:
2541
+ return Sn;
2527
2542
  case b.Note:
2528
- return yn;
2543
+ return kn;
2529
2544
  case b.Indexes:
2530
- return wn;
2545
+ return yn;
2531
2546
  default:
2532
- return An;
2547
+ return vn;
2533
2548
  }
2534
2549
  }
2535
- function kt(t) {
2536
- return !!W(t).unwrap_or(!1);
2550
+ function xt(t) {
2551
+ return !!j(t).unwrap_or(!1);
2537
2552
  }
2538
- function Un(t) {
2553
+ function Mn(t) {
2539
2554
  return ye(t);
2540
2555
  }
2541
2556
  function ye(t) {
2542
- return t instanceof U && t.expression instanceof K;
2557
+ return t instanceof F && t.expression instanceof ee;
2543
2558
  }
2544
- function Ze(t, e, n) {
2559
+ function et(t, e, n) {
2545
2560
  var i;
2546
2561
  t[0] === "public" && (t = t.slice(1));
2547
2562
  let s = e;
2548
2563
  for (const r of t) {
2549
2564
  let a;
2550
- const l = je(r);
2565
+ const l = ze(r);
2551
2566
  if (s.has(l)) {
2552
2567
  if (a = (i = s.get(l)) == null ? void 0 : i.symbolTable, !a)
2553
2568
  throw new Error("Expect a symbol table in a schema symbol");
2554
2569
  } else {
2555
2570
  a = new we();
2556
- const p = n.create(At, { symbolTable: a });
2571
+ const p = n.create(vt, { symbolTable: a });
2557
2572
  s.set(l, p);
2558
2573
  }
2559
2574
  s = a;
2560
2575
  }
2561
2576
  return s;
2562
2577
  }
2563
- function xt(t) {
2578
+ function St(t) {
2564
2579
  return t === "-" || t === "<>" || t === ">" || t === "<";
2565
2580
  }
2566
- function St(t) {
2581
+ function tt(t) {
2567
2582
  var n;
2568
- if (!(t instanceof U) || !(t.expression instanceof be) || ((n = t.expression.literal) == null ? void 0 : n.kind) !== u.COLOR_LITERAL)
2583
+ if (!(t instanceof F) || !(t.expression instanceof be) || ((n = t.expression.literal) == null ? void 0 : n.kind) !== u.COLOR_LITERAL)
2569
2584
  return !1;
2570
2585
  const e = t.expression.literal.value;
2571
2586
  if (e.length !== 4 && e.length !== 7 || e[0] !== "#")
2572
2587
  return !1;
2573
2588
  for (let s = 1; s < e.length; s += 1)
2574
- if (!en(e[s]))
2589
+ if (!tn(e[s]))
2575
2590
  return !1;
2576
2591
  return !0;
2577
2592
  }
2578
2593
  function ue(t) {
2579
2594
  return t === void 0;
2580
2595
  }
2581
- function Mn(t) {
2596
+ function Fn(t) {
2582
2597
  var e;
2583
- return !!($(t) || fe(t) || me(t) && ["true", "false", "null"].includes(t.expression.variable.value.toLowerCase()) || t instanceof Q && yt.includes((e = t.op) == null ? void 0 : e.value) && fe(t.expression) || t instanceof ne);
2598
+ return !!(W(t) || fe(t) || me(t) && ["true", "false", "null"].includes(t.expression.variable.value.toLowerCase()) || t instanceof q && kt.includes((e = t.op) == null ? void 0 : e.value) && fe(t.expression) || t instanceof se);
2584
2599
  }
2585
2600
  function fe(t) {
2586
2601
  var e;
2587
- return t instanceof U && t.expression instanceof be && ((e = t.expression.literal) == null ? void 0 : e.kind) === u.NUMERIC_LITERAL;
2602
+ return t instanceof F && t.expression instanceof be && ((e = t.expression.literal) == null ? void 0 : e.kind) === u.NUMERIC_LITERAL;
2588
2603
  }
2589
- function Fn(t) {
2604
+ function Bn(t) {
2590
2605
  var n;
2591
- if (!(t instanceof Q) || !xt((n = t.op) == null ? void 0 : n.value))
2606
+ if (!(t instanceof q) || !St((n = t.op) == null ? void 0 : n.value))
2592
2607
  return !1;
2593
- const e = W(t.expression).unwrap_or(void 0);
2608
+ const e = j(t.expression).unwrap_or(void 0);
2594
2609
  return e !== void 0 && e.length > 0;
2595
2610
  }
2596
2611
  function Ot(t) {
2597
- return t instanceof Z && t.elementList.every(M);
2612
+ return t instanceof K && t.elementList.every(B);
2598
2613
  }
2599
- function B(t) {
2614
+ function M(t) {
2600
2615
  var s;
2601
2616
  const e = {}, n = [];
2602
2617
  if (!t)
2603
- return new V({});
2618
+ return new G({});
2604
2619
  for (const i of t.elementList) {
2605
2620
  if (!i.name)
2606
2621
  continue;
2607
- if (i.name instanceof U) {
2622
+ if (i.name instanceof F) {
2608
2623
  n.push(new c(o.INVALID_SETTINGS, "A setting name must be a stream of identifiers", i.name));
2609
2624
  continue;
2610
2625
  }
2611
2626
  const r = (s = Te(i.name).unwrap_or(void 0)) == null ? void 0 : s.toLowerCase();
2612
2627
  r && (e[r] === void 0 ? e[r] = [i] : e[r].push(i));
2613
2628
  }
2614
- return new V(e, n);
2629
+ return new G(e, n);
2615
2630
  }
2616
- class pt {
2631
+ class dt {
2617
2632
  constructor(e, n) {
2618
- this.ast = e, this.symbolFactory = n, this.publicSchemaSymbol = this.symbolFactory.create(At, {
2633
+ this.ast = e, this.symbolFactory = n, this.publicSchemaSymbol = this.symbolFactory.create(vt, {
2619
2634
  symbolTable: new we()
2620
2635
  }), this.ast.symbol = this.publicSchemaSymbol, this.ast.symbol.declaration = this.ast;
2621
2636
  }
@@ -2624,7 +2639,7 @@ class pt {
2624
2639
  this.ast.body.forEach((s) => {
2625
2640
  if (s.parent = this.ast, s.type === void 0)
2626
2641
  return;
2627
- const i = ae(s), r = new i(
2642
+ const i = oe(s), r = new i(
2628
2643
  s,
2629
2644
  this.publicSchemaSymbol.symbolTable,
2630
2645
  this.symbolFactory
@@ -2632,10 +2647,10 @@ class pt {
2632
2647
  e.push(...r.validate());
2633
2648
  });
2634
2649
  const n = this.ast.body.filter((s) => ve(s).unwrap_or(void 0) === b.Project);
2635
- return n.length > 1 && n.forEach((s) => e.push(new c(o.PROJECT_REDEFINED, "Only one project can exist", s))), new V(this.ast, e);
2650
+ return n.length > 1 && n.forEach((s) => e.push(new c(o.PROJECT_REDEFINED, "Only one project can exist", s))), new G(this.ast, e);
2636
2651
  }
2637
2652
  }
2638
- class oe {
2653
+ class le {
2639
2654
  constructor(e, n) {
2640
2655
  this.declarationNode = e, this.errors = n;
2641
2656
  }
@@ -2645,7 +2660,7 @@ class oe {
2645
2660
  bindSettingList(e, n) {
2646
2661
  if (e)
2647
2662
  for (const s of e.elementList) {
2648
- if (s.name instanceof U)
2663
+ if (s.name instanceof F)
2649
2664
  continue;
2650
2665
  const i = Te(s.name).unwrap_or(void 0);
2651
2666
  if (!i)
@@ -2659,9 +2674,9 @@ class oe {
2659
2674
  if (!e.body)
2660
2675
  return;
2661
2676
  const { body: n } = e;
2662
- if (n instanceof J)
2677
+ if (n instanceof Z)
2663
2678
  for (const s of n.body)
2664
- if (s instanceof v) {
2679
+ if (s instanceof A) {
2665
2680
  if (!s.type)
2666
2681
  continue;
2667
2682
  const i = Dt(s);
@@ -2673,7 +2688,7 @@ class oe {
2673
2688
  }
2674
2689
  bindSubfield(e) {
2675
2690
  const n = [e.callee, ...e.args], s = I.last(n);
2676
- s instanceof R && (n.pop(), this.bindSettingList(s, this.subfield.settingList));
2691
+ s instanceof P && (n.pop(), this.bindSettingList(s, this.subfield.settingList));
2677
2692
  const { argBinderRules: i } = this.subfield.arg;
2678
2693
  for (let r = 0; r < Math.min(n.length, i.length); r += 1)
2679
2694
  i[r].shouldBind && this.scanAndBind(n[r], i[r]);
@@ -2682,12 +2697,12 @@ class oe {
2682
2697
  scanAndBind(e, n) {
2683
2698
  var s, i;
2684
2699
  if (e)
2685
- if (e instanceof U) {
2686
- if (e.expression instanceof K && ((i = n.keywords) != null && i.includes((s = e.expression.variable) == null ? void 0 : s.value.toLowerCase())))
2700
+ if (e instanceof F) {
2701
+ if (e.expression instanceof ee && ((i = n.keywords) != null && i.includes((s = e.expression.variable) == null ? void 0 : s.value.toLowerCase())))
2687
2702
  return;
2688
2703
  this.bindFragments([e], n);
2689
2704
  } else
2690
- e instanceof q ? Je(e) ? this.bindFragments(pe(e).unwrap_or([]), n) : (this.scanAndBind(e.leftExpression, n), this.scanAndBind(e.rightExpression, n)) : e instanceof Q ? this.scanAndBind(e.expression, n) : e instanceof Ue ? this.scanAndBind(e.expression, n) : e instanceof Z && e.elementList.forEach((r) => this.scanAndBind(r, n));
2705
+ e instanceof H ? Ke(e) ? this.bindFragments(pe(e).unwrap_or([]), n) : (this.scanAndBind(e.leftExpression, n), this.scanAndBind(e.rightExpression, n)) : e instanceof q ? this.scanAndBind(e.expression, n) : e instanceof Ue ? this.scanAndBind(e.expression, n) : e instanceof K && e.elementList.forEach((r) => this.scanAndBind(r, n));
2691
2706
  }
2692
2707
  // Bind the fragments of a member access expression
2693
2708
  // which can be a simple expression like v1.User,
@@ -2695,7 +2710,7 @@ class oe {
2695
2710
  bindFragments(e, n) {
2696
2711
  if (e.length === 0)
2697
2712
  return;
2698
- const s = [...n.topSubnamesSymbolKind], { remainingSubnamesSymbolKind: i } = n, r = e.findIndex((h) => !M(h)), l = r !== -1 && Ot(e[r]) ? e[r] : void 0, p = r >= 0 ? s.pop() : void 0, f = e.slice(
2713
+ const s = [...n.topSubnamesSymbolKind], { remainingSubnamesSymbolKind: i } = n, r = e.findIndex((h) => !B(h)), l = r !== -1 && Ot(e[r]) ? e[r] : void 0, p = r >= 0 ? s.pop() : void 0, f = e.slice(
2699
2714
  0,
2700
2715
  r === -1 ? void 0 : r
2701
2716
  );
@@ -2703,16 +2718,16 @@ class oe {
2703
2718
  return;
2704
2719
  const E = [];
2705
2720
  for (; s.length && f.length; ) {
2706
- const h = s.pop(), m = f.pop(), g = C(m).unwrap();
2721
+ const h = s.pop(), m = f.pop(), g = X(m).unwrap();
2707
2722
  E.unshift({
2708
- index: Ve(g, h),
2723
+ index: Ge(g, h),
2709
2724
  referrer: m
2710
2725
  });
2711
2726
  }
2712
2727
  for (; f.length; ) {
2713
- const h = f.pop(), m = C(h).unwrap();
2728
+ const h = f.pop(), m = X(h).unwrap();
2714
2729
  E.unshift({
2715
- index: Ve(m, i),
2730
+ index: Ge(m, i),
2716
2731
  referrer: h
2717
2732
  });
2718
2733
  }
@@ -2721,8 +2736,8 @@ class oe {
2721
2736
  [
2722
2737
  ...E,
2723
2738
  {
2724
- index: Ve(
2725
- C(h).unwrap(),
2739
+ index: Ge(
2740
+ X(h).unwrap(),
2726
2741
  p
2727
2742
  ),
2728
2743
  referrer: h
@@ -2737,16 +2752,16 @@ class oe {
2737
2752
  resolveIndexStack(e, n) {
2738
2753
  if (e.length === 0)
2739
2754
  throw new Error("Unreachable - An unresolved name must have at least one name component");
2740
- const [s, ...i] = e, r = _n(s.index, this.declarationNode);
2755
+ const [s, ...i] = e, r = An(s.index, this.declarationNode);
2741
2756
  if (r === void 0) {
2742
- const { kind: f, name: E } = ie(s.index).unwrap();
2757
+ const { kind: f, name: E } = re(s.index).unwrap();
2743
2758
  this.logError(s.referrer, `Can not find ${f} '${E}'`, n);
2744
2759
  return;
2745
2760
  }
2746
2761
  r.references.push(s.referrer), s.referrer.referee = r;
2747
- let a = r.symbolTable, { kind: l, name: p } = ie(s.index).unwrap();
2762
+ let a = r.symbolTable, { kind: l, name: p } = re(s.index).unwrap();
2748
2763
  for (const f of i) {
2749
- const { kind: E, name: h } = ie(f.index).unwrap(), m = a.get(f.index);
2764
+ const { kind: E, name: h } = re(f.index).unwrap(), m = a.get(f.index);
2750
2765
  if (!m) {
2751
2766
  this.logError(
2752
2767
  f.referrer,
@@ -2764,7 +2779,7 @@ class oe {
2764
2779
  s || this.errors.push(new c(o.BINDING_ERROR, n, e));
2765
2780
  }
2766
2781
  }
2767
- class Bn extends oe {
2782
+ class Vn extends le {
2768
2783
  constructor() {
2769
2784
  super(...arguments), this.subfield = {
2770
2785
  arg: {
@@ -2774,7 +2789,7 @@ class Bn extends oe {
2774
2789
  }, this.settingList = {};
2775
2790
  }
2776
2791
  }
2777
- class Vn extends oe {
2792
+ class Gn extends le {
2778
2793
  constructor() {
2779
2794
  super(...arguments), this.subfield = {
2780
2795
  arg: {
@@ -2784,7 +2799,7 @@ class Vn extends oe {
2784
2799
  }, this.settingList = {};
2785
2800
  }
2786
2801
  }
2787
- class Gn extends oe {
2802
+ class Cn extends le {
2788
2803
  constructor() {
2789
2804
  super(...arguments), this.subfield = {
2790
2805
  arg: {
@@ -2819,7 +2834,7 @@ class Gn extends oe {
2819
2834
  }, this.settingList = {};
2820
2835
  }
2821
2836
  }
2822
- class Cn extends oe {
2837
+ class Xn extends le {
2823
2838
  constructor() {
2824
2839
  super(...arguments), this.subfield = {
2825
2840
  arg: {
@@ -2829,7 +2844,7 @@ class Cn extends oe {
2829
2844
  }, this.settingList = {};
2830
2845
  }
2831
2846
  }
2832
- class Xn extends oe {
2847
+ class $n extends le {
2833
2848
  constructor() {
2834
2849
  super(...arguments), this.subfield = {
2835
2850
  arg: {
@@ -2839,7 +2854,7 @@ class Xn extends oe {
2839
2854
  }, this.settingList = {};
2840
2855
  }
2841
2856
  }
2842
- class $n extends oe {
2857
+ class Wn extends le {
2843
2858
  constructor() {
2844
2859
  super(...arguments), this.subfield = {
2845
2860
  arg: {
@@ -2856,7 +2871,7 @@ class $n extends oe {
2856
2871
  }, this.settingList = {};
2857
2872
  }
2858
2873
  }
2859
- class Wn extends oe {
2874
+ class jn extends le {
2860
2875
  constructor() {
2861
2876
  super(...arguments), this.subfield = {
2862
2877
  arg: {
@@ -2884,7 +2899,7 @@ class Wn extends oe {
2884
2899
  }, this.settingList = {};
2885
2900
  }
2886
2901
  }
2887
- class jn extends oe {
2902
+ class Yn extends le {
2888
2903
  constructor() {
2889
2904
  super(...arguments), this.subfield = {
2890
2905
  arg: {
@@ -2904,24 +2919,24 @@ class jn extends oe {
2904
2919
  function Dt(t) {
2905
2920
  switch (t.type.value.toLowerCase()) {
2906
2921
  case b.Enum:
2907
- return Vn;
2922
+ return Gn;
2908
2923
  case b.Table:
2909
- return Wn;
2910
- case b.TableGroup:
2911
2924
  return jn;
2925
+ case b.TableGroup:
2926
+ return Yn;
2912
2927
  case b.Project:
2913
- return Xn;
2914
- case b.Ref:
2915
2928
  return $n;
2929
+ case b.Ref:
2930
+ return Wn;
2916
2931
  case b.Note:
2917
- return Cn;
2932
+ return Xn;
2918
2933
  case b.Indexes:
2919
- return Gn;
2934
+ return Cn;
2920
2935
  default:
2921
- return Bn;
2936
+ return Vn;
2922
2937
  }
2923
2938
  }
2924
- class Yn {
2939
+ class zn {
2925
2940
  constructor(e) {
2926
2941
  this.ast = e, this.errors = [];
2927
2942
  }
@@ -2931,10 +2946,10 @@ class Yn {
2931
2946
  const n = Dt(e);
2932
2947
  new n(e, this.errors).bind();
2933
2948
  }
2934
- return new V(this.ast, this.errors);
2949
+ return new G(this.ast, this.errors);
2935
2950
  }
2936
2951
  }
2937
- class zn {
2952
+ class Qn {
2938
2953
  constructor(e) {
2939
2954
  this.generator = e;
2940
2955
  }
@@ -2942,20 +2957,20 @@ class zn {
2942
2957
  return new e(n, this.generator.nextId());
2943
2958
  }
2944
2959
  }
2945
- class Qn {
2960
+ class qn {
2946
2961
  constructor(e, n) {
2947
- this.ast = e, this.symbolFactory = new zn(n);
2962
+ this.ast = e, this.symbolFactory = new Qn(n);
2948
2963
  }
2949
2964
  // Analyzing: Invoking both the validator and binder
2950
2965
  analyze() {
2951
- return new pt(this.ast, this.symbolFactory).validate().chain((n) => new Yn(n).resolve());
2966
+ return new dt(this.ast, this.symbolFactory).validate().chain((n) => new zn(n).resolve());
2952
2967
  }
2953
2968
  // For invoking the validator only
2954
2969
  validate() {
2955
- return new pt(this.ast, this.symbolFactory).validate().chain((n) => new V(n, []));
2970
+ return new dt(this.ast, this.symbolFactory).validate().chain((n) => new G(n, []));
2956
2971
  }
2957
2972
  }
2958
- function dt(t, e) {
2973
+ function Et(t, e) {
2959
2974
  const { variables: n, tupleElements: s } = _e(t).unwrap();
2960
2975
  return s ? n.length === 0 ? {
2961
2976
  schemaName: e.schemaName,
@@ -2988,7 +3003,7 @@ function Rt(t) {
2988
3003
  }
2989
3004
  throw new Error("Invalid relation op");
2990
3005
  }
2991
- function A(t) {
3006
+ function _(t) {
2992
3007
  return {
2993
3008
  start: {
2994
3009
  offset: t.startPos.offset,
@@ -2998,19 +3013,19 @@ function A(t) {
2998
3013
  end: { offset: t.endPos.offset, line: t.endPos.line + 1, column: t.endPos.column + 1 }
2999
3014
  };
3000
3015
  }
3001
- function $e(t) {
3016
+ function je(t) {
3002
3017
  var n;
3003
3018
  const e = (n = pe(t).unwrap_or(void 0)) == null ? void 0 : n.pop();
3004
- return e instanceof Z ? e.elementList.map((s) => s.referee) : [e.referee];
3019
+ return e instanceof K ? e.elementList.map((s) => s.referee) : [e.referee];
3005
3020
  }
3006
3021
  function Ie(t) {
3007
- const e = W(t).unwrap();
3022
+ const e = j(t).unwrap();
3008
3023
  return {
3009
3024
  name: e.pop(),
3010
3025
  schemaName: e
3011
3026
  };
3012
3027
  }
3013
- function Ke(t) {
3028
+ function Fe(t) {
3014
3029
  return t.expression.literal.value;
3015
3030
  }
3016
3031
  function Pt(t, e) {
@@ -3029,7 +3044,7 @@ function Ut(t, e) {
3029
3044
  const n = t.id, s = e.id;
3030
3045
  return n === s;
3031
3046
  }
3032
- function re(t) {
3047
+ function ae(t) {
3033
3048
  const e = t.split(`
3034
3049
  `), n = e.slice(e.findIndex((r) => r.trimStart() !== "")), s = n.filter((r) => r.trimStart()), i = Math.min(...s.map((r) => r.length - r.trimStart().length));
3035
3050
  return n.map((r) => r.slice(i)).join(`
@@ -3040,7 +3055,7 @@ class Mt {
3040
3055
  this.declarationNode = e, this.env = n, this.table = { name: void 0, schemaName: void 0, alias: null, fields: [], token: void 0, indexes: [] }, this.pkColumns = [];
3041
3056
  }
3042
3057
  interpret() {
3043
- this.table.token = A(this.declarationNode), this.env.tables.set(this.declarationNode, this.table);
3058
+ this.table.token = _(this.declarationNode), this.env.tables.set(this.declarationNode, this.table);
3044
3059
  const e = [
3045
3060
  ...this.interpretName(this.declarationNode.name),
3046
3061
  ...this.interpretAlias(this.declarationNode.alias),
@@ -3065,7 +3080,7 @@ class Mt {
3065
3080
  interpretAlias(e) {
3066
3081
  if (!e)
3067
3082
  return [];
3068
- const n = C(e).unwrap_or(null);
3083
+ const n = X(e).unwrap_or(null);
3069
3084
  return n && (this.env.aliases.push({
3070
3085
  name: n,
3071
3086
  kind: "table",
@@ -3077,16 +3092,16 @@ class Mt {
3077
3092
  }
3078
3093
  interpretSettingList(e) {
3079
3094
  var i, r, a;
3080
- const n = B(e).getValue();
3081
- this.table.headerColor = (i = n.headercolor) != null && i.length ? Ke((a = (r = n.headercolor) == null ? void 0 : r.at(0)) == null ? void 0 : a.value) : void 0;
3095
+ const n = M(e).getValue();
3096
+ this.table.headerColor = (i = n.headercolor) != null && i.length ? Fe((a = (r = n.headercolor) == null ? void 0 : r.at(0)) == null ? void 0 : a.value) : void 0;
3082
3097
  const [s] = n.note || [];
3083
3098
  return this.table.note = s && {
3084
- value: G(s == null ? void 0 : s.value).map(re).unwrap(),
3085
- token: A(s)
3099
+ value: C(s == null ? void 0 : s.value).map(ae).unwrap(),
3100
+ token: _(s)
3086
3101
  }, [];
3087
3102
  }
3088
3103
  interpretBody(e) {
3089
- const [n, s] = I.partition(e.body, (i) => i instanceof w);
3104
+ const [n, s] = I.partition(e.body, (i) => i instanceof v);
3090
3105
  return [...this.interpretFields(n), ...this.interpretSubElements(s)];
3091
3106
  }
3092
3107
  interpretSubElements(e) {
@@ -3095,8 +3110,8 @@ class Mt {
3095
3110
  switch ((s = n.type) == null ? void 0 : s.value.toLowerCase()) {
3096
3111
  case "note":
3097
3112
  return this.table.note = {
3098
- value: G(n.body instanceof J ? n.body.body[0].callee : n.body.callee).map(re).unwrap(),
3099
- token: A(n)
3113
+ value: C(n.body instanceof Z ? n.body.body[0].callee : n.body.callee).map(ae).unwrap(),
3114
+ token: _(n)
3100
3115
  }, [];
3101
3116
  case "indexes":
3102
3117
  return this.interpretIndexes(n);
@@ -3108,105 +3123,105 @@ class Mt {
3108
3123
  return e.flatMap((n) => this.interpretColumn(n));
3109
3124
  }
3110
3125
  interpretColumn(e) {
3111
- var a, l, p, f, E, h, m, g;
3126
+ var a, l, p, f, E, h, m, g, R;
3112
3127
  const n = [], s = {};
3113
- s.name = C(e.callee).unwrap();
3114
- const i = qn(e.args[0]);
3115
- s.type = i.getValue(), n.push(...i.getErrors()), s.token = A(e), s.inline_refs = [];
3128
+ s.name = X(e.callee).unwrap();
3129
+ const i = Hn(e.args[0]);
3130
+ s.type = i.getValue(), n.push(...i.getErrors()), s.token = _(e), s.inline_refs = [];
3116
3131
  const r = e.args.slice(1);
3117
- if (I.last(r) instanceof R) {
3118
- const _ = B(r.pop()).getValue();
3119
- s.pk = !!((a = _.pk) != null && a.length) || !!((l = _["primary key"]) != null && l.length), s.increment = !!((p = _.increment) != null && p.length), s.unique = !!((f = _.unique) != null && f.length), s.not_null = !!((E = _["not null"]) != null && E.length) && !0, s.dbdefault = Hn((m = (h = _.default) == null ? void 0 : h.at(0)) == null ? void 0 : m.value);
3120
- const ee = (g = _.note) == null ? void 0 : g.at(0);
3121
- s.note = ee && {
3122
- value: G(ee.value).map(re).unwrap(),
3123
- token: A(ee)
3132
+ if (I.last(r) instanceof P) {
3133
+ const S = M(r.pop()).getValue();
3134
+ s.pk = !!((a = S.pk) != null && a.length) || !!((l = S["primary key"]) != null && l.length), s.increment = !!((p = S.increment) != null && p.length), s.unique = !!((f = S.unique) != null && f.length), s.not_null = (E = S["not null"]) != null && E.length ? !0 : (h = S.null) != null && h.length ? !1 : void 0, s.dbdefault = Jn((g = (m = S.default) == null ? void 0 : m.at(0)) == null ? void 0 : g.value);
3135
+ const te = (R = S.note) == null ? void 0 : R.at(0);
3136
+ s.note = te && {
3137
+ value: C(te.value).map(ae).unwrap(),
3138
+ token: _(te)
3124
3139
  };
3125
- const le = _.ref || [];
3126
- s.inline_refs = le.flatMap((z) => {
3127
- const [nt] = $e(z.value.expression);
3128
- if (Ut(nt, e.symbol))
3129
- return n.push(new c(o.SAME_ENDPOINT, "Two endpoints are the same", z)), [];
3130
- const ke = z.value.op, te = W(z.value.expression).unwrap();
3140
+ const Yt = S.ref || [];
3141
+ s.inline_refs = Yt.flatMap((Q) => {
3142
+ const [it] = je(Q.value.expression);
3143
+ if (Ut(it, e.symbol))
3144
+ return n.push(new c(o.SAME_ENDPOINT, "Two endpoints are the same", Q)), [];
3145
+ const ke = Q.value.op, ne = j(Q.value.expression).unwrap();
3131
3146
  let de;
3132
- if (te.length === 1) {
3133
- const [ce] = te;
3147
+ if (ne.length === 1) {
3148
+ const [ce] = ne;
3134
3149
  de = {
3135
3150
  schemaName: this.table.schemaName,
3136
3151
  tableName: this.table.name,
3137
3152
  fieldNames: [ce],
3138
3153
  relation: ke.value,
3139
- token: A(z)
3154
+ token: _(Q)
3140
3155
  };
3141
- } else if (te.length === 2) {
3142
- const [ce, Le] = te;
3156
+ } else if (ne.length === 2) {
3157
+ const [ce, Le] = ne;
3143
3158
  de = {
3144
3159
  schemaName: null,
3145
3160
  tableName: ce,
3146
3161
  fieldNames: [Le],
3147
3162
  relation: ke.value,
3148
- token: A(z)
3163
+ token: _(Q)
3149
3164
  };
3150
- } else if (te.length === 3) {
3151
- const [ce, Le, it] = te;
3165
+ } else if (ne.length === 3) {
3166
+ const [ce, Le, at] = ne;
3152
3167
  de = {
3153
3168
  schemaName: ce,
3154
3169
  tableName: Le,
3155
- fieldNames: [it],
3170
+ fieldNames: [at],
3156
3171
  relation: ke.value,
3157
- token: A(z)
3172
+ token: _(Q)
3158
3173
  };
3159
3174
  } else {
3160
- n.push(new c(o.UNSUPPORTED, "Nested schema is not supported", z));
3161
- const ce = te.pop(), Le = te.pop();
3175
+ n.push(new c(o.UNSUPPORTED, "Nested schema is not supported", Q));
3176
+ const ce = ne.pop(), Le = ne.pop();
3162
3177
  de = {
3163
- schemaName: te.join("."),
3178
+ schemaName: ne.join("."),
3164
3179
  tableName: Le,
3165
3180
  fieldNames: [ce],
3166
3181
  relation: ke.value,
3167
- token: A(z)
3182
+ token: _(Q)
3168
3183
  };
3169
3184
  }
3170
- const st = this.registerInlineRefToEnv(e, nt, de, z);
3171
- return n.push(...st), st.length === 0 ? de : [];
3185
+ const rt = this.registerInlineRefToEnv(e, it, de, Q);
3186
+ return n.push(...rt), rt.length === 0 ? de : [];
3172
3187
  });
3173
3188
  }
3174
- return s.pk || (s.pk = r.some((_) => j(_).unwrap().toLowerCase() === "pk")), s.unique || (s.unique = r.some((_) => j(_).unwrap().toLowerCase() === "unique")), this.table.fields.push(s), s.pk && this.pkColumns.push(s), n;
3189
+ return s.pk || (s.pk = r.some((S) => Y(S).unwrap().toLowerCase() === "pk")), s.unique || (s.unique = r.some((S) => Y(S).unwrap().toLowerCase() === "unique")), this.table.fields.push(s), s.pk && this.pkColumns.push(s), n;
3175
3190
  }
3176
3191
  interpretIndexes(e) {
3177
3192
  return this.table.indexes.push(...e.body.body.map((n) => {
3178
3193
  var a, l, p, f, E, h, m;
3179
3194
  const s = { columns: [] }, i = n;
3180
- s.token = A(i);
3195
+ s.token = _(i);
3181
3196
  const r = [i.callee, ...i.args];
3182
- if (I.last(r) instanceof R) {
3183
- const g = B(r.pop()).getValue();
3184
- s.pk = !!((a = g.pk) != null && a.length), s.unique = !!((l = g.unique) != null && l.length), s.name = G((f = (p = g.name) == null ? void 0 : p.at(0)) == null ? void 0 : f.value).unwrap_or(void 0);
3185
- const _ = (E = g.note) == null ? void 0 : E.at(0);
3186
- s.note = _ && {
3187
- value: G(_.value).unwrap(),
3188
- token: A(_)
3189
- }, s.type = j((m = (h = g.type) == null ? void 0 : h.at(0)) == null ? void 0 : m.value).unwrap_or(void 0);
3197
+ if (I.last(r) instanceof P) {
3198
+ const g = M(r.pop()).getValue();
3199
+ s.pk = !!((a = g.pk) != null && a.length), s.unique = !!((l = g.unique) != null && l.length), s.name = C((f = (p = g.name) == null ? void 0 : p.at(0)) == null ? void 0 : f.value).unwrap_or(void 0);
3200
+ const R = (E = g.note) == null ? void 0 : E.at(0);
3201
+ s.note = R && {
3202
+ value: C(R.value).unwrap(),
3203
+ token: _(R)
3204
+ }, s.type = Y((m = (h = g.type) == null ? void 0 : h.at(0)) == null ? void 0 : m.value).unwrap_or(void 0);
3190
3205
  }
3191
3206
  return r.flatMap((g) => {
3192
- if (!(g instanceof H))
3207
+ if (!(g instanceof J))
3193
3208
  return g;
3194
- const _ = [];
3195
- for (; g instanceof H; )
3196
- _.push(g.argumentList), g = g.callee;
3197
- return _.push(g), _;
3209
+ const R = [];
3210
+ for (; g instanceof J; )
3211
+ R.push(g.argumentList), g = g.callee;
3212
+ return R.push(g), R;
3198
3213
  }).forEach((g) => {
3199
- const { functional: _, nonFunctional: ee } = Xe(g).unwrap();
3214
+ const { functional: R, nonFunctional: S } = We(g).unwrap();
3200
3215
  s.columns.push(
3201
- ..._.map((le) => ({
3202
- value: le.value.value,
3216
+ ...R.map((te) => ({
3217
+ value: te.value.value,
3203
3218
  type: "expression",
3204
- token: A(le)
3219
+ token: _(te)
3205
3220
  })),
3206
- ...ee.map((le) => ({
3207
- value: C(le).unwrap(),
3221
+ ...S.map((te) => ({
3222
+ value: X(te).unwrap(),
3208
3223
  type: "column",
3209
- token: A(le)
3224
+ token: _(te)
3210
3225
  }))
3211
3226
  );
3212
3227
  }), s;
@@ -3232,40 +3247,40 @@ class Mt {
3232
3247
  {
3233
3248
  schemaName: this.table.schemaName,
3234
3249
  tableName: this.table.name,
3235
- fieldNames: [j(e.callee).unwrap()],
3236
- token: A(e),
3250
+ fieldNames: [Y(e.callee).unwrap()],
3251
+ token: _(e),
3237
3252
  relation: a[0]
3238
3253
  }
3239
3254
  ]
3240
3255
  }), [];
3241
3256
  }
3242
3257
  }
3243
- function qn(t) {
3258
+ function Hn(t) {
3244
3259
  let e = null;
3245
- t instanceof H && (e = t.argumentList.elementList.map((r) => fe(r) ? r.expression.literal.value : $(r) ? G(r).unwrap() : j(r).unwrap()).join(","), t = t.callee);
3260
+ t instanceof J && (e = t.argumentList.elementList.map((r) => fe(r) ? r.expression.literal.value : W(r) ? C(r).unwrap() : Y(r).unwrap()).join(","), t = t.callee);
3246
3261
  let n = "";
3247
3262
  for (; t instanceof he; )
3248
3263
  n = `[${t.indexer.elementList.map((r) => r.name.expression.literal.value).join(",")}]${n}`, t = t.array;
3249
3264
  const { name: s, schemaName: i } = Ie(t);
3250
- return i.length > 1 ? new V(
3265
+ return i.length > 1 ? new G(
3251
3266
  {
3252
3267
  schemaName: i.length === 0 ? null : i[0],
3253
3268
  type_name: `${s}${n}${e ? `(${e})` : ""}`,
3254
3269
  args: e
3255
3270
  },
3256
3271
  [new c(o.UNSUPPORTED, "Nested schema is not supported", t)]
3257
- ) : new V({
3272
+ ) : new G({
3258
3273
  schemaName: i.length === 0 ? null : i[0],
3259
3274
  type_name: `${s}${n}${e ? `(${e})` : ""}`,
3260
3275
  args: e
3261
3276
  });
3262
3277
  }
3263
- function Hn(t) {
3278
+ function Jn(t) {
3264
3279
  var e, n, s;
3265
3280
  if (t) {
3266
- if ($(t))
3281
+ if (W(t))
3267
3282
  return {
3268
- value: G(t).unwrap(),
3283
+ value: C(t).unwrap(),
3269
3284
  type: "string"
3270
3285
  };
3271
3286
  if (fe(t))
@@ -3278,14 +3293,14 @@ function Hn(t) {
3278
3293
  value: t.expression.variable.value.toLowerCase(),
3279
3294
  type: "boolean"
3280
3295
  };
3281
- if (t instanceof Q && yt.includes((e = t.op) == null ? void 0 : e.value) && fe(t.expression)) {
3296
+ if (t instanceof q && kt.includes((e = t.op) == null ? void 0 : e.value) && fe(t.expression)) {
3282
3297
  const i = Number.parseFloat(t.expression.expression.literal.value);
3283
3298
  return {
3284
3299
  value: ((n = t.op) == null ? void 0 : n.value) === "-" ? 0 - i : i,
3285
3300
  type: "number"
3286
3301
  };
3287
3302
  }
3288
- if (t instanceof ne)
3303
+ if (t instanceof se)
3289
3304
  return {
3290
3305
  value: (s = t.value) == null ? void 0 : s.value,
3291
3306
  type: "expression"
@@ -3293,12 +3308,12 @@ function Hn(t) {
3293
3308
  throw new Error("Unreachable");
3294
3309
  }
3295
3310
  }
3296
- class Jn {
3311
+ class Zn {
3297
3312
  constructor(e, n) {
3298
3313
  this.declarationNode = e, this.env = n, this.note = { name: void 0, content: void 0, token: void 0 };
3299
3314
  }
3300
3315
  interpret() {
3301
- return this.note.token = A(this.declarationNode), this.env.notes.set(this.declarationNode, this.note), [
3316
+ return this.note.token = _(this.declarationNode), this.env.notes.set(this.declarationNode, this.note), [
3302
3317
  ...this.interpretName(this.declarationNode.name),
3303
3318
  ...this.interpretSettingList(this.declarationNode.attributeList),
3304
3319
  ...this.interpretBody(this.declarationNode.body)
@@ -3310,37 +3325,46 @@ class Jn {
3310
3325
  }
3311
3326
  interpretSettingList(e) {
3312
3327
  var s, i, r;
3313
- const n = B(e).getValue();
3314
- return this.note.headerColor = (s = n.headercolor) != null && s.length ? Ke((r = (i = n.headercolor) == null ? void 0 : i.at(0)) == null ? void 0 : r.value) : void 0, [];
3328
+ const n = M(e).getValue();
3329
+ return this.note.headerColor = (s = n.headercolor) != null && s.length ? Fe((r = (i = n.headercolor) == null ? void 0 : i.at(0)) == null ? void 0 : r.value) : void 0, [];
3315
3330
  }
3316
3331
  interpretBody(e) {
3317
- const [n, s] = I.partition(e.body, (i) => i instanceof w);
3332
+ const [n, s] = I.partition(e.body, (i) => i instanceof v);
3318
3333
  return n.length !== 1 || s.length > 0 ? [
3319
3334
  new c(o.INVALID_NOTE, "Invalid note syntax", e)
3320
3335
  ] : [...this.interpretNote(n[0])];
3321
3336
  }
3322
3337
  interpretNote(e) {
3323
3338
  const n = I.get(e, "callee.expression.literal.value", "");
3324
- return this.note.content = re(n), [];
3339
+ return this.note.content = ae(n), [];
3325
3340
  }
3326
3341
  }
3327
3342
  class Ft {
3328
3343
  constructor(e, n) {
3329
- this.declarationNode = e, this.env = n, this.container = this.declarationNode.parent instanceof v ? this.env.tables.get(this.declarationNode.parent) : void 0, this.ref = {};
3344
+ this.declarationNode = e, this.env = n, this.container = this.declarationNode.parent instanceof A ? this.env.tables.get(this.declarationNode.parent) : void 0, this.ref = {};
3330
3345
  }
3331
3346
  interpret() {
3332
- return this.ref.token = A(this.declarationNode), this.env.ref.set(this.declarationNode, this.ref), [...this.interpretName(this.declarationNode.name), ...this.interpretBody(this.declarationNode.body)];
3347
+ return this.ref.token = _(this.declarationNode), this.env.ref.set(this.declarationNode, this.ref), [
3348
+ ...this.interpretName(this.declarationNode.name),
3349
+ ...this.interpretSettingList(this.declarationNode.attributeList),
3350
+ ...this.interpretBody(this.declarationNode.body)
3351
+ ];
3333
3352
  }
3334
3353
  interpretName(e) {
3335
- const n = [], s = W(this.declarationNode.name).unwrap_or([]);
3354
+ const n = [], s = j(this.declarationNode.name).unwrap_or([]);
3336
3355
  return this.ref.name = s.pop() || null, s.length > 1 && n.push(new c(o.UNSUPPORTED, "Nested schema is not supported", this.declarationNode.name)), this.ref.schemaName = s.join(".") || null, n;
3337
3356
  }
3357
+ interpretSettingList(e) {
3358
+ var s, i, r;
3359
+ const n = M(e).getValue();
3360
+ return this.ref.color = (s = n.color) != null && s.length ? Fe((r = (i = n.color) == null ? void 0 : i.at(0)) == null ? void 0 : r.value) : void 0, [];
3361
+ }
3338
3362
  interpretBody(e) {
3339
- return e instanceof w ? this.interpretField(e) : this.interpretField(e.body[0]);
3363
+ return e instanceof v ? this.interpretField(e) : this.interpretField(e.body[0]);
3340
3364
  }
3341
3365
  interpretField(e) {
3342
3366
  var f, E, h, m;
3343
- const n = e.callee.op.value, { leftExpression: s, rightExpression: i } = e.callee, r = $e(s), a = $e(i);
3367
+ const n = e.callee.op.value, { leftExpression: s, rightExpression: i } = e.callee, r = je(s), a = je(i);
3344
3368
  if (Ut(r, a))
3345
3369
  return [new c(o.SAME_ENDPOINT, "Two endpoints are the same", e)];
3346
3370
  const l = Pt(r, a);
@@ -3350,22 +3374,22 @@ class Ft {
3350
3374
  new c(o.CIRCULAR_REF, "References with same endpoints exist", this.env.refIds[l])
3351
3375
  ];
3352
3376
  if (e.args[0]) {
3353
- const g = B(e.args[0]).getValue(), _ = (E = (f = g.delete) == null ? void 0 : f.at(0)) == null ? void 0 : E.value;
3354
- this.ref.onDelete = _ instanceof Y ? Te(_).unwrap_or(void 0) : j(_).unwrap_or(void 0);
3355
- const ee = (m = (h = g.update) == null ? void 0 : h.at(0)) == null ? void 0 : m.value;
3356
- this.ref.onUpdate = ee instanceof Y ? Te(ee).unwrap_or(void 0) : j(ee).unwrap_or(void 0);
3377
+ const g = M(e.args[0]).getValue(), R = (E = (f = g.delete) == null ? void 0 : f.at(0)) == null ? void 0 : E.value;
3378
+ this.ref.onDelete = R instanceof z ? Te(R).unwrap_or(void 0) : Y(R).unwrap_or(void 0);
3379
+ const S = (m = (h = g.update) == null ? void 0 : h.at(0)) == null ? void 0 : m.value;
3380
+ this.ref.onUpdate = S instanceof z ? Te(S).unwrap_or(void 0) : Y(S).unwrap_or(void 0);
3357
3381
  }
3358
3382
  const p = Rt(n);
3359
3383
  return this.ref.endpoints = [
3360
3384
  {
3361
- ...dt(s, this.container),
3385
+ ...Et(s, this.container),
3362
3386
  relation: p[0],
3363
- token: A(s)
3387
+ token: _(s)
3364
3388
  },
3365
3389
  {
3366
- ...dt(i, this.container),
3390
+ ...Et(i, this.container),
3367
3391
  relation: p[1],
3368
- token: A(i)
3392
+ token: _(i)
3369
3393
  }
3370
3394
  ], this.env.refIds[l] = this.declarationNode, [];
3371
3395
  }
@@ -3376,7 +3400,7 @@ class Bt {
3376
3400
  }
3377
3401
  interpret() {
3378
3402
  const e = [];
3379
- return this.tableGroup.token = A(this.declarationNode), this.env.tableGroups.set(this.declarationNode, this.tableGroup), e.push(
3403
+ return this.tableGroup.token = _(this.declarationNode), this.env.tableGroups.set(this.declarationNode, this.tableGroup), e.push(
3380
3404
  ...this.interpretName(this.declarationNode.name),
3381
3405
  ...this.interpretSettingList(this.declarationNode.attributeList),
3382
3406
  ...this.interpretBody(this.declarationNode.body)
@@ -3387,7 +3411,7 @@ class Bt {
3387
3411
  return i.length >= 2 && (this.tableGroup.name = s, this.tableGroup.schemaName = i.join("."), n.push(new c(o.UNSUPPORTED, "Nested schema is not supported", this.declarationNode.name))), this.tableGroup.name = s, this.tableGroup.schemaName = i[0] || null, n;
3388
3412
  }
3389
3413
  interpretBody(e) {
3390
- const [n, s] = Yt(e.body, (i) => i instanceof w);
3414
+ const [n, s] = zt(e.body, (i) => i instanceof v);
3391
3415
  return [
3392
3416
  ...this.interpretFields(n),
3393
3417
  ...this.interpretSubElements(s)
@@ -3399,10 +3423,10 @@ class Bt {
3399
3423
  switch ((s = n.type) == null ? void 0 : s.value.toLowerCase()) {
3400
3424
  case "note":
3401
3425
  this.tableGroup.note = {
3402
- value: G(
3403
- n.body instanceof J ? n.body.body[0].callee : n.body.callee
3404
- ).map(re).unwrap(),
3405
- token: A(n)
3426
+ value: C(
3427
+ n.body instanceof Z ? n.body.body[0].callee : n.body.callee
3428
+ ).map(ae).unwrap(),
3429
+ token: _(n)
3406
3430
  };
3407
3431
  break;
3408
3432
  }
@@ -3412,7 +3436,7 @@ class Bt {
3412
3436
  interpretFields(e) {
3413
3437
  const n = [];
3414
3438
  return this.tableGroup.tables = e.map((s) => {
3415
- const i = W(s.callee).unwrap();
3439
+ const i = j(s.callee).unwrap();
3416
3440
  i.length > 2 && n.push(new c(o.UNSUPPORTED, "Nested schema is not supported", s));
3417
3441
  const r = pe(s.callee).unwrap().pop().referee.id;
3418
3442
  if (this.env.groupOfTable[r]) {
@@ -3428,12 +3452,12 @@ class Bt {
3428
3452
  }
3429
3453
  interpretSettingList(e) {
3430
3454
  var i, r, a;
3431
- const n = B(e).getValue();
3432
- this.tableGroup.color = (i = n.color) != null && i.length ? Ke((a = (r = n.color) == null ? void 0 : r.at(0)) == null ? void 0 : a.value) : void 0;
3455
+ const n = M(e).getValue();
3456
+ this.tableGroup.color = (i = n.color) != null && i.length ? Fe((a = (r = n.color) == null ? void 0 : r.at(0)) == null ? void 0 : a.value) : void 0;
3433
3457
  const [s] = n.note || [];
3434
3458
  return this.tableGroup.note = s && {
3435
- value: G(s == null ? void 0 : s.value).map(re).unwrap(),
3436
- token: A(s)
3459
+ value: C(s == null ? void 0 : s.value).map(ae).unwrap(),
3460
+ token: _(s)
3437
3461
  }, [];
3438
3462
  }
3439
3463
  }
@@ -3442,7 +3466,7 @@ class Vt {
3442
3466
  this.declarationNode = e, this.env = n, this.enum = { values: [] };
3443
3467
  }
3444
3468
  interpret() {
3445
- return this.enum.token = A(this.declarationNode), this.env.enums.set(this.declarationNode, this.enum), [...this.interpretName(this.declarationNode.name), ...this.interpretBody(this.declarationNode.body)];
3469
+ return this.enum.token = _(this.declarationNode), this.env.enums.set(this.declarationNode, this.enum), [...this.interpretName(this.declarationNode.name), ...this.interpretBody(this.declarationNode.body)];
3446
3470
  }
3447
3471
  interpretName(e) {
3448
3472
  const { name: n, schemaName: s } = Ie(e);
@@ -3452,21 +3476,21 @@ class Vt {
3452
3476
  return e.body.flatMap((n) => {
3453
3477
  var l;
3454
3478
  const s = n, i = {};
3455
- i.token = A(s), i.name = j(s.callee).unwrap();
3456
- const a = (l = B(s.args[0]).getValue().note) == null ? void 0 : l.at(0);
3479
+ i.token = _(s), i.name = Y(s.callee).unwrap();
3480
+ const a = (l = M(s.args[0]).getValue().note) == null ? void 0 : l.at(0);
3457
3481
  return i.note = a && {
3458
- value: G(a.value).map(re).unwrap(),
3459
- token: A(a)
3482
+ value: C(a.value).map(ae).unwrap(),
3483
+ token: _(a)
3460
3484
  }, this.enum.values.push(i), [];
3461
3485
  });
3462
3486
  }
3463
3487
  }
3464
- class Zn {
3488
+ class Kn {
3465
3489
  constructor(e, n) {
3466
3490
  this.declarationNode = e, this.env = n, this.project = { enums: [], refs: [], tableGroups: [], tables: [] };
3467
3491
  }
3468
3492
  interpret() {
3469
- return this.env.project.set(this.declarationNode, this.project), this.project.token = A(this.declarationNode), [...this.interpretName(this.declarationNode.name), ...this.interpretBody(this.declarationNode.body)];
3493
+ return this.env.project.set(this.declarationNode, this.project), this.project.token = _(this.declarationNode), [...this.interpretName(this.declarationNode.name), ...this.interpretBody(this.declarationNode.body)];
3470
3494
  }
3471
3495
  interpretName(e) {
3472
3496
  if (!e)
@@ -3497,16 +3521,16 @@ class Zn {
3497
3521
  }
3498
3522
  case "note":
3499
3523
  return this.project.note = {
3500
- value: G(s.body instanceof J ? s.body.body[0].callee : s.body.callee).map(re).unwrap(),
3501
- token: A(s)
3524
+ value: C(s.body instanceof Z ? s.body.body[0].callee : s.body.callee).map(ae).unwrap(),
3525
+ token: _(s)
3502
3526
  }, [];
3503
3527
  default:
3504
- return this.project[s.type.value.toLowerCase()] = G(s.body.callee).unwrap(), [];
3528
+ return this.project[s.type.value.toLowerCase()] = C(s.body.callee).unwrap(), [];
3505
3529
  }
3506
3530
  });
3507
3531
  }
3508
3532
  }
3509
- class Kn {
3533
+ class es {
3510
3534
  constructor(e) {
3511
3535
  this.ast = e, this.env = {
3512
3536
  schema: [],
@@ -3527,7 +3551,7 @@ class Kn {
3527
3551
  case b.Table:
3528
3552
  return new Mt(n, this.env).interpret();
3529
3553
  case b.Note:
3530
- return new Jn(n, this.env).interpret();
3554
+ return new Zn(n, this.env).interpret();
3531
3555
  case b.Ref:
3532
3556
  return new Ft(n, this.env).interpret();
3533
3557
  case b.TableGroup:
@@ -3535,15 +3559,15 @@ class Kn {
3535
3559
  case b.Enum:
3536
3560
  return new Vt(n, this.env).interpret();
3537
3561
  case b.Project:
3538
- return new Zn(n, this.env).interpret();
3562
+ return new Kn(n, this.env).interpret();
3539
3563
  default:
3540
3564
  return [];
3541
3565
  }
3542
3566
  });
3543
- return new V(es(this.env), e);
3567
+ return new G(ts(this.env), e);
3544
3568
  }
3545
3569
  }
3546
- function es(t) {
3570
+ function ts(t) {
3547
3571
  return {
3548
3572
  schemas: [],
3549
3573
  tables: Array.from(t.tables.values()),
@@ -3555,7 +3579,7 @@ function es(t) {
3555
3579
  project: Array.from(t.project.values())[0] || {}
3556
3580
  };
3557
3581
  }
3558
- var L = /* @__PURE__ */ ((t) => (t[t.Function = 1] = "Function", t[t.Constructor = 2] = "Constructor", t[t.Field = 3] = "Field", t[t.Variable = 4] = "Variable", t[t.Class = 5] = "Class", t[t.Struct = 6] = "Struct", t[t.Interface = 7] = "Interface", t[t.Module = 8] = "Module", t[t.Property = 9] = "Property", t[t.Event = 10] = "Event", t[t.Operator = 11] = "Operator", t[t.Unit = 12] = "Unit", t[t.Value = 13] = "Value", t[t.Constant = 14] = "Constant", t[t.Enum = 15] = "Enum", t[t.EnumMember = 16] = "EnumMember", t[t.Keyword = 17] = "Keyword", t[t.Text = 18] = "Text", t[t.Color = 19] = "Color", t[t.File = 20] = "File", t[t.Reference = 21] = "Reference", t[t.Customcolor = 22] = "Customcolor", t[t.Folder = 23] = "Folder", t[t.TypeParameter = 24] = "TypeParameter", t[t.User = 25] = "User", t[t.Issue = 26] = "Issue", t[t.Snippet = 27] = "Snippet", t))(L || {}), y = /* @__PURE__ */ ((t) => (t[t.None = 0] = "None", t[t.KeepWhitespace = 1] = "KeepWhitespace", t[t.InsertAsSnippet = 4] = "InsertAsSnippet", t))(y || {});
3582
+ var L = /* @__PURE__ */ ((t) => (t[t.Function = 1] = "Function", t[t.Constructor = 2] = "Constructor", t[t.Field = 3] = "Field", t[t.Variable = 4] = "Variable", t[t.Class = 5] = "Class", t[t.Struct = 6] = "Struct", t[t.Interface = 7] = "Interface", t[t.Module = 8] = "Module", t[t.Property = 9] = "Property", t[t.Event = 10] = "Event", t[t.Operator = 11] = "Operator", t[t.Unit = 12] = "Unit", t[t.Value = 13] = "Value", t[t.Constant = 14] = "Constant", t[t.Enum = 15] = "Enum", t[t.EnumMember = 16] = "EnumMember", t[t.Keyword = 17] = "Keyword", t[t.Text = 18] = "Text", t[t.Color = 19] = "Color", t[t.File = 20] = "File", t[t.Reference = 21] = "Reference", t[t.Customcolor = 22] = "Customcolor", t[t.Folder = 23] = "Folder", t[t.TypeParameter = 24] = "TypeParameter", t[t.User = 25] = "User", t[t.Issue = 26] = "Issue", t[t.Snippet = 27] = "Snippet", t))(L || {}), w = /* @__PURE__ */ ((t) => (t[t.None = 0] = "None", t[t.KeepWhitespace = 1] = "KeepWhitespace", t[t.InsertAsSnippet = 4] = "InsertAsSnippet", t))(w || {});
3559
3583
  function Ae(t) {
3560
3584
  switch (t) {
3561
3585
  case T.Schema:
@@ -3577,7 +3601,7 @@ function Ae(t) {
3577
3601
  }
3578
3602
  }
3579
3603
  function Re(t, e) {
3580
- if (!t || Ce(t))
3604
+ if (!t || $e(t))
3581
3605
  return !1;
3582
3606
  for (const n of t.trailingTrivia) {
3583
3607
  if (n.start > e)
@@ -3601,7 +3625,7 @@ function Pe(t) {
3601
3625
  }))
3602
3626
  };
3603
3627
  }
3604
- function Fe(t) {
3628
+ function Be(t) {
3605
3629
  return {
3606
3630
  ...t,
3607
3631
  suggestions: t.suggestions.map((e) => ({
@@ -3610,7 +3634,7 @@ function Fe(t) {
3610
3634
  }))
3611
3635
  };
3612
3636
  }
3613
- function et(t, e) {
3637
+ function nt(t, e) {
3614
3638
  return t.getOffsetAt(e);
3615
3639
  }
3616
3640
  class Gt {
@@ -3619,41 +3643,41 @@ class Gt {
3619
3643
  }
3620
3644
  provideCompletionItems(e, n) {
3621
3645
  var E, h;
3622
- const s = et(e, n), i = this.compiler.token.flatStream(), { token: r, index: a } = this.compiler.container.token(s), l = a === void 0 ? i[0] : i[a + 1];
3646
+ const s = nt(e, n), i = this.compiler.token.flatStream(), { token: r, index: a } = this.compiler.container.token(s), l = a === void 0 ? i[0] : i[a + 1];
3623
3647
  if ([
3624
3648
  ...(r == null ? void 0 : r.trailingTrivia) || [],
3625
3649
  ...(r == null ? void 0 : r.leadingTrivia) || [],
3626
3650
  ...(l == null ? void 0 : l.leadingTrivia) || []
3627
- ].find((m) => qt(m) && ge(s, m)))
3651
+ ].find((m) => Ht(m) && ge(s, m)))
3628
3652
  return D();
3629
3653
  if (a === void 0)
3630
- return bt();
3654
+ return It();
3631
3655
  if ([u.STRING_LITERAL, u.QUOTED_STRING].includes(r.kind) && ge(s, r))
3632
3656
  return D();
3633
3657
  const p = this.compiler.container.element(s);
3634
- if (this.compiler.container.scopeKind(s) === O.TOPLEVEL || p instanceof v && p.type && p.type.start <= s && p.type.end >= s)
3635
- return bt();
3658
+ if (this.compiler.container.scopeKind(s) === O.TOPLEVEL || p instanceof A && p.type && p.type.start <= s && p.type.end >= s)
3659
+ return It();
3636
3660
  const f = [...this.compiler.container.stack(s)].reverse();
3637
3661
  for (const m of f)
3638
- if (m instanceof Q)
3662
+ if (m instanceof q)
3639
3663
  switch ((E = m.op) == null ? void 0 : E.value) {
3640
3664
  case ">":
3641
3665
  case "<":
3642
3666
  case "<>":
3643
3667
  case "-":
3644
- return Et(
3668
+ return Nt(
3645
3669
  this.compiler,
3646
3670
  s,
3647
3671
  m
3648
3672
  );
3649
3673
  }
3650
- else if (m instanceof q)
3674
+ else if (m instanceof H)
3651
3675
  switch ((h = m.op) == null ? void 0 : h.value) {
3652
3676
  case ">":
3653
3677
  case "<":
3654
3678
  case "<>":
3655
3679
  case "-":
3656
- return Et(
3680
+ return Nt(
3657
3681
  this.compiler,
3658
3682
  s,
3659
3683
  m
@@ -3666,24 +3690,24 @@ class Gt {
3666
3690
  );
3667
3691
  }
3668
3692
  else {
3669
- if (m instanceof se)
3670
- return Nt(this.compiler, s, m);
3671
- if (m instanceof R)
3672
- return Nt(this.compiler, s, m);
3673
- if (m instanceof Z)
3674
- return ts(this.compiler, s);
3675
- if (m instanceof w)
3676
- return Tt(this.compiler, s, m);
3677
- if (m instanceof v && (m.bodyColon && s >= m.bodyColon.end || m.body && ge(s, m.body)))
3678
- return Tt(this.compiler, s, void 0);
3693
+ if (m instanceof ie)
3694
+ return mt(this.compiler, s, m);
3695
+ if (m instanceof P)
3696
+ return mt(this.compiler, s, m);
3697
+ if (m instanceof K)
3698
+ return ns(this.compiler, s);
3699
+ if (m instanceof v)
3700
+ return bt(this.compiler, s, m);
3701
+ if (m instanceof A && (m.bodyColon && s >= m.bodyColon.end || m.body && ge(s, m.body)))
3702
+ return bt(this.compiler, s, void 0);
3679
3703
  }
3680
3704
  return D();
3681
3705
  }
3682
3706
  }
3683
- function Et(t, e, n) {
3707
+ function Nt(t, e, n) {
3684
3708
  const s = t.container.scopeKind(e);
3685
3709
  if ([O.REF, O.TABLE].includes(s)) {
3686
- const i = Be(t, e, t.container.element(e), [
3710
+ const i = Ve(t, e, t.container.element(e), [
3687
3711
  T.Table,
3688
3712
  T.Schema,
3689
3713
  T.Column
@@ -3692,7 +3716,7 @@ function Et(t, e, n) {
3692
3716
  }
3693
3717
  return D();
3694
3718
  }
3695
- function Be(t, e, n, s) {
3719
+ function Ve(t, e, n, s) {
3696
3720
  var a;
3697
3721
  if (n === void 0)
3698
3722
  return D();
@@ -3705,18 +3729,18 @@ function Be(t, e, n, s) {
3705
3729
  ...t.symbol.members(l).filter(({ kind: p }) => s.includes(p)).map(({ name: p, kind: f }) => ({
3706
3730
  label: p,
3707
3731
  insertText: p,
3708
- insertTextRules: y.KeepWhitespace,
3732
+ insertTextRules: w.KeepWhitespace,
3709
3733
  kind: Ae(f),
3710
3734
  sortText: Ae(f).toString().padStart(2, "0"),
3711
3735
  range: void 0
3712
3736
  }))
3713
3737
  );
3714
3738
  }
3715
- i = i instanceof v ? i.parent : void 0;
3739
+ i = i instanceof A ? i.parent : void 0;
3716
3740
  }
3717
- return Fe(r);
3741
+ return Be(r);
3718
3742
  }
3719
- function ts(t, e) {
3743
+ function ns(t, e) {
3720
3744
  var s;
3721
3745
  switch (t.container.scopeKind(e)) {
3722
3746
  case O.INDEXES:
@@ -3726,7 +3750,7 @@ function ts(t, e) {
3726
3750
  const i = [...t.container.stack(e)];
3727
3751
  for (; i.length > 0; ) {
3728
3752
  const r = i.pop();
3729
- if (r instanceof q && ((s = r.op) == null ? void 0 : s.value) === ".")
3753
+ if (r instanceof H && ((s = r.op) == null ? void 0 : s.value) === ".")
3730
3754
  return Ct(
3731
3755
  t,
3732
3756
  e,
@@ -3738,16 +3762,16 @@ function ts(t, e) {
3738
3762
  }
3739
3763
  return D();
3740
3764
  }
3741
- function Nt(t, e, n) {
3765
+ function mt(t, e, n) {
3742
3766
  const { token: s } = t.container.token(e);
3743
3767
  if ([u.COMMA, u.LBRACKET].includes(s == null ? void 0 : s.kind)) {
3744
- const i = mt(t, e);
3768
+ const i = Tt(t, e);
3745
3769
  return (s == null ? void 0 : s.kind) === u.COMMA && Re(s, e) ? Pe(i) : i;
3746
3770
  }
3747
3771
  if (n.name && n.name.start <= e && n.name.end >= e)
3748
- return mt(t, e);
3749
- if (n.name instanceof Y) {
3750
- const i = ns(
3772
+ return Tt(t, e);
3773
+ if (n.name instanceof z) {
3774
+ const i = ss(
3751
3775
  t,
3752
3776
  e,
3753
3777
  Te(n.name).unwrap_or("")
@@ -3756,9 +3780,9 @@ function Nt(t, e, n) {
3756
3780
  }
3757
3781
  return D();
3758
3782
  }
3759
- function mt(t, e) {
3783
+ function Tt(t, e) {
3760
3784
  const n = t.container.element(e), s = t.container.scopeKind(e);
3761
- if (n instanceof X)
3785
+ if (n instanceof $)
3762
3786
  return D();
3763
3787
  if (n.body && !ge(e, n.body))
3764
3788
  switch (s) {
@@ -3768,7 +3792,7 @@ function mt(t, e) {
3768
3792
  label: i,
3769
3793
  insertText: `${i}: `,
3770
3794
  kind: L.Field,
3771
- insertTextRules: y.KeepWhitespace,
3795
+ insertTextRules: w.KeepWhitespace,
3772
3796
  range: void 0
3773
3797
  }))
3774
3798
  };
@@ -3778,7 +3802,7 @@ function mt(t, e) {
3778
3802
  label: i,
3779
3803
  insertText: `${i}: `,
3780
3804
  kind: L.Field,
3781
- insertTextRules: y.KeepWhitespace,
3805
+ insertTextRules: w.KeepWhitespace,
3782
3806
  range: void 0
3783
3807
  }))
3784
3808
  };
@@ -3793,21 +3817,21 @@ function mt(t, e) {
3793
3817
  label: i,
3794
3818
  insertText: i,
3795
3819
  kind: L.Property,
3796
- insertTextRules: y.KeepWhitespace,
3820
+ insertTextRules: w.KeepWhitespace,
3797
3821
  range: void 0
3798
3822
  })),
3799
3823
  ...["ref", "default"].map((i) => ({
3800
3824
  label: i,
3801
3825
  insertText: `${i}: `,
3802
3826
  kind: L.Property,
3803
- insertTextRules: y.KeepWhitespace,
3827
+ insertTextRules: w.KeepWhitespace,
3804
3828
  range: void 0
3805
3829
  })),
3806
3830
  {
3807
3831
  label: "note",
3808
3832
  insertText: "note: ",
3809
3833
  kind: L.Property,
3810
- insertTextRules: y.KeepWhitespace,
3834
+ insertTextRules: w.KeepWhitespace,
3811
3835
  range: void 0
3812
3836
  }
3813
3837
  ]
@@ -3819,7 +3843,7 @@ function mt(t, e) {
3819
3843
  label: "note",
3820
3844
  insertText: "note: ",
3821
3845
  kind: L.Property,
3822
- insertTextRules: y.KeepWhitespace,
3846
+ insertTextRules: w.KeepWhitespace,
3823
3847
  range: void 0
3824
3848
  }
3825
3849
  ]
@@ -3830,7 +3854,7 @@ function mt(t, e) {
3830
3854
  ...["unique", "pk"].map((i) => ({
3831
3855
  label: i,
3832
3856
  insertText: i,
3833
- insertTextRules: y.KeepWhitespace,
3857
+ insertTextRules: w.KeepWhitespace,
3834
3858
  kind: L.Property,
3835
3859
  range: void 0
3836
3860
  })),
@@ -3838,7 +3862,7 @@ function mt(t, e) {
3838
3862
  label: i,
3839
3863
  insertText: `${i}: `,
3840
3864
  kind: L.Property,
3841
- insertTextRules: y.KeepWhitespace,
3865
+ insertTextRules: w.KeepWhitespace,
3842
3866
  range: void 0
3843
3867
  }))
3844
3868
  ]
@@ -3849,14 +3873,14 @@ function mt(t, e) {
3849
3873
  label: i,
3850
3874
  insertText: `${i}: `,
3851
3875
  kind: L.Property,
3852
- insertTextRules: y.KeepWhitespace,
3876
+ insertTextRules: w.KeepWhitespace,
3853
3877
  range: void 0
3854
3878
  }))
3855
3879
  };
3856
3880
  }
3857
3881
  return D();
3858
3882
  }
3859
- function ns(t, e, n) {
3883
+ function ss(t, e, n) {
3860
3884
  switch (n == null ? void 0 : n.toLowerCase()) {
3861
3885
  case "update":
3862
3886
  case "delete":
@@ -3865,7 +3889,7 @@ function ns(t, e, n) {
3865
3889
  label: s,
3866
3890
  insertText: s,
3867
3891
  kind: L.Value,
3868
- insertTextRules: y.KeepWhitespace,
3892
+ insertTextRules: w.KeepWhitespace,
3869
3893
  range: void 0
3870
3894
  }))
3871
3895
  };
@@ -3875,7 +3899,7 @@ function ns(t, e, n) {
3875
3899
  label: s,
3876
3900
  insertText: `${s}`,
3877
3901
  kind: L.Value,
3878
- insertTextRules: y.KeepWhitespace,
3902
+ insertTextRules: w.KeepWhitespace,
3879
3903
  range: void 0
3880
3904
  }))
3881
3905
  };
@@ -3884,10 +3908,10 @@ function ns(t, e, n) {
3884
3908
  }
3885
3909
  function Ct(t, e, n) {
3886
3910
  const s = pe(n).unwrap_or([]);
3887
- if (s.pop(), s.some((r) => !M(r)))
3911
+ if (s.pop(), s.some((r) => !B(r)))
3888
3912
  return D();
3889
- const i = s.map((r) => j(r).unwrap());
3890
- return Fe({
3913
+ const i = s.map((r) => Y(r).unwrap());
3914
+ return Be({
3891
3915
  suggestions: t.symbol.ofName({ nameStack: i, owner: t.container.element(e) }).flatMap(({ symbol: r }) => t.symbol.members(r)).map(({ kind: r, name: a }) => ({
3892
3916
  label: a,
3893
3917
  insertText: a,
@@ -3896,73 +3920,73 @@ function Ct(t, e, n) {
3896
3920
  }))
3897
3921
  });
3898
3922
  }
3899
- function Tt(t, e, n) {
3923
+ function bt(t, e, n) {
3900
3924
  var i;
3901
3925
  switch (t.container.scopeKind(e)) {
3902
3926
  case O.TABLE:
3903
- return is(t, e, n);
3904
- case O.PROJECT:
3905
3927
  return rs(t, e, n);
3928
+ case O.PROJECT:
3929
+ return as(t, e, n);
3906
3930
  case O.INDEXES:
3907
- return os(t, e);
3931
+ return ls(t, e);
3908
3932
  case O.ENUM:
3909
- return ss(t, e, n);
3933
+ return is(t, e, n);
3910
3934
  case O.REF: {
3911
3935
  const r = Xt(t, e);
3912
3936
  return ((i = t.container.token(e).token) == null ? void 0 : i.kind) === u.COLON && Re(t.container.token(e).token, e) ? Pe(r) : r;
3913
3937
  }
3914
3938
  case O.TABLEGROUP:
3915
- return as(t);
3939
+ return os(t);
3916
3940
  default:
3917
3941
  return D();
3918
3942
  }
3919
3943
  }
3920
- function bt() {
3944
+ function It() {
3921
3945
  return {
3922
3946
  suggestions: ["Table", "TableGroup", "Enum", "Project", "Ref"].map((t) => ({
3923
3947
  label: t,
3924
3948
  insertText: t,
3925
- insertTextRules: y.KeepWhitespace,
3949
+ insertTextRules: w.KeepWhitespace,
3926
3950
  kind: L.Keyword,
3927
3951
  range: void 0
3928
3952
  }))
3929
3953
  };
3930
3954
  }
3931
- function ss(t, e, n) {
3932
- return n != null && n.callee && tt(e, n) === 1 ? Be(t, e, t.container.element(e), [
3955
+ function is(t, e, n) {
3956
+ return n != null && n.callee && st(e, n) === 1 ? Ve(t, e, t.container.element(e), [
3933
3957
  T.Schema,
3934
3958
  T.Table,
3935
3959
  T.Column
3936
3960
  ]) : D();
3937
3961
  }
3938
- function is(t, e, n) {
3962
+ function rs(t, e, n) {
3939
3963
  if (!(n != null && n.callee))
3940
3964
  return {
3941
3965
  suggestions: ["Note", "indexes"].map((i) => ({
3942
3966
  label: i,
3943
3967
  insertText: i,
3944
- insertTextRules: y.KeepWhitespace,
3968
+ insertTextRules: w.KeepWhitespace,
3945
3969
  kind: L.Keyword,
3946
3970
  range: void 0
3947
3971
  }))
3948
3972
  };
3949
- const s = tt(e, n);
3973
+ const s = st(e, n);
3950
3974
  return s === 0 ? {
3951
3975
  suggestions: ["Note", "indexes"].map((i) => ({
3952
3976
  label: i,
3953
3977
  insertText: i,
3954
- insertTextRules: y.KeepWhitespace,
3978
+ insertTextRules: w.KeepWhitespace,
3955
3979
  kind: L.Keyword,
3956
3980
  range: void 0
3957
3981
  }))
3958
- } : s === 1 ? ls(t, e) : D();
3982
+ } : s === 1 ? cs(t, e) : D();
3959
3983
  }
3960
- function rs(t, e, n) {
3961
- return n != null && n.callee ? tt(e, n) === 0 ? {
3984
+ function as(t, e, n) {
3985
+ return n != null && n.callee ? st(e, n) === 0 ? {
3962
3986
  suggestions: ["Table", "TableGroup", "Enum", "Note", "Ref"].map((i) => ({
3963
3987
  label: i,
3964
3988
  insertText: i,
3965
- insertTextRules: y.KeepWhitespace,
3989
+ insertTextRules: w.KeepWhitespace,
3966
3990
  kind: L.Keyword,
3967
3991
  range: void 0
3968
3992
  }))
@@ -3970,32 +3994,32 @@ function rs(t, e, n) {
3970
3994
  suggestions: ["Table", "TableGroup", "Enum", "Note", "Ref"].map((i) => ({
3971
3995
  label: i,
3972
3996
  insertText: i,
3973
- insertTextRules: y.KeepWhitespace,
3997
+ insertTextRules: w.KeepWhitespace,
3974
3998
  kind: L.Keyword,
3975
3999
  range: void 0
3976
4000
  }))
3977
4001
  };
3978
4002
  }
3979
4003
  function Xt(t, e) {
3980
- return Be(t, e, t.container.element(e), [
4004
+ return Ve(t, e, t.container.element(e), [
3981
4005
  T.Schema,
3982
4006
  T.Table,
3983
4007
  T.Column
3984
4008
  ]);
3985
4009
  }
3986
- function as(t) {
4010
+ function os(t) {
3987
4011
  return {
3988
4012
  suggestions: [
3989
- ...Fe({
4013
+ ...Be({
3990
4014
  suggestions: [...t.parse.publicSymbolTable().entries()].flatMap(([e]) => {
3991
- const n = ie(e).unwrap_or(void 0);
4015
+ const n = re(e).unwrap_or(void 0);
3992
4016
  if (n === void 0)
3993
4017
  return [];
3994
4018
  const { kind: s, name: i } = n;
3995
4019
  return s !== T.Table && s !== T.Schema ? [] : {
3996
4020
  label: i,
3997
4021
  insertText: i,
3998
- insertTextRules: y.KeepWhitespace,
4022
+ insertTextRules: w.KeepWhitespace,
3999
4023
  kind: Ae(s),
4000
4024
  range: void 0
4001
4025
  };
@@ -4004,17 +4028,17 @@ function as(t) {
4004
4028
  ...["Note"].map((e) => ({
4005
4029
  label: e,
4006
4030
  insertText: e,
4007
- insertTextRules: y.KeepWhitespace,
4031
+ insertTextRules: w.KeepWhitespace,
4008
4032
  kind: L.Keyword,
4009
4033
  range: void 0
4010
4034
  }))
4011
4035
  ]
4012
4036
  };
4013
4037
  }
4014
- function os(t, e) {
4038
+ function ls(t, e) {
4015
4039
  return $t(t, e);
4016
4040
  }
4017
- function ls(t, e) {
4041
+ function cs(t, e) {
4018
4042
  return {
4019
4043
  suggestions: [
4020
4044
  ...[
@@ -4077,12 +4101,12 @@ function ls(t, e) {
4077
4101
  ].map((n) => ({
4078
4102
  label: n,
4079
4103
  insertText: n,
4080
- insertTextRules: y.KeepWhitespace,
4104
+ insertTextRules: w.KeepWhitespace,
4081
4105
  kind: L.TypeParameter,
4082
4106
  sortText: L.TypeParameter.toString().padStart(2, "0"),
4083
4107
  range: void 0
4084
4108
  })),
4085
- ...Be(t, e, t.container.element(e), [
4109
+ ...Ve(t, e, t.container.element(e), [
4086
4110
  T.Enum,
4087
4111
  T.Schema
4088
4112
  ]).suggestions
@@ -4091,26 +4115,26 @@ function ls(t, e) {
4091
4115
  }
4092
4116
  function $t(t, e) {
4093
4117
  const n = t.container.element(e), s = n == null ? void 0 : n.parent;
4094
- if (!((s == null ? void 0 : s.symbol) instanceof vt))
4118
+ if (!((s == null ? void 0 : s.symbol) instanceof wt))
4095
4119
  return D();
4096
4120
  const { symbolTable: i } = s.symbol;
4097
- return Fe({
4121
+ return Be({
4098
4122
  suggestions: [...i.entries()].flatMap(([r]) => {
4099
- const a = ie(r).unwrap_or(void 0);
4123
+ const a = re(r).unwrap_or(void 0);
4100
4124
  if (a === void 0)
4101
4125
  return [];
4102
4126
  const { name: l } = a;
4103
4127
  return {
4104
4128
  label: l,
4105
4129
  insertText: l,
4106
- insertTextRules: y.KeepWhitespace,
4130
+ insertTextRules: w.KeepWhitespace,
4107
4131
  kind: Ae(T.Column),
4108
4132
  range: void 0
4109
4133
  };
4110
4134
  })
4111
4135
  });
4112
4136
  }
4113
- function tt(t, e) {
4137
+ function st(t, e) {
4114
4138
  if (!e.callee)
4115
4139
  return -1;
4116
4140
  const n = [e.callee, ...e.args], s = n.findIndex((i) => t <= i.end);
@@ -4122,7 +4146,7 @@ class Wt {
4122
4146
  }
4123
4147
  provideDefinition(e, n) {
4124
4148
  var a;
4125
- const { uri: s } = e, i = et(e, n), r = [...this.compiler.container.stack(i)];
4149
+ const { uri: s } = e, i = nt(e, n), r = [...this.compiler.container.stack(i)];
4126
4150
  for (; r.length !== 0; ) {
4127
4151
  const l = r.pop();
4128
4152
  if ((a = l == null ? void 0 : l.referee) != null && a.declaration && [Ne.PRIMARY_EXPRESSION, Ne.VARIABLE].includes(l == null ? void 0 : l.kind)) {
@@ -4148,7 +4172,7 @@ class jt {
4148
4172
  this.compiler = e;
4149
4173
  }
4150
4174
  provideReferences(e, n) {
4151
- const { uri: s } = e, i = et(e, n), r = [...this.compiler.container.stack(i)];
4175
+ const { uri: s } = e, i = nt(e, n), r = [...this.compiler.container.stack(i)];
4152
4176
  for (; r.length !== 0; ) {
4153
4177
  const a = r.pop();
4154
4178
  if (a && [
@@ -4172,24 +4196,24 @@ class jt {
4172
4196
  return [];
4173
4197
  }
4174
4198
  }
4175
- const hs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4199
+ const fs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4176
4200
  __proto__: null,
4177
- CompletionItemInsertTextRule: y,
4201
+ CompletionItemInsertTextRule: w,
4178
4202
  CompletionItemKind: L,
4179
4203
  DBMLCompletionItemProvider: Gt,
4180
4204
  DBMLDefinitionProvider: Wt,
4181
4205
  DBMLReferencesProvider: jt
4182
4206
  }, Symbol.toStringTag, { value: "Module" }));
4183
4207
  var O = /* @__PURE__ */ ((t) => (t[t.TABLE = 0] = "TABLE", t[t.ENUM = 1] = "ENUM", t[t.TABLEGROUP = 2] = "TABLEGROUP", t[t.INDEXES = 3] = "INDEXES", t[t.NOTE = 4] = "NOTE", t[t.REF = 5] = "REF", t[t.PROJECT = 6] = "PROJECT", t[t.CUSTOM = 7] = "CUSTOM", t[t.TOPLEVEL = 8] = "TOPLEVEL", t))(O || {});
4184
- class fs {
4208
+ class ps {
4185
4209
  constructor() {
4186
4210
  this.source = "", this.cache = new Array(
4187
4211
  16
4188
4212
  /* TOTAL_QUERY_COUNT */
4189
- ).fill(null), this.nodeIdGenerator = new Ht(), this.symbolIdGenerator = new tn(), this.token = {
4213
+ ).fill(null), this.nodeIdGenerator = new Jt(), this.symbolIdGenerator = new nn(), this.token = {
4190
4214
  invalidStream: this.createQuery(
4191
4215
  6,
4192
- () => this.parse.tokens().filter(wt)
4216
+ () => this.parse.tokens().filter(yt)
4193
4217
  ),
4194
4218
  // Valid + Invalid tokens (which are guarenteed to be non-trivials) are included in the stream
4195
4219
  flatStream: this.createQuery(
@@ -4201,8 +4225,8 @@ class fs {
4201
4225
  _: this.createQuery(
4202
4226
  0,
4203
4227
  () => {
4204
- const e = new fn(this.source).lex().chain((n) => new En(n, this.nodeIdGenerator).parse()).chain(({ ast: n, tokens: s }) => new Qn(n, this.symbolIdGenerator).analyze().map(() => ({ ast: n, tokens: s })));
4205
- return e.getErrors().length > 0 ? e : e.chain(({ ast: n, tokens: s }) => new Kn(n).interpret().map((r) => ({ ast: n, tokens: s, rawDb: r })));
4228
+ const e = new pn(this.source).lex().chain((n) => new Nn(n, this.nodeIdGenerator).parse()).chain(({ ast: n, tokens: s }) => new qn(n, this.symbolIdGenerator).analyze().map(() => ({ ast: n, tokens: s })));
4229
+ return e.getErrors().length > 0 ? e : e.chain(({ ast: n, tokens: s }) => new es(n).interpret().map((r) => ({ ast: n, tokens: s, rawDb: r })));
4206
4230
  }
4207
4231
  ),
4208
4232
  ast: this.createQuery(
@@ -4226,15 +4250,15 @@ class fs {
4226
4250
  stack: this.createQuery(
4227
4251
  10,
4228
4252
  (e) => {
4229
- const n = this.token.flatStream(), { index: s, token: i } = this.container.token(e), r = s === void 0 ? -1 : zt(n, (f) => !f.isInvalid, s);
4253
+ const n = this.token.flatStream(), { index: s, token: i } = this.container.token(e), r = s === void 0 ? -1 : Qt(n, (f) => !f.isInvalid, s);
4230
4254
  if (r === -1)
4231
4255
  return [this.parse.ast()];
4232
4256
  const a = n[r].start;
4233
4257
  let l = this.parse.ast();
4234
4258
  const p = [l];
4235
4259
  for (; ; ) {
4236
- const E = hn(l).find((h) => ge(a, h));
4237
- if (E === void 0 || E instanceof F)
4260
+ const E = fn(l).find((h) => ge(a, h));
4261
+ if (E === void 0 || E instanceof V)
4238
4262
  break;
4239
4263
  p.push(E), l = E;
4240
4264
  }
@@ -4242,17 +4266,17 @@ class fs {
4242
4266
  return p;
4243
4267
  for (; p.length > 0; ) {
4244
4268
  let f = !1;
4245
- const E = rt(p);
4246
- if (E instanceof w) {
4269
+ const E = Xe(p);
4270
+ if (E instanceof v) {
4247
4271
  const h = this.parse.source();
4248
4272
  for (let m = E.end; m < e; m += 1)
4249
4273
  h[m] === `
4250
4274
  ` && (p.pop(), f = !0);
4251
4275
  } else
4252
- E instanceof Q || E instanceof q ? this.container.token(e).token !== E.op && (p.pop(), f = !0) : E instanceof R ? E.listCloseBracket && E.end <= e && (p.pop(), f = !0) : E instanceof Z ? E.tupleCloseParen && E.end <= e && (p.pop(), f = !0) : E instanceof J ? E.blockCloseBrace && E.end <= e && (p.pop(), f = !0) : E instanceof Y || E.end < e && (p.pop(), f = !0);
4276
+ E instanceof q || E instanceof H ? this.container.token(e).token !== E.op && (p.pop(), f = !0) : E instanceof P ? E.listCloseBracket && E.end <= e && (p.pop(), f = !0) : E instanceof K ? E.tupleCloseParen && E.end <= e && (p.pop(), f = !0) : E instanceof Z ? E.blockCloseBrace && E.end <= e && (p.pop(), f = !0) : E instanceof z || E.end < e && (p.pop(), f = !0);
4253
4277
  if (f) {
4254
- const h = rt(p);
4255
- h instanceof v && h.end <= e && p.pop();
4278
+ const h = Xe(p);
4279
+ h instanceof A && h.end <= e && p.pop();
4256
4280
  }
4257
4281
  if (!f)
4258
4282
  break;
@@ -4275,7 +4299,7 @@ class fs {
4275
4299
  (e) => {
4276
4300
  const n = this.container.stack(e);
4277
4301
  for (let s = n.length - 1; s >= 0; s -= 1)
4278
- if (n[s] instanceof v)
4302
+ if (n[s] instanceof A)
4279
4303
  return n[s];
4280
4304
  return this.parse.ast();
4281
4305
  }
@@ -4289,7 +4313,7 @@ class fs {
4289
4313
  ),
4290
4314
  scopeKind: this.createQuery(15, (e) => {
4291
4315
  var s;
4292
- if (this.container.element(e) instanceof X)
4316
+ if (this.container.element(e) instanceof $)
4293
4317
  return 8;
4294
4318
  switch ((s = this.container.element(e).type) == null ? void 0 : s.value.toLowerCase()) {
4295
4319
  case "table":
@@ -4325,15 +4349,15 @@ class fs {
4325
4349
  if (e.length === 0)
4326
4350
  return [];
4327
4351
  const s = [];
4328
- for (let r = n; r; r = r instanceof v ? r.parent : void 0) {
4352
+ for (let r = n; r; r = r instanceof A ? r.parent : void 0) {
4329
4353
  if (!((i = r.symbol) != null && i.symbolTable))
4330
4354
  continue;
4331
4355
  const { symbolTable: a } = r.symbol;
4332
4356
  let l = [a], p = [];
4333
4357
  for (const f of e)
4334
4358
  p = l.flatMap(
4335
- (E) => Kt(f).flatMap((h) => {
4336
- const m = E.get(h), g = ie(h).unwrap_or(void 0);
4359
+ (E) => en(f).flatMap((h) => {
4360
+ const m = E.get(h), g = re(h).unwrap_or(void 0);
4337
4361
  return !m || !g ? [] : { ...g, symbol: m };
4338
4362
  })
4339
4363
  ), l = p.flatMap(
@@ -4348,7 +4372,7 @@ class fs {
4348
4372
  members: this.createQuery(
4349
4373
  9,
4350
4374
  (e) => e.symbolTable ? [...e.symbolTable.entries()].map(([n, s]) => ({
4351
- ...ie(n).unwrap(),
4375
+ ...re(n).unwrap(),
4352
4376
  symbol: s
4353
4377
  })) : []
4354
4378
  )
@@ -4382,7 +4406,7 @@ class fs {
4382
4406
  }
4383
4407
  }
4384
4408
  export {
4385
- fs as Compiler,
4386
- us as serialize,
4387
- hs as services
4409
+ ps as Compiler,
4410
+ hs as serialize,
4411
+ fs as services
4388
4412
  };