@jasonshimmy/custom-elements-runtime 3.7.3 → 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.
@@ -1,4 +1,4 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./logger-Dkht1dCX.cjs`),t=require(`./helpers-BQ37xfhc.cjs`),n=require(`./template-compiler-CeeH0904.cjs`),r=require(`./css-utils-CFeP8SK1.cjs`),i=require(`./hooks-DTyLoDNI.cjs`);function a(e,t,r){let a=`idle`,o=null,s={fn:()=>{}},c=!1,l=!1,u=null,d=(e,t)=>{l||(l=!0,u!==null&&clearTimeout(u),t&&(o=t),a=e,s.fn())},f=()=>{c||(c=!0,a=`loading`,r?.timeout!=null&&(u=setTimeout(()=>d(`timeout`),r.timeout)),t().then(e=>d(`resolved`,e)).catch(()=>d(`error`)))};n.n(e,()=>{let e=i.i();switch(typeof e?.requestRender==`function`&&(s.fn=()=>{e.requestRender()}),a){case`idle`:return f(),r?.loading?.()??[];case`loading`:return r?.loading?.()??[];case`resolved`:return o();case`error`:case`timeout`:return r?.error?.()??[]}})}function o(e=document){typeof CustomEvent>`u`||(e instanceof Document?e.documentElement:e).dispatchEvent(new CustomEvent(`cer:hydrate`,{bubbles:!0,composed:!0}))}var s=100,c=3e4;function l(e,t,n){return n===`jitCacheHitRate`?e<t*.5?`critical`:e<t?`warning`:`healthy`:e>t*2?`critical`:e>t?`warning`:`healthy`}function u(e){let t=[];return e.memoryUsage?.status!==`healthy`&&t.push(`Consider reducing component complexity or implementing better memory cleanup`),e.averageRenderTime?.status!==`healthy`&&t.push(`Optimize component render functions - consider lazy loading or virtualization`),e.jitCacheHitRate?.status!==`healthy`&&t.push(`JIT CSS cache performance is poor - review CSS patterns for optimization`),e.componentErrorRate?.status!==`healthy`&&t.push(`High component error rate detected - review error handling and component logic`),e.activeReactiveStates?.status!==`healthy`&&t.push(`High number of reactive states - consider state consolidation or cleanup`),e.memoryLeakIndicator?.status!==`healthy`&&t.push(`Potential memory leak detected - review component cleanup and event listener management`),t}function d(){let t=new Map,n=new Set,r=null;function i(e,n,r){t.set(e,{name:e,value:n,threshold:r,status:`healthy`,lastUpdated:Date.now(),history:[]})}function a(){i(`activeComponents`,0,1e3),i(`componentCreateRate`,0,50),i(`componentErrorRate`,0,.1),i(`memoryUsage`,0,50*1024*1024),i(`memoryGrowthRate`,0,1024*1024),i(`averageRenderTime`,0,16),i(`slowRenderCount`,0,10),i(`jitCacheHitRate`,100,80),i(`activeReactiveStates`,0,5e3),i(`dependencyUpdates`,0,100),i(`memoryLeakIndicator`,0,.1)}function o(e,n){let r=t.get(e);r&&(r.value=n,r.lastUpdated=Date.now(),r.history.push(n),r.history.length>s&&r.history.shift(),r.status=l(n,r.threshold,e))}function d(){let e={},n=`healthy`;for(let[r,i]of t)e[r]={...i},i.status===`critical`?n=`critical`:i.status===`warning`&&n===`healthy`&&(n=`warning`);return{overall:n,metrics:e,timestamp:Date.now(),recommendations:u(e)}}function f(){if(`memory`in performance&&performance.memory){let e=performance.memory;o(`memoryUsage`,e.usedJSHeapSize);let n=t.get(`memoryUsage`);if(n&&n.history.length>1){let e=n.history[n.history.length-2],t=n.history[n.history.length-1];o(`memoryGrowthRate`,Math.max(0,t-e))}}}function p(t){for(let r of n)try{r(t)}catch(t){e.t(`Error in health monitor listener:`,t)}}function m(){f();let t=d();p(t),t.overall===`critical`?e.t(`🚨 Runtime Health: Critical issues detected`,t.recommendations):t.overall===`warning`&&e.r(`⚠️ Runtime Health: Performance warnings`,t.recommendations)}function h(){typeof window>`u`||(r=setInterval(m,c))}function g(){r!==null&&(clearInterval(r),r=null)}function _(e){n.add(e)}function v(e){n.delete(e)}function y(e){let n=t.get(e);return n?[...n.history]:[]}function b(){for(let e of t.values())e.history=[]}return a(),h(),{updateMetric:o,getHealthReport:d,addListener:_,removeListener:v,stop:g,getMetricHistory:y,clearHistory:b}}var f=null;function p(){return f||=d(),f}function m(e,t){p().updateMetric(e,t)}function h(){return p().getHealthReport()}function g(){typeof window>`u`||typeof customElements>`u`||customElements.get(`cer-keep-alive`)||customElements.define(`cer-keep-alive`,_())}function _(){return class extends HTMLElement{_cache=new Map;_slot=null;_slotListener=null;connectedCallback(){this.shadowRoot||this.attachShadow({mode:`open`}),this.shadowRoot.querySelector(`slot`)||(this.shadowRoot.innerHTML=`<slot></slot>`),this._slot=this.shadowRoot.querySelector(`slot`),this._slot&&(this._slotListener=()=>this._handleSlotChange(),this._slot.addEventListener(`slotchange`,this._slotListener),this._handleSlotChange())}disconnectedCallback(){this._slot&&this._slotListener&&this._slot.removeEventListener(`slotchange`,this._slotListener),this._slotListener=null}clearCache(e){e?this._cache.delete(e):this._cache.clear()}_handleSlotChange(){if(!this._slot)return;let e=this._slot.assignedElements({flatten:!0});for(let t of e){let e=this._buildCacheKey(t);if(!this._cache.has(e))this._cache.set(e,t);else{let n=this._cache.get(e);if(n!==t)try{t.parentNode?.replaceChild(n,t)}catch{this._cache.set(e,t)}}}}_buildCacheKey(e){let t=e.tagName.toLowerCase(),n=e.getAttribute(`id`);return n?`${t}:${n}`:t}}}function v(){typeof customElements<`u`&&customElements.get(`cer-suspense`)||n.n(`cer-suspense`,()=>{let{pending:e}=i._({pending:!1});return e?n.t`<slot name="fallback"><span>Loading…</span></slot>`:n.t`<slot></slot>`})}function y(){typeof customElements<`u`&&customElements.get(`cer-error-boundary`)||n.n(`cer-error-boundary`,()=>{let e=t.y(!1),r=t.y(``);return i.g(t=>{e.value=!0,r.value=t.message}),i.d({_cerHandleChildError:t=>{e.peek()||(e.value=!0,r.value=t instanceof Error?t.message:String(t))},reset:()=>{e.value=!1,r.value=``}}),e.value?n.t`<slot name="fallback"
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./logger-Dkht1dCX.cjs`),t=require(`./helpers-BQ37xfhc.cjs`),n=require(`./template-compiler-D3r3ajIB.cjs`),r=require(`./css-utils-CFeP8SK1.cjs`),i=require(`./hooks-DTyLoDNI.cjs`);function a(e,t,r){let a=`idle`,o=null,s={fn:()=>{}},c=!1,l=!1,u=null,d=(e,t)=>{l||(l=!0,u!==null&&clearTimeout(u),t&&(o=t),a=e,s.fn())},f=()=>{c||(c=!0,a=`loading`,r?.timeout!=null&&(u=setTimeout(()=>d(`timeout`),r.timeout)),t().then(e=>d(`resolved`,e)).catch(()=>d(`error`)))};n.n(e,()=>{let e=i.i();switch(typeof e?.requestRender==`function`&&(s.fn=()=>{e.requestRender()}),a){case`idle`:return f(),r?.loading?.()??[];case`loading`:return r?.loading?.()??[];case`resolved`:return o();case`error`:case`timeout`:return r?.error?.()??[]}})}function o(e=document){typeof CustomEvent>`u`||(e instanceof Document?e.documentElement:e).dispatchEvent(new CustomEvent(`cer:hydrate`,{bubbles:!0,composed:!0}))}var s=100,c=3e4;function l(e,t,n){return n===`jitCacheHitRate`?e<t*.5?`critical`:e<t?`warning`:`healthy`:e>t*2?`critical`:e>t?`warning`:`healthy`}function u(e){let t=[];return e.memoryUsage?.status!==`healthy`&&t.push(`Consider reducing component complexity or implementing better memory cleanup`),e.averageRenderTime?.status!==`healthy`&&t.push(`Optimize component render functions - consider lazy loading or virtualization`),e.jitCacheHitRate?.status!==`healthy`&&t.push(`JIT CSS cache performance is poor - review CSS patterns for optimization`),e.componentErrorRate?.status!==`healthy`&&t.push(`High component error rate detected - review error handling and component logic`),e.activeReactiveStates?.status!==`healthy`&&t.push(`High number of reactive states - consider state consolidation or cleanup`),e.memoryLeakIndicator?.status!==`healthy`&&t.push(`Potential memory leak detected - review component cleanup and event listener management`),t}function d(){let t=new Map,n=new Set,r=null;function i(e,n,r){t.set(e,{name:e,value:n,threshold:r,status:`healthy`,lastUpdated:Date.now(),history:[]})}function a(){i(`activeComponents`,0,1e3),i(`componentCreateRate`,0,50),i(`componentErrorRate`,0,.1),i(`memoryUsage`,0,50*1024*1024),i(`memoryGrowthRate`,0,1024*1024),i(`averageRenderTime`,0,16),i(`slowRenderCount`,0,10),i(`jitCacheHitRate`,100,80),i(`activeReactiveStates`,0,5e3),i(`dependencyUpdates`,0,100),i(`memoryLeakIndicator`,0,.1)}function o(e,n){let r=t.get(e);r&&(r.value=n,r.lastUpdated=Date.now(),r.history.push(n),r.history.length>s&&r.history.shift(),r.status=l(n,r.threshold,e))}function d(){let e={},n=`healthy`;for(let[r,i]of t)e[r]={...i},i.status===`critical`?n=`critical`:i.status===`warning`&&n===`healthy`&&(n=`warning`);return{overall:n,metrics:e,timestamp:Date.now(),recommendations:u(e)}}function f(){if(`memory`in performance&&performance.memory){let e=performance.memory;o(`memoryUsage`,e.usedJSHeapSize);let n=t.get(`memoryUsage`);if(n&&n.history.length>1){let e=n.history[n.history.length-2],t=n.history[n.history.length-1];o(`memoryGrowthRate`,Math.max(0,t-e))}}}function p(t){for(let r of n)try{r(t)}catch(t){e.t(`Error in health monitor listener:`,t)}}function m(){f();let t=d();p(t),t.overall===`critical`?e.t(`🚨 Runtime Health: Critical issues detected`,t.recommendations):t.overall===`warning`&&e.r(`⚠️ Runtime Health: Performance warnings`,t.recommendations)}function h(){typeof window>`u`||(r=setInterval(m,c))}function g(){r!==null&&(clearInterval(r),r=null)}function _(e){n.add(e)}function v(e){n.delete(e)}function y(e){let n=t.get(e);return n?[...n.history]:[]}function b(){for(let e of t.values())e.history=[]}return a(),h(),{updateMetric:o,getHealthReport:d,addListener:_,removeListener:v,stop:g,getMetricHistory:y,clearHistory:b}}var f=null;function p(){return f||=d(),f}function m(e,t){p().updateMetric(e,t)}function h(){return p().getHealthReport()}function g(){typeof window>`u`||typeof customElements>`u`||customElements.get(`cer-keep-alive`)||customElements.define(`cer-keep-alive`,_())}function _(){return class extends HTMLElement{_cache=new Map;_slot=null;_slotListener=null;connectedCallback(){this.shadowRoot||this.attachShadow({mode:`open`}),this.shadowRoot.querySelector(`slot`)||(this.shadowRoot.innerHTML=`<slot></slot>`),this._slot=this.shadowRoot.querySelector(`slot`),this._slot&&(this._slotListener=()=>this._handleSlotChange(),this._slot.addEventListener(`slotchange`,this._slotListener),this._handleSlotChange())}disconnectedCallback(){this._slot&&this._slotListener&&this._slot.removeEventListener(`slotchange`,this._slotListener),this._slotListener=null}clearCache(e){e?this._cache.delete(e):this._cache.clear()}_handleSlotChange(){if(!this._slot)return;let e=this._slot.assignedElements({flatten:!0});for(let t of e){let e=this._buildCacheKey(t);if(!this._cache.has(e))this._cache.set(e,t);else{let n=this._cache.get(e);if(n!==t)try{t.parentNode?.replaceChild(n,t)}catch{this._cache.set(e,t)}}}}_buildCacheKey(e){let t=e.tagName.toLowerCase(),n=e.getAttribute(`id`);return n?`${t}:${n}`:t}}}function v(){typeof customElements<`u`&&customElements.get(`cer-suspense`)||n.n(`cer-suspense`,()=>{let{pending:e}=i._({pending:!1});return e?n.t`<slot name="fallback"><span>Loading…</span></slot>`:n.t`<slot></slot>`})}function y(){typeof customElements<`u`&&customElements.get(`cer-error-boundary`)||n.n(`cer-error-boundary`,()=>{let e=t.y(!1),r=t.y(``);return i.g(t=>{e.value=!0,r.value=t.message}),i.d({_cerHandleChildError:t=>{e.peek()||(e.value=!0,r.value=t instanceof Error?t.message:String(t))},reset:()=>{e.value=!1,r.value=``}}),e.value?n.t`<slot name="fallback"
2
2
  ><div role="alert">
