@cascadiajs/discord-mirror
Version:
A web component for displaying current activity within a Discord Channel
1 lines • 8.38 kB
JavaScript
let e,t,n=!1;const l="undefined"!=typeof window?window:{},s=l.document||{head:{}},o={t:0,l:"",jmp:e=>e(),raf:e=>requestAnimationFrame(e),ael:(e,t,n,l)=>e.addEventListener(t,n,l),rel:(e,t,n,l)=>e.removeEventListener(t,n,l),ce:(e,t)=>new CustomEvent(e,t)},i=e=>Promise.resolve(e),r=(()=>{try{return new CSSStyleSheet,"function"==typeof(new CSSStyleSheet).replace}catch(e){}return!1})(),c=new WeakMap,u=e=>"sc-"+e.o,f={},a=e=>"object"==(e=typeof e)||"function"===e,d=(e,t,...n)=>{let l=null,s=null,o=!1,i=!1,r=[];const c=t=>{for(let n=0;n<t.length;n++)l=t[n],Array.isArray(l)?c(l):null!=l&&"boolean"!=typeof l&&((o="function"!=typeof e&&!a(l))&&(l+=""),o&&i?r[r.length-1].i+=l:r.push(o?y(null,l):l),i=o)};if(c(n),t){t.key&&(s=t.key);{const e=t.className||t.class;e&&(t.class="object"!=typeof e?e:Object.keys(e).filter((t=>e[t])).join(" "))}}if("function"==typeof e)return e(null===t?{}:t,r,h);const u=y(e,null);return u.u=t,r.length>0&&(u.$=r),u.h=s,u},y=(e,t)=>({t:0,p:e,i:t,m:null,$:null,u:null,h:null}),$={},h={forEach:(e,t)=>e.map(p).forEach(t),map:(e,t)=>e.map(p).map(t).map(m)},p=e=>({vattrs:e.u,vchildren:e.$,vkey:e.h,vname:e.v,vtag:e.p,vtext:e.i}),m=e=>{if("function"==typeof e.vtag){const t=Object.assign({},e.vattrs);return e.vkey&&(t.key=e.vkey),e.vname&&(t.name=e.vname),d(e.vtag,t,...e.vchildren||[])}const t=y(e.vtag,e.vtext);return t.u=e.vattrs,t.$=e.vchildren,t.h=e.vkey,t.v=e.vname,t},b=(e,t,n,l,s,o)=>{if(n!==l){let i=z(e,t);if(t.toLowerCase(),"class"===t){const t=e.classList,s=v(n),o=v(l);t.remove(...s.filter((e=>e&&!o.includes(e)))),t.add(...o.filter((e=>e&&!s.includes(e))))}else if("style"===t){for(const t in n)l&&null!=l[t]||(t.includes("-")?e.style.removeProperty(t):e.style[t]="");for(const t in l)n&&l[t]===n[t]||(t.includes("-")?e.style.setProperty(t,l[t]):e.style[t]=l[t])}else if("key"===t);else if("ref"===t)l&&l(e);else{const r=a(l);if((i||r&&null!==l)&&!s)try{if(e.tagName.includes("-"))e[t]=l;else{let s=null==l?"":l;"list"===t?i=!1:null!=n&&e[t]==s||(e[t]=s)}}catch(e){}null==l||!1===l?!1===l&&""!==e.getAttribute(t)||e.removeAttribute(t):(!i||4&o||s)&&!r&&e.setAttribute(t,l=!0===l?"":l)}}},w=/\s/,v=e=>e?e.split(w):[],S=(e,t,n,l)=>{const s=11===t.m.nodeType&&t.m.host?t.m.host:t.m,o=e&&e.u||f,i=t.u||f;for(l in o)l in i||b(s,l,o[l],void 0,n,t.t);for(l in i)b(s,l,o[l],i[l],n,t.t)},g=(t,n,l)=>{let o,i,r=n.$[l],c=0;if(null!==r.i)o=r.m=s.createTextNode(r.i);else if(o=r.m=s.createElement(r.p),S(null,r,!1),null!=e&&o["s-si"]!==e&&o.classList.add(o["s-si"]=e),r.$)for(c=0;c<r.$.length;++c)i=g(t,r,c),i&&o.appendChild(i);return o},k=(e,n,l,s,o,i)=>{let r,c=e;for(c.shadowRoot&&c.tagName===t&&(c=c.shadowRoot);o<=i;++o)s[o]&&(r=g(null,l,o),r&&(s[o].m=r,c.insertBefore(r,n)))},j=(e,t,n,l,s)=>{for(;t<=n;++t)(l=e[t])&&(s=l.m,O(l),s.remove())},M=(e,t)=>e.p===t.p&&e.h===t.h,C=(e,t)=>{const n=t.m=e.m,l=e.$,s=t.$,o=t.i;null===o?(S(e,t,!1),null!==l&&null!==s?((e,t,n,l)=>{let s,o,i=0,r=0,c=0,u=0,f=t.length-1,a=t[0],d=t[f],y=l.length-1,$=l[0],h=l[y];for(;i<=f&&r<=y;)if(null==a)a=t[++i];else if(null==d)d=t[--f];else if(null==$)$=l[++r];else if(null==h)h=l[--y];else if(M(a,$))C(a,$),a=t[++i],$=l[++r];else if(M(d,h))C(d,h),d=t[--f],h=l[--y];else if(M(a,h))C(a,h),e.insertBefore(a.m,d.m.nextSibling),a=t[++i],h=l[--y];else if(M(d,$))C(d,$),e.insertBefore(d.m,a.m),d=t[--f],$=l[++r];else{for(c=-1,u=i;u<=f;++u)if(t[u]&&null!==t[u].h&&t[u].h===$.h){c=u;break}c>=0?(o=t[c],o.p!==$.p?s=g(t&&t[r],n,c):(C(o,$),t[c]=void 0,s=o.m),$=l[++r]):(s=g(t&&t[r],n,r),$=l[++r]),s&&a.m.parentNode.insertBefore(s,a.m)}i>f?k(e,null==l[y+1]?null:l[y+1].m,n,l,r,y):r>y&&j(t,i,f)})(n,l,t,s):null!==s?(null!==e.i&&(n.textContent=""),k(n,null,t,s,0,s.length-1)):null!==l&&j(l,0,l.length-1)):e.i!==o&&(n.data=o)},O=e=>{e.u&&e.u.ref&&e.u.ref(null),e.$&&e.$.map(O)},x=(e,t)=>{t&&!e.S&&t["s-p"]&&t["s-p"].push(new Promise((t=>e.S=t)))},E=(e,t)=>{if(e.t|=16,!(4&e.t))return x(e,e.g),te((()=>P(e,t)));e.t|=512},P=(e,t)=>{const n=e.k;return U(void 0,(()=>L(e,n,t)))},L=async(e,t,n)=>{const l=e.j,o=l["s-rc"];n&&(e=>{const t=e.M,n=e.j,l=t.t,o=((e,t)=>{let n=u(t),l=J.get(n);if(e=11===e.nodeType?e:s,l)if("string"==typeof l){let t,o=c.get(e=e.head||e);o||c.set(e,o=new Set),o.has(n)||(t=s.createElement("style"),t.innerHTML=l,e.insertBefore(t,e.querySelector("link")),o&&o.add(n))}else e.adoptedStyleSheets.includes(l)||(e.adoptedStyleSheets=[...e.adoptedStyleSheets,l]);return n})(n.shadowRoot?n.shadowRoot:n.getRootNode(),t);10&l&&(n["s-sc"]=o,n.classList.add(o+"-h"))})(e);T(e,t),o&&(o.map((e=>e())),l["s-rc"]=void 0);{const t=l["s-p"],n=()=>A(e);0===t.length?n():(Promise.all(t).then(n),e.t|=4,t.length=0)}},T=(n,l)=>{try{l=l.render(),n.t&=-17,n.t|=2,((n,l)=>{const s=n.j,o=n.C||y(null,null),i=(e=>e&&e.p===$)(l)?l:d(null,null,l);t=s.tagName,i.p=null,i.t|=4,n.C=i,i.m=o.m=s.shadowRoot||s,e=s["s-sc"],C(o,i)})(n,l)}catch(e){B(e,n.j)}return null},A=e=>{const t=e.j,n=e.k,l=e.g;64&e.t||(e.t|=64,W(t),R(n,"componentDidLoad"),e.O(t),l||H()),e.S&&(e.S(),e.S=void 0),512&e.t&&ee((()=>E(e,!1))),e.t&=-517},H=()=>{W(s.documentElement),ee((()=>(e=>{const t=o.ce("appload",{detail:{namespace:"discord-mirror"}});return e.dispatchEvent(t),t})(l)))},R=(e,t,n)=>{if(e&&e[t])try{return e[t](n)}catch(e){B(e)}},U=(e,t)=>e&&e.then?e.then(t):t(),W=e=>e.classList.add("hydrated"),q=(e,t,n)=>{if(t.P){e.watchers&&(t.L=e.watchers);const l=Object.entries(t.P),s=e.prototype;if(l.map((([e,[l]])=>{(31&l||2&n&&32&l)&&Object.defineProperty(s,e,{get(){return((e,t)=>N(this).T.get(t))(0,e)},set(n){((e,t,n,l)=>{const s=N(e),o=s.j,i=s.T.get(t),r=s.t,c=s.k;if(n=((e,t)=>null==e||a(e)?e:4&t?"false"!==e&&(""===e||!!e):1&t?e+"":e)(n,l.P[t][0]),!(8&r&&void 0!==i||n===i)&&(s.T.set(t,n),c)){if(l.L&&128&r){const e=l.L[t];e&&e.map((e=>{try{c[e](n,i,t)}catch(e){B(e,o)}}))}2==(18&r)&&E(s,!1)}})(this,e,n,t)},configurable:!0,enumerable:!0})})),1&n){const t=new Map;s.attributeChangedCallback=function(e,n,l){o.jmp((()=>{const n=t.get(e);this.hasOwnProperty(n)&&(l=this[n],delete this[n]),this[n]=(null!==l||"boolean"!=typeof this[n])&&l}))},e.observedAttributes=l.filter((([e,t])=>15&t[0])).map((([e,n])=>{const l=n[1]||e;return t.set(l,e),l}))}}return e},D=(e,t={})=>{const n=[],i=t.exclude||[],c=l.customElements,f=s.head,a=f.querySelector("meta[charset]"),d=s.createElement("style"),y=[];let $,h=!0;Object.assign(o,t),o.l=new URL(t.resourcesUrl||"./",s.baseURI).href,e.map((e=>e[1].map((t=>{const l={t:t[0],o:t[1],P:t[2],A:t[3]};l.P=t[2],l.L={};const s=l.o,f=class extends HTMLElement{constructor(e){super(e),_(e=this,l),1&l.t&&e.attachShadow({mode:"open"})}connectedCallback(){$&&(clearTimeout($),$=null),h?y.push(this):o.jmp((()=>(e=>{if(0==(1&o.t)){const t=N(e),n=t.M,l=()=>{};if(!(1&t.t)){t.t|=1;{let n=e;for(;n=n.parentNode||n.host;)if(n["s-p"]){x(t,t.g=n);break}}n.P&&Object.entries(n.P).map((([t,[n]])=>{if(31&n&&e.hasOwnProperty(t)){const n=e[t];delete e[t],e[t]=n}})),(async(e,t,n,l,s)=>{if(0==(32&t.t)){{if(t.t|=32,(s=I(n)).then){const e=()=>{};s=await s,e()}s.isProxied||(n.L=s.watchers,q(s,n,2),s.isProxied=!0);const e=()=>{};t.t|=8;try{new s(t)}catch(e){B(e)}t.t&=-9,t.t|=128,e()}if(s.style){let e=s.style;const t=u(n);if(!J.has(t)){const l=()=>{};((e,t,n)=>{let l=J.get(e);r&&n?(l=l||new CSSStyleSheet,l.replace(t)):l=t,J.set(e,l)})(t,e,!!(1&n.t)),l()}}}const o=t.g,i=()=>E(t,!0);o&&o["s-rc"]?o["s-rc"].push(i):i()})(0,t,n)}l()}})(this)))}disconnectedCallback(){o.jmp((()=>(()=>{0==(1&o.t)&&R(N(this).k,"disconnectedCallback")})()))}componentOnReady(){return N(this).H}};l.R=e[0],i.includes(s)||c.get(s)||(n.push(s),c.define(s,q(f,l,1)))})))),d.innerHTML=n+"{visibility:hidden}.hydrated{visibility:inherit}",d.setAttribute("data-styles",""),f.insertBefore(d,a?a.nextSibling:f.firstChild),h=!1,y.length?y.map((e=>e.connectedCallback())):o.jmp((()=>$=setTimeout(H,30)))},F=new WeakMap,N=e=>F.get(e),V=(e,t)=>F.set(t.k=e,t),_=(e,t)=>{const n={t:0,j:e,M:t,T:new Map};return n.H=new Promise((e=>n.O=e)),e["s-p"]=[],e["s-rc"]=[],F.set(e,n)},z=(e,t)=>t in e,B=(e,t)=>(0,console.error)(e,t),G=new Map,I=e=>{const t=e.o.replace(/-/g,"_"),n=e.R,l=G.get(n);return l?l[t]:import(`./${n}.entry.js`).then((e=>(G.set(n,e),e[t])),B)},J=new Map,K=[],Q=[],X=(e,t)=>l=>{e.push(l),n||(n=!0,t&&4&o.t?ee(Z):o.raf(Z))},Y=e=>{for(let t=0;t<e.length;t++)try{e[t](performance.now())}catch(e){B(e)}e.length=0},Z=()=>{Y(K),Y(Q),(n=K.length>0)&&o.raf(Z)},ee=e=>i().then(e),te=X(Q,!0);export{$ as H,D as b,d as h,i as p,V as r}