jq79 0.7.7 → 0.7.8

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/dev/vite.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { readFile } from "node:fs/promises"
2
- import { basename, relative } from "node:path"
2
+ import { posix, relative } from "node:path"
3
3
  import { preprocessCSS, transformWithEsbuild } from "vite"
4
4
  import type { Plugin, ResolvedConfig } from "vite"
5
5
  // by package name rather than ../src: this file's types are emitted with dev/
@@ -35,8 +35,8 @@ export interface Jq79PluginOptions {
35
35
  // run the app without eval, for a CSP with no 'unsafe-eval' - the value
36
36
  // Component79.safeEval() takes, and meaning the same thing
37
37
  // (RECORD/2026-09-23.no-unsafe-eval.md). Every component is precompiled, and
38
- // its functions ship as a script of their own. `true`: those and nothing
39
- // else - whatever the build couldn't see is reported, never evaluated.
38
+ // their functions ship as one script beside the bundle. `true`: those and
39
+ // nothing else - whatever the build couldn't see is reported, never evaluated.
40
40
  // `{ nonce: true }`: whatever it couldn't see (a component built from a
41
41
  // string, an edit during HMR) is built as a <script> carrying the page's nonce
42
42
  safeEval?: boolean | { nonce?: boolean }
@@ -46,20 +46,23 @@ export interface Jq79PluginOptions {
46
46
  // Vite's own html handling (entries, asset pipeline) leaves them alone
47
47
  const COMPONENT_QUERY = "?jq79"
48
48
 
49
- // safeEval. A component's precompiled functions travel as a classic script of
50
- // their own - Card.html.jq79.js - and not inside its module: they compile
51
- // under `with`, which is a SyntaxError in strict code, and every module is
52
- // strict. In a build the script is an asset beside the chunk; in dev the
53
- // server hands it out (PRECOMPILED_PATH). Either way it pushes its functions
54
- // onto the queue the runtime drains (see "safe eval" in src/jq79.ts).
49
+ // safeEval. Precompiled functions travel as a classic script, and not inside
50
+ // a module: they compile under `with`, which is a SyntaxError in strict code,
51
+ // and every module is strict. In a build it is one script for every component
52
+ // - jq79-precompiled-[hash].js, an asset beside the chunks - and the pages that
53
+ // need it preload it (RECORD/2026-11-04.one-precompiled-script.md); in dev each
54
+ // component has its own, which the server hands out (PRECOMPILED_PATH). Either
55
+ // way it pushes its functions onto the queue the runtime drains (see "safe
56
+ // eval" in src/jq79.ts).
55
57
  //
56
58
  // The component's module waits for it - a top-level await - before it builds
57
59
  // anything, through a module every component module imports. That module
58
60
  // evaluates once, so safe mode is turned on once per app, and a page with no
59
61
  // nonce is reported once rather than once per component; and it loads each
60
- // script once, however many modules ask. The <script> carries the page's
61
- // nonce when there is one, so a CSP that works by nonce admits it; under
62
- // `script-src 'self'` the URL is what admits it.
62
+ // script once, however many modules ask - in a build they all ask for the
63
+ // same one, so the first await downloads it and the rest resolve at once. The
64
+ // <script> carries the page's nonce when there is one, so a CSP that works by
65
+ // nonce admits it; under `script-src 'self'` the URL is what admits it.
63
66
  //
64
67
  // Component79 is passed in rather than imported, so the module resolves
65
68
  // nothing: a bare "jq79" from a virtual importer is the one resolution that
@@ -105,6 +108,16 @@ export const safeEval = (Component79, url) => {
105
108
  // where the dev server hands out a component's precompiled script
106
109
  const PRECOMPILED_PATH = "/@jq79/precompiled.js"
107
110
 
111
+ // a build's one precompiled script, named as an asset: assets/jq79-precompiled-[hash].js
112
+ const PRECOMPILED_ASSET = "jq79-precompiled.js"
113
+ // what a component's module passes for that script's URL in a build. The asset
114
+ // is emitted in buildEnd, once every component is known - Rolldown has no
115
+ // setAssetSource to fill it in later, and a module is loaded before the build
116
+ // knows the rest - so a module can't name it by reference when it's loaded;
117
+ // renderChunk writes the URL over this
118
+ const PRECOMPILED_URL_PLACEHOLDER = "__JQ79_PRECOMPILED_URL__"
119
+ const PRECOMPILED_URL_PLACEHOLDER_RE = /(["'`])__JQ79_PRECOMPILED_URL__\1/g
120
+
108
121
  // the plugin's safeEval option, as what the modules pass the runtime: null
109
122
  // for off, or Component79.safeEval's own options
110
123
  const safeEvalOptions = (option: Jq79PluginOptions["safeEval"]): { nonce?: boolean } | null => {
@@ -116,21 +129,86 @@ const safeEvalOptions = (option: Jq79PluginOptions["safeEval"]): { nonce?: boole
116
129
  // doesn't compile, so only the `with` form's failure is worth a word
117
130
  const SCOPED_BODY_RE = /^(?:let \$t;| return \()/
118
131
 
119
- // a component's precompiled functions, as the classic script that registers
120
- // them (precompiledScript, in jq79/precompile). Each is compiled here first -
121
- // node can, where the page may not - so the script holds only functions that
122
- // parse; one that doesn't ships as null, and the build says so
123
- const componentScript = (source: string, warn: (message: string) => void): string =>
124
- precompiledScript(precompile(source), (params, body) => {
132
+ // one precompiled function, and whether it parses
133
+ type CheckedFunction = [params: string[], body: string, parses: boolean]
134
+
135
+ // a component's precompiled functions, each compiled here first - node can,
136
+ // where the page may not - so a script holds only functions that parse; one
137
+ // that doesn't ships as null, and the build says so, once, with its file
138
+ const componentFunctions = (source: string, warn: (message: string) => void): CheckedFunction[] =>
139
+ precompile(source).map(([params, body]) => {
125
140
  try {
126
141
  new Function(...params, body)
127
- return true
142
+ return [params, body, true]
128
143
  } catch (error) {
129
144
  if (!SCOPED_BODY_RE.test(body)) warn(`${(error as Error).message}, in: ${body.length > 120 ? `${body.slice(0, 120)}…` : body}`)
130
- return false
145
+ return [params, body, false]
131
146
  }
132
147
  })
133
148
 
149
+ // the classic script that registers functions (precompiledScript, in
150
+ // jq79/precompile): one component's in dev, every component's in a build. One
151
+ // push, each function once - the runtime keys them by (params, body), so
152
+ // `{{ name }}` written in ten components is one function, and a second entry
153
+ // would only replace the first with itself
154
+ const registeringScript = (functions: CheckedFunction[]): string => {
155
+ const unique = new Map<string, CheckedFunction>()
156
+ for (const fn of functions) {
157
+ const key = JSON.stringify([fn[0], fn[1]])
158
+ if (!unique.has(key)) unique.set(key, fn)
159
+ }
160
+ return precompiledScript(
161
+ [...unique.values()].map(([params, body]) => [params, body]),
162
+ (params, body) => unique.get(JSON.stringify([params, body]))?.[2] ?? false
163
+ )
164
+ }
165
+
166
+ type BundleFile = { type: string; fileName: string; moduleIds?: string[]; imports?: string[] }
167
+
168
+ // whether a page's entry chunk waits for the precompiled script as it loads:
169
+ // it, or a chunk it imports statically, holds a component module. A component
170
+ // behind import() asks for the script when it is imported, and a preload the
171
+ // page doesn't use straight away only earns a warning in the console
172
+ const reachesComponent = (entry: BundleFile, bundle: Record<string, BundleFile>): boolean => {
173
+ const seen = new Set<string>()
174
+ const visit = (chunk: BundleFile | undefined): boolean => {
175
+ if (!chunk || chunk.type !== "chunk" || seen.has(chunk.fileName)) return false
176
+ seen.add(chunk.fileName)
177
+ return (chunk.moduleIds ?? []).some(id => id.endsWith(COMPONENT_QUERY)) || (chunk.imports ?? []).some(file => visit(bundle[file]))
178
+ }
179
+ return visit(entry)
180
+ }
181
+
182
+ // a <script src>, quote-aware, and not a data-src
183
+ const SCRIPT_SRC_RE = /<script\b(?:"[^"]*"|'[^']*'|[^>"'])*?\ssrc\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+))/gi
184
+
185
+ // `file` as the page has to write it to get the URL a module asks for: the
186
+ // file relative to the module's chunk, against that chunk's own URL - which
187
+ // is what new URL(..., import.meta.url) resolves. The chunk's URL is read off
188
+ // the page, from the <script src> Vite wrote for it, so `base`, a relative
189
+ // base and renderBuiltUrl are already in it. Any of the bundle's chunks will
190
+ // do, because chunks import each other by relative path - and it has to be
191
+ // any: an entry that is nothing but imports gets no <script> of its own, only
192
+ // its imports do. null when no script on the page loads one of them: no
193
+ // preload is better than one at the wrong URL, which downloads twice
194
+ const precompiledHref = (html: string, bundle: Record<string, BundleFile>, file: string): string | null => {
195
+ const chunks = Object.values(bundle).filter(out => out.type === "chunk").map(out => out.fileName)
196
+ for (const match of html.matchAll(SCRIPT_SRC_RE)) {
197
+ const src = (match[1] ?? match[2] ?? match[3]).replace(/[?#].*$/, "")
198
+ const chunk = chunks.find(name => src === name || src.endsWith(`/${name}`))
199
+ if (chunk === undefined) continue
200
+ const path = posix.relative(posix.dirname(chunk), file)
201
+ // a full URL, or a protocol-relative one
202
+ if (/^(?:[a-z][a-z\d+.-]*:)?\/\//i.test(src)) {
203
+ const scheme = src.startsWith("//") ? "https:" : ""
204
+ return new URL(path, scheme + src).href.slice(scheme.length)
205
+ }
206
+ const href = posix.join(posix.dirname(src), path)
207
+ return src.startsWith("/") || href.startsWith(".") ? href : `./${href}`
208
+ }
209
+ return null
210
+ }
211
+
134
212
  // a <script> block with its attribute string, so `lang` can be read and the
135
213
  // body replaced - the same shape as STYLE_BLOCK_RE below, quote-aware so a
136
214
  // ">" inside an attribute value (`:setup="{ n = a > 1 }"`) doesn't end the tag
@@ -507,6 +585,11 @@ export function jq79(options: Jq79PluginOptions = {}): Plugin {
507
585
  // for - so the server hands out what the plugin compiled and nothing else
508
586
  const devScripts = new Map<string, string>()
509
587
  const devIds = new Map<string, number>()
588
+ // build only: each component's functions, by file, for the one script
589
+ // buildEnd emits - its reference, and the file name renderChunk resolves it to
590
+ const buildFunctions = new Map<string, CheckedFunction[]>()
591
+ let precompiledRef: string | undefined
592
+ let precompiledFile: string | undefined
510
593
 
511
594
  let config: ResolvedConfig | null = null
512
595
 
@@ -561,20 +644,69 @@ export function jq79(options: Jq79PluginOptions = {}): Plugin {
561
644
 
562
645
  // the component's functions, compiled after its TypeScript and styles are:
563
646
  // the runtime compiles what reaches it, and this is what reaches it
564
- const script = componentScript(source, message => this.warn(`jq79: ${filename}: ${message}`))
647
+ const functions = componentFunctions(source, message => this.warn(`jq79: ${filename}: ${message}`))
565
648
  let url: string
566
649
  if (config?.command === "serve") {
567
650
  let devId = devIds.get(file)
568
651
  if (devId === undefined) devIds.set(file, devId = devIds.size)
569
- devScripts.set(String(devId), script)
652
+ devScripts.set(String(devId), registeringScript(functions))
570
653
  // versioned, so an edit loads the new functions rather than a cached copy
571
654
  url = JSON.stringify(`${config.base}${PRECOMPILED_PATH.slice(1)}?id=${devId}&v=${Date.now()}`)
572
655
  } else {
573
- const ref = this.emitFile({ type: "asset", name: `${basename(file)}.jq79.js`, source: script })
574
- url = `import.meta.ROLLUP_FILE_URL_${ref}`
656
+ buildFunctions.set(file, functions)
657
+ url = JSON.stringify(PRECOMPILED_URL_PLACEHOLDER)
575
658
  }
576
659
  return { code: componentModule(source, include, filename, url), map: null }
577
660
  },
661
+
662
+ buildStart() {
663
+ precompiledRef = undefined
664
+ precompiledFile = undefined
665
+ },
666
+
667
+ // the build's one precompiled script, from every component still in the
668
+ // module graph. What earlier builds recorded is kept and pruned rather than
669
+ // cleared in buildStart, so a watch rebuild that doesn't load a module again
670
+ // keeps its functions. Sorted by file, so the same sources make the same
671
+ // bytes, and the same hash
672
+ buildEnd(error) {
673
+ if (!safeEval || error || config?.command === "serve") return
674
+ const inGraph = new Set<string>()
675
+ for (const id of this.getModuleIds()) if (id.endsWith(COMPONENT_QUERY)) inGraph.add(id.slice(0, -COMPONENT_QUERY.length))
676
+ for (const file of buildFunctions.keys()) if (!inGraph.has(file)) buildFunctions.delete(file)
677
+ if (buildFunctions.size === 0) return
678
+ const functions = [...buildFunctions.keys()].sort().flatMap(file => buildFunctions.get(file)!)
679
+ precompiledRef = this.emitFile({ type: "asset", name: PRECOMPILED_ASSET, source: registeringScript(functions) })
680
+ },
681
+
682
+ // the placeholder, as what import.meta.ROLLUP_FILE_URL_<ref> renders to:
683
+ // the asset's path relative to the chunk, against the chunk's own URL - so
684
+ // `base` doesn't matter. Before minification, and part of the chunk's hash.
685
+ // The source map is left as it is: the placeholder sits on a line of its
686
+ // own with only `)` after it
687
+ renderChunk(code, chunk) {
688
+ if (precompiledRef === undefined || !code.includes(PRECOMPILED_URL_PLACEHOLDER)) return null
689
+ precompiledFile = this.getFileName(precompiledRef)
690
+ const path = JSON.stringify(posix.relative(posix.dirname(chunk.fileName), precompiledFile))
691
+ return { code: code.replace(PRECOMPILED_URL_PLACEHOLDER_RE, () => `new URL(${path}, import.meta.url).href`), map: null }
692
+ },
693
+
694
+ // a page that waits for the script asks for it as it parses, rather than
695
+ // once its entry has loaded and run. Same URL as the module's
696
+ // (precompiledHref), and no crossorigin, as the <script> has none: a
697
+ // preload is only reused by a request that matches it. Vite's html.cspNonce
698
+ // stamps it with the nonce, after this hook - without it,
699
+ // `script-src 'nonce-…'` refuses a preload. Build only: dev has one script
700
+ // per component, versioned per edit. Vite writes the page's <script> tags
701
+ // before it runs this hook, in every version the plugin supports
702
+ transformIndexHtml(html, ctx) {
703
+ if (!safeEval || !precompiledFile || !ctx.bundle || !ctx.chunk) return
704
+ const bundle = ctx.bundle as Record<string, BundleFile>
705
+ if (!reachesComponent(ctx.chunk as BundleFile, bundle)) return
706
+ const href = precompiledHref(html, bundle, precompiledFile)
707
+ if (href === null) return
708
+ return [{ tag: "link", attrs: { rel: "preload", as: "script", href }, injectTo: "head" }]
709
+ },
578
710
  }
579
711
  }
580
712
 
package/dist/jq79.cjs CHANGED
@@ -14,7 +14,7 @@ ${e}
14
14
  ;$__exports.done = true })()`,Cn=e=>{let t=e.attrs[":setup"];return t===void 0?null:t.trim()===""?[]:ke(t)},Mn=(e,t)=>{let n=new Set;return e.forEach(s=>{(Ae(s.content)??t(s))?.forEach(({name:i})=>n.add(i))}),n};var kn="__jq79precompiled",An="jq79-precompiled",On=(e,t)=>`function anonymous(${e.join(",")}
15
15
  ) {
16
16
  ${t}
17
- }`;var $i={};var qr="0.7.7",ns=e=>Object.fromEntries(Array.from(e.attributes).map(t=>[t.name,t.value])),ss="http://www.w3.org/1999/xhtml",rs=e=>{let t=ns(e),n=e.namespaceURI,s=t[Oe];delete t[Oe];let r=n!==null&&n!==ss;return{tag:r?e.tagName:e.tagName.toLowerCase(),attrs:t,...s===void 0?{}:{component:s},...r?{ns:n}:{},children:Array.from((e instanceof HTMLTemplateElement?e.content:e).childNodes).flatMap(i=>{if(i.nodeType===Node.TEXT_NODE){let o=i.textContent??"";return o?[o]:[]}return i.nodeType===Node.ELEMENT_NODE?[rs(i)]:[]})}},Je=new Map,Ye=new Map,Ut=!1,jt,Pe=class extends Error{constructor(n,s){super(`${n}. ${s}`);k(this,"reason",n);k(this,"hint",s)}},Hr=()=>new Pe("was not precompiled","Safe mode never builds code at runtime: the component's precompiled functions did not reach the page."),Wr=(e,t)=>{let n=globalThis[kn];if(Array.isArray(n)&&n.length>0)for(let[s,r,i]of n.splice(0))Ye.set(Qe(s,r),i);return Ye.size===0?void 0:Ye.get(Qe(e,t))},Bt=(e,t,n="")=>{let s=Wr(e,t);if(s===null)throw new SyntaxError("jq79: this code did not compile when it was precompiled");if(s!==void 0)return s;if(jt!==void 0)return Fr(e,t,n,jt);if(Ut)throw Hr();return new Function(...e,t+n)},os=()=>{if(!(typeof document>"u"))for(let e of Array.from(document.querySelectorAll("script[nonce]"))){let t=e.nonce||e.getAttribute("nonce");if(t)return t}},_n="__jq79built",Fr=(e,t,n,s)=>{let r=document.createElement("script");r.setAttribute("nonce",s),r.textContent=`document.currentScript.${_n} = ${On(e,t)}${n}`;let i,o=l=>{i=l.error??new SyntaxError(l.message),l.preventDefault()};window.addEventListener("error",o);try{(document.head??document.documentElement).append(r)}finally{window.removeEventListener("error",o),r.remove()}let a=r[_n];if(typeof a=="function")return Ye.set(Qe(e,t),a),a;throw i!==void 0?i:new Pe("could not be built","The page's CSP refused a <script> carrying the nonce jq79 read from the page.")},jn=new Set,Ur=(e,t)=>{jn.has(e)||(jn.add(e),console.error(`jq79: safeEval() is on, and "${e}" ${t.reason}, so it rendered as nothing. ${t.hint}`))},Pt=(e,t)=>{if(!(t in e)){if(t in globalThis)return globalThis[t];throw new ReferenceError(`${t} is not defined`)}},is=(e,t)=>{try{return Bt([...Nt,...t],$n(e))}catch(n){return n instanceof Pe&&Ur(e,n),null}},Br=(e,t)=>{if(!le.scopedNames)return null;let n=Rn(e,t);if(n===null)return null;try{return Bt([...Nt,...t],n)}catch{return null}},as=(e,t,n)=>{let s=Je.get(e);if(s===void 0){let r=Br(t,n);s=r?{fn:r,scoped:!0}:{fn:is(t,n),scoped:!1},Je.set(e,s)}return s},ls=(e,t)=>`${t.join(",")}|${e}`,Kr=(e,t)=>as(ls(e,t),e,t).fn,zr=(e,t,n)=>{let s=is(t,n);return Je.set(e,{fn:s,scoped:!1}),s},Gr=/^(?:([\w$]+) is not defined|Can't find variable: ([\w$]+))/,Vr=100,we=new Map,Kt=new Set,et=0,Lt=!1,Dt=new Set,Zr=()=>{Lt=!1,!(et>0)&&(we.forEach(({name:e,expr:t,scope:n},s)=>{e in n||(Kt.add(s),console.warn(`jq79: ${e} is not defined - evaluating "${t}". Template expressions resolve against the component store: a top-level let/var/const in a :setup script, a declared prop, or a global. Note a "function name() {}" declaration is not on the store - write "const name = () => {}".`))}),we.clear())},cs=()=>{Lt||et>0||!we.size||(Lt=!0,queueMicrotask(Zr))},ds=e=>{et++;let t=()=>{et--,cs()};e.then(t,t)},Qr=(e,t)=>{if(Dt.has(e))return;Dt.add(e);let n=t?.message||String(t);console.error(`jq79: ${n} - evaluating "${e}". The expression rendered as nothing. If the value arrives later, guard it - "a?.b", or :if on the element.`)},us=(e,t,n)=>{if(!(n instanceof ReferenceError))return Qr(e,n);let s=Gr.exec(n.message),r=s?.[1]??s?.[2];if(!r)return;let i=`${r}|${e}`;Kt.has(i)||we.has(i)||we.size>=Vr||(we.set(i,{name:r,expr:e,scope:t}),cs())},fs=(e,t,n)=>{let s=n?Object.keys(n):[],r=ls(e,s),{fn:i,scoped:o}=as(r,e,s);if(!i)return;let a=n?Object.values(n):[];if(!o)return i(t,Pt,...a);try{return i(t,Pt,...a)}catch(l){if(!(l instanceof ReferenceError))throw l;let f=zr(r,e,s);if(!f)throw l;return f(t,Pt,...a)}},_=(e,t,n)=>{try{return fs(e,t,n)}catch(s){us(e,t,s);return}},ps=(e,t,n)=>{try{return fs(e,t,n)}catch(s){if(!(s instanceof ReferenceError))throw s;us(e,t,s);return}},hs=(e,t)=>{if(e.length===1){let s=e[0];return typeof s=="string"?s:String(_(s.expr,t)??"")}let n="";for(let s of e)n+=typeof s=="string"?s:String(_(s.expr,t)??"");return n},gs=(e,t,n,s)=>{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=ps(n,s,{$event:a});typeof l=="function"&&l.call(e,a)},{once:o.has("once"),capture:o.has("capture")})},Xr=(e,t,n,s)=>{let[r,...i]=t.slice(1).split("."),o=new Set(i),a=l=>{o.has("prevent")&&l.preventDefault(),o.has("stop")&&l.stopPropagation(),o.has("once")&&e.off(r,a),Re(()=>{let f=ps(n,s,{$event:l});typeof f=="function"&&f(l)})};e.on(r,a)},zt=e=>e instanceof DocumentFragment?{first:e.firstChild,last:e.lastChild}:{first:e,last:e},it=({first:e,last:t})=>{for(let n=e;n;){let s=n===t?null:n.nextSibling;n.parentNode?.removeChild(n),n=s}},Yr=e=>{e.forEach(t=>{if(t.first===t.last)return it(t);if(!t.first.parentNode)return;let s=document.createRange();s.setStartBefore(t.first),s.setEndAfter(t.last),s.deleteContents()})},Jr=(e,t)=>{let n=[],s=null;return e.forEach(r=>{if(!t(r)){s=null;return}s&&s.last.nextSibling===r.range.first?s.last=r.range.last:n.push(s={first:r.range.first,last:r.range.last})}),n},eo=({first:e,last:t},n)=>{let s=n.nextSibling;for(let r=e;r;){let i=r===t?null:r.nextSibling;n.parentNode.insertBefore(r,s),r=i}},Ln=(e,t)=>{let n=t.replace(/-/g,"").toLowerCase();for(let s=e;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},Ee=null,tt=null,ms=new WeakSet,to=e=>{let t={memo:Ee,base:tt};return Ee=new Map,tt=e,t},no=e=>{Ee=e.memo,tt=e.base},Dn=(e,t)=>e.component!==void 0?In(t,e.component):e.tag.includes("-")?In(t,e.tag):null,X=e=>e.component??e.tag,In=(e,t)=>{if(!Ee)return Ln(e,t);let n=t.replace(/-/g,"").toLowerCase();for(let s=e;s&&s!==Object.prototype;s=Object.getPrototypeOf(s)){if(s===tt){if(Ee.has(t))return Ee.get(t);let r=Ln(s,t);return Ee.set(t,r),r}if(!ms.has(s)){for(let r of Object.keys(s))if(/^[A-Z]/.test(r)&&r.replace(/-/g,"").toLowerCase()===n)return r}}return null},so=e=>{let t=new Set;for(let n=e;n&&n!==Object.prototype;n=Object.getPrototypeOf(n))for(let s of Object.keys(n))/^[A-Z]/.test(s)&&t.add(s);return[...t].sort()},ro=(e,t)=>{let n=so(t);return new Error(`jq79: <${e}> is not defined - no component of that name is in scope, and nothing renders here. Import it in a :setup script, declare it as a prop, or add a <template name="${e}"> to this file. In scope: ${n.length?n.join(", "):"(none)"}.`)},qn=100,Ct=0,ys=Symbol("jq79.slots"),Le=e=>Object.keys(e.attrs).find(t=>t===":slot"||t.startsWith(":slot.")),oo=e=>e==="default"?":slot":`:slot.${e}`,io=e=>typeof e!="string"||e.trim()!=="",ao=e=>{let t={},n=[];e.children.forEach(r=>{let i=typeof r=="object"&&r.tag==="template"?Le(r):void 0;if(typeof r=="string"||i===void 0){n.push(r);return}let o=Rt(i.slice(6));if(o in t){console.warn(`jq79: two <template ${oo(o)}> in <${X(e)}>; the second was ignored`);return}t[o]={nodes:r.children,binder:r.attrs[i]||void 0}});let s=n.some(io);return s&&"default"in t?console.warn(`jq79: <${X(e)}> has both a <template :slot> and content outside it - the <template> is the default slot's content, and the rest was ignored`):s&&(t.default={nodes:n,binder:e.attrs[":slot"]||void 0}),t},lo=(e,t,n)=>{ke(t)?.forEach(({name:s,as:r,default:i})=>{let o=r??s;Object.defineProperty(e,o,{enumerable:!0,configurable:!0,get:()=>{let a=n[s]?.();return a===void 0&&i!==void 0?_(i,e):a},set:()=>console.warn(`jq79: "${o}" is a slot prop - it comes from the component, so assigning to it does nothing`)})})},co=e=>{let t=Le(e);return console.warn(`jq79: <template ${t}> fills a slot only as a direct child of a component tag; here it rendered nothing`),document.createComment(`misplaced ${t}`)},uo=(e,t)=>{let n=Object.entries(ao(e));if(!n.length)return null;let s={};return n.forEach(([r,i])=>{s[r]=fo(i,t)}),s},fo=(e,t)=>(n,s,r,i)=>{let o=Object.create(t);lo(o,e.binder,n);let a=o[We]??[];Object.defineProperty(o,We,{value:[...a,s]});let l=me(o);return l.ownedBy(s),r.onDispose(()=>l.dispose()),be(e.nodes,o,l,i)},po=(e,t,n,s)=>{let r=Rt(e.tag.slice(5)),i=document.createDocumentFragment(),o=document.createComment(e.tag),a=document.createComment(`/${e.tag}`);i.append(o,a);let l=t[ys]?.[r];if(!l)return i.insertBefore(be(e.children,t,n,s),a),i;let f={};return Object.entries(e.attrs).forEach(([u,h])=>{if(!(u===Ce||ye(u)||u.startsWith("@")))if(u.startsWith(":")){let w=h||u.slice(1);f[ie(u.slice(1))]=()=>_(w,t)}else f[ie(u)]=()=>h}),i.insertBefore(l(f,t,n,s),a),i},Es="data-c79-box",ho=(e,t,n)=>{if(t.ns!==void 0)return document.createDocumentFragment();let s=document.createElement(_e(e));s.setAttribute(Es,"");let r=t.attrs[Ce];return r!==void 0&&s.setAttribute(Ce,r),n||ti(),s},Hn=new WeakSet,go=(e,t)=>{if(e.ns===void 0||Hn.has(e))return;let n=t.template.find(r=>typeof r=="object");if(n===void 0||n.ns!==void 0)return;Hn.add(e);let s=e.ns==="http://www.w3.org/1998/Math/MathML"?"<math>":"<svg>";console.warn(`jq79: <${X(e)}> is used inside ${s} and its template starts with <${n.tag.toLowerCase()}>, which is parsed as HTML - it renders and never draws. A component's template decides its own namespace, so root it at ${s}`)},Wn=(e,t,n,s,r)=>{let i=ho(e,t,r),o=!(i instanceof DocumentFragment),a=o?null:document.createComment(`/${e}`);o||i.append(document.createComment(e),a);let l=uo(t,n),f={},u={},h=[],w=[],O=!1;Object.entries(t.attrs).forEach(([v,P])=>{if(v!==Ce){if(v===":props"||v.startsWith(":props.")){O=!0,w.push({expr:P});return}if(!ye(v))if(v.startsWith("@"))h.push([v,P]);else if(v===":model"||v.startsWith(":model.")){let x=v===":model"?"default":ie(v.slice(7));u[x]=P||(v===":model"?"model":x)}else if(v.startsWith(":")){let x=ie(v.slice(1));f[x]=P||x,w.push({name:x,expr:P||x})}else{let x=ie(v),W=JSON.stringify(P);f[x]=W,w.push({name:x,expr:W})}}});let I=v=>v==="default"?":model":`:model.${v}`,G=v=>v==="default"?"model":v,j=new Set;Object.entries(u).forEach(([v,P])=>{let x=G(v);f[x]!==void 0&&console.warn(`jq79: <${X(t)}> binds prop "${x}" through both :${x} and ${I(v)} - ${I(v)} wins`),f[x]=P,Kr(xt(P),["$value"])===null&&(j.add(v),console.warn(`jq79: ${I(v)}="${P}" is not assignable - updates from <${X(t)}> will be dropped`))});let b=()=>{let v={};return w.forEach(({name:P,expr:x})=>{if(P!==void 0)v[P]=_(x,n);else{let W=_(x,n);W!==null&&typeof W=="object"&&Object.assign(v,W)}}),Object.entries(u).forEach(([P,x])=>{v[G(P)]=_(x,n)}),v},H=null,D=null,L=null,B=new Set,ae=v=>{if(v==null){if(!n[Os]?.has(e)||B.has("unfilled"))return;B.add("unfilled"),console.error(`jq79: <${X(t)}> is declared as a prop and the parent passed nothing - nothing renders here. Pass it (:${e}="\u2026"), or drop it from the signature to use the one declared in this file.`);return}B.has("type")||(B.add("type"),console.error(`jq79: <${X(t)}> is ${typeof v}, not a component - nothing renders here`))};return s.effect(()=>{let v=_(e,n),P=v instanceof de?v:null;if(P||ae(v),P===D||(L?.dispose(),L=null,H?.destroy(),H=null,D=P,!P))return;go(t,P);let x=new de({template:P.template,scripts:P.scripts,styles:P.styles,modules:P.modules,filename:P.filename,siblings:P.siblings,name:P.name});if(l&&(x.slots=l),Object.keys(u).length){let M=new Set;x.modelWriteback=(U,Q)=>{let $=U==null?"default":ie(String(U)),q=u[$];return q===void 0?(M.has($)||(M.add($),console.warn(`jq79: <${X(t)}> has no ${I($)} - bound: ${Object.keys(u).map(I).join(", ")}`)),!1):j.has($)?!1:(Re(()=>_(xt(q),n,{$value:Q})),!0)}}h.forEach(([M,U])=>Xr(x,M,U,n));let W=ii(x.scripts);ai(t,e,Object.keys(f),W);let J=Yn(Re(b),W),V=document.createDocumentFragment();if(Ct>=qn){console.error(`jq79: <${X(t)}> is ${qn} levels deep inside itself; giving up here. A component that renders itself stops when its data stops - is there a cycle in it?`);return}Ct++;try{(r?x.renderShadow(J):x.render(J)).mount(V)}finally{Ct--}let E=n[rt];E&&x.holdOwner(E.owner),a?a.parentNode.insertBefore(V,a):i.appendChild(V);let C=me(n,!0);if(O){let M=[];C.effect(()=>{let U=Yn(b(),W),Q=Object.keys(U);M.forEach($=>{$ in U||(x.data[$]=void 0)}),Q.forEach($=>{x.data[$]=U[$]}),M=Q})}else Object.entries(f).forEach(([M,U])=>{W!==null&&!W.has(M)||C.effect(()=>{x.data[M]=_(U,n)})});L=C,H=x}),s.onDispose(()=>{L?.dispose(),H?.destroy()}),i},mo=(e,t)=>{let n=()=>{let s=_(e,t);return s!==null&&typeof s=="object"?s:null};return new Proxy(t,{has(s,r){let i=n();return i!==null&&Reflect.has(i,r)||Reflect.has(s,r)},get(s,r){let i=n();return i!==null&&Reflect.has(i,r)?i[r]:Reflect.get(s,r)},set(s,r,i){let o=n();return o!==null&&Reflect.has(o,r)?(o[r]=i,!0):Reflect.set(s,r,i)}})},pe=e=>typeof e=="string"?e.split(/\s+/).filter(Boolean):Array.isArray(e)?e.flatMap(pe):e!==null&&typeof e=="object"?Object.entries(e).flatMap(([t,n])=>n?pe(t):[]):[],yo=e=>typeof e=="function"?(t,n,s)=>{try{return!!e(t,n,s)}catch{return!1}}:typeof e=="string"||Array.isArray(e)?Jt(e):()=>!1,Eo=new Set(["allowfullscreen","async","autofocus","autoplay","checked","controls","default","defer","disabled","formnovalidate","inert","ismap","itemscope","loop","multiple","muted","nomodule","novalidate","open","playsinline","readonly","required","reversed","selected"]),ws=e=>e.ns===void 0?document.createElement(e.tag):document.createElementNS(e.ns,e.tag),wo={"http://www.w3.org/2000/svg":["svg","feGaussianBlur"],"http://www.w3.org/1998/Math/MathML":["math","mi"]},Fn=new Map,So=(e,t)=>{let n=`${e} ${t}`,s=Fn.get(n);if(s!==void 0)return s;let r=wo[e],i=t;if(r!==void 0&&typeof DOMParser<"u"&&/^[a-z][a-z0-9]*$/.test(t)){let[o,a]=r;i=new DOMParser().parseFromString(`<${o}><${a} ${t}="x"/></${o}>`,"text/html").querySelector(a)?.getAttributeNames().find(f=>f.toLowerCase()===t)??t}return Fn.set(n,i),i},Ss=(e,t)=>{let n=e.namespaceURI;if(n===null||n===ss)return t;let s=t.replace(/-/g,"").toLowerCase(),r=So(n,s);return r===s?t:r},bs=(e,t,n)=>{let s=Eo.has(t);(s?!n:n==null)?e.removeAttribute(t):e.setAttribute(t,s?"":String(n))},le={cloneSkeletons:!0,scopedNames:!0},bo=new Set([":text",":html",":value",":checked",":selected"]),To=e=>e.startsWith("@")||e===":class"||e.startsWith(":class.")||bo.has(e)?!0:e.startsWith(":")?e===":model"?!1:!ye(e)&&!e.includes("."):e!==Oe,Ts=e=>{if(e.component||e.tag.includes("-")||Ze(e.tag)||e.tag==="template"||e.ns===void 0&&document.createElement(e.tag)instanceof HTMLUnknownElement)return!1;for(let t in e.attrs)if(!To(t))return!1;return e.attrs[":text"]!==void 0||e.attrs[":html"]!==void 0?!0:e.children.every(t=>typeof t=="string"||Ts(t))},$s=(e,t,n)=>{let s=ws(e),r,i=null;for(let h in e.attrs){let w=e.attrs[h];if(h.startsWith("@"))n.push({kind:"event",path:t,attr:h,expr:w});else if(h===":class")r=w;else if(h.startsWith(":class."))(i??(i=[])).push([h.slice(7),w]);else if(!ye(h))if(h.startsWith(":")){let O=h.slice(1);n.push({kind:"attr",path:t,name:Ss(s,O),expr:w||ie(O)})}else s.setAttribute(h,w)}(r!==void 0||i)&&n.push({kind:"class",path:t,classExpr:r,toggles:i,staticClasses:new Set(pe(e.attrs.class??""))});let o=e.attrs[":text"],a=e.attrs[":html"];o!==void 0?n.push({kind:"textContent",path:t,expr:o}):a!==void 0?n.push({kind:"html",path:t,expr:a}):e.children.forEach((h,w)=>{if(typeof h=="string"){h.includes("{{")?(n.push({kind:"text",path:[...t,w],parts:Tt(h)}),s.appendChild(document.createTextNode(""))):s.appendChild(document.createTextNode(h));return}s.appendChild($s(h,[...t,w],n))});let l=e.attrs[":value"];l!==void 0&&n.push({kind:"value",path:t,expr:l});let f=e.attrs[":checked"];f!==void 0&&n.push({kind:"checked",path:t,expr:f});let u=e.attrs[":selected"];return u!==void 0&&n.push({kind:"selected",path:t,expr:u}),s},$o=3,Rs=e=>e.attrs[":text"]!==void 0||e.attrs[":html"]!==void 0?1:1+e.children.reduce((t,n)=>t+(typeof n=="string"?0:Rs(n)),0),Un=new WeakMap,Bn=new WeakSet,Ro=e=>{let t=Un.get(e);if(t!==void 0)return t;if(!Bn.has(e))return Bn.add(e),null;let n=null;if(Ts(e)&&Rs(e)>=$o){let s=[];n={skeleton:$s(e,[],s),ops:s}}return Un.set(e,n),n},xo=(e,t)=>{let n=e;for(let s=0;s<t.length;s++)n=n.childNodes[t[s]];return n},No=(e,t,n)=>{let s=e.skeleton.cloneNode(!0);for(let r of e.ops){let i=r.path.length===0?s:xo(s,r.path);if(r.kind==="text"){let o=i,a=r.parts;n.effect(()=>{let l=hs(a,t);o.textContent!==l&&(o.textContent=l)})}else if(r.kind==="event")gs(i,r.attr,r.expr,t);else if(r.kind==="attr"){let o=i,{name:a,expr:l}=r;n.effect(()=>bs(o,a,_(l,t)))}else if(r.kind==="class"){let o=i,{classExpr:a,toggles:l,staticClasses:f}=r,u=[];n.effect(()=>{let h=a!==void 0?pe(_(a,t)):[];l?.forEach(([w,O])=>{_(O,t)&&h.push(...pe(w))}),u.forEach(w=>{!h.includes(w)&&!f.has(w)&&o.classList.remove(w)}),o.classList.add(...h),u=h})}else if(r.kind==="textContent"){let o=i,{expr:a}=r;n.effect(()=>{let l=String(_(a,t)??"");o.textContent!==l&&(o.textContent=l)})}else if(r.kind==="html"){let o=i,{expr:a}=r;n.effect(()=>{o.innerHTML=lt(String(_(a,t)??""))})}else if(r.kind==="value"){let o=i,{expr:a}=r;n.effect(()=>{let l=String(_(a,t)??"");o.value!==l&&(o.value=l)})}else if(r.kind==="checked"){let o=i,{expr:a}=r;n.effect(()=>{let l=!!_(a,t);o.checked!==l&&(o.checked=l)})}else if(r.kind==="selected"){let o=i,{expr:a}=r;n.effect(()=>{let l=!!_(a,t);o.selected!==l&&(o.selected=l)})}else{let o=r}}return s},Gt=(e,t,n,s)=>{let r=e.attrs[":with"],i=r!==void 0?mo(r,t):t;if(Ze(e.tag))return po(e,i,n,s);if(e.tag==="template"&&Le(e)!==void 0)return co(e);let o=Dn(e,i);if(o)return Wn(o,e,i,n,s);if(le.cloneSkeletons){let b=Ro(e);if(b)return No(b,i,n)}let a=ws(e);if(e.component!==void 0&&i[rt]?.count===0)throw ro(e.component,i);let l=e.ns===void 0&&(e.component!==void 0||e.tag.includes("-"));if(l){let b=!1;n.effect(()=>{if(b)return;let H=Dn(e,i);if(!H)return;b=!0;let D=Wn(H,e,i,n,s),L=zt(D);n.onDispose(()=>it(L)),a.replaceWith(D)})}for(let b in e.attrs){let H=e.attrs[b];if(b.startsWith("@"))gs(a,b,H,i);else if(b===":model"||b.startsWith(":model."))l||console.warn(`jq79: ${b} on <${X(e)}> does nothing - :model binds component tags only (for now)`);else if(!ye(b))if(b.startsWith(":"))if(l)a.setAttribute(b,H);else{let D=b.slice(1),L=H||ie(D),B=Ss(a,D);n.effect(()=>bs(a,B,_(L,i)))}else a.setAttribute(b,H)}let f=e.attrs[":class"],u=null;for(let b in e.attrs)b.startsWith(":class.")&&(u??(u=[])).push([b.slice(7),e.attrs[b]]);if(f!==void 0||u){let b=new Set(pe(e.attrs.class??"")),H=[];n.effect(()=>{let D=f!==void 0?pe(_(f,i)):[];u?.forEach(([L,B])=>{_(B,i)&&D.push(...pe(L))}),H.forEach(L=>{!D.includes(L)&&!b.has(L)&&a.classList.remove(L)}),a.classList.add(...D),H=D})}let h=e.attrs[":text"],w=e.attrs[":html"],O=e.attrs[":html.allowed"];O!==void 0&&w===void 0&&console.warn("jq79: :html.allowed without :html on the same element does nothing"),h!==void 0?n.effect(()=>{let b=String(_(h,i)??"");a.textContent!==b&&(a.textContent=b)}):w!==void 0?n.effect(()=>{let b=O!==void 0?{allowUrl:yo(_(O,i))}:void 0;a.innerHTML=lt(String(_(w,i)??""),b)}):a instanceof HTMLTemplateElement?be(e.children,i,n,s,a.content):be(e.children,i,n,s,a);let I=e.attrs[":value"];I!==void 0&&n.effect(()=>{let b=String(_(I,i)??"");a.value!==b&&(a.value=b)});let G=e.attrs[":checked"];G!==void 0&&n.effect(()=>{let b=!!_(G,i);a.checked!==b&&(a.checked=b)});let j=e.attrs[":selected"];return j!==void 0&&n.effect(()=>{let b=!!_(j,i);a.selected!==b&&(a.selected=b)}),a},vo=(e,t,n,s)=>{let r=document.createComment("if"),i=document.createDocumentFragment();i.appendChild(r);let o=null,a=null,l=null;return n.effect(()=>{let f=e.find(h=>h.expr===void 0||_(h.expr,t))??null;if(f===a||(l?.dispose(),o&&it(o),o=null,a=f,!f))return;l=me(t);let u=Gt(f.node,t,l,s);o=zt(u),r.parentNode.insertBefore(u,r.nextSibling)}),n.onDispose(()=>l?.dispose()),i},Ne=(e,t,n)=>{Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})},Po=e=>{let t=new Uint8Array(e.length),n=[],s=new Int32Array(e.length).fill(-1);for(let r=0;r<e.length;r++){let i=e[r];if(i<0)continue;let o=0,a=n.length;for(;o<a;){let l=o+a>>1;e[n[l]]<i?o=l+1:a=l}o>0&&(s[r]=n[o-1]),n[o]=r}for(let r=n.length?n[n.length-1]:-1;r!==-1;r=s[r])t[r]=1;return t},Co=e=>{if(e===null||typeof e!="object"||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null},xs=(e,t)=>typeof e=="string"?t.some(n=>zn(e,n)):Object.values(e.attrs).some(n=>t.some(s=>zn(n,s)))||e.children.some(n=>xs(n,t)),Ns=e=>typeof e!="string"&&(":if"in e.attrs||":elseif"in e.attrs||":else"in e.attrs||":each"in e.attrs||e.component!==void 0||e.tag.includes("-")||Ze(e.tag)||e.children.some(Ns)),Kn=/[A-Za-z0-9_$]/,Mo=/^[A-Za-z_$][\w$]*\.[A-Za-z_$][\w$]*$/,zn=(e,t)=>{for(let n=e.indexOf(t);n!==-1;n=e.indexOf(t,n+1)){let s=n===0?"":e[n-1],r=e[n+t.length]??"";if(!Kn.test(s)&&!Kn.test(r))return!0}return!1},Mt=new WeakMap,ko=e=>{let t=Mt.get(e);if(t!==void 0)return t;let n=e.attrs[":each"].match(Tn);if(!n)return Mt.set(e,null),null;let[,s,r,i]=n,o=e.attrs[":key"],a=o===s,l=o!==void 0&&!a&&Mo.test(o)&&o.startsWith(`${s}.`)?o.slice(s.length+1):void 0,{[":each"]:f,[":key"]:u,...h}=e.attrs,w={...e,attrs:h},O=["$index",...r?[r]:[]],I=xs(w,O),G=/^[A-Z]/.test(s)||r!==void 0&&/^[A-Z]/.test(r),j=o!==void 0&&Ns(w),b={itemName:s,atName:r,listExpr:i,keyExpr:o,keyIsItem:a,keyProp:l,itemNode:w,readsPosition:I,namesComponent:G,nestsScopes:j};return Mt.set(e,b),b},Ao=(e,t,n,s)=>{let r=ko(e);if(!r)return document.createComment(`invalid :each expression "${e.attrs[":each"]}"`);let{itemName:i,atName:o,listExpr:a,keyExpr:l,keyIsItem:f,keyProp:u,itemNode:h,readsPosition:w,namesComponent:O,nestsScopes:I}=r,G=document.createComment("each"),j=document.createDocumentFragment();j.appendChild(G),(":if"in e.attrs||":elseif"in e.attrs||":else"in e.attrs)&&console.warn("jq79: :if/:elseif/:else on a :each element is ignored; filter the list expression instead");let b=[],H=!1;return n.effect(()=>{let D=to(t);try{let L=_(a,t),B=Array.isArray(L),ae=B?null:Co(L)?Object.keys(L):[],v=B?L.length:ae.length,P=new Map;b.forEach(($,q)=>{$.pos=q;let K=P.get($.key);K?K.push($):P.set($.key,[$])});let x=new Set,W=[],J=[],V=[],E=[],C;for(let $=0;$<v;$++){let q=B?$:ae[$],K=B?L[$]:L[q],c=q;f?c=K:u!==void 0&&K!==null&&typeof K=="object"?c=K[u]:l!==void 0&&(C===void 0?(C=Object.create(t),Ne(C,i,K),o&&Ne(C,o,q),Ne(C,"$index",$)):(C[i]=K,o&&(C[o]=q),C.$index=$),c=_(l,C)),x.has(c)&&!H&&(H=!0,console.warn(`jq79: duplicate :key in :each "${e.attrs[":each"]}"; duplicates pair up by position`)),x.add(c);let d=P.get(c)?.shift();if(d&&Object.is(d.item,K)){let m=d.scope;m.$index!==$&&(w&&W.push(d),m.$index=$),o&&m[o]!==q&&(m[o]=q),V.push(d),E.push(d.pos);continue}if(d&&l!==void 0){let m=d.scope;m[i]=K,m.$index!==$&&(m.$index=$),o&&m[o]!==q&&(m[o]=q),d.item=K,J.push(d),V.push(d),E.push(d.pos);continue}d&&(d.fx.dispose(),it(d.range));let g=Object.create(t);Ne(g,i,K),o&&Ne(g,o,q),Ne(g,"$index",$),O||ms.add(g);let p=me(t);I&&Object.defineProperty(g,ht,{value:p});let S=zt(Gt(h,g,p,s));V.push({key:c,item:K,scope:g,fx:p,range:S,pos:$}),E.push(-1)}let M=new Set;P.forEach($=>$.forEach(q=>M.add(q))),M.size&&(M.forEach($=>{$.dead=!0,$.fx.dispose()}),Yr(Jr(b,$=>$.dead===!0)));let U=G,Q=Po(E);V.forEach(($,q)=>{!Q[q]&&U.nextSibling!==$.range.first&&eo($.range,U),U=$.range.last}),W.forEach($=>Re(()=>$.fx.refresh())),J.forEach($=>Re(()=>$.fx.rerun())),b=V}finally{no(D)}}),n.onDispose(()=>b.forEach(D=>D.fx.dispose())),j},vs=(e,t)=>{let n=t;for(;n<e.length&&typeof e[n]=="string"&&!e[n].trim();)n++;return n},kt=e=>{let t=":if"in e.attrs,n=":elseif"in e.attrs,s=":else"in e.attrs;if((t?1:0)+(n?1:0)+(s?1:0)<2)return;let r=[t?":if":null,n?":elseif":null,s?":else":null].filter(Boolean);console.warn(`jq79: ${r.join(" and ")} on the same <${X(e)}> - only ${r[0]} applies; the branches of a chain are sibling elements, one directive each`)},Oo=(e,t)=>{let n=":elseif"in e.attrs?":elseif":":else";console.warn(t?`jq79: a second ${n} on <${X(e)}> - the chain before it already ended with :else, which closes it. One :if, any number of :elseif, at most one :else`:`jq79: ${n} on <${X(e)}> continues no :if - it renders unconditionally. A chain is :if, then :elseif, then :else, on adjacent siblings: anything but whitespace between them breaks it`)},_o=[":if",":elseif",":else",":each"],jo=(e,t)=>{if(e.tag!=="template"||e.ns!==void 0)return;let n=_o.find(s=>s in e.attrs);if(n!==void 0){if(Le(e)!==void 0){if(t?.component===void 0)return;console.warn(`jq79: ${n} on <template ${Le(e)}> is ignored - a slot is filled with its children as written. Put ${n} on the elements inside it, or on the component's tag`);return}console.warn(`jq79: ${n} on a nested <template> shows nothing - a <template>'s children live in its .content and never reach the page. Put ${n} on the elements themselves`)}},Lo=[...$t,":model",":slot"].map(e=>e.slice(1)),Do={":attrs":':attrs was removed in 0.7 - it now binds an attribute called "attrs". Bind them one at a time (:disabled="x", :title="y"), or :class for classes'},Io=e=>{for(let t in e.attrs){let n=Do[t];n!==void 0&&console.warn(`jq79: ${n}`)}},qo=e=>{if(!(e.component!==void 0||e.tag.includes("-")))for(let t in e.attrs){if(!t.startsWith(":")||ye(t)||t===":model"||t.startsWith(":model."))continue;let n=t.slice(1);if(n.includes(".")){console.warn(`jq79: ${t} is not a directive - it bound an attribute named "${n}". Dotted modifiers belong to an event: if you meant @${n}, that is the spelling`);continue}let s=Lo.find(r=>n!==r&&n.startsWith(r));s!==void 0&&console.warn(`jq79: ${t} is not a directive - it bound an attribute named "${n}". A ":name" jq79 does not recognize binds that attribute (which is what :src and :disabled are). If you meant :${s}, that is the spelling`)}},Ps=(e,t)=>{e.forEach(s=>{typeof s!="string"&&(jo(s,t),Io(s),qo(s),Ps(s.children,s))});let n=!1;for(let s=0;s<e.length;){let r=e[s];if(typeof r=="string"){r.trim()&&(n=!1),s++;continue}if(":each"in r.attrs){n=!1,s++;continue}if(kt(r),":if"in r.attrs){s++;let i=a=>{let l=vs(e,s),f=e[l];if(typeof f=="object"&&a in f.attrs)return s=l+1,f};for(let a=i(":elseif");a;a=i(":elseif"))kt(a);let o=i(":else");o&&kt(o),n=o!==void 0;continue}(":elseif"in r.attrs||":else"in r.attrs)&&Oo(r,n),n=!1,s++}},Gn=new WeakMap,Ho=(e,t,n)=>{let s=Gn.get(t);if(s)return s;let r=[{expr:t.attrs[":if"],node:t}],i=n+1,o=f=>{let u=vs(e,i),h=e[u];if(typeof h=="object"&&f in h.attrs)return i=u+1,h};for(let f=o(":elseif");f;f=o(":elseif"))r.push({expr:f.attrs[":elseif"],node:f});let a=o(":else");a&&r.push({node:a});let l={branches:r,next:i};return Gn.set(t,l),l},be=(e,t,n,s=!1,r)=>{let i=r??document.createDocumentFragment(),o=0;for(;o<e.length;){let a=e[o];if(typeof a=="string"){let l=document.createTextNode(a);if(a.includes("{{")){let f=Tt(a);n.effect(()=>{let u=hs(f,t);l.textContent!==u&&(l.textContent=u)})}i.appendChild(l),o++;continue}if(":each"in a.attrs){i.appendChild(Ao(a,t,n,s)),o++;continue}if(":if"in a.attrs){let l=Ho(e,a,o);i.appendChild(vo(l.branches,t,n,s)),o=l.next;continue}i.appendChild(Gt(a,t,n,s)),o++}return i},Wo=(e,t,n=!1)=>be(e.template,t,me(t),n),Ce="data-jq79",Fo=e=>{let t=2166136261;for(let n=0;n<e.length;n++)t=Math.imul(t^e.charCodeAt(n),16777619);return(t>>>0).toString(36)},Cs=(e,t)=>{e.forEach(n=>{typeof n!="string"&&(n.attrs[Ce]=t,Cs(n.children,t))})},Uo=(e,t)=>e.split(",").map(n=>{let s=n.trim(),r=s.indexOf("::"),i=r===-1?s:s.slice(0,r),o=r===-1?"":s.slice(r);return`${i}[${Ce}="${t}"]${o}`}).join(", "),Ms=(e,t)=>{Array.from(e).forEach(n=>{n instanceof CSSStyleRule?n.selectorText=Uo(n.selectorText,t):n instanceof CSSGroupingRule&&Ms(n.cssRules,t)})},Bo=/(^|[\s>+~,(])([A-Z][A-Za-z0-9]*)(?![\w-])/g,Ko=/[a-z]/,zo=e=>e.replace(Bo,(t,n,s)=>Ko.test(s)?`${n}${_e(s)}`:t),Go=/^\s*@(media|supports|container|layer|scope|document)\b/i,Vo=/^\s*@/,Zo=e=>{let t="",n="",s="",r=[],i=()=>r.length===0||r[r.length-1],o=()=>{t+=i()&&!Vo.test(s)?zo(n):n,n=""},a=f=>{o(),t+=f,s+=f},l=(f,u)=>{o(),t+=f,s="",u!==void 0?r.push(u):f==="}"&&r.pop()};for(let f=0;f<e.length;){let u=e[f];if(u==="/"&&e[f+1]==="*"){let h=e.indexOf("*/",f+2),w=h===-1?e.length:h+2;a(e.slice(f,w)),f=w}else if(u==='"'||u==="'"){let h=f+1;for(;h<e.length&&e[h]!==u;)h+=e[h]==="\\"?2:1;a(e.slice(f,Math.min(h+1,e.length))),f=h+1}else u==="{"?(l("{",Go.test(s)),f++):u==="}"||u===";"?(l(u),f++):(n+=u,s+=u,f++)}return o(),t},Qo=(e,t)=>{/:deep\(|::v-deep|>>>/.test(e)&&console.warn("jq79: :deep()/::v-deep/>>> are not supported in <style scoped>; the rule will be dropped by the browser");let n=new CSSStyleSheet;return n.replaceSync(e),Ms(n.cssRules,t),Array.from(n.cssRules).map(s=>s.cssText).join(`
17
+ }`;var $i={};var qr="0.7.8",ns=e=>Object.fromEntries(Array.from(e.attributes).map(t=>[t.name,t.value])),ss="http://www.w3.org/1999/xhtml",rs=e=>{let t=ns(e),n=e.namespaceURI,s=t[Oe];delete t[Oe];let r=n!==null&&n!==ss;return{tag:r?e.tagName:e.tagName.toLowerCase(),attrs:t,...s===void 0?{}:{component:s},...r?{ns:n}:{},children:Array.from((e instanceof HTMLTemplateElement?e.content:e).childNodes).flatMap(i=>{if(i.nodeType===Node.TEXT_NODE){let o=i.textContent??"";return o?[o]:[]}return i.nodeType===Node.ELEMENT_NODE?[rs(i)]:[]})}},Je=new Map,Ye=new Map,Ut=!1,jt,Pe=class extends Error{constructor(n,s){super(`${n}. ${s}`);k(this,"reason",n);k(this,"hint",s)}},Hr=()=>new Pe("was not precompiled","Safe mode never builds code at runtime: the component's precompiled functions did not reach the page."),Wr=(e,t)=>{let n=globalThis[kn];if(Array.isArray(n)&&n.length>0)for(let[s,r,i]of n.splice(0))Ye.set(Qe(s,r),i);return Ye.size===0?void 0:Ye.get(Qe(e,t))},Bt=(e,t,n="")=>{let s=Wr(e,t);if(s===null)throw new SyntaxError("jq79: this code did not compile when it was precompiled");if(s!==void 0)return s;if(jt!==void 0)return Fr(e,t,n,jt);if(Ut)throw Hr();return new Function(...e,t+n)},os=()=>{if(!(typeof document>"u"))for(let e of Array.from(document.querySelectorAll("script[nonce]"))){let t=e.nonce||e.getAttribute("nonce");if(t)return t}},_n="__jq79built",Fr=(e,t,n,s)=>{let r=document.createElement("script");r.setAttribute("nonce",s),r.textContent=`document.currentScript.${_n} = ${On(e,t)}${n}`;let i,o=l=>{i=l.error??new SyntaxError(l.message),l.preventDefault()};window.addEventListener("error",o);try{(document.head??document.documentElement).append(r)}finally{window.removeEventListener("error",o),r.remove()}let a=r[_n];if(typeof a=="function")return Ye.set(Qe(e,t),a),a;throw i!==void 0?i:new Pe("could not be built","The page's CSP refused a <script> carrying the nonce jq79 read from the page.")},jn=new Set,Ur=(e,t)=>{jn.has(e)||(jn.add(e),console.error(`jq79: safeEval() is on, and "${e}" ${t.reason}, so it rendered as nothing. ${t.hint}`))},Pt=(e,t)=>{if(!(t in e)){if(t in globalThis)return globalThis[t];throw new ReferenceError(`${t} is not defined`)}},is=(e,t)=>{try{return Bt([...Nt,...t],$n(e))}catch(n){return n instanceof Pe&&Ur(e,n),null}},Br=(e,t)=>{if(!le.scopedNames)return null;let n=Rn(e,t);if(n===null)return null;try{return Bt([...Nt,...t],n)}catch{return null}},as=(e,t,n)=>{let s=Je.get(e);if(s===void 0){let r=Br(t,n);s=r?{fn:r,scoped:!0}:{fn:is(t,n),scoped:!1},Je.set(e,s)}return s},ls=(e,t)=>`${t.join(",")}|${e}`,Kr=(e,t)=>as(ls(e,t),e,t).fn,zr=(e,t,n)=>{let s=is(t,n);return Je.set(e,{fn:s,scoped:!1}),s},Gr=/^(?:([\w$]+) is not defined|Can't find variable: ([\w$]+))/,Vr=100,we=new Map,Kt=new Set,et=0,Lt=!1,Dt=new Set,Zr=()=>{Lt=!1,!(et>0)&&(we.forEach(({name:e,expr:t,scope:n},s)=>{e in n||(Kt.add(s),console.warn(`jq79: ${e} is not defined - evaluating "${t}". Template expressions resolve against the component store: a top-level let/var/const in a :setup script, a declared prop, or a global. Note a "function name() {}" declaration is not on the store - write "const name = () => {}".`))}),we.clear())},cs=()=>{Lt||et>0||!we.size||(Lt=!0,queueMicrotask(Zr))},ds=e=>{et++;let t=()=>{et--,cs()};e.then(t,t)},Qr=(e,t)=>{if(Dt.has(e))return;Dt.add(e);let n=t?.message||String(t);console.error(`jq79: ${n} - evaluating "${e}". The expression rendered as nothing. If the value arrives later, guard it - "a?.b", or :if on the element.`)},us=(e,t,n)=>{if(!(n instanceof ReferenceError))return Qr(e,n);let s=Gr.exec(n.message),r=s?.[1]??s?.[2];if(!r)return;let i=`${r}|${e}`;Kt.has(i)||we.has(i)||we.size>=Vr||(we.set(i,{name:r,expr:e,scope:t}),cs())},fs=(e,t,n)=>{let s=n?Object.keys(n):[],r=ls(e,s),{fn:i,scoped:o}=as(r,e,s);if(!i)return;let a=n?Object.values(n):[];if(!o)return i(t,Pt,...a);try{return i(t,Pt,...a)}catch(l){if(!(l instanceof ReferenceError))throw l;let f=zr(r,e,s);if(!f)throw l;return f(t,Pt,...a)}},_=(e,t,n)=>{try{return fs(e,t,n)}catch(s){us(e,t,s);return}},ps=(e,t,n)=>{try{return fs(e,t,n)}catch(s){if(!(s instanceof ReferenceError))throw s;us(e,t,s);return}},hs=(e,t)=>{if(e.length===1){let s=e[0];return typeof s=="string"?s:String(_(s.expr,t)??"")}let n="";for(let s of e)n+=typeof s=="string"?s:String(_(s.expr,t)??"");return n},gs=(e,t,n,s)=>{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=ps(n,s,{$event:a});typeof l=="function"&&l.call(e,a)},{once:o.has("once"),capture:o.has("capture")})},Xr=(e,t,n,s)=>{let[r,...i]=t.slice(1).split("."),o=new Set(i),a=l=>{o.has("prevent")&&l.preventDefault(),o.has("stop")&&l.stopPropagation(),o.has("once")&&e.off(r,a),Re(()=>{let f=ps(n,s,{$event:l});typeof f=="function"&&f(l)})};e.on(r,a)},zt=e=>e instanceof DocumentFragment?{first:e.firstChild,last:e.lastChild}:{first:e,last:e},it=({first:e,last:t})=>{for(let n=e;n;){let s=n===t?null:n.nextSibling;n.parentNode?.removeChild(n),n=s}},Yr=e=>{e.forEach(t=>{if(t.first===t.last)return it(t);if(!t.first.parentNode)return;let s=document.createRange();s.setStartBefore(t.first),s.setEndAfter(t.last),s.deleteContents()})},Jr=(e,t)=>{let n=[],s=null;return e.forEach(r=>{if(!t(r)){s=null;return}s&&s.last.nextSibling===r.range.first?s.last=r.range.last:n.push(s={first:r.range.first,last:r.range.last})}),n},eo=({first:e,last:t},n)=>{let s=n.nextSibling;for(let r=e;r;){let i=r===t?null:r.nextSibling;n.parentNode.insertBefore(r,s),r=i}},Ln=(e,t)=>{let n=t.replace(/-/g,"").toLowerCase();for(let s=e;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},Ee=null,tt=null,ms=new WeakSet,to=e=>{let t={memo:Ee,base:tt};return Ee=new Map,tt=e,t},no=e=>{Ee=e.memo,tt=e.base},Dn=(e,t)=>e.component!==void 0?In(t,e.component):e.tag.includes("-")?In(t,e.tag):null,X=e=>e.component??e.tag,In=(e,t)=>{if(!Ee)return Ln(e,t);let n=t.replace(/-/g,"").toLowerCase();for(let s=e;s&&s!==Object.prototype;s=Object.getPrototypeOf(s)){if(s===tt){if(Ee.has(t))return Ee.get(t);let r=Ln(s,t);return Ee.set(t,r),r}if(!ms.has(s)){for(let r of Object.keys(s))if(/^[A-Z]/.test(r)&&r.replace(/-/g,"").toLowerCase()===n)return r}}return null},so=e=>{let t=new Set;for(let n=e;n&&n!==Object.prototype;n=Object.getPrototypeOf(n))for(let s of Object.keys(n))/^[A-Z]/.test(s)&&t.add(s);return[...t].sort()},ro=(e,t)=>{let n=so(t);return new Error(`jq79: <${e}> is not defined - no component of that name is in scope, and nothing renders here. Import it in a :setup script, declare it as a prop, or add a <template name="${e}"> to this file. In scope: ${n.length?n.join(", "):"(none)"}.`)},qn=100,Ct=0,ys=Symbol("jq79.slots"),Le=e=>Object.keys(e.attrs).find(t=>t===":slot"||t.startsWith(":slot.")),oo=e=>e==="default"?":slot":`:slot.${e}`,io=e=>typeof e!="string"||e.trim()!=="",ao=e=>{let t={},n=[];e.children.forEach(r=>{let i=typeof r=="object"&&r.tag==="template"?Le(r):void 0;if(typeof r=="string"||i===void 0){n.push(r);return}let o=Rt(i.slice(6));if(o in t){console.warn(`jq79: two <template ${oo(o)}> in <${X(e)}>; the second was ignored`);return}t[o]={nodes:r.children,binder:r.attrs[i]||void 0}});let s=n.some(io);return s&&"default"in t?console.warn(`jq79: <${X(e)}> has both a <template :slot> and content outside it - the <template> is the default slot's content, and the rest was ignored`):s&&(t.default={nodes:n,binder:e.attrs[":slot"]||void 0}),t},lo=(e,t,n)=>{ke(t)?.forEach(({name:s,as:r,default:i})=>{let o=r??s;Object.defineProperty(e,o,{enumerable:!0,configurable:!0,get:()=>{let a=n[s]?.();return a===void 0&&i!==void 0?_(i,e):a},set:()=>console.warn(`jq79: "${o}" is a slot prop - it comes from the component, so assigning to it does nothing`)})})},co=e=>{let t=Le(e);return console.warn(`jq79: <template ${t}> fills a slot only as a direct child of a component tag; here it rendered nothing`),document.createComment(`misplaced ${t}`)},uo=(e,t)=>{let n=Object.entries(ao(e));if(!n.length)return null;let s={};return n.forEach(([r,i])=>{s[r]=fo(i,t)}),s},fo=(e,t)=>(n,s,r,i)=>{let o=Object.create(t);lo(o,e.binder,n);let a=o[We]??[];Object.defineProperty(o,We,{value:[...a,s]});let l=me(o);return l.ownedBy(s),r.onDispose(()=>l.dispose()),be(e.nodes,o,l,i)},po=(e,t,n,s)=>{let r=Rt(e.tag.slice(5)),i=document.createDocumentFragment(),o=document.createComment(e.tag),a=document.createComment(`/${e.tag}`);i.append(o,a);let l=t[ys]?.[r];if(!l)return i.insertBefore(be(e.children,t,n,s),a),i;let f={};return Object.entries(e.attrs).forEach(([u,h])=>{if(!(u===Ce||ye(u)||u.startsWith("@")))if(u.startsWith(":")){let w=h||u.slice(1);f[ie(u.slice(1))]=()=>_(w,t)}else f[ie(u)]=()=>h}),i.insertBefore(l(f,t,n,s),a),i},Es="data-c79-box",ho=(e,t,n)=>{if(t.ns!==void 0)return document.createDocumentFragment();let s=document.createElement(_e(e));s.setAttribute(Es,"");let r=t.attrs[Ce];return r!==void 0&&s.setAttribute(Ce,r),n||ti(),s},Hn=new WeakSet,go=(e,t)=>{if(e.ns===void 0||Hn.has(e))return;let n=t.template.find(r=>typeof r=="object");if(n===void 0||n.ns!==void 0)return;Hn.add(e);let s=e.ns==="http://www.w3.org/1998/Math/MathML"?"<math>":"<svg>";console.warn(`jq79: <${X(e)}> is used inside ${s} and its template starts with <${n.tag.toLowerCase()}>, which is parsed as HTML - it renders and never draws. A component's template decides its own namespace, so root it at ${s}`)},Wn=(e,t,n,s,r)=>{let i=ho(e,t,r),o=!(i instanceof DocumentFragment),a=o?null:document.createComment(`/${e}`);o||i.append(document.createComment(e),a);let l=uo(t,n),f={},u={},h=[],w=[],O=!1;Object.entries(t.attrs).forEach(([v,P])=>{if(v!==Ce){if(v===":props"||v.startsWith(":props.")){O=!0,w.push({expr:P});return}if(!ye(v))if(v.startsWith("@"))h.push([v,P]);else if(v===":model"||v.startsWith(":model.")){let x=v===":model"?"default":ie(v.slice(7));u[x]=P||(v===":model"?"model":x)}else if(v.startsWith(":")){let x=ie(v.slice(1));f[x]=P||x,w.push({name:x,expr:P||x})}else{let x=ie(v),W=JSON.stringify(P);f[x]=W,w.push({name:x,expr:W})}}});let I=v=>v==="default"?":model":`:model.${v}`,G=v=>v==="default"?"model":v,j=new Set;Object.entries(u).forEach(([v,P])=>{let x=G(v);f[x]!==void 0&&console.warn(`jq79: <${X(t)}> binds prop "${x}" through both :${x} and ${I(v)} - ${I(v)} wins`),f[x]=P,Kr(xt(P),["$value"])===null&&(j.add(v),console.warn(`jq79: ${I(v)}="${P}" is not assignable - updates from <${X(t)}> will be dropped`))});let b=()=>{let v={};return w.forEach(({name:P,expr:x})=>{if(P!==void 0)v[P]=_(x,n);else{let W=_(x,n);W!==null&&typeof W=="object"&&Object.assign(v,W)}}),Object.entries(u).forEach(([P,x])=>{v[G(P)]=_(x,n)}),v},H=null,D=null,L=null,B=new Set,ae=v=>{if(v==null){if(!n[Os]?.has(e)||B.has("unfilled"))return;B.add("unfilled"),console.error(`jq79: <${X(t)}> is declared as a prop and the parent passed nothing - nothing renders here. Pass it (:${e}="\u2026"), or drop it from the signature to use the one declared in this file.`);return}B.has("type")||(B.add("type"),console.error(`jq79: <${X(t)}> is ${typeof v}, not a component - nothing renders here`))};return s.effect(()=>{let v=_(e,n),P=v instanceof de?v:null;if(P||ae(v),P===D||(L?.dispose(),L=null,H?.destroy(),H=null,D=P,!P))return;go(t,P);let x=new de({template:P.template,scripts:P.scripts,styles:P.styles,modules:P.modules,filename:P.filename,siblings:P.siblings,name:P.name});if(l&&(x.slots=l),Object.keys(u).length){let M=new Set;x.modelWriteback=(U,Q)=>{let $=U==null?"default":ie(String(U)),q=u[$];return q===void 0?(M.has($)||(M.add($),console.warn(`jq79: <${X(t)}> has no ${I($)} - bound: ${Object.keys(u).map(I).join(", ")}`)),!1):j.has($)?!1:(Re(()=>_(xt(q),n,{$value:Q})),!0)}}h.forEach(([M,U])=>Xr(x,M,U,n));let W=ii(x.scripts);ai(t,e,Object.keys(f),W);let J=Yn(Re(b),W),V=document.createDocumentFragment();if(Ct>=qn){console.error(`jq79: <${X(t)}> is ${qn} levels deep inside itself; giving up here. A component that renders itself stops when its data stops - is there a cycle in it?`);return}Ct++;try{(r?x.renderShadow(J):x.render(J)).mount(V)}finally{Ct--}let E=n[rt];E&&x.holdOwner(E.owner),a?a.parentNode.insertBefore(V,a):i.appendChild(V);let C=me(n,!0);if(O){let M=[];C.effect(()=>{let U=Yn(b(),W),Q=Object.keys(U);M.forEach($=>{$ in U||(x.data[$]=void 0)}),Q.forEach($=>{x.data[$]=U[$]}),M=Q})}else Object.entries(f).forEach(([M,U])=>{W!==null&&!W.has(M)||C.effect(()=>{x.data[M]=_(U,n)})});L=C,H=x}),s.onDispose(()=>{L?.dispose(),H?.destroy()}),i},mo=(e,t)=>{let n=()=>{let s=_(e,t);return s!==null&&typeof s=="object"?s:null};return new Proxy(t,{has(s,r){let i=n();return i!==null&&Reflect.has(i,r)||Reflect.has(s,r)},get(s,r){let i=n();return i!==null&&Reflect.has(i,r)?i[r]:Reflect.get(s,r)},set(s,r,i){let o=n();return o!==null&&Reflect.has(o,r)?(o[r]=i,!0):Reflect.set(s,r,i)}})},pe=e=>typeof e=="string"?e.split(/\s+/).filter(Boolean):Array.isArray(e)?e.flatMap(pe):e!==null&&typeof e=="object"?Object.entries(e).flatMap(([t,n])=>n?pe(t):[]):[],yo=e=>typeof e=="function"?(t,n,s)=>{try{return!!e(t,n,s)}catch{return!1}}:typeof e=="string"||Array.isArray(e)?Jt(e):()=>!1,Eo=new Set(["allowfullscreen","async","autofocus","autoplay","checked","controls","default","defer","disabled","formnovalidate","inert","ismap","itemscope","loop","multiple","muted","nomodule","novalidate","open","playsinline","readonly","required","reversed","selected"]),ws=e=>e.ns===void 0?document.createElement(e.tag):document.createElementNS(e.ns,e.tag),wo={"http://www.w3.org/2000/svg":["svg","feGaussianBlur"],"http://www.w3.org/1998/Math/MathML":["math","mi"]},Fn=new Map,So=(e,t)=>{let n=`${e} ${t}`,s=Fn.get(n);if(s!==void 0)return s;let r=wo[e],i=t;if(r!==void 0&&typeof DOMParser<"u"&&/^[a-z][a-z0-9]*$/.test(t)){let[o,a]=r;i=new DOMParser().parseFromString(`<${o}><${a} ${t}="x"/></${o}>`,"text/html").querySelector(a)?.getAttributeNames().find(f=>f.toLowerCase()===t)??t}return Fn.set(n,i),i},Ss=(e,t)=>{let n=e.namespaceURI;if(n===null||n===ss)return t;let s=t.replace(/-/g,"").toLowerCase(),r=So(n,s);return r===s?t:r},bs=(e,t,n)=>{let s=Eo.has(t);(s?!n:n==null)?e.removeAttribute(t):e.setAttribute(t,s?"":String(n))},le={cloneSkeletons:!0,scopedNames:!0},bo=new Set([":text",":html",":value",":checked",":selected"]),To=e=>e.startsWith("@")||e===":class"||e.startsWith(":class.")||bo.has(e)?!0:e.startsWith(":")?e===":model"?!1:!ye(e)&&!e.includes("."):e!==Oe,Ts=e=>{if(e.component||e.tag.includes("-")||Ze(e.tag)||e.tag==="template"||e.ns===void 0&&document.createElement(e.tag)instanceof HTMLUnknownElement)return!1;for(let t in e.attrs)if(!To(t))return!1;return e.attrs[":text"]!==void 0||e.attrs[":html"]!==void 0?!0:e.children.every(t=>typeof t=="string"||Ts(t))},$s=(e,t,n)=>{let s=ws(e),r,i=null;for(let h in e.attrs){let w=e.attrs[h];if(h.startsWith("@"))n.push({kind:"event",path:t,attr:h,expr:w});else if(h===":class")r=w;else if(h.startsWith(":class."))(i??(i=[])).push([h.slice(7),w]);else if(!ye(h))if(h.startsWith(":")){let O=h.slice(1);n.push({kind:"attr",path:t,name:Ss(s,O),expr:w||ie(O)})}else s.setAttribute(h,w)}(r!==void 0||i)&&n.push({kind:"class",path:t,classExpr:r,toggles:i,staticClasses:new Set(pe(e.attrs.class??""))});let o=e.attrs[":text"],a=e.attrs[":html"];o!==void 0?n.push({kind:"textContent",path:t,expr:o}):a!==void 0?n.push({kind:"html",path:t,expr:a}):e.children.forEach((h,w)=>{if(typeof h=="string"){h.includes("{{")?(n.push({kind:"text",path:[...t,w],parts:Tt(h)}),s.appendChild(document.createTextNode(""))):s.appendChild(document.createTextNode(h));return}s.appendChild($s(h,[...t,w],n))});let l=e.attrs[":value"];l!==void 0&&n.push({kind:"value",path:t,expr:l});let f=e.attrs[":checked"];f!==void 0&&n.push({kind:"checked",path:t,expr:f});let u=e.attrs[":selected"];return u!==void 0&&n.push({kind:"selected",path:t,expr:u}),s},$o=3,Rs=e=>e.attrs[":text"]!==void 0||e.attrs[":html"]!==void 0?1:1+e.children.reduce((t,n)=>t+(typeof n=="string"?0:Rs(n)),0),Un=new WeakMap,Bn=new WeakSet,Ro=e=>{let t=Un.get(e);if(t!==void 0)return t;if(!Bn.has(e))return Bn.add(e),null;let n=null;if(Ts(e)&&Rs(e)>=$o){let s=[];n={skeleton:$s(e,[],s),ops:s}}return Un.set(e,n),n},xo=(e,t)=>{let n=e;for(let s=0;s<t.length;s++)n=n.childNodes[t[s]];return n},No=(e,t,n)=>{let s=e.skeleton.cloneNode(!0);for(let r of e.ops){let i=r.path.length===0?s:xo(s,r.path);if(r.kind==="text"){let o=i,a=r.parts;n.effect(()=>{let l=hs(a,t);o.textContent!==l&&(o.textContent=l)})}else if(r.kind==="event")gs(i,r.attr,r.expr,t);else if(r.kind==="attr"){let o=i,{name:a,expr:l}=r;n.effect(()=>bs(o,a,_(l,t)))}else if(r.kind==="class"){let o=i,{classExpr:a,toggles:l,staticClasses:f}=r,u=[];n.effect(()=>{let h=a!==void 0?pe(_(a,t)):[];l?.forEach(([w,O])=>{_(O,t)&&h.push(...pe(w))}),u.forEach(w=>{!h.includes(w)&&!f.has(w)&&o.classList.remove(w)}),o.classList.add(...h),u=h})}else if(r.kind==="textContent"){let o=i,{expr:a}=r;n.effect(()=>{let l=String(_(a,t)??"");o.textContent!==l&&(o.textContent=l)})}else if(r.kind==="html"){let o=i,{expr:a}=r;n.effect(()=>{o.innerHTML=lt(String(_(a,t)??""))})}else if(r.kind==="value"){let o=i,{expr:a}=r;n.effect(()=>{let l=String(_(a,t)??"");o.value!==l&&(o.value=l)})}else if(r.kind==="checked"){let o=i,{expr:a}=r;n.effect(()=>{let l=!!_(a,t);o.checked!==l&&(o.checked=l)})}else if(r.kind==="selected"){let o=i,{expr:a}=r;n.effect(()=>{let l=!!_(a,t);o.selected!==l&&(o.selected=l)})}else{let o=r}}return s},Gt=(e,t,n,s)=>{let r=e.attrs[":with"],i=r!==void 0?mo(r,t):t;if(Ze(e.tag))return po(e,i,n,s);if(e.tag==="template"&&Le(e)!==void 0)return co(e);let o=Dn(e,i);if(o)return Wn(o,e,i,n,s);if(le.cloneSkeletons){let b=Ro(e);if(b)return No(b,i,n)}let a=ws(e);if(e.component!==void 0&&i[rt]?.count===0)throw ro(e.component,i);let l=e.ns===void 0&&(e.component!==void 0||e.tag.includes("-"));if(l){let b=!1;n.effect(()=>{if(b)return;let H=Dn(e,i);if(!H)return;b=!0;let D=Wn(H,e,i,n,s),L=zt(D);n.onDispose(()=>it(L)),a.replaceWith(D)})}for(let b in e.attrs){let H=e.attrs[b];if(b.startsWith("@"))gs(a,b,H,i);else if(b===":model"||b.startsWith(":model."))l||console.warn(`jq79: ${b} on <${X(e)}> does nothing - :model binds component tags only (for now)`);else if(!ye(b))if(b.startsWith(":"))if(l)a.setAttribute(b,H);else{let D=b.slice(1),L=H||ie(D),B=Ss(a,D);n.effect(()=>bs(a,B,_(L,i)))}else a.setAttribute(b,H)}let f=e.attrs[":class"],u=null;for(let b in e.attrs)b.startsWith(":class.")&&(u??(u=[])).push([b.slice(7),e.attrs[b]]);if(f!==void 0||u){let b=new Set(pe(e.attrs.class??"")),H=[];n.effect(()=>{let D=f!==void 0?pe(_(f,i)):[];u?.forEach(([L,B])=>{_(B,i)&&D.push(...pe(L))}),H.forEach(L=>{!D.includes(L)&&!b.has(L)&&a.classList.remove(L)}),a.classList.add(...D),H=D})}let h=e.attrs[":text"],w=e.attrs[":html"],O=e.attrs[":html.allowed"];O!==void 0&&w===void 0&&console.warn("jq79: :html.allowed without :html on the same element does nothing"),h!==void 0?n.effect(()=>{let b=String(_(h,i)??"");a.textContent!==b&&(a.textContent=b)}):w!==void 0?n.effect(()=>{let b=O!==void 0?{allowUrl:yo(_(O,i))}:void 0;a.innerHTML=lt(String(_(w,i)??""),b)}):a instanceof HTMLTemplateElement?be(e.children,i,n,s,a.content):be(e.children,i,n,s,a);let I=e.attrs[":value"];I!==void 0&&n.effect(()=>{let b=String(_(I,i)??"");a.value!==b&&(a.value=b)});let G=e.attrs[":checked"];G!==void 0&&n.effect(()=>{let b=!!_(G,i);a.checked!==b&&(a.checked=b)});let j=e.attrs[":selected"];return j!==void 0&&n.effect(()=>{let b=!!_(j,i);a.selected!==b&&(a.selected=b)}),a},vo=(e,t,n,s)=>{let r=document.createComment("if"),i=document.createDocumentFragment();i.appendChild(r);let o=null,a=null,l=null;return n.effect(()=>{let f=e.find(h=>h.expr===void 0||_(h.expr,t))??null;if(f===a||(l?.dispose(),o&&it(o),o=null,a=f,!f))return;l=me(t);let u=Gt(f.node,t,l,s);o=zt(u),r.parentNode.insertBefore(u,r.nextSibling)}),n.onDispose(()=>l?.dispose()),i},Ne=(e,t,n)=>{Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})},Po=e=>{let t=new Uint8Array(e.length),n=[],s=new Int32Array(e.length).fill(-1);for(let r=0;r<e.length;r++){let i=e[r];if(i<0)continue;let o=0,a=n.length;for(;o<a;){let l=o+a>>1;e[n[l]]<i?o=l+1:a=l}o>0&&(s[r]=n[o-1]),n[o]=r}for(let r=n.length?n[n.length-1]:-1;r!==-1;r=s[r])t[r]=1;return t},Co=e=>{if(e===null||typeof e!="object"||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null},xs=(e,t)=>typeof e=="string"?t.some(n=>zn(e,n)):Object.values(e.attrs).some(n=>t.some(s=>zn(n,s)))||e.children.some(n=>xs(n,t)),Ns=e=>typeof e!="string"&&(":if"in e.attrs||":elseif"in e.attrs||":else"in e.attrs||":each"in e.attrs||e.component!==void 0||e.tag.includes("-")||Ze(e.tag)||e.children.some(Ns)),Kn=/[A-Za-z0-9_$]/,Mo=/^[A-Za-z_$][\w$]*\.[A-Za-z_$][\w$]*$/,zn=(e,t)=>{for(let n=e.indexOf(t);n!==-1;n=e.indexOf(t,n+1)){let s=n===0?"":e[n-1],r=e[n+t.length]??"";if(!Kn.test(s)&&!Kn.test(r))return!0}return!1},Mt=new WeakMap,ko=e=>{let t=Mt.get(e);if(t!==void 0)return t;let n=e.attrs[":each"].match(Tn);if(!n)return Mt.set(e,null),null;let[,s,r,i]=n,o=e.attrs[":key"],a=o===s,l=o!==void 0&&!a&&Mo.test(o)&&o.startsWith(`${s}.`)?o.slice(s.length+1):void 0,{[":each"]:f,[":key"]:u,...h}=e.attrs,w={...e,attrs:h},O=["$index",...r?[r]:[]],I=xs(w,O),G=/^[A-Z]/.test(s)||r!==void 0&&/^[A-Z]/.test(r),j=o!==void 0&&Ns(w),b={itemName:s,atName:r,listExpr:i,keyExpr:o,keyIsItem:a,keyProp:l,itemNode:w,readsPosition:I,namesComponent:G,nestsScopes:j};return Mt.set(e,b),b},Ao=(e,t,n,s)=>{let r=ko(e);if(!r)return document.createComment(`invalid :each expression "${e.attrs[":each"]}"`);let{itemName:i,atName:o,listExpr:a,keyExpr:l,keyIsItem:f,keyProp:u,itemNode:h,readsPosition:w,namesComponent:O,nestsScopes:I}=r,G=document.createComment("each"),j=document.createDocumentFragment();j.appendChild(G),(":if"in e.attrs||":elseif"in e.attrs||":else"in e.attrs)&&console.warn("jq79: :if/:elseif/:else on a :each element is ignored; filter the list expression instead");let b=[],H=!1;return n.effect(()=>{let D=to(t);try{let L=_(a,t),B=Array.isArray(L),ae=B?null:Co(L)?Object.keys(L):[],v=B?L.length:ae.length,P=new Map;b.forEach(($,q)=>{$.pos=q;let K=P.get($.key);K?K.push($):P.set($.key,[$])});let x=new Set,W=[],J=[],V=[],E=[],C;for(let $=0;$<v;$++){let q=B?$:ae[$],K=B?L[$]:L[q],c=q;f?c=K:u!==void 0&&K!==null&&typeof K=="object"?c=K[u]:l!==void 0&&(C===void 0?(C=Object.create(t),Ne(C,i,K),o&&Ne(C,o,q),Ne(C,"$index",$)):(C[i]=K,o&&(C[o]=q),C.$index=$),c=_(l,C)),x.has(c)&&!H&&(H=!0,console.warn(`jq79: duplicate :key in :each "${e.attrs[":each"]}"; duplicates pair up by position`)),x.add(c);let d=P.get(c)?.shift();if(d&&Object.is(d.item,K)){let m=d.scope;m.$index!==$&&(w&&W.push(d),m.$index=$),o&&m[o]!==q&&(m[o]=q),V.push(d),E.push(d.pos);continue}if(d&&l!==void 0){let m=d.scope;m[i]=K,m.$index!==$&&(m.$index=$),o&&m[o]!==q&&(m[o]=q),d.item=K,J.push(d),V.push(d),E.push(d.pos);continue}d&&(d.fx.dispose(),it(d.range));let g=Object.create(t);Ne(g,i,K),o&&Ne(g,o,q),Ne(g,"$index",$),O||ms.add(g);let p=me(t);I&&Object.defineProperty(g,ht,{value:p});let S=zt(Gt(h,g,p,s));V.push({key:c,item:K,scope:g,fx:p,range:S,pos:$}),E.push(-1)}let M=new Set;P.forEach($=>$.forEach(q=>M.add(q))),M.size&&(M.forEach($=>{$.dead=!0,$.fx.dispose()}),Yr(Jr(b,$=>$.dead===!0)));let U=G,Q=Po(E);V.forEach(($,q)=>{!Q[q]&&U.nextSibling!==$.range.first&&eo($.range,U),U=$.range.last}),W.forEach($=>Re(()=>$.fx.refresh())),J.forEach($=>Re(()=>$.fx.rerun())),b=V}finally{no(D)}}),n.onDispose(()=>b.forEach(D=>D.fx.dispose())),j},vs=(e,t)=>{let n=t;for(;n<e.length&&typeof e[n]=="string"&&!e[n].trim();)n++;return n},kt=e=>{let t=":if"in e.attrs,n=":elseif"in e.attrs,s=":else"in e.attrs;if((t?1:0)+(n?1:0)+(s?1:0)<2)return;let r=[t?":if":null,n?":elseif":null,s?":else":null].filter(Boolean);console.warn(`jq79: ${r.join(" and ")} on the same <${X(e)}> - only ${r[0]} applies; the branches of a chain are sibling elements, one directive each`)},Oo=(e,t)=>{let n=":elseif"in e.attrs?":elseif":":else";console.warn(t?`jq79: a second ${n} on <${X(e)}> - the chain before it already ended with :else, which closes it. One :if, any number of :elseif, at most one :else`:`jq79: ${n} on <${X(e)}> continues no :if - it renders unconditionally. A chain is :if, then :elseif, then :else, on adjacent siblings: anything but whitespace between them breaks it`)},_o=[":if",":elseif",":else",":each"],jo=(e,t)=>{if(e.tag!=="template"||e.ns!==void 0)return;let n=_o.find(s=>s in e.attrs);if(n!==void 0){if(Le(e)!==void 0){if(t?.component===void 0)return;console.warn(`jq79: ${n} on <template ${Le(e)}> is ignored - a slot is filled with its children as written. Put ${n} on the elements inside it, or on the component's tag`);return}console.warn(`jq79: ${n} on a nested <template> shows nothing - a <template>'s children live in its .content and never reach the page. Put ${n} on the elements themselves`)}},Lo=[...$t,":model",":slot"].map(e=>e.slice(1)),Do={":attrs":':attrs was removed in 0.7 - it now binds an attribute called "attrs". Bind them one at a time (:disabled="x", :title="y"), or :class for classes'},Io=e=>{for(let t in e.attrs){let n=Do[t];n!==void 0&&console.warn(`jq79: ${n}`)}},qo=e=>{if(!(e.component!==void 0||e.tag.includes("-")))for(let t in e.attrs){if(!t.startsWith(":")||ye(t)||t===":model"||t.startsWith(":model."))continue;let n=t.slice(1);if(n.includes(".")){console.warn(`jq79: ${t} is not a directive - it bound an attribute named "${n}". Dotted modifiers belong to an event: if you meant @${n}, that is the spelling`);continue}let s=Lo.find(r=>n!==r&&n.startsWith(r));s!==void 0&&console.warn(`jq79: ${t} is not a directive - it bound an attribute named "${n}". A ":name" jq79 does not recognize binds that attribute (which is what :src and :disabled are). If you meant :${s}, that is the spelling`)}},Ps=(e,t)=>{e.forEach(s=>{typeof s!="string"&&(jo(s,t),Io(s),qo(s),Ps(s.children,s))});let n=!1;for(let s=0;s<e.length;){let r=e[s];if(typeof r=="string"){r.trim()&&(n=!1),s++;continue}if(":each"in r.attrs){n=!1,s++;continue}if(kt(r),":if"in r.attrs){s++;let i=a=>{let l=vs(e,s),f=e[l];if(typeof f=="object"&&a in f.attrs)return s=l+1,f};for(let a=i(":elseif");a;a=i(":elseif"))kt(a);let o=i(":else");o&&kt(o),n=o!==void 0;continue}(":elseif"in r.attrs||":else"in r.attrs)&&Oo(r,n),n=!1,s++}},Gn=new WeakMap,Ho=(e,t,n)=>{let s=Gn.get(t);if(s)return s;let r=[{expr:t.attrs[":if"],node:t}],i=n+1,o=f=>{let u=vs(e,i),h=e[u];if(typeof h=="object"&&f in h.attrs)return i=u+1,h};for(let f=o(":elseif");f;f=o(":elseif"))r.push({expr:f.attrs[":elseif"],node:f});let a=o(":else");a&&r.push({node:a});let l={branches:r,next:i};return Gn.set(t,l),l},be=(e,t,n,s=!1,r)=>{let i=r??document.createDocumentFragment(),o=0;for(;o<e.length;){let a=e[o];if(typeof a=="string"){let l=document.createTextNode(a);if(a.includes("{{")){let f=Tt(a);n.effect(()=>{let u=hs(f,t);l.textContent!==u&&(l.textContent=u)})}i.appendChild(l),o++;continue}if(":each"in a.attrs){i.appendChild(Ao(a,t,n,s)),o++;continue}if(":if"in a.attrs){let l=Ho(e,a,o);i.appendChild(vo(l.branches,t,n,s)),o=l.next;continue}i.appendChild(Gt(a,t,n,s)),o++}return i},Wo=(e,t,n=!1)=>be(e.template,t,me(t),n),Ce="data-jq79",Fo=e=>{let t=2166136261;for(let n=0;n<e.length;n++)t=Math.imul(t^e.charCodeAt(n),16777619);return(t>>>0).toString(36)},Cs=(e,t)=>{e.forEach(n=>{typeof n!="string"&&(n.attrs[Ce]=t,Cs(n.children,t))})},Uo=(e,t)=>e.split(",").map(n=>{let s=n.trim(),r=s.indexOf("::"),i=r===-1?s:s.slice(0,r),o=r===-1?"":s.slice(r);return`${i}[${Ce}="${t}"]${o}`}).join(", "),Ms=(e,t)=>{Array.from(e).forEach(n=>{n instanceof CSSStyleRule?n.selectorText=Uo(n.selectorText,t):n instanceof CSSGroupingRule&&Ms(n.cssRules,t)})},Bo=/(^|[\s>+~,(])([A-Z][A-Za-z0-9]*)(?![\w-])/g,Ko=/[a-z]/,zo=e=>e.replace(Bo,(t,n,s)=>Ko.test(s)?`${n}${_e(s)}`:t),Go=/^\s*@(media|supports|container|layer|scope|document)\b/i,Vo=/^\s*@/,Zo=e=>{let t="",n="",s="",r=[],i=()=>r.length===0||r[r.length-1],o=()=>{t+=i()&&!Vo.test(s)?zo(n):n,n=""},a=f=>{o(),t+=f,s+=f},l=(f,u)=>{o(),t+=f,s="",u!==void 0?r.push(u):f==="}"&&r.pop()};for(let f=0;f<e.length;){let u=e[f];if(u==="/"&&e[f+1]==="*"){let h=e.indexOf("*/",f+2),w=h===-1?e.length:h+2;a(e.slice(f,w)),f=w}else if(u==='"'||u==="'"){let h=f+1;for(;h<e.length&&e[h]!==u;)h+=e[h]==="\\"?2:1;a(e.slice(f,Math.min(h+1,e.length))),f=h+1}else u==="{"?(l("{",Go.test(s)),f++):u==="}"||u===";"?(l(u),f++):(n+=u,s+=u,f++)}return o(),t},Qo=(e,t)=>{/:deep\(|::v-deep|>>>/.test(e)&&console.warn("jq79: :deep()/::v-deep/>>> are not supported in <style scoped>; the rule will be dropped by the browser");let n=new CSSStyleSheet;return n.replaceSync(e),Ms(n.cssRules,t),Array.from(n.cssRules).map(s=>s.cssText).join(`
18
18
  `)},It=e=>{let t=Sn(e),s=new DOMParser().parseFromString(`<template>${t}</template>`,"text/html").querySelector("template"),r=[],i=[];Array.from(s.content.children).forEach(l=>{l.tagName==="TEMPLATE"?i.push(l):r.push(l)});let o=Vn(r,e),a={};return i.forEach(l=>{let f=l.getAttribute("name");if(f===null){console.warn("jq79: a top-level <template> without a name declares nothing and was ignored");return}if(!bn.test(f)){console.warn(`jq79: <template name="${f}"> was ignored - a component name has to be PascalCase, or no tag could ever reference it (only capitalized names resolve as components)`);return}if(f in a){console.warn(`jq79: two <template name="${f}"> in one file; the second was ignored`);return}a[f]=new de({...Vn(Array.from(l.content.children),l.innerHTML),siblings:a,name:f})}),Object.keys(a).length&&(o.siblings=a),o},Xo=/^(?:text|application)\/(?:x-)?typescript$/i,Yo=e=>"lang"in e?`lang="${e.lang}"`:Xo.test(e.type?.trim()??"")?`type="${e.type}"`:null,Vn=(e,t)=>{let n=[],s=[],r=[];e.forEach(o=>{let a={attrs:ns(o),content:o.textContent??""};o.tagName==="SCRIPT"?n.push(a):o.tagName==="STYLE"?s.push(a):r.push(rs(o))}),n.forEach(o=>{let a=Yo(o.attrs);a&&console.warn(`jq79: <script ${a}> needs the jq79/vite plugin to compile it. This component didn't go through the bundler, so its types were never stripped: the script will throw, or - for a plain \`let x: T = ...\` - silently fail to declare x.`)}),s.forEach(o=>{"lang"in o.attrs&&console.warn(`jq79: <style lang="${o.attrs.lang}"> needs the jq79/vite plugin to compile it. This component didn't go through the bundler, so its styles were left uncompiled and the browser will ignore them.`)}),s.forEach(o=>{"lang"in o.attrs||(o.content=Zo(o.content))});let i=o=>"scoped"in o.attrs&&!("lang"in o.attrs);if(s.some(i)){let o=Fo(t);Cs(r,o),s.forEach(a=>{i(a)&&(a.scoped=Qo(a.content,o))})}return Ps(r),{template:r,scripts:n,styles:s}},Vt=e=>/\.html?([?#]|$)/.test(e)?Ft(e):import(e),ks=/^(?:\.\.?\/|\/|[a-z][a-z0-9+.-]*:)/i,Jo=(e,t)=>{if(!ks.test(e))return e;try{return new URL(e,new URL(t??"",document.baseURI)).href}catch{return e}},ei=(e,t)=>e?`
19
19
  //# sourceURL=${e}?jq79-script=${t}`:"",As=(e,t,n)=>{try{return Bt(e,t,ei(n.filename,n.index??0))}catch(s){throw s instanceof Pe?new Error(`jq79: safeEval() is on, and script ${n.index??0} of ${n.filename??"a component built from a string"} ${s.reason}. ${s.hint}`):s}},Zn=e=>e.scoped??e.content,je=`:where([${Es}]) { display: contents }`,Zt=()=>Ut&&typeof Document<"u"&&"adoptedStyleSheets"in Document.prototype,nt=e=>{let t=new CSSStyleSheet;return t.replaceSync(e),t},Qt=(e,t)=>{e.adoptedStyleSheets.includes(t)||(e.adoptedStyleSheets=[...e.adoptedStyleSheets,t])},qt=(e,t)=>{e.adoptedStyleSheets=e.adoptedStyleSheets.filter(n=>n!==t)},Xe=null,Ht=null,ti=()=>{if(Zt()){Qt(document,Ht??(Ht=nt(je)));return}Xe?.isConnected||(Xe=document.createElement("style"),Xe.textContent=je,document.head.appendChild(Xe))},st=new Map,ni=e=>{let t=st.get(e);if(!t){if(Zt()){let n=nt(e);Qt(document,n),t={sheet:n,count:0}}else{let n=document.createElement("style");n.textContent=e,document.head.appendChild(n),t={el:n,count:0}}st.set(e,t)}t.count++},si=e=>{let t=st.get(e);t&&--t.count<=0&&(t.sheet?qt(document,t.sheet):t.el?.remove(),st.delete(e))},ri=(e,t,n,s={},r=Vt,i={})=>{let o={...Ds,...s},a=new Proxy(t,{has:(u,h)=>h!=="$__effect"&&h!=="$__import"&&h!=="$__state"&&(Reflect.has(u,h)||!(h in globalThis)&&!(h in o))}),l={},f=As(xn(Object.keys(o)),Nn(e),i)(a,n,r,l,...Object.values(o));return f.catch(u=>console.error("jq79: error in :setup script",u)),ds(f),{settled:f,sync:l.done===!0}},Qn=(e,t)=>{t?.forEach(({name:n,default:s})=>{e[n]===void 0&&(e[n]=s===void 0?void 0:_(s,e))})},Wt=e=>{let t=Cn(e);return!t&&e.attrs[":setup"]!==void 0&&oi(e,e.attrs[":setup"]),t},Xn=new WeakSet,oi=(e,t)=>{t.trim()==="_"||Xn.has(e)||(Xn.add(e),console.warn(`jq79: :setup="${t}" is not a props pattern, so this component declares no signature and takes whatever a parent passes - write the props it takes ("{ a, b }"), a bare :setup for none, or "_" to stay open on purpose`))},ii=e=>{let t=null;return e.forEach(n=>{let s=Ae(n.content)??Wt(n);if(!s)return;let r=t??(t=new Set);s.forEach(({name:i})=>r.add(i))}),t},Yn=(e,t)=>{if(t===null)return e;let n={};return Object.keys(e).forEach(s=>{t.has(s)&&(n[s]=e[s])}),n},Jn=new WeakMap,ai=(e,t,n,s)=>{if(s===null)return;let r=Jn.get(e)??new Set;Jn.set(e,r),n.forEach(i=>{s.has(i)||r.has(i)||(r.add(i),console.warn(`jq79: :${i} is not declared by <${t}> - add it to the :setup signature, or drop it`))})},li=(e,t)=>{if(!e)return null;let n=Object.create(null),s=!1;return Object.entries(e).forEach(([r,i])=>{t.has(r)||(n[r]=i,s=!0)}),s?n:null},Os=Symbol("jq79.unfilledProps"),rt=Symbol("jq79.pendingScripts"),ci=e=>e&&e.default!==void 0?e.default:e,di=(e,t,n,s={},r=Vt,i={})=>{let o={...Ds,...s},a={},l=As(vn(Object.keys(o)),Pn(e),i)(a,ci,r,...Object.values(o)),f=I=>console.error("jq79: error in factory script",I),u=!1,h,w=()=>{if(u)return h;u=!0;let I=a.default;if(typeof I!="function")return;let G=j=>{j&&typeof j=="object"&&Object.assign(t,j)};try{let j=I(t,{$data:t,$props:t,$effect:n,...s});j instanceof Promise?h=j.then(G).catch(f):G(j)}catch(j){f(j)}return h},O=l.then(w,f);return ds(O),a.done&&w(),{settled:O,sync:a.done===!0&&h===void 0}},ui="__JQ79_HMR_ENABLED__",fi="__JQ79_HMR__",Se=null,pi=e=>{if(!Se||!e.filename)return;let t=Se.get(e.filename);t||Se.set(e.filename,t=new Set),t.add(new WeakRef(e))},At=e=>{try{return new URL(e,document.baseURI).pathname}catch{return e}},_s=(e,t)=>{if(!Se)return 0;let n=At(e),s=It(t);ne?.forEach((a,l)=>{At(l)===n&&ne.set(l,Promise.resolve(t))});let r=!1,i=a=>a.name===void 0?s:s.siblings?.[a.name]??null,o=0;for(let[a,l]of Se)if(At(a)===n){for(let f of l){let u=f.deref();if(!u){l.delete(f);continue}let h=i(u);if(!h){r=!0;continue}u.hotReplace(h)&&o++}l.size||Se.delete(a)}return r?0:o},js=()=>{Se??(Se=new Map),globalThis[fi]={update:_s}},es=3e3,hi=(e,t)=>{let n=setTimeout(()=>{console.warn(`jq79: ${e.name?`<${e.name}>`:"a component"}${e.filename?` (${e.filename})`:""} has been waiting ${es/1e3}s for a :setup script and has rendered nothing. The template waits until every script returns or calls $mounted() - add an await $mounted() above the slow part to render first and fill in after.`)},es);n?.unref?.(),Promise.all(t).then(()=>clearTimeout(n))},gi=e=>{if(ks.test(e))return e;let t=$i.resolve;if(typeof t!="function")return e;try{return t(e)}catch{return e}},ne=new Map,mi=e=>{try{return new URL(e,document.baseURI).href.replace(/#.*$/,"")}catch{return e}},ts=e=>Promise.all([fetch(e).then(t=>{if(!t.ok)throw new Error(`failed to fetch component from ${e}: ${t.status}`);return t.text()}),Ls?.then(()=>Si(e))]).then(([t])=>t),yi=e=>{if(!ne)return ts(e);let t=mi(e),n=ne.get(t);if(!n){n=ts(e),ne.set(t,n);let s=n;s.catch(()=>{ne?.get(t)===s&&ne.delete(t)})}return n},Ft=async e=>{let t=gi(e),n=await yi(t);return new de(n,{filename:t})},Ls,Ei="/jq79-sw.js",wi=async e=>{let t=typeof navigator>"u"?void 0:navigator.serviceWorker;if(!t)throw new Error("jq79: safeEval() compiles components in a service worker, and this page can't have one - service workers need https (or localhost). Precompile with the jq79/vite plugin instead, or use safeEval({ nonce: true }) on a page whose server issues a nonce.");let n;try{n=await t.register(e)}catch(s){throw new Error(`jq79: safeEval() couldn't register its service worker at ${e} (${s.message}). Serve jq79-sw.js from the jq79 package at your site's root, or pass its URL: safeEval({ worker: "/path/jq79-sw.js" }).`)}await t.ready,!t.controller&&await new Promise(s=>{t.addEventListener("controllerchange",()=>s(),{once:!0}),t.controller?s():n.active?.postMessage("jq79:claim")})},Si=e=>{let t=new URL(e,document.baseURI);return t.hash="",t.searchParams.set(An,""),new Promise((n,s)=>{let r=document.createElement("script"),i=os();i&&r.setAttribute("nonce",i),r.src=t.href,r.onload=()=>{r.remove(),n()},r.onerror=()=>{r.remove(),s(new Error(`jq79: the precompiled functions of ${e} did not load, and safeEval() can't render it without them`))},document.head.append(r)})},ce=class ce{constructor(t,n={}){k(this,"template");k(this,"scripts");k(this,"styles");k(this,"modules");k(this,"filename");k(this,"siblings");k(this,"name");k(this,"slots");k(this,"modelWriteback");k(this,"data",null);k(this,"fx",null);k(this,"content",null);k(this,"startMarker",null);k(this,"endMarker",null);k(this,"styleEls",[]);k(this,"shadowCss",null);k(this,"shadowSheets",[]);k(this,"sheetRoot",null);k(this,"ownsSharedStyles",!1);k(this,"useShadow",!1);k(this,"mountRoot",null);k(this,"resolveMounted",null);k(this,"renderDone",!1);k(this,"held",0);k(this,"onPaint",null);k(this,"destroyHooks",null);k(this,"attachHooks",null);k(this,"detachHooks",null);k(this,"onPage",!1);k(this,"emitListeners",new Map);let s=typeof t=="string"?It(t):t;this.template=s.template,this.scripts=s.scripts,this.styles=s.styles,this.modules=n.modules??(typeof t=="string"?void 0:t.modules),this.filename=n.filename??(typeof t=="string"?void 0:t.filename),this.siblings=s.siblings,this.name=s.name,this.adoptSiblings(),pi(this)}adoptSiblings(){this.siblings&&Object.entries(this.siblings).forEach(([t,n])=>{n.filename??(n.filename=this.filename),n.modules??(n.modules=this.modules),this.name||(this[t]=n)})}hotReplace(t){let n=typeof t=="string"?It(t):t;Kt.clear(),we.clear(),Dt.clear();let s=this.startMarker,r=!!(s&&this.content),i=r&&s.isConnected,o=i?s.parentNode:null,a=i?this.endMarker.nextSibling:null,l={...this.data},f=this.useShadow;return r&&this.destroy(),this.template=n.template,this.scripts=n.scripts,this.styles=n.styles,this.siblings=n.siblings,this.adoptSiblings(),!r||(this.renderWith(l,f),!o)?!1:(f&&this.placeShadowStyles(o,a),o.insertBefore(this.content,a),this.mountRoot=o,this.settleMounted(),!0)}static debug(t){if(t){let n=le.scopedNames;for(let s in t){let r=t[s];Object.prototype.hasOwnProperty.call(le,s)?typeof r=="boolean"?le[s]=r:console.warn(`jq79: Component79.debug ignored "${s}" - the flags are booleans, and the ones it knows are: ${Object.keys(le).join(", ")}`):console.warn(`jq79: Component79.debug does not know "${s}" - the flags it has are: ${Object.keys(le).join(", ")}`)}le.scopedNames!==n&&Je.clear()}return{...le}}static safeEval(t={}){Ut=!0;let n=[];if(t.nonce){let r=os();r===void 0?n.push(Promise.reject(new Error("jq79: safeEval({ nonce: true }) found no nonce on this page - no <script> carries one. The nonce belongs on the script that loads the page, the one the CSP names."))):jt=r}let s=t.worker??(t.nonce?!1:Ei);return s!==!1&&n.push(Ls??(Ls=wi(s))),Promise.all(n).then(()=>{})}static cache(t){return t===!1?ne=null:t===!0&&(ne??(ne=new Map)),!!ne}static clearCache(){ne?.clear()}static fetch(t){if(Array.isArray(t))throw new TypeError("Component79.fetch takes one URL; use fetchAll for an array");return new ot(Ft(t))}static fetchAll(t){return Promise.all(t.map(Ft))}on(t,n){return this.emitListeners.has(t)||this.emitListeners.set(t,new Set),this.emitListeners.get(t).add(n),this}off(t,n){return this.emitListeners.get(t)?.delete(n),this}render(t={}){return this.renderWith(t,!1)}renderShadow(t={}){return this.renderWith(t,!0)}renderWith(t,n){this.destroy();let s=Mn(this.scripts,Wt),r=li(this.siblings,s),i=r?Object.assign(Object.create(r),t):{...t},o=new Set([...s].filter(E=>!(E in t)));o.size&&Object.defineProperty(i,Os,{value:o}),this.slots&&Object.defineProperty(i,ys,{value:this.slots}),Object.defineProperty(i,rt,{value:{count:0,owner:this}});let a=xe(i),l=me(a);this.data=a,this.fx=l,this.useShadow=n,this.startMarker=document.createComment("jq79"),this.endMarker=document.createComment("/jq79");let f=this.startMarker,u=!1,h=(E,C)=>{E==="model:update"&&!u&&(u=!0,console.warn("jq79: $emit('model:update', \u2026) no longer feeds :model - call $updateModel(value) or $updateModel(name, value) instead"));let M=new CustomEvent(E,{detail:C,bubbles:!0,composed:!0,cancelable:!0});return f===this.startMarker&&this.emitListeners.get(E)?.forEach(U=>U(M,C)),M.cancelBubble||f.dispatchEvent(M),!M.defaultPrevented},w,O=new Promise(E=>{w=E});this.resolveMounted=w,this.renderDone=!1,this.held=0;let I=E=>{if(typeof E!="function")throw new TypeError("jq79: $destroyed expects a function");return f!==this.startMarker?(ve(E,"$destroyed"),()=>{}):Ot(this.destroyHooks??(this.destroyHooks=[]),E)},G=(E,{immediate:C=!0}={})=>{if(typeof E!="function")throw new TypeError("jq79: $attached expects a function");if(f!==this.startMarker)return()=>{};this.watchPage();let M=Ot(this.attachHooks??(this.attachHooks=[]),E);return C&&this.onPage&&ve(E,"$attached"),M},j=E=>{if(typeof E!="function")throw new TypeError("jq79: $detached expects a function");return f!==this.startMarker?(ve(E,"$detached"),()=>{}):(this.watchPage(),Ot(this.detachHooks??(this.detachHooks=[]),E))},b=E=>{let C=Fe(E);return I(()=>C.$dispose()),C},H=this.endMarker,D=(E=>{let C=[];for(let M=f.nextSibling;M&&M!==H;M=M.nextSibling)M instanceof Element&&(M.matches(E)&&C.push(M),C.push(...Array.from(M.querySelectorAll(E))));return C}),L=(E=>D(E)[0]??null),B=this.modules,ae=E=>B&&E in B?Promise.resolve(B[E]):Vt(Jo(E,this.filename)),P=Object.assign(Object.create(null),{$emit:h,$updateModel:(...E)=>{let[C,M]=E.length>1?E:[void 0,E[0]];return f!==this.startMarker?!1:this.modelWriteback?.(C,M)??!1},$slots:Object.fromEntries(Object.keys(this.slots??{}).map(E=>[E,!0]))}),x=[],W=!0;this.scripts.forEach((E,C)=>{let M;x.push(new Promise(p=>{M=p}));let U=!1,Q=()=>{U=!0,M()},q={$mounted:()=>(Q(),O),$destroyed:I,$attached:G,$detached:j,$computed:b,$self:L,$$self:D,...P,...r},K={filename:this.filename,index:C},c=":mounted"in E.attrs,d=mn(E.content),g=(()=>{if(d!==null){c&&console.warn("jq79: :mounted on a factory script renders the template before the factory has returned, so none of its bindings exist yet - await $mounted() inside the factory instead."),Qn(a,Ae(E.content));let y=c?vt(d):d;return di(y,a,R=>l.effect(R),q,ae,K)}let{vars:p,code:S}=Ge(E.content);Qn(a,Wt(E)),p.forEach(y=>{y in a||(a[y]=void 0)});let m=c?vt(S):S;return ri(m,a,y=>l.effect(y),q,ae,K)})();if(g.sync)g.settled.then(Q,Q);else{let p=i[rt];p.count++;let S=()=>{p.count--,Q()};g.settled.then(S,S)}!g.sync&&!U&&(W=!1)});let J=document.createDocumentFragment(),V=new Proxy(a,{has:(E,C)=>typeof C=="string"&&C in P||Reflect.has(E,C),get:(E,C,M)=>typeof C=="string"&&C in P&&!Reflect.has(E,C)?P[C]:Reflect.get(E,C,M)});if(J.append(this.startMarker,this.endMarker),this.content=J,W?(this.endMarker.parentNode.insertBefore(be(this.template,V,l,n),this.endMarker),this.renderDone=!0,this.settleMounted()):(Promise.all(x).then(()=>{f===this.startMarker&&(this.endMarker.parentNode.insertBefore(be(this.template,V,l,n),this.endMarker),this.renderDone=!0,this.settleMounted(),ce.settleAttached())}),hi(this,x)),n)if(Zt())this.shadowCss=[...this.styles.map(E=>E.content),je];else{let E=document.createElement("style");E.textContent=je,this.styleEls=[...this.styles.map(C=>{let M=document.createElement("style");return M.textContent=C.content,M}),E]}else this.styles.forEach(E=>ni(Zn(E))),this.ownsSharedStyles=!0;return this}mount(t,n){let s=typeof t=="string"?Te(t):t;if(!s)throw new Error(`mount target not found: ${t}`);return(!this.content||n!==void 0)&&this.renderWith(n??{},this.useShadow),this.attach(s)}mountShadow(t,n){let s=typeof t=="string"?Te(t):t;if(!s)throw new Error(`mount target not found: ${t}`);return(!this.content||n!==void 0||!this.useShadow)&&this.renderWith(n??{},!0),this.attach(s)}attach(t){this.mountRoot&&this.detach();let n=this.useShadow&&t instanceof Element?t.shadowRoot??t.attachShadow({mode:"open"}):t;return this.useShadow&&this.placeShadowStyles(n,null),n.appendChild(this.content),this.mountRoot=n,this.settleMounted(),ce.settleAttached(),this}isOnPage(){return this.renderDone&&this.startMarker?.isConnected===!0}watchPage(){fe.has(this)||(fe.add(this),this.onPage=this.isOnPage(),this.onPage||ce.queueSettle())}static queueSettle(){_t||(_t=!0,queueMicrotask(()=>{_t=!1,ce.settleAttached()}))}static settleAttached(){if(fe.size===0)return;let t=[...fe].filter(n=>!n.onPage&&n.isOnPage());ce.inDocumentOrder(t).forEach(n=>{n.onPage||!fe.has(n)||(n.onPage=!0,n.attachHooks?.slice().forEach(s=>ve(s,"$attached")))})}notifyDetached(){if(fe.size===0)return;let t=[];if(this.startMarker?.isConnected){let n=new Set;for(let r=this.startMarker;r&&(n.add(r),r!==this.endMarker);r=r.nextSibling);let s=r=>{for(;r;r=r.parentNode)if(n.has(r))return!0;return!1};t=ce.inDocumentOrder([...fe].filter(r=>r.onPage&&s(r.startMarker)))}else this.onPage&&(t=[this]);t.forEach(n=>{n.onPage&&(n.onPage=!1,n.detachHooks?.slice().forEach(s=>ve(s,"$detached")))})}static inDocumentOrder(t){return t.sort((n,s)=>n.startMarker.compareDocumentPosition(s.startMarker)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1)}placeShadowStyles(t,n){if(this.shadowCss&&typeof ShadowRoot<"u"&&t instanceof ShadowRoot){this.sheetRoot&&this.sheetRoot!==t&&this.shadowSheets.forEach(s=>qt(this.sheetRoot,s)),this.shadowSheets.length===0&&(this.shadowSheets=this.shadowCss.map(s=>s===je?Ht??(Ht=nt(s)):nt(s))),this.shadowSheets.forEach(s=>Qt(t,s)),this.sheetRoot=t;return}this.shadowCss&&this.styleEls.length===0&&(this.styleEls=this.shadowCss.map(s=>{let r=document.createElement("style");return r.textContent=s,r})),this.styleEls.forEach(s=>t.insertBefore(s,n))}settleMounted(){if(!this.renderDone||this.held>0)return;let t=this.onPaint;this.onPaint=null,t?.(),this.mountRoot&&this.resolveMounted?.()}holdOwner(t){this.renderDone&&this.held===0||(t.held++,this.onPaint=()=>{t.held--,t.settleMounted()})}detach(){if(!this.mountRoot||!this.content||!this.startMarker||!this.endMarker)return this;this.notifyDetached();let t=this.startMarker;for(;t;){let n=t.nextSibling;if(this.content.appendChild(t),t===this.endMarker)break;t=n}return this.mountRoot=null,this}destroy(){this.notifyDetached(),fe.delete(this),this.attachHooks=null,this.detachHooks=null,this.onPage=!1;let t=this.destroyHooks;this.destroyHooks=null,t?.forEach(s=>ve(s,"$destroyed")),this.resolveMounted=null;let n=this.onPaint;return this.onPaint=null,n?.(),this.detach(),this.fx?.dispose(),this.fx=null,this.data?.$dispose(),this.styleEls.forEach(s=>s.parentNode?.removeChild(s)),this.styleEls=[],this.sheetRoot&&this.shadowSheets.forEach(s=>{s!==Ht&&qt(this.sheetRoot,s)}),this.shadowCss=null,this.shadowSheets=[],this.sheetRoot=null,this.ownsSharedStyles&&(this.styles.forEach(s=>si(Zn(s))),this.ownsSharedStyles=!1),this.content=null,this.startMarker=null,this.endMarker=null,this.renderDone=!1,this.data=null,this.resolveMounted=null,this}};k(ce,"version",qr);var de=ce,ot=class{constructor(t){k(this,"chain");this.chain=t}queue(t){return this.chain=this.chain.then(n=>(t(n),n)),this}then(t,n){return this.chain.then(t,n)}catch(t){return this.chain.catch(t)}finally(t){return this.chain.finally(t)}mount(t,n){return this.queue(s=>s.mount(t,n))}mountShadow(t,n){return this.queue(s=>s.mountShadow(t,n))}render(t={}){return this.queue(n=>n.render(t))}renderShadow(t={}){return this.queue(n=>n.renderShadow(t))}on(t,n){return this.queue(s=>s.on(t,n))}off(t,n){return this.queue(s=>s.off(t,n))}detach(){return this.queue(t=>t.detach())}destroy(){return this.queue(t=>t.destroy())}};var bi=e=>new de(e),ve=(e,t)=>{try{e()}catch(n){console.error(`jq79: error in a ${t} hook`,n)}},Ot=(e,t)=>(e.push(t),()=>{let n=e.indexOf(t);n!==-1&&e.splice(n,1)}),fe=new Set,_t=!1,Ds={$:Te,$$:Ie,$create:qe,$reactive:xe,$toRaw:Z,Component79:de};typeof globalThis<"u"&&globalThis[ui]&&js();0&&(module.exports={$,$$,$computed,$create,$reactive,$toRaw,C79,Component79,PendingComponent79,enableHotReload,hotUpdate,parseComponent,renderComponent});
20
20
  //# sourceMappingURL=jq79.cjs.map