@hyperfixi/engine 4.1.0 → 4.2.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/CHANGELOG.md +184 -1
- package/dist/ast.d.ts +2 -0
- package/dist/commands/platform.d.ts +2 -0
- package/dist/common.js +2 -1
- package/dist/common.min.js +2 -2
- package/dist/core.js +2 -1
- package/dist/core.min.js +2 -2
- package/dist/full.js +3 -2
- package/dist/full.min.js +3 -3
- package/dist/hyperfixi-hs.dev.js +3 -2
- package/dist/hyperfixi-hs.js +3 -3
- package/dist/index.js +3 -2
- package/dist/minimal.js +2 -1
- package/dist/minimal.min.js +2 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,188 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [4.2.0] - 2026-10-07
|
|
11
|
+
|
|
12
|
+
A translation that would lose part of a script is now refused instead of returned short.
|
|
13
|
+
`@lokascript/semantic`'s `translate()` throws a `LossyTranslationError` unless the caller passes
|
|
14
|
+
`{ lossy: 'allow' }`, and the adapter, the Vite plugin's bundle and `@hyperscript-tools/i18n` keep
|
|
15
|
+
the author's text and warn. Upstream forms that translations used to drop now read whole in every
|
|
16
|
+
language: scripts of several features, `catch` / `finally`, conditionals and loops, `bind … and`,
|
|
17
|
+
scoped names such as `element x`, what `on` reads after its event, and clauses a command's
|
|
18
|
+
pattern does not model. On the new command-shape gate, round trips that came back silently
|
|
19
|
+
different fell from 7,614 at its first run to 174 (none in English); 23,763 of 27,240 now read as
|
|
20
|
+
their source does, and 3,303 are refused.
|
|
21
|
+
|
|
22
|
+
### Added
|
|
23
|
+
|
|
24
|
+
- **`@lokascript/semantic` keeps a clause its pattern does not model, as written.** A command's
|
|
25
|
+
pattern read the start of the command and dropped the rest:
|
|
26
|
+
`add .foo to .bar when it matches .doh`, `toggle between .a and .b`,
|
|
27
|
+
`take .foo from .div for #d3`, `render #tmpl into #target`, `log me, my`. The rest is now
|
|
28
|
+
kept on the node as `verbatimClause` and written back after the command in every language, in
|
|
29
|
+
SOV and VSO word order too (ja `クリック を で .bar に .rey を 追加 when it matches .doh` reads
|
|
30
|
+
back as `on click add .rey to .bar when it matches .doh`). So a foreign render can now hold a
|
|
31
|
+
clause in English. A run that holds a command verb, a structure word (`else`, `catch`, `on`, …)
|
|
32
|
+
or a word of the source language (es `cuando`) is not a clause, and its translation is
|
|
33
|
+
refused. The parser records a `verbatim-clause` warning for each kept clause, since no role
|
|
34
|
+
reads it: `@lokascript/compilation-service` reports it as `UNCONSUMED_INPUT` with its repair
|
|
35
|
+
hint, and MCP `validate_hyperscript` lists it with the unconsumed tokens. A pattern group that
|
|
36
|
+
reads its marker and binds no role now gives the marker back, so
|
|
37
|
+
`take .foo from .div for #d3` keeps its `for` and `transition *width from 0px to 100px` its
|
|
38
|
+
`from`.
|
|
39
|
+
- **`@lokascript/semantic` keeps what upstream's `on` reads between the event and the body.**
|
|
40
|
+
`on click elsewhere`, a count (`on click 1`, `on click 1 to 2`), `on mutation of attributes`,
|
|
41
|
+
`on click in #d1`, `on foo queue first` and `on x having threshold 0.1` lost everything after
|
|
42
|
+
the event, so the handler ran on every event, or with a count, on the wrong ones. The run is now
|
|
43
|
+
kept as `EventHandlerSemanticNode.headClause`, written after the whole head in every language
|
|
44
|
+
(ja `クリック を で elsewhere .clicked を 追加`) and reported with the same `verbatim-clause`
|
|
45
|
+
warning. Outside English a count is read only in the `1 to 2` form, since a body there can open
|
|
46
|
+
with a number: a bare count in another language (`on click 1`) is refused.
|
|
47
|
+
- **`@lokascript/semantic` reads `catch` and `finally` in handlers and functions.** In a `def`, the
|
|
48
|
+
clauses ran as more of the function's body, so its error handling ran every time, in silence. In
|
|
49
|
+
a handler, `catch e …` was left unread. `EventHandlerSemanticNode` and `DefSemanticNode` now
|
|
50
|
+
carry `catchName`, `catchBody` and `finallyBody`. A `def` writes its clauses before its `end`,
|
|
51
|
+
and a handler writes them after its commands. No language has its own words for them yet, so
|
|
52
|
+
every language writes English's `catch` and `finally`. `wait a tick` now reads as `wait 0ms`, as
|
|
53
|
+
the engine runs it; every render wrote `wait tick`, a wait on a variable named `tick`.
|
|
54
|
+
- **`@hyperfixi/testing-framework`: the command-shape gate.** It takes the 1,135 scripts in
|
|
55
|
+
upstream _hyperscript's own test suite (0.9.93) and in core's reference and hover examples that
|
|
56
|
+
the engine reads, translates each into the other 23 languages and back (and English to English),
|
|
57
|
+
and has the engine parse the result and the source. A pair passes when the two parses match,
|
|
58
|
+
after a short list of named equivalences that are each checked on both engines. Otherwise it is
|
|
59
|
+
refused (`translate` threw) or silent. The baseline lists the refused and silent pairs and only
|
|
60
|
+
shrinks: the gate fails on a pair worse than listed and on one better. Every silent pair left
|
|
61
|
+
belongs to a named family with a reason (`SILENT_FAMILIES`), and none is in English.
|
|
62
|
+
- **`@hyperfixi/engine`'s parse keeps two values it held only in a closure.** `GoNode.url` holds
|
|
63
|
+
the address of `go to url <address>`, and `SymbolNode.on` the element of `^name on <element>`.
|
|
64
|
+
Two scripts that differed only there parsed to the same tree. Nothing reads them at run time.
|
|
65
|
+
|
|
66
|
+
### Changed
|
|
67
|
+
|
|
68
|
+
- **`@lokascript/semantic`'s `translate()` refuses a translation that would lose part of the
|
|
69
|
+
script.** This is a change in behavior. It used to return what it could render:
|
|
70
|
+
`log it?.dataset?.customValue` came back in Spanish as `registrar ello`, and Hindi wrote
|
|
71
|
+
`put it.name into #r` in a form that reads back as `on its.name put #r into me`. It now throws a
|
|
72
|
+
`LossyTranslationError` carrying `partial` (what it would have returned, not the whole script),
|
|
73
|
+
`loss.kind` and `loss.lost` (what it drops). It refuses when the parse leaves input unread
|
|
74
|
+
(`truncation`); when the output does not read back with the input's commands, roles and `put`
|
|
75
|
+
positions (`read-back`), as when a foreign `wait for <event>` reads back as a time wait; and when
|
|
76
|
+
a string, number, selector, attribute, style or `$` / `:` / `^` name of the input is missing from
|
|
77
|
+
the output (`invariant`). For example,
|
|
78
|
+
`translate('on click ask "Name?" then put it into me', 'en', 'es')` throws with `loss.lost`
|
|
79
|
+
`['ask "Name?"']`, since `ask` has no schema yet. Pass `{ lossy: 'allow' }` as the fourth
|
|
80
|
+
argument to get the partial output instead. The root and
|
|
81
|
+
`@lokascript/semantic/core` export `LossyTranslationError`, `findTranslationLoss` (the same
|
|
82
|
+
checks on a parse and its render) and the types `TranslateOptions`, `TranslationLoss` and
|
|
83
|
+
`TranslationLossKind`. Comments (`--`, `//`) and Bengali's polite verb forms (`টগল করুন`) are now
|
|
84
|
+
read whole, so a correct translation that holds them is not refused.
|
|
85
|
+
`@hyperfixi/core/multilingual`'s `translate` takes the same options and rethrows the refusal. It
|
|
86
|
+
used to return the input unchanged on any error; input that does not parse still comes back
|
|
87
|
+
unchanged.
|
|
88
|
+
- **`@lokascript/hyperscript-adapter`, `@hyperfixi/vite-plugin`'s bundle and
|
|
89
|
+
`@hyperscript-tools/i18n` keep the author's text when a translation would lose part of it.**
|
|
90
|
+
This is a change in behavior. The adapter's full, slim and lite plugins ran the partial English:
|
|
91
|
+
`al clic alternar .foo cuando .bar` ran as `on click toggle .foo`. They now leave the script as
|
|
92
|
+
written, so the host reports a parse error naming code the author wrote, and warn once per
|
|
93
|
+
language with what would be dropped (`cuando .bar`). `preprocess()`'s config takes `onLossy`,
|
|
94
|
+
which is called with the refusal. The Vite plugin's source transform does the same, and its
|
|
95
|
+
`translateHyperscript` rethrows the refusal, where it returned the code unchanged on any error.
|
|
96
|
+
`@hyperscript-tools/i18n`'s lenient mode kept the source text in silence. Now `translateHtml`
|
|
97
|
+
reports a refusal through `onRefused` (`'warn'`, the default, `'error'`, or a callback), the
|
|
98
|
+
Eleventy filters take `'warn'` or `'error'`, and the CLI names the file.
|
|
99
|
+
- **`@hyperfixi/mcp-server`'s translate tools report a refusal.** `translate_code` returns
|
|
100
|
+
`ok: false` with a `LOSSY_TRANSLATION` diagnostic and `loss.lost`, and the partial text under
|
|
101
|
+
`partial`, never `code`. `translate_hyperscript` and `translate_to_english` return
|
|
102
|
+
`refused: true` with `lost` and `partial`. `translate_hyperscript` used to report every error as
|
|
103
|
+
a missing package.
|
|
104
|
+
|
|
105
|
+
### Fixed
|
|
106
|
+
|
|
107
|
+
- **`@lokascript/semantic`: a script of several features reads as one program.** Upstream reads
|
|
108
|
+
each top-level feature on its own. Semantic kept only the first and dropped the rest, or chained
|
|
109
|
+
them with `then`, which neither engine reads: `def a … end def b … end` became one function,
|
|
110
|
+
`def … end on click …` lost its handler, and `bind … end live …` and `set :x to 1 on click …`
|
|
111
|
+
came out joined by `then`. A handler, a `def`, a `behavior`, a feature block, or a top-level
|
|
112
|
+
`bind`, `set`, `install` or `js` now starts a new part of the program, and a top-level `init`
|
|
113
|
+
parses, as a feature block (`FeatureAction` gains `'init'`). English writes one feature per
|
|
114
|
+
line and closes each handler with `end`. It writes a `bind`, `set` or `install` with the `end`
|
|
115
|
+
upstream allows when the next feature has no head word to split at, and joins consecutive
|
|
116
|
+
`install` and `bind` features with a space, never `then`, which the engine rejects.
|
|
117
|
+
- **`@lokascript/semantic`: a dotted name is one name, and a behavior's `end`s are optional.**
|
|
118
|
+
A dotted name is one name: `def utils.foo()` defined `utils` and left `.foo ( )` unread, and
|
|
119
|
+
`behavior App.Widgets.Clickable` did not parse as a behavior. A behavior's last handler needs no
|
|
120
|
+
`end`, nor does the behavior at the end of input: `behavior B(x) on click set @out to x` read as
|
|
121
|
+
a `behavior` command chained to a `set`. A trailing `init` block in such a behavior is its init.
|
|
122
|
+
A behavior member that is neither a handler nor `init`
|
|
123
|
+
(`behavior MarkIt set @data-marked to 'yes' end`) came out as `behavior MarkIt then set …`,
|
|
124
|
+
which the engine rejects; semantic does not model such members yet, so the translation is now
|
|
125
|
+
refused. So is `behavior A … behavior B …` with no `end` between them: upstream reads B as part
|
|
126
|
+
of A, and semantic read it as a `behavior` command in A's last handler.
|
|
127
|
+
- **`@lokascript/semantic`: `bind … and` / `with` and `install`'s arguments read.** Upstream reads
|
|
128
|
+
`bind <left> and|with|to <right>` as the same binding. Only `to` had a pattern, and its left
|
|
129
|
+
side took only a variable, so twelve of upstream's test scripts did not parse, among them
|
|
130
|
+
`bind .dark and $darkMode` and `bind my value and #slider's value`. The left side now takes
|
|
131
|
+
selectors and property paths too. `install Toggleable(cls: 'highlighted')`, the documented
|
|
132
|
+
behaviors usage, lost its arguments: an install's parentheses are arguments, not a signature.
|
|
133
|
+
- **`@lokascript/semantic`: conditionals and loops read whole.** An English pattern read every
|
|
134
|
+
top-level `if X …` as a handler for an event named `X`, so `if x log 1 else log 2 end` became
|
|
135
|
+
`on x log 1 then log 2`. Seven languages read their own `if` the same way (es and fr `si`, pt
|
|
136
|
+
`se`, zh `如果`, sw `kama` / `ikiwa`, id `jika` / `kalau` / `bila`, de `falls`), so every
|
|
137
|
+
conditional rendered in them read back as a handler. A bare `if … end` is now a conditional; de
|
|
138
|
+
`wenn` and `sobald` and id `apabila` still head a handler. An `if` on the line after `else`
|
|
139
|
+
opens its own block, as upstream reads it. Semantic chained the two, so the commands after the
|
|
140
|
+
inner `end` ran whether or not the condition held. Tokens that open a line now carry
|
|
141
|
+
`metadata.lineStart`, and English writes such an `if` on its own line. The `end` of
|
|
142
|
+
`at end of` no longer closes a conditional: in
|
|
143
|
+
`if x put 'a' at end of me end put 'b' at end of me`, the second `put` ran inside the branch. An
|
|
144
|
+
empty block (`if x then end`) stays a conditional, and a condition ends at `else`. `break` and
|
|
145
|
+
`continue` read. A loop whose test follows its body (`repeat … until x end`,
|
|
146
|
+
`repeat … while x end`) is read as one (`LoopSemanticNode.bottomTested`) and written
|
|
147
|
+
`repeat forever … until x end`, which the engine reads as the same loop; before, `repeat set x`
|
|
148
|
+
read as `repeat x times`. `repeat in X` keeps its collection, and `indexed by i` reads as
|
|
149
|
+
`index i`.
|
|
150
|
+
- **`@lokascript/semantic`: a name with its scope is one value, in every language.** Upstream reads
|
|
151
|
+
`global x`, `element x`, `element's x` (and `the element's x`), `local x` and `dom x` as one
|
|
152
|
+
variable, its idiom for a behavior's state; seven of `@hyperfixi/behaviors`' sources use it.
|
|
153
|
+
Semantic read the scope word alone, so the command around it was dropped, in English and in
|
|
154
|
+
every language: `set element x to 10`, `set global x to 10`, `init set dom count to 42`. The
|
|
155
|
+
tokenizers now read the scope word and the name as one token, and every language writes it as
|
|
156
|
+
written, as it writes `$` and `:` names (es `establecer element x a 10`). A scope word alone
|
|
157
|
+
(`set element to 5`) is still a word.
|
|
158
|
+
- **`@lokascript/semantic`: English writes upstream's postfix `unless` and drops `open`'s mode.**
|
|
159
|
+
`toggle .foo unless I match .bar` was written `toggle .foo then unless I match .bar`, and core's
|
|
160
|
+
prefix `unless C X` as it is; upstream rejects both. English now writes the guard after its
|
|
161
|
+
command, and other languages keep their own form. Upstream's `open` is modal, and the engine
|
|
162
|
+
reads `open #d as non-modal` as an expression, `(#d as non) - modal`. English now writes it
|
|
163
|
+
`call #d.show()`, and `open #d as modal` as `open #d`. The reader still accepts core's mode.
|
|
164
|
+
- **`@lokascript/semantic`: a value keeps its spelling.** A call's arguments keep their spacing:
|
|
165
|
+
`call navigator.clipboard.writeText(#input's value)` became `…(#input'svalue)`. A style block
|
|
166
|
+
kept a space between every token, so `font-family` became `font - family`, a subtraction.
|
|
167
|
+
`show`'s strategy argument is read raw, as upstream reads it: `display:inline-block` became
|
|
168
|
+
`display:inline - block`. A swap's strategy slot takes only core's strategy words (`into`,
|
|
169
|
+
`over`, `innerHTML`, …, `morph`), so `swap arr[0] with arr[2]` exchanges two values, as
|
|
170
|
+
upstream reads it; it was written `swap arr of [0] …`. An attribute with its value and a name
|
|
171
|
+
with its index are one value when nothing spaces them: `add @data-foo=baz` and
|
|
172
|
+
`remove :arr[1]` kept only their first part, and `increment arr[1]` read as
|
|
173
|
+
`increment arr by [1]`. Every language writes them as written. The words inside an index are
|
|
174
|
+
the script's: bn wrote the variable `index` in `var[(index-1)..(index+1)]` as `সূচক`.
|
|
175
|
+
- **`@lokascript/semantic`: events, waits and amounts keep what was written.** A quoted event name
|
|
176
|
+
stays quoted (`LiteralValue.quoted`): `trigger "my event"` now round-trips in all 23 languages,
|
|
177
|
+
and `send "hello" to ChatSocket` keeps its quotes. A spaced time unit is read with its number:
|
|
178
|
+
`wait 2 seconds` translated as `wait 2`, which is two milliseconds. A written `by 1` stays and
|
|
179
|
+
an implicit one is never shown: German wrote `um 1` for every increment, and English dropped
|
|
180
|
+
every written `by 1`. `measure` reads its element: `measure #other` became `measure`.
|
|
181
|
+
- **`@hyperfixi/core`'s reference and hover docs teach what the 4.x engine does.** `open`'s
|
|
182
|
+
`as modal` / `as non-modal` mode does nothing on the engine, so the docs drop it and give
|
|
183
|
+
`call #myDialog.show()` for a non-modal dialog. The `swap` example
|
|
184
|
+
`swap innerHTML of #target with result` was core's `put`, but upstream and the engine exchange
|
|
185
|
+
the two values: it is now `swap #a's value with #b's value`, and the hover text reads "Exchanges
|
|
186
|
+
two elements, or two writable values." The `fetch` example is now a template literal,
|
|
187
|
+
``fetch `/api/${id}` as json``, since upstream sends a naked URL's `${id}` as written.
|
|
188
|
+
Translation keeps core's meaning for both old forms: English writes `put result into #target`
|
|
189
|
+
and a template literal. The Japanese example in `docs/EXAMPLES.md` is written as semantic writes
|
|
190
|
+
it, `クリック で 自分 に .active を 切り替え`; the old one left `を 私` unread.
|
|
191
|
+
|
|
10
192
|
## [4.1.0] - 2026-10-06
|
|
11
193
|
|
|
12
194
|
Translations keep what the source says. `tell` blocks, swaps, view transitions, chains of
|
|
@@ -1241,7 +1423,8 @@ _Synchronized version release. See git history for details._
|
|
|
1241
1423
|
- npm access token stored in GitHub Secrets
|
|
1242
1424
|
- 2FA recommended for npm organization
|
|
1243
1425
|
|
|
1244
|
-
[Unreleased]: https://github.com/codetalcott/hyperfixi/compare/v4.
|
|
1426
|
+
[Unreleased]: https://github.com/codetalcott/hyperfixi/compare/v4.2.0...HEAD
|
|
1427
|
+
[4.2.0]: https://github.com/codetalcott/hyperfixi/compare/v4.1.0...v4.2.0
|
|
1245
1428
|
[4.1.0]: https://github.com/codetalcott/hyperfixi/compare/v4.0.1...v4.1.0
|
|
1246
1429
|
[4.0.1]: https://github.com/codetalcott/hyperfixi/compare/v4.0.0...v4.0.1
|
|
1247
1430
|
[4.0.0]: https://github.com/codetalcott/hyperfixi/compare/v3.3.0...v4.0.0
|
package/dist/ast.d.ts
CHANGED
|
@@ -83,6 +83,8 @@ export interface SymbolNode extends Expr {
|
|
|
83
83
|
type: 'symbol';
|
|
84
84
|
name: string;
|
|
85
85
|
scope: Scope;
|
|
86
|
+
/** The element a `^name on <element>` reads and writes. */
|
|
87
|
+
on?: Expr;
|
|
86
88
|
}
|
|
87
89
|
export interface LiteralNode extends Expr {
|
|
88
90
|
type: 'boolean' | 'null' | 'number';
|
package/dist/common.js
CHANGED
|
@@ -1107,6 +1107,7 @@
|
|
|
1107
1107
|
type: "symbol",
|
|
1108
1108
|
name,
|
|
1109
1109
|
scope,
|
|
1110
|
+
...on2 ? { on: on2 } : {},
|
|
1110
1111
|
start,
|
|
1111
1112
|
end: p.endPos(),
|
|
1112
1113
|
ev: (ctx) => resolveSymbol(name, ctx, scope, on2?.ev(ctx)),
|
|
@@ -2733,7 +2734,7 @@
|
|
|
2733
2734
|
cleanup,
|
|
2734
2735
|
/** The part of upstream's `internals` that pages and tests reach for. */
|
|
2735
2736
|
internals: { runtime: { cleanup, processNode } },
|
|
2736
|
-
version: false ? "dev" : "4.
|
|
2737
|
+
version: false ? "dev" : "4.2.0"
|
|
2737
2738
|
});
|
|
2738
2739
|
function boot() {
|
|
2739
2740
|
Object.assign(globalThis, { _hyperscript: api });
|
package/dist/common.min.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
`,r:"\r",t:" ",v:"\v"},V=e=>e>="a"&&e<="z"||e>="A"&&e<="Z",B=e=>e>="0"&&e<="9",Ve=e=>e===" "||e===" "||e==="\r"||e===`
|
|
3
3
|
`,Be=e=>V(e)||B(e)||e==="-"||e==="_"||e===":",ze=e=>V(e)||B(e)||e==="_"||e==="$";function he(e,t=!1){let n=[],r=0,o=0,i=1,s="<START>",u=0,a=()=>e.charAt(r),l=y=>e.charAt(r+y),c=()=>(s=e.charAt(r++),s===`
|
|
4
4
|
`?(i++,o=0):o++,s),p=y=>({type:y,value:"",start:r,end:r+1,line:i,column:o}),f=(y,w)=>(y.value=w,y.end=r,y),d=y=>{let w="";for(;a()&&y(a());)w+=c();return w},m=()=>t&&u===0,h=()=>V(s)||B(s)||")\"'`}]".includes(s),E=(y,w)=>{let A=p(y),L=c();if(a()==="{"){if(A.template=!0,L+=c(),L+=d(yn=>yn!=="}"),a()!=="}")throw new Error("Unterminated "+(w?"class":"id")+" reference");let ve=c();w&&(L+=ve)}else if(w)for(;Be(a())||a()==="\\";)a()==="\\"&&c(),L+=c();else L+=d(Be);return f(A,L)},N=()=>{let y=p("STRING"),w=c();y.template=w==="`";let A="";for(;a()&&a()!==w;)if(a()==="\\"){c();let L=c();if(L in yt)A+=yt[L];else if(y.template&&L==="$")A+="\\$";else if(L==="x"){let ve=a()&&l(1)?parseInt(c()+c(),16):NaN;if(Number.isNaN(ve))throw new Error(`Invalid hexadecimal escape at [Line: ${y.line}, Column: ${y.column}]`);A+=String.fromCharCode(ve)}else A+=L}else A+=c();if(a()!==w)throw new Error(`Unterminated string at [Line: ${y.line}, Column: ${y.column}]`);return c(),f(y,A)},M=()=>{let y=p("IDENTIFIER"),w=c()+d(ze);return a()==="!"&&w==="beep"&&(w+=c()),f(y,w)},P=()=>{let y=p("IDENTIFIER"),w=c(),A=w==="\\";for(A&&(w="");(ze(a())||"\\{}".includes(a()||" "))&&!(a()==="$"&&!A);)a()==="\\"?(A=!0,c()):(A=!1,w+=c());return f(y,w)},O=()=>{let y=p("NUMBER"),w=c()+d(B);return a()==="."&&B(l(1))&&(w+=c()),w+=d(B),(a()==="e"||a()==="E")&&(B(l(1))?w+=c():l(1)==="-"&&(w+=c()+c())),f(y,w+d(B))},I=()=>{let y=p("OP");y.op=!0;let w=c();for(;a()&&ht.has(w+a());)w+=c();return f(y,w)},D=()=>{let y=p("ATTRIBUTE_REF"),w=c();return w==="["?(w+=d(A=>A!=="]"),a()==="]"&&(w+=c())):(w+=d(Be),a()==="="&&(w+=c(),a()==='"'||a()==="'"?w+=N().value:ze(a())&&(w+=M().value))),f(y,w)},te=()=>{let y=n.at(-1);return y?y.type==="IDENTIFIER"||y.type==="CLASS_REF"||y.type==="ID_REF"?!1:!(y.op&&(y.value===">"||y.value===")")):!0},ne=()=>{let y=a(),w=l(2);return(y==="-"||y==="/")&&l(1)===y&&(Ve(w)||w===""||w===y)};for(;r<e.length;){let y=a(),w=l(1);if(ne())d(A=>A!=="\r"&&A!==`
|
|
5
|
-
`),c();else if(Ve(y))n.push(f(p("WHITESPACE"),d(Ve)));else if(!h()&&y==="."&&(V(w)||w==="{"||w==="-"))n.push(E("CLASS_REF",!0));else if(!h()&&y==="#"&&(V(w)||w==="{"))n.push(E("ID_REF",!1));else if(y==="@"||y==="["&&w==="@")n.push(D());else if(y==="*"&&V(w)){let A=p("STYLE_REF");n.push(f(A,c()+d(L=>V(L)||L==="-")))}else if(m()&&(V(y)||y==="\\"))n.push(P());else if(!m()&&(V(y)||y==="_"||y==="$"))n.push(M());else if(B(y))n.push(O());else if(!m()&&(y==='"'||y==="`"))n.push(N());else if(!m()&&y==="'")n.push(te()?N():I());else if(ht.has(y))s==="$"&&y==="{"&&u++,y==="}"&&u--,n.push(I());else if(m()||y==="`"){let A=p("RESERVED");n.push(f(A,c()))}else throw new Error("Unknown token: "+y+" ")}return n}function g(e){return e.match("the"),xn(e)}function xn(e){let t=wt(e),n,r=()=>e.match("and")??e.match("or");for(let o=r();o;o=r())n??=o.value,n!==o.value&&e.err("You must parenthesize logical operations with different operators"),t=bn(o.value,t,wt(e));return t}function bn(e,t,n){let r=e==="or";return{type:"logicalOperator",operator:e,left:t,right:n,start:t.start,end:n.end,ev:o=>x(t.ev(o),i=>!!i===r?i:n.ev(o))}}var kn={"+":(e,t)=>Array.isArray(e)?e.concat(t):b(e)+b(t),"-":(e,t)=>b(e)-b(t),"*":(e,t)=>b(e)*b(t),"/":(e,t)=>b(e)/b(t),mod:(e,t)=>b(e)%b(t)};function Qe(e){let t=Xe(e),n,r=()=>e.matchAnyOp("+","-","*","/")??e.match("mod");for(let o=r();o;o=r()){n??=o.value,n!==o.value&&e.err("You must parenthesize math operations with different operators");let i=t,s=Xe(e),u=kn[o.value];t={type:"mathOperator",operator:o.value,left:i,right:s,start:i.start,end:s.end,ev:l=>T([i.ev(l),s.ev(l)],([c,p])=>u(c,p))}}return t}function Xe(e){let t=z(e);for(let n=!0;n;){n=!1;for(let r of e.g.collections){let o=r(e,t);if(o){t=o,n=!0;break}}}return t}function z(e){e.match("the");let t=e.pos();if(e.match("not"))return Ze(e,"logicalNot",t,z(e),n=>!n);if(e.match("no"))return Ze(e,"noExpression",t,Xe(e),We);for(let n of e.g.unaries){let r=n(e);if(r)return H(e,r)}return Tn(e)}function Ze(e,t,n,r,o,i=t!=="negativeNumber"){let s={type:t,root:r,start:n,end:e.endPos(),ev:u=>x(r.ev(u),a=>o(a,u))};return i?H(e,s):s}var Nn="em ex cap ch ic rem lh rlh vw vh vi vb vmin vmax cm mm Q pc pt px".split(" ");function Tn(e){let t=xt(e),n=e.matchAny(...Nn)??e.matchOp("%");if(n)return gt(e,"stringPostfixExpression",t,n.value);let r=e.matchAny("s","seconds")?1e3:e.matchAny("ms","milliseconds")?1:0;if(r)return gt(e,"timeExpression",t,r);for(let o of e.g.postfixes){let i=o(e,t);if(i)return i}return t}function gt(e,t,n,r){let o=s=>typeof r=="number"?b(s)*r:`${s}${r}`,i={type:t,root:n,suffix:r,start:n.start,end:e.endPos(),ev:s=>x(n.ev(s),o)};return n.stat&&(i.stat=()=>o(ye(n))),i}function xt(e){let t=e.pos();return e.matchOp("-")?Ze(e,"negativeNumber",t,xt(e),n=>-b(n)):Ae(e)}function Ae(e){let t=Sn(e);return t?H(e,t):e.err("Unexpected value: "+e.cur().value)}function se(e){return e.match("the"),Ke(e,Ae(e))}function Ke(e,t){let n=Oe(t);return n.put||e.err(`A target expression must be writable. The expression type '${n.type}' is not.`),n}function Oe(e){let t=e;for(;t.type==="parenthesized"&&"expr"in t&&Cn(t.expr);)t=t.expr;return t}var Cn=e=>q(v(e,"ev"));function ye(e){if(e.stat)return e.stat();throw new Error("This expression cannot be evaluated statically: "+e.type)}function Pn(e){let t=e.matchAnyOp("<",">","<=",">=","==","===","!=","!==");if(t)return{operator:t.value,right:!0,isType:!1};let n=(a,l=!0,c=!1)=>({operator:a,right:l,isType:c}),r=()=>e.match("equal")&&e.match("to"),o=(a,l)=>(e.req("than"),e.match("or")?(e.req("equal"),e.req("to"),n(l)):n(a));if(e.match("is")||e.match("am")){let a=!!e.match("not"),l=a?"not ":"";return e.match("in")?n(l+"in"):e.match("a")||e.match("an")?n(l+"a",!1,!0):e.match("empty")?n(l+"empty",!1):e.match("between")?n(l+"between"):!a&&e.match("less")?o("<","<="):!a&&e.match("greater")?o(">",">="):e.match("really")?(r(),n(a?"!==":"===")):e.match("equal")?(e.match("to"),n(a?"!=":"==")):n(a?"is not":"is")}if(e.match("equals"))return n("==");if(e.match("really"))return e.req("equals"),n("===");if(e.matchAny("exist","exists"))return n("exist",!1);let i=!!e.matchAny("do","does");i&&e.req("not");let s=i?"not ":"",u=(a,l)=>e.match(a)??(i&&a!=="match"&&a!=="contain"?void 0:e.match(l));if(u("match","matches"))return n(s+"match");if(u("contain","contains"))return n(s+"contain");if(i&&e.match("exist"))return n("not exist",!1);if(u("include","includes"))return n(s+"include");if(e.match(i?"start":"starts"))return e.req("with"),n(s+"start with");if(e.match(i?"end":"ends"))return e.req("with"),n(s+"end with");if(u("precede","precedes"))return n(s+"precede");if(u("follow","follows"))return n(s+"follow");i&&e.expected("matches","contains","starts with","ends with","precede","follow")}function wt(e){let t=Qe(e),n=Pn(e);if(!n)return t;let{operator:r}=n,o,i=!0,s,u;n.isType?(o=e.reqType("IDENTIFIER").value,i=!e.matchOp("!")):n.right&&(s=Qe(e),r.endsWith("match")&&(u=s.css));let a;r.endsWith("between")&&(e.req("and"),a=Qe(e));let l=!1;e.match("ignoring")&&(e.req("case"),l=!0);let c=d=>l&&typeof d=="string"?d.toLowerCase():d,p=s?.type==="symbol"&&"scope"in s&&s.scope==="local"&&s.name!=="undefined"&&s.name!=="null"?s.name:void 0;return{type:"comparisonOperator",operator:r,left:t,right:s,right2:a,typeName:o,ignoringCase:l,start:t.start,end:e.endPos(),ev:d=>T([t.ev(d),u??s?.ev(d),a?.ev(d)],([m,h,E])=>{if(o){let N=lt(m,o,i);return r==="a"?N:!N}if(p&&h===void 0&&(r==="is"||r==="is not")){let N=!!ce(m,p);return r==="is"?N:!N}return bt(r,c(m),c(h),E)})}}function vt(e,t){let n=v(e,"contains")??v(e,"includes");if(!q(n))throw new Error("The value does not have a contains or includes method on it");return!!Reflect.apply(n,e,[t])}function Rn(e,t){let n=v(e,"match")??v(e,"matches");if(!q(n))throw new Error("The value does not have a match or matches method on it");return!!Reflect.apply(n,e,[t])}var Et=(e,t,n)=>e instanceof Node&&t instanceof Node&&(e.compareDocumentPosition(t)&n)!==0;function bt(e,t,n,r){if(e==="not between")return b(t)<b(n)||b(t)>b(r);if(e.startsWith("not "))return!bt(e.slice(4),t,n,r);switch(e){case"is":case"==":return t==n;case"is not":case"!=":return t!=n;case"===":return t===n;case"!==":return t!==n;case"<":return b(t)<b(n);case">":return b(t)>b(n);case"<=":return b(t)<=b(n);case">=":return b(t)>=b(n);case"match":return t!=null&&Rn(t,n);case"in":return n!=null&&vt(n,t);case"contain":case"include":return t!=null&&vt(t,n);case"start with":return t!=null&&String(t).startsWith(String(n));case"end with":return t!=null&&String(t).endsWith(String(n));case"between":return b(t)>=b(n)&&b(t)<=b(r);case"precede":return Et(t,n,Node.DOCUMENT_POSITION_FOLLOWING);case"follow":return Et(t,n,Node.DOCUMENT_POSITION_PRECEDING);case"empty":return We(t);case"exist":return ct(t)}throw new Error("Unknown comparison : "+e)}function Sn(e){let t=e.cur();switch(t.type){case"NUMBER":return e.consume(),Ye("number",parseFloat(t.value),t);case"STRING":return In(e);case"ID_REF":return Mn(e);case"CLASS_REF":return Z(e);case"ATTRIBUTE_REF":return Q(e);case"STYLE_REF":return Rt(e)}if(t.op){if(t.value==="(")return An(e);if(t.value==="[")return Ln(e);if(t.value==="{")return et(e);if(t.value==="<")return _n(e)}let n=e.match("true")??e.match("false");if(n)return Ye("boolean",n.value==="true",n);let r=e.match("null");if(r)return Ye("null",null,r);for(let o of e.g.leaves){let i=o(e);if(i)return i}return Ct(e)}function Ye(e,t,n){return{type:e,value:t,start:n.start,end:n.end,ev:()=>t,stat:()=>t}}function An(e){let t=e.pos();e.consume();let n=e.withoutFollows(()=>g(e));return e.reqOp(")"),{type:"parenthesized",expr:n,start:t,end:e.endPos(),ev:r=>n.ev(r)}}var On=(e,t)=>T(e.map(n=>typeof n=="string"?n:n.ev(t)),n=>n.map(r=>r===void 0?"":`${r}`).join(""));function kt(e,t){let n=e.child(he(t,!0),t),r=[],o="";do{o+=n.lastWs();let i=n.cur();if(i.value==="$"){n.consume();let s=n.matchOp("{");r.push(o,g(n)),o="",s&&n.reqOp("}")}else i.value==="\\"?(n.consume(),n.consume()):n.hasMore()&&(o+=n.consume().value)}while(n.hasMore());return r.push(o+n.lastWs()),r}function In(e){let t=e.consume(),n=t.value,r={type:"string",value:n,start:t.start,end:t.end,ev:()=>n};if(t.template){let o=r.parts=kt(e,n);r.ev=i=>On(o,i)}else r.stat=()=>n;return r}function Ln(e){let t=e.pos();e.consume();let n=[];if(!e.matchOp("]")){do n.push(g(e));while(e.matchOp(","));e.reqOp("]")}return{type:"arrayLiteral",values:n,start:t,end:e.endPos(),ev:r=>T(n.map(o=>o.ev(r)),o=>o)}}function et(e){let t=e.pos();e.consume();let n=[],r=[],o=()=>e.cur().op&&e.cur().value==="}";if(!e.matchOp("}")){do{let i=e.matchType("STRING");if(i)n.push(i.value);else if(e.matchOp("["))n.push(g(e)),e.reqOp("]");else{let s="";for(let u=e.matchType("IDENTIFIER")??e.matchOp("-");u;u=e.matchType("IDENTIFIER")??e.matchOp("-"))s+=u.value;n.push(s)}e.reqOp(":"),r.push(g(e))}while(e.matchOp(",")&&!o());e.reqOp("}")}return{type:"objectLiteral",keys:n,values:r,start:t,end:e.endPos(),ev:i=>T([...n.map(s=>typeof s=="string"?s:s.ev(i)),...r.map(s=>s.ev(i))],s=>Object.fromEntries(n.map((u,a)=>[String(s[a]),s[n.length+a]])))}}function Nt(e){if(!e.matchOp("("))return;let t=e.last.start,n=Fn(e,t);return e.reqOp(")"),n.end=e.endPos(),n}function Fn(e,t=e.pos()){let n=[],r=[];if(e.cur().type==="IDENTIFIER")do n.push(e.reqType("IDENTIFIER").value),e.reqOp(":"),r.push(g(e));while(e.matchOp(","));return{type:"namedArgumentList",names:n,values:r,start:t,end:e.endPos(),ev:o=>T(r.map(i=>i.ev(o)),i=>Object.fromEntries([["_namedArgList_",!0],...n.map((s,u)=>[s,i[u]])]))}}function Tt(e){return e.matchType("STRING")?.value??e.consumeUntil(void 0,"WHITESPACE").map(t=>t.value).join("")}function Ct(e){let t=e.pos(),n;e.match("global")?n="global":e.match("element")?(n="element",e.matchOp("'")&&e.req("s")):e.match("dom")?n="inherited":e.match("local")&&(n="local");let r=e.matchOp(":"),o=!r&&e.matchOp("^"),i=e.matchType("IDENTIFIER");if(!i?.value)return;let s=(r?":":o?"^":"")+i.value,a=n??{$:"global",":":"element","^":"inherited"}[s[0]]??"local",l;return a==="inherited"&&e.match("on")&&(l=e.withFollow(["to","into","before","after","then"],()=>g(e))),{type:"symbol",name:s,scope:a,start:t,end:e.endPos(),ev:c=>$e(s,c,a,l?.ev(c)),lhs:()=>{},put:(c,p,f)=>Ue(s,c,a,f,l?.ev(c))}}var Pt=(e,t)=>{let n=t.value.substring(2);return g(e.child(he(n),n))};function Mn(e){let t=e.consume(),n=(o,i)=>He(o.me).getElementById(String(i)),r={type:"idRef",start:t.start,end:t.end,ev:()=>null,lhs:()=>{},put:(o,i,s)=>x(r.ev(o),u=>u&&me(u,s))};if(t.template){let o=r.expr=Pt(e,t);r.ev=i=>x(o.ev(i),s=>n(i,s))}else{let o=r.value=t.value.substring(1);r.css=t.value,r.ev=i=>n(i,o)}return r}function Z(e){let t=e.matchType("CLASS_REF");if(!t)return;let n={type:"classRef",start:t.start,end:t.end,ev:()=>null,lhs:()=>{},put:(r,o,i)=>x(n.ev(r),s=>me(Array.from(s instanceof G?s:[]),i))};if(t.template){let r=n.expr=Pt(e,t);n.ev=o=>x(r.ev(o),i=>new G("."+i,o.me,!0))}else{let r=n.css=t.value;n.className=r.slice(1),n.ev=o=>new G(r,o.me,!0)}return n}var Je=class extends G{constructor(n,r){super("",n);this.parts=r}get css(){let n=0;return this.parts.map(r=>R(r)?`[data-hs-query-id='${n++}']`:`${r??""}`).join("")}select(){let n=this.parts.filter(R);n.forEach((o,i)=>o.setAttribute("data-hs-query-id",String(i)));let r=super.select();return n.forEach(o=>o.removeAttribute("data-hs-query-id")),r}};function _n(e){let t=e.pos();e.consume();let n=e.consumeUntil("/").map(o=>o.type==="STRING"?`"${o.value}"`:o.value).join("");e.reqOp("/"),e.reqOp(">");let r={type:"queryRef",css:n,start:t,end:e.endPos(),ev:o=>new G(n,o.me),lhs:()=>{},put:(o,i,s)=>x(r.ev(o),u=>me(Array.from(u instanceof G?u:[]),s))};if(/\$[^=]/.test(n)){let o=r.parts=kt(e,n);r.ev=i=>T(o.map(s=>typeof s=="string"?s:s.ev(i)),s=>new Je(i.me,s))}return r}function Q(e){let t=e.matchType("ATTRIBUTE_REF");if(!t)return;let n=t.value.startsWith("[")?t.value.slice(2,-1):t.value.slice(1),[r,o]=n.split("="),i=o&&/^["']/.test(o)?o.slice(1,-1):o;return{type:"attributeRef",name:r,value:i,css:`[${n}]`,start:t.start,end:t.end,ev:s=>le(s.you||s.me,r),lhs:()=>{},put:(s,u,a)=>de(s.you||s.me,r,a)}}function Rt(e){let t=e.matchType("STYLE_REF");if(!t)return;let n=t.value.startsWith("*computed-"),r=t.value.slice(n?10:1);return{type:n?"computedStyleRef":"styleRef",name:r,start:t.start,end:t.end,ev:o=>(n?Te:Ne)(o.you||o.me,r),lhs:()=>{},put:(o,i,s)=>Ce(o.you||o.me,r,s)}}function St(e){let t=e.pos();if(!e.matchOp("{"))return;let n=[""],r=[];for(;e.hasMore();){if(e.matchOp("\\"))e.consume();else{if(e.matchOp("}"))break;if(e.match("$")){let o=e.matchOp("{");r.push(g(e)),o&&e.reqOp("}"),n.push("")}else n[n.length-1]+=e.text(e.consume())}n[n.length-1]+=e.lastWs()}return{type:"styleLiteral",parts:n,exprs:r,start:t,end:e.endPos(),ev:o=>T(r.map(i=>i.ev(o)),i=>n.map((s,u)=>s+(u in i?`${i[u]}`:"")).join(""))}}function j(e){let t=e.endPos();return{type:"implicitMeTarget",start:t,end:t,ev:n=>n.you||n.me}}function At(e){let t=e.matchType("IDENTIFIER");if(!t)return;let n=[t.value],r=e.matchOp(".")??e.matchOp(":");if(r)do n.push(e.reqType("IDENTIFIER","NUMBER").value);while(e.matchOp(r.value));return n.join(r?.value??"")}function K(e,t="Expected event name"){return e.matchType("STRING")?.value??At(e)??e.err(t)}function H(e,t){return Dn(e,t)??Hn(e,t)??Un(e,t)??jn(e,t)??Gn(e,t)??Wn(e,t)??$n(e,t)??Bn(e,t)??qn(e,t)??t}function qn(e,t){for(let n of e.g.indirects){let r=n(e,t);if(r)return r}}function Dn(e,t){if(!e.matchOp("."))return;let n=e.reqType("IDENTIFIER").value,r=e.text(t),o={type:"propertyAccess",root:t,prop:n,start:t.start,end:e.endPos(),ev:i=>x(o.root.ev(i),s=>ce(s,n)),lhs:i=>o.root.ev(i),put:(i,s,u)=>{S(s,r),Pe(s,n,u)},del:(i,s)=>{S(s,r),C(s,u=>{_(u)&&delete u[n],k.wroteProperty(u)})}};return H(e,o)}function Hn(e,t){if(!e.match("of"))return;let n=z(e),r,o=t;for(;o.root;)r=o,o=o.root;let s={symbol:"property",attributeRef:"attribute",styleRef:"style",computedStyleRef:"computed"}[o.type],u=o.name;if(!s||u===void 0)return e.err("Cannot take a property of a non-symbol: "+o.type);let a=e.text(n),l={property:ce,attribute:le,style:Ne,computed:Te}[s],c={type:"ofExpression",root:n,name:u,kind:s,start:t.start,end:e.endPos(),ev:p=>x(c.root.ev(p),f=>l(f,u)),lhs:p=>c.root.ev(p),put:(p,f,d)=>{S(f,a),s==="attribute"?de(f,u,d):s==="property"?Pe(f,u,d):Ce(f,u,d)},del:(p,f)=>{S(f,a),C(f,d=>{s==="attribute"?R(d)&&d.removeAttribute(u):s==="property"?(_(d)&&delete d[u],k.wroteProperty(d)):d instanceof HTMLElement&&d.style.removeProperty(u)})}};return r?(r.root=c,H(e,t)):H(e,c)}function jn(e,t){let n=e.matchOp("'"),r=t.type==="symbol"&&["my","its","your"].includes(t.name??"")&&["IDENTIFIER","ATTRIBUTE_REF","STYLE_REF"].includes(e.cur().type);if(!n&&!r)return;n&&e.req("s");let o=Q(e)??Rt(e),i=o?void 0:e.reqType("IDENTIFIER").value,s=e.text(t),u=l=>i!==void 0?ce(l,i):o?.type==="attributeRef"?le(l,o.name):o?.type==="computedStyleRef"?Te(l,o.name):o&&Ne(l,o.name),a={type:"possessive",root:t,prop:i,attribute:o,start:t.start,end:e.endPos(),ev:l=>x(a.root.ev(l),u),lhs:l=>a.root.ev(l),put:(l,c,p)=>{S(c,s),i!==void 0?Pe(c,i,p):o?.type==="attributeRef"?de(c,o.name,p):o&&Ce(c,o.name,p)}};return H(e,a)}function Gn(e,t){if(!e.match("in"))return;let n=z(e),r=(s,u)=>{if(s==null)return[];let a=[],l=v(s,"css");if(typeof l=="string")C(u,c=>R(c)&&a.push(...je(c,l)));else if(R(s)){let c=!1;if(C(u,p=>{p instanceof Node&&p.contains(s)&&(c=!0)}),c)return s}else C(s,c=>C(u,p=>c===p&&a.push(c)));return a},o={type:"inExpression",root:t,target:n,start:t.start,end:e.endPos(),ev:s=>T([o.root.ev(s),n.ev(s)],([u,a])=>r(u,a)),lhs:s=>o.ev(s),put:(s,u,a)=>me(u,a)},i;if(e.peek("where"))for(let s of e.g.collections)i??=s(e,o);return H(e,i??o)}function Wn(e,t){if(!e.match("as"))return;e.match("a")||e.match("an");let n=o=>{let i=At(e)??e.err("Expected dotOrColonPath"),s={type:"asExpression",root:o,conversion:i,start:o.start,end:e.endPos(),ev:u=>x(s.root.ev(u),a=>dt(a,i))};return s},r=n(t);for(;e.matchOp("|");)r=n(r);return H(e,r)}function $n(e,t){if(!e.matchOp("("))return;let n=[];if(!e.matchOp(")")){do n.push(g(e));while(e.matchOp(","));e.reqOp(")")}let r=e.text(t),o=t.root?e.text(t.root):"",i={type:"functionCall",root:t,args:n,start:t.start,end:e.endPos(),ev:s=>{let u=i.root,a=u.prop,l=a===void 0?void 0:u.root;return T([(l??u).ev(s),...n.map(c=>c.ev(s))],([c,...p])=>{if(!l||a===void 0)return Se(c,void 0,p,s,r);S(c,o);let f=Se(v(c,a),c,p,s,r);return be(c,a),f})}};return H(e,i)}function Se(e,t,n,r,o){if(!q(e))throw S(e,o),new Error(`'${o}' is not a function`);return v(e,"hyperfunc")&&n.push(r),Reflect.apply(e,t,n)}function Un(e,t){let n=Q(e);return n&&Vn(e,t,n)}function Vn(e,t,n){let r=e.text(t),o={type:"attributeRefAccess",root:t,attribute:n,start:t.start,end:e.endPos(),ev:i=>x(o.root.ev(i),s=>le(s,n.name)),lhs:i=>o.root.ev(i),put:(i,s,u)=>{S(s,r),de(s,n.name,u)}};return o}function Bn(e,t){if(!e.matchOp("["))return;let n=!!e.matchOp(".."),r=g(e),o=!1,i;!n&&e.matchOp("..")&&(o=!0,e.cur().op&&e.cur().value==="]"||(i=g(e))),e.reqOp("]");let s=e.text(t),u=(c,p)=>b(p)<0?b(v(c,"length"))+b(p):b(p),a=(c,p,f)=>{let d=v(c,"slice");return q(d)?Reflect.apply(d,c,[p,f]):void 0},l={type:"arrayIndex",root:t,first:r,second:i,andBefore:n,andAfter:o,start:t.start,end:e.endPos(),ev:c=>T([l.root.ev(c),r.ev(c),i?.ev(c)],([p,f,d])=>p==null?null:n?a(p,0,u(p,f)+1):o?d==null?a(p,b(f)):a(p,b(f),u(p,d)+1):v(p,String(f))),lhs:c=>T([l.root.ev(c),r.ev(c)],p=>p),put:(c,p,f)=>{let[d,m]=Array.isArray(p)?p:[];S(d,s),_(d)&&(d[String(m)]=f)},del:(c,p)=>{if(n||o)throw new Error("Cannot remove a slice - use a single index");let[f,d]=Array.isArray(p)?p:[];S(f,s),Array.isArray(f)?f.splice(u(f,d),1):_(f)&&delete f[String(d)],k.wroteProperty(f)}};return H(e,l)}function Ie(e){let t=e.pos();if(e.matchOp("(")){let a=Ie(e)??e.err("Expected command");return e.reqOp(")"),a}let n=e.cur(),r=e.g.commands[n.value],o;if(r?o=e.match(n.value)&&r(e,n.value,t):n.type==="IDENTIFIER"&&(o=e.g.pseudo?.(e,t)),!o||!e.match("unless"))return o;let i=o,s=g(e);return{type:"unlessStatementModifier",command:i,condition:s,start:t,end:e.endPos(),run:a=>x(s.ev(a),l=>l?void 0:i.run(a))}}function Y(e){let t=[];for(;e.hasMore();){let n=Ie(e);if(!n)break;t.push(n),e.match("then")}return t}function Ot(e){let t=e.pos();if(e.matchOp("(")){let o=Ot(e);return e.reqOp(")"),o}let n=e.cur(),r=e.g.features[n.value];return!r||!e.match(n.value)?e.err("Expected feature"):r(e,t)}function tt(e){let t=e.pos(),n=[];for(;e.hasMore();){let r=e.cur();if(e.featureStart(r)||r.value==="(")n.push(Ot(e)),e.match("end");else{if(r.value==="end")break;e.err()}}return{type:"hyperscript",features:n,start:t,end:e.endPos()}}function It(e){let t={};return e.match("catch")&&(t.errorSymbol=e.reqType("IDENTIFIER").value,t.errorHandler=Y(e)),e.match("finally")&&(t.finallyHandler=Y(e)),t}function Le(e){let t=[],n=e.tok(1).value,r=e.tok(2).value;if(e.cur().value==="("&&(n===")"||r===","||r===")")){e.matchOp("(");do t.push(e.reqType("IDENTIFIER").value);while(e.matchOp(","));e.reqOp(")")}return t}function Lt(e){e.commands.if=(t,n,r)=>{let o=g(t);t.match("then");let i=Y(t),s,u=!1,a=t.match("else")??t.match("otherwise");if(a)if(u=t.peek("if")?.line===a.line,u){let c=Ie(t);s=c?[c]:[]}else s=Y(t);return t.hasMore()&&!u&&t.req("end"),{type:"ifCommand",condition:o,trueBranch:i,falseBranch:s,start:r,end:t.endPos(),run:c=>x(o.ev(c),p=>p?$(i,c):s&&$(s,c))}}}var zn={k:"return",value:null};function Ft(e){e.commands.halt=(t,n,r)=>{let o=!1;t.match("the")&&(t.req("event"),t.matchOp("'")&&t.req("s"),o=!0);let i=!!t.match("bubbling"),s=!i&&!!t.match("default");return{type:"haltCommand",keepExecuting:o,bubbling:i,haltDefault:s,start:r,end:t.endPos(),run:a=>{let l=a.event;if(l instanceof Event&&(s||l.stopPropagation(),i||l.preventDefault()),!o)return zn}}}}function qt(e){let t=Z(e);if(!t)return;let n=[t];for(let r=Z(e);r;r=Z(e))n.push(r);return n}var nt=(e,t)=>(e??[]).map(n=>x(n.ev(t),r=>String(v(r,"className")))),Qn=e=>e.split(";").map(t=>t.split(":")[0].trim()).filter(Boolean),rt=e=>e instanceof HTMLElement||e instanceof SVGElement?e.style:void 0,Mt=(e,t,n,r,o)=>t?Re(e,t,n,i=>R(i)&&r(i),i=>R(i)&&o(i)):C(e,i=>R(i)&&r(i)),ge=(e,{name:t,value:n},r)=>r?e.setAttribute(t,String(n)):e.removeAttribute(t),Dt=(e,t,n,r,o,i)=>i?Mt(t,n,r,s=>ge(s,i,e),s=>ge(s,i,!e)):T(o.map(s=>Mt(t,n,r,u=>u.classList.toggle(String(s),e),u=>u.classList.toggle(String(s),!e))),()=>{});function Ht(e){let t=qt(e),n=t?void 0:Q(e);return{refs:t,attribute:n,css:t||n?void 0:St(e)}}function jt(e){e.commands.add=(t,n,r)=>{let{refs:o,attribute:i,css:s}=Ht(t),u;!o&&!i&&!s&&(u=t.withFollow(["to"],()=>g(t)),t.cur().value!=="to"&&t.err("Expected either a class reference or attribute expression"));let a=t.match("to")?g(t):j(t),l=t.match("when")?g(t):void 0,c=o||i?l:void 0,p=t.text(a);return{type:"addCommand",classRefs:o,attributeRef:i,css:s,value:u,to:a,when:c,start:r,end:t.endPos(),run:d=>T([a.ev(d),s?.ev(d),u?.ev(d),...nt(o,d)],([m,h,E,...N])=>{if(S(m,p),u){if(Array.isArray(m))m.push(E);else if(m instanceof Set)m.add(E);else throw m instanceof Map?new Error("Use 'set myMap[key] to value' for Maps"):new Error("Cannot add to "+typeof m);k.wroteProperty(m)}else if(s)C(m,M=>{let P=rt(M);P&&(P.cssText+=h)});else return Dt(!0,m,c,d,N,i)})}}}var Yn=e=>e instanceof Node||e instanceof NodeList||e instanceof HTMLCollection;function Gt(e){e.commands.remove=(t,n,r)=>{let{refs:o,attribute:i,css:s}=Ht(t),u=o||i||s?void 0:g(t),a=t.match("from")?g(t):u?void 0:j(t),l;t.match("when")&&(u&&t.err("'when' clause is not supported when removing elements"),l=g(t));let c=a?t.text(a):"",p=u?t.text(u):"",f=(m,h,E)=>{if(E==null&&u?.del&&u.lhs&&!Yn(h)){let N=u;return x(u.lhs(m),M=>N.del?.(m,M))}if(S(h,p),Array.isArray(E)){let N=E.indexOf(h);N>-1&&E.splice(N,1),k.wroteProperty(E)}else E instanceof Set||E instanceof Map?(E.delete(h),k.wroteProperty(E)):C(h,N=>{R(N)&&N.parentElement&&(E==null||E instanceof Node&&E.contains(N))&&N.parentElement.removeChild(N)})};return{type:"removeCommand",classRefs:o,attributeRef:i,css:s,element:u,from:a,when:l,start:r,end:t.endPos(),run:m=>T([a?.ev(m),s?.ev(m),u?.ev(m),...nt(o,m)],([h,E,N,...M])=>{if(u)return f(m,N,h);if(S(h,c),s){let P=Qn(String(E));C(h,O=>P.forEach(I=>rt(O)?.removeProperty(I)))}else return Dt(!1,h,l,m,M,i)})}}}var _t=(e,t,n)=>(r,o,i)=>{i?o.style[e]=i:r==="toggle"?o.style[e]=getComputedStyle(o)[e]===t?n:t:o.style[e]=r==="hide"?t:n},Wt={display(e,t,n){if(!n&&t instanceof HTMLDialogElement){e==="hide"||e==="toggle"&&t.open?t.close():t.open||t.show();return}let r=X(t);n?t.style.display=n:e==="toggle"?Wt.display(getComputedStyle(t).display==="none"?"show":"hide",t):e==="hide"?(r.originalDisplay??=t.style.display,t.style.display="none"):r.originalDisplay&&r.originalDisplay!=="none"?t.style.display=r.originalDisplay:t.style.removeProperty("display")},visibility:_t("visibility","hidden","visible"),opacity:_t("opacity","0","1"),hidden(e,t){(e==="toggle"?!t.hasAttribute("hidden"):e==="hide")?t.setAttribute("hidden",""):t.removeAttribute("hidden")}};function ot(e,t){let n=t??J.defaultHideShowStrategy??"display";return J.hideShowStrategies[n]??Wt[n]??e.err("Unknown show/hide strategy : "+n)}function $t(e){e.commands.toggle=(t,n,r)=>{t.matchAny("the","my");let o={type:"toggleCommand",start:r,end:r,run:()=>{}},i;if(t.cur().type==="STYLE_REF"){let h=o.styleProp=t.consume().value.slice(1);i=ot(t,h),o.on=t.match("of")?t.withFollow(["with","between"],()=>g(t)):j(t)}else if(t.match("between")){let h=Z(t);if(h)t.req("and"),o.between=[h,Z(t)??t.err("Expected classRef")];else{let E=Q(t)??t.err("Expected either a class reference or attribute expression");t.req("and"),o.between=[E,Q(t)??t.err("Expected attributeRef")]}}else if(!(o.classRefs=qt(t))&&!(o.attributeRef=Q(t))){let h=t.g.toggleElement;if(!h)o.target=t.withFollow(["between"],()=>se(t));else{let E=t.withFollow(["between","as"],()=>z(t));if(!t.peek("between"))return h(t,E,r);o.target=Ke(t,E)}}if(!o.styleProp&&!o.target&&(o.on=t.match("on")?g(t):j(t)),t.match("between")){let h=o.betweenValues=t.withFollow(["and"],()=>{let E=[g(t)];for(;t.matchOp(",");)E.push(g(t));return E});t.req("and"),h.push(g(t))}o.target&&!o.betweenValues&&t.err("toggle <expression> requires 'between' with values"),t.peek("for")&&!t.peek("in",2)?(t.match("for"),o.time=g(t)):t.match("until")&&(o.until=K(t),t.match("from")&&(o.from=g(t))),o.end=t.endPos();let{on:s,target:u,betweenValues:a,between:l,attributeRef:c,styleProp:p}=o,f=s?t.text(s):"",d=(h,E)=>h[(h.findIndex(N=>N==E)+1)%h.length],m=(h,E,N,M)=>{if(a&&u?.lhs&&u.put){let P=u;return T([u.ev(h),u.lhs(h)],([O,I])=>P.put?.(h,I,d(N,O)))}if(a&&p)return C(E,P=>{let O=rt(P);if(!O||!R(P))return;let I=O.getPropertyValue(p)||getComputedStyle(P).getPropertyValue(p);O.setProperty(p,String(d(N,I)))});S(E,f),C(E,P=>{if(R(P))if(i)P instanceof HTMLElement&&i("toggle",P);else if(l){let[O,I]=l;if(O.type==="classRef"&&I.type==="classRef"){let[D,te]=[String(O.className),String(I.className)],ne=P.classList.contains(D);P.classList.toggle(D,!ne),P.classList.toggle(te,ne)}else if(O.type==="attributeRef"&&I.type==="attributeRef"){let D=P.getAttribute(O.name)===String(O.value);ge(P,D?O:I,!1),ge(P,D?I:O,!0)}}else c?ge(P,c,!P.hasAttribute(c.name)):M.forEach(O=>P.classList.toggle(String(O)))})};return o.run=h=>T([s?.ev(h),o.time?.ev(h),o.from?.ev(h),T((a??[]).map(E=>E.ev(h)),E=>E),...nt(o.classRefs,h)],([E,N,M,P,...O])=>{let I=()=>m(h,E,Array.isArray(P)?P:[],O);if(o.time)return new Promise(D=>{I(),setTimeout(()=>{I(),D()},b(N))});if(o.until){let D=o.until,te=M||h.me;return new Promise(ne=>{W(te)&&te.addEventListener(D,()=>{I(),ne()},{once:!0}),I()})}return x(I(),()=>{})}),o}}function Ut(e){for(let t of["hide","show"])e.commands[t]=(n,r,o)=>{let i=n.cur(),s=i.value==="when"||i.value==="with"||n.commandBoundary(i)?j(n):g(n),u;n.match("with")&&(u=n.reqType("IDENTIFIER","STYLE_REF").value.replace(/^\*/,""));let a;t==="show"&&n.matchOp(":")&&(a=n.consumeUntil(void 0,"WHITESPACE").map(m=>m.value).join(""));let l=n.match("when")?g(n):void 0,c=ot(n,u),p=n.text(s),f=m=>h=>{h instanceof HTMLElement&&c(m,h,m==="show"?a:void 0)};return{type:`${t}Command`,target:s,strategy:u,arg:a,when:l,start:o,end:n.endPos(),run:m=>x(s.ev(m),h=>{if(S(h,p),l)return Re(h,l,m,f(t),f(t==="hide"?"show":"hide"));C(h,f(t))})}}}var Lr="x y left top right bottom width height bounds scrollLeft scrollTop scrollLeftMax scrollTopMax scrollWidth scrollHeight scroll".split(" ");function Vt(e){e.commands.send=e.commands.trigger=(t,n,r)=>{let o=K(t),i=Nt(t),s=t.match(n==="trigger"?"on":"to")?g(t):j(t),u=t.text(s);return{type:"sendCommand",event:o,details:i,to:s,start:r,end:t.endPos(),run:l=>T([s.ev(l),i?.ev(l)],([c,p])=>{S(c,u),C(c,f=>F(f,o,_(p)?p:{},l.me))})}}}function Bt(e){e.commands.wait=(t,n,r)=>{let o={type:"waitCommand",start:r,end:r,run:()=>{}};if(t.match("for")){t.match("a");let i=o.events=[];do{let a=t.cur();a.type==="NUMBER"||a.op&&a.value==="("?i.push(g(t)):i.push({event:K(t),args:Le(t)})}while(t.match("or"));let s=o.from=t.match("from")?g(t):void 0,u=s?t.text(s):"me";o.run=a=>x(s?s.ev(a):a.me,l=>{if(!W(l))throw new Error("Not a valid event target: "+u);return new Promise(c=>{for(let p of i)"event"in p?l.addEventListener(p.event,f=>{a.result=f;for(let d of p.args)a.locals[d]=v(f,d)||v(v(f,"detail"),d)||null;c()},{once:!0}):x(p.ev(a),f=>setTimeout(()=>{a.result=f,c()},b(f)))})})}else{let i;t.match("a")?t.req("tick"):i=o.time=g(t),o.run=s=>x(i?.ev(s),u=>new Promise(a=>setTimeout(a,i?b(u):0)))}return o.end=t.endPos(),o}}function zt(e){e.commands.log=(t,n,r)=>{let o=[g(t)];for(;t.matchOp(",");)o.push(g(t));let i=t.match("with")?g(t):void 0;return{type:"logCommand",values:o,logger:i,start:r,end:t.endPos(),run:u=>T([i?.ev(u),...o.map(a=>a.ev(u))],([a,...l])=>{q(a)?a(...l):console.log(...l)})}}}function Qt(e){e.commands.get=e.commands.call=(t,n,r)=>{let o=g(t);return n==="call"&&o.type!=="functionCall"&&t.err("Must be a function invocation"),{type:"getCommand",value:o,start:r,end:t.endPos(),run:s=>x(o.ev(s),u=>{s.result=u})}}}function Yt(e){e.pseudo=(t,n)=>{let r=t.tok(1);if(!(r.op&&(r.value==="."||r.value==="(")))return;let o=Ae(t);o.type!=="functionCall"&&t.err("Pseudo-commands must be function calls");let i=o.root,s="args"in o&&Array.isArray(o.args)?o.args:[],u;i&&!i.root&&(t.matchAny("the","to","on","with","into","from","at")?u=g(t):t.match("me")&&(u=j(t)));let a=i?.name??"",l=u?t.text(u):"",c=t.text(o),p=u;return{type:"pseudoCommand",value:o,target:u,start:n,end:t.endPos(),run:d=>p?T([p.ev(d),...s.map(m=>m.ev(d))],([m,...h])=>{S(m,l),d.result=Se(v(m,a),m,h,d,c),be(m,a)}):x(o.ev(d),m=>{d.result=m})}}}function Zt(e){e.commands.set=(t,n,r)=>Xn(t,r)}function Xn(e,t){{if(e.cur().op&&e.cur().value==="{"){let i=et(e);e.req("on");let s=g(e);return{type:"setCommand",target:s,object:i,start:t,end:e.endPos(),run:a=>T([i.ev(a),s.ev(a)],([l,c])=>void Object.assign(Object(c),l))}}let n=e.withFollow(["to"],()=>se(e));e.req("to");let r=g(e);return{type:"setCommand",target:n,value:r,start:t,end:e.endPos(),run:i=>T([n.lhs?.(i),r.ev(i)],([s,u])=>n.put?.(i,s,u))}}}function Jt(e){for(let t of["increment","decrement"]){let n=t==="increment"?1:-1;e.commands[t]=(r,o,i)=>{let s=r.withFollow(n<0?["by"]:[],()=>se(r)),u=r.match("by")?g(r):void 0;return{type:`${t}Command`,target:s,amount:u,start:i,end:r.endPos(),run:l=>T([s.ev(l),u?.ev(l),s.lhs?.(l)],([c,p,f])=>{let d=(c?parseFloat(String(c)):0)+n*(u?parseFloat(String(p)):1);l.result=d,s.put?.(l,f,d)})}}}}function Xt(e,t){e.replaceChildren(fe(t)),U.process(e)}var Zn=["arrayIndex","propertyAccess","possessive","ofExpression","attributeRef","styleRef","attributeRefAccess"],Jn={into:"into",before:"before",after:"after",start:"start",end:"end"},Kn={before:"before",after:"after",start:"prepend",end:"append"};function Kt(e){e.commands.put=(t,n,r)=>{let o=g(t),i=t.matchAny("into","before","after");!i&&t.match("at")&&(t.match("the"),i=t.matchAny("start","end"),t.req("of"));let s=Jn[(i??t.expected("into","before","at start of","at end of","after")).value],u=Oe(g(t)),a=t.text(u),l=(f,d)=>u.type==="symbol"?x(u.ev(f),m=>{R(m)||m instanceof Document?Xt(m,d):u.put?.(f,void 0,d)}):Zn.includes(u.type)?x(u.lhs?.(f),m=>u.put?.(f,m,d)):x(u.ev(f),m=>{S(m,a),C(m,h=>{(R(h)||h instanceof Document)&&Xt(h,d)})}),c=(f,d,m)=>x(u.ev(f),h=>{if(S(h,a),Array.isArray(h)){m==="prepend"?h.unshift(d):h.push(d),k.wroteProperty(h);return}C(h,E=>{R(E)&&(E[m](d instanceof Node?d:fe(d)),U.process(E.parentElement??E))})});return{type:"putCommand",value:o,operation:s,target:u,start:r,end:t.endPos(),run:f=>x(o.ev(f),d=>s==="into"?l(f,d):c(f,d,Kn[s]))}}}var ee=class extends Error{constructor(n,r,o,i){super(n);this.token=r;this.source=o;this.expected=i}written},en=()=>({commands:Object.create(null),features:Object.create(null),leaves:[],indirects:[],unaries:[],postfixes:[],collections:[]}),Fe=class e{constructor(t,n,r){this.g=t;this.tokens=n;this.src=r;let o=r.length;this.eof={type:"EOF",value:"<<<EOF>>>",start:o,end:o,line:0,column:0},this.last=this.eof,this.skipWs()}i=0;follows=[];eof;last;child(t,n){return new e(this.g,t,n)}tok(t=0,n=!1){let r=this.i;for(;;){if(!n)for(;this.tokens[r]?.type==="WHITESPACE";)r++;if(t--===0)return this.tokens[r]??this.eof;r++}}cur(){return this.tokens[this.i]??this.eof}hasMore(){return this.i<this.tokens.length}pos(){return this.cur().start}endPos(){return this.last.end}text(t){return this.src.substring(t.start,t.end)}match(t,n="IDENTIFIER"){if(this.follows.includes(t))return;let r=this.cur();if(r.value===t&&r.type===n)return this.consume()}matchOp(t){let n=this.cur();if(n.op&&n.value===t)return this.consume()}matchType(...t){if(t.includes(this.cur().type))return this.consume()}matchAny(...t){for(let n of t){let r=this.match(n);if(r)return r}}matchAnyOp(...t){for(let n of t){let r=this.matchOp(n);if(r)return r}}req(t){return this.match(t)??this.expected(t)}reqOp(t){return this.matchOp(t)??this.expected(t)}reqType(...t){return this.matchType(...t)??this.expected(...t)}peek(t,n=0,r="IDENTIFIER"){let o=this.tok(n);if(o.value===t&&o.type===r)return o}consume(){return this.hasMore()?(this.last=this.tokens[this.i++],this.skipWs(),this.last):this.eof}skipWs(){for(;this.tokens[this.i]?.type==="WHITESPACE";)this.i++}consumeUntil(t,n){let r=[],o=this.cur();for(;(n==null||o.type!==n)&&(t==null||o.value!==t)&&o.type!=="EOF";)r.push(o),this.i++,o=this.cur();return this.skipWs(),r}lastWs(){let t=this.tokens[this.i-1];return t?.type==="WHITESPACE"?t.value:""}pushFollow(...t){return this.follows.push(...t),t.length}popFollow(t=1){this.follows.length-=t}withFollow(t,n){let r=this.pushFollow(...t);try{return n()}finally{this.popFollow(r)}}withoutFollows(t){let n=this.follows;this.follows=[];try{return t()}finally{this.follows=n}}err(t,n){let r=this.cur();throw new ee(t??"Unexpected Token : "+r.value,r,this.src,n)}expected(...t){this.err(t.length===1?`Expected '${t[0]}' but found '${this.cur().value}'`:"Expected one of: "+t.map(n=>`'${n}'`).join(", "),t)}commandStart(t){return t.value in this.g.commands}featureStart(t){return t.value in this.g.features}commandBoundary(t){return["end","then","else","otherwise",")"].includes(t.value)||this.commandStart(t)||this.featureStart(t)||t.type==="EOF"}};function st(e){let t=e.source.split(`
|
|
5
|
+
`),c();else if(Ve(y))n.push(f(p("WHITESPACE"),d(Ve)));else if(!h()&&y==="."&&(V(w)||w==="{"||w==="-"))n.push(E("CLASS_REF",!0));else if(!h()&&y==="#"&&(V(w)||w==="{"))n.push(E("ID_REF",!1));else if(y==="@"||y==="["&&w==="@")n.push(D());else if(y==="*"&&V(w)){let A=p("STYLE_REF");n.push(f(A,c()+d(L=>V(L)||L==="-")))}else if(m()&&(V(y)||y==="\\"))n.push(P());else if(!m()&&(V(y)||y==="_"||y==="$"))n.push(M());else if(B(y))n.push(O());else if(!m()&&(y==='"'||y==="`"))n.push(N());else if(!m()&&y==="'")n.push(te()?N():I());else if(ht.has(y))s==="$"&&y==="{"&&u++,y==="}"&&u--,n.push(I());else if(m()||y==="`"){let A=p("RESERVED");n.push(f(A,c()))}else throw new Error("Unknown token: "+y+" ")}return n}function g(e){return e.match("the"),xn(e)}function xn(e){let t=wt(e),n,r=()=>e.match("and")??e.match("or");for(let o=r();o;o=r())n??=o.value,n!==o.value&&e.err("You must parenthesize logical operations with different operators"),t=bn(o.value,t,wt(e));return t}function bn(e,t,n){let r=e==="or";return{type:"logicalOperator",operator:e,left:t,right:n,start:t.start,end:n.end,ev:o=>x(t.ev(o),i=>!!i===r?i:n.ev(o))}}var kn={"+":(e,t)=>Array.isArray(e)?e.concat(t):b(e)+b(t),"-":(e,t)=>b(e)-b(t),"*":(e,t)=>b(e)*b(t),"/":(e,t)=>b(e)/b(t),mod:(e,t)=>b(e)%b(t)};function Qe(e){let t=Xe(e),n,r=()=>e.matchAnyOp("+","-","*","/")??e.match("mod");for(let o=r();o;o=r()){n??=o.value,n!==o.value&&e.err("You must parenthesize math operations with different operators");let i=t,s=Xe(e),u=kn[o.value];t={type:"mathOperator",operator:o.value,left:i,right:s,start:i.start,end:s.end,ev:l=>T([i.ev(l),s.ev(l)],([c,p])=>u(c,p))}}return t}function Xe(e){let t=z(e);for(let n=!0;n;){n=!1;for(let r of e.g.collections){let o=r(e,t);if(o){t=o,n=!0;break}}}return t}function z(e){e.match("the");let t=e.pos();if(e.match("not"))return Ze(e,"logicalNot",t,z(e),n=>!n);if(e.match("no"))return Ze(e,"noExpression",t,Xe(e),We);for(let n of e.g.unaries){let r=n(e);if(r)return H(e,r)}return Tn(e)}function Ze(e,t,n,r,o,i=t!=="negativeNumber"){let s={type:t,root:r,start:n,end:e.endPos(),ev:u=>x(r.ev(u),a=>o(a,u))};return i?H(e,s):s}var Nn="em ex cap ch ic rem lh rlh vw vh vi vb vmin vmax cm mm Q pc pt px".split(" ");function Tn(e){let t=xt(e),n=e.matchAny(...Nn)??e.matchOp("%");if(n)return gt(e,"stringPostfixExpression",t,n.value);let r=e.matchAny("s","seconds")?1e3:e.matchAny("ms","milliseconds")?1:0;if(r)return gt(e,"timeExpression",t,r);for(let o of e.g.postfixes){let i=o(e,t);if(i)return i}return t}function gt(e,t,n,r){let o=s=>typeof r=="number"?b(s)*r:`${s}${r}`,i={type:t,root:n,suffix:r,start:n.start,end:e.endPos(),ev:s=>x(n.ev(s),o)};return n.stat&&(i.stat=()=>o(ye(n))),i}function xt(e){let t=e.pos();return e.matchOp("-")?Ze(e,"negativeNumber",t,xt(e),n=>-b(n)):Ae(e)}function Ae(e){let t=Sn(e);return t?H(e,t):e.err("Unexpected value: "+e.cur().value)}function se(e){return e.match("the"),Ke(e,Ae(e))}function Ke(e,t){let n=Oe(t);return n.put||e.err(`A target expression must be writable. The expression type '${n.type}' is not.`),n}function Oe(e){let t=e;for(;t.type==="parenthesized"&&"expr"in t&&Cn(t.expr);)t=t.expr;return t}var Cn=e=>q(v(e,"ev"));function ye(e){if(e.stat)return e.stat();throw new Error("This expression cannot be evaluated statically: "+e.type)}function Pn(e){let t=e.matchAnyOp("<",">","<=",">=","==","===","!=","!==");if(t)return{operator:t.value,right:!0,isType:!1};let n=(a,l=!0,c=!1)=>({operator:a,right:l,isType:c}),r=()=>e.match("equal")&&e.match("to"),o=(a,l)=>(e.req("than"),e.match("or")?(e.req("equal"),e.req("to"),n(l)):n(a));if(e.match("is")||e.match("am")){let a=!!e.match("not"),l=a?"not ":"";return e.match("in")?n(l+"in"):e.match("a")||e.match("an")?n(l+"a",!1,!0):e.match("empty")?n(l+"empty",!1):e.match("between")?n(l+"between"):!a&&e.match("less")?o("<","<="):!a&&e.match("greater")?o(">",">="):e.match("really")?(r(),n(a?"!==":"===")):e.match("equal")?(e.match("to"),n(a?"!=":"==")):n(a?"is not":"is")}if(e.match("equals"))return n("==");if(e.match("really"))return e.req("equals"),n("===");if(e.matchAny("exist","exists"))return n("exist",!1);let i=!!e.matchAny("do","does");i&&e.req("not");let s=i?"not ":"",u=(a,l)=>e.match(a)??(i&&a!=="match"&&a!=="contain"?void 0:e.match(l));if(u("match","matches"))return n(s+"match");if(u("contain","contains"))return n(s+"contain");if(i&&e.match("exist"))return n("not exist",!1);if(u("include","includes"))return n(s+"include");if(e.match(i?"start":"starts"))return e.req("with"),n(s+"start with");if(e.match(i?"end":"ends"))return e.req("with"),n(s+"end with");if(u("precede","precedes"))return n(s+"precede");if(u("follow","follows"))return n(s+"follow");i&&e.expected("matches","contains","starts with","ends with","precede","follow")}function wt(e){let t=Qe(e),n=Pn(e);if(!n)return t;let{operator:r}=n,o,i=!0,s,u;n.isType?(o=e.reqType("IDENTIFIER").value,i=!e.matchOp("!")):n.right&&(s=Qe(e),r.endsWith("match")&&(u=s.css));let a;r.endsWith("between")&&(e.req("and"),a=Qe(e));let l=!1;e.match("ignoring")&&(e.req("case"),l=!0);let c=d=>l&&typeof d=="string"?d.toLowerCase():d,p=s?.type==="symbol"&&"scope"in s&&s.scope==="local"&&s.name!=="undefined"&&s.name!=="null"?s.name:void 0;return{type:"comparisonOperator",operator:r,left:t,right:s,right2:a,typeName:o,ignoringCase:l,start:t.start,end:e.endPos(),ev:d=>T([t.ev(d),u??s?.ev(d),a?.ev(d)],([m,h,E])=>{if(o){let N=lt(m,o,i);return r==="a"?N:!N}if(p&&h===void 0&&(r==="is"||r==="is not")){let N=!!ce(m,p);return r==="is"?N:!N}return bt(r,c(m),c(h),E)})}}function vt(e,t){let n=v(e,"contains")??v(e,"includes");if(!q(n))throw new Error("The value does not have a contains or includes method on it");return!!Reflect.apply(n,e,[t])}function Rn(e,t){let n=v(e,"match")??v(e,"matches");if(!q(n))throw new Error("The value does not have a match or matches method on it");return!!Reflect.apply(n,e,[t])}var Et=(e,t,n)=>e instanceof Node&&t instanceof Node&&(e.compareDocumentPosition(t)&n)!==0;function bt(e,t,n,r){if(e==="not between")return b(t)<b(n)||b(t)>b(r);if(e.startsWith("not "))return!bt(e.slice(4),t,n,r);switch(e){case"is":case"==":return t==n;case"is not":case"!=":return t!=n;case"===":return t===n;case"!==":return t!==n;case"<":return b(t)<b(n);case">":return b(t)>b(n);case"<=":return b(t)<=b(n);case">=":return b(t)>=b(n);case"match":return t!=null&&Rn(t,n);case"in":return n!=null&&vt(n,t);case"contain":case"include":return t!=null&&vt(t,n);case"start with":return t!=null&&String(t).startsWith(String(n));case"end with":return t!=null&&String(t).endsWith(String(n));case"between":return b(t)>=b(n)&&b(t)<=b(r);case"precede":return Et(t,n,Node.DOCUMENT_POSITION_FOLLOWING);case"follow":return Et(t,n,Node.DOCUMENT_POSITION_PRECEDING);case"empty":return We(t);case"exist":return ct(t)}throw new Error("Unknown comparison : "+e)}function Sn(e){let t=e.cur();switch(t.type){case"NUMBER":return e.consume(),Ye("number",parseFloat(t.value),t);case"STRING":return In(e);case"ID_REF":return Mn(e);case"CLASS_REF":return Z(e);case"ATTRIBUTE_REF":return Q(e);case"STYLE_REF":return Rt(e)}if(t.op){if(t.value==="(")return An(e);if(t.value==="[")return Ln(e);if(t.value==="{")return et(e);if(t.value==="<")return _n(e)}let n=e.match("true")??e.match("false");if(n)return Ye("boolean",n.value==="true",n);let r=e.match("null");if(r)return Ye("null",null,r);for(let o of e.g.leaves){let i=o(e);if(i)return i}return Ct(e)}function Ye(e,t,n){return{type:e,value:t,start:n.start,end:n.end,ev:()=>t,stat:()=>t}}function An(e){let t=e.pos();e.consume();let n=e.withoutFollows(()=>g(e));return e.reqOp(")"),{type:"parenthesized",expr:n,start:t,end:e.endPos(),ev:r=>n.ev(r)}}var On=(e,t)=>T(e.map(n=>typeof n=="string"?n:n.ev(t)),n=>n.map(r=>r===void 0?"":`${r}`).join(""));function kt(e,t){let n=e.child(he(t,!0),t),r=[],o="";do{o+=n.lastWs();let i=n.cur();if(i.value==="$"){n.consume();let s=n.matchOp("{");r.push(o,g(n)),o="",s&&n.reqOp("}")}else i.value==="\\"?(n.consume(),n.consume()):n.hasMore()&&(o+=n.consume().value)}while(n.hasMore());return r.push(o+n.lastWs()),r}function In(e){let t=e.consume(),n=t.value,r={type:"string",value:n,start:t.start,end:t.end,ev:()=>n};if(t.template){let o=r.parts=kt(e,n);r.ev=i=>On(o,i)}else r.stat=()=>n;return r}function Ln(e){let t=e.pos();e.consume();let n=[];if(!e.matchOp("]")){do n.push(g(e));while(e.matchOp(","));e.reqOp("]")}return{type:"arrayLiteral",values:n,start:t,end:e.endPos(),ev:r=>T(n.map(o=>o.ev(r)),o=>o)}}function et(e){let t=e.pos();e.consume();let n=[],r=[],o=()=>e.cur().op&&e.cur().value==="}";if(!e.matchOp("}")){do{let i=e.matchType("STRING");if(i)n.push(i.value);else if(e.matchOp("["))n.push(g(e)),e.reqOp("]");else{let s="";for(let u=e.matchType("IDENTIFIER")??e.matchOp("-");u;u=e.matchType("IDENTIFIER")??e.matchOp("-"))s+=u.value;n.push(s)}e.reqOp(":"),r.push(g(e))}while(e.matchOp(",")&&!o());e.reqOp("}")}return{type:"objectLiteral",keys:n,values:r,start:t,end:e.endPos(),ev:i=>T([...n.map(s=>typeof s=="string"?s:s.ev(i)),...r.map(s=>s.ev(i))],s=>Object.fromEntries(n.map((u,a)=>[String(s[a]),s[n.length+a]])))}}function Nt(e){if(!e.matchOp("("))return;let t=e.last.start,n=Fn(e,t);return e.reqOp(")"),n.end=e.endPos(),n}function Fn(e,t=e.pos()){let n=[],r=[];if(e.cur().type==="IDENTIFIER")do n.push(e.reqType("IDENTIFIER").value),e.reqOp(":"),r.push(g(e));while(e.matchOp(","));return{type:"namedArgumentList",names:n,values:r,start:t,end:e.endPos(),ev:o=>T(r.map(i=>i.ev(o)),i=>Object.fromEntries([["_namedArgList_",!0],...n.map((s,u)=>[s,i[u]])]))}}function Tt(e){return e.matchType("STRING")?.value??e.consumeUntil(void 0,"WHITESPACE").map(t=>t.value).join("")}function Ct(e){let t=e.pos(),n;e.match("global")?n="global":e.match("element")?(n="element",e.matchOp("'")&&e.req("s")):e.match("dom")?n="inherited":e.match("local")&&(n="local");let r=e.matchOp(":"),o=!r&&e.matchOp("^"),i=e.matchType("IDENTIFIER");if(!i?.value)return;let s=(r?":":o?"^":"")+i.value,a=n??{$:"global",":":"element","^":"inherited"}[s[0]]??"local",l;return a==="inherited"&&e.match("on")&&(l=e.withFollow(["to","into","before","after","then"],()=>g(e))),{type:"symbol",name:s,scope:a,...l?{on:l}:{},start:t,end:e.endPos(),ev:c=>$e(s,c,a,l?.ev(c)),lhs:()=>{},put:(c,p,f)=>Ue(s,c,a,f,l?.ev(c))}}var Pt=(e,t)=>{let n=t.value.substring(2);return g(e.child(he(n),n))};function Mn(e){let t=e.consume(),n=(o,i)=>He(o.me).getElementById(String(i)),r={type:"idRef",start:t.start,end:t.end,ev:()=>null,lhs:()=>{},put:(o,i,s)=>x(r.ev(o),u=>u&&me(u,s))};if(t.template){let o=r.expr=Pt(e,t);r.ev=i=>x(o.ev(i),s=>n(i,s))}else{let o=r.value=t.value.substring(1);r.css=t.value,r.ev=i=>n(i,o)}return r}function Z(e){let t=e.matchType("CLASS_REF");if(!t)return;let n={type:"classRef",start:t.start,end:t.end,ev:()=>null,lhs:()=>{},put:(r,o,i)=>x(n.ev(r),s=>me(Array.from(s instanceof G?s:[]),i))};if(t.template){let r=n.expr=Pt(e,t);n.ev=o=>x(r.ev(o),i=>new G("."+i,o.me,!0))}else{let r=n.css=t.value;n.className=r.slice(1),n.ev=o=>new G(r,o.me,!0)}return n}var Je=class extends G{constructor(n,r){super("",n);this.parts=r}get css(){let n=0;return this.parts.map(r=>R(r)?`[data-hs-query-id='${n++}']`:`${r??""}`).join("")}select(){let n=this.parts.filter(R);n.forEach((o,i)=>o.setAttribute("data-hs-query-id",String(i)));let r=super.select();return n.forEach(o=>o.removeAttribute("data-hs-query-id")),r}};function _n(e){let t=e.pos();e.consume();let n=e.consumeUntil("/").map(o=>o.type==="STRING"?`"${o.value}"`:o.value).join("");e.reqOp("/"),e.reqOp(">");let r={type:"queryRef",css:n,start:t,end:e.endPos(),ev:o=>new G(n,o.me),lhs:()=>{},put:(o,i,s)=>x(r.ev(o),u=>me(Array.from(u instanceof G?u:[]),s))};if(/\$[^=]/.test(n)){let o=r.parts=kt(e,n);r.ev=i=>T(o.map(s=>typeof s=="string"?s:s.ev(i)),s=>new Je(i.me,s))}return r}function Q(e){let t=e.matchType("ATTRIBUTE_REF");if(!t)return;let n=t.value.startsWith("[")?t.value.slice(2,-1):t.value.slice(1),[r,o]=n.split("="),i=o&&/^["']/.test(o)?o.slice(1,-1):o;return{type:"attributeRef",name:r,value:i,css:`[${n}]`,start:t.start,end:t.end,ev:s=>le(s.you||s.me,r),lhs:()=>{},put:(s,u,a)=>de(s.you||s.me,r,a)}}function Rt(e){let t=e.matchType("STYLE_REF");if(!t)return;let n=t.value.startsWith("*computed-"),r=t.value.slice(n?10:1);return{type:n?"computedStyleRef":"styleRef",name:r,start:t.start,end:t.end,ev:o=>(n?Te:Ne)(o.you||o.me,r),lhs:()=>{},put:(o,i,s)=>Ce(o.you||o.me,r,s)}}function St(e){let t=e.pos();if(!e.matchOp("{"))return;let n=[""],r=[];for(;e.hasMore();){if(e.matchOp("\\"))e.consume();else{if(e.matchOp("}"))break;if(e.match("$")){let o=e.matchOp("{");r.push(g(e)),o&&e.reqOp("}"),n.push("")}else n[n.length-1]+=e.text(e.consume())}n[n.length-1]+=e.lastWs()}return{type:"styleLiteral",parts:n,exprs:r,start:t,end:e.endPos(),ev:o=>T(r.map(i=>i.ev(o)),i=>n.map((s,u)=>s+(u in i?`${i[u]}`:"")).join(""))}}function j(e){let t=e.endPos();return{type:"implicitMeTarget",start:t,end:t,ev:n=>n.you||n.me}}function At(e){let t=e.matchType("IDENTIFIER");if(!t)return;let n=[t.value],r=e.matchOp(".")??e.matchOp(":");if(r)do n.push(e.reqType("IDENTIFIER","NUMBER").value);while(e.matchOp(r.value));return n.join(r?.value??"")}function K(e,t="Expected event name"){return e.matchType("STRING")?.value??At(e)??e.err(t)}function H(e,t){return Dn(e,t)??Hn(e,t)??Un(e,t)??jn(e,t)??Gn(e,t)??Wn(e,t)??$n(e,t)??Bn(e,t)??qn(e,t)??t}function qn(e,t){for(let n of e.g.indirects){let r=n(e,t);if(r)return r}}function Dn(e,t){if(!e.matchOp("."))return;let n=e.reqType("IDENTIFIER").value,r=e.text(t),o={type:"propertyAccess",root:t,prop:n,start:t.start,end:e.endPos(),ev:i=>x(o.root.ev(i),s=>ce(s,n)),lhs:i=>o.root.ev(i),put:(i,s,u)=>{S(s,r),Pe(s,n,u)},del:(i,s)=>{S(s,r),C(s,u=>{_(u)&&delete u[n],k.wroteProperty(u)})}};return H(e,o)}function Hn(e,t){if(!e.match("of"))return;let n=z(e),r,o=t;for(;o.root;)r=o,o=o.root;let s={symbol:"property",attributeRef:"attribute",styleRef:"style",computedStyleRef:"computed"}[o.type],u=o.name;if(!s||u===void 0)return e.err("Cannot take a property of a non-symbol: "+o.type);let a=e.text(n),l={property:ce,attribute:le,style:Ne,computed:Te}[s],c={type:"ofExpression",root:n,name:u,kind:s,start:t.start,end:e.endPos(),ev:p=>x(c.root.ev(p),f=>l(f,u)),lhs:p=>c.root.ev(p),put:(p,f,d)=>{S(f,a),s==="attribute"?de(f,u,d):s==="property"?Pe(f,u,d):Ce(f,u,d)},del:(p,f)=>{S(f,a),C(f,d=>{s==="attribute"?R(d)&&d.removeAttribute(u):s==="property"?(_(d)&&delete d[u],k.wroteProperty(d)):d instanceof HTMLElement&&d.style.removeProperty(u)})}};return r?(r.root=c,H(e,t)):H(e,c)}function jn(e,t){let n=e.matchOp("'"),r=t.type==="symbol"&&["my","its","your"].includes(t.name??"")&&["IDENTIFIER","ATTRIBUTE_REF","STYLE_REF"].includes(e.cur().type);if(!n&&!r)return;n&&e.req("s");let o=Q(e)??Rt(e),i=o?void 0:e.reqType("IDENTIFIER").value,s=e.text(t),u=l=>i!==void 0?ce(l,i):o?.type==="attributeRef"?le(l,o.name):o?.type==="computedStyleRef"?Te(l,o.name):o&&Ne(l,o.name),a={type:"possessive",root:t,prop:i,attribute:o,start:t.start,end:e.endPos(),ev:l=>x(a.root.ev(l),u),lhs:l=>a.root.ev(l),put:(l,c,p)=>{S(c,s),i!==void 0?Pe(c,i,p):o?.type==="attributeRef"?de(c,o.name,p):o&&Ce(c,o.name,p)}};return H(e,a)}function Gn(e,t){if(!e.match("in"))return;let n=z(e),r=(s,u)=>{if(s==null)return[];let a=[],l=v(s,"css");if(typeof l=="string")C(u,c=>R(c)&&a.push(...je(c,l)));else if(R(s)){let c=!1;if(C(u,p=>{p instanceof Node&&p.contains(s)&&(c=!0)}),c)return s}else C(s,c=>C(u,p=>c===p&&a.push(c)));return a},o={type:"inExpression",root:t,target:n,start:t.start,end:e.endPos(),ev:s=>T([o.root.ev(s),n.ev(s)],([u,a])=>r(u,a)),lhs:s=>o.ev(s),put:(s,u,a)=>me(u,a)},i;if(e.peek("where"))for(let s of e.g.collections)i??=s(e,o);return H(e,i??o)}function Wn(e,t){if(!e.match("as"))return;e.match("a")||e.match("an");let n=o=>{let i=At(e)??e.err("Expected dotOrColonPath"),s={type:"asExpression",root:o,conversion:i,start:o.start,end:e.endPos(),ev:u=>x(s.root.ev(u),a=>dt(a,i))};return s},r=n(t);for(;e.matchOp("|");)r=n(r);return H(e,r)}function $n(e,t){if(!e.matchOp("("))return;let n=[];if(!e.matchOp(")")){do n.push(g(e));while(e.matchOp(","));e.reqOp(")")}let r=e.text(t),o=t.root?e.text(t.root):"",i={type:"functionCall",root:t,args:n,start:t.start,end:e.endPos(),ev:s=>{let u=i.root,a=u.prop,l=a===void 0?void 0:u.root;return T([(l??u).ev(s),...n.map(c=>c.ev(s))],([c,...p])=>{if(!l||a===void 0)return Se(c,void 0,p,s,r);S(c,o);let f=Se(v(c,a),c,p,s,r);return be(c,a),f})}};return H(e,i)}function Se(e,t,n,r,o){if(!q(e))throw S(e,o),new Error(`'${o}' is not a function`);return v(e,"hyperfunc")&&n.push(r),Reflect.apply(e,t,n)}function Un(e,t){let n=Q(e);return n&&Vn(e,t,n)}function Vn(e,t,n){let r=e.text(t),o={type:"attributeRefAccess",root:t,attribute:n,start:t.start,end:e.endPos(),ev:i=>x(o.root.ev(i),s=>le(s,n.name)),lhs:i=>o.root.ev(i),put:(i,s,u)=>{S(s,r),de(s,n.name,u)}};return o}function Bn(e,t){if(!e.matchOp("["))return;let n=!!e.matchOp(".."),r=g(e),o=!1,i;!n&&e.matchOp("..")&&(o=!0,e.cur().op&&e.cur().value==="]"||(i=g(e))),e.reqOp("]");let s=e.text(t),u=(c,p)=>b(p)<0?b(v(c,"length"))+b(p):b(p),a=(c,p,f)=>{let d=v(c,"slice");return q(d)?Reflect.apply(d,c,[p,f]):void 0},l={type:"arrayIndex",root:t,first:r,second:i,andBefore:n,andAfter:o,start:t.start,end:e.endPos(),ev:c=>T([l.root.ev(c),r.ev(c),i?.ev(c)],([p,f,d])=>p==null?null:n?a(p,0,u(p,f)+1):o?d==null?a(p,b(f)):a(p,b(f),u(p,d)+1):v(p,String(f))),lhs:c=>T([l.root.ev(c),r.ev(c)],p=>p),put:(c,p,f)=>{let[d,m]=Array.isArray(p)?p:[];S(d,s),_(d)&&(d[String(m)]=f)},del:(c,p)=>{if(n||o)throw new Error("Cannot remove a slice - use a single index");let[f,d]=Array.isArray(p)?p:[];S(f,s),Array.isArray(f)?f.splice(u(f,d),1):_(f)&&delete f[String(d)],k.wroteProperty(f)}};return H(e,l)}function Ie(e){let t=e.pos();if(e.matchOp("(")){let a=Ie(e)??e.err("Expected command");return e.reqOp(")"),a}let n=e.cur(),r=e.g.commands[n.value],o;if(r?o=e.match(n.value)&&r(e,n.value,t):n.type==="IDENTIFIER"&&(o=e.g.pseudo?.(e,t)),!o||!e.match("unless"))return o;let i=o,s=g(e);return{type:"unlessStatementModifier",command:i,condition:s,start:t,end:e.endPos(),run:a=>x(s.ev(a),l=>l?void 0:i.run(a))}}function Y(e){let t=[];for(;e.hasMore();){let n=Ie(e);if(!n)break;t.push(n),e.match("then")}return t}function Ot(e){let t=e.pos();if(e.matchOp("(")){let o=Ot(e);return e.reqOp(")"),o}let n=e.cur(),r=e.g.features[n.value];return!r||!e.match(n.value)?e.err("Expected feature"):r(e,t)}function tt(e){let t=e.pos(),n=[];for(;e.hasMore();){let r=e.cur();if(e.featureStart(r)||r.value==="(")n.push(Ot(e)),e.match("end");else{if(r.value==="end")break;e.err()}}return{type:"hyperscript",features:n,start:t,end:e.endPos()}}function It(e){let t={};return e.match("catch")&&(t.errorSymbol=e.reqType("IDENTIFIER").value,t.errorHandler=Y(e)),e.match("finally")&&(t.finallyHandler=Y(e)),t}function Le(e){let t=[],n=e.tok(1).value,r=e.tok(2).value;if(e.cur().value==="("&&(n===")"||r===","||r===")")){e.matchOp("(");do t.push(e.reqType("IDENTIFIER").value);while(e.matchOp(","));e.reqOp(")")}return t}function Lt(e){e.commands.if=(t,n,r)=>{let o=g(t);t.match("then");let i=Y(t),s,u=!1,a=t.match("else")??t.match("otherwise");if(a)if(u=t.peek("if")?.line===a.line,u){let c=Ie(t);s=c?[c]:[]}else s=Y(t);return t.hasMore()&&!u&&t.req("end"),{type:"ifCommand",condition:o,trueBranch:i,falseBranch:s,start:r,end:t.endPos(),run:c=>x(o.ev(c),p=>p?$(i,c):s&&$(s,c))}}}var zn={k:"return",value:null};function Ft(e){e.commands.halt=(t,n,r)=>{let o=!1;t.match("the")&&(t.req("event"),t.matchOp("'")&&t.req("s"),o=!0);let i=!!t.match("bubbling"),s=!i&&!!t.match("default");return{type:"haltCommand",keepExecuting:o,bubbling:i,haltDefault:s,start:r,end:t.endPos(),run:a=>{let l=a.event;if(l instanceof Event&&(s||l.stopPropagation(),i||l.preventDefault()),!o)return zn}}}}function qt(e){let t=Z(e);if(!t)return;let n=[t];for(let r=Z(e);r;r=Z(e))n.push(r);return n}var nt=(e,t)=>(e??[]).map(n=>x(n.ev(t),r=>String(v(r,"className")))),Qn=e=>e.split(";").map(t=>t.split(":")[0].trim()).filter(Boolean),rt=e=>e instanceof HTMLElement||e instanceof SVGElement?e.style:void 0,Mt=(e,t,n,r,o)=>t?Re(e,t,n,i=>R(i)&&r(i),i=>R(i)&&o(i)):C(e,i=>R(i)&&r(i)),ge=(e,{name:t,value:n},r)=>r?e.setAttribute(t,String(n)):e.removeAttribute(t),Dt=(e,t,n,r,o,i)=>i?Mt(t,n,r,s=>ge(s,i,e),s=>ge(s,i,!e)):T(o.map(s=>Mt(t,n,r,u=>u.classList.toggle(String(s),e),u=>u.classList.toggle(String(s),!e))),()=>{});function Ht(e){let t=qt(e),n=t?void 0:Q(e);return{refs:t,attribute:n,css:t||n?void 0:St(e)}}function jt(e){e.commands.add=(t,n,r)=>{let{refs:o,attribute:i,css:s}=Ht(t),u;!o&&!i&&!s&&(u=t.withFollow(["to"],()=>g(t)),t.cur().value!=="to"&&t.err("Expected either a class reference or attribute expression"));let a=t.match("to")?g(t):j(t),l=t.match("when")?g(t):void 0,c=o||i?l:void 0,p=t.text(a);return{type:"addCommand",classRefs:o,attributeRef:i,css:s,value:u,to:a,when:c,start:r,end:t.endPos(),run:d=>T([a.ev(d),s?.ev(d),u?.ev(d),...nt(o,d)],([m,h,E,...N])=>{if(S(m,p),u){if(Array.isArray(m))m.push(E);else if(m instanceof Set)m.add(E);else throw m instanceof Map?new Error("Use 'set myMap[key] to value' for Maps"):new Error("Cannot add to "+typeof m);k.wroteProperty(m)}else if(s)C(m,M=>{let P=rt(M);P&&(P.cssText+=h)});else return Dt(!0,m,c,d,N,i)})}}}var Yn=e=>e instanceof Node||e instanceof NodeList||e instanceof HTMLCollection;function Gt(e){e.commands.remove=(t,n,r)=>{let{refs:o,attribute:i,css:s}=Ht(t),u=o||i||s?void 0:g(t),a=t.match("from")?g(t):u?void 0:j(t),l;t.match("when")&&(u&&t.err("'when' clause is not supported when removing elements"),l=g(t));let c=a?t.text(a):"",p=u?t.text(u):"",f=(m,h,E)=>{if(E==null&&u?.del&&u.lhs&&!Yn(h)){let N=u;return x(u.lhs(m),M=>N.del?.(m,M))}if(S(h,p),Array.isArray(E)){let N=E.indexOf(h);N>-1&&E.splice(N,1),k.wroteProperty(E)}else E instanceof Set||E instanceof Map?(E.delete(h),k.wroteProperty(E)):C(h,N=>{R(N)&&N.parentElement&&(E==null||E instanceof Node&&E.contains(N))&&N.parentElement.removeChild(N)})};return{type:"removeCommand",classRefs:o,attributeRef:i,css:s,element:u,from:a,when:l,start:r,end:t.endPos(),run:m=>T([a?.ev(m),s?.ev(m),u?.ev(m),...nt(o,m)],([h,E,N,...M])=>{if(u)return f(m,N,h);if(S(h,c),s){let P=Qn(String(E));C(h,O=>P.forEach(I=>rt(O)?.removeProperty(I)))}else return Dt(!1,h,l,m,M,i)})}}}var _t=(e,t,n)=>(r,o,i)=>{i?o.style[e]=i:r==="toggle"?o.style[e]=getComputedStyle(o)[e]===t?n:t:o.style[e]=r==="hide"?t:n},Wt={display(e,t,n){if(!n&&t instanceof HTMLDialogElement){e==="hide"||e==="toggle"&&t.open?t.close():t.open||t.show();return}let r=X(t);n?t.style.display=n:e==="toggle"?Wt.display(getComputedStyle(t).display==="none"?"show":"hide",t):e==="hide"?(r.originalDisplay??=t.style.display,t.style.display="none"):r.originalDisplay&&r.originalDisplay!=="none"?t.style.display=r.originalDisplay:t.style.removeProperty("display")},visibility:_t("visibility","hidden","visible"),opacity:_t("opacity","0","1"),hidden(e,t){(e==="toggle"?!t.hasAttribute("hidden"):e==="hide")?t.setAttribute("hidden",""):t.removeAttribute("hidden")}};function ot(e,t){let n=t??J.defaultHideShowStrategy??"display";return J.hideShowStrategies[n]??Wt[n]??e.err("Unknown show/hide strategy : "+n)}function $t(e){e.commands.toggle=(t,n,r)=>{t.matchAny("the","my");let o={type:"toggleCommand",start:r,end:r,run:()=>{}},i;if(t.cur().type==="STYLE_REF"){let h=o.styleProp=t.consume().value.slice(1);i=ot(t,h),o.on=t.match("of")?t.withFollow(["with","between"],()=>g(t)):j(t)}else if(t.match("between")){let h=Z(t);if(h)t.req("and"),o.between=[h,Z(t)??t.err("Expected classRef")];else{let E=Q(t)??t.err("Expected either a class reference or attribute expression");t.req("and"),o.between=[E,Q(t)??t.err("Expected attributeRef")]}}else if(!(o.classRefs=qt(t))&&!(o.attributeRef=Q(t))){let h=t.g.toggleElement;if(!h)o.target=t.withFollow(["between"],()=>se(t));else{let E=t.withFollow(["between","as"],()=>z(t));if(!t.peek("between"))return h(t,E,r);o.target=Ke(t,E)}}if(!o.styleProp&&!o.target&&(o.on=t.match("on")?g(t):j(t)),t.match("between")){let h=o.betweenValues=t.withFollow(["and"],()=>{let E=[g(t)];for(;t.matchOp(",");)E.push(g(t));return E});t.req("and"),h.push(g(t))}o.target&&!o.betweenValues&&t.err("toggle <expression> requires 'between' with values"),t.peek("for")&&!t.peek("in",2)?(t.match("for"),o.time=g(t)):t.match("until")&&(o.until=K(t),t.match("from")&&(o.from=g(t))),o.end=t.endPos();let{on:s,target:u,betweenValues:a,between:l,attributeRef:c,styleProp:p}=o,f=s?t.text(s):"",d=(h,E)=>h[(h.findIndex(N=>N==E)+1)%h.length],m=(h,E,N,M)=>{if(a&&u?.lhs&&u.put){let P=u;return T([u.ev(h),u.lhs(h)],([O,I])=>P.put?.(h,I,d(N,O)))}if(a&&p)return C(E,P=>{let O=rt(P);if(!O||!R(P))return;let I=O.getPropertyValue(p)||getComputedStyle(P).getPropertyValue(p);O.setProperty(p,String(d(N,I)))});S(E,f),C(E,P=>{if(R(P))if(i)P instanceof HTMLElement&&i("toggle",P);else if(l){let[O,I]=l;if(O.type==="classRef"&&I.type==="classRef"){let[D,te]=[String(O.className),String(I.className)],ne=P.classList.contains(D);P.classList.toggle(D,!ne),P.classList.toggle(te,ne)}else if(O.type==="attributeRef"&&I.type==="attributeRef"){let D=P.getAttribute(O.name)===String(O.value);ge(P,D?O:I,!1),ge(P,D?I:O,!0)}}else c?ge(P,c,!P.hasAttribute(c.name)):M.forEach(O=>P.classList.toggle(String(O)))})};return o.run=h=>T([s?.ev(h),o.time?.ev(h),o.from?.ev(h),T((a??[]).map(E=>E.ev(h)),E=>E),...nt(o.classRefs,h)],([E,N,M,P,...O])=>{let I=()=>m(h,E,Array.isArray(P)?P:[],O);if(o.time)return new Promise(D=>{I(),setTimeout(()=>{I(),D()},b(N))});if(o.until){let D=o.until,te=M||h.me;return new Promise(ne=>{W(te)&&te.addEventListener(D,()=>{I(),ne()},{once:!0}),I()})}return x(I(),()=>{})}),o}}function Ut(e){for(let t of["hide","show"])e.commands[t]=(n,r,o)=>{let i=n.cur(),s=i.value==="when"||i.value==="with"||n.commandBoundary(i)?j(n):g(n),u;n.match("with")&&(u=n.reqType("IDENTIFIER","STYLE_REF").value.replace(/^\*/,""));let a;t==="show"&&n.matchOp(":")&&(a=n.consumeUntil(void 0,"WHITESPACE").map(m=>m.value).join(""));let l=n.match("when")?g(n):void 0,c=ot(n,u),p=n.text(s),f=m=>h=>{h instanceof HTMLElement&&c(m,h,m==="show"?a:void 0)};return{type:`${t}Command`,target:s,strategy:u,arg:a,when:l,start:o,end:n.endPos(),run:m=>x(s.ev(m),h=>{if(S(h,p),l)return Re(h,l,m,f(t),f(t==="hide"?"show":"hide"));C(h,f(t))})}}}var Lr="x y left top right bottom width height bounds scrollLeft scrollTop scrollLeftMax scrollTopMax scrollWidth scrollHeight scroll".split(" ");function Vt(e){e.commands.send=e.commands.trigger=(t,n,r)=>{let o=K(t),i=Nt(t),s=t.match(n==="trigger"?"on":"to")?g(t):j(t),u=t.text(s);return{type:"sendCommand",event:o,details:i,to:s,start:r,end:t.endPos(),run:l=>T([s.ev(l),i?.ev(l)],([c,p])=>{S(c,u),C(c,f=>F(f,o,_(p)?p:{},l.me))})}}}function Bt(e){e.commands.wait=(t,n,r)=>{let o={type:"waitCommand",start:r,end:r,run:()=>{}};if(t.match("for")){t.match("a");let i=o.events=[];do{let a=t.cur();a.type==="NUMBER"||a.op&&a.value==="("?i.push(g(t)):i.push({event:K(t),args:Le(t)})}while(t.match("or"));let s=o.from=t.match("from")?g(t):void 0,u=s?t.text(s):"me";o.run=a=>x(s?s.ev(a):a.me,l=>{if(!W(l))throw new Error("Not a valid event target: "+u);return new Promise(c=>{for(let p of i)"event"in p?l.addEventListener(p.event,f=>{a.result=f;for(let d of p.args)a.locals[d]=v(f,d)||v(v(f,"detail"),d)||null;c()},{once:!0}):x(p.ev(a),f=>setTimeout(()=>{a.result=f,c()},b(f)))})})}else{let i;t.match("a")?t.req("tick"):i=o.time=g(t),o.run=s=>x(i?.ev(s),u=>new Promise(a=>setTimeout(a,i?b(u):0)))}return o.end=t.endPos(),o}}function zt(e){e.commands.log=(t,n,r)=>{let o=[g(t)];for(;t.matchOp(",");)o.push(g(t));let i=t.match("with")?g(t):void 0;return{type:"logCommand",values:o,logger:i,start:r,end:t.endPos(),run:u=>T([i?.ev(u),...o.map(a=>a.ev(u))],([a,...l])=>{q(a)?a(...l):console.log(...l)})}}}function Qt(e){e.commands.get=e.commands.call=(t,n,r)=>{let o=g(t);return n==="call"&&o.type!=="functionCall"&&t.err("Must be a function invocation"),{type:"getCommand",value:o,start:r,end:t.endPos(),run:s=>x(o.ev(s),u=>{s.result=u})}}}function Yt(e){e.pseudo=(t,n)=>{let r=t.tok(1);if(!(r.op&&(r.value==="."||r.value==="(")))return;let o=Ae(t);o.type!=="functionCall"&&t.err("Pseudo-commands must be function calls");let i=o.root,s="args"in o&&Array.isArray(o.args)?o.args:[],u;i&&!i.root&&(t.matchAny("the","to","on","with","into","from","at")?u=g(t):t.match("me")&&(u=j(t)));let a=i?.name??"",l=u?t.text(u):"",c=t.text(o),p=u;return{type:"pseudoCommand",value:o,target:u,start:n,end:t.endPos(),run:d=>p?T([p.ev(d),...s.map(m=>m.ev(d))],([m,...h])=>{S(m,l),d.result=Se(v(m,a),m,h,d,c),be(m,a)}):x(o.ev(d),m=>{d.result=m})}}}function Zt(e){e.commands.set=(t,n,r)=>Xn(t,r)}function Xn(e,t){{if(e.cur().op&&e.cur().value==="{"){let i=et(e);e.req("on");let s=g(e);return{type:"setCommand",target:s,object:i,start:t,end:e.endPos(),run:a=>T([i.ev(a),s.ev(a)],([l,c])=>void Object.assign(Object(c),l))}}let n=e.withFollow(["to"],()=>se(e));e.req("to");let r=g(e);return{type:"setCommand",target:n,value:r,start:t,end:e.endPos(),run:i=>T([n.lhs?.(i),r.ev(i)],([s,u])=>n.put?.(i,s,u))}}}function Jt(e){for(let t of["increment","decrement"]){let n=t==="increment"?1:-1;e.commands[t]=(r,o,i)=>{let s=r.withFollow(n<0?["by"]:[],()=>se(r)),u=r.match("by")?g(r):void 0;return{type:`${t}Command`,target:s,amount:u,start:i,end:r.endPos(),run:l=>T([s.ev(l),u?.ev(l),s.lhs?.(l)],([c,p,f])=>{let d=(c?parseFloat(String(c)):0)+n*(u?parseFloat(String(p)):1);l.result=d,s.put?.(l,f,d)})}}}}function Xt(e,t){e.replaceChildren(fe(t)),U.process(e)}var Zn=["arrayIndex","propertyAccess","possessive","ofExpression","attributeRef","styleRef","attributeRefAccess"],Jn={into:"into",before:"before",after:"after",start:"start",end:"end"},Kn={before:"before",after:"after",start:"prepend",end:"append"};function Kt(e){e.commands.put=(t,n,r)=>{let o=g(t),i=t.matchAny("into","before","after");!i&&t.match("at")&&(t.match("the"),i=t.matchAny("start","end"),t.req("of"));let s=Jn[(i??t.expected("into","before","at start of","at end of","after")).value],u=Oe(g(t)),a=t.text(u),l=(f,d)=>u.type==="symbol"?x(u.ev(f),m=>{R(m)||m instanceof Document?Xt(m,d):u.put?.(f,void 0,d)}):Zn.includes(u.type)?x(u.lhs?.(f),m=>u.put?.(f,m,d)):x(u.ev(f),m=>{S(m,a),C(m,h=>{(R(h)||h instanceof Document)&&Xt(h,d)})}),c=(f,d,m)=>x(u.ev(f),h=>{if(S(h,a),Array.isArray(h)){m==="prepend"?h.unshift(d):h.push(d),k.wroteProperty(h);return}C(h,E=>{R(E)&&(E[m](d instanceof Node?d:fe(d)),U.process(E.parentElement??E))})});return{type:"putCommand",value:o,operation:s,target:u,start:r,end:t.endPos(),run:f=>x(o.ev(f),d=>s==="into"?l(f,d):c(f,d,Kn[s]))}}}var ee=class extends Error{constructor(n,r,o,i){super(n);this.token=r;this.source=o;this.expected=i}written},en=()=>({commands:Object.create(null),features:Object.create(null),leaves:[],indirects:[],unaries:[],postfixes:[],collections:[]}),Fe=class e{constructor(t,n,r){this.g=t;this.tokens=n;this.src=r;let o=r.length;this.eof={type:"EOF",value:"<<<EOF>>>",start:o,end:o,line:0,column:0},this.last=this.eof,this.skipWs()}i=0;follows=[];eof;last;child(t,n){return new e(this.g,t,n)}tok(t=0,n=!1){let r=this.i;for(;;){if(!n)for(;this.tokens[r]?.type==="WHITESPACE";)r++;if(t--===0)return this.tokens[r]??this.eof;r++}}cur(){return this.tokens[this.i]??this.eof}hasMore(){return this.i<this.tokens.length}pos(){return this.cur().start}endPos(){return this.last.end}text(t){return this.src.substring(t.start,t.end)}match(t,n="IDENTIFIER"){if(this.follows.includes(t))return;let r=this.cur();if(r.value===t&&r.type===n)return this.consume()}matchOp(t){let n=this.cur();if(n.op&&n.value===t)return this.consume()}matchType(...t){if(t.includes(this.cur().type))return this.consume()}matchAny(...t){for(let n of t){let r=this.match(n);if(r)return r}}matchAnyOp(...t){for(let n of t){let r=this.matchOp(n);if(r)return r}}req(t){return this.match(t)??this.expected(t)}reqOp(t){return this.matchOp(t)??this.expected(t)}reqType(...t){return this.matchType(...t)??this.expected(...t)}peek(t,n=0,r="IDENTIFIER"){let o=this.tok(n);if(o.value===t&&o.type===r)return o}consume(){return this.hasMore()?(this.last=this.tokens[this.i++],this.skipWs(),this.last):this.eof}skipWs(){for(;this.tokens[this.i]?.type==="WHITESPACE";)this.i++}consumeUntil(t,n){let r=[],o=this.cur();for(;(n==null||o.type!==n)&&(t==null||o.value!==t)&&o.type!=="EOF";)r.push(o),this.i++,o=this.cur();return this.skipWs(),r}lastWs(){let t=this.tokens[this.i-1];return t?.type==="WHITESPACE"?t.value:""}pushFollow(...t){return this.follows.push(...t),t.length}popFollow(t=1){this.follows.length-=t}withFollow(t,n){let r=this.pushFollow(...t);try{return n()}finally{this.popFollow(r)}}withoutFollows(t){let n=this.follows;this.follows=[];try{return t()}finally{this.follows=n}}err(t,n){let r=this.cur();throw new ee(t??"Unexpected Token : "+r.value,r,this.src,n)}expected(...t){this.err(t.length===1?`Expected '${t[0]}' but found '${this.cur().value}'`:"Expected one of: "+t.map(n=>`'${n}'`).join(", "),t)}commandStart(t){return t.value in this.g.commands}featureStart(t){return t.value in this.g.features}commandBoundary(t){return["end","then","else","otherwise",")"].includes(t.value)||this.commandStart(t)||this.featureStart(t)||t.type==="EOF"}};function st(e){let t=e.source.split(`
|
|
6
6
|
`),n=e.token.line?e.token.line-1:t.length-1,r=t[n]??"",o=e.token.line?e.token.column:Math.max(0,r.length-1),i=String(n+1).length,s=" ".repeat(i+5+o);return` ${n+1} | ${r}
|
|
7
7
|
`+s+"^".repeat(Math.max(1,e.token.value.length))+`
|
|
8
8
|
`+s+e.message+`
|
|
@@ -14,4 +14,4 @@
|
|
|
14
14
|
|
|
15
15
|
`+st(i)+s)}else F(e,"exception",{error:i}),console.error("hyperscript errors were found on the following element:",e,`
|
|
16
16
|
|
|
17
|
-
`,i)}}var dn=[],fn=[];function we(e){if(!(e instanceof Element||e instanceof Document||e instanceof DocumentFragment))return;for(let n of dn)n(e);let t=un().map(n=>`[${n}]`).join(", ")+", [type='text/hyperscript']";e instanceof Element&&e.matches(t)&&nn(e),e.querySelectorAll(t).forEach(nn);for(let n of fn)n(e)}function Me(e){let t=oe(e);if(t){F(e,"hyperscript:before:cleanup");for(let{target:n,event:r,handler:o}of t.listeners??[])n.removeEventListener(r,o);for(let n of t.observers??[])n.disconnect();for(let n of t.timers??[])clearTimeout(n);k.stop(e),e.querySelectorAll("[data-hyperscript-powered]").forEach(Me),F(e,"hyperscript:after:cleanup"),e.removeAttribute("data-hyperscript-powered"),ut(e)}}U.process=we;function rr(e){try{let t=an(e);return t.kind==="features"?{...t.program,errors:[]}:{...t.kind==="commands"?t.commands[0]:t.expression,errors:[]}}catch(t){if(t instanceof ee)return{errors:[t]};throw t}}var mn=Object.assign(tn,{config:Object.assign(J,{conversions:Object.assign(qe,{dynamicResolvers:De})}),use(e){e(mn)},addBeforeProcessHook:e=>void dn.push(e),addAfterProcessHook:e=>void fn.push(e),addSourceTransform:e=>void ln.push(e),evaluate:tn,parse:rr,process:we,processNode:we,cleanup:Me,internals:{runtime:{cleanup:Me,processNode:we}},version:"4.
|
|
17
|
+
`,i)}}var dn=[],fn=[];function we(e){if(!(e instanceof Element||e instanceof Document||e instanceof DocumentFragment))return;for(let n of dn)n(e);let t=un().map(n=>`[${n}]`).join(", ")+", [type='text/hyperscript']";e instanceof Element&&e.matches(t)&&nn(e),e.querySelectorAll(t).forEach(nn);for(let n of fn)n(e)}function Me(e){let t=oe(e);if(t){F(e,"hyperscript:before:cleanup");for(let{target:n,event:r,handler:o}of t.listeners??[])n.removeEventListener(r,o);for(let n of t.observers??[])n.disconnect();for(let n of t.timers??[])clearTimeout(n);k.stop(e),e.querySelectorAll("[data-hyperscript-powered]").forEach(Me),F(e,"hyperscript:after:cleanup"),e.removeAttribute("data-hyperscript-powered"),ut(e)}}U.process=we;function rr(e){try{let t=an(e);return t.kind==="features"?{...t.program,errors:[]}:{...t.kind==="commands"?t.commands[0]:t.expression,errors:[]}}catch(t){if(t instanceof ee)return{errors:[t]};throw t}}var mn=Object.assign(tn,{config:Object.assign(J,{conversions:Object.assign(qe,{dynamicResolvers:De})}),use(e){e(mn)},addBeforeProcessHook:e=>void dn.push(e),addAfterProcessHook:e=>void fn.push(e),addSourceTransform:e=>void ln.push(e),evaluate:tn,parse:rr,process:we,processNode:we,cleanup:Me,internals:{runtime:{cleanup:Me,processNode:we}},version:"4.2.0"});function pn(){if(Object.assign(globalThis,{_hyperscript:mn}),typeof document>"u")return;let e=()=>{we(document.documentElement),document.dispatchEvent(new Event("hyperscript:ready"))};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",e):setTimeout(e)}function or(e,t){if(typeof e!="object"||e===null)return{queue:[],executing:!1};let n=X(e).eventQueues??=new Map,r=n.get(t);return r||n.set(t,r={queue:[],executing:!1}),r}function it(e,t){let n=or(e.me,t);if(n.executing&&!t.every){if(t.queue==="none"||t.queue==="first"&&n.queue.length>0)return;t.queue!=="all"&&(n.queue.length=0),n.queue.push(e);return}n.executing=!0;let r=o=>{n.executing=!1;let i=n.queue.shift();if(i&&setTimeout(()=>it(i,t),1),o){let{error:s}=o;console.error(v(s,"message")??s),console.error(v(s,"stack")),F(e.me,"exception",{error:s})}};ue(()=>x(pt(e,t.body,t),()=>r()),o=>r({error:o}))}function sr(e,t){if(!W(t))return;let n=X(t),r=n.listeners??=[],o=n.observers??=[],i=n.timers??=new Set;for(let s of e.events){let u={execCount:0},a=s.elsewhere?[document]:s.from?s.from.ev(pe(t,e,t,null)):[t];C(a,l=>{if(!W(l)){console.warn("'%s' feature ignored because target does not exists:",e.displayName,t);return}let c=s.on;if(s.mutationSpec&&l instanceof Node){c="hyperscript:mutation";let f=new MutationObserver(d=>F(l,c,{mutationList:d,observer:f}));f.observe(l,s.mutationSpec),o.push(f)}if(s.intersectionSpec&&l instanceof Element){c="hyperscript:intersection";let f=new IntersectionObserver(d=>{for(let m of d)F(l,c,{observer:f,entry:m,intersecting:m.isIntersecting,isIntersecting:m.isIntersecting,intersectionRatio:m.intersectionRatio})},s.intersectionSpec);f.observe(l),o.push(f)}if(s.resizeSpec&&l instanceof Element){c="hyperscript:resize";let f=new ResizeObserver(d=>{for(let m of d){let{width:h,height:E}=m.contentRect;F(l,c,{width:h,height:E,contentRect:m.contentRect,entry:m})}});f.observe(l),o.push(f)}let p=f=>{if(t instanceof Node&&l!==t&&!t.isConnected){l.removeEventListener(c,p);return}let d=pe(t,e,t,f);if(!(s.elsewhere&&t instanceof Node&&f.target instanceof Node&&t.contains(f.target))){s.from&&(d.result=l);for(let m of s.args){let h=v(f,m);h!==void 0?d.locals[m]=h:d.detail!=null&&(d.locals[m]=v(d.detail,m))}if(s.filter){d.meta.context=f;try{if(!s.filter.ev(d))return}finally{d.meta.context=void 0}}if(s.inExpr?.css){let m=f.target instanceof Element?f.target:null;for(;m&&!m.matches(s.inExpr.css);)m=m.parentElement;if(!m)return;d.result=m}if(u.execCount++,s.startCount){let m=u.execCount;if(s.endCount?m<s.startCount||m>s.endCount:s.unbounded?m<s.startCount:m!==s.startCount)return}if(s.debounceTime){u.debounced&&(clearTimeout(u.debounced),i.delete(u.debounced)),i.add(u.debounced=setTimeout(()=>it(d,e),s.debounceTime));return}if(s.throttleTime){if(u.lastExec&&Date.now()<u.lastExec+s.throttleTime)return;u.lastExec=Date.now()}it(d,e)}};l.addEventListener(c,p),r.push({target:l,event:c,handler:p})})}}function ir(e){if(!e.match("of"))return{attributes:!0,characterData:!0,childList:!0,attributeOldValue:!0,characterDataOldValue:!0};let t={};do if(e.match("anything"))Object.assign(t,{attributes:!0,subtree:!0,characterData:!0,childList:!0});else if(e.match("childList"))t.childList=!0;else if(e.match("attributes"))t.attributes=!0;else if(e.match("subtree"))t.subtree=!0;else if(e.match("characterData"))t.characterData=!0;else if(e.cur().type==="ATTRIBUTE_REF"){let n=e.consume().value;n.startsWith("@")||e.err("Only shorthand attribute references are allowed here"),(t.attributeFilter??=[]).push(n.substring(1))}else e.err("Unknown mutation config specification");while(e.match("or"));return(t.attributes||t.attributeFilter)&&(t.attributeOldValue=!0),t.characterData&&(t.characterDataOldValue=!0),t}function ar(e){let t={};if(e.match("with")){let n=ye(g(e));n instanceof Element&&(t.root=n)}if(e.match("having"))do e.match("margin")?t.rootMargin=Tt(e):e.match("threshold")?t.threshold=Number(ye(g(e))):e.err("Unknown intersection config specification");while(e.match("and"));return t}function ur(e,t){let n=K(e),r=Le(e),o;e.matchOp("[")&&(o=g(e),e.reqOp("]"));let i,s,u=!1;t?i=1:e.cur().type==="NUMBER"&&(i=parseInt(e.consume().value),e.match("to")?s=parseInt(e.consume().value):e.match("and")&&(u=!0,e.req("on")));let a={on:n,args:r,filter:o,startCount:i,endCount:s,unbounded:u,elsewhere:!1,resizeSpec:n==="resize"};n==="intersection"?a.intersectionSpec=ar(e):n==="mutation"&&(a.mutationSpec=ir(e)),e.match("from")&&(e.match("elsewhere")?a.elsewhere=!0:a.from=e.withFollow(["or"],()=>g(e))),!a.from&&!a.elsewhere&&e.match("elsewhere")&&(a.elsewhere=!0),e.match("in")&&(a.inExpr=z(e));let l=()=>(e.req("at"),Number(ye(z(e))));return e.match("debounced")?a.debounceTime=l():e.match("throttled")&&(a.throttleTime=l()),a}function hn(e){e.features.on=(t,n)=>{let r=!!t.match("every"),o=!r&&!!t.match("first"),i=[];do i.push(ur(t,o));while(t.match("or"));let s="last";!r&&t.match("queue")&&(t.match("all")?s="all":t.match("first")?s="first":t.match("none")?s="none":t.req("last"));let u=Y(t),a={type:"onFeature",displayName:"on "+i.map(l=>l.on).join(" or "),events:i,body:u,every:r,queue:s,...It(t),start:n,end:t.endPos(),install:l=>sr(a,l)};return a}}on(hn,jt,Gt,$t,Ut,Zt,Kt,Jt,Lt,Ft,Vt,Bt,zt,Qt,Yt);pn();})();
|
package/dist/core.js
CHANGED
|
@@ -1040,6 +1040,7 @@
|
|
|
1040
1040
|
type: "symbol",
|
|
1041
1041
|
name,
|
|
1042
1042
|
scope,
|
|
1043
|
+
...on2 ? { on: on2 } : {},
|
|
1043
1044
|
start,
|
|
1044
1045
|
end: p.endPos(),
|
|
1045
1046
|
ev: (ctx) => resolveSymbol(name, ctx, scope, on2?.ev(ctx)),
|
|
@@ -1903,7 +1904,7 @@
|
|
|
1903
1904
|
cleanup,
|
|
1904
1905
|
/** The part of upstream's `internals` that pages and tests reach for. */
|
|
1905
1906
|
internals: { runtime: { cleanup, processNode } },
|
|
1906
|
-
version: false ? "dev" : "4.
|
|
1907
|
+
version: false ? "dev" : "4.2.0"
|
|
1907
1908
|
});
|
|
1908
1909
|
function boot() {
|
|
1909
1910
|
Object.assign(globalThis, { _hyperscript: api });
|