@dbml/parse 3.1.5-alpha.0 → 3.1.6

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.
@@ -1,6 +1,6 @@
1
1
  import I from "lodash";
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 $t(t) {
2
+ var c = /* @__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))(c || {});
3
+ function Xt(t) {
4
4
  switch (t.kind) {
5
5
  case "<newline>":
6
6
  case "<space>":
@@ -12,7 +12,7 @@ function $t(t) {
12
12
  return !1;
13
13
  }
14
14
  }
15
- function rt(t) {
15
+ function it(t) {
16
16
  if (!t)
17
17
  return !1;
18
18
  switch (t) {
@@ -33,38 +33,38 @@ function rt(t) {
33
33
  return !1;
34
34
  }
35
35
  }
36
- function at(t) {
36
+ function rt(t) {
37
37
  return t !== void 0 && t.kind === "<op>";
38
38
  }
39
- class V {
39
+ class B {
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 V(e, n, s, i, r);
44
+ return new B(e, n, s, i, r);
45
45
  }
46
46
  }
47
- function bt(t) {
48
- return t.trailingTrivia.find(({ kind: e }) => e === u.NEWLINE) !== void 0;
47
+ function Tt(t) {
48
+ return t.trailingTrivia.find(({ kind: e }) => e === c.NEWLINE) !== void 0;
49
49
  }
50
- function ot(t, e) {
51
- return e.leadingTrivia.find(({ kind: s }) => s === u.NEWLINE) !== void 0 || bt(t);
50
+ function at(t, e) {
51
+ return e.leadingTrivia.find(({ kind: s }) => s === c.NEWLINE) !== void 0 || Tt(t);
52
52
  }
53
53
  function Ve(t) {
54
- return t.trailingTrivia.find(({ kind: e }) => e === u.SPACE) !== void 0;
54
+ return t.trailingTrivia.find(({ kind: e }) => e === c.SPACE) !== void 0;
55
55
  }
56
- function It(t) {
57
- return t.trailingTrivia.length === 0 ? t.end : It(I.last(t.trailingTrivia));
56
+ function bt(t) {
57
+ return t.trailingTrivia.length === 0 ? t.end : bt(I.last(t.trailingTrivia));
58
58
  }
59
- function Lt(t) {
60
- return t.leadingTrivia.length === 0 ? t.start : Lt(t.leadingTrivia[0]);
59
+ function It(t) {
60
+ return t.leadingTrivia.length === 0 ? t.start : It(t.leadingTrivia[0]);
61
61
  }
62
- function Wt(t) {
63
- return [u.SINGLE_LINE_COMMENT, u.MULTILINE_COMMENT].includes(
62
+ function $t(t) {
63
+ return [c.SINGLE_LINE_COMMENT, c.MULTILINE_COMMENT].includes(
64
64
  t.kind
65
65
  );
66
66
  }
67
- class jt {
67
+ class Wt {
68
68
  constructor() {
69
69
  this.id = 0;
70
70
  }
@@ -75,32 +75,32 @@ class jt {
75
75
  return this.id++;
76
76
  }
77
77
  }
78
- class x {
78
+ class y {
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 V ? Lt(i) : i.fullStart) : (this.startPos = {
84
+ i ? (this.startPos = i.startPos, this.fullStart = i instanceof B ? It(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 V ? It(r) : r.fullEnd) : (this.endPos = {
90
+ r ? (this.endPos = r.endPos, this.fullEnd = r instanceof B ? bt(r) : r.fullEnd) : (this.endPos = {
91
91
  offset: NaN,
92
92
  column: NaN,
93
93
  line: NaN
94
94
  }, this.fullEnd = NaN), this.start = this.startPos.offset, this.end = this.endPos.offset;
95
95
  }
96
96
  }
97
- var ue = /* @__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))(ue || {});
98
- class F extends x {
97
+ var pe = /* @__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))(pe || {});
98
+ class C extends y {
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 _ extends x {
103
+ class _ extends y {
104
104
  constructor({
105
105
  type: e,
106
106
  name: n,
@@ -108,7 +108,7 @@ class _ extends x {
108
108
  alias: i,
109
109
  attributeList: r,
110
110
  bodyColon: a,
111
- body: c
111
+ body: l
112
112
  }, p) {
113
113
  if (super(p, "<element-declaration>", [
114
114
  e,
@@ -117,18 +117,18 @@ class _ extends x {
117
117
  i,
118
118
  r,
119
119
  a,
120
- c
121
- ]), c && a && !(c instanceof v || c instanceof _))
120
+ l
121
+ ]), l && a && !(l instanceof k || l instanceof _))
122
122
  throw new Error("If an element has a simple body, it must be a function application node");
123
- this.type = e, this.name = n, this.as = s, this.alias = i, this.attributeList = r, this.bodyColon = a, this.body = c;
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 te extends x {
126
+ class K extends y {
127
127
  constructor({ identifiers: e = [] }, n) {
128
128
  super(n, "<identifer-stream>", e || []), this.identifiers = e;
129
129
  }
130
130
  }
131
- class ne extends x {
131
+ class ne extends y {
132
132
  constructor({
133
133
  name: e,
134
134
  colon: n,
@@ -137,12 +137,12 @@ class ne 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 y {
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 q extends y {
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 De extends x {
154
+ class Re extends y {
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 K extends x {
159
+ class ee extends y {
160
160
  constructor({ value: e }, n) {
161
161
  super(n, "<function-expression>", [e]), this.value = e;
162
162
  }
163
163
  }
164
- class v extends x {
164
+ class k extends y {
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 ee extends x {
169
+ class te extends y {
170
170
  constructor({
171
171
  blockOpenBrace: e,
172
172
  body: n = [],
@@ -175,7 +175,7 @@ class ee 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 U extends x {
178
+ class P extends y {
179
179
  constructor({
180
180
  listOpenBracket: e,
181
181
  elementList: n = [],
@@ -184,12 +184,12 @@ class U extends x {
184
184
  }, r) {
185
185
  super(r, "<list-expression>", [
186
186
  e,
187
- ...gt(n, s),
187
+ ...Lt(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 J extends x {
192
+ class J extends y {
193
193
  constructor({
194
194
  tupleOpenParen: e,
195
195
  elementList: n = [],
@@ -198,7 +198,7 @@ class J extends x {
198
198
  }, r) {
199
199
  super(r, "<tuple-expression>", [
200
200
  e,
201
- ...gt(n, s),
201
+ ...Lt(n, s),
202
202
  i
203
203
  ]), this.tupleOpenParen = e, this.elementList = n, this.commaList = s, this.tupleCloseParen = i;
204
204
  }
@@ -220,7 +220,7 @@ class Xe extends J {
220
220
  ), this.kind = "<group-expression>";
221
221
  }
222
222
  }
223
- class H extends x {
223
+ class H extends y {
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 pe extends x {
231
+ class Ee extends y {
232
232
  constructor({ literal: e }, n) {
233
233
  super(n, "<literal>", [e]), this.literal = e;
234
234
  }
235
235
  }
236
- class W extends x {
236
+ class X extends y {
237
237
  constructor({ variable: e }, n) {
238
238
  super(n, "<variable>", [e]), this.variable = e;
239
239
  }
240
240
  }
241
- class R extends x {
241
+ class D extends y {
242
242
  constructor({ expression: e }, n) {
243
243
  super(n, "<primary-expression>", [e]), this.expression = e;
244
244
  }
245
245
  }
246
- class we extends x {
246
+ class we extends y {
247
247
  constructor({ pre: e }, n) {
248
- const s = V.create(u.SPACE, e.endPos, e.endPos, " ", !1);
248
+ const s = B.create(c.SPACE, e.endPos, e.endPos, " ", !1);
249
249
  super(n, "<dummy>", [s]);
250
250
  }
251
251
  }
252
- class he extends x {
252
+ class le extends y {
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 gt(t, e) {
257
+ function Lt(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 gt(t, e) {
264
264
  (i) => i !== null
265
265
  );
266
266
  }
267
- function as(t, e = !1) {
267
+ function is(t, e = !1) {
268
268
  return JSON.stringify(
269
269
  t,
270
270
  function(n, s) {
271
271
  var i;
272
- return !(this instanceof F) && n === "symbol" ? s == null ? void 0 : s.id : (
272
+ return !(this instanceof C) && 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 as(t, e = !1) {
290
290
  e ? 2 : 0
291
291
  );
292
292
  }
293
- class S {
293
+ class O {
294
294
  constructor(e) {
295
295
  this.value = e;
296
296
  }
@@ -305,7 +305,7 @@ class S {
305
305
  return e(this.value);
306
306
  }
307
307
  map(e) {
308
- return new S(e(this.value));
308
+ return new O(e(this.value));
309
309
  }
310
310
  // eslint-disable-next-line class-methods-use-this
311
311
  isOk() {
@@ -334,11 +334,11 @@ class A {
334
334
  return !1;
335
335
  }
336
336
  }
337
- var m = /* @__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))(m || {});
337
+ var m = /* @__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))(m || {});
338
338
  function $e(t) {
339
339
  return `Schema:${t}`;
340
340
  }
341
- function xe(t) {
341
+ function ke(t) {
342
342
  return `Table:${t}`;
343
343
  }
344
344
  function We(t) {
@@ -356,9 +356,6 @@ function ze(t) {
356
356
  function Qe(t) {
357
357
  return `TableGroup field:${t}`;
358
358
  }
359
- function Yt(t) {
360
- return `Note:${t}`;
361
- }
362
359
  function Fe(t, e) {
363
360
  switch (e) {
364
361
  case "Column":
@@ -370,7 +367,7 @@ function Fe(t, e) {
370
367
  case "Schema":
371
368
  return $e(t);
372
369
  case "Table":
373
- return xe(t);
370
+ return ke(t);
374
371
  case "TableGroup":
375
372
  return ze(t);
376
373
  case "TableGroup field":
@@ -381,22 +378,22 @@ function Fe(t, e) {
381
378
  }
382
379
  function se(t) {
383
380
  const [e, n] = t.split(":");
384
- return Object.values(m).includes(e) ? new S({
381
+ return Object.values(m).includes(e) ? new O({
385
382
  name: n,
386
383
  kind: e
387
384
  }) : new A();
388
385
  }
389
- function zt(t) {
386
+ function jt(t) {
390
387
  const e = se(t).unwrap_or(void 0);
391
388
  if (!e)
392
389
  return !1;
393
390
  const { kind: n, name: s } = e;
394
391
  return n === "Schema" && s === "public";
395
392
  }
396
- function Qt(t) {
393
+ function Yt(t) {
397
394
  return [
398
395
  $e,
399
- xe,
396
+ ke,
400
397
  je,
401
398
  ze,
402
399
  We,
@@ -408,27 +405,27 @@ function qe(t) {
408
405
  const [e] = t;
409
406
  return e >= "a" && e <= "z" || e >= "A" && e <= "Z" || e === "_";
410
407
  }
411
- function ke(t) {
408
+ function xe(t) {
412
409
  const [e] = t;
413
410
  return e >= "0" && e <= "9";
414
411
  }
415
- function qt(t) {
412
+ function zt(t) {
416
413
  const [e] = t;
417
- return ke(e) || qe(e) && e.toLowerCase() >= "a" && e.toLowerCase() <= "f";
414
+ return xe(e) || qe(e) && e.toLowerCase() >= "a" && e.toLowerCase() <= "f";
418
415
  }
419
- function Ie(t) {
420
- return qe(t) || ke(t);
416
+ function fe(t) {
417
+ return qe(t) || xe(t);
421
418
  }
422
- function ct(t, e) {
419
+ function ot(t, e) {
423
420
  const n = [], s = Math.min(t.length, e.length);
424
421
  for (let i = 0; i < s; i += 1)
425
422
  n.push(t[i], e[i]);
426
423
  return n.push(...t.slice(s), ...e.slice(s)), n;
427
424
  }
428
- function Le(t, e) {
425
+ function be(t, e) {
429
426
  return t >= e.start && t < e.end;
430
427
  }
431
- class Ht {
428
+ class Qt {
432
429
  constructor() {
433
430
  this.id = 0;
434
431
  }
@@ -439,48 +436,48 @@ class Ht {
439
436
  return this.id++;
440
437
  }
441
438
  }
442
- class _t {
439
+ class gt {
443
440
  constructor({ symbolTable: e }, n) {
444
441
  this.references = [], this.id = n, this.symbolTable = e;
445
442
  }
446
443
  }
447
- class Jt {
444
+ class qt {
448
445
  constructor({ symbolTable: e, declaration: n }, s) {
449
446
  this.references = [], this.id = s, this.symbolTable = e, this.declaration = n;
450
447
  }
451
448
  }
452
- class Zt {
449
+ class Ht {
453
450
  constructor({ declaration: e }, n) {
454
451
  this.references = [], this.id = n, this.declaration = e;
455
452
  }
456
453
  }
457
- class At {
454
+ class _t {
458
455
  constructor({ symbolTable: e, declaration: n }, s) {
459
456
  this.references = [], this.id = s, this.symbolTable = e, this.declaration = n;
460
457
  }
461
458
  }
462
- class Kt {
459
+ class Jt {
463
460
  constructor({ declaration: e }, n) {
464
461
  this.references = [], this.id = n, this.declaration = e;
465
462
  }
466
463
  }
467
- class en {
464
+ class Zt {
468
465
  constructor({ symbolTable: e, declaration: n }, s) {
469
466
  this.references = [], this.id = s, this.symbolTable = e, this.declaration = n;
470
467
  }
471
468
  }
472
- class tn {
469
+ class Kt {
473
470
  constructor({ declaration: e }, n) {
474
471
  this.references = [], this.id = n, this.declaration = e;
475
472
  }
476
473
  }
477
- var o = /* @__PURE__ */ ((t) => (t[t.UNKNOWN_SYMBOL = 1e3] = "UNKNOWN_SYMBOL", t[t.UNEXPECTED_SYMBOL = 1001] = "UNEXPECTED_SYMBOL", t[t.UNEXPECTED_EOF = 1002] = "UNEXPECTED_EOF", t[t.UNEXPECTED_NEWLINE = 1003] = "UNEXPECTED_NEWLINE", t[t.UNKNOWN_TOKEN = 1004] = "UNKNOWN_TOKEN", t[t.UNEXPECTED_TOKEN = 1005] = "UNEXPECTED_TOKEN", t[t.UNEXPECTED_ELEMENT_DECLARATION = 1006] = "UNEXPECTED_ELEMENT_DECLARATION", t[t.MISSING_SPACES = 1007] = "MISSING_SPACES", t[t.UNKNOWN_PREFIX_OP = 1008] = "UNKNOWN_PREFIX_OP", t[t.INVALID_OPERAND = 1009] = "INVALID_OPERAND", t[t.EMPTY_ATTRIBUTE_NAME = 1010] = "EMPTY_ATTRIBUTE_NAME", t[t.INVALID_NAME = 3e3] = "INVALID_NAME", t[t.UNEXPECTED_NAME = 3001] = "UNEXPECTED_NAME", t[t.NAME_NOT_FOUND = 3002] = "NAME_NOT_FOUND", t[t.DUPLICATE_NAME = 3003] = "DUPLICATE_NAME", t[t.INVALID_ALIAS = 3004] = "INVALID_ALIAS", t[t.UNEXPECTED_ALIAS = 3005] = "UNEXPECTED_ALIAS", t[t.UNEXPECTED_SETTINGS = 3006] = "UNEXPECTED_SETTINGS", t[t.INVALID_SETTINGS = 3007] = "INVALID_SETTINGS", t[t.UNEXPECTED_SIMPLE_BODY = 3008] = "UNEXPECTED_SIMPLE_BODY", t[t.UNEXPECTED_COMPLEX_BODY = 3009] = "UNEXPECTED_COMPLEX_BODY", t[t.INVALID_TABLE_CONTEXT = 3010] = "INVALID_TABLE_CONTEXT", t[t.INVALID_TABLE_SETTING = 3011] = "INVALID_TABLE_SETTING", t[t.DUPLICATE_TABLE_SETTING = 3012] = "DUPLICATE_TABLE_SETTING", t[t.INVALID_TABLEGROUP_CONTEXT = 3013] = "INVALID_TABLEGROUP_CONTEXT", t[t.INVALID_TABLEGROUP_ELEMENT_NAME = 3014] = "INVALID_TABLEGROUP_ELEMENT_NAME", t[t.DUPLICATE_TABLEGROUP_ELEMENT_NAME = 3015] = "DUPLICATE_TABLEGROUP_ELEMENT_NAME", t[t.DUPLICATE_TABLEGROUP_FIELD_NAME = 3016] = "DUPLICATE_TABLEGROUP_FIELD_NAME", t[t.INVALID_TABLEGROUP_FIELD = 3017] = "INVALID_TABLEGROUP_FIELD", t[t.EMPTY_TABLE = 3018] = "EMPTY_TABLE", t[t.INVALID_COLUMN = 3019] = "INVALID_COLUMN", t[t.INVALID_COLUMN_NAME = 3020] = "INVALID_COLUMN_NAME", t[t.UNKNOWN_COLUMN_SETTING = 3021] = "UNKNOWN_COLUMN_SETTING", t[t.INVALID_COLUMN_TYPE = 3022] = "INVALID_COLUMN_TYPE", t[t.DUPLICATE_COLUMN_NAME = 3023] = "DUPLICATE_COLUMN_NAME", t[t.DUPLICATE_COLUMN_SETTING = 3024] = "DUPLICATE_COLUMN_SETTING", t[t.INVALID_COLUMN_SETTING_VALUE = 3025] = "INVALID_COLUMN_SETTING_VALUE", t[t.INVALID_ENUM_CONTEXT = 3026] = "INVALID_ENUM_CONTEXT", t[t.INVALID_ENUM_ELEMENT_NAME = 3027] = "INVALID_ENUM_ELEMENT_NAME", t[t.INVALID_ENUM_ELEMENT = 3028] = "INVALID_ENUM_ELEMENT", t[t.DUPLICATE_ENUM_ELEMENT_NAME = 3029] = "DUPLICATE_ENUM_ELEMENT_NAME", t[t.UNKNOWN_ENUM_ELEMENT_SETTING = 3030] = "UNKNOWN_ENUM_ELEMENT_SETTING", t[t.DUPLICATE_ENUM_ELEMENT_SETTING = 3031] = "DUPLICATE_ENUM_ELEMENT_SETTING", t[t.INVALID_ENUM_ELEMENT_SETTING = 3032] = "INVALID_ENUM_ELEMENT_SETTING", t[t.EMPTY_ENUM = 3033] = "EMPTY_ENUM", t[t.INVALID_REF_CONTEXT = 3034] = "INVALID_REF_CONTEXT", t[t.UNKNOWN_REF_SETTING = 3035] = "UNKNOWN_REF_SETTING", t[t.DUPLICATE_REF_SETTING = 3036] = "DUPLICATE_REF_SETTING", t[t.INVALID_REF_SETTING_VALUE = 3037] = "INVALID_REF_SETTING_VALUE", t[t.INVALID_REF_RELATIONSHIP = 3038] = "INVALID_REF_RELATIONSHIP", t[t.INVALID_REF_FIELD = 3039] = "INVALID_REF_FIELD", t[t.EMPTY_REF = 3040] = "EMPTY_REF", t[t.REF_REDEFINED = 3041] = "REF_REDEFINED", t[t.INVALID_NOTE_CONTEXT = 3042] = "INVALID_NOTE_CONTEXT", t[t.INVALID_NOTE = 3043] = "INVALID_NOTE", t[t.NOTE_REDEFINED = 3044] = "NOTE_REDEFINED", t[t.NOTE_CONTENT_REDEFINED = 3045] = "NOTE_CONTENT_REDEFINED", t[t.EMPTY_NOTE = 3046] = "EMPTY_NOTE", t[t.INVALID_INDEXES_CONTEXT = 3047] = "INVALID_INDEXES_CONTEXT", t[t.INVALID_INDEXES_FIELD = 3048] = "INVALID_INDEXES_FIELD", t[t.INVALID_INDEX = 3049] = "INVALID_INDEX", t[t.UNKNOWN_INDEX_SETTING = 3050] = "UNKNOWN_INDEX_SETTING", t[t.DUPLICATE_INDEX_SETTING = 3051] = "DUPLICATE_INDEX_SETTING", t[t.UNEXPECTED_INDEX_SETTING_VALUE = 3052] = "UNEXPECTED_INDEX_SETTING_VALUE", t[t.INVALID_INDEX_SETTING_VALUE = 3053] = "INVALID_INDEX_SETTING_VALUE", t[t.INVALID_PROJECT_CONTEXT = 3054] = "INVALID_PROJECT_CONTEXT", t[t.PROJECT_REDEFINED = 3055] = "PROJECT_REDEFINED", t[t.INVALID_PROJECT_FIELD = 3056] = "INVALID_PROJECT_FIELD", t[t.INVALID_CUSTOM_CONTEXT = 3057] = "INVALID_CUSTOM_CONTEXT", t[t.INVALID_CUSTOM_ELEMENT_VALUE = 3058] = "INVALID_CUSTOM_ELEMENT_VALUE", t[t.INVALID_ELEMENT_IN_SIMPLE_BODY = 3059] = "INVALID_ELEMENT_IN_SIMPLE_BODY", t[t.BINDING_ERROR = 4e3] = "BINDING_ERROR", t[t.UNSUPPORTED = 5e3] = "UNSUPPORTED", t[t.CIRCULAR_REF = 5001] = "CIRCULAR_REF", t[t.SAME_ENDPOINT = 5002] = "SAME_ENDPOINT", t[t.UNEQUAL_FIELDS_BINARY_REF = 5003] = "UNEQUAL_FIELDS_BINARY_REF", t[t.CONFLICTING_SETTING = 5004] = "CONFLICTING_SETTING", t))(o || {});
478
- class l extends Error {
474
+ var o = /* @__PURE__ */ ((t) => (t[t.UNKNOWN_SYMBOL = 1e3] = "UNKNOWN_SYMBOL", t[t.UNEXPECTED_SYMBOL = 1001] = "UNEXPECTED_SYMBOL", t[t.UNEXPECTED_EOF = 1002] = "UNEXPECTED_EOF", t[t.UNEXPECTED_NEWLINE = 1003] = "UNEXPECTED_NEWLINE", t[t.UNKNOWN_TOKEN = 1004] = "UNKNOWN_TOKEN", t[t.UNEXPECTED_TOKEN = 1005] = "UNEXPECTED_TOKEN", t[t.UNEXPECTED_ELEMENT_DECLARATION = 1006] = "UNEXPECTED_ELEMENT_DECLARATION", t[t.MISSING_SPACES = 1007] = "MISSING_SPACES", t[t.UNKNOWN_PREFIX_OP = 1008] = "UNKNOWN_PREFIX_OP", t[t.INVALID_OPERAND = 1009] = "INVALID_OPERAND", t[t.EMPTY_ATTRIBUTE_NAME = 1010] = "EMPTY_ATTRIBUTE_NAME", t[t.INVALID_NAME = 3e3] = "INVALID_NAME", t[t.UNEXPECTED_NAME = 3001] = "UNEXPECTED_NAME", t[t.NAME_NOT_FOUND = 3002] = "NAME_NOT_FOUND", t[t.DUPLICATE_NAME = 3003] = "DUPLICATE_NAME", t[t.INVALID_ALIAS = 3004] = "INVALID_ALIAS", t[t.UNEXPECTED_ALIAS = 3005] = "UNEXPECTED_ALIAS", t[t.UNEXPECTED_SETTINGS = 3006] = "UNEXPECTED_SETTINGS", t[t.INVALID_SETTINGS = 3007] = "INVALID_SETTINGS", t[t.UNEXPECTED_SIMPLE_BODY = 3008] = "UNEXPECTED_SIMPLE_BODY", t[t.UNEXPECTED_COMPLEX_BODY = 3009] = "UNEXPECTED_COMPLEX_BODY", t[t.INVALID_TABLE_CONTEXT = 3010] = "INVALID_TABLE_CONTEXT", t[t.INVALID_TABLE_SETTING = 3011] = "INVALID_TABLE_SETTING", t[t.DUPLICATE_TABLE_SETTING = 3012] = "DUPLICATE_TABLE_SETTING", t[t.INVALID_TABLEGROUP_CONTEXT = 3013] = "INVALID_TABLEGROUP_CONTEXT", t[t.INVALID_TABLEGROUP_ELEMENT_NAME = 3014] = "INVALID_TABLEGROUP_ELEMENT_NAME", t[t.DUPLICATE_TABLEGROUP_ELEMENT_NAME = 3015] = "DUPLICATE_TABLEGROUP_ELEMENT_NAME", t[t.DUPLICATE_TABLEGROUP_FIELD_NAME = 3016] = "DUPLICATE_TABLEGROUP_FIELD_NAME", t[t.INVALID_TABLEGROUP_FIELD = 3017] = "INVALID_TABLEGROUP_FIELD", t[t.EMPTY_TABLE = 3018] = "EMPTY_TABLE", t[t.INVALID_COLUMN = 3019] = "INVALID_COLUMN", t[t.INVALID_COLUMN_NAME = 3020] = "INVALID_COLUMN_NAME", t[t.UNKNOWN_COLUMN_SETTING = 3021] = "UNKNOWN_COLUMN_SETTING", t[t.INVALID_COLUMN_TYPE = 3022] = "INVALID_COLUMN_TYPE", t[t.DUPLICATE_COLUMN_NAME = 3023] = "DUPLICATE_COLUMN_NAME", t[t.DUPLICATE_COLUMN_SETTING = 3024] = "DUPLICATE_COLUMN_SETTING", t[t.INVALID_COLUMN_SETTING_VALUE = 3025] = "INVALID_COLUMN_SETTING_VALUE", t[t.INVALID_ENUM_CONTEXT = 3026] = "INVALID_ENUM_CONTEXT", t[t.INVALID_ENUM_ELEMENT_NAME = 3027] = "INVALID_ENUM_ELEMENT_NAME", t[t.INVALID_ENUM_ELEMENT = 3028] = "INVALID_ENUM_ELEMENT", t[t.DUPLICATE_ENUM_ELEMENT_NAME = 3029] = "DUPLICATE_ENUM_ELEMENT_NAME", t[t.UNKNOWN_ENUM_ELEMENT_SETTING = 3030] = "UNKNOWN_ENUM_ELEMENT_SETTING", t[t.DUPLICATE_ENUM_ELEMENT_SETTING = 3031] = "DUPLICATE_ENUM_ELEMENT_SETTING", t[t.INVALID_ENUM_ELEMENT_SETTING = 3032] = "INVALID_ENUM_ELEMENT_SETTING", t[t.EMPTY_ENUM = 3033] = "EMPTY_ENUM", t[t.INVALID_REF_CONTEXT = 3034] = "INVALID_REF_CONTEXT", t[t.UNKNOWN_REF_SETTING = 3035] = "UNKNOWN_REF_SETTING", t[t.DUPLICATE_REF_SETTING = 3036] = "DUPLICATE_REF_SETTING", t[t.INVALID_REF_SETTING_VALUE = 3037] = "INVALID_REF_SETTING_VALUE", t[t.INVALID_REF_RELATIONSHIP = 3038] = "INVALID_REF_RELATIONSHIP", t[t.INVALID_REF_FIELD = 3039] = "INVALID_REF_FIELD", t[t.EMPTY_REF = 3040] = "EMPTY_REF", t[t.REF_REDEFINED = 3041] = "REF_REDEFINED", t[t.INVALID_NOTE_CONTEXT = 3042] = "INVALID_NOTE_CONTEXT", t[t.INVALID_NOTE = 3043] = "INVALID_NOTE", t[t.NOTE_REDEFINED = 3044] = "NOTE_REDEFINED", t[t.NOTE_CONTENT_REDEFINED = 3045] = "NOTE_CONTENT_REDEFINED", t[t.EMPTY_NOTE = 3046] = "EMPTY_NOTE", t[t.INVALID_INDEXES_CONTEXT = 3047] = "INVALID_INDEXES_CONTEXT", t[t.INVALID_INDEXES_FIELD = 3048] = "INVALID_INDEXES_FIELD", t[t.INVALID_INDEX = 3049] = "INVALID_INDEX", t[t.UNKNOWN_INDEX_SETTING = 3050] = "UNKNOWN_INDEX_SETTING", t[t.DUPLICATE_INDEX_SETTING = 3051] = "DUPLICATE_INDEX_SETTING", t[t.UNEXPECTED_INDEX_SETTING_VALUE = 3052] = "UNEXPECTED_INDEX_SETTING_VALUE", t[t.INVALID_INDEX_SETTING_VALUE = 3053] = "INVALID_INDEX_SETTING_VALUE", t[t.INVALID_PROJECT_CONTEXT = 3054] = "INVALID_PROJECT_CONTEXT", t[t.PROJECT_REDEFINED = 3055] = "PROJECT_REDEFINED", t[t.INVALID_PROJECT_FIELD = 3056] = "INVALID_PROJECT_FIELD", t[t.INVALID_CUSTOM_CONTEXT = 3057] = "INVALID_CUSTOM_CONTEXT", t[t.INVALID_CUSTOM_ELEMENT_VALUE = 3058] = "INVALID_CUSTOM_ELEMENT_VALUE", t[t.INVALID_ELEMENT_IN_SIMPLE_BODY = 3059] = "INVALID_ELEMENT_IN_SIMPLE_BODY", t[t.BINDING_ERROR = 4e3] = "BINDING_ERROR", t[t.UNSUPPORTED = 5e3] = "UNSUPPORTED", t[t.CIRCULAR_REF = 5001] = "CIRCULAR_REF", t[t.SAME_ENDPOINT = 5002] = "SAME_ENDPOINT", t[t.UNEQUAL_FIELDS_BINARY_REF = 5003] = "UNEQUAL_FIELDS_BINARY_REF", t[t.CONFLICTING_SETTING = 5004] = "CONFLICTING_SETTING", t[t.TABLE_REAPPEAR_IN_TABLEGROUP = 5005] = "TABLE_REAPPEAR_IN_TABLEGROUP", t))(o || {});
475
+ class u extends Error {
479
476
  constructor(e, n, s) {
480
- 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, l.prototype);
477
+ 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, u.prototype);
481
478
  }
482
479
  }
