xmlui 0.7.33 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/dist/_commonjsHelpers-BkfeUUK-.mjs +28 -0
  2. package/dist/{apiInterceptorWorker-CE7NtDJI.mjs → apiInterceptorWorker-C5K2aqZR.mjs} +1 -1
  3. package/dist/index-DG5iykVX.mjs +28210 -0
  4. package/dist/index.css +1 -1
  5. package/dist/language-server.d.ts +24 -0
  6. package/dist/language-server.mjs +14331 -0
  7. package/dist/lint-BN6SMVda.mjs +4902 -0
  8. package/dist/parser-Bko8vvFS.mjs +746 -0
  9. package/dist/scripts/src/abstractions/ComponentDefs.js +2 -1
  10. package/dist/scripts/src/components/Accordion/Accordion.js +14 -14
  11. package/dist/scripts/src/components/App/App.js +3 -3
  12. package/dist/scripts/src/components/App/AppNative.js +2 -2
  13. package/dist/scripts/src/components/AppHeader/AppHeader.js +6 -3
  14. package/dist/scripts/src/components/AutoComplete/AutoComplete.js +19 -19
  15. package/dist/scripts/src/components/Avatar/Avatar.js +7 -7
  16. package/dist/scripts/src/components/Badge/Badge.js +8 -8
  17. package/dist/scripts/src/components/Button/Button.js +79 -79
  18. package/dist/scripts/src/components/Card/Card.js +5 -5
  19. package/dist/scripts/src/components/Carousel/Carousel.js +18 -15
  20. package/dist/scripts/src/components/Checkbox/Checkbox.js +14 -14
  21. package/dist/scripts/src/components/ComponentProvider.js +2 -1
  22. package/dist/scripts/src/components/ContentSeparator/ContentSeparator.js +1 -1
  23. package/dist/scripts/src/components/DatePicker/DatePicker.js +9 -9
  24. package/dist/scripts/src/components/DropdownMenu/DropdownMenu.js +17 -17
  25. package/dist/scripts/src/components/FileUploadDropZone/FileUploadDropZone.js +3 -3
  26. package/dist/scripts/src/components/Footer/Footer.js +5 -5
  27. package/dist/scripts/src/components/Form/Form.js +16 -16
  28. package/dist/scripts/src/components/FormItem/FormItem.js +5 -5
  29. package/dist/scripts/src/components/Heading/Heading.js +22 -28
  30. package/dist/scripts/src/components/Heading/HeadingNative.js +2 -1
  31. package/dist/scripts/src/components/HtmlTags/HtmlTags.js +68 -31
  32. package/dist/scripts/src/components/IconRegistryContext.js +243 -242
  33. package/dist/scripts/src/components/Link/Link.js +22 -19
  34. package/dist/scripts/src/components/List/ListNative.js +53 -39
  35. package/dist/scripts/src/components/Markdown/Markdown.js +6 -6
  36. package/dist/scripts/src/components/Markdown/MarkdownNative.js +73 -17
  37. package/dist/scripts/src/components/ModalDialog/ModalDialog.js +2 -2
  38. package/dist/scripts/src/components/NavGroup/NavGroup.js +3 -3
  39. package/dist/scripts/src/components/NavLink/NavLink.js +26 -23
  40. package/dist/scripts/src/components/NavPanel/NavPanel.js +8 -8
  41. package/dist/scripts/src/components/NoResult/NoResult.js +2 -2
  42. package/dist/scripts/src/components/OffCanvas/OffCanvas.js +5 -5
  43. package/dist/scripts/src/components/ProgressBar/ProgressBar.js +4 -4
  44. package/dist/scripts/src/components/RadioGroup/RadioGroup.js +18 -18
  45. package/dist/scripts/src/components/Select/Select.js +21 -21
  46. package/dist/scripts/src/components/Select/SelectNative.js +16 -15
  47. package/dist/scripts/src/components/Slider/Slider.js +11 -11
  48. package/dist/scripts/src/components/Spinner/Spinner.js +2 -2
  49. package/dist/scripts/src/components/Splitter/Splitter.js +1 -1
  50. package/dist/scripts/src/components/StickyBox/StickyBox.js +1 -1
  51. package/dist/scripts/src/components/Switch/Switch.js +18 -18
  52. package/dist/scripts/src/components/Table/Table.js +29 -29
  53. package/dist/scripts/src/components/TableOfContents/TableOfContents.js +27 -27
  54. package/dist/scripts/src/components/TableOfContents/TableOfContentsNative.js +2 -1
  55. package/dist/scripts/src/components/Tabs/Tabs.js +12 -12
  56. package/dist/scripts/src/components/Text/Text.js +60 -61
  57. package/dist/scripts/src/components/TextBox/TextBox.js +17 -17
  58. package/dist/scripts/src/components/Theme/ThemeNative.js +1 -1
  59. package/dist/scripts/src/components-core/descriptorHelper.js +7 -7
  60. package/dist/scripts/src/components-core/theming/layout-resolver.js +26 -26
  61. package/dist/scripts/src/components-core/theming/themes/base-utils.js +7 -23
  62. package/dist/scripts/src/components-core/theming/themes/root.js +101 -114
  63. package/dist/scripts/src/components-core/theming/themes/solid.js +3 -3
  64. package/dist/scripts/src/components-core/theming/themes/xmlui.js +4 -4
  65. package/dist/scripts/src/components-core/theming/transformThemeVars.js +189 -189
  66. package/dist/scripts/src/components-core/utils/hooks.js +2 -2
  67. package/dist/scripts/src/parsers/scripting/Parser.js +2 -2
  68. package/dist/style.css +1 -1
  69. package/dist/xmlui-metadata.mjs +8534 -8204
  70. package/dist/xmlui-metadata.umd.js +11 -11
  71. package/dist/xmlui-parser.d.ts +1 -0
  72. package/dist/xmlui-parser.mjs +53 -52
  73. package/dist/xmlui-standalone.umd.js +174 -174
  74. package/dist/xmlui.d.ts +5 -4
  75. package/dist/xmlui.mjs +13 -12
  76. package/package.json +11 -5
  77. package/dist/index-lMqf6HyK.mjs +0 -27841
  78. package/dist/lint-DgP_MIP6.mjs +0 -5645
  79. package/dist/scripts/bin/language-server.js +0 -11
  80. package/dist/scripts/src/components-core/abstractions/standalone.js +0 -2
  81. package/dist/scripts/src/components-core/interception/abstractions.js +0 -2
  82. package/dist/scripts/src/language-server/metadata.js +0 -8206
  83. package/dist/scripts/src/language-server/server.js +0 -135
  84. package/dist/scripts/src/language-server/services/completion.js +0 -100
  85. package/dist/scripts/src/language-server/services/hover.js +0 -170
  86. package/dist/scripts/src/language-server/services/syntax-node-utilities.js +0 -22
  87. package/dist/scripts/src/parsers/xmlui-parser/index.js +0 -29
  88. package/dist/scripts/src/parsers/xmlui-parser/lint.js +0 -177
  89. package/dist/scripts/src/parsers/xmlui-parser/xmlui-serializer.js +0 -582
  90. package/dist/scripts/src/parsers/xmlui-parser/xmlui-tree.js +0 -2
