@weatherboard/gyde-design 0.4.4 → 0.6.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.
package/README.md CHANGED
@@ -171,6 +171,24 @@ into their repository.
171
171
  product's; a scaffolder that clobbers has taken ownership of something it does
172
172
  not own, silently.
173
173
 
174
+ ## Importing a module directly
175
+
176
+ The barrel (`@weatherboard/gyde-design`) is the curated named surface. Every
177
+ module the package ships is also reachable by its own subpath:
178
+
179
+ ```js
180
+ import { themeStartup } from "@weatherboard/gyde-design/theme-entry.mjs";
181
+ import pkg from "@weatherboard/gyde-design/package.json" with { type: "json" };
182
+ ```
183
+
184
+ That is a stated guarantee rather than an accident of file layout, and
185
+ `exports.test.mjs` fails if a shipped module is not reachable — so verifying
186
+ your own repository never means reaching into `node_modules` by filesystem
187
+ path. The two exceptions are named there with their reasons: the CLI, which is
188
+ the `bin` and executes on import, and the vendored parsers under `vendor/`,
189
+ which ship so the Action can run with nothing installed and are not ours to
190
+ promise.
191
+
174
192
  ## The rules, as data
175
193
 
176
194
  A rule id reaches you three times — in a finding, in the `rules` stamp inside
@@ -368,6 +386,19 @@ whatever lands under that name next, and it is the only way the list could
368
386
  shrink invisibly. The same discipline the allowance ledger has — it may only
369
387
  ever get shorter, and never by accident.
370
388
 
389
+ **One `file` + tag may repeat, but not with different reasons.** An exception
390
+ identifies its element by file and tag name matched in source order, so nothing
391
+ records *which* `<div>` a reason was written about. Many elements sharing one
392
+ argument is normal and safe — an inline-styled block of markup is genuinely one
393
+ decision — and reordering them changes nothing a reader could act on. Two
394
+ entries for one file and tag carrying **different** arguments is a different
395
+ thing: a reorder reattaches each reason to an element nobody wrote it about,
396
+ with the count, the figure and the verdict all unchanged. That is an **error**,
397
+ and the fix is one reason true of the whole group, because that is the
398
+ granularity the exemption actually has. No occurrence index is offered: an
399
+ explicit ordinal makes the identity visible without making it stable, so the
400
+ same reorder still reattaches the reasons, now with a number agreeing.
401
+
371
402
  **Every path fails closed.** A malformed entry, an unknown key, a scope that
372
403
  does not resolve, a scope that matches no markup files, a scope whose files make
373
404
  no visual decision, an unreadable component barrel, an exception naming
@@ -382,6 +413,13 @@ and a rule that matches nothing reads exactly like a rule that passes.
382
413
  bespoke element and carries a reason somebody wrote. It cannot tell a true
383
414
  reason from a plausible sentence. What it buys is that every one of them is
384
415
  on the artefact, in the diff, with a name and a line number attached.
416
+ - **Element identity is still ordinal.** The reason-collision check above is a
417
+ check on the *configuration*, never on the source. A single entry for `<div>`
418
+ in a file that later grows a second bespoke `<div>` forms no group, so nothing
419
+ fires — and that entry now matches whichever comes first in source order,
420
+ which may not be the one it was written about. Within an identical-reason
421
+ group nothing is guarded at all, by design; if one member is later edited so
422
+ the shared reason stops being true of it, the group still validates.
385
423
  - **It measures markup, not rendering.** An element is the system's if its tag
386
424
  is one of the design system's exports. A component that imports the system
387
425
  and then restyles it at the call site still counts — that is the styling
package/floor.mjs CHANGED
@@ -149,6 +149,112 @@ const EXCEPTION_KEYS = new Set(["file", "element", "because"]);
149
149
  */
150
150
  const MIN_REASON = 12;
151
151
 
152
+ /**
153
+ * G-135 — two exceptions for one `file` + tag, carrying DIFFERENT reasons.
154
+ *
155
+ * ===========================================================================
156
+ * THE DEFECT, AND WHY THE OBVIOUS GUARD IS THE WRONG ONE
157
+ * ===========================================================================
158
+ *
159
+ * `measureFloor` identifies an excepted element by `file` + tag name, matched
160
+ * in SOURCE ORDER: the first unclaimed `<div>` in that file, then the next.
161
+ * Nothing in the configuration says WHICH `div`, because nothing in the
162
+ * configuration can. So move a block, wrap something, reorder a return — and
163
+ * entry 1's reason attaches to entry 2's element. Every element is still real,
164
+ * the count is still right, the floor is still met: the gate stays green and
165
+ * the ledger now misdescribes which element was argued for and why. A silent
166
+ * wrong answer, which this repository holds to be worse than a red one.
167
+ *
168
+ * The obvious guard — refuse any repeated `file` + tag — is too blunt, and
169
+ * measurably so. Against the first consumer to adopt a floor, fourteen of
170
+ * nineteen exceptions sat in same-file-same-tag groups, and thirteen of those
171
+ * were one inline-styled preview surface: many elements, genuinely ONE
172
+ * argument. Reordering them is harmless, because the reasons are
173
+ * interchangeable in fact and not merely in the matcher. Forcing thirteen
174
+ * distinct sentences there would produce worse prose, not better identity.
175
+ *
176
+ * So the hazard is not repetition. It is **repetition carrying different
177
+ * reasons**, and that is exactly what is checked here.
178
+ *
179
+ * ===========================================================================
180
+ * WHY THIS REFUSES RATHER THAN WARNS
181
+ * ===========================================================================
182
+ *
183
+ * Every other malformed floor is an error — an unknown key, a duplicate scope,
184
+ * a zero-match scope, a stale exception. A warning would be the one advisory
185
+ * thing in a fail-closed file, and this repository's standing finding is that
186
+ * a gate nobody must act on is a gate that does not exist.
187
+ *
188
+ * The usual objection to refusing is that it removes a capability with nothing
189
+ * to replace it. It does not, and this is the crux: the per-element precision
190
+ * a differing-reason group appears to have **was never delivered**. Four divs
191
+ * with four reasons read as four arguments about four elements; the matcher
192
+ * can only offer "four of the divs in this file are excepted". The
193
+ * configuration is claiming a precision the mechanism does not have, and
194
+ * refusing it is Gyde declining to keep up the appearance.
195
+ *
196
+ * The way to express it is therefore already in the format, needs no new key,
197
+ * and is what the error says: **write one reason that covers the group.** A
198
+ * single argument true of all four members is a claim the matcher can actually
199
+ * honour, and a reader who disagrees with it disagrees with all four at once —
200
+ * which is the granularity the exemption really has.
201
+ *
202
+ * NO DISAMBIGUATOR IS ADDED, AND THAT IS A DECISION RATHER THAN AN OMISSION.
203
+ * An optional occurrence index (`nth`) is the tempting small fix and it buys
204
+ * nothing: it makes the ordinal identity EXPLICIT without making it STABLE, so
205
+ * the reorder that reattached the reasons silently still reattaches them —
206
+ * now with a number in the config agreeing. Line anchors and content hashes do
207
+ * fix identity, and were rejected on the issue for churning a reviewed ledger
208
+ * into a file people update mechanically without reading, which is the failure
209
+ * the reasons exist to prevent. A guard that needs no new vocabulary is worth
210
+ * more here than a key that needs one and still does not work.
211
+ *
212
+ * ===========================================================================
213
+ * WHAT THIS DOES NOT PROTECT AGAINST
214
+ * ===========================================================================
215
+ *
216
+ * - **A reorder inside an identical-reason group.** Deliberately unguarded:
217
+ * the reasons are interchangeable, so the reattachment changes nothing a
218
+ * reader could act on. The residue is that if one member is later edited so
219
+ * the shared reason stops being true of it, the group still validates and
220
+ * nothing notices.
221
+ * - **A collision introduced by the FILE rather than the config.** This is a
222
+ * schema check: it reads the configuration and never the source. One entry
223
+ * for `<div>` in a file that later grows a second bespoke `<div>` is not a
224
+ * group, so nothing here fires — and yet the single entry now matches
225
+ * whichever `div` comes first in source order, which may not be the one it
226
+ * was written about. That is the same defect arriving from the other side,
227
+ * and it is not covered.
228
+ * - **Whether a shared reason is true.** As everywhere else in this file,
229
+ * Gyde checks that a reason was written, never that it is honest.
230
+ */
231
+ function reasonCollisions(at, exceptions) {
232
+ const groups = new Map();
233
+ exceptions.forEach((ex, j) => {
234
+ if (!isPlainObject(ex) || typeof ex.file !== "string" || typeof ex.element !== "string") return;
235
+ const key = JSON.stringify([norm(ex.file), ex.element]);
236
+ if (!groups.has(key)) groups.set(key, []);
237
+ groups.get(key).push({ j, because: typeof ex.because === "string" ? ex.because.trim() : "" });
238
+ });
239
+
240
+ const out = [];
241
+ for (const [key, members] of groups) {
242
+ if (members.length < 2) continue;
243
+ const distinct = new Set(members.map((m) => m.because));
244
+ if (distinct.size < 2) continue;
245
+ const [file, element] = JSON.parse(key);
246
+ out.push(
247
+ `${at}.exceptions: ${members.length} exceptions name <${element}> in ${file} and ${distinct.size} of them ` +
248
+ `give DIFFERENT reasons (entries ${members.map((m) => m.j).join(", ")}). An exception identifies its element ` +
249
+ `by file and tag name in source order, so nothing records which <${element}> each reason was written about: ` +
250
+ `reorder the file and the reasons reattach to different elements, silently, with the count and the verdict ` +
251
+ `unchanged. Repeating a tag is fine — repeating it with different arguments is not. Give the group ONE reason ` +
252
+ `that is true of all ${members.length}, which is the granularity this exemption actually has.`,
253
+ );
254
+ }
255
+ return out;
256
+ }
257
+
152
258
  /**
153
259
  * Validate the declared floors.
154
260
  *
@@ -243,6 +349,7 @@ export function validateFloors(raw) {
243
349
  `(at least ${MIN_REASON} characters). An exception nobody had to justify is an exemption, not an exception.`);
244
350
  }
245
351
  });
352
+ for (const e of reasonCollisions(at, exceptions)) errors.push(e);
246
353
  }
247
354
 
248
355
  floors.push({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@weatherboard/gyde-design",
3
- "version": "0.4.4",
3
+ "version": "0.6.0",
4
4
  "private": false,
5
5
  "description": "Scaffolds a design system into a product repository, then keeps auditing it.",
6
6
  "type": "module",
@@ -15,32 +15,39 @@
15
15
  },
16
16
  "exports": {
17
17
  ".": "./index.mjs",
18
- "./workspace.mjs": "./workspace.mjs",
19
- "./normalise.mjs": "./normalise.mjs",
20
- "./rules.mjs": "./rules.mjs",
21
- "./ruleindex.mjs": "./ruleindex.mjs",
22
- "./scan.mjs": "./scan.mjs",
23
- "./tokens.mjs": "./tokens.mjs",
18
+ "./package.json": "./package.json",
19
+ "./adoption.mjs": "./adoption.mjs",
20
+ "./agentdocs.mjs": "./agentdocs.mjs",
24
21
  "./boundaries.mjs": "./boundaries.mjs",
25
- "./ratchet.mjs": "./ratchet.mjs",
26
- "./emit.mjs": "./emit.mjs",
27
22
  "./catalogue.mjs": "./catalogue.mjs",
28
- "./agentdocs.mjs": "./agentdocs.mjs",
29
- "./upgrade.mjs": "./upgrade.mjs",
30
- "./usage.mjs": "./usage.mjs",
31
- "./wiring.mjs": "./wiring.mjs",
32
23
  "./clientboundary.mjs": "./clientboundary.mjs",
33
- "./props.mjs": "./props.mjs",
34
- "./docdrift.mjs": "./docdrift.mjs",
35
24
  "./compound.mjs": "./compound.mjs",
25
+ "./docdrift.mjs": "./docdrift.mjs",
26
+ "./emit.mjs": "./emit.mjs",
27
+ "./enforcement.mjs": "./enforcement.mjs",
28
+ "./floor.mjs": "./floor.mjs",
36
29
  "./htmlscan.mjs": "./htmlscan.mjs",
37
30
  "./markup.mjs": "./markup.mjs",
38
- "./floor.mjs": "./floor.mjs",
39
- "./adoption.mjs": "./adoption.mjs",
40
- "./tailwind.mjs": "./tailwind.mjs",
41
31
  "./migration.mjs": "./migration.mjs",
32
+ "./normalise.mjs": "./normalise.mjs",
33
+ "./props.mjs": "./props.mjs",
34
+ "./ratchet.mjs": "./ratchet.mjs",
35
+ "./ruleindex.mjs": "./ruleindex.mjs",
36
+ "./rules.mjs": "./rules.mjs",
37
+ "./scan.mjs": "./scan.mjs",
38
+ "./scope.mjs": "./scope.mjs",
39
+ "./selfgate.mjs": "./selfgate.mjs",
42
40
  "./stylex.mjs": "./stylex.mjs",
43
- "./enforcement.mjs": "./enforcement.mjs"
41
+ "./tailwind.mjs": "./tailwind.mjs",
42
+ "./theme-choice.mjs": "./theme-choice.mjs",
43
+ "./theme-entry.mjs": "./theme-entry.mjs",
44
+ "./themehost.mjs": "./themehost.mjs",
45
+ "./tokens.mjs": "./tokens.mjs",
46
+ "./upgrade.mjs": "./upgrade.mjs",
47
+ "./usage.mjs": "./usage.mjs",
48
+ "./wiring.mjs": "./wiring.mjs",
49
+ "./workflow.mjs": "./workflow.mjs",
50
+ "./workspace.mjs": "./workspace.mjs"
44
51
  },
45
52
  "files": [
46
53
  "*.mjs",
package/theme-entry.mjs CHANGED
@@ -1,34 +1,208 @@
1
- /** Parse the linked JavaScript module before accepting theme startup wiring. */
2
- // Vendored rather than depended on: `action.yml` installs nothing, so every
3
- // module it reaches may import only node: builtins and files inside the
4
- // action path. G-138 is what happened when that was a comment. See
5
- // vendor/README.md, and selfcontained.test.mjs for the guard.
6
- import { parse } from "./vendor/acorn.mjs";
1
+ /**
2
+ * Parse the linked module of a declared theme host before accepting its wiring.
3
+ *
4
+ * WHY THIS PARSES TYPESCRIPT AND JSX (G-134)
5
+ *
6
+ * This gate is aimed at an application's entry module, and in practice that
7
+ * file is `main.tsx`. The first version parsed with plain acorn and no plugin,
8
+ * so a `.tsx` or `.jsx` entry could never satisfy the gate at all — acorn stops
9
+ * at the first `<`, and the canonical Vite React entry stops one character
10
+ * earlier still, at the `!` in `document.getElementById('root')!`.
11
+ *
12
+ * Measured against 0.4.3 on a real consumer's `apps/design/src/main.tsx`:
13
+ * `Unexpected token (21:2)`, which is a `<StrictMode>` element. Every host
14
+ * entry a React repository actually has was unreachable.
15
+ *
16
+ * So the parser is the vendored acorn extended with the vendored
17
+ * `acorn-typescript`, configured for JSX. That is ONE parsing approach rather
18
+ * than two: the same acorn, producing the same ESTree AST, so the traversal
19
+ * below is unchanged and there is no second dialect to keep in step. A regex
20
+ * would not do — the whole point of reading an AST here is that comments,
21
+ * strings, template literals, regex literals, dead branches and callbacks are
22
+ * excluded by construction, and there is a test for each.
23
+ *
24
+ * Its one measured gap is `satisfies` (TS 4.9), which `acorn-typescript@1.4.13`
25
+ * does not accept. That is stated rather than hidden — in `docs/contract.md` as
26
+ * well as here — and a file it cannot parse is reported as a parse failure
27
+ * naming the position, so a reader is sent to the token rather than to their
28
+ * imports.
29
+ *
30
+ * Both parsers are vendored and imported by RELATIVE PATH: `action.yml`
31
+ * installs nothing, so every module it reaches may import only `node:`
32
+ * builtins and files inside the action path. G-138 is what happened when that
33
+ * was a comment. See vendor/README.md, and selfcontained.test.mjs for the
34
+ * guard.
35
+ *
36
+ * WHY A PARSE FAILURE IS ITS OWN ANSWER
37
+ *
38
+ * The first version returned `false` for a syntax error, and the caller's only
39
+ * message for `false` said the entry "must import and immediately call
40
+ * startThemeChoice at module top level". That describes a real but different
41
+ * defect, and it is a false statement about a file the parser never finished
42
+ * reading — it sends the reader to rearrange imports that were already correct.
43
+ * `themeStartup` therefore reports the two outcomes separately, and the caller
44
+ * renders them as different errors.
45
+ *
46
+ * A TYPE-ONLY IMPORT IS NOT WIRING
47
+ *
48
+ * Parsing TypeScript introduces a hole that plain ESM did not have: `import
49
+ * type { startThemeChoice }` and `import { type startThemeChoice }` are erased
50
+ * before the module runs, so a call beside them throws at runtime rather than
51
+ * starting the theme. Both are rejected below, at the declaration and at the
52
+ * specifier.
53
+ */
54
+ import { Parser } from "./vendor/acorn.mjs";
55
+ import { tsPlugin } from "./vendor/acorn-typescript.mjs";
7
56
 
8
- const directCall = (node, binding) => node?.type === "CallExpression" &&
9
- node.callee.type === "Identifier" && node.callee.name === binding &&
10
- node.arguments.length === 0 && !node.optional;
57
+ /**
58
+ * One parser for every entry dialect this gate accepts: .js, .ts, .jsx, .tsx.
59
+ *
60
+ * The plugin itself is load-bearing — without it a .tsx entry does not parse
61
+ * at all. `{ jsx: true }` is documentation of intent rather than a guarded
62
+ * setting: in acorn-typescript@1.4.13 the option is inert, and the plugin
63
+ * parses JSX whether or not it is passed.
64
+ */
65
+ const EntryParser = Parser.extend(tsPlugin({ jsx: true }));
11
66
 
12
67
  /**
13
- * Only an actual named import followed by a direct top-level call counts.
14
- * Acorn's module AST excludes comments, strings, template literals, regex
15
- * literals, branches and callbacks from this path. A syntax error is a failed
16
- * static contract rather than a guess that source-looking text will execute.
68
+ * TypeScript expression wrappers are erased before the module runs, so
69
+ * `startThemeChoice() as Theme` and `startThemeChoice()!` ARE the call.
70
+ * Matching `CallExpression` directly rejected both with the semantic message —
71
+ * the exact misattribution G-134 exists to kill, arriving through the door TS
72
+ * support opened. Nested casts (`f() as unknown as Theme`) mean a loop.
73
+ *
74
+ * `TSSatisfiesExpression` is unreachable under `acorn-typescript@1.4.13`, which
75
+ * does not parse `satisfies` at all (see the header). It is listed so that
76
+ * upgrading the plugin cannot quietly reintroduce the defect.
17
77
  */
