@deijose/nix-js 1.7.6 → 1.7.7
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.
- package/dist/lib/nix-js.cjs +8 -8
- package/dist/lib/nix-js.js +8 -8
- package/package.json +1 -1
package/dist/lib/nix-js.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var e=[],t=[],n=null,r=null,i=null,a=[];function o(e){a.push(i),i=e}function s(){i=a.pop()??null}var c=0,l=new Set,u=[],d=100,f=0,p=[],m=class{_value;_subs=new Set;constructor(e){this._value=e}get value(){return n&&(this._subs.add(n),r?.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.has(e)||(l.add(e),u.push(e));return}let e=0;for(let t of this._subs)p[e++]=t;for(let t=0;t<e;t++)p[t](),p[t]=null}dispose(){this._subs.clear()}};function h(e){return new m(e)}function g(l){let o,u=!1,a=new Set,s=new Set,c=i,p=()=>{if(u)return;"function"==typeof o&&o();let i=a;a=s,s=i,s.clear();let h=e.length>0?e.pop():{effect:null,deps:null};if(h.effect=n,h.deps=r,t.push(h),n=p,r=s,++f>d){f=0;let l=t.pop();throw n=l.effect,r=l.deps,l.effect=null,l.deps=null,e.push(l),Error("[Nix] Maximum effect re-execution depth exceeded (possible infinite loop).")}try{o=l()}catch(e){if(!c)throw e;c(e)}finally{f--;let l=t.pop();if(n=l.effect,r=l.deps,l.effect=null,l.deps=null,e.push(l),a.size!==s.size)for(let e of a)s.has(e)||e._removeSub(p)}};return p(),()=>{u=!0,"function"==typeof o&&o();for(let e of s)e._removeSub(p);s.clear(),a.clear()}}function _(e){let t=new m(void 0),n=g(()=>{t.value=e()}),r=t.dispose;return t.dispose=()=>{n(),r.call(t)},t}function v(e){c++;try{e()}finally{if(0===--c&&u.length>0){let e=u.length;for(let t=0;t<e;t++)u[t]();u.length=0,l.clear()}}}function y(e){let t=n,l=r;n=null,r=null;try{return e()}finally{n=t,r=l}}function b(e,t,n={}){let r,{immediate:l=!1,once:o=!1}=n,i=e instanceof m?()=>e.value:e,u=!0,a=!1,s=g(()=>{let e=i();if(u){if(u=!1,l&&!a){let n=e;y(()=>t(n,void 0)),o&&(a=!0,Promise.resolve().then(s))}r=e}else if(!a){let n=e,l=r;r=e,y(()=>t(n,l)),o&&(a=!0,Promise.resolve().then(s))}});return()=>{a=!0,s()}}function x(e){return e?Promise.resolve().then(e):Promise.resolve()}var S=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 C(e){return"object"==typeof e&&!!e&&!0===e.__isNixComponent}function w(e){return Symbol(e)}var T=[];function ee(){return[...T]}function E(){T.push(new Map)}function D(){T.pop()}function O(e,t){let n=T.splice(0);e.forEach(e=>T.push(e)),T.push(new Map);try{return t()}finally{T.splice(0),n.forEach(e=>T.push(e))}}function k(e,t){let n=T[T.length-1];if(!n)throw Error("[Nix] provide() must be called inside onInit() of a NixComponent.");n.set(e,t)}function te(e){for(let t=T.length-1;t>=0;t--)if(T[t].has(e))return T[t].get(e)}var ne={SCOPE:"nix-scope",ERROR_BOUNDARY:"nix-eb",TRANSITION:"nix-t",KEYED_START:"nix-ks",KEYED_END:"nix-ke",KEYED_ZONE:"nix-kz"};function re(){return{el:null}}function ie(e,t){t?"none"===e.style.display&&(e.style.display=""):"none"!==e.style.display&&(e.style.display="none")}function ae(e,t,n){return{__isKeyedList:!0,items:e,keyFn:t,renderFn:n}}function oe(e,t,n){let r,l;E();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}r=e.render()._render(t,n)}finally{D()}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 se(e,t,n){let r,l;E();try{try{e.onInit?.()}catch{}r=e.render()._render(t,n)}finally{D()}try{let t=e.onMount?.();"function"==typeof t&&(l=t)}catch{}return()=>{try{e.onUnmount?.()}catch{}try{l?.()}catch{}r()}}function A(e,t,n,r){let l,o;O(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 ce(e,t,n,r,l){let o,i;E();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}o=e.render()._render(t,n)}finally{D()}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 le(){return{__isPortalOutlet:!0,_container:null}}function ue(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 de(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,C(e)?oe(e,l,null):e._render(l,null)}}}var j=w("nix:portal-outlet");function fe(e){k(j,e)}function pe(){return te(j)}function me(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(ne.ERROR_BOUNDARY);n.insertBefore(l,r);let i,u=null,a=!1,c=!1,f=!1,d=e=>{let n=l.parentNode,o="function"!=typeof t||C(t)?t:t(e);u=C(o)?se(o,n,r):o._render(n,r)};o(e=>{a||(a=!0,c?(u?.(),u=null,d(e)):(i=e,f=!0))});try{if(C(e)){E();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}u=e.render()._render(n,r)}finally{D()}if(!a)try{let t=e.onMount?.(),n=u;u=()=>{try{e.onUnmount?.()}catch{}if("function"==typeof t)try{t()}catch{}n?.()}}catch(t){if(!e.onError)throw t;e.onError(t)}}else u=e._render(n,r)}catch(e){a=!0,u?.(),u=null,i=e,f=!0}finally{s(),c=!0}return f&&(u?.(),u=null,d(i)),()=>{u?.(),l.remove()}}}}function he(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 M(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(M(r.transitionDuration||"0"),M(r.animationDuration||"0")),o=l>0?l+100:t;if(o<=0)return void n();let i,u=t=>{t.target===e&&(clearTimeout(i),e.removeEventListener("transitionend",u),e.removeEventListener("animationend",u),n())};e.addEventListener("transitionend",u),e.addEventListener("animationend",u),i=setTimeout(()=>{e.removeEventListener("transitionend",u),e.removeEventListener("animationend",u),n()},o)})}function ge(e,t={}){let n=he(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(ne.TRANSITION);r.insertBefore(o,l);let i=null,u=null,a=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 C(e)?se(e,r,l):e._render(r,l)}let d=(e,r=!1)=>{a++,u&&=(u(),null),i=f(e);let l=c();if(l&&(!s||t.appear)&&!r){let e=a;(async()=>{t.onBeforeEnter?.(l),l.classList.add(n.enterFrom,n.enterActive),l.getBoundingClientRect(),await new Promise(e=>requestAnimationFrame(()=>e())),a===e&&(l.classList.remove(n.enterFrom),l.classList.add(n.enterTo),await N(l,t.duration),a===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=++a;u=e??null,(async()=>{t.onBeforeLeave?.(r),r.classList.add(n.leaveFrom,n.leaveActive),r.getBoundingClientRect(),await new Promise(e=>requestAnimationFrame(()=>e())),a===l&&(r.classList.remove(n.leaveFrom),r.classList.add(n.leaveTo),await N(r,t.duration),a===l&&(r.classList.remove(n.leaveActive,n.leaveTo),t.onAfterLeave?.(r),u?.(),u=null))})().catch(()=>{})},h=null;if("function"!=typeof e||C(e))d(e);else{let t=e,n=null;h=g(()=>{let e=t(),r=null===n,l=null===e;r&&!l?d(e):!r&&l?p():!r&&!l&&(a++,u?.(),u=null,i?.(),i=null,d(e,!0)),n=e}),s=!1}return()=>{a++,h?.(),i?.(),u?.(),i=null,u=null,o.remove()}}}}function _e(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 u=r.slice(i,l);if("@"===u[0]){let e=u.slice(1).split(".");return{type:"event",eventName:e[0],modifiers:e.slice(1),hadOpenQuote:o}}return{type:"attr",attrName:u,hadOpenQuote:o}}function ve(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 ye(e){return"object"==typeof e&&!!e&&!0===e.__isKeyedList}var be={enter:"Enter",escape:"Escape",space:" ",tab:"Tab",delete:"Delete",backspace:"Backspace",up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight"},xe=new Set(["click","dblclick","mousedown","mouseup","keydown","keyup","input","change","submit"]),Se=new Set;function Ce(e,t,n){let r=e.target,l=e.stopPropagation,o=!1;for(e.stopPropagation=()=>{o=!0,l.call(e)};r&&r!==document;){let l=r[t];if(l){let t=r[n];if(t){if(t.includes("prevent")&&e.preventDefault(),t.includes("stop")&&e.stopPropagation(),t.includes("self")&&e.target!==r){r=r.parentNode;continue}if("key"in e){let n=e,l=!0;for(let e of t){let t=be[e];if(void 0!==t&&n.key!==t){l=!1;break}if(!t&&1===e.length&&n.key.toLowerCase()!==e){l=!1;break}}if(!l){r=r.parentNode;continue}}}if(l(e),o)break}r=r.parentNode}e.stopPropagation=l}var we=new Map,F=new Set,I=!1;function L(e){F.add(e),I||(I=!0,queueMicrotask(()=>{for(let e of F)e();F.clear(),I=!1}))}function Te(e,t,n,r){let l=[],o=[],i=Array(t.length),u=-1;for(let e=0;e<t.length;e++)r[e]&&r[e].nodeIndex>u&&(u=r[e].nodeIndex);let a=Array(u+1);if(a[0]=e,u>0){let t,n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_COMMENT),r=1;for(;r<=u&&(t=n.nextNode());)a[r++]=t}for(let e=0;e<t.length;e++){let t=r[e];i[e]=t?a[t.nodeIndex]:null}for(let e=0;e<t.length;e++){let u=t[e],a=n[e],s=r[e];if(!s)continue;let c=i[e];if("event"===u.type){let e=s.name,t=a,n=u.modifiers;if(!xe.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{if(!Se.has(e)){let t=`__nix_${e}`,n=`__nix_${e}_mods`,r=e=>Ce(e,t,n);we.set(e,r),document.addEventListener(e,r),Se.add(e)}let r=`__nix_${e}`,o=`__nix_${e}_mods`;c[r]=t,n.length>0&&(c[o]=n),l.push(()=>{c[r]=null,c[o]=null})}continue}if("attr"===u.type){let e=s.name,t=c;if("ref"===e){a.el=t,l.push(()=>{a.el=null});continue}if("show"===e||"hide"===e){let n=t,r=null;if("function"==typeof a){let t=!1,o=!1,i=!0,u=g(()=>{o=!!a();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,L(l))});l.push(u)}else("show"===e?a:!a)||(n.style.display="none");continue}let n=("value"===e||"checked"===e||"selected"===e)&&e in t;if("function"==typeof a){let r,o=!1,i=!0,u=g(()=>{r=a();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,L(l))});l.push(u)}else n?t[e]=a??"":null!=a&&!1!==a&&t.setAttribute(e,String(a));continue}let f=c;if(!f)continue;let d=document.createTextNode("");if(f.parentNode.replaceChild(d,f),"function"!=typeof a){if(C(a))ce(a,d.parentNode,d,o,l);else if(P(a)){let e=a._render(d.parentNode,d);l.push(e)}else if(Array.isArray(a))for(let e of a)C(e)?ce(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!=a&&!1!==a&&d.parentNode.insertBefore(document.createTextNode(String(a)),d);continue}let p=null,h=null,m=null,y=[],x=null,_=ee(),b=!1,w="",N=!0,E=g(()=>{let e=a();if("string"==typeof e||"number"==typeof e){w=String(e);let t=()=>{b=!1,h&&=(h(),null),p?p.nodeValue=w:(p=document.createTextNode(w),d.parentNode.insertBefore(p,d))};return void(N?(N=!1,t()):b||(b=!0,L(t)))}if(b=!1,N=!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(C(e))h=A(e,d.parentNode,d,_);else if(ye(e)){m||(m=new Map,x=document.createTextNode(""),d.parentNode.insertBefore(x,d));let t=d.parentNode,n=e.items.map((t,n)=>e.keyFn(t,n)),r=new Set(n),l=!1;if(m.size>0)for(let e of m.keys())if(r.has(e)){l=!0;break}if(!l){if(m.size>0){let e=document.createRange();e.setStartAfter(x),e.setEndBefore(d),e.deleteContents();for(let e of m.values())e.cleanup();m.clear()}if(n.length>0){let r=document.createDocumentFragment();v(()=>{for(let t=0;t<n.length;t++){let l=n[t],o=e.items[t],i=document.createTextNode(""),u=document.createTextNode("");r.appendChild(i),r.appendChild(u);let a=e.renderFn(o,t),s=C(a)?A(a,r,u,_):a._render(r,u);m?.set(l,{start:i,end:u,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),u=!1,a=0;for(let e=0;e<y.length;e++){let t=y[e],n=o.get(t);if(void 0===n){let e=m.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}m.delete(t)}else i[n]=e+1,n>=a?a=n:u=!0}let s=u?Ee(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(""),u=document.createDocumentFragment();u.appendChild(o),u.appendChild(i);let a=e.renderFn(n,r),s=C(a)?A(a,u,i,_):a._render(u,i);m.set(l,{start:o,end:i,cleanup:s}),t.insertBefore(u,f),f=o}else{let e=m.get(l);if(u)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(C(n))t.push(oe(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(E(),h&&=(h(),null),p&&=(p.parentNode?.removeChild(p),null),m){for(let e of m.values())e.cleanup();m=null,x=null}})}return{disposes:l,postMountHooks:o}}function Ee(e){let t,n,r,l,o,i=e.slice(),u=[0],a=e.length;for(t=0;t<a;t++){let a=e[t];if(0!==a){if(n=u[u.length-1],e[n]<a){i[t]=n,u.push(t);continue}for(r=0,l=u.length-1;r<l;)o=r+l>>1,e[u[o]]<a?r=o+1:l=o;a<e[u[r]]&&(r>0&&(i[t]=u[r-1]),u[r]=t)}}for(r=u.length,l=u[r-1];r-- >0;)u[r]=l,l=i[l];return u}var De=new WeakMap;function R(e,...t){let n=De.get(e);if(!n){let t=[],r="";for(let n=0;n<e.length-1;n++)r+=e[n],t.push(_e(r)),r+="__nix__";let l=document.createElement("template");l.innerHTML=ve(e,t);let o,i=Array(t.length).fill(null),u=l.content,a=document.createTreeWalker(u,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_COMMENT),s=0;for(;o=a.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},De.set(e,n)}let{contexts:r,tpl:l,pathMap:o}=n;function i(e,n){let i=l.content.cloneNode(!0),{disposes:u,postMountHooks:a}=Te(i,r,t,o),s=document.createTextNode("");return e.insertBefore(s,n),e.insertBefore(i,n),a.forEach(e=>e()),()=>{for(let e=u.length-1;e>=0;e--)u[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 Oe(e,t){if(C(e)){let n,r,l="string"==typeof t?document.querySelector(t):t;if(!l)throw Error(`[Nix] mount: container not found: ${t}`);E();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}n=e.render()._render(l,null)}finally{D()}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 ke(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]=h(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 z=null,B=null;function V(){if(!z)throw Error("[Nix] No active router. Call createRouter() first.");return z}function H(e){let t={};return new URLSearchParams(e).forEach((e,n)=>{t[n]=e}),t}function U(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 Ae(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 je(e,t){return"*"===t?""===e?"*":e+"/*":(e+(t.startsWith("/")?t:"/"+t)).replace(/\/+/g,"/")||"/"}function W(e,t="",n=[]){let r=[];for(let l of e){let e=je(t,l.path),o=[...n,l.component],i=Ae(e);r.push({fullPath:e,segments:i,chain:o,beforeEnter:l.beforeEnter}),l.children?.length&&r.push(...W(l.children,e,o))}return r}function Me(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 Ne(e){return e.segments.reduce((e,t)=>"literal"===t.kind?e+2:"param"===t.kind?e+1:e,0)}function G(e,t){let n,r={},l=-1;for(let o of t){let t=Me(e,o);if(null===t)continue;let i=Ne(o);i>l&&(n=o,r=t,l=i)}return n?{route:n,params:r}:void 0}function K(e){let t=e.trim();return t&&"/"!==t?(t.startsWith("/")||(t="/"+t),t.endsWith("/")&&(t=t.slice(0,-1)),t):""}function Pe(){if(typeof document>"u")return"";let e=document.querySelector("base");if(!e)return"";let t=e.getAttribute("href")||"";try{return K(new URL(t,window.location.origin).pathname)}catch{return K(t)}}function Fe(e,t){let n=null==t?.base?Pe():K(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=W(e),u=G(o,i),a=h(o),s=h(u?.params??{}),c=h(H(window.location.search)),f=[],d=[],p=0;function m(e,t,n,r,l){let o=[...f];n&&o.push(n);let i=++p;if(0===o.length)return void r();let u=0;!function n(a){if(i!==p)return;if(!1===a)return void l?.();if("string"==typeof a)return void(a===e?r():_(a));if(u>=o.length)return void r();let s=o[u++](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?{}:H(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}}B&&=(B(),null);let g=()=>{let e=r(),t=a.value,n=c.value,o=G(e,i),u=H(window.location.search);m(e,t,o?.route.beforeEnter,()=>{s.value=o?.params??{},c.value=u,a.value=e;for(let n of d)try{n(e,t)}catch{}},()=>{history.pushState(null,"",l(t)+U(n))})};function x(e,t,n,r,o){s.value=r?.params??{},c.value=t,a.value=e;let i=l(e)+U(t);o?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),l=a.value,o=G(n,i);m(n,l,o?.route.beforeEnter,()=>x(n,r,l,o,!1))}window.addEventListener("popstate",g),B=()=>window.removeEventListener("popstate",g);let b={current:a,params:s,query:c,base:n||"/",navigate:_,replace:function(e,t){v=!0;let{pathname:n,stringQuery:r}=y(e,t),l=a.value,o=G(n,i);m(n,l,o?.route.beforeEnter,()=>x(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=a.value;return t?n===e:n===e||n.startsWith(e.endsWith("/")?e:e+"/")},resolve:function(t){let n=G(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 z&&console.warn("[Nix] A router already exists. The previous router is being replaced. Only one router instance should be active at a time."),z=b,queueMicrotask(()=>{v||m(o,"",G(o,i)?.route.beforeEnter,()=>{},()=>{history.replaceState(null,"",l("/"));let e=G("/",i);a.value="/",s.value=e?.params??{},c.value={}})}),b}function Ie(){return V()}var Le=class extends S{_depth;constructor(e=0){super(),this._depth=e}render(){let e=this._depth;return R`<div class="router-view">${()=>{let t=V(),n=G(t.current.value,t._flat);return n?e>=n.route.chain.length?R`<span></span>`:n.route.chain[e]():R`<div style="color:#f87171;padding:16px 0">
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var e=[],t=[],n=null,r=null,i=null,a=[];function o(e){a.push(i),i=e}function s(){i=a.pop()??null}var c=0,l=new Set,u=[],d=100,f=0,p=[],m=0,h=class{_value;_subs=new Set;constructor(e){this._value=e}get value(){return n&&(this._subs.add(n),r?.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.has(e)||(l.add(e),u.push(e));return}let e=m,t=0;for(let n of this._subs)p[e+t++]=n;m=e+t;try{for(let n=0;n<t;n++){let t=p[e+n];p[e+n]=null,t?.()}}finally{m=e}}dispose(){this._subs.clear()}};function g(e){return new h(e)}function _(l){let o,u=!1,a=new Set,s=new Set,c=i,p=()=>{if(u)return;"function"==typeof o&&o();let i=a;a=s,s=i,s.clear();let h=e.length>0?e.pop():{effect:null,deps:null};if(h.effect=n,h.deps=r,t.push(h),n=p,r=s,++f>d){f=0;let l=t.pop();throw n=l.effect,r=l.deps,l.effect=null,l.deps=null,e.push(l),Error("[Nix] Maximum effect re-execution depth exceeded (possible infinite loop).")}try{o=l()}catch(e){if(!c)throw e;c(e)}finally{f--;let l=t.pop();n=l.effect,r=l.deps,l.effect=null,l.deps=null,e.push(l);for(let e of a)s.has(e)||e._removeSub(p)}};return p(),()=>{u=!0,"function"==typeof o&&o();for(let e of s)e._removeSub(p);s.clear(),a.clear()}}function v(e){let t=new h(void 0),n=_(()=>{t.value=e()}),r=t.dispose;return t.dispose=()=>{n(),r.call(t)},t}function y(e){c++;try{e()}finally{if(0===--c&&u.length>0){let e=u.length;for(let t=0;t<e;t++)u[t]();u.length=0,l.clear()}}}function b(e){let t=n,l=r;n=null,r=null;try{return e()}finally{n=t,r=l}}function x(e,t,n={}){let r,{immediate:l=!1,once:o=!1}=n,i=e instanceof h?()=>e.value:e,u=!0,a=!1,s=_(()=>{let e=i();if(u){if(u=!1,l&&!a){let n=e;b(()=>t(n,void 0)),o&&(a=!0,Promise.resolve().then(s))}r=e}else if(!a){let n=e,l=r;r=e,b(()=>t(n,l)),o&&(a=!0,Promise.resolve().then(s))}});return()=>{a=!0,s()}}function S(e){return e?Promise.resolve().then(e):Promise.resolve()}var C=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 w(e){return"object"==typeof e&&!!e&&!0===e.__isNixComponent}function T(e){return Symbol(e)}var E=[];function ee(){return[...E]}function D(){E.push(new Map)}function O(){E.pop()}function te(e,t){let n=E.splice(0);e.forEach(e=>E.push(e)),E.push(new Map);try{return t()}finally{E.splice(0),n.forEach(e=>E.push(e))}}function k(e,t){let n=E[E.length-1];if(!n)throw Error("[Nix] provide() must be called inside onInit() of a NixComponent.");n.set(e,t)}function A(e){for(let t=E.length-1;t>=0;t--)if(E[t].has(e))return E[t].get(e)}var j={SCOPE:"nix-scope",ERROR_BOUNDARY:"nix-eb",TRANSITION:"nix-t",KEYED_START:"nix-ks",KEYED_END:"nix-ke",KEYED_ZONE:"nix-kz"};function ne(){return{el:null}}function re(e,t){t?"none"===e.style.display&&(e.style.display=""):"none"!==e.style.display&&(e.style.display="none")}function ie(e,t,n){return{__isKeyedList:!0,items:e,keyFn:t,renderFn:n}}function ae(e,t,n){let r,l;D();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}r=e.render()._render(t,n)}finally{O()}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 oe(e,t,n){let r,l;D();try{try{e.onInit?.()}catch{}r=e.render()._render(t,n)}finally{O()}try{let t=e.onMount?.();"function"==typeof t&&(l=t)}catch{}return()=>{try{e.onUnmount?.()}catch{}try{l?.()}catch{}r()}}function M(e,t,n,r){let l,o;te(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 se(e,t,n,r,l){let o,i;D();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}o=e.render()._render(t,n)}finally{O()}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 ce(){return{__isPortalOutlet:!0,_container:null}}function le(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 ue(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,w(e)?ae(e,l,null):e._render(l,null)}}}var de=T("nix:portal-outlet");function fe(e){k(de,e)}function pe(){return A(de)}function me(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(j.ERROR_BOUNDARY);n.insertBefore(l,r);let i,u=null,a=!1,c=!1,f=!1,d=e=>{let n=l.parentNode,o="function"!=typeof t||w(t)?t:t(e);u=w(o)?oe(o,n,r):o._render(n,r)};o(e=>{a||(a=!0,c?(u?.(),u=null,d(e)):(i=e,f=!0))});try{if(w(e)){D();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}u=e.render()._render(n,r)}finally{O()}if(!a)try{let t=e.onMount?.(),n=u;u=()=>{try{e.onUnmount?.()}catch{}if("function"==typeof t)try{t()}catch{}n?.()}}catch(t){if(!e.onError)throw t;e.onError(t)}}else u=e._render(n,r)}catch(e){a=!0,u?.(),u=null,i=e,f=!0}finally{s(),c=!0}return f&&(u?.(),u=null,d(i)),()=>{u?.(),l.remove()}}}}function he(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 N(e){return Math.max(0,...e.split(",").map(e=>parseFloat(e.trim())||0))}function P(e,t=0){return new Promise(n=>{let r=getComputedStyle(e),l=1e3*Math.max(N(r.transitionDuration||"0"),N(r.animationDuration||"0")),o=l>0?l+100:t;if(o<=0)return void n();let i,u=t=>{t.target===e&&(clearTimeout(i),e.removeEventListener("transitionend",u),e.removeEventListener("animationend",u),n())};e.addEventListener("transitionend",u),e.addEventListener("animationend",u),i=setTimeout(()=>{e.removeEventListener("transitionend",u),e.removeEventListener("animationend",u),n()},o)})}function ge(e,t={}){let n=he(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(j.TRANSITION);r.insertBefore(o,l);let i=null,u=null,a=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 w(e)?oe(e,r,l):e._render(r,l)}let d=(e,r=!1)=>{a++,u&&=(u(),null),i=f(e);let l=c();if(l&&(!s||t.appear)&&!r){let e=a;(async()=>{t.onBeforeEnter?.(l),l.classList.add(n.enterFrom,n.enterActive),l.getBoundingClientRect(),await new Promise(e=>requestAnimationFrame(()=>e())),a===e&&(l.classList.remove(n.enterFrom),l.classList.add(n.enterTo),await P(l,t.duration),a===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=++a;u=e??null,(async()=>{t.onBeforeLeave?.(r),r.classList.add(n.leaveFrom,n.leaveActive),r.getBoundingClientRect(),await new Promise(e=>requestAnimationFrame(()=>e())),a===l&&(r.classList.remove(n.leaveFrom),r.classList.add(n.leaveTo),await P(r,t.duration),a===l&&(r.classList.remove(n.leaveActive,n.leaveTo),t.onAfterLeave?.(r),u?.(),u=null))})().catch(()=>{})},h=null;if("function"!=typeof e||w(e))d(e);else{let t=e,n=null;h=_(()=>{let e=t(),r=null===n,l=null===e;r&&!l?d(e):!r&&l?p():!r&&!l&&(a++,u?.(),u=null,i?.(),i=null,d(e,!0)),n=e}),s=!1}return()=>{a++,h?.(),i?.(),u?.(),i=null,u=null,o.remove()}}}}function _e(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 u=r.slice(i,l);if("@"===u[0]){let e=u.slice(1).split(".");return{type:"event",eventName:e[0],modifiers:e.slice(1),hadOpenQuote:o}}return{type:"attr",attrName:u,hadOpenQuote:o}}function ve(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 F(e){return"object"==typeof e&&!!e&&!0===e.__isNixTemplate}function ye(e){return"object"==typeof e&&!!e&&!0===e.__isKeyedList}var be={enter:"Enter",escape:"Escape",space:" ",tab:"Tab",delete:"Delete",backspace:"Backspace",up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight"},xe=new Set(["click","dblclick","mousedown","mouseup","keydown","keyup","input","change","submit"]),I=new Set;function Se(e,t,n){let r=e.target,l=e.stopPropagation,o=!1;for(e.stopPropagation=()=>{o=!0,l.call(e)};r&&r!==document;){let l=r[t];if(l){let t=r[n];if(t){if(t.includes("prevent")&&e.preventDefault(),t.includes("stop")&&e.stopPropagation(),t.includes("self")&&e.target!==r){r=r.parentNode;continue}if("key"in e){let n=e,l=!0;for(let e of t){let t=be[e];if(void 0!==t&&n.key!==t){l=!1;break}if(!t&&1===e.length&&n.key.toLowerCase()!==e){l=!1;break}}if(!l){r=r.parentNode;continue}}}if(l(e),o)break}r=r.parentNode}e.stopPropagation=l}var Ce=new Map,L=new Set,R=!1;function z(e){L.add(e),R||(R=!0,queueMicrotask(()=>{for(let e of L)e();L.clear(),R=!1}))}function we(e,t,n,r){let l=[],o=[],i=Array(t.length),u=-1;for(let e=0;e<t.length;e++)r[e]&&r[e].nodeIndex>u&&(u=r[e].nodeIndex);let a=Array(u+1);if(a[0]=e,u>0){let t,n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_COMMENT),r=1;for(;r<=u&&(t=n.nextNode());)a[r++]=t}for(let e=0;e<t.length;e++){let t=r[e];i[e]=t?a[t.nodeIndex]:null}for(let e=0;e<t.length;e++){let u=t[e],a=n[e],s=r[e];if(!s)continue;let c=i[e];if("event"===u.type){let e=s.name,t=a,n=u.modifiers;if(!xe.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{if(!I.has(e)){let t=`__nix_${e}`,n=`__nix_${e}_mods`,r=e=>Se(e,t,n);Ce.set(e,r),document.addEventListener(e,r),I.add(e)}let r=`__nix_${e}`,o=`__nix_${e}_mods`;c[r]=t,n.length>0&&(c[o]=n),l.push(()=>{c[r]=null,c[o]=null})}continue}if("attr"===u.type){let e=s.name,t=c;if("ref"===e){a.el=t,l.push(()=>{a.el=null});continue}if("show"===e||"hide"===e){let n=t,r=null;if("function"==typeof a){let t=!1,o=!1,i=!0,u=_(()=>{o=!!a();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,z(l))});l.push(u)}else("show"===e?a:!a)||(n.style.display="none");continue}let n=("value"===e||"checked"===e||"selected"===e)&&e in t;if("function"==typeof a){let r,o=!1,i=!0,u=_(()=>{r=a();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,z(l))});l.push(u)}else n?t[e]=a??"":null!=a&&!1!==a&&t.setAttribute(e,String(a));continue}let f=c;if(!f)continue;let d=document.createTextNode("");if(f.parentNode.replaceChild(d,f),"function"!=typeof a){if(w(a))se(a,d.parentNode,d,o,l);else if(F(a)){let e=a._render(d.parentNode,d);l.push(e)}else if(Array.isArray(a))for(let e of a)w(e)?se(e,d.parentNode,d,o,l):F(e)?e._render(d.parentNode,d):null!=e&&!1!==e&&d.parentNode.insertBefore(document.createTextNode(String(e)),d);else null!=a&&!1!==a&&d.parentNode.insertBefore(document.createTextNode(String(a)),d);continue}let p=null,h=null,v=null,m=[],g=null,x=ee(),b=!1,E="",N=!0,S=_(()=>{let e=a();if("string"==typeof e||"number"==typeof e){E=String(e);let t=()=>{b=!1,h&&=(h(),null),p?p.nodeValue=E:(p=document.createTextNode(E),d.parentNode.insertBefore(p,d))};return void(N?(N=!1,t()):b||(b=!0,z(t)))}if(b=!1,N=!1,p&&=(p.parentNode?.removeChild(p),null),h&&=(h(),null),null!=e&&!1!==e)if(F(e))h=e._render(d.parentNode,d);else if(w(e))h=M(e,d.parentNode,d,x);else if(ye(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();y(()=>{for(let t=0;t<n.length;t++){let l=n[t],o=e.items[t],i=document.createTextNode(""),u=document.createTextNode("");r.appendChild(i),r.appendChild(u);let a=e.renderFn(o,t),s=w(a)?M(a,r,u,x):a._render(r,u);v?.set(l,{start:i,end:u,cleanup:s})}}),t.insertBefore(r,d)}return void(m=n)}let o=new Map;for(let e=0;e<n.length;e++)o.set(n[e],e);let i=new Int32Array(n.length),u=!1,a=0;for(let e=0;e<m.length;e++){let t=m[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>=a?a=n:u=!0}let s=u?Te(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(""),u=document.createDocumentFragment();u.appendChild(o),u.appendChild(i);let a=e.renderFn(n,r),s=w(a)?M(a,u,i,x):a._render(u,i);v.set(l,{start:o,end:i,cleanup:s}),t.insertBefore(u,f),f=o}else{let e=v.get(l);if(u)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}}m=n}else if(Array.isArray(e)){let t=[];for(let n of e)if(w(n))t.push(ae(n,d.parentNode,d));else if(F(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 Te(e){let t,n,r,l,o,i=e.slice(),u=[0],a=e.length;for(t=0;t<a;t++){let a=e[t];if(0!==a){if(n=u[u.length-1],e[n]<a){i[t]=n,u.push(t);continue}for(r=0,l=u.length-1;r<l;)o=r+l>>1,e[u[o]]<a?r=o+1:l=o;a<e[u[r]]&&(r>0&&(i[t]=u[r-1]),u[r]=t)}}for(r=u.length,l=u[r-1];r-- >0;)u[r]=l,l=i[l];return u}var Ee=new WeakMap;function B(e,...t){let n=Ee.get(e);if(!n){let t=[],r="";for(let n=0;n<e.length-1;n++)r+=e[n],t.push(_e(r)),r+="__nix__";let l=document.createElement("template");l.innerHTML=ve(e,t);let o,i=Array(t.length).fill(null),u=l.content,a=document.createTreeWalker(u,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_COMMENT),s=0;for(;o=a.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},Ee.set(e,n)}let{contexts:r,tpl:l,pathMap:o}=n;function i(e,n){let i=l.content.cloneNode(!0),{disposes:u,postMountHooks:a}=we(i,r,t,o),s=document.createTextNode("");return e.insertBefore(s,n),e.insertBefore(i,n),a.forEach(e=>e()),()=>{for(let e=u.length-1;e>=0;e--)u[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 De(e,t){if(w(e)){let n,r,l="string"==typeof t?document.querySelector(t):t;if(!l)throw Error(`[Nix] mount: container not found: ${t}`);D();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}n=e.render()._render(l,null)}finally{O()}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 Oe(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]=g(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 ke(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 Ae(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 je(e,t){return"*"===t?""===e?"*":e+"/*":(e+(t.startsWith("/")?t:"/"+t)).replace(/\/+/g,"/")||"/"}function Me(e,t="",n=[]){let r=[];for(let l of e){let e=je(t,l.path),o=[...n,l.component],i=Ae(e);r.push({fullPath:e,segments:i,chain:o,beforeEnter:l.beforeEnter}),l.children?.length&&r.push(...Me(l.children,e,o))}return r}function Ne(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 Pe(e){return e.segments.reduce((e,t)=>"literal"===t.kind?e+2:"param"===t.kind?e+1:e,0)}function G(e,t){let n,r={},l=-1;for(let o of t){let t=Ne(e,o);if(null===t)continue;let i=Pe(o);i>l&&(n=o,r=t,l=i)}return n?{route:n,params:r}:void 0}function K(e){let t=e.trim();return t&&"/"!==t?(t.startsWith("/")||(t="/"+t),t.endsWith("/")&&(t=t.slice(0,-1)),t):""}function Fe(){if(typeof document>"u")return"";let e=document.querySelector("base");if(!e)return"";let t=e.getAttribute("href")||"";try{return K(new URL(t,window.location.origin).pathname)}catch{return K(t)}}function Ie(e,t){let n=null==t?.base?Fe():K(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=Me(e),u=G(o,i),a=g(o),s=g(u?.params??{}),c=g(W(window.location.search)),f=[],d=[],p=0;function h(e,t,n,r,l){let o=[...f];n&&o.push(n);let i=++p;if(0===o.length)return void r();let u=0;!function n(a){if(i!==p)return;if(!1===a)return void l?.();if("string"==typeof a)return void(a===e?r():_(a));if(u>=o.length)return void r();let s=o[u++](e,t);s instanceof Promise?s.then(n):n(s)}(void 0)}let v=!1;function m(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 y=()=>{let e=r(),t=a.value,n=c.value,o=G(e,i),u=W(window.location.search);h(e,t,o?.route.beforeEnter,()=>{s.value=o?.params??{},c.value=u,a.value=e;for(let n of d)try{n(e,t)}catch{}},()=>{history.pushState(null,"",l(t)+ke(n))})};function x(e,t,n,r,o){s.value=r?.params??{},c.value=t,a.value=e;let i=l(e)+ke(t);o?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}=m(e,t),l=a.value,o=G(n,i);h(n,l,o?.route.beforeEnter,()=>x(n,r,l,o,!1))}window.addEventListener("popstate",y),H=()=>window.removeEventListener("popstate",y);let b={current:a,params:s,query:c,base:n||"/",navigate:_,replace:function(e,t){v=!0;let{pathname:n,stringQuery:r}=m(e,t),l=a.value,o=G(n,i);h(n,l,o?.route.beforeEnter,()=>x(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=a.value;return t?n===e:n===e||n.startsWith(e.endsWith("/")?e:e+"/")},resolve:function(t){let n=G(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||h(o,"",G(o,i)?.route.beforeEnter,()=>{},()=>{history.replaceState(null,"",l("/"));let e=G("/",i);a.value="/",s.value=e?.params??{},c.value={}})}),b}function Le(){return U()}var Re=class extends C{_depth;constructor(e=0){super(),this._depth=e}render(){let e=this._depth;return B`<div class="router-view">${()=>{let t=U(),n=G(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
|
-
</div>`}}</div>`}},
|
|
4
|
-
href=${(
|
|
5
|
-
style=${()=>
|
|
6
|
-
@click=${t=>{t.preventDefault(),
|
|
7
|
-
>${t}</a>`}};function
|
|
3
|
+
</div>`}}</div>`}},ze=class extends C{_to;_label;constructor(e,t){super(),this._to=e,this._label=t}render(){let e=this._to,t=this._label;return B`<a
|
|
4
|
+
href=${(U()._base||"")+(e.startsWith("/")?e:"/"+e)}
|
|
5
|
+
style=${()=>U().current.value===e?"color:#38bdf8;font-weight:700;text-decoration:none;cursor:pointer;padding:4px 10px;border-radius:4px;background:#0c2a3a":"color:#a3a3a3;text-decoration:none;cursor:pointer;padding:4px 10px;border-radius:4px"}
|
|
6
|
+
@click=${t=>{t.preventDefault(),U().navigate(e)}}
|
|
7
|
+
>${t}</a>`}};function Be(){return B`
|
|
8
8
|
<span style="color:#52525b;font-size:13px;display:inline-flex;align-items:center;gap:6px">
|
|
9
9
|
<span class="nix-spinner" style="
|
|
10
10
|
display:inline-block;width:14px;height:14px;border-radius:50%;
|
|
@@ -14,8 +14,8 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var e=[],t=[]
|
|
|
14
14
|
Loading…
|
|
15
15
|
</span>
|
|
16
16
|
<style>@keyframes nix-spin{to{transform:rotate(360deg)}}</style>
|
|
17
|
-
`}function
|
|
17
|
+
`}function Ve(e){return B`
|
|
18
18
|
<span style="color:#f87171;font-size:13px">
|
|
19
19
|
⚠ ${e instanceof Error?e.message:String(e)}
|
|
20
20
|
</span>
|
|
21
|
-
`}var q=new Map,
|
|
21
|
+
`}var q=new Map,He=3e5,J=null,Ue=He;function We(){null===J&&(J=setInterval(()=>{let e=Date.now();for(let[t,n]of q)n.subscribers<=0&&e-n.fetchedAt>Ue&&q.delete(t);0===q.size&&null!==J&&(clearInterval(J),J=null)},6e4))}function Y(e){return q.get(e)}function Ge(e,t){let n=q.get(e);q.set(e,{data:t,fetchedAt:Date.now(),subscribers:n?.subscribers??0}),We()}function Ke(e){let t=q.get(e);t&&t.subscribers++}function qe(e){let t=q.get(e);t&&(t.subscribers=Math.max(0,t.subscribers-1))}function X(e,t){let n=q.get(e);return!!n&&Date.now()-n.fetchedAt<t}function Je(e){void 0===e?q.clear():q.delete(e)}function Ye(e){Ue=e}function Xe(e,t,n={}){let{fallback:r,errorFallback:l,resetOnRefresh:o=!1,invalidate:i,cacheKey:u,staleTime:a=0}=n,s=r??Be(),c=l??Ve;return new class extends C{_state;_disposeWatcher;constructor(){super();let e=u?Y(u):void 0;this._state=g(e?{status:"resolved",data:e.data}:{status:"pending"})}onMount(){u&&Ke(u);let e=u?Y(u):void 0;if(e&&X(u,a)||(e?this._fetch():this._run()),i){let e=!0;this._disposeWatcher=_(()=>{i.value,e?e=!1:(u&&q.delete(u),this._run())})}return()=>{this._disposeWatcher?.(),u&&qe(u)}}_run(){(o||"pending"===this._state.peek().status)&&(this._state.value={status:"pending"}),this._fetch()}_fetch(){e().then(e=>{u&&Ge(u,e),this._state.value={status:"resolved",data:e}},e=>{this._state.value={status:"error",error:e}})}render(){return B`<div class="nix-suspense" style="display:contents">${()=>{let e=this._state.value;return"pending"===e.status?s:"error"===e.status?c(e.error):t(e.data)}}</div>`}}}var Z=new Map;function Ze(e){q.delete(e);let t=Z.get(e);if(t)for(let e of t)e()}function Qe(e,t,n,r={}){let{fallback:l,errorFallback:o,resetOnRefresh:i=!1,staleTime:u=0,refetchOnMount:a="always"}=r,s=l??Be(),c=o??Ve;return new class extends C{_state;constructor(){super();let t=Y(e);this._state=g(t?{status:"resolved",data:t.data}:{status:"pending"})}onMount(){Z.has(e)||Z.set(e,new Set);let t=Z.get(e),n=()=>this._run();t.add(n),Ke(e);let r=Y(e),l=X(e,u);return r?!1===a||"stale"===a&&l||"always"===a&&l&&u>0||this._fetch():this._run(),()=>{t.delete(n),0===t.size&&Z.delete(e),qe(e)}}_run(){(i||"pending"===this._state.peek().status)&&(this._state.value={status:"pending"}),this._fetch()}_fetch(){t().then(t=>{Ge(e,t),this._state.value={status:"resolved",data:t}},e=>{this._state.value={status:"error",error:e}})}render(){return B`<div class="nix-query" style="display:contents">${()=>{let e=this._state.value;return"pending"===e.status?s:"error"===e.status?c(e.error):n(e.data)}}</div>`}}}function $e(e,t){let n=null;return()=>n?new n:Xe(async()=>(n=(await e()).default,n),e=>new e,{fallback:t})}function et(e="Required"){return t=>null==t||""===t||Array.isArray(t)&&0===t.length?e:null}function tt(e,t){return n=>"string"==typeof n&&n.length<e?t??`Minimum ${e} characters`:null}function nt(e,t){return n=>"string"==typeof n&&n.length>e?t??`Maximum ${e} characters`:null}function Q(e,t="Invalid format"){return n=>"string"!=typeof n||e.test(n)?null:t}function rt(e="Invalid email"){return Q(/^[^\s@]+@[^\s@]+\.[^\s@]+$/,e)}function it(e,t){return n=>"number"==typeof n&&n<e?t??`Minimum value is ${e}`:null}function at(e,t){return n=>"number"==typeof n&&n>e?t??`Maximum value is ${e}`:null}function ot(e){return e}const st={required:et,minLength:tt,maxLength:nt,email:rt,pattern:Q,min:it,max:at};function ct(e,t){return{...e,...t}}function $(e,t=[],n="blur"){let r=g(e),l=g(!1),o=g(!1),i=g(null),u=g(!1),a=v(()=>{if(i.value)return i.value;if(!("input"===n?o.value||l.value:"submit"===n?u.value:l.value))return null;for(let e of t){let t=e(r.value);if(t)return t}return null});function s(t){if(!t||!("value"in t))return e;let n=t;return"boolean"==typeof e?n.checked:"number"==typeof e?Number(n.value):n.value}return{value:r,error:a,touched:l,dirty:o,onInput:e=>{r.value=s(e.target),o.value=!0,i.value=null},onBlur:()=>{l.value=!0},reset:function(){r.value=e,l.value=!1,o.value=!1,i.value=null,u.value=!1},_setExternalError:function(e){i.value=e,e&&(l.value=!0)},_forceVisible:function(){l.value=!0,u.value=!0},_dispose:function(){a.dispose()}}}function lt(e,t={},n="blur"){function r(e){let r={};for(let l in e){let o=t[l]??[];r[l]=$(e[l],o,n)}return r}let l=g(e.map(r)),o=v(()=>l.value.length);return{fields:l,append:function(e){l.value=[...l.value,r(e)]},remove:function(e){let t=l.value;if(!(e<0||e>=t.length)){for(let n in t[e])t[e][n]._dispose();l.value=t.filter((t,n)=>n!==e)}},move:function(e,t){let n=[...l.value];if(e<0||e>=n.length||t<0||t>=n.length||e===t)return;let[r]=n.splice(e,1);n.splice(t,0,r),l.value=n},replace:function(e,t){let n=[...l.value];if(!(e<0||e>=n.length)){for(let t in n[e])n[e][t]._dispose();n[e]=r(t),l.value=n}},length:o,reset:function(){for(let e of l.value)for(let t in e)e[t]._dispose();l.value=e.map(r)},_dispose:function(){for(let e of l.value)for(let t in e)e[t]._dispose();o.dispose()}}}function ut(e,t={}){let n=t.validateOn??"blur",r={};for(let l in e){let o=t.validators?.[l]??[];r[l]=$(e[l],o,n)}let l=g(!1),o=g(0),i=v(()=>{let e={};for(let t in r)e[t]=r[t].value.value;return e}),u=v(()=>{let e={};for(let t in r){let n=r[t].error.value;n&&(e[t]=n)}return e}),a=v(()=>{for(let e in r)if(r[e].error.value)return!1;return!0}),s=v(()=>{for(let e in r)if(r[e].dirty.value)return!0;return!1}),c=v(()=>{for(let e in r)if(r[e].touched.value)return!0;return!1});function f(e){for(let t in e)r[t]?._setExternalError(e[t]??null)}return{fields:r,values:i,errors:u,valid:a,dirty:s,touched:c,isSubmitting:l,submitCount:o,handleSubmit:function(e){return n=>{n.preventDefault(),o.value++;for(let e in r)r[e]._forceVisible();let u=i.value;if(t.validate){let e=t.validate(u);if(e){let t={},n=!1;for(let r in e){let l=e[r],o=Array.isArray(l)?l[0]??null:l??null;o&&(t[r]=o,n=!0)}if(n)return void f(t)}}for(let e in r)if(r[e].error.value)return;let a=e(u);a instanceof Promise&&(l.value=!0,a.finally(()=>{l.value=!1}).catch(()=>{}))}},reset:function(){for(let e in r)r[e].reset();l.value=!1,o.value=0},setErrors:f,dispose:function(){i.dispose(),u.dispose(),a.dispose(),s.dispose(),c.dispose();for(let e in r)r[e]._dispose()}}}exports.Link=ze,exports.NixComponent=C,exports.RouterView=Re,exports.Signal=h,exports.batch=y,exports.clearQueryCache=Je,exports.computed=v,exports.createErrorBoundary=me,exports.createForm=ut,exports.createInjectionKey=T,exports.createPortalOutlet=ce,exports.createQuery=Qe,exports.createRouter=Ie,exports.createStore=Oe,exports.createValidator=ot,exports.effect=_,exports.email=rt,exports.extendValidators=ct,exports.html=B,exports.inject=A,exports.injectOutlet=pe,exports.invalidateQueries=Ze,exports.lazy=$e,exports.max=at,exports.maxLength=nt,exports.min=it,exports.minLength=tt,exports.mount=De,exports.nextTick=S,exports.pattern=Q,exports.portal=ue,exports.portalOutlet=le,exports.provide=k,exports.provideOutlet=fe,exports.ref=ne,exports.repeat=ie,exports.required=et,exports.setQueryCacheTime=Ye,exports.showWhen=re,exports.signal=g,exports.suspend=Xe,exports.transition=ge,exports.untrack=b,exports.useField=$,exports.useFieldArray=lt,exports.useRouter=Le,exports.validators=st,exports.watch=x;
|
package/dist/lib/nix-js.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
var e=[],t=[],n=null,r=null,i=null,a=[];function o(e){a.push(i),i=e}function s(){i=a.pop()??null}var c=0,l=new Set,u=[],d=100,f=0,p=[],m=class{_value;_subs=new Set;constructor(e){this._value=e}get value(){return n&&(this._subs.add(n),r?.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.has(e)||(l.add(e),u.push(e));return}let e=0;for(let t of this._subs)p[e++]=t;for(let t=0;t<e;t++)p[t](),p[t]=null}dispose(){this._subs.clear()}};function h(e){return new m(e)}function g(l){let o,a=!1,u=new Set,s=new Set,c=i,p=()=>{if(a)return;"function"==typeof o&&o();let i=u;u=s,s=i,s.clear();let h=e.length>0?e.pop():{effect:null,deps:null};if(h.effect=n,h.deps=r,t.push(h),n=p,r=s,++f>d){f=0;let l=t.pop();throw n=l.effect,r=l.deps,l.effect=null,l.deps=null,e.push(l),Error("[Nix] Maximum effect re-execution depth exceeded (possible infinite loop).")}try{o=l()}catch(e){if(!c)throw e;c(e)}finally{f--;let l=t.pop();if(n=l.effect,r=l.deps,l.effect=null,l.deps=null,e.push(l),u.size!==s.size)for(let e of u)s.has(e)||e._removeSub(p)}};return p(),()=>{a=!0,"function"==typeof o&&o();for(let e of s)e._removeSub(p);s.clear(),u.clear()}}function _(e){let t=new m(void 0),n=g(()=>{t.value=e()}),r=t.dispose;return t.dispose=()=>{n(),r.call(t)},t}function v(e){c++;try{e()}finally{if(0===--c&&u.length>0){let e=u.length;for(let t=0;t<e;t++)u[t]();u.length=0,l.clear()}}}function y(e){let t=n,l=r;n=null,r=null;try{return e()}finally{n=t,r=l}}function b(e,t,n={}){let r,{immediate:l=!1,once:o=!1}=n,i=e instanceof m?()=>e.value:e,a=!0,u=!1,s=g(()=>{let e=i();if(a){if(a=!1,l&&!u){let n=e;y(()=>t(n,void 0)),o&&(u=!0,Promise.resolve().then(s))}r=e}else if(!u){let n=e,l=r;r=e,y(()=>t(n,l)),o&&(u=!0,Promise.resolve().then(s))}});return()=>{u=!0,s()}}function x(e){return e?Promise.resolve().then(e):Promise.resolve()}var S=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 C(e){return"object"==typeof e&&!!e&&!0===e.__isNixComponent}function w(e){return Symbol(e)}var T=[];function ee(){return[...T]}function E(){T.push(new Map)}function D(){T.pop()}function O(e,t){let n=T.splice(0);e.forEach(e=>T.push(e)),T.push(new Map);try{return t()}finally{T.splice(0),n.forEach(e=>T.push(e))}}function k(e,t){let n=T[T.length-1];if(!n)throw Error("[Nix] provide() must be called inside onInit() of a NixComponent.");n.set(e,t)}function te(e){for(let t=T.length-1;t>=0;t--)if(T[t].has(e))return T[t].get(e)}var ne={SCOPE:"nix-scope",ERROR_BOUNDARY:"nix-eb",TRANSITION:"nix-t",KEYED_START:"nix-ks",KEYED_END:"nix-ke",KEYED_ZONE:"nix-kz"};function re(){return{el:null}}function ie(e,t){t?"none"===e.style.display&&(e.style.display=""):"none"!==e.style.display&&(e.style.display="none")}function ae(e,t,n){return{__isKeyedList:!0,items:e,keyFn:t,renderFn:n}}function oe(e,t,n){let r,l;E();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}r=e.render()._render(t,n)}finally{D()}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 se(e,t,n){let r,l;E();try{try{e.onInit?.()}catch{}r=e.render()._render(t,n)}finally{D()}try{let t=e.onMount?.();"function"==typeof t&&(l=t)}catch{}return()=>{try{e.onUnmount?.()}catch{}try{l?.()}catch{}r()}}function A(e,t,n,r){let l,o;O(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 ce(e,t,n,r,l){let o,i;E();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}o=e.render()._render(t,n)}finally{D()}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 le(){return{__isPortalOutlet:!0,_container:null}}function ue(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 de(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,C(e)?oe(e,l,null):e._render(l,null)}}}var j=w("nix:portal-outlet");function fe(e){k(j,e)}function pe(){return te(j)}function me(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(ne.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||C(t)?t:t(e);a=C(o)?se(o,n,r):o._render(n,r)};o(e=>{u||(u=!0,c?(a?.(),a=null,d(e)):(i=e,f=!0))});try{if(C(e)){E();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}a=e.render()._render(n,r)}finally{D()}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 he(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 M(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(M(r.transitionDuration||"0"),M(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 ge(e,t={}){let n=he(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(ne.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 C(e)?se(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||C(e))d(e);else{let t=e,n=null;h=g(()=>{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 _e(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 ve(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 ye(e){return"object"==typeof e&&!!e&&!0===e.__isKeyedList}var be={enter:"Enter",escape:"Escape",space:" ",tab:"Tab",delete:"Delete",backspace:"Backspace",up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight"},xe=new Set(["click","dblclick","mousedown","mouseup","keydown","keyup","input","change","submit"]),Se=new Set;function Ce(e,t,n){let r=e.target,l=e.stopPropagation,o=!1;for(e.stopPropagation=()=>{o=!0,l.call(e)};r&&r!==document;){let l=r[t];if(l){let t=r[n];if(t){if(t.includes("prevent")&&e.preventDefault(),t.includes("stop")&&e.stopPropagation(),t.includes("self")&&e.target!==r){r=r.parentNode;continue}if("key"in e){let n=e,l=!0;for(let e of t){let t=be[e];if(void 0!==t&&n.key!==t){l=!1;break}if(!t&&1===e.length&&n.key.toLowerCase()!==e){l=!1;break}}if(!l){r=r.parentNode;continue}}}if(l(e),o)break}r=r.parentNode}e.stopPropagation=l}var we=new Map,F=new Set,I=!1;function L(e){F.add(e),I||(I=!0,queueMicrotask(()=>{for(let e of F)e();F.clear(),I=!1}))}function Te(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=Array(a+1);if(u[0]=e,a>0){let t,n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_COMMENT),r=1;for(;r<=a&&(t=n.nextNode());)u[r++]=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(!xe.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{if(!Se.has(e)){let t=`__nix_${e}`,n=`__nix_${e}_mods`,r=e=>Ce(e,t,n);we.set(e,r),document.addEventListener(e,r),Se.add(e)}let r=`__nix_${e}`,o=`__nix_${e}_mods`;c[r]=t,n.length>0&&(c[o]=n),l.push(()=>{c[r]=null,c[o]=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=g(()=>{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,L(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=g(()=>{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,L(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(C(u))ce(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)C(e)?ce(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,m=null,y=[],_=null,b=ee(),x=!1,w="",N=!0,E=g(()=>{let e=u();if("string"==typeof e||"number"==typeof e){w=String(e);let t=()=>{x=!1,h&&=(h(),null),p?p.nodeValue=w:(p=document.createTextNode(w),d.parentNode.insertBefore(p,d))};return void(N?(N=!1,t()):x||(x=!0,L(t)))}if(x=!1,N=!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(C(e))h=A(e,d.parentNode,d,b);else if(ye(e)){m||(m=new Map,_=document.createTextNode(""),d.parentNode.insertBefore(_,d));let t=d.parentNode,n=e.items.map((t,n)=>e.keyFn(t,n)),r=new Set(n),l=!1;if(m.size>0)for(let e of m.keys())if(r.has(e)){l=!0;break}if(!l){if(m.size>0){let e=document.createRange();e.setStartAfter(_),e.setEndBefore(d),e.deleteContents();for(let e of m.values())e.cleanup();m.clear()}if(n.length>0){let r=document.createDocumentFragment();v(()=>{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=C(u)?A(u,r,a,b):u._render(r,a);m?.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=m.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}m.delete(t)}else i[n]=e+1,n>=u?u=n:a=!0}let s=a?Ee(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=C(u)?A(u,a,i,b):u._render(a,i);m.set(l,{start:o,end:i,cleanup:s}),t.insertBefore(a,f),f=o}else{let e=m.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(C(n))t.push(oe(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(E(),h&&=(h(),null),p&&=(p.parentNode?.removeChild(p),null),m){for(let e of m.values())e.cleanup();m=null,_=null}})}return{disposes:l,postMountHooks:o}}function Ee(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 De=new WeakMap;function R(e,...t){let n=De.get(e);if(!n){let t=[],r="";for(let n=0;n<e.length-1;n++)r+=e[n],t.push(_e(r)),r+="__nix__";let l=document.createElement("template");l.innerHTML=ve(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},De.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}=Te(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 Oe(e,t){if(C(e)){let n,r,l="string"==typeof t?document.querySelector(t):t;if(!l)throw Error(`[Nix] mount: container not found: ${t}`);E();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}n=e.render()._render(l,null)}finally{D()}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 ke(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]=h(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 z=null,B=null;function V(){if(!z)throw Error("[Nix] No active router. Call createRouter() first.");return z}function H(e){let t={};return new URLSearchParams(e).forEach((e,n)=>{t[n]=e}),t}function U(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 Ae(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 je(e,t){return"*"===t?""===e?"*":e+"/*":(e+(t.startsWith("/")?t:"/"+t)).replace(/\/+/g,"/")||"/"}function W(e,t="",n=[]){let r=[];for(let l of e){let e=je(t,l.path),o=[...n,l.component],i=Ae(e);r.push({fullPath:e,segments:i,chain:o,beforeEnter:l.beforeEnter}),l.children?.length&&r.push(...W(l.children,e,o))}return r}function Me(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 Ne(e){return e.segments.reduce((e,t)=>"literal"===t.kind?e+2:"param"===t.kind?e+1:e,0)}function G(e,t){let n,r={},l=-1;for(let o of t){let t=Me(e,o);if(null===t)continue;let i=Ne(o);i>l&&(n=o,r=t,l=i)}return n?{route:n,params:r}:void 0}function K(e){let t=e.trim();return t&&"/"!==t?(t.startsWith("/")||(t="/"+t),t.endsWith("/")&&(t=t.slice(0,-1)),t):""}function Pe(){if(typeof document>"u")return"";let e=document.querySelector("base");if(!e)return"";let t=e.getAttribute("href")||"";try{return K(new URL(t,window.location.origin).pathname)}catch{return K(t)}}function Fe(e,t){let n=null==t?.base?Pe():K(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=W(e),a=G(o,i),u=h(o),s=h(a?.params??{}),c=h(H(window.location.search)),f=[],d=[],p=0;function m(e,t,n,r,l){let o=[...f];n&&o.push(n);let i=++p;if(0===o.length)return void r();let a=0;!function n(u){if(i!==p)return;if(!1===u)return void l?.();if("string"==typeof u)return void(u===e?r():b(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?{}:H(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}}B&&=(B(),null);let g=()=>{let e=r(),t=u.value,n=c.value,o=G(e,i),a=H(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)+U(n))})};function _(e,t,n,r,o){s.value=r?.params??{},c.value=t,u.value=e;let i=l(e)+U(t);o?history.replaceState(null,"",i):history.pushState(null,"",i);for(let t of d)try{t(e,n)}catch{}}function b(e,t){v=!0;let{pathname:n,stringQuery:r}=y(e,t),l=u.value,o=G(n,i);m(n,l,o?.route.beforeEnter,()=>_(n,r,l,o,!1))}window.addEventListener("popstate",g),B=()=>window.removeEventListener("popstate",g);let x={current:u,params:s,query:c,base:n||"/",navigate:b,replace:function(e,t){v=!0;let{pathname:n,stringQuery:r}=y(e,t),l=u.value,o=G(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=G(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 z&&console.warn("[Nix] A router already exists. The previous router is being replaced. Only one router instance should be active at a time."),z=x,queueMicrotask(()=>{v||m(o,"",G(o,i)?.route.beforeEnter,()=>{},()=>{history.replaceState(null,"",l("/"));let e=G("/",i);u.value="/",s.value=e?.params??{},c.value={}})}),x}function Ie(){return V()}var Le=class extends S{_depth;constructor(e=0){super(),this._depth=e}render(){let e=this._depth;return R`<div class="router-view">${()=>{let t=V(),n=G(t.current.value,t._flat);return n?e>=n.route.chain.length?R`<span></span>`:n.route.chain[e]():R`<div style="color:#f87171;padding:16px 0">
|
|
1
|
+
var e=[],t=[],n=null,r=null,i=null,a=[];function o(e){a.push(i),i=e}function s(){i=a.pop()??null}var c=0,l=new Set,u=[],d=100,f=0,p=[],m=0,h=class{_value;_subs=new Set;constructor(e){this._value=e}get value(){return n&&(this._subs.add(n),r?.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.has(e)||(l.add(e),u.push(e));return}let e=m,t=0;for(let n of this._subs)p[e+t++]=n;m=e+t;try{for(let n=0;n<t;n++){let t=p[e+n];p[e+n]=null,t?.()}}finally{m=e}}dispose(){this._subs.clear()}};function g(e){return new h(e)}function _(l){let o,a=!1,u=new Set,s=new Set,c=i,p=()=>{if(a)return;"function"==typeof o&&o();let i=u;u=s,s=i,s.clear();let h=e.length>0?e.pop():{effect:null,deps:null};if(h.effect=n,h.deps=r,t.push(h),n=p,r=s,++f>d){f=0;let l=t.pop();throw n=l.effect,r=l.deps,l.effect=null,l.deps=null,e.push(l),Error("[Nix] Maximum effect re-execution depth exceeded (possible infinite loop).")}try{o=l()}catch(e){if(!c)throw e;c(e)}finally{f--;let l=t.pop();n=l.effect,r=l.deps,l.effect=null,l.deps=null,e.push(l);for(let e of u)s.has(e)||e._removeSub(p)}};return p(),()=>{a=!0,"function"==typeof o&&o();for(let e of s)e._removeSub(p);s.clear(),u.clear()}}function v(e){let t=new h(void 0),n=_(()=>{t.value=e()}),r=t.dispose;return t.dispose=()=>{n(),r.call(t)},t}function y(e){c++;try{e()}finally{if(0===--c&&u.length>0){let e=u.length;for(let t=0;t<e;t++)u[t]();u.length=0,l.clear()}}}function b(e){let t=n,l=r;n=null,r=null;try{return e()}finally{n=t,r=l}}function x(e,t,n={}){let r,{immediate:l=!1,once:o=!1}=n,i=e instanceof h?()=>e.value:e,a=!0,u=!1,s=_(()=>{let e=i();if(a){if(a=!1,l&&!u){let n=e;b(()=>t(n,void 0)),o&&(u=!0,Promise.resolve().then(s))}r=e}else if(!u){let n=e,l=r;r=e,b(()=>t(n,l)),o&&(u=!0,Promise.resolve().then(s))}});return()=>{u=!0,s()}}function S(e){return e?Promise.resolve().then(e):Promise.resolve()}var C=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 w(e){return"object"==typeof e&&!!e&&!0===e.__isNixComponent}function T(e){return Symbol(e)}var E=[];function ee(){return[...E]}function D(){E.push(new Map)}function O(){E.pop()}function te(e,t){let n=E.splice(0);e.forEach(e=>E.push(e)),E.push(new Map);try{return t()}finally{E.splice(0),n.forEach(e=>E.push(e))}}function k(e,t){let n=E[E.length-1];if(!n)throw Error("[Nix] provide() must be called inside onInit() of a NixComponent.");n.set(e,t)}function A(e){for(let t=E.length-1;t>=0;t--)if(E[t].has(e))return E[t].get(e)}var j={SCOPE:"nix-scope",ERROR_BOUNDARY:"nix-eb",TRANSITION:"nix-t",KEYED_START:"nix-ks",KEYED_END:"nix-ke",KEYED_ZONE:"nix-kz"};function ne(){return{el:null}}function re(e,t){t?"none"===e.style.display&&(e.style.display=""):"none"!==e.style.display&&(e.style.display="none")}function ie(e,t,n){return{__isKeyedList:!0,items:e,keyFn:t,renderFn:n}}function ae(e,t,n){let r,l;D();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}r=e.render()._render(t,n)}finally{O()}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 oe(e,t,n){let r,l;D();try{try{e.onInit?.()}catch{}r=e.render()._render(t,n)}finally{O()}try{let t=e.onMount?.();"function"==typeof t&&(l=t)}catch{}return()=>{try{e.onUnmount?.()}catch{}try{l?.()}catch{}r()}}function M(e,t,n,r){let l,o;te(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 se(e,t,n,r,l){let o,i;D();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}o=e.render()._render(t,n)}finally{O()}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 ce(){return{__isPortalOutlet:!0,_container:null}}function le(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 ue(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,w(e)?ae(e,l,null):e._render(l,null)}}}var de=T("nix:portal-outlet");function fe(e){k(de,e)}function pe(){return A(de)}function me(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(j.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||w(t)?t:t(e);a=w(o)?oe(o,n,r):o._render(n,r)};o(e=>{u||(u=!0,c?(a?.(),a=null,d(e)):(i=e,f=!0))});try{if(w(e)){D();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}a=e.render()._render(n,r)}finally{O()}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 he(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 N(e){return Math.max(0,...e.split(",").map(e=>parseFloat(e.trim())||0))}function P(e,t=0){return new Promise(n=>{let r=getComputedStyle(e),l=1e3*Math.max(N(r.transitionDuration||"0"),N(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 ge(e,t={}){let n=he(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(j.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 w(e)?oe(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 P(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 P(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||w(e))d(e);else{let t=e,n=null;h=_(()=>{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 _e(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 ve(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 F(e){return"object"==typeof e&&!!e&&!0===e.__isNixTemplate}function ye(e){return"object"==typeof e&&!!e&&!0===e.__isKeyedList}var be={enter:"Enter",escape:"Escape",space:" ",tab:"Tab",delete:"Delete",backspace:"Backspace",up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight"},xe=new Set(["click","dblclick","mousedown","mouseup","keydown","keyup","input","change","submit"]),I=new Set;function Se(e,t,n){let r=e.target,l=e.stopPropagation,o=!1;for(e.stopPropagation=()=>{o=!0,l.call(e)};r&&r!==document;){let l=r[t];if(l){let t=r[n];if(t){if(t.includes("prevent")&&e.preventDefault(),t.includes("stop")&&e.stopPropagation(),t.includes("self")&&e.target!==r){r=r.parentNode;continue}if("key"in e){let n=e,l=!0;for(let e of t){let t=be[e];if(void 0!==t&&n.key!==t){l=!1;break}if(!t&&1===e.length&&n.key.toLowerCase()!==e){l=!1;break}}if(!l){r=r.parentNode;continue}}}if(l(e),o)break}r=r.parentNode}e.stopPropagation=l}var Ce=new Map,L=new Set,R=!1;function z(e){L.add(e),R||(R=!0,queueMicrotask(()=>{for(let e of L)e();L.clear(),R=!1}))}function we(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=Array(a+1);if(u[0]=e,a>0){let t,n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_COMMENT),r=1;for(;r<=a&&(t=n.nextNode());)u[r++]=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(!xe.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{if(!I.has(e)){let t=`__nix_${e}`,n=`__nix_${e}_mods`,r=e=>Se(e,t,n);Ce.set(e,r),document.addEventListener(e,r),I.add(e)}let r=`__nix_${e}`,o=`__nix_${e}_mods`;c[r]=t,n.length>0&&(c[o]=n),l.push(()=>{c[r]=null,c[o]=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=_(()=>{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,z(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=_(()=>{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,z(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(w(u))se(u,d.parentNode,d,o,l);else if(F(u)){let e=u._render(d.parentNode,d);l.push(e)}else if(Array.isArray(u))for(let e of u)w(e)?se(e,d.parentNode,d,o,l):F(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,m=[],g=null,b=ee(),x=!1,E="",N=!0,k=_(()=>{let e=u();if("string"==typeof e||"number"==typeof e){E=String(e);let t=()=>{x=!1,h&&=(h(),null),p?p.nodeValue=E:(p=document.createTextNode(E),d.parentNode.insertBefore(p,d))};return void(N?(N=!1,t()):x||(x=!0,z(t)))}if(x=!1,N=!1,p&&=(p.parentNode?.removeChild(p),null),h&&=(h(),null),null!=e&&!1!==e)if(F(e))h=e._render(d.parentNode,d);else if(w(e))h=M(e,d.parentNode,d,b);else if(ye(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();y(()=>{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=w(u)?M(u,r,a,b):u._render(r,a);v?.set(l,{start:i,end:a,cleanup:s})}}),t.insertBefore(r,d)}return void(m=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<m.length;e++){let t=m[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?Te(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=w(u)?M(u,a,i,b):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}}m=n}else if(Array.isArray(e)){let t=[];for(let n of e)if(w(n))t.push(ae(n,d.parentNode,d));else if(F(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(k(),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 Te(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 Ee=new WeakMap;function B(e,...t){let n=Ee.get(e);if(!n){let t=[],r="";for(let n=0;n<e.length-1;n++)r+=e[n],t.push(_e(r)),r+="__nix__";let l=document.createElement("template");l.innerHTML=ve(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},Ee.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}=we(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 De(e,t){if(w(e)){let n,r,l="string"==typeof t?document.querySelector(t):t;if(!l)throw Error(`[Nix] mount: container not found: ${t}`);D();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}n=e.render()._render(l,null)}finally{O()}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 Oe(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]=g(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 ke(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 Ae(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 je(e,t){return"*"===t?""===e?"*":e+"/*":(e+(t.startsWith("/")?t:"/"+t)).replace(/\/+/g,"/")||"/"}function Me(e,t="",n=[]){let r=[];for(let l of e){let e=je(t,l.path),o=[...n,l.component],i=Ae(e);r.push({fullPath:e,segments:i,chain:o,beforeEnter:l.beforeEnter}),l.children?.length&&r.push(...Me(l.children,e,o))}return r}function Ne(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 Pe(e){return e.segments.reduce((e,t)=>"literal"===t.kind?e+2:"param"===t.kind?e+1:e,0)}function G(e,t){let n,r={},l=-1;for(let o of t){let t=Ne(e,o);if(null===t)continue;let i=Pe(o);i>l&&(n=o,r=t,l=i)}return n?{route:n,params:r}:void 0}function K(e){let t=e.trim();return t&&"/"!==t?(t.startsWith("/")||(t="/"+t),t.endsWith("/")&&(t=t.slice(0,-1)),t):""}function Fe(){if(typeof document>"u")return"";let e=document.querySelector("base");if(!e)return"";let t=e.getAttribute("href")||"";try{return K(new URL(t,window.location.origin).pathname)}catch{return K(t)}}function Ie(e,t){let n=null==t?.base?Fe():K(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=Me(e),a=G(o,i),u=g(o),s=g(a?.params??{}),c=g(W(window.location.search)),f=[],d=[],p=0;function h(e,t,n,r,l){let o=[...f];n&&o.push(n);let i=++p;if(0===o.length)return void r();let a=0;!function n(u){if(i!==p)return;if(!1===u)return void l?.();if("string"==typeof u)return void(u===e?r():b(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 m(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 y=()=>{let e=r(),t=u.value,n=c.value,o=G(e,i),a=W(window.location.search);h(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)+ke(n))})};function _(e,t,n,r,o){s.value=r?.params??{},c.value=t,u.value=e;let i=l(e)+ke(t);o?history.replaceState(null,"",i):history.pushState(null,"",i);for(let t of d)try{t(e,n)}catch{}}function b(e,t){v=!0;let{pathname:n,stringQuery:r}=m(e,t),l=u.value,o=G(n,i);h(n,l,o?.route.beforeEnter,()=>_(n,r,l,o,!1))}window.addEventListener("popstate",y),H=()=>window.removeEventListener("popstate",y);let x={current:u,params:s,query:c,base:n||"/",navigate:b,replace:function(e,t){v=!0;let{pathname:n,stringQuery:r}=m(e,t),l=u.value,o=G(n,i);h(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=G(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=x,queueMicrotask(()=>{v||h(o,"",G(o,i)?.route.beforeEnter,()=>{},()=>{history.replaceState(null,"",l("/"));let e=G("/",i);u.value="/",s.value=e?.params??{},c.value={}})}),x}function Le(){return U()}var Re=class extends C{_depth;constructor(e=0){super(),this._depth=e}render(){let e=this._depth;return B`<div class="router-view">${()=>{let t=U(),n=G(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
|
-
</div>`}}</div>`}},
|
|
4
|
-
href=${(
|
|
5
|
-
style=${()=>
|
|
6
|
-
@click=${t=>{t.preventDefault(),
|
|
7
|
-
>${t}</a>`}};function
|
|
3
|
+
</div>`}}</div>`}},ze=class extends C{_to;_label;constructor(e,t){super(),this._to=e,this._label=t}render(){let e=this._to,t=this._label;return B`<a
|
|
4
|
+
href=${(U()._base||"")+(e.startsWith("/")?e:"/"+e)}
|
|
5
|
+
style=${()=>U().current.value===e?"color:#38bdf8;font-weight:700;text-decoration:none;cursor:pointer;padding:4px 10px;border-radius:4px;background:#0c2a3a":"color:#a3a3a3;text-decoration:none;cursor:pointer;padding:4px 10px;border-radius:4px"}
|
|
6
|
+
@click=${t=>{t.preventDefault(),U().navigate(e)}}
|
|
7
|
+
>${t}</a>`}};function Be(){return B`
|
|
8
8
|
<span style="color:#52525b;font-size:13px;display:inline-flex;align-items:center;gap:6px">
|
|
9
9
|
<span class="nix-spinner" style="
|
|
10
10
|
display:inline-block;width:14px;height:14px;border-radius:50%;
|
|
@@ -14,8 +14,8 @@ var e=[],t=[],n=null,r=null,i=null,a=[];function o(e){a.push(i),i=e}function s()
|
|
|
14
14
|
Loading…
|
|
15
15
|
</span>
|
|
16
16
|
<style>@keyframes nix-spin{to{transform:rotate(360deg)}}</style>
|
|
17
|
-
`}function
|
|
17
|
+
`}function Ve(e){return B`
|
|
18
18
|
<span style="color:#f87171;font-size:13px">
|
|
19
19
|
⚠ ${e instanceof Error?e.message:String(e)}
|
|
20
20
|
</span>
|
|
21
|
-
`}var q=new Map,
|
|
21
|
+
`}var q=new Map,He=3e5,J=null,Ue=He;function We(){null===J&&(J=setInterval(()=>{let e=Date.now();for(let[t,n]of q)n.subscribers<=0&&e-n.fetchedAt>Ue&&q.delete(t);0===q.size&&null!==J&&(clearInterval(J),J=null)},6e4))}function Y(e){return q.get(e)}function Ge(e,t){let n=q.get(e);q.set(e,{data:t,fetchedAt:Date.now(),subscribers:n?.subscribers??0}),We()}function Ke(e){let t=q.get(e);t&&t.subscribers++}function qe(e){let t=q.get(e);t&&(t.subscribers=Math.max(0,t.subscribers-1))}function X(e,t){let n=q.get(e);return!!n&&Date.now()-n.fetchedAt<t}function Je(e){void 0===e?q.clear():q.delete(e)}function Ye(e){Ue=e}function Xe(e,t,n={}){let{fallback:r,errorFallback:l,resetOnRefresh:o=!1,invalidate:i,cacheKey:a,staleTime:u=0}=n,s=r??Be(),c=l??Ve;return new class extends C{_state;_disposeWatcher;constructor(){super();let e=a?Y(a):void 0;this._state=g(e?{status:"resolved",data:e.data}:{status:"pending"})}onMount(){a&&Ke(a);let e=a?Y(a):void 0;if(e&&X(a,u)||(e?this._fetch():this._run()),i){let e=!0;this._disposeWatcher=_(()=>{i.value,e?e=!1:(a&&q.delete(a),this._run())})}return()=>{this._disposeWatcher?.(),a&&qe(a)}}_run(){(o||"pending"===this._state.peek().status)&&(this._state.value={status:"pending"}),this._fetch()}_fetch(){e().then(e=>{a&&Ge(a,e),this._state.value={status:"resolved",data:e}},e=>{this._state.value={status:"error",error:e}})}render(){return B`<div class="nix-suspense" style="display:contents">${()=>{let e=this._state.value;return"pending"===e.status?s:"error"===e.status?c(e.error):t(e.data)}}</div>`}}}var Z=new Map;function Ze(e){q.delete(e);let t=Z.get(e);if(t)for(let e of t)e()}function Qe(e,t,n,r={}){let{fallback:l,errorFallback:o,resetOnRefresh:i=!1,staleTime:a=0,refetchOnMount:u="always"}=r,s=l??Be(),c=o??Ve;return new class extends C{_state;constructor(){super();let t=Y(e);this._state=g(t?{status:"resolved",data:t.data}:{status:"pending"})}onMount(){Z.has(e)||Z.set(e,new Set);let t=Z.get(e),n=()=>this._run();t.add(n),Ke(e);let r=Y(e),l=X(e,a);return r?!1===u||"stale"===u&&l||"always"===u&&l&&a>0||this._fetch():this._run(),()=>{t.delete(n),0===t.size&&Z.delete(e),qe(e)}}_run(){(i||"pending"===this._state.peek().status)&&(this._state.value={status:"pending"}),this._fetch()}_fetch(){t().then(t=>{Ge(e,t),this._state.value={status:"resolved",data:t}},e=>{this._state.value={status:"error",error:e}})}render(){return B`<div class="nix-query" style="display:contents">${()=>{let e=this._state.value;return"pending"===e.status?s:"error"===e.status?c(e.error):n(e.data)}}</div>`}}}function $e(e,t){let n=null;return()=>n?new n:Xe(async()=>(n=(await e()).default,n),e=>new e,{fallback:t})}function et(e="Required"){return t=>null==t||""===t||Array.isArray(t)&&0===t.length?e:null}function tt(e,t){return n=>"string"==typeof n&&n.length<e?t??`Minimum ${e} characters`:null}function nt(e,t){return n=>"string"==typeof n&&n.length>e?t??`Maximum ${e} characters`:null}function Q(e,t="Invalid format"){return n=>"string"!=typeof n||e.test(n)?null:t}function rt(e="Invalid email"){return Q(/^[^\s@]+@[^\s@]+\.[^\s@]+$/,e)}function it(e,t){return n=>"number"==typeof n&&n<e?t??`Minimum value is ${e}`:null}function at(e,t){return n=>"number"==typeof n&&n>e?t??`Maximum value is ${e}`:null}function ot(e){return e}const st={required:et,minLength:tt,maxLength:nt,email:rt,pattern:Q,min:it,max:at};function ct(e,t){return{...e,...t}}function $(e,t=[],n="blur"){let r=g(e),l=g(!1),o=g(!1),i=g(null),a=g(!1),u=v(()=>{if(i.value)return i.value;if(!("input"===n?o.value||l.value:"submit"===n?a.value:l.value))return null;for(let e of t){let t=e(r.value);if(t)return t}return null});function s(t){if(!t||!("value"in t))return e;let n=t;return"boolean"==typeof e?n.checked:"number"==typeof e?Number(n.value):n.value}return{value:r,error:u,touched:l,dirty:o,onInput:e=>{r.value=s(e.target),o.value=!0,i.value=null},onBlur:()=>{l.value=!0},reset:function(){r.value=e,l.value=!1,o.value=!1,i.value=null,a.value=!1},_setExternalError:function(e){i.value=e,e&&(l.value=!0)},_forceVisible:function(){l.value=!0,a.value=!0},_dispose:function(){u.dispose()}}}function lt(e,t={},n="blur"){function r(e){let r={};for(let l in e){let o=t[l]??[];r[l]=$(e[l],o,n)}return r}let l=g(e.map(r)),o=v(()=>l.value.length);return{fields:l,append:function(e){l.value=[...l.value,r(e)]},remove:function(e){let t=l.value;if(!(e<0||e>=t.length)){for(let n in t[e])t[e][n]._dispose();l.value=t.filter((t,n)=>n!==e)}},move:function(e,t){let n=[...l.value];if(e<0||e>=n.length||t<0||t>=n.length||e===t)return;let[r]=n.splice(e,1);n.splice(t,0,r),l.value=n},replace:function(e,t){let n=[...l.value];if(!(e<0||e>=n.length)){for(let t in n[e])n[e][t]._dispose();n[e]=r(t),l.value=n}},length:o,reset:function(){for(let e of l.value)for(let t in e)e[t]._dispose();l.value=e.map(r)},_dispose:function(){for(let e of l.value)for(let t in e)e[t]._dispose();o.dispose()}}}function ut(e,t={}){let n=t.validateOn??"blur",r={};for(let l in e){let o=t.validators?.[l]??[];r[l]=$(e[l],o,n)}let l=g(!1),o=g(0),i=v(()=>{let e={};for(let t in r)e[t]=r[t].value.value;return e}),a=v(()=>{let e={};for(let t in r){let n=r[t].error.value;n&&(e[t]=n)}return e}),u=v(()=>{for(let e in r)if(r[e].error.value)return!1;return!0}),s=v(()=>{for(let e in r)if(r[e].dirty.value)return!0;return!1}),c=v(()=>{for(let e in r)if(r[e].touched.value)return!0;return!1});function f(e){for(let t in e)r[t]?._setExternalError(e[t]??null)}return{fields:r,values:i,errors:a,valid:u,dirty:s,touched:c,isSubmitting:l,submitCount:o,handleSubmit:function(e){return n=>{n.preventDefault(),o.value++;for(let e in r)r[e]._forceVisible();let a=i.value;if(t.validate){let e=t.validate(a);if(e){let t={},n=!1;for(let r in e){let l=e[r],o=Array.isArray(l)?l[0]??null:l??null;o&&(t[r]=o,n=!0)}if(n)return void f(t)}}for(let e in r)if(r[e].error.value)return;let u=e(a);u instanceof Promise&&(l.value=!0,u.finally(()=>{l.value=!1}).catch(()=>{}))}},reset:function(){for(let e in r)r[e].reset();l.value=!1,o.value=0},setErrors:f,dispose:function(){i.dispose(),a.dispose(),u.dispose(),s.dispose(),c.dispose();for(let e in r)r[e]._dispose()}}}export{ze as Link,C as NixComponent,Re as RouterView,h as Signal,y as batch,Je as clearQueryCache,v as computed,me as createErrorBoundary,ut as createForm,T as createInjectionKey,ce as createPortalOutlet,Qe as createQuery,Ie as createRouter,Oe as createStore,ot as createValidator,_ as effect,rt as email,ct as extendValidators,B as html,A as inject,pe as injectOutlet,Ze as invalidateQueries,$e as lazy,at as max,nt as maxLength,it as min,tt as minLength,De as mount,S as nextTick,Q as pattern,ue as portal,le as portalOutlet,k as provide,fe as provideOutlet,ne as ref,ie as repeat,et as required,Ye as setQueryCacheTime,re as showWhen,g as signal,Xe as suspend,ge as transition,b as untrack,$ as useField,lt as useFieldArray,Le as useRouter,st as validators,x as watch};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deijose/nix-js",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.7",
|
|
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/",
|