sveld 0.40.6 → 0.41.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,99 +1,16 @@
1
1
  # sveld
2
2
 
3
- [![NPM][npm]][npm-url]
4
- ![npm downloads to date](https://img.shields.io/npm/dt/sveld?color=262626&style=for-the-badge)
3
+ Generate TypeScript definitions and component documentation for your Svelte components.
5
4
 
6
- `sveld` generates TypeScript definitions and component documentation (JSON and Markdown) for Svelte component libraries. It statically analyzes props, events, slots, snippets, context, module exports, and rest props, and reads [JSDoc](https://jsdoc.app/) where inference isn't enough.
7
-
8
- The generated `.d.ts` files give consumers autocomplete and type checking through the Svelte Language Server and TypeScript, with little effort from the library author. [Carbon Components Svelte](https://github.com/carbon-design-system/carbon-components-svelte) uses sveld to generate its component types and API metadata.
9
-
10
- sveld supports Svelte 3, Svelte 4, Svelte 5 without runes (`export let`, `<slot>`, `$$restProps`), and Svelte 5 runes (`$props()`, `$bindable()`, `{@render}`, callback props).
11
-
12
- ## When to use sveld
13
-
14
- If your library is built with SvelteKit's `svelte-package`, it already emits `.d.ts` files through `svelte2tsx`; start there.
15
-
16
- sveld is for:
17
-
18
- - **JavaScript-first libraries.** Components written in plain JavaScript with JSDoc, where you want full editor types without converting to `lang="ts"`.
19
- - **Docs from the same source as the types.** JSON and Markdown API docs, generated in the same run.
20
- - **API drift checks.** `--check` diffs the component API against a committed snapshot and fails CI on breaking changes.
21
- - **Richer types from JSDoc.** `@typedef`, `@callback`, `@slot`, `@event`, and context types that plain inference can't produce.
22
-
23
- `lang="ts"` components work too: sveld keeps their type annotations as written.
24
-
25
- ## Install
26
-
27
- ```sh
28
- npm i -D sveld
29
- # or: pnpm i -D sveld / bun i -D sveld / yarn add -D sveld
30
- ```
31
-
32
- ## Quick start
33
-
34
- sveld reads the `"svelte"` field of your `package.json` as the entry point: the file that re-exports your components.
35
-
36
- ```json
37
- {
38
- "svelte": "./src/index.js"
39
- }
40
- ```
41
-
42
- ### CLI
43
-
44
- ```sh
45
- npx sveld # writes types/*.d.ts
46
- npx sveld --json --markdown # also writes COMPONENT_API.json and COMPONENT_INDEX.md
47
- ```
48
-
49
- Run `npx sveld --help` for every flag. Options can also live in a `sveld.config.js`:
50
-
51
- ```js
52
- // sveld.config.js
53
- import { defineConfig } from "sveld";
54
-
55
- export default defineConfig({
56
- json: true,
57
- markdown: true,
58
- });
59
- ```
60
-
61
- ### Vite plugin
62
-
63
- ```ts
64
- // vite.config.ts
65
- import { svelte } from "@sveltejs/vite-plugin-svelte";
66
- import sveld from "sveld";
67
- import { defineConfig } from "vite";
68
-
69
- export default defineConfig({
70
- plugins: [svelte(), sveld({ json: true })],
71
- });
72
- ```
73
-
74
- The plugin runs during `vite build` (and during `vite dev` with `watch: true`). It also works in Rollup configs.
75
-
76
- ### Node
77
-
78
- ```js
79
- import { sveld } from "sveld";
80
-
81
- const { document, diagnostics, exitCode } = await sveld({
82
- entry: "./src/index.js",
83
- json: true,
84
- });
85
- ```
86
-
87
- `document` is the same component API document `json: true` writes, so you can render your own formats from it. See [Options](docs/options.md) for everything `sveld()` accepts and returns.
88
-
89
- ## Example
90
-
91
- Given this component:
5
+ sveld reads your components' props, events, slots, snippets and context, and the JSDoc where inference isn't enough, and writes `.d.ts` files your users' editors type-check against, plus JSON and Markdown docs from the same pass. It's for JavaScript-first libraries; one built with `svelte-package` already gets `.d.ts` files from `svelte2tsx`. A type it can't pin down falls back to `any`, and `--strict` says where. [Carbon Components Svelte](https://github.com/carbon-design-system/carbon-components-svelte) generates its types and API docs with it.
92
6
 
93
7
  ```svelte
94
- <!-- Button.svelte -->
8
+ <!-- src/Button.svelte -->
95
9
  <script>
10
+ /** @type {"button" | "submit" | "reset"} */
96
11
  export let type = "button";
12
+
13
+ /** Set to `true` to use the primary variant */
97
14
  export let primary = false;
98
15
  </script>
99
16
 
@@ -102,22 +19,18 @@ Given this component:
102
19
  </button>
103
20
  ```
104
21
 
105
- sveld infers prop types and defaults, the forwarded `click` event, the default slot, and the rest props spread onto `<button>`:
106
-
107
22
  ```ts
108
- // types/Button.svelte.d.ts
109
- import { SvelteComponentTyped } from "svelte";
110
- import type { SvelteHTMLElements } from "svelte/elements";
111
-
23
+ // types/Button.svelte.d.ts, from `npx sveld` (imports left out)
112
24
  type $RestProps = SvelteHTMLElements["button"];
113
25
 
114
26
  type $Props = {
115
27
  /**
116
28
  * @default "button"
117
29
  */
118
- type?: string;
30
+ type?: "button" | "submit" | "reset";
119
31
 
120
32
  /**
33
+ * Set to `true` to use the primary variant
121
34
  * @default false
122
35
  */
123
36
  primary?: boolean;
@@ -136,158 +49,79 @@ export default class Button extends SvelteComponentTyped<
136
49
  > {}
137
50
  ```
138
51
 
139
- The default slot is also typed as a `children` snippet prop for Svelte 5 consumers, and the `data-*` index signature lets callers pass data attributes through `$$restProps`.
140
-
141
- Add JSDoc to tighten types and add descriptions:
52
+ **An API change fails CI before it ships.** Commit `COMPONENT_API.json`, and `--check` diffs each run against it:
142
53
 
143
- ```svelte
144
- <script>
145
- /** @type {"button" | "submit" | "reset"} */
146
- export let type = "button";
147
-
148
- /**
149
- * Set to `true` to use the primary variant
150
- */
151
- export let primary = false;
152
- </script>
153
- ```
154
-
155
- ```ts
156
- type $Props = {
157
- /**
158
- * @default "button"
159
- */
160
- type?: "button" | "submit" | "reset";
161
-
162
- /**
163
- * Set to `true` to use the primary variant
164
- * @default false
165
- */
166
- primary?: boolean;
167
-
168
- children?: (this: void) => void;
54
+ ```console
55
+ $ npx sveld --check
56
+ sveld --check: 2 API changes detected against "COMPONENT_API.json".
57
+ Suggested semver bump: major.
169
58
 
170
- [key: `data-${string}`]: unknown;
171
- };
59
+ Button
60
+ [BREAKING] prop "label" added (required)
61
+ [BREAKING] prop "primary" removed
172
62
  ```
173
63
 
174
- The runes version (`let { type = "button", primary = false, children, ...rest } = $props()`, spreading `rest` and rendering `children`) produces the same `$Props`. It has no `click` event, since runes components take `onclick` as a prop through `rest`.
175
-
176
- The `.d.ts` extends `SvelteComponentTyped` by default, which works for consumers on Svelte 3, 4, and 5. Set `typesOptions.format: "component"` (`--types-format=component`) to emit the Svelte 5 `Component` type instead. See [Output](docs/output.md#formats).
177
-
178
- ### JSON and Markdown
64
+ It runs on Node 22 or later, or Bun, and parses Svelte 3, 4 and 5, runes included.
179
65
 
180
- `npx sveld --markdown` documents the same component in `COMPONENT_INDEX.md`:
181
-
182
- ```md
183
- ## `Button`
184
-
185
- ### Props
186
-
187
- | Prop name | Required | Kind | Reactive | Binding | Type | Default value | Description |
188
- | :- | :- | :- | :- | :- | :- | :- | :- |
189
- | type | No | <code>let</code> | No | -- | <code>"button" &#124; "submit" &#124; "reset"</code> | <code>"button"</code> | -- |
190
- | primary | No | <code>let</code> | No | -- | <code>boolean</code> | <code>false</code> | Set to `true` to use the primary variant |
191
-
192
- ### Slots
193
-
194
- | Slot name | Default | Props | Fallback | Description |
195
- | :- | :- | :- | :- | :- |
196
- | -- | Yes | <code>Record&lt;string, never> </code> | <code>Click me</code> | -- |
197
-
198
- ### Events
66
+ ## Quick start
199
67
 
200
- | Event name | Type | Detail | Description |
201
- | :- | :- | :- | :- |
202
- | click | forwarded | -- | -- |
68
+ ```sh
69
+ npm i -D sveld
203
70
  ```
204
71
 
205
- `npx sveld --json` writes the same data to `COMPONENT_API.json`, validated by a [JSON Schema](schema/component-api.schema.json) that ships with the package. An excerpt of the prop entry:
206
-
207
72
  ```json
208
73
  {
209
- "name": "type",
210
- "kind": "let",
211
- "type": "\"button\" | \"submit\" | \"reset\"",
212
- "typeSource": "jsdoc",
213
- "value": "\"button\"",
214
- "isRequired": false,
215
- "reactive": false
74
+ "svelte": "./src/index.js"
216
75
  }
217
76
  ```
218
77
 
219
- See [Output](docs/output.md#json-output) for the full shape.
220
-
221
- ## In CI
222
-
223
- Commit `COMPONENT_API.json`, then gate pull requests on API changes and inference gaps:
224
-
225
78
  ```sh
226
- npx sveld --check # exit 3 on a breaking API change against the snapshot
227
- npx sveld --strict # exit 4 when a prop fell back to `any`, a tag was dropped, ...
79
+ npx sveld # writes types/*.d.ts for what src/index.js exports
228
80
  ```
229
81
 
230
- ```
231
- sveld --check: 2 API changes detected against "COMPONENT_API.json".
232
- Suggested semver bump: major.
82
+ Exit status: `0` when done, `1` when the run found problems, `2` when it was called wrong or couldn't finish.
233
83
 
234
- Button
235
- [BREAKING] prop "target" added (required)
236
- [BREAKING] prop "href" removed
237
- ```
84
+ ## Common tasks
238
85
 
239
- See [CI](docs/ci.md) for exit codes, the change classification table, diagnostic codes, and how to ignore a diagnostic.
240
-
241
- ## JSDoc tags
242
-
243
- | Tag | Use it to | Example |
244
- | :--------------------------------------------------------------------- | :-------------------------------------------------------- | :--------------------------------------------- |
245
- | [`@type`](docs/jsdoc-tags.md#type) | Type a prop | `@type {"sm" \| "md" \| "lg"}` |
246
- | [`@default`](docs/jsdoc-tags.md#default) | Override the inferred default shown in docs | `@default () => true` |
247
- | [`@typedef`](docs/jsdoc-tags.md#typedef) | Declare a shared, exported type | `@typedef {{ id: string }} Item` |
248
- | [`@property`](docs/jsdoc-tags.md#property) | Document a field of a `@typedef {object}` or event detail | `@property {string} [label] - Label text` |
249
- | [`@callback`](docs/jsdoc-tags.md#callback) | Declare a function type | `@callback OnChange` + `@param`/`@returns` |
250
- | [`@slot` / `@snippet`](docs/jsdoc-tags.md#slot--snippet) | Type slot or snippet props | `@slot {{ item: Item }} row` |
251
- | [`@event`](docs/jsdoc-tags.md#event) | Type a dispatched event's detail | `@event {{ id: string }} save` |
252
- | [`@param` / `@returns`](docs/jsdoc-tags.md#accessor-props) | Type an exported function | `@param {string} id` |
253
- | [`@restProps`](docs/jsdoc-tags.md#restprops) | Name the element rest props are spread onto | `@restProps {button \| a}` |
254
- | [`@extendProps`](docs/jsdoc-tags.md#extendprops) | Extend another component's props | `@extendProps {"./Button.svelte"} ButtonProps` |
255
- | [`@template` / `@generics`](docs/jsdoc-tags.md#template--generics) | Declare generics in a JS component | `@template {Item} [T=Item]` |
256
- | [`@bindable`](docs/jsdoc-tags.md#bindable) | Document a prop's `bind:` contract | `@bindable writable` |
257
- | [`@deprecated`](docs/jsdoc-tags.md#deprecated) | Mark a prop, event, slot, or export deprecated | `@deprecated Use "size" instead.` |
258
- | [`@ignore` / `@internal`](docs/jsdoc-tags.md#ignore--internal) | Hide from every output | `@internal` |
259
- | [`@since` / `@see` / `@example`](docs/jsdoc-tags.md#since-see-example) | Pass structured tags through to all outputs | `@since 1.2.0` |
260
- | [`{@link}`](docs/jsdoc-tags.md#link) | Link in a description | `{@link https://example.com\|docs}` |
261
- | [`@csspart` / `@cssprop`](docs/jsdoc-tags.md#csspart--cssprop) | Document shadow-DOM styling hooks | `@cssprop {Color} [--bg=white]` |
262
- | [`@sveld-ignore`](docs/ci.md#ignoring-diagnostics) | Suppress a diagnostic | `@sveld-ignore sveld/prop-unknown-type` |
263
- | [`<!-- @component -->`](docs/jsdoc-tags.md#component-comments) | Document the component itself | `<!-- @component Renders a button. -->` |
264
-
265
- Context types come from `setContext` calls with no tag needed. See [Context](docs/jsdoc-tags.md#context).
86
+ ```sh
87
+ # Write the JSON and Markdown docs too
88
+ npx sveld --json --markdown
266
89
 
267
- ## Docs
90
+ # Fail CI on a breaking API change against COMPONENT_API.json
91
+ npx sveld --check
268
92
 
269
- - [Options](docs/options.md): every option and CLI flag, the config file, the Vite plugin, `sveld()` and its result, and `sveld/browser`.
270
- - [JSDoc tags](docs/jsdoc-tags.md): how types are inferred and every tag sveld reads.
271
- - [Output](docs/output.md): `.d.ts` formats, JSON output and schema, Markdown, entry exports, custom element metadata, and custom output formats.
272
- - [CI](docs/ci.md): exit codes, `--check` for API drift, `--strict` and diagnostic codes, and `@example` checking.
273
- - [Troubleshooting](docs/troubleshooting.md)
93
+ # Fail CI where a prop fell back to `any` or a tag was dropped
94
+ npx sveld --strict
274
95
 
275
- Try sveld in the browser at [sveld.onrender.com](https://sveld.onrender.com) (source in [`playground/`](playground)).
96
+ # Every .svelte file under the entry's directory, not just its exports
97
+ npx sveld --glob
276
98
 
277
- ## Requirements
99
+ # Svelte 5's `Component` type instead of a class
100
+ npx sveld --types-format=component
278
101
 
279
- - Node 22 or later, or Bun. sveld is ESM-only.
280
- - A `sveld.config.ts` needs a runtime that strips TypeScript: Bun, or Node 22.18+ / 23.6+.
281
- - The optional [`checkExamples`](docs/ci.md#checking-example-blocks) check for TS/JS examples needs `typescript` 7+ and a `tsconfig.json`. Nothing else loads TypeScript.
282
- - Your installed Svelte version doesn't affect parsing. sveld parses with [svelte-ast](https://github.com/metonym/svelte-ast), kept in parity with `svelte/compiler`.
102
+ # Check the @example blocks against your TypeScript program
103
+ npx sveld --check-examples
104
+ ```
283
105
 
284
- ## Contributing
106
+ With `--format=json`, the `--check` report and an exit-`2` error print as JSON on stdout, each with a `schemaVersion`. The same options go in a `sveld.config.js`, or to the Vite plugin: `sveld({ json: true })` in `vite.config.ts`.
285
107
 
286
- See the [contributing guidelines](CONTRIBUTING.md).
108
+ ## From code
287
109
 
288
- ## License
110
+ ```js
111
+ import { sveld } from "sveld";
289
112
 
290
- [Apache-2.0](LICENSE)
113
+ const { document, diagnostics, exitCode, failures } = await sveld({
114
+ entry: "./src/index.js",
115
+ json: true,
116
+ });
117
+ document.components; // the same document `json: true` writes
118
+ ```
119
+
120
+ ## Docs
291
121
 
292
- [npm]: https://img.shields.io/npm/v/sveld.svg?color=262626&style=for-the-badge
293
- [npm-url]: https://npmjs.com/package/sveld
122
+ - [Options](https://github.com/carbon-design-system/sveld/blob/main/docs/options.md): every option and flag, the config file, the Vite plugin, `sveld()`, `sveld/browser`, and requirements
123
+ - [JSDoc tags](https://github.com/carbon-design-system/sveld/blob/main/docs/jsdoc-tags.md): how types are inferred, and every tag sveld reads
124
+ - [Output](https://github.com/carbon-design-system/sveld/blob/main/docs/output.md): a worked example, `.d.ts` formats, JSON and its schema, Markdown, and custom output
125
+ - [CI](https://github.com/carbon-design-system/sveld/blob/main/docs/ci.md): exit codes, `--check`, `--strict` and diagnostic codes, and `@example` checks
126
+ - [Troubleshooting](https://github.com/carbon-design-system/sveld/blob/main/docs/troubleshooting.md): common problems, and the fix for each
127
+ - [Playground](https://sveld.onrender.com): try it in the browser
package/browser.js CHANGED
@@ -55,7 +55,7 @@ ${" ".repeat(r+2+qp(s.slice(0,t)).length)}^`}).join(`
55
55
  `).length===e.lines.length}function Sr(e,t){if(t<=0)return e;return e.split(`
56
56
  `).slice(0,-t).join(`
57
57
  `).trimEnd()}var oS=new Set(["abstract","access","alias","alpha","arg","argument","async","augments","author","beta","borrows","const","constructs","copyright","defaultValue","description","emits","experimental","exports","external","fires","function","global","import","inner","instance","kind","lends","license","link","listens","member","name","override","package","private","prop","protected","public","readonly","remarks","requires","satisfies","sealed","static","summary","throws","todo","tutorial","typeParam","version","virtual","yields"]),aS=[...pi,...ts,"type","param","returns","typedef","property","callback","template","generics","slot","snippet","event","restProps","extends","extendProps","deprecated","ignore","internal","sveld-ignore","csspart","cssprop"],lS=/;$/;function pS(e){let t=e.trim().replace(lS,"").trimEnd();if(!t.startsWith("{")||!t.endsWith("}"))return!1;return Ke(t,0)===t.length-1}var cS=/[\w$]+/g,uS=new Set(["property","param","returns","return"]);function dS(e,t,n){let i=[e[t].type];for(let s=t+1;uS.has(e[s]?.tag);s++)i.push(e[s].type);let r=new Set(i.join(" ").match(cS));return n.some(({name:s})=>r.has(s))}function fS(e){let t=e.trim();return!t||t==="object"||t==="Object"}function td(e,t){if(t.usedGenericsTag&&t.usedTemplateTag&&!t.warnedMixedGenericsTags){t.warnedMixedGenericsTags=!0;let n=e.componentFilePath?` in ${e.componentFilePath}`:"";console.warn(`Warning: Both @generics and @template tags are used to declare component generics${n}; their declarations are combined in the order encountered.`)}}function nd(e,t,n,i){if(t.seenGenericNames.has(n))D(e,"generics-conflict",n,`Duplicate generic name "${n}".`,i);else t.seenGenericNames.add(n)}function id(e,t,n){if(e.generics){let r=F(e.generics[0],",").map((s)=>s.trim()).indexOf(t.trim());if(r!==-1){let s=F(e.generics[1],",").map((l)=>l.trim());s[r]=n,e.generics=[e.generics[0],s.join(", ")];return}}bi(e,t,n)}function rd(e,{name:t,description:n,tags:i,internal:r,source:s},l,o){if(e.typedefs.has(t))D(e,"typedef-duplicate",t,`Duplicate typedef/callback name "${t}"; the later declaration overwrites the earlier one.`,s);e.typedefs.set(t,{type:l,name:t,description:n||void 0,ts:o,tags:i.length>0?i:void 0,...r?{internal:!0}:{},source:s})}function hS(e,t,n,i,r){let s=t.findIndex((l)=>l.name===n.name);if(s===-1)t.push(n);else{let l=i?` of "${i}"`:"";D(e,"property-duplicate",n.name,`Duplicate property "${n.name}"${l}; the later declaration overwrites the earlier one.`,r),t[s]=n}}class sd{tags;lines;commentDescription;commentDescriptionUsed=!1;isFirstTag=!0;event;typedef;callback;typeDeclaration;attachTrailingTag;pendingTags=[];pendingDeprecated;pendingInternal=!1;pendingTypeParameters=[];lineDescriptions=new Map;tagLineNumbers=new Set;consumedDescriptionLines=new Set;indentedContinuationLines=new Set;trimBodyAbove;trimThisBody;hasSlotOrSnippetTag;hasExtendsTag;ctx;generics;documentsFunction;constructor(e,t,n,i){this.ctx=e,this.generics=t,this.documentsFunction=i;let{tags:r,lines:s}=n;this.tags=r,this.lines=s,this.commentDescription=n.description,this.hasSlotOrSnippetTag=r.some((a)=>a.tag==="slot"||a.tag==="snippet"),this.hasExtendsTag=r.some((a)=>a.tag==="extends"||a.tag==="extendProps");for(let a of r)if(a.lines.length>0)this.tagLineNumbers.add(a.lines[0].number);for(let a of s)if(a.continuesType)this.tagLineNumbers.add(a.number);let l=!1,o=!1;for(let a of s){if(!a.tag&&!a.continuesType&&a.content&&(o||a.content.trim()!=="}"))this.lineDescriptions.set(a.number,a.content);if(a.tag!==void 0||a.continuesType)l=!0;else if(!a.content.trim());else if(l&&(a.indent||o))this.indentedContinuationLines.add(a.number);else l=!1;if(on(a.content))o=!o}}orCommentDescription(e){if(e||!this.isFirstTag||this.commentDescriptionUsed||!this.commentDescription)return e;return this.commentDescriptionUsed=!0,this.commentDescription}typeDeclarationName(e){if(this.pendingTypeParameters.length===0)return iS(e);let t=`${e}<${this.pendingTypeParameters.join(", ")}>`;return this.pendingTypeParameters.length=0,t}joinBlockLines(e,t){let n=t?t.text.split(`
58
- `):[],i=t?.line;for(let r of e){if(i!==void 0&&r-i>1){let l=i+1;while(l<r&&ed(this.lines[l]))l++;if(l===r)for(let o=i+1;o<r;o++)n.push("")}let s=this.lines[r];n.push(s.indent+s.content),i=r}return li(n)}getPrecedingDescription(e){if(e.length===0)return;let t=e[0].number,n=[],i=!1;for(let r=t-1;r>=0;r--){if(this.tagLineNumbers.has(r)||this.indentedContinuationLines.has(r)||this.consumedDescriptionLines.has(r))break;if(this.lineDescriptions.has(r))n.unshift(r),i=!0;else if(i&&!ed(this.lines[r]))break}if(n.length===0)return;for(let r of n)this.consumedDescriptionLines.add(r);return this.trimBodyAbove?.(n[0]),this.joinBlockLines(n)}claimBodyLines(e,t){if(!sS(e)){for(let i=1;i<e.lines.length;i++)this.consumedDescriptionLines.add(e.lines[i].number);return}let n=e.lines[e.lines.length-1].number;this.trimThisBody=(i)=>t(n-i+1)}getTagDescription(e,t,n=!1){let i=Er(e),r=t!==void 0&&rS.has(t.tag)&&!Er(t.lines),s=n&&(t===void 0||!Mo.has(t.tag)),l=[];for(let o=1;o<e.length;o++){let a=e[o];if((r||s)&&!this.indentedContinuationLines.has(a.number))continue;if(!this.lineDescriptions.get(a.number)?.trim()||this.consumedDescriptionLines.has(a.number))continue;l.push(a.number),this.consumedDescriptionLines.add(a.number)}if(l.length===0)return i;return this.joinBlockLines(l,{text:i??"",line:e[es(e)].number})}flagDescriptionAfterEvent(e,t,n,i){let{event:r}=this;if(r===void 0||r.description)return;if(r.tagLine!==void 0&&this.indentedContinuationLines.has(r.tagLine+1))return;if(i?.tag!=="event"&&!Mo.has(i?.tag??""))return;if(Er(n))return;let s=t?`@${e} "${t}"`:`@${e}`;D(this.ctx,"event-description-ambiguous",r.name,`Text after @event "${r.name}" was used as the description of ${s}. Move it above the tag it describes, indent it as a continuation line, or give each event its own comment block.`,_e(this.ctx,n))}takePrecedingDescription(e){let{tag:t,name:n,lines:i}=this.tags[e],r=this.getPrecedingDescription(i);if(r)this.flagDescriptionAfterEvent(t,n,i,this.tags[e-1]);return r}finalizeEvent(){let{ctx:e,event:t}=this;if(t===void 0)return;this.event=void 0;let i=(t.type&&t.type!=="object"&&t.type!=="Object"?t.type:void 0)??(t.properties.length>0?Cn(t.properties,!0):t.type||""),{tagLine:r}=t;if(r!==void 0){let p=this.tags.find((u)=>{let f=u.lines[0]?.number;return f!==void 0&&f>r&&!Mo.has(u.tag)})?.lines[0].number,c=Array.from(this.lineDescriptions.keys()).sort((u,f)=>u-f).filter((u)=>u>r&&(p===void 0||u<p)&&!this.consumedDescriptionLines.has(u)&&this.lineDescriptions.get(u)?.trim());for(let u of c)this.consumedDescriptionLines.add(u);if(c.length>0)t.description=this.joinBlockLines(c,t.description?{text:t.description,line:r}:void 0)}let{name:s,description:l,source:o}=t,a=i===""&&(!e.events.has(s)||e.untypedJsDocEventNames.has(s));if(Qe(e,{name:s,detail:i,has_argument:!1,description:l,deprecated:t.deprecated,tags:t.tags.length>0?t.tags:void 0,internal:t.internal||void 0,source:o}),a)e.untypedJsDocEventNames.add(s);e.eventDescriptions.set(s,l),e.jsDocEventNames.add(s),e.jsDocEventSources.set(s,o),Je(e,"event-no-source",s,t.ignores)}finalizeTypedef(){let{ctx:e,typedef:t}=this;if(t===void 0)return;this.typedef=void 0;let{properties:n}=t,i=n.length>0,r=i?Cn(n,!0):t.type||"{}",s=!i&&t.type&&pS(r)?`interface ${t.name} ${r}`:`type ${t.name} = ${r};`,l=i?n.filter(({name:o})=>!o.includes(".")&&!o.startsWith("[")).map(({name:o,type:a,optional:p,description:c})=>({name:o,type:a,optional:p===!0,...c?{description:c}:{}})):Ge(r,{skipIndexSignatures:!0});if(l)e.typedefMembersByName.set(t.name,l);rd(e,t,r,s)}finalizeCallback(){let{callback:e}=this;if(e===void 0)return;this.callback=void 0;let t=`(${ge(e.params)}) => ${e.returnType||"void"}`;rd(this.ctx,e,t,`type ${e.name} = ${t};`)}openTypeDeclaration(e){let{name:t,lines:n}=this.tags[e],i={name:this.typeDeclarationName(t),source:_e(this.ctx,n),description:this.orCommentDescription(this.getTagDescription(n,this.tags[e+1])||this.takePrecedingDescription(e)),tags:this.pendingTags.splice(0),internal:this.pendingInternal},{tags:r}=i;if(this.pendingDeprecated!==void 0)r.push({name:"deprecated",body:this.pendingDeprecated===!0?"":this.pendingDeprecated}),this.pendingDeprecated=void 0;return this.pendingInternal=!1,this.attachTrailingTag=(s)=>r.push(s),this.isFirstTag=!1,i}readExtends(e,t){let{name:n,lines:i}=this.tags[e];if(this.ctx.extends!==void 0)D(this.ctx,"extend-props-duplicate",n,`A second @extends/@extendProps tag ("${n}") overwrote the first ("${this.ctx.extends.interface}"); only one is used.`,_e(this.ctx,i));this.ctx.extends={interface:n,import:nS.test(t)?JSON.stringify(t):t},this.isFirstTag=!1}readRestProps(e,t){let{name:n,description:i}=this.tags[e],r=n?i?`${n} ${i}`:n:i,s=Lt(r),l=this.orCommentDescription(s||this.takePrecedingDescription(e)),o={type:"Element",name:t,description:l||void 0};if(this.ctx.rest_props=o,s)this.claimBodyLines(this.tags[e],(a)=>{o.description=Lt(Sr(r,a))||void 0});this.isFirstTag=!1}readSlot(e,t){let{tag:n,name:i,lines:r}=this.tags[e],s=i==="-"||n==="snippet"&&i==="children"?void 0:i,l=this.orCommentDescription(this.getTagDescription(r,this.tags[e+1]));if(!l&&this.pendingTags.length===0)l=this.takePrecedingDescription(e);this.isFirstTag=!1;let o=t||"Record<string, never>",a=_e(this.ctx,r);if(!t)D(this.ctx,"slot-missing-type",s||"default",`@${n}${s?` "${s}"`:""} is missing a required {Type} annotation; falling back to "${o}".`,a);let p=this.pendingTags.splice(0),c=et(s);this.ctx.jsDocSlots.set(c,{tag:n,source:a}),_n(this.ctx,{slot_name:s,slot_props:o,slot_description:l||void 0,slot_deprecated:this.pendingDeprecated,slot_tags:p.length>0?p:void 0,slot_internal:this.pendingInternal||void 0,source:a}),this.pendingDeprecated=void 0,this.pendingInternal=!1,this.typeDeclaration=void 0,this.attachTrailingTag=(u)=>{let f=this.ctx.slots.get(c);if(f)f.tags=[...f.tags??[],u]}}readEvent(e,t){let{name:n,lines:i}=this.tags[e],r=Er(i)||this.takePrecedingDescription(e);this.finalizeEvent();let s=this.pendingTags.splice(0);this.event={name:n,type:t,tagLine:i.length>0?i[0].number:void 0,description:this.orCommentDescription(r),source:_e(this.ctx,i),tags:s,internal:this.pendingInternal,deprecated:this.pendingDeprecated,ignores:[],properties:[]},this.pendingInternal=!1,this.pendingDeprecated=void 0,this.typeDeclaration=void 0,this.attachTrailingTag=(l)=>s.push(l),this.isFirstTag=!1}readProperty(e,t){let{name:n,optional:i,default:r,lines:s}=this.tags[e],l=this.getTagDescription(s,this.tags[e+1],this.event!==void 0),o=this.event??(this.typedef&&fS(this.typedef.type)?this.typedef:void 0);if(o===void 0)return;hS(this.ctx,o.properties,{name:n,type:t,description:l,optional:i||!1,default:r},o.name,_e(this.ctx,s))}readTypedef(e,t){this.finalizeTypedef(),this.typedef={...this.openTypeDeclaration(e),type:t,properties:[]},this.typeDeclaration=this.typedef}readCallback(e){this.finalizeCallback(),this.callback={...this.openTypeDeclaration(e),params:[],returnType:void 0},this.typeDeclaration=this.callback}readGenerics(e,t){let{name:n,lines:i}=this.tags[e],r=_e(this.ctx,i);for(let s of F(n,","))nd(this.ctx,this.generics,s.trim(),r);this.generics.usedGenericsTag=!0,td(this.ctx,this.generics),id(this.ctx,n,t||n),this.isFirstTag=!1}readTemplate(e,t){let{tags:n}=this,i=is(n[e],t),r=e+1;while(n[r]?.tag==="template")r++;let s=n[r];if((s?.tag==="typedef"||s?.tag==="callback")&&!s.name.includes("<")&&dS(n,r,i)){this.pendingTypeParameters.push(...i.map(({constraint:o})=>o));return}if(this.hasSlotOrSnippetTag&&!this.hasExtendsTag){this.ctx.deferredSlotBlockGenerics.push(...i);return}if(this.documentsFunction)return;let l=_e(this.ctx,n[e].lines);for(let o of i)nd(this.ctx,this.generics,o.name,l),id(this.ctx,o.name,o.constraint);this.generics.usedTemplateTag=!0,td(this.ctx,this.generics),this.isFirstTag=!1}readDeprecated(e){let{text:t}=this.tags[e],{event:n}=this;if(!n&&this.typeDeclaration){let r={name:"deprecated",body:t};this.typeDeclaration.tags.push(r),this.claimBodyLines(this.tags[e],(s)=>{r.body=Sr(t,s)});return}if((n?n.deprecated:this.pendingDeprecated)!==void 0)return;let i=(r)=>{if(n)n.deprecated=r;else this.pendingDeprecated=r};i(ci(t)),this.claimBodyLines(this.tags[e],(r)=>{i(ci(Sr(t,r)))})}readPassthrough(e){let{tag:t,text:n,lines:i}=this.tags[e],r={name:t,body:n};if(this.claimBodyLines(this.tags[e],(s)=>{r.body=Sr(n,s)}),!pi.has(t)&&!ts.has(t)){let s=oS.has(t)?void 0:Qu(t,aS,t.length<=4?1:2);D(this.ctx,"jsdoc-unknown-tag",t,s?`Unknown JSDoc tag "@${t}"; did you mean "@${s}"? Passed through unchanged.`:`Unknown JSDoc tag "@${t}"; passed through unchanged. If this is a typo, fix the tag name.`,_e(this.ctx,i))}if(this.attachTrailingTag)this.attachTrailingTag(r);else this.pendingTags.push(r)}read(){let{tags:e}=this;for(let i=0;i<e.length;i++){let{tag:r,type:s,name:l,optional:o}=e[i],a=ke(s);switch(this.trimBodyAbove=this.trimThisBody,this.trimThisBody=void 0,r){case"extends":case"extendProps":this.readExtends(i,a);break;case"restProps":this.readRestProps(i,a);break;case"slot":case"snippet":this.readSlot(i,a);break;case"csspart":{let p=this.getTagDescription(e[i].lines,e[i+1]);this.ctx.cssParts.push({name:l,...p?{description:p}:{}});break}case"cssprop":case"cssproperty":{let p=this.getTagDescription(e[i].lines,e[i+1]),c=e[i].default;this.ctx.cssProperties.push({name:l,...a?{type:a}:{},...c===void 0?{}:{default:c},...p?{description:p}:{}});break}case"event":this.readEvent(i,a);break;case"type":if(this.event)this.event.type=a;break;case"param":this.callback?.params.push({name:l,type:a,optional:o||!1});break;case"returns":case"return":if(this.callback)this.callback.returnType=a;break;case"property":this.readProperty(i,a);break;case"typedef":this.readTypedef(i,a);break;case"callback":this.readCallback(i);break;case"generics":this.readGenerics(i,a);break;case"template":this.readTemplate(i,a);break;case"deprecated":this.readDeprecated(i);break;case"ignore":case"internal":if(this.event)this.event.internal=!0;else if(this.typeDeclaration)this.typeDeclaration.internal=!0;else this.pendingInternal=!0;break;case"sveld-ignore":this.event?.ignores.push(l);break;case"enum":case"class":case"implements":case"this":case"namespace":case"memberof":case"module":case"file":case"overview":break;default:this.readPassthrough(i);break}if(Zu.has(r))this.finalizeEvent()}this.finalizeEvent(),this.finalizeTypedef(),this.finalizeCallback();let t=[...this.pendingTags,...this.pendingDeprecated===void 0?[]:[{name:"deprecated"}],...this.pendingInternal?[{name:"internal"}]:[]];if(t.length===0)return;if(!e.some((i)=>i.tag==="event"||Zu.has(i.tag)))return;for(let i of t)D(this.ctx,"jsdoc-tag-dropped",i.name,`@${i.name} could not attach to a @slot/@snippet/@event/@typedef/@callback tag in the same comment block and was dropped.`)}}function od(e,t=e.source){if(!t)return;let n={usedGenericsTag:!1,usedTemplateTag:!1,warnedMixedGenericsTags:!1,seenGenericNames:new Set},i=t.includes("@template")?wa(e):new Set;e.functionDocCommentStarts=i;let r=an(t);for(let s of r)e.jsDocBlocksByStart.set(s.start,s);for(let s of r)new sd(e,n,s,i.has(s.start)).read()}var ld=new Set(["$state","$derived","$effect","$props","$bindable","$inspect","$host"]),mS=Array.from(ld);function ad(e){return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===95||e===36}function yS(e){if(e.includes("\\u"))return!0;for(let t of mS){let n=e.indexOf(t);while(n!==-1){if(!ad(e.charCodeAt(n-1))&&!ad(e.charCodeAt(n+t.length)))return!0;n=e.indexOf(t,n+1)}}return!1}function gS(e,t){for(let n=t.length-1;n>=0;n-=1)if(t[n]?.has(e))return!0;return!1}function xS(e){let t=new Set;switch(e.type){case"FunctionDeclaration":case"FunctionExpression":case"ArrowFunctionExpression":if(e.type!=="ArrowFunctionExpression"&&e.id)t.add(e.id.name);for(let n of e.params)Q(n,t);break;case"BlockStatement":Tr(e.body,t);break;case"CatchClause":Q(e.param,t);break;case"EachBlock":if(Q(e.context,t),e.index)t.add(e.index);break;case"AwaitBlock":Q(e.value,t),Q(e.error,t);break}return t}function Tr(e,t){for(let n of e??[])switch(n.type){case"ImportDeclaration":for(let i of n.specifiers)t.add(i.local.name);break;case"VariableDeclaration":for(let i of n.declarations)Q(i.id,t);break;case"FunctionDeclaration":case"ClassDeclaration":if(n.id?.name)t.add(n.id.name);break;case"ExportNamedDeclaration":if(n.declaration)Tr([n.declaration],t);break;case"BlockStatement":case"BreakStatement":case"ContinueStatement":case"DebuggerStatement":case"DoWhileStatement":case"EmptyStatement":case"ExportAllDeclaration":case"ExportDefaultDeclaration":case"ExpressionStatement":case"ForInStatement":case"ForOfStatement":case"ForStatement":case"IfStatement":case"LabeledStatement":case"ReturnStatement":case"StaticBlock":case"SwitchStatement":case"ThrowStatement":case"TryStatement":case"TSDeclareFunction":case"TSEnumDeclaration":case"TSExportAssignment":case"TSImportEqualsDeclaration":case"TSInterfaceDeclaration":case"TSModuleDeclaration":case"TSNamespaceExportDeclaration":case"TSTypeAliasDeclaration":case"WhileStatement":case"WithStatement":break}}function Oo(e,t){if(!e)return!1;let n=[...t],i=!1;return K(e,{enter(r,s){if(mi(r.type))return re;if(jt(r))n.push(xS(r));if(r.type==="Identifier"&&ld.has(r.name)&&Vr(r,s)&&!gS(r.name,n))return i=!0,en},leave(r){if(jt(r))n.pop()}}),i}function pd(e){if(e.runesOptionOverride!==void 0)return e.runesOptionOverride?"runes":"legacy";let t=e.parsed;if(!t)return"legacy";if(e.source!==void 0&&!yS(e.source))return"legacy";let n=new Set;Tr(t.module?.content.body,n);let i=new Set;return Tr(t.instance?.content.body,i),Oo(t.module,[n])||Oo(t.instance,[n,i])||Oo(t.fragment,[n,i])?"runes":"legacy"}var ES=new Set(["TSAsExpression","TSSatisfiesExpression","TSNonNullExpression","TSTypeAssertion","TSInstantiationExpression"]);function SS(e){if(e.type!=="TSAsExpression"&&e.type!=="TSTypeAssertion")return!1;let t="typeAnnotation"in e?e.typeAnnotation:void 0;return t?.type==="TSTypeReference"&&t.typeName.type==="Identifier"&&t.typeName.name==="const"}function br(e,t){if(!e)return;K(e,{enter(n){if(!ES.has(n.type)||!("expression"in n)||!n.expression)return;let{expression:i}=n;if(typeof i!=="object")return i;let r=t.typeAssertions.get(n);if(t.constAssertions.has(n)||r===void 0&&SS(n))t.constAssertions.add(i);else if(r!==void 0)t.typeAssertions.set(i,r);else if((n.type==="TSAsExpression"||n.type==="TSTypeAssertion")&&"typeAnnotation"in n)t.typeAssertions.set(i,n.typeAnnotation);return i}})}var TS=/\/\/(?<!^[ \t]*\*.*\/\/)\s*@ts-[^\n\r]*/gm;function bS(e){if(!e.includes("@ts-"))return e;let t=e.charCodeAt(0)===65279?1:0,{instance:n,module:i}=Ji(e),r=[n,i].flatMap((o)=>o?[o.content]:[]).sort((o,a)=>o.start-a.start),s="",l=0;for(let{start:o,end:a}of r)s+=e.slice(l,o+t),s+=e.slice(o+t,a+t).replace(TS,""),l=a+t;return s+e.slice(l)}function cd(e,t,n){e.componentFilePath=n;let i=bS(t);e.source=i;let r=Yu(i);if(Il(e,r),e.parsed=r,e.scriptLanguage==="ts")br(r.module,e.typeCasts),br(r.instance,e.typeCasts),br(r.fragment,e.typeCasts);e.syntaxMode=pd(e);let s=r.css,l=s?i.slice(0,s.start)+" ".repeat(s.end-s.start)+i.slice(s.end):i;cs(e,r.module),cs(e,r.instance),od(e,l)}class Bo{ctx=Hr();cleanup(){this.ctx=Hr()}parseSvelteComponent(e,t){let{component:n,pending:i}=this.parse(e,t);if(i)n[Oe]={...n[Oe]??{canonicalPropNames:[],localTypeDeclarations:[],typeImportStatements:[]},...i};return n}parse(e,t){this.cleanup();let n=this.ctx;cd(n,e,t.filePath),lu(n);let i=Vl(n);return eu(n,i)}}var vS=/\.$/,Fo="resolving it needs file access (generateBundle or the CLI)";function CS(e,t={}){let n=e[Oe];if(!n)return e;let{pendingCallDefaultCandidates:i,pendingConstDefaultCandidates:r,pendingContextKeyCandidates:s,pendingDispatchEscapeCandidates:l,deferredEventNoSourceDiagnostics:o,untypedJsDocEventNames:a,...p}=n,c=(i??[]).filter((v)=>v.importSource!==void 0);if(c.length===0&&!r&&!s&&!l&&!o)return e;let u="filePath"in e?e.filePath:void 0,f=t.filePath??(typeof u==="string"?u:""),h=[],m=(v,Y,me,Le)=>{h.push(oi({component:f,kind:"cross-file-unresolved",name:v,message:Y,...me?{source:me}:{},...Le?{ignored:Le}:{}}))},g=(v,Y)=>(v==="props"?e.props:e.moduleExports).find((me)=>me.name===Y)?.source,y=(v)=>v==="props"?"Prop":"Module export";for(let v of s??[]){let Y=dn(v);m(Y,`setContext key \`${Y}\` is imported from "${v.importSource}"; ${Fo}, so the context is omitted.`,v.source)}for(let v of r??[])m(v.propName,`${y(v.location)} "${v.propName}" defaults to \`${dn(v)}\` imported from "${v.importSource}"; ${Fo}, so the default shows the identifier and its type isn't read.`,g(v.location,v.propName));for(let v of c)m(v.propName,`${y(v.location)} "${v.propName}" defaults to \`${v.calleeName}()\` imported from "${v.importSource}"; ${Fo}, so its return type isn't read and the prop falls back to "any".`,g(v.location,v.propName));for(let v of l??[])m(v.calleeText,`\`${v.dispatcherName}\` is passed to \`${v.calleeText}\`, imported from "${v.importSource}"; reading the events it dispatches needs file access (generateBundle or the CLI), so they're omitted.`,v.source,v.ignored);let S=Array.from(new Set((l??[]).map((v)=>`\`${v.calleeText}\``))).join(", "),b=(o??[]).map((v)=>S?{...v,message:`${v.message.replace(vS,"")} in this file; ${S} may dispatch it, but imported helpers aren't read without file access.`}:v),M={...e,diagnostics:[...e.diagnostics??[],...b,...h]};return M[Oe]=p,M}var dd="sveld",fd="0.40.6";var Vo="5.59.1";var hd=1;function rt(e){return e.some((t)=>t.internal)?e.filter((t)=>!t.internal):e}function wS(e){return{...e,props:rt(e.props),moduleExports:rt(e.moduleExports),slots:rt(e.slots),events:rt(e.events),typedefs:rt(e.typedefs),...e.contexts?{contexts:rt(e.contexts).map((t)=>({...t,properties:rt(t.properties)}))}:{}}}function jo(e,t={}){let n=Array.from(e.values(),(s)=>{let{diagnostics:l,...o}=s;return wS(o)}).sort((s,l)=>Ve(s.moduleName,l.moduleName)),i={schemaVersion:hd,generator:{name:dd,version:fd,svelteVersion:Vo},total:n.length,components:n},r=t.entryExports?rt(t.entryExports):void 0;if(r&&r.length>0)i.totalExports=r.length,i.exports=r;return i}var PS=" ",kS=120,_S=/\binterface\s+[A-Za-z_$][\w$]*(\s*<[^{};]*>)?\s*$/,NS=200,xd=/\s/,DS=/\s{2}|[^\S ]/,$S=/["'`{}/]/g,IS=/["'`{};/]/g,Ed=9,Go=10,LS=13,Kn=32,Cr=34,RS=38,Ar=39,MS=40,OS=41,vr=42,md=46,Ho=47,Sd=59,BS=62,FS=91,Uo=92,VS=93,wr=96,qo=123,jS=124,zo=125;function GS(e){return _S.test(HS(e,NS))}var yd=[""];function WS(e){let t=yd[e];if(t===void 0)t=PS.repeat(e),yd[e]=t;return t}function HS(e,t){let n="";for(let i=e.length-1;i>=0&&n.length<t;i--)n=e[i]+n;return n.length>t?n.slice(-t):n}function US(e){if(e.length===0)return!1;let t=e[e.length-1];return t.charCodeAt(t.length-1)===Go}function qS(e){while(e.length>0){let t=e[e.length-1],n=t.length;while(n>0){let i=t.charCodeAt(n-1);if(i!==Kn&&i!==Ed)break;n--}if(n===t.length)return;if(n===0){e.pop();continue}e[e.length-1]=t.slice(0,n);return}}function zS(e){while(e.length>0){let t=e[e.length-1];if(!xd.test(t[t.length-1]))return;let n=t.trimEnd();if(n.length===t.length)return;if(n.length===0){e.pop();continue}e[e.length-1]=n;return}}function KS(e){if(e.includes("{"))return!1;let t=0,n=0;for(let i=0;i<e.length;i++){let r=e.charCodeAt(i);if(t!==0){if(r===t&&e.charCodeAt(i-1)!==Uo)t=0;continue}if(r===Cr||r===Ar||r===wr){t=r;continue}if(r===Sd&&++n>=2)return!0}return!1}function JS(e){if(!DS.test(e))return e.trimEnd();let t="",n=null,i=!1;for(let r=0;r<e.length;r++){let s=e[r],l=e[r-1];if(n){if(t+=s,n==="double"&&s==='"'&&l!=="\\"||n==="single"&&s==="'"&&l!=="\\"||n==="template"&&s==="`"&&l!=="\\")n=null;i=!1;continue}if(s==='"'||s==="'"||s==="`"){n=s==='"'?"double":s==="'"?"single":"template",t+=s,i=!1;continue}if(xd.test(s)){if(!i&&t.length>0)t+=" ",i=!0;continue}t+=s,i=!1}return t.trimEnd()}function Td(e,t){let n=e[t],i=e.indexOf(n,t+1);while(i!==-1&&e.charCodeAt(i-1)===Uo)i=e.indexOf(n,i+1);return i}function bd(e,t){let n=e.indexOf("*/",t+1);return n===-1?-1:n+1}function XS(e){let t=new Map,n=[],i=$S,r=0;while(r<e.length){if(i.lastIndex=r,!i.test(e))break;r=i.lastIndex-1;let s=e.charCodeAt(r);if(s===Ho){if(e.charCodeAt(r+1)===vr){let l=bd(e,r);if(l===-1)break;r=l}}else if(s===Cr||s===Ar||s===wr){let l=Td(e,r);if(l===-1)break;r=l}else if(s===qo)n.push(r);else if(s===zo){let l=n.pop();if(l!==void 0)t.set(l,r)}r++}return t}function YS(e,t,n){for(let i=t;i<n;i++)if(!Wo(e.charCodeAt(i)))return!1;return!0}function Wo(e){if(e<=Kn)return e===Kn||e>=Ed&&e<=LS;if(e<160)return!1;return e===160||e===5760||e>=8192&&e<=8202||e===8232||e===8233||e===8239||e===8287||e===12288||e===65279}function vd(e,t,n,i){let r=[],s=IS,l=t,o=t;while(o<n){if(s.lastIndex=o,!s.test(e))break;if(o=s.lastIndex-1,o>=n)break;let a=e.charCodeAt(o);if(a===Ho){if(e.charCodeAt(o+1)===vr){let p=bd(e,o);if(p===-1)break;o=p}o++;continue}if(a===Cr||a===Ar||a===wr){let p=Td(e,o);if(p===-1)break;o=p+1;continue}if(a===qo){let p=i.get(o);if(p===void 0||p>=n){o++;continue}if(l<o)r.push(e.slice(l,o));let c=o+1;if(YS(e,c,p)){r.push("{}"),o=p+1,l=o;continue}let u=e.slice(c,p),f=e.charCodeAt(c)===Go;if(!f&&!u.includes("/*")&&!KS(u)&&!GS(r)){let h=vd(e,c,p,i),m=h.trim();if(!m.includes(`
58
+ `):[],i=t?.line;for(let r of e){if(i!==void 0&&r-i>1){let l=i+1;while(l<r&&ed(this.lines[l]))l++;if(l===r)for(let o=i+1;o<r;o++)n.push("")}let s=this.lines[r];n.push(s.indent+s.content),i=r}return li(n)}getPrecedingDescription(e){if(e.length===0)return;let t=e[0].number,n=[],i=!1;for(let r=t-1;r>=0;r--){if(this.tagLineNumbers.has(r)||this.indentedContinuationLines.has(r)||this.consumedDescriptionLines.has(r))break;if(this.lineDescriptions.has(r))n.unshift(r),i=!0;else if(i&&!ed(this.lines[r]))break}if(n.length===0)return;for(let r of n)this.consumedDescriptionLines.add(r);return this.trimBodyAbove?.(n[0]),this.joinBlockLines(n)}claimBodyLines(e,t){if(!sS(e)){for(let i=1;i<e.lines.length;i++)this.consumedDescriptionLines.add(e.lines[i].number);return}let n=e.lines[e.lines.length-1].number;this.trimThisBody=(i)=>t(n-i+1)}getTagDescription(e,t,n=!1){let i=Er(e),r=t!==void 0&&rS.has(t.tag)&&!Er(t.lines),s=n&&(t===void 0||!Mo.has(t.tag)),l=[];for(let o=1;o<e.length;o++){let a=e[o];if((r||s)&&!this.indentedContinuationLines.has(a.number))continue;if(!this.lineDescriptions.get(a.number)?.trim()||this.consumedDescriptionLines.has(a.number))continue;l.push(a.number),this.consumedDescriptionLines.add(a.number)}if(l.length===0)return i;return this.joinBlockLines(l,{text:i??"",line:e[es(e)].number})}flagDescriptionAfterEvent(e,t,n,i){let{event:r}=this;if(r===void 0||r.description)return;if(r.tagLine!==void 0&&this.indentedContinuationLines.has(r.tagLine+1))return;if(i?.tag!=="event"&&!Mo.has(i?.tag??""))return;if(Er(n))return;let s=t?`@${e} "${t}"`:`@${e}`;D(this.ctx,"event-description-ambiguous",r.name,`Text after @event "${r.name}" was used as the description of ${s}. Move it above the tag it describes, indent it as a continuation line, or give each event its own comment block.`,_e(this.ctx,n))}takePrecedingDescription(e){let{tag:t,name:n,lines:i}=this.tags[e],r=this.getPrecedingDescription(i);if(r)this.flagDescriptionAfterEvent(t,n,i,this.tags[e-1]);return r}finalizeEvent(){let{ctx:e,event:t}=this;if(t===void 0)return;this.event=void 0;let i=(t.type&&t.type!=="object"&&t.type!=="Object"?t.type:void 0)??(t.properties.length>0?Cn(t.properties,!0):t.type||""),{tagLine:r}=t;if(r!==void 0){let p=this.tags.find((u)=>{let f=u.lines[0]?.number;return f!==void 0&&f>r&&!Mo.has(u.tag)})?.lines[0].number,c=Array.from(this.lineDescriptions.keys()).sort((u,f)=>u-f).filter((u)=>u>r&&(p===void 0||u<p)&&!this.consumedDescriptionLines.has(u)&&this.lineDescriptions.get(u)?.trim());for(let u of c)this.consumedDescriptionLines.add(u);if(c.length>0)t.description=this.joinBlockLines(c,t.description?{text:t.description,line:r}:void 0)}let{name:s,description:l,source:o}=t,a=i===""&&(!e.events.has(s)||e.untypedJsDocEventNames.has(s));if(Qe(e,{name:s,detail:i,has_argument:!1,description:l,deprecated:t.deprecated,tags:t.tags.length>0?t.tags:void 0,internal:t.internal||void 0,source:o}),a)e.untypedJsDocEventNames.add(s);e.eventDescriptions.set(s,l),e.jsDocEventNames.add(s),e.jsDocEventSources.set(s,o),Je(e,"event-no-source",s,t.ignores)}finalizeTypedef(){let{ctx:e,typedef:t}=this;if(t===void 0)return;this.typedef=void 0;let{properties:n}=t,i=n.length>0,r=i?Cn(n,!0):t.type||"{}",s=!i&&t.type&&pS(r)?`interface ${t.name} ${r}`:`type ${t.name} = ${r};`,l=i?n.filter(({name:o})=>!o.includes(".")&&!o.startsWith("[")).map(({name:o,type:a,optional:p,description:c})=>({name:o,type:a,optional:p===!0,...c?{description:c}:{}})):Ge(r,{skipIndexSignatures:!0});if(l)e.typedefMembersByName.set(t.name,l);rd(e,t,r,s)}finalizeCallback(){let{callback:e}=this;if(e===void 0)return;this.callback=void 0;let t=`(${ge(e.params)}) => ${e.returnType||"void"}`;rd(this.ctx,e,t,`type ${e.name} = ${t};`)}openTypeDeclaration(e){let{name:t,lines:n}=this.tags[e],i={name:this.typeDeclarationName(t),source:_e(this.ctx,n),description:this.orCommentDescription(this.getTagDescription(n,this.tags[e+1])||this.takePrecedingDescription(e)),tags:this.pendingTags.splice(0),internal:this.pendingInternal},{tags:r}=i;if(this.pendingDeprecated!==void 0)r.push({name:"deprecated",body:this.pendingDeprecated===!0?"":this.pendingDeprecated}),this.pendingDeprecated=void 0;return this.pendingInternal=!1,this.attachTrailingTag=(s)=>r.push(s),this.isFirstTag=!1,i}readExtends(e,t){let{name:n,lines:i}=this.tags[e];if(this.ctx.extends!==void 0)D(this.ctx,"extend-props-duplicate",n,`A second @extends/@extendProps tag ("${n}") overwrote the first ("${this.ctx.extends.interface}"); only one is used.`,_e(this.ctx,i));this.ctx.extends={interface:n,import:nS.test(t)?JSON.stringify(t):t},this.isFirstTag=!1}readRestProps(e,t){let{name:n,description:i}=this.tags[e],r=n?i?`${n} ${i}`:n:i,s=Lt(r),l=this.orCommentDescription(s||this.takePrecedingDescription(e)),o={type:"Element",name:t,description:l||void 0};if(this.ctx.rest_props=o,s)this.claimBodyLines(this.tags[e],(a)=>{o.description=Lt(Sr(r,a))||void 0});this.isFirstTag=!1}readSlot(e,t){let{tag:n,name:i,lines:r}=this.tags[e],s=i==="-"||n==="snippet"&&i==="children"?void 0:i,l=this.orCommentDescription(this.getTagDescription(r,this.tags[e+1]));if(!l&&this.pendingTags.length===0)l=this.takePrecedingDescription(e);this.isFirstTag=!1;let o=t||"Record<string, never>",a=_e(this.ctx,r);if(!t)D(this.ctx,"slot-missing-type",s||"default",`@${n}${s?` "${s}"`:""} is missing a required {Type} annotation; falling back to "${o}".`,a);let p=this.pendingTags.splice(0),c=et(s);this.ctx.jsDocSlots.set(c,{tag:n,source:a}),_n(this.ctx,{slot_name:s,slot_props:o,slot_description:l||void 0,slot_deprecated:this.pendingDeprecated,slot_tags:p.length>0?p:void 0,slot_internal:this.pendingInternal||void 0,source:a}),this.pendingDeprecated=void 0,this.pendingInternal=!1,this.typeDeclaration=void 0,this.attachTrailingTag=(u)=>{let f=this.ctx.slots.get(c);if(f)f.tags=[...f.tags??[],u]}}readEvent(e,t){let{name:n,lines:i}=this.tags[e],r=Er(i)||this.takePrecedingDescription(e);this.finalizeEvent();let s=this.pendingTags.splice(0);this.event={name:n,type:t,tagLine:i.length>0?i[0].number:void 0,description:this.orCommentDescription(r),source:_e(this.ctx,i),tags:s,internal:this.pendingInternal,deprecated:this.pendingDeprecated,ignores:[],properties:[]},this.pendingInternal=!1,this.pendingDeprecated=void 0,this.typeDeclaration=void 0,this.attachTrailingTag=(l)=>s.push(l),this.isFirstTag=!1}readProperty(e,t){let{name:n,optional:i,default:r,lines:s}=this.tags[e],l=this.getTagDescription(s,this.tags[e+1],this.event!==void 0),o=this.event??(this.typedef&&fS(this.typedef.type)?this.typedef:void 0);if(o===void 0)return;hS(this.ctx,o.properties,{name:n,type:t,description:l,optional:i||!1,default:r},o.name,_e(this.ctx,s))}readTypedef(e,t){this.finalizeTypedef(),this.typedef={...this.openTypeDeclaration(e),type:t,properties:[]},this.typeDeclaration=this.typedef}readCallback(e){this.finalizeCallback(),this.callback={...this.openTypeDeclaration(e),params:[],returnType:void 0},this.typeDeclaration=this.callback}readGenerics(e,t){let{name:n,lines:i}=this.tags[e],r=_e(this.ctx,i);for(let s of F(n,","))nd(this.ctx,this.generics,s.trim(),r);this.generics.usedGenericsTag=!0,td(this.ctx,this.generics),id(this.ctx,n,t||n),this.isFirstTag=!1}readTemplate(e,t){let{tags:n}=this,i=is(n[e],t),r=e+1;while(n[r]?.tag==="template")r++;let s=n[r];if((s?.tag==="typedef"||s?.tag==="callback")&&!s.name.includes("<")&&dS(n,r,i)){this.pendingTypeParameters.push(...i.map(({constraint:o})=>o));return}if(this.hasSlotOrSnippetTag&&!this.hasExtendsTag){this.ctx.deferredSlotBlockGenerics.push(...i);return}if(this.documentsFunction)return;let l=_e(this.ctx,n[e].lines);for(let o of i)nd(this.ctx,this.generics,o.name,l),id(this.ctx,o.name,o.constraint);this.generics.usedTemplateTag=!0,td(this.ctx,this.generics),this.isFirstTag=!1}readDeprecated(e){let{text:t}=this.tags[e],{event:n}=this;if(!n&&this.typeDeclaration){let r={name:"deprecated",body:t};this.typeDeclaration.tags.push(r),this.claimBodyLines(this.tags[e],(s)=>{r.body=Sr(t,s)});return}if((n?n.deprecated:this.pendingDeprecated)!==void 0)return;let i=(r)=>{if(n)n.deprecated=r;else this.pendingDeprecated=r};i(ci(t)),this.claimBodyLines(this.tags[e],(r)=>{i(ci(Sr(t,r)))})}readPassthrough(e){let{tag:t,text:n,lines:i}=this.tags[e],r={name:t,body:n};if(this.claimBodyLines(this.tags[e],(s)=>{r.body=Sr(n,s)}),!pi.has(t)&&!ts.has(t)){let s=oS.has(t)?void 0:Qu(t,aS,t.length<=4?1:2);D(this.ctx,"jsdoc-unknown-tag",t,s?`Unknown JSDoc tag "@${t}"; did you mean "@${s}"? Passed through unchanged.`:`Unknown JSDoc tag "@${t}"; passed through unchanged. If this is a typo, fix the tag name.`,_e(this.ctx,i))}if(this.attachTrailingTag)this.attachTrailingTag(r);else this.pendingTags.push(r)}read(){let{tags:e}=this;for(let i=0;i<e.length;i++){let{tag:r,type:s,name:l,optional:o}=e[i],a=ke(s);switch(this.trimBodyAbove=this.trimThisBody,this.trimThisBody=void 0,r){case"extends":case"extendProps":this.readExtends(i,a);break;case"restProps":this.readRestProps(i,a);break;case"slot":case"snippet":this.readSlot(i,a);break;case"csspart":{let p=this.getTagDescription(e[i].lines,e[i+1]);this.ctx.cssParts.push({name:l,...p?{description:p}:{}});break}case"cssprop":case"cssproperty":{let p=this.getTagDescription(e[i].lines,e[i+1]),c=e[i].default;this.ctx.cssProperties.push({name:l,...a?{type:a}:{},...c===void 0?{}:{default:c},...p?{description:p}:{}});break}case"event":this.readEvent(i,a);break;case"type":if(this.event)this.event.type=a;break;case"param":this.callback?.params.push({name:l,type:a,optional:o||!1});break;case"returns":case"return":if(this.callback)this.callback.returnType=a;break;case"property":this.readProperty(i,a);break;case"typedef":this.readTypedef(i,a);break;case"callback":this.readCallback(i);break;case"generics":this.readGenerics(i,a);break;case"template":this.readTemplate(i,a);break;case"deprecated":this.readDeprecated(i);break;case"ignore":case"internal":if(this.event)this.event.internal=!0;else if(this.typeDeclaration)this.typeDeclaration.internal=!0;else this.pendingInternal=!0;break;case"sveld-ignore":this.event?.ignores.push(l);break;case"enum":case"class":case"implements":case"this":case"namespace":case"memberof":case"module":case"file":case"overview":break;default:this.readPassthrough(i);break}if(Zu.has(r))this.finalizeEvent()}this.finalizeEvent(),this.finalizeTypedef(),this.finalizeCallback();let t=[...this.pendingTags,...this.pendingDeprecated===void 0?[]:[{name:"deprecated"}],...this.pendingInternal?[{name:"internal"}]:[]];if(t.length===0)return;if(!e.some((i)=>i.tag==="event"||Zu.has(i.tag)))return;for(let i of t)D(this.ctx,"jsdoc-tag-dropped",i.name,`@${i.name} could not attach to a @slot/@snippet/@event/@typedef/@callback tag in the same comment block and was dropped.`)}}function od(e,t=e.source){if(!t)return;let n={usedGenericsTag:!1,usedTemplateTag:!1,warnedMixedGenericsTags:!1,seenGenericNames:new Set},i=t.includes("@template")?wa(e):new Set;e.functionDocCommentStarts=i;let r=an(t);for(let s of r)e.jsDocBlocksByStart.set(s.start,s);for(let s of r)new sd(e,n,s,i.has(s.start)).read()}var ld=new Set(["$state","$derived","$effect","$props","$bindable","$inspect","$host"]),mS=Array.from(ld);function ad(e){return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===95||e===36}function yS(e){if(e.includes("\\u"))return!0;for(let t of mS){let n=e.indexOf(t);while(n!==-1){if(!ad(e.charCodeAt(n-1))&&!ad(e.charCodeAt(n+t.length)))return!0;n=e.indexOf(t,n+1)}}return!1}function gS(e,t){for(let n=t.length-1;n>=0;n-=1)if(t[n]?.has(e))return!0;return!1}function xS(e){let t=new Set;switch(e.type){case"FunctionDeclaration":case"FunctionExpression":case"ArrowFunctionExpression":if(e.type!=="ArrowFunctionExpression"&&e.id)t.add(e.id.name);for(let n of e.params)Q(n,t);break;case"BlockStatement":Tr(e.body,t);break;case"CatchClause":Q(e.param,t);break;case"EachBlock":if(Q(e.context,t),e.index)t.add(e.index);break;case"AwaitBlock":Q(e.value,t),Q(e.error,t);break}return t}function Tr(e,t){for(let n of e??[])switch(n.type){case"ImportDeclaration":for(let i of n.specifiers)t.add(i.local.name);break;case"VariableDeclaration":for(let i of n.declarations)Q(i.id,t);break;case"FunctionDeclaration":case"ClassDeclaration":if(n.id?.name)t.add(n.id.name);break;case"ExportNamedDeclaration":if(n.declaration)Tr([n.declaration],t);break;case"BlockStatement":case"BreakStatement":case"ContinueStatement":case"DebuggerStatement":case"DoWhileStatement":case"EmptyStatement":case"ExportAllDeclaration":case"ExportDefaultDeclaration":case"ExpressionStatement":case"ForInStatement":case"ForOfStatement":case"ForStatement":case"IfStatement":case"LabeledStatement":case"ReturnStatement":case"StaticBlock":case"SwitchStatement":case"ThrowStatement":case"TryStatement":case"TSDeclareFunction":case"TSEnumDeclaration":case"TSExportAssignment":case"TSImportEqualsDeclaration":case"TSInterfaceDeclaration":case"TSModuleDeclaration":case"TSNamespaceExportDeclaration":case"TSTypeAliasDeclaration":case"WhileStatement":case"WithStatement":break}}function Oo(e,t){if(!e)return!1;let n=[...t],i=!1;return K(e,{enter(r,s){if(mi(r.type))return re;if(jt(r))n.push(xS(r));if(r.type==="Identifier"&&ld.has(r.name)&&Vr(r,s)&&!gS(r.name,n))return i=!0,en},leave(r){if(jt(r))n.pop()}}),i}function pd(e){if(e.runesOptionOverride!==void 0)return e.runesOptionOverride?"runes":"legacy";let t=e.parsed;if(!t)return"legacy";if(e.source!==void 0&&!yS(e.source))return"legacy";let n=new Set;Tr(t.module?.content.body,n);let i=new Set;return Tr(t.instance?.content.body,i),Oo(t.module,[n])||Oo(t.instance,[n,i])||Oo(t.fragment,[n,i])?"runes":"legacy"}var ES=new Set(["TSAsExpression","TSSatisfiesExpression","TSNonNullExpression","TSTypeAssertion","TSInstantiationExpression"]);function SS(e){if(e.type!=="TSAsExpression"&&e.type!=="TSTypeAssertion")return!1;let t="typeAnnotation"in e?e.typeAnnotation:void 0;return t?.type==="TSTypeReference"&&t.typeName.type==="Identifier"&&t.typeName.name==="const"}function br(e,t){if(!e)return;K(e,{enter(n){if(!ES.has(n.type)||!("expression"in n)||!n.expression)return;let{expression:i}=n;if(typeof i!=="object")return i;let r=t.typeAssertions.get(n);if(t.constAssertions.has(n)||r===void 0&&SS(n))t.constAssertions.add(i);else if(r!==void 0)t.typeAssertions.set(i,r);else if((n.type==="TSAsExpression"||n.type==="TSTypeAssertion")&&"typeAnnotation"in n)t.typeAssertions.set(i,n.typeAnnotation);return i}})}var TS=/\/\/(?<!^[ \t]*\*.*\/\/)\s*@ts-[^\n\r]*/gm;function bS(e){if(!e.includes("@ts-"))return e;let t=e.charCodeAt(0)===65279?1:0,{instance:n,module:i}=Ji(e),r=[n,i].flatMap((o)=>o?[o.content]:[]).sort((o,a)=>o.start-a.start),s="",l=0;for(let{start:o,end:a}of r)s+=e.slice(l,o+t),s+=e.slice(o+t,a+t).replace(TS,""),l=a+t;return s+e.slice(l)}function cd(e,t,n){e.componentFilePath=n;let i=bS(t);e.source=i;let r=Yu(i);if(Il(e,r),e.parsed=r,e.scriptLanguage==="ts")br(r.module,e.typeCasts),br(r.instance,e.typeCasts),br(r.fragment,e.typeCasts);e.syntaxMode=pd(e);let s=r.css,l=s?i.slice(0,s.start)+" ".repeat(s.end-s.start)+i.slice(s.end):i;cs(e,r.module),cs(e,r.instance),od(e,l)}class Bo{ctx=Hr();cleanup(){this.ctx=Hr()}parseSvelteComponent(e,t){let{component:n,pending:i}=this.parse(e,t);if(i)n[Oe]={...n[Oe]??{canonicalPropNames:[],localTypeDeclarations:[],typeImportStatements:[]},...i};return n}parse(e,t){this.cleanup();let n=this.ctx;cd(n,e,t.filePath),lu(n);let i=Vl(n);return eu(n,i)}}var vS=/\.$/,Fo="resolving it needs file access (generateBundle or the CLI)";function CS(e,t={}){let n=e[Oe];if(!n)return e;let{pendingCallDefaultCandidates:i,pendingConstDefaultCandidates:r,pendingContextKeyCandidates:s,pendingDispatchEscapeCandidates:l,deferredEventNoSourceDiagnostics:o,untypedJsDocEventNames:a,...p}=n,c=(i??[]).filter((v)=>v.importSource!==void 0);if(c.length===0&&!r&&!s&&!l&&!o)return e;let u="filePath"in e?e.filePath:void 0,f=t.filePath??(typeof u==="string"?u:""),h=[],m=(v,Y,me,Le)=>{h.push(oi({component:f,kind:"cross-file-unresolved",name:v,message:Y,...me?{source:me}:{},...Le?{ignored:Le}:{}}))},g=(v,Y)=>(v==="props"?e.props:e.moduleExports).find((me)=>me.name===Y)?.source,y=(v)=>v==="props"?"Prop":"Module export";for(let v of s??[]){let Y=dn(v);m(Y,`setContext key \`${Y}\` is imported from "${v.importSource}"; ${Fo}, so the context is omitted.`,v.source)}for(let v of r??[])m(v.propName,`${y(v.location)} "${v.propName}" defaults to \`${dn(v)}\` imported from "${v.importSource}"; ${Fo}, so the default shows the identifier and its type isn't read.`,g(v.location,v.propName));for(let v of c)m(v.propName,`${y(v.location)} "${v.propName}" defaults to \`${v.calleeName}()\` imported from "${v.importSource}"; ${Fo}, so its return type isn't read and the prop falls back to "any".`,g(v.location,v.propName));for(let v of l??[])m(v.calleeText,`\`${v.dispatcherName}\` is passed to \`${v.calleeText}\`, imported from "${v.importSource}"; reading the events it dispatches needs file access (generateBundle or the CLI), so they're omitted.`,v.source,v.ignored);let S=Array.from(new Set((l??[]).map((v)=>`\`${v.calleeText}\``))).join(", "),b=(o??[]).map((v)=>S?{...v,message:`${v.message.replace(vS,"")} in this file; ${S} may dispatch it, but imported helpers aren't read without file access.`}:v),M={...e,diagnostics:[...e.diagnostics??[],...b,...h]};return M[Oe]=p,M}var dd="sveld",fd="0.41.1";var Vo="5.59.1";var hd=1;function rt(e){return e.some((t)=>t.internal)?e.filter((t)=>!t.internal):e}function wS(e){return{...e,props:rt(e.props),moduleExports:rt(e.moduleExports),slots:rt(e.slots),events:rt(e.events),typedefs:rt(e.typedefs),...e.contexts?{contexts:rt(e.contexts).map((t)=>({...t,properties:rt(t.properties)}))}:{}}}function jo(e,t={}){let n=Array.from(e.values(),(s)=>{let{diagnostics:l,...o}=s;return wS(o)}).sort((s,l)=>Ve(s.moduleName,l.moduleName)),i={schemaVersion:hd,generator:{name:dd,version:fd,svelteVersion:Vo},total:n.length,components:n},r=t.entryExports?rt(t.entryExports):void 0;if(r&&r.length>0)i.totalExports=r.length,i.exports=r;return i}var PS=" ",kS=120,_S=/\binterface\s+[A-Za-z_$][\w$]*(\s*<[^{};]*>)?\s*$/,NS=200,xd=/\s/,DS=/\s{2}|[^\S ]/,$S=/["'`{}/]/g,IS=/["'`{};/]/g,Ed=9,Go=10,LS=13,Kn=32,Cr=34,RS=38,Ar=39,MS=40,OS=41,vr=42,md=46,Ho=47,Sd=59,BS=62,FS=91,Uo=92,VS=93,wr=96,qo=123,jS=124,zo=125;function GS(e){return _S.test(HS(e,NS))}var yd=[""];function WS(e){let t=yd[e];if(t===void 0)t=PS.repeat(e),yd[e]=t;return t}function HS(e,t){let n="";for(let i=e.length-1;i>=0&&n.length<t;i--)n=e[i]+n;return n.length>t?n.slice(-t):n}function US(e){if(e.length===0)return!1;let t=e[e.length-1];return t.charCodeAt(t.length-1)===Go}function qS(e){while(e.length>0){let t=e[e.length-1],n=t.length;while(n>0){let i=t.charCodeAt(n-1);if(i!==Kn&&i!==Ed)break;n--}if(n===t.length)return;if(n===0){e.pop();continue}e[e.length-1]=t.slice(0,n);return}}function zS(e){while(e.length>0){let t=e[e.length-1];if(!xd.test(t[t.length-1]))return;let n=t.trimEnd();if(n.length===t.length)return;if(n.length===0){e.pop();continue}e[e.length-1]=n;return}}function KS(e){if(e.includes("{"))return!1;let t=0,n=0;for(let i=0;i<e.length;i++){let r=e.charCodeAt(i);if(t!==0){if(r===t&&e.charCodeAt(i-1)!==Uo)t=0;continue}if(r===Cr||r===Ar||r===wr){t=r;continue}if(r===Sd&&++n>=2)return!0}return!1}function JS(e){if(!DS.test(e))return e.trimEnd();let t="",n=null,i=!1;for(let r=0;r<e.length;r++){let s=e[r],l=e[r-1];if(n){if(t+=s,n==="double"&&s==='"'&&l!=="\\"||n==="single"&&s==="'"&&l!=="\\"||n==="template"&&s==="`"&&l!=="\\")n=null;i=!1;continue}if(s==='"'||s==="'"||s==="`"){n=s==='"'?"double":s==="'"?"single":"template",t+=s,i=!1;continue}if(xd.test(s)){if(!i&&t.length>0)t+=" ",i=!0;continue}t+=s,i=!1}return t.trimEnd()}function Td(e,t){let n=e[t],i=e.indexOf(n,t+1);while(i!==-1&&e.charCodeAt(i-1)===Uo)i=e.indexOf(n,i+1);return i}function bd(e,t){let n=e.indexOf("*/",t+1);return n===-1?-1:n+1}function XS(e){let t=new Map,n=[],i=$S,r=0;while(r<e.length){if(i.lastIndex=r,!i.test(e))break;r=i.lastIndex-1;let s=e.charCodeAt(r);if(s===Ho){if(e.charCodeAt(r+1)===vr){let l=bd(e,r);if(l===-1)break;r=l}}else if(s===Cr||s===Ar||s===wr){let l=Td(e,r);if(l===-1)break;r=l}else if(s===qo)n.push(r);else if(s===zo){let l=n.pop();if(l!==void 0)t.set(l,r)}r++}return t}function YS(e,t,n){for(let i=t;i<n;i++)if(!Wo(e.charCodeAt(i)))return!1;return!0}function Wo(e){if(e<=Kn)return e===Kn||e>=Ed&&e<=LS;if(e<160)return!1;return e===160||e===5760||e>=8192&&e<=8202||e===8232||e===8233||e===8239||e===8287||e===12288||e===65279}function vd(e,t,n,i){let r=[],s=IS,l=t,o=t;while(o<n){if(s.lastIndex=o,!s.test(e))break;if(o=s.lastIndex-1,o>=n)break;let a=e.charCodeAt(o);if(a===Ho){if(e.charCodeAt(o+1)===vr){let p=bd(e,o);if(p===-1)break;o=p}o++;continue}if(a===Cr||a===Ar||a===wr){let p=Td(e,o);if(p===-1)break;o=p+1;continue}if(a===qo){let p=i.get(o);if(p===void 0||p>=n){o++;continue}if(l<o)r.push(e.slice(l,o));let c=o+1;if(YS(e,c,p)){r.push("{}"),o=p+1,l=o;continue}let u=e.slice(c,p),f=e.charCodeAt(c)===Go;if(!f&&!u.includes("/*")&&!KS(u)&&!GS(r)){let h=vd(e,c,p,i),m=h.trim();if(!m.includes(`
59
59
  `)){let g=m.endsWith(";")?m.slice(0,-1):m,y=`{ ${JS(g)} }`;if(y.length<=kS){r.push(y),o=p+1,l=o;continue}}if(r.push("{"),h.charCodeAt(0)!==Sd)r.push(`
60
60
  `);if(h.length>0)r.push(h);o=p,l=p;continue}if(r.push("{"),!f)r.push(`
61
61
  `);o=c,l=c;continue}if(a===zo){if(l<o)r.push(e.slice(l,o));if(qS(r),!US(r))r.push(`