483
- class B {
480
+ class F {
484
481
  constructor(e, n) {
485
482
  this.value = e, this.errors = n === void 0 ? [] : n;
486
483
  }
@@ -492,20 +489,20 @@ class B {
492
489
  }
493
490
  chain(e) {
494
491
  const n = e(this.value), s = [...this.errors, ...n.errors];
495
- return new B(n.value, s);
492
+ return new F(n.value, s);
496
493
  }
497
494
  map(e) {
498
- return new B(e(this.value), this.errors);
495
+ return new F(e(this.value), this.errors);
499
496
  }
500
497
  }
501
- function nn(t, e, n) {
502
- if (!t || !fe(t) || e.length === 0)
498
+ function en(t, e, n) {
499
+ if (!t || !de(t) || e.length === 0)
503
500
  return new A();
504
501
  const s = [...e], i = Be(t).unwrap(), r = s.pop();
505
- if (!(r instanceof ee))
502
+ if (!(r instanceof te))
506
503
  return new A();
507
- const a = I.last(s) instanceof U ? s.pop() : void 0;
508
- return s.length === 3 && Be(s[1]).unwrap().value === "as" ? new S(
504
+ const a = I.last(s) instanceof P ? s.pop() : void 0;
505
+ return s.length === 3 && Be(s[1]).unwrap().value === "as" ? new O(
509
506
  n.create(_, {
510
507
  type: i,
511
508
  name: s[0],
@@ -514,14 +511,14 @@ function nn(t, e, n) {
514
511
  attributeList: a,
515
512
  body: r
516
513
  })
517
- ) : s.length === 1 ? new S(
514
+ ) : s.length === 1 ? new O(
518
515
  n.create(_, {
519
516
  type: i,
520
517
  name: s[0],
521
518
  attributeList: a,
522
519
  body: r
523
520
  })
524
- ) : s.length === 0 ? new S(
521
+ ) : s.length === 0 ? new O(
525
522
  n.create(_, {
526
523
  type: i,
527
524
  attributeList: a,
@@ -530,18 +527,18 @@ function nn(t, e, n) {
530
527
  ) : new A();
531
528
  }
532
529
  function lt(t) {
533
- return t.kind === u.IDENTIFIER && t.value === "as";
530
+ return t.kind === c.IDENTIFIER && t.value === "as";
534
531
  }
535
532
  function E(t) {
536
- t && (t instanceof V ? sn(t) : rn(t));
533
+ t && (t instanceof B ? tn(t) : nn(t));
537
534
  }
538
- function sn(t) {
539
- t.kind !== u.EOF && (t.isInvalid = !0);
535
+ function tn(t) {
536
+ t.kind !== c.EOF && (t.isInvalid = !0);
540
537
  }
541
- function rn(t) {
538
+ function nn(t) {
542
539
  if (t instanceof _)
543
540
  E(t.type), E(t.name), E(t.as), E(t.alias), E(t.bodyColon), E(t.attributeList), E(t.body);
544
- else if (t instanceof te)
541
+ else if (t instanceof K)
545
542
  t.identifiers.forEach(E);
546
543
  else if (t instanceof ne)
547
544
  E(t.name), E(t.colon), E(t.value);
@@ -549,40 +546,40 @@ function rn(t) {
549
546
  E(t.op), E(t.expression);
550
547
  else if (t instanceof q)
551
548
  E(t.leftExpression), E(t.op), E(t.rightExpression);
552
- else if (t instanceof De)
549
+ else if (t instanceof Re)
553
550
  E(t.op), E(t.expression);
554
- else if (t instanceof ee)
551
+ else if (t instanceof te)
555
552
  E(t.blockOpenBrace), t.body.forEach(E), E(t.blockCloseBrace);
556
- else if (t instanceof U)
553
+ else if (t instanceof P)
557
554
  E(t.listOpenBracket), t.commaList.forEach(E), t.elementList.forEach(E), E(t.listCloseBracket);
558
555
  else if (t instanceof J)
559
556
  E(t.tupleOpenParen), t.commaList.forEach(E), t.elementList.forEach(E), E(t.tupleCloseParen);
560
557
  else if (t instanceof H)
561
558
  E(t.callee), E(t.argumentList);
562
- else if (t instanceof v)
559
+ else if (t instanceof k)
563
560
  E(t.callee), t.args.forEach(E);
564
- else if (t instanceof R)
561
+ else if (t instanceof D)
565
562
  E(t.expression);
566
- else if (t instanceof K)
563
+ else if (t instanceof ee)
567
564
  E(t.value);
568
- else if (t instanceof W)
565
+ else if (t instanceof X)
569
566
  E(t.variable);
570
- else if (t instanceof pe)
567
+ else if (t instanceof Ee)
571
568
  E(t.literal);
572
569
  else
573
570
  throw t instanceof Xe ? new Error("This case is handled by the TupleExpressionNode case") : new Error("Unreachable case in markInvalidNode");
574
571
  }
575
- function vt(t) {
572
+ function At(t) {
576
573
  return !!(t != null && t.isInvalid);
577
574
  }
578
- function P(...t) {
575
+ function U(...t) {
579
576
  return t.filter((e) => e !== void 0);
580
577
  }
581
- function an(t) {
582
- if (t instanceof F)
583
- return P(...t.body, t.eof);
578
+ function sn(t) {
579
+ if (t instanceof C)
580
+ return U(...t.body, t.eof);
584
581
  if (t instanceof _)
585
- return P(
582
+ return U(
586
583
  t.type,
587
584
  t.name,
588
585
  t.as,
@@ -592,68 +589,73 @@ function an(t) {
592
589
  t.body
593
590
  );
594
591
  if (t instanceof ne)
595
- return P(t.name, t.colon, t.value);
596
- if (t instanceof te)
592
+ return U(t.name, t.colon, t.value);
593
+ if (t instanceof K)
597
594
  return t.identifiers;
598
- if (t instanceof pe)
595
+ if (t instanceof Ee)
599
596
  return t.literal ? [t.literal] : [];
600
- if (t instanceof W)
601
- return P(t.variable);
597
+ if (t instanceof X)
598
+ return U(t.variable);
602
599
  if (t instanceof Q)
603
- return P(t.op, t.expression);
600
+ return U(t.op, t.expression);
604
601
  if (t instanceof q)
605
- return P(t.leftExpression, t.op, t.rightExpression);
606
- if (t instanceof De)
607
- return P(t.expression, t.op);
608
- if (t instanceof K)
609
- return P(t.value);
610
- if (t instanceof v)
611
- return P(t.callee, ...t.args);
602
+ return U(t.leftExpression, t.op, t.rightExpression);
603
+ if (t instanceof Re)
604
+ return U(t.expression, t.op);
612
605
  if (t instanceof ee)
613
- return P(t.blockOpenBrace, ...t.body, t.blockCloseBrace);
614
- if (t instanceof U)
615
- return P(
606
+ return U(t.value);
607
+ if (t instanceof k)
608
+ return U(t.callee, ...t.args);
609
+ if (t instanceof te)
610
+ return U(t.blockOpenBrace, ...t.body, t.blockCloseBrace);
611
+ if (t instanceof P)
612
+ return U(
616
613
  t.listOpenBracket,
617
- ...ct(t.elementList, t.commaList),
614
+ ...ot(t.elementList, t.commaList),
618
615
  t.listCloseBracket
619
616
  );
620
617
  if (t instanceof J)
621
- return P(
618
+ return U(
622
619
  t.tupleOpenParen,
623
- ...ct(t.elementList, t.commaList),
620
+ ...ot(t.elementList, t.commaList),
624
621
  t.tupleCloseParen
625
622
  );
626
623
  if (t instanceof H)
627
- return P(t.callee, t.argumentList);
628
- if (t instanceof R)
629
- return P(t.expression);
624
+ return U(t.callee, t.argumentList);
625
+ if (t instanceof D)
626
+ return U(t.expression);
627
+ if (t instanceof le)
628
+ return U(
629
+ t.array,
630
+ t.indexer
631
+ );
630
632
  throw t instanceof Xe ? new Error("This case is already handled by TupleExpressionNode") : new Error("Unreachable - no other possible cases");
631
633
  }
632
634
  function Be(t) {
633
- return M(t) ? new S(t.expression.variable) : new A();
635
+ return M(t) ? new O(t.expression.variable) : new A();
634
636
  }
635
- function j(t) {
637
+ function $(t) {
636
638
  var e;
637
- return t instanceof R && (t.expression instanceof W && t.expression.variable instanceof V && t.expression.variable.kind === u.QUOTED_STRING || t.expression instanceof pe && ((e = t.expression.literal) == null ? void 0 : e.kind) === u.STRING_LITERAL);
639
+ return t instanceof D && (t.expression instanceof X && t.expression.variable instanceof B && t.expression.variable.kind === c.QUOTED_STRING || t.expression instanceof Ee && ((e = t.expression.literal) == null ? void 0 : e.kind) === c.STRING_LITERAL);
638
640
  }
639
641
  function M(t) {
640
- return t instanceof R && t.expression instanceof W && t.expression.variable instanceof V;
642
+ return t instanceof D && t.expression instanceof X && t.expression.variable instanceof B;
641
643
  }
642
- function fe(t) {
644
+ function de(t) {
643
645
  var e;
644
- return t instanceof R && t.expression instanceof W && ((e = t.expression.variable) == null ? void 0 : e.kind) === u.IDENTIFIER;
646
+ return t instanceof D && t.expression instanceof X && ((e = t.expression.variable) == null ? void 0 : e.kind) === c.IDENTIFIER;
645
647
  }
646
648
  function He(t) {
647
649
  var e;
648
- return t instanceof q && t.leftExpression instanceof x && t.rightExpression instanceof x && ((e = t.op) == null ? void 0 : e.value) === ".";
650
+ return t instanceof q && t.leftExpression instanceof y && t.rightExpression instanceof y && ((e = t.op) == null ? void 0 : e.value) === ".";
649
651
  }
650
- function Re(t) {
652
+ function De(t) {
651
653
  if (t === void 0)
652
654
  return new A();
653
655
  const e = t.identifiers.map((n) => n.value).join(" ");
654
- return e === "" ? new A() : new S(e);
656
+ return e === "" ? new A() : new O(e);
655
657
  }
656
- class on {
658
+ class rn {
657
659
  // list of errors during lexing
658
660
  constructor(e) {
659
661
  this.start = {
@@ -693,7 +695,7 @@ class on {
693
695
  this.tokens.push(this.createToken(e, n));
694
696
  }
695
697
  createToken(e, n = !1) {
696
- return V.create(
698
+ return B.create(
697
699
  e,
698
700
  this.start,
699
701
  this.current,
@@ -702,50 +704,50 @@ class on {
702
704
  );
703
705
  }
704
706
  lex() {
705
- return this.scanTokens(), this.tokens.push(V.create(u.EOF, this.start, this.current, "", !1)), this.gatherTrivia(), this.gatherInvalid(), new B(this.tokens, this.errors);
707
+ return this.scanTokens(), this.tokens.push(B.create(c.EOF, this.start, this.current, "", !1)), this.gatherTrivia(), this.gatherInvalid(), new F(this.tokens, this.errors);
706
708
  }
707
709
  scanTokens() {
708
710
  for (; !this.isAtEnd(); ) {
709
711
  const e = this.advance();
710
712
  switch (e) {
711
713
  case " ":
712
- this.addToken(u.SPACE);
714
+ this.addToken(c.SPACE);
713
715
  break;
714
716
  case "\r":
715
717
  break;
716
718
  case `
717
719
  `:
718
- this.addToken(u.NEWLINE);
720
+ this.addToken(c.NEWLINE);
719
721
  break;
720
722
  case " ":
721
- this.addToken(u.TAB);
723
+ this.addToken(c.TAB);
722
724
  break;
723
725
  case ",":
724
- this.addToken(u.COMMA);
726
+ this.addToken(c.COMMA);
725
727
  break;
726
728
  case "(":
727
- this.addToken(u.LPAREN);
729
+ this.addToken(c.LPAREN);
728
730
  break;
729
731
  case ")":
730
- this.addToken(u.RPAREN);
732
+ this.addToken(c.RPAREN);
731
733
  break;
732
734
  case "[":
733
- this.addToken(u.LBRACKET);
735
+ this.addToken(c.LBRACKET);
734
736
  break;
735
737
  case "]":
736
- this.addToken(u.RBRACKET);
738
+ this.addToken(c.RBRACKET);
737
739
  break;
738
740
  case "{":
739
- this.addToken(u.LBRACE);
741
+ this.addToken(c.LBRACE);
740
742
  break;
741
743
  case "}":
742
- this.addToken(u.RBRACE);
744
+ this.addToken(c.RBRACE);
743
745
  break;
744
746
  case ";":
745
- this.addToken(u.SEMICOLON);
747
+ this.addToken(c.SEMICOLON);
746
748
  break;
747
749
  case ":":
748
- this.addToken(u.COLON);
750
+ this.addToken(c.COLON);
749
751
  break;
750
752
  case "'":
751
753
  this.match("''") ? this.multilineStringLiteral() : this.singleLineStringLiteral();
@@ -763,7 +765,7 @@ class on {
763
765
  this.match("/") ? this.singleLineComment() : this.match("*") ? this.multilineComment() : this.operator();
764
766
  break;
765
767
  default:
766
- if (rt(e)) {
768
+ if (it(e)) {
767
769
  this.operator();
768
770
  break;
769
771
  }
@@ -771,15 +773,15 @@ class on {
771
773
  this.identifier();
772
774
  break;
773
775
  }
774
- if (ke(e)) {
775
- this.numericLiteral();
776
+ if (xe(e)) {
777
+ this.numericLiteralOrIdentifier();
776
778
  break;
777
779
  }
778
- this.addToken(u.OP, !0), this.errors.push(
779
- new l(
780
+ this.addToken(c.OP, !0), this.errors.push(
781
+ new u(
780
782
  o.UNKNOWN_SYMBOL,
781
783
  `Unexpected token '${e}'`,
782
- this.createToken(u.OP, !0)
784
+ this.createToken(c.OP, !0)
783
785
  )
784
786
  );
785
787
  break;
@@ -791,13 +793,13 @@ class on {
791
793
  let e = !0, n = [], s;
792
794
  const i = [];
793
795
  for (const r of this.tokens)
794
- $t(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);
796
+ Xt(r) ? (n.push(r), r.kind === c.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);
795
797
  this.tokens = i;
796
798
  }
797
799
  gatherInvalid() {
798
800
  let e;
799
801
  const n = [], s = [];
800
- for (e = 0; e < this.tokens.length && vt(this.tokens[e]); e += 1)
802
+ for (e = 0; e < this.tokens.length && At(this.tokens[e]); e += 1)
801
803
  s.push(this.tokens[e]);
802
804
  let i = this.tokens[e];
803
805
  for (i.leadingInvalid = [...s, ...i.leadingInvalid]; e < this.tokens.length; e += 1) {
@@ -816,14 +818,14 @@ class on {
816
818
  // Whether to interpret '\' as a backlash
817
819
  consumeStopSequence: a = !0
818
820
  }) {
819
- let c = "";
821
+ let l = "";
820
822
  for (; !this.isAtEnd() && (s || !this.check(`
821
823
  `)) && !this.check(n); )
822
- this.peek() === "\\" && !r ? (this.advance(), c += this.escapedString()) : c += this.advance();
824
+ this.peek() === "\\" && !r ? (this.advance(), l += this.escapedString()) : l += this.advance();
823
825
  if (this.isAtEnd() && !i) {
824
826
  const p = this.createToken(e, !0);
825
827
  this.tokens.push(p), this.errors.push(
826
- new l(o.UNEXPECTED_EOF, "EOF reached while parsing", p)
828
+ new u(o.UNEXPECTED_EOF, "EOF reached while parsing", p)
827
829
  );
828
830
  return;
829
831
  }
@@ -831,7 +833,7 @@ class on {
831
833
  `) && !s) {
832
834
  const p = this.createToken(e, !0);
833
835
  this.tokens.push(p), this.errors.push(
834
- new l(
836
+ new u(
835
837
  o.UNEXPECTED_NEWLINE,
836
838
  "Invalid newline encountered while parsing",
837
839
  p
@@ -839,38 +841,38 @@ class on {
839
841
  );
840
842
  return;
841
843
  }
842
- a && this.match(n), this.tokens.push(V.create(e, this.start, this.current, c, !1));
844
+ a && this.match(n), this.tokens.push(B.create(e, this.start, this.current, l, !1));
843
845
  }
844
846
  singleLineStringLiteral() {
845
- this.consumeUntil(u.STRING_LITERAL, "'", {
847
+ this.consumeUntil(c.STRING_LITERAL, "'", {
846
848
  allowNewline: !1,
847
849
  allowEof: !1,
848
850
  raw: !1
849
851
  });
850
852
  }
851
853
  multilineStringLiteral() {
852
- this.consumeUntil(u.STRING_LITERAL, "'''", {
854
+ this.consumeUntil(c.STRING_LITERAL, "'''", {
853
855
  allowNewline: !0,
854
856
  allowEof: !1,
855
857
  raw: !1
856
858
  });
857
859
  }
858
860
  functionExpression() {
859
- this.consumeUntil(u.FUNCTION_EXPRESSION, "`", {
861
+ this.consumeUntil(c.FUNCTION_EXPRESSION, "`", {
860
862
  allowNewline: !1,
861
863
  allowEof: !1,
862
864
  raw: !0
863
865
  });
864
866
  }
865
867
  quotedVariable() {
866
- this.consumeUntil(u.QUOTED_STRING, '"', {
868
+ this.consumeUntil(c.QUOTED_STRING, '"', {
867
869
  allowNewline: !1,
868
870
  allowEof: !1,
869
871
  raw: !1
870
872
  });
871
873
  }
872
874
  singleLineComment() {
873
- this.consumeUntil(u.SINGLE_LINE_COMMENT, `
875
+ this.consumeUntil(c.SINGLE_LINE_COMMENT, `
874
876
  `, {
875
877
  allowNewline: !0,
876
878
  allowEof: !0,
@@ -879,47 +881,55 @@ class on {
879
881
  });
880
882
  }
881
883
  multilineComment() {
882
- this.consumeUntil(u.MULTILINE_COMMENT, "*/", {
884
+ this.consumeUntil(c.MULTILINE_COMMENT, "*/", {
883
885
  allowNewline: !0,
884
886
  allowEof: !1,
885
887
  raw: !0
886
888
  });
887
889
  }
888
890
  identifier() {
889
- for (; !this.isAtEnd() && Ie(this.peek()); )
891
+ for (; !this.isAtEnd() && fe(this.peek()); )
890
892
  this.advance();
891
- this.addToken(u.IDENTIFIER);
893
+ this.addToken(c.IDENTIFIER);
892
894
  }
893
895
  operator() {
894
- for (; rt(this.peek()); )
896
+ for (; it(this.peek()); )
895
897
  this.advance();
896
- this.addToken(u.OP);
898
+ this.addToken(c.OP);
897
899
  }
898
- numericLiteral() {
900
+ // we accept identifiers starting with digits but must contain at least one char or underscore
901
+ numericLiteralOrIdentifier() {
899
902
  let e = 0;
900
903
  if (this.isAtEnd())
901
- return this.addToken(u.NUMERIC_LITERAL);
904
+ return this.addToken(c.NUMERIC_LITERAL);
902
905
  for (; !this.isAtEnd(); ) {
903
- const s = this.check(".");
904
- if (e += s ? 1 : 0, e > 1)
906
+ const n = this.check(".");
907
+ if (e += n ? 1 : 0, e > 1)
905
908
  break;
906
- if (!s && this.current.offset === this.text.length - 1)
907
- return this.advance(), this.addToken(u.NUMERIC_LITERAL);
908
- if (!s && !Ie(this.peek()))
909
- return this.addToken(u.NUMERIC_LITERAL);
910
- if (!s && !ke(this.peek()))
909
+ if (!n && this.current.offset === this.text.length - 1)
910
+ return this.advance(), this.addToken(c.NUMERIC_LITERAL);
911
+ if (!n && !fe(this.peek()))
912
+ return this.addToken(c.NUMERIC_LITERAL);
913
+ if (!n && !xe(this.peek()))
911
914
  break;
912
915
  this.advance();
913
916
  }
914
- for (; !this.isAtEnd() && (this.check(".") || Ie(this.peek())); )
915
- this.advance();
916
- const n = this.createToken(u.NUMERIC_LITERAL, !0);
917
- this.tokens.push(n), this.errors.push(new l(o.UNKNOWN_TOKEN, "Invalid number", n));
917
+ if (e > 0) {
918
+ for (; !this.isAtEnd() && (this.check(".") || fe(this.peek())); )
919
+ this.advance();
920
+ const n = this.createToken(c.NUMERIC_LITERAL, !0);
921
+ this.tokens.push(n), this.errors.push(new u(o.UNKNOWN_TOKEN, "Invalid number", n));
922
+ } else {
923
+ for (; !this.isAtEnd() && fe(this.peek()); )
924
+ this.advance();
925
+ const n = this.createToken(c.IDENTIFIER, !1);
926
+ this.tokens.push(n);
927
+ }
918
928
  }
919
929
  colorLiteral() {
920
- for (; !this.isAtEnd() && Ie(this.peek()); )
930
+ for (; !this.isAtEnd() && fe(this.peek()); )
921
931
  this.advance();
922
- this.addToken(u.COLOR_LITERAL);
932
+ this.addToken(c.COLOR_LITERAL);
923
933
  }
924
934
  escapedString() {
925
935
  if (this.isAtEnd())
@@ -949,7 +959,7 @@ class on {
949
959
  case "u": {
950
960
  let e = "";
951
961
  for (let n = 0; n <= 3; n += 1) {
952
- if (this.isAtEnd() || !Ie(this.peek()))
962
+ if (this.isAtEnd() || !fe(this.peek()))
953
963
  return `\\u${e}`;
954
964
  e += this.advance();
955
965
  }
@@ -961,7 +971,7 @@ class on {
961
971
  }
962
972
  }
963
973
  var ye = /* @__PURE__ */ ((t) => (t[t.ListExpression = 0] = "ListExpression", t[t.GroupExpression = 1] = "GroupExpression", t[t.BlockExpression = 2] = "BlockExpression", t))(ye || {});
964
- class cn {
974
+ class an {
965
975
  constructor() {
966
976
  this.stack = [], this.numberOfNestedLParens = 0, this.numberOfNestedLBrackets = 0, this.numberOfNestedLBraces = 0;
967
977
  }
@@ -1002,7 +1012,7 @@ class cn {
1002
1012
  if (!(this.numberOfNestedLBraces <= 0 && this.numberOfNestedLBrackets <= 0 && this.numberOfNestedLParens <= 0))
1003
1013
  for (let s = n; s < e.length - 1; s += 1)
1004
1014
  switch (e[s].kind) {
1005
- case u.COMMA:
1015
+ case c.COMMA:
1006
1016
  if (this.isWithinGroupExpressionContext() || this.isWithinListExpressionContext())
1007
1017
  return [...this.stack].reverse().find(
1008
1018
  (r) => [
@@ -1012,22 +1022,22 @@ class cn {
1012
1022
  ].includes(r)
1013
1023
  );
1014
1024
  break;
1015
- case u.RPAREN:
1025
+ case c.RPAREN:
1016
1026
  if (this.isWithinGroupExpressionContext())
1017
1027
  return 1;
1018
1028
  break;
1019
- case u.RBRACE:
1029
+ case c.RBRACE:
1020
1030
  if (this.isWithinBlockExpressionContext())
1021
1031
  return 2;
1022
1032
  break;
1023
- case u.RBRACKET:
1033
+ case c.RBRACKET:
1024
1034
  if (this.isWithinListExpressionContext())
1025
1035
  return 0;
1026
1036
  break;
1027
1037
  }
1028
1038
  }
1029
1039
  }
1030
- class ln {
1040
+ class on {
1031
1041
  constructor(e) {
1032
1042
  this.generator = e;
1033
1043
  }
@@ -1040,29 +1050,29 @@ class d {
1040
1050
  this.token = e, this.partialNode = n, this.handlerContext = s;
1041
1051
  }
1042
1052
  }
1043
- class un {
1053
+ class ln {
1044
1054
  constructor(e, n) {
1045
- this.current = 0, this.errors = [], this.contextStack = new cn(), this.synchronizeProgram = () => {
1055
+ this.current = 0, this.errors = [], this.contextStack = new an(), this.synchronizeProgram = () => {
1046
1056
  const s = this.peek();
1047
- s.kind !== u.EOF ? E(this.advance()) : (E(this.peek()), this.logError(s, o.UNEXPECTED_EOF, "Unexpected EOF"));
1057
+ s.kind !== c.EOF ? E(this.advance()) : (E(this.peek()), this.logError(s, o.UNEXPECTED_EOF, "Unexpected EOF"));
1048
1058
  }, this.synchronizeElementDeclarationName = () => {
1049
1059
  for (; !this.isAtEnd(); ) {
1050
1060
  const s = this.peek();
1051
- if (lt(s) || this.check(u.COLON, u.LBRACE, u.LBRACKET))
1061
+ if (lt(s) || this.check(c.COLON, c.LBRACE, c.LBRACKET))
1052
1062
  break;
1053
1063
  E(s), this.advance();
1054
1064
  }
1055
1065
  }, this.synchronizeElementDeclarationAlias = () => {
1056
1066
  for (; !this.isAtEnd(); ) {
1057
1067
  const s = this.peek();
1058
- if (this.check(u.COLON, u.LBRACE, u.LBRACKET))
1068
+ if (this.check(c.COLON, c.LBRACE, c.LBRACKET))
1059
1069
  break;
1060
1070
  E(s), this.advance();
1061
1071
  }
1062
1072
  }, this.blockExpression = this.contextStack.withContextDo(ye.BlockExpression, () => {
1063
- const s = { body: [] }, i = () => this.nodeFactory.create(ee, s);
1073
+ const s = { body: [] }, i = () => this.nodeFactory.create(te, s);
1064
1074
  try {
1065
- this.consume("Expect an opening brace '{'", u.LBRACE), s.blockOpenBrace = this.previous();
1075
+ this.consume("Expect an opening brace '{'", c.LBRACE), s.blockOpenBrace = this.previous();
1066
1076
  } catch (r) {
1067
1077
  if (!(r instanceof d))
1068
1078
  throw r;
@@ -1070,7 +1080,7 @@ class un {
1070
1080
  throw new d(r.token, i(), r.handlerContext);
1071
1081
  this.synchronizeBlock();
1072
1082
  }
1073
- for (; !this.isAtEnd() && !this.check(u.RBRACE); )
1083
+ for (; !this.isAtEnd() && !this.check(c.RBRACE); )
1074
1084
  try {
1075
1085
  s.body.push(this.canBeField() ? this.fieldDeclaration() : this.expression());
1076
1086
  } catch (r) {
@@ -1081,7 +1091,7 @@ class un {
1081
1091
  this.synchronizeBlock();
1082
1092
  }
1083
1093
  try {
1084
- this.consume("Expect a closing brace '}'", u.RBRACE), s.blockCloseBrace = this.previous();
1094
+ this.consume("Expect a closing brace '}'", c.RBRACE), s.blockCloseBrace = this.previous();
1085
1095
  } catch (r) {
1086
1096
  if (!(r instanceof d))
1087
1097
  throw r;
@@ -1091,10 +1101,10 @@ class un {
1091
1101
  }
1092
1102
  return i();
1093
1103
  }), this.synchronizeBlock = () => {
1094
- if (!this.check(u.RBRACE))
1104
+ if (!this.check(c.RBRACE))
1095
1105
  for (E(this.advance()); !this.isAtEnd(); ) {
1096
1106
  const s = this.peek();
1097
- if (this.check(u.RBRACE) || ot(this.previous(), s))
1107
+ if (this.check(c.RBRACE) || at(this.previous(), s))
1098
1108
  break;
1099
1109
  E(s), this.advance();
1100
1110
  }
@@ -1105,7 +1115,7 @@ class un {
1105
1115
  expression: s.elementList[0]
1106
1116
  }), r = () => this.nodeFactory.create(J, s);
1107
1117
  try {
1108
- this.consume("Expect an opening parenthesis '('", u.LPAREN), s.tupleOpenParen = this.previous();
1118
+ this.consume("Expect an opening parenthesis '('", c.LPAREN), s.tupleOpenParen = this.previous();
1109
1119
  } catch (a) {
1110
1120
  if (!(a instanceof d))
1111
1121
  throw a;
@@ -1113,7 +1123,7 @@ class un {
1113
1123
  throw new d(a.token, r(), a.handlerContext);
1114
1124
  this.synchronizeTuple();
1115
1125
  }
1116
- if (!this.isAtEnd() && !this.check(u.RPAREN))
1126
+ if (!this.isAtEnd() && !this.check(c.RPAREN))
1117
1127
  try {
1118
1128
  s.elementList.push(this.normalExpression());
1119
1129
  } catch (a) {
@@ -1123,18 +1133,18 @@ class un {
1123
1133
  throw new d(a.token, i(), a.handlerContext);
1124
1134
  this.synchronizeTuple();
1125
1135
  }
1126
- for (; !this.isAtEnd() && !this.check(u.RPAREN); )
1136
+ for (; !this.isAtEnd() && !this.check(c.RPAREN); )
1127
1137
  try {
1128
- this.consume("Expect a comma ','", u.COMMA), s.commaList.push(this.previous()), s.elementList.push(this.normalExpression());
1138
+ this.consume("Expect a comma ','", c.COMMA), s.commaList.push(this.previous()), s.elementList.push(this.normalExpression());
1129
1139
  } catch (a) {
1130
1140
  if (!(a instanceof d))
1131
1141
  throw a;
1132
- if (a.partialNode instanceof x && s.elementList.push(a.partialNode), !this.canHandle(a))
1142
+ if (a.partialNode instanceof y && s.elementList.push(a.partialNode), !this.canHandle(a))
1133
1143
  throw new d(a.token, r(), a.handlerContext);
1134
1144
  this.synchronizeTuple();
1135
1145
  }
1136
1146
  try {
1137
- this.consume("Expect a closing parenthesis ')'", u.RPAREN), s.tupleCloseParen = this.previous();
1147
+ this.consume("Expect a closing parenthesis ')'", c.RPAREN), s.tupleCloseParen = this.previous();
1138
1148
  } catch (a) {
1139
1149
  if (!(a instanceof d))
1140
1150
  throw a;
@@ -1146,14 +1156,14 @@ class un {
1146
1156
  }), this.synchronizeTuple = () => {
1147
1157
  for (; !this.isAtEnd(); ) {
1148
1158
  const s = this.peek();
1149
- if (this.check(u.RPAREN, u.COMMA))
1159
+ if (this.check(c.RPAREN, c.COMMA))
1150
1160
  break;
1151
1161
  E(s), this.advance();
1152
1162
  }
1153
1163
  }, this.listExpression = this.contextStack.withContextDo(ye.ListExpression, () => {
1154
- const s = { elementList: [], commaList: [] }, i = () => this.nodeFactory.create(U, s);
1164
+ const s = { elementList: [], commaList: [] }, i = () => this.nodeFactory.create(P, s);
1155
1165
  try {
1156
- this.consume("Expect an opening bracket '['", u.LBRACKET), s.listOpenBracket = this.previous();
1166
+ this.consume("Expect an opening bracket '['", c.LBRACKET), s.listOpenBracket = this.previous();
1157
1167
  } catch (r) {
1158
1168
  if (!(r instanceof d))
1159
1169
  throw r;
@@ -1161,7 +1171,7 @@ class un {
1161
1171
  throw new d(r.token, i(), r.handlerContext);
1162
1172
  this.synchronizeList();
1163
1173
  }
1164
- if (!this.isAtEnd() && !this.check(u.RBRACKET))
1174
+ if (!this.isAtEnd() && !this.check(c.RBRACKET))
1165
1175
  try {
1166
1176
  s.elementList.push(this.attribute());
1167
1177
  } catch (r) {
@@ -1171,18 +1181,18 @@ class un {
1171
1181
  throw new d(r.token, i(), r.handlerContext);
1172
1182
  this.synchronizeList();
1173
1183
  }
1174
- for (; !this.isAtEnd() && !this.check(u.RBRACKET); )
1184
+ for (; !this.isAtEnd() && !this.check(c.RBRACKET); )
1175
1185
  try {
1176
- this.consume("Expect a comma ','", u.COMMA), s.commaList.push(this.previous()), s.elementList.push(this.attribute());
1186
+ this.consume("Expect a comma ','", c.COMMA), s.commaList.push(this.previous()), s.elementList.push(this.attribute());
1177
1187
  } catch (r) {
1178
1188
  if (!(r instanceof d))
1179
1189
  throw r;
1180
- if (r.partialNode instanceof x && s.elementList.push(r.partialNode), !this.canHandle(r))
1190
+ if (r.partialNode instanceof y && s.elementList.push(r.partialNode), !this.canHandle(r))
1181
1191
  throw new d(r.token, i(), r.handlerContext);
1182
1192
  this.synchronizeList();
1183
1193
  }
1184
1194
  try {
1185
- this.consume("Expect a closing bracket ']'", u.RBRACKET), s.listCloseBracket = this.previous();
1195
+ this.consume("Expect a closing bracket ']'", c.RBRACKET), s.listCloseBracket = this.previous();
1186
1196
  } catch (r) {
1187
1197
  if (!(r instanceof d))
1188
1198
  throw r;
@@ -1194,28 +1204,28 @@ class un {
1194
1204
  }), this.synchronizeList = () => {
1195
1205
  for (; !this.isAtEnd(); ) {
1196
1206
  const s = this.peek();
1197
- if (this.check(u.COMMA, u.RBRACKET))
1207
+ if (this.check(c.COMMA, c.RBRACKET))
1198
1208
  break;
1199
1209
  E(s), this.advance();
1200
1210
  }
1201
1211
  }, this.synchronizeAttributeName = () => {
1202
1212
  for (; !this.isAtEnd(); ) {
1203
1213
  const s = this.peek();
1204
- if (this.check(u.COMMA, u.RBRACKET, u.COLON))
1214
+ if (this.check(c.COMMA, c.RBRACKET, c.COLON))
1205
1215
  break;
1206
1216
  E(s), this.advance();
1207
1217
  }
1208
1218
  }, this.synchronizeAttributeValue = () => {
1209
1219
  for (; !this.isAtEnd(); ) {
1210
1220
  const s = this.peek();
1211
- if (this.check(u.COMMA, u.RBRACKET))
1221
+ if (this.check(c.COMMA, c.RBRACKET))
1212
1222
  break;
1213
1223
  E(s), this.advance();
1214
1224
  }
1215
- }, this.tokens = e, this.nodeFactory = new ln(n);
1225
+ }, this.tokens = e, this.nodeFactory = new on(n);
1216
1226
  }
1217
1227
  isAtEnd() {
1218
- return this.current >= this.tokens.length || this.tokens[this.current].kind === u.EOF;
1228
+ return this.current >= this.tokens.length || this.tokens[this.current].kind === c.EOF;
1219
1229
  }
1220
1230
  advance() {
1221
1231
  return this.isAtEnd() ? I.last(this.tokens) : this.tokens[this.current++];
@@ -1268,8 +1278,8 @@ class un {
1268
1278
  this.tokens = e;
1269
1279
  }
1270
1280
  parse() {
1271
- const e = this.program(), n = this.advance(), s = this.nodeFactory.create(F, { body: e, eof: n });
1272
- return this.gatherInvalid(), new B({ ast: s, tokens: this.tokens }, this.errors);
1281
+ const e = this.program(), n = this.advance(), s = this.nodeFactory.create(C, { body: e, eof: n });
1282
+ return this.gatherInvalid(), new F({ ast: s, tokens: this.tokens }, this.errors);
1273
1283
  }
1274
1284
  /* Parsing and synchronizing ProgramNode */
1275
1285
  program() {
@@ -1289,11 +1299,11 @@ class un {
1289
1299
  elementDeclaration() {
1290
1300
  const e = {}, n = () => this.nodeFactory.create(_, e);
1291
1301
  try {
1292
- this.consume("Expect an identifier", u.IDENTIFIER), e.type = this.previous();
1302
+ this.consume("Expect an identifier", c.IDENTIFIER), e.type = this.previous();
1293
1303
  } catch (s) {
1294
1304
  throw s instanceof d ? (e.type = s.partialNode, new d(s.token, n(), s.handlerContext)) : s;
1295
1305
  }
1296
- if (!this.check(u.COLON, u.LBRACE, u.LBRACKET))
1306
+ if (!this.check(c.COLON, c.LBRACE, c.LBRACKET))
1297
1307
  try {
1298
1308
  e.name = this.normalExpression();
1299
1309
  } catch (s) {
@@ -1304,7 +1314,7 @@ class un {
1304
1314
  this.synchronizeElementDeclarationName();
1305
1315
  }
1306
1316
  if (lt(this.peek()))
1307
- if (e.as = this.advance(), this.check(u.COLON, u.LBRACE, u.LBRACKET))
1317
+ if (e.as = this.advance(), this.check(c.COLON, c.LBRACE, c.LBRACKET))
1308
1318
  this.logError(this.peek(), o.UNEXPECTED_TOKEN, "Expect an alias");
1309
1319
  else
1310
1320
  try {
@@ -1317,18 +1327,18 @@ class un {
1317
1327
  this.synchronizeElementDeclarationAlias();
1318
1328
  }
1319
1329
  try {
1320
- e.attributeList = this.check(u.LBRACKET) ? this.listExpression() : void 0;
1330
+ e.attributeList = this.check(c.LBRACKET) ? this.listExpression() : void 0;
1321
1331
  } catch (s) {
1322
1332
  throw s instanceof d ? (e.attributeList = s.partialNode, new d(s.token, n(), s.handlerContext)) : s;
1323
1333
  }
1324
1334
  if (!this.discardUntil(
1325
1335
  "Expect an opening brace '{' or a colon ':'",
1326
- u.LBRACE,
1327
- u.COLON
1336
+ c.LBRACE,
1337
+ c.COLON
1328
1338
  ))
1329
1339
  return n();
1330
1340
  try {
1331
- if (this.match(u.COLON)) {
1341
+ if (this.match(c.COLON)) {
1332
1342
  e.bodyColon = this.previous();
1333
1343
  const s = this.expression();
1334
1344
  s instanceof _ ? (E(s), this.logError(s, o.UNEXPECTED_ELEMENT_DECLARATION, "An element's simple body must not be an element declaration")) : e.body = s;
@@ -1348,18 +1358,18 @@ class un {
1348
1358
  fieldDeclaration() {
1349
1359
  const e = {}, n = () => this.nodeFactory.create(_, e);
1350
1360
  try {
1351
- this.consume("Expect an identifier", u.IDENTIFIER), e.type = this.previous();
1361
+ this.consume("Expect an identifier", c.IDENTIFIER), e.type = this.previous();
1352
1362
  } catch (s) {
1353
1363
  throw s instanceof d ? (e.type = s.partialNode, new d(s.token, n(), s.handlerContext)) : s;
1354
1364
  }
1355
1365
  try {
1356
- this.consume("Expect a colon ':'", u.COLON), e.bodyColon = this.previous();
1366
+ this.consume("Expect a colon ':'", c.COLON), e.bodyColon = this.previous();
1357
1367
  } catch (s) {
1358
1368
  throw s instanceof d ? (e.bodyColon = s.partialNode, new d(s.token, n(), s.handlerContext)) : s;
1359
1369
  }
1360
1370
  try {
1361
1371
  const s = this.expression();
1362
- s instanceof _ ? this.errors.push(new l(o.INVALID_ELEMENT_IN_SIMPLE_BODY, "Simple body cannot be an element declaration", s)) : e.body = s;
1372
+ s instanceof _ ? this.errors.push(new u(o.INVALID_ELEMENT_IN_SIMPLE_BODY, "Simple body cannot be an element declaration", s)) : e.body = s;
1363
1373
  } catch (s) {
1364
1374
  throw s instanceof d ? (e.body = s.partialNode, new d(s.token, n(), s.handlerContext)) : s;
1365
1375
  }
@@ -1367,8 +1377,8 @@ class un {
1367
1377
  }
1368
1378
  /* Parsing any ExpressionNode, including non-NormalExpression */
1369
1379
  expression() {
1370
- const e = { args: [] }, n = () => nn(e.callee, e.args, this.nodeFactory).unwrap_or(
1371
- this.nodeFactory.create(v, e)
1380
+ const e = { args: [] }, n = () => en(e.callee, e.args, this.nodeFactory).unwrap_or(
1381
+ this.nodeFactory.create(k, e)
1372
1382
  );
1373
1383
  try {
1374
1384
  e.callee = this.normalExpression();
@@ -1389,10 +1399,10 @@ class un {
1389
1399
  return n();
1390
1400
  }
1391
1401
  shouldStopExpression() {
1392
- if (this.isAtEnd() || bt(this.previous()))
1402
+ if (this.isAtEnd() || Tt(this.previous()))
1393
1403
  return !0;
1394
1404
  const e = this.peek().kind;
1395
- return e === u.RBRACE || e === u.RBRACKET || e === u.RPAREN || e === u.COMMA || e === u.COLON;
1405
+ return e === c.RBRACE || e === c.RBRACKET || e === c.RPAREN || e === c.COMMA || e === c.COLON;
1396
1406
  }
1397
1407
  normalExpression() {
1398
1408
  return this.expression_bp(0);
@@ -1402,13 +1412,13 @@ class un {
1402
1412
  let n = this.leftExpression_bp();
1403
1413
  for (; !this.isAtEnd(); ) {
1404
1414
  const s = this.peek();
1405
- if (s.kind === u.LPAREN) {
1406
- const { left: i } = ut(s);
1415
+ if (s.kind === c.LPAREN) {
1416
+ const { left: i } = ct(s);
1407
1417
  if (i < e || // When '(' is encountered,
1408
1418
  // consider it part of another expression if
1409
1419
  // it's at the start of a new line
1410
1420
  // and we're currently not having unmatched '(' or '['
1411
- ot(this.previous(), s) && !this.contextStack.isWithinGroupExpressionContext() && !this.contextStack.isWithinListExpressionContext())
1421
+ at(this.previous(), s) && !this.contextStack.isWithinGroupExpressionContext() && !this.contextStack.isWithinListExpressionContext())
1412
1422
  break;
1413
1423
  try {
1414
1424
  n = this.nodeFactory.create(H, {
@@ -1421,31 +1431,31 @@ class un {
1421
1431
  argumentList: r.partialNode
1422
1432
  }), new d(r.token, n, r.handlerContext)) : r;
1423
1433
  }
1424
- } else if (s.kind === u.LBRACKET) {
1434
+ } else if (s.kind === c.LBRACKET) {
1425
1435
  if (Ve(this.previous()))
1426
1436
  break;
1427
1437
  try {
1428
- n = this.nodeFactory.create(he, {
1438
+ n = this.nodeFactory.create(le, {
1429
1439
  expression: n,
1430
1440
  indexer: this.listExpression()
1431
1441
  });
1432
1442
  } catch (i) {
1433
- throw i instanceof d ? (n = this.nodeFactory.create(he, {
1443
+ throw i instanceof d ? (n = this.nodeFactory.create(le, {
1434
1444
  expression: n,
1435
1445
  indexer: i.partialNode
1436
1446
  }), new d(i.token, n, i.handlerContext)) : i;
1437
1447
  }
1438
- } else if (at(s)) {
1439
- const i = s, r = ut(i);
1448
+ } else if (rt(s)) {
1449
+ const i = s, r = ct(i);
1440
1450
  if (r.left !== null) {
1441
1451
  if (r.left <= e)
1442
1452
  break;
1443
- this.advance(), n = this.nodeFactory.create(De, {
1453
+ this.advance(), n = this.nodeFactory.create(Re, {
1444
1454
  expression: n,
1445
1455
  op: i
1446
1456
  });
1447
1457
  } else {
1448
- const a = fn(i);
1458
+ const a = un(i);
1449
1459
  if (a.left === null || a.left <= e)
1450
1460
  break;
1451
1461
  this.advance();
@@ -1455,12 +1465,12 @@ class un {
1455
1465
  op: i,
1456
1466
  rightExpression: i.value === "." ? this.extractOperand() : this.expression_bp(a.right)
1457
1467
  });
1458
- } catch (c) {
1459
- throw c instanceof d ? (n = this.nodeFactory.create(q, {
1468
+ } catch (l) {
1469
+ throw l instanceof d ? (n = this.nodeFactory.create(q, {
1460
1470
  leftExpression: n,
1461
1471
  op: i,
1462
- rightExpression: c.partialNode
1463
- }), new d(c.token, n, c.handlerContext)) : c;
1472
+ rightExpression: l.partialNode
1473
+ }), new d(l.token, n, l.handlerContext)) : l;
1464
1474
  }
1465
1475
  }
1466
1476
  } else
@@ -1470,10 +1480,10 @@ class un {
1470
1480
  }
1471
1481
  leftExpression_bp() {
1472
1482
  let e;
1473
- if (at(this.peek())) {
1483
+ if (rt(this.peek())) {
1474
1484
  const n = {};
1475
1485
  n.op = this.peek();
1476
- const s = dn(n.op);
1486
+ const s = fn(n.op);
1477
1487
  if (s.right === null)
1478
1488
  throw this.logError(
1479
1489
  n.op,
@@ -1509,12 +1519,12 @@ class un {
1509
1519
  // e.g { ... }
1510
1520
  extractOperand() {
1511
1521
  return this.check(
1512
- u.NUMERIC_LITERAL,
1513
- u.STRING_LITERAL,
1514
- u.COLOR_LITERAL,
1515
- u.QUOTED_STRING,
1516
- u.IDENTIFIER
1517
- ) ? this.primaryExpression() : this.check(u.FUNCTION_EXPRESSION) ? this.functionExpression() : this.check(u.LBRACKET) ? this.listExpression() : this.check(u.LBRACE) ? this.blockExpression() : this.check(u.LPAREN) ? this.tupleExpression() : (this.peek().kind === u.EOF ? this.logError(
1522
+ c.NUMERIC_LITERAL,
1523
+ c.STRING_LITERAL,
1524
+ c.COLOR_LITERAL,
1525
+ c.QUOTED_STRING,
1526
+ c.IDENTIFIER
1527
+ ) ? this.primaryExpression() : this.check(c.FUNCTION_EXPRESSION) ? this.functionExpression() : this.check(c.LBRACKET) ? this.listExpression() : this.check(c.LBRACE) ? this.blockExpression() : this.check(c.LPAREN) ? this.tupleExpression() : (this.peek().kind === c.EOF ? this.logError(
1518
1528
  this.peek(),
1519
1529
  o.UNEXPECTED_EOF,
1520
1530
  "Unexpected EOF"
@@ -1528,50 +1538,50 @@ class un {
1528
1538
  functionExpression() {
1529
1539
  const e = {};
1530
1540
  try {
1531
- this.consume("Expect a function expression", u.FUNCTION_EXPRESSION), e.value = this.previous();
1541
+ this.consume("Expect a function expression", c.FUNCTION_EXPRESSION), e.value = this.previous();
1532
1542
  } catch (n) {
1533
1543
  throw n instanceof d ? (e.value = n.partialNode, new d(
1534
1544
  n.token,
1535
- this.nodeFactory.create(K, e),
1545
+ this.nodeFactory.create(ee, e),
1536
1546
  n.handlerContext
1537
1547
  )) : n;
1538
1548
  }
1539
- return this.nodeFactory.create(K, e);
1549
+ return this.nodeFactory.create(ee, e);
1540
1550
  }
1541
1551
  canBeField() {
1542
- return this.peek().kind === u.IDENTIFIER && this.peek(1).kind === u.COLON;
1552
+ return this.peek().kind === c.IDENTIFIER && this.peek(1).kind === c.COLON;
1543
1553
  }
1544
1554
  /* Parsing PrimaryExpression */
1545
1555
  primaryExpression() {
1546
1556
  if (this.match(
1547
- u.COLOR_LITERAL,
1548
- u.STRING_LITERAL,
1549
- u.NUMERIC_LITERAL
1557
+ c.COLOR_LITERAL,
1558
+ c.STRING_LITERAL,
1559
+ c.NUMERIC_LITERAL
1550
1560
  ))
1551
- return this.nodeFactory.create(R, {
1552
- expression: this.nodeFactory.create(pe, { literal: this.previous() })
1561
+ return this.nodeFactory.create(D, {
1562
+ expression: this.nodeFactory.create(Ee, { literal: this.previous() })
1553
1563
  });
1554
- if (this.match(u.QUOTED_STRING, u.IDENTIFIER))
1555
- return this.nodeFactory.create(R, {
1556
- expression: this.nodeFactory.create(W, { variable: this.previous() })
1564
+ if (this.match(c.QUOTED_STRING, c.IDENTIFIER))
1565
+ return this.nodeFactory.create(D, {
1566
+ expression: this.nodeFactory.create(X, { variable: this.previous() })
1557
1567
  });
1558
1568
  throw this.logError(this.peek(), o.UNEXPECTED_TOKEN, "Expect a variable or literal"), new d(
1559
1569
  this.peek(),
1560
- this.nodeFactory.create(R, {
1561
- expression: this.nodeFactory.create(W, {})
1570
+ this.nodeFactory.create(D, {
1571
+ expression: this.nodeFactory.create(X, {})
1562
1572
  }),
1563
1573
  this.contextStack.findHandlerContext(this.tokens, this.current)
1564
1574
  );
1565
1575
  }
1566
1576
  attribute() {
1567
1577
  const e = {};
1568
- if (this.check(u.COLON, u.RBRACKET, u.COMMA)) {
1578
+ if (this.check(c.COLON, c.RBRACKET, c.COMMA)) {
1569
1579
  const n = this.peek();
1570
1580
  this.logError(
1571
1581
  n,
1572
1582
  o.EMPTY_ATTRIBUTE_NAME,
1573
1583
  "Expect a non-empty attribute name"
1574
- ), e.name = this.nodeFactory.create(te, { identifiers: [] });
1584
+ ), e.name = this.nodeFactory.create(K, { identifiers: [] });
1575
1585
  } else
1576
1586
  try {
1577
1587
  e.name = this.attributeName();
@@ -1586,12 +1596,12 @@ class un {
1586
1596
  );
1587
1597
  this.synchronizeAttributeName();
1588
1598
  }
1589
- return this.match(u.COLON) && (e.colon = this.previous(), e.value = this.attributeValue()), this.nodeFactory.create(ne, e);
1599
+ return this.match(c.COLON) && (e.colon = this.previous(), e.value = this.attributeValue()), this.nodeFactory.create(ne, e);
1590
1600
  }
1591
1601
  attributeValue() {
1592
1602
  let e;
1593
1603
  try {
1594
- e = this.peek().kind === u.IDENTIFIER && this.peek(1).kind === u.IDENTIFIER ? this.attributeName() : this.normalExpression();
1604
+ e = this.peek().kind === c.IDENTIFIER && this.peek(1).kind === c.IDENTIFIER ? this.attributeName() : this.normalExpression();
1595
1605
  } catch (n) {
1596
1606
  if (!(n instanceof d) || !this.canHandle(n))
1597
1607
  throw n;
@@ -1601,25 +1611,25 @@ class un {
1601
1611
  }
1602
1612
  attributeName() {
1603
1613
  const e = [];
1604
- if (this.peek().kind !== u.IDENTIFIER)
1614
+ if (this.peek().kind !== c.IDENTIFIER)
1605
1615
  return this.primaryExpression();
1606
- for (; !this.isAtEnd() && !this.check(u.COLON, u.COMMA, u.RBRACKET); )
1616
+ for (; !this.isAtEnd() && !this.check(c.COLON, c.COMMA, c.RBRACKET); )
1607
1617
  try {
1608
- this.consume("Expect an identifier", u.IDENTIFIER), e.push(this.previous());
1618
+ this.consume("Expect an identifier", c.IDENTIFIER), e.push(this.previous());
1609
1619
  } catch (n) {
1610
1620
  throw n instanceof d ? new d(
1611
1621
  n.token,
1612
- this.nodeFactory.create(te, { identifiers: e }),
1622
+ this.nodeFactory.create(K, { identifiers: e }),
1613
1623
  n.handlerContext
1614
1624
  ) : n;
1615
1625
  }
1616
- return this.nodeFactory.create(te, { identifiers: e });
1626
+ return this.nodeFactory.create(K, { identifiers: e });
1617
1627
  }
1618
1628
  logError(e, n, s) {
1619
- this.errors.push(new l(n, s, e));
1629
+ this.errors.push(new u(n, s, e));
1620
1630
  }
1621
1631
  }
1622
- const hn = {
1632
+ const cn = {
1623
1633
  "+": { left: 9, right: 10 },
1624
1634
  "*": { left: 11, right: 12 },
1625
1635
  "-": { left: 9, right: 10 },
@@ -1635,10 +1645,10 @@ const hn = {
1635
1645
  "!=": { left: 4, right: 5 },
1636
1646
  ".": { left: 16, right: 17 }
1637
1647
  };
1638
- function fn(t) {
1639
- return hn[t.value] || { left: null, right: null };
1648
+ function un(t) {
1649
+ return cn[t.value] || { left: null, right: null };
1640
1650
  }
1641
- const pn = {
1651
+ const hn = {
1642
1652
  "+": { left: null, right: 15 },
1643
1653
  "-": { left: null, right: 15 },
1644
1654
  "<": { left: null, right: 15 },
@@ -1646,17 +1656,17 @@ const pn = {
1646
1656
  "<>": { left: null, right: 15 },
1647
1657
  "!": { left: null, right: 15 }
1648
1658
  };
1649
- function dn(t) {
1650
- return pn[t.value] || { left: null, right: null };
1659
+ function fn(t) {
1660
+ return hn[t.value] || { left: null, right: null };
1651
1661
  }
1652
- const En = {
1662
+ const pn = {
1653
1663
  "(": { left: 14, right: null }
1654
1664
  };
1655
- function ut(t) {
1656
- return En[t.value] || { left: null, right: null };
1665
+ function ct(t) {
1666
+ return pn[t.value] || { left: null, right: null };
1657
1667
  }
1658
1668
  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 || {});
1659
- function de(t) {
1669
+ function ge(t) {
1660
1670
  var n;
1661
1671
  const e = (n = t == null ? void 0 : t.type) == null ? void 0 : n.value.toLowerCase();
1662
1672
  switch (e) {
@@ -1667,111 +1677,111 @@ function de(t) {
1667
1677
  case b.Project:
1668
1678
  case b.Ref:
1669
1679
  case b.TableGroup:
1670
- return new S(e);
1680
+ return new O(e);
1671
1681
  default:
1672
1682
  return new A();
1673
1683
  }
1674
1684
  }
1675
- function Ee(t) {
1685
+ function ue(t) {
1676
1686
  if (!He(t))
1677
- return new S([t]);
1678
- const e = Ee(t.leftExpression).unwrap_or(void 0);
1679
- return e ? (e.push(t.rightExpression), new S(e)) : new A();
1687
+ return new O([t]);
1688
+ const e = ue(t.leftExpression).unwrap_or(void 0);
1689
+ return e ? (e.push(t.rightExpression), new O(e)) : new A();
1680
1690
  }
1681
- function C(t) {
1691
+ function W(t) {
1682
1692
  if (t === void 0)
1683
1693
  return new A();
1684
- const e = Ee(t).unwrap_or(void 0);
1694
+ const e = ue(t).unwrap_or(void 0);
1685
1695
  if (!e)
1686
1696
  return new A();
1687
1697
  const n = [];
1688
1698
  for (const s of e) {
1689
- const i = X(s).unwrap_or(void 0);
1699
+ const i = G(s).unwrap_or(void 0);
1690
1700
  if (!i)
1691
1701
  return new A();
1692
1702
  n.push(i);
1693
1703
  }
1694
- return new S(n);
1704
+ return new O(n);
1695
1705
  }
1696
- function ge(t) {
1706
+ function Ie(t) {
1697
1707
  if (t === void 0)
1698
1708
  return new A();
1699
- const e = Ee(t).unwrap_or(void 0);
1709
+ const e = ue(t).unwrap_or(void 0);
1700
1710
  if (!e || e.length === 0)
1701
1711
  return new A();
1702
1712
  const n = [];
1703
1713
  let s;
1704
1714
  if (!M(I.last(e))) {
1705
1715
  const i = e.pop();
1706
- if (xt(i))
1716
+ if (yt(i))
1707
1717
  s = i.elementList.map(
1708
- (r) => G(r).unwrap()
1718
+ (r) => V(r).unwrap()
1709
1719
  );
1710
1720
  else
1711
1721
  return new A();
1712
1722
  }
1713
1723
  for (const i of e) {
1714
- const r = X(i).unwrap_or(void 0);
1724
+ const r = G(i).unwrap_or(void 0);
1715
1725
  if (!r)
1716
1726
  return new A();
1717
1727
  n.push(r);
1718
1728
  }
1719
- return new S({
1729
+ return new O({
1720
1730
  variables: n,
1721
1731
  tupleElements: s
1722
1732
  });
1723
1733
  }
1724
- function X(t) {
1725
- return M(t) ? new S(t.expression.variable.value) : new A();
1734
+ function G(t) {
1735
+ return M(t) ? new O(t.expression.variable.value) : new A();
1726
1736
  }
1727
1737
  function Ge(t) {
1728
- if (ht(t))
1729
- return t instanceof K ? new S({ functional: [t], nonFunctional: [] }) : new S({ functional: [], nonFunctional: [t] });
1730
- if (t instanceof J && t.elementList.every(ht)) {
1738
+ if (ut(t))
1739
+ return t instanceof ee ? new O({ functional: [t], nonFunctional: [] }) : new O({ functional: [], nonFunctional: [t] });
1740
+ if (t instanceof J && t.elementList.every(ut)) {
1731
1741
  const e = t.elementList.filter(
1732
- (s) => s instanceof K
1742
+ (s) => s instanceof ee
1733
1743
  ), n = t.elementList.filter(M);
1734
- return new S({ functional: e, nonFunctional: n });
1744
+ return new O({ functional: e, nonFunctional: n });
1735
1745
  }
1736
1746
  return new A();
1737
1747
  }
1738
- function G(t) {
1748
+ function V(t) {
1739
1749
  var n;
1740
1750
  const e = (n = t == null ? void 0 : t.expression.variable) == null ? void 0 : n.value;
1741
- return e === void 0 ? new A() : new S(e);
1751
+ return e === void 0 ? new A() : new O(e);
1742
1752
  }
1743
- function z(t) {
1744
- return j(t) ? t.expression instanceof W ? new S(t.expression.variable.value) : new S(t.expression.literal.value) : new A();
1753
+ function Y(t) {
1754
+ return $(t) ? t.expression instanceof X ? new O(t.expression.variable.value) : new O(t.expression.literal.value) : new A();
1745
1755
  }
1746
- function Nn(t) {
1756
+ function dn(t) {
1747
1757
  var e;
1748
- return !(t instanceof q) || !yt((e = t.op) == null ? void 0 : e.value) ? !1 : ge(t.leftExpression).and_then(() => ge(t.rightExpression)).unwrap_or(void 0) !== void 0;
1758
+ return !(t instanceof q) || !wt((e = t.op) == null ? void 0 : e.value) ? !1 : Ie(t.leftExpression).and_then(() => Ie(t.rightExpression)).unwrap_or(void 0) !== void 0;
1749
1759
  }
1750
- function mn(t) {
1751
- const e = ge(t.leftExpression), n = ge(t.rightExpression);
1760
+ function En(t) {
1761
+ const e = Ie(t.leftExpression), n = Ie(t.rightExpression);
1752
1762
  if (!e.isOk() || !n.isOk())
1753
1763
  return !1;
1754
1764
  const { tupleElements: s } = e.unwrap(), { tupleElements: i } = n.unwrap();
1755
1765
  return (s == null ? void 0 : s.length) === (i == null ? void 0 : i.length);
1756
1766
  }
1757
- function ht(t) {
1758
- return t instanceof R && t.expression instanceof W || t instanceof K;
1767
+ function ut(t) {
1768
+ return t instanceof D && t.expression instanceof X || t instanceof ee;
1759
1769
  }
1760
- function Tn(t, e) {
1761
- var i, r, a, c;
1770
+ function Nn(t, e) {
1771
+ var i, r, a, l;
1762
1772
  let n = e;
1763
- const s = zt(t);
1773
+ const s = jt(t);
1764
1774
  for (; n; ) {
1765
1775
  if ((r = (i = n.symbol) == null ? void 0 : i.symbolTable) != null && r.has(t))
1766
1776
  return (a = n.symbol.symbolTable) == null ? void 0 : a.get(t);
1767
- if (((c = n.symbol) == null ? void 0 : c.declaration) instanceof F && s)
1777
+ if (((l = n.symbol) == null ? void 0 : l.declaration) instanceof C && s)
1768
1778
  return n.symbol;
1769
- if (n instanceof F)
1779
+ if (n instanceof C)
1770
1780
  return;
1771
1781
  n = n.parent;
1772
1782
  }
1773
1783
  }
1774
- class bn {
1784
+ class mn {
1775
1785
  constructor(e, n, s) {
1776
1786
  this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
1777
1787
  }
@@ -1779,27 +1789,27 @@ class bn {
1779
1789
  return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
1780
1790
  }
1781
1791
  validateContext() {
1782
- return this.declarationNode.parent instanceof F || de(this.declarationNode.parent).unwrap_or(void 0) !== b.Project ? [new l(o.INVALID_CUSTOM_CONTEXT, "A custom element can only appear in a Project", this.declarationNode)] : [];
1792
+ return this.declarationNode.parent instanceof C || ge(this.declarationNode.parent).unwrap_or(void 0) !== b.Project ? [new u(o.INVALID_CUSTOM_CONTEXT, "A custom element can only appear in a Project", this.declarationNode)] : [];
1783
1793
  }
1784
1794
  validateName(e) {
1785
- return e ? [new l(o.UNEXPECTED_NAME, "A Custom element shouldn't have a name", e)] : [];
1795
+ return e ? [new u(o.UNEXPECTED_NAME, "A Custom element shouldn't have a name", e)] : [];
1786
1796
  }
1787
1797
  validateAlias(e) {
1788
- return e ? [new l(o.UNEXPECTED_NAME, "A Custom element shouldn't have an alias", e)] : [];
1798
+ return e ? [new u(o.UNEXPECTED_NAME, "A Custom element shouldn't have an alias", e)] : [];
1789
1799
  }
1790
1800
  validateSettingList(e) {
1791
- return e ? [new l(o.UNEXPECTED_SETTINGS, "A Custom element shouldn't have a setting list", e)] : [];
1801
+ return e ? [new u(o.UNEXPECTED_SETTINGS, "A Custom element shouldn't have a setting list", e)] : [];
1792
1802
  }
1793
1803
  validateBody(e) {
1794
1804
  if (!e)
1795
1805
  return [];
1796
- if (e instanceof ee)
1797
- return [new l(o.UNEXPECTED_COMPLEX_BODY, "A Custom element can only have an inline field", e)];
1806
+ if (e instanceof te)
1807
+ return [new u(o.UNEXPECTED_COMPLEX_BODY, "A Custom element can only have an inline field", e)];
1798
1808
  const n = [];
1799
- return j(e.callee) || n.push(new l(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 l(o.INVALID_CUSTOM_ELEMENT_VALUE, "A Custom element value can only be a string", s))), n;
1809
+ return $(e.callee) || n.push(new u(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 u(o.INVALID_CUSTOM_ELEMENT_VALUE, "A Custom element value can only be a string", s))), n;
1800
1810
  }
1801
1811
  }
1802
- class Ae {
1812
+ class _e {
1803
1813
  constructor() {
1804
1814
  this.table = /* @__PURE__ */ new Map();
1805
1815
  }
@@ -1816,7 +1826,7 @@ class Ae {
1816
1826
  return this.table.entries();
1817
1827
  }
1818
1828
  }
1819
- class In {
1829
+ class Tn {
1820
1830
  constructor(e, n, s) {
1821
1831
  this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
1822
1832
  }
@@ -1824,53 +1834,55 @@ class In {
1824
1834
  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)];
1825
1835
  }
1826
1836
  validateContext() {
1827
- return this.declarationNode.parent instanceof _ ? [new l(o.INVALID_PROJECT_CONTEXT, "An Enum can only appear top-level", this.declarationNode)] : [];
1837
+ return this.declarationNode.parent instanceof _ ? [new u(o.INVALID_PROJECT_CONTEXT, "An Enum can only appear top-level", this.declarationNode)] : [];
1828
1838
  }
1829
1839
  validateName(e) {
1830
- return e ? Je(e) ? [] : [new l(o.INVALID_NAME, "An Enum name must be of the form <enum> or <schema>.<enum>", e)] : [new l(o.NAME_NOT_FOUND, "An Enum must have a name", this.declarationNode)];
1840
+ return e ? Je(e) ? [] : [new u(o.INVALID_NAME, "An Enum name must be of the form <enum> or <schema>.<enum>", e)] : [new u(o.NAME_NOT_FOUND, "An Enum must have a name", this.declarationNode)];
1831
1841
  }
1832
1842
  validateAlias(e) {
1833
- return e ? [new l(o.UNEXPECTED_ALIAS, "A Ref shouldn't have an alias", e)] : [];
1843
+ return e ? [new u(o.UNEXPECTED_ALIAS, "A Ref shouldn't have an alias", e)] : [];
1834
1844
  }
1835
1845
  registerElement() {
1836
1846
  const e = [];
1837
- this.declarationNode.symbol = this.symbolFactory.create(Jt, { declaration: this.declarationNode, symbolTable: new Ae() });
1838
- const { name: n } = this.declarationNode, s = C(n);
1847
+ this.declarationNode.symbol = this.symbolFactory.create(qt, { declaration: this.declarationNode, symbolTable: new _e() });
1848
+ const { name: n } = this.declarationNode, s = W(n);
1839
1849
  if (s.isOk()) {
1840
- const i = s.unwrap(), r = i.pop(), a = Ze(i, this.publicSymbolTable, this.symbolFactory), c = je(r);
1841
- a.has(c) && e.push(new l(o.DUPLICATE_NAME, `Enum name ${r} already exists in schema '${i.join(".") || "public"}'`, n)), a.set(c, this.declarationNode.symbol);
1850
+ const i = s.unwrap(), r = i.pop(), a = Ze(i, this.publicSymbolTable, this.symbolFactory), l = je(r);
1851
+ a.has(l) && e.push(new u(o.DUPLICATE_NAME, `Enum name ${r} already exists in schema '${i.join(".") || "public"}'`, n)), a.set(l, this.declarationNode.symbol);
1842
1852
  }
1843
1853
  return e;
1844
1854
  }
1845
1855
  validateSettingList(e) {
1846
- return e ? [new l(o.UNEXPECTED_SETTINGS, "An Enum shouldn't have a setting list", e)] : [];
1856
+ return e ? [new u(o.UNEXPECTED_SETTINGS, "An Enum shouldn't have a setting list", e)] : [];
1847
1857
  }
1848
1858
  validateBody(e) {
1849
1859
  if (!e)
1850
1860
  return [];
1851
- if (e instanceof v)
1861
+ if (e instanceof k)
1852
1862
  return this.validateFields([e]);
1853
- const [n, s] = I.partition(e.body, (i) => i instanceof v);
1863
+ const [n, s] = I.partition(e.body, (i) => i instanceof k);
1854
1864
  return [...this.validateFields(n), ...this.validateSubElements(s)];
1855
1865
  }
1856
1866
  validateFields(e) {
1857
- return e.length === 0 ? [new l(o.EMPTY_ENUM, "An Enum must have at least one element", this.declarationNode)] : e.flatMap((n) => {
1867
+ return e.length === 0 ? [new u(o.EMPTY_ENUM, "An Enum must have at least one element", this.declarationNode)] : e.flatMap((n) => {
1858
1868
  const s = [];
1859
- return n.callee && !M(n.callee) && s.push(new l(o.INVALID_COLUMN_NAME, "A column name must be an identifier or a quoted identifier", n.callee)), I.last(n.args) instanceof U && s.push(...this.validateFieldSetting(I.last(n.args))), n.args.length > 1 && s.push(...n.args.map((i) => new l(o.INVALID_ENUM_ELEMENT, "An Enum must have only a field and optionally a setting list", i))), s.push(...this.registerField(n)), s;
1869
+ n.callee && !M(n.callee) && s.push(new u(o.INVALID_ENUM_ELEMENT_NAME, "An enum field must be an identifier or a quoted identifier", n.callee));
1870
+ const i = [...n.args];
1871
+ 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 u(o.INVALID_ENUM_ELEMENT, "An Enum must have only a field and optionally a setting list", r))), s.push(...this.registerField(n)), s;
1860
1872
  });
1861
1873
  }
1862
- validateFieldSetting(e) {
1863
- const n = $(e), s = n.getErrors(), i = n.getValue();
1874
+ validateFieldSettings(e) {
1875
+ const n = z(e), s = n.getErrors(), i = n.getValue();
1864
1876
  for (const r in i) {
1865
1877
  const a = i[r];
1866
1878
  switch (r) {
1867
1879
  case "note":
1868
- a.length > 1 && a.forEach((c) => s.push(new l(o.DUPLICATE_ENUM_ELEMENT_SETTING, "'note' can only appear once", c))), a.forEach((c) => {
1869
- j(c.value) || s.push(new l(o.INVALID_ENUM_ELEMENT_SETTING, "'note' must be a string", c));
1880
+ a.length > 1 && a.forEach((l) => s.push(new u(o.DUPLICATE_ENUM_ELEMENT_SETTING, "'note' can only appear once", l))), a.forEach((l) => {
1881
+ $(l.value) || s.push(new u(o.INVALID_ENUM_ELEMENT_SETTING, "'note' must be a string", l));
1870
1882
  });
1871
1883
  break;
1872
1884
  default:
1873
- a.forEach((c) => s.push(new l(o.UNKNOWN_ENUM_ELEMENT_SETTING, `Unknown enum field setting '${r}'`, c)));
1885
+ a.forEach((l) => s.push(new u(o.UNKNOWN_ENUM_ELEMENT_SETTING, `Unknown enum field setting '${r}'`, l)));
1874
1886
  }
1875
1887
  }
1876
1888
  return s;
@@ -1885,14 +1897,14 @@ class In {
1885
1897
  }
1886
1898
  registerField(e) {
1887
1899
  if (e.callee && M(e.callee)) {
1888
- const n = G(e.callee).unwrap(), s = Ye(n), i = this.symbolFactory.create(Zt, { declaration: e });
1900
+ const n = V(e.callee).unwrap(), s = Ye(n), i = this.symbolFactory.create(Ht, { declaration: e });
1889
1901
  e.symbol = i;
1890
1902
  const r = this.declarationNode.symbol.symbolTable;
1891
1903
  if (r.has(s)) {
1892
1904
  const a = r.get(s);
1893
1905
  return [
1894
- new l(o.DUPLICATE_COLUMN_NAME, `Duplicate enum field ${n}`, e),
1895
- new l(o.DUPLICATE_COLUMN_NAME, `Duplicate enum field ${n}`, a.declaration)
1906
+ new u(o.DUPLICATE_COLUMN_NAME, `Duplicate enum field ${n}`, e),
1907
+ new u(o.DUPLICATE_COLUMN_NAME, `Duplicate enum field ${n}`, a.declaration)
1896
1908
  ];
1897
1909
  }
1898
1910
  r.set(s, i);
@@ -1900,7 +1912,7 @@ class In {
1900
1912
  return [];
1901
1913
  }
1902
1914
  }
1903
- class Ln {
1915
+ class bn {
1904
1916
  constructor(e, n, s) {
1905
1917
  this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
1906
1918
  }
@@ -1908,23 +1920,23 @@ class Ln {
1908
1920
  return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
1909
1921
  }
1910
1922
  validateContext() {
1911
- return this.declarationNode.parent instanceof F || de(this.declarationNode.parent).unwrap_or(void 0) !== b.Table ? [new l(o.INVALID_NOTE_CONTEXT, "An Indexes can only appear inside a Table", this.declarationNode)] : [];
1923
+ return this.declarationNode.parent instanceof C || ge(this.declarationNode.parent).unwrap_or(void 0) !== b.Table ? [new u(o.INVALID_NOTE_CONTEXT, "An Indexes can only appear inside a Table", this.declarationNode)] : [];
1912
1924
  }
1913
1925
  validateName(e) {
1914
- return e ? [new l(o.UNEXPECTED_NAME, "An Indexes shouldn't have a name", e)] : [];
1926
+ return e ? [new u(o.UNEXPECTED_NAME, "An Indexes shouldn't have a name", e)] : [];
1915
1927
  }
1916
1928
  validateAlias(e) {
1917
- return e ? [new l(o.UNEXPECTED_ALIAS, "An Indexes shouldn't have an alias", e)] : [];
1929
+ return e ? [new u(o.UNEXPECTED_ALIAS, "An Indexes shouldn't have an alias", e)] : [];
1918
1930
  }
1919
1931
  validateSettingList(e) {
1920
- return e ? [new l(o.UNEXPECTED_SETTINGS, "An Indexes shouldn't have a setting list", e)] : [];
1932
+ return e ? [new u(o.UNEXPECTED_SETTINGS, "An Indexes shouldn't have a setting list", e)] : [];
1921
1933
  }
1922
1934
  validateBody(e) {
1923
1935
  if (!e)
1924
1936
  return [];
1925
- if (e instanceof v)
1926
- return [new l(o.UNEXPECTED_SIMPLE_BODY, "An Indexes must have a complex body", e)];
1927
- const [n, s] = I.partition(e.body, (i) => i instanceof v);
1937
+ if (e instanceof k)
1938
+ return [new u(o.UNEXPECTED_SIMPLE_BODY, "An Indexes must have a complex body", e)];
1939
+ const [n, s] = I.partition(e.body, (i) => i instanceof k);
1928
1940
  return [...this.validateFields(n), ...this.validateSubElements(s)];
1929
1941
  }
1930
1942
  validateFields(e) {
@@ -1932,37 +1944,37 @@ class Ln {
1932
1944
  if (!n.callee)
1933
1945
  return [];
1934
1946
  const s = [], i = [n.callee, ...n.args];
1935
- return I.last(i) instanceof U && s.push(...this.validateFieldSetting(i.pop())), i.forEach((r) => {
1947
+ return I.last(i) instanceof P && s.push(...this.validateFieldSetting(i.pop())), i.forEach((r) => {
1936
1948
  for (; r instanceof H; )
1937
- r.argumentList && !Ge(r.argumentList).isOk() && s.push(new l(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;
1938
- Ge(r).isOk() || s.push(new l(o.INVALID_INDEXES_FIELD, "An index field must be an identifier, a quoted identifier, a functional expression or a tuple of such", r));
1949
+ r.argumentList && !Ge(r.argumentList).isOk() && s.push(new u(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;
1950
+ Ge(r).isOk() || s.push(new u(o.INVALID_INDEXES_FIELD, "An index field must be an identifier, a quoted identifier, a functional expression or a tuple of such", r));
1939
1951
  }), s;
1940
1952
  });
1941
1953
  }
1942
1954
  validateFieldSetting(e) {
1943
- const n = $(e), s = n.getErrors(), i = n.getValue();
1955
+ const n = z(e), s = n.getErrors(), i = n.getValue();
1944
1956
  for (const r in i) {
1945
1957
  const a = i[r];
1946
1958
  switch (r) {
1947
1959
  case "note":
1948
1960
  case "name":
1949
- a.length > 1 && a.forEach((c) => s.push(new l(o.DUPLICATE_INDEX_SETTING, `'${r}' can only appear once`, c))), a.forEach((c) => {
1950
- j(c.value) || s.push(new l(o.INVALID_INDEX_SETTING_VALUE, `'${r}' must be a string`, c));
1961
+ a.length > 1 && a.forEach((l) => s.push(new u(o.DUPLICATE_INDEX_SETTING, `'${r}' can only appear once`, l))), a.forEach((l) => {
1962
+ $(l.value) || s.push(new u(o.INVALID_INDEX_SETTING_VALUE, `'${r}' must be a string`, l));
1951
1963
  });
1952
1964
  break;
1953
1965
  case "unique":
1954
1966
  case "pk":
1955
- a.length > 1 && a.forEach((c) => s.push(new l(o.DUPLICATE_INDEX_SETTING, `'${r}' can only appear once`, c))), a.forEach((c) => {
1956
- oe(c.value) || s.push(new l(o.INVALID_INDEX_SETTING_VALUE, `'${r}' must not have a value`, c));
1967
+ a.length > 1 && a.forEach((l) => s.push(new u(o.DUPLICATE_INDEX_SETTING, `'${r}' can only appear once`, l))), a.forEach((l) => {
1968
+ oe(l.value) || s.push(new u(o.INVALID_INDEX_SETTING_VALUE, `'${r}' must not have a value`, l));
1957
1969
  });
1958
1970
  break;
1959
1971
  case "type":
1960
- a.length > 1 && a.forEach((c) => s.push(new l(o.DUPLICATE_INDEX_SETTING, "'type' can only appear once", c))), a.forEach((c) => {
1961
- M(c.value) || s.push(new l(o.INVALID_INDEX_SETTING_VALUE, `'type' must be "btree" or "hash"`, c));
1972
+ a.length > 1 && a.forEach((l) => s.push(new u(o.DUPLICATE_INDEX_SETTING, "'type' can only appear once", l))), a.forEach((l) => {
1973
+ M(l.value) || s.push(new u(o.INVALID_INDEX_SETTING_VALUE, `'type' must be "btree" or "hash"`, l));
1962
1974
  });
1963
1975
  break;
1964
1976
  default:
1965
- a.forEach((c) => s.push(new l(o.UNKNOWN_INDEX_SETTING, `Unknown index setting '${r}'`, c)));
1977
+ a.forEach((l) => s.push(new u(o.UNKNOWN_INDEX_SETTING, `Unknown index setting '${r}'`, l)));
1966
1978
  }
1967
1979
  }
1968
1980
  return s;
@@ -1976,7 +1988,7 @@ class Ln {
1976
1988
  });
1977
1989
  }
1978
1990
  }
1979
- class gn {
1991
+ class In {
1980
1992
  constructor(e, n, s) {
1981
1993
  this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
1982
1994
  }
@@ -1984,36 +1996,28 @@ class gn {
1984
1996
  return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
1985
1997
  }
1986
1998
  validateContext() {
1987
- return !(this.declarationNode.parent instanceof F) && ![b.Table, b.Project].includes(de(this.declarationNode.parent).unwrap_or(void 0)) ? [new l(o.INVALID_NOTE_CONTEXT, "A Note can only appear inside a Table or a Project. Sticky note can only appear at the global scope.", this.declarationNode)] : [];
1999
+ return this.declarationNode.parent instanceof C || ![b.Table, b.Project].includes(ge(this.declarationNode.parent).unwrap_or(void 0)) ? [new u(o.INVALID_NOTE_CONTEXT, "A Note can only appear inside a Table or a Project", this.declarationNode)] : [];
1988
2000
  }
1989
2001
  validateName(e) {
1990
- if (!(this.declarationNode.parent instanceof F))
1991
- return e ? [new l(o.UNEXPECTED_NAME, "A Note shouldn't have a name", e)] : [];
1992
- if (!e)
1993
- return [new l(o.INVALID_NAME, "Sticky note must have a name", this.declarationNode)];
1994
- const n = C(e);
1995
- if (!n.isOk())
1996
- return [];
1997
- const i = n.unwrap().join("."), r = Yt(i);
1998
- return this.publicSymbolTable.has(r) ? [new l(o.DUPLICATE_NAME, `Sticky note "${i}" has already been defined`, e)] : (this.publicSymbolTable.set(r, this.declarationNode.symbol), []);
2002
+ return e ? [new u(o.UNEXPECTED_NAME, "A Note shouldn't have a name", e)] : [];
1999
2003
  }
2000
2004
  validateAlias(e) {
2001
- return e ? [new l(o.UNEXPECTED_ALIAS, "A Ref shouldn't have an alias", e)] : [];
2005
+ return e ? [new u(o.UNEXPECTED_ALIAS, "A Ref shouldn't have an alias", e)] : [];
2002
2006
  }
2003
2007
  validateSettingList(e) {
2004
- return e && !(this.declarationNode.parent instanceof F) ? [new l(o.UNEXPECTED_SETTINGS, "A Note shouldn't have a setting list", e)] : [];
2008
+ return e ? [new u(o.UNEXPECTED_SETTINGS, "A Note shouldn't have a setting list", e)] : [];
2005
2009
  }
2006
2010
  validateBody(e) {
2007
2011
  if (!e)
2008
2012
  return [];
2009
- if (e instanceof v)
2013
+ if (e instanceof k)
2010
2014
  return this.validateFields([e]);
2011
- const [n, s] = I.partition(e.body, (i) => i instanceof v);
2015
+ const [n, s] = I.partition(e.body, (i) => i instanceof k);
2012
2016
  return [...this.validateFields(n), ...this.validateSubElements(s)];
2013
2017
  }
2014
2018
  validateFields(e) {
2015
2019
  const n = [];
2016
- return e.length === 0 ? [new l(o.EMPTY_NOTE, "A Note must have a content", this.declarationNode)] : (e.length > 1 && e.slice(1).forEach((s) => n.push(new l(o.NOTE_CONTENT_REDEFINED, "A Note can only contain one string", s))), j(e[0].callee) || n.push(new l(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 l(o.INVALID_NOTE, "A Note can only contain one quoted string", s))), n);
2020
+ return e.length === 0 ? [new u(o.EMPTY_NOTE, "A Note must have a content", this.declarationNode)] : (e.length > 1 && e.slice(1).forEach((s) => n.push(new u(o.NOTE_CONTENT_REDEFINED, "A Note can only contain one string", s))), $(e[0].callee) || n.push(new u(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 u(o.INVALID_NOTE, "A Note can only contain one quoted string", s))), n);
2017
2021
  }
2018
2022
  validateSubElements(e) {
2019
2023
  return e.flatMap((n) => {
@@ -2024,7 +2028,7 @@ class gn {
2024
2028
  });
2025
2029
  }
2026
2030
  }
2027
- class _n {
2031
+ class Ln {
2028
2032
  constructor(e, n, s) {
2029
2033
  this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
2030
2034
  }
@@ -2032,25 +2036,25 @@ class _n {
2032
2036
  return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
2033
2037
  }
2034
2038
  validateContext() {
2035
- return this.declarationNode.parent instanceof _ ? [new l(o.INVALID_PROJECT_CONTEXT, "A Project can only appear top-level", this.declarationNode)] : [];
2039
+ return this.declarationNode.parent instanceof _ ? [new u(o.INVALID_PROJECT_CONTEXT, "A Project can only appear top-level", this.declarationNode)] : [];
2036
2040
  }
2037
2041
  validateName(e) {
2038
- return e ? Pe(e) ? [] : [new l(o.INVALID_NAME, "A Project's name is optional or must be an identifier or a quoted identifer", e)] : [];
2042
+ return e ? Pe(e) ? [] : [new u(o.INVALID_NAME, "A Project's name is optional or must be an identifier or a quoted identifer", e)] : [];
2039
2043
  }
2040
2044
  validateAlias(e) {
2041
- return e ? [new l(o.UNEXPECTED_ALIAS, "A Project shouldn't have an alias", e)] : [];
2045
+ return e ? [new u(o.UNEXPECTED_ALIAS, "A Project shouldn't have an alias", e)] : [];
2042
2046
  }
2043
2047
  validateSettingList(e) {
2044
- return e ? [new l(o.UNEXPECTED_SETTINGS, "A Project shouldn't have a setting list", e)] : [];
2048
+ return e ? [new u(o.UNEXPECTED_SETTINGS, "A Project shouldn't have a setting list", e)] : [];
2045
2049
  }
2046
2050
  validateBody(e) {
2047
2051
  if (!e)
2048
2052
  return [];
2049
- if (e instanceof v)
2050
- return [new l(o.UNEXPECTED_SIMPLE_BODY, "A Project's body must be a block", e)];
2051
- const [n, s] = I.partition(e.body, (i) => i instanceof v);
2053
+ if (e instanceof k)
2054
+ return [new u(o.UNEXPECTED_SIMPLE_BODY, "A Project's body must be a block", e)];
2055
+ const [n, s] = I.partition(e.body, (i) => i instanceof k);
2052
2056
  return [
2053
- ...n.map((i) => new l(o.INVALID_PROJECT_FIELD, "A Project can not have inline fields", i)),
2057
+ ...n.map((i) => new u(o.INVALID_PROJECT_FIELD, "A Project can not have inline fields", i)),
2054
2058
  ...this.validateSubElements(s)
2055
2059
  ];
2056
2060
  }
@@ -2063,7 +2067,7 @@ class _n {
2063
2067
  });
2064
2068
  }
2065
2069
  }
2066
- class An {
2070
+ class gn {
2067
2071
  constructor(e, n, s) {
2068
2072
  this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
2069
2073
  }
@@ -2071,46 +2075,48 @@ class An {
2071
2075
  return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
2072
2076
  }
2073
2077
  validateContext() {
2074
- return this.declarationNode.parent instanceof F || de(this.declarationNode.parent).unwrap_or(void 0) === b.Table ? [] : [new l(o.INVALID_REF_CONTEXT, "A Ref must appear top-level or inside a table", this.declarationNode)];
2078
+ return this.declarationNode.parent instanceof C ? [] : [new u(o.INVALID_REF_CONTEXT, "A Ref must appear top-level", this.declarationNode)];
2075
2079
  }
2076
2080
  validateName(e) {
2077
- return e ? Pe(e) ? [] : [new l(o.INVALID_NAME, "A Ref's name is optional or must be an identifier or a quoted identifer", e)] : [];
2081
+ return e ? Pe(e) ? [] : [new u(o.INVALID_NAME, "A Ref's name is optional or must be an identifier or a quoted identifer", e)] : [];
2078
2082
  }
2079
2083
  validateAlias(e) {
2080
- return e ? [new l(o.UNEXPECTED_ALIAS, "A Ref shouldn't have an alias", e)] : [];
2084
+ return e ? [new u(o.UNEXPECTED_ALIAS, "A Ref shouldn't have an alias", e)] : [];
2081
2085
  }
2082
2086
  validateSettingList(e) {
2083
- return e ? [new l(o.UNEXPECTED_SETTINGS, "A Ref shouldn't have a setting list", e)] : [];
2087
+ return e ? [new u(o.UNEXPECTED_SETTINGS, "A Ref shouldn't have a setting list", e)] : [];
2084
2088
  }
2085
2089
  validateBody(e) {
2086
2090
  if (!e)
2087
2091
  return [];
2088
- if (e instanceof v)
2092
+ if (e instanceof k)
2089
2093
  return this.validateFields([e]);
2090
- const [n, s] = I.partition(e.body, (i) => i instanceof v);
2094
+ const [n, s] = I.partition(e.body, (i) => i instanceof k);
2091
2095
  return [...this.validateFields(n), ...this.validateSubElements(s)];
2092
2096
  }
2093
2097
  validateFields(e) {
2094
2098
  if (e.length === 0)
2095
- return [new l(o.EMPTY_REF, "A Ref must have at least one field", this.declarationNode)];
2099
+ return [new u(o.EMPTY_REF, "A Ref must have at least one field", this.declarationNode)];
2096
2100
  const n = [];
2097
- return e.length > 1 && n.push(...e.slice(1).map((s) => new l(o.REF_REDEFINED, "A Ref can only contain one binary relationship", s))), e.forEach((s) => {
2098
- s.callee && !Nn(s.callee) && n.push(new l(o.INVALID_REF_FIELD, "A Ref field must be a binary relationship", s.callee)), s.callee && !mn(s.callee) && n.push(new l(o.UNEQUAL_FIELDS_BINARY_REF, "Unequal fields in ref endpoints", s.callee)), I.last(s.args) instanceof U && this.validateFieldSettings(I.last(s.args)), s.args.length > 1 && n.push(...s.args.map((i) => new l(o.INVALID_REF_FIELD, "A Ref field should only have a single binary relationship", i)));
2101
+ return e.length > 1 && n.push(...e.slice(1).map((s) => new u(o.REF_REDEFINED, "A Ref can only contain one binary relationship", s))), e.forEach((s) => {
2102
+ s.callee && !dn(s.callee) && n.push(new u(o.INVALID_REF_FIELD, "A Ref field must be a binary relationship", s.callee)), s.callee && !En(s.callee) && n.push(new u(o.UNEQUAL_FIELDS_BINARY_REF, "Unequal fields in ref endpoints", s.callee));
2103
+ const i = [...s.args];
2104
+ 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 u(o.INVALID_REF_FIELD, "A Ref field should only have a single binary relationship", r)));
2099
2105
  }), n;
2100
2106
  }
2101
2107
  validateFieldSettings(e) {
2102
- const n = $(e), s = n.getErrors(), i = n.getValue();
2108
+ const n = z(e), s = n.getErrors(), i = n.getValue();
2103
2109
  for (const r in i) {
2104
2110
  const a = i[r];
2105
2111
  switch (r) {
2106
2112
  case "delete":
2107
2113
  case "update":
2108
- a.length > 1 && a.forEach((c) => s.push(new l(o.DUPLICATE_REF_SETTING, `'${r}' can only appear once`, c))), a.forEach((c) => {
2109
- vn(c.value) || s.push(new l(o.INVALID_REF_SETTING_VALUE, `'${r}' can only have values "cascade", "no action", "set null", "set default" or "restrict"`, c));
2114
+ a.length > 1 && a.forEach((l) => s.push(new u(o.DUPLICATE_REF_SETTING, `'${r}' can only appear once`, l))), a.forEach((l) => {
2115
+ _n(l.value) || s.push(new u(o.INVALID_REF_SETTING_VALUE, `'${r}' can only have values "cascade", "no action", "set null", "set default" or "restrict"`, l));
2110
2116
  });
2111
2117
  break;
2112
2118
  default:
2113
- a.forEach((c) => s.push(new l(o.UNKNOWN_REF_SETTING, `Unknown ref setting '${r}'`, c)));
2119
+ a.forEach((l) => s.push(new u(o.UNKNOWN_REF_SETTING, `Unknown ref setting '${r}'`, l)));
2114
2120
  }
2115
2121
  }
2116
2122
  return s;
@@ -2124,11 +2130,11 @@ class An {
2124
2130
  });
2125
2131
  }
2126
2132
  }
2127
- function vn(t) {
2128
- if (!(M(t) && t.expression.variable.kind !== u.QUOTED_STRING) && !(t instanceof te))
2133
+ function _n(t) {
2134
+ if (!(M(t) && t.expression.variable.kind !== c.QUOTED_STRING) && !(t instanceof K))
2129
2135
  return !1;
2130
2136
  let e;
2131
- if (t instanceof te ? e = Re(t).unwrap_or("") : e = t.expression.variable.value, e)
2137
+ if (t instanceof K ? e = De(t).unwrap_or("") : e = t.expression.variable.value, e)
2132
2138
  switch (e.toLowerCase()) {
2133
2139
  case "cascade":
2134
2140
  case "no action":
@@ -2141,7 +2147,7 @@ function vn(t) {
2141
2147
  }
2142
2148
  return !1;
2143
2149
  }
2144
- class wn {
2150
+ class An {
2145
2151
  constructor(e, n, s) {
2146
2152
  this.declarationNode = e, this.symbolFactory = s, this.publicSymbolTable = n;
2147
2153
  }
@@ -2149,77 +2155,77 @@ class wn {
2149
2155
  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)];
2150
2156
  }
2151
2157
  validateContext() {
2152
- return this.declarationNode.parent instanceof _ ? [new l(o.INVALID_TABLE_CONTEXT, "Table must appear top-level", this.declarationNode)] : [];
2158
+ return this.declarationNode.parent instanceof _ ? [new u(o.INVALID_TABLE_CONTEXT, "Table must appear top-level", this.declarationNode)] : [];
2153
2159
  }
2154
2160
  validateName(e) {
2155
- return e ? e instanceof he ? [new l(o.INVALID_NAME, "Invalid array as Table name, maybe you forget to add a space between the name and the setting list?", e)] : Je(e) ? [] : [new l(o.INVALID_NAME, "A Table name must be of the form <table> or <schema>.<table>", e)] : [new l(o.NAME_NOT_FOUND, "A Table must have a name", this.declarationNode)];
2161
+ return e ? e instanceof le ? [new u(o.INVALID_NAME, "Invalid array as Table name, maybe you forget to add a space between the name and the setting list?", e)] : Je(e) ? [] : [new u(o.INVALID_NAME, "A Table name must be of the form <table> or <schema>.<table>", e)] : [new u(o.NAME_NOT_FOUND, "A Table must have a name", this.declarationNode)];
2156
2162
  }
2157
2163
  validateAlias(e) {
2158
- return e ? Sn(e) ? [] : [new l(o.INVALID_ALIAS, "Table aliases can only contains alphanumeric and underscore unless surrounded by double quotes", e)] : [];
2164
+ return e ? kn(e) ? [] : [new u(o.INVALID_ALIAS, "Table aliases can only contains alphanumeric and underscore unless surrounded by double quotes", e)] : [];
2159
2165
  }
2160
2166
  validateSettingList(e) {
2161
- const n = $(e), s = n.getErrors(), i = n.getValue();
2167
+ const n = z(e), s = n.getErrors(), i = n.getValue();
2162
2168
  for (const r in i) {
2163
2169
  const a = i[r];
2164
2170
  switch (r) {
2165
2171
  case "headercolor":
2166
- a.length > 1 && s.push(...a.map((c) => new l(o.DUPLICATE_TABLE_SETTING, "'headercolor' can only appear once", c))), a.forEach((c) => {
2167
- On(c.value) || s.push(new l(o.INVALID_TABLE_SETTING, "'headercolor' must be a color literal", c.value || c.name));
2172
+ a.length > 1 && s.push(...a.map((l) => new u(o.DUPLICATE_TABLE_SETTING, "'headercolor' can only appear once", l))), a.forEach((l) => {
2173
+ xn(l.value) || s.push(new u(o.INVALID_TABLE_SETTING, "'headercolor' must be a color literal", l.value || l.name));
2168
2174
  });
2169
2175
  break;
2170
2176
  case "note":
2171
- a.length > 1 && s.push(...a.map((c) => new l(o.DUPLICATE_TABLE_SETTING, "'note' can only appear once", c))), a.forEach((c) => {
2172
- j(c.value) || s.push(new l(o.INVALID_TABLE_SETTING, "'note' must be a string literal", c.value || c.name));
2177
+ a.length > 1 && s.push(...a.map((l) => new u(o.DUPLICATE_TABLE_SETTING, "'note' can only appear once", l))), a.forEach((l) => {
2178
+ $(l.value) || s.push(new u(o.INVALID_TABLE_SETTING, "'note' must be a string literal", l.value || l.name));
2173
2179
  });
2174
2180
  break;
2175
2181
  default:
2176
- s.push(...a.map((c) => new l(o.INVALID_TABLE_SETTING, `Unknown '${r}' setting`, c)));
2182
+ s.push(...a.map((l) => new u(o.INVALID_TABLE_SETTING, `Unknown '${r}' setting`, l)));
2177
2183
  }
2178
2184
  }
2179
2185
  return s;
2180
2186
  }
2181
2187
  registerElement() {
2182
2188
  const e = [];
2183
- this.declarationNode.symbol = this.symbolFactory.create(At, { declaration: this.declarationNode, symbolTable: new Ae() });
2184
- const { name: n, alias: s } = this.declarationNode, i = C(n);
2189
+ this.declarationNode.symbol = this.symbolFactory.create(_t, { declaration: this.declarationNode, symbolTable: new _e() });
2190
+ const { name: n, alias: s } = this.declarationNode, i = W(n);
2185
2191
  if (i.isOk()) {
2186
- const r = [...i.unwrap()], a = r.pop(), c = Ze(r, this.publicSymbolTable, this.symbolFactory), p = xe(a);
2187
- c.has(p) && e.push(new l(o.DUPLICATE_NAME, `Table name '${a}' already exists in schema '${r.join(".") || "public"}'`, n)), c.set(p, this.declarationNode.symbol);
2192
+ const r = [...i.unwrap()], a = r.pop(), l = Ze(r, this.publicSymbolTable, this.symbolFactory), p = ke(a);
2193
+ l.has(p) && e.push(new u(o.DUPLICATE_NAME, `Table name '${a}' already exists in schema '${r.join(".") || "public"}'`, n)), l.set(p, this.declarationNode.symbol);
2188
2194
  }
2189
- if (s && Pe(s) && !xn(s.expression.variable.value, i.unwrap_or([]))) {
2190
- const r = G(s).unwrap(), a = xe(r);
2191
- this.publicSymbolTable.has(a) && e.push(new l(o.DUPLICATE_NAME, `Table name '${r}' already exists`, n)), this.publicSymbolTable.set(a, this.declarationNode.symbol);
2195
+ if (s && Pe(s) && !wn(s.expression.variable.value, i.unwrap_or([]))) {
2196
+ const r = V(s).unwrap(), a = ke(r);
2197
+ this.publicSymbolTable.has(a) && e.push(new u(o.DUPLICATE_NAME, `Table name '${r}' already exists`, n)), this.publicSymbolTable.set(a, this.declarationNode.symbol);
2192
2198
  }
2193
2199
  return e;
2194
2200
  }
2195
2201
  validateBody(e) {
2196
2202
  if (!e)
2197
2203
  return [];
2198
- if (e instanceof v)
2199
- return [new l(o.UNEXPECTED_SIMPLE_BODY, "A Table's body must be a block", e)];
2200
- const [n, s] = I.partition(e.body, (i) => i instanceof v);
2204
+ if (e instanceof k)
2205
+ return [new u(o.UNEXPECTED_SIMPLE_BODY, "A Table's body must be a block", e)];
2206
+ const [n, s] = I.partition(e.body, (i) => i instanceof k);
2201
2207
  return [...this.validateFields(n), ...this.validateSubElements(s)];
2202
2208
  }
2203
2209
  validateFields(e) {
2204
- return e.length === 0 ? [new l(o.EMPTY_TABLE, "A Table must have at least one column", this.declarationNode)] : e.flatMap((n) => {
2210
+ return e.length === 0 ? [new u(o.EMPTY_TABLE, "A Table must have at least one column", this.declarationNode)] : e.flatMap((n) => {
2205
2211
  if (!n.callee)
2206
2212
  return [];
2207
2213
  const s = [];
2208
- n.args.length === 0 && s.push(new l(o.INVALID_COLUMN, "A column must have a type", n.callee)), M(n.callee) || s.push(new l(o.INVALID_COLUMN_NAME, "A column name must be an identifier or a quoted identifier", n.callee)), n.args[0] && !yn(n.args[0]) && s.push(new l(o.INVALID_COLUMN_TYPE, "Invalid column type", n.args[0]));
2214
+ n.args.length === 0 && s.push(new u(o.INVALID_COLUMN, "A column must have a type", n.callee)), M(n.callee) || s.push(new u(o.INVALID_COLUMN_NAME, "A column name must be an identifier or a quoted identifier", n.callee)), n.args[0] && !vn(n.args[0]) && s.push(new u(o.INVALID_COLUMN_TYPE, "Invalid column type", n.args[0]));
2209
2215
  const i = n.args.slice(1);
2210
2216
  return s.push(...this.validateFieldSetting(i)), s.push(...this.registerField(n)), s;
2211
2217
  });
2212
2218
  }
2213
2219
  registerField(e) {
2214
2220
  if (e.callee && M(e.callee)) {
2215
- const n = G(e.callee).unwrap(), s = We(n), i = this.symbolFactory.create(Kt, { declaration: e });
2221
+ const n = V(e.callee).unwrap(), s = We(n), i = this.symbolFactory.create(Jt, { declaration: e });
2216
2222
  e.symbol = i;
2217
2223
  const r = this.declarationNode.symbol.symbolTable;
2218
2224
  if (r.has(s)) {
2219
2225
  const a = r.get(s);
2220
2226
  return [
2221
- new l(o.DUPLICATE_COLUMN_NAME, `Duplicate column ${n}`, e),
2222
- new l(o.DUPLICATE_COLUMN_NAME, `Duplicate column ${n}`, a.declaration)
2227
+ new u(o.DUPLICATE_COLUMN_NAME, `Duplicate column ${n}`, e),
2228
+ new u(o.DUPLICATE_COLUMN_NAME, `Duplicate column ${n}`, a.declaration)
2223
2229
  ];
2224
2230
  }
2225
2231
  r.set(s, i);
@@ -2228,75 +2234,75 @@ class wn {
2228
2234
  }
2229
2235
  // This is needed to support legacy inline settings
2230
2236
  validateFieldSetting(e) {
2231
- if (!e.slice(0, -1).every(fe) || !e.slice(-1).every((p) => fe(p) || p instanceof U))
2232
- return [...e.map((p) => new l(o.INVALID_COLUMN, "These fields must be some inline settings optionally ended with a setting list", p))];
2237
+ if (!e.slice(0, -1).every(de) || !e.slice(-1).every((p) => de(p) || p instanceof P))
2238
+ return [...e.map((p) => new u(o.INVALID_COLUMN, "These fields must be some inline settings optionally ended with a setting list", p))];
2233
2239
  if (e.length === 0)
2234
2240
  return [];
2235
2241
  let n;
2236
- I.last(e) instanceof U && (n = e.pop());
2237
- const s = $(n), i = s.getErrors(), r = s.getValue();
2242
+ I.last(e) instanceof P && (n = e.pop());
2243
+ const s = z(n), i = s.getErrors(), r = s.getValue();
2238
2244
  for (const p of e) {
2239
- const h = G(p).unwrap_or("").toLowerCase();
2245
+ const h = V(p).unwrap_or("").toLowerCase();
2240
2246
  if (h !== "pk" && h !== "unique") {
2241
- i.push(new l(o.INVALID_SETTINGS, "Inline column settings can only be `pk` or `unique`", p));
2247
+ i.push(new u(o.INVALID_SETTINGS, "Inline column settings can only be `pk` or `unique`", p));
2242
2248
  continue;
2243
2249
  }
2244
2250
  r[h] === void 0 ? r[h] = [p] : r[h].push(p);
2245
2251
  }
2246
- const a = r.pk || [], c = r["primary key"] || [];
2247
- a.length >= 1 && c.length >= 1 && i.push(...[...a, ...c].map((p) => new l(o.DUPLICATE_COLUMN_SETTING, "Either one of 'primary key' and 'pk' can appear", p)));
2252
+ const a = r.pk || [], l = r["primary key"] || [];
2253
+ a.length >= 1 && l.length >= 1 && i.push(...[...a, ...l].map((p) => new u(o.DUPLICATE_COLUMN_SETTING, "Either one of 'primary key' and 'pk' can appear", p)));
2248
2254
  for (const p in r) {
2249
2255
  const h = r[p];
2250
2256
  switch (p) {
2251
2257
  case "note":
2252
- h.length > 1 && i.push(...h.map((f) => new l(o.DUPLICATE_COLUMN_SETTING, "note can only appear once", f))), h.forEach((f) => {
2253
- j(f.value) || i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'note' must be a quoted string", f.value || f.name));
2258
+ h.length > 1 && i.push(...h.map((f) => new u(o.DUPLICATE_COLUMN_SETTING, "note can only appear once", f))), h.forEach((f) => {
2259
+ $(f.value) || i.push(new u(o.INVALID_COLUMN_SETTING_VALUE, "'note' must be a quoted string", f.value || f.name));
2254
2260
  });
2255
2261
  break;
2256
2262
  case "ref":
2257
2263
  h.forEach((f) => {
2258
- Rn(f.value) || i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'ref' must be a valid unary relationship", f.value || f.name));
2264
+ Sn(f.value) || i.push(new u(o.INVALID_COLUMN_SETTING_VALUE, "'ref' must be a valid unary relationship", f.value || f.name));
2259
2265
  });
2260
2266
  break;
2261
2267
  case "primary key":
2262
- h.length > 1 && i.push(...h.map((f) => new l(o.DUPLICATE_COLUMN_SETTING, "primary key can only appear once", f))), h.forEach((f) => {
2263
- oe(f.value) || i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'primary key' must not have a value", f.value || f.name));
2268
+ h.length > 1 && i.push(...h.map((f) => new u(o.DUPLICATE_COLUMN_SETTING, "primary key can only appear once", f))), h.forEach((f) => {
2269
+ oe(f.value) || i.push(new u(o.INVALID_COLUMN_SETTING_VALUE, "'primary key' must not have a value", f.value || f.name));
2264
2270
  });
2265
2271
  break;
2266
2272
  case "pk":
2267
- h.length > 1 && i.push(...h.map((f) => new l(o.DUPLICATE_COLUMN_SETTING, "'pk' can only appear once", f))), h.forEach((f) => {
2268
- f instanceof ne && !oe(f.value) && i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'pk' must not have a value", f.value || f.name));
2273
+ h.length > 1 && i.push(...h.map((f) => new u(o.DUPLICATE_COLUMN_SETTING, "'pk' can only appear once", f))), h.forEach((f) => {
2274
+ f instanceof ne && !oe(f.value) && i.push(new u(o.INVALID_COLUMN_SETTING_VALUE, "'pk' must not have a value", f.value || f.name));
2269
2275
  });
2270
2276
  break;
2271
2277
  case "not null":
2272
- h.length > 1 && i.push(...h.map((f) => new l(o.DUPLICATE_COLUMN_SETTING, "'not null' can only appear once", f)));
2278
+ h.length > 1 && i.push(...h.map((f) => new u(o.DUPLICATE_COLUMN_SETTING, "'not null' can only appear once", f)));
2273
2279
  const T = r.null || [];
2274
- h.length >= 1 && T.length >= 1 && i.push(...[...h, ...T].map((f) => new l(o.CONFLICTING_SETTING, "'not null' and 'null' can not be set at the same time", f))), h.forEach((f) => {
2275
- oe(f.value) || i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'not null' must not have a value", f.value || f.name));
2280
+ h.length >= 1 && T.length >= 1 && i.push(...[...h, ...T].map((f) => new u(o.CONFLICTING_SETTING, "'not null' and 'null' can not be set at the same time", f))), h.forEach((f) => {
2281
+ oe(f.value) || i.push(new u(o.INVALID_COLUMN_SETTING_VALUE, "'not null' must not have a value", f.value || f.name));
2276
2282
  });
2277
2283
  break;
2278
2284
  case "null":
2279
- h.length > 1 && i.push(...h.map((f) => new l(o.DUPLICATE_COLUMN_SETTING, "'null' can only appear once", f))), h.forEach((f) => {
2280
- oe(f.value) || i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'null' must not have a value", f.value || f.name));
2285
+ h.length > 1 && i.push(...h.map((f) => new u(o.DUPLICATE_COLUMN_SETTING, "'null' can only appear once", f))), h.forEach((f) => {
2286
+ oe(f.value) || i.push(new u(o.INVALID_COLUMN_SETTING_VALUE, "'null' must not have a value", f.value || f.name));
2281
2287
  });
2282
2288
  break;
2283
2289
  case "unique":
2284
- h.length > 1 && i.push(...h.map((f) => new l(o.DUPLICATE_COLUMN_SETTING, "'unique' can only appear once", f))), h.forEach((f) => {
2285
- f instanceof ne && !oe(f.value) && i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'unique' must not have a value", f.value || f.name));
2290
+ h.length > 1 && i.push(...h.map((f) => new u(o.DUPLICATE_COLUMN_SETTING, "'unique' can only appear once", f))), h.forEach((f) => {
2291
+ f instanceof ne && !oe(f.value) && i.push(new u(o.INVALID_COLUMN_SETTING_VALUE, "'unique' must not have a value", f.value || f.name));
2286
2292
  });
2287
2293
  break;
2288
2294
  case "increment":
2289
- h.length > 1 && i.push(...h.map((f) => new l(o.DUPLICATE_COLUMN_SETTING, "'increment' can only appear once", f))), h.forEach((f) => {
2290
- f instanceof ne && !oe(f.value) && i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'increment' must not have a value", f.value || f.name));
2295
+ h.length > 1 && i.push(...h.map((f) => new u(o.DUPLICATE_COLUMN_SETTING, "'increment' can only appear once", f))), h.forEach((f) => {
2296
+ f instanceof ne && !oe(f.value) && i.push(new u(o.INVALID_COLUMN_SETTING_VALUE, "'increment' must not have a value", f.value || f.name));
2291
2297
  });
2292
2298
  break;
2293
2299
  case "default":
2294
- h.length > 1 && i.push(...h.map((f) => new l(o.DUPLICATE_TABLE_SETTING, "'default' can only appear once", f))), h.forEach((f) => {
2295
- Dn(f.value) || i.push(new l(o.INVALID_TABLE_SETTING, "'default' must be a string literal, number literal, function expression, true, false or null", f.value || f.name));
2300
+ h.length > 1 && i.push(...h.map((f) => new u(o.DUPLICATE_TABLE_SETTING, "'default' can only appear once", f))), h.forEach((f) => {
2301
+ On(f.value) || i.push(new u(o.INVALID_TABLE_SETTING, "'default' must be a string literal, number literal, function expression, true, false or null", f.value || f.name));
2296
2302
  });
2297
2303
  break;
2298
2304
  default:
2299
- h.forEach((f) => i.push(new l(o.UNKNOWN_COLUMN_SETTING, `Unknown column setting '${p}'`, f)));
2305
+ h.forEach((f) => i.push(new u(o.UNKNOWN_COLUMN_SETTING, `Unknown column setting '${p}'`, f)));
2300
2306
  }
2301
2307
  }
2302
2308
  return i;
@@ -2311,29 +2317,29 @@ class wn {
2311
2317
  var r;
2312
2318
  return ((r = i.type) == null ? void 0 : r.value.toLowerCase()) === "note";
2313
2319
  });
2314
- return s.length > 1 && (n.push(...s.map((i) => new l(o.NOTE_REDEFINED, "Duplicate notes are defined", i))), n.push()), n;
2320
+ return s.length > 1 && (n.push(...s.map((i) => new u(o.NOTE_REDEFINED, "Duplicate notes are defined", i))), n.push()), n;
2315
2321
  }
2316
2322
  }
2317
- function yn(t) {
2318
- if (!(t instanceof H || He(t) || t instanceof R || t instanceof he))
2323
+ function vn(t) {
2324
+ if (!(t instanceof H || He(t) || t instanceof D || t instanceof le))
2319
2325
  return !1;
2320
2326
  if (t instanceof H) {
2321
- if (t.callee === void 0 || t.argumentList === void 0 || !t.argumentList.elementList.every((n) => ce(n) || j(n) || fe(n)))
2327
+ if (t.callee === void 0 || t.argumentList === void 0 || !t.argumentList.elementList.every((n) => ce(n) || $(n) || de(n)))
2322
2328
  return !1;
2323
2329
  t = t.callee;
2324
2330
  }
2325
- for (; t instanceof he; ) {
2331
+ for (; t instanceof le; ) {
2326
2332
  if (t.array === void 0 || t.indexer === void 0 || !t.indexer.elementList.every((n) => !n.colon && !n.value && ce(n.name)))
2327
2333
  return !1;
2328
2334
  t = t.array;
2329
2335
  }
2330
- const e = C(t).unwrap_or(void 0);
2336
+ const e = W(t).unwrap_or(void 0);
2331
2337
  return e !== void 0 && e.length > 0;
2332
2338
  }
2333
- function xn(t, e) {
2339
+ function wn(t, e) {
2334
2340
  return e.length === 1 && t === e[0];
2335
2341
  }
2336
- class kn {
2342
+ class yn {
2337
2343
  constructor(e, n, s) {
2338
2344
  this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
2339
2345
  }
@@ -2341,41 +2347,41 @@ class kn {
2341
2347
  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)];
2342
2348
  }
2343
2349
  validateContext() {
2344
- return this.declarationNode.parent instanceof _ ? [new l(o.INVALID_TABLEGROUP_CONTEXT, "TableGroup must appear top-level", this.declarationNode)] : [];
2350
+ return this.declarationNode.parent instanceof _ ? [new u(o.INVALID_TABLEGROUP_CONTEXT, "TableGroup must appear top-level", this.declarationNode)] : [];
2345
2351
  }
2346
2352
  validateName(e) {
2347
- return e ? Je(e) ? [] : [new l(o.INVALID_NAME, "A TableGroup name must be of the form <tablegroup> or <schema>.<tablegroup>", e)] : [new l(o.NAME_NOT_FOUND, "A TableGroup must have a name", this.declarationNode)];
2353
+ return e ? Je(e) ? [] : [new u(o.INVALID_NAME, "A TableGroup name must be of the form <tablegroup> or <schema>.<tablegroup>", e)] : [new u(o.NAME_NOT_FOUND, "A TableGroup must have a name", this.declarationNode)];
2348
2354
  }
2349
2355
  validateAlias(e) {
2350
- return e ? [new l(o.UNEXPECTED_ALIAS, "A TableGroup shouldn't have an alias", e)] : [];
2356
+ return e ? [new u(o.UNEXPECTED_ALIAS, "A TableGroup shouldn't have an alias", e)] : [];
2351
2357
  }
2352
2358
  registerElement() {
2353
2359
  const { name: e } = this.declarationNode;
2354
- this.declarationNode.symbol = this.symbolFactory.create(en, { declaration: this.declarationNode, symbolTable: new Ae() });
2355
- const n = C(e);
2360
+ this.declarationNode.symbol = this.symbolFactory.create(Zt, { declaration: this.declarationNode, symbolTable: new _e() });
2361
+ const n = W(e);
2356
2362
  if (n.isOk()) {
2357
2363
  const s = n.unwrap(), i = s.pop(), r = Ze(s, this.publicSymbolTable, this.symbolFactory), a = ze(i);
2358
2364
  if (r.has(a))
2359
- return [new l(o.DUPLICATE_NAME, `TableGroup name '${i}' already exists in schema '${s.join(".") || "public"}'`, e)];
2365
+ return [new u(o.DUPLICATE_NAME, `TableGroup name '${i}' already exists in schema '${s.join(".") || "public"}'`, e)];
2360
2366
  r.set(a, this.declarationNode.symbol);
2361
2367
  }
2362
2368
  return [];
2363
2369
  }
2364
2370
  validateSettingList(e) {
2365
- return e ? [new l(o.UNEXPECTED_SETTINGS, "A TableGroup shouldn't have a setting list", e)] : [];
2371
+ return e ? [new u(o.UNEXPECTED_SETTINGS, "A TableGroup shouldn't have a setting list", e)] : [];
2366
2372
  }
2367
2373
  validateBody(e) {
2368
2374
  if (!e)
2369
2375
  return [];
2370
- if (e instanceof v)
2371
- return [new l(o.UNEXPECTED_SIMPLE_BODY, "A TableGroup's body must be a block", e)];
2372
- const [n, s] = I.partition(e.body, (i) => i instanceof v);
2376
+ if (e instanceof k)
2377
+ return [new u(o.UNEXPECTED_SIMPLE_BODY, "A TableGroup's body must be a block", e)];
2378
+ const [n, s] = I.partition(e.body, (i) => i instanceof k);
2373
2379
  return [...this.validateFields(n), ...this.validateSubElements(s)];
2374
2380
  }
2375
2381
  validateFields(e) {
2376
2382
  return e.flatMap((n) => {
2377
2383
  const s = [];
2378
- return n.callee && !C(n.callee).isOk() && s.push(new l(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 l(o.INVALID_TABLEGROUP_FIELD, "A TableGroup field should only have a single Table name", i))), s;
2384
+ return n.callee && !W(n.callee).isOk() && s.push(new u(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 u(o.INVALID_TABLEGROUP_FIELD, "A TableGroup field should only have a single Table name", i))), s;
2379
2385
  });
2380
2386
  }
2381
2387
  validateSubElements(e) {
@@ -2388,14 +2394,14 @@ class kn {
2388
2394
  }
2389
2395
  registerField(e) {
2390
2396
  if (e.callee && M(e.callee)) {
2391
- const n = G(e.callee).unwrap(), s = Qe(n), i = this.symbolFactory.create(tn, { declaration: e });
2397
+ const n = V(e.callee).unwrap(), s = Qe(n), i = this.symbolFactory.create(Kt, { declaration: e });
2392
2398
  e.symbol = i;
2393
2399
  const r = this.declarationNode.symbol.symbolTable;
2394
2400
  if (r.has(s)) {
2395
2401
  const a = r.get(s);
2396
2402
  return [
2397
- new l(o.DUPLICATE_TABLEGROUP_FIELD_NAME, `${n} already exists in the group`, e),
2398
- new l(o.DUPLICATE_TABLEGROUP_FIELD_NAME, `${n} already exists in the group`, a.declaration)
2403
+ new u(o.DUPLICATE_TABLEGROUP_FIELD_NAME, `${n} already exists in the group`, e),
2404
+ new u(o.DUPLICATE_TABLEGROUP_FIELD_NAME, `${n} already exists in the group`, a.declaration)
2399
2405
  ];
2400
2406
  }
2401
2407
  r.set(s, i);
@@ -2403,35 +2409,35 @@ class kn {
2403
2409
  return [];
2404
2410
  }
2405
2411
  }
2406
- const wt = ["-", "+"];
2412
+ const vt = ["-", "+"];
2407
2413
  function ie(t) {
2408
2414
  switch (t.type.value.toLowerCase()) {
2409
2415
  case b.Enum:
2410
- return In;
2416
+ return Tn;
2411
2417
  case b.Table:
2412
- return wn;
2418
+ return An;
2413
2419
  case b.TableGroup:
2414
- return kn;
2420
+ return yn;
2415
2421
  case b.Project:
2416
- return _n;
2422
+ return Ln;
2417
2423
  case b.Ref:
2418
- return An;
2419
- case b.Note:
2420
2424
  return gn;
2425
+ case b.Note:
2426
+ return In;
2421
2427
  case b.Indexes:
2422
- return Ln;
2423
- default:
2424
2428
  return bn;
2429
+ default:
2430
+ return mn;
2425
2431
  }
2426
2432
  }
2427
2433
  function Je(t) {
2428
- return !!C(t).unwrap_or(!1);
2434
+ return !!W(t).unwrap_or(!1);
2429
2435
  }
2430
- function Sn(t) {
2436
+ function kn(t) {
2431
2437
  return Pe(t);
2432
2438
  }
2433
2439
  function Pe(t) {
2434
- return t instanceof R && t.expression instanceof W;
2440
+ return t instanceof D && t.expression instanceof X;
2435
2441
  }
2436
2442
  function Ze(t, e, n) {
2437
2443
  var i;
@@ -2439,76 +2445,76 @@ function Ze(t, e, n) {
2439
2445
  let s = e;
2440
2446
  for (const r of t) {
2441
2447
  let a;
2442
- const c = $e(r);
2443
- if (s.has(c)) {
2444
- if (a = (i = s.get(c)) == null ? void 0 : i.symbolTable, !a)
2448
+ const l = $e(r);
2449
+ if (s.has(l)) {
2450
+ if (a = (i = s.get(l)) == null ? void 0 : i.symbolTable, !a)
2445
2451
  throw new Error("Expect a symbol table in a schema symbol");
2446
2452
  } else {
2447
- a = new Ae();
2448
- const p = n.create(_t, { symbolTable: a });
2449
- s.set(c, p);
2453
+ a = new _e();
2454
+ const p = n.create(gt, { symbolTable: a });
2455
+ s.set(l, p);
2450
2456
  }
2451
2457
  s = a;
2452
2458
  }
2453
2459
  return s;
2454
2460
  }
2455
- function yt(t) {
2461
+ function wt(t) {
2456
2462
  return t === "-" || t === "<>" || t === ">" || t === "<";
2457
2463
  }
2458
- function On(t) {
2464
+ function xn(t) {
2459
2465
  var n;
2460
- if (!(t instanceof R) || !(t.expression instanceof pe) || ((n = t.expression.literal) == null ? void 0 : n.kind) !== u.COLOR_LITERAL)
2466
+ if (!(t instanceof D) || !(t.expression instanceof Ee) || ((n = t.expression.literal) == null ? void 0 : n.kind) !== c.COLOR_LITERAL)
2461
2467
  return !1;
2462
2468
  const e = t.expression.literal.value;
2463
2469
  if (e.length !== 4 && e.length !== 7 || e[0] !== "#")
2464
2470
  return !1;
2465
2471
  for (let s = 1; s < e.length; s += 1)
2466
- if (!qt(e[s]))
2472
+ if (!zt(e[s]))
2467
2473
  return !1;
2468
2474
  return !0;
2469
2475
  }
2470
2476
  function oe(t) {
2471
2477
  return t === void 0;
2472
2478
  }
2473
- function Dn(t) {
2479
+ function On(t) {
2474
2480
  var e;
2475
- return !!(j(t) || ce(t) || fe(t) && ["true", "false", "null"].includes(t.expression.variable.value.toLowerCase()) || t instanceof Q && wt.includes((e = t.op) == null ? void 0 : e.value) && ce(t.expression) || t instanceof K);
2481
+ return !!($(t) || ce(t) || de(t) && ["true", "false", "null"].includes(t.expression.variable.value.toLowerCase()) || t instanceof Q && vt.includes((e = t.op) == null ? void 0 : e.value) && ce(t.expression) || t instanceof ee);
2476
2482
  }
2477
2483
  function ce(t) {
2478
2484
  var e;
2479
- return t instanceof R && t.expression instanceof pe && ((e = t.expression.literal) == null ? void 0 : e.kind) === u.NUMERIC_LITERAL;
2485
+ return t instanceof D && t.expression instanceof Ee && ((e = t.expression.literal) == null ? void 0 : e.kind) === c.NUMERIC_LITERAL;
2480
2486
  }
2481
- function Rn(t) {
2487
+ function Sn(t) {
2482
2488
  var n;
2483
- if (!(t instanceof Q) || !yt((n = t.op) == null ? void 0 : n.value))
2489
+ if (!(t instanceof Q) || !wt((n = t.op) == null ? void 0 : n.value))
2484
2490
  return !1;
2485
- const e = C(t.expression).unwrap_or(void 0);
2491
+ const e = W(t.expression).unwrap_or(void 0);
2486
2492
  return e !== void 0 && e.length > 0;
2487
2493
  }
2488
- function xt(t) {
2494
+ function yt(t) {
2489
2495
  return t instanceof J && t.elementList.every(M);
2490
2496
  }
2491
- function $(t) {
2497
+ function z(t) {
2492
2498
  var s;
2493
2499
  const e = {}, n = [];
2494
2500
  if (!t)
2495
- return new B({});
2501
+ return new F({});
2496
2502
  for (const i of t.elementList) {
2497
2503
  if (!i.name)
2498
2504
  continue;
2499
- if (i.name instanceof R) {
2500
- n.push(new l(o.INVALID_SETTINGS, "A setting name must be a stream of identifiers", i.name));
2505
+ if (i.name instanceof D) {
2506
+ n.push(new u(o.INVALID_SETTINGS, "A setting name must be a stream of identifiers", i.name));
2501
2507
  continue;
2502
2508
  }
2503
- const r = (s = Re(i.name).unwrap_or(void 0)) == null ? void 0 : s.toLowerCase();
2509
+ const r = (s = De(i.name).unwrap_or(void 0)) == null ? void 0 : s.toLowerCase();
2504
2510
  r && (e[r] === void 0 ? e[r] = [i] : e[r].push(i));
2505
2511
  }
2506
- return new B(e, n);
2512
+ return new F(e, n);
2507
2513
  }
2508
- class ft {
2514
+ class ht {
2509
2515
  constructor(e, n) {
2510
- this.ast = e, this.symbolFactory = n, this.publicSchemaSymbol = this.symbolFactory.create(_t, {
2511
- symbolTable: new Ae()
2516
+ this.ast = e, this.symbolFactory = n, this.publicSchemaSymbol = this.symbolFactory.create(gt, {
2517
+ symbolTable: new _e()
2512
2518
  }), this.ast.symbol = this.publicSchemaSymbol, this.ast.symbol.declaration = this.ast;
2513
2519
  }
2514
2520
  validate() {
@@ -2523,8 +2529,8 @@ class ft {
2523
2529
  );
2524
2530
  e.push(...r.validate());
2525
2531
  });
2526
- const n = this.ast.body.filter((s) => de(s).unwrap_or(void 0) === b.Project);
2527
- return n.length > 1 && n.forEach((s) => e.push(new l(o.PROJECT_REDEFINED, "Only one project can exist", s))), new B(this.ast, e);
2532
+ const n = this.ast.body.filter((s) => ge(s).unwrap_or(void 0) === b.Project);
2533
+ return n.length > 1 && n.forEach((s) => e.push(new u(o.PROJECT_REDEFINED, "Only one project can exist", s))), new F(this.ast, e);
2528
2534
  }
2529
2535
  }
2530
2536
  class re {
@@ -2537,9 +2543,9 @@ class re {
2537
2543
  bindSettingList(e, n) {
2538
2544
  if (e)
2539
2545
  for (const s of e.elementList) {
2540
- if (s.name instanceof R)
2546
+ if (s.name instanceof D)
2541
2547
  continue;
2542
- const i = Re(s.name).unwrap_or(void 0);
2548
+ const i = De(s.name).unwrap_or(void 0);
2543
2549
  if (!i)
2544
2550
  continue;
2545
2551
  const r = n[i.toLowerCase()];
@@ -2551,7 +2557,7 @@ class re {
2551
2557
  if (!e.body)
2552
2558
  return;
2553
2559
  const { body: n } = e;
2554
- if (n instanceof ee)
2560
+ if (n instanceof te)
2555
2561
  for (const s of n.body)
2556
2562
  if (s instanceof _) {
2557
2563
  if (!s.type)
@@ -2565,7 +2571,7 @@ class re {
2565
2571
  }
2566
2572
  bindSubfield(e) {
2567
2573
  const n = [e.callee, ...e.args], s = I.last(n);
2568
- s instanceof U && (n.pop(), this.bindSettingList(s, this.subfield.settingList));
2574
+ s instanceof P && (n.pop(), this.bindSettingList(s, this.subfield.settingList));
2569
2575
  const { argBinderRules: i } = this.subfield.arg;
2570
2576
  for (let r = 0; r < Math.min(n.length, i.length); r += 1)
2571
2577
  i[r].shouldBind && this.scanAndBind(n[r], i[r]);
@@ -2574,12 +2580,12 @@ class re {
2574
2580
  scanAndBind(e, n) {
2575
2581
  var s, i;
2576
2582
  if (e)
2577
- if (e instanceof R) {
2578
- if (e.expression instanceof W && ((i = n.keywords) != null && i.includes((s = e.expression.variable) == null ? void 0 : s.value.toLowerCase())))
2583
+ if (e instanceof D) {
2584
+ if (e.expression instanceof X && ((i = n.keywords) != null && i.includes((s = e.expression.variable) == null ? void 0 : s.value.toLowerCase())))
2579
2585
  return;
2580
2586
  this.bindFragments([e], n);
2581
2587
  } else
2582
- e instanceof q ? He(e) ? this.bindFragments(Ee(e).unwrap_or([]), n) : (this.scanAndBind(e.leftExpression, n), this.scanAndBind(e.rightExpression, n)) : e instanceof Q ? this.scanAndBind(e.expression, n) : e instanceof De ? this.scanAndBind(e.expression, n) : e instanceof J && e.elementList.forEach((r) => this.scanAndBind(r, n));
2588
+ e instanceof q ? He(e) ? this.bindFragments(ue(e).unwrap_or([]), n) : (this.scanAndBind(e.leftExpression, n), this.scanAndBind(e.rightExpression, n)) : e instanceof Q ? this.scanAndBind(e.expression, n) : e instanceof Re ? this.scanAndBind(e.expression, n) : e instanceof J && e.elementList.forEach((r) => this.scanAndBind(r, n));
2583
2589
  }
2584
2590
  // Bind the fragments of a member access expression
2585
2591
  // which can be a simple expression like v1.User,
@@ -2587,7 +2593,7 @@ class re {
2587
2593
  bindFragments(e, n) {
2588
2594
  if (e.length === 0)
2589
2595
  return;
2590
- const s = [...n.topSubnamesSymbolKind], { remainingSubnamesSymbolKind: i } = n, r = e.findIndex((f) => !M(f)), c = r !== -1 && xt(e[r]) ? e[r] : void 0, p = r >= 0 ? s.pop() : void 0, h = e.slice(
2596
+ const s = [...n.topSubnamesSymbolKind], { remainingSubnamesSymbolKind: i } = n, r = e.findIndex((f) => !M(f)), l = r !== -1 && yt(e[r]) ? e[r] : void 0, p = r >= 0 ? s.pop() : void 0, h = e.slice(
2591
2597
  0,
2592
2598
  r === -1 ? void 0 : r
2593
2599
  );
@@ -2595,26 +2601,26 @@ class re {
2595
2601
  return;
2596
2602
  const T = [];
2597
2603
  for (; s.length && h.length; ) {
2598
- const f = s.pop(), N = h.pop(), g = G(N).unwrap();
2604
+ const f = s.pop(), N = h.pop(), g = V(N).unwrap();
2599
2605
  T.unshift({
2600
2606
  index: Fe(g, f),
2601
2607
  referrer: N
2602
2608
  });
2603
2609
  }
2604
2610
  for (; h.length; ) {
2605
- const f = h.pop(), N = G(f).unwrap();
2611
+ const f = h.pop(), N = V(f).unwrap();
2606
2612
  T.unshift({
2607
2613
  index: Fe(N, i),
2608
2614
  referrer: f
2609
2615
  });
2610
2616
  }
2611
- return c ? c.elementList.forEach(
2617
+ return l ? l.elementList.forEach(
2612
2618
  (f) => this.resolveIndexStack(
2613
2619
  [
2614
2620
  ...T,
2615
2621
  {
2616
2622
  index: Fe(
2617
- G(f).unwrap(),
2623
+ V(f).unwrap(),
2618
2624
  p
2619
2625
  ),
2620
2626
  referrer: f
@@ -2629,34 +2635,34 @@ class re {
2629
2635
  resolveIndexStack(e, n) {
2630
2636
  if (e.length === 0)
2631
2637
  throw new Error("Unreachable - An unresolved name must have at least one name component");
2632
- const [s, ...i] = e, r = Tn(s.index, this.declarationNode);
2638
+ const [s, ...i] = e, r = Nn(s.index, this.declarationNode);
2633
2639
  if (r === void 0) {
2634
2640
  const { kind: h, name: T } = se(s.index).unwrap();
2635
2641
  this.logError(s.referrer, `Can not find ${h} '${T}'`, n);
2636
2642
  return;
2637
2643
  }
2638
2644
  r.references.push(s.referrer), s.referrer.referee = r;
2639
- let a = r.symbolTable, { kind: c, name: p } = se(s.index).unwrap();
2645
+ let a = r.symbolTable, { kind: l, name: p } = se(s.index).unwrap();
2640
2646
  for (const h of i) {
2641
2647
  const { kind: T, name: f } = se(h.index).unwrap(), N = a.get(h.index);
2642
2648
  if (!N) {
2643
2649
  this.logError(
2644
2650
  h.referrer,
2645
- `${c} '${p}' does not have ${T} '${f}'`,
2651
+ `${l} '${p}' does not have ${T} '${f}'`,
2646
2652
  n
2647
2653
  );
2648
2654
  return;
2649
2655
  }
2650
- if (c = T, p = f, h.referrer.referee = N, N.references.push(h.referrer), !N.symbolTable)
2656
+ if (l = T, p = f, h.referrer.referee = N, N.references.push(h.referrer), !N.symbolTable)
2651
2657
  break;
2652
2658
  a = N.symbolTable;
2653
2659
  }
2654
2660
  }
2655
2661
  logError(e, n, s) {
2656
- s || this.errors.push(new l(o.BINDING_ERROR, n, e));
2662
+ s || this.errors.push(new u(o.BINDING_ERROR, n, e));
2657
2663
  }
2658
2664
  }
2659
- class Pn extends re {
2665
+ class Rn extends re {
2660
2666
  constructor() {
2661
2667
  super(...arguments), this.subfield = {
2662
2668
  arg: {
@@ -2666,7 +2672,7 @@ class Pn extends re {
2666
2672
  }, this.settingList = {};
2667
2673
  }
2668
2674
  }
2669
- class Un extends re {
2675
+ class Dn extends re {
2670
2676
  constructor() {
2671
2677
  super(...arguments), this.subfield = {
2672
2678
  arg: {
@@ -2676,7 +2682,7 @@ class Un extends re {
2676
2682
  }, this.settingList = {};
2677
2683
  }
2678
2684
  }
2679
- class Mn extends re {
2685
+ class Pn extends re {
2680
2686
  constructor() {
2681
2687
  super(...arguments), this.subfield = {
2682
2688
  arg: {
@@ -2711,7 +2717,7 @@ class Mn extends re {
2711
2717
  }, this.settingList = {};
2712
2718
  }
2713
2719
  }
2714
- class Fn extends re {
2720
+ class Un extends re {
2715
2721
  constructor() {
2716
2722
  super(...arguments), this.subfield = {
2717
2723
  arg: {
@@ -2721,7 +2727,7 @@ class Fn extends re {
2721
2727
  }, this.settingList = {};
2722
2728
  }
2723
2729
  }
2724
- class Bn extends re {
2730
+ class Mn extends re {
2725
2731
  constructor() {
2726
2732
  super(...arguments), this.subfield = {
2727
2733
  arg: {
@@ -2731,7 +2737,7 @@ class Bn extends re {
2731
2737
  }, this.settingList = {};
2732
2738
  }
2733
2739
  }
2734
- class Vn extends re {
2740
+ class Fn extends re {
2735
2741
  constructor() {
2736
2742
  super(...arguments), this.subfield = {
2737
2743
  arg: {
@@ -2748,7 +2754,7 @@ class Vn extends re {
2748
2754
  }, this.settingList = {};
2749
2755
  }
2750
2756
  }
2751
- class Gn extends re {
2757
+ class Bn extends re {
2752
2758
  constructor() {
2753
2759
  super(...arguments), this.subfield = {
2754
2760
  arg: {
@@ -2776,7 +2782,7 @@ class Gn extends re {
2776
2782
  }, this.settingList = {};
2777
2783
  }
2778
2784
  }
2779
- class Cn extends re {
2785
+ class Vn extends re {
2780
2786
  constructor() {
2781
2787
  super(...arguments), this.subfield = {
2782
2788
  arg: {
@@ -2796,24 +2802,24 @@ class Cn extends re {
2796
2802
  function kt(t) {
2797
2803
  switch (t.type.value.toLowerCase()) {
2798
2804
  case b.Enum:
2799
- return Un;
2805
+ return Dn;
2800
2806
  case b.Table:
2801
- return Gn;
2807
+ return Bn;
2802
2808
  case b.TableGroup:
2803
- return Cn;
2809
+ return Vn;
2804
2810
  case b.Project:
2805
- return Bn;
2811
+ return Mn;
2806
2812
  case b.Ref:
2807
- return Vn;
2808
- case b.Note:
2809
2813
  return Fn;
2814
+ case b.Note:
2815
+ return Un;
2810
2816
  case b.Indexes:
2811
- return Mn;
2812
- default:
2813
2817
  return Pn;
2818
+ default:
2819
+ return Rn;
2814
2820
  }
2815
2821
  }
2816
- class Xn {
2822
+ class Gn {
2817
2823
  constructor(e) {
2818
2824
  this.ast = e, this.errors = [];
2819
2825
  }
@@ -2823,10 +2829,10 @@ class Xn {
2823
2829
  const n = kt(e);
2824
2830
  new n(e, this.errors).bind();
2825
2831
  }
2826
- return new B(this.ast, this.errors);
2832
+ return new F(this.ast, this.errors);
2827
2833
  }
2828
2834
  }
2829
- class $n {
2835
+ class Cn {
2830
2836
  constructor(e) {
2831
2837
  this.generator = e;
2832
2838
  }
@@ -2834,21 +2840,21 @@ class $n {
2834
2840
  return new e(n, this.generator.nextId());
2835
2841
  }
2836
2842
  }
2837
- class Wn {
2843
+ class Xn {
2838
2844
  constructor(e, n) {
2839
- this.ast = e, this.symbolFactory = new $n(n);
2845
+ this.ast = e, this.symbolFactory = new Cn(n);
2840
2846
  }
2841
2847
  // Analyzing: Invoking both the validator and binder
2842
2848
  analyze() {
2843
- return new ft(this.ast, this.symbolFactory).validate().chain((n) => new Xn(n).resolve());
2849
+ return new ht(this.ast, this.symbolFactory).validate().chain((n) => new Gn(n).resolve());
2844
2850
  }
2845
2851
  // For invoking the validator only
2846
2852
  validate() {
2847
- return new ft(this.ast, this.symbolFactory).validate().chain((n) => new B(n, []));
2853
+ return new ht(this.ast, this.symbolFactory).validate().chain((n) => new F(n, []));
2848
2854
  }
2849
2855
  }
2850
- function pt(t, e) {
2851
- const { variables: n, tupleElements: s } = ge(t).unwrap();
2856
+ function ft(t, e) {
2857
+ const { variables: n, tupleElements: s } = Ie(t).unwrap();
2852
2858
  return s ? n.length === 0 ? {
2853
2859
  schemaName: e.schemaName,
2854
2860
  tableName: e.name,
@@ -2867,7 +2873,7 @@ function pt(t, e) {
2867
2873
  schemaName: n.pop() || null
2868
2874
  };
2869
2875
  }
2870
- function St(t) {
2876
+ function xt(t) {
2871
2877
  switch (t) {
2872
2878
  case "<":
2873
2879
  return ["1", "*"];
@@ -2880,7 +2886,7 @@ function St(t) {
2880
2886
  }
2881
2887
  throw new Error("Invalid relation op");
2882
2888
  }
2883
- function k(t) {
2889
+ function x(t) {
2884
2890
  return {
2885
2891
  start: {
2886
2892
  offset: t.startPos.offset,
@@ -2892,85 +2898,41 @@ function k(t) {
2892
2898
  }
2893
2899
  function Ce(t) {
2894
2900
  var n;
2895
- const e = (n = Ee(t).unwrap_or(void 0)) == null ? void 0 : n.pop();
2901
+ const e = (n = ue(t).unwrap_or(void 0)) == null ? void 0 : n.pop();
2896
2902
  return e instanceof J ? e.elementList.map((s) => s.referee) : [e.referee];
2897
2903
  }
2898
- function Ne(t) {
2899
- const e = C(t).unwrap();
2904
+ function Ae(t) {
2905
+ const e = W(t).unwrap();
2900
2906
  return {
2901
2907
  name: e.pop(),
2902
2908
  schemaName: e
2903
2909
  };
2904
2910
  }
2905
- function Ot(t) {
2911
+ function $n(t) {
2906
2912
  return t.expression.literal.value;
2907
2913
  }
2908
- function Dt(t, e) {
2914
+ function Ot(t, e) {
2909
2915
  if (Array.isArray(t)) {
2910
2916
  const i = t.map(({ id: a }) => a).sort().join(","), r = e.map(({ id: a }) => a).sort().join(",");
2911
- return i < r ? `${i}-${r}` : `${i}-${r}`;
2917
+ return i < r ? `${i}-${r}` : `${r}-${i}`;
2912
2918
  }
2913
2919
  const n = t.id, s = e.id;
2914
2920
  return n < s ? `${n}-${s}` : `${s}-${n}`;
2915
2921
  }
2916
- function Rt(t, e) {
2922
+ function St(t, e) {
2917
2923
  if (Array.isArray(t)) {
2918
2924
  const i = t.map(({ id: a }) => a).sort(), r = e.map(({ id: a }) => a).sort();
2919
- return I.zip(i, r).every(([a, c]) => a === c);
2925
+ return I.zip(i, r).every(([a, l]) => a === l);
2920
2926
  }
2921
2927
  const n = t.id, s = e.id;
2922
2928
  return n === s;
2923
2929
  }
2924
- class Ke {
2925
- constructor(e, n) {
2926
- this.declarationNode = e, this.env = n, this.container = this.declarationNode.parent instanceof _ ? this.env.tables.get(this.declarationNode.parent) : void 0, this.ref = {};
2927
- }
2928
- interpret() {
2929
- return this.ref.token = k(this.declarationNode), this.env.ref.set(this.declarationNode, this.ref), [...this.interpretName(this.declarationNode.name), ...this.interpretBody(this.declarationNode.body)];
2930
- }
2931
- interpretName(e) {
2932
- const n = [], s = C(this.declarationNode.name).unwrap_or([]);
2933
- return this.ref.name = s.pop() || null, s.length > 1 && n.push(new l(o.UNSUPPORTED, "Nested schema is not supported", this.declarationNode.name)), this.ref.schemaName = s.join(".") || null, n;
2934
- }
2935
- interpretBody(e) {
2936
- return e instanceof v ? this.interpretField(e) : this.interpretField(e.body[0]);
2937
- }
2938
- interpretField(e) {
2939
- var h, T, f, N;
2940
- const n = e.callee.op.value, { leftExpression: s, rightExpression: i } = e.callee, r = Ce(s), a = Ce(i);
2941
- if (Rt(r, a))
2942
- return [new l(o.SAME_ENDPOINT, "Two endpoints are the same", e)];
2943
- const c = Dt(r, a);
2944
- if (this.env.refIds[c])
2945
- return [
2946
- new l(o.CIRCULAR_REF, "References with same endpoints exist", this.declarationNode),
2947
- new l(o.CIRCULAR_REF, "References with same endpoints exist", this.env.refIds[c])
2948
- ];
2949
- if (e.args[0]) {
2950
- const g = $(e.args[0]).getValue();
2951
- this.ref.onDelete = X((T = (h = g.delete) == null ? void 0 : h.at(0)) == null ? void 0 : T.value).unwrap_or(void 0), this.ref.onDelete = X((N = (f = g.delete) == null ? void 0 : f.at(0)) == null ? void 0 : N.value).unwrap_or(void 0);
2952
- }
2953
- const p = St(n);
2954
- return this.ref.endpoints = [
2955
- {
2956
- ...pt(s, this.container),
2957
- relation: p[0],
2958
- token: k(s)
2959
- },
2960
- {
2961
- ...pt(i, this.container),
2962
- relation: p[1],
2963
- token: k(i)
2964
- }
2965
- ], this.env.refIds[c] = this.declarationNode, [];
2966
- }
2967
- }
2968
- class Pt {
2930
+ class Rt {
2969
2931
  constructor(e, n) {
2970
2932
  this.declarationNode = e, this.env = n, this.table = { name: void 0, schemaName: void 0, alias: null, fields: [], token: void 0, indexes: [] }, this.pkColumns = [];
2971
2933
  }
2972
2934
  interpret() {
2973
- this.table.token = k(this.declarationNode), this.env.tables.set(this.declarationNode, this.table);
2935
+ this.table.token = x(this.declarationNode), this.env.tables.set(this.declarationNode, this.table);
2974
2936
  const e = [
2975
2937
  ...this.interpretName(this.declarationNode.name),
2976
2938
  ...this.interpretAlias(this.declarationNode.alias),
@@ -2989,13 +2951,13 @@ class Pt {
2989
2951
  }), this.pkColumns.forEach((n) => n.pk = !1)), e;
2990
2952
  }
2991
2953
  interpretName(e) {
2992
- const { name: n, schemaName: s } = Ne(e);
2993
- return s.length > 1 ? (this.table.name = n, this.table.schemaName = s.join("."), [new l(o.UNSUPPORTED, "Nested schema is not supported", e)]) : (this.table.name = n, this.table.schemaName = s.length ? s[0] : null, []);
2954
+ const { name: n, schemaName: s } = Ae(e);
2955
+ return s.length > 1 ? (this.table.name = n, this.table.schemaName = s.join("."), [new u(o.UNSUPPORTED, "Nested schema is not supported", e)]) : (this.table.name = n, this.table.schemaName = s.length ? s[0] : null, []);
2994
2956
  }
2995
2957
  interpretAlias(e) {
2996
2958
  if (!e)
2997
2959
  return [];
2998
- const n = G(e).unwrap_or(null);
2960
+ const n = V(e).unwrap_or(null);
2999
2961
  return n && (this.env.aliases.push({
3000
2962
  name: n,
3001
2963
  kind: "table",
@@ -3006,17 +2968,17 @@ class Pt {
3006
2968
  }), this.table.alias = n), [];
3007
2969
  }
3008
2970
  interpretSettingList(e) {
3009
- var r, a, c;
3010
- const n = $(e).getValue();
3011
- this.table.headerColor = (r = n.headercolor) != null && r.length ? Ot((c = (a = n.headercolor) == null ? void 0 : a.at(0)) == null ? void 0 : c.value) : void 0;
3012
- const [s] = n.note || [], i = z(s == null ? void 0 : s.value).unwrap_or(void 0);
2971
+ var r, a, l;
2972
+ const n = z(e).getValue();
2973
+ this.table.headerColor = (r = n.headercolor) != null && r.length ? $n((l = (a = n.headercolor) == null ? void 0 : a.at(0)) == null ? void 0 : l.value) : void 0;
2974
+ const [s] = n.note || [], i = Y(s == null ? void 0 : s.value).unwrap_or(void 0);
3013
2975
  return this.table.note = s && {
3014
2976
  value: i,
3015
- token: k(s)
2977
+ token: x(s)
3016
2978
  }, [];
3017
2979
  }
3018
2980
  interpretBody(e) {
3019
- const [n, s] = I.partition(e.body, (i) => i instanceof v);
2981
+ const [n, s] = I.partition(e.body, (i) => i instanceof k);
3020
2982
  return [...this.interpretFields(n), ...this.interpretSubElements(s)];
3021
2983
  }
3022
2984
  interpretSubElements(e) {
@@ -3025,13 +2987,11 @@ class Pt {
3025
2987
  switch ((s = n.type) == null ? void 0 : s.value.toLowerCase()) {
3026
2988
  case "note":
3027
2989
  return this.table.note = {
3028
- value: z(n.body instanceof ee ? n.body.body[0].callee : n.body.callee).unwrap(),
3029
- token: k(n)
2990
+ value: Y(n.body instanceof te ? n.body.body[0].callee : n.body.callee).unwrap(),
2991
+ token: x(n)
3030
2992
  }, [];
3031
2993
  case "indexes":
3032
2994
  return this.interpretIndexes(n);
3033
- case "ref":
3034
- return new Ke(n, this.env).interpret();
3035
2995
  }
3036
2996
  return [];
3037
2997
  });
@@ -3040,102 +3000,102 @@ class Pt {
3040
3000
  return e.flatMap((n) => this.interpretColumn(n));
3041
3001
  }
3042
3002
  interpretColumn(e) {
3043
- var a, c, p, h, T, f, N, g;
3003
+ var a, l, p, h, T, f, N, g;
3044
3004
  const n = [], s = {};
3045
- s.name = G(e.callee).unwrap();
3046
- const i = jn(e.args[0]);
3047
- s.type = i.getValue(), n.push(...i.getErrors()), s.token = k(e), s.inline_refs = [];
3005
+ s.name = V(e.callee).unwrap();
3006
+ const i = Wn(e.args[0]);
3007
+ s.type = i.getValue(), n.push(...i.getErrors()), s.token = x(e), s.inline_refs = [];
3048
3008
  const r = e.args.slice(1);
3049
- if (I.last(r) instanceof U) {
3050
- const w = $(r.pop()).getValue();
3051
- s.pk = !!((a = w.pk) != null && a.length) || !!((c = w["primary key"]) != null && c.length), s.increment = !!((p = w.increment) != null && p.length), s.unique = !!((h = w.unique) != null && h.length), s.not_null = !!((T = w["not null"]) != null && T.length) && !0, s.dbdefault = Yn((N = (f = w.default) == null ? void 0 : f.at(0)) == null ? void 0 : N.value);
3052
- const me = (g = w.note) == null ? void 0 : g.at(0);
3053
- s.note = me && {
3054
- value: z(me.value).unwrap(),
3055
- token: k(me)
3009
+ if (I.last(r) instanceof P) {
3010
+ const v = z(r.pop()).getValue();
3011
+ s.pk = !!((a = v.pk) != null && a.length) || !!((l = v["primary key"]) != null && l.length), s.increment = !!((p = v.increment) != null && p.length), s.unique = !!((h = v.unique) != null && h.length), s.not_null = !!((T = v["not null"]) != null && T.length) && !0, s.dbdefault = jn((N = (f = v.default) == null ? void 0 : f.at(0)) == null ? void 0 : N.value);
3012
+ const Ne = (g = v.note) == null ? void 0 : g.at(0);
3013
+ s.note = Ne && {
3014
+ value: Y(Ne.value).unwrap(),
3015
+ token: x(Ne)
3056
3016
  };
3057
- const Te = w.ref || [];
3058
- s.inline_refs = Te.flatMap((Y) => {
3059
- const [nt] = Ce(Y.value.expression);
3060
- if (Rt(nt, e.symbol))
3061
- return n.push(new l(o.SAME_ENDPOINT, "Two endpoints are the same", Y)), [];
3062
- const ve = Y.value.op, Z = C(Y.value.expression).unwrap();
3063
- let le;
3017
+ const me = v.ref || [];
3018
+ s.inline_refs = me.flatMap((j) => {
3019
+ const [tt] = Ce(j.value.expression);
3020
+ if (St(tt, e.symbol))
3021
+ return n.push(new u(o.SAME_ENDPOINT, "Two endpoints are the same", j)), [];
3022
+ const ve = j.value.op, Z = W(j.value.expression).unwrap();
3023
+ let he;
3064
3024
  if (Z.length === 1) {
3065
3025
  const [ae] = Z;
3066
- le = {
3026
+ he = {
3067
3027
  schemaName: this.table.schemaName,
3068
3028
  tableName: this.table.name,
3069
3029
  fieldNames: [ae],
3070
3030
  relation: ve.value,
3071
- token: k(Y)
3031
+ token: x(j)
3072
3032
  };
3073
3033
  } else if (Z.length === 2) {
3074
- const [ae, be] = Z;
3075
- le = {
3034
+ const [ae, Te] = Z;
3035
+ he = {
3076
3036
  schemaName: null,
3077
3037
  tableName: ae,
3078
- fieldNames: [be],
3038
+ fieldNames: [Te],
3079
3039
  relation: ve.value,
3080
- token: k(Y)
3040
+ token: x(j)
3081
3041
  };
3082
3042
  } else if (Z.length === 3) {
3083
- const [ae, be, it] = Z;
3084
- le = {
3043
+ const [ae, Te, st] = Z;
3044
+ he = {
3085
3045
  schemaName: ae,
3086
- tableName: be,
3087
- fieldNames: [it],
3046
+ tableName: Te,
3047
+ fieldNames: [st],
3088
3048
  relation: ve.value,
3089
- token: k(Y)
3049
+ token: x(j)
3090
3050
  };
3091
3051
  } else {
3092
- n.push(new l(o.UNSUPPORTED, "Nested schema is not supported", Y));
3093
- const ae = Z.pop(), be = Z.pop();
3094
- le = {
3052
+ n.push(new u(o.UNSUPPORTED, "Nested schema is not supported", j));
3053
+ const ae = Z.pop(), Te = Z.pop();
3054
+ he = {
3095
3055
  schemaName: Z.join("."),
3096
- tableName: be,
3056
+ tableName: Te,
3097
3057
  fieldNames: [ae],
3098
3058
  relation: ve.value,
3099
- token: k(Y)
3059
+ token: x(j)
3100
3060
  };
3101
3061
  }
3102
- const st = this.registerInlineRefToEnv(e, nt, le, Y);
3103
- return n.push(...st), st.length === 0 ? le : [];
3062
+ const nt = this.registerInlineRefToEnv(e, tt, he, j);
3063
+ return n.push(...nt), nt.length === 0 ? he : [];
3104
3064
  });
3105
3065
  }
3106
- return s.pk || (s.pk = r.some((w) => X(w).unwrap().toLowerCase() === "pk")), s.unique || (s.unique = r.some((w) => X(w).unwrap().toLowerCase() === "unique")), this.table.fields.push(s), s.pk && this.pkColumns.push(s), n;
3066
+ return s.pk || (s.pk = r.some((v) => G(v).unwrap().toLowerCase() === "pk")), s.unique || (s.unique = r.some((v) => G(v).unwrap().toLowerCase() === "unique")), this.table.fields.push(s), s.pk && this.pkColumns.push(s), n;
3107
3067
  }
3108
3068
  interpretIndexes(e) {
3109
3069
  return this.table.indexes.push(...e.body.body.map((n) => {
3110
- var a, c, p, h, T, f, N;
3070
+ var a, l, p, h, T, f, N;
3111
3071
  const s = { columns: [] }, i = n;
3112
- s.token = k(e);
3072
+ s.token = x(e);
3113
3073
  const r = [i.callee, ...i.args];
3114
- if (I.last(r) instanceof U) {
3115
- const g = $(r.pop()).getValue();
3116
- s.pk = !!((a = g.pk) != null && a.length), s.unique = !!((c = g.unique) != null && c.length), s.name = z((h = (p = g.name) == null ? void 0 : p.at(0)) == null ? void 0 : h.value).unwrap_or(void 0);
3117
- const w = (T = g.note) == null ? void 0 : T.at(0);
3118
- s.note = w && {
3119
- value: z(w.value).unwrap(),
3120
- token: k(w)
3121
- }, s.type = X((N = (f = g.type) == null ? void 0 : f.at(0)) == null ? void 0 : N.value).unwrap_or(void 0);
3074
+ if (I.last(r) instanceof P) {
3075
+ const g = z(r.pop()).getValue();
3076
+ s.pk = !!((a = g.pk) != null && a.length), s.unique = !!((l = g.unique) != null && l.length), s.name = Y((h = (p = g.name) == null ? void 0 : p.at(0)) == null ? void 0 : h.value).unwrap_or(void 0);
3077
+ const v = (T = g.note) == null ? void 0 : T.at(0);
3078
+ s.note = v && {
3079
+ value: Y(v.value).unwrap(),
3080
+ token: x(v)
3081
+ }, s.type = G((N = (f = g.type) == null ? void 0 : f.at(0)) == null ? void 0 : N.value).unwrap_or(void 0);
3122
3082
  }
3123
3083
  return r.flatMap((g) => {
3124
3084
  if (!(g instanceof H))
3125
3085
  return g;
3126
- const w = [];
3086
+ const v = [];
3127
3087
  for (; g instanceof H; )
3128
- w.push(g.argumentList), g = g.callee;
3129
- return w.push(g), w;
3088
+ v.push(g.argumentList), g = g.callee;
3089
+ return v.push(g), v;
3130
3090
  }).forEach((g) => {
3131
- const { functional: w, nonFunctional: me } = Ge(g).unwrap();
3091
+ const { functional: v, nonFunctional: Ne } = Ge(g).unwrap();
3132
3092
  s.columns.push(
3133
- ...w.map((Te) => ({
3134
- value: Te.value.value,
3093
+ ...v.map((me) => ({
3094
+ value: me.value.value,
3135
3095
  type: "expression"
3136
3096
  })),
3137
- ...me.map((Te) => ({
3138
- value: G(Te).unwrap(),
3097
+ ...Ne.map((me) => ({
3098
+ value: V(me).unwrap(),
3139
3099
  type: "column"
3140
3100
  }))
3141
3101
  );
@@ -3143,13 +3103,13 @@ class Pt {
3143
3103
  })), [];
3144
3104
  }
3145
3105
  registerInlineRefToEnv(e, n, s, i) {
3146
- const r = Dt(e.symbol, n);
3106
+ const r = Ot(e.symbol, n);
3147
3107
  if (this.env.refIds[r])
3148
3108
  return [
3149
- new l(o.CIRCULAR_REF, "References with same endpoints exist", i),
3150
- new l(o.CIRCULAR_REF, "References with same endpoints exist", this.env.refIds[r])
3109
+ new u(o.CIRCULAR_REF, "References with same endpoints exist", i),
3110
+ new u(o.CIRCULAR_REF, "References with same endpoints exist", this.env.refIds[r])
3151
3111
  ];
3152
- const a = St(s.relation);
3112
+ const a = xt(s.relation);
3153
3113
  return this.env.refIds[r] = i, this.env.ref.set(i, {
3154
3114
  name: null,
3155
3115
  schemaName: null,
@@ -3162,40 +3122,40 @@ class Pt {
3162
3122
  {
3163
3123
  schemaName: this.table.schemaName,
3164
3124
  tableName: this.table.name,
3165
- fieldNames: [X(e.callee).unwrap()],
3166
- token: k(e),
3125
+ fieldNames: [G(e.callee).unwrap()],
3126
+ token: x(e),
3167
3127
  relation: a[0]
3168
3128
  }
3169
3129
  ]
3170
3130
  }), [];
3171
3131
  }
3172
3132
  }
3173
- function jn(t) {
3133
+ function Wn(t) {
3174
3134
  let e = null;
3175
- t instanceof H && (e = t.argumentList.elementList.map((r) => ce(r) ? r.expression.literal.value : j(r) ? z(r).unwrap() : X(r).unwrap()).join(","), t = t.callee);
3135
+ t instanceof H && (e = t.argumentList.elementList.map((r) => ce(r) ? r.expression.literal.value : $(r) ? Y(r).unwrap() : G(r).unwrap()).join(","), t = t.callee);
3176
3136
  let n = "";
3177
- for (; t instanceof he; )
3137
+ for (; t instanceof le; )
3178
3138
  n = `[${t.indexer.elementList.map((r) => r.name.expression.literal.value).join(",")}]${n}`, t = t.array;
3179
- const { name: s, schemaName: i } = Ne(t);
3180
- return i.length > 1 && new B(
3139
+ const { name: s, schemaName: i } = Ae(t);
3140
+ return i.length > 1 ? new F(
3181
3141
  {
3182
3142
  schemaName: i.length === 0 ? null : i[0],
3183
3143
  type_name: `${s}${n}${e ? `(${e})` : ""}`,
3184
3144
  args: e
3185
3145
  },
3186
- [new l(o.UNSUPPORTED, "Nested schema is not supported", t)]
3187
- ), new B({
3146
+ [new u(o.UNSUPPORTED, "Nested schema is not supported", t)]
3147
+ ) : new F({
3188
3148
  schemaName: i.length === 0 ? null : i[0],
3189
3149
  type_name: `${s}${n}${e ? `(${e})` : ""}`,
3190
3150
  args: e
3191
3151
  });
3192
3152
  }
3193
- function Yn(t) {
3153
+ function jn(t) {
3194
3154
  var e, n, s;
3195
3155
  if (t) {
3196
- if (j(t))
3156
+ if ($(t))
3197
3157
  return {
3198
- value: z(t).unwrap(),
3158
+ value: Y(t).unwrap(),
3199
3159
  type: "string"
3200
3160
  };
3201
3161
  if (ce(t))
@@ -3203,19 +3163,19 @@ function Yn(t) {
3203
3163
  type: "number",
3204
3164
  value: Number.parseFloat(t.expression.literal.value)
3205
3165
  };
3206
- if (fe(t))
3166
+ if (de(t))
3207
3167
  return {
3208
3168
  value: t.expression.variable.value.toLowerCase(),
3209
3169
  type: "boolean"
3210
3170
  };
3211
- if (t instanceof Q && wt.includes((e = t.op) == null ? void 0 : e.value) && ce(t.expression)) {
3171
+ if (t instanceof Q && vt.includes((e = t.op) == null ? void 0 : e.value) && ce(t.expression)) {
3212
3172
  const i = Number.parseFloat(t.expression.expression.literal.value);
3213
3173
  return {
3214
3174
  value: ((n = t.op) == null ? void 0 : n.value) === "-" ? 0 - i : i,
3215
3175
  type: "number"
3216
3176
  };
3217
3177
  }
3218
- if (t instanceof K)
3178
+ if (t instanceof ee)
3219
3179
  return {
3220
3180
  value: (s = t.value) == null ? void 0 : s.value,
3221
3181
  type: "expression"
@@ -3223,79 +3183,108 @@ function Yn(t) {
3223
3183
  throw new Error("Unreachable");
3224
3184
  }
3225
3185
  }
3226
- class zn {
3186
+ class Dt {
3227
3187
  constructor(e, n) {
3228
- this.declarationNode = e, this.env = n, this.note = { name: void 0, content: void 0, token: void 0 };
3188
+ this.declarationNode = e, this.env = n, this.container = this.declarationNode.parent instanceof _ ? this.env.tables.get(this.declarationNode.parent) : void 0, this.ref = {};
3229
3189
  }
3230
3190
  interpret() {
3231
- return this.note.token = k(this.declarationNode), this.env.notes.set(this.declarationNode, this.note), [
3232
- ...this.interpretName(this.declarationNode.name),
3233
- ...this.interpretSettingList(this.declarationNode.attributeList),
3234
- ...this.interpretBody(this.declarationNode.body)
3235
- ];
3191
+ return this.ref.token = x(this.declarationNode), this.env.ref.set(this.declarationNode, this.ref), [...this.interpretName(this.declarationNode.name), ...this.interpretBody(this.declarationNode.body)];
3236
3192
  }
3237
3193
  interpretName(e) {
3238
- const { name: n } = Ne(e);
3239
- return this.note.name = n, [];
3240
- }
3241
- interpretSettingList(e) {
3242
- var s, i, r;
3243
- const n = $(e).getValue();
3244
- return this.note.headerColor = (s = n.headercolor) != null && s.length ? Ot((r = (i = n.headercolor) == null ? void 0 : i.at(0)) == null ? void 0 : r.value) : void 0, [];
3194
+ const n = [], s = W(this.declarationNode.name).unwrap_or([]);
3195
+ return this.ref.name = s.pop() || null, s.length > 1 && n.push(new u(o.UNSUPPORTED, "Nested schema is not supported", this.declarationNode.name)), this.ref.schemaName = s.join(".") || null, n;
3245
3196
  }
3246
3197
  interpretBody(e) {
3247
- const [n, s] = I.partition(e.body, (i) => i instanceof v);
3248
- return n.length !== 1 || s.length > 0 ? [
3249
- new l(o.INVALID_NOTE, "Invalid note syntax", e)
3250
- ] : [...this.interpretNote(n[0])];
3198
+ return e instanceof k ? this.interpretField(e) : this.interpretField(e.body[0]);
3251
3199
  }
3252
- interpretNote(e) {
3253
- const n = I.get(e, "callee.expression.literal.value", "");
3254
- return this.note.content = n, [];
3200
+ interpretField(e) {
3201
+ var h, T, f, N;
3202
+ const n = e.callee.op.value, { leftExpression: s, rightExpression: i } = e.callee, r = Ce(s), a = Ce(i);
3203
+ if (St(r, a))
3204
+ return [new u(o.SAME_ENDPOINT, "Two endpoints are the same", e)];
3205
+ const l = Ot(r, a);
3206
+ if (this.env.refIds[l])
3207
+ return [
3208
+ new u(o.CIRCULAR_REF, "References with same endpoints exist", this.declarationNode),
3209
+ new u(o.CIRCULAR_REF, "References with same endpoints exist", this.env.refIds[l])
3210
+ ];
3211
+ if (e.args[0]) {
3212
+ const g = z(e.args[0]).getValue();
3213
+ this.ref.onDelete = G((T = (h = g.delete) == null ? void 0 : h.at(0)) == null ? void 0 : T.value).unwrap_or(void 0), this.ref.onDelete = G((N = (f = g.delete) == null ? void 0 : f.at(0)) == null ? void 0 : N.value).unwrap_or(void 0);
3214
+ }
3215
+ const p = xt(n);
3216
+ return this.ref.endpoints = [
3217
+ {
3218
+ ...ft(s, this.container),
3219
+ relation: p[0],
3220
+ token: x(s)
3221
+ },
3222
+ {
3223
+ ...ft(i, this.container),
3224
+ relation: p[1],
3225
+ token: x(i)
3226
+ }
3227
+ ], this.env.refIds[l] = this.declarationNode, [];
3255
3228
  }
3256
3229
  }
3257
- class Ut {
3230
+ class Pt {
3258
3231
  constructor(e, n) {
3259
3232
  this.declarationNode = e, this.env = n, this.tableGroup = { tables: [] };
3260
3233
  }
3261
3234
  interpret() {
3262
3235
  const e = [];
3263
- this.tableGroup.token = k(this.declarationNode), this.env.tableGroups.set(this.declarationNode, this.tableGroup);
3264
- const { name: n, schemaName: s } = Ne(this.declarationNode.name);
3265
- return s.length >= 2 && (this.tableGroup.name = n, this.tableGroup.schemaName = s.join("."), e.push(new l(o.UNSUPPORTED, "Nested schema is not supported", this.declarationNode.name))), this.tableGroup.name = n, this.tableGroup.schemaName = s[0] || null, this.tableGroup.tables = this.declarationNode.body.body.map((i) => {
3266
- const r = C(i.callee).unwrap();
3267
- return r.length > 2 && e.push(new l(o.UNSUPPORTED, "Nested schema is not supported", i)), {
3268
- name: r.pop(),
3269
- schemaName: r.join(".")
3236
+ return this.tableGroup.token = x(this.declarationNode), this.env.tableGroups.set(this.declarationNode, this.tableGroup), e.push(
3237
+ ...this.interpretName(this.declarationNode.name),
3238
+ ...this.interpretBody(this.declarationNode.body)
3239
+ ), e;
3240
+ }
3241
+ interpretName(e) {
3242
+ const n = [], { name: s, schemaName: i } = Ae(e);
3243
+ return i.length >= 2 && (this.tableGroup.name = s, this.tableGroup.schemaName = i.join("."), n.push(new u(o.UNSUPPORTED, "Nested schema is not supported", this.declarationNode.name))), this.tableGroup.name = s, this.tableGroup.schemaName = i[0] || null, n;
3244
+ }
3245
+ interpretBody(e) {
3246
+ const n = [];
3247
+ return this.tableGroup.tables = this.declarationNode.body.body.map((s) => {
3248
+ const i = W(s.callee).unwrap();
3249
+ i.length > 2 && n.push(new u(o.UNSUPPORTED, "Nested schema is not supported", s));
3250
+ const r = ue(s.callee).unwrap().pop().referee.id;
3251
+ if (this.env.groupOfTable[r]) {
3252
+ const a = this.env.groupOfTable[r], { schemaName: l, name: p } = this.env.tableGroups.get(a), h = l ? `${l}.${p}` : p;
3253
+ n.push(new u(o.TABLE_REAPPEAR_IN_TABLEGROUP, `Table "${i.join(".")}" already appears in group "${h}"`, s));
3254
+ } else
3255
+ this.env.groupOfTable[r] = this.declarationNode;
3256
+ return {
3257
+ name: i.pop(),
3258
+ schemaName: i.join(".")
3270
3259
  };
3271
- }), e;
3260
+ }), n;
3272
3261
  }
3273
3262
  }
3274
- class Mt {
3263
+ class Ut {
3275
3264
  constructor(e, n) {
3276
3265
  this.declarationNode = e, this.env = n, this.enum = { values: [] };
3277
3266
  }
3278
3267
  interpret() {
3279
- return this.enum.token = k(this.declarationNode), this.env.enums.set(this.declarationNode, this.enum), [...this.interpretName(this.declarationNode.name), ...this.interpretBody(this.declarationNode.body)];
3268
+ return this.enum.token = x(this.declarationNode), this.env.enums.set(this.declarationNode, this.enum), [...this.interpretName(this.declarationNode.name), ...this.interpretBody(this.declarationNode.body)];
3280
3269
  }
3281
3270
  interpretName(e) {
3282
- const { name: n, schemaName: s } = Ne(e);
3283
- return s.length > 1 ? (this.enum.name = n, this.enum.schemaName = s.join("."), [new l(o.UNSUPPORTED, "Nested schema is not supported", e)]) : (this.enum.name = n, this.enum.schemaName = s.length ? s[0] : null, []);
3271
+ const { name: n, schemaName: s } = Ae(e);
3272
+ return s.length > 1 ? (this.enum.name = n, this.enum.schemaName = s.join("."), [new u(o.UNSUPPORTED, "Nested schema is not supported", e)]) : (this.enum.name = n, this.enum.schemaName = s.length ? s[0] : null, []);
3284
3273
  }
3285
3274
  interpretBody(e) {
3286
3275
  return e.body.flatMap((n) => {
3287
- var c;
3276
+ var l;
3288
3277
  const s = n, i = {};
3289
- i.token = k(s), i.name = X(s.callee).unwrap();
3290
- const a = (c = $(s.args[0]).getValue().note) == null ? void 0 : c.at(0);
3278
+ i.token = x(s), i.name = G(s.callee).unwrap();
3279
+ const a = (l = z(s.args[0]).getValue().note) == null ? void 0 : l.at(0);
3291
3280
  return i.note = a && {
3292
- value: z(a.value).unwrap(),
3293
- token: k(a)
3281
+ value: Y(a.value).unwrap(),
3282
+ token: x(a)
3294
3283
  }, this.enum.values.push(i), [];
3295
3284
  });
3296
3285
  }
3297
3286
  }
3298
- class Qn {
3287
+ class Yn {
3299
3288
  constructor(e, n) {
3300
3289
  this.declarationNode = e, this.env = n, this.project = { enums: [], refs: [], tableGroups: [], tables: [] };
3301
3290
  }
@@ -3305,7 +3294,7 @@ class Qn {
3305
3294
  interpretName(e) {
3306
3295
  if (!e)
3307
3296
  return this.project.name = null, [];
3308
- const { name: n } = Ne(e);
3297
+ const { name: n } = Ae(e);
3309
3298
  return this.project.name = n, [];
3310
3299
  }
3311
3300
  interpretBody(e) {
@@ -3314,73 +3303,70 @@ class Qn {
3314
3303
  const s = n;
3315
3304
  switch ((i = s.type) == null ? void 0 : i.value.toLowerCase()) {
3316
3305
  case "table": {
3317
- const r = new Pt(s, this.env).interpret();
3306
+ const r = new Rt(s, this.env).interpret();
3318
3307
  return this.project.tables.push(this.env.tables.get(s)), r;
3319
3308
  }
3320
3309
  case "ref": {
3321
- const r = new Ke(s, this.env).interpret();
3310
+ const r = new Dt(s, this.env).interpret();
3322
3311
  return this.project.refs.push(this.env.ref.get(s)), r;
3323
3312
  }
3324
3313
  case "tablegroup": {
3325
- const r = new Ut(s, this.env).interpret();
3314
+ const r = new Pt(s, this.env).interpret();
3326
3315
  return this.project.tableGroups.push(this.env.tableGroups.get(s)), r;
3327
3316
  }
3328
3317
  case "enum": {
3329
- const r = new Mt(s, this.env).interpret();
3318
+ const r = new Ut(s, this.env).interpret();
3330
3319
  return this.project.enums.push(this.env.enums.get(s)), r;
3331
3320
  }
3332
3321
  case "note":
3333
3322
  return this.project.note = {
3334
- value: z(s.body instanceof ee ? s.body.body[0].callee : s.body.callee).unwrap(),
3335
- token: k(s)
3323
+ value: Y(s.body instanceof te ? s.body.body[0].callee : s.body.callee).unwrap(),
3324
+ token: x(s)
3336
3325
  }, [];
3337
3326
  default:
3338
- return this.project[s.type.value.toLowerCase()] = z(s.body.callee).unwrap(), [];
3327
+ return this.project[s.type.value.toLowerCase()] = Y(s.body.callee).unwrap(), [];
3339
3328
  }
3340
3329
  });
3341
3330
  }
3342
3331
  }
3343
- class qn {
3332
+ class zn {
3344
3333
  constructor(e) {
3345
3334
  this.ast = e, this.env = {
3346
3335
  schema: [],
3347
3336
  tables: /* @__PURE__ */ new Map(),
3348
- notes: /* @__PURE__ */ new Map(),
3349
3337
  refIds: {},
3350
3338
  ref: /* @__PURE__ */ new Map(),
3351
3339
  enums: /* @__PURE__ */ new Map(),
3352
3340
  tableGroups: /* @__PURE__ */ new Map(),
3341
+ groupOfTable: {},
3353
3342
  aliases: [],
3354
3343
  project: /* @__PURE__ */ new Map()
3355
3344
  };
3356
3345
  }
3357
3346
  interpret() {
3358
3347
  const e = this.ast.body.flatMap((n) => {
3359
- switch (de(n).unwrap_or(void 0)) {
3348
+ switch (ge(n).unwrap_or(void 0)) {
3360
3349
  case b.Table:
3361
- return new Pt(n, this.env).interpret();
3362
- case b.Note:
3363
- return new zn(n, this.env).interpret();
3350
+ return new Rt(n, this.env).interpret();
3364
3351
  case b.Ref:
3365
- return new Ke(n, this.env).interpret();
3352
+ return new Dt(n, this.env).interpret();
3366
3353
  case b.TableGroup:
3367
- return new Ut(n, this.env).interpret();
3354
+ return new Pt(n, this.env).interpret();
3368
3355
  case b.Enum:
3369
- return new Mt(n, this.env).interpret();
3356
+ return new Ut(n, this.env).interpret();
3370
3357
  case b.Project:
3371
- return new Qn(n, this.env).interpret();
3358
+ return new Yn(n, this.env).interpret();
3372
3359
  default:
3373
3360
  return [];
3374
3361
  }
3375
3362
  });
3376
- return new B(Hn(this.env), e);
3363
+ return new F(Qn(this.env), e);
3377
3364
  }
3378
3365
  }
3379
- function Hn(t) {
3366
+ function Qn(t) {
3380
3367
  return {
3381
3368
  schemas: [],
3382
3369
  tables: Array.from(t.tables.values()),
3383
- notes: Array.from(t.notes.values()),
3384
3370
  refs: Array.from(t.ref.values()),
3385
3371
  enums: Array.from(t.enums.values()),
3386
3372
  tableGroups: Array.from(t.tableGroups.values()),
@@ -3388,8 +3374,8 @@ function Hn(t) {
3388
3374
  project: Array.from(t.project.values())[0] || {}
3389
3375
  };
3390
3376
  }
3391
- 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 || {});
3392
- function _e(t) {
3377
+ 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 || {});
3378
+ function Le(t) {
3393
3379
  switch (t) {
3394
3380
  case m.Schema:
3395
3381
  return L.Module;
@@ -3409,23 +3395,23 @@ function _e(t) {
3409
3395
  return L.Text;
3410
3396
  }
3411
3397
  }
3412
- function Se(t, e) {
3398
+ function Oe(t, e) {
3413
3399
  if (!t || Ve(t))
3414
3400
  return !1;
3415
3401
  for (const n of t.trailingTrivia) {
3416
3402
  if (n.start > e)
3417
3403
  break;
3418
- if (n.kind === u.NEWLINE && n.end <= e)
3404
+ if (n.kind === c.NEWLINE && n.end <= e)
3419
3405
  return !1;
3420
3406
  }
3421
3407
  return !0;
3422
3408
  }
3423
- function O() {
3409
+ function S() {
3424
3410
  return {
3425
3411
  suggestions: []
3426
3412
  };
3427
3413
  }
3428
- function Oe(t) {
3414
+ function Se(t) {
3429
3415
  return {
3430
3416
  ...t,
3431
3417
  suggestions: t.suggestions.map((e) => ({
@@ -3443,29 +3429,29 @@ function Ue(t) {
3443
3429
  }))
3444
3430
  };
3445
3431
  }
3446
- function et(t, e) {
3432
+ function Ke(t, e) {
3447
3433
  return t.getOffsetAt(e);
3448
3434
  }
3449
- class Ft {
3435
+ class Mt {
3450
3436
  constructor(e, n = []) {
3451
3437
  this.compiler = e, this.triggerCharacters = n;
3452
3438
  }
3453
3439
  provideCompletionItems(e, n) {
3454
3440
  var T, f;
3455
- const s = et(e, n), i = this.compiler.token.flatStream(), { token: r, index: a } = this.compiler.container.token(s), c = a === void 0 ? i[0] : i[a + 1];
3441
+ const s = Ke(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];
3456
3442
  if ([
3457
3443
  ...(r == null ? void 0 : r.trailingTrivia) || [],
3458
3444
  ...(r == null ? void 0 : r.leadingTrivia) || [],
3459
- ...(c == null ? void 0 : c.leadingTrivia) || []
3460
- ].find((N) => Wt(N) && Le(s, N)))
3461
- return O();
3445
+ ...(l == null ? void 0 : l.leadingTrivia) || []
3446
+ ].find((N) => $t(N) && be(s, N)))
3447
+ return S();
3462
3448
  if (a === void 0)
3463
- return Tt();
3464
- if ([u.STRING_LITERAL, u.QUOTED_STRING].includes(r.kind) && Le(s, r))
3465
- return O();
3449
+ return mt();
3450
+ if ([c.STRING_LITERAL, c.QUOTED_STRING].includes(r.kind) && be(s, r))
3451
+ return S();
3466
3452
  const p = this.compiler.container.element(s);
3467
- if (this.compiler.container.scopeKind(s) === D.TOPLEVEL || p instanceof _ && p.type && p.type.start <= s && p.type.end >= s)
3468
- return Tt();
3453
+ if (this.compiler.container.scopeKind(s) === R.TOPLEVEL || p instanceof _ && p.type && p.type.start <= s && p.type.end >= s)
3454
+ return mt();
3469
3455
  const h = [...this.compiler.container.stack(s)].reverse();
3470
3456
  for (const N of h)
3471
3457
  if (N instanceof Q)
@@ -3474,7 +3460,7 @@ class Ft {
3474
3460
  case "<":
3475
3461
  case "<>":
3476
3462
  case "-":
3477
- return dt(
3463
+ return pt(
3478
3464
  this.compiler,
3479
3465
  s,
3480
3466
  N
@@ -3486,13 +3472,13 @@ class Ft {
3486
3472
  case "<":
3487
3473
  case "<>":
3488
3474
  case "-":
3489
- return dt(
3475
+ return pt(
3490
3476
  this.compiler,
3491
3477
  s,
3492
3478
  N
3493
3479
  );
3494
3480
  case ".":
3495
- return Bt(
3481
+ return Ft(
3496
3482
  this.compiler,
3497
3483
  s,
3498
3484
  N
@@ -3500,47 +3486,47 @@ class Ft {
3500
3486
  }
3501
3487
  else {
3502
3488
  if (N instanceof ne)
3503
- return Et(this.compiler, s, N);
3504
- if (N instanceof U)
3505
- return Et(this.compiler, s, N);
3489
+ return dt(this.compiler, s, N);
3490
+ if (N instanceof P)
3491
+ return dt(this.compiler, s, N);
3506
3492
  if (N instanceof J)
3507
- return Jn(this.compiler, s);
3508
- if (N instanceof v)
3509
- return mt(this.compiler, s, N);
3510
- if (N instanceof _ && (N.bodyColon && s >= N.bodyColon.end || N.body && Le(s, N.body)))
3511
- return mt(this.compiler, s, void 0);
3493
+ return qn(this.compiler, s);
3494
+ if (N instanceof k)
3495
+ return Nt(this.compiler, s, N);
3496
+ if (N instanceof _ && (N.bodyColon && s >= N.bodyColon.end || N.body && be(s, N.body)))
3497
+ return Nt(this.compiler, s, void 0);
3512
3498
  }
3513
- return O();
3499
+ return S();
3514
3500
  }
3515
3501
  }
3516
- function dt(t, e, n) {
3502
+ function pt(t, e, n) {
3517
3503
  const s = t.container.scopeKind(e);
3518
- if ([D.REF, D.TABLE].includes(s)) {
3504
+ if ([R.REF, R.TABLE].includes(s)) {
3519
3505
  const i = Me(t, e, t.container.element(e), [
3520
3506
  m.Table,
3521
3507
  m.Schema,
3522
3508
  m.Column
3523
3509
  ]);
3524
- return Se(n.op, e) ? Oe(i) : i;
3510
+ return Oe(n.op, e) ? Se(i) : i;
3525
3511
  }
3526
- return O();
3512
+ return S();
3527
3513
  }
3528
3514
  function Me(t, e, n, s) {
3529
3515
  var a;
3530
3516
  if (n === void 0)
3531
- return O();
3517
+ return S();
3532
3518
  let i = n;
3533
3519
  const r = { suggestions: [] };
3534
3520
  for (; i; ) {
3535
3521
  if ((a = i == null ? void 0 : i.symbol) != null && a.symbolTable) {
3536
- const { symbol: c } = i;
3522
+ const { symbol: l } = i;
3537
3523
  r.suggestions.push(
3538
- ...t.symbol.members(c).filter(({ kind: p }) => s.includes(p)).map(({ name: p, kind: h }) => ({
3524
+ ...t.symbol.members(l).filter(({ kind: p }) => s.includes(p)).map(({ name: p, kind: h }) => ({
3539
3525
  label: p,
3540
3526
  insertText: p,
3541
- insertTextRules: y.KeepWhitespace,
3542
- kind: _e(h),
3543
- sortText: _e(h).toString().padStart(2, "0"),
3527
+ insertTextRules: w.KeepWhitespace,
3528
+ kind: Le(h),
3529
+ sortText: Le(h).toString().padStart(2, "0"),
3544
3530
  range: void 0
3545
3531
  }))
3546
3532
  );
@@ -3549,120 +3535,120 @@ function Me(t, e, n, s) {
3549
3535
  }
3550
3536
  return Ue(r);
3551
3537
  }
3552
- function Jn(t, e) {
3538
+ function qn(t, e) {
3553
3539
  var s;
3554
3540
  switch (t.container.scopeKind(e)) {
3555
- case D.INDEXES:
3556
- return Gt(t, e);
3557
- case D.REF:
3541
+ case R.INDEXES:
3542
+ return Vt(t, e);
3543
+ case R.REF:
3558
3544
  {
3559
3545
  const i = [...t.container.stack(e)];
3560
3546
  for (; i.length > 0; ) {
3561
3547
  const r = i.pop();
3562
3548
  if (r instanceof q && ((s = r.op) == null ? void 0 : s.value) === ".")
3563
- return Bt(
3549
+ return Ft(
3564
3550
  t,
3565
3551
  e,
3566
3552
  r
3567
3553
  );
3568
3554
  }
3569
3555
  }
3570
- return Vt(t, e);
3556
+ return Bt(t, e);
3571
3557
  }
3572
- return O();
3558
+ return S();
3573
3559
  }
3574
- function Et(t, e, n) {
3560
+ function dt(t, e, n) {
3575
3561
  const { token: s } = t.container.token(e);
3576
- if ([u.COMMA, u.LBRACKET].includes(s == null ? void 0 : s.kind)) {
3577
- const i = Nt(t, e);
3578
- return (s == null ? void 0 : s.kind) === u.COMMA && Se(s, e) ? Oe(i) : i;
3562
+ if ([c.COMMA, c.LBRACKET].includes(s == null ? void 0 : s.kind)) {
3563
+ const i = Et(t, e);
3564
+ return (s == null ? void 0 : s.kind) === c.COMMA && Oe(s, e) ? Se(i) : i;
3579
3565
  }
3580
3566
  if (n.name && n.name.start <= e && n.name.end >= e)
3581
- return Nt(t, e);
3582
- if (n.name) {
3583
- const i = Zn(
3567
+ return Et(t, e);
3568
+ if (n.name instanceof K) {
3569
+ const i = Hn(
3584
3570
  t,
3585
3571
  e,
3586
- Re(n.name).unwrap()
3572
+ De(n.name).unwrap()
3587
3573
  );
3588
- return (s == null ? void 0 : s.kind) === u.COLON && Se(s, e) ? Oe(i) : i;
3574
+ return (s == null ? void 0 : s.kind) === c.COLON && Oe(s, e) ? Se(i) : i;
3589
3575
  }
3590
- return O();
3576
+ return S();
3591
3577
  }
3592
- function Nt(t, e) {
3578
+ function Et(t, e) {
3593
3579
  const n = t.container.element(e), s = t.container.scopeKind(e);
3594
- if (n instanceof F)
3595
- return O();
3596
- if (n.body && !Le(e, n.body))
3580
+ if (n instanceof C)
3581
+ return S();
3582
+ if (n.body && !be(e, n.body))
3597
3583
  switch (s) {
3598
- case D.TABLE:
3584
+ case R.TABLE:
3599
3585
  return {
3600
3586
  suggestions: [
3601
3587
  {
3602
3588
  label: "headercolor",
3603
3589
  insertText: "headercolor: ",
3604
3590
  kind: L.Field,
3605
- insertTextRules: y.KeepWhitespace,
3591
+ insertTextRules: w.KeepWhitespace,
3606
3592
  range: void 0
3607
3593
  },
3608
3594
  {
3609
3595
  label: "note",
3610
3596
  insertText: "note: ",
3611
3597
  kind: L.Field,
3612
- insertTextRules: y.KeepWhitespace,
3598
+ insertTextRules: w.KeepWhitespace,
3613
3599
  range: void 0
3614
3600
  }
3615
3601
  ]
3616
3602
  };
3617
3603
  default:
3618
- return O();
3604
+ return S();
3619
3605
  }
3620
3606
  switch (s) {
3621
- case D.TABLE:
3607
+ case R.TABLE:
3622
3608
  return {
3623
3609
  suggestions: [
3624
3610
  ...["primary key", "null", "not null", "increment", "pk", "unique"].map((i) => ({
3625
3611
  label: i,
3626
3612
  insertText: i,
3627
3613
  kind: L.Property,
3628
- insertTextRules: y.KeepWhitespace,
3614
+ insertTextRules: w.KeepWhitespace,
3629
3615
  range: void 0
3630
3616
  })),
3631
3617
  ...["ref", "default"].map((i) => ({
3632
3618
  label: i,
3633
3619
  insertText: `${i}: `,
3634
3620
  kind: L.Property,
3635
- insertTextRules: y.KeepWhitespace,
3621
+ insertTextRules: w.KeepWhitespace,
3636
3622
  range: void 0
3637
3623
  })),
3638
3624
  {
3639
3625
  label: "note",
3640
3626
  insertText: "note: ",
3641
3627
  kind: L.Property,
3642
- insertTextRules: y.KeepWhitespace,
3628
+ insertTextRules: w.KeepWhitespace,
3643
3629
  range: void 0
3644
3630
  }
3645
3631
  ]
3646
3632
  };
3647
- case D.ENUM:
3633
+ case R.ENUM:
3648
3634
  return {
3649
3635
  suggestions: [
3650
3636
  {
3651
3637
  label: "note",
3652
3638
  insertText: "note: ",
3653
3639
  kind: L.Property,
3654
- insertTextRules: y.KeepWhitespace,
3640
+ insertTextRules: w.KeepWhitespace,
3655
3641
  range: void 0
3656
3642
  }
3657
3643
  ]
3658
3644
  };
3659
- case D.INDEXES:
3645
+ case R.INDEXES:
3660
3646
  return {
3661
3647
  suggestions: [
3662
3648
  ...["unique", "pk"].map((i) => ({
3663
3649
  label: i,
3664
3650
  insertText: i,
3665
- insertTextRules: y.KeepWhitespace,
3651
+ insertTextRules: w.KeepWhitespace,
3666
3652
  kind: L.Property,
3667
3653
  range: void 0
3668
3654
  })),
@@ -3670,25 +3656,25 @@ function Nt(t, e) {
3670
3656
  label: i,
3671
3657
  insertText: `${i}: `,
3672
3658
  kind: L.Property,
3673
- insertTextRules: y.KeepWhitespace,
3659
+ insertTextRules: w.KeepWhitespace,
3674
3660
  range: void 0
3675
3661
  }))
3676
3662
  ]
3677
3663
  };
3678
- case D.REF:
3664
+ case R.REF:
3679
3665
  return {
3680
3666
  suggestions: ["update", "delete"].map((i) => ({
3681
3667
  label: i,
3682
3668
  insertText: `${i}: `,
3683
3669
  kind: L.Property,
3684
- insertTextRules: y.KeepWhitespace,
3670
+ insertTextRules: w.KeepWhitespace,
3685
3671
  range: void 0
3686
3672
  }))
3687
3673
  };
3688
3674
  }
3689
- return O();
3675
+ return S();
3690
3676
  }
3691
- function Zn(t, e, n) {
3677
+ function Hn(t, e, n) {
3692
3678
  switch (n == null ? void 0 : n.toLowerCase()) {
3693
3679
  case "update":
3694
3680
  case "delete":
@@ -3697,7 +3683,7 @@ function Zn(t, e, n) {
3697
3683
  label: s,
3698
3684
  insertText: s,
3699
3685
  kind: L.Value,
3700
- insertTextRules: y.KeepWhitespace,
3686
+ insertTextRules: w.KeepWhitespace,
3701
3687
  range: void 0
3702
3688
  }))
3703
3689
  };
@@ -3707,115 +3693,115 @@ function Zn(t, e, n) {
3707
3693
  label: s,
3708
3694
  insertText: `${s}`,
3709
3695
  kind: L.Value,
3710
- insertTextRules: y.KeepWhitespace,
3696
+ insertTextRules: w.KeepWhitespace,
3711
3697
  range: void 0
3712
3698
  }))
3713
3699
  };
3714
3700
  }
3715
- return O();
3701
+ return S();
3716
3702
  }
3717
- function Bt(t, e, n) {
3718
- const s = Ee(n).unwrap_or([]);
3703
+ function Ft(t, e, n) {
3704
+ const s = ue(n).unwrap_or([]);
3719
3705
  if (s.pop(), s.some((r) => !M(r)))
3720
- return O();
3721
- const i = s.map((r) => X(r).unwrap());
3706
+ return S();
3707
+ const i = s.map((r) => G(r).unwrap());
3722
3708
  return Ue({
3723
3709
  suggestions: t.symbol.ofName({ nameStack: i, owner: t.container.element(e) }).flatMap(({ symbol: r }) => t.symbol.members(r)).map(({ kind: r, name: a }) => ({
3724
3710
  label: a,
3725
3711
  insertText: a,
3726
- kind: _e(r),
3712
+ kind: Le(r),
3727
3713
  range: void 0
3728
3714
  }))
3729
3715
  });
3730
3716
  }
3731
- function mt(t, e, n) {
3717
+ function Nt(t, e, n) {
3732
3718
  var i;
3733
3719
  switch (t.container.scopeKind(e)) {
3734
- case D.TABLE:
3735
- return es(t, e, n);
3736
- case D.PROJECT:
3737
- return ts(t, e, n);
3738
- case D.INDEXES:
3739
- return ss(t, e);
3740
- case D.ENUM:
3720
+ case R.TABLE:
3721
+ return Zn(t, e, n);
3722
+ case R.PROJECT:
3741
3723
  return Kn(t, e, n);
3742
- case D.REF: {
3743
- const r = Vt(t, e);
3744
- return ((i = t.container.token(e).token) == null ? void 0 : i.kind) === u.COLON && Se(t.container.token(e).token, e) ? Oe(r) : r;
3724
+ case R.INDEXES:
3725
+ return ts(t, e);
3726
+ case R.ENUM:
3727
+ return Jn(t, e, n);
3728
+ case R.REF: {
3729
+ const r = Bt(t, e);
3730
+ return ((i = t.container.token(e).token) == null ? void 0 : i.kind) === c.COLON && Oe(t.container.token(e).token, e) ? Se(r) : r;
3745
3731
  }
3746
- case D.TABLEGROUP:
3747
- return ns(t);
3732
+ case R.TABLEGROUP:
3733
+ return es(t);
3748
3734
  default:
3749
- return O();
3735
+ return S();
3750
3736
  }
3751
3737
  }
3752
- function Tt() {
3738
+ function mt() {
3753
3739
  return {
3754
3740
  suggestions: ["Table", "TableGroup", "Enum", "Project", "Ref"].map((t) => ({
3755
3741
  label: t,
3756
3742
  insertText: t,
3757
- insertTextRules: y.KeepWhitespace,
3743
+ insertTextRules: w.KeepWhitespace,
3758
3744
  kind: L.Keyword,
3759
3745
  range: void 0
3760
3746
  }))
3761
3747
  };
3762
3748
  }
3763
- function Kn(t, e, n) {
3764
- return n != null && n.callee && tt(e, n) === 1 ? Me(t, e, t.container.element(e), [
3749
+ function Jn(t, e, n) {
3750
+ return n != null && n.callee && et(e, n) === 1 ? Me(t, e, t.container.element(e), [
3765
3751
  m.Schema,
3766
3752
  m.Table,
3767
3753
  m.Column
3768
- ]) : O();
3754
+ ]) : S();
3769
3755
  }
3770
- function es(t, e, n) {
3756
+ function Zn(t, e, n) {
3771
3757
  if (!(n != null && n.callee))
3772
3758
  return {
3773
- suggestions: ["Ref", "Note", "indexes"].map((i) => ({
3759
+ suggestions: ["Note", "indexes"].map((i) => ({
3774
3760
  label: i,
3775
3761
  insertText: i,
3776
- insertTextRules: y.KeepWhitespace,
3762
+ insertTextRules: w.KeepWhitespace,
3777
3763
  kind: L.Keyword,
3778
3764
  range: void 0
3779
3765
  }))
3780
3766
  };
3781
- const s = tt(e, n);
3767
+ const s = et(e, n);
3782
3768
  return s === 0 ? {
3783
- suggestions: ["Ref", "Note", "indexes"].map((i) => ({
3769
+ suggestions: ["Note", "indexes"].map((i) => ({
3784
3770
  label: i,
3785
3771
  insertText: i,
3786
- insertTextRules: y.KeepWhitespace,
3772
+ insertTextRules: w.KeepWhitespace,
3787
3773
  kind: L.Keyword,
3788
3774
  range: void 0
3789
3775
  }))
3790
- } : s === 1 ? is(t, e) : O();
3776
+ } : s === 1 ? ns(t, e) : S();
3791
3777
  }
3792
- function ts(t, e, n) {
3793
- return n != null && n.callee ? tt(e, n) === 0 ? {
3778
+ function Kn(t, e, n) {
3779
+ return n != null && n.callee ? et(e, n) === 0 ? {
3794
3780
  suggestions: ["Table", "TableGroup", "Enum", "Note", "Ref"].map((i) => ({
3795
3781
  label: i,
3796
3782
  insertText: i,
3797
- insertTextRules: y.KeepWhitespace,
3783
+ insertTextRules: w.KeepWhitespace,
3798
3784
  kind: L.Keyword,
3799
3785
  range: void 0
3800
3786
  }))
3801
- } : O() : {
3787
+ } : S() : {
3802
3788
  suggestions: ["Table", "TableGroup", "Enum", "Note", "Ref"].map((i) => ({
3803
3789
  label: i,
3804
3790
  insertText: i,
3805
- insertTextRules: y.KeepWhitespace,
3791
+ insertTextRules: w.KeepWhitespace,
3806
3792
  kind: L.Keyword,
3807
3793
  range: void 0
3808
3794
  }))
3809
3795
  };
3810
3796
  }
3811
- function Vt(t, e) {
3797
+ function Bt(t, e) {
3812
3798
  return Me(t, e, t.container.element(e), [
3813
3799
  m.Schema,
3814
3800
  m.Table,
3815
3801
  m.Column
3816
3802
  ]);
3817
3803
  }
3818
- function ns(t) {
3804
+ function es(t) {
3819
3805
  return Ue({
3820
3806
  suggestions: [...t.parse.publicSymbolTable().entries()].flatMap(([e]) => {
3821
3807
  const n = se(e).unwrap_or(void 0);
@@ -3825,17 +3811,17 @@ function ns(t) {
3825
3811
  return s !== m.Table && s !== m.Schema ? [] : {
3826
3812
  label: i,
3827
3813
  insertText: i,
3828
- insertTextRules: y.KeepWhitespace,
3829
- kind: _e(s),
3814
+ insertTextRules: w.KeepWhitespace,
3815
+ kind: Le(s),
3830
3816
  range: void 0
3831
3817
  };
3832
3818
  })
3833
3819
  });
3834
3820
  }
3835
- function ss(t, e) {
3836
- return Gt(t, e);
3821
+ function ts(t, e) {
3822
+ return Vt(t, e);
3837
3823
  }
3838
- function is(t, e) {
3824
+ function ns(t, e) {
3839
3825
  return {
3840
3826
  suggestions: [
3841
3827
  ...[
@@ -3898,7 +3884,7 @@ function is(t, e) {
3898
3884
  ].map((n) => ({
3899
3885
  label: n,
3900
3886
  insertText: n,
3901
- insertTextRules: y.KeepWhitespace,
3887
+ insertTextRules: w.KeepWhitespace,
3902
3888
  kind: L.TypeParameter,
3903
3889
  sortText: L.TypeParameter.toString().padStart(2, "0"),
3904
3890
  range: void 0
@@ -3910,44 +3896,44 @@ function is(t, e) {
3910
3896
  ]
3911
3897
  };
3912
3898
  }
3913
- function Gt(t, e) {
3914
- const s = t.container.element(e).parent;
3915
- if (!((s == null ? void 0 : s.symbol) instanceof At))
3916
- return O();
3899
+ function Vt(t, e) {
3900
+ const n = t.container.element(e), s = n == null ? void 0 : n.parent;
3901
+ if (!((s == null ? void 0 : s.symbol) instanceof _t))
3902
+ return S();
3917
3903
  const { symbolTable: i } = s.symbol;
3918
3904
  return Ue({
3919
3905
  suggestions: [...i.entries()].flatMap(([r]) => {
3920
3906
  const a = se(r).unwrap_or(void 0);
3921
3907
  if (a === void 0)
3922
3908
  return [];
3923
- const { name: c } = a;
3909
+ const { name: l } = a;
3924
3910
  return {
3925
- label: c,
3926
- insertText: c,
3927
- insertTextRules: y.KeepWhitespace,
3928
- kind: _e(m.Column),
3911
+ label: l,
3912
+ insertText: l,
3913
+ insertTextRules: w.KeepWhitespace,
3914
+ kind: Le(m.Column),
3929
3915
  range: void 0
3930
3916
  };
3931
3917
  })
3932
3918
  });
3933
3919
  }
3934
- function tt(t, e) {
3920
+ function et(t, e) {
3935
3921
  if (!e.callee)
3936
3922
  return -1;
3937
3923
  const n = [e.callee, ...e.args], s = n.findIndex((i) => t <= i.end);
3938
3924
  return s === -1 ? n.length : s;
3939
3925
  }
3940
- class Ct {
3926
+ class Gt {
3941
3927
  constructor(e) {
3942
3928
  this.compiler = e;
3943
3929
  }
3944
3930
  provideDefinition(e, n) {
3945
3931
  var a;
3946
- const { uri: s } = e, i = et(e, n), r = [...this.compiler.container.stack(i)];
3932
+ const { uri: s } = e, i = Ke(e, n), r = [...this.compiler.container.stack(i)];
3947
3933
  for (; r.length !== 0; ) {
3948
- const c = r.pop();
3949
- if ((a = c == null ? void 0 : c.referee) != null && a.declaration && [ue.PRIMARY_EXPRESSION, ue.VARIABLE].includes(c == null ? void 0 : c.kind)) {
3950
- const { startPos: p, endPos: h } = c.referee.declaration;
3934
+ const l = r.pop();
3935
+ if ((a = l == null ? void 0 : l.referee) != null && a.declaration && [pe.PRIMARY_EXPRESSION, pe.VARIABLE].includes(l == null ? void 0 : l.kind)) {
3936
+ const { startPos: p, endPos: h } = l.referee.declaration;
3951
3937
  return [
3952
3938
  {
3953
3939
  range: {
@@ -3964,22 +3950,22 @@ class Ct {
3964
3950
  return [];
3965
3951
  }
3966
3952
  }
3967
- class Xt {
3953
+ class Ct {
3968
3954
  constructor(e) {
3969
3955
  this.compiler = e;
3970
3956
  }
3971
3957
  provideReferences(e, n) {
3972
- const { uri: s } = e, i = et(e, n), r = [...this.compiler.container.stack(i)];
3958
+ const { uri: s } = e, i = Ke(e, n), r = [...this.compiler.container.stack(i)];
3973
3959
  for (; r.length !== 0; ) {
3974
3960
  const a = r.pop();
3975
3961
  if (a && [
3976
- ue.ELEMENT_DECLARATION,
3977
- ue.FUNCTION_APPLICATION,
3978
- ue.PRIMARY_EXPRESSION
3962
+ pe.ELEMENT_DECLARATION,
3963
+ pe.FUNCTION_APPLICATION,
3964
+ pe.PRIMARY_EXPRESSION
3979
3965
  ].includes(a == null ? void 0 : a.kind)) {
3980
- const { symbol: c } = a;
3981
- if (c != null && c.references.length)
3982
- return c.references.map(({ startPos: p, endPos: h }) => ({
3966
+ const { symbol: l } = a;
3967
+ if (l != null && l.references.length)
3968
+ return l.references.map(({ startPos: p, endPos: h }) => ({
3983
3969
  range: {
3984
3970
  startColumn: p.column + 1,
3985
3971
  startLineNumber: p.line + 1,
@@ -3993,24 +3979,24 @@ class Xt {
3993
3979
  return [];
3994
3980
  }
3995
3981
  }
3996
- const os = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3982
+ const rs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3997
3983
  __proto__: null,
3998
- CompletionItemInsertTextRule: y,
3984
+ CompletionItemInsertTextRule: w,
3999
3985
  CompletionItemKind: L,
4000
- DBMLCompletionItemProvider: Ft,
4001
- DBMLDefinitionProvider: Ct,
4002
- DBMLReferencesProvider: Xt
3986
+ DBMLCompletionItemProvider: Mt,
3987
+ DBMLDefinitionProvider: Gt,
3988
+ DBMLReferencesProvider: Ct
4003
3989
  }, Symbol.toStringTag, { value: "Module" }));
4004
- var D = /* @__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))(D || {});
4005
- class cs {
3990
+ var R = /* @__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))(R || {});
3991
+ class as {
4006
3992
  constructor() {
4007
3993
  this.source = "", this.cache = new Array(
4008
3994
  16
4009
3995
  /* TOTAL_QUERY_COUNT */
4010
- ).fill(null), this.nodeIdGenerator = new jt(), this.symbolIdGenerator = new Ht(), this.token = {
3996
+ ).fill(null), this.nodeIdGenerator = new Wt(), this.symbolIdGenerator = new Qt(), this.token = {
4011
3997
  invalidStream: this.createQuery(
4012
3998
  6,
4013
- () => this.parse.tokens().filter(vt)
3999
+ () => this.parse.tokens().filter(At)
4014
4000
  ),
4015
4001
  // Valid + Invalid tokens (which are guarenteed to be non-trivials) are included in the stream
4016
4002
  flatStream: this.createQuery(
@@ -4022,8 +4008,8 @@ class cs {
4022
4008
  _: this.createQuery(
4023
4009
  0,
4024
4010
  () => {
4025
- const e = new on(this.source).lex().chain((n) => new un(n, this.nodeIdGenerator).parse()).chain(({ ast: n, tokens: s }) => new Wn(n, this.symbolIdGenerator).analyze().map(() => ({ ast: n, tokens: s })));
4026
- return e.getErrors().length > 0 ? e : e.chain(({ ast: n, tokens: s }) => new qn(n).interpret().map((r) => ({ ast: n, tokens: s, rawDb: r })));
4011
+ const e = new rn(this.source).lex().chain((n) => new ln(n, this.nodeIdGenerator).parse()).chain(({ ast: n, tokens: s }) => new Xn(n, this.symbolIdGenerator).analyze().map(() => ({ ast: n, tokens: s })));
4012
+ return e.getErrors().length > 0 ? e : e.chain(({ ast: n, tokens: s }) => new zn(n).interpret().map((r) => ({ ast: n, tokens: s, rawDb: r })));
4027
4013
  }
4028
4014
  ),
4029
4015
  ast: this.createQuery(
@@ -4058,33 +4044,33 @@ class cs {
4058
4044
  return [this.parse.ast()];
4059
4045
  const r = n[s].start;
4060
4046
  let a = this.parse.ast();
4061
- const c = [a];
4047
+ const l = [a];
4062
4048
  for (; ; ) {
4063
- const h = an(a).find((T) => Le(r, T));
4064
- if (h === void 0 || h instanceof V)
4049
+ const h = sn(a).find((T) => be(r, T));
4050
+ if (h === void 0 || h instanceof B)
4065
4051
  break;
4066
- c.push(h), a = h;
4052
+ l.push(h), a = h;
4067
4053
  }
4068
- if ((i == null ? void 0 : i.kind) === u.COLON)
4069
- return c;
4070
- for (; c.length > 0; ) {
4054
+ if ((i == null ? void 0 : i.kind) === c.COLON)
4055
+ return l;
4056
+ for (; l.length > 0; ) {
4071
4057
  let p = !1;
4072
- const h = I.last(c);
4073
- if (h instanceof v) {
4058
+ const h = I.last(l);
4059
+ if (h instanceof k) {
4074
4060
  const T = this.parse.source();
4075
4061
  for (let f = h.end; f < e; f += 1)
4076
4062
  T[f] === `
4077
- ` && (c.pop(), p = !0);
4063
+ ` && (l.pop(), p = !0);
4078
4064
  } else
4079
- h instanceof Q || h instanceof q ? this.container.token(e).token !== h.op && (c.pop(), p = !0) : h instanceof U ? h.listCloseBracket && h.end <= e && (c.pop(), p = !0) : h instanceof J ? h.tupleCloseParen && h.end <= e && (c.pop(), p = !0) : h instanceof ee ? h.blockCloseBrace && h.end <= e && (c.pop(), p = !0) : h instanceof te || h.end < e && (c.pop(), p = !0);
4065
+ h instanceof Q || h instanceof q ? this.container.token(e).token !== h.op && (l.pop(), p = !0) : h instanceof P ? h.listCloseBracket && h.end <= e && (l.pop(), p = !0) : h instanceof J ? h.tupleCloseParen && h.end <= e && (l.pop(), p = !0) : h instanceof te ? h.blockCloseBrace && h.end <= e && (l.pop(), p = !0) : h instanceof K || h.end < e && (l.pop(), p = !0);
4080
4066
  if (p) {
4081
- const T = I.last(c);
4082
- T instanceof _ && T.end <= e && c.pop();
4067
+ const T = I.last(l);
4068
+ T instanceof _ && T.end <= e && l.pop();
4083
4069
  }
4084
4070
  if (!p)
4085
4071
  break;
4086
4072
  }
4087
- return c;
4073
+ return l;
4088
4074
  }
4089
4075
  ),
4090
4076
  token: this.createQuery(
@@ -4116,7 +4102,7 @@ class cs {
4116
4102
  ),
4117
4103
  scopeKind: this.createQuery(15, (e) => {
4118
4104
  var s;
4119
- if (this.container.element(e) instanceof F)
4105
+ if (this.container.element(e) instanceof C)
4120
4106
  return 8;
4121
4107
  switch ((s = this.container.element(e).type) == null ? void 0 : s.value.toLowerCase()) {
4122
4108
  case "table":
@@ -4156,14 +4142,14 @@ class cs {
4156
4142
  if (!((i = r.symbol) != null && i.symbolTable))
4157
4143
  continue;
4158
4144
  const { symbolTable: a } = r.symbol;
4159
- let c = [a], p = [];
4145
+ let l = [a], p = [];
4160
4146
  for (const h of e)
4161
- p = c.flatMap(
4162
- (T) => Qt(h).flatMap((f) => {
4147
+ p = l.flatMap(
4148
+ (T) => Yt(h).flatMap((f) => {
4163
4149
  const N = T.get(f), g = se(f).unwrap_or(void 0);
4164
4150
  return !N || !g ? [] : { ...g, symbol: N };
4165
4151
  })
4166
- ), c = p.flatMap(
4152
+ ), l = p.flatMap(
4167
4153
  (T) => T.symbol.symbolTable ? T.symbol.symbolTable : []
4168
4154
  );
4169
4155
  s.push(...p);
@@ -4190,8 +4176,8 @@ class cs {
4190
4176
  if (r.has(a))
4191
4177
  return r.get(a);
4192
4178
  }
4193
- const c = n(i);
4194
- return i !== void 0 ? r instanceof Map ? r.set(a, c) : (this.cache[e] = /* @__PURE__ */ new Map(), this.cache[e].set(a, c)) : this.cache[e] = c, c;
4179
+ const l = n(i);
4180
+ return i !== void 0 ? r instanceof Map ? r.set(a, l) : (this.cache[e] = /* @__PURE__ */ new Map(), this.cache[e].set(a, l)) : this.cache[e] = l, l;
4195
4181
  };
4196
4182
  }
4197
4183
  setSource(e) {
@@ -4202,14 +4188,14 @@ class cs {
4202
4188
  }
4203
4189
  initMonacoServices() {
4204
4190
  return {
4205
- definitionProvider: new Ct(this),
4206
- referenceProvider: new Xt(this),
4207
- autocompletionProvider: new Ft(this)
4191
+ definitionProvider: new Gt(this),
4192
+ referenceProvider: new Ct(this),
4193
+ autocompletionProvider: new Mt(this)
4208
4194
  };
4209
4195
  }
4210
4196
  }
4211
4197
  export {
4212
- cs as Compiler,
4213
- as as serialize,
4214
- os as services
4198
+ as as Compiler,
4199
+ is as serialize,
4200
+ rs as services
4215
4201
  };