ladrillosjs 2.0.0-rc.2 → 2.0.0-rc.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core.js +1 -1
- package/dist/index.js +1 -1
- package/dist/lazy.js +1 -1
- package/dist/shared-BgAD3IVo.js +2 -0
- package/dist/{shared-B9pKDD6k.js.map → shared-BgAD3IVo.js.map} +1 -1
- package/dist/shared-zqkjmWU9.js +2 -0
- package/dist/shared-zqkjmWU9.js.map +1 -0
- package/package.json +1 -1
- package/dist/shared-B9pKDD6k.js +0 -2
- package/dist/shared-DXb2n_kf.js +0 -2
- package/dist/shared-DXb2n_kf.js.map +0 -1
package/dist/core.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{$ as r,r as s,e}from"./shared-
|
|
1
|
+
import{$ as r,r as s,e}from"./shared-zqkjmWU9.js";import{E as o}from"./shared-zqkjmWU9.js";import{c as a}from"./shared-BgAD3IVo.js";const t={registerComponent:e,registerComponents:s,$use:r,configure:a};export{r as $use,o as ErrorCode,a as configure,t as default,e as registerComponent,s as registerComponents};
|
|
2
2
|
//# sourceMappingURL=core.js.map
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{l as a,a as s,b as e,c as o,d as r,$ as n,r as t,e as i,f as l}from"./shared-
|
|
1
|
+
import{l as a,a as s,b as e,c as o,d as r,$ as n,r as t,e as i,f as l}from"./shared-zqkjmWU9.js";import{E as m}from"./shared-zqkjmWU9.js";import{$ as d,a as p}from"./shared-DGGk2qBc.js";import{c as y}from"./shared-BgAD3IVo.js";const f=a=>l.loadLazyComponent(a),z={registerComponent:i,registerComponents:t,$use:n,$emit:p,$listen:d,loadLazyComponent:f,configure:y,lazyOnIdle:r,lazyOnVisible:o,lazyOnMedia:e,lazyOnInteraction:s,lazyOnDelay:a};export{p as $emit,d as $listen,n as $use,m as ErrorCode,y as configure,z as default,a as lazyOnDelay,r as lazyOnIdle,s as lazyOnInteraction,e as lazyOnMedia,o as lazyOnVisible,f as loadLazyComponent,i as registerComponent,t as registerComponents};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/lazy.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{h as a,i as e,j as s,l as n,d as o,a as y,b as l,c as t}from"./shared-
|
|
1
|
+
import{h as a,i as e,j as s,l as n,d as o,a as y,b as l,c as t}from"./shared-zqkjmWU9.js";export{a as defaultLazyStrategy,e as forceLoadLazyComponent,s as isLazyComponent,n as lazyOnDelay,o as lazyOnIdle,y as lazyOnInteraction,l as lazyOnMedia,t as lazyOnVisible};
|
|
2
2
|
//# sourceMappingURL=lazy.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared-
|
|
1
|
+
{"version":3,"file":"shared-BgAD3IVo.js","sources":["../src/core/configure.ts"],"sourcesContent":["/**\r\n * Framework-level configuration API for LadrillosJS.\r\n *\r\n * Exposed to consumers via `import { configure } from 'ladrillosjs'`.\r\n * All options are optional; unspecified keys retain their defaults.\r\n */\r\n\r\nimport { setCacheSize } from \"./component/cache\";\r\nimport {\r\n setErrorHandler,\r\n type LadrillosErrorHandler,\r\n} from \"../utils/devWarnings\";\r\n\r\n/**\r\n * Options accepted by `configure()`.\r\n */\r\nexport interface LadrillosConfig {\r\n /**\r\n * Maximum number of component source files retained in the LRU cache.\r\n * Defaults to 25. Must be a positive integer.\r\n */\r\n cacheSize?: number;\r\n\r\n /**\r\n * Custom error handler. Called in addition to the framework's built-in\r\n * console logging so embedders can route framework errors to telemetry.\r\n *\r\n * @example\r\n * configure({\r\n * onError: (err) => telemetry.capture(err),\r\n * });\r\n */\r\n onError?: LadrillosErrorHandler | null;\r\n}\r\n\r\n/**\r\n * Configure framework-level options.\r\n *\r\n * Safe to call at any time; subsequent calls override prior values. Pass\r\n * `onError: null` to clear a previously registered handler.\r\n */\r\nexport function configure(config: LadrillosConfig): void {\r\n if (config.cacheSize !== undefined) {\r\n setCacheSize(config.cacheSize);\r\n }\r\n if (config.onError !== undefined) {\r\n setErrorHandler(config.onError);\r\n }\r\n}\r\n"],"names":["configure","config","cacheSize","setCacheSize","onError","setErrorHandler"],"mappings":"gDAyCO,SAASA,EAAUC,QACC,IAArBA,EAAOC,WACTC,EAAaF,EAAOC,gBAEC,IAAnBD,EAAOG,SACTC,EAAgBJ,EAAOG,QAE3B"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{e,c as t,b as n}from"./shared-DGGk2qBc.js";const r=/{([^}]+)}/g,o=new DOMParser;async function s(e,t,n){const s=function(e){return o.parseFromString(e,"text/html")}(e),i=Array.from(s.querySelectorAll("script")),a=i.filter(e=>!e.src).map(e=>({content:(e.textContent??"").trim(),type:e.getAttribute("type")})).filter(e=>e.content.length>0),c=i.filter(e=>(e.getAttribute("src")||"").includes("html-proxy")&&"module"===e.getAttribute("type")),l=[...a,...(await Promise.all(c.map(async e=>{const t=e.getAttribute("src")||"";try{const e=await fetch(t);if(e.ok)return{content:(await e.text()).trim(),type:"module"}}catch(n){}return null}))).filter(e=>null!==e&&e.content.length>0)],u=i.filter(e=>{if(!e.src)return!1;const t=e.getAttribute("src")||"";return!t.includes("@vite/client")&&!t.includes("html-proxy")}).map(e=>{const t=e.getAttribute("type");let r=e.src;if(n)try{r=new URL(e.getAttribute("src")??e.src,n).toString()}catch{}return{src:r,type:t,external:e.hasAttribute("external")}}).filter(e=>e.src.length>0);i.forEach(e=>e.remove());const f=Array.from(s.querySelectorAll('link[rel="stylesheet"]')),p=f.map(e=>{let t=e.getAttribute("href")||"";const r=e.getAttribute("rel")||"stylesheet";if(n&&t&&!t.startsWith("http"))try{t=new URL(t,n).toString()}catch{}return{href:t,rel:r}}).filter(e=>e.href.length>0);f.forEach(e=>e.remove());const d=Array.from(s.querySelectorAll("style")),h=d.map(e=>e.textContent??"").join("\n").trim();d.forEach(e=>e.remove());const m=e=>e?Array.from(e.children).find(e=>"TEMPLATE"===e.tagName):void 0,g=m(s.body)??m(s.head);let _;if(g){const e=document.createElement("div");e.appendChild(g.content.cloneNode(!0)),_=e.innerHTML.trim()}else _=s.body.innerHTML.trim();const y=function(e){const t=/* @__PURE__ */new Set,n=function(e){const t=/* @__PURE__ */new Set,n=/<for\b[^>]*?\beach\s*=\s*["']([^"']+)["'][^>]*>/gi;let r;for(;null!==(r=n.exec(e));){const e=r[1].trim(),n=e.match(/^\(\s*([a-zA-Z_$][a-zA-Z0-9_$]*)\s*,\s*([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\)\s+in\s+/);if(n){t.add(n[1]),t.add(n[2]);continue}const o=e.match(/^([a-zA-Z_$][a-zA-Z0-9_$]*)\s+in\s+/);o&&t.add(o[1])}return t}(e),o=e.matchAll(r);for(const r of o){const e=r[1].trim().match(/^([a-zA-Z_$][a-zA-Z0-9_$]*)/);if(e){const r=e[1];["true","false","null","undefined","new","this","typeof","instanceof","void","delete","in","of","if","else","for","while","do","switch","case","break","continue","return","throw","try","catch","finally","function","class","const","let","var","Math","Date","JSON","Array","Object","String","Number","Boolean","console","window","document"].includes(r)||n.has(r)||t.add(r)}}return Array.from(t)}(_);return{tagName:t,template:_,scripts:l,externalScripts:u,externalStyles:p,styles:h,sourcePath:n,lazy:!1,templateBindings:y}}const i=/* @__PURE__ */new Map;let a=25;const c=e=>{if(!Number.isFinite(e)||e<1)throw new Error(`[LadrillosJS] configure({ cacheSize }) requires a positive integer, got ${e}`);for(a=Math.floor(e);i.size>a;){const e=i.keys().next().value;if(!e)break;i.delete(e)}},l=(e,t)=>{if(i.has(e))i.delete(e);else if(i.size>=a){const e=i.keys().next().value;e&&i.delete(e)}i.set(e,t)};async function u(e){if(!e)throw new Error("Path cannot be null or empty");const t=(e=>{const t=i.get(e);return t&&(i.delete(e),i.set(e,t)),t})(e);if(t)return{source:t,resolvedPath:e};try{const t=await async function(e){if(e.endsWith(".html")){const t=await fetch(e);return t.ok?{path:e,response:t}:null}const t=e.endsWith("/")?e.slice(0,-1):e,n=`${t}/index.html`;try{const e=await fetch(n);if(e.ok)return{path:n,response:e}}catch{}try{const e=await fetch(t);if(e.ok&&(e.headers.get("content-type")||"").includes("text/html"))return{path:t,response:e}}catch{}return null}(e);if(!t)throw new Error(`Failed to fetch component from ${e}: Could not resolve path. Tried: ${e}${e.endsWith(".html")?"":` and ${e}/index.html`}`);const n=await t.response.text();return l(e,n),t.path!==e&&l(t.path,n),{source:n,resolvedPath:t.path}}catch(n){return}}function f(e){const t=e.trim(),n=function(e){const t=function(e){let t=0,n=0,r=0,o=!1,s=!1,i=!1,a=!1;for(let c=0;c<e.length;c++){const l=e[c];if(a)a=!1;else if("\\"!==l)if(s||i||"'"!==l)if(o||i||'"'!==l)if(o||s||"`"!==l){if(!(o||s||i)&&("("===l?t++:")"===l?t=Math.max(0,t-1):"["===l?n++:"]"===l?n=Math.max(0,n-1):"{"===l?r++:"}"===l&&(r=Math.max(0,r-1)),"("===l&&0===t&&0===n&&0===r))return c}else i=!i;else s=!s;else o=!o;else a=!0}return-1}(e);if(t<0)return null;const n=function(e,t){let n=0,r=!1,o=!1,s=!1,i=!1;for(let a=t;a<e.length;a++){const t=e[a];if(i)i=!1;else if("\\"!==t)if(o||s||"'"!==t)if(r||s||'"'!==t)if(r||o||"`"!==t){if(!(r||o||s))if("("===t)n++;else if(")"===t){if(n--,0===n)return a;if(n<0)return-1}}else s=!s;else o=!o;else r=!r;else i=!0}return-1}(e,t);if(n<0)return null;if(0!==e.slice(n+1).trim().length)return null;const r=p(e.slice(0,t).trim());if(!r)return null;return{calleePath:r,args:function(e){const t=[];let n="",r=0,o=0,s=0,i=!1,a=!1,c=!1,l=!1;for(let f=0;f<e.length;f++){const u=e[f];if(l)n+=u,l=!1;else if("\\"!==u)if(a||c||"'"!==u)if(i||c||'"'!==u)if(i||a||"`"!==u){if(!i&&!a&&!c&&("("===u?r++:")"===u?r=Math.max(0,r-1):"["===u?o++:"]"===u?o=Math.max(0,o-1):"{"===u?s++:"}"===u&&(s=Math.max(0,s-1)),","===u&&0===r&&0===o&&0===s)){const e=n.trim();e.length>0&&t.push(e),n="";continue}n+=u}else c=!c,n+=u;else a=!a,n+=u;else i=!i,n+=u;else n+=u,l=!0}const u=n.trim();return u.length>0&&t.push(u),t}(e.slice(t+1,n))}}(t);if(n)return{raw:t,path:n.calleePath,isFunction:!0,isExpression:!0,functionArgs:n.args};const r=p(t);return r?{raw:t,path:r,isFunction:!1,isExpression:!1}:{raw:t,path:[],isExpression:!0}}function p(e){return/^[$A-Z_][0-9A-Z_$]*(?:\s*\.\s*[$A-Z_][0-9A-Z_$]*)*$/i.test(e)?e.split(".").map(e=>e.trim()).filter(e=>e.length>0):null}function d(e){let t=(Node,e.parentElement);for(;t;){if("FOR"===t.tagName)return!0;t=t.parentElement}return!1}function h(e){let t=e.parentElement;for(;t;){if(t.hasAttribute&&t.hasAttribute("$no:bind"))return!0;t=t.parentElement}return!1}const m=["onclick","ondblclick","onmousedown","onmouseup","onmouseover","onmouseout","onmousemove","onmouseenter","onmouseleave","onkeydown","onkeyup","onkeypress","onfocus","onblur","onchange","oninput","onsubmit","onreset","onscroll","onload","onerror","ontouchstart","ontouchmove","ontouchend","ontouchcancel","ondragstart","ondrag","ondragend","ondragenter","ondragleave","ondragover","ondrop"],g=Object.freeze(["alert","confirm","prompt","console","JSON","Math","Date","Array","Object","String","Number","Boolean","Map","Set","WeakMap","WeakSet","Symbol","BigInt","Promise","Proxy","Reflect","parseInt","parseFloat","isNaN","isFinite","Infinity","NaN","encodeURIComponent","decodeURIComponent","encodeURI","decodeURI","setTimeout","clearTimeout","setInterval","clearInterval","requestAnimationFrame","cancelAnimationFrame","requestIdleCallback","cancelIdleCallback","queueMicrotask","fetch","AbortController","AbortSignal","Headers","Request","Response","URL","URLSearchParams","navigator","location","history","localStorage","sessionStorage","crypto","document","window","globalThis","Element","HTMLElement","Event","CustomEvent","EventTarget","TextEncoder","TextDecoder","Blob","File","FileReader","FormData","Error","TypeError","RangeError","SyntaxError","ReferenceError","atob","btoa","structuredClone"]),_=Object.freeze([]),y=/* @__PURE__ */new Set(["with","eval","arguments","constructor","prototype","break","case","catch","continue","debugger","default","delete","do","else","finally","for","function","if","in","instanceof","new","return","switch","this","throw","try","typeof","var","void","while","class","const","enum","export","extends","import","super","implements","interface","let","package","private","protected","public","static","yield","null","true","false"]),b={enter:"Enter",tab:"Tab",esc:"Escape",escape:"Escape",space:" ",up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight",delete:"Delete",backspace:"Backspace",insert:"Insert",f1:"F1",f2:"F2",f3:"F3",f4:"F4",f5:"F5",f6:"F6",f7:"F7",f8:"F8",f9:"F9",f10:"F10",f11:"F11",f12:"F12",home:"Home",end:"End",pageup:"PageUp",pagedown:"PageDown"},v=["ctrl","alt","shift","meta"],w=["prevent","stop","self","once","passive","capture"],E={left:0,middle:1,right:2};function A(e){if(!e.startsWith("$on:"))return null;const t=e.slice(4).split(".");if(0===t.length||!t[0])return null;const n=t[0],r=t.slice(1),o={eventName:n,keyModifiers:[],systemModifiers:[],eventModifiers:[],mouseModifier:null,exact:!1};for(const s of r){const e=s.toLowerCase();"exact"!==e?w.includes(e)?o.eventModifiers.push(e):v.includes(e)?o.systemModifiers.push(e):e in E?o.mouseModifier=e:o.keyModifiers.push(e):o.exact=!0}return o}function $(e){const t={};return e.includes("passive")&&(t.passive=!0),e.includes("capture")&&(t.capture=!0),e.includes("once")&&(t.once=!0),t}function C(e,t){return function(n){if((!t.eventModifiers.includes("self")||n.target===n.currentTarget)&&(!(t.mouseModifier&&n instanceof MouseEvent)||function(e,t){return e.button===E[t]}(n,t.mouseModifier))&&(!(t.systemModifiers.length>0||t.exact)||!(n instanceof KeyboardEvent||n instanceof MouseEvent)||function(e,t,n){const r={ctrl:e.ctrlKey,alt:e.altKey,shift:e.shiftKey,meta:e.metaKey};for(const o of t)if(!r[o])return!1;if(n)for(const o of v)if(!t.includes(o)&&r[o])return!1;return!0}(n,t.systemModifiers,t.exact))){if(t.keyModifiers.length>0&&n instanceof KeyboardEvent){const e=t.keyModifiers.some(e=>function(e,t){const n=t.toLowerCase(),r=b[n];if(r)return e.key===r;if(1===n.length)return e.key.toLowerCase()===n;const o=n.split("-").map((e,t)=>0===t?e:e.charAt(0).toUpperCase()+e.slice(1)).join("");return e.key.toLowerCase()===n||e.key.toLowerCase()===o.toLowerCase()}(n,e));if(!e)return}t.eventModifiers.includes("prevent")&&n.preventDefault(),t.eventModifiers.includes("stop")&&n.stopPropagation(),e(n)}}}function S(e){return e.startsWith("$on:")}let R=null;var N=/* @__PURE__ */(e=>(e[e.EXPRESSION_EVAL_FAILED=101]="EXPRESSION_EVAL_FAILED",e[e.EXPRESSION_SYNTAX_ERROR=102]="EXPRESSION_SYNTAX_ERROR",e[e.EXPRESSION_UNDEFINED_VAR=103]="EXPRESSION_UNDEFINED_VAR",e[e.EXPRESSION_NULL_ACCESS=104]="EXPRESSION_NULL_ACCESS",e[e.SCRIPT_EXTRACT_FAILED=201]="SCRIPT_EXTRACT_FAILED",e[e.SCRIPT_EXECUTION_FAILED=202]="SCRIPT_EXECUTION_FAILED",e[e.EVENT_HANDLER_FAILED=301]="EVENT_HANDLER_FAILED",e[e.DIRECTIVE_ERROR=401]="DIRECTIVE_ERROR",e[e.LOOP_ERROR=402]="LOOP_ERROR",e[e.CONDITIONAL_ERROR=403]="CONDITIONAL_ERROR",e[e.COMPONENT_LOAD_FAILED=501]="COMPONENT_LOAD_FAILED",e[e.COMPONENT_NOT_FOUND=502]="COMPONENT_NOT_FOUND",e[e.MODULE_LOAD_FAILED=601]="MODULE_LOAD_FAILED",e[e.MODULE_EXECUTION_FAILED=602]="MODULE_EXECUTION_FAILED",e))(N||{});let x=null;function L(e){x=e}function T(e,t,n){const r=function(e,t){const n=function(e){const t=void 0!==e?e:R;if(!t)return"";const n=[];if(t.tagName&&n.push(`<${t.tagName}>`),t.sourcePath){const e=t.sourcePath.split("/").pop()||t.sourcePath;n.push(`(${e})`)}return n.length>0?` in ${n.join(" ")}`:""}(t);return`${e}${n}`}(e,t);"undefined"!=typeof window&&"undefined"!=typeof console&&console,function(e,t){if(x)try{const n=e instanceof Error?e:new Error(String(e));x(n,t??null)}catch{}}(n instanceof Error?n:new Error(r,void 0!==n?{cause:n}:void 0),t)}function I(e,t,n={}){var r;n.errorCode||(r=t)instanceof SyntaxError||r instanceof ReferenceError||r instanceof TypeError&&(r.message.includes("Cannot read properties of null")||r.message.includes("Cannot read properties of undefined")),function(e){if(e instanceof SyntaxError)return"Invalid expression syntax";if(e instanceof ReferenceError){const t=e.message.match(/(\w+) is not defined/);return t?`Undefined variable: "${t[1]}"`:"Undefined variable"}e instanceof TypeError&&(e.message.includes("Cannot read properties of null")||e.message.includes("Cannot read properties of undefined"))}(t)}const k=/* @__PURE__ */new Map,O=/* @__PURE__ */Symbol("reactive-array"),M=["push","pop","shift","unshift","splice","sort","reverse","fill","copyWithin"];function D(e,t){return e[O]?e:new Proxy(e,{get(e,n){if(n===O)return!0;const r=e[n];return"string"==typeof n&&M.includes(n)&&"function"==typeof r?(...n)=>{const o=n.map(e=>Array.isArray(e)?D(e,t):e),s=r.apply(e,o);return t(),s}:Array.isArray(r)?D(r,t):r},set(e,n,r){const o="string"==typeof n?parseInt(n,10):NaN,s=!isNaN(o),i="length"===n,a=Array.isArray(r)?D(r,t):r;return e[n]===a||(e[n]=a,(s||i)&&t()),!0},deleteProperty(e,n){const r=delete e[n];return r&&t(),r}})}function P(e,t){for(const n of Object.keys(e)){const r=e[n];Array.isArray(r)?e[n]=D(r,t):r&&"object"==typeof r&&!Array.isArray(r)&&P(r,t)}return e}function F(e,t,n,r){const o=function(e,t){const n=/* @__PURE__ */new Map;for(const r of t)n.set(r,/* @__PURE__ */new Set);for(const r of e)for(const e of r.bindings)for(const o of t)j(e.raw,o)&&n.get(o).add(r);return n}(t,Object.keys(e));P(e,()=>{r&&r()});const s=new Proxy(e,{get:(e,t)=>e[t],set(e,s,i){const a=!(s in e);if(!a&&e[s]===i)return!0;const c=Array.isArray(i)?D(i,()=>{r&&r()}):i;return e[s]=c,a&&function(e,t,n){n.set(e,/* @__PURE__ */new Set);for(const r of t)for(const t of r.bindings)j(t.raw,e)&&n.get(e).add(r)}(s,t,o),e.__suspendReactivity||((e,t)=>{const s=o.get(e);if(s)for(const r of s)n(r,t);r&&r()})(s,e),!0}});return s}function j(e,t){const n=function(e){let t=k.get(e);if(!t){const n=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");t=new RegExp(`\\b${n}\\b`),k.set(e,t)}return t}(t);return n.test(e)}function U(e,t){return e.startsWith("http://")||e.startsWith("https://")||e.startsWith("/")?e.startsWith("/")?new URL(e,window.location.origin).href:e:new URL(e,t).href}function z(e){return{registerComponent:function(t,n,r=!0,o=!1){const s=U(n,e);return wt.registerComponent(t,s,r,o)},registerComponents:function(t){const n=Array.isArray(t)?t.map(t=>({...t,path:U(t.path,e)})):Object.entries(t).map(([t,n])=>"string"==typeof n?{name:t,path:U(n,e)}:{name:t,...n,path:U(n.path,e)});return wt.registerComponents(n)},$use:function(t,n=!0,r=!1){const o=function(e){return(e.split("/").pop()?.replace(/\.[^.]+$/,"")||e).replace(/([a-z])([A-Z])/g,"$1-$2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1-$2").toLowerCase()}(t),s=U(t,e);return wt.registerComponent(o,s,n,r)}}}const W=["registerComponent","registerComponents","$use"],B=z(window.location.href),H=B.registerComponent,Z=B.registerComponents,q=B.$use,X=e=>e instanceof ShadowRoot?e.host:e;function V(e,t,n,r){const o=Array.from(e.querySelectorAll("*"));for(const s of o)if(!J(s)){for(const e of m){const o=s.getAttribute(e);if(o){s.removeAttribute(e);const i=e.slice(2),a=Y(o,t,n,r);a&&s.addEventListener(i,a)}}G(s,t,n,r)}}function G(e,t,n,r){const o=Array.from(e.attributes).filter(e=>S(e.name));for(const s of o){const o=A(s.name);if(!o)continue;const i=s.value;e.removeAttribute(s.name);const a=Y(i,t,n,r);if(!a)continue;const c=C(a,o),l=$(o.eventModifiers);e.addEventListener(o.eventName,c,l)}}function J(e){if(e.hasAttribute("$for")||"FOR"===e.tagName)return!0;let t=e.parentElement;for(;t;){if(t.hasAttribute("$for")||"FOR"===t.tagName)return!0;t=t.parentElement}return!1}function Y(e,t,n,r){try{const o=r?.__componentUrl,s=r?.__componentId,i=oe(o,s),a=re(),c=["event","state","$refs",...a,...i.keys],l=Object.keys(t),u=l.filter(e=>"function"==typeof t[e]),f=l.filter(e=>"function"!=typeof t[e]),p=!0===t.__hasModuleScripts,d=f.length>0?`let { ${f.join(", ")} } = state;`:"",h=p&&u.length>0?`const { ${u.join(", ")} } = state;`:"",m=function(e,t){if(!e||0===t.length)return e;const n=[];let r=e.replace(/"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'/g,e=>(n.push(e),`__STRING_PLACEHOLDER_${n.length-1}__`));r=r.replace(/`(?:[^`\\$]|\\.|\$(?!\{)|\$\{[^}]*\})*`/g,e=>e.replace(/\$\{([^}]+)\}/g,(e,n)=>{let r=n;for(const o of t){const e=new RegExp(`(?<![^.]\\.)(?<!state\\.)\\b${ne(o)}\\b(?!\\s*[:(])`,"g");r=r.replace(e,`state.${o}`)}return`\${${r}}`}));for(const s of t){const e=new RegExp(`(?<![^.]\\.)(?<!state\\.)\\b${ne(s)}\\b(?!\\s*[:(])`,"g");r=r.replace(e,`state.${s}`)}let o=r;for(let s=0;s<n.length;s++)o=o.replace(`__STRING_PLACEHOLDER_${s}__`,n[s]);return o}(K(n,p?u:[]),f),g=f.some(t=>new RegExp(`\\b${t}\\b`).test(e))?f.filter(t=>new RegExp(`\\b${t}\\b`).test(e)).map(e=>`state.${e} = ${e};`).join(" "):"",_=/\bawait\b/.test(e)||/\bawait\b/.test(m)||/\basync\b/.test(m),y=o||"ladrillos-event-handler",b=_?`"use strict"; ${d} ${h} ${m} try { await (async () => { ${e} })(); } finally { ${g} }\n//# sourceURL=${y}`:`"use strict"; ${d} ${h} ${m} ${e}; ${g}\n//# sourceURL=${y}`,v=Object.getPrototypeOf(async function(){}).constructor,w=_?new v(...c,b):new Function(...c,b);return e=>{try{const n=[e,t,r&&r.__refs||/* @__PURE__ */new Map,...a.map(()=>{}),...i.values],o=w(...n);o&&"function"==typeof o.catch&&o.catch(e=>{r?.tagName?.toLowerCase(),I(0,e,{errorCode:N.EVENT_HANDLER_FAILED})})}catch(n){r?.tagName?.toLowerCase(),I(0,n,{errorCode:N.EVENT_HANDLER_FAILED})}}}catch(o){return r?.tagName&&r.tagName.toLowerCase(),null}}function K(e,t=[]){const n=[],r=/(?:async\s+)?function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\([^)]*\)\s*\{/g;let o;for(;null!==(o=r.exec(e));){if(t.includes(o[1]))continue;const r=Q(e,o.index);r&&n.push(r)}const s=/(?:const|let)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=\s*(?:async\s*)?\([^)]*\)\s*=>\s*\{/g;for(;null!==(o=s.exec(e));){if(t.includes(o[1]))continue;const r=o.index,s=e.indexOf("{",r+o[0].length-1),i=Q(e,r,s);i&&n.push(i)}return n.map(e=>e.trim()).join(";\n")+(n.length>0?";":"")}function Q(e,t,n){let r=0,o=t,s=!1,i="",a=!1;for(let c=n??t;c<e.length;c++){const t=e[c];if('"'!==t&&"'"!==t&&"`"!==t||"\\"===(c>0?e[c-1]:"")||(s?t===i&&(s=!1):(s=!0,i=t)),!s&&("{"===t&&(r++,a=!0),"}"===t&&r--,a&&0===r&&"}"===t)){o=c+1;break}}return 0!==r?null:e.slice(t,o)}function ee(e,t,n,r,o,s,i=[]){try{const a=te(e),c=`\n "use strict";\n ${function(e,t){if(0===t.length)return e;const n=[];let r=e.replace(/(["'])(?:(?!\1)[^\\]|\\.)*\1/g,e=>(n.push(e),`__STRING_PLACEHOLDER_${n.length-1}__`));r=r.replace(/`(?:[^`\\$]|\\.|\$(?!\{)|\$\{[^}]*\})*`/g,e=>e.replace(/\$\{([^}]+)\}/g,(e,n)=>{let r=n;for(const o of t){const e=new RegExp(`(?<![^.]\\.)(?<!__state__\\.)\\b${ne(o)}\\b(?!\\s*[:(])`,"g");r=r.replace(e,`__state__.${o}`)}return`\${${r}}`}));for(const s of t){const e=new RegExp(`\\b(let|const|var)\\s+(${ne(s)})\\s*=`,"g");r=r.replace(e,`__state__.${s} ??=`)}for(const s of t){const e=new RegExp(`(?<![^.]\\.)(?<!__state__\\.)\\b${ne(s)}\\b(?!\\s*[:(])`,"g");r=r.replace(e,`__state__.${s}`)}let o=r;for(let s=0;s<n.length;s++)o=o.replace(`__STRING_PLACEHOLDER_${s}__`,n[s]);return o}(e,[.../* @__PURE__ */new Set([...a,...i])])}\n//# sourceURL=${n||"ladrillos-component"}\n `,l=oe(n,r),u=re(),f=["__state__","$host","$refs",...u,...l.keys],p=[t,o,s,...u.map(()=>{}),...l.values];new Function(...f,c)(...p)}catch(a){}}function te(e){const t=[],n=/(?:let|const|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=/g;let r;for(;null!==(r=n.exec(e));)t.push(r[1]);return t}function ne(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function re(){return _.filter(e=>!y.has(e))}function oe(n,r){const o=[],s=[];for(const e of g)e in globalThis&&(o.push(e),s.push(globalThis[e]));const i=z(n||window.location.href);o.push(...W),s.push(i.registerComponent,i.registerComponents,i.$use);const a=t(r||"anonymous");return o.push(...e),s.push(a.$emit,a.$listen),{keys:o,values:s}}function se(e,t){try{const n=Object.keys(t),r=Object.values(t),o=re(),s=[...o,...n],i=[...o.map(()=>{}),...r];return new Function(...s,`"use strict"; return ${e};`)(...i)}catch(n){return I(0,n,{}),`{${e}}`}}function ie(e,t){let n=e.original;for(const r of e.bindings){const e=se(r.raw,t),o=String(e??"");n=n.replace(`{${r.raw}}`,o)}if(e.isAttribute&&e.attributeName){const t=e.element??e.node.parentElement;t&&t.setAttribute(e.attributeName,n)}else e.node.textContent=n}function ae(e,t){for(const n of e)ie(n,t)}const ce=/* @__PURE__ */new Map,le=/* @__PURE__ */new Map,ue=/(?:import|export)\s+(?:[\s\S]*?\s+from\s+)?['"]([^'"]+)['"]/g,fe=/import\s*\(\s*['"]([^'"]+)['"]\s*\)/g,pe=[".ts",".tsx",".mts"];function de(e){return e.startsWith("./")||e.startsWith("../")}function he(e){return pe.some(t=>e.endsWith(t))}function me(e){return!(e.startsWith("/")||e.startsWith("./")||e.startsWith("../")||e.startsWith("http://")||e.startsWith("https://")||e.startsWith("data:")||e.startsWith("blob:"))}const ge=/^(?:export\s+)?(?:let|const|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)/gm,_e=["$emit","$listen","$refs","registerComponent","registerComponents","$use"];async function ye(e,t,n){if(e.external)return document.querySelector(`script[src="${e.src}"]`)?Promise.resolve(void 0):new Promise((t,n)=>{const r=document.createElement("script");r.src=e.src,e.type&&(r.type=e.type),r.onload=()=>t(void 0),r.onerror=t=>n(new Error(`Failed to load external script: ${e.src}`)),document.head.appendChild(r)});if("module"!==e.type)return document.querySelector(`script[src="${e.src}"]`)?Promise.resolve(void 0):new Promise((t,n)=>{const r=document.createElement("script");r.src=e.src,e.type&&(r.type=e.type),r.onload=()=>t(void 0),r.onerror=t=>n(new Error(`Failed to load script: ${e.src}`)),document.head.appendChild(r)});try{const r=await fetch(e.src);if(!r.ok)throw new Error(`Failed to fetch module: ${e.src}`);const o=function(e,t){let n=e;const r=[],o=[];return n=n.replace(ue,(e,n)=>{if(de(n)){const r=new URL(n,t).href;return he(n)&&o.push(n),e.replace(n,r)}return me(n)&&r.push(n),e}),n=n.replace(fe,(e,n)=>{if(de(n)){const e=new URL(n,t).href;return he(n)&&o.push(n),`import("${e}")`}return me(n)&&r.push(n),e}),n}(await r.text(),e.src),s=function(e){const t=function(e){const t=[];let n;for(ge.lastIndex=0;null!==(n=ge.exec(e));)t.push(n[1]);const r=/^(?:export\s+)?function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)/gm;for(;null!==(n=r.exec(e));)t.includes(n[1])||t.push(n[1]);return t}(e),n=/* @__PURE__ */new Set,r=/export\s+(?:let|const|var|function)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)/g;let o;for(;null!==(o=r.exec(e));)n.add(o[1]);const s=/export\s*\{([^}]+)\}/g;for(;null!==(o=s.exec(e));)o[1].split(",").map(e=>e.trim().split(/\s+as\s+/)[0].trim()).forEach(e=>n.add(e));const i=t.filter(e=>!n.has(e));return 0===i.length?e:`${e}\nexport { ${i.join(", ")} };`}(function(e){const t=[];let n=e;if(n=n.replace(/import\s*\{([^}]+)\}\s*from\s*(['"][^'"]+['"])\s*;?/g,(e,n,r)=>{const o=n.split(",").map(e=>e.trim()),s=[];for(const i of o){if(!i)continue;const e=i.match(/^(\w+)\s+as\s+(\w+)$/);if(e){const[,n,r]=e,o=`__raw_${r}`;s.push(`${n} as ${o}`),t.push(`const ${r} = __wrapReactiveArray(${o}, __ladrillos_componentId);`)}else{const e=`__raw_${i}`;s.push(`${i} as ${e}`),t.push(`const ${i} = __wrapReactiveArray(${e}, __ladrillos_componentId);`)}}return`import { ${s.join(", ")} } from ${r};`}),t.length>0){const e=n.split("\n");let r=-1;for(let t=0;t<e.length;t++){const n=e[t].trim();(n.startsWith("import ")||n.startsWith("import{"))&&(r=t)}r>=0&&(e.splice(r+1,0,"","// === Reactive Import Wrappers ===",...t,"// === End Reactive Import Wrappers ===",""),n=e.join("\n"))}return n}(o)),i=function(e){const t=/* @__PURE__ */new Set;for(const n of _e){const r=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");new RegExp(`(?:^|[\\s,{])${r}(?:\\s+as\\b|[\\s,}=;(])|\\b(?:let|const|var|function)\\s+${r}\\b`,"m").test(e)&&t.add(n)}return t}(o),a=function(e,t,n=/* @__PURE__ */new Set){const r=(e,t)=>n.has(e)?"":t;return`\n// === LadrillosJS Framework Helpers (auto-injected) ===\nconst __ladrillos_componentId = "${e||"anonymous"}";\nconst __ladrillos_componentUrl = "${t||"unknown"}";\n\n// Global event bus (shared across all components)\nif (!globalThis.__ladrillosEventBus) {\n globalThis.__ladrillosEventBus = {\n listeners: new Map(),\n componentListeners: new Map()\n };\n}\n\n// Global state change callbacks (for reactive array updates)\nif (!globalThis.__ladrillosStateCallbacks) {\n globalThis.__ladrillosStateCallbacks = new Map();\n}\n\n// Reactive array symbol\nconst __REACTIVE_ARRAY = Symbol.for("ladrillos-reactive-array");\n\n// Array mutation methods to intercept\nconst __ARRAY_METHODS = ["push", "pop", "shift", "unshift", "splice", "sort", "reverse", "fill", "copyWithin"];\n\n// Wrap an array in a reactive proxy\nconst __wrapReactiveArray = (arr, componentId) => {\n if (!Array.isArray(arr) || arr[__REACTIVE_ARRAY]) return arr;\n \n const onMutate = () => {\n const callback = globalThis.__ladrillosStateCallbacks?.get(componentId);\n if (callback) callback();\n };\n \n return new Proxy(arr, {\n get(target, key) {\n if (key === __REACTIVE_ARRAY) return true;\n const value = target[key];\n if (typeof key === "string" && __ARRAY_METHODS.includes(key) && typeof value === "function") {\n return (...args) => {\n const result = value.apply(target, args);\n onMutate();\n return result;\n };\n }\n if (Array.isArray(value)) return __wrapReactiveArray(value, componentId);\n return value;\n },\n set(target, key, value) {\n const index = parseInt(key, 10);\n const isIndex = !isNaN(index);\n const isLength = key === "length";\n target[key] = Array.isArray(value) ? __wrapReactiveArray(value, componentId) : value;\n if (isIndex || isLength) onMutate();\n return true;\n }\n });\n};\n\nconst __ladrillos_emit = (eventName, data) => {\n const listeners = globalThis.__ladrillosEventBus.listeners.get(eventName);\n if (!listeners || listeners.size === 0) return;\n for (const registration of listeners) {\n try {\n registration.callback(data);\n } catch (error) {\n console.error(\`[LadrillosJS] Error in event listener for "\${eventName}":\`, error);\n }\n }\n};\n${r("$emit","const $emit = __ladrillos_emit;")}\n\nconst __ladrillos_listen = (eventName, callback) => {\n const bus = globalThis.__ladrillosEventBus;\n let listeners = bus.listeners.get(eventName);\n if (!listeners) {\n listeners = new Set();\n bus.listeners.set(eventName, listeners);\n }\n const registration = { callback, componentId: __ladrillos_componentId };\n listeners.add(registration);\n\n // Track by component ID for cleanup\n let componentRegs = bus.componentListeners.get(__ladrillos_componentId);\n if (!componentRegs) {\n componentRegs = new Set();\n bus.componentListeners.set(__ladrillos_componentId, componentRegs);\n }\n componentRegs.add({ event: eventName, registration });\n\n // Return unsubscribe function\n return () => {\n listeners?.delete(registration);\n if (listeners?.size === 0) bus.listeners.delete(eventName);\n const compRegs = bus.componentListeners.get(__ladrillos_componentId);\n if (compRegs) {\n for (const reg of compRegs) {\n if (reg.registration === registration) {\n compRegs.delete(reg);\n break;\n }\n }\n if (compRegs.size === 0) bus.componentListeners.delete(__ladrillos_componentId);\n }\n };\n};\n${r("$listen","const $listen = __ladrillos_listen;")}\n\n// Global refs registry (shared across all components)\n// Each component gets its own Map, keyed by component ID\nif (!globalThis.__ladrillosRefs) {\n globalThis.__ladrillosRefs = new Map();\n}\n\n// Helper to wrap refs Map in Proxy for cleaner dot notation access\nconst __createRefsProxy = (map) => new Proxy(map, {\n get(target, prop, receiver) {\n if (prop in target) {\n const value = Reflect.get(target, prop, receiver);\n return typeof value === "function" ? value.bind(target) : value;\n }\n if (typeof prop === "string") return target.get(prop);\n return undefined;\n },\n set(target, prop, value) {\n if (typeof prop === "string") { target.set(prop, value); return true; }\n return false;\n },\n has(target, prop) {\n return typeof prop === "string" ? target.has(prop) || prop in target : prop in target;\n }\n});\n\n// Get or create refs Map for this component (wrapped in Proxy)\nif (!globalThis.__ladrillosRefs.has(__ladrillos_componentId)) {\n globalThis.__ladrillosRefs.set(__ladrillos_componentId, __createRefsProxy(new Map()));\n}\n\n// $refs for this component - supports both $refs.inputEl and $refs.get("inputEl")\nconst __ladrillos_refs = globalThis.__ladrillosRefs.get(__ladrillos_componentId);\n${r("$refs","const $refs = __ladrillos_refs;")}\n\n// Helper to resolve relative paths against component URL\nconst __resolvePath = (path) => {\n if (path.startsWith("http://") || path.startsWith("https://") || path.startsWith("/")) {\n return path.startsWith("/") ? new URL(path, window.location.origin).href : path;\n }\n return new URL(path, __ladrillos_componentUrl).href;\n};\n\n// Helper to convert filename to tag name\nconst __filenameToTagName = (path) => {\n const filename = path.split("/").pop()?.replace(/\\.[^.]+$/, "") || path;\n return filename.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/[_\\s]+/g, "-").toLowerCase();\n};\n\n// registerComponent - Register a child component\nconst __ladrillos_registerComponent = async (name, path, useShadowDOM = true) => {\n const resolvedPath = __resolvePath(path);\n return globalThis.ladrillosjs.registerComponent({ name, path: resolvedPath, useShadowDOM });\n};\n${r("registerComponent","const registerComponent = __ladrillos_registerComponent;")}\n\n// registerComponents - Register multiple components at once\nconst __ladrillos_registerComponents = async (configs) => {\n const resolvedConfigs = configs.map(config => ({\n ...config,\n path: __resolvePath(config.path)\n }));\n return globalThis.ladrillosjs.registerComponents(resolvedConfigs);\n};\n${r("registerComponents","const registerComponents = __ladrillos_registerComponents;")}\n\n// $use - Shorthand for registerComponent with auto-derived tag name\nconst __ladrillos_use = async (path, useShadowDOM = true) => {\n const tagName = __filenameToTagName(path);\n return __ladrillos_registerComponent(tagName, path, useShadowDOM);\n};\n${r("$use","const $use = __ladrillos_use;")}\n\n// === End Framework Helpers ===\n\n`}(t,n||e.src,i),c=new Blob([a+s],{type:"text/javascript"}),l=URL.createObjectURL(c);try{return await(0,eval)(`import("${l}")`)}finally{URL.revokeObjectURL(l)}}catch(r){throw r}}const be=/* @__PURE__ */new Map;async function ve(e){if(le.has(e))return le.get(e);const t=(async()=>{try{return await(0,eval)(`import("${e}")`)}catch(t){throw t}})();return le.set(e,t),t}function we(e,t){return t&&Array.isArray(e)?D(e,t):e}async function Ee(n,r,o,s,i,a,c){if("module"!==n.type)throw new Error('executeModuleScriptWithReactivity only handles type="module" scripts');const l=n.content,u=await async function(e,t,n){const r=function(e){const t=[],n=/import\s+(?:(\{[^}]+\})|(\*\s+as\s+\w+)|(\w+)(?:\s*,\s*(\{[^}]+\}))?)?\s*(?:from\s+)?['"]([^'"]+)['"]/g;let r;for(;null!==(r=n.exec(e));){const[e,n,o,s,i,a]=r,c={statement:e,specifier:a,imports:[],isDefault:!1,isNamespace:!1,isSideEffect:!1};if(n||o||s||(c.isSideEffect=!0),s&&(c.isDefault=!0,c.imports.push({imported:"default",local:s})),o){c.isNamespace=!0;const e=o.replace(/\*\s+as\s+/,"").trim();c.imports.push({imported:"*",local:e})}const l=n||i;if(l){const e=l.slice(1,-1).split(",").map(e=>e.trim()).filter(Boolean);for(const t of e){const e=t.match(/(\w+)\s+as\s+(\w+)/);c.imports.push(e?{imported:e[1],local:e[2]}:{imported:t,local:t})}}t.push(c)}return t}(e),o={};for(const i of r){if(i.isSideEffect){const e=de(i.specifier)?new URL(i.specifier,t).href:i.specifier;await ve(e);continue}const e=de(i.specifier)?new URL(i.specifier,t).href:i.specifier;try{const t=await ve(e);for(const e of i.imports){let r;r="*"===e.imported?t:"default"===e.imported?t.default:t[e.imported],o[e.local]=we(r,n)}}catch(s){}}return o}(l,r,a),f=function(e){return e.replace(/import\s+(?:(?:\{[^}]+\}|\*\s+as\s+\w+|\w+)(?:\s*,\s*\{[^}]+\})?\s+from\s+)?['"][^'"]+['"]\s*;?/g,"").trim()}(l),{variables:p,functions:d}=function(e){const t=[],n=[],r=e.replace(/`[^`]*`/g,e=>" ".repeat(e.length)).replace(/"(?:[^"\\]|\\.)*"/g,e=>" ".repeat(e.length)).replace(/'(?:[^'\\]|\\.)*'/g,e=>" ".repeat(e.length)).replace(/\/\*[\s\S]*?\*\//g,e=>" ".repeat(e.length)).replace(/\/\/[^\n]*/g,e=>" ".repeat(e.length));let o=0,s=0;for(;s<r.length;){const e=r[s];if("{"!==e)if("}"!==e){if(0===o){const e=r.slice(s).match(/^(?:async\s+)?function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(e){n.push(e[1]),s+=e[0].length;continue}const o=r.slice(s).match(/^(?:let|const|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=/);if(o){t.push(o[1]),s+=o[0].length;continue}}s++}else o--,s++;else o++,s++}return{variables:t,functions:n}}(f),h=function(e,t){if(0===t.length)return e;const n=[];let r=e.replace(/(["'`])(?:(?!\1)[^\\]|\\.)*\1/g,e=>(n.push(e),`__STRING_PLACEHOLDER_${n.length-1}__`));for(const s of t){const e=new RegExp(`\\b(let|const|var)\\s+(${Ae(s)})\\s*=`,"g");r=r.replace(e,`__state__.${s} =`)}for(const s of t){const e=new RegExp(`(?<![^.]\\.)(?<!__state__\\.)\\b${Ae(s)}\\b(?!\\s*[:(])`,"g");r=r.replace(e,`__state__.${s}`)}let o=r;for(let s=0;s<n.length;s++)o=o.replace(`__STRING_PLACEHOLDER_${s}__`,n[s]);return o}(f,p),m=Object.keys(u),g=Object.values(u),_=`\n "use strict";\n return (async () => {\n ${h}\n ${d.length>0?`return { ${d.join(", ")} };`:"return {};"}\n })();\n `;try{const n=["console","alert","Math","JSON","Date","Array","Object","String","Number","Boolean","Promise","setTimeout","setInterval","clearTimeout","clearInterval"],a=n.map(e=>globalThis[e]),l=["$refs","__state__","$host"],u=[s||/* @__PURE__ */new Map,i||{},c],f=z(r),p=[f.registerComponent,f.registerComponents,f.$use],d=t(o||"anonymous"),h=[d.$emit,d.$listen],y={...globalThis.ladrillosjs||{},registerComponent:f.registerComponent,registerComponents:f.registerComponents},b={registerComponent:f.registerComponent,registerComponents:f.registerComponents,$use:f.$use,$emit:d.$emit,$listen:d.$listen,ladrillosjs:y},v=new Set(m),w=[...m],E=m.map((e,t)=>e in b?b[e]:g[t]),A=(e,t)=>{for(let n=0;n<e.length;n++){const r=e[n];v.has(r)||(v.add(r),w.push(r),E.push(t[n]))}};A(n,a),A(W,p),A(e,h),A(l,u),A(["ladrillosjs"],[y]);const $=new Function(...w,_),C=await $(...E);return{...i||{},...C||{}}}catch(y){throw y}}function Ae(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}const $e="$bind",Ce="$ref",Se=/([\s\S]*?)\s+(?:in|of)\s+([\s\S]+)$/,Re=/,([^,\}\]]*)(?:,([^,\}\]]*))?$/,Ne=/^\(|\)$/g;function xe(e){return e.replace(/\$/g,"\\$")}const Le=globalThis.requestIdleCallback||(e=>setTimeout(e,1)),Te=globalThis.cancelIdleCallback||(e=>clearTimeout(e)),Ie=(e=1e4)=>t=>{const n=Le(t,{timeout:e});return()=>Te(n)},ke=e=>(t,n)=>{if(function(e){const{top:t,left:n,bottom:r,right:o}=e.getBoundingClientRect(),{innerHeight:s,innerWidth:i}=window;return(t>0&&t<s||r>0&&r<s)&&(n>0&&n<i||o>0&&o<i)}(n))return void t();const r=new IntersectionObserver(e=>{for(const n of e)if(n.isIntersecting){r.disconnect(),t();break}},e);return r.observe(n),()=>r.disconnect()},Oe=e=>t=>{if(!e)return void t();const n=matchMedia(e);if(n.matches)return void t();const r=()=>t();return n.addEventListener("change",r,{once:!0}),()=>n.removeEventListener("change",r)},Me=(e=["click","focusin"])=>{const t="string"==typeof e?[e]:e;return(e,n)=>{let r=!1;const o=t=>{r||(r=!0,s(),e(),queueMicrotask(()=>{t.target&&t.target instanceof Element&&t.target.dispatchEvent(new t.constructor(t.type,t))}))},s=()=>{for(const e of t)n.removeEventListener(e,o)};for(const i of t)n.addEventListener(i,o,{once:!0,passive:!0});return s}},De=(e=0)=>t=>{const n=setTimeout(t,e);return()=>clearTimeout(n)},Pe=ke({rootMargin:"100px"});function Fe(e){const t=e.querySelector(':scope > template[slot="placeholder"]');return t?(t.remove(),t.content.cloneNode(!0)):null}function je(e){const t=e.parentNode;if(!t)return;const n=function(e){if(e.hasAttribute("eager"))return null;if(e.hasAttribute("interaction")){const t=(e.getAttribute("interaction")||"").trim();if(!t)return Me();const n=t.split(",").map(e=>e.trim()).filter(Boolean);return Me(1===n.length?n[0]:n)}if(e.hasAttribute("media")){const t=e.getAttribute("media")||"";return Oe(t)}if(e.hasAttribute("delay")){const t=Number(e.getAttribute("delay"))||0;return De(t)}if(e.hasAttribute("idle")||e.hasAttribute("idle-timeout")){const t=e.getAttribute("idle-timeout");return t?Ie(Number(t)||1e4):Ie()}const t={},n=e.getAttribute("margin");n&&(t.rootMargin=n);const r=e.getAttribute("threshold");if(null!==r){const e=Number(r);Number.isNaN(e)||(t.threshold=e)}return Object.keys(t).length>0?ke(t):Pe}(e),r=e.getAttribute("src"),o=e.getAttribute("component"),s=/* @__PURE__ */new Set(["eager","visible","margin","threshold","idle","idle-timeout","delay","interaction","media","src","component"]),i=document.createComment(r?` <lazy src="${r}"> `:" <lazy> ");if(t.insertBefore(i,e),e.remove(),r){const t=(o||(a=r,(a.split(/[?#]/)[0].split("/").pop()?.replace(/\.[^.]+$/,"")||a).replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/[_\s]+/g,"-").toLowerCase())).trim();if(!t.includes("-"))return;const c=Fe(e),l=()=>{const n=document.createElement(t);for(const t of Array.from(e.attributes))s.has(t.name)||n.setAttribute(t.name,t.value);i.parentNode?.replaceChild(n,i)};let u=null;c&&(u=document.createComment(" /lazy-placeholder "),i.parentNode?.insertBefore(u,i.nextSibling),i.parentNode?.insertBefore(c,u));const f=async()=>{try{if(customElements.get(t)||await async function(e,t){return(await Promise.resolve().then(()=>Et)).ladrillos.registerComponent(e,t,!0,!1)}(t,r),u){let e=i.nextSibling;for(;e&&e!==u;){const t=e.nextSibling;e.parentNode?.removeChild(e),e=t}u.parentNode?.removeChild(u)}l()}catch(e){}};if(!n)return void f();const p=document.createElement("span");let d;p.setAttribute("data-lazy-sentinel",""),p.style.cssText="display:inline-block;width:0;height:0;padding:0;margin:0;border:0;",i.parentNode?.insertBefore(p,i.nextSibling);const h=()=>{d?.(),p.remove(),f()};return void(d=n(h,p))}var a;const c=Fe(e),l=document.createDocumentFragment();for(;e.firstChild;)l.appendChild(e.firstChild);const u=document.createComment(" /lazy ");i.parentNode?.insertBefore(u,i.nextSibling),c&&i.parentNode?.insertBefore(c,u);const f=()=>{let e=i.nextSibling;for(;e&&e!==u;){const t=e.nextSibling;e.parentNode?.removeChild(e),e=t}u.parentNode?.insertBefore(l,u)};if(!n)return void f();const p=document.createElement("span");let d;p.setAttribute("data-lazy-sentinel",""),p.style.cssText="display:inline-block;width:0;height:0;padding:0;margin:0;border:0;",i.parentNode?.insertBefore(p,i.nextSibling),d=n(()=>{d?.(),p.remove(),f()},p)}function Ue(e){let t=e.parentElement;for(;t;){if("FOR"===t.tagName)return!0;t=t.parentElement}return!1}function ze(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(null===e||null===t)return e===t;if("object"!=typeof e)return e===t;const n=e,r=t,o=Object.keys(n),s=Object.keys(r);if(o.length!==s.length)return!1;for(const i of o)if(n[i]!==r[i])return!1;return!0}function We(e){const t=e.trim();return t.startsWith("{")&&t.endsWith("}")?t.slice(1,-1).trim():t}function Be(e){const t=[];for(const r of Array.from(e.childNodes))(r.nodeType!==Node.TEXT_NODE||r.textContent?.trim())&&t.push(r);if(0===t.length)return null;if(1===t.length&&t[0].nodeType===Node.ELEMENT_NODE)return t[0];const n=document.createElement("span");n.style.display="contents";for(const r of Array.from(e.childNodes))n.appendChild(r);return n}function He(e){let t=e.parentElement;for(;t;){if("FOR"===t.tagName)return!0;t=t.parentElement}return!1}function Ze(e){const t=e.match(Se);if(!t)return null;let n,[,r,o]=t;r=r.trim(),o=o.trim();const s=o.match(/\s+track\s+by\s+(.+)$/i);s&&(n=s[1].trim(),o=o.slice(0,s.index).trim());const i=r.replace(Ne,"").trim(),a=i.match(Re);let c,l,u;return a?(c=i.replace(Re,"").trim(),l=a[1]?.trim(),u=a[2]?.trim()):c=i,{item:c,index:l||u,key:n,array:o}}function qe(e,t,n,r,o,s){return e.removeAttribute("condition"),e.style.display="contents",{element:e,condition:t,type:n,placeholder:r,group:[],originalParent:o,nextSibling:s}}function Xe(e,t){return He(e)}function Ve(e,t,n){const r=n(e.arrayName,t);if(!r||null==(o=r)||!Array.isArray(o)&&"function"!=typeof o[Symbol.iterator]&&"object"!=typeof o){for(const t of e.renderedElements)t.remove();return e.renderedElements=[],void(e.previousItems=[])}var o;const s=Array.from(r),i=e.previousItems||[],a=e.renderedElements;e.keyGetter||(e.keyGetter=function(e,t){if(!e)return(e,t)=>t;const n=e.startsWith(t+".")?e.slice(t.length+1).split("."):e.split(".");return e=>{let t=e;for(const r of n){if(null==t)return;t=t[r]}return t}}(e.keyAttribute,e.itemName));const c=(r,o)=>{const s=e.template.cloneNode(!0);return Ye(s,Ge(t,e,r,o),n),s};if(e.keyAttribute){const r=function(e,t,n){const r=[],o=/* @__PURE__ */new Map,s=/* @__PURE__ */new Map;for(let f=0;f<e.length;f++)o.set(n(e[f],f),f);for(let f=0;f<t.length;f++)s.set(n(t[f],f),f);const i=/* @__PURE__ */new Set;for(let f=0;f<e.length;f++){const t=n(e[f],f);s.has(t)||r.push({type:"remove",oldIndex:f,key:t,item:e[f]})}for(let f=0;f<t.length;f++){const e=n(t[f],f);o.has(e)||(r.push({type:"insert",newIndex:f,key:e,item:t[f]}),i.add(f))}const a=[];for(let f=0;f<e.length;f++){const t=n(e[f],f),r=s.get(t);void 0!==r&&a.push(r)}const c=function(e){if(0===e.length)return[];const t=e.length,n=new Array(t).fill(1),r=new Array(t).fill(-1);let o=1,s=0;for(let c=1;c<t;c++){for(let t=0;t<c;t++)e[t]<e[c]&&n[t]+1>n[c]&&(n[c]=n[t]+1,r[c]=t);n[c]>o&&(o=n[c],s=c)}const i=[];let a=s;for(;-1!==a;)i.unshift(a),a=r[a];return i}(a),l=new Set(c.map(e=>a[e]));let u=0;for(const f of a){for(;u<e.length&&!s.has(n(e[u],u));)u++;if(u<e.length){const t=n(e[u],u),o=u,i=s.get(t);l.has(i)||r.push({type:"move",oldIndex:o,newIndex:i,key:t,item:e[o]}),u++}}for(let f=0;f<t.length;f++){const s=n(t[f],f),i=o.get(s);if(void 0!==i){const n=t[f];ze(e[i],n)||r.push({type:"update",oldIndex:i,newIndex:f,key:s,item:n})}}return r}(i,s,e.keyGetter),o=/* @__PURE__ */new Map;for(let t=0;t<i.length;t++){const n=e.keyGetter(i[t],t);a[t]&&o.set(n,a[t])}const l=new Array(s.length);for(const e of r)if("remove"===e.type&&void 0!==e.key){const t=o.get(e.key);t&&(t.remove(),o.delete(e.key))}for(let i=0;i<s.length;i++){const r=s[i],a=e.keyGetter(r,i),u=o.get(a);u?(Je(u,Ge(t,e,r,i),n),l[i]=u):l[i]=c(r,i)}const u=document.createDocumentFragment();for(const e of l)u.appendChild(e);e.placeholder.parentNode?.insertBefore(u,e.placeholder.nextSibling),e.renderedElements=l}else{const r=Math.min(i.length,s.length);for(let i=0;i<r;i++){const r=Ge(t,e,s[i],i);Je(a[i],r,n)}for(let e=s.length;e<i.length;e++)a[e]?.remove();const o=document.createDocumentFragment();for(let e=i.length;e<s.length;e++){const t=c(s[e],e);o.appendChild(t),a[e]=t}if(o.childNodes.length>0){const t=a[r-1]?.nextSibling||e.placeholder.nextSibling;e.placeholder.parentNode?.insertBefore(o,t)}e.renderedElements=a.slice(0,s.length)}e.previousItems=[...s]}function Ge(e,t,n,r){const o=e.__scriptContent,s={...e,[t.itemName]:n,__reactiveState__:e,__scriptContent__:o||"",__componentUrl__:e.__componentUrl||""};return t.indexName&&(s[t.indexName]=r),s}function Je(e,t,n){const r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);let o;for(;o=r.nextNode();){const e=o.__originalTemplate;e&&(o.textContent=e.replace(/\{([^}]+)\}/g,(e,r)=>{const o=n(r.trim(),t);return String(o??"")}))}for(const s of Array.from(e.attributes)){const e=s.__originalTemplate;e&&(s.value=e.replace(/\{([^}]+)\}/g,(e,r)=>{const o=n(r.trim(),t);return null!==o&&"object"==typeof o?JSON.stringify(o):String(o??"")}))}for(const s of Array.from(e.children))Je(s,t,n)}function Ye(e,t,n){for(const i of Array.from(e.attributes))if(i.value.includes("{")){i.__originalTemplate=i.value;const e=i.value.replace(/\{([^}]+)\}/g,(e,r)=>{const o=n(r.trim(),t);return null!==o&&"object"==typeof o?JSON.stringify(o):String(o??"")});i.value=e}!function(e,t){for(const n of m){const r=e.getAttribute(n);if(r){e.removeAttribute(n);const o=n.slice(2),s=Ke(r,t);s&&e.addEventListener(o,s)}}!function(e,t){const n=Array.from(e.attributes).filter(e=>S(e.name));for(const r of n){const n=A(r.name);if(!n)continue;const o=r.value;e.removeAttribute(r.name);const s=Ke(o,t);if(!s)continue;const i=C(s,n),a=$(n.eventModifiers);e.addEventListener(n.eventName,i,a)}}(e,t)}(e,t);const r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),o=[];let s;for(;s=r.nextNode();)s.textContent?.includes("{")&&o.push(s);for(const i of o)i.__originalTemplate=i.textContent,i.textContent=i.textContent.replace(/\{([^}]+)\}/g,(e,r)=>{const o=n(r.trim(),t);return String(o??"")});for(const i of Array.from(e.children))Ye(i,t,n)}function Ke(e,n){try{const r=n.__reactiveState__,o=n.__scriptContent__||"",s=Object.keys(n).filter(e=>!e.startsWith("__")),i=r?Object.keys(r).filter(e=>!e.startsWith("__")&&"function"!=typeof r[e]):[],a=s.filter(e=>!i.includes(e)&&"function"!=typeof n[e]),c=o.trim().length>0,l=s.filter(e=>"function"==typeof n[e]),u=r&&!0===r.__hasModuleScripts;let f="",p="";u?p=l.length>0?`const { ${l.join(", ")} } = context;`:"":c?f=K(o,[]):p=l.length>0?`const { ${l.join(", ")} } = context;`:"";const d=a.length>0?`const { ${a.join(", ")} } = context;`:"",h=r&&i.length>0?"reactiveState":"context",m=i.length>0?`let { ${i.join(", ")} } = ${h};`:"",g=!u&&r&&i.length>0?i.map(e=>`reactiveState.${e} = ${e};`).join(" "):"",_=t(n.__componentId__||r?.__componentId||"anonymous"),y=new Function("event","context","reactiveState","$emit","$listen",`"use strict";\n ${d}\n ${m}\n ${p}\n ${f}\n ${e};\n ${g}`);return t=>{try{y(t,n,r,_.$emit,_.$listen)}catch(o){T(`Error in loop event handler: ${e}`,null,o)}}}catch(r){return null}}function Qe(e,t,n){for(const r of e)r.element.parentNode&&r.element.remove();for(const r of e){let e=!1;if("else"===r.type)e=!0;else{const o=n(r.condition,t);e=Boolean(o)}if(e){r.placeholder.parentNode?.insertBefore(r.element,r.placeholder.nextSibling);break}}}function et(e,t,n,r){const o=e.element,{raw:s,path:i,isContentEditable:a}=e,c=n(s,t);tt(o,c,a);const l=i[0];r.has(l)||r.set(l,[]),r.get(l).push({element:o,path:i,isContentEditable:a}),s===l||r.has(s)||r.set(s,[]),s!==l&&r.get(s).push({element:o,path:i,isContentEditable:a});const u=function(e){if(e instanceof HTMLSelectElement)return"change";if(e instanceof HTMLInputElement){const t=e.type.toLowerCase();if("checkbox"===t||"radio"===t)return"change"}return"input"}(o);let f=!1;o.__isUpdatingFromState=()=>f,o.__setUpdatingFromState=e=>{f=e},o.addEventListener(u,()=>{if(f)return;const e=function(e,t){if(t)return e.textContent||"";if(e instanceof HTMLInputElement){const t=e.type.toLowerCase();return"checkbox"===t?e.checked:"number"===t||"range"===t?e.valueAsNumber:e.value}return e instanceof HTMLSelectElement?e.multiple?Array.from(e.selectedOptions).map(e=>e.value):e.value:e instanceof HTMLTextAreaElement?e.value:e.value??""}(o,a);!function(e,t,n){let r=e;for(let o=0;o<t.length-1;o++){const e=t[o];e in r&&"object"==typeof r[e]||(r[e]={}),r=r[e]}r[t[t.length-1]]=n}(t,i,e)})}function tt(e,t,n){if(n)e.textContent=String(t??"");else{if(e instanceof HTMLInputElement)return void("checkbox"===e.type.toLowerCase()?e.checked=Boolean(t):e.value=String(t??""));e.value=e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement?String(t??""):t}}const nt=[],rt=/* @__PURE__ */new Set;let ot=!1,st=!1,it=0;const at=Promise.resolve();function ct(){st=!1,ot=!0,nt.sort((e,t)=>(e.id??0)-(t.id??0));try{for(const t of nt)if(!1!==t.active)try{t()}catch(e){T("Error in scheduled update",null,e)}}finally{nt.length=0,rt.clear(),ot=!1}}const lt=/* @__PURE__ */new Map;function ut(e,t){const{tagName:o,template:s,scripts:i,externalScripts:a,externalStyles:c,styles:l,sourcePath:u,templateBindings:p=[]}=e,m=te(i.map(e=>e.content).join("\n")),g=[.../* @__PURE__ */new Set([...m,...p])];class _ extends HTMLElement{static get observedAttributes(){return g}state={};_root=null;_initialized=!1;_componentId=`${o}-${Math.random().toString(36).slice(2)}`;_directives=null;_evaluator=null;_updateBoundInputs=null;constructor(){super()}async connectedCallback(){if(this._initialized)return;this._initialized=!0,R={tagName:o,sourcePath:u,instanceId:this._componentId};const e=this.innerHTML,n=document.createDocumentFragment();for(;this.firstChild;)n.appendChild(this.firstChild);this.__originalHTML=e,this.__originalChildren=n,this._root=t?this.shadowRoot??this.attachShadow({mode:"open"}):this;const{bindings:m}=((e,t)=>{const n=document.createElement("template");n.innerHTML=t,e.innerHTML="",e.appendChild(n.content);const o=function(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null);let o;for(;o=n.nextNode();){if(d(o)||h(o))continue;const e=o.textContent;if(!e)continue;const n=[...e.matchAll(r)];if(n.length>0){const r=e,s=n.map(e=>f(e[1].trim()));t.push({node:o,bindings:s,original:r})}}const s=function(e){const t=[],n=["$bind","$ref","$no:bind","condition","each","key","track-by"],o=Array.from(e.querySelectorAll("*"));for(const s of o)if("FOR"!==s.tagName&&!d(s)&&!s.hasAttribute("$no:bind")&&!h(s))for(const e of Array.from(s.attributes)){if(n.includes(e.name))continue;const o=[...e.value.matchAll(r)];if(o.length>0){const n=document.createTextNode(e.value),r=o.map(e=>f(e[1].trim()));t.push({node:n,bindings:r,original:e.value,isAttribute:!0,attributeName:e.name,element:s})}}return t}(e);return t.push(...s),t}(e);return{bindings:o}})(this._root,s);((e,t,n)=>{if(!t)return;const r=document.createElement("style");r.textContent=t,n?e.appendChild(r):document.head.appendChild(r)})(this._root,l,t);const g=this._getAttributeOverrides(),_=i.filter(e=>"module"!==e.type),y=i.some(e=>"module"===e.type),b=new Proxy(/* @__PURE__ */new Map,{get(e,t,n){if(t in e){const r=Reflect.get(e,t,n);return"function"==typeof r?r.bind(e):r}if("string"==typeof t)return e.get(t)},set:(e,t,n)=>"string"==typeof t&&(e.set(t,n),!0),has:(e,t)=>"string"==typeof t&&e.has(t)||t in e});if(function(e,t){const n=Array.from(e.querySelectorAll(`[${xe(Ce)}]`));for(const r of n){const e=r.getAttribute(Ce);e&&t.set(e,r)}}(this._root,b),c&&c.length>0&&await async function(e,t,n){for(const o of e)if(n&&t)try{let e=be.get(o.href);if(!e){const t=await fetch(o.href);if(!t.ok)continue;e=await t.text(),be.set(o.href,e)}const n=document.createElement("style");n.textContent=e,n.setAttribute("data-external-href",o.href),t.insertBefore(n,t.firstChild)}catch(r){}else{if(document.querySelector(`link[href="${o.href}"]`))continue;await new Promise(e=>{const t=document.createElement("link");t.rel=o.rel||"stylesheet",t.href=o.href,t.onload=()=>e(),t.onerror=()=>{e()},document.head.appendChild(t)})}}(c,this._root,t),a.length>0&&await async function(e){const t=e.filter(e=>e.external);for(const r of t)try{await ye(r)}catch(n){}}(a),this.state=await async function(e,t,n,r={},o,s=!1,i,a,c,l=[]){const u=X(e),f={},p=t.map(e=>e.content).join("\n");for(const[h,m]of Object.entries(r))f[h]=m;f.__scriptContent=p,f.__componentUrl=i,f.__componentId=a;const d=F(f,n,(e,t)=>ie(e,t),o);for(const h of t)ee(h.content,d,i,a,u,c,l);return u.__state=d,u.__scriptContent=p,u.__componentUrl=i,u.__componentId=a,s||(V(e,d,p,u),ae(n,d)),d}(this._root,_,m,g,()=>this._updateDirectives(),y,u,this._componentId,b,p),"undefined"!=typeof globalThis&&(globalThis.__ladrillosStateCallbacks||(globalThis.__ladrillosStateCallbacks=/* @__PURE__ */new Map),globalThis.__ladrillosStateCallbacks.set(this._componentId,()=>this._updateDirectives())),u){this.state.__suspendReactivity=!0;try{const e=await async function(e,t,n,r,o,s,i,a){const c={},l=e.filter(e=>"module"===e.type),u=t.filter(e=>"module"===e.type),f=t.filter(e=>"module"!==e.type);for(const d of f)try{await ye(d,r,n)}catch(p){}for(const d of u)try{const e=await ye(d,r,n);if(e&&"object"==typeof e)for(const[t,n]of Object.entries(e))"default"!==t&&(c[t]=n,s&&(s[t]=n))}catch(p){}for(const d of l)try{const e=await Ee(d,n,r,o,s,i,a);Object.assign(c,e)}catch(p){}return c}(i,a,u,this._componentId,b,this.state,()=>this._updateDirectives(),this);(y||a.length>0)&&(this.state.__hasModuleScripts=!0);for(const[t,n]of Object.entries(e))"function"==typeof n&&(this.state[t]=n)}finally{this.state.__suspendReactivity=!1}}if(y&&function(e,t,n){const r=X(e);V(e,n,r.__scriptContent||"",r),ae(t,n)}(this._root,m,this.state),this._evaluator=se,this._directives=function(e,t){const n={loops:[],conditionals:[],twoWayBindings:[],refs:t,showElements:[]};return function(e,t){const n=Array.from(e.querySelectorAll(`[${xe(Ce)}]`));for(const r of n){const e=r.getAttribute(Ce);e&&(t.refs.set(e,r),r.removeAttribute(Ce))}}(e,n),function(e,t){const n=Array.from(e.querySelectorAll("for"));for(const r of n){if(!r.isConnected)continue;if(He(r))continue;const n=r.getAttribute("each")||r.getAttribute("of")||"";if(!n)continue;let o=Ze(n);if(!o)continue;const s=r.getAttribute("key")||r.getAttribute("track-by")||o.key,i=Be(r);if(!i)continue;const a=document.createComment(` <for> ${n} `),c=r.parentElement||e;c.insertBefore(a,r),r.remove(),t.loops.push({template:i,expression:n,itemName:o.item,indexName:o.index,arrayName:o.array,keyAttribute:s,placeholder:a,renderedElements:[],originalParent:c})}}(e,n),function(e,t){const n=Array.from(e.querySelectorAll("show"));for(const r of n){if(!r.isConnected)continue;if(He(r))continue;const e=We(r.getAttribute("condition")||""),n=r;n.style.display="contents",t.showElements.push({element:n,expression:e,originalDisplay:"contents"}),r.removeAttribute("condition")}}(e,n),function(e,t){const n=Array.from(e.querySelectorAll(`[${xe($e)}]`));for(const r of n){const e=r.getAttribute($e);if(!e)continue;if(Xe(r))continue;const n=e.split("."),o=r.hasAttribute("contenteditable");t.twoWayBindings.push({element:r,path:n,raw:e,isContentEditable:o}),r.removeAttribute($e)}}(e,n),function(e,t){const n=Array.from(e.querySelectorAll("if"));for(const r of n){if(He(r))continue;const n=[],o=We(r.getAttribute("condition")||""),s=document.createComment(` <if> ${o} `),i=r.parentElement||e,a=r.nextSibling;i.insertBefore(s,r),n.push(qe(r,o,"if",s,i,a));let c=r.nextElementSibling;for(;c;){const e=c.tagName;if("ELSE-IF"!==e){if("ELSE"===e){n.push(qe(c,"","else",s,i,c.nextSibling)),c.remove();break}break}{const e=We(c.getAttribute("condition")||""),t=c.nextElementSibling;n.push(qe(c,e,"else-if",s,i,c.nextSibling)),c.remove(),c=t}}r.remove();for(const e of n)e.group=n;t.conditionals.push(n)}}(e,n),function(e){const t=Array.from(e.querySelectorAll("lazy"));for(const n of t)Ue(n)||je(n)}(e),n}(this._root,b),"undefined"!=typeof globalThis){globalThis.__ladrillosRefs||(globalThis.__ladrillosRefs=/* @__PURE__ */new Map);let e=globalThis.__ladrillosRefs.get(this._componentId);e||(e=/* @__PURE__ */new Map,globalThis.__ladrillosRefs.set(this._componentId,e));for(const[t,n]of this._directives.refs)e.set(t,n)}this.refs=this._directives.refs,this.__refs=this._directives.refs,this._updateDirectives(),this._directives.twoWayBindings.length>0&&(this._updateBoundInputs=function(e,t,n){const r=/* @__PURE__ */new Map;for(const o of e)et(o,t,n,r);return e=>{!function(e,t,n,r){const o=r?[r]:Array.from(e.keys());for(const s of o){const r=e.get(s);if(r)for(const e of r){const{element:r,path:o,isContentEditable:s}=e,i=n(o.join("."),t),a=r.__setUpdatingFromState;a&&a(!0),tt(r,i,s),a&&queueMicrotask(()=>a(!1))}}}(r,t,n,e)}}(this._directives.twoWayBindings,this.state,this._evaluator)),this.dispatchEvent(new CustomEvent("ladrillos:ready",{bubbles:!0,composed:!0,detail:{state:this.state,refs:this._directives.refs}}))}disconnectedCallback(){!function(e){const t=ce.get(e);if(t){for(const e of t)URL.revokeObjectURL(e);ce.delete(e)}}(this._componentId),n(this._componentId),function(e){const t=lt.get(e);t&&(t.active=!1,lt.delete(e))}(this._componentId),"undefined"!=typeof globalThis&&globalThis.__ladrillosStateCallbacks?.delete(this._componentId),this._initialized=!1}attributeChangedCallback(e,t,n){if(t===n)return;if(!this._initialized)return;const r=this._parseAttributeValue(n);this.state[e]=r}adoptedCallback(){}_updateDirectives(){this._directives&&this._evaluator&&function(e,t){let n=lt.get(e);n||(n=function(){const e=()=>{t()};return e.id=++it,e.active=!0,e}(),lt.set(e,n)),function(e){void 0===e.id&&(e.id=++it),rt.has(e.id)||(rt.add(e.id),nt.push(e),ot||st||(st=!0,at.then(ct)))}(n)}(this._componentId,()=>{this._performDirectiveUpdates()})}_performDirectiveUpdates(){this._directives&&this._evaluator&&(this._directives.loops.length>0&&function(e,t,n){for(const r of e)Ve(r,t,n)}(this._directives.loops,this.state,this._evaluator),this._directives.conditionals.length>0&&function(e,t,n){for(const r of e)Qe(r,t,n)}(this._directives.conditionals,this.state,this._evaluator),this._directives.showElements.length>0&&function(e,t,n){for(const r of e){const e=n(r.expression,t),o=Boolean(e);r.element.style.display=o?r.originalDisplay:"none"}}(this._directives.showElements,this.state,this._evaluator),this._updateBoundInputs&&this._updateBoundInputs())}_getAttributeOverrides(){const e={},t=[];for(const r of Array.from(this.attributes))this._isReservedAttribute(r.name)?r.value&&""!==r.value.trim()&&t.push(r.name):e[r.name]=this._parseAttributeValue(r.value);const n=t.filter(e=>!p.includes(e));return n.length>0&&n.map(e=>{const t={title:"heading",class:"className",style:"customStyle",id:"componentId",hidden:"isHidden"}[e]||`my${e.charAt(0).toUpperCase()}${e.slice(1)}`;return`"${e}" → try "${t}"`}),e}_isReservedAttribute(e){return!p.includes(e)&&(["id","class","style","slot","part","is","tabindex","title","lang","dir","hidden","draggable","contenteditable"].includes(e.toLowerCase())||e.startsWith("data-"))}_parseAttributeValue(e){if(null===e)return null;if(""===e)return!0;if("true"===e)return!0;if("false"===e)return!1;const t=Number(e);if(!isNaN(t)&&""!==e.trim())return t;try{const t=e.trim();if(t.startsWith("[")||t.startsWith("{"))return JSON.parse(t)}catch{}return e}get root(){return this._root}}return _}function ft(e,t){const{tagName:n}=e;if(!customElements.get(n)){const r=ut(e,t);customElements.define(n,r)}}const pt=/* @__PURE__ */new Map;let dt;const ht=/* @__PURE__ */new Map,mt=/* @__PURE__ */new Set,gt=/* @__PURE__ */new Map;function _t(e,t,n,r){var o;gt.set(e,{name:e,absolutePath:t,useShadowDOM:n,strategy:r}),customElements.get(e)||customElements.define(e,(o=e,class extends HTMLElement{teardown;isLoading=!1;isUpgraded=!1;connectedCallback(){if(this.hasAttribute("eager"))return void this.triggerLoad();const e=gt.get(o);e?this.teardown=e.strategy(()=>this.triggerLoad(),this):this.triggerLoad()}disconnectedCallback(){this.teardown?.(),this.teardown=void 0}async triggerLoad(){if(!this.isLoading&&!this.isUpgraded){this.isLoading=!0,this.teardown?.(),this.teardown=void 0;try{const e=await yt(o);this.isUpgraded=!0,this.upgradeToRealComponent(e)}catch(e){T(`Failed to load lazy component "<${o}>"`,{tagName:o}),this.isLoading=!1}}}upgradeToRealComponent(e){const t=document.createElement(e);for(const n of Array.from(this.attributes))"eager"!==n.name&&"tabindex"!==n.name&&t.setAttribute(n.name,n.value);for(;this.firstChild;)t.appendChild(this.firstChild);this.parentNode?this.parentNode.replaceChild(t,this):T("No parent node for placeholder - cannot upgrade lazy component",{tagName:o})}}))}async function yt(e){const t=function(e){return`${e}--loaded`}(e);if(mt.has(e))return t;if(pt.has(e))return await pt.get(e),t;const n=gt.get(e);if(!n)throw new Error(`Lazy component "${e}" not registered`);const r=(async()=>{const r=await u(n.absolutePath);if(!r)throw new Error(`Failed to fetch component source for "${e}"`);const o=await s(r.source,e,r.resolvedPath);dt[e]=o;const i=ut(o,n.useShadowDOM);return customElements.get(t)||customElements.define(t,i),mt.add(e),ht.set(e,{component:o,useShadowDOM:n.useShadowDOM}),o})();pt.set(e,r);try{return await r,t}finally{pt.delete(e)}}function bt(e){return gt.has(e)||mt.has(e)}async function vt(e){return gt.has(e)&&await yt(e),dt[e]}const wt=new class{components;constructor(){this.components={},dt=this.components}async registerComponent(e,t,n=!0,r=!1){if(this.components[e])return;const o=new URL(t,window.location.href).href;if(r)_t(e,o,n,!0===r?Pe:r);else try{const t=await u(o);if(!t)throw new Error(`Failed to fetch component source from ${o}`);const r=await s(t.source,e,t.resolvedPath);this.components[e]=r,ft(r,n)}catch(i){T(`Error registering component "<${e}>"`,{tagName:e,sourcePath:t},i)}}async registerComponents(e){const t=Array.isArray(e)?e:Object.entries(e).map(([e,t])=>"string"==typeof t?{name:e,path:t}:{name:e,...t}),n={success:[],failed:[],skipped:[]},r=[],o=[];for(const s of t){if(this.components[s.name]){n.skipped.push(s.name);continue}const e=new URL(s.path,window.location.href).href,t={...s,absolutePath:e};s.lazy?r.push(t):o.push(t)}for(const s of r)try{_t(s.name,s.absolutePath,s.useShadowDOM??!0,!0===s.lazy?Pe:s.lazy),n.success.push(s.name)}catch(c){n.failed.push({name:s.name,error:c instanceof Error?c:new Error(String(c))})}if(0===o.length)return n;const i=await Promise.allSettled(o.map(async e=>({config:e,result:await u(e.absolutePath)}))),a=await Promise.allSettled(i.map(async(e,t)=>{if("rejected"===e.status)throw e.reason;const{config:n,result:r}=e.value;if(!r)throw new Error(`Failed to fetch component source from ${n.absolutePath}`);return{config:n,component:await s(r.source,n.name,r.resolvedPath)}}));for(let s=0;s<a.length;s++){const e=a[s],t=o[s];if("rejected"===e.status){n.failed.push({name:t.name,error:e.reason instanceof Error?e.reason:new Error(String(e.reason))}),T(`Error registering component "${t.name}"`,{tagName:t.name,sourcePath:t.path},e.reason);continue}const{component:r}=e.value,i=t.useShadowDOM??!0;this.components[t.name]=r;try{ft(r,i),n.success.push(t.name)}catch(c){n.failed.push({name:t.name,error:c instanceof Error?c:new Error(String(c))}),delete this.components[t.name]}}return n}async loadLazyComponent(e){return vt(e)}},Et=/* @__PURE__ */Object.freeze(/* @__PURE__ */Object.defineProperty({__proto__:null,ladrillos:wt},Symbol.toStringTag,{value:"Module"}));export{q as $,N as E,Me as a,Oe as b,ke as c,Ie as d,H as e,wt as f,L as g,Pe as h,vt as i,bt as j,De as l,Z as r,c as s};
|
|
2
|
+
//# sourceMappingURL=shared-zqkjmWU9.js.map
|