UNPKG

@blaze/atoms

Version:

Open Source UI Toolkit - Atoms

2 lines 10.3 kB
let t,e,l=!1,n=!1,o=!1,s=!1;const c="undefined"!=typeof window?window:{},i=c.document||{head:{}},r={t:0,l:"",jmp:t=>t(),raf:t=>requestAnimationFrame(t),ael:(t,e,l,n)=>t.addEventListener(e,l,n),rel:(t,e,l,n)=>t.removeEventListener(e,l,n),ce:(t,e)=>new CustomEvent(t,e)},a=t=>Promise.resolve(t),u=(t,e,l)=>{l&&l.map((([l,n,o])=>{const s=d(t,l),c=f(e,o),i=$(l);r.ael(s,n,c,i),(e.o=e.o||[]).push((()=>r.rel(s,n,c,i)))}))},f=(t,e)=>l=>{try{256&t.t?t.i[e](l):(t.u=t.u||[]).push([e,l])}catch(t){nt(t)}},d=(t,e)=>4&e?i:8&e?c:t,$=t=>0!=(2&t),m={},b=t=>"object"==(t=typeof t)||"function"===t,h=(t,e,...l)=>{let n=null,o=null,s=!1,c=!1;const i=[],r=e=>{for(let l=0;l<e.length;l++)n=e[l],Array.isArray(n)?r(n):null!=n&&"boolean"!=typeof n&&((s="function"!=typeof t&&!b(n))&&(n+=""),s&&c?i[i.length-1].$+=n:i.push(s?p(null,n):n),c=s)};if(r(l),e){e.name&&(o=e.name);{const t=e.className||e.class;t&&(e.class="object"!=typeof t?t:Object.keys(t).filter((e=>t[e])).join(" "))}}const a=p(t,null);return a.m=e,i.length>0&&(a.h=i),a.p=o,a},p=(t,e)=>({t:0,g:t,$:e,j:null,h:null,m:null,p:null}),y={},w=(t,e,l,n,o,s)=>{if(l!==n){let i=lt(t,e),a=e.toLowerCase();if("class"===e){const e=t.classList,o=j(l),s=j(n);e.remove(...o.filter((t=>t&&!s.includes(t)))),e.add(...s.filter((t=>t&&!o.includes(t))))}else if("style"===e){for(const e in l)n&&null!=n[e]||(e.includes("-")?t.style.removeProperty(e):t.style[e]="");for(const e in n)l&&n[e]===l[e]||(e.includes("-")?t.style.setProperty(e,n[e]):t.style[e]=n[e])}else if("ref"===e)n&&n(t);else if(i||"o"!==e[0]||"n"!==e[1]){const c=b(n);if((i||c&&null!==n)&&!o)try{if(t.tagName.includes("-"))t[e]=n;else{const o=null==n?"":n;"list"===e?i=!1:null!=l&&t[e]==o||(t[e]=o)}}catch(t){}null==n||!1===n?!1===n&&""!==t.getAttribute(e)||t.removeAttribute(e):(!i||4&s||o)&&!c&&t.setAttribute(e,n=!0===n?"":n)}else e="-"===e[2]?e.slice(3):lt(c,a)?a.slice(2):a[2]+e.slice(3),l&&r.rel(t,e,l,!1),n&&r.ael(t,e,n,!1)}},g=/\s/,j=t=>t?t.split(g):[],v=(t,e,l,n)=>{const o=11===e.j.nodeType&&e.j.host?e.j.host:e.j,s=t&&t.m||m,c=e.m||m;for(n in s)n in c||w(o,n,s[n],void 0,l,e.t);for(n in c)w(o,n,s[n],c[n],l,e.t)},k=(n,s,c)=>{const r=s.h[c];let a,u,f,d=0;if(l||(o=!0,"slot"===r.g&&(r.t|=r.h?2:1)),null!==r.$)a=r.j=i.createTextNode(r.$);else if(1&r.t)a=r.j=i.createTextNode("");else if(a=r.j=i.createElement(2&r.t?"slot-fb":r.g),v(null,r,!1),r.h)for(d=0;d<r.h.length;++d)u=k(n,r,d),u&&a.appendChild(u);return a["s-hn"]=e,3&r.t&&(a["s-sr"]=!0,a["s-cr"]=t,a["s-sn"]=r.p||"",f=n&&n.h&&n.h[c],f&&f.g===r.g&&n.j&&O(n.j,!1)),a},O=(t,l)=>{r.t|=1;const n=t.childNodes;for(let t=n.length-1;t>=0;t--){const s=n[t];s["s-hn"]!==e&&s["s-ol"]&&(C(s).insertBefore(s,T(s)),s["s-ol"].remove(),s["s-ol"]=void 0,o=!0),l&&O(s,l)}r.t&=-2},M=(t,e,l,n,o,s)=>{let c,i=t["s-cr"]&&t["s-cr"].parentNode||t;for(;o<=s;++o)n[o]&&(c=k(null,l,o),c&&(n[o].j=c,i.insertBefore(c,T(e))))},P=(t,e,l,o,s)=>{for(;e<=l;++e)(o=t[e])&&(s=o.j,W(o),n=!0,s["s-ol"]?s["s-ol"].remove():O(s,!0),s.remove())},R=(t,e)=>t.g===e.g&&("slot"!==t.g||t.p===e.p),T=t=>t&&t["s-ol"]||t,C=t=>(t["s-ol"]?t["s-ol"]:t).parentNode,L=(t,e)=>{const l=e.j=t.j,n=t.h,o=e.h,s=e.$;let c;null===s?("slot"===e.g||v(t,e,!1),null!==n&&null!==o?((t,e,l,n)=>{let o,s=0,c=0,i=e.length-1,r=e[0],a=e[i],u=n.length-1,f=n[0],d=n[u];for(;s<=i&&c<=u;)null==r?r=e[++s]:null==a?a=e[--i]:null==f?f=n[++c]:null==d?d=n[--u]:R(r,f)?(L(r,f),r=e[++s],f=n[++c]):R(a,d)?(L(a,d),a=e[--i],d=n[--u]):R(r,d)?("slot"!==r.g&&"slot"!==d.g||O(r.j.parentNode,!1),L(r,d),t.insertBefore(r.j,a.j.nextSibling),r=e[++s],d=n[--u]):R(a,f)?("slot"!==r.g&&"slot"!==d.g||O(a.j.parentNode,!1),L(a,f),t.insertBefore(a.j,r.j),a=e[--i],f=n[++c]):(o=k(e&&e[c],l,c),f=n[++c],o&&C(r.j).insertBefore(o,T(r.j)));s>i?M(t,null==n[u+1]?null:n[u+1].j,l,n,c,u):c>u&&P(e,s,i)})(l,n,e,o):null!==o?(null!==t.$&&(l.textContent=""),M(l,null,e,o,0,o.length-1)):null!==n&&P(n,0,n.length-1)):(c=l["s-cr"])?c.parentNode.textContent=s:t.$!==s&&(l.data=s)},N=t=>{const e=t.childNodes;let l,n,o,s,c,i;for(n=0,o=e.length;n<o;n++)if(l=e[n],1===l.nodeType){if(l["s-sr"])for(c=l["s-sn"],l.hidden=!1,s=0;s<o;s++)if(i=e[s].nodeType,e[s]["s-hn"]!==l["s-hn"]||""!==c){if(1===i&&c===e[s].getAttribute("slot")){l.hidden=!0;break}}else if(1===i||3===i&&""!==e[s].textContent.trim()){l.hidden=!0;break}N(l)}},U=[],x=t=>{let e,l,o,s,c,i,r=0;const a=t.childNodes,u=a.length;for(;r<u;r++){if(e=a[r],e["s-sr"]&&(l=e["s-cr"])&&l.parentNode)for(o=l.parentNode.childNodes,s=e["s-sn"],i=o.length-1;i>=0;i--)l=o[i],l["s-cn"]||l["s-nr"]||l["s-hn"]===e["s-hn"]||(E(l,s)?(c=U.find((t=>t.v===l)),n=!0,l["s-sn"]=l["s-sn"]||s,c?c.k=e:U.push({k:e,v:l}),l["s-sr"]&&U.map((t=>{E(t.v,l["s-sn"])&&(c=U.find((t=>t.v===l)),c&&!t.k&&(t.k=c.k))}))):U.some((t=>t.v===l))||U.push({v:l}));1===e.nodeType&&x(e)}},E=(t,e)=>1===t.nodeType?null===t.getAttribute("slot")&&""===e||t.getAttribute("slot")===e:t["s-sn"]===e||""===e,W=t=>{t.m&&t.m.ref&&t.m.ref(null),t.h&&t.h.map(W)},A=t=>Z(t).O,D=(t,e,l)=>{const n=A(t);return{emit:t=>F(n,e,{bubbles:!!(4&l),composed:!!(2&l),cancelable:!!(1&l),detail:t})}},F=(t,e,l)=>{const n=r.ce(e,l);return t.dispatchEvent(n),n},q=(t,e)=>{e&&!t.M&&e["s-p"]&&e["s-p"].push(new Promise((e=>t.M=e)))},z=(t,e)=>{if(t.t|=16,!(4&t.t))return q(t,t.P),dt((()=>H(t,e)));t.t|=512},H=(t,e)=>{const l=t.i;let n;return e?(t.t|=256,t.u&&(t.u.map((([t,e])=>I(l,t,e))),t.u=null),n=I(l,"componentWillLoad")):n=I(l,"componentWillUpdate"),J(n,(()=>V(t,l)))},V=async(t,e)=>{const l=t.O,n=l["s-rc"];_(t,e),n&&(n.map((t=>t())),l["s-rc"]=void 0);{const e=l["s-p"],n=()=>B(t);0===e.length?n():(Promise.all(e).then(n),t.t|=4,e.length=0)}},_=(s,c)=>{try{c=c.render(),s.t&=-17,s.t|=2,((s,c)=>{const a=s.O,u=s.R,f=s.T||p(null,null),d=(t=>t&&t.g===y)(c)?c:h(null,null,c);if(e=a.tagName,u.C&&(d.m=d.m||{},u.C.map((([t,e])=>d.m[e]=a[t]))),d.g=null,d.t|=4,s.T=d,d.j=f.j=a,t=a["s-cr"],l=0!=(1&u.t),n=!1,L(f,d),r.t|=1,o){let t,e,l,n,o,s;x(d.j);let c=0;for(;c<U.length;c++)t=U[c],e=t.v,e["s-ol"]||(l=i.createTextNode(""),l["s-nr"]=e,e.parentNode.insertBefore(e["s-ol"]=l,e));for(c=0;c<U.length;c++)if(t=U[c],e=t.v,t.k){for(n=t.k.parentNode,o=t.k.nextSibling,l=e["s-ol"];l=l.previousSibling;)if(s=l["s-nr"],s&&s["s-sn"]===e["s-sn"]&&n===s.parentNode&&(s=s.nextSibling,!s||!s["s-nr"])){o=s;break}(!o&&n!==e.parentNode||e.nextSibling!==o)&&e!==o&&(!e["s-hn"]&&e["s-ol"]&&(e["s-hn"]=e["s-ol"].parentNode.nodeName),n.insertBefore(e,o))}else 1===e.nodeType&&(e.hidden=!0)}n&&N(d.j),r.t&=-2,U.length=0})(s,c)}catch(t){nt(t,s.O)}return null},B=t=>{const e=t.O,l=t.i,n=t.P;64&t.t?I(l,"componentDidUpdate"):(t.t|=64,K(e),I(l,"componentDidLoad"),t.L(e),n||G()),t.N(e),t.M&&(t.M(),t.M=void 0),512&t.t&&ft((()=>z(t,!1))),t.t&=-517},G=()=>{K(i.documentElement),ft((()=>F(c,"appload",{detail:{namespace:"blaze-atoms"}})))},I=(t,e,l)=>{if(t&&t[e])try{return t[e](l)}catch(t){nt(t)}},J=(t,e)=>t&&t.then?t.then(e):e(),K=t=>t.classList.add("hydrated"),Q=(t,e,l)=>{if(e.U){t.watchers&&(e.W=t.watchers);const n=Object.entries(e.U),o=t.prototype;if(n.map((([t,[n]])=>{31&n||2&l&&32&n?Object.defineProperty(o,t,{get(){return((t,e)=>Z(this).A.get(e))(0,t)},set(l){((t,e,l,n)=>{const o=Z(t),s=o.O,c=o.A.get(e),i=o.t,r=o.i;if(l=((t,e)=>null==t||b(t)?t:4&e?"false"!==t&&(""===t||!!t):2&e?parseFloat(t):1&e?t+"":t)(l,n.U[e][0]),(!(8&i)||void 0===c)&&l!==c&&(!Number.isNaN(c)||!Number.isNaN(l))&&(o.A.set(e,l),r)){if(n.W&&128&i){const t=n.W[e];t&&t.map((t=>{try{r[t](l,c,e)}catch(t){nt(t,s)}}))}2==(18&i)&&z(o,!1)}})(this,t,l,e)},configurable:!0,enumerable:!0}):1&l&&64&n&&Object.defineProperty(o,t,{value(...e){const l=Z(this);return l.D.then((()=>l.i[t](...e)))}})})),1&l){const l=new Map;o.attributeChangedCallback=function(t,e,n){r.jmp((()=>{const e=l.get(t);if(this.hasOwnProperty(e))n=this[e],delete this[e];else if(o.hasOwnProperty(e)&&"number"==typeof this[e]&&this[e]==n)return;this[e]=(null!==n||"boolean"!=typeof this[e])&&n}))},t.observedAttributes=n.filter((([t,e])=>15&e[0])).map((([t,n])=>{const o=n[1]||t;return l.set(o,t),512&n[0]&&e.C.push([t,o]),o}))}}return t},S=t=>{const e=t["s-cr"]=i.createComment("");e["s-cn"]=!0,t.insertBefore(e,t.firstChild)},X=(t,e={})=>{const l=[],n=e.exclude||[],o=c.customElements,s=i.head,a=s.querySelector("meta[charset]"),f=i.createElement("style"),d=[];let $,m=!0;Object.assign(r,e),r.l=new URL(e.resourcesUrl||"./",i.baseURI).href,t.map((t=>{t[1].map((e=>{const s={t:e[0],F:e[1],U:e[2],q:e[3]};s.U=e[2],s.q=e[3],s.C=[],s.W={};const c=s.F,i=class extends HTMLElement{constructor(t){super(t),et(t=this,s)}connectedCallback(){$&&(clearTimeout($),$=null),m?d.push(this):r.jmp((()=>(t=>{if(0==(1&r.t)){const e=Z(t),l=e.R,n=()=>{};if(1&e.t)u(t,e,l.q);else{e.t|=1,12&l.t&&S(t);{let l=t;for(;l=l.parentNode||l.host;)if(l["s-p"]){q(e,e.P=l);break}}l.U&&Object.entries(l.U).map((([e,[l]])=>{if(31&l&&t.hasOwnProperty(e)){const l=t[e];delete t[e],t[e]=l}})),(async(t,e,l,n,o)=>{if(0==(32&e.t)){if(e.t|=32,(o=st(l)).then){const t=()=>{};o=await o,t()}o.isProxied||(l.W=o.watchers,Q(o,l,2),o.isProxied=!0);const t=()=>{};e.t|=8;try{new o(e)}catch(t){nt(t)}e.t&=-9,e.t|=128,t()}const s=e.P,c=()=>z(e,!0);s&&s["s-rc"]?s["s-rc"].push(c):c()})(0,e,l)}n()}})(this)))}disconnectedCallback(){r.jmp((()=>(()=>{if(0==(1&r.t)){const t=Z(this),e=t.i;t.o&&(t.o.map((t=>t())),t.o=void 0),I(e,"disconnectedCallback")}})()))}componentOnReady(){return Z(this).H}};s.V=t[0],n.includes(c)||o.get(c)||(l.push(c),o.define(c,Q(i,s,1)))}))})),f.innerHTML=l+"{visibility:hidden}.hydrated{visibility:inherit}",f.setAttribute("data-styles",""),s.insertBefore(f,a?a.nextSibling:s.firstChild),m=!1,d.length?d.map((t=>t.connectedCallback())):r.jmp((()=>$=setTimeout(G,30)))},Y=new WeakMap,Z=t=>Y.get(t),tt=(t,e)=>Y.set(e.i=t,e),et=(t,e)=>{const l={t:0,O:t,R:e,A:new Map};return l.D=new Promise((t=>l.N=t)),l.H=new Promise((t=>l.L=t)),t["s-p"]=[],t["s-rc"]=[],u(t,l,e.q),Y.set(t,l)},lt=(t,e)=>e in t,nt=(t,e)=>(0,console.error)(t,e),ot=new Map,st=t=>{const e=t.F.replace(/-/g,"_"),l=t.V,n=ot.get(l);return n?n[e]:import(`./${l}.entry.js`).then((t=>(ot.set(l,t),t[e])),nt) /*!__STENCIL_STATIC_IMPORT_SWITCH__*/},ct=[],it=[],rt=(t,e)=>l=>{t.push(l),s||(s=!0,e&&4&r.t?ft(ut):r.raf(ut))},at=t=>{for(let e=0;e<t.length;e++)try{t[e](performance.now())}catch(t){nt(t)}t.length=0},ut=()=>{at(ct),at(it),(s=ct.length>0)&&r.raf(ut)},ft=t=>a().then(t),dt=rt(it,!0);export{X as b,D as c,A as g,h,a as p,tt as r}