@dbml/parse 3.13.0-alpha.0 → 3.13.0-alpha.1

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
- import _, { last as Ke, forIn as ft, partition as tn, findLastIndex as nn } from "lodash";
1
+ import _, { last as Ze, forIn as ft, partition as nn, findLastIndex as sn } from "lodash";
2
2
  var h = /* @__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.TILDE = "<tilde>", t.SINGLE_LINE_COMMENT = "<single-line-comment>", t.MULTILINE_COMMENT = "<multiline-comment>", t))(h || {});
3
- function sn(t) {
3
+ function an(t) {
4
4
  switch (t.kind) {
5
5
  case "<newline>":
6
6
  case "<space>":
@@ -45,27 +45,27 @@ class J {
45
45
  return new J(e, n, s, i, a);
46
46
  }
47
47
  }
48
- function kt(t) {
48
+ function St(t) {
49
49
  return t.trailingTrivia.find(({ kind: e }) => e === h.NEWLINE) !== void 0;
50
50
  }
51
51
  function Et(t, e) {
52
- return e.leadingTrivia.find(({ kind: s }) => s === h.NEWLINE) !== void 0 || kt(t);
52
+ return e.leadingTrivia.find(({ kind: s }) => s === h.NEWLINE) !== void 0 || St(t);
53
53
  }
54
- function Ze(t) {
54
+ function Ke(t) {
55
55
  return t.trailingTrivia.find(({ kind: e }) => [h.SPACE, h.TAB].includes(e)) !== void 0;
56
56
  }
57
- function St(t) {
58
- return t.trailingTrivia.length === 0 ? t.end : St(Ke(t.trailingTrivia));
57
+ function Pt(t) {
58
+ return t.trailingTrivia.length === 0 ? t.end : Pt(Ze(t.trailingTrivia));
59
59
  }
60
60
  function xt(t) {
61
61
  return t.leadingTrivia.length === 0 ? t.start : xt(t.leadingTrivia[0]);
62
62
  }
63
- function an(t) {
63
+ function rn(t) {
64
64
  return [h.SINGLE_LINE_COMMENT, h.MULTILINE_COMMENT].includes(
65
65
  t.kind
66
66
  );
67
67
  }
68
- class rn {
68
+ class on {
69
69
  constructor() {
70
70
  this.id = 0;
71
71
  }
@@ -88,15 +88,15 @@ class D {
88
88
  line: NaN
89
89
  }, this.fullStart = NaN);
90
90
  const a = [...s].reverse().find((r) => r !== void 0 && !Number.isNaN(r.end));
91
- a ? (this.endPos = a.endPos, this.fullEnd = a instanceof J ? St(a) : a.fullEnd) : (this.endPos = {
91
+ a ? (this.endPos = a.endPos, this.fullEnd = a instanceof J ? Pt(a) : a.fullEnd) : (this.endPos = {
92
92
  offset: NaN,
93
93
  column: NaN,
94
94
  line: NaN
95
95
  }, this.fullEnd = NaN), this.start = this.startPos.offset, this.end = this.endPos.offset;
96
96
  }
97
97
  }
98
- var _e = /* @__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.PARTIAL_INJECTION = "<partial-injection>", t))(_e || {});
99
- class K extends D {
98
+ var Ie = /* @__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.PARTIAL_INJECTION = "<partial-injection>", t))(Ie || {});
99
+ class Z extends D {
100
100
  constructor({ body: e = [], eof: n }, s) {
101
101
  super(s, "<program>", [...e, n]), this.body = e, this.eof = n;
102
102
  }
@@ -119,7 +119,7 @@ class y extends D {
119
119
  a,
120
120
  r,
121
121
  c
122
- ]), c && r && !(c instanceof w || c instanceof y))
122
+ ]), c && r && !(c instanceof v || c instanceof y))
123
123
  throw new Error("If an element has a simple body, it must be a function application node");
124
124
  this.type = e, this.name = n, this.as = s, this.alias = i, this.attributeList = a, this.bodyColon = r, this.body = c;
125
125
  }
@@ -138,7 +138,7 @@ class se extends D {
138
138
  super(i, "<attribute>", [e, n, s]), this.name = e, this.value = s, this.colon = n;
139
139
  }
140
140
  }
141
- class Z extends D {
141
+ class K extends D {
142
142
  constructor({ op: e, expression: n }, s) {
143
143
  super(s, "<prefix-expression>", [e, n]), this.op = e, this.expression = n;
144
144
  }
@@ -152,7 +152,7 @@ class le extends D {
152
152
  super(i, "<infix-expression>", [n, e, s]), this.op = e, this.leftExpression = n, this.rightExpression = s;
153
153
  }
154
154
  }
155
- class $e extends D {
155
+ class je extends D {
156
156
  constructor({ op: e, expression: n }, s) {
157
157
  super(s, "<postfix-expression>", [n, e]), this.op = e, this.expression = n;
158
158
  }
@@ -162,7 +162,7 @@ class ce extends D {
162
162
  super(n, "<function-expression>", [e]), this.value = e;
163
163
  }
164
164
  }
165
- class w extends D {
165
+ class v extends D {
166
166
  constructor({ callee: e, args: n = [] }, s) {
167
167
  super(s, "<function-application>", [e, ...n]), this.callee = e, this.args = n;
168
168
  }
@@ -176,9 +176,9 @@ class re extends D {
176
176
  super(i, "<block-expression>", [e, ...n, s]), this.blockOpenBrace = e, this.body = n, this.blockCloseBrace = s;
177
177
  }
178
178
  }
179
- class ke extends D {
180
- constructor({ partial: e }, n) {
181
- super(n, "<partial-injection>", [e]), this.partial = e;
179
+ class Le extends D {
180
+ constructor({ op: e, partial: n }, s) {
181
+ super(s, "<partial-injection>", [e, n]), this.partial = n;
182
182
  }
183
183
  }
184
184
  class R extends D {
@@ -190,7 +190,7 @@ class R extends D {
190
190
  }, a) {
191
191
  super(a, "<list-expression>", [
192
192
  e,
193
- ...Pt(n, s),
193
+ ...Dt(n, s),
194
194
  i
195
195
  ]), this.listOpenBracket = e, this.elementList = n, this.commaList = s, this.listCloseBracket = i;
196
196
  }
@@ -204,7 +204,7 @@ class fe extends D {
204
204
  }, a) {
205
205
  super(a, "<tuple-expression>", [
206
206
  e,
207
- ...Pt(n, s),
207
+ ...Dt(n, s),
208
208
  i
209
209
  ]), this.tupleOpenParen = e, this.elementList = n, this.commaList = s, this.tupleCloseParen = i;
210
210
  }
@@ -234,7 +234,7 @@ class Y extends D {
234
234
  super(s, "<call-expression>", [e, n]), this.callee = e, this.argumentList = n;
235
235
  }
236
236
  }
237
- class ge extends D {
237
+ class ve extends D {
238
238
  constructor({ literal: e }, n) {
239
239
  super(n, "<literal>", [e]), this.literal = e;
240
240
  }
@@ -249,7 +249,7 @@ class G extends D {
249
249
  super(n, "<primary-expression>", [e]), this.expression = e;
250
250
  }
251
251
  }
252
- class Re extends D {
252
+ class Ue extends D {
253
253
  constructor({ pre: e }, n) {
254
254
  const s = J.create(h.SPACE, e.endPos, e.endPos, " ", !1);
255
255
  super(n, "<dummy>", [s]);
@@ -260,7 +260,7 @@ class ue extends D {
260
260
  super(s, "<array>", [e, n]), this.array = e, this.indexer = n;
261
261
  }
262
262
  }
263
- function Pt(t, e) {
263
+ function Dt(t, e) {
264
264
  if (!t || t.length === 0)
265
265
  return e || [];
266
266
  if (!e || e.length === 0)
@@ -270,12 +270,12 @@ function Pt(t, e) {
270
270
  (i) => i !== null
271
271
  );
272
272
  }
273
- function ws(t, e = !1) {
273
+ function ys(t, e = !1) {
274
274
  return JSON.stringify(
275
275
  t,
276
276
  function(n, s) {
277
277
  var i;
278
- return !(this instanceof K) && n === "symbol" ? s == null ? void 0 : s.id : (
278
+ return !(this instanceof Z) && n === "symbol" ? s == null ? void 0 : s.id : (
279
279
  /* this instanceof SyntaxNode && */
280
280
  n === "symbol" ? {
281
281
  symbolTable: s == null ? void 0 : s.symbolTable,
@@ -318,7 +318,7 @@ class O {
318
318
  return !0;
319
319
  }
320
320
  }
