-
Notifications
You must be signed in to change notification settings - Fork 16
/
new.js
2 lines (2 loc) · 8.94 KB
/
new.js
1
2
var uce=function(e){"use strict";class t extends Map{set(e,t){return super.set(e,t),t}}class n extends WeakMap{set(e,t){return super.set(e,t),t}}
/*! (c) Andrea Giammarchi - ISC */const s=/^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i,r=/<([a-z]+[a-z0-9:._-]*)([^>]*?)(\/?)>/g,l=/([^\s\\>"'=]+)\s*=\s*(['"]?)\x01/g,o=/[\x01\x02]/g;const a=(e,t)=>111===e.nodeType?1/t<0?t?(({firstChild:e,lastChild:t})=>{const n=document.createRange();return n.setStartAfter(e),n.setEndAfter(t),n.deleteContents(),e})(e):e.lastChild:t?e.valueOf():e.firstChild:e,{isArray:c}=Array,i=e=>null==e?e:e.valueOf(),u=(e,t)=>{let n,s,r=t.slice(2);return!(t in e)&&(s=t.toLowerCase())in e&&(r=s.slice(2)),t=>{const s=c(t)?t:[t,!1];n!==s[0]&&(n&&e.removeEventListener(r,n,s[1]),(n=s[0])&&e.addEventListener(r,n,s[1]))}};const{isArray:d,prototype:p}=Array,{indexOf:h}=p,{createDocumentFragment:f,createElement:g,createElementNS:b,createTextNode:m,createTreeWalker:y,importNode:v}=new Proxy(document,{get:(e,t)=>e[t].bind(e)});let w;const x=(e,t)=>t?(e=>{w||(w=b("http://www.w3.org/2000/svg","svg")),w.innerHTML=e;const t=f();return t.append(...w.childNodes),t})(e):(e=>{const t=g("template");return t.innerHTML=e,t.content})(e),C=({childNodes:e},t)=>e[t],A=(e,t,n)=>((e,t,n,s,r)=>{const l=n.length;let o=t.length,a=l,c=0,i=0,u=null;for(;c<o||i<a;)if(o===c){const t=a<l?i?s(n[i-1],-0).nextSibling:s(n[a-i],0):r;for(;i<a;)e.insertBefore(s(n[i++],1),t)}else if(a===i)for(;c<o;)u&&u.has(t[c])||e.removeChild(s(t[c],-1)),c++;else if(t[c]===n[i])c++,i++;else if(t[o-1]===n[a-1])o--,a--;else if(t[c]===n[a-1]&&n[i]===t[o-1]){const r=s(t[--o],-1).nextSibling;e.insertBefore(s(n[i++],1),s(t[c++],-1).nextSibling),e.insertBefore(s(n[--a],1),r),t[o]=n[a]}else{if(!u){u=new Map;let e=i;for(;e<a;)u.set(n[e],e++)}if(u.has(t[c])){const r=u.get(t[c]);if(i<r&&r<a){let l=c,d=1;for(;++l<o&&l<a&&u.get(t[l])===r+d;)d++;if(d>r-i){const l=s(t[c],0);for(;i<r;)e.insertBefore(s(n[i++],1),l)}else e.replaceChild(s(n[i++],1),s(t[c++],-1))}else c++}else e.removeChild(s(t[c++],-1))}return n})(e.parentNode,t,n,a,e),k=(e,t)=>{switch(t[0]){case"?":return((e,t,n)=>s=>{const r=!!i(s);n!==r&&((n=r)?e.setAttribute(t,""):e.removeAttribute(t))})(e,t.slice(1),!1);case".":return((e,t)=>"dataset"===t?(({dataset:e})=>t=>{for(const n in t){const s=t[n];null==s?delete e[n]:e[n]=s}})(e):n=>{e[t]=n})(e,t.slice(1));case"@":return u(e,"on"+t.slice(1));case"o":if("n"===t[1])return u(e,t)}switch(t){case"ref":return(e=>{let t;return n=>{t!==n&&(t=n,"function"==typeof n?n(e):n.current=e)}})(e);case"aria":return(e=>t=>{for(const n in t){const s="role"===n?n:`aria-${n}`,r=t[n];null==r?e.removeAttribute(s):e.setAttribute(s,r)}})(e)}return((e,t)=>{let n,s=!0;const r=document.createAttributeNS(null,t);return t=>{const l=i(t);n!==l&&(null==(n=l)?s||(e.removeAttributeNode(r),s=!0):(r.value=l,s&&(e.setAttributeNodeNS(r),s=!1)))}})(e,t)};function N(e){const{type:t,path:n}=e,s=n.reduceRight(C,this);return"node"===t?(e=>{let t,n,s=[];const r=l=>{switch(typeof l){case"string":case"number":case"boolean":t!==l&&(t=l,n||(n=m("")),n.data=l,s=A(e,s,[n]));break;case"object":case"undefined":if(null==l){t!=l&&(t=l,s=A(e,s,[]));break}if(d(l)){t=l,0===l.length?s=A(e,s,[]):"object"==typeof l[0]?s=A(e,s,l):r(String(l));break}if(t!==l)if("ELEMENT_NODE"in l)t=l,s=A(e,s,11===l.nodeType?[...l.childNodes]:[l]);else{const e=l.valueOf();e!==l&&r(e)}break;case"function":r(l(e))}};return r})(s):"attr"===t?k(s,e.name):(e=>{let t;return n=>{const s=i(n);t!=s&&(t=s,e.textContent=null==s?"":s)}})(s)}const E=e=>{const t=[];let{parentNode:n}=e;for(;n;)t.push(h.call(n.childNodes,e)),e=n,({parentNode:n}=e);return t},O="isµ",$=new n,S=/^(?:textarea|script|style|title|plaintext|xmp)$/,M=(e,t)=>{const n="svg"===e,a=((e,t,n)=>{let a=0;return e.join("").trim().replace(r,((e,t,r,o)=>{let a=t+r.replace(l,"=$2$1").trimEnd();return o.length&&(a+=n||s.test(t)?" /":"></"+t),"<"+a+">"})).replace(o,(e=>""===e?"\x3c!--"+t+a+++"--\x3e":t+a++))})(t,O,n),c=x(a,n),i=y(c,129),u=[],d=t.length-1;let p=0,h=`${O}${p}`;for(;p<d;){const e=i.nextNode();if(!e)throw`bad template: ${a}`;if(8===e.nodeType)e.data===h&&(u.push({type:"node",path:E(e)}),h=`${O}${++p}`);else{for(;e.hasAttribute(h);)u.push({type:"attr",path:E(e),name:e.getAttribute(h)}),e.removeAttribute(h),h=`${O}${++p}`;S.test(e.localName)&&e.textContent.trim()===`\x3c!--${h}--\x3e`&&(e.textContent="",u.push({type:"text",path:E(e)}),h=`${O}${++p}`)}}return{content:c,nodes:u}},T=(e,t)=>{const{content:n,nodes:s}=$.get(t)||$.set(t,M(e,t)),r=v(n,!0);return{content:r,updates:s.map(N,r)}},L=(e,{type:t,template:n,values:s})=>{const r=j(e,s);let{entry:l}=e;l&&l.template===n&&l.type===t||(e.entry=l=((e,t)=>{const{content:n,updates:s}=T(e,t);return{type:e,template:t,content:n,updates:s,wire:null}})(t,n));const{content:o,updates:a,wire:c}=l;for(let e=0;e<r;e++)a[e](s[e]);return c||(l.wire=(e=>{const{firstChild:t,lastChild:n}=e;if(t===n)return n||e;const{childNodes:s}=e,r=[...s];return{ELEMENT_NODE:1,nodeType:111,firstChild:t,lastChild:n,valueOf:()=>(s.length!==r.length&&e.append(...r),e)}})(o))},j=({stack:e},t)=>{const{length:n}=t;for(let s=0;s<n;s++){const n=t[s];n instanceof P?t[s]=L(e[s]||(e[s]={stack:[],entry:null,wire:null}),n):d(n)?j(e[s]||(e[s]={stack:[],entry:null,wire:null}),n):e[s]=null}return n<e.length&&e.splice(n),n};class P{constructor(e,t,n){this.type=e,this.template=t,this.values=n}}const B=e=>{const s=new n;return Object.assign(((t,...n)=>new P(e,t,n)),{for(n,r){const l=s.get(n)||s.set(n,new t);return l.get(r)||l.set(r,(t=>(n,...s)=>L(t,{type:e,template:n,values:s}))({stack:[],entry:null,wire:null}))},node:(t,...n)=>L({stack:[],entry:null,wire:null},new P(e,t,n)).valueOf()})},D=new n,W=(e,t)=>{const n="function"==typeof t?t():t,s=D.get(e)||D.set(e,{stack:[],entry:null,wire:null}),r=n instanceof P?L(s,n):n;return r!==s.wire&&(s.wire=r,e.replaceChildren(r.valueOf())),e},H=B("html"),_=B("svg");function z(e){for(var t=e[0],n=1,s=arguments.length;n<s;n++)t+=arguments[n]+e[n];return t}const{defineProperties:R,keys:F}=Object,J=(e,t,n,s,r)=>({configurable:!0,get:()=>s,set(l){(e||l!==s||t&&"object"==typeof l&&l)&&(s=l,n?r.call(this,s):r.call(this))}}),q=()=>{};const G=(({all:e=!1,shallow:t=!0,useState:n=q,getAttribute:s=((e,t)=>e.getAttribute(t))}={})=>(r,l,o)=>{const a=((e,t,n,s,r,l)=>{const o={},a=r!==q,c=[n,s,a];for(let n=F(e),s=0;s<n.length;s++){const i=t(e,n[s]),u=a?r(i):[i,r];l&&(u[1]=l),o[n[s]]=J.apply(null,c.concat(u))}return o})(l,((e,t)=>{let n=e[t],l=typeof n;return r.hasOwnProperty(t)?(n=r[t],delete r[t]):r.hasAttribute(t)&&(n=s(r,t),"number"==l?n=+n:"boolean"==l&&(n=!/^(?:false|0|)$/.test(n))),n}),e,t,n,o);return R(r,a)})({dom:!0}),I=customElements,{define:K}=I,{parse:Q,stringify:U}=JSON,{create:V,defineProperties:X,getOwnPropertyDescriptor:Y,keys:Z}=Object,ee="element",te=new WeakMap,ne=(se=new Map([[ee,{c:HTMLElement,e:ee}]]),{get:e=>se.get(e),set:(e,t)=>(se.set(e,t),t)});var se;const re=e=>document.createElement(e),le=e=>ne.get(e)||ne.set(e,{c:re(e).constructor,e:e}),oe=(e,t)=>{const{attachShadow:n,attributeChanged:s,bound:r,connected:l,disconnected:o,formAssociated:a,handleEvent:c,init:i,observedAttributes:u,props:d,render:p,style:h}=t,f=new WeakMap,g={},b={},m=[],y=V(null),v=(e,t,s)=>{if(!f.has(e)){f.set(e,0),X(e,{html:{configurable:!0,value:ce.bind(n?e.attachShadow(n):e)}});for(let t=0;t<w;t++){const{type:n,options:s}=m[t];e.addEventListener(n,e,s)}if(r&&r.forEach(ae,e),d){const t={};for(let e=Z(d),n=0;n<e.length;n++){const s=e[n],r=d[s];t[s]="object"==typeof r?Q(U(r)):r}te.set(e,t),G(e,t,p)}(i||p)&&(i||p).call(e),t&&(e[t]=s)}};for(let e=Z(t),n=0,{length:s}=e;n<s;n++){const s=e[n];if(/^on./.test(s)&&!/Options$/.test(s)){const e=t[s+"Options"]||!1,n=s.toLowerCase();let r=n.slice(2);m.push({type:r,options:e}),y[r]=s,n!==s&&(r=n.slice(2,3)+s.slice(3),y[r]=s,m.push({type:r,options:e}))}switch(s){case"attachShadow":case"constructor":case"observedAttributes":case"style":break;default:b[s]=Y(t,s)}}const{length:w}=m;if(w&&!c&&(b.handleEvent={value(e){this[y[e.type]](e)}}),null!==d)if(d)for(let e=Z(d),t=0;t<e.length;t++){const n=e[t];b[n]={get(){return v(this),te.get(this)[n]},set(e){v(this,n,e)}}}else b.props={get(){const e={};for(let{attributes:t}=this,{length:n}=t,s=0;s<n;s++){const{name:n,value:r}=t[s];e[n]=r}return e}};u&&(g.observedAttributes={value:u}),b.attributeChangedCallback={value(){v(this),s&&s.apply(this,arguments)}},a&&(g.formAssociated={value:a}),b.connectedCallback={value(){v(this),l&&l.call(this)}},o&&(b.disconnectedCallback={value:o});const{c:x,e:C}=le(t.extends||ee);class A extends x{}X(A,g),X(A.prototype,b);const k=[e,A];return C!==ee&&k.push({extends:C}),K.apply(I,k),ne.set(e,{c:A,e:C}),h&&(document.head.appendChild(re("style")).textContent=h(C===ee?e:C+'[is="'+e+'"]')),A};function ae(e){this[e]=this[e].bind(this)}function ce(){return W(this,H.apply(null,arguments))}return I.get("uce-lib")||I.define("uce-lib",class extends le(ee).c{static get define(){return oe}static get render(){return W}static get html(){return H}static get svg(){return _}static get css(){return z}}),e.css=z,e.define=oe,e.html=H,e.render=W,e.svg=_,e}({});