var y=(e)=>typeof e==="function",B=(e)=>e&&typeof e==="object",b=Array.isArray,g=typeof document<"u"?document:null,k=(e)=>e?._isRuntime?e.container:e instanceof Node?e:g.createTextNode(e==null?"":String(e)),p=null,m=null,x=!1,A=0,C=new Set,D=new WeakMap,L=Symbol("iter"),P=new WeakMap,E=(e)=>{if(!e||e._disposed)return;e._disposed=!0;let r=[e];while(r.length){let n=r.pop();if(n._cleanups)n._cleanups.forEach((i)=>i()),n._cleanups.clear();if(n._children)n._children.forEach((i)=>r.push(i)),n._children.clear();if(n._deps)n._deps.forEach((i)=>i.delete(n)),n._deps.clear()}},v=(e)=>{if(m)(m._cleanups||=new Set).add(e)},V=(e)=>{let r=p;p=null;try{return e()}finally{p=r}},O=(e,r=!1)=>{let n=()=>{if(n._disposed)return;if(n._deps)n._deps.forEach((c)=>c.delete(n));if(n._cleanups)n._cleanups.forEach((c)=>c()),n._cleanups.clear();let i=p,o=m;p=m=n;try{return n._result=e()}catch(c){console.error("[SigPro]",c)}finally{p=i,m=o}};if(n._deps=n._cleanups=n._children=null,n._disposed=!1,n._isComputed=r,n._depth=p?p._depth+1:0,n._mounts=[],n._parent=m,m)(m._children||=new Set).add(n);return n},q=()=>{if(x)return;x=!0;let e=Array.from(C).sort((r,n)=>r._depth-n._depth);C.clear();for(let r of e)if(!r._disposed)r();x=!1},W=(e)=>{A++;try{return e()}finally{if(A--,A===0&&C.size>0&&!x)q()}},w=(e,r=!1)=>{if(!r&&p&&!p._disposed)e.add(p),(p._deps||=new Set).add(e);else if(r&&e.size>0){let n=!1;for(let i of e){if(i===p||i._disposed)continue;if(i._isComputed){if(i._dirty=!0,i._subs)w(i._subs,!0)}else C.add(i),n=!0}if(n&&!x&&A===0)queueMicrotask(q)}},N=(e,r=null)=>{let n=new Set;if(y(e)){let i,o=()=>{if(o._dirty){let c=p;p=o;try{let t=e();if(!Object.is(i,t))i=t,w(n,!0)}finally{p=c}o._dirty=!1}return w(n),i};if(o._isComputed=!0,o._subs=n,o._dirty=!0,o._deps=null,o._disposed=!1,o.stop=()=>{},m)v(o.stop);return o}if(r)try{e=JSON.parse(localStorage.getItem(r))??e}catch(i){}return(...i)=>{if(i.length){let o=y(i[0])?i[0](e):i[0];if(!Object.is(e,o)){if(e=o,r)localStorage.setItem(r,JSON.stringify(e));w(n,!0)}}return w(n),e}},I=(e)=>{if(!B(e))return e;let r=D.get(e);if(r)return r;let n=new Map,i=(c)=>{let t=n.get(c);if(!t)n.set(c,t=new Set);return t},o=new Proxy(e,{get(c,t,s){if(typeof t!=="symbol")w(i(t));return I(Reflect.get(c,t,s))},set(c,t,s,l){let a=Reflect.has(c,t),f=Reflect.get(c,t,l),u=Reflect.set(c,t,s,l);if(u&&!Object.is(f,s)){if(w(i(t),!0),!a)w(i(L),!0)}return u},deleteProperty(c,t){let s=Reflect.deleteProperty(c,t);if(s)w(i(t),!0),w(i(L),!0);return s},ownKeys(c){return w(i(L)),Reflect.ownKeys(c)}});return D.set(e,o),o},$=(e,r)=>{if(r===void 0){let i=O(e);return i(),()=>E(i)}let n=O(()=>{let i=Array.isArray(e)?e.map((o)=>o()):e();V(()=>r(i))});return n(),()=>E(n)},R=(e,r=!1)=>{if(!e)return;if(e._cleanups)e._cleanups.forEach((n)=>n()),e._cleanups.clear();if(e._ownerEffect)E(e._ownerEffect);if(!r&&e._sig_leave)return e._sig_leave(()=>{if(e.childNodes)e.childNodes.forEach((n)=>R(n,!0));e.remove()});if(e.childNodes)e.childNodes.forEach((n)=>R(n,!1))},F=/^\s*(javascript|data|vbscript):/i,J=(e)=>e==="src"||e==="href"||e.startsWith("on"),M=(e,r)=>{if(r==null||r===!1)return null;if(J(e)){let n=String(r);if(F.test(n))return console.warn(`[SigPro] Bloqueado protocolo peligroso en ${e}`),"#"}return r},T=(e,r={},n=[])=>{if(r instanceof Node||b(r)||!B(r))n=r,r={};if(y(e)){let t=O(()=>{let f=e(r,{children:n,emit:(u,...h)=>r[`on${u[0].toUpperCase()}${u.slice(1)}`]?.(...h)});return t._result=f,f});t();let s=t._result;if(s==null)return null;let l=s instanceof Node||b(s)&&s.every((f)=>f instanceof Node)?s:g.createTextNode(String(s)),a=(f)=>{if(B(f)&&!f._isRuntime)f._mounts=t._mounts||[],f._cleanups=t._cleanups||new Set,f._ownerEffect=t};return b(l)?l.forEach(a):a(l),l}let i=/^(svg|path|circle|rect|line|poly(line|gon)|g|defs|text(path)?|tspan|use|symbol|image|marker|ellipse)$/i.test(e),o=i?g.createElementNS("http://www.w3.org/2000/svg",e):g.createElement(e);o._cleanups=new Set;for(let t in r){if(!r.hasOwnProperty(t))continue;let s=r[t];if(t==="ref"){y(s)?s(o):s.current=o;continue}if(i&&t.startsWith("xlink:")){s==null?o.removeAttributeNS("http://www.w3.org/1999/xlink",t.slice(6)):o.setAttributeNS("http://www.w3.org/1999/xlink",t.slice(6),s);continue}if(t.startsWith("on")){let l=t.slice(2).toLowerCase();o.addEventListener(l,s);let a=()=>o.removeEventListener(l,s);o._cleanups.add(a),v(a)}else if(y(s)){let l=O(()=>{let a=M(t,s());if(t==="class")o.className=a||"";else if(a==null)o.removeAttribute(t);else if(t in o&&!i)o[t]=a;else o.setAttribute(t,a===!0?"":a)});if(l(),o._cleanups.add(()=>E(l)),v(()=>E(l)),/^(INPUT|TEXTAREA|SELECT)$/.test(o.tagName)&&(t==="value"||t==="checked")){let a=t==="checked"?"change":"input";o.addEventListener(a,(f)=>s(f.target[t]))}}else{let l=M(t,s);if(l!=null)if(t in o&&!i)o[t]=l;else o.setAttribute(t,l===!0?"":l)}}let c=(t)=>{if(b(t))return t.forEach(c);if(y(t)){let s=g.createTextNode("");o.appendChild(s);let l=[],a=O(()=>{let f=t(),u=(b(f)?f:[f]).map(k);l.forEach((d)=>{if(d._isRuntime)d.destroy();else R(d);if(d.parentNode)d.remove()});let h=s;for(let d=u.length-1;d>=0;d--){let _=u[d];if(_.parentNode!==h.parentNode)h.parentNode?.insertBefore(_,h);if(_._mounts)_._mounts.forEach((U)=>U());h=_}l=u});a(),o._cleanups.add(()=>E(a)),v(()=>E(a))}else{let s=k(t);if(o.appendChild(s),s._mounts)s._mounts.forEach((l)=>l())}};return c(n),o},j=(e)=>{let r=new Set,n=m,i=p,o=g.createElement("div");o.style.display="contents",o.setAttribute("role","presentation"),m={_cleanups:r},p=null;let c=(t)=>{if(!t)return;if(t._isRuntime)r.add(t.destroy),o.appendChild(t.container);else if(b(t))t.forEach(c);else o.appendChild(t instanceof Node?t:g.createTextNode(String(t==null?"":t)))};try{c(e({onCleanup:(t)=>r.add(t)}))}finally{m=n,p=i}return{_isRuntime:!0,container:o,destroy:()=>{if(r.forEach((t)=>t()),R(o),!o._sig_leave)o.remove()}}},z=(e,r,n=null)=>{let i=g.createTextNode(""),o=T("div",{style:"display:contents"},[i]),c=null;return $(()=>!!(y(e)?e():e),(t)=>{if(c)c.destroy(),c=null;let s=t?r:n;if(s)c=j(()=>y(s)?s():s),o.insertBefore(c.container,i)}),v(()=>c?.destroy()),o},G=({name:e,duration:r=200,scale:n,slide:i,rotate:o,blur:c},t)=>{let s=typeof t==="function"?t():t;if(!(s instanceof Node))return s;if(e)return s.style.animation=`${e}-in ${r}ms`,s._sig_leave=(a)=>{s.style.animation=`${e}-out ${r}ms`,s.addEventListener("animationend",a,{once:!0})},s;let l=n||i||o||c;if(s.style.transition=l?`all ${r}ms`:"",s.style.opacity="0",n)s.style.transform="scale(0.95)";if(i)s.style.transform="translateY(-10px)";if(o)s.style.transform="rotate(-2deg)";if(c)s.style.filter="blur(4px)";return requestAnimationFrame(()=>{s.style.opacity="1",s.style.transform=n||i||o||c?"":"none"}),s._sig_leave=(a)=>{s.style.opacity="0",s.addEventListener("transitionend",a,{once:!0})},s},K=(e,r,n)=>{let i=g.createTextNode(""),o=T("div",{style:"display:contents"},[i]),c=new Map;return $(()=>(y(e)?e():e)||[],(t)=>{let s=new Map,l=[],a=t||[];for(let u=0;ur(h,u));else c.delete(d);s.set(d,_),l.push(_)}c.forEach((u)=>u.destroy());let f=i;for(let u=l.length-1;u>=0;u--){let d=l[u].container;if(d.nextSibling!==f)o.insertBefore(d,f);f=d}c=s}),o},S=(e)=>{let r=()=>window.location.hash.slice(1)||"/",n=N(r()),i=()=>n(r());window.addEventListener("hashchange",i),v(()=>window.removeEventListener("hashchange",i));let o=T("div",{class:"router-hook"}),c=null;return $([n],()=>{let t=n(),s=e.find((l)=>{let a=l.path.split("/").filter(Boolean),f=t.split("/").filter(Boolean);return a.length===f.length&&a.every((u,h)=>u[0]===":"||u===f[h])})||e.find((l)=>l.path==="*");if(s){c?.destroy();let l={};s.path.split("/").filter(Boolean).forEach((a,f)=>{if(a[0]===":")l[a.slice(1)]=t.split("/").filter(Boolean)[f]}),S.params(l),c=j(()=>y(s.component)?s.component(l):s.component),o.replaceChildren(c.container)}}),o};S.params=N({});S.to=(e)=>window.location.hash=e.replace(/^#?\/?/,"#/");S.back=()=>window.history.back();S.path=()=>window.location.hash.replace(/^#/,"")||"/";var Q=({url:e,method:r="GET",headers:n={}})=>{let i=N(!1),o=N(null),c=N(null),t=null,s=null;return{run:async(f=null)=>{t?.abort(),clearTimeout(s),t=new AbortController,s=setTimeout(()=>t.abort(),1e4),i(!0),o(null);try{let u=f instanceof FormData,h=await fetch(e,{method:r,headers:u?n:{"Content-Type":"application/json",...n},body:u?f:f?JSON.stringify(f):void 0,signal:t.signal}),d=await h.text(),_=d?JSON.parse(d):null;if(!h.ok)throw Error(_?.message||h.statusText);return c(_),_}catch(u){if(u.name!=="AbortError")o(u.message);throw u}finally{i(!1),clearTimeout(s),t=null,s=null}},abort:()=>t?.abort(),loading:i,error:o,data:c}},H=(e,r)=>{let n=typeof r==="string"?g.querySelector(r):r;if(!n)return;if(P.has(n))P.get(n).destroy();let i=j(y(e)?e:()=>e);return n.replaceChildren(i.container),P.set(n,i),i},X=Object.freeze({$:N,$$:I,watch:$,h:T,when:z,each:K,fx:G,router:S,req:Q,mount:H,batch:W});if(typeof window<"u")Object.assign(window,X),"a abbr article aside audio b blockquote br button canvas caption cite code col colgroup datalist dd del details dfn dialog div dl dt em embed fieldset figcaption figure footer form h1 h2 h3 h4 h5 h6 header hr i iframe img input ins kbd label legend li main mark meter nav object ol optgroup option output p picture pre progress section select slot small source span strong sub summary sup svg table tbody td template textarea tfoot th thead time tr u ul video".split(" ").forEach((e)=>{window[e]=(r,n)=>T(e,r,n)});export{z as when,$ as watch,S as router,Q as req,H as mount,T as h,G as fx,K as each,W as batch,I as $$,N as $};