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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/dist/dbml-parse.js +6 -6
  2. package/dist/dbml-parse.mjs +904 -891
  3. package/dist/{compiler.d.ts → src/compiler.d.ts} +2 -1
  4. package/dist/{lib → src/lib}/analyzer/binder/elementBinder/elementBinder.d.ts +2 -2
  5. package/dist/{lib → src/lib}/analyzer/binder/elementBinder/table.d.ts +6 -8
  6. package/dist/{lib → src/lib}/analyzer/binder/types.d.ts +0 -3
  7. package/dist/{lib → src/lib}/analyzer/symbol/symbols.d.ts +6 -4
  8. package/dist/src/lib/analyzer/symbol/utils.d.ts +4 -0
  9. package/dist/{lib → src/lib}/analyzer/utils.d.ts +2 -1
  10. package/dist/{lib → src/lib}/analyzer/validator/elementValidators/table.d.ts +3 -4
  11. package/dist/{lib → src/lib}/parser/nodes.d.ts +2 -1
  12. package/dist/tests/NaN_errors/interpreter_NaN.test.d.ts +1 -0
  13. package/dist/tests/binder/binder.test.d.ts +1 -0
  14. package/dist/tests/interpreter/interpreter.test.d.ts +1 -0
  15. package/dist/tests/jestHelpers.d.ts +1 -0
  16. package/dist/tests/lexer/lexer.test.d.ts +1 -0
  17. package/dist/tests/parser/parser.test.d.ts +1 -0
  18. package/dist/tests/validator/validator.test.d.ts +1 -0
  19. package/package.json +4 -2
  20. package/dist/lib/analyzer/symbol/utils.d.ts +0 -2
  21. /package/dist/{constants.d.ts → src/constants.d.ts} +0 -0
  22. /package/dist/{index.d.ts → src/index.d.ts} +0 -0
  23. /package/dist/{lib → src/lib}/analyzer/analyzer.d.ts +0 -0
  24. /package/dist/{lib → src/lib}/analyzer/binder/binder.d.ts +0 -0
  25. /package/dist/{lib → src/lib}/analyzer/binder/elementBinder/custom.d.ts +0 -0
  26. /package/dist/{lib → src/lib}/analyzer/binder/elementBinder/enum.d.ts +0 -0
  27. /package/dist/{lib → src/lib}/analyzer/binder/elementBinder/indexes.d.ts +0 -0
  28. /package/dist/{lib → src/lib}/analyzer/binder/elementBinder/note.d.ts +0 -0
  29. /package/dist/{lib → src/lib}/analyzer/binder/elementBinder/project.d.ts +0 -0
  30. /package/dist/{lib → src/lib}/analyzer/binder/elementBinder/ref.d.ts +0 -0
  31. /package/dist/{lib → src/lib}/analyzer/binder/elementBinder/tableGroup.d.ts +0 -0
  32. /package/dist/{lib → src/lib}/analyzer/binder/elementBinder/tablePartial.d.ts +0 -0
  33. /package/dist/{lib → src/lib}/analyzer/binder/utils.d.ts +0 -0
  34. /package/dist/{lib → src/lib}/analyzer/symbol/factory.d.ts +0 -0
  35. /package/dist/{lib → src/lib}/analyzer/symbol/symbolIndex.d.ts +0 -0
  36. /package/dist/{lib → src/lib}/analyzer/symbol/symbolTable.d.ts +0 -0
  37. /package/dist/{lib → src/lib}/analyzer/types.d.ts +0 -0
  38. /package/dist/{lib → src/lib}/analyzer/validator/elementValidators/custom.d.ts +0 -0
  39. /package/dist/{lib → src/lib}/analyzer/validator/elementValidators/enum.d.ts +0 -0
  40. /package/dist/{lib → src/lib}/analyzer/validator/elementValidators/indexes.d.ts +0 -0
  41. /package/dist/{lib → src/lib}/analyzer/validator/elementValidators/note.d.ts +0 -0
  42. /package/dist/{lib → src/lib}/analyzer/validator/elementValidators/project.d.ts +0 -0
  43. /package/dist/{lib → src/lib}/analyzer/validator/elementValidators/ref.d.ts +0 -0
  44. /package/dist/{lib → src/lib}/analyzer/validator/elementValidators/tableGroup.d.ts +0 -0
  45. /package/dist/{lib → src/lib}/analyzer/validator/elementValidators/tablePartial.d.ts +0 -0
  46. /package/dist/{lib → src/lib}/analyzer/validator/types.d.ts +0 -0
  47. /package/dist/{lib → src/lib}/analyzer/validator/utils.d.ts +0 -0
  48. /package/dist/{lib → src/lib}/analyzer/validator/validator.d.ts +0 -0
  49. /package/dist/{lib → src/lib}/errors.d.ts +0 -0
  50. /package/dist/{lib → src/lib}/interpreter/elementInterpreter/enum.d.ts +0 -0
  51. /package/dist/{lib → src/lib}/interpreter/elementInterpreter/project.d.ts +0 -0
  52. /package/dist/{lib → src/lib}/interpreter/elementInterpreter/ref.d.ts +0 -0
  53. /package/dist/{lib → src/lib}/interpreter/elementInterpreter/sticky_note.d.ts +0 -0
  54. /package/dist/{lib → src/lib}/interpreter/elementInterpreter/table.d.ts +0 -0
  55. /package/dist/{lib → src/lib}/interpreter/elementInterpreter/tableGroup.d.ts +0 -0
  56. /package/dist/{lib → src/lib}/interpreter/elementInterpreter/tablePartial.d.ts +0 -0
  57. /package/dist/{lib → src/lib}/interpreter/interpreter.d.ts +0 -0
  58. /package/dist/{lib → src/lib}/interpreter/types.d.ts +0 -0
  59. /package/dist/{lib → src/lib}/interpreter/utils.d.ts +0 -0
  60. /package/dist/{lib → src/lib}/lexer/lexer.d.ts +0 -0
  61. /package/dist/{lib → src/lib}/lexer/tokens.d.ts +0 -0
  62. /package/dist/{lib → src/lib}/lexer/utils.d.ts +0 -0
  63. /package/dist/{lib → src/lib}/option.d.ts +0 -0
  64. /package/dist/{lib → src/lib}/parser/contextStack.d.ts +0 -0
  65. /package/dist/{lib → src/lib}/parser/factory.d.ts +0 -0
  66. /package/dist/{lib → src/lib}/parser/parser.d.ts +0 -0
  67. /package/dist/{lib → src/lib}/parser/utils.d.ts +0 -0
  68. /package/dist/{lib → src/lib}/report.d.ts +0 -0
  69. /package/dist/{lib → src/lib}/serialization/serialize.d.ts +0 -0
  70. /package/dist/{lib → src/lib}/types.d.ts +0 -0
  71. /package/dist/{lib → src/lib}/utils.d.ts +0 -0
  72. /package/dist/{services → src/services}/definition/provider.d.ts +0 -0
  73. /package/dist/{services → src/services}/index.d.ts +0 -0
  74. /package/dist/{services → src/services}/references/provider.d.ts +0 -0
  75. /package/dist/{services → src/services}/suggestions/provider.d.ts +0 -0
  76. /package/dist/{services → src/services}/suggestions/utils.d.ts +0 -0
  77. /package/dist/{services → src/services}/types.d.ts +0 -0
  78. /package/dist/{services → src/services}/utils.d.ts +0 -0
@@ -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 pt, 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>":
@@ -12,7 +12,7 @@ function sn(t) {
12
12
  return !1;
13
13
  }
14
14
  }
