jq79 0.1.6 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,14 @@
1
+
1
2
  # jq79
2
3
 
3
- A mini reactive component library in a single file. Single-file components (template + `<script :setup>` + `<style>`), Svelte-style reactive scripts, fine-grained DOM updates via proxy-based dependency tracking — no compiler, no virtual DOM, no dependencies.
4
+ <img src="assets/Component79.svg" alt="jq79 logo" width="100" align="right">
5
+
6
+ [![npm](https://jgermade.github.io/jq79/badges/npm.svg)](https://www.npmjs.com/package/jq79)
7
+ [![coverage](https://jgermade.github.io/jq79/badges/coverage.svg)](https://jgermade.github.io/jq79/coverage/)
8
+
9
+ A mini reactive component library that ships as a single file. Svelte-style reactive scripts, fine-grained DOM updates via proxy-based dependency tracking
10
+
11
+ > no compiler, no virtual DOM, no dependencies.
4
12
 
5
13
  ## Installation
6
14
 
@@ -14,6 +22,26 @@ npm install jq79
14
22
  import { Component79, $, $$ } from "jq79"
15
23
  ```
16
24
 
25
+ ### Vite
26
+
27
+ With the bundled plugin, `.html` component files import as modules — no
28
+ runtime fetch, with HMR in dev:
29
+
30
+ ```js
31
+ // vite.config.js
32
+ import { jq79 } from "jq79/vite"
33
+ export default { plugins: [jq79()] }
34
+ ```
35
+
36
+ ```js
37
+ import UserCard from "./UserCard.html"
38
+ UserCard.mount("#app")
39
+ ```
40
+
41
+ The plugin is a pure loader (nothing inside the component is transformed), so
42
+ the same file keeps working from `public/` via `Component79.fetch` — see
43
+ [the Vite plugin docs](docs/vite-plugin.md).
44
+
17
45
  ### CDN
18
46
 
19
47
  Once published to npm, the package is automatically served by every major CDN — no separate publishing step:
@@ -24,25 +52,28 @@ Once published to npm, the package is automatically served by every major CDN
24
52
  import { Component79 } from "https://esm.sh/jq79"
25
53
  // or: https://cdn.jsdelivr.net/npm/jq79/+esm
26
54
  // or: https://unpkg.com/jq79?module
55
+ // or, straight from this repo's GitHub Pages (latest release):
56
+ // https://jgermade.github.io/jq79/jq79.js
27
57
  </script>
28
58
 
29
59
  <!-- or as a classic script exposing window.jq79 -->
30
60
  <script src="https://cdn.jsdelivr.net/npm/jq79/dist/jq79.global.js"></script>
61
+ <!-- or: <script src="https://jgermade.github.io/jq79/jq79.global.js"></script> -->
31
62
  <script>
32
63
  const { Component79 } = jq79
33
64
  </script>
34
65
  ```
35
66
 
36
- Pin a version in production: `https://cdn.jsdelivr.net/npm/jq79@0.1.0/...`.
67
+ Pin a version in production: `https://cdn.jsdelivr.net/npm/jq79@0.1.0/...` (the GitHub Pages copy always tracks the latest release).
37
68
 
38
- Or grab [`src/jq79.ts`](src/jq79.ts) directlythe whole library is one file.
69
+ The source is small enough to read in a sitting: the core (parsing, rendering, components) lives in [`src/jq79.ts`](src/jq79.ts), with three leaf helpers [`dom.ts`](src/dom.ts), [`reactive.ts`](src/reactive.ts) and [`transform.ts`](src/transform.ts). The published build is a single dependency-free file.
39
70
 
40
71
  ## Quick start
41
72
 
42
73
  ```js
43
74
  import { Component79 } from "jq79"
44
75
 
45
- const jq79 = new Component79(`
76
+ const jq79 = new Component79(html`
46
77
  <script :setup>
47
78
  let firstName = null
48
79
  let lastName = null
@@ -63,266 +94,20 @@ const jq79 = new Component79(`
63
94
  </style>
64
95
  `)
65
96
 
66
- jq79.render().mount("#app")
97
+ jq79.mount("#app")
67
98
  ```
68
99
 
69
100
  When the fetch resolves, the assignments to `firstName`/`lastName` re-run the `$:` declaration, which flips the `:if` and renders the span — no manual wiring.
70
101
 
71
- ## Components
72
-
73
- ### Lifecycle
74
-
75
- ```js
76
- const jq79 = new Component79(src) // src: string, or { template, scripts, styles }
77
-
78
- jq79.render(data) // build reactive DOM, run setup scripts, inject styles
79
- .mount(el) // attach; accepts an Element or a selector string
80
-
81
- jq79.unmount() // detach, keeping state — mount() re-attaches, with
82
- // any updates that happened while detached applied
83
- .destroy() // dispose all effects and remove injected styles
84
- ```
85
-
86
- - `render(data)` injects the component's `<style>` blocks into `document.head`.
87
- - `renderShadow(data)` instead attaches a shadow root to the mount target and injects content and styles there, so CSS stays scoped to the component.
88
- - `jq79.data` is the live reactive store — mutate it from outside and the DOM follows.
89
-
90
- ### Loading remote components
91
-
92
- ```js
93
- const jq79 = await Component79.fetch("/components/user-card.html")
94
- jq79.render({ userId: 42 }).mount("#app")
95
- ```
96
-
97
- ## Template syntax
98
-
99
- ### Interpolation
100
-
101
- Any JS expression between `{{ }}`:
102
-
103
- ```html
104
- <span>{{ user.name }}</span>
105
- <span>{{ price * quantity }} €</span>
106
- ```
107
-
108
- ### `:bind` — dynamic attributes
109
-
110
- Evaluates to an object; each entry becomes an attribute. `null`, `undefined` and `false` values remove the attribute.
111
-
112
- ```html
113
- <button :bind="{ disabled: isSaving, title: tooltip }">Save</button>
114
- ```
115
-
116
- ### `:if` / `:elseif` / `:else` — conditionals
117
-
118
- Consecutive siblings form one chain; only the active branch is in the DOM.
119
-
120
- ```html
121
- <div :if="score > 8">great</div>
122
- <div :elseif="score > 4">ok</div>
123
- <div :else>bad</div>
124
- ```
125
-
126
- ### `:each` / `:key` — lists
127
-
128
- ```html
129
- <li :each="user in users" :key="user.id">{{ $index }}: {{ user.name }}</li>
130
- ```
131
-
132
- The list is diffed by key: unchanged items keep their DOM (and state) when the array is reordered, filtered or extended. Without `:key`, position is used — fine for append-only lists, wasteful for reordering. `$index` is available inside each item.
133
-
134
- ### `:with` — narrowed scope
135
-
136
- Evaluates to an object whose properties become directly addressable inside the element; anything else still resolves from the outer scope:
137
-
138
- ```html
139
- <div :each="item in items">
140
- <div>{{ item.name }}</div>
141
- <div :with="item">
142
- Another way to get: {{ name }}
143
- Items total: {{ items.length }}
144
- </div>
145
- </div>
146
- ```
147
-
148
- - Applies to the element's own bindings (`:bind`, `@events`) and its whole subtree; object properties shadow same-named outer scope names.
149
- - Fully reactive: mutating a property of the object, or replacing the object itself (`user = other`), updates exactly what depends on it — the subtree is not rebuilt.
150
- - Assignments to names the object owns write through to it (`@click="name = 'x'"` inside `:with="user"` sets `user.name`, reactively).
151
- - If the expression isn't an object (`null`, still loading, …), names simply resolve from the outer scope.
152
- - Combines with `:each`/`:if` on the same element: those evaluate in the outer scope first, then `:with` wraps the subtree — so `:with="item"` on the `:each` element itself works.
153
-
154
- ### `@event` — listeners
155
-
156
- ```html
157
- <button @click="onClick">…</button>
158
- <form @submit.prevent="$event => onSubmit($event)">…</form>
159
- <button @click="count = count + 1">clicked {{ count }} times</button>
160
- ```
161
-
162
- The attribute value is evaluated on every event with `$event` in scope; if it evaluates to a function, that function is called with the event. So all three styles work: a handler reference, an inline arrow, or an inline statement that mutates reactive data.
163
-
164
- Modifiers (chainable, e.g. `@click.stop.once`):
165
-
166
- | modifier | effect |
167
- | ---------- | ---------------------------------------- |
168
- | `.prevent` | `event.preventDefault()` |
169
- | `.stop` | `event.stopPropagation()` |
170
- | `.self` | only fire when `event.target` is the element itself |
171
- | `.once` | listener runs at most once |
172
- | `.capture` | listen in the capture phase |
173
-
174
- ### Nested components
175
-
176
- A tag matching a **PascalCase scope variable** renders as a child component. Components reach the scope through render data, `:setup` props, or an `await import(...)` in the setup script:
177
-
178
- ```html
179
- <script :setup="{ user, NestedComponent }">
180
- const ImportedComponent = await import('/components/foobar.html')
181
- </script>
182
-
183
- <div>
184
- <NestedComponent :user :title="'Hardcoded title'" />
185
- <ImportedComponent :user="user" />
186
- </div>
187
- ```
188
-
189
- ```html
190
- <!-- /components/foobar.html -->
191
- <script :setup="{ user }"></script>
192
- <div>User: {{ user.firstName }}</div>
193
- ```
194
-
195
- - Props: `:name="expr"` evaluates in the parent scope; `:name` alone is shorthand for `:name="name"`; plain attributes pass as literal strings.
196
- - Props are **live**: when a parent expression's dependencies change (deeply), the new value is written into the child's store.
197
- - HTML lowercases everything, so matching ignores case and dashes: `<NestedComponent>` and `<nested-component>` both resolve `NestedComponent`, and `:user-name` becomes the `userName` prop.
198
- - `await import('/x.html')` returns a `Component79` (non-`.html` URLs fall through to native `import()`). While the promise is pending nothing renders; the child appears when it resolves.
199
- - Each usage site gets its own instance (own store, effects and DOM); instances are destroyed with their parent. Identical `<style>` blocks are refcounted, so N instances inject one tag.
200
- - Self-closing tags work: jq79 expands `<MyComponent />` (and `<div />`) into explicit open+close pairs before HTML parsing, since the HTML parser would otherwise treat them as unclosed. Void elements (`<img />`, `<br />`) and `<script>`/`<style>` contents are left untouched.
201
-
202
- ## Setup scripts
203
-
204
- `<script :setup>` blocks run against the component's reactive scope, Svelte-style:
205
-
206
- ```html
207
- <script :setup="{ fname, lname }">
208
- let count = 0 // top-level let/var/const become reactive scope vars
209
- const greeting = `Hi ${fname}` // initialized once, visible to the template
210
-
211
- $: doubled = count * 2 // re-runs whenever `count` changes
212
-
213
- setInterval(() => { count++ }, 1000) // assignments from callbacks work too
214
- </script>
215
- ```
216
-
217
- - Top-level `let` / `var` / `const` declarations become properties of the reactive store (also reachable from outside via `jq79.data`).
218
- - `$: x = expr` is a reactive declaration: it re-runs whenever anything it reads changes.
219
- - Assignments — including from `.then()` callbacks, timers, and event handlers — go through the reactive proxy and update the DOM.
220
- - Globals (`fetch`, `console`, `Promise`, …) resolve normally; assignments to names you never declared stay on the component scope instead of leaking to `globalThis`.
221
- - The [DOM helpers](#dom-helpers) `$`, `$$` and `$create`, plus [`$reactive`](#reactive-data), are automatically available in every setup script — no import or declaration needed, same as `$emit` and `$mounted`. Like globals, they are shadowed by same-named scope properties.
222
- - `$emit(eventName, payload)` dispatches a native bubbling `CustomEvent` (with `payload` as `event.detail`) from the component's position in the DOM. Listen from a parent component with `@event-name` on any wrapping element, or with plain `addEventListener` on the mount target:
223
-
224
- ```html
225
- <!-- child -->
226
- <script :setup>
227
- const save = () => $emit("saved", { id: 42 })
228
- </script>
229
- <button @click="save">Save</button>
230
-
231
- <!-- parent -->
232
- <div @saved="lastSaved = $event.detail.id">
233
- <ChildForm />
234
- </div>
235
- ```
236
-
237
- Events emitted before the component is mounted have no ancestors to bubble to, so nobody hears them — `$emit` is meant for handlers and async code, not synchronous top-level setup.
238
-
239
- - `await $mounted()` suspends the script until the component is attached to the DOM, so everything below it can use `querySelector` (or `$`/`$$`) directly:
240
-
241
- ```html
242
- <script :setup>
243
- let items = await fetchItems() // runs before render
244
-
245
- await $mounted()
246
-
247
- let height = $(".list").offsetHeight // real DOM access — still reactive
248
- </script>
249
- <ul class="list">
250
- <li :each="item in items">{{ item }}</li>
251
- </ul>
252
- ```
253
-
254
- Reactivity is unaffected by where a declaration sits: variables declared after the `await` are pre-declared on the store before the first render (as `undefined`), so the template can bind to them from the start and updates when the assignment runs. If the component is never mounted, the code after `await $mounted()` never runs.
255
-
256
- To defer a whole script until mount, add `:mounted` to the tag — it behaves as if `await $mounted()` were its first line:
257
-
258
- ```html
259
- <script :setup :mounted>
260
- $self(".list").focus() // the component is already in the DOM
261
- </script>
262
- ```
263
-
264
- - `$self(selector)` and `$$self(selector)` are component-scoped versions of [`$` / `$$`](#dom-helpers): they only search this component instance's own rendered nodes, so they can't accidentally match another component (or anything else in the page). They work even while the component is rendered but not yet mounted — but remember the template renders *after* the synchronous part of the script, so call them from post-`await $mounted()` code or from handlers/callbacks.
265
-
266
- Only top-level code is rewritten; declarations inside callbacks/blocks behave as plain JS. `let a = 1, b = 2` multi-declarators are not supported — one declaration per statement.
267
-
268
- ## Reactive data
269
-
270
- The store used by components is available standalone:
271
-
272
- ```js
273
- import { $reactive } from "jq79" // also injected into setup scripts
274
-
275
- const data = $reactive({ user: { address: { city: "NYC" } } })
276
-
277
- data.$on("user.address.city", (value, dotKey) => { … }, { immediate: true })
278
- data.$onAny((dotKey, value) => { … })
279
- const stop = data.$effect(() => {
280
- // re-runs whenever anything it *read* changes (fine-grained, deep)
281
- console.log(data.user.address.city)
282
- })
283
-
284
- data.user.address.city = "LA" // deep mutations notify with the full dot path
285
- stop() // effects/listeners return an unsubscribe fn
286
- ```
287
-
288
- ## DOM helpers
289
-
290
- ```js
291
- import { $, $$, $create } from "jq79"
292
-
293
- $(".card") // document.querySelector
294
- $(el, ".card") // scoped querySelector
295
- $$(".card") // querySelectorAll, as a real Array
296
- $$(el, ".card") // scoped
297
-
298
- $create("div", { // document.createElement + attrs
299
- className: ["card", "active"], // string or array
300
- textContent: "hi",
301
- children: [$create("span")],
302
- "data-id": "42", // anything else via setAttribute
303
- })
304
- ```
305
-
306
- ## Development
307
-
308
- ```sh
309
- npm install
310
- npm test # vitest + jsdom
311
- npm run build # tsup → dist/ (ESM + CJS + IIFE + .d.ts)
312
- ```
313
-
314
- ## Publishing
315
-
316
- Releases are automated via GitHub Actions ([release.yml](.github/workflows/release.yml)):
317
-
318
- ```sh
319
- npm version patch|minor|major # bumps package.json and creates the vX.Y.Z tag
320
- git push --follow-tags
321
- ```
322
-
323
- Pushing the tag runs tests + build, creates the GitHub release with the `dist/` files attached, and publishes to npm with provenance. Requires an `NPM_TOKEN` repository secret (npm automation token). CDNs (unpkg, jsDelivr, esm.sh) pick the new version up from npm automatically.
102
+ ## Documentation
324
103
 
325
- Every push/PR to `main` also runs tests + build ([ci.yml](.github/workflows/ci.yml)).
104
+ - [Components](docs/components.md) lifecycle (`mount`, `mountShadow`, `detach`, `destroy`), instance events (`on`/`off`), loading remote components with `Component79.fetch`.
105
+ - [Template syntax](docs/template-syntax.md) — `{{ }}` interpolation, `:bind`, `:if`/`:elseif`/`:else`, `:each`/`:key`, `:with`, `@event` listeners and modifiers, nested components.
106
+ - [Setup scripts](docs/setup-scripts.md) — `<script :setup>` reactive scripts, `$:` declarations, `$emit`, `await $mounted()`, `$self`/`$$self`, and `export default` factory scripts (plain-JS alternative).
107
+ - [Reactive data](docs/reactive-data.md) — the standalone `$reactive` store: `$on`, `$onAny`, `$effect`.
108
+ - [DOM helpers](docs/dom-helpers.md) — `$`, `$$` and `$create`.
109
+ - [Vite plugin](docs/vite-plugin.md) — importing `.html` components as bundled modules, HMR, options.
110
+ - [Development](docs/development.md) — running tests, building, publishing releases.
326
111
 
327
112
  ## License
328
113
 
@@ -0,0 +1,8 @@
1
+ <svg width="100%" viewBox="0 0 410 410" xmlns="http://www.w3.org/2000/svg" role="img" style="">
2
+ <title style="fill:rgb(0, 0, 0);stroke:none;color:rgb(11, 11, 11);stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;opacity:1;font-family:&quot;Anthropic Sans&quot;, -apple-system, &quot;system-ui&quot;, &quot;Segoe UI&quot;, sans-serif;font-size:16px;font-weight:400;text-anchor:start;dominant-baseline:auto">Component79 logo</title>
3
+ <desc style="fill:rgb(0, 0, 0);stroke:none;color:rgb(11, 11, 11);stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;opacity:1;font-family:&quot;Anthropic Sans&quot;, -apple-system, &quot;system-ui&quot;, &quot;Segoe UI&quot;, sans-serif;font-size:16px;font-weight:400;text-anchor:start;dominant-baseline:auto">A square logo with a royalblue background, with "jq" in white and "79" in JS-yellow in the bottom right corner</desc>
4
+ <rect x="0" y="0" width="400" height="400" fill="royalblue" style="fill:rgb(65, 105, 225);stroke:none;color:rgb(11, 11, 11);stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;opacity:1;font-family:&quot;Anthropic Sans&quot;, -apple-system, &quot;system-ui&quot;, &quot;Segoe UI&quot;, sans-serif;font-size:16px;font-weight:400;text-anchor:start;dominant-baseline:auto"/>
5
+ <text x="372" y="340" text-anchor="end" font-family="Arial, Helvetica, sans-serif" font-weight="700" font-size="96" style="fill:rgb(0, 0, 0);stroke:none;color:rgb(11, 11, 11);stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;opacity:1;font-family:Arial, Helvetica, sans-serif;font-size:96px;font-weight:700;text-anchor:end;dominant-baseline:auto">
6
+ <tspan fill="#FFFFFF" style="fill:rgb(255, 255, 255);stroke:none;color:rgb(11, 11, 11);stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;opacity:1;font-family:Arial, Helvetica, sans-serif;font-size:96px;font-weight:700;text-anchor:end;dominant-baseline:auto">jq</tspan><tspan fill="#F7DF1E" style="fill:rgb(247, 223, 30);stroke:none;color:rgb(11, 11, 11);stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;opacity:1;font-family:Arial, Helvetica, sans-serif;font-size:96px;font-weight:700;text-anchor:end;dominant-baseline:auto">79</tspan>
7
+ </text>
8
+ </svg>
package/dist/dom.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ export declare const $: (selectorOrEl: string | Element, selector?: string) => Element | null;
2
+ export declare const $$: (selectorOrEl: string | Element, selector?: string) => Element[];
3
+ export declare const $create: (tag: string, attrs?: Record<string, any>) => HTMLElement;
package/dist/jq79.cjs CHANGED
@@ -1,6 +1,10 @@
1
- var N=Object.defineProperty;var Q=Object.getOwnPropertyDescriptor;var ee=Object.getOwnPropertyNames;var te=Object.prototype.hasOwnProperty;var ne=(e,t,s)=>t in e?N(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s;var se=(e,t)=>{for(var s in t)N(e,s,{get:t[s],enumerable:!0})},re=(e,t,s,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of ee(t))!te.call(e,r)&&r!==s&&N(e,r,{get:()=>t[r],enumerable:!(n=Q(t,r))||n.enumerable});return e};var oe=e=>re(N({},"__esModule",{value:!0}),e);var E=(e,t,s)=>ne(e,typeof t!="symbol"?t+"":t,s);var Le={};se(Le,{$:()=>M,$$:()=>H,$create:()=>z,$reactive:()=>D,Component79:()=>w,parseComponent:()=>Ae,renderComponent:()=>ye});module.exports=oe(Le);var M=(e,t)=>typeof e=="string"?document.querySelector(e):e.querySelector(t||""),H=(e,t)=>Array.from(typeof e=="string"?document.querySelectorAll(e):e.querySelectorAll(t||"")),z=(e,t={})=>{let s=document.createElement(e);for(let[n,r]of Object.entries(t))if(n==="className")s.className=Array.isArray(r)?r.join(" "):r;else if(n==="textContent")s.textContent=r;else if(n==="children")for(let i of r)s.appendChild(i);else s.setAttribute(n,r);return s},V=e=>Object.fromEntries(Array.from(e.attributes).map(t=>[t.name,t.value])),Z=e=>({tag:e.tagName.toLowerCase(),attrs:V(e),children:Array.from(e.childNodes).flatMap(t=>{if(t.nodeType===Node.TEXT_NODE){let s=t.textContent?.trim()??"";return s?[s]:[]}return t.nodeType===Node.ELEMENT_NODE?[Z(t)]:[]})}),S=(e,t,s)=>{try{return new Function("$scope",...Object.keys(s??{}),`with ($scope) { return (${e}); }`)(t,...Object.values(s??{}))}catch{return}},ie=(e,t)=>e.replace(/{{\s*(.+?)\s*}}/g,(s,n)=>S(n,t)??""),ce=(e,t)=>t.split(".").reduce((s,n)=>s?.[n],e),j=e=>{if(Array.isArray(e))return!0;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null},K=(e,t,s)=>{Object.entries(e).forEach(([n,r])=>{let i=t?`${t}.${n}`:n;r&&typeof r=="object"&&j(r)?K(r,i,s):s(i,r)})},ae=(e,t)=>e===t||e.startsWith(`${t}.`)||t.startsWith(`${e}.`),x=[],le=e=>{x.push(new Set);try{return e()}finally{x.pop()}},D=e=>{let t=new Map,s=new Set,n=new Set,r=new WeakSet,i=(c,d)=>{t.get(c)?.forEach(h=>h(d,c)),s.forEach(h=>h(c,d)),n.forEach(h=>{Array.from(h.deps).some(u=>ae(u,c))&&h.run()})},o=(c,d)=>{if(r.has(c))return c;Object.entries(c).forEach(([u,p])=>{p&&typeof p=="object"&&j(p)&&(c[u]=o(p,d?`${d}.${u}`:u))});let h=new Proxy(c,{get(u,p,f){return typeof p=="string"&&x[x.length-1]?.add(d?`${d}.${p}`:p),Reflect.get(u,p,f)},set(u,p,f,b){if(b!==h&&!Object.prototype.hasOwnProperty.call(u,p))return Reflect.set(u,p,f,b);let C=d?`${d}.${p}`:p;return f&&typeof f=="object"&&j(f)&&(f=o(f,C)),u[p]=f,i(C,f),!0}});return r.add(h),h},a=o(e,""),l=(c,d,{immediate:h=!1}={})=>(t.has(c)||t.set(c,new Set),t.get(c).add(d),h&&d(ce(a,c),c),()=>t.get(c)?.delete(d)),m=(c,{immediate:d=!1}={})=>(s.add(c),d&&K(a,"",(h,u)=>c(h,u)),()=>s.delete(c)),g=c=>{let d={deps:new Set,run:()=>{let h=new Set;x.push(h);try{c()}finally{x.pop(),d.deps=h}}};return n.add(d),d.run(),()=>{n.delete(d)}};return Object.defineProperty(a,"$on",{value:l,enumerable:!1}),Object.defineProperty(a,"$onAny",{value:m,enumerable:!1}),Object.defineProperty(a,"$effect",{value:g,enumerable:!1}),a},G=new Set([":bind",":if",":elseif",":else",":each",":key",":with"]),de=/^\s*(\w+)\s+in\s+(.+)$/,T=e=>{let t=[];return{effect:s=>{t.push(e.$effect(s))},onDispose:s=>{t.push(s)},dispose:()=>{t.splice(0).forEach(s=>s())}}},ue=(e,t,s,n)=>{let[r,...i]=t.slice(1).split("."),o=new Set(i);e.addEventListener(r,a=>{if(o.has("self")&&a.target!==e)return;o.has("prevent")&&a.preventDefault(),o.has("stop")&&a.stopPropagation();let l=S(s,n,{$event:a});typeof l=="function"&&l.call(e,a)},{once:o.has("once"),capture:o.has("capture")})},F=e=>e.replace(/-(\w)/g,(t,s)=>s.toUpperCase()),pe=(e,t)=>{let s=t.replace(/-/g,"").toLowerCase();for(let n=e;n&&n!==Object.prototype;n=Object.getPrototypeOf(n))for(let r of Object.keys(n))if(/^[A-Z]/.test(r)&&r.replace(/-/g,"").toLowerCase()===s)return r;return null},fe=(e,t,s,n)=>{let r=document.createComment(e),i=document.createDocumentFragment();i.appendChild(r);let o={};Object.entries(t.attrs).forEach(([g,c])=>{if(!(G.has(g)||g.startsWith("@")))if(g.startsWith(":")){let d=F(g.slice(1));o[d]=c||d}else o[F(g)]=JSON.stringify(c)});let a=null,l=null,m=null;return n.effect(()=>{let g=S(e,s),c=g instanceof w?g:null;if(c===l||(m?.dispose(),m=null,a?.destroy(),a=null,l=c,!c))return;let d=new w({template:c.template,scripts:c.scripts,styles:c.styles}),h=le(()=>Object.fromEntries(Object.entries(o).map(([f,b])=>[f,S(b,s)]))),u=document.createDocumentFragment();d.render(h).mount(u),r.parentNode.insertBefore(u,r.nextSibling);let p=T(s);Object.entries(o).forEach(([f,b])=>{p.effect(()=>{d.data[f]=S(b,s)})}),m=p,a=d}),n.onDispose(()=>{m?.dispose(),a?.destroy()}),i},he=(e,t)=>{let s=()=>{let n=S(e,t);return n!==null&&typeof n=="object"?n:null};return new Proxy(t,{has(n,r){let i=s();return i!==null&&Reflect.has(i,r)||Reflect.has(n,r)},get(n,r){let i=s();return i!==null&&Reflect.has(i,r)?i[r]:Reflect.get(n,r)},set(n,r,i){let o=s();return o!==null&&Reflect.has(o,r)?(o[r]=i,!0):Reflect.set(n,r,i)}})},_=(e,t,s)=>{let n=e.attrs[":with"],r=n!==void 0?he(n,t):t,i=pe(r,e.tag);if(i)return fe(i,e,r,s);let o=document.createElement(e.tag);Object.entries(e.attrs).forEach(([l,m])=>{l.startsWith("@")?ue(o,l,m,r):G.has(l)||o.setAttribute(l,m)});let a=e.attrs[":bind"];if(a!==void 0){let l=[];s.effect(()=>{l.forEach(g=>o.removeAttribute(g));let m=S(a,r);l=m&&typeof m=="object"?Object.keys(m):[],l.forEach(g=>{let c=m[g];c!=null&&c!==!1&&o.setAttribute(g,String(c))})})}return o.appendChild(k(e.children,r,s)),o},me=(e,t,s)=>{let n=document.createComment("if"),r=document.createDocumentFragment();r.appendChild(n);let i=null,o=null,a=null;return s.effect(()=>{let l=e.find(m=>m.expr===void 0||S(m.expr,t))??null;l!==o&&(a?.dispose(),i&&i.parentNode?.removeChild(i),i=null,o=l,l&&(a=T(t),i=_(l.node,t,a),n.parentNode.insertBefore(i,n.nextSibling)))}),r},L=(e,t,s)=>{Object.defineProperty(e,t,{value:s,writable:!0,enumerable:!0,configurable:!0})},ge=(e,t,s)=>{let n=e.attrs[":each"].match(de);if(!n)return document.createComment(`invalid :each expression "${e.attrs[":each"]}"`);let[,r,i]=n,o=e.attrs[":key"],{[":each"]:a,[":key"]:l,...m}=e.attrs,g={...e,attrs:m},c=document.createComment("each"),d=document.createDocumentFragment();d.appendChild(c);let h=[];return s.effect(()=>{let u=S(i,t),p=Array.isArray(u)?u:[],f=new Map(h.map(y=>[y.key,y])),b=p.map((y,A)=>{let $=Object.create(t);L($,r,y),L($,"$index",A);let P=o!==void 0?S(o,$):A,R=f.get(P);if(R&&Object.is(R.item,y))return L(R.scope,"$index",A),R;R?.fx.dispose(),R?.node.parentNode?.removeChild(R.node);let B=T(t);return{key:P,item:y,scope:$,fx:B,node:_(g,$,B)}}),C=new Set(b.map(y=>y.key));h.forEach(y=>{C.has(y.key)||(y.fx.dispose(),y.node.parentNode?.removeChild(y.node))});let O=c;b.forEach(y=>{O.nextSibling!==y.node&&c.parentNode.insertBefore(y.node,O.nextSibling),O=y.node}),h=b}),d},k=(e,t,s)=>{let n=document.createDocumentFragment(),r=0;for(;r<e.length;){let i=e[r];if(typeof i=="string"){let o=document.createTextNode("");s.effect(()=>{o.textContent=ie(i,t)}),n.appendChild(o),r++;continue}if(":each"in i.attrs){n.appendChild(ge(i,t,s)),r++;continue}if(":if"in i.attrs){let o=[{expr:i.attrs[":if"],node:i}];for(r++;r<e.length&&typeof e[r]!="string"&&":elseif"in e[r].attrs;){let a=e[r];o.push({expr:a.attrs[":elseif"],node:a}),r++}r<e.length&&typeof e[r]!="string"&&":else"in e[r].attrs&&(o.push({node:e[r]}),r++),n.appendChild(me(o,t,s));continue}n.appendChild(_(i,t,s)),r++}return n},ye=(e,t)=>k(e.template,t,T(t)),Ee=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),be=/<([A-Za-z][\w-]*)((?:"[^"]*"|'[^']*'|[^>"'])*?)\/>/g,Se=/(<script[\s\S]*?<\/script\s*>|<style[\s\S]*?<\/style\s*>)/gi,Ce=e=>e.split(Se).map((t,s)=>s%2===1?t:t.replace(be,(n,r,i)=>Ee.has(r.toLowerCase())?n:`<${r}${i}></${r}>`)).join(""),Re=e=>{let s=new DOMParser().parseFromString(`<template>${Ce(e)}</template>`,"text/html").querySelector("template"),n=[],r=[],i=[];return Array.from(s.content.children).forEach(o=>{let a={attrs:V(o),content:o.textContent??""};o.tagName==="SCRIPT"?n.push(a):o.tagName==="STYLE"?r.push(a):i.push(Z(o))}),{template:i,scripts:n,styles:r}},I=/(?:let|var|const)\s+([A-Za-z_$][\w$]*)/y,q=/\$:\s*/y,U=/import(?=\s*\()/y,W=/\$:\s*([A-Za-z_$][\w$]*)\s*=(?!=)/y,J=(e,t)=>{let s=e[t],n=t+1;for(;n<e.length;){if(e[n]==="\\"){n+=2;continue}if(e[n]===s)return n+1;n++}return e.length},X=(e,t)=>{let s=e.indexOf(`
2
- `,t);return s===-1?e.length:s},Y=(e,t)=>{let s=e.indexOf("*/",t+2);return s===-1?e.length:s+2},we=(e,t)=>{let s=0,n=t;for(;n<e.length;){let r=e[n];if(r==="'"||r==='"'||r==="`"){n=J(e,n);continue}if(r==="/"&&e[n+1]==="/"){n=X(e,n);continue}if(r==="/"&&e[n+1]==="*"){n=Y(e,n);continue}if("([{".includes(r))s++;else if(")]}".includes(r))s--;else if(s<=0&&(r===`
3
- `||r===";"))return n;n++}return e.length},xe=e=>{let t=[],s="",n=0,r=0,i=!0;for(;n<e.length;){let o=e[n],a=e[n+1];if(o==="'"||o==='"'||o==="`"){let l=J(e,n);s+=e.slice(n,l),n=l,i=!1;continue}if(o==="/"&&(a==="/"||a==="*")){let l=a==="/"?X(e,n):Y(e,n);s+=e.slice(n,l),n=l;continue}if(o==="i"&&(n===0||!/[\w$.]/.test(e[n-1]))&&(U.lastIndex=n,U.test(e))){s+="$__import",n+=6,i=!1;continue}if(r===0&&i){I.lastIndex=n;let l=I.exec(e);if(l){t.push(l[1]),s+=l[1],n+=l[0].length,i=!1;continue}q.lastIndex=n;let m=q.exec(e);if(m){W.lastIndex=n;let g=W.exec(e);g&&t.push(g[1]);let c=n+m[0].length,d=we(e,c);s+=`$__effect(() => { ${e.slice(c,d)} });`,n=d;continue}}"([{".includes(o)?r++:")]}".includes(o)&&(r=Math.max(0,r-1)),o===`
4
- `||o===";"||o==="}"?i=!0:/\s/.test(o)||(i=!1),s+=o,n++}return{vars:t,code:s}},$e=e=>/\.html?([?#]|$)/.test(e)?w.fetch(e):import(e),v=new Map,Te=e=>{let t=v.get(e);if(!t){let s=document.createElement("style");s.textContent=e,document.head.appendChild(s),t={el:s,count:0},v.set(e,t)}t.count++},Ne=e=>{let t=v.get(e);t&&--t.count<=0&&(t.el.remove(),v.delete(e))},ve={$:M,$$:H,$create:z,$reactive:D},Oe=(e,t,s,n={})=>{let r={...ve,...n},i=new Proxy(t,{has:(a,l)=>l!=="$__effect"&&l!=="$__import"&&(Reflect.has(a,l)||!(l in globalThis)&&!(l in r))});new Function("$scope","$__effect","$__import",...Object.keys(r),`return (async () => { with ($scope) { ${e} } })()`)(i,s,$e,...Object.values(r)).catch(a=>console.error("jq79: error in :setup script",a))},w=class e{constructor(t){E(this,"template");E(this,"scripts");E(this,"styles");E(this,"data",null);E(this,"fx",null);E(this,"content",null);E(this,"startMarker",null);E(this,"endMarker",null);E(this,"styleEls",[]);E(this,"ownsSharedStyles",!1);E(this,"useShadow",!1);E(this,"mountRoot",null);E(this,"resolveMounted",null);let{template:s,scripts:n,styles:r}=typeof t=="string"?Re(t):t;this.template=s,this.scripts=n,this.styles=r}static async fetch(t){let s=await fetch(t);if(!s.ok)throw new Error(`failed to fetch component from ${t}: ${s.status}`);return new e(await s.text())}render(t={}){return this.renderWith(t,!1)}renderShadow(t={}){return this.renderWith(t,!0)}renderWith(t,s){this.destroy();let n=D({...t}),r=T(n);this.data=n,this.fx=r,this.useShadow=s,this.startMarker=document.createComment("jq79"),this.endMarker=document.createComment("/jq79");let i=this.startMarker,o=(u,p)=>i.dispatchEvent(new CustomEvent(u,{detail:p,bubbles:!0,composed:!0})),a,l=new Promise(u=>{a=u});this.resolveMounted=a;let m=()=>l,g=this.endMarker,c=u=>{let p=[];for(let f=i.nextSibling;f&&f!==g;f=f.nextSibling)f instanceof Element&&(f.matches(u)&&p.push(f),p.push(...Array.from(f.querySelectorAll(u))));return p},d=u=>c(u)[0]??null;this.scripts.forEach(u=>{let{vars:p,code:f}=xe(u.content);p.forEach(C=>{C in n||(n[C]=void 0)});let b=":mounted"in u.attrs?`await $mounted();
5
- ${f}`:f;Oe(b,n,r.effect,{$emit:o,$mounted:m,$self:d,$$self:c})});let h=document.createDocumentFragment();return h.append(this.startMarker,k(this.template,n,r),this.endMarker),this.content=h,s?this.styleEls=this.styles.map(u=>{let p=document.createElement("style");return p.textContent=u.content,p}):(this.styles.forEach(u=>Te(u.content)),this.ownsSharedStyles=!0),this}mount(t){let s=typeof t=="string"?M(t):t;if(!s)throw new Error(`mount target not found: ${t}`);if(!this.content)throw new Error("render() must be called before mount()");this.mountRoot&&this.unmount();let n=this.useShadow&&s instanceof Element?s.shadowRoot??s.attachShadow({mode:"open"}):s;return this.useShadow&&this.styleEls.forEach(r=>n.appendChild(r)),n.appendChild(this.content),this.mountRoot=n,this.resolveMounted?.(),this}unmount(){if(!this.mountRoot||!this.content||!this.startMarker||!this.endMarker)return this;let t=this.startMarker;for(;t;){let s=t.nextSibling;if(this.content.appendChild(t),t===this.endMarker)break;t=s}return this.mountRoot=null,this}destroy(){return this.unmount(),this.fx?.dispose(),this.fx=null,this.styleEls.forEach(t=>t.parentNode?.removeChild(t)),this.styleEls=[],this.ownsSharedStyles&&(this.styles.forEach(t=>Ne(t.content)),this.ownsSharedStyles=!1),this.content=null,this.startMarker=null,this.endMarker=null,this.data=null,this.resolveMounted=null,this}},Ae=e=>new w(e);0&&(module.exports={$,$$,$create,$reactive,Component79,parseComponent,renderComponent});
1
+ var L=Object.defineProperty;var at=Object.getOwnPropertyDescriptor;var lt=Object.getOwnPropertyNames;var dt=Object.prototype.hasOwnProperty;var ft=(t,e,n)=>e in t?L(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var ut=(t,e)=>{for(var n in e)L(t,n,{get:e[n],enumerable:!0})},pt=(t,e,n,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of lt(e))!dt.call(t,r)&&r!==n&&L(t,r,{get:()=>e[r],enumerable:!(s=at(e,r))||s.enumerable});return t};var ht=t=>pt(L({},"__esModule",{value:!0}),t);var S=(t,e,n)=>ft(t,typeof e!="symbol"?e+"":e,n);var Ft={};ut(Ft,{$:()=>T,$$:()=>A,$create:()=>j,$reactive:()=>O,Component79:()=>C,parseComponent:()=>kt,renderComponent:()=>Tt});module.exports=ht(Ft);var T=(t,e)=>typeof t=="string"?document.querySelector(t):t.querySelector(e||""),A=(t,e)=>Array.from(typeof t=="string"?document.querySelectorAll(t):t.querySelectorAll(e||"")),j=(t,e={})=>{let n=document.createElement(t);for(let[s,r]of Object.entries(e))if(s==="className")n.className=Array.isArray(r)?r.join(" "):r;else if(s==="textContent")n.textContent=r;else if(s==="children")for(let o of r)n.appendChild(o);else n.setAttribute(s,r);return n};var mt=(t,e)=>e.split(".").reduce((n,s)=>n?.[s],t),P=t=>{if(Array.isArray(t))return!0;let e=Object.getPrototypeOf(t);return e===Object.prototype||e===null},K=(t,e,n)=>{Object.entries(t).forEach(([s,r])=>{let o=e?`${e}.${s}`:s;r&&typeof r=="object"&&P(r)?K(r,o,n):n(o,r)})},gt=(t,e)=>t===e||t.startsWith(`${e}.`)||e.startsWith(`${t}.`),v=[],V=t=>{v.push(new Set);try{return t()}finally{v.pop()}},O=t=>{let e=new Map,n=new Set,s=new Set,r=new WeakSet,o=(a,p,m=!1)=>{e.get(a)?.forEach(h=>h(p,a)),n.forEach(h=>h(a,p)),s.forEach(h=>{(m||Array.from(h.deps).some(g=>gt(g,a)))&&h.run()})},i=(a,p)=>{if(r.has(a))return a;Object.entries(a).forEach(([h,g])=>{g&&typeof g=="object"&&P(g)&&(a[h]=i(g,p?`${p}.${h}`:h))});let m=new Proxy(a,{get(h,g,u){return typeof g=="string"&&v[v.length-1]?.add(p?`${p}.${g}`:g),Reflect.get(h,g,u)},set(h,g,u,y){if(y!==m&&!Object.prototype.hasOwnProperty.call(h,g))return Reflect.set(h,g,u,y);let b=p?`${p}.${g}`:g;u&&typeof u=="object"&&P(u)&&(u=i(u,b));let R=!Object.prototype.hasOwnProperty.call(h,g);return h[g]=u,o(b,u,R),!0}});return r.add(m),m},c=i(t,""),l=(a,p,{immediate:m=!1}={})=>(e.has(a)||e.set(a,new Set),e.get(a).add(p),m&&p(mt(c,a),a),()=>e.get(a)?.delete(p)),d=(a,{immediate:p=!1}={})=>(n.add(a),p&&K(c,"",(m,h)=>a(m,h)),()=>n.delete(a)),f=a=>{let p={deps:new Set,run:()=>{let m=new Set;v.push(m);try{a()}finally{v.pop(),p.deps=m}}};return s.add(p),p.run(),()=>{s.delete(p)}};return Object.defineProperty(c,"$on",{value:l,enumerable:!1}),Object.defineProperty(c,"$onAny",{value:d,enumerable:!1}),Object.defineProperty(c,"$effect",{value:f,enumerable:!1}),c},N=t=>{let e=[];return{effect:n=>{e.push(t.$effect(n))},onDispose:n=>{e.push(n)},dispose:()=>{e.splice(0).forEach(n=>n())}}};var Z=/(?:let|var|const)\s+([A-Za-z_$][\w$]*)/y,G=/\$:\s*/y,D=/import(?=\s*\()/y,J=/\$:\s*([A-Za-z_$][\w$]*)\s*=(?!=)/y,k=(t,e)=>{let n=t[e],s=e+1;for(;s<t.length;){if(t[s]==="\\"){s+=2;continue}if(t[s]===n)return s+1;s++}return t.length},F=(t,e)=>{let n=t.indexOf(`
2
+ `,e);return n===-1?t.length:n},B=(t,e)=>{let n=t.indexOf("*/",e+2);return n===-1?t.length:n+2},yt=(t,e)=>{let n=0,s=e;for(;s<t.length;){let r=t[s];if(r==="'"||r==='"'||r==="`"){s=k(t,s);continue}if(r==="/"&&t[s+1]==="/"){s=F(t,s);continue}if(r==="/"&&t[s+1]==="*"){s=B(t,s);continue}if("([{".includes(r))n++;else if(")]}".includes(r))n--;else if(n<=0&&(r===`
3
+ `||r===";"))return s;s++}return t.length},Q=t=>{let e=[],n="",s=0,r=0,o=!0;for(;s<t.length;){let i=t[s],c=t[s+1];if(i==="'"||i==='"'||i==="`"){let l=k(t,s);n+=t.slice(s,l),s=l,o=!1;continue}if(i==="/"&&(c==="/"||c==="*")){let l=c==="/"?F(t,s):B(t,s);n+=t.slice(s,l),s=l;continue}if(i==="i"&&(s===0||!/[\w$.]/.test(t[s-1]))&&(D.lastIndex=s,D.test(t))){n+="$__import",s+=6,o=!1;continue}if(r===0&&o){Z.lastIndex=s;let l=Z.exec(t);if(l){e.push(l[1]),n+=l[1],s+=l[0].length,o=!1;continue}G.lastIndex=s;let d=G.exec(t);if(d){J.lastIndex=s;let f=J.exec(t);f&&e.push(f[1]);let a=s+d[0].length,p=yt(t,a);n+=`$__effect(() => { ${t.slice(a,p)} });`,s=p;continue}}"([{".includes(i)?r++:")]}".includes(i)&&(r=Math.max(0,r-1)),i===`
4
+ `||i===";"||i==="}"?o=!0:/\s/.test(i)||(o=!1),n+=i,s++}return{vars:e,code:n}},X=/export\s+default(?![\w$])/y,Y=/import\s*(?:([\w$\s,{}*]+?)\s*from\s*)?(["'])([^"'\n]+)\2/y,Et=t=>{let e=[],n=0,s=0;for(let r=0;r<=t.length;r++){let o=t[r];if(o==="{")n++;else if(o==="}")n--;else if(r===t.length||o===","&&n===0){let i=t.slice(s,r).trim();i&&e.push(i),s=r+1}}return e},bt=(t,e,n)=>{let s=`await $__import(${JSON.stringify(e)})`;if(t===void 0)return s;let r=Et(t),o=[],i=s;if(r.length>1){let c=`$__mod${n}`;o.push(`${c} = ${s}`),i=c}for(let c of r)c.startsWith("{")?o.push(`${c.replace(/\s+as\s+/g,": ")} = ${i}`):c.startsWith("*")?o.push(`${c.replace(/^\*\s*as\s+/,"")} = ${i}`):o.push(`${c} = $__default(${i})`);return`const ${o.join(", ")}`},tt=t=>{let e="",n=0,s=0,r=!0,o=!1,i=0;for(;n<t.length;){let c=t[n],l=t[n+1],d=n===0||!/[\w$.]/.test(t[n-1]);if(c==="'"||c==='"'||c==="`"){let f=k(t,n);e+=t.slice(n,f),n=f,r=!1;continue}if(c==="/"&&(l==="/"||l==="*")){let f=l==="/"?F(t,n):B(t,n);e+=t.slice(n,f),n=f;continue}if(c==="i"&&d){if(D.lastIndex=n,D.test(t)){e+="$__import",n+=6,r=!1;continue}if(s===0&&r){Y.lastIndex=n;let f=Y.exec(t);if(f){e+=bt(f[1],f[3],i++),n+=f[0].length,r=!1;continue}}}if(c==="e"&&d&&s===0&&r){X.lastIndex=n;let f=X.exec(t);if(f){o=!0,e+="$__exports.default =",n+=f[0].length,r=!1;continue}}"([{".includes(c)?s++:")]}".includes(c)&&(s=Math.max(0,s-1)),c===`
5
+ `||c===";"||c==="}"?r=!0:/\s/.test(c)||(r=!1),e+=c,n++}return o?e:null};var rt=t=>Object.fromEntries(Array.from(t.attributes).map(e=>[e.name,e.value])),ot=t=>({tag:t.tagName.toLowerCase(),attrs:rt(t),children:Array.from(t.childNodes).flatMap(e=>{if(e.nodeType===Node.TEXT_NODE){let n=e.textContent?.trim()??"";return n?[n]:[]}return e.nodeType===Node.ELEMENT_NODE?[ot(e)]:[]})}),w=(t,e,n)=>{try{return new Function("$scope",...Object.keys(n??{}),`with ($scope) { return (${t}); }`)(e,...Object.values(n??{}))}catch{return}},St=(t,e)=>t.replace(/{{\s*(.+?)\s*}}/g,(n,s)=>w(s,e)??""),it=new Set([":bind",":if",":elseif",":else",":each",":key",":with"]),$t=/^\s*(\w+)\s+in\s+(.+)$/,wt=(t,e,n,s)=>{let[r,...o]=e.slice(1).split("."),i=new Set(o);t.addEventListener(r,c=>{if(i.has("self")&&c.target!==t)return;i.has("prevent")&&c.preventDefault(),i.has("stop")&&c.stopPropagation();let l=w(n,s,{$event:c});typeof l=="function"&&l.call(t,c)},{once:i.has("once"),capture:i.has("capture")})},et=t=>t.replace(/-(\w)/g,(e,n)=>n.toUpperCase()),nt=(t,e)=>{let n=e.replace(/-/g,"").toLowerCase();for(let s=t;s&&s!==Object.prototype;s=Object.getPrototypeOf(s))for(let r of Object.keys(s))if(/^[A-Z]/.test(r)&&r.replace(/-/g,"").toLowerCase()===n)return r;return null},st=(t,e,n,s)=>{let r=document.createComment(t),o=document.createDocumentFragment();o.appendChild(r);let i={};Object.entries(e.attrs).forEach(([f,a])=>{if(!(it.has(f)||f.startsWith("@")))if(f.startsWith(":")){let p=et(f.slice(1));i[p]=a||p}else i[et(f)]=JSON.stringify(a)});let c=null,l=null,d=null;return s.effect(()=>{let f=w(t,n),a=f instanceof C?f:null;if(a===l||(d?.dispose(),d=null,c?.destroy(),c=null,l=a,!a))return;let p=new C({template:a.template,scripts:a.scripts,styles:a.styles,modules:a.modules}),m=V(()=>Object.fromEntries(Object.entries(i).map(([u,y])=>[u,w(y,n)]))),h=document.createDocumentFragment();p.render(m).mount(h),r.parentNode.insertBefore(h,r.nextSibling);let g=N(n);Object.entries(i).forEach(([u,y])=>{g.effect(()=>{p.data[u]=w(y,n)})}),d=g,c=p}),s.onDispose(()=>{d?.dispose(),c?.destroy()}),o},Rt=(t,e)=>{let n=()=>{let s=w(t,e);return s!==null&&typeof s=="object"?s:null};return new Proxy(e,{has(s,r){let o=n();return o!==null&&Reflect.has(o,r)||Reflect.has(s,r)},get(s,r){let o=n();return o!==null&&Reflect.has(o,r)?o[r]:Reflect.get(s,r)},set(s,r,o){let i=n();return i!==null&&Reflect.has(i,r)?(i[r]=o,!0):Reflect.set(s,r,o)}})},W=(t,e,n)=>{let s=t.attrs[":with"],r=s!==void 0?Rt(s,e):e,o=nt(r,t.tag);if(o)return st(o,t,r,n);let i=document.createElement(t.tag);if(i instanceof HTMLUnknownElement||t.tag.includes("-")){let l=!1;n.effect(()=>{if(l)return;let d=nt(r,t.tag);d&&(l=!0,i.replaceWith(st(d,t,r,n)))})}Object.entries(t.attrs).forEach(([l,d])=>{l.startsWith("@")?wt(i,l,d,r):it.has(l)||i.setAttribute(l,d)});let c=t.attrs[":bind"];if(c!==void 0){let l=[];n.effect(()=>{l.forEach(f=>i.removeAttribute(f));let d=w(c,r);l=d&&typeof d=="object"?Object.keys(d):[],l.forEach(f=>{let a=d[f];a!=null&&a!==!1&&i.setAttribute(f,String(a))})})}return i.appendChild(U(t.children,r,n)),i},xt=(t,e,n)=>{let s=document.createComment("if"),r=document.createDocumentFragment();r.appendChild(s);let o=null,i=null,c=null;return n.effect(()=>{let l=t.find(d=>d.expr===void 0||w(d.expr,e))??null;l!==i&&(c?.dispose(),o&&o.parentNode?.removeChild(o),o=null,i=l,l&&(c=N(e),o=W(l.node,e,c),s.parentNode.insertBefore(o,s.nextSibling)))}),r},I=(t,e,n)=>{Object.defineProperty(t,e,{value:n,writable:!0,enumerable:!0,configurable:!0})},Ct=(t,e,n)=>{let s=t.attrs[":each"].match($t);if(!s)return document.createComment(`invalid :each expression "${t.attrs[":each"]}"`);let[,r,o]=s,i=t.attrs[":key"],{[":each"]:c,[":key"]:l,...d}=t.attrs,f={...t,attrs:d},a=document.createComment("each"),p=document.createDocumentFragment();p.appendChild(a);let m=[];return n.effect(()=>{let h=w(o,e),g=Array.isArray(h)?h:[],u=new Map(m.map(E=>[E.key,E])),y=g.map((E,_)=>{let $=Object.create(e);I($,r,E),I($,"$index",_);let H=i!==void 0?w(i,$):_,x=u.get(H);if(x&&Object.is(x.item,E))return I(x.scope,"$index",_),x;x?.fx.dispose(),x?.node.parentNode?.removeChild(x.node);let z=N(e);return{key:H,item:E,scope:$,fx:z,node:W(f,$,z)}}),b=new Set(y.map(E=>E.key));m.forEach(E=>{b.has(E.key)||(E.fx.dispose(),E.node.parentNode?.removeChild(E.node))});let R=a;y.forEach(E=>{R.nextSibling!==E.node&&a.parentNode.insertBefore(E.node,R.nextSibling),R=E.node}),m=y}),p},U=(t,e,n)=>{let s=document.createDocumentFragment(),r=0;for(;r<t.length;){let o=t[r];if(typeof o=="string"){let i=document.createTextNode("");n.effect(()=>{i.textContent=St(o,e)}),s.appendChild(i),r++;continue}if(":each"in o.attrs){s.appendChild(Ct(o,e,n)),r++;continue}if(":if"in o.attrs){let i=[{expr:o.attrs[":if"],node:o}];for(r++;r<t.length&&typeof t[r]!="string"&&":elseif"in t[r].attrs;){let c=t[r];i.push({expr:c.attrs[":elseif"],node:c}),r++}r<t.length&&typeof t[r]!="string"&&":else"in t[r].attrs&&(i.push({node:t[r]}),r++),s.appendChild(xt(i,e,n));continue}s.appendChild(W(o,e,n)),r++}return s},Tt=(t,e)=>U(t.template,e,N(e)),vt=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),Nt=/<([A-Za-z][\w-]*)((?:"[^"]*"|'[^']*'|[^>"'])*?)\/>/g,_t=/(<script[\s\S]*?<\/script\s*>|<style[\s\S]*?<\/style\s*>)/gi,Ot=t=>t.split(_t).map((e,n)=>n%2===1?e:e.replace(Nt,(s,r,o)=>vt.has(r.toLowerCase())?s:`<${r}${o}></${r}>`)).join(""),Lt=t=>{let n=new DOMParser().parseFromString(`<template>${Ot(t)}</template>`,"text/html").querySelector("template"),s=[],r=[],o=[];return Array.from(n.content.children).forEach(i=>{let c={attrs:rt(i),content:i.textContent??""};i.tagName==="SCRIPT"?s.push(c):i.tagName==="STYLE"?r.push(c):o.push(ot(i))}),{template:o,scripts:s,styles:r}},q=t=>/\.html?([?#]|$)/.test(t)?C.fetch(t):import(t),M=new Map,At=t=>{let e=M.get(t);if(!e){let n=document.createElement("style");n.textContent=t,document.head.appendChild(n),e={el:n,count:0},M.set(t,e)}e.count++},jt=t=>{let e=M.get(t);e&&--e.count<=0&&(e.el.remove(),M.delete(t))},ct={$:T,$$:A,$create:j,$reactive:O},Dt=(t,e,n,s={},r=q)=>{let o={...ct,...s},i=new Proxy(e,{has:(l,d)=>d!=="$__effect"&&d!=="$__import"&&(Reflect.has(l,d)||!(d in globalThis)&&!(d in o))});new Function("$scope","$__effect","$__import",...Object.keys(o),`return (async () => { with ($scope) { ${t} } })()`)(i,n,r,...Object.values(o)).catch(l=>console.error("jq79: error in :setup script",l))},Mt=t=>t&&t.default!==void 0?t.default:t,Pt=(t,e,n,s={},r=q)=>{let o={...ct,...s},i={},c=new Function("$__exports","$__default","$__import",...Object.keys(o),`return (async () => { "use strict";
6
+ ${t}
7
+ ;$__exports.done = true })()`)(i,Mt,r,...Object.values(o)),l=a=>console.error("jq79: error in factory script",a),d=!1,f=()=>{if(d)return;d=!0;let a=i.default;if(typeof a!="function")return;let p=h=>{h&&typeof h=="object"&&Object.assign(e,h)},m=a({$data:e,$effect:n,...s});m instanceof Promise?m.then(p).catch(l):p(m)};c.then(f,l),i.done&&f()},C=class t{constructor(e,n={}){S(this,"template");S(this,"scripts");S(this,"styles");S(this,"modules");S(this,"data",null);S(this,"fx",null);S(this,"content",null);S(this,"startMarker",null);S(this,"endMarker",null);S(this,"styleEls",[]);S(this,"ownsSharedStyles",!1);S(this,"useShadow",!1);S(this,"mountRoot",null);S(this,"resolveMounted",null);S(this,"emitListeners",new Map);let s=typeof e=="string"?Lt(e):e;this.template=s.template,this.scripts=s.scripts,this.styles=s.styles,this.modules=n.modules??(typeof e=="string"?void 0:e.modules)}static async fetch(e){let n=await fetch(e);if(!n.ok)throw new Error(`failed to fetch component from ${e}: ${n.status}`);return new t(await n.text())}on(e,n){return this.emitListeners.has(e)||this.emitListeners.set(e,new Set),this.emitListeners.get(e).add(n),this}off(e,n){return this.emitListeners.get(e)?.delete(n),this}render(e={}){return this.renderWith(e,!1)}renderShadow(e={}){return this.renderWith(e,!0)}renderWith(e,n){this.destroy();let s=O({...e}),r=N(s);this.data=s,this.fx=r,this.useShadow=n,this.startMarker=document.createComment("jq79"),this.endMarker=document.createComment("/jq79");let o=this.startMarker,i=(u,y)=>{let b=new CustomEvent(u,{detail:y,bubbles:!0,composed:!0}),R=o.dispatchEvent(b);return o===this.startMarker&&this.emitListeners.get(u)?.forEach(E=>E(b,y)),R},c,l=new Promise(u=>{c=u});this.resolveMounted=c;let d=()=>l,f=this.endMarker,a=u=>{let y=[];for(let b=o.nextSibling;b&&b!==f;b=b.nextSibling)b instanceof Element&&(b.matches(u)&&y.push(b),y.push(...Array.from(b.querySelectorAll(u))));return y},p=u=>a(u)[0]??null,m=this.modules,h=u=>m&&u in m?Promise.resolve(m[u]):q(u);this.scripts.forEach(u=>{let y={$emit:i,$mounted:d,$self:p,$$self:a},b=tt(u.content);if(b!==null){let $=":mounted"in u.attrs?`await $mounted();
8
+ ${b}`:b;Pt($,s,r.effect,y,h);return}let{vars:R,code:E}=Q(u.content);R.forEach($=>{$ in s||(s[$]=void 0)});let _=":mounted"in u.attrs?`await $mounted();
9
+ ${E}`:E;Dt(_,s,r.effect,y,h)});let g=document.createDocumentFragment();return g.append(this.startMarker,U(this.template,s,r),this.endMarker),this.content=g,n?this.styleEls=this.styles.map(u=>{let y=document.createElement("style");return y.textContent=u.content,y}):(this.styles.forEach(u=>At(u.content)),this.ownsSharedStyles=!0),this}mount(e,n){let s=typeof e=="string"?T(e):e;if(!s)throw new Error(`mount target not found: ${e}`);return(!this.content||n!==void 0)&&this.renderWith(n??{},this.useShadow),this.attach(s)}mountShadow(e,n){let s=typeof e=="string"?T(e):e;if(!s)throw new Error(`mount target not found: ${e}`);return(!this.content||n!==void 0||!this.useShadow)&&this.renderWith(n??{},!0),this.attach(s)}attach(e){this.mountRoot&&this.detach();let n=this.useShadow&&e instanceof Element?e.shadowRoot??e.attachShadow({mode:"open"}):e;return this.useShadow&&this.styleEls.forEach(s=>n.appendChild(s)),n.appendChild(this.content),this.mountRoot=n,this.resolveMounted?.(),this}detach(){if(!this.mountRoot||!this.content||!this.startMarker||!this.endMarker)return this;let e=this.startMarker;for(;e;){let n=e.nextSibling;if(this.content.appendChild(e),e===this.endMarker)break;e=n}return this.mountRoot=null,this}destroy(){return this.detach(),this.fx?.dispose(),this.fx=null,this.styleEls.forEach(e=>e.parentNode?.removeChild(e)),this.styleEls=[],this.ownsSharedStyles&&(this.styles.forEach(e=>jt(e.content)),this.ownsSharedStyles=!1),this.content=null,this.startMarker=null,this.endMarker=null,this.data=null,this.resolveMounted=null,this}},kt=t=>new C(t);0&&(module.exports={$,$$,$create,$reactive,Component79,parseComponent,renderComponent});
6
10
  //# sourceMappingURL=jq79.cjs.map