From c3ca59fa5a7b0595c76fbb38ab7e2a7df9d505d2 Mon Sep 17 00:00:00 2001 From: natxocc Date: Tue, 14 Apr 2026 21:57:45 +0200 Subject: [PATCH] 1.2.0 --- dist/sigpro-ui.esm.js | 70 ++--- dist/sigpro-ui.esm.min.js | 8 +- dist/sigpro-ui.js | 70 ++--- dist/sigpro-ui.min.js | 8 +- docs/sigpro-ui.min.js | 70 ++--- src/components/Fetch.js | 45 +++ src/components/Fetch2.js | 53 ++++ src/sigpro.js | 76 ++---- src/sigpro.min.js | 1 - src/sigpro2.js | 558 ++++++++++++++++++++++++++++++++++++++ 10 files changed, 742 insertions(+), 217 deletions(-) create mode 100644 src/components/Fetch.js create mode 100644 src/components/Fetch2.js delete mode 100644 src/sigpro.min.js create mode 100644 src/sigpro2.js diff --git a/dist/sigpro-ui.esm.js b/dist/sigpro-ui.esm.js index 396563d..5df6280 100644 --- a/dist/sigpro-ui.esm.js +++ b/dist/sigpro-ui.esm.js @@ -119,11 +119,11 @@ var trackUpdate = (subs, trigger = false) => { if (!trigger && activeEffect && !activeEffect._disposed) { subs.add(activeEffect); (activeEffect._deps ||= new Set).add(subs); - } else if (trigger && subs.size > 0) { + } else if (trigger) { let hasQueue = false; - for (const e of subs) { + subs.forEach((e) => { if (e === activeEffect || e._disposed) - continue; + return; if (e._isComputed) { e._dirty = true; if (e._subs) @@ -132,7 +132,7 @@ var trackUpdate = (subs, trigger = false) => { effectQueue.add(e); hasQueue = true; } - } + }); if (hasQueue && !isFlushing && batchDepth === 0) queueMicrotask(flush); } @@ -200,9 +200,8 @@ var $2 = (val, key = null) => { var $$ = (target) => { if (!isObj(target)) return target; - let proxy = proxyCache.get(target); - if (proxy) - return proxy; + if (proxyCache.has(target)) + return proxyCache.get(target); const subsMap = new Map; const getSubs = (k) => { let s = subsMap.get(k); @@ -210,30 +209,28 @@ var $$ = (target) => { subsMap.set(k, s = new Set); return s; }; - proxy = new Proxy(target, { - get(t, k, receiver) { - if (typeof k !== "symbol") - trackUpdate(getSubs(k)); - return $$(Reflect.get(t, k, receiver)); + const proxy = new Proxy(target, { + get(t, k) { + trackUpdate(getSubs(k)); + return $$(t[k]); }, - set(t, k, v, receiver) { - const isNew = !Reflect.has(t, k); - const oldV = Reflect.get(t, k, receiver); - const result = Reflect.set(t, k, v, receiver); - if (result && !Object.is(oldV, v)) { + set(t, k, v) { + const isNew = !(k in t); + if (!Object.is(t[k], v)) { + t[k] = v; trackUpdate(getSubs(k), true); if (isNew) trackUpdate(getSubs(ITER), true); } - return result; + return true; }, deleteProperty(t, k) { - const result = Reflect.deleteProperty(t, k); - if (result) { + const res = Reflect.deleteProperty(t, k); + if (res) { trackUpdate(getSubs(k), true); trackUpdate(getSubs(ITER), true); } - return result; + return res; }, ownKeys(t) { trackUpdate(getSubs(ITER)); @@ -520,35 +517,6 @@ Router.params = $2({}); Router.to = (p) => window.location.hash = p.replace(/^#?\/?/, "#/"); Router.back = () => window.history.back(); Router.path = () => window.location.hash.replace(/^#/, "") || "/"; -var Anim = (show, render, { enter, leave } = {}) => { - const wrap = Tag2("div", { style: "display:contents" }); - let view = null; - const wait = (el, cb) => { - let done = false; - const finish = () => !done && (done = true, cb()); - if (!el) - return finish(); - "transitionend animationend".split(" ").map((e) => el.addEventListener(e, finish, { once: true })); - setTimeout(finish, 500); - }; - Watch2(show, (on) => { - if (on && !view) { - const el = (view = Render(render)).container.firstChild; - wrap.appendChild(view.container); - if (enter && el) { - el.classList.add(enter); - el.clientTop; - el.classList.add(enter + "-active"); - wait(el, () => el.classList.remove(enter, enter + "-active")); - } - } else if (!on && view) { - const el = view.container.firstChild; - const del = () => (view?.destroy(), view = null); - leave && el ? (el.classList.add(leave), wait(el, del)) : del(); - } - }); - return onUnmount(() => view?.destroy()), wrap; -}; var Mount2 = (comp, target) => { const t = typeof target === "string" ? doc.querySelector(target) : target; if (!t) @@ -560,7 +528,7 @@ var Mount2 = (comp, target) => { MOUNTED_NODES.set(t, inst); return inst; }; -var SigPro = Object.freeze({ $: $2, $$, Watch: Watch2, Tag: Tag2, Render, If: If2, For: For2, Router, Mount: Mount2, onMount, onUnmount, Anim, Batch }); +var SigPro = Object.freeze({ $: $2, $$, Watch: Watch2, Tag: Tag2, Render, If: If2, For: For2, Router, Mount: Mount2, onMount, onUnmount, Batch }); if (typeof window !== "undefined") { Object.assign(window, SigPro); "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((t) => window[t[0].toUpperCase() + t.slice(1)] = (p, c) => SigPro.Tag(t, p, c)); diff --git a/dist/sigpro-ui.esm.min.js b/dist/sigpro-ui.esm.min.js index f8b42d5..4bb09f9 100644 --- a/dist/sigpro-ui.esm.min.js +++ b/dist/sigpro-ui.esm.min.js @@ -1,7 +1,7 @@ -var I_=Object.defineProperty;var q=(f,M)=>{for(var _ in M)I_(f,_,{get:M[_],enumerable:!0,configurable:!0,set:(E)=>M[_]=()=>E})};var y=(f)=>typeof f==="function",Qf=(f)=>f&&typeof f==="object",o=Array.isArray,x=typeof document<"u"?document:null,of=(f)=>f?._isRuntime?f.container:f instanceof Node?f:x.createTextNode(f==null?"":String(f)),O=null,U=null,a=!1,ff=0,_f=new Set,sf=new WeakMap,Pf=Symbol("iter"),Jf=new WeakMap,r=(f)=>{if(!f||f._disposed)return;f._disposed=!0;let M=[f];while(M.length){let _=M.pop();if(_._cleanups)_._cleanups.forEach((E)=>E()),_._cleanups.clear();if(_._children)_._children.forEach((E)=>M.push(E)),_._children.clear();if(_._deps)_._deps.forEach((E)=>E.delete(_)),_._deps.clear()}},u_=(f)=>{if(U)(U._mounts||=[]).push(f)},v=(f)=>{if(U)(U._cleanups||=new Set).add(f)},m_=(f)=>{let M=O;O=null;try{return f()}finally{O=M}},e=(f,M=!1)=>{let _=()=>{if(_._disposed)return;if(_._deps)_._deps.forEach((L)=>L.delete(_));if(_._cleanups)_._cleanups.forEach((L)=>L()),_._cleanups.clear();let E=O,A=U;O=U=_;try{return _._result=f()}catch(L){console.error("[SigPro]",L)}finally{O=E,U=A}};if(_._deps=_._cleanups=_._children=null,_._disposed=!1,_._isComputed=M,_._depth=O?O._depth+1:0,_._mounts=[],_._parent=U,U)(U._children||=new Set).add(_);return _},af=()=>{if(a)return;a=!0;let f=Array.from(_f).sort((M,_)=>M._depth-_._depth);_f.clear();for(let M of f)if(!M._disposed)M();a=!1},v_=(f)=>{ff++;try{return f()}finally{if(ff--,ff===0&&_f.size>0&&!a)af()}},j=(f,M=!1)=>{if(!M&&O&&!O._disposed)f.add(O),(O._deps||=new Set).add(f);else if(M&&f.size>0){let _=!1;for(let E of f){if(E===O||E._disposed)continue;if(E._isComputed){if(E._dirty=!0,E._subs)j(E._subs,!0)}else _f.add(E),_=!0}if(_&&!a&&ff===0)queueMicrotask(af)}},i=(f,M=null)=>{let _=new Set;if(y(f)){let E,A=!0,L=()=>{if(A){let W=O;O=L;try{let T=f();if(!Object.is(E,T))E=T,A=!1,j(_,!0)}finally{O=W}}return j(_),E};if(L._isComputed=!0,L._subs=_,L._dirty=!0,L._deps=null,L._disposed=!1,L.markDirty=()=>{A=!0},L.stop=()=>{if(L._disposed=!0,L._deps)L._deps.forEach((W)=>W.delete(L)),L._deps.clear();_.clear()},U)v(L.stop);return L}if(M)try{f=JSON.parse(localStorage.getItem(M))??f}catch(E){}return(...E)=>{if(E.length){let A=y(E[0])?E[0](f):E[0];if(!Object.is(f,A)){if(f=A,M)localStorage.setItem(M,JSON.stringify(f));j(_,!0)}}return j(_),f}},ef=(f)=>{if(!Qf(f))return f;let M=sf.get(f);if(M)return M;let _=new Map,E=(A)=>{let L=_.get(A);if(!L)_.set(A,L=new Set);return L};return M=new Proxy(f,{get(A,L,W){if(typeof L!=="symbol")j(E(L));return ef(Reflect.get(A,L,W))},set(A,L,W,T){let P=!Reflect.has(A,L),J=Reflect.get(A,L,T),B=Reflect.set(A,L,W,T);if(B&&!Object.is(J,W)){if(j(E(L),!0),P)j(E(Pf),!0)}return B},deleteProperty(A,L){let W=Reflect.deleteProperty(A,L);if(W)j(E(L),!0),j(E(Pf),!0);return W},ownKeys(A){return j(E(Pf)),Reflect.ownKeys(A)}}),sf.set(f,M),M},g=(f,M)=>{if(M===void 0){let E=e(f);return E(),()=>r(E)}let _=e(()=>{let E=Array.isArray(f)?f.map((A)=>A()):f();m_(()=>M(E))});return _(),()=>r(_)},Bf=(f)=>{if(f._cleanups)f._cleanups.forEach((M)=>M()),f._cleanups.clear();if(f._ownerEffect)r(f._ownerEffect);if(f.childNodes)f.childNodes.forEach(Bf)},g_=/^\s*(javascript|data|vbscript):/i,c_=(f)=>f==="src"||f==="href"||f.startsWith("on"),tf=(f,M)=>{if(M==null||M===!1)return null;if(c_(f)){let _=String(M);if(g_.test(_))return console.warn(`[SigPro] Bloqueado protocolo peligroso en ${f}`),"#"}return M},H=(f,M={},_=[])=>{if(M instanceof Node||o(M)||!Qf(M))_=M,M={};if(y(f)){let W={_mounts:[],_cleanups:new Set},T=e(()=>{let Q=f(M,{children:_,emit:(C,...K)=>M[`on${C[0].toUpperCase()}${C.slice(1)}`]?.(...K)});return T._result=Q,Q});T();let P=T._result;if(P==null)return null;let J=P instanceof Node||o(P)&&P.every((Q)=>Q instanceof Node)?P:x.createTextNode(String(P)),B=(Q)=>{if(Qf(Q)&&!Q._isRuntime)Q._mounts=T._mounts||[],Q._cleanups=T._cleanups||new Set,Q._ownerEffect=T};return o(J)?J.forEach(B):B(J),J}let E=/^(svg|path|circle|rect|line|polyline|polygon|g|defs|text|tspan|use)$/.test(f),A=E?x.createElementNS("http://www.w3.org/2000/svg",f):x.createElement(f);A._cleanups=new Set;for(let W in M){if(!M.hasOwnProperty(W))continue;let T=M[W];if(W==="ref"){y(T)?T(A):T.current=A;continue}if(W.startsWith("on")){let P=W.slice(2).toLowerCase();A.addEventListener(P,T);let J=()=>A.removeEventListener(P,T);A._cleanups.add(J),v(J)}else if(y(T)){let P=e(()=>{let J=tf(W,T());if(W==="class")A.className=J||"";else if(J==null)A.removeAttribute(W);else if(W in A&&!E)A[W]=J;else A.setAttribute(W,J===!0?"":J)});if(P(),A._cleanups.add(()=>r(P)),v(()=>r(P)),/^(INPUT|TEXTAREA|SELECT)$/.test(A.tagName)&&(W==="value"||W==="checked")){let J=W==="checked"?"change":"input";A.addEventListener(J,(B)=>T(B.target[W]))}}else{let P=tf(W,T);if(P!=null)if(W in A&&!E)A[W]=P;else A.setAttribute(W,P===!0?"":P)}}let L=(W)=>{if(o(W))return W.forEach(L);if(y(W)){let T=x.createTextNode("");A.appendChild(T);let P=[],J=e(()=>{let B=W(),Q=(o(B)?B:[B]).map(of);P.forEach((K)=>{if(K._isRuntime)K.destroy();else Bf(K);if(K.parentNode)K.remove()});let C=T;for(let K=Q.length-1;K>=0;K--){let X=Q[K];if(X.parentNode!==C.parentNode)C.parentNode?.insertBefore(X,C);if(X._mounts)X._mounts.forEach((Y)=>Y());C=X}P=Q});J(),A._cleanups.add(()=>r(J)),v(()=>r(J))}else{let T=of(W);if(A.appendChild(T),T._mounts)T._mounts.forEach((P)=>P())}};return L(_),A},s=(f)=>{let M=new Set,_=[],E=U,A=O,L=x.createElement("div");L.style.display="contents",L.setAttribute("role","presentation"),U={_cleanups:M,_mounts:_},O=null;let W=(T)=>{if(!T)return;if(T._isRuntime)M.add(T.destroy),L.appendChild(T.container);else if(o(T))T.forEach(W);else L.appendChild(T instanceof Node?T:x.createTextNode(String(T==null?"":T)))};try{W(f({onCleanup:(T)=>M.add(T)}))}finally{U=E,O=A}return _.forEach((T)=>T()),{_isRuntime:!0,container:L,destroy:()=>{M.forEach((T)=>T()),Bf(L),L.remove()}}},f_=(f,M,_=null)=>{let E=x.createTextNode(""),A=H("div",{style:"display:contents"},[E]),L=null;return g(()=>!!(y(f)?f():f),(W)=>{if(L)L.destroy(),L=null;let T=W?M:_;if(T)L=s(()=>y(T)?T():T),A.insertBefore(L.container,E)}),v(()=>L?.destroy()),A},__=(f,M,_)=>{let E=x.createTextNode(""),A=H("div",{style:"display:contents"},[E]),L=new Map;return g(()=>(y(f)?f():f)||[],(W)=>{let T=new Map,P=[],J=W||[];for(let Q=0;QM(C,Q));else L.delete(K);T.set(K,X),P.push(X)}L.forEach((Q)=>Q.destroy());let B=E;for(let Q=P.length-1;Q>=0;Q--){let K=P[Q].container;if(K.nextSibling!==B)A.insertBefore(K,B);B=K}L=T}),A},b=(f)=>{let M=()=>window.location.hash.slice(1)||"/",_=i(M()),E=()=>_(M());window.addEventListener("hashchange",E),v(()=>window.removeEventListener("hashchange",E));let A=H("div",{class:"router-hook"}),L=null;return g([_],()=>{let W=_(),T=f.find((P)=>{let J=P.path.split("/").filter(Boolean),B=W.split("/").filter(Boolean);return J.length===B.length&&J.every((Q,C)=>Q[0]===":"||Q===B[C])})||f.find((P)=>P.path==="*");if(T){L?.destroy();let P={};T.path.split("/").filter(Boolean).forEach((J,B)=>{if(J[0]===":")P[J.slice(1)]=W.split("/").filter(Boolean)[B]}),b.params(P),L=s(()=>y(T.component)?T.component(P):T.component),A.replaceChildren(L.container)}}),A};b.params=i({});b.to=(f)=>window.location.hash=f.replace(/^#?\/?/,"#/");b.back=()=>window.history.back();b.path=()=>window.location.hash.replace(/^#/,"")||"/";var p_=(f,M,{enter:_,leave:E}={})=>{let A=H("div",{style:"display:contents"}),L=null,W=(T,P)=>{let J=!1,B=()=>!J&&(J=!0,P());if(!T)return B();"transitionend animationend".split(" ").map((Q)=>T.addEventListener(Q,B,{once:!0})),setTimeout(B,500)};return g(f,(T)=>{if(T&&!L){let P=(L=s(M)).container.firstChild;if(A.appendChild(L.container),_&&P)P.classList.add(_),P.clientTop,P.classList.add(_+"-active"),W(P,()=>P.classList.remove(_,_+"-active"))}else if(!T&&L){let P=L.container.firstChild,J=()=>(L?.destroy(),L=null);E&&P?(P.classList.add(E),W(P,J)):J()}}),v(()=>L?.destroy()),A},M_=(f,M)=>{let _=typeof M==="string"?x.querySelector(M):M;if(!_)return;if(Jf.has(_))Jf.get(_).destroy();let E=s(y(f)?f:()=>f);return _.replaceChildren(E.container),Jf.set(_,E),E},lf=Object.freeze({$:i,$$:ef,Watch:g,Tag:H,Render:s,If:f_,For:__,Router:b,Mount:M_,onMount:u_,onUnmount:v,Anim:p_,Batch:v_});if(typeof window<"u")Object.assign(window,lf),"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((f)=>window[f[0].toUpperCase()+f.slice(1)]=(M,_)=>lf.Tag(f,M,_));var Ef={};q(Ef,{default:()=>d_,Tooltip:()=>w_,Toast:()=>k_,Timeline:()=>H_,Tabs:()=>F_,Table:()=>U_,Swap:()=>V_,Stat:()=>O_,Stack:()=>N_,Select:()=>D_,Rating:()=>z_,Range:()=>h_,Radio:()=>q_,Navbar:()=>R_,Modal:()=>Y_,Menu:()=>C_,List:()=>S_,Label:()=>K_,Input:()=>t,Indicator:()=>Z_,Fileinput:()=>X_,Fieldset:()=>G_,Fab:()=>B_,Dropdown:()=>Q_,Drawer:()=>J_,Datepicker:()=>P_,Colorpicker:()=>W_,Checkbox:()=>T_,Button:()=>l,Badge:()=>A_,Autocomplete:()=>$_,Alert:()=>L_,Accordion:()=>E_});var Gf={};q(Gf,{Accordion:()=>E_});var Mf={};q(Mf,{val:()=>G,ui:()=>Z,getIcon:()=>h});var G=(f)=>typeof f==="function"?f():f,Z=(f,M)=>typeof M==="function"?()=>`${f} ${M()||""}`.trim():`${f} ${M||""}`.trim(),h=(f)=>{if(!f)return null;if(typeof f==="function")return Tag("span",{class:"mr-1"},f());if(typeof f==="object")return Tag("span",{class:"mr-1"},f);if(typeof f==="string"){let M=f.trim().split(/\s+/),_=M[M.length-1]==="right",E=_?M.slice(0,-1).join(" "):f,A=_?"ml-1":"mr-1";if(E&&!E.startsWith("icon-[")&&!E.includes("--"))return Tag("span",{class:A},E);return Tag("span",{class:`${E} ${A}`.trim()})}return null};var E_=(f,M)=>{let{class:_,title:E,name:A,open:L,...W}=f;return Tag("div",{...W,class:Z("collapse collapse-arrow bg-base-200 mb-2",_)},[Tag("input",{type:A?"radio":"checkbox",name:A,checked:G(L)}),Tag("div",{class:"collapse-title text-xl font-medium"},E),Tag("div",{class:"collapse-content"},M)])};var Xf={};q(Xf,{Alert:()=>L_});var L_=(f,M)=>{let{class:_,actions:E,type:A="info",soft:L=!0,...W}=f,T={info:"icon-[lucide--info]",success:"icon-[lucide--check-circle]",warning:"icon-[lucide--alert-triangle]",error:"icon-[lucide--alert-circle]"},B=[`alert-${A}`,L?"alert-soft":"",_].filter(Boolean).join(" "),Q=M||f.message;return Tag("div",{...W,role:"alert",class:Z("alert",B)},()=>[h(T[A]),Tag("div",{class:"flex-1"},[Tag("span",{},[typeof Q==="function"?Q():Q])]),E?Tag("div",{class:"flex-none"},[typeof E==="function"?E():E]):null].filter(Boolean))};var Kf={};q(Kf,{Autocomplete:()=>$_});var r_={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"}},b_=$("es");var I=(f)=>()=>r_[b_()][f]||f;var Zf={};q(Zf,{Input:()=>t});var t=(f)=>{let{class:M,value:_,type:E="text",icon:A,oninput:L,placeholder:W,disabled:T,validate:P,label:J,...B}=f,Q=E==="password",C=$(!1),K=$(null),X={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]"},Y=A?h(A):X[E]?h(X[E]):null,z=()=>h(C()?"icon-[lucide--eye-off]":"icon-[lucide--eye]"),V=Y?"pl-10":"",k=Q?"pr-10":"",d=()=>{if(M?.includes("input-xs"))return"btn-xs";if(M?.includes("input-sm"))return"btn-sm";if(M?.includes("input-lg"))return"btn-lg";return"btn-md"},n=(D)=>{let c=D.target.value;if(P){let Lf=P(c);K(Lf||null)}L?.(D)},F=()=>K()&&K()!=="",S=()=>{let D=`input w-full ${V} ${k}`;if(M)D+=` ${M}`;if(F())D+=" input-error";return D.trim()},R=Tag("input",{...B,type:()=>Q?C()?"text":"password":E,placeholder:W||(J?" ":W),class:S,value:_,oninput:n,disabled:()=>G(T),"aria-invalid":()=>F()?"true":"false"}),N=()=>[R,Y?Tag("div",{class:"absolute left-3 inset-y-0 flex items-center pointer-events-none text-base-content/60"},Y):null,Q?Tag("button",{type:"button",class:Z("absolute right-3 inset-y-0 flex items-center","btn btn-ghost btn-circle opacity-50 hover:opacity-100",d()),onclick:(D)=>{D.preventDefault(),C(!C())}},()=>z()):null,Tag("div",{class:"text-error text-xs mt-1 px-3 absolute -bottom-5 left-0"},()=>F()?K():null)];if(J)return Tag("label",{class:Z("floating-label w-full",M)},()=>[Tag("div",{class:"relative w-full"},N),Tag("span",{},G(J))]);return Tag("div",{class:"relative w-full"},N)};var $_=(f)=>{let{class:M,items:_=[],value:E,onselect:A,label:L,placeholder:W,...T}=f,P=$(G(E)||""),J=$(!1),B=$(-1),Q=$([]);Watch(()=>{let X=String(P()).toLowerCase(),Y=G(_)||[],z=X?Y.filter((V)=>(typeof V==="string"?V:V.label).toLowerCase().includes(X)):Y;Q(z)});let C=(X)=>{let Y=typeof X==="string"?X:X.value,z=typeof X==="string"?X:X.label;if(P(z),typeof E==="function")E(Y);A?.(X),J(!1),B(-1)},K=(X)=>{let Y=Q();if(X.key==="ArrowDown")X.preventDefault(),J(!0),B(Math.min(B()+1,Y.length-1));else if(X.key==="ArrowUp")X.preventDefault(),B(Math.max(B()-1,0));else if(X.key==="Enter"&&B()>=0)X.preventDefault(),C(Y[B()]);else if(X.key==="Escape")J(!1)};return Tag("div",{class:"relative w-full"},[t({label:L,class:M,placeholder:W||I("search")(),value:P,onfocus:()=>J(!0),onblur:()=>setTimeout(()=>J(!1),150),onkeydown:K,oninput:(X)=>{let Y=X.target.value;if(P(Y),typeof E==="function")E(Y);J(!0),B(-1)},...T}),Tag("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:()=>J()&&Q().length?"display:block":"display:none"},[For(Q,(X,Y)=>Tag("li",{},[Tag("a",{class:()=>`block w-full ${B()===Y?"active bg-primary text-primary-content":""}`,onclick:()=>C(X),onmouseenter:()=>B(Y)},typeof X==="string"?X:X.label)]),(X,Y)=>(typeof X==="string"?X:X.value)+Y),()=>Q().length?null:Tag("li",{class:"p-2 text-center opacity-50"},I("nodata")())])])};var Sf={};q(Sf,{Badge:()=>A_});var A_=(f,M)=>{let{class:_,...E}=f;return Tag("span",{...E,class:Z("badge",_)},M)};var Cf={};q(Cf,{Button:()=>l});var l=(f,M)=>{let{class:_,loading:E,icon:A,...L}=f,W=h(A);return Tag("button",{...L,class:Z("btn",_),disabled:()=>G(E)||G(f.disabled)},()=>[G(E)&&Tag("span",{class:"loading loading-spinner"}),W,M].filter(Boolean))};var Yf={};q(Yf,{Checkbox:()=>T_});var T_=(f)=>{let{class:M,value:_,toggle:E,label:A,...L}=f,W=Tag("input",{...L,type:"checkbox",class:()=>Z(G(E)?"toggle":"checkbox",M),checked:_});return Tag("label",{class:"label cursor-pointer justify-start gap-3"},[W,A?Tag("span",{class:"label-text"},A):null])};var Rf={};q(Rf,{Colorpicker:()=>W_});var W_=(f)=>{let{class:M,value:_,label:E,...A}=f,L=$(!1),W=["#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"],T=()=>G(_)||"#000000";return Tag("div",{class:Z("relative w-fit",M)},[Tag("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:(P)=>{P.stopPropagation(),L(!L())},...A},[Tag("div",{class:"size-5 rounded-sm shadow-inner border border-black/10 shrink-0",style:()=>`background-color: ${T()}`}),E?Tag("span",{class:"opacity-80"},E):null]),If(L,()=>Tag("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:(P)=>P.stopPropagation()},[Tag("div",{class:"grid grid-cols-8 gap-1"},W.map((P)=>Tag("button",{type:"button",style:`background-color: ${P}`,class:()=>{return`size-6 rounded-sm cursor-pointer transition-all hover:scale-125 hover:z-10 active:scale-95 outline-none border border-black/5 - ${T().toLowerCase()===P.toLowerCase()?"ring-2 ring-offset-1 ring-primary z-10 scale-110":""}`},onclick:()=>{if(typeof _==="function")_(P);L(!1)}})))])),If(L,()=>Tag("div",{class:"fixed inset-0 z-[100]",onclick:()=>L(!1)}))])};var qf={};q(qf,{Datepicker:()=>P_});var P_=(f)=>{let{class:M,value:_,range:E,label:A,placeholder:L,hour:W=!1,...T}=f,P=$(!1),J=$(new Date),B=$(null),Q=$(0),C=$(0),K=()=>G(E)===!0,X=new Date,Y=`${X.getFullYear()}-${String(X.getMonth()+1).padStart(2,"0")}-${String(X.getDate()).padStart(2,"0")}`,z=(S)=>{let R=S.getFullYear(),N=String(S.getMonth()+1).padStart(2,"0"),D=String(S.getDate()).padStart(2,"0");return`${R}-${N}-${D}`},V=(S)=>{let R=z(S),N=G(_);if(K())if(!N?.start||N.start&&N.end){if(typeof _==="function")_({start:R,end:null,...W&&{startHour:Q()}})}else{let D=N.start;if(typeof _==="function"){let c=R{let S=G(_);if(!S){k("");return}let R="";if(typeof S==="string")R=W&&S.includes("T")?S.replace("T"," "):S;else if(S.start&&S.end){let N=W&&S.startHour!==void 0?`${S.start} ${String(S.startHour).padStart(2,"0")}:00`:S.start,D=W&&S.endHour!==void 0?`${S.end} ${String(S.endHour).padStart(2,"0")}:00`:S.end;R=`${N} - ${D}`}else if(S.start)R=`${W&&S.startHour!==void 0?`${S.start} ${String(S.startHour).padStart(2,"0")}:00`:S.start}...`;k(R)});let d=(S)=>{let R=J();J(new Date(R.getFullYear(),R.getMonth()+S,1))},n=(S)=>{let R=J();J(new Date(R.getFullYear()+S,R.getMonth(),1))},F=({value:S,onChange:R})=>{return Tag("div",{class:"flex-1"},[Tag("div",{class:"flex gap-2 items-center"},[Tag("input",{type:"range",min:0,max:23,value:S,class:"range range-xs flex-1",oninput:(N)=>{let D=parseInt(N.target.value);R(D)}}),Tag("span",{class:"text-sm font-mono min-w-[48px] text-center"},()=>String(G(S)).padStart(2,"0")+":00")])])};return Tag("div",{class:Z("relative w-full",M)},[t({label:A,placeholder:L||(K()?"Seleccionar rango...":"Seleccionar fecha..."),value:k,readonly:!0,icon:h("icon-[lucide--calendar]"),onclick:(S)=>{S.stopPropagation(),P(!P())},...T}),If(P,()=>Tag("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:(S)=>S.stopPropagation()},[Tag("div",{class:"flex justify-between items-center mb-4 gap-1"},[Tag("div",{class:"flex gap-0.5"},[Tag("button",{type:"button",class:"btn btn-ghost btn-xs px-1",onclick:()=>n(-1)},h("icon-[lucide--chevrons-left]")),Tag("button",{type:"button",class:"btn btn-ghost btn-xs px-1",onclick:()=>d(-1)},h("icon-[lucide--chevron-left]"))]),Tag("span",{class:"font-bold uppercase flex-1 text-center"},[()=>J().toLocaleString("es-ES",{month:"short",year:"numeric"})]),Tag("div",{class:"flex gap-0.5"},[Tag("button",{type:"button",class:"btn btn-ghost btn-xs px-1",onclick:()=>d(1)},h("icon-[lucide--chevron-right]")),Tag("button",{type:"button",class:"btn btn-ghost btn-xs px-1",onclick:()=>n(1)},h("icon-[lucide--chevrons-right]"))])]),Tag("div",{class:"grid grid-cols-7 gap-1",onmouseleave:()=>B(null)},[...["L","M","X","J","V","S","D"].map((S)=>Tag("div",{class:"text-[10px] opacity-40 font-bold text-center"},S)),()=>{let S=J(),R=S.getFullYear(),N=S.getMonth(),D=new Date(R,N,1).getDay(),c=D===0?6:D-1,Lf=new Date(R,N+1,0).getDate(),$f=[];for(let p=0;p{let m=G(_),Af=B(),y_=typeof m==="string"?m.split("T")[0]===w:m?.start===w,x_=m?.end===w,Tf=!1;if(K()&&m?.start){let Wf=m.start;if(!m.end&&Af)Tf=w>Wf&&w<=Af||w=Af;else if(m.end)Tf=w>Wf&&w{if(K())B(w)},onclick:()=>V(nf)},[p.toString()]))}return $f}]),W?Tag("div",{class:"mt-3 pt-2 border-t border-base-300"},[K()?Tag("div",{class:"flex gap-4"},[F({value:Q,onChange:(S)=>{Q(S);let R=G(_);if(R?.start)_({...R,startHour:S})}}),F({value:C,onChange:(S)=>{C(S);let R=G(_);if(R?.end)_({...R,endHour:S})}})]):F({value:Q,onChange:(S)=>{Q(S);let R=G(_);if(R&&typeof R==="string")_(R.split("T")[0]+"T"+String(S).padStart(2,"0")+":00:00")}})]):null])),If(P,()=>Tag("div",{class:"fixed inset-0 z-[90]",onclick:()=>P(!1)}))])};var hf={};q(hf,{Drawer:()=>J_});var J_=(f,M)=>{let{class:_,id:E,open:A,side:L,content:W,...T}=f,P=E||`drawer-${Math.random().toString(36).slice(2,9)}`;return Tag("div",{...T,class:Z("drawer",_)},[Tag("input",{id:P,type:"checkbox",class:"drawer-toggle",checked:()=>typeof A==="function"?A():A,onchange:(J)=>{if(typeof A==="function")A(J.target.checked)}}),Tag("div",{class:"drawer-content"},[typeof W==="function"?W():W]),Tag("div",{class:"drawer-side"},[Tag("label",{for:P,class:"drawer-overlay",onclick:()=>{if(typeof A==="function")A(!1)}}),Tag("div",{class:"min-h-full bg-base-200 w-80"},[typeof L==="function"?L():L])])])};var zf={};q(zf,{Dropdown:()=>Q_});var u=null;if(typeof window<"u"&&!window.__dropdownHandlerRegistered)window.addEventListener("click",(f)=>{if(u&&!u.contains(f.target))u.open=!1,u=null}),window.__dropdownHandlerRegistered=!0;var Q_=(f)=>{let{class:M,label:_,icon:E,items:A,...L}=f;return Tag("details",{...L,class:Z("dropdown",M)},[Tag("summary",{class:"btn m-1 flex items-center gap-2 list-none cursor-pointer",style:"display: inline-flex;",onclick:(W)=>{let T=W.currentTarget.closest("details");if(u&&u!==T)u.open=!1;setTimeout(()=>{u=T.open?T:null},0)}},[()=>E?typeof E==="function"?E():E:null,()=>_?typeof _==="function"?_():_:null]),Tag("ul",{tabindex:"-1",class:"dropdown-content z-[50] menu p-2 shadow bg-base-100 rounded-box w-52 border border-base-300"},[()=>{return(typeof A==="function"?A():A||[]).map((T)=>Tag("li",{},[Tag("a",{class:T.class||"",onclick:(P)=>{if(T.onclick)T.onclick(P);let J=P.currentTarget.closest("details");if(J){if(J.open=!1,u===J)u=null}}},[T.icon?Tag("span",{},T.icon):null,Tag("span",{},T.label)])]))}])])};var Df={};q(Df,{Fab:()=>B_});var B_=(f)=>{let{class:M,icon:_,label:E,actions:A=[],position:L="bottom-6 right-6",...W}=f;return Tag("div",{...W,class:Z(`fab absolute ${L} flex flex-col-reverse items-end gap-3 z-[100]`,M)},[Tag("div",{tabindex:0,role:"button",class:"btn btn-lg btn-circle btn-primary shadow-2xl"},[_?h(_):null,!_&&E?E:null]),...G(A).map((T)=>Tag("div",{class:"flex items-center gap-3 transition-all duration-300"},[T.label?Tag("span",{class:"badge badge-ghost shadow-sm whitespace-nowrap"},T.label):null,Tag("button",{type:"button",class:`btn btn-circle shadow-lg ${T.class||""}`,onclick:(P)=>{P.stopPropagation(),T.onclick?.(P)}},[T.icon?h(T.icon):T.text||""])]))])};var Nf={};q(Nf,{Fieldset:()=>G_});var G_=(f,M)=>{let{class:_,legend:E,...A}=f;return Tag("fieldset",{...A,class:Z("fieldset bg-base-200 border border-base-300 p-4 rounded-lg",_)},[()=>{let L=G(E);return L?Tag("legend",{class:"fieldset-legend font-bold"},[L]):null},M])};var Of={};q(Of,{Fileinput:()=>X_});var X_=(f)=>{let{class:M,tooltip:_,max:E=2,accept:A="*",onselect:L,...W}=f,T=$([]),P=$(!1),J=$(null),B=E*1024*1024,Q=(K)=>{let X=Array.from(K);if(J(null),X.find((z)=>z.size>B)){J(`Máx ${E}MB`);return}T([...T(),...X]),L?.(T())},C=(K)=>{let X=T().filter((Y,z)=>z!==K);T(X),L?.(X)};return Tag("fieldset",{...W,class:Z("fieldset w-full p-0",M)},[Tag("div",{class:()=>`w-full ${_?"tooltip tooltip-top before:z-50 after:z-50":""}`,"data-tip":_},[Tag("label",{class:()=>` +var I_=Object.defineProperty;var R=(f,M)=>{for(var _ in M)I_(f,_,{get:M[_],enumerable:!0,configurable:!0,set:(E)=>M[_]=()=>E})};var y=(f)=>typeof f==="function",Bf=(f)=>f&&typeof f==="object",o=Array.isArray,x=typeof document<"u"?document:null,sf=(f)=>f?._isRuntime?f.container:f instanceof Node?f:x.createTextNode(f==null?"":String(f)),O=null,V=null,t=!1,ff=0,_f=new Set,Jf=new WeakMap,Qf=Symbol("iter"),Tf=new WeakMap,c=(f)=>{if(!f||f._disposed)return;f._disposed=!0;let M=[f];while(M.length){let _=M.pop();if(_._cleanups)_._cleanups.forEach((E)=>E()),_._cleanups.clear();if(_._children)_._children.forEach((E)=>M.push(E)),_._children.clear();if(_._deps)_._deps.forEach((E)=>E.delete(_)),_._deps.clear()}},u_=(f)=>{if(V)(V._mounts||=[]).push(f)},p=(f)=>{if(V)(V._cleanups||=new Set).add(f)},m_=(f)=>{let M=O;O=null;try{return f()}finally{O=M}},a=(f,M=!1)=>{let _=()=>{if(_._disposed)return;if(_._deps)_._deps.forEach((A)=>A.delete(_));if(_._cleanups)_._cleanups.forEach((A)=>A()),_._cleanups.clear();let E=O,L=V;O=V=_;try{return _._result=f()}catch(A){console.error("[SigPro]",A)}finally{O=E,V=L}};if(_._deps=_._cleanups=_._children=null,_._disposed=!1,_._isComputed=M,_._depth=O?O._depth+1:0,_._mounts=[],_._parent=V,V)(V._children||=new Set).add(_);return _},af=()=>{if(t)return;t=!0;let f=Array.from(_f).sort((M,_)=>M._depth-_._depth);_f.clear();for(let M of f)if(!M._disposed)M();t=!1},v_=(f)=>{ff++;try{return f()}finally{if(ff--,ff===0&&_f.size>0&&!t)af()}},w=(f,M=!1)=>{if(!M&&O&&!O._disposed)f.add(O),(O._deps||=new Set).add(f);else if(M){let _=!1;if(f.forEach((E)=>{if(E===O||E._disposed)return;if(E._isComputed){if(E._dirty=!0,E._subs)w(E._subs,!0)}else _f.add(E),_=!0}),_&&!t&&ff===0)queueMicrotask(af)}},i=(f,M=null)=>{let _=new Set;if(y(f)){let E,L=!0,A=()=>{if(L){let P=O;O=A;try{let W=f();if(!Object.is(E,W))E=W,L=!1,w(_,!0)}finally{O=P}}return w(_),E};if(A._isComputed=!0,A._subs=_,A._dirty=!0,A._deps=null,A._disposed=!1,A.markDirty=()=>{L=!0},A.stop=()=>{if(A._disposed=!0,A._deps)A._deps.forEach((P)=>P.delete(A)),A._deps.clear();_.clear()},V)p(A.stop);return A}if(M)try{f=JSON.parse(localStorage.getItem(M))??f}catch(E){}return(...E)=>{if(E.length){let L=y(E[0])?E[0](f):E[0];if(!Object.is(f,L)){if(f=L,M)localStorage.setItem(M,JSON.stringify(f));w(_,!0)}}return w(_),f}},ef=(f)=>{if(!Bf(f))return f;if(Jf.has(f))return Jf.get(f);let M=new Map,_=(L)=>{let A=M.get(L);if(!A)M.set(L,A=new Set);return A},E=new Proxy(f,{get(L,A){return w(_(A)),ef(L[A])},set(L,A,P){let W=!(A in L);if(!Object.is(L[A],P)){if(L[A]=P,w(_(A),!0),W)w(_(Qf),!0)}return!0},deleteProperty(L,A){let P=Reflect.deleteProperty(L,A);if(P)w(_(A),!0),w(_(Qf),!0);return P},ownKeys(L){return w(_(Qf)),Reflect.ownKeys(L)}});return Jf.set(f,E),E},b=(f,M)=>{if(M===void 0){let E=a(f);return E(),()=>c(E)}let _=a(()=>{let E=Array.isArray(f)?f.map((L)=>L()):f();m_(()=>M(E))});return _(),()=>c(_)},Gf=(f)=>{if(f._cleanups)f._cleanups.forEach((M)=>M()),f._cleanups.clear();if(f._ownerEffect)c(f._ownerEffect);if(f.childNodes)f.childNodes.forEach(Gf)},g_=/^\s*(javascript|data|vbscript):/i,c_=(f)=>f==="src"||f==="href"||f.startsWith("on"),lf=(f,M)=>{if(M==null||M===!1)return null;if(c_(f)){let _=String(M);if(g_.test(_))return console.warn(`[SigPro] Bloqueado protocolo peligroso en ${f}`),"#"}return M},k=(f,M={},_=[])=>{if(M instanceof Node||o(M)||!Bf(M))_=M,M={};if(y(f)){let P={_mounts:[],_cleanups:new Set},W=a(()=>{let T=f(M,{children:_,emit:(Y,...K)=>M[`on${Y[0].toUpperCase()}${Y.slice(1)}`]?.(...K)});return W._result=T,T});W();let J=W._result;if(J==null)return null;let Q=J instanceof Node||o(J)&&J.every((T)=>T instanceof Node)?J:x.createTextNode(String(J)),X=(T)=>{if(Bf(T)&&!T._isRuntime)T._mounts=W._mounts||[],T._cleanups=W._cleanups||new Set,T._ownerEffect=W};return o(Q)?Q.forEach(X):X(Q),Q}let E=/^(svg|path|circle|rect|line|polyline|polygon|g|defs|text|tspan|use)$/.test(f),L=E?x.createElementNS("http://www.w3.org/2000/svg",f):x.createElement(f);L._cleanups=new Set;for(let P in M){if(!M.hasOwnProperty(P))continue;let W=M[P];if(P==="ref"){y(W)?W(L):W.current=L;continue}if(P.startsWith("on")){let J=P.slice(2).toLowerCase();L.addEventListener(J,W);let Q=()=>L.removeEventListener(J,W);L._cleanups.add(Q),p(Q)}else if(y(W)){let J=a(()=>{let Q=lf(P,W());if(P==="class")L.className=Q||"";else if(Q==null)L.removeAttribute(P);else if(P in L&&!E)L[P]=Q;else L.setAttribute(P,Q===!0?"":Q)});if(J(),L._cleanups.add(()=>c(J)),p(()=>c(J)),/^(INPUT|TEXTAREA|SELECT)$/.test(L.tagName)&&(P==="value"||P==="checked")){let Q=P==="checked"?"change":"input";L.addEventListener(Q,(X)=>W(X.target[P]))}}else{let J=lf(P,W);if(J!=null)if(P in L&&!E)L[P]=J;else L.setAttribute(P,J===!0?"":J)}}let A=(P)=>{if(o(P))return P.forEach(A);if(y(P)){let W=x.createTextNode("");L.appendChild(W);let J=[],Q=a(()=>{let X=P(),T=(o(X)?X:[X]).map(sf);J.forEach((K)=>{if(K._isRuntime)K.destroy();else Gf(K);if(K.parentNode)K.remove()});let Y=W;for(let K=T.length-1;K>=0;K--){let G=T[K];if(G.parentNode!==Y.parentNode)Y.parentNode?.insertBefore(G,Y);if(G._mounts)G._mounts.forEach((C)=>C());Y=G}J=T});Q(),L._cleanups.add(()=>c(Q)),p(()=>c(Q))}else{let W=sf(P);if(L.appendChild(W),W._mounts)W._mounts.forEach((J)=>J())}};return A(_),L},e=(f)=>{let M=new Set,_=[],E=V,L=O,A=x.createElement("div");A.style.display="contents",A.setAttribute("role","presentation"),V={_cleanups:M,_mounts:_},O=null;let P=(W)=>{if(!W)return;if(W._isRuntime)M.add(W.destroy),A.appendChild(W.container);else if(o(W))W.forEach(P);else A.appendChild(W instanceof Node?W:x.createTextNode(String(W==null?"":W)))};try{P(f({onCleanup:(W)=>M.add(W)}))}finally{V=E,O=L}return _.forEach((W)=>W()),{_isRuntime:!0,container:A,destroy:()=>{M.forEach((W)=>W()),Gf(A),A.remove()}}},f_=(f,M,_=null)=>{let E=x.createTextNode(""),L=k("div",{style:"display:contents"},[E]),A=null;return b(()=>!!(y(f)?f():f),(P)=>{if(A)A.destroy(),A=null;let W=P?M:_;if(W)A=e(()=>y(W)?W():W),L.insertBefore(A.container,E)}),p(()=>A?.destroy()),L},__=(f,M,_)=>{let E=x.createTextNode(""),L=k("div",{style:"display:contents"},[E]),A=new Map;return b(()=>(y(f)?f():f)||[],(P)=>{let W=new Map,J=[],Q=P||[];for(let T=0;TM(Y,T));else A.delete(K);W.set(K,G),J.push(G)}A.forEach((T)=>T.destroy());let X=E;for(let T=J.length-1;T>=0;T--){let K=J[T].container;if(K.nextSibling!==X)L.insertBefore(K,X);X=K}A=W}),L},r=(f)=>{let M=()=>window.location.hash.slice(1)||"/",_=i(M()),E=()=>_(M());window.addEventListener("hashchange",E),p(()=>window.removeEventListener("hashchange",E));let L=k("div",{class:"router-hook"}),A=null;return b([_],()=>{let P=_(),W=f.find((J)=>{let Q=J.path.split("/").filter(Boolean),X=P.split("/").filter(Boolean);return Q.length===X.length&&Q.every((T,Y)=>T[0]===":"||T===X[Y])})||f.find((J)=>J.path==="*");if(W){A?.destroy();let J={};W.path.split("/").filter(Boolean).forEach((Q,X)=>{if(Q[0]===":")J[Q.slice(1)]=P.split("/").filter(Boolean)[X]}),r.params(J),A=e(()=>y(W.component)?W.component(J):W.component),L.replaceChildren(A.container)}}),L};r.params=i({});r.to=(f)=>window.location.hash=f.replace(/^#?\/?/,"#/");r.back=()=>window.history.back();r.path=()=>window.location.hash.replace(/^#/,"")||"/";var M_=(f,M)=>{let _=typeof M==="string"?x.querySelector(M):M;if(!_)return;if(Tf.has(_))Tf.get(_).destroy();let E=e(y(f)?f:()=>f);return _.replaceChildren(E.container),Tf.set(_,E),E},tf=Object.freeze({$:i,$$:ef,Watch:b,Tag:k,Render:e,If:f_,For:__,Router:r,Mount:M_,onMount:u_,onUnmount:p,Batch:v_});if(typeof window<"u")Object.assign(window,tf),"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((f)=>window[f[0].toUpperCase()+f.slice(1)]=(M,_)=>tf.Tag(f,M,_));var Ef={};R(Ef,{default:()=>r_,Tooltip:()=>j_,Toast:()=>H_,Timeline:()=>k_,Tabs:()=>F_,Table:()=>V_,Swap:()=>U_,Stat:()=>O_,Stack:()=>N_,Select:()=>D_,Rating:()=>h_,Range:()=>z_,Radio:()=>R_,Navbar:()=>q_,Modal:()=>C_,Menu:()=>Y_,List:()=>S_,Label:()=>K_,Input:()=>s,Indicator:()=>Z_,Fileinput:()=>X_,Fieldset:()=>G_,Fab:()=>B_,Dropdown:()=>T_,Drawer:()=>Q_,Datepicker:()=>J_,Colorpicker:()=>P_,Checkbox:()=>W_,Button:()=>l,Badge:()=>A_,Autocomplete:()=>L_,Alert:()=>$_,Accordion:()=>E_});var Xf={};R(Xf,{Accordion:()=>E_});var Mf={};R(Mf,{val:()=>B,ui:()=>Z,getIcon:()=>z});var B=(f)=>typeof f==="function"?f():f,Z=(f,M)=>typeof M==="function"?()=>`${f} ${M()||""}`.trim():`${f} ${M||""}`.trim(),z=(f)=>{if(!f)return null;if(typeof f==="function")return Tag("span",{class:"mr-1"},f());if(typeof f==="object")return Tag("span",{class:"mr-1"},f);if(typeof f==="string"){let M=f.trim().split(/\s+/),_=M[M.length-1]==="right",E=_?M.slice(0,-1).join(" "):f,L=_?"ml-1":"mr-1";if(E&&!E.startsWith("icon-[")&&!E.includes("--"))return Tag("span",{class:L},E);return Tag("span",{class:`${E} ${L}`.trim()})}return null};var E_=(f,M)=>{let{class:_,title:E,name:L,open:A,...P}=f;return Tag("div",{...P,class:Z("collapse collapse-arrow bg-base-200 mb-2",_)},[Tag("input",{type:L?"radio":"checkbox",name:L,checked:B(A)}),Tag("div",{class:"collapse-title text-xl font-medium"},E),Tag("div",{class:"collapse-content"},M)])};var Zf={};R(Zf,{Alert:()=>$_});var $_=(f,M)=>{let{class:_,actions:E,type:L="info",soft:A=!0,...P}=f,W={info:"icon-[lucide--info]",success:"icon-[lucide--check-circle]",warning:"icon-[lucide--alert-triangle]",error:"icon-[lucide--alert-circle]"},X=[`alert-${L}`,A?"alert-soft":"",_].filter(Boolean).join(" "),T=M||f.message;return Tag("div",{...P,role:"alert",class:Z("alert",X)},()=>[z(W[L]),Tag("div",{class:"flex-1"},[Tag("span",{},[typeof T==="function"?T():T])]),E?Tag("div",{class:"flex-none"},[typeof E==="function"?E():E]):null].filter(Boolean))};var Sf={};R(Sf,{Autocomplete:()=>L_});var p_={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"}},b_=$("es");var I=(f)=>()=>p_[b_()][f]||f;var Kf={};R(Kf,{Input:()=>s});var s=(f)=>{let{class:M,value:_,type:E="text",icon:L,oninput:A,placeholder:P,disabled:W,validate:J,label:Q,...X}=f,T=E==="password",Y=$(!1),K=$(null),G={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]"},C=L?z(L):G[E]?z(G[E]):null,h=()=>z(Y()?"icon-[lucide--eye-off]":"icon-[lucide--eye]"),U=C?"pl-10":"",H=T?"pr-10":"",d=()=>{if(M?.includes("input-xs"))return"btn-xs";if(M?.includes("input-sm"))return"btn-sm";if(M?.includes("input-lg"))return"btn-lg";return"btn-md"},n=(D)=>{let v=D.target.value;if(J){let $f=J(v);K($f||null)}A?.(D)},F=()=>K()&&K()!=="",S=()=>{let D=`input w-full ${U} ${H}`;if(M)D+=` ${M}`;if(F())D+=" input-error";return D.trim()},q=Tag("input",{...X,type:()=>T?Y()?"text":"password":E,placeholder:P||(Q?" ":P),class:S,value:_,oninput:n,disabled:()=>B(W),"aria-invalid":()=>F()?"true":"false"}),N=()=>[q,C?Tag("div",{class:"absolute left-3 inset-y-0 flex items-center pointer-events-none text-base-content/60"},C):null,T?Tag("button",{type:"button",class:Z("absolute right-3 inset-y-0 flex items-center","btn btn-ghost btn-circle opacity-50 hover:opacity-100",d()),onclick:(D)=>{D.preventDefault(),Y(!Y())}},()=>h()):null,Tag("div",{class:"text-error text-xs mt-1 px-3 absolute -bottom-5 left-0"},()=>F()?K():null)];if(Q)return Tag("label",{class:Z("floating-label w-full",M)},()=>[Tag("div",{class:"relative w-full"},N),Tag("span",{},B(Q))]);return Tag("div",{class:"relative w-full"},N)};var L_=(f)=>{let{class:M,items:_=[],value:E,onselect:L,label:A,placeholder:P,...W}=f,J=$(B(E)||""),Q=$(!1),X=$(-1),T=$([]);Watch(()=>{let G=String(J()).toLowerCase(),C=B(_)||[],h=G?C.filter((U)=>(typeof U==="string"?U:U.label).toLowerCase().includes(G)):C;T(h)});let Y=(G)=>{let C=typeof G==="string"?G:G.value,h=typeof G==="string"?G:G.label;if(J(h),typeof E==="function")E(C);L?.(G),Q(!1),X(-1)},K=(G)=>{let C=T();if(G.key==="ArrowDown")G.preventDefault(),Q(!0),X(Math.min(X()+1,C.length-1));else if(G.key==="ArrowUp")G.preventDefault(),X(Math.max(X()-1,0));else if(G.key==="Enter"&&X()>=0)G.preventDefault(),Y(C[X()]);else if(G.key==="Escape")Q(!1)};return Tag("div",{class:"relative w-full"},[s({label:A,class:M,placeholder:P||I("search")(),value:J,onfocus:()=>Q(!0),onblur:()=>setTimeout(()=>Q(!1),150),onkeydown:K,oninput:(G)=>{let C=G.target.value;if(J(C),typeof E==="function")E(C);Q(!0),X(-1)},...W}),Tag("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:()=>Q()&&T().length?"display:block":"display:none"},[For(T,(G,C)=>Tag("li",{},[Tag("a",{class:()=>`block w-full ${X()===C?"active bg-primary text-primary-content":""}`,onclick:()=>Y(G),onmouseenter:()=>X(C)},typeof G==="string"?G:G.label)]),(G,C)=>(typeof G==="string"?G:G.value)+C),()=>T().length?null:Tag("li",{class:"p-2 text-center opacity-50"},I("nodata")())])])};var Yf={};R(Yf,{Badge:()=>A_});var A_=(f,M)=>{let{class:_,...E}=f;return Tag("span",{...E,class:Z("badge",_)},M)};var Cf={};R(Cf,{Button:()=>l});var l=(f,M)=>{let{class:_,loading:E,icon:L,...A}=f,P=z(L);return Tag("button",{...A,class:Z("btn",_),disabled:()=>B(E)||B(f.disabled)},()=>[B(E)&&Tag("span",{class:"loading loading-spinner"}),P,M].filter(Boolean))};var qf={};R(qf,{Checkbox:()=>W_});var W_=(f)=>{let{class:M,value:_,toggle:E,label:L,...A}=f,P=Tag("input",{...A,type:"checkbox",class:()=>Z(B(E)?"toggle":"checkbox",M),checked:_});return Tag("label",{class:"label cursor-pointer justify-start gap-3"},[P,L?Tag("span",{class:"label-text"},L):null])};var Rf={};R(Rf,{Colorpicker:()=>P_});var P_=(f)=>{let{class:M,value:_,label:E,...L}=f,A=$(!1),P=["#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"],W=()=>B(_)||"#000000";return Tag("div",{class:Z("relative w-fit",M)},[Tag("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:(J)=>{J.stopPropagation(),A(!A())},...L},[Tag("div",{class:"size-5 rounded-sm shadow-inner border border-black/10 shrink-0",style:()=>`background-color: ${W()}`}),E?Tag("span",{class:"opacity-80"},E):null]),If(A,()=>Tag("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:(J)=>J.stopPropagation()},[Tag("div",{class:"grid grid-cols-8 gap-1"},P.map((J)=>Tag("button",{type:"button",style:`background-color: ${J}`,class:()=>{return`size-6 rounded-sm cursor-pointer transition-all hover:scale-125 hover:z-10 active:scale-95 outline-none border border-black/5 + ${W().toLowerCase()===J.toLowerCase()?"ring-2 ring-offset-1 ring-primary z-10 scale-110":""}`},onclick:()=>{if(typeof _==="function")_(J);A(!1)}})))])),If(A,()=>Tag("div",{class:"fixed inset-0 z-[100]",onclick:()=>A(!1)}))])};var zf={};R(zf,{Datepicker:()=>J_});var J_=(f)=>{let{class:M,value:_,range:E,label:L,placeholder:A,hour:P=!1,...W}=f,J=$(!1),Q=$(new Date),X=$(null),T=$(0),Y=$(0),K=()=>B(E)===!0,G=new Date,C=`${G.getFullYear()}-${String(G.getMonth()+1).padStart(2,"0")}-${String(G.getDate()).padStart(2,"0")}`,h=(S)=>{let q=S.getFullYear(),N=String(S.getMonth()+1).padStart(2,"0"),D=String(S.getDate()).padStart(2,"0");return`${q}-${N}-${D}`},U=(S)=>{let q=h(S),N=B(_);if(K())if(!N?.start||N.start&&N.end){if(typeof _==="function")_({start:q,end:null,...P&&{startHour:T()}})}else{let D=N.start;if(typeof _==="function"){let v=q{let S=B(_);if(!S){H("");return}let q="";if(typeof S==="string")q=P&&S.includes("T")?S.replace("T"," "):S;else if(S.start&&S.end){let N=P&&S.startHour!==void 0?`${S.start} ${String(S.startHour).padStart(2,"0")}:00`:S.start,D=P&&S.endHour!==void 0?`${S.end} ${String(S.endHour).padStart(2,"0")}:00`:S.end;q=`${N} - ${D}`}else if(S.start)q=`${P&&S.startHour!==void 0?`${S.start} ${String(S.startHour).padStart(2,"0")}:00`:S.start}...`;H(q)});let d=(S)=>{let q=Q();Q(new Date(q.getFullYear(),q.getMonth()+S,1))},n=(S)=>{let q=Q();Q(new Date(q.getFullYear()+S,q.getMonth(),1))},F=({value:S,onChange:q})=>{return Tag("div",{class:"flex-1"},[Tag("div",{class:"flex gap-2 items-center"},[Tag("input",{type:"range",min:0,max:23,value:S,class:"range range-xs flex-1",oninput:(N)=>{let D=parseInt(N.target.value);q(D)}}),Tag("span",{class:"text-sm font-mono min-w-[48px] text-center"},()=>String(B(S)).padStart(2,"0")+":00")])])};return Tag("div",{class:Z("relative w-full",M)},[s({label:L,placeholder:A||(K()?"Seleccionar rango...":"Seleccionar fecha..."),value:H,readonly:!0,icon:z("icon-[lucide--calendar]"),onclick:(S)=>{S.stopPropagation(),J(!J())},...W}),If(J,()=>Tag("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:(S)=>S.stopPropagation()},[Tag("div",{class:"flex justify-between items-center mb-4 gap-1"},[Tag("div",{class:"flex gap-0.5"},[Tag("button",{type:"button",class:"btn btn-ghost btn-xs px-1",onclick:()=>n(-1)},z("icon-[lucide--chevrons-left]")),Tag("button",{type:"button",class:"btn btn-ghost btn-xs px-1",onclick:()=>d(-1)},z("icon-[lucide--chevron-left]"))]),Tag("span",{class:"font-bold uppercase flex-1 text-center"},[()=>Q().toLocaleString("es-ES",{month:"short",year:"numeric"})]),Tag("div",{class:"flex gap-0.5"},[Tag("button",{type:"button",class:"btn btn-ghost btn-xs px-1",onclick:()=>d(1)},z("icon-[lucide--chevron-right]")),Tag("button",{type:"button",class:"btn btn-ghost btn-xs px-1",onclick:()=>n(1)},z("icon-[lucide--chevrons-right]"))])]),Tag("div",{class:"grid grid-cols-7 gap-1",onmouseleave:()=>X(null)},[...["L","M","X","J","V","S","D"].map((S)=>Tag("div",{class:"text-[10px] opacity-40 font-bold text-center"},S)),()=>{let S=Q(),q=S.getFullYear(),N=S.getMonth(),D=new Date(q,N,1).getDay(),v=D===0?6:D-1,$f=new Date(q,N+1,0).getDate(),Lf=[];for(let g=0;g{let m=B(_),Af=X(),y_=typeof m==="string"?m.split("T")[0]===j:m?.start===j,x_=m?.end===j,Wf=!1;if(K()&&m?.start){let Pf=m.start;if(!m.end&&Af)Wf=j>Pf&&j<=Af||j=Af;else if(m.end)Wf=j>Pf&&j{if(K())X(j)},onclick:()=>U(of)},[g.toString()]))}return Lf}]),P?Tag("div",{class:"mt-3 pt-2 border-t border-base-300"},[K()?Tag("div",{class:"flex gap-4"},[F({value:T,onChange:(S)=>{T(S);let q=B(_);if(q?.start)_({...q,startHour:S})}}),F({value:Y,onChange:(S)=>{Y(S);let q=B(_);if(q?.end)_({...q,endHour:S})}})]):F({value:T,onChange:(S)=>{T(S);let q=B(_);if(q&&typeof q==="string")_(q.split("T")[0]+"T"+String(S).padStart(2,"0")+":00:00")}})]):null])),If(J,()=>Tag("div",{class:"fixed inset-0 z-[90]",onclick:()=>J(!1)}))])};var hf={};R(hf,{Drawer:()=>Q_});var Q_=(f,M)=>{let{class:_,id:E,open:L,side:A,content:P,...W}=f,J=E||`drawer-${Math.random().toString(36).slice(2,9)}`;return Tag("div",{...W,class:Z("drawer",_)},[Tag("input",{id:J,type:"checkbox",class:"drawer-toggle",checked:()=>typeof L==="function"?L():L,onchange:(Q)=>{if(typeof L==="function")L(Q.target.checked)}}),Tag("div",{class:"drawer-content"},[typeof P==="function"?P():P]),Tag("div",{class:"drawer-side"},[Tag("label",{for:J,class:"drawer-overlay",onclick:()=>{if(typeof L==="function")L(!1)}}),Tag("div",{class:"min-h-full bg-base-200 w-80"},[typeof A==="function"?A():A])])])};var Df={};R(Df,{Dropdown:()=>T_});var u=null;if(typeof window<"u"&&!window.__dropdownHandlerRegistered)window.addEventListener("click",(f)=>{if(u&&!u.contains(f.target))u.open=!1,u=null}),window.__dropdownHandlerRegistered=!0;var T_=(f)=>{let{class:M,label:_,icon:E,items:L,...A}=f;return Tag("details",{...A,class:Z("dropdown",M)},[Tag("summary",{class:"btn m-1 flex items-center gap-2 list-none cursor-pointer",style:"display: inline-flex;",onclick:(P)=>{let W=P.currentTarget.closest("details");if(u&&u!==W)u.open=!1;setTimeout(()=>{u=W.open?W:null},0)}},[()=>E?typeof E==="function"?E():E:null,()=>_?typeof _==="function"?_():_:null]),Tag("ul",{tabindex:"-1",class:"dropdown-content z-[50] menu p-2 shadow bg-base-100 rounded-box w-52 border border-base-300"},[()=>{return(typeof L==="function"?L():L||[]).map((W)=>Tag("li",{},[Tag("a",{class:W.class||"",onclick:(J)=>{if(W.onclick)W.onclick(J);let Q=J.currentTarget.closest("details");if(Q){if(Q.open=!1,u===Q)u=null}}},[W.icon?Tag("span",{},W.icon):null,Tag("span",{},W.label)])]))}])])};var Nf={};R(Nf,{Fab:()=>B_});var B_=(f)=>{let{class:M,icon:_,label:E,actions:L=[],position:A="bottom-6 right-6",...P}=f;return Tag("div",{...P,class:Z(`fab absolute ${A} flex flex-col-reverse items-end gap-3 z-[100]`,M)},[Tag("div",{tabindex:0,role:"button",class:"btn btn-lg btn-circle btn-primary shadow-2xl"},[_?z(_):null,!_&&E?E:null]),...B(L).map((W)=>Tag("div",{class:"flex items-center gap-3 transition-all duration-300"},[W.label?Tag("span",{class:"badge badge-ghost shadow-sm whitespace-nowrap"},W.label):null,Tag("button",{type:"button",class:`btn btn-circle shadow-lg ${W.class||""}`,onclick:(J)=>{J.stopPropagation(),W.onclick?.(J)}},[W.icon?z(W.icon):W.text||""])]))])};var Of={};R(Of,{Fieldset:()=>G_});var G_=(f,M)=>{let{class:_,legend:E,...L}=f;return Tag("fieldset",{...L,class:Z("fieldset bg-base-200 border border-base-300 p-4 rounded-lg",_)},[()=>{let A=B(E);return A?Tag("legend",{class:"fieldset-legend font-bold"},[A]):null},M])};var Uf={};R(Uf,{Fileinput:()=>X_});var X_=(f)=>{let{class:M,tooltip:_,max:E=2,accept:L="*",onselect:A,...P}=f,W=$([]),J=$(!1),Q=$(null),X=E*1024*1024,T=(K)=>{let G=Array.from(K);if(Q(null),G.find((h)=>h.size>X)){Q(`Máx ${E}MB`);return}W([...W(),...G]),A?.(W())},Y=(K)=>{let G=W().filter((C,h)=>h!==K);W(G),A?.(G)};return Tag("fieldset",{...P,class:Z("fieldset w-full p-0",M)},[Tag("div",{class:()=>`w-full ${_?"tooltip tooltip-top before:z-50 after:z-50":""}`,"data-tip":_},[Tag("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 - ${P()?"border-primary bg-primary/10":"border-base-content/20 bg-base-100 hover:bg-base-200"} - `,ondragover:(K)=>{K.preventDefault(),P(!0)},ondragleave:()=>P(!1),ondrop:(K)=>{K.preventDefault(),P(!1),Q(K.dataTransfer.files)}},[Tag("div",{class:"flex items-center gap-3 w-full"},[h("icon-[lucide--upload]"),Tag("span",{class:"text-sm opacity-70 truncate grow text-left"},"Arrastra o selecciona archivos..."),Tag("span",{class:"text-[10px] opacity-40 shrink-0"},`Máx ${E}MB`)]),Tag("input",{type:"file",multiple:!0,accept:A,class:"hidden",onchange:(K)=>Q(K.target.files)})])]),()=>J()?Tag("span",{class:"text-[10px] text-error mt-1 px-1 font-medium"},J()):null,If(()=>T().length>0,()=>Tag("ul",{class:"mt-2 space-y-1"},[For(T,(K,X)=>Tag("li",{class:"flex items-center justify-between p-1.5 pl-3 text-xs bg-base-200/50 rounded-md border border-base-300"},[Tag("div",{class:"flex items-center gap-2 truncate"},[Tag("span",{class:"opacity-50"},"\uD83D\uDCC4"),Tag("span",{class:"truncate font-medium max-w-[200px]"},K.name),Tag("span",{class:"text-[9px] opacity-40"},`(${(K.size/1024).toFixed(0)} KB)`)]),Tag("button",{type:"button",class:"btn btn-ghost btn-xs btn-circle",onclick:(Y)=>{Y.preventDefault(),Y.stopPropagation(),C(X)}},[h("icon-[lucide--x]")])]),(K)=>K.name+K.lastModified)]))])};var Vf={};q(Vf,{Indicator:()=>Z_});var Z_=(f,M)=>{let{value:_,class:E,...A}=f;return Tag("div",{...A,class:"indicator"},()=>[_?Tag("span",{class:Z("indicator-item badge",E)},()=>typeof _==="function"?_():_):null,M].filter(Boolean))};var Uf={};q(Uf,{Label:()=>K_});var K_=(f)=>{let{children:M,value:_,floating:E=!1,class:A,...L}=f;if(E)return Tag("label",{class:Z("floating-label",A),...L},()=>[typeof M==="function"?M():M,_?Tag("span",{},G(_)):null]);return Tag("label",{class:Z("label",A),...L},()=>[_?Tag("span",{class:"label-text"},G(_)):null,typeof M==="function"?M():M])};var Ff={};q(Ff,{List:()=>S_});var S_=(f)=>{let{class:M,items:_,header:E,render:A=(P)=>P,keyFn:L=(P,J)=>P.id??J,...W}=f,T=For(_,(P,J)=>Tag("li",{class:"list-row",style:"width: 100%; display: block;"},[Tag("div",{style:"width: 100%;"},[A(P,J)])]),L);return Tag("ul",{...W,style:"display: block; width: 100%;",class:Z("list bg-base-100 rounded-box shadow-md",M)},E?[If(E,()=>Tag("li",{class:"p-4 pb-2 text-xs opacity-60",style:"width: 100%;"},[G(E)])),T]:T)};var Hf={};q(Hf,{Menu:()=>C_});var C_=(f)=>{let{class:M,items:_,...E}=f,A=(L)=>For(()=>L||[],(W)=>Tag("li",{},[W.children?Tag("details",{open:W.open},[Tag("summary",{},[W.icon&&Tag("span",{class:"mr-2"},W.icon),W.label]),Tag("ul",{},A(W.children))]):Tag("a",{class:()=>G(W.active)?"active":"",onclick:W.onclick},[W.icon&&Tag("span",{class:"mr-2"},W.icon),W.label])]),(W,T)=>W.label||T);return Tag("ul",{...E,class:Z("menu bg-base-200 rounded-box",M)},A(_))};var kf={};q(kf,{Modal:()=>Y_});var Y_=(f,M)=>{let{class:_,title:E,buttons:A,open:L,...W}=f,T=null,P=()=>{let B=typeof L==="function"?L():L;if(!T)return;if(B){if(!T.open)T.showModal()}else if(T.open)T.close()};Watch(()=>P());let J=()=>{if(typeof L==="function")L(!1)};return Tag("dialog",{...W,ref:(B)=>{if(T=B,B)P()},class:Z("modal",_),onclose:J,oncancel:J},[Tag("div",{class:"modal-box"},[E?Tag("h3",{class:"text-lg font-bold mb-4"},()=>typeof E==="function"?E():E):null,Tag("div",{class:"py-2"},[typeof M==="function"?M():M]),Tag("div",{class:"modal-action"},[Tag("form",{method:"dialog",class:"flex gap-2"},[...(Array.isArray(A)?A:[A]).filter(Boolean),l({type:"submit"},I("close")())])])]),Tag("form",{method:"dialog",class:"modal-backdrop"},[Tag("button",{},"close")])])};var wf={};q(wf,{Navbar:()=>R_});var R_=(f,M)=>{let{class:_,...E}=f;return Tag("div",{...E,class:Z("navbar bg-base-100 shadow-sm px-4",_)},M)};var jf={};q(jf,{Radio:()=>q_});var q_=(f)=>{let{class:M,label:_,tooltip:E,value:A,inputValue:L,name:W,...T}=f,P=Tag("input",{...T,type:"radio",name:W,class:Z("radio",M),checked:()=>G(A)===L,onclick:()=>{if(typeof A==="function")A(L)}});if(!_&&!E)return P;let J=Tag("label",{class:"label cursor-pointer justify-start gap-3"},[P,_?Tag("span",{class:"label-text"},_):null]);return E?Tag("div",{class:"tooltip","data-tip":E},J):J};var yf={};q(yf,{Range:()=>h_});var h_=(f)=>{let{class:M,label:_,tooltip:E,value:A,...L}=f,W=Tag("input",{...L,type:"range",class:Z("range",M),value:A,disabled:()=>G(f.disabled)});if(!_&&!E)return W;let T=Tag("div",{class:"flex flex-col gap-2"},[_?Tag("span",{class:"label-text"},_):null,W]);return E?Tag("div",{class:"tooltip","data-tip":E},T):T};var xf={};q(xf,{Rating:()=>z_});var z_=(f)=>{let{class:M,value:_,count:E=5,mask:A="mask-star",readonly:L=!1,onchange:W,...T}=f,P=`rating-${Math.random().toString(36).slice(2,7)}`;return Tag("div",{...T,class:()=>Z(`rating ${G(L)?"pointer-events-none":""}`,M)},Array.from({length:G(E)},(J,B)=>{let Q=B+1;return Tag("input",{type:"radio",name:P,class:`mask ${A}`,checked:()=>Math.round(G(_))===Q,onchange:()=>{if(!G(L)){if(typeof W==="function")W(Q);else if(typeof _==="function")_(Q)}}})}))};var uf={};q(uf,{Select:()=>D_});var D_=(f)=>{let{class:M,label:_,items:E,value:A,...L}=f,W=Tag("select",{...L,class:Z("select select-bordered w-full",M),value:A},For(()=>G(E)||[],(T)=>Tag("option",{value:T.value,$selected:()=>String(G(A))===String(T.value)},T.label),(T)=>T.value));if(!_)return W;return Tag("label",{class:"fieldset-label flex flex-col gap-1"},[Tag("span",{},_),W])};var mf={};q(mf,{Stack:()=>N_});var N_=(f,M)=>{let{class:_,...E}=f;return Tag("div",{...E,class:Z("stack",_)},M)};var vf={};q(vf,{Stat:()=>O_});var O_=(f)=>{let{class:M,icon:_,label:E,value:A,desc:L,...W}=f;return Tag("div",{...W,class:Z("stat",M)},[_&&Tag("div",{class:"stat-figure text-secondary"},_),E&&Tag("div",{class:"stat-title"},E),Tag("div",{class:"stat-value"},()=>G(A)??A),L&&Tag("div",{class:"stat-desc"},L)])};var gf={};q(gf,{Swap:()=>V_});var V_=(f)=>{let{class:M,value:_,on:E,off:A,...L}=f;return Tag("label",{...L,class:Z("swap",M)},[Tag("input",{type:"checkbox",checked:()=>G(_),onclick:(W)=>{if(typeof _==="function")_(W.target.checked)}}),Tag("div",{class:"swap-on"},E),Tag("div",{class:"swap-off"},A)])};var cf={};q(cf,{Table:()=>U_});var U_=(f)=>{let{class:M,items:_=[],columns:E=[],keyFn:A,zebra:L=!1,pinRows:W=!1,empty:T=I("nodata")(),...P}=f,J=()=>{let Q=G(L)?"table-zebra":"",C=G(W)?"table-pin-rows":"";return Z("table",M,Q,C)},B=A||((Q,C)=>Q.id||C);return Tag("div",{class:"overflow-x-auto w-full bg-base-100 rounded-box border border-base-300"},[Tag("table",{...P,class:J},[Tag("thead",{},[Tag("tr",{},E.map((Q)=>Tag("th",{class:Q.class||""},Q.label)))]),Tag("tbody",{},[For(_,(Q,C)=>{let K=()=>{let X=G(_),Y=B(Q,C);return X.find((z,V)=>B(z,V)===Y)||Q};return Tag("tr",{class:"hover"},E.map((X)=>{let Y=()=>{let z=K();if(X.render)return X.render(z,C);return G(z[X.key])};return Tag("td",{class:X.class||""},[Y])}))},B),If(()=>G(_).length===0,()=>Tag("tr",{},[Tag("td",{colspan:E.length,class:"text-center p-10 opacity-50"},[G(T)])]))])])])};var pf={};q(pf,{Tabs:()=>F_});var F_=(f)=>{let{items:M,class:_,onTabClose:E,...A}=f,L=typeof M==="function"?M:()=>M||[],W=i(0);g(()=>{let J=L().findIndex((B)=>G(B.active)===!0);if(J!==-1&&W()!==J)W(J)});let T=(P,J)=>{if(J.onClose)J.onClose(J);if(E)E(J,P);let Q=L().filter((X,Y)=>Y!==P);if(!(typeof M==="function"&&!M._isComputed)){console.warn("Tabs: items must be a writable signal to support closable tabs");return}if(M(Q),Q.length===0)return;let K=W();if(P{let P=L(),J=[];for(let B=0;B{R.stopPropagation(),T(B,Q)};let S=H("span",{class:"flex items-center"},[K,F]);X.push(S)}else X.push(K);let Y=H("button",{class:()=>Z("tab",W()===B?"tab-active":""),onclick:(F)=>{if(F.preventDefault(),!G(Q.disabled)){if(Q.onclick)Q.onclick();W(B)}}},X),z=Q.tip?H("div",{class:"tooltip","data-tip":Q.tip},Y):Y;J.push(z);let V,k=G(Q.content);if(typeof k==="function")V=k();else if(k instanceof Node)V=k;else V=document.createTextNode(String(k));let d=H("div",{class:"tab-content-inner"},V),n=H("div",{class:"tab-content bg-base-100 border-base-300 p-6",style:()=>W()===B?"display: block":"display: none"},d);J.push(n)}return J})};var rf={};q(rf,{Timeline:()=>H_});var H_=(f)=>{let{class:M,items:_=[],vertical:E=!0,compact:A=!1,...L}=f,W={info:"icon-[lucide--info]",success:"icon-[lucide--check-circle]",warning:"icon-[lucide--alert-triangle]",error:"icon-[lucide--alert-circle]"};return Tag("ul",{...L,class:()=>Z(`timeline ${G(E)?"timeline-vertical":"timeline-horizontal"} ${G(A)?"timeline-compact":""}`,M)},()=>{let T=(typeof _==="function"?_():_)||[];return T.map((P,J)=>{let B=J===0,Q=J===T.length-1,C=P.type||"success",K=()=>G(P.completed),X=()=>J>0&&G(T[J-1].completed),Y=(z)=>typeof z==="function"?z():z;return Tag("li",{class:"flex-1"},[!B?Tag("hr",{class:()=>X()?"bg-primary":""}):null,Tag("div",{class:"timeline-start"},[()=>Y(P.title)]),Tag("div",{class:"timeline-middle"},[()=>P.icon?h(P.icon):h(W[C]||W.success)]),Tag("div",{class:"timeline-end timeline-box shadow-sm"},[()=>Y(P.detail)]),!Q?Tag("hr",{class:()=>K()?"bg-primary":""}):null])})})};var bf={};q(bf,{Toast:()=>k_});var k_=(f,M="alert-success",_=3500)=>{let E=document.getElementById("sigpro-toast-container");if(!E)E=Tag("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(E);let A=Tag("div",{style:"display: contents"});E.appendChild(A);let L,W=()=>{clearTimeout(L);let J=A.firstElementChild;if(J&&!J.classList.contains("opacity-0"))J.classList.add("translate-x-full","opacity-0"),setTimeout(()=>{if(P.destroy(),A.remove(),!E.hasChildNodes())E.remove()},300);else P.destroy(),A.remove()},T=()=>{let J=h("icon-[lucide--x]"),B=Tag("div",{class:`alert alert-soft ${M} shadow-lg transition-all duration-300 translate-x-10 opacity-0 pointer-events-auto`},[Tag("span",{},[typeof f==="function"?f():f]),l({class:"btn-xs btn-circle btn-ghost",onclick:W},J)]);return requestAnimationFrame(()=>B.classList.remove("translate-x-10","opacity-0")),B},P=Mount(T,A);if(_>0)L=setTimeout(W,_);return W};var df={};q(df,{Tooltip:()=>w_});var w_=(f,M)=>Tag("div",{...f,class:()=>Z("tooltip w-full",f.class),"data-tip":f.tip},M);var j_={...Gf,...Xf,...Kf,...Sf,...Cf,...Yf,...Rf,...qf,...hf,...zf,...Df,...Nf,...Of,...Vf,...Zf,...Uf,...Ff,...Hf,...kf,...wf,...jf,...yf,...xf,...uf,...mf,...vf,...gf,...cf,...pf,...rf,...bf,...df},d_={...j_,install:(f=window)=>{Object.entries(j_).forEach(([M,_])=>{f[M]=_}),console.log("\uD83D\uDE80 SigproUI")}};if(typeof window<"u")Object.entries(Ef).forEach(([f,M])=>{Object.defineProperty(window,f,{value:M,writable:!1,configurable:!0,enumerable:!0})}),Object.entries(Mf).forEach(([f,M])=>{Object.defineProperty(window,f,{value:M,writable:!1,configurable:!0,enumerable:!0})}),Object.defineProperty(window,"tt",{value:I,writable:!1,configurable:!0,enumerable:!0}),Object.defineProperty(window,"SigProUI",{value:{...Ef,Utils:Mf,tt:I},writable:!1,configurable:!0,enumerable:!0}),console.log("\uD83C\uDFA8 SigProUI ready");export{G as val,Z as ui,I as tt,h as getIcon,g as Watch,w_ as Tooltip,k_ as Toast,H_ as Timeline,H as Tag,F_ as Tabs,U_ as Table,V_ as Swap,O_ as Stat,N_ as Stack,D_ as Select,b as Router,z_ as Rating,h_ as Range,q_ as Radio,R_ as Navbar,M_ as Mount,Y_ as Modal,C_ as Menu,S_ as List,K_ as Label,t as Input,Z_ as Indicator,f_ as If,__ as For,X_ as Fileinput,G_ as Fieldset,B_ as Fab,Q_ as Dropdown,J_ as Drawer,P_ as Datepicker,W_ as Colorpicker,T_ as Checkbox,l as Button,A_ as Badge,$_ as Autocomplete,L_ as Alert,E_ as Accordion,i as $}; + ${J()?"border-primary bg-primary/10":"border-base-content/20 bg-base-100 hover:bg-base-200"} + `,ondragover:(K)=>{K.preventDefault(),J(!0)},ondragleave:()=>J(!1),ondrop:(K)=>{K.preventDefault(),J(!1),T(K.dataTransfer.files)}},[Tag("div",{class:"flex items-center gap-3 w-full"},[z("icon-[lucide--upload]"),Tag("span",{class:"text-sm opacity-70 truncate grow text-left"},"Arrastra o selecciona archivos..."),Tag("span",{class:"text-[10px] opacity-40 shrink-0"},`Máx ${E}MB`)]),Tag("input",{type:"file",multiple:!0,accept:L,class:"hidden",onchange:(K)=>T(K.target.files)})])]),()=>Q()?Tag("span",{class:"text-[10px] text-error mt-1 px-1 font-medium"},Q()):null,If(()=>W().length>0,()=>Tag("ul",{class:"mt-2 space-y-1"},[For(W,(K,G)=>Tag("li",{class:"flex items-center justify-between p-1.5 pl-3 text-xs bg-base-200/50 rounded-md border border-base-300"},[Tag("div",{class:"flex items-center gap-2 truncate"},[Tag("span",{class:"opacity-50"},"\uD83D\uDCC4"),Tag("span",{class:"truncate font-medium max-w-[200px]"},K.name),Tag("span",{class:"text-[9px] opacity-40"},`(${(K.size/1024).toFixed(0)} KB)`)]),Tag("button",{type:"button",class:"btn btn-ghost btn-xs btn-circle",onclick:(C)=>{C.preventDefault(),C.stopPropagation(),Y(G)}},[z("icon-[lucide--x]")])]),(K)=>K.name+K.lastModified)]))])};var Vf={};R(Vf,{Indicator:()=>Z_});var Z_=(f,M)=>{let{value:_,class:E,...L}=f;return Tag("div",{...L,class:"indicator"},()=>[_?Tag("span",{class:Z("indicator-item badge",E)},()=>typeof _==="function"?_():_):null,M].filter(Boolean))};var Ff={};R(Ff,{Label:()=>K_});var K_=(f)=>{let{children:M,value:_,floating:E=!1,class:L,...A}=f;if(E)return Tag("label",{class:Z("floating-label",L),...A},()=>[typeof M==="function"?M():M,_?Tag("span",{},B(_)):null]);return Tag("label",{class:Z("label",L),...A},()=>[_?Tag("span",{class:"label-text"},B(_)):null,typeof M==="function"?M():M])};var kf={};R(kf,{List:()=>S_});var S_=(f)=>{let{class:M,items:_,header:E,render:L=(J)=>J,keyFn:A=(J,Q)=>J.id??Q,...P}=f,W=For(_,(J,Q)=>Tag("li",{class:"list-row",style:"width: 100%; display: block;"},[Tag("div",{style:"width: 100%;"},[L(J,Q)])]),A);return Tag("ul",{...P,style:"display: block; width: 100%;",class:Z("list bg-base-100 rounded-box shadow-md",M)},E?[If(E,()=>Tag("li",{class:"p-4 pb-2 text-xs opacity-60",style:"width: 100%;"},[B(E)])),W]:W)};var Hf={};R(Hf,{Menu:()=>Y_});var Y_=(f)=>{let{class:M,items:_,...E}=f,L=(A)=>For(()=>A||[],(P)=>Tag("li",{},[P.children?Tag("details",{open:P.open},[Tag("summary",{},[P.icon&&Tag("span",{class:"mr-2"},P.icon),P.label]),Tag("ul",{},L(P.children))]):Tag("a",{class:()=>B(P.active)?"active":"",onclick:P.onclick},[P.icon&&Tag("span",{class:"mr-2"},P.icon),P.label])]),(P,W)=>P.label||W);return Tag("ul",{...E,class:Z("menu bg-base-200 rounded-box",M)},L(_))};var jf={};R(jf,{Modal:()=>C_});var C_=(f,M)=>{let{class:_,title:E,buttons:L,open:A,...P}=f,W=null,J=()=>{let X=typeof A==="function"?A():A;if(!W)return;if(X){if(!W.open)W.showModal()}else if(W.open)W.close()};Watch(()=>J());let Q=()=>{if(typeof A==="function")A(!1)};return Tag("dialog",{...P,ref:(X)=>{if(W=X,X)J()},class:Z("modal",_),onclose:Q,oncancel:Q},[Tag("div",{class:"modal-box"},[E?Tag("h3",{class:"text-lg font-bold mb-4"},()=>typeof E==="function"?E():E):null,Tag("div",{class:"py-2"},[typeof M==="function"?M():M]),Tag("div",{class:"modal-action"},[Tag("form",{method:"dialog",class:"flex gap-2"},[...(Array.isArray(L)?L:[L]).filter(Boolean),l({type:"submit"},I("close")())])])]),Tag("form",{method:"dialog",class:"modal-backdrop"},[Tag("button",{},"close")])])};var wf={};R(wf,{Navbar:()=>q_});var q_=(f,M)=>{let{class:_,...E}=f;return Tag("div",{...E,class:Z("navbar bg-base-100 shadow-sm px-4",_)},M)};var yf={};R(yf,{Radio:()=>R_});var R_=(f)=>{let{class:M,label:_,tooltip:E,value:L,inputValue:A,name:P,...W}=f,J=Tag("input",{...W,type:"radio",name:P,class:Z("radio",M),checked:()=>B(L)===A,onclick:()=>{if(typeof L==="function")L(A)}});if(!_&&!E)return J;let Q=Tag("label",{class:"label cursor-pointer justify-start gap-3"},[J,_?Tag("span",{class:"label-text"},_):null]);return E?Tag("div",{class:"tooltip","data-tip":E},Q):Q};var xf={};R(xf,{Range:()=>z_});var z_=(f)=>{let{class:M,label:_,tooltip:E,value:L,...A}=f,P=Tag("input",{...A,type:"range",class:Z("range",M),value:L,disabled:()=>B(f.disabled)});if(!_&&!E)return P;let W=Tag("div",{class:"flex flex-col gap-2"},[_?Tag("span",{class:"label-text"},_):null,P]);return E?Tag("div",{class:"tooltip","data-tip":E},W):W};var uf={};R(uf,{Rating:()=>h_});var h_=(f)=>{let{class:M,value:_,count:E=5,mask:L="mask-star",readonly:A=!1,onchange:P,...W}=f,J=`rating-${Math.random().toString(36).slice(2,7)}`;return Tag("div",{...W,class:()=>Z(`rating ${B(A)?"pointer-events-none":""}`,M)},Array.from({length:B(E)},(Q,X)=>{let T=X+1;return Tag("input",{type:"radio",name:J,class:`mask ${L}`,checked:()=>Math.round(B(_))===T,onchange:()=>{if(!B(A)){if(typeof P==="function")P(T);else if(typeof _==="function")_(T)}}})}))};var mf={};R(mf,{Select:()=>D_});var D_=(f)=>{let{class:M,label:_,items:E,value:L,...A}=f,P=Tag("select",{...A,class:Z("select select-bordered w-full",M),value:L},For(()=>B(E)||[],(W)=>Tag("option",{value:W.value,$selected:()=>String(B(L))===String(W.value)},W.label),(W)=>W.value));if(!_)return P;return Tag("label",{class:"fieldset-label flex flex-col gap-1"},[Tag("span",{},_),P])};var vf={};R(vf,{Stack:()=>N_});var N_=(f,M)=>{let{class:_,...E}=f;return Tag("div",{...E,class:Z("stack",_)},M)};var gf={};R(gf,{Stat:()=>O_});var O_=(f)=>{let{class:M,icon:_,label:E,value:L,desc:A,...P}=f;return Tag("div",{...P,class:Z("stat",M)},[_&&Tag("div",{class:"stat-figure text-secondary"},_),E&&Tag("div",{class:"stat-title"},E),Tag("div",{class:"stat-value"},()=>B(L)??L),A&&Tag("div",{class:"stat-desc"},A)])};var cf={};R(cf,{Swap:()=>U_});var U_=(f)=>{let{class:M,value:_,on:E,off:L,...A}=f;return Tag("label",{...A,class:Z("swap",M)},[Tag("input",{type:"checkbox",checked:()=>B(_),onclick:(P)=>{if(typeof _==="function")_(P.target.checked)}}),Tag("div",{class:"swap-on"},E),Tag("div",{class:"swap-off"},L)])};var pf={};R(pf,{Table:()=>V_});var V_=(f)=>{let{class:M,items:_=[],columns:E=[],keyFn:L,zebra:A=!1,pinRows:P=!1,empty:W=I("nodata")(),...J}=f,Q=()=>{let T=B(A)?"table-zebra":"",Y=B(P)?"table-pin-rows":"";return Z("table",M,T,Y)},X=L||((T,Y)=>T.id||Y);return Tag("div",{class:"overflow-x-auto w-full bg-base-100 rounded-box border border-base-300"},[Tag("table",{...J,class:Q},[Tag("thead",{},[Tag("tr",{},E.map((T)=>Tag("th",{class:T.class||""},T.label)))]),Tag("tbody",{},[For(_,(T,Y)=>{let K=()=>{let G=B(_),C=X(T,Y);return G.find((h,U)=>X(h,U)===C)||T};return Tag("tr",{class:"hover"},E.map((G)=>{let C=()=>{let h=K();if(G.render)return G.render(h,Y);return B(h[G.key])};return Tag("td",{class:G.class||""},[C])}))},X),If(()=>B(_).length===0,()=>Tag("tr",{},[Tag("td",{colspan:E.length,class:"text-center p-10 opacity-50"},[B(W)])]))])])])};var bf={};R(bf,{Tabs:()=>F_});var F_=(f)=>{let{items:M,class:_,onTabClose:E,...L}=f,A=typeof M==="function"?M:()=>M||[],P=i(0);b(()=>{let Q=A().findIndex((X)=>B(X.active)===!0);if(Q!==-1&&P()!==Q)P(Q)});let W=(J,Q)=>{if(Q.onClose)Q.onClose(Q);if(E)E(Q,J);let T=A().filter((G,C)=>C!==J);if(!(typeof M==="function"&&!M._isComputed)){console.warn("Tabs: items must be a writable signal to support closable tabs");return}if(M(T),T.length===0)return;let K=P();if(J{let J=A(),Q=[];for(let X=0;X{q.stopPropagation(),W(X,T)};let S=k("span",{class:"flex items-center"},[K,F]);G.push(S)}else G.push(K);let C=k("button",{class:()=>Z("tab",P()===X?"tab-active":""),onclick:(F)=>{if(F.preventDefault(),!B(T.disabled)){if(T.onclick)T.onclick();P(X)}}},G),h=T.tip?k("div",{class:"tooltip","data-tip":T.tip},C):C;Q.push(h);let U,H=B(T.content);if(typeof H==="function")U=H();else if(H instanceof Node)U=H;else U=document.createTextNode(String(H));let d=k("div",{class:"tab-content-inner"},U),n=k("div",{class:"tab-content bg-base-100 border-base-300 p-6",style:()=>P()===X?"display: block":"display: none"},d);Q.push(n)}return Q})};var rf={};R(rf,{Timeline:()=>k_});var k_=(f)=>{let{class:M,items:_=[],vertical:E=!0,compact:L=!1,...A}=f,P={info:"icon-[lucide--info]",success:"icon-[lucide--check-circle]",warning:"icon-[lucide--alert-triangle]",error:"icon-[lucide--alert-circle]"};return Tag("ul",{...A,class:()=>Z(`timeline ${B(E)?"timeline-vertical":"timeline-horizontal"} ${B(L)?"timeline-compact":""}`,M)},()=>{let W=(typeof _==="function"?_():_)||[];return W.map((J,Q)=>{let X=Q===0,T=Q===W.length-1,Y=J.type||"success",K=()=>B(J.completed),G=()=>Q>0&&B(W[Q-1].completed),C=(h)=>typeof h==="function"?h():h;return Tag("li",{class:"flex-1"},[!X?Tag("hr",{class:()=>G()?"bg-primary":""}):null,Tag("div",{class:"timeline-start"},[()=>C(J.title)]),Tag("div",{class:"timeline-middle"},[()=>J.icon?z(J.icon):z(P[Y]||P.success)]),Tag("div",{class:"timeline-end timeline-box shadow-sm"},[()=>C(J.detail)]),!T?Tag("hr",{class:()=>K()?"bg-primary":""}):null])})})};var df={};R(df,{Toast:()=>H_});var H_=(f,M="alert-success",_=3500)=>{let E=document.getElementById("sigpro-toast-container");if(!E)E=Tag("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(E);let L=Tag("div",{style:"display: contents"});E.appendChild(L);let A,P=()=>{clearTimeout(A);let Q=L.firstElementChild;if(Q&&!Q.classList.contains("opacity-0"))Q.classList.add("translate-x-full","opacity-0"),setTimeout(()=>{if(J.destroy(),L.remove(),!E.hasChildNodes())E.remove()},300);else J.destroy(),L.remove()},W=()=>{let Q=z("icon-[lucide--x]"),X=Tag("div",{class:`alert alert-soft ${M} shadow-lg transition-all duration-300 translate-x-10 opacity-0 pointer-events-auto`},[Tag("span",{},[typeof f==="function"?f():f]),l({class:"btn-xs btn-circle btn-ghost",onclick:P},Q)]);return requestAnimationFrame(()=>X.classList.remove("translate-x-10","opacity-0")),X},J=Mount(W,L);if(_>0)A=setTimeout(P,_);return P};var nf={};R(nf,{Tooltip:()=>j_});var j_=(f,M)=>Tag("div",{...f,class:()=>Z("tooltip w-full",f.class),"data-tip":f.tip},M);var w_={...Xf,...Zf,...Sf,...Yf,...Cf,...qf,...Rf,...zf,...hf,...Df,...Nf,...Of,...Uf,...Vf,...Kf,...Ff,...kf,...Hf,...jf,...wf,...yf,...xf,...uf,...mf,...vf,...gf,...cf,...pf,...bf,...rf,...df,...nf},r_={...w_,install:(f=window)=>{Object.entries(w_).forEach(([M,_])=>{f[M]=_}),console.log("\uD83D\uDE80 SigproUI")}};if(typeof window<"u")Object.entries(Ef).forEach(([f,M])=>{Object.defineProperty(window,f,{value:M,writable:!1,configurable:!0,enumerable:!0})}),Object.entries(Mf).forEach(([f,M])=>{Object.defineProperty(window,f,{value:M,writable:!1,configurable:!0,enumerable:!0})}),Object.defineProperty(window,"tt",{value:I,writable:!1,configurable:!0,enumerable:!0}),Object.defineProperty(window,"SigProUI",{value:{...Ef,Utils:Mf,tt:I},writable:!1,configurable:!0,enumerable:!0}),console.log("\uD83C\uDFA8 SigProUI ready");export{B as val,Z as ui,I as tt,z as getIcon,b as Watch,j_ as Tooltip,H_ as Toast,k_ as Timeline,k as Tag,F_ as Tabs,V_ as Table,U_ as Swap,O_ as Stat,N_ as Stack,D_ as Select,r as Router,h_ as Rating,z_ as Range,R_ as Radio,q_ as Navbar,M_ as Mount,C_ as Modal,Y_ as Menu,S_ as List,K_ as Label,s as Input,Z_ as Indicator,f_ as If,__ as For,X_ as Fileinput,G_ as Fieldset,B_ as Fab,T_ as Dropdown,Q_ as Drawer,J_ as Datepicker,P_ as Colorpicker,W_ as Checkbox,l as Button,A_ as Badge,L_ as Autocomplete,$_ as Alert,E_ as Accordion,i as $}; diff --git a/dist/sigpro-ui.js b/dist/sigpro-ui.js index 80e8e73..492b668 100644 --- a/dist/sigpro-ui.js +++ b/dist/sigpro-ui.js @@ -185,11 +185,11 @@ if (!trigger && activeEffect && !activeEffect._disposed) { subs.add(activeEffect); (activeEffect._deps ||= new Set).add(subs); - } else if (trigger && subs.size > 0) { + } else if (trigger) { let hasQueue = false; - for (const e of subs) { + subs.forEach((e) => { if (e === activeEffect || e._disposed) - continue; + return; if (e._isComputed) { e._dirty = true; if (e._subs) @@ -198,7 +198,7 @@ effectQueue.add(e); hasQueue = true; } - } + }); if (hasQueue && !isFlushing && batchDepth === 0) queueMicrotask(flush); } @@ -266,9 +266,8 @@ var $$ = (target) => { if (!isObj(target)) return target; - let proxy = proxyCache.get(target); - if (proxy) - return proxy; + if (proxyCache.has(target)) + return proxyCache.get(target); const subsMap = new Map; const getSubs = (k) => { let s = subsMap.get(k); @@ -276,30 +275,28 @@ subsMap.set(k, s = new Set); return s; }; - proxy = new Proxy(target, { - get(t, k, receiver) { - if (typeof k !== "symbol") - trackUpdate(getSubs(k)); - return $$(Reflect.get(t, k, receiver)); + const proxy = new Proxy(target, { + get(t, k) { + trackUpdate(getSubs(k)); + return $$(t[k]); }, - set(t, k, v, receiver) { - const isNew = !Reflect.has(t, k); - const oldV = Reflect.get(t, k, receiver); - const result = Reflect.set(t, k, v, receiver); - if (result && !Object.is(oldV, v)) { + set(t, k, v) { + const isNew = !(k in t); + if (!Object.is(t[k], v)) { + t[k] = v; trackUpdate(getSubs(k), true); if (isNew) trackUpdate(getSubs(ITER), true); } - return result; + return true; }, deleteProperty(t, k) { - const result = Reflect.deleteProperty(t, k); - if (result) { + const res = Reflect.deleteProperty(t, k); + if (res) { trackUpdate(getSubs(k), true); trackUpdate(getSubs(ITER), true); } - return result; + return res; }, ownKeys(t) { trackUpdate(getSubs(ITER)); @@ -586,35 +583,6 @@ Router.to = (p) => window.location.hash = p.replace(/^#?\/?/, "#/"); Router.back = () => window.history.back(); Router.path = () => window.location.hash.replace(/^#/, "") || "/"; - var Anim = (show, render, { enter, leave } = {}) => { - const wrap = Tag2("div", { style: "display:contents" }); - let view = null; - const wait = (el, cb) => { - let done = false; - const finish = () => !done && (done = true, cb()); - if (!el) - return finish(); - "transitionend animationend".split(" ").map((e) => el.addEventListener(e, finish, { once: true })); - setTimeout(finish, 500); - }; - Watch2(show, (on) => { - if (on && !view) { - const el = (view = Render(render)).container.firstChild; - wrap.appendChild(view.container); - if (enter && el) { - el.classList.add(enter); - el.clientTop; - el.classList.add(enter + "-active"); - wait(el, () => el.classList.remove(enter, enter + "-active")); - } - } else if (!on && view) { - const el = view.container.firstChild; - const del = () => (view?.destroy(), view = null); - leave && el ? (el.classList.add(leave), wait(el, del)) : del(); - } - }); - return onUnmount(() => view?.destroy()), wrap; - }; var Mount2 = (comp, target) => { const t = typeof target === "string" ? doc.querySelector(target) : target; if (!t) @@ -626,7 +594,7 @@ MOUNTED_NODES.set(t, inst); return inst; }; - var SigPro = Object.freeze({ $: $2, $$, Watch: Watch2, Tag: Tag2, Render, If: If2, For: For2, Router, Mount: Mount2, onMount, onUnmount, Anim, Batch }); + var SigPro = Object.freeze({ $: $2, $$, Watch: Watch2, Tag: Tag2, Render, If: If2, For: For2, Router, Mount: Mount2, onMount, onUnmount, Batch }); if (typeof window !== "undefined") { Object.assign(window, SigPro); "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((t) => window[t[0].toUpperCase() + t.slice(1)] = (p, c) => SigPro.Tag(t, p, c)); diff --git a/dist/sigpro-ui.min.js b/dist/sigpro-ui.min.js index 3cbe2ff..8f4468b 100644 --- a/dist/sigpro-ui.min.js +++ b/dist/sigpro-ui.min.js @@ -1,7 +1,7 @@ -(()=>{var{defineProperty:Pf,getOwnPropertyNames:m_,getOwnPropertyDescriptor:v_}=Object,g_=Object.prototype.hasOwnProperty;var U_=new WeakMap,c_=(f)=>{var M=U_.get(f),_;if(M)return M;if(M=Pf({},"__esModule",{value:!0}),f&&typeof f==="object"||typeof f==="function")m_(f).map((E)=>!g_.call(M,E)&&Pf(M,E,{get:()=>f[E],enumerable:!(_=v_(f,E))||_.enumerable}));return U_.set(f,M),M};var q=(f,M)=>{for(var _ in M)Pf(f,_,{get:M[_],enumerable:!0,configurable:!0,set:(E)=>M[_]=()=>E})};var l_={};q(l_,{val:()=>G,ui:()=>Z,tt:()=>x,getIcon:()=>h,Watch:()=>v,Tooltip:()=>N_,Toast:()=>z_,Timeline:()=>q_,Tag:()=>F,Tabs:()=>Y_,Table:()=>S_,Swap:()=>Z_,Stat:()=>G_,Stack:()=>Q_,Select:()=>P_,Router:()=>c,Rating:()=>T_,Range:()=>$_,Radio:()=>E_,Navbar:()=>__,Mount:()=>Kf,Modal:()=>ef,Menu:()=>lf,List:()=>sf,Label:()=>nf,Input:()=>n,Indicator:()=>bf,If:()=>Xf,For:()=>Zf,Fileinput:()=>pf,Fieldset:()=>gf,Fab:()=>mf,Dropdown:()=>xf,Drawer:()=>jf,Datepicker:()=>kf,Colorpicker:()=>Ff,Checkbox:()=>Vf,Button:()=>o,Badge:()=>Df,Autocomplete:()=>hf,Alert:()=>Yf,Accordion:()=>Sf,$:()=>d});var y=(f)=>typeof f==="function",Bf=(f)=>f&&typeof f==="object",t=Array.isArray,I=typeof document<"u"?document:null,F_=(f)=>f?._isRuntime?f.container:f instanceof Node?f:I.createTextNode(f==null?"":String(f)),O=null,U=null,a=!1,ff=0,_f=new Set,H_=new WeakMap,Jf=Symbol("iter"),Qf=new WeakMap,b=(f)=>{if(!f||f._disposed)return;f._disposed=!0;let M=[f];while(M.length){let _=M.pop();if(_._cleanups)_._cleanups.forEach((E)=>E()),_._cleanups.clear();if(_._children)_._children.forEach((E)=>M.push(E)),_._children.clear();if(_._deps)_._deps.forEach((E)=>E.delete(_)),_._deps.clear()}},p_=(f)=>{if(U)(U._mounts||=[]).push(f)},g=(f)=>{if(U)(U._cleanups||=new Set).add(f)},r_=(f)=>{let M=O;O=null;try{return f()}finally{O=M}},e=(f,M=!1)=>{let _=()=>{if(_._disposed)return;if(_._deps)_._deps.forEach((L)=>L.delete(_));if(_._cleanups)_._cleanups.forEach((L)=>L()),_._cleanups.clear();let E=O,A=U;O=U=_;try{return _._result=f()}catch(L){console.error("[SigPro]",L)}finally{O=E,U=A}};if(_._deps=_._cleanups=_._children=null,_._disposed=!1,_._isComputed=M,_._depth=O?O._depth+1:0,_._mounts=[],_._parent=U,U)(U._children||=new Set).add(_);return _},j_=()=>{if(a)return;a=!0;let f=Array.from(_f).sort((M,_)=>M._depth-_._depth);_f.clear();for(let M of f)if(!M._disposed)M();a=!1},b_=(f)=>{ff++;try{return f()}finally{if(ff--,ff===0&&_f.size>0&&!a)j_()}},j=(f,M=!1)=>{if(!M&&O&&!O._disposed)f.add(O),(O._deps||=new Set).add(f);else if(M&&f.size>0){let _=!1;for(let E of f){if(E===O||E._disposed)continue;if(E._isComputed){if(E._dirty=!0,E._subs)j(E._subs,!0)}else _f.add(E),_=!0}if(_&&!a&&ff===0)queueMicrotask(j_)}},d=(f,M=null)=>{let _=new Set;if(y(f)){let E,A=!0,L=()=>{if(A){let W=O;O=L;try{let T=f();if(!Object.is(E,T))E=T,A=!1,j(_,!0)}finally{O=W}}return j(_),E};if(L._isComputed=!0,L._subs=_,L._dirty=!0,L._deps=null,L._disposed=!1,L.markDirty=()=>{A=!0},L.stop=()=>{if(L._disposed=!0,L._deps)L._deps.forEach((W)=>W.delete(L)),L._deps.clear();_.clear()},U)g(L.stop);return L}if(M)try{f=JSON.parse(localStorage.getItem(M))??f}catch(E){}return(...E)=>{if(E.length){let A=y(E[0])?E[0](f):E[0];if(!Object.is(f,A)){if(f=A,M)localStorage.setItem(M,JSON.stringify(f));j(_,!0)}}return j(_),f}},y_=(f)=>{if(!Bf(f))return f;let M=H_.get(f);if(M)return M;let _=new Map,E=(A)=>{let L=_.get(A);if(!L)_.set(A,L=new Set);return L};return M=new Proxy(f,{get(A,L,W){if(typeof L!=="symbol")j(E(L));return y_(Reflect.get(A,L,W))},set(A,L,W,T){let P=!Reflect.has(A,L),J=Reflect.get(A,L,T),B=Reflect.set(A,L,W,T);if(B&&!Object.is(J,W)){if(j(E(L),!0),P)j(E(Jf),!0)}return B},deleteProperty(A,L){let W=Reflect.deleteProperty(A,L);if(W)j(E(L),!0),j(E(Jf),!0);return W},ownKeys(A){return j(E(Jf)),Reflect.ownKeys(A)}}),H_.set(f,M),M},v=(f,M)=>{if(M===void 0){let E=e(f);return E(),()=>b(E)}let _=e(()=>{let E=Array.isArray(f)?f.map((A)=>A()):f();r_(()=>M(E))});return _(),()=>b(_)},Gf=(f)=>{if(f._cleanups)f._cleanups.forEach((M)=>M()),f._cleanups.clear();if(f._ownerEffect)b(f._ownerEffect);if(f.childNodes)f.childNodes.forEach(Gf)},d_=/^\s*(javascript|data|vbscript):/i,n_=(f)=>f==="src"||f==="href"||f.startsWith("on"),k_=(f,M)=>{if(M==null||M===!1)return null;if(n_(f)){let _=String(M);if(d_.test(_))return console.warn(`[SigPro] Bloqueado protocolo peligroso en ${f}`),"#"}return M},F=(f,M={},_=[])=>{if(M instanceof Node||t(M)||!Bf(M))_=M,M={};if(y(f)){let W={_mounts:[],_cleanups:new Set},T=e(()=>{let Q=f(M,{children:_,emit:(C,...K)=>M[`on${C[0].toUpperCase()}${C.slice(1)}`]?.(...K)});return T._result=Q,Q});T();let P=T._result;if(P==null)return null;let J=P instanceof Node||t(P)&&P.every((Q)=>Q instanceof Node)?P:I.createTextNode(String(P)),B=(Q)=>{if(Bf(Q)&&!Q._isRuntime)Q._mounts=T._mounts||[],Q._cleanups=T._cleanups||new Set,Q._ownerEffect=T};return t(J)?J.forEach(B):B(J),J}let E=/^(svg|path|circle|rect|line|polyline|polygon|g|defs|text|tspan|use)$/.test(f),A=E?I.createElementNS("http://www.w3.org/2000/svg",f):I.createElement(f);A._cleanups=new Set;for(let W in M){if(!M.hasOwnProperty(W))continue;let T=M[W];if(W==="ref"){y(T)?T(A):T.current=A;continue}if(W.startsWith("on")){let P=W.slice(2).toLowerCase();A.addEventListener(P,T);let J=()=>A.removeEventListener(P,T);A._cleanups.add(J),g(J)}else if(y(T)){let P=e(()=>{let J=k_(W,T());if(W==="class")A.className=J||"";else if(J==null)A.removeAttribute(W);else if(W in A&&!E)A[W]=J;else A.setAttribute(W,J===!0?"":J)});if(P(),A._cleanups.add(()=>b(P)),g(()=>b(P)),/^(INPUT|TEXTAREA|SELECT)$/.test(A.tagName)&&(W==="value"||W==="checked")){let J=W==="checked"?"change":"input";A.addEventListener(J,(B)=>T(B.target[W]))}}else{let P=k_(W,T);if(P!=null)if(W in A&&!E)A[W]=P;else A.setAttribute(W,P===!0?"":P)}}let L=(W)=>{if(t(W))return W.forEach(L);if(y(W)){let T=I.createTextNode("");A.appendChild(T);let P=[],J=e(()=>{let B=W(),Q=(t(B)?B:[B]).map(F_);P.forEach((K)=>{if(K._isRuntime)K.destroy();else Gf(K);if(K.parentNode)K.remove()});let C=T;for(let K=Q.length-1;K>=0;K--){let X=Q[K];if(X.parentNode!==C.parentNode)C.parentNode?.insertBefore(X,C);if(X._mounts)X._mounts.forEach((Y)=>Y());C=X}P=Q});J(),A._cleanups.add(()=>b(J)),g(()=>b(J))}else{let T=F_(W);if(A.appendChild(T),T._mounts)T._mounts.forEach((P)=>P())}};return L(_),A},l=(f)=>{let M=new Set,_=[],E=U,A=O,L=I.createElement("div");L.style.display="contents",L.setAttribute("role","presentation"),U={_cleanups:M,_mounts:_},O=null;let W=(T)=>{if(!T)return;if(T._isRuntime)M.add(T.destroy),L.appendChild(T.container);else if(t(T))T.forEach(W);else L.appendChild(T instanceof Node?T:I.createTextNode(String(T==null?"":T)))};try{W(f({onCleanup:(T)=>M.add(T)}))}finally{U=E,O=A}return _.forEach((T)=>T()),{_isRuntime:!0,container:L,destroy:()=>{M.forEach((T)=>T()),Gf(L),L.remove()}}},Xf=(f,M,_=null)=>{let E=I.createTextNode(""),A=F("div",{style:"display:contents"},[E]),L=null;return v(()=>!!(y(f)?f():f),(W)=>{if(L)L.destroy(),L=null;let T=W?M:_;if(T)L=l(()=>y(T)?T():T),A.insertBefore(L.container,E)}),g(()=>L?.destroy()),A},Zf=(f,M,_)=>{let E=I.createTextNode(""),A=F("div",{style:"display:contents"},[E]),L=new Map;return v(()=>(y(f)?f():f)||[],(W)=>{let T=new Map,P=[],J=W||[];for(let Q=0;QM(C,Q));else L.delete(K);T.set(K,X),P.push(X)}L.forEach((Q)=>Q.destroy());let B=E;for(let Q=P.length-1;Q>=0;Q--){let K=P[Q].container;if(K.nextSibling!==B)A.insertBefore(K,B);B=K}L=T}),A},c=(f)=>{let M=()=>window.location.hash.slice(1)||"/",_=d(M()),E=()=>_(M());window.addEventListener("hashchange",E),g(()=>window.removeEventListener("hashchange",E));let A=F("div",{class:"router-hook"}),L=null;return v([_],()=>{let W=_(),T=f.find((P)=>{let J=P.path.split("/").filter(Boolean),B=W.split("/").filter(Boolean);return J.length===B.length&&J.every((Q,C)=>Q[0]===":"||Q===B[C])})||f.find((P)=>P.path==="*");if(T){L?.destroy();let P={};T.path.split("/").filter(Boolean).forEach((J,B)=>{if(J[0]===":")P[J.slice(1)]=W.split("/").filter(Boolean)[B]}),c.params(P),L=l(()=>y(T.component)?T.component(P):T.component),A.replaceChildren(L.container)}}),A};c.params=d({});c.to=(f)=>window.location.hash=f.replace(/^#?\/?/,"#/");c.back=()=>window.history.back();c.path=()=>window.location.hash.replace(/^#/,"")||"/";var o_=(f,M,{enter:_,leave:E}={})=>{let A=F("div",{style:"display:contents"}),L=null,W=(T,P)=>{let J=!1,B=()=>!J&&(J=!0,P());if(!T)return B();"transitionend animationend".split(" ").map((Q)=>T.addEventListener(Q,B,{once:!0})),setTimeout(B,500)};return v(f,(T)=>{if(T&&!L){let P=(L=l(M)).container.firstChild;if(A.appendChild(L.container),_&&P)P.classList.add(_),P.clientTop,P.classList.add(_+"-active"),W(P,()=>P.classList.remove(_,_+"-active"))}else if(!T&&L){let P=L.container.firstChild,J=()=>(L?.destroy(),L=null);E&&P?(P.classList.add(E),W(P,J)):J()}}),g(()=>L?.destroy()),A},Kf=(f,M)=>{let _=typeof M==="string"?I.querySelector(M):M;if(!_)return;if(Qf.has(_))Qf.get(_).destroy();let E=l(y(f)?f:()=>f);return _.replaceChildren(E.container),Qf.set(_,E),E},w_=Object.freeze({$:d,$$:y_,Watch:v,Tag:F,Render:l,If:Xf,For:Zf,Router:c,Mount:Kf,onMount:p_,onUnmount:g,Anim:o_,Batch:b_});if(typeof window<"u")Object.assign(window,w_),"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((f)=>window[f[0].toUpperCase()+f.slice(1)]=(M,_)=>w_.Tag(f,M,_));var Ef={};q(Ef,{default:()=>t_,Tooltip:()=>N_,Toast:()=>z_,Timeline:()=>q_,Tabs:()=>Y_,Table:()=>S_,Swap:()=>Z_,Stat:()=>G_,Stack:()=>Q_,Select:()=>P_,Rating:()=>T_,Range:()=>$_,Radio:()=>E_,Navbar:()=>__,Modal:()=>ef,Menu:()=>lf,List:()=>sf,Label:()=>nf,Input:()=>n,Indicator:()=>bf,Fileinput:()=>pf,Fieldset:()=>gf,Fab:()=>mf,Dropdown:()=>xf,Drawer:()=>jf,Datepicker:()=>kf,Colorpicker:()=>Ff,Checkbox:()=>Vf,Button:()=>o,Badge:()=>Df,Autocomplete:()=>hf,Alert:()=>Yf,Accordion:()=>Sf});var Cf={};q(Cf,{Accordion:()=>Sf});var Mf={};q(Mf,{val:()=>G,ui:()=>Z,getIcon:()=>h});var G=(f)=>typeof f==="function"?f():f,Z=(f,M)=>typeof M==="function"?()=>`${f} ${M()||""}`.trim():`${f} ${M||""}`.trim(),h=(f)=>{if(!f)return null;if(typeof f==="function")return Tag("span",{class:"mr-1"},f());if(typeof f==="object")return Tag("span",{class:"mr-1"},f);if(typeof f==="string"){let M=f.trim().split(/\s+/),_=M[M.length-1]==="right",E=_?M.slice(0,-1).join(" "):f,A=_?"ml-1":"mr-1";if(E&&!E.startsWith("icon-[")&&!E.includes("--"))return Tag("span",{class:A},E);return Tag("span",{class:`${E} ${A}`.trim()})}return null};var Sf=(f,M)=>{let{class:_,title:E,name:A,open:L,...W}=f;return Tag("div",{...W,class:Z("collapse collapse-arrow bg-base-200 mb-2",_)},[Tag("input",{type:A?"radio":"checkbox",name:A,checked:G(L)}),Tag("div",{class:"collapse-title text-xl font-medium"},E),Tag("div",{class:"collapse-content"},M)])};var Rf={};q(Rf,{Alert:()=>Yf});var Yf=(f,M)=>{let{class:_,actions:E,type:A="info",soft:L=!0,...W}=f,T={info:"icon-[lucide--info]",success:"icon-[lucide--check-circle]",warning:"icon-[lucide--alert-triangle]",error:"icon-[lucide--alert-circle]"},B=[`alert-${A}`,L?"alert-soft":"",_].filter(Boolean).join(" "),Q=M||f.message;return Tag("div",{...W,role:"alert",class:Z("alert",B)},()=>[h(T[A]),Tag("div",{class:"flex-1"},[Tag("span",{},[typeof Q==="function"?Q():Q])]),E?Tag("div",{class:"flex-none"},[typeof E==="function"?E():E]):null].filter(Boolean))};var zf={};q(zf,{Autocomplete:()=>hf});var i_={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"}},s_=$("es");var x=(f)=>()=>i_[s_()][f]||f;var qf={};q(qf,{Input:()=>n});var n=(f)=>{let{class:M,value:_,type:E="text",icon:A,oninput:L,placeholder:W,disabled:T,validate:P,label:J,...B}=f,Q=E==="password",C=$(!1),K=$(null),X={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]"},Y=A?h(A):X[E]?h(X[E]):null,z=()=>h(C()?"icon-[lucide--eye-off]":"icon-[lucide--eye]"),V=Y?"pl-10":"",k=Q?"pr-10":"",i=()=>{if(M?.includes("input-xs"))return"btn-xs";if(M?.includes("input-sm"))return"btn-sm";if(M?.includes("input-lg"))return"btn-lg";return"btn-md"},s=(D)=>{let p=D.target.value;if(P){let Lf=P(p);K(Lf||null)}L?.(D)},H=()=>K()&&K()!=="",S=()=>{let D=`input w-full ${V} ${k}`;if(M)D+=` ${M}`;if(H())D+=" input-error";return D.trim()},R=Tag("input",{...B,type:()=>Q?C()?"text":"password":E,placeholder:W||(J?" ":W),class:S,value:_,oninput:s,disabled:()=>G(T),"aria-invalid":()=>H()?"true":"false"}),N=()=>[R,Y?Tag("div",{class:"absolute left-3 inset-y-0 flex items-center pointer-events-none text-base-content/60"},Y):null,Q?Tag("button",{type:"button",class:Z("absolute right-3 inset-y-0 flex items-center","btn btn-ghost btn-circle opacity-50 hover:opacity-100",i()),onclick:(D)=>{D.preventDefault(),C(!C())}},()=>z()):null,Tag("div",{class:"text-error text-xs mt-1 px-3 absolute -bottom-5 left-0"},()=>H()?K():null)];if(J)return Tag("label",{class:Z("floating-label w-full",M)},()=>[Tag("div",{class:"relative w-full"},N),Tag("span",{},G(J))]);return Tag("div",{class:"relative w-full"},N)};var hf=(f)=>{let{class:M,items:_=[],value:E,onselect:A,label:L,placeholder:W,...T}=f,P=$(G(E)||""),J=$(!1),B=$(-1),Q=$([]);Watch(()=>{let X=String(P()).toLowerCase(),Y=G(_)||[],z=X?Y.filter((V)=>(typeof V==="string"?V:V.label).toLowerCase().includes(X)):Y;Q(z)});let C=(X)=>{let Y=typeof X==="string"?X:X.value,z=typeof X==="string"?X:X.label;if(P(z),typeof E==="function")E(Y);A?.(X),J(!1),B(-1)},K=(X)=>{let Y=Q();if(X.key==="ArrowDown")X.preventDefault(),J(!0),B(Math.min(B()+1,Y.length-1));else if(X.key==="ArrowUp")X.preventDefault(),B(Math.max(B()-1,0));else if(X.key==="Enter"&&B()>=0)X.preventDefault(),C(Y[B()]);else if(X.key==="Escape")J(!1)};return Tag("div",{class:"relative w-full"},[n({label:L,class:M,placeholder:W||x("search")(),value:P,onfocus:()=>J(!0),onblur:()=>setTimeout(()=>J(!1),150),onkeydown:K,oninput:(X)=>{let Y=X.target.value;if(P(Y),typeof E==="function")E(Y);J(!0),B(-1)},...T}),Tag("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:()=>J()&&Q().length?"display:block":"display:none"},[For(Q,(X,Y)=>Tag("li",{},[Tag("a",{class:()=>`block w-full ${B()===Y?"active bg-primary text-primary-content":""}`,onclick:()=>C(X),onmouseenter:()=>B(Y)},typeof X==="string"?X:X.label)]),(X,Y)=>(typeof X==="string"?X:X.value)+Y),()=>Q().length?null:Tag("li",{class:"p-2 text-center opacity-50"},x("nodata")())])])};var Nf={};q(Nf,{Badge:()=>Df});var Df=(f,M)=>{let{class:_,...E}=f;return Tag("span",{...E,class:Z("badge",_)},M)};var Of={};q(Of,{Button:()=>o});var o=(f,M)=>{let{class:_,loading:E,icon:A,...L}=f,W=h(A);return Tag("button",{...L,class:Z("btn",_),disabled:()=>G(E)||G(f.disabled)},()=>[G(E)&&Tag("span",{class:"loading loading-spinner"}),W,M].filter(Boolean))};var Uf={};q(Uf,{Checkbox:()=>Vf});var Vf=(f)=>{let{class:M,value:_,toggle:E,label:A,...L}=f,W=Tag("input",{...L,type:"checkbox",class:()=>Z(G(E)?"toggle":"checkbox",M),checked:_});return Tag("label",{class:"label cursor-pointer justify-start gap-3"},[W,A?Tag("span",{class:"label-text"},A):null])};var Hf={};q(Hf,{Colorpicker:()=>Ff});var Ff=(f)=>{let{class:M,value:_,label:E,...A}=f,L=$(!1),W=["#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"],T=()=>G(_)||"#000000";return Tag("div",{class:Z("relative w-fit",M)},[Tag("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:(P)=>{P.stopPropagation(),L(!L())},...A},[Tag("div",{class:"size-5 rounded-sm shadow-inner border border-black/10 shrink-0",style:()=>`background-color: ${T()}`}),E?Tag("span",{class:"opacity-80"},E):null]),If(L,()=>Tag("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:(P)=>P.stopPropagation()},[Tag("div",{class:"grid grid-cols-8 gap-1"},W.map((P)=>Tag("button",{type:"button",style:`background-color: ${P}`,class:()=>{return`size-6 rounded-sm cursor-pointer transition-all hover:scale-125 hover:z-10 active:scale-95 outline-none border border-black/5 - ${T().toLowerCase()===P.toLowerCase()?"ring-2 ring-offset-1 ring-primary z-10 scale-110":""}`},onclick:()=>{if(typeof _==="function")_(P);L(!1)}})))])),If(L,()=>Tag("div",{class:"fixed inset-0 z-[100]",onclick:()=>L(!1)}))])};var wf={};q(wf,{Datepicker:()=>kf});var kf=(f)=>{let{class:M,value:_,range:E,label:A,placeholder:L,hour:W=!1,...T}=f,P=$(!1),J=$(new Date),B=$(null),Q=$(0),C=$(0),K=()=>G(E)===!0,X=new Date,Y=`${X.getFullYear()}-${String(X.getMonth()+1).padStart(2,"0")}-${String(X.getDate()).padStart(2,"0")}`,z=(S)=>{let R=S.getFullYear(),N=String(S.getMonth()+1).padStart(2,"0"),D=String(S.getDate()).padStart(2,"0");return`${R}-${N}-${D}`},V=(S)=>{let R=z(S),N=G(_);if(K())if(!N?.start||N.start&&N.end){if(typeof _==="function")_({start:R,end:null,...W&&{startHour:Q()}})}else{let D=N.start;if(typeof _==="function"){let p=R{let S=G(_);if(!S){k("");return}let R="";if(typeof S==="string")R=W&&S.includes("T")?S.replace("T"," "):S;else if(S.start&&S.end){let N=W&&S.startHour!==void 0?`${S.start} ${String(S.startHour).padStart(2,"0")}:00`:S.start,D=W&&S.endHour!==void 0?`${S.end} ${String(S.endHour).padStart(2,"0")}:00`:S.end;R=`${N} - ${D}`}else if(S.start)R=`${W&&S.startHour!==void 0?`${S.start} ${String(S.startHour).padStart(2,"0")}:00`:S.start}...`;k(R)});let i=(S)=>{let R=J();J(new Date(R.getFullYear(),R.getMonth()+S,1))},s=(S)=>{let R=J();J(new Date(R.getFullYear()+S,R.getMonth(),1))},H=({value:S,onChange:R})=>{return Tag("div",{class:"flex-1"},[Tag("div",{class:"flex gap-2 items-center"},[Tag("input",{type:"range",min:0,max:23,value:S,class:"range range-xs flex-1",oninput:(N)=>{let D=parseInt(N.target.value);R(D)}}),Tag("span",{class:"text-sm font-mono min-w-[48px] text-center"},()=>String(G(S)).padStart(2,"0")+":00")])])};return Tag("div",{class:Z("relative w-full",M)},[n({label:A,placeholder:L||(K()?"Seleccionar rango...":"Seleccionar fecha..."),value:k,readonly:!0,icon:h("icon-[lucide--calendar]"),onclick:(S)=>{S.stopPropagation(),P(!P())},...T}),If(P,()=>Tag("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:(S)=>S.stopPropagation()},[Tag("div",{class:"flex justify-between items-center mb-4 gap-1"},[Tag("div",{class:"flex gap-0.5"},[Tag("button",{type:"button",class:"btn btn-ghost btn-xs px-1",onclick:()=>s(-1)},h("icon-[lucide--chevrons-left]")),Tag("button",{type:"button",class:"btn btn-ghost btn-xs px-1",onclick:()=>i(-1)},h("icon-[lucide--chevron-left]"))]),Tag("span",{class:"font-bold uppercase flex-1 text-center"},[()=>J().toLocaleString("es-ES",{month:"short",year:"numeric"})]),Tag("div",{class:"flex gap-0.5"},[Tag("button",{type:"button",class:"btn btn-ghost btn-xs px-1",onclick:()=>i(1)},h("icon-[lucide--chevron-right]")),Tag("button",{type:"button",class:"btn btn-ghost btn-xs px-1",onclick:()=>s(1)},h("icon-[lucide--chevrons-right]"))])]),Tag("div",{class:"grid grid-cols-7 gap-1",onmouseleave:()=>B(null)},[...["L","M","X","J","V","S","D"].map((S)=>Tag("div",{class:"text-[10px] opacity-40 font-bold text-center"},S)),()=>{let S=J(),R=S.getFullYear(),N=S.getMonth(),D=new Date(R,N,1).getDay(),p=D===0?6:D-1,Lf=new Date(R,N+1,0).getDate(),$f=[];for(let r=0;r{let m=G(_),Af=B(),I_=typeof m==="string"?m.split("T")[0]===w:m?.start===w,u_=m?.end===w,Tf=!1;if(K()&&m?.start){let Wf=m.start;if(!m.end&&Af)Tf=w>Wf&&w<=Af||w=Af;else if(m.end)Tf=w>Wf&&w{if(K())B(w)},onclick:()=>V(V_)},[r.toString()]))}return $f}]),W?Tag("div",{class:"mt-3 pt-2 border-t border-base-300"},[K()?Tag("div",{class:"flex gap-4"},[H({value:Q,onChange:(S)=>{Q(S);let R=G(_);if(R?.start)_({...R,startHour:S})}}),H({value:C,onChange:(S)=>{C(S);let R=G(_);if(R?.end)_({...R,endHour:S})}})]):H({value:Q,onChange:(S)=>{Q(S);let R=G(_);if(R&&typeof R==="string")_(R.split("T")[0]+"T"+String(S).padStart(2,"0")+":00:00")}})]):null])),If(P,()=>Tag("div",{class:"fixed inset-0 z-[90]",onclick:()=>P(!1)}))])};var yf={};q(yf,{Drawer:()=>jf});var jf=(f,M)=>{let{class:_,id:E,open:A,side:L,content:W,...T}=f,P=E||`drawer-${Math.random().toString(36).slice(2,9)}`;return Tag("div",{...T,class:Z("drawer",_)},[Tag("input",{id:P,type:"checkbox",class:"drawer-toggle",checked:()=>typeof A==="function"?A():A,onchange:(J)=>{if(typeof A==="function")A(J.target.checked)}}),Tag("div",{class:"drawer-content"},[typeof W==="function"?W():W]),Tag("div",{class:"drawer-side"},[Tag("label",{for:P,class:"drawer-overlay",onclick:()=>{if(typeof A==="function")A(!1)}}),Tag("div",{class:"min-h-full bg-base-200 w-80"},[typeof L==="function"?L():L])])])};var uf={};q(uf,{Dropdown:()=>xf});var u=null;if(typeof window<"u"&&!window.__dropdownHandlerRegistered)window.addEventListener("click",(f)=>{if(u&&!u.contains(f.target))u.open=!1,u=null}),window.__dropdownHandlerRegistered=!0;var xf=(f)=>{let{class:M,label:_,icon:E,items:A,...L}=f;return Tag("details",{...L,class:Z("dropdown",M)},[Tag("summary",{class:"btn m-1 flex items-center gap-2 list-none cursor-pointer",style:"display: inline-flex;",onclick:(W)=>{let T=W.currentTarget.closest("details");if(u&&u!==T)u.open=!1;setTimeout(()=>{u=T.open?T:null},0)}},[()=>E?typeof E==="function"?E():E:null,()=>_?typeof _==="function"?_():_:null]),Tag("ul",{tabindex:"-1",class:"dropdown-content z-[50] menu p-2 shadow bg-base-100 rounded-box w-52 border border-base-300"},[()=>{return(typeof A==="function"?A():A||[]).map((T)=>Tag("li",{},[Tag("a",{class:T.class||"",onclick:(P)=>{if(T.onclick)T.onclick(P);let J=P.currentTarget.closest("details");if(J){if(J.open=!1,u===J)u=null}}},[T.icon?Tag("span",{},T.icon):null,Tag("span",{},T.label)])]))}])])};var vf={};q(vf,{Fab:()=>mf});var mf=(f)=>{let{class:M,icon:_,label:E,actions:A=[],position:L="bottom-6 right-6",...W}=f;return Tag("div",{...W,class:Z(`fab absolute ${L} flex flex-col-reverse items-end gap-3 z-[100]`,M)},[Tag("div",{tabindex:0,role:"button",class:"btn btn-lg btn-circle btn-primary shadow-2xl"},[_?h(_):null,!_&&E?E:null]),...G(A).map((T)=>Tag("div",{class:"flex items-center gap-3 transition-all duration-300"},[T.label?Tag("span",{class:"badge badge-ghost shadow-sm whitespace-nowrap"},T.label):null,Tag("button",{type:"button",class:`btn btn-circle shadow-lg ${T.class||""}`,onclick:(P)=>{P.stopPropagation(),T.onclick?.(P)}},[T.icon?h(T.icon):T.text||""])]))])};var cf={};q(cf,{Fieldset:()=>gf});var gf=(f,M)=>{let{class:_,legend:E,...A}=f;return Tag("fieldset",{...A,class:Z("fieldset bg-base-200 border border-base-300 p-4 rounded-lg",_)},[()=>{let L=G(E);return L?Tag("legend",{class:"fieldset-legend font-bold"},[L]):null},M])};var rf={};q(rf,{Fileinput:()=>pf});var pf=(f)=>{let{class:M,tooltip:_,max:E=2,accept:A="*",onselect:L,...W}=f,T=$([]),P=$(!1),J=$(null),B=E*1024*1024,Q=(K)=>{let X=Array.from(K);if(J(null),X.find((z)=>z.size>B)){J(`Máx ${E}MB`);return}T([...T(),...X]),L?.(T())},C=(K)=>{let X=T().filter((Y,z)=>z!==K);T(X),L?.(X)};return Tag("fieldset",{...W,class:Z("fieldset w-full p-0",M)},[Tag("div",{class:()=>`w-full ${_?"tooltip tooltip-top before:z-50 after:z-50":""}`,"data-tip":_},[Tag("label",{class:()=>` +(()=>{var{defineProperty:Jf,getOwnPropertyNames:m_,getOwnPropertyDescriptor:v_}=Object,g_=Object.prototype.hasOwnProperty;var F_=new WeakMap,c_=(f)=>{var M=F_.get(f),_;if(M)return M;if(M=Jf({},"__esModule",{value:!0}),f&&typeof f==="object"||typeof f==="function")m_(f).map((E)=>!g_.call(M,E)&&Jf(M,E,{get:()=>f[E],enumerable:!(_=v_(f,E))||_.enumerable}));return F_.set(f,M),M};var R=(f,M)=>{for(var _ in M)Jf(f,_,{get:M[_],enumerable:!0,configurable:!0,set:(E)=>M[_]=()=>E})};var l_={};R(l_,{val:()=>B,ui:()=>Z,tt:()=>x,getIcon:()=>z,Watch:()=>v,Tooltip:()=>O_,Toast:()=>D_,Timeline:()=>z_,Tag:()=>k,Tabs:()=>q_,Table:()=>Y_,Swap:()=>K_,Stat:()=>X_,Stack:()=>B_,Select:()=>Q_,Router:()=>g,Rating:()=>P_,Range:()=>A_,Radio:()=>$_,Navbar:()=>M_,Mount:()=>Sf,Modal:()=>f_,Menu:()=>af,List:()=>lf,Label:()=>of,Input:()=>n,Indicator:()=>df,If:()=>Zf,For:()=>Kf,Fileinput:()=>bf,Fieldset:()=>cf,Fab:()=>vf,Dropdown:()=>uf,Drawer:()=>yf,Datepicker:()=>jf,Colorpicker:()=>kf,Checkbox:()=>Vf,Button:()=>o,Badge:()=>Nf,Autocomplete:()=>hf,Alert:()=>qf,Accordion:()=>Yf,$:()=>d});var y=(f)=>typeof f==="function",Gf=(f)=>f&&typeof f==="object",l=Array.isArray,I=typeof document<"u"?document:null,k_=(f)=>f?._isRuntime?f.container:f instanceof Node?f:I.createTextNode(f==null?"":String(f)),O=null,V=null,t=!1,ff=0,_f=new Set,Qf=new WeakMap,Tf=Symbol("iter"),Bf=new WeakMap,b=(f)=>{if(!f||f._disposed)return;f._disposed=!0;let M=[f];while(M.length){let _=M.pop();if(_._cleanups)_._cleanups.forEach((E)=>E()),_._cleanups.clear();if(_._children)_._children.forEach((E)=>M.push(E)),_._children.clear();if(_._deps)_._deps.forEach((E)=>E.delete(_)),_._deps.clear()}},p_=(f)=>{if(V)(V._mounts||=[]).push(f)},r=(f)=>{if(V)(V._cleanups||=new Set).add(f)},b_=(f)=>{let M=O;O=null;try{return f()}finally{O=M}},a=(f,M=!1)=>{let _=()=>{if(_._disposed)return;if(_._deps)_._deps.forEach((A)=>A.delete(_));if(_._cleanups)_._cleanups.forEach((A)=>A()),_._cleanups.clear();let E=O,L=V;O=V=_;try{return _._result=f()}catch(A){console.error("[SigPro]",A)}finally{O=E,V=L}};if(_._deps=_._cleanups=_._children=null,_._disposed=!1,_._isComputed=M,_._depth=O?O._depth+1:0,_._mounts=[],_._parent=V,V)(V._children||=new Set).add(_);return _},w_=()=>{if(t)return;t=!0;let f=Array.from(_f).sort((M,_)=>M._depth-_._depth);_f.clear();for(let M of f)if(!M._disposed)M();t=!1},r_=(f)=>{ff++;try{return f()}finally{if(ff--,ff===0&&_f.size>0&&!t)w_()}},w=(f,M=!1)=>{if(!M&&O&&!O._disposed)f.add(O),(O._deps||=new Set).add(f);else if(M){let _=!1;if(f.forEach((E)=>{if(E===O||E._disposed)return;if(E._isComputed){if(E._dirty=!0,E._subs)w(E._subs,!0)}else _f.add(E),_=!0}),_&&!t&&ff===0)queueMicrotask(w_)}},d=(f,M=null)=>{let _=new Set;if(y(f)){let E,L=!0,A=()=>{if(L){let P=O;O=A;try{let W=f();if(!Object.is(E,W))E=W,L=!1,w(_,!0)}finally{O=P}}return w(_),E};if(A._isComputed=!0,A._subs=_,A._dirty=!0,A._deps=null,A._disposed=!1,A.markDirty=()=>{L=!0},A.stop=()=>{if(A._disposed=!0,A._deps)A._deps.forEach((P)=>P.delete(A)),A._deps.clear();_.clear()},V)r(A.stop);return A}if(M)try{f=JSON.parse(localStorage.getItem(M))??f}catch(E){}return(...E)=>{if(E.length){let L=y(E[0])?E[0](f):E[0];if(!Object.is(f,L)){if(f=L,M)localStorage.setItem(M,JSON.stringify(f));w(_,!0)}}return w(_),f}},y_=(f)=>{if(!Gf(f))return f;if(Qf.has(f))return Qf.get(f);let M=new Map,_=(L)=>{let A=M.get(L);if(!A)M.set(L,A=new Set);return A},E=new Proxy(f,{get(L,A){return w(_(A)),y_(L[A])},set(L,A,P){let W=!(A in L);if(!Object.is(L[A],P)){if(L[A]=P,w(_(A),!0),W)w(_(Tf),!0)}return!0},deleteProperty(L,A){let P=Reflect.deleteProperty(L,A);if(P)w(_(A),!0),w(_(Tf),!0);return P},ownKeys(L){return w(_(Tf)),Reflect.ownKeys(L)}});return Qf.set(f,E),E},v=(f,M)=>{if(M===void 0){let E=a(f);return E(),()=>b(E)}let _=a(()=>{let E=Array.isArray(f)?f.map((L)=>L()):f();b_(()=>M(E))});return _(),()=>b(_)},Xf=(f)=>{if(f._cleanups)f._cleanups.forEach((M)=>M()),f._cleanups.clear();if(f._ownerEffect)b(f._ownerEffect);if(f.childNodes)f.childNodes.forEach(Xf)},d_=/^\s*(javascript|data|vbscript):/i,n_=(f)=>f==="src"||f==="href"||f.startsWith("on"),H_=(f,M)=>{if(M==null||M===!1)return null;if(n_(f)){let _=String(M);if(d_.test(_))return console.warn(`[SigPro] Bloqueado protocolo peligroso en ${f}`),"#"}return M},k=(f,M={},_=[])=>{if(M instanceof Node||l(M)||!Gf(M))_=M,M={};if(y(f)){let P={_mounts:[],_cleanups:new Set},W=a(()=>{let T=f(M,{children:_,emit:(Y,...K)=>M[`on${Y[0].toUpperCase()}${Y.slice(1)}`]?.(...K)});return W._result=T,T});W();let J=W._result;if(J==null)return null;let Q=J instanceof Node||l(J)&&J.every((T)=>T instanceof Node)?J:I.createTextNode(String(J)),X=(T)=>{if(Gf(T)&&!T._isRuntime)T._mounts=W._mounts||[],T._cleanups=W._cleanups||new Set,T._ownerEffect=W};return l(Q)?Q.forEach(X):X(Q),Q}let E=/^(svg|path|circle|rect|line|polyline|polygon|g|defs|text|tspan|use)$/.test(f),L=E?I.createElementNS("http://www.w3.org/2000/svg",f):I.createElement(f);L._cleanups=new Set;for(let P in M){if(!M.hasOwnProperty(P))continue;let W=M[P];if(P==="ref"){y(W)?W(L):W.current=L;continue}if(P.startsWith("on")){let J=P.slice(2).toLowerCase();L.addEventListener(J,W);let Q=()=>L.removeEventListener(J,W);L._cleanups.add(Q),r(Q)}else if(y(W)){let J=a(()=>{let Q=H_(P,W());if(P==="class")L.className=Q||"";else if(Q==null)L.removeAttribute(P);else if(P in L&&!E)L[P]=Q;else L.setAttribute(P,Q===!0?"":Q)});if(J(),L._cleanups.add(()=>b(J)),r(()=>b(J)),/^(INPUT|TEXTAREA|SELECT)$/.test(L.tagName)&&(P==="value"||P==="checked")){let Q=P==="checked"?"change":"input";L.addEventListener(Q,(X)=>W(X.target[P]))}}else{let J=H_(P,W);if(J!=null)if(P in L&&!E)L[P]=J;else L.setAttribute(P,J===!0?"":J)}}let A=(P)=>{if(l(P))return P.forEach(A);if(y(P)){let W=I.createTextNode("");L.appendChild(W);let J=[],Q=a(()=>{let X=P(),T=(l(X)?X:[X]).map(k_);J.forEach((K)=>{if(K._isRuntime)K.destroy();else Xf(K);if(K.parentNode)K.remove()});let Y=W;for(let K=T.length-1;K>=0;K--){let G=T[K];if(G.parentNode!==Y.parentNode)Y.parentNode?.insertBefore(G,Y);if(G._mounts)G._mounts.forEach((C)=>C());Y=G}J=T});Q(),L._cleanups.add(()=>b(Q)),r(()=>b(Q))}else{let W=k_(P);if(L.appendChild(W),W._mounts)W._mounts.forEach((J)=>J())}};return A(_),L},e=(f)=>{let M=new Set,_=[],E=V,L=O,A=I.createElement("div");A.style.display="contents",A.setAttribute("role","presentation"),V={_cleanups:M,_mounts:_},O=null;let P=(W)=>{if(!W)return;if(W._isRuntime)M.add(W.destroy),A.appendChild(W.container);else if(l(W))W.forEach(P);else A.appendChild(W instanceof Node?W:I.createTextNode(String(W==null?"":W)))};try{P(f({onCleanup:(W)=>M.add(W)}))}finally{V=E,O=L}return _.forEach((W)=>W()),{_isRuntime:!0,container:A,destroy:()=>{M.forEach((W)=>W()),Xf(A),A.remove()}}},Zf=(f,M,_=null)=>{let E=I.createTextNode(""),L=k("div",{style:"display:contents"},[E]),A=null;return v(()=>!!(y(f)?f():f),(P)=>{if(A)A.destroy(),A=null;let W=P?M:_;if(W)A=e(()=>y(W)?W():W),L.insertBefore(A.container,E)}),r(()=>A?.destroy()),L},Kf=(f,M,_)=>{let E=I.createTextNode(""),L=k("div",{style:"display:contents"},[E]),A=new Map;return v(()=>(y(f)?f():f)||[],(P)=>{let W=new Map,J=[],Q=P||[];for(let T=0;TM(Y,T));else A.delete(K);W.set(K,G),J.push(G)}A.forEach((T)=>T.destroy());let X=E;for(let T=J.length-1;T>=0;T--){let K=J[T].container;if(K.nextSibling!==X)L.insertBefore(K,X);X=K}A=W}),L},g=(f)=>{let M=()=>window.location.hash.slice(1)||"/",_=d(M()),E=()=>_(M());window.addEventListener("hashchange",E),r(()=>window.removeEventListener("hashchange",E));let L=k("div",{class:"router-hook"}),A=null;return v([_],()=>{let P=_(),W=f.find((J)=>{let Q=J.path.split("/").filter(Boolean),X=P.split("/").filter(Boolean);return Q.length===X.length&&Q.every((T,Y)=>T[0]===":"||T===X[Y])})||f.find((J)=>J.path==="*");if(W){A?.destroy();let J={};W.path.split("/").filter(Boolean).forEach((Q,X)=>{if(Q[0]===":")J[Q.slice(1)]=P.split("/").filter(Boolean)[X]}),g.params(J),A=e(()=>y(W.component)?W.component(J):W.component),L.replaceChildren(A.container)}}),L};g.params=d({});g.to=(f)=>window.location.hash=f.replace(/^#?\/?/,"#/");g.back=()=>window.history.back();g.path=()=>window.location.hash.replace(/^#/,"")||"/";var Sf=(f,M)=>{let _=typeof M==="string"?I.querySelector(M):M;if(!_)return;if(Bf.has(_))Bf.get(_).destroy();let E=e(y(f)?f:()=>f);return _.replaceChildren(E.container),Bf.set(_,E),E},j_=Object.freeze({$:d,$$:y_,Watch:v,Tag:k,Render:e,If:Zf,For:Kf,Router:g,Mount:Sf,onMount:p_,onUnmount:r,Batch:r_});if(typeof window<"u")Object.assign(window,j_),"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((f)=>window[f[0].toUpperCase()+f.slice(1)]=(M,_)=>j_.Tag(f,M,_));var Ef={};R(Ef,{default:()=>s_,Tooltip:()=>O_,Toast:()=>D_,Timeline:()=>z_,Tabs:()=>q_,Table:()=>Y_,Swap:()=>K_,Stat:()=>X_,Stack:()=>B_,Select:()=>Q_,Rating:()=>P_,Range:()=>A_,Radio:()=>$_,Navbar:()=>M_,Modal:()=>f_,Menu:()=>af,List:()=>lf,Label:()=>of,Input:()=>n,Indicator:()=>df,Fileinput:()=>bf,Fieldset:()=>cf,Fab:()=>vf,Dropdown:()=>uf,Drawer:()=>yf,Datepicker:()=>jf,Colorpicker:()=>kf,Checkbox:()=>Vf,Button:()=>o,Badge:()=>Nf,Autocomplete:()=>hf,Alert:()=>qf,Accordion:()=>Yf});var Cf={};R(Cf,{Accordion:()=>Yf});var Mf={};R(Mf,{val:()=>B,ui:()=>Z,getIcon:()=>z});var B=(f)=>typeof f==="function"?f():f,Z=(f,M)=>typeof M==="function"?()=>`${f} ${M()||""}`.trim():`${f} ${M||""}`.trim(),z=(f)=>{if(!f)return null;if(typeof f==="function")return Tag("span",{class:"mr-1"},f());if(typeof f==="object")return Tag("span",{class:"mr-1"},f);if(typeof f==="string"){let M=f.trim().split(/\s+/),_=M[M.length-1]==="right",E=_?M.slice(0,-1).join(" "):f,L=_?"ml-1":"mr-1";if(E&&!E.startsWith("icon-[")&&!E.includes("--"))return Tag("span",{class:L},E);return Tag("span",{class:`${E} ${L}`.trim()})}return null};var Yf=(f,M)=>{let{class:_,title:E,name:L,open:A,...P}=f;return Tag("div",{...P,class:Z("collapse collapse-arrow bg-base-200 mb-2",_)},[Tag("input",{type:L?"radio":"checkbox",name:L,checked:B(A)}),Tag("div",{class:"collapse-title text-xl font-medium"},E),Tag("div",{class:"collapse-content"},M)])};var Rf={};R(Rf,{Alert:()=>qf});var qf=(f,M)=>{let{class:_,actions:E,type:L="info",soft:A=!0,...P}=f,W={info:"icon-[lucide--info]",success:"icon-[lucide--check-circle]",warning:"icon-[lucide--alert-triangle]",error:"icon-[lucide--alert-circle]"},X=[`alert-${L}`,A?"alert-soft":"",_].filter(Boolean).join(" "),T=M||f.message;return Tag("div",{...P,role:"alert",class:Z("alert",X)},()=>[z(W[L]),Tag("div",{class:"flex-1"},[Tag("span",{},[typeof T==="function"?T():T])]),E?Tag("div",{class:"flex-none"},[typeof E==="function"?E():E]):null].filter(Boolean))};var Df={};R(Df,{Autocomplete:()=>hf});var o_={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"}},i_=$("es");var x=(f)=>()=>o_[i_()][f]||f;var zf={};R(zf,{Input:()=>n});var n=(f)=>{let{class:M,value:_,type:E="text",icon:L,oninput:A,placeholder:P,disabled:W,validate:J,label:Q,...X}=f,T=E==="password",Y=$(!1),K=$(null),G={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]"},C=L?z(L):G[E]?z(G[E]):null,h=()=>z(Y()?"icon-[lucide--eye-off]":"icon-[lucide--eye]"),U=C?"pl-10":"",H=T?"pr-10":"",i=()=>{if(M?.includes("input-xs"))return"btn-xs";if(M?.includes("input-sm"))return"btn-sm";if(M?.includes("input-lg"))return"btn-lg";return"btn-md"},s=(D)=>{let c=D.target.value;if(J){let $f=J(c);K($f||null)}A?.(D)},F=()=>K()&&K()!=="",S=()=>{let D=`input w-full ${U} ${H}`;if(M)D+=` ${M}`;if(F())D+=" input-error";return D.trim()},q=Tag("input",{...X,type:()=>T?Y()?"text":"password":E,placeholder:P||(Q?" ":P),class:S,value:_,oninput:s,disabled:()=>B(W),"aria-invalid":()=>F()?"true":"false"}),N=()=>[q,C?Tag("div",{class:"absolute left-3 inset-y-0 flex items-center pointer-events-none text-base-content/60"},C):null,T?Tag("button",{type:"button",class:Z("absolute right-3 inset-y-0 flex items-center","btn btn-ghost btn-circle opacity-50 hover:opacity-100",i()),onclick:(D)=>{D.preventDefault(),Y(!Y())}},()=>h()):null,Tag("div",{class:"text-error text-xs mt-1 px-3 absolute -bottom-5 left-0"},()=>F()?K():null)];if(Q)return Tag("label",{class:Z("floating-label w-full",M)},()=>[Tag("div",{class:"relative w-full"},N),Tag("span",{},B(Q))]);return Tag("div",{class:"relative w-full"},N)};var hf=(f)=>{let{class:M,items:_=[],value:E,onselect:L,label:A,placeholder:P,...W}=f,J=$(B(E)||""),Q=$(!1),X=$(-1),T=$([]);Watch(()=>{let G=String(J()).toLowerCase(),C=B(_)||[],h=G?C.filter((U)=>(typeof U==="string"?U:U.label).toLowerCase().includes(G)):C;T(h)});let Y=(G)=>{let C=typeof G==="string"?G:G.value,h=typeof G==="string"?G:G.label;if(J(h),typeof E==="function")E(C);L?.(G),Q(!1),X(-1)},K=(G)=>{let C=T();if(G.key==="ArrowDown")G.preventDefault(),Q(!0),X(Math.min(X()+1,C.length-1));else if(G.key==="ArrowUp")G.preventDefault(),X(Math.max(X()-1,0));else if(G.key==="Enter"&&X()>=0)G.preventDefault(),Y(C[X()]);else if(G.key==="Escape")Q(!1)};return Tag("div",{class:"relative w-full"},[n({label:A,class:M,placeholder:P||x("search")(),value:J,onfocus:()=>Q(!0),onblur:()=>setTimeout(()=>Q(!1),150),onkeydown:K,oninput:(G)=>{let C=G.target.value;if(J(C),typeof E==="function")E(C);Q(!0),X(-1)},...W}),Tag("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:()=>Q()&&T().length?"display:block":"display:none"},[For(T,(G,C)=>Tag("li",{},[Tag("a",{class:()=>`block w-full ${X()===C?"active bg-primary text-primary-content":""}`,onclick:()=>Y(G),onmouseenter:()=>X(C)},typeof G==="string"?G:G.label)]),(G,C)=>(typeof G==="string"?G:G.value)+C),()=>T().length?null:Tag("li",{class:"p-2 text-center opacity-50"},x("nodata")())])])};var Of={};R(Of,{Badge:()=>Nf});var Nf=(f,M)=>{let{class:_,...E}=f;return Tag("span",{...E,class:Z("badge",_)},M)};var Uf={};R(Uf,{Button:()=>o});var o=(f,M)=>{let{class:_,loading:E,icon:L,...A}=f,P=z(L);return Tag("button",{...A,class:Z("btn",_),disabled:()=>B(E)||B(f.disabled)},()=>[B(E)&&Tag("span",{class:"loading loading-spinner"}),P,M].filter(Boolean))};var Ff={};R(Ff,{Checkbox:()=>Vf});var Vf=(f)=>{let{class:M,value:_,toggle:E,label:L,...A}=f,P=Tag("input",{...A,type:"checkbox",class:()=>Z(B(E)?"toggle":"checkbox",M),checked:_});return Tag("label",{class:"label cursor-pointer justify-start gap-3"},[P,L?Tag("span",{class:"label-text"},L):null])};var Hf={};R(Hf,{Colorpicker:()=>kf});var kf=(f)=>{let{class:M,value:_,label:E,...L}=f,A=$(!1),P=["#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"],W=()=>B(_)||"#000000";return Tag("div",{class:Z("relative w-fit",M)},[Tag("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:(J)=>{J.stopPropagation(),A(!A())},...L},[Tag("div",{class:"size-5 rounded-sm shadow-inner border border-black/10 shrink-0",style:()=>`background-color: ${W()}`}),E?Tag("span",{class:"opacity-80"},E):null]),If(A,()=>Tag("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:(J)=>J.stopPropagation()},[Tag("div",{class:"grid grid-cols-8 gap-1"},P.map((J)=>Tag("button",{type:"button",style:`background-color: ${J}`,class:()=>{return`size-6 rounded-sm cursor-pointer transition-all hover:scale-125 hover:z-10 active:scale-95 outline-none border border-black/5 + ${W().toLowerCase()===J.toLowerCase()?"ring-2 ring-offset-1 ring-primary z-10 scale-110":""}`},onclick:()=>{if(typeof _==="function")_(J);A(!1)}})))])),If(A,()=>Tag("div",{class:"fixed inset-0 z-[100]",onclick:()=>A(!1)}))])};var wf={};R(wf,{Datepicker:()=>jf});var jf=(f)=>{let{class:M,value:_,range:E,label:L,placeholder:A,hour:P=!1,...W}=f,J=$(!1),Q=$(new Date),X=$(null),T=$(0),Y=$(0),K=()=>B(E)===!0,G=new Date,C=`${G.getFullYear()}-${String(G.getMonth()+1).padStart(2,"0")}-${String(G.getDate()).padStart(2,"0")}`,h=(S)=>{let q=S.getFullYear(),N=String(S.getMonth()+1).padStart(2,"0"),D=String(S.getDate()).padStart(2,"0");return`${q}-${N}-${D}`},U=(S)=>{let q=h(S),N=B(_);if(K())if(!N?.start||N.start&&N.end){if(typeof _==="function")_({start:q,end:null,...P&&{startHour:T()}})}else{let D=N.start;if(typeof _==="function"){let c=q{let S=B(_);if(!S){H("");return}let q="";if(typeof S==="string")q=P&&S.includes("T")?S.replace("T"," "):S;else if(S.start&&S.end){let N=P&&S.startHour!==void 0?`${S.start} ${String(S.startHour).padStart(2,"0")}:00`:S.start,D=P&&S.endHour!==void 0?`${S.end} ${String(S.endHour).padStart(2,"0")}:00`:S.end;q=`${N} - ${D}`}else if(S.start)q=`${P&&S.startHour!==void 0?`${S.start} ${String(S.startHour).padStart(2,"0")}:00`:S.start}...`;H(q)});let i=(S)=>{let q=Q();Q(new Date(q.getFullYear(),q.getMonth()+S,1))},s=(S)=>{let q=Q();Q(new Date(q.getFullYear()+S,q.getMonth(),1))},F=({value:S,onChange:q})=>{return Tag("div",{class:"flex-1"},[Tag("div",{class:"flex gap-2 items-center"},[Tag("input",{type:"range",min:0,max:23,value:S,class:"range range-xs flex-1",oninput:(N)=>{let D=parseInt(N.target.value);q(D)}}),Tag("span",{class:"text-sm font-mono min-w-[48px] text-center"},()=>String(B(S)).padStart(2,"0")+":00")])])};return Tag("div",{class:Z("relative w-full",M)},[n({label:L,placeholder:A||(K()?"Seleccionar rango...":"Seleccionar fecha..."),value:H,readonly:!0,icon:z("icon-[lucide--calendar]"),onclick:(S)=>{S.stopPropagation(),J(!J())},...W}),If(J,()=>Tag("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:(S)=>S.stopPropagation()},[Tag("div",{class:"flex justify-between items-center mb-4 gap-1"},[Tag("div",{class:"flex gap-0.5"},[Tag("button",{type:"button",class:"btn btn-ghost btn-xs px-1",onclick:()=>s(-1)},z("icon-[lucide--chevrons-left]")),Tag("button",{type:"button",class:"btn btn-ghost btn-xs px-1",onclick:()=>i(-1)},z("icon-[lucide--chevron-left]"))]),Tag("span",{class:"font-bold uppercase flex-1 text-center"},[()=>Q().toLocaleString("es-ES",{month:"short",year:"numeric"})]),Tag("div",{class:"flex gap-0.5"},[Tag("button",{type:"button",class:"btn btn-ghost btn-xs px-1",onclick:()=>i(1)},z("icon-[lucide--chevron-right]")),Tag("button",{type:"button",class:"btn btn-ghost btn-xs px-1",onclick:()=>s(1)},z("icon-[lucide--chevrons-right]"))])]),Tag("div",{class:"grid grid-cols-7 gap-1",onmouseleave:()=>X(null)},[...["L","M","X","J","V","S","D"].map((S)=>Tag("div",{class:"text-[10px] opacity-40 font-bold text-center"},S)),()=>{let S=Q(),q=S.getFullYear(),N=S.getMonth(),D=new Date(q,N,1).getDay(),c=D===0?6:D-1,$f=new Date(q,N+1,0).getDate(),Lf=[];for(let p=0;p{let m=B(_),Af=X(),I_=typeof m==="string"?m.split("T")[0]===j:m?.start===j,u_=m?.end===j,Wf=!1;if(K()&&m?.start){let Pf=m.start;if(!m.end&&Af)Wf=j>Pf&&j<=Af||j=Af;else if(m.end)Wf=j>Pf&&j{if(K())X(j)},onclick:()=>U(V_)},[p.toString()]))}return Lf}]),P?Tag("div",{class:"mt-3 pt-2 border-t border-base-300"},[K()?Tag("div",{class:"flex gap-4"},[F({value:T,onChange:(S)=>{T(S);let q=B(_);if(q?.start)_({...q,startHour:S})}}),F({value:Y,onChange:(S)=>{Y(S);let q=B(_);if(q?.end)_({...q,endHour:S})}})]):F({value:T,onChange:(S)=>{T(S);let q=B(_);if(q&&typeof q==="string")_(q.split("T")[0]+"T"+String(S).padStart(2,"0")+":00:00")}})]):null])),If(J,()=>Tag("div",{class:"fixed inset-0 z-[90]",onclick:()=>J(!1)}))])};var xf={};R(xf,{Drawer:()=>yf});var yf=(f,M)=>{let{class:_,id:E,open:L,side:A,content:P,...W}=f,J=E||`drawer-${Math.random().toString(36).slice(2,9)}`;return Tag("div",{...W,class:Z("drawer",_)},[Tag("input",{id:J,type:"checkbox",class:"drawer-toggle",checked:()=>typeof L==="function"?L():L,onchange:(Q)=>{if(typeof L==="function")L(Q.target.checked)}}),Tag("div",{class:"drawer-content"},[typeof P==="function"?P():P]),Tag("div",{class:"drawer-side"},[Tag("label",{for:J,class:"drawer-overlay",onclick:()=>{if(typeof L==="function")L(!1)}}),Tag("div",{class:"min-h-full bg-base-200 w-80"},[typeof A==="function"?A():A])])])};var mf={};R(mf,{Dropdown:()=>uf});var u=null;if(typeof window<"u"&&!window.__dropdownHandlerRegistered)window.addEventListener("click",(f)=>{if(u&&!u.contains(f.target))u.open=!1,u=null}),window.__dropdownHandlerRegistered=!0;var uf=(f)=>{let{class:M,label:_,icon:E,items:L,...A}=f;return Tag("details",{...A,class:Z("dropdown",M)},[Tag("summary",{class:"btn m-1 flex items-center gap-2 list-none cursor-pointer",style:"display: inline-flex;",onclick:(P)=>{let W=P.currentTarget.closest("details");if(u&&u!==W)u.open=!1;setTimeout(()=>{u=W.open?W:null},0)}},[()=>E?typeof E==="function"?E():E:null,()=>_?typeof _==="function"?_():_:null]),Tag("ul",{tabindex:"-1",class:"dropdown-content z-[50] menu p-2 shadow bg-base-100 rounded-box w-52 border border-base-300"},[()=>{return(typeof L==="function"?L():L||[]).map((W)=>Tag("li",{},[Tag("a",{class:W.class||"",onclick:(J)=>{if(W.onclick)W.onclick(J);let Q=J.currentTarget.closest("details");if(Q){if(Q.open=!1,u===Q)u=null}}},[W.icon?Tag("span",{},W.icon):null,Tag("span",{},W.label)])]))}])])};var gf={};R(gf,{Fab:()=>vf});var vf=(f)=>{let{class:M,icon:_,label:E,actions:L=[],position:A="bottom-6 right-6",...P}=f;return Tag("div",{...P,class:Z(`fab absolute ${A} flex flex-col-reverse items-end gap-3 z-[100]`,M)},[Tag("div",{tabindex:0,role:"button",class:"btn btn-lg btn-circle btn-primary shadow-2xl"},[_?z(_):null,!_&&E?E:null]),...B(L).map((W)=>Tag("div",{class:"flex items-center gap-3 transition-all duration-300"},[W.label?Tag("span",{class:"badge badge-ghost shadow-sm whitespace-nowrap"},W.label):null,Tag("button",{type:"button",class:`btn btn-circle shadow-lg ${W.class||""}`,onclick:(J)=>{J.stopPropagation(),W.onclick?.(J)}},[W.icon?z(W.icon):W.text||""])]))])};var pf={};R(pf,{Fieldset:()=>cf});var cf=(f,M)=>{let{class:_,legend:E,...L}=f;return Tag("fieldset",{...L,class:Z("fieldset bg-base-200 border border-base-300 p-4 rounded-lg",_)},[()=>{let A=B(E);return A?Tag("legend",{class:"fieldset-legend font-bold"},[A]):null},M])};var rf={};R(rf,{Fileinput:()=>bf});var bf=(f)=>{let{class:M,tooltip:_,max:E=2,accept:L="*",onselect:A,...P}=f,W=$([]),J=$(!1),Q=$(null),X=E*1024*1024,T=(K)=>{let G=Array.from(K);if(Q(null),G.find((h)=>h.size>X)){Q(`Máx ${E}MB`);return}W([...W(),...G]),A?.(W())},Y=(K)=>{let G=W().filter((C,h)=>h!==K);W(G),A?.(G)};return Tag("fieldset",{...P,class:Z("fieldset w-full p-0",M)},[Tag("div",{class:()=>`w-full ${_?"tooltip tooltip-top before:z-50 after:z-50":""}`,"data-tip":_},[Tag("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 - ${P()?"border-primary bg-primary/10":"border-base-content/20 bg-base-100 hover:bg-base-200"} - `,ondragover:(K)=>{K.preventDefault(),P(!0)},ondragleave:()=>P(!1),ondrop:(K)=>{K.preventDefault(),P(!1),Q(K.dataTransfer.files)}},[Tag("div",{class:"flex items-center gap-3 w-full"},[h("icon-[lucide--upload]"),Tag("span",{class:"text-sm opacity-70 truncate grow text-left"},"Arrastra o selecciona archivos..."),Tag("span",{class:"text-[10px] opacity-40 shrink-0"},`Máx ${E}MB`)]),Tag("input",{type:"file",multiple:!0,accept:A,class:"hidden",onchange:(K)=>Q(K.target.files)})])]),()=>J()?Tag("span",{class:"text-[10px] text-error mt-1 px-1 font-medium"},J()):null,If(()=>T().length>0,()=>Tag("ul",{class:"mt-2 space-y-1"},[For(T,(K,X)=>Tag("li",{class:"flex items-center justify-between p-1.5 pl-3 text-xs bg-base-200/50 rounded-md border border-base-300"},[Tag("div",{class:"flex items-center gap-2 truncate"},[Tag("span",{class:"opacity-50"},"\uD83D\uDCC4"),Tag("span",{class:"truncate font-medium max-w-[200px]"},K.name),Tag("span",{class:"text-[9px] opacity-40"},`(${(K.size/1024).toFixed(0)} KB)`)]),Tag("button",{type:"button",class:"btn btn-ghost btn-xs btn-circle",onclick:(Y)=>{Y.preventDefault(),Y.stopPropagation(),C(X)}},[h("icon-[lucide--x]")])]),(K)=>K.name+K.lastModified)]))])};var df={};q(df,{Indicator:()=>bf});var bf=(f,M)=>{let{value:_,class:E,...A}=f;return Tag("div",{...A,class:"indicator"},()=>[_?Tag("span",{class:Z("indicator-item badge",E)},()=>typeof _==="function"?_():_):null,M].filter(Boolean))};var of={};q(of,{Label:()=>nf});var nf=(f)=>{let{children:M,value:_,floating:E=!1,class:A,...L}=f;if(E)return Tag("label",{class:Z("floating-label",A),...L},()=>[typeof M==="function"?M():M,_?Tag("span",{},G(_)):null]);return Tag("label",{class:Z("label",A),...L},()=>[_?Tag("span",{class:"label-text"},G(_)):null,typeof M==="function"?M():M])};var tf={};q(tf,{List:()=>sf});var sf=(f)=>{let{class:M,items:_,header:E,render:A=(P)=>P,keyFn:L=(P,J)=>P.id??J,...W}=f,T=For(_,(P,J)=>Tag("li",{class:"list-row",style:"width: 100%; display: block;"},[Tag("div",{style:"width: 100%;"},[A(P,J)])]),L);return Tag("ul",{...W,style:"display: block; width: 100%;",class:Z("list bg-base-100 rounded-box shadow-md",M)},E?[If(E,()=>Tag("li",{class:"p-4 pb-2 text-xs opacity-60",style:"width: 100%;"},[G(E)])),T]:T)};var af={};q(af,{Menu:()=>lf});var lf=(f)=>{let{class:M,items:_,...E}=f,A=(L)=>For(()=>L||[],(W)=>Tag("li",{},[W.children?Tag("details",{open:W.open},[Tag("summary",{},[W.icon&&Tag("span",{class:"mr-2"},W.icon),W.label]),Tag("ul",{},A(W.children))]):Tag("a",{class:()=>G(W.active)?"active":"",onclick:W.onclick},[W.icon&&Tag("span",{class:"mr-2"},W.icon),W.label])]),(W,T)=>W.label||T);return Tag("ul",{...E,class:Z("menu bg-base-200 rounded-box",M)},A(_))};var f_={};q(f_,{Modal:()=>ef});var ef=(f,M)=>{let{class:_,title:E,buttons:A,open:L,...W}=f,T=null,P=()=>{let B=typeof L==="function"?L():L;if(!T)return;if(B){if(!T.open)T.showModal()}else if(T.open)T.close()};Watch(()=>P());let J=()=>{if(typeof L==="function")L(!1)};return Tag("dialog",{...W,ref:(B)=>{if(T=B,B)P()},class:Z("modal",_),onclose:J,oncancel:J},[Tag("div",{class:"modal-box"},[E?Tag("h3",{class:"text-lg font-bold mb-4"},()=>typeof E==="function"?E():E):null,Tag("div",{class:"py-2"},[typeof M==="function"?M():M]),Tag("div",{class:"modal-action"},[Tag("form",{method:"dialog",class:"flex gap-2"},[...(Array.isArray(A)?A:[A]).filter(Boolean),o({type:"submit"},x("close")())])])]),Tag("form",{method:"dialog",class:"modal-backdrop"},[Tag("button",{},"close")])])};var M_={};q(M_,{Navbar:()=>__});var __=(f,M)=>{let{class:_,...E}=f;return Tag("div",{...E,class:Z("navbar bg-base-100 shadow-sm px-4",_)},M)};var L_={};q(L_,{Radio:()=>E_});var E_=(f)=>{let{class:M,label:_,tooltip:E,value:A,inputValue:L,name:W,...T}=f,P=Tag("input",{...T,type:"radio",name:W,class:Z("radio",M),checked:()=>G(A)===L,onclick:()=>{if(typeof A==="function")A(L)}});if(!_&&!E)return P;let J=Tag("label",{class:"label cursor-pointer justify-start gap-3"},[P,_?Tag("span",{class:"label-text"},_):null]);return E?Tag("div",{class:"tooltip","data-tip":E},J):J};var A_={};q(A_,{Range:()=>$_});var $_=(f)=>{let{class:M,label:_,tooltip:E,value:A,...L}=f,W=Tag("input",{...L,type:"range",class:Z("range",M),value:A,disabled:()=>G(f.disabled)});if(!_&&!E)return W;let T=Tag("div",{class:"flex flex-col gap-2"},[_?Tag("span",{class:"label-text"},_):null,W]);return E?Tag("div",{class:"tooltip","data-tip":E},T):T};var W_={};q(W_,{Rating:()=>T_});var T_=(f)=>{let{class:M,value:_,count:E=5,mask:A="mask-star",readonly:L=!1,onchange:W,...T}=f,P=`rating-${Math.random().toString(36).slice(2,7)}`;return Tag("div",{...T,class:()=>Z(`rating ${G(L)?"pointer-events-none":""}`,M)},Array.from({length:G(E)},(J,B)=>{let Q=B+1;return Tag("input",{type:"radio",name:P,class:`mask ${A}`,checked:()=>Math.round(G(_))===Q,onchange:()=>{if(!G(L)){if(typeof W==="function")W(Q);else if(typeof _==="function")_(Q)}}})}))};var J_={};q(J_,{Select:()=>P_});var P_=(f)=>{let{class:M,label:_,items:E,value:A,...L}=f,W=Tag("select",{...L,class:Z("select select-bordered w-full",M),value:A},For(()=>G(E)||[],(T)=>Tag("option",{value:T.value,$selected:()=>String(G(A))===String(T.value)},T.label),(T)=>T.value));if(!_)return W;return Tag("label",{class:"fieldset-label flex flex-col gap-1"},[Tag("span",{},_),W])};var B_={};q(B_,{Stack:()=>Q_});var Q_=(f,M)=>{let{class:_,...E}=f;return Tag("div",{...E,class:Z("stack",_)},M)};var X_={};q(X_,{Stat:()=>G_});var G_=(f)=>{let{class:M,icon:_,label:E,value:A,desc:L,...W}=f;return Tag("div",{...W,class:Z("stat",M)},[_&&Tag("div",{class:"stat-figure text-secondary"},_),E&&Tag("div",{class:"stat-title"},E),Tag("div",{class:"stat-value"},()=>G(A)??A),L&&Tag("div",{class:"stat-desc"},L)])};var K_={};q(K_,{Swap:()=>Z_});var Z_=(f)=>{let{class:M,value:_,on:E,off:A,...L}=f;return Tag("label",{...L,class:Z("swap",M)},[Tag("input",{type:"checkbox",checked:()=>G(_),onclick:(W)=>{if(typeof _==="function")_(W.target.checked)}}),Tag("div",{class:"swap-on"},E),Tag("div",{class:"swap-off"},A)])};var C_={};q(C_,{Table:()=>S_});var S_=(f)=>{let{class:M,items:_=[],columns:E=[],keyFn:A,zebra:L=!1,pinRows:W=!1,empty:T=x("nodata")(),...P}=f,J=()=>{let Q=G(L)?"table-zebra":"",C=G(W)?"table-pin-rows":"";return Z("table",M,Q,C)},B=A||((Q,C)=>Q.id||C);return Tag("div",{class:"overflow-x-auto w-full bg-base-100 rounded-box border border-base-300"},[Tag("table",{...P,class:J},[Tag("thead",{},[Tag("tr",{},E.map((Q)=>Tag("th",{class:Q.class||""},Q.label)))]),Tag("tbody",{},[For(_,(Q,C)=>{let K=()=>{let X=G(_),Y=B(Q,C);return X.find((z,V)=>B(z,V)===Y)||Q};return Tag("tr",{class:"hover"},E.map((X)=>{let Y=()=>{let z=K();if(X.render)return X.render(z,C);return G(z[X.key])};return Tag("td",{class:X.class||""},[Y])}))},B),If(()=>G(_).length===0,()=>Tag("tr",{},[Tag("td",{colspan:E.length,class:"text-center p-10 opacity-50"},[G(T)])]))])])])};var R_={};q(R_,{Tabs:()=>Y_});var Y_=(f)=>{let{items:M,class:_,onTabClose:E,...A}=f,L=typeof M==="function"?M:()=>M||[],W=d(0);v(()=>{let J=L().findIndex((B)=>G(B.active)===!0);if(J!==-1&&W()!==J)W(J)});let T=(P,J)=>{if(J.onClose)J.onClose(J);if(E)E(J,P);let Q=L().filter((X,Y)=>Y!==P);if(!(typeof M==="function"&&!M._isComputed)){console.warn("Tabs: items must be a writable signal to support closable tabs");return}if(M(Q),Q.length===0)return;let K=W();if(P{let P=L(),J=[];for(let B=0;B{R.stopPropagation(),T(B,Q)};let S=F("span",{class:"flex items-center"},[K,H]);X.push(S)}else X.push(K);let Y=F("button",{class:()=>Z("tab",W()===B?"tab-active":""),onclick:(H)=>{if(H.preventDefault(),!G(Q.disabled)){if(Q.onclick)Q.onclick();W(B)}}},X),z=Q.tip?F("div",{class:"tooltip","data-tip":Q.tip},Y):Y;J.push(z);let V,k=G(Q.content);if(typeof k==="function")V=k();else if(k instanceof Node)V=k;else V=document.createTextNode(String(k));let i=F("div",{class:"tab-content-inner"},V),s=F("div",{class:"tab-content bg-base-100 border-base-300 p-6",style:()=>W()===B?"display: block":"display: none"},i);J.push(s)}return J})};var h_={};q(h_,{Timeline:()=>q_});var q_=(f)=>{let{class:M,items:_=[],vertical:E=!0,compact:A=!1,...L}=f,W={info:"icon-[lucide--info]",success:"icon-[lucide--check-circle]",warning:"icon-[lucide--alert-triangle]",error:"icon-[lucide--alert-circle]"};return Tag("ul",{...L,class:()=>Z(`timeline ${G(E)?"timeline-vertical":"timeline-horizontal"} ${G(A)?"timeline-compact":""}`,M)},()=>{let T=(typeof _==="function"?_():_)||[];return T.map((P,J)=>{let B=J===0,Q=J===T.length-1,C=P.type||"success",K=()=>G(P.completed),X=()=>J>0&&G(T[J-1].completed),Y=(z)=>typeof z==="function"?z():z;return Tag("li",{class:"flex-1"},[!B?Tag("hr",{class:()=>X()?"bg-primary":""}):null,Tag("div",{class:"timeline-start"},[()=>Y(P.title)]),Tag("div",{class:"timeline-middle"},[()=>P.icon?h(P.icon):h(W[C]||W.success)]),Tag("div",{class:"timeline-end timeline-box shadow-sm"},[()=>Y(P.detail)]),!Q?Tag("hr",{class:()=>K()?"bg-primary":""}):null])})})};var D_={};q(D_,{Toast:()=>z_});var z_=(f,M="alert-success",_=3500)=>{let E=document.getElementById("sigpro-toast-container");if(!E)E=Tag("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(E);let A=Tag("div",{style:"display: contents"});E.appendChild(A);let L,W=()=>{clearTimeout(L);let J=A.firstElementChild;if(J&&!J.classList.contains("opacity-0"))J.classList.add("translate-x-full","opacity-0"),setTimeout(()=>{if(P.destroy(),A.remove(),!E.hasChildNodes())E.remove()},300);else P.destroy(),A.remove()},T=()=>{let J=h("icon-[lucide--x]"),B=Tag("div",{class:`alert alert-soft ${M} shadow-lg transition-all duration-300 translate-x-10 opacity-0 pointer-events-auto`},[Tag("span",{},[typeof f==="function"?f():f]),o({class:"btn-xs btn-circle btn-ghost",onclick:W},J)]);return requestAnimationFrame(()=>B.classList.remove("translate-x-10","opacity-0")),B},P=Mount(T,A);if(_>0)L=setTimeout(W,_);return W};var O_={};q(O_,{Tooltip:()=>N_});var N_=(f,M)=>Tag("div",{...f,class:()=>Z("tooltip w-full",f.class),"data-tip":f.tip},M);var x_={...Cf,...Rf,...zf,...Nf,...Of,...Uf,...Hf,...wf,...yf,...uf,...vf,...cf,...rf,...df,...qf,...of,...tf,...af,...f_,...M_,...L_,...A_,...W_,...J_,...B_,...X_,...K_,...C_,...R_,...h_,...D_,...O_},t_={...x_,install:(f=window)=>{Object.entries(x_).forEach(([M,_])=>{f[M]=_}),console.log("\uD83D\uDE80 SigproUI")}};if(typeof window<"u")Object.entries(Ef).forEach(([f,M])=>{Object.defineProperty(window,f,{value:M,writable:!1,configurable:!0,enumerable:!0})}),Object.entries(Mf).forEach(([f,M])=>{Object.defineProperty(window,f,{value:M,writable:!1,configurable:!0,enumerable:!0})}),Object.defineProperty(window,"tt",{value:x,writable:!1,configurable:!0,enumerable:!0}),Object.defineProperty(window,"SigProUI",{value:{...Ef,Utils:Mf,tt:x},writable:!1,configurable:!0,enumerable:!0}),console.log("\uD83C\uDFA8 SigProUI ready");})(); + ${J()?"border-primary bg-primary/10":"border-base-content/20 bg-base-100 hover:bg-base-200"} + `,ondragover:(K)=>{K.preventDefault(),J(!0)},ondragleave:()=>J(!1),ondrop:(K)=>{K.preventDefault(),J(!1),T(K.dataTransfer.files)}},[Tag("div",{class:"flex items-center gap-3 w-full"},[z("icon-[lucide--upload]"),Tag("span",{class:"text-sm opacity-70 truncate grow text-left"},"Arrastra o selecciona archivos..."),Tag("span",{class:"text-[10px] opacity-40 shrink-0"},`Máx ${E}MB`)]),Tag("input",{type:"file",multiple:!0,accept:L,class:"hidden",onchange:(K)=>T(K.target.files)})])]),()=>Q()?Tag("span",{class:"text-[10px] text-error mt-1 px-1 font-medium"},Q()):null,If(()=>W().length>0,()=>Tag("ul",{class:"mt-2 space-y-1"},[For(W,(K,G)=>Tag("li",{class:"flex items-center justify-between p-1.5 pl-3 text-xs bg-base-200/50 rounded-md border border-base-300"},[Tag("div",{class:"flex items-center gap-2 truncate"},[Tag("span",{class:"opacity-50"},"\uD83D\uDCC4"),Tag("span",{class:"truncate font-medium max-w-[200px]"},K.name),Tag("span",{class:"text-[9px] opacity-40"},`(${(K.size/1024).toFixed(0)} KB)`)]),Tag("button",{type:"button",class:"btn btn-ghost btn-xs btn-circle",onclick:(C)=>{C.preventDefault(),C.stopPropagation(),Y(G)}},[z("icon-[lucide--x]")])]),(K)=>K.name+K.lastModified)]))])};var nf={};R(nf,{Indicator:()=>df});var df=(f,M)=>{let{value:_,class:E,...L}=f;return Tag("div",{...L,class:"indicator"},()=>[_?Tag("span",{class:Z("indicator-item badge",E)},()=>typeof _==="function"?_():_):null,M].filter(Boolean))};var sf={};R(sf,{Label:()=>of});var of=(f)=>{let{children:M,value:_,floating:E=!1,class:L,...A}=f;if(E)return Tag("label",{class:Z("floating-label",L),...A},()=>[typeof M==="function"?M():M,_?Tag("span",{},B(_)):null]);return Tag("label",{class:Z("label",L),...A},()=>[_?Tag("span",{class:"label-text"},B(_)):null,typeof M==="function"?M():M])};var tf={};R(tf,{List:()=>lf});var lf=(f)=>{let{class:M,items:_,header:E,render:L=(J)=>J,keyFn:A=(J,Q)=>J.id??Q,...P}=f,W=For(_,(J,Q)=>Tag("li",{class:"list-row",style:"width: 100%; display: block;"},[Tag("div",{style:"width: 100%;"},[L(J,Q)])]),A);return Tag("ul",{...P,style:"display: block; width: 100%;",class:Z("list bg-base-100 rounded-box shadow-md",M)},E?[If(E,()=>Tag("li",{class:"p-4 pb-2 text-xs opacity-60",style:"width: 100%;"},[B(E)])),W]:W)};var ef={};R(ef,{Menu:()=>af});var af=(f)=>{let{class:M,items:_,...E}=f,L=(A)=>For(()=>A||[],(P)=>Tag("li",{},[P.children?Tag("details",{open:P.open},[Tag("summary",{},[P.icon&&Tag("span",{class:"mr-2"},P.icon),P.label]),Tag("ul",{},L(P.children))]):Tag("a",{class:()=>B(P.active)?"active":"",onclick:P.onclick},[P.icon&&Tag("span",{class:"mr-2"},P.icon),P.label])]),(P,W)=>P.label||W);return Tag("ul",{...E,class:Z("menu bg-base-200 rounded-box",M)},L(_))};var __={};R(__,{Modal:()=>f_});var f_=(f,M)=>{let{class:_,title:E,buttons:L,open:A,...P}=f,W=null,J=()=>{let X=typeof A==="function"?A():A;if(!W)return;if(X){if(!W.open)W.showModal()}else if(W.open)W.close()};Watch(()=>J());let Q=()=>{if(typeof A==="function")A(!1)};return Tag("dialog",{...P,ref:(X)=>{if(W=X,X)J()},class:Z("modal",_),onclose:Q,oncancel:Q},[Tag("div",{class:"modal-box"},[E?Tag("h3",{class:"text-lg font-bold mb-4"},()=>typeof E==="function"?E():E):null,Tag("div",{class:"py-2"},[typeof M==="function"?M():M]),Tag("div",{class:"modal-action"},[Tag("form",{method:"dialog",class:"flex gap-2"},[...(Array.isArray(L)?L:[L]).filter(Boolean),o({type:"submit"},x("close")())])])]),Tag("form",{method:"dialog",class:"modal-backdrop"},[Tag("button",{},"close")])])};var E_={};R(E_,{Navbar:()=>M_});var M_=(f,M)=>{let{class:_,...E}=f;return Tag("div",{...E,class:Z("navbar bg-base-100 shadow-sm px-4",_)},M)};var L_={};R(L_,{Radio:()=>$_});var $_=(f)=>{let{class:M,label:_,tooltip:E,value:L,inputValue:A,name:P,...W}=f,J=Tag("input",{...W,type:"radio",name:P,class:Z("radio",M),checked:()=>B(L)===A,onclick:()=>{if(typeof L==="function")L(A)}});if(!_&&!E)return J;let Q=Tag("label",{class:"label cursor-pointer justify-start gap-3"},[J,_?Tag("span",{class:"label-text"},_):null]);return E?Tag("div",{class:"tooltip","data-tip":E},Q):Q};var W_={};R(W_,{Range:()=>A_});var A_=(f)=>{let{class:M,label:_,tooltip:E,value:L,...A}=f,P=Tag("input",{...A,type:"range",class:Z("range",M),value:L,disabled:()=>B(f.disabled)});if(!_&&!E)return P;let W=Tag("div",{class:"flex flex-col gap-2"},[_?Tag("span",{class:"label-text"},_):null,P]);return E?Tag("div",{class:"tooltip","data-tip":E},W):W};var J_={};R(J_,{Rating:()=>P_});var P_=(f)=>{let{class:M,value:_,count:E=5,mask:L="mask-star",readonly:A=!1,onchange:P,...W}=f,J=`rating-${Math.random().toString(36).slice(2,7)}`;return Tag("div",{...W,class:()=>Z(`rating ${B(A)?"pointer-events-none":""}`,M)},Array.from({length:B(E)},(Q,X)=>{let T=X+1;return Tag("input",{type:"radio",name:J,class:`mask ${L}`,checked:()=>Math.round(B(_))===T,onchange:()=>{if(!B(A)){if(typeof P==="function")P(T);else if(typeof _==="function")_(T)}}})}))};var T_={};R(T_,{Select:()=>Q_});var Q_=(f)=>{let{class:M,label:_,items:E,value:L,...A}=f,P=Tag("select",{...A,class:Z("select select-bordered w-full",M),value:L},For(()=>B(E)||[],(W)=>Tag("option",{value:W.value,$selected:()=>String(B(L))===String(W.value)},W.label),(W)=>W.value));if(!_)return P;return Tag("label",{class:"fieldset-label flex flex-col gap-1"},[Tag("span",{},_),P])};var G_={};R(G_,{Stack:()=>B_});var B_=(f,M)=>{let{class:_,...E}=f;return Tag("div",{...E,class:Z("stack",_)},M)};var Z_={};R(Z_,{Stat:()=>X_});var X_=(f)=>{let{class:M,icon:_,label:E,value:L,desc:A,...P}=f;return Tag("div",{...P,class:Z("stat",M)},[_&&Tag("div",{class:"stat-figure text-secondary"},_),E&&Tag("div",{class:"stat-title"},E),Tag("div",{class:"stat-value"},()=>B(L)??L),A&&Tag("div",{class:"stat-desc"},A)])};var S_={};R(S_,{Swap:()=>K_});var K_=(f)=>{let{class:M,value:_,on:E,off:L,...A}=f;return Tag("label",{...A,class:Z("swap",M)},[Tag("input",{type:"checkbox",checked:()=>B(_),onclick:(P)=>{if(typeof _==="function")_(P.target.checked)}}),Tag("div",{class:"swap-on"},E),Tag("div",{class:"swap-off"},L)])};var C_={};R(C_,{Table:()=>Y_});var Y_=(f)=>{let{class:M,items:_=[],columns:E=[],keyFn:L,zebra:A=!1,pinRows:P=!1,empty:W=x("nodata")(),...J}=f,Q=()=>{let T=B(A)?"table-zebra":"",Y=B(P)?"table-pin-rows":"";return Z("table",M,T,Y)},X=L||((T,Y)=>T.id||Y);return Tag("div",{class:"overflow-x-auto w-full bg-base-100 rounded-box border border-base-300"},[Tag("table",{...J,class:Q},[Tag("thead",{},[Tag("tr",{},E.map((T)=>Tag("th",{class:T.class||""},T.label)))]),Tag("tbody",{},[For(_,(T,Y)=>{let K=()=>{let G=B(_),C=X(T,Y);return G.find((h,U)=>X(h,U)===C)||T};return Tag("tr",{class:"hover"},E.map((G)=>{let C=()=>{let h=K();if(G.render)return G.render(h,Y);return B(h[G.key])};return Tag("td",{class:G.class||""},[C])}))},X),If(()=>B(_).length===0,()=>Tag("tr",{},[Tag("td",{colspan:E.length,class:"text-center p-10 opacity-50"},[B(W)])]))])])])};var R_={};R(R_,{Tabs:()=>q_});var q_=(f)=>{let{items:M,class:_,onTabClose:E,...L}=f,A=typeof M==="function"?M:()=>M||[],P=d(0);v(()=>{let Q=A().findIndex((X)=>B(X.active)===!0);if(Q!==-1&&P()!==Q)P(Q)});let W=(J,Q)=>{if(Q.onClose)Q.onClose(Q);if(E)E(Q,J);let T=A().filter((G,C)=>C!==J);if(!(typeof M==="function"&&!M._isComputed)){console.warn("Tabs: items must be a writable signal to support closable tabs");return}if(M(T),T.length===0)return;let K=P();if(J{let J=A(),Q=[];for(let X=0;X{q.stopPropagation(),W(X,T)};let S=k("span",{class:"flex items-center"},[K,F]);G.push(S)}else G.push(K);let C=k("button",{class:()=>Z("tab",P()===X?"tab-active":""),onclick:(F)=>{if(F.preventDefault(),!B(T.disabled)){if(T.onclick)T.onclick();P(X)}}},G),h=T.tip?k("div",{class:"tooltip","data-tip":T.tip},C):C;Q.push(h);let U,H=B(T.content);if(typeof H==="function")U=H();else if(H instanceof Node)U=H;else U=document.createTextNode(String(H));let i=k("div",{class:"tab-content-inner"},U),s=k("div",{class:"tab-content bg-base-100 border-base-300 p-6",style:()=>P()===X?"display: block":"display: none"},i);Q.push(s)}return Q})};var h_={};R(h_,{Timeline:()=>z_});var z_=(f)=>{let{class:M,items:_=[],vertical:E=!0,compact:L=!1,...A}=f,P={info:"icon-[lucide--info]",success:"icon-[lucide--check-circle]",warning:"icon-[lucide--alert-triangle]",error:"icon-[lucide--alert-circle]"};return Tag("ul",{...A,class:()=>Z(`timeline ${B(E)?"timeline-vertical":"timeline-horizontal"} ${B(L)?"timeline-compact":""}`,M)},()=>{let W=(typeof _==="function"?_():_)||[];return W.map((J,Q)=>{let X=Q===0,T=Q===W.length-1,Y=J.type||"success",K=()=>B(J.completed),G=()=>Q>0&&B(W[Q-1].completed),C=(h)=>typeof h==="function"?h():h;return Tag("li",{class:"flex-1"},[!X?Tag("hr",{class:()=>G()?"bg-primary":""}):null,Tag("div",{class:"timeline-start"},[()=>C(J.title)]),Tag("div",{class:"timeline-middle"},[()=>J.icon?z(J.icon):z(P[Y]||P.success)]),Tag("div",{class:"timeline-end timeline-box shadow-sm"},[()=>C(J.detail)]),!T?Tag("hr",{class:()=>K()?"bg-primary":""}):null])})})};var N_={};R(N_,{Toast:()=>D_});var D_=(f,M="alert-success",_=3500)=>{let E=document.getElementById("sigpro-toast-container");if(!E)E=Tag("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(E);let L=Tag("div",{style:"display: contents"});E.appendChild(L);let A,P=()=>{clearTimeout(A);let Q=L.firstElementChild;if(Q&&!Q.classList.contains("opacity-0"))Q.classList.add("translate-x-full","opacity-0"),setTimeout(()=>{if(J.destroy(),L.remove(),!E.hasChildNodes())E.remove()},300);else J.destroy(),L.remove()},W=()=>{let Q=z("icon-[lucide--x]"),X=Tag("div",{class:`alert alert-soft ${M} shadow-lg transition-all duration-300 translate-x-10 opacity-0 pointer-events-auto`},[Tag("span",{},[typeof f==="function"?f():f]),o({class:"btn-xs btn-circle btn-ghost",onclick:P},Q)]);return requestAnimationFrame(()=>X.classList.remove("translate-x-10","opacity-0")),X},J=Mount(W,L);if(_>0)A=setTimeout(P,_);return P};var U_={};R(U_,{Tooltip:()=>O_});var O_=(f,M)=>Tag("div",{...f,class:()=>Z("tooltip w-full",f.class),"data-tip":f.tip},M);var x_={...Cf,...Rf,...Df,...Of,...Uf,...Ff,...Hf,...wf,...xf,...mf,...gf,...pf,...rf,...nf,...zf,...sf,...tf,...ef,...__,...E_,...L_,...W_,...J_,...T_,...G_,...Z_,...S_,...C_,...R_,...h_,...N_,...U_},s_={...x_,install:(f=window)=>{Object.entries(x_).forEach(([M,_])=>{f[M]=_}),console.log("\uD83D\uDE80 SigproUI")}};if(typeof window<"u")Object.entries(Ef).forEach(([f,M])=>{Object.defineProperty(window,f,{value:M,writable:!1,configurable:!0,enumerable:!0})}),Object.entries(Mf).forEach(([f,M])=>{Object.defineProperty(window,f,{value:M,writable:!1,configurable:!0,enumerable:!0})}),Object.defineProperty(window,"tt",{value:x,writable:!1,configurable:!0,enumerable:!0}),Object.defineProperty(window,"SigProUI",{value:{...Ef,Utils:Mf,tt:x},writable:!1,configurable:!0,enumerable:!0}),console.log("\uD83C\uDFA8 SigProUI ready");})(); diff --git a/docs/sigpro-ui.min.js b/docs/sigpro-ui.min.js index 80e8e73..492b668 100644 --- a/docs/sigpro-ui.min.js +++ b/docs/sigpro-ui.min.js @@ -185,11 +185,11 @@ if (!trigger && activeEffect && !activeEffect._disposed) { subs.add(activeEffect); (activeEffect._deps ||= new Set).add(subs); - } else if (trigger && subs.size > 0) { + } else if (trigger) { let hasQueue = false; - for (const e of subs) { + subs.forEach((e) => { if (e === activeEffect || e._disposed) - continue; + return; if (e._isComputed) { e._dirty = true; if (e._subs) @@ -198,7 +198,7 @@ effectQueue.add(e); hasQueue = true; } - } + }); if (hasQueue && !isFlushing && batchDepth === 0) queueMicrotask(flush); } @@ -266,9 +266,8 @@ var $$ = (target) => { if (!isObj(target)) return target; - let proxy = proxyCache.get(target); - if (proxy) - return proxy; + if (proxyCache.has(target)) + return proxyCache.get(target); const subsMap = new Map; const getSubs = (k) => { let s = subsMap.get(k); @@ -276,30 +275,28 @@ subsMap.set(k, s = new Set); return s; }; - proxy = new Proxy(target, { - get(t, k, receiver) { - if (typeof k !== "symbol") - trackUpdate(getSubs(k)); - return $$(Reflect.get(t, k, receiver)); + const proxy = new Proxy(target, { + get(t, k) { + trackUpdate(getSubs(k)); + return $$(t[k]); }, - set(t, k, v, receiver) { - const isNew = !Reflect.has(t, k); - const oldV = Reflect.get(t, k, receiver); - const result = Reflect.set(t, k, v, receiver); - if (result && !Object.is(oldV, v)) { + set(t, k, v) { + const isNew = !(k in t); + if (!Object.is(t[k], v)) { + t[k] = v; trackUpdate(getSubs(k), true); if (isNew) trackUpdate(getSubs(ITER), true); } - return result; + return true; }, deleteProperty(t, k) { - const result = Reflect.deleteProperty(t, k); - if (result) { + const res = Reflect.deleteProperty(t, k); + if (res) { trackUpdate(getSubs(k), true); trackUpdate(getSubs(ITER), true); } - return result; + return res; }, ownKeys(t) { trackUpdate(getSubs(ITER)); @@ -586,35 +583,6 @@ Router.to = (p) => window.location.hash = p.replace(/^#?\/?/, "#/"); Router.back = () => window.history.back(); Router.path = () => window.location.hash.replace(/^#/, "") || "/"; - var Anim = (show, render, { enter, leave } = {}) => { - const wrap = Tag2("div", { style: "display:contents" }); - let view = null; - const wait = (el, cb) => { - let done = false; - const finish = () => !done && (done = true, cb()); - if (!el) - return finish(); - "transitionend animationend".split(" ").map((e) => el.addEventListener(e, finish, { once: true })); - setTimeout(finish, 500); - }; - Watch2(show, (on) => { - if (on && !view) { - const el = (view = Render(render)).container.firstChild; - wrap.appendChild(view.container); - if (enter && el) { - el.classList.add(enter); - el.clientTop; - el.classList.add(enter + "-active"); - wait(el, () => el.classList.remove(enter, enter + "-active")); - } - } else if (!on && view) { - const el = view.container.firstChild; - const del = () => (view?.destroy(), view = null); - leave && el ? (el.classList.add(leave), wait(el, del)) : del(); - } - }); - return onUnmount(() => view?.destroy()), wrap; - }; var Mount2 = (comp, target) => { const t = typeof target === "string" ? doc.querySelector(target) : target; if (!t) @@ -626,7 +594,7 @@ MOUNTED_NODES.set(t, inst); return inst; }; - var SigPro = Object.freeze({ $: $2, $$, Watch: Watch2, Tag: Tag2, Render, If: If2, For: For2, Router, Mount: Mount2, onMount, onUnmount, Anim, Batch }); + var SigPro = Object.freeze({ $: $2, $$, Watch: Watch2, Tag: Tag2, Render, If: If2, For: For2, Router, Mount: Mount2, onMount, onUnmount, Batch }); if (typeof window !== "undefined") { Object.assign(window, SigPro); "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((t) => window[t[0].toUpperCase() + t.slice(1)] = (p, c) => SigPro.Tag(t, p, c)); diff --git a/src/components/Fetch.js b/src/components/Fetch.js new file mode 100644 index 0000000..628ccd3 --- /dev/null +++ b/src/components/Fetch.js @@ -0,0 +1,45 @@ +export const Fetch = ({ url, options = {}, fallback = "Cargando..." }, { children }) => { + const state = $$({ data: null, loading: true, error: null }); + let controller = null; + + const run = async () => { + if (controller) controller.abort(); + controller = new AbortController(); + state.loading = true; + state.error = null; + + try { + const targetUrl = isFunc(url) ? url() : url; + const fetchOpts = { + ...(isFunc(options) ? options() : options), + signal: controller.signal + }; + + const res = await fetch(targetUrl, fetchOpts); + if (!res.ok) throw new Error(`HTTP ${res.status}`); + + const contentType = res.headers.get("content-type"); + state.data = contentType?.includes("application/json") + ? await res.json() + : await res.text(); + } catch (err) { + if (err.name !== 'AbortError') state.error = err.message; + } finally { + state.loading = false; + } + }; + + if (isFunc(url)) Watch(url, run); + else run(); + + onUnmount(() => controller?.abort()); + + return Tag("div", { class: "sigpro-fetch" }, [ + () => { + if (state.loading) return fallback; + if (state.error) return Tag("span", { style: "color:red" }, state.error); + if (state.data) return isFunc(children[0]) ? children[0](state.data) : children; + return null; + } + ]); +}; \ No newline at end of file diff --git a/src/components/Fetch2.js b/src/components/Fetch2.js new file mode 100644 index 0000000..310bca8 --- /dev/null +++ b/src/components/Fetch2.js @@ -0,0 +1,53 @@ +import { $$, Tag, isFunc } from "./sigpro.js"; + +const _cache = new Map(); + +const getStore = (key) => { + if (!_cache.has(key)) { + _cache.set(key, $$({ data: null, loading: false, error: null })); + } + return _cache.get(key); +}; + +export const Request = async (key, url, opts = {}) => { + const store = getStore(key); + const { body, ...rest } = opts; + + store.loading = true; + store.error = null; + + try { + const config = { + method: rest.method || 'GET', + headers: { 'Content-Type': 'application/json', ...rest.headers }, + ...rest + }; + + if (body) config.body = typeof body === 'object' ? JSON.stringify(body) : body; + + const res = await fetch(url, config); + if (!res.ok) throw new Error(`HTTP ${res.status}`); + + const result = await res.json(); + store.data = result; + return result; + } catch (err) { + store.error = err.message; + throw err; + } finally { + store.loading = false; + } +}; + +export const Response = ({ name, loading, error }, { children }) => { + const store = getStore(name); + + return Tag("div", { style: "display:contents" }, [ + () => { + if (store.loading) return loading || "Cargando..."; + if (store.error) return isFunc(error) ? error(store.error) : Tag("p", {}, store.error); + if (store.data) return isFunc(children[0]) ? children[0](store.data) : children; + return null; + } + ]); +}; \ No newline at end of file diff --git a/src/sigpro.js b/src/sigpro.js index d41ce78..74ce884 100644 --- a/src/sigpro.js +++ b/src/sigpro.js @@ -1,4 +1,4 @@ -// sigpro 1.2.1 +// sigpro 1.2.0 const isFunc = f => typeof f === "function" const isObj = o => o && typeof o === "object" const isArr = Array.isArray @@ -104,10 +104,10 @@ const trackUpdate = (subs, trigger = false) => { if (!trigger && activeEffect && !activeEffect._disposed) { subs.add(activeEffect) ; (activeEffect._deps ||= new Set()).add(subs) - } else if (trigger && subs.size > 0) { + } else if (trigger) { let hasQueue = false - for (const e of subs) { - if (e === activeEffect || e._disposed) continue + subs.forEach(e => { + if (e === activeEffect || e._disposed) return if (e._isComputed) { e._dirty = true if (e._subs) trackUpdate(e._subs, true) @@ -115,7 +115,7 @@ const trackUpdate = (subs, trigger = false) => { effectQueue.add(e) hasQueue = true } - } + }) if (hasQueue && !isFlushing && batchDepth === 0) queueMicrotask(flush) } } @@ -175,39 +175,36 @@ const $ = (val, key = null) => { const $$ = (target) => { if (!isObj(target)) return target - let proxy = proxyCache.get(target) - if (proxy) return proxy + if (proxyCache.has(target)) return proxyCache.get(target) const subsMap = new Map() const getSubs = (k) => { let s = subsMap.get(k) - if (!s) subsMap.set(k, (s = new Set())) + if (!s) subsMap.set(k, s = new Set()) return s } - proxy = new Proxy(target, { - get(t, k, receiver) { - if (typeof k !== 'symbol') trackUpdate(getSubs(k)) - return $$(Reflect.get(t, k, receiver)) + const proxy = new Proxy(target, { + get(t, k) { + trackUpdate(getSubs(k)) + return $$(t[k]) }, - set(t, k, v, receiver) { - const isNew = !Reflect.has(t, k) - const oldV = Reflect.get(t, k, receiver) - const result = Reflect.set(t, k, v, receiver) - - if (result && !Object.is(oldV, v)) { + set(t, k, v) { + const isNew = !(k in t) + if (!Object.is(t[k], v)) { + t[k] = v trackUpdate(getSubs(k), true) if (isNew) trackUpdate(getSubs(ITER), true) } - return result + return true }, deleteProperty(t, k) { - const result = Reflect.deleteProperty(t, k) - if (result) { + const res = Reflect.deleteProperty(t, k) + if (res) { trackUpdate(getSubs(k), true) trackUpdate(getSubs(ITER), true) } - return result + return res }, ownKeys(t) { trackUpdate(getSubs(ITER)) @@ -499,37 +496,6 @@ Router.to = p => window.location.hash = p.replace(/^#?\/?/, "#/") Router.back = () => window.history.back() Router.path = () => window.location.hash.replace(/^#/, "") || "/" -const Anim = (show, render, { enter, leave } = {}) => { - const wrap = Tag('div', { style: 'display:contents' }) - let view = null - - const wait = (el, cb) => { - let done = false - const finish = () => !done && (done = true, cb()) - if (!el) return finish() - 'transitionend animationend'.split(' ').map(e => el.addEventListener(e, finish, { once: true })) - setTimeout(finish, 500) - } - - Watch(show, on => { - if (on && !view) { - const el = (view = Render(render)).container.firstChild - wrap.appendChild(view.container) - if (enter && el) { - el.classList.add(enter); el.clientTop - el.classList.add(enter + '-active') - wait(el, () => el.classList.remove(enter, enter + '-active')) - } - } else if (!on && view) { - const el = view.container.firstChild - const del = () => (view?.destroy(), view = null) - leave && el ? (el.classList.add(leave), wait(el, del)) : del() - } - }) - - return onUnmount(() => view?.destroy()), wrap -} - const Mount = (comp, target) => { const t = typeof target === "string" ? doc.querySelector(target) : target if (!t) return @@ -540,7 +506,7 @@ const Mount = (comp, target) => { return inst } -const SigPro = Object.freeze({ $, $$, Watch, Tag, Render, If, For, Router, Mount, onMount, onUnmount, Anim, Batch }) +const SigPro = Object.freeze({ $, $$, Watch, Tag, Render, If, For, Router, Mount, onMount, onUnmount, Batch }) if (typeof window !== "undefined") { Object.assign(window, SigPro) @@ -548,5 +514,5 @@ if (typeof window !== "undefined") { .split(" ").forEach(t => window[t[0].toUpperCase() + t.slice(1)] = (p, c) => SigPro.Tag(t, p, c)) } -export { $, $$, Watch, Tag, Render, If, For, Router, Mount, onMount, onUnmount, Anim, Batch } +export { $, $$, Watch, Tag, Render, If, For, Router, Mount, onMount, onUnmount, Batch } export default SigPro \ No newline at end of file diff --git a/src/sigpro.min.js b/src/sigpro.min.js deleted file mode 100644 index 1f29db7..0000000 --- a/src/sigpro.min.js +++ /dev/null @@ -1 +0,0 @@ -const isFunc=e=>"function"==typeof e,isArr=Array.isArray,doc="undefined"!=typeof document?document:null,ensureNode=e=>e?._isRuntime?e.container:e instanceof Node?e:doc.createTextNode(null==e?"":String(e));let activeEffect=null,activeOwner=null,isFlushing=!1;const effectQueue=new Set,MOUNTED_NODES=new WeakMap,dispose=e=>{if(!e||e._disposed)return;e._disposed=!0;const t=[e];for(;t.length;){const e=t.pop();e._cleanups&&(e._cleanups.forEach((e=>e())),e._cleanups.clear()),e._children&&(e._children.forEach((e=>t.push(e))),e._children.clear()),e._deps&&(e._deps.forEach((t=>t.delete(e))),e._deps.clear())}},onUnmount=e=>{activeOwner&&(activeOwner._cleanups||=new Set).add(e)},onMount=e=>{activeOwner&&(activeOwner._mounts||=[]).push(e)},createEffect=(e,t=!1)=>{const n=()=>{if(n._disposed)return;n._deps&&n._deps.forEach((e=>e.delete(n))),n._cleanups&&(n._cleanups.forEach((e=>e())),n._cleanups.clear());const s=activeEffect,o=activeOwner;activeEffect=activeOwner=n;try{const r=t?e():void e();return t||(n._result=r),r}finally{activeEffect=s,activeOwner=o}};return n._deps=n._cleanups=n._children=null,n._disposed=!1,n._isComputed=t,n._depth=activeEffect?activeEffect._depth+1:0,n._mounts=[],n._parent=activeOwner,activeOwner&&(activeOwner._children||=new Set).add(n),n},flush=()=>{if(isFlushing)return;isFlushing=!0;const e=Array.from(effectQueue).sort(((e,t)=>e._depth-t._depth));effectQueue.clear();for(const t of e)t._disposed||t();isFlushing=!1},trackUpdate=(e,t=!1)=>{if(t||!activeEffect||activeEffect._disposed){if(t){let t=!1;e.forEach((e=>{e===activeEffect||e._disposed||(e._isComputed?(e._dirty=!0,e._subs&&trackUpdate(e._subs,!0)):(effectQueue.add(e),t=!0))})),t&&!isFlushing&&queueMicrotask(flush)}}else e.add(activeEffect),(activeEffect._deps||=new Set).add(e)},untrack=e=>{const t=activeEffect;activeEffect=null;try{return e()}finally{activeEffect=t}},$=(e,t=null)=>{const n=new Set;if(isFunc(e)){let t,s=!0;const o=()=>{if(s){const r=activeEffect;activeEffect=o;try{const o=e();Object.is(t,o)||(t=o,s=!1,trackUpdate(n,!0))}finally{activeEffect=r}}return trackUpdate(n),t};return o._isComputed=!0,o._subs=n,o._dirty=!0,o._deps=null,o._disposed=!1,o.markDirty=()=>{s=!0},o.stop=()=>{o._disposed=!0,o._deps&&(o._deps.forEach((e=>e.delete(o))),o._deps.clear()),n.clear()},activeOwner&&onUnmount(o.stop),o}if(t)try{e=JSON.parse(localStorage.getItem(t))??e}catch(e){}return(...s)=>{if(s.length){const o=isFunc(s[0])?s[0](e):s[0];Object.is(e,o)||(e=o,t&&localStorage.setItem(t,JSON.stringify(e)),trackUpdate(n,!0))}return trackUpdate(n),e}},Watch=(e,t)=>{if(void 0===t){const t=createEffect(e);return t(),()=>dispose(t)}const n=createEffect((()=>{const n=isArr(e)?e.map((e=>e())):e();untrack((()=>t(n)))}));return n(),()=>dispose(n)},cleanupNode=e=>{e._cleanups&&(e._cleanups.forEach((e=>e())),e._cleanups.clear()),e._ownerEffect&&dispose(e._ownerEffect),e.childNodes&&e.childNodes.forEach(cleanupNode)},DANGEROUS_PROTOCOL=/^\s*(javascript|data|vbscript):/i,isDangerousAttr=e=>"src"===e||"href"===e||e.startsWith("on"),applyProp=(e,t,n,s)=>{null!=n&&!1!==n?"class"===t||"className"===t?e.className=n:"style"===t&&"object"==typeof n?Object.assign(e.style,n):t in e&&!s?e[t]=n:s?t.startsWith("xlink:")?e.setAttributeNS("http://www.w3.org/1999/xlink",t,n):"xmlns"===t||t.startsWith("xmlns:")?e.setAttributeNS("http://www.w3.org/2000/xmlns/",t,n):e.setAttribute(t,!0===n?"":n):e.setAttribute(t,!0===n?"":n):"class"===t||"className"===t?e.className="":t in e&&!s?e[t]="":e.removeAttribute(t)},Tag=(e,t={},n=[])=>{if((t instanceof Node||isArr(t)||t&&"object"!=typeof t)&&(n=t,t={}),isFunc(e)){const s={_mounts:[],_cleanups:new Set},o=createEffect((()=>{const s=e(t,{children:n,emit:(e,...n)=>t[`on${e[0].toUpperCase()}${e.slice(1)}`]?.(...n)});return o._result=s,s}));o(),s._mounts=o._mounts||[],s._cleanups=o._cleanups||new Set;const r=o._result,c=e=>{e&&"object"==typeof e&&!e._isRuntime&&(e._mounts=s._mounts,e._cleanups=s._cleanups,e._ownerEffect=o)};return isArr(r)?r.forEach(c):c(r),null==r?null:r instanceof Node||isArr(r)&&r.every((e=>e instanceof Node))?r:doc.createTextNode(String(r))}const s=/^(svg|path|circle|rect|line|polyline|polygon|g|defs|text|tspan|use|image|ellipse|foreignObject|linearGradient|radialGradient|stop|pattern|mask|clipPath|filter|feColorMatrix|feBlend|feGaussianBlur|animate|animateTransform|set|metadata|desc|title|symbol|marker|view)$/i.test(e),o=s?doc.createElementNS("http://www.w3.org/2000/svg",e):doc.createElement(e);o._cleanups=new Set;for(let e in t){if(!t.hasOwnProperty(e))continue;let n=t[e];if("ref"!==e)if(e.startsWith("on")){const t=e.slice(2).toLowerCase();o.addEventListener(t,n);const s=()=>o.removeEventListener(t,n);o._cleanups.add(s),onUnmount(s)}else if(isFunc(n)){const t=createEffect((()=>{let t=n();isDangerousAttr(e)&&DANGEROUS_PROTOCOL.test(String(t))&&(t="#"),applyProp(o,e,t,s)}));if(t(),o._cleanups.add((()=>dispose(t))),onUnmount((()=>dispose(t))),/^(INPUT|TEXTAREA|SELECT)$/.test(o.tagName)&&("value"===e||"checked"===e)){const t="checked"===e?"change":"input";o.addEventListener(t,(t=>n(t.target[e])))}}else{let t=n;isDangerousAttr(e)&&DANGEROUS_PROTOCOL.test(String(t))&&(t="#"),null!=t&&applyProp(o,e,t,s)}else isFunc(n)?n(o):n.current=o}const r=e=>{if(isArr(e))return e.forEach(r);if(isFunc(e)){const t=doc.createTextNode("");o.appendChild(t);let n=[];const s=createEffect((()=>{const s=e(),o=(isArr(s)?s:[s]).map(ensureNode);n.forEach((e=>{e._isRuntime?e.destroy():cleanupNode(e),e.parentNode&&e.remove()}));let r=t;for(let e=o.length-1;e>=0;e--){const t=o[e];t.parentNode!==r.parentNode&&r.parentNode?.insertBefore(t,r),t._mounts&&t._mounts.forEach((e=>e())),r=t}n=o}));s(),o._cleanups.add((()=>dispose(s))),onUnmount((()=>dispose(s)))}else{const t=ensureNode(e);o.appendChild(t),t._mounts&&t._mounts.forEach((e=>e()))}};return r(n),o},createView=e=>{const t=new Set,n=[],s=activeOwner;activeOwner={_cleanups:t,_mounts:n};const o=e({onCleanup:e=>t.add(e)});if(activeOwner=s,null==o)return null;if(o instanceof Node)return n.forEach((e=>e())),{_isRuntime:!0,container:o,destroy:()=>{t.forEach((e=>e())),cleanupNode(o),o.remove()}};const r=doc.createElement("div");r.style.display="contents",r.setAttribute("role","presentation");const c=e=>{e&&(e._isRuntime?(t.add(e.destroy),r.appendChild(e.container)):isArr(e)?e.forEach(c):r.appendChild(e instanceof Node?e:doc.createTextNode(String(e))))};return c(o),n.forEach((e=>e())),{_isRuntime:!0,container:r,destroy:()=>{t.forEach((e=>e())),cleanupNode(r),r.remove()}}},If=(e,t,n=null,s=null)=>{const o=doc.createTextNode(""),r=Tag("div",{style:"display:contents"},[o]);let c=null,a=null,i=null;return Watch((()=>!!(isFunc(e)?e():e)),(e=>{if(e===a)return;a=e;const l=()=>{c&&(c.destroy(),c=null)};if(c&&!e&&s?.out){i&&i.cancel&&i.cancel();const e=s.out(c.container,l);i=e,e&&e.finished?e.finished.then(l):l()}else l();const u=e?t:n;u&&(c=createView((()=>isFunc(u)?u():u)),r.insertBefore(c.container,o),s?.in&&s.in(c.container))})),r},For=(e,t,n)=>{const s=doc.createTextNode(""),o=Tag("div",{style:"display:contents"},[s]);let r=new Map;return Watch((()=>(isFunc(e)?e():e)||[]),(e=>{const c=new Map,a=[],i=e||[];for(let e=0;et(s,e))),c.set(o,l),a.push(l)}r.forEach((e=>e.destroy()));let l=s;for(let e=a.length-1;e>=0;e--){const t=a[e].container;t.nextSibling!==l&&o.insertBefore(t,l),l=t}r=c})),o},Router=e=>{const t=()=>window.location.hash.slice(1)||"/",n=$(t()),s=()=>n(t());window.addEventListener("hashchange",s),onUnmount((()=>window.removeEventListener("hashchange",s)));const o=Tag("div",{class:"router-outlet"});let r=null;return Watch([n],(()=>{const t=n(),s=e.find((e=>{const n=e.path.split("/").filter(Boolean),s=t.split("/").filter(Boolean);return n.length===s.length&&n.every(((e,t)=>":"===e[0]||e===s[t]))}))||e.find((e=>"*"===e.path));if(s){r?.destroy();const e={};s.path.split("/").filter(Boolean).forEach(((n,s)=>{":"===n[0]&&(e[n.slice(1)]=t.split("/").filter(Boolean)[s])})),Router.params(e),r=createView((()=>isFunc(s.component)?s.component(e):s.component)),o.replaceChildren(r.container)}})),o};Router.params=$({}),Router.to=e=>window.location.hash=e.replace(/^#?\/?/,"#/"),Router.back=()=>window.history.back(),Router.path=()=>window.location.hash.replace(/^#/,"")||"/";const Mount=(e,t)=>{const n="string"==typeof t?doc.querySelector(t):t;if(!n)return;MOUNTED_NODES.has(n)&&MOUNTED_NODES.get(n).destroy();const s=createView((()=>isFunc(e)?e():e));return n.replaceChildren(s.container),MOUNTED_NODES.set(n,s),s},set=(e,t,n)=>{if(void 0===n)e(isFunc(t)?t(e()):t);else{const s=t.split("."),o=s.pop(),r=e(),c=s.reduce(((e,t)=>({...e,[t]:{...e[t]}})),{...r});c[o]=n,e(c)}},SigPro=Object.freeze({$:$,Watch:Watch,Tag:Tag,If:If,For:For,Router:Router,Mount:Mount,onMount:onMount,onUnmount:onUnmount,set:set});"undefined"!=typeof window&&(Object.assign(window,SigPro),"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=>window[e[0].toUpperCase()+e.slice(1)]=(t,n)=>SigPro.Tag(e,t,n))));export{$,Watch,Tag,If,For,Router,Mount,onMount,onUnmount,set};export default SigPro; \ No newline at end of file diff --git a/src/sigpro2.js b/src/sigpro2.js new file mode 100644 index 0000000..d5748aa --- /dev/null +++ b/src/sigpro2.js @@ -0,0 +1,558 @@ +// sigpro 1.2.2 +const isFunc = f => typeof f === "function" +const isObj = o => o && typeof o === "object" +const isArr = Array.isArray +const doc = typeof document !== "undefined" ? document : null +const ensureNode = n => n?._isRuntime ? n.container : (n instanceof Node ? n : doc.createTextNode(n == null ? "" : String(n))) + +let activeEffect = null +let activeOwner = null +let isFlushing = false +let batchDepth = 0 +const effectQueue = new Set() +const proxyCache = new WeakMap() +const ITER = Symbol('iter') +const MOUNTED_NODES = new WeakMap() + +const dispose = eff => { + if (!eff || eff._disposed) return + eff._disposed = true + const stack = [eff] + while (stack.length) { + const e = stack.pop() + if (e._cleanups) { + e._cleanups.forEach(fn => fn()) + e._cleanups.clear() + } + if (e._children) { + e._children.forEach(child => stack.push(child)) + e._children.clear() + } + if (e._deps) { + e._deps.forEach(depSet => depSet.delete(e)) + e._deps.clear() + } + } +} + +const onMount = fn => { + if (activeOwner) (activeOwner._mounts ||= []).push(fn) +} + +const onUnmount = fn => { + if (activeOwner) (activeOwner._cleanups ||= new Set()).add(fn) +} + +const untrack = fn => { + const p = activeEffect + activeEffect = null + try { return fn() } finally { activeEffect = p } +} + +const createEffect = (fn, isComputed = false) => { + const effect = () => { + if (effect._disposed) return + if (effect._deps) effect._deps.forEach(s => s.delete(effect)) + if (effect._cleanups) { + effect._cleanups.forEach(c => c()) + effect._cleanups.clear() + } + const prevEffect = activeEffect + const prevOwner = activeOwner + activeEffect = activeOwner = effect + try { + return effect._result = fn() + } catch (e) { + console.error("[SigPro]", e) + } finally { + activeEffect = prevEffect + activeOwner = prevOwner + } + } + effect._deps = effect._cleanups = effect._children = null + effect._disposed = false + effect._isComputed = isComputed + effect._depth = activeEffect ? activeEffect._depth + 1 : 0 + effect._mounts = [] + effect._parent = activeOwner + if (activeOwner) (activeOwner._children ||= new Set()).add(effect) + return effect +} + +const flush = () => { + if (isFlushing) return + isFlushing = true + const sorted = Array.from(effectQueue).sort((a, b) => a._depth - b._depth) + effectQueue.clear() + for (const e of sorted) if (!e._disposed) e() + isFlushing = false +} + +const Batch = fn => { + batchDepth++ + try { + return fn() + } finally { + batchDepth-- + if (batchDepth === 0 && effectQueue.size > 0 && !isFlushing) { + flush() + } + } +} + +const trackUpdate = (subs, trigger = false) => { + if (!trigger && activeEffect && !activeEffect._disposed) { + subs.add(activeEffect) + ; (activeEffect._deps ||= new Set()).add(subs) + } else if (trigger && subs.size > 0) { + let hasQueue = false + for (const e of subs) { + if (e === activeEffect || e._disposed) continue + if (e._isComputed) { + e._dirty = true + if (e._subs) trackUpdate(e._subs, true) + } else { + effectQueue.add(e) + hasQueue = true + } + } + if (hasQueue && !isFlushing && batchDepth === 0) queueMicrotask(flush) + } +} + +const $ = (val, key = null) => { + const subs = new Set() + if (isFunc(val)) { + let cache, dirty = true + const computed = () => { + if (dirty) { + const prev = activeEffect + activeEffect = computed + try { + const next = val() + if (!Object.is(cache, next)) { + cache = next + dirty = false + trackUpdate(subs, true) + } + } finally { activeEffect = prev } + } + trackUpdate(subs) + return cache + } + computed._isComputed = true + computed._subs = subs + computed._dirty = true + computed._deps = null + computed._disposed = false + computed.markDirty = () => { dirty = true } + computed.stop = () => { + computed._disposed = true + if (computed._deps) { + computed._deps.forEach(depSet => depSet.delete(computed)) + computed._deps.clear() + } + subs.clear() + } + if (activeOwner) onUnmount(computed.stop) + return computed + } + if (key) try { val = JSON.parse(localStorage.getItem(key)) ?? val } catch (e) { } + return (...args) => { + if (args.length) { + const next = isFunc(args[0]) ? args[0](val) : args[0] + if (!Object.is(val, next)) { + val = next + if (key) localStorage.setItem(key, JSON.stringify(val)) + trackUpdate(subs, true) + } + } + trackUpdate(subs) + return val + } +} + +const $$ = (target) => { + if (!isObj(target)) return target + + let proxy = proxyCache.get(target) + if (proxy) return proxy + + const subsMap = new Map() + const getSubs = (k) => { + let s = subsMap.get(k) + if (!s) subsMap.set(k, (s = new Set())) + return s + } + + proxy = new Proxy(target, { + get(t, k, receiver) { + if (typeof k !== 'symbol') trackUpdate(getSubs(k)) + return $$(Reflect.get(t, k, receiver)) + }, + set(t, k, v, receiver) { + const isNew = !Reflect.has(t, k) + const oldV = Reflect.get(t, k, receiver) + const result = Reflect.set(t, k, v, receiver) + + if (result && !Object.is(oldV, v)) { + trackUpdate(getSubs(k), true) + if (isNew) trackUpdate(getSubs(ITER), true) + } + return result + }, + deleteProperty(t, k) { + const result = Reflect.deleteProperty(t, k) + if (result) { + trackUpdate(getSubs(k), true) + trackUpdate(getSubs(ITER), true) + } + return result + }, + ownKeys(t) { + trackUpdate(getSubs(ITER)) + return Reflect.ownKeys(t) + } + }) + + proxyCache.set(target, proxy) + return proxy +} + +const Watch = (sources, cb) => { + if (cb === undefined) { + const effect = createEffect(sources) + effect() + return () => dispose(effect) + } + const effect = createEffect(() => { + const vals = Array.isArray(sources) ? sources.map(s => s()) : sources() + untrack(() => cb(vals)) + }) + effect() + return () => dispose(effect) +} + +const cleanupNode = node => { + if (node._cleanups) { + node._cleanups.forEach(fn => fn()) + node._cleanups.clear() + } + if (node._ownerEffect) dispose(node._ownerEffect) + if (node.childNodes) node.childNodes.forEach(cleanupNode) +} + +const DANGEROUS_PROTOCOL = /^\s*(javascript|data|vbscript):/i +const isDangerousAttr = key => key === 'src' || key === 'href' || key.startsWith('on') + +const validateAttr = (key, val) => { + if (val == null || val === false) return null + if (isDangerousAttr(key)) { + const sVal = String(val) + if (DANGEROUS_PROTOCOL.test(sVal)) { + console.warn(`[SigPro] Bloqueado protocolo peligroso en ${key}`) + return '#' + } + } + return val +} + +const Tag = (tag, props = {}, children = []) => { + if (props instanceof Node || isArr(props) || !isObj(props)) { + children = props + props = {} + } + if (isFunc(tag)) { + const ctx = { _mounts: [], _cleanups: new Set() } + const effect = createEffect(() => { + const result = tag(props, { + children, + emit: (ev, ...args) => props[`on${ev[0].toUpperCase()}${ev.slice(1)}`]?.(...args) + }) + effect._result = result + return result + }) + effect() + + const result = effect._result + if (result == null) return null + + const node = (result instanceof Node || (isArr(result) && result.every(n => n instanceof Node))) + ? result + : doc.createTextNode(String(result)) + + const attach = n => { + if (isObj(n) && !n._isRuntime) { + n._mounts = effect._mounts || [] + n._cleanups = effect._cleanups || new Set() + n._ownerEffect = effect + } + } + + isArr(node) ? node.forEach(attach) : attach(node) + return node + } + const SVG_TAGS = /^(svg|path|circle|rect|line|polyline|polygon|g|defs|text|tspan|use|image|ellipse|foreignObject|linearGradient|radialGradient|stop|pattern|mask|clipPath|filter|feColorMatrix|feBlend|feGaussianBlur|animate|animateTransform|set|metadata|desc|title|symbol|marker|view|switch|a|altGlyph|altGlyphDef|altGlyphItem|glyph|glyphRef|hkern|vkern|font|font-face|font-face-format|font-face-name|font-face-src|font-face-uri|missing-glyph|mpath|textPath|tref|tbreak)$/i; + const isSVG = SVG_TAGS.test(tag); + const el = isSVG ? doc.createElementNS("http://www.w3.org/2000/svg", tag) : doc.createElement(tag) + el._cleanups = new Set() + + for (let k in props) { + if (!props.hasOwnProperty(k)) continue + let v = props[k] + if (k === "ref") { + isFunc(v) ? v(el) : (v.current = el) + continue + } + if (isSVG && k.startsWith("xlink:")) { + const ns = "http://www.w3.org/1999/xlink" + val == null ? el.removeAttributeNS(ns, k.slice(6)) : el.setAttributeNS(ns, k.slice(6), val) + continue + } + if (k.startsWith("on")) { + const ev = k.slice(2).toLowerCase() + el.addEventListener(ev, v) + const off = () => el.removeEventListener(ev, v) + el._cleanups.add(off) + onUnmount(off) + } else if (isFunc(v)) { + const effect = createEffect(() => { + const val = validateAttr(k, v()) + if (k === "class") el.className = val || "" + else if (val == null) el.removeAttribute(k) + else if (k in el && !isSVG) el[k] = val + else el.setAttribute(k, val === true ? "" : val) + }) + effect() + el._cleanups.add(() => dispose(effect)) + onUnmount(() => dispose(effect)) + if (/^(INPUT|TEXTAREA|SELECT)$/.test(el.tagName) && (k === "value" || k === "checked")) { + const evType = k === "checked" ? "change" : "input" + el.addEventListener(evType, ev => v(ev.target[k])) + } + } else { + const val = validateAttr(k, v) + if (val != null) { + if (k in el && !isSVG) el[k] = val + else el.setAttribute(k, val === true ? "" : val) + } + } + } + + const append = c => { + if (isArr(c)) return c.forEach(append) + if (isFunc(c)) { + const anchor = doc.createTextNode("") + el.appendChild(anchor) + let currentNodes = [] + const effect = createEffect(() => { + const res = c() + const next = (isArr(res) ? res : [res]).map(ensureNode) + currentNodes.forEach(n => { + if (n._isRuntime) n.destroy() + else cleanupNode(n) + if (n.parentNode) n.remove() + }) + let ref = anchor + for (let i = next.length - 1; i >= 0; i--) { + const node = next[i] + if (node.parentNode !== ref.parentNode) ref.parentNode?.insertBefore(node, ref) + if (node._mounts) node._mounts.forEach(fn => fn()) + ref = node + } + currentNodes = next + }) + effect() + el._cleanups.add(() => dispose(effect)) + onUnmount(() => dispose(effect)) + } else { + const node = ensureNode(c) + el.appendChild(node) + if (node._mounts) node._mounts.forEach(fn => fn()) + } + } + append(children) + return el +} + +const Render = renderFn => { + const cleanups = new Set() + const mounts = [] + const previousOwner = activeOwner + const previousEffect = activeEffect + const container = doc.createElement("div") + container.style.display = "contents" + container.setAttribute("role", "presentation") + activeOwner = { _cleanups: cleanups, _mounts: mounts } + activeEffect = null + + const processResult = result => { + if (!result) return + if (result._isRuntime) { + cleanups.add(result.destroy) + container.appendChild(result.container) + } else if (isArr(result)) { + result.forEach(processResult) + } else { + container.appendChild(result instanceof Node ? result : doc.createTextNode(String(result == null ? "" : result))) + } + } + + try { + processResult(renderFn({ onCleanup: fn => cleanups.add(fn) })) + } finally { + activeOwner = previousOwner + activeEffect = previousEffect + } + + mounts.forEach(fn => fn()) + return { + _isRuntime: true, + container, + destroy: () => { + cleanups.forEach(fn => fn()) + cleanupNode(container) + container.remove() + } + } +} + +const If = (cond, ifYes, ifNot = null) => { + const anchor = doc.createTextNode("") + const root = Tag("div", { style: "display:contents" }, [anchor]) + let currentView = null + + Watch( + () => !!(isFunc(cond) ? cond() : cond), + show => { + if (currentView) { + currentView.destroy() + currentView = null + } + + const content = show ? ifYes : ifNot + if (content) { + currentView = Render(() => isFunc(content) ? content() : content) + root.insertBefore(currentView.container, anchor) + } + } + ) + + onUnmount(() => currentView?.destroy()) + return root +} + +const For = (src, itemFn, keyFn) => { + const anchor = doc.createTextNode("") + const root = Tag("div", { style: "display:contents" }, [anchor]) + let cache = new Map() + Watch(() => (isFunc(src) ? src() : src) || [], items => { + const nextCache = new Map() + const nextOrder = [] + const newItems = items || [] + for (let i = 0; i < newItems.length; i++) { + const item = newItems[i] + const key = keyFn ? keyFn(item, i) : (item?.id ?? i) + let view = cache.get(key) + if (!view) view = Render(() => itemFn(item, i)) + else cache.delete(key) + nextCache.set(key, view) + nextOrder.push(view) + } + cache.forEach(view => view.destroy()) + let lastRef = anchor + for (let i = nextOrder.length - 1; i >= 0; i--) { + const view = nextOrder[i] + const node = view.container + if (node.nextSibling !== lastRef) root.insertBefore(node, lastRef) + lastRef = node + } + cache = nextCache + }) + return root +} + +const Router = routes => { + const getHash = () => window.location.hash.slice(1) || "/" + const path = $(getHash()) + const handler = () => path(getHash()) + window.addEventListener("hashchange", handler) + onUnmount(() => window.removeEventListener("hashchange", handler)) + const hook = Tag("div", { class: "router-hook" }) + let currentView = null + Watch([path], () => { + const cur = path() + const route = routes.find(r => { + const p1 = r.path.split("/").filter(Boolean) + const p2 = cur.split("/").filter(Boolean) + return p1.length === p2.length && p1.every((p, i) => p[0] === ":" || p === p2[i]) + }) || routes.find(r => r.path === "*") + if (route) { + currentView?.destroy() + const params = {} + route.path.split("/").filter(Boolean).forEach((p, i) => { + if (p[0] === ":") params[p.slice(1)] = cur.split("/").filter(Boolean)[i] + }) + Router.params(params) + currentView = Render(() => isFunc(route.component) ? route.component(params) : route.component) + hook.replaceChildren(currentView.container) + } + }) + return hook +} +Router.params = $({}) +Router.to = p => window.location.hash = p.replace(/^#?\/?/, "#/") +Router.back = () => window.history.back() +Router.path = () => window.location.hash.replace(/^#/, "") || "/" + +const Anim = (show, render, { enter, leave } = {}) => { + const wrap = Tag('div', { style: 'display:contents' }) + let view = null + + const wait = (el, cb) => { + let done = false + const finish = () => !done && (done = true, cb()) + if (!el) return finish() + 'transitionend animationend'.split(' ').map(e => el.addEventListener(e, finish, { once: true })) + setTimeout(finish, 500) + } + + Watch(show, on => { + if (on && !view) { + const el = (view = Render(render)).container.firstChild + wrap.appendChild(view.container) + if (enter && el) { + el.classList.add(enter); el.clientTop + el.classList.add(enter + '-active') + wait(el, () => el.classList.remove(enter, enter + '-active')) + } + } else if (!on && view) { + const el = view.container.firstChild + const del = () => (view?.destroy(), view = null) + leave && el ? (el.classList.add(leave), wait(el, del)) : del() + } + }) + + return onUnmount(() => view?.destroy()), wrap +} + +const Mount = (comp, target) => { + const t = typeof target === "string" ? doc.querySelector(target) : target + if (!t) return + if (MOUNTED_NODES.has(t)) MOUNTED_NODES.get(t).destroy() + const inst = Render(isFunc(comp) ? comp : () => comp) + t.replaceChildren(inst.container) + MOUNTED_NODES.set(t, inst) + return inst +} + +const SigPro = Object.freeze({ $, $$, Watch, Tag, Render, If, For, Router, Mount, onMount, onUnmount, Anim, Batch }) + +if (typeof window !== "undefined") { + Object.assign(window, SigPro) + "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(t => window[t[0].toUpperCase() + t.slice(1)] = (p, c) => SigPro.Tag(t, p, c)) +} + +export { $, $$, Watch, Tag, Render, If, For, Router, Mount, onMount, onUnmount, Anim, Batch } +export default SigPro \ No newline at end of file