UNPKG

galho

Version:

galho is js library for create and manipulate dom elements without need compiling, configuration or VirtualDom

2 lines (1 loc) 18.6 kB
window.g=window.$=function(){const t=(t,e)=>t instanceof e,e=t=>"string"==typeof t,i=t=>"function"==typeof t,r=t=>"object"==typeof t,s=t=>"number"==typeof t,n=t=>void 0===t,l=t=>Array.isArray(t),h=Object.assign,u=(t,e)=>n(t)?e:t,o=t=>t.length,a=JSON.stringify;function f(t,e,i,r){return i&&(t.eh[e]||=[]).push(r?h(i,r):i),t}function c(t,e,i){if(e in t.eh)if(i){let r=t.eh[e];for(let t=0,e=r.length;t<e;t++)if(r[t]===i)return void r.splice(t,1)}else delete t.eh[e];return t}function d(t,e,...i){if(!t.slip){let r=t.eh[e];if(r)for(let e=0;e<r.length;e++){let s=r[e];if(!s.check||s.check.apply(t,i))if(s.once&&r.splice(e--,1),s.delay)setTimeout((()=>s.apply(t,i)),s.delay);else if(!1===s.apply(t,i))break}}return t}function p(r,s,n){if(!r)return null;let h=e(r)?new w(document.createElement(r)):"render"in r?r.render():t(r,w)?r:new w(r);return s&&(e(s)?e(r)?h.attr("class",s):h.c(s):l(s)||i(s)?h.add(s):h.p(s)),null!=n&&h.add(n),h}const g=/[A-Z]/g,m=t=>t.e&&1===t.e?.nodeType,v=t=>t.e?t.e:t,y=t=>1===t.nodeType;class w{e;constructor(t){this.e=t}static empty;get active(){return this.e.ownerDocument.activeElement==this.e}get parent(){let t=this.e.parentElement;return t&&new w(t)}get prev(){let t=this.e.previousElementSibling;return t&&new w(t)}get next(){let t=this.e.nextElementSibling;return t&&new w(t)}get first(){let t=this.e.firstElementChild;return t&&new w(t)}get last(){let t=this.e.lastElementChild;return t&&new w(t)}get rect(){return this.e.getBoundingClientRect()}toJSON(){}contains(t){return!!t&&this.e.contains(v(t))}v(t){let e=this.e;return n(t)?e.value:(e.value=t,this)}on(t,i,r){if(e(t))i&&this.e.addEventListener(t,i,r);else if(l(t)){if(i)for(let e of t)this.e.addEventListener(e,i,r)}else for(let e in t){let r=t[e];r&&this.e.addEventListener(e,r,i)}return this}one(t,e){return this.on(t,e,{once:!0})}emit(t,i){return this.e.dispatchEvent(e(t)?new Event(t,i):t),this}off(t,i){for(let r of e(t)?[t]:t)this.e.removeEventListener(r,i);return this}put(t,e){switch(typeof e){case"object":if(!e)break;if(m(e)?e=e.e:y(e))this.e.insertAdjacentElement(t,e);else if(i(e.render))this.put(t,e.render());else if(i(e.then))e.then((e=>this.put(t,e)));else if("a"==t[0])for(let i=e.length-1;i>=0;i--)this.put(t,e[i]);else for(let i=0,r=e.length;i<r;i++)this.put(t,e[i]);break;case"string":case"number":case"bigint":this.e.insertAdjacentText(t,e);break;case"function":this.put(t,e())}return this}after(t){return this.put("afterend",t)}before(t){return this.put("beforebegin",t)}putText(t,e){return this.e.insertAdjacentText(t,e),this}putHTML(t,e){return this.e.insertAdjacentHTML(t,e),this}add(t){switch(typeof t){case"object":if(!t)break;if(m(t)?t=t.e:y(t))this.e.append(t);else if(i(t.render))this.add(t.render());else if(i(t.then))t.then((t=>this.add(t)));else for(let e=0,i=t.length;e<i;e++)this.add(t[e]);break;case"string":case"number":case"bigint":this.e.append(t);break;case"function":this.add(t())}return this}badd(t){return this.put("afterbegin",t)}place(t,e){if(!t)return this.badd(e);var i=this.e.children,r=i[t<0?i.length+t:t-1];if(!r)throw"invalid index";return new w(r).put("afterend",e),this}unplace(t){return this.e.children[t].remove(),this}addHTML(t){return this.putHTML("beforeend",t)}set(t){return this.e.textContent="",this.add(t),this}is(t){return e(t)?this.e.matches(t):this.e==v(t)}id(t){return t?(this.e.id=t,this):this.e.id}text(t){return n(t)?this.e.textContent:(this.e.textContent=t,this)}addTo(t){return v(t).appendChild(this.e),this}html(t){return arguments.length?(this.e.innerHTML=t,this):this.e.innerHTML}replace(t){return this.put("beforebegin",t),this.remove(),this}focus(t){return this.e.focus(t),this}blur(){return this.e.blur(),this}child(t){let i,r=this.e.children;if(e(t)){for(let e=0;e<r.length;e++)if((i=r[e]).matches(t))return new w(i);return null}if(s(t))return(i=r[t<0?o(r)+t:t])?new w(i):null}childs(t,r){let n=Array.from(this.e.children);return new b(...e(t)?n.filter((e=>e.matches(t))):s(t)?n.slice(t,r):i(t)?n.filter((e=>t(new w(e)))):n)}query(t){let e=this.e.querySelector(t);return e&&new w(e)}queryAll(t){return new b(...Array.from(this.e.querySelectorAll(t)))}closest(t){return p(this.e.closest(t))}parents(t){let e=new b,i=this.e;for(;i=i.parentElement;)t&&!i.matches(t)||e.push(i);return e}clone(t){return new w(this.e.cloneNode(t))}p(t,i){if(e(t)){if(n(i))return this.e[t];this.e[t]=i}else for(let e in t){let r=t[e];i||n(r)||(this.e[e]=r)}return this}call(t,...e){return this.e[t](...e),this}css(t,i,r){let s=this.e.style;if(e(t)){if(n(i))return s[t];s.setProperty(t.replace(g,(t=>"-"+t)),i,r?"important":"")}else for(let e in t)s.setProperty(e.replace(g,(t=>"-"+t)),t[e],i?"important":"");return this}uncss(...t){if(t.length)for(let e=0;e<t.length;e++)this.e.style[t[e]]="";else this.e.removeAttribute("style");return this}c(t,i){return t&&this.e.classList[!1===i?"remove":"add"].apply(this.e.classList,(e(t)?t.trim().split(" "):t).filter((t=>t))),this}tcls(t){for(let e of t.split(" "))e&&this.e.classList.toggle(e);return this}attr(t,i){let r=(t,e)=>!1===e?this.e.removeAttribute(t):this.e.setAttribute(t,!0===e?"":e);if(e(t)){if(n(i))return this.e.getAttribute(t);r(t,i)}else for(let e in t)r(e,t[e]);return this}d(t){let e=this.e;return n(t)?u(e._d,(e=e.parentElement)&&new w(e).d()):(e._d=t,this)}remove(){return this.e.remove(),this}}class b extends Array{constructor(...t){s(t[0])?super(t[0]):super(...t.map((t=>"e"in t?t.e:t)))}e(t){return new w(this[t])}on(t,e,i){for(let r=0;r<this.length;r++)this[r].addEventListener(t,e,i);return this}emit(t,i){e(t)&&(t=new Event(t,i));for(let e=0,i=this.length;e<i;e++)this[e].dispatchEvent(t);return this}css(t,e){for(let i=0;i<this.length;i++){let r=this[i].style;for(let i in t)r.setProperty(i.replace(g,(t=>"-"+t)),t[i],e?"important":"")}return this}uncss(t){for(let e=0;e<this.length;e++){let i=this[e];if(t)for(let e=0;e<t.length;e++)i.style.removeProperty(t[e]);else i.removeAttribute("style")}return this}c(t,i){e(t)&&(t=t.split(" ").filter((t=>t)));for(let e=0;e<this.length;e++)this[e].classList[!1===i?"remove":"add"](...t);return this}p(t,e){for(let i=0;i<this.length;i++)this[i][t]=e;return this}remove(){for(let t of this)t.remove();return this}child(t){let i=new b;for(let r of this)if(e(t))for(let e=0;e<r.children.length;e++){let s=r.children[e];s.matches(t)&&i.push(s)}else s(t)?t in r.children&&i.push(r.children[t]):i.push(...Array.from(r.children));return i}next(){return new b(...this.map((t=>t.nextElementSibling)))}prev(){return new b(...this.map((t=>t.previousElementSibling)))}do(t){for(let e=0;e<this.length;e++)t(new w(this[e]),e);return this}eachS(t){return this.forEach(((e,i)=>t(new w(e),i))),this}push(...t){return super.push(...t.map((t=>p(t).e)))}}class A extends Array{put(t,...e){if(this.parse)for(let i=0;i<e.length;i++){let r=this.parse(e[i],i+t);void 0===r?e.splice(i--,1):e[i]=r}if(!e.length)return;let i=e.length,r=this.length;this.length+=i;for(let e=r-1;e>=t;e--)this[e+i]=this[e];for(let r=0;r<i;r++)this[t+r]=e[r];if(this.tags)for(let e in this.tags){let r=this.tags[e];r.i>=t&&(r.i+=i)}return d(this,"push",e),this.nu||d(this,"update",{tp:"push",start:t,items:e}),this}removeAt(t,e=1){if(e+t>this.length&&(e=this.length-t),!(e<=0)){var i=Array(e);for(let r=0;r<e;r++)i[r]=this[t+r];for(let i=t+e;i<this.length;i++)this[i-e]=this[i];this.length-=e;for(let t in this.g)this.g[t].remove(...Array.from(i));if(this.tags)for(let i in this.tags){let r=this.tags[i];r.i>=t+e?r.i-=e:r.i>=t&&this.tag(i,r.replace?this[Math.min(r.i,this.length-1)]:null,r.replace)}return d(this,"pop",i),this.nu||d(this,"update",{tp:"pop",start:t,items:i}),i}}push(...t){return this.put(this.length,...t),this.length}pop(){if(this.length)return this.removeAt(this.length-1)[0]}shift(){return this.removeAt(0)[0]}unshift(...t){return this.put(0,...t),this.length}set(t){if(!this.length&&!t?.length)return;this.nu=!0;let e=this.removeAt(0,this.length);if(t){if(this.sorts)for(let e=0;e<this.sorts.length;e++){let i=this.sorts[e],r={vars:{}};t.sort(((t,e)=>(r.vars[0]=t,r.vars.b=e,i.calc(r))))}this.put(0,...t)}return this.nu=!1,d(this,"update",{tp:"set",items:this,removed:e}),this}has(t,e=0){for(;e<this.length;e++)if(this[e][this.key]===t)return!0;return!1}includes(t,e){let i=this.key;if(i){for(e=0;e<this.length;e++){let r=this[e];if(r===t||r[i]===t)return!0}return!1}return super.includes(t,e)}addGroup(t){let e=this.g[t]=new I;return e.eh={},e.l=this,e}group(t){return this.g[t]||this.addGroup(t)}on(t,e,r){return i(t)&&(e=t,t="update"),f(this,t,e,r)}find(t,e){return super.find(i(t)?t:e=>e===t||e&&e[this.key]==t,e)}findIndex(t,e){return super.findIndex(i(t)?t:e=>e===t||e[this.key]==t,e)}sort(t){return this.set(this.slice().sort(t)),this}remove(...t){for(let e of t){let t=this.findIndex(e);t>=0&&this.removeAt(t)}return this}place(t,e){let i=this.findIndex(t),r=this[i];return this.removeAt(i),this.put(e,r),d(this,"update"),this}tag(t,e,i){let r,s=null,n=this.tags||={},l=n[t];switch(e){case void 0:return l?.v;case null:if(!l)return this;delete n[t];break;default:if(s=this.findIndex(e),-1==s)return this;if(l&&s==l.i)return this;r={v:e=this[s],i:s,replace:i},n[t]=r}return this.retag(t,l?.i),this}retag(t,e){let i=this.tags[t];d(this,"tag:"+t,i?.v),d(this,"update",{tp:"tag",tag:t,newI:i?.i,oldI:e})}ontag(t,e){return f(this,`tag:${t}`,e),this}unbind(t){let e=this.binds;if(e){let i=e.findIndex((e=>e[0]==t));-1!=i&&e.splice(i,1)}return this}bind(t,e={}){let r=i(e)?{insert:e}:e,s=e=>{r.empty&&r.empty.call(this,e)&&t.set(e)},n=(e,i)=>{for(let s=0;s<e.length;s++){let n=e[s],l=r.insert?r.insert.call(this,n,i+s,t):n;l&&t.place(i+s,l)}},l=(e,i)=>{for(let s=0;s<e.length;s++)r.remove&&!r.remove.call(this,e[s],i+s,t)||t.unplace(i+s)},h=e=>{switch(e.tp){case"push":this.length==e.items.length&&s(!1),n(e.items,e.start);break;case"pop":l(e.items,e.start),this.length||s(!0);break;case"tag":r.tag&&(null!=e.oldI&&r.tag.call(this,!1,e.oldI,t,e.tag,this[e.oldI]),null!=e.newI&&r.tag.call(this,!0,e.newI,t,e.tag,this[e.newI]));break;case"set":!1===r.clear?l(e.removed,0):r.clear?r.clear(t):t.set(),e.items?(e.removed||s(!1),n(e.items,0)):s(!0);break;case"reload":if(r.reload)for(let i=0;i<e.items.length;i++){let s=e.items[i],n=r.reload.call(this,s,e.start+i,t);n&&t.child(e.start+i).replace(n)}else l(e.items,e.start),n(e.items,e.start)}};if(this.on(h),r.groups)if(i(r.groups))for(let e in this.g)S(this,t,e,r.groups);else for(let e in r.groups)S(this,t,e,r.groups[e]);return(this.binds||=[]).push([t,h]),n(this,0),t}reload(t){return this.reloadAt(this.findIndex(t))}reloadAt(t){return d(this,"update",{tp:"reload",start:t,items:[this[t]]})}reloadAll(){return d(this,"update",{tp:"reload",start:0,items:this.slice()})}eh;slip;tags;sorts;g;nu;key;childKey;parse;binds}function k(t,e){let i=t.findIndex(e.item);return-1!==i&&(e.item=Object.assign(e.item=t[i],e.props),d(t,"edit",[e]),d(t,"update",null)),t}function x(t,e){e||l(t)||(e=t,t=null);let r=new A;if(r.g={},r.eh={},e&&(i(e)&&(e={parse:e}),r.key=e.key,r.childKey=e.child,r.sorts=e.sorts,r.parse=e.parse||e.converter,e.g))for(let t of e.g)r.addGroup(t);return t&&r.put(0,...t),r}function E(t,e){let i=[],r=t.length;for(let s=0;s<e.length;s++){let n=e[s],l=t.l.findIndex(n);-1==l||t.includes(n=e[s]=t.l[l])?e.splice(s--,1):(i[s]=l,t[r+s]=n)}return o(e)&&(d(t,"push",e),t.nu||d(t,"set",e,i)),i}class I extends Array{eh={};slip;nu;l;push(...t){return E(this,t),this.length}toggle(t){this.includes(t)?this.remove(t):E(this,[t])}pushRange(t,e){return E(this,this.l.slice(t,e))}pushAll(){return E(this,this.l.slice())}remove(...t){let e=Array(t.length);for(let i=0;i<t.length;i++){let r=t[i],s=this.l.indexOf(r),n=this.indexOf(r);if(-1!=n){e[i]=s;for(let t=n;t<this.length-1;t++)this[t]=this[t+1];delete this[this.length-1]}else t.splice(i--,1)}return this.length-=t.length,t.length&&(d(this,"remove",t),this.nu||d(this,"set",null,null,t,e)),e}removeAt(t,e=0){let i=this[t],r=[i];this.splice(t,e),d(this,"remove",r),this.nu||d(this,"set",r,[this.indexOf(i)])}clear(){return this.remove(...this)}removeRange(t,e){return this.remove(...this.l.slice(t,e))}set(t){if(!o(t)&&!o(this))return;this.nu=!0;let e=this.slice(),i=this.clear(),r=E(this,t);return this.nu=!1,d(this,"set",t,r,e,i),this}invert(){return this.set(this.l.filter((t=>!this.includes(t)))),this}setRange(t,e){this.set(this.l.slice(t,e))}indexes(){for(var t=Array(this.length),e=0;e<this.length;e++)t[e]=this.l.indexOf(this[e]);return t}keyField(){for(var t=this.l.key,e=[],i=0;i<this.length;i++)e.push(this[i][t]);return e}on(t){return f(this,"set",t)}reload(t,e=this.l.indexOf(t)){return d(this,"set",[t],null,[e])}static get[Symbol.species](){return Array}}function S(t,e,i,r){let s=t.g[i];if(s){let n=(s,n,l)=>{for(let h=0;h<s.length;h++){let u=n[h];r.call(t,l,u,e,i,s[h])}};s.on(((t,e,i,r)=>{i&&n(i,r,!1),t&&n(t,e,!0)}))}return e}return p.range=void 0,function(t){const e=(t,e,i)=>t<e?e:t>=i?i-1:t,i=(t,e)=>(t.tags||={})[e];function r(t,e){let r=i(t,e);return r?r.i:0}function s(t,e,r,s){let n=t.g[e],l=i(t,e),h=l?l.i:-1,u=t.findIndex(r);if(h!=u&&(t.tag(e,r),n))switch(s){case"set":n.set([t[u]]);break;case"add":n.push(t[u]);break;case"range":if(h>u){let t=h;h=u,u=t}n.setRange(h,u);break;case"addR":if(h>u){let t=h;h=u,u=t}n.pushRange(h,u)}return t}t.pivot=r,t.add=s,t.addAll=function(t,e){return t.length&&(t.tag(e)||t.tag(e,t[0]),t.g[e]&&t.g[e].pushAll()),t},t.clear=function(t,e){return t.tag(e,null),t.g[e]&&t.g[e].clear(),t},t.onchange=function(t,e,r){let s=t.g[e];return s?s.on((()=>{let n=i(t,e);r.call(t,n&&n.v,s)})):t.ontag(e,r),t},t.tp=(t,e)=>t?e?"addR":"add":e?"range":"set",t.move=function(t,i,n,l){return s(t,i,t[e(r(t,i)+n,0,t.length)],l)},t.movePivot=function(t,i,s,n){let l=t.length;if(l){let h=r(t,i)+s;t.tag(i,t[n?h<0?l-1:h>=l?0:h:e(h,0,t.length)])}return t},t.list=function(t,e){let r,s=t.g[e];return s?s.slice():(r=i(t,e))?[r.v]:[]}}(p.range||(p.range={})),p.Component=class{p;$;validators;constructor(t){this.eh={},this.p=t||{}}focus(){return this.$.focus(),this}render(){if(void 0===this.$){let t=this.view();this.$=t?"render"in t?t.render():m(t)?t:new w(t):null}return this.$}dispose(){this.$&&(this.$.remove(),delete this.$)}addValidators(t,e){var i,r;return((i=this.validators||(this.validators={}))[r=t]||(i[r]=[])).push(e),this}_valid(t,e){let i=this.validators[t];if(i)for(let r=0;r<i.length;r++)if(!i[r](e,t))return!1;return!0}set(t,e){let i=this.p;if(r(t))if(l(t)){let e={};for(let r=0;r<t.length;r++){let s=t[r];e[s]=i[s]}t=e}else{let e={};for(let r in t){let s=t[r];s===i[r]||this.validators&&!this._valid(r,s)||(i[r]=e[r]=s)}if(!Object.keys(t=e).length)return this}else if(t){if(i[t]===e||this.validators&&!this._valid(t,e))return this;i[t]=e,t={[t]:e}}else t=i;return d(this,"set",t),this}toggle(t){return this.set(t,!this.p[t])}clone(){return new this.constructor(this.p)}eh;on(t,e,r){return i(t)&&(e=t,t="set"),f(this,t,e,r)}off(t,e){return c(this,t,e)}emit(t,...e){return d(this,t,...e)}onset(t,i,r={}){return r.check=e(t)?e=>t in e:e=>t.some((t=>t in e)),f(this,"set",i,r)}bind(t,e,i,r){let s=()=>e.call(this,t,this.p);return i&&(s.check=t=>i in t),r||s(),this.on(s),"render"in t?t.render():t}toJSON(){}},p.G=w,p.Group=I,p.L=A,p.M=b,p.active=()=>p(document.activeElement),p.arr=t=>l(t)?t:void 0===t?[]:[t],p.asE=v,p.assign=h,p.bind=S,p.byKey=function(t,e,i,r=0){for(;r<t.length;r++)if(e===t[r][i])return t[r];return null},p.call=(t,e)=>(e(t),t),p.clearEvent=function(t){t.stopImmediatePropagation(),t.preventDefault()},p.clone=t=>h({},t),p.copy=function(t,e,i=!0,r=(t=>t)){i&&e.set(t.map(r)),t.on((t=>{switch(t.tp){case"push":e.put(t.start,...t.items.map(((e,i)=>r(e,t.start+i))));break;case"pop":e.removeAt(t.start,t.items.length);break;case"set":e.set(t.items.map(r));break;case"edit":throw"not implemented"}}))},p.create=(t,e,...i)=>h(new t(...i),e),p.css=function t(e,i,s=" "){let n,l=[">"," ",":","~","+"],h="",u="";function o(t,e){return e.split(",").map((e=>t.map((t=>-1!=l.indexOf(e[0])?t+e:e.includes("&")?e.replaceAll("&",t):t+s+e)).join(","))).join(",")}if(!i||"@"==i[0]){for(let i in e)h+=t(e[i],i,s);return h?i?i+"{"+h+"}":h:""}for(let l in e){let a=e[l];(a||0===a)&&(r(a)?u+=t(a,o(n||(n=i.split(",")),l),s):h+=l.replace(g,(t=>"-"+t.toLowerCase()))+":"+a+";")}return(h?i+"{"+h+"}":"")+u},p.def=u,p.delay=function(t,e,i,r){return r=r.bind(t.e),t.on(e,(function(t){var s=`__${e}`;clearTimeout(this[s]),this[s]=setTimeout(r,i,t)}))},p.distinct=t=>t.filter(((e,i)=>-1==t.indexOf(e,i+1))),p.div=function(t,r){let s=new w(document.createElement("div"));return t&&(e(t)?s.attr("class",t):l(t)||i(t)?s.add(t):s.p(t)),null!=r&&s.add(r),s},p.edit=k,p.editItems=function(t,...e){let i;for(let r of e){let e=r[t.key],s=t.findIndex((i=>i[t.key]==e));-1!==s&&(t[s]=r,i=!0)}return i&&(d(t,"edit",null),d(t,"update",null)),t},p.emit=d,p.emitAsync=async function(t,e,i){if(t)for(let r=0;r<t.length;r++){let s=t[r];if(s.once&&t.splice(r--,1),s.delay&&await new Promise((t=>setTimeout(t,s.delay))),!1===await s.apply(i,e))break}},p.empty="&#8203;",p.extend=function(t,e){if(t&&t.eh){if(e){if(i(e)&&(e={parse:e}),e.g)for(let i of e.g)i in t.g||t.addGroup(i);if(e.sorts)throw"not implemented";if(e.key){if(t.key&&t.key!=e.key)throw"inconpatible lists";t.key=e.key}}}else t=x(t,e);return t},p.filter=(t,e)=>t.filter(e||(t=>t)),p.g=p,p.get=t=>p(document.querySelector(t)),p.getAll=t=>new b(...Array.from(document.querySelectorAll(t))),p.html=function(t,e,i){return p(document.createElementNS("http://www.w3.org/1999/xhtml",t),e,i)},p.iByKey=function(t,e,i,r=0){for(;r<t.length;r++)if(e===t[r][i])return r;return-1},p.is=t,p.isA=l,p.isB=t=>"boolean"==typeof t,p.isE=m,p.isF=i,p.isN=s,p.isO=r,p.isP=t=>t&&i(t.then),p.isS=e,p.isU=n,p.json=a,p.l=o,p.m=(...t)=>new b(...t),p.notF=(t,e,i,r)=>new Error(`${e||"item"} '${t}' not found`+(i?` in '${i}' ${r||""}`:"")),p.notImp=()=>new Error("not implemented"),p.off=c,p.on=f,p.onfocusout=function(t,e){return e&&t.on("focusout",(i=>t.contains(i.relatedTarget)||e.call(t,i))),t},p.orray=x,p.set=function(t,e,i){return t[e]=i,t},p.sub=(t,e)=>t.map((t=>t?t[e]:null)),p.svg=function(t,i,r){var s=new w(document.createElementNS("http://www.w3.org/2000/svg",t));return i&&(e(i)||l(i)?s.c(i):s.attr(i)),(r||0===r)&&s.add(r),s},p.t=t=>!1!==t,p.toSVG=function(t){let e=(new DOMParser).parseFromString(t,"image/svg+xml");return new b(...Array.from(e.children))},p.toStr=t=>null==t?t+"":"",p.tryPush=function(t,e){let i=e[t.key];t.find((e=>e[t.key]==i))?k(t,{item:i,props:e}):t.push(e)},p.wait=t=>new Promise((e=>setTimeout(e,t))),p.wrap=function(t,e,r){return i(t)&&(t=t()),i(t?.render)&&(t=t.render()),t instanceof Element?t=new w(t):t instanceof w||(t=p(r||"div",0,t)),e&&p(t,e),t},p.z=t=>t[o(t)-1],p}();