15
- function pt(t) {
15
+ function dt(t) {
16
16
  if (!t)
17
17
  return !1;
18
18
  switch (t) {
@@ -28,13 +28,12 @@ function pt(t) {
28
28
  case ".":
29
29
  case "&":
30
30
  case "|":
31
- case "~":
32
31
  return !0;
33
32
  default:
34
33
  return !1;
35
34
  }
36
35
  }
37
- function dt(t) {
36
+ function Et(t) {
38
37
  return t !== void 0 && t.kind === "<op>";
39
38
  }
40
39
  class J {
@@ -45,27 +44,27 @@ class J {
45
44
  return new J(e, n, s, i, a);
46
45
  }
47
46
  }
48
- function kt(t) {
47
+ function St(t) {
49
48
  return t.trailingTrivia.find(({ kind: e }) => e === h.NEWLINE) !== void 0;
50
49
  }
51
- function Et(t, e) {
52
- return e.leadingTrivia.find(({ kind: s }) => s === h.NEWLINE) !== void 0 || kt(t);
50
+ function Nt(t, e) {
51
+ return e.leadingTrivia.find(({ kind: s }) => s === h.NEWLINE) !== void 0 || St(t);
53
52
  }
54
- function Ze(t) {
53
+ function Ke(t) {
55
54
  return t.trailingTrivia.find(({ kind: e }) => [h.SPACE, h.TAB].includes(e)) !== void 0;
56
55
  }
57
- function St(t) {
58
- return t.trailingTrivia.length === 0 ? t.end : St(Ke(t.trailingTrivia));
56
+ function Pt(t) {
57
+ return t.trailingTrivia.length === 0 ? t.end : Pt(Ze(t.trailingTrivia));
59
58
  }
60
59
  function xt(t) {
61
60
  return t.leadingTrivia.length === 0 ? t.start : xt(t.leadingTrivia[0]);
62
61
  }
63
- function an(t) {
62
+ function rn(t) {
64
63
  return [h.SINGLE_LINE_COMMENT, h.MULTILINE_COMMENT].includes(
65
64
  t.kind
66
65
  );
67
66
  }
68
- class rn {
67
+ class on {
69
68
  constructor() {
70
69
  this.id = 0;
71
70
  }
@@ -76,7 +75,7 @@ class rn {
76
75
  return this.id++;
77
76
  }
78
77
  }
79
- class D {
78
+ class x {
80
79
  // The symbol that this syntax node refers to
81
80
  // args must be passed in order of appearance in the node
82
81
  constructor(e, n, s) {
@@ -88,20 +87,20 @@ class D {
88
87
  line: NaN
89
88
  }, this.fullStart = NaN);
90
89
  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 = {
90
+ a ? (this.endPos = a.endPos, this.fullEnd = a instanceof J ? Pt(a) : a.fullEnd) : (this.endPos = {
92
91
  offset: NaN,
93
92
  column: NaN,
94
93
  line: NaN
95
94
  }, this.fullEnd = NaN), this.start = this.startPos.offset, this.end = this.endPos.offset;
96
95
  }
97
96
  }
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 {
97
+ 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 || {});
98
+ class Z extends x {
100
99
  constructor({ body: e = [], eof: n }, s) {
101
100
  super(s, "<program>", [...e, n]), this.body = e, this.eof = n;
102
101
  }
103
102
  }
104
- class y extends D {
103
+ class y extends x {
105
104
  constructor({
106
105
  type: e,
107
106
  name: n,
@@ -119,17 +118,17 @@ class y extends D {
119
118
  a,
120
119
  r,
121
120
  c
122
- ]), c && r && !(c instanceof w || c instanceof y))
121
+ ]), c && r && !(c instanceof v || c instanceof y))
123
122
  throw new Error("If an element has a simple body, it must be a function application node");
124
123
  this.type = e, this.name = n, this.as = s, this.alias = i, this.attributeList = a, this.bodyColon = r, this.body = c;
125
124
  }
126
125
  }
127
- class ne extends D {
126
+ class te extends x {
128
127
  constructor({ identifiers: e = [] }, n) {
129
128
  super(n, "<identifer-stream>", e || []), this.identifiers = e;
130
129
  }
131
130
  }
132
- class se extends D {
131
+ class ne extends x {
133
132
  constructor({
134
133
  name: e,
135
134
  colon: n,
@@ -138,12 +137,12 @@ class se extends D {
138
137
  super(i, "<attribute>", [e, n, s]), this.name = e, this.value = s, this.colon = n;
139
138
  }
140
139
  }
141
- class Z extends D {
140
+ class ie extends x {
142
141
  constructor({ op: e, expression: n }, s) {
143
142
  super(s, "<prefix-expression>", [e, n]), this.op = e, this.expression = n;
144
143
  }
145
144
  }
146
- class le extends D {
145
+ class le extends x {
147
146
  constructor({
148
147
  op: e,
149
148
  leftExpression: n,
@@ -152,22 +151,22 @@ class le extends D {
152
151
  super(i, "<infix-expression>", [n, e, s]), this.op = e, this.leftExpression = n, this.rightExpression = s;
153
152
  }
154
153
  }
155
- class $e extends D {
154
+ class $e extends x {
156
155
  constructor({ op: e, expression: n }, s) {
157
156
  super(s, "<postfix-expression>", [n, e]), this.op = e, this.expression = n;
158
157
  }
159
158
  }
160
- class ce extends D {
159
+ class ce extends x {
161
160
  constructor({ value: e }, n) {
162
161
  super(n, "<function-expression>", [e]), this.value = e;
163
162
  }
164
163
  }
165
- class w extends D {
164
+ class v extends x {
166
165
  constructor({ callee: e, args: n = [] }, s) {
167
166
  super(s, "<function-application>", [e, ...n]), this.callee = e, this.args = n;
168
167
  }
169
168
  }
170
- class re extends D {
169
+ class re extends x {
171
170
  constructor({
172
171
  blockOpenBrace: e,
173
172
  body: n = [],
@@ -176,12 +175,12 @@ class re extends D {
176
175
  super(i, "<block-expression>", [e, ...n, s]), this.blockOpenBrace = e, this.body = n, this.blockCloseBrace = s;
177
176
  }
178
177
  }
179
- class ke extends D {
180
- constructor({ partial: e }, n) {
181
- super(n, "<partial-injection>", [e]), this.partial = e;
178
+ class Le extends x {
179
+ constructor({ op: e, partial: n }, s) {
180
+ super(s, "<partial-injection>", [e, n]), this.partial = n;
182
181
  }
183
182
  }
184
- class R extends D {
183
+ class U extends x {
185
184
  constructor({
186
185
  listOpenBracket: e,
187
186
  elementList: n = [],
@@ -190,12 +189,12 @@ class R extends D {
190
189
  }, a) {
191
190
  super(a, "<list-expression>", [
192
191
  e,
193
- ...Pt(n, s),
192
+ ...Dt(n, s),
194
193
  i
195
194
  ]), this.listOpenBracket = e, this.elementList = n, this.commaList = s, this.listCloseBracket = i;
196
195
  }
197
196
  }
198
- class fe extends D {
197
+ class fe extends x {
199
198
  constructor({
200
199
  tupleOpenParen: e,
201
200
  elementList: n = [],
@@ -204,12 +203,12 @@ class fe extends D {
204
203
  }, a) {
205
204
  super(a, "<tuple-expression>", [
206
205
  e,
207
- ...Pt(n, s),
206
+ ...Dt(n, s),
208
207
  i
209
208
  ]), this.tupleOpenParen = e, this.elementList = n, this.commaList = s, this.tupleCloseParen = i;
210
209
  }
211
210
  }
212
- class tt extends fe {
211
+ class et extends fe {
213
212
  constructor({
214
213
  groupOpenParen: e,
215
214
  expression: n,
@@ -226,7 +225,7 @@ class tt extends fe {
226
225
  ), this.kind = "<group-expression>";
227
226
  }
228
227
  }
229
- class Y extends D {
228
+ class Y extends x {
230
229
  constructor({
231
230
  callee: e,
232
231
  argumentList: n
@@ -234,33 +233,33 @@ class Y extends D {
234
233
  super(s, "<call-expression>", [e, n]), this.callee = e, this.argumentList = n;
235
234
  }
236
235
  }
237
- class ge extends D {
236
+ class we extends x {
238
237
  constructor({ literal: e }, n) {
239
238
  super(n, "<literal>", [e]), this.literal = e;
240
239
  }
241
240
  }
242
- class ae extends D {
241
+ class ae extends x {
243
242
  constructor({ variable: e }, n) {
244
243
  super(n, "<variable>", [e]), this.variable = e;
245
244
  }
246
245
  }
247
- class G extends D {
246
+ class j extends x {
248
247
  constructor({ expression: e }, n) {
249
248
  super(n, "<primary-expression>", [e]), this.expression = e;
250
249
  }
251
250
  }
252
- class Re extends D {
251
+ class Ue extends x {
253
252
  constructor({ pre: e }, n) {
254
253
  const s = J.create(h.SPACE, e.endPos, e.endPos, " ", !1);
255
254
  super(n, "<dummy>", [s]);
256
255
  }
257
256
  }
258
- class ue extends D {
257
+ class ue extends x {
259
258
  constructor({ expression: e, indexer: n }, s) {
260
259
  super(s, "<array>", [e, n]), this.array = e, this.indexer = n;
261
260
  }
262
261
  }
263
- function Pt(t, e) {
262
+ function Dt(t, e) {
264
263
  if (!t || t.length === 0)
265
264
  return e || [];
266
265
  if (!e || e.length === 0)
@@ -270,12 +269,12 @@ function Pt(t, e) {
270
269
  (i) => i !== null
271
270
  );
272
271
  }
273
- function ws(t, e = !1) {
272
+ function Ss(t, e = !1) {
274
273
  return JSON.stringify(
275
274
  t,
276
275
  function(n, s) {
277
276
  var i;
278
- return !(this instanceof K) && n === "symbol" ? s == null ? void 0 : s.id : (
277
+ return !(this instanceof Z) && n === "symbol" ? s == null ? void 0 : s.id : (
279
278
  /* this instanceof SyntaxNode && */
280
279
  n === "symbol" ? {
281
280
  symbolTable: s == null ? void 0 : s.symbolTable,
@@ -296,7 +295,7 @@ function ws(t, e = !1) {
296
295
  e ? 2 : 0
297
296
  );
298
297
  }
299
- class O {
298
+ class R {
300
299
  constructor(e) {
301
300
  this.value = e;
302
301
  }
@@ -311,14 +310,14 @@ class O {
311
310
  return e(this.value);
312
311
  }
313
312
  map(e) {
314
- return new O(e(this.value));
313
+ return new R(e(this.value));
315
314
  }
316
315
  // eslint-disable-next-line class-methods-use-this
317
316
  isOk() {
318
317
  return !0;
319
318
  }
320
319
  }
321
- class P {
320
+ class S {
322
321
  // eslint-disable-next-line class-methods-use-this
323
322
  unwrap() {
324
323
  throw new Error("Trying to unwrap a None value");
@@ -329,11 +328,11 @@ class P {
329
328
  }
330
329
  // eslint-disable-next-line @typescript-eslint/no-unused-vars, class-methods-use-this
331
330
  and_then(e) {
332
- return new P();
331
+ return new S();
333
332
  }
334
333
  // eslint-disable-next-line @typescript-eslint/no-unused-vars, class-methods-use-this
335
334
  map(e) {
336
- return new P();
335
+ return new S();
337
336
  }
338
337
  // eslint-disable-next-line class-methods-use-this
339
338
  isOk() {
@@ -341,64 +340,64 @@ class P {
341
340
  }
342
341
  }
343
342
  var m = /* @__PURE__ */ ((t) => (t.Schema = "Schema", t.Table = "Table", t.Column = "Column", t.TableGroup = "TableGroup", t.TableGroupField = "TableGroup field", t.Enum = "Enum", t.EnumField = "Enum field", t.Note = "Note", t.TablePartial = "TablePartial", t.TablePartialInjection = "TablePartialInjection", t))(m || {});
344
- function nt(t) {
343
+ function tt(t) {
345
344
  return `Schema:${t}`;
346
345
  }
347
- function Fe(t) {
346
+ function Be(t) {
348
347
  return `Table:${t}`;
349
348
  }
350
- function je(t) {
349
+ function We(t) {
351
350
  return `Column:${t}`;
352
351
  }
353
- function st(t) {
352
+ function nt(t) {
354
353
  return `Enum:${t}`;
355
354
  }
356
- function it(t) {
355
+ function st(t) {
357
356
  return `Enum field:${t}`;
358
357
  }
359
- function at(t) {
358
+ function it(t) {
360
359
  return `TableGroup:${t}`;
361
360
  }
362
- function rt(t) {
361
+ function at(t) {
363
362
  return `TableGroup field:${t}`;
364
363
  }
365
- function on(t) {
364
+ function ln(t) {
366
365
  return `Note:${t}`;
367
366
  }
368
- function Dt(t) {
367
+ function rt(t) {
369
368
  return `TablePartial:${t}`;
370
369
  }
371
- function ln(t) {
370
+ function Ot(t) {
372
371
  return `TablePartialInjection:${t}`;
373
372
  }
374
- function Ue(t, e) {
373
+ function Me(t, e) {
375
374
  switch (e) {
376
375
  case "Column":
377
- return je(t);
376
+ return We(t);
378
377
  case "Enum":
379
- return st(t);
378
+ return nt(t);
380
379
  case "Enum field":
381
- return it(t);
380
+ return st(t);
382
381
  case "Schema":
383
- return nt(t);
382
+ return tt(t);
384
383
  case "Table":
385
- return Fe(t);
384
+ return Be(t);
386
385
  case "TableGroup":
387
- return at(t);
386
+ return it(t);
388
387
  case "TableGroup field":
389
- return rt(t);
388
+ return at(t);
390
389
  case "TablePartial":
391
- return Dt(t);
390
+ return rt(t);
392
391
  default:
393
392
  throw new Error("Unreachable");
394
393
  }
395
394
  }
396
395
  function oe(t) {
397
396
  const [e, n] = t.split(":");
398
- return Object.values(m).includes(e) ? new O({
397
+ return Object.values(m).includes(e) ? new R({
399
398
  name: n,
400
399
  kind: e
401
- }) : new P();
400
+ }) : new S();
402
401
  }
403
402
  function cn(t) {
404
403
  const e = oe(t).unwrap_or(void 0);
@@ -419,47 +418,13 @@ function hn(t) {
419
418
  if (!e)
420
419
  return null;
421
420
  const { kind: n, name: s } = e;
422
- return n === "TablePartialInjection" ? Ue(
421
+ return n === "TablePartialInjection" ? Me(
423
422
  s,
424
423
  "TablePartial"
425
424
  /* TablePartial */
426
425
  ) : null;
427
426
  }
428
- function fn(t) {
429
- return [
430
- nt,
431
- Fe,
432
- st,
433
- at,
434
- je,
435
- it,
436
- rt
437
- ].map((e) => e(t));
438
- }
439
- function We(t) {
440
- return !!t.match(/(\p{L}|_|\p{M})/gu);
441
- }
442
- function Be(t) {
443
- const [e] = t;
444
- return e >= "0" && e <= "9";
445
- }
446
- function pn(t) {
447
- const [e] = t;
448
- return Be(e) || We(e) && e.toLowerCase() >= "a" && e.toLowerCase() <= "f";
449
- }
450
- function Le(t) {
451
- return We(t) || Be(t);
452
- }
453
- function Nt(t, e) {
454
- const n = [], s = Math.min(t.length, e.length);
455
- for (let i = 0; i < s; i += 1)
456
- n.push(t[i], e[i]);
457
- return n.push(...t.slice(s), ...e.slice(s)), n;
458
- }
459
- function ye(t, e) {
460
- return t >= e.start && t < e.end;
461
- }
462
- class dn {
427
+ class fn {
463
428
  constructor() {
464
429
  this.id = 0;
465
430
  }
@@ -470,56 +435,95 @@ class dn {
470
435
  return this.id++;
471
436
  }
472
437
  }
473
- class Ot {
438
+ class Rt {
474
439
  constructor({ symbolTable: e }, n) {
475
440
  this.references = [], this.id = n, this.symbolTable = e;
476
441
  }
477
442
  }
478
- class En {
443
+ class pn {
479
444
  constructor({ symbolTable: e, declaration: n }, s) {
480
445
  this.references = [], this.id = s, this.symbolTable = e, this.declaration = n;
481
446
  }
482
447
  }
483
- class Nn {
448
+ class dn {
484
449
  constructor({ declaration: e }, n) {
485
450
  this.references = [], this.id = n, this.declaration = e;
486
451
  }
487
452
  }
488
- class Rt {
453
+ class Ut {
489
454
  constructor({ symbolTable: e, declaration: n }, s) {
490
455
  this.references = [], this.id = s, this.symbolTable = e, this.declaration = n;
491
456
  }
492
457
  }
493
- class Ut {
458
+ class ot {
494
459
  constructor({ declaration: e }, n) {
495
460
  this.references = [], this.id = n, this.declaration = e;
496
461
  }
497
462
  }
498
- class mn {
463
+ class En {
499
464
  constructor({ symbolTable: e, declaration: n }, s) {
500
465
  this.references = [], this.id = s, this.symbolTable = e, this.declaration = n;
501
466
  }
502
467
  }
503
- class Tn {
468
+ class Nn {
504
469
  constructor({ declaration: e }, n) {
505
470
  this.references = [], this.id = n, this.declaration = e;
506
471
  }
507
472
  }
508
- class bn {
473
+ class mn {
509
474
  constructor({ symbolTable: e, declaration: n }, s) {
510
475
  this.references = [], this.id = s, this.symbolTable = e, this.declaration = n;
511
476
  }
512
477
  }
513
- class In {
478
+ class Tn {
514
479
  constructor({ declaration: e }, n) {
515
480
  this.references = [], this.id = n, this.declaration = e;
516
481
  }
517
482
  }
518
- class Ln {
519
- constructor({ injectorId: e }, n) {
520
- this.references = [], this.id = n, this.injectorId = e;
483
+ class bn {
484
+ constructor({ injectorFieldSymbol: e, injectorDeclaration: n }, s) {
485
+ this.references = [], this.id = s, this.injectorDeclaration = n, this.injectorFieldSymbol = e;
521
486
  }
522
487
  }
488
+ function In(t) {
489
+ return [
490
+ tt,
491
+ Be,
492
+ We,
493
+ nt,
494
+ st,
495
+ it,
496
+ at,
497
+ rt,
498
+ Ot
499
+ ].map((e) => e(t));
500
+ }
501
+ function Ln(t) {
502
+ return t instanceof ot ? bn : null;
503
+ }
504
+ function Ye(t) {
505
+ return !!t.match(/(\p{L}|_|\p{M})/gu);
506
+ }
507
+ function Ve(t) {
508
+ const [e] = t;
509
+ return e >= "0" && e <= "9";
510
+ }
511
+ function An(t) {
512
+ const [e] = t;
513
+ return Ve(e) || Ye(e) && e.toLowerCase() >= "a" && e.toLowerCase() <= "f";
514
+ }
515
+ function ge(t) {
516
+ return Ye(t) || Ve(t);
517
+ }
518
+ function mt(t, e) {
519
+ const n = [], s = Math.min(t.length, e.length);
520
+ for (let i = 0; i < s; i += 1)
521
+ n.push(t[i], e[i]);
522
+ return n.push(...t.slice(s), ...e.slice(s)), n;
523
+ }
524
+ function Se(t, e) {
525
+ return t >= e.start && t < e.end;
526
+ }
523
527
  var o = /* @__PURE__ */ ((t) => (t[t.UNKNOWN_SYMBOL = 1e3] = "UNKNOWN_SYMBOL", t[t.UNEXPECTED_SYMBOL = 1001] = "UNEXPECTED_SYMBOL", t[t.UNEXPECTED_EOF = 1002] = "UNEXPECTED_EOF", t[t.UNEXPECTED_NEWLINE = 1003] = "UNEXPECTED_NEWLINE", t[t.UNKNOWN_TOKEN = 1004] = "UNKNOWN_TOKEN", t[t.UNEXPECTED_TOKEN = 1005] = "UNEXPECTED_TOKEN", t[t.UNEXPECTED_ELEMENT_DECLARATION = 1006] = "UNEXPECTED_ELEMENT_DECLARATION", t[t.MISSING_SPACES = 1007] = "MISSING_SPACES", t[t.UNKNOWN_PREFIX_OP = 1008] = "UNKNOWN_PREFIX_OP", t[t.INVALID_OPERAND = 1009] = "INVALID_OPERAND", t[t.EMPTY_ATTRIBUTE_NAME = 1010] = "EMPTY_ATTRIBUTE_NAME", t[t.INVALID_ESCAPE_SEQUENCE = 1011] = "INVALID_ESCAPE_SEQUENCE", t[t.INVALID_NAME = 3e3] = "INVALID_NAME", t[t.UNEXPECTED_NAME = 3001] = "UNEXPECTED_NAME", t[t.NAME_NOT_FOUND = 3002] = "NAME_NOT_FOUND", t[t.DUPLICATE_NAME = 3003] = "DUPLICATE_NAME", t[t.INVALID_ALIAS = 3004] = "INVALID_ALIAS", t[t.UNEXPECTED_ALIAS = 3005] = "UNEXPECTED_ALIAS", t[t.UNEXPECTED_SETTINGS = 3006] = "UNEXPECTED_SETTINGS", t[t.INVALID_SETTINGS = 3007] = "INVALID_SETTINGS", t[t.UNEXPECTED_SIMPLE_BODY = 3008] = "UNEXPECTED_SIMPLE_BODY", t[t.UNEXPECTED_COMPLEX_BODY = 3009] = "UNEXPECTED_COMPLEX_BODY", t[t.INVALID_TABLE_CONTEXT = 3010] = "INVALID_TABLE_CONTEXT", t[t.INVALID_TABLE_SETTING = 3011] = "INVALID_TABLE_SETTING", t[t.DUPLICATE_TABLE_SETTING = 3012] = "DUPLICATE_TABLE_SETTING", t[t.INVALID_TABLE_FIELD = 3013] = "INVALID_TABLE_FIELD", t[t.INVALID_TABLEGROUP_CONTEXT = 3014] = "INVALID_TABLEGROUP_CONTEXT", t[t.INVALID_TABLEGROUP_ELEMENT_NAME = 3015] = "INVALID_TABLEGROUP_ELEMENT_NAME", t[t.DUPLICATE_TABLEGROUP_ELEMENT_NAME = 3016] = "DUPLICATE_TABLEGROUP_ELEMENT_NAME", t[t.DUPLICATE_TABLEGROUP_FIELD_NAME = 3017] = "DUPLICATE_TABLEGROUP_FIELD_NAME", t[t.INVALID_TABLEGROUP_FIELD = 3018] = "INVALID_TABLEGROUP_FIELD", t[t.INVALID_TABLE_PARTIAL_CONTEXT = 3019] = "INVALID_TABLE_PARTIAL_CONTEXT", t[t.INVALID_TABLE_PARTIAL_ELEMENT_NAME = 3020] = "INVALID_TABLE_PARTIAL_ELEMENT_NAME", t[t.INVALID_TABLE_PARTIAL_SETTING = 3021] = "INVALID_TABLE_PARTIAL_SETTING", t[t.DUPLICATE_TABLE_PARTIAL_ELEMENT_NAME = 3022] = "DUPLICATE_TABLE_PARTIAL_ELEMENT_NAME", t[t.DUPLICATE_TABLE_PARTIAL_SETTING = 3023] = "DUPLICATE_TABLE_PARTIAL_SETTING", t[t.INVALID_TABLE_PARTIAL_INJECTION = 3024] = "INVALID_TABLE_PARTIAL_INJECTION", t[t.INVALID_TABLE_PARTIAL_INJECTION_OP = 3025] = "INVALID_TABLE_PARTIAL_INJECTION_OP", t[t.INVALID_TABLE_PARTIAL_INJECTION_NAME = 3026] = "INVALID_TABLE_PARTIAL_INJECTION_NAME", t[t.DUPLICATE_TABLE_PARTIAL_INJECTION_NAME = 3027] = "DUPLICATE_TABLE_PARTIAL_INJECTION_NAME", t[t.EMPTY_TABLE = 3028] = "EMPTY_TABLE", t[t.INVALID_COLUMN = 3029] = "INVALID_COLUMN", t[t.INVALID_COLUMN_NAME = 3030] = "INVALID_COLUMN_NAME", t[t.UNKNOWN_COLUMN_SETTING = 3031] = "UNKNOWN_COLUMN_SETTING", t[t.INVALID_COLUMN_TYPE = 3032] = "INVALID_COLUMN_TYPE", t[t.DUPLICATE_COLUMN_NAME = 3033] = "DUPLICATE_COLUMN_NAME", t[t.DUPLICATE_COLUMN_SETTING = 3034] = "DUPLICATE_COLUMN_SETTING", t[t.INVALID_COLUMN_SETTING_VALUE = 3035] = "INVALID_COLUMN_SETTING_VALUE", t[t.INVALID_ENUM_CONTEXT = 3036] = "INVALID_ENUM_CONTEXT", t[t.INVALID_ENUM_ELEMENT_NAME = 3037] = "INVALID_ENUM_ELEMENT_NAME", t[t.INVALID_ENUM_ELEMENT = 3038] = "INVALID_ENUM_ELEMENT", t[t.DUPLICATE_ENUM_ELEMENT_NAME = 3039] = "DUPLICATE_ENUM_ELEMENT_NAME", t[t.UNKNOWN_ENUM_ELEMENT_SETTING = 3040] = "UNKNOWN_ENUM_ELEMENT_SETTING", t[t.DUPLICATE_ENUM_ELEMENT_SETTING = 3041] = "DUPLICATE_ENUM_ELEMENT_SETTING", t[t.INVALID_ENUM_ELEMENT_SETTING = 3042] = "INVALID_ENUM_ELEMENT_SETTING", t[t.EMPTY_ENUM = 3043] = "EMPTY_ENUM", t[t.INVALID_REF_CONTEXT = 3044] = "INVALID_REF_CONTEXT", t[t.UNKNOWN_REF_SETTING = 3045] = "UNKNOWN_REF_SETTING", t[t.DUPLICATE_REF_SETTING = 3046] = "DUPLICATE_REF_SETTING", t[t.INVALID_REF_SETTING_VALUE = 3047] = "INVALID_REF_SETTING_VALUE", t[t.INVALID_REF_RELATIONSHIP = 3048] = "INVALID_REF_RELATIONSHIP", t[t.INVALID_REF_FIELD = 3049] = "INVALID_REF_FIELD", t[t.EMPTY_REF = 3050] = "EMPTY_REF", t[t.REF_REDEFINED = 3051] = "REF_REDEFINED", t[t.INVALID_NOTE_CONTEXT = 3052] = "INVALID_NOTE_CONTEXT", t[t.INVALID_NOTE = 3053] = "INVALID_NOTE", t[t.NOTE_REDEFINED = 3054] = "NOTE_REDEFINED", t[t.NOTE_CONTENT_REDEFINED = 3055] = "NOTE_CONTENT_REDEFINED", t[t.EMPTY_NOTE = 3056] = "EMPTY_NOTE", t[t.INVALID_INDEXES_CONTEXT = 3057] = "INVALID_INDEXES_CONTEXT", t[t.INVALID_INDEXES_FIELD = 3058] = "INVALID_INDEXES_FIELD", t[t.INVALID_INDEX = 3059] = "INVALID_INDEX", t[t.UNKNOWN_INDEX_SETTING = 3060] = "UNKNOWN_INDEX_SETTING", t[t.DUPLICATE_INDEX_SETTING = 3061] = "DUPLICATE_INDEX_SETTING", t[t.UNEXPECTED_INDEX_SETTING_VALUE = 3062] = "UNEXPECTED_INDEX_SETTING_VALUE", t[t.INVALID_INDEX_SETTING_VALUE = 3063] = "INVALID_INDEX_SETTING_VALUE", t[t.INVALID_PROJECT_CONTEXT = 3064] = "INVALID_PROJECT_CONTEXT", t[t.PROJECT_REDEFINED = 3065] = "PROJECT_REDEFINED", t[t.INVALID_PROJECT_FIELD = 3066] = "INVALID_PROJECT_FIELD", t[t.INVALID_CUSTOM_CONTEXT = 3067] = "INVALID_CUSTOM_CONTEXT", t[t.INVALID_CUSTOM_ELEMENT_VALUE = 3068] = "INVALID_CUSTOM_ELEMENT_VALUE", t[t.INVALID_ELEMENT_IN_SIMPLE_BODY = 3069] = "INVALID_ELEMENT_IN_SIMPLE_BODY", t[t.BINDING_ERROR = 4e3] = "BINDING_ERROR", t[t.UNSUPPORTED = 5e3] = "UNSUPPORTED", t[t.CIRCULAR_REF = 5001] = "CIRCULAR_REF", t[t.SAME_ENDPOINT = 5002] = "SAME_ENDPOINT", t[t.UNEQUAL_FIELDS_BINARY_REF = 5003] = "UNEQUAL_FIELDS_BINARY_REF", t[t.CONFLICTING_SETTING = 5004] = "CONFLICTING_SETTING", t[t.TABLE_REAPPEAR_IN_TABLEGROUP = 5005] = "TABLE_REAPPEAR_IN_TABLEGROUP", t))(o || {});
524
528
  class l extends Error {
525
529
  constructor(e, n, s) {
@@ -546,12 +550,12 @@ class q {
546
550
  }
547
551
  function _n(t, e, n) {
548
552
  if (!t || !he(t) || e.length === 0)
549
- return new P();
553
+ return new S();
550
554
  const s = [...e], i = Je(t).unwrap(), a = s.pop();
551
555
  if (!(a instanceof re))
552
- return new P();
553
- const r = _.last(s) instanceof R ? s.pop() : void 0;
554
- return s.length === 3 && Je(s[1]).unwrap().value === "as" ? new O(
556
+ return new S();
557
+ const r = _.last(s) instanceof U ? s.pop() : void 0;
558
+ return s.length === 3 && Je(s[1]).unwrap().value === "as" ? new R(
555
559
  n.create(y, {
556
560
  type: i,
557
561
  name: s[0],
@@ -560,38 +564,38 @@ function _n(t, e, n) {
560
564
  attributeList: r,
561
565
  body: a
562
566
  })
563
- ) : s.length === 1 ? new O(
567
+ ) : s.length === 1 ? new R(
564
568
  n.create(y, {
565
569
  type: i,
566
570
  name: s[0],
567
571
  attributeList: r,
568
572
  body: a
569
573
  })
570
- ) : s.length === 0 ? new O(
574
+ ) : s.length === 0 ? new R(
571
575
  n.create(y, {
572
576
  type: i,
573
577
  attributeList: r,
574
578
  body: a
575
579
  })
576
- ) : new P();
580
+ ) : new S();
577
581
  }
578
- function mt(t) {
582
+ function Tt(t) {
579
583
  return t.kind === h.IDENTIFIER && t.value === "as";
580
584
  }
581
585
  function T(t) {
582
- t && (t instanceof J ? An(t) : gn(t));
586
+ t && (t instanceof J ? gn(t) : vn(t));
583
587
  }
584
- function An(t) {
588
+ function gn(t) {
585
589
  t.kind !== h.EOF && (t.isInvalid = !0);
586
590
  }
587
- function gn(t) {
591
+ function vn(t) {
588
592
  if (t instanceof y)
589
593
  T(t.type), T(t.name), T(t.as), T(t.alias), T(t.bodyColon), T(t.attributeList), T(t.body);
590
- else if (t instanceof ne)
594
+ else if (t instanceof te)
591
595
  t.identifiers.forEach(T);
592
- else if (t instanceof se)
596
+ else if (t instanceof ne)
593
597
  T(t.name), T(t.colon), T(t.value);
594
- else if (t instanceof Z)
598
+ else if (t instanceof ie)
595
599
  T(t.op), T(t.expression);
596
600
  else if (t instanceof le)
597
601
  T(t.leftExpression), T(t.op), T(t.rightExpression);
@@ -599,36 +603,36 @@ function gn(t) {
599
603
  T(t.op), T(t.expression);
600
604
  else if (t instanceof re)
601
605
  T(t.blockOpenBrace), t.body.forEach(T), T(t.blockCloseBrace);
602
- else if (t instanceof R)
606
+ else if (t instanceof U)
603
607
  T(t.listOpenBracket), t.commaList.forEach(T), t.elementList.forEach(T), T(t.listCloseBracket);
604
608
  else if (t instanceof fe)
605
609
  T(t.tupleOpenParen), t.commaList.forEach(T), t.elementList.forEach(T), T(t.tupleCloseParen);
606
610
  else if (t instanceof Y)
607
611
  T(t.callee), T(t.argumentList);
608
- else if (t instanceof w)
612
+ else if (t instanceof v)
609
613
  T(t.callee), t.args.forEach(T);
610
- else if (t instanceof G)
614
+ else if (t instanceof j)
611
615
  T(t.expression);
612
616
  else if (t instanceof ce)
613
617
  T(t.value);
614
618
  else if (t instanceof ae)
615
619
  T(t.variable);
616
- else if (t instanceof ge)
620
+ else if (t instanceof we)
617
621
  T(t.literal);
618
622
  else
619
- throw t instanceof tt ? new Error("This case is handled by the TupleExpressionNode case") : new Error("Unreachable case in markInvalidNode");
623
+ throw t instanceof et ? new Error("This case is handled by the TupleExpressionNode case") : new Error("Unreachable case in markInvalidNode");
620
624
  }
621
625
  function Mt(t) {
622
626
  return !!(t != null && t.isInvalid);
623
627
  }
624
- function j(...t) {
628
+ function C(...t) {
625
629
  return t.filter((e) => e !== void 0);
626
630
  }
627
- function vn(t) {
628
- if (t instanceof K)
629
- return j(...t.body, t.eof);
631
+ function wn(t) {
632
+ if (t instanceof Z)
633
+ return C(...t.body, t.eof);
630
634
  if (t instanceof y)
631
- return j(
635
+ return C(
632
636
  t.type,
633
637
  t.name,
634
638
  t.as,
@@ -637,74 +641,76 @@ function vn(t) {
637
641
  t.bodyColon,
638
642
  t.body
639
643
  );
640
- if (t instanceof se)
641
- return j(t.name, t.colon, t.value);
642
644
  if (t instanceof ne)
645
+ return C(t.name, t.colon, t.value);
646
+ if (t instanceof te)
643
647
  return t.identifiers;
644
- if (t instanceof ge)
648
+ if (t instanceof we)
645
649
  return t.literal ? [t.literal] : [];
646
650
  if (t instanceof ae)
647
- return j(t.variable);
648
- if (t instanceof Z)
649
- return j(t.op, t.expression);
651
+ return C(t.variable);
652
+ if (t instanceof ie)
653
+ return C(t.op, t.expression);
650
654
  if (t instanceof le)
651
- return j(t.leftExpression, t.op, t.rightExpression);
655
+ return C(t.leftExpression, t.op, t.rightExpression);
652
656
  if (t instanceof $e)
653
- return j(t.expression, t.op);
657
+ return C(t.expression, t.op);
654
658
  if (t instanceof ce)
655
- return j(t.value);
656
- if (t instanceof w)
657
- return j(t.callee, ...t.args);
659
+ return C(t.value);
660
+ if (t instanceof v)
661
+ return C(t.callee, ...t.args);
658
662
  if (t instanceof re)
659
- return j(t.blockOpenBrace, ...t.body, t.blockCloseBrace);
660
- if (t instanceof R)
661
- return j(
663
+ return C(t.blockOpenBrace, ...t.body, t.blockCloseBrace);
664
+ if (t instanceof U)
665
+ return C(
662
666
  t.listOpenBracket,
663
- ...Nt(t.elementList, t.commaList),
667
+ ...mt(t.elementList, t.commaList),
664
668
  t.listCloseBracket
665
669
  );
666
670
  if (t instanceof fe)
667
- return j(
671
+ return C(
668
672
  t.tupleOpenParen,
669
- ...Nt(t.elementList, t.commaList),
673
+ ...mt(t.elementList, t.commaList),
670
674
  t.tupleCloseParen
671
675
  );
672
676
  if (t instanceof Y)
673
- return j(t.callee, t.argumentList);
674
- if (t instanceof G)
675
- return j(t.expression);
677
+ return C(t.callee, t.argumentList);
678
+ if (t instanceof j)
679
+ return C(t.expression);
676
680
  if (t instanceof ue)
677
- return j(
681
+ return C(
678
682
  t.array,
679
683
  t.indexer
680
684
  );
681
- throw t instanceof tt ? new Error("This case is already handled by TupleExpressionNode") : new Error("Unreachable - no other possible cases");
685
+ if (t instanceof Le)
686
+ return C(t.partial);
687
+ throw t instanceof et ? new Error("This case is already handled by TupleExpressionNode") : new Error("Unreachable - no other possible cases");
682
688
  }
683
689
  function Je(t) {
684
- return $(t) ? new O(t.expression.variable) : new P();
690
+ return $(t) ? new R(t.expression.variable) : new S();
685
691
  }
686
- function C(t) {
692
+ function G(t) {
687
693
  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);
694
+ return t instanceof j && (t.expression instanceof ae && t.expression.variable instanceof J && t.expression.variable.kind === h.QUOTED_STRING || t.expression instanceof we && ((e = t.expression.literal) == null ? void 0 : e.kind) === h.STRING_LITERAL);
689
695
  }
690
696
  function $(t) {
691
- return t instanceof G && t.expression instanceof ae && t.expression.variable instanceof J;
697
+ return t instanceof j && t.expression instanceof ae && t.expression.variable instanceof J;
692
698
  }
693
699
  function he(t) {
694
700
  var e;
695
- return t instanceof G && t.expression instanceof ae && ((e = t.expression.variable) == null ? void 0 : e.kind) === h.IDENTIFIER;
701
+ return t instanceof j && t.expression instanceof ae && ((e = t.expression.variable) == null ? void 0 : e.kind) === h.IDENTIFIER;
696
702
  }
697
- function Ye(t) {
703
+ function qe(t) {
698
704
  var e;
699
- return t instanceof le && t.leftExpression instanceof D && t.rightExpression instanceof D && ((e = t.op) == null ? void 0 : e.value) === ".";
705
+ return t instanceof le && t.leftExpression instanceof x && t.rightExpression instanceof x && ((e = t.op) == null ? void 0 : e.value) === ".";
700
706
  }
701
- function Ae(t) {
707
+ function ve(t) {
702
708
  if (t === void 0)
703
- return new P();
709
+ return new S();
704
710
  const e = t.identifiers.map((n) => n.value).join(" ");
705
- return e === "" ? new P() : new O(e);
711
+ return e === "" ? new S() : new R(e);
706
712
  }
707
- class wn {
713
+ class yn {
708
714
  // list of errors during lexing
709
715
  constructor(e) {
710
716
  this.start = {
@@ -817,15 +823,15 @@ class wn {
817
823
  this.match("/") ? this.singleLineComment() : this.match("*") ? this.multilineComment() : this.operator();
818
824
  break;
819
825
  default:
820
- if (pt(e)) {
826
+ if (dt(e)) {
821
827
  this.operator();
822
828
  break;
823
829
  }
824
- if (We(e)) {
830
+ if (Ye(e)) {
825
831
  this.identifier();
826
832
  break;
827
833
  }
828
- if (Be(e)) {
834
+ if (Ve(e)) {
829
835
  this.numericLiteralOrIdentifier();
830
836
  break;
831
837
  }
@@ -845,7 +851,7 @@ class wn {
845
851
  let e = !0, n = [], s;
846
852
  const i = [];
847
853
  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);
854
+ 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
855
  this.tokens = i;
850
856
  }
851
857
  gatherInvalid() {
@@ -940,12 +946,12 @@ class wn {
940
946
  });
941
947
  }
942
948
  identifier() {
943
- for (; !this.isAtEnd() && Le(this.peek()); )
949
+ for (; !this.isAtEnd() && ge(this.peek()); )
944
950
  this.advance();
945
951
  this.addToken(h.IDENTIFIER);
946
952
  }
947
953
  operator() {
948
- for (; pt(this.peek()); )
954
+ for (; dt(this.peek()); )
949
955
  this.advance();
950
956
  this.addToken(h.OP);
951
957
  }
@@ -960,26 +966,26 @@ class wn {
960
966
  break;
961
967
  if (!n && this.current.offset === this.text.length - 1)
962
968
  return this.advance(), this.addToken(h.NUMERIC_LITERAL);
963
- if (!n && !Le(this.peek()))
969
+ if (!n && !ge(this.peek()))
964
970
  return this.addToken(h.NUMERIC_LITERAL);
965
- if (!n && !Be(this.peek()))
971
+ if (!n && !Ve(this.peek()))
966
972
  break;
967
973
  this.advance();
968
974
  }
969
975
  if (e > 0) {
970
- for (; !this.isAtEnd() && (this.check(".") || Le(this.peek())); )
976
+ for (; !this.isAtEnd() && (this.check(".") || ge(this.peek())); )
971
977
  this.advance();
972
978
  const n = this.createToken(h.NUMERIC_LITERAL, !0);
973
979
  this.tokens.push(n), this.errors.push(new l(o.UNKNOWN_TOKEN, "Invalid number", n));
974
980
  } else {
975
- for (; !this.isAtEnd() && Le(this.peek()); )
981
+ for (; !this.isAtEnd() && ge(this.peek()); )
976
982
  this.advance();
977
983
  const n = this.createToken(h.IDENTIFIER, !1);
978
984
  this.tokens.push(n);
979
985
  }
980
986
  }
981
987
  colorLiteral() {
982
- for (; !this.isAtEnd() && Le(this.peek()); )
988
+ for (; !this.isAtEnd() && ge(this.peek()); )
983
989
  this.advance();
984
990
  this.addToken(h.COLOR_LITERAL);
985
991
  }
@@ -1020,7 +1026,7 @@ class wn {
1020
1026
  case "u": {
1021
1027
  let n = "";
1022
1028
  for (let s = 0; s <= 3; s += 1) {
1023
- if (this.isAtEnd() || !Le(this.peek()))
1029
+ if (this.isAtEnd() || !ge(this.peek()))
1024
1030
  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
1031
  n += this.advance();
1026
1032
  }
@@ -1031,8 +1037,8 @@ class wn {
1031
1037
  }
1032
1038
  }
1033
1039
  }
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 {
1040
+ var Fe = /* @__PURE__ */ ((t) => (t[t.ListExpression = 0] = "ListExpression", t[t.GroupExpression = 1] = "GroupExpression", t[t.BlockExpression = 2] = "BlockExpression", t))(Fe || {});
1041
+ class kn {
1036
1042
  constructor() {
1037
1043
  this.stack = [], this.numberOfNestedLParens = 0, this.numberOfNestedLBrackets = 0, this.numberOfNestedLBraces = 0;
1038
1044
  }
@@ -1098,7 +1104,7 @@ class yn {
1098
1104
  }
1099
1105
  }
1100
1106
  }
1101
- class kn {
1107
+ class Sn {
1102
1108
  constructor(e) {
1103
1109
  this.generator = e;
1104
1110
  }
@@ -1111,15 +1117,15 @@ class N {
1111
1117
  this.token = e, this.partialNode = n, this.handlerContext = s;
1112
1118
  }
1113
1119
  }
1114
- class Sn {
1120
+ class Pn {
1115
1121
  constructor(e, n) {
1116
- this.current = 0, this.errors = [], this.contextStack = new yn(), this.synchronizeProgram = () => {
1122
+ this.current = 0, this.errors = [], this.contextStack = new kn(), this.synchronizeProgram = () => {
1117
1123
  const s = this.peek();
1118
1124
  s.kind !== h.EOF ? T(this.advance()) : (T(this.peek()), this.logError(s, o.UNEXPECTED_EOF, "Unexpected EOF"));
1119
1125
  }, this.synchronizeElementDeclarationName = () => {
1120
1126
  for (; !this.isAtEnd(); ) {
1121
1127
  const s = this.peek();
1122
- if (mt(s) || this.check(h.COLON, h.LBRACE, h.LBRACKET))
1128
+ if (Tt(s) || this.check(h.COLON, h.LBRACE, h.LBRACKET))
1123
1129
  break;
1124
1130
  T(s), this.advance();
1125
1131
  }
@@ -1130,7 +1136,7 @@ class Sn {
1130
1136
  break;
1131
1137
  T(s), this.advance();
1132
1138
  }
1133
- }, this.blockExpression = this.contextStack.withContextDo(Me.BlockExpression, () => {
1139
+ }, this.blockExpression = this.contextStack.withContextDo(Fe.BlockExpression, () => {
1134
1140
  const s = { body: [] }, i = () => this.nodeFactory.create(re, s);
1135
1141
  try {
1136
1142
  this.consume("Expect an opening brace '{'", h.LBRACE), s.blockOpenBrace = this.previous();
@@ -1144,7 +1150,7 @@ class Sn {
1144
1150
  for (; !this.isAtEnd() && !this.check(h.RBRACE); )
1145
1151
  try {
1146
1152
  if (this.match(h.TILDE)) {
1147
- const a = this.previous(), r = this.variable(), c = this.nodeFactory.create(ke, { op: a, partial: r });
1153
+ const a = this.previous(), r = this.variable(), c = this.nodeFactory.create(Le, { op: a, partial: r });
1148
1154
  s.body.push(c);
1149
1155
  } else
1150
1156
  s.body.push(this.canBeField() ? this.fieldDeclaration() : this.expression());
@@ -1169,12 +1175,12 @@ class Sn {
1169
1175
  if (!this.check(h.RBRACE))
1170
1176
  for (T(this.advance()); !this.isAtEnd(); ) {
1171
1177
  const s = this.peek();
1172
- if (this.check(h.RBRACE) || Et(this.previous(), s))
1178
+ if (this.check(h.RBRACE) || Nt(this.previous(), s))
1173
1179
  break;
1174
1180
  T(s), this.advance();
1175
1181
  }
1176
- }, this.tupleExpression = this.contextStack.withContextDo(Me.GroupExpression, () => {
1177
- const s = { elementList: [], commaList: [] }, i = () => this.nodeFactory.create(tt, {
1182
+ }, this.tupleExpression = this.contextStack.withContextDo(Fe.GroupExpression, () => {
1183
+ const s = { elementList: [], commaList: [] }, i = () => this.nodeFactory.create(et, {
1178
1184
  groupOpenParen: s.tupleOpenParen,
1179
1185
  groupCloseParen: s.tupleCloseParen,
1180
1186
  expression: s.elementList[0]
@@ -1204,7 +1210,7 @@ class Sn {
1204
1210
  } catch (r) {
1205
1211
  if (!(r instanceof N))
1206
1212
  throw r;
1207
- if (r.partialNode instanceof D && s.elementList.push(r.partialNode), !this.canHandle(r))
1213
+ if (r.partialNode instanceof x && s.elementList.push(r.partialNode), !this.canHandle(r))
1208
1214
  throw new N(r.token, a(), r.handlerContext);
1209
1215
  this.synchronizeTuple();
1210
1216
  }
@@ -1225,8 +1231,8 @@ class Sn {
1225
1231
  break;
1226
1232
  T(s), this.advance();
1227
1233
  }
1228
- }, this.listExpression = this.contextStack.withContextDo(Me.ListExpression, () => {
1229
- const s = { elementList: [], commaList: [] }, i = () => this.nodeFactory.create(R, s);
1234
+ }, this.listExpression = this.contextStack.withContextDo(Fe.ListExpression, () => {
1235
+ const s = { elementList: [], commaList: [] }, i = () => this.nodeFactory.create(U, s);
1230
1236
  try {
1231
1237
  this.consume("Expect an opening bracket '['", h.LBRACKET), s.listOpenBracket = this.previous();
1232
1238
  } catch (a) {
@@ -1252,7 +1258,7 @@ class Sn {
1252
1258
  } catch (a) {
1253
1259
  if (!(a instanceof N))
1254
1260
  throw a;
1255
- if (a.partialNode instanceof D && s.elementList.push(a.partialNode), !this.canHandle(a))
1261
+ if (a.partialNode instanceof x && s.elementList.push(a.partialNode), !this.canHandle(a))
1256
1262
  throw new N(a.token, i(), a.handlerContext);
1257
1263
  this.synchronizeList();
1258
1264
  }
@@ -1287,7 +1293,7 @@ class Sn {
1287
1293
  break;
1288
1294
  T(s), this.advance();
1289
1295
  }
1290
- }, this.tokens = e, this.nodeFactory = new kn(n);
1296
+ }, this.tokens = e, this.nodeFactory = new Sn(n);
1291
1297
  }
1292
1298
  isAtEnd() {
1293
1299
  return this.current >= this.tokens.length || this.tokens[this.current].kind === h.EOF;
@@ -1343,7 +1349,7 @@ class Sn {
1343
1349
  this.tokens = e;
1344
1350
  }
1345
1351
  parse() {
1346
- const e = this.program(), n = this.advance(), s = this.nodeFactory.create(K, { body: e, eof: n });
1352
+ const e = this.program(), n = this.advance(), s = this.nodeFactory.create(Z, { body: e, eof: n });
1347
1353
  return this.gatherInvalid(), new q({ ast: s, tokens: this.tokens }, this.errors);
1348
1354
  }
1349
1355
  /* Parsing and synchronizing ProgramNode */
@@ -1378,7 +1384,7 @@ class Sn {
1378
1384
  throw new N(s.token, n(), s.handlerContext);
1379
1385
  this.synchronizeElementDeclarationName();
1380
1386
  }
1381
- if (mt(this.peek()))
1387
+ if (Tt(this.peek()))
1382
1388
  if (e.as = this.advance(), this.check(h.COLON, h.LBRACE, h.LBRACKET))
1383
1389
  this.logError(this.peek(), o.UNEXPECTED_TOKEN, "Expect an alias");
1384
1390
  else
@@ -1443,7 +1449,7 @@ class Sn {
1443
1449
  /* Parsing any ExpressionNode, including non-NormalExpression */
1444
1450
  expression() {
1445
1451
  const e = { args: [] }, n = () => _n(e.callee, e.args, this.nodeFactory).unwrap_or(
1446
- this.nodeFactory.create(w, e)
1452
+ this.nodeFactory.create(v, e)
1447
1453
  );
1448
1454
  try {
1449
1455
  e.callee = this.normalExpression();
@@ -1454,7 +1460,7 @@ class Sn {
1454
1460
  return n();
1455
1461
  let s = e.callee;
1456
1462
  for (; !this.shouldStopExpression(); ) {
1457
- Ze(this.previous()) || this.logError(s, o.MISSING_SPACES, "Expect a following space");
1463
+ Ke(this.previous()) || this.logError(s, o.MISSING_SPACES, "Expect a following space");
1458
1464
  try {
1459
1465
  s = this.normalExpression(), e.args.push(s);
1460
1466
  } catch (i) {
@@ -1464,7 +1470,7 @@ class Sn {
1464
1470
  return n();
1465
1471
  }
1466
1472
  shouldStopExpression() {
1467
- if (this.isAtEnd() || kt(this.previous()))
1473
+ if (this.isAtEnd() || St(this.previous()))
1468
1474
  return !0;
1469
1475
  const e = this.peek().kind;
1470
1476
  return e === h.RBRACE || e === h.RBRACKET || e === h.RPAREN || e === h.COMMA || e === h.COLON;
@@ -1478,12 +1484,12 @@ class Sn {
1478
1484
  for (; !this.isAtEnd(); ) {
1479
1485
  const s = this.peek();
1480
1486
  if (s.kind === h.LPAREN) {
1481
- const { left: i } = Tt(s);
1487
+ const { left: i } = bt(s);
1482
1488
  if (i < e || // When '(' is encountered,
1483
1489
  // consider it part of another expression if
1484
1490
  // it's at the start of a new line
1485
1491
  // and we're currently not having unmatched '(' or '['
1486
- Et(this.previous(), s) && !this.contextStack.isWithinGroupExpressionContext() && !this.contextStack.isWithinListExpressionContext())
1492
+ Nt(this.previous(), s) && !this.contextStack.isWithinGroupExpressionContext() && !this.contextStack.isWithinListExpressionContext())
1487
1493
  break;
1488
1494
  try {
1489
1495
  n = this.nodeFactory.create(Y, {
@@ -1497,7 +1503,7 @@ class Sn {
1497
1503
  }), new N(a.token, n, a.handlerContext)) : a;
1498
1504
  }
1499
1505
  } else if (s.kind === h.LBRACKET) {
1500
- if (Ze(this.previous()))
1506
+ if (Ke(this.previous()))
1501
1507
  break;
1502
1508
  try {
1503
1509
  n = this.nodeFactory.create(ue, {
@@ -1510,8 +1516,8 @@ class Sn {
1510
1516
  indexer: i.partialNode
1511
1517
  }), new N(i.token, n, i.handlerContext)) : i;
1512
1518
  }
1513
- } else if (dt(s)) {
1514
- const i = s, a = Tt(i);
1519
+ } else if (Et(s)) {
1520
+ const i = s, a = bt(i);
1515
1521
  if (a.left !== null) {
1516
1522
  if (a.left <= e)
1517
1523
  break;
@@ -1520,7 +1526,7 @@ class Sn {
1520
1526
  op: i
1521
1527
  });
1522
1528
  } else {
1523
- const r = Pn(i);
1529
+ const r = Dn(i);
1524
1530
  if (r.left === null || r.left <= e)
1525
1531
  break;
1526
1532
  this.advance();
@@ -1545,10 +1551,10 @@ class Sn {
1545
1551
  }
1546
1552
  leftExpression_bp() {
1547
1553
  let e;
1548
- if (dt(this.peek())) {
1554
+ if (Et(this.peek())) {
1549
1555
  const n = {};
1550
1556
  n.op = this.peek();
1551
- const s = On(n.op);
1557
+ const s = Rn(n.op);
1552
1558
  if (s.right === null)
1553
1559
  throw this.logError(
1554
1560
  n.op,
@@ -1556,7 +1562,7 @@ class Sn {
1556
1562
  `Unexpected '${n.op.value}' in an expression`
1557
1563
  ), new N(
1558
1564
  n.op,
1559
- this.nodeFactory.create(Re, { pre: n.op }),
1565
+ this.nodeFactory.create(Ue, { pre: n.op }),
1560
1566
  this.contextStack.findHandlerContext(this.tokens, this.current)
1561
1567
  );
1562
1568
  this.advance();
@@ -1565,15 +1571,15 @@ class Sn {
1565
1571
  } catch (i) {
1566
1572
  throw i instanceof N ? (n.expression = i.partialNode, new N(
1567
1573
  i.token,
1568
- this.nodeFactory.create(Z, n),
1574
+ this.nodeFactory.create(ie, n),
1569
1575
  i.handlerContext
1570
1576
  )) : i;
1571
1577
  }
1572
- e = this.nodeFactory.create(Z, n);
1573
- } else if (e = this.extractOperand(), e instanceof Re)
1578
+ e = this.nodeFactory.create(ie, n);
1579
+ } else if (e = this.extractOperand(), e instanceof Ue)
1574
1580
  throw new N(
1575
1581
  this.peek(),
1576
- this.nodeFactory.create(Re, { pre: this.peek() }),
1582
+ this.nodeFactory.create(Ue, { pre: this.peek() }),
1577
1583
  this.contextStack.findHandlerContext(this.tokens, this.current)
1578
1584
  );
1579
1585
  return e;
@@ -1597,7 +1603,7 @@ class Sn {
1597
1603
  this.peek(),
1598
1604
  o.INVALID_OPERAND,
1599
1605
  `Invalid start of operand "${this.peek().value}"`
1600
- ), this.nodeFactory.create(Re, { pre: this.previous() }));
1606
+ ), this.nodeFactory.create(Ue, { pre: this.previous() }));
1601
1607
  }
1602
1608
  /* Parsing FunctionExpression */
1603
1609
  functionExpression() {
@@ -1628,11 +1634,11 @@ class Sn {
1628
1634
  h.STRING_LITERAL,
1629
1635
  h.NUMERIC_LITERAL
1630
1636
  ))
1631
- return this.nodeFactory.create(G, {
1632
- expression: this.nodeFactory.create(ge, { literal: this.previous() })
1637
+ return this.nodeFactory.create(j, {
1638
+ expression: this.nodeFactory.create(we, { literal: this.previous() })
1633
1639
  });
1634
1640
  if (this.match(h.QUOTED_STRING, h.IDENTIFIER))
1635
- return this.nodeFactory.create(G, {
1641
+ return this.nodeFactory.create(j, {
1636
1642
  expression: this.nodeFactory.create(ae, { variable: this.previous() })
1637
1643
  });
1638
1644
  throw this.logError(this.peek(), o.UNEXPECTED_TOKEN, "Expect a variable or literal"), new N(
@@ -1649,7 +1655,7 @@ class Sn {
1649
1655
  n,
1650
1656
  o.EMPTY_ATTRIBUTE_NAME,
1651
1657
  "Expect a non-empty attribute name"
1652
- ), e.name = this.nodeFactory.create(ne, { identifiers: [] });
1658
+ ), e.name = this.nodeFactory.create(te, { identifiers: [] });
1653
1659
  } else
1654
1660
  try {
1655
1661
  e.name = this.attributeName();
@@ -1659,12 +1665,12 @@ class Sn {
1659
1665
  if (e.name = n.partialNode, !this.canHandle(n))
1660
1666
  throw new N(
1661
1667
  n.token,
1662
- this.nodeFactory.create(se, e),
1668
+ this.nodeFactory.create(ne, e),
1663
1669
  n.handlerContext
1664
1670
  );
1665
1671
  this.synchronizeAttributeName();
1666
1672
  }
1667
- return this.match(h.COLON) && (e.colon = this.previous(), e.value = this.attributeValue()), this.nodeFactory.create(se, e);
1673
+ return this.match(h.COLON) && (e.colon = this.previous(), e.value = this.attributeValue()), this.nodeFactory.create(ne, e);
1668
1674
  }
1669
1675
  attributeValue() {
1670
1676
  let e;
@@ -1687,11 +1693,11 @@ class Sn {
1687
1693
  } catch (n) {
1688
1694
  throw n instanceof N ? new N(
1689
1695
  n.token,
1690
- this.nodeFactory.create(ne, { identifiers: e }),
1696
+ this.nodeFactory.create(te, { identifiers: e }),
1691
1697
  n.handlerContext
1692
1698
  ) : n;
1693
1699
  }
1694
- return this.nodeFactory.create(ne, { identifiers: e });
1700
+ return this.nodeFactory.create(te, { identifiers: e });
1695
1701
  }
1696
1702
  logError(e, n, s) {
1697
1703
  this.errors.push(new l(n, s, e));
@@ -1713,10 +1719,10 @@ const xn = {
1713
1719
  "!=": { left: 4, right: 5 },
1714
1720
  ".": { left: 16, right: 17 }
1715
1721
  };
1716
- function Pn(t) {
1722
+ function Dn(t) {
1717
1723
  return xn[t.value] || { left: null, right: null };
1718
1724
  }
1719
- const Dn = {
1725
+ const On = {
1720
1726
  "+": { left: null, right: 15 },
1721
1727
  "-": { left: null, right: 15 },
1722
1728
  "<": { left: null, right: 15 },
@@ -1724,17 +1730,17 @@ const Dn = {
1724
1730
  "<>": { left: null, right: 15 },
1725
1731
  "!": { left: null, right: 15 }
1726
1732
  };
1727
- function On(t) {
1728
- return Dn[t.value] || { left: null, right: null };
1733
+ function Rn(t) {
1734
+ return On[t.value] || { left: null, right: null };
1729
1735
  }
1730
- const Rn = {
1736
+ const Un = {
1731
1737
  "(": { left: 14, right: null }
1732
1738
  };
1733
- function Tt(t) {
1734
- return Rn[t.value] || { left: null, right: null };
1739
+ function bt(t) {
1740
+ return Un[t.value] || { left: null, right: null };
1735
1741
  }
1736
1742
  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) {
1743
+ function Ae(t) {
1738
1744
  var n;
1739
1745
  const e = (n = t == null ? void 0 : t.type) == null ? void 0 : n.value.toLowerCase();
1740
1746
  switch (e) {
@@ -1746,38 +1752,38 @@ function Pe(t) {
1746
1752
  case I.Ref:
1747
1753
  case I.TableGroup:
1748
1754
  case I.TablePartial:
1749
- return new O(e);
1755
+ return new R(e);
1750
1756
  default:
1751
- return new P();
1757
+ return new S();
1752
1758
  }
1753
1759
  }
1754
- function Ie(t) {
1755
- if (!Ye(t))
1756
- 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();
1760
+ function _e(t) {
1761
+ if (!qe(t))
1762
+ return new R([t]);
1763
+ const e = _e(t.leftExpression).unwrap_or(void 0);
1764
+ return e ? (e.push(t.rightExpression), new R(e)) : new S();
1759
1765
  }
1760
1766
  function z(t) {
1761
1767
  if (t === void 0)
1762
- return new P();
1763
- const e = Ie(t).unwrap_or(void 0);
1768
+ return new S();
1769
+ const e = _e(t).unwrap_or(void 0);
1764
1770
  if (!e)
1765
- return new P();
1771
+ return new S();
1766
1772
  const n = [];
1767
1773
  for (const s of e) {
1768
1774
  const i = W(s).unwrap_or(void 0);
1769
1775
  if (!i)
1770
- return new P();
1776
+ return new S();
1771
1777
  n.push(i);
1772
1778
  }
1773
- return new O(n);
1779
+ return new R(n);
1774
1780
  }
1775
- function Se(t) {
1781
+ function Pe(t) {
1776
1782
  if (t === void 0)
1777
- return new P();
1778
- const e = Ie(t).unwrap_or(void 0);
1783
+ return new S();
1784
+ const e = _e(t).unwrap_or(void 0);
1779
1785
  if (!e || e.length === 0)
1780
- return new P();
1786
+ return new S();
1781
1787
  const n = [];
1782
1788
  let s;
1783
1789
  if (!$(_.last(e))) {
@@ -1787,70 +1793,75 @@ function Se(t) {
1787
1793
  (a) => X(a).unwrap()
1788
1794
  );
1789
1795
  else
1790
- return new P();
1796
+ return new S();
1791
1797
  }
1792
1798
  for (const i of e) {
1793
1799
  const a = W(i).unwrap_or(void 0);
1794
1800
  if (!a)
1795
- return new P();
1801
+ return new S();
1796
1802
  n.push(a);
1797
1803
  }
1798
- return new O({
1804
+ return new R({
1799
1805
  variables: n,
1800
1806
  tupleElements: s
1801
1807
  });
1802
1808
  }
1803
1809
  function W(t) {
1804
- return $(t) ? new O(t.expression.variable.value) : new P();
1810
+ return $(t) ? new R(t.expression.variable.value) : new S();
1805
1811
  }
1806
- function Ve(t) {
1807
- if (bt(t))
1808
- return t instanceof ce ? new O({ functional: [t], nonFunctional: [] }) : new O({ functional: [], nonFunctional: [t] });
1809
- if (t instanceof fe && t.elementList.every(bt)) {
1812
+ function Ge(t) {
1813
+ if (It(t))
1814
+ return t instanceof ce ? new R({ functional: [t], nonFunctional: [] }) : new R({ functional: [], nonFunctional: [t] });
1815
+ if (t instanceof fe && t.elementList.every(It)) {
1810
1816
  const e = t.elementList.filter(
1811
1817
  (s) => s instanceof ce
1812
1818
  ), n = t.elementList.filter($);
1813
- return new O({ functional: e, nonFunctional: n });
1819
+ return new R({ functional: e, nonFunctional: n });
1814
1820
  }
1815
- return new P();
1821
+ return new S();
1816
1822
  }
1817
1823
  function X(t) {
1818
1824
  var n;
1819
1825
  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);
1826
+ return e === void 0 ? new S() : new R(e);
1821
1827
  }
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();
1828
+ function Mn(t) {
1829
+ var n, s;
1830
+ const e = (s = (n = t == null ? void 0 : t.partial) == null ? void 0 : n.variable) == null ? void 0 : s.value;
1831
+ return e === void 0 ? new S() : new R(e);
1824
1832
  }
1825
- function Un(t) {
1833
+ function M(t) {
1834
+ return G(t) ? t.expression instanceof ae ? new R(t.expression.variable.value) : new R(t.expression.literal.value) : new S();
1835
+ }
1836
+ function Fn(t) {
1826
1837
  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;
1838
+ return !(t instanceof le) || !Bt((e = t.op) == null ? void 0 : e.value) ? !1 : Pe(t.leftExpression).and_then(() => Pe(t.rightExpression)).unwrap_or(void 0) !== void 0;
1828
1839
  }
1829
- function Mn(t) {
1830
- const e = Se(t.leftExpression), n = Se(t.rightExpression);
1840
+ function Bn(t) {
1841
+ const e = Pe(t.leftExpression), n = Pe(t.rightExpression);
1831
1842
  if (!e.isOk() || !n.isOk())
1832
1843
  return !1;
1833
1844
  const { tupleElements: s } = e.unwrap(), { tupleElements: i } = n.unwrap();
1834
1845
  return (s == null ? void 0 : s.length) === (i == null ? void 0 : i.length);
1835
1846
  }
1836
- function bt(t) {
1837
- return t instanceof G && t.expression instanceof ae || t instanceof ce;
1847
+ function It(t) {
1848
+ return t instanceof j && t.expression instanceof ae || t instanceof ce;
1838
1849
  }
1839
- function It(t, e) {
1850
+ function Lt(t, e) {
1840
1851
  var i, a, r, c;
1841
1852
  let n = e;
1842
1853
  const s = cn(t);
1843
1854
  for (; n; ) {
1844
1855
  if ((a = (i = n.symbol) == null ? void 0 : i.symbolTable) != null && a.has(t))
1845
1856
  return (r = n.symbol.symbolTable) == null ? void 0 : r.get(t);
1846
- if (((c = n.symbol) == null ? void 0 : c.declaration) instanceof K && s)
1857
+ if (((c = n.symbol) == null ? void 0 : c.declaration) instanceof Z && s)
1847
1858
  return n.symbol;
1848
- if (n instanceof K)
1859
+ if (n instanceof Z)
1849
1860
  return;
1850
1861
  n = n.parent;
1851
1862
  }
1852
1863
  }
1853
- class Fn {
1864
+ class Vn {
1854
1865
  constructor(e, n, s) {
1855
1866
  this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
1856
1867
  }
@@ -1858,7 +1869,7 @@ class Fn {
1858
1869
  return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
1859
1870
  }
1860
1871
  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)] : [];
1872
+ return this.declarationNode.parent instanceof Z || Ae(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
1873
  }
1863
1874
  validateName(e) {
1864
1875
  return e ? [new l(o.UNEXPECTED_NAME, "A Custom element shouldn't have a name", e)] : [];
@@ -1875,10 +1886,10 @@ class Fn {
1875
1886
  if (e instanceof re)
1876
1887
  return [new l(o.UNEXPECTED_COMPLEX_BODY, "A Custom element can only have an inline field", e)];
1877
1888
  const n = [];
1878
- 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;
1889
+ return G(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
1890
  }
1880
1891
  }
1881
- class ve {
1892
+ class ye {
1882
1893
  constructor() {
1883
1894
  this.table = /* @__PURE__ */ new Map();
1884
1895
  }
@@ -1898,7 +1909,7 @@ class ve {
1898
1909
  return this.table.forEach(e);
1899
1910
  }
1900
1911
  }
1901
- class Bn {
1912
+ class Gn {
1902
1913
  constructor(e, n, s) {
1903
1914
  this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
1904
1915
  }
@@ -1916,10 +1927,10 @@ class Bn {
1916
1927
  }
1917
1928
  registerElement() {
1918
1929
  const e = [];
1919
- this.declarationNode.symbol = this.symbolFactory.create(En, { declaration: this.declarationNode, symbolTable: new ve() });
1930
+ this.declarationNode.symbol = this.symbolFactory.create(pn, { declaration: this.declarationNode, symbolTable: new ye() });
1920
1931
  const { name: n } = this.declarationNode, s = z(n);
1921
1932
  if (s.isOk()) {
1922
- const i = s.unwrap(), a = i.pop(), r = qe(i, this.publicSymbolTable, this.symbolFactory), c = st(a);
1933
+ const i = s.unwrap(), a = i.pop(), r = ze(i, this.publicSymbolTable, this.symbolFactory), c = nt(a);
1923
1934
  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
1935
  }
1925
1936
  return e;
@@ -1930,9 +1941,9 @@ class Bn {
1930
1941
  validateBody(e) {
1931
1942
  if (!e)
1932
1943
  return [];
1933
- if (e instanceof w)
1944
+ if (e instanceof v)
1934
1945
  return this.validateFields([e]);
1935
- const [n, s] = _.partition(e.body, (i) => i instanceof w);
1946
+ const [n, s] = _.partition(e.body, (i) => i instanceof v);
1936
1947
  return [...this.validateFields(n), ...this.validateSubElements(s)];
1937
1948
  }
1938
1949
  validateFields(e) {
@@ -1940,7 +1951,7 @@ class Bn {
1940
1951
  const s = [];
1941
1952
  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));
1942
1953
  const i = [...n.args];
1943
- 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;
1954
+ return _.last(i) instanceof U ? (s.push(...this.validateFieldSettings(_.last(i))), i.pop()) : i[0] instanceof U && (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
1955
  });
1945
1956
  }
1946
1957
  validateFieldSettings(e) {
@@ -1950,7 +1961,7 @@ class Bn {
1950
1961
  switch (a) {
1951
1962
  case "note":
1952
1963
  r.length > 1 && r.forEach((c) => s.push(new l(o.DUPLICATE_ENUM_ELEMENT_SETTING, "'note' can only appear once", c))), r.forEach((c) => {
1953
- C(c.value) || s.push(new l(o.INVALID_ENUM_ELEMENT_SETTING, "'note' must be a string", c));
1964
+ G(c.value) || s.push(new l(o.INVALID_ENUM_ELEMENT_SETTING, "'note' must be a string", c));
1954
1965
  });
1955
1966
  break;
1956
1967
  default:
@@ -1969,7 +1980,7 @@ class Bn {
1969
1980
  }
1970
1981
  registerField(e) {
1971
1982
  if (e.callee && $(e.callee)) {
1972
- const n = X(e.callee).unwrap(), s = it(n), i = this.symbolFactory.create(Nn, { declaration: e });
1983
+ const n = X(e.callee).unwrap(), s = st(n), i = this.symbolFactory.create(dn, { declaration: e });
1973
1984
  e.symbol = i;
1974
1985
  const a = this.declarationNode.symbol.symbolTable;
1975
1986
  if (a.has(s)) {
@@ -1984,7 +1995,7 @@ class Bn {
1984
1995
  return [];
1985
1996
  }
1986
1997
  }
1987
- class Vn {
1998
+ class Cn {
1988
1999
  constructor(e, n, s) {
1989
2000
  this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
1990
2001
  }
@@ -1992,13 +2003,13 @@ class Vn {
1992
2003
  return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
1993
2004
  }
1994
2005
  validateContext() {
1995
- if (this.declarationNode.parent instanceof K)
2006
+ if (this.declarationNode.parent instanceof Z)
1996
2007
  return [new l(
1997
2008
  o.INVALID_NOTE_CONTEXT,
1998
2009
  "An Indexes can only appear inside a Table or a TablePartial",
1999
2010
  this.declarationNode
2000
2011
  )];
2001
- const e = Pe(this.declarationNode.parent).unwrap_or(void 0);
2012
+ const e = Ae(this.declarationNode.parent).unwrap_or(void 0);
2002
2013
  return e && [I.Table, I.TablePartial].includes(e) ? [] : [new l(
2003
2014
  o.INVALID_NOTE_CONTEXT,
2004
2015
  "An Indexes can only appear inside a Table or a TablePartial",
@@ -2017,9 +2028,9 @@ class Vn {
2017
2028
  validateBody(e) {
2018
2029
  if (!e)
2019
2030
  return [];
2020
- if (e instanceof w)
2031
+ if (e instanceof v)
2021
2032
  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);
2033
+ const [n, s] = _.partition(e.body, (i) => i instanceof v);
2023
2034
  return [...this.validateFields(n), ...this.validateSubElements(s)];
2024
2035
  }
2025
2036
  validateFields(e) {
@@ -2027,10 +2038,10 @@ class Vn {
2027
2038
  if (!n.callee)
2028
2039
  return [];
2029
2040
  const s = [], i = [n.callee, ...n.args];
2030
- return _.last(i) instanceof R && s.push(...this.validateFieldSetting(i.pop())), i.forEach((a) => {
2041
+ return _.last(i) instanceof U && s.push(...this.validateFieldSetting(i.pop())), i.forEach((a) => {
2031
2042
  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));
2043
+ 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;
2044
+ 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
2045
  }), s;
2035
2046
  });
2036
2047
  }
@@ -2042,7 +2053,7 @@ class Vn {
2042
2053
  case "note":
2043
2054
  case "name":
2044
2055
  r.length > 1 && r.forEach((c) => s.push(new l(o.DUPLICATE_INDEX_SETTING, `'${a}' can only appear once`, c))), r.forEach((c) => {
2045
- C(c.value) || s.push(new l(o.INVALID_INDEX_SETTING_VALUE, `'${a}' must be a string`, c));
2056
+ G(c.value) || s.push(new l(o.INVALID_INDEX_SETTING_VALUE, `'${a}' must be a string`, c));
2046
2057
  });
2047
2058
  break;
2048
2059
  case "unique":
@@ -2071,7 +2082,7 @@ class Vn {
2071
2082
  });
2072
2083
  }
2073
2084
  }
2074
- class Gn {
2085
+ class Xn {
2075
2086
  constructor(e, n, s) {
2076
2087
  this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
2077
2088
  }
@@ -2085,26 +2096,26 @@ class Gn {
2085
2096
  ];
2086
2097
  }
2087
2098
  validateContext() {
2088
- return !(this.declarationNode.parent instanceof K) && ![
2099
+ return !(this.declarationNode.parent instanceof Z) && ![
2089
2100
  I.Table,
2090
2101
  I.TableGroup,
2091
2102
  I.TablePartial,
2092
2103
  I.Project
2093
- ].includes(Pe(this.declarationNode.parent).unwrap_or(void 0)) ? [new l(
2104
+ ].includes(Ae(this.declarationNode.parent).unwrap_or(void 0)) ? [new l(
2094
2105
  o.INVALID_NOTE_CONTEXT,
2095
2106
  "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
2107
  this.declarationNode
2097
2108
  )] : [];
2098
2109
  }
2099
2110
  validateName(e) {
2100
- if (!(this.declarationNode.parent instanceof K))
2111
+ if (!(this.declarationNode.parent instanceof Z))
2101
2112
  return e ? [new l(o.UNEXPECTED_NAME, "A Note shouldn't have a name", e)] : [];
2102
2113
  if (!e)
2103
2114
  return [new l(o.INVALID_NAME, "Sticky note must have a name", this.declarationNode)];
2104
2115
  const n = z(e);
2105
2116
  if (!n.isOk())
2106
2117
  return [new l(o.INVALID_NAME, "Invalid name for sticky note ", this.declarationNode)];
2107
- const i = n.unwrap().join("."), a = on(i);
2118
+ const i = n.unwrap().join("."), a = ln(i);
2108
2119
  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
2120
  }
2110
2121
  validateAlias(e) {
@@ -2116,14 +2127,14 @@ class Gn {
2116
2127
  validateBody(e) {
2117
2128
  if (!e)
2118
2129
  return [];
2119
- if (e instanceof w)
2130
+ if (e instanceof v)
2120
2131
  return this.validateFields([e]);
2121
- const [n, s] = _.partition(e.body, (i) => i instanceof w);
2132
+ const [n, s] = _.partition(e.body, (i) => i instanceof v);
2122
2133
  return [...this.validateFields(n), ...this.validateSubElements(s)];
2123
2134
  }
2124
2135
  validateFields(e) {
2125
2136
  const n = [];
2126
- return e.length === 0 ? [new l(o.EMPTY_NOTE, "A Note must have a content", this.declarationNode)] : (e.length > 1 && e.slice(1).forEach((s) => n.push(new l(o.NOTE_CONTENT_REDEFINED, "A Note can only contain one string", s))), C(e[0].callee) || n.push(new l(o.INVALID_NOTE, "A Note content must be a quoted string", e[0])), e[0].args.length > 0 && n.push(...e[0].args.map((s) => new l(o.INVALID_NOTE, "A Note can only contain one quoted string", s))), n);
2137
+ return e.length === 0 ? [new l(o.EMPTY_NOTE, "A Note must have a content", this.declarationNode)] : (e.length > 1 && e.slice(1).forEach((s) => n.push(new l(o.NOTE_CONTENT_REDEFINED, "A Note can only contain one string", s))), G(e[0].callee) || n.push(new l(o.INVALID_NOTE, "A Note content must be a quoted string", e[0])), e[0].args.length > 0 && n.push(...e[0].args.map((s) => new l(o.INVALID_NOTE, "A Note can only contain one quoted string", s))), n);
2127
2138
  }
2128
2139
  validateSubElements(e) {
2129
2140
  return e.flatMap((n) => {
@@ -2134,7 +2145,7 @@ class Gn {
2134
2145
  });
2135
2146
  }
2136
2147
  }
2137
- class Cn {
2148
+ class jn {
2138
2149
  constructor(e, n, s) {
2139
2150
  this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
2140
2151
  }
@@ -2145,7 +2156,7 @@ class Cn {
2145
2156
  return this.declarationNode.parent instanceof y ? [new l(o.INVALID_PROJECT_CONTEXT, "A Project can only appear top-level", this.declarationNode)] : [];
2146
2157
  }
2147
2158
  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)] : [];
2159
+ return e ? ke(e) ? [] : [new l(o.INVALID_NAME, "A Project's name is optional or must be an identifier or a quoted identifer", e)] : [];
2149
2160
  }
2150
2161
  validateAlias(e) {
2151
2162
  return e ? [new l(o.UNEXPECTED_ALIAS, "A Project shouldn't have an alias", e)] : [];
@@ -2156,9 +2167,9 @@ class Cn {
2156
2167
  validateBody(e) {
2157
2168
  if (!e)
2158
2169
  return [];
2159
- if (e instanceof w)
2170
+ if (e instanceof v)
2160
2171
  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);
2172
+ const [n, s] = _.partition(e.body, (i) => i instanceof v);
2162
2173
  return [
2163
2174
  ...n.map((i) => new l(o.INVALID_PROJECT_FIELD, "A Project can not have inline fields", i)),
2164
2175
  ...this.validateSubElements(s)
@@ -2173,7 +2184,7 @@ class Cn {
2173
2184
  });
2174
2185
  }
2175
2186
  }
2176
- class Xn {
2187
+ class $n {
2177
2188
  constructor(e, n, s) {
2178
2189
  this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
2179
2190
  }
@@ -2181,10 +2192,10 @@ class Xn {
2181
2192
  return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
2182
2193
  }
2183
2194
  validateContext() {
2184
- return this.declarationNode.parent instanceof K ? [] : [new l(o.INVALID_REF_CONTEXT, "A Ref must appear top-level", this.declarationNode)];
2195
+ return this.declarationNode.parent instanceof Z ? [] : [new l(o.INVALID_REF_CONTEXT, "A Ref must appear top-level", this.declarationNode)];
2185
2196
  }
2186
2197
  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)] : [];
2198
+ return e ? ke(e) ? [] : [new l(o.INVALID_NAME, "A Ref's name is optional or must be an identifier or a quoted identifer", e)] : [];
2188
2199
  }
2189
2200
  validateAlias(e) {
2190
2201
  return e ? [new l(o.UNEXPECTED_ALIAS, "A Ref shouldn't have an alias", e)] : [];
@@ -2195,9 +2206,9 @@ class Xn {
2195
2206
  validateBody(e) {
2196
2207
  if (!e)
2197
2208
  return [];
2198
- if (e instanceof w)
2209
+ if (e instanceof v)
2199
2210
  return this.validateFields([e]);
2200
- const [n, s] = _.partition(e.body, (i) => i instanceof w);
2211
+ const [n, s] = _.partition(e.body, (i) => i instanceof v);
2201
2212
  return [...this.validateFields(n), ...this.validateSubElements(s)];
2202
2213
  }
2203
2214
  validateFields(e) {
@@ -2205,13 +2216,13 @@ class Xn {
2205
2216
  return [new l(o.EMPTY_REF, "A Ref must have at least one field", this.declarationNode)];
2206
2217
  const n = [];
2207
2218
  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));
2219
+ s.callee && !Fn(s.callee) && n.push(new l(o.INVALID_REF_FIELD, "A Ref field must be a binary relationship", s.callee)), s.callee && !Bn(s.callee) && n.push(new l(o.UNEQUAL_FIELDS_BINARY_REF, "Unequal fields in ref endpoints", s.callee));
2209
2220
  const i = [...s.args];
2210
- if (_.last(i) instanceof R) {
2221
+ if (_.last(i) instanceof U) {
2211
2222
  const a = this.validateFieldSettings(_.last(i));
2212
2223
  n.push(...a), i.pop();
2213
2224
  } else
2214
- i[0] instanceof R && (n.push(...this.validateFieldSettings(i[0])), i.shift());
2225
+ i[0] instanceof U && (n.push(...this.validateFieldSettings(i[0])), i.shift());
2215
2226
  i.length > 0 && n.push(...i.map((a) => new l(o.INVALID_REF_FIELD, "A Ref field should only have a single binary relationship", a)));
2216
2227
  }), n;
2217
2228
  }
@@ -2223,12 +2234,12 @@ class Xn {
2223
2234
  case "delete":
2224
2235
  case "update":
2225
2236
  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));
2237
+ Wn(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
2238
  });
2228
2239
  break;
2229
2240
  case "color":
2230
2241
  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));
2242
+ Qe(c.value) || s.push(new l(o.INVALID_REF_SETTING_VALUE, "'color' must be a color literal", c));
2232
2243
  });
2233
2244
  break;
2234
2245
  default:
@@ -2246,11 +2257,11 @@ class Xn {
2246
2257
  });
2247
2258
  }
2248
2259
  }
2249
- function $n(t) {
2250
- if (!($(t) && t.expression.variable.kind !== h.QUOTED_STRING) && !(t instanceof ne))
2260
+ function Wn(t) {
2261
+ if (!($(t) && t.expression.variable.kind !== h.QUOTED_STRING) && !(t instanceof te))
2251
2262
  return !1;
2252
2263
  let e;
2253
- if (t instanceof ne ? e = Ae(t).unwrap_or("") : e = t.expression.variable.value, e)
2264
+ if (t instanceof te ? e = ve(t).unwrap_or("") : e = t.expression.variable.value, e)
2254
2265
  switch (e.toLowerCase()) {
2255
2266
  case "cascade":
2256
2267
  case "no action":
@@ -2263,7 +2274,7 @@ function $n(t) {
2263
2274
  }
2264
2275
  return !1;
2265
2276
  }
2266
- class jn {
2277
+ class Yn {
2267
2278
  constructor(e, n, s) {
2268
2279
  this.declarationNode = e, this.symbolFactory = s, this.publicSymbolTable = n;
2269
2280
  }
@@ -2277,7 +2288,7 @@ class jn {
2277
2288
  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)];
2278
2289
  }
2279
2290
  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)] : [];
2291
+ return e ? Zn(e) ? [] : [new l(o.INVALID_ALIAS, "Table aliases can only contains alphanumeric and underscore unless surrounded by double quotes", e)] : [];
2281
2292
  }
2282
2293
  validateSettingList(e) {
2283
2294
  const n = F(e), s = n.getErrors(), i = n.getValue();
@@ -2286,12 +2297,12 @@ class jn {
2286
2297
  switch (a) {
2287
2298
  case "headercolor":
2288
2299
  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));
2300
+ Qe(c.value) || s.push(new l(o.INVALID_TABLE_SETTING, "'headercolor' must be a color literal", c.value || c.name));
2290
2301
  });
2291
2302
  break;
2292
2303
  case "note":
2293
2304
  r.length > 1 && s.push(...r.map((c) => new l(o.DUPLICATE_TABLE_SETTING, "'note' can only appear once", c))), r.forEach((c) => {
2294
- C(c.value) || s.push(new l(o.INVALID_TABLE_SETTING, "'note' must be a string literal", c.value || c.name));
2305
+ G(c.value) || s.push(new l(o.INVALID_TABLE_SETTING, "'note' must be a string literal", c.value || c.name));
2295
2306
  });
2296
2307
  break;
2297
2308
  default:
@@ -2302,14 +2313,14 @@ class jn {
2302
2313
  }
2303
2314
  registerElement() {
2304
2315
  const e = [];
2305
- this.declarationNode.symbol = this.symbolFactory.create(Rt, { declaration: this.declarationNode, symbolTable: new ve() });
2316
+ this.declarationNode.symbol = this.symbolFactory.create(Ut, { declaration: this.declarationNode, symbolTable: new ye() });
2306
2317
  const { name: n, alias: s } = this.declarationNode, i = z(n);
2307
2318
  if (i.isOk()) {
2308
- const a = [...i.unwrap()], r = a.pop(), c = qe(a, this.publicSymbolTable, this.symbolFactory), f = Fe(r);
2319
+ const a = [...i.unwrap()], r = a.pop(), c = ze(a, this.publicSymbolTable, this.symbolFactory), f = Be(r);
2309
2320
  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
2321
  }
2311
- if (s && we(s) && !Yn(s.expression.variable.value, i.unwrap_or([]))) {
2312
- const a = X(s).unwrap(), r = Fe(a);
2322
+ if (s && ke(s) && !zn(s.expression.variable.value, i.unwrap_or([]))) {
2323
+ const a = X(s).unwrap(), r = Be(a);
2313
2324
  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
2325
  }
2315
2326
  return e;
@@ -2317,52 +2328,46 @@ class jn {
2317
2328
  validateBody(e) {
2318
2329
  if (!e)
2319
2330
  return [];
2320
- if (e instanceof w)
2331
+ if (e instanceof v)
2321
2332
  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);
2333
+ const [n, s, i] = e.body.reduce((a, r) => (r instanceof v ? a[0].push(r) : r instanceof Le ? a[1].push(r) : r instanceof y && a[2].push(r), a), [[], [], []]);
2323
2334
  return [
2324
2335
  ...this.validateFields(n),
2325
- ...this.validateInjections(i),
2326
- ...this.validateSubElements(a)
2327
- ];
2328
- }
2329
- 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), [[], [], []]);
2331
- return [
2332
- ...i,
2333
- ...this.validateColumns(n),
2334
- ...this.validateInjections(s)
2336
+ ...this.validateInjections(s),
2337
+ ...this.validateSubElements(i)
2335
2338
  ];
2336
2339
  }
2337
2340
  validateInjections(e) {
2338
2341
  return e.flatMap((n) => this.registerInjection(n));
2339
2342
  }
2340
2343
  registerInjection(e) {
2341
- var n, s;
2342
- 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 });
2344
- e.symbol = r;
2345
- const c = this.declarationNode.symbol.symbolTable, f = c.get(a);
2346
- if (f)
2344
+ var n, s, i;
2345
+ if ((s = (n = e.partial) == null ? void 0 : n.variable) != null && s.value) {
2346
+ const a = (i = e.partial.variable) == null ? void 0 : i.value, r = Ot(a), c = this.symbolFactory.create(Tn, { declaration: e });
2347
+ e.symbol = c;
2348
+ const f = this.declarationNode.symbol.symbolTable, p = f.get(r);
2349
+ if (p)
2347
2350
  return [
2348
- new l(o.DUPLICATE_TABLE_PARTIAL_INJECTION_NAME, `Duplicate injection ${i}`, e),
2349
- new l(o.DUPLICATE_TABLE_PARTIAL_INJECTION_NAME, `Duplicate injection ${i}`, f.declaration)
2351
+ new l(o.DUPLICATE_TABLE_PARTIAL_INJECTION_NAME, `Duplicate injection ${a}`, e),
2352
+ new l(o.DUPLICATE_TABLE_PARTIAL_INJECTION_NAME, `Duplicate injection ${a}`, p.declaration)
2350
2353
  ];
2351
- c.set(a, r);
2354
+ f.set(r, c);
2352
2355
  }
2353
2356
  return [];
2354
2357
  }
2355
- validateColumns(e) {
2358
+ validateFields(e) {
2356
2359
  return e.length === 0 ? [new l(o.EMPTY_TABLE, "A Table must have at least one column", this.declarationNode)] : e.flatMap((n) => {
2360
+ if (!n.callee)
2361
+ return [];
2357
2362
  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]));
2363
+ 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] && !qn(n.args[0]) && s.push(new l(o.INVALID_COLUMN_TYPE, "Invalid column type", n.args[0]));
2359
2364
  const i = n.args.slice(1);
2360
- return s.push(...this.validateColumnSetting(i)), s.push(...this.registerColumn(n)), s;
2365
+ return s.push(...this.validateFieldSetting(i)), s.push(...this.registerField(n)), s;
2361
2366
  });
2362
2367
  }
2363
- registerColumn(e) {
2368
+ registerField(e) {
2364
2369
  if (e.callee && $(e.callee)) {
2365
- const n = X(e.callee).unwrap(), s = je(n), i = this.symbolFactory.create(Ut, { declaration: e });
2370
+ const n = X(e.callee).unwrap(), s = We(n), i = this.symbolFactory.create(ot, { declaration: e });
2366
2371
  e.symbol = i;
2367
2372
  const a = this.declarationNode.symbol.symbolTable;
2368
2373
  if (a.has(s)) {
@@ -2377,13 +2382,13 @@ class jn {
2377
2382
  return [];
2378
2383
  }
2379
2384
  // This is needed to support legacy inline settings
2380
- validateColumnSetting(e) {
2381
- if (!e.slice(0, -1).every(he) || !e.slice(-1).every((f) => he(f) || f instanceof R))
2385
+ validateFieldSetting(e) {
2386
+ if (!e.slice(0, -1).every(he) || !e.slice(-1).every((f) => he(f) || f instanceof U))
2382
2387
  return [...e.map((f) => new l(o.INVALID_COLUMN, "These fields must be some inline settings optionally ended with a setting list", f))];
2383
2388
  if (e.length === 0)
2384
2389
  return [];
2385
2390
  let n;
2386
- _.last(e) instanceof R && (n = e.pop());
2391
+ _.last(e) instanceof U && (n = e.pop());
2387
2392
  const s = F(n), i = s.getErrors(), a = s.getValue();
2388
2393
  for (const f of e) {
2389
2394
  const p = X(f).unwrap_or("").toLowerCase();
@@ -2400,7 +2405,7 @@ class jn {
2400
2405
  switch (f) {
2401
2406
  case "note":
2402
2407
  p.length > 1 && i.push(...p.map((u) => new l(o.DUPLICATE_COLUMN_SETTING, "note can only appear once", u))), p.forEach((u) => {
2403
- C(u.value) || i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'note' must be a quoted string", u.value || u.name));
2408
+ G(u.value) || i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'note' must be a quoted string", u.value || u.name));
2404
2409
  });
2405
2410
  break;
2406
2411
  case "ref":
@@ -2415,7 +2420,7 @@ class jn {
2415
2420
  break;
2416
2421
  case "pk":
2417
2422
  p.length > 1 && i.push(...p.map((u) => new l(o.DUPLICATE_COLUMN_SETTING, "'pk' can only appear once", u))), p.forEach((u) => {
2418
- u instanceof se && !H(u.value) && i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'pk' must not have a value", u.value || u.name));
2423
+ u instanceof ne && !H(u.value) && i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'pk' must not have a value", u.value || u.name));
2419
2424
  });
2420
2425
  break;
2421
2426
  case "not null":
@@ -2432,12 +2437,12 @@ class jn {
2432
2437
  break;
2433
2438
  case "unique":
2434
2439
  p.length > 1 && i.push(...p.map((u) => new l(o.DUPLICATE_COLUMN_SETTING, "'unique' can only appear once", u))), p.forEach((u) => {
2435
- u instanceof se && !H(u.value) && i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'unique' must not have a value", u.value || u.name));
2440
+ u instanceof ne && !H(u.value) && i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'unique' must not have a value", u.value || u.name));
2436
2441
  });
2437
2442
  break;
2438
2443
  case "increment":
2439
2444
  p.length > 1 && i.push(...p.map((u) => new l(o.DUPLICATE_COLUMN_SETTING, "'increment' can only appear once", u))), p.forEach((u) => {
2440
- u instanceof se && !H(u.value) && i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'increment' must not have a value", u.value || u.name));
2445
+ u instanceof ne && !H(u.value) && i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'increment' must not have a value", u.value || u.name));
2441
2446
  });
2442
2447
  break;
2443
2448
  case "default":
@@ -2453,39 +2458,37 @@ class jn {
2453
2458
  }
2454
2459
  validateSubElements(e) {
2455
2460
  const n = e.flatMap((i) => {
2456
- if (!i)
2457
- return [];
2458
2461
  if (i.parent = this.declarationNode, !i.type)
2459
2462
  return [];
2460
2463
  const a = pe(i);
2461
2464
  return new a(i, this.publicSymbolTable, this.symbolFactory).validate();
2462
2465
  }), s = e.filter((i) => {
2463
2466
  var a;
2464
- return ((a = i == null ? void 0 : i.type) == null ? void 0 : a.value.toLowerCase()) === "note";
2467
+ return ((a = i.type) == null ? void 0 : a.value.toLowerCase()) === "note";
2465
2468
  });
2466
2469
  return s.length > 1 && n.push(...s.map((i) => new l(o.NOTE_REDEFINED, "Duplicate notes are defined", i))), n;
2467
2470
  }
2468
2471
  }
2469
- function Wn(t) {
2470
- if (!(t instanceof Y || Ye(t) || t instanceof G || t instanceof ue))
2472
+ function qn(t) {
2473
+ if (!(t instanceof Y || qe(t) || t instanceof j || t instanceof ue))
2471
2474
  return !1;
2472
2475
  if (t instanceof Y) {
2473
- if (t.callee === void 0 || t.argumentList === void 0 || !t.argumentList.elementList.every((n) => ee(n) || C(n) || he(n)))
2476
+ if (t.callee === void 0 || t.argumentList === void 0 || !t.argumentList.elementList.every((n) => K(n) || G(n) || he(n)))
2474
2477
  return !1;
2475
2478
  t = t.callee;
2476
2479
  }
2477
2480
  for (; t instanceof ue; ) {
2478
- if (t.array === void 0 || t.indexer === void 0 || !t.indexer.elementList.every((n) => !n.colon && !n.value && ee(n.name)))
2481
+ if (t.array === void 0 || t.indexer === void 0 || !t.indexer.elementList.every((n) => !n.colon && !n.value && K(n.name)))
2479
2482
  return !1;
2480
2483
  t = t.array;
2481
2484
  }
2482
2485
  const e = z(t).unwrap_or(void 0);
2483
2486
  return e !== void 0 && e.length > 0;
2484
2487
  }
2485
- function Yn(t, e) {
2488
+ function zn(t, e) {
2486
2489
  return e.length === 1 && t === e[0];
2487
2490
  }
2488
- class qn {
2491
+ class Qn {
2489
2492
  constructor(e, n, s) {
2490
2493
  this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
2491
2494
  }
@@ -2507,7 +2510,7 @@ class qn {
2507
2510
  )] : [];
2508
2511
  }
2509
2512
  validateName(e) {
2510
- return e ? we(e) ? [] : [new l(
2513
+ return e ? ke(e) ? [] : [new l(
2511
2514
  o.INVALID_NAME,
2512
2515
  "A TableGroup name must be a single identifier",
2513
2516
  e
@@ -2526,10 +2529,10 @@ class qn {
2526
2529
  }
2527
2530
  registerElement() {
2528
2531
  const { name: e } = this.declarationNode;
2529
- this.declarationNode.symbol = this.symbolFactory.create(mn, { declaration: this.declarationNode, symbolTable: new ve() });
2532
+ this.declarationNode.symbol = this.symbolFactory.create(En, { declaration: this.declarationNode, symbolTable: new ye() });
2530
2533
  const n = z(e);
2531
2534
  if (n.isOk()) {
2532
- const s = n.unwrap(), i = s.pop(), a = qe(s, this.publicSymbolTable, this.symbolFactory), r = at(i);
2535
+ const s = n.unwrap(), i = s.pop(), a = ze(s, this.publicSymbolTable, this.symbolFactory), r = it(i);
2533
2536
  if (a.has(r))
2534
2537
  return [new l(o.DUPLICATE_NAME, `TableGroup name '${i}' already exists`, e)];
2535
2538
  a.set(r, this.declarationNode.symbol);
@@ -2546,7 +2549,7 @@ class qn {
2546
2549
  "'color' can only appear once",
2547
2550
  c
2548
2551
  ))), a.forEach((c) => {
2549
- ze(c.value) || s.push(new l(
2552
+ Qe(c.value) || s.push(new l(
2550
2553
  o.INVALID_TABLE_SETTING,
2551
2554
  "'color' must be a color literal",
2552
2555
  c.value || c.name
@@ -2558,7 +2561,7 @@ class qn {
2558
2561
  o.DUPLICATE_TABLE_SETTING,
2559
2562
  "'note' can only appear once",
2560
2563
  c
2561
- ))), a.filter((c) => !C(c.value)).forEach((c) => {
2564
+ ))), a.filter((c) => !G(c.value)).forEach((c) => {
2562
2565
  s.push(new l(
2563
2566
  o.INVALID_TABLE_SETTING,
2564
2567
  "'note' must be a string literal",
@@ -2579,13 +2582,13 @@ class qn {
2579
2582
  validateBody(e) {
2580
2583
  if (!e)
2581
2584
  return [];
2582
- if (e instanceof w)
2585
+ if (e instanceof v)
2583
2586
  return [new l(
2584
2587
  o.UNEXPECTED_SIMPLE_BODY,
2585
2588
  "A TableGroup's body must be a block",
2586
2589
  e
2587
2590
  )];
2588
- const [n, s] = _.partition(e.body, (i) => i instanceof w);
2591
+ const [n, s] = _.partition(e.body, (i) => i instanceof v);
2589
2592
  return [
2590
2593
  ...this.validateFields(n),
2591
2594
  ...this.validateSubElements(s)
@@ -2611,7 +2614,7 @@ class qn {
2611
2614
  }
2612
2615
  registerField(e) {
2613
2616
  if (e.callee && $(e.callee)) {
2614
- const n = X(e.callee).unwrap(), s = rt(n), i = this.symbolFactory.create(Tn, { declaration: e });
2617
+ const n = X(e.callee).unwrap(), s = at(n), i = this.symbolFactory.create(Nn, { declaration: e });
2615
2618
  e.symbol = i;
2616
2619
  const a = this.declarationNode.symbol.symbolTable;
2617
2620
  if (a.has(s)) {
@@ -2626,24 +2629,24 @@ class qn {
2626
2629
  return [];
2627
2630
  }
2628
2631
  }
2629
- const ot = ["-", "+"];
2630
- function zn(t) {
2631
- if (!(t instanceof Y || Ye(t) || t instanceof G || t instanceof ue))
2632
+ const lt = ["-", "+"];
2633
+ function Hn(t) {
2634
+ if (!(t instanceof Y || qe(t) || t instanceof j || t instanceof ue))
2632
2635
  return !1;
2633
2636
  if (t instanceof Y) {
2634
- if (t.callee === void 0 || t.argumentList === void 0 || !t.argumentList.elementList.every((n) => ee(n) || C(n) || he(n)))
2637
+ if (t.callee === void 0 || t.argumentList === void 0 || !t.argumentList.elementList.every((n) => K(n) || G(n) || he(n)))
2635
2638
  return !1;
2636
2639
  t = t.callee;
2637
2640
  }
2638
2641
  for (; t instanceof ue; ) {
2639
- if (t.array === void 0 || t.indexer === void 0 || !t.indexer.elementList.every((n) => !n.colon && !n.value && ee(n.name)))
2642
+ if (t.array === void 0 || t.indexer === void 0 || !t.indexer.elementList.every((n) => !n.colon && !n.value && K(n.name)))
2640
2643
  return !1;
2641
2644
  t = t.array;
2642
2645
  }
2643
2646
  const e = z(t).unwrap_or(void 0);
2644
2647
  return e !== void 0 && e.length > 0;
2645
2648
  }
2646
- class Qn {
2649
+ class Jn {
2647
2650
  constructor(e, n, s) {
2648
2651
  this.declarationNode = e, this.symbolFactory = s, this.publicSymbolTable = n;
2649
2652
  }
@@ -2665,7 +2668,7 @@ class Qn {
2665
2668
  )] : [];
2666
2669
  }
2667
2670
  validateName(e) {
2668
- return e ? we(e) ? [] : [new l(
2671
+ return e ? ke(e) ? [] : [new l(
2669
2672
  o.INVALID_NAME,
2670
2673
  "A TablePartial name must be an identifier or a quoted identifer",
2671
2674
  e
@@ -2684,16 +2687,16 @@ class Qn {
2684
2687
  }
2685
2688
  validateSettingList(e) {
2686
2689
  const n = F(e), s = n.getErrors(), i = n.getValue();
2687
- return ft(i, (a, r) => {
2690
+ return pt(i, (a, r) => {
2688
2691
  switch (r) {
2689
2692
  case "headercolor":
2690
2693
  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));
2694
+ Qe(c.value) || s.push(new l(o.INVALID_TABLE_PARTIAL_SETTING, "'headercolor' must be a color literal", c.value || c.name));
2692
2695
  });
2693
2696
  break;
2694
2697
  case "note":
2695
2698
  a.length > 1 && s.push(...a.map((c) => new l(o.DUPLICATE_TABLE_PARTIAL_SETTING, "'note' can only appear once", c))), a.forEach((c) => {
2696
- C(c.value) || s.push(new l(o.INVALID_TABLE_PARTIAL_SETTING, "'note' must be a string literal", c.value || c.name));
2699
+ G(c.value) || s.push(new l(o.INVALID_TABLE_PARTIAL_SETTING, "'note' must be a string literal", c.value || c.name));
2697
2700
  });
2698
2701
  break;
2699
2702
  default:
@@ -2703,10 +2706,10 @@ class Qn {
2703
2706
  }
2704
2707
  registerElement() {
2705
2708
  const { name: e } = this.declarationNode;
2706
- this.declarationNode.symbol = this.symbolFactory.create(bn, { declaration: this.declarationNode, symbolTable: new ve() });
2709
+ this.declarationNode.symbol = this.symbolFactory.create(mn, { declaration: this.declarationNode, symbolTable: new ye() });
2707
2710
  const n = z(e);
2708
2711
  if (n.isOk()) {
2709
- const s = n.unwrap(), i = s.pop(), a = qe(s, this.publicSymbolTable, this.symbolFactory), r = Dt(i);
2712
+ const s = n.unwrap(), i = s.pop(), a = ze(s, this.publicSymbolTable, this.symbolFactory), r = rt(i);
2710
2713
  if (a.has(r))
2711
2714
  return [new l(o.DUPLICATE_NAME, `TablePartial name '${i}' already exists`, e)];
2712
2715
  a.set(r, this.declarationNode.symbol);
@@ -2716,9 +2719,9 @@ class Qn {
2716
2719
  validateBody(e) {
2717
2720
  if (!e)
2718
2721
  return [];
2719
- if (e instanceof w)
2722
+ if (e instanceof v)
2720
2723
  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);
2724
+ const [n, s] = _.partition(e.body, (i) => i instanceof v);
2722
2725
  return [...this.validateFields(n), ...this.validateSubElements(s)];
2723
2726
  }
2724
2727
  validateFields(e) {
@@ -2726,14 +2729,14 @@ class Qn {
2726
2729
  if (!n.callee)
2727
2730
  return [];
2728
2731
  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]));
2732
+ 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] && !Hn(n.args[0]) && s.push(new l(o.INVALID_COLUMN_TYPE, "Invalid column type", n.args[0]));
2730
2733
  const i = n.args.slice(1);
2731
2734
  return s.push(...this.validateFieldSetting(i)), s.push(...this.registerField(n)), s;
2732
2735
  });
2733
2736
  }
2734
2737
  registerField(e) {
2735
2738
  if (e.callee && $(e.callee)) {
2736
- const n = X(e.callee).unwrap(), s = je(n), i = this.symbolFactory.create(Ut, { declaration: e });
2739
+ const n = X(e.callee).unwrap(), s = We(n), i = this.symbolFactory.create(ot, { declaration: e });
2737
2740
  e.symbol = i;
2738
2741
  const a = this.declarationNode.symbol.symbolTable;
2739
2742
  if (a.has(s)) {
@@ -2749,12 +2752,12 @@ class Qn {
2749
2752
  }
2750
2753
  // This is needed to support legacy inline settings
2751
2754
  validateFieldSetting(e) {
2752
- if (!e.slice(0, -1).every(he) || !e.slice(-1).every((f) => he(f) || f instanceof R))
2755
+ if (!e.slice(0, -1).every(he) || !e.slice(-1).every((f) => he(f) || f instanceof U))
2753
2756
  return [...e.map((f) => new l(o.INVALID_COLUMN, "These fields must be some inline settings optionally ended with a setting list", f))];
2754
2757
  if (e.length === 0)
2755
2758
  return [];
2756
2759
  let n;
2757
- _.last(e) instanceof R && (n = e.pop());
2760
+ _.last(e) instanceof U && (n = e.pop());
2758
2761
  const s = F(n), i = s.getErrors(), a = s.getValue();
2759
2762
  e.forEach((f) => {
2760
2763
  const p = X(f).unwrap_or("").toLowerCase();
@@ -2769,11 +2772,11 @@ class Qn {
2769
2772
  o.DUPLICATE_COLUMN_SETTING,
2770
2773
  "Either one of 'primary key' and 'pk' can appear",
2771
2774
  f
2772
- ))), ft(a, (f, p) => {
2775
+ ))), pt(a, (f, p) => {
2773
2776
  switch (p) {
2774
2777
  case "note":
2775
2778
  f.length > 1 && i.push(...f.map((u) => new l(o.DUPLICATE_COLUMN_SETTING, "note can only appear once", u))), f.forEach((u) => {
2776
- C(u.value) || i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'note' must be a quoted string", u.value || u.name));
2779
+ G(u.value) || i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'note' must be a quoted string", u.value || u.name));
2777
2780
  });
2778
2781
  break;
2779
2782
  case "ref":
@@ -2788,7 +2791,7 @@ class Qn {
2788
2791
  break;
2789
2792
  case "pk":
2790
2793
  f.length > 1 && i.push(...f.map((u) => new l(o.DUPLICATE_COLUMN_SETTING, "'pk' can only appear once", u))), f.forEach((u) => {
2791
- u instanceof se && !H(u.value) && i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'pk' must not have a value", u.value || u.name));
2794
+ u instanceof ne && !H(u.value) && i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'pk' must not have a value", u.value || u.name));
2792
2795
  });
2793
2796
  break;
2794
2797
  case "not null":
@@ -2809,12 +2812,12 @@ class Qn {
2809
2812
  break;
2810
2813
  case "unique":
2811
2814
  f.length > 1 && i.push(...f.map((u) => new l(o.DUPLICATE_COLUMN_SETTING, "'unique' can only appear once", u))), f.forEach((u) => {
2812
- u instanceof se && !H(u.value) && i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'unique' must not have a value", u.value || u.name));
2815
+ u instanceof ne && !H(u.value) && i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'unique' must not have a value", u.value || u.name));
2813
2816
  });
2814
2817
  break;
2815
2818
  case "increment":
2816
2819
  f.length > 1 && i.push(...f.map((u) => new l(o.DUPLICATE_COLUMN_SETTING, "'increment' can only appear once", u))), f.forEach((u) => {
2817
- u instanceof se && !H(u.value) && i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'increment' must not have a value", u.value || u.name));
2820
+ u instanceof ne && !H(u.value) && i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'increment' must not have a value", u.value || u.name));
2818
2821
  });
2819
2822
  break;
2820
2823
  case "default":
@@ -2847,47 +2850,47 @@ class Qn {
2847
2850
  function pe(t) {
2848
2851
  switch (t.type.value.toLowerCase()) {
2849
2852
  case I.Enum:
2850
- return Bn;
2853
+ return Gn;
2851
2854
  case I.Table:
2852
- return jn;
2855
+ return Yn;
2853
2856
  case I.TableGroup:
2854
- return qn;
2857
+ return Qn;
2855
2858
  case I.Project:
2856
- return Cn;
2859
+ return jn;
2857
2860
  case I.Ref:
2858
- return Xn;
2861
+ return $n;
2859
2862
  case I.Note:
2860
- return Gn;
2863
+ return Xn;
2861
2864
  case I.Indexes:
2862
- return Vn;
2865
+ return Cn;
2863
2866
  case I.TablePartial:
2864
- return Qn;
2867
+ return Jn;
2865
2868
  default:
2866
- return Fn;
2869
+ return Vn;
2867
2870
  }
2868
2871
  }
2869
2872
  function Ft(t) {
2870
2873
  return !!z(t).unwrap_or(!1);
2871
2874
  }
2872
- function Hn(t) {
2873
- return we(t);
2875
+ function Zn(t) {
2876
+ return ke(t);
2874
2877
  }
2875
- function we(t) {
2876
- return t instanceof G && t.expression instanceof ae;
2878
+ function ke(t) {
2879
+ return t instanceof j && t.expression instanceof ae;
2877
2880
  }
2878
- function qe(t, e, n) {
2881
+ function ze(t, e, n) {
2879
2882
  var i;
2880
2883
  t[0] === "public" && (t = t.slice(1));
2881
2884
  let s = e;
2882
2885
  for (const a of t) {
2883
2886
  let r;
2884
- const c = nt(a);
2887
+ const c = tt(a);
2885
2888
  if (s.has(c)) {
2886
2889
  if (r = (i = s.get(c)) == null ? void 0 : i.symbolTable, !r)
2887
2890
  throw new Error("Expect a symbol table in a schema symbol");
2888
2891
  } else {
2889
- r = new ve();
2890
- const f = n.create(Ot, { symbolTable: r });
2892
+ r = new ye();
2893
+ const f = n.create(Rt, { symbolTable: r });
2891
2894
  s.set(c, f);
2892
2895
  }
2893
2896
  s = r;
@@ -2897,15 +2900,15 @@ function qe(t, e, n) {
2897
2900
  function Bt(t) {
2898
2901
  return t === "-" || t === "<>" || t === ">" || t === "<";
2899
2902
  }
2900
- function ze(t) {
2903
+ function Qe(t) {
2901
2904
  var n;
2902
- if (!(t instanceof G) || !(t.expression instanceof ge) || ((n = t.expression.literal) == null ? void 0 : n.kind) !== h.COLOR_LITERAL)
2905
+ if (!(t instanceof j) || !(t.expression instanceof we) || ((n = t.expression.literal) == null ? void 0 : n.kind) !== h.COLOR_LITERAL)
2903
2906
  return !1;
2904
2907
  const e = t.expression.literal.value;
2905
2908
  if (e.length !== 4 && e.length !== 7 || e[0] !== "#")
2906
2909
  return !1;
2907
2910
  for (let s = 1; s < e.length; s += 1)
2908
- if (!pn(e[s]))
2911
+ if (!An(e[s]))
2909
2912
  return !1;
2910
2913
  return !0;
2911
2914
  }
@@ -2914,15 +2917,15 @@ function H(t) {
2914
2917
  }
2915
2918
  function Vt(t) {
2916
2919
  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);
2920
+ return !!(G(t) || K(t) || he(t) && ["true", "false", "null"].includes(t.expression.variable.value.toLowerCase()) || t instanceof ie && lt.includes((e = t.op) == null ? void 0 : e.value) && K(t.expression) || t instanceof ce);
2918
2921
  }
2919
- function ee(t) {
2922
+ function K(t) {
2920
2923
  var e;
2921
- return t instanceof G && t.expression instanceof ge && ((e = t.expression.literal) == null ? void 0 : e.kind) === h.NUMERIC_LITERAL;
2924
+ return t instanceof j && t.expression instanceof we && ((e = t.expression.literal) == null ? void 0 : e.kind) === h.NUMERIC_LITERAL;
2922
2925
  }
2923
2926
  function Gt(t) {
2924
2927
  var n;
2925
- if (!(t instanceof Z) || !Bt((n = t.op) == null ? void 0 : n.value))
2928
+ if (!(t instanceof ie) || !Bt((n = t.op) == null ? void 0 : n.value))
2926
2929
  return !1;
2927
2930
  const e = z(t.expression).unwrap_or(void 0);
2928
2931
  return e !== void 0 && e.length > 0;
@@ -2938,19 +2941,19 @@ function F(t) {
2938
2941
  for (const i of t.elementList) {
2939
2942
  if (!i.name)
2940
2943
  continue;
2941
- if (i.name instanceof G) {
2944
+ if (i.name instanceof j) {
2942
2945
  n.push(new l(o.INVALID_SETTINGS, "A setting name must be a stream of identifiers", i.name));
2943
2946
  continue;
2944
2947
  }
2945
- const a = (s = Ae(i.name).unwrap_or(void 0)) == null ? void 0 : s.toLowerCase();
2948
+ const a = (s = ve(i.name).unwrap_or(void 0)) == null ? void 0 : s.toLowerCase();
2946
2949
  a && (e[a] === void 0 ? e[a] = [i] : e[a].push(i));
2947
2950
  }
2948
2951
  return new q(e, n);
2949
2952
  }
2950
- class Lt {
2953
+ class At {
2951
2954
  constructor(e, n) {
2952
- this.ast = e, this.symbolFactory = n, this.publicSchemaSymbol = this.symbolFactory.create(Ot, {
2953
- symbolTable: new ve()
2955
+ this.ast = e, this.symbolFactory = n, this.publicSchemaSymbol = this.symbolFactory.create(Rt, {
2956
+ symbolTable: new ye()
2954
2957
  }), this.ast.symbol = this.publicSchemaSymbol, this.ast.symbol.declaration = this.ast;
2955
2958
  }
2956
2959
  validate() {
@@ -2965,7 +2968,7 @@ class Lt {
2965
2968
  );
2966
2969
  e.push(...a.validate());
2967
2970
  });
2968
- const n = this.ast.body.filter((s) => Pe(s).unwrap_or(void 0) === I.Project);
2971
+ const n = this.ast.body.filter((s) => Ae(s).unwrap_or(void 0) === I.Project);
2969
2972
  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
2973
  }
2971
2974
  }
@@ -2977,56 +2980,52 @@ class de {
2977
2980
  this.bindSettingList(this.declarationNode.attributeList, this.settingList), this.bindBody();
2978
2981
  }
2979
2982
  bindSettingList(e, n) {
2980
- if (e)
2981
- for (const s of e.elementList) {
2982
- if (s.name instanceof G)
2983
- continue;
2984
- const i = Ae(s.name).unwrap_or(void 0);
2985
- if (!i)
2986
- continue;
2987
- const a = n[i.toLowerCase()];
2988
- a != null && a.shouldBind && this.scanAndBind(s.value, a);
2989
- }
2983
+ e && e.elementList.forEach((s) => {
2984
+ if (s.name instanceof j)
2985
+ return;
2986
+ const i = ve(s.name).unwrap_or(void 0);
2987
+ if (!i)
2988
+ return;
2989
+ const a = n[i.toLowerCase()];
2990
+ a != null && a.shouldBind && this.scanAndBind(s.value, a);
2991
+ });
2990
2992
  }
2991
2993
  bindBody() {
2992
- var s, i;
2993
2994
  const e = this.declarationNode;
2994
2995
  if (!e.body)
2995
2996
  return;
2996
2997
  const { body: n } = e;
2997
- if (n instanceof re)
2998
- for (const a of n.body)
2999
- if (a instanceof y) {
3000
- if (((s = this.declarationNode.type) == null ? void 0 : s.value.toLowerCase()) === I.TablePartial && ((i = a.type) == null ? void 0 : i.value.toLowerCase()) === I.Indexes || !a.type)
3001
- continue;
3002
- const r = et(a);
3003
- new r(a, this.errors).bind();
3004
- } else
3005
- a instanceof w ? this.bindSubfield(a) : this.bindPartialInjection(a);
3006
- else
3007
- this.bindSubfield(n);
2998
+ n instanceof re ? n.body.forEach((s) => {
2999
+ if (s instanceof y) {
3000
+ if (!s.type || Ae(this.declarationNode).unwrap_or(null) === I.TablePartial && Ae(s).unwrap_or(null) === I.Indexes)
3001
+ return;
3002
+ const i = Xt(s);
3003
+ new i(s, this.errors).bind();
3004
+ } else
3005
+ s instanceof v ? this.bindSubfield(s) : this.bindPartialInjection(s);
3006
+ }) : this.bindSubfield(n);
3008
3007
  }
3009
3008
  bindSubfield(e) {
3010
3009
  const n = [e.callee, ...e.args], s = _.last(n);
3011
- s instanceof R && (n.pop(), this.bindSettingList(s, this.subfield.settingList));
3010
+ s instanceof U && (n.pop(), this.bindSettingList(s, this.subfield.settingList));
3012
3011
  const { argBinderRules: i } = this.subfield.arg;
3013
3012
  for (let a = 0; a < Math.min(n.length, i.length); a += 1)
3014
3013
  i[a].shouldBind && this.scanAndBind(n[a], i[a]);
3015
3014
  }
3016
3015
  bindPartialInjection(e) {
3017
3016
  var n;
3018
- (n = this.subfield.injection) != null && n.injectionBinderRule.shouldBind && this.scanAndBind(e, this.subfield.injection.injectionBinderRule);
3017
+ (n = this.injectionBinderRule) != null && n.shouldBind && this.scanAndBind(e, this.injectionBinderRule);
3019
3018
  }
3020
3019
  // Scan for variable node and member access expression in the node to bind
3021
3020
  scanAndBind(e, n) {
3022
3021
  var s, i;
3023
3022
  if (e)
3024
- if (e instanceof G) {
3023
+ if (e instanceof j) {
3025
3024
  if (e.expression instanceof ae && ((i = n.keywords) != null && i.includes((s = e.expression.variable) == null ? void 0 : s.value.toLowerCase())))
3026
3025
  return;
3027
3026
  this.bindFragments([e], n);
3028
3027
  } 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);
3028
+ e instanceof le ? qe(e) ? this.bindFragments(_e(e).unwrap_or([]), n) : (this.scanAndBind(e.leftExpression, n), this.scanAndBind(e.rightExpression, n)) : e instanceof ie ? 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 Le && this.bindFragments([e], n);
3030
3029
  }
3031
3030
  // Bind the fragments of a member access expression
3032
3031
  // which can be a simple expression like v1.User,
@@ -3034,7 +3033,7 @@ class de {
3034
3033
  bindFragments(e, n) {
3035
3034
  if (e.length === 0)
3036
3035
  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(
3036
+ const s = e.length === 1 && e[0] instanceof Le, 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(
3038
3037
  0,
3039
3038
  r === -1 ? void 0 : r
3040
3039
  );
@@ -3044,39 +3043,37 @@ class de {
3044
3043
  for (; i.length && d.length; ) {
3045
3044
  const E = i.pop(), b = d.pop(), g = X(b).unwrap();
3046
3045
  u.unshift({
3047
- index: Ue(g, E),
3046
+ index: Me(g, E),
3048
3047
  referrer: b
3049
3048
  });
3050
3049
  }
3051
3050
  for (; d.length; ) {
3052
- const E = d.pop(), b = s ? E.partial.variable.value : X(E).unwrap();
3051
+ const E = d.pop(), b = s ? Mn(E).unwrap() : X(E).unwrap();
3053
3052
  u.unshift({
3054
- index: Ue(b, a),
3053
+ index: Me(b, a),
3055
3054
  referrer: E
3056
3055
  });
3057
3056
  }
3058
- return f ? f.elementList.forEach(
3059
- (E) => this.resolveIndexStack(
3060
- [
3061
- ...u,
3062
- {
3063
- index: Ue(
3064
- X(E).unwrap(),
3065
- p
3066
- ),
3067
- referrer: E
3068
- }
3069
- ],
3070
- n.ignoreNameNotFound
3071
- )
3072
- ) : this.resolveIndexStack(u, n.ignoreNameNotFound);
3057
+ return f ? f.elementList.forEach((E) => this.resolveIndexStack(
3058
+ [
3059
+ ...u,
3060
+ {
3061
+ index: Me(
3062
+ X(E).unwrap(),
3063
+ p
3064
+ ),
3065
+ referrer: E
3066
+ }
3067
+ ],
3068
+ n.ignoreNameNotFound
3069
+ )) : this.resolveIndexStack(u, n.ignoreNameNotFound);
3073
3070
  }
3074
3071
  // Looking up the indexes in the subname stack from the current declaration node
3075
3072
  // Each time the index resolves to a symbol, the referrer's symbol is bound to it
3076
3073
  resolveIndexStack(e, n) {
3077
3074
  if (e.length === 0)
3078
3075
  throw new Error("Unreachable - An unresolved name must have at least one name component");
3079
- const [s, ...i] = e, a = It(s.index, this.declarationNode);
3076
+ const [s, ...i] = e, a = Lt(s.index, this.declarationNode);
3080
3077
  if (a === void 0) {
3081
3078
  const { kind: p, name: d } = oe(s.index).unwrap();
3082
3079
  this.logError(s.referrer, `Can not find ${p} '${d}'`, n);
@@ -3109,20 +3106,23 @@ class de {
3109
3106
  return;
3110
3107
  const s = /* @__PURE__ */ new Map();
3111
3108
  n.forEach((a, r) => {
3112
- var c, f, p;
3113
- if (un(r)) {
3114
- const d = It(hn(r), this.declarationNode);
3115
- (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
- n.has(E) || s.set(E, u);
3117
- });
3118
- }
3109
+ var p, d;
3110
+ if (!un(r))
3111
+ return;
3112
+ const c = Lt(hn(r), this.declarationNode), f = (d = (p = c == null ? void 0 : c.declaration) == null ? void 0 : p.symbol) == null ? void 0 : d.symbolTable;
3113
+ f && f.forEach((u, E) => {
3114
+ n.has(E) || s.set(E, { injectorFieldSymbol: u, injectorDeclaration: a.declaration });
3115
+ });
3119
3116
  }), s.forEach((a, r) => {
3120
- const c = e.create(Ln, { injectorId: a.id });
3121
- n.set(r, c);
3117
+ const c = Ln(a.injectorFieldSymbol);
3118
+ if (!c)
3119
+ return;
3120
+ const f = e.create(c, a);
3121
+ n.set(r, f);
3122
3122
  });
3123
3123
  }
3124
3124
  }
3125
- class Jn extends de {
3125
+ class Kn extends de {
3126
3126
  constructor() {
3127
3127
  super(...arguments), this.subfield = {
3128
3128
  arg: {
@@ -3132,7 +3132,7 @@ class Jn extends de {
3132
3132
  }, this.settingList = {};
3133
3133
  }
3134
3134
  }
3135
- class Kn extends de {
3135
+ class es extends de {
3136
3136
  constructor() {
3137
3137
  super(...arguments), this.subfield = {
3138
3138
  arg: {
@@ -3142,7 +3142,7 @@ class Kn extends de {
3142
3142
  }, this.settingList = {};
3143
3143
  }
3144
3144
  }
3145
- class Zn extends de {
3145
+ class ts extends de {
3146
3146
  constructor() {
3147
3147
  super(...arguments), this.subfield = {
3148
3148
  arg: {
@@ -3177,7 +3177,7 @@ class Zn extends de {
3177
3177
  }, this.settingList = {};
3178
3178
  }
3179
3179
  }
3180
- class es extends de {
3180
+ class ns extends de {
3181
3181
  constructor() {
3182
3182
  super(...arguments), this.subfield = {
3183
3183
  arg: {
@@ -3187,7 +3187,7 @@ class es extends de {
3187
3187
  }, this.settingList = {};
3188
3188
  }
3189
3189
  }
3190
- class ts extends de {
3190
+ class ss extends de {
3191
3191
  constructor() {
3192
3192
  super(...arguments), this.subfield = {
3193
3193
  arg: {
@@ -3197,7 +3197,7 @@ class ts extends de {
3197
3197
  }, this.settingList = {};
3198
3198
  }
3199
3199
  }
3200
- class ns extends de {
3200
+ class is extends de {
3201
3201
  constructor() {
3202
3202
  super(...arguments), this.subfield = {
3203
3203
  arg: {
@@ -3214,7 +3214,7 @@ class ns extends de {
3214
3214
  }, this.settingList = {};
3215
3215
  }
3216
3216
  }
3217
- class ss extends de {
3217
+ class as extends de {
3218
3218
  constructor() {
3219
3219
  super(...arguments), this.subfield = {
3220
3220
  arg: {
@@ -3228,14 +3228,6 @@ class ss extends de {
3228
3228
  }
3229
3229
  ]
3230
3230
  },
3231
- injection: {
3232
- injectionBinderRule: {
3233
- shouldBind: !0,
3234
- topSubnamesSymbolKind: [],
3235
- remainingSubnamesSymbolKind: m.TablePartial,
3236
- ignoreNameNotFound: !1
3237
- }
3238
- },
3239
3231
  settingList: {
3240
3232
  ref: {
3241
3233
  shouldBind: !0,
@@ -3247,10 +3239,15 @@ class ss extends de {
3247
3239
  shouldBind: !1
3248
3240
  }
3249
3241
  }
3250
- }, this.settingList = {};
3242
+ }, this.settingList = {}, this.injectionBinderRule = {
3243
+ shouldBind: !0,
3244
+ topSubnamesSymbolKind: [],
3245
+ remainingSubnamesSymbolKind: m.TablePartial,
3246
+ ignoreNameNotFound: !1
3247
+ };
3251
3248
  }
3252
3249
  }
3253
- class is extends de {
3250
+ class rs extends de {
3254
3251
  constructor() {
3255
3252
  super(...arguments), this.subfield = {
3256
3253
  arg: {
@@ -3267,7 +3264,7 @@ class is extends de {
3267
3264
  }, this.settingList = {};
3268
3265
  }
3269
3266
  }
3270
- class as extends de {
3267
+ class os extends de {
3271
3268
  constructor() {
3272
3269
  super(...arguments), this.subfield = {
3273
3270
  arg: {
@@ -3295,48 +3292,42 @@ class as extends de {
3295
3292
  }, this.settingList = {};
3296
3293
  }
3297
3294
  }
3298
- function et(t) {
3295
+ function Xt(t) {
3299
3296
  switch (t.type.value.toLowerCase()) {
3300
3297
  case I.Enum:
3301
- return Kn;
3298
+ return es;
3302
3299
  case I.Table:
3303
- return ss;
3300
+ return as;
3304
3301
  case I.TableGroup:
3305
- return is;
3302
+ return rs;
3306
3303
  case I.Project:
3307
- return ts;
3304
+ return ss;
3308
3305
  case I.Ref:
3309
- return ns;
3306
+ return is;
3310
3307
  case I.Note:
3311
- return es;
3308
+ return ns;
3312
3309
  case I.Indexes:
3313
- return Zn;
3310
+ return ts;
3314
3311
  case I.TablePartial:
3315
- return as;
3312
+ return os;
3316
3313
  default:
3317
- return Jn;
3314
+ return Kn;
3318
3315
  }
3319
3316
  }
3320
- class rs {
3317
+ class ls {
3321
3318
  constructor(e) {
3322
3319
  this.ast = e, this.errors = [];
3323
3320
  }
3324
3321
  resolve(e) {
3325
- this.ast.body.forEach((n) => {
3326
- if (n.type) {
3327
- const s = et(n);
3328
- new s(n, this.errors).resolveInjections(e);
3329
- }
3330
- });
3331
- for (const n of this.ast.body)
3332
- if (n.type) {
3333
- const s = et(n);
3334
- new s(n, this.errors).bind();
3335
- }
3336
- return new q(this.ast, this.errors);
3322
+ return this.ast.body.map((n) => {
3323
+ if (!n.type)
3324
+ return null;
3325
+ const s = Xt(n), i = new s(n, this.errors);
3326
+ return i.resolveInjections(e), i;
3327
+ }).forEach((n) => n == null ? void 0 : n.bind()), new q(this.ast, this.errors);
3337
3328
  }
3338
3329
  }
3339
- class os {
3330
+ class cs {
3340
3331
  constructor(e) {
3341
3332
  this.generator = e;
3342
3333
  }
@@ -3344,21 +3335,21 @@ class os {
3344
3335
  return new e(n, this.generator.nextId());
3345
3336
  }
3346
3337
  }
3347
- class ls {
3338
+ class us {
3348
3339
  constructor(e, n) {
3349
- this.ast = e, this.symbolFactory = new os(n);
3340
+ this.ast = e, this.symbolFactory = new cs(n);
3350
3341
  }
3351
3342
  // Analyzing: Invoking both the validator and binder
3352
3343
  analyze() {
3353
- return new Lt(this.ast, this.symbolFactory).validate().chain((n) => new rs(n).resolve(this.symbolFactory));
3344
+ return new At(this.ast, this.symbolFactory).validate().chain((n) => new ls(n).resolve(this.symbolFactory));
3354
3345
  }
3355
3346
  // For invoking the validator only
3356
3347
  validate() {
3357
- return new Lt(this.ast, this.symbolFactory).validate().chain((n) => new q(n, []));
3348
+ return new At(this.ast, this.symbolFactory).validate().chain((n) => new q(n, []));
3358
3349
  }
3359
3350
  }
3360
3351
  function _t(t, e) {
3361
- const { variables: n, tupleElements: s } = Se(t).unwrap();
3352
+ const { variables: n, tupleElements: s } = Pe(t).unwrap();
3362
3353
  return s ? n.length === 0 ? {
3363
3354
  schemaName: e.schemaName,
3364
3355
  tableName: e.name,
@@ -3377,7 +3368,7 @@ function _t(t, e) {
3377
3368
  schemaName: n.pop() || null
3378
3369
  };
3379
3370
  }
3380
- function Xt(t) {
3371
+ function jt(t) {
3381
3372
  switch (t) {
3382
3373
  case "<":
3383
3374
  return ["1", "*"];
@@ -3400,9 +3391,9 @@ function L(t) {
3400
3391
  end: { offset: t.endPos.offset, line: t.endPos.line + 1, column: t.endPos.column + 1 }
3401
3392
  };
3402
3393
  }
3403
- function Ge(t) {
3394
+ function Ce(t) {
3404
3395
  var n;
3405
- const e = (n = Ie(t).unwrap_or(void 0)) == null ? void 0 : n.pop();
3396
+ const e = (n = _e(t).unwrap_or(void 0)) == null ? void 0 : n.pop();
3406
3397
  return e instanceof fe ? e.elementList.map((s) => s.referee) : [e.referee];
3407
3398
  }
3408
3399
  function Te(t) {
@@ -3423,7 +3414,7 @@ function $t(t, e) {
3423
3414
  const n = t.id.toString(), s = e.id.toString();
3424
3415
  return n < s ? `${n}-${s}` : `${s}-${n}`;
3425
3416
  }
3426
- function lt(t, e) {
3417
+ function ct(t, e) {
3427
3418
  if (Array.isArray(t)) {
3428
3419
  const i = t.map(({ id: r }) => r).sort(), a = e.map(({ id: r }) => r).sort();
3429
3420
  return _.zip(i, a).every(([r, c]) => r === c);
@@ -3431,13 +3422,13 @@ function lt(t, e) {
3431
3422
  const n = t.id, s = e.id;
3432
3423
  return n === s;
3433
3424
  }
3434
- function ie(t) {
3425
+ function se(t) {
3435
3426
  const e = t.split(`
3436
3427
  `), n = e.slice(e.findIndex((a) => a.trimStart() !== "")), s = n.filter((a) => a.trimStart()), i = Math.min(...s.map((a) => a.length - a.trimStart().length));
3437
3428
  return n.map((a) => a.slice(i)).join(`
3438
3429
  `);
3439
3430
  }
3440
- class jt {
3431
+ class Wt {
3441
3432
  constructor(e, n) {
3442
3433
  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
3434
  }
@@ -3483,12 +3474,12 @@ class jt {
3483
3474
  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
3475
  const [s] = n.note || [];
3485
3476
  return this.table.note = s && {
3486
- value: U(s == null ? void 0 : s.value).map(ie).unwrap(),
3477
+ value: M(s == null ? void 0 : s.value).map(se).unwrap(),
3487
3478
  token: L(s)
3488
3479
  }, [];
3489
3480
  }
3490
3481
  interpretBody(e) {
3491
- const [n, s] = _.partition(e.body, (i) => i instanceof w || i instanceof ke);
3482
+ const [n, s] = _.partition(e.body, (i) => i instanceof v || i instanceof Le);
3492
3483
  return [
3493
3484
  ...this.interpretFields(n),
3494
3485
  ...this.interpretSubElements(s)
@@ -3500,7 +3491,7 @@ class jt {
3500
3491
  switch ((s = n.type) == null ? void 0 : s.value.toLowerCase()) {
3501
3492
  case "note":
3502
3493
  return this.table.note = {
3503
- value: U(n.body instanceof re ? n.body.body[0].callee : n.body.callee).map(ie).unwrap(),
3494
+ value: M(n.body instanceof re ? n.body.body[0].callee : n.body.callee).map(se).unwrap(),
3504
3495
  token: L(n)
3505
3496
  }, [];
3506
3497
  case "indexes":
@@ -3514,70 +3505,70 @@ class jt {
3514
3505
  return s.name = e.partial.variable.value, this.table.partials.push(s), [];
3515
3506
  }
3516
3507
  interpretFields(e) {
3517
- return e.flatMap((n, s) => n instanceof w ? this.interpretColumn(n) : this.interpretInjection(n, s));
3508
+ return e.flatMap((n, s) => n instanceof v ? this.interpretColumn(n) : this.interpretInjection(n, s));
3518
3509
  }
3519
3510
  interpretColumn(e) {
3520
3511
  var r, c, f, p, d, u, E, b, g;
3521
3512
  const n = [], s = {};
3522
3513
  s.name = X(e.callee).unwrap();
3523
- const i = cs(e.args[0]);
3514
+ const i = hs(e.args[0]);
3524
3515
  s.type = i.getValue(), n.push(...i.getErrors()), s.token = L(e), s.inline_refs = [];
3525
3516
  const a = e.args.slice(1);
3526
- if (_.last(a) instanceof R) {
3517
+ if (_.last(a) instanceof U) {
3527
3518
  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);
3519
+ 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 = fs((b = (E = A.default) == null ? void 0 : E.at(0)) == null ? void 0 : b.value);
3529
3520
  const k = (g = A.note) == null ? void 0 : g.at(0);
3530
3521
  s.note = k && {
3531
- value: U(k.value).map(ie).unwrap(),
3522
+ value: M(k.value).map(se).unwrap(),
3532
3523
  token: L(k)
3533
3524
  };
3534
3525
  const be = A.ref || [];
3535
- s.inline_refs = be.flatMap((S) => {
3536
- const [Oe] = Ge(S.value.expression);
3537
- if (lt(Oe, e.symbol))
3538
- return n.push(new l(o.SAME_ENDPOINT, "Two endpoints are the same", S)), [];
3539
- const Ee = S.value.op, V = z(S.value.expression).unwrap();
3540
- let te;
3541
- if (V.length === 1) {
3542
- const [Q] = V;
3543
- te = {
3526
+ s.inline_refs = be.flatMap((P) => {
3527
+ const [Re] = Ce(P.value.expression);
3528
+ if (ct(Re, e.symbol))
3529
+ return n.push(new l(o.SAME_ENDPOINT, "Two endpoints are the same", P)), [];
3530
+ const Ee = P.value.op, B = z(P.value.expression).unwrap();
3531
+ let ee;
3532
+ if (B.length === 1) {
3533
+ const [Q] = B;
3534
+ ee = {
3544
3535
  schemaName: this.table.schemaName,
3545
3536
  tableName: this.table.name,
3546
3537
  fieldNames: [Q],
3547
3538
  relation: Ee.value,
3548
- token: L(S)
3539
+ token: L(P)
3549
3540
  };
3550
- } else if (V.length === 2) {
3551
- const [Q, me] = V;
3552
- te = {
3541
+ } else if (B.length === 2) {
3542
+ const [Q, me] = B;
3543
+ ee = {
3553
3544
  schemaName: null,
3554
3545
  tableName: Q,
3555
3546
  fieldNames: [me],
3556
3547
  relation: Ee.value,
3557
- token: L(S)
3548
+ token: L(P)
3558
3549
  };
3559
- } else if (V.length === 3) {
3560
- const [Q, me, ht] = V;
3561
- te = {
3550
+ } else if (B.length === 3) {
3551
+ const [Q, me, ft] = B;
3552
+ ee = {
3562
3553
  schemaName: Q,
3563
3554
  tableName: me,
3564
- fieldNames: [ht],
3555
+ fieldNames: [ft],
3565
3556
  relation: Ee.value,
3566
- token: L(S)
3557
+ token: L(P)
3567
3558
  };
3568
3559
  } else {
3569
- n.push(new l(o.UNSUPPORTED, "Nested schema is not supported", S));
3570
- const Q = V.pop(), me = V.pop();
3571
- te = {
3572
- schemaName: V.join("."),
3560
+ n.push(new l(o.UNSUPPORTED, "Nested schema is not supported", P));
3561
+ const Q = B.pop(), me = B.pop();
3562
+ ee = {
3563
+ schemaName: B.join("."),
3573
3564
  tableName: me,
3574
3565
  fieldNames: [Q],
3575
3566
  relation: Ee.value,
3576
- token: L(S)
3567
+ token: L(P)
3577
3568
  };
3578
3569
  }
3579
- const Ne = this.registerInlineRefToEnv(e, Oe, te, S);
3580
- return n.push(...Ne), Ne.length === 0 ? te : [];
3570
+ const Ne = this.registerInlineRefToEnv(e, Re, ee, P);
3571
+ return n.push(...Ne), Ne.length === 0 ? ee : [];
3581
3572
  });
3582
3573
  }
3583
3574
  return s.pk || (s.pk = a.some((A) => W(A).unwrap().toLowerCase() === "pk")), s.unique || (s.unique = a.some((A) => W(A).unwrap().toLowerCase() === "unique")), this.table.fields.push(s), s.pk && this.pkColumns.push(s), n;
@@ -3588,12 +3579,12 @@ class jt {
3588
3579
  const s = { columns: [] }, i = n;
3589
3580
  s.token = L(i);
3590
3581
  const a = [i.callee, ...i.args];
3591
- if (_.last(a) instanceof R) {
3582
+ if (_.last(a) instanceof U) {
3592
3583
  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);
3584
+ 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
3585
  const g = (d = b.note) == null ? void 0 : d.at(0);
3595
3586
  s.note = g && {
3596
- value: U(g.value).unwrap(),
3587
+ value: M(g.value).unwrap(),
3597
3588
  token: L(g)
3598
3589
  }, s.type = W((E = (u = b.type) == null ? void 0 : u.at(0)) == null ? void 0 : E.value).unwrap_or(void 0);
3599
3590
  }
@@ -3605,7 +3596,7 @@ class jt {
3605
3596
  g.push(b.argumentList), b = b.callee;
3606
3597
  return g.push(b), g;
3607
3598
  }).forEach((b) => {
3608
- const { functional: g, nonFunctional: A } = Ve(b).unwrap();
3599
+ const { functional: g, nonFunctional: A } = Ge(b).unwrap();
3609
3600
  s.columns.push(
3610
3601
  ...g.map((k) => ({
3611
3602
  value: k.value.value,
@@ -3628,7 +3619,7 @@ class jt {
3628
3619
  new l(o.CIRCULAR_REF, "References with same endpoints exist", i),
3629
3620
  new l(o.CIRCULAR_REF, "References with same endpoints exist", this.env.refIds[a])
3630
3621
  ];
3631
- const r = Xt(s.relation);
3622
+ const r = jt(s.relation);
3632
3623
  return this.env.refIds[a] = i, this.env.ref.set(i, {
3633
3624
  name: null,
3634
3625
  schemaName: null,
@@ -3649,9 +3640,9 @@ class jt {
3649
3640
  }), [];
3650
3641
  }
3651
3642
  }
3652
- function cs(t) {
3643
+ function hs(t) {
3653
3644
  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);
3645
+ t instanceof Y && (e = t.argumentList.elementList.map((a) => K(a) ? a.expression.literal.value : G(a) ? M(a).unwrap() : W(a).unwrap()).join(","), t = t.callee);
3655
3646
  let n = "";
3656
3647
  for (; t instanceof ue; )
3657
3648
  n = `[${t.indexer.elementList.map((a) => a.name.expression.literal.value).join(",")}]${n}`, t = t.array;
@@ -3669,15 +3660,15 @@ function cs(t) {
3669
3660
  args: e
3670
3661
  });
3671
3662
  }
3672
- function us(t) {
3663
+ function fs(t) {
3673
3664
  var e, n, s;
3674
3665
  if (t) {
3675
- if (C(t))
3666
+ if (G(t))
3676
3667
  return {
3677
- value: U(t).unwrap(),
3668
+ value: M(t).unwrap(),
3678
3669
  type: "string"
3679
3670
  };
3680
- if (ee(t))
3671
+ if (K(t))
3681
3672
  return {
3682
3673
  type: "number",
3683
3674
  value: Number.parseFloat(t.expression.literal.value)
@@ -3687,7 +3678,7 @@ function us(t) {
3687
3678
  value: t.expression.variable.value.toLowerCase(),
3688
3679
  type: "boolean"
3689
3680
  };
3690
- if (t instanceof Z && ot.includes((e = t.op) == null ? void 0 : e.value) && ee(t.expression)) {
3681
+ if (t instanceof ie && lt.includes((e = t.op) == null ? void 0 : e.value) && K(t.expression)) {
3691
3682
  const i = Number.parseFloat(t.expression.expression.literal.value);
3692
3683
  return {
3693
3684
  value: ((n = t.op) == null ? void 0 : n.value) === "-" ? 0 - i : i,
@@ -3702,7 +3693,7 @@ function us(t) {
3702
3693
  throw new Error("Unreachable");
3703
3694
  }
3704
3695
  }
3705
- class hs {
3696
+ class ps {
3706
3697
  constructor(e, n) {
3707
3698
  this.declarationNode = e, this.env = n, this.note = { name: void 0, content: void 0, token: void 0 };
3708
3699
  }
@@ -3723,17 +3714,17 @@ class hs {
3723
3714
  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
3715
  }
3725
3716
  interpretBody(e) {
3726
- const [n, s] = _.partition(e.body, (i) => i instanceof w);
3717
+ const [n, s] = _.partition(e.body, (i) => i instanceof v);
3727
3718
  return n.length !== 1 || s.length > 0 ? [
3728
3719
  new l(o.INVALID_NOTE, "Invalid note syntax", e)
3729
3720
  ] : [...this.interpretNote(n[0])];
3730
3721
  }
3731
3722
  interpretNote(e) {
3732
3723
  const n = _.get(e, "callee.expression.literal.value", "");
3733
- return this.note.content = ie(n), [];
3724
+ return this.note.content = se(n), [];
3734
3725
  }
3735
3726
  }
3736
- class Wt {
3727
+ class Yt {
3737
3728
  constructor(e, n) {
3738
3729
  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
3730
  }
@@ -3748,12 +3739,12 @@ class Wt {
3748
3739
  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
3740
  }
3750
3741
  interpretBody(e) {
3751
- return e instanceof w ? this.interpretField(e) : this.interpretField(e.body[0]);
3742
+ return e instanceof v ? this.interpretField(e) : this.interpretField(e.body[0]);
3752
3743
  }
3753
3744
  interpretField(e) {
3754
3745
  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);
3756
- if (lt(a, r))
3746
+ const n = e.callee.op.value, { leftExpression: s, rightExpression: i } = e.callee, a = Ce(s), r = Ce(i);
3747
+ if (ct(a, r))
3757
3748
  return [new l(o.SAME_ENDPOINT, "Two endpoints are the same", e)];
3758
3749
  const c = $t(a, r);
3759
3750
  if (this.env.refIds[c])
@@ -3763,11 +3754,11 @@ class Wt {
3763
3754
  ];
3764
3755
  if (e.args[0]) {
3765
3756
  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);
3767
- 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;
3757
+ this.ref.onDelete = be instanceof te ? ve(be).unwrap_or(void 0) : W(be).unwrap_or(void 0);
3758
+ const P = (E = (u = k.update) == null ? void 0 : u.at(0)) == null ? void 0 : E.value;
3759
+ this.ref.onUpdate = P instanceof te ? ve(P).unwrap_or(void 0) : W(P).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
3760
  }
3770
- const f = Xt(n);
3761
+ const f = jt(n);
3771
3762
  return this.ref.endpoints = [
3772
3763
  {
3773
3764
  ..._t(s, this.container),
@@ -3782,7 +3773,7 @@ class Wt {
3782
3773
  ], this.env.refIds[c] = this.declarationNode, [];
3783
3774
  }
3784
3775
  }
3785
- class Yt {
3776
+ class qt {
3786
3777
  constructor(e, n) {
3787
3778
  this.declarationNode = e, this.env = n, this.tableGroup = { tables: [] };
3788
3779
  }
@@ -3799,7 +3790,7 @@ class Yt {
3799
3790
  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
3791
  }
3801
3792
  interpretBody(e) {
3802
- const [n, s] = tn(e.body, (i) => i instanceof w);
3793
+ const [n, s] = nn(e.body, (i) => i instanceof v);
3803
3794
  return [
3804
3795
  ...this.interpretFields(n),
3805
3796
  ...this.interpretSubElements(s)
@@ -3811,9 +3802,9 @@ class Yt {
3811
3802
  switch ((s = n.type) == null ? void 0 : s.value.toLowerCase()) {
3812
3803
  case "note":
3813
3804
  this.tableGroup.note = {
3814
- value: U(
3805
+ value: M(
3815
3806
  n.body instanceof re ? n.body.body[0].callee : n.body.callee
3816
- ).map(ie).unwrap(),
3807
+ ).map(se).unwrap(),
3817
3808
  token: L(n)
3818
3809
  };
3819
3810
  break;
@@ -3826,7 +3817,7 @@ class Yt {
3826
3817
  return this.tableGroup.tables = e.map((s) => {
3827
3818
  const i = z(s.callee).unwrap();
3828
3819
  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;
3820
+ const a = _e(s.callee).unwrap().pop().referee.id;
3830
3821
  if (this.env.groupOfTable[a]) {
3831
3822
  const r = this.env.groupOfTable[a], { schemaName: c, name: f } = this.env.tableGroups.get(r), p = c ? `${c}.${f}` : f;
3832
3823
  n.push(new l(o.TABLE_REAPPEAR_IN_TABLEGROUP, `Table "${i.join(".")}" already appears in group "${p}"`, s));
@@ -3844,12 +3835,12 @@ class Yt {
3844
3835
  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
3836
  const [s] = n.note || [];
3846
3837
  return this.tableGroup.note = s && {
3847
- value: U(s == null ? void 0 : s.value).map(ie).unwrap(),
3838
+ value: M(s == null ? void 0 : s.value).map(se).unwrap(),
3848
3839
  token: L(s)
3849
3840
  }, [];
3850
3841
  }
3851
3842
  }
3852
- class qt {
3843
+ class zt {
3853
3844
  constructor(e, n) {
3854
3845
  this.declarationNode = e, this.env = n, this.enum = { values: [] };
3855
3846
  }
@@ -3867,13 +3858,13 @@ class qt {
3867
3858
  i.token = L(s), i.name = W(s.callee).unwrap();
3868
3859
  const r = (c = F(s.args[0]).getValue().note) == null ? void 0 : c.at(0);
3869
3860
  return i.note = r && {
3870
- value: U(r.value).map(ie).unwrap(),
3861
+ value: M(r.value).map(se).unwrap(),
3871
3862
  token: L(r)
3872
3863
  }, this.enum.values.push(i), [];
3873
3864
  });
3874
3865
  }
3875
3866
  }
3876
- class zt {
3867
+ class Qt {
3877
3868
  constructor(e, n) {
3878
3869
  this.declarationNode = e, this.env = n, this.tablePartial = { name: void 0, fields: [], token: void 0, indexes: [] }, this.pkColumns = [];
3879
3870
  }
@@ -3905,12 +3896,12 @@ class zt {
3905
3896
  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
3897
  const [s] = n.note || [];
3907
3898
  return this.tablePartial.note = s && {
3908
- value: U(s == null ? void 0 : s.value).map(ie).unwrap(),
3899
+ value: M(s == null ? void 0 : s.value).map(se).unwrap(),
3909
3900
  token: L(s)
3910
3901
  }, [];
3911
3902
  }
3912
3903
  interpretBody(e) {
3913
- const [n, s] = _.partition(e.body, (i) => i instanceof w);
3904
+ const [n, s] = _.partition(e.body, (i) => i instanceof v);
3914
3905
  return [...this.interpretFields(n), ...this.interpretSubElements(s)];
3915
3906
  }
3916
3907
  interpretSubElements(e) {
@@ -3919,7 +3910,7 @@ class zt {
3919
3910
  switch ((s = n.type) == null ? void 0 : s.value.toLowerCase()) {
3920
3911
  case "note":
3921
3912
  return this.tablePartial.note = {
3922
- value: U(n.body instanceof re ? n.body.body[0].callee : n.body.callee).map(ie).unwrap(),
3913
+ value: M(n.body instanceof re ? n.body.body[0].callee : n.body.callee).map(se).unwrap(),
3923
3914
  token: L(n)
3924
3915
  }, [];
3925
3916
  case "indexes":
@@ -3935,54 +3926,54 @@ class zt {
3935
3926
  var r, c, f, p, d, u, E, b, g;
3936
3927
  const n = [], s = {};
3937
3928
  s.name = X(e.callee).unwrap();
3938
- const i = fs(e.args[0]);
3929
+ const i = ds(e.args[0]);
3939
3930
  s.type = i.getValue(), n.push(...i.getErrors()), s.token = L(e), s.inline_refs = [];
3940
3931
  const a = e.args.slice(1);
3941
- if (_.last(a) instanceof R) {
3932
+ if (_.last(a) instanceof U) {
3942
3933
  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);
3934
+ 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 = Es((b = (E = A.default) == null ? void 0 : E.at(0)) == null ? void 0 : b.value);
3944
3935
  const k = (g = A.note) == null ? void 0 : g.at(0);
3945
3936
  s.note = k && {
3946
- value: U(k.value).map(ie).unwrap(),
3937
+ value: M(k.value).map(se).unwrap(),
3947
3938
  token: L(k)
3948
3939
  };
3949
3940
  const be = A.ref || [];
3950
- s.inline_refs = be.flatMap((S) => {
3951
- const [Oe] = Ge(S.value.expression);
3952
- if (lt(Oe, e.symbol))
3953
- return n.push(new l(o.SAME_ENDPOINT, "Two endpoints are the same", S)), [];
3954
- const Ee = S.value.op, V = z(S.value.expression).unwrap();
3955
- let te;
3956
- if (V.length === 2) {
3957
- const [Ne, Q] = V;
3958
- te = {
3941
+ s.inline_refs = be.flatMap((P) => {
3942
+ const [Re] = Ce(P.value.expression);
3943
+ if (ct(Re, e.symbol))
3944
+ return n.push(new l(o.SAME_ENDPOINT, "Two endpoints are the same", P)), [];
3945
+ const Ee = P.value.op, B = z(P.value.expression).unwrap();
3946
+ let ee;
3947
+ if (B.length === 2) {
3948
+ const [Ne, Q] = B;
3949
+ ee = {
3959
3950
  schemaName: null,
3960
3951
  tableName: Ne,
3961
3952
  fieldNames: [Q],
3962
3953
  relation: Ee.value,
3963
- token: L(S)
3954
+ token: L(P)
3964
3955
  };
3965
- } else if (V.length === 3) {
3966
- const [Ne, Q, me] = V;
3967
- te = {
3956
+ } else if (B.length === 3) {
3957
+ const [Ne, Q, me] = B;
3958
+ ee = {
3968
3959
  schemaName: Ne,
3969
3960
  tableName: Q,
3970
3961
  fieldNames: [me],
3971
3962
  relation: Ee.value,
3972
- token: L(S)
3963
+ token: L(P)
3973
3964
  };
3974
3965
  } else {
3975
- n.push(new l(o.UNSUPPORTED, "Unsupported", S));
3976
- const Ne = V.pop(), Q = V.pop();
3977
- te = {
3978
- schemaName: V.join("."),
3966
+ n.push(new l(o.UNSUPPORTED, "Unsupported", P));
3967
+ const Ne = B.pop(), Q = B.pop();
3968
+ ee = {
3969
+ schemaName: B.join("."),
3979
3970
  tableName: Q,
3980
3971
  fieldNames: [Ne],
3981
3972
  relation: Ee.value,
3982
- token: L(S)
3973
+ token: L(P)
3983
3974
  };
3984
3975
  }
3985
- return te;
3976
+ return ee;
3986
3977
  });
3987
3978
  }
3988
3979
  return s.pk || (s.pk = a.some((A) => W(A).unwrap().toLowerCase() === "pk")), s.unique || (s.unique = a.some((A) => W(A).unwrap().toLowerCase() === "unique")), this.tablePartial.fields.push(s), s.pk && this.pkColumns.push(s), n;
@@ -3993,12 +3984,12 @@ class zt {
3993
3984
  const s = { columns: [] }, i = n;
3994
3985
  s.token = L(i);
3995
3986
  const a = [i.callee, ...i.args];
3996
- if (_.last(a) instanceof R) {
3987
+ if (_.last(a) instanceof U) {
3997
3988
  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);
3989
+ 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
3990
  const g = (d = b.note) == null ? void 0 : d.at(0);
4000
3991
  s.note = g && {
4001
- value: U(g.value).unwrap(),
3992
+ value: M(g.value).unwrap(),
4002
3993
  token: L(g)
4003
3994
  }, s.type = W((E = (u = b.type) == null ? void 0 : u.at(0)) == null ? void 0 : E.value).unwrap_or(void 0);
4004
3995
  }
@@ -4010,7 +4001,7 @@ class zt {
4010
4001
  g.push(b.argumentList), b = b.callee;
4011
4002
  return g.push(b), g;
4012
4003
  }).forEach((b) => {
4013
- const { functional: g, nonFunctional: A } = Ve(b).unwrap();
4004
+ const { functional: g, nonFunctional: A } = Ge(b).unwrap();
4014
4005
  s.columns.push(
4015
4006
  ...g.map((k) => ({
4016
4007
  value: k.value.value,
@@ -4059,9 +4050,9 @@ class zt {
4059
4050
  // return [];
4060
4051
  // }
4061
4052
  }
4062
- function fs(t) {
4053
+ function ds(t) {
4063
4054
  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);
4055
+ t instanceof Y && (e = t.argumentList.elementList.map((a) => K(a) ? a.expression.literal.value : G(a) ? M(a).unwrap() : W(a).unwrap()).join(","), t = t.callee);
4065
4056
  let n = "";
4066
4057
  for (; t instanceof ue; )
4067
4058
  n = `[${t.indexer.elementList.map((a) => a.name.expression.literal.value).join(",")}]${n}`, t = t.array;
@@ -4079,15 +4070,15 @@ function fs(t) {
4079
4070
  args: e
4080
4071
  });
4081
4072
  }
4082
- function ps(t) {
4073
+ function Es(t) {
4083
4074
  var e, n, s;
4084
4075
  if (t) {
4085
- if (C(t))
4076
+ if (G(t))
4086
4077
  return {
4087
- value: U(t).unwrap(),
4078
+ value: M(t).unwrap(),
4088
4079
  type: "string"
4089
4080
  };
4090
- if (ee(t))
4081
+ if (K(t))
4091
4082
  return {
4092
4083
  type: "number",
4093
4084
  value: Number.parseFloat(t.expression.literal.value)
@@ -4097,7 +4088,7 @@ function ps(t) {
4097
4088
  value: t.expression.variable.value.toLowerCase(),
4098
4089
  type: "boolean"
4099
4090
  };
4100
- if (t instanceof Z && ot.includes((e = t.op) == null ? void 0 : e.value) && ee(t.expression)) {
4091
+ if (t instanceof ie && lt.includes((e = t.op) == null ? void 0 : e.value) && K(t.expression)) {
4101
4092
  const i = Number.parseFloat(t.expression.expression.literal.value);
4102
4093
  return {
4103
4094
  value: ((n = t.op) == null ? void 0 : n.value) === "-" ? 0 - i : i,
@@ -4112,7 +4103,7 @@ function ps(t) {
4112
4103
  throw new Error("Unreachable");
4113
4104
  }
4114
4105
  }
4115
- class ds {
4106
+ class Ns {
4116
4107
  constructor(e, n) {
4117
4108
  this.declarationNode = e, this.env = n, this.project = { enums: [], refs: [], tableGroups: [], tables: [], tablePartials: [] };
4118
4109
  }
@@ -4131,37 +4122,37 @@ class ds {
4131
4122
  const s = n;
4132
4123
  switch ((i = s.type) == null ? void 0 : i.value.toLowerCase()) {
4133
4124
  case "table": {
4134
- const a = new jt(s, this.env).interpret();
4125
+ const a = new Wt(s, this.env).interpret();
4135
4126
  return this.project.tables.push(this.env.tables.get(s)), a;
4136
4127
  }
4137
4128
  case "ref": {
4138
- const a = new Wt(s, this.env).interpret();
4129
+ const a = new Yt(s, this.env).interpret();
4139
4130
  return this.project.refs.push(this.env.ref.get(s)), a;
4140
4131
  }
4141
4132
  case "tablegroup": {
4142
- const a = new Yt(s, this.env).interpret();
4133
+ const a = new qt(s, this.env).interpret();
4143
4134
  return this.project.tableGroups.push(this.env.tableGroups.get(s)), a;
4144
4135
  }
4145
4136
  case "enum": {
4146
- const a = new qt(s, this.env).interpret();
4137
+ const a = new zt(s, this.env).interpret();
4147
4138
  return this.project.enums.push(this.env.enums.get(s)), a;
4148
4139
  }
4149
4140
  case "note":
4150
4141
  return this.project.note = {
4151
- value: U(s.body instanceof re ? s.body.body[0].callee : s.body.callee).map(ie).unwrap(),
4142
+ value: M(s.body instanceof re ? s.body.body[0].callee : s.body.callee).map(se).unwrap(),
4152
4143
  token: L(s)
4153
4144
  }, [];
4154
4145
  case "tablepartial": {
4155
- const a = new zt(s, this.env).interpret();
4146
+ const a = new Qt(s, this.env).interpret();
4156
4147
  return this.project.tablePartials.push(this.env.tablePartials.get(s)), a;
4157
4148
  }
4158
4149
  default:
4159
- return this.project[s.type.value.toLowerCase()] = U(s.body.callee).unwrap(), [];
4150
+ return this.project[s.type.value.toLowerCase()] = M(s.body.callee).unwrap(), [];
4160
4151
  }
4161
4152
  });
4162
4153
  }
4163
4154
  }
4164
- class Es {
4155
+ class ms {
4165
4156
  constructor(e) {
4166
4157
  this.ast = e, this.env = {
4167
4158
  schema: [],
@@ -4179,29 +4170,29 @@ class Es {
4179
4170
  }
4180
4171
  interpret() {
4181
4172
  const e = this.ast.body.flatMap((n) => {
4182
- switch (Pe(n).unwrap_or(void 0)) {
4173
+ switch (Ae(n).unwrap_or(void 0)) {
4183
4174
  case I.Table:
4184
- return new jt(n, this.env).interpret();
4175
+ return new Wt(n, this.env).interpret();
4185
4176
  case I.Note:
4186
- return new hs(n, this.env).interpret();
4177
+ return new ps(n, this.env).interpret();
4187
4178
  case I.Ref:
4188
- return new Wt(n, this.env).interpret();
4189
- case I.TableGroup:
4190
4179
  return new Yt(n, this.env).interpret();
4180
+ case I.TableGroup:
4181
+ return new qt(n, this.env).interpret();
4191
4182
  case I.TablePartial:
4192
- return new zt(n, this.env).interpret();
4183
+ return new Qt(n, this.env).interpret();
4193
4184
  case I.Enum:
4194
- return new qt(n, this.env).interpret();
4185
+ return new zt(n, this.env).interpret();
4195
4186
  case I.Project:
4196
- return new ds(n, this.env).interpret();
4187
+ return new Ns(n, this.env).interpret();
4197
4188
  default:
4198
4189
  return [];
4199
4190
  }
4200
4191
  });
4201
- return new q(Ns(this.env), e);
4192
+ return new q(Ts(this.env), e);
4202
4193
  }
4203
4194
  }
4204
- function Ns(t) {
4195
+ function Ts(t) {
4205
4196
  return {
4206
4197
  schemas: [],
4207
4198
  tables: Array.from(t.tables.values()),
@@ -4214,29 +4205,29 @@ function Ns(t) {
4214
4205
  tablePartials: Array.from(t.tablePartials.values())
4215
4206
  };
4216
4207
  }
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 || {});
4208
+ 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 || {}), D = /* @__PURE__ */ ((t) => (t[t.None = 0] = "None", t[t.KeepWhitespace = 1] = "KeepWhitespace", t[t.InsertAsSnippet = 4] = "InsertAsSnippet", t))(D || {});
4218
4209
  function xe(t) {
4219
4210
  switch (t) {
4220
4211
  case m.Schema:
4221
- return v.Module;
4212
+ return w.Module;
4222
4213
  case m.Table:
4223
- return v.Class;
4214
+ case m.TablePartial:
4215
+ return w.Class;
4224
4216
  case m.Column:
4225
- return v.Field;
4217
+ case m.TableGroupField:
4218
+ return w.Field;
4226
4219
  case m.Enum:
4227
- return v.Enum;
4220
+ return w.Enum;
4228
4221
  case m.EnumField:
4229
- return v.EnumMember;
4222
+ return w.EnumMember;
4230
4223
  case m.TableGroup:
4231
- return v.Struct;
4232
- case m.TableGroupField:
4233
- return v.Field;
4224
+ return w.Struct;
4234
4225
  default:
4235
- return v.Text;
4226
+ return w.Text;
4236
4227
  }
4237
4228
  }
4238
- function Ce(t, e) {
4239
- if (!t || Ze(t))
4229
+ function Xe(t, e) {
4230
+ if (!t || Ke(t))
4240
4231
  return !1;
4241
4232
  for (const n of t.trailingTrivia) {
4242
4233
  if (n.start > e)
@@ -4246,12 +4237,12 @@ function Ce(t, e) {
4246
4237
  }
4247
4238
  return !0;
4248
4239
  }
4249
- function B() {
4240
+ function V() {
4250
4241
  return {
4251
4242
  suggestions: []
4252
4243
  };
4253
4244
  }
4254
- function Xe(t) {
4245
+ function je(t) {
4255
4246
  return {
4256
4247
  ...t,
4257
4248
  suggestions: t.suggestions.map((e) => ({
@@ -4260,47 +4251,47 @@ function Xe(t) {
4260
4251
  }))
4261
4252
  };
4262
4253
  }
4263
- function Qe(t) {
4254
+ function He(t) {
4264
4255
  return {
4265
4256
  ...t,
4266
4257
  suggestions: t.suggestions.map((e) => ({
4267
4258
  ...e,
4268
- insertText: e.insertText.split("").every(We) ? e.insertText : `"${e.insertText}"`
4259
+ insertText: e.insertText.split("").every(Ye) ? e.insertText : `"${e.insertText}"`
4269
4260
  }))
4270
4261
  };
4271
4262
  }
4272
- function ct(t, e) {
4263
+ function ut(t, e) {
4273
4264
  return t.getOffsetAt(e);
4274
4265
  }
4275
- class Qt {
4266
+ class Ht {
4276
4267
  constructor(e, n = []) {
4277
4268
  this.compiler = e, this.triggerCharacters = n;
4278
4269
  }
4279
4270
  provideCompletionItems(e, n) {
4280
4271
  var d, u;
4281
- const s = ct(e, n), i = this.compiler.token.flatStream(), { token: a, index: r } = this.compiler.container.token(s), c = r === void 0 ? i[0] : i[r + 1];
4272
+ const s = ut(e, n), i = this.compiler.token.flatStream(), { token: a, index: r } = this.compiler.container.token(s), c = r === void 0 ? i[0] : i[r + 1];
4282
4273
  if ([
4283
4274
  ...(a == null ? void 0 : a.trailingTrivia) || [],
4284
4275
  ...(a == null ? void 0 : a.leadingTrivia) || [],
4285
4276
  ...(c == null ? void 0 : c.leadingTrivia) || []
4286
- ].find((E) => an(E) && ye(s, E)))
4287
- return B();
4277
+ ].find((E) => rn(E) && Se(s, E)))
4278
+ return V();
4288
4279
  if (r === void 0)
4289
- return yt();
4290
- if ([h.STRING_LITERAL, h.QUOTED_STRING].includes(a.kind) && ye(s, a))
4291
- return B();
4280
+ return kt();
4281
+ if ([h.STRING_LITERAL, h.QUOTED_STRING].includes(a.kind) && Se(s, a))
4282
+ return V();
4292
4283
  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)
4294
- return yt();
4284
+ if (this.compiler.container.scopeKind(s) === O.TOPLEVEL || f instanceof y && f.type && f.type.start <= s && f.type.end >= s)
4285
+ return kt();
4295
4286
  const p = [...this.compiler.container.stack(s)].reverse();
4296
4287
  for (const E of p)
4297
- if (E instanceof Z)
4288
+ if (E instanceof ie)
4298
4289
  switch ((d = E.op) == null ? void 0 : d.value) {
4299
4290
  case ">":
4300
4291
  case "<":
4301
4292
  case "<>":
4302
4293
  case "-":
4303
- return At(
4294
+ return gt(
4304
4295
  this.compiler,
4305
4296
  s,
4306
4297
  E
@@ -4312,49 +4303,59 @@ class Qt {
4312
4303
  case "<":
4313
4304
  case "<>":
4314
4305
  case "-":
4315
- return At(
4306
+ return gt(
4316
4307
  this.compiler,
4317
4308
  s,
4318
4309
  E
4319
4310
  );
4320
4311
  case ".":
4321
- return Ht(
4312
+ return Jt(
4322
4313
  this.compiler,
4323
4314
  s,
4324
4315
  E
4325
4316
  );
4326
4317
  }
4327
4318
  else {
4328
- if (E instanceof se)
4329
- return gt(this.compiler, s, E);
4330
- if (E instanceof R)
4331
- return gt(this.compiler, s, E);
4319
+ if (E instanceof ne)
4320
+ return vt(this.compiler, s, E);
4321
+ if (E instanceof U)
4322
+ return vt(this.compiler, s, E);
4332
4323
  if (E instanceof fe)
4333
- return ms(this.compiler, s);
4334
- if (E instanceof w)
4335
- return wt(this.compiler, s, E);
4336
- if (E instanceof y && (E.bodyColon && s >= E.bodyColon.end || E.body && ye(s, E.body)))
4337
- return wt(this.compiler, s, void 0);
4324
+ return Is(this.compiler, s);
4325
+ if (E instanceof Le)
4326
+ return bs(this.compiler, s);
4327
+ if (E instanceof v)
4328
+ return yt(this.compiler, s, E);
4329
+ if (E instanceof y && (E.bodyColon && s >= E.bodyColon.end || E.body && Se(s, E.body)))
4330
+ return yt(this.compiler, s, void 0);
4338
4331
  }
4339
- return B();
4332
+ return V();
4340
4333
  }
4341
4334
  }
4342
- function At(t, e, n) {
4335
+ function bs(t, e) {
4336
+ const n = t.container.element(e);
4337
+ return Oe(t, e, n, [m.TablePartial]);
4338
+ }
4339
+ function gt(t, e, n) {
4343
4340
  const s = t.container.scopeKind(e);
4344
- if ([M.REF, M.TABLE].includes(s)) {
4345
- const i = He(t, e, t.container.element(e), [
4341
+ if ([
4342
+ O.REF,
4343
+ O.TABLE,
4344
+ O.TABLEPARTIAL
4345
+ ].includes(s)) {
4346
+ const i = Oe(t, e, t.container.element(e), [
4346
4347
  m.Table,
4347
4348
  m.Schema,
4348
4349
  m.Column
4349
4350
  ]);
4350
- return Ce(n.op, e) ? Xe(i) : i;
4351
+ return Xe(n.op, e) ? je(i) : i;
4351
4352
  }
4352
- return B();
4353
+ return V();
4353
4354
  }
4354
- function He(t, e, n, s) {
4355
+ function Oe(t, e, n, s) {
4355
4356
  var r;
4356
4357
  if (n === void 0)
4357
- return B();
4358
+ return V();
4358
4359
  let i = n;
4359
4360
  const a = { suggestions: [] };
4360
4361
  for (; i; ) {
@@ -4364,7 +4365,7 @@ function He(t, e, n, s) {
4364
4365
  ...t.symbol.members(c).filter(({ kind: f }) => s.includes(f)).map(({ name: f, kind: p }) => ({
4365
4366
  label: f,
4366
4367
  insertText: f,
4367
- insertTextRules: x.KeepWhitespace,
4368
+ insertTextRules: D.KeepWhitespace,
4368
4369
  kind: xe(p),
4369
4370
  sortText: xe(p).toString().padStart(2, "0"),
4370
4371
  range: void 0
@@ -4373,149 +4374,149 @@ function He(t, e, n, s) {
4373
4374
  }
4374
4375
  i = i instanceof y ? i.parent : void 0;
4375
4376
  }
4376
- return Qe(a);
4377
+ return He(a);
4377
4378
  }
4378
- function ms(t, e) {
4379
+ function Is(t, e) {
4379
4380
  var s;
4380
4381
  switch (t.container.scopeKind(e)) {
4381
- case M.INDEXES:
4382
+ case O.INDEXES:
4382
4383
  return Kt(t, e);
4383
- case M.REF:
4384
+ case O.REF:
4384
4385
  {
4385
4386
  const i = [...t.container.stack(e)];
4386
4387
  for (; i.length > 0; ) {
4387
4388
  const a = i.pop();
4388
4389
  if (a instanceof le && ((s = a.op) == null ? void 0 : s.value) === ".")
4389
- return Ht(
4390
+ return Jt(
4390
4391
  t,
4391
4392
  e,
4392
4393
  a
4393
4394
  );
4394
4395
  }
4395
4396
  }
4396
- return Jt(t, e);
4397
+ return Zt(t, e);
4397
4398
  }
4398
- return B();
4399
+ return V();
4399
4400
  }
4400
- function gt(t, e, n) {
4401
+ function vt(t, e, n) {
4401
4402
  const { token: s } = t.container.token(e);
4402
4403
  if ([h.COMMA, h.LBRACKET].includes(s == null ? void 0 : s.kind)) {
4403
- const i = vt(t, e);
4404
- return (s == null ? void 0 : s.kind) === h.COMMA && Ce(s, e) ? Xe(i) : i;
4404
+ const i = wt(t, e);
4405
+ return (s == null ? void 0 : s.kind) === h.COMMA && Xe(s, e) ? je(i) : i;
4405
4406
  }
4406
4407
  if (n.name && n.name.start <= e && n.name.end >= e)
4407
- return vt(t, e);
4408
- if (n.name instanceof ne) {
4409
- const i = Ts(
4408
+ return wt(t, e);
4409
+ if (n.name instanceof te) {
4410
+ const i = Ls(
4410
4411
  t,
4411
4412
  e,
4412
- Ae(n.name).unwrap_or("")
4413
+ ve(n.name).unwrap_or("")
4413
4414
  );
4414
- return (s == null ? void 0 : s.kind) === h.COLON && Ce(s, e) ? Xe(i) : i;
4415
+ return (s == null ? void 0 : s.kind) === h.COLON && Xe(s, e) ? je(i) : i;
4415
4416
  }
4416
- return B();
4417
+ return V();
4417
4418
  }
4418
- function vt(t, e) {
4419
- const n = t.container.element(e), s = t.container.scopeKind(e);
4420
- if (n instanceof K)
4421
- return B();
4422
- if (n.body && !ye(e, n.body))
4419
+ function wt(t, e) {
4420
+ const n = t.container.element(e);
4421
+ if (n instanceof Z)
4422
+ return V();
4423
+ const s = t.container.scopeKind(e);
4424
+ if (n.body && !Se(e, n.body)) {
4425
+ let i;
4423
4426
  switch (s) {
4424
- case M.TABLE:
4425
- return {
4426
- suggestions: ["headercolor", "note"].map((i) => ({
4427
- label: i,
4428
- insertText: `${i}: `,
4429
- kind: v.Field,
4430
- insertTextRules: x.KeepWhitespace,
4431
- range: void 0
4432
- }))
4433
- };
4434
- case M.TABLEGROUP:
4435
- return {
4436
- suggestions: ["color", "note"].map((i) => ({
4437
- label: i,
4438
- insertText: `${i}: `,
4439
- kind: v.Field,
4440
- insertTextRules: x.KeepWhitespace,
4441
- range: void 0
4442
- }))
4443
- };
4427
+ case O.TABLE:
4428
+ case O.TABLEPARTIAL:
4429
+ i = ["headercolor", "note"];
4430
+ break;
4431
+ case O.TABLEGROUP:
4432
+ i = ["color", "note"];
4433
+ break;
4444
4434
  default:
4445
- return B();
4435
+ i = [];
4446
4436
  }
4437
+ return {
4438
+ suggestions: i.map((a) => ({
4439
+ label: a,
4440
+ insertText: `${a}: `,
4441
+ kind: w.Field,
4442
+ insertTextRules: D.KeepWhitespace,
4443
+ range: void 0
4444
+ }))
4445
+ };
4446
+ }
4447
4447
  switch (s) {
4448
- case M.TABLE:
4448
+ case O.TABLE:
4449
+ case O.TABLEPARTIAL:
4449
4450
  return {
4450
4451
  suggestions: [
4451
4452
  ...["primary key", "null", "not null", "increment", "pk", "unique"].map((i) => ({
4452
4453
  label: i,
4453
4454
  insertText: i,
4454
- kind: v.Property,
4455
- insertTextRules: x.KeepWhitespace,
4455
+ kind: w.Property,
4456
+ insertTextRules: D.KeepWhitespace,
4456
4457
  range: void 0
4457
4458
  })),
4458
4459
  ...["ref", "default"].map((i) => ({
4459
4460
  label: i,
4460
4461
  insertText: `${i}: `,
4461
- kind: v.Property,
4462
- insertTextRules: x.KeepWhitespace,
4462
+ kind: w.Property,
4463
+ insertTextRules: D.KeepWhitespace,
4463
4464
  range: void 0
4464
4465
  })),
4465
4466
  {
4466
4467
  label: "note",
4467
4468
  insertText: "note: ",
4468
- kind: v.Property,
4469
- insertTextRules: x.KeepWhitespace,
4469
+ kind: w.Property,
4470
+ insertTextRules: D.KeepWhitespace,
4470
4471
  range: void 0
4471
4472
  }
4472
4473
  ]
4473
4474
  };
4474
- case M.ENUM:
4475
+ case O.ENUM:
4475
4476
  return {
4476
4477
  suggestions: [
4477
4478
  {
4478
4479
  label: "note",
4479
4480
  insertText: "note: ",
4480
- kind: v.Property,
4481
- insertTextRules: x.KeepWhitespace,
4481
+ kind: w.Property,
4482
+ insertTextRules: D.KeepWhitespace,
4482
4483
  range: void 0
4483
4484
  }
4484
4485
  ]
4485
4486
  };
4486
- case M.INDEXES:
4487
+ case O.INDEXES:
4487
4488
  return {
4488
4489
  suggestions: [
4489
4490
  ...["unique", "pk"].map((i) => ({
4490
4491
  label: i,
4491
4492
  insertText: i,
4492
- insertTextRules: x.KeepWhitespace,
4493
- kind: v.Property,
4493
+ insertTextRules: D.KeepWhitespace,
4494
+ kind: w.Property,
4494
4495
  range: void 0
4495
4496
  })),
4496
4497
  ...["note", "name", "type"].map((i) => ({
4497
4498
  label: i,
4498
4499
  insertText: `${i}: `,
4499
- kind: v.Property,
4500
- insertTextRules: x.KeepWhitespace,
4500
+ kind: w.Property,
4501
+ insertTextRules: D.KeepWhitespace,
4501
4502
  range: void 0
4502
4503
  }))
4503
4504
  ]
4504
4505
  };
4505
- case M.REF:
4506
+ case O.REF:
4506
4507
  return {
4507
4508
  suggestions: ["update", "delete"].map((i) => ({
4508
4509
  label: i,
4509
4510
  insertText: `${i}: `,
4510
- kind: v.Property,
4511
- insertTextRules: x.KeepWhitespace,
4511
+ kind: w.Property,
4512
+ insertTextRules: D.KeepWhitespace,
4512
4513
  range: void 0
4513
4514
  }))
4514
4515
  };
4515
4516
  }
4516
- return B();
4517
+ return V();
4517
4518
  }
4518
- function Ts(t, e, n) {
4519
+ function Ls(t, e, n) {
4519
4520
  switch (n == null ? void 0 : n.toLowerCase()) {
4520
4521
  case "update":
4521
4522
  case "delete":
@@ -4523,8 +4524,8 @@ function Ts(t, e, n) {
4523
4524
  suggestions: ["cascade", "set default", "set null", "restrict"].map((s) => ({
4524
4525
  label: s,
4525
4526
  insertText: s,
4526
- kind: v.Value,
4527
- insertTextRules: x.KeepWhitespace,
4527
+ kind: w.Value,
4528
+ insertTextRules: D.KeepWhitespace,
4528
4529
  range: void 0
4529
4530
  }))
4530
4531
  };
@@ -4533,20 +4534,20 @@ function Ts(t, e, n) {
4533
4534
  suggestions: ["btree", "hash"].map((s) => ({
4534
4535
  label: s,
4535
4536
  insertText: `${s}`,
4536
- kind: v.Value,
4537
- insertTextRules: x.KeepWhitespace,
4537
+ kind: w.Value,
4538
+ insertTextRules: D.KeepWhitespace,
4538
4539
  range: void 0
4539
4540
  }))
4540
4541
  };
4541
4542
  }
4542
- return B();
4543
+ return V();
4543
4544
  }
4544
- function Ht(t, e, n) {
4545
- const s = Ie(n).unwrap_or([]);
4545
+ function Jt(t, e, n) {
4546
+ const s = _e(n).unwrap_or([]);
4546
4547
  if (s.pop(), s.some((a) => !$(a)))
4547
- return B();
4548
+ return V();
4548
4549
  const i = s.map((a) => W(a).unwrap());
4549
- return Qe({
4550
+ return He({
4550
4551
  suggestions: t.symbol.ofName({ nameStack: i, owner: t.container.element(e) }).flatMap(({ symbol: a }) => t.symbol.members(a)).map(({ kind: a, name: r }) => ({
4551
4552
  label: r,
4552
4553
  insertText: r,
@@ -4555,97 +4556,100 @@ function Ht(t, e, n) {
4555
4556
  }))
4556
4557
  });
4557
4558
  }
4558
- function wt(t, e, n) {
4559
+ function yt(t, e, n) {
4559
4560
  var i;
4560
4561
  switch (t.container.scopeKind(e)) {
4561
- case M.TABLE:
4562
- return Is(t, e, n);
4563
- case M.PROJECT:
4564
- 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;
4562
+ case O.TABLE:
4563
+ case O.TABLEPARTIAL:
4564
+ return _s(t, e, n);
4565
+ case O.PROJECT:
4566
+ return gs(t, e, n);
4567
+ case O.INDEXES:
4568
+ return ws(t, e);
4569
+ case O.ENUM:
4570
+ return As(t, e, n);
4571
+ case O.REF: {
4572
+ const a = Zt(t, e);
4573
+ return ((i = t.container.token(e).token) == null ? void 0 : i.kind) === h.COLON && Xe(t.container.token(e).token, e) ? je(a) : a;
4572
4574
  }
4573
- case M.TABLEGROUP:
4574
- return _s(t);
4575
+ case O.TABLEGROUP:
4576
+ return vs(t);
4575
4577
  default:
4576
- return B();
4578
+ return V();
4577
4579
  }
4578
4580
  }
4579
- function yt() {
4581
+ function kt() {
4580
4582
  return {
4581
- suggestions: ["Table", "TableGroup", "Enum", "Project", "Ref"].map((t) => ({
4583
+ suggestions: ["Table", "TableGroup", "Enum", "Project", "Ref", "TablePartial"].map((t) => ({
4582
4584
  label: t,
4583
4585
  insertText: t,
4584
- insertTextRules: x.KeepWhitespace,
4585
- kind: v.Keyword,
4586
+ insertTextRules: D.KeepWhitespace,
4587
+ kind: w.Keyword,
4586
4588
  range: void 0
4587
4589
  }))
4588
4590
  };
4589
4591
  }
4590
- function bs(t, e, n) {
4591
- return n != null && n.callee && ut(e, n) === 1 ? He(t, e, t.container.element(e), [
4592
+ function As(t, e, n) {
4593
+ return n != null && n.callee && ht(e, n) === 1 ? Oe(t, e, t.container.element(e), [
4592
4594
  m.Schema,
4593
4595
  m.Table,
4594
4596
  m.Column
4595
- ]) : B();
4597
+ ]) : V();
4596
4598
  }
4597
- function Is(t, e, n) {
4599
+ function _s(t, e, n) {
4600
+ const s = ["Note", "indexes"];
4598
4601
  if (!(n != null && n.callee))
4599
4602
  return {
4600
- suggestions: ["Note", "indexes"].map((i) => ({
4601
- label: i,
4602
- insertText: i,
4603
- insertTextRules: x.KeepWhitespace,
4604
- kind: v.Keyword,
4603
+ suggestions: s.map((a) => ({
4604
+ label: a,
4605
+ insertText: a,
4606
+ insertTextRules: D.KeepWhitespace,
4607
+ kind: w.Keyword,
4605
4608
  range: void 0
4606
4609
  }))
4607
4610
  };
4608
- const s = ut(e, n);
4609
- return s === 0 ? {
4610
- suggestions: ["Note", "indexes"].map((i) => ({
4611
- label: i,
4612
- insertText: i,
4613
- insertTextRules: x.KeepWhitespace,
4614
- kind: v.Keyword,
4611
+ const i = ht(e, n);
4612
+ return i === 0 ? {
4613
+ suggestions: s.map((a) => ({
4614
+ label: a,
4615
+ insertText: a,
4616
+ insertTextRules: D.KeepWhitespace,
4617
+ kind: w.Keyword,
4615
4618
  range: void 0
4616
4619
  }))
4617
- } : s === 1 ? gs(t, e) : B();
4618
- }
4619
- function Ls(t, e, n) {
4620
- return n != null && n.callee ? ut(e, n) === 0 ? {
4621
- suggestions: ["Table", "TableGroup", "Enum", "Note", "Ref"].map((i) => ({
4622
- label: i,
4623
- insertText: i,
4624
- insertTextRules: x.KeepWhitespace,
4625
- kind: v.Keyword,
4620
+ } : i === 1 ? ys(t, e) : V();
4621
+ }
4622
+ function gs(t, e, n) {
4623
+ const s = ["Table", "TableGroup", "Enum", "Note", "Ref", "TablePartial"];
4624
+ return n != null && n.callee ? ht(e, n) === 0 ? {
4625
+ suggestions: s.map((a) => ({
4626
+ label: a,
4627
+ insertText: a,
4628
+ insertTextRules: D.KeepWhitespace,
4629
+ kind: w.Keyword,
4626
4630
  range: void 0
4627
4631
  }))
4628
- } : B() : {
4629
- suggestions: ["Table", "TableGroup", "Enum", "Note", "Ref"].map((i) => ({
4630
- label: i,
4631
- insertText: i,
4632
- insertTextRules: x.KeepWhitespace,
4633
- kind: v.Keyword,
4632
+ } : V() : {
4633
+ suggestions: s.map((a) => ({
4634
+ label: a,
4635
+ insertText: a,
4636
+ insertTextRules: D.KeepWhitespace,
4637
+ kind: w.Keyword,
4634
4638
  range: void 0
4635
4639
  }))
4636
4640
  };
4637
4641
  }
4638
- function Jt(t, e) {
4639
- return He(t, e, t.container.element(e), [
4642
+ function Zt(t, e) {
4643
+ return Oe(t, e, t.container.element(e), [
4640
4644
  m.Schema,
4641
4645
  m.Table,
4642
4646
  m.Column
4643
4647
  ]);
4644
4648
  }
4645
- function _s(t) {
4649
+ function vs(t) {
4646
4650
  return {
4647
4651
  suggestions: [
4648
- ...Qe({
4652
+ ...He({
4649
4653
  suggestions: [...t.parse.publicSymbolTable().entries()].flatMap(([e]) => {
4650
4654
  const n = oe(e).unwrap_or(void 0);
4651
4655
  if (n === void 0)
@@ -4654,7 +4658,7 @@ function _s(t) {
4654
4658
  return s !== m.Table && s !== m.Schema ? [] : {
4655
4659
  label: i,
4656
4660
  insertText: i,
4657
- insertTextRules: x.KeepWhitespace,
4661
+ insertTextRules: D.KeepWhitespace,
4658
4662
  kind: xe(s),
4659
4663
  range: void 0
4660
4664
  };
@@ -4663,17 +4667,17 @@ function _s(t) {
4663
4667
  ...["Note"].map((e) => ({
4664
4668
  label: e,
4665
4669
  insertText: e,
4666
- insertTextRules: x.KeepWhitespace,
4667
- kind: v.Keyword,
4670
+ insertTextRules: D.KeepWhitespace,
4671
+ kind: w.Keyword,
4668
4672
  range: void 0
4669
4673
  }))
4670
4674
  ]
4671
4675
  };
4672
4676
  }
4673
- function As(t, e) {
4677
+ function ws(t, e) {
4674
4678
  return Kt(t, e);
4675
4679
  }
4676
- function gs(t, e) {
4680
+ function ys(t, e) {
4677
4681
  return {
4678
4682
  suggestions: [
4679
4683
  ...[
@@ -4736,12 +4740,12 @@ function gs(t, e) {
4736
4740
  ].map((n) => ({
4737
4741
  label: n,
4738
4742
  insertText: n,
4739
- insertTextRules: x.KeepWhitespace,
4740
- kind: v.TypeParameter,
4741
- sortText: v.TypeParameter.toString().padStart(2, "0"),
4743
+ insertTextRules: D.KeepWhitespace,
4744
+ kind: w.TypeParameter,
4745
+ sortText: w.TypeParameter.toString().padStart(2, "0"),
4742
4746
  range: void 0
4743
4747
  })),
4744
- ...He(t, e, t.container.element(e), [
4748
+ ...Oe(t, e, t.container.element(e), [
4745
4749
  m.Enum,
4746
4750
  m.Schema
4747
4751
  ]).suggestions
@@ -4750,10 +4754,10 @@ function gs(t, e) {
4750
4754
  }
4751
4755
  function Kt(t, e) {
4752
4756
  const n = t.container.element(e), s = n == null ? void 0 : n.parent;
4753
- if (!((s == null ? void 0 : s.symbol) instanceof Rt))
4754
- return B();
4757
+ if (!((s == null ? void 0 : s.symbol) instanceof Ut))
4758
+ return V();
4755
4759
  const { symbolTable: i } = s.symbol;
4756
- return Qe({
4760
+ return He({
4757
4761
  suggestions: [...i.entries()].flatMap(([a]) => {
4758
4762
  const r = oe(a).unwrap_or(void 0);
4759
4763
  if (r === void 0)
@@ -4762,37 +4766,44 @@ function Kt(t, e) {
4762
4766
  return {
4763
4767
  label: c,
4764
4768
  insertText: c,
4765
- insertTextRules: x.KeepWhitespace,
4769
+ insertTextRules: D.KeepWhitespace,
4766
4770
  kind: xe(m.Column),
4767
4771
  range: void 0
4768
4772
  };
4769
4773
  })
4770
4774
  });
4771
4775
  }
4772
- function ut(t, e) {
4776
+ function ht(t, e) {
4773
4777
  if (!e.callee)
4774
4778
  return -1;
4775
4779
  const n = [e.callee, ...e.args], s = n.findIndex((i) => t <= i.end);
4776
4780
  return s === -1 ? n.length : s;
4777
4781
  }
4778
- class Zt {
4782
+ class en {
4779
4783
  constructor(e) {
4780
4784
  this.compiler = e;
4781
4785
  }
4782
4786
  provideDefinition(e, n) {
4783
- var r;
4784
- const { uri: s } = e, i = ct(e, n), a = [...this.compiler.container.stack(i)];
4787
+ var r, c;
4788
+ const { uri: s } = e, i = ut(e, n), a = [...this.compiler.container.stack(i)];
4785
4789
  for (; a.length !== 0; ) {
4786
- 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)) {
4788
- const { startPos: f, endPos: p } = c.referee.declaration;
4790
+ const f = a.pop();
4791
+ if (!(f != null && f.referee))
4792
+ continue;
4793
+ let p;
4794
+ if ((r = f.referee) != null && r.declaration && [
4795
+ Ie.PRIMARY_EXPRESSION,
4796
+ Ie.VARIABLE,
4797
+ Ie.PARTIAL_INJECTION
4798
+ ].includes(f == null ? void 0 : f.kind) ? { declaration: p } = f.referee : (c = f.referee) != null && c.injectorDeclaration && (p = f.referee.injectorDeclaration), p) {
4799
+ const { startPos: d, endPos: u } = p;
4789
4800
  return [
4790
4801
  {
4791
4802
  range: {
4792
- startColumn: f.column + 1,
4793
- startLineNumber: f.line + 1,
4794
- endColumn: p.column + 1,
4795
- endLineNumber: p.line + 1
4803
+ startColumn: d.column + 1,
4804
+ startLineNumber: d.line + 1,
4805
+ endColumn: u.column + 1,
4806
+ endLineNumber: u.line + 1
4796
4807
  },
4797
4808
  uri: s
4798
4809
  }
@@ -4802,18 +4813,18 @@ class Zt {
4802
4813
  return [];
4803
4814
  }
4804
4815
  }
4805
- class en {
4816
+ class tn {
4806
4817
  constructor(e) {
4807
4818
  this.compiler = e;
4808
4819
  }
4809
4820
  provideReferences(e, n) {
4810
- const { uri: s } = e, i = ct(e, n), a = [...this.compiler.container.stack(i)];
4821
+ const { uri: s } = e, i = ut(e, n), a = [...this.compiler.container.stack(i)];
4811
4822
  for (; a.length !== 0; ) {
4812
4823
  const r = a.pop();
4813
4824
  if (r && [
4814
- _e.ELEMENT_DECLARATION,
4815
- _e.FUNCTION_APPLICATION,
4816
- _e.PRIMARY_EXPRESSION
4825
+ Ie.ELEMENT_DECLARATION,
4826
+ Ie.FUNCTION_APPLICATION,
4827
+ Ie.PRIMARY_EXPRESSION
4817
4828
  ].includes(r == null ? void 0 : r.kind)) {
4818
4829
  const { symbol: c } = r;
4819
4830
  if (c != null && c.references.length)
@@ -4831,21 +4842,21 @@ class en {
4831
4842
  return [];
4832
4843
  }
4833
4844
  }
4834
- const ys = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4845
+ const Ps = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4835
4846
  __proto__: null,
4836
- CompletionItemInsertTextRule: x,
4837
- CompletionItemKind: v,
4838
- DBMLCompletionItemProvider: Qt,
4839
- DBMLDefinitionProvider: Zt,
4840
- DBMLReferencesProvider: en
4847
+ CompletionItemInsertTextRule: D,
4848
+ CompletionItemKind: w,
4849
+ DBMLCompletionItemProvider: Ht,
4850
+ DBMLDefinitionProvider: en,
4851
+ DBMLReferencesProvider: tn
4841
4852
  }, 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 {
4853
+ var O = /* @__PURE__ */ ((t) => (t[t.TABLE = 0] = "TABLE", t[t.ENUM = 1] = "ENUM", t[t.TABLEGROUP = 2] = "TABLEGROUP", t[t.INDEXES = 3] = "INDEXES", t[t.NOTE = 4] = "NOTE", t[t.REF = 5] = "REF", t[t.PROJECT = 6] = "PROJECT", t[t.CUSTOM = 7] = "CUSTOM", t[t.TOPLEVEL = 8] = "TOPLEVEL", t[t.TABLEPARTIAL = 9] = "TABLEPARTIAL", t))(O || {});
4854
+ class xs {
4844
4855
  constructor() {
4845
4856
  this.source = "", this.cache = new Array(
4846
4857
  16
4847
4858
  /* TOTAL_QUERY_COUNT */
4848
- ).fill(null), this.nodeIdGenerator = new rn(), this.symbolIdGenerator = new dn(), this.token = {
4859
+ ).fill(null), this.nodeIdGenerator = new on(), this.symbolIdGenerator = new fn(), this.token = {
4849
4860
  invalidStream: this.createQuery(
4850
4861
  6,
4851
4862
  () => this.parse.tokens().filter(Mt)
@@ -4860,8 +4871,8 @@ class ks {
4860
4871
  _: this.createQuery(
4861
4872
  0,
4862
4873
  () => {
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 })));
4874
+ const e = new yn(this.source).lex().chain((n) => new Pn(n, this.nodeIdGenerator).parse()).chain(({ ast: n, tokens: s }) => new us(n, this.symbolIdGenerator).analyze().map(() => ({ ast: n, tokens: s })));
4875
+ return e.getErrors().length > 0 ? e : e.chain(({ ast: n, tokens: s }) => new ms(n).interpret().map((a) => ({ ast: n, tokens: s, rawDb: a })));
4865
4876
  }
4866
4877
  ),
4867
4878
  ast: this.createQuery(
@@ -4885,14 +4896,14 @@ class ks {
4885
4896
  stack: this.createQuery(
4886
4897
  10,
4887
4898
  (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);
4899
+ 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
4900
  if (a === -1)
4890
4901
  return [this.parse.ast()];
4891
4902
  const r = n[a].start;
4892
4903
  let c = this.parse.ast();
4893
4904
  const f = [c];
4894
4905
  for (; ; ) {
4895
- const d = vn(c).find((u) => ye(r, u));
4906
+ const d = wn(c).find((u) => Se(r, u));
4896
4907
  if (d === void 0 || d instanceof J)
4897
4908
  break;
4898
4909
  f.push(d), c = d;
@@ -4901,16 +4912,16 @@ class ks {
4901
4912
  return f;
4902
4913
  for (; f.length > 0; ) {
4903
4914
  let p = !1;
4904
- const d = Ke(f);
4905
- if (d instanceof w) {
4915
+ const d = Ze(f);
4916
+ if (d instanceof v) {
4906
4917
  const u = this.parse.source();
4907
4918
  for (let E = d.end; E < e; E += 1)
4908
4919
  u[E] === `
4909
4920
  ` && (f.pop(), p = !0);
4910
4921
  } 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);
4922
+ d instanceof ie || d instanceof le ? this.container.token(e).token !== d.op && (f.pop(), p = !0) : d instanceof U ? 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 te || d.end < e && (f.pop(), p = !0);
4912
4923
  if (p) {
4913
- const u = Ke(f);
4924
+ const u = Ze(f);
4914
4925
  u instanceof y && u.end <= e && f.pop();
4915
4926
  }
4916
4927
  if (!p)
@@ -4948,7 +4959,7 @@ class ks {
4948
4959
  ),
4949
4960
  scopeKind: this.createQuery(15, (e) => {
4950
4961
  var s;
4951
- if (this.container.element(e) instanceof K)
4962
+ if (this.container.element(e) instanceof Z)
4952
4963
  return 8;
4953
4964
  switch ((s = this.container.element(e).type) == null ? void 0 : s.value.toLowerCase()) {
4954
4965
  case "table":
@@ -4965,6 +4976,8 @@ class ks {
4965
4976
  return 4;
4966
4977
  case "project":
4967
4978
  return 6;
4979
+ case "tablepartial":
4980
+ return 9;
4968
4981
  default:
4969
4982
  return 7;
4970
4983
  }
@@ -4991,7 +5004,7 @@ class ks {
4991
5004
  let c = [r], f = [];
4992
5005
  for (const p of e)
4993
5006
  f = c.flatMap(
4994
- (d) => fn(p).flatMap((u) => {
5007
+ (d) => In(p).flatMap((u) => {
4995
5008
  const E = d.get(u), b = oe(u).unwrap_or(void 0);
4996
5009
  return !E || !b ? [] : { ...b, symbol: E };
4997
5010
  })
@@ -5034,14 +5047,14 @@ class ks {
5034
5047
  }
5035
5048
  initMonacoServices() {
5036
5049
  return {
5037
- definitionProvider: new Zt(this),
5038
- referenceProvider: new en(this),
5039
- autocompletionProvider: new Qt(this)
5050
+ definitionProvider: new en(this),
5051
+ referenceProvider: new tn(this),
5052
+ autocompletionProvider: new Ht(this)
5040
5053
  };
5041
5054
  }
5042
5055
  }
5043
5056
  export {
5044
- ks as Compiler,
5045
- ws as serialize,
5046
- ys as services
5057
+ xs as Compiler,
5058
+ Ss as serialize,
5059
+ Ps as services
5047
5060
  };