321
- class P {
321
+ class x {
322
322
  // eslint-disable-next-line class-methods-use-this
323
323
  unwrap() {
324
324
  throw new Error("Trying to unwrap a None value");
@@ -329,11 +329,11 @@ class P {
329
329
  }
330
330
  // eslint-disable-next-line @typescript-eslint/no-unused-vars, class-methods-use-this
331
331
  and_then(e) {
332
- return new P();
332
+ return new x();
333
333
  }
334
334
  // eslint-disable-next-line @typescript-eslint/no-unused-vars, class-methods-use-this
335
335
  map(e) {
336
- return new P();
336
+ return new x();
337
337
  }
338
338
  // eslint-disable-next-line class-methods-use-this
339
339
  isOk() {
@@ -344,10 +344,10 @@ var m = /* @__PURE__ */ ((t) => (t.Schema = "Schema", t.Table = "Table", t.Colum
344
344
  function nt(t) {
345
345
  return `Schema:${t}`;
346
346
  }
347
- function Fe(t) {
347
+ function Be(t) {
348
348
  return `Table:${t}`;
349
349
  }
350
- function je(t) {
350
+ function We(t) {
351
351
  return `Column:${t}`;
352
352
  }
353
353
  function st(t) {
@@ -362,19 +362,19 @@ function at(t) {
362
362
  function rt(t) {
363
363
  return `TableGroup field:${t}`;
364
364
  }
365
- function on(t) {
365
+ function ln(t) {
366
366
  return `Note:${t}`;
367
367
  }
368
- function Dt(t) {
368
+ function Ot(t) {
369
369
  return `TablePartial:${t}`;
370
370
  }
371
- function ln(t) {
371
+ function cn(t) {
372
372
  return `TablePartialInjection:${t}`;
373
373
  }
374
- function Ue(t, e) {
374
+ function Me(t, e) {
375
375
  switch (e) {
376
376
  case "Column":
377
- return je(t);
377
+ return We(t);
378
378
  case "Enum":
379
379
  return st(t);
380
380
  case "Enum field":
@@ -382,13 +382,13 @@ function Ue(t, e) {
382
382
  case "Schema":
383
383
  return nt(t);
384
384
  case "Table":
385
- return Fe(t);
385
+ return Be(t);
386
386
  case "TableGroup":
387
387
  return at(t);
388
388
  case "TableGroup field":
389
389
  return rt(t);
390
390
  case "TablePartial":
391
- return Dt(t);
391
+ return Ot(t);
392
392
  default:
393
393
  throw new Error("Unreachable");
394
394
  }
@@ -398,57 +398,57 @@ function oe(t) {
398
398
  return Object.values(m).includes(e) ? new O({
399
399
  name: n,
400
400
  kind: e
401
- }) : new P();
401
+ }) : new x();
402
402
  }
403
- function cn(t) {
403
+ function un(t) {
404
404
  const e = oe(t).unwrap_or(void 0);
405
405
  if (!e)
406
406
  return !1;
407
407
  const { kind: n, name: s } = e;
408
408
  return n === "Schema" && s === "public";
409
409
  }
410
- function un(t) {
410
+ function hn(t) {
411
411
  const e = oe(t).unwrap_or(void 0);
412
412
  if (!e)
413
413
  return !1;
414
414
  const { kind: n } = e;
415
415
  return n === "TablePartialInjection";
416
416
  }
417
- function hn(t) {
417
+ function fn(t) {
418
418
  const e = oe(t).unwrap_or(void 0);
419
419
  if (!e)
420
420
  return null;
421
421
  const { kind: n, name: s } = e;
422
- return n === "TablePartialInjection" ? Ue(
422
+ return n === "TablePartialInjection" ? Me(
423
423
  s,
424
424
  "TablePartial"
425
425
  /* TablePartial */
426
426
  ) : null;
427
427
  }
428
- function fn(t) {
428
+ function pn(t) {
429
429
  return [
430
430
  nt,
431
- Fe,
431
+ Be,
432
432
  st,
433
433
  at,
434
- je,
434
+ We,
435
435
  it,
436
436
  rt
437
437
  ].map((e) => e(t));
438
438
  }
439
- function We(t) {
439
+ function Ye(t) {
440
440
  return !!t.match(/(\p{L}|_|\p{M})/gu);
441
441
  }
442
- function Be(t) {
442
+ function Ve(t) {
443
443
  const [e] = t;
444
444
  return e >= "0" && e <= "9";
445
445
  }
446
- function pn(t) {
446
+ function dn(t) {
447
447
  const [e] = t;
448
- return Be(e) || We(e) && e.toLowerCase() >= "a" && e.toLowerCase() <= "f";
448
+ return Ve(e) || Ye(e) && e.toLowerCase() >= "a" && e.toLowerCase() <= "f";
449
449
  }
450
- function Le(t) {
451
- return We(t) || Be(t);
450
+ function Ae(t) {
451
+ return Ye(t) || Ve(t);
452
452
  }
453
453
  function Nt(t, e) {
454
454
  const n = [], s = Math.min(t.length, e.length);
@@ -456,10 +456,10 @@ function Nt(t, e) {
456
456
  n.push(t[i], e[i]);
457
457
  return n.push(...t.slice(s), ...e.slice(s)), n;
458
458
  }
459
- function ye(t, e) {
459
+ function ke(t, e) {
460
460
  return t >= e.start && t < e.end;
461
461
  }
462
- class dn {
462
+ class En {
463
463
  constructor() {
464
464
  this.id = 0;
465
465
  }
@@ -470,52 +470,52 @@ class dn {
470
470
  return this.id++;
471
471
  }
472
472
  }
473
- class Ot {
473
+ class Rt {
474
474
  constructor({ symbolTable: e }, n) {
475
475
  this.references = [], this.id = n, this.symbolTable = e;
476
476
  }
477
477
  }
478
- class En {
478
+ class Nn {
479
479
  constructor({ symbolTable: e, declaration: n }, s) {
480
480
  this.references = [], this.id = s, this.symbolTable = e, this.declaration = n;
481
481
  }
482
482
  }
483
- class Nn {
483
+ class mn {
484
484
  constructor({ declaration: e }, n) {
485
485
  this.references = [], this.id = n, this.declaration = e;
486
486
  }
487
487
  }
488
- class Rt {
488
+ class Ut {
489
489
  constructor({ symbolTable: e, declaration: n }, s) {
490
490
  this.references = [], this.id = s, this.symbolTable = e, this.declaration = n;
491
491
  }
492
492
  }
493
- class Ut {
493
+ class Mt {
494
494
  constructor({ declaration: e }, n) {
495
495
  this.references = [], this.id = n, this.declaration = e;
496
496
  }
497
497
  }
498
- class mn {
498
+ class Tn {
499
499
  constructor({ symbolTable: e, declaration: n }, s) {
500
500
  this.references = [], this.id = s, this.symbolTable = e, this.declaration = n;
501
501
  }
502
502
  }
503
- class Tn {
503
+ class bn {
504
504
  constructor({ declaration: e }, n) {
505
505
  this.references = [], this.id = n, this.declaration = e;
506
506
  }
507
507
  }
508
- class bn {
508
+ class In {
509
509
  constructor({ symbolTable: e, declaration: n }, s) {
510
510
  this.references = [], this.id = s, this.symbolTable = e, this.declaration = n;
511
511
  }
512
512
  }
513
- class In {
513
+ class Ln {
514
514
  constructor({ declaration: e }, n) {
515
515
  this.references = [], this.id = n, this.declaration = e;
516
516
  }
517
517
  }
518
- class Ln {
518
+ class _n {
519
519
  constructor({ injectorId: e }, n) {
520
520
  this.references = [], this.id = n, this.injectorId = e;
521
521
  }
@@ -544,12 +544,12 @@ class q {
544
544
  return new q(e(this.value), this.errors);
545
545
  }
546
546
  }
547
- function _n(t, e, n) {
547
+ function An(t, e, n) {
548
548
  if (!t || !he(t) || e.length === 0)
549
- return new P();
549
+ return new x();
550
550
  const s = [...e], i = Je(t).unwrap(), a = s.pop();
551
551
  if (!(a instanceof re))
552
- return new P();
552
+ return new x();
553
553
  const r = _.last(s) instanceof R ? s.pop() : void 0;
554
554
  return s.length === 3 && Je(s[1]).unwrap().value === "as" ? new O(
555
555
  n.create(y, {
@@ -573,29 +573,29 @@ function _n(t, e, n) {
573
573
  attributeList: r,
574
574
  body: a
575
575
  })
576
- ) : new P();
576
+ ) : new x();
577
577
  }
578
578
  function mt(t) {
579
579
  return t.kind === h.IDENTIFIER && t.value === "as";
580
580
  }
581
581
  function T(t) {
582
- t && (t instanceof J ? An(t) : gn(t));
582
+ t && (t instanceof J ? gn(t) : vn(t));
583
583
  }
584
- function An(t) {
584
+ function gn(t) {
585
585
  t.kind !== h.EOF && (t.isInvalid = !0);
586
586
  }
587
- function gn(t) {
587
+ function vn(t) {
588
588
  if (t instanceof y)
589
589
  T(t.type), T(t.name), T(t.as), T(t.alias), T(t.bodyColon), T(t.attributeList), T(t.body);
590
590
  else if (t instanceof ne)
591
591
  t.identifiers.forEach(T);
592
592
  else if (t instanceof se)
593
593
  T(t.name), T(t.colon), T(t.value);
594
- else if (t instanceof Z)
594
+ else if (t instanceof K)
595
595
  T(t.op), T(t.expression);
596
596
  else if (t instanceof le)
597
597
  T(t.leftExpression), T(t.op), T(t.rightExpression);
598
- else if (t instanceof $e)
598
+ else if (t instanceof je)
599
599
  T(t.op), T(t.expression);
600
600
  else if (t instanceof re)
601
601
  T(t.blockOpenBrace), t.body.forEach(T), T(t.blockCloseBrace);
@@ -605,7 +605,7 @@ function gn(t) {
605
605
  T(t.tupleOpenParen), t.commaList.forEach(T), t.elementList.forEach(T), T(t.tupleCloseParen);
606
606
  else if (t instanceof Y)
607
607
  T(t.callee), T(t.argumentList);
608
- else if (t instanceof w)
608
+ else if (t instanceof v)
609
609
  T(t.callee), t.args.forEach(T);
610
610
  else if (t instanceof G)
611
611
  T(t.expression);
@@ -613,22 +613,22 @@ function gn(t) {
613
613
  T(t.value);
614
614
  else if (t instanceof ae)
615
615
  T(t.variable);
616
- else if (t instanceof ge)
616
+ else if (t instanceof ve)
617
617
  T(t.literal);
618
618
  else
619
619
  throw t instanceof tt ? new Error("This case is handled by the TupleExpressionNode case") : new Error("Unreachable case in markInvalidNode");
620
620
  }
621
- function Mt(t) {
621
+ function Ft(t) {
622
622
  return !!(t != null && t.isInvalid);
623
623
  }
624
- function j(...t) {
624
+ function X(...t) {
625
625
  return t.filter((e) => e !== void 0);
626
626
  }
627
- function vn(t) {
628
- if (t instanceof K)
629
- return j(...t.body, t.eof);
627
+ function wn(t) {
628
+ if (t instanceof Z)
629
+ return X(...t.body, t.eof);
630
630
  if (t instanceof y)
631
- return j(
631
+ return X(
632
632
  t.type,
633
633
  t.name,
634
634
  t.as,
@@ -638,73 +638,75 @@ function vn(t) {
638
638
  t.body
639
639
  );
640
640
  if (t instanceof se)
641
- return j(t.name, t.colon, t.value);
641
+ return X(t.name, t.colon, t.value);
642
642
  if (t instanceof ne)
643
643
  return t.identifiers;
644
- if (t instanceof ge)
644
+ if (t instanceof ve)
645
645
  return t.literal ? [t.literal] : [];
646
646
  if (t instanceof ae)
647
- return j(t.variable);
648
- if (t instanceof Z)
649
- return j(t.op, t.expression);
647
+ return X(t.variable);
648
+ if (t instanceof K)
649
+ return X(t.op, t.expression);
650
650
  if (t instanceof le)
651
- return j(t.leftExpression, t.op, t.rightExpression);
652
- if (t instanceof $e)
653
- return j(t.expression, t.op);
651
+ return X(t.leftExpression, t.op, t.rightExpression);
652
+ if (t instanceof je)
653
+ return X(t.expression, t.op);
654
654
  if (t instanceof ce)
655
- return j(t.value);
656
- if (t instanceof w)
657
- return j(t.callee, ...t.args);
655
+ return X(t.value);
656
+ if (t instanceof v)
657
+ return X(t.callee, ...t.args);
658
658
  if (t instanceof re)
659
- return j(t.blockOpenBrace, ...t.body, t.blockCloseBrace);
659
+ return X(t.blockOpenBrace, ...t.body, t.blockCloseBrace);
660
660
  if (t instanceof R)
661
- return j(
661
+ return X(
662
662
  t.listOpenBracket,
663
663
  ...Nt(t.elementList, t.commaList),
664
664
  t.listCloseBracket
665
665
  );
666
666
  if (t instanceof fe)
667
- return j(
667
+ return X(
668
668
  t.tupleOpenParen,
669
669
  ...Nt(t.elementList, t.commaList),
670
670
  t.tupleCloseParen
671
671
  );
672
672
  if (t instanceof Y)
673
- return j(t.callee, t.argumentList);
673
+ return X(t.callee, t.argumentList);
674
674
  if (t instanceof G)
675
- return j(t.expression);
675
+ return X(t.expression);
676
676
  if (t instanceof ue)
677
- return j(
677
+ return X(
678
678
  t.array,
679
679
  t.indexer
680
680
  );
681
+ if (t instanceof Le)
682
+ return X(t.partial);
681
683
  throw t instanceof tt ? new Error("This case is already handled by TupleExpressionNode") : new Error("Unreachable - no other possible cases");
682
684
  }
683
685
  function Je(t) {
684
- return $(t) ? new O(t.expression.variable) : new P();
686
+ return j(t) ? new O(t.expression.variable) : new x();
685
687
  }
686
688
  function C(t) {
687
689
  var e;
688
- return t instanceof G && (t.expression instanceof ae && t.expression.variable instanceof J && t.expression.variable.kind === h.QUOTED_STRING || t.expression instanceof ge && ((e = t.expression.literal) == null ? void 0 : e.kind) === h.STRING_LITERAL);
690
+ return t instanceof G && (t.expression instanceof ae && t.expression.variable instanceof J && t.expression.variable.kind === h.QUOTED_STRING || t.expression instanceof ve && ((e = t.expression.literal) == null ? void 0 : e.kind) === h.STRING_LITERAL);
689
691
  }
690
- function $(t) {
692
+ function j(t) {
691
693
  return t instanceof G && t.expression instanceof ae && t.expression.variable instanceof J;
692
694
  }
693
695
  function he(t) {
694
696
  var e;
695
697
  return t instanceof G && t.expression instanceof ae && ((e = t.expression.variable) == null ? void 0 : e.kind) === h.IDENTIFIER;
696
698
  }
697
- function Ye(t) {
699
+ function qe(t) {
698
700
  var e;
699
701
  return t instanceof le && t.leftExpression instanceof D && t.rightExpression instanceof D && ((e = t.op) == null ? void 0 : e.value) === ".";
700
702
  }
701
- function Ae(t) {
703
+ function ge(t) {
702
704
  if (t === void 0)
703
- return new P();
705
+ return new x();
704
706
  const e = t.identifiers.map((n) => n.value).join(" ");
705
- return e === "" ? new P() : new O(e);
707
+ return e === "" ? new x() : new O(e);
706
708
  }
707
- class wn {
709
+ class yn {
708
710
  // list of errors during lexing
709
711
  constructor(e) {
710
712
  this.start = {
@@ -821,11 +823,11 @@ class wn {
821
823
  this.operator();
822
824
  break;
823
825
  }
824
- if (We(e)) {
826
+ if (Ye(e)) {
825
827
  this.identifier();
826
828
  break;
827
829
  }
828
- if (Be(e)) {
830
+ if (Ve(e)) {
829
831
  this.numericLiteralOrIdentifier();
830
832
  break;
831
833
  }
@@ -845,13 +847,13 @@ class wn {
845
847
  let e = !0, n = [], s;
846
848
  const i = [];
847
849
  for (const a of this.tokens)
848
- sn(a) ? (n.push(a), a.kind === h.NEWLINE && s && (s.trailingTrivia = n, e = !0, s = void 0, n = [])) : (e ? a.leadingTrivia = n : s.trailingTrivia = n, i.push(a), n = [], s = a, e = !1);
850
+ an(a) ? (n.push(a), a.kind === h.NEWLINE && s && (s.trailingTrivia = n, e = !0, s = void 0, n = [])) : (e ? a.leadingTrivia = n : s.trailingTrivia = n, i.push(a), n = [], s = a, e = !1);
849
851
  this.tokens = i;
850
852
  }
851
853
  gatherInvalid() {
852
854
  let e;
853
855
  const n = [], s = [];
854
- for (e = 0; e < this.tokens.length && Mt(this.tokens[e]); e += 1)
856
+ for (e = 0; e < this.tokens.length && Ft(this.tokens[e]); e += 1)
855
857
  s.push(this.tokens[e]);
856
858
  let i = this.tokens[e];
857
859
  for (i.leadingInvalid = [...s, ...i.leadingInvalid]; e < this.tokens.length; e += 1) {
@@ -940,7 +942,7 @@ class wn {
940
942
  });
941
943
  }
942
944
  identifier() {
943
- for (; !this.isAtEnd() && Le(this.peek()); )
945
+ for (; !this.isAtEnd() && Ae(this.peek()); )
944
946
  this.advance();
945
947
  this.addToken(h.IDENTIFIER);
946
948
  }
@@ -960,26 +962,26 @@ class wn {
960
962
  break;
961
963
  if (!n && this.current.offset === this.text.length - 1)
962
964
  return this.advance(), this.addToken(h.NUMERIC_LITERAL);
963
- if (!n && !Le(this.peek()))
965
+ if (!n && !Ae(this.peek()))
964
966
  return this.addToken(h.NUMERIC_LITERAL);
965
- if (!n && !Be(this.peek()))
967
+ if (!n && !Ve(this.peek()))
966
968
  break;
967
969
  this.advance();
968
970
  }
969
971
  if (e > 0) {
970
- for (; !this.isAtEnd() && (this.check(".") || Le(this.peek())); )
972
+ for (; !this.isAtEnd() && (this.check(".") || Ae(this.peek())); )
971
973
  this.advance();
972
974
  const n = this.createToken(h.NUMERIC_LITERAL, !0);
973
975
  this.tokens.push(n), this.errors.push(new l(o.UNKNOWN_TOKEN, "Invalid number", n));
974
976
  } else {
975
- for (; !this.isAtEnd() && Le(this.peek()); )
977
+ for (; !this.isAtEnd() && Ae(this.peek()); )
976
978
  this.advance();
977
979
  const n = this.createToken(h.IDENTIFIER, !1);
978
980
  this.tokens.push(n);
979
981
  }
980
982
  }
981
983
  colorLiteral() {
982
- for (; !this.isAtEnd() && Le(this.peek()); )
984
+ for (; !this.isAtEnd() && Ae(this.peek()); )
983
985
  this.advance();
984
986
  this.addToken(h.COLOR_LITERAL);
985
987
  }
@@ -1020,7 +1022,7 @@ class wn {
1020
1022
  case "u": {
1021
1023
  let n = "";
1022
1024
  for (let s = 0; s <= 3; s += 1) {
1023
- if (this.isAtEnd() || !Le(this.peek()))
1025
+ if (this.isAtEnd() || !Ae(this.peek()))
1024
1026
  return this.errors.push(new l(o.INVALID_ESCAPE_SEQUENCE, `Invalid unicode escape sequence '\\u${n}', only unicode escape sequences of the form '\\uHHHH' where H is a hexadecimal number are allowed`, J.create(h.STRING_LITERAL, e, this.current, `\\u${n}`, !0))), `\\u${n}`;
1025
1027
  n += this.advance();
1026
1028
  }
@@ -1031,8 +1033,8 @@ class wn {
1031
1033
  }
1032
1034
  }
1033
1035
  }
1034
- var Me = /* @__PURE__ */ ((t) => (t[t.ListExpression = 0] = "ListExpression", t[t.GroupExpression = 1] = "GroupExpression", t[t.BlockExpression = 2] = "BlockExpression", t))(Me || {});
1035
- class yn {
1036
+ var Fe = /* @__PURE__ */ ((t) => (t[t.ListExpression = 0] = "ListExpression", t[t.GroupExpression = 1] = "GroupExpression", t[t.BlockExpression = 2] = "BlockExpression", t))(Fe || {});
1037
+ class kn {
1036
1038
  constructor() {
1037
1039
  this.stack = [], this.numberOfNestedLParens = 0, this.numberOfNestedLBrackets = 0, this.numberOfNestedLBraces = 0;
1038
1040
  }
@@ -1098,7 +1100,7 @@ class yn {
1098
1100
  }
1099
1101
  }
1100
1102
  }
1101
- class kn {
1103
+ class Sn {
1102
1104
  constructor(e) {
1103
1105
  this.generator = e;
1104
1106
  }
@@ -1111,9 +1113,9 @@ class N {
1111
1113
  this.token = e, this.partialNode = n, this.handlerContext = s;
1112
1114
  }
1113
1115
  }
1114
- class Sn {
1116
+ class Pn {
1115
1117
  constructor(e, n) {
1116
- this.current = 0, this.errors = [], this.contextStack = new yn(), this.synchronizeProgram = () => {
1118
+ this.current = 0, this.errors = [], this.contextStack = new kn(), this.synchronizeProgram = () => {
1117
1119
  const s = this.peek();
1118
1120
  s.kind !== h.EOF ? T(this.advance()) : (T(this.peek()), this.logError(s, o.UNEXPECTED_EOF, "Unexpected EOF"));
1119
1121
  }, this.synchronizeElementDeclarationName = () => {
@@ -1130,7 +1132,7 @@ class Sn {
1130
1132
  break;
1131
1133
  T(s), this.advance();
1132
1134
  }
1133
- }, this.blockExpression = this.contextStack.withContextDo(Me.BlockExpression, () => {
1135
+ }, this.blockExpression = this.contextStack.withContextDo(Fe.BlockExpression, () => {
1134
1136
  const s = { body: [] }, i = () => this.nodeFactory.create(re, s);
1135
1137
  try {
1136
1138
  this.consume("Expect an opening brace '{'", h.LBRACE), s.blockOpenBrace = this.previous();
@@ -1144,7 +1146,7 @@ class Sn {
1144
1146
  for (; !this.isAtEnd() && !this.check(h.RBRACE); )
1145
1147
  try {
1146
1148
  if (this.match(h.TILDE)) {
1147
- const a = this.previous(), r = this.variable(), c = this.nodeFactory.create(ke, { op: a, partial: r });
1149
+ const a = this.previous(), r = this.variable(), c = this.nodeFactory.create(Le, { op: a, partial: r });
1148
1150
  s.body.push(c);
1149
1151
  } else
1150
1152
  s.body.push(this.canBeField() ? this.fieldDeclaration() : this.expression());
@@ -1173,7 +1175,7 @@ class Sn {
1173
1175
  break;
1174
1176
  T(s), this.advance();
1175
1177
  }
1176
- }, this.tupleExpression = this.contextStack.withContextDo(Me.GroupExpression, () => {
1178
+ }, this.tupleExpression = this.contextStack.withContextDo(Fe.GroupExpression, () => {
1177
1179
  const s = { elementList: [], commaList: [] }, i = () => this.nodeFactory.create(tt, {
1178
1180
  groupOpenParen: s.tupleOpenParen,
1179
1181
  groupCloseParen: s.tupleCloseParen,
@@ -1225,7 +1227,7 @@ class Sn {
1225
1227
  break;
1226
1228
  T(s), this.advance();
1227
1229
  }
1228
- }, this.listExpression = this.contextStack.withContextDo(Me.ListExpression, () => {
1230
+ }, this.listExpression = this.contextStack.withContextDo(Fe.ListExpression, () => {
1229
1231
  const s = { elementList: [], commaList: [] }, i = () => this.nodeFactory.create(R, s);
1230
1232
  try {
1231
1233
  this.consume("Expect an opening bracket '['", h.LBRACKET), s.listOpenBracket = this.previous();
@@ -1287,7 +1289,7 @@ class Sn {
1287
1289
  break;
1288
1290
  T(s), this.advance();
1289
1291
  }
1290
- }, this.tokens = e, this.nodeFactory = new kn(n);
1292
+ }, this.tokens = e, this.nodeFactory = new Sn(n);
1291
1293
  }
1292
1294
  isAtEnd() {
1293
1295
  return this.current >= this.tokens.length || this.tokens[this.current].kind === h.EOF;
@@ -1343,7 +1345,7 @@ class Sn {
1343
1345
  this.tokens = e;
1344
1346
  }
1345
1347
  parse() {
1346
- const e = this.program(), n = this.advance(), s = this.nodeFactory.create(K, { body: e, eof: n });
1348
+ const e = this.program(), n = this.advance(), s = this.nodeFactory.create(Z, { body: e, eof: n });
1347
1349
  return this.gatherInvalid(), new q({ ast: s, tokens: this.tokens }, this.errors);
1348
1350
  }
1349
1351
  /* Parsing and synchronizing ProgramNode */
@@ -1442,8 +1444,8 @@ class Sn {
1442
1444
  }
1443
1445
  /* Parsing any ExpressionNode, including non-NormalExpression */
1444
1446
  expression() {
1445
- const e = { args: [] }, n = () => _n(e.callee, e.args, this.nodeFactory).unwrap_or(
1446
- this.nodeFactory.create(w, e)
1447
+ const e = { args: [] }, n = () => An(e.callee, e.args, this.nodeFactory).unwrap_or(
1448
+ this.nodeFactory.create(v, e)
1447
1449
  );
1448
1450
  try {
1449
1451
  e.callee = this.normalExpression();
@@ -1454,7 +1456,7 @@ class Sn {
1454
1456
  return n();
1455
1457
  let s = e.callee;
1456
1458
  for (; !this.shouldStopExpression(); ) {
1457
- Ze(this.previous()) || this.logError(s, o.MISSING_SPACES, "Expect a following space");
1459
+ Ke(this.previous()) || this.logError(s, o.MISSING_SPACES, "Expect a following space");
1458
1460
  try {
1459
1461
  s = this.normalExpression(), e.args.push(s);
1460
1462
  } catch (i) {
@@ -1464,7 +1466,7 @@ class Sn {
1464
1466
  return n();
1465
1467
  }
1466
1468
  shouldStopExpression() {
1467
- if (this.isAtEnd() || kt(this.previous()))
1469
+ if (this.isAtEnd() || St(this.previous()))
1468
1470
  return !0;
1469
1471
  const e = this.peek().kind;
1470
1472
  return e === h.RBRACE || e === h.RBRACKET || e === h.RPAREN || e === h.COMMA || e === h.COLON;
@@ -1497,7 +1499,7 @@ class Sn {
1497
1499
  }), new N(a.token, n, a.handlerContext)) : a;
1498
1500
  }
1499
1501
  } else if (s.kind === h.LBRACKET) {
1500
- if (Ze(this.previous()))
1502
+ if (Ke(this.previous()))
1501
1503
  break;
1502
1504
  try {
1503
1505
  n = this.nodeFactory.create(ue, {
@@ -1515,12 +1517,12 @@ class Sn {
1515
1517
  if (a.left !== null) {
1516
1518
  if (a.left <= e)
1517
1519
  break;
1518
- this.advance(), n = this.nodeFactory.create($e, {
1520
+ this.advance(), n = this.nodeFactory.create(je, {
1519
1521
  expression: n,
1520
1522
  op: i
1521
1523
  });
1522
1524
  } else {
1523
- const r = Pn(i);
1525
+ const r = Dn(i);
1524
1526
  if (r.left === null || r.left <= e)
1525
1527
  break;
1526
1528
  this.advance();
@@ -1548,7 +1550,7 @@ class Sn {
1548
1550
  if (dt(this.peek())) {
1549
1551
  const n = {};
1550
1552
  n.op = this.peek();
1551
- const s = On(n.op);
1553
+ const s = Rn(n.op);
1552
1554
  if (s.right === null)
1553
1555
  throw this.logError(
1554
1556
  n.op,
@@ -1556,7 +1558,7 @@ class Sn {
1556
1558
  `Unexpected '${n.op.value}' in an expression`
1557
1559
  ), new N(
1558
1560
  n.op,
1559
- this.nodeFactory.create(Re, { pre: n.op }),
1561
+ this.nodeFactory.create(Ue, { pre: n.op }),
1560
1562
  this.contextStack.findHandlerContext(this.tokens, this.current)
1561
1563
  );
1562
1564
  this.advance();
@@ -1565,15 +1567,15 @@ class Sn {
1565
1567
  } catch (i) {
1566
1568
  throw i instanceof N ? (n.expression = i.partialNode, new N(
1567
1569
  i.token,
1568
- this.nodeFactory.create(Z, n),
1570
+ this.nodeFactory.create(K, n),
1569
1571
  i.handlerContext
1570
1572
  )) : i;
1571
1573
  }
1572
- e = this.nodeFactory.create(Z, n);
1573
- } else if (e = this.extractOperand(), e instanceof Re)
1574
+ e = this.nodeFactory.create(K, n);
1575
+ } else if (e = this.extractOperand(), e instanceof Ue)
1574
1576
  throw new N(
1575
1577
  this.peek(),
1576
- this.nodeFactory.create(Re, { pre: this.peek() }),
1578
+ this.nodeFactory.create(Ue, { pre: this.peek() }),
1577
1579
  this.contextStack.findHandlerContext(this.tokens, this.current)
1578
1580
  );
1579
1581
  return e;
@@ -1597,7 +1599,7 @@ class Sn {
1597
1599
  this.peek(),
1598
1600
  o.INVALID_OPERAND,
1599
1601
  `Invalid start of operand "${this.peek().value}"`
1600
- ), this.nodeFactory.create(Re, { pre: this.previous() }));
1602
+ ), this.nodeFactory.create(Ue, { pre: this.previous() }));
1601
1603
  }
1602
1604
  /* Parsing FunctionExpression */
1603
1605
  functionExpression() {
@@ -1629,7 +1631,7 @@ class Sn {
1629
1631
  h.NUMERIC_LITERAL
1630
1632
  ))
1631
1633
  return this.nodeFactory.create(G, {
1632
- expression: this.nodeFactory.create(ge, { literal: this.previous() })
1634
+ expression: this.nodeFactory.create(ve, { literal: this.previous() })
1633
1635
  });
1634
1636
  if (this.match(h.QUOTED_STRING, h.IDENTIFIER))
1635
1637
  return this.nodeFactory.create(G, {
@@ -1713,10 +1715,10 @@ const xn = {
1713
1715
  "!=": { left: 4, right: 5 },
1714
1716
  ".": { left: 16, right: 17 }
1715
1717
  };
1716
- function Pn(t) {
1718
+ function Dn(t) {
1717
1719
  return xn[t.value] || { left: null, right: null };
1718
1720
  }
1719
- const Dn = {
1721
+ const On = {
1720
1722
  "+": { left: null, right: 15 },
1721
1723
  "-": { left: null, right: 15 },
1722
1724
  "<": { left: null, right: 15 },
@@ -1724,17 +1726,17 @@ const Dn = {
1724
1726
  "<>": { left: null, right: 15 },
1725
1727
  "!": { left: null, right: 15 }
1726
1728
  };
1727
- function On(t) {
1728
- return Dn[t.value] || { left: null, right: null };
1729
+ function Rn(t) {
1730
+ return On[t.value] || { left: null, right: null };
1729
1731
  }
1730
- const Rn = {
1732
+ const Un = {
1731
1733
  "(": { left: 14, right: null }
1732
1734
  };
1733
1735
  function Tt(t) {
1734
- return Rn[t.value] || { left: null, right: null };
1736
+ return Un[t.value] || { left: null, right: null };
1735
1737
  }
1736
1738
  var I = /* @__PURE__ */ ((t) => (t.Table = "table", t.Enum = "enum", t.Ref = "ref", t.Note = "note", t.Project = "project", t.Indexes = "indexes", t.TableGroup = "tablegroup", t.TablePartial = "tablepartial", t))(I || {});
1737
- function Pe(t) {
1739
+ function xe(t) {
1738
1740
  var n;
1739
1741
  const e = (n = t == null ? void 0 : t.type) == null ? void 0 : n.value.toLowerCase();
1740
1742
  switch (e) {
@@ -1748,51 +1750,51 @@ function Pe(t) {
1748
1750
  case I.TablePartial:
1749
1751
  return new O(e);
1750
1752
  default:
1751
- return new P();
1753
+ return new x();
1752
1754
  }
1753
1755
  }
1754
- function Ie(t) {
1755
- if (!Ye(t))
1756
+ function _e(t) {
1757
+ if (!qe(t))
1756
1758
  return new O([t]);
1757
- const e = Ie(t.leftExpression).unwrap_or(void 0);
1758
- return e ? (e.push(t.rightExpression), new O(e)) : new P();
1759
+ const e = _e(t.leftExpression).unwrap_or(void 0);
1760
+ return e ? (e.push(t.rightExpression), new O(e)) : new x();
1759
1761
  }
1760
1762
  function z(t) {
1761
1763
  if (t === void 0)
1762
- return new P();
1763
- const e = Ie(t).unwrap_or(void 0);
1764
+ return new x();
1765
+ const e = _e(t).unwrap_or(void 0);
1764
1766
  if (!e)
1765
- return new P();
1767
+ return new x();
1766
1768
  const n = [];
1767
1769
  for (const s of e) {
1768
1770
  const i = W(s).unwrap_or(void 0);
1769
1771
  if (!i)
1770
- return new P();
1772
+ return new x();
1771
1773
  n.push(i);
1772
1774
  }
1773
1775
  return new O(n);
1774
1776
  }
1775
1777
  function Se(t) {
1776
1778
  if (t === void 0)
1777
- return new P();
1778
- const e = Ie(t).unwrap_or(void 0);
1779
+ return new x();
1780
+ const e = _e(t).unwrap_or(void 0);
1779
1781
  if (!e || e.length === 0)
1780
- return new P();
1782
+ return new x();
1781
1783
  const n = [];
1782
1784
  let s;
1783
- if (!$(_.last(e))) {
1785
+ if (!j(_.last(e))) {
1784
1786
  const i = e.pop();
1785
- if (Ct(i))
1787
+ if (Xt(i))
1786
1788
  s = i.elementList.map(
1787
- (a) => X(a).unwrap()
1789
+ (a) => $(a).unwrap()
1788
1790
  );
1789
1791
  else
1790
- return new P();
1792
+ return new x();
1791
1793
  }
1792
1794
  for (const i of e) {
1793
1795
  const a = W(i).unwrap_or(void 0);
1794
1796
  if (!a)
1795
- return new P();
1797
+ return new x();
1796
1798
  n.push(a);
1797
1799
  }
1798
1800
  return new O({
@@ -1801,32 +1803,32 @@ function Se(t) {
1801
1803
  });
1802
1804
  }
1803
1805
  function W(t) {
1804
- return $(t) ? new O(t.expression.variable.value) : new P();
1806
+ return j(t) ? new O(t.expression.variable.value) : new x();
1805
1807
  }
1806
- function Ve(t) {
1808
+ function Ge(t) {
1807
1809
  if (bt(t))
1808
1810
  return t instanceof ce ? new O({ functional: [t], nonFunctional: [] }) : new O({ functional: [], nonFunctional: [t] });
1809
1811
  if (t instanceof fe && t.elementList.every(bt)) {
1810
1812
  const e = t.elementList.filter(
1811
1813
  (s) => s instanceof ce
1812
- ), n = t.elementList.filter($);
1814
+ ), n = t.elementList.filter(j);
1813
1815
  return new O({ functional: e, nonFunctional: n });
1814
1816
  }
1815
- return new P();
1817
+ return new x();
1816
1818
  }
1817
- function X(t) {
1819
+ function $(t) {
1818
1820
  var n;
1819
1821
  const e = (n = t == null ? void 0 : t.expression.variable) == null ? void 0 : n.value;
1820
- return e === void 0 ? new P() : new O(e);
1822
+ return e === void 0 ? new x() : new O(e);
1821
1823
  }
1822
- function U(t) {
1823
- return C(t) ? t.expression instanceof ae ? new O(t.expression.variable.value) : new O(t.expression.literal.value) : new P();
1824
+ function M(t) {
1825
+ return C(t) ? t.expression instanceof ae ? new O(t.expression.variable.value) : new O(t.expression.literal.value) : new x();
1824
1826
  }
1825
- function Un(t) {
1827
+ function Mn(t) {
1826
1828
  var e;
1827
- return !(t instanceof le) || !Bt((e = t.op) == null ? void 0 : e.value) ? !1 : Se(t.leftExpression).and_then(() => Se(t.rightExpression)).unwrap_or(void 0) !== void 0;
1829
+ return !(t instanceof le) || !Vt((e = t.op) == null ? void 0 : e.value) ? !1 : Se(t.leftExpression).and_then(() => Se(t.rightExpression)).unwrap_or(void 0) !== void 0;
1828
1830
  }
1829
- function Mn(t) {
1831
+ function Fn(t) {
1830
1832
  const e = Se(t.leftExpression), n = Se(t.rightExpression);
1831
1833
  if (!e.isOk() || !n.isOk())
1832
1834
  return !1;
@@ -1839,18 +1841,18 @@ function bt(t) {
1839
1841
  function It(t, e) {
1840
1842
  var i, a, r, c;
1841
1843
  let n = e;
1842
- const s = cn(t);
1844
+ const s = un(t);
1843
1845
  for (; n; ) {
1844
1846
  if ((a = (i = n.symbol) == null ? void 0 : i.symbolTable) != null && a.has(t))
1845
1847
  return (r = n.symbol.symbolTable) == null ? void 0 : r.get(t);
1846
- if (((c = n.symbol) == null ? void 0 : c.declaration) instanceof K && s)
1848
+ if (((c = n.symbol) == null ? void 0 : c.declaration) instanceof Z && s)
1847
1849
  return n.symbol;
1848
- if (n instanceof K)
1850
+ if (n instanceof Z)
1849
1851
  return;
1850
1852
  n = n.parent;
1851
1853
  }
1852
1854
  }
1853
- class Fn {
1855
+ class Bn {
1854
1856
  constructor(e, n, s) {
1855
1857
  this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
1856
1858
  }
@@ -1858,7 +1860,7 @@ class Fn {
1858
1860
  return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
1859
1861
  }
1860
1862
  validateContext() {
1861
- return this.declarationNode.parent instanceof K || Pe(this.declarationNode.parent).unwrap_or(void 0) !== I.Project ? [new l(o.INVALID_CUSTOM_CONTEXT, "A custom element can only appear in a Project", this.declarationNode)] : [];
1863
+ return this.declarationNode.parent instanceof Z || xe(this.declarationNode.parent).unwrap_or(void 0) !== I.Project ? [new l(o.INVALID_CUSTOM_CONTEXT, "A custom element can only appear in a Project", this.declarationNode)] : [];
1862
1864
  }
1863
1865
  validateName(e) {
1864
1866
  return e ? [new l(o.UNEXPECTED_NAME, "A Custom element shouldn't have a name", e)] : [];
@@ -1878,7 +1880,7 @@ class Fn {
1878
1880
  return C(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;
1879
1881
  }
1880
1882
  }
1881
- class ve {
1883
+ class we {
1882
1884
  constructor() {
1883
1885
  this.table = /* @__PURE__ */ new Map();
1884
1886
  }
@@ -1898,7 +1900,7 @@ class ve {
1898
1900
  return this.table.forEach(e);
1899
1901
  }
1900
1902
  }
1901
- class Bn {
1903
+ class Vn {
1902
1904
  constructor(e, n, s) {
1903
1905
  this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
1904
1906
  }
@@ -1909,17 +1911,17 @@ class Bn {
1909
1911
  return this.declarationNode.parent instanceof y ? [new l(o.INVALID_PROJECT_CONTEXT, "An Enum can only appear top-level", this.declarationNode)] : [];
1910
1912
  }
1911
1913
  validateName(e) {
1912
- return e ? Ft(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)];
1914
+ return e ? Bt(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)];
1913
1915
  }
1914
1916
  validateAlias(e) {
1915
1917
  return e ? [new l(o.UNEXPECTED_ALIAS, "A Ref shouldn't have an alias", e)] : [];
1916
1918
  }
1917
1919
  registerElement() {
1918
1920
  const e = [];
1919
- this.declarationNode.symbol = this.symbolFactory.create(En, { declaration: this.declarationNode, symbolTable: new ve() });
1921
+ this.declarationNode.symbol = this.symbolFactory.create(Nn, { declaration: this.declarationNode, symbolTable: new we() });
1920
1922
  const { name: n } = this.declarationNode, s = z(n);
1921
1923
  if (s.isOk()) {
1922
- const i = s.unwrap(), a = i.pop(), r = qe(i, this.publicSymbolTable, this.symbolFactory), c = st(a);
1924
+ const i = s.unwrap(), a = i.pop(), r = ze(i, this.publicSymbolTable, this.symbolFactory), c = st(a);
1923
1925
  r.has(c) && e.push(new l(o.DUPLICATE_NAME, `Enum name ${a} already exists in schema '${i.join(".") || "public"}'`, n)), r.set(c, this.declarationNode.symbol);
1924
1926
  }
1925
1927
  return e;
@@ -1930,15 +1932,15 @@ class Bn {
1930
1932
  validateBody(e) {
1931
1933
  if (!e)
1932
1934
  return [];
1933
- if (e instanceof w)
1935
+ if (e instanceof v)
1934
1936
  return this.validateFields([e]);
1935
- const [n, s] = _.partition(e.body, (i) => i instanceof w);
1937
+ const [n, s] = _.partition(e.body, (i) => i instanceof v);
1936
1938
  return [...this.validateFields(n), ...this.validateSubElements(s)];
1937
1939
  }
1938
1940
  validateFields(e) {
1939
1941
  return e.length === 0 ? [new l(o.EMPTY_ENUM, "An Enum must have at least one element", this.declarationNode)] : e.flatMap((n) => {
1940
1942
  const s = [];
1941
- n.callee && !$(n.callee) && s.push(new l(o.INVALID_ENUM_ELEMENT_NAME, "An enum field must be an identifier or a quoted identifier", n.callee));
1943
+ n.callee && !j(n.callee) && s.push(new l(o.INVALID_ENUM_ELEMENT_NAME, "An enum field must be an identifier or a quoted identifier", n.callee));
1942
1944
  const i = [...n.args];
1943
1945
  return _.last(i) instanceof R ? (s.push(...this.validateFieldSettings(_.last(i))), i.pop()) : i[0] instanceof R && (s.push(...this.validateFieldSettings(i[0])), i.shift()), i.length > 0 && s.push(...i.map((a) => new l(o.INVALID_ENUM_ELEMENT, "An Enum must have only a field and optionally a setting list", a))), s.push(...this.registerField(n)), s;
1944
1946
  });
@@ -1968,8 +1970,8 @@ class Bn {
1968
1970
  });
1969
1971
  }
1970
1972
  registerField(e) {
1971
- if (e.callee && $(e.callee)) {
1972
- const n = X(e.callee).unwrap(), s = it(n), i = this.symbolFactory.create(Nn, { declaration: e });
1973
+ if (e.callee && j(e.callee)) {
1974
+ const n = $(e.callee).unwrap(), s = it(n), i = this.symbolFactory.create(mn, { declaration: e });
1973
1975
  e.symbol = i;
1974
1976
  const a = this.declarationNode.symbol.symbolTable;
1975
1977
  if (a.has(s)) {
@@ -1984,7 +1986,7 @@ class Bn {
1984
1986
  return [];
1985
1987
  }
1986
1988
  }
1987
- class Vn {
1989
+ class Gn {
1988
1990
  constructor(e, n, s) {
1989
1991
  this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
1990
1992
  }
@@ -1992,13 +1994,13 @@ class Vn {
1992
1994
  return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
1993
1995
  }
1994
1996
  validateContext() {
1995
- if (this.declarationNode.parent instanceof K)
1997
+ if (this.declarationNode.parent instanceof Z)
1996
1998
  return [new l(
1997
1999
  o.INVALID_NOTE_CONTEXT,
1998
2000
  "An Indexes can only appear inside a Table or a TablePartial",
1999
2001
  this.declarationNode
2000
2002
  )];
2001
- const e = Pe(this.declarationNode.parent).unwrap_or(void 0);
2003
+ const e = xe(this.declarationNode.parent).unwrap_or(void 0);
2002
2004
  return e && [I.Table, I.TablePartial].includes(e) ? [] : [new l(
2003
2005
  o.INVALID_NOTE_CONTEXT,
2004
2006
  "An Indexes can only appear inside a Table or a TablePartial",
@@ -2017,9 +2019,9 @@ class Vn {
2017
2019
  validateBody(e) {
2018
2020
  if (!e)
2019
2021
  return [];
2020
- if (e instanceof w)
2022
+ if (e instanceof v)
2021
2023
  return [new l(o.UNEXPECTED_SIMPLE_BODY, "An Indexes must have a complex body", e)];
2022
- const [n, s] = _.partition(e.body, (i) => i instanceof w);
2024
+ const [n, s] = _.partition(e.body, (i) => i instanceof v);
2023
2025
  return [...this.validateFields(n), ...this.validateSubElements(s)];
2024
2026
  }
2025
2027
  validateFields(e) {
@@ -2029,8 +2031,8 @@ class Vn {
2029
2031
  const s = [], i = [n.callee, ...n.args];
2030
2032
  return _.last(i) instanceof R && s.push(...this.validateFieldSetting(i.pop())), i.forEach((a) => {
2031
2033
  for (; a instanceof Y; )
2032
- a.argumentList && !Ve(a.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", a.argumentList)), a = a.callee;
2033
- Ve(a).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", a));
2034
+ a.argumentList && !Ge(a.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", a.argumentList)), a = a.callee;
2035
+ Ge(a).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", a));
2034
2036
  }), s;
2035
2037
  });
2036
2038
  }
@@ -2053,7 +2055,7 @@ class Vn {
2053
2055
  break;
2054
2056
  case "type":
2055
2057
  r.length > 1 && r.forEach((c) => s.push(new l(o.DUPLICATE_INDEX_SETTING, "'type' can only appear once", c))), r.forEach((c) => {
2056
- $(c.value) || s.push(new l(o.INVALID_INDEX_SETTING_VALUE, `'type' must be "btree" or "hash"`, c));
2058
+ j(c.value) || s.push(new l(o.INVALID_INDEX_SETTING_VALUE, `'type' must be "btree" or "hash"`, c));
2057
2059
  });
2058
2060
  break;
2059
2061
  default:
@@ -2071,7 +2073,7 @@ class Vn {
2071
2073
  });
2072
2074
  }
2073
2075
  }
2074
- class Gn {
2076
+ class Cn {
2075
2077
  constructor(e, n, s) {
2076
2078
  this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
2077
2079
  }
@@ -2085,26 +2087,26 @@ class Gn {
2085
2087
  ];
2086
2088
  }
2087
2089
  validateContext() {
2088
- return !(this.declarationNode.parent instanceof K) && ![
2090
+ return !(this.declarationNode.parent instanceof Z) && ![
2089
2091
  I.Table,
2090
2092
  I.TableGroup,
2091
2093
  I.TablePartial,
2092
2094
  I.Project
2093
- ].includes(Pe(this.declarationNode.parent).unwrap_or(void 0)) ? [new l(
2095
+ ].includes(xe(this.declarationNode.parent).unwrap_or(void 0)) ? [new l(
2094
2096
  o.INVALID_NOTE_CONTEXT,
2095
2097
  "A Note can only appear inside a Table, a TableGroup, a TablePartial or a Project. Sticky note can only appear at the global scope.",
2096
2098
  this.declarationNode
2097
2099
  )] : [];
2098
2100
  }
2099
2101
  validateName(e) {
2100
- if (!(this.declarationNode.parent instanceof K))
2102
+ if (!(this.declarationNode.parent instanceof Z))
2101
2103
  return e ? [new l(o.UNEXPECTED_NAME, "A Note shouldn't have a name", e)] : [];
2102
2104
  if (!e)
2103
2105
  return [new l(o.INVALID_NAME, "Sticky note must have a name", this.declarationNode)];
2104
2106
  const n = z(e);
2105
2107
  if (!n.isOk())
2106
2108
  return [new l(o.INVALID_NAME, "Invalid name for sticky note ", this.declarationNode)];
2107
- const i = n.unwrap().join("."), a = on(i);
2109
+ const i = n.unwrap().join("."), a = ln(i);
2108
2110
  return this.publicSymbolTable.has(a) ? [new l(o.DUPLICATE_NAME, `Sticky note "${i}" has already been defined`, e)] : (this.publicSymbolTable.set(a, this.declarationNode.symbol), []);
2109
2111
  }
2110
2112
  validateAlias(e) {
@@ -2116,9 +2118,9 @@ class Gn {
2116
2118
  validateBody(e) {
2117
2119
  if (!e)
2118
2120
  return [];
2119
- if (e instanceof w)
2121
+ if (e instanceof v)
2120
2122
  return this.validateFields([e]);
2121
- const [n, s] = _.partition(e.body, (i) => i instanceof w);
2123
+ const [n, s] = _.partition(e.body, (i) => i instanceof v);
2122
2124
  return [...this.validateFields(n), ...this.validateSubElements(s)];
2123
2125
  }
2124
2126
  validateFields(e) {
@@ -2134,7 +2136,7 @@ class Gn {
2134
2136
  });
2135
2137
  }
2136
2138
  }
2137
- class Cn {
2139
+ class Xn {
2138
2140
  constructor(e, n, s) {
2139
2141
  this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
2140
2142
  }
@@ -2145,7 +2147,7 @@ class Cn {
2145
2147
  return this.declarationNode.parent instanceof y ? [new l(o.INVALID_PROJECT_CONTEXT, "A Project can only appear top-level", this.declarationNode)] : [];
2146
2148
  }
2147
2149
  validateName(e) {
2148
- return e ? we(e) ? [] : [new l(o.INVALID_NAME, "A Project's name is optional or must be an identifier or a quoted identifer", e)] : [];
2150
+ return e ? ye(e) ? [] : [new l(o.INVALID_NAME, "A Project's name is optional or must be an identifier or a quoted identifer", e)] : [];
2149
2151
  }
2150
2152
  validateAlias(e) {
2151
2153
  return e ? [new l(o.UNEXPECTED_ALIAS, "A Project shouldn't have an alias", e)] : [];
@@ -2156,9 +2158,9 @@ class Cn {
2156
2158
  validateBody(e) {
2157
2159
  if (!e)
2158
2160
  return [];
2159
- if (e instanceof w)
2161
+ if (e instanceof v)
2160
2162
  return [new l(o.UNEXPECTED_SIMPLE_BODY, "A Project's body must be a block", e)];
2161
- const [n, s] = _.partition(e.body, (i) => i instanceof w);
2163
+ const [n, s] = _.partition(e.body, (i) => i instanceof v);
2162
2164
  return [
2163
2165
  ...n.map((i) => new l(o.INVALID_PROJECT_FIELD, "A Project can not have inline fields", i)),
2164
2166
  ...this.validateSubElements(s)
@@ -2173,7 +2175,7 @@ class Cn {
2173
2175
  });
2174
2176
  }
2175
2177
  }
2176
- class Xn {
2178
+ class $n {
2177
2179
  constructor(e, n, s) {
2178
2180
  this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
2179
2181
  }
@@ -2181,10 +2183,10 @@ class Xn {
2181
2183
  return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
2182
2184
  }
2183
2185
  validateContext() {
2184
- return this.declarationNode.parent instanceof K ? [] : [new l(o.INVALID_REF_CONTEXT, "A Ref must appear top-level", this.declarationNode)];
2186
+ return this.declarationNode.parent instanceof Z ? [] : [new l(o.INVALID_REF_CONTEXT, "A Ref must appear top-level", this.declarationNode)];
2185
2187
  }
2186
2188
  validateName(e) {
2187
- return e ? we(e) ? [] : [new l(o.INVALID_NAME, "A Ref's name is optional or must be an identifier or a quoted identifer", e)] : [];
2189
+ return e ? ye(e) ? [] : [new l(o.INVALID_NAME, "A Ref's name is optional or must be an identifier or a quoted identifer", e)] : [];
2188
2190
  }
2189
2191
  validateAlias(e) {
2190
2192
  return e ? [new l(o.UNEXPECTED_ALIAS, "A Ref shouldn't have an alias", e)] : [];
@@ -2195,9 +2197,9 @@ class Xn {
2195
2197
  validateBody(e) {
2196
2198
  if (!e)
2197
2199
  return [];
2198
- if (e instanceof w)
2200
+ if (e instanceof v)
2199
2201
  return this.validateFields([e]);
2200
- const [n, s] = _.partition(e.body, (i) => i instanceof w);
2202
+ const [n, s] = _.partition(e.body, (i) => i instanceof v);
2201
2203
  return [...this.validateFields(n), ...this.validateSubElements(s)];
2202
2204
  }
2203
2205
  validateFields(e) {
@@ -2205,7 +2207,7 @@ class Xn {
2205
2207
  return [new l(o.EMPTY_REF, "A Ref must have at least one field", this.declarationNode)];
2206
2208
  const n = [];
2207
2209
  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) => {
2208
- s.callee && !Un(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));
2210
+ s.callee && !Mn(s.callee) && n.push(new l(o.INVALID_REF_FIELD, "A Ref field must be a binary relationship", s.callee)), s.callee && !Fn(s.callee) && n.push(new l(o.UNEQUAL_FIELDS_BINARY_REF, "Unequal fields in ref endpoints", s.callee));
2209
2211
  const i = [...s.args];
2210
2212
  if (_.last(i) instanceof R) {
2211
2213
  const a = this.validateFieldSettings(_.last(i));
@@ -2223,12 +2225,12 @@ class Xn {
2223
2225
  case "delete":
2224
2226
  case "update":
2225
2227
  r.length > 1 && r.forEach((c) => s.push(new l(o.DUPLICATE_REF_SETTING, `'${a}' can only appear once`, c))), r.forEach((c) => {
2226
- $n(c.value) || s.push(new l(o.INVALID_REF_SETTING_VALUE, `'${a}' can only have values "cascade", "no action", "set null", "set default" or "restrict"`, c));
2228
+ jn(c.value) || s.push(new l(o.INVALID_REF_SETTING_VALUE, `'${a}' can only have values "cascade", "no action", "set null", "set default" or "restrict"`, c));
2227
2229
  });
2228
2230
  break;
2229
2231
  case "color":
2230
2232
  r.length > 1 && s.push(...r.map((c) => new l(o.DUPLICATE_REF_SETTING, "'color' can only appear once", c))), r.forEach((c) => {
2231
- ze(c.value) || s.push(new l(o.INVALID_REF_SETTING_VALUE, "'color' must be a color literal", c));
2233
+ Qe(c.value) || s.push(new l(o.INVALID_REF_SETTING_VALUE, "'color' must be a color literal", c));
2232
2234
  });
2233
2235
  break;
2234
2236
  default:
@@ -2246,11 +2248,11 @@ class Xn {
2246
2248
  });
2247
2249
  }
2248
2250
  }
2249
- function $n(t) {
2250
- if (!($(t) && t.expression.variable.kind !== h.QUOTED_STRING) && !(t instanceof ne))
2251
+ function jn(t) {
2252
+ if (!(j(t) && t.expression.variable.kind !== h.QUOTED_STRING) && !(t instanceof ne))
2251
2253
  return !1;
2252
2254
  let e;
2253
- if (t instanceof ne ? e = Ae(t).unwrap_or("") : e = t.expression.variable.value, e)
2255
+ if (t instanceof ne ? e = ge(t).unwrap_or("") : e = t.expression.variable.value, e)
2254
2256
  switch (e.toLowerCase()) {
2255
2257
  case "cascade":
2256
2258
  case "no action":
@@ -2263,7 +2265,7 @@ function $n(t) {
2263
2265
  }
2264
2266
  return !1;
2265
2267
  }
2266
- class jn {
2268
+ class Wn {
2267
2269
  constructor(e, n, s) {
2268
2270
  this.declarationNode = e, this.symbolFactory = s, this.publicSymbolTable = n;
2269
2271
  }
@@ -2274,10 +2276,10 @@ class jn {
2274
2276
  return this.declarationNode.parent instanceof y ? [new l(o.INVALID_TABLE_CONTEXT, "Table must appear top-level", this.declarationNode)] : [];
2275
2277
  }
2276
2278
  validateName(e) {
2277
- return e ? e instanceof ue ? [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)] : Ft(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)];
2279
+ return e ? e instanceof ue ? [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)] : Bt(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)];
2278
2280
  }
2279
2281
  validateAlias(e) {
2280
- return e ? Hn(e) ? [] : [new l(o.INVALID_ALIAS, "Table aliases can only contains alphanumeric and underscore unless surrounded by double quotes", e)] : [];
2282
+ return e ? Jn(e) ? [] : [new l(o.INVALID_ALIAS, "Table aliases can only contains alphanumeric and underscore unless surrounded by double quotes", e)] : [];
2281
2283
  }
2282
2284
  validateSettingList(e) {
2283
2285
  const n = F(e), s = n.getErrors(), i = n.getValue();
@@ -2286,7 +2288,7 @@ class jn {
2286
2288
  switch (a) {
2287
2289
  case "headercolor":
2288
2290
  r.length > 1 && s.push(...r.map((c) => new l(o.DUPLICATE_TABLE_SETTING, "'headercolor' can only appear once", c))), r.forEach((c) => {
2289
- ze(c.value) || s.push(new l(o.INVALID_TABLE_SETTING, "'headercolor' must be a color literal", c.value || c.name));
2291
+ Qe(c.value) || s.push(new l(o.INVALID_TABLE_SETTING, "'headercolor' must be a color literal", c.value || c.name));
2290
2292
  });
2291
2293
  break;
2292
2294
  case "note":
@@ -2302,14 +2304,14 @@ class jn {
2302
2304
  }
2303
2305
  registerElement() {
2304
2306
  const e = [];
2305
- this.declarationNode.symbol = this.symbolFactory.create(Rt, { declaration: this.declarationNode, symbolTable: new ve() });
2307
+ this.declarationNode.symbol = this.symbolFactory.create(Ut, { declaration: this.declarationNode, symbolTable: new we() });
2306
2308
  const { name: n, alias: s } = this.declarationNode, i = z(n);
2307
2309
  if (i.isOk()) {
2308
- const a = [...i.unwrap()], r = a.pop(), c = qe(a, this.publicSymbolTable, this.symbolFactory), f = Fe(r);
2310
+ const a = [...i.unwrap()], r = a.pop(), c = ze(a, this.publicSymbolTable, this.symbolFactory), f = Be(r);
2309
2311
  c.has(f) && e.push(new l(o.DUPLICATE_NAME, `Table name '${r}' already exists in schema '${a.join(".") || "public"}'`, n)), c.set(f, this.declarationNode.symbol);
2310
2312
  }
2311
- if (s && we(s) && !Yn(s.expression.variable.value, i.unwrap_or([]))) {
2312
- const a = X(s).unwrap(), r = Fe(a);
2313
+ if (s && ye(s) && !qn(s.expression.variable.value, i.unwrap_or([]))) {
2314
+ const a = $(s).unwrap(), r = Be(a);
2313
2315
  this.publicSymbolTable.has(r) && e.push(new l(o.DUPLICATE_NAME, `Table name '${a}' already exists`, n)), this.publicSymbolTable.set(r, this.declarationNode.symbol);
2314
2316
  }
2315
2317
  return e;
@@ -2317,9 +2319,9 @@ class jn {
2317
2319
  validateBody(e) {
2318
2320
  if (!e)
2319
2321
  return [];
2320
- if (e instanceof w)
2322
+ if (e instanceof v)
2321
2323
  return [new l(o.UNEXPECTED_SIMPLE_BODY, "A Table's body must be a block", e)];
2322
- const [n, s] = _.partition(e.body, (r) => r instanceof w), [i, a] = _.partition(s, (r) => r instanceof ke);
2324
+ const [n, s] = _.partition(e.body, (r) => r instanceof v), [i, a] = _.partition(s, (r) => r instanceof Le);
2323
2325
  return [
2324
2326
  ...this.validateFields(n),
2325
2327
  ...this.validateInjections(i),
@@ -2327,7 +2329,7 @@ class jn {
2327
2329
  ];
2328
2330
  }
2329
2331
  validateFields(e) {
2330
- const [n, s, i] = e.reduce((a, r) => (r.callee instanceof G ? a[0].push(r) : r.callee instanceof Z ? a[1].push(r) : a[2].push(new l(o.INVALID_TABLE_FIELD, "A Table field must be a column or a TablePartial injection", r)), a), [[], [], []]);
2332
+ const [n, s, i] = e.reduce((a, r) => (r.callee instanceof G ? a[0].push(r) : r.callee instanceof K ? a[1].push(r) : a[2].push(new l(o.INVALID_TABLE_FIELD, "A Table field must be a column or a TablePartial injection", r)), a), [[], [], []]);
2331
2333
  return [
2332
2334
  ...i,
2333
2335
  ...this.validateColumns(n),
@@ -2340,7 +2342,7 @@ class jn {
2340
2342
  registerInjection(e) {
2341
2343
  var n, s;
2342
2344
  if (e.partial && ((n = e.partial.variable) != null && n.value)) {
2343
- const i = (s = e.partial.variable) == null ? void 0 : s.value, a = ln(i), r = this.symbolFactory.create(In, { declaration: e });
2345
+ const i = (s = e.partial.variable) == null ? void 0 : s.value, a = cn(i), r = this.symbolFactory.create(Ln, { declaration: e });
2344
2346
  e.symbol = r;
2345
2347
  const c = this.declarationNode.symbol.symbolTable, f = c.get(a);
2346
2348
  if (f)
@@ -2355,14 +2357,14 @@ class jn {
2355
2357
  validateColumns(e) {
2356
2358
  return e.length === 0 ? [new l(o.EMPTY_TABLE, "A Table must have at least one column", this.declarationNode)] : e.flatMap((n) => {
2357
2359
  const s = [];
2358
- n.args.length === 0 && s.push(new l(o.INVALID_COLUMN, "A column must have a type", n.callee)), $(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] && !Wn(n.args[0]) && s.push(new l(o.INVALID_COLUMN_TYPE, "Invalid column type", n.args[0]));
2360
+ n.args.length === 0 && s.push(new l(o.INVALID_COLUMN, "A column must have a type", n.callee)), j(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]));
2359
2361
  const i = n.args.slice(1);
2360
2362
  return s.push(...this.validateColumnSetting(i)), s.push(...this.registerColumn(n)), s;
2361
2363
  });
2362
2364
  }
2363
2365
  registerColumn(e) {
2364
- if (e.callee && $(e.callee)) {
2365
- const n = X(e.callee).unwrap(), s = je(n), i = this.symbolFactory.create(Ut, { declaration: e });
2366
+ if (e.callee && j(e.callee)) {
2367
+ const n = $(e.callee).unwrap(), s = We(n), i = this.symbolFactory.create(Mt, { declaration: e });
2366
2368
  e.symbol = i;
2367
2369
  const a = this.declarationNode.symbol.symbolTable;
2368
2370
  if (a.has(s)) {
@@ -2386,7 +2388,7 @@ class jn {
2386
2388
  _.last(e) instanceof R && (n = e.pop());
2387
2389
  const s = F(n), i = s.getErrors(), a = s.getValue();
2388
2390
  for (const f of e) {
2389
- const p = X(f).unwrap_or("").toLowerCase();
2391
+ const p = $(f).unwrap_or("").toLowerCase();
2390
2392
  if (p !== "pk" && p !== "unique") {
2391
2393
  i.push(new l(o.INVALID_SETTINGS, "Inline column settings can only be `pk` or `unique`", f));
2392
2394
  continue;
@@ -2405,7 +2407,7 @@ class jn {
2405
2407
  break;
2406
2408
  case "ref":
2407
2409
  p.forEach((u) => {
2408
- Gt(u.value) || i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'ref' must be a valid unary relationship", u.value || u.name));
2410
+ Ct(u.value) || i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'ref' must be a valid unary relationship", u.value || u.name));
2409
2411
  });
2410
2412
  break;
2411
2413
  case "primary key":
@@ -2442,7 +2444,7 @@ class jn {
2442
2444
  break;
2443
2445
  case "default":
2444
2446
  p.length > 1 && i.push(...p.map((u) => new l(o.DUPLICATE_TABLE_SETTING, "'default' can only appear once", u))), p.forEach((u) => {
2445
- Vt(u.value) || i.push(new l(o.INVALID_TABLE_SETTING, "'default' must be a string literal, number literal, function expression, true, false or null", u.value || u.name));
2447
+ Gt(u.value) || i.push(new l(o.INVALID_TABLE_SETTING, "'default' must be a string literal, number literal, function expression, true, false or null", u.value || u.name));
2446
2448
  });
2447
2449
  break;
2448
2450
  default:
@@ -2466,8 +2468,8 @@ class jn {
2466
2468
  return s.length > 1 && n.push(...s.map((i) => new l(o.NOTE_REDEFINED, "Duplicate notes are defined", i))), n;
2467
2469
  }
2468
2470
  }
2469
- function Wn(t) {
2470
- if (!(t instanceof Y || Ye(t) || t instanceof G || t instanceof ue))
2471
+ function Yn(t) {
2472
+ if (!(t instanceof Y || qe(t) || t instanceof G || t instanceof ue))
2471
2473
  return !1;
2472
2474
  if (t instanceof Y) {
2473
2475
  if (t.callee === void 0 || t.argumentList === void 0 || !t.argumentList.elementList.every((n) => ee(n) || C(n) || he(n)))
@@ -2482,10 +2484,10 @@ function Wn(t) {
2482
2484
  const e = z(t).unwrap_or(void 0);
2483
2485
  return e !== void 0 && e.length > 0;
2484
2486
  }
2485
- function Yn(t, e) {
2487
+ function qn(t, e) {
2486
2488
  return e.length === 1 && t === e[0];
2487
2489
  }
2488
- class qn {
2490
+ class zn {
2489
2491
  constructor(e, n, s) {
2490
2492
  this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
2491
2493
  }
@@ -2507,7 +2509,7 @@ class qn {
2507
2509
  )] : [];
2508
2510
  }
2509
2511
  validateName(e) {
2510
- return e ? we(e) ? [] : [new l(
2512
+ return e ? ye(e) ? [] : [new l(
2511
2513
  o.INVALID_NAME,
2512
2514
  "A TableGroup name must be a single identifier",
2513
2515
  e
@@ -2526,10 +2528,10 @@ class qn {
2526
2528
  }
2527
2529
  registerElement() {
2528
2530
  const { name: e } = this.declarationNode;
2529
- this.declarationNode.symbol = this.symbolFactory.create(mn, { declaration: this.declarationNode, symbolTable: new ve() });
2531
+ this.declarationNode.symbol = this.symbolFactory.create(Tn, { declaration: this.declarationNode, symbolTable: new we() });
2530
2532
  const n = z(e);
2531
2533
  if (n.isOk()) {
2532
- const s = n.unwrap(), i = s.pop(), a = qe(s, this.publicSymbolTable, this.symbolFactory), r = at(i);
2534
+ const s = n.unwrap(), i = s.pop(), a = ze(s, this.publicSymbolTable, this.symbolFactory), r = at(i);
2533
2535
  if (a.has(r))
2534
2536
  return [new l(o.DUPLICATE_NAME, `TableGroup name '${i}' already exists`, e)];
2535
2537
  a.set(r, this.declarationNode.symbol);
@@ -2546,7 +2548,7 @@ class qn {
2546
2548
  "'color' can only appear once",
2547
2549
  c
2548
2550
  ))), a.forEach((c) => {
2549
- ze(c.value) || s.push(new l(
2551
+ Qe(c.value) || s.push(new l(
2550
2552
  o.INVALID_TABLE_SETTING,
2551
2553
  "'color' must be a color literal",
2552
2554
  c.value || c.name
@@ -2579,13 +2581,13 @@ class qn {
2579
2581
  validateBody(e) {
2580
2582
  if (!e)
2581
2583
  return [];
2582
- if (e instanceof w)
2584
+ if (e instanceof v)
2583
2585
  return [new l(
2584
2586
  o.UNEXPECTED_SIMPLE_BODY,
2585
2587
  "A TableGroup's body must be a block",
2586
2588
  e
2587
2589
  )];
2588
- const [n, s] = _.partition(e.body, (i) => i instanceof w);
2590
+ const [n, s] = _.partition(e.body, (i) => i instanceof v);
2589
2591
  return [
2590
2592
  ...this.validateFields(n),
2591
2593
  ...this.validateSubElements(s)
@@ -2610,8 +2612,8 @@ class qn {
2610
2612
  return s.length > 1 && n.push(...s.map((i) => new l(o.NOTE_REDEFINED, "Duplicate notes are defined", i))), n;
2611
2613
  }
2612
2614
  registerField(e) {
2613
- if (e.callee && $(e.callee)) {
2614
- const n = X(e.callee).unwrap(), s = rt(n), i = this.symbolFactory.create(Tn, { declaration: e });
2615
+ if (e.callee && j(e.callee)) {
2616
+ const n = $(e.callee).unwrap(), s = rt(n), i = this.symbolFactory.create(bn, { declaration: e });
2615
2617
  e.symbol = i;
2616
2618
  const a = this.declarationNode.symbol.symbolTable;
2617
2619
  if (a.has(s)) {
@@ -2627,8 +2629,8 @@ class qn {
2627
2629
  }
2628
2630
  }
2629
2631
  const ot = ["-", "+"];
2630
- function zn(t) {
2631
- if (!(t instanceof Y || Ye(t) || t instanceof G || t instanceof ue))
2632
+ function Qn(t) {
2633
+ if (!(t instanceof Y || qe(t) || t instanceof G || t instanceof ue))
2632
2634
  return !1;
2633
2635
  if (t instanceof Y) {
2634
2636
  if (t.callee === void 0 || t.argumentList === void 0 || !t.argumentList.elementList.every((n) => ee(n) || C(n) || he(n)))
@@ -2643,7 +2645,7 @@ function zn(t) {
2643
2645
  const e = z(t).unwrap_or(void 0);
2644
2646
  return e !== void 0 && e.length > 0;
2645
2647
  }
2646
- class Qn {
2648
+ class Hn {
2647
2649
  constructor(e, n, s) {
2648
2650
  this.declarationNode = e, this.symbolFactory = s, this.publicSymbolTable = n;
2649
2651
  }
@@ -2665,7 +2667,7 @@ class Qn {
2665
2667
  )] : [];
2666
2668
  }
2667
2669
  validateName(e) {
2668
- return e ? we(e) ? [] : [new l(
2670
+ return e ? ye(e) ? [] : [new l(
2669
2671
  o.INVALID_NAME,
2670
2672
  "A TablePartial name must be an identifier or a quoted identifer",
2671
2673
  e
@@ -2688,7 +2690,7 @@ class Qn {
2688
2690
  switch (r) {
2689
2691
  case "headercolor":
2690
2692
  a.length > 1 && s.push(...a.map((c) => new l(o.DUPLICATE_TABLE_PARTIAL_SETTING, "'headercolor' can only appear once", c))), a.forEach((c) => {
2691
- ze(c.value) || s.push(new l(o.INVALID_TABLE_PARTIAL_SETTING, "'headercolor' must be a color literal", c.value || c.name));
2693
+ Qe(c.value) || s.push(new l(o.INVALID_TABLE_PARTIAL_SETTING, "'headercolor' must be a color literal", c.value || c.name));
2692
2694
  });
2693
2695
  break;
2694
2696
  case "note":
@@ -2703,10 +2705,10 @@ class Qn {
2703
2705
  }
2704
2706
  registerElement() {
2705
2707
  const { name: e } = this.declarationNode;
2706
- this.declarationNode.symbol = this.symbolFactory.create(bn, { declaration: this.declarationNode, symbolTable: new ve() });
2708
+ this.declarationNode.symbol = this.symbolFactory.create(In, { declaration: this.declarationNode, symbolTable: new we() });
2707
2709
  const n = z(e);
2708
2710
  if (n.isOk()) {
2709
- const s = n.unwrap(), i = s.pop(), a = qe(s, this.publicSymbolTable, this.symbolFactory), r = Dt(i);
2711
+ const s = n.unwrap(), i = s.pop(), a = ze(s, this.publicSymbolTable, this.symbolFactory), r = Ot(i);
2710
2712
  if (a.has(r))
2711
2713
  return [new l(o.DUPLICATE_NAME, `TablePartial name '${i}' already exists`, e)];
2712
2714
  a.set(r, this.declarationNode.symbol);
@@ -2716,9 +2718,9 @@ class Qn {
2716
2718
  validateBody(e) {
2717
2719
  if (!e)
2718
2720
  return [];
2719
- if (e instanceof w)
2721
+ if (e instanceof v)
2720
2722
  return [new l(o.UNEXPECTED_SIMPLE_BODY, "A TablePartial's body must be a block", e)];
2721
- const [n, s] = _.partition(e.body, (i) => i instanceof w);
2723
+ const [n, s] = _.partition(e.body, (i) => i instanceof v);
2722
2724
  return [...this.validateFields(n), ...this.validateSubElements(s)];
2723
2725
  }
2724
2726
  validateFields(e) {
@@ -2726,14 +2728,14 @@ class Qn {
2726
2728
  if (!n.callee)
2727
2729
  return [];
2728
2730
  const s = [];
2729
- n.args.length === 0 && s.push(new l(o.INVALID_COLUMN, "A column must have a type", n.callee)), $(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] && !zn(n.args[0]) && s.push(new l(o.INVALID_COLUMN_TYPE, "Invalid column type", n.args[0]));
2731
+ n.args.length === 0 && s.push(new l(o.INVALID_COLUMN, "A column must have a type", n.callee)), j(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] && !Qn(n.args[0]) && s.push(new l(o.INVALID_COLUMN_TYPE, "Invalid column type", n.args[0]));
2730
2732
  const i = n.args.slice(1);
2731
2733
  return s.push(...this.validateFieldSetting(i)), s.push(...this.registerField(n)), s;
2732
2734
  });
2733
2735
  }
2734
2736
  registerField(e) {
2735
- if (e.callee && $(e.callee)) {
2736
- const n = X(e.callee).unwrap(), s = je(n), i = this.symbolFactory.create(Ut, { declaration: e });
2737
+ if (e.callee && j(e.callee)) {
2738
+ const n = $(e.callee).unwrap(), s = We(n), i = this.symbolFactory.create(Mt, { declaration: e });
2737
2739
  e.symbol = i;
2738
2740
  const a = this.declarationNode.symbol.symbolTable;
2739
2741
  if (a.has(s)) {
@@ -2757,7 +2759,7 @@ class Qn {
2757
2759
  _.last(e) instanceof R && (n = e.pop());
2758
2760
  const s = F(n), i = s.getErrors(), a = s.getValue();
2759
2761
  e.forEach((f) => {
2760
- const p = X(f).unwrap_or("").toLowerCase();
2762
+ const p = $(f).unwrap_or("").toLowerCase();
2761
2763
  if (p !== "pk" && p !== "unique") {
2762
2764
  i.push(new l(o.INVALID_SETTINGS, "Inline column settings can only be `pk` or `unique`", f));
2763
2765
  return;
@@ -2778,7 +2780,7 @@ class Qn {
2778
2780
  break;
2779
2781
  case "ref":
2780
2782
  f.forEach((u) => {
2781
- Gt(u.value) || i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'ref' must be a valid unary relationship", u.value || u.name));
2783
+ Ct(u.value) || i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'ref' must be a valid unary relationship", u.value || u.name));
2782
2784
  });
2783
2785
  break;
2784
2786
  case "primary key":
@@ -2819,7 +2821,7 @@ class Qn {
2819
2821
  break;
2820
2822
  case "default":
2821
2823
  f.length > 1 && i.push(...f.map((u) => new l(o.DUPLICATE_COLUMN_SETTING, "'default' can only appear once", u))), f.forEach((u) => {
2822
- Vt(u.value) || i.push(new l(
2824
+ Gt(u.value) || i.push(new l(
2823
2825
  o.INVALID_COLUMN_SETTING_VALUE,
2824
2826
  "'default' must be a string literal, number literal, function expression, true, false or null",
2825
2827
  u.value || u.name
@@ -2847,35 +2849,35 @@ class Qn {
2847
2849
  function pe(t) {
2848
2850
  switch (t.type.value.toLowerCase()) {
2849
2851
  case I.Enum:
2850
- return Bn;
2852
+ return Vn;
2851
2853
  case I.Table:
2852
- return jn;
2854
+ return Wn;
2853
2855
  case I.TableGroup:
2854
- return qn;
2856
+ return zn;
2855
2857
  case I.Project:
2856
- return Cn;
2857
- case I.Ref:
2858
2858
  return Xn;
2859
+ case I.Ref:
2860
+ return $n;
2859
2861
  case I.Note:
2860
- return Gn;
2862
+ return Cn;
2861
2863
  case I.Indexes:
2862
- return Vn;
2864
+ return Gn;
2863
2865
  case I.TablePartial:
2864
- return Qn;
2866
+ return Hn;
2865
2867
  default:
2866
- return Fn;
2868
+ return Bn;
2867
2869
  }
2868
2870
  }
2869
- function Ft(t) {
2871
+ function Bt(t) {
2870
2872
  return !!z(t).unwrap_or(!1);
2871
2873
  }
2872
- function Hn(t) {
2873
- return we(t);
2874
+ function Jn(t) {
2875
+ return ye(t);
2874
2876
  }
2875
- function we(t) {
2877
+ function ye(t) {
2876
2878
  return t instanceof G && t.expression instanceof ae;
2877
2879
  }
2878
- function qe(t, e, n) {
2880
+ function ze(t, e, n) {
2879
2881
  var i;
2880
2882
  t[0] === "public" && (t = t.slice(1));
2881
2883
  let s = e;
@@ -2886,49 +2888,49 @@ function qe(t, e, n) {
2886
2888
  if (r = (i = s.get(c)) == null ? void 0 : i.symbolTable, !r)
2887
2889
  throw new Error("Expect a symbol table in a schema symbol");
2888
2890
  } else {
2889
- r = new ve();
2890
- const f = n.create(Ot, { symbolTable: r });
2891
+ r = new we();
2892
+ const f = n.create(Rt, { symbolTable: r });
2891
2893
  s.set(c, f);
2892
2894
  }
2893
2895
  s = r;
2894
2896
  }
2895
2897
  return s;
2896
2898
  }
2897
- function Bt(t) {
2899
+ function Vt(t) {
2898
2900
  return t === "-" || t === "<>" || t === ">" || t === "<";
2899
2901
  }
2900
- function ze(t) {
2902
+ function Qe(t) {
2901
2903
  var n;
2902
- if (!(t instanceof G) || !(t.expression instanceof ge) || ((n = t.expression.literal) == null ? void 0 : n.kind) !== h.COLOR_LITERAL)
2904
+ if (!(t instanceof G) || !(t.expression instanceof ve) || ((n = t.expression.literal) == null ? void 0 : n.kind) !== h.COLOR_LITERAL)
2903
2905
  return !1;
2904
2906
  const e = t.expression.literal.value;
2905
2907
  if (e.length !== 4 && e.length !== 7 || e[0] !== "#")
2906
2908
  return !1;
2907
2909
  for (let s = 1; s < e.length; s += 1)
2908
- if (!pn(e[s]))
2910
+ if (!dn(e[s]))
2909
2911
  return !1;
2910
2912
  return !0;
2911
2913
  }
2912
2914
  function H(t) {
2913
2915
  return t === void 0;
2914
2916
  }
2915
- function Vt(t) {
2917
+ function Gt(t) {
2916
2918
  var e;
2917
- return !!(C(t) || ee(t) || he(t) && ["true", "false", "null"].includes(t.expression.variable.value.toLowerCase()) || t instanceof Z && ot.includes((e = t.op) == null ? void 0 : e.value) && ee(t.expression) || t instanceof ce);
2919
+ return !!(C(t) || ee(t) || he(t) && ["true", "false", "null"].includes(t.expression.variable.value.toLowerCase()) || t instanceof K && ot.includes((e = t.op) == null ? void 0 : e.value) && ee(t.expression) || t instanceof ce);
2918
2920
  }
2919
2921
  function ee(t) {
2920
2922
  var e;
2921
- return t instanceof G && t.expression instanceof ge && ((e = t.expression.literal) == null ? void 0 : e.kind) === h.NUMERIC_LITERAL;
2923
+ return t instanceof G && t.expression instanceof ve && ((e = t.expression.literal) == null ? void 0 : e.kind) === h.NUMERIC_LITERAL;
2922
2924
  }
2923
- function Gt(t) {
2925
+ function Ct(t) {
2924
2926
  var n;
2925
- if (!(t instanceof Z) || !Bt((n = t.op) == null ? void 0 : n.value))
2927
+ if (!(t instanceof K) || !Vt((n = t.op) == null ? void 0 : n.value))
2926
2928
  return !1;
2927
2929
  const e = z(t.expression).unwrap_or(void 0);
2928
2930
  return e !== void 0 && e.length > 0;
2929
2931
  }
2930
- function Ct(t) {
2931
- return t instanceof fe && t.elementList.every($);
2932
+ function Xt(t) {
2933
+ return t instanceof fe && t.elementList.every(j);
2932
2934
  }
2933
2935
  function F(t) {
2934
2936
  var s;
@@ -2942,15 +2944,15 @@ function F(t) {
2942
2944
  n.push(new l(o.INVALID_SETTINGS, "A setting name must be a stream of identifiers", i.name));
2943
2945
  continue;
2944
2946
  }
2945
- const a = (s = Ae(i.name).unwrap_or(void 0)) == null ? void 0 : s.toLowerCase();
2947
+ const a = (s = ge(i.name).unwrap_or(void 0)) == null ? void 0 : s.toLowerCase();
2946
2948
  a && (e[a] === void 0 ? e[a] = [i] : e[a].push(i));
2947
2949
  }
2948
2950
  return new q(e, n);
2949
2951
  }
2950
2952
  class Lt {
2951
2953
  constructor(e, n) {
2952
- this.ast = e, this.symbolFactory = n, this.publicSchemaSymbol = this.symbolFactory.create(Ot, {
2953
- symbolTable: new ve()
2954
+ this.ast = e, this.symbolFactory = n, this.publicSchemaSymbol = this.symbolFactory.create(Rt, {
2955
+ symbolTable: new we()
2954
2956
  }), this.ast.symbol = this.publicSchemaSymbol, this.ast.symbol.declaration = this.ast;
2955
2957
  }
2956
2958
  validate() {
@@ -2965,7 +2967,7 @@ class Lt {
2965
2967
  );
2966
2968
  e.push(...a.validate());
2967
2969
  });
2968
- const n = this.ast.body.filter((s) => Pe(s).unwrap_or(void 0) === I.Project);
2970
+ const n = this.ast.body.filter((s) => xe(s).unwrap_or(void 0) === I.Project);
2969
2971
  return n.length > 1 && n.forEach((s) => e.push(new l(o.PROJECT_REDEFINED, "Only one project can exist", s))), new q(this.ast, e);
2970
2972
  }
2971
2973
  }
@@ -2981,7 +2983,7 @@ class de {
2981
2983
  for (const s of e.elementList) {
2982
2984
  if (s.name instanceof G)
2983
2985
  continue;
2984
- const i = Ae(s.name).unwrap_or(void 0);
2986
+ const i = ge(s.name).unwrap_or(void 0);
2985
2987
  if (!i)
2986
2988
  continue;
2987
2989
  const a = n[i.toLowerCase()];
@@ -3002,7 +3004,7 @@ class de {
3002
3004
  const r = et(a);
3003
3005
  new r(a, this.errors).bind();
3004
3006
  } else
3005
- a instanceof w ? this.bindSubfield(a) : this.bindPartialInjection(a);
3007
+ a instanceof v ? this.bindSubfield(a) : this.bindPartialInjection(a);
3006
3008
  else
3007
3009
  this.bindSubfield(n);
3008
3010
  }
@@ -3026,7 +3028,7 @@ class de {
3026
3028
  return;
3027
3029
  this.bindFragments([e], n);
3028
3030
  } else
3029
- e instanceof le ? Ye(e) ? this.bindFragments(Ie(e).unwrap_or([]), n) : (this.scanAndBind(e.leftExpression, n), this.scanAndBind(e.rightExpression, n)) : e instanceof Z ? this.scanAndBind(e.expression, n) : e instanceof $e ? this.scanAndBind(e.expression, n) : e instanceof fe ? e.elementList.forEach((a) => this.scanAndBind(a, n)) : e instanceof ke && this.bindFragments([e], n);
3031
+ e instanceof le ? qe(e) ? this.bindFragments(_e(e).unwrap_or([]), n) : (this.scanAndBind(e.leftExpression, n), this.scanAndBind(e.rightExpression, n)) : e instanceof K ? this.scanAndBind(e.expression, n) : e instanceof je ? this.scanAndBind(e.expression, n) : e instanceof fe ? e.elementList.forEach((a) => this.scanAndBind(a, n)) : e instanceof Le && this.bindFragments([e], n);
3030
3032
  }
3031
3033
  // Bind the fragments of a member access expression
3032
3034
  // which can be a simple expression like v1.User,
@@ -3034,7 +3036,7 @@ class de {
3034
3036
  bindFragments(e, n) {
3035
3037
  if (e.length === 0)
3036
3038
  return;
3037
- const s = e[0] instanceof ke, i = [...n.topSubnamesSymbolKind], { remainingSubnamesSymbolKind: a } = n, r = s ? -1 : e.findIndex((E) => !$(E)), f = r !== -1 && Ct(e[r]) ? e[r] : void 0, p = r >= 0 ? i.pop() : void 0, d = e.slice(
3039
+ const s = e[0] instanceof Le, i = [...n.topSubnamesSymbolKind], { remainingSubnamesSymbolKind: a } = n, r = s ? -1 : e.findIndex((E) => !j(E)), f = r !== -1 && Xt(e[r]) ? e[r] : void 0, p = r >= 0 ? i.pop() : void 0, d = e.slice(
3038
3040
  0,
3039
3041
  r === -1 ? void 0 : r
3040
3042
  );
@@ -3042,16 +3044,16 @@ class de {
3042
3044
  return;
3043
3045
  const u = [];
3044
3046
  for (; i.length && d.length; ) {
3045
- const E = i.pop(), b = d.pop(), g = X(b).unwrap();
3047
+ const E = i.pop(), b = d.pop(), g = $(b).unwrap();
3046
3048
  u.unshift({
3047
- index: Ue(g, E),
3049
+ index: Me(g, E),
3048
3050
  referrer: b
3049
3051
  });
3050
3052
  }
3051
3053
  for (; d.length; ) {
3052
- const E = d.pop(), b = s ? E.partial.variable.value : X(E).unwrap();
3054
+ const E = d.pop(), b = s ? E.partial.variable.value : $(E).unwrap();
3053
3055
  u.unshift({
3054
- index: Ue(b, a),
3056
+ index: Me(b, a),
3055
3057
  referrer: E
3056
3058
  });
3057
3059
  }
@@ -3060,8 +3062,8 @@ class de {
3060
3062
  [
3061
3063
  ...u,
3062
3064
  {
3063
- index: Ue(
3064
- X(E).unwrap(),
3065
+ index: Me(
3066
+ $(E).unwrap(),
3065
3067
  p
3066
3068
  ),
3067
3069
  referrer: E
@@ -3110,19 +3112,19 @@ class de {
3110
3112
  const s = /* @__PURE__ */ new Map();
3111
3113
  n.forEach((a, r) => {
3112
3114
  var c, f, p;
3113
- if (un(r)) {
3114
- const d = It(hn(r), this.declarationNode);
3115
+ if (hn(r)) {
3116
+ const d = It(fn(r), this.declarationNode);
3115
3117
  (p = (f = (c = d == null ? void 0 : d.declaration) == null ? void 0 : c.symbol) == null ? void 0 : f.symbolTable) == null || p.forEach((u, E) => {
3116
3118
  n.has(E) || s.set(E, u);
3117
3119
  });
3118
3120
  }
3119
3121
  }), s.forEach((a, r) => {
3120
- const c = e.create(Ln, { injectorId: a.id });
3122
+ const c = e.create(_n, { injectorId: a.id });
3121
3123
  n.set(r, c);
3122
3124
  });
3123
3125
  }
3124
3126
  }
3125
- class Jn extends de {
3127
+ class Zn extends de {
3126
3128
  constructor() {
3127
3129
  super(...arguments), this.subfield = {
3128
3130
  arg: {
@@ -3142,7 +3144,7 @@ class Kn extends de {
3142
3144
  }, this.settingList = {};
3143
3145
  }
3144
3146
  }
3145
- class Zn extends de {
3147
+ class es extends de {
3146
3148
  constructor() {
3147
3149
  super(...arguments), this.subfield = {
3148
3150
  arg: {
@@ -3177,7 +3179,7 @@ class Zn extends de {
3177
3179
  }, this.settingList = {};
3178
3180
  }
3179
3181
  }
3180
- class es extends de {
3182
+ class ts extends de {
3181
3183
  constructor() {
3182
3184
  super(...arguments), this.subfield = {
3183
3185
  arg: {
@@ -3187,7 +3189,7 @@ class es extends de {
3187
3189
  }, this.settingList = {};
3188
3190
  }
3189
3191
  }
3190
- class ts extends de {
3192
+ class ns extends de {
3191
3193
  constructor() {
3192
3194
  super(...arguments), this.subfield = {
3193
3195
  arg: {
@@ -3197,7 +3199,7 @@ class ts extends de {
3197
3199
  }, this.settingList = {};
3198
3200
  }
3199
3201
  }
3200
- class ns extends de {
3202
+ class ss extends de {
3201
3203
  constructor() {
3202
3204
  super(...arguments), this.subfield = {
3203
3205
  arg: {
@@ -3214,7 +3216,7 @@ class ns extends de {
3214
3216
  }, this.settingList = {};
3215
3217
  }
3216
3218
  }
3217
- class ss extends de {
3219
+ class is extends de {
3218
3220
  constructor() {
3219
3221
  super(...arguments), this.subfield = {
3220
3222
  arg: {
@@ -3250,7 +3252,7 @@ class ss extends de {
3250
3252
  }, this.settingList = {};
3251
3253
  }
3252
3254
  }
3253
- class is extends de {
3255
+ class as extends de {
3254
3256
  constructor() {
3255
3257
  super(...arguments), this.subfield = {
3256
3258
  arg: {
@@ -3267,7 +3269,7 @@ class is extends de {
3267
3269
  }, this.settingList = {};
3268
3270
  }
3269
3271
  }
3270
- class as extends de {
3272
+ class rs extends de {
3271
3273
  constructor() {
3272
3274
  super(...arguments), this.subfield = {
3273
3275
  arg: {
@@ -3300,24 +3302,24 @@ function et(t) {
3300
3302
  case I.Enum:
3301
3303
  return Kn;
3302
3304
  case I.Table:
3303
- return ss;
3304
- case I.TableGroup:
3305
3305
  return is;
3306
+ case I.TableGroup:
3307
+ return as;
3306
3308
  case I.Project:
3307
- return ts;
3308
- case I.Ref:
3309
3309
  return ns;
3310
+ case I.Ref:
3311
+ return ss;
3310
3312
  case I.Note:
3311
- return es;
3313
+ return ts;
3312
3314
  case I.Indexes:
3313
- return Zn;
3315
+ return es;
3314
3316
  case I.TablePartial:
3315
- return as;
3317
+ return rs;
3316
3318
  default:
3317
- return Jn;
3319
+ return Zn;
3318
3320
  }
3319
3321
  }
3320
- class rs {
3322
+ class os {
3321
3323
  constructor(e) {
3322
3324
  this.ast = e, this.errors = [];
3323
3325
  }
@@ -3336,7 +3338,7 @@ class rs {
3336
3338
  return new q(this.ast, this.errors);
3337
3339
  }
3338
3340
  }
3339
- class os {
3341
+ class ls {
3340
3342
  constructor(e) {
3341
3343
  this.generator = e;
3342
3344
  }
@@ -3344,13 +3346,13 @@ class os {
3344
3346
  return new e(n, this.generator.nextId());
3345
3347
  }
3346
3348
  }
3347
- class ls {
3349
+ class cs {
3348
3350
  constructor(e, n) {
3349
- this.ast = e, this.symbolFactory = new os(n);
3351
+ this.ast = e, this.symbolFactory = new ls(n);
3350
3352
  }
3351
3353
  // Analyzing: Invoking both the validator and binder
3352
3354
  analyze() {
3353
- return new Lt(this.ast, this.symbolFactory).validate().chain((n) => new rs(n).resolve(this.symbolFactory));
3355
+ return new Lt(this.ast, this.symbolFactory).validate().chain((n) => new os(n).resolve(this.symbolFactory));
3354
3356
  }
3355
3357
  // For invoking the validator only
3356
3358
  validate() {
@@ -3377,7 +3379,7 @@ function _t(t, e) {
3377
3379
  schemaName: n.pop() || null
3378
3380
  };
3379
3381
  }
3380
- function Xt(t) {
3382
+ function $t(t) {
3381
3383
  switch (t) {
3382
3384
  case "<":
3383
3385
  return ["1", "*"];
@@ -3400,9 +3402,9 @@ function L(t) {
3400
3402
  end: { offset: t.endPos.offset, line: t.endPos.line + 1, column: t.endPos.column + 1 }
3401
3403
  };
3402
3404
  }
3403
- function Ge(t) {
3405
+ function Ce(t) {
3404
3406
  var n;
3405
- const e = (n = Ie(t).unwrap_or(void 0)) == null ? void 0 : n.pop();
3407
+ const e = (n = _e(t).unwrap_or(void 0)) == null ? void 0 : n.pop();
3406
3408
  return e instanceof fe ? e.elementList.map((s) => s.referee) : [e.referee];
3407
3409
  }
3408
3410
  function Te(t) {
@@ -3415,7 +3417,7 @@ function Te(t) {
3415
3417
  function De(t) {
3416
3418
  return t.expression.literal.value;
3417
3419
  }
3418
- function $t(t, e) {
3420
+ function jt(t, e) {
3419
3421
  if (Array.isArray(t)) {
3420
3422
  const i = t.map(({ id: r }) => r).sort().join(","), a = e.map(({ id: r }) => r).sort().join(",");
3421
3423
  return i < a ? `${i}-${a}` : `${a}-${i}`;
@@ -3437,7 +3439,7 @@ function ie(t) {
3437
3439
  return n.map((a) => a.slice(i)).join(`
3438
3440
  `);
3439
3441
  }
3440
- class jt {
3442
+ class Wt {
3441
3443
  constructor(e, n) {
3442
3444
  this.declarationNode = e, this.env = n, this.table = { name: void 0, schemaName: void 0, alias: null, fields: [], token: void 0, indexes: [], partials: [] }, this.pkColumns = [];
3443
3445
  }
@@ -3467,7 +3469,7 @@ class jt {
3467
3469
  interpretAlias(e) {
3468
3470
  if (!e)
3469
3471
  return [];
3470
- const n = X(e).unwrap_or(null);
3472
+ const n = $(e).unwrap_or(null);
3471
3473
  return n && (this.env.aliases.push({
3472
3474
  name: n,
3473
3475
  kind: "table",
@@ -3483,12 +3485,12 @@ class jt {
3483
3485
  this.table.headerColor = (i = n.headercolor) != null && i.length ? De((r = (a = n.headercolor) == null ? void 0 : a.at(0)) == null ? void 0 : r.value) : void 0;
3484
3486
  const [s] = n.note || [];
3485
3487
  return this.table.note = s && {
3486
- value: U(s == null ? void 0 : s.value).map(ie).unwrap(),
3488
+ value: M(s == null ? void 0 : s.value).map(ie).unwrap(),
3487
3489
  token: L(s)
3488
3490
  }, [];
3489
3491
  }
3490
3492
  interpretBody(e) {
3491
- const [n, s] = _.partition(e.body, (i) => i instanceof w || i instanceof ke);
3493
+ const [n, s] = _.partition(e.body, (i) => i instanceof v || i instanceof Le);
3492
3494
  return [
3493
3495
  ...this.interpretFields(n),
3494
3496
  ...this.interpretSubElements(s)
@@ -3500,7 +3502,7 @@ class jt {
3500
3502
  switch ((s = n.type) == null ? void 0 : s.value.toLowerCase()) {
3501
3503
  case "note":
3502
3504
  return this.table.note = {
3503
- value: U(n.body instanceof re ? n.body.body[0].callee : n.body.callee).map(ie).unwrap(),
3505
+ value: M(n.body instanceof re ? n.body.body[0].callee : n.body.callee).map(ie).unwrap(),
3504
3506
  token: L(n)
3505
3507
  }, [];
3506
3508
  case "indexes":
@@ -3514,27 +3516,27 @@ class jt {
3514
3516
  return s.name = e.partial.variable.value, this.table.partials.push(s), [];
3515
3517
  }
3516
3518
  interpretFields(e) {
3517
- return e.flatMap((n, s) => n instanceof w ? this.interpretColumn(n) : this.interpretInjection(n, s));
3519
+ return e.flatMap((n, s) => n instanceof v ? this.interpretColumn(n) : this.interpretInjection(n, s));
3518
3520
  }
3519
3521
  interpretColumn(e) {
3520
3522
  var r, c, f, p, d, u, E, b, g;
3521
3523
  const n = [], s = {};
3522
- s.name = X(e.callee).unwrap();
3523
- const i = cs(e.args[0]);
3524
+ s.name = $(e.callee).unwrap();
3525
+ const i = us(e.args[0]);
3524
3526
  s.type = i.getValue(), n.push(...i.getErrors()), s.token = L(e), s.inline_refs = [];
3525
3527
  const a = e.args.slice(1);
3526
3528
  if (_.last(a) instanceof R) {
3527
3529
  const A = F(a.pop()).getValue();
3528
- s.pk = !!((r = A.pk) != null && r.length) || !!((c = A["primary key"]) != null && c.length), s.increment = !!((f = A.increment) != null && f.length), s.unique = !!((p = A.unique) != null && p.length), s.not_null = (d = A["not null"]) != null && d.length ? !0 : (u = A.null) != null && u.length ? !1 : void 0, s.dbdefault = us((b = (E = A.default) == null ? void 0 : E.at(0)) == null ? void 0 : b.value);
3530
+ s.pk = !!((r = A.pk) != null && r.length) || !!((c = A["primary key"]) != null && c.length), s.increment = !!((f = A.increment) != null && f.length), s.unique = !!((p = A.unique) != null && p.length), s.not_null = (d = A["not null"]) != null && d.length ? !0 : (u = A.null) != null && u.length ? !1 : void 0, s.dbdefault = hs((b = (E = A.default) == null ? void 0 : E.at(0)) == null ? void 0 : b.value);
3529
3531
  const k = (g = A.note) == null ? void 0 : g.at(0);
3530
3532
  s.note = k && {
3531
- value: U(k.value).map(ie).unwrap(),
3533
+ value: M(k.value).map(ie).unwrap(),
3532
3534
  token: L(k)
3533
3535
  };
3534
3536
  const be = A.ref || [];
3535
3537
  s.inline_refs = be.flatMap((S) => {
3536
- const [Oe] = Ge(S.value.expression);
3537
- if (lt(Oe, e.symbol))
3538
+ const [Re] = Ce(S.value.expression);
3539
+ if (lt(Re, e.symbol))
3538
3540
  return n.push(new l(o.SAME_ENDPOINT, "Two endpoints are the same", S)), [];
3539
3541
  const Ee = S.value.op, V = z(S.value.expression).unwrap();
3540
3542
  let te;
@@ -3576,7 +3578,7 @@ class jt {
3576
3578
  token: L(S)
3577
3579
  };
3578
3580
  }
3579
- const Ne = this.registerInlineRefToEnv(e, Oe, te, S);
3581
+ const Ne = this.registerInlineRefToEnv(e, Re, te, S);
3580
3582
  return n.push(...Ne), Ne.length === 0 ? te : [];
3581
3583
  });
3582
3584
  }
@@ -3590,10 +3592,10 @@ class jt {
3590
3592
  const a = [i.callee, ...i.args];
3591
3593
  if (_.last(a) instanceof R) {
3592
3594
  const b = F(a.pop()).getValue();
3593
- s.pk = !!((r = b.pk) != null && r.length), s.unique = !!((c = b.unique) != null && c.length), s.name = U((p = (f = b.name) == null ? void 0 : f.at(0)) == null ? void 0 : p.value).unwrap_or(void 0);
3595
+ s.pk = !!((r = b.pk) != null && r.length), s.unique = !!((c = b.unique) != null && c.length), s.name = M((p = (f = b.name) == null ? void 0 : f.at(0)) == null ? void 0 : p.value).unwrap_or(void 0);
3594
3596
  const g = (d = b.note) == null ? void 0 : d.at(0);
3595
3597
  s.note = g && {
3596
- value: U(g.value).unwrap(),
3598
+ value: M(g.value).unwrap(),
3597
3599
  token: L(g)
3598
3600
  }, s.type = W((E = (u = b.type) == null ? void 0 : u.at(0)) == null ? void 0 : E.value).unwrap_or(void 0);
3599
3601
  }
@@ -3605,7 +3607,7 @@ class jt {
3605
3607
  g.push(b.argumentList), b = b.callee;
3606
3608
  return g.push(b), g;
3607
3609
  }).forEach((b) => {
3608
- const { functional: g, nonFunctional: A } = Ve(b).unwrap();
3610
+ const { functional: g, nonFunctional: A } = Ge(b).unwrap();
3609
3611
  s.columns.push(
3610
3612
  ...g.map((k) => ({
3611
3613
  value: k.value.value,
@@ -3613,7 +3615,7 @@ class jt {
3613
3615
  token: L(k)
3614
3616
  })),
3615
3617
  ...A.map((k) => ({
3616
- value: X(k).unwrap(),
3618
+ value: $(k).unwrap(),
3617
3619
  type: "column",
3618
3620
  token: L(k)
3619
3621
  }))
@@ -3622,13 +3624,13 @@ class jt {
3622
3624
  })), [];
3623
3625
  }
3624
3626
  registerInlineRefToEnv(e, n, s, i) {
3625
- const a = $t(e.symbol, n);
3627
+ const a = jt(e.symbol, n);
3626
3628
  if (this.env.refIds[a])
3627
3629
  return [
3628
3630
  new l(o.CIRCULAR_REF, "References with same endpoints exist", i),
3629
3631
  new l(o.CIRCULAR_REF, "References with same endpoints exist", this.env.refIds[a])
3630
3632
  ];
3631
- const r = Xt(s.relation);
3633
+ const r = $t(s.relation);
3632
3634
  return this.env.refIds[a] = i, this.env.ref.set(i, {
3633
3635
  name: null,
3634
3636
  schemaName: null,
@@ -3649,9 +3651,9 @@ class jt {
3649
3651
  }), [];
3650
3652
  }
3651
3653
  }
3652
- function cs(t) {
3654
+ function us(t) {
3653
3655
  let e = null;
3654
- t instanceof Y && (e = t.argumentList.elementList.map((a) => ee(a) ? a.expression.literal.value : C(a) ? U(a).unwrap() : W(a).unwrap()).join(","), t = t.callee);
3656
+ t instanceof Y && (e = t.argumentList.elementList.map((a) => ee(a) ? a.expression.literal.value : C(a) ? M(a).unwrap() : W(a).unwrap()).join(","), t = t.callee);
3655
3657
  let n = "";
3656
3658
  for (; t instanceof ue; )
3657
3659
  n = `[${t.indexer.elementList.map((a) => a.name.expression.literal.value).join(",")}]${n}`, t = t.array;
@@ -3669,12 +3671,12 @@ function cs(t) {
3669
3671
  args: e
3670
3672
  });
3671
3673
  }
3672
- function us(t) {
3674
+ function hs(t) {
3673
3675
  var e, n, s;
3674
3676
  if (t) {
3675
3677
  if (C(t))
3676
3678
  return {
3677
- value: U(t).unwrap(),
3679
+ value: M(t).unwrap(),
3678
3680
  type: "string"
3679
3681
  };
3680
3682
  if (ee(t))
@@ -3687,7 +3689,7 @@ function us(t) {
3687
3689
  value: t.expression.variable.value.toLowerCase(),
3688
3690
  type: "boolean"
3689
3691
  };
3690
- if (t instanceof Z && ot.includes((e = t.op) == null ? void 0 : e.value) && ee(t.expression)) {
3692
+ if (t instanceof K && ot.includes((e = t.op) == null ? void 0 : e.value) && ee(t.expression)) {
3691
3693
  const i = Number.parseFloat(t.expression.expression.literal.value);
3692
3694
  return {
3693
3695
  value: ((n = t.op) == null ? void 0 : n.value) === "-" ? 0 - i : i,
@@ -3702,7 +3704,7 @@ function us(t) {
3702
3704
  throw new Error("Unreachable");
3703
3705
  }
3704
3706
  }
3705
- class hs {
3707
+ class fs {
3706
3708
  constructor(e, n) {
3707
3709
  this.declarationNode = e, this.env = n, this.note = { name: void 0, content: void 0, token: void 0 };
3708
3710
  }
@@ -3723,7 +3725,7 @@ class hs {
3723
3725
  return this.note.headerColor = (s = n.headercolor) != null && s.length ? De((a = (i = n.headercolor) == null ? void 0 : i.at(0)) == null ? void 0 : a.value) : void 0, [];
3724
3726
  }
3725
3727
  interpretBody(e) {
3726
- const [n, s] = _.partition(e.body, (i) => i instanceof w);
3728
+ const [n, s] = _.partition(e.body, (i) => i instanceof v);
3727
3729
  return n.length !== 1 || s.length > 0 ? [
3728
3730
  new l(o.INVALID_NOTE, "Invalid note syntax", e)
3729
3731
  ] : [...this.interpretNote(n[0])];
@@ -3733,7 +3735,7 @@ class hs {
3733
3735
  return this.note.content = ie(n), [];
3734
3736
  }
3735
3737
  }
3736
- class Wt {
3738
+ class Yt {
3737
3739
  constructor(e, n) {
3738
3740
  this.declarationNode = e, this.env = n, this.container = this.declarationNode.parent instanceof y ? this.env.tables.get(this.declarationNode.parent) : void 0, this.ref = {};
3739
3741
  }
@@ -3748,14 +3750,14 @@ class Wt {
3748
3750
  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;
3749
3751
  }
3750
3752
  interpretBody(e) {
3751
- return e instanceof w ? this.interpretField(e) : this.interpretField(e.body[0]);
3753
+ return e instanceof v ? this.interpretField(e) : this.interpretField(e.body[0]);
3752
3754
  }
3753
3755
  interpretField(e) {
3754
3756
  var p, d, u, E, b, g, A;
3755
- const n = e.callee.op.value, { leftExpression: s, rightExpression: i } = e.callee, a = Ge(s), r = Ge(i);
3757
+ const n = e.callee.op.value, { leftExpression: s, rightExpression: i } = e.callee, a = Ce(s), r = Ce(i);
3756
3758
  if (lt(a, r))
3757
3759
  return [new l(o.SAME_ENDPOINT, "Two endpoints are the same", e)];
3758
- const c = $t(a, r);
3760
+ const c = jt(a, r);
3759
3761
  if (this.env.refIds[c])
3760
3762
  return [
3761
3763
  new l(o.CIRCULAR_REF, "References with same endpoints exist", this.declarationNode),
@@ -3763,11 +3765,11 @@ class Wt {
3763
3765
  ];
3764
3766
  if (e.args[0]) {
3765
3767
  const k = F(e.args[0]).getValue(), be = (d = (p = k.delete) == null ? void 0 : p.at(0)) == null ? void 0 : d.value;
3766
- this.ref.onDelete = be instanceof ne ? Ae(be).unwrap_or(void 0) : W(be).unwrap_or(void 0);
3768
+ this.ref.onDelete = be instanceof ne ? ge(be).unwrap_or(void 0) : W(be).unwrap_or(void 0);
3767
3769
  const S = (E = (u = k.update) == null ? void 0 : u.at(0)) == null ? void 0 : E.value;
3768
- this.ref.onUpdate = S instanceof ne ? Ae(S).unwrap_or(void 0) : W(S).unwrap_or(void 0), this.ref.color = (b = k.color) != null && b.length ? De((A = (g = k.color) == null ? void 0 : g.at(0)) == null ? void 0 : A.value) : void 0;
3770
+ this.ref.onUpdate = S instanceof ne ? ge(S).unwrap_or(void 0) : W(S).unwrap_or(void 0), this.ref.color = (b = k.color) != null && b.length ? De((A = (g = k.color) == null ? void 0 : g.at(0)) == null ? void 0 : A.value) : void 0;
3769
3771
  }
3770
- const f = Xt(n);
3772
+ const f = $t(n);
3771
3773
  return this.ref.endpoints = [
3772
3774
  {
3773
3775
  ..._t(s, this.container),
@@ -3782,7 +3784,7 @@ class Wt {
3782
3784
  ], this.env.refIds[c] = this.declarationNode, [];
3783
3785
  }
3784
3786
  }
3785
- class Yt {
3787
+ class qt {
3786
3788
  constructor(e, n) {
3787
3789
  this.declarationNode = e, this.env = n, this.tableGroup = { tables: [] };
3788
3790
  }
@@ -3799,7 +3801,7 @@ class Yt {
3799
3801
  return i.length >= 2 && (this.tableGroup.name = s, this.tableGroup.schemaName = i.join("."), n.push(new l(o.UNSUPPORTED, "Nested schema is not supported", this.declarationNode.name))), this.tableGroup.name = s, this.tableGroup.schemaName = i[0] || null, n;
3800
3802
  }
3801
3803
  interpretBody(e) {
3802
- const [n, s] = tn(e.body, (i) => i instanceof w);
3804
+ const [n, s] = nn(e.body, (i) => i instanceof v);
3803
3805
  return [
3804
3806
  ...this.interpretFields(n),
3805
3807
  ...this.interpretSubElements(s)
@@ -3811,7 +3813,7 @@ class Yt {
3811
3813
  switch ((s = n.type) == null ? void 0 : s.value.toLowerCase()) {
3812
3814
  case "note":
3813
3815
  this.tableGroup.note = {
3814
- value: U(
3816
+ value: M(
3815
3817
  n.body instanceof re ? n.body.body[0].callee : n.body.callee
3816
3818
  ).map(ie).unwrap(),
3817
3819
  token: L(n)
@@ -3826,7 +3828,7 @@ class Yt {
3826
3828
  return this.tableGroup.tables = e.map((s) => {
3827
3829
  const i = z(s.callee).unwrap();
3828
3830
  i.length > 2 && n.push(new l(o.UNSUPPORTED, "Nested schema is not supported", s));
3829
- const a = Ie(s.callee).unwrap().pop().referee.id;
3831
+ const a = _e(s.callee).unwrap().pop().referee.id;
3830
3832
  if (this.env.groupOfTable[a]) {
3831
3833
  const r = this.env.groupOfTable[a], { schemaName: c, name: f } = this.env.tableGroups.get(r), p = c ? `${c}.${f}` : f;
3832
3834
  n.push(new l(o.TABLE_REAPPEAR_IN_TABLEGROUP, `Table "${i.join(".")}" already appears in group "${p}"`, s));
@@ -3844,12 +3846,12 @@ class Yt {
3844
3846
  this.tableGroup.color = (i = n.color) != null && i.length ? De((r = (a = n.color) == null ? void 0 : a.at(0)) == null ? void 0 : r.value) : void 0;
3845
3847
  const [s] = n.note || [];
3846
3848
  return this.tableGroup.note = s && {
3847
- value: U(s == null ? void 0 : s.value).map(ie).unwrap(),
3849
+ value: M(s == null ? void 0 : s.value).map(ie).unwrap(),
3848
3850
  token: L(s)
3849
3851
  }, [];
3850
3852
  }
3851
3853
  }
3852
- class qt {
3854
+ class zt {
3853
3855
  constructor(e, n) {
3854
3856
  this.declarationNode = e, this.env = n, this.enum = { values: [] };
3855
3857
  }
@@ -3867,13 +3869,13 @@ class qt {
3867
3869
  i.token = L(s), i.name = W(s.callee).unwrap();
3868
3870
  const r = (c = F(s.args[0]).getValue().note) == null ? void 0 : c.at(0);
3869
3871
  return i.note = r && {
3870
- value: U(r.value).map(ie).unwrap(),
3872
+ value: M(r.value).map(ie).unwrap(),
3871
3873
  token: L(r)
3872
3874
  }, this.enum.values.push(i), [];
3873
3875
  });
3874
3876
  }
3875
3877
  }
3876
- class zt {
3878
+ class Qt {
3877
3879
  constructor(e, n) {
3878
3880
  this.declarationNode = e, this.env = n, this.tablePartial = { name: void 0, fields: [], token: void 0, indexes: [] }, this.pkColumns = [];
3879
3881
  }
@@ -3905,12 +3907,12 @@ class zt {
3905
3907
  this.tablePartial.headerColor = (i = n.headercolor) != null && i.length ? De((r = (a = n.headercolor) == null ? void 0 : a.at(0)) == null ? void 0 : r.value) : void 0;
3906
3908
  const [s] = n.note || [];
3907
3909
  return this.tablePartial.note = s && {
3908
- value: U(s == null ? void 0 : s.value).map(ie).unwrap(),
3910
+ value: M(s == null ? void 0 : s.value).map(ie).unwrap(),
3909
3911
  token: L(s)
3910
3912
  }, [];
3911
3913
  }
3912
3914
  interpretBody(e) {
3913
- const [n, s] = _.partition(e.body, (i) => i instanceof w);
3915
+ const [n, s] = _.partition(e.body, (i) => i instanceof v);
3914
3916
  return [...this.interpretFields(n), ...this.interpretSubElements(s)];
3915
3917
  }
3916
3918
  interpretSubElements(e) {
@@ -3919,7 +3921,7 @@ class zt {
3919
3921
  switch ((s = n.type) == null ? void 0 : s.value.toLowerCase()) {
3920
3922
  case "note":
3921
3923
  return this.tablePartial.note = {
3922
- value: U(n.body instanceof re ? n.body.body[0].callee : n.body.callee).map(ie).unwrap(),
3924
+ value: M(n.body instanceof re ? n.body.body[0].callee : n.body.callee).map(ie).unwrap(),
3923
3925
  token: L(n)
3924
3926
  }, [];
3925
3927
  case "indexes":
@@ -3934,22 +3936,22 @@ class zt {
3934
3936
  interpretColumn(e) {
3935
3937
  var r, c, f, p, d, u, E, b, g;
3936
3938
  const n = [], s = {};
3937
- s.name = X(e.callee).unwrap();
3938
- const i = fs(e.args[0]);
3939
+ s.name = $(e.callee).unwrap();
3940
+ const i = ps(e.args[0]);
3939
3941
  s.type = i.getValue(), n.push(...i.getErrors()), s.token = L(e), s.inline_refs = [];
3940
3942
  const a = e.args.slice(1);
3941
3943
  if (_.last(a) instanceof R) {
3942
3944
  const A = F(a.pop()).getValue();
3943
- s.pk = !!((r = A.pk) != null && r.length) || !!((c = A["primary key"]) != null && c.length), s.increment = !!((f = A.increment) != null && f.length), s.unique = !!((p = A.unique) != null && p.length), s.not_null = (d = A["not null"]) != null && d.length ? !0 : (u = A.null) != null && u.length ? !1 : void 0, s.dbdefault = ps((b = (E = A.default) == null ? void 0 : E.at(0)) == null ? void 0 : b.value);
3945
+ s.pk = !!((r = A.pk) != null && r.length) || !!((c = A["primary key"]) != null && c.length), s.increment = !!((f = A.increment) != null && f.length), s.unique = !!((p = A.unique) != null && p.length), s.not_null = (d = A["not null"]) != null && d.length ? !0 : (u = A.null) != null && u.length ? !1 : void 0, s.dbdefault = ds((b = (E = A.default) == null ? void 0 : E.at(0)) == null ? void 0 : b.value);
3944
3946
  const k = (g = A.note) == null ? void 0 : g.at(0);
3945
3947
  s.note = k && {
3946
- value: U(k.value).map(ie).unwrap(),
3948
+ value: M(k.value).map(ie).unwrap(),
3947
3949
  token: L(k)
3948
3950
  };
3949
3951
  const be = A.ref || [];
3950
3952
  s.inline_refs = be.flatMap((S) => {
3951
- const [Oe] = Ge(S.value.expression);
3952
- if (lt(Oe, e.symbol))
3953
+ const [Re] = Ce(S.value.expression);
3954
+ if (lt(Re, e.symbol))
3953
3955
  return n.push(new l(o.SAME_ENDPOINT, "Two endpoints are the same", S)), [];
3954
3956
  const Ee = S.value.op, V = z(S.value.expression).unwrap();
3955
3957
  let te;
@@ -3995,10 +3997,10 @@ class zt {
3995
3997
  const a = [i.callee, ...i.args];
3996
3998
  if (_.last(a) instanceof R) {
3997
3999
  const b = F(a.pop()).getValue();
3998
- s.pk = !!((r = b.pk) != null && r.length), s.unique = !!((c = b.unique) != null && c.length), s.name = U((p = (f = b.name) == null ? void 0 : f.at(0)) == null ? void 0 : p.value).unwrap_or(void 0);
4000
+ s.pk = !!((r = b.pk) != null && r.length), s.unique = !!((c = b.unique) != null && c.length), s.name = M((p = (f = b.name) == null ? void 0 : f.at(0)) == null ? void 0 : p.value).unwrap_or(void 0);
3999
4001
  const g = (d = b.note) == null ? void 0 : d.at(0);
4000
4002
  s.note = g && {
4001
- value: U(g.value).unwrap(),
4003
+ value: M(g.value).unwrap(),
4002
4004
  token: L(g)
4003
4005
  }, s.type = W((E = (u = b.type) == null ? void 0 : u.at(0)) == null ? void 0 : E.value).unwrap_or(void 0);
4004
4006
  }
@@ -4010,7 +4012,7 @@ class zt {
4010
4012
  g.push(b.argumentList), b = b.callee;
4011
4013
  return g.push(b), g;
4012
4014
  }).forEach((b) => {
4013
- const { functional: g, nonFunctional: A } = Ve(b).unwrap();
4015
+ const { functional: g, nonFunctional: A } = Ge(b).unwrap();
4014
4016
  s.columns.push(
4015
4017
  ...g.map((k) => ({
4016
4018
  value: k.value.value,
@@ -4018,7 +4020,7 @@ class zt {
4018
4020
  token: L(k)
4019
4021
  })),
4020
4022
  ...A.map((k) => ({
4021
- value: X(k).unwrap(),
4023
+ value: $(k).unwrap(),
4022
4024
  type: "column",
4023
4025
  token: L(k)
4024
4026
  }))
@@ -4059,9 +4061,9 @@ class zt {
4059
4061
  // return [];
4060
4062
  // }
4061
4063
  }
4062
- function fs(t) {
4064
+ function ps(t) {
4063
4065
  let e = null;
4064
- t instanceof Y && (e = t.argumentList.elementList.map((a) => ee(a) ? a.expression.literal.value : C(a) ? U(a).unwrap() : W(a).unwrap()).join(","), t = t.callee);
4066
+ t instanceof Y && (e = t.argumentList.elementList.map((a) => ee(a) ? a.expression.literal.value : C(a) ? M(a).unwrap() : W(a).unwrap()).join(","), t = t.callee);
4065
4067
  let n = "";
4066
4068
  for (; t instanceof ue; )
4067
4069
  n = `[${t.indexer.elementList.map((a) => a.name.expression.literal.value).join(",")}]${n}`, t = t.array;
@@ -4079,12 +4081,12 @@ function fs(t) {
4079
4081
  args: e
4080
4082
  });
4081
4083
  }
4082
- function ps(t) {
4084
+ function ds(t) {
4083
4085
  var e, n, s;
4084
4086
  if (t) {
4085
4087
  if (C(t))
4086
4088
  return {
4087
- value: U(t).unwrap(),
4089
+ value: M(t).unwrap(),
4088
4090
  type: "string"
4089
4091
  };
4090
4092
  if (ee(t))
@@ -4097,7 +4099,7 @@ function ps(t) {
4097
4099
  value: t.expression.variable.value.toLowerCase(),
4098
4100
  type: "boolean"
4099
4101
  };
4100
- if (t instanceof Z && ot.includes((e = t.op) == null ? void 0 : e.value) && ee(t.expression)) {
4102
+ if (t instanceof K && ot.includes((e = t.op) == null ? void 0 : e.value) && ee(t.expression)) {
4101
4103
  const i = Number.parseFloat(t.expression.expression.literal.value);
4102
4104
  return {
4103
4105
  value: ((n = t.op) == null ? void 0 : n.value) === "-" ? 0 - i : i,
@@ -4112,7 +4114,7 @@ function ps(t) {
4112
4114
  throw new Error("Unreachable");
4113
4115
  }
4114
4116
  }
4115
- class ds {
4117
+ class Es {
4116
4118
  constructor(e, n) {
4117
4119
  this.declarationNode = e, this.env = n, this.project = { enums: [], refs: [], tableGroups: [], tables: [], tablePartials: [] };
4118
4120
  }
@@ -4131,37 +4133,37 @@ class ds {
4131
4133
  const s = n;
4132
4134
  switch ((i = s.type) == null ? void 0 : i.value.toLowerCase()) {
4133
4135
  case "table": {
4134
- const a = new jt(s, this.env).interpret();
4136
+ const a = new Wt(s, this.env).interpret();
4135
4137
  return this.project.tables.push(this.env.tables.get(s)), a;
4136
4138
  }
4137
4139
  case "ref": {
4138
- const a = new Wt(s, this.env).interpret();
4140
+ const a = new Yt(s, this.env).interpret();
4139
4141
  return this.project.refs.push(this.env.ref.get(s)), a;
4140
4142
  }
4141
4143
  case "tablegroup": {
4142
- const a = new Yt(s, this.env).interpret();
4144
+ const a = new qt(s, this.env).interpret();
4143
4145
  return this.project.tableGroups.push(this.env.tableGroups.get(s)), a;
4144
4146
  }
4145
4147
  case "enum": {
4146
- const a = new qt(s, this.env).interpret();
4148
+ const a = new zt(s, this.env).interpret();
4147
4149
  return this.project.enums.push(this.env.enums.get(s)), a;
4148
4150
  }
4149
4151
  case "note":
4150
4152
  return this.project.note = {
4151
- value: U(s.body instanceof re ? s.body.body[0].callee : s.body.callee).map(ie).unwrap(),
4153
+ value: M(s.body instanceof re ? s.body.body[0].callee : s.body.callee).map(ie).unwrap(),
4152
4154
  token: L(s)
4153
4155
  }, [];
4154
4156
  case "tablepartial": {
4155
- const a = new zt(s, this.env).interpret();
4157
+ const a = new Qt(s, this.env).interpret();
4156
4158
  return this.project.tablePartials.push(this.env.tablePartials.get(s)), a;
4157
4159
  }
4158
4160
  default:
4159
- return this.project[s.type.value.toLowerCase()] = U(s.body.callee).unwrap(), [];
4161
+ return this.project[s.type.value.toLowerCase()] = M(s.body.callee).unwrap(), [];
4160
4162
  }
4161
4163
  });
4162
4164
  }
4163
4165
  }
4164
- class Es {
4166
+ class Ns {
4165
4167
  constructor(e) {
4166
4168
  this.ast = e, this.env = {
4167
4169
  schema: [],
@@ -4179,29 +4181,29 @@ class Es {
4179
4181
  }
4180
4182
  interpret() {
4181
4183
  const e = this.ast.body.flatMap((n) => {
4182
- switch (Pe(n).unwrap_or(void 0)) {
4184
+ switch (xe(n).unwrap_or(void 0)) {
4183
4185
  case I.Table:
4184
- return new jt(n, this.env).interpret();
4186
+ return new Wt(n, this.env).interpret();
4185
4187
  case I.Note:
4186
- return new hs(n, this.env).interpret();
4188
+ return new fs(n, this.env).interpret();
4187
4189
  case I.Ref:
4188
- return new Wt(n, this.env).interpret();
4189
- case I.TableGroup:
4190
4190
  return new Yt(n, this.env).interpret();
4191
+ case I.TableGroup:
4192
+ return new qt(n, this.env).interpret();
4191
4193
  case I.TablePartial:
4192
- return new zt(n, this.env).interpret();
4194
+ return new Qt(n, this.env).interpret();
4193
4195
  case I.Enum:
4194
- return new qt(n, this.env).interpret();
4196
+ return new zt(n, this.env).interpret();
4195
4197
  case I.Project:
4196
- return new ds(n, this.env).interpret();
4198
+ return new Es(n, this.env).interpret();
4197
4199
  default:
4198
4200
  return [];
4199
4201
  }
4200
4202
  });
4201
- return new q(Ns(this.env), e);
4203
+ return new q(ms(this.env), e);
4202
4204
  }
4203
4205
  }
4204
- function Ns(t) {
4206
+ function ms(t) {
4205
4207
  return {
4206
4208
  schemas: [],
4207
4209
  tables: Array.from(t.tables.values()),
@@ -4214,29 +4216,29 @@ function Ns(t) {
4214
4216
  tablePartials: Array.from(t.tablePartials.values())
4215
4217
  };
4216
4218
  }
4217
- var v = /* @__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))(v || {}), x = /* @__PURE__ */ ((t) => (t[t.None = 0] = "None", t[t.KeepWhitespace = 1] = "KeepWhitespace", t[t.InsertAsSnippet = 4] = "InsertAsSnippet", t))(x || {});
4218
- function xe(t) {
4219
+ var w = /* @__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))(w || {}), P = /* @__PURE__ */ ((t) => (t[t.None = 0] = "None", t[t.KeepWhitespace = 1] = "KeepWhitespace", t[t.InsertAsSnippet = 4] = "InsertAsSnippet", t))(P || {});
4220
+ function Pe(t) {
4219
4221
  switch (t) {
4220
4222
  case m.Schema:
4221
- return v.Module;
4223
+ return w.Module;
4222
4224
  case m.Table:
4223
- return v.Class;
4225
+ case m.TablePartial:
4226
+ return w.Class;
4224
4227
  case m.Column:
4225
- return v.Field;
4228
+ case m.TableGroupField:
4229
+ return w.Field;
4226
4230
  case m.Enum:
4227
- return v.Enum;
4231
+ return w.Enum;
4228
4232
  case m.EnumField:
4229
- return v.EnumMember;
4233
+ return w.EnumMember;
4230
4234
  case m.TableGroup:
4231
- return v.Struct;
4232
- case m.TableGroupField:
4233
- return v.Field;
4235
+ return w.Struct;
4234
4236
  default:
4235
- return v.Text;
4237
+ return w.Text;
4236
4238
  }
4237
4239
  }
4238
- function Ce(t, e) {
4239
- if (!t || Ze(t))
4240
+ function Xe(t, e) {
4241
+ if (!t || Ke(t))
4240
4242
  return !1;
4241
4243
  for (const n of t.trailingTrivia) {
4242
4244
  if (n.start > e)
@@ -4251,7 +4253,7 @@ function B() {
4251
4253
  suggestions: []
4252
4254
  };
4253
4255
  }
4254
- function Xe(t) {
4256
+ function $e(t) {
4255
4257
  return {
4256
4258
  ...t,
4257
4259
  suggestions: t.suggestions.map((e) => ({
@@ -4260,19 +4262,19 @@ function Xe(t) {
4260
4262
  }))
4261
4263
  };
4262
4264
  }
4263
- function Qe(t) {
4265
+ function He(t) {
4264
4266
  return {
4265
4267
  ...t,
4266
4268
  suggestions: t.suggestions.map((e) => ({
4267
4269
  ...e,
4268
- insertText: e.insertText.split("").every(We) ? e.insertText : `"${e.insertText}"`
4270
+ insertText: e.insertText.split("").every(Ye) ? e.insertText : `"${e.insertText}"`
4269
4271
  }))
4270
4272
  };
4271
4273
  }
4272
4274
  function ct(t, e) {
4273
4275
  return t.getOffsetAt(e);
4274
4276
  }
4275
- class Qt {
4277
+ class Ht {
4276
4278
  constructor(e, n = []) {
4277
4279
  this.compiler = e, this.triggerCharacters = n;
4278
4280
  }
@@ -4283,18 +4285,18 @@ class Qt {
4283
4285
  ...(a == null ? void 0 : a.trailingTrivia) || [],
4284
4286
  ...(a == null ? void 0 : a.leadingTrivia) || [],
4285
4287
  ...(c == null ? void 0 : c.leadingTrivia) || []
4286
- ].find((E) => an(E) && ye(s, E)))
4288
+ ].find((E) => rn(E) && ke(s, E)))
4287
4289
  return B();
4288
4290
  if (r === void 0)
4289
4291
  return yt();
4290
- if ([h.STRING_LITERAL, h.QUOTED_STRING].includes(a.kind) && ye(s, a))
4292
+ if ([h.STRING_LITERAL, h.QUOTED_STRING].includes(a.kind) && ke(s, a))
4291
4293
  return B();
4292
4294
  const f = this.compiler.container.element(s);
4293
- if (this.compiler.container.scopeKind(s) === M.TOPLEVEL || f instanceof y && f.type && f.type.start <= s && f.type.end >= s)
4295
+ if (this.compiler.container.scopeKind(s) === U.TOPLEVEL || f instanceof y && f.type && f.type.start <= s && f.type.end >= s)
4294
4296
  return yt();
4295
4297
  const p = [...this.compiler.container.stack(s)].reverse();
4296
4298
  for (const E of p)
4297
- if (E instanceof Z)
4299
+ if (E instanceof K)
4298
4300
  switch ((d = E.op) == null ? void 0 : d.value) {
4299
4301
  case ">":
4300
4302
  case "<":
@@ -4318,7 +4320,7 @@ class Qt {
4318
4320
  E
4319
4321
  );
4320
4322
  case ".":
4321
- return Ht(
4323
+ return Jt(
4322
4324
  this.compiler,
4323
4325
  s,
4324
4326
  E
@@ -4330,28 +4332,34 @@ class Qt {
4330
4332
  if (E instanceof R)
4331
4333
  return gt(this.compiler, s, E);
4332
4334
  if (E instanceof fe)
4333
- return ms(this.compiler, s);
4334
- if (E instanceof w)
4335
+ return bs(this.compiler, s);
4336
+ if (E instanceof Le)
4337
+ return Ts(this.compiler, s);
4338
+ if (E instanceof v)
4335
4339
  return wt(this.compiler, s, E);
4336
- if (E instanceof y && (E.bodyColon && s >= E.bodyColon.end || E.body && ye(s, E.body)))
4340
+ if (E instanceof y && (E.bodyColon && s >= E.bodyColon.end || E.body && ke(s, E.body)))
4337
4341
  return wt(this.compiler, s, void 0);
4338
4342
  }
4339
4343
  return B();
4340
4344
  }
4341
4345
  }
4346
+ function Ts(t, e, n) {
4347
+ const s = t.container.element(e);
4348
+ return Oe(t, e, s, [m.TablePartial]);
4349
+ }
4342
4350
  function At(t, e, n) {
4343
4351
  const s = t.container.scopeKind(e);
4344
- if ([M.REF, M.TABLE].includes(s)) {
4345
- const i = He(t, e, t.container.element(e), [
4352
+ if ([U.REF, U.TABLE].includes(s)) {
4353
+ const i = Oe(t, e, t.container.element(e), [
4346
4354
  m.Table,
4347
4355
  m.Schema,
4348
4356
  m.Column
4349
4357
  ]);
4350
- return Ce(n.op, e) ? Xe(i) : i;
4358
+ return Xe(n.op, e) ? $e(i) : i;
4351
4359
  }
4352
4360
  return B();
4353
4361
  }
4354
- function He(t, e, n, s) {
4362
+ function Oe(t, e, n, s) {
4355
4363
  var r;
4356
4364
  if (n === void 0)
4357
4365
  return B();
@@ -4364,36 +4372,36 @@ function He(t, e, n, s) {
4364
4372
  ...t.symbol.members(c).filter(({ kind: f }) => s.includes(f)).map(({ name: f, kind: p }) => ({
4365
4373
  label: f,
4366
4374
  insertText: f,
4367
- insertTextRules: x.KeepWhitespace,
4368
- kind: xe(p),
4369
- sortText: xe(p).toString().padStart(2, "0"),
4375
+ insertTextRules: P.KeepWhitespace,
4376
+ kind: Pe(p),
4377
+ sortText: Pe(p).toString().padStart(2, "0"),
4370
4378
  range: void 0
4371
4379
  }))
4372
4380
  );
4373
4381
  }
4374
4382
  i = i instanceof y ? i.parent : void 0;
4375
4383
  }
4376
- return Qe(a);
4384
+ return He(a);
4377
4385
  }
4378
- function ms(t, e) {
4386
+ function bs(t, e) {
4379
4387
  var s;
4380
4388
  switch (t.container.scopeKind(e)) {
4381
- case M.INDEXES:
4389
+ case U.INDEXES:
4382
4390
  return Kt(t, e);
4383
- case M.REF:
4391
+ case U.REF:
4384
4392
  {
4385
4393
  const i = [...t.container.stack(e)];
4386
4394
  for (; i.length > 0; ) {
4387
4395
  const a = i.pop();
4388
4396
  if (a instanceof le && ((s = a.op) == null ? void 0 : s.value) === ".")
4389
- return Ht(
4397
+ return Jt(
4390
4398
  t,
4391
4399
  e,
4392
4400
  a
4393
4401
  );
4394
4402
  }
4395
4403
  }
4396
- return Jt(t, e);
4404
+ return Zt(t, e);
4397
4405
  }
4398
4406
  return B();
4399
4407
  }
@@ -4401,43 +4409,43 @@ function gt(t, e, n) {
4401
4409
  const { token: s } = t.container.token(e);
4402
4410
  if ([h.COMMA, h.LBRACKET].includes(s == null ? void 0 : s.kind)) {
4403
4411
  const i = vt(t, e);
4404
- return (s == null ? void 0 : s.kind) === h.COMMA && Ce(s, e) ? Xe(i) : i;
4412
+ return (s == null ? void 0 : s.kind) === h.COMMA && Xe(s, e) ? $e(i) : i;
4405
4413
  }
4406
4414
  if (n.name && n.name.start <= e && n.name.end >= e)
4407
4415
  return vt(t, e);
4408
4416
  if (n.name instanceof ne) {
4409
- const i = Ts(
4417
+ const i = Is(
4410
4418
  t,
4411
4419
  e,
4412
- Ae(n.name).unwrap_or("")
4420
+ ge(n.name).unwrap_or("")
4413
4421
  );
4414
- return (s == null ? void 0 : s.kind) === h.COLON && Ce(s, e) ? Xe(i) : i;
4422
+ return (s == null ? void 0 : s.kind) === h.COLON && Xe(s, e) ? $e(i) : i;
4415
4423
  }
4416
4424
  return B();
4417
4425
  }
4418
4426
  function vt(t, e) {
4419
4427
  const n = t.container.element(e), s = t.container.scopeKind(e);
4420
- if (n instanceof K)
4428
+ if (n instanceof Z)
4421
4429
  return B();
4422
- if (n.body && !ye(e, n.body))
4430
+ if (n.body && !ke(e, n.body))
4423
4431
  switch (s) {
4424
- case M.TABLE:
4432
+ case U.TABLE:
4425
4433
  return {
4426
4434
  suggestions: ["headercolor", "note"].map((i) => ({
4427
4435
  label: i,
4428
4436
  insertText: `${i}: `,
4429
- kind: v.Field,
4430
- insertTextRules: x.KeepWhitespace,
4437
+ kind: w.Field,
4438
+ insertTextRules: P.KeepWhitespace,
4431
4439
  range: void 0
4432
4440
  }))
4433
4441
  };
4434
- case M.TABLEGROUP:
4442
+ case U.TABLEGROUP:
4435
4443
  return {
4436
4444
  suggestions: ["color", "note"].map((i) => ({
4437
4445
  label: i,
4438
4446
  insertText: `${i}: `,
4439
- kind: v.Field,
4440
- insertTextRules: x.KeepWhitespace,
4447
+ kind: w.Field,
4448
+ insertTextRules: P.KeepWhitespace,
4441
4449
  range: void 0
4442
4450
  }))
4443
4451
  };
@@ -4445,77 +4453,77 @@ function vt(t, e) {
4445
4453
  return B();
4446
4454
  }
4447
4455
  switch (s) {
4448
- case M.TABLE:
4456
+ case U.TABLE:
4449
4457
  return {
4450
4458
  suggestions: [
4451
4459
  ...["primary key", "null", "not null", "increment", "pk", "unique"].map((i) => ({
4452
4460
  label: i,
4453
4461
  insertText: i,
4454
- kind: v.Property,
4455
- insertTextRules: x.KeepWhitespace,
4462
+ kind: w.Property,
4463
+ insertTextRules: P.KeepWhitespace,
4456
4464
  range: void 0
4457
4465
  })),
4458
4466
  ...["ref", "default"].map((i) => ({
4459
4467
  label: i,
4460
4468
  insertText: `${i}: `,
4461
- kind: v.Property,
4462
- insertTextRules: x.KeepWhitespace,
4469
+ kind: w.Property,
4470
+ insertTextRules: P.KeepWhitespace,
4463
4471
  range: void 0
4464
4472
  })),
4465
4473
  {
4466
4474
  label: "note",
4467
4475
  insertText: "note: ",
4468
- kind: v.Property,
4469
- insertTextRules: x.KeepWhitespace,
4476
+ kind: w.Property,
4477
+ insertTextRules: P.KeepWhitespace,
4470
4478
  range: void 0
4471
4479
  }
4472
4480
  ]
4473
4481
  };
4474
- case M.ENUM:
4482
+ case U.ENUM:
4475
4483
  return {
4476
4484
  suggestions: [
4477
4485
  {
4478
4486
  label: "note",
4479
4487
  insertText: "note: ",
4480
- kind: v.Property,
4481
- insertTextRules: x.KeepWhitespace,
4488
+ kind: w.Property,
4489
+ insertTextRules: P.KeepWhitespace,
4482
4490
  range: void 0
4483
4491
  }
4484
4492
  ]
4485
4493
  };
4486
- case M.INDEXES:
4494
+ case U.INDEXES:
4487
4495
  return {
4488
4496
  suggestions: [
4489
4497
  ...["unique", "pk"].map((i) => ({
4490
4498
  label: i,
4491
4499
  insertText: i,
4492
- insertTextRules: x.KeepWhitespace,
4493
- kind: v.Property,
4500
+ insertTextRules: P.KeepWhitespace,
4501
+ kind: w.Property,
4494
4502
  range: void 0
4495
4503
  })),
4496
4504
  ...["note", "name", "type"].map((i) => ({
4497
4505
  label: i,
4498
4506
  insertText: `${i}: `,
4499
- kind: v.Property,
4500
- insertTextRules: x.KeepWhitespace,
4507
+ kind: w.Property,
4508
+ insertTextRules: P.KeepWhitespace,
4501
4509
  range: void 0
4502
4510
  }))
4503
4511
  ]
4504
4512
  };
4505
- case M.REF:
4513
+ case U.REF:
4506
4514
  return {
4507
4515
  suggestions: ["update", "delete"].map((i) => ({
4508
4516
  label: i,
4509
4517
  insertText: `${i}: `,
4510
- kind: v.Property,
4511
- insertTextRules: x.KeepWhitespace,
4518
+ kind: w.Property,
4519
+ insertTextRules: P.KeepWhitespace,
4512
4520
  range: void 0
4513
4521
  }))
4514
4522
  };
4515
4523
  }
4516
4524
  return B();
4517
4525
  }
4518
- function Ts(t, e, n) {
4526
+ function Is(t, e, n) {
4519
4527
  switch (n == null ? void 0 : n.toLowerCase()) {
4520
4528
  case "update":
4521
4529
  case "delete":
@@ -4523,8 +4531,8 @@ function Ts(t, e, n) {
4523
4531
  suggestions: ["cascade", "set default", "set null", "restrict"].map((s) => ({
4524
4532
  label: s,
4525
4533
  insertText: s,
4526
- kind: v.Value,
4527
- insertTextRules: x.KeepWhitespace,
4534
+ kind: w.Value,
4535
+ insertTextRules: P.KeepWhitespace,
4528
4536
  range: void 0
4529
4537
  }))
4530
4538
  };
@@ -4533,24 +4541,24 @@ function Ts(t, e, n) {
4533
4541
  suggestions: ["btree", "hash"].map((s) => ({
4534
4542
  label: s,
4535
4543
  insertText: `${s}`,
4536
- kind: v.Value,
4537
- insertTextRules: x.KeepWhitespace,
4544
+ kind: w.Value,
4545
+ insertTextRules: P.KeepWhitespace,
4538
4546
  range: void 0
4539
4547
  }))
4540
4548
  };
4541
4549
  }
4542
4550
  return B();
4543
4551
  }
4544
- function Ht(t, e, n) {
4545
- const s = Ie(n).unwrap_or([]);
4546
- if (s.pop(), s.some((a) => !$(a)))
4552
+ function Jt(t, e, n) {
4553
+ const s = _e(n).unwrap_or([]);
4554
+ if (s.pop(), s.some((a) => !j(a)))
4547
4555
  return B();
4548
4556
  const i = s.map((a) => W(a).unwrap());
4549
- return Qe({
4557
+ return He({
4550
4558
  suggestions: t.symbol.ofName({ nameStack: i, owner: t.container.element(e) }).flatMap(({ symbol: a }) => t.symbol.members(a)).map(({ kind: a, name: r }) => ({
4551
4559
  label: r,
4552
4560
  insertText: r,
4553
- kind: xe(a),
4561
+ kind: Pe(a),
4554
4562
  range: void 0
4555
4563
  }))
4556
4564
  });
@@ -4558,50 +4566,52 @@ function Ht(t, e, n) {
4558
4566
  function wt(t, e, n) {
4559
4567
  var i;
4560
4568
  switch (t.container.scopeKind(e)) {
4561
- case M.TABLE:
4562
- return Is(t, e, n);
4563
- case M.PROJECT:
4569
+ case U.TABLE:
4570
+ return kt(t, e, n);
4571
+ case U.TABLEPARTIAL:
4572
+ return kt(t, e, n);
4573
+ case U.PROJECT:
4574
+ return _s(t, e, n);
4575
+ case U.INDEXES:
4576
+ return gs(t, e);
4577
+ case U.ENUM:
4564
4578
  return Ls(t, e, n);
4565
- case M.INDEXES:
4566
- return As(t, e);
4567
- case M.ENUM:
4568
- return bs(t, e, n);
4569
- case M.REF: {
4570
- const a = Jt(t, e);
4571
- return ((i = t.container.token(e).token) == null ? void 0 : i.kind) === h.COLON && Ce(t.container.token(e).token, e) ? Xe(a) : a;
4579
+ case U.REF: {
4580
+ const a = Zt(t, e);
4581
+ return ((i = t.container.token(e).token) == null ? void 0 : i.kind) === h.COLON && Xe(t.container.token(e).token, e) ? $e(a) : a;
4572
4582
  }
4573
- case M.TABLEGROUP:
4574
- return _s(t);
4583
+ case U.TABLEGROUP:
4584
+ return As(t);
4575
4585
  default:
4576
4586
  return B();
4577
4587
  }
4578
4588
  }
4579
4589
  function yt() {
4580
4590
  return {
4581
- suggestions: ["Table", "TableGroup", "Enum", "Project", "Ref"].map((t) => ({
4591
+ suggestions: ["Table", "TableGroup", "Enum", "Project", "Ref", "TablePartial"].map((t) => ({
4582
4592
  label: t,
4583
4593
  insertText: t,
4584
- insertTextRules: x.KeepWhitespace,
4585
- kind: v.Keyword,
4594
+ insertTextRules: P.KeepWhitespace,
4595
+ kind: w.Keyword,
4586
4596
  range: void 0
4587
4597
  }))
4588
4598
  };
4589
4599
  }
4590
- function bs(t, e, n) {
4591
- return n != null && n.callee && ut(e, n) === 1 ? He(t, e, t.container.element(e), [
4600
+ function Ls(t, e, n) {
4601
+ return n != null && n.callee && ut(e, n) === 1 ? Oe(t, e, t.container.element(e), [
4592
4602
  m.Schema,
4593
4603
  m.Table,
4594
4604
  m.Column
4595
4605
  ]) : B();
4596
4606
  }
4597
- function Is(t, e, n) {
4607
+ function kt(t, e, n) {
4598
4608
  if (!(n != null && n.callee))
4599
4609
  return {
4600
4610
  suggestions: ["Note", "indexes"].map((i) => ({
4601
4611
  label: i,
4602
4612
  insertText: i,
4603
- insertTextRules: x.KeepWhitespace,
4604
- kind: v.Keyword,
4613
+ insertTextRules: P.KeepWhitespace,
4614
+ kind: w.Keyword,
4605
4615
  range: void 0
4606
4616
  }))
4607
4617
  };
@@ -4610,42 +4620,42 @@ function Is(t, e, n) {
4610
4620
  suggestions: ["Note", "indexes"].map((i) => ({
4611
4621
  label: i,
4612
4622
  insertText: i,
4613
- insertTextRules: x.KeepWhitespace,
4614
- kind: v.Keyword,
4623
+ insertTextRules: P.KeepWhitespace,
4624
+ kind: w.Keyword,
4615
4625
  range: void 0
4616
4626
  }))
4617
- } : s === 1 ? gs(t, e) : B();
4627
+ } : s === 1 ? vs(t, e) : B();
4618
4628
  }
4619
- function Ls(t, e, n) {
4629
+ function _s(t, e, n) {
4620
4630
  return n != null && n.callee ? ut(e, n) === 0 ? {
4621
4631
  suggestions: ["Table", "TableGroup", "Enum", "Note", "Ref"].map((i) => ({
4622
4632
  label: i,
4623
4633
  insertText: i,
4624
- insertTextRules: x.KeepWhitespace,
4625
- kind: v.Keyword,
4634
+ insertTextRules: P.KeepWhitespace,
4635
+ kind: w.Keyword,
4626
4636
  range: void 0
4627
4637
  }))
4628
4638
  } : B() : {
4629
4639
  suggestions: ["Table", "TableGroup", "Enum", "Note", "Ref"].map((i) => ({
4630
4640
  label: i,
4631
4641
  insertText: i,
4632
- insertTextRules: x.KeepWhitespace,
4633
- kind: v.Keyword,
4642
+ insertTextRules: P.KeepWhitespace,
4643
+ kind: w.Keyword,
4634
4644
  range: void 0
4635
4645
  }))
4636
4646
  };
4637
4647
  }
4638
- function Jt(t, e) {
4639
- return He(t, e, t.container.element(e), [
4648
+ function Zt(t, e) {
4649
+ return Oe(t, e, t.container.element(e), [
4640
4650
  m.Schema,
4641
4651
  m.Table,
4642
4652
  m.Column
4643
4653
  ]);
4644
4654
  }
4645
- function _s(t) {
4655
+ function As(t) {
4646
4656
  return {
4647
4657
  suggestions: [
4648
- ...Qe({
4658
+ ...He({
4649
4659
  suggestions: [...t.parse.publicSymbolTable().entries()].flatMap(([e]) => {
4650
4660
  const n = oe(e).unwrap_or(void 0);
4651
4661
  if (n === void 0)
@@ -4654,8 +4664,8 @@ function _s(t) {
4654
4664
  return s !== m.Table && s !== m.Schema ? [] : {
4655
4665
  label: i,
4656
4666
  insertText: i,
4657
- insertTextRules: x.KeepWhitespace,
4658
- kind: xe(s),
4667
+ insertTextRules: P.KeepWhitespace,
4668
+ kind: Pe(s),
4659
4669
  range: void 0
4660
4670
  };
4661
4671
  })
@@ -4663,17 +4673,17 @@ function _s(t) {
4663
4673
  ...["Note"].map((e) => ({
4664
4674
  label: e,
4665
4675
  insertText: e,
4666
- insertTextRules: x.KeepWhitespace,
4667
- kind: v.Keyword,
4676
+ insertTextRules: P.KeepWhitespace,
4677
+ kind: w.Keyword,
4668
4678
  range: void 0
4669
4679
  }))
4670
4680
  ]
4671
4681
  };
4672
4682
  }
4673
- function As(t, e) {
4683
+ function gs(t, e) {
4674
4684
  return Kt(t, e);
4675
4685
  }
4676
- function gs(t, e) {
4686
+ function vs(t, e) {
4677
4687
  return {
4678
4688
  suggestions: [
4679
4689
  ...[
@@ -4736,12 +4746,12 @@ function gs(t, e) {
4736
4746
  ].map((n) => ({
4737
4747
  label: n,
4738
4748
  insertText: n,
4739
- insertTextRules: x.KeepWhitespace,
4740
- kind: v.TypeParameter,
4741
- sortText: v.TypeParameter.toString().padStart(2, "0"),
4749
+ insertTextRules: P.KeepWhitespace,
4750
+ kind: w.TypeParameter,
4751
+ sortText: w.TypeParameter.toString().padStart(2, "0"),
4742
4752
  range: void 0
4743
4753
  })),
4744
- ...He(t, e, t.container.element(e), [
4754
+ ...Oe(t, e, t.container.element(e), [
4745
4755
  m.Enum,
4746
4756
  m.Schema
4747
4757
  ]).suggestions
@@ -4750,10 +4760,10 @@ function gs(t, e) {
4750
4760
  }
4751
4761
  function Kt(t, e) {
4752
4762
  const n = t.container.element(e), s = n == null ? void 0 : n.parent;
4753
- if (!((s == null ? void 0 : s.symbol) instanceof Rt))
4763
+ if (!((s == null ? void 0 : s.symbol) instanceof Ut))
4754
4764
  return B();
4755
4765
  const { symbolTable: i } = s.symbol;
4756
- return Qe({
4766
+ return He({
4757
4767
  suggestions: [...i.entries()].flatMap(([a]) => {
4758
4768
  const r = oe(a).unwrap_or(void 0);
4759
4769
  if (r === void 0)
@@ -4762,8 +4772,8 @@ function Kt(t, e) {
4762
4772
  return {
4763
4773
  label: c,
4764
4774
  insertText: c,
4765
- insertTextRules: x.KeepWhitespace,
4766
- kind: xe(m.Column),
4775
+ insertTextRules: P.KeepWhitespace,
4776
+ kind: Pe(m.Column),
4767
4777
  range: void 0
4768
4778
  };
4769
4779
  })
@@ -4775,7 +4785,7 @@ function ut(t, e) {
4775
4785
  const n = [e.callee, ...e.args], s = n.findIndex((i) => t <= i.end);
4776
4786
  return s === -1 ? n.length : s;
4777
4787
  }
4778
- class Zt {
4788
+ class en {
4779
4789
  constructor(e) {
4780
4790
  this.compiler = e;
4781
4791
  }
@@ -4784,7 +4794,11 @@ class Zt {
4784
4794
  const { uri: s } = e, i = ct(e, n), a = [...this.compiler.container.stack(i)];
4785
4795
  for (; a.length !== 0; ) {
4786
4796
  const c = a.pop();
4787
- if ((r = c == null ? void 0 : c.referee) != null && r.declaration && [_e.PRIMARY_EXPRESSION, _e.VARIABLE].includes(c == null ? void 0 : c.kind)) {
4797
+ if ((r = c == null ? void 0 : c.referee) != null && r.declaration && [
4798
+ Ie.PRIMARY_EXPRESSION,
4799
+ Ie.VARIABLE,
4800
+ Ie.PARTIAL_INJECTION
4801
+ ].includes(c == null ? void 0 : c.kind)) {
4788
4802
  const { startPos: f, endPos: p } = c.referee.declaration;
4789
4803
  return [
4790
4804
  {
@@ -4802,7 +4816,7 @@ class Zt {
4802
4816
  return [];
4803
4817
  }
4804
4818
  }
4805
- class en {
4819
+ class tn {
4806
4820
  constructor(e) {
4807
4821
  this.compiler = e;
4808
4822
  }
@@ -4811,9 +4825,9 @@ class en {
4811
4825
  for (; a.length !== 0; ) {
4812
4826
  const r = a.pop();
4813
4827
  if (r && [
4814
- _e.ELEMENT_DECLARATION,
4815
- _e.FUNCTION_APPLICATION,
4816
- _e.PRIMARY_EXPRESSION
4828
+ Ie.ELEMENT_DECLARATION,
4829
+ Ie.FUNCTION_APPLICATION,
4830
+ Ie.PRIMARY_EXPRESSION
4817
4831
  ].includes(r == null ? void 0 : r.kind)) {
4818
4832
  const { symbol: c } = r;
4819
4833
  if (c != null && c.references.length)
@@ -4831,24 +4845,24 @@ class en {
4831
4845
  return [];
4832
4846
  }
4833
4847
  }
4834
- const ys = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4848
+ const ks = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4835
4849
  __proto__: null,
4836
- CompletionItemInsertTextRule: x,
4837
- CompletionItemKind: v,
4838
- DBMLCompletionItemProvider: Qt,
4839
- DBMLDefinitionProvider: Zt,
4840
- DBMLReferencesProvider: en
4850
+ CompletionItemInsertTextRule: P,
4851
+ CompletionItemKind: w,
4852
+ DBMLCompletionItemProvider: Ht,
4853
+ DBMLDefinitionProvider: en,
4854
+ DBMLReferencesProvider: tn
4841
4855
  }, Symbol.toStringTag, { value: "Module" }));
4842
- var M = /* @__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))(M || {});
4843
- class ks {
4856
+ var U = /* @__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[t.TABLEPARTIAL = 9] = "TABLEPARTIAL", t))(U || {});
4857
+ class Ss {
4844
4858
  constructor() {
4845
4859
  this.source = "", this.cache = new Array(
4846
4860
  16
4847
4861
  /* TOTAL_QUERY_COUNT */
4848
- ).fill(null), this.nodeIdGenerator = new rn(), this.symbolIdGenerator = new dn(), this.token = {
4862
+ ).fill(null), this.nodeIdGenerator = new on(), this.symbolIdGenerator = new En(), this.token = {
4849
4863
  invalidStream: this.createQuery(
4850
4864
  6,
4851
- () => this.parse.tokens().filter(Mt)
4865
+ () => this.parse.tokens().filter(Ft)
4852
4866
  ),
4853
4867
  // Valid + Invalid tokens (which are guarenteed to be non-trivials) are included in the stream
4854
4868
  flatStream: this.createQuery(
@@ -4860,8 +4874,8 @@ class ks {
4860
4874
  _: this.createQuery(
4861
4875
  0,
4862
4876
  () => {
4863
- const e = new wn(this.source).lex().chain((n) => new Sn(n, this.nodeIdGenerator).parse()).chain(({ ast: n, tokens: s }) => new ls(n, this.symbolIdGenerator).analyze().map(() => ({ ast: n, tokens: s })));
4864
- return e.getErrors().length > 0 ? e : e.chain(({ ast: n, tokens: s }) => new Es(n).interpret().map((a) => ({ ast: n, tokens: s, rawDb: a })));
4877
+ const e = new yn(this.source).lex().chain((n) => new Pn(n, this.nodeIdGenerator).parse()).chain(({ ast: n, tokens: s }) => new cs(n, this.symbolIdGenerator).analyze().map(() => ({ ast: n, tokens: s })));
4878
+ return e.getErrors().length > 0 ? e : e.chain(({ ast: n, tokens: s }) => new Ns(n).interpret().map((a) => ({ ast: n, tokens: s, rawDb: a })));
4865
4879
  }
4866
4880
  ),
4867
4881
  ast: this.createQuery(
@@ -4885,14 +4899,14 @@ class ks {
4885
4899
  stack: this.createQuery(
4886
4900
  10,
4887
4901
  (e) => {
4888
- const n = this.token.flatStream(), { index: s, token: i } = this.container.token(e), a = s === void 0 ? -1 : nn(n, (p) => !p.isInvalid, s);
4902
+ const n = this.token.flatStream(), { index: s, token: i } = this.container.token(e), a = s === void 0 ? -1 : sn(n, (p) => !p.isInvalid, s);
4889
4903
  if (a === -1)
4890
4904
  return [this.parse.ast()];
4891
4905
  const r = n[a].start;
4892
4906
  let c = this.parse.ast();
4893
4907
  const f = [c];
4894
4908
  for (; ; ) {
4895
- const d = vn(c).find((u) => ye(r, u));
4909
+ const d = wn(c).find((u) => ke(r, u));
4896
4910
  if (d === void 0 || d instanceof J)
4897
4911
  break;
4898
4912
  f.push(d), c = d;
@@ -4901,16 +4915,16 @@ class ks {
4901
4915
  return f;
4902
4916
  for (; f.length > 0; ) {
4903
4917
  let p = !1;
4904
- const d = Ke(f);
4905
- if (d instanceof w) {
4918
+ const d = Ze(f);
4919
+ if (d instanceof v) {
4906
4920
  const u = this.parse.source();
4907
4921
  for (let E = d.end; E < e; E += 1)
4908
4922
  u[E] === `
4909
4923
  ` && (f.pop(), p = !0);
4910
4924
  } else
4911
- d instanceof Z || d instanceof le ? this.container.token(e).token !== d.op && (f.pop(), p = !0) : d instanceof R ? d.listCloseBracket && d.end <= e && (f.pop(), p = !0) : d instanceof fe ? d.tupleCloseParen && d.end <= e && (f.pop(), p = !0) : d instanceof re ? d.blockCloseBrace && d.end <= e && (f.pop(), p = !0) : d instanceof ne || d.end < e && (f.pop(), p = !0);
4925
+ d instanceof K || d instanceof le ? this.container.token(e).token !== d.op && (f.pop(), p = !0) : d instanceof R ? d.listCloseBracket && d.end <= e && (f.pop(), p = !0) : d instanceof fe ? d.tupleCloseParen && d.end <= e && (f.pop(), p = !0) : d instanceof re ? d.blockCloseBrace && d.end <= e && (f.pop(), p = !0) : d instanceof ne || d.end < e && (f.pop(), p = !0);
4912
4926
  if (p) {
4913
- const u = Ke(f);
4927
+ const u = Ze(f);
4914
4928
  u instanceof y && u.end <= e && f.pop();
4915
4929
  }
4916
4930
  if (!p)
@@ -4948,7 +4962,7 @@ class ks {
4948
4962
  ),
4949
4963
  scopeKind: this.createQuery(15, (e) => {
4950
4964
  var s;
4951
- if (this.container.element(e) instanceof K)
4965
+ if (this.container.element(e) instanceof Z)
4952
4966
  return 8;
4953
4967
  switch ((s = this.container.element(e).type) == null ? void 0 : s.value.toLowerCase()) {
4954
4968
  case "table":
@@ -4965,6 +4979,8 @@ class ks {
4965
4979
  return 4;
4966
4980
  case "project":
4967
4981
  return 6;
4982
+ case "tablepartial":
4983
+ return 9;
4968
4984
  default:
4969
4985
  return 7;
4970
4986
  }
@@ -4991,7 +5007,7 @@ class ks {
4991
5007
  let c = [r], f = [];
4992
5008
  for (const p of e)
4993
5009
  f = c.flatMap(
4994
- (d) => fn(p).flatMap((u) => {
5010
+ (d) => pn(p).flatMap((u) => {
4995
5011
  const E = d.get(u), b = oe(u).unwrap_or(void 0);
4996
5012
  return !E || !b ? [] : { ...b, symbol: E };
4997
5013
  })
@@ -5034,14 +5050,14 @@ class ks {
5034
5050
  }
5035
5051
  initMonacoServices() {
5036
5052
  return {
5037
- definitionProvider: new Zt(this),
5038
- referenceProvider: new en(this),
5039
- autocompletionProvider: new Qt(this)
5053
+ definitionProvider: new en(this),
5054
+ referenceProvider: new tn(this),
5055
+ autocompletionProvider: new Ht(this)
5040
5056
  };
5041
5057
  }
5042
5058
  }
5043
5059
  export {
5044
- ks as Compiler,
5045
- ws as serialize,
5046
- ys as services
5060
+ Ss as Compiler,
5061
+ ys as serialize,
5062
+ ks as services
5047
5063
  };