18
- export function hasThemeStartup(source, systemPackage) {
19
- let program;
20
- try { program = parse(source, { ecmaVersion: "latest", sourceType: "module" }); }
21
- catch { return false; }
78
+ const TYPE_WRAPPERS = new Set(["TSAsExpression", "TSNonNullExpression", "TSSatisfiesExpression"]);
79
+
80
+ const unwrapTypes = (node) => {
81
+ let current = node;
82
+ while (current && TYPE_WRAPPERS.has(current.type)) current = current.expression;
83
+ return current;
84
+ };
85
+
86
+ const directCall = (wrapped, binding) => {
87
+ const node = unwrapTypes(wrapped);
88
+ return node?.type === "CallExpression" &&
89
+ node.callee.type === "Identifier" && node.callee.name === binding &&
90
+ node.arguments.length === 0 && !node.optional;
91
+ };
92
+
93
+ /**
94
+ * Parse an entry module.
95
+ *
96
+ * Returns `{ program }` or `{ error }`, never a thrown exception and never a
97
+ * bare boolean — the caller has to be able to tell "this file does not say
98
+ * what we need" from "this file was never read".
99
+ */
100
+ export function parseEntry(source) {
101
+ try {
102
+ return { program: EntryParser.parse(source, { ecmaVersion: "latest", sourceType: "module", locations: true }) };
103
+ } catch (cause) {
104
+ const { line = null, column = null } = cause?.loc ?? {};
105
+ return { error: { message: String(cause?.message ?? cause), line, column } };
106
+ }
107
+ }
108
+
109
+ /**
110
+ * Why the answer names the QUESTION it answered, and not only "no" (G-141).
111
+ *
112
+ * `{ started: false, parseError: null }` used to be the answer to four
113
+ * different questions, and a caller could not tell them apart:
114
+ *
115
+ * - the entry has no import of `startThemeChoice` at all
116
+ * - it imports it as a TYPE, which is erased before the module runs
117
+ * - it imports it and the call is not the next top-level statement
118
+ * - `systemPackage` was never passed, so the walk searched for an import
119
+ * from the literal string `undefined/theme-choice` and matched nothing
120
+ *
121
+ * The last is a CALLER error and not a verdict about the entry, and it is the
122
+ * one that cost two wrong measurements: `themeStartup(source)` reads unary,
123
+ * returns the byte-identical shape of a genuinely unwired entry, and a
124
+ * correctly-wired file is then reported as failing the gate. So a missing or
125
+ * non-string `systemPackage` now THROWS rather than being searched for. A
126
+ * programming mistake that produces a plausible verdict is worse than one that
127
+ * produces an exception, which is G-134's lesson one layer along: a file the
128
+ * parser never read is not a wiring complaint, and a question nobody asked is
129
+ * not a wiring verdict either.
130
+ *
131
+ * The other three are real verdicts and stay verdicts — but each gets its own
132
+ * `reason`, because the caller's single message named only the third
133
+ * possibility and was therefore a false statement about the first two.
134
+ */
135
+ export const STARTUP_REASON = Object.freeze({
136
+ STARTED: "started",
137
+ PARSE_ERROR: "parse-error",
138
+ /** Nothing in the file imports `startThemeChoice` as a value from the controller. */
139
+ NO_IMPORT: "no-import",
140
+ /** It is imported, but as a type, so the binding does not exist at runtime. */
141
+ TYPE_ONLY_IMPORT: "type-only-import",
142
+ /** It is imported as a value, and the call is not the next top-level statement. */
143
+ CALL_NOT_ADJACENT: "call-not-adjacent",
144
+ });
145
+
146
+ /**
147
+ * Worse news wins. A file with one irrelevant import and one nearly-correct one
148
+ * should be told about the nearly-correct one, so the reasons are ranked and
149
+ * the walk keeps the strongest it has seen rather than the last.
150
+ */
151
+ const REASON_RANK = [
152
+ STARTUP_REASON.NO_IMPORT,
153
+ STARTUP_REASON.TYPE_ONLY_IMPORT,
154
+ STARTUP_REASON.CALL_NOT_ADJACENT,
155
+ ];
156
+
157
+ /**
158
+ * Only an actual VALUE import followed by a direct top-level call counts.
159
+ *
160
+ * `{ started: true, reason: "started" }` the contract is met
161
+ * `{ started: false, reason: "no-import" }` parsed fine, nothing imports it
162
+ * `{ started: false, reason: "type-only-import" }` imported, but erased at runtime
163
+ * `{ started: false, reason: "call-not-adjacent" }` imported, not called next
164
+ * `{ started: false, reason: "parse-error", parseError }` never read; say where
165
+ *
166
+ * @throws {TypeError} if `systemPackage` is missing or is not a non-empty
167
+ * string. See the note above: searching for `undefined/theme-choice` and
168
+ * reporting the miss as a wiring failure is a lie about the consumer's file.
169
+ */
170
+ export function themeStartup(source, systemPackage) {
171
+ if (typeof systemPackage !== "string" || systemPackage === "") {
172
+ throw new TypeError(
173
+ "themeStartup(source, systemPackage): systemPackage must be a non-empty string naming the design-system " +
174
+ `package whose /theme-choice module the entry imports; received ${
175
+ systemPackage === undefined ? "undefined — it takes TWO arguments" : JSON.stringify(systemPackage)}`,
176
+ );
177
+ }
178
+ const { program, error } = parseEntry(source);
179
+ if (error) return { started: false, reason: STARTUP_REASON.PARSE_ERROR, parseError: error };
180
+ let reason = STARTUP_REASON.NO_IMPORT;
181
+ const worse = (next) => {
182
+ if (REASON_RANK.indexOf(next) > REASON_RANK.indexOf(reason)) reason = next;
183
+ };
22
184
  for (const [index, node] of program.body.entries()) {
23
185
  if (node.type !== "ImportDeclaration" ||
24
186
  node.source.value !== `${systemPackage}/theme-choice`) continue;
25
- const binding = node.specifiers.find((part) => part.type === "ImportSpecifier" &&
26
- part.imported.type === "Identifier" && part.imported.name === "startThemeChoice")?.local.name;
27
- if (!binding) continue;
187
+ const named = node.specifiers.find((part) => part.type === "ImportSpecifier" &&
188
+ part.imported.type === "Identifier" && part.imported.name === "startThemeChoice");
189
+ if (!named) continue;
190
+ // `import type { … }` and `import { type … }` are both erased before the
191
+ // module runs, so the call beside them throws rather than starting the theme.
192
+ if (node.importKind === "type" || named.importKind === "type") {
193
+ worse(STARTUP_REASON.TYPE_ONLY_IMPORT);
194
+ continue;
195
+ }
196
+ worse(STARTUP_REASON.CALL_NOT_ADJACENT);
197
+ const binding = named.local.name;
28
198
  const next = program.body[index + 1];
29
- if (next?.type === "ExpressionStatement" && directCall(next.expression, binding)) return true;
199
+ if (next?.type === "ExpressionStatement" && directCall(next.expression, binding)) {
200
+ return { started: true, reason: STARTUP_REASON.STARTED, parseError: null };
201
+ }
30
202
  if (next?.type === "VariableDeclaration" && next.kind === "const" &&
31
- next.declarations.length === 1 && directCall(next.declarations[0].init, binding)) return true;
203
+ next.declarations.length === 1 && directCall(next.declarations[0].init, binding)) {
204
+ return { started: true, reason: STARTUP_REASON.STARTED, parseError: null };
205
+ }
32
206
  }
33
- return false;
207
+ return { started: false, reason, parseError: null };
34
208
  }
package/themehost.mjs CHANGED
@@ -2,7 +2,7 @@
2
2
  import { readFileSync, existsSync } from "node:fs";
3
3
  import { join, resolve, relative, sep } from "node:path";
4
4
  import { htmlElements } from "./htmlscan.mjs";
5
- import { hasThemeStartup } from "./theme-entry.mjs";
5
+ import { themeStartup, STARTUP_REASON } from "./theme-entry.mjs";
6
6
 
