@koppajs/koppajs-core 3.0.9 → 3.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -16,6 +16,26 @@ This section is intentionally empty.
16
16
 
17
17
  ---
18
18
 
19
+ ## [3.0.10] — Local First-Presentation Protection
20
+
21
+ **2026-10-16**
22
+
23
+ Patch release to prevent raw slot content from painting outside its unfinished
24
+ first template. Navigation remains immediate; no router readiness barrier or new
25
+ public API is introduced.
26
+
27
+ ### Fixed
28
+
29
+ - Protect original slot content locally during asynchronous first rendering so it is
30
+ not painted outside the finished template. Preserve connected nodes and author
31
+ presentation declarations without delaying router replacement or waiting for children.
32
+ - Emit first mount and resolve readiness only after a successful render, including
33
+ replacement renders after an aborted first attempt.
34
+ - Preserve tracked listeners when synchronous slot transfers reconnect original nodes
35
+ before the global removal observer runs.
36
+
37
+ ---
38
+
19
39
  ## [3.0.9] — Native CommonJS Package Entrypoint
20
40
 
21
41
  **2026-10-16**
package/dist/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var be=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e[e.NONE=4]="NONE",e))(be||{});const q={ERROR:"❌",WARN:"⚠️",INFO:"ℹ️",DEBUG:"🔍"};class Le{level=3;isDevelopment=!1;init(t){this.isDevelopment=t?.isDevelopment??(typeof process<"u"&&process.env?.NODE_ENV==="development")??!1,this.level=t?.level??(this.isDevelopment?0:3)}setLevel(t){this.level=t}getLevel(){return this.level}shouldLog(t){return t>=this.level}formatMessage(t,o,n){const i=[t,o];if(n){const l=Object.entries(n).map(([r,s])=>`${r}: ${s}`).join(", ");l&&i.push(`[${l}]`)}return i.join(" ")}error(t,...o){this.shouldLog(3)&&console.error(this.formatMessage(q.ERROR,t),...o)}warn(t,...o){this.shouldLog(2)&&console.warn(this.formatMessage(q.WARN,t),...o)}info(t,...o){this.shouldLog(1)&&console.info(this.formatMessage(q.INFO,t),...o)}debug(t,...o){this.shouldLog(0)&&console.debug(this.formatMessage(q.DEBUG,t),...o)}errorWithContext(t,o,n){if(!this.shouldLog(3))return;const i=this.formatMessage(q.ERROR,t,o);n?console.error(i,n):console.error(i)}warnWithContext(t,o){this.shouldLog(2)&&console.warn(this.formatMessage(q.WARN,t,o))}}const T=new Le;T.init();const ue=Symbol("isBounded"),Ee=Symbol("isProxy"),De=["created","beforeMount","mounted","beforeUpdate","updated","beforeDestroy","destroyed","processed"];function Y(e,t){if(typeof e!="function"||e[ue])return e;const n=e.bind(t);return n[ue]=!0,n}function We(e,t){for(const o in e){const n=e[o];if(Object.prototype.hasOwnProperty.call(e,o)&&typeof n=="function")try{e[o]=Y(n,t)}catch(i){T.errorWithContext(`Failed to bind method "${o}"`,{methodName:o},i)}}}function Fe(e){return/<\/?[a-z][^>]*>/i.test(e)}function re(e,t){if(e==null||typeof t!="string")return;const o=t.trim().replace(/\[(\w+)\]/g,".$1").split(".").filter(Boolean);try{return o.reduce((n,i)=>{if(n!=null)return n[i]},e)}catch{return}}function Ve(e){return typeof e=="string"?e.toLowerCase():typeof e=="function"&&typeof e.name=="string"?e.name.toLowerCase():"unknown"}function ve(e){const t=e.trim();return/^[a-zA-Z_$][0-9a-zA-Z_$]*(?:\[(?:\d+|\w+)\]|\.[a-zA-Z_$][0-9a-zA-Z_$]*)*$/.test(t)}function je(e,t,o){if(e==null||typeof e!="object"&&typeof e!="function")throw new Error("❌ setValueByPath: target must be an object.");if(typeof t!="string"||!t.trim())throw new Error("❌ setValueByPath: path must be a non-empty string.");const n=t.trim().replace(/\[(\w+)\]/g,".$1").split(".").filter(Boolean);if(n.length===0)throw new Error(`❌ setValueByPath: invalid path "${t}".`);const i=(c,a)=>Object.prototype.hasOwnProperty.call(c,a),l=n.pop();let r=e;for(const c of n){if(r==null||typeof r!="object"&&typeof r!="function")throw new Error(`❌ setValueByPath: invalid path "${t}". Segment "${c}" is not an object.`);if(!i(r,c))throw new Error(`❌ setValueByPath: invalid path "${t}". Missing segment "${c}".`);const a=r[c];if(a==null||typeof a!="object"&&typeof a!="function")throw new Error(`❌ setValueByPath: invalid path "${t}". Segment "${c}" is not an object.`);r=a}if(r==null||typeof r!="object"&&typeof r!="function")throw new Error(`❌ setValueByPath: invalid path "${t}". Final target is not an object.`);if(!i(r,l))throw new Error(`❌ setValueByPath: invalid path "${t}". Final key "${l}" does not exist.`);const s=Object.getOwnPropertyDescriptor(r,l);if(s&&s.writable===!1&&!s.set)throw new Error(`❌ setValueByPath: cannot write "${t}". Property "${l}" is read-only.`);r[l]=o}const He={select:{get(){return e=>this instanceof HTMLInputElement||this instanceof HTMLTextAreaElement?(this.select(),null):this.querySelector(e)}},selectAll:{get(){return e=>this.querySelectorAll(e)}},addClass:{get(){return e=>(e.split(/\s+/).map(t=>t.trim()).filter(t=>t.length>0).forEach(t=>this.classList.add(t)),this)}},removeClass:{get(){return e=>(e.split(/\s+/).map(t=>t.trim()).filter(t=>t.length>0).forEach(t=>this.classList.remove(t)),this)}},toggleClass:{get(){return e=>(e.split(/\s+/).map(t=>t.trim()).filter(t=>t.length>0).forEach(t=>this.classList.toggle(t)),this)}},hasClass:{get(){return e=>this.classList.contains(e.trim())}},replaceWith:{get(){return e=>{this.parentNode&&(e instanceof HTMLElement?this.parentNode.replaceChild(e,this):typeof e=="string"&&(this.insertAdjacentText("beforebegin",e),this.remove()))}}},siblings:{get(){return e=>{if(!this.parentNode)return[];const t=[];let o=this.parentNode.firstChild;for(;o;)o.nodeType===Node.ELEMENT_NODE&&o!==this&&o instanceof HTMLElement&&(e?.(o),t.push(o)),o=o.nextSibling;return t}}},before:{get(){return e=>{this.parentNode&&(e instanceof HTMLElement?this.parentNode.insertBefore(e,this):this.insertAdjacentHTML("beforebegin",e.toString()))}}},after:{get(){return e=>{this.parentNode&&(e instanceof HTMLElement?this.parentNode.insertBefore(e,this.nextSibling):this.insertAdjacentHTML("afterend",e.toString()))}}},attr:{get(){return(e,t)=>(t!==void 0&&this.setAttribute(e,t||"true"),this.getAttribute(e))}}},Be={};function qe(e){return e.replace(/-./g,t=>t[1].toUpperCase())}const ze=/(?:\bwindow\b|\bdocument\b|\bglobalThis\b|\bFunction\b|\beval\b|\bsetTimeout\b|\bsetInterval\b|\bfetch\b|\bXMLHttpRequest\b|\bimport\b|\brequire\b|\bthis\b)/,z=new Map,Ue=1e3,de=new WeakMap;function Xe(e){const t=Object.keys(e),o=t.join("\0"),n=de.get(e);if(n&&n.fingerprint===o)return n.keys;const i=t.sort();return de.set(e,{keys:i,fingerprint:o}),i}function B(e,t={}){const o=(e??"").trim();if(o)try{if(ze.test(o))return;if(ve(o)){const r=re(t,o);return typeof r=="function"?r.call(t):r}const n=Xe(t),i=`${o}|${n.join(",")}`;let l=z.get(i);if(!l){const r=`"use strict"; return (${o});`;if(l=new Function(...n,r),z.size>=Ue){const s=z.keys().next().value;s&&z.delete(s)}z.set(i,l)}return l(...n.map(r=>t[r]))}catch(n){T.debug(`Expression evaluation failed: ${o}`,n);return}}function Ge(e){return e.length===0?"":e.map(t=>`var ${t} = __deps.${t};`).join(`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var ve=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e[e.NONE=4]="NONE",e))(ve||{});const z={ERROR:"❌",WARN:"⚠️",INFO:"ℹ️",DEBUG:"🔍"};class De{level=3;isDevelopment=!1;init(t){this.isDevelopment=t?.isDevelopment??(typeof process<"u"&&process.env?.NODE_ENV==="development")??!1,this.level=t?.level??(this.isDevelopment?0:3)}setLevel(t){this.level=t}getLevel(){return this.level}shouldLog(t){return t>=this.level}formatMessage(t,r,n){const o=[t,r];if(n){const l=Object.entries(n).map(([i,s])=>`${i}: ${s}`).join(", ");l&&o.push(`[${l}]`)}return o.join(" ")}error(t,...r){this.shouldLog(3)&&console.error(this.formatMessage(z.ERROR,t),...r)}warn(t,...r){this.shouldLog(2)&&console.warn(this.formatMessage(z.WARN,t),...r)}info(t,...r){this.shouldLog(1)&&console.info(this.formatMessage(z.INFO,t),...r)}debug(t,...r){this.shouldLog(0)&&console.debug(this.formatMessage(z.DEBUG,t),...r)}errorWithContext(t,r,n){if(!this.shouldLog(3))return;const o=this.formatMessage(z.ERROR,t,r);n?console.error(o,n):console.error(o)}warnWithContext(t,r){this.shouldLog(2)&&console.warn(this.formatMessage(z.WARN,t,r))}}const N=new De;N.init();const de=Symbol("isBounded"),we=Symbol("isProxy"),Ve=["created","beforeMount","mounted","beforeUpdate","updated","beforeDestroy","destroyed","processed"];function Q(e,t){if(typeof e!="function"||e[de])return e;const n=e.bind(t);return n[de]=!0,n}function We(e,t){for(const r in e){const n=e[r];if(Object.prototype.hasOwnProperty.call(e,r)&&typeof n=="function")try{e[r]=Q(n,t)}catch(o){N.errorWithContext(`Failed to bind method "${r}"`,{methodName:r},o)}}}function je(e){return/<\/?[a-z][^>]*>/i.test(e)}function se(e,t){if(e==null||typeof t!="string")return;const r=t.trim().replace(/\[(\w+)\]/g,".$1").split(".").filter(Boolean);try{return r.reduce((n,o)=>{if(n!=null)return n[o]},e)}catch{return}}function He(e){return typeof e=="string"?e.toLowerCase():typeof e=="function"&&typeof e.name=="string"?e.name.toLowerCase():"unknown"}function _e(e){const t=e.trim();return/^[a-zA-Z_$][0-9a-zA-Z_$]*(?:\[(?:\d+|\w+)\]|\.[a-zA-Z_$][0-9a-zA-Z_$]*)*$/.test(t)}function Be(e,t,r){if(e==null||typeof e!="object"&&typeof e!="function")throw new Error("❌ setValueByPath: target must be an object.");if(typeof t!="string"||!t.trim())throw new Error("❌ setValueByPath: path must be a non-empty string.");const n=t.trim().replace(/\[(\w+)\]/g,".$1").split(".").filter(Boolean);if(n.length===0)throw new Error(`❌ setValueByPath: invalid path "${t}".`);const o=(c,a)=>Object.prototype.hasOwnProperty.call(c,a),l=n.pop();let i=e;for(const c of n){if(i==null||typeof i!="object"&&typeof i!="function")throw new Error(`❌ setValueByPath: invalid path "${t}". Segment "${c}" is not an object.`);if(!o(i,c))throw new Error(`❌ setValueByPath: invalid path "${t}". Missing segment "${c}".`);const a=i[c];if(a==null||typeof a!="object"&&typeof a!="function")throw new Error(`❌ setValueByPath: invalid path "${t}". Segment "${c}" is not an object.`);i=a}if(i==null||typeof i!="object"&&typeof i!="function")throw new Error(`❌ setValueByPath: invalid path "${t}". Final target is not an object.`);if(!o(i,l))throw new Error(`❌ setValueByPath: invalid path "${t}". Final key "${l}" does not exist.`);const s=Object.getOwnPropertyDescriptor(i,l);if(s&&s.writable===!1&&!s.set)throw new Error(`❌ setValueByPath: cannot write "${t}". Property "${l}" is read-only.`);i[l]=r}const qe={select:{get(){return e=>this instanceof HTMLInputElement||this instanceof HTMLTextAreaElement?(this.select(),null):this.querySelector(e)}},selectAll:{get(){return e=>this.querySelectorAll(e)}},addClass:{get(){return e=>(e.split(/\s+/).map(t=>t.trim()).filter(t=>t.length>0).forEach(t=>this.classList.add(t)),this)}},removeClass:{get(){return e=>(e.split(/\s+/).map(t=>t.trim()).filter(t=>t.length>0).forEach(t=>this.classList.remove(t)),this)}},toggleClass:{get(){return e=>(e.split(/\s+/).map(t=>t.trim()).filter(t=>t.length>0).forEach(t=>this.classList.toggle(t)),this)}},hasClass:{get(){return e=>this.classList.contains(e.trim())}},replaceWith:{get(){return e=>{this.parentNode&&(e instanceof HTMLElement?this.parentNode.replaceChild(e,this):typeof e=="string"&&(this.insertAdjacentText("beforebegin",e),this.remove()))}}},siblings:{get(){return e=>{if(!this.parentNode)return[];const t=[];let r=this.parentNode.firstChild;for(;r;)r.nodeType===Node.ELEMENT_NODE&&r!==this&&r instanceof HTMLElement&&(e?.(r),t.push(r)),r=r.nextSibling;return t}}},before:{get(){return e=>{this.parentNode&&(e instanceof HTMLElement?this.parentNode.insertBefore(e,this):this.insertAdjacentHTML("beforebegin",e.toString()))}}},after:{get(){return e=>{this.parentNode&&(e instanceof HTMLElement?this.parentNode.insertBefore(e,this.nextSibling):this.insertAdjacentHTML("afterend",e.toString()))}}},attr:{get(){return(e,t)=>(t!==void 0&&this.setAttribute(e,t||"true"),this.getAttribute(e))}}},ze={};function Ue(e){return e.replace(/-./g,t=>t[1].toUpperCase())}const Xe=/(?:\bwindow\b|\bdocument\b|\bglobalThis\b|\bFunction\b|\beval\b|\bsetTimeout\b|\bsetInterval\b|\bfetch\b|\bXMLHttpRequest\b|\bimport\b|\brequire\b|\bthis\b)/,U=new Map,Ge=1e3,he=new WeakMap;function Ke(e){const t=Object.keys(e),r=t.join("\0"),n=he.get(e);if(n&&n.fingerprint===r)return n.keys;const o=t.sort();return he.set(e,{keys:o,fingerprint:r}),o}function q(e,t={}){const r=(e??"").trim();if(r)try{if(Xe.test(r))return;if(_e(r)){const i=se(t,r);return typeof i=="function"?i.call(t):i}const n=Ke(t),o=`${r}|${n.join(",")}`;let l=U.get(o);if(!l){const i=`"use strict"; return (${r});`;if(l=new Function(...n,i),U.size>=Ge){const s=U.keys().next().value;s&&U.delete(s)}U.set(o,l)}return l(...n.map(i=>t[i]))}catch(n){N.debug(`Expression evaluation failed: ${r}`,n);return}}function Ze(e){return e.length===0?"":e.map(t=>`var ${t} = __deps.${t};`).join(`
2
2
  `)+`
3
- `}function Ke(e,t){const o=e.replace(/\$-\{/g,"${"),n=t?Object.keys(t):[],l=`
3
+ `}function Ye(e,t){const r=e.replace(/\$-\{/g,"${"),n=t?Object.keys(t):[],l=`
4
4
  const { $refs, $parent, $emit, $take, $handleEventFromChild, ...rest } = context;
5
5
 
6
6
  // Expose all $*-prefixed context entries (e.g. $router, $store) as local variables
@@ -13,7 +13,7 @@
13
13
  }
14
14
 
15
15
  // Inject resolved dependencies as local variables
16
- ${Ge(n)}
16
+ ${Ze(n)}
17
17
 
18
- return (${o});
19
- `;try{const r=t?new Function("context","__deps",l):new Function("context",l);return(c=>t?r(c,t):r(c))}catch(r){throw T.errorWithContext("Failed to compile dynamic code",{functionBody:l},r),r}}function we(){return new Map}const Ne=we();function _e(e,t,o){e==="global"&&(e=Ne),e.has(t)||e.set(t,new Set),e.get(t).add(o)}async function P(e,t,o){e==="global"&&(e=Ne);const n=Array.from(e.get(t)??[]);for(const i of n)try{await i(o)}catch(l){T.errorWithContext(`Hook "${t}" callback failed`,{hook:t},l)}}const Z={modules:{},plugins:{}};function Ze(e){if(e==null||typeof e!="object")return!1;const t=e;return typeof t.template=="string"&&typeof t.script=="string"&&typeof t.style=="string"}function J(e){if(e==null||typeof e!="object")return!1;const t=e;return typeof t.setup=="function"&&t.attach===void 0}function Ye(e){if(e==null||typeof e!="object")return!1;const t=e;return typeof t.attach=="function"&&t.setup===void 0}function Je(e){return e instanceof HTMLElement&&"instance"in e&&e.instance!==void 0}const Qe=()=>{Object.defineProperties(Object.prototype,Be),typeof HTMLElement<"u"&&Object.defineProperties(HTMLElement.prototype,He)};function U(e){return e.nodeType===Node.ELEMENT_NODE&&e.tagName.includes("-")}function et(e,t){const o=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:i=>U(i)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP});let n=o.nextNode();for(;n;){const i=n.getAttribute(t);i!==null&&(Se(n)===void 0&&Te(n,i),n.removeAttribute(t)),n=o.nextNode()}}function he(e,t){if(!U(e))return null;const o=e.tagName;let n=Se(e);const i=rt(e);if(n===void 0&&t){const l=e.getAttribute(t);l!==null&&(Te(e,l),n=l,e.removeAttribute(t))}return n===void 0?null:i!==void 0?`${o}:${String(n)}:${String(i)}`:`${o}:${String(n)}`}function tt(e,t){return e.nodeType!==t.nodeType?!1:e.nodeType===Node.TEXT_NODE||e.nodeType===Node.COMMENT_NODE?!0:e.nodeType===Node.ELEMENT_NODE?e.tagName===t.tagName:!1}function Q(e,t){const o=new Set(e.getAttributeNames()),n=new Set(t.getAttributeNames());for(const i of o)!n.has(i)&&!i.startsWith("@")&&e.removeAttribute(i);for(const i of n){const l=t.getAttribute(i),r=e.getAttribute(i);l!==r&&(l===null?e.removeAttribute(i):e.setAttribute(i,l))}}function Ce(e,t,o){const n=Array.from(e.childNodes),i=Array.from(t.childNodes),l=new Map,r=new Set;for(const s of n){const c=he(s,o);c!==null&&!l.has(c)&&l.set(c,s)}for(let s=0;s<i.length;s++){const c=i[s],a=n[s],u=he(c,o);let d=null;if(u!==null&&l.has(u)&&(d=l.get(u),r.add(d)),d&&U(d)){a!==d&&(s<e.childNodes.length?e.insertBefore(d,e.childNodes[s]):e.appendChild(d)),Q(d,c);continue}if(U(c)&&u!==null){a?e.replaceChild(c,a):e.appendChild(c);continue}if(!a){e.appendChild(c);continue}if(!tt(a,c)){e.replaceChild(c,a);continue}if(a.nodeType===Node.TEXT_NODE){a.textContent!==c.textContent&&(a.textContent=c.textContent);continue}if(a.nodeType===Node.COMMENT_NODE){a.textContent!==c.textContent&&(a.textContent=c.textContent);continue}if(a.nodeType===Node.ELEMENT_NODE){const v=a,x=c;if(U(v)){Q(v,x);continue}Q(v,x),Ce(v,x,o)}}for(;e.childNodes.length>i.length;){const s=e.lastChild;s&&e.removeChild(s)}}function nt(e,t,o,n){if(o||e.childNodes.length===0){n&&et(t,n),e.replaceChildren(t);return}const i=document.createElement("div");i.appendChild(t),Ce(e,i,n)}const ie=Symbol("STRUCT_ID"),se=Symbol("SLOT_ID");function Ae(e,t,o){Object.defineProperty(e,t,{value:o,writable:!0,configurable:!0,enumerable:!1})}function Te(e,t){Ae(e,ie,t)}function Se(e){return Object.prototype.hasOwnProperty.call(e,ie)?e[ie]:void 0}function ot(e,t){Ae(e,se,t)}function rt(e){return Object.prototype.hasOwnProperty.call(e,se)?e[se]:void 0}function it(e,t,o,n){if(!Array.isArray(t))return()=>{};const i=[];return t.forEach(([l,r,s])=>{if(typeof l!="string"||typeof s!="function"){T.error("Provided handler is not a function",s);return}let c=[];if(r==="window")c=[window];else if(typeof r=="string")if(r.startsWith("$refs.")){const[a,...u]=r.slice(6).split(" "),d=n[a];d&&(c=u.length?Array.from(d.querySelectorAll(u.join(" "))):[d])}else c=Array.from(o.querySelectorAll(r));else if(r instanceof Element||r instanceof Window)c=[r];else if(typeof r=="object"&&r&&"ref"in r){const{ref:a,selector:u}=r,d=n[a];d&&(c=u?Array.from(d.querySelectorAll(u)):[d])}for(const a of c){const u=Y(s,e);a.addEventListener(l,u),i.push({target:a,type:l,handler:u})}}),()=>{for(const{target:l,type:r,handler:s}of i)l.removeEventListener(r,s);i.length=0}}const xe=/^on([a-z]+)$/i;function st(e,t){const o=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT);let n=o.nextNode();for(;n;){for(const i of Array.from(n.attributes)){const l=i.name.match(xe);if(l){const r=l[1].toLowerCase(),s=i.value;if(s){const c=e[s];typeof c=="function"&&(n.removeAttribute(i.name),n.addEventListener(r,c))}}}n=o.nextNode()}}function ct(e,t){const o=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT);let n=o.nextNode();for(;n;){for(const i of Array.from(n.attributes)){const l=i.name.match(xe);if(l){const r=l[1].toLowerCase(),s=i.value;if(s){const c=e[s];typeof c=="function"&&(n.removeAttribute(i.name),n.addEventListener(r,c))}}}n=o.nextNode()}}function at(e,t,o,n,i){if(!Array.isArray(o))return()=>{};const l=[];return o.forEach(([r,s,c])=>{if(typeof r!="string"||typeof c!="function"){T.error("Provided handler is not a function",c);return}let a=[];if(s==="window")a=[window];else if(typeof s=="string")if(s.startsWith("$refs.")){const[u,...d]=s.slice(6).split(" "),v=i[u];v&&(a=d.length?Array.from(v.querySelectorAll(d.join(" "))):[v])}else a=Array.from(n.querySelectorAll(s));else if(s instanceof Element||s instanceof Window)a=[s];else if(typeof s=="object"&&s&&"ref"in s){const{ref:u,selector:d}=s,v=i[u];v&&(a=d?Array.from(v.querySelectorAll(d)):[v])}for(const u of a){const d=Y(c,t);u.addEventListener(r,d),l.push({target:u,type:r,handler:d})}}),()=>{for(const{target:r,type:s,handler:c}of l)r.removeEventListener(s,c);l.length=0}}const V=new WeakMap;let ee;function lt(){if(typeof EventTarget>"u")return;const e=globalThis;if(e.__koppajsEventTrackingPatched)return;e.__koppajsEventTrackingPatched=!0;const t=EventTarget.prototype.addEventListener,o=EventTarget.prototype.removeEventListener;EventTarget.prototype.addEventListener=function(n,i,l){return V.has(this)||V.set(this,new Set),V.get(this).add({type:n,listener:i,options:l}),t.call(this,n,i,l)},EventTarget.prototype.removeEventListener=function(n,i,l){const r=V.get(this);if(r){for(const s of r)if(s.type===n&&s.listener===i){r.delete(s);break}r.size===0&&V.delete(this)}return o.call(this,n,i,l)}}function ft(e){const t=V.get(e);if(t){for(const{type:o,listener:n,options:i}of t)e.removeEventListener(o,n,i);V.delete(e)}}function Me(e){if(typeof document>"u"||typeof NodeFilter>"u"||typeof Element>"u")return;const t=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT);let o=e instanceof Element?e:null;for(;o;)V.has(o)&&ft(o),o=t.nextNode()}function ut(){ee||typeof MutationObserver>"u"||typeof document>"u"||document.body&&(ee=new MutationObserver(e=>{for(const t of e)t.removedNodes.forEach(o=>{o.nodeType===Node.ELEMENT_NODE&&Me(o)})}),ee.observe(document.body,{childList:!0,subtree:!0}))}const Oe=new WeakMap,ke=new WeakMap,X=new WeakMap;let dt=0;const H=()=>`slot-${++dt}`,W=e=>typeof e=="object"&&e!==null,te=e=>typeof e=="symbol"?e.toString():String(e),ht=e=>{const t=Oe.get(e);return t&&W(t)?t:void 0};function $e(e){const t=ke.get(e);return t||e}const F=e=>W(e)?Reflect.get(e,Ee)===!0:!1;function pt(e){const t=F(e)?$e(e):e;return X.get(t)}const mt=e=>e!==null&&(typeof e=="string"||typeof e=="number"||typeof e=="boolean"||typeof e=="function"||typeof e>"u"),K=e=>{let t=X.get(e);return t||(t=e.map(()=>H()),X.set(e,t)),t},pe=e=>{const t=X.get(e);if(t&&t.length!==e.length)throw new Error(`Slot sidecar invariant violation: slotIds length (${t.length}) does not match array length (${e.length})`)};function yt(e){const t=new Set,o=new WeakMap;let n=0,i=new Set;const l=new Map,r=(f,y)=>!!(f===y||f.startsWith(y+".")),s=(f,y)=>{const b=o.get(f)??"";return b?`${b}.${y}`:y};let c=!1;const a=f=>{i.add(f),n++,c||(c=!0,queueMicrotask(()=>{c=!1,t.forEach(y=>{try{y()}catch(b){console.error("Observer error:",b)}})}))},u=(f,y,b)=>{if(f===y)return;let w=f.length!==y.length;if(!w){for(let h=0;h<f.length;h++)if(f[h]!==y[h]){w=!0;break}}f.splice(0,f.length,...y),w&&a(b)},d=(f,y,b)=>{const w=new Set(f),h=new Set(y);let m=!1;for(const E of w)if(!h.has(E)){m=!0;break}if(!m){for(const E of h)if(!w.has(E)){m=!0;break}}m&&(f.splice(0,f.length,...y),a(b))},v=(f,y,b)=>{const w=new Set(f),h=new Set(y);f.length!==y.length||[...w].some(E=>!h.has(E))||[...h].some(E=>!w.has(E))?d(f,y,b):u(f,y,b)},x=(f,y,b)=>{if(f===y)return!1;let w=!1;for(const h of Object.keys(f))h in y||(w=!0,Reflect.deleteProperty(f,h));for(const h of Object.keys(y)){const m=f[h],E=y[h];m!==E&&(W(m)&&F(m)&&W(E)&&!F(E)?(x(m,E)&&(w=!0),m!==E&&(w=!0,Reflect.set(f,h,E))):(w=!0,Reflect.set(f,h,E)))}return w},M=(f,y,b)=>{const w=K(f);switch(y){case"push":{const h=Array.from({length:b.length},()=>H());w.push(...h);break}case"pop":{w.pop();break}case"shift":{w.shift();break}case"unshift":{const h=Array.from({length:b.length},()=>H());w.unshift(...h);break}case"splice":{const h=b[0]??0,m=b[1]!==void 0?b[1]:f.length-h,E=b.slice(2),S=Array.from({length:E.length},()=>H());w.splice(h,m,...S);break}case"reverse":{w.reverse();break}}pe(f)},N=(f,y="")=>{if(f instanceof Node||f instanceof Window||f instanceof Document)return f;const b=ht(f);if(b)return b;y&&o.set(f,y),Array.isArray(f)&&K(f);const w=new Proxy(f,{get:(h,m,E)=>{if(m===Ee)return!0;if(m==="toJSON")return function(){return $e(h)};if(Array.isArray(h)&&typeof m=="string"&&["push","pop","shift","unshift","splice","reverse","sort"].includes(m)){const R=h[m];if(typeof R=="function")return function(...D){if(m==="sort"){const k=K(h),$=h.map((p,_)=>({el:p,slotId:k[_]||H()})),G=R.apply(this,D),g=new Map;for(let p=0;p<$.length;p++){const _=$[p].el;let O=g.get(_);O||(O=[],g.set(_,O)),O.push(p)}for(let p=0;p<h.length;p++){const _=h[p],O=g.get(_);if(O&&O.length>0){const L=O.shift();k[p]=$[L].slotId}else k[p]=H()}return pe(h),G}else{const k=R.apply(this,D);return M(h,m,D),k}}}const S=Reflect.get(h,m,E),A=Array.isArray(h)&&typeof m=="string"&&/^\d+$/.test(m);if(W(S)&&!F(S)&&!A&&(Array.isArray(S)||!Array.isArray(h))){const I=te(m),R=s(h,I);return N(S,R)}return S},set:(h,m,E,S)=>{const A=Reflect.get(h,m,S);if(A===E)return!0;const I=te(m),R=s(h,I);if(Array.isArray(h)&&typeof m=="string"&&/^\d+$/.test(m)){const k=parseInt(m,10);if(k>=0&&k<h.length){const $=Reflect.set(h,m,E,S);return a(R),$}}if(Array.isArray(A)&&!mt(E)&&Array.isArray(E)){v(A,E,R);const k=A.map(()=>H());return X.set(A,k),!0}if(W(A)&&F(A)&&W(E)&&!F(E)){if(x(A,E)){let $=E;W($)&&!F($)&&($=N($,R)),Reflect.set(h,m,$,S),a(R)}return!0}const D=Reflect.set(h,m,E,S);if(W(E)&&!F(E)){const k=N(E,R);Reflect.set(h,m,k,S),Array.isArray(E)&&K(E)}return a(R),D},deleteProperty:(h,m)=>{if(m==="changedPaths")return Reflect.deleteProperty(h,m);const E=te(m),S=s(h,E),A=Reflect.get(h,m),I=Reflect.deleteProperty(h,m);return I&&A!==void 0&&a(S),I}});return Oe.set(f,w),ke.set(w,f),w};return{state:N(e),watch(f,y){let b=l.get(f);b||(b=new Set,l.set(f,b)),b.add(y);let w=!1;return()=>{if(w)return;w=!0;const h=l.get(f);h&&(h.delete(y),h.size===0&&l.delete(f))}},addObserver(f){t.add(f)},removeObserver(f){t.delete(f)},getStateVersion(){return n},hasPendingChangesFor(f){for(const y of i)for(const b of f)if(y===b||y.startsWith(b+"."))return!0;return!1},flushChanges(){const f=new Set(i);if(f.size>0&&l.size>0){const y=new Map;for(const[b,w]of l){const h=new Set;for(const m of f)r(m,b)&&h.add(m);if(h.size>0)for(const m of w){const E=y.get(m);if(E)for(const S of h)E.add(S);else y.set(m,new Set(h))}}for(const[b,w]of y)b({changedPaths:w})}return i=new Set,f}}}const ne=/^[A-Za-z_$][A-Za-z0-9_$]*$/;function gt(e){const t=e.trim();if(t.startsWith("[")&&t.endsWith("]")){const n=t.slice(1,-1).split(",").map(r=>r.trim());if(n.length!==2)throw new Error("Invalid loop binding: expected <id> or [<id>, <id>]");const[i,l]=n;if(!ne.test(i)||!ne.test(l))throw new Error("Invalid loop binding: expected <id> or [<id>, <id>]");return{type:"tuple",keyVar:i,itemVar:l}}if(!ne.test(t))throw new Error("Invalid loop binding: expected <id> or [<id>, <id>]");return{type:"single",itemVar:t}}function bt(e){const t={acceptNode(o){return o.nodeType===Node.ELEMENT_NODE||o.nodeType===Node.TEXT_NODE&&/\{\{(.+?)\}\}/g.test(o.nodeValue||"")?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}};return document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT,t)}function Et(e){const t=e.currentNode;return t?.nextSibling?e.currentNode=t.nextSibling:e.nextNode()}function vt(e,t){let o=t.nextSibling;if(!o){let n=t.parentNode;for(;n&&n!==e.root;){if(n.nextSibling){o=n.nextSibling;break}n=n.parentNode}}return o?(e.currentNode=o,o):null}function wt(e){return e==null||e===!0||e===!1?"":String(e)}function Re(e,t){return e.replace(/\{\{(.+?)\}\}/g,(o,n)=>{const i=B(n.trim(),t);return wt(i)})}async function Nt(e,t,o){const n=e.getAttribute("loop");if(!n)return;e.removeAttribute("loop");const i=e.getAttribute("if");i&&e.removeAttribute("if");const l=n.match(/^(.+?)\s+in\s+(.+)$/);if(!l)throw new Error("Invalid loop binding: expected <id> or [<id>, <id>]");const[,r,s]=l,c=gt(r),a=B(s.trim(),t);if(a==null){e.remove();return}if(typeof a!="object"){T.error("State source is not iterable",{collectionExp:s,raw:a});return}const u=Array.isArray(a),d=u?a.map((f,y)=>[String(y),f]):Object.entries(a),v=d.length,x=document.createDocumentFragment(),M=u?pt(a):void 0,N={...t};let C=0;for(const[f,y]of d){if(N.index=C,N.key=f,N.isFirst=C===0,N.isLast=C===v-1,N.isEven=C%2===0,N.isOdd=C%2!==0,c.type==="single"||(N[c.keyVar]=f),N[c.itemVar]=y,i&&!B(i,N)){C++;continue}const b=e.cloneNode(!0);u&&b instanceof HTMLElement&&M&&M[C]!==void 0&&ot(b,M[C]),b instanceof HTMLElement&&(await Pe(b,N,o),x.appendChild(b)),C++}x.childNodes.length>0&&e.parentNode?e.parentNode.replaceChild(x,e):e.remove()}function _t(e,t,o){const n=e.parentNode,i=()=>{if(n)return o.get(n)},l=a=>{n&&o.set(n,a)},r=()=>{n&&o.delete(n)},s=e.getAttribute("if");if(s!==null){const a=!!B(s,t);l({hasHead:!0,resolved:a}),a?e.removeAttribute("if"):e.remove();return}const c=e.getAttribute("else-if");if(c!==null){const a=i();if(!a?.hasHead){e.remove();return}if(a.resolved){e.remove();return}const u=!!B(c,t);l({hasHead:!0,resolved:u}),u?e.removeAttribute("else-if"):e.remove();return}if(e.hasAttribute("else")){const a=i();if(!a?.hasHead){e.remove();return}a.resolved?e.remove():e.removeAttribute("else"),r();return}}async function Ct(e,t,o=50){const n=new WeakMap;for(let i=0;i<e.length;i+=o){const l=e.slice(i,i+o);for(const{node:r,state:s}of l){if(r instanceof HTMLElement){if(r.hasAttribute("loop")){await Nt(r,s,t);continue}if(r.hasAttribute("if")||r.hasAttribute("else")||r.hasAttribute("else-if")){_t(r,s,n);continue}continue}const c=Re(r.nodeValue,s);if(Fe(c)){const a=document.createRange().createContextualFragment(c);r.replaceWith(a)}else r.nodeValue=c}i+o<e.length&&await new Promise(requestAnimationFrame)}}async function Pe(e,t,o){try{const n=bt(e),i=new Set,l=[];let r=n.currentNode;for(;r;){if(i.has(r)){r=n.nextNode();continue}if(i.add(r),r.nodeType===Node.ELEMENT_NODE&&r instanceof HTMLElement){const s=r;if(s.hasAttribute("loop")){l.push({node:s,state:t}),r=vt(n,s);continue}(s.hasAttribute("if")||s.hasAttribute("else")||s.hasAttribute("else-if"))&&l.push({node:s,state:t});for(const c of Array.from(s.attributes)){if(c.name==="ref"&&(o[c.value]=s),c.name.startsWith(":")){const a=c.name.slice(1),u=c.value.trim();try{const d=B(u,t);if(a==="class"&&typeof d=="object"&&d!==null){const v=[];for(const[x,M]of Object.entries(d))M&&v.push(x);if(v.length>0){const x=s.getAttribute("class")||"",M=x?`${x} ${v.join(" ")}`:v.join(" ");s.setAttribute("class",M)}}else d!=null&&d!==!1&&(d===!0?s.setAttribute(a,""):s.setAttribute(a,String(d)));s.removeAttribute(c.name)}catch(d){T.errorWithContext(`Error evaluating dynamic attribute "${c.name}"`,{attributeName:c.name,expression:u},d)}continue}if(c.value.includes("{{"))try{let a=Re(c.value,t);c.name==="class"&&(a=a.replace(/\s+/g," ").trim()),a!==c.value&&s.setAttribute(c.name,a)}catch(a){T.errorWithContext(`Error replacing attribute "${c.name}"`,{attributeName:c.name},a)}}if(s.tagName.includes("-")){r=Et(n)||n.nextNode();continue}}else if(r.nodeType===Node.TEXT_NODE&&r instanceof Text){let s=r.parentElement,c=!1;for(;s;){if(s.tagName.includes("-")){c=!0;break}s=s.parentElement}c||l.push({node:r,state:t})}r=n.nextNode()}await Ct(l,o)}catch(n){throw T.errorWithContext("Error processing template",{},n),n}}function At(e,t={}){if(!Array.isArray(e)||e.length===0)throw new Error("composeBySource: layers must be a non-empty array");if(e.some(s=>s==null||typeof s!="object"))throw new Error("composeBySource: all layers must be objects");const{defaultWriteIndex:o=e.length-1,includePrototype:n=!1}=t,i=o>=0&&o<e.length&&Number.isInteger(o)?o:e.length-1;o!==i&&T.warnWithContext(`Invalid defaultWriteIndex ${o}, using ${i}`,{defaultWriteIndex:o,validWriteIndex:i,layersLength:e.length});const l=(s,c)=>n?c in s:Object.prototype.hasOwnProperty.call(s,c),r=s=>{for(let c=0;c<e.length;c++)if(l(e[c],s))return c;return-1};return new Proxy(e[i],{get(s,c){const a=r(c);if(a!==-1)return e[a][c]},set(s,c,a){const u=r(c),d=u!==-1?u:i;return e[d][c]=a,!0},deleteProperty(s,c){const a=r(c);return a===-1?!0:delete e[a][c]},has(s,c){return r(c)!==-1},ownKeys(){const s=new Set;for(const c of e)Reflect.ownKeys(c).forEach(a=>{typeof a!="number"&&s.add(a)});return Array.from(s)},getOwnPropertyDescriptor(s,c){for(const a of e){const u=Object.getOwnPropertyDescriptor(a,c);if(u)return u}}})}function me(e){const t=e.getRootNode(),o=e.parentElement??(t instanceof ShadowRoot?t.host:void 0);if(Je(o))return o.instance}function Tt({container:e,host:t}){const o=Array.from(t.childNodes).filter(i=>i.nodeType===Node.ELEMENT_NODE||i.nodeType===Node.TEXT_NODE),n={};for(const i of o){const l=i instanceof HTMLElement&&i.hasAttribute("slot")?i.getAttribute("slot"):"default";n[l]||(n[l]=[]),n[l].push(i)}e.querySelectorAll("slot").forEach(i=>{const l=i.getAttribute("name")||"default",r=n[l];r&&r.length>0&&r.forEach(s=>{i.parentNode.insertBefore(s,i)}),i.remove()})}function St(e,t,o){const n=new Map,i=new Map,l=()=>{for(const a of Object.keys(o)){const u=n.get(o[a]);u instanceof HTMLElement&&(o[a]=u)}};if(!e.querySelector("slot"))return{commit:()=>{},remapRefs:l};const r=document.createElement("div"),s=a=>{const u=a.cloneNode(!1);if(n.set(u,a),!(a instanceof HTMLElement&&a.tagName.includes("-")))for(const d of a.childNodes)u.appendChild(s(d));return i.set(u,{attributes:new Map(a instanceof HTMLElement?Array.from(a.attributes,d=>[d.name,d.value]):[]),children:Array.from(u.childNodes),value:u.nodeValue}),u};for(const a of t.childNodes)r.appendChild(s(a));return Tt({container:e,host:r}),{commit:()=>{const a=u=>{const d=n.get(u),v=i.get(u),x=Array.from(u.childNodes),M=x.map(a);if(!d||!v)return x.forEach((N,C)=>{M[C]!==N&&N.replaceWith(M[C])}),u;if(d instanceof HTMLElement&&u instanceof HTMLElement){for(const N of v.attributes.keys())u.hasAttribute(N)||d.removeAttribute(N);for(const N of Array.from(u.attributes))v.attributes.get(N.name)!==N.value&&d.setAttribute(N.name,N.value);!d.tagName.includes("-")&&(x.length!==v.children.length||x.some((N,C)=>N!==v.children[C]))&&d.replaceChildren(...M)}else u.nodeValue!==v.value&&(d.nodeValue=u.nodeValue);return d};for(const u of Array.from(e.childNodes)){const d=a(u);d!==u&&u.replaceWith(d)}l()},remapRefs:l}}function oe({propName:e,propValue:t,props:o}){const n=o[e],i=t??n?.default;if(!n)return!0;const l=Ve(n.type),r=Array.isArray(i)?"array":typeof i,s={string:r==="string",number:r==="number",boolean:r==="boolean",array:Array.isArray(i),object:r==="object"&&i!==null&&!Array.isArray(i),function:r==="function"};return(l==="unknown"?!0:s[l]??!1)?n.regex&&typeof i=="string"&&!new RegExp(n.regex).test(i)?(T.error(`Prop "${e}" does not match regex "${n.regex}".`),!1):!0:(T.error(`Prop "${e}" should be of type "${l}", but got "${r}".`,i),!1)}function ye({ele:e,parent:t,props:o,state:n}){const i=Object.keys(o).length>0,l=(r,s)=>{Object.defineProperty(n,r,{enumerable:!0,configurable:!0,get(){if(t)return re(t.state,s)},set(c){if(!(!t||!t.state))try{je(t.state,s,c)}catch(a){T.errorWithContext(`Failed to set bound prop "${r}" → "${s}"`,{propName:r,parentPath:s},a)}}})};for(const r of e.attributes){const s=r.name.startsWith(":"),c=qe(r.name.substring(s?1:0));if(s&&!t||!(!i||o[c]&&o[c]!==void 0))continue;if(!s){const v=r.value!==""?r.value:!0;(!i||oe({propName:c,propValue:v,props:o}))&&(n[c]=v);continue}const u=r.value?.trim()??"";if(u&&ve(u)){const v=re(t.state,u);(!i||oe({propName:c,propValue:v,props:o}))&&l(c,u);continue}const d=u?B(u,t.state):void 0;(!i||oe({propName:c,propValue:d,props:o}))&&(n[c]=d)}for(const[r,s]of Object.entries(o))r in n||(s.default!==void 0?n[r]=s.default:s.required&&T.error(`Required prop "${r}" is missing.`))}function xt(e,t){const o=new Set;customElements.define(e,class extends HTMLElement{template;instance;_connectionVersion=0;_isDisconnected=!1;_isMounted=!1;_model;_observerFn;_renderAborted=!1;_pendingRender=null;_eventCleanup=null;constructor(){super(),this.template=document.createElement("template"),this.template.innerHTML=t.template}async connectedCallback(){const n=this,i=++this._connectionVersion;if(this._isDisconnected=!1,this._renderAborted=!1,this._pendingRender=null,o.add(this),!document.head.querySelector(`style#style-${e}`)){const g=document.createElement("style");g.id=`style-${e}`,g.textContent=t.style,document.head.appendChild(g)}if(n.instance&&this._model&&this._observerFn){const g=n.instance,p=me(n);g.$parent=p,this._isDisconnected=!1,this._renderAborted=!1,this._pendingRender=null,this._model.addObserver(this._observerFn),g.props&&g.state&&ye({ele:n,parent:p,props:g.props,state:g.state});return}const r=(t.type||"options")==="options",s=me(n),c=this.template.cloneNode(!0);let a;if(t.deps){a={};const g=Object.entries(t.deps),p=await Promise.all(g.map(([,_])=>_()));for(let _=0;_<g.length;_++)a[g[_][0]]=p[_]}if(i!==this._connectionVersion||this._isDisconnected)return;const u=Ke(t.script,a),d={};let v=!1,x=-1;this._isDisconnected=!1,this._renderAborted=!1,this._pendingRender=null;const M=we(),N=(()=>{let g;return{promise:new Promise(_=>{g=_}),resolve:g}})();let C,f;const y=g=>{const p=Z.plugins[g];if(!p||typeof p.setup!="function"){T.warnWithContext(`Plugin "${g}" not found or has no setup method`,{pluginName:g});return}try{const _=r&&f?f:C;return p.setup.call(_)}catch(_){T.errorWithContext(`Plugin "${g}" setup failed`,{pluginName:g},_);return}},b={};for(const[g,p]of Object.entries(Z.modules))if(typeof p.attach=="function"){const _=p.attach.call({element:n,parent:s,core:{take:le.take}});_&&(b[`$${g}`]=_)}const w=new Map,h=g=>{let p=w.get(g);return p||(p=`on${g.charAt(0).toUpperCase()}${g.slice(1)}`,w.set(g,p)),p},m=(g,...p)=>{const _=h(g);let O=s;for(;O;){const L=O.userContext;if(L){const j=L[_];typeof j=="function"&&j(...p)}else if(O.methods){const j=O.methods[_];typeof j=="function"&&j(...p)}O=O.$parent}},E={$refs:d,$parent:s,$emit:m,$take:y,...b},S=u(E),A=yt(S.state??{});C=A.state;const I=S.methods||{},R=S.props||{},D=S.events||[];let k=S.watchList||[];r&&(f=At([I,C])),ye({ele:n,parent:s,props:R,state:C}),r&&f&&We(I,f);for(const g of De){const p=S[g];if(typeof p=="function"){const _=r&&f?Y(p,f):p;_e(M,g,async()=>{const O=_();O instanceof Promise&&await O})}}this._model=A;const $=async()=>{if(this._isDisconnected)return;if(v){this._renderAborted=!0,this._pendingRender=$;return}const g=A.getStateVersion();if(x!==g){v=!0,this._renderAborted=!1,n.instance&&(n.instance.isRendering=!0);try{const p=c.content.cloneNode(!0),_=St(p,n,d);if(await Pe(p,r&&f?f:C,d),_.remapRefs(),this._renderAborted||this._model!==A){this._pendingRender=$;return}const L=r&&f?f:C;if(await P("global","processed",L),await P(M,"processed"),this._renderAborted||this._model!==A){this._pendingRender=$;return}const j=A.flushChanges();Object.defineProperty(L,"changedPaths",{value:j,writable:!0,configurable:!0,enumerable:!1});const fe=!this._isMounted;if(await P("global",fe?"beforeMount":"beforeUpdate",L),await P(M,fe?"beforeMount":"beforeUpdate",L),this._renderAborted||this._model!==A){delete L.changedPaths,this._pendingRender=$;return}_.commit(),r&&f?(st(f,p),this._eventCleanup&&this._eventCleanup(),this._eventCleanup=it(f,D,p,d)):(ct(I,p),this._eventCleanup&&this._eventCleanup(),this._eventCleanup=at(I,C,D,p,d)),nt(n,p,!this._isMounted,t.structAttr),this._isMounted&&(await P("global","updated",L),await P(M,"updated",L)),delete L.changedPaths,x=g,n.instance&&(n.instance._lastRenderedStateVersion=x)}catch(p){T.errorWithContext("Error during render",{componentName:e},p)}finally{const p=r&&f?f:C;if(delete p.changedPaths,v=!1,n.instance&&(n.instance.isRendering=!1),this._pendingRender&&!this._isDisconnected){const _=this._pendingRender;this._pendingRender=null,requestAnimationFrame(()=>{this._isDisconnected||_().catch(O=>{T.errorWithContext("Error during pending render",{componentName:e},O)})})}}}};n.instance={element:n,template:c,state:C,userContext:r?f:void 0,props:R,methods:I,events:D,watchList:k,$refs:d,$parent:s,$emit:m,$take:y,readyPromise:N.promise,lifecycleRegistry:M,...b,isRendering:!1},this._observerFn=()=>{if(this._isDisconnected||k&&k.length>0&&!A.hasPendingChangesFor(k))return;let g=s;for(;g;){if(g.isRendering)return;g=g.$parent}requestAnimationFrame(()=>{this._isDisconnected||$().catch(p=>{T.errorWithContext("Error during render (observer)",{componentName:e},p)})})},A.addObserver(this._observerFn);const G=r&&f?f:C;if(await P("global","created",G),await P(M,"created"),!(this._isDisconnected||this._model!==A)&&(await $(),!(this._isDisconnected||this._model!==A))){if(!this._isMounted){if(await P("global","mounted",G),this._isDisconnected||this._model!==A||(await P(M,"mounted"),this._isDisconnected||this._model!==A))return;this._isMounted=!0}N.resolve()}}async disconnectedCallback(){const n=this,i=++this._connectionVersion;if(this._isDisconnected=!0,this._renderAborted=!0,this._pendingRender=null,o.delete(this),o.size===0&&document.head.querySelector(`style#style-${e}`)?.remove(),!n.instance)return;const l=n.instance;this._isDisconnected=!0,this._renderAborted=!0,this._pendingRender=null,this._model&&this._observerFn&&this._model.removeObserver(this._observerFn);const r=l.userContext||l.state;await P("global","beforeDestroy",r),await P(l.lifecycleRegistry,"beforeDestroy"),!(!this._isDisconnected||i!==this._connectionVersion)&&(Me(this),this._eventCleanup&&(this._eventCleanup(),this._eventCleanup=null),await P("global","destroyed",r),await P(l.lifecycleRegistry,"destroyed"),!(!this._isDisconnected||i!==this._connectionVersion)&&(this._isMounted=!1,this._model=void 0,this._observerFn=void 0,this._eventCleanup=null,n.instance=void 0))}})}let ce=!1,ge=!1,ae=[];function Mt(){ge||(ge=!0,!(typeof document>"u"||typeof HTMLElement>"u")&&(lt(),Qe(),ut()))}function Ie(...e){const t=e[0],o=e[1];if(Ze(t)){if(!o){T.error("ComponentSource requires a component name when calling take()");return}xt(o,t);return}if(J(t)||Ye(t)){const n={registerHook:(i,l)=>{_e("global",i,l)},take:le.take};try{t.install(n),J(t)?Z.plugins[t.name]=t:Z.modules[t.name]=t}catch(i){T.errorWithContext("Failed to install extension",{name:t.name,type:J(t)?"plugin":"module"},i)}return}T.error("Unknown extension type",t)}function Ot(){ce||(ce=!0,ae.forEach(e=>Ie(...e)),ae=[],T.info("Core initialized"))}const le=Object.assign(()=>{Mt(),Ot()},{take:(...t)=>{ce?Ie(...t):ae.push(t)}});exports.Core=le;exports.LogLevel=be;exports.logger=T;
18
+ return (${r});
19
+ `;try{const i=t?new Function("context","__deps",l):new Function("context",l);return(c=>t?i(c,t):i(c))}catch(i){throw N.errorWithContext("Failed to compile dynamic code",{functionBody:l},i),i}}function Ce(){return new Map}const Ne=Ce();function Ae(e,t,r){e==="global"&&(e=Ne),e.has(t)||e.set(t,new Set),e.get(t).add(r)}async function I(e,t,r){e==="global"&&(e=Ne);const n=Array.from(e.get(t)??[]);for(const o of n)try{await o(r)}catch(l){N.errorWithContext(`Hook "${t}" callback failed`,{hook:t},l)}}const J={modules:{},plugins:{}};function Je(e){if(e==null||typeof e!="object")return!1;const t=e;return typeof t.template=="string"&&typeof t.script=="string"&&typeof t.style=="string"}function ee(e){if(e==null||typeof e!="object")return!1;const t=e;return typeof t.setup=="function"&&t.attach===void 0}function Qe(e){if(e==null||typeof e!="object")return!1;const t=e;return typeof t.attach=="function"&&t.setup===void 0}function et(e){return e instanceof HTMLElement&&"instance"in e&&e.instance!==void 0}const tt=()=>{Object.defineProperties(Object.prototype,ze),typeof HTMLElement<"u"&&Object.defineProperties(HTMLElement.prototype,qe)};function X(e){return e.nodeType===Node.ELEMENT_NODE&&e.tagName.includes("-")}function nt(e,t){const r=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:o=>X(o)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP});let n=r.nextNode();for(;n;){const o=n.getAttribute(t);o!==null&&(Pe(n)===void 0&&xe(n,o),n.removeAttribute(t)),n=r.nextNode()}}function pe(e,t){if(!X(e))return null;const r=e.tagName;let n=Pe(e);const o=st(e);if(n===void 0&&t){const l=e.getAttribute(t);l!==null&&(xe(e,l),n=l,e.removeAttribute(t))}return n===void 0?null:o!==void 0?`${r}:${String(n)}:${String(o)}`:`${r}:${String(n)}`}function rt(e,t){return e.nodeType!==t.nodeType?!1:e.nodeType===Node.TEXT_NODE||e.nodeType===Node.COMMENT_NODE?!0:e.nodeType===Node.ELEMENT_NODE?e.tagName===t.tagName:!1}function te(e,t){const r=new Set(e.getAttributeNames()),n=new Set(t.getAttributeNames());for(const o of r)!n.has(o)&&!o.startsWith("@")&&e.removeAttribute(o);for(const o of n){const l=t.getAttribute(o),i=e.getAttribute(o);l!==i&&(l===null?e.removeAttribute(o):e.setAttribute(o,l))}}function Te(e,t,r){const n=Array.from(e.childNodes),o=Array.from(t.childNodes),l=new Map,i=new Set;for(const s of n){const c=pe(s,r);c!==null&&!l.has(c)&&l.set(c,s)}for(let s=0;s<o.length;s++){const c=o[s],a=n[s],u=pe(c,r);let d=null;if(u!==null&&l.has(u)&&(d=l.get(u),i.add(d)),d&&X(d)){a!==d&&(s<e.childNodes.length?e.insertBefore(d,e.childNodes[s]):e.appendChild(d)),te(d,c);continue}if(X(c)&&u!==null){a?e.replaceChild(c,a):e.appendChild(c);continue}if(!a){e.appendChild(c);continue}if(!rt(a,c)){e.replaceChild(c,a);continue}if(a.nodeType===Node.TEXT_NODE){a.textContent!==c.textContent&&(a.textContent=c.textContent);continue}if(a.nodeType===Node.COMMENT_NODE){a.textContent!==c.textContent&&(a.textContent=c.textContent);continue}if(a.nodeType===Node.ELEMENT_NODE){const v=a,A=c;if(X(v)){te(v,A);continue}te(v,A),Te(v,A,r)}}for(;e.childNodes.length>o.length;){const s=e.lastChild;s&&e.removeChild(s)}}function ot(e,t,r,n){if(r||e.childNodes.length===0){n&&nt(t,n),e.replaceChildren(t);return}const o=document.createElement("div");o.appendChild(t),Te(e,o,n)}const ce=Symbol("STRUCT_ID"),ae=Symbol("SLOT_ID");function Se(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,configurable:!0,enumerable:!1})}function xe(e,t){Se(e,ce,t)}function Pe(e){return Object.prototype.hasOwnProperty.call(e,ce)?e[ce]:void 0}function it(e,t){Se(e,ae,t)}function st(e){return Object.prototype.hasOwnProperty.call(e,ae)?e[ae]:void 0}function ct(e,t,r,n){if(!Array.isArray(t))return()=>{};const o=[];return t.forEach(([l,i,s])=>{if(typeof l!="string"||typeof s!="function"){N.error("Provided handler is not a function",s);return}let c=[];if(i==="window")c=[window];else if(typeof i=="string")if(i.startsWith("$refs.")){const[a,...u]=i.slice(6).split(" "),d=n[a];d&&(c=u.length?Array.from(d.querySelectorAll(u.join(" "))):[d])}else c=Array.from(r.querySelectorAll(i));else if(i instanceof Element||i instanceof Window)c=[i];else if(typeof i=="object"&&i&&"ref"in i){const{ref:a,selector:u}=i,d=n[a];d&&(c=u?Array.from(d.querySelectorAll(u)):[d])}for(const a of c){const u=Q(s,e);a.addEventListener(l,u),o.push({target:a,type:l,handler:u})}}),()=>{for(const{target:l,type:i,handler:s}of o)l.removeEventListener(i,s);o.length=0}}const ke=/^on([a-z]+)$/i;function at(e,t){const r=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT);let n=r.nextNode();for(;n;){for(const o of Array.from(n.attributes)){const l=o.name.match(ke);if(l){const i=l[1].toLowerCase(),s=o.value;if(s){const c=e[s];typeof c=="function"&&(n.removeAttribute(o.name),n.addEventListener(i,c))}}}n=r.nextNode()}}function lt(e,t){const r=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT);let n=r.nextNode();for(;n;){for(const o of Array.from(n.attributes)){const l=o.name.match(ke);if(l){const i=l[1].toLowerCase(),s=o.value;if(s){const c=e[s];typeof c=="function"&&(n.removeAttribute(o.name),n.addEventListener(i,c))}}}n=r.nextNode()}}function ft(e,t,r,n,o){if(!Array.isArray(r))return()=>{};const l=[];return r.forEach(([i,s,c])=>{if(typeof i!="string"||typeof c!="function"){N.error("Provided handler is not a function",c);return}let a=[];if(s==="window")a=[window];else if(typeof s=="string")if(s.startsWith("$refs.")){const[u,...d]=s.slice(6).split(" "),v=o[u];v&&(a=d.length?Array.from(v.querySelectorAll(d.join(" "))):[v])}else a=Array.from(n.querySelectorAll(s));else if(s instanceof Element||s instanceof Window)a=[s];else if(typeof s=="object"&&s&&"ref"in s){const{ref:u,selector:d}=s,v=o[u];v&&(a=d?Array.from(v.querySelectorAll(d)):[v])}for(const u of a){const d=Q(c,t);u.addEventListener(i,d),l.push({target:u,type:i,handler:d})}}),()=>{for(const{target:i,type:s,handler:c}of l)i.removeEventListener(s,c);l.length=0}}const j=new WeakMap;let ne;function ut(){if(typeof EventTarget>"u")return;const e=globalThis;if(e.__koppajsEventTrackingPatched)return;e.__koppajsEventTrackingPatched=!0;const t=EventTarget.prototype.addEventListener,r=EventTarget.prototype.removeEventListener;EventTarget.prototype.addEventListener=function(n,o,l){return j.has(this)||j.set(this,new Set),j.get(this).add({type:n,listener:o,options:l}),t.call(this,n,o,l)},EventTarget.prototype.removeEventListener=function(n,o,l){const i=j.get(this);if(i){for(const s of i)if(s.type===n&&s.listener===o){i.delete(s);break}i.size===0&&j.delete(this)}return r.call(this,n,o,l)}}function dt(e){const t=j.get(e);if(t){for(const{type:r,listener:n,options:o}of t)e.removeEventListener(r,n,o);j.delete(e)}}function Oe(e){if(typeof document>"u"||typeof NodeFilter>"u"||typeof Element>"u")return;const t=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT);let r=e instanceof Element?e:null;for(;r;)j.has(r)&&dt(r),r=t.nextNode()}function ht(){ne||typeof MutationObserver>"u"||typeof document>"u"||document.body&&(ne=new MutationObserver(e=>{for(const t of e)t.removedNodes.forEach(r=>{r.nodeType!==Node.ELEMENT_NODE||r.isConnected||Oe(r)})}),ne.observe(document.body,{childList:!0,subtree:!0}))}const Re=new WeakMap,$e=new WeakMap,G=new WeakMap;let pt=0;const B=()=>`slot-${++pt}`,L=e=>typeof e=="object"&&e!==null,re=e=>typeof e=="symbol"?e.toString():String(e),mt=e=>{const t=Re.get(e);return t&&L(t)?t:void 0};function Me(e){const t=$e.get(e);return t||e}const W=e=>L(e)?Reflect.get(e,we)===!0:!1;function yt(e){const t=W(e)?Me(e):e;return G.get(t)}const gt=e=>e!==null&&(typeof e=="string"||typeof e=="number"||typeof e=="boolean"||typeof e=="function"||typeof e>"u"),Y=e=>{let t=G.get(e);return t||(t=e.map(()=>B()),G.set(e,t)),t},me=e=>{const t=G.get(e);if(t&&t.length!==e.length)throw new Error(`Slot sidecar invariant violation: slotIds length (${t.length}) does not match array length (${e.length})`)};function bt(e){const t=new Set,r=new WeakMap;let n=0,o=new Set;const l=new Map,i=(f,h)=>!!(f===h||f.startsWith(h+".")),s=(f,h)=>{const b=r.get(f)??"";return b?`${b}.${h}`:h};let c=!1;const a=f=>{o.add(f),n++,c||(c=!0,queueMicrotask(()=>{c=!1,t.forEach(h=>{try{h()}catch(b){console.error("Observer error:",b)}})}))},u=(f,h,b)=>{if(f===h)return;let _=f.length!==h.length;if(!_){for(let p=0;p<f.length;p++)if(f[p]!==h[p]){_=!0;break}}f.splice(0,f.length,...h),_&&a(b)},d=(f,h,b)=>{const _=new Set(f),p=new Set(h);let y=!1;for(const E of _)if(!p.has(E)){y=!0;break}if(!y){for(const E of p)if(!_.has(E)){y=!0;break}}y&&(f.splice(0,f.length,...h),a(b))},v=(f,h,b)=>{const _=new Set(f),p=new Set(h);f.length!==h.length||[..._].some(E=>!p.has(E))||[...p].some(E=>!_.has(E))?d(f,h,b):u(f,h,b)},A=(f,h,b)=>{if(f===h)return!1;let _=!1;for(const p of Object.keys(f))p in h||(_=!0,Reflect.deleteProperty(f,p));for(const p of Object.keys(h)){const y=f[p],E=h[p];y!==E&&(L(y)&&W(y)&&L(E)&&!W(E)?(A(y,E)&&(_=!0),y!==E&&(_=!0,Reflect.set(f,p,E))):(_=!0,Reflect.set(f,p,E)))}return _},O=(f,h,b)=>{const _=Y(f);switch(h){case"push":{const p=Array.from({length:b.length},()=>B());_.push(...p);break}case"pop":{_.pop();break}case"shift":{_.shift();break}case"unshift":{const p=Array.from({length:b.length},()=>B());_.unshift(...p);break}case"splice":{const p=b[0]??0,y=b[1]!==void 0?b[1]:f.length-p,E=b.slice(2),S=Array.from({length:E.length},()=>B());_.splice(p,y,...S);break}case"reverse":{_.reverse();break}}me(f)},w=(f,h="")=>{if(f instanceof Node||f instanceof Window||f instanceof Document)return f;const b=mt(f);if(b)return b;h&&r.set(f,h),Array.isArray(f)&&Y(f);const _=new Proxy(f,{get:(p,y,E)=>{if(y===we)return!0;if(y==="toJSON")return function(){return Me(p)};if(Array.isArray(p)&&typeof y=="string"&&["push","pop","shift","unshift","splice","reverse","sort"].includes(y)){const k=p[y];if(typeof k=="function")return function(...D){if(y==="sort"){const R=Y(p),$=p.map((m,g)=>({el:m,slotId:R[g]||B()})),V=k.apply(this,D),K=new Map;for(let m=0;m<$.length;m++){const g=$[m].el;let C=K.get(g);C||(C=[],K.set(g,C)),C.push(m)}for(let m=0;m<p.length;m++){const g=p[m],C=K.get(g);if(C&&C.length>0){const M=C.shift();R[m]=$[M].slotId}else R[m]=B()}return me(p),V}else{const R=k.apply(this,D);return O(p,y,D),R}}}const S=Reflect.get(p,y,E),x=Array.isArray(p)&&typeof y=="string"&&/^\d+$/.test(y);if(L(S)&&!W(S)&&!x&&(Array.isArray(S)||!Array.isArray(p))){const T=re(y),k=s(p,T);return w(S,k)}return S},set:(p,y,E,S)=>{const x=Reflect.get(p,y,S);if(x===E)return!0;const T=re(y),k=s(p,T);if(Array.isArray(p)&&typeof y=="string"&&/^\d+$/.test(y)){const R=parseInt(y,10);if(R>=0&&R<p.length){const $=Reflect.set(p,y,E,S);return a(k),$}}if(Array.isArray(x)&&!gt(E)&&Array.isArray(E)){v(x,E,k);const R=x.map(()=>B());return G.set(x,R),!0}if(L(x)&&W(x)&&L(E)&&!W(E)){if(A(x,E)){let $=E;L($)&&!W($)&&($=w($,k)),Reflect.set(p,y,$,S),a(k)}return!0}const D=Reflect.set(p,y,E,S);if(L(E)&&!W(E)){const R=w(E,k);Reflect.set(p,y,R,S),Array.isArray(E)&&Y(E)}return a(k),D},deleteProperty:(p,y)=>{if(y==="changedPaths")return Reflect.deleteProperty(p,y);const E=re(y),S=s(p,E),x=Reflect.get(p,y),T=Reflect.deleteProperty(p,y);return T&&x!==void 0&&a(S),T}});return Re.set(f,_),$e.set(_,f),_};return{state:w(e),watch(f,h){let b=l.get(f);b||(b=new Set,l.set(f,b)),b.add(h);let _=!1;return()=>{if(_)return;_=!0;const p=l.get(f);p&&(p.delete(h),p.size===0&&l.delete(f))}},addObserver(f){t.add(f)},removeObserver(f){t.delete(f)},getStateVersion(){return n},hasPendingChangesFor(f){for(const h of o)for(const b of f)if(h===b||h.startsWith(b+"."))return!0;return!1},flushChanges(){const f=new Set(o);if(f.size>0&&l.size>0){const h=new Map;for(const[b,_]of l){const p=new Set;for(const y of f)i(y,b)&&p.add(y);if(p.size>0)for(const y of _){const E=h.get(y);if(E)for(const S of p)E.add(S);else h.set(y,new Set(p))}}for(const[b,_]of h)b({changedPaths:_})}return o=new Set,f}}}const oe=/^[A-Za-z_$][A-Za-z0-9_$]*$/;function Et(e){const t=e.trim();if(t.startsWith("[")&&t.endsWith("]")){const n=t.slice(1,-1).split(",").map(i=>i.trim());if(n.length!==2)throw new Error("Invalid loop binding: expected <id> or [<id>, <id>]");const[o,l]=n;if(!oe.test(o)||!oe.test(l))throw new Error("Invalid loop binding: expected <id> or [<id>, <id>]");return{type:"tuple",keyVar:o,itemVar:l}}if(!oe.test(t))throw new Error("Invalid loop binding: expected <id> or [<id>, <id>]");return{type:"single",itemVar:t}}function vt(e){const t={acceptNode(r){return r.nodeType===Node.ELEMENT_NODE||r.nodeType===Node.TEXT_NODE&&/\{\{(.+?)\}\}/g.test(r.nodeValue||"")?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}};return document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT,t)}function wt(e){const t=e.currentNode;return t?.nextSibling?e.currentNode=t.nextSibling:e.nextNode()}function _t(e,t){let r=t.nextSibling;if(!r){let n=t.parentNode;for(;n&&n!==e.root;){if(n.nextSibling){r=n.nextSibling;break}n=n.parentNode}}return r?(e.currentNode=r,r):null}function Ct(e){return e==null||e===!0||e===!1?"":String(e)}function Ie(e,t){return e.replace(/\{\{(.+?)\}\}/g,(r,n)=>{const o=q(n.trim(),t);return Ct(o)})}async function Nt(e,t,r){const n=e.getAttribute("loop");if(!n)return;e.removeAttribute("loop");const o=e.getAttribute("if");o&&e.removeAttribute("if");const l=n.match(/^(.+?)\s+in\s+(.+)$/);if(!l)throw new Error("Invalid loop binding: expected <id> or [<id>, <id>]");const[,i,s]=l,c=Et(i),a=q(s.trim(),t);if(a==null){e.remove();return}if(typeof a!="object"){N.error("State source is not iterable",{collectionExp:s,raw:a});return}const u=Array.isArray(a),d=u?a.map((f,h)=>[String(h),f]):Object.entries(a),v=d.length,A=document.createDocumentFragment(),O=u?yt(a):void 0,w={...t};let P=0;for(const[f,h]of d){if(w.index=P,w.key=f,w.isFirst=P===0,w.isLast=P===v-1,w.isEven=P%2===0,w.isOdd=P%2!==0,c.type==="single"||(w[c.keyVar]=f),w[c.itemVar]=h,o&&!q(o,w)){P++;continue}const b=e.cloneNode(!0);u&&b instanceof HTMLElement&&O&&O[P]!==void 0&&it(b,O[P]),b instanceof HTMLElement&&(await Fe(b,w,r),A.appendChild(b)),P++}A.childNodes.length>0&&e.parentNode?e.parentNode.replaceChild(A,e):e.remove()}function At(e,t,r){const n=e.parentNode,o=()=>{if(n)return r.get(n)},l=a=>{n&&r.set(n,a)},i=()=>{n&&r.delete(n)},s=e.getAttribute("if");if(s!==null){const a=!!q(s,t);l({hasHead:!0,resolved:a}),a?e.removeAttribute("if"):e.remove();return}const c=e.getAttribute("else-if");if(c!==null){const a=o();if(!a?.hasHead){e.remove();return}if(a.resolved){e.remove();return}const u=!!q(c,t);l({hasHead:!0,resolved:u}),u?e.removeAttribute("else-if"):e.remove();return}if(e.hasAttribute("else")){const a=o();if(!a?.hasHead){e.remove();return}a.resolved?e.remove():e.removeAttribute("else"),i();return}}async function Tt(e,t,r=50){const n=new WeakMap;for(let o=0;o<e.length;o+=r){const l=e.slice(o,o+r);for(const{node:i,state:s}of l){if(i instanceof HTMLElement){if(i.hasAttribute("loop")){await Nt(i,s,t);continue}if(i.hasAttribute("if")||i.hasAttribute("else")||i.hasAttribute("else-if")){At(i,s,n);continue}continue}const c=Ie(i.nodeValue,s);if(je(c)){const a=document.createRange().createContextualFragment(c);i.replaceWith(a)}else i.nodeValue=c}o+r<e.length&&await new Promise(requestAnimationFrame)}}async function Fe(e,t,r){try{const n=vt(e),o=new Set,l=[];let i=n.currentNode;for(;i;){if(o.has(i)){i=n.nextNode();continue}if(o.add(i),i.nodeType===Node.ELEMENT_NODE&&i instanceof HTMLElement){const s=i;if(s.hasAttribute("loop")){l.push({node:s,state:t}),i=_t(n,s);continue}(s.hasAttribute("if")||s.hasAttribute("else")||s.hasAttribute("else-if"))&&l.push({node:s,state:t});for(const c of Array.from(s.attributes)){if(c.name==="ref"&&(r[c.value]=s),c.name.startsWith(":")){const a=c.name.slice(1),u=c.value.trim();try{const d=q(u,t);if(a==="class"&&typeof d=="object"&&d!==null){const v=[];for(const[A,O]of Object.entries(d))O&&v.push(A);if(v.length>0){const A=s.getAttribute("class")||"",O=A?`${A} ${v.join(" ")}`:v.join(" ");s.setAttribute("class",O)}}else d!=null&&d!==!1&&(d===!0?s.setAttribute(a,""):s.setAttribute(a,String(d)));s.removeAttribute(c.name)}catch(d){N.errorWithContext(`Error evaluating dynamic attribute "${c.name}"`,{attributeName:c.name,expression:u},d)}continue}if(c.value.includes("{{"))try{let a=Ie(c.value,t);c.name==="class"&&(a=a.replace(/\s+/g," ").trim()),a!==c.value&&s.setAttribute(c.name,a)}catch(a){N.errorWithContext(`Error replacing attribute "${c.name}"`,{attributeName:c.name},a)}}if(s.tagName.includes("-")){i=wt(n)||n.nextNode();continue}}else if(i.nodeType===Node.TEXT_NODE&&i instanceof Text){let s=i.parentElement,c=!1;for(;s;){if(s.tagName.includes("-")){c=!0;break}s=s.parentElement}c||l.push({node:i,state:t})}i=n.nextNode()}await Tt(l,r)}catch(n){throw N.errorWithContext("Error processing template",{},n),n}}function St(e,t={}){if(!Array.isArray(e)||e.length===0)throw new Error("composeBySource: layers must be a non-empty array");if(e.some(s=>s==null||typeof s!="object"))throw new Error("composeBySource: all layers must be objects");const{defaultWriteIndex:r=e.length-1,includePrototype:n=!1}=t,o=r>=0&&r<e.length&&Number.isInteger(r)?r:e.length-1;r!==o&&N.warnWithContext(`Invalid defaultWriteIndex ${r}, using ${o}`,{defaultWriteIndex:r,validWriteIndex:o,layersLength:e.length});const l=(s,c)=>n?c in s:Object.prototype.hasOwnProperty.call(s,c),i=s=>{for(let c=0;c<e.length;c++)if(l(e[c],s))return c;return-1};return new Proxy(e[o],{get(s,c){const a=i(c);if(a!==-1)return e[a][c]},set(s,c,a){const u=i(c),d=u!==-1?u:o;return e[d][c]=a,!0},deleteProperty(s,c){const a=i(c);return a===-1?!0:delete e[a][c]},has(s,c){return i(c)!==-1},ownKeys(){const s=new Set;for(const c of e)Reflect.ownKeys(c).forEach(a=>{typeof a!="number"&&s.add(a)});return Array.from(s)},getOwnPropertyDescriptor(s,c){for(const a of e){const u=Object.getOwnPropertyDescriptor(a,c);if(u)return u}}})}function ye(e){const t=e.getRootNode(),r=e.parentElement??(t instanceof ShadowRoot?t.host:void 0);if(et(r))return r.instance}function xt({container:e,host:t}){const r=Array.from(t.childNodes).filter(o=>o.nodeType===Node.ELEMENT_NODE||o.nodeType===Node.TEXT_NODE),n={};for(const o of r){const l=o instanceof HTMLElement&&o.hasAttribute("slot")?o.getAttribute("slot"):"default";n[l]||(n[l]=[]),n[l].push(o)}e.querySelectorAll("slot").forEach(o=>{const l=o.getAttribute("name")||"default",i=n[l];i&&i.length>0&&i.forEach(s=>{o.parentNode.insertBefore(s,o)}),o.remove()})}function Pt(e,t,r){const n=new Map,o=new Map,l=()=>{for(const a of Object.keys(r)){const u=n.get(r[a]);u instanceof HTMLElement&&(r[a]=u)}};if(!e.querySelector("slot"))return{commit:()=>{},remapRefs:l};const i=document.createElement("div"),s=a=>{const u=a.cloneNode(!1);if(n.set(u,a),!(a instanceof HTMLElement&&a.tagName.includes("-")))for(const d of a.childNodes)u.appendChild(s(d));return o.set(u,{attributes:new Map(a instanceof HTMLElement?Array.from(a.attributes,d=>[d.name,d.value]):[]),children:Array.from(u.childNodes),value:u.nodeValue}),u};for(const a of t.childNodes)i.appendChild(s(a));return xt({container:e,host:i}),{commit:()=>{const a=u=>{const d=n.get(u),v=o.get(u),A=Array.from(u.childNodes),O=A.map(a);if(!d||!v)return A.forEach((w,P)=>{O[P]!==w&&w.replaceWith(O[P])}),u;if(d instanceof HTMLElement&&u instanceof HTMLElement){for(const w of v.attributes.keys())u.hasAttribute(w)||d.removeAttribute(w);for(const w of Array.from(u.attributes))v.attributes.get(w.name)!==w.value&&d.setAttribute(w.name,w.value);!d.tagName.includes("-")&&(A.length!==v.children.length||A.some((w,P)=>w!==v.children[P]))&&d.replaceChildren(...O)}else u.nodeValue!==v.value&&(d.nodeValue=u.nodeValue);return d};for(const u of Array.from(e.childNodes)){const d=a(u);d!==u&&u.replaceWith(d)}l()},remapRefs:l}}function ge(e){const t=["opacity","transition-property"],r=t.map(o=>({name:o,value:e.style.getPropertyValue(o),priority:e.style.getPropertyPriority(o)}));e.style.setProperty("transition-property","none","important"),e.style.setProperty("opacity","0","important");const n=t.map(o=>e.style.getPropertyPriority(o));return()=>{for(const[o,{name:l,value:i,priority:s}]of r.entries()){const c=l==="opacity"?"0":"none";e.style.getPropertyValue(l)!==c||e.style.getPropertyPriority(l)!==n[o]||(i?e.style.setProperty(l,i,s):e.style.removeProperty(l))}}}function ie({propName:e,propValue:t,props:r}){const n=r[e],o=t??n?.default;if(!n)return!0;const l=He(n.type),i=Array.isArray(o)?"array":typeof o,s={string:i==="string",number:i==="number",boolean:i==="boolean",array:Array.isArray(o),object:i==="object"&&o!==null&&!Array.isArray(o),function:i==="function"};return(l==="unknown"?!0:s[l]??!1)?n.regex&&typeof o=="string"&&!new RegExp(n.regex).test(o)?(N.error(`Prop "${e}" does not match regex "${n.regex}".`),!1):!0:(N.error(`Prop "${e}" should be of type "${l}", but got "${i}".`,o),!1)}function be({ele:e,parent:t,props:r,state:n}){const o=Object.keys(r).length>0,l=(i,s)=>{Object.defineProperty(n,i,{enumerable:!0,configurable:!0,get(){if(t)return se(t.state,s)},set(c){if(!(!t||!t.state))try{Be(t.state,s,c)}catch(a){N.errorWithContext(`Failed to set bound prop "${i}" → "${s}"`,{propName:i,parentPath:s},a)}}})};for(const i of e.attributes){const s=i.name.startsWith(":"),c=Ue(i.name.substring(s?1:0));if(s&&!t||!(!o||r[c]&&r[c]!==void 0))continue;if(!s){const v=i.value!==""?i.value:!0;(!o||ie({propName:c,propValue:v,props:r}))&&(n[c]=v);continue}const u=i.value?.trim()??"";if(u&&_e(u)){const v=se(t.state,u);(!o||ie({propName:c,propValue:v,props:r}))&&l(c,u);continue}const d=u?q(u,t.state):void 0;(!o||ie({propName:c,propValue:d,props:r}))&&(n[c]=d)}for(const[i,s]of Object.entries(r))i in n||(s.default!==void 0?n[i]=s.default:s.required&&N.error(`Required prop "${i}" is missing.`))}function kt(e,t){const r=new Set;customElements.define(e,class extends HTMLElement{template;instance;_connectionVersion=0;_isDisconnected=!1;_hasRendered=!1;_releaseFirstPresentation;_model;_observerFn;_renderAborted=!1;_pendingRender=null;_eventCleanup=null;constructor(){super(),this.template=document.createElement("template"),this.template.innerHTML=t.template}async connectedCallback(){const n=this,o=++this._connectionVersion;this._isDisconnected=!1,this._renderAborted=!1,this._pendingRender=null,!this._hasRendered&&!this._releaseFirstPresentation&&(this._releaseFirstPresentation=ge(this));try{await this.initializeConnection(n,o)}catch(l){if(o!==this._connectionVersion||this._isDisconnected)return;this.releaseFirstPresentation(),N.errorWithContext("Error during initialization",{componentName:e},l)}}async initializeConnection(n,o){if(r.add(this),!document.head.querySelector(`style#style-${e}`)){const m=document.createElement("style");m.id=`style-${e}`,m.textContent=t.style,document.head.appendChild(m)}if(n.instance&&this._model&&this._observerFn){const m=n.instance,g=ye(n);m.$parent=g,this._isDisconnected=!1,this._renderAborted=!1,this._pendingRender=null,this._model.addObserver(this._observerFn),m.props&&m.state&&be({ele:n,parent:g,props:m.props,state:m.state});return}const i=(t.type||"options")==="options",s=ye(n),c=this.template.cloneNode(!0);let a;if(t.deps){a={};const m=Object.entries(t.deps),g=await Promise.all(m.map(([,C])=>C()));for(let C=0;C<m.length;C++)a[m[C][0]]=g[C]}if(o!==this._connectionVersion||this._isDisconnected)return;const u=Ye(t.script,a),d={};let v=!1,A=-1,O;this._isDisconnected=!1,this._renderAborted=!1,this._pendingRender=null;const w=Ce(),P=(()=>{let m;return{promise:new Promise(C=>{m=C}),resolve:m}})();let f,h;const b=m=>{const g=J.plugins[m];if(!g||typeof g.setup!="function"){N.warnWithContext(`Plugin "${m}" not found or has no setup method`,{pluginName:m});return}try{const C=i&&h?h:f;return g.setup.call(C)}catch(C){N.errorWithContext(`Plugin "${m}" setup failed`,{pluginName:m},C);return}},_={};for(const[m,g]of Object.entries(J.modules))if(typeof g.attach=="function"){const C=g.attach.call({element:n,parent:s,core:{take:ue.take}});C&&(_[`$${m}`]=C)}const p=new Map,y=m=>{let g=p.get(m);return g||(g=`on${m.charAt(0).toUpperCase()}${m.slice(1)}`,p.set(m,g)),g},E=(m,...g)=>{const C=y(m);let M=s;for(;M;){const F=M.userContext;if(F){const H=F[C];typeof H=="function"&&H(...g)}else if(M.methods){const H=M.methods[C];typeof H=="function"&&H(...g)}M=M.$parent}},S={$refs:d,$parent:s,$emit:E,$take:b,..._},x=u(S),T=bt(x.state??{});f=T.state;const k=x.methods||{},D=x.props||{},R=x.events||[];let $=x.watchList||[];i&&(h=St([k,f])),be({ele:n,parent:s,props:D,state:f}),i&&h&&We(k,h);for(const m of Ve){const g=x[m];if(typeof g=="function"){const C=i&&h?Q(g,h):g;Ae(w,m,async()=>{const M=C();M instanceof Promise&&await M})}}this._model=T;const V=async()=>{if(this._isDisconnected)return;if(v){this._renderAborted=!0,this._pendingRender=V;return}const m=T.getStateVersion();if(A!==m){!this._hasRendered&&!this._releaseFirstPresentation&&(this._releaseFirstPresentation=ge(this)),v=!0,this._renderAborted=!1,n.instance&&(n.instance.isRendering=!0);try{const g=c.content.cloneNode(!0),C=Pt(g,n,d);if(await Fe(g,i&&h?h:f,d),C.remapRefs(),this._renderAborted||this._model!==T){this._pendingRender=V;return}const F=i&&h?h:f;if(await I("global","processed",F),await I(w,"processed"),this._renderAborted||this._model!==T){this._pendingRender=V;return}const H=T.flushChanges();Object.defineProperty(F,"changedPaths",{value:H,writable:!0,configurable:!0,enumerable:!1});const Z=!this._hasRendered;if(await I("global",Z?"beforeMount":"beforeUpdate",F),await I(w,Z?"beforeMount":"beforeUpdate",F),this._renderAborted||this._model!==T){delete F.changedPaths,this._pendingRender=V;return}C.commit(),i&&h?(at(h,g),this._eventCleanup&&this._eventCleanup(),this._eventCleanup=ct(h,R,g,d)):(lt(k,g),this._eventCleanup&&this._eventCleanup(),this._eventCleanup=ft(k,f,R,g,d)),ot(n,g,Z,t.structAttr),this._hasRendered=!0,this.releaseFirstPresentation(),Z||(await I("global","updated",F),await I(w,"updated",F)),delete F.changedPaths,A=m,n.instance&&(n.instance._lastRenderedStateVersion=A)}catch(g){this._model===T&&this.releaseFirstPresentation(),N.errorWithContext("Error during render",{componentName:e},g);return}finally{const g=i&&h?h:f;if(delete g.changedPaths,v=!1,n.instance&&(n.instance.isRendering=!1),this._pendingRender&&!this._isDisconnected){const C=this._pendingRender;this._pendingRender=null,requestAnimationFrame(()=>{this._isDisconnected||C().catch(M=>{N.errorWithContext("Error during pending render",{componentName:e},M)})})}}this._isDisconnected||this._model!==T||(O||(O=(async()=>{await I("global","mounted",i&&h?h:f),!(this._isDisconnected||this._model!==T)&&await I(w,"mounted")})()),await O,!(this._isDisconnected||this._model!==T)&&P.resolve())}};n.instance={element:n,template:c,state:f,userContext:i?h:void 0,props:D,methods:k,events:R,watchList:$,$refs:d,$parent:s,$emit:E,$take:b,readyPromise:P.promise,lifecycleRegistry:w,..._,isRendering:!1},this._observerFn=()=>{if(this._isDisconnected||$&&$.length>0&&!T.hasPendingChangesFor($))return;let m=s;for(;m;){if(m.isRendering)return;m=m.$parent}requestAnimationFrame(()=>{this._isDisconnected||V().catch(g=>{N.errorWithContext("Error during render (observer)",{componentName:e},g)})})},T.addObserver(this._observerFn),await I("global","created",i&&h?h:f),await I(w,"created"),!(this._isDisconnected||this._model!==T)&&await V()}releaseFirstPresentation(){this._releaseFirstPresentation?.(),this._releaseFirstPresentation=void 0}async disconnectedCallback(){const n=this,o=++this._connectionVersion;if(this._isDisconnected=!0,this._renderAborted=!0,this._pendingRender=null,this.releaseFirstPresentation(),r.delete(this),r.size===0&&document.head.querySelector(`style#style-${e}`)?.remove(),!n.instance)return;const l=n.instance;this._isDisconnected=!0,this._renderAborted=!0,this._pendingRender=null,this._model&&this._observerFn&&this._model.removeObserver(this._observerFn);const i=l.userContext||l.state;await I("global","beforeDestroy",i),await I(l.lifecycleRegistry,"beforeDestroy"),!(!this._isDisconnected||o!==this._connectionVersion)&&(Oe(this),this._eventCleanup&&(this._eventCleanup(),this._eventCleanup=null),await I("global","destroyed",i),await I(l.lifecycleRegistry,"destroyed"),!(!this._isDisconnected||o!==this._connectionVersion)&&(this._hasRendered=!1,this._model=void 0,this._observerFn=void 0,this._eventCleanup=null,n.instance=void 0))}})}let le=!1,Ee=!1,fe=[];function Ot(){Ee||(Ee=!0,!(typeof document>"u"||typeof HTMLElement>"u")&&(ut(),tt(),ht()))}function Le(...e){const t=e[0],r=e[1];if(Je(t)){if(!r){N.error("ComponentSource requires a component name when calling take()");return}kt(r,t);return}if(ee(t)||Qe(t)){const n={registerHook:(o,l)=>{Ae("global",o,l)},take:ue.take};try{t.install(n),ee(t)?J.plugins[t.name]=t:J.modules[t.name]=t}catch(o){N.errorWithContext("Failed to install extension",{name:t.name,type:ee(t)?"plugin":"module"},o)}return}N.error("Unknown extension type",t)}function Rt(){le||(le=!0,fe.forEach(e=>Le(...e)),fe=[],N.info("Core initialized"))}const ue=Object.assign(()=>{Ot(),Rt()},{take:(...t)=>{le?Le(...t):fe.push(t)}});exports.Core=ue;exports.LogLevel=ve;exports.logger=N;