ladrillosjs 2.0.0-beta.5.1 → 2.0.0-beta.6
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/README.md +8 -0
- package/dist/core.d.ts +14 -0
- package/dist/core.js +1 -0
- package/dist/events.d.ts +20 -0
- package/dist/events.js +1 -0
- package/dist/index.js +1 -1
- package/dist/lazy.d.ts +17 -0
- package/dist/lazy.js +1 -0
- package/dist/shared-DGGk2qBc.js +1 -0
- package/dist/shared-Dru_qCE_.js +1 -0
- package/package.json +21 -4
package/README.md
CHANGED
|
@@ -406,6 +406,14 @@ await registerComponents([
|
|
|
406
406
|
| `lazyOnMedia` | Mobile/desktop specific components |
|
|
407
407
|
| `lazyOnDelay` | Chat widgets, notifications |
|
|
408
408
|
|
|
409
|
+
### Eager Override
|
|
410
|
+
|
|
411
|
+
Force a lazy component to load immediately by adding the `eager` attribute:
|
|
412
|
+
|
|
413
|
+
```html
|
|
414
|
+
<lazy-footer eager></lazy-footer>
|
|
415
|
+
```
|
|
416
|
+
|
|
409
417
|
---
|
|
410
418
|
|
|
411
419
|
## 📋 API Reference
|
package/dist/core.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ComponentConfig, RegisterComponentsResult } from './core/ladrillos';
|
|
2
|
+
import { $registerComponent, $registerComponents, $use } from './core/helpers/frameworkHelpers';
|
|
3
|
+
export type { ComponentConfig, RegisterComponentsResult };
|
|
4
|
+
export declare const registerComponent: (name: string, path: string, useShadowDOM?: boolean) => Promise<void>;
|
|
5
|
+
export declare const registerComponents: (configs: ComponentConfig[] | Record<string, string | Omit<ComponentConfig, "name">>) => Promise<RegisterComponentsResult>;
|
|
6
|
+
export { $registerComponent, $registerComponents, $use };
|
|
7
|
+
declare const _default: {
|
|
8
|
+
registerComponent: (name: string, path: string, useShadowDOM?: boolean) => Promise<void>;
|
|
9
|
+
registerComponents: (configs: ComponentConfig[] | Record<string, string | Omit<ComponentConfig, "name">>) => Promise<RegisterComponentsResult>;
|
|
10
|
+
$registerComponent: (name: string, path: string, useShadowDOM?: boolean) => Promise<void>;
|
|
11
|
+
$registerComponents: (configs: ComponentConfig[] | Record<string, string | Omit<ComponentConfig, "name">>) => Promise<RegisterComponentsResult>;
|
|
12
|
+
$use: (path: string, useShadowDOM?: boolean) => Promise<void>;
|
|
13
|
+
};
|
|
14
|
+
export default _default;
|
package/dist/core.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{l as e,$ as s,f as o,g as r}from"./shared-Dru_qCE_.js";const t=(s,o,r)=>e.registerComponent(s,o,r,!1),n=s=>e.registerComponents(s),m={registerComponent:t,registerComponents:n,$registerComponent:r,$registerComponents:o,$use:s};export{r as $registerComponent,o as $registerComponents,s as $use,m as default,t as registerComponent,n as registerComponents};
|
package/dist/events.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LadrillosJS Events Module
|
|
3
|
+
*
|
|
4
|
+
* Provides the event bus for cross-component communication.
|
|
5
|
+
* Import this module only if you need $emit/$listen.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { $emit, $listen } from 'ladrillosjs/events';
|
|
10
|
+
*
|
|
11
|
+
* // Emit an event
|
|
12
|
+
* $emit('user-login', { userId: 123 });
|
|
13
|
+
*
|
|
14
|
+
* // Listen for events
|
|
15
|
+
* const unsubscribe = $listen('user-login', (data) => {
|
|
16
|
+
* console.log('User logged in:', data.userId);
|
|
17
|
+
* });
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export { $emit, $listen, type EventCallback, type Unsubscribe, } from './core/events/eventBus';
|
package/dist/events.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as s,$ as e}from"./shared-DGGk2qBc.js";export{s as $emit,e as $listen};
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=/{([^}]+)}/g,t=new DOMParser;async function n(n,r,o){const s=function(e){return t.parseFromString(e,"text/html")}(n),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 n=e.src;if(o)try{n=new URL(e.getAttribute("src")??e.src,o).toString()}catch{}return{src:n,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 n=e.getAttribute("rel")||"stylesheet";if(o&&t&&!t.startsWith("http"))try{t=new URL(t,o).toString()}catch{}return{href:t,rel:n}}).filter(e=>e.href.length>0);f.forEach(e=>e.remove());const h=Array.from(s.querySelectorAll("style")),d=h.map(e=>e.textContent??"").join("\n").trim();h.forEach(e=>e.remove());const m=s.querySelector("template");let g;if(m){const e=document.createElement("div");e.appendChild(m.content.cloneNode(!0)),g=e.innerHTML.trim()}else g=s.body.innerHTML.trim();const _=function(t){const n=/* @__PURE__ */new Set,r=function(e){const t=/* @__PURE__ */new Set,n=/\$for\s*=\s*["']([^"']+)["']/g;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}(t),o=t.matchAll(e);for(const e of o){const t=e[1].trim().match(/^([a-zA-Z_$][a-zA-Z0-9_$]*)/);if(t){const e=t[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(e)||r.has(e)||n.add(e)}}return Array.from(n)}(g);return{tagName:r,template:g,scripts:l,externalScripts:u,externalStyles:p,styles:d,sourcePath:o,lazy:!1,templateBindings:_}}const r=/* @__PURE__ */new Map,o=(e,t)=>{if(r.has(e))r.delete(e);else if(r.size>=25){const e=r.keys().next().value;e&&r.delete(e)}r.set(e,t)};async function s(e){if(!e)throw new Error("Path cannot be null or empty");const t=(e=>{const t=r.get(e);return t&&(r.delete(e),r.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 o(e,n),t.path!==e&&o(t.path,n),{source:n,resolvedPath:t.path}}catch(n){return}}function i(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=a(e.slice(0,t).trim());if(!r)return null;const o=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));return{calleePath:r,args:o}}(t);if(n)return{raw:t,path:n.calleePath,isFunction:!0,isExpression:!0,functionArgs:n.args};const r=a(t);return r?{raw:t,path:r,isFunction:!1,isExpression:!1}:{raw:t,path:[],isExpression:!0}}function a(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 c(e){let t=e.parentElement;for(;t;){if(t.hasAttribute&&t.hasAttribute("$for"))return!0;t=t.parentElement}return!1}function l(e){let t=e.parentElement;for(;t;){if(t.hasAttribute&&t.hasAttribute("$no:bind"))return!0;t=t.parentElement}return!1}const u=["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"],f=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"]),p=Object.freeze([]),h=/* @__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"]),d={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"},m=["ctrl","alt","shift","meta"],g=["prevent","stop","self","once","passive","capture"],_={left:0,middle:1,right:2};function y(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?g.includes(e)?o.eventModifiers.push(e):m.includes(e)?o.systemModifiers.push(e):e in _?o.mouseModifier=e:o.keyModifiers.push(e):o.exact=!0}return o}function b(e){const t={};return e.includes("passive")&&(t.passive=!0),e.includes("capture")&&(t.capture=!0),e.includes("once")&&(t.once=!0),t}function $(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===_[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 m)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=d[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 v(e){return e.startsWith("$on:")}const w="[LadrillosJS]",E=function(){try{if(void 0!==import.meta)return!1}catch{}try{if("undefined"!=typeof globalThis&&globalThis.process?.env?.NODE_ENV)return"production"!==globalThis.process.env.NODE_ENV}catch{}return!0}(),A=()=>"undefined"!=typeof window&&"undefined"!=typeof console&&"function"==typeof console.log;let S=null;function C(){return S}function R(e,t){const n=`{${t}}`,r=e.indexOf(n);if(-1!==r)return{start:r,end:r+n.length};const o=e.indexOf(t);return-1!==o?{start:o,end:o+t.length}:null}function x(e){const t=void 0!==e?e:S;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(" ")}`:""}function L(e,t){return`${e}${x(t)}`}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||{});function T(e,t){E&&(L(e,t),A())}function I(e,t){L(e,t),A()}function M(e,t,n={}){const r=n.context||S,o=n.errorCode||((i=t)instanceof SyntaxError?102:i instanceof ReferenceError?103:i instanceof TypeError&&(i.message.includes("Cannot read properties of null")||i.message.includes("Cannot read properties of undefined"))?104:101),s=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"}return e instanceof TypeError?e.message.includes("Cannot read properties of null")?"Cannot access property of null":e.message.includes("Cannot read properties of undefined")?"Cannot access property of undefined":"Type error":"Expression evaluation failed"}(t);var i;if(!E)return;const a=x(r);if(A())n.template&&R(n.template,e);else{const i=[`${w} ${s}${a}`,` Expression: ${e}`];if(r?.tagName&&i.push(` Component: <${r.tagName}>`),r?.sourcePath&&i.push(` File: ${r.sourcePath}`),n.template){const t=R(n.template,e);t&&(i.push(" Location:"),i.push(function(e,t=0,n=e.length){const r=e.split("\n");let o=0;const s=[];for(let i=0;i<r.length;i++){const e=r[i].length+1;if(o+e>=t){for(let a=Math.max(0,i-2);a<=Math.min(r.length-1,i+2);a++){const c=a+1,l=r[a],u=`${c}`.padStart(4)+" │ ";if(s.push(`${u}${l}`),a===i){const r=t-(o-e),i=Math.min(n>o?n-t:e-r,l.length-r);s.push(` │ ${"".padStart(Math.max(0,r))}${"^".repeat(Math.max(1,i))}`)}}break}o+=e}return s.join("\n")}(n.template,t.start,t.end).split("\n").map(e=>` ${e}`).join("\n")))}i.push(` Error: ${t.message}`),i.push(` Docs: ${function(e){return`https://ladrillosjs.dev/errors/${e}`}(o)}`)}}const O=/* @__PURE__ */Symbol("reactive-array"),k=["push","pop","shift","unshift","splice","sort","reverse","fill","copyWithin"];function P(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&&k.includes(n)&&"function"==typeof r?(...n)=>{const o=n.map(e=>Array.isArray(e)?P(e,t):e),s=r.apply(e,o);return t(),s}:Array.isArray(r)?P(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)?P(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 D(e,t){for(const n of Object.keys(e)){const r=e[n];Array.isArray(r)?e[n]=P(r,t):r&&"object"==typeof r&&!Array.isArray(r)&&D(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)U(e.raw,o)&&n.get(o).add(r);return n}(t,Object.keys(e));D(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)?P(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)U(t.raw,e)&&n.get(e).add(r)}(s,t,o),((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 U(e,t){var n;return new RegExp(`\\b${n=t,n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\b`).test(e)}function j(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=!1){const o=j(n,e);return dt.registerComponent(t,o,r)},$registerComponents:function(t){const n=Array.isArray(t)?t.map(t=>({...t,path:j(t.path,e)})):Object.entries(t).map(([t,n])=>"string"==typeof n?{name:t,path:j(n,e)}:{name:t,...n,path:j(n.path,e)});return dt.registerComponents(n)},$use:function(t,n=!1){const r=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),o=j(t,e);return dt.registerComponent(r,o,n)}}}const W=["$registerComponent","$registerComponents","$use"],H=z(window.location.href),B=H.$registerComponent,Z=H.$registerComponents,q=H.$use;function V(){return globalThis.__ladrillosEventBus||(globalThis.__ladrillosEventBus={listeners:/* @__PURE__ */new Map,componentListeners:/* @__PURE__ */new Map}),globalThis.__ladrillosEventBus}function X(){return V().listeners}function G(){return V().componentListeners}function J(e,t){const n=X().get(e);if(n&&0!==n.size)for(const o of n)try{o.callback(t)}catch(r){}}function Y(e,t,n){const r=X(),o=G();let s=r.get(e);s||(s=/* @__PURE__ */new Set,r.set(e,s));const i={callback:t,componentId:n};if(s.add(i),n){let t=o.get(n);t||(t=/* @__PURE__ */new Set,o.set(n,t)),t.add({event:e,registration:i})}return()=>{const t=X(),r=G();if(s?.delete(i),0===s?.size&&t.delete(e),n){const e=r.get(n);if(e){for(const t of e)if(t.registration===i){e.delete(t);break}0===e.size&&r.delete(n)}}}}function K(e){return{$emit:function(e,t){J(e,t)},$listen:function(t,n){return Y(t,n,e)}}}const Q=["$emit","$listen"],ee=e=>e instanceof ShadowRoot?e.host:e;function te(e,t,n,r){const o=Array.from(e.querySelectorAll("*"));for(const s of o)if(!re(s)){for(const e of u){const o=s.getAttribute(e);if(o){s.removeAttribute(e);const i=e.slice(2),a=oe(o,t,n,r);a&&s.addEventListener(i,a)}}ne(s,t,n,r)}}function ne(e,t,n,r){const o=Array.from(e.attributes).filter(e=>v(e.name));for(const s of o){const o=y(s.name);if(!o)continue;const i=s.value;e.removeAttribute(s.name);const a=oe(i,t,n,r);if(!a)continue;const c=$(a,o),l=b(o.eventModifiers);e.addEventListener(o.eventName,c,l)}}function re(e){if(e.hasAttribute("$for"))return!0;let t=e.parentElement;for(;t;){if(t.hasAttribute("$for"))return!0;t=t.parentElement}return!1}function oe(e,t,n,r){try{const o=r?.__componentUrl,s=r?.__componentId,i=fe(o,s),a=ue(),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,h=p?f.length>0?`const { ${f.join(", ")} } = state;`:"":f.length>0?`let { ${f.join(", ")} } = state;`:"",d=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${le(o)}\\b(?!\\s*[:(])`,"g");r=r.replace(e,`state.${o}`)}return`\${${r}}`}));for(const s of t){const e=new RegExp(`(?<![^.]\\.)(?<!state\\.)\\b${le(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}(se(n,p?u:[]),f),g=f.some(t=>new RegExp(`\\b${t}\\b`).test(e)),_=p||!g?"":f.filter(t=>new RegExp(`\\b${t}\\b`).test(e)).map(e=>`state.${e} = ${e};`).join(" "),y=/\bawait\b/.test(e)||/\bawait\b/.test(m)||/\basync\b/.test(m),b=o||"ladrillos-event-handler",$=y?`"use strict"; ${h} ${d} ${m} try { await (async () => { ${e} })(); } finally { ${_} }\n//# sourceURL=${b}`:`"use strict"; ${h} ${d} ${m} ${e}; ${_}\n//# sourceURL=${b}`,v=Object.getPrototypeOf(async function(){}).constructor,w=y?new v(...c,$):new Function(...c,$);return n=>{try{const o=r&&r.__refs||/* @__PURE__ */new Map,s=[n,t,o,...a.map(()=>{}),...i.values],c=w(...s);c&&"function"==typeof c.catch&&c.catch(n=>{const o={tagName:r?.tagName?.toLowerCase(),sourcePath:t.__componentUrl,instanceId:t.__componentId};M(e,n,{context:o.tagName?o:C(),errorCode:N.EVENT_HANDLER_FAILED})})}catch(o){const n={tagName:r?.tagName?.toLowerCase(),sourcePath:t.__componentUrl,instanceId:t.__componentId};M(e,o,{context:n.tagName?n:C(),errorCode:N.EVENT_HANDLER_FAILED})}}}catch(o){const n=r?.tagName?{tagName:r.tagName.toLowerCase(),sourcePath:t.__componentUrl}:null;return T(`Failed to create event handler: ${e}`,n),null}}function se(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));){const r=o[1];if(t.includes(r))continue;const s=ie(e,o.index);s&&n.push(s)}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));){const r=o[1];if(t.includes(r))continue;const s=o.index,i=e.indexOf("{",s+o[0].length-1),a=ie(e,s,i);a&&n.push(a)}return n.map(e=>e.trim()).join(";\n")+(n.length>0?";":"")}function ie(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],n=c>0?e[c-1]:"";if('"'!==t&&"'"!==t&&"`"!==t||"\\"===n||(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 ae(e,t,n,r,o,s,i=[]){try{const a=ce(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${le(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+(${le(s)})\\s*=`,"g");r=r.replace(e,`__state__.${s} ??=`)}for(const s of t){const e=new RegExp(`(?<![^.]\\.)(?<!__state__\\.)\\b${le(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=fe(n,r),u=ue(),f=["__state__","$host","$refs",...u,...l.keys],p=[t,o,s,...u.map(()=>{}),...l.values];new Function(...f,c)(...p)}catch(a){!function(e,t){const n=S;if(!E)return;const r=x(n);if(A());else{const e=[`${w} Script Error${r}`," Message: Error executing script with reactive state"];n?.tagName&&e.push(` Component: <${n.tagName}>`),n?.sourcePath&&e.push(` File: ${n.sourcePath}`),e.push(` Error: ${t.message}`)}}(0,a)}}function ce(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 le(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ue(){return p.filter(e=>!h.has(e))}function fe(e,t){const n=[],r=[];for(const i of f)i in globalThis&&(n.push(i),r.push(globalThis[i]));const o=z(e||window.location.href);n.push(...W),r.push(o.$registerComponent,o.$registerComponents,o.$use);const s=K(t||"anonymous");return n.push(...Q),r.push(s.$emit,s.$listen),{keys:n,values:r}}function pe(e,t){try{const n=Object.keys(t),r=Object.values(t),o=ue(),s=[...o,...n],i=[...o.map(()=>{}),...r];return new Function(...s,`"use strict"; return ${e};`)(...i)}catch(n){return M(e,n,{context:C()}),`{${e}}`}}function he(e,t){let n=e.original;for(const r of e.bindings){const e=pe(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 de(e,t){for(const n of e)he(n,t)}const me=/* @__PURE__ */new Map,ge=/* @__PURE__ */new Map,_e=/(?:import|export)\s+(?:[\s\S]*?\s+from\s+)?['"]([^'"]+)['"]/g,ye=/import\s*\(\s*['"]([^'"]+)['"]\s*\)/g,be=[".ts",".tsx",".mts"];function $e(e){return e.startsWith("./")||e.startsWith("../")}function ve(e){return be.some(t=>e.endsWith(t))}function we(e){return!(e.startsWith("/")||e.startsWith("./")||e.startsWith("../")||e.startsWith("http://")||e.startsWith("https://")||e.startsWith("data:")||e.startsWith("blob:"))}const Ee=/^(?:export\s+)?(?:let|const|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)/gm;async function Ae(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(_e,(e,n)=>{if($e(n)){const r=new URL(n,t).href;return ve(n)&&o.push(n),e.replace(n,r)}return we(n)&&r.push(n),e}),n=n.replace(ye,(e,n)=>{if($e(n)){const e=new URL(n,t).href;return ve(n)&&o.push(n),`import("${e}")`}return we(n)&&r.push(n),e}),o.length,r.length,n}(await r.text(),e.src),s=function(e){const t=function(e){const t=[];let n;for(Ee.lastIndex=0;null!==(n=Ee.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,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 $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\nconst $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\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 $refs = globalThis.__ladrillosRefs.get(__ladrillos_componentId);\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 $registerComponent = async (name, path, useShadowDOM = false) => {\n const resolvedPath = __resolvePath(path);\n return globalThis.ladrillosjs.registerComponent({ name, path: resolvedPath, useShadowDOM });\n};\n\n// $registerComponents - Register multiple components at once\nconst $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\n// $use - Shorthand for $registerComponent with auto-derived tag name\nconst $use = async (path, useShadowDOM = false) => {\n const tagName = __filenameToTagName(path);\n return $registerComponent(tagName, path, useShadowDOM);\n};\n\n// === End Framework Helpers ===\n\n`}(t,n||e.src),a=new Blob([i+s],{type:"text/javascript"}),c=URL.createObjectURL(a);try{return await(0,eval)(`import("${c}")`)}finally{URL.revokeObjectURL(c)}}catch(r){throw r}}const Se=/* @__PURE__ */new Map;async function Ce(e){if(ge.has(e))return ge.get(e);const t=(async()=>{try{return await(0,eval)(`import("${e}")`)}catch(t){throw t}})();return ge.set(e,t),t}function Re(e,t){return t&&Array.isArray(e)?P(e,t):e}async function xe(e,t,n,r,o,s){if("module"!==e.type)throw new Error('executeModuleScriptWithReactivity only handles type="module" scripts');const i=e.content,a=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+)/);e?c.imports.push({imported:e[1],local:e[2]}):c.imports.push({imported:t,local:t})}}t.push(c)}return t}(e),o={};for(const i of r){if(i.isSideEffect){const e=$e(i.specifier)?new URL(i.specifier,t).href:i.specifier;await Ce(e);continue}const e=$e(i.specifier)?new URL(i.specifier,t).href:i.specifier;try{const t=await Ce(e);for(const e of i.imports){let r;r="*"===e.imported?t:"default"===e.imported?t.default:t[e.imported],o[e.local]=Re(r,n)}}catch(s){}}return o}(i,t,s),c=function(e){return e.replace(/import\s+(?:(?:\{[^}]+\}|\*\s+as\s+\w+|\w+)(?:\s*,\s*\{[^}]+\})?\s+from\s+)?['"][^'"]+['"]\s*;?/g,"").trim()}(i),{variables:l,functions:u}=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}}(c),f=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+(${Le(s)})\\s*=`,"g");r=r.replace(e,`__state__.${s} =`)}for(const s of t){const e=new RegExp(`(?<![^.]\\.)(?<!__state__\\.)\\b${Le(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}(c,l),p=Object.keys(a),h=Object.values(a),d=`\n "use strict";\n return (async () => {\n ${f}\n ${u.length>0?`return { ${u.join(", ")} };`:"return {};"}\n })();\n `;try{const e=["console","alert","Math","JSON","Date","Array","Object","String","Number","Boolean","Promise","setTimeout","setInterval","clearTimeout","clearInterval"],s=e.map(e=>globalThis[e]),i=["$refs","__state__"],a=[r||/* @__PURE__ */new Map,o||{}],c=z(t),l=[c.$registerComponent,c.$registerComponents,c.$use],u=K(n||"anonymous"),f=[u.$emit,u.$listen],m={...globalThis.ladrillosjs||{},registerComponent:c.$registerComponent,registerComponents:c.$registerComponents},g=[...p,...e,...W,...Q,...i,"ladrillosjs"],_=[...h,...s,...l,...f,...a,m],y=new Function(...g,d),b=await y(..._);return{...o||{},...b||{}}}catch(m){throw m}}function Le(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}const Ne="$for",Te="$if",Ie="$else",Me="$else-if",Oe="$show",ke="$bind",Pe="$ref",De=/([\s\S]*?)\s+(?:in|of)\s+([\s\S]+)$/,Fe=/,([^,\}\]]*)(?:,([^,\}\]]*))?$/,Ue=/^\(|\)$/g;function je(e){return e.replace(/\$/g,"\\$")}function ze(e){const t=e.trim();return t.startsWith("{")&&t.endsWith("}")?t.slice(1,-1).trim():t}function We(e){const t=e.match(De);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(Ue,"").trim(),a=i.match(Fe);let c,l,u;return a?(c=i.replace(Fe,"").trim(),l=a[1]?.trim(),u=a[2]?.trim()):c=i,{item:c,index:l||u,key:n,array:o}}function He(e,t,n,r,o,s){return e.removeAttribute(Te),e.removeAttribute(Me),e.removeAttribute(Ie),{element:e,condition:t,type:n,placeholder:r,group:[],originalParent:o,nextSibling:s}}function Be(e,t){let n=e.parentElement;for(;n;){if(n.hasAttribute(Ne))return!0;n=n.parentElement}return!1}function Ze(e,t,n){for(const a of e.renderedElements)a.remove();e.renderedElements=[];const r=n(e.arrayName,t);if(!r||null==(o=r)||!Array.isArray(o)&&"function"!=typeof o[Symbol.iterator]&&"object"!=typeof o)return;var o;const s=Array.from(r),i=document.createDocumentFragment();s.forEach((r,o)=>{const s=e.template.cloneNode(!0),a=t.__scriptContent,c={...t,[e.itemName]:r,__reactiveState__:t,__scriptContent__:a||"",__componentUrl__:t.__componentUrl||""};e.indexName&&(c[e.indexName]=o),qe(s,c,n),i.appendChild(s),e.renderedElements.push(s)}),e.placeholder.parentNode?.insertBefore(i,e.placeholder.nextSibling)}function qe(e,t,n){for(const i of Array.from(e.attributes))if(i.value.includes("{")){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 u){const r=e.getAttribute(n);if(r){e.removeAttribute(n);const o=n.slice(2),s=Ve(r,t);s&&e.addEventListener(o,s)}}!function(e,t){const n=Array.from(e.attributes).filter(e=>v(e.name));for(const r of n){const n=y(r.name);if(!n)continue;const o=r.value;e.removeAttribute(r.name);const s=Ve(o,t);if(!s)continue;const i=$(s,n),a=b(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.textContent=i.textContent.replace(/\{([^}]+)\}/g,(e,r)=>{const o=n(r.trim(),t);return String(o??"")});for(const i of Array.from(e.children))qe(i,t,n)}function Ve(e,t){try{const n=t.__reactiveState__,r=t.__scriptContent__||"",o=Object.keys(t).filter(e=>!e.startsWith("__")),s=n?Object.keys(n).filter(e=>!e.startsWith("__")&&"function"!=typeof n[e]):[],i=o.filter(e=>!s.includes(e)&&"function"!=typeof t[e]),a=r.trim().length>0,c=o.filter(e=>"function"==typeof t[e]),l=n&&!0===n.__hasModuleScripts;let u="",f="";l?f=c.length>0?`const { ${c.join(", ")} } = context;`:"":a?u=se(r,[]):f=c.length>0?`const { ${c.join(", ")} } = context;`:"";const p=i.length>0?`const { ${i.join(", ")} } = context;`:"",h=n&&s.length>0?"reactiveState":"context",d=s.length>0?`let { ${s.join(", ")} } = ${h};`:"",m=!l&&n&&s.length>0?s.map(e=>`reactiveState.${e} = ${e};`).join(" "):"",g=K(t.__componentId__||n?.__componentId||"anonymous"),_=new Function("event","context","reactiveState","$emit","$listen",`"use strict";\n ${p}\n ${d}\n ${f}\n ${u}\n ${e};\n ${m}`);return e=>{try{_(e,t,n,g.$emit,g.$listen)}catch(r){}}}catch(n){return null}}function Xe(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 Ge(e,t,n,r){const o=e.element,{raw:s,path:i,isContentEditable:a}=e,c=n(s,t);Je(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 Je(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 instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement?e.value=String(t??""):e.value=t}}function Ye(t,n){const{tagName:r,template:o,scripts:s,externalScripts:a,externalStyles:u,styles:f,sourcePath:p,templateBindings:h=[]}=t,d=ce(s.map(e=>e.content).join("\n")),m=[.../* @__PURE__ */new Set([...d,...h])];class g extends HTMLElement{static get observedAttributes(){return m}state={};_root=null;_initialized=!1;_componentId=`${r}-${Math.random().toString(36).slice(2)}`;_directives=null;_evaluator=null;_updateBoundInputs=null;constructor(){super()}async connectedCallback(){if(this._initialized)return;var t;this._initialized=!0,t={tagName:r,sourcePath:p,instanceId:this._componentId},S=t,this._root=n?this.attachShadow({mode:"open"}):this;const{bindings:d}=((t,n)=>{t.innerHTML=n;const r=function(t){const n=[],r=document.createTreeWalker(t,NodeFilter.SHOW_TEXT,null);let o;for(;o=r.nextNode();){if(c(o)||l(o))continue;const t=[...o.textContent.matchAll(e)];if(t.length>0){const e=o.textContent,r=t.map(e=>i(e[1].trim()));n.push({node:o,bindings:r,original:e})}}const s=function(t){const n=[],r=["$if","$else","$else-if","$for","$show","$bind","$ref","$no:bind"],o=Array.from(t.querySelectorAll("*"));for(const s of o)if(!(s.hasAttribute("$for")||c(s)||s.hasAttribute("$no:bind")||l(s)))for(const t of Array.from(s.attributes)){if(r.includes(t.name))continue;const o=[...t.value.matchAll(e)];if(o.length>0){const e=document.createTextNode(t.value),r=o.map(e=>i(e[1].trim()));n.push({node:e,bindings:r,original:t.value,isAttribute:!0,attributeName:t.name,element:s})}}return n}(t);return n.push(...s),n}(t);return{bindings:r,twoWayBindings:[],conditionals:[],loops:[]}})(this._root,o);((e,t,n)=>{if(!t)return;const r=document.createElement("style");r.textContent=t,n?e.appendChild(r):document.head.appendChild(r)})(this._root,f,n);const m=this._getAttributeOverrides(),g=s.filter(e=>"module"!==e.type),_=s.some(e=>"module"===e.type),y=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(`[${je(Pe)}]`));for(const r of n){const e=r.getAttribute(Pe);e&&t.set(e,r)}}(this._root,y),u&&u.length>0&&await async function(e,t,n){for(const o of e)if(n&&t)try{let e=Se.get(o.href);if(!e){const t=await fetch(o.href);if(!t.ok)continue;e=await t.text(),Se.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)})}}(u,this._root,n),a.length>0&&await async function(e){const t=e.filter(e=>e.external);for(const r of t)try{await Ae(r)}catch(n){}}(a),this.state=await async function(e,t,n,r={},o,s=!1,i,a,c,l=[]){const u=ee(e),f={},p=t.map(e=>e.content).join("\n");for(const[d,m]of Object.entries(r))f[d]=m;f.__scriptContent=p,f.__componentUrl=i,f.__componentId=a;const h=F(f,n,(e,t)=>he(e,t),o);for(const d of t)ae(d.content,h,i,a,u,c,l);return u.__state=h,u.__scriptContent=p,u.__componentUrl=i,u.__componentId=a,s||(te(e,h,p,u),de(n,h)),h}(this._root,g,d,m,()=>this._updateDirectives(),_,p,this._componentId,y,h),"undefined"!=typeof globalThis&&(globalThis.__ladrillosStateCallbacks||(globalThis.__ladrillosStateCallbacks=/* @__PURE__ */new Map),globalThis.__ladrillosStateCallbacks.set(this._componentId,()=>this._updateDirectives())),p){const e=await async function(e,t,n,r,o,s,i){const a={},c=e.filter(e=>"module"===e.type),l=t.filter(e=>"module"===e.type),u=t.filter(e=>"module"!==e.type);for(const p of u)try{await Ae(p,r,n)}catch(f){}for(const p of l)try{const e=await Ae(p,r,n);if(e&&"object"==typeof e)for(const[t,n]of Object.entries(e))"default"!==t&&(a[t]=n,s&&(s[t]=n))}catch(f){}for(const p of c)try{const e=await xe(p,n,r,o,s,i);Object.assign(a,e)}catch(f){}return a}(s,a,p,this._componentId,y,this.state,()=>this._updateDirectives());(_||a.length>0)&&(this.state.__hasModuleScripts=!0);for(const[t,n]of Object.entries(e))"function"==typeof n&&(this.state[t]=n)}if(_&&function(e,t,n){const r=ee(e);te(e,n,r.__scriptContent||"",r),de(t,n)}(this._root,d,this.state),this._evaluator=pe,this._directives=function(e,t){const n={loops:[],conditionals:[],twoWayBindings:[],refs:t,showElements:[]};return function(e,t){const n=Array.from(e.querySelectorAll(`[${je(Pe)}]`));for(const r of n){const e=r.getAttribute(Pe);e&&(t.refs.set(e,r),r.removeAttribute(Pe))}}(e,n),function(e,t){const n=Array.from(e.querySelectorAll(`[${je(Ne)}]`));for(const r of n){const n=r.getAttribute(Ne);if(!n)continue;const o=We(n);if(!o)continue;const s=document.createComment(` $for: ${n} `),i=r.parentElement||e;i.insertBefore(s,r),r.remove(),r.removeAttribute(Ne);const a={template:r,expression:n,itemName:o.item,indexName:o.index,arrayName:o.array,keyAttribute:o.key,placeholder:s,renderedElements:[],originalParent:i};t.loops.push(a)}}(e,n),function(e,t){const n=Array.from(e.querySelectorAll(`[${je(Te)}]`));for(const r of n){if(Be(r))continue;const n=[],o=ze(r.getAttribute(Te)),s=document.createComment(` $if: ${o} `),i=r.parentElement||e,a=r.nextSibling;i.insertBefore(s,r),n.push(He(r,o,"if",s,i,a));let c=r.nextElementSibling;for(;c;){if(!c.hasAttribute(Me)){if(c.hasAttribute(Ie)){n.push(He(c,"","else",s,i,c.nextSibling)),c.remove();break}break}{const e=ze(c.getAttribute(Me)),t=c.nextElementSibling;n.push(He(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,t){const n=Array.from(e.querySelectorAll(`[${je(Oe)}]`));for(const r of n){const e=r.getAttribute(Oe);if(!e)continue;const n=ze(e);if(Be(r))continue;const o=r;t.showElements.push({element:o,expression:n,originalDisplay:o.style.display||""}),r.removeAttribute(Oe)}}(e,n),function(e,t){const n=Array.from(e.querySelectorAll(`[${je(ke)}]`));for(const r of n){const e=r.getAttribute(ke);if(!e)continue;if(Be(r))continue;const n=e.split("."),o=r.hasAttribute("contenteditable"),s={element:r,path:n,raw:e,isContentEditable:o};t.twoWayBindings.push(s),r.removeAttribute(ke)}}(e,n),n}(this._root,y),"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)Ge(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),Je(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=me.get(e);if(t){for(const e of t)URL.revokeObjectURL(e);me.delete(e)}}(this._componentId),function(e){const t=X(),n=G(),r=n.get(e);if(r){for(const{event:e,registration:n}of r){const r=t.get(e);r&&(r.delete(n),0===r.size&&t.delete(e))}n.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&&(this._directives.loops.length>0&&function(e,t,n){for(const r of e)Ze(r,t,n)}(this._directives.loops,this.state,this._evaluator),this._directives.conditionals.length>0&&function(e,t,n){for(const r of e)Xe(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=>!h.includes(e));if(n.length>0){const e=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}"`});T(`Reserved HTML attribute(s) used on <${r}>: ${n.map(e=>`"${e}"`).join(", ")}.\n These won't be available as component state because they're standard HTML attributes.\n Suggestions: ${e.join(", ")}`,{tagName:r,sourcePath:p})}return e}_isReservedAttribute(e){return!h.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 g}function Ke(e,t){const{tagName:n}=e;if(!customElements.get(n)){const r=Ye(e,t);customElements.define(n,r)}}const Qe=globalThis.requestIdleCallback||(e=>setTimeout(e,1)),et=globalThis.cancelIdleCallback||(e=>clearTimeout(e)),tt=(e=1e4)=>t=>{const n=Qe(t,{timeout:e});return()=>et(n)},nt=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()},rt=e=>t=>{if(!e)return void t();const n=matchMedia(e);if(!n.matches){const e=()=>t();return n.addEventListener("change",e,{once:!0}),()=>n.removeEventListener("change",e)}t()},ot=(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}},st=(e=0)=>t=>{const n=setTimeout(t,e);return()=>clearTimeout(n)},it=nt({rootMargin:"100px"}),at=/* @__PURE__ */new Map;let ct;const lt=/* @__PURE__ */new Map,ut=/* @__PURE__ */new Set,ft=/* @__PURE__ */new Map;function pt(e,t,n,r){var o;ft.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=ft.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 ht(o);this.isUpgraded=!0,this.upgradeToRealComponent(e)}catch(e){I(`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);this.parentNode?this.parentNode.replaceChild(t,this):I("No parent node for placeholder - cannot upgrade lazy component",{tagName:o})}}))}async function ht(e){const t=function(e){return`${e}--loaded`}(e);if(ut.has(e))return t;if(at.has(e))return await at.get(e),t;const r=ft.get(e);if(!r)throw new Error(`Lazy component "${e}" not registered`);const o=(async()=>{const o=await s(r.absolutePath);if(!o)throw new Error(`Failed to fetch component source for "${e}"`);const i=await n(o.source,e,o.resolvedPath);ct[e]=i;const a=Ye(i,r.useShadowDOM);return customElements.get(t)||customElements.define(t,a),ut.add(e),lt.set(e,{component:i,useShadowDOM:r.useShadowDOM}),i})();at.set(e,o);try{return await o,t}finally{at.delete(e)}}const dt=new class{components;constructor(){var e;this.components={},e=this.components,ct=e}async registerComponent(e,t,r=!0,o=!1){if(this.components[e])return void T(`Component with name "<${e}>" is already registered.`);const i=new URL(t,window.location.href).href;if(o)pt(e,i,r,!0===o?it:o);else try{const t=await s(i);if(!t)throw new Error(`Failed to fetch component source from ${i}`);const o=await n(t.source,e,t.resolvedPath);this.components[e]=o,Ke(o,r)}catch(a){I(`Error registering component "<${e}>"`,{tagName:e,sourcePath:t})}}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}),r={success:[],failed:[],skipped:[]},o=[],i=[];for(const n of t){if(this.components[n.name]){r.skipped.push(n.name);continue}const e=new URL(n.path,window.location.href).href,t={...n,absolutePath:e};n.lazy?o.push(t):i.push(t)}for(const n of o)try{const e=!0===n.lazy?it:n.lazy,t=n.useShadowDOM??!0;pt(n.name,n.absolutePath,t,e),r.success.push(n.name)}catch(l){r.failed.push({name:n.name,error:l instanceof Error?l:new Error(String(l))})}if(0===i.length)return r;const a=await Promise.allSettled(i.map(async e=>({config:e,result:await s(e.absolutePath)}))),c=await Promise.allSettled(a.map(async(e,t)=>{if("rejected"===e.status)throw e.reason;const{config:r,result:o}=e.value;if(!o)throw new Error(`Failed to fetch component source from ${r.absolutePath}`);return{config:r,component:await n(o.source,r.name,o.resolvedPath)}}));for(let n=0;n<c.length;n++){const e=c[n],t=i[n];if("rejected"===e.status){r.failed.push({name:t.name,error:e.reason instanceof Error?e.reason:new Error(String(e.reason))});continue}const{component:o}=e.value,s=t.useShadowDOM??!0;this.components[t.name]=o;try{Ke(o,s),r.success.push(t.name)}catch(l){r.failed.push({name:t.name,error:l instanceof Error?l:new Error(String(l))}),delete this.components[t.name]}}return r}async loadLazyComponent(e){return async function(e){return ft.has(e)&&await ht(e),ct[e]}(e)}},mt=(e,t,n,r)=>dt.registerComponent(e,t,n,r),gt=e=>dt.registerComponents(e),_t=e=>dt.loadLazyComponent(e),yt={registerComponent:mt,registerComponents:gt,loadLazyComponent:_t,$registerComponent:B,$registerComponents:Z,$use:q,$emit:J,$listen:Y,lazyOnIdle:tt,lazyOnVisible:nt,lazyOnMedia:rt,lazyOnInteraction:ot,lazyOnDelay:st};export{J as $emit,Y as $listen,B as $registerComponent,Z as $registerComponents,q as $use,yt as default,st as lazyOnDelay,tt as lazyOnIdle,ot as lazyOnInteraction,rt as lazyOnMedia,nt as lazyOnVisible,_t as loadLazyComponent,mt as registerComponent,gt as registerComponents};
|
|
1
|
+
import{l as e,a,b as s,c as n,d as o,e as t,$ as r,f as i,g as l}from"./shared-Dru_qCE_.js";import{$ as m,a as p}from"./shared-DGGk2qBc.js";const d=(a,s,n,o)=>e.registerComponent(a,s,n,o),y=a=>e.registerComponents(a),C=a=>e.loadLazyComponent(a),g={registerComponent:d,registerComponents:y,loadLazyComponent:C,$registerComponent:l,$registerComponents:i,$use:r,$emit:p,$listen:m,lazyOnIdle:t,lazyOnVisible:o,lazyOnMedia:n,lazyOnInteraction:s,lazyOnDelay:a};export{p as $emit,m as $listen,l as $registerComponent,i as $registerComponents,r as $use,g as default,a as lazyOnDelay,t as lazyOnIdle,s as lazyOnInteraction,n as lazyOnMedia,o as lazyOnVisible,C as loadLazyComponent,d as registerComponent,y as registerComponents};
|
package/dist/lazy.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LadrillosJS Lazy Loading Module
|
|
3
|
+
*
|
|
4
|
+
* Provides lazy loading strategies for components.
|
|
5
|
+
* Import this module only if you need lazy loading.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { lazyOnVisible, lazyOnIdle } from 'ladrillosjs/lazy';
|
|
10
|
+
*
|
|
11
|
+
* $registerComponent('heavy-widget', '/components/heavy.html', {
|
|
12
|
+
* lazy: lazyOnVisible({ rootMargin: '100px' })
|
|
13
|
+
* });
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export { type LazyStrategy, type LazyStrategyFactory, lazyOnIdle, lazyOnVisible, lazyOnMedia, lazyOnInteraction, lazyOnDelay, defaultLazyStrategy, } from './core/lazy';
|
|
17
|
+
export { forceLoadLazyComponent, isLazyComponent } from './core/lazy';
|
package/dist/lazy.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{h as a,i as e,j as s,a as n,e as o,b as y,c as l,d as t}from"./shared-Dru_qCE_.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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(){return globalThis.__ladrillosEventBus||(globalThis.__ladrillosEventBus={listeners:/* @__PURE__ */new Map,componentListeners:/* @__PURE__ */new Map}),globalThis.__ladrillosEventBus}function t(){return e().listeners}function n(){return e().componentListeners}function s(e,n){const s=t().get(e);if(s&&0!==s.size)for(const t of s)try{t.callback(n)}catch(o){}}function o(e,s,o){const i=t(),l=n();let r=i.get(e);r||(r=/* @__PURE__ */new Set,i.set(e,r));const c={callback:s,componentId:o};if(r.add(c),o){let t=l.get(o);t||(t=/* @__PURE__ */new Set,l.set(o,t)),t.add({event:e,registration:c})}return()=>{const s=t(),i=n();if(r?.delete(c),0===r?.size&&s.delete(e),o){const e=i.get(o);if(e){for(const t of e)if(t.registration===c){e.delete(t);break}0===e.size&&i.delete(o)}}}}function i(e){const s=t(),o=n(),i=o.get(e);if(i){for(const{event:e,registration:t}of i){const n=s.get(e);n&&(n.delete(t),0===n.size&&s.delete(e))}o.delete(e)}}function l(e){return{$emit:function(e,t){s(e,t)},$listen:function(t,n){return o(t,n,e)}}}const r=["$emit","$listen"];export{o as $,s as a,i as b,l as c,r as e};
|
|
@@ -0,0 +1 @@
|
|
|
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 h=Array.from(s.querySelectorAll("style")),d=h.map(e=>e.textContent??"").join("\n").trim();h.forEach(e=>e.remove());const m=s.querySelector("template");let g;if(m){const e=document.createElement("div");e.appendChild(m.content.cloneNode(!0)),g=e.innerHTML.trim()}else g=s.body.innerHTML.trim();const _=function(e){const t=/* @__PURE__ */new Set,n=function(e){const t=/* @__PURE__ */new Set,n=/\$for\s*=\s*["']([^"']+)["']/g;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)}(g);return{tagName:t,template:g,scripts:l,externalScripts:u,externalStyles:p,styles:d,sourcePath:n,lazy:!1,templateBindings:_}}const i=/* @__PURE__ */new Map,a=(e,t)=>{if(i.has(e))i.delete(e);else if(i.size>=25){const e=i.keys().next().value;e&&i.delete(e)}i.set(e,t)};async function c(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 a(e,n),t.path!==e&&a(t.path,n),{source:n,resolvedPath:t.path}}catch(n){return}}function l(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=u(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=u(t);return r?{raw:t,path:r,isFunction:!1,isExpression:!1}:{raw:t,path:[],isExpression:!0}}function u(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 f(e){let t=e.parentElement;for(;t;){if(t.hasAttribute&&t.hasAttribute("$for"))return!0;t=t.parentElement}return!1}function p(e){let t=e.parentElement;for(;t;){if(t.hasAttribute&&t.hasAttribute("$no:bind"))return!0;t=t.parentElement}return!1}const h=["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"],d=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"]),m=Object.freeze([]),g=/* @__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"]),_={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"},y=["ctrl","alt","shift","meta"],b=["prevent","stop","self","once","passive","capture"],w={left:0,middle:1,right:2};function v(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?b.includes(e)?o.eventModifiers.push(e):y.includes(e)?o.systemModifiers.push(e):e in w?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 E(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===w[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 y)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=_[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 A(e){return e.startsWith("$on:")}let S=null;var R=/* @__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))(R||{});function x(e,t){!function(e,t){!function(e){const t=void 0!==e?e:S;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})`)}n.length>0&&n.join(" ")}(t)}(0,t),"undefined"!=typeof window&&"undefined"!=typeof console&&console}function C(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 L=/* @__PURE__ */new Map,N=/* @__PURE__ */Symbol("reactive-array"),I=["push","pop","shift","unshift","splice","sort","reverse","fill","copyWithin"];function T(e,t){return e[N]?e:new Proxy(e,{get(e,n){if(n===N)return!0;const r=e[n];return"string"==typeof n&&I.includes(n)&&"function"==typeof r?(...n)=>{const o=n.map(e=>Array.isArray(e)?T(e,t):e),s=r.apply(e,o);return t(),s}:Array.isArray(r)?T(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)?T(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 k(e,t){for(const n of Object.keys(e)){const r=e[n];Array.isArray(r)?e[n]=T(r,t):r&&"object"==typeof r&&!Array.isArray(r)&&k(r,t)}return e}function M(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)O(e.raw,o)&&n.get(o).add(r);return n}(t,Object.keys(e));k(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)?T(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)O(t.raw,e)&&n.get(e).add(r)}(s,t,o),((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 O(e,t){const n=function(e){let t=L.get(e);if(!t){const n=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");t=new RegExp(`\\b${n}\\b`),L.set(e,t)}return t}(t);return n.test(e)}function D(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 P(e){return{$registerComponent:function(t,n,r=!1){const o=D(n,e);return gt.registerComponent(t,o,r)},$registerComponents:function(t){const n=Array.isArray(t)?t.map(t=>({...t,path:D(t.path,e)})):Object.entries(t).map(([t,n])=>"string"==typeof n?{name:t,path:D(n,e)}:{name:t,...n,path:D(n.path,e)});return gt.registerComponents(n)},$use:function(t,n=!1){const r=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),o=D(t,e);return gt.registerComponent(r,o,n)}}}const F=["$registerComponent","$registerComponents","$use"],j=P(window.location.href),U=j.$registerComponent,W=j.$registerComponents,z=j.$use,H=e=>e instanceof ShadowRoot?e.host:e;function B(e,t,n,r){const o=Array.from(e.querySelectorAll("*"));for(const s of o)if(!q(s)){for(const e of h){const o=s.getAttribute(e);if(o){s.removeAttribute(e);const i=e.slice(2),a=X(o,t,n,r);a&&s.addEventListener(i,a)}}Z(s,t,n,r)}}function Z(e,t,n,r){const o=Array.from(e.attributes).filter(e=>A(e.name));for(const s of o){const o=v(s.name);if(!o)continue;const i=s.value;e.removeAttribute(s.name);const a=X(i,t,n,r);if(!a)continue;const c=E(a,o),l=$(o.eventModifiers);e.addEventListener(o.eventName,c,l)}}function q(e){if(e.hasAttribute("$for"))return!0;let t=e.parentElement;for(;t;){if(t.hasAttribute("$for"))return!0;t=t.parentElement}return!1}function X(e,t,n,r){try{const o=r?.__componentUrl,s=r?.__componentId,i=ee(o,s),a=Q(),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,h=p?f.length>0?`const { ${f.join(", ")} } = state;`:"":f.length>0?`let { ${f.join(", ")} } = state;`:"",d=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${K(o)}\\b(?!\\s*[:(])`,"g");r=r.replace(e,`state.${o}`)}return`\${${r}}`}));for(const s of t){const e=new RegExp(`(?<![^.]\\.)(?<!state\\.)\\b${K(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}(V(n,p?u:[]),f),g=f.some(t=>new RegExp(`\\b${t}\\b`).test(e)),_=p||!g?"":f.filter(t=>new RegExp(`\\b${t}\\b`).test(e)).map(e=>`state.${e} = ${e};`).join(" "),y=/\bawait\b/.test(e)||/\bawait\b/.test(m)||/\basync\b/.test(m),b=o||"ladrillos-event-handler",w=y?`"use strict"; ${h} ${d} ${m} try { await (async () => { ${e} })(); } finally { ${_} }\n//# sourceURL=${b}`:`"use strict"; ${h} ${d} ${m} ${e}; ${_}\n//# sourceURL=${b}`,v=Object.getPrototypeOf(async function(){}).constructor,$=y?new v(...c,w):new Function(...c,w);return e=>{try{const n=[e,t,r&&r.__refs||/* @__PURE__ */new Map,...a.map(()=>{}),...i.values],o=$(...n);o&&"function"==typeof o.catch&&o.catch(e=>{r?.tagName?.toLowerCase(),C(0,e,{errorCode:R.EVENT_HANDLER_FAILED})})}catch(n){r?.tagName?.toLowerCase(),C(0,n,{errorCode:R.EVENT_HANDLER_FAILED})}}}catch(o){return r?.tagName&&r.tagName.toLowerCase(),null}}function V(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=G(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=G(e,r,s);i&&n.push(i)}return n.map(e=>e.trim()).join(";\n")+(n.length>0?";":"")}function G(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 J(e,t,n,r,o,s,i=[]){try{const a=Y(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${K(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+(${K(s)})\\s*=`,"g");r=r.replace(e,`__state__.${s} ??=`)}for(const s of t){const e=new RegExp(`(?<![^.]\\.)(?<!__state__\\.)\\b${K(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=ee(n,r),u=Q(),f=["__state__","$host","$refs",...u,...l.keys],p=[t,o,s,...u.map(()=>{}),...l.values];new Function(...f,c)(...p)}catch(a){}}function Y(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 K(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Q(){return m.filter(e=>!g.has(e))}function ee(n,r){const o=[],s=[];for(const e of d)e in globalThis&&(o.push(e),s.push(globalThis[e]));const i=P(n||window.location.href);o.push(...F),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 te(e,t){try{const n=Object.keys(t),r=Object.values(t),o=Q(),s=[...o,...n],i=[...o.map(()=>{}),...r];return new Function(...s,`"use strict"; return ${e};`)(...i)}catch(n){return C(0,n,{}),`{${e}}`}}function ne(e,t){let n=e.original;for(const r of e.bindings){const e=te(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 re(e,t){for(const n of e)ne(n,t)}const oe=/* @__PURE__ */new Map,se=/* @__PURE__ */new Map,ie=/(?:import|export)\s+(?:[\s\S]*?\s+from\s+)?['"]([^'"]+)['"]/g,ae=/import\s*\(\s*['"]([^'"]+)['"]\s*\)/g,ce=[".ts",".tsx",".mts"];function le(e){return e.startsWith("./")||e.startsWith("../")}function ue(e){return ce.some(t=>e.endsWith(t))}function fe(e){return!(e.startsWith("/")||e.startsWith("./")||e.startsWith("../")||e.startsWith("http://")||e.startsWith("https://")||e.startsWith("data:")||e.startsWith("blob:"))}const pe=/^(?:export\s+)?(?:let|const|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)/gm;async function he(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){const t=function(e){const t=[];let n;for(pe.lastIndex=0;null!==(n=pe.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}(function(e,t){let n=e;const r=[],o=[];return n=n.replace(ie,(e,n)=>{if(le(n)){const r=new URL(n,t).href;return ue(n)&&o.push(n),e.replace(n,r)}return fe(n)&&r.push(n),e}),n=n.replace(ae,(e,n)=>{if(le(n)){const e=new URL(n,t).href;return ue(n)&&o.push(n),`import("${e}")`}return fe(n)&&r.push(n),e}),n}(await r.text(),e.src))),s=function(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 $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\nconst $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\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 $refs = globalThis.__ladrillosRefs.get(__ladrillos_componentId);\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 $registerComponent = async (name, path, useShadowDOM = false) => {\n const resolvedPath = __resolvePath(path);\n return globalThis.ladrillosjs.registerComponent({ name, path: resolvedPath, useShadowDOM });\n};\n\n// $registerComponents - Register multiple components at once\nconst $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\n// $use - Shorthand for $registerComponent with auto-derived tag name\nconst $use = async (path, useShadowDOM = false) => {\n const tagName = __filenameToTagName(path);\n return $registerComponent(tagName, path, useShadowDOM);\n};\n\n// === End Framework Helpers ===\n\n`}(t,n||e.src),i=new Blob([s+o],{type:"text/javascript"}),a=URL.createObjectURL(i);try{return await(0,eval)(`import("${a}")`)}finally{URL.revokeObjectURL(a)}}catch(r){throw r}}const de=/* @__PURE__ */new Map;async function me(e){if(se.has(e))return se.get(e);const t=(async()=>{try{return await(0,eval)(`import("${e}")`)}catch(t){throw t}})();return se.set(e,t),t}function ge(e,t){return t&&Array.isArray(e)?T(e,t):e}async function _e(n,r,o,s,i,a){if("module"!==n.type)throw new Error('executeModuleScriptWithReactivity only handles type="module" scripts');const c=n.content,l=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=le(i.specifier)?new URL(i.specifier,t).href:i.specifier;await me(e);continue}const e=le(i.specifier)?new URL(i.specifier,t).href:i.specifier;try{const t=await me(e);for(const e of i.imports){let r;r="*"===e.imported?t:"default"===e.imported?t.default:t[e.imported],o[e.local]=ge(r,n)}}catch(s){}}return o}(c,r,a),u=function(e){return e.replace(/import\s+(?:(?:\{[^}]+\}|\*\s+as\s+\w+|\w+)(?:\s*,\s*\{[^}]+\})?\s+from\s+)?['"][^'"]+['"]\s*;?/g,"").trim()}(c),{variables:f,functions:p}=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}}(u),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+(${ye(s)})\\s*=`,"g");r=r.replace(e,`__state__.${s} =`)}for(const s of t){const e=new RegExp(`(?<![^.]\\.)(?<!__state__\\.)\\b${ye(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}(u,f),d=Object.keys(l),m=Object.values(l),g=`\n "use strict";\n return (async () => {\n ${h}\n ${p.length>0?`return { ${p.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]),c=["$refs","__state__"],l=[s||/* @__PURE__ */new Map,i||{}],u=P(r),f=[u.$registerComponent,u.$registerComponents,u.$use],p=t(o||"anonymous"),h=[p.$emit,p.$listen],_={...globalThis.ladrillosjs||{},registerComponent:u.$registerComponent,registerComponents:u.$registerComponents},y=[...d,...n,...F,...e,...c,"ladrillosjs"],b=[...m,...a,...f,...h,...l,_],w=new Function(...y,g),v=await w(...b);return{...i||{},...v||{}}}catch(_){throw _}}function ye(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}const be="$for",we="$if",ve="$else",$e="$else-if",Ee="$show",Ae="$bind",Se="$ref",Re=/([\s\S]*?)\s+(?:in|of)\s+([\s\S]+)$/,xe=/,([^,\}\]]*)(?:,([^,\}\]]*))?$/,Ce=/^\(|\)$/g;function Le(e){return e.replace(/\$/g,"\\$")}function Ne(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 Ie(e){const t=e.trim();return t.startsWith("{")&&t.endsWith("}")?t.slice(1,-1).trim():t}function Te(e){const t=e.match(Re);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(Ce,"").trim(),a=i.match(xe);let c,l,u;return a?(c=i.replace(xe,"").trim(),l=a[1]?.trim(),u=a[2]?.trim()):c=i,{item:c,index:l||u,key:n,array:o}}function ke(e,t,n,r,o,s){return e.removeAttribute(we),e.removeAttribute($e),e.removeAttribute(ve),{element:e,condition:t,type:n,placeholder:r,group:[],originalParent:o,nextSibling:s}}function Me(e,t){let n=e.parentElement;for(;n;){if(n.hasAttribute(be))return!0;n=n.parentElement}return!1}function Oe(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 Fe(s,De(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];Ne(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?(Pe(u,De(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=De(t,e,s[i],i);Pe(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 De(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 Pe(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))Pe(s,t,n)}function Fe(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 h){const r=e.getAttribute(n);if(r){e.removeAttribute(n);const o=n.slice(2),s=je(r,t);s&&e.addEventListener(o,s)}}!function(e,t){const n=Array.from(e.attributes).filter(e=>A(e.name));for(const r of n){const n=v(r.name);if(!n)continue;const o=r.value;e.removeAttribute(r.name);const s=je(o,t);if(!s)continue;const i=E(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))Fe(i,t,n)}function je(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=V(o,[]):p=l.length>0?`const { ${l.join(", ")} } = context;`:"";const h=a.length>0?`const { ${a.join(", ")} } = context;`:"",d=r&&i.length>0?"reactiveState":"context",m=i.length>0?`let { ${i.join(", ")} } = ${d};`:"",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 ${h}\n ${m}\n ${p}\n ${f}\n ${e};\n ${g}`);return e=>{try{y(e,n,r,_.$emit,_.$listen)}catch(t){}}}catch(r){return null}}function Ue(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 We(e,t,n,r){const o=e.element,{raw:s,path:i,isContentEditable:a}=e,c=n(s,t);ze(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 ze(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 He=[],Be=/* @__PURE__ */new Set;let Ze=!1,qe=!1,Xe=0;const Ve=Promise.resolve();function Ge(){qe=!1,Ze=!0,He.sort((e,t)=>(e.id??0)-(t.id??0));try{for(const t of He)if(!1!==t.active)try{t()}catch(e){}}finally{He.length=0,Be.clear(),Ze=!1}}const Je=/* @__PURE__ */new Map;function Ye(e,t){const{tagName:o,template:s,scripts:i,externalScripts:a,externalStyles:c,styles:u,sourcePath:h,templateBindings:d=[]}=e,m=Y(i.map(e=>e.content).join("\n")),g=[.../* @__PURE__ */new Set([...m,...d])];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,S={tagName:o,sourcePath:h,instanceId:this._componentId},this._root=t?this.attachShadow({mode:"open"}):this;const{bindings:e}=((e,t)=>{e.innerHTML=t;const n=function(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null);let o;for(;o=n.nextNode();){if(f(o)||p(o))continue;const e=[...o.textContent.matchAll(r)];if(e.length>0){const n=o.textContent,r=e.map(e=>l(e[1].trim()));t.push({node:o,bindings:r,original:n})}}const s=function(e){const t=[],n=["$if","$else","$else-if","$for","$show","$bind","$ref","$no:bind"],o=Array.from(e.querySelectorAll("*"));for(const s of o)if(!(s.hasAttribute("$for")||f(s)||s.hasAttribute("$no:bind")||p(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=>l(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:n,twoWayBindings:[],conditionals:[],loops:[]}})(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,u,t);const n=this._getAttributeOverrides(),m=i.filter(e=>"module"!==e.type),g=i.some(e=>"module"===e.type),_=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(`[${Le(Se)}]`));for(const r of n){const e=r.getAttribute(Se);e&&t.set(e,r)}}(this._root,_),c&&c.length>0&&await async function(e,t,n){for(const o of e)if(n&&t)try{let e=de.get(o.href);if(!e){const t=await fetch(o.href);if(!t.ok)continue;e=await t.text(),de.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 he(r)}catch(n){}}(a),this.state=await async function(e,t,n,r={},o,s=!1,i,a,c,l=[]){const u=H(e),f={},p=t.map(e=>e.content).join("\n");for(const[d,m]of Object.entries(r))f[d]=m;f.__scriptContent=p,f.__componentUrl=i,f.__componentId=a;const h=M(f,n,(e,t)=>ne(e,t),o);for(const d of t)J(d.content,h,i,a,u,c,l);return u.__state=h,u.__scriptContent=p,u.__componentUrl=i,u.__componentId=a,s||(B(e,h,p,u),re(n,h)),h}(this._root,m,e,n,()=>this._updateDirectives(),g,h,this._componentId,_,d),"undefined"!=typeof globalThis&&(globalThis.__ladrillosStateCallbacks||(globalThis.__ladrillosStateCallbacks=/* @__PURE__ */new Map),globalThis.__ladrillosStateCallbacks.set(this._componentId,()=>this._updateDirectives())),h){const e=await async function(e,t,n,r,o,s,i){const a={},c=e.filter(e=>"module"===e.type),l=t.filter(e=>"module"===e.type),u=t.filter(e=>"module"!==e.type);for(const p of u)try{await he(p,r,n)}catch(f){}for(const p of l)try{const e=await he(p,r,n);if(e&&"object"==typeof e)for(const[t,n]of Object.entries(e))"default"!==t&&(a[t]=n,s&&(s[t]=n))}catch(f){}for(const p of c)try{const e=await _e(p,n,r,o,s,i);Object.assign(a,e)}catch(f){}return a}(i,a,h,this._componentId,_,this.state,()=>this._updateDirectives());(g||a.length>0)&&(this.state.__hasModuleScripts=!0);for(const[t,n]of Object.entries(e))"function"==typeof n&&(this.state[t]=n)}if(g&&function(e,t,n){const r=H(e);B(e,n,r.__scriptContent||"",r),re(t,n)}(this._root,e,this.state),this._evaluator=te,this._directives=function(e,t){const n={loops:[],conditionals:[],twoWayBindings:[],refs:t,showElements:[]};return function(e,t){const n=Array.from(e.querySelectorAll(`[${Le(Se)}]`));for(const r of n){const e=r.getAttribute(Se);e&&(t.refs.set(e,r),r.removeAttribute(Se))}}(e,n),function(e,t){const n=Array.from(e.querySelectorAll(`[${Le(be)}]`));for(const r of n){const n=r.getAttribute(be);if(!n)continue;const o=Te(n);if(!o)continue;const s=document.createComment(` $for: ${n} `),i=r.parentElement||e;i.insertBefore(s,r),r.remove(),r.removeAttribute(be),t.loops.push({template:r,expression:n,itemName:o.item,indexName:o.index,arrayName:o.array,keyAttribute:o.key,placeholder:s,renderedElements:[],originalParent:i})}}(e,n),function(e,t){const n=Array.from(e.querySelectorAll(`[${Le(we)}]`));for(const r of n){if(Me(r))continue;const n=[],o=Ie(r.getAttribute(we)),s=document.createComment(` $if: ${o} `),i=r.parentElement||e,a=r.nextSibling;i.insertBefore(s,r),n.push(ke(r,o,"if",s,i,a));let c=r.nextElementSibling;for(;c;){if(!c.hasAttribute($e)){if(c.hasAttribute(ve)){n.push(ke(c,"","else",s,i,c.nextSibling)),c.remove();break}break}{const e=Ie(c.getAttribute($e)),t=c.nextElementSibling;n.push(ke(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,t){const n=Array.from(e.querySelectorAll(`[${Le(Ee)}]`));for(const r of n){const e=r.getAttribute(Ee);if(!e)continue;const n=Ie(e);Me(r)||(t.showElements.push({element:r,expression:n,originalDisplay:r.style.display||""}),r.removeAttribute(Ee))}}(e,n),function(e,t){const n=Array.from(e.querySelectorAll(`[${Le(Ae)}]`));for(const r of n){const e=r.getAttribute(Ae);if(!e)continue;if(Me(r))continue;const n=e.split("."),o=r.hasAttribute("contenteditable");t.twoWayBindings.push({element:r,path:n,raw:e,isContentEditable:o}),r.removeAttribute(Ae)}}(e,n),n}(this._root,_),"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)We(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),ze(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=oe.get(e);if(t){for(const e of t)URL.revokeObjectURL(e);oe.delete(e)}}(this._componentId),n(this._componentId),function(e){const t=Je.get(e);t&&(t.active=!1,Je.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=Je.get(e);n||(n=function(){const e=()=>{t()};return e.id=++Xe,e.active=!0,e}(),Je.set(e,n)),function(e){void 0===e.id&&(e.id=++Xe),Be.has(e.id)||(Be.add(e.id),He.push(e),Ze||qe||(qe=!0,Ve.then(Ge)))}(n)}(this._componentId,()=>{this._performDirectiveUpdates()})}_performDirectiveUpdates(){this._directives&&this._evaluator&&(this._directives.loops.length>0&&function(e,t,n){for(const r of e)Oe(r,t,n)}(this._directives.loops,this.state,this._evaluator),this._directives.conditionals.length>0&&function(e,t,n){for(const r of e)Ue(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=>!d.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!d.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 Ke(e,t){const{tagName:n}=e;if(!customElements.get(n)){const r=Ye(e,t);customElements.define(n,r)}}const Qe=globalThis.requestIdleCallback||(e=>setTimeout(e,1)),et=globalThis.cancelIdleCallback||(e=>clearTimeout(e)),tt=(e=1e4)=>t=>{const n=Qe(t,{timeout:e});return()=>et(n)},nt=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()},rt=e=>t=>{if(!e)return void t();const n=matchMedia(e);if(!n.matches){const e=()=>t();return n.addEventListener("change",e,{once:!0}),()=>n.removeEventListener("change",e)}t()},ot=(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}},st=(e=0)=>t=>{const n=setTimeout(t,e);return()=>clearTimeout(n)},it=nt({rootMargin:"100px"}),at=/* @__PURE__ */new Map;let ct;const lt=/* @__PURE__ */new Map,ut=/* @__PURE__ */new Set,ft=/* @__PURE__ */new Map;function pt(e,t,n,r){var o;ft.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=ft.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 ht(o);this.isUpgraded=!0,this.upgradeToRealComponent(e)}catch(e){x(0,{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);this.parentNode?this.parentNode.replaceChild(t,this):x(0,{tagName:o})}}))}async function ht(e){const t=function(e){return`${e}--loaded`}(e);if(ut.has(e))return t;if(at.has(e))return await at.get(e),t;const n=ft.get(e);if(!n)throw new Error(`Lazy component "${e}" not registered`);const r=(async()=>{const r=await c(n.absolutePath);if(!r)throw new Error(`Failed to fetch component source for "${e}"`);const o=await s(r.source,e,r.resolvedPath);ct[e]=o;const i=Ye(o,n.useShadowDOM);return customElements.get(t)||customElements.define(t,i),ut.add(e),lt.set(e,{component:o,useShadowDOM:n.useShadowDOM}),o})();at.set(e,r);try{return await r,t}finally{at.delete(e)}}function dt(e){return ft.has(e)||ut.has(e)}async function mt(e){return ft.has(e)&&await ht(e),ct[e]}const gt=new class{components;constructor(){this.components={},ct=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)pt(e,o,n,!0===r?it:r);else try{const t=await c(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,Ke(r,n)}catch(i){x(0,{tagName:e,sourcePath:t})}}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{pt(s.name,s.absolutePath,s.useShadowDOM??!0,!0===s.lazy?it:s.lazy),n.success.push(s.name)}catch(l){n.failed.push({name:s.name,error:l instanceof Error?l:new Error(String(l))})}if(0===o.length)return n;const i=await Promise.allSettled(o.map(async e=>({config:e,result:await c(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))});continue}const{component:r}=e.value,i=t.useShadowDOM??!0;this.components[t.name]=r;try{Ke(r,i),n.success.push(t.name)}catch(l){n.failed.push({name:t.name,error:l instanceof Error?l:new Error(String(l))}),delete this.components[t.name]}}return n}async loadLazyComponent(e){return mt(e)}};export{z as $,st as a,ot as b,rt as c,nt as d,tt as e,W as f,U as g,it as h,mt as i,dt as j,gt as l};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ladrillosjs",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.6",
|
|
4
4
|
"description": "A lightweight, zero-dependency web component framework for building modular web applications.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -9,21 +9,36 @@
|
|
|
9
9
|
".": {
|
|
10
10
|
"types": "./dist/index.d.ts",
|
|
11
11
|
"default": "./dist/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./core": {
|
|
14
|
+
"types": "./dist/core.d.ts",
|
|
15
|
+
"default": "./dist/core.js"
|
|
16
|
+
},
|
|
17
|
+
"./lazy": {
|
|
18
|
+
"types": "./dist/lazy.d.ts",
|
|
19
|
+
"default": "./dist/lazy.js"
|
|
20
|
+
},
|
|
21
|
+
"./events": {
|
|
22
|
+
"types": "./dist/events.d.ts",
|
|
23
|
+
"default": "./dist/events.js"
|
|
12
24
|
}
|
|
13
25
|
},
|
|
14
26
|
"files": [
|
|
15
|
-
"dist
|
|
16
|
-
"dist
|
|
27
|
+
"dist/*.js",
|
|
28
|
+
"dist/*.d.ts"
|
|
17
29
|
],
|
|
18
30
|
"scripts": {
|
|
19
31
|
"build": "vite build --config vite.npm.config.ts",
|
|
20
32
|
"build:dev": "tsc -p tsconfig.json",
|
|
21
33
|
"dev": "tsc -p tsconfig.json -w",
|
|
22
34
|
"build:cdn": "vite build --config vite.cdn.config.ts",
|
|
23
|
-
"
|
|
35
|
+
"build:cdn:dev": "vite build --config vite.cdn.dev.config.ts",
|
|
36
|
+
"watch:cdn": "vite build --config vite.cdn.dev.config.ts --watch",
|
|
24
37
|
"serve:cdn": "npx serve dist-cdn -p 3000 --cors",
|
|
25
38
|
"dev:cdn": "concurrently \"npm run watch:cdn\" \"npm run serve:cdn\"",
|
|
26
39
|
"dev:dotnet": "concurrently \"npm run dev:cdn\" \"cd samples/dotnet-sample && dotnet watch run\"",
|
|
40
|
+
"verify:build": "node scripts/verify-treeshaking.js",
|
|
41
|
+
"build:all": "npm run build && npm run build:cdn && npm run verify:build",
|
|
27
42
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
28
43
|
},
|
|
29
44
|
"workspaces": [
|
|
@@ -40,7 +55,9 @@
|
|
|
40
55
|
},
|
|
41
56
|
"homepage": "https://github.com/drubiodev/LadrillosJS#readme",
|
|
42
57
|
"devDependencies": {
|
|
58
|
+
"@swc/core": "^1.15.8",
|
|
43
59
|
"concurrently": "^9.2.1",
|
|
60
|
+
"source-map-explorer": "^2.5.3",
|
|
44
61
|
"terser": "^5.44.1",
|
|
45
62
|
"typescript": "~5.9.3",
|
|
46
63
|
"vite": "^7.2.7",
|