@@ -0,0 +1,4902 @@
1
+ import { parseRegExpLiteral as de } from "@eslint-community/regexpp";
2
+ import { S as k, C as R } from "./parser-Bko8vvFS.mjs";
3
+ const fr = [
4
+ {
5
+ value: "_self",
6
+ description: "The link will open in the same frame as it was clicked."
7
+ },
8
+ {
9
+ value: "_blank",
10
+ description: "The link will open in a new window or tab."
11
+ },
12
+ {
13
+ value: "_parent",
14
+ description: "The link will open in the parent frame. If no parent, behaves as _self."
15
+ },
16
+ {
17
+ value: "_top",
18
+ description: "The topmost browsing context. The link will open in the full body of the window. If no ancestors, behaves as _self."
19
+ },
20
+ {
21
+ value: "_unfencedTop",
22
+ description: "Allows embedded fenced frames to navigate the top-level frame, i.e. traversing beyond the root of the fenced frame."
23
+ }
24
+ ], ye = [
25
+ {
26
+ value: "xs",
27
+ description: "Extra small devices (e.g., a small smartphone with low screen resolution)"
28
+ },
29
+ { value: "sm", description: "Small devices (e.g., a smartphone in landscape view)" },
30
+ { value: "md", description: "Medium devices (e.g., a tablet)" },
31
+ { value: "lg", description: "Large devices (e.g., a laptop)" },
32
+ { value: "xl", description: 'Extra large devices (e.g., a standard 20" monitor)' },
33
+ { value: "xxl", description: 'Extra extra large devices (e.g., a large 29" monitor)' }
34
+ ], pr = Object.keys(ye), Ie = [
35
+ { value: "xs", description: "Extra small button" },
36
+ { value: "sm", description: "Small button" },
37
+ { value: "md", description: "Medium button" },
38
+ { value: "lg", description: "Large button" }
39
+ ], Oe = Object.keys(Ie);
40
+ [...Oe];
41
+ const We = ["attention", "primary", "secondary"], gr = [...We], kr = [
42
+ { value: "attention", description: "Attention state theme color" },
43
+ { value: "primary", description: "Primary theme color" },
44
+ { value: "secondary", description: "Secondary theme color" }
45
+ ], Er = [
46
+ {
47
+ value: "button",
48
+ description: "Regular behavior that only executes logic if explicitly determined."
49
+ },
50
+ {
51
+ value: "submit",
52
+ description: "The button submits the form data to the server. This is the default for buttons in a Form or NativeForm component."
53
+ },
54
+ {
55
+ value: "reset",
56
+ description: "Resets all the controls to their initial values. Using it is ill advised for UX reasons."
57
+ }
58
+ ], Be = ["solid", "outlined", "ghost"], xr = [...Be], mr = [
59
+ { value: "solid", description: "A button with a border and a filled background." },
60
+ {
61
+ value: "outlined",
62
+ description: "The button is displayed with a border and a transparent background."
63
+ },
64
+ {
65
+ value: "ghost",
66
+ description: "A button with no border and fill. Only the label is visible; the background is colored when hovered or clicked."
67
+ }
68
+ ], Pe = ["start", "center", "end"];
69
+ [...Pe];
70
+ const Sr = [
71
+ { value: "center", description: "Place the content in the middle" },
72
+ {
73
+ value: "start",
74
+ description: "Justify the content to the left (to the right if in right-to-left)"
75
+ },
76
+ {
77
+ value: "end",
78
+ description: "Justify the content to the right (to the left if in right-to-left)"
79
+ }
80
+ ], _r = [
81
+ { value: "horizontal", description: "The component will fill the available space horizontally" },
82
+ { value: "vertical", description: "The component will fill the available space vertically" }
83
+ ], Re = ["start", "end"], Lr = [...Re], wr = [
84
+ {
85
+ value: "start",
86
+ description: "The icon will appear at the start (left side when the left-to-right direction is set)"
87
+ },
88
+ {
89
+ value: "end",
90
+ description: "The icon will appear at the end (right side when the left-to-right direction is set)"
91
+ }
92
+ ], Cr = [
93
+ { value: "primary", description: "Primary theme color, no default icon" },
94
+ { value: "secondary", description: "Secondary theme color, no default icon" },
95
+ { value: "success", description: 'Success theme color, "success" icon' },
96
+ { value: "danger", description: 'Warning theme color, "warning" icon' },
97
+ { value: "warning", description: 'Danger theme color, "danger" icon' },
98
+ { value: "info", description: 'Info theme color, "info" icon' },
99
+ { value: "light", description: "Light theme color, no default icon" },
100
+ { value: "dark", description: "Dark theme color, no default icon" }
101
+ ], Ar = [
102
+ {
103
+ value: "start",
104
+ description: "The left side of the window (left-to-right) or the right side of the window (right-to-left)"
105
+ },
106
+ {
107
+ value: "end",
108
+ description: "The right side of the window (left-to-right) or the left side of the window (right-to-left)"
109
+ },
110
+ { value: "top", description: "The top of the window" },
111
+ { value: "bottom", description: "The bottom of the window" }
112
+ ], vr = [
113
+ {
114
+ value: "start",
115
+ description: "The left side of the input (left-to-right) or the right side of the input (right-to-left)"
116
+ },
117
+ {
118
+ value: "end",
119
+ description: "The right side of the input (left-to-right) or the left side of the input (right-to-left)"
120
+ },
121
+ { value: "top", description: "The top of the input" },
122
+ { value: "bottom", description: "The bottom of the input" }
123
+ ], Fe = ["start", "end"], yr = [...Fe], br = [
124
+ // { value: "none", description: "No indicator" },
125
+ { value: "valid", description: "Visual indicator for an input that is accepted" },
126
+ { value: "warning", description: "Visual indicator for an input that produced a warning" },
127
+ { value: "error", description: "Visual indicator for an input that produced an error" }
128
+ ], Ue = ["top", "bottom"];
129
+ [...Ue];
130
+ const Nr = {
131
+ abbr: "abbr",
132
+ cite: "cite",
133
+ code: "code",
134
+ codefence: "pre",
135
+ deleted: "del",
136
+ inserted: "ins",
137
+ keyboard: "kbd",
138
+ marked: "mark",
139
+ sample: "samp",
140
+ sub: "sub",
141
+ sup: "sup",
142
+ var: "var",
143
+ mono: "pre",
144
+ strong: "strong",
145
+ em: "em",
146
+ title: "span",
147
+ subtitle: "span",
148
+ small: "span",
149
+ caption: "span",
150
+ placeholder: "span",
151
+ paragraph: "p",
152
+ subheading: "h6",
153
+ tableheading: "h6",
154
+ secondary: "span"
155
+ }, Dr = [
156
+ { value: "abbr", description: "Represents an abbreviation or acronym" },
157
+ { value: "caption", description: "Represents the caption (or title) of a table" },
158
+ { value: "cite", description: "Is used to mark up the title of a cited work" },
159
+ { value: "code", description: "Represents a line of code" },
160
+ {
161
+ value: "codefence",
162
+ description: "Handles the display of code blocks if combined with a `code` variant"
163
+ },
164
+ { value: "deleted", description: "Represents text that has been deleted" },
165
+ { value: "em", description: "Marks text to stress emphasis" },
166
+ {
167
+ value: "inserted",
168
+ description: "Represents a range of text that has been added to a document"
169
+ },
170
+ {
171
+ value: "keyboard",
172
+ description: "Represents a span of text denoting textual user input from a keyboard or voice input"
173
+ },
174
+ {
175
+ value: "marked",
176
+ description: "Represents text which is marked or highlighted for reference or notation"
177
+ },
178
+ { value: "mono", description: "Text using a mono style font family" },
179
+ { value: "paragraph", description: "Represents a paragraph" },
180
+ {
181
+ value: "placeholder",
182
+ description: "Text that is mostly used as the placeholder style in input controls"
183
+ },
184
+ { value: "sample", description: "Represents sample (or quoted) output from a computer program" },
185
+ { value: "secondary", description: "Represents a bit dimmed secondary text" },
186
+ { value: "small", description: "Represents side-comments and small print" },
187
+ { value: "sub", description: "Specifies inline text as subscript" },
188
+ { value: "strong", description: "Contents have strong importance" },
189
+ { value: "subheading", description: "Indicates that the text is the subtitle in a heading" },
190
+ {
191
+ value: "subtitle",
192
+ description: "Indicates that the text is the subtitle of some other content"
193
+ },
194
+ { value: "sup", description: "Specifies inline text as superscript" },
195
+ { value: "tableheading", description: "Indicates that the text is a table heading" },
196
+ { value: "title", description: "Indicates that the text is the title of some other content" },
197
+ { value: "var", description: "Represents the name of a variable in a mathematical expression" }
198
+ ], Me = ["title"], qe = ["cite", "dateTime"], Ir = [...Me, ...qe], Or = [
199
+ "get",
200
+ "post",
201
+ "put",
202
+ "delete",
203
+ "patch",
204
+ "head",
205
+ "options",
206
+ "trace",
207
+ "connect"
208
+ ];
209
+ var i = /* @__PURE__ */ ((n) => (n[n.Eof = -1] = "Eof", n[n.Ws = -2] = "Ws", n[n.BlockComment = -3] = "BlockComment", n[n.EolComment = -4] = "EolComment", n[n.Unknown = 0] = "Unknown", n[n.LParent = 1] = "LParent", n[n.RParent = 2] = "RParent", n[n.Identifier = 3] = "Identifier", n[n.Exponent = 4] = "Exponent", n[n.Divide = 5] = "Divide", n[n.Multiply = 6] = "Multiply", n[n.Remainder = 7] = "Remainder", n[n.Plus = 8] = "Plus", n[n.Minus = 9] = "Minus", n[n.BitwiseXor = 10] = "BitwiseXor", n[n.BitwiseOr = 11] = "BitwiseOr", n[n.LogicalOr = 12] = "LogicalOr", n[n.BitwiseAnd = 13] = "BitwiseAnd", n[n.LogicalAnd = 14] = "LogicalAnd", n[n.IncOp = 15] = "IncOp", n[n.DecOp = 16] = "DecOp", n[n.Assignment = 17] = "Assignment", n[n.AddAssignment = 18] = "AddAssignment", n[n.SubtractAssignment = 19] = "SubtractAssignment", n[n.ExponentAssignment = 20] = "ExponentAssignment", n[n.MultiplyAssignment = 21] = "MultiplyAssignment", n[n.DivideAssignment = 22] = "DivideAssignment", n[n.RemainderAssignment = 23] = "RemainderAssignment", n[n.ShiftLeftAssignment = 24] = "ShiftLeftAssignment", n[n.ShiftRightAssignment = 25] = "ShiftRightAssignment", n[n.SignedShiftRightAssignment = 26] = "SignedShiftRightAssignment", n[n.BitwiseAndAssignment = 27] = "BitwiseAndAssignment", n[n.BitwiseXorAssignment = 28] = "BitwiseXorAssignment", n[n.BitwiseOrAssignment = 29] = "BitwiseOrAssignment", n[n.LogicalAndAssignment = 30] = "LogicalAndAssignment", n[n.LogicalOrAssignment = 31] = "LogicalOrAssignment", n[n.NullCoalesceAssignment = 32] = "NullCoalesceAssignment", n[n.Semicolon = 33] = "Semicolon", n[n.Comma = 34] = "Comma", n[n.Colon = 35] = "Colon", n[n.LSquare = 36] = "LSquare", n[n.RSquare = 37] = "RSquare", n[n.QuestionMark = 38] = "QuestionMark", n[n.NullCoalesce = 39] = "NullCoalesce", n[n.OptionalChaining = 40] = "OptionalChaining", n[n.BinaryNot = 41] = "BinaryNot", n[n.LBrace = 42] = "LBrace", n[n.RBrace = 43] = "RBrace", n[n.Equal = 44] = "Equal", n[n.StrictEqual = 45] = "StrictEqual", n[n.LogicalNot = 46] = "LogicalNot", n[n.NotEqual = 47] = "NotEqual", n[n.StrictNotEqual = 48] = "StrictNotEqual", n[n.LessThan = 49] = "LessThan", n[n.LessThanOrEqual = 50] = "LessThanOrEqual", n[n.ShiftLeft = 51] = "ShiftLeft", n[n.GreaterThan = 52] = "GreaterThan", n[n.GreaterThanOrEqual = 53] = "GreaterThanOrEqual", n[n.ShiftRight = 54] = "ShiftRight", n[n.SignedShiftRight = 55] = "SignedShiftRight", n[n.Dot = 56] = "Dot", n[n.Spread = 57] = "Spread", n[n.Global = 58] = "Global", n[n.Backtick = 59] = "Backtick", n[n.DollarLBrace = 60] = "DollarLBrace", n[n.Arrow = 61] = "Arrow", n[n.DecimalLiteral = 62] = "DecimalLiteral", n[n.HexadecimalLiteral = 63] = "HexadecimalLiteral", n[n.BinaryLiteral = 64] = "BinaryLiteral", n[n.RealLiteral = 65] = "RealLiteral", n[n.StringLiteral = 66] = "StringLiteral", n[n.Infinity = 67] = "Infinity", n[n.NaN = 68] = "NaN", n[n.True = 69] = "True", n[n.False = 70] = "False", n[n.Typeof = 71] = "Typeof", n[n.Null = 72] = "Null", n[n.Undefined = 73] = "Undefined", n[n.In = 74] = "In", n[n.Let = 75] = "Let", n[n.Const = 76] = "Const", n[n.Var = 77] = "Var", n[n.If = 78] = "If", n[n.Else = 79] = "Else", n[n.Return = 80] = "Return", n[n.Break = 81] = "Break", n[n.Continue = 82] = "Continue", n[n.Do = 83] = "Do", n[n.While = 84] = "While", n[n.For = 85] = "For", n[n.Of = 86] = "Of", n[n.Try = 87] = "Try", n[n.Catch = 88] = "Catch", n[n.Finally = 89] = "Finally", n[n.Throw = 90] = "Throw", n[n.Switch = 91] = "Switch", n[n.Case = 92] = "Case", n[n.Default = 93] = "Default", n[n.Delete = 94] = "Delete", n[n.Function = 95] = "Function", n[n.Export = 96] = "Export", n[n.Import = 97] = "Import", n[n.As = 98] = "As", n[n.From = 99] = "From", n))(i || {});
210
+ class $e {
211
+ // Creates a stream that uses the specified source code
212
+ constructor(e) {
213
+ this.source = e, this._pos = 0, this._line = 1, this._column = 0;
214
+ }
215
+ // Gets the current position in the stream. Starts from 0.
216
+ get position() {
217
+ return this._pos;
218
+ }
219
+ // Gets the current line number. Starts from 1.
220
+ get line() {
221
+ return this._line;
222
+ }
223
+ // Gets the current column number. Starts from 0.
224
+ get column() {
225
+ return this._column;
226
+ }
227
+ // Peeks the next character in the stream. Returns null, if EOF; otherwise the current source code character
228
+ peek() {
229
+ return this.ahead(0);
230
+ }
231
+ // Looks ahead with `n` characters in the stream. Returns null, if EOF; otherwise the look-ahead character
232
+ ahead(e = 1) {
233
+ return this._pos + e > this.source.length - 1 ? null : this.source[this._pos + e];
234
+ }
235
+ // Gets the next character from the stream
236
+ get() {
237
+ if (this._pos >= this.source.length)
238
+ return null;
239
+ const e = this.source[this._pos++];
240
+ return e === `
241
+ ` ? (this._line++, this._column = 0) : this._column++, e;
242
+ }
243
+ // Gets the tail of the input stream
244
+ getTail(e) {
245
+ var r;
246
+ return ((r = this.source) == null ? void 0 : r.substring(e)) ?? "";
247
+ }
248
+ }
249
+ const j = {
250
+ [i.Eof]: {},
251
+ [i.Ws]: {},
252
+ [i.DollarLBrace]: {},
253
+ [i.Backtick]: { expressionStart: !0 },
254
+ [i.BlockComment]: {},
255
+ [i.EolComment]: {},
256
+ [i.Unknown]: {},
257
+ [i.LParent]: { expressionStart: !0 },
258
+ [i.RParent]: {},
259
+ [i.Identifier]: { expressionStart: !0, keywordLike: !0, isPropLiteral: !0 },
260
+ [i.Exponent]: {},
261
+ [i.Divide]: {},
262
+ [i.Multiply]: {},
263
+ [i.Remainder]: {},
264
+ [i.Plus]: { expressionStart: !0, canBeUnary: !0 },
265
+ [i.Minus]: { expressionStart: !0, canBeUnary: !0 },
266
+ [i.BitwiseXor]: {},
267
+ [i.BitwiseOr]: {},
268
+ [i.LogicalOr]: {},
269
+ [i.BitwiseAnd]: {},
270
+ [i.LogicalAnd]: {},
271
+ [i.Assignment]: { isAssignment: !0 },
272
+ [i.AddAssignment]: { isAssignment: !0 },
273
+ [i.SubtractAssignment]: { isAssignment: !0 },
274
+ [i.ExponentAssignment]: { isAssignment: !0 },
275
+ [i.MultiplyAssignment]: { isAssignment: !0 },
276
+ [i.DivideAssignment]: { isAssignment: !0 },
277
+ [i.RemainderAssignment]: { isAssignment: !0 },
278
+ [i.ShiftLeftAssignment]: { isAssignment: !0 },
279
+ [i.ShiftRightAssignment]: { isAssignment: !0 },
280
+ [i.SignedShiftRightAssignment]: { isAssignment: !0 },
281
+ [i.BitwiseAndAssignment]: { isAssignment: !0 },
282
+ [i.BitwiseXorAssignment]: { isAssignment: !0 },
283
+ [i.BitwiseOrAssignment]: { isAssignment: !0 },
284
+ [i.LogicalAndAssignment]: { isAssignment: !0 },
285
+ [i.LogicalOrAssignment]: { isAssignment: !0 },
286
+ [i.NullCoalesceAssignment]: { isAssignment: !0 },
287
+ [i.Semicolon]: {},
288
+ [i.Comma]: {},
289
+ [i.Colon]: {},
290
+ [i.LSquare]: { expressionStart: !0 },
291
+ [i.RSquare]: {},
292
+ [i.QuestionMark]: {},
293
+ [i.NullCoalesce]: {},
294
+ [i.OptionalChaining]: {},
295
+ [i.BinaryNot]: { expressionStart: !0, canBeUnary: !0 },
296
+ [i.LBrace]: { expressionStart: !0 },
297
+ [i.RBrace]: {},
298
+ [i.Equal]: {},
299
+ [i.StrictEqual]: {},
300
+ [i.LogicalNot]: { expressionStart: !0, canBeUnary: !0 },
301
+ [i.NotEqual]: {},
302
+ [i.StrictNotEqual]: {},
303
+ [i.LessThan]: {},
304
+ [i.LessThanOrEqual]: {},
305
+ [i.ShiftLeft]: {},
306
+ [i.GreaterThan]: {},
307
+ [i.GreaterThanOrEqual]: {},
308
+ [i.ShiftRight]: {},
309
+ [i.SignedShiftRight]: {},
310
+ [i.Dot]: {},
311
+ [i.Spread]: { expressionStart: !0, isPropLiteral: !0 },
312
+ [i.Global]: { expressionStart: !0 },
313
+ [i.DecimalLiteral]: { expressionStart: !0, isPropLiteral: !0 },
314
+ [i.HexadecimalLiteral]: { expressionStart: !0, isPropLiteral: !0 },
315
+ [i.BinaryLiteral]: { expressionStart: !0, isPropLiteral: !0 },
316
+ [i.RealLiteral]: { expressionStart: !0, isPropLiteral: !0 },
317
+ [i.StringLiteral]: { expressionStart: !0, isPropLiteral: !0 },
318
+ [i.IncOp]: { expressionStart: !0 },
319
+ [i.DecOp]: { expressionStart: !0 },
320
+ [i.Infinity]: { expressionStart: !0, keywordLike: !0 },
321
+ [i.NaN]: { expressionStart: !0, keywordLike: !0 },
322
+ [i.True]: { expressionStart: !0, keywordLike: !0, isPropLiteral: !0 },
323
+ [i.False]: { expressionStart: !0, keywordLike: !0, isPropLiteral: !0 },
324
+ [i.Typeof]: { expressionStart: !0, canBeUnary: !0, keywordLike: !0 },
325
+ [i.Null]: { expressionStart: !0, keywordLike: !0 },
326
+ [i.Undefined]: { expressionStart: !0, keywordLike: !0 },
327
+ [i.In]: { keywordLike: !0 },
328
+ [i.Let]: { keywordLike: !0 },
329
+ [i.Const]: { keywordLike: !0 },
330
+ [i.Var]: { keywordLike: !0 },
331
+ [i.If]: { keywordLike: !0 },
332
+ [i.Else]: { keywordLike: !0 },
333
+ [i.Arrow]: { keywordLike: !0 },
334
+ [i.Return]: { keywordLike: !0 },
335
+ [i.Break]: { keywordLike: !0 },
336
+ [i.Continue]: { keywordLike: !0 },
337
+ [i.Do]: { keywordLike: !0 },
338
+ [i.While]: { keywordLike: !0 },
339
+ [i.For]: { keywordLike: !0 },
340
+ [i.Of]: { keywordLike: !0 },
341
+ [i.Throw]: { keywordLike: !0 },
342
+ [i.Try]: { keywordLike: !0 },
343
+ [i.Catch]: { keywordLike: !0 },
344
+ [i.Finally]: { keywordLike: !0 },
345
+ [i.Switch]: { keywordLike: !0 },
346
+ [i.Case]: { keywordLike: !0 },
347
+ [i.Default]: { keywordLike: !0 },
348
+ [i.Delete]: { expressionStart: !0, canBeUnary: !0, keywordLike: !0 },
349
+ [i.Function]: { keywordLike: !0, expressionStart: !0 },
350
+ [i.Export]: { keywordLike: !0 },
351
+ [i.Import]: { keywordLike: !0 },
352
+ [i.As]: { keywordLike: !0 },
353
+ [i.From]: { keywordLike: !0 }
354
+ };
355
+ class ze {
356
+ /**
357
+ * Initializes the tokenizer with the input stream
358
+ * @param input Input source code stream
359
+ */
360
+ constructor(e) {
361
+ this.input = e, this._ahead = [], this._prefetched = null, this._prefetchedPos = null, this._prefetchedColumn = null, this._lastFetchPosition = 0, this._phaseExternallySet = null;
362
+ }
363
+ /**
364
+ * Fetches the next token without advancing to its position
365
+ * @param ws If true, retrieve whitespaces too
366
+ */
367
+ peek(e = !1) {
368
+ return this.ahead(0, e);
369
+ }
370
+ /**
371
+ * Reads tokens ahead
372
+ * @param n Number of token positions to read ahead
373
+ * @param ws If true, retrieve whitespaces too
374
+ */
375
+ ahead(e = 1, r = !1) {
376
+ if (e > 16)
377
+ throw new Error("Cannot look ahead more than 16 tokens");
378
+ for (; this._ahead.length <= e; ) {
379
+ const t = this.fetch();
380
+ if (fe(t))
381
+ return t;
382
+ (r || !r && !pe(t)) && this._ahead.push(t);
383
+ }
384
+ return this._ahead[e];
385
+ }
386
+ /**
387
+ * Fetches the next token and advances the stream position
388
+ * @param ws If true, retrieve whitespaces too
389
+ */
390
+ get(e = !1) {
391
+ if (this._ahead.length > 0) {
392
+ const r = this._ahead.shift();
393
+ if (!r)
394
+ throw new Error("Token expected");
395
+ return r;
396
+ }
397
+ for (; ; ) {
398
+ const r = this.fetch();
399
+ if (fe(r) || e || !e && !pe(r))
400
+ return r;
401
+ }
402
+ }
403
+ /**
404
+ * Gets a RegEx from the current position
405
+ */
406
+ getRegEx() {
407
+ return this.fetchRegEx();
408
+ }
409
+ /**
410
+ * Gets the remaining characters after the parsing phase
411
+ */
412
+ getTail() {
413
+ return this._ahead.length > 0 ? this.input.getTail(this._ahead[0].location.startPosition) : this.input.getTail(this._lastFetchPosition);
414
+ }
415
+ /**
416
+ * Parsing template literals requires a context sensitive lexer.
417
+ * This method has to be called by the parser when the lexer needs to scan a string inside a template literal.
418
+ * Call this after the first opening backing and after the parser is done with parsing a placeholder, after the right brace.
419
+ */
420
+ setStartingPhaseToTemplateLiteral() {
421
+ this._phaseExternallySet = 33;
422
+ }
423
+ /**
424
+ * Fetches the next character from the input stream
425
+ */
426
+ fetchNextChar() {
427
+ return this._prefetched || (this._prefetchedPos = this.input.position, this._prefetchedColumn = this.input.column, this._prefetched = this.input.get()), this._prefetched;
428
+ }
429
+ /**
430
+ * Fetches the next token from the input stream
431
+ */
432
+ fetch() {
433
+ const e = this, r = this.input, t = this._prefetchedPos || r.position, l = r.line, a = this._prefetchedColumn || r.column;
434
+ this._lastFetchPosition = this.input.position;
435
+ let o = null, c = "", s = i.Eof, D = r.position, L = r.column, u = null, O = !1, p = this.getStartingPhaseThenReset();
436
+ for (; ; ) {
437
+ if (u = this.fetchNextChar(), u === null)
438
+ return m();
439
+ s === i.Eof && (s = i.Unknown);
440
+ e: switch (p) {
441
+ case 0:
442
+ switch (u) {
443
+ case " ":
444
+ case " ":
445
+ case `
446
+ `:
447
+ case "\r":
448
+ p = 1, s = i.Ws;
449
+ break;
450
+ case "/":
451
+ p = 5, s = i.Divide;
452
+ break;
453
+ case "$":
454
+ p = 6, s = i.Identifier;
455
+ break;
456
+ case "*":
457
+ p = 8, s = i.Multiply;
458
+ break;
459
+ case "%":
460
+ p = 54, s = i.Remainder;
461
+ break;
462
+ case "+":
463
+ p = 51, s = i.Plus;
464
+ break;
465
+ case "-":
466
+ p = 52, s = i.Minus;
467
+ break;
468
+ case "^":
469
+ p = 58, s = i.BitwiseXor;
470
+ break;
471
+ case "|":
472
+ p = 7, s = i.BitwiseOr;
473
+ break;
474
+ case "&":
475
+ p = 9, s = i.BitwiseAnd;
476
+ break;
477
+ case "?":
478
+ p = 22, s = i.QuestionMark;
479
+ break;
480
+ case ";":
481
+ return E(i.Semicolon);
482
+ case ",":
483
+ return E(i.Comma);
484
+ case "(":
485
+ return E(i.LParent);
486
+ case ")":
487
+ return E(i.RParent);
488
+ case ":":
489
+ p = 20, s = i.Colon;
490
+ break;
491
+ case "`":
492
+ return E(i.Backtick);
493
+ case "[":
494
+ return E(i.LSquare);
495
+ case "]":
496
+ return E(i.RSquare);
497
+ case "~":
498
+ return E(i.BinaryNot);
499
+ case "{":
500
+ return E(i.LBrace);
501
+ case "}":
502
+ return E(i.RBrace);
503
+ case "=":
504
+ p = 10, s = i.Assignment;
505
+ break;
506
+ case "!":
507
+ p = 13, s = i.LogicalNot;
508
+ break;
509
+ case "<":
510
+ p = 14, s = i.LessThan;
511
+ break;
512
+ case ">":
513
+ p = 15, s = i.GreaterThan;
514
+ break;
515
+ case "0":
516
+ p = 21, s = i.DecimalLiteral;
517
+ break;
518
+ case ".":
519
+ p = 18, s = i.Dot;
520
+ break;
521
+ case '"':
522
+ case "'":
523
+ o = u, p = 35;
524
+ break;
525
+ default:
526
+ ge(u) ? (O = !0, p = 17, s = i.Identifier) : Z(u) ? (p = 27, s = i.DecimalLiteral) : E(i.Unknown);
527
+ break;
528
+ }
529
+ break;
530
+ case 6:
531
+ if (u === "{")
532
+ return E(i.DollarLBrace);
533
+ p = 17, O = !0, s = i.Identifier, ke(u) || m();
534
+ break;
535
+ case 1:
536
+ if (u !== " " && u !== " " && u !== "\r" && u !== `
537
+ `)
538
+ return m();
539
+ break;
540
+ case 3:
541
+ u === "*" && (p = 4);
542
+ break;
543
+ case 4:
544
+ if (u === "/")
545
+ return E(i.BlockComment);
546
+ break;
547
+ case 2:
548
+ if (u === `
549
+ `)
550
+ return E();
551
+ break;
552
+ case 17:
553
+ if (!ke(u))
554
+ return m();
555
+ break;
556
+ case 20:
557
+ return u === ":" ? E(i.Global) : m();
558
+ case 5:
559
+ if (u === "*")
560
+ p = 3;
561
+ else if (u === "/")
562
+ p = 2, s = i.EolComment;
563
+ else return u === "=" ? E(i.DivideAssignment) : m();
564
+ break;
565
+ case 51:
566
+ return u === "+" ? E(i.IncOp) : u === "=" ? E(i.AddAssignment) : m();
567
+ case 52:
568
+ return u === "-" ? E(i.DecOp) : u === "=" ? E(i.SubtractAssignment) : m();
569
+ case 54:
570
+ return u === "=" ? E(i.RemainderAssignment) : m();
571
+ case 58:
572
+ return u === "=" ? E(i.BitwiseXorAssignment) : m();
573
+ case 7:
574
+ if (u === "=")
575
+ return E(i.BitwiseOrAssignment);
576
+ if (u === "|") {
577
+ p = 59, s = i.LogicalOr;
578
+ break;
579
+ }
580
+ return m();
581
+ case 59:
582
+ return u === "=" ? E(i.LogicalOrAssignment) : m();
583
+ case 9:
584
+ if (u === "=")
585
+ return E(i.BitwiseAndAssignment);
586
+ if (u === "&") {
587
+ p = 57, s = i.LogicalAnd;
588
+ break;
589
+ }
590
+ return m();
591
+ case 57:
592
+ return u === "=" ? E(i.LogicalAndAssignment) : m();
593
+ case 8:
594
+ if (u === "*") {
595
+ p = 50, s = i.Exponent;
596
+ break;
597
+ } else if (u === "=")
598
+ return E(i.MultiplyAssignment);
599
+ return m();
600
+ case 50:
601
+ return u === "=" ? E(i.ExponentAssignment) : m();
602
+ case 22:
603
+ if (u === "?") {
604
+ p = 60, s = i.NullCoalesce;
605
+ break;
606
+ }
607
+ return u === "." ? E(i.OptionalChaining) : m();
608
+ case 60:
609
+ return u === "=" ? E(i.NullCoalesceAssignment) : m();
610
+ case 10:
611
+ if (u === ">")
612
+ return E(i.Arrow);
613
+ if (u === "=") {
614
+ p = 11, s = i.Equal;
615
+ break;
616
+ }
617
+ return m();
618
+ case 11:
619
+ return u === "=" ? E(i.StrictEqual) : m();
620
+ case 13:
621
+ if (u === "=") {
622
+ p = 12, s = i.NotEqual;
623
+ break;
624
+ }
625
+ return m();
626
+ case 12:
627
+ return u === "=" ? E(i.StrictNotEqual) : m();
628
+ case 14:
629
+ if (u === "=")
630
+ return E(i.LessThanOrEqual);
631
+ if (u === "<") {
632
+ p = 55, s = i.ShiftLeft;
633
+ break;
634
+ }
635
+ return m();
636
+ case 55:
637
+ return u === "=" ? E(i.ShiftLeftAssignment) : m();
638
+ case 15:
639
+ if (u === "=")
640
+ return E(i.GreaterThanOrEqual);
641
+ if (u === ">") {
642
+ p = 16, s = i.SignedShiftRight;
643
+ break;
644
+ }
645
+ return m();
646
+ case 16:
647
+ if (u === ">") {
648
+ p = 56, s = i.ShiftRight;
649
+ break;
650
+ }
651
+ return u === "=" ? E(i.SignedShiftRightAssignment) : m();
652
+ case 56:
653
+ return u === "=" ? E(i.ShiftRightAssignment) : m();
654
+ case 21:
655
+ if (u === "x")
656
+ p = 23, s = i.Unknown;
657
+ else if (u === "b")
658
+ p = 25, s = i.Unknown;
659
+ else if (Z(u) || u === "_")
660
+ p = 27;
661
+ else if (u === ".")
662
+ p = 28, s = i.Unknown;
663
+ else if (u === "e" || u === "E")
664
+ p = 30, s = i.Unknown;
665
+ else
666
+ return m();
667
+ break;
668
+ case 18:
669
+ if (u === ".") {
670
+ p = 19, s = i.Unknown;
671
+ break;
672
+ }
673
+ if (!Z(u))
674
+ return m();
675
+ p = 29, s = i.RealLiteral;
676
+ break;
677
+ case 19:
678
+ return u === "." ? E(i.Spread) : m();
679
+ case 23:
680
+ if (u === "_")
681
+ break;
682
+ if (!z(u))
683
+ return m();
684
+ p = 24, s = i.HexadecimalLiteral;
685
+ break;
686
+ case 24:
687
+ if (!z(u) && u !== "_")
688
+ return m();
689
+ break;
690
+ case 25:
691
+ if (u === "_")
692
+ break;
693
+ if (!Ee(u))
694
+ return m();
695
+ p = 26, s = i.BinaryLiteral;
696
+ break;
697
+ case 26:
698
+ if (!Ee(u) && u !== "_")
699
+ return m();
700
+ s = i.BinaryLiteral;
701
+ break;
702
+ case 27:
703
+ if (Z(u) || u === "_")
704
+ break;
705
+ if (u === "." && (this.input.peek() === null || Z(this.input.peek())))
706
+ p = 28, s = i.Unknown;
707
+ else if (u === "e" || u === "E")
708
+ p = 30, s = i.Unknown;
709
+ else
710
+ return m();
711
+ break;
712
+ case 28:
713
+ if (Z(u))
714
+ p = 29, s = i.RealLiteral;
715
+ else if (u === "e" || u === "E")
716
+ p = 30;
717
+ else
718
+ return m();
719
+ break;
720
+ case 29:
721
+ if (u === "e" || u === "E")
722
+ p = 30, s = i.Unknown;
723
+ else if (!Z(u) && u !== "_")
724
+ return m();
725
+ break;
726
+ case 30:
727
+ if (u === "+" || u === "-")
728
+ p = 31;
729
+ else if (Z(u))
730
+ p = 32, s = i.RealLiteral;
731
+ else
732
+ return m();
733
+ break;
734
+ case 31:
735
+ if (Z(u))
736
+ p = 32, s = i.RealLiteral;
737
+ else
738
+ return m();
739
+ break;
740
+ case 32:
741
+ if (!Z(u))
742
+ return m();
743
+ break;
744
+ case 34: {
745
+ p = 33;
746
+ const q = this.input.ahead(0), X = this.input.ahead(1);
747
+ if (q === "`" || q === "$" && X === "{")
748
+ return E(i.StringLiteral);
749
+ break;
750
+ }
751
+ case 33:
752
+ switch (u) {
753
+ case "\\":
754
+ p = 34, s = i.Unknown;
755
+ break e;
756
+ case "`":
757
+ return E(i.Backtick);
758
+ case "$":
759
+ if (this.input.ahead(0) === "{")
760
+ return U(), this.fetchNextChar(), E(i.DollarLBrace);
761
+ }
762
+ const $ = this.input.ahead(0), K = this.input.ahead(1);
763
+ if ($ === "`" || $ === "$" && K === "{")
764
+ return E(i.StringLiteral);
765
+ break;
766
+ case 35:
767
+ if (u === o)
768
+ return E(i.StringLiteral);
769
+ if (He(u))
770
+ return E(i.Unknown);
771
+ u === "\\" && (p = 36, s = i.Unknown);
772
+ break;
773
+ case 36:
774
+ switch (u) {
775
+ case "b":
776
+ case "f":
777
+ case "n":
778
+ case "r":
779
+ case "t":
780
+ case "v":
781
+ case "S":
782
+ case "0":
783
+ case "'":
784
+ case '"':
785
+ case "`":
786
+ case "\\":
787
+ p = 35;
788
+ break;
789
+ case "x":
790
+ p = 37;
791
+ break;
792
+ case "u":
793
+ p = 39;
794
+ break;
795
+ default:
796
+ p = 35;
797
+ break;
798
+ }
799
+ break;
800
+ case 37:
801
+ if (z(u))
802
+ p = 38;
803
+ else
804
+ return E(i.Unknown);
805
+ break;
806
+ case 38:
807
+ if (z(u))
808
+ p = 35;
809
+ else
810
+ return E(i.Unknown);
811
+ break;
812
+ case 39:
813
+ if (u === "{") {
814
+ p = 43;
815
+ break;
816
+ }
817
+ if (z(u))
818
+ p = 40;
819
+ else
820
+ return E(i.Unknown);
821
+ break;
822
+ case 40:
823
+ if (z(u))
824
+ p = 41;
825
+ else
826
+ return E(i.Unknown);
827
+ break;
828
+ case 41:
829
+ if (z(u))
830
+ p = 42;
831
+ else
832
+ return E(i.Unknown);
833
+ break;
834
+ case 42:
835
+ if (z(u))
836
+ p = 35;
837
+ else
838
+ return E(i.Unknown);
839
+ break;
840
+ case 43:
841
+ if (z(u))
842
+ p = 44;
843
+ else
844
+ return E(i.Unknown);
845
+ break;
846
+ case 44:
847
+ if (u === "}")
848
+ p = 35;
849
+ else if (z(u))
850
+ p = 45;
851
+ else
852
+ return E(i.Unknown);
853
+ break;
854
+ case 45:
855
+ if (u === "}")
856
+ p = 35;
857
+ else if (z(u))
858
+ p = 46;
859
+ else
860
+ return E(i.Unknown);
861
+ break;
862
+ case 46:
863
+ if (u === "}")
864
+ p = 35;
865
+ else if (z(u))
866
+ p = 47;
867
+ else
868
+ return E(i.Unknown);
869
+ break;
870
+ case 47:
871
+ if (u === "}")
872
+ p = 35;
873
+ else if (z(u))
874
+ p = 48;
875
+ else
876
+ return E(i.Unknown);
877
+ break;
878
+ case 48:
879
+ if (u === "}")
880
+ p = 35;
881
+ else if (z(u))
882
+ p = 49;
883
+ else
884
+ return E(i.Unknown);
885
+ break;
886
+ case 49:
887
+ if (u === "}")
888
+ p = 35;
889
+ else
890
+ return E(i.Unknown);
891
+ break;
892
+ default:
893
+ return m();
894
+ }
895
+ U();
896
+ }
897
+ function U() {
898
+ c += u, e._prefetched = null, e._prefetchedPos = null, e._prefetchedColumn = null, D = r.position, L = r.position;
899
+ }
900
+ function m() {
901
+ return O && (s = N.get(c) ?? (ge(c[0]) && c[c.length - 1] !== "'" ? i.Identifier : i.Unknown)), {
902
+ text: c,
903
+ type: s,
904
+ location: {
905
+ startPosition: t,
906
+ endPosition: D,
907
+ startLine: l,
908
+ endLine: l,
909
+ startColumn: a,
910
+ endColumn: L
911
+ }
912
+ };
913
+ }
914
+ function E($) {
915
+ return U(), $ !== void 0 && (s = $), m();
916
+ }
917
+ }
918
+ getStartingPhaseThenReset() {
919
+ if (this._phaseExternallySet !== null) {
920
+ const e = this._phaseExternallySet;
921
+ return this._phaseExternallySet = null, e;
922
+ }
923
+ return 0;
924
+ }
925
+ /**
926
+ * Fetches the next RegEx token from the input stream
927
+ */
928
+ fetchRegEx() {
929
+ const e = this._ahead.length > 0 ? this._ahead[0].location.startPosition : this._lastFetchPosition, r = this.input.getTail(e);
930
+ try {
931
+ const t = de(r), l = t.raw;
932
+ for (let a = 1; a < l.length; a++)
933
+ this.fetchNextChar(), this._prefetched = null, this._prefetchedPos = null, this._prefetchedColumn = null;
934
+ return this._ahead.length = 0, {
935
+ success: !0,
936
+ pattern: t.pattern.raw,
937
+ flags: t.flags.raw,
938
+ length: l.length
939
+ };
940
+ } catch (t) {
941
+ let l = t.index;
942
+ if (t.toString().includes("Invalid flag"))
943
+ for (; l < r.length && "dgimsuy".includes(r[l]); )
944
+ l++;
945
+ if (l === void 0)
946
+ return {
947
+ success: !1,
948
+ pattern: r[0]
949
+ };
950
+ const a = r.substring(0, l);
951
+ try {
952
+ const o = de(a), c = o.raw;
953
+ for (let s = 1; s < c.length; s++)
954
+ this.fetchNextChar(), this._prefetched = null, this._prefetchedPos = null, this._prefetchedColumn = null;
955
+ return this._ahead.length = 0, {
956
+ success: !0,
957
+ pattern: o.pattern.raw,
958
+ flags: o.flags.raw,
959
+ length: c.length
960
+ };
961
+ } catch {
962
+ return {
963
+ success: !1,
964
+ pattern: a
965
+ };
966
+ }
967
+ }
968
+ }
969
+ }
970
+ const N = /* @__PURE__ */ new Map();
971
+ N.set("typeof", i.Typeof);
972
+ N.set("Infinity", i.Infinity);
973
+ N.set("NaN", i.NaN);
974
+ N.set("true", i.True);
975
+ N.set("false", i.False);
976
+ N.set("undefined", i.Undefined);
977
+ N.set("null", i.Null);
978
+ N.set("in", i.In);
979
+ N.set("let", i.Let);
980
+ N.set("const", i.Const);
981
+ N.set("var", i.Var);
982
+ N.set("if", i.If);
983
+ N.set("else", i.Else);
984
+ N.set("return", i.Return);
985
+ N.set("break", i.Break);
986
+ N.set("continue", i.Continue);
987
+ N.set("do", i.Do);
988
+ N.set("while", i.While);
989
+ N.set("for", i.For);
990
+ N.set("of", i.Of);
991
+ N.set("try", i.Try);
992
+ N.set("catch", i.Catch);
993
+ N.set("finally", i.Finally);
994
+ N.set("throw", i.Throw);
995
+ N.set("switch", i.Switch);
996
+ N.set("case", i.Case);
997
+ N.set("default", i.Default);
998
+ N.set("delete", i.Delete);
999
+ N.set("function", i.Function);
1000
+ N.set("export", i.Export);
1001
+ N.set("import", i.Import);
1002
+ N.set("as", i.As);
1003
+ N.set("from", i.From);
1004
+ function fe(n) {
1005
+ return n.type === i.Eof;
1006
+ }
1007
+ function pe(n) {
1008
+ return n.type <= i.Ws;
1009
+ }
1010
+ function ge(n) {
1011
+ return n >= "a" && n <= "z" || n >= "A" && n <= "Z" || n === "_" || n === "$";
1012
+ }
1013
+ function ke(n) {
1014
+ return n >= "a" && n <= "z" || n >= "A" && n <= "Z" || n >= "0" && n <= "9" || n === "_" || n === "$";
1015
+ }
1016
+ function Ee(n) {
1017
+ return n === "0" || n === "1";
1018
+ }
1019
+ function Z(n) {
1020
+ return n >= "0" && n <= "9";
1021
+ }
1022
+ function z(n) {
1023
+ return n >= "0" && n <= "9" || n >= "A" && n <= "F" || n >= "a" && n <= "f";
1024
+ }
1025
+ function He(n) {
1026
+ return n === "\r" || n === `
1027
+ ` || n === "…" || n === "\u2028" || n === "\u2029";
1028
+ }
1029
+ let Ge = class be extends Error {
1030
+ constructor(e, r) {
1031
+ super(e), this.code = r, Object.setPrototypeOf(this, be.prototype);
1032
+ }
1033
+ };
1034
+ const ie = {
1035
+ W001: "An expression expected",
1036
+ W002: "Unexpected token: {0}",
1037
+ W003: "An identifier expected",
1038
+ W004: "'}' expected",
1039
+ W005: "']' expected",
1040
+ W006: "')' expected",
1041
+ W007: "Invalid object property name type",
1042
+ W008: "':' expected",
1043
+ W009: "'=' expected",
1044
+ W010: "Invalid argument list",
1045
+ W011: "For loop variable must be initialized",
1046
+ W012: "'{' expected",
1047
+ W013: "'catch' or 'finally' expected",
1048
+ W014: "'(' or expected",
1049
+ W015: "'case' or 'default' expected",
1050
+ W016: "'default' case can be used only once within a switch statement",
1051
+ W017: "Invalid sequence expression",
1052
+ W018: "Invalid object literal",
1053
+ W019: "Identifier '{0}' is already imported",
1054
+ W020: "Function '{0}' is already defined in the module",
1055
+ W021: "'{0}' is already exported from the module",
1056
+ W022: "Cannot find module '{0}'",
1057
+ W023: "Module '{0}' does not export '{1}'",
1058
+ W024: "'function' or 'const' expected",
1059
+ W025: "'from' expected",
1060
+ W026: "A string literal expected",
1061
+ W027: "Variables can be declared only in the top level module",
1062
+ W028: "Invalid statement used in a module",
1063
+ W029: "An imported module can contain only exported functions",
1064
+ W030: "Nested declarations cannot be exported",
1065
+ W031: "An identifier in a declaration cannot start with '$'"
1066
+ };
1067
+ class Ne {
1068
+ /**
1069
+ * Initializes the parser with the specified source code
1070
+ * @param source Source code to parse
1071
+ */
1072
+ constructor(e) {
1073
+ this.source = e, this._parseErrors = [], this._statementLevel = 0, this._lexer = new ze(new $e(e));
1074
+ }
1075
+ /**
1076
+ * The errors raised during the parse phase
1077
+ */
1078
+ get errors() {
1079
+ return this._parseErrors;
1080
+ }
1081
+ /**
1082
+ * Gets the current token
1083
+ */
1084
+ get current() {
1085
+ return this._lexer.peek();
1086
+ }
1087
+ /**
1088
+ * Checks if we're at the end of the expression
1089
+ */
1090
+ get isEof() {
1091
+ return this._lexer.peek().type === i.Eof;
1092
+ }
1093
+ /**
1094
+ * Gets the characters remaining after parsing
1095
+ */
1096
+ getTail() {
1097
+ return this._lexer.getTail();
1098
+ }
1099
+ // ==========================================================================
1100
+ // Statement parsing
1101
+ /**
1102
+ * Parses a list of statements:
1103
+ *
1104
+ * statements
1105
+ * : statement*
1106
+ * ;
1107
+ *
1108
+ * statement
1109
+ * : emptyStatement
1110
+ * | expressionStatement
1111
+ * | letStatement
1112
+ * | returnStatement
1113
+ * ;
1114
+ */
1115
+ parseStatements() {
1116
+ this._statementLevel = 0;
1117
+ const e = [];
1118
+ for (; !this.isEof; ) {
1119
+ const r = this.parseStatement();
1120
+ if (!r) return null;
1121
+ e.push(r), r.type !== "EmptyS" && this.skipToken(i.Semicolon);
1122
+ }
1123
+ return e;
1124
+ }
1125
+ /**
1126
+ * Parses a single statement
1127
+ */
1128
+ parseStatement(e = !0) {
1129
+ this._statementLevel++;
1130
+ try {
1131
+ const r = this._lexer.peek();
1132
+ switch (r.type) {
1133
+ case i.Semicolon:
1134
+ return this.parseEmptyStatement();
1135
+ case i.Let:
1136
+ return this.parseLetStatement();
1137
+ case i.Const:
1138
+ return this.parseConstStatement();
1139
+ case i.Var:
1140
+ return this.parseVarStatement();
1141
+ case i.LBrace:
1142
+ return this.parseBlockStatement();
1143
+ case i.If:
1144
+ return this.parseIfStatement();
1145
+ case i.Do:
1146
+ return this.parseDoWhileStatement();
1147
+ case i.While:
1148
+ return this.parseWhileStatement();
1149
+ case i.Return:
1150
+ return this.parseReturnStatement();
1151
+ case i.Break:
1152
+ return this._lexer.get(), this.createStatementNode("BrkS", {}, r, r);
1153
+ case i.Continue:
1154
+ return this._lexer.get(), this.createStatementNode("ContS", {}, r, r);
1155
+ case i.For:
1156
+ return this.parseForStatement();
1157
+ case i.Throw:
1158
+ return this.parseThrowStatement();
1159
+ case i.Try:
1160
+ return this.parseTryStatement();
1161
+ case i.Switch:
1162
+ return this.parseSwitchStatement();
1163
+ case i.Function:
1164
+ return this.parseFunctionDeclaration();
1165
+ case i.Export:
1166
+ return this.parseExport();
1167
+ case i.Import:
1168
+ return this.parseImport();
1169
+ default:
1170
+ return r.type === i.Eof ? (this.reportError("W002", r, "EOF"), null) : this.isExpressionStart(r) ? this.parseExpressionStatement(e) : (this.reportError("W002", r, r.text), null);
1171
+ }
1172
+ } finally {
1173
+ this._statementLevel--;
1174
+ }
1175
+ }
1176
+ /**
1177
+ * Parses an empty statement
1178
+ *
1179
+ * emptyStatement
1180
+ * : ";"
1181
+ * ;
1182
+ */
1183
+ parseEmptyStatement() {
1184
+ const e = this._lexer.get();
1185
+ return this.createStatementNode("EmptyS", {}, e, e);
1186
+ }
1187
+ /**
1188
+ * Parses an expression statement
1189
+ *
1190
+ * expressionStatement
1191
+ * : expression
1192
+ * ;
1193
+ */
1194
+ parseExpressionStatement(e = !0) {
1195
+ const r = this._lexer.peek(), t = this.getExpression(e);
1196
+ return t ? this.createStatementNode(
1197
+ "ExprS",
1198
+ {
1199
+ expression: t
1200
+ },
1201
+ r,
1202
+ t.endToken
1203
+ ) : null;
1204
+ }
1205
+ /**
1206
+ * Parses a let statement
1207
+ *
1208
+ * letStatement
1209
+ * : "let" id ["=" expression] ("," id ["=" expression])*
1210
+ * ;
1211
+ */
1212
+ parseLetStatement() {
1213
+ const e = this._lexer.get();
1214
+ let r = e;
1215
+ const t = [];
1216
+ for (; ; ) {
1217
+ const l = this._lexer.peek();
1218
+ let a = {};
1219
+ if (l.type === i.LBrace) {
1220
+ r = this._lexer.ahead(1);
1221
+ const s = this.parseObjectDestructure();
1222
+ if (s === null) return null;
1223
+ a = {
1224
+ objectDestruct: s
1225
+ }, r = s.length > 0 ? s[s.length - 1].endToken : r;
1226
+ } else if (l.type === i.LSquare) {
1227
+ r = this._lexer.ahead(1);
1228
+ const s = this.parseArrayDestructure();
1229
+ if (s === null) return null;
1230
+ a = {
1231
+ arrayDestruct: s
1232
+ }, r = s.length > 0 ? s[s.length - 1].endToken : r;
1233
+ } else if (l.type === i.Identifier) {
1234
+ if (l.text.startsWith("$"))
1235
+ return this.reportError("W031"), null;
1236
+ r = this._lexer.get(), a = {
1237
+ id: l.text
1238
+ };
1239
+ } else
1240
+ return this.reportError("W003"), null;
1241
+ const o = this._lexer.peek();
1242
+ let c = null;
1243
+ if (o.type === i.Assignment) {
1244
+ if (this._lexer.get(), c = this.getExpression(!1), c === null) return null;
1245
+ a.expression = c, r = c.endToken;
1246
+ } else if (a.arrayDestruct || a.objectDestruct)
1247
+ return this.reportError("W009", o), null;
1248
+ if (t.push(
1249
+ this.createExpressionNode("VarD", a, l, r)
1250
+ ), this._lexer.peek().type !== i.Comma) break;
1251
+ this._lexer.get();
1252
+ }
1253
+ return this.createStatementNode(
1254
+ "LetS",
1255
+ {
1256
+ declarations: t
1257
+ },
1258
+ e,
1259
+ r
1260
+ );
1261
+ }
1262
+ /**
1263
+ * Parses a const statement
1264
+ *
1265
+ * constStatement
1266
+ * : "const" id "=" expression
1267
+ * ;
1268
+ */
1269
+ parseConstStatement() {
1270
+ const e = this._lexer.get();
1271
+ let r = e;
1272
+ const t = [];
1273
+ for (; ; ) {
1274
+ const l = this._lexer.peek();
1275
+ let a = {};
1276
+ if (l.type === i.LBrace) {
1277
+ r = this._lexer.ahead(1);
1278
+ const c = this.parseObjectDestructure();
1279
+ if (c === null) return null;
1280
+ a = {
1281
+ objectDestruct: c
1282
+ }, r = c.length > 0 ? c[c.length - 1].endToken : r;
1283
+ } else if (l.type === i.LSquare) {
1284
+ r = this._lexer.ahead(1);
1285
+ const c = this.parseArrayDestructure();
1286
+ if (c === null) return null;
1287
+ a = {
1288
+ arrayDestruct: c
1289
+ }, r = c.length > 0 ? c[c.length - 1].endToken : r;
1290
+ } else if (l.type === i.Identifier) {
1291
+ if (l.text.startsWith("$"))
1292
+ return this.reportError("W031"), null;
1293
+ r = this._lexer.get(), a = {
1294
+ id: l.text
1295
+ };
1296
+ } else
1297
+ return this.reportError("W003"), null;
1298
+ this.expectToken(i.Assignment);
1299
+ const o = this.getExpression(!1);
1300
+ if (o === null) return null;
1301
+ if (a.expression = o, r = o.endToken, t.push(
1302
+ this.createExpressionNode("VarD", a, l, r)
1303
+ ), this._lexer.peek().type !== i.Comma) break;
1304
+ this._lexer.get();
1305
+ }
1306
+ return this.createStatementNode(
1307
+ "ConstS",
1308
+ {
1309
+ declarations: t
1310
+ },
1311
+ e,
1312
+ r
1313
+ );
1314
+ }
1315
+ /**
1316
+ * Parses a const statement
1317
+ *
1318
+ * constStatement
1319
+ * : "var" id "=" expression
1320
+ * ;
1321
+ */
1322
+ parseVarStatement() {
1323
+ const e = this._lexer.get();
1324
+ let r = e;
1325
+ const t = [];
1326
+ for (; ; ) {
1327
+ const l = this._lexer.peek();
1328
+ let a = {};
1329
+ if (l.type === i.Identifier) {
1330
+ if (l.text.startsWith("$"))
1331
+ return this.reportError("W031"), null;
1332
+ r = this._lexer.get(), a = {
1333
+ id: l.text
1334
+ };
1335
+ } else
1336
+ return this.reportError("W003"), null;
1337
+ this.expectToken(i.Assignment);
1338
+ const o = this.getExpression(!1);
1339
+ if (o === null) return null;
1340
+ if (a.expression = o, r = o.endToken, t.push(
1341
+ this.createExpressionNode(
1342
+ "RVarD",
1343
+ a,
1344
+ l,
1345
+ r
1346
+ )
1347
+ ), this._lexer.peek().type !== i.Comma) break;
1348
+ this._lexer.get();
1349
+ }
1350
+ return this.createStatementNode(
1351
+ "VarS",
1352
+ {
1353
+ declarations: t
1354
+ },
1355
+ e,
1356
+ r
1357
+ );
1358
+ }
1359
+ /**
1360
+ * Parses an object destructure expression
1361
+ */
1362
+ parseObjectDestructure() {
1363
+ const e = [], r = this._lexer.get();
1364
+ let t = r, l = this._lexer.peek();
1365
+ for (; l.type === i.Identifier; ) {
1366
+ const a = l.text;
1367
+ if (a.startsWith("$"))
1368
+ return this.reportError("W031"), null;
1369
+ let o, c, s;
1370
+ if (this._lexer.get(), l = this._lexer.peek(), l.type === i.Colon) {
1371
+ if (this._lexer.get(), l = this._lexer.peek(), l.type === i.Identifier)
1372
+ o = l.text, t = l, this._lexer.get();
1373
+ else if (l.type === i.LSquare) {
1374
+ if (c = this.parseArrayDestructure(), c === null) return null;
1375
+ t = c[c.length - 1].endToken;
1376
+ } else if (l.type === i.LBrace) {
1377
+ if (s = this.parseObjectDestructure(), s === null) return null;
1378
+ t = s[s.length - 1].endToken;
1379
+ }
1380
+ }
1381
+ l = this._lexer.peek(), (l.type === i.Comma || l.type === i.RBrace) && (e.push(
1382
+ this.createExpressionNode(
1383
+ "ODestr",
1384
+ { id: a, alias: o, arrayDestruct: c, objectDestruct: s },
1385
+ r,
1386
+ t
1387
+ )
1388
+ ), l.type === i.Comma && (this._lexer.get(), l = this._lexer.peek()));
1389
+ }
1390
+ return this.expectToken(i.RBrace, "W004"), e;
1391
+ }
1392
+ parseArrayDestructure() {
1393
+ const e = [], r = this._lexer.get();
1394
+ let t = r;
1395
+ do {
1396
+ let l = this._lexer.peek(), a, o, c;
1397
+ if (l.type === i.Identifier) {
1398
+ if (a = l.text, a.startsWith("$"))
1399
+ return this.reportError("W031"), null;
1400
+ t = l, l = this._lexer.get();
1401
+ } else if (l.type === i.LSquare) {
1402
+ if (o = this.parseArrayDestructure(), o === null) return null;
1403
+ t = o[o.length - 1].endToken;
1404
+ } else if (l.type === i.LBrace) {
1405
+ if (c = this.parseObjectDestructure(), c === null) return null;
1406
+ t = c[c.length - 1].endToken;
1407
+ }
1408
+ if (l = this._lexer.peek(), l.type === i.Comma)
1409
+ e.push(
1410
+ this.createExpressionNode(
1411
+ "ADestr",
1412
+ { id: a, arrayDestruct: o, objectDestruct: c },
1413
+ r,
1414
+ t
1415
+ )
1416
+ ), this._lexer.get();
1417
+ else if (l.type === i.RSquare) {
1418
+ (a || o || c) && e.push(
1419
+ this.createExpressionNode(
1420
+ "ADestr",
1421
+ { id: a, arrayDestruct: o, objectDestruct: c },
1422
+ r,
1423
+ t
1424
+ )
1425
+ );
1426
+ break;
1427
+ } else
1428
+ return this.reportError("W002", l), null;
1429
+ } while (!0);
1430
+ return this.expectToken(i.RSquare, "W005"), e;
1431
+ }
1432
+ /**
1433
+ * Parses a block statement
1434
+ *
1435
+ * blockStatement
1436
+ * : "{" (statement [";"])* "}"
1437
+ * ;
1438
+ */
1439
+ parseBlockStatement() {
1440
+ const e = this._lexer.get(), r = [];
1441
+ for (; this._lexer.peek().type !== i.RBrace; ) {
1442
+ const l = this.parseStatement();
1443
+ if (!l) return null;
1444
+ r.push(l), l.type !== "EmptyS" && this.skipToken(i.Semicolon);
1445
+ }
1446
+ const t = this._lexer.get();
1447
+ return this.createStatementNode("BlockS", { statements: r }, e, t);
1448
+ }
1449
+ /**
1450
+ * Parses an if statement
1451
+ *
1452
+ * ifStatement
1453
+ * : "if" "(" expression ")" statement ["else" statement]
1454
+ * ;
1455
+ */
1456
+ parseIfStatement() {
1457
+ const e = this._lexer.get();
1458
+ let r = e;
1459
+ this.expectToken(i.LParent, "W014");
1460
+ const t = this.getExpression();
1461
+ if (!t) return null;
1462
+ this.expectToken(i.RParent, "W006");
1463
+ const l = this.parseStatement();
1464
+ if (!l) return null;
1465
+ r = l.endToken;
1466
+ let a = !0;
1467
+ l.type !== "BlockS" && (this._lexer.peek().type === i.Semicolon ? this._lexer.get() : a = !1);
1468
+ let o = null;
1469
+ if (a && this._lexer.peek().type === i.Else) {
1470
+ if (this._lexer.get(), o = this.parseStatement(), !o) return null;
1471
+ r = o.endToken;
1472
+ }
1473
+ return this.createStatementNode(
1474
+ "IfS",
1475
+ {
1476
+ condition: t,
1477
+ thenBranch: l,
1478
+ elseBranch: o
1479
+ },
1480
+ e,
1481
+ r
1482
+ );
1483
+ }
1484
+ /**
1485
+ * Parses a while statement
1486
+ *
1487
+ * whileStatement
1488
+ * : "while" "(" condition ")" statement
1489
+ * ;
1490
+ */
1491
+ parseWhileStatement() {
1492
+ const e = this._lexer.get();
1493
+ this.expectToken(i.LParent, "W014");
1494
+ const r = this.getExpression();
1495
+ if (!r) return null;
1496
+ this.expectToken(i.RParent, "W006");
1497
+ const t = this.parseStatement();
1498
+ return t ? this.createStatementNode(
1499
+ "WhileS",
1500
+ {
1501
+ condition: r,
1502
+ body: t
1503
+ },
1504
+ e,
1505
+ t.endToken
1506
+ ) : null;
1507
+ }
1508
+ /**
1509
+ * Parses a do-while statement
1510
+ *
1511
+ * doWhileStatement
1512
+ * : "do" statement "while" "(" condition ")"
1513
+ * ;
1514
+ */
1515
+ parseDoWhileStatement() {
1516
+ const e = this._lexer.get(), r = this.parseStatement();
1517
+ if (!r) return null;
1518
+ r.type !== "BlockS" && r.type !== "EmptyS" && this.expectToken(i.Semicolon), this.expectToken(i.While), this.expectToken(i.LParent, "W014");
1519
+ const t = this.getExpression();
1520
+ if (!t) return null;
1521
+ const l = this._lexer.peek();
1522
+ return this.expectToken(i.RParent, "W006"), this.createStatementNode(
1523
+ "DoWS",
1524
+ {
1525
+ condition: t,
1526
+ body: r
1527
+ },
1528
+ e,
1529
+ l
1530
+ );
1531
+ }
1532
+ /**
1533
+ * Parses an expression statement
1534
+ *
1535
+ * returnStatement
1536
+ * : "return" expression?
1537
+ * ;
1538
+ */
1539
+ parseReturnStatement() {
1540
+ const e = this._lexer.peek();
1541
+ let r = this._lexer.get(), t;
1542
+ if (j[this._lexer.peek().type].expressionStart) {
1543
+ if (t = this.getExpression(), t === null) return null;
1544
+ r = t.endToken;
1545
+ }
1546
+ return this.createStatementNode(
1547
+ "RetS",
1548
+ {
1549
+ expression: t
1550
+ },
1551
+ e,
1552
+ r
1553
+ );
1554
+ }
1555
+ /**
1556
+ * forStatement
1557
+ * : "for" "(" initStatement? ";" expression? ";" expression? ")" statement
1558
+ * | forInOfStatement
1559
+ * ;
1560
+ */
1561
+ parseForStatement() {
1562
+ const e = this._lexer.peek();
1563
+ this._lexer.get(), this.expectToken(i.LParent, "W014");
1564
+ let r = this._lexer.peek();
1565
+ if (r.type === i.Identifier) {
1566
+ if (this._lexer.ahead(1).type === i.In)
1567
+ return this.parseForInOfStatement(e, "none", r.text, "ForInS");
1568
+ if (this._lexer.ahead(1).type === i.Of)
1569
+ return this.parseForInOfStatement(e, "none", r.text, "ForOfS");
1570
+ } else if (r.type === i.Let) {
1571
+ const c = this._lexer.ahead(1);
1572
+ if (c.type === i.Identifier) {
1573
+ const s = this._lexer.ahead(2);
1574
+ if (s.type === i.In)
1575
+ return this.parseForInOfStatement(e, "let", c.text, "ForInS");
1576
+ if (s.type === i.Of)
1577
+ return this.parseForInOfStatement(e, "let", c.text, "ForOfS");
1578
+ }
1579
+ } else if (r.type === i.Const) {
1580
+ const c = this._lexer.ahead(1);
1581
+ if (c.type === i.Identifier) {
1582
+ const s = this._lexer.ahead(2);
1583
+ if (s.type === i.In)
1584
+ return this.parseForInOfStatement(e, "const", c.text, "ForInS");
1585
+ if (s.type === i.Of)
1586
+ return this.parseForInOfStatement(e, "const", c.text, "ForOfS");
1587
+ }
1588
+ }
1589
+ let t;
1590
+ if (r = this._lexer.peek(), r.type === i.Semicolon)
1591
+ this._lexer.get();
1592
+ else if (r.type === i.Let) {
1593
+ const c = this.parseLetStatement();
1594
+ if (c === null)
1595
+ return null;
1596
+ if (t = c, t.declarations.some((s) => !s.expression))
1597
+ return this.reportError("W011"), null;
1598
+ this.expectToken(i.Semicolon);
1599
+ } else if (j[r.type].expressionStart) {
1600
+ const c = this.parseExpressionStatement();
1601
+ if (c === null)
1602
+ return null;
1603
+ t = c, this.expectToken(i.Semicolon);
1604
+ }
1605
+ let l;
1606
+ if (r = this._lexer.peek(), r.type === i.Semicolon)
1607
+ this._lexer.get();
1608
+ else {
1609
+ if (l = this.getExpression(), l === null)
1610
+ return null;
1611
+ this.expectToken(i.Semicolon);
1612
+ }
1613
+ let a;
1614
+ if (r = this._lexer.peek(), r.type !== i.RParent && (a = this.getExpression(), a === null))
1615
+ return null;
1616
+ this.expectToken(i.RParent, "W006");
1617
+ const o = this.parseStatement();
1618
+ return o ? this.createStatementNode(
1619
+ "ForS",
1620
+ {
1621
+ init: t,
1622
+ condition: l,
1623
+ update: a,
1624
+ body: o
1625
+ },
1626
+ e,
1627
+ o.endToken
1628
+ ) : null;
1629
+ }
1630
+ /**
1631
+ * forInOfStatement
1632
+ * : "for" "(" [ "let" | "const" ] identifier ( "in" | "of" ) expression? ")" statement
1633
+ * | forInOfStatement
1634
+ * ;
1635
+ *
1636
+ * @param startToken Statement start token
1637
+ * @param varBinding Variable binding of the for..in/of statement
1638
+ * @param id ID name
1639
+ * @param type Is it a for..in or a for..of?
1640
+ */
1641
+ parseForInOfStatement(e, r, t, l) {
1642
+ if (r !== "none") {
1643
+ if (t.startsWith("$"))
1644
+ return this.reportError("W031"), null;
1645
+ this._lexer.get();
1646
+ }
1647
+ this._lexer.get(), this._lexer.get();
1648
+ const a = this.getExpression(!0);
1649
+ this.expectToken(i.RParent, "W006");
1650
+ const o = this.parseStatement();
1651
+ return o ? l === "ForInS" ? this.createStatementNode(
1652
+ "ForInS",
1653
+ {
1654
+ varBinding: r,
1655
+ id: t,
1656
+ expression: a,
1657
+ body: o
1658
+ },
1659
+ e,
1660
+ o.endToken
1661
+ ) : this.createStatementNode(
1662
+ "ForOfS",
1663
+ {
1664
+ varBinding: r,
1665
+ id: t,
1666
+ expression: a,
1667
+ body: o
1668
+ },
1669
+ e,
1670
+ o.endToken
1671
+ ) : null;
1672
+ }
1673
+ /**
1674
+ * Parses a throw statement
1675
+ *
1676
+ * throwStatement
1677
+ * : "throw" expression
1678
+ * ;
1679
+ */
1680
+ parseThrowStatement() {
1681
+ const e = this._lexer.peek();
1682
+ this._lexer.get();
1683
+ let r;
1684
+ return r = this.getExpression(), r === null ? null : this.createStatementNode(
1685
+ "ThrowS",
1686
+ {
1687
+ expression: r
1688
+ },
1689
+ e,
1690
+ r.endToken
1691
+ );
1692
+ }
1693
+ /**
1694
+ * Parses a try..catch..finally statement
1695
+ *
1696
+ * tryStatement
1697
+ * : "try" blockStatement catchClause finallyClause?
1698
+ * | "try" blockStatement catchClause? finallyClause
1699
+ * ;
1700
+ *
1701
+ * catchClause
1702
+ * : "catch" [ "(" identifier ") ]? blockStatement
1703
+ * ;
1704
+ *
1705
+ * finallyClause
1706
+ * : "finally" blockStatement
1707
+ */
1708
+ parseTryStatement() {
1709
+ const e = this._lexer.peek();
1710
+ let r = this._lexer.get();
1711
+ const t = this, l = D();
1712
+ let a, o, c, s = this._lexer.peek();
1713
+ if (s.type === i.Catch) {
1714
+ if (this._lexer.get(), s = this._lexer.peek(), s.type === i.LParent) {
1715
+ if (this._lexer.get(), s = this._lexer.peek(), s.type !== i.Identifier)
1716
+ return this.reportError("W003", s), null;
1717
+ o = s.text, this._lexer.get(), this.expectToken(i.RParent, "W006");
1718
+ }
1719
+ a = D(), r = a.endToken, this._lexer.peek().type === i.Finally && (this._lexer.get(), c = D(), r = c.endToken);
1720
+ } else if (s.type === i.Finally)
1721
+ this._lexer.get(), c = D(), r = c.endToken;
1722
+ else
1723
+ return this.reportError("W013", s), null;
1724
+ return this.createStatementNode(
1725
+ "TryS",
1726
+ {
1727
+ tryBlock: l,
1728
+ catchBlock: a,
1729
+ catchVariable: o,
1730
+ finallyBlock: c
1731
+ },
1732
+ e,
1733
+ r
1734
+ );
1735
+ function D() {
1736
+ const L = t._lexer.peek();
1737
+ return L.type !== i.LBrace ? (t.reportError("W012", L), null) : t.parseBlockStatement();
1738
+ }
1739
+ }
1740
+ /**
1741
+ * Parses a switch statement
1742
+ *
1743
+ * switchStatement
1744
+ * : "switch" "(" expression ")" "{" caseClauses "}"
1745
+ * ;
1746
+ *
1747
+ * caseClauses
1748
+ * : "case" expression ":" statement*
1749
+ * | "default" ":" statement*
1750
+ * ;
1751
+ */
1752
+ parseSwitchStatement() {
1753
+ const e = this._lexer.get();
1754
+ this.expectToken(i.LParent, "W014");
1755
+ const r = this.getExpression();
1756
+ if (!r) return null;
1757
+ this.expectToken(i.RParent, "W006"), this.expectToken(i.LBrace, "W012");
1758
+ const t = [];
1759
+ let l = !1;
1760
+ for (; ; ) {
1761
+ let o = this._lexer.peek(), c;
1762
+ if (o.type === i.Case) {
1763
+ if (this._lexer.get(), c = this.getExpression(), !c) return null;
1764
+ } else if (o.type === i.Default) {
1765
+ if (l)
1766
+ return this.reportError("W016"), null;
1767
+ l = !0, this._lexer.get();
1768
+ } else {
1769
+ if (o.type === i.RBrace)
1770
+ break;
1771
+ return this.reportError("W015"), null;
1772
+ }
1773
+ this.expectToken(i.Colon, "W008");
1774
+ let s = [], D = !1;
1775
+ for (; !D; )
1776
+ switch (this._lexer.peek().type) {
1777
+ case i.Case:
1778
+ case i.Default:
1779
+ case i.RBrace:
1780
+ D = !0;
1781
+ break;
1782
+ default:
1783
+ const u = this.parseStatement();
1784
+ if (u === null) {
1785
+ D = !0;
1786
+ break;
1787
+ }
1788
+ s.push(u), u.type !== "EmptyS" && this.skipToken(i.Semicolon);
1789
+ }
1790
+ t.push(
1791
+ this.createNode(
1792
+ "SwitchC",
1793
+ {
1794
+ caseExpression: c,
1795
+ statements: s
1796
+ },
1797
+ e
1798
+ )
1799
+ );
1800
+ }
1801
+ const a = this._lexer.peek();
1802
+ return this.expectToken(i.RBrace, "W004"), this.createStatementNode(
1803
+ "SwitchS",
1804
+ {
1805
+ expression: r,
1806
+ cases: t
1807
+ },
1808
+ e,
1809
+ a
1810
+ );
1811
+ }
1812
+ /**
1813
+ * Parses a function declaration
1814
+ *
1815
+ * functionDeclaration
1816
+ * : "function" identifier "(" [parameterList] ")" blockStatement
1817
+ * ;
1818
+ */
1819
+ parseFunctionDeclaration(e = !1) {
1820
+ const r = this._lexer.get();
1821
+ let t;
1822
+ const l = this._lexer.peek();
1823
+ if (e) {
1824
+ if (l.type !== i.LParent) {
1825
+ if (l.type !== i.Identifier)
1826
+ return this.reportError("W003", l), null;
1827
+ t = l.text, this._lexer.get();
1828
+ }
1829
+ } else {
1830
+ if (l.type !== i.Identifier)
1831
+ return this.reportError("W003", l), null;
1832
+ t = l.text, this._lexer.get();
1833
+ }
1834
+ const a = this._lexer.peek();
1835
+ if (a.type !== i.LParent)
1836
+ return this.reportError("W014", a), null;
1837
+ const o = this.getExpression(!0);
1838
+ let c;
1839
+ const s = [];
1840
+ switch (o.type) {
1841
+ case "NoArgE":
1842
+ c = !0;
1843
+ break;
1844
+ case "IdE":
1845
+ c = (o.parenthesized ?? 0) <= 1, s.push(o);
1846
+ break;
1847
+ case "SeqE":
1848
+ c = o.parenthesized === 1;
1849
+ let L = !1;
1850
+ if (c)
1851
+ for (const u of o.expressions) {
1852
+ if (L) {
1853
+ c = !1;
1854
+ break;
1855
+ }
1856
+ switch (u.type) {
1857
+ case "IdE":
1858
+ c = !u.parenthesized, s.push(u);
1859
+ break;
1860
+ case "OLitE": {
1861
+ if (c = !u.parenthesized, c) {
1862
+ const O = this.convertToObjectDestructure(u);
1863
+ O && s.push(O);
1864
+ }
1865
+ break;
1866
+ }
1867
+ case "ALitE": {
1868
+ if (c = !u.parenthesized, c) {
1869
+ const O = this.convertToArrayDestructure(u);
1870
+ O && s.push(O);
1871
+ }
1872
+ break;
1873
+ }
1874
+ case "SpreadE": {
1875
+ if (L = !0, u.operand.type !== "IdE") {
1876
+ c = !1;
1877
+ break;
1878
+ }
1879
+ s.push(u);
1880
+ break;
1881
+ }
1882
+ default:
1883
+ c = !1;
1884
+ break;
1885
+ }
1886
+ }
1887
+ break;
1888
+ case "OLitE":
1889
+ if (c = o.parenthesized === 1, c) {
1890
+ const u = this.convertToObjectDestructure(o);
1891
+ u && s.push(u);
1892
+ }
1893
+ break;
1894
+ case "ALitE":
1895
+ if (c = o.parenthesized === 1, c) {
1896
+ const u = this.convertToArrayDestructure(o);
1897
+ u && s.push(u);
1898
+ }
1899
+ break;
1900
+ case "SpreadE":
1901
+ if (o.operand.type !== "IdE") {
1902
+ c = !1;
1903
+ break;
1904
+ }
1905
+ c = !0, s.push(o);
1906
+ break;
1907
+ default:
1908
+ c = !1;
1909
+ }
1910
+ if (!c)
1911
+ return this.reportError("W010", r), null;
1912
+ if (this._lexer.peek().type !== i.LBrace)
1913
+ return this.reportError("W012", this._lexer.peek()), null;
1914
+ const D = this.parseBlockStatement();
1915
+ return D ? this.createStatementNode(
1916
+ "FuncD",
1917
+ {
1918
+ name: t,
1919
+ args: s,
1920
+ statement: D
1921
+ },
1922
+ r,
1923
+ D.endToken
1924
+ ) : null;
1925
+ }
1926
+ /**
1927
+ * Parses an export statement
1928
+ *
1929
+ * exportStatement
1930
+ * : "export" (constStatement | functionDeclaration)
1931
+ * ;
1932
+ */
1933
+ parseExport() {
1934
+ this._lexer.get();
1935
+ const e = this._lexer.peek();
1936
+ if (e.type === i.Const) {
1937
+ if (this._statementLevel > 1)
1938
+ return this.reportError("W030", e), null;
1939
+ const r = this.parseConstStatement();
1940
+ return r === null ? null : { ...r, isExported: !0 };
1941
+ } else if (e.type === i.Function) {
1942
+ if (this._statementLevel > 1)
1943
+ return this.reportError("W030", e), null;
1944
+ const r = this.parseFunctionDeclaration();
1945
+ return r === null ? null : { ...r, isExported: !0 };
1946
+ }
1947
+ return this.reportError("W024", e), null;
1948
+ }
1949
+ /**
1950
+ * Parse an import declaration
1951
+ *
1952
+ * importDeclaration
1953
+ * : "import" "{" importItem ("," importItem)* [ "," ] "}" from module
1954
+ * ;
1955
+ *
1956
+ * importItem
1957
+ * : identifier [ "as" identifier ]
1958
+ * ;
1959
+ */
1960
+ parseImport() {
1961
+ const e = this._lexer.get();
1962
+ this.expectToken(i.LBrace, "W012");
1963
+ const r = {};
1964
+ let t = this._lexer.peek();
1965
+ for (; t.type !== i.RBrace; ) {
1966
+ if (t.type !== i.Identifier)
1967
+ return this.reportError("W003", t), null;
1968
+ const o = t.text;
1969
+ if (this._lexer.get(), t = this._lexer.peek(), t.type === i.As) {
1970
+ if (this._lexer.get(), t = this._lexer.peek(), t.type !== i.Identifier)
1971
+ return this.reportError("W003", t), null;
1972
+ if (r[t.text])
1973
+ return this.reportError("W019", t, t.text), null;
1974
+ r[t.text] = o, this._lexer.get();
1975
+ } else {
1976
+ if (r[o])
1977
+ return this.reportError("W019", t, o), null;
1978
+ r[o] = o;
1979
+ }
1980
+ t = this._lexer.peek(), t.type === i.Comma && (this._lexer.get(), t = this._lexer.peek());
1981
+ }
1982
+ this._lexer.get(), this.expectToken(i.From, "W025");
1983
+ const l = this._lexer.peek();
1984
+ if (l.type !== i.StringLiteral)
1985
+ return this.reportError("W026", l), null;
1986
+ this._lexer.get();
1987
+ const a = this.parseStringLiteral(l);
1988
+ return this.createStatementNode(
1989
+ "ImportD",
1990
+ {
1991
+ imports: r,
1992
+ moduleFile: a.value
1993
+ },
1994
+ e,
1995
+ l
1996
+ );
1997
+ }
1998
+ // ==========================================================================
1999
+ // Expression parsing
2000
+ /**
2001
+ * Parses an expression:
2002
+ *
2003
+ * expr
2004
+ * : sequenceExpr
2005
+ * ;
2006
+ */
2007
+ parseExpr(e = !0) {
2008
+ return e ? this.parseSequenceExpression() : this.parseCondOrSpreadOrAsgnOrArrowExpr();
2009
+ }
2010
+ /**
2011
+ * sequenceExpr
2012
+ * : conditionalExpr ( "," conditionalExpr )?
2013
+ */
2014
+ parseSequenceExpression() {
2015
+ const e = this._lexer.peek();
2016
+ let r = e, t = this.parseCondOrSpreadOrAsgnOrArrowExpr();
2017
+ if (!t)
2018
+ return null;
2019
+ r = t.endToken;
2020
+ const l = [];
2021
+ let a = !1;
2022
+ if (this._lexer.peek().type === i.Comma)
2023
+ for (l.push(t); this.skipToken(i.Comma); )
2024
+ if (this._lexer.peek().type === i.Comma)
2025
+ a = !0, r = this._lexer.peek(), l.push(
2026
+ this.createExpressionNode("NoArgE", {}, r, r)
2027
+ );
2028
+ else {
2029
+ const o = this.parseCondOrSpreadOrAsgnOrArrowExpr();
2030
+ if (!o)
2031
+ break;
2032
+ r = o.endToken, l.push(o);
2033
+ }
2034
+ return l.length && (t = this.createExpressionNode(
2035
+ "SeqE",
2036
+ {
2037
+ expressions: l,
2038
+ loose: a
2039
+ },
2040
+ e,
2041
+ r
2042
+ ), a && (t = this.convertToArrayDestructure(t))), t;
2043
+ }
2044
+ /**
2045
+ * conditionalOrSpreadOrAsgnOrArrowExpr
2046
+ * : nullCoalescingExpr ( "?" expr ":" expr )?
2047
+ * | "..." nullCoalescingExpr
2048
+ * | identifier "=" expr
2049
+ * ;
2050
+ */
2051
+ parseCondOrSpreadOrAsgnOrArrowExpr() {
2052
+ const e = this._lexer.peek();
2053
+ if (e.type === i.Spread) {
2054
+ this._lexer.get();
2055
+ const l = this.parseNullCoalescingExpr();
2056
+ return l ? this.createExpressionNode(
2057
+ "SpreadE",
2058
+ {
2059
+ operand: l
2060
+ },
2061
+ e,
2062
+ l.endToken
2063
+ ) : null;
2064
+ }
2065
+ if (e.type === i.Function) {
2066
+ const l = this.parseFunctionDeclaration(!0);
2067
+ return l ? this.createExpressionNode(
2068
+ "ArrowE",
2069
+ {
2070
+ name: l.name,
2071
+ args: l.args,
2072
+ statement: l.statement
2073
+ },
2074
+ e,
2075
+ l.endToken
2076
+ ) : null;
2077
+ }
2078
+ const r = this.parseNullCoalescingExpr();
2079
+ if (!r)
2080
+ return null;
2081
+ const t = this._lexer.peek();
2082
+ if (t.type === i.Arrow)
2083
+ return this.parseArrowExpression(e, r);
2084
+ if (t.type === i.QuestionMark) {
2085
+ this._lexer.get();
2086
+ const l = this.getExpression(!1);
2087
+ this.expectToken(i.Colon);
2088
+ const a = this.getExpression(!1);
2089
+ return this.createExpressionNode(
2090
+ "CondE",
2091
+ {
2092
+ condition: r,
2093
+ consequent: l,
2094
+ alternate: a
2095
+ },
2096
+ e,
2097
+ a.endToken
2098
+ );
2099
+ }
2100
+ if (j[t.type].isAssignment) {
2101
+ this._lexer.get();
2102
+ const l = this.getExpression();
2103
+ return l ? this.createExpressionNode(
2104
+ "AsgnE",
2105
+ {
2106
+ leftValue: r,
2107
+ operator: t.text,
2108
+ operand: l
2109
+ },
2110
+ e,
2111
+ l.endToken
2112
+ ) : null;
2113
+ }
2114
+ return r;
2115
+ }
2116
+ /**
2117
+ * Parses an arrow expression
2118
+ * @param start Start token
2119
+ * @param left Expression to the left from the arrow
2120
+ */
2121
+ parseArrowExpression(e, r) {
2122
+ let t;
2123
+ const l = [];
2124
+ switch (r.type) {
2125
+ case "NoArgE":
2126
+ t = !0;
2127
+ break;
2128
+ case "IdE":
2129
+ t = (r.parenthesized ?? 0) <= 1, l.push(r);
2130
+ break;
2131
+ case "SeqE":
2132
+ t = r.parenthesized === 1;
2133
+ let o = !1;
2134
+ if (t)
2135
+ for (const c of r.expressions) {
2136
+ if (o) {
2137
+ t = !1;
2138
+ break;
2139
+ }
2140
+ switch (c.type) {
2141
+ case "IdE":
2142
+ t = !c.parenthesized, l.push(c);
2143
+ break;
2144
+ case "OLitE": {
2145
+ if (t = !c.parenthesized, t) {
2146
+ const s = this.convertToObjectDestructure(c);
2147
+ s && l.push(s);
2148
+ }
2149
+ break;
2150
+ }
2151
+ case "ALitE": {
2152
+ if (t = !c.parenthesized, t) {
2153
+ const s = this.convertToArrayDestructure(c);
2154
+ s && l.push(s);
2155
+ }
2156
+ break;
2157
+ }
2158
+ case "SpreadE": {
2159
+ if (o = !0, c.operand.type !== "IdE") {
2160
+ t = !1;
2161
+ break;
2162
+ }
2163
+ l.push(c);
2164
+ break;
2165
+ }
2166
+ default:
2167
+ t = !1;
2168
+ break;
2169
+ }
2170
+ }
2171
+ break;
2172
+ case "OLitE":
2173
+ if (t = r.parenthesized === 1, t) {
2174
+ const c = this.convertToObjectDestructure(r);
2175
+ c && l.push(c);
2176
+ }
2177
+ break;
2178
+ case "ALitE":
2179
+ if (t = r.parenthesized === 1, t) {
2180
+ const c = this.convertToArrayDestructure(r);
2181
+ c && l.push(c);
2182
+ }
2183
+ break;
2184
+ case "SpreadE":
2185
+ t = r.operand.type === "IdE", t && l.push(r);
2186
+ break;
2187
+ default:
2188
+ t = !1;
2189
+ }
2190
+ if (!t)
2191
+ return this.reportError("W010", e), null;
2192
+ this._lexer.get();
2193
+ const a = this.parseStatement(!1);
2194
+ return a ? this.createExpressionNode(
2195
+ "ArrowE",
2196
+ {
2197
+ args: l,
2198
+ statement: a
2199
+ },
2200
+ e,
2201
+ a.endToken
2202
+ ) : null;
2203
+ }
2204
+ /**
2205
+ * nullCoalescingExpr
2206
+ * : logicalOrExpr ( "??" logicalOrExpr )?
2207
+ * ;
2208
+ */
2209
+ parseNullCoalescingExpr() {
2210
+ const e = this._lexer.peek();
2211
+ let r = this.parseLogicalOrExpr();
2212
+ if (!r)
2213
+ return null;
2214
+ for (; this.skipToken(i.NullCoalesce); ) {
2215
+ const t = this.parseLogicalOrExpr();
2216
+ if (!t)
2217
+ return this.reportError("W001"), null;
2218
+ let l = t.endToken;
2219
+ r = this.createExpressionNode(
2220
+ "BinaryE",
2221
+ {
2222
+ operator: "??",
2223
+ left: r,
2224
+ right: t
2225
+ },
2226
+ e,
2227
+ l
2228
+ );
2229
+ }
2230
+ return r;
2231
+ }
2232
+ /**
2233
+ * logicalOrExpr
2234
+ * : logicalAndExpr ( "||" logicalAndExpr )?
2235
+ * ;
2236
+ */
2237
+ parseLogicalOrExpr() {
2238
+ const e = this._lexer.peek();
2239
+ let r = this.parseLogicalAndExpr();
2240
+ if (!r)
2241
+ return null;
2242
+ for (; this.skipToken(i.LogicalOr); ) {
2243
+ const t = this.parseLogicalAndExpr();
2244
+ if (!t)
2245
+ return this.reportError("W001"), null;
2246
+ let l = t.endToken;
2247
+ r = this.createExpressionNode(
2248
+ "BinaryE",
2249
+ {
2250
+ operator: "||",
2251
+ left: r,
2252
+ right: t
2253
+ },
2254
+ e,
2255
+ l
2256
+ );
2257
+ }
2258
+ return r;
2259
+ }
2260
+ /**
2261
+ * logicalAndExpr
2262
+ * : bitwiseOrExpr ( "&&" bitwiseOrExpr )?
2263
+ * ;
2264
+ */
2265
+ parseLogicalAndExpr() {
2266
+ const e = this._lexer.peek();
2267
+ let r = this.parseBitwiseOrExpr();
2268
+ if (!r)
2269
+ return null;
2270
+ for (; this.skipToken(i.LogicalAnd); ) {
2271
+ const t = this.parseBitwiseOrExpr();
2272
+ if (!t)
2273
+ return this.reportError("W001"), null;
2274
+ let l = t.endToken;
2275
+ r = this.createExpressionNode(
2276
+ "BinaryE",
2277
+ {
2278
+ operator: "&&",
2279
+ left: r,
2280
+ right: t
2281
+ },
2282
+ e,
2283
+ l
2284
+ );
2285
+ }
2286
+ return r;
2287
+ }
2288
+ /**
2289
+ * bitwiseOrExpr
2290
+ * : bitwiseXorExpr ( "|" bitwiseXorExpr )?
2291
+ * ;
2292
+ */
2293
+ parseBitwiseOrExpr() {
2294
+ const e = this._lexer.peek();
2295
+ let r = this.parseBitwiseXorExpr();
2296
+ if (!r)
2297
+ return null;
2298
+ for (; this.skipToken(i.BitwiseOr); ) {
2299
+ const t = this.parseBitwiseXorExpr();
2300
+ if (!t)
2301
+ return this.reportError("W001"), null;
2302
+ let l = t.endToken;
2303
+ r = this.createExpressionNode(
2304
+ "BinaryE",
2305
+ {
2306
+ operator: "|",
2307
+ left: r,
2308
+ right: t
2309
+ },
2310
+ e,
2311
+ l
2312
+ );
2313
+ }
2314
+ return r;
2315
+ }
2316
+ /**
2317
+ * bitwiseXorExpr
2318
+ * : bitwiseAndExpr ( "^" bitwiseAndExpr )?
2319
+ * ;
2320
+ */
2321
+ parseBitwiseXorExpr() {
2322
+ const e = this._lexer.peek();
2323
+ let r = this.parseBitwiseAndExpr();
2324
+ if (!r)
2325
+ return null;
2326
+ for (; this.skipToken(i.BitwiseXor); ) {
2327
+ const t = this.parseBitwiseAndExpr();
2328
+ if (!t)
2329
+ return this.reportError("W001"), null;
2330
+ let l = t.endToken;
2331
+ r = this.createExpressionNode(
2332
+ "BinaryE",
2333
+ {
2334
+ operator: "^",
2335
+ left: r,
2336
+ right: t
2337
+ },
2338
+ e,
2339
+ l
2340
+ );
2341
+ }
2342
+ return r;
2343
+ }
2344
+ /**
2345
+ * bitwiseAndExpr
2346
+ * : equExpr ( "&" equExpr )?
2347
+ * ;
2348
+ */
2349
+ parseBitwiseAndExpr() {
2350
+ const e = this._lexer.peek();
2351
+ let r = this.parseEquExpr();
2352
+ if (!r)
2353
+ return null;
2354
+ for (; this.skipToken(i.BitwiseAnd); ) {
2355
+ const t = this.parseEquExpr();
2356
+ if (!t)
2357
+ return this.reportError("W001"), null;
2358
+ let l = t.endToken;
2359
+ r = this.createExpressionNode(
2360
+ "BinaryE",
2361
+ {
2362
+ operator: "&",
2363
+ left: r,
2364
+ right: t
2365
+ },
2366
+ e,
2367
+ l
2368
+ );
2369
+ }
2370
+ return r;
2371
+ }
2372
+ /**
2373
+ * equExpr
2374
+ * : relOrInExpr ( ( "==" | "!=" | "===" | "!==" ) relOrInExpr )?
2375
+ * ;
2376
+ */
2377
+ parseEquExpr() {
2378
+ const e = this._lexer.peek();
2379
+ let r = this.parseRelOrInExpr();
2380
+ if (!r)
2381
+ return null;
2382
+ let t;
2383
+ for (; t = this.skipTokens(
2384
+ i.Equal,
2385
+ i.StrictEqual,
2386
+ i.NotEqual,
2387
+ i.StrictNotEqual
2388
+ ); ) {
2389
+ const l = this.parseRelOrInExpr();
2390
+ if (!l)
2391
+ return this.reportError("W001"), null;
2392
+ let a = l.endToken;
2393
+ r = this.createExpressionNode(
2394
+ "BinaryE",
2395
+ {
2396
+ type: "BinaryE",
2397
+ operator: t.text,
2398
+ left: r,
2399
+ right: l
2400
+ },
2401
+ e,
2402
+ a
2403
+ );
2404
+ }
2405
+ return r;
2406
+ }
2407
+ /**
2408
+ * relOrInExpr
2409
+ * : shiftExpr ( ( "<" | "<=" | ">" | ">=", "in" ) shiftExpr )?
2410
+ * ;
2411
+ */
2412
+ parseRelOrInExpr() {
2413
+ const e = this._lexer.peek();
2414
+ let r = this.parseShiftExpr();
2415
+ if (!r)
2416
+ return null;
2417
+ let t;
2418
+ for (; t = this.skipTokens(
2419
+ i.LessThan,
2420
+ i.LessThanOrEqual,
2421
+ i.GreaterThan,
2422
+ i.GreaterThanOrEqual,
2423
+ i.In
2424
+ ); ) {
2425
+ const l = this.parseShiftExpr();
2426
+ if (!l)
2427
+ return this.reportError("W001"), null;
2428
+ let a = l.endToken;
2429
+ r = this.createExpressionNode(
2430
+ "BinaryE",
2431
+ {
2432
+ operator: t.text,
2433
+ left: r,
2434
+ right: l
2435
+ },
2436
+ e,
2437
+ a
2438
+ );
2439
+ }
2440
+ return r;
2441
+ }
2442
+ /**
2443
+ * shiftExpr
2444
+ * : addExpr ( ( "<<" | ">>" | ">>>" ) addExpr )?
2445
+ * ;
2446
+ */
2447
+ parseShiftExpr() {
2448
+ const e = this._lexer.peek();
2449
+ let r = this.parseAddExpr();
2450
+ if (!r)
2451
+ return null;
2452
+ let t;
2453
+ for (; t = this.skipTokens(
2454
+ i.ShiftLeft,
2455
+ i.ShiftRight,
2456
+ i.SignedShiftRight
2457
+ ); ) {
2458
+ const l = this.parseAddExpr();
2459
+ if (!l)
2460
+ return this.reportError("W001"), null;
2461
+ let a = l.endToken;
2462
+ r = this.createExpressionNode(
2463
+ "BinaryE",
2464
+ {
2465
+ operator: t.text,
2466
+ left: r,
2467
+ right: l
2468
+ },
2469
+ e,
2470
+ a
2471
+ );
2472
+ }
2473
+ return r;
2474
+ }
2475
+ /**
2476
+ * addExpr
2477
+ * : multExpr ( ( "+" | "-" ) multExpr )?
2478
+ * ;
2479
+ */
2480
+ parseAddExpr() {
2481
+ const e = this._lexer.peek();
2482
+ let r = this.parseMultExpr();
2483
+ if (!r)
2484
+ return null;
2485
+ let t;
2486
+ for (; t = this.skipTokens(i.Plus, i.Minus); ) {
2487
+ const l = this.parseMultExpr();
2488
+ if (!l)
2489
+ return this.reportError("W001"), null;
2490
+ let a = l.endToken;
2491
+ r = this.createExpressionNode(
2492
+ "BinaryE",
2493
+ {
2494
+ operator: t.text,
2495
+ left: r,
2496
+ right: l
2497
+ },
2498
+ e,
2499
+ a
2500
+ );
2501
+ }
2502
+ return r;
2503
+ }
2504
+ /**
2505
+ * multExpr
2506
+ * : exponentialExpr ( ( "*" | "/" | "%") exponentialExpr )?
2507
+ * ;
2508
+ */
2509
+ parseMultExpr() {
2510
+ const e = this._lexer.peek();
2511
+ let r = this.parseExponentialExpr();
2512
+ if (!r)
2513
+ return null;
2514
+ let t;
2515
+ for (; t = this.skipTokens(i.Multiply, i.Divide, i.Remainder); ) {
2516
+ const l = this.parseExponentialExpr();
2517
+ if (!l)
2518
+ return this.reportError("W001"), null;
2519
+ let a = l.endToken;
2520
+ r = this.createExpressionNode(
2521
+ "BinaryE",
2522
+ {
2523
+ operator: t.text,
2524
+ left: r,
2525
+ right: l
2526
+ },
2527
+ e,
2528
+ a
2529
+ );
2530
+ }
2531
+ return r;
2532
+ }
2533
+ /**
2534
+ * exponentialExpr
2535
+ * : unaryExpr ( "**" unaryExpr )?
2536
+ * ;
2537
+ */
2538
+ parseExponentialExpr() {
2539
+ const e = this._lexer.peek();
2540
+ let r = this.parseUnaryOrPrefixExpr();
2541
+ if (!r)
2542
+ return null;
2543
+ let t, l = 0;
2544
+ for (; t = this.skipToken(i.Exponent); ) {
2545
+ let a = this.parseUnaryOrPrefixExpr();
2546
+ if (!a)
2547
+ return this.reportError("W001"), null;
2548
+ let o = a.endToken;
2549
+ if (l === 0)
2550
+ r = this.createExpressionNode(
2551
+ "BinaryE",
2552
+ {
2553
+ operator: t.text,
2554
+ left: r,
2555
+ right: a
2556
+ },
2557
+ e,
2558
+ o
2559
+ );
2560
+ else {
2561
+ const c = r;
2562
+ r = this.createExpressionNode(
2563
+ "BinaryE",
2564
+ {
2565
+ operator: t.text,
2566
+ left: c.left,
2567
+ right: {
2568
+ type: "BinaryE",
2569
+ operator: t.text,
2570
+ left: c.right,
2571
+ right: a
2572
+ }
2573
+ },
2574
+ e,
2575
+ o
2576
+ );
2577
+ }
2578
+ l++;
2579
+ }
2580
+ return r;
2581
+ }
2582
+ /**
2583
+ * unaryExpr
2584
+ * : ( "typeof" | "delete" | "+" | "-" | "~" | "!" ) memberOrInvocationExpr
2585
+ * | memberOrInvocationExpr
2586
+ * ;
2587
+ */
2588
+ parseUnaryOrPrefixExpr() {
2589
+ const e = this._lexer.peek();
2590
+ if (j[e.type].canBeUnary) {
2591
+ this._lexer.get();
2592
+ const r = this.parseUnaryOrPrefixExpr();
2593
+ return r ? this.createExpressionNode(
2594
+ "UnaryE",
2595
+ {
2596
+ operator: e.text,
2597
+ operand: r
2598
+ },
2599
+ e,
2600
+ r.endToken
2601
+ ) : null;
2602
+ }
2603
+ if (e.type === i.IncOp || e.type === i.DecOp) {
2604
+ this._lexer.get();
2605
+ const r = this.parseMemberOrInvocationExpr();
2606
+ return r ? this.createExpressionNode(
2607
+ "PrefE",
2608
+ {
2609
+ operator: e.text,
2610
+ operand: r
2611
+ },
2612
+ e,
2613
+ r.endToken
2614
+ ) : null;
2615
+ }
2616
+ return this.parseMemberOrInvocationExpr();
2617
+ }
2618
+ /**
2619
+ * memberOrInvocationExpr
2620
+ * : primaryExpr "(" functionArgs ")"
2621
+ * | primaryExpr "." identifier
2622
+ * | primaryExpr "?." identifier
2623
+ * | primaryExpr "[" expr "]"
2624
+ * ;
2625
+ */
2626
+ parseMemberOrInvocationExpr() {
2627
+ const e = this._lexer.peek();
2628
+ let r = this.parsePrimaryExpr();
2629
+ if (!r)
2630
+ return null;
2631
+ let t = !1;
2632
+ do {
2633
+ const a = this._lexer.peek();
2634
+ switch (a.type) {
2635
+ case i.LParent: {
2636
+ this._lexer.get();
2637
+ let L = [];
2638
+ if (this._lexer.peek().type !== i.RParent) {
2639
+ const O = this.parseExpr();
2640
+ if (!O)
2641
+ return this.reportError("W001"), null;
2642
+ L = O.type === "SeqE" ? O.expressions : [O];
2643
+ }
2644
+ const u = this._lexer.peek();
2645
+ this.expectToken(i.RParent, "W006"), r = this.createExpressionNode(
2646
+ "InvokeE",
2647
+ {
2648
+ object: r,
2649
+ arguments: L
2650
+ },
2651
+ e,
2652
+ u
2653
+ );
2654
+ break;
2655
+ }
2656
+ case i.Dot:
2657
+ case i.OptionalChaining:
2658
+ this._lexer.get();
2659
+ const o = this._lexer.get();
2660
+ if (!j[o.type].keywordLike)
2661
+ return this.reportError("W003"), null;
2662
+ r = this.createExpressionNode(
2663
+ "MembE",
2664
+ {
2665
+ object: r,
2666
+ member: o.text,
2667
+ isOptional: a.type === i.OptionalChaining
2668
+ },
2669
+ e,
2670
+ o
2671
+ );
2672
+ break;
2673
+ case i.LSquare:
2674
+ this._lexer.get();
2675
+ const s = this.getExpression();
2676
+ if (!s)
2677
+ return null;
2678
+ const D = this._lexer.peek();
2679
+ this.expectToken(i.RSquare, "W005"), r = this.createExpressionNode(
2680
+ "CMembE",
2681
+ {
2682
+ object: r,
2683
+ member: s
2684
+ },
2685
+ e,
2686
+ D
2687
+ );
2688
+ break;
2689
+ default:
2690
+ t = !0;
2691
+ break;
2692
+ }
2693
+ } while (!t);
2694
+ const l = this._lexer.peek();
2695
+ return l.type === i.IncOp || l.type === i.DecOp ? (this._lexer.get(), this.createExpressionNode(
2696
+ "PostfE",
2697
+ {
2698
+ operator: l.text,
2699
+ operand: r
2700
+ },
2701
+ e,
2702
+ l
2703
+ )) : r;
2704
+ }
2705
+ /**
2706
+ * primaryExpr
2707
+ * : literal
2708
+ * | identifier
2709
+ * | "::" identifier
2710
+ * | "$item"
2711
+ * | "(" expr ")"
2712
+ * ;
2713
+ */
2714
+ parsePrimaryExpr() {
2715
+ const e = this._lexer.peek();
2716
+ switch (e.type) {
2717
+ case i.LParent:
2718
+ if (this._lexer.get(), this._lexer.peek().type === i.RParent) {
2719
+ const l = this._lexer.get();
2720
+ return this.createExpressionNode("NoArgE", {}, e, l);
2721
+ }
2722
+ const r = this.parseExpr();
2723
+ if (!r)
2724
+ return null;
2725
+ const t = this._lexer.peek();
2726
+ return this.expectToken(i.RParent, "W006"), r.parenthesized ?? (r.parenthesized = 0), r.parenthesized++, r.startToken = e, r.startPosition = e.location.startPosition, r.startLine = e.location.startLine, r.startColumn = e.location.startColumn, r.endToken = t, r.endPosition = t.location.endPosition, r.endLine = t.location.endLine, r.endColumn = t.location.endColumn, r.source = this.getSource(e, t), r;
2727
+ case i.Identifier: {
2728
+ const l = this._lexer.get();
2729
+ return this.createExpressionNode(
2730
+ "IdE",
2731
+ {
2732
+ name: l.text
2733
+ },
2734
+ l,
2735
+ l
2736
+ );
2737
+ }
2738
+ case i.Global: {
2739
+ this._lexer.get();
2740
+ const l = this._lexer.get();
2741
+ return l.type !== i.Identifier ? (this.reportError("W003"), null) : this.createExpressionNode(
2742
+ "IdE",
2743
+ {
2744
+ name: l.text,
2745
+ isGlobal: !0
2746
+ },
2747
+ l,
2748
+ l
2749
+ );
2750
+ }
2751
+ case i.Backtick:
2752
+ return this.parseTemplateLiteral();
2753
+ case i.False:
2754
+ case i.True:
2755
+ return this._lexer.get(), this.createExpressionNode(
2756
+ "LitE",
2757
+ {
2758
+ value: e.type === i.True
2759
+ },
2760
+ e,
2761
+ e
2762
+ );
2763
+ case i.BinaryLiteral:
2764
+ return this._lexer.get(), this.parseBinaryLiteral(e);
2765
+ case i.DecimalLiteral:
2766
+ return this._lexer.get(), this.parseDecimalLiteral(e);
2767
+ case i.HexadecimalLiteral:
2768
+ return this._lexer.get(), this.parseHexadecimalLiteral(e);
2769
+ case i.RealLiteral:
2770
+ return this._lexer.get(), this.parseRealLiteral(e);
2771
+ case i.StringLiteral:
2772
+ return this._lexer.get(), this.parseStringLiteral(e);
2773
+ case i.Infinity:
2774
+ return this._lexer.get(), this.createExpressionNode(
2775
+ "LitE",
2776
+ {
2777
+ value: 1 / 0
2778
+ },
2779
+ e,
2780
+ e
2781
+ );
2782
+ case i.NaN:
2783
+ return this._lexer.get(), this.createExpressionNode(
2784
+ "LitE",
2785
+ {
2786
+ value: NaN
2787
+ },
2788
+ e,
2789
+ e
2790
+ );
2791
+ case i.Null:
2792
+ return this._lexer.get(), this.createExpressionNode(
2793
+ "LitE",
2794
+ {
2795
+ value: null
2796
+ },
2797
+ e,
2798
+ e
2799
+ );
2800
+ case i.Undefined:
2801
+ return this._lexer.get(), this.createExpressionNode(
2802
+ "LitE",
2803
+ {
2804
+ value: void 0
2805
+ },
2806
+ e,
2807
+ e
2808
+ );
2809
+ case i.LSquare:
2810
+ return this.parseArrayLiteral();
2811
+ case i.LBrace:
2812
+ return this.parseObjectLiteral();
2813
+ case i.Divide:
2814
+ return this.parseRegExpLiteral();
2815
+ }
2816
+ return null;
2817
+ }
2818
+ parseTemplateLiteral() {
2819
+ const e = this._lexer.get();
2820
+ this._lexer.setStartingPhaseToTemplateLiteral();
2821
+ const r = [];
2822
+ e: for (; ; ) {
2823
+ let l = this._lexer.peek();
2824
+ switch (l.type) {
2825
+ case i.StringLiteral:
2826
+ this._lexer.get();
2827
+ const a = this.parseStringLiteral(l, !1);
2828
+ r.push(a);
2829
+ break;
2830
+ case i.DollarLBrace:
2831
+ this._lexer.get();
2832
+ const o = this.parseExpr();
2833
+ r.push(o), this.expectToken(i.RBrace, "W004"), this._lexer.setStartingPhaseToTemplateLiteral();
2834
+ break;
2835
+ case i.Backtick:
2836
+ break e;
2837
+ default:
2838
+ this.reportError("W004");
2839
+ }
2840
+ }
2841
+ const t = this._lexer.get();
2842
+ return this.createExpressionNode(
2843
+ "TempLitE",
2844
+ { segments: r },
2845
+ e,
2846
+ t
2847
+ );
2848
+ }
2849
+ /**
2850
+ * Parses an array literal
2851
+ */
2852
+ parseArrayLiteral() {
2853
+ const e = this._lexer.get();
2854
+ let r = [];
2855
+ if (this._lexer.peek().type !== i.RSquare) {
2856
+ const l = this.getExpression();
2857
+ l && (r = l.type === "SeqE" ? l.expressions : [l]);
2858
+ }
2859
+ const t = this._lexer.peek();
2860
+ return this.expectToken(i.RSquare), this.createExpressionNode(
2861
+ "ALitE",
2862
+ {
2863
+ items: r
2864
+ },
2865
+ e,
2866
+ t
2867
+ );
2868
+ }
2869
+ /**
2870
+ * Parses an object literal
2871
+ */
2872
+ parseObjectLiteral() {
2873
+ const e = this._lexer.get();
2874
+ let r = [];
2875
+ if (this._lexer.peek().type !== i.RBrace)
2876
+ for (; this._lexer.peek().type !== i.RBrace; ) {
2877
+ const l = this._lexer.peek(), a = j[l.type];
2878
+ let o;
2879
+ if (a.expressionStart)
2880
+ if (l.type === i.LSquare) {
2881
+ if (this._lexer.get(), o = this.getExpression(), !o)
2882
+ return null;
2883
+ this.expectToken(i.RSquare, "W005"), o = this.createExpressionNode(
2884
+ "SeqE",
2885
+ {
2886
+ expressions: [o]
2887
+ },
2888
+ e
2889
+ );
2890
+ } else if (a.isPropLiteral) {
2891
+ if (o = this.getExpression(!1), !o)
2892
+ return null;
2893
+ if (o.type !== "IdE" && o.type !== "LitE" && o.type !== "SpreadE")
2894
+ return this.reportError("W007"), null;
2895
+ } else
2896
+ return this.reportError("W007"), null;
2897
+ else if (a.keywordLike)
2898
+ o = {
2899
+ type: "IdE",
2900
+ name: l.text,
2901
+ value: void 0,
2902
+ startPosition: l.location.startPosition,
2903
+ startLine: l.location.startLine,
2904
+ startColumn: l.location.startColumn,
2905
+ endPosition: l.location.endPosition,
2906
+ endLine: l.location.endLine,
2907
+ endColumn: l.location.endColumn,
2908
+ source: l.text,
2909
+ startToken: l,
2910
+ endToken: l
2911
+ }, this._lexer.get();
2912
+ else
2913
+ return this.reportError("W001"), null;
2914
+ const c = o.type;
2915
+ if (c === "SpreadE")
2916
+ r.push(o);
2917
+ else {
2918
+ if (c === "LitE") {
2919
+ const L = o.value;
2920
+ if (typeof L != "number" && typeof L != "string")
2921
+ return this.expectToken(i.RBrace, "W007"), null;
2922
+ }
2923
+ let D = null;
2924
+ if (c === "IdE") {
2925
+ const L = this._lexer.peek();
2926
+ (L.type === i.Comma || L.type === i.RBrace) && (D = { ...o });
2927
+ }
2928
+ if (!D && (this.expectToken(i.Colon, "W008"), D = this.getExpression(!1), !D))
2929
+ return null;
2930
+ r.push([o, D]);
2931
+ }
2932
+ const s = this._lexer.peek().type;
2933
+ if (s === i.Comma)
2934
+ this._lexer.get();
2935
+ else if (s !== i.RBrace)
2936
+ break;
2937
+ }
2938
+ const t = this._lexer.peek();
2939
+ return this.expectToken(i.RBrace, "W004"), this.createExpressionNode(
2940
+ "OLitE",
2941
+ {
2942
+ props: r
2943
+ },
2944
+ e,
2945
+ t
2946
+ );
2947
+ }
2948
+ parseRegExpLiteral() {
2949
+ const e = this._lexer.peek(), r = this._lexer.getRegEx();
2950
+ return r.success ? this.createExpressionNode(
2951
+ "LitE",
2952
+ {
2953
+ value: new RegExp(r.pattern, r.flags)
2954
+ },
2955
+ e,
2956
+ this._lexer.peek()
2957
+ ) : (this.reportError("W002", e, r.pattern ?? ""), null);
2958
+ }
2959
+ /**
2960
+ * Gets an expression
2961
+ */
2962
+ getExpression(e = !0) {
2963
+ const r = this.parseExpr(e);
2964
+ return r || (this.reportError("W001"), null);
2965
+ }
2966
+ // ==========================================================================
2967
+ // Helpers
2968
+ /**
2969
+ * Tests the type of the next token
2970
+ * @param type Expected token type
2971
+ * @param errorCode Error to raise if the next token is not expected
2972
+ * @param allowEof Allow an EOF instead of the expected token?
2973
+ */
2974
+ expectToken(e, r, t) {
2975
+ const l = this._lexer.peek();
2976
+ return l.type === e || t && l.type === i.Eof ? this._lexer.get() : (this.reportError(r ?? "W002", l, l.text), null);
2977
+ }
2978
+ /**
2979
+ * Skips the next token if the type is the specified one
2980
+ * @param type Token type to check
2981
+ */
2982
+ skipToken(e) {
2983
+ const r = this._lexer.peek();
2984
+ return r.type === e ? (this._lexer.get(), r) : null;
2985
+ }
2986
+ /**
2987
+ * Skips the next token if the type is the specified one
2988
+ * @param types Token types to check
2989
+ */
2990
+ skipTokens(...e) {
2991
+ const r = this._lexer.peek();
2992
+ for (const t of e)
2993
+ if (r.type === t)
2994
+ return this._lexer.get(), r;
2995
+ return null;
2996
+ }
2997
+ /**
2998
+ * Reports the specified error
2999
+ * @param errorCode Error code
3000
+ * @param token Token that represents the error's position
3001
+ * @param options Error message options
3002
+ */
3003
+ reportError(e, r, ...t) {
3004
+ let l = ie[e] ?? "Unkonwn error";
3005
+ throw t && t.forEach(
3006
+ (o, c) => l = a(l, `{${c}}`, t[c].toString())
3007
+ ), r || (r = this._lexer.peek()), this._parseErrors.push({
3008
+ code: e,
3009
+ text: l,
3010
+ line: r.location.startLine,
3011
+ column: r.location.startColumn,
3012
+ position: r.location.startPosition
3013
+ }), new Ge(l, e);
3014
+ function a(o, c, s) {
3015
+ do
3016
+ o = o.replace(c, s);
3017
+ while (o.includes(c));
3018
+ return o;
3019
+ }
3020
+ }
3021
+ /**
3022
+ * Creates an expression node
3023
+ * @param type Expression type
3024
+ * @param stump Stump properties
3025
+ * @param startToken The token that starts the expression
3026
+ * @param endToken The token that ends the expression
3027
+ * @param source Expression source code to store to the node
3028
+ */
3029
+ createNode(e, r, t, l, a) {
3030
+ l || (l = this._lexer.peek());
3031
+ const o = t.location.startPosition, c = l.location.startPosition;
3032
+ return Object.assign({}, r, {
3033
+ type: e,
3034
+ startPosition: o,
3035
+ endPosition: c,
3036
+ startLine: t.location.startLine,
3037
+ startColumn: t.location.startColumn,
3038
+ endLine: l.location.endLine,
3039
+ endColumn: l.location.endColumn,
3040
+ source: a ?? this.getSource(t, l)
3041
+ });
3042
+ }
3043
+ /**
3044
+ * Creates an expression node
3045
+ * @param type Expression type
3046
+ * @param stump Stump properties
3047
+ * @param startToken The token that starts the expression
3048
+ * @param endToken The token that ends the expression
3049
+ * @param source Expression source code to store to the node
3050
+ */
3051
+ createExpressionNode(e, r = {}, t, l, a) {
3052
+ l || (l = this._lexer.peek()), t || (t = l);
3053
+ const o = t.location.startPosition, c = l.location.endPosition;
3054
+ return Object.assign({}, r, {
3055
+ type: e,
3056
+ startPosition: o,
3057
+ endPosition: c,
3058
+ startLine: t.location.startLine,
3059
+ startColumn: t.location.startColumn,
3060
+ endLine: l.location.endLine,
3061
+ endColumn: l.location.endColumn,
3062
+ source: a ?? this.getSource(t, l),
3063
+ startToken: t,
3064
+ endToken: l
3065
+ });
3066
+ }
3067
+ /**
3068
+ * Creates a statement node
3069
+ * @param type Statement type
3070
+ * @param stump Stump properties
3071
+ * @param startToken The token that starts the statement
3072
+ * @param endToken The token that ends the statement
3073
+ */
3074
+ createStatementNode(e, r, t, l) {
3075
+ var s, D, L, u, O;
3076
+ const a = (s = t == null ? void 0 : t.location) == null ? void 0 : s.startPosition, o = this._lexer.peek(), c = l ? l.location.endPosition : o.type === i.Eof ? o.location.startPosition + 1 : o.location.startPosition;
3077
+ return Object.assign({}, r, {
3078
+ type: e,
3079
+ startPosition: a,
3080
+ endPosition: c,
3081
+ startLine: (D = t == null ? void 0 : t.location) == null ? void 0 : D.startLine,
3082
+ startColumn: (L = t == null ? void 0 : t.location) == null ? void 0 : L.startColumn,
3083
+ endLine: l ? l.location.endLine : (u = t == null ? void 0 : t.location) == null ? void 0 : u.endLine,
3084
+ endColumn: l ? l.location.endColumn : (O = t == null ? void 0 : t.location) == null ? void 0 : O.endColumn,
3085
+ source: this.source && a !== void 0 && c !== void 0 ? this.source.substring(a, c) : void 0,
3086
+ startToken: t,
3087
+ endToken: l
3088
+ });
3089
+ }
3090
+ /**
3091
+ * Gets the source code for the specified token range
3092
+ * @param start Start token
3093
+ * @param end Optional end token
3094
+ * @returns The source code for the token range
3095
+ */
3096
+ getSource(e, r) {
3097
+ return this.source.substring(
3098
+ e.location.startPosition,
3099
+ r.type === i.Eof ? r.location.startPosition : r.location.endPosition
3100
+ );
3101
+ }
3102
+ /**
3103
+ * Parses a binary literal
3104
+ * @param token Literal token
3105
+ */
3106
+ parseBinaryLiteral(e) {
3107
+ let r;
3108
+ const t = BigInt(e.text.replace(/[_']/g, ""));
3109
+ return t < Number.MIN_SAFE_INTEGER || t > Number.MAX_SAFE_INTEGER ? r = t : r = parseInt(e.text.substring(2).replace(/[_']/g, ""), 2), this.createExpressionNode(
3110
+ "LitE",
3111
+ {
3112
+ value: r
3113
+ },
3114
+ e,
3115
+ e
3116
+ );
3117
+ }
3118
+ /**
3119
+ * Parses a decimal literal
3120
+ * @param token Literal token
3121
+ */
3122
+ parseDecimalLiteral(e) {
3123
+ let r;
3124
+ const t = BigInt(e.text.replace(/[_']/g, ""));
3125
+ return t < Number.MIN_SAFE_INTEGER || t > Number.MAX_SAFE_INTEGER ? r = t : r = parseInt(e.text.replace(/[_']/g, ""), 10), this.createExpressionNode(
3126
+ "LitE",
3127
+ {
3128
+ value: r
3129
+ },
3130
+ e,
3131
+ e
3132
+ );
3133
+ }
3134
+ /**
3135
+ * Parses a hexadecimal literal
3136
+ * @param token Literal token
3137
+ */
3138
+ parseHexadecimalLiteral(e) {
3139
+ let r;
3140
+ const t = BigInt(e.text.replace(/[_']/g, ""));
3141
+ return t < Number.MIN_SAFE_INTEGER || t > Number.MAX_SAFE_INTEGER ? r = t : r = parseInt(e.text.substring(2).replace(/[_']/g, ""), 16), this.createExpressionNode(
3142
+ "LitE",
3143
+ {
3144
+ value: r
3145
+ },
3146
+ e,
3147
+ e
3148
+ );
3149
+ }
3150
+ /**
3151
+ * Parses a real literal
3152
+ * @param token Literal token
3153
+ */
3154
+ parseRealLiteral(e) {
3155
+ let r = parseFloat(e.text.replace(/[_']/g, ""));
3156
+ return this.createExpressionNode(
3157
+ "LitE",
3158
+ {
3159
+ value: r
3160
+ },
3161
+ e,
3162
+ e
3163
+ );
3164
+ }
3165
+ /**
3166
+ * Converts a string token to intrinsic string
3167
+ * @param token Literal token
3168
+ */
3169
+ parseStringLiteral(e, r = !0) {
3170
+ let t = e.text;
3171
+ r && (t = e.text.length < 2 ? "" : t.substring(1, t.length - 1));
3172
+ let l = "", a = 0, o = 0;
3173
+ for (const s of t)
3174
+ switch (a) {
3175
+ case 0:
3176
+ s === "\\" ? a = 1 : l += s;
3177
+ break;
3178
+ case 1:
3179
+ switch (a = 0, s) {
3180
+ case "b":
3181
+ l += "\b";
3182
+ break;
3183
+ case "f":
3184
+ l += "\f";
3185
+ break;
3186
+ case "n":
3187
+ l += `
3188
+ `;
3189
+ break;
3190
+ case "r":
3191
+ l += "\r";
3192
+ break;
3193
+ case "t":
3194
+ l += " ";
3195
+ break;
3196
+ case "v":
3197
+ l += "\v";
3198
+ break;
3199
+ case "S":
3200
+ l += " ";
3201
+ break;
3202
+ case "0":
3203
+ l += "\0";
3204
+ break;
3205
+ case "'":
3206
+ l += "'";
3207
+ break;
3208
+ case '"':
3209
+ l += '"';
3210
+ break;
3211
+ case "\\":
3212
+ l += "\\";
3213
+ break;
3214
+ case "x":
3215
+ a = 2;
3216
+ break;
3217
+ case "u":
3218
+ a = 4;
3219
+ break;
3220
+ default:
3221
+ l += s;
3222
+ break;
3223
+ }
3224
+ break;
3225
+ case 2:
3226
+ c(s) ? (o = parseInt(s, 16), a = 3) : (l += "x", a = 0);
3227
+ break;
3228
+ case 3:
3229
+ c(s) ? (o = o * 16 + parseInt(s, 16), l += String.fromCharCode(o), a = 0) : (l += String.fromCharCode(o), l += s, a = 0);
3230
+ break;
3231
+ case 4:
3232
+ if (s === "{") {
3233
+ a = 8;
3234
+ break;
3235
+ }
3236
+ c(s) ? (o = parseInt(s, 16), a = 5) : (l += "x", a = 0);
3237
+ break;
3238
+ case 5:
3239
+ c(s) ? (o = o * 16 + parseInt(s, 16), a = 6) : (l += String.fromCharCode(o), l += s, a = 0);
3240
+ break;
3241
+ case 6:
3242
+ c(s) ? (o = o * 16 + parseInt(s, 16), a = 7) : (l += String.fromCharCode(o), l += s, a = 0);
3243
+ break;
3244
+ case 7:
3245
+ c(s) ? (o = o * 16 + parseInt(s, 16), l += String.fromCharCode(o), a = 0) : (l += String.fromCharCode(o), l += s, a = 0);
3246
+ break;
3247
+ case 8:
3248
+ c(s) ? (o = parseInt(s, 16), a = 9) : (l += "x", a = 0);
3249
+ break;
3250
+ case 9:
3251
+ c(s) ? (o = o * 16 + parseInt(s, 16), a = 10) : (l += String.fromCharCode(o), l += s, a = 0);
3252
+ break;
3253
+ case 10:
3254
+ c(s) ? (o = o * 16 + parseInt(s, 16), a = 11) : (l += String.fromCharCode(o), l += s, a = 0);
3255
+ break;
3256
+ case 11:
3257
+ c(s) ? (o = o * 16 + parseInt(s, 16), a = 12) : (l += String.fromCharCode(o), l += s, a = 0);
3258
+ break;
3259
+ case 12:
3260
+ c(s) ? (o = o * 16 + parseInt(s, 16), a = 13) : (l += String.fromCharCode(o), l += s, a = 0);
3261
+ break;
3262
+ case 13:
3263
+ c(s) ? (o = o * 16 + parseInt(s, 16), a = 14) : (l += String.fromCharCode(o), l += s, a = 0);
3264
+ break;
3265
+ case 14:
3266
+ l += String.fromCharCode(o), s !== "}" && (l += s), a = 0;
3267
+ break;
3268
+ }
3269
+ switch (a) {
3270
+ case 1:
3271
+ l += "\\";
3272
+ break;
3273
+ case 2:
3274
+ l += "x";
3275
+ break;
3276
+ case 3:
3277
+ l += String.fromCharCode(o);
3278
+ break;
3279
+ }
3280
+ return this.createExpressionNode(
3281
+ "LitE",
3282
+ {
3283
+ value: l
3284
+ },
3285
+ e,
3286
+ e
3287
+ );
3288
+ function c(s) {
3289
+ return s >= "0" && s <= "9" || s >= "a" && s <= "f" || s >= "A" && s <= "F";
3290
+ }
3291
+ }
3292
+ convertToArrayDestructure(e) {
3293
+ var l;
3294
+ const r = e.type === "SeqE" ? e.expressions : e.items, t = this.createExpressionNode(
3295
+ "Destr",
3296
+ { arrayDestruct: [] },
3297
+ e.startToken,
3298
+ e.endToken
3299
+ );
3300
+ for (const a of r) {
3301
+ let o;
3302
+ switch (a.type) {
3303
+ case "NoArgE":
3304
+ o = this.createExpressionNode(
3305
+ "ADestr",
3306
+ {},
3307
+ a.startToken,
3308
+ a.endToken
3309
+ );
3310
+ break;
3311
+ case "IdE":
3312
+ o = this.createExpressionNode(
3313
+ "ADestr",
3314
+ { id: a.name },
3315
+ a.startToken,
3316
+ a.endToken
3317
+ );
3318
+ break;
3319
+ case "Destr":
3320
+ t.arrayDestruct.push(...a.arrayDestruct);
3321
+ break;
3322
+ case "ADestr":
3323
+ o = a;
3324
+ break;
3325
+ case "ALitE": {
3326
+ const c = this.convertToArrayDestructure(a);
3327
+ c && (o = this.createExpressionNode(
3328
+ "ADestr",
3329
+ {
3330
+ arrayDestruct: c.arrayDestruct
3331
+ },
3332
+ a.startToken,
3333
+ a.endToken
3334
+ ));
3335
+ break;
3336
+ }
3337
+ case "ODestr":
3338
+ o = this.createExpressionNode(
3339
+ "ADestr",
3340
+ {
3341
+ objectDestruct: a
3342
+ },
3343
+ a.startToken,
3344
+ a.endToken
3345
+ );
3346
+ break;
3347
+ case "OLitE": {
3348
+ const c = this.convertToObjectDestructure(a);
3349
+ c && (o = this.createExpressionNode(
3350
+ "ADestr",
3351
+ {
3352
+ objectDestruct: c.objectDestruct
3353
+ },
3354
+ a.startToken,
3355
+ a.endToken
3356
+ ));
3357
+ break;
3358
+ }
3359
+ default:
3360
+ return this.reportError("W017"), null;
3361
+ }
3362
+ o && ((l = t.arrayDestruct) == null || l.push(o));
3363
+ }
3364
+ return t;
3365
+ }
3366
+ convertToObjectDestructure(e) {
3367
+ var t;
3368
+ const r = this.createExpressionNode(
3369
+ "Destr",
3370
+ { objectDestruct: [] },
3371
+ e.startToken,
3372
+ e.endToken
3373
+ );
3374
+ for (const l of e.props) {
3375
+ if (!Array.isArray(l)) return this.reportError("W018"), null;
3376
+ const [a, o] = l;
3377
+ if (a.type !== "IdE")
3378
+ return this.reportError("W018"), null;
3379
+ let c;
3380
+ switch (o.type) {
3381
+ case "IdE":
3382
+ o.name === a.name ? c = this.createExpressionNode(
3383
+ "ODestr",
3384
+ { id: a.name },
3385
+ o.startToken,
3386
+ o.endToken
3387
+ ) : c = this.createExpressionNode(
3388
+ "ODestr",
3389
+ {
3390
+ id: a.name,
3391
+ alias: o.name
3392
+ },
3393
+ o.startToken,
3394
+ o.endToken
3395
+ );
3396
+ break;
3397
+ case "ADestr": {
3398
+ c = this.createExpressionNode(
3399
+ "ODestr",
3400
+ {
3401
+ id: a.name,
3402
+ arrayDestruct: o
3403
+ },
3404
+ a.startToken,
3405
+ o.endToken
3406
+ );
3407
+ break;
3408
+ }
3409
+ case "ALitE": {
3410
+ const s = this.convertToArrayDestructure(o);
3411
+ s && (c = this.createExpressionNode(
3412
+ "ODestr",
3413
+ {
3414
+ id: a.name,
3415
+ arrayDestruct: s.arrayDestruct
3416
+ },
3417
+ a.startToken,
3418
+ o.endToken
3419
+ ));
3420
+ break;
3421
+ }
3422
+ case "ODestr":
3423
+ c = o;
3424
+ break;
3425
+ case "OLitE": {
3426
+ const s = this.convertToObjectDestructure(o);
3427
+ s && (c = this.createExpressionNode(
3428
+ "ODestr",
3429
+ {
3430
+ id: a.name,
3431
+ objectDestruct: s.objectDestruct
3432
+ },
3433
+ a.startToken,
3434
+ o.endToken
3435
+ ));
3436
+ break;
3437
+ }
3438
+ default:
3439
+ return this.reportError("W018"), null;
3440
+ }
3441
+ c && ((t = r.objectDestruct) == null || t.push(c));
3442
+ }
3443
+ return r;
3444
+ }
3445
+ /**
3446
+ * Tests if the specified token can be the start of an expression
3447
+ */
3448
+ isExpressionStart(e) {
3449
+ var r;
3450
+ return ((r = j[e.type]) == null ? void 0 : r.expressionStart) ?? !1;
3451
+ }
3452
+ }
3453
+ function x(n, e, r, t, l, a) {
3454
+ if (e.cancel)
3455
+ return e;
3456
+ if (e.skipChildren = !1, Array.isArray(n)) {
3457
+ for (const o of n)
3458
+ e = x(o, e, r, t, l, a);
3459
+ return e;
3460
+ }
3461
+ switch (n.type) {
3462
+ case "BlockS": {
3463
+ if (e = (r == null ? void 0 : r(!0, n, e, l, a)) || e, e.cancel) return e;
3464
+ if (!e.skipChildren) {
3465
+ for (const o of n.statements)
3466
+ if (e = x(o, e, r, t, n, "statements"), e.cancel) return e;
3467
+ }
3468
+ return e = (r == null ? void 0 : r(!1, n, e, l, a)) || e, e;
3469
+ }
3470
+ case "EmptyS":
3471
+ return e = (r == null ? void 0 : r(!0, n, e, l, a)) || e, e;
3472
+ case "ExprS":
3473
+ return e = (r == null ? void 0 : r(!0, n, e, l, a)) || e, e.cancel || !e.skipChildren && (e = x(n.expression, e, r, t, n, "expression"), e.cancel) || (e = (r == null ? void 0 : r(!1, n, e, l, a)) || e), e;
3474
+ case "ArrowS":
3475
+ return e;
3476
+ case "LetS": {
3477
+ if (e = (r == null ? void 0 : r(!0, n, e, l, a)) || e, e.cancel) return e;
3478
+ if (!e.skipChildren) {
3479
+ for (const o of n.declarations)
3480
+ if (e = x(o, e, r, t, n, "declarations"), e.cancel) return e;
3481
+ }
3482
+ return e = (r == null ? void 0 : r(!1, n, e, l, a)) || e, e;
3483
+ }
3484
+ case "ConstS": {
3485
+ if (e = (r == null ? void 0 : r(!0, n, e, l, a)) || e, e.cancel) return e;
3486
+ if (!e.skipChildren) {
3487
+ for (const o of n.declarations)
3488
+ if (e = x(o, e, r, t, n, "declarations"), e.cancel) return e;
3489
+ }
3490
+ return e = (r == null ? void 0 : r(!1, n, e, l, a)) || e, e;
3491
+ }
3492
+ case "VarS": {
3493
+ if (e = (r == null ? void 0 : r(!0, n, e, l, a)) || e, e.cancel) return e;
3494
+ if (!e.skipChildren) {
3495
+ for (const o of n.declarations)
3496
+ if (e = x(o, e, r, t, n, "declarations"), e.cancel) return e;
3497
+ }
3498
+ return e = (r == null ? void 0 : r(!1, n, e, l, a)) || e, e;
3499
+ }
3500
+ case "IfS":
3501
+ return e = (r == null ? void 0 : r(!0, n, e, l, a)) || e, e.cancel || !e.skipChildren && (e = x(n.condition, e, r, t, n, "condition"), e.cancel || (n.thenBranch && (e = x(n.thenBranch, e, r, t, n, "thenBranch")), e.cancel) || (n.elseBranch && (e = x(n.elseBranch, e, r, t, n, "elseBranch")), e.cancel)) || (e = (r == null ? void 0 : r(!1, n, e, l, a)) || e), e;
3502
+ case "RetS":
3503
+ return e = (r == null ? void 0 : r(!0, n, e, l, a)) || e, e.cancel || !e.skipChildren && (n.expression && (e = x(n.expression, e, r, t, n, "expression")), e.cancel) || (e = (r == null ? void 0 : r(!1, n, e, l, a)) || e), e;
3504
+ case "BrkS":
3505
+ return e = (r == null ? void 0 : r(!0, n, e, l, a)) || e, e;
3506
+ case "ContS":
3507
+ return e = (r == null ? void 0 : r(!0, n, e, l, a)) || e, e;
3508
+ case "WhileS":
3509
+ return e = (r == null ? void 0 : r(!0, n, e, l, a)) || e, e.cancel || !e.skipChildren && (e = x(n.condition, e, r, t, n, "condition"), e.cancel || (e = x(n.body, e, r, t, n, "body"), e.cancel)) || (e = (r == null ? void 0 : r(!1, n, e, l, a)) || e), e;
3510
+ case "DoWS":
3511
+ return e = (r == null ? void 0 : r(!0, n, e, l, a)) || e, e.cancel || !e.skipChildren && (e = x(n.body, e, r, t, n, "body"), e.cancel || (e = x(n.condition, e, r, t, n, "condition"), e.cancel)) || (e = (r == null ? void 0 : r(!1, n, e, l, a)) || e), e;
3512
+ case "ForS":
3513
+ return e = (r == null ? void 0 : r(!0, n, e, l, a)) || e, e.cancel || !e.skipChildren && (n.init && (e = x(n.init, e, r, t, n, "init")), e.cancel || (n.condition && (e = x(n.condition, e, r, t, n, "condition")), e.cancel) || (n.update && (e = x(n.update, e, r, t, n, "update")), e.cancel) || (e = x(n.body, e, r, t, n, "body"), e.cancel)) || (e = (r == null ? void 0 : r(!1, n, e, l, a)) || e), e;
3514
+ case "ForInS":
3515
+ return e = (r == null ? void 0 : r(!0, n, e, l, a)) || e, e.cancel || !e.skipChildren && (e = x(n.expression, e, r, t, n, "expression"), e.cancel || (e = x(n.body, e, r, t, n, "body"), e.cancel)) || (e = (r == null ? void 0 : r(!1, n, e, l, a)) || e), e;
3516
+ case "ForOfS":
3517
+ return e = (r == null ? void 0 : r(!0, n, e, l, a)) || e, e.cancel || !e.skipChildren && (e = x(n.expression, e, r, t, n, "expression"), e.cancel || (e = x(n.body, e, r, t, n, "body"), e.cancel)) || (e = (r == null ? void 0 : r(!1, n, e, l, a)) || e), e;
3518
+ case "ThrowS":
3519
+ return e = (r == null ? void 0 : r(!0, n, e, l, a)) || e, e.cancel || !e.skipChildren && (e = x(n.expression, e, r, t, n, "expression"), e.cancel) || (e = (r == null ? void 0 : r(!1, n, e, l, a)) || e), e;
3520
+ case "TryS":
3521
+ return e = (r == null ? void 0 : r(!0, n, e, l, a)) || e, e.cancel || !e.skipChildren && (n.tryBlock && (e = x(n.tryBlock, e, r, t, n, "tryBlock")), e.cancel || (n.catchBlock && (e = x(n.catchBlock, e, r, t, n, "catchBlock")), e.cancel) || (n.finallyBlock && (e = x(n.finallyBlock, e, r, t, n, "finallyBlock")), e.cancel)) || (e = (r == null ? void 0 : r(!1, n, e, l, a)) || e), e;
3522
+ case "SwitchS": {
3523
+ if (e = (r == null ? void 0 : r(!0, n, e, l, a)) || e, e.cancel) return e;
3524
+ if (!e.skipChildren) {
3525
+ if (e = x(n.expression, e, r, t, n, "expression"), e.cancel) return e;
3526
+ for (const o of n.cases) {
3527
+ if (o.caseExpression && (e = x(o.caseExpression, e, r, t, n, "caseExpression")), e.cancel) return e;
3528
+ if (o.statements !== void 0) {
3529
+ for (const c of o.statements)
3530
+ if (e = x(c, e, r, t, n, "switchStatement"), e.cancel) return e;
3531
+ }
3532
+ }
3533
+ }
3534
+ return e = (r == null ? void 0 : r(!1, n, e, l, a)) || e, e;
3535
+ }
3536
+ case "FuncD": {
3537
+ if (e = (r == null ? void 0 : r(!0, n, e, l, a)) || e, e.cancel) return e;
3538
+ if (!e.skipChildren) {
3539
+ for (const o of n.args)
3540
+ if (e = x(o, e, r, t, n, "arg"), e.cancel) return e;
3541
+ if (e = x(n.statement, e, r, t, n, "statement"), e.cancel) return e;
3542
+ }
3543
+ return e = (r == null ? void 0 : r(!1, n, e, l, a)) || e, e;
3544
+ }
3545
+ case "ImportD":
3546
+ return e = (r == null ? void 0 : r(!0, n, e, l, a)) || e, e.cancel || (e = (r == null ? void 0 : r(!1, n, e, l, a)) || e), e;
3547
+ case "UnaryE":
3548
+ return e = (t == null ? void 0 : t(!0, n, e, l, a)) || e, e.cancel || !e.skipChildren && (e = x(n.operand, e, r, t, n, "operand"), e.cancel) || (e = (t == null ? void 0 : t(!1, n, e, l, a)) || e), e;
3549
+ case "BinaryE":
3550
+ return e = (t == null ? void 0 : t(!0, n, e, l, a)) || e, e.cancel || !e.skipChildren && (e = x(n.left, e, r, t, n, "left"), e.cancel || (e = x(n.right, e, r, t, n, "right"), e.cancel)) || (e = (t == null ? void 0 : t(!1, n, e, l, a)) || e), e;
3551
+ case "SeqE": {
3552
+ if (e = (t == null ? void 0 : t(!0, n, e, l, a)) || e, e.cancel) return e;
3553
+ if (!e.skipChildren) {
3554
+ for (const o of n.expressions)
3555
+ if (e = x(o, e, r, t, n, "expression"), e.cancel) return e;
3556
+ }
3557
+ return e = (t == null ? void 0 : t(!1, n, e, l, a)) || e, e;
3558
+ }
3559
+ case "CondE":
3560
+ return e = (t == null ? void 0 : t(!0, n, e, l, a)) || e, e.cancel || !e.skipChildren && (e = x(n.condition, e, r, t, n, "condition"), e.cancel || (e = x(n.consequent, e, r, t, n, "consequent"), e.cancel) || (e = x(n.alternate, e, r, t, n, "alternate"), e.cancel)) || (e = (t == null ? void 0 : t(!1, n, e, l, a)) || e), e;
3561
+ case "InvokeE": {
3562
+ if (e = (t == null ? void 0 : t(!0, n, e, l, a)) || e, e.cancel) return e;
3563
+ if (!e.skipChildren) {
3564
+ for (const o of n.arguments)
3565
+ if (e = x(o, e, r, t, n, "argument"), e.cancel) return e;
3566
+ if (e = x(n.object, e, r, t, n, "object"), e.cancel) return e;
3567
+ }
3568
+ return e = (t == null ? void 0 : t(!1, n, e, l, a)) || e, e;
3569
+ }
3570
+ case "MembE":
3571
+ return e = (t == null ? void 0 : t(!0, n, e, l, a)) || e, e.cancel || !e.skipChildren && (e = x(n.object, e, r, t, n, "object"), e.cancel) || (e = (t == null ? void 0 : t(!1, n, e, l, a)) || e), e;
3572
+ case "CMembE":
3573
+ return e = (t == null ? void 0 : t(!0, n, e, l, a)) || e, e.cancel || !e.skipChildren && (e = x(n.object, e, r, t, n, "object"), e.cancel || (e = x(n.member, e, r, t, n, "member"), e.cancel)) || (e = (t == null ? void 0 : t(!1, n, e, l, a)) || e), e;
3574
+ case "IdE":
3575
+ return e = (t == null ? void 0 : t(!0, n, e, l, a)) || e, e;
3576
+ case "LitE":
3577
+ return e = (t == null ? void 0 : t(!0, n, e, l, a)) || e, e;
3578
+ case "ALitE": {
3579
+ if (e = (t == null ? void 0 : t(!0, n, e, l, a)) || e, e.cancel) return e;
3580
+ if (!e.skipChildren) {
3581
+ for (const o of n.items)
3582
+ if (e = x(o, e, r, t, n, "item"), e.cancel) return e;
3583
+ }
3584
+ return e = (t == null ? void 0 : t(!1, n, e, l, a)) || e, e;
3585
+ }
3586
+ case "OLitE": {
3587
+ if (e = (t == null ? void 0 : t(!0, n, e, l, a)) || e, e.cancel) return e;
3588
+ if (!e.skipChildren) {
3589
+ for (const o of n.props)
3590
+ if (Array.isArray(o)) {
3591
+ const [c, s] = o;
3592
+ if (e = x(c, e, r, t, n, "propKey"), e.cancel || (e = x(s, e, r, t, n, "propValue"), e.cancel)) return e;
3593
+ } else if (e = x(o, e, r, t, n, "prop"), e.cancel) return e;
3594
+ }
3595
+ return e = (t == null ? void 0 : t(!1, n, e, l, a)) || e, e;
3596
+ }
3597
+ case "SpreadE":
3598
+ return e = (t == null ? void 0 : t(!0, n, e, l, a)) || e, e.cancel || !e.skipChildren && (e = x(n.operand, e, r, t, n, "operand"), e.cancel) || (e = (t == null ? void 0 : t(!1, n, e, l, a)) || e), e;
3599
+ case "AsgnE":
3600
+ return e = (t == null ? void 0 : t(!0, n, e, l, a)) || e, e.cancel || !e.skipChildren && (e = x(n.operand, e, r, t, n, "operand"), e.cancel || (e = x(n.leftValue, e, r, t, n, "leftValue"), e.cancel)) || (e = (t == null ? void 0 : t(!1, n, e, l, a)) || e), e;
3601
+ case "NoArgE":
3602
+ return e = (t == null ? void 0 : t(!0, n, e, l, a)) || e, e;
3603
+ case "ArrowE": {
3604
+ if (e = (t == null ? void 0 : t(!0, n, e, l, a)) || e, e.cancel) return e;
3605
+ if (!e.skipChildren) {
3606
+ for (const o of n.args)
3607
+ if (e = x(o, e, r, t, n, "arg"), e.cancel) return e;
3608
+ if (e = x(n.statement, e, r, t, n, "statement"), e.cancel) return e;
3609
+ }
3610
+ return e = (t == null ? void 0 : t(!1, n, e, l, a)) || e, e;
3611
+ }
3612
+ case "PrefE":
3613
+ case "PostfE":
3614
+ return e = (t == null ? void 0 : t(!0, n, e, l, a)) || e, e.cancel || !e.skipChildren && (e = x(n.operand, e, r, t, n, "operand"), e.cancel) || (e = (t == null ? void 0 : t(!1, n, e, l, a)) || e), e;
3615
+ case "VarD": {
3616
+ if (e = (t == null ? void 0 : t(!0, n, e, l, a)) || e, e.cancel) return e;
3617
+ if (!e.skipChildren) {
3618
+ if (n.arrayDestruct !== void 0) {
3619
+ for (const o of n.arrayDestruct)
3620
+ if (e = x(o, e, r, t, n), e.cancel) return e;
3621
+ }
3622
+ if (n.objectDestruct !== void 0) {
3623
+ for (const o of n.objectDestruct)
3624
+ if (e = x(o, e, r, t, n), e.cancel) return e;
3625
+ }
3626
+ if (n.expression && (e = x(n.expression, e, r, t, n, "expression")), e.cancel) return e;
3627
+ }
3628
+ return e = (t == null ? void 0 : t(!1, n, e, l, a)) || e, e;
3629
+ }
3630
+ case "Destr":
3631
+ case "ODestr":
3632
+ case "ADestr": {
3633
+ if (e = (t == null ? void 0 : t(!0, n, e, l, a)) || e, e.cancel) return e;
3634
+ if (!e.skipChildren) {
3635
+ if (n.arrayDestruct !== void 0) {
3636
+ for (const o of n.arrayDestruct)
3637
+ if (e = x(o, e, r, t, n), e.cancel) return e;
3638
+ }
3639
+ if (n.objectDestruct !== void 0) {
3640
+ for (const o of n.objectDestruct)
3641
+ if (e = x(o, e, r, t, n), e.cancel) return e;
3642
+ }
3643
+ }
3644
+ return e = (t == null ? void 0 : t(!1, n, e, l, a)) || e, e;
3645
+ }
3646
+ case "RVarD":
3647
+ return e = (t == null ? void 0 : t(!0, n, e, l, a)) || e, e.cancel || !e.skipChildren && (n.expression && (e = x(n.expression, e, r, t, n, "expression")), e.cancel) || (e = (t == null ? void 0 : t(!1, n, e, l, a)) || e), e;
3648
+ case "TempLitE":
3649
+ return e;
3650
+ default:
3651
+ return e;
3652
+ }
3653
+ }
3654
+ function Xe(n) {
3655
+ return n.type !== "ScriptModule";
3656
+ }
3657
+ function Te(n, e, r, t = !1) {
3658
+ const l = /* @__PURE__ */ new Map(), a = {}, o = c(n, e, r, !0);
3659
+ return !o || Object.keys(a).length > 0 ? a : o;
3660
+ function c(s, D, L, u = !1) {
3661
+ var O;
3662
+ if (l.has(s))
3663
+ return l.get(s);
3664
+ const p = new Ne(D);
3665
+ let U = [];
3666
+ try {
3667
+ U = p.parseStatements();
3668
+ } catch {
3669
+ return a[s] = p.errors, null;
3670
+ }
3671
+ const m = p.current;
3672
+ if (m.type !== i.Eof)
3673
+ return a[s] ?? (a[s] = []), a[s].push({
3674
+ code: "W002",
3675
+ text: ie.W002.replace(/\{(\d+)}/g, () => m.text),
3676
+ position: m.location.startLine,
3677
+ line: m.location.startLine,
3678
+ column: m.location.startColumn
3679
+ }), null;
3680
+ const E = [];
3681
+ x(U, {
3682
+ data: null,
3683
+ cancel: !1,
3684
+ skipChildren: !1
3685
+ }, (I, v, G, d, h) => {
3686
+ if (!I) return G;
3687
+ if (u)
3688
+ switch (v.type) {
3689
+ case "VarS":
3690
+ d && H("W027", v);
3691
+ break;
3692
+ case "FuncD":
3693
+ case "ImportD":
3694
+ break;
3695
+ default:
3696
+ t && !d && H("W028", v, v.type);
3697
+ break;
3698
+ }
3699
+ else
3700
+ switch (v.type) {
3701
+ case "VarS":
3702
+ H("W027", v);
3703
+ break;
3704
+ case "FuncD":
3705
+ t && !v.isExported && H("W029", v);
3706
+ break;
3707
+ case "ImportD":
3708
+ break;
3709
+ default:
3710
+ t && !d && H("W028", v, v.type);
3711
+ break;
3712
+ }
3713
+ return G;
3714
+ });
3715
+ const K = {};
3716
+ U.filter((I) => I.type === "FuncD").forEach((I) => {
3717
+ const v = I;
3718
+ if (K[v.name]) {
3719
+ H("W020", I, v.name);
3720
+ return;
3721
+ }
3722
+ K[v.name] = v;
3723
+ });
3724
+ const q = /* @__PURE__ */ new Map();
3725
+ U.forEach((I) => {
3726
+ I.type === "ConstS" && I.isExported ? Ke(I, (v) => {
3727
+ q.has(v) ? H("W021", I, v) : q.set(v, I);
3728
+ }) : I.type === "FuncD" && I.isExported && (q.has(I.name) ? H("W021", I, I.name) : q.set(I.name, I));
3729
+ });
3730
+ const X = {
3731
+ type: "ScriptModule",
3732
+ name: s,
3733
+ exports: q,
3734
+ importedModules: [],
3735
+ imports: {},
3736
+ functions: K,
3737
+ statements: U,
3738
+ executed: !1
3739
+ };
3740
+ l.set(s, X);
3741
+ const V = [], ee = {};
3742
+ for (let I = 0; I < U.length; I++) {
3743
+ const v = U[I];
3744
+ if (v.type !== "ImportD")
3745
+ continue;
3746
+ const G = L(s, v.moduleFile);
3747
+ if (G === null) {
3748
+ H("W022", v, v.moduleFile);
3749
+ continue;
3750
+ }
3751
+ const d = c(v.moduleFile, G, L);
3752
+ if (!d)
3753
+ return;
3754
+ V.push(d);
3755
+ const h = Object.keys(v.imports);
3756
+ h.length > 0 && (ee[O = v.moduleFile] ?? (ee[O] = {}));
3757
+ for (const g of h)
3758
+ d.exports.has(v.imports[g]) ? ee[v.moduleFile][g] = d.exports.get(v.imports[g]) : H("W023", v, v.moduleFile, g);
3759
+ }
3760
+ if (E.length > 0)
3761
+ return a[s] = E, null;
3762
+ return V.forEach((I) => I.parent = X), X.importedModules = V, X.imports = ee, X;
3763
+ function H(I, v, ...G) {
3764
+ let d = ie[I];
3765
+ G && G.forEach(
3766
+ (h, g) => d = d.replaceAll(`{${g}}`, G[g].toString())
3767
+ ), E.push({
3768
+ code: I,
3769
+ text: ie[I].replace(/\{(\d+)}/g, (h, g) => G[g]),
3770
+ position: v.startPosition,
3771
+ line: v.startLine,
3772
+ column: v.startColumn
3773
+ });
3774
+ }
3775
+ }
3776
+ }
3777
+ function De(n) {
3778
+ var r;
3779
+ const e = ((r = n.blocks) == null ? void 0 : r.slice(0)) ?? [];
3780
+ return n.parent ? [...De(n.parent), ...e] : e;
3781
+ }
3782
+ function Ke(n, e) {
3783
+ for (let a = 0; a < n.declarations.length; a++) {
3784
+ const o = n.declarations[a];
3785
+ r(o, e);
3786
+ }
3787
+ function r(a, o) {
3788
+ if (a.id)
3789
+ o(a.id);
3790
+ else if (a.arrayDestruct)
3791
+ t(a.arrayDestruct, o);
3792
+ else if (a.objectDestruct)
3793
+ l(a.objectDestruct, o);
3794
+ else
3795
+ throw new Error("Unknown declaration specifier");
3796
+ }
3797
+ function t(a, o) {
3798
+ for (let c = 0; c < a.length; c++) {
3799
+ const s = a[c];
3800
+ s.id ? o(s.id) : s.arrayDestruct ? t(s.arrayDestruct, o) : s.objectDestruct && l(s.objectDestruct, o);
3801
+ }
3802
+ }
3803
+ function l(a, o) {
3804
+ for (let c = 0; c < a.length; c++) {
3805
+ const s = a[c];
3806
+ s.arrayDestruct ? t(s.arrayDestruct, o) : s.objectDestruct ? l(s.objectDestruct, o) : o(s.alias ?? s.id);
3807
+ }
3808
+ }
3809
+ }
3810
+ const le = "__PARSED__";
3811
+ function Qe(n, e, r, t) {
3812
+ const l = {
3813
+ vars: {},
3814
+ moduleErrors: {},
3815
+ functions: {}
3816
+ }, a = {}, o = Te(n, e, r, !0);
3817
+ if (Xe(o))
3818
+ return { ...l, moduleErrors: o };
3819
+ const c = t(o.name);
3820
+ return o.statements.forEach((L) => {
3821
+ switch (L.type) {
3822
+ case "VarS":
3823
+ L.declarations.forEach((u) => {
3824
+ if (u.id in l.vars)
3825
+ throw new Error(`Duplicated var declaration: '${u.id}'`);
3826
+ l.vars[u.id] = {
3827
+ [le]: !0,
3828
+ source: u.expression.source,
3829
+ tree: u.expression
3830
+ };
3831
+ });
3832
+ break;
3833
+ case "FuncD":
3834
+ D(c, L);
3835
+ break;
3836
+ case "ImportD":
3837
+ break;
3838
+ default:
3839
+ throw new Error(`'${L.type}' is not allowed in a code-behind module.`);
3840
+ }
3841
+ }), s(o), l;
3842
+ function s(L) {
3843
+ var O;
3844
+ const u = t(L.name);
3845
+ if (!((O = a == null ? void 0 : a[u]) != null && O.collectedImportsFrom)) {
3846
+ for (const p in L.imports) {
3847
+ const U = t(p), m = L.imports[p];
3848
+ for (const E of Object.values(m))
3849
+ E.type === "FuncD" && D(U, E);
3850
+ }
3851
+ a[u] ?? (a[u] = { collectedImportsFrom: !0 }), a[u].collectedImportsFrom = !0;
3852
+ for (let p of L.importedModules)
3853
+ s(p);
3854
+ }
3855
+ }
3856
+ function D(L, u) {
3857
+ var E, $, K, q;
3858
+ var O;
3859
+ if ((($ = (E = a == null ? void 0 : a[L]) == null ? void 0 : E.functions) == null ? void 0 : $[u.name]) !== void 0)
3860
+ return;
3861
+ if (u.name in l.functions)
3862
+ throw new Error(`Duplicated function declaration: '${u.name}'`);
3863
+ const p = u.args.length === 1 ? `${u.args[0].source} => ${u.statement.source}` : `(${u.args.map((X) => X.source).join(", ")}) => ${u.statement.source}`, U = {
3864
+ type: "ArrowE",
3865
+ args: u.args.slice(),
3866
+ statement: u.statement,
3867
+ closureContext: De({
3868
+ blocks: [{ vars: {} }]
3869
+ })
3870
+ }, m = (q = (K = U.closureContext[0]) == null ? void 0 : K.vars) == null ? void 0 : q[u.name];
3871
+ m != null && m.closureContext && delete m.closureContext, a[L] ?? (a[L] = { functions: {}, collectedImportsFrom: !1 }), (O = a[L]).functions ?? (O.functions = {}), a[L].functions[u.name] = {
3872
+ [le]: !0,
3873
+ source: p,
3874
+ tree: U
3875
+ }, l.functions[u.name] = {
3876
+ [le]: !0,
3877
+ source: p,
3878
+ tree: U
3879
+ };
3880
+ }
3881
+ }
3882
+ function Wr(n) {
3883
+ if (!n) return;
3884
+ const e = {
3885
+ data: null,
3886
+ cancel: !1,
3887
+ skipChildren: !1
3888
+ };
3889
+ Object.keys(n.vars).forEach((t) => {
3890
+ r(n.vars[t]);
3891
+ }), Object.keys(n.functions).forEach((t) => {
3892
+ r(n.functions[t]);
3893
+ });
3894
+ function r(t) {
3895
+ const l = (a, o, c) => (a && o && (delete o.startPosition, delete o.endPosition, delete o.startLine, delete o.endLine, delete o.startColumn, delete o.endColumn, delete o.startToken, delete o.endToken), c);
3896
+ x(t.tree, e, l, l);
3897
+ }
3898
+ }
3899
+ class ue extends Error {
3900
+ constructor(e, r) {
3901
+ super(`${r ? `${r}: ` : ""}${e}`), this.code = r, Object.setPrototypeOf(this, ue.prototype);
3902
+ }
3903
+ }
3904
+ const Ze = {
3905
+ U001: "Unexpected token: {0}.",
3906
+ U002: "A component definition can have exactly one XMLUI element.",
3907
+ U003: "A '<' token expected.",
3908
+ U004: "A node identifier expected.",
3909
+ U005: "A '</' token expected.",
3910
+ U006: "A '>' or '/>' token expected.",
3911
+ U007: "An '{0}' ID expected in the closing tag but '{1}' received.",
3912
+ U008: "A '>' token expected.",
3913
+ U009: "An attribute identifier expected.",
3914
+ U010: "An '=' token expected.",
3915
+ U011: "An attribute value expected.",
3916
+ U012: "Duplicated attribute: '{0}'.",
3917
+ U013: "Attribute name cannot start with an uppercase letter.",
3918
+ U014: "An '{0}' ID expected in the closing tag's namespace but '{1}' received.",
3919
+ U015: "Unexpected token in text element: {0}.",
3920
+ T001: "A component definition must have exactly one XMLUI element.",
3921
+ T002: "A component definition's name must start with an uppercase letter.",
3922
+ T003: "A reusable component must have a non-empty name.",
3923
+ T004: "A reusable component's name must start with an uppercase letter.",
3924
+ T005: "A reusable component must have at least one nested component definition.",
3925
+ T006: "A reusable component definition cannot nest another one.",
3926
+ T007: "Invalid attribute name: '{0}'",
3927
+ T008: "Event attribute names should not start with 'on' prefix: '{0}'",
3928
+ T009: "Invalid node name '{0}' in a component definition",
3929
+ T010: "The '{0}' element does not accept a text child",
3930
+ T011: "Only 'name', 'value', and type hint attributes are accepted in '{0}'.",
3931
+ T012: "The 'name' attribute in '{0}' is required.",
3932
+ T013: "A loader element must have an id.",
3933
+ T014: "A loader element must not have '{0}'.",
3934
+ T015: "The uses element must define only a non-empty 'value' attribute.",
3935
+ T016: "Only 'field' or 'item' are accepted as a child element.",
3936
+ T017: "Cannot mix 'field' and 'item' nodes within an element.",
3937
+ T018: "The '{0}' node cannot have a 'name' attribute.",
3938
+ T019: "The 'value' attribute in '{0}' is required.",
3939
+ T020: "Cannot mix nested components and non-component children.",
3940
+ T021: "Invalid reusable component attribute '{0}'.",
3941
+ T022: "The 'script' tag must not have any attribute.",
3942
+ T023: "A 'script' tag cannot nest other child nodes, only text.",
3943
+ T024: "Cannot put a reusable component definitions into a slot.",
3944
+ T025: "Duplicate xmlns found: '{0}'.",
3945
+ T026: "The top level component's name cannot have a namespace.",
3946
+ T027: "Cannot resolve namespace '{0}'. It was not defined in any of the ancestor components.",
3947
+ T028: "Incorrect namespace value '{0}'. {1}",
3948
+ T029: "Incorrect scheme specified before ':' (colon) in namespace {0}. Delete it to get the default '{1}'."
3949
+ }, xe = "Component", ae = /^[A-Z]/, me = /^on[A-Z]/, Je = ["name", "value"], Ye = 9, oe = "component-ns", je = "app-ns", Ve = "#app-ns", er = "core-ns", se = "#xmlui-core-ns", Y = {
3950
+ property: "property",
3951
+ event: "event",
3952
+ variable: "variable",
3953
+ loaders: "loaders",
3954
+ uses: "uses",
3955
+ method: "method",
3956
+ item: "item",
3957
+ field: "field"
3958
+ };
3959
+ function Br(n, e, r, t = () => "") {
3960
+ const l = (d) => d.text ?? e(d), a = ir(n), o = V(a), c = [], s = [];
3961
+ return D(c, o);
3962
+ function D(d, h) {
3963
+ const g = Ce(h, l, s);
3964
+ if (g === xe)
3965
+ return u(h);
3966
+ let f = {
3967
+ type: g,
3968
+ debug: {
3969
+ source: {
3970
+ start: h.start,
3971
+ end: h.end,
3972
+ fileId: r
3973
+ }
3974
+ }
3975
+ };
3976
+ return O(d, f, h), f;
3977
+ }
3978
+ function L(d, h) {
3979
+ const g = Ce(h, l, s);
3980
+ g === xe && b("T006");
3981
+ let f = {
3982
+ type: g,
3983
+ debug: {
3984
+ source: {
3985
+ start: h.start,
3986
+ end: h.end,
3987
+ fileId: r
3988
+ }
3989
+ }
3990
+ };
3991
+ return O(d, f, h), f;
3992
+ }
3993
+ function u(d) {
3994
+ const h = re(d).map(q), g = h.find((W) => W.name === "name");
3995
+ g || b("T003"), ae.test(g.value) || b("T004");
3996
+ let f;
3997
+ const S = h.filter((W) => W.startSegment === "method");
3998
+ S.length > 0 && (f = {}, S.forEach((W) => {
3999
+ f[W.name] = W.value;
4000
+ }));
4001
+ let C;
4002
+ const A = h.filter((W) => W.startSegment === "var");
4003
+ A.length > 0 && (C = {}, A.forEach((W) => {
4004
+ C[W.name] = W.value;
4005
+ }));
4006
+ const P = ne(d), F = P.filter(
4007
+ (W) => W.kind === k.ElementNode && !(J(W, l) in Y)
4008
+ );
4009
+ F.length === 0 && F.push(Se(""));
4010
+ const y = [], M = [];
4011
+ for (let W of P)
4012
+ if (W.kind === k.ElementNode) {
4013
+ const he = J(W, l);
4014
+ he === Y.variable ? M.push(W) : he in Y && y.push(W);
4015
+ }
4016
+ let _;
4017
+ F.length > 1 || M.length > 0 ? _ = _e([...M, ...F]) : _ = F[0], s.push(/* @__PURE__ */ new Map()), h.filter((W) => W.namespace === "xmlns").forEach((W) => {
4018
+ we(s, _, W.unsegmentedName, W.value);
4019
+ });
4020
+ let w = L(
4021
+ c,
4022
+ _
4023
+ );
4024
+ s.pop();
4025
+ const B = {
4026
+ name: g.value,
4027
+ component: w,
4028
+ debug: {
4029
+ source: {
4030
+ start: d.start,
4031
+ end: d.end,
4032
+ fileId: r
4033
+ }
4034
+ }
4035
+ };
4036
+ f && (B.api = f), C && (w.vars = { ...w.vars, ...C }), w.debug = {
4037
+ source: {
4038
+ start: _.start,
4039
+ end: _.end,
4040
+ fileId: r
4041
+ }
4042
+ };
4043
+ const Q = Le(d, y);
4044
+ return O(c, B, Q), B;
4045
+ }
4046
+ function O(d, h, g) {
4047
+ var F;
4048
+ const f = !T(h), S = re(g);
4049
+ if (s.push(/* @__PURE__ */ new Map()), S.forEach((y) => {
4050
+ p(h, y);
4051
+ }), ne(g).forEach((y) => {
4052
+ if (y.kind === k.Script) {
4053
+ re(y).length > 0 && b("T022");
4054
+ const _ = l(y), w = _.slice(
4055
+ _.indexOf(">") + 1,
4056
+ _.lastIndexOf("</")
4057
+ );
4058
+ h.script ?? (h.script = ""), h.script.length > 0 && (h.script += `
4059
+ `), h.script += w;
4060
+ return;
4061
+ }
4062
+ if (y.kind === k.TextNode && !f) {
4063
+ h.children = te(h.children, l(y));
4064
+ return;
4065
+ }
4066
+ const M = J(y, l);
4067
+ if (!(f && y.kind === k.ElementNode && !(M in Y))) {
4068
+ if (!(M in Y) && !f) {
4069
+ const _ = L(d, y);
4070
+ _ && (h.children ? typeof h.children == "string" ? h.children = [h.children, _] : Array.isArray(h.children) && h.children.push(_) : h.children = [_]);
4071
+ return;
4072
+ }
4073
+ switch (M) {
4074
+ case "property":
4075
+ $(
4076
+ d,
4077
+ h,
4078
+ y,
4079
+ (_) => {
4080
+ var w;
4081
+ return T(h) ? (w = h.props) == null ? void 0 : w[_] : void 0;
4082
+ },
4083
+ (_, w) => {
4084
+ T(h) && (h.props ?? (h.props = {}), h.props[_] = w);
4085
+ }
4086
+ );
4087
+ return;
4088
+ case "event":
4089
+ $(
4090
+ d,
4091
+ h,
4092
+ y,
4093
+ (_) => {
4094
+ var w;
4095
+ return T(h) ? (w = h.events) == null ? void 0 : w[_] : void 0;
4096
+ },
4097
+ (_, w) => {
4098
+ T(h) && (h.events ?? (h.events = {}), h.events[_] = w);
4099
+ },
4100
+ (_) => {
4101
+ me.test(_) && b("T008", _);
4102
+ }
4103
+ );
4104
+ return;
4105
+ case Y.variable:
4106
+ $(
4107
+ d,
4108
+ h,
4109
+ y,
4110
+ (_) => {
4111
+ var w;
4112
+ return T(h) ? (w = h.vars) == null ? void 0 : w[_] : void 0;
4113
+ },
4114
+ (_, w) => {
4115
+ T(h) && (h.vars ?? (h.vars = {}), h.vars[_] = w);
4116
+ }
4117
+ );
4118
+ return;
4119
+ case "loaders":
4120
+ E(d, h, y);
4121
+ return;
4122
+ case "uses":
4123
+ K(h, y);
4124
+ return;
4125
+ case "method":
4126
+ $(
4127
+ d,
4128
+ h,
4129
+ y,
4130
+ (_) => {
4131
+ var w;
4132
+ return T(h) ? (w = h.api) == null ? void 0 : w[_] : void 0;
4133
+ },
4134
+ (_, w) => {
4135
+ h.api ?? (h.api = {}), h.api[_] = w;
4136
+ }
4137
+ );
4138
+ return;
4139
+ default:
4140
+ b("T009", M);
4141
+ return;
4142
+ }
4143
+ }
4144
+ }), s.pop(), !h.script || h.script.trim().length === 0)
4145
+ return;
4146
+ const A = new Ne(h.script);
4147
+ try {
4148
+ A.parseStatements(), h.scriptCollected = Qe(
4149
+ "Main",
4150
+ h.script,
4151
+ t,
4152
+ (y) => y
4153
+ );
4154
+ } catch (y) {
4155
+ A.errors && A.errors.length > 0 ? h.scriptError = A.errors : h.scriptError = y;
4156
+ }
4157
+ const P = ((F = h.scriptCollected) == null ? void 0 : F.moduleErrors) ?? {};
4158
+ Object.keys(P).length > 0 && (h.scriptError = P);
4159
+ }
4160
+ function p(d, h) {
4161
+ const { namespace: g, startSegment: f, name: S, value: C, unsegmentedName: A } = q(h);
4162
+ if (g === "xmlns")
4163
+ return we(s, d, A, C);
4164
+ if (!T(d)) {
4165
+ if (f && f !== "method" && f !== "var") {
4166
+ b("T021");
4167
+ return;
4168
+ }
4169
+ if (S === "name" && !f)
4170
+ return;
4171
+ !f && S && b("T021", S);
4172
+ return;
4173
+ }
4174
+ switch (S) {
4175
+ case "id":
4176
+ d.uid = C;
4177
+ return;
4178
+ case "testId":
4179
+ d.testId = C;
4180
+ return;
4181
+ case "when":
4182
+ d.when = C;
4183
+ return;
4184
+ default:
4185
+ if (f === "var")
4186
+ d.vars ?? (d.vars = {}), d.vars[S] = C;
4187
+ else if (f === "method")
4188
+ d.api ?? (d.api = {}), d.api[S] = C;
4189
+ else if (f === "event")
4190
+ d.events ?? (d.events = {}), d.events[S] = C;
4191
+ else if (me.test(S)) {
4192
+ d.events ?? (d.events = {});
4193
+ const F = S[2].toLowerCase() + S.substring(3);
4194
+ d.events[F] = C;
4195
+ } else
4196
+ d.props ?? (d.props = {}), d.props[S] = C;
4197
+ return;
4198
+ }
4199
+ }
4200
+ function U(d, h) {
4201
+ let g = null;
4202
+ if (!h) return g;
4203
+ let f = null;
4204
+ return h.forEach((S) => {
4205
+ if (S.kind === k.TextNode) {
4206
+ g = te(g, l(S));
4207
+ return;
4208
+ }
4209
+ if (S.kind !== k.ElementNode) return;
4210
+ const C = J(S, l);
4211
+ if (C !== "field" && C !== "item") {
4212
+ b("T016");
4213
+ return;
4214
+ }
4215
+ if (C === "field") {
4216
+ if (!f)
4217
+ f = C, g = {};
4218
+ else if (f !== C) {
4219
+ b("T017");
4220
+ return;
4221
+ }
4222
+ } else if (C === "item") {
4223
+ if (!f)
4224
+ f = C, g = [];
4225
+ else if (f !== C) {
4226
+ b("T017");
4227
+ return;
4228
+ }
4229
+ }
4230
+ let A = m(d, S, C === "field");
4231
+ if (!A)
4232
+ return null;
4233
+ f === "field" ? g[A.name] = A.value : g.push(A.value);
4234
+ }), g;
4235
+ }
4236
+ function m(d, h, g = !0) {
4237
+ const f = J(h, l), S = ne(h), C = S.filter(
4238
+ (B) => B.kind === k.ElementNode && ae.test(J(B, l))
4239
+ ), A = S.filter(
4240
+ (B) => B.kind === k.ElementNode && !ae.test(J(B, l))
4241
+ ), P = re(h).map(q), F = P.filter((B) => Je.indexOf(B.name) >= 0);
4242
+ if (P.length > F.length)
4243
+ return b("T011", f), null;
4244
+ const y = F.find((B) => B.name === "name");
4245
+ if (g) {
4246
+ if (!(y != null && y.value))
4247
+ return b("T012", f), null;
4248
+ } else if (y)
4249
+ return b("T018", f), null;
4250
+ const M = y == null ? void 0 : y.value, _ = F.find((B) => B.name === "value");
4251
+ if (_ && _.value === void 0)
4252
+ return b("T019", f), null;
4253
+ if (M && C.length >= 1) {
4254
+ if (A.length > 0)
4255
+ return b("T020"), null;
4256
+ const B = C.map((Q) => L(d, Q));
4257
+ return {
4258
+ name: M,
4259
+ value: B.length === 1 ? B[0] : B
4260
+ };
4261
+ }
4262
+ let w = _ == null ? void 0 : _.value;
4263
+ return w === null ? null : typeof w == "string" ? { name: M, value: w } : { name: M, value: U(d, S) };
4264
+ }
4265
+ function E(d, h, g) {
4266
+ var C;
4267
+ if (!T(h)) {
4268
+ b("T009", "loaders");
4269
+ return;
4270
+ }
4271
+ const f = ne(g);
4272
+ if (f.length === 0 && (h.loaders ?? (h.loaders = [])), (C = g.children) == null ? void 0 : C.some((A) => A.kind === k.AttributeListNode)) {
4273
+ b("T014", "attributes");
4274
+ return;
4275
+ }
4276
+ f.forEach((A) => {
4277
+ if (A.kind === k.TextNode) {
4278
+ b("T010", "loader");
4279
+ return;
4280
+ }
4281
+ const P = L(d, A);
4282
+ if (!P.uid) {
4283
+ b("T013");
4284
+ return;
4285
+ }
4286
+ if (P.vars) {
4287
+ b("T014", "vars");
4288
+ return;
4289
+ }
4290
+ if (P.loaders) {
4291
+ b("T014", "loaders");
4292
+ return;
4293
+ }
4294
+ if (P.uses) {
4295
+ b("T014", "uses");
4296
+ return;
4297
+ }
4298
+ h.loaders ?? (h.loaders = []), h.loaders.push(P);
4299
+ });
4300
+ }
4301
+ function $(d, h, g, f, S, C) {
4302
+ const A = m(d, g);
4303
+ if (!A)
4304
+ return;
4305
+ C == null || C((A == null ? void 0 : A.name) ?? "");
4306
+ const P = A.name, F = A.value;
4307
+ if ((A == null ? void 0 : A.value) !== void 0)
4308
+ S(P, te(f(P), F));
4309
+ else {
4310
+ const y = ne(g), M = U(d, y);
4311
+ let _ = f(P);
4312
+ _ = te(_, M), S(P, _);
4313
+ }
4314
+ }
4315
+ function K(d, h) {
4316
+ if (!T(d)) {
4317
+ b("T009", "uses");
4318
+ return;
4319
+ }
4320
+ const g = re(h).map(q), f = g.find((S) => S.name === "value");
4321
+ if (!(f != null && f.value) || g.length !== 1) {
4322
+ b("T015", "uses");
4323
+ return;
4324
+ }
4325
+ d.uses ?? (d.uses = f.value.split(",").map((S) => S.trim()));
4326
+ }
4327
+ function q(d) {
4328
+ let h = d.children[0];
4329
+ const g = h.children.length === 3;
4330
+ let f;
4331
+ g && (f = l(h.children[0]));
4332
+ let S = l(h.children[h.children.length - 1]);
4333
+ const C = S.split(".");
4334
+ C.length > 2 && b("T007", d, h);
4335
+ let A, P;
4336
+ C.length === 2 ? (P = C[0], A = C[1], A.trim() === "" && b("T007", d, A)) : A = S;
4337
+ const F = l(d.children[2]), y = F.substring(1, F.length - 1);
4338
+ return { namespace: f, startSegment: P, name: A, value: y, unsegmentedName: S };
4339
+ }
4340
+ function X(d) {
4341
+ for (let h of d) {
4342
+ const g = h.children[h.children.length - 1], f = v(l(g));
4343
+ f !== null && (g.text = f);
4344
+ }
4345
+ }
4346
+ function V(d) {
4347
+ const h = ne(d), g = J(d, l), S = !(g in Y) || g === "property", C = g !== "event" && g !== "method", A = re(d);
4348
+ nr(A), tr(A, l), X(A), I(h), G(h, C);
4349
+ let P = !1, F = !1;
4350
+ for (let w = 0; w < h.length; ++w) {
4351
+ const B = h[w];
4352
+ let Q;
4353
+ if (B.kind == k.Script) {
4354
+ F = !0;
4355
+ continue;
4356
+ }
4357
+ if (B.kind === k.ElementNode) {
4358
+ Q = V(B), h[w] = Q;
4359
+ continue;
4360
+ }
4361
+ let W = l(B);
4362
+ B.kind === k.StringLiteral ? W = W.slice(1, -1) : B.kind === k.CData ? P = !0 : (B.kind, k.TextNode), S ? P ? Q = rr(W) : Q = Se(W) : Q = {
4363
+ kind: k.TextNode,
4364
+ text: W
4365
+ }, h[w] = Q;
4366
+ }
4367
+ const y = [], M = [];
4368
+ let _ = !1;
4369
+ for (const w of h) {
4370
+ if (w.kind === k.ElementNode) {
4371
+ if ((J(w, l) ?? void 0) in Y) {
4372
+ y.push(w);
4373
+ continue;
4374
+ }
4375
+ _ = !0;
4376
+ }
4377
+ M.push(w);
4378
+ }
4379
+ if (F && _) {
4380
+ const w = _e(M);
4381
+ return y.push(w), Le(d, y);
4382
+ }
4383
+ return d;
4384
+ }
4385
+ function ee(d) {
4386
+ for (let h = 0; h < d.length; ++h)
4387
+ if (d[h].kind === k.StringLiteral || d[h].kind === k.TextNode) {
4388
+ const g = /[\f\n\r\t\v\u0020\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]+/g;
4389
+ d[h].text = l(d[h]).replace(
4390
+ g,
4391
+ " "
4392
+ );
4393
+ }
4394
+ }
4395
+ function H(d) {
4396
+ for (let h = 0; h < d.length; ++h)
4397
+ d[h].kind === k.CData && (d[h].text = l(d[h]).slice(Ye, -3));
4398
+ }
4399
+ function I(d) {
4400
+ for (let h of d)
4401
+ if (h.kind === k.StringLiteral || h.kind === k.TextNode) {
4402
+ const g = v(l(h));
4403
+ g !== null && (h.text = g);
4404
+ }
4405
+ }
4406
+ function v(d) {
4407
+ let h = "", g = 0;
4408
+ for (let f = 0; f < d.length; ++f)
4409
+ if (d.charCodeAt(f) === R.ampersand)
4410
+ switch (d.charCodeAt(f + 1)) {
4411
+ case R.a:
4412
+ switch (d.charCodeAt(f + 2)) {
4413
+ case R.m:
4414
+ d.charCodeAt(f + 3) === R.p && d.charCodeAt(f + 4) === R.semicolon && (h = h + d.substring(g, f) + "&", f += 4, g = f + 1);
4415
+ break;
4416
+ case R.p:
4417
+ d.charCodeAt(f + 3) === R.o && d.charCodeAt(f + 4) === R.s && d.charCodeAt(f + 5) === R.semicolon && (h = h + d.substring(g, f) + "'", f += 5, g = f + 1);
4418
+ break;
4419
+ }
4420
+ break;
4421
+ case R.g:
4422
+ d.charCodeAt(f + 2) === R.t && d.charCodeAt(f + 3) === R.semicolon && (h = h + d.substring(g, f) + ">", f += 3, g = f + 1);
4423
+ break;
4424
+ case R.l:
4425
+ d.charCodeAt(f + 2) === R.t && d.charCodeAt(f + 3) === R.semicolon && (h = h + d.substring(g, f) + "<", f += 3, g = f + 1);
4426
+ break;
4427
+ case R.q:
4428
+ d.charCodeAt(f + 2) === R.u && d.charCodeAt(f + 3) === R.o && d.charCodeAt(f + 4) === R.t && d.charCodeAt(f + 5) === R.semicolon && (h = h + d.substring(g, f) + '"', f += 5, g = f + 1);
4429
+ break;
4430
+ case R.n:
4431
+ d.charCodeAt(f + 2) === R.b && d.charCodeAt(f + 3) === R.s && d.charCodeAt(f + 4) === R.p && d.charCodeAt(f + 5) === R.semicolon && (h = h + d.substring(g, f) + " ", f += 5, g = f + 1);
4432
+ break;
4433
+ }
4434
+ return g === 0 ? null : (h += d.substring(g), h);
4435
+ }
4436
+ function G(d, h) {
4437
+ h && ee(d), H(d);
4438
+ for (let g = d.length - 1; g > 0; --g) {
4439
+ const f = d[g - 1], S = d[g];
4440
+ f.kind === k.StringLiteral && S.kind === k.CData ? (d[g - 1] = {
4441
+ kind: k.CData,
4442
+ text: l(f).slice(1, -1) + l(S)
4443
+ }, d.pop()) : f.kind === k.CData && S.kind === k.StringLiteral ? (d[g - 1] = {
4444
+ kind: k.CData,
4445
+ text: l(f) + l(S).slice(1, -1)
4446
+ }, d.pop()) : f.kind === k.CData && S.kind === k.TextNode ? (d[g - 1] = {
4447
+ kind: k.CData,
4448
+ text: l(f) + l(S)
4449
+ }, d.pop()) : f.kind === k.CData && S.kind === k.CData ? (d[g - 1] = {
4450
+ kind: k.CData,
4451
+ text: l(f) + l(S)
4452
+ }, d.pop()) : f.kind === k.TextNode && S.kind === k.TextNode ? (l(f).endsWith(" ") && l(S).startsWith(" ") && (f.text = l(f).trimEnd()), d[g - 1] = {
4453
+ kind: k.TextNode,
4454
+ text: l(f) + l(S)
4455
+ }, d.pop()) : f.kind === k.TextNode && S.kind === k.CData && (d[g - 1] = {
4456
+ kind: k.CData,
4457
+ text: l(f) + l(S)
4458
+ }, d.pop());
4459
+ }
4460
+ }
4461
+ }
4462
+ function rr(n) {
4463
+ return {
4464
+ kind: k.ElementNode,
4465
+ children: [
4466
+ { kind: k.OpenNodeStart },
4467
+ {
4468
+ kind: k.TagNameNode,
4469
+ children: [{ kind: k.Identifier, text: "TextNodeCData" }]
4470
+ },
4471
+ {
4472
+ kind: k.AttributeListNode,
4473
+ children: [
4474
+ {
4475
+ kind: k.AttributeNode,
4476
+ children: [
4477
+ {
4478
+ kind: k.AttributeKeyNode,
4479
+ children: [{ kind: k.Identifier, text: "value" }]
4480
+ },
4481
+ { kind: k.Equal },
4482
+ { kind: k.Identifier, text: `"${n}"` }
4483
+ ]
4484
+ }
4485
+ ]
4486
+ },
4487
+ { kind: k.NodeClose }
4488
+ ]
4489
+ };
4490
+ }
4491
+ function Se(n) {
4492
+ return {
4493
+ kind: k.ElementNode,
4494
+ children: [
4495
+ { kind: k.OpenNodeStart },
4496
+ {
4497
+ kind: k.TagNameNode,
4498
+ children: [{ kind: k.Identifier, text: "TextNode" }]
4499
+ },
4500
+ {
4501
+ kind: k.AttributeListNode,
4502
+ children: [
4503
+ {
4504
+ kind: k.AttributeNode,
4505
+ children: [
4506
+ {
4507
+ kind: k.AttributeKeyNode,
4508
+ children: [{ kind: k.Identifier, text: "value" }]
4509
+ },
4510
+ { kind: k.Equal },
4511
+ { kind: k.Identifier, text: `"${n}"` }
4512
+ ]
4513
+ }
4514
+ ]
4515
+ },
4516
+ { kind: k.NodeClose }
4517
+ ]
4518
+ };
4519
+ }
4520
+ function b(n, ...e) {
4521
+ let r = Ze[n] ?? "Unknown error";
4522
+ throw e && e.forEach((l, a) => r = t(r, `{${a}}`, l.toString())), new ue(r, n);
4523
+ function t(l, a, o) {
4524
+ do
4525
+ l = l.replace(a, o);
4526
+ while (l.includes(a));
4527
+ return l;
4528
+ }
4529
+ }
4530
+ function T(n) {
4531
+ return n.type;
4532
+ }
4533
+ function te(n, e) {
4534
+ return n ? Array.isArray(n) ? typeof n == "string" ? [n, e] : (n.push(e), n) : [n, e] : e;
4535
+ }
4536
+ function _e(n) {
4537
+ const e = {
4538
+ kind: k.TagNameNode,
4539
+ children: [{ kind: k.Identifier, text: "Fragment" }]
4540
+ };
4541
+ return {
4542
+ kind: k.ElementNode,
4543
+ start: n[0].start,
4544
+ pos: n[0].pos,
4545
+ end: n[n.length - 1].end,
4546
+ children: [
4547
+ { kind: k.OpenNodeStart },
4548
+ e,
4549
+ { kind: k.NodeEnd },
4550
+ { kind: k.ContentListNode, children: n },
4551
+ { kind: k.CloseNodeStart },
4552
+ e,
4553
+ { kind: k.NodeEnd }
4554
+ ]
4555
+ };
4556
+ }
4557
+ function re(n) {
4558
+ var e, r;
4559
+ return ((r = (e = n.children) == null ? void 0 : e.find((t) => t.kind === k.AttributeListNode)) == null ? void 0 : r.children) ?? [];
4560
+ }
4561
+ function ne(n) {
4562
+ var e, r;
4563
+ return ((r = (e = n.children) == null ? void 0 : e.find((t) => t.kind === k.ContentListNode)) == null ? void 0 : r.children) ?? [];
4564
+ }
4565
+ function Le(n, e) {
4566
+ var t;
4567
+ const r = (t = n.children) == null ? void 0 : t.findIndex((l) => l.kind === k.ContentListNode);
4568
+ return r === void 0 || r === -1 ? n : {
4569
+ ...n,
4570
+ children: [
4571
+ ...n.children.slice(0, r),
4572
+ { ...n.children[r], children: e },
4573
+ ...n.children.slice(r)
4574
+ ]
4575
+ };
4576
+ }
4577
+ function nr(n) {
4578
+ var e;
4579
+ for (let r of n)
4580
+ if (((e = r.children) == null ? void 0 : e.length) === 1) {
4581
+ const t = {
4582
+ kind: k.Equal
4583
+ }, l = {
4584
+ kind: k.StringLiteral,
4585
+ text: '"true"'
4586
+ };
4587
+ r.children.push(t, l);
4588
+ }
4589
+ }
4590
+ function tr(n, e) {
4591
+ var r, t, l;
4592
+ for (let a of n) {
4593
+ const o = (r = a.children) == null ? void 0 : r[2];
4594
+ ((l = (t = a.children) == null ? void 0 : t[2]) == null ? void 0 : l.kind) === k.Identifier && (o.text = '"' + e(o) + '"');
4595
+ }
4596
+ }
4597
+ function we(n, e, r, t) {
4598
+ let l = t.split(":");
4599
+ if (l.length > 2)
4600
+ return b("T028", t, "Namespace cannot contain multiple ':' (colon).");
4601
+ let a = t;
4602
+ if (l.length === 2) {
4603
+ if (l[0] != oe)
4604
+ return b("T029", t, oe);
4605
+ a = l[1];
4606
+ }
4607
+ if (a.includes("#"))
4608
+ return b("T028", a, "Namespace cannot contain character '#'.");
4609
+ switch (a) {
4610
+ case oe:
4611
+ a = r;
4612
+ break;
4613
+ case je:
4614
+ a = Ve;
4615
+ break;
4616
+ case er:
4617
+ a = se;
4618
+ break;
4619
+ }
4620
+ const o = n[n.length - 1];
4621
+ if (o.has(r))
4622
+ return b("T025", r);
4623
+ o.set(r, a), e.namespaces ?? (e.namespaces = {}), e.namespaces[r] = a;
4624
+ }
4625
+ function ir(n, e) {
4626
+ n.children.length !== 2 && b("T001");
4627
+ const r = n.children[0];
4628
+ return r.kind !== k.ElementNode && b("T001"), r;
4629
+ }
4630
+ function J(n, e) {
4631
+ const r = n.children.find((l) => l.kind === k.TagNameNode).children;
4632
+ return e(r.at(-1));
4633
+ }
4634
+ function Ce(n, e, r) {
4635
+ const t = n.children.find((c) => c.kind === k.TagNameNode).children, l = e(t.at(-1));
4636
+ if (t.length === 1)
4637
+ return l;
4638
+ const a = e(t[0]);
4639
+ r.length === 0 && b("T026");
4640
+ let o;
4641
+ for (let c = r.length - 1; c >= 0 && (o = r[c].get(a), o === void 0); --c)
4642
+ ;
4643
+ return o === void 0 && b("T027", a), o + "." + l;
4644
+ }
4645
+ const lr = [
4646
+ "horizontalAlignment",
4647
+ "verticalAlignment",
4648
+ "orientation",
4649
+ "width",
4650
+ "minWidth",
4651
+ "maxWidth",
4652
+ "height",
4653
+ "minHeight",
4654
+ "maxHeight",
4655
+ "gap",
4656
+ "border",
4657
+ "borderTop",
4658
+ "borderRight",
4659
+ "borderBottom",
4660
+ "borderLeft",
4661
+ "borderColor",
4662
+ "borderStyle",
4663
+ "borderWidth",
4664
+ "borderHorizontal",
4665
+ "borderVertical",
4666
+ "borderRadius",
4667
+ "radiusTopLeft",
4668
+ "radiusTopRight",
4669
+ "radiusBottomLeft",
4670
+ "radiusBottomRight",
4671
+ "padding",
4672
+ "paddingHorizontal",
4673
+ "paddingVertical",
4674
+ "paddingTop",
4675
+ "paddingRight",
4676
+ "paddingBottom",
4677
+ "paddingLeft",
4678
+ "backgroundColor",
4679
+ "background",
4680
+ "boxShadow",
4681
+ "direction",
4682
+ "overflowX",
4683
+ "overflowY",
4684
+ "zIndex",
4685
+ "color",
4686
+ "fontFamily",
4687
+ "fontSize",
4688
+ "fontWeight",
4689
+ "fontStyle",
4690
+ "textDecoration",
4691
+ "wrapContent",
4692
+ "canShrink",
4693
+ "margin",
4694
+ "marginHorizontal",
4695
+ "marginVertical",
4696
+ "marginTop",
4697
+ "marginRight",
4698
+ "marginBottom",
4699
+ "marginLeft",
4700
+ "userSelect",
4701
+ "letterSpacing",
4702
+ "textTransform",
4703
+ "lineHeight",
4704
+ "opacity",
4705
+ "cursor",
4706
+ "textWrap",
4707
+ "textAlign",
4708
+ "textAlignLast",
4709
+ "top",
4710
+ "right",
4711
+ "bottom",
4712
+ "left",
4713
+ "zoom",
4714
+ "whiteSpace",
4715
+ "textDecoration",
4716
+ "textDecorationLine",
4717
+ "textDecorationColor",
4718
+ "textDecorationStyle",
4719
+ "textDecorationThickness",
4720
+ "textUnderlineOffset",
4721
+ "outline",
4722
+ "outlineWidth",
4723
+ "outlineColor",
4724
+ "outlineStyle",
4725
+ "outlineOffset"
4726
+ ], Pr = "xmlui", Rr = "xmlui.xs", Fr = "xs";
4727
+ var ar = /* @__PURE__ */ ((n) => (n[n.Skip = 0] = "Skip", n[n.Warning = 1] = "Warning", n[n.Error = 2] = "Error", n))(ar || {}), or = /* @__PURE__ */ ((n) => (n[n.UnrecognisedProp = 0] = "UnrecognisedProp", n))(or || {});
4728
+ function Ur(n) {
4729
+ if (!n)
4730
+ return 1;
4731
+ switch (n.toLowerCase()) {
4732
+ case "warning":
4733
+ return 1;
4734
+ case "error":
4735
+ return 2;
4736
+ case "skip":
4737
+ return 0;
4738
+ default:
4739
+ return console.warn(`Invalid lint severity option '${n}'. Must be one of: 'warning', 'error', 'skip'. Defaulting to 'warning'.`), 1;
4740
+ }
4741
+ }
4742
+ function Mr({
4743
+ appDef: n,
4744
+ metadataByComponent: e
4745
+ }) {
4746
+ const r = {
4747
+ componentName: "Main",
4748
+ lints: Ae({
4749
+ component: n.entryPoint,
4750
+ metadataByComponent: e
4751
+ })
4752
+ }, t = (n.components ?? []).map((l) => ({ lints: Ae({
4753
+ component: l,
4754
+ metadataByComponent: e
4755
+ }), componentName: l.name }));
4756
+ return [r, ...t].filter((l) => l.lints.length > 0);
4757
+ }
4758
+ function qr(n) {
4759
+ console.group(`Validation on '${n.componentName}':`), n.lints.forEach(({ message: e }) => {
4760
+ console.warn(e);
4761
+ }), console.groupEnd();
4762
+ }
4763
+ function $r(n) {
4764
+ function e() {
4765
+ const r = n.map((l, a) => ({
4766
+ type: "VStack",
4767
+ props: { gap: "0px" },
4768
+ children: [
4769
+ {
4770
+ type: "VStack",
4771
+ props: { backgroundColor: "lightgrey", padding: "10px" },
4772
+ children: [
4773
+ {
4774
+ type: "H2",
4775
+ props: {
4776
+ value: `#${a + 1}: In component '${l.componentName}':`,
4777
+ color: "$color-info"
4778
+ }
4779
+ },
4780
+ {
4781
+ type: "VStack",
4782
+ children: l.lints.map(({ message: o }, c) => ({
4783
+ type: "Text",
4784
+ props: { value: `${a + 1}.${c + 1}: ${o}`, fontWeight: "bold" }
4785
+ }))
4786
+ }
4787
+ ]
4788
+ }
4789
+ ]
4790
+ }));
4791
+ return {
4792
+ type: "VStack",
4793
+ props: { padding: "$padding-normal", gap: 0 },
4794
+ children: [
4795
+ {
4796
+ type: "H1",
4797
+ props: {
4798
+ value: "Errors found while checking Xmlui markup",
4799
+ padding: "$padding-normal",
4800
+ backgroundColor: "$color-error",
4801
+ color: "white"
4802
+ }
4803
+ },
4804
+ {
4805
+ type: "VStack",
4806
+ props: {
4807
+ gap: "$gap-tight",
4808
+ padding: "$padding-normal"
4809
+ },
4810
+ children: r
4811
+ }
4812
+ ]
4813
+ };
4814
+ }
4815
+ return e();
4816
+ }
4817
+ function Ae({
4818
+ component: n,
4819
+ metadataByComponent: e
4820
+ }) {
4821
+ return "component" in n ? ce(n.component, e, []) : ce(n, e, []);
4822
+ }
4823
+ function ce(n, e, r) {
4824
+ const t = n.type.startsWith(se) ? n.type.slice(se.length + 1) : n.type, l = e[t];
4825
+ if (!n.props || !l || !l.props || l.allowArbitraryProps || sr(n, l, r), !n.children)
4826
+ return r;
4827
+ for (const o of n.children)
4828
+ ce(o, e, r);
4829
+ return r;
4830
+ }
4831
+ const ve = lr;
4832
+ function sr(n, e, r) {
4833
+ const l = Object.keys(n.props).filter((a) => !ur(a) && !(a in e.props));
4834
+ for (const a of l)
4835
+ r.push(cr(n, a));
4836
+ }
4837
+ function cr(n, e) {
4838
+ return {
4839
+ message: `Unrecognised property '${e}' on component '${n.type}'.`,
4840
+ kind: 0
4841
+ /* UnrecognisedProp */
4842
+ };
4843
+ }
4844
+ function ur(n) {
4845
+ for (const e of ye) {
4846
+ const r = "-" + e.value;
4847
+ if (n.endsWith(r)) {
4848
+ const t = n.slice(0, -r.length);
4849
+ if (ve.includes(t))
4850
+ return !0;
4851
+ }
4852
+ }
4853
+ return ve.includes(n);
4854
+ }
4855
+ export {
4856
+ Ur as A,
4857
+ ar as B,
4858
+ Mr as C,
4859
+ qr as D,
4860
+ $r as E,
4861
+ Qe as F,
4862
+ Wr as G,
4863
+ xe as H,
4864
+ Fr as I,
4865
+ or as J,
4866
+ Ae as K,
4867
+ fr as L,
4868
+ ue as M,
4869
+ Ze as N,
4870
+ me as O,
4871
+ Ne as P,
4872
+ se as Q,
4873
+ Nr as T,
4874
+ ae as U,
4875
+ Ir as V,
4876
+ Pe as a,
4877
+ Sr as b,
4878
+ Er as c,
4879
+ kr as d,
4880
+ mr as e,
4881
+ De as f,
4882
+ Dr as g,
4883
+ Ue as h,
4884
+ wr as i,
4885
+ gr as j,
4886
+ Lr as k,
4887
+ vr as l,
4888
+ xr as m,
4889
+ Br as n,
4890
+ _r as o,
4891
+ Cr as p,
4892
+ Ar as q,
4893
+ Or as r,
4894
+ Ie as s,
4895
+ yr as t,
4896
+ le as u,
4897
+ br as v,
4898
+ lr as w,
4899
+ pr as x,
4900
+ Pr as y,
4901
+ Rr as z
4902
+ };