solarite 0.3.1 → 0.3.2

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.
@@ -1106,9 +1106,6 @@ class ExprPath {
1106
1106
  if (!ng.startNode.parentNode)
1107
1107
  ng.removeAndSaveOrphans();
1108
1108
 
1109
-
1110
-
1111
-
1112
1109
  // Instantiate components created within ${...} expressions.
1113
1110
  // Embedded style tags are handled elsewhere, but where?
1114
1111
  for (let el of newNodes) {
@@ -1318,16 +1315,30 @@ class ExprPath {
1318
1315
  Globals$1.currentExprPath = null;
1319
1316
  }
1320
1317
 
1321
- let attrs = (expr +'') // Split string into multiple attributes.
1322
- .split(/([\w-]+\s*=\s*(?:"[^"]*"|'[^']*'|[^\s]+))/g)
1323
- .map(text => text.trim())
1324
- .filter(text => text.length);
1318
+ // Attribute as name: value object.
1319
+ if (typeof expr === 'object') {
1320
+ for (let name in expr) {
1321
+ let value = expr[name];
1322
+ if (value === undefined || value === false || value === null)
1323
+ continue;
1324
+ node.setAttribute(name, value);
1325
+ this.attrNames.add(name);
1326
+ }
1327
+ }
1325
1328
 
1326
- for (let attr of attrs) {
1327
- let [name, value] = attr.split(/\s*=\s*/); // split on first equals.
1328
- value = (value || '').replace(/^(['"])(.*)\1$/, '$2'); // trim value quotes if they match.
1329
- node.setAttribute(name, value);
1330
- this.attrNames.add(name);
1329
+ // Attributes as string
1330
+ else {
1331
+ let attrs = (expr + '') // Split string into multiple attributes.
1332
+ .split(/([\w-]+\s*=\s*(?:"[^"]*"|'[^']*'|[^\s]+))/g)
1333
+ .map(text => text.trim())
1334
+ .filter(text => text.length);
1335
+
1336
+ for (let attr of attrs) {
1337
+ let [name, value] = attr.split(/\s*=\s*/); // split on first equals.
1338
+ value = (value || '').replace(/^(['"])(.*)\1$/, '$2'); // trim value quotes if they match.
1339
+ node.setAttribute(name, value);
1340
+ this.attrNames.add(name);
1341
+ }
1331
1342
  }
1332
1343
  }
1333
1344
 
@@ -2616,24 +2627,24 @@ class NodeGroup {
2616
2627
  if (!Constructor)
2617
2628
  throw new Error(`The custom tag name ${tagName} is not registered.`)
2618
2629
 
2619
- let args = {};
2630
+ let attribs = {};
2620
2631
  for (let name in props || {})
2621
- args[Util.dashesToCamel(name)] = props[name];
2632
+ attribs[Util.dashesToCamel(name)] = props[name];
2622
2633
 
2623
2634
  // Pass other attribs to constructor, since otherwise they're not yet set on the element,
2624
2635
  // and the constructor would otherwise have no way to see them.
2625
2636
  if (el.attributes.length) {
2626
2637
  for (let attrib of el.attributes) {
2627
2638
  let attribName = Util.dashesToCamel(attrib.name);
2628
- if (!args.hasOwnProperty(attribName) && attribName !== 'solarite-placeholder')
2629
- args[attribName] = attrib.value;
2639
+ if (!attribs.hasOwnProperty(attribName) && attribName !== 'solarite-placeholder')
2640
+ attribs[attribName] = attrib.value;
2630
2641
  }
2631
2642
  }
2632
2643
 
2633
2644
  // Create the web component.
2634
2645
  // Get the children that aren't Solarite's comment placeholders.
2635
- let ch = [...el.childNodes].filter(node => node.nodeType !== Node.COMMENT_NODE || !node.nodeValue.startsWith('ExprPath'));
2636
- let newEl = new Constructor(args, ch);
2646
+ let children = [...el.childNodes].filter(node => node.nodeType !== Node.COMMENT_NODE || !node.nodeValue.startsWith('ExprPath'));
2647
+ let newEl = new Constructor(attribs, children);
2637
2648
 
2638
2649
  if (!isPreHtmlElement)
2639
2650
  newEl.setAttribute('is', el.getAttribute('is').toLowerCase());
package/dist/Solarite.js CHANGED
@@ -994,9 +994,6 @@ class ExprPath {
994
994
  if (!ng.startNode.parentNode)
995
995
  ng.removeAndSaveOrphans();
996
996
 
997
-
998
-
999
-
1000
997
  // Instantiate components created within ${...} expressions.
1001
998
  // Embedded style tags are handled elsewhere, but where?
1002
999
  for (let el of newNodes) {
@@ -1204,16 +1201,30 @@ class ExprPath {
1204
1201
  Globals$1.currentExprPath = null;
1205
1202
  }
1206
1203
 
1207
- let attrs = (expr +'') // Split string into multiple attributes.
1208
- .split(/([\w-]+\s*=\s*(?:"[^"]*"|'[^']*'|[^\s]+))/g)
1209
- .map(text => text.trim())
1210
- .filter(text => text.length);
1204
+ // Attribute as name: value object.
1205
+ if (typeof expr === 'object') {
1206
+ for (let name in expr) {
1207
+ let value = expr[name];
1208
+ if (value === undefined || value === false || value === null)
1209
+ continue;
1210
+ node.setAttribute(name, value);
1211
+ this.attrNames.add(name);
1212
+ }
1213
+ }
1211
1214
 
1212
- for (let attr of attrs) {
1213
- let [name, value] = attr.split(/\s*=\s*/); // split on first equals.
1214
- value = (value || '').replace(/^(['"])(.*)\1$/, '$2'); // trim value quotes if they match.
1215
- node.setAttribute(name, value);
1216
- this.attrNames.add(name);
1215
+ // Attributes as string
1216
+ else {
1217
+ let attrs = (expr + '') // Split string into multiple attributes.
1218
+ .split(/([\w-]+\s*=\s*(?:"[^"]*"|'[^']*'|[^\s]+))/g)
1219
+ .map(text => text.trim())
1220
+ .filter(text => text.length);
1221
+
1222
+ for (let attr of attrs) {
1223
+ let [name, value] = attr.split(/\s*=\s*/); // split on first equals.
1224
+ value = (value || '').replace(/^(['"])(.*)\1$/, '$2'); // trim value quotes if they match.
1225
+ node.setAttribute(name, value);
1226
+ this.attrNames.add(name);
1227
+ }
1217
1228
  }
1218
1229
  }
1219
1230
 
@@ -2421,24 +2432,24 @@ class NodeGroup {
2421
2432
  if (!Constructor)
2422
2433
  throw new Error(`The custom tag name ${tagName} is not registered.`)
2423
2434
 
2424
- let args = {};
2435
+ let attribs = {};
2425
2436
  for (let name in props || {})
2426
- args[Util.dashesToCamel(name)] = props[name];
2437
+ attribs[Util.dashesToCamel(name)] = props[name];
2427
2438
 
2428
2439
  // Pass other attribs to constructor, since otherwise they're not yet set on the element,
2429
2440
  // and the constructor would otherwise have no way to see them.
2430
2441
  if (el.attributes.length) {
2431
2442
  for (let attrib of el.attributes) {
2432
2443
  let attribName = Util.dashesToCamel(attrib.name);
2433
- if (!args.hasOwnProperty(attribName) && attribName !== 'solarite-placeholder')
2434
- args[attribName] = attrib.value;
2444
+ if (!attribs.hasOwnProperty(attribName) && attribName !== 'solarite-placeholder')
2445
+ attribs[attribName] = attrib.value;
2435
2446
  }
2436
2447
  }
2437
2448
 
2438
2449
  // Create the web component.
2439
2450
  // Get the children that aren't Solarite's comment placeholders.
2440
- let ch = [...el.childNodes].filter(node => node.nodeType !== Node.COMMENT_NODE || !node.nodeValue.startsWith('ExprPath'));
2441
- let newEl = new Constructor(args, ch);
2451
+ let children = [...el.childNodes].filter(node => node.nodeType !== Node.COMMENT_NODE || !node.nodeValue.startsWith('ExprPath'));
2452
+ let newEl = new Constructor(attribs, children);
2442
2453
 
2443
2454
  if (!isPreHtmlElement)
2444
2455
  newEl.setAttribute('is', el.getAttribute('is').toLowerCase());
@@ -1,4 +1,4 @@
1
- // Version 2025.7.20.0141
1
+ // Version 2025.7.28.0000
2
2
  // License: MIT
3
3
  // http://vorticode.github.io/solarite
4
- let lastObjectId=1,objectIds=new WeakMap;function getObjectId(t){let e=objectIds.get(t);return e||(e="~\f"+lastObjectId++,objectIds.set(t,e)),e}let isHashing=!0;function toJSON(){return isHashing?getObjectId(this):this}function getObjectHash(t){let e;Node.prototype.toJSON!==toJSON&&(Node.prototype.toJSON=toJSON,(()=>{}).toJSON!==toJSON&&(Function.prototype.toJSON=toJSON)),isHashing=!0;try{e=JSON.stringify(t)}catch(l){e=getObjectHashCircular(t)}return isHashing=!1,e}function getObjectHashCircular(t){const e=new Set;return JSON.stringify(t,((t,l)=>{if("object"==typeof l&&null!==l){if(e.has(l))return getObjectId(l);e.add(l)}return l}))}var Globals;function reset(){Globals={t:new WeakMap,connected:new WeakSet,l:null,div:document.createElement("div"),i:{},o:{},h:new WeakMap,u:new WeakMap,p:new WeakMap,m:new WeakSet,v:new WeakSet,P:new WeakMap,reset,count:0}}reset();var Globals$1=Globals;function delve(t,e,l=d){let s=l!==d,i=e.length;if(!t&&!s&&i)return;let r=0;for(let o of e){if(void 0===t[o]){if(!s)return;i-1>r&&(t[o]=(e[r+1]+"").match(/^\d+$/)?[]:{})}s&&r===i-1&&(t[o]=l),t=t[o],r++}return t}let d={},Util={$(t,e){let l=t.length;if(l!==e.length)return!1;for(let s=0;l>s;s++)if(t[s]!==e[s])return!1;return!0},N(t,e){let l=e.getAttribute("data-id")||e.getAttribute("id");if(l){if(t[l]&&!(t[l]instanceof Node))throw Error(`${t.constructor.name}.${l} already has a value. Can't set it as a reference to <${e.tagName.toLowerCase()} id="${l}">`);delve(t,l.split(/\./g),e)}},T(t,e){let l=e.getAttribute("data-style");l||(e.constructor.G||(e.constructor.G=1),l=e.constructor.G++,e.setAttribute("data-style",l));let s=e.tagName.toLowerCase();for(let e of t.childNodes)if(3===e.nodeType){let t=e.textContent,i=t.replace(/:host(?=[^a-z0-9_])/gi,`${s}[data-style="${l}"]`);t!==i&&(e.textContent=i)}},A: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(),S:t=>t.replace(/-([a-z])/g,(t=>t[1].toUpperCase())),H:t=>"checkbox"===t.type||"radio"===t.type?t.checked:"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.value,O:t=>t.startsWith("on")&&t in Globals$1.div,C(t,e){let l=t.tagName+"."+e,s=Globals$1.o[l];if(void 0===s){let i=Object.getPrototypeOf(t);for(;i;){const t=i.constructor.name;if(t.startsWith("HTML")&&t.endsWith("Element"))break;i=Object.getPrototypeOf(i)}Globals$1.o[l]=s=!!i&&!!Object.getOwnPropertyDescriptor(i,e)?.set}return s},k:t=>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)),M:t=>void 0===t||!1===t||null===t,j:t=>"function"==typeof t?Util.j(t()):t instanceof Date?t.toISOString().replace(/T/," "):Array.isArray(t)||"object"==typeof t?"":t,U(t,e,l){let s=t.get(e);s?s.push(l):(s=[l],t.set(e,s))},I(t){const e=t=>t.nodeType!==Node.ELEMENT_NODE&&(t.nodeType!==Node.TEXT_NODE||""===t.textContent.trim()),l=[...t];for(;l.length>0&&e(l[0]);)l.shift();for(;l.length>0&&e(l[l.length-1]);)l.pop();return l}};class MultiValueMap{data={};add(t,e){let l=this.data,s=l[t];s||(s=new Set,l[t]=s),s.add(e)}F(){for(let t in this.data)return!0;return!1}getAll(t){return this.data[t]||[]}delete(t,e=void 0){let l,s=this.data,i=s[t];if(i)return void 0===e?([l]=i,i.delete(l)):(i.delete(e),l=e),0===i.size&&delete s[t],l}R(t){let e,l=this.data,s=l[t];if(s)return[e]=s,s.delete(e),0===s.size&&delete l[t],e}V(t,e){let l,s=this.data,i=s[t];if(i)return i.delete(e),l=e,0===i.size&&delete s[t],l}J(t){let e=this.data,l=[];for(let s in e)e[s].has(t)&&l.push(s);return l}}const udomdiff=(t,e,l,s)=>{const i=l.length;let r=e.length,o=i,a=0,n=0,h=null;for(;r>a||o>n;)if(r===a){const e=i>o?n?l[n-1].nextSibling:l[o-n]:s;for(;o>n;){let s=l[n++];t.insertBefore(s,e)}}else if(o===n)for(;r>a;){let l=e[a];h&&h.has(l)||t.removeChild(l),a++}else if(e[a]===l[n])a++,n++;else if(e[r-1]===l[o-1])r--,o--;else if(e[a]===l[o-1]&&l[n]===e[r-1]){const s=e[--r].nextSibling;let i=l[n++],h=e[a++];t.insertBefore(i,h.nextSibling);let f=l[--o];t.insertBefore(f,s),e[r]=l[o]}else{if(!h){h=new Map;let t=n;for(;o>t;)h.set(l[t],t++)}if(h.has(e[a])){const s=h.get(e[a]);if(s>n&&o>s){let i=a,f=1;for(;++i<r&&o>i&&h.get(e[i])===s+f;)f++;if(f>s-n){const i=e[a];for(;s>n;){let e=l[n++];t.insertBefore(e,i)}}else{let s=e[a++],i=l[n++];t.replaceChild(i,s)}}else a++}else{let l=e[a++];t.removeChild(l)}}return l};class ExprPath{type;attrName;L;W;D;_;B;u=[];K;Z;q;X;Y;tt=void 0;constructor(t,e,l=ExprPathType.et,s=null,i=null){this.D=t,this._=e,this.type=l,this.attrName=s,this.L=i,l===ExprPathType.lt&&(this.W=new Set)}apply(t,e=!0){switch(this.type){case 1:this.st(t[0],e);break;case 2:this.it(this._,t[0]);break;case 5:break;case 6:this.rt(this._,t[0],this.B.ot.root);break;default:this.nt(this._,t)}}st(t,e=!0){let l=this;e&&l.ht();let s=[],i=l.u,r=[];l.u=[],l.ft(t,s,r);let o=!1;if(r.length){for(let[t,e]of r){let i=l.ut(s[t],!1),r=i.ct();1===r.length?s[t]=r[0]:(s[t]=r,o=!0),l.u[e]=i}o&&(s=s.flat())}let a=l.ct();if(!Util.$(a,s)){l.K=s,this.B.dt&&this.B.dt.bt(),a.length&&!s.length&&l.yt()||udomdiff(l._.parentNode,a,s,l._);for(let t of i)t.gt.parentNode||t.vt();for(let t of s)if(t instanceof HTMLElement){t.hasAttribute("solarite-placeholder")&&this.B.Et(t);for(let e of t.querySelectorAll("[solarite-placeholder]"))this.B.Et(e)}}}Pt(t){let e=Math.min(t.$t,t.items.length),l=t.$t-e;for(let l=0;e>l;l++){let e=this.u[t.index+l],s=(this.Y||this.X)(t.items[l]);this.Nt(s,(s=>{let i=this.ut(s,!0);if(i&&i===e);else{i||(i=this.ut(s,!1)),this.u[t.index+l]=i;let r=e.gt;for(let t of i.ct())r.parentNode.insertBefore(t,r);i!==e&&e.vt()}}))}if(l>0){for(let s=0;l>s;s++)this.u[t.index+e+s].vt();this.u.splice(t.index+e,l)}else{let l=t.items.slice(e),s=this.u[t.index+e]?.gt||this._;for(let t=0;l.length>t;t++){let e=this.Y(l[t]),i=this.ut(e,!0);i||(i=this.ut(e,!1)),this.u.push(i);for(let t of i.ct())s.parentNode.insertBefore(t,s)}}this.K=null}Nt(t,e){if(Array.isArray(t))for(let l of t)this.Nt(l,e);else if("function"==typeof t)Globals$1.l=this,this.X=t,t=t(),Globals$1.l=null,this.Nt(t,e);else if(t instanceof Template||t instanceof Node)e(t);else{void 0===t||!1===t||null===t?t="":"string"!=typeof t&&(t+="");let l=new Template([t],[]);this.Nt(l,e)}}ft(t,e,l){if(t instanceof Template){let s=this.ut(t,!0);s?(e.push(...s.ct()),this.u.push(s)):(l.push([e.length,this.u.length]),e.push(t),this.u.push(null))}else t instanceof Node?t instanceof DocumentFragment?e.push(...t.childNodes):e.push(t):this.Nt(t,(t=>{this.ft(t,e,l)}))}it(t,e){Array.isArray(e)&&(e=e.flat().join(" "));let l=this.W;if(this.W=new Set,e){"function"==typeof e&&(Globals$1.l=this,this.X=e,e=e(),Globals$1.l=null);let l=(e+"").split(/([\w-]+\s*=\s*(?:"[^"]*"|'[^']*'|[^\s]+))/g).map((t=>t.trim())).filter((t=>t.length));for(let e of l){let[l,s]=e.split(/\s*=\s*/);s=(s||"").replace(/^(['"])(.*)\1$/,"$2"),t.setAttribute(l,s),this.W.add(l)}}for(let e of l)this.W.has(e)||t.removeAttribute(e)}rt(t,e,l){let s,i=this.attrName.slice(2),r=[];if(Array.isArray(e)&&"function"==typeof e[0])s=e[0],r=e.slice(1);else{if("function"!=typeof e)throw Error(`Invalid event binding: <${t.tagName.toLowerCase()} ${this.attrName}=\${${JSON.stringify(e)}}>`);s=e}this.Tt(t,l,i,i,s,r)}Tt(t,e,l,s,i,r,o=!1){let a=Globals$1.h.get(t);a||(a={[l]:[,,,]},Globals$1.h.set(t,a));let n=a[l];if(n||(a[l]=n=[,,,]),"function"!=typeof i)throw Error(`Solarite cannot bind to <${t.tagName.toLowerCase()} ${this.attrName}=\${${i}}> because it's not a function.`);if(n[0]!==i){let[l,r,a]=n;l&&t.removeEventListener(s,r,o);let h=i,f=l=>h.call(e,...n[2],l,t);n[0]=h,n[1]=f,t.addEventListener(s,f,o)}a[l][2]=r}nt(t,e){let l=e[0];if(Util.k(l)){let[e,s]=[l[0],l.slice(1)];if(!e)throw Error(`Solarite cannot bind to <${t.tagName.toLowerCase()} ${this.attrName}=\${[${l.map((t=>t?`'${t}'`:t+"")).join(", ")}]}>.`);let i=delve(e,s);if("value"===this.attrName&&"select-multiple"===t.type&&Array.isArray(i)){let e=i.map((t=>t+""));for(let l of t.options)l.selected=e.includes(l.value)}else{let e=Util.M(i)?"":i;e!==t[this.attrName]&&(t[this.attrName]=e)}let r=()=>{let l="value"===this.attrName?Util.H(t):t[this.attrName];delve(e,s,l)};this.Tt(t,s[0],this.attrName,"input",r,[],!0)}else{let s=this.tt;void 0===s&&(s=this.tt=Util.C(t,this.attrName));let i=this.L;if(!i){if(Globals$1.l=this,"function"==typeof l){if(4===this.type)return;this.X=l,l=l()}else l=Util.j(l);Globals$1.l=null}if(i||void 0!==l&&!1!==l&&null!==l)if(i||!0!==l){let r;if(i){let t=[];for(let l=0;this.L.length>l;l++)if(t.push(this.L[l]),this.L.length-1>l){Globals$1.l=this;let s=Util.j(e[l]);Globals$1.l=null,Util.M(s)||t.push(s)}r=t.join("")}else r=l;(s?t[this.attrName]:t.getAttribute(this.attrName))!==r&&(s&&(t[this.attrName]=r),t.setAttribute(this.attrName,r))}else s&&(t[this.attrName]=!0),t.setAttribute(this.attrName,"");else s&&(t[this.attrName]=!1),t.removeAttribute(this.attrName)}}clone(t,e=0){let l,s,i=t,r=e?this.q.slice(0,-e):this.q;for(let t=r.length-1;t>0;t--)i=i.childNodes[r[t]];let o=i.childNodes;return l=r.length?o[r[0]]:t,this.D&&(s=o[this.Z]),new ExprPath(s,l,this.type,this.attrName,this.L)}bt(){let t=this,e=this._.parentNode;for(;t&&t._.parentNode===e;)t.K=null,t=t.B?.dt}yt(){let t=this.D.parentNode;return this.D===t.firstChild&&this._===t.lastChild&&(t.innerHTML="",t.append(this.D,this._),!0)}ct(){if(this.type===ExprPathType.wt||this.type===ExprPathType.lt||this.type===ExprPathType.Gt)return[this._];let t;if(t=this.K,t)return t;t=[];let e=this.D.nextSibling,l=this._;for(;e&&e!==l;)t.push(e),e=e.nextSibling;return this.K=t,t}xt(){return this._.parentNode}ut(t,e=!0){let l,s=this.At;if(e){if(l=s.R(t.St()),l||(s=this.Ht,l=s.R(t.St())),!l)return null;s.V(t.Ot(),l)}else t.Ct.length&&(l=s.R(t.Ot()),l||(s=this.Ht,l=s.R(t.Ot())),l&&(s.V(l.kt,l),l.Mt(t.Ct),l.kt=t.St()));return l||(l=new NodeGroup(t,this)),this.jt.push(l),l}Ut(){return this.type===ExprPathType.Gt||this.attrName&&this._.tagName&&this._.tagName.includes("-")}jt=[];At=new MultiValueMap;Ht=new MultiValueMap;ht(){let t=this.At.data,e=this.Ht.data;for(let l in t){let s=e[l];if(s)for(let e of t[l])s.add(e);else e[l]=t[l]}this.At=new MultiValueMap;let l=this.At;for(let t of this.jt)l.add(t.kt,t),l.add(t.It,t);this.jt=[]}}const ExprPathType={et:1,lt:2,wt:3,Gt:4,Comment:5,Event:6};function getNodePath(t){let e=[];for(;;){let l=t.parentNode;if(!l)break;e.push([].indexOf.call(t.parentNode.childNodes,t)),t=l}return e}function resolveNodePath(t,e){for(let l=e.length-1;l>=0;l--)t=t.childNodes[e[l]];return t}class HtmlParser{constructor(){this.Ft={context:HtmlParser.Text,quote:null,buffer:"",Rt:null},this.state={...this.Ft}}reset(){return this.state={...this.Ft},this.state.context}parse(t,e=null){if(null===t)return this.reset();for(let l=0;t.length>l;l++){const s=t[l];switch(this.state.context){case HtmlParser.Text:"<"===s&&t[l+1].match(/[/a-z!]/i)&&(e?.(t,l,this.state.context,HtmlParser.Vt),this.state.context=HtmlParser.Vt,this.state.buffer="");break;case HtmlParser.Vt:if(">"===s)e?.(t,l+1,this.state.context,HtmlParser.Text),this.state.context=HtmlParser.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,l,this.state.context,HtmlParser.Jt),this.state.context=HtmlParser.Jt,this.state.quote="="===s?null:s,this.state.buffer=""):this.state.buffer+=s}break;case HtmlParser.Jt:this.state.quote||this.state.buffer.length||'"'!==s&&"'"!==s?s===this.state.quote||!this.state.quote&&this.state.buffer.length?(e?.(t,l,this.state.context,HtmlParser.Vt),this.state.context=HtmlParser.Vt,this.state.quote=null,this.state.buffer=""):this.state.quote||">"!==s?" "!==s&&(this.state.buffer+=s):(e?.(t,l+1,this.state.context,HtmlParser.Text),this.state.context=HtmlParser.Text,this.state.quote=null,this.state.buffer=""):this.state.quote=s}}return e?.(t,t.length,this.state.context,null),this.state.context}}HtmlParser.Jt="Attribute",HtmlParser.Text="Text",HtmlParser.Vt="Tag";class Shell{fragment;Lt=[];Wt=[];scripts=[];zt=[];Dt=[];constructor(t=null){if(!t)return;if(1===t.length&&!t[0].match(/[<&]/))return void(this.fragment=document.createTextNode(t[0]));let e,l=Shell._t(t),s=document.createElement("template");l?s.innerHTML=l:s.content.append(document.createTextNode("")),this.fragment=s.content;let i=[],r=0;const o=document.createTreeWalker(this.fragment,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_COMMENT|NodeFilter.SHOW_TEXT);for(;e=o.nextNode();)if(i.map((t=>t.remove())),i=[],1===e.nodeType)for(let t of[...e.attributes]){let l=t.name.match(/^[\ue000-\uf8ff]$/);if(l)this.Lt.push(new ExprPath(null,e,ExprPathType.lt)),r++,e.removeAttribute(l[0]);else{let l=t.value.split(/[\ue000-\uf8ff]/g);if(l.length>1){let s=2!==l.length||l[0].length||l[1].length?l:null,i=Util.O(t.name)?ExprPathType.Event:ExprPathType.wt;this.Lt.push(new ExprPath(null,e,i,t.name,s)),r+=l.length-1,e.setAttribute(t.name,l.join(""))}}}else if(8===e.nodeType&&"!✨!"===e.nodeValue){let t,l=e.previousSibling;l||(l=document.createComment("ExprPath:"+this.Lt.length),e.parentNode.insertBefore(l,e)),!e.nextSibling||8===e.nextSibling.nodeType&&"!✨!"===e.nextSibling.textContent?(t=e,t.textContent="ExprPathEnd:"+this.Lt.length):(t=e.nextSibling,i.push(e));let s=new ExprPath(l,t,ExprPathType.et);this.Lt.push(s),r++}else{if(3===e.nodeType&&"TEXTAREA"===e.parentNode?.tagName&&e.textContent.includes("\x3c!--!✨!--\x3e"))throw Error('Textarea can\'t have expressions inside them. Use <textarea value="${...}"> instead.');if(e.nodeType===Node.COMMENT_NODE){let t=e.textContent.split(/[\ue000-\uf8ff]/g);for(let l=0;t.length-1>l;l++){let t=new ExprPath(e.previousSibling,e);t.type=ExprPathType.Comment,this.Lt.push(t),r++}}else if(e.nodeType===Node.TEXT_NODE&&["SCRIPT","STYLE"].includes(e.parentNode?.nodeName)){let t=e.textContent.split(commentPlaceholder);if(t.length>1){let l=[];for(let s=0;t.length>s;s++){let i=document.createTextNode(t[s]);e.parentNode.insertBefore(i,e),s>0&&l.push(i)}for(let t,e=0;t=l[e];e++){let e=new ExprPath(t.previousSibling,t,ExprPathType.et);this.Lt.push(e),r++}i.push(e)}}}if(i.map((t=>t.remove())),r!==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.fragment.querySelectorAll("[is]"))t.setAttribute("_is",t.getAttribute("is"));for(let t of this.Lt)t.D&&(t.Z=[].indexOf.call(t.D.parentNode.childNodes,t.D)),t.q=getNodePath(t._),t.type===ExprPathType.wt&&1===t._.nodeType&&(t._.tagName.includes("-")||t._.hasAttribute("is"))&&(t.type=ExprPathType.Gt);this.Bt()}static _t(t){let e=[];function l(t,l){l===HtmlParser.Vt&&(t=t.replace(/^<\/?[a-z][a-z0-9]*-[a-z0-9-]+/i,(t=>t+"-solarite-placeholder solarite-placeholder"))),e.push(t)}let s=new HtmlParser;for(let i=0;t.length>i;i++){let r=0,o=s.parse(t[i],((t,e,s,i)=>{r!==e&&l(t.slice(r,e),s),r=e}));t.length-1>i&&e.push(o===HtmlParser.Text?commentPlaceholder:String.fromCharCode(attribPlaceholder+i))}return e.join("")}Bt(){this.scripts=[].map.call(this.fragment.querySelectorAll("scripts"),(t=>getNodePath(t))),this.zt=[].map.call(this.fragment.querySelectorAll("style"),(t=>getNodePath(t)));let t=this.fragment.querySelectorAll("[id],[data-id]");for(let e of t){let t=e.getAttribute("data-id")||e.getAttribute("id");if(Globals$1.div.hasOwnProperty(t))throw Error(`<${e.tagName.toLowerCase()} id="${t}"> can't override existing HTMLElement id property.`)}this.Wt=[].map.call(t,(t=>getNodePath(t)));for(let t of this.fragment.querySelectorAll("*"))(t.tagName.includes("-")||t.hasAttribute("_is"))&&(this.Lt.find((e=>e._===t))||this.Dt.push(getNodePath(t)))}static get(t){let e=Globals$1.P.get(t);return e||(e=new Shell(t),Globals$1.P.set(t,e)),e}}const commentPlaceholder="\x3c!--!✨!--\x3e",attribPlaceholder=57344;class NodeGroup{ot;dt;gt;Kt;Lt=[];kt;It;K;zt;constructor(t,e=null){if(!(this instanceof RootNodeGroup)){let[l,s]=this.init(t,e);if(l&&t.Ct.length){this.Zt(l,s.Lt);let e=this.qt(l,s);this.Xt(l,s),this.Mt(t.Ct),this.Yt(e)}else s&&this.Xt(l,s)}}init(t,e=null,l=null,s=null){if(this.kt=l||t.St(),this.It=s||t.Ot(),this.dt=e,this.ot=e?.B?.ot||this,this.Qt=t,t.te=this,this instanceof RootNodeGroup||t.Ct.length||t.ee[0].includes("<")){let e=Shell.get(t.ee),l=e.fragment.cloneNode(!0);if(l instanceof DocumentFragment){let t=l.childNodes;this.gt=t[0],this.Kt=t[t.length-1]}else this.gt=this.Kt=l;return[l,e]}{let e=document.createTextNode(t.ee[0]);return this.gt=this.Kt=e,[]}}Mt(t,e=null){let l,s=t.length-1,i=Array((e=e||this.Lt).length);for(let r,o=e.length-1;r=e[o];o--){let a=e[o-1],n=e[o+1];if(r.L?.length>2?(i[o]=t.slice(s-(r.L.length-1)+1,s+1),s-=i[o].length):(i[o]=[t[s]],s--),r._!==this.ot.root&&r.Ut()){if(n&&n.Ut()&&n._===r._||(l=o),!a||!a.Ut()||a._!==r._){let t={};for(let s=o;l>=s;s++)t[e[s].attrName]=i[s].length>1?i[s].join(""):i[s][0];this.le(r._,t);for(let t=o;l>=t;t++)e[t].apply(i[t])}}else r.apply(i[o])}this.se(),this.K=null}le(t,e){let l=getObjectHash(e),s=t.hasAttribute("solarite-placeholder"),i=t.hasAttribute("_is");if(s||i)t=this.Et(t,s,e);else if(t.ie){let l={};for(let t in e||{})l[Util.S(t)]=e[t];t.ie(l)}Globals$1.t.set(t,l)}Et(t,e=void 0,l=void 0){void 0===e&&(e=!t.hasAttribute("_is"));let s=(e?t.tagName.slice(0,-21):t.getAttribute("is")).toLowerCase(),i=customElements.get(s);if(!i)throw Error(`The custom tag name ${s} is not registered.`);let r={};for(let t in l||{})r[Util.S(t)]=l[t];if(t.attributes.length)for(let e of t.attributes){let t=Util.S(e.name);r.hasOwnProperty(t)||"solarite-placeholder"===t||(r[t]=e.value)}let o=new i(r,[...t.childNodes].filter((t=>t.nodeType!==Node.COMMENT_NODE||!t.nodeValue.startsWith("ExprPath"))));e||o.setAttribute("is",t.getAttribute("is").toLowerCase()),t.replaceWith(o);let a=t.getAttribute("data-id")||t.getAttribute("id");a&&delve(this.getRootNode(),a.split(/\./g),o);for(let e of this.Lt)e._===t&&(e._=o),e.D===t&&(e.D=o);this.gt===t&&(this.gt=o),this.Kt===t&&(this.Kt=o),o.re&&o.re();for(let e of t.attributes)"_is"!==e.name&&"solarite-placeholder"!==e.name&&o.setAttribute(e.name,e.value);for(let t in l){let e=l[t];"boolean"==typeof e?!1!==e&&null!=e&&o.setAttribute(t,""):["number","bigint","string"].includes(typeof e)&&o.setAttribute(t,e)}return o}ct(){let t=this.K;if(t)return t;t=[];let e=this.gt,l=this.Kt?.nextSibling;for(;e&&e!==l;)t.push(e),e=e.nextSibling;return this.K=t,t}xt(){return this.gt?.parentNode}getRootNode(){return this.ot.root}oe(){return this.ot}vt(){let t=document.createDocumentFragment();for(let e of this.ct())t.append(e)}Zt(t,e,l){let s=e.length;this.Lt.length=s;for(let i=0;s>i;i++){let s=e[i].clone(t,l);s.B=this,this.Lt[i]=s}}se(){if(this.zt)for(let[t,e]of this.zt)e!==t.textContent&&Util.T(t,this.oe().root)}qt(t,e,l=0){let s=[];for(let i of e.Dt){l&&(i=i.slice(0,-l));let e=resolveNodePath(t,i);t!==e&&s.push(e)}return s}Yt(t){for(let e of t)this.Et(e)}Xt(root,shell,pathOffset=0){let rootEl=this.ot.root;if(rootEl){let options=this.ot.options;if(!1!==options?.Wt)for(let t of shell.Wt){pathOffset&&(t=t.slice(0,-pathOffset));let e=resolveNodePath(root,t);Util.N(rootEl,e)}if(!1!==options?.zt){shell.zt.length&&(this.zt=new Map);for(let t of shell.zt){pathOffset&&(t=t.slice(0,-pathOffset));let e=resolveNodePath(root,t);1===rootEl.nodeType&&(Util.T(e,rootEl),this.zt.set(e,e.textContent))}}if(!1!==options?.scripts)for(let path of shell.scripts){pathOffset&&(path=path.slice(0,-pathOffset));let script=resolveNodePath(root,path);eval(script.textContent)}}}}class RootNodeGroup extends NodeGroup{root;ae=new Map;constructor(t,e,l){super(t),this.options=l,this.ot=this;let[s,i]=this.init(t);if(s instanceof Text)e&&(this.gt=e,this.Kt=e,s.nodeValue.length&&e.append(s),this.root=e),Globals$1.u.set(this.root,this);else{let l=0,r=s;if(e){let t;if(Globals$1.u.set(e,this),e.childNodes.length&&(t=document.createDocumentFragment(),t.append(...e.childNodes)),this.root=e,isReplaceEl(s,e)){e.append(...s.children[0].childNodes);for(let t of s.children[0].attributes)e.hasAttribute(t.name)||"solarite-placeholder"===t.name||e.setAttribute(t.name,t.value);l=1}else 1===s.childNodes.length&&3===s.childNodes[0].nodeType&&""===s.childNodes[0].textContent||e.append(...s.childNodes);if(t){for(let l of e.querySelectorAll("slot[name]")){let e=l.getAttribute("name");if(e){let s=t.querySelectorAll(`[slot='${e}']`);l.append(...s)}}let l=e.querySelector("slot:not([name])");l?l.append(t):e.append(t)}r=e,this.gt=e,this.Kt=e}else{let t=getSingleEl(s);this.root=t||s,Globals$1.u.set(this.root,this),t&&(r=t,l=1)}this.Zt(r,i.Lt,l);let o=this.qt(r,i,l);this.Xt(r,i,l),this.Mt(t.Ct),this.Yt(o)}}}function getSingleEl(t){let e=[];for(let l of t.childNodes)if(1===l.nodeType||3===l.nodeType&&l.textContent.trim().length){if(e.length)return null;e.push(l)}return e[0]}function isReplaceEl(t,e){return 1===t.children.length&&e.tagName.includes("-")&&t.children[0].tagName.replace("-SOLARITE-PLACEHOLDER","")===e.tagName}class Template{Ct=[];ee=[];ne;te;constructor(t,e){this.ee=t,this.Ct=e}toJSON(){return this.ne||(this.ne=[getObjectId(this.ee),this.Ct]),this.ne}ie(t=null,e={}){let l,s=!1;if(t){if(l=Globals$1.u.get(t),l||(l=new RootNodeGroup(this,t,e),Globals$1.u.set(t,l),s=!0),0===l.Lt.length&&this.Ct.length||l.Lt.length>this.Ct.length)throw Error(`Solarite Error: Parent HTMLElement ${l.Qt.ee.join("${...}")} and ${l.Lt.length} \${value} placeholders can't accomodate a Template with ${this.Ct.length} values.`)}else l=new RootNodeGroup(this,null,e),t=l.getRootNode(),Globals$1.u.set(t,l),s=!0;return s||(1!==this.ee?.length||this.ee[0]?l.Mt(this.Ct):t.innerHTML=""),l.ae=new Map,t}St(){return this.kt||(this.kt=this.Ct.length?getObjectHash(this):this.ee[0]),this.kt}Ot(){return this.It||(this.It=this.Ct.length?this.toJSON()[0]:this.ee[0]),this.It}}function h(t=void 0,...e){if(void 0===t&&!e.length&&arguments.length)throw Error("h() cannot be called with undefined.");if(!(t instanceof Node)){if(Array.isArray(t))return new Template(t,e);if("string"==typeof t||t instanceof String){if("object"==typeof e[0]){e.slice(1);let t=[],l=[];return assert(t.length===l.length+1),new Template(t,l)}t.match(/^\s^</)&&(t=t.trim());let l=document.createElement("template");l.innerHTML=t;let s=Util.I(l.content.childNodes);return 1===s.length?s[0]:l.content}if(void 0===t)return(t,...e)=>h(t,...e).ie();if(t instanceof Template)return t.ie();if("object"==typeof t){let e=t;if("Object"!==e.constructor.name)throw Error(`Solarate Web Component class ${e.constructor?.name} must extend HTMLElement.`);if(Globals$1.p.has(e))return((...t)=>{let l=h(...t).ie();Globals$1.p.set(e,l)}).bind(e);{Globals$1.p.set(e,null),e[renderF]();let t=Globals$1.p.get(e);Globals$1.p.delete(e);for(let l in e)t[l]="function"==typeof e[l]?e[l].bind(t):e[l];return t}}throw Error("Unsupported arguments.")}{let l=t,s=e[0];if(!(e[0]instanceof Template)){l.shadowRoot&&(l.innerHTML="");let t=e[0],s=(e,...s)=>(Globals$1.m.add(l),new Template(e,s).ie(l,t));return s}s.ie(l,e[1]),!l.childNodes.length&&this&&l.append(this.ot.xt())}}let renderF="render";function getArg(el,attributeName,defaultValue=void 0,type=ArgType.String,fallback=void 0){let val=defaultValue,attrVal=el.getAttribute(attributeName)||el.getAttribute(Util.A(attributeName)),result;if(null!==attrVal&&(val=attrVal),Array.isArray(type))return type.includes(val)?val:fallback;if("function"==typeof type)return type.constructor?new type(val):type(val);if(type===ArgType.he){let t="string"==typeof val?val.toLowerCase():val;return!["false","0",!1,0,null,void 0,NaN].includes(t)&&(!(!["true",!0].includes(t)&&0===parseFloat(t))||fallback)}switch(type){case ArgType.fe:return result=parseInt(val),isNaN(result)?fallback:result;case ArgType.ue:return result=parseFloat(val),isNaN(result)?fallback:result;case ArgType.String:return[void 0,null,!1].includes(val)?"":val+"";case ArgType.ce:case ArgType.de:if("string"!=typeof val||!val.length)return val;try{return type===ArgType.ce?JSON.parse(val):eval(`(${val})`)}catch(t){return val}default:return val}}function setArgs(t,e,l){for(let s in e)this[s]=getArg(t,s,e[s],l[s]||ArgType.String)}var ArgType={he:"Bool",fe:"Int",ue:"Float",String:"String",JSON:"Json",ce:"Json",de:"Eval"};function defineClass(t,e,l){if(!customElements[getName](t)){(e=e||Util.A(t.name)).includes("-")||(e+="-element");let s=null;l&&(s={pe:l}),customElements[define](e,t,s)}}function createSolarite(t=null){let e=HTMLElement;t&&!t.includes("-")&&(t=t.toLowerCase(),e=Globals$1.i[t],e||(e=document.createElement(t).constructor,Globals$1.i[t]=e));let l=new Proxy(e,{construct:(e,l,s)=>(defineClass(s,null,t),Reflect.construct(e,l,s))});return class extends l{me;be;ye;constructor(t={}){super(),!0===t.ie?this.ie():!1===t.ie&&Globals$1.m.add(this)}re(){!Globals$1.m.has(this)&&this.ie&&this.ie()}ge(){this.re(),Globals$1.connected.has(this)||(Globals$1.connected.add(this),this.be&&this.be()),this.me&&this.me()}ve(){this.ye&&this.ye()}static define(e=null){defineClass(this,e,t)}}}let define="define",getName="getName";const Solarite=new Proxy(createSolarite(),{apply:(t,e,l)=>createSolarite(...l)});export default h;export{ArgType,Globals$1 as Globals,Solarite,Util as SolariteUtil,Template,delve,getArg,h,h as r,setArgs};
4
+ let lastObjectId=1,objectIds=new WeakMap;function getObjectId(t){let e=objectIds.get(t);return e||(e="~\f"+lastObjectId++,objectIds.set(t,e)),e}let isHashing=!0;function toJSON(){return isHashing?getObjectId(this):this}function getObjectHash(t){let e;Node.prototype.toJSON!==toJSON&&(Node.prototype.toJSON=toJSON,(()=>{}).toJSON!==toJSON&&(Function.prototype.toJSON=toJSON)),isHashing=!0;try{e=JSON.stringify(t)}catch(l){e=getObjectHashCircular(t)}return isHashing=!1,e}function getObjectHashCircular(t){const e=new Set;return JSON.stringify(t,((t,l)=>{if("object"==typeof l&&null!==l){if(e.has(l))return getObjectId(l);e.add(l)}return l}))}var Globals;function reset(){Globals={t:new WeakMap,connected:new WeakSet,l:null,div:document.createElement("div"),i:{},o:{},h:new WeakMap,u:new WeakMap,p:new WeakMap,m:new WeakSet,v:new WeakSet,P:new WeakMap,reset,count:0}}reset();var Globals$1=Globals;function delve(t,e,l=d){let s=l!==d,i=e.length;if(!t&&!s&&i)return;let r=0;for(let o of e){if(void 0===t[o]){if(!s)return;i-1>r&&(t[o]=(e[r+1]+"").match(/^\d+$/)?[]:{})}s&&r===i-1&&(t[o]=l),t=t[o],r++}return t}let d={},Util={$(t,e){let l=t.length;if(l!==e.length)return!1;for(let s=0;l>s;s++)if(t[s]!==e[s])return!1;return!0},N(t,e){let l=e.getAttribute("data-id")||e.getAttribute("id");if(l){if(t[l]&&!(t[l]instanceof Node))throw Error(`${t.constructor.name}.${l} already has a value. Can't set it as a reference to <${e.tagName.toLowerCase()} id="${l}">`);delve(t,l.split(/\./g),e)}},T(t,e){let l=e.getAttribute("data-style");l||(e.constructor.G||(e.constructor.G=1),l=e.constructor.G++,e.setAttribute("data-style",l));let s=e.tagName.toLowerCase();for(let e of t.childNodes)if(3===e.nodeType){let t=e.textContent,i=t.replace(/:host(?=[^a-z0-9_])/gi,`${s}[data-style="${l}"]`);t!==i&&(e.textContent=i)}},A: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(),S:t=>t.replace(/-([a-z])/g,(t=>t[1].toUpperCase())),H:t=>"checkbox"===t.type||"radio"===t.type?t.checked:"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.value,O:t=>t.startsWith("on")&&t in Globals$1.div,C(t,e){let l=t.tagName+"."+e,s=Globals$1.o[l];if(void 0===s){let i=Object.getPrototypeOf(t);for(;i;){const t=i.constructor.name;if(t.startsWith("HTML")&&t.endsWith("Element"))break;i=Object.getPrototypeOf(i)}Globals$1.o[l]=s=!!i&&!!Object.getOwnPropertyDescriptor(i,e)?.set}return s},k:t=>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)),M:t=>void 0===t||!1===t||null===t,j:t=>"function"==typeof t?Util.j(t()):t instanceof Date?t.toISOString().replace(/T/," "):Array.isArray(t)||"object"==typeof t?"":t,U(t,e,l){let s=t.get(e);s?s.push(l):(s=[l],t.set(e,s))},I(t){const e=t=>t.nodeType!==Node.ELEMENT_NODE&&(t.nodeType!==Node.TEXT_NODE||""===t.textContent.trim()),l=[...t];for(;l.length>0&&e(l[0]);)l.shift();for(;l.length>0&&e(l[l.length-1]);)l.pop();return l}};class MultiValueMap{data={};add(t,e){let l=this.data,s=l[t];s||(s=new Set,l[t]=s),s.add(e)}F(){for(let t in this.data)return!0;return!1}getAll(t){return this.data[t]||[]}delete(t,e=void 0){let l,s=this.data,i=s[t];if(i)return void 0===e?([l]=i,i.delete(l)):(i.delete(e),l=e),0===i.size&&delete s[t],l}R(t){let e,l=this.data,s=l[t];if(s)return[e]=s,s.delete(e),0===s.size&&delete l[t],e}V(t,e){let l,s=this.data,i=s[t];if(i)return i.delete(e),l=e,0===i.size&&delete s[t],l}J(t){let e=this.data,l=[];for(let s in e)e[s].has(t)&&l.push(s);return l}}const udomdiff=(t,e,l,s)=>{const i=l.length;let r=e.length,o=i,a=0,n=0,h=null;for(;r>a||o>n;)if(r===a){const e=i>o?n?l[n-1].nextSibling:l[o-n]:s;for(;o>n;){let s=l[n++];t.insertBefore(s,e)}}else if(o===n)for(;r>a;){let l=e[a];h&&h.has(l)||t.removeChild(l),a++}else if(e[a]===l[n])a++,n++;else if(e[r-1]===l[o-1])r--,o--;else if(e[a]===l[o-1]&&l[n]===e[r-1]){const s=e[--r].nextSibling;let i=l[n++],h=e[a++];t.insertBefore(i,h.nextSibling);let f=l[--o];t.insertBefore(f,s),e[r]=l[o]}else{if(!h){h=new Map;let t=n;for(;o>t;)h.set(l[t],t++)}if(h.has(e[a])){const s=h.get(e[a]);if(s>n&&o>s){let i=a,f=1;for(;++i<r&&o>i&&h.get(e[i])===s+f;)f++;if(f>s-n){const i=e[a];for(;s>n;){let e=l[n++];t.insertBefore(e,i)}}else{let s=e[a++],i=l[n++];t.replaceChild(i,s)}}else a++}else{let l=e[a++];t.removeChild(l)}}return l};class ExprPath{type;attrName;L;W;D;_;B;u=[];K;Z;q;X;Y;tt=void 0;constructor(t,e,l=ExprPathType.et,s=null,i=null){this.D=t,this._=e,this.type=l,this.attrName=s,this.L=i,l===ExprPathType.lt&&(this.W=new Set)}apply(t,e=!0){switch(this.type){case 1:this.st(t[0],e);break;case 2:this.it(this._,t[0]);break;case 5:break;case 6:this.rt(this._,t[0],this.B.ot.root);break;default:this.nt(this._,t)}}st(t,e=!0){let l=this;e&&l.ht();let s=[],i=l.u,r=[];l.u=[],l.ft(t,s,r);let o=!1;if(r.length){for(let[t,e]of r){let i=l.ut(s[t],!1),r=i.ct();1===r.length?s[t]=r[0]:(s[t]=r,o=!0),l.u[e]=i}o&&(s=s.flat())}let a=l.ct();if(!Util.$(a,s)){l.K=s,this.B.dt&&this.B.dt.bt(),a.length&&!s.length&&l.yt()||udomdiff(l._.parentNode,a,s,l._);for(let t of i)t.gt.parentNode||t.vt();for(let t of s)if(t instanceof HTMLElement){t.hasAttribute("solarite-placeholder")&&this.B.Et(t);for(let e of t.querySelectorAll("[solarite-placeholder]"))this.B.Et(e)}}}Pt(t){let e=Math.min(t.$t,t.items.length),l=t.$t-e;for(let l=0;e>l;l++){let e=this.u[t.index+l],s=(this.Y||this.X)(t.items[l]);this.Nt(s,(s=>{let i=this.ut(s,!0);if(i&&i===e);else{i||(i=this.ut(s,!1)),this.u[t.index+l]=i;let r=e.gt;for(let t of i.ct())r.parentNode.insertBefore(t,r);i!==e&&e.vt()}}))}if(l>0){for(let s=0;l>s;s++)this.u[t.index+e+s].vt();this.u.splice(t.index+e,l)}else{let l=t.items.slice(e),s=this.u[t.index+e]?.gt||this._;for(let t=0;l.length>t;t++){let e=this.Y(l[t]),i=this.ut(e,!0);i||(i=this.ut(e,!1)),this.u.push(i);for(let t of i.ct())s.parentNode.insertBefore(t,s)}}this.K=null}Nt(t,e){if(Array.isArray(t))for(let l of t)this.Nt(l,e);else if("function"==typeof t)Globals$1.l=this,this.X=t,t=t(),Globals$1.l=null,this.Nt(t,e);else if(t instanceof Template||t instanceof Node)e(t);else{void 0===t||!1===t||null===t?t="":"string"!=typeof t&&(t+="");let l=new Template([t],[]);this.Nt(l,e)}}ft(t,e,l){if(t instanceof Template){let s=this.ut(t,!0);s?(e.push(...s.ct()),this.u.push(s)):(l.push([e.length,this.u.length]),e.push(t),this.u.push(null))}else t instanceof Node?t instanceof DocumentFragment?e.push(...t.childNodes):e.push(t):this.Nt(t,(t=>{this.ft(t,e,l)}))}it(t,e){Array.isArray(e)&&(e=e.flat().join(" "));let l=this.W;if(this.W=new Set,e)if("function"==typeof e&&(Globals$1.l=this,this.X=e,e=e(),Globals$1.l=null),"object"==typeof e)for(let l in e){let s=e[l];void 0!==s&&!1!==s&&null!==s&&(t.setAttribute(l,s),this.W.add(l))}else{let l=(e+"").split(/([\w-]+\s*=\s*(?:"[^"]*"|'[^']*'|[^\s]+))/g).map((t=>t.trim())).filter((t=>t.length));for(let e of l){let[l,s]=e.split(/\s*=\s*/);s=(s||"").replace(/^(['"])(.*)\1$/,"$2"),t.setAttribute(l,s),this.W.add(l)}}for(let e of l)this.W.has(e)||t.removeAttribute(e)}rt(t,e,l){let s,i=this.attrName.slice(2),r=[];if(Array.isArray(e)&&"function"==typeof e[0])s=e[0],r=e.slice(1);else{if("function"!=typeof e)throw Error(`Invalid event binding: <${t.tagName.toLowerCase()} ${this.attrName}=\${${JSON.stringify(e)}}>`);s=e}this.Tt(t,l,i,i,s,r)}Tt(t,e,l,s,i,r,o=!1){let a=Globals$1.h.get(t);a||(a={[l]:[,,,]},Globals$1.h.set(t,a));let n=a[l];if(n||(a[l]=n=[,,,]),"function"!=typeof i)throw Error(`Solarite cannot bind to <${t.tagName.toLowerCase()} ${this.attrName}=\${${i}}> because it's not a function.`);if(n[0]!==i){let[l,r,a]=n;l&&t.removeEventListener(s,r,o);let h=i,f=l=>h.call(e,...n[2],l,t);n[0]=h,n[1]=f,t.addEventListener(s,f,o)}a[l][2]=r}nt(t,e){let l=e[0];if(Util.k(l)){let[e,s]=[l[0],l.slice(1)];if(!e)throw Error(`Solarite cannot bind to <${t.tagName.toLowerCase()} ${this.attrName}=\${[${l.map((t=>t?`'${t}'`:t+"")).join(", ")}]}>.`);let i=delve(e,s);if("value"===this.attrName&&"select-multiple"===t.type&&Array.isArray(i)){let e=i.map((t=>t+""));for(let l of t.options)l.selected=e.includes(l.value)}else{let e=Util.M(i)?"":i;e!==t[this.attrName]&&(t[this.attrName]=e)}let r=()=>{let l="value"===this.attrName?Util.H(t):t[this.attrName];delve(e,s,l)};this.Tt(t,s[0],this.attrName,"input",r,[],!0)}else{let s=this.tt;void 0===s&&(s=this.tt=Util.C(t,this.attrName));let i=this.L;if(!i){if(Globals$1.l=this,"function"==typeof l){if(4===this.type)return;this.X=l,l=l()}else l=Util.j(l);Globals$1.l=null}if(i||void 0!==l&&!1!==l&&null!==l)if(i||!0!==l){let r;if(i){let t=[];for(let l=0;this.L.length>l;l++)if(t.push(this.L[l]),this.L.length-1>l){Globals$1.l=this;let s=Util.j(e[l]);Globals$1.l=null,Util.M(s)||t.push(s)}r=t.join("")}else r=l;(s?t[this.attrName]:t.getAttribute(this.attrName))!==r&&(s&&(t[this.attrName]=r),t.setAttribute(this.attrName,r))}else s&&(t[this.attrName]=!0),t.setAttribute(this.attrName,"");else s&&(t[this.attrName]=!1),t.removeAttribute(this.attrName)}}clone(t,e=0){let l,s,i=t,r=e?this.q.slice(0,-e):this.q;for(let t=r.length-1;t>0;t--)i=i.childNodes[r[t]];let o=i.childNodes;return l=r.length?o[r[0]]:t,this.D&&(s=o[this.Z]),new ExprPath(s,l,this.type,this.attrName,this.L)}bt(){let t=this,e=this._.parentNode;for(;t&&t._.parentNode===e;)t.K=null,t=t.B?.dt}yt(){let t=this.D.parentNode;return this.D===t.firstChild&&this._===t.lastChild&&(t.innerHTML="",t.append(this.D,this._),!0)}ct(){if(this.type===ExprPathType.wt||this.type===ExprPathType.lt||this.type===ExprPathType.Gt)return[this._];let t;if(t=this.K,t)return t;t=[];let e=this.D.nextSibling,l=this._;for(;e&&e!==l;)t.push(e),e=e.nextSibling;return this.K=t,t}xt(){return this._.parentNode}ut(t,e=!0){let l,s=this.At;if(e){if(l=s.R(t.St()),l||(s=this.Ht,l=s.R(t.St())),!l)return null;s.V(t.Ot(),l)}else t.Ct.length&&(l=s.R(t.Ot()),l||(s=this.Ht,l=s.R(t.Ot())),l&&(s.V(l.kt,l),l.Mt(t.Ct),l.kt=t.St()));return l||(l=new NodeGroup(t,this)),this.jt.push(l),l}Ut(){return this.type===ExprPathType.Gt||this.attrName&&this._.tagName&&this._.tagName.includes("-")}jt=[];At=new MultiValueMap;Ht=new MultiValueMap;ht(){let t=this.At.data,e=this.Ht.data;for(let l in t){let s=e[l];if(s)for(let e of t[l])s.add(e);else e[l]=t[l]}this.At=new MultiValueMap;let l=this.At;for(let t of this.jt)l.add(t.kt,t),l.add(t.It,t);this.jt=[]}}const ExprPathType={et:1,lt:2,wt:3,Gt:4,Comment:5,Event:6};function getNodePath(t){let e=[];for(;;){let l=t.parentNode;if(!l)break;e.push([].indexOf.call(t.parentNode.childNodes,t)),t=l}return e}function resolveNodePath(t,e){for(let l=e.length-1;l>=0;l--)t=t.childNodes[e[l]];return t}class HtmlParser{constructor(){this.Ft={context:HtmlParser.Text,quote:null,buffer:"",Rt:null},this.state={...this.Ft}}reset(){return this.state={...this.Ft},this.state.context}parse(t,e=null){if(null===t)return this.reset();for(let l=0;t.length>l;l++){const s=t[l];switch(this.state.context){case HtmlParser.Text:"<"===s&&t[l+1].match(/[/a-z!]/i)&&(e?.(t,l,this.state.context,HtmlParser.Vt),this.state.context=HtmlParser.Vt,this.state.buffer="");break;case HtmlParser.Vt:if(">"===s)e?.(t,l+1,this.state.context,HtmlParser.Text),this.state.context=HtmlParser.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,l,this.state.context,HtmlParser.Jt),this.state.context=HtmlParser.Jt,this.state.quote="="===s?null:s,this.state.buffer=""):this.state.buffer+=s}break;case HtmlParser.Jt:this.state.quote||this.state.buffer.length||'"'!==s&&"'"!==s?s===this.state.quote||!this.state.quote&&this.state.buffer.length?(e?.(t,l,this.state.context,HtmlParser.Vt),this.state.context=HtmlParser.Vt,this.state.quote=null,this.state.buffer=""):this.state.quote||">"!==s?" "!==s&&(this.state.buffer+=s):(e?.(t,l+1,this.state.context,HtmlParser.Text),this.state.context=HtmlParser.Text,this.state.quote=null,this.state.buffer=""):this.state.quote=s}}return e?.(t,t.length,this.state.context,null),this.state.context}}HtmlParser.Jt="Attribute",HtmlParser.Text="Text",HtmlParser.Vt="Tag";class Shell{fragment;Lt=[];Wt=[];scripts=[];zt=[];Dt=[];constructor(t=null){if(!t)return;if(1===t.length&&!t[0].match(/[<&]/))return void(this.fragment=document.createTextNode(t[0]));let e,l=Shell._t(t),s=document.createElement("template");l?s.innerHTML=l:s.content.append(document.createTextNode("")),this.fragment=s.content;let i=[],r=0;const o=document.createTreeWalker(this.fragment,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_COMMENT|NodeFilter.SHOW_TEXT);for(;e=o.nextNode();)if(i.map((t=>t.remove())),i=[],1===e.nodeType)for(let t of[...e.attributes]){let l=t.name.match(/^[\ue000-\uf8ff]$/);if(l)this.Lt.push(new ExprPath(null,e,ExprPathType.lt)),r++,e.removeAttribute(l[0]);else{let l=t.value.split(/[\ue000-\uf8ff]/g);if(l.length>1){let s=2!==l.length||l[0].length||l[1].length?l:null,i=Util.O(t.name)?ExprPathType.Event:ExprPathType.wt;this.Lt.push(new ExprPath(null,e,i,t.name,s)),r+=l.length-1,e.setAttribute(t.name,l.join(""))}}}else if(8===e.nodeType&&"!✨!"===e.nodeValue){let t,l=e.previousSibling;l||(l=document.createComment("ExprPath:"+this.Lt.length),e.parentNode.insertBefore(l,e)),!e.nextSibling||8===e.nextSibling.nodeType&&"!✨!"===e.nextSibling.textContent?(t=e,t.textContent="ExprPathEnd:"+this.Lt.length):(t=e.nextSibling,i.push(e));let s=new ExprPath(l,t,ExprPathType.et);this.Lt.push(s),r++}else{if(3===e.nodeType&&"TEXTAREA"===e.parentNode?.tagName&&e.textContent.includes("\x3c!--!✨!--\x3e"))throw Error('Textarea can\'t have expressions inside them. Use <textarea value="${...}"> instead.');if(e.nodeType===Node.COMMENT_NODE){let t=e.textContent.split(/[\ue000-\uf8ff]/g);for(let l=0;t.length-1>l;l++){let t=new ExprPath(e.previousSibling,e);t.type=ExprPathType.Comment,this.Lt.push(t),r++}}else if(e.nodeType===Node.TEXT_NODE&&["SCRIPT","STYLE"].includes(e.parentNode?.nodeName)){let t=e.textContent.split(commentPlaceholder);if(t.length>1){let l=[];for(let s=0;t.length>s;s++){let i=document.createTextNode(t[s]);e.parentNode.insertBefore(i,e),s>0&&l.push(i)}for(let t,e=0;t=l[e];e++){let e=new ExprPath(t.previousSibling,t,ExprPathType.et);this.Lt.push(e),r++}i.push(e)}}}if(i.map((t=>t.remove())),r!==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.fragment.querySelectorAll("[is]"))t.setAttribute("_is",t.getAttribute("is"));for(let t of this.Lt)t.D&&(t.Z=[].indexOf.call(t.D.parentNode.childNodes,t.D)),t.q=getNodePath(t._),t.type===ExprPathType.wt&&1===t._.nodeType&&(t._.tagName.includes("-")||t._.hasAttribute("is"))&&(t.type=ExprPathType.Gt);this.Bt()}static _t(t){let e=[];function l(t,l){l===HtmlParser.Vt&&(t=t.replace(/^<\/?[a-z][a-z0-9]*-[a-z0-9-]+/i,(t=>t+"-solarite-placeholder solarite-placeholder"))),e.push(t)}let s=new HtmlParser;for(let i=0;t.length>i;i++){let r=0,o=s.parse(t[i],((t,e,s,i)=>{r!==e&&l(t.slice(r,e),s),r=e}));t.length-1>i&&e.push(o===HtmlParser.Text?commentPlaceholder:String.fromCharCode(attribPlaceholder+i))}return e.join("")}Bt(){this.scripts=[].map.call(this.fragment.querySelectorAll("scripts"),(t=>getNodePath(t))),this.zt=[].map.call(this.fragment.querySelectorAll("style"),(t=>getNodePath(t)));let t=this.fragment.querySelectorAll("[id],[data-id]");for(let e of t){let t=e.getAttribute("data-id")||e.getAttribute("id");if(Globals$1.div.hasOwnProperty(t))throw Error(`<${e.tagName.toLowerCase()} id="${t}"> can't override existing HTMLElement id property.`)}this.Wt=[].map.call(t,(t=>getNodePath(t)));for(let t of this.fragment.querySelectorAll("*"))(t.tagName.includes("-")||t.hasAttribute("_is"))&&(this.Lt.find((e=>e._===t))||this.Dt.push(getNodePath(t)))}static get(t){let e=Globals$1.P.get(t);return e||(e=new Shell(t),Globals$1.P.set(t,e)),e}}const commentPlaceholder="\x3c!--!✨!--\x3e",attribPlaceholder=57344;class NodeGroup{ot;dt;gt;Kt;Lt=[];kt;It;K;zt;constructor(t,e=null){if(!(this instanceof RootNodeGroup)){let[l,s]=this.init(t,e);if(l&&t.Ct.length){this.Zt(l,s.Lt);let e=this.qt(l,s);this.Xt(l,s),this.Mt(t.Ct),this.Yt(e)}else s&&this.Xt(l,s)}}init(t,e=null,l=null,s=null){if(this.kt=l||t.St(),this.It=s||t.Ot(),this.dt=e,this.ot=e?.B?.ot||this,this.Qt=t,t.te=this,this instanceof RootNodeGroup||t.Ct.length||t.ee[0].includes("<")){let e=Shell.get(t.ee),l=e.fragment.cloneNode(!0);if(l instanceof DocumentFragment){let t=l.childNodes;this.gt=t[0],this.Kt=t[t.length-1]}else this.gt=this.Kt=l;return[l,e]}{let e=document.createTextNode(t.ee[0]);return this.gt=this.Kt=e,[]}}Mt(t,e=null){let l,s=t.length-1,i=Array((e=e||this.Lt).length);for(let r,o=e.length-1;r=e[o];o--){let a=e[o-1],n=e[o+1];if(r.L?.length>2?(i[o]=t.slice(s-(r.L.length-1)+1,s+1),s-=i[o].length):(i[o]=[t[s]],s--),r._!==this.ot.root&&r.Ut()){if(n&&n.Ut()&&n._===r._||(l=o),!a||!a.Ut()||a._!==r._){let t={};for(let s=o;l>=s;s++)t[e[s].attrName]=i[s].length>1?i[s].join(""):i[s][0];this.le(r._,t);for(let t=o;l>=t;t++)e[t].apply(i[t])}}else r.apply(i[o])}this.se(),this.K=null}le(t,e){let l=getObjectHash(e),s=t.hasAttribute("solarite-placeholder"),i=t.hasAttribute("_is");if(s||i)t=this.Et(t,s,e);else if(t.ie){let l={};for(let t in e||{})l[Util.S(t)]=e[t];t.ie(l)}Globals$1.t.set(t,l)}Et(t,e=void 0,l=void 0){void 0===e&&(e=!t.hasAttribute("_is"));let s=(e?t.tagName.slice(0,-21):t.getAttribute("is")).toLowerCase(),i=customElements.get(s);if(!i)throw Error(`The custom tag name ${s} is not registered.`);let r={};for(let t in l||{})r[Util.S(t)]=l[t];if(t.attributes.length)for(let e of t.attributes){let t=Util.S(e.name);r.hasOwnProperty(t)||"solarite-placeholder"===t||(r[t]=e.value)}let o=new i(r,[...t.childNodes].filter((t=>t.nodeType!==Node.COMMENT_NODE||!t.nodeValue.startsWith("ExprPath"))));e||o.setAttribute("is",t.getAttribute("is").toLowerCase()),t.replaceWith(o);let a=t.getAttribute("data-id")||t.getAttribute("id");a&&delve(this.getRootNode(),a.split(/\./g),o);for(let e of this.Lt)e._===t&&(e._=o),e.D===t&&(e.D=o);this.gt===t&&(this.gt=o),this.Kt===t&&(this.Kt=o),o.re&&o.re();for(let e of t.attributes)"_is"!==e.name&&"solarite-placeholder"!==e.name&&o.setAttribute(e.name,e.value);for(let t in l){let e=l[t];"boolean"==typeof e?!1!==e&&null!=e&&o.setAttribute(t,""):["number","bigint","string"].includes(typeof e)&&o.setAttribute(t,e)}return o}ct(){let t=this.K;if(t)return t;t=[];let e=this.gt,l=this.Kt?.nextSibling;for(;e&&e!==l;)t.push(e),e=e.nextSibling;return this.K=t,t}xt(){return this.gt?.parentNode}getRootNode(){return this.ot.root}oe(){return this.ot}vt(){let t=document.createDocumentFragment();for(let e of this.ct())t.append(e)}Zt(t,e,l){let s=e.length;this.Lt.length=s;for(let i=0;s>i;i++){let s=e[i].clone(t,l);s.B=this,this.Lt[i]=s}}se(){if(this.zt)for(let[t,e]of this.zt)e!==t.textContent&&Util.T(t,this.oe().root)}qt(t,e,l=0){let s=[];for(let i of e.Dt){l&&(i=i.slice(0,-l));let e=resolveNodePath(t,i);t!==e&&s.push(e)}return s}Yt(t){for(let e of t)this.Et(e)}Xt(root,shell,pathOffset=0){let rootEl=this.ot.root;if(rootEl){let options=this.ot.options;if(!1!==options?.Wt)for(let t of shell.Wt){pathOffset&&(t=t.slice(0,-pathOffset));let e=resolveNodePath(root,t);Util.N(rootEl,e)}if(!1!==options?.zt){shell.zt.length&&(this.zt=new Map);for(let t of shell.zt){pathOffset&&(t=t.slice(0,-pathOffset));let e=resolveNodePath(root,t);1===rootEl.nodeType&&(Util.T(e,rootEl),this.zt.set(e,e.textContent))}}if(!1!==options?.scripts)for(let path of shell.scripts){pathOffset&&(path=path.slice(0,-pathOffset));let script=resolveNodePath(root,path);eval(script.textContent)}}}}class RootNodeGroup extends NodeGroup{root;ae=new Map;constructor(t,e,l){super(t),this.options=l,this.ot=this;let[s,i]=this.init(t);if(s instanceof Text)e&&(this.gt=e,this.Kt=e,s.nodeValue.length&&e.append(s),this.root=e),Globals$1.u.set(this.root,this);else{let l=0,r=s;if(e){let t;if(Globals$1.u.set(e,this),e.childNodes.length&&(t=document.createDocumentFragment(),t.append(...e.childNodes)),this.root=e,isReplaceEl(s,e)){e.append(...s.children[0].childNodes);for(let t of s.children[0].attributes)e.hasAttribute(t.name)||"solarite-placeholder"===t.name||e.setAttribute(t.name,t.value);l=1}else 1===s.childNodes.length&&3===s.childNodes[0].nodeType&&""===s.childNodes[0].textContent||e.append(...s.childNodes);if(t){for(let l of e.querySelectorAll("slot[name]")){let e=l.getAttribute("name");if(e){let s=t.querySelectorAll(`[slot='${e}']`);l.append(...s)}}let l=e.querySelector("slot:not([name])");l?l.append(t):e.append(t)}r=e,this.gt=e,this.Kt=e}else{let t=getSingleEl(s);this.root=t||s,Globals$1.u.set(this.root,this),t&&(r=t,l=1)}this.Zt(r,i.Lt,l);let o=this.qt(r,i,l);this.Xt(r,i,l),this.Mt(t.Ct),this.Yt(o)}}}function getSingleEl(t){let e=[];for(let l of t.childNodes)if(1===l.nodeType||3===l.nodeType&&l.textContent.trim().length){if(e.length)return null;e.push(l)}return e[0]}function isReplaceEl(t,e){return 1===t.children.length&&e.tagName.includes("-")&&t.children[0].tagName.replace("-SOLARITE-PLACEHOLDER","")===e.tagName}class Template{Ct=[];ee=[];ne;te;constructor(t,e){this.ee=t,this.Ct=e}toJSON(){return this.ne||(this.ne=[getObjectId(this.ee),this.Ct]),this.ne}ie(t=null,e={}){let l,s=!1;if(t){if(l=Globals$1.u.get(t),l||(l=new RootNodeGroup(this,t,e),Globals$1.u.set(t,l),s=!0),0===l.Lt.length&&this.Ct.length||l.Lt.length>this.Ct.length)throw Error(`Solarite Error: Parent HTMLElement ${l.Qt.ee.join("${...}")} and ${l.Lt.length} \${value} placeholders can't accomodate a Template with ${this.Ct.length} values.`)}else l=new RootNodeGroup(this,null,e),t=l.getRootNode(),Globals$1.u.set(t,l),s=!0;return s||(1!==this.ee?.length||this.ee[0]?l.Mt(this.Ct):t.innerHTML=""),l.ae=new Map,t}St(){return this.kt||(this.kt=this.Ct.length?getObjectHash(this):this.ee[0]),this.kt}Ot(){return this.It||(this.It=this.Ct.length?this.toJSON()[0]:this.ee[0]),this.It}}function h(t=void 0,...e){if(void 0===t&&!e.length&&arguments.length)throw Error("h() cannot be called with undefined.");if(!(t instanceof Node)){if(Array.isArray(t))return new Template(t,e);if("string"==typeof t||t instanceof String){if("object"==typeof e[0]){e.slice(1);let t=[],l=[];return assert(t.length===l.length+1),new Template(t,l)}t.match(/^\s^</)&&(t=t.trim());let l=document.createElement("template");l.innerHTML=t;let s=Util.I(l.content.childNodes);return 1===s.length?s[0]:l.content}if(void 0===t)return(t,...e)=>h(t,...e).ie();if(t instanceof Template)return t.ie();if("object"==typeof t){let e=t;if("Object"!==e.constructor.name)throw Error(`Solarate Web Component class ${e.constructor?.name} must extend HTMLElement.`);if(Globals$1.p.has(e))return((...t)=>{let l=h(...t).ie();Globals$1.p.set(e,l)}).bind(e);{Globals$1.p.set(e,null),e[renderF]();let t=Globals$1.p.get(e);Globals$1.p.delete(e);for(let l in e)t[l]="function"==typeof e[l]?e[l].bind(t):e[l];return t}}throw Error("Unsupported arguments.")}{let l=t,s=e[0];if(!(e[0]instanceof Template)){l.shadowRoot&&(l.innerHTML="");let t=e[0],s=(e,...s)=>(Globals$1.m.add(l),new Template(e,s).ie(l,t));return s}s.ie(l,e[1]),!l.childNodes.length&&this&&l.append(this.ot.xt())}}let renderF="render";function getArg(el,attributeName,defaultValue=void 0,type=ArgType.String,fallback=void 0){let val=defaultValue,attrVal=el.getAttribute(attributeName)||el.getAttribute(Util.A(attributeName)),result;if(null!==attrVal&&(val=attrVal),Array.isArray(type))return type.includes(val)?val:fallback;if("function"==typeof type)return type.constructor?new type(val):type(val);if(type===ArgType.he){let t="string"==typeof val?val.toLowerCase():val;return!["false","0",!1,0,null,void 0,NaN].includes(t)&&(!(!["true",!0].includes(t)&&0===parseFloat(t))||fallback)}switch(type){case ArgType.fe:return result=parseInt(val),isNaN(result)?fallback:result;case ArgType.ue:return result=parseFloat(val),isNaN(result)?fallback:result;case ArgType.String:return[void 0,null,!1].includes(val)?"":val+"";case ArgType.ce:case ArgType.de:if("string"!=typeof val||!val.length)return val;try{return type===ArgType.ce?JSON.parse(val):eval(`(${val})`)}catch(t){return val}default:return val}}function setArgs(t,e,l){for(let s in e)this[s]=getArg(t,s,e[s],l[s]||ArgType.String)}var ArgType={he:"Bool",fe:"Int",ue:"Float",String:"String",JSON:"Json",ce:"Json",de:"Eval"};function defineClass(t,e,l){if(!customElements[getName](t)){(e=e||Util.A(t.name)).includes("-")||(e+="-element");let s=null;l&&(s={pe:l}),customElements[define](e,t,s)}}function createSolarite(t=null){let e=HTMLElement;t&&!t.includes("-")&&(t=t.toLowerCase(),e=Globals$1.i[t],e||(e=document.createElement(t).constructor,Globals$1.i[t]=e));let l=new Proxy(e,{construct:(e,l,s)=>(defineClass(s,null,t),Reflect.construct(e,l,s))});return class extends l{me;be;ye;constructor(t={}){super(),!0===t.ie?this.ie():!1===t.ie&&Globals$1.m.add(this)}re(){!Globals$1.m.has(this)&&this.ie&&this.ie()}ge(){this.re(),Globals$1.connected.has(this)||(Globals$1.connected.add(this),this.be&&this.be()),this.me&&this.me()}ve(){this.ye&&this.ye()}static define(e=null){defineClass(this,e,t)}}}let define="define",getName="getName";const Solarite=new Proxy(createSolarite(),{apply:(t,e,l)=>createSolarite(...l)});export default h;export{ArgType,Globals$1 as Globals,Solarite,Util as SolariteUtil,Template,delve,getArg,h,h as r,setArgs};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "solarite",
3
- "version": "0.3.1",
4
- "description": "Solarite is a small (8KB min+gzip), fast, compilation-free JavaScript library for adding reactivity to web components, so that updates require minimal re-rendering.",
3
+ "version": "0.3.2",
4
+ "description": "Solarite is a small (8KB min+gzip), fast, compilation-free JavaScript library for adding reactivity to native web components, so that updates require minimal re-rendering.",
5
5
  "main": "dist/Solarite.js",
6
6
  "files": [
7
7
  "readme.md",
package/readme.md CHANGED
@@ -1,10 +1,10 @@
1
1
  # Solarite
2
2
 
3
- Solarite is a small (8KB min+gzip), fast, compilation-free JavaScript library for adding reactivity to web components, so that updates require minimal re-rendering. It follows modern web standards and is easy to use with vanilla JavaScript.
3
+ Solarite is a small, fast, compilation-free JavaScript library for adding reactivity to native web components, so that updates require minimal re-rendering. It follows modern web standards and is easy to use with vanilla JavaScript.
4
4
 
5
5
  For documentation and examples, see the **[Official Solarite Page](https://vorticode.github.io/solarite/)**.
6
6
 
7
- Download [Solarite.js](https://vorticode.github.io/solarite/dist/Solarite.js) (111KB, 8.8KB min+gzip)
7
+ Download [Solarite.js](https://vorticode.github.io/solarite/dist/Solarite.js) (109KB, 8.6KB min+gzip)
8
8
 
9
9
  Or:
10
10
 
package/src/ExprPath.js CHANGED
@@ -228,9 +228,6 @@ export default class ExprPath {
228
228
  if (!ng.startNode.parentNode)
229
229
  ng.removeAndSaveOrphans();
230
230
 
231
-
232
-
233
-
234
231
  // Instantiate components created within ${...} expressions.
235
232
  // Embedded style tags are handled elsewhere, but where?
236
233
  for (let el of newNodes) {
@@ -443,16 +440,30 @@ export default class ExprPath {
443
440
  Globals.currentExprPath = null;
444
441
  }
445
442
 
446
- let attrs = (expr +'') // Split string into multiple attributes.
447
- .split(/([\w-]+\s*=\s*(?:"[^"]*"|'[^']*'|[^\s]+))/g)
448
- .map(text => text.trim())
449
- .filter(text => text.length);
443
+ // Attribute as name: value object.
444
+ if (typeof expr === 'object') {
445
+ for (let name in expr) {
446
+ let value = expr[name];
447
+ if (value === undefined || value === false || value === null)
448
+ continue;
449
+ node.setAttribute(name, value);
450
+ this.attrNames.add(name)
451
+ }
452
+ }
450
453
 
451
- for (let attr of attrs) {
452
- let [name, value] = attr.split(/\s*=\s*/); // split on first equals.
453
- value = (value || '').replace(/^(['"])(.*)\1$/, '$2'); // trim value quotes if they match.
454
- node.setAttribute(name, value);
455
- this.attrNames.add(name)
454
+ // Attributes as string
455
+ else {
456
+ let attrs = (expr + '') // Split string into multiple attributes.
457
+ .split(/([\w-]+\s*=\s*(?:"[^"]*"|'[^']*'|[^\s]+))/g)
458
+ .map(text => text.trim())
459
+ .filter(text => text.length);
460
+
461
+ for (let attr of attrs) {
462
+ let [name, value] = attr.split(/\s*=\s*/); // split on first equals.
463
+ value = (value || '').replace(/^(['"])(.*)\1$/, '$2'); // trim value quotes if they match.
464
+ node.setAttribute(name, value);
465
+ this.attrNames.add(name)
466
+ }
456
467
  }
457
468
  }
458
469
 
package/src/NodeGroup.js CHANGED
@@ -283,24 +283,24 @@ export default class NodeGroup {
283
283
  if (!Constructor)
284
284
  throw new Error(`The custom tag name ${tagName} is not registered.`)
285
285
 
286
- let args = {};
286
+ let attribs = {};
287
287
  for (let name in props || {})
288
- args[Util.dashesToCamel(name)] = props[name];
288
+ attribs[Util.dashesToCamel(name)] = props[name];
289
289
 
290
290
  // Pass other attribs to constructor, since otherwise they're not yet set on the element,
291
291
  // and the constructor would otherwise have no way to see them.
292
292
  if (el.attributes.length) {
293
293
  for (let attrib of el.attributes) {
294
294
  let attribName = Util.dashesToCamel(attrib.name);
295
- if (!args.hasOwnProperty(attribName) && attribName !== 'solarite-placeholder')
296
- args[attribName] = attrib.value;
295
+ if (!attribs.hasOwnProperty(attribName) && attribName !== 'solarite-placeholder')
296
+ attribs[attribName] = attrib.value;
297
297
  }
298
298
  }
299
299
 
300
300
  // Create the web component.
301
301
  // Get the children that aren't Solarite's comment placeholders.
302
- let ch = [...el.childNodes].filter(node => node.nodeType !== Node.COMMENT_NODE || !node.nodeValue.startsWith('ExprPath'));
303
- let newEl = new Constructor(args, ch);
302
+ let children = [...el.childNodes].filter(node => node.nodeType !== Node.COMMENT_NODE || !node.nodeValue.startsWith('ExprPath'));
303
+ let newEl = new Constructor(attribs, children);
304
304
 
305
305
  if (!isPreHtmlElement)
306
306
  newEl.setAttribute('is', el.getAttribute('is').toLowerCase());