@estjs/template 0.0.15-beta.13 → 0.0.15-beta.14
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/template.cjs.js +2 -2
- package/dist/template.cjs.js.map +1 -1
- package/dist/template.d.cts +71 -42
- package/dist/template.d.ts +71 -42
- package/dist/template.dev.cjs.js +127 -129
- package/dist/template.dev.cjs.js.map +1 -1
- package/dist/template.dev.esm.js +127 -129
- package/dist/template.dev.esm.js.map +1 -1
- package/dist/template.esm.js +2 -2
- package/dist/template.esm.js.map +1 -1
- package/package.json +3 -3
package/dist/template.esm.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {isHTMLElement,isPrimitive,isFalsy,isNull,isObject,isArray,isHtmlInputElement,isHtmlSelectElement,isHtmlTextAreaElement,isFunction,hasChanged,isPromise,coerceArray,startsWith,isString,error,isBrowser,normalizeClassName,camelCase,capitalize,isSpecialBooleanAttr,isBooleanAttr,includeBooleanAttr,isSymbol,isUndefined,isNumber,isTextNode}from'@estjs/shared';import {effect,shallowReactive,isSignal,isComputed,signal,memoEffect,untrack}from'@estjs/signals';var vt=Object.defineProperty;var De=Object.getOwnPropertySymbols;var xt=Object.prototype.hasOwnProperty,_t=Object.prototype.propertyIsEnumerable;var Le=(e,t,n)=>t in e?vt(e,t,{enumerable:true,configurable:true,writable:true,value:n}):e[t]=n,V=(e,t)=>{for(var n in t||(t={}))xt.call(t,n)&&Le(e,n,t[n]);if(De)for(var n of De(t))_t.call(t,n)&&Le(e,n,t[n]);return e};var ie=(e,t,n)=>new Promise((o,r)=>{var s=a=>{try{c(n.next(a));}catch(f){r(f);}},i=a=>{try{c(n.throw(a));}catch(f){r(f);}},c=a=>a.done?o(a.value):Promise.resolve(a.value).then(s,i);c((n=n.apply(e,t)).next());});var K=null,At=0;function C(){return K}function R(e){K=e;}function z(e=K){let t={id:++At,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 O(e,t){let n=K;K=e;try{return t()}finally{K=n;}}function $(e){var t,n,o,r,s;if(!(!e||e.isDestroyed)){if(e.children)for(;e.children.size>0;){let i=e.children.values().next().value;i&&$(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),(n=e.children)==null||n.clear(),(o=e.provides)==null||o.clear(),(r=e.onMount)==null||r.clear(),(s=e.onUpdate)==null||s.clear(),R(e.parent),e.parent=null,e.isDestroyed=true;}}function H(e){let t=K;t&&(t.cleanup||(t.cleanup=new Set),t.cleanup.add(e));}var Me="_$spread$";var Re="http://www.w3.org/2000/svg",se="http://www.w3.org/2000/xlink",ce="http://www.w3.org/2000/xmlns/";var ae=Symbol(""),fe=Symbol(""),X=Symbol(""),ue=Symbol(""),He=Symbol("");var Ie=1e3,Fe=new WeakMap;function Oe(e){let t=Fe.get(e);if(!t){let n=e.name||"anonymous",o=Ve(e.toString()).toString(36);t=`${n}_${o}`,Fe.set(e,t);}return t}function Ve(e){let t=0,n=e.length<100?e.length:100;for(let o=0;o<n;o++)t=Math.trunc((t<<5)-t+e.charCodeAt(o));return t<0?-t:t}var Pt=0;function de(e){if(!isFalsy(e)){if(isString(e))return e.length<=Ie?e:`${e.slice(0,Ie-10)}_${Ve(e).toString(36)}`;if(isNumber(e))return String(e);if(isSymbol(e)){let t=Symbol.keyFor(e);if(t)return `_s.${t}`;let n=e.description;return n?`_s.${n}`:`${Pt++}`}return String(e)}}var le=Symbol("essor.key");function Y(e,t){if(y(e)||!e||e.nodeType===Node.DOCUMENT_NODE)return;let n=de(t);isFalsy(n)?delete e[le]:e[le]=n;}function L(e){if(e)return y(e)?e.key:e[le]}function M(e){if(isHTMLElement(e))return e;if(isPrimitive(e)){let t=isFalsy(e)?"":String(e);return document.createTextNode(t)}return e}function D(e,t){let n=L(e),o=L(t);if(n!==o)return false;let r=y(e),s=y(t);if(r&&s)return e.component===t.component;if(r!==s)return false;if(isPrimitive(e)||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 me(e,t){if(e===t)return true;if(isNull(e)||isNull(t)||!isObject(e)||!isObject(t)||isArray(e)!==isArray(t))return false;let n=e,o=t,r=Object.keys(n),s=Object.keys(o);if(r.length!==s.length)return false;for(let i of r)if(!(i in o)||n[i]!==o[i])return false;return true}function P(e){if(!e)return;if(y(e)){e.destroy();return}let t=e;t.parentElement&&t.remove();}function k(e,t,n){if(!e||!t)return;if(y(t)){let r=y(n)?n.firstChild:n;t.mount(e,r);return}let o=y(n)?n.firstChild:n;o?e.insertBefore(t,o):e.appendChild(t);}function q(e,t,n){if(!e||!t||!n||t===n)return;let o=y(n)?n.beforeNode:n.nextSibling;P(n),k(e,t,o);}function T(e){if(e){if(y(e))return e.firstChild;if(!isPrimitive(e))return e}}function Be(e,t){if(y(e)||y(t))return;let n=L(e);n&&!L(t)&&Y(t,n);}function I(e,t,n){if(n===t)return t;let o=isHTMLElement(t);if(isHTMLElement(n)&&o){if(n.isEqualNode(t))return t;if(t.tagName===n.tagName){let c=t.attributes,a=n.attributes;for(let f=c.length-1;f>=0;f--){let p=c[f].name;n.hasAttribute(p)||t.removeAttribute(p);}for(let f=0,p=a.length;f<p;f++){let u=a[f];t.getAttribute(u.name)!==u.value&&t.setAttribute(u.name,u.value);}return Be(t,n),t}}if(isTextNode(t)&&isTextNode(n))return t.textContent!==n.textContent&&(t.textContent=n.textContent),Be(t,n),t;let s=y(t),i=y(n);return s&&i&&t.component===n.component?n.update(t):(q(e,n,t),n)}function Ge(e,t,n,o){let r=t.length,s=n.length;if(r===0&&s===0)return [];if(r===0){for(let i=0;i<s;i++)k(e,n[i],o);return n}if(s===0){for(let i=0;i<r;i++)P(t[i]);return []}if(r===1&&s===1){let i=t[0],c=n[0];return D(i,c)?(I(e,i,c),n[0]=i):q(e,c,i),n}if(r===2&&s===2){let i=t[0],c=t[1],a=n[0],f=n[1];if(D(i,a)&&D(c,f))return I(e,i,a),I(e,c,f),n[0]=i,n[1]=c,n;if(D(i,f)&&D(c,a)){I(e,i,f),I(e,c,a);let p=T(c),u=T(i);return p&&u&&p.parentNode===e&&e.insertBefore(p,u),n[0]=c,n[1]=i,n}}return Lt(e,t,n,o)}function Lt(e,t,n,o){let r=0,s=0,i=t.length-1,c=n.length-1,a=t[0],f=t[i],p=n[0],u=n[c];for(;r<=i&&s<=c;)if(!a)a=t[++r];else if(!f)f=t[--i];else if(D(a,p))I(e,a,p),n[s]=a,a=t[++r],p=n[++s];else break;for(;r<=i&&s<=c;)if(!a)a=t[++r];else if(!f)f=t[--i];else if(D(f,u))I(e,f,u),n[c]=f,f=t[--i],u=n[--c];else break;if(r>i){if(s<=c){let l=c+1<n.length?T(n[c+1]):o;for(let m=s;m<=c;m++)k(e,n[m],l);}}else if(s>c)for(let l=r;l<=i;l++){let m=t[l];m&&P(m);}else Mt(e,t,n,r,i,s,c,o);return n}function Mt(e,t,n,o,r,s,i,c){let a=i-s+1,f;for(let S=s;S<=i;S++){let v=L(n[S]);v!==void 0&&(f||(f=Object.create(null)),f[v]=S);}let p=new Int32Array(a),u=false,l=0,m=0;for(let S=o;S<=r;S++){let v=t[S];if(!v)continue;if(m>=a){P(v);continue}let _,A=L(v);if(A!==void 0&&f&&A in f)_=f[A];else for(let d=s;d<=i;d++)if(p[d-s]===0&&A===void 0&&L(n[d])===void 0&&D(v,n[d])){_=d;break}_===void 0?P(v):(p[_-s]=S+1,_>=l?l=_:u=true,I(e,v,n[_]),n[_]=v,m++);}let E=u?Rt(p):[],x=E.length-1,h=c;for(let S=a-1;S>=0;S--){let v=s+S,_=n[v];if(p[S]===0)k(e,_,h),h=T(_)||h;else if(u)if(x<0||S!==E[x]){let A=T(_);A&&A.parentNode===e&&k(e,A,h),h=A||h;}else h=T(_)||h,x--;else h=T(_)||h;}}function Rt(e){let t=e.length;if(t===0)return [];if(t===1)return e[0]!==0?[0]:[];let n=[],o=new Int32Array(t),r,s,i,c,a;for(r=0;r<t;r++){let f=e[r];if(f!==0){if(s=n[n.length-1],n.length===0||e[s]<f){o[r]=s,n.push(r);continue}for(i=0,c=n.length-1;i<c;)a=i+c>>1,e[n[a]]<f?i=a+1:c=a;f<e[n[i]]&&(i>0&&(o[r]=n[i-1]),n[i]=r);}}for(i=n.length,c=n[i-1];i-- >0;)n[i]=c,c=o[c];return n}function w(e,t,n,o){e.addEventListener(t,n,o),H(()=>{e.removeEventListener(t,n,o);});}function Vt(e,t,n,o){isHtmlInputElement(e)?$t(e,o):isHtmlSelectElement(e)?Ut(e,o):isHtmlTextAreaElement(e)&&w(e,"input",()=>{o(e.value);});}function $t(e,t){switch(e.type){case "checkbox":w(e,"change",()=>{t(!!e.checked);});break;case "radio":w(e,"change",()=>{t(e.checked?e.value:"");});break;case "file":w(e,"change",()=>{t(e.files);});break;case "number":case "range":w(e,"input",()=>{t(e.value||"");});break;case "date":case "datetime-local":case "month":case "time":case "week":w(e,"change",()=>{t(e.value||"");});break;default:w(e,"input",()=>{t(e.value);});break}}function Ut(e,t){w(e,"change",()=>{if(e.multiple){let n=Array.from(e.options).filter(o=>o.selected).map(o=>o.value);t(n);}else t(e.value);});}function ye(e,t,n){if(!e)return;let o=[],r=C(),s=effect(()=>{let i=()=>{let c=isFunction(t)?t():t,a=coerceArray(c).map(f=>isFunction(f)?f():f).flatMap(M);o=Ge(e,o,a,n);};r?O(r,i):i();});return H(()=>{s(),o.forEach(i=>P(i)),o.length=0;}),o}function he(e,t){let n=t.length,o=new Array(n),r=new Set(t),s=1,i=0,c=a=>{if(a.nodeType!==Node.DOCUMENT_FRAGMENT_NODE){if(r.has(s)&&(o[i++]=a,i===n))return true;s++;}let f=a.firstChild;for(;f;){if(c(f))return true;f=f.nextSibling;}return false};return c(e),o}function jt(e){let t=C();if(t){if(t.isMounted){try{e();}catch(n){}return}t.onMount||(t.onMount=new Set),t.onMount.add(e);}}function zt(e){let t=C();t&&(t.onUpdate||(t.onUpdate=new Set),t.onUpdate.add(e));}function Yt(e){let t=C();t&&(t.onDestroy||(t.onDestroy=new Set),t.onDestroy.add(e));}function Xe(e){!e||e.isDestroyed||e.isMounted||(e.isMounted=true,e.onMount&&O(e,()=>{for(let t of e.onMount)try{t();}catch(n){}}));}function ge(e){if(!(!e||e.isDestroyed)&&e.onUpdate)for(let t of e.onUpdate)try{t();}catch(n){}}function Ne(e){jt(e);}function Se(e){Yt(e);}function Bt(e){zt(e);}var Ze;Ze=ae;var Q=class{constructor(t,n={}){this.component=t;this.props=n;this.renderedNodes=[];this.scope=null;this.parentNode=void 0;this.beforeNode=void 0;this.reactiveProps={};this._propSnapshots={};this.state=0;this.parentScope=null;this[Ze]=true;this.key=n.key?de(n.key):Oe(t),this.reactiveProps=shallowReactive(V({},n)),this.parentScope=C();for(let o in n){let r=n[o];isObject(r)&&(this._propSnapshots[o]=isArray(r)?[...r]:V({},r));}}get isConnected(){return this.state===2}get firstChild(){for(let t of this.renderedNodes){let n=T(t);if(n)return n}}mount(t,n){var i,c;if(this.parentNode=t,this.beforeNode=n,this.state=1,this.renderedNodes.length>0){for(let a of this.renderedNodes)k(t,a,n);return this.state=2,this.renderedNodes}let o=(i=this.parentScope)!=null?i:C();this.scope=z(o),R(this.scope);let r=this.component(this.reactiveProps);isFunction(r)&&(r=r(this.reactiveProps)),(isSignal(r)||isComputed(r))&&(r=r.value);let s=(c=ye(t,r,n))!=null?c:[];return this.renderedNodes=s,this.applyProps(this.props),this.state=2,Xe(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&&(R(this.scope),this.applyProps(this.props),ge(this.scope)),this))}_updateReactiveProps(t){for(let n in t){if(n==="key")continue;let o=t[n],r=this.reactiveProps[n];if(o===r&&!this._propSnapshots[n])continue;if(isObject(o)){let i=this._propSnapshots[n];if(i&&me(o,i))continue;let c=isArray(o)?[...o]:V({},o);this.reactiveProps[n]=c,this._propSnapshots[n]=c;}else hasChanged(o,r)&&(this.reactiveProps[n]=o,this._propSnapshots[n]&&delete this._propSnapshots[n]);}}unwrapRenderResult(t){return isFunction(t)&&(t=t(this.reactiveProps)),(isSignal(t)||isComputed(t))&&(t=t.value),y(t)&&(t=t.mount(this.parentNode,this.beforeNode)),isPromise(t)&&(t=t.then(n=>this.unwrapRenderResult(n))),t}forceUpdate(){if(this.state===5||!this.parentNode||!this.scope)return;let t=[...this.renderedNodes];try{O(this.scope,()=>{let n=this.component(this.reactiveProps);isFunction(n)&&(n=n(this.reactiveProps)),(isSignal(n)||isComputed(n))&&(n=n.value);let o=coerceArray(n),r=this._getAnchorNode();if(this.parentNode){for(let s of this.renderedNodes)P(s);for(let s of o)k(this.parentNode,s,r);this.renderedNodes=o;}}),this.scope&&ge(this.scope);}catch(n){throw this.renderedNodes=t,n}}_getAnchorNode(){if(this.beforeNode)return this.beforeNode;if(this.renderedNodes.length>0){let t=this.renderedNodes[this.renderedNodes.length-1],n=T(t);if(n)return n.nextSibling}}destroy(){if(this.state===4||this.state===5)return;this.state=4;for(let n of this.renderedNodes)P(n);let t=this.scope;t&&($(t),this.scope=null),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 n=this.firstChild;for(let[o,r]of Object.entries(t))if(startsWith(o,"on")){if(!n||!isHTMLElement(n))return;let s=o.slice("on".length).toLowerCase();w(n,s,r);}else o==="ref"&&isSignal(r)&&(r.value=n);this.props=t;}};function y(e){return !!e&&!!e[ae]}function B(e,t){return y(e)?e:new Q(e,t)}function xe(e){let t,n=()=>{let o=document.createElement("template");o.innerHTML=e;let r=o.content.firstChild;if(!r)throw new Error("Invalid template: empty content");return r};return ()=>(t||(t=n())).cloneNode(true)}function tn(e,t){let n=isString(t)?document.querySelector(t):t;if(!n){error(`Target element not found: ${t}`);return}n.innerHTML&&(error(`Target element is not empty, it will be delete: ${t}`),n.innerHTML="");let r=y(e)?e:B(e);return r.mount(n),r}function _e(e,t){let n=C();n&&(n.provides||(n.provides=new Map),n.provides.set(e,t));}function Ae(e,t){let n=C();if(!n)return t;let o=n;for(;o;){if(o.provides){let r=o.provides.get(e);if(r)return r}o=o.parent;}return t}function be(e,t){Object.defineProperty(e,"target",{configurable:true,value:t});}function rt(e,t,n){let o=e[`_$${n}`];if(o&&isFunction(o)&&!e.disabled){let r=e[`${n}Data`];if(r?o.call(e,r,t):o.call(e,t),t.cancelBubble)return false}return e.host&&!isString(e.host)&&!e.host._$host&&isFunction(e.contains)&&e.contains(t.target)&&be(t,e.host),true}function nt(e,t,n){let o=e;for(;rt(o,t,n)&&(o=o._$host||o.parentNode||o.host););return o}function on(e){let t=e.target,n=`${e.type}`,o=e.target,r=e.currentTarget;if(Object.defineProperty(e,"currentTarget",{configurable:true,get(){return t||document}}),e.composedPath){let s=e.composedPath();be(e,s[0]);for(let i=0;i<s.length-2&&(t=s[i],!!rt(t,e,n));i++){if(t._$host){t=t._$host,t=nt(t,e,n);break}if(t.parentNode===r)break}}else t=nt(t,e,n);be(e,o);}var ot=Symbol("_$EVENTS");function rn(e,t=window.document){let n=t,o=n[ot]||(n[ot]=new Set);for(let r of e)o.has(r)||(o.add(r),t.addEventListener(r,on));}function sn(e,t){let n=new Set(t);return new Proxy(e,{get(o,r){if(!n.has(r))return Reflect.get(o,r)},ownKeys(o){return Reflect.ownKeys(o).filter(r=>!n.has(r))},getOwnPropertyDescriptor(o,r){if(!n.has(r))return Reflect.getOwnPropertyDescriptor(o,r)},has(o,r){return n.has(r)?false:Reflect.has(o,r)}})}var Ce=false;function Z(){Ce=true;}function G(){Ce=false;}function F(){return Ce}var it=0;function ee(){return `${it++}`}function te(){it=0;}var ct=/^\d+-\d+$/;function at(e){return ()=>{if(!isBrowser())return null;let t=ee(),n=document.querySelector(`[data-hk="${t}"]`);return n||xe(e)()}}function ft(e,t){let n=e.dataset.hk;if(!n)return he(e,t);let o=[],r=e.querySelectorAll(`[data-idx^="${n}"]`);r.length>0&&o.push(...Array.from(r).filter(a=>{let f=a.dataset.idx;return f!==null&&ct.test(f)}).map(a=>{let f=a.dataset.idx||"",[p,u]=f.split("-");return {hk:p,idx:u,node:a}}));let s=[],i=a=>{if(a.nodeType===Node.COMMENT_NODE&&a.textContent&&ct.test(a.textContent)){let[p,u]=a.textContent.split("-");s.push({hk:p,idx:u,node:a});}let f=a.firstChild;for(;f;)i(f),f=f.nextSibling;};i(e),o.push(...s);let c=[e];return t.forEach(a=>{let f=o.find(p=>p.idx===String(a));f&&c.push(f.node);}),c}function ut(e,t){Z(),te();try{let n=isString(t)?document.querySelector(t):t;if(!n){error("Hydration error: Root element not found");return}let o=B(e);return o.mount(n),G(),o}catch(n){error("Hydration error:",n),G();return}}function lt(e,t,n,o=false){if(t===n||F())return;let r=ne(n),s=ne(t);r&&s===r||(r?o?e.setAttribute("class",r):e.className=r:e.removeAttribute("class"));}function ne(e){return normalizeClassName(e)}var dt=/\s*!important$/,pn=["Webkit","Moz","ms"],ke={};function mt(e,t,n){let o=e.style,r=isString(n);if(!F()){if(n&&r){t!==n&&(o.cssText=n);return}if(!n){t&&e.removeAttribute("style");return}if(t&&!isString(t))for(let s in t)(!n||n[s]==null)&&j(o,s,"");else if(t&&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();n&&isObject(n)&&n[a]==null&&j(o,a,"");}}}if(n&&!isString(n))for(let s in n){let i=n[s];(!t||isString(t)||t[s]!==i)&&i!=null&&j(o,s,i);}}}function j(e,t,n){if(isArray(n)){for(let r of n)j(e,t,r);return}if((n==null||n==="")&&(n=""),t.startsWith("--")){e.setProperty(t,n);return}let o=mn(e,t);isString(n)&&dt.test(n)?e.setProperty(camelCase(o),n.replace(dt,""),"important"):e[o]=n;}function mn(e,t){let n=ke[t];if(n)return n;let o=camelCase(t);if(o!=="filter"&&o in e)return ke[t]=o;o=capitalize(o);for(let r of pn){let s=r+o;if(s in e)return ke[t]=s}return t}function Pe(e,t,n,o){if(t==="key"){o==null?Y(e,void 0):Y(e,String(o));return}if(t===Me){Object.keys(o).forEach(u=>{Pe(e,u,n==null?void 0:n[u],o==null?void 0:o[u]);});return}if(F())return;let r=(e==null?void 0:e.namespaceURI)===Re,s=r&&t.startsWith("xlink:"),i=r&&t.startsWith("xmlns:"),c=isSpecialBooleanAttr(t)||isBooleanAttr(t);if(n===o)return;let a=t.toLowerCase();if(a.length>2&&a.charCodeAt(0)===111&&a.charCodeAt(1)===110||a==="innerhtml")return;if(o==null){if(s)e.removeAttributeNS(se,t.slice(6));else if(i){let u=t.slice(6);e.removeAttributeNS(ce,u);}else e.removeAttribute(t);return}if(s){e.setAttributeNS(se,t,String(o));return}if(i){e.setAttributeNS(ce,t,String(o));return}if(c){includeBooleanAttr(o)?e.setAttribute(t,""):e.removeAttribute(t);return}let f=isSymbol(o)?String(o):o;if((a==="href"||a==="src"||a==="xlink:href")&&isString(f)){let u=f.trim().toLowerCase();if(u.startsWith("javascript:")||u.startsWith("data:"))return}if(r)e.setAttribute(t,String(f));else if(t in e)try{e[t]=f;}catch(u){e.setAttribute(t,String(f));}else e.setAttribute(t,String(f));}function yt(e,t,n,o){if(!(o!=null&&o.delegate))return e.addEventListener(t,n,o),()=>e.removeEventListener(t,n,o);let r=o.delegate,s=c=>{let a=c.target;(a.matches(r)||a.closest(r))&&n.call(e,c);},i=V({},o);return i.delegate=void 0,e.addEventListener(t,s,i),()=>{e.removeEventListener(t,s,i);}}function ht(e){if(!(e!=null&&e.children))return error("Fragment component requires children"),null;let{children:t}=e;return t}ht[fe]=true;function xn(e){return !!e&&!!e[fe]}function Nt(e){let t=document.createComment("portal");t[X]=true;let n=e.children;if(n){let o=isArray(n)?n:[n],r=[];Ne(()=>{let s=isString(e.target)?document.querySelector(e.target):e.target;s&&(o.forEach(i=>{if(i!=null){let c=M(i);c&&(k(s,c),r.push(c));}}),H(()=>{r.forEach(i=>{!isString(i)&&i.parentNode===s&&s.removeChild(i);});}));});}return t}Nt[X]=true;function An(e){return !!e&&!!e[X]}var we=Symbol("SuspenseContext");function St(e){if(isUndefined(document)){let u=e.fallback;return u?String(u||""):""}let t=document.createElement("div");t.style.display="contents";let n=true,o=0,r=false,s=null,i=()=>{if(!r){for(r=true;t.firstChild;)t.removeChild(t.firstChild);if(e.fallback!=null){let u=M(e.fallback);u&&k(t,u);}}},c=()=>{if(!(!r||!(s||e.children!=null&&!isPromise(e.children)))){for(r=false;t.firstChild;)t.removeChild(t.firstChild);s?a(s):e.children!=null&&!isPromise(e.children)&&a(e.children);}},a=u=>{for(;t.firstChild;)t.removeChild(t.firstChild);if(u==null)return;let l=C();if((isArray(u)?u:[u]).forEach(E=>{if(E!=null){y(E)&&(E.parentContext=l);let x=M(E);x&&k(t,x);}}),r){for(;t.firstChild;)t.removeChild(t.firstChild);if(e.fallback!=null){let E=M(e.fallback);E&&k(t,E);}}},f={register:u=>{o++,i(),u.then(()=>{n&&(o--,o===0&&c());}).catch(l=>{n&&(o--,o===0&&c());});},increment:()=>{o++,i();},decrement:()=>{o--,o===0&&c();}};_e(we,f);let p=e.children;return isPromise(p)?(p.then(u=>{s=u;}).catch(()=>{}),f.register(p)):p!=null?a(p):i(),Se(()=>{for(n=false;t.firstChild;)t.removeChild(t.firstChild);}),t}St[ue]=true;function kn(e){return !!e&&!!e[ue]}function Pn(e,t){let n=signal(t==null?void 0:t.initialValue),o=signal(true),r=signal(null),s=signal("pending"),i=0,c=null,a=()=>ie(null,null,function*(){let u=++i;o.value=true,s.value="pending",r.value=null;try{let l=e();c=l.then(()=>{}).catch(()=>{});let m=yield l;u===i&&(n.value=m,s.value="ready",o.value=!1);}catch(l){u===i&&(r.value=l instanceof Error?l:new Error(String(l)),s.value="errored",o.value=false);}});a();let f=(()=>{if(o.value&&c){let u=Ae(we,null);u&&u.register(c);}return n.value});return f.loading=o,f.error=r,f.state=s,[f,{mutate:u=>{n.value=u,s.value="ready",o.value=false,r.value=null;},refetch:()=>ie(null,null,function*(){yield a();})}]}function Et(e){let t=document.createDocumentFragment(),n=document.createComment("");t.appendChild(n);let o=[],r=null,s=e.keyFn,i=e.children,c=()=>{var m,E;let l=e.each;return isSignal(l)?(m=l.value)!=null?m:[]:typeof l=="function"?(E=l())!=null?E:[]:l!=null?l:[]},a=l=>s?s(l):l,f=(l,m,E,x)=>{var _;let h=C(),S=z(h);R(S);let v;try{let A=i(l,m);y(A)?(A.mount(E,x),v=(_=A.firstChild)!=null?_:document.createComment("empty")):(v=A,v.parentNode||(x?E.insertBefore(v,x):E.appendChild(v)));}finally{R(h);}return {key:a(l),node:v,scope:S}},p=l=>{$(l.scope),l.node.parentNode&&l.node.parentNode.removeChild(l.node);};memoEffect(({prev:l})=>{var x;let m=c();if(l===m)return {prev:m};let E=n.parentNode;if(!E){if(m.length===0){if(e.fallback){let h=e.fallback();y(h)?(h.mount(t,n),r=(x=h.firstChild)!=null?x:document.createComment("empty")):(r=h,t.insertBefore(r,n));}return {prev:m}}o=new Array(m.length);for(let[h,S]of m.entries())o[h]=f(S,h,t,n);return {prev:m}}return untrack(()=>u(E,m)),{prev:m}},{prev:[]});function u(l,m){var A;let E=o.length,x=m.length;if(x===0){for(let d=0;d<E;d++)p(o[d]);if(o=[],e.fallback&&!r){let d=e.fallback();y(d)?(d.mount(l,n),r=(A=d.firstChild)!=null?A:document.createComment("empty")):(r=d,l.insertBefore(r,n));}return}if(E===0||r){r&&(r.parentNode&&r.parentNode.removeChild(r),r=null),o=new Array(x);let d=document.createDocumentFragment();for(let b=0;b<x;b++)o[b]=f(m[b],b,d,null);l.insertBefore(d,n);return}let h=new Map;for(let d=0;d<E;d++){let b=o[d],W=h.get(b.key);W?W.push(b):h.set(b.key,[b]);}let S=new Array(x),v=[],_=document.createDocumentFragment();for(let d=0;d<x;d++){let b=m[d],W=a(b),re=h.get(W);re&&re.length>0?S[d]=re.shift():S[d]=f(b,d,_,null);}for(let d of h.values())for(let b of d)v.push(b);for(let d of v)p(d);for(let d=0;d<x;d++){let b=S[d].node;l.insertBefore(b,n);}o=S;}return H(()=>{for(let l of o)p(l);r&&r.parentNode&&r.parentNode.removeChild(r),n.parentNode&&n.parentNode.removeChild(n);}),t}Et[He]=true;
|
|
2
|
-
export{Q as Component,
|
|
1
|
+
import {isHTMLElement,isPrimitive,isFalsy,isNull,isObject,isArray,isHtmlInputElement,isHtmlSelectElement,isHtmlTextAreaElement,isFunction,hasChanged,isPromise,coerceArray,startsWith,isString,error,isBrowser,normalizeClassName,camelCase,capitalize,isSpecialBooleanAttr,isBooleanAttr,includeBooleanAttr,isSymbol,isUndefined,isNumber,isTextNode}from'@estjs/shared';import {effect,shallowReactive,isSignal,isComputed,signal,memoEffect,untrack}from'@estjs/signals';var _t=Object.defineProperty;var Me=Object.getOwnPropertySymbols;var Ct=Object.prototype.hasOwnProperty,Pt=Object.prototype.propertyIsEnumerable;var Re=(e,t,n)=>t in e?_t(e,t,{enumerable:true,configurable:true,writable:true,value:n}):e[t]=n,V=(e,t)=>{for(var n in t||(t={}))Ct.call(t,n)&&Re(e,n,t[n]);if(Me)for(var n of Me(t))Pt.call(t,n)&&Re(e,n,t[n]);return e};var ie=(e,t,n)=>new Promise((o,r)=>{var s=a=>{try{c(n.next(a));}catch(u){r(u);}},i=a=>{try{c(n.throw(a));}catch(u){r(u);}},c=a=>a.done?o(a.value):Promise.resolve(a.value).then(s,i);c((n=n.apply(e,t)).next());});var kt={mount:"mount",destroy:"destroy",update:"update"};function se(e,t,n){let o=e[t];o||(o=e[t]=[]),o.includes(n)||o.push(n);}function ce(e,t,n){let o=e.length;if(o===0)return;let r;for(let s=0;s<o;s++)try{let i=e[s]();if(isPromise(i)){let c=i.catch(a=>{});(r!=null?r:r=[]).push(c);}}catch(i){}if(r)return Promise.all(r).then(()=>{})}function ae(e){let t=C();if(t){if(t.isMounted){try{let n=e();isPromise(n)&&n.catch(o=>{});}catch(n){}return}se(t,"onMount",e);}}function Tt(e){let t=C();t&&se(t,"onUpdate",e);}function ue(e){let t=C();t&&se(t,"onDestroy",e);}function He(e){var o;if(e.isDestroyed||!((o=e.onMount)!=null&&o.length)){e.isMounted=true;return}let t=e.onMount,n=L(e,()=>ce(t,e.id,kt.mount));return t.length=0,e.isMounted=true,n}function fe(e){var o;if(e.isDestroyed||!((o=e.onUpdate)!=null&&o.length))return;let t=e.onUpdate,n=L(e,()=>ce(t,e.id,"update"));return t.length=0,n}function Fe(e){var t;if(!(e.isDestroyed||!((t=e.onDestroy)!=null&&t.length)))return L(e,()=>ce(e.onDestroy,e.id,"destroy"))}var M=null,Dt=0;function C(){return M}function O(e){M=e;}function z(e=M){let t={id:++Dt,parent:e,children:null,provides:null,cleanup:null,onMount:null,onUpdate:null,onDestroy:null,isMounted:false,isDestroyed:false};return e&&(e.children||(e.children=[]),e.children.push(t)),t}function L(e,t){let n=M;M=e;try{return t()}finally{M=n;}}function $(e){var n,o,r;if(!e||e.isDestroyed)return;let t=e.parent;if(e.children){for(let s of e.children)$(s);e.children.length=0;}if((n=e.onDestroy)!=null&&n.length&&(Fe(e),e.onDestroy.length=0),(o=e.cleanup)!=null&&o.length){for(let s of e.cleanup)try{s();}catch(i){}e.cleanup.length=0;}if(t!=null&&t.children){let s=t.children.indexOf(e);s!==-1&&t.children.splice(s,1);}(r=e.provides)==null||r.clear(),e.onMount&&(e.onMount.length=0),e.onUpdate&&(e.onUpdate.length=0),e.parent=null,e.isDestroyed=true,M===e&&(M=t);}function H(e){let t=M;t&&(t.cleanup||(t.cleanup=[]),t.cleanup.push(e));}var Ke="_$spread$";var Oe="http://www.w3.org/2000/svg",le="http://www.w3.org/2000/xlink",de="http://www.w3.org/2000/xmlns/";var pe=Symbol(""),me=Symbol(""),X=Symbol(""),ye=Symbol(""),Ve=Symbol("");var $e=1e3,je=new WeakMap;function ze(e){let t=je.get(e);if(!t){let n=e.name||"anonymous",o=Ye(e.toString()).toString(36);t=`${n}_${o}`,je.set(e,t);}return t}function Ye(e){let t=0,n=e.length<100?e.length:100;for(let o=0;o<n;o++)t=Math.trunc((t<<5)-t+e.charCodeAt(o));return t<0?-t:t}var Rt=0;function ge(e){if(!isFalsy(e)){if(isString(e))return e.length<=$e?e:`${e.slice(0,$e-10)}_${Ye(e).toString(36)}`;if(isNumber(e))return String(e);if(isSymbol(e)){let t=Symbol.keyFor(e);if(t)return `_s.${t}`;let n=e.description;return n?`_s.${n}`:`${Rt++}`}return String(e)}}var he=Symbol("essor.key");function Y(e,t){if(y(e)||!e||e.nodeType===Node.DOCUMENT_NODE)return;let n=ge(t);isFalsy(n)?delete e[he]:e[he]=n;}function R(e){if(e)return y(e)?e.key:e[he]}function I(e){if(isHTMLElement(e))return e;if(isPrimitive(e)){let t=isFalsy(e)?"":String(e);return document.createTextNode(t)}return e}function w(e,t){let n=R(e),o=R(t);if(n!==o)return false;let r=y(e),s=y(t);if(r&&s)return e.component===t.component;if(r!==s)return false;if(isPrimitive(e)||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 Se(e,t){if(e===t)return true;if(isNull(e)||isNull(t)||!isObject(e)||!isObject(t)||isArray(e)!==isArray(t))return false;let n=e,o=t,r=Object.keys(n),s=Object.keys(o);if(r.length!==s.length)return false;for(let i of r)if(!(i in o)||n[i]!==o[i])return false;return true}function k(e){if(!e)return;if(y(e)){e.destroy();return}let t=e;t.parentElement&&t.remove();}function P(e,t,n){if(!e||!t)return;if(y(t)){let r=y(n)?n.firstChild:n;t.mount(e,r);return}let o=y(n)?n.firstChild:n;o?e.insertBefore(t,o):e.appendChild(t);}function q(e,t,n){if(!e||!t||!n||t===n)return;let o=y(n)?n.beforeNode:n.nextSibling;k(n),P(e,t,o);}function T(e){if(e){if(y(e))return e.firstChild;if(!isPrimitive(e))return e}}function Je(e,t){if(y(e)||y(t))return;let n=R(e);n&&!R(t)&&Y(t,n);}function F(e,t,n){if(n===t)return t;let o=isHTMLElement(t);if(isHTMLElement(n)&&o){if(n.isEqualNode(t))return t;if(t.tagName===n.tagName){let c=t.attributes,a=n.attributes;for(let u=c.length-1;u>=0;u--){let p=c[u].name;n.hasAttribute(p)||t.removeAttribute(p);}for(let u=0,p=a.length;u<p;u++){let f=a[u];t.getAttribute(f.name)!==f.value&&t.setAttribute(f.name,f.value);}return Je(t,n),t}}if(isTextNode(t)&&isTextNode(n))return t.textContent!==n.textContent&&(t.textContent=n.textContent),Je(t,n),t;let s=y(t),i=y(n);return s&&i&&t.component===n.component?n.update(t):(q(e,n,t),n)}function Qe(e,t,n,o){let r=t.length,s=n.length;if(r===0&&s===0)return [];if(r===0){for(let i=0;i<s;i++)P(e,n[i],o);return n}if(s===0){for(let i=0;i<r;i++)k(t[i]);return []}if(r===1&&s===1){let i=t[0],c=n[0];return w(i,c)?(F(e,i,c),n[0]=i):q(e,c,i),n}if(r===2&&s===2){let i=t[0],c=t[1],a=n[0],u=n[1];if(w(i,a)&&w(c,u))return F(e,i,a),F(e,c,u),n[0]=i,n[1]=c,n;if(w(i,u)&&w(c,a)){F(e,i,u),F(e,c,a);let p=T(c),f=T(i);return p&&f&&p.parentNode===e&&e.insertBefore(p,f),n[0]=c,n[1]=i,n}}return Kt(e,t,n,o)}function Kt(e,t,n,o){let r=0,s=0,i=t.length-1,c=n.length-1,a=t[0],u=t[i],p=n[0],f=n[c];for(;r<=i&&s<=c;)if(!a)a=t[++r];else if(!u)u=t[--i];else if(w(a,p))F(e,a,p),n[s]=a,a=t[++r],p=n[++s];else break;for(;r<=i&&s<=c;)if(!a)a=t[++r];else if(!u)u=t[--i];else if(w(u,f))F(e,u,f),n[c]=u,u=t[--i],f=n[--c];else break;if(r>i){if(s<=c){let l=c+1<n.length?T(n[c+1]):o;for(let m=s;m<=c;m++)P(e,n[m],l);}}else if(s>c)for(let l=r;l<=i;l++){let m=t[l];m&&k(m);}else Ot(e,t,n,r,i,s,c,o);return n}function Ot(e,t,n,o,r,s,i,c){let a=i-s+1,u;for(let S=s;S<=i;S++){let v=R(n[S]);v!==void 0&&(u||(u=Object.create(null)),u[v]=S);}let p=new Int32Array(a),f=false,l=0,m=0;for(let S=o;S<=r;S++){let v=t[S];if(!v)continue;if(m>=a){k(v);continue}let A,b=R(v);if(b!==void 0&&u&&b in u)A=u[b];else for(let d=s;d<=i;d++)if(p[d-s]===0&&b===void 0&&R(n[d])===void 0&&w(v,n[d])){A=d;break}A===void 0?k(v):(p[A-s]=S+1,A>=l?l=A:f=true,F(e,v,n[A]),n[A]=v,m++);}let E=f?Vt(p):[],x=E.length-1,h=c;for(let S=a-1;S>=0;S--){let v=s+S,A=n[v];if(p[S]===0)P(e,A,h),h=T(A)||h;else if(f)if(x<0||S!==E[x]){let b=T(A);b&&b.parentNode===e&&P(e,b,h),h=b||h;}else h=T(A)||h,x--;else h=T(A)||h;}}function Vt(e){let t=e.length;if(t===0)return [];if(t===1)return e[0]!==0?[0]:[];let n=[],o=new Int32Array(t),r,s,i,c,a;for(r=0;r<t;r++){let u=e[r];if(u!==0){if(s=n[n.length-1],n.length===0||e[s]<u){o[r]=s,n.push(r);continue}for(i=0,c=n.length-1;i<c;)a=i+c>>1,e[n[a]]<u?i=a+1:c=a;u<e[n[i]]&&(i>0&&(o[r]=n[i-1]),n[i]=r);}}for(i=n.length,c=n[i-1];i-- >0;)n[i]=c,c=o[c];return n}function D(e,t,n,o){e.addEventListener(t,n,o),H(()=>{e.removeEventListener(t,n,o);});}function Bt(e,t,n,o){isHtmlInputElement(e)?Gt(e,o):isHtmlSelectElement(e)?Wt(e,o):isHtmlTextAreaElement(e)&&D(e,"input",()=>{o(e.value);});}function Gt(e,t){switch(e.type){case "checkbox":D(e,"change",()=>{t(!!e.checked);});break;case "radio":D(e,"change",()=>{t(e.checked?e.value:"");});break;case "file":D(e,"change",()=>{t(e.files);});break;case "number":case "range":D(e,"input",()=>{t(e.value||"");});break;case "date":case "datetime-local":case "month":case "time":case "week":D(e,"change",()=>{t(e.value||"");});break;default:D(e,"input",()=>{t(e.value);});break}}function Wt(e,t){D(e,"change",()=>{if(e.multiple){let n=Array.from(e.options).filter(o=>o.selected).map(o=>o.value);t(n);}else t(e.value);});}function Ee(e,t,n){if(!e)return;let o=[],r=C(),s=effect(()=>{let i=()=>{let c=isFunction(t)?t():t,a=coerceArray(c).map(u=>isFunction(u)?u():u).flatMap(I);o=Qe(e,o,a,n);};r?L(r,i):i();});return H(()=>{s(),o.forEach(i=>k(i)),o.length=0;}),o}function ve(e,t){let n=t.length,o=new Array(n),r=new Set(t),s=1,i=0,c=a=>{if(a.nodeType!==Node.DOCUMENT_FRAGMENT_NODE){if(r.has(s)&&(o[i++]=a,i===n))return true;s++;}let u=a.firstChild;for(;u;){if(c(u))return true;u=u.nextSibling;}return false};return c(e),o}var ot;ot=pe;var Q=class{constructor(t,n={}){this.component=t;this.props=n;this.renderedNodes=[];this.scope=null;this.parentNode=void 0;this.beforeNode=void 0;this.reactiveProps={};this._propSnapshots={};this.state=0;this.parentScope=null;this[ot]=true;this.key=n.key?ge(n.key):ze(t),this.reactiveProps=shallowReactive(V({},n)),this.parentScope=C();for(let o in n){let r=n[o];isObject(r)&&(this._propSnapshots[o]=isArray(r)?[...r]:V({},r));}}get isConnected(){return this.state===2}get firstChild(){for(let t of this.renderedNodes){let n=T(t);if(n)return n}}mount(t,n){var i,c;if(this.parentNode=t,this.beforeNode=n,this.state=1,this.renderedNodes.length>0){for(let a of this.renderedNodes)P(t,a,n);return this.state=2,this.renderedNodes}let o=(i=this.parentScope)!=null?i:C();this.scope=z(o),O(this.scope);let r=this.component(this.reactiveProps);isFunction(r)&&(r=r(this.reactiveProps)),(isSignal(r)||isComputed(r))&&(r=r.value);let s=(c=Ee(t,r,n))!=null?c:[];return this.renderedNodes=s,this.applyProps(this.props),this.state=2,He(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&&(O(this.scope),this.applyProps(this.props),fe(this.scope)),this))}_updateReactiveProps(t){for(let n in t){if(n==="key")continue;let o=t[n],r=this.reactiveProps[n];if(o===r&&!this._propSnapshots[n])continue;if(isObject(o)){let i=this._propSnapshots[n];if(i&&Se(o,i))continue;let c=isArray(o)?[...o]:V({},o);this.reactiveProps[n]=c,this._propSnapshots[n]=c;}else hasChanged(o,r)&&(this.reactiveProps[n]=o,this._propSnapshots[n]&&delete this._propSnapshots[n]);}}unwrapRenderResult(t){return isFunction(t)&&(t=t(this.reactiveProps)),(isSignal(t)||isComputed(t))&&(t=t.value),y(t)&&(t=t.mount(this.parentNode,this.beforeNode)),isPromise(t)&&(t=t.then(n=>this.unwrapRenderResult(n))),t}forceUpdate(){if(this.state===5||!this.parentNode||!this.scope)return;let t=[...this.renderedNodes];try{L(this.scope,()=>{let n=this.component(this.reactiveProps);isFunction(n)&&(n=n(this.reactiveProps)),(isSignal(n)||isComputed(n))&&(n=n.value);let o=coerceArray(n),r=this._getAnchorNode();if(this.parentNode){for(let s of this.renderedNodes)k(s);for(let s of o)P(this.parentNode,s,r);this.renderedNodes=o;}}),this.scope&&fe(this.scope);}catch(n){throw this.renderedNodes=t,n}}_getAnchorNode(){if(this.beforeNode)return this.beforeNode;if(this.renderedNodes.length>0){let t=this.renderedNodes[this.renderedNodes.length-1],n=T(t);if(n)return n.nextSibling}}destroy(){if(this.state===4||this.state===5)return;this.state=4;for(let n of this.renderedNodes)k(n);let t=this.scope;t&&($(t),this.scope=null),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 n=this.firstChild;for(let[o,r]of Object.entries(t))if(startsWith(o,"on")){if(!n||!isHTMLElement(n))return;let s=o.slice("on".length).toLowerCase();D(n,s,r);}else o==="ref"&&isSignal(r)&&(r.value=n);this.props=t;}};function y(e){return !!e&&!!e[pe]}function B(e,t){return y(e)?e:new Q(e,t)}function be(e){let t,n=()=>{let o=document.createElement("template");o.innerHTML=e;let r=o.content.firstChild;if(!r)throw new Error("Invalid template: empty content");return r};return ()=>(t||(t=n())).cloneNode(true)}function on(e,t){let n=isString(t)?document.querySelector(t):t;if(!n){error(`Target element not found: ${t}`);return}n.innerHTML&&(error(`Target element is not empty, it will be delete: ${t}`),n.innerHTML="");let r=y(e)?e:B(e);return r.mount(n),r}function _e(e,t){let n=C();n&&(n.provides||(n.provides=new Map),n.provides.set(e,t));}function Ce(e,t){let n=C();if(!n)return t;let o=n;for(;o;){if(o.provides){let r=o.provides.get(e);if(r)return r}o=o.parent;}return t}function Pe(e,t){Object.defineProperty(e,"target",{configurable:true,value:t});}function at(e,t,n){let o=e[`_$${n}`];if(o&&isFunction(o)&&!e.disabled){let r=e[`${n}Data`];if(r?o.call(e,r,t):o.call(e,t),t.cancelBubble)return false}return e.host&&!isString(e.host)&&!e.host._$host&&isFunction(e.contains)&&e.contains(t.target)&&Pe(t,e.host),true}function st(e,t,n){let o=e;for(;at(o,t,n)&&(o=o._$host||o.parentNode||o.host););return o}function sn(e){let t=e.target,n=`${e.type}`,o=e.target,r=e.currentTarget;if(Object.defineProperty(e,"currentTarget",{configurable:true,get(){return t||document}}),e.composedPath){let s=e.composedPath();Pe(e,s[0]);for(let i=0;i<s.length-2&&(t=s[i],!!at(t,e,n));i++){if(t._$host){t=t._$host,t=st(t,e,n);break}if(t.parentNode===r)break}}else t=st(t,e,n);Pe(e,o);}var ct=Symbol("_$EVENTS");function cn(e,t=window.document){let n=t,o=n[ct]||(n[ct]=new Set);for(let r of e)o.has(r)||(o.add(r),t.addEventListener(r,sn));}function an(e,t){let n=new Set(t);return new Proxy(e,{get(o,r){if(!n.has(r))return Reflect.get(o,r)},ownKeys(o){return Reflect.ownKeys(o).filter(r=>!n.has(r))},getOwnPropertyDescriptor(o,r){if(!n.has(r))return Reflect.getOwnPropertyDescriptor(o,r)},has(o,r){return n.has(r)?false:Reflect.has(o,r)}})}var ke=false;function Z(){ke=true;}function G(){ke=false;}function K(){return ke}var ut=0;function ee(){return `${ut++}`}function te(){ut=0;}var lt=/^\d+-\d+$/;function dt(e){return ()=>{if(!isBrowser())return null;let t=ee(),n=document.querySelector(`[data-hk="${t}"]`);return n||be(e)()}}function pt(e,t){let n=e.dataset.hk;if(!n)return ve(e,t);let o=[],r=e.querySelectorAll(`[data-idx^="${n}"]`);r.length>0&&o.push(...Array.from(r).filter(a=>{let u=a.dataset.idx;return u!==null&<.test(u)}).map(a=>{let u=a.dataset.idx||"",[p,f]=u.split("-");return {hk:p,idx:f,node:a}}));let s=[],i=a=>{if(a.nodeType===Node.COMMENT_NODE&&a.textContent&<.test(a.textContent)){let[p,f]=a.textContent.split("-");s.push({hk:p,idx:f,node:a});}let u=a.firstChild;for(;u;)i(u),u=u.nextSibling;};i(e),o.push(...s);let c=[e];return t.forEach(a=>{let u=o.find(p=>p.idx===String(a));u&&c.push(u.node);}),c}function mt(e,t){Z(),te();try{let n=isString(t)?document.querySelector(t):t;if(!n){error("Hydration error: Root element not found");return}let o=B(e);return o.mount(n),G(),o}catch(n){error("Hydration error:",n),G();return}}function yt(e,t,n,o=false){if(t===n||K())return;let r=ne(n),s=ne(t);r&&s===r||(r?o?e.setAttribute("class",r):e.className=r:e.removeAttribute("class"));}function ne(e){return normalizeClassName(e)}var ht=/\s*!important$/,yn=["Webkit","Moz","ms"],Te={};function Nt(e,t,n){let o=e.style,r=isString(n);if(!K()){if(n&&r){t!==n&&(o.cssText=n);return}if(!n){t&&e.removeAttribute("style");return}if(t&&!isString(t))for(let s in t)(!n||n[s]==null)&&U(o,s,"");else if(t&&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();n&&isObject(n)&&n[a]==null&&U(o,a,"");}}}if(n&&!isString(n))for(let s in n){let i=n[s];(!t||isString(t)||t[s]!==i)&&i!=null&&U(o,s,i);}}}function U(e,t,n){if(isArray(n)){for(let r of n)U(e,t,r);return}if((n==null||n==="")&&(n=""),t.startsWith("--")){e.setProperty(t,n);return}let o=hn(e,t);isString(n)&&ht.test(n)?e.setProperty(camelCase(o),n.replace(ht,""),"important"):e[o]=n;}function hn(e,t){let n=Te[t];if(n)return n;let o=camelCase(t);if(o!=="filter"&&o in e)return Te[t]=o;o=capitalize(o);for(let r of yn){let s=r+o;if(s in e)return Te[t]=s}return t}function De(e,t,n,o){if(t==="key"){o==null?Y(e,void 0):Y(e,String(o));return}if(t===Ke){Object.keys(o).forEach(f=>{De(e,f,n==null?void 0:n[f],o==null?void 0:o[f]);});return}if(K())return;let r=(e==null?void 0:e.namespaceURI)===Oe,s=r&&t.startsWith("xlink:"),i=r&&t.startsWith("xmlns:"),c=isSpecialBooleanAttr(t)||isBooleanAttr(t);if(n===o)return;let a=t.toLowerCase();if(a.length>2&&a.charCodeAt(0)===111&&a.charCodeAt(1)===110||a==="innerhtml")return;if(o==null){if(s)e.removeAttributeNS(le,t.slice(6));else if(i){let f=t.slice(6);e.removeAttributeNS(de,f);}else e.removeAttribute(t);return}if(s){e.setAttributeNS(le,t,String(o));return}if(i){e.setAttributeNS(de,t,String(o));return}if(c){includeBooleanAttr(o)?e.setAttribute(t,""):e.removeAttribute(t);return}let u=isSymbol(o)?String(o):o;if((a==="href"||a==="src"||a==="xlink:href")&&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 St(e,t,n,o){if(!(o!=null&&o.delegate))return e.addEventListener(t,n,o),()=>e.removeEventListener(t,n,o);let r=o.delegate,s=c=>{let a=c.target;(a.matches(r)||a.closest(r))&&n.call(e,c);},i=V({},o);return i.delegate=void 0,e.addEventListener(t,s,i),()=>{e.removeEventListener(t,s,i);}}function Et(e){if(!(e!=null&&e.children))return error("Fragment component requires children"),null;let{children:t}=e;return t}Et[me]=true;function bn(e){return !!e&&!!e[me]}function xt(e){let t=document.createComment("portal");t[X]=true;let n=e.children;if(n){let o=isArray(n)?n:[n],r=[];ae(()=>{let s=isString(e.target)?document.querySelector(e.target):e.target;s&&(o.forEach(i=>{if(i!=null){let c=I(i);c&&(P(s,c),r.push(c));}}),H(()=>{r.forEach(i=>{!isString(i)&&i.parentNode===s&&s.removeChild(i);});}));});}return t}xt[X]=true;function Cn(e){return !!e&&!!e[X]}var Le=Symbol("SuspenseContext");function At(e){if(isUndefined(document)){let f=e.fallback;return f?String(f||""):""}let t=document.createElement("div");t.style.display="contents";let n=true,o=0,r=false,s=null,i=()=>{if(!r){for(r=true;t.firstChild;)t.removeChild(t.firstChild);if(e.fallback!=null){let f=I(e.fallback);f&&P(t,f);}}},c=()=>{if(!(!r||!(s||e.children!=null&&!isPromise(e.children)))){for(r=false;t.firstChild;)t.removeChild(t.firstChild);s?a(s):e.children!=null&&!isPromise(e.children)&&a(e.children);}},a=f=>{for(;t.firstChild;)t.removeChild(t.firstChild);if(f==null)return;let l=C();if((isArray(f)?f:[f]).forEach(E=>{if(E!=null){y(E)&&(E.parentContext=l);let x=I(E);x&&P(t,x);}}),r){for(;t.firstChild;)t.removeChild(t.firstChild);if(e.fallback!=null){let E=I(e.fallback);E&&P(t,E);}}},u={register:f=>{o++,i(),f.then(()=>{n&&(o--,o===0&&c());}).catch(l=>{n&&(o--,o===0&&c());});},increment:()=>{o++,i();},decrement:()=>{o--,o===0&&c();}};_e(Le,u);let p=e.children;return isPromise(p)?(p.then(f=>{s=f;}).catch(()=>{}),u.register(p)):p!=null?a(p):i(),ue(()=>{for(n=false;t.firstChild;)t.removeChild(t.firstChild);}),t}At[ye]=true;function Tn(e){return !!e&&!!e[ye]}function Dn(e,t){let n=signal(t==null?void 0:t.initialValue),o=signal(true),r=signal(null),s=signal("pending"),i=0,c=null,a=()=>ie(null,null,function*(){let f=++i;o.value=true,s.value="pending",r.value=null;try{let l=e();c=l.then(()=>{}).catch(()=>{});let m=yield l;f===i&&(n.value=m,s.value="ready",o.value=!1);}catch(l){f===i&&(r.value=l instanceof Error?l:new Error(String(l)),s.value="errored",o.value=false);}});a();let u=(()=>{if(o.value&&c){let f=Ce(Le,null);f&&f.register(c);}return n.value});return u.loading=o,u.error=r,u.state=s,[u,{mutate:f=>{n.value=f,s.value="ready",o.value=false,r.value=null;},refetch:()=>ie(null,null,function*(){yield a();})}]}function bt(e){let t=document.createDocumentFragment(),n=document.createComment("");t.appendChild(n);let o=[],r=null,s=e.keyFn,i=e.children,c=()=>{var m,E;let l=e.each;return isSignal(l)?(m=l.value)!=null?m:[]:typeof l=="function"?(E=l())!=null?E:[]:l!=null?l:[]},a=l=>s?s(l):l,u=(l,m,E,x)=>{var A;let h=C(),S=z(h);O(S);let v;try{let b=i(l,m);y(b)?(b.mount(E,x),v=(A=b.firstChild)!=null?A:document.createComment("empty")):(v=b,v.parentNode||(x?E.insertBefore(v,x):E.appendChild(v)));}finally{O(h);}return {key:a(l),node:v,scope:S}},p=l=>{$(l.scope),l.node.parentNode&&l.node.parentNode.removeChild(l.node);};memoEffect(({prev:l})=>{var x;let m=c();if(l===m)return {prev:m};let E=n.parentNode;if(!E){if(m.length===0){if(e.fallback){let h=e.fallback();y(h)?(h.mount(t,n),r=(x=h.firstChild)!=null?x:document.createComment("empty")):(r=h,t.insertBefore(r,n));}return {prev:m}}o=new Array(m.length);for(let[h,S]of m.entries())o[h]=u(S,h,t,n);return {prev:m}}return untrack(()=>f(E,m)),{prev:m}},{prev:[]});function f(l,m){var b;let E=o.length,x=m.length;if(x===0){for(let d=0;d<E;d++)p(o[d]);if(o=[],e.fallback&&!r){let d=e.fallback();y(d)?(d.mount(l,n),r=(b=d.firstChild)!=null?b:document.createComment("empty")):(r=d,l.insertBefore(r,n));}return}if(E===0||r){r&&(r.parentNode&&r.parentNode.removeChild(r),r=null),o=new Array(x);let d=document.createDocumentFragment();for(let _=0;_<x;_++)o[_]=u(m[_],_,d,null);l.insertBefore(d,n);return}let h=new Map;for(let d=0;d<E;d++){let _=o[d],W=h.get(_.key);W?W.push(_):h.set(_.key,[_]);}let S=new Array(x),v=[],A=document.createDocumentFragment();for(let d=0;d<x;d++){let _=m[d],W=a(_),re=h.get(W);re&&re.length>0?S[d]=re.shift():S[d]=u(_,d,A,null);}for(let d of h.values())for(let _ of d)v.push(_);for(let d of v)p(d);for(let d=0;d<x;d++){let _=S[d].node;l.insertBefore(_,n);}o=S;}return H(()=>{for(let l of o)p(l);r&&r.parentNode&&r.parentNode.removeChild(r),n.parentNode&&n.parentNode.removeChild(n);}),t}bt[Ve]=true;
|
|
2
|
+
export{Q as Component,bt as For,Et as Fragment,xt as Portal,At as Suspense,St as addEvent,D as addEventListener,Bt as bindElement,on as createApp,B as createComponent,Dn as createResource,z as createScope,cn as delegateEvents,$ as disposeScope,G as endHydration,C as getActiveScope,T as getFirstDOMNode,ee as getHydrationKey,dt as getRenderedElement,mt as hydrate,Ce as inject,Ee as insert,P as insertNode,y as isComponent,bn as isFragment,K as isHydrating,Cn as isPortal,w as isSameNode,Tn as isSuspense,ve as mapNodes,pt as mapSSRNodes,ne as normalizeClass,I as normalizeNode,an as omitProps,H as onCleanup,ue as onDestroy,ae as onMount,Tt as onUpdate,De as patchAttr,yt as patchClass,Nt as patchStyle,_e as provide,k as removeNode,q as replaceNode,te as resetHydrationKey,L as runWithScope,O as setActiveScope,U as setStyle,Se as shallowCompare,Z as startHydration,be as template};//# sourceMappingURL=template.esm.js.map
|
|
3
3
|
//# sourceMappingURL=template.esm.js.map
|