solarite 0.7.0 → 0.8.0
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/Solarite-debug.js +5193 -4114
- package/dist/Solarite.js +4951 -3878
- package/dist/Solarite.min.js +2 -2
- package/dist/jsx-dev-runtime.js +3 -0
- package/dist/jsx-runtime.js +86 -0
- package/package.json +11 -10
- package/readme.md +8 -8
- package/src/MappedList.js +34 -0
- package/src/MultiValueMap.js +4 -4
- package/src/NodeGroup.js +205 -119
- package/src/Path.js +52 -53
- package/src/PathToAttribValue.js +182 -101
- package/src/PathToAttribs.js +10 -18
- package/src/PathToComponent.js +43 -19
- package/src/PathToEvent.js +18 -12
- package/src/PathToKey.js +0 -6
- package/src/PathToNodes.js +695 -155
- package/src/RootNodeGroup.js +23 -30
- package/src/Selector.js +207 -0
- package/src/Shell.js +276 -117
- package/src/Solarite.d.ts +89 -13
- package/src/Solarite.js +38 -25
- package/src/Template.js +20 -7
- package/src/Util.js +75 -60
- package/src/assert.js +1 -1
- package/src/assignAttributes.js +20 -19
- package/src/h.js +64 -37
- package/src/jsx.js +4 -7
- package/src/toEl.js +1 -1
- package/src/HtmlParser.js +0 -91
- package/src/PathToComment.js +0 -8
package/dist/Solarite.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
// Solarite v0.
|
|
2
|
-
var t;!function e(){t={connected:new WeakSet,t:null,div:document.createElement("div"),i:document,l:{},o:{},h:new WeakMap,u:new WeakMap,p:new WeakSet,m:new WeakMap,reset:e}}();var e=t;function i(t,e,i=l){let s=i!==l,n=e.length;if(!t&&!s&&n)return;let r=0;for(let l of e){if(void 0===t[l]){if(!s)return;n-1>r&&(t[l]=(e[r+1]+"").match(/^\d+$/)?[]:{})}s&&r===n-1&&(t[l]=i),t=t[l],r++}return t}function s(t){return Array.isArray(t)&&t.length>=2&&("object"==typeof t[0]||void 0===t[0])&&!t.slice(1).find((t=>"string"!=typeof t&&"number"!=typeof t))}let l={},n={v(t,e){let i=t.length;if(i!==e.length)return!1;for(let s=0;i>s;s++)if(t[s]!==e[s])return!1;return!0},S(t,e=null){let i={};for(let s of t.attributes)s.name!==e&&(i[n.k(s.name)]=s.value);return i},$(t,e){let s=e.getAttribute("data-id")||e.getAttribute("id");if(s){if(!s.includes(".")){let i=t[s],l=s in t&&!Object.hasOwn(t,s);if(!i?.nodeType&&(null!=i||l))throw Error(`${t.constructor.name}.${s} can't be a reference to <${e.tagName.toLowerCase()} id="${s}"> because it would clobber an existing `+(l?"built-in ":"")+"property. Rename the id or the property.")}i(t,s.split(/\./g),e)}},A(t,i){let s,l,n=i.tagName.toLowerCase();if(t.hasAttribute("global")||t.hasAttribute("data-global")){s=n,l="";let r=e.i||i.ownerDocument||document;r.head.querySelector(`style[data-style="${s}"]`)?t.remove():(r.head.append(t),t.setAttribute("data-style",s))}else{let t=i.getAttribute("data-style");t||(i.constructor.T||(i.constructor.T=1),t=i.constructor.T++,i.setAttribute("data-style",t)),l=`[data-style="${t}"]`}for(let e of t.childNodes)if(3===e.nodeType){let t=e.textContent,i=t.replace(/:host(?=[^a-z0-9_])/gi,`${n}${l}`);t!==i&&(e.textContent=i)}},N:t=>(t=(t=(t=t.replace(/([a-z0-9])([A-Z])/g,"$1-$2")).replace(/([A-Z])([A-Z][a-z])/g,"$1-$2")).replace(/([a-zA-Z])([0-9])/g,"$1-$2")).toLowerCase(),k:t=>t.replace(/-([a-z])/g,(t=>t[1].toUpperCase())),C(t,e){customElements[o](t)||((e=e||n.N(t.name)).includes("-")||(e+="-element"),customElements[r](e,t))},O:t=>"checkbox"===t.type?t.checked:"radio"===t.type?t.value:"file"===t.type?[...t.files]:"number"===t.type||"range"===t.type?t.valueAsNumber:"date"===t.type||"time"===t.type||"datetime-local"===t.type?t.valueAsDate:"select-multiple"===t.type?[...t.selectedOptions].map((t=>t.value)):t.hasAttribute("contenteditable")?t.innerHTML:t.value,L:t=>t.startsWith("on")&&t in e.div,j(t,i){let s=t.tagName+"."+i,l=e.o[s];if(void 0===l){let n=Object.getPrototypeOf(t);for(;n;){const t=n.constructor.name;if(t.startsWith("HTML")&&t.endsWith("Element"))break;n=Object.getPrototypeOf(n)}e.o[s]=l=!!n&&!!Object.getOwnPropertyDescriptor(n,i)?.set}return l},P:t=>void 0===t||!1===t||null===t,R(t){let e={},i=(t+"").split(/([\w-]+\s*=\s*(?:"[^"]*"|'[^']*'|\S+))/g).map((t=>t.trim())).filter((t=>t.length));for(let t of i){let[i,s]=t.split(/\s*=\s*/);s=(s||"").replace(/^(['"])(.*)\1$/,"$2"),e[i]=s}return e},M:t=>"function"==typeof t?n.M(t()):t instanceof Date?t.toISOString().replace(/T/," "):Array.isArray(t)||"object"==typeof t?"":t,D(t){e.i.createDocumentFragment().append(...t)},H(t){const e=t=>t.nodeType!==Node.ELEMENT_NODE&&(t.nodeType!==Node.TEXT_NODE||""===t.textContent.trim()),i=[...t];for(;i.length>0&&e(i[0]);)i.shift();for(;i.length>0&&e(i[i.length-1]);)i.pop();return i}},r="define",o="getName";class f{F;G;I=!1;W;J;constructor(t,e){this.F=t,this.G=e}apply(t){}V(t){}_(){return 1}B(t,e){let i=t,s=this.K,l=s.length-e;for(let t=l-1;t>0;t--)i=i.childNodes[s[t]];return l?i.childNodes[s[0]]:t}Z(t,e){let i=new this.constructor(t,e,this.attrName,this.U);return i.q=this.q,i.I=this.I,i.Y=this.Y,i}clone(t,e=0){let i,s,l=t,n=this.K,r=n.length-e;for(let t=r-1;t>0;t--)l=l.childNodes[n[t]];let o=l.childNodes;i=r?o[n[0]]:t,this.F&&(s=o[this.X]);let f=new this.constructor(s,i,this.attrName,this.U);return f.q=this.q,f.I=this.I,f.Y=this.Y,f}static get(t){let e=[];for(;;){let i=t.parentNode;if(!i)break;e.push([].indexOf.call(t.parentNode.childNodes,t)),t=i}return e}static resolve(t,e){for(let i=e.length-1;i>=0;i--)t=t.childNodes[e[i]];return t}}class h{constructor(){this.tt={context:h.Text,quote:null,buffer:"",et:null},this.state={...this.tt}}reset(){return this.state={...this.tt},this.state.context}parse(t,e=null){if(null===t)return this.reset();for(let i=0;t.length>i;i++){const s=t[i];switch(this.state.context){case h.Text:"<"===s&&t[i+1].match(/[/a-z!]/i)&&(e?.(t,i,this.state.context,h.it),this.state.context=h.it,this.state.buffer="");break;case h.it:if(">"===s)e?.(t,i+1,this.state.context,h.Text),this.state.context=h.Text,this.state.quote=null,this.state.buffer="";else{if(" "===s&&!this.state.buffer)continue;" "===s||"/"===s||"?"===s?this.state.buffer="":'"'===s||"'"===s||"="===s?(e?.(t,i,this.state.context,h.st),this.state.context=h.st,this.state.quote="="===s?null:s,this.state.buffer=""):this.state.buffer+=s}break;case h.st:this.state.quote||this.state.buffer.length||'"'!==s&&"'"!==s?s===this.state.quote||!this.state.quote&&this.state.buffer.length?(e?.(t,i,this.state.context,h.it),this.state.context=h.it,this.state.quote=null,this.state.buffer=""):this.state.quote||">"!==s?" "!==s&&(this.state.buffer+=s):(e?.(t,i+1,this.state.context,h.Text),this.state.context=h.Text,this.state.quote=null,this.state.buffer=""):this.state.quote=s}}return e?.(t,t.length,this.state.context,null),this.state.context}}h.st="Attribute",h.Text="Text",h.it="Tag";class u extends f{attrName;U;lt;Y;constructor(t,e,i=null,s=null){super(null,e),this.attrName=i,this.U=s}apply(t){if(this.U){let e=this.G,i=this.nt(t),s=this.Y;(s?e[this.attrName]:e.getAttribute(this.attrName))!==i&&(s?e[this.attrName]=i:"value"===this.attrName&&e.hasAttribute("contenteditable")&&(e.innerHTML=i),e.setAttribute(this.attrName,i))}else this.V(t[0])}V(t){if(this.U)return this.apply([t]);let e=this.G;if(s(t)){if(this.q&&e.tagName.endsWith("-SOLARITE-PLACEHOLDER"))return;let[s,l]=[t[0],t.slice(1)];if(!s)throw Error(`Solarite cannot bind to <${e.tagName.toLowerCase()} ${this.attrName}=\${[${t.map((t=>t?`'${t}'`:t+"")).join(", ")}]}>.`);let r=i(s,l);if("value"===this.attrName&&"select-multiple"===e.type&&Array.isArray(r)){let t=r.map((t=>t+""));for(let i of e.options)i.selected=t.includes(i.value)}else if("radio"===e.type)e.checked=e.value===r+"";else{const t=n.P(r)?"":r;"value"===this.attrName&&e.hasAttribute("contenteditable")?t!==e.innerHTML&&(e.innerHTML=t):t!==e[this.attrName]&&(e[this.attrName]=t)}let o=()=>{let t="value"===this.attrName||"radio"===e.type?n.O(e):e[this.attrName];i(s,l,t)};this.rt(e,this.W.getRootNode(),this.attrName,"input",o,null,!0)}else{let i=this.Y;if("function"==typeof t){if(this.q)return;t=t()}else t=n.M(t);void 0===t||!1===t||null===t?(i&&(e[this.attrName]=!1),e.removeAttribute(this.attrName)):!0===t?(i&&(e[this.attrName]=!0),e.setAttribute(this.attrName,"")):(i?e[this.attrName]:e.getAttribute(this.attrName)??"")!==t&&(i?e[this.attrName]=t:"value"===this.attrName&&e.hasAttribute("contenteditable")&&(e.innerHTML=t),e.setAttribute(this.attrName,t))}}_(){return this.U?this.U.length-1:1}nt(t){if(!this.U)return t[0];let e=[],i=this.U;for(let s=0;i.length>s;s++)if(e.push(i[s]),i.length-1>s){let i=n.M(t[s]);n.P(i)||e.push(i)}return e.join("")}rt(t,e,i,s,l,n,r=!1){if("function"!=typeof l)throw Error(`Solarite cannot bind to <${t.tagName.toLowerCase()} ${this.attrName}=\${${l}}> because it's not a function.`);let o,f=this.W.ot.options,h=n||[l],u=t[a];if(void 0!==u){if(u instanceof g){if(u.key!==i){let l=t[a]={};return l[u.key]=u,o=l[i]=new g(e,t,i,h),void d(o,t,s,r,f,e)}o=u}else if(o=u[i],!o)return o=u[i]=new g(e,t,i,h),void d(o,t,s,r,f,e);o.root=e,o.ft=h}else d(t[a]=new g(e,t,i,h),t,s,r,f,e)}}const a=Symbol("solariteEvents");function c(t,e){let i=t[a];if(void 0!==i)return i instanceof g?i.key===e?i:void 0:i[e]}function d(t,e,i,s,l,n){let r=!1;if(!1===s){let t=l?.eventDelegation??!0;!1!==t&&p.has(i)&&(r=!0===t||t.includes(i))}if(r){t.ht=!0;let e=n[y];void 0===e&&(e=n[y]=new Set),e.has(i)||(e.add(i),n.addEventListener(i,b))}else e.addEventListener(i,t,s)}const p=new Set(["beforeinput","click","contextmenu","dblclick","focusin","focusout","input","keydown","keyup","mousedown","mousemove","mouseout","mouseover","mouseup","pointerdown","pointermove","pointerout","pointerover","pointerup","touchend","touchmove","touchstart"]),y=Symbol("solariteDelegatedTypes"),m=Symbol("solariteDelegated");function b(t){if(t[m])return;t[m]=!0;let e=t.type,i=t.target;for(Object.defineProperty(t,"currentTarget",{configurable:!0,get:()=>i});i;){let s=i[a];if(void 0!==s){let i=s instanceof g?s:s[e];if(void 0!==i&&!0===i.ht&&i.key===e&&(i.handleEvent(t),t.cancelBubble))break}i=i.parentNode}delete t.currentTarget}class g{constructor(t,e,i,s){this.root=t,this.node=e,this.key=i,this.ft=s}handleEvent(t){let e=this.ft;switch(e.length){case 1:return e[0].call(this.root,t,this.node);case 2:return e[0].call(this.root,e[1],t,this.node);case 3:return e[0].call(this.root,e[1],e[2],t,this.node)}return e[0].call(this.root,...e.slice(1),t,this.node)}}class v extends u{ut;constructor(t,e,i=null,s=null){super(null,e,i,s),this.ut=i?i.slice(2):null}apply(t){this.U?.length>1?super.apply(t):this.V(t[0])}V(t){if(this.U?.length>1)return super.apply([t]);if(this.q&&this.G.tagName.endsWith("-SOLARITE-PLACEHOLDER"))return;let e,i=this.W.ot.root,s=this.G,l=this.ut;if(Array.isArray(t)&&"function"==typeof t[0])e=t[0];else{if("function"!=typeof t)throw Error(`Invalid event binding: <${s.tagName.toLowerCase()} ${this.attrName}=\${${JSON.stringify(t)}}>`);e=t,t=null}this.rt(s,i,l,l,e,t)}}const w=Symbol("Fragment");class E{constructor(t,e){this.name=t,this.value=e}}const S=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),k=new Map;function $(t){if(null===t||"object"!=typeof t)return t;let e="";for(let i in t){let s=t[i];null!=s&&!1!==s&&(e+=(e?";":"")+n.N(i)+":"+s)}return e}function x(t){return(""+t).replace(/&/g,"&").replace(/"/g,""")}function A(t,e,i=[],s){if(e=e||{},t===w){let t=[""];for(let e=0;i.length>e;e++)t.push("");return new Q(t,i)}if("function"==typeof t){if(t.prototype instanceof HTMLElement){n.C(t);let l=customElements.ct?customElements.ct(t):n.N(t.name);return l&&!l.includes("-")&&(l+="-element"),T(l,e,i,s)}let l={};for(let t in e)"key"!==t&&(l[t]="style"===t?$(e[t]):e[t]);!("children"in l)&&i.length&&(l.children=1===i.length?i[0]:i);let r=t(l);return void 0===s&&(s=e.key),void 0!==s&&r instanceof Q&&(r.key=s),r}return T(t,e,i,s)}function T(t,e,i,s){let l=S.has(t.toLowerCase()),n=[],r=[],o="";for(let t in e){if("children"===t)continue;if("key"===t){void 0===s&&(s=e[t]);continue}let i=e[t];"id"!==t&&"data-id"!==t||"string"!=typeof i?("style"===t&&(i=$(i)),n.push(t),r.push(i)):o+=` ${t}="${x(i)}"`}let f=l?0:i.length,h=t+o+"\0"+n.join("\0")+"\0#"+f,u=k.get(h);u||(u=((t,e,i,s,l)=>{let n=[],r="<"+t+e;for(let t of i)n.push(r+" "+t+"="),r="";if(r+=">",l)return n.push(r),n;if(0===s)n.push(r+"</"+t+">");else{n.push(r);for(let t=1;s>t;t++)n.push("");n.push("</"+t+">")}return n})(t,o,n,f,l),k.set(h,u));let a=l?r:r.concat(i),c=new Q(u,a);return void 0!==s&&(c.key=s),c}class N extends f{dt;lt;constructor(t,e){super(null,null),this.G=e,this.dt=new Set}apply(t){this.V(t[0])}V(t){let e=this.G;if(t instanceof E)return this.yt(t);Array.isArray(t)&&(t=t.flat().join(" "));let i=this.dt;if(this.dt=new Set,t)if("function"==typeof t&&(t=t()),"object"==typeof t)for(let i in t){let s=t[i];void 0!==s&&!1!==s&&null!==s&&(e.setAttribute(i,s),this.dt.add(i))}else{let i=n.R(t);for(let t in i)e.setAttribute(t,i[t]),this.dt.add(t)}for(let t of i)this.dt.has(t)||e.removeAttribute(t)}yt(t){let e=t.name;if("key"===e)return;let i=t.value,s=this.bt;if(void 0===s||this.gt!==e){let t=this.G;n.L(e)?s=new v(null,t,e,null):(s=new u(null,t,e,null),s.Y=n.j(t,e)),s.q=this.q,this.bt=s,this.gt=e}s.G=this.G,s.W=this.W,"style"===e&&(i=$(i)),s.V(i)}_(){return 1}nt(t){return t[0]}}class C{data={};add(t,e){let i=this.data,s=i[t];s?s.push(e):i[t]=[e]}vt(t,e,i){let s=this.data,l=s[t];l?i>l.length-(l.head||0)&&l.push(e):s[t]=[e]}wt(t){let e=this.data,i=e[t];if(!i)return;let s=i.head||0,l=i[s];return s++,i.length>s?i.head=s:delete e[t],l}}class O extends f{Et=null;St=null;kt=null;$t=null;xt=null;At=null;constructor(t,e){super(t,e)}apply(t){this.V(t[0])}V(t){let i=typeof t;if(("string"===i||"number"===i)&&!this.Tt){"string"!==i&&(t+="");let s=this.St;if(null!==s)return void(this.kt!==t&&(s.nodeValue=t,this.kt=t));let l=this.Et;if(null===l||0===l.length){let i;if(this.I){let e=this.G.firstChild;if(null!==e&&3===e.nodeType&&e===this.G.lastChild)return e.nodeValue!==t&&(e.nodeValue=t),this.St=e,void(this.kt=t);this.G.textContent=t,i=this.G.firstChild}else i=e.i.createTextNode(t),this.G.parentNode.insertBefore(i,this.G);return this.St=i,this.kt=t,void(this.W.Nt||(this.J=null,this.W.Ct&&this.W.Ct.Ot()))}if(1===l.length){let e=l[0],i=e.Lt;if(!0===i.jt)return void(i.html[0]!==t&&(e.Pt.nodeValue=t,i.html[0]=t,e.Rt=t))}}if(null!==this.St){let t=new Z(P(this.kt),this,this.St);(this.Et??=[]).push(t),this.St=null}let s=[],l=this.Mt(t,s,!1);if(l||this.Tt)this.Tt=l,this.Dt(s);else{let t=0!==s.length?s[0]:null;(null!==t?"string"==typeof t||void 0===t.key&&0>I.get(t.html,t.Ft).Ht:null===this.Et||0===this.Et.length||void 0===this.Et[0].key)?this.Gt(s):this.It(s)}}Gt(t){let i=this.Et||L,s=i.length,l=t.length,r=Array(l),o=0,f=s,h=l;for(;f>o&&h>o;){let e=i[o],s=t[o];if(!R(e,s))break;e.zt&&e.Wt(s.exprs,!1),r[o]=e,o++}for(;f>o&&h>o;){let e=i[f-1],s=t[h-1];if(!R(e,s))break;e.zt&&e.Wt(s.exprs,!1),r[--h]=e,f--}for(;f>o&&h>o;){let e=i[o],s=t[o];if(R(e,s))e.zt&&e.Wt(s.exprs,!1);else{if(!M(e,s))break;this.Jt(e,s)}r[o]=e,o++}let u=f-o,a=h-o;if(u||a){if(u){for(let t=o;f>t;t++){let e=i[t];e.Pt!==e.Vt&&e._t()}let t=0===l&&0===o&&this.Bt(),e=this.At??=new C;for(let s=o;f>s;s++){let l=i[s];l.Pt!==l.Vt?n.D(l._t()):t||l.Pt.remove(),l.Lt.jt||e.vt(l.Rt,l,j)}}if(a){let i=this.I,s=l>h?r[h].Pt:i?null:this.G,n=i?this.G:this.G.parentNode,f=n,u=s,c=null;a>1&&(c=e.i.createDocumentFragment(),f=c,u=null);for(let e=o;h>e;e++){let i=this.Kt(t[e]);r[e]=i;let s=i.Pt,l=i.Vt;if(s===l)f.insertBefore(s,u);else for(;;){let t=s.nextSibling;if(f.insertBefore(s,u),s===l)break;s=t}}c&&n.insertBefore(c,s)}this.W.Nt||(this.J=null,this.W.Ct&&this.W.Ct.Ot())}this.Et=r,this.$t&&(this.$t=null),this.xt&&(this.xt=null)}It(t){let i=this.Et||L,s=i.length,l=t.length,r=Array(l),o=null,f=-1;const h=t=>void 0!==t.key?t.key:(t.html!==o&&(o=t.html,f=I.get(t.html,t.Ft).Ht),0>f?void 0:t.exprs[f]);let u=0,a=s,c=l;for(;a>u&&c>u;){let e=i[u],s=t[u];if(e.Lt===s)e.zt&&e.Wt(s.exprs,!1);else{if("string"==typeof s||e.key!==h(s)||!M(e,s))break;R(e,s)?e.zt&&e.Wt(s.exprs,!1):this.Jt(e,s)}r[u]=e,u++}for(;a>u&&c>u;){let e=i[a-1],s=t[c-1];if(e.Lt===s)e.zt&&e.Wt(s.exprs,!1);else{if("string"==typeof s||e.key!==h(s)||!M(e,s))break;R(e,s)?e.zt&&e.Wt(s.exprs,!1):this.Jt(e,s)}r[--c]=e,a--}let d=a-u,p=c-u;if(d||p){let s=this.I,o=s?this.G:this.G.parentNode,f=0,y=!1,m=null,b=null;if(d)if(p){let e=new Map;for(let i=u;c>i;i++){let s=t[i];"string"!=typeof s&&e.set(h(s),i)}m=Array(p).fill(-1);let s=-1;for(let l=u;a>l;l++){let n,o=i[l],h=void 0===o.key?void 0:e.get(o.key);void 0!==h&&-1===m[h-u]&&M(o,n=t[h])?(m[h-u]=l,f++,s>h?y=!0:s=h,R(o,n)?o.zt&&o.Wt(n.exprs,!1):this.Jt(o,n),r[h]=o):(b??=[]).push(o)}}else b=i.slice(u,a);if(b){for(let t of b)t.Pt!==t.Vt&&t._t();if(0!==u||c!==l||0!==f||!this.Bt())for(let t of b)t.Pt!==t.Vt?n.D(t._t()):t.Pt.remove()}if(p){let i=l>c?r[c].Pt:s?null:this.G;if(0===f){let s=o,l=i,n=null;p>1&&(n=e.i.createDocumentFragment(),s=n,l=null);for(let e=u;c>e;e++){let i=this.Zt(t[e]);r[e]=i;let n=i.Pt,o=i.Vt;if(n===o)s.insertBefore(n,l);else for(;;){let t=n.nextSibling;if(s.insertBefore(n,l),n===o)break;n=t}}n&&o.insertBefore(n,i)}else{let e=y?(t=>{let e=[],i=Array(t.length);for(let s=0;t.length>s;s++){let l=t[s];if(-1===l)continue;let n=0,r=e.length;for(;r>n;){let i=n+r>>1;l>t[e[i]]?n=i+1:r=i}n>0&&(i[s]=e[n-1]),n===e.length?e.push(s):e[n]=s}let s=e.length;if(s){let t=e[s-1];for(;s-- >0;)e[s]=t,t=i[t]}return e})(m):null,s=null!==e?e.length-1:-1;for(let l=c-1;l>=u;l--){let n=r[l];void 0===n?(n=this.Zt(t[l]),r[l]=n,D(o,n,i)):null!==e&&(0>s||e[s]!==l-u?D(o,n,i):s--),i=n.Pt}}}this.W.Nt||(this.J=null,this.W.Ct&&this.W.Ct.Ot())}this.Et=r,this.$t&&(this.$t=null),this.xt&&(this.xt=null)}Zt(t){if("string"==typeof t)return new Z(P(t),this);let e=new Z(t,this);return(t.exprs.length||e.Ut&&e.Ut.length)&&e.Wt(t.exprs),e}Jt(t,e){if("string"==typeof e)t.Pt.nodeValue=e,t.Lt.html[0]=e,t.Rt=e;else{if(t.qt){if(null!==t.Ut||!t.Yt(e)){let i=t.Lt.exprs,s=e.exprs,l=t.Ut??t.Xt();for(let t=l.length-1;t>=0;t--)et(i[t],s[t])||l[t].V(s[t])}t.styles&&t.Qt(),t.J=null,t.Nt=!1}else t.Wt(e.exprs);t.Lt=e,void 0!==e.key&&(t.key=e.key)}}Kt(t){let e;if("string"==typeof t)return t=P(t),new Z(t,this);let i=this.At;return i&&(e=i.wt(t.te()),e)?(this.Jt(e,t),e):(e=new Z(t,this),(t.exprs.length||e.Ut&&e.Ut.length)&&e.Wt(t.exprs),e)}Mt(t,e,i){if(t instanceof Q)e.push(t);else if(Array.isArray(t))for(let s of t)s instanceof Q?e.push(s):i=this.Mt(s,e,i);else if("function"==typeof t)i=this.Mt(t(),e,i);else if(t instanceof NodeList){for(let i of t)e.push(i);i=i||t.length>0}else if(t?.nodeType){if(11===t.nodeType)for(let i of[...t.childNodes])e.push(i);else e.push(t);i=!0}else void 0===t||!1===t||null===t?t="":"string"!=typeof t&&(t+=""),e.push(t);return i}Dt(t){let e=this;e.ee();let i=[],s=e.Et||L;e.Et=[];for(let s of t)if("string"==typeof s&&(s=P(s)),s instanceof Q){let t=e.ie(s);i.push(...t._t()),e.Et.push(t)}else i.push(s);let l=e._t();if(!n.v(l,i)){e.J=i,this.W.Ct&&this.W.Ct.Ot(),l.length&&!i.length&&e.Bt()||(e.I?H(e.G,l,i,null):H(e.G.parentNode,l,i,e.G));for(let t of s)t.Pt.parentNode||n.D(t._t())}}Ot(){let t=this,e=this.I?this.G:this.G.parentNode;for(;t&&(t.I?t.G:t.G.parentNode)===e;)t.J=null,t=t.W?.Ct}Bt(){if(this.I)return this.G.textContent="",!0;let t=this.F.parentNode;return this.F===t.firstChild&&this.G===t.lastChild&&(t.innerHTML="",t.append(this.F,this.G),!0)}ie(t){let e=t.te(),i=this.xt?.wt(e)||this.At?.wt(e);return i?(tt(i.Lt,t)?i.zt&&i.Wt(t.exprs,!1):i.Wt(t.exprs),i.Lt=t):(i=new Z(t,this),i.Wt(t.exprs)),(this.$t??=[]).push(i),i}ee(){let t=this.xt?.data;if(t){let e=(this.At??=new C).data;for(let i in t){let s=t[i],l=s.head||0,n=e[i];if(n)for(let t=l,e=j+(n.head||0);s.length>t&&e>n.length;t++)n.push(s[t]);else n=e[i]=l?s.slice(l):s,n.length>j&&(n.length=j)}}this.xt=new C;let e=this.xt,i=this.$t?.length?this.$t:this.Et;if(i)for(let t of i)e.add(t.Rt,t);this.$t=null}_t(){let t;if(t=this.J,t)return t;t=[];let e,i=null;for(this.I?e=this.G.firstChild:(e=this.F.nextSibling,i=this.G);e&&e!==i;)t.push(e),e=e.nextSibling;return this.J=t,t}}const L=[],j=1e4;function P(t){let e=new Q([t],[]);return e.jt=!0,e}function R(t,e){let i=t.Lt;return i===e||("string"==typeof e?!0===i.jt&&i.html[0]===e:tt(i,e))}function M(t,e){let i=t.Lt;return"string"==typeof e?!0===i.jt:i.html===e.html&&i.Ft===e.Ft}function D(t,e,i){let s=e.Pt,l=e.Vt;if(s===l)t.insertBefore(s,i);else for(;;){let e=s.nextSibling;if(t.insertBefore(s,i),s===l)break;s=e}}function H(t,e,i,s){if(e.length){let s=new Set(i);for(let i of e)s.has(i)||i.parentNode!==t||t.removeChild(i)}let l=s;for(let e=i.length;e--;){let s=i[e];s.nextSibling===l&&s.parentNode===t||t.insertBefore(s,l),l=s}}class F extends f{apply(t){this.W.key=t[0]}V(t){this.W.key=t}}class G extends f{se;le;constructor(t,e){super(null,e)}apply(t){let l=(t=>{const e=new Set;return JSON.stringify(t,((t,i)=>{if("function"==typeof i)return X(i);if("object"==typeof i&&null!==i){if(i instanceof Node)return X(i);if(e.has(i))return X(i);if(e.add(i),i instanceof Q)return{html:X(i.html),exprs:i.exprs}}return i}))})(t),r=l!==this.le;this.le=l;let o=this.G,f=n.S(o,"_is");for(let e,l=0;e=this.se[l];l++)if(!(e instanceof F))if(e instanceof u){let r=n.k(e.attrName),o=e.nt(t[l]);!e.U&&s(o)&&(o=i(o[0],o.slice(1))),f[r]=o}else{let i=e.nt(t[l]);if("object"==typeof i)for(let t in i)f[n.k(t)]=i[t];else if("string"==typeof i){let t=n.R(i);for(let e in t)f[n.k(e)]=t[e]}}let h=o.getAttribute("_is");if(o.tagName.endsWith("-SOLARITE-PLACEHOLDER")||h){let s=(h||o.tagName.slice(0,-21)).toLowerCase(),l=customElements.get(s);if(!l)throw Error(`Must call customElements.define('${s}', Class) before using it.`);e.t=[...o.childNodes];let n=new l(f);h&&n.setAttribute("is",h);for(let t of o.attributes)"_is"!==t.name&&n.setAttribute(t.name,t.value);for(let t in f){let e=f[t],i=typeof e;"boolean"===i?!1!==e&&null!=e&&n.setAttribute(t,""):"string"!==i&&"number"!==i&&"bigint"!==i||n.setAttribute(t,e)}let r=n.getAttribute("data-id")||n.getAttribute("id");r&&i(this.W.getRootNode(),r.split(/\./g),n);let u=this.W;this.G=n;for(let t of u.Ut)t.G===o&&(t.G=n),t.F===o&&(t.F=n);u.Pt===o&&(u.Pt=n),u.Vt===o&&(u.Vt=n),"function"!=typeof n.render||e.p.has(n)||n.render(f,!0);for(let e,i=0;e=this.se[i];i++)e.W=this.W,e.G=n,e.apply(t[i]);o.replaceWith(n)}else"function"==typeof o.render&&o.render(f,r);e.t=null}clone(t,e=0){let i=this.B(t,e),s=new G(null,i);return s.se=this.se.map((i=>i.clone(t,e))),s}_(){return 0}}class I{fragment;Ut=[];ids=[];styles=[];scripts=[];zt=!1;qt=!1;ne=!1;Ht=-1;re=!1;oe=!1;constructor(t=null,i=!1){if(!t)return;if(1===t.length&&!t[0].match(/[<&]/))return void(this.fragment=e.i.createTextNode(t[0]));let s,l=I.fe(t),r=e.i.createElement("template");if(l)if(i){r.innerHTML="<svg>"+l+"</svg>";let t=r.content.firstChild,i=e.i.createDocumentFragment();for(;t.firstChild;)i.append(t.firstChild);this.fragment=i}else r.innerHTML=l,this.fragment=r.content;else r.content.append(e.i.createTextNode("")),this.fragment=r.content;J(this.fragment);let o=[],h=0;const a=e.i.createTreeWalker(this.fragment,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_COMMENT|NodeFilter.SHOW_TEXT);for(;s=a.nextNode();)if(o.map((t=>t.remove())),o=[],1===s.nodeType){const t=s.hasAttribute("is"),e=t||s.tagName.includes("-"),l=[];for(let t of[...s.attributes]){if("key"===t.name){let i=t.value.split(/[\ue000-\uf8ff]/g);if(2!==i.length||""!==i[0]||""!==i[1])throw Error("The key attribute is reserved and must be a single expression: key=${...}");if(s.parentNode!==this.fragment)throw Error("The key attribute must be on a top-level element of its template.");if(this.Ht>=0)throw Error("A template can have only one key attribute.");this.Ht=t.value.charCodeAt(0)-K;let n=new F(null,s);this.Ut.push(n),e&&l.push(n),h++,s.removeAttribute("key");continue}let r=t.name.match(/^[\ue000-\uf8ff]$/);if(r){let t=new N(null,s);this.Ut.push(t),e&&(t.q=!0,l.push(t)),h++,s.removeAttribute(r[0])}else{let r=t.value.split(/[\ue000-\uf8ff]/g);if(r.length>1){let o=2!==r.length||r[0].length||r[1].length?r:null,f=n.L(t.name),a=f?new v(null,s,t.name,o):new u(null,s,t.name,o);if(a.Y=n.j(s,t.name),this.Ut.push(a),e&&(a.q=!0,l.push(a)),h+=r.length-1,i||f&&!o)s.removeAttribute(t.name);else try{s.setAttribute(t.name,r.join(""))}catch(e){throw Error(`Error setting attribute "${t.name}" on node <${s.tagName}>: ${e.message}`)}}}}if(e){let e=new G(null,s);e.se=l,this.Ut.splice(this.Ut.length-l.length,0,e),t&&(s.setAttribute("_is",s.getAttribute("is")),s.removeAttribute("is"))}}else if(8===s.nodeType&&"!✨!"===s.nodeValue){if(s?.parentNode?.closest&&s?.parentNode?.closest("[contenteditable]"))throw Error('Contenteditable can\'t have expressions inside them. Use <div contenteditable value="${...}"> instead.');let t=s.parentNode;if(1!==t.nodeType||s.previousSibling||s.nextSibling||t.tagName.includes("-")||"SLOT"===t.tagName||t.hasAttribute("is")){let t,i=s.previousSibling;i||(i=e.i.createComment("Path:"+this.Ut.length),s.parentNode.insertBefore(i,s)),!s.nextSibling||8===s.nextSibling.nodeType&&"!✨!"===s.nextSibling.textContent?(t=s,t.textContent="PathEnd:"+this.Ut.length):(t=s.nextSibling,o.push(s));let l=new O(i,t);this.Ut.push(l),h++}else{let e=new O(null,t);e.I=!0,this.Ut.push(e),h++,o.push(s)}}else{if(3===s.nodeType&&"TEXTAREA"===s.parentNode?.tagName&&s.textContent.includes("\x3c!--!✨!--\x3e"))throw Error('Textarea can\'t have expressions inside them. Use <textarea value="${...}"> instead.');if(8===s.nodeType){let t=s.textContent.split(/[\ue000-\uf8ff]/g);for(let e=0;t.length-1>e;e++){let t=new f(s.previousSibling,s);this.Ut.push(t),h++}}else if(3===s.nodeType&&["SCRIPT","STYLE"].includes(s.parentNode?.nodeName)){let t=s.textContent.split(z);if(t.length>1){let i=[];for(let l=0;t.length>l;l++){let n=e.i.createTextNode(t[l]);s.parentNode.insertBefore(n,s),l>0&&i.push(n)}for(let t,e=0;t=i[e];e++){let e=new O(t.previousSibling,t);this.Ut.push(e),h++}o.push(s)}}}if(o.map((t=>t.remove())),h!==t.length-1)throw Error("Could not parse expressions in template. Check for duplicate attributes or malformed html: "+t.join("${...}"));for(let t of this.Ut)t.F&&(t.X=[].indexOf.call(t.F.parentNode.childNodes,t.F)),t.K=f.get(t.G);this.he(),this.ue(),this.qt=!0;for(let t of this.Ut){if(t instanceof G){this.zt=!0,this.qt=!1;break}1!==t._()&&(this.qt=!1)}if(this.re&&this.qt){let t=[],e=!0;for(let i=0;this.Ut.length>i;i++){let s=this.Ut[i];if(s instanceof O){if(!s.I){e=!1;break}t.push(i)}else if(!(s instanceof u||s instanceof F)){e=!1;break}}e&&(this.oe=!0,this.ae=t,this.ce=this.Ut.map((t=>t.Z(null,t.G))))}}static fe(t){let e=[],i=new h;for(let s=0;t.length>s;s++){let l=0,n=i.parse(t[s],((t,i,s)=>{if(l!==i){let n=t.slice(l,i);s===h.it&&(n=n.replace(/^<\/?[a-z][a-z0-9]*-[a-z0-9-]+/i,(t=>t+"-SOLARITE-PLACEHOLDER"))),e.push(n)}l=i}));t.length-1>s&&e.push(n===h.Text?z:String.fromCharCode(K+s))}return e.join("")}he(){this.scripts=[].map.call(this.fragment.querySelectorAll("script"),(t=>f.get(t))),this.styles=[].map.call(this.fragment.querySelectorAll("style"),(t=>f.get(t)));let t=this.fragment.querySelectorAll("[id],[data-id]");for(let i of t){let t=i.getAttribute("data-id")||i.getAttribute("id");if(e.div.hasOwnProperty(t))throw Error(`<${i.tagName.toLowerCase()} id="${t}"> can't override existing HTMLElement id property.`)}this.ids=[].map.call(t,(t=>f.get(t))),this.ne=this.ids.length>0||this.styles.length>0||this.scripts.length>0}ue(){let t=!1;for(let e of this.Ut)if(e instanceof G){t=!0;break}if(t||!this.Ut.length)return;let e=[],i=new Map,s=this.fragment,l=1,n=t=>{if(t===s)return 0;let r=i.get(t);return void 0===r&&(e.push(n(t.parentNode),[].indexOf.call(t.parentNode.childNodes,t)),r=l++,i.set(t,r)),r};for(let t of this.Ut)t.de=t.G===s?0:n(t.G),t.pe=t.F?n(t.F):-1;this.ye=e,this.me=Array(l),this.ne||1!==s.childNodes.length||1!==s.firstChild.nodeType||2>e.length||0!==e[0]||0!==e[1]||(this.re=!0)}static get(t,i=!1){if(t===V&&i===_)return B;let s=e.m.get(t);s||(s={},e.m.set(t,s));let l=i?"svg":"html",n=s[l];return n||(n=s[l]=new I(t,i)),V=t,_=i,B=n,n}}const z="\x3c!--!✨!--\x3e",W=["TABLE","THEAD","TBODY","TFOOT","TR"];function J(t){let e=1===t.nodeType&&W.includes(t.tagName),i=t.firstChild;for(;i;){let t=i.nextSibling;1===i.nodeType?J(i):e&&3===i.nodeType&&!i.nodeValue.trim()&&i.remove(),i=t}}let V=null,_=!1,B=null;const K=57344;class Z{ot;Ct;Pt;Vt;Ut=null;Rt;key;zt=!1;qt=!1;Nt=!0;J;styles;Lt;constructor(t,i=null,s=null,l=null){if(this.ot=i?.W?.ot||this,this.Ct=i,this.Lt=t,void 0!==t.key&&(this.key=t.key),t.jt)this.Rt=t.te(),this.Pt=this.Vt=s||e.i.createTextNode(t.html[0]);else{const e=I.get(t.html,t.Ft);if(this.Rt=e.Rt??=t.te(),this.zt=e.zt,this.qt=e.qt,e.re&&null!==i){const t=e.fragment.firstChild.cloneNode(!0);this.Pt=this.Vt=t,!0!==e.oe&&this.be(t,e,0,!0)}else{const t=e.fragment.cloneNode(!0);11===t.nodeType?(this.Pt=t.firstChild,this.Vt=t.lastChild):this.Pt=this.Vt=t,this.instantiate(e,t,s,l)}}}instantiate(t,e,i,s){t.Ut.length?this.be(e,t):this.Ut=[],t.ne&&this.ge(e,t)}Wt(t,e=!0){let i=this.Ut;if(this.qt){if(e){if(null===i)return void this.ve(t);for(let e=i.length-1;e>=0;e--)i[e].V(t[e]);this.styles&&this.Qt(),this.J=null}return void(this.Nt=!1)}if(!i)return void(this.Nt=!1);let s=t.length,l=Array(i.length);for(let n,r=i.length-1;n=i[r];r--){if(0===r&&n instanceof G&&n.G===this.getRootNode())continue;let i=n._();if(l[r]=t.slice(s-i,s),s-=i,n instanceof G){let t=l.slice(r+1,r+1+n.se.length);n.apply(t)}else e&&n.apply(l[r])}e&&(this.Qt(),this.J=null),this.Nt=!1}ve(t){let e=this.Lt,i=I.get(e.html,e.Ft),s=i.ae;for(let e=0;s.length>e;e++){let l=typeof t[s[e]];if("string"!==l&&"number"!==l){let e=this.Xt(i);for(let i=e.length-1;i>=0;i--)e[i].V(t[i]);return this.J=null,void(this.Nt=!1)}}let l=this.we(i),n=i.Ut,r=i.ce;for(let e=n.length-1;e>=0;e--){let i=r[e],s=l[n[e].de];if(i.I){let i=t[e];"number"==typeof i&&(i+=""),s.textContent=i}else i.G=s,i.W=this,i.V(t[e])}this.J=null,this.Nt=!1}Yt(t){let e=I.get(t.html,t.Ft),i=t.exprs,s=e.ae;for(let t=0;s.length>t;t++){let e=typeof i[s[t]];if("string"!==e&&"number"!==e)return!1}let l=this.Lt.exprs,n=e.Ut,r=e.ce,o=null;for(let t=n.length-1;t>=0;t--)if(!et(l[t],i[t])){null===o&&(o=this.we(e));let s=r[t],l=o[n[t].de];if(s.I){let e=i[t],n=l.firstChild;"number"==typeof e&&(e+=""),null!==n&&3===n.nodeType&&n===l.lastChild?n.nodeValue=e:(s.G=l,s.W=this,s.V(i[t]),s.St=null,s.kt=null,s.J=null);continue}s.G=l,s.W=this,s.V(i[t])}return!0}we(t){let e=t.me;e[1]=this.Pt;let i=t.ye;for(let t=2,s=2;i.length>t;t+=2,s++){let l=e[i[t]].firstChild;for(let e=i[t+1];e>0;e--)l=l.nextSibling;e[s]=l}return e}Xt(t=null){t??=I.get(this.Lt.html,this.Lt.Ft);let e=this.we(t),i=t.Ut,s=i.length,l=this.Ut=Array(s);for(let t=0;s>t;t++){let s=i[t],n=s.Z(0>s.pe?null:e[s.pe],e[s.de]);n.W=this,l[t]=n}for(let e of t.ae){let t=l[e],i=t.G.firstChild;null!==i&&3===i.nodeType&&i===t.G.lastChild&&(t.St=i,t.kt=i.nodeValue)}return l}_t(){let t=this.J;if(t)return t;t=[];let e=this.Pt,i=this.Vt?.nextSibling;for(;e&&e!==i;)t.push(e),e=e.nextSibling;return this.J=t,t}getRootNode(){return this.ot.root}Ee(){return this.ot}be(t,e,i=0,s=!1){let l=e.Ut,n=l.length,r=this.Ut=Array(n),o=e.ye;if(o&&0===i){let i=e.me,f=0,h=1;for(s?(i[1]=t,f=2,h=2):i[0]=t;o.length>f;f+=2,h++){let t=i[o[f]].firstChild;for(let e=o[f+1];e>0;e--)t=t.nextSibling;i[h]=t}for(let t=0;n>t;t++){let e=l[t],s=e.Z(0>e.pe?null:i[e.pe],i[e.de]);s.W=this,r[t]=s}}else for(let e=0;n>e;e++){let s=l[e].clone(t,i);s.W=this,r[e]=s}}Qt(){if(this.styles)for(let[t,e]of this.styles)e!==t.textContent&&n.A(t,this.Ee().root)}ge(t,e,i=0){let s=this.ot.root;if(s){let l=this.ot.options;if(!1!==l?.ids)for(let l of e.ids){i&&(l=l.slice(0,-i));let e=f.resolve(t,l);n.$(s,e)}if(!1!==l?.styles){e.styles.length&&(this.styles=new Map);for(let l of e.styles){i&&(l=l.slice(0,-i));let e=f.resolve(t,l);1===s.nodeType&&(n.A(e,s),this.styles.set(e,e.textContent))}}if(!1!==l?.scripts)for(let s of e.scripts){i&&(s=s.slice(0,-i));let e=f.resolve(t,s);(0,eval)(e.textContent)}}}}class U extends Z{instantiate(t,i,s,l){let n=0;if(this.options=l,i instanceof Text){if(!s)throw Error("Cannot create a standalone text node");this.root=s,i.nodeValue.length&&this.root.append(i)}else{if(s){let t;if(this.root=s,(e.t||s.childNodes.length)&&(t=e.i.createDocumentFragment(),t.append(...e.t||s.childNodes)),o=this.root.tagName,1===(r=i).children.length&&o.includes("-")&&r.children[0].tagName.replace("-SOLARITE-PLACEHOLDER","")===o){this.root.append(...i.children[0].childNodes);for(let t of i.children[0].attributes)this.root.hasAttribute(t.name)||this.root.setAttribute(t.name,t.value);n=1}else 1===i.childNodes.length&&3===i.childNodes[0].nodeType&&""===i.childNodes[0].textContent||this.root.append(...i.childNodes);if(t){for(let e of s.querySelectorAll("slot[name]")){let i=e.getAttribute("name");if(i){let s=t.querySelectorAll(`[slot='${i}']`);e.append(...s)}}let e=s.querySelector("slot:not([name])");e?e.append(t):s.append(t)}}else{let t=(t=>{let e=[];for(let i of t.childNodes)if(1===i.nodeType||3===i.nodeType&&i.textContent.trim().length){if(e.length)return null;e.push(i)}return e[0]})(i);this.root=t||i,t&&(n=1)}this.be(this.root,t,n),this.ge(this.root,t,n)}var r,o;this.Pt=this.Vt=this.root,e.h.set(this.root,this)}}let q=1,Y=new WeakMap;function X(t){let e=Y.get(t);return void 0===e&&(e="~@"+q++,Y.set(t,e)),e}class Q{exprs=void 0;html=void 0;Rt;jt;key;Ft=!1;constructor(t=[""],e=[]){this.html=t,this.exprs=e}render(t=null,i={}){let s=t&&e.h.get(t);return s||(s=new U(this,null,t,i),t||(t=s.getRootNode()),e.h.set(t,s)),1!==this.html?.length||this.html[0]?s.Wt(this.exprs):t.innerHTML="",t}te(){return void 0===this.Rt&&(this.Rt=this.exprs.length?X(this.html):this.html[0]),this.Rt}}function tt(t,e){if(t.html===e.html&&t.Ft===e.Ft){let i=t.exprs,s=e.exprs;for(let t=0;i.length>t;t++)if(!et(i[t],s[t]))return!1;return!0}return t.jt===e.jt&&!t.exprs.length&&!e.exprs.length&&1===t.html.length&&1===e.html.length&&t.Ft===e.Ft&&t.html[0]===e.html[0]}function et(t,e){if(t===e)return!0;if(Array.isArray(t)){if(!Array.isArray(e)||t.length!==e.length)return!1;for(let i=0;t.length>i;i++)if(!et(t[i],e[i]))return!1;return!0}return t instanceof Q&&e instanceof Q&&tt(t,e)}function it(t){if("string"==typeof t){let i=e.i.createElement("template");i.innerHTML=t;let s=n.H(i.content.childNodes);return 1===s.length?s[0]:i.content}if(t instanceof Q)return t.render();if(t&&"object"==typeof t){let i=t;if("Object"!==i.constructor.name)throw Error(`Solarate Web Component class ${i.constructor?.name} must extend HTMLElement.`);if(!e.u.has(i)){e.u.set(i,null),i[st]();let t=e.u.get(i);e.u.delete(i);for(let e in i)t[e]="function"==typeof i[e]?i[e].bind(t):i[e];return t}}throw Error("toEl() does not support argument of type: "+(t?typeof t:t))}let st="render";function lt(t,...e){let i=new Q(t,e);return i.Ft=!0,i}const nt=Symbol("solariteRender"),rt=Symbol();function ot(t=rt,...i){if(Array.isArray(t))return new Q(t,i);if("string"==typeof t||t instanceof String){let e=t;if(!i.length||"object"!=typeof i[0]&&null!==i[0]){let t=e;return/^\s+</.test(t)&&(t=t.trim()),new Q([t],[])}return A(e+"",i[0]||{},i.slice(1))}if("function"==typeof t||t===w)return A(t,i[0]||{},i.slice(1));if(t instanceof HTMLElement||t instanceof DocumentFragment){if(!(i[0]instanceof Q)){let s=t,l=i[0];if(void 0===l){let t=s[nt];if(t)return t}let n=(t,...i)=>(s.shadowRoot&&(s.innerHTML=""),e.p.add(s),new Q(t,i).render(s,l));return void 0===l&&(s[nt]=n),n}i[0].render(t,i[1])}else{if(t===rt)return(t,...e)=>it(ot(t,...e));if("object"!=typeof t||!e.u.has(t)){if(n.P(t))return new Q;throw Error("h() does not support argument of type: "+(t?typeof t:t))}{let s=t;if("Object"!==s.constructor.name)throw Error(`Solarate Web Component class ${s.constructor?.name} must extend HTMLElement.`);if(!(i[0]instanceof Q))return((...t)=>{let i=ot(...t).render();e.u.set(s,i)}).bind(s);{let t=i[0].render();e.u.set(s,t)}}}}const ft=new WeakMap;function ht(t,e={},i=[]){for(let s of t.attributes){let l=n.k(s.name);if(!(l in t)||i.includes(l))continue;let r=s.value,o=e[l];t[l]=r.startsWith("${")&&r.endsWith("}")?JSON.parse(r.slice(2,-1)):o===Date?new Date(r):o===Boolean?!["false","0"].includes(r):o===Number?+r:o===String?r+"":o?o(r):r}}ot.immutableMap=ot.map=(t,e)=>{let i=Array(t.length);for(let s=0;t.length>s;s++){let l=t[s];if(null!==l&&"object"==typeof l){let t=ft.get(l);void 0===t&&(t=e(l),ft.set(l,t)),i[s]=t}else i[s]=e(l)}return i};let ut=new Proxy(HTMLElement,{construct:(t,e,i)=>(n.C(i),Reflect.construct(t,e,i))});class at extends ut{constructor(t=null){if(super(),t){if("object"!=typeof t)throw Error("First argument to custom element constructor must be an object.");if(t&&!Object.keys(t).length){let e=at.getAttribs(this);for(let i in e)t[i]=e[i]}}}render(){throw Error("render() is not defined for "+this.constructor.name)}renderFirstTime(){if(!e.p.has(this)){let t=at.getAttribs(this);this.render(t)}}connectedCallback(){this.renderFirstTime()}static define(t=null){n.C(this,t)}static getAttribs(t){let e=n.S(t);for(let t in e){let i=e[t];i.startsWith("${")&&i.endsWith("}")&&(e[t]=JSON.parse(i.slice(2,-1)))}return e}}export default ot;export{w as Fragment,e as Globals,at as Solarite,n as SolariteUtil,Q as Template,ht as assignAttributes,i as delve,c as getEventBinding,ot as h,lt as svg,it as toEl};
|
|
1
|
+
// Solarite v0.8.0 | MIT | eric-frost.github.io/solarite
|
|
2
|
+
function t(t,e,i=O){let l=i!==O,s=e.length;if(!t&&!l&&s)return;let n=0;for(let r of e){if(void 0===t[r]){if(!l)return;s-1>n&&(t[r]=(e[n+1]+"").match(/^\d+$/)?[]:{})}l&&n===s-1&&(t[r]=i);t=t[r];n++}return t}function e(t){return Array.isArray(t)&&t.length>=2&&("object"==typeof t[0]||void 0===t[0])&&!t.slice(1).find(t=>"string"!=typeof t&&"number"!=typeof t)}function i(t,e){let i=t[I];if(void 0!==i)return i instanceof V?i.key===e?i:void 0:i[e]}function l(t,e,i=!1){let l=t[z];void 0===l&&(l=t[z]=new Set);if(!l.has(e)){l.add(e);t.addEventListener(e,s)}if(i){let i=t.ownerDocument??document,l=i[z];void 0===l&&(l=i[z]=new Set);if(!l.has(e)){l.add(e);i.addEventListener(e,s)}}}function s(t){if(t[G])return;t[G]=!0;let e=H[t.type],i=t.target;Object.defineProperty(t,"currentTarget",{configurable:!0,get:()=>i});for(;i;){let l=i[e];if(void 0!==l){let e=i[F];if("function"==typeof l)l.call(e,t,i);else switch(l.length){case 1:l[0].call(e,t,i);break;case 2:l[0].call(e,l[1],t,i);break;case 3:l[0].call(e,l[1],l[2],t,i);break;default:l[0].call(e,...l.slice(1),t,i)}if(t.cancelBubble)break}i=i.parentNode}delete t.currentTarget}function n(t){if(null===t||"object"!=typeof t)return t;let e="";for(let i in t){let l=t[i];null!=l&&!1!==l&&(e+=(e?";":"")+$.t(i)+":"+l)}return e}function r(t){return(""+t).replace(/&/g,"&").replace(/"/g,""")}function o(t,e,i=[],l){e=e||{};if(t===J){let t=[""];for(let e=0;i.length>e;e++)t.push("");return new Et(t,i)}if("function"==typeof t){if(t.prototype instanceof HTMLElement)return f($.i(t),e,i,l);let s={};for(let t in e)"key"!==t&&(s[t]="style"===t?n(e[t]):e[t]);!("children"in s)&&i.length&&(s.children=1===i.length?i[0]:i);let r=t(s);void 0===l&&(l=e.key);void 0!==l&&r instanceof Et&&(r.key=l);return r}return f(t,e,i,l)}function f(t,e,i,l){let s=_.has(t.toLowerCase()),o=[],f=[],h="";for(let t in e){if("children"===t)continue;if("key"===t){void 0===l&&(l=e[t]);continue}let i=e[t];if("id"!==t&&"data-id"!==t||"string"!=typeof i){"style"===t&&(i=n(i));o.push(t);f.push(i)}else h+=` ${t}="${r(i)}"`}let u=s?0:i.length,a=t+h+"\0"+o.join("\0")+"\0#"+u,c=B.get(a);if(!c){c=((t,e,i,l,s)=>{let n=[],r="<"+t+e;for(let t of i){n.push(r+" "+t+"=");r=""}r+=">";if(s){n.push(r);return n}if(0===l)n.push(r+"</"+t+">");else{n.push(r);for(let t=1;l>t;t++)n.push("");n.push("</"+t+">")}return n})(t,h,o,u,s);B.set(a,c)}let p=s?f:f.concat(i),d=new Et(c,p);void 0!==l&&(d.key=l);return d}function h(t){if("string"!=typeof t){if(void 0!==t.key)return t.key;if(t.html!==st){st=t.html;nt=ft.get(t.html,t.o).l}return 0>nt?void 0:t.exprs[nt]}}function u(t){let e=new Et([t],[]);e.h=!0;return e}function a(t,e){let i=t.u;return i===e||("string"==typeof e?!0===i.h&&i.html[0]===e:g(i,e))}function c(t,e){let i=t.u;return"string"==typeof e?!0===i.h:i.html===e.html&&i.o===e.o}function p(t,e,i){for(let l=0;e>l;l++)if(t[l]===i)return!0;return!1}function d(t,e,i){let l=e.p,s=e.m;if(l===s)t.insertBefore(l,i);else for(;;){let e=l.nextSibling;t.insertBefore(l,i);if(l===s)break;l=e}}function y(t,e,i,l){if(e.length){let l=new Set(i);for(let i of e)l.has(i)||i.parentNode!==t||t.removeChild(i)}let s=l;for(let e=i.length;e--;){let l=i[e];l.nextSibling===s&&l.parentNode===t||t.insertBefore(l,s);s=l}}function m(t){let e=1===t.nodeType&&at.includes(t.tagName),i=t.firstChild;for(;i;){let t=i.nextSibling;1===i.nodeType?m(i):e&&3===i.nodeType&&!i.nodeValue.trim()&&i.remove();i=t}}function b(t,e,i,l){for(;e.length>i;i+=2,l++){let s,n=e[i+1];if(0>n){s=t[e[i]];do{s=s.nextSibling}while(0>++n)}else{s=t[e[i]].firstChild;for(;n>0;n--)s=s.nextSibling}t[l]=s}return t}function w(t){let e=St.get(t);if(void 0===e){e="~@"+vt++;St.set(t,e)}return e}function g(t,e){if(t.html===e.html&&t.o===e.o){let i=t.exprs,l=e.exprs;for(let t=0;i.length>t;t++){let e=i[t],s=l[t];if(e!==s&&!v(e,s))return!1}return!0}return t.h===e.h&&!t.exprs.length&&!e.exprs.length&&1===t.html.length&&1===e.html.length&&t.o===e.o&&t.html[0]===e.html[0]}function v(t,e){if(t===e)return!0;if(Array.isArray(t)){if(!Array.isArray(e)||t.length!==e.length)return!1;for(let i=0;t.length>i;i++)if(!v(t[i],e[i]))return!1;return!0}return t instanceof Et&&e instanceof Et&&g(t,e)}function S(t){if("string"==typeof t){let e=N.v.createElement("template");e.innerHTML=t;let i=$.S(e.content.childNodes);return 1===i.length?i[0]:e.content}if(t instanceof Et)return t.render();if(t&&"object"==typeof t){let e=t;if("Object"!==e.constructor.name)throw Error(`Solarite web component class ${e.constructor?.name} must extend HTMLElement.`);if(!N.A.has(e)){N.A.set(e,null);e[At]();let t=N.A.get(e);N.A.delete(e);for(let i in e)t[i]="function"==typeof e[i]?e[i].bind(t):e[i];return t}}throw Error("toEl() does not support argument of type: "+(t?typeof t:t))}function E(t,...e){let i=new Et(t,e);i.o=!0;return i}function A(t=xt,...e){if(Array.isArray(t))return new Et(t,e);if("string"==typeof t||t instanceof String){let i=t;if(!e.length||"object"!=typeof e[0]&&null!==e[0]){let t=i;/^\s+</.test(t)&&(t=t.trim());return new Et([t],[])}return o(i+"",e[0]||{},e.slice(1))}if("function"==typeof t||t===J)return o(t,e[0]||{},e.slice(1));if(t instanceof HTMLElement||t instanceof DocumentFragment){if(!(e[0]instanceof Et)){let i=t,l=e[0],s=i[kt];if(s)return s;let n=(t,...e)=>{i.shadowRoot&&(i.innerHTML="");N.k.add(i);return new Et(t,e).render(i,l)};i[kt]=n;return n}e[0].render(t,e[1])}else{if(t===xt)return(t,...e)=>S(A(t,...e));if("object"!=typeof t||!N.A.has(t)){if($.T(t))return new Et;throw Error("h() does not support argument of type: "+(t?typeof t:t))}{let i=t;if(!(e[0]instanceof Et))return((...t)=>{let e=A(...t).render();N.A.set(i,e)}).bind(i);{let t=e[0].render();N.A.set(i,t)}}}}function k(t,e){return e===Date?new Date(t):e===Boolean?!["false","0"].includes(t):e?e(t):t}function x(t,e={},i=[]){for(let l of t.attributes){let s=$.N(l.name);if(!(s in t)||i.includes(s))continue;let n=l.value,r=e[s];n.startsWith("${")&&n.endsWith("}")?t[s]=JSON.parse(n.slice(2,-1)):r?t[s]=k(n,r):""===n&&("function"==typeof t[s]||"object"==typeof t[s]&&null!==t[s])||(t[s]=n)}}var T;!function t(){T={connected:new WeakSet,O:null,div:document.createElement("div"),v:document,$:{},L:{},P:new WeakMap,A:new WeakMap,k:new WeakSet,j:new WeakMap,reset:t}}();var N=T;let O={},$={C(t,e){let i=t.length;if(i!==e.length)return!1;for(let l=0;i>l;l++)if(t[l]!==e[l])return!1;return!0},R(t,e=null){let i={};for(let l of t.attributes)l.name!==e&&(i[$.N(l.name)]=l.value);return i},M(e,i){let l=i.getAttribute("data-id")||i.getAttribute("id");if(l){if(!l.includes(".")){let t=e[l],i=l in e&&!Object.hasOwn(e,l);if(!t?.nodeType&&(null!=t||i))throw Error(`Solarite: id="${l}" would overwrite an existing ${e.constructor.name} property.`)}t(e,l.split(/\./g),i)}},I(t,e){let i=e.tagName.toLowerCase(),l="";if(t.hasAttribute("global")||t.hasAttribute("data-global")){let e=N.v.head;if(e.querySelector(`style[data-style="${i}"]`))t.remove();else{e.append(t);t.setAttribute("data-style",i)}}else{let t=e.getAttribute("data-style");if(!t){let i=e.constructor;e.setAttribute("data-style",t=i.D=(i.D||0)+1)}l=`[data-style="${t}"]`}for(let e of t.childNodes)if(3===e.nodeType){let t=e.textContent,s=t.replace(/:host(?:\(((?:[^()]|\([^()]*\))*)\)|(?![-a-z0-9_(]))/gi,`${i}${l}$1`);t!==s&&(e.textContent=s)}},t:t=>t.replace(/[a-z0-9](?=[A-Z])|[A-Z](?=[A-Z][a-z])|[a-zA-Z](?=\d)/g,"$&-").toLowerCase(),N:t=>t.replace(/-([a-z])/g,t=>t[1].toUpperCase()),i(t,e){let i=customElements[P](t);if(i)return i;(e=e||$.t(t.name)).includes("-")||(e+="-element");customElements[L](e,t);return e},H:t=>"checkbox"===t.type?t.checked:"radio"===t.type?t.value:"file"===t.type?[...t.files]:"number"===t.type||"range"===t.type?t.valueAsNumber:"date"===t.type||"time"===t.type||"datetime-local"===t.type?t.valueAsDate:"select-multiple"===t.type?[...t.selectedOptions].map(t=>t.value):t.hasAttribute("contenteditable")?t.innerHTML:t.value,F:t=>t.startsWith("on")&&t in N.div,G(t,e){let i=t.tagName+"."+e,l=N.L[i];if(void 0===l){let s=Object.getPrototypeOf(t);for(;s;){const t=s.constructor.name;if(t.startsWith("HTML")&&t.endsWith("Element"))break;s=Object.getPrototypeOf(s)}N.L[i]=l=!!s&&!!Object.getOwnPropertyDescriptor(s,e)?.set}return l},T:t=>void 0===t||!1===t||null===t,V(){return{}},W:t=>"function"==typeof t?$.W(t()):t instanceof Date?t.toISOString().replace(/T/," "):Array.isArray(t)||"object"==typeof t?"":t,J(t){N.v.createDocumentFragment().append(...t)},S(t){let e=t=>1!==t.nodeType&&(3!==t.nodeType||!t.textContent.trim()),i=[...t];for(;i.length&&e(i[0]);)i.shift();for(;i.length&&e(i[i.length-1]);)i.pop();return i}},L="define",P="getName";class j{K;_;B=!1;U;Z;Y;q=!1;X;constructor(t,e){this.K=t;this._=e}tt(t){this.et(t[0])}et(t){}it(){return 1}lt(t){return t[0]}st(t,e){let i=new this.constructor(t,e,this.nt,this.rt);i.Y=this.Y;i.B=this.B;i.X=this.X;return i}clone(t,e=0){let i,l=j.resolve(t,this.ot,e);this.K&&(i=(l===t?t:l.parentNode).childNodes[this.ft]);return this.st(i,l)}static get(t){let e=[];for(;;){let i=t.parentNode;if(!i)break;e.push([].indexOf.call(t.parentNode.childNodes,t));t=i}return e}static resolve(t,e,i=0){for(let l=e.length-1-i;l>=0;l--)t=t.childNodes[e[l]];return t}}class C{selector;selected;constructor(t,e){this.selector=t;this.selected=e}value(){let t=this.selector;return this.selected?t.ht:t.ut}bind(t,e,i){if(i.p!==t)throw Error("Solarite: a selector must be on the row's root element.");let l=this.selector;l.nt=e;l.path=i.ct;let s=this.selected?l.ht:l.ut;""===s||!1===s||null==s?!0!==i.dt&&t.removeAttribute(e):t.setAttribute(e,s)}}class R{#t=null;#e=new C(this,!0);#i=new C(this,!1);ht;ut="";nt=null;path=null;constructor(t=null){this.#t=t}get key(){return this.#t}when(t,e,i=""){this.ht=e;this.ut=i;return t===this.#t?this.#e:this.#i}set(t){let e=this.#t;if(e!==t){this.#t=t;if(null!==this.path){this.#l(e,this.ut);this.#l(t,this.ht)}}}#l(t,e){if(null==t)return;let i=this.path.yt;if(null===i||0===i.length)return;if(void 0===i[0].key)throw Error("Solarite: a selector must be on a keyed list, as key=${...}.");let l=null;for(let e=0;i.length>e;e++)if(i[e].key===t){l=i[e];break}if(null===l)return;let s=l.p;null!==s&&1===s.nodeType&&(""===e||!1===e||null==e?s.removeAttribute(this.nt):s.setAttribute(this.nt,e))}}class M extends j{nt;rt;constructor(t,e,i=null,l=null){super(null,e);this.nt=i;this.rt=l}tt(t){if(this.rt){let e=this._,i=this.lt(t),l=this.X;if((l?e[this.nt]:e.getAttribute(this.nt))!==i){l?e[this.nt]=i:"value"===this.nt&&e.hasAttribute("contenteditable")&&(e.innerHTML=i);e.setAttribute(this.nt,i)}}else this.et(t[0])}et(i){if(this.rt)return this.tt([i]);let l=this._;if(e(i)){if(this.Y&&l.tagName.endsWith("-SOLARITE-PLACEHOLDER"))return;let[e,s]=[i[0],i.slice(1)];if(!e)throw Error(`Solarite cannot bind ${this.nt} to ${e}.`);let n=t(e,s);if("value"===this.nt&&"select-multiple"===l.type&&Array.isArray(n)){let t=n.map(t=>t+"");for(let e of l.options)e.selected=t.includes(e.value)}else if("radio"===l.type)l.checked=l.value===n+"";else{const t=$.T(n)?"":n;"value"===this.nt&&l.hasAttribute("contenteditable")?t!==l.innerHTML&&(l.innerHTML=t):t!==l[this.nt]&&(l[this.nt]=t)}let r=()=>{let i="value"===this.nt||"radio"===l.type?$.H(l):l[this.nt];t(e,s,i)};this.bt(l,this.U.wt(),this.nt,"input",r,null,!0)}else{if("object"==typeof i&&i instanceof C){this.Y||i.bind(l,this.nt,this.U);return}let t=this.X;if("function"==typeof i){if(this.Y)return;i=i()}else i=$.W(i);if(void 0===i||!1===i||null===i||""===i&&!t){t&&(l[this.nt]="boolean"!=typeof l[this.nt]&&"");l.removeAttribute(this.nt)}else if(!0===i){t&&(l[this.nt]=!0);l.setAttribute(this.nt,"")}else if((t?l[this.nt]:l.getAttribute(this.nt)??"")!==i){t?l[this.nt]=i:"value"===this.nt&&l.hasAttribute("contenteditable")&&(l.innerHTML=i);l.setAttribute(this.nt,i)}}}it(){return this.rt?this.rt.length-1:1}lt(t){if(!this.rt)return t[0];let e=[],i=this.rt;for(let l=0;i.length>l;l++){e.push(i[l]);if(i.length-1>l){if("object"==typeof t[l]&&t[l]instanceof C)throw Error(`Solarite: a selector must own the whole ${this.nt} attribute.`);let i=$.W(t[l]);$.T(i)||e.push(i)}}return e.join("")}bt(t,e,i,s,n,r,o=!1){if(!1===o&&void 0!==this.gt){let i=this.U.St.vt?.eventDelegation??!0,o="document"===i;if(!1!==i&&(!0===i||o||i.includes(s))){let i=this.gt;void 0===t[i]&&l(e,s,o);t[i]=r||n;t[F]=e;return}}let f,h=r||[n],u=t[I];if(void 0!==u){if(u instanceof V){if(u.key!==i){let l=t[I]={};l[u.key]=u;f=l[i]=new V(e,t,i,h);t.addEventListener(s,f,o);return}f=u}else{f=u[i];if(!f){f=u[i]=new V(e,t,i,h);t.addEventListener(s,f,o);return}}f.Et=e;f.At=h}else{let l=t[I]=new V(e,t,i,h);t.addEventListener(s,l,o)}}}const I=Symbol(),D=new Set(["beforeinput","click","contextmenu","dblclick","focusin","focusout","input","keydown","keyup","mousedown","mousemove","mouseout","mouseover","mouseup","pointerdown","pointermove","pointerout","pointerover","pointerup","touchend","touchmove","touchstart"]),H={},F=Symbol(),z=Symbol(),G=Symbol();class V{constructor(t,e,i,l){this.Et=t;this.node=e;this.key=i;this.At=l}handleEvent(t){let e=this.At;switch(e.length){case 1:return e[0].call(this.Et,t,this.node);case 2:return e[0].call(this.Et,e[1],t,this.node);case 3:return e[0].call(this.Et,e[1],e[2],t,this.node)}return e[0].call(this.Et,...e.slice(1),t,this.node)}}class W extends M{kt;gt;constructor(t,e,i=null,l=null){super(null,e,i,l);this.q=!0;this.kt=i?i.slice(2):null;this.gt=null!==this.kt?(t=>{if(D.has(t))return H[t]??=Symbol("sol$"+t)})(this.kt):void 0}tt(t){this.rt?.length>1?super.tt(t):this.et(t[0])}et(t){if(this.rt?.length>1)return super.tt([t]);if(this.Y&&this._.tagName.endsWith("-SOLARITE-PLACEHOLDER"))return;let e,i=this.U.St.Et,l=this._,s=this.kt;if(Array.isArray(t)&&"function"==typeof t[0])e=t[0];else{if("function"!=typeof t)throw Error(`Solarite: ${this.nt}=\${...} is not a function.`);e=t;t=null}this.bt(l,i,s,s,e,t)}}const J=Symbol();class K{constructor(t,e){this.name=t;this.value=e}}const _=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),B=new Map;class U extends j{xt;Tt;Nt;constructor(t,e){super(null,e);this.xt=new Set}et(t){let e=this._;if(t instanceof K)return this.Ot(t);Array.isArray(t)&&(t=t.flat().join(" "));let i=this.xt;this.xt=new Set;if(t){"function"==typeof t&&(t=t());if("object"==typeof t)for(let i in t){let l=t[i];if(void 0!==l&&!1!==l&&null!==l){e.setAttribute(i,l);this.xt.add(i)}}else{let i=$.V(t);for(let t in i){e.setAttribute(t,i[t]);this.xt.add(t)}}}for(let t of i)this.xt.has(t)||e.removeAttribute(t)}Ot(t){let e=t.name;if("key"===e)return;let i=t.value,l=this.Tt;if(void 0===l||this.Nt!==e){let t=this._;if($.F(e))l=new W(null,t,e,null);else{l=new M(null,t,e,null);l.X=$.G(t,e)}l.Y=this.Y;this.Tt=l;this.Nt=e}l._=this._;l.U=this.U;"style"===e&&(i=n(i));l.et(i)}}class Z{data={};add(t,e){let i=this.data,l=i[t];l?l.push(e):i[t]=[e]}$t(t,e,i){let l=this.data,s=l[t];s?i>s.length-(s.Lt||0)&&s.push(e):l[t]=[e]}Pt(t){let e=this.data,i=e[t];if(!i)return;let l=i.Lt||0,s=i[l];l++;i.length>l?i.Lt=l:delete e[t];return s}}class Y{items;jt;constructor(t,e){this.items=t;this.jt=e}*[Symbol.iterator](){let t=this.items,e=this.jt;for(let i=0;t.length>i;i++)yield e(t[i])}}class q extends j{Rt=!1;Mt=null;It=!1;yt=null;Dt=null;Ht=null;Ft=null;zt=null;constructor(t,e){super(t,e)}et(t){let e=typeof t;if(("string"===e||"number"===e)&&!this.It){"string"!==e&&(t+="");let i=this.Dt;if(null!==i){if(this.Ht!==t){i.nodeValue=t;this.Ht=t}return}let l=this.yt;if(null===l||0===l.length){let e;if(this.B){let i=this._.firstChild;if(null!==i&&3===i.nodeType&&i===this._.lastChild){i.nodeValue!==t&&(i.nodeValue=t);this.Dt=i;this.Ht=t;return}this._.textContent=t;e=this._.firstChild}else{e=N.v.createTextNode(t);this._.parentNode.insertBefore(e,this._)}this.Dt=e;this.Ht=t;if(!this.U.dt){this.Z=null;this.U.ct&&this.U.ct.Gt()}return}if(1===l.length){let e=l[0],i=e.u;if(!0===i.h){if(i.html[0]!==t){e.p.nodeValue=t;i.html[0]=t;e.Vt=t}return}}}if(null!==this.Dt){let t=new wt(u(this.Ht),this,this.Dt);(this.yt??=[]).push(t);this.Dt=null}if(t instanceof C)throw Error("Solarite: a selector must own the whole attribute.");if(t instanceof Y){this.Wt(t);return}this.Mt=null;let i=null,l=!1;if(Array.isArray(t)){let e=t.length,l=0;for(;e>l&&t[l]instanceof Et;)l++;l===e&&(i=t)}if(null===i){i=[];l=this.Jt(t,i,!1)}if(l||this.It){this.It=l;this.Kt(i)}else this._t(i)}_t(t){let e=0!==t.length?t[0]:null;(null!==e?"string"==typeof e||void 0===e.key&&0>ft.get(e.html,e.o).l:null===this.yt||0===this.yt.length||void 0===this.yt[0].key)?this.Bt(t):this.Ut(t)}Wt(t){let e=t.items,i=t.jt,l=e.length,s=this.yt,n=this.Mt,r=null===s||null===n||n.length!==s.length?0:s.length,o=null,f=null,h=0;if(r===l&&0!==l&&!this.Rt&&!this.It){let t=!1,u=Q;for(let i=0;l>i;i++)if(n[i]!==e[i]){if(h===u){if(p(n,r,e[i])){t=!0;h=0;break}u=l}(o??=[])[h++]=i}if(!t&&0!==h){f=Array(h);for(let l=0;h>l;l++){let s=i(e[o[l]]);if(!(s instanceof Et)&&"string"!=typeof s){t=!0;h=l;break}f[l]=s}}if(!t&&(0===h||this.Zt(s,o,f,h,l))){for(let t=0;h>t;t++){let i=o[t];n[i]=e[i]}return}}let u=Array(l),a=0!==h?o:null,c=0,d=null,y=!1;const m=t=>{if(y)return-1;if(null===d){if(!p(n,r,t)){y=!0;return-1}d=new Map;for(let t=0;r>t;t++)d.set(n[t],t)}let e=d.get(t);return void 0===e?-1:e};if(0!==r){let t=0,o=!0;for(let p=0;l>p;p++){let d=e[p],y=p+t,b=y>=0&&r>y;if(b&&n[y]===d){u[p]=s[y].u;o=!0}else if(null!==a&&h>c&&a[c]===p)u[p]=f[c++];else{if(o){let f=-1;for(let t=1;et>=t;t++){let e=y+t,i=y-t;if(r>e&&n[e]===d){f=e;break}if(i>=0&&n[i]===d){f=i;break}}if(f>=0){t=f-p;u[p]=s[f].u;continue}if(b&&l>r)for(let s=1;it>=s&&l>p+s;s++)if(e[p+s]===n[y]){u[p]=i(d);t--;f=-2;break}if(-2===f)continue;o=!1}if(r>y){let e=m(d);if(e>=0){u[p]=s[e].u;t=e-p;o=!0;continue}}u[p]=i(d)}}}else for(let t=0;l>t;t++)u[t]=i(e[t]);let b=0!==l?u[0]:null;if(null!==b&&!(b instanceof Et)&&"string"!=typeof b){let t=[],e=this.Jt(u,t,!1);if(e||this.It){this.It=e;this.Kt(t)}else this._t(t);return}if(this.It){this.It=!1;this.Kt(u);return}this._t(u);let w=this.Mt;null!==w&&w.length===l||(w=this.Mt=Array(l));for(let t=0;l>t;t++)w[t]=e[t]}Zt(t,e,i,l,s){let n=void 0!==t[0].key,r=null,o=0;for(let s=0;l>s;s++){let l=t[e[s]],f=i[s];if("string"==typeof f||!c(l,f)||n&&l.key!==h(f)){if(!n||o===tt)return!1;(r??=[])[o++]=s}}for(let s=0,n=0;l>s;s++){if(o>n&&r[n]===s){n++;continue}let l=t[e[s]],f=i[s];a(l,f)?this.Yt(l,f):this.qt(l,f)}if(0===o)return!0;let f=this.B;this.Xt(r,e,t,i,t,s,f?null:this._,f?this._:this._.parentNode);if(!this.U.dt){this.Z=null;this.U.ct&&this.U.ct.Gt()}this.Ft&&(this.Ft=null);return!0}Xt(t,e,i,l,s,n,r,o){let f=t.length,u=Array(f);for(let l=0;f>l;l++){let s=t[l];u[l]=i[null===e?s:e[s]]}let p=Array(f);for(let e=0;f>e;e++){let i=l[t[e]],s=h(i);if(void 0!==s)for(let t=0;f>t;t++){let l=u[t];if(null!==l&&l.key===s&&c(l,i)){u[t]=null;a(l,i)?this.Yt(l,i):this.qt(l,i);p[e]=l;break}}}for(let t=0;f>t;t++){let e=u[t];null!==e&&(e.p!==e.m?$.J(e.Qt()):e.p.remove())}for(let i=f-1;i>=0;i--){let f=t[i],h=null===e?f:e[f],u=p[i];void 0===u&&(u=this.te(l[f]));s[h]=u;let a=n>h+1?s[h+1].p:r;u.m.nextSibling===a&&u.p.parentNode===o||d(o,u,a)}}Bt(t){let e=this.yt||X,i=e.length,l=t.length,s=Array(l),n=0,r=i,o=l;for(;r>n&&o>n;){let i=e[n],l=t[n];if(!a(i,l))break;i.ie.ee&&this.Yt(i,l);s[n]=i;n++}for(;r>n&&o>n;){let i=e[r-1],l=t[o-1];if(!a(i,l))break;i.ie.ee&&this.Yt(i,l);s[--o]=i;r--}for(;r>n&&o>n;){let i=e[n],l=t[n];if(a(i,l))i.ie.ee&&this.Yt(i,l);else{if(!c(i,l))break;this.qt(i,l)}s[n]=i;n++}let f=r-n,h=o-n;if(f||h){if(f){for(let t=n;r>t;t++){let i=e[t];i.p!==i.m&&i.Qt()}let t=0===l&&0===n&&this.le(),i=this.zt??=new Z;for(let l=n;r>l;l++){let s=e[l];s.p!==s.m?$.J(s.Qt()):t||s.p.remove();s.u.h||i.$t(s.Vt,s,lt)}}if(h){let e=this.B,i=l>o?s[o].p:e?null:this._,r=e?this._:this._.parentNode;for(let e=n;o>e;e++){let l=this.se(t[e]);s[e]=l;d(r,l,i)}}if(!this.U.dt){this.Z=null;this.U.ct&&this.U.ct.Gt()}}this.yt=s;this.Ft&&(this.Ft=null)}Ut(t){let e=this.yt||X,i=e.length,l=t.length,s=Array(l),n=0,r=i,o=l;for(;r>n&&o>n;){let i=e[n],l=t[n];if(i.u===l)i.ie.ee&&this.Yt(i,l);else{if("string"==typeof l||i.key!==h(l)||!c(i,l))break;a(i,l)?this.Yt(i,l):this.qt(i,l)}s[n]=i;n++}for(;r>n&&o>n;){let i=e[r-1],l=t[o-1];if(i.u===l)i.ie.ee&&this.Yt(i,l);else{if("string"==typeof l||i.key!==h(l)||!c(i,l))break;a(i,l)?this.Yt(i,l):this.qt(i,l)}s[--o]=i;r--}let f=r-n,u=o-n;if(f||u){let i=this.B,p=i?this._:this._.parentNode,y=!1;if(f===u){let r=null,f=!0;for(let i=n;o>i;i++){let l=e[i],n=t[i];if(l.u===n)l.ie.ee&&this.Yt(l,n);else{let t=h(n);if(void 0===t||l.key!==t||!c(l,n)){(r??=[]).push(i);if(r.length>8){f=!1;break}continue}a(l,n)?this.Yt(l,n):this.qt(l,n)}s[i]=l}if(f){null!==r&&this.Xt(r,null,e,t,s,o,l>o?s[o].p:i?null:this._,p);y=!0}}if(!y){let y=0,m=!1,b=null,w=null;if(f&&u){let i=new Map;for(let e=n;o>e;e++){let l=t[e];"string"!=typeof l&&i.set(h(l),e)}b=Array(u).fill(-1);let l=-1;for(let o=n;r>o;o++){let r,f=e[o],h=void 0===f.key?void 0:i.get(f.key);if(void 0!==h&&-1===b[h-n]&&c(f,r=t[h])){b[h-n]=o;y++;l>h?m=!0:l=h;a(f,r)?this.Yt(f,r):this.qt(f,r);s[h]=f}else(w??=[]).push(f)}}let g=null,v=null;if(i&&0===n&&o===l&&0===y&&u>500&&p.isConnected&&null!==p.parentNode&&-1===p.localName.indexOf("-")&&!p.hasAttribute("is")){g=p.parentNode;v=p.nextSibling;p.remove()}let S=0!==f&&0===u;if((null!==w||S)&&(0!==n||o!==l||0!==y||!this.le())){S&&(w=e.slice(n,r));for(let t of w)t.p!==t.m&&t.Qt();for(let t of w)t.p!==t.m?$.J(t.Qt()):t.p.remove()}if(u){let e=l>o?s[o].p:i?null:this._;if(0===y)for(let i=n;o>i;i++){let l=this.te(t[i]);s[i]=l;d(p,l,e)}else{let i=m?(t=>{let e=[],i=Array(t.length);for(let l=0;t.length>l;l++){let s=t[l];if(-1===s)continue;let n=0,r=e.length;for(;r>n;){let i=n+r>>1;s>t[e[i]]?n=i+1:r=i}n>0&&(i[l]=e[n-1]);n===e.length?e.push(l):e[n]=l}let l=e.length;if(l){let t=e[l-1];for(;l-- >0;){e[l]=t;t=i[t]}}return e})(b):null,l=null!==i?i.length-1:-1;for(let r=o-1;r>=n;r--){let o=s[r];if(void 0===o){o=this.te(t[r]);s[r]=o;d(p,o,e)}else null!==i&&(0>l||i[l]!==r-n?d(p,o,e):l--);e=o.p}}}null!==g&&g.insertBefore(p,v)}if(!this.U.dt){this.Z=null;this.U.ct&&this.U.ct.Gt()}}this.yt=s;this.Ft&&(this.Ft=null)}te(t){if("string"==typeof t)return new wt(u(t),this);let e=new wt(t,this);e.ie.ee&&(this.Rt=!0);(t.exprs.length||e.ne&&e.ne.length)&&e.re(t.exprs);return e}Yt(t,e){let i=t.ie;i.oe?t.re(e.exprs,!1):i.fe&&i.he&&"string"!=typeof e&&this.qt(t,e)}qt(t,e){if("string"==typeof e){t.p.nodeValue=e;t.u.html[0]=e;t.Vt=e}else{if(t.ie.he){if(null!==t.ne||!t.ue(e)){let i=t.u.exprs,l=e.exprs,s=t.ne??t.ae();for(let t=s.length-1;t>=0;t--){let e=i[t],n=l[t];(e!==n&&!v(e,n)||s[t].X&&"boolean"==typeof n)&&s[t].et(n)}}t.styles&&t.ce();t.Z=null;t.dt=!1}else t.re(e.exprs);t.u=e;void 0!==e.key&&(t.key=e.key)}}se(t){let e;if("string"==typeof t){t=u(t);return new wt(t,this)}let i=this.zt;if(i){e=i.Pt(t.pe());if(e){this.qt(e,t);return e}}e=new wt(t,this);e.ie.ee&&(this.Rt=!0);(t.exprs.length||e.ne&&e.ne.length)&&e.re(t.exprs);return e}Jt(t,e,i){if(t instanceof Et)e.push(t);else if(Array.isArray(t))for(let l of t)l instanceof Et?e.push(l):i=this.Jt(l,e,i);else if("function"==typeof t)i=this.Jt(t(),e,i);else if(t instanceof Y){let i=t.items,l=t.jt;for(let t=0;i.length>t;t++)e.push(l(i[t]))}else if(t instanceof NodeList){for(let i of t)e.push(i);i=i||t.length>0}else if(t?.nodeType){if(11===t.nodeType)for(let i of[...t.childNodes])e.push(i);else e.push(t);i=!0}else{void 0===t||!1===t||null===t?t="":"string"!=typeof t&&(t+="");e.push(t)}return i}Kt(t){let e=this;e.de();let i=[],l=e.yt||X;e.yt=[];for(let l of t){"string"==typeof l&&(l=u(l));if(l instanceof Et){let t=e.ye(l);i.push(...t.Qt());e.yt.push(t)}else i.push(l)}let s=e.Qt();if(!$.C(s,i)){e.Z=i;this.U.ct&&this.U.ct.Gt();s.length&&!i.length&&e.le()||(e.B?y(e._,s,i,null):y(e._.parentNode,s,i,e._));for(let t of l)t.p.parentNode||$.J(t.Qt())}}Gt(){let t=this,e=this.B?this._:this._.parentNode;for(;t&&(t.B?t._:t._.parentNode)===e;){t.Z=null;t=t.U?.ct}}le(){if(this.B){this._.textContent="";return!0}let t=this.K.parentNode;if(this.K===t.firstChild&&this._===t.lastChild){t.innerHTML="";t.append(this.K,this._);return!0}return!1}ye(t){let e=t.pe(),i=this.Ft?.Pt(e)||this.zt?.Pt(e);if(i){g(i.u,t)?this.Yt(i,t):i.re(t.exprs);i.u=t}else{i=new wt(t,this);i.ie.ee&&(this.Rt=!0);i.re(t.exprs)}return i}de(){let t=this.Ft?.data;if(t){let e=(this.zt??=new Z).data;for(let i in t){let l=t[i],s=l.Lt||0,n=e[i];if(n)for(let t=s,e=lt+(n.Lt||0);l.length>t&&e>n.length;t++)n.push(l[t]);else{n=e[i]=s?l.slice(s):l;n.length>lt&&(n.length=lt)}}}let e=this.Ft=new Z;if(this.yt)for(let t of this.yt)e.add(t.Vt,t)}Qt(){let t;t=this.Z;if(t)return t;t=[];let e,i=null;if(this.B)e=this._.firstChild;else{e=this.K.nextSibling;i=this._}for(;e&&e!==i;){t.push(e);e=e.nextSibling}this.Z=t;return t}}const X=[],Q=256,tt=16,et=4,it=64,lt=1e4;let st=null,nt=-1;class rt extends j{et(t){this.U.key=t}}class ot extends j{me;be;constructor(t,e){super(null,e)}tt(i){let l=(t=>{const e=new Set;return JSON.stringify(t,(t,i)=>{if("function"==typeof i)return w(i);if("object"==typeof i&&null!==i){if(i instanceof Node)return w(i);if(e.has(i))return w(i);e.add(i);if(i instanceof Et)return{html:w(i.html),exprs:i.exprs}}return i})})(i),s=l!==this.be;this.be=l;let n=this._,r=$.R(n,"_is");for(let l,s=0;l=this.me[s];s++)if(!(l instanceof rt||l instanceof W))if(l instanceof M){let n=$.N(l.nt),o=l.lt(i[s]);!l.rt&&e(o)&&(o=t(o[0],o.slice(1)));r[n]=o}else{let t=l.lt(i[s]);if("object"==typeof t)for(let e in t)r[$.N(e)]=t[e];else if("string"==typeof t){let e=$.V(t);for(let t in e)r[$.N(t)]=e[t]}}let o=n.getAttribute("_is");if(n.tagName.endsWith("-SOLARITE-PLACEHOLDER")||o){let e=(o||n.tagName.slice(0,-21)).toLowerCase(),l=customElements.get(e);if(!l){this.we=i;if(!this.ge){this.ge=!0;console.warn(`Solarite: <${e}> is not defined yet; waiting for customElements.define().`);customElements.whenDefined(e).then(()=>{this.ge=!1;let t=this.we;this.we=null;t&&this._===n&&n.tagName.endsWith("-SOLARITE-PLACEHOLDER")&&this.tt(t)})}N.O=null;return}N.O=[...n.childNodes];let s=new l(r);o&&s.setAttribute("is",o);for(let t of n.attributes)"_is"!==t.name&&s.setAttribute(t.name,t.value);for(let t in r){let e=r[t],i=typeof e;"boolean"===i?e&&s.setAttribute(t,""):"string"!==i&&"number"!==i&&"bigint"!==i||s.setAttribute(t,e)}let f=s.getAttribute("data-id")||s.getAttribute("id");f&&t(this.U.wt(),f.split(/\./g),s);let h=this.U;this._=s;for(let t of h.ne){t._===n&&(t._=s);t.K===n&&(t.K=s)}h.p===n&&(h.p=s);h.m===n&&(h.m=s);"function"!=typeof s.render||N.k.has(s)||s.render(r,!0);for(let t,e=0;t=this.me[e];e++){t.U=this.U;t._=s;t.tt(i[e])}n.replaceWith(s)}else"function"==typeof n.render&&n.render(r,s);N.O=null}clone(t,e=0){let i=super.clone(t,e);i.me=this.me.map(i=>i.clone(t,e));return i}it(){return 0}}class ft{ve;ne=[];ids=[];styles=[];scripts=[];oe=!1;fe=!1;he=!1;ee=!1;Se=!1;l=-1;Ee=!1;Ae=!1;Vt;ke;xe;Te;Ne;Oe;$e;Le;Pe;je;constructor(t=null,e=!1){if(!t)return;if(1===t.length&&!t[0].match(/[<&]/)){this.ve=N.v.createTextNode(t[0]);return}let i,l=ft.Ce(t),s=N.v.createElement("template");if(l)if(e){s.innerHTML="<svg>"+l+"</svg>";let t=s.content.firstChild,e=N.v.createDocumentFragment();for(;t.firstChild;)e.append(t.firstChild);this.ve=e}else{s.innerHTML=l;this.ve=s.content}else{s.content.append(N.v.createTextNode(""));this.ve=s.content}m(this.ve);let n=[],r=0;const o=N.v.createTreeWalker(this.ve,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_COMMENT|NodeFilter.SHOW_TEXT);for(;i=o.nextNode();){n.map(t=>t.remove());n=[];if(1===i.nodeType){const t=i.hasAttribute("is"),l=t||i.tagName.includes("-"),s=[];for(let t of[...i.attributes]){if("key"===t.name){let e=t.value.split(/[\ue000-\uf8ff]/g);if(2!==e.length||""!==e[0]||""!==e[1])throw Error("Solarite: key must be one whole expression.");if(i.parentNode!==this.ve)throw Error("Solarite: key must be on a top-level element.");if(this.l>=0)throw Error("Solarite: duplicate key attribute.");this.l=t.value.charCodeAt(0)-yt;let n=new rt(null,i);this.ne.push(n);l&&s.push(n);r++;i.removeAttribute("key");continue}let n=t.name.match(/^[\ue000-\uf8ff]$/);if(n){let t=new U(null,i);this.ne.push(t);if(l){t.Y=!0;s.push(t)}r++;i.removeAttribute(n[0])}else{let n=t.value.split(/[\ue000-\uf8ff]/g);if(n.length>1){let o=2!==n.length||n[0].length||n[1].length?n:null,f=$.F(t.name)?new W(null,i,t.name,o):new M(null,i,t.name,o);f.X=$.G(i,t.name);this.ne.push(f);if(l){f.Y=!0;s.push(f)}r+=n.length-1;e||!o?i.removeAttribute(t.name):i.setAttribute(t.name,n.join(""))}}}if(l){let e=new ot(null,i);e.me=s;this.ne.splice(this.ne.length-s.length,0,e);if(t){i.setAttribute("_is",i.getAttribute("is"));i.removeAttribute("is")}}}else if(8===i.nodeType&&"!\u2728!"===i.nodeValue){if(i?.parentNode?.closest&&i?.parentNode?.closest("[contenteditable]"))throw Error('Solarite: no ${...} inside contenteditable; use value="${...}".');let t=i.parentNode;if(1!==t.nodeType||i.previousSibling||i.nextSibling||t.tagName.includes("-")||"SLOT"===t.tagName||t.hasAttribute("is")){let t,e=i.previousSibling;if(!e){e=N.v.createComment("Path:"+this.ne.length);i.parentNode.insertBefore(e,i)}if(!i.nextSibling||8===i.nextSibling.nodeType&&"!\u2728!"===i.nextSibling.textContent){t=i;t.textContent="PathEnd:"+this.ne.length}else{t=i.nextSibling;n.push(i)}let l=new q(e,t);this.ne.push(l);r++}else{let e=new q(null,t);e.B=!0;this.ne.push(e);r++;n.push(i)}}else if(8===i.nodeType){let t=i.textContent.split(/[\ue000-\uf8ff]/g);for(let e=0;t.length-1>e;e++){let t=new j(i.previousSibling,i);this.ne.push(t);r++}}else if(3===i.nodeType){let t=i.parentNode?.nodeName;if("TEXTAREA"===t&&i.textContent.includes(ht))throw Error('Solarite: no ${...} inside textarea; use value="${...}".');if("SCRIPT"===t||"STYLE"===t){let t=i.textContent.split(ht);if(t.length>1){for(let e=0;t.length>e;e++){let l=N.v.createTextNode(t[e]);i.parentNode.insertBefore(l,i);if(e>0){let t=new q(l.previousSibling,l);this.ne.push(t);r++}}n.push(i)}}}}n.map(t=>t.remove());if(r!==t.length-1)throw Error("Solarite: bad html or duplicate attribute: "+t.join("${...}"));for(let t of this.ne){t.ft=t.K?[].indexOf.call(t.K.parentNode.childNodes,t.K):-1;t.ot=j.get(t._)}this.Re();this.he=!0;for(let t of this.ne){if(t instanceof ot){this.oe=!0;this.he=!1}else 1!==t.it()&&(this.he=!1);t.X&&(this.fe=!0)}this.ee=this.oe||this.fe&&this.he;this.Me();if(this.Ee&&this.he){let t=[],e=!0;for(let i=0;this.ne.length>i;i++){let l=this.ne[i];if(l instanceof q){if(!l.B){e=!1;break}t.push(i)}else if(!(l instanceof M||l instanceof rt)){e=!1;break}}if(e){this.Ae=!0;this.Te=t;this.Ne=this.ne.map(t=>t.st(null,t._));let e=this.ne.length;this.Oe=new Uint8Array(e);this.$e=new Uint16Array(e);this.Le=Array(e).fill(null);this.je=new Uint8Array(e);let i=null;for(let t=0;e>t;t++){let e=this.ne[t],l=this.Ne[t];this.$e[t]=e.Ie;this.je[t]=(l.X?1:0)|(l.B?2:0);if(e instanceof rt)this.Oe[t]=1;else if(l.B)this.Oe[t]=2;else if(l instanceof W&&void 0!==l.gt&&!l.rt){this.Oe[t]=3;this.Le[t]=l;(i??=[]).push(l.kt)}else if(l instanceof M&&!l.rt&&!l.X&&!l.Y){this.Oe[t]=4;this.Le[t]=l.nt}}this.Pe=i}}}static Ce(t){let e="",i=!1,l=null;for(let s=0;t.length>s;s++){let n=t[s],r=0;for(let t=0;n.length>t;t++){const s=n[t];if(i)l?s===l&&(l=null):'"'===s||"'"===s?l=s:">"===s&&(i=!1);else if("<"===s&&n[t+1].match(/[/a-z!]/i)){i=!0;ut.lastIndex=t;let l=ut.exec(n);if(l){let i=t+l[0].length;e+=n.slice(r,i)+"-SOLARITE-PLACEHOLDER";r=i}}}e+=n.slice(r);t.length-1>s&&(e+=i?String.fromCharCode(yt+s):ht)}return e}Re(){this.scripts=[].map.call(this.ve.querySelectorAll("script"),t=>j.get(t));this.styles=[].map.call(this.ve.querySelectorAll("style"),t=>j.get(t));this.ids=[].map.call(this.ve.querySelectorAll("[id],[data-id]"),t=>j.get(t));this.Se=this.ids.length>0||this.styles.length>0||this.scripts.length>0}Me(){if(this.oe||!this.ne.length)return;let t=[],e=new Map,i=this.ve,l=1,s=n=>{if(n===i)return 0;let r=e.get(n);if(void 0===r){let i=0,o=-1;for(let t=n.previousSibling;t;t=t.previousSibling){i++;let l=e.get(t);if(void 0!==l){o=l;break}}let f=[].indexOf.call(n.parentNode.childNodes,n);0>o||i>f+1?t.push(s(n.parentNode),f):t.push(o,-i);r=l++;e.set(n,r)}return r};for(let t of this.ne){t.Ie=t._===i?0:s(t._);t.De=t.K?s(t.K):-1}this.ke=t;this.xe=Array(l);this.Se||1!==i.childNodes.length||1!==i.firstChild.nodeType||2>t.length||0!==t[0]||0!==t[1]||(this.Ee=!0)}static get(t,e=!1){if(t===ct&&e===pt)return dt;let i=N.j.get(t);if(!i){i={};N.j.set(t,i)}let l=e?"svg":"html",s=i[l];s||(s=i[l]=new ft(t,e));ct=t;pt=e;dt=s;return s}}const ht="\x3c!--!\u2728!--\x3e",ut=/<\/?[a-z][a-z0-9]*-[a-z0-9-]+/iy,at=["TABLE","THEAD","TBODY","TFOOT","TR"];let ct=null,pt=!1,dt=null;const yt=57344,mt=new ft,bt=Symbol();class wt{St;ct;p;m;ne=null;Vt;key;ie;dt=!0;Z;He=null;styles;u;constructor(t,e=null,i=null,l=null){this.St=e?.U?.St||this;this.ct=e;this.u=t;void 0!==t.key&&(this.key=t.key);if(t.h){this.ie=mt;this.Vt=t.pe();this.p=this.m=i||N.v.createTextNode(t.html[0])}else{const s=this.ie=ft.get(t.html,t.o);this.Vt=s.Vt??=t.pe();if(s.Ee&&null!==e){const t=s.ve.firstChild.cloneNode(!0);this.p=this.m=t;!0!==s.Ae&&this.Fe(t,s,0,!0)}else{const t=s.ve.cloneNode(!0);if(11===t.nodeType){this.p=t.firstChild;this.m=t.lastChild}else this.p=this.m=t;this.instantiate(s,t,i,l)}}}instantiate(t,e,i,l){t.ne.length?this.Fe(e,t):this.ne=[];t.Se&&this.ze(e,t)}re(t,e=!0,i=null){let l=this.ne;if(this.ie.he){if(e){if(null===l){this.Ge(t);return}for(let e=l.length-1;e>=0;e--){let s=l[e];null!==i&&s.q&&i[e]===t[e]||s.et(t[e])}this.styles&&this.ce();this.Z=null}this.dt=!1;return}if(!l){this.dt=!1;return}let s=t.length,n=Array(l.length);for(let i,r=l.length-1;i=l[r];r--){if(0===r&&i instanceof ot&&i._===this.wt())continue;let l=i.it();n[r]=t.slice(s-l,s);s-=l;if(i instanceof ot){let t=n.slice(r+1,r+1+i.me.length);i.tt(t)}else e&&i.tt(n[r])}if(e){this.ce();this.Z=null}this.dt=!1}Ge(t){let e=this.ie,i=e.Te;for(let l=0;i.length>l;l++){let s=typeof t[i[l]];if("string"!==s&&"number"!==s){let i=this.ae(e);for(let e=i.length-1;e>=0;e--)i[e].et(t[e]);this.Z=null;this.dt=!1;return}}let s=this.Ve(e),n=e.Oe,r=e.$e,o=e.Le,f=e.Ne,h=this.St,u=h.Et,a=h.vt?.eventDelegation,c="document"===a,p=void 0===a||!0===a||c,d=e.Pe;if(null!==d&&p&&h[bt]!==e){for(let t=0;d.length>t;t++)l(u,d[t],c);h[bt]=e}let y=this.dt;for(let e=n.length-1;e>=0;e--){let i=t[e],l=n[e];if(2===l){"number"==typeof i&&(i+="");s[r[e]].textContent=i}else if(3===l&&p&&("function"==typeof i||Array.isArray(i)&&"function"==typeof i[0])){let t=s[r[e]];t[o[e].gt]=i;t[F]=u}else if(4===l&&y&&"string"==typeof i)""!==i&&s[r[e]].setAttribute(o[e],i);else if(1===l)this.key=i;else{let t=f[e];t._=s[r[e]];t.U=this;t.et(i)}}this.Z=null;this.dt=!1}ue(t){let e=this.ie,i=t.exprs,l=e.Te;for(let t=0;l.length>t;t++){let e=typeof i[l[t]];if("string"!==e&&"number"!==e)return!1}let s=this.u.exprs,n=e.Ne,r=e.$e,o=e.je,f=this.He;for(let t=n.length-1;t>=0;t--){let l=s[t],h=i[t],u=o[t];if(l!==h&&!v(l,h)||1&u&&"boolean"==typeof h){null===f&&(f=this.He=this.Ve(e).slice());let l=n[t],s=f[r[t]];if(2&u){let e=i[t],n=s.firstChild;"number"==typeof e&&(e+="");if(null!==n&&3===n.nodeType&&n===s.lastChild)n.nodeValue=e;else{l._=s;l.U=this;l.et(i[t]);l.Dt=null;l.Ht=null;l.Z=null}continue}l._=s;l.U=this;l.et(i[t])}}return!0}Ve(t){let e=t.xe;e[1]=this.p;return b(e,t.ke,2,2)}ae(t=null){t??=this.ie;let e=this.We(t,this.Ve(t));for(let i of t.Te){let t=e[i],l=t._.firstChild;if(null!==l&&3===l.nodeType&&l===t._.lastChild){t.Dt=l;t.Ht=l.nodeValue}}return e}Qt(){let t=this.Z;if(t)return t;t=[];let e=this.p,i=this.m?.nextSibling;for(;e&&e!==i;){t.push(e);e=e.nextSibling}this.Z=t;return t}wt(){return this.St.Et}Fe(t,e,i=0,l=!1){let s=e.ke;if(s&&0===i){let i;if(l)i=this.Ve(e);else{i=e.xe;i[0]=t;b(i,s,0,1)}this.We(e,i)}else{let l=e.ne,s=l.length,n=this.ne=Array(s);for(let e=0;s>e;e++){let s=l[e].clone(t,i);s.U=this;n[e]=s}}}We(t,e){let i=t.ne,l=i.length,s=this.ne=Array(l);for(let t=0;l>t;t++){let l=i[t],n=l.st(0>l.De?null:e[l.De],e[l.Ie]);n.U=this;s[t]=n}return s}ce(){if(this.styles)for(let[t,e]of this.styles)e!==t.textContent&&$.I(t,this.St.Et)}ze(t,e,i=0){let l=this.St.Et;if(l){let s=this.St.vt;if(!1!==s?.ids)for(let s of e.ids){let e=j.resolve(t,s,i);$.M(l,e)}if(!1!==s?.styles){e.styles.length&&(this.styles=new Map);for(let s of e.styles){let e=j.resolve(t,s,i);if(1===l.nodeType){$.I(e,l);this.styles.set(e,e.textContent)}}}if(!1!==s?.scripts)for(let l of e.scripts){let e=j.resolve(t,l,i);(0,eval)(e.textContent)}}}}class gt extends wt{instantiate(t,e,i,l){let s=0;this.vt=l;if(e instanceof Text){if(!i)throw Error("Text node needs an element.");this.Et=i;e.nodeValue.length&&this.Et.append(e)}else{if(i){this.Et=i;let t;if(N.O||i.childNodes.length){t=N.v.createDocumentFragment();t.append(...N.O||i.childNodes)}if(r=this.Et.tagName,1===(n=e).children.length&&r.includes("-")&&n.children[0].tagName.replace("-SOLARITE-PLACEHOLDER","")===r){this.Et.append(...e.children[0].childNodes);for(let t of e.children[0].attributes)this.Et.hasAttribute(t.name)||this.Et.setAttribute(t.name,t.value);s=1}else 1===e.childNodes.length&&3===e.childNodes[0].nodeType&&""===e.childNodes[0].textContent||this.Et.append(...e.childNodes);if(t){for(let e of i.querySelectorAll("slot[name]")){let i=e.getAttribute("name");if(i){let l=t.querySelectorAll(`[slot='${i}']`);e.append(...l)}}let e=i.querySelector("slot:not([name])");e?e.append(t):i.append(t)}}else{let t=$.S(e.childNodes),i=1===t.length?t[0]:null;this.Et=i||e;i&&(s=1)}this.Fe(this.Et,t,s);this.ze(this.Et,t,s)}var n,r;this.p=this.m=this.Et;N.P.set(this.Et,this)}}let vt=1,St=new WeakMap;class Et{exprs=void 0;html=void 0;Vt;h;key;o=!1;constructor(t=[""],e=[]){this.html=t;this.exprs=e}render(t=null,e={}){let i=t&&N.P.get(t);if(!i){i=new gt(this,null,t,e);t||(t=i.wt())}if(1!==this.html?.length||this.html[0]){let t=i.u;i.re(this.exprs,!0,t!==this&&t.html===this.html?t.exprs:null);i.u=this}else t.innerHTML="";return t}pe(){void 0===this.Vt&&(this.Vt=this.exprs.length?w(this.html):this.html[0]);return this.Vt}}let At="render";const kt=Symbol(),xt=Symbol();A.immutableMap=A.map=(t,e)=>new Y(t,e);A.selector=(t=null)=>new R(t);let Tt=new Proxy(HTMLElement,{construct(t,e,i){$.i(i);return Reflect.construct(t,e,i)}});class Nt extends Tt{constructor(t=null,e=null){super();if(t){if("object"!=typeof t)throw Error("First argument must be an object.");if(!Object.keys(t).length){let e=Nt.getAttribs(this);for(let i in e)t[i]=e[i]}for(let i in e||{})"string"==typeof t[i]&&(t[i]=k(t[i],e[i]))}}render(){throw Error("render() is not defined for "+this.constructor.name)}renderFirstTime(){if(!N.k.has(this)){let t=Nt.getAttribs(this);this.render(t)}}connectedCallback(){this.renderFirstTime()}static define(t=null){$.i(this,t)}static getAttribs(t){let e=$.R(t);for(let t in e){let i=e[t];i.startsWith("${")&&i.endsWith("}")&&(e[t]=JSON.parse(i.slice(2,-1)))}return e}}export default A;export{J as Fragment,N as Globals,K as InternalJsxAttr,Y as MappedList,R as Selector,C as SelectorRef,Nt as Solarite,$ as SolariteUtil,Et as Template,x as assignAttributes,k as convertType,t as delve,i as getEventBinding,A as h,o as internalJsxToTemplate,E as svg,S as toEl};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
// Generated by build/build.js from src/jsx-runtime.js — do not edit.
|
|
2
|
+
/**
|
|
3
|
+
* Solarite JSX runtime. Configure your toolchain with `jsxImportSource: "solarite"` (automatic
|
|
4
|
+
* runtime) or have Deno's `jsx:"precompile"` / a Solarite build plugin target this module.
|
|
5
|
+
*
|
|
6
|
+
* Tier 1 (precompile): jsxTemplate/jsxAttr/jsxEscape map hoisted statics straight onto Template.
|
|
7
|
+
* Tier 2 (automatic): jsx/jsxs/jsxDEV build a Template per render via the shape-interning factory.
|
|
8
|
+
*
|
|
9
|
+
* See src/jsx.js for the shared core (jsxToTemplate, JsxAttr, Fragment). */
|
|
10
|
+
import {Template} from './Solarite.js';
|
|
11
|
+
import {InternalJsxAttr as JsxAttr, internalJsxToTemplate as jsxToTemplate,
|
|
12
|
+
Fragment} from './Solarite.js';
|
|
13
|
+
|
|
14
|
+
export {Fragment};
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Tier 1: build a Template from hoisted static strings and expression holes, with the statics'
|
|
18
|
+
* stable array identity feeding Shell cache / NodeGroup reuse just like a tagged template.
|
|
19
|
+
* @param strings {string[]} Module-hoisted static html (same array every render).
|
|
20
|
+
* @param exprs {...*} jsxAttr() pairs, jsxEscape() children, and bare boolean-attr strings.
|
|
21
|
+
* @return {Template} */
|
|
22
|
+
export function jsxTemplate(strings, ...exprs) {
|
|
23
|
+
let key;
|
|
24
|
+
for (let i = 0; i < exprs.length; i++) {
|
|
25
|
+
let e = exprs[i];
|
|
26
|
+
// A `key` prop arrives as jsxAttr("key", value) at an attribute hole. Lift it onto the
|
|
27
|
+
// Template for keyed diffing and blank the hole so it never renders as an attribute.
|
|
28
|
+
if (e instanceof JsxAttr && e.name === 'key') {
|
|
29
|
+
key = e.value;
|
|
30
|
+
exprs[i] = '';
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
let t = new Template(strings, exprs);
|
|
34
|
+
if (key !== undefined)
|
|
35
|
+
t.key = key;
|
|
36
|
+
return t;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Tier 1: a whole-attribute hole, e.g. `<a ` + jsxAttr("href", v) + `>`. PathToAttribs detects
|
|
41
|
+
* this and routes the value through normal attribute/event/property application.
|
|
42
|
+
* @param name {string}
|
|
43
|
+
* @param value {*}
|
|
44
|
+
* @return {JsxAttr} */
|
|
45
|
+
export function jsxAttr(name, value) {
|
|
46
|
+
return new JsxAttr(name, value);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Tier 1: a child hole. Solarite already html-escapes child expressions (strings render as text,
|
|
51
|
+
* Templates/arrays as nodes), so this is the identity function.
|
|
52
|
+
* @param value {*}
|
|
53
|
+
* @return {*} */
|
|
54
|
+
export function jsxEscape(value) {
|
|
55
|
+
return value;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Tier 2 automatic runtime: a single-child element. props.children is one child hole.
|
|
60
|
+
* @param tag {string|Function|symbol}
|
|
61
|
+
* @param props {Object}
|
|
62
|
+
* @param key {*}
|
|
63
|
+
* @return {Template} */
|
|
64
|
+
export function jsx(tag, props, key) {
|
|
65
|
+
props = props || {};
|
|
66
|
+
let children = ('children' in props) ? [props.children] : [];
|
|
67
|
+
return jsxToTemplate(tag, props, children, key);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Tier 2 automatic runtime: multiple static children. props.children is the children array.
|
|
72
|
+
* @param tag {string|Function|symbol}
|
|
73
|
+
* @param props {Object}
|
|
74
|
+
* @param key {*}
|
|
75
|
+
* @return {Template} */
|
|
76
|
+
export function jsxs(tag, props, key) {
|
|
77
|
+
props = props || {};
|
|
78
|
+
let children = props.children;
|
|
79
|
+
children = Array.isArray(children) ? children : (children === undefined ? [] : [children]);
|
|
80
|
+
return jsxToTemplate(tag, props, children, key);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** Dev variant (extra source/self args are ignored). */
|
|
84
|
+
export function jsxDEV(tag, props, key) {
|
|
85
|
+
return jsx(tag, props, key);
|
|
86
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "solarite",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Solarite is a small (
|
|
3
|
+
"version": "0.8.0",
|
|
4
|
+
"description": "Solarite is a small (12.4KB with Brotli), fast, compilation-free JavaScript library that makes native web components fast to update, patching only the DOM that actually changed when you call render().",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/Solarite.js",
|
|
7
7
|
"module": "dist/Solarite.js",
|
|
@@ -14,13 +14,13 @@
|
|
|
14
14
|
},
|
|
15
15
|
"./jsx-runtime": {
|
|
16
16
|
"types": "./src/jsx-runtime.d.ts",
|
|
17
|
-
"import": "./
|
|
18
|
-
"default": "./
|
|
17
|
+
"import": "./dist/jsx-runtime.js",
|
|
18
|
+
"default": "./dist/jsx-runtime.js"
|
|
19
19
|
},
|
|
20
20
|
"./jsx-dev-runtime": {
|
|
21
21
|
"types": "./src/jsx-dev-runtime.d.ts",
|
|
22
|
-
"import": "./
|
|
23
|
-
"default": "./
|
|
22
|
+
"import": "./dist/jsx-dev-runtime.js",
|
|
23
|
+
"default": "./dist/jsx-dev-runtime.js"
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
26
|
"files": [
|
|
@@ -32,11 +32,12 @@
|
|
|
32
32
|
"packages/*"
|
|
33
33
|
],
|
|
34
34
|
"scripts": {
|
|
35
|
-
"test": "
|
|
35
|
+
"test": "deno run --node-modules-dir=none -A tests/Testimony.js --headless --webroot=../ --page=tests/index.html",
|
|
36
|
+
"test:plugins": "npm test -w babel-plugin-solarite -w esbuild-plugin-solarite -w vite-plugin-solarite"
|
|
36
37
|
},
|
|
37
38
|
"repository": {
|
|
38
39
|
"type": "git",
|
|
39
|
-
"url": "git+https://github.com/
|
|
40
|
+
"url": "git+https://github.com/eric-frost/solarite.git"
|
|
40
41
|
},
|
|
41
42
|
"keywords": [
|
|
42
43
|
"JavaScript",
|
|
@@ -51,7 +52,7 @@
|
|
|
51
52
|
"author": "Eric Frost",
|
|
52
53
|
"license": "MIT",
|
|
53
54
|
"bugs": {
|
|
54
|
-
"url": "https://github.com/
|
|
55
|
+
"url": "https://github.com/eric-frost/solarite/issues"
|
|
55
56
|
},
|
|
56
|
-
"homepage": "https://
|
|
57
|
+
"homepage": "https://eric-frost.github.io/solarite/"
|
|
57
58
|
}
|
package/readme.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# Solarite
|
|
2
2
|
|
|
3
|
-
Solarite makes native web components fast to update, with no build step and no signals. You write plain JavaScript and call `render()` when your data changes; Solarite then patches only the DOM that actually changed. It's
|
|
3
|
+
Solarite makes native web components fast to update, with no build step and no signals. You write plain JavaScript and call `render()` when your data changes; Solarite then patches only the DOM that actually changed. It's small (12.4KB with Brotli) and runs straight in the browser as a standard ES module.
|
|
4
4
|
|
|
5
|
-
**[Documentation & live examples →](https://
|
|
5
|
+
**[Documentation & live examples →](https://eric-frost.github.io/solarite/)**
|
|
6
6
|
|
|
7
7
|
## Install
|
|
8
8
|
|
|
@@ -14,7 +14,7 @@ Or use it with no build step at all, straight from a CDN:
|
|
|
14
14
|
|
|
15
15
|
```javascript
|
|
16
16
|
import h, {Solarite} from
|
|
17
|
-
'https://cdn.jsdelivr.net/npm/solarite@0.
|
|
17
|
+
'https://cdn.jsdelivr.net/npm/solarite@0.8.0/dist/Solarite.min.js';
|
|
18
18
|
```
|
|
19
19
|
|
|
20
20
|
## Example
|
|
@@ -40,18 +40,18 @@ document.body.append(new Counter());
|
|
|
40
40
|
|
|
41
41
|
## Why Solarite?
|
|
42
42
|
|
|
43
|
-
It's one of the fastest UI libraries measured: a score of **1.
|
|
43
|
+
It's one of the fastest UI libraries measured: a score of **1.10** on the [js-framework-benchmark](https://krausest.github.io/js-framework-benchmark/current.html) — about 10% slower than hand-written vanilla JavaScript — while staying tiny and build-free.
|
|
44
44
|
|
|
45
45
|
### Compared to Lit
|
|
46
46
|
|
|
47
|
-
Lit is
|
|
47
|
+
[Lit](https://lit.dev/) is a popular library for building web components. Here's where Solarite differs:
|
|
48
48
|
|
|
49
49
|
- **Scoped CSS without Shadow DOM.** Solarite scopes each component's `<style>` in the light DOM, so global stylesheets, form participation, and third-party CSS still reach your elements. There's no Shadow DOM boundary to work around.
|
|
50
50
|
- **No reactivity system to learn.** No signals, no `@property` decorators, no reactive controllers. Mutate plain JavaScript objects and arrays of any depth, then call `render()`. Updates happen exactly when you ask for them.
|
|
51
|
-
- **Truly build-free.**
|
|
52
|
-
- **Closer to vanilla speed.** Solarite sits near the top of the benchmark, ahead of most signal-based and virtual-DOM libraries.
|
|
51
|
+
- **Truly build-free.** You can optionally use the Solarite JSX plugins for Babel, esbuild, and Vite, but Solarite is still elegant to use in vanilla JS with a single import statement.
|
|
52
|
+
- **Closer to vanilla speed.** Solarite sits near the top of the [js-framework-benchmark](https://krausest.github.io/js-framework-benchmark/current.html), ahead of most signal-based and virtual-DOM libraries.
|
|
53
53
|
|
|
54
|
-
The trade-off is deliberate: Solarite re-renders when you call `render()` rather than tracking dependencies automatically.
|
|
54
|
+
The trade-off is deliberate: Solarite re-renders when you call `render()` rather than tracking dependencies automatically.
|
|
55
55
|
|
|
56
56
|
## License
|
|
57
57
|
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A list of items plus the function that builds one item's Template, as returned by h.map().
|
|
3
|
+
*
|
|
4
|
+
* Handing the reconciler the source items instead of an array of Templates is what makes
|
|
5
|
+
* h.map() cheap on a long list: a row whose item is the same object it was built from needs
|
|
6
|
+
* neither a Template built for it nor a cache lookup to find one, just an identity check
|
|
7
|
+
* against the item the row already remembers. Rows that moved are recognized too — see
|
|
8
|
+
* PathToNodes.applyMapped(), which follows a shifted list's offset and, failing that, matches
|
|
9
|
+
* items against the Templates the previous render built.
|
|
10
|
+
*/
|
|
11
|
+
export default class MappedList {
|
|
12
|
+
|
|
13
|
+
/** @type {Array} */
|
|
14
|
+
items;
|
|
15
|
+
|
|
16
|
+
/** @type {function(*):Template} */
|
|
17
|
+
fn;
|
|
18
|
+
|
|
19
|
+
constructor(items, fn) {
|
|
20
|
+
this.items = items;
|
|
21
|
+
this.fn = fn;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Yield the Templates, building each one as it goes, so that code written against the older
|
|
26
|
+
* array-returning h.map() — spreading it, iterating it, passing it to Array.from — still
|
|
27
|
+
* works. Doing so builds every row, which is exactly the work the reconciler skips when the
|
|
28
|
+
* list is handed to it whole, so prefer putting an h.map() straight into a template. */
|
|
29
|
+
*[Symbol.iterator]() {
|
|
30
|
+
let items = this.items, fn = this.fn;
|
|
31
|
+
for (let i=0; i<items.length; i++)
|
|
32
|
+
yield fn(items[i]);
|
|
33
|
+
}
|
|
34
|
+
}
|
package/src/MultiValueMap.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Maps a string key to multiple values.
|
|
3
3
|
* Values are stored in arrays because pushing them is much faster than Set operations,
|
|
4
4
|
* and deleteAny() needs no iterator allocation.
|
|
5
|
-
* deleteAny() returns values first-in-first-out by advancing a head index (array.
|
|
5
|
+
* deleteAny() returns values first-in-first-out by advancing a head index (array.hd)
|
|
6
6
|
* instead of calling shift(), which would be O(n). */
|
|
7
7
|
export default class MultiValueMap {
|
|
8
8
|
|
|
@@ -30,7 +30,7 @@ export default class MultiValueMap {
|
|
|
30
30
|
let array = data[key]
|
|
31
31
|
if (!array)
|
|
32
32
|
data[key] = [value];
|
|
33
|
-
else if (array.length - (array.
|
|
33
|
+
else if (array.length - (array.hd || 0) < max)
|
|
34
34
|
array.push(value);
|
|
35
35
|
}
|
|
36
36
|
|
|
@@ -44,13 +44,13 @@ export default class MultiValueMap {
|
|
|
44
44
|
if (!array) // slower than pre-check.
|
|
45
45
|
return undefined;
|
|
46
46
|
|
|
47
|
-
let head = array.
|
|
47
|
+
let head = array.hd || 0;
|
|
48
48
|
let result = array[head];
|
|
49
49
|
head++;
|
|
50
50
|
if (head >= array.length)
|
|
51
51
|
delete data[key];
|
|
52
52
|
else
|
|
53
|
-
array.
|
|
53
|
+
array.hd = head;
|
|
54
54
|
|
|
55
55
|
return result;
|
|
56
56
|
}
|