(() => { var __defProp = Object.defineProperty; var __getOwnPropNames = Object.getOwnPropertyNames; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __hasOwnProp = Object.prototype.hasOwnProperty; function __accessProp(key) { return this[key]; } var __toCommonJS = (from) => { var entry = (__moduleCache ??= new WeakMap).get(from), desc; if (entry) return entry; entry = __defProp({}, "__esModule", { value: true }); if (from && typeof from === "object" || typeof from === "function") { for (var key of __getOwnPropNames(from)) if (!__hasOwnProp.call(entry, key)) __defProp(entry, key, { get: __accessProp.bind(from, key), enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } __moduleCache.set(from, entry); return entry; }; var __moduleCache; var __returnValue = (v) => v; function __exportSetter(name, newValue) { this[name] = __returnValue.bind(null, newValue); } var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true, configurable: true, set: __exportSetter.bind(all, name) }); }; // index.js var exports_sigpro_ui = {}; __export(exports_sigpro_ui, { Utils: () => Utils, Components: () => Components }); // src/components/Accordion.js var exports_Accordion = {}; __export(exports_Accordion, { Accordion: () => Accordion }); // node_modules/sigpro/dist/sigpro.esm.min.js var m = (e) => typeof e === "function"; var j = (e) => e && typeof e === "object"; var N = Array.isArray; var E = typeof document < "u" ? document : null; var $2 = (e) => e?._isRuntime ? e.container : e instanceof Node ? e : E.createTextNode(e == null ? "" : String(e)); var p = null; var _ = null; var C = false; var A = 0; var T = new Set; var U = new WeakMap; var L = Symbol("iter"); var M = new WeakMap; var v = (e) => { if (!e || e._disposed) return; e._disposed = true; let s = [e]; while (s.length) { let t = s.pop(); if (t._cleanups) t._cleanups.forEach((r) => r()), t._cleanups.clear(); if (t._children) t._children.forEach((r) => s.push(r)), t._children.clear(); if (t._deps) t._deps.forEach((r) => r.delete(t)), t._deps.clear(); } }; var k = (e) => { if (_) (_._mounts ||= []).push(e); }; var g = (e) => { if (_) (_._cleanups ||= new Set).add(e); }; var q = (e) => { let s = p; p = null; try { return e(); } finally { p = s; } }; var O = (e, s = false) => { let t = () => { if (t._disposed) return; if (t._deps) t._deps.forEach((c) => c.delete(t)); if (t._cleanups) t._cleanups.forEach((c) => c()), t._cleanups.clear(); let r = p, n = _; p = _ = t; try { return t._result = e(); } catch (c) { console.error("[SigPro]", c); } finally { p = r, _ = n; } }; if (t._deps = t._cleanups = t._children = null, t._disposed = false, t._isComputed = s, t._depth = p ? p._depth + 1 : 0, t._mounts = [], t._parent = _, _) (_._children ||= new Set).add(t); return t; }; var W = () => { if (C) return; C = true; let e = Array.from(T).sort((s, t) => s._depth - t._depth); T.clear(); for (let s of e) if (!s._disposed) s(); C = false; }; var z = (e) => { A++; try { return e(); } finally { if (A--, A === 0 && T.size > 0 && !C) W(); } }; var w = (e, s = false) => { if (!s && p && !p._disposed) e.add(p), (p._deps ||= new Set).add(e); else if (s && e.size > 0) { let t = false; for (let r of e) { if (r === p || r._disposed) continue; if (r._isComputed) { if (r._dirty = true, r._subs) w(r._subs, true); } else T.add(r), t = true; } if (t && !C && A === 0) queueMicrotask(W); } }; var B = (e, s = null) => { let t = new Set; if (m(e)) { let r, n = () => { if (n._dirty) { let c = p; p = n; try { let i = e(); if (!Object.is(r, i)) r = i, w(t, true); } finally { p = c; } n._dirty = false; } return w(t), r; }; if (n._isComputed = true, n._subs = t, n._dirty = true, n._deps = null, n._disposed = false, n.stop = () => {}, _) g(n.stop); return n; } if (s) try { e = JSON.parse(localStorage.getItem(s)) ?? e; } catch (r) {} return (...r) => { if (r.length) { let n = m(r[0]) ? r[0](e) : r[0]; if (!Object.is(e, n)) { if (e = n, s) localStorage.setItem(s, JSON.stringify(e)); w(t, true); } } return w(t), e; }; }; var D = (e) => { if (!j(e)) return e; let s = U.get(e); if (s) return s; let t = new Map, r = (n) => { let c = t.get(n); if (!c) t.set(n, c = new Set); return c; }; return s = new Proxy(e, { get(n, c, i) { if (typeof c !== "symbol") w(r(c)); return D(Reflect.get(n, c, i)); }, set(n, c, i, o) { let l = !Reflect.has(n, c), a = Reflect.get(n, c, o), d = Reflect.set(n, c, i, o); if (d && !Object.is(a, i)) { if (w(r(c), true), l) w(r(L), true); } return d; }, deleteProperty(n, c) { let i = Reflect.deleteProperty(n, c); if (i) w(r(c), true), w(r(L), true); return i; }, ownKeys(n) { return w(r(L)), Reflect.ownKeys(n); } }), U.set(e, s), s; }; var R = (e, s) => { if (s === undefined) { let r = O(e); return r(), () => v(r); } let t = O(() => { let r = Array.isArray(e) ? e.map((n) => n()) : e(); q(() => s(r)); }); return t(), () => v(t); }; var P = (e) => { if (e._cleanups) e._cleanups.forEach((s) => s()), e._cleanups.clear(); if (e._ownerEffect) v(e._ownerEffect); if (e.childNodes) e.childNodes.forEach(P); }; var F = /^\s*(javascript|data|vbscript):/i; var G = (e) => e === "src" || e === "href" || e.startsWith("on"); var I = (e, s) => { if (s == null || s === false) return null; if (G(e)) { let t = String(s); if (F.test(t)) return console.warn(`[SigPro] Bloqueado protocolo peligroso en ${e}`), "#"; } return s; }; var S = (e, s = {}, t = []) => { if (s instanceof Node || N(s) || !j(s)) t = s, s = {}; if (m(e)) { let i = { _mounts: [], _cleanups: new Set }, o = O(() => { let f = e(s, { children: t, emit: (h, ...u) => s[`on${h[0].toUpperCase()}${h.slice(1)}`]?.(...u) }); return o._result = f, f; }); o(); let l = o._result; if (l == null) return null; let a = l instanceof Node || N(l) && l.every((f) => f instanceof Node) ? l : E.createTextNode(String(l)), d = (f) => { if (j(f) && !f._isRuntime) f._mounts = o._mounts || [], f._cleanups = o._cleanups || new Set, f._ownerEffect = o; }; return N(a) ? a.forEach(d) : d(a), a; } let r = /^(svg|path|circle|rect|line|poly(line|gon)|g|defs|text(path)?|tspan|use|symbol|image|marker|ellipse)$/i.test(e), n = r ? E.createElementNS("http://www.w3.org/2000/svg", e) : E.createElement(e); n._cleanups = new Set; for (let i in s) { if (!s.hasOwnProperty(i)) continue; let o = s[i]; if (i === "ref") { m(o) ? o(n) : o.current = n; continue; } if (r && i.startsWith("xlink:")) { val == null ? n.removeAttributeNS("http://www.w3.org/1999/xlink", i.slice(6)) : n.setAttributeNS("http://www.w3.org/1999/xlink", i.slice(6), val); continue; } if (i.startsWith("on")) { let l = i.slice(2).toLowerCase(); n.addEventListener(l, o); let a = () => n.removeEventListener(l, o); n._cleanups.add(a), g(a); } else if (m(o)) { let l = O(() => { let a = I(i, o()); if (i === "class") n.className = a || ""; else if (a == null) n.removeAttribute(i); else if (i in n && !r) n[i] = a; else n.setAttribute(i, a === true ? "" : a); }); if (l(), n._cleanups.add(() => v(l)), g(() => v(l)), /^(INPUT|TEXTAREA|SELECT)$/.test(n.tagName) && (i === "value" || i === "checked")) { let a = i === "checked" ? "change" : "input"; n.addEventListener(a, (d) => o(d.target[i])); } } else { let l = I(i, o); if (l != null) if (i in n && !r) n[i] = l; else n.setAttribute(i, l === true ? "" : l); } } let c = (i) => { if (N(i)) return i.forEach(c); if (m(i)) { let o = E.createTextNode(""); n.appendChild(o); let l = [], a = O(() => { let d = i(), f = (N(d) ? d : [d]).map($2); l.forEach((u) => { if (u._isRuntime) u.destroy(); else P(u); if (u.parentNode) u.remove(); }); let h = o; for (let u = f.length - 1;u >= 0; u--) { let y = f[u]; if (y.parentNode !== h.parentNode) h.parentNode?.insertBefore(y, h); if (y._mounts) y._mounts.forEach((V) => V()); h = y; } l = f; }); a(), n._cleanups.add(() => v(a)), g(() => v(a)); } else { let o = $2(i); if (n.appendChild(o), o._mounts) o._mounts.forEach((l) => l()); } }; return c(t), n; }; var b = (e) => { let s = new Set, t = [], r = _, n = p, c = E.createElement("div"); c.style.display = "contents", c.setAttribute("role", "presentation"), _ = { _cleanups: s, _mounts: t }, p = null; let i = (o) => { if (!o) return; if (o._isRuntime) s.add(o.destroy), c.appendChild(o.container); else if (N(o)) o.forEach(i); else c.appendChild(o instanceof Node ? o : E.createTextNode(String(o == null ? "" : o))); }; try { i(e({ onCleanup: (o) => s.add(o) })); } finally { _ = r, p = n; } return t.forEach((o) => o()), { _isRuntime: true, container: c, destroy: () => { s.forEach((o) => o()), P(c), c.remove(); } }; }; var J = (e, s, t = null) => { let r = E.createTextNode(""), n = S("div", { style: "display:contents" }, [r]), c = null; return R(() => !!(m(e) ? e() : e), (i) => { if (c) c.destroy(), c = null; let o = i ? s : t; if (o) c = b(() => m(o) ? o() : o), n.insertBefore(c.container, r); }), g(() => c?.destroy()), n; }; var K = (e, s, t) => { let r = E.createTextNode(""), n = S("div", { style: "display:contents" }, [r]), c = new Map; return R(() => (m(e) ? e() : e) || [], (i) => { let o = new Map, l = [], a = i || []; for (let f = 0;f < a.length; f++) { let h = a[f], u = t ? t(h, f) : h?.id ?? f, y = c.get(u); if (!y) y = b(() => s(h, f)); else c.delete(u); o.set(u, y), l.push(y); } c.forEach((f) => f.destroy()); let d = r; for (let f = l.length - 1;f >= 0; f--) { let u = l[f].container; if (u.nextSibling !== d) n.insertBefore(u, d); d = u; } c = o; }), n; }; var x = (e) => { let s = () => window.location.hash.slice(1) || "/", t = B(s()), r = () => t(s()); window.addEventListener("hashchange", r), g(() => window.removeEventListener("hashchange", r)); let n = S("div", { class: "router-hook" }), c = null; return R([t], () => { let i = t(), o = e.find((l) => { let a = l.path.split("/").filter(Boolean), d = i.split("/").filter(Boolean); return a.length === d.length && a.every((f, h) => f[0] === ":" || f === d[h]); }) || e.find((l) => l.path === "*"); if (o) { c?.destroy(); let l = {}; o.path.split("/").filter(Boolean).forEach((a, d) => { if (a[0] === ":") l[a.slice(1)] = i.split("/").filter(Boolean)[d]; }), x.params(l), c = b(() => m(o.component) ? o.component(l) : o.component), n.replaceChildren(c.container); } }), n; }; x.params = B({}); x.to = (e) => window.location.hash = e.replace(/^#?\/?/, "#/"); x.back = () => window.history.back(); x.path = () => window.location.hash.replace(/^#/, "") || "/"; var Q = (e, s, { enter: t, leave: r } = {}) => { let n = S("div", { style: "display:contents" }), c = null, i = (o, l) => { let a = false, d = () => !a && (a = true, l()); if (!o) return d(); "transitionend animationend".split(" ").map((f) => o.addEventListener(f, d, { once: true })), setTimeout(d, 500); }; return R(e, (o) => { if (o && !c) { let l = (c = b(s)).container.firstChild; if (n.appendChild(c.container), t && l) l.classList.add(t), l.clientTop, l.classList.add(t + "-active"), i(l, () => l.classList.remove(t, t + "-active")); } else if (!o && c) { let l = c.container.firstChild, a = () => (c?.destroy(), c = null); r && l ? (l.classList.add(r), i(l, a)) : a(); } }), g(() => c?.destroy()), n; }; var H = (e, s) => { let t = typeof s === "string" ? E.querySelector(s) : s; if (!t) return; if (M.has(t)) M.get(t).destroy(); let r = b(m(e) ? e : () => e); return t.replaceChildren(r.container), M.set(t, r), r; }; var X = Object.freeze({ $: B, $$: D, Watch: R, Tag: S, Render: b, If: J, For: K, Router: x, Mount: H, onMount: k, onUnmount: g, Anim: Q, Batch: z }); if (typeof window < "u") Object.assign(window, X), "div span p h1 h2 h3 h4 h5 h6 br hr section article aside nav main header footer ul ol li a em strong pre code form label input textarea select button img svg".split(" ").forEach((e) => { let s = e[0].toUpperCase() + e.slice(1); window[s] = (t, r) => S(e, t, r); }); // src/utils.js var val2 = (t) => typeof t === "function" ? t() : t; var ui = (baseClass, additionalClassOrFn) => typeof additionalClassOrFn === "function" ? () => `${baseClass} ${additionalClassOrFn() || ""}`.trim() : `${baseClass} ${additionalClassOrFn || ""}`.trim(); var getIcon = (icon) => { if (!icon) return null; if (typeof icon === "function") { return S("span", { class: "mr-1" }, icon()); } if (typeof icon === "object") { return S("span", { class: "mr-1" }, icon); } if (typeof icon === "string") { const parts = icon.trim().split(/\s+/); const hasRight = parts[parts.length - 1] === "right"; const iconClass = hasRight ? parts.slice(0, -1).join(" ") : icon; const spacing = hasRight ? "ml-1" : "mr-1"; if (iconClass && !iconClass.startsWith("icon-[") && !iconClass.includes("--")) { return S("span", { class: spacing }, iconClass); } return S("span", { class: `${iconClass} ${spacing}`.trim() }); } return null; }; var i18n = { es: { close: "Cerrar", confirm: "Confirmar", cancel: "Cancelar", search: "Buscar...", loading: "Cargando...", nodata: "Sin datos" }, en: { close: "Close", confirm: "Confirm", cancel: "Cancel", search: "Search...", loading: "Loading...", nodata: "No data" } }; var currentLocale = B("es"); var Locale = (t) => currentLocale(t); var tt = (t) => () => i18n[currentLocale()][t] || t; // src/components/Accordion.js var Accordion = (props, children) => { const { class: className, title, name, open, ...rest } = props; return S("div", { ...rest, class: ui("collapse collapse-arrow bg-base-200 mb-2", className) }, [ S("input", { type: name ? "radio" : "checkbox", name, checked: val2(open) }), S("div", { class: "collapse-title text-xl font-medium" }, title), S("div", { class: "collapse-content" }, children) ]); }; // src/components/Alert.js var exports_Alert = {}; __export(exports_Alert, { Alert: () => Alert }); var Alert = (props, children) => { const { class: className, actions, type = "info", soft = true, ...rest } = props; const iconMap = { info: "icon-[lucide--info]", success: "icon-[lucide--check-circle]", warning: "icon-[lucide--alert-triangle]", error: "icon-[lucide--alert-circle]" }; const typeClass = `alert-${type}`; const softClass = soft ? "alert-soft" : ""; const allClasses = [typeClass, softClass, className].filter(Boolean).join(" "); const content = children || props.message; return S("div", { ...rest, role: "alert", class: ui("alert", allClasses) }, () => [ getIcon(iconMap[type]), S("div", { class: "flex-1" }, [ S("span", {}, [typeof content === "function" ? content() : content]) ]), actions ? S("div", { class: "flex-none" }, [ typeof actions === "function" ? actions() : actions ]) : null ].filter(Boolean)); }; // src/components/Autocomplete.js var exports_Autocomplete = {}; __export(exports_Autocomplete, { Autocomplete: () => Autocomplete }); // src/components/Input.js var exports_Input = {}; __export(exports_Input, { Input: () => Input }); var Input = (props) => { const { class: className, value, type = "text", icon, oninput, placeholder, disabled, validate, label, ...rest } = props; const isPassword = type === "password"; const visible = $(false); const errorMsg = $(null); const iconMap = { text: "icon-[lucide--text]", password: "icon-[lucide--lock]", date: "icon-[lucide--calendar]", number: "icon-[lucide--hash]", email: "icon-[lucide--mail]", search: "icon-[lucide--search]", tel: "icon-[lucide--phone]", url: "icon-[lucide--link]" }; const leftIcon = icon ? getIcon(icon) : iconMap[type] ? getIcon(iconMap[type]) : null; const getPasswordIcon = () => getIcon(visible() ? "icon-[lucide--eye-off]" : "icon-[lucide--eye]"); const paddingLeft = leftIcon ? "pl-10" : ""; const paddingRight = isPassword ? "pr-10" : ""; const buttonSize = () => { if (className?.includes("input-xs")) return "btn-xs"; if (className?.includes("input-sm")) return "btn-sm"; if (className?.includes("input-lg")) return "btn-lg"; return "btn-md"; }; const handleInput = (e) => { const newValue = e.target.value; if (validate) { const result = validate(newValue); errorMsg(result || null); } oninput?.(e); }; const hasError = () => errorMsg() && errorMsg() !== ""; const inputClasses = () => { let classes = `input w-full ${paddingLeft} ${paddingRight}`; if (className) classes += ` ${className}`; if (hasError()) classes += " input-error"; return classes.trim(); }; const inputElement = S("input", { ...rest, type: () => isPassword ? visible() ? "text" : "password" : type, placeholder: placeholder || (label ? " " : placeholder), class: inputClasses, value, oninput: handleInput, disabled: () => val2(disabled), "aria-invalid": () => hasError() ? "true" : "false" }); const inputContent = () => [ inputElement, leftIcon ? S("div", { class: "absolute left-3 inset-y-0 flex items-center pointer-events-none text-base-content/60" }, leftIcon) : null, isPassword ? S("button", { type: "button", class: ui("absolute right-3 inset-y-0 flex items-center", "btn btn-ghost btn-circle opacity-50 hover:opacity-100", buttonSize()), onclick: (e) => { e.preventDefault(); visible(!visible()); } }, () => getPasswordIcon()) : null, S("div", { class: "text-error text-xs mt-1 px-3 absolute -bottom-5 left-0" }, () => hasError() ? errorMsg() : null) ]; if (label) { return S("label", { class: ui("floating-label w-full", className) }, () => [ S("div", { class: "relative w-full" }, inputContent), S("span", {}, val2(label)) ]); } return S("div", { class: "relative w-full" }, inputContent); }; // src/components/Autocomplete.js var Autocomplete = (props) => { const { class: className, items = [], value, onselect, label, placeholder, ...rest } = props; const query = B(val2(value) || ""); const isOpen = B(false); const cursor = B(-1); const list = B([]); Watch(() => { const q2 = String(query()).toLowerCase(); const data = val2(items) || []; const filtered = q2 ? data.filter((o) => (typeof o === "string" ? o : o.label).toLowerCase().includes(q2)) : data; list(filtered); }); const pick = (opt) => { const valStr = typeof opt === "string" ? opt : opt.value; const labelStr = typeof opt === "string" ? opt : opt.label; query(labelStr); if (typeof value === "function") value(valStr); onselect?.(opt); isOpen(false); cursor(-1); }; const nav = (e) => { const currentItems = list(); if (e.key === "ArrowDown") { e.preventDefault(); isOpen(true); cursor(Math.min(cursor() + 1, currentItems.length - 1)); } else if (e.key === "ArrowUp") { e.preventDefault(); cursor(Math.max(cursor() - 1, 0)); } else if (e.key === "Enter" && cursor() >= 0) { e.preventDefault(); pick(currentItems[cursor()]); } else if (e.key === "Escape") { isOpen(false); } }; return S("div", { class: "relative w-full" }, [ Input({ label, class: className, placeholder, value: query, onfocus: () => isOpen(true), onblur: () => setTimeout(() => isOpen(false), 150), onkeydown: nav, oninput: (e) => { const v2 = e.target.value; query(v2); if (typeof value === "function") value(v2); isOpen(true); cursor(-1); }, ...rest }), S("ul", { class: "absolute dropdown-menu 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: () => isOpen() && list().length ? "display:block" : "display:none" }, [ K(list, (opt, i) => S("li", {}, [ S("a", { class: () => `block w-full ${cursor() === i ? "active bg-primary text-primary-content" : ""}`, onclick: () => pick(opt), onmouseenter: () => cursor(i) }, typeof opt === "string" ? opt : opt.label) ]), (opt, i) => (typeof opt === "string" ? opt : opt.value) + i), () => list().length ? null : S("li", { class: "p-2 text-center opacity-50" }, "nodata") ]) ]); }; // src/components/Badge.js var exports_Badge = {}; __export(exports_Badge, { Badge: () => Badge }); var Badge = (props, children) => { const { class: className, ...rest } = props; return S("span", { ...rest, class: ui("badge", className) }, children); }; // src/components/Button.js var exports_Button = {}; __export(exports_Button, { Button: () => Button }); var Button = (props, children) => { const { class: className, loading, icon, ...rest } = props; const iconEl = getIcon(icon); return S("button", { ...rest, class: ui("btn", className), disabled: () => val2(loading) || val2(props.disabled) }, () => [ val2(loading) && S("span", { class: "loading loading-spinner" }), iconEl, children ].filter(Boolean)); }; // src/components/Checkbox.js var exports_Checkbox = {}; __export(exports_Checkbox, { Checkbox: () => Checkbox }); var Checkbox = (props) => { const { class: className, value, toggle, label, ...rest } = props; const checkEl = S("input", { ...rest, type: "checkbox", class: () => ui(val2(toggle) ? "toggle" : "checkbox", className), checked: value }); return S("label", { class: "label cursor-pointer justify-start gap-3" }, [ checkEl, label ? S("span", { class: "label-text" }, label) : null ]); }; // src/components/Colorpicker.js var exports_Colorpicker = {}; __export(exports_Colorpicker, { Colorpicker: () => Colorpicker }); var Colorpicker = (props) => { const { class: className, value, label, ...rest } = props; const isOpen = B(false); const palette = [ ...["#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"] ]; const getColor = () => val2(value) || "#000000"; return S("div", { class: ui("relative w-fit", className) }, [ S("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: (e) => { e.stopPropagation(); isOpen(!isOpen()); }, ...rest }, [ S("div", { class: "size-5 rounded-sm shadow-inner border border-black/10 shrink-0", style: () => `background-color: ${getColor()}` }), label ? S("span", { class: "opacity-80" }, label) : null ]), J(isOpen, () => S("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: (e) => e.stopPropagation() }, [ S("div", { class: "grid grid-cols-8 gap-1" }, palette.map((c) => S("button", { type: "button", style: `background-color: ${c}`, class: () => { const active = getColor().toLowerCase() === c.toLowerCase(); return `size-6 rounded-sm cursor-pointer transition-all hover:scale-125 hover:z-10 active:scale-95 outline-none border border-black/5 ${active ? "ring-2 ring-offset-1 ring-primary z-10 scale-110" : ""}`; }, onclick: () => { if (typeof value === "function") value(c); isOpen(false); } }))) ])), J(isOpen, () => S("div", { class: "fixed inset-0 z-[100]", onclick: () => isOpen(false) })) ]); }; // src/components/Datepicker.js var exports_Datepicker = {}; __export(exports_Datepicker, { Datepicker: () => Datepicker }); // src/components/Calendar.js var Calendar = (props) => { const { value, range = false, hour = false, onChange, class: className = "" } = props; const internalDate = B(new Date); const hoverDate = B(null); const startHour = B(0); const endHour = B(0); const isRangeMode = () => range === true; const now = new Date; const todayStr = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, "0")}-${String(now.getDate()).padStart(2, "0")}`; const formatDate = (d) => { const year = d.getFullYear(); const month = String(d.getMonth() + 1).padStart(2, "0"); const day = String(d.getDate()).padStart(2, "0"); return `${year}-${month}-${day}`; }; const selectDate = (date) => { const dateStr = formatDate(date); const current = val2(value); if (isRangeMode()) { if (!current?.start || current.start && current.end) { const newValue = { start: dateStr, end: null, ...hour && { startHour: startHour() } }; onChange?.(newValue); } else { const start = current.start; let newValue; if (dateStr < start) { newValue = { start: dateStr, end: start }; } else { newValue = { start, end: dateStr }; } if (hour) { newValue.startHour = current.startHour !== undefined ? current.startHour : startHour(); newValue.endHour = endHour(); } onChange?.(newValue); } } else { const newValue = hour ? `${dateStr}T${String(startHour()).padStart(2, "0")}:00:00` : dateStr; onChange?.(newValue); } }; const move = (m2) => { const d = internalDate(); internalDate(new Date(d.getFullYear(), d.getMonth() + m2, 1)); }; const moveYear = (y) => { const d = internalDate(); internalDate(new Date(d.getFullYear() + y, d.getMonth(), 1)); }; const HourSlider = ({ value: hVal, onChange: onHourChange }) => { return S("div", { class: "flex-1" }, [ S("div", { class: "flex gap-2 items-center" }, [ S("input", { type: "range", min: 0, max: 23, value: hVal, class: "range range-xs flex-1", oninput: (e) => { const newHour = parseInt(e.target.value); onHourChange(newHour); } }), S("span", { class: "text-sm font-mono min-w-[48px] text-center" }, () => String(val2(hVal)).padStart(2, "0") + ":00") ]) ]); }; return S("div", { class: `p-4 bg-base-100 border border-base-300 shadow-2xl rounded-box w-80 select-none ${className}` }, [ S("div", { class: "flex justify-between items-center mb-4 gap-1" }, [ S("div", { class: "flex gap-0.5" }, [ S("button", { type: "button", class: "btn btn-ghost btn-xs px-1", onclick: () => moveYear(-1) }, getIcon("icon-[lucide--chevrons-left]")), S("button", { type: "button", class: "btn btn-ghost btn-xs px-1", onclick: () => move(-1) }, getIcon("icon-[lucide--chevron-left]")) ]), S("span", { class: "font-bold uppercase flex-1 text-center" }, [ () => internalDate().toLocaleString("es-ES", { month: "short", year: "numeric" }) ]), S("div", { class: "flex gap-0.5" }, [ S("button", { type: "button", class: "btn btn-ghost btn-xs px-1", onclick: () => move(1) }, getIcon("icon-[lucide--chevron-right]")), S("button", { type: "button", class: "btn btn-ghost btn-xs px-1", onclick: () => moveYear(1) }, getIcon("icon-[lucide--chevrons-right]")) ]) ]), S("div", { class: "grid grid-cols-7 gap-1", onmouseleave: () => hoverDate(null) }, [ ...["L", "M", "X", "J", "V", "S", "D"].map((d) => S("div", { class: "text-[10px] opacity-40 font-bold text-center" }, d)), () => { const d = internalDate(); const year = d.getFullYear(); const month = d.getMonth(); const firstDay = new Date(year, month, 1).getDay(); const offset = firstDay === 0 ? 6 : firstDay - 1; const daysInMonth = new Date(year, month + 1, 0).getDate(); const nodes = []; for (let i = 0;i < offset; i++) nodes.push(S("div")); for (let i = 1;i <= daysInMonth; i++) { const date = new Date(year, month, i); const dStr = formatDate(date); nodes.push(S("button", { type: "button", class: () => { const v2 = val2(value); const h = hoverDate(); const isStart = typeof v2 === "string" ? v2.split("T")[0] === dStr : v2?.start === dStr; const isEnd = v2?.end === dStr; let inRange = false; if (isRangeMode() && v2?.start) { const start = v2.start; if (!v2.end && h) { inRange = dStr > start && dStr <= h || dStr < start && dStr >= h; } else if (v2.end) { inRange = dStr > start && dStr < v2.end; } } const base = "btn btn-xs p-0 aspect-square min-h-0 h-auto font-normal relative"; const state = isStart || isEnd ? "btn-primary z-10" : inRange ? "bg-primary/20 border-none rounded-none" : "btn-ghost"; const today = dStr === todayStr ? "ring-1 ring-primary ring-inset font-black text-primary" : ""; return `${base} ${state} ${today}`; }, onmouseenter: () => { if (isRangeMode()) hoverDate(dStr); }, onclick: () => selectDate(date) }, [i.toString()])); } return nodes; } ]), hour ? S("div", { class: "mt-3 pt-2 border-t border-base-300" }, [ isRangeMode() ? S("div", { class: "flex gap-4" }, [ HourSlider({ value: startHour, onChange: (newHour) => startHour(newHour) }), HourSlider({ value: endHour, onChange: (newHour) => endHour(newHour) }) ]) : HourSlider({ value: startHour, onChange: (newHour) => startHour(newHour) }) ]) : null ]); }; // src/components/Datepicker.js var Datepicker = (props) => { const { class: className, value, range, label, placeholder, hour = false, ...rest } = props; const isOpen = B(false); const isRangeMode = () => val2(range) === true; const displayValue = B(""); R(() => { const v2 = val2(value); if (!v2) { displayValue(""); return; } let text = ""; if (typeof v2 === "string") { text = hour && v2.includes("T") ? v2.replace("T", " ") : v2; } else if (v2.start && v2.end) { const startStr = hour && v2.startHour !== undefined ? `${v2.start} ${String(v2.startHour).padStart(2, "0")}:00` : v2.start; const endStr = hour && v2.endHour !== undefined ? `${v2.end} ${String(v2.endHour).padStart(2, "0")}:00` : v2.end; text = `${startStr} - ${endStr}`; } else if (v2.start) { const startStr = hour && v2.startHour !== undefined ? `${v2.start} ${String(v2.startHour).padStart(2, "0")}:00` : v2.start; text = `${startStr}...`; } displayValue(text); }); const handleCalendarChange = (newValue) => { if (typeof value === "function") { value(newValue); } if (!isRangeMode() || newValue?.end !== undefined && newValue?.end !== null) { isOpen(false); } }; return S("div", { class: ui("relative w-full", className) }, [ Input({ label, placeholder: placeholder || (isRangeMode() ? "Seleccionar rango..." : "Seleccionar fecha..."), value: displayValue, readonly: true, icon: getIcon("icon-[lucide--calendar]"), onclick: (e) => { e.stopPropagation(); isOpen(!isOpen()); }, ...rest }), J(isOpen, () => S("div", { class: "absolute left-0 mt-2 z-[100]", onclick: (e) => e.stopPropagation() }, [ Calendar({ value, range: isRangeMode(), hour, onChange: handleCalendarChange }) ])), J(isOpen, () => S("div", { class: "fixed inset-0 z-[90]", onclick: () => isOpen(false) })) ]); }; // src/components/Drawer.js var exports_Drawer = {}; __export(exports_Drawer, { Drawer: () => Drawer }); var Drawer = (props, children) => { const { class: className, id, open, side, content, ...rest } = props; const drawerId = id || `drawer-${Math.random().toString(36).slice(2, 9)}`; return S("div", { ...rest, class: ui("drawer", className) }, [ S("input", { id: drawerId, type: "checkbox", class: "drawer-toggle", checked: () => typeof open === "function" ? open() : open, onchange: (e) => { if (typeof open === "function") open(e.target.checked); } }), S("div", { class: "drawer-content" }, [ typeof content === "function" ? content() : content ]), S("div", { class: "drawer-side" }, [ S("label", { for: drawerId, class: "drawer-overlay", onclick: () => { if (typeof open === "function") open(false); } }), S("div", { class: "min-h-full bg-base-200 w-80" }, [ typeof side === "function" ? side() : side ]) ]) ]); }; // src/components/Dropdown.js var exports_Dropdown = {}; __export(exports_Dropdown, { Dropdown: () => Dropdown }); var currentOpen = null; if (typeof window !== "undefined" && !window.__dropdownHandlerRegistered) { window.addEventListener("click", (e) => { if (currentOpen && !currentOpen.contains(e.target)) { currentOpen.open = false; currentOpen = null; } }); window.__dropdownHandlerRegistered = true; } var Dropdown = (props) => { const { class: className, label, icon, items, ...rest } = props; return S("details", { ...rest, class: ui("dropdown", className) }, [ S("summary", { class: "btn m-1 flex items-center gap-2 list-none cursor-pointer", style: "display: inline-flex;", onclick: (e) => { const details = e.currentTarget.closest("details"); if (currentOpen && currentOpen !== details) { currentOpen.open = false; } setTimeout(() => { currentOpen = details.open ? details : null; }, 0); } }, [ () => icon ? typeof icon === "function" ? icon() : icon : null, () => label ? typeof label === "function" ? label() : label : null ]), S("ul", { tabindex: "-1", class: "dropdown-content z-[50] menu p-2 shadow bg-base-100 rounded-box w-52 border border-base-300" }, [ () => { const currentItems = typeof items === "function" ? items() : items || []; return currentItems.map((item) => S("li", {}, [ S("a", { class: item.class || "", onclick: (e) => { if (item.onclick) item.onclick(e); const details = e.currentTarget.closest("details"); if (details) { details.open = false; if (currentOpen === details) currentOpen = null; } } }, [ item.icon ? S("span", {}, item.icon) : null, S("span", {}, item.label) ]) ])); } ]) ]); }; // src/components/Fab.js var exports_Fab = {}; __export(exports_Fab, { Fab: () => Fab }); var Fab = (props) => { const { class: className, icon, label, actions = [], position = "bottom-6 right-6", ...rest } = props; return S("div", { ...rest, class: ui(`fab absolute ${position} flex flex-col-reverse items-end gap-3 z-[100]`, className) }, [ S("div", { tabindex: 0, role: "button", class: "btn btn-lg btn-circle btn-primary shadow-2xl" }, [ icon ? getIcon(icon) : null, !icon && label ? label : null ]), ...val2(actions).map((act) => S("div", { class: "flex items-center gap-3 transition-all duration-300" }, [ act.label ? S("span", { class: "badge badge-ghost shadow-sm whitespace-nowrap" }, act.label) : null, S("button", { type: "button", class: `btn btn-circle shadow-lg ${act.class || ""}`, onclick: (e) => { e.stopPropagation(); act.onclick?.(e); } }, [act.icon ? getIcon(act.icon) : act.text || ""]) ])) ]); }; // src/components/Fieldset.js var exports_Fieldset = {}; __export(exports_Fieldset, { Fieldset: () => Fieldset }); var Fieldset = (props, children) => { const { class: className, legend, ...rest } = props; return S("fieldset", { ...rest, class: ui("fieldset bg-base-200 border border-base-300 p-4 rounded-lg", className) }, [ () => { const legendText = val2(legend); return legendText ? S("legend", { class: "fieldset-legend font-bold" }, [legendText]) : null; }, children ]); }; // src/components/Fileinput.js var exports_Fileinput = {}; __export(exports_Fileinput, { Fileinput: () => Fileinput }); var Fileinput = (props) => { const { class: className, tooltip, max = 2, accept = "*", onselect, ...rest } = props; const selectedFiles = B([]); const isDragging = B(false); const error = B(null); const MAX_BYTES = max * 1024 * 1024; const handleFiles = (files) => { const fileList = Array.from(files); error(null); const oversized = fileList.find((f) => f.size > MAX_BYTES); if (oversized) { error(`Máx ${max}MB`); return; } selectedFiles([...selectedFiles(), ...fileList]); onselect?.(selectedFiles()); }; const removeFile = (index) => { const updated = selectedFiles().filter((_2, i) => i !== index); selectedFiles(updated); onselect?.(updated); }; return S("fieldset", { ...rest, class: ui("fieldset w-full p-0", className) }, [ S("div", { class: () => `w-full ${tooltip ? "tooltip tooltip-top before:z-50 after:z-50" : ""}`, "data-tip": tooltip }, [ S("label", { class: () => ` relative flex items-center justify-between w-full h-12 px-4 border-2 border-dashed rounded-lg cursor-pointer transition-all duration-200 ${isDragging() ? "border-primary bg-primary/10" : "border-base-content/20 bg-base-100 hover:bg-base-200"} `, ondragover: (e) => { e.preventDefault(); isDragging(true); }, ondragleave: () => isDragging(false), ondrop: (e) => { e.preventDefault(); isDragging(false); handleFiles(e.dataTransfer.files); } }, [ S("div", { class: "flex items-center gap-3 w-full" }, [ getIcon("icon-[lucide--upload]"), S("span", { class: "text-sm opacity-70 truncate grow text-left" }, "Arrastra o selecciona archivos..."), S("span", { class: "text-[10px] opacity-40 shrink-0" }, `Máx ${max}MB`) ]), S("input", { type: "file", multiple: true, accept, class: "hidden", onchange: (e) => handleFiles(e.target.files) }) ]) ]), () => error() ? S("span", { class: "text-[10px] text-error mt-1 px-1 font-medium" }, error()) : null, J(() => selectedFiles().length > 0, () => S("ul", { class: "mt-2 space-y-1" }, [ K(selectedFiles, (file, index) => S("li", { class: "flex items-center justify-between p-1.5 pl-3 text-xs bg-base-200/50 rounded-md border border-base-300" }, [ S("div", { class: "flex items-center gap-2 truncate" }, [ S("span", { class: "opacity-50" }, "\uD83D\uDCC4"), S("span", { class: "truncate font-medium max-w-[200px]" }, file.name), S("span", { class: "text-[9px] opacity-40" }, `(${(file.size / 1024).toFixed(0)} KB)`) ]), S("button", { type: "button", class: "btn btn-ghost btn-xs btn-circle", onclick: (e) => { e.preventDefault(); e.stopPropagation(); removeFile(index); } }, [getIcon("icon-[lucide--x]")]) ]), (file) => file.name + file.lastModified) ])) ]); }; // src/components/Indicator.js var exports_Indicator = {}; __export(exports_Indicator, { Indicator: () => Indicator }); var Indicator = (props, children) => { const { value, class: className, ...rest } = props; return S("div", { ...rest, class: "indicator" }, () => [ value ? S("span", { class: ui("indicator-item badge", className) }, () => typeof value === "function" ? value() : value) : null, children ].filter(Boolean)); }; // src/components/Label.js var exports_Label = {}; __export(exports_Label, { Label: () => Label }); var Label = (props) => { const { children, value, floating = false, class: className, ...rest } = props; if (floating) { return S("label", { class: ui("floating-label", className), ...rest }, () => [ typeof children === "function" ? children() : children, value ? S("span", {}, val2(value)) : null ]); } return S("label", { class: ui("label", className), ...rest }, () => [ value ? S("span", { class: "label-text" }, val2(value)) : null, typeof children === "function" ? children() : children ]); }; // src/components/List.js var exports_List = {}; __export(exports_List, { List: () => List }); var List = (props) => { const { class: className, items, header, render = (item) => item, keyFn = (item, index) => item.id ?? index, ...rest } = props; const listItems = K(items, (item, index) => S("li", { class: "list-row", style: "width: 100%; display: block;" }, [ S("div", { style: "width: 100%;" }, [render(item, index)]) ]), keyFn); return S("ul", { ...rest, style: "display: block; width: 100%;", class: ui("list bg-base-100 rounded-box shadow-md", className) }, header ? [J(header, () => S("li", { class: "p-4 pb-2 text-xs opacity-60", style: "width: 100%;" }, [val2(header)])), listItems] : listItems); }; // src/components/Menu.js var exports_Menu = {}; __export(exports_Menu, { Menu: () => Menu }); var Menu = (props) => { const { class: className, items, ...rest } = props; const renderItems = (items2) => K(() => items2 || [], (it) => S("li", {}, [ it.children ? S("details", { open: it.open }, [ S("summary", {}, [it.icon && S("span", { class: "mr-2" }, it.icon), it.label]), S("ul", {}, renderItems(it.children)) ]) : S("a", { class: () => val2(it.active) ? "active" : "", onclick: it.onclick }, [ it.icon && S("span", { class: "mr-2" }, it.icon), it.label ]) ]), (it, i) => it.label || i); return S("ul", { ...rest, class: ui("menu bg-base-200 rounded-box", className) }, renderItems(items)); }; // src/components/Modal.js var exports_Modal = {}; __export(exports_Modal, { Modal: () => Modal }); var Modal = (props, children) => { const { class: className, title, buttons, open, ...rest } = props; let dialogElement = null; const handleOpen = () => { const isOpen = typeof open === "function" ? open() : open; if (!dialogElement) return; if (isOpen) { if (!dialogElement.open) dialogElement.showModal(); } else { if (dialogElement.open) dialogElement.close(); } }; R(() => handleOpen()); const close = () => { if (typeof open === "function") open(false); }; return S("dialog", { ...rest, ref: (el) => { dialogElement = el; if (el) handleOpen(); }, class: ui("modal", className), onclose: close, oncancel: close }, [ S("div", { class: "modal-box" }, [ title ? S("h3", { class: "text-lg font-bold mb-4" }, () => typeof title === "function" ? title() : title) : null, S("div", { class: "py-2" }, [ typeof children === "function" ? children() : children ]), S("div", { class: "modal-action" }, [ S("form", { method: "dialog", class: "flex gap-2" }, [ ...(Array.isArray(buttons) ? buttons : [buttons]).filter(Boolean), Button({ type: "submit" }, "close") ]) ]) ]), S("form", { method: "dialog", class: "modal-backdrop" }, [ S("button", {}, "close") ]) ]); }; // src/components/Navbar.js var exports_Navbar = {}; __export(exports_Navbar, { Navbar: () => Navbar }); var Navbar = (props, children) => { const { class: className, ...rest } = props; return S("div", { ...rest, class: ui("navbar bg-base-100 shadow-sm px-4", className) }, children); }; // src/components/Radio.js var exports_Radio = {}; __export(exports_Radio, { Radio: () => Radio }); var Radio = (props) => { const { class: className, label, tooltip, value, inputValue, name, ...rest } = props; const radioEl = S("input", { ...rest, type: "radio", name, class: ui("radio", className), checked: () => val2(value) === inputValue, onclick: () => { if (typeof value === "function") value(inputValue); } }); if (!label && !tooltip) return radioEl; const layout = S("label", { class: "label cursor-pointer justify-start gap-3" }, [ radioEl, label ? S("span", { class: "label-text" }, label) : null ]); return tooltip ? S("div", { class: "tooltip", "data-tip": tooltip }, layout) : layout; }; // src/components/Range.js var exports_Range = {}; __export(exports_Range, { Range: () => Range }); var Range = (props) => { const { class: className, label, tooltip, value, ...rest } = props; const rangeEl = S("input", { ...rest, type: "range", class: ui("range", className), value, disabled: () => val2(props.disabled) }); if (!label && !tooltip) return rangeEl; const layout = S("div", { class: "flex flex-col gap-2" }, [ label ? S("span", { class: "label-text" }, label) : null, rangeEl ]); return tooltip ? S("div", { class: "tooltip", "data-tip": tooltip }, layout) : layout; }; // src/components/Rating.js var exports_Rating = {}; __export(exports_Rating, { Rating: () => Rating }); var Rating = (props) => { const { class: className, value, count = 5, mask = "mask-star", readonly = false, onchange, ...rest } = props; const ratingGroup = `rating-${Math.random().toString(36).slice(2, 7)}`; return S("div", { ...rest, class: () => ui(`rating ${val2(readonly) ? "pointer-events-none" : ""}`, className) }, Array.from({ length: val2(count) }, (_2, i) => { const starValue = i + 1; return S("input", { type: "radio", name: ratingGroup, class: `mask ${mask}`, checked: () => Math.round(val2(value)) === starValue, onchange: () => { if (!val2(readonly)) { if (typeof onchange === "function") { onchange(starValue); } else if (typeof value === "function") { value(starValue); } } } }); })); }; // src/components/Select.js var exports_Select = {}; __export(exports_Select, { Select: () => Select }); var Select = (props) => { const { class: className, label, items, value, ...rest } = props; const selectEl = S("select", { ...rest, class: ui("select select-bordered w-full", className), value }, K(() => val2(items) || [], (opt) => S("option", { value: opt.value, $selected: () => String(val2(value)) === String(opt.value) }, opt.label), (opt) => opt.value)); if (!label) return selectEl; return S("label", { class: "fieldset-label flex flex-col gap-1" }, [ S("span", {}, label), selectEl ]); }; // src/components/Stack.js var exports_Stack = {}; __export(exports_Stack, { Stack: () => Stack }); var Stack = (props, children) => { const { class: className, ...rest } = props; return S("div", { ...rest, class: ui("stack", className) }, children); }; // src/components/Stat.js var exports_Stat = {}; __export(exports_Stat, { Stat: () => Stat }); var Stat = (props) => { const { class: className, icon, label, value, desc, ...rest } = props; return S("div", { ...rest, class: ui("stat", className) }, [ icon && S("div", { class: "stat-figure text-secondary" }, icon), label && S("div", { class: "stat-title" }, label), S("div", { class: "stat-value" }, () => val2(value) ?? value), desc && S("div", { class: "stat-desc" }, desc) ]); }; // src/components/Swap.js var exports_Swap = {}; __export(exports_Swap, { Swap: () => Swap }); var Swap = (props) => { const { class: className, value, on, off, ...rest } = props; return S("label", { ...rest, class: ui("swap", className) }, [ S("input", { type: "checkbox", checked: () => val2(value), onclick: (e) => { if (typeof value === "function") { value(e.target.checked); } } }), S("div", { class: "swap-on" }, on), S("div", { class: "swap-off" }, off) ]); }; // src/components/Table.js var exports_Table = {}; __export(exports_Table, { Table: () => Table }); var Table = (props) => { const { class: className, items = [], columns = [], keyFn, zebra = false, pinRows = false, empty = "nodata", ...rest } = props; const tableClass = () => { const zebraClass = val2(zebra) ? "table-zebra" : ""; const pinRowsClass = val2(pinRows) ? "table-pin-rows" : ""; return ui("table", className, zebraClass, pinRowsClass); }; const getInternalKeyFn = keyFn || ((item, idx) => item.id || idx); return S("div", { class: "overflow-x-auto w-full bg-base-100 rounded-box border border-base-300" }, [ S("table", { ...rest, class: tableClass }, [ S("thead", {}, [ S("tr", {}, columns.map((col) => S("th", { class: col.class || "" }, col.label))) ]), S("tbody", {}, [ K(items, (item, index) => { const it = () => { const currentItems = val2(items); const key = getInternalKeyFn(item, index); return currentItems.find((u, i) => getInternalKeyFn(u, i) === key) || item; }; return S("tr", { class: "hover" }, columns.map((col) => { const cellContent = () => { const latestItem = it(); if (col.render) return col.render(latestItem, index); return val2(latestItem[col.key]); }; return S("td", { class: col.class || "" }, [cellContent]); })); }, getInternalKeyFn), J(() => val2(items).length === 0, () => S("tr", {}, [ S("td", { colspan: columns.length, class: "text-center p-10 opacity-50" }, [ val2(empty) ]) ])) ]) ]) ]); }; // src/components/Tabs.js var exports_Tabs = {}; __export(exports_Tabs, { Tabs: () => Tabs }); var Tabs = (props) => { const { items, class: className, onTabClose, ...rest } = props; const itemsSignal = typeof items === "function" ? items : () => items || []; const activeIndex = B(0); R(() => { const list = itemsSignal(); const idx = list.findIndex((it) => val2(it.active) === true); if (idx !== -1 && activeIndex() !== idx) { activeIndex(idx); } }); const removeTab = (indexToRemove, item) => { if (item.onClose) item.onClose(item); if (onTabClose) onTabClose(item, indexToRemove); const currentItems = itemsSignal(); const newItems = currentItems.filter((_2, idx) => idx !== indexToRemove); const isWritableSignal = typeof items === "function" && !items._isComputed; if (!isWritableSignal) { console.warn("Tabs: items must be a writable signal to support closable tabs"); return; } items(newItems); if (newItems.length === 0) return; let newActive = activeIndex(); if (indexToRemove < newActive) newActive--; else if (indexToRemove === newActive) newActive = Math.min(newActive, newItems.length - 1); activeIndex(newActive); }; return S("div", { ...rest, class: ui("tabs", className) }, () => { const list = itemsSignal(); const elements = []; for (let i = 0;i < list.length; i++) { const item = list[i]; const label = val2(item.label); const labelNode = label instanceof Node ? label : document.createTextNode(String(label)); const buttonChildren = []; if (item.closable) { const closeIcon = getIcon("icon-[lucide--x]"); closeIcon.classList.add("w-3.5", "h-3.5", "ml-2", "cursor-pointer", "hover:opacity-70"); closeIcon.onclick = (e) => { e.stopPropagation(); removeTab(i, item); }; const wrapper = S("span", { class: "flex items-center" }, [labelNode, closeIcon]); buttonChildren.push(wrapper); } else { buttonChildren.push(labelNode); } const buttonBase = S("button", { class: () => ui("tab", activeIndex() === i ? "tab-active" : ""), onclick: (e) => { e.preventDefault(); if (!val2(item.disabled)) { if (item.onclick) item.onclick(); activeIndex(i); } } }, buttonChildren); const button = item.tip ? S("div", { class: "tooltip", "data-tip": item.tip }, buttonBase) : buttonBase; elements.push(button); let contentNode; const rawContent = val2(item.content); if (typeof rawContent === "function") { contentNode = rawContent(); } else if (rawContent instanceof Node) { contentNode = rawContent; } else { contentNode = document.createTextNode(String(rawContent)); } const inner = S("div", { class: "tab-content-inner" }, contentNode); const panel = S("div", { class: "tab-content bg-base-100 border-base-300 p-6", style: () => activeIndex() === i ? "display: block" : "display: none" }, inner); elements.push(panel); } return elements; }); }; // src/components/Timeline.js var exports_Timeline = {}; __export(exports_Timeline, { Timeline: () => Timeline }); var Timeline = (props) => { const { class: className, items = [], vertical = true, compact = false, ...rest } = props; const iconMap = { info: "icon-[lucide--info]", success: "icon-[lucide--check-circle]", warning: "icon-[lucide--alert-triangle]", error: "icon-[lucide--alert-circle]" }; return S("ul", { ...rest, class: () => ui(`timeline ${val2(vertical) ? "timeline-vertical" : "timeline-horizontal"} ${val2(compact) ? "timeline-compact" : ""}`, className) }, () => { const list = (typeof items === "function" ? items() : items) || []; return list.map((item, i) => { const isFirst = i === 0; const isLast = i === list.length - 1; const itemType = item.type || "success"; const isCompleted = () => val2(item.completed); const prevCompleted = () => i > 0 && val2(list[i - 1].completed); const renderSlot = (content) => typeof content === "function" ? content() : content; return S("li", { class: "flex-1" }, [ !isFirst ? S("hr", { class: () => prevCompleted() ? "bg-primary" : "" }) : null, S("div", { class: "timeline-start" }, [() => renderSlot(item.title)]), S("div", { class: "timeline-middle" }, [ () => item.icon ? getIcon(item.icon) : getIcon(iconMap[itemType] || iconMap.success) ]), S("div", { class: "timeline-end timeline-box shadow-sm" }, [() => renderSlot(item.detail)]), !isLast ? S("hr", { class: () => isCompleted() ? "bg-primary" : "" }) : null ]); }); }); }; // src/components/Toast.js var exports_Toast = {}; __export(exports_Toast, { Toast: () => Toast }); var Toast = (message, type = "alert-success", duration = 3500) => { let container = document.getElementById("sigpro-toast-container"); if (!container) { container = S("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(container); } const toastHost = S("div", { style: "display: contents" }); container.appendChild(toastHost); let timeoutId; const close = () => { clearTimeout(timeoutId); const el = toastHost.firstElementChild; if (el && !el.classList.contains("opacity-0")) { el.classList.add("translate-x-full", "opacity-0"); setTimeout(() => { instance.destroy(); toastHost.remove(); if (!container.hasChildNodes()) container.remove(); }, 300); } else { instance.destroy(); toastHost.remove(); } }; const ToastComponent = () => { const closeIcon = getIcon("icon-[lucide--x]"); const el = S("div", { class: `alert alert-soft ${type} shadow-lg transition-all duration-300 translate-x-10 opacity-0 pointer-events-auto` }, [ S("span", {}, [typeof message === "function" ? message() : message]), Button({ class: "btn-xs btn-circle btn-ghost", onclick: close }, closeIcon) ]); requestAnimationFrame(() => el.classList.remove("translate-x-10", "opacity-0")); return el; }; const instance = H(ToastComponent, toastHost); if (duration > 0) { timeoutId = setTimeout(close, duration); } return close; }; // src/components/Tooltip.js var exports_Tooltip = {}; __export(exports_Tooltip, { Tooltip: () => Tooltip }); var Tooltip = (props, children) => S("div", { ...props, class: () => ui("tooltip w-full", props.class), "data-tip": props.tip }, children); // index.js var Components = { ...exports_Accordion, ...exports_Alert, ...exports_Autocomplete, ...exports_Badge, ...exports_Button, ...exports_Checkbox, ...exports_Colorpicker, ...exports_Datepicker, ...exports_Drawer, ...exports_Dropdown, ...exports_Fab, ...exports_Fieldset, ...exports_Fileinput, ...exports_Indicator, ...exports_Input, ...exports_Label, ...exports_List, ...exports_Menu, ...exports_Modal, ...exports_Navbar, ...exports_Radio, ...exports_Range, ...exports_Rating, ...exports_Select, ...exports_Stack, ...exports_Stat, ...exports_Swap, ...exports_Table, ...exports_Tabs, ...exports_Timeline, ...exports_Toast, ...exports_Tooltip }; var Utils = { Locale, tt }; if (typeof window !== "undefined") { Object.entries({ ...Components, ...Utils }).forEach(([name, value]) => { Object.defineProperty(window, name, { value, writable: false, configurable: true, enumerable: true }); }); console.log("SigProUI installed"); } })();