diff --git a/sigpro/sigpro.js b/sigpro/sigpro.js index a14f410..73e8ee0 100644 --- a/sigpro/sigpro.js +++ b/sigpro/sigpro.js @@ -2,12 +2,14 @@ * SigPro Core */ (() => { + let activeEffect = null; let currentOwner = null; const effectQueue = new Set(); let isFlushing = false; const MOUNTED_NODES = new WeakMap(); + /** flush */ const flush = () => { if (isFlushing) return; isFlushing = true; @@ -19,6 +21,7 @@ isFlushing = false; }; + /** track */ const track = (subs) => { if (activeEffect && !activeEffect._deleted) { subs.add(activeEffect); @@ -26,6 +29,7 @@ } }; + /** trigger */ const trigger = (subs) => { for (const eff of subs) { if (eff === activeEffect || eff._deleted) continue; @@ -39,6 +43,56 @@ if (!isFlushing) queueMicrotask(flush); }; + /** sweep */ + const sweep = (node) => { + if (node._cleanups) { + node._cleanups.forEach((f) => f()); + node._cleanups.clear(); + } + node.childNodes?.forEach(sweep); + }; + + /** _view */ + const _view = (fn) => { + const cleanups = new Set(); + const prev = currentOwner; + const container = document.createElement("div"); + container.style.display = "contents"; + currentOwner = { cleanups }; + try { + const res = fn({ onCleanup: (f) => cleanups.add(f) }); + const process = (n) => { + if (!n) return; + if (n._isRuntime) { + cleanups.add(n.destroy); + container.appendChild(n.container); + } else if (Array.isArray(n)) n.forEach(process); + else container.appendChild(n instanceof Node ? n : document.createTextNode(String(n))); + }; + process(res); + } finally { currentOwner = prev; } + return { + _isRuntime: true, + container, + destroy: () => { + cleanups.forEach((f) => f()); + sweep(container); + container.remove(); + }, + }; + }; + + /** + * Creates a reactive Signal or a Computed Value. + * @param {any|Function} initial - Initial value or a getter function for computed state. + * @param {string} [key] - Optional. Key for automatic persistence in localStorage. + * @returns {Function} Signal getter/setter. Use `sig()` to read and `sig(val)` to write. + * @example + * const count = $(0); // Simple signal + * const double = $(() => count() * 2); // Computed signal + * const name = $("John", "user-name"); // Persisted signal + */ + const $ = (initial, key = null) => { if (typeof initial === "function") { const subs = new Set(); @@ -92,6 +146,17 @@ }; }; + /** + * Watches for signal changes and executes a side effect. + * Handles automatic cleanup of previous effects. + * @param {Function|Array} target - Function to execute or Array of signals for explicit dependency tracking. + * @param {Function} [fn] - If the first parameter is an Array, this is the callback function. + * @returns {Function} Function to manually stop the watcher. + * @example + * $watch(() => console.log("Count is:", count())); + * $watch([count], () => console.log("Only runs when count changes")); + */ + const $watch = (target, fn) => { const isExplicit = Array.isArray(target); const callback = isExplicit ? fn : target; @@ -145,42 +210,13 @@ return runner.stop; }; - const sweep = (node) => { - if (node._cleanups) { - node._cleanups.forEach((f) => f()); - node._cleanups.clear(); - } - node.childNodes?.forEach(sweep); - }; - - const _view = (fn) => { - const cleanups = new Set(); - const prev = currentOwner; - const container = document.createElement("div"); - container.style.display = "contents"; - currentOwner = { cleanups }; - try { - const res = fn({ onCleanup: (f) => cleanups.add(f) }); - const process = (n) => { - if (!n) return; - if (n._isRuntime) { - cleanups.add(n.destroy); - container.appendChild(n.container); - } else if (Array.isArray(n)) n.forEach(process); - else container.appendChild(n instanceof Node ? n : document.createTextNode(String(n))); - }; - process(res); - } finally { currentOwner = prev; } - return { - _isRuntime: true, - container, - destroy: () => { - cleanups.forEach((f) => f()); - sweep(container); - container.remove(); - }, - }; - }; + /** + * DOM element rendering engine with built-in reactivity. + * @param {string} tag - HTML tag name (e.g., 'div', 'span'). + * @param {Object} [props] - Attributes, events (onEvent), or two-way bindings (value, checked). + * @param {Array|any} [content] - Children: text, other nodes, or reactive signals. + * @returns {HTMLElement} The configured reactive DOM element. + */ const $html = (tag, props = {}, content = []) => { if (props instanceof Node || Array.isArray(props) || typeof props !== "object") { @@ -240,6 +276,14 @@ return el; }; + /** + * Conditional rendering component. + * @param {Function|boolean} condition - Reactive signal or boolean value. + * @param {Function|HTMLElement} thenVal - Content to show if true. + * @param {Function|HTMLElement} [otherwiseVal] - Content to show if false (optional). + * @returns {HTMLElement} A reactive container (display: contents). + */ + const $if = (condition, thenVal, otherwiseVal = null) => { const marker = document.createTextNode(""); const container = $html("div", { style: "display:contents" }, [marker]); @@ -261,6 +305,14 @@ $if.not = (condition, thenVal, otherwiseVal) => $if(() => !(typeof condition === "function" ? condition() : condition), thenVal, otherwiseVal); + /** + * Optimized reactive loop with key-based reconciliation. + * @param {Function|Array} source - Signal containing an Array of data. + * @param {Function} render - Function receiving (item, index) and returning a node. + * @param {Function} keyFn - Function to extract a unique key from the item. + * @returns {HTMLElement} A reactive container (display: contents). + */ + const $for = (source, render, keyFn) => { const marker = document.createTextNode(""); const container = $html("div", { style: "display:contents" }, [marker]); @@ -285,6 +337,12 @@ return container; }; + /** + * Hash-based (#) routing system. + * @param {Array<{path: string, component: Function}>} routes - Route definitions. + * @returns {HTMLElement} The router outlet container. + */ + const $router = (routes) => { const sPath = $(window.location.hash.replace(/^#/, "") || "/"); window.addEventListener("hashchange", () => sPath(window.location.hash.replace(/^#/, "") || "/")); @@ -321,6 +379,21 @@ $router.back = () => window.history.back(); $router.path = () => window.location.hash.replace(/^#/, "") || "/"; + /** + * Mounts a component or node into a DOM target element. + * It automatically handles the cleanup of any previously mounted SigPro instances + * in that target to prevent memory leaks and duplicate renders. + * * @param {Function|HTMLElement} component - The component function to render or a pre-built DOM node. + * @param {string|HTMLElement} target - A CSS selector string or a direct DOM element to mount into. + * @returns {Object|undefined} The view instance containing the `container` and `destroy` method, or undefined if target is not found. + * * @example + * // Mount using a component function + * $mount(() => Div({ class: "app" }, "Hello World"), "#root"); + * * // Mount using a direct element + * const myApp = Div("Hello"); + * $mount(myApp, document.getElementById("app")); + */ + const $mount = (component, target) => { const el = typeof target === "string" ? document.querySelector(target) : target; if (!el) return; @@ -331,6 +404,15 @@ return instance; }; + /* * Global API & DOM Tag Helpers Injection + * ------------------------------------------------ + * This block exposes the SigPro core API ($, $if, etc.) and auto-generates + * PascalCase helpers (Div, Span, Button) for all standard HTML tags. + * * - Uses Object.defineProperty to prevent accidental overwriting (read-only). + * - Enables a "Zero-Import" developer experience by attaching everything to 'window'. + * - Maps every helper directly to the $html factory for instant DOM creation. + */ + const core = { $, $if, $for, $watch, $mount, $router, $html }; for (const [name, fn] of Object.entries(core)) { @@ -341,10 +423,15 @@ }); } - const tags = `div span p h1 h2 h3 h4 h5 h6 br hr section article aside nav main header footer address ul ol li dl dt dd a em strong small i b u mark time sub sup pre code blockquote details summary dialog form label input textarea select button option fieldset legend table thead tbody tfoot tr th td caption img video audio canvas svg iframe picture source progress meter`.split(/\s+/); + /** HELPER TAGS */ + const tags = `div span p h1 h2 h3 h4 h5 h6 br hr section article aside nav main header footer address + ul ol li dl dt dd a em strong small i b u mark time sub sup pre code blockquote details summary dialog + form label input textarea select button option fieldset legend table thead tbody tfoot tr th td caption + img video audio canvas svg iframe picture source progress meter`.split(/\s+/); + tags.forEach((tagName) => { const helperName = tagName.charAt(0).toUpperCase() + tagName.slice(1); - + /** Protect Tags */ Object.defineProperty(window, helperName, { value: (props, content) => $html(tagName, props, content), writable: false, diff --git a/sigpro/sigpro.min.js b/sigpro/sigpro.min.js deleted file mode 100644 index dc5cf9c..0000000 --- a/sigpro/sigpro.min.js +++ /dev/null @@ -1 +0,0 @@ -(()=>{let e=null,t=null;const n=new Set;let o=!1;const r=new WeakMap,a=()=>{if(!o){for(o=!0;n.size>0;){const e=Array.from(n).sort(((e,t)=>(e.depth||0)-(t.depth||0)));n.clear();for(const t of e)t._deleted||t()}o=!1}},s=t=>{e&&!e._deleted&&(t.add(e),e._deps.add(t))},c=t=>{for(const o of t)o===e||o._deleted||(o._isComputed?(o.markDirty(),o._subs&&c(o._subs)):n.add(o));o||queueMicrotask(a)},l=(n,o=null)=>{if("function"==typeof n){const o=new Set;let r,a=!0;const l=()=>{if(l._deleted)return;l._deps.forEach((e=>e.delete(l))),l._deps.clear();const t=e;e=l;try{const s=n();Object.is(r,s)&&!a||(r=s,a=!1,c(o))}finally{e=t}};return l._deps=new Set,l._isComputed=!0,l._subs=o,l._deleted=!1,l.markDirty=()=>a=!0,l.stop=()=>{l._deleted=!0,l._deps.forEach((e=>e.delete(l))),o.clear()},t&&t.cleanups.add(l.stop),()=>(a&&l(),s(o),r)}let r=n;if(o){const e=localStorage.getItem(o);if(null!==e)try{r=JSON.parse(e)}catch{r=e}}const a=new Set;return(...e)=>{if(e.length){const t="function"==typeof e[0]?e[0](r):e[0];Object.is(r,t)||(r=t,o&&localStorage.setItem(o,JSON.stringify(r)),c(a))}return s(a),r}},d=(o,r)=>{const a=Array.isArray(o),s=a?r:o,c=a?o:null;if("function"!=typeof s)return()=>{};const l=t,d=()=>{if(d._deleted)return;d._deps.forEach((e=>e.delete(d))),d._deps.clear(),d._cleanups.forEach((e=>e())),d._cleanups.clear();const n=e,o=t;e=d,t={cleanups:d._cleanups},d.depth=n?n.depth+1:0;try{a?(e=null,s(),e=d,c.forEach((e=>"function"==typeof e&&e()))):s()}finally{e=n,t=o}};return d._deps=new Set,d._cleanups=new Set,d._deleted=!1,d.stop=()=>{d._deleted||(d._deleted=!0,n.delete(d),d._deps.forEach((e=>e.delete(d))),d._cleanups.forEach((e=>e())),l&&l.cleanups.delete(d.stop))},l&&l.cleanups.add(d.stop),d(),d.stop},i=e=>{e._cleanups&&(e._cleanups.forEach((e=>e())),e._cleanups.clear()),e.childNodes?.forEach(i)},u=e=>{const n=new Set,o=t,r=document.createElement("div");r.style.display="contents",t={cleanups:n};try{const a=e({onCleanup:e=>n.add(e)}),s=e=>{e&&(e._isRuntime?(n.add(e.destroy),r.appendChild(e.container)):Array.isArray(e)?e.forEach(s):r.appendChild(e instanceof Node?e:document.createTextNode(String(e))))};s(a)}finally{t=o}return{_isRuntime:!0,container:r,destroy:()=>{n.forEach((e=>e())),i(r),r.remove()}}},p=(e,t={},n=[])=>{(t instanceof Node||Array.isArray(t)||"object"!=typeof t)&&(n=t,t={});const o=document.createElement(e);o._cleanups=new Set;for(let[e,n]of Object.entries(t)){const t="function"==typeof n,r=["INPUT","TEXTAREA","SELECT"].includes(o.tagName),a="value"===e||"checked"===e;if(r&&a&&t){o._cleanups.add(d((()=>{const t=n();o[e]!==t&&(o[e]=t)})));const t="checked"===e?"change":"input",r=t=>n(t.target[e]);o.addEventListener(t,r),o._cleanups.add((()=>o.removeEventListener(t,r)))}else if(e.startsWith("on")){const t=e.slice(2).toLowerCase().split(".")[0],r=e=>n(e);o.addEventListener(t,r),o._cleanups.add((()=>o.removeEventListener(t,r)))}else t?o._cleanups.add(d((()=>{const t=n();"class"===e?o.className=t||"":null==t?o.removeAttribute(e):o.setAttribute(e,t)}))):o.setAttribute(e,n)}const r=e=>{if(Array.isArray(e))return e.forEach(r);if("function"==typeof e){const t=document.createTextNode("");o.appendChild(t);let n=[];o._cleanups.add(d((()=>{const o=e(),r=(Array.isArray(o)?o:[o]).map((e=>e?._isRuntime?e.container:e instanceof Node?e:document.createTextNode(e??"")));n.forEach((e=>{i(e),e.remove()})),r.forEach((e=>t.parentNode?.insertBefore(e,t))),n=r})))}else o.appendChild(e instanceof Node?e:document.createTextNode(e??""))};return r(n),o},f=(e,t,n=null)=>{const o=document.createTextNode(""),r=p("div",{style:"display:contents"},[o]);let a=null,s=null;return d((()=>{const c=!!("function"==typeof e?e():e);if(c!==s){s=c,a&&a.destroy();const e=c?t:n;e&&(a=u((()=>"function"==typeof e?e():e)),r.insertBefore(a.container,o))}})),r};f.not=(e,t,n)=>f((()=>!("function"==typeof e?e():e)),t,n);const h=e=>{const t=l(window.location.hash.replace(/^#/,"")||"/");window.addEventListener("hashchange",(()=>t(window.location.hash.replace(/^#/,"")||"/")));const n=Div({class:"router-outlet"});let o=null;return d([t],(()=>{o&&o.destroy();const r=t(),a=e.find((e=>{const t=e.path.split("/").filter(Boolean),n=r.split("/").filter(Boolean);return t.length===n.length&&t.every(((e,t)=>e.startsWith(":")||e===n[t]))}))||e.find((e=>"*"===e.path));if(a){const e={};a.path.split("/").filter(Boolean).forEach(((t,n)=>{t.startsWith(":")&&(e[t.slice(1)]=r.split("/").filter(Boolean)[n])})),h.params&&h.params(e),o=u((()=>{const t=a.component(e);return"function"==typeof t?t():t})),n.appendChild(o.container)}})),n};h.params=l({}),h.to=e=>window.location.hash=e.replace(/^#?\/?/,"#/"),h.back=()=>window.history.back(),h.path=()=>window.location.hash.replace(/^#/,"")||"/";const y={$:l,$if:f,$for:(e,t,n)=>{const o=document.createTextNode(""),r=p("div",{style:"display:contents"},[o]),a=new Map;return d((()=>{const s=("function"==typeof e?e():e)||[],c=new Set;s.forEach(((e,s)=>{const l=n(e,s);c.add(l);let d=a.get(l);d||(d=u((()=>t(e,s))),a.set(l,d)),r.insertBefore(d.container,o)})),a.forEach(((e,t)=>{c.has(t)||(e.destroy(),a.delete(t))}))})),r},$watch:d,$mount:(e,t)=>{const n="string"==typeof t?document.querySelector(t):t;if(!n)return;r.has(n)&&r.get(n).destroy();const o=u("function"==typeof e?e:()=>e);return n.replaceChildren(o.container),r.set(n,o),o},$router:h,$html:p};for(const[e,t]of Object.entries(y))Object.defineProperty(window,e,{value:t,writable:!1,configurable:!1});"div span p h1 h2 h3 h4 h5 h6 br hr section article aside nav main header footer address ul ol li dl dt dd a em strong small i b u mark time sub sup pre code blockquote details summary dialog form label input textarea select button option fieldset legend table thead tbody tfoot tr th td caption img video audio canvas svg iframe picture source progress meter".split(/\s+/).forEach((e=>{const t=e.charAt(0).toUpperCase()+e.slice(1);Object.defineProperty(window,t,{value:(t,n)=>p(e,t,n),writable:!1,configurable:!0,enumerable:!0})}))})();export const{$:$,$watch:$watch,$html:$html,$if:$if,$for:$for,$router:$router,$mount:$mount}=window; \ No newline at end of file diff --git a/ui/sigpro-ui.min.js b/ui/sigpro-ui.min.js deleted file mode 100644 index b5d5a2b..0000000 --- a/ui/sigpro-ui.min.js +++ /dev/null @@ -1 +0,0 @@ -import{$,$if,$for,$watch,$html,$mount}from"sigpro.js";export const UI=(t="es")=>{const l={},e={es:{close:"Cerrar",confirm:"Confirmar",cancel:"Cancelar",search:"Buscar...",loading:"Cargando..."},en:{close:"Close",confirm:"Confirm",cancel:"Cancel",search:"Search...",loading:"Loading..."}},a=$(t);l.SetLocale=t=>a(t);const s=t=>()=>e[a()][t]||t,A=t=>"function"==typeof t?t():t,n=(t,l)=>"function"==typeof l?()=>`${t} ${l()||""}`.trim():`${t} ${l||""}`.trim(),o="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAAdgAAAHYBTnsmCAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAACLSURBVDiN7dO9CQJBFEXhb38K0FwQrMNEVpuwB0NjrcYabECsQk0sQ1mTF4zIjrgmBh54MMx998AEwzOrmC5e8gJjbDHCJO7PHYI0v2JT4Ig9DljGwq5DkOZTLOCOMoIhBpknpHmFWx3ldaaUo6oTc2/ab7rl+508f8GvCC5oenTn4tM1cWg/nBNmD4fBH/Kfvt2TAAAAAElFTkSuQmCC",c="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAACXBIWXMAAAnXAAAJ1wGxbhe3AAAAGXRFWHRTb2Z0d2FyZQB3d3cuaW5rc2NhcGUub3Jnm+48GgAAASVJREFUOI190r0uhFEQBuBnVxaF2PUTCkFchV0SV6BQi0rEbShFlCqNktJP0Iqf3i3YVSlXVEQozojP8e2+ySSTed+ZMzNnKnpjCFPhv+C9j/YPlnCBV3TCujhHq19iFftoYxOjBa4esTb2QvsP+7jFWJ9HxnEXRf5gGU9Z8gKucBl+sUgHTahE8AJnOCoIT/AcmhmsF7gtrGINBqWFFWcmLXMUhzjIuEbk1GA+2i/DNh4wUsK1MVfFV2GUHJO4xlsPHr8j1Eu44bAcDek2agP4lDZaxWMm3MEKbrL4hjT/8U+gJc00nglnw4qYkL5xMW9rTzqSvEiefI/dMrIaRTrSPzcKXCNinUguPeUfNKWj6kqH9Bz+aVnbvb6PtKTp8F/wUSb6Bu5YN5n7ff0kAAAAAElFTkSuQmCC",i="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAACXBIWXMAAAnXAAAJ1wGxbhe3AAAAGXRFWHRTb2Z0d2FyZQB3d3cuaW5rc2NhcGUub3Jnm+48GgAAAQtJREFUOI2F0jFOAlEQBuAPImoFqyTa6TEEbfUihruYDYfwCAg3UDsTY20na0VjgqUWWuxgHsuy/skk82bmn/fPm9eyHXs4Cn+Br4baNZxjhk8UYUtMMWwitjHGHNfoJrlexObIo3YDY9zjoOGSQzxEkzVc4O0fctqkwCANzkJiE9LmI9ytDrvKB+tWGQnylIAsOB04VcrfdluO55CeYo6THfygVUne4jX8S1zho1LTDu7fCL2KxCe8oF8zUqb8G51VYGrzEffD6jDCJA0MY6bqnHXoK9d4Vk3kyk/S1KSPR9zUJdvRpAiJWZLLIlYEufYrrzBQ7nyJ97ClcuYN2dX1pejgOPwFvuuKfgHXiDR+HL1j1AAAAABJRU5ErkJggg==",r="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAACXBIWXMAAAnXAAAJ1wGxbhe3AAAAGXRFWHRTb2Z0d2FyZQB3d3cuaW5rc2NhcGUub3Jnm+48GgAAARZJREFUOI2V0j1KQ1EQBeDPp4lWRiMoKVyAK9AoiLgJGytxD9oJNhKyDyvBnw2IugC3YGKVRk1KRbR48yC5vjzwwIHL3DPnzp2ZGdMxj9U4D/BZoZ3ANu4wQj84xC3aVYkZuujhCItjd42I9dAJ7R908YDlikeaeAyTCezgpST5IJia9LFVlA0nOMd7It4IjuMttKeFQR17uKooPcUV9lHL0ArX0T8MPqLa1hx+MDNFWDX7LHLV4/VGiWghmGJJvhu1WXzLO5rhORGeYRf3SfwQNVwWgbZ8SZqJcD04jhX5GDfTsjryJUlN0uQnXJRdZmHSx7H8nwWWItaP5NJVLrCFG3mTXoNDXJeVPW185E1ai/MAX2WiX9S3NSPYbj+uAAAAAElFTkSuQmCC",d="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAACXBIWXMAAAnXAAAJ1wGxbhe3AAAAGXRFWHRTb2Z0d2FyZQB3d3cuaW5rc2NhcGUub3Jnm+48GgAAARJJREFUOI2l0r8uRFEQBvAfu9glwUYiUaxHUEl0VDpKeq+wpZBINAqFRHgTKg0tCSqVhmKDEM1u/Esodm725rq7iC+ZzMnM982ZmXP4JwpdchWsYBrXeMkj9XQQV3GEi+BMYR63v+mqiDPUUrEaTiP3I1ZxEOcySnE+jFxXVPEQPimWiCYzOdCbKbCFPe1Z+8PgBvvBycVMCIdSsY2wBEPBmcnrYBtraKRib2EJGljHjswLLuI8Z6SS9hLTl15iIR08wZLv2AzLYjk0YATP8n9lVWbrgUJohosYxCdG8Zghdvp5ldCUi6hrPd0VjvGEVzTxEYLkogGMYQ67uEtvcgKzGA8y9IV/D9/Evdb89Q7d/Q1fB8U0mpUmzV0AAAAASUVORK5CYII=";return l.Request=(t,l=null,e={})=>{const a=$(null),s=$(!1),n=$(null),o=$(!1);let c=null;const i=async(i=null)=>{const r=A(t);if(r){c&&c.abort(),c=new AbortController,s(!0),n(null),o(!1);try{const t=i||l,A=await fetch(r,{method:e.method||(t?"POST":"GET"),headers:{"Content-Type":"application/json",...e.headers},body:t?JSON.stringify(t):null,signal:c.signal,...e});if(!A.ok)throw new Error(`HTTP ${A.status}`);let n=await A.json();"function"==typeof e.transform&&(n=e.transform(n)),a(n),o(!0)}catch(t){"AbortError"!==t.name&&n(t.message)}finally{s(!1)}}};return $((()=>(i(),()=>c?.abort()))),{data:a,loading:s,error:n,success:o,reload:t=>i(t)}},l.Response=(t,e)=>$html("div",{class:"res-container"},[$if(t.loading,$html("div",{class:"flex justify-center p-4"},$html("span",{class:"loading loading-dots text-primary"}))),$if(t.error,(()=>$html("div",{role:"alert",class:"alert alert-error"},[$html("span",{},t.error()),l.Button({class:"btn-xs btn-ghost border-current",onclick:()=>t.reload()},"Retry")]))),$if(t.success,(()=>{const l=t.data();return null!==l?e(l):null}))]),l.Button=(t,l)=>{const{badge:e,badgeClass:a,tooltip:s,icon:o,loading:c,...i}=t;let r=$html("button",{...i,class:n("btn",t.class||t.class),disabled:()=>A(c)||A(t.disabled)||A(t.disabled)},[()=>A(c)?$html("span",{class:"loading loading-spinner"}):null,o?$html("span",{class:"mr-1"},o):null,l]);return e&&(r=$html("div",{class:"indicator"},[$html("span",{class:n("indicator-item badge",a||"badge-secondary")},e),r])),s?$html("div",{class:"tooltip","data-tip":s},r):r},l.Input=t=>{const{label:l,tip:e,value:a,error:c,isSearch:i,icon:r,type:d="text",...m}=t,h="password"===d,u=$(!1),g={text:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAACXBIWXMAAAB2AAAAdgFOeyYIAAAAGXRFWHRTb2Z0d2FyZQB3d3cuaW5rc2NhcGUub3Jnm+48GgAAAMRJREFUOI3t0bFKAmAUBeAPURD1HQwUTKPJEmzQoSWQcKpVfIuWdvU9WnqNhsYWBx0a2lvLSMKGbvQ7SO564HA497/3cu/92SPFAS5QDN9CftviDhZYYRpNPtH/rzATOsQT6jhCFzmc4DTJL6AX067hPiimuAr95RglzMJ/4AyyUXSMw3iEauhN6C0eUEMFAyzTFZ7xiOvwL3jbsPYSr3hPg3dB/o43SVYY+TnsPPwXztMG5SDr39dGM8kr4RKNDdPtJL4BNXEmsdKC+S4AAAAASUVORK5CYII=",password:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAAWQAAAFkBqp2phgAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAACQSURBVDiN7dKxDcJQDATQJ0YgXQQ1bAgDEIZBETPQwjakIjRQ8CMSyR8SiZKTrvHZd/r+JsYSNZrEI1ZR4ywzfElcJ55xwiITOECNTVDf4jDGoEEZ1Etcxxg8pmjRDiahb7BH20uKKPVUkVmL+YjQArdI+PT2bO9Pd/A34O71Rd9QeN/LAFUSckfUscWuG3oCgP8nrDH6T5AAAAAASUVORK5CYII=",date:o,number:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAACXBIWXMAAAB2AAAAdgFOeyYIAAAAGXRFWHRTb2Z0d2FyZQB3d3cuaW5rc2NhcGUub3Jnm+48GgAAAMxJREFUOI3t0bFKwlEUBvBfmmBEr1APIDZJ9AJJQyAIvkGP0C4uQruza+DUmuIc9AC9gBG4Nmpkw/8IB3Vw1w8u95zvnvPde77LEeUUV9HAF67QRA2nmMf5A+o4x3cWOsMYy8j7WMX6jaYbLBL/mAWe8RcHm1ihs8G94gVKQQzwlAouMcQo8p/Y28HdYpYFZmsi0MVdxD1MdrxsC500wijdvgtbI1AYtDbxMwkuFAZmE1uYwkkSqOIaHyHcxEU0vUXNPSqKr37fZ6xDwD9DPS0OyHjQHQAAAABJRU5ErkJggg==",email:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAAdgAAAHYBTnsmCAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAC4SURBVDiNxdIxagJRFIXhLzLFBNJYaJslSEylWOhq3IorMGQ16SyjYCFiZWU5pTaDFvOUyTAZ8RHID69555577oXLf/OEGaY4R3g/4IhORHg3eOXYYvSAeRQ8OWQYYoNPvDQYnxUr7zBB1grCAv3QbIlxjXmAb7Txhq+rkFUKq9NUU8vcJiizwDtOWGEdmvTKqT+61H0GXsP7jSxpEGF/R1e3wkO0FBeVRnhTSBTneBB3yvOI4D/mAnvrIwKM5s4AAAAAAElFTkSuQmCC"},b=$html("input",{...m,type:()=>h?u()?"text":"password":d,placeholder:t.placeholder||l||(i?s("search")():" "),class:n("grow order-2 focus:outline-none",t.class),value:a,oninput:l=>t.oninput?.(l),disabled:()=>A(t.disabled)}),p=r||(g[d]?$html("img",{src:g[d],class:"w-5 h-5 opacity-50",alt:d}):null);return $html("label",{class:()=>n("input input-bordered floating-label flex items-center gap-2 w-full relative",A(c)?"input-error":"")},[p?$html("div",{class:"order-1 shrink-0"},p):null,l?$html("span",{class:"text-base-content/60 order-0"},l):null,b,h?$html("button",{type:"button",class:"order-3 btn btn-ghost btn-xs btn-circle opacity-50 hover:opacity-100",onclick:t=>{t.preventDefault(),u(!u())}},(()=>$html("img",{class:"w-5 h-5",src:u()?"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAAdgAAAHYBTnsmCAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAADjSURBVDiN3dJNSgNBEAXgz4DZeAAVJ9tko2St3kaIFxAVt4KZeAD1GKKi7vQSydI/yHgALxAXU02GxniAFBR0v1ev+3V1sZSxjxtM8BM5wTX2/hNu4gFvOMI21iJ3cIwP3GMjF/dQ4RyraOMS34GPAmvjIrBeEnfwjoPGgSM8ooh8QtngB6Ep4BWnmaMqkY1LqqzmDC8tzNDK3/RHzLL9SloUYWfQIMuw3Yl8xrDBH6qbvZWALqbqBqVmlWF7GuKEDwPr5hbXcYdPnKBv/o39wL5wG7ULY1c9NGPzQRrjKrhli1/02zEjWyWMBwAAAABJRU5ErkJggg==":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAAdgAAAHYBTnsmCAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAEDSURBVDiN1dK/K8VhFAbwD+VLGSxKcu9guSQ/Zils/gNkuaX4BxRZDTdklYU/QAaDlEVGGwu2Kz/uVbKJzWDwfuv1+jHz1Km3c85znuf0Hv4jxnD2W8MItnCJ5xAX2MQcHsOQL+jEAapYQD9aQwxiDy+B3JKSe1DHCpqQYQ0PeMJOpDyAmyAAirjGbDRwFYcoYCZSzjGP+8B1gqXEUT2QxyPlqaRnGceNeENzUswwil1MBocbSU9DCAXUUI6K25HtIo5QSVaooitP9OEO65iIbE+HXSvBVRbeNZQSR9pxGil3o83HNw5hEbfYR0dKFki5ci+u8OrzIQ1/R8xx7ocL+9t4B0HPOVXjoptxAAAAAElFTkSuQmCC"}))):null,e?$html("div",{class:"tooltip tooltip-left order-4","data-tip":e},$html("span",{class:"badge badge-ghost badge-xs cursor-help"},"?")):null,()=>A(c)?$html("span",{class:"text-error text-[10px] absolute -bottom-5 left-2"},A(c)):null])},l.Select=t=>{const{label:l,options:e,value:a,...s}=t,o=$html("select",{...s,class:n("select select-bordered w-full",t.class||t.class),value:a},$for((()=>A(e)||[]),(t=>$html("option",{value:t.value,$selected:()=>String(A(a))===String(t.value)},t.label)),(t=>t.value)));return l?$html("label",{class:"fieldset-label flex flex-col gap-1"},[$html("span",{},l),o]):o},l.Autocomplete=t=>{const{options:e=[],value:a,onSelect:n,label:o,placeholder:c,...i}=t,r=$(A(a)||""),d=$(!1),m=$(-1),h=$((()=>{const t=r().toLowerCase(),l=A(e)||[];return t?l.filter((l=>("string"==typeof l?l:l.label).toLowerCase().includes(t))):l})),u=t=>{const l="string"==typeof t?t:t.value,e="string"==typeof t?t:t.label;r(e),"function"==typeof a&&a(l),n?.(t),d(!1),m(-1)};return $html("div",{class:"relative w-full"},[l.Input({label:o,placeholder:c||s("search")(),value:r,onfocus:()=>d(!0),onblur:()=>setTimeout((()=>d(!1)),150),onkeydown:t=>{const l=h();"ArrowDown"===t.key?(t.preventDefault(),d(!0),m(Math.min(m()+1,l.length-1))):"ArrowUp"===t.key?(t.preventDefault(),m(Math.max(m()-1,0))):"Enter"===t.key&&m()>=0?(t.preventDefault(),u(l[m()])):"Escape"===t.key&&d(!1)},oninput:t=>{const l=t.target.value;r(l),"function"==typeof a&&a(l),d(!0),m(-1)},...i}),$html("ul",{class:"absolute left-0 w-full menu bg-base-100 rounded-box mt-1 p-2 shadow-xl max-h-60 overflow-y-auto border border-base-300 z-50",style:()=>d()&&h().length?"display:block":"display:none"},[$for(h,((t,l)=>$html("li",{},[$html("a",{class:()=>"block w-full "+(m()===l?"active bg-primary text-primary-content":""),onclick:()=>u(t),onmouseenter:()=>m(l)},"string"==typeof t?t:t.label)])),((t,l)=>("string"==typeof t?t:t.value)+l)),()=>h().length?null:$html("li",{class:"p-2 text-center opacity-50"},"No results")])])},l.Datepicker=t=>{const{value:e,range:a,label:s,placeholder:n,...c}=t,i=$(!1),r=$(new Date),d=$(null),m=()=>!0===A(a),h=new Date,u=`${h.getFullYear()}-${String(h.getMonth()+1).padStart(2,"0")}-${String(h.getDate()).padStart(2,"0")}`,g=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`,b=t=>{const l=g(t),a=A(e);if(m())if(!a?.start||a.start&&a.end)"function"==typeof e&&e({start:l,end:null});else{const t=a.start;"function"==typeof e&&e(l{const t=A(e);return t?"string"==typeof t?t:t.start&&t.end?`${t.start} - ${t.end}`:t.start?`${t.start}...`:"":""})),f=t=>{const l=r();r(new Date(l.getFullYear(),l.getMonth()+t,1))},v=t=>{const l=r();r(new Date(l.getFullYear()+t,l.getMonth(),1))};return $html("div",{class:"relative w-full"},[l.Input({label:s,placeholder:n||(m()?"Seleccionar rango...":"Seleccionar fecha..."),value:p,readonly:!0,icon:$html("img",{src:o,class:"opacity-40"}),onclick:t=>{t.stopPropagation(),i(!i())},...c}),$if(i,(()=>$html("div",{class:"absolute left-0 mt-2 p-4 bg-base-100 border border-base-300 shadow-2xl rounded-box z-[100] w-80 select-none",onclick:t=>t.stopPropagation()},[$html("div",{class:"flex justify-between items-center mb-4 gap-1"},[$html("div",{class:"flex gap-0.5"},[$html("button",{type:"button",class:"btn btn-ghost btn-xs px-1",onclick:()=>v(-1)},$html("img",{src:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAAdgAAAHYBTnsmCAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAABlSURBVDiN3ZLBDUBAEEUfmtCchA5woUMlOO1FCQrAwbqwf8eFhHd7mfzJn2Tg82TGvABywAmPUgOLD4XcDK9AJ/y5cOlrNsIvpCdPDL/FUbkX/t6Slv3+SjgQf6QBmIAZGAP+FzZJViOd89x8pAAAAABJRU5ErkJggg==",class:"opacity-40"})),$html("button",{type:"button",class:"btn btn-ghost btn-xs px-1",onclick:()=>f(-1)},$html("img",{src:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAAdgAAAHYBTnsmCAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAABfSURBVDiNY2AY8oCZSHWxDAwMEgwMDHfJsaSAgYHhH9QQsjT/Z2BgKKe75gQGiLMLCSlkwiHOSI6t6ADmhYoBN6SIARIeidgkiUlIxxkYGB4xMDB8YmBguE6JSwYpAACvLRHTKwPjZgAAAABJRU5ErkJggg==",class:"opacity-40"}))]),$html("span",{class:"font-bold uppercase flex-1 text-center"},[()=>r().toLocaleString("es-ES",{month:"short",year:"numeric"})]),$html("div",{class:"flex gap-0.5"},[$html("button",{type:"button",class:"btn btn-ghost btn-xs px-1",onclick:()=>f(1)},$html("img",{src:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAAdgAAAHYBTnsmCAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAABNSURBVDiN3dAxCoAwFATRh3fU2oAHiDbi5Y1F2jT+gKLbzyy7/DYjUo8g4cTWI8koOF6XrOqc5ifDDVGJthfsj8OLujtHYJgwR+GP5QKMxA9/SolDQgAAAABJRU5ErkJggg==",class:"opacity-40"})),$html("button",{type:"button",class:"btn btn-ghost btn-xs px-1",onclick:()=>v(1)},$html("img",{src:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAAdgAAAHYBTnsmCAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAABmSURBVDiN3dGxCoAgEMbxfz1dL1BTREJzmUv08trgDYcg6VCD3/YD7zvkoLmMgFEegLmmwAAecOJVvNeUWCAAt7IHjt9LThkyiRf9qC8oCom70u0BuDL+bngj/tNm/JqJePucW8wDvGYdzT0nMUkAAAAASUVORK5CYII=",class:"opacity-40"}))])]),$html("div",{class:"grid grid-cols-7 gap-1",onmouseleave:()=>d(null)},[...["L","M","X","J","V","S","D"].map((t=>$html("div",{class:"text-[10px] opacity-40 font-bold text-center"},t))),()=>{const t=r(),l=t.getFullYear(),a=t.getMonth(),s=new Date(l,a,1).getDay(),n=0===s?6:s-1,o=new Date(l,a+1,0).getDate(),c=[];for(let t=0;t{const t=A(e),l=d(),a="string"==typeof t?t===n:t?.start===n,s=t?.end===n;let o=!1;if(m()&&t?.start){const e=t.start;!t.end&&l?o=n>e&&n<=l||n=l:t.end&&(o=n>e&&n{m()&&d(n)},onclick:()=>b(s)},[t.toString()]))}return c}])]))),$if(i,(()=>$html("div",{class:"fixed inset-0 z-[90]",onclick:()=>i(!1)})))])},l.Colorpicker=t=>{const{value:l,label:e,...a}=t,s=$(!1),n=["#000","#1A1A1A","#333","#4D4D4D","#666","#808080","#B3B3B3","#FFF","#450a0a","#7f1d1d","#991b1b","#b91c1c","#dc2626","#ef4444","#f87171","#fca5a5","#431407","#7c2d12","#9a3412","#c2410c","#ea580c","#f97316","#fb923c","#ffedd5","#713f12","#a16207","#ca8a04","#eab308","#facc15","#fde047","#fef08a","#fff9c4","#064e3b","#065f46","#059669","#10b981","#34d399","#4ade80","#84cc16","#d9f99d","#082f49","#075985","#0284c7","#0ea5e9","#38bdf8","#7dd3fc","#22d3ee","#cffafe","#1e1b4b","#312e81","#4338ca","#4f46e5","#6366f1","#818cf8","#a5b4fc","#e0e7ff","#2e1065","#4c1d95","#6d28d9","#7c3aed","#8b5cf6","#a855f7","#d946ef","#fae8ff"],o=()=>A(l)||"#000000";return $html("div",{class:"relative w-fit"},[$html("button",{type:"button",class:"btn px-3 bg-base-100 border-base-300 hover:border-primary/50 flex items-center gap-2 shadow-sm font-normal normal-case",onclick:t=>{t.stopPropagation(),s(!s())},...a},[$html("div",{class:"size-5 rounded-sm shadow-inner border border-black/10 shrink-0",style:()=>`background-color: ${o()}`}),e?$html("span",{class:"opacity-80"},e):null]),$if(s,(()=>$html("div",{class:"absolute left-0 mt-2 p-3 bg-base-100 border border-base-300 shadow-2xl rounded-box z-[110] w-64 select-none",onclick:t=>t.stopPropagation()},[$html("div",{class:"grid grid-cols-8 gap-1"},n.map((t=>$html("button",{type:"button",style:`background-color: ${t}`,class:()=>"size-6 rounded-sm cursor-pointer transition-all hover:scale-125 hover:z-10 active:scale-95 outline-none border border-black/5 \n "+(o().toLowerCase()===t.toLowerCase()?"ring-2 ring-offset-1 ring-primary z-10 scale-110":""),onclick:()=>{l(t),s(!1)}}))))]))),$if(s,(()=>$html("div",{class:"fixed inset-0 z-[100]",onclick:()=>s(!1)})))])},l.CheckBox=t=>{const{value:l,tooltip:e,toggle:a,...s}=t,n=$html("input",{...s,type:"checkbox",class:()=>A(a)?"toggle":"checkbox",checked:l}),o=$html("label",{class:"label cursor-pointer justify-start gap-3"},[n,t.label?$html("span",{class:"label-text"},t.label):null]);return e?$html("div",{class:"tooltip","data-tip":e},o):o},l.Radio=t=>{const{label:l,tooltip:e,value:a,...s}=t,o=$html("input",{...s,type:"radio",class:n("radio",t.class||t.class),checked:()=>A(a)===a,disabled:()=>A(t.disabled)||A(t.disabled),onclick:()=>"function"==typeof a&&a(a)});if(!l&&!e)return o;const c=$html("label",{class:"label cursor-pointer justify-start gap-3"},[o,l?$html("span",{class:"label-text"},l):null]);return e?$html("div",{class:"tooltip","data-tip":e},c):c},l.Range=t=>{const{label:l,tooltip:e,value:a,...s}=t,o=$html("input",{...s,type:"range",class:n("range",t.class),value:a,disabled:()=>A(t.disabled)});if(!l&&!e)return o;const c=$html("div",{class:"flex flex-col gap-2"},[l?$html("span",{class:"label-text"},l):null,o]);return e?$html("div",{class:"tooltip","data-tip":e},c):c},l.Modal=(t,e)=>{const{title:a,buttons:A,open:n,...o}=t,c=()=>n(!1);return $if(n,(()=>$html("dialog",{...o,class:"modal modal-open"},[$html("div",{class:"modal-box"},[a?$html("h3",{class:"text-lg font-bold mb-4"},a):null,"function"==typeof e?e():e,$html("div",{class:"modal-action flex gap-2"},[...(Array.isArray(A)?A:[A]).filter(Boolean),l.Button({onclick:c},s("close")())])]),$html("form",{method:"dialog",class:"modal-backdrop",onclick:t=>(t.preventDefault(),c())},[$html("button",{},"close")])])))},l.Grid=t=>{const{data:l,options:e,class:a}=t;let s=null;const n=$html("div",{style:"height: 100%; width: 100%;",class:a}),o=new MutationObserver((()=>{s&&s.setGridOption("theme",getTheme(isDark()))}));o.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),n._cleanups.add((()=>o.disconnect()));const c=$watch((()=>{const t=isDark(),a=getTheme(t),o=A(l)||[];s?s.setGridOption("theme",a):s=createGrid(n,{...A(e)||{},theme:a,rowData:o})}));n._cleanups.add(c);const i=$watch((()=>{const t=A(l);s&&Array.isArray(t)&&s.setGridOption("rowData",t)}));return n._cleanups.add(i),n._cleanups.add((()=>{s&&(s.destroy(),s=null)})),n},l.Dropdown=(t,l)=>{const{label:e,icon:a,...s}=t;return $html("div",{...s,class:()=>`dropdown ${A(t.class)||t.class||""}`},[$html("div",{tabindex:0,role:"button",class:"btn m-1 flex items-center gap-2"},[a?"function"==typeof a?a():a:null,e?"function"==typeof e?e():e:null]),$html("ul",{tabindex:0,class:"dropdown-content z-[50] menu p-2 shadow bg-base-100 rounded-box min-w-max border border-base-300"},["function"==typeof l?l():l])])},l.Accordion=(t,l)=>{const{title:e,name:a,open:s,...A}=t;return $html("div",{...A,class:n("collapse collapse-arrow bg-base-200 mb-2",t.class||t.class)},[$html("input",{type:a?"radio":"checkbox",name:a,checked:s}),$html("div",{class:"collapse-title text-xl font-medium"},e),$html("div",{class:"collapse-content"},l)])},l.Tabs=t=>{const{items:l,...e}=t,a="function"==typeof l?l:()=>l||[];return $html("div",{...e,class:"flex flex-col gap-4 w-full"},[$html("div",{role:"tablist",class:n("tabs tabs-box",t.class||t.class)},$for(a,(t=>$html("a",{role:"tab",class:()=>n("tab",A(t.active)&&"tab-active",A(t.disabled),t.tip),"data-tip":t.tip,onclick:l=>!A(t.disabled)&&t.onclick?.(l)},t.label)),(t=>t.label))),()=>{const t=a().find((t=>A(t.active)));if(!t)return null;const l=A(t.content);return $html("div",{class:"p-4"},["function"==typeof l?l():l])}])},l.Badge=(t,l)=>$html("span",{...t,class:n("badge",t.class||t.class)},l),l.Tooltip=(t,l)=>$html("div",{...t,class:n("tooltip",t.class||t.class),"data-tip":t.tip},l),l.Navbar=(t,l)=>$html("div",{...t,class:n("navbar bg-base-100 shadow-sm px-4",t.class||t.class)},l),l.Menu=t=>{const l=t=>$for((()=>t||[]),(t=>$html("li",{},[t.children?$html("details",{open:t.open},[$html("summary",{},[t.icon&&$html("span",{class:"mr-2"},t.icon),t.label]),$html("ul",{},l(t.children))]):$html("a",{class:()=>A(t.active)?"active":"",onclick:t.onclick},[t.icon&&$html("span",{class:"mr-2"},t.icon),t.label])])),((t,l)=>t.label||l));return $html("ul",{...t,class:n("menu bg-base-200 rounded-box",t.class||t.class)},l(t.items))},l.Drawer=t=>$html("div",{class:n("drawer",t.class||t.class)},[$html("input",{id:t.id,type:"checkbox",class:"drawer-toggle",checked:t.open}),$html("div",{class:"drawer-content"},t.content),$html("div",{class:"drawer-side"},[$html("label",{for:t.id,class:"drawer-overlay",onclick:()=>t.open?.(!1)}),$html("div",{class:"min-h-full bg-base-200 w-80"},t.side)])]),l.Fieldset=(t,l)=>$html("fieldset",{...t,class:n("fieldset bg-base-200 border border-base-300 p-4 rounded-lg",t.class||t.class)},[()=>{const l=A(t.legend);return l?$html("legend",{class:"fieldset-legend font-bold"},[l]):null},l]),l.List=t=>{const{items:l,header:e,render:a,keyFn:s,class:o}=t;return $html("ul",{class:n("list bg-base-100 rounded-box shadow-md",o)},[$if(e,(()=>$html("li",{class:"p-4 pb-2 text-xs opacity-60 tracking-wide"},[A(e)]))),$for(l,((t,l)=>$html("li",{class:"list-row"},[a(t,l)])),s)])},l.Stack=(t,l)=>$html("div",{...t,class:n("stack",t.class||t.class)},l),l.Stat=t=>$html("div",{...t,class:n("stat",t.class||t.class)},[t.icon&&$html("div",{class:"stat-figure text-secondary"},t.icon),t.label&&$html("div",{class:"stat-title"},t.label),$html("div",{class:"stat-value"},(()=>A(t.value)??t.value)),t.desc&&$html("div",{class:"stat-desc"},t.desc)]),l.Swap=t=>$html("label",{class:n("swap",t.class||t.class)},[$html("input",{type:"checkbox",checked:t.value}),$html("div",{class:"swap-on"},t.on),$html("div",{class:"swap-off"},t.off)]),l.Indicator=(t,l)=>$html("div",{class:n("indicator",t.class||t.class)},[l,$html("span",{class:n("indicator-item badge",t.badgeClass)},t.badge)]),l.Rating=t=>{const{value:l,count:e=5,mask:a="mask-star",readonly:s=!1,...n}=t,o=`rating-${Math.random().toString(36).slice(2,7)}`;return $html("div",{...n,class:()=>`rating ${A(s)?"pointer-events-none":""} ${t.class||""}`},Array.from({length:A(e)},((t,e)=>{const n=e+1;return $html("input",{type:"radio",name:o,class:`mask ${a}`,"aria-label":`${n} star`,checked:()=>Math.round(A(l))===n,onchange:()=>{A(s)||"function"!=typeof l||l(n)}})})))},l.Alert=(t,l)=>{const{type:e="info",soft:a=!0,...s}=t,n={info:c,success:i,warning:d,error:r},o=l||t.message;return $html("div",{...s,role:"alert",class:()=>`alert ${(()=>{const t=A(e);return{info:"alert-info",success:"alert-success",warning:"alert-warning",error:"alert-error"}[t]||t})()} ${A(a)?"alert-soft":""} ${t.class||""}`},[$html("img",{src:n[A(e)]||n.info,class:"w-4 h-4 object-contain",alt:A(e)}),$html("div",{class:"flex-1"},[$html("span",{},["function"==typeof o?o():o])]),t.actions?$html("div",{class:"flex-none"},["function"==typeof t.actions?t.actions():t.actions]):null])},l.Timeline=t=>{const{items:l=[],vertical:e=!0,compact:a=!1,...s}=t,n={info:c,success:i,warning:d,error:r};return $html("ul",{...s,class:()=>`timeline ${A(e)?"timeline-vertical":"timeline-horizontal"} ${A(a)?"timeline-compact":""} ${t.class||""}`},[$for(l,((t,e)=>{const a=0===e,s=e===A(l).length-1,o=t.type||"success",c=t=>"function"==typeof t?t():t;return $html("li",{class:"flex-1"},[a?null:$html("hr",{class:t.completed?"bg-primary":""}),$html("div",{class:"timeline-start"},[c(t.title)]),$html("div",{class:"timeline-middle"},[$html("img",{src:n[o]||t.icon||n.success,class:"w-4 h-4 object-contain mx-1",alt:o})]),$html("div",{class:"timeline-end timeline-box shadow-sm"},[c(t.detail)]),s?null:$html("hr",{class:t.completed?"bg-primary":""})])}),((t,l)=>t.id||l))])},l.Fab=t=>{const{icon:l,label:e,actions:a=[],position:s="bottom-6 right-6",...n}=t;return $html("div",{...n,class:()=>`fab fixed ${A(s)} flex flex-col-reverse items-end gap-3 z-[100] ${t.class||""}`},[$html("div",{tabindex:0,role:"button",class:"btn btn-lg btn-circle btn-primary shadow-2xl"},[l?"function"==typeof l?l():l:null,!l&&e?e:null]),...A(a).map((t=>$html("div",{class:"flex items-center gap-3 transition-all duration-300"},[t.label?$html("span",{class:"badge badge-ghost shadow-sm whitespace-nowrap"},t.label):null,$html("button",{type:"button",class:`btn btn-circle shadow-lg ${t.class||""}`,onclick:l=>{l.stopPropagation(),t.onclick?.(l)}},[t.icon?"function"==typeof t.icon?t.icon():t.icon:t.text||""])])))])},l.Toast=(t,e="alert-success",a=3500)=>{let s=document.getElementById("sigpro-toast-container");s||(s=$html("div",{id:"sigpro-toast-container",class:"fixed top-0 right-0 z-[9999] p-4 flex flex-col gap-2 pointer-events-none"}),document.body.appendChild(s));const A=$html("div",{style:"display: contents"});let n;s.appendChild(A);const o=()=>{clearTimeout(n);const t=A.firstElementChild;t&&!t.classList.contains("opacity-0")?(t.classList.add("translate-x-full","opacity-0"),setTimeout((()=>{c.destroy(),A.remove(),s.hasChildNodes()||s.remove()}),300)):(c.destroy(),A.remove())},c=$mount((()=>{const a=$html("div",{class:`alert alert-soft ${e} shadow-lg transition-all duration-300 translate-x-10 opacity-0 pointer-events-auto`},[$html("span","function"==typeof t?t:()=>t),l.Button({class:"btn-xs btn-circle btn-ghost",onclick:o},"✕")]);return requestAnimationFrame((()=>a.classList.remove("translate-x-10","opacity-0"))),a}),A);return a>0&&(n=setTimeout(o,a)),o},l.Loading=t=>$if(t.$show,(()=>$html("div",{class:"fixed inset-0 z-[100] flex items-center justify-center backdrop-blur-sm bg-base-100/30"},[$html("span",{class:"loading loading-spinner loading-lg text-primary"})]))),l.tt=s,Object.keys(l).forEach((t=>{$[t]=l[t],Object.defineProperty(window,t,{value:l[t],writable:!1,configurable:!0,enumerable:!0})})),l}; \ No newline at end of file