3
3
  <strong>Something went wrong.</strong>
4
4
  ${r.value?n.t`<p>${r.value}</p>`:n.t``}
@@ -1,6 +1,6 @@
1
1
  import { i as e, n as t, r as n, t as r } from "./logger-DIJ0UH3R.js";
2
2
  import { D as i, E as a, _ as o, b as s, g as c, h as l, k as u, m as d, n as f, v as p, x as m, y as h } from "./helpers-llht6g11.js";
3
- import { n as g, r as _, t as v } from "./template-compiler-BpHiWIRk.js";
3
+ import { n as g, r as _, t as v } from "./template-compiler-D7BToKVe.js";
4
4
  import { o as y } from "./css-utils-Bn-dO44e.js";
5
5
  import { _ as b, a as x, d as S, f as C, g as w, h as T, i as E, l as D, m as O, n as k, o as A, p as ee, r as j, s as M, u as N, v as P, y as F } from "./hooks-BZwRvrjJ.js";
6
6
  //#region src/lib/runtime/component/async-component.ts
@@ -1,4 +1,4 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./logger-Dkht1dCX.cjs`),t=require(`./helpers-BQ37xfhc.cjs`),n=require(`./template-compiler-CeeH0904.cjs`),r=require(`./custom-elements-runtime.directives.cjs.js`),i=require(`./hooks-DTyLoDNI.cjs`),a=require(`./custom-elements-runtime.store.cjs.js`);var o={enabled:!0,offset:0,timeoutMs:2e3},s=e=>!e||typeof URLSearchParams>`u`?{}:Object.fromEntries(new URLSearchParams(e)),c=e=>{if(!e||Object.keys(e).length===0)return``;try{return`?`+new URLSearchParams(e).toString()}catch{return``}},l=e=>e?/^\s*javascript\s*:/i.test(e):!1,u=e=>/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(e)||e.startsWith(`//`),d=e=>{try{return decodeURIComponent(e)}catch{return e}};function f(e){if(!e)return`/`;let t=e.replace(/\/+/g,`/`);return t.startsWith(`/`)||(t=`/`+t),t.length>1&&t.endsWith(`/`)&&(t=t.slice(0,-1)),t}var p=e=>{if(!e)return``;let t=f(e);return t===`/`?``:t},m=new WeakMap;function h(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function g(t){let n=f(t.path||`/`),r=n===`/`?[]:n.split(`/`).filter(Boolean),i=[],a=[];for(let n=0;n<r.length;n++){let o=r[n];if(o===`*`){if(n!==r.length-1)return e.r(`Route '${t.path}' contains a '*' splat in a non-terminal position; splats must be the last segment. This route will be ignored.`),{invalid:!0};let o=`splat${i.length}`;i.push(o),a.push(`__SPLAT__`);continue}let s=o.match(/^:([A-Za-z0-9_-]+)(\*)?$/);if(s){let o=s[1],c=!!s[2];if(c&&n!==r.length-1)return e.r(`Route '${t.path}' contains a splat param ':${o}*' in a non-terminal position; splats must be the last segment. This route will be ignored.`),{invalid:!0};i.push(o),a.push(c?`__SPLAT__`:`([^/]+)`);continue}a.push(h(o))}let o;if(a.length===0)o=`^/$`;else if(a[a.length-1]===`__SPLAT__`){let e=a.slice(0,-1).join(`/`);o=e?`^/${e}(?:/(.*))?(?:/)?$`:`^(?:/(.*))?(?:/)?$`}else o=`^/${a.join(`/`)}(?:/)?$`;try{return{regex:new RegExp(o),paramNames:i}}catch(n){return e.r(`Failed to compile route regex for '${t.path}': ${String(n)}`),{invalid:!0}}}var _=(e,t)=>{let n=f(t);for(let t of e){let e=m.get(t);if(e||(e=g(t),m.set(t,e)),e.invalid)continue;let{regex:r,paramNames:i}=e,a=r.exec(n);if(a){let e={};for(let t=0;t<i.length;t++){let n=a[t+1]||``;e[i[t]]=n?d(n):``}return{route:t,params:e}}}return{route:null,params:{}}};function v(e,t){for(let n of e)if(_([n],t).route!==null)return n;return null}function y(e,t){let n=t.split(`?`)[0].split(`#`)[0];return _(e,n)}var b=50,x={},S={};function C(){x={},S={}}function w(){let e=Object.entries(x);if(e.length<=b)return;let t=e.sort(([,e],[,t])=>e.lastAccessed-t.lastAccessed).slice(0,e.length-b);for(let[e]of t)delete x[e]}async function T(t){if(t.component)return t.component;if(t.load){let n=x[t.path];if(n)return n.lastAccessed=Date.now(),n.component;if(S[t.path]!==void 0)return S[t.path];let r=typeof window>`u`;try{let n=t.load().then(e=>{w();let n=e.default;return x[t.path]={component:n,lastAccessed:Date.now()},delete S[t.path],n}).catch(n=>{delete S[t.path];let i=n instanceof Error?n.message:String(n);throw r&&e.t(`SSR component load failed for route: ${t.path}. ${i}`),Error(`Failed to load component for route: ${t.path}. ${i}`)});return S[t.path]=n,await n}catch(e){let n=e instanceof Error?e.message:String(e);throw Error(`Failed to load component for route: ${t.path}. ${n}`,{cause:e})}}throw Error(`No component or loader defined for route: ${t.path}`)}var E=null;function D(e){E=e}function O(){return E}var k=new Set,A=null;function j(){if(A){try{A()}catch{}A=null}if(E)try{let e=!1;A=E.subscribe(t=>{e=!0;for(let e of k)try{e(t)}catch{}});try{N.base=E.base}catch{}if(e){let e=E.getCurrent();for(let t of k)try{t(e)}catch{}}else{let e=E.getCurrent();for(let t of k)try{t(e)}catch{}}try{typeof window<`u`&&t.E()}catch{}}catch{A=null}}function M(){j()}var N={store:{subscribe(e){if(E)return E.store.subscribe(e);try{e({path:`/`,params:{},query:{}})}catch{}return()=>{}},getState(){return E?E.getCurrent():{path:`/`,params:{},query:{}}},setState(e){if(E)try{E.store.setState(e)}catch{}}},subscribe(t){if(typeof t!=`function`)return e.r(`activeRouterProxy.subscribe: listener must be a function`),()=>{};if(k.add(t),E)if(!A)j();else try{let e=E.getCurrent();e&&t(e)}catch(t){e.r(`activeRouterProxy subscription failed`,t)}else try{t({path:`/`,params:{},query:{}})}catch(t){e.r(`activeRouterProxy fallback state delivery failed`,t)}return()=>{try{if(k.delete(t),k.size===0&&A){try{A()}catch(t){e.r(`activeRouterProxy inner unsubscribe failed`,t)}A=null}}catch(t){e.r(`activeRouterProxy unsubscribe failed`,t)}}},getCurrent(){return E?E.getCurrent():{path:`/`,params:{},query:{}}},async push(e){return E?E.push(e):Promise.resolve()},async replace(e){return E?E.replace(e):Promise.resolve()},back(){if(E)return E.back()},matchRoute(e){return E?E.matchRoute(e):{route:null,params:{}}},resolveRouteComponent(e){return E?E.resolveRouteComponent(e):Promise.reject(Error(`No active router`))},base:``,scrollToFragment(e){return E?E.scrollToFragment(e):Promise.resolve(!1)},destroy(){E&&E.destroy()}};function P(t){let{routes:n,base:r=``,initialUrl:i,scrollToFragment:l=!0}=t,u=p(r),d=typeof l==`boolean`?{...o,enabled:l}:{...o,...l},m,h,g,y,b,x,S,C=()=>{},w=new Set,E=0,D=async(t,r)=>{let i=v(n,t.path);if(!i||!i.beforeEnter)return!0;try{let n=await i.beforeEnter(t,r);if(typeof n==`string`){let r=`${t.path}->${n}`;return w.has(r)||E>=10?(e.t(`Redirect loop detected: ${r}`),!1):n}return n!==!1}catch(t){e.t(`beforeEnter error`,t);try{g.setState(r)}catch{}throw t}},O=async(t,r)=>{let i=v(n,t.path);if(!i||!i.onEnter)return!0;try{let n=await i.onEnter(t,r);if(typeof n==`string`){let r=`${t.path}->${n}`;return w.has(r)||E>=10?(e.t(`Redirect loop detected: ${r}`),!1):n}return n!==!1}catch(t){e.t(`onEnter error`,t);try{g.setState(r)}catch{}throw t}},k=(t,r)=>{let i=v(n,t.path);if(!(!i||!i.afterEnter))try{let n=i.afterEnter(t,r);n instanceof Promise&&n.catch(t=>{e.t(`afterEnter async error`,t)})}catch(t){e.t(`afterEnter error`,t)}},A=new Map,j=e=>{if(A.has(e))return A.get(e);let t=_(n,e);if(A.size>=100){let e=Array.from(A.keys());for(let t=0;t<25&&t<e.length;t++)A.delete(e[t])}return A.set(e,t),t},M=()=>{};async function N(e,t=0){try{let n=document.getElementById(e);if(!n)return!1;if(t>0)try{let e=n.getBoundingClientRect(),r=Math.max(0,window.scrollY+e.top-t);typeof window.scrollTo==`function`&&window.scrollTo({top:r,behavior:`auto`})}catch{try{n.scrollIntoView()}catch{return!1}}else if(typeof n.scrollIntoView==`function`)try{n.scrollIntoView({behavior:`auto`,block:`start`,inline:`nearest`})}catch{try{n.scrollIntoView()}catch{return!1}}return!0}catch{return!1}}function P(t,n=0,r=2e3){return new Promise(i=>{let a=!1,o=null,s=null,c=Date.now(),l=e=>{a||(a=!0,o&&clearTimeout(o),s!==null&&cancelAnimationFrame(s),i(e))};o=setTimeout(()=>{l(!1)},r),(async()=>{if(!a)try{if(await N(t,n))return l(!0);let i=async()=>{if(!a){if(Date.now()-c>=r)return l(!1);try{if(await N(t,n))return l(!0);s=requestAnimationFrame(i)}catch(t){e.r(`Scroll retry attempt failed:`,t),s=requestAnimationFrame(i)}}};s=requestAnimationFrame(i)}catch(t){e.r(`Initial scroll attempt failed:`,t),l(!1)}})().catch(t=>{e.r(`Scroll attempt failed:`,t),l(!1)})})}let F=!1,I=async(t,n=!1)=>{if(F){e.r(`Navigation to ${t} blocked - navigation already in progress`);return}F=!0,E=0,w.clear();try{await R(t,n)}finally{F=!1,E=0,w.clear()}},L=e=>{let t=e.indexOf(`#`),n=t>=0?e.slice(t+1):``,r=t>=0?e.slice(0,t):e,i=r.indexOf(`?`),a=i>=0?r.slice(0,i):r,o=i>=0?s(r.slice(i)):{};return{path:f((a.startsWith(u)?a.slice(u.length):a)||`/`),query:o,fragment:n}},R=async(t,r=!1)=>{try{let e=L(t),n=j(e.path);if(!n.route)throw Error(`No route found for ${e.path}`);let i=g.getState(),a={path:e.path,params:n.params,query:e.query,fragment:e.fragment},o=await D(a,i);if(o===!1)return;if(typeof o==`string`){E++;let e=`${a.path}->${o}`;w.add(e),await R(o,!0);return}let s=await O(a,i);if(s===!1)return;if(typeof s==`string`){E++;let e=`${a.path}->${s}`;w.add(e),await R(s,!0);return}if(typeof window<`u`&&typeof document<`u`){let t=c(e.query),n=u+e.path+(t||``)+(e.fragment?`#`+e.fragment:``);r?window.history.replaceState({},``,n):window.history.pushState({},``,n)}if(g.setState(a),k(a,i),typeof window<`u`&&typeof document<`u`)try{let e=a.fragment;d.enabled&&e&&P(String(e),d.offset,d.timeoutMs).catch(()=>{})}catch{}}catch(t){if(e.t(`Navigation error:`,t),t instanceof Error&&(t.stack?.includes(`runBeforeEnter`)||t.stack?.includes(`runOnEnter`)))throw t;try{if(!_(n,g.getState().path).route){let t=n.find(e=>e.path===`/`);if(t||=n.find(e=>!e.path.includes(`:`)&&!e.path.includes(`*`)),!t&&n.length>0&&(t=n[0]),t){let e=_(n,t.path);g.setState({path:t.path,params:e.params,query:{}})}else e.t(`No fallback route available for error recovery`)}}catch(t){e.r(`State recovery failed during navigation error:`,t)}}};if((t=>{if(!t||t.length===0)return e.t(`Router configuration error: No routes provided`),!1;let n=new Set;for(let r of t){if(!r.path)return e.t(`Router configuration error: Route missing path`,r),!1;n.has(r.path)&&e.r(`Duplicate route path detected: ${r.path}`),n.add(r.path),!r.component&&!r.load&&e.r(`Route '${r.path}' has no component or load function`)}return!0})(n),typeof window>`u`||i!==void 0){for(let e of n)j(e.path);e.r(`Pre-compiled ${n.length} routes for SSR`)}if(typeof window<`u`&&typeof document<`u`&&i===void 0){m=()=>{try{let e=new URL(window.location.href),t=e.pathname;return{path:f((t.startsWith(u)?t.slice(u.length):t)||`/`),query:s(e.search),fragment:e.hash&&e.hash.length?e.hash.slice(1):``}}catch(t){return e.r(`Invalid URL detected, falling back to safe defaults`,t),{path:`/`,query:{},fragment:``}}},h=m();let t=j(h.path);g=a.createStore({path:h.path,params:t.params,query:h.query,fragment:h.fragment}),y=async(e=!1)=>{await I(m().path,e)};let n=()=>y(!0);window.addEventListener(`popstate`,n),C=()=>window.removeEventListener(`popstate`,n),b=e=>I(e,!1),x=e=>I(e,!0),S=()=>window.history.back(),queueMicrotask(()=>{I(h.path,!0).catch(t=>{e.t(`Initial navigation error:`,t)})})}else{m=()=>{try{let e=new URL(i||`/`,`http://localhost`),t=e.pathname;return{path:f((t.startsWith(u)?t.slice(u.length):t)||`/`),query:s(e.search),fragment:e.hash&&e.hash.length?e.hash.slice(1):``}}catch(t){return e.r(`Invalid SSR URL detected, falling back to safe defaults`,t),{path:`/`,query:{},fragment:``}}},h=m();let t=j(h.path);g=a.createStore({path:h.path,params:t.params,query:h.query,fragment:h.fragment}),y=async()=>{await r(m().path)};let r=async t=>{if(E++,E>10){e.t(`SSR redirect depth exceeded for path: ${t}`);return}try{let e=L(t),i=j(e.path);if(!i.route)throw Error(`No route found for ${e.path}`);let a=g.getState(),o={path:e.path,params:i.params,query:e.query,fragment:e.fragment},s=v(n,o.path);if(s?.beforeEnter){let e=await s.beforeEnter(o,a);if(typeof e==`string`){let t=`${o.path}->${e}`;w.add(t),await r(e);return}if(e===!1)return}if(s?.onEnter){let e=await s.onEnter(o,a);if(typeof e==`string`){let t=`${o.path}->${e}`;w.add(t),await r(e);return}if(e===!1)return}g.setState(o),s?.afterEnter&&s.afterEnter(o,a)}catch(t){throw e.t(`SSR navigation error:`,t),t}};b=async e=>(E=0,w.clear(),r(e)),x=async e=>(E=0,w.clear(),r(e)),S=()=>{}}return{_cleanupScrollState:M,destroy:C,store:g,push:b,replace:x,back:S,subscribe:g.subscribe,matchRoute:e=>j(e),getCurrent:()=>g.getState(),resolveRouteComponent:T,base:u,scrollToFragment:e=>{let t=e||g.getState().fragment;return!t||typeof window>`u`||typeof document>`u`?Promise.resolve(!1):P(t,d.offset,d.timeoutMs)}}}function F(a){C();let o=P(a),s=O();if(s){try{s.destroy()}catch{}try{s._cleanupScrollState?.()}catch{}}D(o);try{M();try{typeof window<`u`&&t.E()}catch{}try{typeof window<`u`&&queueMicrotask(()=>{try{t.E()}catch{}})}catch{}}catch{}return n.n(`router-view`,async()=>{let r=i.i()?._router,a=r??N;if(!O()&&!r)return n.t`<div>Router not initialized.</div>`;let o=t.y(a.getCurrent()),s=typeof window>`u`,c;s||(i.m(()=>{try{typeof a.subscribe==`function`&&(c=a.subscribe(t=>{try{t&&typeof t==`object`&&typeof t.path==`string`?o.value=t:(e.r(`router-view received invalid state`,t),o.value={path:`/`,params:{},query:{}})}catch(t){e.r(`router-view subscription update failed`,t);try{o.value={path:`/`,params:{},query:{}}}catch{}}}))}catch(t){e.r(`router-view subscribe failed`,t)}}),i.h(()=>{if(typeof c==`function`){try{c()}catch(t){e.r(`router-view unsubscribe failed`,t)}c=void 0}}));let l=a.matchRoute(o.value.path);if(!l||!l.route)return n.t`<div>Not found</div>`;try{let e=await a.resolveRouteComponent(l.route);if(typeof e==`string`)return{tag:e,props:{attrs:{...o.value.params}},children:[]};if(typeof e==`function`){let t=e();return(t instanceof Promise?t:Promise.resolve(t)).then(e=>typeof e==`string`?{tag:e,props:{},children:[]}:e)}return n.t`<div>Invalid route component</div>`}catch{return n.t`<div>Invalid route component</div>`}}),n.n(`router-link`,()=>{let a=i._({to:``,tag:`a`,replace:!1,exact:!1,activeClass:`active`,exactActiveClass:`exact-active`,ariaCurrentValue:`page`,disabled:!1,external:!1,class:``,style:``}),o=typeof window>`u`,s=t.y(N.getCurrent()),c=s.value?.path||`/`,d=String(a.to||``),p=o?{isExactActive:I(c,d,N.base),isActive:L(c,d,N.base),isExternal:u(d)||!!a.external}:null,m;i.y(()=>`a,button{display:inline-block;}`);let h=t.y(a.class||``),g=t.y(a.style||``);if(!o){let n=i.i(),r=n?._host??null,o=null,c=null;i.m(()=>{r instanceof HTMLElement&&(c=()=>{let e=String(a.to||``);if(e&&!u(e))try{let{route:t}=N.matchRoute(e);t?.load&&T(t).catch(()=>{})}catch{}},r.addEventListener(`mouseenter`,c,{once:!0}));try{if(typeof N.subscribe==`function`){m=N.subscribe(t=>{try{t&&typeof t==`object`&&typeof t.path==`string`?s.value=t:(e.r(`router-link received invalid state`,t),s.value={path:`/`,params:{},query:{}})}catch(t){e.r(`router-link subscription update failed`,t);try{s.value={path:`/`,params:{},query:{}}}catch{}}});try{let e=N.getCurrent();e&&typeof e.path==`string`&&(s.value=e)}catch(t){e.r(`router-link initial state sync failed`,t)}o=setInterval(()=>{try{let e=N.getCurrent();e&&typeof e.path==`string`&&JSON.stringify(s.value)!==JSON.stringify(e)&&(s.value=e)}catch{}},100)}}catch(t){e.r(`router-link subscribe failed`,t)}try{if(r instanceof HTMLElement){let e=r.getAttribute(`class`),i=r.getAttribute(`style`);e&&(h.value=e),i&&(g.value=i),e!==null&&r.removeAttribute(`class`),i!==null&&r.removeAttribute(`style`);try{n?._requestRender?.();try{t.E()}catch{}}catch{}}}catch(t){e.r(`router-link host migration failed`,t)}}),i.h(()=>{if(c&&r instanceof HTMLElement)try{r.removeEventListener(`mouseenter`,c)}catch{}finally{c=null}if(typeof m==`function`)try{m()}catch(t){e.r(`router-link unsubscribe failed`,t)}finally{m=void 0}if(o)try{clearInterval(o)}catch(t){e.r(`router-link sync interval cleanup failed`,t)}finally{o=null}})}let _=t.g(()=>{if(o&&p)return p.isExactActive;try{let e=N.base??``,t=a.to||``;return!s.value||typeof s.value.path!=`string`?!1:I(s.value.path,t,e)}catch(t){return e.r(`isExactActive computation error`,t),!1}}),v=t.g(()=>{if(o&&p)return p.isActive;try{let e=N.base??``,t=a.to||``;return!s.value||typeof s.value.path!=`string`?!1:a.exact?_.value:L(s.value.path,t,e)}catch(t){return e.r(`isActive computation error`,t),!1}}),y=t.g(()=>{let e=String(a.to||``);if(l(e))return null;if(u(e))return e;let[t,n]=e.split(`#`),[r,i]=(t||``).split(`?`),o=N.base??``,s=r||`/`;if(o&&o!==`/`){let e=f(o),t=f(s);s=t.startsWith(e)?t.slice(e.length)||`/`:t}return o+f(s||`/`)+(i?`?`+i:``)+(n?`#`+n:``)}),b=t.g(()=>{let e=(h&&h.value||a.class||``).split(/\s+/).filter(Boolean),t={};for(let n of e)t[n]=!0;return t}),x=t.g(()=>({...b.value,[a.activeClass||`active`]:v.value,[a.exactActiveClass||`exact-active`]:_.value})),S=t.g(()=>Object.keys(x.value).filter(e=>x.value[e]).join(` `)),C=t.g(()=>a.tag||`a`),w=t.g(()=>C.value===`button`),E=t.g(()=>_.value?a.ariaCurrentValue:null),D=t.g(()=>!!a.disabled),O=t.g(()=>(u(String(a.to||``))||!!a.external)&&C.value===`a`),k=t.g(()=>g&&g.value||a.style||``),A=t=>{if(!(t.defaultPrevented||t.button!==0||t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)){if(D.value){t.preventDefault();return}if(l(String(a.to||``))){try{t.preventDefault()}catch{}e.r(`Blocked unsafe javascript: URI in router-link.to`);return}O.value||(t.preventDefault(),a.replace?N.replace(a.to):N.push(a.to))}};return n.t`
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./logger-Dkht1dCX.cjs`),t=require(`./helpers-BQ37xfhc.cjs`),n=require(`./template-compiler-D3r3ajIB.cjs`),r=require(`./custom-elements-runtime.directives.cjs.js`),i=require(`./hooks-DTyLoDNI.cjs`),a=require(`./custom-elements-runtime.store.cjs.js`);var o={enabled:!0,offset:0,timeoutMs:2e3},s=e=>!e||typeof URLSearchParams>`u`?{}:Object.fromEntries(new URLSearchParams(e)),c=e=>{if(!e||Object.keys(e).length===0)return``;try{return`?`+new URLSearchParams(e).toString()}catch{return``}},l=e=>e?/^\s*javascript\s*:/i.test(e):!1,u=e=>/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(e)||e.startsWith(`//`),d=e=>{try{return decodeURIComponent(e)}catch{return e}};function f(e){if(!e)return`/`;let t=e.replace(/\/+/g,`/`);return t.startsWith(`/`)||(t=`/`+t),t.length>1&&t.endsWith(`/`)&&(t=t.slice(0,-1)),t}var p=e=>{if(!e)return``;let t=f(e);return t===`/`?``:t},m=new WeakMap;function h(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function g(t){let n=f(t.path||`/`),r=n===`/`?[]:n.split(`/`).filter(Boolean),i=[],a=[];for(let n=0;n<r.length;n++){let o=r[n];if(o===`*`){if(n!==r.length-1)return e.r(`Route '${t.path}' contains a '*' splat in a non-terminal position; splats must be the last segment. This route will be ignored.`),{invalid:!0};let o=`splat${i.length}`;i.push(o),a.push(`__SPLAT__`);continue}let s=o.match(/^:([A-Za-z0-9_-]+)(\*)?$/);if(s){let o=s[1],c=!!s[2];if(c&&n!==r.length-1)return e.r(`Route '${t.path}' contains a splat param ':${o}*' in a non-terminal position; splats must be the last segment. This route will be ignored.`),{invalid:!0};i.push(o),a.push(c?`__SPLAT__`:`([^/]+)`);continue}a.push(h(o))}let o;if(a.length===0)o=`^/$`;else if(a[a.length-1]===`__SPLAT__`){let e=a.slice(0,-1).join(`/`);o=e?`^/${e}(?:/(.*))?(?:/)?$`:`^(?:/(.*))?(?:/)?$`}else o=`^/${a.join(`/`)}(?:/)?$`;try{return{regex:new RegExp(o),paramNames:i}}catch(n){return e.r(`Failed to compile route regex for '${t.path}': ${String(n)}`),{invalid:!0}}}var _=(e,t)=>{let n=f(t);for(let t of e){let e=m.get(t);if(e||(e=g(t),m.set(t,e)),e.invalid)continue;let{regex:r,paramNames:i}=e,a=r.exec(n);if(a){let e={};for(let t=0;t<i.length;t++){let n=a[t+1]||``;e[i[t]]=n?d(n):``}return{route:t,params:e}}}return{route:null,params:{}}};function v(e,t){for(let n of e)if(_([n],t).route!==null)return n;return null}function y(e,t){let n=t.split(`?`)[0].split(`#`)[0];return _(e,n)}var b=50,x={},S={};function C(){x={},S={}}function w(){let e=Object.entries(x);if(e.length<=b)return;let t=e.sort(([,e],[,t])=>e.lastAccessed-t.lastAccessed).slice(0,e.length-b);for(let[e]of t)delete x[e]}async function T(t){if(t.component)return t.component;if(t.load){let n=x[t.path];if(n)return n.lastAccessed=Date.now(),n.component;if(S[t.path]!==void 0)return S[t.path];let r=typeof window>`u`;try{let n=t.load().then(e=>{w();let n=e.default;return x[t.path]={component:n,lastAccessed:Date.now()},delete S[t.path],n}).catch(n=>{delete S[t.path];let i=n instanceof Error?n.message:String(n);throw r&&e.t(`SSR component load failed for route: ${t.path}. ${i}`),Error(`Failed to load component for route: ${t.path}. ${i}`)});return S[t.path]=n,await n}catch(e){let n=e instanceof Error?e.message:String(e);throw Error(`Failed to load component for route: ${t.path}. ${n}`,{cause:e})}}throw Error(`No component or loader defined for route: ${t.path}`)}var E=null;function D(e){E=e}function O(){return E}var k=new Set,A=null;function j(){if(A){try{A()}catch{}A=null}if(E)try{let e=!1;A=E.subscribe(t=>{e=!0;for(let e of k)try{e(t)}catch{}});try{N.base=E.base}catch{}if(e){let e=E.getCurrent();for(let t of k)try{t(e)}catch{}}else{let e=E.getCurrent();for(let t of k)try{t(e)}catch{}}try{typeof window<`u`&&t.E()}catch{}}catch{A=null}}function M(){j()}var N={store:{subscribe(e){if(E)return E.store.subscribe(e);try{e({path:`/`,params:{},query:{}})}catch{}return()=>{}},getState(){return E?E.getCurrent():{path:`/`,params:{},query:{}}},setState(e){if(E)try{E.store.setState(e)}catch{}}},subscribe(t){if(typeof t!=`function`)return e.r(`activeRouterProxy.subscribe: listener must be a function`),()=>{};if(k.add(t),E)if(!A)j();else try{let e=E.getCurrent();e&&t(e)}catch(t){e.r(`activeRouterProxy subscription failed`,t)}else try{t({path:`/`,params:{},query:{}})}catch(t){e.r(`activeRouterProxy fallback state delivery failed`,t)}return()=>{try{if(k.delete(t),k.size===0&&A){try{A()}catch(t){e.r(`activeRouterProxy inner unsubscribe failed`,t)}A=null}}catch(t){e.r(`activeRouterProxy unsubscribe failed`,t)}}},getCurrent(){return E?E.getCurrent():{path:`/`,params:{},query:{}}},async push(e){return E?E.push(e):Promise.resolve()},async replace(e){return E?E.replace(e):Promise.resolve()},back(){if(E)return E.back()},matchRoute(e){return E?E.matchRoute(e):{route:null,params:{}}},resolveRouteComponent(e){return E?E.resolveRouteComponent(e):Promise.reject(Error(`No active router`))},base:``,scrollToFragment(e){return E?E.scrollToFragment(e):Promise.resolve(!1)},destroy(){E&&E.destroy()}};function P(t){let{routes:n,base:r=``,initialUrl:i,scrollToFragment:l=!0}=t,u=p(r),d=typeof l==`boolean`?{...o,enabled:l}:{...o,...l},m,h,g,y,b,x,S,C=()=>{},w=new Set,E=0,D=async(t,r)=>{let i=v(n,t.path);if(!i||!i.beforeEnter)return!0;try{let n=await i.beforeEnter(t,r);if(typeof n==`string`){let r=`${t.path}->${n}`;return w.has(r)||E>=10?(e.t(`Redirect loop detected: ${r}`),!1):n}return n!==!1}catch(t){e.t(`beforeEnter error`,t);try{g.setState(r)}catch{}throw t}},O=async(t,r)=>{let i=v(n,t.path);if(!i||!i.onEnter)return!0;try{let n=await i.onEnter(t,r);if(typeof n==`string`){let r=`${t.path}->${n}`;return w.has(r)||E>=10?(e.t(`Redirect loop detected: ${r}`),!1):n}return n!==!1}catch(t){e.t(`onEnter error`,t);try{g.setState(r)}catch{}throw t}},k=(t,r)=>{let i=v(n,t.path);if(!(!i||!i.afterEnter))try{let n=i.afterEnter(t,r);n instanceof Promise&&n.catch(t=>{e.t(`afterEnter async error`,t)})}catch(t){e.t(`afterEnter error`,t)}},A=new Map,j=e=>{if(A.has(e))return A.get(e);let t=_(n,e);if(A.size>=100){let e=Array.from(A.keys());for(let t=0;t<25&&t<e.length;t++)A.delete(e[t])}return A.set(e,t),t},M=()=>{};async function N(e,t=0){try{let n=document.getElementById(e);if(!n)return!1;if(t>0)try{let e=n.getBoundingClientRect(),r=Math.max(0,window.scrollY+e.top-t);typeof window.scrollTo==`function`&&window.scrollTo({top:r,behavior:`auto`})}catch{try{n.scrollIntoView()}catch{return!1}}else if(typeof n.scrollIntoView==`function`)try{n.scrollIntoView({behavior:`auto`,block:`start`,inline:`nearest`})}catch{try{n.scrollIntoView()}catch{return!1}}return!0}catch{return!1}}function P(t,n=0,r=2e3){return new Promise(i=>{let a=!1,o=null,s=null,c=Date.now(),l=e=>{a||(a=!0,o&&clearTimeout(o),s!==null&&cancelAnimationFrame(s),i(e))};o=setTimeout(()=>{l(!1)},r),(async()=>{if(!a)try{if(await N(t,n))return l(!0);let i=async()=>{if(!a){if(Date.now()-c>=r)return l(!1);try{if(await N(t,n))return l(!0);s=requestAnimationFrame(i)}catch(t){e.r(`Scroll retry attempt failed:`,t),s=requestAnimationFrame(i)}}};s=requestAnimationFrame(i)}catch(t){e.r(`Initial scroll attempt failed:`,t),l(!1)}})().catch(t=>{e.r(`Scroll attempt failed:`,t),l(!1)})})}let F=!1,I=async(t,n=!1)=>{if(F){e.r(`Navigation to ${t} blocked - navigation already in progress`);return}F=!0,E=0,w.clear();try{await R(t,n)}finally{F=!1,E=0,w.clear()}},L=e=>{let t=e.indexOf(`#`),n=t>=0?e.slice(t+1):``,r=t>=0?e.slice(0,t):e,i=r.indexOf(`?`),a=i>=0?r.slice(0,i):r,o=i>=0?s(r.slice(i)):{};return{path:f((a.startsWith(u)?a.slice(u.length):a)||`/`),query:o,fragment:n}},R=async(t,r=!1)=>{try{let e=L(t),n=j(e.path);if(!n.route)throw Error(`No route found for ${e.path}`);let i=g.getState(),a={path:e.path,params:n.params,query:e.query,fragment:e.fragment},o=await D(a,i);if(o===!1)return;if(typeof o==`string`){E++;let e=`${a.path}->${o}`;w.add(e),await R(o,!0);return}let s=await O(a,i);if(s===!1)return;if(typeof s==`string`){E++;let e=`${a.path}->${s}`;w.add(e),await R(s,!0);return}if(typeof window<`u`&&typeof document<`u`){let t=c(e.query),n=u+e.path+(t||``)+(e.fragment?`#`+e.fragment:``);r?window.history.replaceState({},``,n):window.history.pushState({},``,n)}if(g.setState(a),k(a,i),typeof window<`u`&&typeof document<`u`)try{let e=a.fragment;d.enabled&&e&&P(String(e),d.offset,d.timeoutMs).catch(()=>{})}catch{}}catch(t){if(e.t(`Navigation error:`,t),t instanceof Error&&(t.stack?.includes(`runBeforeEnter`)||t.stack?.includes(`runOnEnter`)))throw t;try{if(!_(n,g.getState().path).route){let t=n.find(e=>e.path===`/`);if(t||=n.find(e=>!e.path.includes(`:`)&&!e.path.includes(`*`)),!t&&n.length>0&&(t=n[0]),t){let e=_(n,t.path);g.setState({path:t.path,params:e.params,query:{}})}else e.t(`No fallback route available for error recovery`)}}catch(t){e.r(`State recovery failed during navigation error:`,t)}}};if((t=>{if(!t||t.length===0)return e.t(`Router configuration error: No routes provided`),!1;let n=new Set;for(let r of t){if(!r.path)return e.t(`Router configuration error: Route missing path`,r),!1;n.has(r.path)&&e.r(`Duplicate route path detected: ${r.path}`),n.add(r.path),!r.component&&!r.load&&e.r(`Route '${r.path}' has no component or load function`)}return!0})(n),typeof window>`u`||i!==void 0){for(let e of n)j(e.path);e.r(`Pre-compiled ${n.length} routes for SSR`)}if(typeof window<`u`&&typeof document<`u`&&i===void 0){m=()=>{try{let e=new URL(window.location.href),t=e.pathname;return{path:f((t.startsWith(u)?t.slice(u.length):t)||`/`),query:s(e.search),fragment:e.hash&&e.hash.length?e.hash.slice(1):``}}catch(t){return e.r(`Invalid URL detected, falling back to safe defaults`,t),{path:`/`,query:{},fragment:``}}},h=m();let t=j(h.path);g=a.createStore({path:h.path,params:t.params,query:h.query,fragment:h.fragment}),y=async(e=!1)=>{await I(m().path,e)};let n=()=>y(!0);window.addEventListener(`popstate`,n),C=()=>window.removeEventListener(`popstate`,n),b=e=>I(e,!1),x=e=>I(e,!0),S=()=>window.history.back(),queueMicrotask(()=>{I(h.path,!0).catch(t=>{e.t(`Initial navigation error:`,t)})})}else{m=()=>{try{let e=new URL(i||`/`,`http://localhost`),t=e.pathname;return{path:f((t.startsWith(u)?t.slice(u.length):t)||`/`),query:s(e.search),fragment:e.hash&&e.hash.length?e.hash.slice(1):``}}catch(t){return e.r(`Invalid SSR URL detected, falling back to safe defaults`,t),{path:`/`,query:{},fragment:``}}},h=m();let t=j(h.path);g=a.createStore({path:h.path,params:t.params,query:h.query,fragment:h.fragment}),y=async()=>{await r(m().path)};let r=async t=>{if(E++,E>10){e.t(`SSR redirect depth exceeded for path: ${t}`);return}try{let e=L(t),i=j(e.path);if(!i.route)throw Error(`No route found for ${e.path}`);let a=g.getState(),o={path:e.path,params:i.params,query:e.query,fragment:e.fragment},s=v(n,o.path);if(s?.beforeEnter){let e=await s.beforeEnter(o,a);if(typeof e==`string`){let t=`${o.path}->${e}`;w.add(t),await r(e);return}if(e===!1)return}if(s?.onEnter){let e=await s.onEnter(o,a);if(typeof e==`string`){let t=`${o.path}->${e}`;w.add(t),await r(e);return}if(e===!1)return}g.setState(o),s?.afterEnter&&s.afterEnter(o,a)}catch(t){throw e.t(`SSR navigation error:`,t),t}};b=async e=>(E=0,w.clear(),r(e)),x=async e=>(E=0,w.clear(),r(e)),S=()=>{}}return{_cleanupScrollState:M,destroy:C,store:g,push:b,replace:x,back:S,subscribe:g.subscribe,matchRoute:e=>j(e),getCurrent:()=>g.getState(),resolveRouteComponent:T,base:u,scrollToFragment:e=>{let t=e||g.getState().fragment;return!t||typeof window>`u`||typeof document>`u`?Promise.resolve(!1):P(t,d.offset,d.timeoutMs)}}}function F(a){C();let o=P(a),s=O();if(s){try{s.destroy()}catch{}try{s._cleanupScrollState?.()}catch{}}D(o);try{M();try{typeof window<`u`&&t.E()}catch{}try{typeof window<`u`&&queueMicrotask(()=>{try{t.E()}catch{}})}catch{}}catch{}return n.n(`router-view`,async()=>{let r=i.i()?._router,a=r??N;if(!O()&&!r)return n.t`<div>Router not initialized.</div>`;let o=t.y(a.getCurrent()),s=typeof window>`u`,c;s||(i.m(()=>{try{typeof a.subscribe==`function`&&(c=a.subscribe(t=>{try{t&&typeof t==`object`&&typeof t.path==`string`?o.value=t:(e.r(`router-view received invalid state`,t),o.value={path:`/`,params:{},query:{}})}catch(t){e.r(`router-view subscription update failed`,t);try{o.value={path:`/`,params:{},query:{}}}catch{}}}))}catch(t){e.r(`router-view subscribe failed`,t)}}),i.h(()=>{if(typeof c==`function`){try{c()}catch(t){e.r(`router-view unsubscribe failed`,t)}c=void 0}}));let l=a.matchRoute(o.value.path);if(!l||!l.route)return n.t`<div>Not found</div>`;try{let e=await a.resolveRouteComponent(l.route);if(typeof e==`string`)return{tag:e,props:{attrs:{...o.value.params}},children:[]};if(typeof e==`function`){let t=e();return(t instanceof Promise?t:Promise.resolve(t)).then(e=>typeof e==`string`?{tag:e,props:{},children:[]}:e)}return n.t`<div>Invalid route component</div>`}catch{return n.t`<div>Invalid route component</div>`}}),n.n(`router-link`,()=>{let a=i._({to:``,tag:`a`,replace:!1,exact:!1,activeClass:`active`,exactActiveClass:`exact-active`,ariaCurrentValue:`page`,disabled:!1,external:!1,class:``,style:``}),o=typeof window>`u`,s=t.y(N.getCurrent()),c=s.value?.path||`/`,d=String(a.to||``),p=o?{isExactActive:I(c,d,N.base),isActive:L(c,d,N.base),isExternal:u(d)||!!a.external}:null,m;i.y(()=>`a,button{display:inline-block;}`);let h=t.y(a.class||``),g=t.y(a.style||``);if(!o){let n=i.i(),r=n?._host??null,o=null,c=null;i.m(()=>{r instanceof HTMLElement&&(c=()=>{let e=String(a.to||``);if(e&&!u(e))try{let{route:t}=N.matchRoute(e);t?.load&&T(t).catch(()=>{})}catch{}},r.addEventListener(`mouseenter`,c,{once:!0}));try{if(typeof N.subscribe==`function`){m=N.subscribe(t=>{try{t&&typeof t==`object`&&typeof t.path==`string`?s.value=t:(e.r(`router-link received invalid state`,t),s.value={path:`/`,params:{},query:{}})}catch(t){e.r(`router-link subscription update failed`,t);try{s.value={path:`/`,params:{},query:{}}}catch{}}});try{let e=N.getCurrent();e&&typeof e.path==`string`&&(s.value=e)}catch(t){e.r(`router-link initial state sync failed`,t)}o=setInterval(()=>{try{let e=N.getCurrent();e&&typeof e.path==`string`&&JSON.stringify(s.value)!==JSON.stringify(e)&&(s.value=e)}catch{}},100)}}catch(t){e.r(`router-link subscribe failed`,t)}try{if(r instanceof HTMLElement){let e=r.getAttribute(`class`),i=r.getAttribute(`style`);e&&(h.value=e),i&&(g.value=i),e!==null&&r.removeAttribute(`class`),i!==null&&r.removeAttribute(`style`);try{n?._requestRender?.();try{t.E()}catch{}}catch{}}}catch(t){e.r(`router-link host migration failed`,t)}}),i.h(()=>{if(c&&r instanceof HTMLElement)try{r.removeEventListener(`mouseenter`,c)}catch{}finally{c=null}if(typeof m==`function`)try{m()}catch(t){e.r(`router-link unsubscribe failed`,t)}finally{m=void 0}if(o)try{clearInterval(o)}catch(t){e.r(`router-link sync interval cleanup failed`,t)}finally{o=null}})}let _=t.g(()=>{if(o&&p)return p.isExactActive;try{let e=N.base??``,t=a.to||``;return!s.value||typeof s.value.path!=`string`?!1:I(s.value.path,t,e)}catch(t){return e.r(`isExactActive computation error`,t),!1}}),v=t.g(()=>{if(o&&p)return p.isActive;try{let e=N.base??``,t=a.to||``;return!s.value||typeof s.value.path!=`string`?!1:a.exact?_.value:L(s.value.path,t,e)}catch(t){return e.r(`isActive computation error`,t),!1}}),y=t.g(()=>{let e=String(a.to||``);if(l(e))return null;if(u(e))return e;let[t,n]=e.split(`#`),[r,i]=(t||``).split(`?`),o=N.base??``,s=r||`/`;if(o&&o!==`/`){let e=f(o),t=f(s);s=t.startsWith(e)?t.slice(e.length)||`/`:t}return o+f(s||`/`)+(i?`?`+i:``)+(n?`#`+n:``)}),b=t.g(()=>{let e=(h&&h.value||a.class||``).split(/\s+/).filter(Boolean),t={};for(let n of e)t[n]=!0;return t}),x=t.g(()=>({...b.value,[a.activeClass||`active`]:v.value,[a.exactActiveClass||`exact-active`]:_.value})),S=t.g(()=>Object.keys(x.value).filter(e=>x.value[e]).join(` `)),C=t.g(()=>a.tag||`a`),w=t.g(()=>C.value===`button`),E=t.g(()=>_.value?a.ariaCurrentValue:null),D=t.g(()=>!!a.disabled),O=t.g(()=>(u(String(a.to||``))||!!a.external)&&C.value===`a`),k=t.g(()=>g&&g.value||a.style||``),A=t=>{if(!(t.defaultPrevented||t.button!==0||t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)){if(D.value){t.preventDefault();return}if(l(String(a.to||``))){try{t.preventDefault()}catch{}e.r(`Blocked unsafe javascript: URI in router-link.to`);return}O.value||(t.preventDefault(),a.replace?N.replace(a.to):N.push(a.to))}};return n.t`
2
2
  ${r.match().when(w.value,n.t`
3
3
  <button
4
4
  part="button"
@@ -1,6 +1,6 @@
1
1
  import { r as e, t } from "./logger-DIJ0UH3R.js";
2
2
  import { E as n, g as r, y as i } from "./helpers-llht6g11.js";
3
- import { n as a, t as o } from "./template-compiler-BpHiWIRk.js";
3
+ import { n as a, t as o } from "./template-compiler-D7BToKVe.js";
4
4
  import { match as s } from "./custom-elements-runtime.directives.es.js";
5
5
  import { _ as c, h as l, i as u, m as d, y as f } from "./hooks-BZwRvrjJ.js";
6
6
  import { createStore as p } from "./custom-elements-runtime.store.es.js";
@@ -15,5 +15,5 @@ Possible causes:
15
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
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
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._requestRender(),h(i,this.context,this._mounted,e=>{this._mounted=e})}})}_hydrateNow(e){this._runLogicWithinErrorBoundary(e,()=>{this._applyProps(e),this._requestRender(),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-CeeH0904.cjs.map
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