7
7
  function within(root, path) {
8
8
  if (typeof path !== "string" || !path || path.startsWith("/")) return null;
@@ -24,14 +24,43 @@ function read(root, path) {
24
24
  */
25
25
  export function checkThemeHosts(root, design = {}, { packages = null } = {}) {
26
26
  const declared = design.themeHosts;
27
- if (declared === undefined) return { checked: 0, errors: [] };
28
- if (!Array.isArray(declared)) return { checked: 0, errors: ["design.themeHosts must be an array"] };
27
+ if (declared === undefined) return { declared: 0, checked: 0, errors: [] };
28
+ if (!Array.isArray(declared)) return { declared: 0, checked: 0, errors: ["design.themeHosts must be an array"] };
29
29
  const errors = [];
30
+ /**
31
+ * `declared` and `checked` are two different numbers and used to be one
32
+ * (G-141 follow-up). The config-gap return below reported
33
+ * `checked: declared.length` from a path that inspects nothing — a count
34
+ * claiming work it did not do, which is the same defect class as the verdict
35
+ * that claimed an answer to a question nobody asked. CHARTER §5: "Gyde did
36
+ * not run" and "Gyde found nothing" must never render the same, and a single
37
+ * number cannot tell them apart.
38
+ *
39
+ * So this one is COUNTED as hosts are inspected rather than restated from
40
+ * the input. A count derived from `declared.length` is an assertion about
41
+ * the loop; a count the loop increments is a measurement of it, and only the
42
+ * second goes wrong when the loop stops running.
43
+ */
44
+ let checked = 0;
30
45
  const systemPath = design.systemPath || "packages/design-system";
31
- const systemPackage = design.systemPackage || `${design.scope}/design-system`;
46
+ // `${undefined}/design-system` is a STRING, so an undeclared scope used to
47
+ // produce the specifier "undefined/design-system", match no import, and be
48
+ // reported as a consumer's broken wiring (G-141, same shape as the arity bug
49
+ // below). Say which key is missing instead.
50
+ const named = (value) => (typeof value === "string" && value !== "" ? value : null);
51
+ const systemPackage = named(design.systemPackage) ??
52
+ (named(design.scope) ? `${design.scope}/design-system` : null);
53
+ if (systemPackage === null) {
54
+ return {
55
+ declared: declared.length,
56
+ checked: 0,
57
+ errors: ["design.themeHosts is declared, but neither design.systemPackage nor design.scope names the design-system package the entry must import"],
58
+ };
59
+ }
32
60
  const expected = read(root, `${systemPath}/src/theme-bootstrap.js`);
33
61
  for (const [index, host] of declared.entries()) {
34
62
  const label = `design.themeHosts[${index}]`;
63
+ checked += 1;
35
64
  if (!host || typeof host !== "object" || host.adapter !== "html-inline") {
36
65
  errors.push(`${label}: unsupported adapter; this gate currently supports html-inline`);
37
66
  continue;
@@ -71,15 +100,38 @@ export function checkThemeHosts(root, design = {}, { packages = null } = {}) {
71
100
  const moduleTag = elements.some((n) => n.name === "script" &&
72
101
  n.attrs.get("type")?.toLowerCase() === "module" && n.attrs.get("src") === src);
73
102
  if (!moduleTag) errors.push(`${label}: HTML must load the declared entry as a module script`);
74
- if (!hasThemeStartup(entry, systemPackage)) {
75
- errors.push(`${label}: linked entry must import and immediately call startThemeChoice at module top level`);
103
+ // A file the parser never finished reading has not failed the wiring
104
+ // contract; it has failed to be read. Saying otherwise sends the reader to
105
+ // rearrange imports the parser never reached (G-134).
106
+ //
107
+ // And one message for "not wired" was a false statement about two of the
108
+ // three ways an entry can be unwired (G-141): a file with no import at all
109
+ // was told its call was misplaced. Each reason gets the sentence that is
110
+ // true of it, or the reader is sent to fix something that is not wrong.
111
+ const startup = themeStartup(entry, systemPackage);
112
+ if (startup.reason === STARTUP_REASON.PARSE_ERROR) {
113
+ const { message, line, column } = startup.parseError;
114
+ const at = line === null ? "" : ` at line ${line}, column ${column}`;
115
+ errors.push(`${label}: declared module entry ${host.entry} could not be parsed${at} — ${message}`);
116
+ } else if (startup.reason === STARTUP_REASON.NO_IMPORT) {
117
+ errors.push(`${label}: linked entry ${host.entry} has no import of startThemeChoice from ${systemPackage}/theme-choice`);
118
+ } else if (startup.reason === STARTUP_REASON.TYPE_ONLY_IMPORT) {
119
+ errors.push(`${label}: linked entry ${host.entry} imports startThemeChoice as a TYPE, which is erased before the module runs — import it as a value and call it at module top level`);
120
+ } else if (startup.reason === STARTUP_REASON.CALL_NOT_ADJACENT) {
121
+ errors.push(`${label}: linked entry ${host.entry} imports startThemeChoice but must call it immediately, at module top level`);
76
122
  }
77
123
  }
78
- return { checked: declared.length, errors };
124
+ return { declared: declared.length, checked, errors };
79
125
  }
80
126
 
127
+ /**
128
+ * Both numbers are printed, always. The line used to render `checked` under
129
+ * the word "declared", so one number stood for two claims and the reader could
130
+ * not see a run that declared hosts and inspected none of them.
131
+ */
81
132
  export function formatThemeHosts(result) {
133
+ const counts = `${result.declared} declared, ${result.checked} checked`;
82
134
  return result.errors.length
83
- ? `theme hosts ${result.checked} declared, ${result.errors.length} error(s):\n${result.errors.map((e) => ` ${e}`).join("\n")}`
84
- : `theme hosts ${result.checked} declared, checked`;
135
+ ? `theme hosts ${counts}, ${result.errors.length} error(s):\n${result.errors.map((e) => ` ${e}`).join("\n")}`
136
+ : `theme hosts ${counts}`;
85
137
  }
package/vendor/README.md CHANGED
@@ -1,9 +1,15 @@
1
1
  # Vendored third-party source
2
2
 
3
- Files here are **copied verbatim from an npm package** and imported by relative
4
- path. They are not edited, ever. `selfcontained.test.mjs` asserts each one is
5
- byte-identical to the installed package it came from, so a hand edit or a stale
6
- copy is a failing gate rather than a divergence nobody can see.
3
+ Files here are **copied from an npm package** and imported by relative path.
4
+ They are not edited by hand, ever. `selfcontained.test.mjs` computes each one's
5
+ expected bytes from the installed package it came from, so a hand edit, a stale
6
+ copy and an upgraded package are all the same failing gate rather than a
7
+ divergence nobody can see.
8
+
9
+ One file is copied with a single mechanical substitution rather than verbatim —
10
+ see "When a vendored file imports its own peer" below. The substitution is part
11
+ of that assertion, applied to the installed source, so it can never check a copy
12
+ against itself and a substitution that stops matching fails by name.
7
13
 
8
14
  ## Why anything is vendored at all
9
15
 
@@ -35,9 +41,55 @@ branch is not startup wiring, and that claim is only as good as the parser. It
35
41
  ships `dist/acorn.mjs` as a **single self-contained ESM file with no
36
42
  dependencies of its own**, so carrying it is one file and one equality check.
37
43
 
38
- | file | package | from |
39
- | --- | --- | --- |
40
- | `acorn.mjs` | `acorn` | `node_modules/acorn/dist/acorn.mjs` |
44
+ | file | package | from | copied |
45
+ | --- | --- | --- | --- |
46
+ | `acorn.mjs` | `acorn` | `node_modules/acorn/dist/acorn.mjs` | verbatim |
47
+ | `acorn-typescript.mjs` | `acorn-typescript` | `node_modules/acorn-typescript/lib/index.mjs` | `from"acorn"` → `from"./acorn.mjs"`, twice |
48
+
49
+ ## Why acorn-typescript
50
+
51
+ The theme-host gate reads an application's entry module, and in practice that
52
+ file is `main.tsx`. Plain acorn cannot parse one — it stops at the first `<`,
53
+ and the canonical Vite React entry stops earlier still, at the `!` in
54
+ `document.getElementById('root')!`. Measured against 0.4.3 on a real consumer:
55
+ `Unexpected token (21:2)`, a `<StrictMode>` element. So a React repository's
56
+ host entry could never satisfy the gate at all (G-134).
57
+
58
+ The alternative to a TypeScript parser is hand-rolling one, which is what the
59
+ acorn paragraph above rules out for the same reason: the gate's claim is that a
60
+ call inside a string, a template, a regex or a dead branch is not startup
61
+ wiring, and TypeScript and JSX do not make that claim easier to keep.
62
+
63
+ It earns its place on the same test acorn passed. `lib/index.mjs` is a single
64
+ self-contained bundle of 104kB with **no dependency tree** — its devDependencies
65
+ are a build's, and its only `peerDependency` is acorn, which is already here.
66
+
67
+ ## When a vendored file imports its own peer
68
+
69
+ `acorn-typescript` is a plugin, so its bundle opens with two import statements
70
+ naming **`acorn`** — a bare specifier, which is precisely what the action may
71
+ not do. The package it names is the file sitting next to it.
72
+
73
+ Three ways to resolve that were measured, and two of them do not work:
74
+
75
+ - **A `vendor/node_modules/acorn` shim** whose `package.json` points `main` at
76
+ `../../acorn.mjs`. Resolution works and there is no second copy — but `.gitignore`
77
+ excludes `node_modules/` from the repository, so the action checkout never
78
+ carries it. That is the decisive reason on its own, and it is the one to
79
+ rely on: `npm pack` has no blanket rule about `node_modules`, and a `files`
80
+ glob covering such a directory was measured shipping
81
+ `package/vendor/node_modules/acorn/package.json`. Today's globs happen not to
82
+ match it — `vendor/*.mjs` is one level deep — which is a coincidence of this
83
+ file rather than a guarantee. The shim would fix the action and break the
84
+ published package: one artefact working and the other not is the exact shape
85
+ of G-138.
86
+ - **A second copy of `acorn.mjs`** inside such a directory. Two copies of a
87
+ 230kB file that must not diverge, to avoid rewriting eleven characters.
88
+ - **Rewriting the specifier**, which is what is done. Two occurrences, both
89
+ import statements in the bundle's leading prologue, `from"acorn"` becoming
90
+ `from"./acorn.mjs"`. Nothing else in the file is touched, and the count is
91
+ asserted: if a future version has a different number of them, the copy is
92
+ refused rather than silently under-substituted.
41
93
 
42
94
  To update: change the version in the root `package.json`, `npm install`, copy
43
95
  the file across, and run `npm run verify`.
@@ -0,0 +1 @@
1
+ import*as t from"./acorn.mjs";import{tokTypes as e,TokContext as s,TokenType as i,keywordTypes as r}from"./acorn.mjs";function a(t,e){for(var s=0;s<e.length;s++){var i=e[s];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,"symbol"==typeof(r=function(t,e){if("object"!=typeof t||null===t)return t;var s=t[Symbol.toPrimitive];if(void 0!==s){var i=s.call(t,"string");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(i.key))?r:String(r),i)}var r}function n(){return n=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var s=arguments[e];for(var i in s)Object.prototype.hasOwnProperty.call(s,i)&&(t[i]=s[i])}return t},n.apply(this,arguments)}function o(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,h(t,e)}function h(t,e){return h=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},h(t,e)}function p(t,e){(null==e||e>t.length)&&(e=t.length);for(var s=0,i=new Array(e);s<e;s++)i[s]=t[s];return i}function c(t,e){var s="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(s)return(s=s.call(t)).next.bind(s);if(Array.isArray(t)||(s=function(t,e){if(t){if("string"==typeof t)return p(t,e);var s=Object.prototype.toString.call(t).slice(8,-1);return"Object"===s&&t.constructor&&(s=t.constructor.name),"Map"===s||"Set"===s?Array.from(t):"Arguments"===s||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(s)?p(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){s&&(t=s);var i=0;return function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var l=!0;function u(t,e){return void 0===e&&(e={}),new i("name",e)}var d=new WeakMap;function m(t){var a=d.get(t.Parser.acorn||t);if(!a){var o={assert:u(0,{startsExpr:l}),asserts:u(0,{startsExpr:l}),global:u(0,{startsExpr:l}),keyof:u(0,{startsExpr:l}),readonly:u(0,{startsExpr:l}),unique:u(0,{startsExpr:l}),abstract:u(0,{startsExpr:l}),declare:u(0,{startsExpr:l}),enum:u(0,{startsExpr:l}),module:u(0,{startsExpr:l}),namespace:u(0,{startsExpr:l}),interface:u(0,{startsExpr:l}),type:u(0,{startsExpr:l})},h={at:new i("@"),jsxName:new i("jsxName"),jsxText:new i("jsxText",{beforeExpr:!0}),jsxTagStart:new i("jsxTagStart",{startsExpr:!0}),jsxTagEnd:new i("jsxTagEnd")},p={tc_oTag:new s("<tag",!1,!1),tc_cTag:new s("</tag",!1,!1),tc_expr:new s("<tag>...</tag>",!0,!0)},c=new RegExp("^(?:"+Object.keys(o).join("|")+")$");h.jsxTagStart.updateContext=function(){this.context.push(p.tc_expr),this.context.push(p.tc_oTag),this.exprAllowed=!1},h.jsxTagEnd.updateContext=function(t){var s=this.context.pop();s===p.tc_oTag&&t===e.slash||s===p.tc_cTag?(this.context.pop(),this.exprAllowed=this.curContext()===p.tc_expr):this.exprAllowed=!0},a={tokTypes:n({},o,h),tokContexts:n({},p),keywordsRegExp:c,tokenIsLiteralPropertyName:function(t){return[e.name,e.string,e.num].concat(Object.values(r),Object.values(o)).includes(t)},tokenIsKeywordOrIdentifier:function(t){return[e.name].concat(Object.values(r),Object.values(o)).includes(t)},tokenIsIdentifier:function(t){return[].concat(Object.values(o),[e.name]).includes(t)},tokenIsTSDeclarationStart:function(t){return[o.abstract,o.declare,o.enum,o.module,o.namespace,o.interface,o.type].includes(t)},tokenIsTSTypeOperator:function(t){return[o.keyof,o.readonly,o.unique].includes(t)},tokenIsTemplate:function(t){return t===e.invalidTemplate}}}return a}var f=1024,y=new RegExp("(?:[^\\S\\n\\r\\u2028\\u2029]|\\/\\/.*|\\/\\*.*?\\*\\/)*","y"),x=new RegExp("(?=("+y.source+"))\\1"+/(?=[\n\r\u2028\u2029]|\/\*(?!.*?\*\/)|$)/.source,"y"),T=function(){this.shorthandAssign=void 0,this.trailingComma=void 0,this.parenthesizedAssign=void 0,this.parenthesizedBind=void 0,this.doubleProto=void 0,this.shorthandAssign=this.trailingComma=this.parenthesizedAssign=this.parenthesizedBind=this.doubleProto=-1};function v(t,e){var s=e.key.name,i=t[s],r="true";return"MethodDefinition"!==e.type||"get"!==e.kind&&"set"!==e.kind||(r=(e.static?"s":"i")+e.kind),"iget"===i&&"iset"===r||"iset"===i&&"iget"===r||"sget"===i&&"sset"===r||"sset"===i&&"sget"===r?(t[s]="true",!1):!!i||(t[s]=r,!1)}function P(t,e){var s=t.key;return!t.computed&&("Identifier"===s.type&&s.name===e||"Literal"===s.type&&s.value===e)}var b={AbstractMethodHasImplementation:function(t){return"Method '"+t.methodName+"' cannot have an implementation because it is marked abstract."},AbstractPropertyHasInitializer:function(t){return"Property '"+t.propertyName+"' cannot have an initializer because it is marked abstract."},AccesorCannotDeclareThisParameter:"'get' and 'set' accessors cannot declare 'this' parameters.",AccesorCannotHaveTypeParameters:"An accessor cannot have type parameters.",CannotFindName:function(t){return"Cannot find name '"+t.name+"'."},ClassMethodHasDeclare:"Class methods cannot have the 'declare' modifier.",ClassMethodHasReadonly:"Class methods cannot have the 'readonly' modifier.",ConstInitiailizerMustBeStringOrNumericLiteralOrLiteralEnumReference:"A 'const' initializer in an ambient context must be a string or numeric literal or literal enum reference.",ConstructorHasTypeParameters:"Type parameters cannot appear on a constructor declaration.",DeclareAccessor:function(t){return"'declare' is not allowed in "+t.kind+"ters."},DeclareClassFieldHasInitializer:"Initializers are not allowed in ambient contexts.",DeclareFunctionHasImplementation:"An implementation cannot be declared in ambient contexts.",DuplicateAccessibilityModifier:function(){return"Accessibility modifier already seen."},DuplicateModifier:function(t){return"Duplicate modifier: '"+t.modifier+"'."},EmptyHeritageClauseType:function(t){return"'"+t.token+"' list cannot be empty."},EmptyTypeArguments:"Type argument list cannot be empty.",EmptyTypeParameters:"Type parameter list cannot be empty.",ExpectedAmbientAfterExportDeclare:"'export declare' must be followed by an ambient declaration.",ImportAliasHasImportType:"An import alias can not use 'import type'.",IncompatibleModifiers:function(t){var e=t.modifiers;return"'"+e[0]+"' modifier cannot be used with '"+e[1]+"' modifier."},IndexSignatureHasAbstract:"Index signatures cannot have the 'abstract' modifier.",IndexSignatureHasAccessibility:function(t){return"Index signatures cannot have an accessibility modifier ('"+t.modifier+"')."},IndexSignatureHasDeclare:"Index signatures cannot have the 'declare' modifier.",IndexSignatureHasOverride:"'override' modifier cannot appear on an index signature.",IndexSignatureHasStatic:"Index signatures cannot have the 'static' modifier.",InitializerNotAllowedInAmbientContext:"Initializers are not allowed in ambient contexts.",InvalidModifierOnTypeMember:function(t){return"'"+t.modifier+"' modifier cannot appear on a type member."},InvalidModifierOnTypeParameter:function(t){return"'"+t.modifier+"' modifier cannot appear on a type parameter."},InvalidModifierOnTypeParameterPositions:function(t){return"'"+t.modifier+"' modifier can only appear on a type parameter of a class, interface or type alias."},InvalidModifiersOrder:function(t){var e=t.orderedModifiers;return"'"+e[0]+"' modifier must precede '"+e[1]+"' modifier."},InvalidPropertyAccessAfterInstantiationExpression:"Invalid property access after an instantiation expression. You can either wrap the instantiation expression in parentheses, or delete the type arguments.",InvalidTupleMemberLabel:"Tuple members must be labeled with a simple identifier.",MissingInterfaceName:"'interface' declarations must be followed by an identifier.",MixedLabeledAndUnlabeledElements:"Tuple members must all have names or all not have names.",NonAbstractClassHasAbstractMethod:"Abstract methods can only appear within an abstract class.",NonClassMethodPropertyHasAbstractModifer:"'abstract' modifier can only appear on a class, method, or property declaration.",OptionalTypeBeforeRequired:"A required element cannot follow an optional element.",OverrideNotInSubClass:"This member cannot have an 'override' modifier because its containing class does not extend another class.",PatternIsOptional:"A binding pattern parameter cannot be optional in an implementation signature.",PrivateElementHasAbstract:"Private elements cannot have the 'abstract' modifier.",PrivateElementHasAccessibility:function(t){return"Private elements cannot have an accessibility modifier ('"+t.modifier+"')."},PrivateMethodsHasAccessibility:function(t){return"Private methods cannot have an accessibility modifier ('"+t.modifier+"')."},ReadonlyForMethodSignature:"'readonly' modifier can only appear on a property declaration or index signature.",ReservedArrowTypeParam:"This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma, as in `<T,>() => ...`.",ReservedTypeAssertion:"This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.",SetAccesorCannotHaveOptionalParameter:"A 'set' accessor cannot have an optional parameter.",SetAccesorCannotHaveRestParameter:"A 'set' accessor cannot have rest parameter.",SetAccesorCannotHaveReturnType:"A 'set' accessor cannot have a return type annotation.",SingleTypeParameterWithoutTrailingComma:function(t){var e=t.typeParameterName;return"Single type parameter "+e+" should have a trailing comma. Example usage: <"+e+",>."},StaticBlockCannotHaveModifier:"Static class blocks cannot have any modifier.",TypeAnnotationAfterAssign:"Type annotations must come before default assignments, e.g. instead of `age = 25: number` use `age: number = 25`.",TypeImportCannotSpecifyDefaultAndNamed:"A type-only import can specify a default import or named bindings, but not both.",TypeModifierIsUsedInTypeExports:"The 'type' modifier cannot be used on a named export when 'export type' is used on its export statement.",TypeModifierIsUsedInTypeImports:"The 'type' modifier cannot be used on a named import when 'import type' is used on its import statement.",UnexpectedParameterModifier:"A parameter property is only allowed in a constructor implementation.",UnexpectedReadonly:"'readonly' type modifier is only permitted on array and tuple literal types.",GenericsEndWithComma:"Trailing comma is not allowed at the end of generics.",UnexpectedTypeAnnotation:"Did not expect a type annotation here.",UnexpectedTypeCastInParameter:"Unexpected type cast in parameter position.",UnsupportedImportTypeArgument:"Argument in a type import must be a string literal.",UnsupportedParameterPropertyKind:"A parameter property may not be declared using a binding pattern.",UnsupportedSignatureParameterKind:function(t){return"Name in a signature must be an Identifier, ObjectPattern or ArrayPattern, instead got "+t.type+"."},LetInLexicalBinding:"'let' is not allowed to be used as a name in 'let' or 'const' declarations."},g={quot:'"',amp:"&",apos:"'",lt:"<",gt:">",nbsp:" ",iexcl:"¡",cent:"¢",pound:"£",curren:"¤",yen:"¥",brvbar:"¦",sect:"§",uml:"¨",copy:"©",ordf:"ª",laquo:"«",not:"¬",shy:"­",reg:"®",macr:"¯",deg:"°",plusmn:"±",sup2:"²",sup3:"³",acute:"´",micro:"µ",para:"¶",middot:"·",cedil:"¸",sup1:"¹",ordm:"º",raquo:"»",frac14:"¼",frac12:"½",frac34:"¾",iquest:"¿",Agrave:"À",Aacute:"Á",Acirc:"Â",Atilde:"Ã",Auml:"Ä",Aring:"Å",AElig:"Æ",Ccedil:"Ç",Egrave:"È",Eacute:"É",Ecirc:"Ê",Euml:"Ë",Igrave:"Ì",Iacute:"Í",Icirc:"Î",Iuml:"Ï",ETH:"Ð",Ntilde:"Ñ",Ograve:"Ò",Oacute:"Ó",Ocirc:"Ô",Otilde:"Õ",Ouml:"Ö",times:"×",Oslash:"Ø",Ugrave:"Ù",Uacute:"Ú",Ucirc:"Û",Uuml:"Ü",Yacute:"Ý",THORN:"Þ",szlig:"ß",agrave:"à",aacute:"á",acirc:"â",atilde:"ã",auml:"ä",aring:"å",aelig:"æ",ccedil:"ç",egrave:"è",eacute:"é",ecirc:"ê",euml:"ë",igrave:"ì",iacute:"í",icirc:"î",iuml:"ï",eth:"ð",ntilde:"ñ",ograve:"ò",oacute:"ó",ocirc:"ô",otilde:"õ",ouml:"ö",divide:"÷",oslash:"ø",ugrave:"ù",uacute:"ú",ucirc:"û",uuml:"ü",yacute:"ý",thorn:"þ",yuml:"ÿ",OElig:"Œ",oelig:"œ",Scaron:"Š",scaron:"š",Yuml:"Ÿ",fnof:"ƒ",circ:"ˆ",tilde:"˜",Alpha:"Α",Beta:"Β",Gamma:"Γ",Delta:"Δ",Epsilon:"Ε",Zeta:"Ζ",Eta:"Η",Theta:"Θ",Iota:"Ι",Kappa:"Κ",Lambda:"Λ",Mu:"Μ",Nu:"Ν",Xi:"Ξ",Omicron:"Ο",Pi:"Π",Rho:"Ρ",Sigma:"Σ",Tau:"Τ",Upsilon:"Υ",Phi:"Φ",Chi:"Χ",Psi:"Ψ",Omega:"Ω",alpha:"α",beta:"β",gamma:"γ",delta:"δ",epsilon:"ε",zeta:"ζ",eta:"η",theta:"θ",iota:"ι",kappa:"κ",lambda:"λ",mu:"μ",nu:"ν",xi:"ξ",omicron:"ο",pi:"π",rho:"ρ",sigmaf:"ς",sigma:"σ",tau:"τ",upsilon:"υ",phi:"φ",chi:"χ",psi:"ψ",omega:"ω",thetasym:"ϑ",upsih:"ϒ",piv:"ϖ",ensp:" ",emsp:" ",thinsp:" ",zwnj:"‌",zwj:"‍",lrm:"‎",rlm:"‏",ndash:"–",mdash:"—",lsquo:"‘",rsquo:"’",sbquo:"‚",ldquo:"“",rdquo:"”",bdquo:"„",dagger:"†",Dagger:"‡",bull:"•",hellip:"…",permil:"‰",prime:"′",Prime:"″",lsaquo:"‹",rsaquo:"›",oline:"‾",frasl:"⁄",euro:"€",image:"ℑ",weierp:"℘",real:"ℜ",trade:"™",alefsym:"ℵ",larr:"←",uarr:"↑",rarr:"→",darr:"↓",harr:"↔",crarr:"↵",lArr:"⇐",uArr:"⇑",rArr:"⇒",dArr:"⇓",hArr:"⇔",forall:"∀",part:"∂",exist:"∃",empty:"∅",nabla:"∇",isin:"∈",notin:"∉",ni:"∋",prod:"∏",sum:"∑",minus:"−",lowast:"∗",radic:"√",prop:"∝",infin:"∞",ang:"∠",and:"∧",or:"∨",cap:"∩",cup:"∪",int:"∫",there4:"∴",sim:"∼",cong:"≅",asymp:"≈",ne:"≠",equiv:"≡",le:"≤",ge:"≥",sub:"⊂",sup:"⊃",nsub:"⊄",sube:"⊆",supe:"⊇",oplus:"⊕",otimes:"⊗",perp:"⊥",sdot:"⋅",lceil:"⌈",rceil:"⌉",lfloor:"⌊",rfloor:"⌋",lang:"〈",rang:"〉",loz:"◊",spades:"♠",clubs:"♣",hearts:"♥",diams:"♦"},A=/^[\da-fA-F]+$/,S=/^\d+$/;function C(t){return t?"JSXIdentifier"===t.type?t.name:"JSXNamespacedName"===t.type?t.namespace.name+":"+t.name.name:"JSXMemberExpression"===t.type?C(t.object)+"."+C(t.property):void 0:t}var E=/(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g;function k(t){if(!t)throw new Error("Assert fail")}function I(t){return"accessor"===t}function N(t){return"in"===t||"out"===t}function w(t,e){return 2|(t?4:0)|(e?8:0)}function L(t){if("MemberExpression"!==t.type)return!1;var e=t.property;return(!t.computed||!("TemplateLiteral"!==e.type||e.expressions.length>0))&&M(t.object)}function M(t){return"Identifier"===t.type||"MemberExpression"===t.type&&!t.computed&&M(t.object)}function O(t){return"private"===t||"public"===t||"protected"===t}function D(e){var s=e||{},i=s.dts,r=void 0!==i&&i,n=s.allowSatisfies,h=void 0!==n&&n;return function(s){var i=s.acorn||t,n=m(i),p=i.tokTypes,l=i.keywordTypes,u=i.isIdentifierStart,d=i.lineBreak,y=i.isNewLine,M=i.tokContexts,D=i.isIdentifierChar,_=n.tokTypes,R=n.tokContexts,j=n.keywordsRegExp,F=n.tokenIsLiteralPropertyName,B=n.tokenIsTemplate,H=n.tokenIsTSDeclarationStart,q=n.tokenIsIdentifier,U=n.tokenIsKeywordOrIdentifier,V=n.tokenIsTSTypeOperator;function K(t,e,s){void 0===s&&(s=t.length);for(var i=e;i<s;i++){var r=t.charCodeAt(i);if(y(r))return i<s-1&&13===r&&10===t.charCodeAt(i+1)?i+2:i+1}return-1}s=function(t,e,s){var i=s.tokTypes,r=e.tokTypes;/*#__PURE__*/return function(t){function e(){return t.apply(this,arguments)||this}o(e,t);var s=e.prototype;return s.takeDecorators=function(t){var e=this.decoratorStack[this.decoratorStack.length-1];e.length&&(t.decorators=e,this.resetStartLocationFromNode(t,e[0]),this.decoratorStack[this.decoratorStack.length-1]=[])},s.parseDecorators=function(t){for(var e=this.decoratorStack[this.decoratorStack.length-1];this.match(r.at);){var s=this.parseDecorator();e.push(s)}this.match(i._export)?t||this.unexpected():this.canHaveLeadingDecorator()||this.raise(this.start,"Leading decorators must be attached to a class declaration.")},s.parseDecorator=function(){var t=this.startNode();this.next(),this.decoratorStack.push([]);var e,s=this.start,r=this.startLoc;if(this.match(i.parenL)){var a=this.start,n=this.startLoc;if(this.next(),e=this.parseExpression(),this.expect(i.parenR),this.options.preserveParens){var o=this.startNodeAt(a,n);o.expression=e,e=this.finishNode(o,"ParenthesizedExpression")}}else for(e=this.parseIdent(!1);this.eat(i.dot);){var h=this.startNodeAt(s,r);h.object=e,h.property=this.parseIdent(!0),h.computed=!1,e=this.finishNode(h,"MemberExpression")}return t.expression=this.parseMaybeDecoratorArguments(e),this.decoratorStack.pop(),this.finishNode(t,"Decorator")},s.parseMaybeDecoratorArguments=function(t){if(this.eat(i.parenL)){var e=this.startNodeAtNode(t);return e.callee=t,e.arguments=this.parseExprList(i.parenR,!1),this.finishNode(e,"CallExpression")}return t},e}(t)}(s,n,i),s=function(t,e,s,i){var r=t.tokTypes,a=e.tokTypes,n=t.isNewLine,h=t.isIdentifierChar,p=Object.assign({allowNamespaces:!0,allowNamespacedObjects:!0},i||{});/*#__PURE__*/return function(t){function e(){return t.apply(this,arguments)||this}o(e,t);var s=e.prototype;return s.jsx_readToken=function(){for(var t="",e=this.pos;;){this.pos>=this.input.length&&this.raise(this.start,"Unterminated JSX contents");var s=this.input.charCodeAt(this.pos);switch(s){case 60:case 123:return this.pos===this.start?60===s&&this.exprAllowed?(++this.pos,this.finishToken(a.jsxTagStart)):this.getTokenFromCode(s):(t+=this.input.slice(e,this.pos),this.finishToken(a.jsxText,t));case 38:t+=this.input.slice(e,this.pos),t+=this.jsx_readEntity(),e=this.pos;break;case 62:case 125:this.raise(this.pos,"Unexpected token `"+this.input[this.pos]+"`. Did you mean `"+(62===s?"&gt;":"&rbrace;")+'` or `{"'+this.input[this.pos]+'"}`?');default:n(s)?(t+=this.input.slice(e,this.pos),t+=this.jsx_readNewLine(!0),e=this.pos):++this.pos}}},s.jsx_readNewLine=function(t){var e,s=this.input.charCodeAt(this.pos);return++this.pos,13===s&&10===this.input.charCodeAt(this.pos)?(++this.pos,e=t?"\n":"\r\n"):e=String.fromCharCode(s),this.options.locations&&(++this.curLine,this.lineStart=this.pos),e},s.jsx_readString=function(t){for(var e="",s=++this.pos;;){this.pos>=this.input.length&&this.raise(this.start,"Unterminated string constant");var i=this.input.charCodeAt(this.pos);if(i===t)break;38===i?(e+=this.input.slice(s,this.pos),e+=this.jsx_readEntity(),s=this.pos):n(i)?(e+=this.input.slice(s,this.pos),e+=this.jsx_readNewLine(!1),s=this.pos):++this.pos}return e+=this.input.slice(s,this.pos++),this.finishToken(r.string,e)},s.jsx_readEntity=function(){var t,e="",s=0,i=this.input[this.pos];"&"!==i&&this.raise(this.pos,"Entity must start with an ampersand");for(var r=++this.pos;this.pos<this.input.length&&s++<10;){if(";"===(i=this.input[this.pos++])){"#"===e[0]?"x"===e[1]?(e=e.substr(2),A.test(e)&&(t=String.fromCharCode(parseInt(e,16)))):(e=e.substr(1),S.test(e)&&(t=String.fromCharCode(parseInt(e,10)))):t=g[e];break}e+=i}return t||(this.pos=r,"&")},s.jsx_readWord=function(){var t,e=this.pos;do{t=this.input.charCodeAt(++this.pos)}while(h(t)||45===t);return this.finishToken(a.jsxName,this.input.slice(e,this.pos))},s.jsx_parseIdentifier=function(){var t=this.startNode();return this.type===a.jsxName?t.name=this.value:this.type.keyword?t.name=this.type.keyword:this.unexpected(),this.next(),this.finishNode(t,"JSXIdentifier")},s.jsx_parseNamespacedName=function(){var t=this.start,e=this.startLoc,s=this.jsx_parseIdentifier();if(!p.allowNamespaces||!this.eat(r.colon))return s;var i=this.startNodeAt(t,e);return i.namespace=s,i.name=this.jsx_parseIdentifier(),this.finishNode(i,"JSXNamespacedName")},s.jsx_parseElementName=function(){if(this.type===a.jsxTagEnd)return"";var t=this.start,e=this.startLoc,s=this.jsx_parseNamespacedName();for(this.type!==r.dot||"JSXNamespacedName"!==s.type||p.allowNamespacedObjects||this.unexpected();this.eat(r.dot);){var i=this.startNodeAt(t,e);i.object=s,i.property=this.jsx_parseIdentifier(),s=this.finishNode(i,"JSXMemberExpression")}return s},s.jsx_parseAttributeValue=function(){switch(this.type){case r.braceL:var t=this.jsx_parseExpressionContainer();return"JSXEmptyExpression"===t.expression.type&&this.raise(t.start,"JSX attributes must only be assigned a non-empty expression"),t;case a.jsxTagStart:case r.string:return this.parseExprAtom();default:this.raise(this.start,"JSX value should be either an expression or a quoted JSX text")}},s.jsx_parseEmptyExpression=function(){var t=this.startNodeAt(this.lastTokEnd,this.lastTokEndLoc);return this.finishNodeAt(t,"JSXEmptyExpression",this.start,this.startLoc)},s.jsx_parseExpressionContainer=function(){var t=this.startNode();return this.next(),t.expression=this.type===r.braceR?this.jsx_parseEmptyExpression():this.parseExpression(),this.expect(r.braceR),this.finishNode(t,"JSXExpressionContainer")},s.jsx_parseAttribute=function(){var t=this.startNode();return this.eat(r.braceL)?(this.expect(r.ellipsis),t.argument=this.parseMaybeAssign(),this.expect(r.braceR),this.finishNode(t,"JSXSpreadAttribute")):(t.name=this.jsx_parseNamespacedName(),t.value=this.eat(r.eq)?this.jsx_parseAttributeValue():null,this.finishNode(t,"JSXAttribute"))},s.jsx_parseOpeningElementAt=function(t,e){var s=this.startNodeAt(t,e);s.attributes=[];var i=this.jsx_parseElementName();for(i&&(s.name=i);this.type!==r.slash&&this.type!==a.jsxTagEnd;)s.attributes.push(this.jsx_parseAttribute());return s.selfClosing=this.eat(r.slash),this.expect(a.jsxTagEnd),this.finishNode(s,i?"JSXOpeningElement":"JSXOpeningFragment")},s.jsx_parseClosingElementAt=function(t,e){var s=this.startNodeAt(t,e),i=this.jsx_parseElementName();return i&&(s.name=i),this.expect(a.jsxTagEnd),this.finishNode(s,i?"JSXClosingElement":"JSXClosingFragment")},s.jsx_parseElementAt=function(t,e){var s=this.startNodeAt(t,e),i=[],n=this.jsx_parseOpeningElementAt(t,e),o=null;if(!n.selfClosing){t:for(;;)switch(this.type){case a.jsxTagStart:if(t=this.start,e=this.startLoc,this.next(),this.eat(r.slash)){o=this.jsx_parseClosingElementAt(t,e);break t}i.push(this.jsx_parseElementAt(t,e));break;case a.jsxText:i.push(this.parseExprAtom());break;case r.braceL:i.push(this.jsx_parseExpressionContainer());break;default:this.unexpected()}C(o.name)!==C(n.name)&&this.raise(o.start,"Expected corresponding JSX closing tag for <"+C(n.name)+">")}var h=n.name?"Element":"Fragment";return s["opening"+h]=n,s["closing"+h]=o,s.children=i,this.type===r.relational&&"<"===this.value&&this.raise(this.start,"Adjacent JSX elements must be wrapped in an enclosing tag"),this.finishNode(s,"JSX"+h)},s.jsx_parseText=function(){var t=this.parseLiteral(this.value);return t.type="JSXText",t},s.jsx_parseElement=function(){var t=this.start,e=this.startLoc;return this.next(),this.jsx_parseElementAt(t,e)},e}(s)}(i,n,s,null==e?void 0:e.jsx),s=function(t,e,s){var i=e.tokTypes,r=s.tokTypes;/*#__PURE__*/return function(t){function e(){return t.apply(this,arguments)||this}o(e,t);var s=e.prototype;return s.parseMaybeImportAttributes=function(t){if(this.type===r._with||this.type===i.assert){this.next();var e=this.parseImportAttributes();e&&(t.attributes=e)}},s.parseImportAttributes=function(){this.expect(r.braceL);var t=this.parseWithEntries();return this.expect(r.braceR),t},s.parseWithEntries=function(){var t=[],e=new Set;do{if(this.type===r.braceR)break;var s,i=this.startNode();s=this.type===r.string?this.parseLiteral(this.value):this.parseIdent(!0),this.next(),i.key=s,e.has(i.key.name)&&this.raise(this.pos,"Duplicated key in attributes"),e.add(i.key.name),this.type!==r.string&&this.raise(this.pos,"Only string is supported as an attribute value"),i.value=this.parseLiteral(this.value),t.push(this.finishNode(i,"ImportAttribute"))}while(this.eat(r.comma));return t},e}(t)}(s,n,i);var z=/*#__PURE__*/function(t){function e(e,s,i){var r;return(r=t.call(this,e,s,i)||this).preValue=null,r.preToken=null,r.isLookahead=!1,r.isAmbientContext=!1,r.inAbstractClass=!1,r.inType=!1,r.inDisallowConditionalTypesContext=!1,r.maybeInArrowParameters=!1,r.shouldParseArrowReturnType=void 0,r.shouldParseAsyncArrowReturnType=void 0,r.decoratorStack=[[]],r.importsStack=[[]],r.importOrExportOuterKind=void 0,r.tsParseConstModifier=r.tsParseModifiers.bind(function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(r),{allowedModifiers:["const"],disallowedModifiers:["in","out"],errorTemplate:b.InvalidModifierOnTypeParameterPositions}),r}o(e,t);var s,m,g,A=e.prototype;return A.getTokenFromCodeInType=function(e){return 62===e||60===e?this.finishOp(p.relational,1):t.prototype.getTokenFromCode.call(this,e)},A.readToken=function(e){if(!this.inType){var s=this.curContext();if(s===R.tc_expr)return this.jsx_readToken();if(s===R.tc_oTag||s===R.tc_cTag){if(u(e))return this.jsx_readWord();if(62==e)return++this.pos,this.finishToken(_.jsxTagEnd);if((34===e||39===e)&&s==R.tc_oTag)return this.jsx_readString(e)}if(60===e&&this.exprAllowed&&33!==this.input.charCodeAt(this.pos+1))return++this.pos,this.finishToken(_.jsxTagStart)}return t.prototype.readToken.call(this,e)},A.getTokenFromCode=function(e){return this.inType?this.getTokenFromCodeInType(e):64===e?(++this.pos,this.finishToken(_.at)):t.prototype.getTokenFromCode.call(this,e)},A.isAbstractClass=function(){return this.ts_isContextual(_.abstract)&&this.lookahead().type===p._class},A.finishNode=function(e,s){return""!==e.type&&0!==e.end?e:t.prototype.finishNode.call(this,e,s)},A.tryParse=function(t,e){void 0===e&&(e=this.cloneCurLookaheadState());var s={node:null};try{return{node:t(function(t){throw void 0===t&&(t=null),s.node=t,s}),error:null,thrown:!1,aborted:!1,failState:null}}catch(t){var i=this.getCurLookaheadState();if(this.setLookaheadState(e),t instanceof SyntaxError)return{node:null,error:t,thrown:!0,aborted:!1,failState:i};if(t===s)return{node:s.node,error:null,thrown:!1,aborted:!0,failState:i};throw t}},A.setOptionalParametersError=function(t,e){var s;t.optionalParametersLoc=null!=(s=null==e?void 0:e.loc)?s:this.startLoc},A.reScan_lt_gt=function(){this.type===p.relational&&(this.pos-=1,this.readToken_lt_gt(this.fullCharCodeAtPos()))},A.reScan_lt=function(){var t=this.type;return t===p.bitShift?(this.pos-=2,this.finishOp(p.relational,1),p.relational):t},A.resetEndLocation=function(t,e){void 0===e&&(e=this.lastTokEndLoc),t.end=e.column,t.loc.end=e,this.options.ranges&&(t.range[1]=e.column)},A.startNodeAtNode=function(e){return t.prototype.startNodeAt.call(this,e.start,e.loc.start)},A.nextTokenStart=function(){return this.nextTokenStartSince(this.pos)},A.tsHasSomeModifiers=function(t,e){return e.some(function(e){return O(e)?t.accessibility===e:!!t[e]})},A.tsIsStartOfStaticBlocks=function(){return this.isContextual("static")&&123===this.lookaheadCharCode()},A.tsCheckForInvalidTypeCasts=function(t){var e=this;t.forEach(function(t){"TSTypeCastExpression"===(null==t?void 0:t.type)&&e.raise(t.typeAnnotation.start,b.UnexpectedTypeAnnotation)})},A.atPossibleAsyncArrow=function(t){return"Identifier"===t.type&&"async"===t.name&&this.lastTokEndLoc.column===t.end&&!this.canInsertSemicolon()&&t.end-t.start==5&&t.start===this.potentialArrowAt},A.tsIsIdentifier=function(){return q(this.type)},A.tsTryParseTypeOrTypePredicateAnnotation=function(){return this.match(p.colon)?this.tsParseTypeOrTypePredicateAnnotation(p.colon):void 0},A.tsTryParseGenericAsyncArrowFunction=function(e,s,i){var r=this;if(this.tsMatchLeftRelational()){var a=this.maybeInArrowParameters;this.maybeInArrowParameters=!0;var n=this.tsTryParseAndCatch(function(){var i=r.startNodeAt(e,s);return i.typeParameters=r.tsParseTypeParameters(),t.prototype.parseFunctionParams.call(r,i),i.returnType=r.tsTryParseTypeOrTypePredicateAnnotation(),r.expect(p.arrow),i});if(this.maybeInArrowParameters=a,n)return t.prototype.parseArrowExpression.call(this,n,null,!0,i)}},A.tsParseTypeArgumentsInExpression=function(){if(this.reScan_lt()===p.relational)return this.tsParseTypeArguments()},A.tsInNoContext=function(t){var e=this.context;this.context=[e[0]];try{return t()}finally{this.context=e}},A.tsTryParseTypeAnnotation=function(){return this.match(p.colon)?this.tsParseTypeAnnotation():void 0},A.isUnparsedContextual=function(t,e){var s=t+e.length;if(this.input.slice(t,s)===e){var i=this.input.charCodeAt(s);return!(D(i)||55296==(64512&i))}return!1},A.isAbstractConstructorSignature=function(){return this.ts_isContextual(_.abstract)&&this.lookahead().type===p._new},A.nextTokenStartSince=function(t){return E.lastIndex=t,E.test(this.input)?E.lastIndex:t},A.lookaheadCharCode=function(){return this.input.charCodeAt(this.nextTokenStart())},A.compareLookaheadState=function(t,e){for(var s=0,i=Object.keys(t);s<i.length;s++){var r=i[s];if(t[r]!==e[r])return!1}return!0},A.createLookaheadState=function(){this.value=null,this.context=[this.curContext()]},A.getCurLookaheadState=function(){return{endLoc:this.endLoc,lastTokEnd:this.lastTokEnd,lastTokStart:this.lastTokStart,lastTokStartLoc:this.lastTokStartLoc,pos:this.pos,value:this.value,type:this.type,start:this.start,end:this.end,context:this.context,startLoc:this.startLoc,lastTokEndLoc:this.lastTokEndLoc,curLine:this.curLine,lineStart:this.lineStart,curPosition:this.curPosition,containsEsc:this.containsEsc}},A.cloneCurLookaheadState=function(){return{pos:this.pos,value:this.value,type:this.type,start:this.start,end:this.end,context:this.context&&this.context.slice(),startLoc:this.startLoc,lastTokEndLoc:this.lastTokEndLoc,endLoc:this.endLoc,lastTokEnd:this.lastTokEnd,lastTokStart:this.lastTokStart,lastTokStartLoc:this.lastTokStartLoc,curLine:this.curLine,lineStart:this.lineStart,curPosition:this.curPosition,containsEsc:this.containsEsc}},A.setLookaheadState=function(t){this.pos=t.pos,this.value=t.value,this.endLoc=t.endLoc,this.lastTokEnd=t.lastTokEnd,this.lastTokStart=t.lastTokStart,this.lastTokStartLoc=t.lastTokStartLoc,this.type=t.type,this.start=t.start,this.end=t.end,this.context=t.context,this.startLoc=t.startLoc,this.lastTokEndLoc=t.lastTokEndLoc,this.curLine=t.curLine,this.lineStart=t.lineStart,this.curPosition=t.curPosition,this.containsEsc=t.containsEsc},A.tsLookAhead=function(t){var e=this.getCurLookaheadState(),s=t();return this.setLookaheadState(e),s},A.lookahead=function(t){var e=this.getCurLookaheadState();if(this.createLookaheadState(),this.isLookahead=!0,void 0!==t)for(var s=0;s<t;s++)this.nextToken();else this.nextToken();this.isLookahead=!1;var i=this.getCurLookaheadState();return this.setLookaheadState(e),i},A.readWord=function(){var t=this.readWord1(),e=p.name;return this.keywords.test(t)?e=l[t]:new RegExp(j).test(t)&&(e=_[t]),this.finishToken(e,t)},A.skipBlockComment=function(){var t;this.isLookahead||(t=this.options.onComment&&this.curPosition());var e=this.pos,s=this.input.indexOf("*/",this.pos+=2);if(-1===s&&this.raise(this.pos-2,"Unterminated comment"),this.pos=s+2,this.options.locations)for(var i,r=e;(i=K(this.input,r,this.pos))>-1;)++this.curLine,r=this.lineStart=i;this.isLookahead||this.options.onComment&&this.options.onComment(!0,this.input.slice(e+2,s),e,this.pos,t,this.curPosition())},A.skipLineComment=function(t){var e,s=this.pos;this.isLookahead||(e=this.options.onComment&&this.curPosition());for(var i=this.input.charCodeAt(this.pos+=t);this.pos<this.input.length&&!y(i);)i=this.input.charCodeAt(++this.pos);this.isLookahead||this.options.onComment&&this.options.onComment(!1,this.input.slice(s+t,this.pos),s,this.pos,e,this.curPosition())},A.finishToken=function(t,e){this.preValue=this.value,this.preToken=this.type,this.end=this.pos,this.options.locations&&(this.endLoc=this.curPosition());var s=this.type;this.type=t,this.value=e,this.isLookahead||this.updateContext(s)},A.resetStartLocation=function(t,e,s){t.start=e,t.loc.start=s,this.options.ranges&&(t.range[0]=e)},A.isLineTerminator=function(){return this.eat(p.semi)||t.prototype.canInsertSemicolon.call(this)},A.hasFollowingLineBreak=function(){return x.lastIndex=this.end,x.test(this.input)},A.addExtra=function(t,e,s,i){if(void 0===i&&(i=!0),t){var r=t.extra=t.extra||{};i?r[e]=s:Object.defineProperty(r,e,{enumerable:i,value:s})}},A.isLiteralPropertyName=function(){return F(this.type)},A.hasPrecedingLineBreak=function(){return d.test(this.input.slice(this.lastTokEndLoc.index,this.start))},A.createIdentifier=function(t,e){return t.name=e,this.finishNode(t,"Identifier")},A.resetStartLocationFromNode=function(t,e){this.resetStartLocation(t,e.start,e.loc.start)},A.isThisParam=function(t){return"Identifier"===t.type&&"this"===t.name},A.isLookaheadContextual=function(t){var e=this.nextTokenStart();return this.isUnparsedContextual(e,t)},A.ts_type_isContextual=function(t,e){return t===e&&!this.containsEsc},A.ts_isContextual=function(t){return this.type===t&&!this.containsEsc},A.ts_isContextualWithState=function(t,e){return t.type===e&&!t.containsEsc},A.isContextualWithState=function(t,e){return e.type===p.name&&e.value===t&&!e.containsEsc},A.tsIsStartOfMappedType=function(){return this.next(),this.eat(p.plusMin)?this.ts_isContextual(_.readonly):(this.ts_isContextual(_.readonly)&&this.next(),!!this.match(p.bracketL)&&(this.next(),!!this.tsIsIdentifier()&&(this.next(),this.match(p._in))))},A.tsInDisallowConditionalTypesContext=function(t){var e=this.inDisallowConditionalTypesContext;this.inDisallowConditionalTypesContext=!0;try{return t()}finally{this.inDisallowConditionalTypesContext=e}},A.tsTryParseType=function(){return this.tsEatThenParseType(p.colon)},A.match=function(t){return this.type===t},A.matchJsx=function(t){return this.type===n.tokTypes[t]},A.ts_eatWithState=function(t,e,s){if(t===s.type){for(var i=0;i<e;i++)this.next();return!0}return!1},A.ts_eatContextualWithState=function(t,e,s){if(j.test(t)){if(this.ts_isContextualWithState(s,_[t])){for(var i=0;i<e;i++)this.next();return!0}return!1}if(!this.isContextualWithState(t,s))return!1;for(var r=0;r<e;r++)this.next();return!0},A.canHaveLeadingDecorator=function(){return this.match(p._class)},A.eatContextual=function(e){return j.test(e)?!!this.ts_isContextual(_[e])&&(this.next(),!0):t.prototype.eatContextual.call(this,e)},A.tsIsExternalModuleReference=function(){return this.isContextual("require")&&40===this.lookaheadCharCode()},A.tsParseExternalModuleReference=function(){var t=this.startNode();return this.expectContextual("require"),this.expect(p.parenL),this.match(p.string)||this.unexpected(),t.expression=this.parseExprAtom(),this.expect(p.parenR),this.finishNode(t,"TSExternalModuleReference")},A.tsParseEntityName=function(t){void 0===t&&(t=!0);for(var e=this.parseIdent(t);this.eat(p.dot);){var s=this.startNodeAtNode(e);s.left=e,s.right=this.parseIdent(t),e=this.finishNode(s,"TSQualifiedName")}return e},A.tsParseEnumMember=function(){var t=this.startNode();return t.id=this.match(p.string)?this.parseLiteral(this.value):this.parseIdent(!0),this.eat(p.eq)&&(t.initializer=this.parseMaybeAssign()),this.finishNode(t,"TSEnumMember")},A.tsParseEnumDeclaration=function(t,e){return void 0===e&&(e={}),e.const&&(t.const=!0),e.declare&&(t.declare=!0),this.expectContextual("enum"),t.id=this.parseIdent(),this.checkLValSimple(t.id),this.expect(p.braceL),t.members=this.tsParseDelimitedList("EnumMembers",this.tsParseEnumMember.bind(this)),this.expect(p.braceR),this.finishNode(t,"TSEnumDeclaration")},A.tsParseModuleBlock=function(){var e=this.startNode();for(t.prototype.enterScope.call(this,512),this.expect(p.braceL),e.body=[];this.type!==p.braceR;){var s=this.parseStatement(null,!0);e.body.push(s)}return this.next(),t.prototype.exitScope.call(this),this.finishNode(e,"TSModuleBlock")},A.tsParseAmbientExternalModuleDeclaration=function(e){return this.ts_isContextual(_.global)?(e.global=!0,e.id=this.parseIdent()):this.match(p.string)?e.id=this.parseLiteral(this.value):this.unexpected(),this.match(p.braceL)?(t.prototype.enterScope.call(this,f),e.body=this.tsParseModuleBlock(),t.prototype.exitScope.call(this)):t.prototype.semicolon.call(this),this.finishNode(e,"TSModuleDeclaration")},A.tsTryParseDeclare=function(t){var e=this;if(!this.isLineTerminator()){var s,i=this.type;return this.isContextual("let")&&(i=p._var,s="let"),this.tsInAmbientContext(function(){if(i===p._function)return t.declare=!0,e.parseFunctionStatement(t,!1,!0);if(i===p._class)return t.declare=!0,e.parseClass(t,!0);if(i===_.enum)return e.tsParseEnumDeclaration(t,{declare:!0});if(i===_.global)return e.tsParseAmbientExternalModuleDeclaration(t);if(i===p._const||i===p._var)return e.match(p._const)&&e.isLookaheadContextual("enum")?(e.expect(p._const),e.tsParseEnumDeclaration(t,{const:!0,declare:!0})):(t.declare=!0,e.parseVarStatement(t,s||e.value,!0));if(i===_.interface){var r=e.tsParseInterfaceDeclaration(t,{declare:!0});if(r)return r}return q(i)?e.tsParseDeclaration(t,e.value,!0):void 0})}},A.tsIsListTerminator=function(t){switch(t){case"EnumMembers":case"TypeMembers":return this.match(p.braceR);case"HeritageClauseElement":return this.match(p.braceL);case"TupleElementTypes":return this.match(p.bracketR);case"TypeParametersOrArguments":return this.tsMatchRightRelational()}},A.tsParseDelimitedListWorker=function(t,e,s,i){for(var r=[],a=-1;!this.tsIsListTerminator(t);){a=-1;var n=e();if(null==n)return;if(r.push(n),!this.eat(p.comma)){if(this.tsIsListTerminator(t))break;return void(s&&this.expect(p.comma))}a=this.lastTokStart}return i&&(i.value=a),r},A.tsParseDelimitedList=function(t,e,s){return function(t){if(null==t)throw new Error("Unexpected "+t+" value.");return t}(this.tsParseDelimitedListWorker(t,e,!0,s))},A.tsParseBracketedList=function(t,e,s,i,r){i||this.expect(s?p.bracketL:p.relational);var a=this.tsParseDelimitedList(t,e,r);return this.expect(s?p.bracketR:p.relational),a},A.tsParseTypeParameterName=function(){return this.parseIdent().name},A.tsEatThenParseType=function(t){return this.match(t)?this.tsNextThenParseType():void 0},A.tsExpectThenParseType=function(t){var e=this;return this.tsDoThenParseType(function(){return e.expect(t)})},A.tsNextThenParseType=function(){var t=this;return this.tsDoThenParseType(function(){return t.next()})},A.tsDoThenParseType=function(t){var e=this;return this.tsInType(function(){return t(),e.tsParseType()})},A.tsSkipParameterStart=function(){if(q(this.type)||this.match(p._this))return this.next(),!0;if(this.match(p.braceL))try{return this.parseObj(!0),!0}catch(t){return!1}if(this.match(p.bracketL)){this.next();try{return this.parseBindingList(p.bracketR,!0,!0),!0}catch(t){return!1}}return!1},A.tsIsUnambiguouslyStartOfFunctionType=function(){if(this.next(),this.match(p.parenR)||this.match(p.ellipsis))return!0;if(this.tsSkipParameterStart()){if(this.match(p.colon)||this.match(p.comma)||this.match(p.question)||this.match(p.eq))return!0;if(this.match(p.parenR)&&(this.next(),this.match(p.arrow)))return!0}return!1},A.tsIsStartOfFunctionType=function(){return!!this.tsMatchLeftRelational()||this.match(p.parenL)&&this.tsLookAhead(this.tsIsUnambiguouslyStartOfFunctionType.bind(this))},A.tsInAllowConditionalTypesContext=function(t){var e=this.inDisallowConditionalTypesContext;this.inDisallowConditionalTypesContext=!1;try{return t()}finally{this.inDisallowConditionalTypesContext=e}},A.tsParseBindingListForSignature=function(){var e=this;return t.prototype.parseBindingList.call(this,p.parenR,!0,!0).map(function(t){return"Identifier"!==t.type&&"RestElement"!==t.type&&"ObjectPattern"!==t.type&&"ArrayPattern"!==t.type&&e.raise(t.start,b.UnsupportedSignatureParameterKind(t.type)),t})},A.tsParseTypePredicateAsserts=function(){if(this.type!==_.asserts)return!1;var t=this.containsEsc;return this.next(),!(!q(this.type)&&!this.match(p._this)||(t&&this.raise(this.lastTokStart,"Escape sequence in keyword asserts"),0))},A.tsParseThisTypeNode=function(){var t=this.startNode();return this.next(),this.finishNode(t,"TSThisType")},A.tsParseTypeAnnotation=function(t,e){var s=this;return void 0===t&&(t=!0),void 0===e&&(e=this.startNode()),this.tsInType(function(){t&&s.expect(p.colon),e.typeAnnotation=s.tsParseType()}),this.finishNode(e,"TSTypeAnnotation")},A.tsParseThisTypePredicate=function(t){this.next();var e=this.startNodeAtNode(t);return e.parameterName=t,e.typeAnnotation=this.tsParseTypeAnnotation(!1),e.asserts=!1,this.finishNode(e,"TSTypePredicate")},A.tsParseThisTypeOrThisTypePredicate=function(){var t=this.tsParseThisTypeNode();return this.isContextual("is")&&!this.hasPrecedingLineBreak()?this.tsParseThisTypePredicate(t):t},A.tsParseTypePredicatePrefix=function(){var t=this.parseIdent();if(this.isContextual("is")&&!this.hasPrecedingLineBreak())return this.next(),t},A.tsParseTypeOrTypePredicateAnnotation=function(t){var e=this;return this.tsInType(function(){var s=e.startNode();e.expect(t);var i=e.startNode(),r=!!e.tsTryParse(e.tsParseTypePredicateAsserts.bind(e));if(r&&e.match(p._this)){var a=e.tsParseThisTypeOrThisTypePredicate();return"TSThisType"===a.type?(i.parameterName=a,i.asserts=!0,i.typeAnnotation=null,a=e.finishNode(i,"TSTypePredicate")):(e.resetStartLocationFromNode(a,i),a.asserts=!0),s.typeAnnotation=a,e.finishNode(s,"TSTypeAnnotation")}var n=e.tsIsIdentifier()&&e.tsTryParse(e.tsParseTypePredicatePrefix.bind(e));if(!n)return r?(i.parameterName=e.parseIdent(),i.asserts=r,i.typeAnnotation=null,s.typeAnnotation=e.finishNode(i,"TSTypePredicate"),e.finishNode(s,"TSTypeAnnotation")):e.tsParseTypeAnnotation(!1,s);var o=e.tsParseTypeAnnotation(!1);return i.parameterName=n,i.typeAnnotation=o,i.asserts=r,s.typeAnnotation=e.finishNode(i,"TSTypePredicate"),e.finishNode(s,"TSTypeAnnotation")})},A.tsFillSignature=function(t,e){var s=t===p.arrow;e.typeParameters=this.tsTryParseTypeParameters(),this.expect(p.parenL),e.parameters=this.tsParseBindingListForSignature(),(s||this.match(t))&&(e.typeAnnotation=this.tsParseTypeOrTypePredicateAnnotation(t))},A.tsTryNextParseConstantContext=function(){if(this.lookahead().type!==p._const)return null;this.next();var t=this.tsParseTypeReference();return t.typeParameters&&this.raise(t.typeName.start,b.CannotFindName({name:"const"})),t},A.tsParseFunctionOrConstructorType=function(t,e){var s=this,i=this.startNode();return"TSConstructorType"===t&&(i.abstract=!!e,e&&this.next(),this.next()),this.tsInAllowConditionalTypesContext(function(){return s.tsFillSignature(p.arrow,i)}),this.finishNode(i,t)},A.tsParseUnionOrIntersectionType=function(t,e,s){var i=this.startNode(),r=this.eat(s),a=[];do{a.push(e())}while(this.eat(s));return 1!==a.length||r?(i.types=a,this.finishNode(i,t)):a[0]},A.tsCheckTypeAnnotationForReadOnly=function(t){switch(t.typeAnnotation.type){case"TSTupleType":case"TSArrayType":return;default:this.raise(t.start,b.UnexpectedReadonly)}},A.tsParseTypeOperator=function(){var t=this.startNode(),e=this.value;return this.next(),t.operator=e,t.typeAnnotation=this.tsParseTypeOperatorOrHigher(),"readonly"===e&&this.tsCheckTypeAnnotationForReadOnly(t),this.finishNode(t,"TSTypeOperator")},A.tsParseConstraintForInferType=function(){var t=this;if(this.eat(p._extends)){var e=this.tsInDisallowConditionalTypesContext(function(){return t.tsParseType()});if(this.inDisallowConditionalTypesContext||!this.match(p.question))return e}},A.tsParseInferType=function(){var t=this,e=this.startNode();this.expectContextual("infer");var s=this.startNode();return s.name=this.tsParseTypeParameterName(),s.constraint=this.tsTryParse(function(){return t.tsParseConstraintForInferType()}),e.typeParameter=this.finishNode(s,"TSTypeParameter"),this.finishNode(e,"TSInferType")},A.tsParseLiteralTypeNode=function(){var t=this,e=this.startNode();return e.literal=function(){switch(t.type){case p.num:case p.string:case p._true:case p._false:return t.parseExprAtom();default:t.unexpected()}}(),this.finishNode(e,"TSLiteralType")},A.tsParseImportType=function(){var t=this.startNode();return this.expect(p._import),this.expect(p.parenL),this.match(p.string)||this.raise(this.start,b.UnsupportedImportTypeArgument),t.argument=this.parseExprAtom(),this.expect(p.parenR),this.eat(p.dot)&&(t.qualifier=this.tsParseEntityName()),this.tsMatchLeftRelational()&&(t.typeParameters=this.tsParseTypeArguments()),this.finishNode(t,"TSImportType")},A.tsParseTypeQuery=function(){var t=this.startNode();return this.expect(p._typeof),t.exprName=this.match(p._import)?this.tsParseImportType():this.tsParseEntityName(),!this.hasPrecedingLineBreak()&&this.tsMatchLeftRelational()&&(t.typeParameters=this.tsParseTypeArguments()),this.finishNode(t,"TSTypeQuery")},A.tsParseMappedTypeParameter=function(){var t=this.startNode();return t.name=this.tsParseTypeParameterName(),t.constraint=this.tsExpectThenParseType(p._in),this.finishNode(t,"TSTypeParameter")},A.tsParseMappedType=function(){var t=this.startNode();return this.expect(p.braceL),this.match(p.plusMin)?(t.readonly=this.value,this.next(),this.expectContextual("readonly")):this.eatContextual("readonly")&&(t.readonly=!0),this.expect(p.bracketL),t.typeParameter=this.tsParseMappedTypeParameter(),t.nameType=this.eatContextual("as")?this.tsParseType():null,this.expect(p.bracketR),this.match(p.plusMin)?(t.optional=this.value,this.next(),this.expect(p.question)):this.eat(p.question)&&(t.optional=!0),t.typeAnnotation=this.tsTryParseType(),this.semicolon(),this.expect(p.braceR),this.finishNode(t,"TSMappedType")},A.tsParseTypeLiteral=function(){var t=this.startNode();return t.members=this.tsParseObjectTypeMembers(),this.finishNode(t,"TSTypeLiteral")},A.tsParseTupleElementType=function(){var t=this.startLoc,e=this.start,s=this.eat(p.ellipsis),i=this.tsParseType(),r=this.eat(p.question);if(this.eat(p.colon)){var a=this.startNodeAtNode(i);a.optional=r,"TSTypeReference"!==i.type||i.typeParameters||"Identifier"!==i.typeName.type?(this.raise(i.start,b.InvalidTupleMemberLabel),a.label=i):a.label=i.typeName,a.elementType=this.tsParseType(),i=this.finishNode(a,"TSNamedTupleMember")}else if(r){var n=this.startNodeAtNode(i);n.typeAnnotation=i,i=this.finishNode(n,"TSOptionalType")}if(s){var o=this.startNodeAt(e,t);o.typeAnnotation=i,i=this.finishNode(o,"TSRestType")}return i},A.tsParseTupleType=function(){var t=this,e=this.startNode();e.elementTypes=this.tsParseBracketedList("TupleElementTypes",this.tsParseTupleElementType.bind(this),!0,!1);var s=!1,i=null;return e.elementTypes.forEach(function(e){var r=e.type;!s||"TSRestType"===r||"TSOptionalType"===r||"TSNamedTupleMember"===r&&e.optional||t.raise(e.start,b.OptionalTypeBeforeRequired),s||(s="TSNamedTupleMember"===r&&e.optional||"TSOptionalType"===r);var a=r;"TSRestType"===r&&(a=(e=e.typeAnnotation).type);var n="TSNamedTupleMember"===a;null!=i||(i=n),i!==n&&t.raise(e.start,b.MixedLabeledAndUnlabeledElements)}),this.finishNode(e,"TSTupleType")},A.tsParseTemplateLiteralType=function(){var t=this.startNode();return t.literal=this.parseTemplate({isTagged:!1}),this.finishNode(t,"TSLiteralType")},A.tsParseTypeReference=function(){var t=this.startNode();return t.typeName=this.tsParseEntityName(),!this.hasPrecedingLineBreak()&&this.tsMatchLeftRelational()&&(t.typeParameters=this.tsParseTypeArguments()),this.finishNode(t,"TSTypeReference")},A.tsMatchLeftRelational=function(){return this.match(p.relational)&&"<"===this.value},A.tsMatchRightRelational=function(){return this.match(p.relational)&&">"===this.value},A.tsParseParenthesizedType=function(){var t=this.startNode();return this.expect(p.parenL),t.typeAnnotation=this.tsParseType(),this.expect(p.parenR),this.finishNode(t,"TSParenthesizedType")},A.tsParseNonArrayType=function(){switch(this.type){case p.string:case p.num:case p._true:case p._false:return this.tsParseLiteralTypeNode();case p.plusMin:if("-"===this.value){var t=this.startNode();return this.lookahead().type!==p.num&&this.unexpected(),t.literal=this.parseMaybeUnary(),this.finishNode(t,"TSLiteralType")}break;case p._this:return this.tsParseThisTypeOrThisTypePredicate();case p._typeof:return this.tsParseTypeQuery();case p._import:return this.tsParseImportType();case p.braceL:return this.tsLookAhead(this.tsIsStartOfMappedType.bind(this))?this.tsParseMappedType():this.tsParseTypeLiteral();case p.bracketL:return this.tsParseTupleType();case p.parenL:return this.tsParseParenthesizedType();case p.backQuote:case p.dollarBraceL:return this.tsParseTemplateLiteralType();default:var e=this.type;if(q(e)||e===p._void||e===p._null){var s=e===p._void?"TSVoidKeyword":e===p._null?"TSNullKeyword":function(t){switch(t){case"any":return"TSAnyKeyword";case"boolean":return"TSBooleanKeyword";case"bigint":return"TSBigIntKeyword";case"never":return"TSNeverKeyword";case"number":return"TSNumberKeyword";case"object":return"TSObjectKeyword";case"string":return"TSStringKeyword";case"symbol":return"TSSymbolKeyword";case"undefined":return"TSUndefinedKeyword";case"unknown":return"TSUnknownKeyword";default:return}}(this.value);if(void 0!==s&&46!==this.lookaheadCharCode()){var i=this.startNode();return this.next(),this.finishNode(i,s)}return this.tsParseTypeReference()}}this.unexpected()},A.tsParseArrayTypeOrHigher=function(){for(var t=this.tsParseNonArrayType();!this.hasPrecedingLineBreak()&&this.eat(p.bracketL);)if(this.match(p.bracketR)){var e=this.startNodeAtNode(t);e.elementType=t,this.expect(p.bracketR),t=this.finishNode(e,"TSArrayType")}else{var s=this.startNodeAtNode(t);s.objectType=t,s.indexType=this.tsParseType(),this.expect(p.bracketR),t=this.finishNode(s,"TSIndexedAccessType")}return t},A.tsParseTypeOperatorOrHigher=function(){var t=this;return V(this.type)&&!this.containsEsc?this.tsParseTypeOperator():this.isContextual("infer")?this.tsParseInferType():this.tsInAllowConditionalTypesContext(function(){return t.tsParseArrayTypeOrHigher()})},A.tsParseIntersectionTypeOrHigher=function(){return this.tsParseUnionOrIntersectionType("TSIntersectionType",this.tsParseTypeOperatorOrHigher.bind(this),p.bitwiseAND)},A.tsParseUnionTypeOrHigher=function(){return this.tsParseUnionOrIntersectionType("TSUnionType",this.tsParseIntersectionTypeOrHigher.bind(this),p.bitwiseOR)},A.tsParseNonConditionalType=function(){return this.tsIsStartOfFunctionType()?this.tsParseFunctionOrConstructorType("TSFunctionType"):this.match(p._new)?this.tsParseFunctionOrConstructorType("TSConstructorType"):this.isAbstractConstructorSignature()?this.tsParseFunctionOrConstructorType("TSConstructorType",!0):this.tsParseUnionTypeOrHigher()},A.tsParseType=function(){var t=this;k(this.inType);var e=this.tsParseNonConditionalType();if(this.inDisallowConditionalTypesContext||this.hasPrecedingLineBreak()||!this.eat(p._extends))return e;var s=this.startNodeAtNode(e);return s.checkType=e,s.extendsType=this.tsInDisallowConditionalTypesContext(function(){return t.tsParseNonConditionalType()}),this.expect(p.question),s.trueType=this.tsInAllowConditionalTypesContext(function(){return t.tsParseType()}),this.expect(p.colon),s.falseType=this.tsInAllowConditionalTypesContext(function(){return t.tsParseType()}),this.finishNode(s,"TSConditionalType")},A.tsIsUnambiguouslyIndexSignature=function(){return this.next(),!!q(this.type)&&(this.next(),this.match(p.colon))},A.tsInType=function(t){var e=this.inType;this.inType=!0;try{return t()}finally{this.inType=e}},A.tsTryParseIndexSignature=function(t){if(this.match(p.bracketL)&&this.tsLookAhead(this.tsIsUnambiguouslyIndexSignature.bind(this))){this.expect(p.bracketL);var e=this.parseIdent();e.typeAnnotation=this.tsParseTypeAnnotation(),this.resetEndLocation(e),this.expect(p.bracketR),t.parameters=[e];var s=this.tsTryParseTypeAnnotation();return s&&(t.typeAnnotation=s),this.tsParseTypeMemberSemicolon(),this.finishNode(t,"TSIndexSignature")}},A.tsParseNoneModifiers=function(t){this.tsParseModifiers({modified:t,allowedModifiers:[],disallowedModifiers:["in","out"],errorTemplate:b.InvalidModifierOnTypeParameterPositions})},A.tsParseTypeParameter=function(t){void 0===t&&(t=this.tsParseNoneModifiers.bind(this));var e=this.startNode();return t(e),e.name=this.tsParseTypeParameterName(),e.constraint=this.tsEatThenParseType(p._extends),e.default=this.tsEatThenParseType(p.eq),this.finishNode(e,"TSTypeParameter")},A.tsParseTypeParameters=function(t){var e=this.startNode();this.tsMatchLeftRelational()||this.matchJsx("jsxTagStart")?this.next():this.unexpected();var s={value:-1};return e.params=this.tsParseBracketedList("TypeParametersOrArguments",this.tsParseTypeParameter.bind(this,t),!1,!0,s),0===e.params.length&&this.raise(this.start,b.EmptyTypeParameters),-1!==s.value&&this.addExtra(e,"trailingComma",s.value),this.finishNode(e,"TSTypeParameterDeclaration")},A.tsTryParseTypeParameters=function(t){if(this.tsMatchLeftRelational())return this.tsParseTypeParameters(t)},A.tsTryParse=function(t){var e=this.getCurLookaheadState(),s=t();return void 0!==s&&!1!==s?s:void this.setLookaheadState(e)},A.tsTokenCanFollowModifier=function(){return(this.match(p.bracketL)||this.match(p.braceL)||this.match(p.star)||this.match(p.ellipsis)||this.match(p.privateId)||this.isLiteralPropertyName())&&!this.hasPrecedingLineBreak()},A.tsNextTokenCanFollowModifier=function(){return this.next(!0),this.tsTokenCanFollowModifier()},A.tsParseModifier=function(t,e){if(q(this.type)||this.type===p._in){var s=this.value;if(-1!==t.indexOf(s)&&!this.containsEsc){if(e&&this.tsIsStartOfStaticBlocks())return;if(this.tsTryParse(this.tsNextTokenCanFollowModifier.bind(this)))return s}}},A.tsParseModifiersByMap=function(t){for(var e=t.modified,s=t.map,i=0,r=Object.keys(s);i<r.length;i++){var a=r[i];e[a]=s[a]}},A.tsParseModifiers=function(t){for(var e=this,s=t.modified,i=t.allowedModifiers,r=t.disallowedModifiers,a=t.stopOnStartOfClassStaticBlock,n=t.errorTemplate,o=void 0===n?b.InvalidModifierOnTypeMember:n,h={},p=function(t,i,r,a){i===r&&s[a]&&e.raise(t.column,b.InvalidModifiersOrder({orderedModifiers:[r,a]}))},c=function(t,i,r,a){(s[r]&&i===a||s[a]&&i===r)&&e.raise(t.column,b.IncompatibleModifiers({modifiers:[r,a]}))};;){var l=this.startLoc,u=this.tsParseModifier(i.concat(null!=r?r:[]),a);if(!u)break;O(u)?s.accessibility?this.raise(this.start,b.DuplicateAccessibilityModifier()):(p(l,u,u,"override"),p(l,u,u,"static"),p(l,u,u,"readonly"),p(l,u,u,"accessor"),h.accessibility=u,s.accessibility=u):N(u)?s[u]?this.raise(this.start,b.DuplicateModifier({modifier:u})):(p(l,u,"in","out"),h[u]=u,s[u]=!0):I(u)?s[u]?this.raise(this.start,b.DuplicateModifier({modifier:u})):(c(l,u,"accessor","readonly"),c(l,u,"accessor","static"),c(l,u,"accessor","override"),h[u]=u,s[u]=!0):Object.hasOwnProperty.call(s,u)?this.raise(this.start,b.DuplicateModifier({modifier:u})):(p(l,u,"static","readonly"),p(l,u,"static","override"),p(l,u,"override","readonly"),p(l,u,"abstract","override"),c(l,u,"declare","override"),c(l,u,"static","abstract"),h[u]=u,s[u]=!0),null!=r&&r.includes(u)&&this.raise(this.start,o)}return h},A.tsParseInOutModifiers=function(t){this.tsParseModifiers({modified:t,allowedModifiers:["in","out"],disallowedModifiers:["public","private","protected","readonly","declare","abstract","override"],errorTemplate:b.InvalidModifierOnTypeParameter})},A.tsParseTypeArguments=function(){var t=this,e=this.startNode();return e.params=this.tsInType(function(){return t.tsInNoContext(function(){return t.expect(p.relational),t.tsParseDelimitedList("TypeParametersOrArguments",t.tsParseType.bind(t))})}),0===e.params.length&&this.raise(this.start,b.EmptyTypeArguments),this.exprAllowed=!1,this.expect(p.relational),this.finishNode(e,"TSTypeParameterInstantiation")},A.tsParseHeritageClause=function(t){var e=this,s=this.start,i=this.tsParseDelimitedList("HeritageClauseElement",function(){var t=e.startNode();return t.expression=e.tsParseEntityName(),e.tsMatchLeftRelational()&&(t.typeParameters=e.tsParseTypeArguments()),e.finishNode(t,"TSExpressionWithTypeArguments")});return i.length||this.raise(s,b.EmptyHeritageClauseType({token:t})),i},A.tsParseTypeMemberSemicolon=function(){this.eat(p.comma)||this.isLineTerminator()||this.expect(p.semi)},A.tsTryParseAndCatch=function(t){var e=this.tryParse(function(e){return t()||e()});if(!e.aborted&&e.node)return e.error&&this.setLookaheadState(e.failState),e.node},A.tsParseSignatureMember=function(t,e){return this.tsFillSignature(p.colon,e),this.tsParseTypeMemberSemicolon(),this.finishNode(e,t)},A.tsParsePropertyOrMethodSignature=function(t,e){this.eat(p.question)&&(t.optional=!0);var s=t;if(this.match(p.parenL)||this.tsMatchLeftRelational()){e&&this.raise(t.start,b.ReadonlyForMethodSignature);var i=s;i.kind&&this.tsMatchLeftRelational()&&this.raise(this.start,b.AccesorCannotHaveTypeParameters),this.tsFillSignature(p.colon,i),this.tsParseTypeMemberSemicolon();var r="parameters",a="typeAnnotation";if("get"===i.kind)i[r].length>0&&(this.raise(this.start,"A 'get' accesor must not have any formal parameters."),this.isThisParam(i[r][0])&&this.raise(this.start,b.AccesorCannotDeclareThisParameter));else if("set"===i.kind){if(1!==i[r].length)this.raise(this.start,"A 'get' accesor must not have any formal parameters.");else{var n=i[r][0];this.isThisParam(n)&&this.raise(this.start,b.AccesorCannotDeclareThisParameter),"Identifier"===n.type&&n.optional&&this.raise(this.start,b.SetAccesorCannotHaveOptionalParameter),"RestElement"===n.type&&this.raise(this.start,b.SetAccesorCannotHaveRestParameter)}i[a]&&this.raise(i[a].start,b.SetAccesorCannotHaveReturnType)}else i.kind="method";return this.finishNode(i,"TSMethodSignature")}var o=s;e&&(o.readonly=!0);var h=this.tsTryParseTypeAnnotation();return h&&(o.typeAnnotation=h),this.tsParseTypeMemberSemicolon(),this.finishNode(o,"TSPropertySignature")},A.tsParseTypeMember=function(){var t=this.startNode();if(this.match(p.parenL)||this.tsMatchLeftRelational())return this.tsParseSignatureMember("TSCallSignatureDeclaration",t);if(this.match(p._new)){var e=this.startNode();return this.next(),this.match(p.parenL)||this.tsMatchLeftRelational()?this.tsParseSignatureMember("TSConstructSignatureDeclaration",t):(t.key=this.createIdentifier(e,"new"),this.tsParsePropertyOrMethodSignature(t,!1))}return this.tsParseModifiers({modified:t,allowedModifiers:["readonly"],disallowedModifiers:["declare","abstract","private","protected","public","static","override"]}),this.tsTryParseIndexSignature(t)||(this.parsePropertyName(t),t.computed||"Identifier"!==t.key.type||"get"!==t.key.name&&"set"!==t.key.name||!this.tsTokenCanFollowModifier()||(t.kind=t.key.name,this.parsePropertyName(t)),this.tsParsePropertyOrMethodSignature(t,!!t.readonly))},A.tsParseList=function(t,e){for(var s=[];!this.tsIsListTerminator(t);)s.push(e());return s},A.tsParseObjectTypeMembers=function(){this.expect(p.braceL);var t=this.tsParseList("TypeMembers",this.tsParseTypeMember.bind(this));return this.expect(p.braceR),t},A.tsParseInterfaceDeclaration=function(t,e){if(void 0===e&&(e={}),this.hasFollowingLineBreak())return null;this.expectContextual("interface"),e.declare&&(t.declare=!0),q(this.type)?(t.id=this.parseIdent(),this.checkLValSimple(t.id,7)):(t.id=null,this.raise(this.start,b.MissingInterfaceName)),t.typeParameters=this.tsTryParseTypeParameters(this.tsParseInOutModifiers.bind(this)),this.eat(p._extends)&&(t.extends=this.tsParseHeritageClause("extends"));var s=this.startNode();return s.body=this.tsInType(this.tsParseObjectTypeMembers.bind(this)),t.body=this.finishNode(s,"TSInterfaceBody"),this.finishNode(t,"TSInterfaceDeclaration")},A.tsParseAbstractDeclaration=function(t){if(this.match(p._class))return t.abstract=!0,this.parseClass(t,!0);if(this.ts_isContextual(_.interface)){if(!this.hasFollowingLineBreak())return t.abstract=!0,this.tsParseInterfaceDeclaration(t)}else this.unexpected(t.start)},A.tsIsDeclarationStart=function(){return H(this.type)},A.tsParseExpressionStatement=function(e,s){switch(s.name){case"declare":var i=this.tsTryParseDeclare(e);if(i)return i.declare=!0,i;break;case"global":if(this.match(p.braceL)){t.prototype.enterScope.call(this,f);var r=e;return r.global=!0,r.id=s,r.body=this.tsParseModuleBlock(),t.prototype.exitScope.call(this),this.finishNode(r,"TSModuleDeclaration")}break;default:return this.tsParseDeclaration(e,s.name,!1)}},A.tsParseModuleReference=function(){return this.tsIsExternalModuleReference()?this.tsParseExternalModuleReference():this.tsParseEntityName(!1)},A.tsIsExportDefaultSpecifier=function(){var t=this.type,e=this.isAsyncFunction(),s=this.isLet();if(q(t)){if(e&&!this.containsEsc||s)return!1;if((t===_.type||t===_.interface)&&!this.containsEsc){var i=this.lookahead();if(q(i.type)&&!this.isContextualWithState("from",i)||i.type===p.braceL)return!1}}else if(!this.match(p._default))return!1;var r=this.nextTokenStart(),a=this.isUnparsedContextual(r,"from");if(44===this.input.charCodeAt(r)||q(this.type)&&a)return!0;if(this.match(p._default)&&a){var n=this.input.charCodeAt(this.nextTokenStartSince(r+4));return 34===n||39===n}return!1},A.tsInAmbientContext=function(t){var e=this.isAmbientContext;this.isAmbientContext=!0;try{return t()}finally{this.isAmbientContext=e}},A.tsCheckLineTerminator=function(t){return t?!this.hasFollowingLineBreak()&&(this.next(),!0):!this.isLineTerminator()},A.tsParseModuleOrNamespaceDeclaration=function(e,s){if(void 0===s&&(s=!1),e.id=this.parseIdent(),s||this.checkLValSimple(e.id,8),this.eat(p.dot)){var i=this.startNode();this.tsParseModuleOrNamespaceDeclaration(i,!0),e.body=i}else t.prototype.enterScope.call(this,f),e.body=this.tsParseModuleBlock(),t.prototype.exitScope.call(this);return this.finishNode(e,"TSModuleDeclaration")},A.checkLValSimple=function(e,s,i){return void 0===s&&(s=0),t.prototype.checkLValSimple.call(this,e,s,i)},A.tsParseTypeAliasDeclaration=function(t){var e=this;return t.id=this.parseIdent(),this.checkLValSimple(t.id,6),t.typeAnnotation=this.tsInType(function(){if(t.typeParameters=e.tsTryParseTypeParameters(e.tsParseInOutModifiers.bind(e)),e.expect(p.eq),e.ts_isContextual(_.interface)&&e.lookahead().type!==p.dot){var s=e.startNode();return e.next(),e.finishNode(s,"TSIntrinsicKeyword")}return e.tsParseType()}),this.semicolon(),this.finishNode(t,"TSTypeAliasDeclaration")},A.tsParseDeclaration=function(t,e,s){switch(e){case"abstract":if(this.tsCheckLineTerminator(s)&&(this.match(p._class)||q(this.type)))return this.tsParseAbstractDeclaration(t);break;case"module":if(this.tsCheckLineTerminator(s)){if(this.match(p.string))return this.tsParseAmbientExternalModuleDeclaration(t);if(q(this.type))return this.tsParseModuleOrNamespaceDeclaration(t)}break;case"namespace":if(this.tsCheckLineTerminator(s)&&q(this.type))return this.tsParseModuleOrNamespaceDeclaration(t);break;case"type":if(this.tsCheckLineTerminator(s)&&q(this.type))return this.tsParseTypeAliasDeclaration(t)}},A.tsTryParseExportDeclaration=function(){return this.tsParseDeclaration(this.startNode(),this.value,!0)},A.tsParseImportEqualsDeclaration=function(e,s){e.isExport=s||!1,e.id=this.parseIdent(),this.checkLValSimple(e.id,2),t.prototype.expect.call(this,p.eq);var i=this.tsParseModuleReference();return"type"===e.importKind&&"TSExternalModuleReference"!==i.type&&this.raise(i.start,b.ImportAliasHasImportType),e.moduleReference=i,t.prototype.semicolon.call(this),this.finishNode(e,"TSImportEqualsDeclaration")},A.isExportDefaultSpecifier=function(){if(this.tsIsDeclarationStart())return!1;var t=this.type;if(q(t)){if(this.isContextual("async")||this.isContextual("let"))return!1;if((t===_.type||t===_.interface)&&!this.containsEsc){var e=this.lookahead();if(q(e.type)&&!this.isContextualWithState("from",e)||e.type===p.braceL)return!1}}else if(!this.match(p._default))return!1;var s=this.nextTokenStart(),i=this.isUnparsedContextual(s,"from");if(44===this.input.charCodeAt(s)||q(this.type)&&i)return!0;if(this.match(p._default)&&i){var r=this.input.charCodeAt(this.nextTokenStartSince(s+4));return 34===r||39===r}return!1},A.parseTemplate=function(t){var e=(void 0===t?{}:t).isTagged,s=void 0!==e&&e,i=this.startNode();this.next(),i.expressions=[];var r=this.parseTemplateElement({isTagged:s});for(i.quasis=[r];!r.tail;)this.type===p.eof&&this.raise(this.pos,"Unterminated template literal"),this.expect(p.dollarBraceL),i.expressions.push(this.inType?this.tsParseType():this.parseExpression()),this.expect(p.braceR),i.quasis.push(r=this.parseTemplateElement({isTagged:s}));return this.next(),this.finishNode(i,"TemplateLiteral")},A.parseFunction=function(t,e,s,i,r){this.initFunction(t),(this.options.ecmaVersion>=9||this.options.ecmaVersion>=6&&!i)&&(this.type===p.star&&2&e&&this.unexpected(),t.generator=this.eat(p.star)),this.options.ecmaVersion>=8&&(t.async=!!i),1&e&&(t.id=4&e&&this.type!==p.name?null:this.parseIdent());var a=this.yieldPos,n=this.awaitPos,o=this.awaitIdentPos,h=this.maybeInArrowParameters;this.maybeInArrowParameters=!1,this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(w(t.async,t.generator)),1&e||(t.id=this.type===p.name?this.parseIdent():null),this.parseFunctionParams(t);var c=1&e;return this.parseFunctionBody(t,s,!1,r,{isFunctionDeclaration:c}),this.yieldPos=a,this.awaitPos=n,this.awaitIdentPos=o,1&e&&t.id&&!(2&e)&&this.checkLValSimple(t.id,t.body?this.strict||t.generator||t.async?this.treatFunctionsAsVar?1:2:3:0),this.maybeInArrowParameters=h,this.finishNode(t,c?"FunctionDeclaration":"FunctionExpression")},A.parseFunctionBody=function(e,s,i,r,a){void 0===s&&(s=!1),void 0===i&&(i=!1),void 0===r&&(r=!1),this.match(p.colon)&&(e.returnType=this.tsParseTypeOrTypePredicateAnnotation(p.colon));var n=null!=a&&a.isFunctionDeclaration?"TSDeclareFunction":null!=a&&a.isClassMethod?"TSDeclareMethod":void 0;return n&&!this.match(p.braceL)&&this.isLineTerminator()?this.finishNode(e,n):"TSDeclareFunction"===n&&this.isAmbientContext&&(this.raise(e.start,b.DeclareFunctionHasImplementation),e.declare)?(t.prototype.parseFunctionBody.call(this,e,s,i,!1),this.finishNode(e,n)):(t.prototype.parseFunctionBody.call(this,e,s,i,r),e)},A.parseNew=function(){var t;this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword new");var e=this.startNode(),s=this.parseIdent(!0);if(this.options.ecmaVersion>=6&&this.eat(p.dot)){e.meta=s;var i=this.containsEsc;return e.property=this.parseIdent(!0),"target"!==e.property.name&&this.raiseRecoverable(e.property.start,"The only valid meta property for new is 'new.target'"),i&&this.raiseRecoverable(e.start,"'new.target' must not contain escaped characters"),this.allowNewDotTarget||this.raiseRecoverable(e.start,"'new.target' can only be used in functions and class static block"),this.finishNode(e,"MetaProperty")}var r=this.start,a=this.startLoc,n=this.type===p._import;e.callee=this.parseSubscripts(this.parseExprAtom(),r,a,!0,!1),n&&"ImportExpression"===e.callee.type&&this.raise(r,"Cannot use new with import()");var o=e.callee;return"TSInstantiationExpression"!==o.type||null!=(t=o.extra)&&t.parenthesized||(e.typeParameters=o.typeParameters,e.callee=o.expression),e.arguments=this.eat(p.parenL)?this.parseExprList(p.parenR,this.options.ecmaVersion>=8,!1):[],this.finishNode(e,"NewExpression")},A.parseExprOp=function(e,s,i,r,a){var n;if(p._in.binop>r&&!this.hasPrecedingLineBreak()&&(this.isContextual("as")&&(n="TSAsExpression"),h&&this.isContextual("satisfies")&&(n="TSSatisfiesExpression"),n)){var o=this.startNodeAt(s,i);o.expression=e;var c=this.tsTryNextParseConstantContext();return o.typeAnnotation=c||this.tsNextThenParseType(),this.finishNode(o,n),this.reScan_lt_gt(),this.parseExprOp(o,s,i,r,a)}return t.prototype.parseExprOp.call(this,e,s,i,r,a)},A.parseImportSpecifiers=function(){var t=[],e=!0;if(n.tokenIsIdentifier(this.type)&&(t.push(this.parseImportDefaultSpecifier()),!this.eat(p.comma)))return t;if(this.type===p.star)return t.push(this.parseImportNamespaceSpecifier()),t;for(this.expect(p.braceL);!this.eat(p.braceR);){if(e)e=!1;else if(this.expect(p.comma),this.afterTrailingComma(p.braceR))break;t.push(this.parseImportSpecifier())}return t},A.parseImport=function(t){var e=this.lookahead();if(t.importKind="value",this.importOrExportOuterKind="value",q(e.type)||this.match(p.star)||this.match(p.braceL)){var s=this.lookahead(2);if(s.type!==p.comma&&!this.isContextualWithState("from",s)&&s.type!==p.eq&&this.ts_eatContextualWithState("type",1,e)&&(this.importOrExportOuterKind="type",t.importKind="type",e=this.lookahead(),s=this.lookahead(2)),q(e.type)&&s.type===p.eq){this.next();var i=this.tsParseImportEqualsDeclaration(t);return this.importOrExportOuterKind="value",i}}return this.next(),this.type===p.string?(t.specifiers=[],t.source=this.parseExprAtom()):(t.specifiers=this.parseImportSpecifiers(),this.expectContextual("from"),t.source=this.type===p.string?this.parseExprAtom():this.unexpected()),this.parseMaybeImportAttributes(t),this.semicolon(),this.finishNode(t,"ImportDeclaration"),this.importOrExportOuterKind="value","type"===t.importKind&&t.specifiers.length>1&&"ImportDefaultSpecifier"===t.specifiers[0].type&&this.raise(t.start,b.TypeImportCannotSpecifyDefaultAndNamed),t},A.parseExportDefaultDeclaration=function(){if(this.isAbstractClass()){var e=this.startNode();return this.next(),e.abstract=!0,this.parseClass(e,!0)}if(this.match(_.interface)){var s=this.tsParseInterfaceDeclaration(this.startNode());if(s)return s}return t.prototype.parseExportDefaultDeclaration.call(this)},A.parseExportAllDeclaration=function(t,e){return this.options.ecmaVersion>=11&&(this.eatContextual("as")?(t.exported=this.parseModuleExportName(),this.checkExport(e,t.exported,this.lastTokStart)):t.exported=null),this.expectContextual("from"),this.type!==p.string&&this.unexpected(),t.source=this.parseExprAtom(),this.parseMaybeImportAttributes(t),this.semicolon(),this.finishNode(t,"ExportAllDeclaration")},A.parseDynamicImport=function(t){if(this.next(),t.source=this.parseMaybeAssign(),this.eat(p.comma)){var e=this.parseExpression();t.arguments=[e]}if(!this.eat(p.parenR)){var s=this.start;this.eat(p.comma)&&this.eat(p.parenR)?this.raiseRecoverable(s,"Trailing comma is not allowed in import()"):this.unexpected(s)}return this.finishNode(t,"ImportExpression")},A.parseExport=function(t,e){var s=this.lookahead();if(this.ts_eatWithState(p._import,2,s)){this.ts_isContextual(_.type)&&61!==this.lookaheadCharCode()?(t.importKind="type",this.importOrExportOuterKind="type",this.next()):(t.importKind="value",this.importOrExportOuterKind="value");var i=this.tsParseImportEqualsDeclaration(t,!0);return this.importOrExportOuterKind=void 0,i}if(this.ts_eatWithState(p.eq,2,s)){var r=t;return r.expression=this.parseExpression(),this.semicolon(),this.importOrExportOuterKind=void 0,this.finishNode(r,"TSExportAssignment")}if(this.ts_eatContextualWithState("as",2,s)){var a=t;return this.expectContextual("namespace"),a.id=this.parseIdent(),this.semicolon(),this.importOrExportOuterKind=void 0,this.finishNode(a,"TSNamespaceExportDeclaration")}if(this.ts_isContextualWithState(s,_.type)&&this.lookahead(2).type===p.braceL?(this.next(),this.importOrExportOuterKind="type",t.exportKind="type"):(this.importOrExportOuterKind="value",t.exportKind="value"),this.next(),this.eat(p.star))return this.parseExportAllDeclaration(t,e);if(this.eat(p._default))return this.checkExport(e,"default",this.lastTokStart),t.declaration=this.parseExportDefaultDeclaration(),this.finishNode(t,"ExportDefaultDeclaration");if(this.shouldParseExportStatement())t.declaration=this.parseExportDeclaration(t),"VariableDeclaration"===t.declaration.type?this.checkVariableExport(e,t.declaration.declarations):this.checkExport(e,t.declaration.id,t.declaration.id.start),t.specifiers=[],t.source=null;else{if(t.declaration=null,t.specifiers=this.parseExportSpecifiers(e),this.eatContextual("from"))this.type!==p.string&&this.unexpected(),t.source=this.parseExprAtom(),this.parseMaybeImportAttributes(t);else{for(var n,o=c(t.specifiers);!(n=o()).done;){var h=n.value;this.checkUnreserved(h.local),this.checkLocalExport(h.local),"Literal"===h.local.type&&this.raise(h.local.start,"A string literal cannot be used as an exported binding without `from`.")}t.source=null}this.semicolon()}return this.finishNode(t,"ExportNamedDeclaration")},A.checkExport=function(t,e,s){t&&("string"!=typeof e&&(e="Identifier"===e.type?e.name:e.value),t[e]=!0)},A.parseMaybeDefault=function(e,s,i){var r=t.prototype.parseMaybeDefault.call(this,e,s,i);return"AssignmentPattern"===r.type&&r.typeAnnotation&&r.right.start<r.typeAnnotation.start&&this.raise(r.typeAnnotation.start,b.TypeAnnotationAfterAssign),r},A.typeCastToParameter=function(t){return t.expression.typeAnnotation=t.typeAnnotation,this.resetEndLocation(t.expression,t.typeAnnotation.end),t.expression},A.toAssignableList=function(e,s){for(var i=0;i<e.length;i++){var r=e[i];"TSTypeCastExpression"===(null==r?void 0:r.type)&&(e[i]=this.typeCastToParameter(r))}return t.prototype.toAssignableList.call(this,e,s)},A.reportReservedArrowTypeParam=function(t){},A.parseExprAtom=function(e,s,i){if(this.type===_.jsxText)return this.jsx_parseText();if(this.type===_.jsxTagStart)return this.jsx_parseElement();if(this.type===_.at)return this.parseDecorators(),this.parseExprAtom();if(q(this.type)){var r=this.potentialArrowAt===this.start,a=this.start,n=this.startLoc,o=this.containsEsc,h=this.parseIdent(!1);if(this.options.ecmaVersion>=8&&!o&&"async"===h.name&&!this.canInsertSemicolon()&&this.eat(p._function))return this.overrideContext(M.f_expr),this.parseFunction(this.startNodeAt(a,n),0,!1,!0,s);if(r&&!this.canInsertSemicolon()){if(this.eat(p.arrow))return this.parseArrowExpression(this.startNodeAt(a,n),[h],!1,s);if(this.options.ecmaVersion>=8&&"async"===h.name&&this.type===p.name&&!o&&(!this.potentialArrowInForAwait||"of"!==this.value||this.containsEsc))return h=this.parseIdent(!1),!this.canInsertSemicolon()&&this.eat(p.arrow)||this.unexpected(),this.parseArrowExpression(this.startNodeAt(a,n),[h],!0,s)}return h}return t.prototype.parseExprAtom.call(this,e,s,i)},A.parseExprAtomDefault=function(){if(q(this.type)){var t=this.potentialArrowAt===this.start,e=this.containsEsc,s=this.parseIdent();if(!e&&"async"===s.name&&!this.canInsertSemicolon()){var i=this.type;if(i===p._function)return this.next(),this.parseFunction(this.startNodeAtNode(s),void 0,!0,!0);if(q(i)){if(61===this.lookaheadCharCode()){var r=this.parseIdent(!1);return!this.canInsertSemicolon()&&this.eat(p.arrow)||this.unexpected(),this.parseArrowExpression(this.startNodeAtNode(s),[r],!0)}return s}}return t&&this.match(p.arrow)&&!this.canInsertSemicolon()?(this.next(),this.parseArrowExpression(this.startNodeAtNode(s),[s],!1)):s}this.unexpected()},A.parseIdentNode=function(){var e=this.startNode();return U(this.type)?(e.name=this.value,e):t.prototype.parseIdentNode.call(this)},A.parseVarStatement=function(e,s,i){void 0===i&&(i=!1);var r=this.isAmbientContext;this.next(),t.prototype.parseVar.call(this,e,!1,s,i||r),this.semicolon();var a=this.finishNode(e,"VariableDeclaration");if(!r)return a;for(var n,o=c(a.declarations);!(n=o()).done;){var h=n.value,p=h.init;p&&("const"!==s||h.id.typeAnnotation?this.raise(p.start,b.InitializerNotAllowedInAmbientContext):"StringLiteral"!==p.type&&"BooleanLiteral"!==p.type&&"NumericLiteral"!==p.type&&"BigIntLiteral"!==p.type&&("TemplateLiteral"!==p.type||p.expressions.length>0)&&!L(p)&&this.raise(p.start,b.ConstInitiailizerMustBeStringOrNumericLiteralOrLiteralEnumReference))}return a},A.parseStatement=function(e,s,i){if(this.match(_.at)&&this.parseDecorators(!0),this.match(p._const)&&this.isLookaheadContextual("enum")){var r=this.startNode();return this.expect(p._const),this.tsParseEnumDeclaration(r,{const:!0})}if(this.ts_isContextual(_.enum))return this.tsParseEnumDeclaration(this.startNode());if(this.ts_isContextual(_.interface)){var a=this.tsParseInterfaceDeclaration(this.startNode());if(a)return a}return t.prototype.parseStatement.call(this,e,s,i)},A.parseAccessModifier=function(){return this.tsParseModifier(["public","protected","private"])},A.parsePostMemberNameModifiers=function(t){this.eat(p.question)&&(t.optional=!0),t.readonly&&this.match(p.parenL)&&this.raise(t.start,b.ClassMethodHasReadonly),t.declare&&this.match(p.parenL)&&this.raise(t.start,b.ClassMethodHasDeclare)},A.parseExpressionStatement=function(e,s){return("Identifier"===s.type?this.tsParseExpressionStatement(e,s):void 0)||t.prototype.parseExpressionStatement.call(this,e,s)},A.shouldParseExportStatement=function(){return!!this.tsIsDeclarationStart()||!!this.match(_.at)||t.prototype.shouldParseExportStatement.call(this)},A.parseConditional=function(t,e,s,i,r){if(this.eat(p.question)){var a=this.startNodeAt(e,s);return a.test=t,a.consequent=this.parseMaybeAssign(),this.expect(p.colon),a.alternate=this.parseMaybeAssign(i),this.finishNode(a,"ConditionalExpression")}return t},A.parseMaybeConditional=function(t,e){var s=this,i=this.start,r=this.startLoc,a=this.parseExprOps(t,e);if(this.checkExpressionErrors(e))return a;if(!this.maybeInArrowParameters||!this.match(p.question))return this.parseConditional(a,i,r,t,e);var n=this.tryParse(function(){return s.parseConditional(a,i,r,t,e)});return n.node?(n.error&&this.setLookaheadState(n.failState),n.node):(n.error&&this.setOptionalParametersError(e,n.error),a)},A.parseParenItem=function(e){var s=this.start,i=this.startLoc;if(e=t.prototype.parseParenItem.call(this,e),this.eat(p.question)&&(e.optional=!0,this.resetEndLocation(e)),this.match(p.colon)){var r=this.startNodeAt(s,i);return r.expression=e,r.typeAnnotation=this.tsParseTypeAnnotation(),this.finishNode(r,"TSTypeCastExpression")}return e},A.parseExportDeclaration=function(t){var e=this;if(!this.isAmbientContext&&this.ts_isContextual(_.declare))return this.tsInAmbientContext(function(){return e.parseExportDeclaration(t)});var s=this.start,i=this.startLoc,r=this.eatContextual("declare");!r||!this.ts_isContextual(_.declare)&&this.shouldParseExportStatement()||this.raise(this.start,b.ExpectedAmbientAfterExportDeclare);var a=q(this.type)&&this.tsTryParseExportDeclaration()||this.parseStatement(null);return a?(("TSInterfaceDeclaration"===a.type||"TSTypeAliasDeclaration"===a.type||r)&&(t.exportKind="type"),r&&(this.resetStartLocation(a,s,i),a.declare=!0),a):null},A.parseClassId=function(e,s){if(s||!this.isContextual("implements")){t.prototype.parseClassId.call(this,e,s);var i=this.tsTryParseTypeParameters(this.tsParseInOutModifiers.bind(this));i&&(e.typeParameters=i)}},A.parseClassPropertyAnnotation=function(t){t.optional||("!"===this.value&&this.eat(p.prefix)?t.definite=!0:this.eat(p.question)&&(t.optional=!0));var e=this.tsTryParseTypeAnnotation();e&&(t.typeAnnotation=e)},A.parseClassField=function(e){if("PrivateIdentifier"===e.key.type)e.abstract&&this.raise(e.start,b.PrivateElementHasAbstract),e.accessibility&&this.raise(e.start,b.PrivateElementHasAccessibility({modifier:e.accessibility})),this.parseClassPropertyAnnotation(e);else if(this.parseClassPropertyAnnotation(e),this.isAmbientContext&&(!e.readonly||e.typeAnnotation)&&this.match(p.eq)&&this.raise(this.start,b.DeclareClassFieldHasInitializer),e.abstract&&this.match(p.eq)){var s=e.key;this.raise(this.start,b.AbstractPropertyHasInitializer({propertyName:"Identifier"!==s.type||e.computed?"["+this.input.slice(s.start,s.end)+"]":s.name}))}return t.prototype.parseClassField.call(this,e)},A.parseClassMethod=function(t,e,s,i){var r="constructor"===t.kind,a="PrivateIdentifier"===t.key.type,n=this.tsTryParseTypeParameters();a?(n&&(t.typeParameters=n),t.accessibility&&this.raise(t.start,b.PrivateMethodsHasAccessibility({modifier:t.accessibility}))):n&&r&&this.raise(n.start,b.ConstructorHasTypeParameters);var o=t.declare,h=t.kind;!(void 0!==o&&o)||"get"!==h&&"set"!==h||this.raise(t.start,b.DeclareAccessor({kind:h})),n&&(t.typeParameters=n);var p=t.key;"constructor"===t.kind?(e&&this.raise(p.start,"Constructor can't be a generator"),s&&this.raise(p.start,"Constructor can't be an async method")):t.static&&P(t,"prototype")&&this.raise(p.start,"Classes may not have a static property named prototype");var c=t.value=this.parseMethod(e,s,i,!0,t);return"get"===t.kind&&0!==c.params.length&&this.raiseRecoverable(c.start,"getter should have no params"),"set"===t.kind&&1!==c.params.length&&this.raiseRecoverable(c.start,"setter should have exactly one param"),"set"===t.kind&&"RestElement"===c.params[0].type&&this.raiseRecoverable(c.params[0].start,"Setter cannot use rest params"),this.finishNode(t,"MethodDefinition")},A.isClassMethod=function(){return this.match(p.relational)},A.parseClassElement=function(e){var s=this;if(this.eat(p.semi))return null;var i,r=this.options.ecmaVersion,a=this.startNode(),n="",o=!1,h=!1,c="method",l=["declare","private","public","protected","accessor","override","abstract","readonly","static"],u=this.tsParseModifiers({modified:a,allowedModifiers:l,disallowedModifiers:["in","out"],stopOnStartOfClassStaticBlock:!0,errorTemplate:b.InvalidModifierOnTypeParameterPositions});i=Boolean(u.static);var d=function(){if(!s.tsIsStartOfStaticBlocks()){var u=s.tsTryParseIndexSignature(a);if(u)return a.abstract&&s.raise(a.start,b.IndexSignatureHasAbstract),a.accessibility&&s.raise(a.start,b.IndexSignatureHasAccessibility({modifier:a.accessibility})),a.declare&&s.raise(a.start,b.IndexSignatureHasDeclare),a.override&&s.raise(a.start,b.IndexSignatureHasOverride),u;if(!s.inAbstractClass&&a.abstract&&s.raise(a.start,b.NonAbstractClassHasAbstractMethod),a.override&&e&&s.raise(a.start,b.OverrideNotInSubClass),a.static=i,i&&(s.isClassElementNameStart()||s.type===p.star||(n="static")),!n&&r>=8&&s.eatContextual("async")&&(!s.isClassElementNameStart()&&s.type!==p.star||s.canInsertSemicolon()?n="async":h=!0),!n&&(r>=9||!h)&&s.eat(p.star)&&(o=!0),!n&&!h&&!o){var d=s.value;(s.eatContextual("get")||s.eatContextual("set"))&&(s.isClassElementNameStart()?c=d:n=d)}if(n?(a.computed=!1,a.key=s.startNodeAt(s.lastTokStart,s.lastTokStartLoc),a.key.name=n,s.finishNode(a.key,"Identifier")):s.parseClassElementName(a),s.parsePostMemberNameModifiers(a),s.isClassMethod()||r<13||s.type===p.parenL||"method"!==c||o||h){var m=!a.static&&P(a,"constructor"),f=m&&e;m&&"method"!==c&&s.raise(a.key.start,"Constructor can't have get/set modifier"),a.kind=m?"constructor":c,s.parseClassMethod(a,o,h,f)}else s.parseClassField(a);return a}if(s.next(),s.next(),s.tsHasSomeModifiers(a,l)&&s.raise(s.start,b.StaticBlockCannotHaveModifier),r>=13)return t.prototype.parseClassStaticBlock.call(s,a),a};return a.declare?this.tsInAmbientContext(d):d(),a},A.isClassElementNameStart=function(){return!!this.tsIsIdentifier()||t.prototype.isClassElementNameStart.call(this)},A.parseClassSuper=function(e){t.prototype.parseClassSuper.call(this,e),e.superClass&&(this.tsMatchLeftRelational()||this.match(p.bitShift))&&(e.superTypeParameters=this.tsParseTypeArgumentsInExpression()),this.eatContextual("implements")&&(e.implements=this.tsParseHeritageClause("implements"))},A.parseFunctionParams=function(e){var s=this.tsTryParseTypeParameters();s&&(e.typeParameters=s),t.prototype.parseFunctionParams.call(this,e)},A.parseVarId=function(e,s){t.prototype.parseVarId.call(this,e,s),"Identifier"===e.id.type&&!this.hasPrecedingLineBreak()&&"!"===this.value&&this.eat(p.prefix)&&(e.definite=!0);var i=this.tsTryParseTypeAnnotation();i&&(e.id.typeAnnotation=i,this.resetEndLocation(e.id))},A.parseArrowExpression=function(t,e,s,i){this.match(p.colon)&&(t.returnType=this.tsParseTypeAnnotation());var r=this.yieldPos,a=this.awaitPos,n=this.awaitIdentPos;this.enterScope(16|w(s,!1)),this.initFunction(t);var o=this.maybeInArrowParameters;return this.options.ecmaVersion>=8&&(t.async=!!s),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.maybeInArrowParameters=!0,t.params=this.toAssignableList(e,!0),this.maybeInArrowParameters=!1,this.parseFunctionBody(t,!0,!1,i),this.yieldPos=r,this.awaitPos=a,this.awaitIdentPos=n,this.maybeInArrowParameters=o,this.finishNode(t,"ArrowFunctionExpression")},A.parseMaybeAssignOrigin=function(t,e,s){if(this.isContextual("yield")){if(this.inGenerator)return this.parseYield(t);this.exprAllowed=!1}var i=!1,r=-1,a=-1,n=-1;e?(r=e.parenthesizedAssign,a=e.trailingComma,n=e.doubleProto,e.parenthesizedAssign=e.trailingComma=-1):(e=new T,i=!0);var o=this.start,h=this.startLoc;(this.type===p.parenL||q(this.type))&&(this.potentialArrowAt=this.start,this.potentialArrowInForAwait="await"===t);var c=this.parseMaybeConditional(t,e);if(s&&(c=s.call(this,c,o,h)),this.type.isAssign){var l=this.startNodeAt(o,h);return l.operator=this.value,this.type===p.eq&&(c=this.toAssignable(c,!0,e)),i||(e.parenthesizedAssign=e.trailingComma=e.doubleProto=-1),e.shorthandAssign>=c.start&&(e.shorthandAssign=-1),this.type===p.eq?this.checkLValPattern(c):this.checkLValSimple(c),l.left=c,this.next(),l.right=this.parseMaybeAssign(t),n>-1&&(e.doubleProto=n),this.finishNode(l,"AssignmentExpression")}return i&&this.checkExpressionErrors(e,!0),r>-1&&(e.parenthesizedAssign=r),a>-1&&(e.trailingComma=a),c},A.parseMaybeAssign=function(t,e,s){var i,r,a,o,h,p,c,l,u,d,m,f=this;if(this.matchJsx("jsxTagStart")||this.tsMatchLeftRelational()){if(l=this.cloneCurLookaheadState(),!(u=this.tryParse(function(){return f.parseMaybeAssignOrigin(t,e,s)},l)).error)return u.node;var y=this.context,x=y[y.length-1];x===n.tokContexts.tc_oTag&&y[y.length-2]===n.tokContexts.tc_expr?(y.pop(),y.pop()):x!==n.tokContexts.tc_oTag&&x!==n.tokContexts.tc_expr||y.pop()}if(!(null!=(i=u)&&i.error||this.tsMatchLeftRelational()))return this.parseMaybeAssignOrigin(t,e,s);l&&!this.compareLookaheadState(l,this.getCurLookaheadState())||(l=this.cloneCurLookaheadState());var T=this.tryParse(function(i){var r,a;m=f.tsParseTypeParameters();var n=f.parseMaybeAssignOrigin(t,e,s);return("ArrowFunctionExpression"!==n.type||null!=(r=n.extra)&&r.parenthesized)&&i(),0!==(null==(a=m)?void 0:a.params.length)&&f.resetStartLocationFromNode(n,m),n.typeParameters=m,n},l);if(!T.error&&!T.aborted)return m&&this.reportReservedArrowTypeParam(m),T.node;if(!u&&(k(!0),!(d=this.tryParse(function(){return f.parseMaybeAssignOrigin(t,e,s)},l)).error))return d.node;if(null!=(r=u)&&r.node)return this.setLookaheadState(u.failState),u.node;if(T.node)return this.setLookaheadState(T.failState),m&&this.reportReservedArrowTypeParam(m),T.node;if(null!=(a=d)&&a.node)return this.setLookaheadState(d.failState),d.node;if(null!=(o=u)&&o.thrown)throw u.error;if(T.thrown)throw T.error;if(null!=(h=d)&&h.thrown)throw d.error;throw(null==(p=u)?void 0:p.error)||T.error||(null==(c=d)?void 0:c.error)},A.parseAssignableListItem=function(t){for(var e=[];this.match(_.at);)e.push(this.parseDecorator());var s,i=this.start,r=this.startLoc,a=!1,n=!1;if(void 0!==t){var o={};this.tsParseModifiers({modified:o,allowedModifiers:["public","private","protected","override","readonly"]}),s=o.accessibility,n=o.override,a=o.readonly,!1===t&&(s||a||n)&&this.raise(r.start,b.UnexpectedParameterModifier)}var h=this.parseMaybeDefault(i,r);this.parseBindingListItem(h);var p=this.parseMaybeDefault(h.start,h.loc,h);if(e.length&&(p.decorators=e),s||a||n){var c=this.startNodeAt(i,r);return s&&(c.accessibility=s),a&&(c.readonly=a),n&&(c.override=n),"Identifier"!==p.type&&"AssignmentPattern"!==p.type&&this.raise(c.start,b.UnsupportedParameterPropertyKind),c.parameter=p,this.finishNode(c,"TSParameterProperty")}return p},A.checkLValInnerPattern=function(e,s,i){void 0===s&&(s=0),"TSParameterProperty"===e.type?this.checkLValInnerPattern(e.parameter,s,i):t.prototype.checkLValInnerPattern.call(this,e,s,i)},A.parseBindingListItem=function(t){this.eat(p.question)&&("Identifier"===t.type||this.isAmbientContext||this.inType||this.raise(t.start,b.PatternIsOptional),t.optional=!0);var e=this.tsTryParseTypeAnnotation();return e&&(t.typeAnnotation=e),this.resetEndLocation(t),t},A.isAssignable=function(t,e){var s=this;switch(t.type){case"TSTypeCastExpression":return this.isAssignable(t.expression,e);case"TSParameterProperty":case"Identifier":case"ObjectPattern":case"ArrayPattern":case"AssignmentPattern":case"RestElement":return!0;case"ObjectExpression":var i=t.properties.length-1;return t.properties.every(function(t,e){return"ObjectMethod"!==t.type&&(e===i||"SpreadElement"!==t.type)&&s.isAssignable(t)});case"Property":case"ObjectProperty":return this.isAssignable(t.value);case"SpreadElement":return this.isAssignable(t.argument);case"ArrayExpression":return t.elements.every(function(t){return null===t||s.isAssignable(t)});case"AssignmentExpression":return"="===t.operator;case"ParenthesizedExpression":return this.isAssignable(t.expression);case"MemberExpression":case"OptionalMemberExpression":return!e;default:return!1}},A.toAssignable=function(e,s,i){switch(void 0===s&&(s=!1),void 0===i&&(i=new T),e.type){case"ParenthesizedExpression":return this.toAssignableParenthesizedExpression(e,s,i);case"TSAsExpression":case"TSSatisfiesExpression":case"TSNonNullExpression":case"TSTypeAssertion":return s||this.raise(e.start,b.UnexpectedTypeCastInParameter),this.toAssignable(e.expression,s,i);case"MemberExpression":break;case"AssignmentExpression":return s||"TSTypeCastExpression"!==e.left.type||(e.left=this.typeCastToParameter(e.left)),t.prototype.toAssignable.call(this,e,s,i);case"TSTypeCastExpression":return this.typeCastToParameter(e);default:return t.prototype.toAssignable.call(this,e,s,i)}return e},A.toAssignableParenthesizedExpression=function(e,s,i){switch(e.expression.type){case"TSAsExpression":case"TSSatisfiesExpression":case"TSNonNullExpression":case"TSTypeAssertion":case"ParenthesizedExpression":return this.toAssignable(e.expression,s,i);default:return t.prototype.toAssignable.call(this,e,s,i)}},A.curPosition=function(){if(this.options.locations){var e=t.prototype.curPosition.call(this);return Object.defineProperty(e,"offset",{get:function(){return function(t){var e=new i.Position(this.line,this.column+t);return e.index=this.index+t,e}}}),e.index=this.pos,e}},A.parseBindingAtom=function(){return this.type===p._this?this.parseIdent(!0):t.prototype.parseBindingAtom.call(this)},A.shouldParseArrow=function(t){var e,s=this;if(e=this.match(p.colon)?t.every(function(t){return s.isAssignable(t,!0)}):!this.canInsertSemicolon()){if(this.match(p.colon)){var i=this.tryParse(function(t){var e=s.tsParseTypeOrTypePredicateAnnotation(p.colon);return!s.canInsertSemicolon()&&s.match(p.arrow)||t(),e});if(i.aborted)return this.shouldParseArrowReturnType=void 0,!1;i.thrown||(i.error&&this.setLookaheadState(i.failState),this.shouldParseArrowReturnType=i.node)}return!!this.match(p.arrow)||(this.shouldParseArrowReturnType=void 0,!1)}return this.shouldParseArrowReturnType=void 0,e},A.parseParenArrowList=function(t,e,s,i){var r=this.startNodeAt(t,e);return r.returnType=this.shouldParseArrowReturnType,this.shouldParseArrowReturnType=void 0,this.parseArrowExpression(r,s,!1,i)},A.parseParenAndDistinguishExpression=function(t,e){var s,i=this.start,r=this.startLoc,a=this.options.ecmaVersion>=8;if(this.options.ecmaVersion>=6){var n=this.maybeInArrowParameters;this.maybeInArrowParameters=!0,this.next();var o,h=this.start,c=this.startLoc,l=[],u=!0,d=!1,m=new T,f=this.yieldPos,y=this.awaitPos;for(this.yieldPos=0,this.awaitPos=0;this.type!==p.parenR;){if(u?u=!1:this.expect(p.comma),a&&this.afterTrailingComma(p.parenR,!0)){d=!0;break}if(this.type===p.ellipsis){o=this.start,l.push(this.parseParenItem(this.parseRestBinding())),this.type===p.comma&&this.raise(this.start,"Comma is not permitted after the rest element");break}l.push(this.parseMaybeAssign(e,m,this.parseParenItem))}var x=this.lastTokEnd,v=this.lastTokEndLoc;if(this.expect(p.parenR),this.maybeInArrowParameters=n,t&&this.shouldParseArrow(l)&&this.eat(p.arrow))return this.checkPatternErrors(m,!1),this.checkYieldAwaitInDefaultParams(),this.yieldPos=f,this.awaitPos=y,this.parseParenArrowList(i,r,l,e);l.length&&!d||this.unexpected(this.lastTokStart),o&&this.unexpected(o),this.checkExpressionErrors(m,!0),this.yieldPos=f||this.yieldPos,this.awaitPos=y||this.awaitPos,l.length>1?((s=this.startNodeAt(h,c)).expressions=l,this.finishNodeAt(s,"SequenceExpression",x,v)):s=l[0]}else s=this.parseParenExpression();if(this.options.preserveParens){var P=this.startNodeAt(i,r);return P.expression=s,this.finishNode(P,"ParenthesizedExpression")}return s},A.parseTaggedTemplateExpression=function(t,e,s,i){var r=this.startNodeAt(e,s);return r.tag=t,r.quasi=this.parseTemplate({isTagged:!0}),i&&this.raise(e,"Tagged Template Literals are not allowed in optionalChain."),this.finishNode(r,"TaggedTemplateExpression")},A.shouldParseAsyncArrow=function(){var t=this;if(!this.match(p.colon))return!this.canInsertSemicolon()&&this.eat(p.arrow);var e=this.tryParse(function(e){var s=t.tsParseTypeOrTypePredicateAnnotation(p.colon);return!t.canInsertSemicolon()&&t.match(p.arrow)||e(),s});return e.aborted?(this.shouldParseAsyncArrowReturnType=void 0,!1):e.thrown?void 0:(e.error&&this.setLookaheadState(e.failState),this.shouldParseAsyncArrowReturnType=e.node,!this.canInsertSemicolon()&&this.eat(p.arrow))},A.parseSubscriptAsyncArrow=function(t,e,s,i){var r=this.startNodeAt(t,e);return r.returnType=this.shouldParseAsyncArrowReturnType,this.shouldParseAsyncArrowReturnType=void 0,this.parseArrowExpression(r,s,!0,i)},A.parseExprList=function(t,e,s,i){for(var r=[],a=!0;!this.eat(t);){if(a)a=!1;else if(this.expect(p.comma),e&&this.afterTrailingComma(t))break;var n=void 0;s&&this.type===p.comma?n=null:this.type===p.ellipsis?(n=this.parseSpread(i),i&&this.type===p.comma&&i.trailingComma<0&&(i.trailingComma=this.start)):n=this.parseMaybeAssign(!1,i,this.parseParenItem),r.push(n)}return r},A.parseSubscript=function(t,e,s,i,r,a,n){var o=this,h=a;if(!this.hasPrecedingLineBreak()&&"!"===this.value&&this.match(p.prefix)){this.exprAllowed=!1,this.next();var c=this.startNodeAt(e,s);return c.expression=t,t=this.finishNode(c,"TSNonNullExpression")}var l=!1;if(this.match(p.questionDot)&&60===this.lookaheadCharCode()){if(i)return t;t.optional=!0,h=l=!0,this.next()}if(this.tsMatchLeftRelational()||this.match(p.bitShift)){var u,d=this.tsTryParseAndCatch(function(){if(!i&&o.atPossibleAsyncArrow(t)){var r=o.tsTryParseGenericAsyncArrowFunction(e,s,n);if(r)return t=r}var a=o.tsParseTypeArgumentsInExpression();if(!a)return t;if(l&&!o.match(p.parenL))return u=o.curPosition(),t;if(B(o.type)||o.type===p.backQuote){var c=o.parseTaggedTemplateExpression(t,e,s,h);return c.typeParameters=a,c}if(!i&&o.eat(p.parenL)){var d=new T,m=o.startNodeAt(e,s);return m.callee=t,m.arguments=o.parseExprList(p.parenR,o.options.ecmaVersion>=8,!1,d),o.tsCheckForInvalidTypeCasts(m.arguments),m.typeParameters=a,h&&(m.optional=l),o.checkExpressionErrors(d,!0),t=o.finishNode(m,"CallExpression")}var f=o.type;if(!(o.tsMatchRightRelational()||f===p.bitShift||f!==p.parenL&&(y=f,Boolean(y.startsExpr))&&!o.hasPrecedingLineBreak())){var y,x=o.startNodeAt(e,s);return x.expression=t,x.typeParameters=a,o.finishNode(x,"TSInstantiationExpression")}});if(u&&this.unexpected(u),d)return"TSInstantiationExpression"===d.type&&(this.match(p.dot)||this.match(p.questionDot)&&40!==this.lookaheadCharCode())&&this.raise(this.start,b.InvalidPropertyAccessAfterInstantiationExpression),t=d}var m=this.options.ecmaVersion>=11,f=m&&this.eat(p.questionDot);i&&f&&this.raise(this.lastTokStart,"Optional chaining cannot appear in the callee of new expressions");var y=this.eat(p.bracketL);if(y||f&&this.type!==p.parenL&&this.type!==p.backQuote||this.eat(p.dot)){var x=this.startNodeAt(e,s);x.object=t,y?(x.property=this.parseExpression(),this.expect(p.bracketR)):x.property=this.type===p.privateId&&"Super"!==t.type?this.parsePrivateIdent():this.parseIdent("never"!==this.options.allowReserved),x.computed=!!y,m&&(x.optional=f),t=this.finishNode(x,"MemberExpression")}else if(!i&&this.eat(p.parenL)){var v=this.maybeInArrowParameters;this.maybeInArrowParameters=!0;var P=new T,g=this.yieldPos,A=this.awaitPos,S=this.awaitIdentPos;this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0;var C=this.parseExprList(p.parenR,this.options.ecmaVersion>=8,!1,P);if(r&&!f&&this.shouldParseAsyncArrow())this.checkPatternErrors(P,!1),this.checkYieldAwaitInDefaultParams(),this.awaitIdentPos>0&&this.raise(this.awaitIdentPos,"Cannot use 'await' as identifier inside an async function"),this.yieldPos=g,this.awaitPos=A,this.awaitIdentPos=S,t=this.parseSubscriptAsyncArrow(e,s,C,n);else{this.checkExpressionErrors(P,!0),this.yieldPos=g||this.yieldPos,this.awaitPos=A||this.awaitPos,this.awaitIdentPos=S||this.awaitIdentPos;var E=this.startNodeAt(e,s);E.callee=t,E.arguments=C,m&&(E.optional=f),t=this.finishNode(E,"CallExpression")}this.maybeInArrowParameters=v}else if(this.type===p.backQuote){(f||h)&&this.raise(this.start,"Optional chaining cannot appear in the tag of tagged template expressions");var k=this.startNodeAt(e,s);k.tag=t,k.quasi=this.parseTemplate({isTagged:!0}),t=this.finishNode(k,"TaggedTemplateExpression")}return t},A.parseGetterSetter=function(t){t.kind=t.key.name,this.parsePropertyName(t),t.value=this.parseMethod(!1);var e="get"===t.kind?0:1,s=t.value.params[0],i=s&&this.isThisParam(s);t.value.params.length!==(e=i?e+1:e)?this.raiseRecoverable(t.value.start,"get"===t.kind?"getter should have no params":"setter should have exactly one param"):"set"===t.kind&&"RestElement"===t.value.params[0].type&&this.raiseRecoverable(t.value.params[0].start,"Setter cannot use rest params")},A.parseProperty=function(e,s){if(!e){var i=[];if(this.match(_.at))for(;this.match(_.at);)i.push(this.parseDecorator());var r=t.prototype.parseProperty.call(this,e,s);return"SpreadElement"===r.type&&i.length&&this.raise(r.start,"Decorators can't be used with SpreadElement"),i.length&&(r.decorators=i,i=[]),r}return t.prototype.parseProperty.call(this,e,s)},A.parseCatchClauseParam=function(){var t=this.parseBindingAtom(),e="Identifier"===t.type;this.enterScope(e?32:0),this.checkLValPattern(t,e?4:2);var s=this.tsTryParseTypeAnnotation();return s&&(t.typeAnnotation=s,this.resetEndLocation(t)),this.expect(p.parenR),t},A.parseClass=function(t,e){var s=this.inAbstractClass;this.inAbstractClass=!!t.abstract;try{this.next(),this.takeDecorators(t);var i=this.strict;this.strict=!0,this.parseClassId(t,e),this.parseClassSuper(t);var r=this.enterClassBody(),a=this.startNode(),n=!1;a.body=[];var o=[];for(this.expect(p.braceL);this.type!==p.braceR;)if(this.match(_.at))o.push(this.parseDecorator());else{var h=this.parseClassElement(null!==t.superClass);o.length&&(h.decorators=o,this.resetStartLocationFromNode(h,o[0]),o=[]),h&&(a.body.push(h),"MethodDefinition"===h.type&&"constructor"===h.kind&&"FunctionExpression"===h.value.type?(n&&this.raiseRecoverable(h.start,"Duplicate constructor in the same class"),n=!0,h.decorators&&h.decorators.length>0&&this.raise(h.start,"Decorators can't be used with a constructor. Did you mean '@dec class { ... }'?")):h.key&&"PrivateIdentifier"===h.key.type&&v(r,h)&&this.raiseRecoverable(h.key.start,"Identifier '#"+h.key.name+"' has already been declared"))}return this.strict=i,this.next(),o.length&&this.raise(this.start,"Decorators must be attached to a class element."),t.body=this.finishNode(a,"ClassBody"),this.exitClassBody(),this.finishNode(t,e?"ClassDeclaration":"ClassExpression")}finally{this.inAbstractClass=s}},A.parseClassFunctionParams=function(){var t=this.tsTryParseTypeParameters(this.tsParseConstModifier),e=this.parseBindingList(p.parenR,!1,this.options.ecmaVersion>=8,!0);return t&&(e.typeParameters=t),e},A.parseMethod=function(t,e,s,i,r){var a=this.startNode(),n=this.yieldPos,o=this.awaitPos,h=this.awaitIdentPos;if(this.initFunction(a),this.options.ecmaVersion>=6&&(a.generator=t),this.options.ecmaVersion>=8&&(a.async=!!e),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(64|w(e,a.generator)|(s?128:0)),this.expect(p.parenL),a.params=this.parseClassFunctionParams(),this.checkYieldAwaitInDefaultParams(),this.parseFunctionBody(a,!1,!0,!1,{isClassMethod:i}),this.yieldPos=n,this.awaitPos=o,this.awaitIdentPos=h,r&&r.abstract&&a.body){var c=r.key;this.raise(r.start,b.AbstractMethodHasImplementation({methodName:"Identifier"!==c.type||r.computed?"["+this.input.slice(c.start,c.end)+"]":c.name}))}return this.finishNode(a,"FunctionExpression")},e.parse=function(t,e){if(!1===e.locations)throw new Error("You have to enable options.locations while using acorn-typescript");e.locations=!0;var s=new this(e,t);return r&&(s.isAmbientContext=!0),s.parse()},e.parseExpressionAt=function(t,e,s){if(!1===s.locations)throw new Error("You have to enable options.locations while using acorn-typescript");s.locations=!0;var i=new this(s,t,e);return r&&(i.isAmbientContext=!0),i.nextToken(),i.parseExpression()},A.parseImportSpecifier=function(){if(this.ts_isContextual(_.type)){var e=this.startNode();return e.imported=this.parseModuleExportName(),this.parseTypeOnlyImportExportSpecifier(e,!0,"type"===this.importOrExportOuterKind),this.finishNode(e,"ImportSpecifier")}var s=t.prototype.parseImportSpecifier.call(this);return s.importKind="value",s},A.parseExportSpecifier=function(e){var s=this.ts_isContextual(_.type);if(!this.match(p.string)&&s){var i=this.startNode();return i.local=this.parseModuleExportName(),this.parseTypeOnlyImportExportSpecifier(i,!1,"type"===this.importOrExportOuterKind),this.finishNode(i,"ExportSpecifier"),this.checkExport(e,i.exported,i.exported.start),i}var r=t.prototype.parseExportSpecifier.call(this,e);return r.exportKind="value",r},A.parseTypeOnlyImportExportSpecifier=function(e,s,i){var r,a=s?"imported":"local",n=s?"local":"exported",o=e[a],h=!1,p=!0,c=o.start;if(this.isContextual("as")){var l=this.parseIdent();if(this.isContextual("as")){var u=this.parseIdent();U(this.type)?(h=!0,o=l,r=s?this.parseIdent():this.parseModuleExportName(),p=!1):(r=u,p=!1)}else U(this.type)?(p=!1,r=s?this.parseIdent():this.parseModuleExportName()):(h=!0,o=l)}else U(this.type)&&(h=!0,s?(o=t.prototype.parseIdent.call(this,!0),this.isContextual("as")||this.checkUnreserved(o)):o=this.parseModuleExportName());h&&i&&this.raise(c,s?b.TypeModifierIsUsedInTypeImports:b.TypeModifierIsUsedInTypeExports),e[a]=o,e[n]=r,e[s?"importKind":"exportKind"]=h?"type":"value",p&&this.eatContextual("as")&&(e[n]=s?this.parseIdent():this.parseModuleExportName()),e[n]||(e[n]=this.copyNode(e[a])),s&&this.checkLValSimple(e[n],2)},A.raiseCommonCheck=function(e,s,i){return"Comma is not permitted after the rest element"===s?this.isAmbientContext&&this.match(p.comma)&&41===this.lookaheadCharCode()?void this.next():t.prototype.raise.call(this,e,s):i?t.prototype.raiseRecoverable.call(this,e,s):t.prototype.raise.call(this,e,s)},A.raiseRecoverable=function(t,e){return this.raiseCommonCheck(t,e,!0)},A.raise=function(t,e){return this.raiseCommonCheck(t,e,!0)},A.updateContext=function(e){var s=this.type;if(s==p.braceL){var i=this.curContext();i==R.tc_oTag?this.context.push(M.b_expr):i==R.tc_expr?this.context.push(M.b_tmpl):t.prototype.updateContext.call(this,e),this.exprAllowed=!0}else{if(s!==p.slash||e!==_.jsxTagStart)return t.prototype.updateContext.call(this,e);this.context.length-=2,this.context.push(R.tc_cTag),this.exprAllowed=!1}},A.jsx_parseOpeningElementAt=function(t,e){var s=this,i=this.startNodeAt(t,e),r=this.jsx_parseElementName();if(r&&(i.name=r),this.match(p.relational)||this.match(p.bitShift)){var a=this.tsTryParseAndCatch(function(){return s.tsParseTypeArgumentsInExpression()});a&&(i.typeParameters=a)}for(i.attributes=[];this.type!==p.slash&&this.type!==_.jsxTagEnd;)i.attributes.push(this.jsx_parseAttribute());return i.selfClosing=this.eat(p.slash),this.expect(_.jsxTagEnd),this.finishNode(i,r?"JSXOpeningElement":"JSXOpeningFragment")},A.enterScope=function(e){e===f&&this.importsStack.push([]),t.prototype.enterScope.call(this,e);var s=t.prototype.currentScope.call(this);s.types=[],s.enums=[],s.constEnums=[],s.classes=[],s.exportOnlyBindings=[]},A.exitScope=function(){t.prototype.currentScope.call(this).flags===f&&this.importsStack.pop(),t.prototype.exitScope.call(this)},A.hasImport=function(t,e){var s=this.importsStack.length;if(this.importsStack[s-1].indexOf(t)>-1)return!0;if(!e&&s>1)for(var i=0;i<s-1;i++)if(this.importsStack[i].indexOf(t)>-1)return!0;return!1},A.maybeExportDefined=function(t,e){this.inModule&&1&t.flags&&this.undefinedExports.delete(e)},A.isRedeclaredInScope=function(e,s,i){return!!(0&i)&&(2&i?e.lexical.indexOf(s)>-1||e.functions.indexOf(s)>-1||e.var.indexOf(s)>-1:3&i?e.lexical.indexOf(s)>-1||!t.prototype.treatFunctionsAsVarInScope.call(this,e)&&e.var.indexOf(s)>-1:e.lexical.indexOf(s)>-1&&!(32&e.flags&&e.lexical[0]===s)||!this.treatFunctionsAsVarInScope(e)&&e.functions.indexOf(s)>-1)},A.checkRedeclarationInScope=function(t,e,s,i){this.isRedeclaredInScope(t,e,s)&&this.raise(i,"Identifier '"+e+"' has already been declared.")},A.declareName=function(e,s,i){if(4096&s)return this.hasImport(e,!0)&&this.raise(i,"Identifier '"+e+"' has already been declared."),void this.importsStack[this.importsStack.length-1].push(e);var r=this.currentScope();if(1024&s)return this.maybeExportDefined(r,e),void r.exportOnlyBindings.push(e);t.prototype.declareName.call(this,e,s,i),0&s&&(0&s||(this.checkRedeclarationInScope(r,e,s,i),this.maybeExportDefined(r,e)),r.types.push(e)),256&s&&r.enums.push(e),512&s&&r.constEnums.push(e),128&s&&r.classes.push(e)},A.checkLocalExport=function(e){var s=e.name;if(!this.hasImport(s)){for(var i=this.scopeStack.length-1;i>=0;i--){var r=this.scopeStack[i];if(r.types.indexOf(s)>-1||r.exportOnlyBindings.indexOf(s)>-1)return}t.prototype.checkLocalExport.call(this,e)}},s=e,g=[{key:"acornTypeScript",get:function(){return n}}],(m=[{key:"acornTypeScript",get:function(){return n}}])&&a(s.prototype,m),g&&a(s,g),Object.defineProperty(s,"prototype",{writable:!1}),e}(s);return z}}export{D as default,D as tsPlugin};