@deijose/nix-js 1.7.3-beta.10 → 1.7.3-beta.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var e=null,t=[],n=null,r=[],i=null,a=[];function o(e){a.push(i),i=e}function s(){i=a.pop()??null}var c=0,l=new Set,u=100,d=0,f=class{_value;_subs=new Set;constructor(e){this._value=e}get value(){return e&&(this._subs.add(e),n?.add(this)),this._value}set value(e){Object.is(this._value,e)||(this._value=e,this._notify())}update(e){this.value=e(this._value)}peek(){return this._value}_removeSub(e){this._subs.delete(e)}_notify(){if(c>0)for(let e of this._subs)l.add(e);else{let e=Array.from(this._subs);for(let t=0;t<e.length;t++)e[t]()}}dispose(){this._subs.clear()}};function p(e){return new f(e)}function m(o){let l,a=!1,s=new Set,c=new Set,f=i,p=()=>{if(a)return;"function"==typeof l&&l();let i=s;if(s=c,c=i,c.clear(),t.push(e),r.push(n),e=p,n=c,++d>u)throw d=0,e=t.pop()||null,n=r.pop()||null,Error("[Nix] Maximum effect re-execution depth exceeded (possible infinite loop).");try{l=o()}catch(e){if(!f)throw e;f(e)}finally{d--,e=t.pop()||null,n=r.pop()||null;for(let e of s)c.has(e)||e._removeSub(p)}};return p(),()=>{a=!0,"function"==typeof l&&l();for(let e of c)e._removeSub(p);c.clear(),s.clear()}}function h(e){let t=new f(void 0),n=m(()=>{t.value=e()}),r=t.dispose;return t.dispose=()=>{n(),r.call(t)},t}function g(e){c++;try{e()}finally{if(0===--c&&l.size>0){for(let e of l)e();l.clear()}}}function _(t){let r=e,o=n;e=null,n=null;try{return t()}finally{e=r,n=o}}function v(e,t,n={}){let r,{immediate:o=!1,once:l=!1}=n,i=e instanceof f?()=>e.value:e,a=!0,u=!1,s=m(()=>{let e=i();if(a){if(a=!1,o&&!u){let n=e;_(()=>t(n,void 0)),l&&(u=!0,Promise.resolve().then(s))}r=e}else if(!u){let n=e,o=r;r=e,_(()=>t(n,o)),l&&(u=!0,Promise.resolve().then(s))}});return()=>{u=!0,s()}}function y(e){return e?Promise.resolve().then(e):Promise.resolve()}var b=class{__isNixComponent=!0;children;_slots=new Map;setChildren(e){return this.children=e,this}setSlot(e,t){return this._slots.set(e,t),this}slot(e){return this._slots.get(e)}};function x(e){return"object"==typeof e&&!!e&&!0===e.__isNixComponent}function S(e){return Symbol(e)}var C=[];function w(){return[...C]}function T(){C.push(new Map)}function E(){C.pop()}function D(e,t){let n=C.splice(0);e.forEach(e=>C.push(e)),C.push(new Map);try{return t()}finally{C.splice(0),n.forEach(e=>C.push(e))}}function O(e,t){let n=C[C.length-1];if(!n)throw Error("[Nix] provide() must be called inside onInit() of a NixComponent.");n.set(e,t)}function k(e){for(let t=C.length-1;t>=0;t--)if(C[t].has(e))return C[t].get(e)}var A={SCOPE:"nix-scope",ERROR_BOUNDARY:"nix-eb",TRANSITION:"nix-t",KEYED_START:"nix-ks",KEYED_END:"nix-ke",KEYED_ZONE:"nix-kz"};function ee(){return{el:null}}function te(e,t){t?"none"===e.style.display&&(e.style.display=""):"none"!==e.style.display&&(e.style.display="none")}function ne(e,t,n){return{__isKeyedList:!0,items:e,keyFn:t,renderFn:n}}function re(e,t,n){let r,o;T();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}r=e.render()._render(t,n)}finally{E()}try{let t=e.onMount?.();"function"==typeof t&&(o=t)}catch(t){if(!e.onError)throw t;e.onError(t)}return()=>{try{e.onUnmount?.()}catch{}try{o?.()}catch{}r()}}function ie(e,t,n){let r,o;T();try{try{e.onInit?.()}catch{}r=e.render()._render(t,n)}finally{E()}try{let t=e.onMount?.();"function"==typeof t&&(o=t)}catch{}return()=>{try{e.onUnmount?.()}catch{}try{o?.()}catch{}r()}}function j(e,t,n,r){let o,l;D(r,()=>{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}o=e.render()._render(t,n)});try{let t=e.onMount?.();"function"==typeof t&&(l=t)}catch(t){if(!e.onError)throw t;e.onError(t)}return()=>{try{e.onUnmount?.()}catch{}try{l?.()}catch{}o()}}function ae(e,t,n,r,o){let l,i;T();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}l=e.render()._render(t,n)}finally{E()}r.push(()=>{try{let t=e.onMount?.();"function"==typeof t&&(i=t)}catch(t){if(!e.onError)throw t;e.onError(t)}}),o.push(()=>{try{e.onUnmount?.()}catch{}try{i?.()}catch{}l()})}function oe(){return{__isPortalOutlet:!0,_container:null}}function se(e){return{__isNixTemplate:!0,mount(e){let t="string"==typeof e?document.querySelector(e)??document.body:e;return{unmount:this._render(t,null)}},_render(t,n){let r=document.createElement("div");return r.setAttribute("data-nix-outlet",""),e._container=r,t.insertBefore(r,n),()=>{e._container=null,r.remove()}}}}function ce(e,t=document.body){return{__isNixTemplate:!0,mount(e){let t="string"==typeof e?document.querySelector(e)??document.body:e;return{unmount:this._render(t,null)}},_render(n,r){let o;return o="string"==typeof t?document.querySelector(t)??document.body:t instanceof Element?t:"__isPortalOutlet"in t?t._container??document.body:t.el??document.body,x(e)?re(e,o,null):e._render(o,null)}}}var M=S("nix:portal-outlet");function le(e){O(M,e)}function ue(){return k(M)}function de(e,t){return{__isNixTemplate:!0,mount(e){let t="string"==typeof e?document.querySelector(e)??document.body:e;return{unmount:this._render(t,null)}},_render(n,r){let l=document.createComment(A.ERROR_BOUNDARY);n.insertBefore(l,r);let i,a=null,u=!1,c=!1,f=!1,d=e=>{let n=l.parentNode,o="function"!=typeof t||x(t)?t:t(e);a=x(o)?ie(o,n,r):o._render(n,r)};o(e=>{u||(u=!0,c?(a?.(),a=null,d(e)):(i=e,f=!0))});try{if(x(e)){T();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}a=e.render()._render(n,r)}finally{E()}if(!u)try{let t=e.onMount?.(),n=a;a=()=>{try{e.onUnmount?.()}catch{}if("function"==typeof t)try{t()}catch{}n?.()}}catch(t){if(!e.onError)throw t;e.onError(t)}}else a=e._render(n,r)}catch(e){u=!0,a?.(),a=null,i=e,f=!0}finally{s(),c=!0}return f&&(a?.(),a=null,d(i)),()=>{a?.(),l.remove()}}}}function fe(e){let t=e.name??"nix";return{enterFrom:e.enterFrom??`${t}-enter-from`,enterActive:e.enterActive??`${t}-enter-active`,enterTo:e.enterTo??`${t}-enter-to`,leaveFrom:e.leaveFrom??`${t}-leave-from`,leaveActive:e.leaveActive??`${t}-leave-active`,leaveTo:e.leaveTo??`${t}-leave-to`}}function pe(e){return Math.max(0,...e.split(",").map(e=>parseFloat(e.trim())||0))}function N(e,t=0){return new Promise(n=>{let r=getComputedStyle(e),o=1e3*Math.max(pe(r.transitionDuration||"0"),pe(r.animationDuration||"0")),l=o>0?o+100:t;if(l<=0)return void n();let i,a=t=>{t.target===e&&(clearTimeout(i),e.removeEventListener("transitionend",a),e.removeEventListener("animationend",a),n())};e.addEventListener("transitionend",a),e.addEventListener("animationend",a),i=setTimeout(()=>{e.removeEventListener("transitionend",a),e.removeEventListener("animationend",a),n()},l)})}function me(e,t={}){let n=fe(t);return{__isNixTemplate:!0,mount(e){let t="string"==typeof e?document.querySelector(e)??document.body:e;return{unmount:this._render(t,null)}},_render(r,o){let l=document.createComment(A.TRANSITION);r.insertBefore(l,o);let i=null,a=null,u=0,s=!0,c=()=>{let e=l.nextSibling;for(;e&&e!==o;){if(e.nodeType===Node.ELEMENT_NODE)return e;e=e.nextSibling}return null};function f(e){return x(e)?ie(e,r,o):e._render(r,o)}let d=(e,r=!1)=>{u++,a&&=(a(),null),i=f(e);let o=c();if(o&&(!s||t.appear)&&!r){let e=u;(async()=>{t.onBeforeEnter?.(o),o.classList.add(n.enterFrom,n.enterActive),o.getBoundingClientRect(),await new Promise(e=>requestAnimationFrame(()=>e())),u===e&&(o.classList.remove(n.enterFrom),o.classList.add(n.enterTo),await N(o,t.duration),u===e&&(o.classList.remove(n.enterActive,n.enterTo),t.onAfterEnter?.(o)))})().catch(()=>{})}s=!1},p=()=>{let e=i;i=null;let r=c();if(!r)return void e?.();let o=++u;a=e??null,(async()=>{t.onBeforeLeave?.(r),r.classList.add(n.leaveFrom,n.leaveActive),r.getBoundingClientRect(),await new Promise(e=>requestAnimationFrame(()=>e())),u===o&&(r.classList.remove(n.leaveFrom),r.classList.add(n.leaveTo),await N(r,t.duration),u===o&&(r.classList.remove(n.leaveActive,n.leaveTo),t.onAfterLeave?.(r),a?.(),a=null))})().catch(()=>{})},h=null;if("function"!=typeof e||x(e))d(e);else{let t=e,n=null;h=m(()=>{let e=t(),r=null===n,o=null===e;r&&!o?d(e):!r&&o?p():!r&&!o&&(u++,a?.(),a=null,i?.(),i=null,d(e,!0)),n=e}),s=!1}return()=>{u++,h?.(),i?.(),a?.(),i=null,a=null,l.remove()}}}}function he(e){let t=e.lastIndexOf(">"),n=e.lastIndexOf("<");if(n<=t)return{type:"node"};let r=e.slice(n+1),o=r.lastIndexOf("=");if(-1===o)return{type:"node"};let l=r.endsWith('"')||r.endsWith("'")||'"'===r[r.length-1]||"'"===r[r.length-1],i=o-1;for(;i>=0&&/\S/.test(r[i]);)i--;i++;let a=r.slice(i,o);if("@"===a[0]){let e=a.slice(1).split(".");return{type:"event",eventName:e[0],modifiers:e.slice(1),hadOpenQuote:l}}return{type:"attr",attrName:a,hadOpenQuote:l}}function ge(e,t){let n=new Uint8Array(e.length),r="";for(let o=0;o<e.length;o++){let l=e[o];if(1===n[o]&&('"'===l[0]||"'"===l[0])&&(l=l.slice(1)),o<t.length){let e=t[o];if("node"===e.type)r+=l+`\x3c!--nix-${o}--\x3e`;else if("event"===e.type){let t=`@${e.modifiers.length?`${e.eventName}.${e.modifiers.join(".")}`:e.eventName}=`.length+(e.hadOpenQuote?1:0);r+=l.slice(0,-t)+` data-nix-e-${o}="${e.eventName}"`,e.hadOpenQuote&&(n[o+1]=1)}else{let t=`${e.attrName}=`.length+(e.hadOpenQuote?1:0);r+=l.slice(0,-t)+` data-nix-a-${o}="${e.attrName}"`,e.hadOpenQuote&&(n[o+1]=1)}}else r+=l}return r}function P(e){return"object"==typeof e&&!!e&&!0===e.__isNixTemplate}function _e(e){return"object"==typeof e&&!!e&&!0===e.__isKeyedList}var ve={enter:"Enter",escape:"Escape",space:" ",tab:"Tab",delete:"Delete",backspace:"Backspace",up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight"},ye=new Set(["click","dblclick","mousedown","mouseup","keydown","keyup","input","change","submit"]),F=new Set;function be(e){let t=e.target,n=`__nix_${e.type}`,r=`__nix_${e.type}_mods`,o=e.stopPropagation,l=!1;for(e.stopPropagation=()=>{l=!0,o.call(e)};t&&t!==document;){let o=t[n];if(o){let n=t[r];if(n){if(n.includes("prevent")&&e.preventDefault(),n.includes("stop")&&e.stopPropagation(),n.includes("self")&&e.target!==t){t=t.parentNode;continue}if("key"in e){let r=e,o=!0;for(let e of n){let t=ve[e];if(void 0!==t&&r.key!==t){o=!1;break}if(!t&&1===e.length&&r.key.toLowerCase()!==e){o=!1;break}}if(!o){t=t.parentNode;continue}}}if(o(e),l)break}t=t.parentNode}e.stopPropagation=o}var I=new Set,L=!1;function R(e){I.add(e),L||(L=!0,queueMicrotask(()=>{for(let e of I)e();I.clear(),L=!1}))}function xe(e,t,n,r){let o=[],l=[],i=Array(t.length),a=-1;for(let e=0;e<t.length;e++)r[e]&&r[e].nodeIndex>a&&(a=r[e].nodeIndex);let u=[e];if(a>0){let t,n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_COMMENT),r=0;for(;r<a&&(t=n.nextNode());)r++,u.push(t)}for(let e=0;e<t.length;e++){let t=r[e];i[e]=t?u[t.nodeIndex]:null}for(let e=0;e<t.length;e++){let a=t[e],u=n[e],s=r[e];if(!s)continue;let c=i[e];if("event"===a.type){let e=s.name,t=u,n=a.modifiers;if(!ye.has(e)||n.includes("capture")||n.includes("once")){let r={once:n.includes("once"),capture:n.includes("capture"),passive:n.includes("passive")},l=e=>{n.includes("prevent")&&e.preventDefault(),n.includes("stop")&&e.stopPropagation(),(!n.includes("self")||e.target===e.currentTarget)&&t(e)};c.addEventListener(e,l,r),o.push(()=>c.removeEventListener(e,l,r))}else F.has(e)||(document.addEventListener(e,be),F.add(e)),c[`__nix_${e}`]=t,n.length>0&&(c[`__nix_${e}_mods`]=n),o.push(()=>{c[`__nix_${e}`]=null,c[`__nix_${e}_mods`]=null});continue}if("attr"===a.type){let e=s.name,t=c;if("ref"===e){u.el=t,o.push(()=>{u.el=null});continue}if("show"===e||"hide"===e){let n=t,r=null;if("function"==typeof u){let t=!1,l=!1,i=!0,a=m(()=>{l=!!u();let o=()=>{t=!1;let o="show"===e?l:!l;null===r&&(r=n.style.display||""),n.style.display=o?r:"none"};i?(i=!1,o()):t||(t=!0,R(o))});o.push(a)}else("show"===e?u:!u)||(n.style.display="none");continue}let n=("value"===e||"checked"===e||"selected"===e)&&e in t;if("function"==typeof u){let r,l=!1,i=!0,a=m(()=>{r=u();let o=()=>{l=!1;let o=r;n?t[e]=o??"":null==o||!1===o?t.removeAttribute(e):t.setAttribute(e,String(o))};i?(i=!1,o()):l||(l=!0,R(o))});o.push(a)}else n?t[e]=u??"":null!=u&&!1!==u&&t.setAttribute(e,String(u));continue}let f=c;if(!f)continue;let d=document.createTextNode("");if(f.parentNode.replaceChild(d,f),"function"!=typeof u){if(x(u))ae(u,d.parentNode,d,l,o);else if(P(u)){let e=u._render(d.parentNode,d);o.push(e)}else if(Array.isArray(u))for(let e of u)x(e)?ae(e,d.parentNode,d,l,o):P(e)?e._render(d.parentNode,d):null!=e&&!1!==e&&d.parentNode.insertBefore(document.createTextNode(String(e)),d);else null!=u&&!1!==u&&d.parentNode.insertBefore(document.createTextNode(String(u)),d);continue}let p=null,h=null,v=null,y=[],g=null,_=w(),b=!1,N="",E=!0,S=m(()=>{let e=u();if("string"==typeof e||"number"==typeof e){N=String(e);let t=()=>{b=!1,h&&=(h(),null),p?p.nodeValue=N:(p=document.createTextNode(N),d.parentNode.insertBefore(p,d))};return void(E?(E=!1,t()):b||(b=!0,R(t)))}if(b=!1,E=!1,p&&=(p.parentNode?.removeChild(p),null),h&&=(h(),null),null!=e&&!1!==e)if(P(e))h=e._render(d.parentNode,d);else if(x(e))h=j(e,d.parentNode,d,_);else if(_e(e)){v||(v=new Map,g=document.createTextNode(""),d.parentNode.insertBefore(g,d));let t=d.parentNode,n=e.items.map((t,n)=>e.keyFn(t,n)),r=new Set(n),o=!1;if(v.size>0)for(let e of v.keys())if(r.has(e)){o=!0;break}if(!o){if(v.size>0){let e=document.createRange();e.setStartAfter(g),e.setEndBefore(d),e.deleteContents();for(let e of v.values())e.cleanup();v.clear()}if(n.length>0){let r=document.createDocumentFragment();for(let t=0;t<n.length;t++){let o=n[t],l=e.items[t],i=document.createTextNode(""),a=document.createTextNode("");r.appendChild(i),r.appendChild(a);let u=e.renderFn(l,t),s=x(u)?j(u,r,a,_):u._render(r,a);v.set(o,{start:i,end:a,cleanup:s})}t.insertBefore(r,d)}return void(y=n)}let l=new Map;for(let e=0;e<n.length;e++)l.set(n[e],e);let i=new Int32Array(n.length),a=!1,u=0;for(let e=0;e<y.length;e++){let t=y[e],n=l.get(t);if(void 0===n){let e=v.get(t);e.cleanup();let n=e.start;for(;n;){let t=n===e.end?null:n.nextSibling;if(n.parentNode?.removeChild(n),!t)break;n=t}v.delete(t)}else i[n]=e+1,n>=u?u=n:a=!0}let s=a?Se(i):[],c=s.length-1,f=d;for(let r=n.length-1;r>=0;r--){let o=n[r];if(0===i[r]){let n=e.items[r],l=document.createTextNode(""),i=document.createTextNode(""),a=document.createDocumentFragment();a.appendChild(l),a.appendChild(i);let u=e.renderFn(n,r),s=x(u)?j(u,a,i,_):u._render(a,i);v.set(o,{start:l,end:i,cleanup:s}),t.insertBefore(a,f),f=l}else{let e=v.get(o);if(a)if(c<0||r!==s[c]){let n=e.start;for(;n;){let r=n===e.end?null:n.nextSibling;if(t.insertBefore(n,f),!r)break;n=r}}else c--;f=e.start}}y=n}else if(Array.isArray(e)){let t=[];for(let n of e)if(x(n))t.push(re(n,d.parentNode,d));else if(P(n))t.push(n._render(d.parentNode,d));else if(null!=n&&!1!==n){let e=document.createTextNode(String(n));d.parentNode.insertBefore(e,d),t.push(()=>e.parentNode?.removeChild(e))}h=()=>t.forEach(e=>e())}else p=document.createTextNode(String(e)),d.parentNode.insertBefore(p,d)});o.push(()=>{if(S(),h&&=(h(),null),p&&=(p.parentNode?.removeChild(p),null),v){for(let e of v.values())e.cleanup();v=null,g=null}})}return{disposes:o,postMountHooks:l}}function Se(e){let t,n,r,o,l,i=e.slice(),a=[0],u=e.length;for(t=0;t<u;t++){let u=e[t];if(0!==u){if(n=a[a.length-1],e[n]<u){i[t]=n,a.push(t);continue}for(r=0,o=a.length-1;r<o;)l=r+o>>1,e[a[l]]<u?r=l+1:o=l;u<e[a[r]]&&(r>0&&(i[t]=a[r-1]),a[r]=t)}}for(r=a.length,o=a[r-1];r-- >0;)a[r]=o,o=i[o];return a}var z=new WeakMap;function B(e,...t){let n=z.get(e);if(!n){let t=[],r="";for(let n=0;n<e.length-1;n++)r+=e[n],t.push(he(r)),r+="__nix__";let o=document.createElement("template");o.innerHTML=ge(e,t);let l,i=Array(t.length).fill(null),a=o.content,u=document.createTreeWalker(a,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_COMMENT),s=0;for(;l=u.nextNode();)if(s++,8===l.nodeType){let e=l.nodeValue;if(e&&e.startsWith("nix-")){let t=parseInt(e.slice(4),10);isNaN(t)||(i[t]={nodeIndex:s})}}else if(1===l.nodeType){let e=l,t=Array.from(e.attributes);for(let n=0;n<t.length;n++){let r=t[n],o=r.name;if(o.startsWith("data-nix-e-")){let t=parseInt(o.slice(11),10);isNaN(t)||(i[t]={nodeIndex:s,name:r.value},e.removeAttribute(o));continue}if(o.startsWith("data-nix-a-")){let t=parseInt(o.slice(11),10);isNaN(t)||(i[t]={nodeIndex:s,name:r.value},e.removeAttribute(o))}}}n={contexts:t,tpl:o,pathMap:i},z.set(e,n)}let{contexts:r,tpl:o,pathMap:l}=n;function i(e,n){let i=o.content.cloneNode(!0),{disposes:a,postMountHooks:u}=xe(i,r,t,l),s=document.createTextNode("");return e.insertBefore(s,n),e.insertBefore(i,n),u.forEach(e=>e()),()=>{for(let e=a.length-1;e>=0;e--)a[e]();let e=s.nextSibling;for(;e&&e!==n;){let t=e.nextSibling;e.parentNode?.removeChild(e),e=t}s.parentNode?.removeChild(s)}}return{__isNixTemplate:!0,_render:i,mount(e){let t="string"==typeof e?document.querySelector(e):e;if(!t)throw Error(`[Nix] mount: contenedor no encontrado: ${e}`);let n=i(t,null);return{unmount(){n()}}}}}function Ce(e,t){if(x(e)){let n,r,o="string"==typeof t?document.querySelector(t):t;if(!o)throw Error(`[Nix] mount: container not found: ${t}`);T();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}n=e.render()._render(o,null)}finally{E()}try{let t=e.onMount?.();"function"==typeof t&&(r=t)}catch(t){if(!e.onError)throw t;e.onError(t)}return{unmount(){try{e.onUnmount?.()}catch{}try{r?.()}catch{}n()}}}return e.mount(t)}function we(e,t){let n={},r=new Set(["$reset","$patch","$state"]);for(let t of Object.keys(e)){if(r.has(t))throw Error(`[Nix] Store key "${t}" is reserved.`);n[t]=p(e[t])}let o=n;let l=Object.assign(Object.create(null),o,{$reset:function(){for(let t of Object.keys(e))n[t].value=e[t]},$patch:function(e){for(let t of Object.keys(e))t in n&&(n[t].value=e[t])}});if(Object.defineProperty(l,"$state",{get(){let e={};for(let t in n)e[t]=n[t].value;return e},enumerable:!0,configurable:!1}),t){let e=t(o);for(let t of Object.keys(e))r.has(t)?console.warn(`[Nix] Store action name "${t}" is reserved and will be ignored.`):l[t]=e[t]}return l}var V=null,H=null;function U(){if(!V)throw Error("[Nix] No active router. Call createRouter() first.");return V}function W(e){let t={};return new URLSearchParams(e).forEach((e,n)=>{t[n]=e}),t}function Te(e){let t=new URLSearchParams;for(let[n,r]of Object.entries(e))null!=r&&!1!==r&&t.set(n,String(r));let n=t.toString();return n?"?"+n:""}function Ee(e){return"*"===e?[{kind:"wildcard"}]:e.split("/").filter(Boolean).map(e=>"*"===e?{kind:"wildcard"}:e.startsWith(":")?{kind:"param",name:e.slice(1)}:{kind:"literal",value:e})}function De(e,t){return"*"===t?""===e?"*":e+"/*":(e+(t.startsWith("/")?t:"/"+t)).replace(/\/+/g,"/")||"/"}function G(e,t="",n=[]){let r=[];for(let o of e){let e=De(t,o.path),l=[...n,o.component],i=Ee(e);r.push({fullPath:e,segments:i,chain:l,beforeEnter:o.beforeEnter}),o.children?.length&&r.push(...G(o.children,e,l))}return r}function Oe(e,t){let n=e.split("/").filter(Boolean),r=t.segments;if(1===r.length&&"wildcard"===r[0].kind)return{};let o=r.length>0&&"wildcard"===r[r.length-1].kind,l=o?r.slice(0,-1):r;if(o){if(n.length<l.length)return null}else if(n.length!==l.length)return null;let i={};for(let e=0;e<l.length;e++){let t=l[e];if("literal"===t.kind){if(n[e]!==t.value)return null}else if("param"===t.kind)try{i[t.name]=decodeURIComponent(n[e]??"")}catch{i[t.name]=n[e]??""}}return i}function ke(e){return e.segments.reduce((e,t)=>"literal"===t.kind?e+2:"param"===t.kind?e+1:e,0)}function K(e,t){let n,r={},o=-1;for(let l of t){let t=Oe(e,l);if(null===t)continue;let i=ke(l);i>o&&(n=l,r=t,o=i)}return n?{route:n,params:r}:void 0}function q(e){let t=e.trim();return t&&"/"!==t?(t.startsWith("/")||(t="/"+t),t.endsWith("/")&&(t=t.slice(0,-1)),t):""}function Ae(){if(typeof document>"u")return"";let e=document.querySelector("base");if(!e)return"";let t=e.getAttribute("href")||"";try{return q(new URL(t,window.location.origin).pathname)}catch{return q(t)}}function je(e,t){let n=null==t?.base?Ae():q(t.base);function r(){let e=window.location.pathname||"/";if(n&&e.startsWith(n)){let t=e.slice(n.length);return""===t?"/":t}return e}function o(e){return n?n+(e.startsWith("/")?e:"/"+e):e}let l=r(),i=G(e),a=K(l,i),u=p(l),s=p(a?.params??{}),c=p(W(window.location.search)),f=[],d=[],h=0;function m(e,t,n,r,o){let l=[...f];n&&l.push(n);let i=++h;if(0===l.length)return void r();let a=0;!function n(u){if(i!==h)return;if(!1===u)return void o?.();if("string"==typeof u)return void(u===e?r():_(u));if(a>=l.length)return void r();let s=l[a++](e,t);s instanceof Promise?s.then(n):n(s)}(void 0)}let v=!1;function y(e,t){let n=e.indexOf("?"),r=-1===n?e:e.slice(0,n),o=-1===n?{}:W(e.slice(n)),l=t?{...o,...t}:o,i={};for(let[e,t]of Object.entries(l))null!=t&&!1!==t&&(i[e]=String(t));return{pathname:r,stringQuery:i}}H&&=(H(),null);let x=()=>{let e=r(),t=u.value,n=c.value,l=K(e,i),a=W(window.location.search);m(e,t,l?.route.beforeEnter,()=>{s.value=l?.params??{},c.value=a,u.value=e;for(let n of d)try{n(e,t)}catch{}},()=>{history.pushState(null,"",o(t)+Te(n))})};function g(e,t,n,r,l){s.value=r?.params??{},c.value=t,u.value=e;let i=o(e)+Te(t);l?history.replaceState(null,"",i):history.pushState(null,"",i);for(let t of d)try{t(e,n)}catch{}}function _(e,t){v=!0;let{pathname:n,stringQuery:r}=y(e,t),o=u.value,l=K(n,i);m(n,o,l?.route.beforeEnter,()=>g(n,r,o,l,!1))}window.addEventListener("popstate",x),H=()=>window.removeEventListener("popstate",x);let b={current:u,params:s,query:c,base:n||"/",navigate:_,replace:function(e,t){v=!0;let{pathname:n,stringQuery:r}=y(e,t),o=u.value,l=K(n,i);m(n,o,l?.route.beforeEnter,()=>g(n,r,o,l,!0))},back:function(){history.back()},forward:function(){history.forward()},go:function(e){history.go(e)},isActive:function(e,t=!0){let n=u.value;return t?n===e:n===e||n.startsWith(e.endsWith("/")?e:e+"/")},resolve:function(t){let n=K(t,i);if(!n)return{matched:!1,params:{},route:void 0};let r=n.route.chain[n.route.chain.length-1];return{matched:!0,params:n.params,route:function e(t){for(let n of t){if(n.component===r)return n;if(n.children){let t=e(n.children);if(t)return t}}}(e)}},beforeEach:function(e){return f.push(e),()=>{let t=f.indexOf(e);-1!==t&&f.splice(t,1)}},afterEach:function(e){return d.push(e),()=>{let t=d.indexOf(e);-1!==t&&d.splice(t,1)}},routes:e,_flat:i,_guards:f,_base:n};return V&&console.warn("[Nix] A router already exists. The previous router is being replaced. Only one router instance should be active at a time."),V=b,queueMicrotask(()=>{v||m(l,"",K(l,i)?.route.beforeEnter,()=>{},()=>{history.replaceState(null,"",o("/"));let e=K("/",i);u.value="/",s.value=e?.params??{},c.value={}})}),b}function Me(){return U()}var Ne=class extends b{_depth;constructor(e=0){super(),this._depth=e}render(){let e=this._depth;return B`<div class="router-view">${()=>{let t=U(),n=K(t.current.value,t._flat);return n?e>=n.route.chain.length?B`<span></span>`:n.route.chain[e]():B`<div style="color:#f87171;padding:16px 0">
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var e=null,t=[],n=null,r=[],i=null,a=[];function o(e){a.push(i),i=e}function s(){i=a.pop()??null}var c=0,l=new Set,u=100,d=0,f=class{_value;_subs=new Set;constructor(e){this._value=e}get value(){return e&&(this._subs.add(e),n?.add(this)),this._value}set value(e){Object.is(this._value,e)||(this._value=e,this._notify())}update(e){this.value=e(this._value)}peek(){return this._value}_removeSub(e){this._subs.delete(e)}_notify(){if(c>0)for(let e of this._subs)l.add(e);else{let e=Array.from(this._subs);for(let t=0;t<e.length;t++)e[t]()}}dispose(){this._subs.clear()}};function p(e){return new f(e)}function m(o){let l,a=!1,s=new Set,c=new Set,f=i,p=()=>{if(a)return;"function"==typeof l&&l();let i=s;if(s=c,c=i,c.clear(),t.push(e),r.push(n),e=p,n=c,++d>u)throw d=0,e=t.pop()||null,n=r.pop()||null,Error("[Nix] Maximum effect re-execution depth exceeded (possible infinite loop).");try{l=o()}catch(e){if(!f)throw e;f(e)}finally{d--,e=t.pop()||null,n=r.pop()||null;for(let e of s)c.has(e)||e._removeSub(p)}};return p(),()=>{a=!0,"function"==typeof l&&l();for(let e of c)e._removeSub(p);c.clear(),s.clear()}}function h(e){let t=new f(void 0),n=m(()=>{t.value=e()}),r=t.dispose;return t.dispose=()=>{n(),r.call(t)},t}function g(e){c++;try{e()}finally{if(0===--c&&l.size>0){for(let e of l)e();l.clear()}}}function _(t){let r=e,o=n;e=null,n=null;try{return t()}finally{e=r,n=o}}function v(e,t,n={}){let r,{immediate:o=!1,once:l=!1}=n,i=e instanceof f?()=>e.value:e,a=!0,u=!1,s=m(()=>{let e=i();if(a){if(a=!1,o&&!u){let n=e;_(()=>t(n,void 0)),l&&(u=!0,Promise.resolve().then(s))}r=e}else if(!u){let n=e,o=r;r=e,_(()=>t(n,o)),l&&(u=!0,Promise.resolve().then(s))}});return()=>{u=!0,s()}}function y(e){return e?Promise.resolve().then(e):Promise.resolve()}var b=class{__isNixComponent=!0;children;_slots=new Map;setChildren(e){return this.children=e,this}setSlot(e,t){return this._slots.set(e,t),this}slot(e){return this._slots.get(e)}};function x(e){return"object"==typeof e&&!!e&&!0===e.__isNixComponent}function S(e){return Symbol(e)}var C=[];function w(){return[...C]}function T(){C.push(new Map)}function E(){C.pop()}function D(e,t){let n=C.splice(0);e.forEach(e=>C.push(e)),C.push(new Map);try{return t()}finally{C.splice(0),n.forEach(e=>C.push(e))}}function O(e,t){let n=C[C.length-1];if(!n)throw Error("[Nix] provide() must be called inside onInit() of a NixComponent.");n.set(e,t)}function k(e){for(let t=C.length-1;t>=0;t--)if(C[t].has(e))return C[t].get(e)}var A={SCOPE:"nix-scope",ERROR_BOUNDARY:"nix-eb",TRANSITION:"nix-t",KEYED_START:"nix-ks",KEYED_END:"nix-ke",KEYED_ZONE:"nix-kz"};function ee(){return{el:null}}function te(e,t){t?"none"===e.style.display&&(e.style.display=""):"none"!==e.style.display&&(e.style.display="none")}function ne(e,t,n){return{__isKeyedList:!0,items:e,keyFn:t,renderFn:n}}function re(e,t,n){let r,o;T();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}r=e.render()._render(t,n)}finally{E()}try{let t=e.onMount?.();"function"==typeof t&&(o=t)}catch(t){if(!e.onError)throw t;e.onError(t)}return()=>{try{e.onUnmount?.()}catch{}try{o?.()}catch{}r()}}function ie(e,t,n){let r,o;T();try{try{e.onInit?.()}catch{}r=e.render()._render(t,n)}finally{E()}try{let t=e.onMount?.();"function"==typeof t&&(o=t)}catch{}return()=>{try{e.onUnmount?.()}catch{}try{o?.()}catch{}r()}}function j(e,t,n,r){let o,l;D(r,()=>{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}o=e.render()._render(t,n)});try{let t=e.onMount?.();"function"==typeof t&&(l=t)}catch(t){if(!e.onError)throw t;e.onError(t)}return()=>{try{e.onUnmount?.()}catch{}try{l?.()}catch{}o()}}function ae(e,t,n,r,o){let l,i;T();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}l=e.render()._render(t,n)}finally{E()}r.push(()=>{try{let t=e.onMount?.();"function"==typeof t&&(i=t)}catch(t){if(!e.onError)throw t;e.onError(t)}}),o.push(()=>{try{e.onUnmount?.()}catch{}try{i?.()}catch{}l()})}function oe(){return{__isPortalOutlet:!0,_container:null}}function se(e){return{__isNixTemplate:!0,mount(e){let t="string"==typeof e?document.querySelector(e)??document.body:e;return{unmount:this._render(t,null)}},_render(t,n){let r=document.createElement("div");return r.setAttribute("data-nix-outlet",""),e._container=r,t.insertBefore(r,n),()=>{e._container=null,r.remove()}}}}function ce(e,t=document.body){return{__isNixTemplate:!0,mount(e){let t="string"==typeof e?document.querySelector(e)??document.body:e;return{unmount:this._render(t,null)}},_render(n,r){let o;return o="string"==typeof t?document.querySelector(t)??document.body:t instanceof Element?t:"__isPortalOutlet"in t?t._container??document.body:t.el??document.body,x(e)?re(e,o,null):e._render(o,null)}}}var M=S("nix:portal-outlet");function le(e){O(M,e)}function ue(){return k(M)}function de(e,t){return{__isNixTemplate:!0,mount(e){let t="string"==typeof e?document.querySelector(e)??document.body:e;return{unmount:this._render(t,null)}},_render(n,r){let l=document.createComment(A.ERROR_BOUNDARY);n.insertBefore(l,r);let i,a=null,u=!1,c=!1,f=!1,d=e=>{let n=l.parentNode,o="function"!=typeof t||x(t)?t:t(e);a=x(o)?ie(o,n,r):o._render(n,r)};o(e=>{u||(u=!0,c?(a?.(),a=null,d(e)):(i=e,f=!0))});try{if(x(e)){T();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}a=e.render()._render(n,r)}finally{E()}if(!u)try{let t=e.onMount?.(),n=a;a=()=>{try{e.onUnmount?.()}catch{}if("function"==typeof t)try{t()}catch{}n?.()}}catch(t){if(!e.onError)throw t;e.onError(t)}}else a=e._render(n,r)}catch(e){u=!0,a?.(),a=null,i=e,f=!0}finally{s(),c=!0}return f&&(a?.(),a=null,d(i)),()=>{a?.(),l.remove()}}}}function fe(e){let t=e.name??"nix";return{enterFrom:e.enterFrom??`${t}-enter-from`,enterActive:e.enterActive??`${t}-enter-active`,enterTo:e.enterTo??`${t}-enter-to`,leaveFrom:e.leaveFrom??`${t}-leave-from`,leaveActive:e.leaveActive??`${t}-leave-active`,leaveTo:e.leaveTo??`${t}-leave-to`}}function pe(e){return Math.max(0,...e.split(",").map(e=>parseFloat(e.trim())||0))}function N(e,t=0){return new Promise(n=>{let r=getComputedStyle(e),o=1e3*Math.max(pe(r.transitionDuration||"0"),pe(r.animationDuration||"0")),l=o>0?o+100:t;if(l<=0)return void n();let i,a=t=>{t.target===e&&(clearTimeout(i),e.removeEventListener("transitionend",a),e.removeEventListener("animationend",a),n())};e.addEventListener("transitionend",a),e.addEventListener("animationend",a),i=setTimeout(()=>{e.removeEventListener("transitionend",a),e.removeEventListener("animationend",a),n()},l)})}function me(e,t={}){let n=fe(t);return{__isNixTemplate:!0,mount(e){let t="string"==typeof e?document.querySelector(e)??document.body:e;return{unmount:this._render(t,null)}},_render(r,o){let l=document.createComment(A.TRANSITION);r.insertBefore(l,o);let i=null,a=null,u=0,s=!0,c=()=>{let e=l.nextSibling;for(;e&&e!==o;){if(e.nodeType===Node.ELEMENT_NODE)return e;e=e.nextSibling}return null};function f(e){return x(e)?ie(e,r,o):e._render(r,o)}let d=(e,r=!1)=>{u++,a&&=(a(),null),i=f(e);let o=c();if(o&&(!s||t.appear)&&!r){let e=u;(async()=>{t.onBeforeEnter?.(o),o.classList.add(n.enterFrom,n.enterActive),o.getBoundingClientRect(),await new Promise(e=>requestAnimationFrame(()=>e())),u===e&&(o.classList.remove(n.enterFrom),o.classList.add(n.enterTo),await N(o,t.duration),u===e&&(o.classList.remove(n.enterActive,n.enterTo),t.onAfterEnter?.(o)))})().catch(()=>{})}s=!1},p=()=>{let e=i;i=null;let r=c();if(!r)return void e?.();let o=++u;a=e??null,(async()=>{t.onBeforeLeave?.(r),r.classList.add(n.leaveFrom,n.leaveActive),r.getBoundingClientRect(),await new Promise(e=>requestAnimationFrame(()=>e())),u===o&&(r.classList.remove(n.leaveFrom),r.classList.add(n.leaveTo),await N(r,t.duration),u===o&&(r.classList.remove(n.leaveActive,n.leaveTo),t.onAfterLeave?.(r),a?.(),a=null))})().catch(()=>{})},h=null;if("function"!=typeof e||x(e))d(e);else{let t=e,n=null;h=m(()=>{let e=t(),r=null===n,o=null===e;r&&!o?d(e):!r&&o?p():!r&&!o&&(u++,a?.(),a=null,i?.(),i=null,d(e,!0)),n=e}),s=!1}return()=>{u++,h?.(),i?.(),a?.(),i=null,a=null,l.remove()}}}}function he(e){let t=e.lastIndexOf(">"),n=e.lastIndexOf("<");if(n<=t)return{type:"node"};let r=e.slice(n+1),o=r.lastIndexOf("=");if(-1===o)return{type:"node"};let l=r.endsWith('"')||r.endsWith("'")||'"'===r[r.length-1]||"'"===r[r.length-1],i=o-1;for(;i>=0&&/\S/.test(r[i]);)i--;i++;let a=r.slice(i,o);if("@"===a[0]){let e=a.slice(1).split(".");return{type:"event",eventName:e[0],modifiers:e.slice(1),hadOpenQuote:l}}return{type:"attr",attrName:a,hadOpenQuote:l}}function ge(e,t){let n=new Uint8Array(e.length),r="";for(let o=0;o<e.length;o++){let l=e[o];if(1===n[o]&&('"'===l[0]||"'"===l[0])&&(l=l.slice(1)),o<t.length){let e=t[o];if("node"===e.type)r+=l+`\x3c!--nix-${o}--\x3e`;else if("event"===e.type){let t=`@${e.modifiers.length?`${e.eventName}.${e.modifiers.join(".")}`:e.eventName}=`.length+(e.hadOpenQuote?1:0);r+=l.slice(0,-t)+` data-nix-e-${o}="${e.eventName}"`,e.hadOpenQuote&&(n[o+1]=1)}else{let t=`${e.attrName}=`.length+(e.hadOpenQuote?1:0);r+=l.slice(0,-t)+` data-nix-a-${o}="${e.attrName}"`,e.hadOpenQuote&&(n[o+1]=1)}}else r+=l}return r}function P(e){return"object"==typeof e&&!!e&&!0===e.__isNixTemplate}function _e(e){return"object"==typeof e&&!!e&&!0===e.__isKeyedList}var ve={enter:"Enter",escape:"Escape",space:" ",tab:"Tab",delete:"Delete",backspace:"Backspace",up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight"},ye=new Set(["click","dblclick","mousedown","mouseup","keydown","keyup","input","change","submit"]),F=new Set;function be(e){let t=e.target,n=`__nix_${e.type}`,r=`__nix_${e.type}_mods`,o=e.stopPropagation,l=!1;for(e.stopPropagation=()=>{l=!0,o.call(e)};t&&t!==document;){let o=t[n];if(o){let n=t[r];if(n){if(n.includes("prevent")&&e.preventDefault(),n.includes("stop")&&e.stopPropagation(),n.includes("self")&&e.target!==t){t=t.parentNode;continue}if("key"in e){let r=e,o=!0;for(let e of n){let t=ve[e];if(void 0!==t&&r.key!==t){o=!1;break}if(!t&&1===e.length&&r.key.toLowerCase()!==e){o=!1;break}}if(!o){t=t.parentNode;continue}}}if(o(e),l)break}t=t.parentNode}e.stopPropagation=o}var I=new Set,L=!1;function R(e){I.add(e),L||(L=!0,queueMicrotask(()=>{for(let e of I)e();I.clear(),L=!1}))}function xe(e,t,n,r){let o=[],l=[],i=Array(t.length),a=-1;for(let e=0;e<t.length;e++)r[e]&&r[e].nodeIndex>a&&(a=r[e].nodeIndex);let u=[e];if(a>0){let t,n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_COMMENT),r=0;for(;r<a&&(t=n.nextNode());)r++,u.push(t)}for(let e=0;e<t.length;e++){let t=r[e];i[e]=t?u[t.nodeIndex]:null}for(let e=0;e<t.length;e++){let a=t[e],u=n[e],s=r[e];if(!s)continue;let c=i[e];if("event"===a.type){let e=s.name,t=u,n=a.modifiers;if(!ye.has(e)||n.includes("capture")||n.includes("once")){let r={once:n.includes("once"),capture:n.includes("capture"),passive:n.includes("passive")},l=e=>{n.includes("prevent")&&e.preventDefault(),n.includes("stop")&&e.stopPropagation(),(!n.includes("self")||e.target===e.currentTarget)&&t(e)};c.addEventListener(e,l,r),o.push(()=>c.removeEventListener(e,l,r))}else F.has(e)||(document.addEventListener(e,be),F.add(e)),c[`__nix_${e}`]=t,n.length>0&&(c[`__nix_${e}_mods`]=n),o.push(()=>{c[`__nix_${e}`]=null,c[`__nix_${e}_mods`]=null});continue}if("attr"===a.type){let e=s.name,t=c;if("ref"===e){u.el=t,o.push(()=>{u.el=null});continue}if("show"===e||"hide"===e){let n=t,r=null;if("function"==typeof u){let t=!1,l=!1,i=!0,a=m(()=>{l=!!u();let o=()=>{t=!1;let o="show"===e?l:!l;null===r&&(r=n.style.display||""),n.style.display=o?r:"none"};i?(i=!1,o()):t||(t=!0,R(o))});o.push(a)}else("show"===e?u:!u)||(n.style.display="none");continue}let n=("value"===e||"checked"===e||"selected"===e)&&e in t;if("function"==typeof u){let r,l=!1,i=!0,a=m(()=>{r=u();let o=()=>{l=!1;let o=r;n?t[e]=o??"":null==o||!1===o?t.removeAttribute(e):t.setAttribute(e,String(o))};i?(i=!1,o()):l||(l=!0,R(o))});o.push(a)}else n?t[e]=u??"":null!=u&&!1!==u&&t.setAttribute(e,String(u));continue}let f=c;if(!f)continue;let d=document.createTextNode("");if(f.parentNode.replaceChild(d,f),"function"!=typeof u){if(x(u))ae(u,d.parentNode,d,l,o);else if(P(u)){let e=u._render(d.parentNode,d);o.push(e)}else if(Array.isArray(u))for(let e of u)x(e)?ae(e,d.parentNode,d,l,o):P(e)?e._render(d.parentNode,d):null!=e&&!1!==e&&d.parentNode.insertBefore(document.createTextNode(String(e)),d);else null!=u&&!1!==u&&d.parentNode.insertBefore(document.createTextNode(String(u)),d);continue}let p=null,h=null,v=null,y=[],g=null,_=w(),b=!1,N="",E=!0,S=m(()=>{let e=u();if("string"==typeof e||"number"==typeof e){N=String(e);let t=()=>{b=!1,h&&=(h(),null),p?p.nodeValue=N:(p=document.createTextNode(N),d.parentNode.insertBefore(p,d))};return void(E?(E=!1,t()):b||(b=!0,R(t)))}if(b=!1,E=!1,p&&=(p.parentNode?.removeChild(p),null),h&&=(h(),null),null!=e&&!1!==e)if(P(e))h=e._render(d.parentNode,d);else if(x(e))h=j(e,d.parentNode,d,_);else if(_e(e)){v||(v=new Map,g=document.createTextNode(""),d.parentNode.insertBefore(g,d));let t=d.parentNode,n=e.items.map((t,n)=>e.keyFn(t,n)),r=new Set(n),o=!1;if(v.size>0)for(let e of v.keys())if(r.has(e)){o=!0;break}if(!o){if(v.size>0){let e=document.createRange();e.setStartAfter(g),e.setEndBefore(d),e.deleteContents();for(let e of v.values())e.cleanup();v.clear()}if(n.length>0){let r=document.createDocumentFragment();for(let t=0;t<n.length;t++){let o=n[t],l=e.items[t],i=document.createTextNode(""),a=document.createTextNode("");r.appendChild(i),r.appendChild(a);let u=e.renderFn(l,t),s=x(u)?j(u,r,a,_):u._render(r,a);v.set(o,{start:i,end:a,cleanup:s})}t.insertBefore(r,d)}return void(y=n)}let l=new Map;for(let e=0;e<n.length;e++)l.set(n[e],e);let i=new Int32Array(n.length),a=!1,u=0;for(let e=0;e<y.length;e++){let t=y[e],n=l.get(t);if(void 0===n){let e=v.get(t);e.cleanup();let n=e.start;for(;n;){let t=n===e.end?null:n.nextSibling;if(n.parentNode?.removeChild(n),!t)break;n=t}v.delete(t)}else i[n]=e+1,n>=u?u=n:a=!0}let s=a?Se(i):[],c=s.length-1,f=d;for(let r=n.length-1;r>=0;r--){let o=n[r];if(0===i[r]){let n=e.items[r],l=document.createTextNode(""),i=document.createTextNode(""),a=document.createDocumentFragment();a.appendChild(l),a.appendChild(i);let u=e.renderFn(n,r),s=x(u)?j(u,a,i,_):u._render(a,i);v.set(o,{start:l,end:i,cleanup:s}),t.insertBefore(a,f),f=l}else{let e=v.get(o);if(a)if(c<0||r!==s[c]){let n=e.start;for(;n;){let r=n===e.end?null:n.nextSibling;if(t.insertBefore(n,f),!r)break;n=r}}else c--;f=e.start}}y=n}else if(Array.isArray(e)){let t=[];for(let n of e)if(x(n))t.push(re(n,d.parentNode,d));else if(P(n))t.push(n._render(d.parentNode,d));else if(null!=n&&!1!==n){let e=document.createTextNode(String(n));d.parentNode.insertBefore(e,d),t.push(()=>e.parentNode?.removeChild(e))}h=()=>t.forEach(e=>e())}else p=document.createTextNode(String(e)),d.parentNode.insertBefore(p,d)});o.push(()=>{if(S(),h&&=(h(),null),p&&=(p.parentNode?.removeChild(p),null),v){for(let e of v.values())e.cleanup();v=null,g=null}})}return{disposes:o,postMountHooks:l}}function Se(e){let t,n,r,o,l,i=e.slice(),a=[0],u=e.length;for(t=0;t<u;t++){let u=e[t];if(0!==u){if(n=a[a.length-1],e[n]<u){i[t]=n,a.push(t);continue}for(r=0,o=a.length-1;r<o;)l=r+o>>1,e[a[l]]<u?r=l+1:o=l;u<e[a[r]]&&(r>0&&(i[t]=a[r-1]),a[r]=t)}}for(r=a.length,o=a[r-1];r-- >0;)a[r]=o,o=i[o];return a}var z=new WeakMap;function B(e,...t){let n=z.get(e);if(!n){let t=[],r="";for(let n=0;n<e.length-1;n++)r+=e[n],t.push(he(r)),r+="__nix__";let o=document.createElement("template");o.innerHTML=ge(e,t);let l,i=Array(t.length).fill(null),a=o.content,u=document.createTreeWalker(a,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_COMMENT),s=0;for(;l=u.nextNode();)if(s++,8===l.nodeType){let e=l.nodeValue;if(e&&e.startsWith("nix-")){let t=parseInt(e.slice(4),10);isNaN(t)||(i[t]={nodeIndex:s})}}else if(1===l.nodeType){let e=l,t=Array.from(e.attributes);for(let n=0;n<t.length;n++){let r=t[n],o=r.name;if(o.startsWith("data-nix-e-")){let t=parseInt(o.slice(11),10);isNaN(t)||(i[t]={nodeIndex:s,name:r.value},e.removeAttribute(o));continue}if(o.startsWith("data-nix-a-")){let t=parseInt(o.slice(11),10);isNaN(t)||(i[t]={nodeIndex:s,name:r.value},e.removeAttribute(o))}}}n={contexts:t,tpl:o,pathMap:i},z.set(e,n)}let{contexts:r,tpl:o,pathMap:l}=n;function i(e,n){let i=document.importNode(o.content,!0),{disposes:a,postMountHooks:u}=xe(i,r,t,l),s=document.createTextNode("");return e.insertBefore(s,n),e.insertBefore(i,n),u.forEach(e=>e()),()=>{for(let e=a.length-1;e>=0;e--)a[e]();let e=s.nextSibling;for(;e&&e!==n;){let t=e.nextSibling;e.parentNode?.removeChild(e),e=t}s.parentNode?.removeChild(s)}}return{__isNixTemplate:!0,_render:i,mount(e){let t="string"==typeof e?document.querySelector(e):e;if(!t)throw Error(`[Nix] mount: contenedor no encontrado: ${e}`);let n=i(t,null);return{unmount(){n()}}}}}function Ce(e,t){if(x(e)){let n,r,o="string"==typeof t?document.querySelector(t):t;if(!o)throw Error(`[Nix] mount: container not found: ${t}`);T();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}n=e.render()._render(o,null)}finally{E()}try{let t=e.onMount?.();"function"==typeof t&&(r=t)}catch(t){if(!e.onError)throw t;e.onError(t)}return{unmount(){try{e.onUnmount?.()}catch{}try{r?.()}catch{}n()}}}return e.mount(t)}function we(e,t){let n={},r=new Set(["$reset","$patch","$state"]);for(let t of Object.keys(e)){if(r.has(t))throw Error(`[Nix] Store key "${t}" is reserved.`);n[t]=p(e[t])}let o=n;let l=Object.assign(Object.create(null),o,{$reset:function(){for(let t of Object.keys(e))n[t].value=e[t]},$patch:function(e){for(let t of Object.keys(e))t in n&&(n[t].value=e[t])}});if(Object.defineProperty(l,"$state",{get(){let e={};for(let t in n)e[t]=n[t].value;return e},enumerable:!0,configurable:!1}),t){let e=t(o);for(let t of Object.keys(e))r.has(t)?console.warn(`[Nix] Store action name "${t}" is reserved and will be ignored.`):l[t]=e[t]}return l}var V=null,H=null;function U(){if(!V)throw Error("[Nix] No active router. Call createRouter() first.");return V}function W(e){let t={};return new URLSearchParams(e).forEach((e,n)=>{t[n]=e}),t}function Te(e){let t=new URLSearchParams;for(let[n,r]of Object.entries(e))null!=r&&!1!==r&&t.set(n,String(r));let n=t.toString();return n?"?"+n:""}function Ee(e){return"*"===e?[{kind:"wildcard"}]:e.split("/").filter(Boolean).map(e=>"*"===e?{kind:"wildcard"}:e.startsWith(":")?{kind:"param",name:e.slice(1)}:{kind:"literal",value:e})}function De(e,t){return"*"===t?""===e?"*":e+"/*":(e+(t.startsWith("/")?t:"/"+t)).replace(/\/+/g,"/")||"/"}function G(e,t="",n=[]){let r=[];for(let o of e){let e=De(t,o.path),l=[...n,o.component],i=Ee(e);r.push({fullPath:e,segments:i,chain:l,beforeEnter:o.beforeEnter}),o.children?.length&&r.push(...G(o.children,e,l))}return r}function Oe(e,t){let n=e.split("/").filter(Boolean),r=t.segments;if(1===r.length&&"wildcard"===r[0].kind)return{};let o=r.length>0&&"wildcard"===r[r.length-1].kind,l=o?r.slice(0,-1):r;if(o){if(n.length<l.length)return null}else if(n.length!==l.length)return null;let i={};for(let e=0;e<l.length;e++){let t=l[e];if("literal"===t.kind){if(n[e]!==t.value)return null}else if("param"===t.kind)try{i[t.name]=decodeURIComponent(n[e]??"")}catch{i[t.name]=n[e]??""}}return i}function ke(e){return e.segments.reduce((e,t)=>"literal"===t.kind?e+2:"param"===t.kind?e+1:e,0)}function K(e,t){let n,r={},o=-1;for(let l of t){let t=Oe(e,l);if(null===t)continue;let i=ke(l);i>o&&(n=l,r=t,o=i)}return n?{route:n,params:r}:void 0}function q(e){let t=e.trim();return t&&"/"!==t?(t.startsWith("/")||(t="/"+t),t.endsWith("/")&&(t=t.slice(0,-1)),t):""}function Ae(){if(typeof document>"u")return"";let e=document.querySelector("base");if(!e)return"";let t=e.getAttribute("href")||"";try{return q(new URL(t,window.location.origin).pathname)}catch{return q(t)}}function je(e,t){let n=null==t?.base?Ae():q(t.base);function r(){let e=window.location.pathname||"/";if(n&&e.startsWith(n)){let t=e.slice(n.length);return""===t?"/":t}return e}function o(e){return n?n+(e.startsWith("/")?e:"/"+e):e}let l=r(),i=G(e),a=K(l,i),u=p(l),s=p(a?.params??{}),c=p(W(window.location.search)),f=[],d=[],h=0;function m(e,t,n,r,o){let l=[...f];n&&l.push(n);let i=++h;if(0===l.length)return void r();let a=0;!function n(u){if(i!==h)return;if(!1===u)return void o?.();if("string"==typeof u)return void(u===e?r():_(u));if(a>=l.length)return void r();let s=l[a++](e,t);s instanceof Promise?s.then(n):n(s)}(void 0)}let v=!1;function y(e,t){let n=e.indexOf("?"),r=-1===n?e:e.slice(0,n),o=-1===n?{}:W(e.slice(n)),l=t?{...o,...t}:o,i={};for(let[e,t]of Object.entries(l))null!=t&&!1!==t&&(i[e]=String(t));return{pathname:r,stringQuery:i}}H&&=(H(),null);let x=()=>{let e=r(),t=u.value,n=c.value,l=K(e,i),a=W(window.location.search);m(e,t,l?.route.beforeEnter,()=>{s.value=l?.params??{},c.value=a,u.value=e;for(let n of d)try{n(e,t)}catch{}},()=>{history.pushState(null,"",o(t)+Te(n))})};function g(e,t,n,r,l){s.value=r?.params??{},c.value=t,u.value=e;let i=o(e)+Te(t);l?history.replaceState(null,"",i):history.pushState(null,"",i);for(let t of d)try{t(e,n)}catch{}}function _(e,t){v=!0;let{pathname:n,stringQuery:r}=y(e,t),o=u.value,l=K(n,i);m(n,o,l?.route.beforeEnter,()=>g(n,r,o,l,!1))}window.addEventListener("popstate",x),H=()=>window.removeEventListener("popstate",x);let b={current:u,params:s,query:c,base:n||"/",navigate:_,replace:function(e,t){v=!0;let{pathname:n,stringQuery:r}=y(e,t),o=u.value,l=K(n,i);m(n,o,l?.route.beforeEnter,()=>g(n,r,o,l,!0))},back:function(){history.back()},forward:function(){history.forward()},go:function(e){history.go(e)},isActive:function(e,t=!0){let n=u.value;return t?n===e:n===e||n.startsWith(e.endsWith("/")?e:e+"/")},resolve:function(t){let n=K(t,i);if(!n)return{matched:!1,params:{},route:void 0};let r=n.route.chain[n.route.chain.length-1];return{matched:!0,params:n.params,route:function e(t){for(let n of t){if(n.component===r)return n;if(n.children){let t=e(n.children);if(t)return t}}}(e)}},beforeEach:function(e){return f.push(e),()=>{let t=f.indexOf(e);-1!==t&&f.splice(t,1)}},afterEach:function(e){return d.push(e),()=>{let t=d.indexOf(e);-1!==t&&d.splice(t,1)}},routes:e,_flat:i,_guards:f,_base:n};return V&&console.warn("[Nix] A router already exists. The previous router is being replaced. Only one router instance should be active at a time."),V=b,queueMicrotask(()=>{v||m(l,"",K(l,i)?.route.beforeEnter,()=>{},()=>{history.replaceState(null,"",o("/"));let e=K("/",i);u.value="/",s.value=e?.params??{},c.value={}})}),b}function Me(){return U()}var Ne=class extends b{_depth;constructor(e=0){super(),this._depth=e}render(){let e=this._depth;return B`<div class="router-view">${()=>{let t=U(),n=K(t.current.value,t._flat);return n?e>=n.route.chain.length?B`<span></span>`:n.route.chain[e]():B`<div style="color:#f87171;padding:16px 0">
2
2
  404 — Route not found: <strong>${t.current.value}</strong>
3
3
  </div>`}}</div>`}},Pe=class extends b{_to;_label;constructor(e,t){super(),this._to=e,this._label=t}render(){let e=this._to,t=this._label;return B`<a
4
4
  href=${(U()._base||"")+(e.startsWith("/")?e:"/"+e)}
@@ -1,4 +1,4 @@
1
- var e=null,t=[],n=null,r=[],i=null,a=[];function o(e){a.push(i),i=e}function s(){i=a.pop()??null}var c=0,l=new Set,u=100,d=0,f=class{_value;_subs=new Set;constructor(e){this._value=e}get value(){return e&&(this._subs.add(e),n?.add(this)),this._value}set value(e){Object.is(this._value,e)||(this._value=e,this._notify())}update(e){this.value=e(this._value)}peek(){return this._value}_removeSub(e){this._subs.delete(e)}_notify(){if(c>0)for(let e of this._subs)l.add(e);else{let e=Array.from(this._subs);for(let t=0;t<e.length;t++)e[t]()}}dispose(){this._subs.clear()}};function p(e){return new f(e)}function m(l){let o,a=!1,s=new Set,c=new Set,f=i,p=()=>{if(a)return;"function"==typeof o&&o();let i=s;if(s=c,c=i,c.clear(),t.push(e),r.push(n),e=p,n=c,++d>u)throw d=0,e=t.pop()||null,n=r.pop()||null,Error("[Nix] Maximum effect re-execution depth exceeded (possible infinite loop).");try{o=l()}catch(e){if(!f)throw e;f(e)}finally{d--,e=t.pop()||null,n=r.pop()||null;for(let e of s)c.has(e)||e._removeSub(p)}};return p(),()=>{a=!0,"function"==typeof o&&o();for(let e of c)e._removeSub(p);c.clear(),s.clear()}}function h(e){let t=new f(void 0),n=m(()=>{t.value=e()}),r=t.dispose;return t.dispose=()=>{n(),r.call(t)},t}function g(e){c++;try{e()}finally{if(0===--c&&l.size>0){for(let e of l)e();l.clear()}}}function _(t){let r=e,l=n;e=null,n=null;try{return t()}finally{e=r,n=l}}function v(e,t,n={}){let r,{immediate:l=!1,once:o=!1}=n,i=e instanceof f?()=>e.value:e,a=!0,u=!1,s=m(()=>{let e=i();if(a){if(a=!1,l&&!u){let n=e;_(()=>t(n,void 0)),o&&(u=!0,Promise.resolve().then(s))}r=e}else if(!u){let n=e,l=r;r=e,_(()=>t(n,l)),o&&(u=!0,Promise.resolve().then(s))}});return()=>{u=!0,s()}}function y(e){return e?Promise.resolve().then(e):Promise.resolve()}var b=class{__isNixComponent=!0;children;_slots=new Map;setChildren(e){return this.children=e,this}setSlot(e,t){return this._slots.set(e,t),this}slot(e){return this._slots.get(e)}};function x(e){return"object"==typeof e&&!!e&&!0===e.__isNixComponent}function S(e){return Symbol(e)}var C=[];function w(){return[...C]}function T(){C.push(new Map)}function E(){C.pop()}function D(e,t){let n=C.splice(0);e.forEach(e=>C.push(e)),C.push(new Map);try{return t()}finally{C.splice(0),n.forEach(e=>C.push(e))}}function O(e,t){let n=C[C.length-1];if(!n)throw Error("[Nix] provide() must be called inside onInit() of a NixComponent.");n.set(e,t)}function k(e){for(let t=C.length-1;t>=0;t--)if(C[t].has(e))return C[t].get(e)}var A={SCOPE:"nix-scope",ERROR_BOUNDARY:"nix-eb",TRANSITION:"nix-t",KEYED_START:"nix-ks",KEYED_END:"nix-ke",KEYED_ZONE:"nix-kz"};function ee(){return{el:null}}function te(e,t){t?"none"===e.style.display&&(e.style.display=""):"none"!==e.style.display&&(e.style.display="none")}function ne(e,t,n){return{__isKeyedList:!0,items:e,keyFn:t,renderFn:n}}function re(e,t,n){let r,l;T();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}r=e.render()._render(t,n)}finally{E()}try{let t=e.onMount?.();"function"==typeof t&&(l=t)}catch(t){if(!e.onError)throw t;e.onError(t)}return()=>{try{e.onUnmount?.()}catch{}try{l?.()}catch{}r()}}function ie(e,t,n){let r,l;T();try{try{e.onInit?.()}catch{}r=e.render()._render(t,n)}finally{E()}try{let t=e.onMount?.();"function"==typeof t&&(l=t)}catch{}return()=>{try{e.onUnmount?.()}catch{}try{l?.()}catch{}r()}}function j(e,t,n,r){let l,o;D(r,()=>{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}l=e.render()._render(t,n)});try{let t=e.onMount?.();"function"==typeof t&&(o=t)}catch(t){if(!e.onError)throw t;e.onError(t)}return()=>{try{e.onUnmount?.()}catch{}try{o?.()}catch{}l()}}function ae(e,t,n,r,l){let o,i;T();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}o=e.render()._render(t,n)}finally{E()}r.push(()=>{try{let t=e.onMount?.();"function"==typeof t&&(i=t)}catch(t){if(!e.onError)throw t;e.onError(t)}}),l.push(()=>{try{e.onUnmount?.()}catch{}try{i?.()}catch{}o()})}function oe(){return{__isPortalOutlet:!0,_container:null}}function se(e){return{__isNixTemplate:!0,mount(e){let t="string"==typeof e?document.querySelector(e)??document.body:e;return{unmount:this._render(t,null)}},_render(t,n){let r=document.createElement("div");return r.setAttribute("data-nix-outlet",""),e._container=r,t.insertBefore(r,n),()=>{e._container=null,r.remove()}}}}function ce(e,t=document.body){return{__isNixTemplate:!0,mount(e){let t="string"==typeof e?document.querySelector(e)??document.body:e;return{unmount:this._render(t,null)}},_render(n,r){let l;return l="string"==typeof t?document.querySelector(t)??document.body:t instanceof Element?t:"__isPortalOutlet"in t?t._container??document.body:t.el??document.body,x(e)?re(e,l,null):e._render(l,null)}}}var M=S("nix:portal-outlet");function le(e){O(M,e)}function ue(){return k(M)}function de(e,t){return{__isNixTemplate:!0,mount(e){let t="string"==typeof e?document.querySelector(e)??document.body:e;return{unmount:this._render(t,null)}},_render(n,r){let l=document.createComment(A.ERROR_BOUNDARY);n.insertBefore(l,r);let i,a=null,u=!1,c=!1,f=!1,d=e=>{let n=l.parentNode,o="function"!=typeof t||x(t)?t:t(e);a=x(o)?ie(o,n,r):o._render(n,r)};o(e=>{u||(u=!0,c?(a?.(),a=null,d(e)):(i=e,f=!0))});try{if(x(e)){T();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}a=e.render()._render(n,r)}finally{E()}if(!u)try{let t=e.onMount?.(),n=a;a=()=>{try{e.onUnmount?.()}catch{}if("function"==typeof t)try{t()}catch{}n?.()}}catch(t){if(!e.onError)throw t;e.onError(t)}}else a=e._render(n,r)}catch(e){u=!0,a?.(),a=null,i=e,f=!0}finally{s(),c=!0}return f&&(a?.(),a=null,d(i)),()=>{a?.(),l.remove()}}}}function fe(e){let t=e.name??"nix";return{enterFrom:e.enterFrom??`${t}-enter-from`,enterActive:e.enterActive??`${t}-enter-active`,enterTo:e.enterTo??`${t}-enter-to`,leaveFrom:e.leaveFrom??`${t}-leave-from`,leaveActive:e.leaveActive??`${t}-leave-active`,leaveTo:e.leaveTo??`${t}-leave-to`}}function pe(e){return Math.max(0,...e.split(",").map(e=>parseFloat(e.trim())||0))}function N(e,t=0){return new Promise(n=>{let r=getComputedStyle(e),l=1e3*Math.max(pe(r.transitionDuration||"0"),pe(r.animationDuration||"0")),o=l>0?l+100:t;if(o<=0)return void n();let i,a=t=>{t.target===e&&(clearTimeout(i),e.removeEventListener("transitionend",a),e.removeEventListener("animationend",a),n())};e.addEventListener("transitionend",a),e.addEventListener("animationend",a),i=setTimeout(()=>{e.removeEventListener("transitionend",a),e.removeEventListener("animationend",a),n()},o)})}function me(e,t={}){let n=fe(t);return{__isNixTemplate:!0,mount(e){let t="string"==typeof e?document.querySelector(e)??document.body:e;return{unmount:this._render(t,null)}},_render(r,l){let o=document.createComment(A.TRANSITION);r.insertBefore(o,l);let i=null,a=null,u=0,s=!0,c=()=>{let e=o.nextSibling;for(;e&&e!==l;){if(e.nodeType===Node.ELEMENT_NODE)return e;e=e.nextSibling}return null};function f(e){return x(e)?ie(e,r,l):e._render(r,l)}let d=(e,r=!1)=>{u++,a&&=(a(),null),i=f(e);let l=c();if(l&&(!s||t.appear)&&!r){let e=u;(async()=>{t.onBeforeEnter?.(l),l.classList.add(n.enterFrom,n.enterActive),l.getBoundingClientRect(),await new Promise(e=>requestAnimationFrame(()=>e())),u===e&&(l.classList.remove(n.enterFrom),l.classList.add(n.enterTo),await N(l,t.duration),u===e&&(l.classList.remove(n.enterActive,n.enterTo),t.onAfterEnter?.(l)))})().catch(()=>{})}s=!1},p=()=>{let e=i;i=null;let r=c();if(!r)return void e?.();let l=++u;a=e??null,(async()=>{t.onBeforeLeave?.(r),r.classList.add(n.leaveFrom,n.leaveActive),r.getBoundingClientRect(),await new Promise(e=>requestAnimationFrame(()=>e())),u===l&&(r.classList.remove(n.leaveFrom),r.classList.add(n.leaveTo),await N(r,t.duration),u===l&&(r.classList.remove(n.leaveActive,n.leaveTo),t.onAfterLeave?.(r),a?.(),a=null))})().catch(()=>{})},h=null;if("function"!=typeof e||x(e))d(e);else{let t=e,n=null;h=m(()=>{let e=t(),r=null===n,l=null===e;r&&!l?d(e):!r&&l?p():!r&&!l&&(u++,a?.(),a=null,i?.(),i=null,d(e,!0)),n=e}),s=!1}return()=>{u++,h?.(),i?.(),a?.(),i=null,a=null,o.remove()}}}}function he(e){let t=e.lastIndexOf(">"),n=e.lastIndexOf("<");if(n<=t)return{type:"node"};let r=e.slice(n+1),l=r.lastIndexOf("=");if(-1===l)return{type:"node"};let o=r.endsWith('"')||r.endsWith("'")||'"'===r[r.length-1]||"'"===r[r.length-1],i=l-1;for(;i>=0&&/\S/.test(r[i]);)i--;i++;let a=r.slice(i,l);if("@"===a[0]){let e=a.slice(1).split(".");return{type:"event",eventName:e[0],modifiers:e.slice(1),hadOpenQuote:o}}return{type:"attr",attrName:a,hadOpenQuote:o}}function ge(e,t){let n=new Uint8Array(e.length),r="";for(let l=0;l<e.length;l++){let o=e[l];if(1===n[l]&&('"'===o[0]||"'"===o[0])&&(o=o.slice(1)),l<t.length){let e=t[l];if("node"===e.type)r+=o+`\x3c!--nix-${l}--\x3e`;else if("event"===e.type){let t=`@${e.modifiers.length?`${e.eventName}.${e.modifiers.join(".")}`:e.eventName}=`.length+(e.hadOpenQuote?1:0);r+=o.slice(0,-t)+` data-nix-e-${l}="${e.eventName}"`,e.hadOpenQuote&&(n[l+1]=1)}else{let t=`${e.attrName}=`.length+(e.hadOpenQuote?1:0);r+=o.slice(0,-t)+` data-nix-a-${l}="${e.attrName}"`,e.hadOpenQuote&&(n[l+1]=1)}}else r+=o}return r}function P(e){return"object"==typeof e&&!!e&&!0===e.__isNixTemplate}function _e(e){return"object"==typeof e&&!!e&&!0===e.__isKeyedList}var ve={enter:"Enter",escape:"Escape",space:" ",tab:"Tab",delete:"Delete",backspace:"Backspace",up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight"},ye=new Set(["click","dblclick","mousedown","mouseup","keydown","keyup","input","change","submit"]),F=new Set;function be(e){let t=e.target,n=`__nix_${e.type}`,r=`__nix_${e.type}_mods`,l=e.stopPropagation,o=!1;for(e.stopPropagation=()=>{o=!0,l.call(e)};t&&t!==document;){let l=t[n];if(l){let n=t[r];if(n){if(n.includes("prevent")&&e.preventDefault(),n.includes("stop")&&e.stopPropagation(),n.includes("self")&&e.target!==t){t=t.parentNode;continue}if("key"in e){let r=e,l=!0;for(let e of n){let t=ve[e];if(void 0!==t&&r.key!==t){l=!1;break}if(!t&&1===e.length&&r.key.toLowerCase()!==e){l=!1;break}}if(!l){t=t.parentNode;continue}}}if(l(e),o)break}t=t.parentNode}e.stopPropagation=l}var I=new Set,L=!1;function R(e){I.add(e),L||(L=!0,queueMicrotask(()=>{for(let e of I)e();I.clear(),L=!1}))}function xe(e,t,n,r){let l=[],o=[],i=Array(t.length),a=-1;for(let e=0;e<t.length;e++)r[e]&&r[e].nodeIndex>a&&(a=r[e].nodeIndex);let u=[e];if(a>0){let t,n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_COMMENT),r=0;for(;r<a&&(t=n.nextNode());)r++,u.push(t)}for(let e=0;e<t.length;e++){let t=r[e];i[e]=t?u[t.nodeIndex]:null}for(let e=0;e<t.length;e++){let a=t[e],u=n[e],s=r[e];if(!s)continue;let c=i[e];if("event"===a.type){let e=s.name,t=u,n=a.modifiers;if(!ye.has(e)||n.includes("capture")||n.includes("once")){let r={once:n.includes("once"),capture:n.includes("capture"),passive:n.includes("passive")},o=e=>{n.includes("prevent")&&e.preventDefault(),n.includes("stop")&&e.stopPropagation(),(!n.includes("self")||e.target===e.currentTarget)&&t(e)};c.addEventListener(e,o,r),l.push(()=>c.removeEventListener(e,o,r))}else F.has(e)||(document.addEventListener(e,be),F.add(e)),c[`__nix_${e}`]=t,n.length>0&&(c[`__nix_${e}_mods`]=n),l.push(()=>{c[`__nix_${e}`]=null,c[`__nix_${e}_mods`]=null});continue}if("attr"===a.type){let e=s.name,t=c;if("ref"===e){u.el=t,l.push(()=>{u.el=null});continue}if("show"===e||"hide"===e){let n=t,r=null;if("function"==typeof u){let t=!1,o=!1,i=!0,a=m(()=>{o=!!u();let l=()=>{t=!1;let l="show"===e?o:!o;null===r&&(r=n.style.display||""),n.style.display=l?r:"none"};i?(i=!1,l()):t||(t=!0,R(l))});l.push(a)}else("show"===e?u:!u)||(n.style.display="none");continue}let n=("value"===e||"checked"===e||"selected"===e)&&e in t;if("function"==typeof u){let r,o=!1,i=!0,a=m(()=>{r=u();let l=()=>{o=!1;let l=r;n?t[e]=l??"":null==l||!1===l?t.removeAttribute(e):t.setAttribute(e,String(l))};i?(i=!1,l()):o||(o=!0,R(l))});l.push(a)}else n?t[e]=u??"":null!=u&&!1!==u&&t.setAttribute(e,String(u));continue}let f=c;if(!f)continue;let d=document.createTextNode("");if(f.parentNode.replaceChild(d,f),"function"!=typeof u){if(x(u))ae(u,d.parentNode,d,o,l);else if(P(u)){let e=u._render(d.parentNode,d);l.push(e)}else if(Array.isArray(u))for(let e of u)x(e)?ae(e,d.parentNode,d,o,l):P(e)?e._render(d.parentNode,d):null!=e&&!1!==e&&d.parentNode.insertBefore(document.createTextNode(String(e)),d);else null!=u&&!1!==u&&d.parentNode.insertBefore(document.createTextNode(String(u)),d);continue}let p=null,h=null,v=null,y=[],g=null,_=w(),b=!1,N="",E=!0,S=m(()=>{let e=u();if("string"==typeof e||"number"==typeof e){N=String(e);let t=()=>{b=!1,h&&=(h(),null),p?p.nodeValue=N:(p=document.createTextNode(N),d.parentNode.insertBefore(p,d))};return void(E?(E=!1,t()):b||(b=!0,R(t)))}if(b=!1,E=!1,p&&=(p.parentNode?.removeChild(p),null),h&&=(h(),null),null!=e&&!1!==e)if(P(e))h=e._render(d.parentNode,d);else if(x(e))h=j(e,d.parentNode,d,_);else if(_e(e)){v||(v=new Map,g=document.createTextNode(""),d.parentNode.insertBefore(g,d));let t=d.parentNode,n=e.items.map((t,n)=>e.keyFn(t,n)),r=new Set(n),l=!1;if(v.size>0)for(let e of v.keys())if(r.has(e)){l=!0;break}if(!l){if(v.size>0){let e=document.createRange();e.setStartAfter(g),e.setEndBefore(d),e.deleteContents();for(let e of v.values())e.cleanup();v.clear()}if(n.length>0){let r=document.createDocumentFragment();for(let t=0;t<n.length;t++){let l=n[t],o=e.items[t],i=document.createTextNode(""),a=document.createTextNode("");r.appendChild(i),r.appendChild(a);let u=e.renderFn(o,t),s=x(u)?j(u,r,a,_):u._render(r,a);v.set(l,{start:i,end:a,cleanup:s})}t.insertBefore(r,d)}return void(y=n)}let o=new Map;for(let e=0;e<n.length;e++)o.set(n[e],e);let i=new Int32Array(n.length),a=!1,u=0;for(let e=0;e<y.length;e++){let t=y[e],n=o.get(t);if(void 0===n){let e=v.get(t);e.cleanup();let n=e.start;for(;n;){let t=n===e.end?null:n.nextSibling;if(n.parentNode?.removeChild(n),!t)break;n=t}v.delete(t)}else i[n]=e+1,n>=u?u=n:a=!0}let s=a?Se(i):[],c=s.length-1,f=d;for(let r=n.length-1;r>=0;r--){let l=n[r];if(0===i[r]){let n=e.items[r],o=document.createTextNode(""),i=document.createTextNode(""),a=document.createDocumentFragment();a.appendChild(o),a.appendChild(i);let u=e.renderFn(n,r),s=x(u)?j(u,a,i,_):u._render(a,i);v.set(l,{start:o,end:i,cleanup:s}),t.insertBefore(a,f),f=o}else{let e=v.get(l);if(a)if(c<0||r!==s[c]){let n=e.start;for(;n;){let r=n===e.end?null:n.nextSibling;if(t.insertBefore(n,f),!r)break;n=r}}else c--;f=e.start}}y=n}else if(Array.isArray(e)){let t=[];for(let n of e)if(x(n))t.push(re(n,d.parentNode,d));else if(P(n))t.push(n._render(d.parentNode,d));else if(null!=n&&!1!==n){let e=document.createTextNode(String(n));d.parentNode.insertBefore(e,d),t.push(()=>e.parentNode?.removeChild(e))}h=()=>t.forEach(e=>e())}else p=document.createTextNode(String(e)),d.parentNode.insertBefore(p,d)});l.push(()=>{if(S(),h&&=(h(),null),p&&=(p.parentNode?.removeChild(p),null),v){for(let e of v.values())e.cleanup();v=null,g=null}})}return{disposes:l,postMountHooks:o}}function Se(e){let t,n,r,l,o,i=e.slice(),a=[0],u=e.length;for(t=0;t<u;t++){let u=e[t];if(0!==u){if(n=a[a.length-1],e[n]<u){i[t]=n,a.push(t);continue}for(r=0,l=a.length-1;r<l;)o=r+l>>1,e[a[o]]<u?r=o+1:l=o;u<e[a[r]]&&(r>0&&(i[t]=a[r-1]),a[r]=t)}}for(r=a.length,l=a[r-1];r-- >0;)a[r]=l,l=i[l];return a}var z=new WeakMap;function B(e,...t){let n=z.get(e);if(!n){let t=[],r="";for(let n=0;n<e.length-1;n++)r+=e[n],t.push(he(r)),r+="__nix__";let l=document.createElement("template");l.innerHTML=ge(e,t);let o,i=Array(t.length).fill(null),a=l.content,u=document.createTreeWalker(a,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_COMMENT),s=0;for(;o=u.nextNode();)if(s++,8===o.nodeType){let e=o.nodeValue;if(e&&e.startsWith("nix-")){let t=parseInt(e.slice(4),10);isNaN(t)||(i[t]={nodeIndex:s})}}else if(1===o.nodeType){let e=o,t=Array.from(e.attributes);for(let n=0;n<t.length;n++){let r=t[n],l=r.name;if(l.startsWith("data-nix-e-")){let t=parseInt(l.slice(11),10);isNaN(t)||(i[t]={nodeIndex:s,name:r.value},e.removeAttribute(l));continue}if(l.startsWith("data-nix-a-")){let t=parseInt(l.slice(11),10);isNaN(t)||(i[t]={nodeIndex:s,name:r.value},e.removeAttribute(l))}}}n={contexts:t,tpl:l,pathMap:i},z.set(e,n)}let{contexts:r,tpl:l,pathMap:o}=n;function i(e,n){let i=l.content.cloneNode(!0),{disposes:a,postMountHooks:u}=xe(i,r,t,o),s=document.createTextNode("");return e.insertBefore(s,n),e.insertBefore(i,n),u.forEach(e=>e()),()=>{for(let e=a.length-1;e>=0;e--)a[e]();let e=s.nextSibling;for(;e&&e!==n;){let t=e.nextSibling;e.parentNode?.removeChild(e),e=t}s.parentNode?.removeChild(s)}}return{__isNixTemplate:!0,_render:i,mount(e){let t="string"==typeof e?document.querySelector(e):e;if(!t)throw Error(`[Nix] mount: contenedor no encontrado: ${e}`);let n=i(t,null);return{unmount(){n()}}}}}function Ce(e,t){if(x(e)){let n,r,l="string"==typeof t?document.querySelector(t):t;if(!l)throw Error(`[Nix] mount: container not found: ${t}`);T();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}n=e.render()._render(l,null)}finally{E()}try{let t=e.onMount?.();"function"==typeof t&&(r=t)}catch(t){if(!e.onError)throw t;e.onError(t)}return{unmount(){try{e.onUnmount?.()}catch{}try{r?.()}catch{}n()}}}return e.mount(t)}function we(e,t){let n={},r=new Set(["$reset","$patch","$state"]);for(let t of Object.keys(e)){if(r.has(t))throw Error(`[Nix] Store key "${t}" is reserved.`);n[t]=p(e[t])}let l=n;let o=Object.assign(Object.create(null),l,{$reset:function(){for(let t of Object.keys(e))n[t].value=e[t]},$patch:function(e){for(let t of Object.keys(e))t in n&&(n[t].value=e[t])}});if(Object.defineProperty(o,"$state",{get(){let e={};for(let t in n)e[t]=n[t].value;return e},enumerable:!0,configurable:!1}),t){let e=t(l);for(let t of Object.keys(e))r.has(t)?console.warn(`[Nix] Store action name "${t}" is reserved and will be ignored.`):o[t]=e[t]}return o}var V=null,H=null;function U(){if(!V)throw Error("[Nix] No active router. Call createRouter() first.");return V}function W(e){let t={};return new URLSearchParams(e).forEach((e,n)=>{t[n]=e}),t}function Te(e){let t=new URLSearchParams;for(let[n,r]of Object.entries(e))null!=r&&!1!==r&&t.set(n,String(r));let n=t.toString();return n?"?"+n:""}function Ee(e){return"*"===e?[{kind:"wildcard"}]:e.split("/").filter(Boolean).map(e=>"*"===e?{kind:"wildcard"}:e.startsWith(":")?{kind:"param",name:e.slice(1)}:{kind:"literal",value:e})}function De(e,t){return"*"===t?""===e?"*":e+"/*":(e+(t.startsWith("/")?t:"/"+t)).replace(/\/+/g,"/")||"/"}function G(e,t="",n=[]){let r=[];for(let l of e){let e=De(t,l.path),o=[...n,l.component],i=Ee(e);r.push({fullPath:e,segments:i,chain:o,beforeEnter:l.beforeEnter}),l.children?.length&&r.push(...G(l.children,e,o))}return r}function Oe(e,t){let n=e.split("/").filter(Boolean),r=t.segments;if(1===r.length&&"wildcard"===r[0].kind)return{};let l=r.length>0&&"wildcard"===r[r.length-1].kind,o=l?r.slice(0,-1):r;if(l){if(n.length<o.length)return null}else if(n.length!==o.length)return null;let i={};for(let e=0;e<o.length;e++){let t=o[e];if("literal"===t.kind){if(n[e]!==t.value)return null}else if("param"===t.kind)try{i[t.name]=decodeURIComponent(n[e]??"")}catch{i[t.name]=n[e]??""}}return i}function ke(e){return e.segments.reduce((e,t)=>"literal"===t.kind?e+2:"param"===t.kind?e+1:e,0)}function K(e,t){let n,r={},l=-1;for(let o of t){let t=Oe(e,o);if(null===t)continue;let i=ke(o);i>l&&(n=o,r=t,l=i)}return n?{route:n,params:r}:void 0}function q(e){let t=e.trim();return t&&"/"!==t?(t.startsWith("/")||(t="/"+t),t.endsWith("/")&&(t=t.slice(0,-1)),t):""}function Ae(){if(typeof document>"u")return"";let e=document.querySelector("base");if(!e)return"";let t=e.getAttribute("href")||"";try{return q(new URL(t,window.location.origin).pathname)}catch{return q(t)}}function je(e,t){let n=null==t?.base?Ae():q(t.base);function r(){let e=window.location.pathname||"/";if(n&&e.startsWith(n)){let t=e.slice(n.length);return""===t?"/":t}return e}function l(e){return n?n+(e.startsWith("/")?e:"/"+e):e}let o=r(),i=G(e),a=K(o,i),u=p(o),s=p(a?.params??{}),c=p(W(window.location.search)),f=[],d=[],h=0;function m(e,t,n,r,l){let o=[...f];n&&o.push(n);let i=++h;if(0===o.length)return void r();let a=0;!function n(u){if(i!==h)return;if(!1===u)return void l?.();if("string"==typeof u)return void(u===e?r():x(u));if(a>=o.length)return void r();let s=o[a++](e,t);s instanceof Promise?s.then(n):n(s)}(void 0)}let v=!1;function y(e,t){let n=e.indexOf("?"),r=-1===n?e:e.slice(0,n),l=-1===n?{}:W(e.slice(n)),o=t?{...l,...t}:l,i={};for(let[e,t]of Object.entries(o))null!=t&&!1!==t&&(i[e]=String(t));return{pathname:r,stringQuery:i}}H&&=(H(),null);let g=()=>{let e=r(),t=u.value,n=c.value,o=K(e,i),a=W(window.location.search);m(e,t,o?.route.beforeEnter,()=>{s.value=o?.params??{},c.value=a,u.value=e;for(let n of d)try{n(e,t)}catch{}},()=>{history.pushState(null,"",l(t)+Te(n))})};function _(e,t,n,r,o){s.value=r?.params??{},c.value=t,u.value=e;let i=l(e)+Te(t);o?history.replaceState(null,"",i):history.pushState(null,"",i);for(let t of d)try{t(e,n)}catch{}}function x(e,t){v=!0;let{pathname:n,stringQuery:r}=y(e,t),l=u.value,o=K(n,i);m(n,l,o?.route.beforeEnter,()=>_(n,r,l,o,!1))}window.addEventListener("popstate",g),H=()=>window.removeEventListener("popstate",g);let b={current:u,params:s,query:c,base:n||"/",navigate:x,replace:function(e,t){v=!0;let{pathname:n,stringQuery:r}=y(e,t),l=u.value,o=K(n,i);m(n,l,o?.route.beforeEnter,()=>_(n,r,l,o,!0))},back:function(){history.back()},forward:function(){history.forward()},go:function(e){history.go(e)},isActive:function(e,t=!0){let n=u.value;return t?n===e:n===e||n.startsWith(e.endsWith("/")?e:e+"/")},resolve:function(t){let n=K(t,i);if(!n)return{matched:!1,params:{},route:void 0};let r=n.route.chain[n.route.chain.length-1];return{matched:!0,params:n.params,route:function e(t){for(let n of t){if(n.component===r)return n;if(n.children){let t=e(n.children);if(t)return t}}}(e)}},beforeEach:function(e){return f.push(e),()=>{let t=f.indexOf(e);-1!==t&&f.splice(t,1)}},afterEach:function(e){return d.push(e),()=>{let t=d.indexOf(e);-1!==t&&d.splice(t,1)}},routes:e,_flat:i,_guards:f,_base:n};return V&&console.warn("[Nix] A router already exists. The previous router is being replaced. Only one router instance should be active at a time."),V=b,queueMicrotask(()=>{v||m(o,"",K(o,i)?.route.beforeEnter,()=>{},()=>{history.replaceState(null,"",l("/"));let e=K("/",i);u.value="/",s.value=e?.params??{},c.value={}})}),b}function Me(){return U()}var Ne=class extends b{_depth;constructor(e=0){super(),this._depth=e}render(){let e=this._depth;return B`<div class="router-view">${()=>{let t=U(),n=K(t.current.value,t._flat);return n?e>=n.route.chain.length?B`<span></span>`:n.route.chain[e]():B`<div style="color:#f87171;padding:16px 0">
1
+ var e=null,t=[],n=null,r=[],i=null,a=[];function o(e){a.push(i),i=e}function s(){i=a.pop()??null}var c=0,l=new Set,u=100,d=0,f=class{_value;_subs=new Set;constructor(e){this._value=e}get value(){return e&&(this._subs.add(e),n?.add(this)),this._value}set value(e){Object.is(this._value,e)||(this._value=e,this._notify())}update(e){this.value=e(this._value)}peek(){return this._value}_removeSub(e){this._subs.delete(e)}_notify(){if(c>0)for(let e of this._subs)l.add(e);else{let e=Array.from(this._subs);for(let t=0;t<e.length;t++)e[t]()}}dispose(){this._subs.clear()}};function p(e){return new f(e)}function m(l){let o,a=!1,s=new Set,c=new Set,f=i,p=()=>{if(a)return;"function"==typeof o&&o();let i=s;if(s=c,c=i,c.clear(),t.push(e),r.push(n),e=p,n=c,++d>u)throw d=0,e=t.pop()||null,n=r.pop()||null,Error("[Nix] Maximum effect re-execution depth exceeded (possible infinite loop).");try{o=l()}catch(e){if(!f)throw e;f(e)}finally{d--,e=t.pop()||null,n=r.pop()||null;for(let e of s)c.has(e)||e._removeSub(p)}};return p(),()=>{a=!0,"function"==typeof o&&o();for(let e of c)e._removeSub(p);c.clear(),s.clear()}}function h(e){let t=new f(void 0),n=m(()=>{t.value=e()}),r=t.dispose;return t.dispose=()=>{n(),r.call(t)},t}function g(e){c++;try{e()}finally{if(0===--c&&l.size>0){for(let e of l)e();l.clear()}}}function _(t){let r=e,l=n;e=null,n=null;try{return t()}finally{e=r,n=l}}function v(e,t,n={}){let r,{immediate:l=!1,once:o=!1}=n,i=e instanceof f?()=>e.value:e,a=!0,u=!1,s=m(()=>{let e=i();if(a){if(a=!1,l&&!u){let n=e;_(()=>t(n,void 0)),o&&(u=!0,Promise.resolve().then(s))}r=e}else if(!u){let n=e,l=r;r=e,_(()=>t(n,l)),o&&(u=!0,Promise.resolve().then(s))}});return()=>{u=!0,s()}}function y(e){return e?Promise.resolve().then(e):Promise.resolve()}var b=class{__isNixComponent=!0;children;_slots=new Map;setChildren(e){return this.children=e,this}setSlot(e,t){return this._slots.set(e,t),this}slot(e){return this._slots.get(e)}};function x(e){return"object"==typeof e&&!!e&&!0===e.__isNixComponent}function S(e){return Symbol(e)}var C=[];function w(){return[...C]}function T(){C.push(new Map)}function E(){C.pop()}function D(e,t){let n=C.splice(0);e.forEach(e=>C.push(e)),C.push(new Map);try{return t()}finally{C.splice(0),n.forEach(e=>C.push(e))}}function O(e,t){let n=C[C.length-1];if(!n)throw Error("[Nix] provide() must be called inside onInit() of a NixComponent.");n.set(e,t)}function k(e){for(let t=C.length-1;t>=0;t--)if(C[t].has(e))return C[t].get(e)}var A={SCOPE:"nix-scope",ERROR_BOUNDARY:"nix-eb",TRANSITION:"nix-t",KEYED_START:"nix-ks",KEYED_END:"nix-ke",KEYED_ZONE:"nix-kz"};function ee(){return{el:null}}function te(e,t){t?"none"===e.style.display&&(e.style.display=""):"none"!==e.style.display&&(e.style.display="none")}function ne(e,t,n){return{__isKeyedList:!0,items:e,keyFn:t,renderFn:n}}function re(e,t,n){let r,l;T();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}r=e.render()._render(t,n)}finally{E()}try{let t=e.onMount?.();"function"==typeof t&&(l=t)}catch(t){if(!e.onError)throw t;e.onError(t)}return()=>{try{e.onUnmount?.()}catch{}try{l?.()}catch{}r()}}function ie(e,t,n){let r,l;T();try{try{e.onInit?.()}catch{}r=e.render()._render(t,n)}finally{E()}try{let t=e.onMount?.();"function"==typeof t&&(l=t)}catch{}return()=>{try{e.onUnmount?.()}catch{}try{l?.()}catch{}r()}}function j(e,t,n,r){let l,o;D(r,()=>{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}l=e.render()._render(t,n)});try{let t=e.onMount?.();"function"==typeof t&&(o=t)}catch(t){if(!e.onError)throw t;e.onError(t)}return()=>{try{e.onUnmount?.()}catch{}try{o?.()}catch{}l()}}function ae(e,t,n,r,l){let o,i;T();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}o=e.render()._render(t,n)}finally{E()}r.push(()=>{try{let t=e.onMount?.();"function"==typeof t&&(i=t)}catch(t){if(!e.onError)throw t;e.onError(t)}}),l.push(()=>{try{e.onUnmount?.()}catch{}try{i?.()}catch{}o()})}function oe(){return{__isPortalOutlet:!0,_container:null}}function se(e){return{__isNixTemplate:!0,mount(e){let t="string"==typeof e?document.querySelector(e)??document.body:e;return{unmount:this._render(t,null)}},_render(t,n){let r=document.createElement("div");return r.setAttribute("data-nix-outlet",""),e._container=r,t.insertBefore(r,n),()=>{e._container=null,r.remove()}}}}function ce(e,t=document.body){return{__isNixTemplate:!0,mount(e){let t="string"==typeof e?document.querySelector(e)??document.body:e;return{unmount:this._render(t,null)}},_render(n,r){let l;return l="string"==typeof t?document.querySelector(t)??document.body:t instanceof Element?t:"__isPortalOutlet"in t?t._container??document.body:t.el??document.body,x(e)?re(e,l,null):e._render(l,null)}}}var M=S("nix:portal-outlet");function le(e){O(M,e)}function ue(){return k(M)}function de(e,t){return{__isNixTemplate:!0,mount(e){let t="string"==typeof e?document.querySelector(e)??document.body:e;return{unmount:this._render(t,null)}},_render(n,r){let l=document.createComment(A.ERROR_BOUNDARY);n.insertBefore(l,r);let i,a=null,u=!1,c=!1,f=!1,d=e=>{let n=l.parentNode,o="function"!=typeof t||x(t)?t:t(e);a=x(o)?ie(o,n,r):o._render(n,r)};o(e=>{u||(u=!0,c?(a?.(),a=null,d(e)):(i=e,f=!0))});try{if(x(e)){T();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}a=e.render()._render(n,r)}finally{E()}if(!u)try{let t=e.onMount?.(),n=a;a=()=>{try{e.onUnmount?.()}catch{}if("function"==typeof t)try{t()}catch{}n?.()}}catch(t){if(!e.onError)throw t;e.onError(t)}}else a=e._render(n,r)}catch(e){u=!0,a?.(),a=null,i=e,f=!0}finally{s(),c=!0}return f&&(a?.(),a=null,d(i)),()=>{a?.(),l.remove()}}}}function fe(e){let t=e.name??"nix";return{enterFrom:e.enterFrom??`${t}-enter-from`,enterActive:e.enterActive??`${t}-enter-active`,enterTo:e.enterTo??`${t}-enter-to`,leaveFrom:e.leaveFrom??`${t}-leave-from`,leaveActive:e.leaveActive??`${t}-leave-active`,leaveTo:e.leaveTo??`${t}-leave-to`}}function pe(e){return Math.max(0,...e.split(",").map(e=>parseFloat(e.trim())||0))}function N(e,t=0){return new Promise(n=>{let r=getComputedStyle(e),l=1e3*Math.max(pe(r.transitionDuration||"0"),pe(r.animationDuration||"0")),o=l>0?l+100:t;if(o<=0)return void n();let i,a=t=>{t.target===e&&(clearTimeout(i),e.removeEventListener("transitionend",a),e.removeEventListener("animationend",a),n())};e.addEventListener("transitionend",a),e.addEventListener("animationend",a),i=setTimeout(()=>{e.removeEventListener("transitionend",a),e.removeEventListener("animationend",a),n()},o)})}function me(e,t={}){let n=fe(t);return{__isNixTemplate:!0,mount(e){let t="string"==typeof e?document.querySelector(e)??document.body:e;return{unmount:this._render(t,null)}},_render(r,l){let o=document.createComment(A.TRANSITION);r.insertBefore(o,l);let i=null,a=null,u=0,s=!0,c=()=>{let e=o.nextSibling;for(;e&&e!==l;){if(e.nodeType===Node.ELEMENT_NODE)return e;e=e.nextSibling}return null};function f(e){return x(e)?ie(e,r,l):e._render(r,l)}let d=(e,r=!1)=>{u++,a&&=(a(),null),i=f(e);let l=c();if(l&&(!s||t.appear)&&!r){let e=u;(async()=>{t.onBeforeEnter?.(l),l.classList.add(n.enterFrom,n.enterActive),l.getBoundingClientRect(),await new Promise(e=>requestAnimationFrame(()=>e())),u===e&&(l.classList.remove(n.enterFrom),l.classList.add(n.enterTo),await N(l,t.duration),u===e&&(l.classList.remove(n.enterActive,n.enterTo),t.onAfterEnter?.(l)))})().catch(()=>{})}s=!1},p=()=>{let e=i;i=null;let r=c();if(!r)return void e?.();let l=++u;a=e??null,(async()=>{t.onBeforeLeave?.(r),r.classList.add(n.leaveFrom,n.leaveActive),r.getBoundingClientRect(),await new Promise(e=>requestAnimationFrame(()=>e())),u===l&&(r.classList.remove(n.leaveFrom),r.classList.add(n.leaveTo),await N(r,t.duration),u===l&&(r.classList.remove(n.leaveActive,n.leaveTo),t.onAfterLeave?.(r),a?.(),a=null))})().catch(()=>{})},h=null;if("function"!=typeof e||x(e))d(e);else{let t=e,n=null;h=m(()=>{let e=t(),r=null===n,l=null===e;r&&!l?d(e):!r&&l?p():!r&&!l&&(u++,a?.(),a=null,i?.(),i=null,d(e,!0)),n=e}),s=!1}return()=>{u++,h?.(),i?.(),a?.(),i=null,a=null,o.remove()}}}}function he(e){let t=e.lastIndexOf(">"),n=e.lastIndexOf("<");if(n<=t)return{type:"node"};let r=e.slice(n+1),l=r.lastIndexOf("=");if(-1===l)return{type:"node"};let o=r.endsWith('"')||r.endsWith("'")||'"'===r[r.length-1]||"'"===r[r.length-1],i=l-1;for(;i>=0&&/\S/.test(r[i]);)i--;i++;let a=r.slice(i,l);if("@"===a[0]){let e=a.slice(1).split(".");return{type:"event",eventName:e[0],modifiers:e.slice(1),hadOpenQuote:o}}return{type:"attr",attrName:a,hadOpenQuote:o}}function ge(e,t){let n=new Uint8Array(e.length),r="";for(let l=0;l<e.length;l++){let o=e[l];if(1===n[l]&&('"'===o[0]||"'"===o[0])&&(o=o.slice(1)),l<t.length){let e=t[l];if("node"===e.type)r+=o+`\x3c!--nix-${l}--\x3e`;else if("event"===e.type){let t=`@${e.modifiers.length?`${e.eventName}.${e.modifiers.join(".")}`:e.eventName}=`.length+(e.hadOpenQuote?1:0);r+=o.slice(0,-t)+` data-nix-e-${l}="${e.eventName}"`,e.hadOpenQuote&&(n[l+1]=1)}else{let t=`${e.attrName}=`.length+(e.hadOpenQuote?1:0);r+=o.slice(0,-t)+` data-nix-a-${l}="${e.attrName}"`,e.hadOpenQuote&&(n[l+1]=1)}}else r+=o}return r}function P(e){return"object"==typeof e&&!!e&&!0===e.__isNixTemplate}function _e(e){return"object"==typeof e&&!!e&&!0===e.__isKeyedList}var ve={enter:"Enter",escape:"Escape",space:" ",tab:"Tab",delete:"Delete",backspace:"Backspace",up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight"},ye=new Set(["click","dblclick","mousedown","mouseup","keydown","keyup","input","change","submit"]),F=new Set;function be(e){let t=e.target,n=`__nix_${e.type}`,r=`__nix_${e.type}_mods`,l=e.stopPropagation,o=!1;for(e.stopPropagation=()=>{o=!0,l.call(e)};t&&t!==document;){let l=t[n];if(l){let n=t[r];if(n){if(n.includes("prevent")&&e.preventDefault(),n.includes("stop")&&e.stopPropagation(),n.includes("self")&&e.target!==t){t=t.parentNode;continue}if("key"in e){let r=e,l=!0;for(let e of n){let t=ve[e];if(void 0!==t&&r.key!==t){l=!1;break}if(!t&&1===e.length&&r.key.toLowerCase()!==e){l=!1;break}}if(!l){t=t.parentNode;continue}}}if(l(e),o)break}t=t.parentNode}e.stopPropagation=l}var I=new Set,L=!1;function R(e){I.add(e),L||(L=!0,queueMicrotask(()=>{for(let e of I)e();I.clear(),L=!1}))}function xe(e,t,n,r){let l=[],o=[],i=Array(t.length),a=-1;for(let e=0;e<t.length;e++)r[e]&&r[e].nodeIndex>a&&(a=r[e].nodeIndex);let u=[e];if(a>0){let t,n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_COMMENT),r=0;for(;r<a&&(t=n.nextNode());)r++,u.push(t)}for(let e=0;e<t.length;e++){let t=r[e];i[e]=t?u[t.nodeIndex]:null}for(let e=0;e<t.length;e++){let a=t[e],u=n[e],s=r[e];if(!s)continue;let c=i[e];if("event"===a.type){let e=s.name,t=u,n=a.modifiers;if(!ye.has(e)||n.includes("capture")||n.includes("once")){let r={once:n.includes("once"),capture:n.includes("capture"),passive:n.includes("passive")},o=e=>{n.includes("prevent")&&e.preventDefault(),n.includes("stop")&&e.stopPropagation(),(!n.includes("self")||e.target===e.currentTarget)&&t(e)};c.addEventListener(e,o,r),l.push(()=>c.removeEventListener(e,o,r))}else F.has(e)||(document.addEventListener(e,be),F.add(e)),c[`__nix_${e}`]=t,n.length>0&&(c[`__nix_${e}_mods`]=n),l.push(()=>{c[`__nix_${e}`]=null,c[`__nix_${e}_mods`]=null});continue}if("attr"===a.type){let e=s.name,t=c;if("ref"===e){u.el=t,l.push(()=>{u.el=null});continue}if("show"===e||"hide"===e){let n=t,r=null;if("function"==typeof u){let t=!1,o=!1,i=!0,a=m(()=>{o=!!u();let l=()=>{t=!1;let l="show"===e?o:!o;null===r&&(r=n.style.display||""),n.style.display=l?r:"none"};i?(i=!1,l()):t||(t=!0,R(l))});l.push(a)}else("show"===e?u:!u)||(n.style.display="none");continue}let n=("value"===e||"checked"===e||"selected"===e)&&e in t;if("function"==typeof u){let r,o=!1,i=!0,a=m(()=>{r=u();let l=()=>{o=!1;let l=r;n?t[e]=l??"":null==l||!1===l?t.removeAttribute(e):t.setAttribute(e,String(l))};i?(i=!1,l()):o||(o=!0,R(l))});l.push(a)}else n?t[e]=u??"":null!=u&&!1!==u&&t.setAttribute(e,String(u));continue}let f=c;if(!f)continue;let d=document.createTextNode("");if(f.parentNode.replaceChild(d,f),"function"!=typeof u){if(x(u))ae(u,d.parentNode,d,o,l);else if(P(u)){let e=u._render(d.parentNode,d);l.push(e)}else if(Array.isArray(u))for(let e of u)x(e)?ae(e,d.parentNode,d,o,l):P(e)?e._render(d.parentNode,d):null!=e&&!1!==e&&d.parentNode.insertBefore(document.createTextNode(String(e)),d);else null!=u&&!1!==u&&d.parentNode.insertBefore(document.createTextNode(String(u)),d);continue}let p=null,h=null,v=null,y=[],g=null,_=w(),b=!1,N="",E=!0,S=m(()=>{let e=u();if("string"==typeof e||"number"==typeof e){N=String(e);let t=()=>{b=!1,h&&=(h(),null),p?p.nodeValue=N:(p=document.createTextNode(N),d.parentNode.insertBefore(p,d))};return void(E?(E=!1,t()):b||(b=!0,R(t)))}if(b=!1,E=!1,p&&=(p.parentNode?.removeChild(p),null),h&&=(h(),null),null!=e&&!1!==e)if(P(e))h=e._render(d.parentNode,d);else if(x(e))h=j(e,d.parentNode,d,_);else if(_e(e)){v||(v=new Map,g=document.createTextNode(""),d.parentNode.insertBefore(g,d));let t=d.parentNode,n=e.items.map((t,n)=>e.keyFn(t,n)),r=new Set(n),l=!1;if(v.size>0)for(let e of v.keys())if(r.has(e)){l=!0;break}if(!l){if(v.size>0){let e=document.createRange();e.setStartAfter(g),e.setEndBefore(d),e.deleteContents();for(let e of v.values())e.cleanup();v.clear()}if(n.length>0){let r=document.createDocumentFragment();for(let t=0;t<n.length;t++){let l=n[t],o=e.items[t],i=document.createTextNode(""),a=document.createTextNode("");r.appendChild(i),r.appendChild(a);let u=e.renderFn(o,t),s=x(u)?j(u,r,a,_):u._render(r,a);v.set(l,{start:i,end:a,cleanup:s})}t.insertBefore(r,d)}return void(y=n)}let o=new Map;for(let e=0;e<n.length;e++)o.set(n[e],e);let i=new Int32Array(n.length),a=!1,u=0;for(let e=0;e<y.length;e++){let t=y[e],n=o.get(t);if(void 0===n){let e=v.get(t);e.cleanup();let n=e.start;for(;n;){let t=n===e.end?null:n.nextSibling;if(n.parentNode?.removeChild(n),!t)break;n=t}v.delete(t)}else i[n]=e+1,n>=u?u=n:a=!0}let s=a?Se(i):[],c=s.length-1,f=d;for(let r=n.length-1;r>=0;r--){let l=n[r];if(0===i[r]){let n=e.items[r],o=document.createTextNode(""),i=document.createTextNode(""),a=document.createDocumentFragment();a.appendChild(o),a.appendChild(i);let u=e.renderFn(n,r),s=x(u)?j(u,a,i,_):u._render(a,i);v.set(l,{start:o,end:i,cleanup:s}),t.insertBefore(a,f),f=o}else{let e=v.get(l);if(a)if(c<0||r!==s[c]){let n=e.start;for(;n;){let r=n===e.end?null:n.nextSibling;if(t.insertBefore(n,f),!r)break;n=r}}else c--;f=e.start}}y=n}else if(Array.isArray(e)){let t=[];for(let n of e)if(x(n))t.push(re(n,d.parentNode,d));else if(P(n))t.push(n._render(d.parentNode,d));else if(null!=n&&!1!==n){let e=document.createTextNode(String(n));d.parentNode.insertBefore(e,d),t.push(()=>e.parentNode?.removeChild(e))}h=()=>t.forEach(e=>e())}else p=document.createTextNode(String(e)),d.parentNode.insertBefore(p,d)});l.push(()=>{if(S(),h&&=(h(),null),p&&=(p.parentNode?.removeChild(p),null),v){for(let e of v.values())e.cleanup();v=null,g=null}})}return{disposes:l,postMountHooks:o}}function Se(e){let t,n,r,l,o,i=e.slice(),a=[0],u=e.length;for(t=0;t<u;t++){let u=e[t];if(0!==u){if(n=a[a.length-1],e[n]<u){i[t]=n,a.push(t);continue}for(r=0,l=a.length-1;r<l;)o=r+l>>1,e[a[o]]<u?r=o+1:l=o;u<e[a[r]]&&(r>0&&(i[t]=a[r-1]),a[r]=t)}}for(r=a.length,l=a[r-1];r-- >0;)a[r]=l,l=i[l];return a}var z=new WeakMap;function B(e,...t){let n=z.get(e);if(!n){let t=[],r="";for(let n=0;n<e.length-1;n++)r+=e[n],t.push(he(r)),r+="__nix__";let l=document.createElement("template");l.innerHTML=ge(e,t);let o,i=Array(t.length).fill(null),a=l.content,u=document.createTreeWalker(a,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_COMMENT),s=0;for(;o=u.nextNode();)if(s++,8===o.nodeType){let e=o.nodeValue;if(e&&e.startsWith("nix-")){let t=parseInt(e.slice(4),10);isNaN(t)||(i[t]={nodeIndex:s})}}else if(1===o.nodeType){let e=o,t=Array.from(e.attributes);for(let n=0;n<t.length;n++){let r=t[n],l=r.name;if(l.startsWith("data-nix-e-")){let t=parseInt(l.slice(11),10);isNaN(t)||(i[t]={nodeIndex:s,name:r.value},e.removeAttribute(l));continue}if(l.startsWith("data-nix-a-")){let t=parseInt(l.slice(11),10);isNaN(t)||(i[t]={nodeIndex:s,name:r.value},e.removeAttribute(l))}}}n={contexts:t,tpl:l,pathMap:i},z.set(e,n)}let{contexts:r,tpl:l,pathMap:o}=n;function i(e,n){let i=document.importNode(l.content,!0),{disposes:a,postMountHooks:u}=xe(i,r,t,o),s=document.createTextNode("");return e.insertBefore(s,n),e.insertBefore(i,n),u.forEach(e=>e()),()=>{for(let e=a.length-1;e>=0;e--)a[e]();let e=s.nextSibling;for(;e&&e!==n;){let t=e.nextSibling;e.parentNode?.removeChild(e),e=t}s.parentNode?.removeChild(s)}}return{__isNixTemplate:!0,_render:i,mount(e){let t="string"==typeof e?document.querySelector(e):e;if(!t)throw Error(`[Nix] mount: contenedor no encontrado: ${e}`);let n=i(t,null);return{unmount(){n()}}}}}function Ce(e,t){if(x(e)){let n,r,l="string"==typeof t?document.querySelector(t):t;if(!l)throw Error(`[Nix] mount: container not found: ${t}`);T();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}n=e.render()._render(l,null)}finally{E()}try{let t=e.onMount?.();"function"==typeof t&&(r=t)}catch(t){if(!e.onError)throw t;e.onError(t)}return{unmount(){try{e.onUnmount?.()}catch{}try{r?.()}catch{}n()}}}return e.mount(t)}function we(e,t){let n={},r=new Set(["$reset","$patch","$state"]);for(let t of Object.keys(e)){if(r.has(t))throw Error(`[Nix] Store key "${t}" is reserved.`);n[t]=p(e[t])}let l=n;let o=Object.assign(Object.create(null),l,{$reset:function(){for(let t of Object.keys(e))n[t].value=e[t]},$patch:function(e){for(let t of Object.keys(e))t in n&&(n[t].value=e[t])}});if(Object.defineProperty(o,"$state",{get(){let e={};for(let t in n)e[t]=n[t].value;return e},enumerable:!0,configurable:!1}),t){let e=t(l);for(let t of Object.keys(e))r.has(t)?console.warn(`[Nix] Store action name "${t}" is reserved and will be ignored.`):o[t]=e[t]}return o}var V=null,H=null;function U(){if(!V)throw Error("[Nix] No active router. Call createRouter() first.");return V}function W(e){let t={};return new URLSearchParams(e).forEach((e,n)=>{t[n]=e}),t}function Te(e){let t=new URLSearchParams;for(let[n,r]of Object.entries(e))null!=r&&!1!==r&&t.set(n,String(r));let n=t.toString();return n?"?"+n:""}function Ee(e){return"*"===e?[{kind:"wildcard"}]:e.split("/").filter(Boolean).map(e=>"*"===e?{kind:"wildcard"}:e.startsWith(":")?{kind:"param",name:e.slice(1)}:{kind:"literal",value:e})}function De(e,t){return"*"===t?""===e?"*":e+"/*":(e+(t.startsWith("/")?t:"/"+t)).replace(/\/+/g,"/")||"/"}function G(e,t="",n=[]){let r=[];for(let l of e){let e=De(t,l.path),o=[...n,l.component],i=Ee(e);r.push({fullPath:e,segments:i,chain:o,beforeEnter:l.beforeEnter}),l.children?.length&&r.push(...G(l.children,e,o))}return r}function Oe(e,t){let n=e.split("/").filter(Boolean),r=t.segments;if(1===r.length&&"wildcard"===r[0].kind)return{};let l=r.length>0&&"wildcard"===r[r.length-1].kind,o=l?r.slice(0,-1):r;if(l){if(n.length<o.length)return null}else if(n.length!==o.length)return null;let i={};for(let e=0;e<o.length;e++){let t=o[e];if("literal"===t.kind){if(n[e]!==t.value)return null}else if("param"===t.kind)try{i[t.name]=decodeURIComponent(n[e]??"")}catch{i[t.name]=n[e]??""}}return i}function ke(e){return e.segments.reduce((e,t)=>"literal"===t.kind?e+2:"param"===t.kind?e+1:e,0)}function K(e,t){let n,r={},l=-1;for(let o of t){let t=Oe(e,o);if(null===t)continue;let i=ke(o);i>l&&(n=o,r=t,l=i)}return n?{route:n,params:r}:void 0}function q(e){let t=e.trim();return t&&"/"!==t?(t.startsWith("/")||(t="/"+t),t.endsWith("/")&&(t=t.slice(0,-1)),t):""}function Ae(){if(typeof document>"u")return"";let e=document.querySelector("base");if(!e)return"";let t=e.getAttribute("href")||"";try{return q(new URL(t,window.location.origin).pathname)}catch{return q(t)}}function je(e,t){let n=null==t?.base?Ae():q(t.base);function r(){let e=window.location.pathname||"/";if(n&&e.startsWith(n)){let t=e.slice(n.length);return""===t?"/":t}return e}function l(e){return n?n+(e.startsWith("/")?e:"/"+e):e}let o=r(),i=G(e),a=K(o,i),u=p(o),s=p(a?.params??{}),c=p(W(window.location.search)),f=[],d=[],h=0;function m(e,t,n,r,l){let o=[...f];n&&o.push(n);let i=++h;if(0===o.length)return void r();let a=0;!function n(u){if(i!==h)return;if(!1===u)return void l?.();if("string"==typeof u)return void(u===e?r():x(u));if(a>=o.length)return void r();let s=o[a++](e,t);s instanceof Promise?s.then(n):n(s)}(void 0)}let v=!1;function y(e,t){let n=e.indexOf("?"),r=-1===n?e:e.slice(0,n),l=-1===n?{}:W(e.slice(n)),o=t?{...l,...t}:l,i={};for(let[e,t]of Object.entries(o))null!=t&&!1!==t&&(i[e]=String(t));return{pathname:r,stringQuery:i}}H&&=(H(),null);let g=()=>{let e=r(),t=u.value,n=c.value,o=K(e,i),a=W(window.location.search);m(e,t,o?.route.beforeEnter,()=>{s.value=o?.params??{},c.value=a,u.value=e;for(let n of d)try{n(e,t)}catch{}},()=>{history.pushState(null,"",l(t)+Te(n))})};function _(e,t,n,r,o){s.value=r?.params??{},c.value=t,u.value=e;let i=l(e)+Te(t);o?history.replaceState(null,"",i):history.pushState(null,"",i);for(let t of d)try{t(e,n)}catch{}}function x(e,t){v=!0;let{pathname:n,stringQuery:r}=y(e,t),l=u.value,o=K(n,i);m(n,l,o?.route.beforeEnter,()=>_(n,r,l,o,!1))}window.addEventListener("popstate",g),H=()=>window.removeEventListener("popstate",g);let b={current:u,params:s,query:c,base:n||"/",navigate:x,replace:function(e,t){v=!0;let{pathname:n,stringQuery:r}=y(e,t),l=u.value,o=K(n,i);m(n,l,o?.route.beforeEnter,()=>_(n,r,l,o,!0))},back:function(){history.back()},forward:function(){history.forward()},go:function(e){history.go(e)},isActive:function(e,t=!0){let n=u.value;return t?n===e:n===e||n.startsWith(e.endsWith("/")?e:e+"/")},resolve:function(t){let n=K(t,i);if(!n)return{matched:!1,params:{},route:void 0};let r=n.route.chain[n.route.chain.length-1];return{matched:!0,params:n.params,route:function e(t){for(let n of t){if(n.component===r)return n;if(n.children){let t=e(n.children);if(t)return t}}}(e)}},beforeEach:function(e){return f.push(e),()=>{let t=f.indexOf(e);-1!==t&&f.splice(t,1)}},afterEach:function(e){return d.push(e),()=>{let t=d.indexOf(e);-1!==t&&d.splice(t,1)}},routes:e,_flat:i,_guards:f,_base:n};return V&&console.warn("[Nix] A router already exists. The previous router is being replaced. Only one router instance should be active at a time."),V=b,queueMicrotask(()=>{v||m(o,"",K(o,i)?.route.beforeEnter,()=>{},()=>{history.replaceState(null,"",l("/"));let e=K("/",i);u.value="/",s.value=e?.params??{},c.value={}})}),b}function Me(){return U()}var Ne=class extends b{_depth;constructor(e=0){super(),this._depth=e}render(){let e=this._depth;return B`<div class="router-view">${()=>{let t=U(),n=K(t.current.value,t._flat);return n?e>=n.route.chain.length?B`<span></span>`:n.route.chain[e]():B`<div style="color:#f87171;padding:16px 0">
2
2
  404 — Route not found: <strong>${t.current.value}</strong>
3
3
  </div>`}}</div>`}},Pe=class extends b{_to;_label;constructor(e,t){super(),this._to=e,this._label=t}render(){let e=this._to,t=this._label;return B`<a
4
4
  href=${(U()._base||"")+(e.startsWith("/")?e:"/"+e)}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deijose/nix-js",
3
- "version": "1.7.3-beta.10",
3
+ "version": "1.7.3-beta.11",
4
4
  "description": "A lightweight, fully reactive micro-framework — no virtual DOM, no compiler, just signals and tagged templates.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://nix-js-landing.vercel.app/",