@teamhive/lottie-player
Version:
Lottie animation web component.
1 lines • 9.4 kB
JavaScript
let t,e,n=0,s=!1,l=!1;const o=window,r=document,c={t:0,s:"",jmp:t=>t(),raf:t=>requestAnimationFrame(t),ael:(t,e,n,s)=>t.addEventListener(e,n,s),rel:(t,e,n,s)=>t.removeEventListener(e,n,s)},i=(()=>!!r.documentElement.attachShadow)(),a=(()=>{try{return new CSSStyleSheet,!0}catch(t){}return!1})(),f=new WeakMap,u=t=>f.get(t),p=(t,e)=>f.set(e.l=t,e),m=(t,e)=>e in t,$=t=>console.error(t),d=new Map,y=new Map,w=[],h=[],b=[],g=(t,e)=>n=>{t.push(n),s||(s=!0,e&&4&c.t?v(j):c.raf(j))},_=(t,e)=>{let n=0,s=0;for(;n<t.length&&(s=performance.now())<e;)try{t[n++](s)}catch(l){$(l)}n===t.length?t.length=0:0!==n&&t.splice(0,n)},j=()=>{n++,(t=>{for(let n=0;n<t.length;n++)try{t[n](performance.now())}catch(e){$(e)}t.length=0})(w);const t=2==(6&c.t)?performance.now()+10*Math.ceil(n*(1/22)):1/0;_(h,t),_(b,t),h.length>0&&(b.push(...h),h.length=0),(s=w.length+h.length+b.length>0)?c.raf(j):n=0},v=t=>Promise.resolve().then(t),O=g(h,!0),S={},M=t=>null!=t,R=t=>"object"==(t=typeof t)||"function"===t,U=()=>o.CSS&&o.CSS.supports&&o.CSS.supports("color","var(--c)")?Promise.resolve():__sc_import_lottie_player("./p-1635c1a0.js").then(()=>{c.o=o.__stencil_cssshim}),L=async()=>{c.o=o.__stencil_cssshim;const t=new RegExp("/lottie-player(\\.esm)?\\.js($|\\?|#)"),e=Array.from(r.querySelectorAll("script")).find(e=>t.test(e.src)||"lottie-player"===e.getAttribute("data-stencil-namespace")),n=e["data-opts"];{const t=new URL(".",new URL(e.getAttribute("data-resources-url")||e.src,o.location.href));return k(t.href),window.customElements||await __sc_import_lottie_player("./p-d0882b30.js"),Object.assign(Object.assign({},n),{resourcesUrl:t.href})}},k=t=>{const e=(()=>`__sc_import_${"lottie-player".replace(/\s|-/g,"_")}`)();try{o[e]=new Function("w",`return import(w);//${Math.random()}`)}catch(n){const s=new Map;o[e]=n=>{const l=new URL(n,t).href;let c=s.get(l);if(!c){const t=r.createElement("script");t.type="module",t.src=URL.createObjectURL(new Blob([`import * as m from '${l}'; window.${e}.m = m;`],{type:"application/javascript"})),c=new Promise(n=>{t.onload=()=>{n(o[e].m),t.remove()}}),s.set(l,c),r.head.appendChild(t)}return c}}},C=new WeakMap,x=t=>"sc-"+t,E=(t,e,...n)=>{let s=null,l=!1,o=!1,r=[];const c=e=>{for(let n=0;n<e.length;n++)s=e[n],Array.isArray(s)?c(s):null!=s&&"boolean"!=typeof s&&((l="function"!=typeof t&&!R(s))&&(s=String(s)),l&&o?r[r.length-1].i+=s:r.push(l?{t:0,i:s}:s),o=l)};if(c(n),e){const t=e.className||e.class;t&&(e.class="object"!=typeof t?t:Object.keys(t).filter(e=>t[e]).join(" "))}return{t:0,u:t,p:r.length>0?r:null,$:void 0,h:e}},P={},T=(t,e,n,s,l,o)=>{if(n===s)return;let r=m(t,e),i=e.toLowerCase();if("class"===e){const e=t.classList;A(n).forEach(t=>e.remove(t)),A(s).forEach(t=>e.add(t))}else if("style"===e){for(const e in n)s&&null!=s[e]||(e.includes("-")?t.style.removeProperty(e):t.style[e]="");for(const e in s)n&&s[e]===n[e]||(e.includes("-")?t.style.setProperty(e,s[e]):t.style[e]=s[e])}else if("ref"===e)s&&s(t);else if(r||"o"!==e[0]||"n"!==e[1]){const c=R(s);if((r||c&&null!==s)&&!l)try{if(t.tagName.includes("-"))t[e]=s;else{let l=null==s?"":s;null!=n&&t[e]==l||(t[e]=l)}}catch(a){}null==s||!1===s?t.removeAttribute(e):(!r||4&o||l)&&!c&&t.setAttribute(e,s=!0===s?"":s)}else e="-"===e[2]?e.substr(3):m(t,i)?i.substr(2):i[2]+e.substr(3),n&&c.rel(t,e,n,!1),s&&c.ael(t,e,s,!1)},A=t=>t?t.split(/\s+/).filter(t=>t):[],F=(t,e,n,s)=>{const l=11===e.$.nodeType&&e.$.host?e.$.host:e.$,o=t&&t.h||S,r=e.h||S;for(s in o)s in r||T(l,s,o[s],void 0,n,e.t);for(s in r)T(l,s,o[s],r[s],n,e.t)},W=(e,n,s)=>{let o,c,i=n.p[s],a=0;if(M(i.i))i.$=r.createTextNode(i.i);else{if(o=i.$=l||"svg"===i.u?r.createElementNS("http://www.w3.org/2000/svg",i.u):r.createElement(i.u),F(null,i,l="svg"===i.u||"foreignObject"!==i.u&&l),M(t)&&o["s-si"]!==t&&o.classList.add(o["s-si"]=t),i.p)for(a=0;a<i.p.length;++a)(c=W(e,i,a))&&o.appendChild(c);"svg"===i.u?l=!1:"foreignObject"===i.$.tagName&&(l=!0)}return i.$},q=(t,n,s,l,o,r)=>{let c,i=t;for(i.shadowRoot&&i.tagName===e&&(i=i.shadowRoot);o<=r;++o)l[o]&&(c=W(null,s,o))&&(l[o].$=c,i.insertBefore(c,n))},B=(t,e,n,s)=>{for(;e<=n;++e)M(t[e])&&(s=t[e].$,N(t[e],!0),s.remove())},D=(t,e)=>t.u===e.u,H=(t,e)=>{const n=e.$=t.$,s=t.p,o=e.p;l=n&&M(n.parentNode)&&void 0!==n.ownerSVGElement,l="svg"===e.u||"foreignObject"!==e.u&&l,M(e.i)?t.i!==e.i&&(n.textContent=e.i):(F(t,e,l),M(s)&&M(o)?((t,e,n,s)=>{let l,o=0,r=0,c=e.length-1,i=e[0],a=e[c],f=s.length-1,u=s[0],p=s[f];for(;o<=c&&r<=f;)null==i?i=e[++o]:null==a?a=e[--c]:null==u?u=s[++r]:null==p?p=s[--f]:D(i,u)?(H(i,u),i=e[++o],u=s[++r]):D(a,p)?(H(a,p),a=e[--c],p=s[--f]):D(i,p)?(H(i,p),t.insertBefore(i.$,a.$.nextSibling),i=e[++o],p=s[--f]):D(a,u)?(H(a,u),t.insertBefore(a.$,i.$),a=e[--c],u=s[++r]):(l=W(e&&e[r],n,r),u=s[++r],l&&i.$.parentNode.insertBefore(l,i.$));o>c?q(t,null==s[f+1]?null:s[f+1].$,n,s,r,f):r>f&&B(e,o,c)})(n,s,e,o):M(o)?(M(t.i)&&(n.textContent=""),q(n,null,e,o,0,o.length-1)):M(s)&&B(s,0,s.length-1)),l&&"svg"===e.u&&(l=!1)},N=(t,e)=>{t&&(t.h&&t.h.ref&&t.h.ref(e?null:t.$),t.p&&t.p.forEach(t=>{N(t,e)}))},V=(t,e,n,s)=>{e.t|=16;const l=e.l,o=()=>z(t,e,n,l,s);return K(void 0,()=>O(o))},z=(n,s,l,o,c)=>{s.t&=-17,n["s-lr"]=!1,c&&((t,e)=>{const n=((t,e)=>{let n=x(e.g),s=y.get(n);if(t=11===t.nodeType?t:r,s)if("string"==typeof s){let e,l=C.get(t=t.head||t);l||C.set(t,l=new Set),l.has(n)||((e=r.createElement("style")).setAttribute("data-styles",""),e.innerHTML=s,t.insertBefore(e,t.querySelector("link")),l&&l.add(n))}else t.adoptedStyleSheets.includes(s)||(t.adoptedStyleSheets=[...t.adoptedStyleSheets,s]);return n})(i&&t.shadowRoot?t.shadowRoot:t.getRootNode(),e);10&e.t&&(t["s-sc"]=n,t.classList.add(n+"-h"))})(n,l),s.t|=4;try{((n,s,l,o)=>{e=n.tagName;const r=s._||{t:0},c=(t=>t&&t.u===P)(o)?o:E(null,null,o);l.j&&(c.h=c.h||{},l.j.forEach(([t,e])=>c.h[e]=n[t])),c.u=null,c.t|=4,s._=c,c.$=r.$=n.shadowRoot||n,t=n["s-sc"],H(r,c)})(n,s,l,o.render())}catch(a){$(a)}s.t&=-5,n["s-lr"]=!0,s.t|=2,n["s-rc"].length>0&&(n["s-rc"].forEach(t=>t()),n["s-rc"].length=0),G(n,s)},G=(t,e,n)=>{if(!t["s-al"]){const s=e.l,l=e.v;64&e.t||(e.t|=64,t.classList.add("hydrated"),J(s,"componentDidLoad"),e.O(t),l||I()),l&&((n=l["s-al"])&&(n.delete(t),0===n.size&&(l["s-al"]=void 0,l["s-init"]())),e.v=void 0)}},I=()=>{r.documentElement.classList.add("hydrated"),c.t|=2},J=(t,e,n)=>{if(t&&t[e])try{return t[e](n)}catch(s){$(s)}},K=(t,e)=>t&&t.then?t.then(e):e(),Q=(t,e,n)=>{if(e.S){const s=Object.entries(e.S),l=t.prototype;if(s.forEach(([t,[s]])=>{31&s||2&n&&32&s?Object.defineProperty(l,t,{get(){return((t,e)=>u(t).M.get(e))(this,t)},set(n){((t,e,n,s)=>{const l=u(this),o=l.R,r=l.M.get(e),c=l.t,i=l.l;(n=((t,e)=>null==t||R(t)?t:4&e?"false"!==t&&(""===t||!!t):2&e?parseFloat(t):1&e?String(t):t)(n,s.S[e][0]))===r||8&c&&void 0!==r||(l.M.set(e,n),i&&2==(22&c)&&V(o,l,s,!1))})(0,t,n,e)},configurable:!0,enumerable:!0}):1&n&&64&s&&Object.defineProperty(l,t,{value(...e){const n=u(this);return n.U.then(()=>n.l[t](...e))}})}),1&n){const n=new Map;l.attributeChangedCallback=function(t,e,s){c.jmp(()=>{const e=n.get(t);this[e]=(null!==s||"boolean"!=typeof this[e])&&s})},t.observedAttributes=s.filter(([t,e])=>15&e[0]).map(([t,s])=>{const l=s[1]||t;return n.set(l,t),512&s[0]&&e.j.push([t,l]),l})}}return t},X=(t,e={})=>{const n=[],s=e.exclude||[],l=r.head,p=o.customElements,m=l.querySelector("meta[charset]"),w=r.createElement("style");let h;Object.assign(c,e),c.s=new URL(e.resourcesUrl||"./",r.baseURI).href,e.syncQueue&&(c.t|=4),t.forEach(t=>t[1].forEach(e=>{const l={t:e[0],g:e[1],S:e[2],L:e[3],j:[]};!i&&1&l.t&&(l.t|=8);const o=l.g,r=class extends HTMLElement{constructor(t){super(t),t=this,this["s-lr"]=!1,this["s-rc"]=[],(t=>{{const e={t:0,R:t,M:new Map};e.U=new Promise(t=>e.O=t),f.set(t,e)}})(t),1&l.t&&(i?t.attachShadow({mode:"open"}):"shadowRoot"in t||(t.shadowRoot=t))}connectedCallback(){h&&(clearTimeout(h),h=null),c.jmp(()=>((t,e)=>{if(0==(1&c.t)){const n=u(t);if(!(1&n.t)){n.t|=1;{let e=t;for(;e=e.parentNode||e.host;)if(e["s-init"]&&!1===e["s-lr"]){n.v=e,(e["s-al"]=e["s-al"]||new Set).add(t);break}}e.S&&Object.entries(e.S).forEach(([e,[n]])=>{if(31&n&&t.hasOwnProperty(e)){const n=t[e];delete t[e],t[e]=n}}),v(()=>(async(t,e,n,s,l)=>{if(0==(32&e.t)){e.t|=32,(l=(t=>{const e=t.g.replace(/-/g,"_"),n=t.k,s=d.get(n);return s?s[e]:__sc_import_lottie_player(`./${n}.entry.js`).then(t=>(d.set(n,t),t[e]),$)})(n)).then&&(l=await l),l.isProxied||(Q(l,n,2),l.isProxied=!0),e.t|=8;try{new l(e)}catch(c){$(c)}e.t&=-9;const t=x(n.g);if(!y.has(t)&&l.style){let e=l.style;8&n.t&&(e=await __sc_import_lottie_player("./p-affe7c09.js").then(n=>n.scopeCss(e,t,!1))),((t,e,n)=>{let s=y.get(t);a&&n?(s=s||new CSSStyleSheet).replace(e):s=e,y.set(t,s)})(t,e,!!(1&n.t))}}const o=e.v,r=()=>V(t,e,n,!0);o&&!1===o["s-lr"]&&o["s-rc"]?o["s-rc"].push(r):r()})(t,n,e))}}})(this,l))}disconnectedCallback(){c.jmp(()=>void 0)}"s-init"(){const t=u(this);t.l&&G(this,t)}"s-hmr"(t){}forceUpdate(){((t,e)=>{{const n=u(t);2&n.t&&V(t,n,e,!1)}})(this,l)}componentOnReady(){return u(this).U}};l.k=t[0],s.includes(o)||p.get(o)||(n.push(o),p.define(o,Q(r,l,1)))})),w.innerHTML=n+"{visibility:hidden}.hydrated{visibility:inherit}",w.setAttribute("data-styles",""),l.insertBefore(w,m?m.nextSibling:l.firstChild),c.jmp(()=>h=setTimeout(I,30))},Y=(t,e,n)=>{const s=Z(t);return{emit:t=>s.dispatchEvent(new CustomEvent(e,{bubbles:!!(4&n),composed:!!(2&n),cancelable:!!(1&n),detail:t}))}},Z=t=>u(t).R;export{U as a,X as b,Y as c,E as h,L as p,p as r};