@estjs/template 0.0.15-beta.1 → 0.0.15-beta.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,3 @@
1
- 'use strict';var shared=require('@estjs/shared'),signals=require('@estjs/signals');/**
2
- * @estjs/template v0.0.15-beta.1
3
- * (c) 2023-Present jiangxd <jiangxd2016@gmail.com>
4
- * @license MIT
5
- **/
6
- var st=Object.defineProperty;var Ne=Object.getOwnPropertySymbols;var ct=Object.prototype.hasOwnProperty,at=Object.prototype.propertyIsEnumerable;var Se=(e,t,n)=>t in e?st(e,t,{enumerable:true,configurable:true,writable:true,value:n}):e[t]=n,H=(e,t)=>{for(var n in t||(t={}))ct.call(t,n)&&Se(e,n,t[n]);if(Ne)for(var n of Ne(t))at.call(t,n)&&Se(e,n,t[n]);return e};var K=(e,t,n)=>new Promise((r,o)=>{var i=c=>{try{a(n.next(c));}catch(u){o(u);}},s=c=>{try{a(n.throw(c));}catch(u){o(u);}},a=c=>c.done?r(c.value):Promise.resolve(c.value).then(i,s);a((n=n.apply(e,t)).next());});var F=null,Ee=[],lt=0;function Ae(e=null){let t={id:++lt,parent:e,provides:new Map,cleanup:new Set,mount:new Set,update:new Set,destroy:new Set,isMount:false,isDestroy:false,children:new Set};return e&&e.children.add(t),t}function N(){return F}function M(e){F&&Ee.push(F),F=e;}function Y(){F=Ee.pop()||null;}function Q(e){if(!e||e.isDestroy)return;Array.from(e.children).forEach(Q),ft(e);}function ft(e){if(!(!e||e.isDestroy)){e.parent&&(e.parent.children.delete(e),e.parent=null);try{e.cleanup.forEach(t=>t()),e.cleanup.clear(),e.mount.clear(),e.update.clear(),e.destroy.clear(),e.provides.clear(),e.children.clear();}catch(t){shared.error("Error during context cleanup:",t);}e.isDestroy=true;}}var v={mount:"mount",destroy:"destroy",update:"update"};function Z(e,t){let n=N();if(!n){shared.error(`Cannot register ${e} hook outside component context`);return}if(!v[e]){shared.error(`Invalid lifecycle type: ${e}`);return}if(e===v.mount&&n.isMount){try{t();}catch(r){shared.error(`Error in ${e} hook:`,r);}return}n[e].add(t);}function $(e){let t=N();if(!t){shared.error(`Cannot trigger ${e} hook outside component context`);return}let n=t[e];n!=null&&n.size&&n.forEach(r=>{try{r();}catch(o){}});}function ee(e){Z(v.mount,e);}function te(e){Z(v.destroy,e);}function dt(e){Z(v.update,e);}var Ce="http://www.w3.org/2000/svg",ne="http://www.w3.org/2000/xlink",re="http://www.w3.org/2000/xmlns/",oe=/^\d+-\d+$/;var ve=1e3,be=new WeakMap;function ke(e){let t=be.get(e);if(!t){let n=e.name||"anonymous",r=Le(e.toString()).toString(36);t=`${n}_${r}`,be.set(e,t);}return t}function Le(e){let t=0,n=e.length<100?e.length:100;for(let r=0;r<n;r++)t=Math.trunc((t<<5)-t+e.charCodeAt(r));return t<0?-t:t}var ht=0;function se(e){if(!shared.isFalsy(e)){if(shared.isString(e))return e.length<=ve?e:`${e.slice(0,ve-10)}_${Le(e).toString(36)}`;if(shared.isNumber(e))return String(e);if(shared.isSymbol(e)){let t=Symbol.keyFor(e);if(t)return `_s.${t}`;let n=e.description;return n?`_s.${n}`:`${ht++}`}return String(e)}}var ie=Symbol("essor.key");function O(e,t){if(m(e)||!e||e.nodeType===Node.DOCUMENT_NODE)return;let n=se(t);shared.isFalsy(n)?delete e[ie]:e[ie]=n;}function k(e){if(e)return m(e)?e.key:e[ie]}function b(e){if(e)try{if(m(e))e.destroy();else {let t=e;t.parentElement&&t.remove();}}catch(t){shared.error("Failed to remove node:",t);}}function p(e,t,n=null){if(!(!e||!t))try{let r=m(n)?n.firstChild:n;if(m(t)){t.mount(e,r);return}r?e.insertBefore(t,r):e.appendChild(t);}catch(r){shared.error("Failed to insert node:",r);}}function z(e,t,n){if(!(!e||!t||!n||t===n))try{p(e,t,n),b(n);}catch(r){shared.error("Failed to replace node:",r);}}function R(e){return e?m(e)?e.firstChild:e:null}function L(e,t){let n=k(e),r=k(t);if(n!==r)return false;let o=m(e),i=m(t);if(o&&i)return e.component===t.component;if(o!==i)return false;let s=e,a=t;return s.nodeType!==a.nodeType?false:s.nodeType===Node.ELEMENT_NODE?s.tagName===a.tagName:true}function T(e){if(shared.isHTMLElement(e))return e;if(shared.isPrimitive(e)){let t=shared.isFalsy(e)?"":String(e);return document.createTextNode(t)}return e}function _e(e){return e instanceof HTMLInputElement}function Pe(e){return e instanceof HTMLSelectElement}function Re(e){return e instanceof HTMLTextAreaElement}function ae(e){return e instanceof Text}function we(e,t){if(e===t)return true;if(!e||!t||Array.isArray(e)!==Array.isArray(t))return false;for(let n in e)if(e[n]!==t[n])return false;for(let n in t)if(!(n in e))return false;return true}function Ie(e,t){if(m(e)||m(t))return;let n=k(e);n&&!k(t)&&O(t,n);}function _(e,t,n){if(n===t)return t;let r=shared.isHTMLElement(t);if(shared.isHTMLElement(n)&&r){if(n.isEqualNode(t))return t;if(t.tagName===n.tagName){let a=t.attributes,c=n.attributes;for(let u=a.length-1;u>=0;u--){let f=a[u].name;n.hasAttribute(f)||t.removeAttribute(f);}for(let u=0,f=c.length;u<f;u++){let l=c[u];t.getAttribute(l.name)!==l.value&&t.setAttribute(l.name,l.value);}return Ie(t,n),t}}if(ae(t)&&ae(n))return t.textContent!==n.textContent&&(t.textContent=n.textContent),Ie(t,n),t;let i=m(t),s=m(n);return i&&s&&t.component===n.component?n.update(t):(z(e,n,t),n)}function He(e,t,n,r){let o=t.length,i=n.length;if(o===0&&i===0)return [];if(o===0){let s=document.createDocumentFragment();for(let a=0;a<i;a++)p(s,n[a]);return p(e,s,r),n}if(i===0){for(let s=0;s<o;s++)b(t[s]);return []}if(o===1&&i===1){let s=t[0],a=n[0];return L(s,a)?(_(e,s,a),n[0]=s):z(e,a,s),n}if(o===2&&i===2){let s=t[0],a=t[1],c=n[0],u=n[1];if(L(s,c)&&L(a,u))return _(e,s,c),_(e,a,u),n[0]=s,n[1]=a,n;if(L(s,u)&&L(a,c)){_(e,s,u),_(e,a,c);let f=R(a),l=R(s);return f&&l&&f.parentNode===e&&e.insertBefore(f,l),n[0]=a,n[1]=s,n}}return St(e,t,n,r)}function St(e,t,n,r){let o=0,i=0,s=t.length-1,a=n.length-1,c=t[0],u=t[s],f=n[0],l=n[a];for(;o<=s&&i<=a;)if(!c)c=t[++o];else if(!u)u=t[--s];else if(L(c,f))_(e,c,f),n[i]=c,c=t[++o],f=n[++i];else break;for(;o<=s&&i<=a;)if(!c)c=t[++o];else if(!u)u=t[--s];else if(L(u,l))_(e,u,l),n[a]=u,u=t[--s],l=n[--a];else break;if(o>s){if(i<=a){let h=a+1<n.length?R(n[a+1]):r;for(let y=i;y<=a;y++)p(e,n[y],h);}}else if(i>a)for(let h=o;h<=s;h++){let y=t[h];y&&b(y);}else Et(e,t,n,o,s,i,a,r);return n}function Et(e,t,n,r,o,i,s,a){let c=s-i+1,u=n.length,f;for(let g=i;g<=s;g++){let x=k(n[g]);x!==void 0&&(f||(f=Object.create(null)),f[x]=g);}let l=new Int32Array(c),h=false,y=0,A=0;for(let g=r;g<=o;g++){let x=t[g];if(!x)continue;if(A>=c){b(x);continue}let S,P=k(x);if(P!==void 0&&f&&P in f)S=f[P];else for(let C=i;C<=s;C++)if(l[C-i]===0&&P===void 0&&k(n[C])===void 0&&L(x,n[C])){S=C;break}S===void 0?b(x):(l[S-i]=g+1,S>=y?y=S:h=true,_(e,x,n[S]),n[S]=x,A++);}let I=h?At(l):[],J=I.length-1;for(let g=c-1;g>=0;g--){let x=i+g,S=n[x],P=x+1<u?R(n[x+1]):a;if(l[g]===0)p(e,S,P);else if(h)if(J<0||g!==I[J]){let C=R(S);C&&C.parentNode===e&&p(e,C,P);}else J--;}}function At(e){let t=e.length;if(t===0)return [];if(t===1)return e[0]!==0?[0]:[];let n=[],r=new Int32Array(t),o,i,s,a,c;for(o=0;o<t;o++){let u=e[o];if(u!==0){if(i=n[n.length-1],n.length===0||e[i]<u){r[o]=i,n.push(o);continue}for(s=0,a=n.length-1;s<a;)c=s+a>>1,e[n[c]]<u?s=c+1:a=c;u<e[n[s]]&&(s>0&&(r[o]=n[s-1]),n[s]=o);}}for(s=n.length,a=n[s-1];s-- >0;)n[s]=a,a=r[a];return n}function E(e,t,n,r){e.addEventListener(t,n,r);let o=N();o&&o.cleanup.add(()=>{e.removeEventListener(t,n,r);});}function Tt(e,t,n,r){if(_e(e))switch(e.type){case "checkbox":E(e,"change",()=>{r(!!e.checked);});break;case "radio":E(e,"change",()=>{r(e.checked?e.value:"");});break;case "file":E(e,"change",()=>{r(e.files);});break;case "number":case "range":E(e,"input",()=>{r(e.value||"");});break;case "date":case "datetime-local":case "month":case "time":case "week":E(e,"change",()=>{r(e.value||"");});break;default:E(e,"input",()=>{r(e.value);});break}else Pe(e)?E(e,"change",()=>{if(e.multiple){let o=Array.from(e.options).filter(i=>i.selected).map(i=>i.value);r(o);}else r(e.value);}):Re(e)&&E(e,"input",()=>{r(e.value);});}function kt(e,t,n,r){if(!e)return;let o=N();if(!o)return;let i=[],s=signals.effect(()=>{let a=shared.isFunction(t)?t():t,c=shared.coerceArray(a).map(T);i=He(e,i,c,n);});o.cleanup.add(()=>{s(),r!=null&&r.preserveOnCleanup||i.forEach(a=>b(a)),i.length=0;});}function ue(e,t){let n=t.length,r=new Array(n),o=new Set(t),i=1,s=0,a=c=>{if(c.nodeType!==Node.DOCUMENT_FRAGMENT_NODE){if(o.has(i)&&(r[s++]=c,s===n))return true;i++;}let u=c.firstChild;for(;u;){if(a(u))return true;u=u.nextSibling;}return false};return a(e),r}var $e;$e="normal";var W=class{constructor(t,n){this.component=t;this.props=n;this.renderedNode=null;this.componentContext=null;this.parentNode=null;this.beforeNode=null;this.reactiveProps={};this._propSnapshots={};this.state=0;this.context=null;this.parentContext=null;this[$e]=true;if(this.key=n!=null&&n.key?se(n.key):ke(t),this.reactiveProps=signals.shallowReactive(H({},this.props||{})),this.parentContext=N(),this.props)for(let r in this.props){let o=this.props[r];shared.isObject(o)&&o!==null&&(this._propSnapshots[r]=Array.isArray(o)?[...o]:H({},o));}}get isConnected(){return this.state===2}get firstChild(){var t;return (t=this.renderedNode)!=null?t:null}mount(t,n){if(this.parentNode=t,this.beforeNode=n||null,this.state=1,this.renderedNode)return p(t,this.renderedNode,n),this.renderedNode;this.componentContext=Ae(this.parentContext),M(this.componentContext);let r=this.component(this.reactiveProps);return shared.isFunction(r)&&(r=r(this.reactiveProps)),(signals.isSignal(r)||signals.isComputed(r))&&(r=r.value),this.renderedNode=r,p(t,this.renderedNode,n),this.applyProps(this.props||{}),this.state=2,this.componentContext&&(this.componentContext.isMount=true),$(v.mount),this.renderedNode}update(t){if(this.key!==t.key)return this.mount(t.parentNode,t.beforeNode),this;if(this.parentNode=t.parentNode,this.beforeNode=t.beforeNode,this.componentContext=t.componentContext,this.renderedNode=t.renderedNode,this.state=t.state,this.reactiveProps=t.reactiveProps,this._propSnapshots=t._propSnapshots,this.props)for(let n in this.props){if(n==="key")continue;let r=this.props[n],o=this.reactiveProps[n];if(shared.isObject(r)&&r!==null){let i=this._propSnapshots[n];if(!i||!we(r,i)){let s=Array.isArray(r)?r.slice():Object.assign({},r);this.reactiveProps[n]=s,this._propSnapshots[n]=s;}}else shared.hasChanged(r,o)&&(this.reactiveProps[n]=r,this._propSnapshots[n]&&delete this._propSnapshots[n]);}return !this.isConnected&&this.parentNode&&this.mount(this.parentNode,this.beforeNode),this.componentContext&&(M(this.componentContext),this.applyProps(this.props||{}),$(v.update),Y()),this}forceUpdate(){return K(this,null,function*(){if(this.state===5||!this.parentNode||!this.componentContext)return;let t=this.renderedNode,n;try{this.componentContext&&M(this.componentContext),n=this.component(this.reactiveProps),shared.isFunction(n)&&(n=n(this.reactiveProps)),(signals.isSignal(n)||signals.isComputed(n))&&(n=n.value),t&&n&&t!==n&&this.parentNode&&(z(this.parentNode,n,t),this.renderedNode=n),yield $(v.update);}catch(r){throw shared.error("Force update failed:",r),r}finally{this.componentContext&&Y();}})}destroy(){if(this.state===4||this.state===5)return;this.state=4;let t=this.componentContext;t&&(M(t),$(v.destroy),Q(t),this.componentContext=null,Y());let n=this.renderedNode;n&&b(n),this.renderedNode=null,this.parentNode=null,this.beforeNode=null,this.reactiveProps={},this.props=void 0,this.state=5;}applyProps(t){if(t){for(let[n,r]of Object.entries(t))if(shared.startsWith(n,"on")&&this.renderedNode){let o=n.slice(2).toLowerCase();shared.isHTMLElement(this.renderedNode)&&E(this.renderedNode,o,r);}else n==="ref"&&signals.isSignal(r)&&(r.value=this.renderedNode);this.props=t;}}};function m(e){return !!e&&!!e.normal}function j(e,t){return m(e)?e:new W(e,t)}function fe(e){let t,n=()=>{let r=document.createElement("template");r.innerHTML=e;let o=r.content.firstChild;if(!o)throw new Error("Invalid template: empty content");return o};return ()=>(t||(t=n())).cloneNode(true)}function It(e,t){let n=shared.isString(t)?document.querySelector(t):t;if(!n){shared.error(`Target element not found: ${t}`);return}n.innerHTML&&(shared.error(`Target element is not empty, it will be delete: ${t}`),n.innerHTML="");let o=j(e);return o.mount(n),o}function de(e,t){let n=N();if(!n){shared.error("provide must be called within a template");return}n.provides.set(e,t);}function me(e,t){let n=N();if(!n)return shared.error("inject must be called within a template"),t;let r=n;for(;r;){let o=r.provides.get(e);if(!shared.isNil(o))return o;r=r.parent;}return t}function Ft(e){let t=e.target,n=`${e.type}`,r=e.target,o=e.currentTarget,i=c=>Object.defineProperty(e,"target",{configurable:true,value:c}),s=()=>{let c=t[`_$${n}`];if(c&&shared.isFunction(c)&&!t.disabled){let u=t[`${n}Data`];if(u?c.call(t,u,e):c.call(t,e),e.cancelBubble)return false}return t.host&&!shared.isString(t.host)&&!t.host._$host&&shared.isFunction(t.contains)&&t.contains(e.target)&&i(t.host),true},a=()=>{for(;s()&&(t=t._$host||t.parentNode||t.host););};if(Object.defineProperty(e,"currentTarget",{configurable:true,get(){return t||document}}),e.composedPath){let c=e.composedPath();i(c[0]);for(let u=0;u<c.length-2&&(t=c[u],!!s());u++){if(t._$host){t=t._$host,a();break}if(t.parentNode===o)break}}else a();i(r);}var Ue=Symbol("_$EVENTS");function Mt(e,t=window.document){let n=t,r=n[Ue]||(n[Ue]=new Set);for(let o of e)r.has(o)||(r.add(o),t.addEventListener(o,Ft));}function zt(e,t,n,r=false){if(t===n)return;let o=q(n),i=q(t);o&&i===o||(o?r?e.setAttribute("class",o):e.className=o:e.removeAttribute("class"));}function q(e){if(e==null)return "";if(typeof e=="string")return e.trim();if(shared.isArray(e))return e.map(q).filter(Boolean).join(" ");if(shared.isObject(e)){let t=[];for(let n in e)e[n]&&t.push(n);return t.join(" ")}return String(e).trim()}var Ye=/\s*!important$/,Yt=["Webkit","Moz","ms"],pe={};function Xt(e,t,n){let r=e.style,o=shared.isString(n);if(n&&o){t!==n&&(r.cssText=n);return}if(!n){t&&e.removeAttribute("style");return}if(t&&!shared.isString(t))for(let i in t)(!n||n[i]==null)&&U(r,i,"");else if(t&&shared.isString(t)){let i=t.split(";");for(let s of i){let a=s.indexOf(":");if(a>0){let c=s.slice(0,a).trim();n&&shared.isObject(n)&&n[c]==null&&U(r,c,"");}}}if(n&&!shared.isString(n))for(let i in n){let s=n[i];(!t||shared.isString(t)||t[i]!==s)&&s!=null&&U(r,i,s);}}function U(e,t,n){if(shared.isArray(n)){for(let o of n)U(e,t,o);return}if((n==null||n==="")&&(n=""),t.startsWith("--")){e.setProperty(t,n);return}let r=Wt(e,t);typeof n=="string"&&Ye.test(n)?e.setProperty(shared.camelCase(r),n.replace(Ye,""),"important"):e[r]=n;}function Wt(e,t){let n=pe[t];if(n)return n;let r=shared.camelCase(t);if(r!=="filter"&&r in e)return pe[t]=r;r=shared.capitalize(r);for(let o of Yt){let i=o+r;if(i in e)return pe[t]=i}return t}function Zt(e,t,n,r){if(t==="ref"){n.value=e;return}if(t==="key"){r==null?O(e,void 0):O(e,String(r));return}let o=(e==null?void 0:e.namespaceURI)===Ce,i=o&&t.startsWith("xlink:"),s=o&&t.startsWith("xmlns:"),a=shared.isSpecialBooleanAttr(t)||shared.isBooleanAttr(t);if(n===r)return;let c=t.toLowerCase();if(/^on[a-z]+/.test(c)||c==="innerhtml")return;if(r==null){if(i)e.removeAttributeNS(ne,t.slice(6));else if(s){let l=t.slice(6);e.removeAttributeNS(re,l);}else e.removeAttribute(t);return}if(i){e.setAttributeNS(ne,t,String(r));return}if(s){e.setAttributeNS(re,t,String(r));return}if(a){shared.includeBooleanAttr(r)?e.setAttribute(t,""):e.removeAttribute(t);return}let u=shared.isSymbol(r)?String(r):r;if((c==="href"||c==="src"||c==="xlink:href")&&typeof u=="string"){let l=u.trim().toLowerCase();if(l.startsWith("javascript:")||l.startsWith("data:"))return}if(o)e.setAttribute(t,String(u));else if(t in e)try{e[t]=u;}catch(l){e.setAttribute(t,String(u));}else e.setAttribute(t,String(u));}function en(e,t,n,r){if(!(r!=null&&r.delegate))return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r);let o=r.delegate,i=a=>{let c=a.target;(c.matches(o)||c.closest(o))&&n.call(e,a);},s=H({},r);return s.delegate=void 0,e.addEventListener(t,i,s),()=>{e.removeEventListener(t,i,s);}}function tn(e){if(typeof document=="undefined"){let r=e.children;return r?(Array.isArray(r)?r:[r]).map(i=>String(i||"")).join(""):""}let t=document.createDocumentFragment(),n=e.children;return n&&(Array.isArray(n)?n:[n]).forEach(o=>{if(o!=null){let i=T(o);i&&p(t,i);}}),t}tn.fragment=true;function Zr(e){return !!e&&!!e.fragment}function rn(e){if(typeof document=="undefined"){let n=e.children;return n?(shared.isArray(n)?n:[n]).map(o=>String(o||"")).join(""):""}let t=document.createComment("portal");return t.portal=true,ee(()=>{let n=shared.isString(e.target)?document.querySelector(e.target):e.target;if(!n)return;let r=e.children;r&&(shared.isArray(r)?r:[r]).forEach(i=>{if(i!=null){let s=T(i);s&&p(n,s);}});}),t}rn.portal=true;function so(e){return !!e&&!!e.portal}var he=Symbol("SuspenseContext");function cn(e){if(shared.isUndefined(document)){let l=e.fallback;return l?String(l||""):""}let t=document.createElement("div");t.style.display="contents";let n=true,r=0,o=false,i=null,s=()=>{if(!o){for(o=true;t.firstChild;)t.removeChild(t.firstChild);if(e.fallback!=null){let l=T(e.fallback);l&&p(t,l);}}},a=()=>{if(!(!o||!(i||e.children!=null&&!shared.isPromise(e.children)))){for(o=false;t.firstChild;)t.removeChild(t.firstChild);i?c(i):e.children!=null&&!shared.isPromise(e.children)&&c(e.children);}},c=l=>{for(;t.firstChild;)t.removeChild(t.firstChild);if(l==null)return;let h=N();if((shared.isArray(l)?l:[l]).forEach(A=>{if(A!=null){m(A)&&(A.parentContext=h);let I=T(A);I&&p(t,I);}}),o){for(;t.firstChild;)t.removeChild(t.firstChild);if(e.fallback!=null){let A=T(e.fallback);A&&p(t,A);}}},u={register:l=>{r++,s(),l.then(()=>{n&&(r--,r===0&&a());}).catch(h=>{n&&(r--,r===0&&a());});},increment:()=>{r++,s();},decrement:()=>{r--,r===0&&a();}};de(he,u);let f=e.children;return shared.isPromise(f)?(f.then(l=>{i=l;}).catch(()=>{}),u.register(f)):f!=null?c(f):s(),te(()=>{for(n=false;t.firstChild;)t.removeChild(t.firstChild);}),t}cn.suspense=true;function go(e){return !!e&&!!e.suspense}function Co(e,t){let n=signals.signal(t==null?void 0:t.initialValue),r=signals.signal(true),o=signals.signal(null),i=signals.signal("pending"),s=0,a=null,c=()=>K(null,null,function*(){let l=++s;r.value=true,i.value="pending",o.value=null;let h=e();a=h.then(()=>{});try{let y=yield h;l===s&&(n.value=y,i.value="ready",r.value=!1);}catch(y){l===s&&(o.value=y instanceof Error?y:new Error(String(y)),i.value="errored",r.value=false);}});c();let u=(()=>{if(r.value&&a){let l=me(he,null);l&&l.register(a);}return n.value});return u.loading=r,u.error=o,u.state=i,[u,{mutate:l=>{n.value=l,i.value="ready",r.value=false,o.value=null;},refetch:()=>K(null,null,function*(){yield c();})}]}var qe=0;function ge(){return `${qe++}`}function V(){qe=0;}function xe(){}function w(e,t=false){return shared.isNil(e)?"":shared.isString(e)?e:shared.isArray(e)?e.map(n=>w(n,t)).join(""):shared.isFunction(e)?w(e(),t):String(e)}function Je(e,t){let n=/^<([a-z]+)(\s*)([^>]*)>/i,r=/data-idx="(\d+)"/g,o=/<!--(.*?)-->/g;return e.replace(n,`<$1$2$3 data-hk="${t}">`).replaceAll(r,`data-idx="${t}-$1"`).replaceAll(o,`<!--${t}-$1-->`)}function dn(e,t){if(!shared.isFunction(e))return shared.error("Component must be a function"),"";V();let n=e(t);return w(n)}function mn(e,t,...n){let r="",o=0;for(let s of e)if(r+=s,o<n.length){let a=n[o++];a&&(r+=w(a));}return Je(r,t)}function pn(e,t={}){if(!shared.isFunction(e))return shared.error("create ssg component: Component is not a function"),"";let n=e(t);return w(n)}function nt(e){if(shared.isArray(e)){let t={};for(let n of e){let r=shared.isString(n)?An(n):nt(n);if(r)for(let o in r)t[o]=r[o];}return t}if(shared.isString(e)||shared.isObject(e))return e}var Nn=/;(?![^(]*\))/g,Sn=/:([\s\S]+)/,En=/\/\*[\s\S]*?\*\//g;function An(e){let t={};return e.replaceAll(En,"").split(Nn).forEach(n=>{if(n){let r=n.split(Sn);r.length>1&&(t[r[0].trim()]=r[1].trim());}}),t}function Cn(e){if(!e)return "";if(shared.isString(e))return e;let t="";for(let n in e){let r=e[n];if(shared.isString(r)||shared.isNumber(r)){let o=n.startsWith("--")?n:shared.kebabCase(n);t+=`${o}:${r};`;}}return t}function rt(e){let t="";if(shared.isString(e))t=e;else if(shared.isArray(e))for(let n of e){let r=rt(n);r&&(t+=`${r} `);}else if(shared.isObject(e))for(let n in e)e[n]&&(t+=`${n} `);return t.trim()}function ot(e,t,n){if(signals.isSignal(t)||signals.isComputed(t))return ot(e,t.value);if(!t&&t!==0)return "";if(e==="style"){let r=nt(t);return r?shared.isString(r)?` style="${r}"`:` style="${Cn(r)}"`:""}if(e==="class"){let r=rt(t);return r?` class="${r}"`:""}return e.startsWith("on")?"":t===true?` ${e}`:` ${e}="${t}"`}function bn(e){return ()=>{let t=ge();return document.querySelector(`[data-hk="${t}"]`)||fe(e)()}}function Tn(e,t){let n=e.dataset.hk;if(!n)return ue(e,t);let r=[],o=e.querySelectorAll(`[data-idx^="${n}"]`);o.length>0&&r.push(...Array.from(o).filter(c=>{let u=c.dataset.idx;return u!==null&&oe.test(u)}).map(c=>{let u=c.dataset.idx||"",[f,l]=u.split("-");return {hk:f,idx:l,node:c}}));let i=[],s=c=>{if(c.nodeType===Node.COMMENT_NODE&&c.textContent&&oe.test(c.textContent)){let[f,l]=c.textContent.split("-");i.push({hk:f,idx:l,node:c});}let u=c.firstChild;for(;u;)s(u),u=u.nextSibling;};s(e),r.push(...i);let a=[e];return t.forEach(c=>{let u=r.find(f=>f.idx===String(c));u&&a.push(u.node);}),a}function kn(e,t,n={}){V();try{let r=shared.isString(t)?document.querySelector(t):t;if(!r){shared.error("Hydration error: Root element not found");return}let o=j(e,n);return o.mount(r),xe(),o}catch(r){shared.error("Hydration error:",r);return}}
7
- Object.defineProperty(exports,"escapeHTML",{enumerable:true,get:function(){return shared.escapeHTML}});exports.Component=W;exports.Fragment=tn;exports.Portal=rn;exports.Suspense=cn;exports.SuspenseContext=he;exports.addEvent=en;exports.addEventListener=E;exports.bindElement=Tt;exports.createApp=It;exports.createComponent=j;exports.createResource=Co;exports.createSSGComponent=pn;exports.delegateEvents=Mt;exports.getHydrationKey=ge;exports.getRenderedElement=bn;exports.hydrate=kn;exports.inject=me;exports.insert=kt;exports.isComponent=m;exports.isFragment=Zr;exports.isPortal=so;exports.isSuspense=go;exports.mapNodes=ue;exports.mapSSRNodes=Tn;exports.normalizeClass=q;exports.onDestroy=te;exports.onMount=ee;exports.onUpdate=dt;exports.patchAttr=Zt;exports.patchClass=zt;exports.patchStyle=Xt;exports.provide=de;exports.render=mn;exports.renderToString=dn;exports.setSSGAttr=ot;exports.setStyle=U;exports.template=fe;//# sourceMappingURL=template.cjs.js.map
1
+ 'use strict';var shared=require('@estjs/shared'),signals=require('@estjs/signals');var Et=Object.defineProperty;var De=Object.getOwnPropertySymbols;var xt=Object.prototype.hasOwnProperty,_t=Object.prototype.propertyIsEnumerable;var we=(e,t,o)=>t in e?Et(e,t,{enumerable:true,configurable:true,writable:true,value:o}):e[t]=o,K=(e,t)=>{for(var o in t||(t={}))xt.call(t,o)&&we(e,o,t[o]);if(De)for(var o of De(t))_t.call(t,o)&&we(e,o,t[o]);return e};var Z=(e,t,o)=>new Promise((n,r)=>{var s=a=>{try{c(o.next(a));}catch(u){r(u);}},i=a=>{try{c(o.throw(a));}catch(u){r(u);}},c=a=>a.done?n(a.value):Promise.resolve(a.value).then(s,i);c((o=o.apply(e,t)).next());});var M=null,vt=0;function N(){return M}function Le(e){M=e;}function ee(e=M){let t={id:++vt,parent:e,children:null,provides:null,cleanup:null,onMount:null,onUpdate:null,onDestroy:null,isMounted:false,isDestroyed:false};return e&&(e.children||(e.children=new Set),e.children.add(t)),t}function D(e,t){let o=M;M=e;try{return t()}finally{M=o;}}function j(e){var t,o,n,r,s;if(!(!e||e.isDestroyed)){if(e.children)for(;e.children.size>0;){let i=e.children.values().next().value;i&&j(i);}if(e.onDestroy){for(let i of e.onDestroy)try{i();}catch(c){}e.onDestroy.clear();}if(e.cleanup){for(let i of e.cleanup)try{i();}catch(c){}e.cleanup.clear();}(t=e.parent)!=null&&t.children&&e.parent.children.delete(e),(o=e.children)==null||o.clear(),(n=e.provides)==null||n.clear(),(r=e.onMount)==null||r.clear(),(s=e.onUpdate)==null||s.clear(),Le(e.parent),e.parent=null,e.isDestroyed=true;}}function I(e){let t=M;t&&(t.cleanup||(t.cleanup=new Set),t.cleanup.add(e));}var Me="_$spread$";var Re="http://www.w3.org/2000/svg",te="http://www.w3.org/2000/xlink",oe="http://www.w3.org/2000/xmlns/";var ne=Symbol(""),re=Symbol(""),z=Symbol(""),ie=Symbol("");var He=1e3,Ke=new WeakMap;function Fe(e){let t=Ke.get(e);if(!t){let o=e.name||"anonymous",n=Oe(e.toString()).toString(36);t=`${o}_${n}`,Ke.set(e,t);}return t}function Oe(e){let t=0,o=e.length<100?e.length:100;for(let n=0;n<o;n++)t=Math.trunc((t<<5)-t+e.charCodeAt(n));return t<0?-t:t}var Ct=0;function ce(e){if(!shared.isFalsy(e)){if(shared.isString(e))return e.length<=He?e:`${e.slice(0,He-10)}_${Oe(e).toString(36)}`;if(shared.isNumber(e))return String(e);if(shared.isSymbol(e)){let t=Symbol.keyFor(e);if(t)return `_s.${t}`;let o=e.description;return o?`_s.${o}`:`${Ct++}`}return String(e)}}var se=Symbol("essor.key");function V(e,t){if(p(e)||!e||e.nodeType===Node.DOCUMENT_NODE)return;let o=ce(t);shared.isFalsy(o)?delete e[se]:e[se]=o;}function k(e){if(e)return p(e)?e.key:e[se]}function T(e){if(shared.isHTMLElement(e))return e;if(shared.isPrimitive(e)){let t=shared.isFalsy(e)?"":String(e);return document.createTextNode(t)}return e}function P(e,t){let o=k(e),n=k(t);if(o!==n)return false;let r=p(e),s=p(t);if(r&&s)return e.component===t.component;if(r!==s)return false;if(shared.isPrimitive(e)||shared.isPrimitive(t))return e===t;let i=e,c=t;return i.nodeType!==c.nodeType?false:i.nodeType===Node.ELEMENT_NODE?i.tagName===c.tagName:true}function ue(e,t){if(e===t)return true;if(shared.isNull(e)||shared.isNull(t)||!shared.isObject(e)||!shared.isObject(t)||shared.isArray(e)!==shared.isArray(t))return false;let o=e,n=t;for(let r in o)if(o[r]!==n[r])return false;for(let r in n)if(!(r in o))return false;return true}function x(e){if(e)try{if(p(e))e.destroy();else {let t=e;t.parentElement&&t.remove();}}catch(t){shared.error("Failed to remove node:",t);}}function y(e,t,o){if(!(!e||!t))try{let n=p(o)?o.firstChild:o;if(p(t)){t.mount(e,n);return}n?e.insertBefore(t,n):e.appendChild(t);}catch(n){shared.error("Failed to insert node:",n);}}function Y(e,t,o){if(!(!e||!t||!o||t===o))try{let n=p(o)?o.beforeNode:o.nextSibling;x(o),y(e,t,n);}catch(n){shared.error("Failed to replace node:",n);}}function _(e){if(e){if(p(e))return e.firstChild;if(!shared.isPrimitive(e))return e}}function Ye(e,t){if(p(e)||p(t))return;let o=k(e);o&&!k(t)&&V(t,o);}function w(e,t,o){if(o===t)return t;let n=shared.isHTMLElement(t);if(shared.isHTMLElement(o)&&n){if(o.isEqualNode(t))return t;if(t.tagName===o.tagName){let c=t.attributes,a=o.attributes;for(let u=c.length-1;u>=0;u--){let l=c[u].name;o.hasAttribute(l)||t.removeAttribute(l);}for(let u=0,l=a.length;u<l;u++){let f=a[u];t.getAttribute(f.name)!==f.value&&t.setAttribute(f.name,f.value);}return Ye(t,o),t}}if(shared.isTextNode(t)&&shared.isTextNode(o))return t.textContent!==o.textContent&&(t.textContent=o.textContent),Ye(t,o),t;let s=p(t),i=p(o);return s&&i&&t.component===o.component?o.update(t):(Y(e,o,t),o)}function Ge(e,t,o,n){let r=t.length,s=o.length;if(r===0&&s===0)return [];if(r===0){for(let i=0;i<s;i++)y(e,o[i],n);return o}if(s===0){for(let i=0;i<r;i++)x(t[i]);return []}if(r===1&&s===1){let i=t[0],c=o[0];return P(i,c)?(w(e,i,c),o[0]=i):Y(e,c,i),o}if(r===2&&s===2){let i=t[0],c=t[1],a=o[0],u=o[1];if(P(i,a)&&P(c,u))return w(e,i,a),w(e,c,u),o[0]=i,o[1]=c,o;if(P(i,u)&&P(c,a)){w(e,i,u),w(e,c,a);let l=_(c),f=_(i);return l&&f&&l.parentNode===e&&e.insertBefore(l,f),o[0]=c,o[1]=i,o}}return wt(e,t,o,n)}function wt(e,t,o,n){let r=0,s=0,i=t.length-1,c=o.length-1,a=t[0],u=t[i],l=o[0],f=o[c];for(;r<=i&&s<=c;)if(!a)a=t[++r];else if(!u)u=t[--i];else if(P(a,l))w(e,a,l),o[s]=a,a=t[++r],l=o[++s];else break;for(;r<=i&&s<=c;)if(!a)a=t[++r];else if(!u)u=t[--i];else if(P(u,f))w(e,u,f),o[c]=u,u=t[--i],f=o[--c];else break;if(r>i){if(s<=c){let m=c+1<o.length?_(o[c+1]):n;for(let S=s;S<=c;S++)y(e,o[S],m);}}else if(s>c)for(let m=r;m<=i;m++){let S=t[m];S&&x(S);}else Lt(e,t,o,r,i,s,c,n);return o}function Lt(e,t,o,n,r,s,i,c){let a=i-s+1,u;for(let h=s;h<=i;h++){let E=k(o[h]);E!==void 0&&(u||(u=Object.create(null)),u[E]=h);}let l=new Int32Array(a),f=false,m=0,S=0;for(let h=n;h<=r;h++){let E=t[h];if(!E)continue;if(S>=a){x(E);continue}let g,C=k(E);if(C!==void 0&&u&&C in u)g=u[C];else for(let H=s;H<=i;H++)if(l[H-s]===0&&C===void 0&&k(o[H])===void 0&&P(E,o[H])){g=H;break}g===void 0?x(E):(l[g-s]=h+1,g>=m?m=g:f=true,w(e,E,o[g]),o[g]=E,S++);}let A=f?Mt(l):[],R=A.length-1,b=c;for(let h=a-1;h>=0;h--){let E=s+h,g=o[E];if(l[h]===0)y(e,g,b),b=_(g)||b;else if(f)if(R<0||h!==A[R]){let C=_(g);C&&C.parentNode===e&&y(e,C,b),b=C||b;}else b=_(g)||b,R--;else b=_(g)||b;}}function Mt(e){let t=e.length;if(t===0)return [];if(t===1)return e[0]!==0?[0]:[];let o=[],n=new Int32Array(t),r,s,i,c,a;for(r=0;r<t;r++){let u=e[r];if(u!==0){if(s=o[o.length-1],o.length===0||e[s]<u){n[r]=s,o.push(r);continue}for(i=0,c=o.length-1;i<c;)a=i+c>>1,e[o[a]]<u?i=a+1:c=a;u<e[o[i]]&&(i>0&&(n[r]=o[i-1]),o[i]=r);}}for(i=o.length,c=o[i-1];i-- >0;)o[i]=c,c=n[c];return o}function v(e,t,o,n){e.addEventListener(t,o,n),I(()=>{e.removeEventListener(t,o,n);});}function Ot(e,t,o,n){shared.isHtmlInputElement(e)?Vt(e,n):shared.isHtmlSelectElement(e)?$t(e,n):shared.isHtmlTextAreaElement(e)&&v(e,"input",()=>{n(e.value);});}function Vt(e,t){switch(e.type){case "checkbox":v(e,"change",()=>{t(!!e.checked);});break;case "radio":v(e,"change",()=>{t(e.checked?e.value:"");});break;case "file":v(e,"change",()=>{t(e.files);});break;case "number":case "range":v(e,"input",()=>{t(e.value||"");});break;case "date":case "datetime-local":case "month":case "time":case "week":v(e,"change",()=>{t(e.value||"");});break;default:v(e,"input",()=>{t(e.value);});break}}function $t(e,t){v(e,"change",()=>{if(e.multiple){let o=Array.from(e.options).filter(n=>n.selected).map(n=>n.value);t(o);}else t(e.value);});}function le(e,t,o){if(!e)return;let n=[],r=signals.effect(()=>{let s=shared.isFunction(t)?t():t,i=shared.coerceArray(s).map(c=>shared.isFunction(c)?c():c).flatMap(T);n=Ge(e,n,i,o);});return I(()=>{r(),n.forEach(s=>x(s)),n.length=0;}),n}function de(e,t){let o=t.length,n=new Array(o),r=new Set(t),s=1,i=0,c=a=>{if(a.nodeType!==Node.DOCUMENT_FRAGMENT_NODE){if(r.has(s)&&(n[i++]=a,i===o))return true;s++;}let u=a.firstChild;for(;u;){if(c(u))return true;u=u.nextSibling;}return false};return c(e),n}function Ut(e){let t=N();if(t){if(t.isMounted){try{e();}catch(o){}return}t.onMount||(t.onMount=new Set),t.onMount.add(e);}}function jt(e){let t=N();t&&(t.onUpdate||(t.onUpdate=new Set),t.onUpdate.add(e));}function zt(e){let t=N();t&&(t.onDestroy||(t.onDestroy=new Set),t.onDestroy.add(e));}function We(e){!e||e.isDestroyed||e.isMounted||(e.isMounted=true,e.onMount&&D(e,()=>{for(let t of e.onMount)try{t();}catch(o){}}));}function pe(e){if(!(!e||e.isDestroyed)&&e.onUpdate)for(let t of e.onUpdate)try{t();}catch(o){}}function me(e){Ut(e);}function ye(e){zt(e);}function Yt(e){jt(e);}var Qe;Qe=ne;var X=class{constructor(t,o={}){this.component=t;this.props=o;this.renderedNodes=[];this.scope=null;this.parentNode=void 0;this.beforeNode=void 0;this.reactiveProps={};this._propSnapshots={};this.state=0;this.parentScope=null;this[Qe]=true;this.key=o.key?ce(o.key):Fe(t),this.reactiveProps=signals.shallowReactive(K({},o)),this.parentScope=N();for(let n in o){let r=o[n];shared.isObject(r)&&(this._propSnapshots[n]=shared.isArray(r)?[...r]:K({},r));}}get isConnected(){return this.state===2}get firstChild(){for(let t of this.renderedNodes){let o=_(t);if(o)return o}}mount(t,o){var s;if(this.parentNode=t,this.beforeNode=o,this.state=1,this.renderedNodes.length>0){for(let i of this.renderedNodes)y(t,i,o);return this.state=2,this.renderedNodes}let n=(s=this.parentScope)!=null?s:N();this.scope=ee(n);let r=D(this.scope,()=>{var c;let i=this.component(this.reactiveProps);return shared.isFunction(i)&&(i=i(this.reactiveProps)),(signals.isSignal(i)||signals.isComputed(i))&&(i=i.value),(c=le(t,i,o))!=null?c:[]});return this.renderedNodes=r,D(this.scope,()=>{this.applyProps(this.props);}),this.state=2,this.scope&&We(this.scope),this.renderedNodes}update(t){return this.key!==t.key?(this.mount(t.parentNode,t.beforeNode),this):(this.parentNode=t.parentNode,this.beforeNode=t.beforeNode,this.scope=t.scope,this.parentScope=t.parentScope,this.renderedNodes=t.renderedNodes,this.state=t.state,this.reactiveProps=t.reactiveProps,this._propSnapshots=t._propSnapshots,this._updateReactiveProps(this.props),!this.isConnected&&this.parentNode?(this.mount(this.parentNode,this.beforeNode),this):(this.scope&&(D(this.scope,()=>{this.applyProps(this.props);}),pe(this.scope)),this))}_updateReactiveProps(t){for(let o in t){if(o==="key")continue;let n=t[o],r=this.reactiveProps[o];if(n===r&&!this._propSnapshots[o])continue;if(shared.isObject(n)){let i=this._propSnapshots[o];if(i&&ue(n,i))continue;let c=shared.isArray(n)?[...n]:K({},n);this.reactiveProps[o]=c,this._propSnapshots[o]=c;}else shared.hasChanged(n,r)&&(this.reactiveProps[o]=n,this._propSnapshots[o]&&delete this._propSnapshots[o]);}}unwrapRenderResult(t){return shared.isFunction(t)&&(t=t(this.reactiveProps)),(signals.isSignal(t)||signals.isComputed(t))&&(t=t.value),p(t)&&(t=t.mount(this.parentNode,this.beforeNode)),shared.isPromise(t)&&(t=t.then(o=>this.unwrapRenderResult(o))),t}forceUpdate(){if(this.state===5||!this.parentNode||!this.scope)return;let t=[...this.renderedNodes];try{D(this.scope,()=>{let o=this.component(this.reactiveProps);shared.isFunction(o)&&(o=o(this.reactiveProps)),(signals.isSignal(o)||signals.isComputed(o))&&(o=o.value);let n=shared.coerceArray(o),r=this._getAnchorNode();if(this.parentNode){for(let s of this.renderedNodes)x(s);for(let s of n)y(this.parentNode,s,r);this.renderedNodes=n;}}),this.scope&&pe(this.scope);}catch(o){throw this.renderedNodes=t,o}}_getAnchorNode(){if(this.beforeNode)return this.beforeNode;if(this.renderedNodes.length>0){let t=this.renderedNodes[this.renderedNodes.length-1],o=_(t);if(o)return o.nextSibling}}destroy(){if(this.state===4||this.state===5)return;this.state=4;let t=this.scope;t&&(j(t),this.scope=null);for(let o of this.renderedNodes)x(o);this.renderedNodes=[],this.parentNode=void 0,this.beforeNode=void 0,this.parentScope=null,this.reactiveProps={},this.props={},this.state=5;}applyProps(t){if(!t)return;let o=this.firstChild;for(let[n,r]of Object.entries(t))if(shared.startsWith(n,"on")){if(!o||!shared.isHTMLElement(o))return;let s=n.slice("on".length).toLowerCase();v(o,s,r);}else n==="ref"&&signals.isSignal(r)&&(r.value=o);this.props=t;}};function p(e){return !!e&&!!e[ne]}function $(e,t){return p(e)?e:new X(e,t)}function Ne(e){let t,o=()=>{let n=document.createElement("template");n.innerHTML=e;let r=n.content.firstChild;if(!r)throw new Error("Invalid template: empty content");return r};return ()=>(t||(t=o())).cloneNode(true)}function eo(e,t){let o=shared.isString(t)?document.querySelector(t):t;if(!o){shared.error(`Target element not found: ${t}`);return}o.innerHTML&&(shared.error(`Target element is not empty, it will be delete: ${t}`),o.innerHTML="");let r=p(e)?e:$(e);return r.mount(o),r}function Se(e,t){let o=N();o&&(o.provides||(o.provides=new Map),o.provides.set(e,t));}function Ee(e,t){let o=N();if(!o)return t;let n=o;for(;n;){if(n.provides){let r=n.provides.get(e);if(r)return r}n=n.parent;}return t}function xe(e,t){Object.defineProperty(e,"target",{configurable:true,value:t});}function nt(e,t,o){let n=e[`_$${o}`];if(n&&shared.isFunction(n)&&!e.disabled){let r=e[`${o}Data`];if(r?n.call(e,r,t):n.call(e,t),t.cancelBubble)return false}return e.host&&!shared.isString(e.host)&&!e.host._$host&&shared.isFunction(e.contains)&&e.contains(t.target)&&xe(t,e.host),true}function tt(e,t,o){let n=e;for(;nt(n,t,o)&&(n=n._$host||n.parentNode||n.host););return n}function oo(e){let t=e.target,o=`${e.type}`,n=e.target,r=e.currentTarget;if(Object.defineProperty(e,"currentTarget",{configurable:true,get(){return t||document}}),e.composedPath){let s=e.composedPath();xe(e,s[0]);for(let i=0;i<s.length-2&&(t=s[i],!!nt(t,e,o));i++){if(t._$host){t=t._$host,t=tt(t,e,o);break}if(t.parentNode===r)break}}else t=tt(t,e,o);xe(e,n);}var ot=Symbol("_$EVENTS");function no(e,t=window.document){let o=t,n=o[ot]||(o[ot]=new Set);for(let r of e)n.has(r)||(n.add(r),t.addEventListener(r,oo));}function ro(e,t){let o=new Set(t);return new Proxy(e,{get(n,r){if(!o.has(r))return Reflect.get(n,r)},ownKeys(n){return Reflect.ownKeys(n).filter(r=>!o.has(r))},getOwnPropertyDescriptor(n,r){if(!o.has(r))return Reflect.getOwnPropertyDescriptor(n,r)},has(n,r){return o.has(r)?false:Reflect.has(n,r)}})}var _e=false;function W(){_e=true;}function U(){_e=false;}function L(){return _e}var rt=0;function q(){return `${rt++}`}function B(){rt=0;}var st=/^\d+-\d+$/;function ct(e){return ()=>{if(!shared.isBrowser())return null;let t=q(),o=document.querySelector(`[data-hk="${t}"]`);return o||Ne(e)()}}function at(e,t){let o=e.dataset.hk;if(!o)return de(e,t);let n=[],r=e.querySelectorAll(`[data-idx^="${o}"]`);r.length>0&&n.push(...Array.from(r).filter(a=>{let u=a.dataset.idx;return u!==null&&st.test(u)}).map(a=>{let u=a.dataset.idx||"",[l,f]=u.split("-");return {hk:l,idx:f,node:a}}));let s=[],i=a=>{if(a.nodeType===Node.COMMENT_NODE&&a.textContent&&st.test(a.textContent)){let[l,f]=a.textContent.split("-");s.push({hk:l,idx:f,node:a});}let u=a.firstChild;for(;u;)i(u),u=u.nextSibling;};i(e),n.push(...s);let c=[e];return t.forEach(a=>{let u=n.find(l=>l.idx===String(a));u&&c.push(u.node);}),c}function ut(e,t){W(),B();try{let o=shared.isString(t)?document.querySelector(t):t;if(!o){shared.error("Hydration error: Root element not found");return}let n=$(e);return n.mount(o),U(),n}catch(o){shared.error("Hydration error:",o),U();return}}function ft(e,t,o,n=false){if(t===o||L())return;let r=J(o),s=J(t);r&&s===r||(r?n?e.setAttribute("class",r):e.className=r:e.removeAttribute("class"));}function J(e){return shared.normalizeClassName(e)}var lt=/\s*!important$/,lo=["Webkit","Moz","ms"],ve={};function pt(e,t,o){let n=e.style,r=shared.isString(o);if(!L()){if(o&&r){t!==o&&(n.cssText=o);return}if(!o){t&&e.removeAttribute("style");return}if(t&&!shared.isString(t))for(let s in t)(!o||o[s]==null)&&O(n,s,"");else if(t&&shared.isString(t)){let s=t.split(";");for(let i of s){let c=i.indexOf(":");if(c>0){let a=i.slice(0,c).trim();o&&shared.isObject(o)&&o[a]==null&&O(n,a,"");}}}if(o&&!shared.isString(o))for(let s in o){let i=o[s];(!t||shared.isString(t)||t[s]!==i)&&i!=null&&O(n,s,i);}}}function O(e,t,o){if(shared.isArray(o)){for(let r of o)O(e,t,r);return}if((o==null||o==="")&&(o=""),t.startsWith("--")){e.setProperty(t,o);return}let n=po(e,t);shared.isString(o)&&lt.test(o)?e.setProperty(shared.camelCase(n),o.replace(lt,""),"important"):e[n]=o;}function po(e,t){let o=ve[t];if(o)return o;let n=shared.camelCase(t);if(n!=="filter"&&n in e)return ve[t]=n;n=shared.capitalize(n);for(let r of lo){let s=r+n;if(s in e)return ve[t]=s}return t}function Ae(e,t,o,n){if(t==="key"){n==null?V(e,void 0):V(e,String(n));return}if(t===Me){Object.keys(n).forEach(f=>{Ae(e,f,o==null?void 0:o[f],n==null?void 0:n[f]);});return}if(L())return;let r=(e==null?void 0:e.namespaceURI)===Re,s=r&&t.startsWith("xlink:"),i=r&&t.startsWith("xmlns:"),c=shared.isSpecialBooleanAttr(t)||shared.isBooleanAttr(t);if(o===n)return;let a=t.toLowerCase();if(a.length>2&&a.charCodeAt(0)===111&&a.charCodeAt(1)===110||a==="innerhtml")return;if(n==null){if(s)e.removeAttributeNS(te,t.slice(6));else if(i){let f=t.slice(6);e.removeAttributeNS(oe,f);}else e.removeAttribute(t);return}if(s){e.setAttributeNS(te,t,String(n));return}if(i){e.setAttributeNS(oe,t,String(n));return}if(c){shared.includeBooleanAttr(n)?e.setAttribute(t,""):e.removeAttribute(t);return}let u=shared.isSymbol(n)?String(n):n;if((a==="href"||a==="src"||a==="xlink:href")&&shared.isString(u)){let f=u.trim().toLowerCase();if(f.startsWith("javascript:")||f.startsWith("data:"))return}if(r)e.setAttribute(t,String(u));else if(t in e)try{e[t]=u;}catch(f){e.setAttribute(t,String(u));}else e.setAttribute(t,String(u));}function mt(e,t,o,n){if(!(n!=null&&n.delegate))return e.addEventListener(t,o,n),()=>e.removeEventListener(t,o,n);let r=n.delegate,s=c=>{let a=c.target;(a.matches(r)||a.closest(r))&&o.call(e,c);},i=K({},n);return i.delegate=void 0,e.addEventListener(t,s,i),()=>{e.removeEventListener(t,s,i);}}function be(e){if(!(e!=null&&e.children))return shared.error("Fragment component requires children"),null;let{children:t}=e;return t}be[re]=true;function yt(e){return !!e&&!!e[re]}function Pe(e){let t=document.createComment("portal");t[z]=true;let o=e.children;if(o){let n=shared.isArray(o)?o:[o],r=[];me(()=>{let s=shared.isString(e.target)?document.querySelector(e.target):e.target;s&&(n.forEach(i=>{if(i!=null){let c=T(i);c&&(y(s,c),r.push(c));}}),I(()=>{r.forEach(i=>{!shared.isString(i)&&i.parentNode===s&&s.removeChild(i);});}));});}return t}Pe[z]=true;function gt(e){return !!e&&!!e[z]}var ke=Symbol("SuspenseContext");function Te(e){if(shared.isUndefined(document)){let f=e.fallback;return f?String(f||""):""}let t=document.createElement("div");t.style.display="contents";let o=true,n=0,r=false,s=null,i=()=>{if(!r){for(r=true;t.firstChild;)t.removeChild(t.firstChild);if(e.fallback!=null){let f=T(e.fallback);f&&y(t,f);}}},c=()=>{if(!(!r||!(s||e.children!=null&&!shared.isPromise(e.children)))){for(r=false;t.firstChild;)t.removeChild(t.firstChild);s?a(s):e.children!=null&&!shared.isPromise(e.children)&&a(e.children);}},a=f=>{for(;t.firstChild;)t.removeChild(t.firstChild);if(f==null)return;let m=N();if((shared.isArray(f)?f:[f]).forEach(A=>{if(A!=null){p(A)&&(A.parentContext=m);let R=T(A);R&&y(t,R);}}),r){for(;t.firstChild;)t.removeChild(t.firstChild);if(e.fallback!=null){let A=T(e.fallback);A&&y(t,A);}}},u={register:f=>{n++,i(),f.then(()=>{o&&(n--,n===0&&c());}).catch(m=>{o&&(n--,n===0&&c());});},increment:()=>{n++,i();},decrement:()=>{n--,n===0&&c();}};Se(ke,u);let l=e.children;return shared.isPromise(l)?(l.then(f=>{s=f;}).catch(()=>{}),u.register(l)):l!=null?a(l):i(),ye(()=>{for(o=false;t.firstChild;)t.removeChild(t.firstChild);}),t}Te[ie]=true;function Nt(e){return !!e&&!!e[ie]}function St(e,t){let o=signals.signal(t==null?void 0:t.initialValue),n=signals.signal(true),r=signals.signal(null),s=signals.signal("pending"),i=0,c=null,a=()=>Z(null,null,function*(){let f=++i;n.value=true,s.value="pending",r.value=null;try{let m=e();c=m.then(()=>{}).catch(()=>{});let S=yield m;f===i&&(o.value=S,s.value="ready",n.value=!1);}catch(m){f===i&&(r.value=m instanceof Error?m:new Error(String(m)),s.value="errored",n.value=false);}});a();let u=(()=>{if(n.value&&c){let f=Ee(ke,null);f&&f.register(c);}return o.value});return u.loading=n,u.error=r,u.state=s,[u,{mutate:f=>{o.value=f,s.value="ready",n.value=false,r.value=null;},refetch:()=>Z(null,null,function*(){yield a();})}]}
2
+ exports.Component=X;exports.Fragment=be;exports.Portal=Pe;exports.Suspense=Te;exports.addEvent=mt;exports.addEventListener=v;exports.bindElement=Ot;exports.createApp=eo;exports.createComponent=$;exports.createResource=St;exports.createScope=ee;exports.delegateEvents=no;exports.disposeScope=j;exports.endHydration=U;exports.getActiveScope=N;exports.getFirstDOMNode=_;exports.getHydrationKey=q;exports.getRenderedElement=ct;exports.hydrate=ut;exports.inject=Ee;exports.insert=le;exports.insertNode=y;exports.isComponent=p;exports.isFragment=yt;exports.isHydrating=L;exports.isPortal=gt;exports.isSameNode=P;exports.isSuspense=Nt;exports.mapNodes=de;exports.mapSSRNodes=at;exports.normalizeClass=J;exports.normalizeNode=T;exports.omitProps=ro;exports.onCleanup=I;exports.onDestroy=ye;exports.onMount=me;exports.onUpdate=Yt;exports.patchAttr=Ae;exports.patchClass=ft;exports.patchStyle=pt;exports.provide=Se;exports.removeNode=x;exports.replaceNode=Y;exports.resetHydrationKey=B;exports.runWithScope=D;exports.setActiveScope=Le;exports.setStyle=O;exports.shallowCompare=ue;exports.startHydration=W;exports.template=Ne;//# sourceMappingURL=template.cjs.js.map
8
3
  //# sourceMappingURL=template.cjs.js.map