@jasonshimmy/custom-elements-runtime 3.7.2 → 3.7.4
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/dist/custom-elements-runtime.cjs.js +1 -1
- package/dist/custom-elements-runtime.es.js +3 -3
- package/dist/custom-elements-runtime.jit-css.cjs.js +1 -1
- package/dist/custom-elements-runtime.jit-css.es.js +2 -2
- package/dist/custom-elements-runtime.router.cjs.js +1 -1
- package/dist/custom-elements-runtime.router.cjs.js.map +1 -1
- package/dist/custom-elements-runtime.router.es.js +3 -3
- package/dist/custom-elements-runtime.router.es.js.map +1 -1
- package/dist/custom-elements-runtime.ssr-middleware.cjs.js +1 -1
- package/dist/custom-elements-runtime.ssr-middleware.es.js +1 -1
- package/dist/custom-elements-runtime.ssr.cjs.js +1 -1
- package/dist/custom-elements-runtime.ssr.es.js +2 -2
- package/dist/custom-elements-runtime.vite-plugin.cjs.js +1 -1
- package/dist/custom-elements-runtime.vite-plugin.es.js +1 -1
- package/dist/helpers-BQ37xfhc.cjs +5 -0
- package/dist/helpers-BQ37xfhc.cjs.map +1 -0
- package/dist/{helpers-BiGdX-3A.js → helpers-llht6g11.js} +5 -2
- package/dist/helpers-llht6g11.js.map +1 -0
- package/dist/{hooks-yP009oF9.js → hooks-BZwRvrjJ.js} +146 -131
- package/dist/hooks-BZwRvrjJ.js.map +1 -0
- package/dist/hooks-DTyLoDNI.cjs +2 -0
- package/dist/hooks-DTyLoDNI.cjs.map +1 -0
- package/dist/runtime/hooks.d.ts +0 -13
- package/dist/runtime/reactive.d.ts +1 -0
- package/dist/{ssr-CUT0FqUz.cjs → ssr-DkMl-vjb.cjs} +2 -2
- package/dist/{ssr-CUT0FqUz.cjs.map → ssr-DkMl-vjb.cjs.map} +1 -1
- package/dist/{ssr-COmrqY64.js → ssr-WD-KTNsB.js} +3 -3
- package/dist/{ssr-COmrqY64.js.map → ssr-WD-KTNsB.js.map} +1 -1
- package/dist/{tag-utils-CMy95A4Z.cjs → tag-utils-BiaxgxbY.cjs} +2 -2
- package/dist/{tag-utils-CMy95A4Z.cjs.map → tag-utils-BiaxgxbY.cjs.map} +1 -1
- package/dist/{tag-utils-DVutXfzj.js → tag-utils-DMHsC8t3.js} +2 -2
- package/dist/{tag-utils-DVutXfzj.js.map → tag-utils-DMHsC8t3.js.map} +1 -1
- package/dist/template-compiler-D3r3ajIB.cjs +19 -0
- package/dist/template-compiler-D3r3ajIB.cjs.map +1 -0
- package/dist/{template-compiler-BkR0G45f.js → template-compiler-D7BToKVe.js} +262 -252
- package/dist/template-compiler-D7BToKVe.js.map +1 -0
- package/package.json +1 -1
- package/dist/helpers-BiGdX-3A.js.map +0 -1
- package/dist/helpers-hGU9czPG.cjs +0 -5
- package/dist/helpers-hGU9czPG.cjs.map +0 -1
- package/dist/hooks-CACte2Ir.cjs +0 -2
- package/dist/hooks-CACte2Ir.cjs.map +0 -1
- package/dist/hooks-yP009oF9.js.map +0 -1
- package/dist/template-compiler-BkR0G45f.js.map +0 -1
- package/dist/template-compiler-EdgxOr6e.cjs +0 -19
- package/dist/template-compiler-EdgxOr6e.cjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ssr-COmrqY64.js","names":[],"sources":["../src/lib/runtime/ssr-utils.ts","../src/lib/runtime/vdom-ssr.ts","../src/lib/runtime/vdom-ssr-dsd.ts","../src/lib/ssr.ts"],"sourcesContent":["/**\n * Shared utilities for SSR renderers.\n * Imported by vdom-ssr.ts and vdom-ssr-dsd.ts to avoid duplication.\n */\nimport { escapeHTML } from './helpers';\nimport { TAG_NAMESPACE_MAP, SVG_NS } from './namespace-helpers';\n\nexport type RenderOptions = {\n /** Backwards-compatible: whether to inject the SVG namespace on <svg> nodes (default true) */\n injectSvgNamespace?: boolean;\n /** Inject known well-known namespaces for tags like <math> when missing (default follows injectSvgNamespace) */\n injectKnownNamespaces?: boolean;\n};\n\nexport const VOID_ELEMENTS = new Set([\n 'area',\n 'base',\n 'br',\n 'col',\n 'embed',\n 'hr',\n 'img',\n 'input',\n 'link',\n 'meta',\n 'param',\n 'source',\n 'track',\n 'wbr',\n]);\n\nexport function buildAttrs(\n attrs: Record<string, unknown>,\n tag: string,\n opts: RenderOptions,\n): string {\n const inject = opts.injectSvgNamespace ?? true;\n const injectKnown = opts.injectKnownNamespaces ?? inject;\n const merged = { ...attrs };\n\n if (inject && tag === 'svg' && !('xmlns' in merged)) {\n merged['xmlns'] = SVG_NS;\n } else if (injectKnown && tag in TAG_NAMESPACE_MAP && !('xmlns' in merged)) {\n merged['xmlns'] = TAG_NAMESPACE_MAP[tag];\n }\n\n return Object.entries(merged)\n .map(([k, v]) => ` ${k}=\"${escapeHTML(String(v))}\"`)\n .join('');\n}\n\nexport function buildRawAttrs(attrs: Record<string, unknown>): string {\n return Object.entries(attrs)\n .map(([k, v]) => ` ${k}=\"${escapeHTML(String(v))}\"`)\n .join('');\n}\n","import type { VNode } from './types';\nimport { escapeHTML } from './helpers';\nimport { VOID_ELEMENTS, buildAttrs, type RenderOptions } from './ssr-utils';\n\n/**\n * Render a VNode to a string (SSR).\n * Kept intentionally minimal: only serializes attributes under `props.attrs`\n * to avoid leaking runtime-only values (functions, reactive state, directives).\n * @param vnode The virtual node to render.\n * @returns The rendered HTML string.\n */\nexport type { RenderOptions } from './ssr-utils';\n\nexport function renderToString(vnode: VNode, opts?: RenderOptions): string {\n if (typeof vnode === 'string') return escapeHTML(vnode) as string;\n\n if (vnode.tag === '#text') {\n return typeof vnode.children === 'string'\n ? (escapeHTML(vnode.children) as string)\n : '';\n }\n\n if (vnode.tag === '#anchor') {\n // Preserve meaningful falsy children (0, false, '') while filtering out\n // only null and undefined. Anchor blocks are normalized by the compiler\n // to exclude null/undefined; SSR should follow the same rule to avoid\n // hydration mismatches where falsy values are significant.\n const children = Array.isArray(vnode.children)\n ? vnode.children.filter((c) => c !== null && c !== undefined)\n : [];\n return children.map((c) => renderToString(c, opts)).join('');\n }\n\n if (vnode.tag === '#raw') {\n return typeof vnode.children === 'string' ? vnode.children : '';\n }\n\n // Collect attributes from props.attrs. For SSR we mirror vnode.attrs\n // but ensure SVG nodes behave like client-side: if this is an <svg>\n // and no xmlns was provided, inject the standard SVG namespace so\n // server markup matches client-created DOM namespace.\n const attrsObj: Record<string, unknown> = vnode.props?.attrs\n ? { ...vnode.props.attrs }\n : {};\n\n const attrsString = buildAttrs(attrsObj, vnode.tag, opts ?? {});\n\n // Handle void elements (self-closing tags)\n if (VOID_ELEMENTS.has(vnode.tag)) {\n return `<${vnode.tag}${attrsString}>`;\n }\n\n const children = Array.isArray(vnode.children)\n ? vnode.children\n .filter((c) => c !== null && c !== undefined)\n .map((c) => renderToString(c, opts))\n .join('')\n : typeof vnode.children === 'string'\n ? escapeHTML(vnode.children)\n : vnode.children\n ? renderToString(vnode.children, opts)\n : '';\n\n return `<${vnode.tag}${attrsString}>${children}</${vnode.tag}>`;\n}\n","/**\n * Declarative Shadow DOM (DSD) SSR renderer.\n *\n * When `dsd: true` is passed to the render options, registered custom elements\n * are serialised as:\n *\n * ```html\n * <my-element attr=\"val\">\n * <template shadowrootmode=\"open\">\n * <style>\n * /* baseReset + useStyle() output + JIT utility CSS *\\/\n * </style>\n * <!-- shadow DOM from component render function -->\n * </template>\n * <!-- light DOM / slotted children from vnode.children -->\n * </my-element>\n * ```\n *\n * The browser parses the `<template shadowrootmode=\"open\">` block and attaches\n * a real shadow root before any JavaScript executes. All CSS layers are present\n * at first paint — eliminating both FOUC and layout shift.\n *\n * Non-custom-element VNodes are rendered identically to renderToString() but\n * with DSD recursion active for any custom elements nested inside them.\n */\n\nimport type { VNode } from './types';\nimport { renderToString } from './vdom-ssr';\nimport { VOID_ELEMENTS, buildAttrs, buildRawAttrs, type RenderOptions } from './ssr-utils';\nimport { registry } from './component/registry';\nimport { runComponentSSRRender } from './ssr-context';\nimport { jitCSS } from './style';\nimport { baseReset, minifyCSS } from './css-utils';\nimport { escapeHTML } from './helpers';\nimport { devWarn } from './logger';\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\nexport type DSDRenderOptions = RenderOptions & {\n /**\n * Emit Declarative Shadow DOM output for registered custom elements.\n * Shadow content is serialised inside `<template shadowrootmode=\"open\">`,\n * with a complete CSS layer stack (`baseReset` + `useStyle` + JIT CSS)\n * injected as a `<style>` block so styles are available at first paint.\n * @default false\n */\n dsd?: boolean;\n /**\n * Append the DSD polyfill `<script>` for browsers without native support\n * (Firefox < 123). Only meaningful when `dsd` is true.\n * @default true\n */\n dsdPolyfill?: boolean;\n /**\n * Router instance to thread through each component's SSR context.\n *\n * When provided, `router-view` reads the current route from this instance\n * instead of the module-level `activeRouterProxy` singleton, making\n * concurrent SSR renders safe — each request carries its own router with\n * its own URL state.\n *\n * In browser mode this option is ignored; components always use\n * `activeRouterProxy` there.\n */\n router?: unknown;\n};\n\n// ---------------------------------------------------------------------------\n// Constants\n// ---------------------------------------------------------------------------\n\n/**\n * @internal\n * Minified DSD polyfill for browsers without native Declarative Shadow DOM.\n * Processes all `<template shadowrootmode>` elements synchronously.\n */\nexport const DSD_POLYFILL_SCRIPT =\n '<script>(function(){' +\n \"if(HTMLTemplateElement.prototype.hasOwnProperty('shadowRootMode'))return;\" +\n \"document.querySelectorAll('template[shadowrootmode]').forEach(function(t){\" +\n \"var m=t.getAttribute('shadowrootmode');\" +\n 'var s=t.parentElement.attachShadow({mode:m});' +\n 's.appendChild(t.content);t.remove();' +\n '});})()' +\n '</script>';\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\nfunction isRegisteredCustomElement(tag: string): boolean {\n return tag.includes('-') && registry.has(tag);\n}\n\n/**\n * Build the combined `<style>` block for a shadow root.\n *\n * Layer order (matches the runtime adoptedStyleSheets order):\n * 1. baseReset — global reset + CSS custom properties\n * 2. useStyle() output — component-defined rules (:host, ::slotted, etc.)\n * 3. JIT CSS — utility classes extracted from the shadow HTML\n */\nexport function buildShadowStyleBlock(\n useStyleCSS: string,\n shadowHTML: string,\n): string {\n const parts: string[] = [baseReset];\n\n if (useStyleCSS.trim()) {\n parts.push(useStyleCSS);\n }\n\n const jit = jitCSS(shadowHTML);\n if (jit.trim()) {\n parts.push(jit);\n }\n\n const combined = minifyCSS(parts.join('\\n'));\n return combined ? `<style>${combined}</style>` : '';\n}\n\n// ---------------------------------------------------------------------------\n// Streaming async component collector\n// ---------------------------------------------------------------------------\n\nexport interface AsyncStreamEntry {\n id: string;\n tag: string;\n attrsString: string;\n hydrateAttr: string;\n useStyleCSS: string;\n lightDOM: string;\n opts: DSDRenderOptions;\n promise: Promise<VNode | VNode[]>;\n /** Router threaded from the originating render pass — propagated to async re-renders. */\n router?: unknown;\n}\n\nlet _streamingCollector: AsyncStreamEntry[] | null = null;\nlet _streamingCounter = 0;\n\n/** @internal Called by renderToStream() before the sync render pass. */\nexport function beginStreamingCollection(collector: AsyncStreamEntry[]): void {\n _streamingCollector = collector;\n _streamingCounter = 0;\n}\n\n/** @internal Called by renderToStream() after the sync render pass. */\nexport function endStreamingCollection(): void {\n _streamingCollector = null;\n}\n\n// ---------------------------------------------------------------------------\n// Core renderer\n// ---------------------------------------------------------------------------\n\n/**\n * Render a VNode tree to an HTML string with Declarative Shadow DOM output\n * for all registered custom elements encountered in the tree.\n */\nexport function renderToDSD(vnode: VNode, opts: DSDRenderOptions): string {\n if (!opts.dsd) {\n return renderToString(vnode, opts);\n }\n\n // Primitive string nodes\n if (typeof vnode === 'string') {\n return escapeHTML(vnode) as string;\n }\n\n const tag = (vnode as VNode).tag;\n\n // Special virtual node types — delegate entirely to the base renderer\n if (tag === '#text' || tag === '#anchor' || tag === '#raw') {\n return renderToString(vnode, opts);\n }\n\n // Custom element — emit DSD wrapper\n if (isRegisteredCustomElement(tag)) {\n return renderCustomElementDSD(vnode, opts);\n }\n\n // Regular element — recurse with DSD mode on\n const attrsObj: Record<string, unknown> = vnode.props?.attrs\n ? { ...vnode.props.attrs }\n : {};\n\n const attrsString = buildAttrs(attrsObj, tag, opts);\n\n if (VOID_ELEMENTS.has(tag)) {\n return `<${tag}${attrsString}>`;\n }\n\n const children = renderChildrenDSD(vnode.children, opts);\n return `<${tag}${attrsString}>${children}</${tag}>`;\n}\n\nfunction renderCustomElementDSD(vnode: VNode, opts: DSDRenderOptions): string {\n const tag = vnode.tag;\n const config = registry.get(tag);\n\n // Build the plain attribute string (no namespace injection for custom elements)\n const rawAttrs = vnode.props?.attrs ?? {};\n const attrsString = buildRawAttrs(rawAttrs);\n\n // Move the null check BEFORE reading config.* properties for clarity.\n if (!config) {\n // Component not in registry on server (e.g. dynamic import not yet run).\n // Emit a shell with an empty DSD template so the client hydrates normally.\n const lightDOM = renderChildrenDSD(vnode.children, opts);\n return `<${tag}${attrsString}><template shadowrootmode=\"open\"></template>${lightDOM}</${tag}>`;\n }\n\n // Emit data-cer-hydrate when a non-default strategy is configured.\n // 'load' is the default and doesn't need to be serialised.\n const hydrateStrategy = config.hydrate;\n const hydrateAttr =\n hydrateStrategy && hydrateStrategy !== 'load'\n ? ` data-cer-hydrate=\"${hydrateStrategy}\"`\n : '';\n\n // Run the component's render function in a minimal SSR context to get the\n // shadow DOM VNode tree and capture any useStyle() output.\n const { shadowVNode, useStyleCSS, asyncPromise } = runComponentSSRRender(config, rawAttrs, tag, opts.router);\n\n // When streaming and this component has an async render, emit a placeholder\n // and register the promise for later resolution.\n if (asyncPromise && _streamingCollector === null) {\n devWarn(\n `[SSR] Component \"${tag}\" has an async render function. ` +\n `In standard SSR the shadow DOM will be empty. ` +\n `Use renderToStream() for incremental async component streaming.`,\n );\n }\n if (asyncPromise && _streamingCollector !== null) {\n const id = `cer-stream-${_streamingCounter++}`;\n const lightDOM = renderChildrenDSD(vnode.children, opts);\n _streamingCollector.push({\n id,\n tag,\n attrsString,\n hydrateAttr,\n useStyleCSS,\n lightDOM,\n opts,\n promise: asyncPromise,\n router: opts.router,\n });\n return (\n `<${tag} id=\"${id}\"${attrsString}${hydrateAttr}>` +\n `<template shadowrootmode=\"open\"></template>` +\n `${lightDOM}` +\n `</${tag}>`\n );\n }\n\n // Render the shadow DOM VNode tree to HTML (DSD-recursive for nested elements)\n let shadowHTML = '';\n if (shadowVNode !== null && shadowVNode !== undefined) {\n if (Array.isArray(shadowVNode)) {\n shadowHTML = (shadowVNode as VNode[])\n .map((n) => renderToDSD(n, opts))\n .join('');\n } else {\n shadowHTML = renderToDSD(shadowVNode as VNode, opts);\n }\n }\n\n const styleBlock = buildShadowStyleBlock(useStyleCSS, shadowHTML);\n\n // Light DOM children become slotted content — rendered outside the template\n const lightDOM = renderChildrenDSD(vnode.children, opts);\n\n return (\n `<${tag}${attrsString}${hydrateAttr}>` +\n `<template shadowrootmode=\"open\">${styleBlock}${shadowHTML}</template>` +\n `${lightDOM}` +\n `</${tag}>`\n );\n}\n\nfunction renderChildrenDSD(\n children: VNode['children'],\n opts: DSDRenderOptions,\n): string {\n if (!children) return '';\n if (typeof children === 'string') return escapeHTML(children) as string;\n if (Array.isArray(children)) {\n return children\n .filter((c) => c !== null && c !== undefined)\n .map((c) => renderToDSD(c as VNode, opts))\n .join('');\n }\n return renderToDSD(children as VNode, opts);\n}\n\n// ---------------------------------------------------------------------------\n// Public entry points\n// ---------------------------------------------------------------------------\n\n/**\n * Render a VNode tree to a DSD HTML string and optionally append the\n * DSD polyfill script for older browsers.\n */\nexport function renderToStringDSD(\n vnode: VNode,\n opts?: DSDRenderOptions,\n): string {\n const effectiveOpts: DSDRenderOptions = { dsd: true, ...opts };\n const html = renderToDSD(vnode, effectiveOpts);\n\n if (effectiveOpts.dsdPolyfill !== false) {\n // Inject polyfill before </body> if present, otherwise append\n if (html.includes('</body>')) {\n return html.replace('</body>', `${DSD_POLYFILL_SCRIPT}</body>`);\n }\n return html + DSD_POLYFILL_SCRIPT;\n }\n\n return html;\n}\n","/**\n * SSR entry point — import from `@jasonshimmy/custom-elements-runtime/ssr`.\n *\n * Provides four rendering modes:\n *\n * 1. **renderToString** — baseline HTML serialisation (no shadow DOM content).\n * Backwards-compatible with the original API.\n *\n * 2. **renderToStringWithJITCSS** — HTML + pre-generated JIT CSS injected into\n * `<head>` to prevent FOUC. Supports `dsd: true` for DSD output.\n *\n * 3. **renderToStringWithJITCSSDSD** — convenience alias for DSD mode.\n * Full Declarative Shadow DOM output with per-shadow-root CSS layer stack\n * (baseReset + useStyle() + JIT CSS). Enables true hydration, zero FOUC.\n *\n * 4. **renderToStream** — ReadableStream variant for streaming SSR.\n *\n * 5. **renderToStreamWithJITCSSDSD** — convenience alias for streaming DSD mode.\n * Equivalent to `renderToStream(vnode, { dsd: true, ...options })`.\n * Recommended for new server-rendered applications that want true incremental\n * streaming with Declarative Shadow DOM and zero FOUC.\n *\n * Entity map utilities are also exported for full HTML5 named-entity support.\n *\n * @example DSD usage (recommended)\n * ```ts\n * import { renderToStringWithJITCSSDSD } from '@jasonshimmy/custom-elements-runtime/ssr';\n *\n * const { htmlWithStyles } = renderToStringWithJITCSSDSD(appVNode, {\n * jit: { extendedColors: true },\n * });\n * res.send(`<!DOCTYPE html><html><head>${head}</head><body>${htmlWithStyles}</body></html>`);\n * ```\n */\n\n// ---------------------------------------------------------------------------\n// Re-exports — backwards-compatible\n// ---------------------------------------------------------------------------\n\nexport { renderToString } from './runtime/vdom-ssr';\nexport type { VNode } from './runtime/types';\nexport type { RenderOptions } from './runtime/vdom-ssr';\n\nexport {\n registerEntityMap,\n loadEntityMap,\n clearRegisteredEntityMap,\n} from './runtime/helpers';\n\nexport {\n renderToStringDSD,\n DSD_POLYFILL_SCRIPT,\n} from './runtime/vdom-ssr-dsd';\nexport type { DSDRenderOptions } from './runtime/vdom-ssr-dsd';\n\n// ---------------------------------------------------------------------------\n// Internal imports\n// ---------------------------------------------------------------------------\n\nimport { renderToString as _render } from './runtime/vdom-ssr';\nimport {\n renderToStringDSD as _renderToStringDSD,\n renderToDSD,\n buildShadowStyleBlock,\n beginStreamingCollection,\n endStreamingCollection,\n DSD_POLYFILL_SCRIPT,\n type AsyncStreamEntry,\n} from './runtime/vdom-ssr-dsd';\nimport { jitCSS, enableJITCSS, type JITCSSOptions } from './runtime/style';\nimport type { VNode } from './runtime/types';\nimport type { RenderOptions } from './runtime/vdom-ssr';\nimport type { DSDRenderOptions } from './runtime/vdom-ssr-dsd';\nimport {\n beginSSRGlobalStyleCollection,\n endSSRGlobalStyleCollection,\n} from './runtime/ssr-context';\n\n// ---------------------------------------------------------------------------\n// Result type\n// ---------------------------------------------------------------------------\n\n/**\n * Result of `renderToStringWithJITCSS()` and `renderToStringWithJITCSSDSD()`.\n */\nexport interface SSRJITResult {\n /** The rendered HTML string (styles not yet injected). */\n html: string;\n /**\n * Global JIT CSS extracted from the rendered HTML.\n * For DSD renders, each shadow root embeds its own scoped styles; this field\n * holds any residual light-DOM utility CSS.\n */\n css: string;\n /**\n * CSS captured from `useGlobalStyle()` calls during this render pass\n * (e.g. `@font-face`, `:root` custom properties).\n * Inject in a `<style id=\"cer-ssr-global\">` in `<head>`.\n */\n globalStyles: string;\n /**\n * Convenience: `html` with both `<style>` tags injected before `</head>`.\n * If no `</head>` is found, the styles are prepended.\n */\n htmlWithStyles: string;\n}\n\n// ---------------------------------------------------------------------------\n// renderToStringWithJITCSS — primary API, supports both modes\n// ---------------------------------------------------------------------------\n\n/**\n * Server-side render a VNode tree and simultaneously pre-generate JIT CSS.\n *\n * Pass `dsd: true` to enable Declarative Shadow DOM output with full per-shadow-\n * root CSS layer extraction (recommended for new apps).\n *\n * @example Standard (no DSD)\n * ```ts\n * const { htmlWithStyles } = renderToStringWithJITCSS(appVNode);\n * ```\n *\n * @example With DSD\n * ```ts\n * const { htmlWithStyles } = renderToStringWithJITCSS(appVNode, {\n * dsd: true,\n * jit: { extendedColors: true },\n * });\n * ```\n */\nexport function renderToStringWithJITCSS(\n vnode: VNode,\n options?: RenderOptions & DSDRenderOptions & { jit?: JITCSSOptions },\n): SSRJITResult {\n const { jit, dsd, dsdPolyfill, ...renderOptions } = options ?? {};\n\n if (jit) enableJITCSS(jit);\n\n beginSSRGlobalStyleCollection();\n\n let html!: string;\n let globalStylesCaptured!: string[];\n try {\n if (dsd) {\n // renderToStringDSD handles DSD wrapping but skips the polyfill so we can\n // place it correctly relative to other injected style tags below.\n html = _renderToStringDSD(vnode, {\n ...renderOptions,\n dsd: true,\n dsdPolyfill: false,\n });\n } else {\n html = _render(vnode, renderOptions);\n }\n } finally {\n // Always end collection — even when the render throws — so the collector\n // is never left non-null, which would cause subsequent non-SSR\n // useGlobalStyle() calls to silently skip DOM injection.\n globalStylesCaptured = endSSRGlobalStyleCollection();\n }\n\n const css = jitCSS(html);\n const globalStyles = globalStylesCaptured.join('\\n');\n\n const styleTags: string[] = [];\n if (css) styleTags.push(`<style id=\"cer-ssr-jit\">${css}</style>`);\n if (globalStyles.trim())\n styleTags.push(`<style id=\"cer-ssr-global\">${globalStyles}</style>`);\n\n let htmlWithStyles = html;\n if (styleTags.length) {\n const injection = styleTags.join('');\n htmlWithStyles = html.includes('</head>')\n ? html.replace('</head>', `${injection}</head>`)\n : `${injection}${html}`;\n }\n\n // Append DSD polyfill script inside </body> when in DSD mode\n if (dsd && dsdPolyfill !== false) {\n htmlWithStyles = htmlWithStyles.includes('</body>')\n ? htmlWithStyles.replace('</body>', `${DSD_POLYFILL_SCRIPT}</body>`)\n : htmlWithStyles + DSD_POLYFILL_SCRIPT;\n }\n\n return { html, css, globalStyles, htmlWithStyles };\n}\n\n// ---------------------------------------------------------------------------\n// renderToStringWithJITCSSDSD — convenience alias\n// ---------------------------------------------------------------------------\n\n/**\n * Convenience alias: `renderToStringWithJITCSS(vnode, { dsd: true, ...options })`.\n *\n * Renders with Declarative Shadow DOM output, full per-shadow-root CSS layer\n * extraction, and the DSD browser polyfill. This is the recommended function\n * for all new server-rendered applications.\n *\n * @example\n * ```ts\n * import { renderToStringWithJITCSSDSD } from '@jasonshimmy/custom-elements-runtime/ssr';\n *\n * const { htmlWithStyles } = renderToStringWithJITCSSDSD(appVNode, {\n * jit: { extendedColors: true },\n * });\n * ```\n */\nexport function renderToStringWithJITCSSDSD(\n vnode: VNode,\n options?: Omit<\n RenderOptions & DSDRenderOptions & { jit?: JITCSSOptions },\n 'dsd'\n >,\n): SSRJITResult {\n return renderToStringWithJITCSS(vnode, { ...options, dsd: true });\n}\n\n// ---------------------------------------------------------------------------\n// renderToStream — streaming SSR\n// ---------------------------------------------------------------------------\n\n/**\n * Render a VNode tree to a `ReadableStream<string>`.\n *\n * Supports true incremental streaming: synchronous components are flushed as\n * the first chunk, then each async component's resolved output is streamed as\n * an inline swap `<script>` that fills the placeholder's shadow root.\n *\n * @example Node.js\n * ```ts\n * import { renderToStream } from '@jasonshimmy/custom-elements-runtime/ssr';\n *\n * app.get('/', (req, res) => {\n * const stream = renderToStream(appVNode, { dsd: true });\n * const reader = stream.getReader();\n * const pump = () =>\n * reader.read().then(({ value, done }) => {\n * if (done) { res.end(); return; }\n * res.write(value);\n * pump();\n * });\n * pump();\n * });\n * ```\n */\nexport function renderToStream(\n vnode: VNode,\n options?: RenderOptions & DSDRenderOptions & { jit?: JITCSSOptions; asyncTimeout?: number },\n): ReadableStream<string> {\n const timeoutMs = options?.asyncTimeout ?? 30_000;\n\n return new ReadableStream<string>({\n async start(controller) {\n const asyncEntries: AsyncStreamEntry[] = [];\n beginStreamingCollection(asyncEntries);\n\n try {\n const { htmlWithStyles } = renderToStringWithJITCSS(vnode, options);\n controller.enqueue(htmlWithStyles);\n } catch (err) {\n controller.error(err);\n return;\n } finally {\n endStreamingCollection();\n }\n\n // Resolve async components and stream swap scripts as they settle.\n // Each resolved component replaces its placeholder via an inline script.\n // A per-entry timeout prevents hung async components from blocking the stream.\n for (const entry of asyncEntries) {\n try {\n const timeout = new Promise<never>((_, reject) =>\n setTimeout(() => reject(new Error(`[cer] async component timed out after ${timeoutMs}ms`)), timeoutMs),\n );\n const resolvedVNodes = await Promise.race([entry.promise, timeout]);\n const shadowHTML = Array.isArray(resolvedVNodes)\n ? (resolvedVNodes as VNode[]).map((n) => renderToDSD(n, entry.opts)).join('')\n : renderToDSD(resolvedVNodes as VNode, entry.opts);\n const styleBlock = buildShadowStyleBlock(entry.useStyleCSS, shadowHTML);\n const shadowContent = `${styleBlock}${shadowHTML}`;\n controller.enqueue(\n `<script>(function(){` +\n `var e=document.getElementById(${JSON.stringify(entry.id)});` +\n `if(!e)return;` +\n // The placeholder already has an empty shadow root attached (native DSD or polyfill).\n // If for some reason it doesn't, attach one now.\n `var s=e.shadowRoot;` +\n `if(!s&&e.attachShadow)try{s=e.attachShadow({mode:'open'});}catch(_){};` +\n `if(s)s.innerHTML=${JSON.stringify(shadowContent)};` +\n `e.removeAttribute('id');` +\n `})();</script>`,\n );\n } catch {\n // Async render failed — leave placeholder for client hydration.\n }\n }\n\n controller.close();\n },\n });\n}\n\n// ---------------------------------------------------------------------------\n// renderToStreamWithJITCSSDSD — convenience alias\n// ---------------------------------------------------------------------------\n\n/**\n * Convenience alias: `renderToStream(vnode, { dsd: true, ...options })`.\n *\n * Renders with Declarative Shadow DOM output and full JIT CSS extraction,\n * streaming the synchronous render as the first chunk and each resolved async\n * component as a subsequent inline-script swap. This is the recommended\n * function for all new server-rendered applications.\n *\n * @example\n * ```ts\n * import { renderToStreamWithJITCSSDSD } from '@jasonshimmy/custom-elements-runtime/ssr';\n *\n * app.get('/', (req, res) => {\n * const stream = renderToStreamWithJITCSSDSD(appVNode, { router });\n * const reader = stream.getReader();\n * const pump = () =>\n * reader.read().then(({ value, done }) => {\n * if (done) { res.end(); return; }\n * res.write(value);\n * pump();\n * });\n * pump();\n * });\n * ```\n */\nexport function renderToStreamWithJITCSSDSD(\n vnode: VNode,\n options?: Omit<\n RenderOptions & DSDRenderOptions & { jit?: JITCSSOptions; asyncTimeout?: number },\n 'dsd'\n >,\n): ReadableStream<string> {\n return renderToStream(vnode, { ...options, dsd: true });\n}\n"],"mappings":";;;;;;;AAcA,IAAa,IAAgB,IAAI,IAAI;CACnC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;C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EAAyB,GAAO;EAAE,GAAG;EAAS,KAAK;EAAM,CAAC;;AA+BnE,SAAgB,EACd,GACA,GACwB;CACxB,IAAM,IAAY,GAAS,gBAAgB;AAE3C,QAAO,IAAI,eAAuB,EAChC,MAAM,MAAM,GAAY;EACtB,IAAM,IAAmC,EAAE;AAC3C,IAAyB,EAAa;AAEtC,MAAI;GACF,IAAM,EAAE,sBAAmB,EAAyB,GAAO,EAAQ;AACnE,KAAW,QAAQ,EAAe;WAC3B,GAAK;AACZ,KAAW,MAAM,EAAI;AACrB;YACQ;AACR,MAAwB;;AAM1B,OAAK,IAAM,KAAS,EAClB,KAAI;GACF,IAAM,IAAU,IAAI,SAAgB,GAAG,MACrC,iBAAiB,EAAO,gBAAI,MAAM,yCAAyC,EAAU,IAAI,CAAC,EAAE,EAAU,CACvG,EACK,IAAiB,MAAM,QAAQ,KAAK,CAAC,EAAM,SAAS,EAAQ,CAAC,EAC7D,IAAa,MAAM,QAAQ,EAAe,GAC3C,EAA2B,KAAK,MAAM,EAAY,GAAG,EAAM,KAAK,CAAC,CAAC,KAAK,GAAG,GAC3E,EAAY,GAAyB,EAAM,KAAK,EAE9C,IAAgB,GADH,EAAsB,EAAM,aAAa,EAAW,GACjC;AACtC,KAAW,QACT,qDACmC,KAAK,UAAU,EAAM,GAAG,CAAC,2HAMtC,KAAK,UAAU,EAAc,CAAC,0CAGrD;UACK;AAKV,IAAW,OAAO;IAErB,CAAC;;AAgCJ,SAAgB,EACd,GACA,GAIwB;AACxB,QAAO,EAAe,GAAO;EAAE,GAAG;EAAS,KAAK;EAAM,CAAC"}
|
|
1
|
+
{"version":3,"file":"ssr-WD-KTNsB.js","names":[],"sources":["../src/lib/runtime/ssr-utils.ts","../src/lib/runtime/vdom-ssr.ts","../src/lib/runtime/vdom-ssr-dsd.ts","../src/lib/ssr.ts"],"sourcesContent":["/**\n * Shared utilities for SSR renderers.\n * Imported by vdom-ssr.ts and vdom-ssr-dsd.ts to avoid duplication.\n */\nimport { escapeHTML } from './helpers';\nimport { TAG_NAMESPACE_MAP, SVG_NS } from './namespace-helpers';\n\nexport type RenderOptions = {\n /** Backwards-compatible: whether to inject the SVG namespace on <svg> nodes (default true) */\n injectSvgNamespace?: boolean;\n /** Inject known well-known namespaces for tags like <math> when missing (default follows injectSvgNamespace) */\n injectKnownNamespaces?: boolean;\n};\n\nexport const VOID_ELEMENTS = new Set([\n 'area',\n 'base',\n 'br',\n 'col',\n 'embed',\n 'hr',\n 'img',\n 'input',\n 'link',\n 'meta',\n 'param',\n 'source',\n 'track',\n 'wbr',\n]);\n\nexport function buildAttrs(\n attrs: Record<string, unknown>,\n tag: string,\n opts: RenderOptions,\n): string {\n const inject = opts.injectSvgNamespace ?? true;\n const injectKnown = opts.injectKnownNamespaces ?? inject;\n const merged = { ...attrs };\n\n if (inject && tag === 'svg' && !('xmlns' in merged)) {\n merged['xmlns'] = SVG_NS;\n } else if (injectKnown && tag in TAG_NAMESPACE_MAP && !('xmlns' in merged)) {\n merged['xmlns'] = TAG_NAMESPACE_MAP[tag];\n }\n\n return Object.entries(merged)\n .map(([k, v]) => ` ${k}=\"${escapeHTML(String(v))}\"`)\n .join('');\n}\n\nexport function buildRawAttrs(attrs: Record<string, unknown>): string {\n return Object.entries(attrs)\n .map(([k, v]) => ` ${k}=\"${escapeHTML(String(v))}\"`)\n .join('');\n}\n","import type { VNode } from './types';\nimport { escapeHTML } from './helpers';\nimport { VOID_ELEMENTS, buildAttrs, type RenderOptions } from './ssr-utils';\n\n/**\n * Render a VNode to a string (SSR).\n * Kept intentionally minimal: only serializes attributes under `props.attrs`\n * to avoid leaking runtime-only values (functions, reactive state, directives).\n * @param vnode The virtual node to render.\n * @returns The rendered HTML string.\n */\nexport type { RenderOptions } from './ssr-utils';\n\nexport function renderToString(vnode: VNode, opts?: RenderOptions): string {\n if (typeof vnode === 'string') return escapeHTML(vnode) as string;\n\n if (vnode.tag === '#text') {\n return typeof vnode.children === 'string'\n ? (escapeHTML(vnode.children) as string)\n : '';\n }\n\n if (vnode.tag === '#anchor') {\n // Preserve meaningful falsy children (0, false, '') while filtering out\n // only null and undefined. Anchor blocks are normalized by the compiler\n // to exclude null/undefined; SSR should follow the same rule to avoid\n // hydration mismatches where falsy values are significant.\n const children = Array.isArray(vnode.children)\n ? vnode.children.filter((c) => c !== null && c !== undefined)\n : [];\n return children.map((c) => renderToString(c, opts)).join('');\n }\n\n if (vnode.tag === '#raw') {\n return typeof vnode.children === 'string' ? vnode.children : '';\n }\n\n // Collect attributes from props.attrs. For SSR we mirror vnode.attrs\n // but ensure SVG nodes behave like client-side: if this is an <svg>\n // and no xmlns was provided, inject the standard SVG namespace so\n // server markup matches client-created DOM namespace.\n const attrsObj: Record<string, unknown> = vnode.props?.attrs\n ? { ...vnode.props.attrs }\n : {};\n\n const attrsString = buildAttrs(attrsObj, vnode.tag, opts ?? {});\n\n // Handle void elements (self-closing tags)\n if (VOID_ELEMENTS.has(vnode.tag)) {\n return `<${vnode.tag}${attrsString}>`;\n }\n\n const children = Array.isArray(vnode.children)\n ? vnode.children\n .filter((c) => c !== null && c !== undefined)\n .map((c) => renderToString(c, opts))\n .join('')\n : typeof vnode.children === 'string'\n ? escapeHTML(vnode.children)\n : vnode.children\n ? renderToString(vnode.children, opts)\n : '';\n\n return `<${vnode.tag}${attrsString}>${children}</${vnode.tag}>`;\n}\n","/**\n * Declarative Shadow DOM (DSD) SSR renderer.\n *\n * When `dsd: true` is passed to the render options, registered custom elements\n * are serialised as:\n *\n * ```html\n * <my-element attr=\"val\">\n * <template shadowrootmode=\"open\">\n * <style>\n * /* baseReset + useStyle() output + JIT utility CSS *\\/\n * </style>\n * <!-- shadow DOM from component render function -->\n * </template>\n * <!-- light DOM / slotted children from vnode.children -->\n * </my-element>\n * ```\n *\n * The browser parses the `<template shadowrootmode=\"open\">` block and attaches\n * a real shadow root before any JavaScript executes. All CSS layers are present\n * at first paint — eliminating both FOUC and layout shift.\n *\n * Non-custom-element VNodes are rendered identically to renderToString() but\n * with DSD recursion active for any custom elements nested inside them.\n */\n\nimport type { VNode } from './types';\nimport { renderToString } from './vdom-ssr';\nimport { VOID_ELEMENTS, buildAttrs, buildRawAttrs, type RenderOptions } from './ssr-utils';\nimport { registry } from './component/registry';\nimport { runComponentSSRRender } from './ssr-context';\nimport { jitCSS } from './style';\nimport { baseReset, minifyCSS } from './css-utils';\nimport { escapeHTML } from './helpers';\nimport { devWarn } from './logger';\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\nexport type DSDRenderOptions = RenderOptions & {\n /**\n * Emit Declarative Shadow DOM output for registered custom elements.\n * Shadow content is serialised inside `<template shadowrootmode=\"open\">`,\n * with a complete CSS layer stack (`baseReset` + `useStyle` + JIT CSS)\n * injected as a `<style>` block so styles are available at first paint.\n * @default false\n */\n dsd?: boolean;\n /**\n * Append the DSD polyfill `<script>` for browsers without native support\n * (Firefox < 123). Only meaningful when `dsd` is true.\n * @default true\n */\n dsdPolyfill?: boolean;\n /**\n * Router instance to thread through each component's SSR context.\n *\n * When provided, `router-view` reads the current route from this instance\n * instead of the module-level `activeRouterProxy` singleton, making\n * concurrent SSR renders safe — each request carries its own router with\n * its own URL state.\n *\n * In browser mode this option is ignored; components always use\n * `activeRouterProxy` there.\n */\n router?: unknown;\n};\n\n// ---------------------------------------------------------------------------\n// Constants\n// ---------------------------------------------------------------------------\n\n/**\n * @internal\n * Minified DSD polyfill for browsers without native Declarative Shadow DOM.\n * Processes all `<template shadowrootmode>` elements synchronously.\n */\nexport const DSD_POLYFILL_SCRIPT =\n '<script>(function(){' +\n \"if(HTMLTemplateElement.prototype.hasOwnProperty('shadowRootMode'))return;\" +\n \"document.querySelectorAll('template[shadowrootmode]').forEach(function(t){\" +\n \"var m=t.getAttribute('shadowrootmode');\" +\n 'var s=t.parentElement.attachShadow({mode:m});' +\n 's.appendChild(t.content);t.remove();' +\n '});})()' +\n '</script>';\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\nfunction isRegisteredCustomElement(tag: string): boolean {\n return tag.includes('-') && registry.has(tag);\n}\n\n/**\n * Build the combined `<style>` block for a shadow root.\n *\n * Layer order (matches the runtime adoptedStyleSheets order):\n * 1. baseReset — global reset + CSS custom properties\n * 2. useStyle() output — component-defined rules (:host, ::slotted, etc.)\n * 3. JIT CSS — utility classes extracted from the shadow HTML\n */\nexport function buildShadowStyleBlock(\n useStyleCSS: string,\n shadowHTML: string,\n): string {\n const parts: string[] = [baseReset];\n\n if (useStyleCSS.trim()) {\n parts.push(useStyleCSS);\n }\n\n const jit = jitCSS(shadowHTML);\n if (jit.trim()) {\n parts.push(jit);\n }\n\n const combined = minifyCSS(parts.join('\\n'));\n return combined ? `<style>${combined}</style>` : '';\n}\n\n// ---------------------------------------------------------------------------\n// Streaming async component collector\n// ---------------------------------------------------------------------------\n\nexport interface AsyncStreamEntry {\n id: string;\n tag: string;\n attrsString: string;\n hydrateAttr: string;\n useStyleCSS: string;\n lightDOM: string;\n opts: DSDRenderOptions;\n promise: Promise<VNode | VNode[]>;\n /** Router threaded from the originating render pass — propagated to async re-renders. */\n router?: unknown;\n}\n\nlet _streamingCollector: AsyncStreamEntry[] | null = null;\nlet _streamingCounter = 0;\n\n/** @internal Called by renderToStream() before the sync render pass. */\nexport function beginStreamingCollection(collector: AsyncStreamEntry[]): void {\n _streamingCollector = collector;\n _streamingCounter = 0;\n}\n\n/** @internal Called by renderToStream() after the sync render pass. */\nexport function endStreamingCollection(): void {\n _streamingCollector = null;\n}\n\n// ---------------------------------------------------------------------------\n// Core renderer\n// ---------------------------------------------------------------------------\n\n/**\n * Render a VNode tree to an HTML string with Declarative Shadow DOM output\n * for all registered custom elements encountered in the tree.\n */\nexport function renderToDSD(vnode: VNode, opts: DSDRenderOptions): string {\n if (!opts.dsd) {\n return renderToString(vnode, opts);\n }\n\n // Primitive string nodes\n if (typeof vnode === 'string') {\n return escapeHTML(vnode) as string;\n }\n\n const tag = (vnode as VNode).tag;\n\n // Special virtual node types — delegate entirely to the base renderer\n if (tag === '#text' || tag === '#anchor' || tag === '#raw') {\n return renderToString(vnode, opts);\n }\n\n // Custom element — emit DSD wrapper\n if (isRegisteredCustomElement(tag)) {\n return renderCustomElementDSD(vnode, opts);\n }\n\n // Regular element — recurse with DSD mode on\n const attrsObj: Record<string, unknown> = vnode.props?.attrs\n ? { ...vnode.props.attrs }\n : {};\n\n const attrsString = buildAttrs(attrsObj, tag, opts);\n\n if (VOID_ELEMENTS.has(tag)) {\n return `<${tag}${attrsString}>`;\n }\n\n const children = renderChildrenDSD(vnode.children, opts);\n return `<${tag}${attrsString}>${children}</${tag}>`;\n}\n\nfunction renderCustomElementDSD(vnode: VNode, opts: DSDRenderOptions): string {\n const tag = vnode.tag;\n const config = registry.get(tag);\n\n // Build the plain attribute string (no namespace injection for custom elements)\n const rawAttrs = vnode.props?.attrs ?? {};\n const attrsString = buildRawAttrs(rawAttrs);\n\n // Move the null check BEFORE reading config.* properties for clarity.\n if (!config) {\n // Component not in registry on server (e.g. dynamic import not yet run).\n // Emit a shell with an empty DSD template so the client hydrates normally.\n const lightDOM = renderChildrenDSD(vnode.children, opts);\n return `<${tag}${attrsString}><template shadowrootmode=\"open\"></template>${lightDOM}</${tag}>`;\n }\n\n // Emit data-cer-hydrate when a non-default strategy is configured.\n // 'load' is the default and doesn't need to be serialised.\n const hydrateStrategy = config.hydrate;\n const hydrateAttr =\n hydrateStrategy && hydrateStrategy !== 'load'\n ? ` data-cer-hydrate=\"${hydrateStrategy}\"`\n : '';\n\n // Run the component's render function in a minimal SSR context to get the\n // shadow DOM VNode tree and capture any useStyle() output.\n const { shadowVNode, useStyleCSS, asyncPromise } = runComponentSSRRender(config, rawAttrs, tag, opts.router);\n\n // When streaming and this component has an async render, emit a placeholder\n // and register the promise for later resolution.\n if (asyncPromise && _streamingCollector === null) {\n devWarn(\n `[SSR] Component \"${tag}\" has an async render function. ` +\n `In standard SSR the shadow DOM will be empty. ` +\n `Use renderToStream() for incremental async component streaming.`,\n );\n }\n if (asyncPromise && _streamingCollector !== null) {\n const id = `cer-stream-${_streamingCounter++}`;\n const lightDOM = renderChildrenDSD(vnode.children, opts);\n _streamingCollector.push({\n id,\n tag,\n attrsString,\n hydrateAttr,\n useStyleCSS,\n lightDOM,\n opts,\n promise: asyncPromise,\n router: opts.router,\n });\n return (\n `<${tag} id=\"${id}\"${attrsString}${hydrateAttr}>` +\n `<template shadowrootmode=\"open\"></template>` +\n `${lightDOM}` +\n `</${tag}>`\n );\n }\n\n // Render the shadow DOM VNode tree to HTML (DSD-recursive for nested elements)\n let shadowHTML = '';\n if (shadowVNode !== null && shadowVNode !== undefined) {\n if (Array.isArray(shadowVNode)) {\n shadowHTML = (shadowVNode as VNode[])\n .map((n) => renderToDSD(n, opts))\n .join('');\n } else {\n shadowHTML = renderToDSD(shadowVNode as VNode, opts);\n }\n }\n\n const styleBlock = buildShadowStyleBlock(useStyleCSS, shadowHTML);\n\n // Light DOM children become slotted content — rendered outside the template\n const lightDOM = renderChildrenDSD(vnode.children, opts);\n\n return (\n `<${tag}${attrsString}${hydrateAttr}>` +\n `<template shadowrootmode=\"open\">${styleBlock}${shadowHTML}</template>` +\n `${lightDOM}` +\n `</${tag}>`\n );\n}\n\nfunction renderChildrenDSD(\n children: VNode['children'],\n opts: DSDRenderOptions,\n): string {\n if (!children) return '';\n if (typeof children === 'string') return escapeHTML(children) as string;\n if (Array.isArray(children)) {\n return children\n .filter((c) => c !== null && c !== undefined)\n .map((c) => renderToDSD(c as VNode, opts))\n .join('');\n }\n return renderToDSD(children as VNode, opts);\n}\n\n// ---------------------------------------------------------------------------\n// Public entry points\n// ---------------------------------------------------------------------------\n\n/**\n * Render a VNode tree to a DSD HTML string and optionally append the\n * DSD polyfill script for older browsers.\n */\nexport function renderToStringDSD(\n vnode: VNode,\n opts?: DSDRenderOptions,\n): string {\n const effectiveOpts: DSDRenderOptions = { dsd: true, ...opts };\n const html = renderToDSD(vnode, effectiveOpts);\n\n if (effectiveOpts.dsdPolyfill !== false) {\n // Inject polyfill before </body> if present, otherwise append\n if (html.includes('</body>')) {\n return html.replace('</body>', `${DSD_POLYFILL_SCRIPT}</body>`);\n }\n return html + DSD_POLYFILL_SCRIPT;\n }\n\n return html;\n}\n","/**\n * SSR entry point — import from `@jasonshimmy/custom-elements-runtime/ssr`.\n *\n * Provides four rendering modes:\n *\n * 1. **renderToString** — baseline HTML serialisation (no shadow DOM content).\n * Backwards-compatible with the original API.\n *\n * 2. **renderToStringWithJITCSS** — HTML + pre-generated JIT CSS injected into\n * `<head>` to prevent FOUC. Supports `dsd: true` for DSD output.\n *\n * 3. **renderToStringWithJITCSSDSD** — convenience alias for DSD mode.\n * Full Declarative Shadow DOM output with per-shadow-root CSS layer stack\n * (baseReset + useStyle() + JIT CSS). Enables true hydration, zero FOUC.\n *\n * 4. **renderToStream** — ReadableStream variant for streaming SSR.\n *\n * 5. **renderToStreamWithJITCSSDSD** — convenience alias for streaming DSD mode.\n * Equivalent to `renderToStream(vnode, { dsd: true, ...options })`.\n * Recommended for new server-rendered applications that want true incremental\n * streaming with Declarative Shadow DOM and zero FOUC.\n *\n * Entity map utilities are also exported for full HTML5 named-entity support.\n *\n * @example DSD usage (recommended)\n * ```ts\n * import { renderToStringWithJITCSSDSD } from '@jasonshimmy/custom-elements-runtime/ssr';\n *\n * const { htmlWithStyles } = renderToStringWithJITCSSDSD(appVNode, {\n * jit: { extendedColors: true },\n * });\n * res.send(`<!DOCTYPE html><html><head>${head}</head><body>${htmlWithStyles}</body></html>`);\n * ```\n */\n\n// ---------------------------------------------------------------------------\n// Re-exports — backwards-compatible\n// ---------------------------------------------------------------------------\n\nexport { renderToString } from './runtime/vdom-ssr';\nexport type { VNode } from './runtime/types';\nexport type { RenderOptions } from './runtime/vdom-ssr';\n\nexport {\n registerEntityMap,\n loadEntityMap,\n clearRegisteredEntityMap,\n} from './runtime/helpers';\n\nexport {\n renderToStringDSD,\n DSD_POLYFILL_SCRIPT,\n} from './runtime/vdom-ssr-dsd';\nexport type { DSDRenderOptions } from './runtime/vdom-ssr-dsd';\n\n// ---------------------------------------------------------------------------\n// Internal imports\n// ---------------------------------------------------------------------------\n\nimport { renderToString as _render } from './runtime/vdom-ssr';\nimport {\n renderToStringDSD as _renderToStringDSD,\n renderToDSD,\n buildShadowStyleBlock,\n beginStreamingCollection,\n endStreamingCollection,\n DSD_POLYFILL_SCRIPT,\n type AsyncStreamEntry,\n} from './runtime/vdom-ssr-dsd';\nimport { jitCSS, enableJITCSS, type JITCSSOptions } from './runtime/style';\nimport type { VNode } from './runtime/types';\nimport type { RenderOptions } from './runtime/vdom-ssr';\nimport type { DSDRenderOptions } from './runtime/vdom-ssr-dsd';\nimport {\n beginSSRGlobalStyleCollection,\n endSSRGlobalStyleCollection,\n} from './runtime/ssr-context';\n\n// ---------------------------------------------------------------------------\n// Result type\n// ---------------------------------------------------------------------------\n\n/**\n * Result of `renderToStringWithJITCSS()` and `renderToStringWithJITCSSDSD()`.\n */\nexport interface SSRJITResult {\n /** The rendered HTML string (styles not yet injected). */\n html: string;\n /**\n * Global JIT CSS extracted from the rendered HTML.\n * For DSD renders, each shadow root embeds its own scoped styles; this field\n * holds any residual light-DOM utility CSS.\n */\n css: string;\n /**\n * CSS captured from `useGlobalStyle()` calls during this render pass\n * (e.g. `@font-face`, `:root` custom properties).\n * Inject in a `<style id=\"cer-ssr-global\">` in `<head>`.\n */\n globalStyles: string;\n /**\n * Convenience: `html` with both `<style>` tags injected before `</head>`.\n * If no `</head>` is found, the styles are prepended.\n */\n htmlWithStyles: string;\n}\n\n// ---------------------------------------------------------------------------\n// renderToStringWithJITCSS — primary API, supports both modes\n// ---------------------------------------------------------------------------\n\n/**\n * Server-side render a VNode tree and simultaneously pre-generate JIT CSS.\n *\n * Pass `dsd: true` to enable Declarative Shadow DOM output with full per-shadow-\n * root CSS layer extraction (recommended for new apps).\n *\n * @example Standard (no DSD)\n * ```ts\n * const { htmlWithStyles } = renderToStringWithJITCSS(appVNode);\n * ```\n *\n * @example With DSD\n * ```ts\n * const { htmlWithStyles } = renderToStringWithJITCSS(appVNode, {\n * dsd: true,\n * jit: { extendedColors: true },\n * });\n * ```\n */\nexport function renderToStringWithJITCSS(\n vnode: VNode,\n options?: RenderOptions & DSDRenderOptions & { jit?: JITCSSOptions },\n): SSRJITResult {\n const { jit, dsd, dsdPolyfill, ...renderOptions } = options ?? {};\n\n if (jit) enableJITCSS(jit);\n\n beginSSRGlobalStyleCollection();\n\n let html!: string;\n let globalStylesCaptured!: string[];\n try {\n if (dsd) {\n // renderToStringDSD handles DSD wrapping but skips the polyfill so we can\n // place it correctly relative to other injected style tags below.\n html = _renderToStringDSD(vnode, {\n ...renderOptions,\n dsd: true,\n dsdPolyfill: false,\n });\n } else {\n html = _render(vnode, renderOptions);\n }\n } finally {\n // Always end collection — even when the render throws — so the collector\n // is never left non-null, which would cause subsequent non-SSR\n // useGlobalStyle() calls to silently skip DOM injection.\n globalStylesCaptured = endSSRGlobalStyleCollection();\n }\n\n const css = jitCSS(html);\n const globalStyles = globalStylesCaptured.join('\\n');\n\n const styleTags: string[] = [];\n if (css) styleTags.push(`<style id=\"cer-ssr-jit\">${css}</style>`);\n if (globalStyles.trim())\n styleTags.push(`<style id=\"cer-ssr-global\">${globalStyles}</style>`);\n\n let htmlWithStyles = html;\n if (styleTags.length) {\n const injection = styleTags.join('');\n htmlWithStyles = html.includes('</head>')\n ? html.replace('</head>', `${injection}</head>`)\n : `${injection}${html}`;\n }\n\n // Append DSD polyfill script inside </body> when in DSD mode\n if (dsd && dsdPolyfill !== false) {\n htmlWithStyles = htmlWithStyles.includes('</body>')\n ? htmlWithStyles.replace('</body>', `${DSD_POLYFILL_SCRIPT}</body>`)\n : htmlWithStyles + DSD_POLYFILL_SCRIPT;\n }\n\n return { html, css, globalStyles, htmlWithStyles };\n}\n\n// ---------------------------------------------------------------------------\n// renderToStringWithJITCSSDSD — convenience alias\n// ---------------------------------------------------------------------------\n\n/**\n * Convenience alias: `renderToStringWithJITCSS(vnode, { dsd: true, ...options })`.\n *\n * Renders with Declarative Shadow DOM output, full per-shadow-root CSS layer\n * extraction, and the DSD browser polyfill. This is the recommended function\n * for all new server-rendered applications.\n *\n * @example\n * ```ts\n * import { renderToStringWithJITCSSDSD } from '@jasonshimmy/custom-elements-runtime/ssr';\n *\n * const { htmlWithStyles } = renderToStringWithJITCSSDSD(appVNode, {\n * jit: { extendedColors: true },\n * });\n * ```\n */\nexport function renderToStringWithJITCSSDSD(\n vnode: VNode,\n options?: Omit<\n RenderOptions & DSDRenderOptions & { jit?: JITCSSOptions },\n 'dsd'\n >,\n): SSRJITResult {\n return renderToStringWithJITCSS(vnode, { ...options, dsd: true });\n}\n\n// ---------------------------------------------------------------------------\n// renderToStream — streaming SSR\n// ---------------------------------------------------------------------------\n\n/**\n * Render a VNode tree to a `ReadableStream<string>`.\n *\n * Supports true incremental streaming: synchronous components are flushed as\n * the first chunk, then each async component's resolved output is streamed as\n * an inline swap `<script>` that fills the placeholder's shadow root.\n *\n * @example Node.js\n * ```ts\n * import { renderToStream } from '@jasonshimmy/custom-elements-runtime/ssr';\n *\n * app.get('/', (req, res) => {\n * const stream = renderToStream(appVNode, { dsd: true });\n * const reader = stream.getReader();\n * const pump = () =>\n * reader.read().then(({ value, done }) => {\n * if (done) { res.end(); return; }\n * res.write(value);\n * pump();\n * });\n * pump();\n * });\n * ```\n */\nexport function renderToStream(\n vnode: VNode,\n options?: RenderOptions & DSDRenderOptions & { jit?: JITCSSOptions; asyncTimeout?: number },\n): ReadableStream<string> {\n const timeoutMs = options?.asyncTimeout ?? 30_000;\n\n return new ReadableStream<string>({\n async start(controller) {\n const asyncEntries: AsyncStreamEntry[] = [];\n beginStreamingCollection(asyncEntries);\n\n try {\n const { htmlWithStyles } = renderToStringWithJITCSS(vnode, options);\n controller.enqueue(htmlWithStyles);\n } catch (err) {\n controller.error(err);\n return;\n } finally {\n endStreamingCollection();\n }\n\n // Resolve async components and stream swap scripts as they settle.\n // Each resolved component replaces its placeholder via an inline script.\n // A per-entry timeout prevents hung async components from blocking the stream.\n for (const entry of asyncEntries) {\n try {\n const timeout = new Promise<never>((_, reject) =>\n setTimeout(() => reject(new Error(`[cer] async component timed out after ${timeoutMs}ms`)), timeoutMs),\n );\n const resolvedVNodes = await Promise.race([entry.promise, timeout]);\n const shadowHTML = Array.isArray(resolvedVNodes)\n ? (resolvedVNodes as VNode[]).map((n) => renderToDSD(n, entry.opts)).join('')\n : renderToDSD(resolvedVNodes as VNode, entry.opts);\n const styleBlock = buildShadowStyleBlock(entry.useStyleCSS, shadowHTML);\n const shadowContent = `${styleBlock}${shadowHTML}`;\n controller.enqueue(\n `<script>(function(){` +\n `var e=document.getElementById(${JSON.stringify(entry.id)});` +\n `if(!e)return;` +\n // The placeholder already has an empty shadow root attached (native DSD or polyfill).\n // If for some reason it doesn't, attach one now.\n `var s=e.shadowRoot;` +\n `if(!s&&e.attachShadow)try{s=e.attachShadow({mode:'open'});}catch(_){};` +\n `if(s)s.innerHTML=${JSON.stringify(shadowContent)};` +\n `e.removeAttribute('id');` +\n `})();</script>`,\n );\n } catch {\n // Async render failed — leave placeholder for client hydration.\n }\n }\n\n controller.close();\n },\n });\n}\n\n// ---------------------------------------------------------------------------\n// renderToStreamWithJITCSSDSD — convenience alias\n// ---------------------------------------------------------------------------\n\n/**\n * Convenience alias: `renderToStream(vnode, { dsd: true, ...options })`.\n *\n * Renders with Declarative Shadow DOM output and full JIT CSS extraction,\n * streaming the synchronous render as the first chunk and each resolved async\n * component as a subsequent inline-script swap. This is the recommended\n * function for all new server-rendered applications.\n *\n * @example\n * ```ts\n * import { renderToStreamWithJITCSSDSD } from '@jasonshimmy/custom-elements-runtime/ssr';\n *\n * app.get('/', (req, res) => {\n * const stream = renderToStreamWithJITCSSDSD(appVNode, { router });\n * const reader = stream.getReader();\n * const pump = () =>\n * reader.read().then(({ value, done }) => {\n * if (done) { res.end(); return; }\n * res.write(value);\n * pump();\n * });\n * pump();\n * });\n * ```\n */\nexport function renderToStreamWithJITCSSDSD(\n vnode: VNode,\n options?: Omit<\n RenderOptions & DSDRenderOptions & { jit?: JITCSSOptions; asyncTimeout?: number },\n 'dsd'\n >,\n): ReadableStream<string> {\n return renderToStream(vnode, { ...options, dsd: true });\n}\n"],"mappings":";;;;;;;AAcA,IAAa,IAAgB,IAAI,IAAI;CACnC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD,CAAC;AAEF,SAAgB,EACd,GACA,GACA,GACQ;CACR,IAAM,IAAS,EAAK,sBAAsB,IACpC,IAAc,EAAK,yBAAyB,GAC5C,IAAS,EAAE,GAAG,GAAO;AAQ3B,QANI,KAAU,MAAQ,SAAS,EAAE,WAAW,KAC1C,EAAO,QAAW,IACT,KAAe,KAAO,KAAqB,EAAE,WAAW,OACjE,EAAO,QAAW,EAAkB,KAG/B,OAAO,QAAQ,EAAO,CAC1B,KAAK,CAAC,GAAG,OAAO,IAAI,EAAE,IAAI,EAAW,OAAO,EAAE,CAAC,CAAC,GAAG,CACnD,KAAK,GAAG;;AAGb,SAAgB,EAAc,GAAwC;AACpE,QAAO,OAAO,QAAQ,EAAM,CACzB,KAAK,CAAC,GAAG,OAAO,IAAI,EAAE,IAAI,EAAW,OAAO,EAAE,CAAC,CAAC,GAAG,CACnD,KAAK,GAAG;;;;ACzCb,SAAgB,EAAe,GAAc,GAA8B;AACzE,KAAI,OAAO,KAAU,SAAU,QAAO,EAAW,EAAM;AAEvD,KAAI,EAAM,QAAQ,QAChB,QAAO,OAAO,EAAM,YAAa,WAC5B,EAAW,EAAM,SAAS,GAC3B;AAGN,KAAI,EAAM,QAAQ,UAQhB,SAHiB,MAAM,QAAQ,EAAM,SAAS,GAC1C,EAAM,SAAS,QAAQ,MAAM,KAAM,KAAwB,GAC3D,EAAE,EACU,KAAK,MAAM,EAAe,GAAG,EAAK,CAAC,CAAC,KAAK,GAAG;AAG9D,KAAI,EAAM,QAAQ,OAChB,QAAO,OAAO,EAAM,YAA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AAM,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require(`./helpers-
|
|
2
|
-
//# sourceMappingURL=tag-utils-
|
|
1
|
+
const e=require(`./helpers-BQ37xfhc.cjs`);function t(t){let n=e.p(t);return n.includes(`-`)?n:`cer-${n}`}Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return t}});
|
|
2
|
+
//# sourceMappingURL=tag-utils-BiaxgxbY.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tag-utils-
|
|
1
|
+
{"version":3,"file":"tag-utils-BiaxgxbY.cjs","names":[],"sources":["../src/lib/runtime/tag-utils.ts"],"sourcesContent":["import { toKebab } from './helpers';\n\n/**\n * Resolves a component() tag argument to the actual registered tag name.\n * Single source of truth used by both factory.ts (runtime) and\n * vite-plugin.ts (build time) so the two can never drift apart.\n *\n * Rules:\n * camelCase → kebab-case (myButton → my-button)\n * no hyphen → cer- prefix (app → cer-app)\n * has hyphen → unchanged (ks-badge → ks-badge)\n */\nexport function resolveTagName(name: string): string {\n const kebab = toKebab(name);\n return kebab.includes('-') ? kebab : `cer-${kebab}`;\n}\n"],"mappings":"0CAYA,SAAgB,EAAe,EAAsB,CACnD,IAAM,EAAQ,EAAA,EAAQ,EAAK,CAC3B,OAAO,EAAM,SAAS,IAAI,CAAG,EAAQ,OAAO"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { p as e } from "./helpers-
|
|
1
|
+
import { p as e } from "./helpers-llht6g11.js";
|
|
2
2
|
//#region src/lib/runtime/tag-utils.ts
|
|
3
3
|
function t(t) {
|
|
4
4
|
let n = e(t);
|
|
@@ -7,4 +7,4 @@ function t(t) {
|
|
|
7
7
|
//#endregion
|
|
8
8
|
export { t };
|
|
9
9
|
|
|
10
|
-
//# sourceMappingURL=tag-utils-
|
|
10
|
+
//# sourceMappingURL=tag-utils-DMHsC8t3.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tag-utils-
|
|
1
|
+
{"version":3,"file":"tag-utils-DMHsC8t3.js","names":[],"sources":["../src/lib/runtime/tag-utils.ts"],"sourcesContent":["import { toKebab } from './helpers';\n\n/**\n * Resolves a component() tag argument to the actual registered tag name.\n * Single source of truth used by both factory.ts (runtime) and\n * vite-plugin.ts (build time) so the two can never drift apart.\n *\n * Rules:\n * camelCase → kebab-case (myButton → my-button)\n * no hyphen → cer- prefix (app → cer-app)\n * has hyphen → unchanged (ks-badge → ks-badge)\n */\nexport function resolveTagName(name: string): string {\n const kebab = toKebab(name);\n return kebab.includes('-') ? kebab : `cer-${kebab}`;\n}\n"],"mappings":";;AAYA,SAAgB,EAAe,GAAsB;CACnD,IAAM,IAAQ,EAAQ,EAAK;AAC3B,QAAO,EAAM,SAAS,IAAI,GAAG,IAAQ,OAAO"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const e=require(`./logger-Dkht1dCX.cjs`),t=require(`./namespace-helpers-yYIb7INq.cjs`),n=require(`./helpers-BQ37xfhc.cjs`),r=require(`./css-utils-CFeP8SK1.cjs`),i=require(`./custom-elements-runtime.directives.cjs.js`),a=require(`./custom-elements-runtime.transitions.cjs.js`),o=require(`./tag-utils-BiaxgxbY.cjs`),s=require(`./hooks-DTyLoDNI.cjs`);function c(t,r,i){if(i)for(let[a,o]of Object.entries(i)){let i,s={};if(Array.isArray(o)?(i=o[0],s=o[1]||{}):i=o,r.set(a,{callback:i,options:s,oldValue:n.i(t,a)}),s.immediate)try{let e=n.i(t,a);i(e,void 0,t)}catch(t){e.t(`Error in immediate watcher for "${a}":`,t)}}}function l(t,r,i,a){let o=(e,t)=>{if(e===t)return!0;if(typeof e!=typeof t||typeof e!=`object`||!e||t===null)return!1;if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length?e.every((e,n)=>o(e,t[n])):!1;let n=e,r=t,i=Object.keys(n||{}),a=Object.keys(r||{});return i.length===a.length?i.every(e=>o(n[e],r[e])):!1},s=r.get(i);if(s&&!o(a,s.oldValue))try{s.callback(a,s.oldValue,t),s.oldValue=a}catch(t){e.t(`Error in watcher for "${i}":`,t)}for(let[a,s]of r.entries())if(s.options.deep&&i.startsWith(a+`.`))try{let e=n.i(t,a);o(e,s.oldValue)||(s.callback(e,s.oldValue,t),s.oldValue=e)}catch(t){e.t(`Error in deep watcher for "${a}":`,t)}}function u(e,t){return t===Boolean?e===``||e===`true`:t===Number?Number(e):e}var d=Symbol.for(`@cer/usePropsState`);function f(e){if(!e)return;let t=e[d];if(t)for(let[n,r]of t.entries())try{let t=e[n];Object.is(r.peek(),t)||(r.value=t)}catch{}}function p(e,t,r){if(t)for(let i in t){let a=t[i],o=n.p(i),s=e.getAttribute(o);if(a.type===Function&&typeof e[i]==`function`)r[i]=e[i];else if(s!==null)r[i]=u(s,a.type);else if(e[i]!==void 0)try{let t=e[i];if(a.type===String&&t&&typeof t==`object`)try{r[i]=u(String(t),a.type)}catch{r[i]=t}else a.type===Boolean&&typeof t==`boolean`||a.type===Number&&typeof t==`number`||a.type===Function&&typeof t==`function`?r[i]=t:r[i]=u(String(t),a.type)}catch{r[i]=e[i]}else `default`in a&&a.default!==void 0&&(r[i]=a.default)}}function m(e,t,r){if(!t.props){try{let t=r?._hookCallbacks?.props||{},i=Array.from(new Set([...Object.keys(e||{}),...Object.keys(t||{})]));for(let a of i){if(typeof a!=`string`||a.startsWith(`_`))continue;let i=Object.getOwnPropertyDescriptor(r,a);if(!(!Object.prototype.hasOwnProperty.call(t,a)&&i&&(i.get||i.set||!i.configurable)))try{Object.defineProperty(r,a,{enumerable:!0,configurable:!0,get(){try{let t=n.p(a),r=e.getAttribute(t);if(r!==null)return r;let i=e[a],o;return o=n._(i)||i&&typeof i==`object`&&`value`in i&&!(typeof Node<`u`&&i instanceof Node)?i.value:i,o}catch{return e[a]}}})}catch{}}}catch{}f(r);return}p(e,t.props,r),f(r)}function h(e,t,n,r){e.onConnected&&!n&&(e.onConnected(t),r(!0))}function g(e,t,n,r,i,a,o,s){e.onDisconnected&&e.onDisconnected(t),n.forEach(e=>e()),r(),i(),a(!1),o(null),s(!1)}function _(e,t,n,r,i){e.onAttributeChanged&&e.onAttributeChanged(t,n,r,i)}var v=class{static cleanupFunctions=new WeakMap;static addListener(e,t,n,r){e.addEventListener(t,n,r);let i={event:t,handler:n,wrapper:n,options:r,cleanup:()=>e.removeEventListener(t,n,r),addedAt:Date.now()};this.cleanupFunctions.has(e)||this.cleanupFunctions.set(e,[]),this.cleanupFunctions.get(e).push(i)}static removeListener(e,t,n,r){e.removeEventListener(t,n,r);let i=this.cleanupFunctions.get(e);if(i)for(let r=0;r<i.length;r++){let a=i[r];if(a.event===t&&a.handler===n){i.splice(r,1),i.length===0&&this.cleanupFunctions.delete(e);return}}}static cleanup(e){let t=this.cleanupFunctions.get(e);t&&(t.forEach(e=>{try{e.cleanup()}catch{}}),this.cleanupFunctions.delete(e))}static cleanupAll(){this.cleanupFunctions=new WeakMap}static hasListeners(e){let t=this.cleanupFunctions.get(e);return!!(t&&t.length>0)}static getListenerCount(e){let t=this.cleanupFunctions.get(e);return t?t.length:0}static getListenerInfo(e){let t=this.cleanupFunctions.get(e);return t?t.map(e=>({event:e.event,handler:e.handler,wrapper:e.wrapper,options:e.options})):[]}},y=class{map=new Map;maxSize;constructor(e){this.maxSize=Math.max(1,e)}get(e){let t=this.map.get(e);if(t!==void 0)return this.map.delete(e),this.map.set(e,t),t}set(e,t){if(this.map.has(e)&&this.map.delete(e),this.map.set(e,t),this.map.size>this.maxSize){let e=this.map.keys().next().value;this.map.delete(e)}}has(e){return this.map.has(e)}clear(){this.map.clear()}get size(){return this.map.size}},b=new y((()=>{if(typeof navigator<`u`&&`deviceMemory`in navigator){let e=navigator.deviceMemory;if(e)return Math.min(1e3,Math.max(200,e*100))}return(()=>{try{return globalThis.process?.env?.NODE_ENV===`test`}catch{return!1}})()?100:500})()),x=new Set(`true.false.null.undefined.typeof.instanceof.in.of.new.delete.void.throw.return.this.class.extends.import.export.from.as.async.await.yield.if.else.for.while.do.switch.case.break.continue.try.catch.finally.let.const.var.function.NaN.Infinity`.split(`.`)),ee=class{static cache=new y(1e3);static dangerousPatterns=[/constructor/i,/prototype/i,/__proto__/i,/\bfunction\b/i,/eval/i,/import/i,/require/i,/window/i,/document/i,/global/i,/process/i,/setTimeout/i,/setInterval/i,/fetch/i,/XMLHttpRequest/i];static evaluate(t,n){let r=this.cache.get(t);if(r){if(!r.isSecure){e.r(`Blocked cached dangerous expression:`,t);return}return r.evaluator(n)}let i=this.createEvaluator(t);if(this.cache.set(t,i),!i.isSecure){e.r(`Blocked dangerous expression:`,t);return}return i.evaluator(n)}static createEvaluator(t){if(this.hasDangerousPatterns(t)||t.length>1e3)return{evaluator:()=>void 0,isSecure:!1};try{return{evaluator:this.createSafeEvaluator(t),isSecure:!0}}catch(n){return e.r(`Failed to create evaluator for expression:`,t,n),{evaluator:()=>void 0,isSecure:!1}}}static hasDangerousPatterns(e){return this.dangerousPatterns.some(t=>t.test(e))}static createSafeEvaluator(e){let t=e.trim();if(t.startsWith(`{`)&&t.endsWith(`}`))return this.createObjectEvaluator(e);if(/^ctx\.[a-zA-Z0-9_.]+$/.test(e.trim())){let t=e.trim().slice(4);return e=>n.i(e,t)}return e.includes(`ctx`)||/[+\-*/%<>=&|?:[\]]/.test(e)?this.createSimpleEvaluator(e):t=>n.i(t,e)}static createObjectEvaluator(e){let t=e.trim().slice(1,-1),r=this.parseObjectProperties(t);return e=>{let t={};for(let{key:i,value:a}of r)try{a.startsWith(`ctx.`)?t[i]=n.i(e,a.slice(4)):t[i]=this.evaluateSimpleValue(a,e)}catch{t[i]=void 0}return t}}static parseObjectProperties(e){let t=[],n=[],r=0,i=null,a=0;for(let t=0;t<e.length;t++){let o=e[t];if(i){if(o===`\\`){t++;continue}o===i&&(i=null)}else o===`"`||o===`'`?i=o:o===`(`||o===`[`||o===`{`?r++:o===`)`||o===`]`||o===`}`?r--:o===`,`&&r===0&&(n.push(e.slice(a,t)),a=t+1)}n.push(e.slice(a));for(let e of n){let n=-1,r=0,i=null;for(let t=0;t<e.length;t++){let a=e[t];if(i){if(a===`\\`){t++;continue}a===i&&(i=null)}else if(a===`"`||a===`'`)i=a;else if(a===`(`||a===`[`||a===`{`)r++;else if(a===`)`||a===`]`||a===`}`)r--;else if(a===`:`&&r===0){n=t;break}}if(n===-1)continue;let a=e.slice(0,n).trim(),o=e.slice(n+1).trim(),s=a.replace(/^['"]|['"]$/g,``);t.push({key:s,value:o})}return t}static createSimpleEvaluator(e){return t=>{try{let r=e,i=[];r=r.replace(/("[^"\\]*(?:\\.[^"\\]*)*"|'[^'\\]*(?:\\.[^'\\]*)*')/g,e=>`<<#${i.push(e)-1}#>>`);let a=r.match(/ctx\.[\w.]+/g)||[];for(let e of a){let a=n.i(t,e.slice(4));if(a===void 0)return;let o=i.push(JSON.stringify(a))-1;r=r.split(e).join(`<<#${o}#>>`)}let o=r.match(/\b[a-zA-Z_][a-zA-Z0-9_]*(?:\.[a-zA-Z_][a-zA-Z0-9_]*)+\b/g)||[];for(let e of o){if(e.startsWith(`ctx.`))continue;let a=n.i(t,e);if(a===void 0)return;let o=i.push(JSON.stringify(a))-1;r=r.split(e).join(`<<#${o}#>>`)}let s=/\b([a-zA-Z_][a-zA-Z0-9_]*)\b/g,c,l=new Set;for(;(c=s.exec(r))!==null;){let e=c[1];if(x.has(e)||/^[0-9]+$/.test(e)||e===`ctx`||l.has(e))continue;l.add(e);let a=n.i(t,e);if(a===void 0)return;let o=JSON.stringify(a),u=i.push(o)-1;r=e.includes(`.`)?r.split(e).join(`<<#${u}#>>`):r.replace(RegExp(`\\b`+e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)+`\\b`,`g`),`<<#${u}#>>`),s.lastIndex=0}r=r.replace(/<<#(\d+)#>>/g,(e,t)=>i[Number(t)]);try{return this.evaluateBasicExpression(r)}catch{return}}catch{return}}}static evaluateBasicExpression(e){let t=this.tokenize(e),n=0;function r(){return t[n]}function i(e){let r=t[n++];if(e&&!r)throw Error(`Unexpected token EOF, expected ${e}`);if(e&&r&&r.type!==e&&r.value!==e)throw Error(`Unexpected token ${r.type}/${r.value}, expected ${e}`);return r}function a(){return p()}function o(e){if(typeof e==`number`)return e;if(e==null)return NaN;if(typeof e==`boolean`)return e?1:0;let t=Number(e);return Number.isNaN(t)?NaN:t}function s(e,t){return typeof e==`string`||typeof t==`string`?String(e)+String(t):o(e)+o(t)}function c(e,t){return o(e)-o(t)}function l(e,t){return o(e)*o(t)}function u(e,t){return o(e)/o(t)}function d(e,t){return o(e)%o(t)}function f(e,t,n){if(typeof t==`number`&&typeof n==`number`)switch(e){case`>`:return t>n;case`<`:return t<n;case`>=`:return t>=n;case`<=`:return t<=n;default:return!1}let r=String(t),i=String(n);switch(e){case`>`:return r>i;case`<`:return r<i;case`>=`:return r>=i;case`<=`:return r<=i;default:return!1}}function p(){let e=m(),t=r();if(t&&t.value===`?`){i(`?`);let t=a();i(`:`);let n=a();return e?t:n}return e}function m(){let e=h();for(;;){let t=r();if(!t||t.value!==`||`)break;i(`OP`);let n=h();e||=n}return e}function h(){let e=g();for(;;){let t=r();if(!t||t.value!==`&&`)break;i(`OP`);let n=g();e&&=n}return e}function g(){let e=_();for(;;){let t=r();if(!t||![`==`,`!=`,`===`,`!==`].includes(t.value))break;let n=i(`OP`).value,a=_();switch(n){case`==`:e=e==a;break;case`!=`:e=e!=a;break;case`===`:e=e===a;break;case`!==`:e=e!==a;break}}return e}function _(){let e=v();for(;;){let t=r();if(!t||![`>`,`<`,`>=`,`<=`].includes(t.value))break;let n=i(`OP`).value,a=v();switch(n){case`>`:e=f(`>`,e,a);break;case`<`:e=f(`<`,e,a);break;case`>=`:e=f(`>=`,e,a);break;case`<=`:e=f(`<=`,e,a);break}}return e}function v(){let e=y();for(;;){let t=r();if(!t||t.value!==`+`&&t.value!==`-`)break;let n=i(`OP`).value,a=y();e=n===`+`?s(e,a):c(e,a)}return e}function y(){let e=b();for(;;){let t=r();if(!t||t.value!==`*`&&t.value!==`/`&&t.value!==`%`)break;let n=i(`OP`).value,a=b();switch(n){case`*`:e=l(e,a);break;case`/`:e=u(e,a);break;case`%`:e=d(e,a);break}}return e}function b(){let e=r();return e&&e.value===`!`?(i(`OP`),!b()):e&&e.value===`-`?(i(`OP`),c(0,b())):x()}function x(){let e=r();if(e){if(e.type===`NUMBER`)return i(`NUMBER`),Number(e.value);if(e.type===`STRING`)return i(`STRING`),e.value.slice(1,-1);if(e.type===`IDENT`)return i(`IDENT`),e.value===`true`?!0:e.value===`false`?!1:e.value===`null`?null:void 0;if(e.value===`[`){i(`PUNC`);let e=[];for(;;){let t=r();if(!t||t.value===`]`)break;e.push(a());let n=r();n&&n.value===`,`&&i(`PUNC`)}return i(`PUNC`),e}if(e.value===`(`){i(`PUNC`);let e=a();return i(`PUNC`),e}throw Error(`Unexpected token in expression`)}}return a()}static tokenize(e){let t=[],n=/\s*(=>|===|!==|==|!=|>=|<=|\|\||&&|[()?:,[\]]|\+|-|\*|\/|%|>|<|!|\d+\.?\d*|"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|[a-zA-Z_][a-zA-Z0-9_]*|\S)\s*/g,r;for(;(r=n.exec(e))!==null;){let e=r[1];e&&(/^\d/.test(e)?t.push({type:`NUMBER`,value:e}):/^"/.test(e)||/^'/.test(e)?t.push({type:`STRING`,value:e}):/^[a-zA-Z_]/.test(e)?t.push({type:`IDENT`,value:e}):/^[()?:,[\]]$/.test(e)?t.push({type:`PUNC`,value:e}):t.push({type:`OP`,value:e}))}return t}static evaluateSimpleValue(e,t){return e===`true`?!0:e===`false`?!1:isNaN(Number(e))?e.startsWith(`ctx.`)?n.i(t,e.slice(4)):e.startsWith(`"`)&&e.endsWith(`"`)||e.startsWith(`'`)&&e.endsWith(`'`)?e.slice(1,-1):e:Number(e)}static clearCache(){this.cache.clear()}static getCacheSize(){return this.cache.size}};function S(e,t){return Array.isArray(e)&&Array.isArray(t)?JSON.stringify([...e].sort())!==JSON.stringify([...t].sort()):e!==t}function C(e,t,r,i,a){if(e){let e=t.value;if(a&&typeof e==`object`&&e){let n={...e};n[a]=r,t.value=n}else t.value=r}else n.d(i._state||i,t,r)}function w(e,t,n,r){if(typeof e._requestRender==`function`&&e._requestRender(),typeof e._triggerWatchers==`function`){let i=t?`reactiveState`:n;e._triggerWatchers(i,r)}}function T(e,t,r){let i=`update:${n.p(t)}`,a=`update:${t}`,o=new CustomEvent(i,{detail:r,bubbles:!0,cancelable:!0}),s=new CustomEvent(a,{detail:r,bubbles:!0,cancelable:!0});e.dispatchEvent(o),e.dispatchEvent(s)}function te(e,r,i,a){let o=i;if(n.l(()=>{if(typeof e.setAttribute==`function`)try{e[r]=o}catch{}else e[r]=o}),o==null||typeof o==`string`||typeof o==`number`||typeof o==`boolean`){let i=n.u(o);i===null?n.l(()=>{typeof e.removeAttribute==`function`&&t.r(e,n.p(r))}):n.l(()=>{typeof e.setAttribute==`function`&&t.i(e,n.p(r),String(i))})}}function ne(e,t,r,i){if(e){let e=t.value;return i&&typeof e==`object`&&e?e[i]:e}else return n.i(r._state||r,t)}function E(e){return typeof e==`object`&&!!e&&`value`in e}function D(e){return typeof e==`object`&&e&&`value`in e?e.value:e}function O(e,t,n){if(!e)return;e.attrs||={};let r=e.attrs;r[t]=n}function k(e){return e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement||e instanceof HTMLButtonElement}function A(e){return typeof e==`object`&&e&&`value`in e?A(e.value):!(typeof e==`object`&&e||e===!1||e===`false`||e==null||e===0)}function re(e){return e.substring(2,3).toLowerCase()+e.substring(3)}function j(e){return typeof e==`boolean`||e===`true`||e===`false`}function ie(e,t,r,i,a,o,s,c){if(!o)return;let l=t.includes(`lazy`),u=t.includes(`trim`),d=t.includes(`number`),f=()=>{if(n._(e)){let t=e.value;return c&&s&&(s instanceof HTMLInputElement||s instanceof HTMLTextAreaElement||s instanceof HTMLSelectElement)&&typeof t==`object`&&t?t[c]:t}return n.i(o?._state||o,e)},p=f(),m=`text`;s instanceof HTMLInputElement?m=i?.type||s.type||`text`:s instanceof HTMLSelectElement?m=`select`:s instanceof HTMLTextAreaElement&&(m=`textarea`);let h=s instanceof HTMLInputElement||s instanceof HTMLTextAreaElement||s instanceof HTMLSelectElement,g=h?m===`checkbox`||m===`radio`?`checked`:`value`:c??`modelValue`;if(m===`checkbox`)Array.isArray(p)?r[g]=p.includes(String(s?.getAttribute(`value`)??i?.value??``)):r[g]=p===(s?.getAttribute(`true-value`)??!0);else if(m===`radio`)r[g]=p===(i?.value??``);else if(m===`select`)if(s&&s.hasAttribute(`multiple`)&&s instanceof HTMLSelectElement){let e=Array.isArray(p)?p.map(String):[];queueMicrotask(()=>{Array.from(s.options).forEach(t=>{t.selected=e.includes(t.value)})}),r[g]=Array.isArray(p)?p:[]}else r[g]=p;else if(!h&&n._(e))r[g]=e;else{r[g]=p;try{let e=n.p(g);i&&(i[e]=p)}catch{}}let _=l||m===`checkbox`||m===`radio`||m===`select`?`change`:`input`,y=t=>{if(t.isComposing||a._isComposing)return;let r=globalThis.process,i=!!r&&r.env?.NODE_ENV===`test`||typeof window<`u`&&globalThis.__vitest__;if(t.isTrusted===!1&&!i)return;let s=t.target;if(!s||s._modelUpdating)return;let l=s.value;if(m===`checkbox`){let e=f();if(Array.isArray(e)){let t=s.getAttribute(`value`)??``,n=Array.from(e);if(s.checked)n.includes(t)||n.push(t);else{let e=n.indexOf(t);e>-1&&n.splice(e,1)}l=n}else{let e=s.getAttribute(`true-value`)??!0,t=s.getAttribute(`false-value`)??!1;l=s.checked?e:t}}else if(m===`radio`)l=s.getAttribute(`value`)??s.value;else if(m===`select`&&s.multiple)l=Array.from(s.selectedOptions).map(e=>e.value);else if(u&&typeof l==`string`&&(l=l.trim()),d){let e=Number(l);isNaN(e)||(l=e)}let p=f();if(S(l,p)){s._modelUpdating=!0;try{C(n._(e),e,l,o,c),w(o,n._(e),e,l),s&&T(s,g,l)}finally{queueMicrotask(()=>s._modelUpdating=!1)}}};if(h){if(a[_]){let e=a[_];s&&v.removeListener(s,_,e)}a[_]=y}else{let t=`update:${n.p(g)}`,r=`update:${g}`;if(a[t]){let e=a[t];s&&v.removeListener(s,t,e)}if(a[r]){let e=a[r];s&&v.removeListener(s,r,e)}if(a[t]=t=>{let r=t.detail,i=r===void 0?void 0:r;if(i===void 0){let e=t.target;if(e&&typeof e==`object`&&`value`in e)try{i=e.value}catch{i=void 0}}let a=ne(n._(e),e,o,c);if(S(i,a)){C(n._(e),e,i,o,c),w(o,n._(e),e,i);let r=t.target;r&&te(r,g,n._(e)?e:i,n._(e))}},n._(e)&&typeof e.value==`object`&&e.value!==null){let i;try{i=Reflect.ownKeys(e.value)}catch{i=Object.keys(e.value)}let c=i.filter(e=>typeof e==`string`&&!String(e).startsWith(`_`)&&e!==`constructor`),l=new Set(c.map(e=>`update:${n.p(e)}`));for(let e of Object.keys(a))e.startsWith(`update:`)&&e!==t&&e!==r&&!l.has(e)&&(s&&v.removeListener(s,e,a[e]),delete a[e]);for(let r of c){let i=String(r),c=`update:${n.p(i)}`,l=`update:${i}`;c!==t&&(a[c]&&s&&(v.removeListener(s,c,a[c]),delete a[c]),a[c]=t=>{let r=t.detail===void 0?t.target?.value:t.detail;if(!S(r,n._(e)?e.value[i]:n.i(o?._state||o,e)))return;if(n._(e)){let t={...e.value};t[i]=r,e.value=t}else n.d(o?._state||o,e,r);w(o,n._(e),e,r);let a=t.currentTarget||s||t.target;a&&te(a,g,n._(e)?e:r,n._(e))},a[l]=a[c])}}a[r]=a[t]}(m===`text`||m===`textarea`)&&(a.compositionstart=()=>a._isComposing=!0,a.compositionend=t=>{a._isComposing=!1;let r=t.target;r&&queueMicrotask(()=>{let t=r.value,i=o?._state||o,a=n.i(i,e),s=t;if(u&&(s=s.trim()),d){let e=Number(s);isNaN(e)||(s=e)}if(S(s,a)){r._modelUpdating=!0;try{n.d(i,e,s),w(o,n._(e),e,s)}finally{queueMicrotask(()=>r._modelUpdating=!1)}}})})}function ae(e,t,r,i,a){if(typeof e==`object`&&e)for(let[i,o]of Object.entries(e))if(i.startsWith(`data-`)||i.startsWith(`aria-`)||i===`class`)r[i]=o;else if(i===`disabled`&&a&&k(a)){let e=o&&typeof o==`object`&&`value`in o;(()=>{try{return n._(o)}catch{return!1}})()||e?t[i]=o:r[i]=o}else t[i]=o;else if(typeof e==`string`){if(!i)return;try{let o=M(e,i);if(typeof o==`object`&&o){for(let[e,i]of Object.entries(o))if(e.startsWith(`data-`)||e.startsWith(`aria-`)||e===`class`)r[e]=i;else if(e===`disabled`&&a&&k(a)){let a=i&&typeof i==`object`&&`value`in i;(()=>{try{return n._(i)}catch{return!1}})()||a?t[e]=i:r[e]=i}else t[e]=i;return}else{r[e]=o;return}}catch{r[e]=n.i(i,e)}}}function oe(e,t,n){let r;if(typeof e==`string`){if(!n)return;r=M(e,n)}else r=e;let i=String(t.style||``),a=i;if(!r)if(i){let e=String(i).split(`;`).filter(Boolean),t=e.findIndex(e=>e.trim().startsWith(`display:`));t>=0?e[t]=`display: none`:e.push(`display: none`),a=e.join(`; `)}else a=`display: none`;else if(i){let e=String(i).split(`;`).map(e=>e.trim()).filter(Boolean),t=e.findIndex(e=>e.startsWith(`display:`));t>=0&&e[t]===`display: none`&&(e.splice(t,1),a=e.length>0?e.join(`; `)+`;`:``)}a!==i&&(a?t.style=a:t.style=void 0)}function M(e,t){return ee.evaluate(e,t)}function se(e,t,r,i){let a;if(typeof e==`string`){if(!r)return;a=M(e,r)}else a=e;try{if(a&&typeof a==`object`){if(n._(a))a=a.value;else if(`value`in a&&a.value!==void 0){let e=a.value;e instanceof Node||(a=e)}}}catch{}let o=[];if(typeof a==`string`)o=[a];else if(Array.isArray(a))o=a.filter(Boolean);else if(typeof a==`object`&&a)for(let[e,t]of Object.entries(a))t&&o.push(e);let s=o.join(` `),c=i&&i.class||t.class||``,l=c?`${c} ${s}`.trim():s.trim();l?t.class=l:t.class=void 0}function ce(e,t,n){let r;if(typeof e==`string`){if(!n)return;r=M(e,n)}else r=e;let i=``;if(typeof r==`string`)i=r;else if(r&&typeof r==`object`){let e=[];for(let[t,n]of Object.entries(r))if(n!=null&&n!==``){let r=t.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`),i=[`width`,`height`,`top`,`right`,`bottom`,`left`,`margin`,`margin-top`,`margin-right`,`margin-bottom`,`margin-left`,`padding`,`padding-top`,`padding-right`,`padding-bottom`,`padding-left`,`font-size`,`line-height`,`border-width`,`border-radius`,`min-width`,`max-width`,`min-height`,`max-height`],a=String(n);typeof n==`number`&&i.includes(r)&&(a=`${n}px`),e.push(`${r}: ${a}`)}i=e.join(`; `)+(e.length>0?`;`:``)}let a=String(t.style||``);t.style=a+(a&&!a.endsWith(`;`)?`; `:``)+i}function le(e,t,r){let i=e;typeof e==`string`&&r&&(i=M(e,r)),n._(i)?t.reactiveRef=i:t.ref=i}function ue(e,t,r,i){let a={},o={...i||{}},s={};for(let[n,c]of Object.entries(e)){let{value:e,modifiers:l,arg:u}=c;if(n===`model`||n.startsWith(`model:`)){let i=n.split(`:`);ie(e,l,a,o,s,t,r,i.length>1?i[1]:u);continue}switch(n){case`bind`:ae(e,a,o,t,r);break;case`show`:oe(e,o,t);break;case`class`:se(e,o,t,i);break;case`style`:ce(e,o,t);break;case`ref`:le(e,a,t);break;case`when`:break}}try{if(Object.prototype.hasOwnProperty.call(a,`disabled`)&&r&&k(r)){let e=a.disabled,t=e&&typeof e==`object`&&`value`in e,r=!1;try{r=n._(e)}catch{r=!1}!t&&!r&&(o.disabled=e,delete a.disabled)}}catch{}return{props:a,attrs:o,listeners:s}}function N(e){return e?e.split(/\s+/).filter(Boolean):[]}function P(e,t){if(t.length===0)return;let n=t.filter(t=>t&&!e.classList.contains(t));n.length>0&&e.classList.add(...n)}function F(e,t){if(t.length===0)return;let n=t.filter(Boolean);n.length>0&&e.classList.remove(...n)}function de(e){let t=window.getComputedStyle(e),n=t.transitionDuration||`0s`,r=t.transitionDelay||`0s`,i=e=>{let t=parseFloat(e);return e.includes(`ms`)?t:t*1e3};return i(n)+i(r)}function I(e,t){return new Promise(n=>{let r=t??de(e);if(r<=0){n();return}let i=!1,a=()=>{i||(i=!0,e.removeEventListener(`transitionend`,o),e.removeEventListener(`transitioncancel`,o),n())},o=()=>a();e.addEventListener(`transitionend`,o),e.addEventListener(`transitioncancel`,o),setTimeout(a,r+50)})}async function L(t,n){let{classes:r,hooks:i,css:a,duration:o}=n;if(i?.onBeforeEnter)try{i.onBeforeEnter(t)}catch(t){e.t(`Transition onBeforeEnter error:`,t)}if(!a)return i?.onEnter?new Promise(n=>{let r=i.onEnter;typeof r==`function`?r(t,()=>{if(i?.onAfterEnter)try{i.onAfterEnter(t)}catch(t){e.t(`Transition onAfterEnter error:`,t)}n()}):n()}):void 0;let s=N(r?.enterFrom),c=N(r?.enterActive),l=N(r?.enterTo);P(t,s),t.offsetHeight,P(t,c),t.offsetHeight;let u;if(i?.onEnter){let n=new Promise(e=>{u=e});try{let e=i.onEnter;typeof e==`function`&&e(t,()=>{u&&u()})}catch(t){e.t(`Transition onEnter error:`,t)}u&&await n}await new Promise(e=>requestAnimationFrame(()=>e())),t.offsetHeight,F(t,s),P(t,l),t.offsetHeight,await new Promise(e=>requestAnimationFrame(()=>e()));let d;if(typeof o==`number`?d=o:o&&typeof o==`object`&&`enter`in o&&(d=o.enter),await I(t,d),F(t,c),i?.onAfterEnter)try{i.onAfterEnter(t)}catch(t){e.t(`Transition onAfterEnter error:`,t)}}async function R(t,n){let{classes:r,hooks:i,css:a,duration:o}=n;if(i?.onBeforeLeave)try{i.onBeforeLeave(t)}catch(t){e.t(`Transition onBeforeLeave error:`,t)}if(!a)return i?.onLeave?new Promise(n=>{let r=i.onLeave;typeof r==`function`?r(t,()=>{if(i?.onAfterLeave)try{i.onAfterLeave(t)}catch(t){e.t(`Transition onAfterLeave error:`,t)}n()}):n()}):void 0;let s=N(r?.leaveFrom),c=N(r?.leaveActive),l=N(r?.leaveTo);P(t,s),t.offsetHeight,P(t,c);let u;if(i?.onLeave){let n=new Promise(e=>{u=e});try{let e=i.onLeave;typeof e==`function`&&e(t,()=>{u&&u()})}catch(t){e.t(`Transition onLeave error:`,t)}u&&await n}await new Promise(e=>requestAnimationFrame(()=>e())),F(t,s),P(t,l);let d;if(typeof o==`number`?d=o:o&&typeof o==`object`&&`leave`in o&&(d=o.leave),await I(t,d),F(t,c),F(t,l),F(t,s),i?.onAfterLeave)try{i.onAfterLeave(t)}catch(t){e.t(`Transition onAfterLeave error:`,t)}}var fe=new WeakMap,pe=new WeakMap;function z(e){if(!e)return;let t=fe.get(e);if(t!==void 0)return t;try{let t=e;if(t&&t.key!=null)return String(t.key)}catch{}if(e instanceof Element){let t=e.getAttribute(`data-anchor-key`);if(t)return t}}function B(e,r){try{fe.set(e,r)}catch{}try{e.key=r}catch{}try{if(e instanceof Element){let i=n.u(r);i!==null&&t.i(e,`data-anchor-key`,i)}}catch{}}function me(e){if(!e)return;let t=pe.get(e);if(t!==void 0)return t;try{let t=e;if(t&&t._transitionGroup!=null)return t._transitionGroup}catch{}}function he(e,t){try{pe.set(e,t)}catch{}try{e._transitionGroup=t}catch{}}var V=new WeakMap;function H(e,t){if(t){if(e instanceof Element){v.cleanup(e);let n=[];for(let r in t)t[r]===e&&n.push(r);for(let e of n)delete t[e]}if(e.hasChildNodes()){let n=e.childNodes;for(let e=n.length-1;e>=0;e--)H(n[e],t)}}}function U(e,t,r){if(typeof e==`string`)return;let i=e.props?.reactiveRef??(e.props?.props&&e.props.props.reactiveRef),a=e.props?.ref??(e.props?.props&&e.props.props.ref);if(i)try{if(n._(i)||typeof i==`object`&&`value`in i)i.value=t;else if(typeof i==`function`)i(t);else if(typeof i==`string`&&r)try{let e=String(i);r[e]=t}catch{}}catch{}else if(a&&r)try{let e=String(a);r[e]=t}catch{}}function W(e,t){if(Array.isArray(e)){let n=new Set,r=new Map;return e.map(e=>{if(!e||typeof e!=`object`)return e;let i=e.props?.key??e.key;if(!i){let n=e.tag||`node`,r=[e.props?.attrs?.id,e.props?.attrs?.name,e.props?.attrs?.[`data-key`],e.props?.props?.id,e.props?.props?.name,e.props?.props?.dataKey,e.props?.props?.[`data-key`]].find(e=>e!=null)??``;i=r?`${t}:${n}:${r}`:`${t}:${n}`}let a=i;if(n.has(a)){let e=(r.get(a)??1)+1;r.set(a,e),a=`${i}#${e}`}r.set(i,(r.get(i)??0)+1),n.add(a);let o=e.children;return Array.isArray(o)&&(o=W(o,a)),{...e,key:a,children:o}})}let n=e,r=n.props?.key??n.key??t,i=n.children;return Array.isArray(i)&&(i=W(i,r)),{...n,key:r,children:i}}function ge(e,r,i,a){let o=i.directives??{},s=i.attrs?{...i.attrs}:{},c=ue(o,a,e,s),l={...r.props||{},...i.props||{},...c.props||{}},u={...s||{},...c.attrs||{}},d=r.props??{},f=l,p=!!(i?.isCustomElement??r?.isCustomElement??!1),m=!1,h=new Set;for(let e in d)h.add(e);for(let e in f)h.add(e);for(let a of h){let o=d[a],s=f[a],c=o,l=s;if(n.l(()=>{n._(o)?c=o.peek():E(o)&&(c=o.value)}),n.l(()=>{n._(s)?l=s.peek():E(s)&&(l=s.value)}),!(o===s&&c===l))if(m=!0,a===`value`&&(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)){let t=D(s),n=t==null?``:String(t);e.value!==n&&(e.value=n)}else if(a===`checked`&&e instanceof HTMLInputElement)e.checked=!!D(s);else if(a.startsWith(`on`)&&typeof s==`function`){let t=re(a);typeof o==`function`&&v.removeListener(e,t,o),typeof s==`function`&&v.addListener(e,t,s);try{if(t&&t.startsWith(`update:`)){let r=t.split(`:`,2)[1],i=f[r],a=[];try{if(n._(i)){let e=i.value;a=e&&typeof e==`object`?Object.keys(e):[]}else i&&typeof i==`object`&&(a=Object.keys(i))}catch{a=[]}let o=a.filter(e=>typeof e==`string`&&!e.startsWith(`_`)&&e!==`constructor`);for(let t of o){let a=`update:${t}`,o=e=>{let a=e.detail===void 0?e.target instanceof HTMLInputElement||e.target instanceof HTMLTextAreaElement||e.target instanceof HTMLSelectElement?e.target.value:void 0:e.detail,o={...n._(i)?i.value||{}:f[r]||{},[t]:a};try{typeof s==`function`&&s({detail:o})}catch{}};n.l(()=>{v.addListener(e,a,o)})}}}catch{}}else if(s==null)t.r(e,a);else{let n=i?.isCustomElement??r?.isCustomElement??!1;if(n||a in e)try{e[a]=s,a===`disabled`&&s===!1&&!n&&k(e)&&t.r(e,`disabled`)}catch{}else s===!1&&t.r(e,a)}}let g=c.listeners??{},_=V.get(e)??{};for(let[t,n]of Object.entries(_))v.removeListener(e,t,n);for(let[t,n]of Object.entries(g))v.addListener(e,t,n);Object.keys(g).length>0?V.set(e,g):V.delete(e);let y={...r.attrs??{}},b=u,x=c&&c.attrs||{};if(Object.prototype.hasOwnProperty.call(x,`class`)&&typeof e.getAttribute==`function`){let t=e.getAttribute(`class`);t!==null&&(y.class=t)}if(Object.prototype.hasOwnProperty.call(x,`style`)&&typeof e.getAttribute==`function`){let t=e.getAttribute(`style`);t!==null&&(y.style=t)}try{if(Object.prototype.hasOwnProperty.call(x,`class`)&&x.class===void 0&&typeof e.getAttribute==`function`){let t=e.getAttribute(`class`);t!==null&&(y.class=t)}if(Object.prototype.hasOwnProperty.call(x,`style`)&&x.style===void 0&&typeof e.getAttribute==`function`){let t=e.getAttribute(`style`);t!==null&&(y.style=t)}try{if(typeof e.getAttribute==`function`){let t=e.getAttribute(`class`);try{e instanceof HTMLInputElement&&e.type===`text`&&t!==null&&t!==y.class&&(y.class=t)}catch{}}}catch{}}catch{}for(let i in{...y,...b}){let a=y[i],o=b[i],s=a,c=o;if(n._(a)&&(s=a.peek()),n._(o)&&(c=o.peek()),s!==c)if(m=!0,c==null||c===!1)n.l(()=>{t.r(e,i)}),O(r,i,void 0),i===`value`&&(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement?n.l(()=>{e.value=``}):e instanceof HTMLProgressElement&&n.l(()=>{e.value=0})),i===`checked`&&e instanceof HTMLInputElement&&n.l(()=>{e.checked=!1}),i===`disabled`&&k(e)&&n.l(()=>{(e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement||e instanceof HTMLButtonElement)&&(e.disabled=!1)});else{if(i===`value`){if(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement){n.l(()=>{e.value=c??``});continue}else if(e instanceof HTMLSelectElement){n.l(()=>{e.value=c??``});continue}else if(e instanceof HTMLProgressElement){n.l(()=>{e.value=Number(c)});continue}}if(i===`checked`&&e instanceof HTMLInputElement){n.l(()=>{e.checked=!!c});continue}if(i===`style`){let a=n.u(c);a!==null&&t.i(e,i,String(a)),O(r,i,c);continue}if(i===`class`){let a=n.u(c);a!==null&&t.i(e,i,String(a)),O(r,i,c);continue}if(i===`disabled`&&k(e)){n.l(()=>{let t=A(c);(e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement||e instanceof HTMLButtonElement)&&(e.disabled=t)}),A(c)?n.l(()=>{t.i(e,i,``)}):n.l(()=>{t.r(e,i)});continue}let a=e.namespaceURI===`http://www.w3.org/2000/svg`;if(p&&!a&&i.includes(`-`))if(n.a(i)){let a=n.u(o??c);if(a!==null){try{t.i(e,i,String(a))}catch{}O(r,i,c)}}else{let a=n.f(i);try{let t=e;t[a]=n._(o)?o:c,O(r,i,c)}catch{let r=n.u(o??c);r!==null&&t.i(e,i,String(r))}}else if(!a&&i in e)try{let t=e;t[i]=n._(o)?o:c,O(r,i,c)}catch{let a=n.u(c);a!==null&&(t.i(e,i,String(a)),O(r,i,c))}else{let a=n.u(c);a!==null&&(t.i(e,i,String(a)),O(r,i,c))}}}try{if(k(e)){let r=l.disabled,i;try{let e=Object.prototype.hasOwnProperty.call(c.props||{},`disabled`),t=r&&typeof r==`object`&&`value`in r,a=!1;n.l(()=>{a=!!n._(r)});let o=j(r);i=a||t||e||o?r:u.disabled}catch{i=u.disabled}let a=A(i);n.l(()=>{(e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement||e instanceof HTMLButtonElement)&&(e.disabled=a)}),a?n.l(()=>{t.i(e,`disabled`,``)}):n.l(()=>{t.r(e,`disabled`)})}}catch{}if(p&&m){let t=e;n.l(()=>{t._applyProps?.(t._cfg)}),n.l(()=>{typeof t.requestRender==`function`?t.requestRender():typeof t._render==`function`&&t._render?.(t._cfg)})}}function G(r,i,a,o=null){if(typeof r==`string`)return document.createTextNode(r);if(r.tag===`#text`){let e=document.createTextNode(typeof r.children==`string`?r.children:``);return r.key!=null&&B(e,r.key),e}if(r.tag===`#raw`){let t=typeof r.children==`string`?r.children:``;return e.r(`[#raw] Inserting unsanitized HTML. Ensure the content is trusted or sanitized before use — unsanitized input can lead to XSS vulnerabilities.`),document.createRange().createContextualFragment(t)}if(r.tag===`#anchor`){let e=r,t=Array.isArray(e.children)?e.children:[],n=document.createTextNode(``),s=document.createTextNode(``);e.key!=null&&(B(n,`${e.key}:start`),B(s,`${e.key}:end`)),e._startNode=n,e._endNode=s;let c=document.createDocumentFragment();c.appendChild(n);for(let n of t){let t=G(n,i,a,o);if(e.key!=null&&t instanceof Element&&!t.hasAttribute(`data-anchor-key`)){let r=n;r&&typeof r==`object`&&r.key!=null||B(t,String(e.key))}c.appendChild(t)}return c.appendChild(s),c}let s=r&&typeof r==`object`&&r.props&&r.props.attrs?r.props.attrs:void 0,c=(s&&typeof s.xmlns==`string`?String(s.xmlns):void 0)??o??t.n[r.tag]??null,l=c?document.createElementNS(c,r.tag):document.createElement(r.tag);r.key!=null&&B(l,r.key),r.props&&r.props?._transitionGroup&&he(l,r.props?._transitionGroup);let{props:u={},attrs:d={},directives:f={}}=r.props??{},p=ue(f,i,l instanceof HTMLElement?l:void 0,d),m={...u,...p.props},h={...d,...p.attrs};try{let e=n.u((h&&h.class)??(m&&m.class)??(r.props&&r.props.attrs&&r.props.attrs.class)??(r.props&&r.props.props&&r.props.props.class));if(e!==null){let n=String(e).trim();n&&t.i(l,`class`,n)}}catch{}try{if(m.disabled!==void 0&&l&&k(l)){let e=m.disabled,t=e&&typeof e==`object`&&`value`in e,r=!1;try{r=n._(e)}catch{r=!1}!t&&!r&&n.l(()=>{h.disabled=e,delete m.disabled})}}catch{}let g=l.namespaceURI===`http://www.w3.org/2000/svg`;for(let e in h){let i=h[e];if(typeof e!=`string`||/\[object Object\]/.test(e))continue;let a=D(i);if(typeof a==`boolean`)a?t.i(l,e,``):n.l(()=>{t.r(l,e)});else if(a!=null){if(e===`disabled`&&k(l)){let r=m.disabled,i=A(j(r)?r:a);n.l(()=>{l.disabled=i}),i?n.l(()=>{t.i(l,e,``)}):n.l(()=>{t.r(l,e)});continue}if(!g&&e===`value`&&(l instanceof HTMLInputElement||l instanceof HTMLTextAreaElement||l instanceof HTMLSelectElement||l instanceof HTMLProgressElement))try{l instanceof HTMLProgressElement?l.value=Number(a):l.value=String(a??``)}catch{let r=n.u(a);r!==null&&t.i(l,e,String(r))}else if(!g&&e===`checked`&&l instanceof HTMLInputElement)try{l.checked=!!a}catch{let r=n.u(a);r!==null&&t.i(l,e,String(r))}else if(!g&&e in l)try{l[e]=a,e===`disabled`&&a===!1&&k(l)&&t.r(l,`disabled`),O(r.props,e,a)}catch{let r=n.u(a);r!==null&&t.i(l,e,String(r))}else if((r.props?.isCustomElement??!1)&&!g&&e.includes(`-`)){let r=n.f(e);try{l[r]=a}catch{let r=n.u(a);r!==null&&t.i(l,e,String(r))}}else{let r=n.u(a);r!==null&&t.i(l,e,String(r))}}}for(let e in m){let i=m[e];if(!(typeof e!=`string`||/\[object Object\]/.test(e)))if(e===`value`&&(l instanceof HTMLInputElement||l instanceof HTMLTextAreaElement||l instanceof HTMLSelectElement)){let e=typeof i==`object`&&i&&E(i)?i.value:i;n.l(()=>{l.value=String(e??``)})}else if(e.startsWith(`on`)&&typeof i==`function`){let t=re(e),n=t.includes(`:`)?(()=>{let e=t.split(`:`),n=e[1];if(n.includes(`-`)){let t=n.split(`-`).map((e,t)=>t===0?e:e.charAt(0).toUpperCase()+e.slice(1)).join(``);return`${e[0]}:${t}`}else{let t=n.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase();return`${e[0]}:${t}`}})():t;p.listeners&&(p.listeners[t]||p.listeners[n])||v.addListener(l,t,i)}else if(e.startsWith(`on`)&&i===void 0)continue;else if(i==null||i===!1)t.r(l,e);else{let a=r.props?.isCustomElement??!1,o=typeof i==`object`&&i&&n._(i)?i:E(i)&&i.value!==void 0?i.value:i;if(e===`class`||e===`style`){try{let r=n.u(o);r!==null&&t.i(l,e,String(r))}catch{}continue}if(a||e in l)try{let r=typeof i==`object`&&i&&n._(i)?i:E(i)?i.value:i;if(e===`disabled`&&k(l)){let i=A(m.disabled===void 0?r:m.disabled);n.l(()=>{l.disabled=i}),i?n.l(()=>{t.i(l,e,``)}):n.l(()=>{t.r(l,e)});continue}try{if(typeof l[e]==`boolean`){let t=r;t=typeof r==`string`?r===`false`?!1:r===`true`?!0:!!r&&r!==``:!!r,l[e]=t}else l[e]=r}catch{l[e]=r}}catch{}}}let _=p.listeners??{};for(let[e,t]of Object.entries(_))v.addListener(l,e,t);Object.keys(_).length>0&&V.set(l,_),U({...r,props:{...r.props,...p.props}},l,a);try{let e=l;if(typeof e._applyProps==`function`)try{e._applyProps(e._cfg)}catch{}typeof e.requestRender==`function`?e.requestRender():typeof e._render==`function`&&e._render(e._cfg)}catch{}if(Array.isArray(r.children)){let e=r.tag===`foreignObject`&&c===`http://www.w3.org/2000/svg`?null:l.namespaceURI??null;for(let t of r.children)l.appendChild(G(t,i,a,e))}else typeof r.children==`string`&&(l.textContent=r.children);try{if(l instanceof HTMLSelectElement&&h&&Object.prototype.hasOwnProperty.call(h,`value`))try{l.value=String(h.value??``)}catch{}}catch{}try{if(k(l)){let e=m.disabled,r=h.disabled,i=e&&typeof e==`object`&&`value`in e,a=!1;try{a=!!n._(e)}catch{a=!1}let o=A(a||i||j(e)?e:r);n.l(()=>{l.disabled=o}),o?n.l(()=>{t.i(l,`disabled`,``)}):n.l(()=>{t.r(l,`disabled`)})}}catch{}return l}function _e(t,n,r,i,a){if(typeof r==`string`){t.textContent!==r&&(t.textContent=r);return}if(!Array.isArray(r))return;let o=t.childNodes,s=[];for(let e=0;e<o.length;e++)s.push(o[e]);let c=Array.isArray(n)?n:[],l=me(t);if(l){let n=e=>{if(typeof e==`string`)return e.startsWith(`each-`)?e.substring(5):e;if(typeof e==`number`)return String(e)},a=[],o=[];for(let e of r)if(e&&e.tag===`#anchor`){let t=Array.isArray(e.children)?e.children:[];for(let r of t){let t=n(r.key??e.key??`unknown`);a.push({...r,key:t})}}else e&&a.push({...e,key:n(e.key)});for(let e of c)if(e&&e.tag===`#anchor`){let t=Array.isArray(e.children)?e.children:[];for(let r of t){let t=n(r.key??e.key??`unknown`);o.push({...r,key:t})}}else e&&o.push({...e,key:n(e.key)});if(a.some(e=>e&&e.key!=null)||o.some(e=>e&&e.key!=null)){let r=new Map,c=new Map;for(let e of o)if(e&&e.key!=null){let t=String(e.key);r.set(t,e)}for(let e=0;e<s.length;e++){let t=s[e],r=z(t);if(r=n(r),r!=null&&t instanceof Element&&t.nodeType===Node.ELEMENT_NODE){let e=typeof r==`string`&&r.includes(`:`)?r.substring(0,r.lastIndexOf(`:`)):r;e=String(e),c.set(e,t)}}let u=new Set,d=new Map,f=s.length>0;if(l.moveClass&&f)for(let e=0;e<s.length;e++){let t=s[e];if(t instanceof HTMLElement&&t.parentElement){let e=t.getBoundingClientRect();d.set(t,e)}}let p=[];for(let n of a){let a=n.key;if(a==null)continue;a=String(a);let o=r.get(a),s=c.get(a);if(s&&o){let e=K(s,o,n,i);u.add(s),B(e,String(a)),p.push({node:e,key:a,newVNode:n,oldVNode:o,isNew:!1})}else{s=G(n,i,void 0,t instanceof Element?t.namespaceURI??null:null),B(s,String(a)),t.appendChild(s);let r=f||l.appear===!0;s instanceof HTMLElement&&r&&L(s,l).catch(t=>{e.t(`Enter transition error:`,t)}),p.push({node:s,key:a,newVNode:n,isNew:!0})}}let m=[];for(let n=0;n<s.length;n++){let r=s[n],i=z(r);if(!u.has(r)&&i!=null&&r instanceof HTMLElement){let n=R(r,l).then(()=>{t.contains(r)&&t.removeChild(r)}).catch(n=>{e.t(`Leave transition error:`,n),t.contains(r)&&t.removeChild(r)});m.push(n)}}if(m.length===0){let e=t.firstChild;for(let{node:n}of p)n!==e&&t.insertBefore(n,e),e=n.nextSibling;if(l.moveClass&&d.size>0){let e=[];for(let{node:t,isNew:n}of p)if(!n&&t instanceof HTMLElement){let n=d.get(t);if(n){let r=t.getBoundingClientRect(),i=n.left-r.left,a=n.top-r.top;if(i!==0||a!==0){let n=l.moveClass.split(/\s+/).filter(e=>e);e.push({node:t,deltaX:i,deltaY:a,moveClasses:n})}}}if(e.length>0){for(let{node:t,deltaX:n,deltaY:r}of e)t.style.transform=`translate(${n}px, ${r}px)`,t.style.transitionProperty=`none`;t.offsetHeight,requestAnimationFrame(()=>{requestAnimationFrame(()=>{for(let{node:t,moveClasses:n}of e)for(let e of n)t.classList.add(e);requestAnimationFrame(()=>{let t=l.moveClass||``,n=t.match(/duration-(\d+)/),r=n?`${n[1]}ms`:`300ms`,i=t.match(/ease-(out|in|in-out|linear)/),a=i?`ease-${i[1]}`:`ease-out`;for(let{node:t}of e)t.style.transition=`transform ${r} ${a}`;requestAnimationFrame(()=>{for(let{node:t,moveClasses:n}of e){t.style.removeProperty(`transform`);let e=()=>{for(let e of n)t.classList.remove(e);t.style.removeProperty(`transition`),t.removeEventListener(`transitionend`,e),t.removeEventListener(`transitioncancel`,e)};t.addEventListener(`transitionend`,e,{once:!0}),t.addEventListener(`transitioncancel`,e,{once:!0})}})})})})}}}return}}let u=new Map;for(let e of c)e&&e.key!=null&&u.set(e.key,e);let d=new Map;for(let e=0;e<s.length;e++){let t=s[e],n=z(t);n!=null&&d.set(n,t)}let f=new Set,p=t.firstChild;function m(e,t){let n=e;for(;n&&(f.add(n),n!==t);)n=n.nextSibling}function h(n,r,a,o,s,c=!0){let l=[],u=n.nextSibling;for(;u&&u!==r;)l.push(u),u=u.nextSibling;let d=Array.isArray(a)?a:[];if(o.some(e=>e&&e.key!=null)||d.some(e=>e&&e.key!=null)){let r=new Map,a=new Map;for(let e of d)e&&e.key!=null&&r.set(e.key,e);for(let e of l){let t=z(e);t!=null&&a.set(t,e)}let u=s&&s.state===`visible`&&d.length===0&&o.length>0,f=new Set,p=n.nextSibling;for(let n of o){if(typeof n==`object`&&n.tag===`#anchor`){let e=n.key,o=`${e}:start`,s=`${e}:end`,c=a.get(o),l=a.get(s),u=Array.isArray(n.children)?n.children:[],d=r.get(e),m,g;if(c&&l&&t.contains(c))m=c,g=l,h(m,g,d?.children,u);else{m=document.createTextNode(``),g=document.createTextNode(``),B(m,o),B(g,s),t.insertBefore(m,p);for(let e of u){let n=G(e,i,void 0,t instanceof Element?t.namespaceURI??null:null);t.insertBefore(n,p),f.add(n)}t.insertBefore(g,p)}let _=m;for(;_&&(f.add(_),_!==g);)_=_.nextSibling;n._startNode=m,n._endNode=g,p=g.nextSibling;continue}let o;if(n.key!=null&&a.has(n.key)){let c=r.get(n.key);o=K(a.get(n.key),c,n,i),f.add(o),s&&o instanceof HTMLElement&&u&&s.appear&&L(o,s).catch(t=>{e.t(`Transition enter error (appear):`,t)}),o!==p&&t.contains(o)&&t.insertBefore(o,p)}else o=G(n,i,void 0,t instanceof Element?t.namespaceURI??null:null),t.insertBefore(o,p),f.add(o),s&&o instanceof HTMLElement&&c&&L(o,s).catch(t=>{e.t(`Transition enter error:`,t)});p=o.nextSibling}for(let n of l)!f.has(n)&&t.contains(n)&&(s&&n instanceof HTMLElement&&c?R(n,s).then(()=>{t.contains(n)&&t.removeChild(n)}).catch(r=>{e.t(`Transition leave error:`,r),t.contains(n)&&t.removeChild(n)}):t.removeChild(n))}else{let n=Math.min(d.length,o.length);for(let e=0;e<n;e++){let n=d[e],r=o[e],a=K(l[e],n,r,i);a!==l[e]&&(t.insertBefore(a,l[e]),t.removeChild(l[e]))}for(let a=n;a<o.length;a++){let n=G(o[a],i,void 0,t instanceof Element?t.namespaceURI??null:null);t.insertBefore(n,r),s&&n instanceof HTMLElement&&c&&L(n,s).catch(t=>{e.t(`Transition enter error:`,t)})}for(let r=n;r<l.length;r++){let n=l[r];s&&n instanceof HTMLElement&&c?R(n,s).then(()=>{t.contains(n)&&t.removeChild(n)}).catch(r=>{e.t(`Transition leave error:`,r),t.contains(n)&&t.removeChild(n)}):t.removeChild(n)}}}for(let n of r){let r;if(n.tag===`#anchor`){let r=n.key,o=`${r}:start`,s=`${r}:end`,c=d.get(o),l=d.get(s),f=Array.isArray(n.children)?n.children:[];if(c||(c=document.createTextNode(``),B(c,o)),l||(l=document.createTextNode(``),B(l,s)),n._startNode=c,n._endNode=l,!t.contains(c)||!t.contains(l)){t.insertBefore(c,p);let r=n._transition,o=!(r&&r.state===`visible`&&f.length>0)||r.appear;for(let n of f){let s=G(n,i,a,t instanceof Element?t.namespaceURI??null:null);t.insertBefore(s,p),r&&s instanceof HTMLElement&&o&&L(s,r).catch(t=>{e.t(`Transition enter error:`,t)})}t.insertBefore(l,p)}else{let e=n._transition,t=u.get(r)._transition,i=t&&t.state!==e?.state,a=e&&e.state===`visible`&&f.length>0&&!i,o=i||!a||e?.appear===!0;h(c,l,u.get(r)?.children,f,e,o)}m(c,l),p=l.nextSibling;continue}if(n.key!=null&&d.has(n.key)){let e=u.get(n.key);r=K(d.get(n.key),e,n,i,a),f.add(r),r!==p&&t.contains(r)&&(p&&!t.contains(p)&&(p=null),t.insertBefore(r,p))}else r=G(n,i,a,t instanceof Element?t.namespaceURI??null:null),p&&!t.contains(p)&&(p=null),t.insertBefore(r,p),f.add(r);p=r.nextSibling}for(let e=0;e<s.length;e++){let n=s[e];!f.has(n)&&t.contains(n)&&(H(n,a),t.removeChild(n))}}function K(e,t,n,r,i){if(t&&typeof t!=`string`&&t.props?.ref&&i&&H(e,i),t===n)return e;if(typeof n==`string`){if(e.nodeType===Node.TEXT_NODE)return e.textContent!==n&&(e.textContent=n),e;{let t=document.createTextNode(n);return e.parentNode?.replaceChild(t,e),t}}if(n&&typeof n!=`string`&&n.tag===`#anchor`){let t=n,a=Array.isArray(t.children)?t.children:[],o=t._startNode??document.createTextNode(``),s=t._endNode??document.createTextNode(``);t.key!=null&&(B(o,`${t.key}:start`),B(s,`${t.key}:end`)),t._startNode=o,t._endNode=s;let c=document.createDocumentFragment();c.appendChild(o);for(let t of a){let n=G(t,r,i,e.parentNode instanceof Element?e.parentNode.namespaceURI??null:null);c.appendChild(n)}return c.appendChild(s),e.parentNode?.replaceChild(c,e),o}if(!n){H(e,i);let t=document.createComment(`removed`);return e.parentNode?.replaceChild(t,e),t}if(!t||typeof t==`string`){H(e,i);let t=G(n,r,i,e.parentNode instanceof Element?e.parentNode.namespaceURI??null:null);return U(n,t,i),e.parentNode?.replaceChild(t,e),t}if(n.tag===`#anchor`){let t=Array.isArray(n.children)?n.children:[],a=n._startNode??document.createTextNode(``),o=n._endNode??document.createTextNode(``);n.key!=null&&(B(a,`${n.key}:start`),B(o,`${n.key}:end`)),n._startNode=a,n._endNode=o;let s=document.createDocumentFragment();s.appendChild(a);for(let n of t)s.appendChild(G(n,r,i,e.parentNode instanceof Element?e.parentNode.namespaceURI??null:null));return s.appendChild(o),e.parentNode?.replaceChild(s,e),a}if(typeof t!=`string`&&typeof n!=`string`&&t.tag===n.tag&&t.key===n.key){let a=e;return ge(a,t.props||{},n.props||{},r),_e(a,t.children,n.children,r,i),U(n,a,i),a}if(typeof t!=`string`&&typeof n!=`string`&&t.tag===n.tag&&(t.tag&&String(t.tag).includes(`-`)||n.props&&n.props.isCustomElement||t.props&&t.props.isCustomElement))try{let a=e;return ge(a,t.props||{},n.props||{},r),U(n,a,i),a}catch{}H(e,i);let a=G(n,r,i,e.parentNode instanceof Element?e.parentNode.namespaceURI??null:null);return U(n,a,i),e.parentNode?.replaceChild(a,e),a}function ve(e,t,n,r){let i;Array.isArray(t)?t.length===1?(i=t[0],i&&typeof i==`object`&&i.key==null&&(i={...i,key:`__root__`})):i={tag:`div`,key:`__root__`,children:t}:(i=t,i&&typeof i==`object`&&i.key==null&&(i={...i,key:`__root__`})),i&&typeof i==`object`&&i.tag===`#anchor`&&(i={tag:`div`,key:`__anchor_root__`,props:{attrs:{"data-anchor-block-root":``,key:`__anchor_root__`}},children:[i]}),i=W(i,String(i.key??`root`));let a=e._prevVNode??null,o=e._prevDom??e.firstChild??null,s;a&&o?typeof a!=`string`&&typeof i!=`string`&&a.tag===i.tag&&a.key===i.key?s=K(o,a,i,n,r):(s=G(i,n,r,e.host instanceof Element?e.host.namespaceURI??null:null),e.replaceChild(s,o)):(s=G(i,n,r,e.host instanceof Element?e.host.namespaceURI??null:null),e.firstChild?e.replaceChild(s,e.firstChild):e.appendChild(s));let c=[];for(let t=0;t<e.childNodes.length;t++){let n=e.childNodes[t];n!==s&&n.nodeName!==`STYLE`&&(H(n,r),c.push(n))}c.forEach(t=>e.removeChild(t)),e._prevVNode=i&&typeof i==`object`&&i.props?{...i,props:{...i.props,attrs:i.props.attrs?{...i.props.attrs}:void 0,props:i.props.props?{...i.props.props}:void 0}}:i,e._prevDom=s}var q=[],ye=new WeakMap,J=new WeakMap,be=new Map;function xe(e){if(typeof CSSStyleSheet>`u`||!(`replaceSync`in CSSStyleSheet.prototype))return null;let t=be.get(e);if(t)return t;try{let t=new CSSStyleSheet;return t.replaceSync(e),be.set(e,t),t}catch{return null}}function Se(e,t){J.has(e)||J.set(e,new Set),J.get(e).add(t)}function Ce(e,t){let n=J.get(e);n&&(n.delete(t),n.size===0&&J.delete(e))}function we(t,n,r,i,a,o,s,c){if(t){q.push(r);try{let l=n.render(r);if(l instanceof Promise){o(!0);let n=t.host.isConnected,u=t,d=u._asyncRenderToken=(u._asyncRenderToken??0)+1;l.then(e=>{n&&!t.host.isConnected||u._asyncRenderToken===d&&(o(!1),s(null),Te(t,e,r,i,a),c(t.innerHTML))}).catch(r=>{if(n&&!t.host.isConnected||u._asyncRenderToken!==d)return;o(!1);let i=r instanceof Error?r:Error(String(r));e.t(`[${t.host.tagName.toLowerCase()}] Async render error:`,i),s(i)});return}Te(t,l,r,i,a),c(t.innerHTML)}catch(n){let r=n instanceof Error?n:Error(String(n));e.t(`[${t.host.tagName.toLowerCase()}] Render error:`,r),s(r)}finally{q.pop()}}}function Te(e,t,n,r,i){e&&(ve(e,Array.isArray(t)?t:[t],n,r),i(e.innerHTML))}function Ee(t,r,i,a,o,s,c){s!==null&&clearTimeout(s);let l=Date.now()-r<16,{isVitest:u,isCypress:d,isTest:f}=n.T(),p=(u||f)&&!d;if(l){let t=i+1;o(t);let n=f?50:10,r=f?100:25,a=p?12:50;if(t===n&&!f)e.r(`⚠️ Component rendering frequently. Performance may be impacted.
|
|
2
|
+
Common causes:
|
|
3
|
+
• State updates during render cycle
|
|
4
|
+
• Event handlers with immediate function calls
|
|
5
|
+
• Missing effect dependencies`);else if(t===r&&!f)e.r(`⚠️ Component is re-rendering rapidly. Applying throttling.
|
|
6
|
+
This might indicate:
|
|
7
|
+
• Event handler calling function immediately: @click="\${fn()}" should be @click="\${fn}"
|
|
8
|
+
• State modification during render
|
|
9
|
+
• Missing dependencies in computed/watch`);else if(t>=a){e.t(`🛑 Infinite render loop detected. Stopping to prevent browser freeze.
|
|
10
|
+
Possible causes:
|
|
11
|
+
• State updates triggering immediate re-renders
|
|
12
|
+
• Computed values changing during evaluation
|
|
13
|
+
• Circular dependencies in reactive system`),c(null);return}}else o(0);let m=0;f||(i>=40?m=500:i>=25?m=100:i>=15&&(m=16));let h=()=>{a(Date.now());try{t()}catch(t){e.t(`Error during render execution:`,t)}finally{c(null)}};m>0?c(setTimeout(h,m)):f?h():(c({}),queueMicrotask(h))}function De(e,t){let n=t;try{let t=J.get(e);if(t?.size)for(let e of t)try{let t=e.lastHtmlStringForJitCSS;t?.trim()&&(n+=`
|
|
14
|
+
`+t)}catch{}else{let t=e.querySelectorAll(`*`);for(let e of t)try{let t=e.lastHtmlStringForJitCSS;t?.trim()&&(n+=`
|
|
15
|
+
`+t)}catch{}}}catch{}return n}function Oe(e){return`adoptedStyleSheets`in e&&typeof CSSStyleSheet<`u`&&`replaceSync`in CSSStyleSheet.prototype}function ke(e,n){let r=e.querySelector(`style[data-cer-runtime]`);r||(r=document.createElement(`style`),t.i(r,`data-cer-runtime`,`true`),e.appendChild(r));try{r.textContent=n}catch{}}function Ae(e,t,n,i,o){if(!e)return;let s=De(e,n);if(ye.get(e)===s)return;ye.set(e,s);let c=r.r(e)?r.i(s):``,l=r.n(),u=t._computedStyle,d=Oe(e),f=a.getTransitionStyleSheet(),p=``;if(!d)try{f?.cssRules&&(p=Array.from(f.cssRules).map(e=>e.cssText).join(`
|
|
16
|
+
`))}catch{p=``}if(!c?.trim()&&!u&&!l){if(o(null),d)e.adoptedStyleSheets=[r.u(),f];else{ke(e,r.d(`${r.d(r.a)}\n${p}`));try{e.adoptedStyleSheets=[r.u(),f]}catch{}}return}let m=``;if(u&&(m+=u+`
|
|
17
|
+
`),c&&(m+=c+`
|
|
18
|
+
`),m=r.f(m),m=r.d(m),d){let t=!c?.trim()&&!!u,n;t?(n=xe(m),n||=new CSSStyleSheet):(n=i,n||=new CSSStyleSheet);try{t||n.replaceSync(m);let i=[r.u(),f];l&&i.push(l),i.push(n),e.adoptedStyleSheets=i,o(t?null:n);return}catch{}}ke(e,r.d(`${r.d(r.a)}\n${p}\n${m}`));try{let t=[r.u(),f];if(l&&t.push(l),typeof CSSStyleSheet<`u`)try{let e=new CSSStyleSheet;e.replaceSync(m),t.push(e)}catch{t.push({cssRules:[],replaceSync:()=>{}})}e.adoptedStyleSheets=t}catch{}o(null)}function je(r,i){if(!i.render)throw Error(`Component must have a render function`);return typeof window>`u`?class{constructor(){}}:class extends HTMLElement{context;_refs={};_listeners=[];_watchers=new Map;_renderTimeoutId=null;_mounted=!1;_hasError=!1;_initializing=!0;_componentId;_styleSheet=null;_lastHtmlStringForJitCSS=``;get lastHtmlStringForJitCSS(){return this._lastHtmlStringForJitCSS}get hasError(){return this._hasError}get isLoading(){return this._templateLoading}get lastError(){return this._templateError}_cfg;_lastRenderTime=0;_renderCount=0;_templateLoading=!1;_templateError=null;constructor(){super(),this.shadowRoot||this.attachShadow({mode:`open`}),this._cfg=t.o.get(r)||i,this._componentId=`${r}-${crypto.randomUUID()}`;let e=this._initContext(i),a=(e,t,n)=>{Object.defineProperty(e,t,{value:n,writable:!1,enumerable:!1,configurable:!1})};a(e,`refs`,this._refs),a(e,`requestRender`,()=>this.requestRender()),a(e,`_requestRender`,()=>this._requestRender()),a(e,`_componentId`,this._componentId),a(e,`_triggerWatchers`,(e,t)=>this._triggerWatchers(e,t)),this.context=e,n.l(()=>{a(e,`_host`,this)}),a(this.context,`emit`,(e,t,r)=>{let i={detail:t,bubbles:!0,composed:!0,...r||{}},a=new CustomEvent(e,i);this.dispatchEvent(a);let o=e.indexOf(`:`);if(o>0){let t=e.substring(0,o),r=e.substring(o+1),a=r.includes(`-`)?`${t}:${r.split(`-`).map((e,t)=>t===0?e:e.charAt(0).toUpperCase()+e.slice(1)).join(``)}`:`${t}:${r.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase()}`;a!==e&&n.l(()=>{this.dispatchEvent(new CustomEvent(a,i))})}return!a.defaultPrevented});let o=t.o.get(r)||i;for(let e in o){let t=o[e];typeof t==`function`&&(this.context[e]=(...e)=>t(...e,this.context))}if(o.props)for(let e in o.props){let t=this[e];Object.defineProperty(this,e,{get(){return t},set(n){let r=t;t=n,this.context[e]=n,this._initializing||(this._applyProps(o),r!==n&&this._requestRender())},enumerable:!0,configurable:!0})}this._initializing=!1,this._initWatchers(o),this._applyProps(o),this._render(o)}connectedCallback(){this._runLogicWithinErrorBoundary(i,()=>{let e=this.getRootNode();e&&e!==document&&`host`in e&&Se(e,this);let t=this.getAttribute(`data-cer-hydrate`);if(t!==`none`){if(t===`idle`){let e=()=>this._hydrateNow(i);typeof requestIdleCallback<`u`?requestIdleCallback(e):setTimeout(e,200);return}if(t===`visible`){new IntersectionObserver((e,t)=>{e.some(e=>e.isIntersecting)&&(t.disconnect(),this._hydrateNow(i))},{rootMargin:`0px`,threshold:0}).observe(this);return}this._applyProps(i),this._render(i),h(i,this.context,this._mounted,e=>{this._mounted=e})}})}_hydrateNow(e){this._runLogicWithinErrorBoundary(e,()=>{this._applyProps(e),this._render(e),h(e,this.context,this._mounted,e=>{this._mounted=e})})}disconnectedCallback(){this._runLogicWithinErrorBoundary(i,()=>{let e=this.getRootNode();e&&e!==document&&`host`in e&&Ce(e,this),g(i,this.context,this._listeners,()=>{this._listeners=[]},()=>{this._watchers.clear()},e=>{this._templateLoading=e},e=>{this._templateError=e},e=>{this._mounted=e}),n.v.cleanup(this._componentId)})}attributeChangedCallback(e,t,n){this._runLogicWithinErrorBoundary(i,()=>{this._applyProps(i),t!==n&&this._requestRender(),_(i,e,t,n,this.context)})}static get observedAttributes(){return i.props?Object.keys(i.props).map(n.p):[]}_render(e){this._runLogicWithinErrorBoundary(e,()=>{we(this.shadowRoot,e,this.context,this._refs,e=>{this._lastHtmlStringForJitCSS=e,typeof this.onHtmlStringUpdate==`function`&&this?.onHtmlStringUpdate?.(e)},e=>{this._templateLoading=e,this?.onLoadingStateChange?.(e)},e=>{this._templateError=e,this?.onErrorStateChange?.(e)},t=>this._applyStyle(e,t))})}requestRender(){this._requestRender()}_requestRender(){this._runLogicWithinErrorBoundary(this._cfg,()=>{n.O(()=>{Ee(()=>this._render(this._cfg),this._lastRenderTime,this._renderCount,e=>{this._lastRenderTime=e},e=>{this._renderCount=e},this._renderTimeoutId,e=>{this._renderTimeoutId=e})},this._componentId)})}_applyStyle(e,t){this._runLogicWithinErrorBoundary(e,()=>{Ae(this.shadowRoot,this.context,t,this._styleSheet,e=>{this._styleSheet=e})})}_runLogicWithinErrorBoundary(t,n){try{n(),this._hasError=!1}catch(n){this._hasError=!0;try{let r=this.tagName?.toLowerCase?.()||`<unknown>`,i=this._componentId||`<unknown-id>`,a={};if(t&&t.props)for(let e of Object.keys(t.props))try{let t=this.context[e];t instanceof Node?a[e]=`[DOM Node: ${t.nodeName}]`:typeof t==`object`&&t?a[e]=Object.keys(t).length>5?`[object(${Object.keys(t).length} keys)]`:t:a[e]=t}catch{a[e]=`[unreadable]`}e.t(`Error rendering component <${r}> (id=${i}):`,n),e.t(`Component props snapshot:`,a),e.r("Common causes: accessing properties of null/undefined inside template interpolations; expensive or throwing expressions inside templates that evaluate eagerly. Fixes: use optional chaining (obj?.prop), guard with ternary, or use the runtime lazy overload: when(cond, () => html`...`).")}catch{}if(t.onError&&t.onError(n,this.context),this.tagName.toLowerCase()!==`cer-error-boundary`){let e=this.parentElement;if(!e){let t=this.getRootNode();t instanceof ShadowRoot&&(e=t.host.parentElement)}for(;e;){if(e.tagName.toLowerCase()===`cer-error-boundary`){e._cerHandleChildError?.(n);break}let t=e.parentElement;if(!t){let n=e.getRootNode();n instanceof ShadowRoot&&(t=n.host.parentElement)}e=t}}}}_initContext(e){try{let t=this;function r(i,a=``){if(Array.isArray(i))return new Proxy(i,{get(r,i,o){let s=Reflect.get(r,i,o);return typeof s==`function`&&typeof i==`string`&&[`push`,`pop`,`shift`,`unshift`,`splice`,`sort`,`reverse`].includes(i)?function(...i){let o=s.apply(r,i);if(!t._initializing){let i=a||`root`;t._triggerWatchers(i,r),n.O(()=>t._render(e),t._componentId)}return o}:s},set(r,i,o){if(r[String(i)]=o,!t._initializing){let r=a?`${a}.${String(i)}`:String(i);t._triggerWatchers(r,o),n.O(()=>t._render(e),t._componentId)}return!0},deleteProperty(r,i){if(delete r[String(i)],!t._initializing){let r=a?`${a}.${String(i)}`:String(i);t._triggerWatchers(r,void 0),n.O(()=>t._render(e),t._componentId)}return!0}});if(i&&typeof i==`object`){if(n._(i))return i;for(let e in i){let t=a?`${a}.${e}`:e;i[e]=r(i[e],t)}return new Proxy(i,{set(i,o,s){let c=a?`${a}.${String(o)}`:String(o);return i[String(o)]=r(s,c),t._initializing||(t._triggerWatchers(c,i[String(o)]),n.O(()=>t._render(e),t._componentId)),!0},get(e,t,n){return Reflect.get(e,t,n)}})}return i}return r({...e.props?Object.fromEntries(Object.entries(e.props).map(([e,t])=>[e,t.default])):{}})}catch{return{}}}_initWatchers(e){this._runLogicWithinErrorBoundary(e,()=>{c(this.context,this._watchers,{})})}_triggerWatchers(e,t){l(this.context,this._watchers,e,t)}_applyProps(e){this._runLogicWithinErrorBoundary(e,()=>{m(this,e,this.context)})}}}function Y(t,n,r,i){for(let a of r)try{a(...i)}catch(r){e.t(`[${t}] Error in ${n} lifecycle hook:`,r)}}function Me(r,a,c){t.a();let l=o.t(r),u={},d={props:{},hydrate:c?.hydrate,onConnected:t=>{if(u.onConnected)try{u.onConnected(t)}catch(t){e.t(`[${l}] Error in onConnected lifecycle hook:`,t)}},onDisconnected:t=>{if(u.onDisconnected)try{u.onDisconnected(t)}catch(t){e.t(`[${l}] Error in onDisconnected lifecycle hook:`,t)}},onAttributeChanged:(t,n,r,i)=>{if(u.onAttributeChanged)try{u.onAttributeChanged(t,n,r,i)}catch(t){e.t(`[${l}] Error in onAttributeChanged lifecycle hook:`,t)}},onError:(t,n)=>{if(u.onError&&t)try{u.onError(t,n)}catch(t){e.t(`[${l}] Error in onError handler (the error handler itself threw):`,t)}},render:e=>{let r=e,o=r._componentId||`${l}-${crypto.randomUUID()}`;n.v.setCurrentComponent(o,()=>{e.requestRender&&e.requestRender()});try{Object.defineProperty(e,`_hookCallbacks`,{value:{},writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(e,`_computedStyle`,{value:void 0,writable:!0,enumerable:!1,configurable:!0}),s.c(e),i.resetWhenCounter();let n;try{n=a()}catch(e){try{let t=r._hookCallbacks?.onError;if(Array.isArray(t))for(let n of t)try{n(e)}catch{}else if(typeof t==`function`)try{t(e)}catch{}}catch{}try{let t=r._host;if(t?.parentElement){let n=t.parentElement;for(;n;){if(n.tagName.toLowerCase()===`cer-error-boundary`){n._cerHandleChildError?.(e);break}let t=n.parentElement;if(!t){let e=n.getRootNode();typeof ShadowRoot<`u`&&e instanceof ShadowRoot&&(t=e.host.parentElement)}n=t}}}catch{}throw e}if(n==null)throw Error(`[${l}] Component render function did not return a value. Make sure your component returns an html\`...\` template.`);if(r._hookCallbacks){let e=r._hookCallbacks;if(e.onConnected){let t=e.onConnected;u.onConnected=e=>{Y(l,`useOnConnected`,t,[e])}}if(e.onDisconnected){let t=e.onDisconnected;u.onDisconnected=e=>{Y(l,`useOnDisconnected`,t,[e])}}if(e.onAttributeChanged){let t=e.onAttributeChanged;u.onAttributeChanged=(e,n,r,i)=>{Y(l,`useOnAttributeChanged`,t,[e,n,r,i])}}if(e.onError){let t=e.onError;u.onError=e=>{Y(l,`useOnError`,t,[e])}}if(e.props&&!Object.keys(d.props??{}).length){let n=e.props;d.props=Object.fromEntries(Object.entries(n).map(([e,t])=>[e,{type:typeof t==`boolean`?Boolean:typeof t==`number`?Number:typeof t==`string`?String:Function,default:t}])),t.o.set(l,d)}}return n}finally{s.t(),n.v.clearCurrentComponent()}}};if(t.o.set(l,d),typeof window<`u`){try{let r={_hookCallbacks:{},requestRender:()=>{},emit:()=>!0};s.c(r),n.S(),i.resetWhenCounter();try{a()}catch(t){try{let n=r?._hookCallbacks?.onError;if(Array.isArray(n))for(let e of n)try{e(t)}catch{}else if(typeof n==`function`)try{n(t)}catch{}e.t(`Error during component discovery render <${l}>:`,t),e.r(`Error occurred during initial component discovery render. Consider guarding expensive expressions or using lazy factories for directives like when().`)}catch{}throw t}finally{n.C(),s.t()}if(r._hookCallbacks?.props){let e=r._hookCallbacks.props;d.props=Object.fromEntries(Object.entries(e).map(([e,t])=>[e,{type:typeof t==`boolean`?Boolean:typeof t==`number`?Number:typeof t==`string`?String:Function,default:t}])),t.o.set(l,d)}}catch(t){e.r(`[${l}] Failed to register component. Check your component definition for errors.`,t)}typeof customElements<`u`&&!customElements.get(l)&&customElements.define(l,je(l,d))}}function X(e,t={},n,r){return{tag:e,key:r??t.key,props:t,children:n}}function Z(e){return!!e&&typeof e==`object`&&(e.type===`AnchorBlock`||e.tag===`#anchor`)}function Q(e){return typeof e==`object`&&!!e&&`tag`in e&&!Z(e)}function Ne(e,t){return e.key==null?{...e,key:t}:e}function Pe(t,n){if(t==null){e.r(`⚠️ Event handler for '@${n}' is ${t}. This will prevent the event from working. Use a function reference instead: @${n}="\${functionName}"`);return}typeof t!=`function`&&e.r(`🚨 Potential infinite loop detected! Event handler for '@${n}' appears to be the result of a function call (${typeof t}) instead of a function reference. Change @${n}="\${functionName()}" to @${n}="\${functionName}" to pass the function reference instead of calling it immediately.`),t===void 0&&typeof t!=`function`&&e.r(`💡 Tip: If your event handler function returns undefined, make sure you're passing the function reference, not calling it. Use @${n}="\${fn}" not @${n}="\${fn()}"`)}function Fe(e,t=[],r={}){let i={},a={},o={},s=[],c=/([:@#]?)([a-zA-Z0-9-:.]+)(?:\s*=\s*("([^"\\]*(\\.[^"\\]*)*)"|'([^'\\]*(\\.[^'\\]*)*)'|([^\s>]+)))?/g,l;for(;l=c.exec(e);){let e=l[1],c=l[2],u=``;for(let e=3;e<l.length;e++)if(l[e]!==void 0){u=l[e];break}u.length>=2&&(u[0]===`"`&&u[u.length-1]===`"`||u[0]===`'`&&u[u.length-1]===`'`)&&(u=u.slice(1,-1));let d=!/=/.test(l[0]),f=u.match(/^{{(\d+)}}$/),p=!f&&/{{(\d+)}}/.test(u),m=d?!0:f?t[Number(f[1])]??null:p?u.replace(/{{(\d+)}}/g,(e,n)=>String(t[Number(n)]??``)):u;!f&&!p&&(m===`true`?m=!0:m===`false`?m=!1:m===`null`?m=null:isNaN(Number(m))||(m=Number(m)));let h=[`model`,`bind`,`show`,`class`,`style`,`ref`,`when`];if(e===`:`){let[e,t]=c.split(`:`),[r,...l]=e.split(`.`);if(h.includes(r)){let e=[...l],n=r===`model`&&t?`model:${t}`:r;o[n]={value:m,modifiers:e,arg:t}}else if(c===`disabled`){let e=m;e&&n._(e)&&(e=e.value);let t=typeof e;if(e===``||t===`boolean`||t===`string`&&(e===`true`||e===`false`)||e==null||t===`number`)i[c]=e;else{let e=m;e&&n._(e)&&(e=e.value),a[c]=e}s.push(c)}else{let e=m;e&&n._(e)&&(e=e.value),a[c]=e,s.push(c)}}else if(e===`@`){let[e,...t]=c.split(`.`),n=t;Pe(m,e);let a=typeof m==`function`?m:typeof r[m]==`function`?r[m]:void 0;if(a){let t=r=>{if(n.includes(`prevent`)&&r.preventDefault(),n.includes(`stop`)&&r.stopPropagation(),!(n.includes(`self`)&&r.target!==r.currentTarget))return n.includes(`once`)&&r.currentTarget?.removeEventListener(e,t),a(r)},r=`on`+e.charAt(0).toUpperCase()+e.slice(1);i[r]=t}}else c===`ref`?i.ref=m:a[c]=m}return{props:i,attrs:a,directives:o,bound:s}}function $(e){if(!Q(e)||Z(e))return e;let t=e.props?.directives;if(t&&t.when){let r=t.when.value,i=n._(r)?r.value:r,a={...t};delete a.when;let o={...e.props};Object.keys(a).length>0?o.directives=a:delete o.directives;let s={...e,props:o};return Array.isArray(s.children)&&(s.children=s.children.map(e=>typeof e==`object`&&e?$(e):e)),{tag:`#anchor`,key:e.key==null?`when-${e.tag}`:`when-${e.key}`,children:i?[s]:[]}}if(Array.isArray(e.children)){let t=e.children.map(e=>typeof e==`object`&&e?$(e):e);return{...e,children:t}}return e}function Ie(e,t,r){let i=q.length>0?q[q.length-1]:void 0,a=r??i,o=!r&&t.length===0,s=o?e.join(`<!--TEMPLATE_DELIM-->`):null;if(o&&s){let e=b.get(s);if(e)return e}function c(e,t){return X(`#text`,{},e,t)}function l(e,t,r=!1){let i=typeof e==`string`?n.n(e):e;return!r&&typeof i==`string`&&/[\r\n]/.test(i)&&(i=i.replace(/\s+/g,` `)),X(`#text`,{},i,t)}let u=``;for(let n=0;n<e.length;n++)u+=e[n],n<t.length&&(u+=`{{${n}}}`);let d=/<!--[\s\S]*?-->|<\/?([a-zA-Z0-9-]+)((?:\s+[^\s=>/]+(?:\s*=\s*(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|[^\s>]+))?)*)\s*\/?>|{{(\d+)}}|([^<]+)/g,f=[],p,m=[],h=null,g={},_,v=0,y=[],x=new Set([`pre`,`code`,`textarea`,`script`,`style`]);function ee(){if(h&&x.has(h.toLowerCase()))return!0;for(let e of f)if(x.has(e.tag.toLowerCase()))return!0;return!1}function S(e){if(!e||typeof e!=`object`||Z(e))return;let t=e,n=g;if(t.props||t.attrs){let e=t;e.props&&(n.props||={},Object.assign(n.props,e.props)),e.attrs&&(n.attrs||={},Object.keys(e.attrs).forEach(t=>{if(t===`style`&&n.attrs.style){let t=String(n.attrs.style).replace(/;?\s*$/,``),r=String(e.attrs.style).replace(/^;?\s*/,``);n.attrs.style=t+`; `+r}else if(t===`class`&&n.attrs.class){let t=String(n.attrs.class).trim().split(/\s+/).filter(Boolean),r=String(e.attrs.class).trim().split(/\s+/).filter(Boolean),i=[...new Set([...t,...r])];n.attrs.class=i.join(` `)}else n.attrs[t]=e.attrs[t]}))}else n.props||={},Object.assign(n.props,t)}function C(e,t){let r=h?m:y;if(Z(e)){let n=e.key??t,i=e.children;r.push({...e,key:n,children:i});return}if(Q(e)){r.push(Ne(e,void 0));return}if(Array.isArray(e)){if(e.length===0)return;for(let i=0;i<e.length;i++){let a=e[i];Z(a)||Q(a)||Array.isArray(a)?C(a,`${t}-${i}`):typeof a==`object`&&a?n.o(a)?r.push(X(`#raw`,{},a.__rawHTML,`${t}-${i}`)):S(a):r.push(c(String(a),`${t}-${i}`))}return}if(typeof e==`object`&&e){if(n.o(e)){let n=e.__rawHTML??``;r.push(X(`#raw`,{},n,t));return}S(e);return}r.push(c(String(e),t))}let w=new Set([`area`,`base`,`br`,`col`,`embed`,`hr`,`img`,`input`,`link`,`meta`,`param`,`source`,`track`,`wbr`]);for(;p=d.exec(u);)if(!(p[0].startsWith(`<!--`)&&p[0].endsWith(`-->`))){if(p[1]){let e=p[1],r=p[0][1]===`/`,i=p[0][p[0].length-2]===`/`||w.has(e),{props:o,attrs:s,directives:c,bound:l}=Fe(p[2]||``,t,a??{}),u={props:{},attrs:{}};for(let e in o)u.props[e]=o[e];for(let e in s)u.attrs[e]=s[e];u.attrs&&Object.prototype.hasOwnProperty.call(u.attrs,`key`)&&!(u.props&&Object.prototype.hasOwnProperty.call(u.props,`key`))&&n.l(()=>{u.props.key=u.attrs.key});try{let t={input:[`value`,`checked`,`readonly`,`required`,`placeholder`,`maxlength`,`minlength`],textarea:[`value`,`readonly`,`required`,`placeholder`,`maxlength`,`minlength`],select:[`value`,`required`,`multiple`],option:[`selected`,`value`],video:[`muted`,`autoplay`,`controls`,`loop`,`playsinline`],audio:[`muted`,`autoplay`,`controls`,`loop`],img:[`src`,`alt`,`width`,`height`],button:[`type`,`name`,`value`,`autofocus`,`form`]},r=e.toLowerCase(),i=t[r]??[];if(u.attrs){for(let e of i)if(l&&l.includes(e)&&e in u.attrs&&!(u.props&&e in u.props)){let t=u.attrs[e];if(t&&n._(t))t=t.value,u.props[e]=t,delete u.attrs[e];else if(t&&typeof t==`object`&&`value`in t&&!(t instanceof Node))try{let n=t.value;u.props[e]=(r===`select`||r===`option`)&&e===`value`?String(n):n,delete u.attrs[e]}catch{}else{let n=typeof t;if(e===`disabled`)(t===``||n===`boolean`||n===`string`&&(t===`true`||t===`false`)||t==null||n===`number`)&&(u.props[e]=t,delete u.attrs[e]);else if(t===``||n===`string`||n===`number`||n===`boolean`||t==null){let n=(r===`select`||r===`option`)&&e===`value`?String(t):t;u.props[e]=n,delete u.attrs[e]}}}}if(e.includes(`-`)||a?.__customElements?.has?.(e)){if(u.isCustomElement=!0,l&&u.attrs){let e=new Set([`id`,`name`,`data-key`,`key`]);for(let t of l)if(t in u.attrs&&!(u.props&&t in u.props)){let r=t.includes(`-`)?n.f(t):t,i=u.attrs[t];if(u.props[r]=i,e.has(t)||n.a(t))try{let e=n.u(u.attrs[t]);e===null?delete u.attrs[t]:u.attrs[t]=e}catch{delete u.attrs[t]}else delete u.attrs[t]}}try{if(u.attrs&&!(u.props&&`modelValue`in u.props)){let e=u.attrs[`model-value`]??u.attrs.modelValue;e!==void 0&&(u.props.modelValue=e)}}catch{}}}catch{}if(c&&Object.keys(c).some(e=>e===`model`||e.startsWith(`model:`)))try{let t=globalThis[Symbol.for(`cer.registry`)],r=!!(t&&typeof t.has==`function`&&t.has(e)),i=a,o=!!(i&&(i.__customElements instanceof Set&&i.__customElements.has(e)||Array.isArray(i.__isCustomElements)&&i.__isCustomElements.includes(e)));if(e.includes(`-`)||o||r)for(let e of Object.keys(c)){if(e!==`model`&&!e.startsWith(`model:`))continue;let t=c[e],r=t.arg??(e.includes(`:`)?e.split(`:`,2)[1]:void 0),i=t.value,o=r??`modelValue`,s=n.i,l=n.d,d=a?._state||a,f;if(typeof i==`string`&&d)f=s(d,i);else if(f=i,n._(i))try{i.value}catch{}u.props[o]=f;try{let e=n.p(o);u.attrs||={},f!=null&&(typeof f==`string`||typeof f==`number`||typeof f==`boolean`)&&(u.attrs[e]=f)}catch{}u.isCustomElement=!0;let p=`update:${n.p(o)}`.replace(/-([a-z])/g,(e,t)=>t.toUpperCase()),m=`on`+p.charAt(0).toUpperCase()+p.slice(1);u.props[m]=function(e){let t=e.detail===void 0?e.target?e.target.value:void 0:e.detail;if(d)if(i&&n._(i)){let e=i.value;if(Array.isArray(t)&&Array.isArray(e)?JSON.stringify([...t].sort())!==JSON.stringify([...e].sort()):t!==e){i.value=t;try{let e=a;if(e){let t=e.requestRender,n=e._requestRender;typeof t==`function`?t():typeof n==`function`&&n()}}catch{}}}else{let e=s(d||{},typeof i==`string`?i:String(i));if(Array.isArray(t)&&Array.isArray(e)?JSON.stringify([...t].sort())!==JSON.stringify([...e].sort()):t!==e){l(d||{},typeof i==`string`?i:String(i),t);try{let e=a;if(e){let t=e.requestRender,n=e._requestRender;typeof t==`function`?t():typeof n==`function`&&n()}}catch{}}}},delete c[e]}}catch{}if(Object.keys(c).length>0&&(u.directives={...c}),r){let e=m.some(e=>typeof e==`object`&&e.tag!==`#text`),t=m;if(e&&m.length>0){let e=0;for(;e<m.length;){let t=m[e];if(!Q(t)||t.tag!==`#text`||typeof t.children!=`string`||t.children.trim()!==``)break;e++}let n=m.length-1;for(;n>=0;){let e=m[n];if(!Q(e)||e.tag!==`#text`||typeof e.children!=`string`||e.children.trim()!==``)break;n--}t=e===0&&n===m.length-1?m:e>n?[]:m.slice(e,n+1)}let n=X(h,g,t.length===1&&Q(t[0])&&t[0].tag===`#text`?typeof t[0].children==`string`?t[0].children:``:t.length?t:void 0,_),r=f.pop();r?(h=r.tag,g=r.props,_=r.key,m=r.children,m.push(n)):(y.push(n),h=null,g={},_=void 0,m=[])}else i?h?m.push(X(e,u,void 0,void 0)):y.push(X(e,u,void 0,void 0)):(h&&f.push({tag:h,props:g,children:m,key:_}),h=e,g=u,m=[])}else if(p[3]!==void 0){let e=Number(p[3]),n=t[e];C(n,`interp-${e}`)}else if(p[4]){let e=p[4],n=h?m:y,r=e.split(/({{\d+}})/);for(let e of r){if(!e)continue;let r=e.match(/^{{(\d+)}}$/);if(r){let e=Number(r[1]),n=t[e];C(n,`interp-${e}`)}else{let t=`text-${v++}`,r=ee();n.push(l(e,t,r))}}}}let T=y.filter(e=>Q(e)&&e.tag===`#text`?typeof e.children==`string`&&e.children.trim()!==``:!0).map(e=>$(e));if(T.length===1){let e=T[0];return o&&s&&b.set(s,e),e}else if(T.length>1){let e=T;return o&&s&&b.set(s,e),e}return X(`div`,{},``,`fallback-root`)}function Le(e,...t){if(n.w())return[];let r=t[t.length-1];return Ie(e,t,typeof r==`object`&&r&&!Array.isArray(r)?r:void 0)}Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return Me}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return ve}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return Le}});
|
|
19
|
+
//# sourceMappingURL=template-compiler-D3r3ajIB.cjs.map
|