deskcord 1.3.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/deskcord.min.js +2 -2
- package/package.json +1 -1
package/dist/deskcord.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(){"use strict";var Pe,N,tn,le,nn,rn,dt,on,ut,pt,ft,sn,Ee={},an=[],si=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,ht=Array.isArray;function se(t,e){for(var n in e)t[n]=e[n];return t}function gt(t){t&&t.parentNode&&t.parentNode.removeChild(t)}function ai(t,e,n){var r,i,o,a={};for(o in e)o=="key"?r=e[o]:o=="ref"?i=e[o]:a[o]=e[o];if(arguments.length>2&&(a.children=arguments.length>3?Pe.call(arguments,2):n),typeof t=="function"&&t.defaultProps!=null)for(o in t.defaultProps)a[o]===void 0&&(a[o]=t.defaultProps[o]);return Be(t,a,r,i,null)}function Be(t,e,n,r,i){var o={type:t,props:e,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++tn,__i:-1,__u:0};return i==null&&N.vnode!=null&&N.vnode(o),o}function B(t){return t.children}function ze(t,e){this.props=t,this.context=e}function me(t,e){if(e==null)return t.__?me(t.__,t.__i+1):null;for(var n;e<t.__k.length;e++)if((n=t.__k[e])!=null&&n.__e!=null)return n.__e;return typeof t.type=="function"?me(t):null}function cn(t){var e,n;if((t=t.__)!=null&&t.__c!=null){for(t.__e=t.__c.base=null,e=0;e<t.__k.length;e++)if((n=t.__k[e])!=null&&n.__e!=null){t.__e=t.__c.base=n.__e;break}return cn(t)}}function mt(t){(!t.__d&&(t.__d=!0)&&le.push(t)&&!Fe.__r++||nn!==N.debounceRendering)&&((nn=N.debounceRendering)||rn)(Fe)}function Fe(){var t,e,n,r,i,o,a,c;for(le.sort(dt);t=le.shift();)t.__d&&(e=le.length,r=void 0,o=(i=(n=t).__v).__e,a=[],c=[],n.__P&&((r=se({},i)).__v=i.__v+1,N.vnode&&N.vnode(r),vt(n.__P,r,i,n.__n,n.__P.namespaceURI,32&i.__u?[o]:null,a,o??me(i),!!(32&i.__u),c),r.__v=i.__v,r.__.__k[r.__i]=r,fn(a,r,c),r.__e!=o&&cn(r)),le.length>e&&le.sort(dt));Fe.__r=0}function ln(t,e,n,r,i,o,a,c,d,p,m){var u,h,w,x,k,_,T=r&&r.__k||an,y=e.length;for(d=ci(n,e,T,d,y),u=0;u<y;u++)(w=n.__k[u])!=null&&(h=w.__i===-1?Ee:T[w.__i]||Ee,w.__i=u,_=vt(t,w,h,i,o,a,c,d,p,m),x=w.__e,w.ref&&h.ref!=w.ref&&(h.ref&&yt(h.ref,null,w),m.push(w.ref,w.__c||x,w)),k==null&&x!=null&&(k=x),4&w.__u||h.__k===w.__k?d=dn(w,d,t):typeof w.type=="function"&&_!==void 0?d=_:x&&(d=x.nextSibling),w.__u&=-7);return n.__e=k,d}function ci(t,e,n,r,i){var o,a,c,d,p,m=n.length,u=m,h=0;for(t.__k=new Array(i),o=0;o<i;o++)(a=e[o])!=null&&typeof a!="boolean"&&typeof a!="function"?(d=o+h,(a=t.__k[o]=typeof a=="string"||typeof a=="number"||typeof a=="bigint"||a.constructor==String?Be(null,a,null,null,null):ht(a)?Be(B,{children:a},null,null,null):a.constructor===void 0&&a.__b>0?Be(a.type,a.props,a.key,a.ref?a.ref:null,a.__v):a).__=t,a.__b=t.__b+1,c=null,(p=a.__i=li(a,n,d,u))!==-1&&(u--,(c=n[p])&&(c.__u|=2)),c==null||c.__v===null?(p==-1&&h--,typeof a.type!="function"&&(a.__u|=4)):p!=d&&(p==d-1?h--:p==d+1?h++:(p>d?h--:h++,a.__u|=4))):t.__k[o]=null;if(u)for(o=0;o<m;o++)(c=n[o])!=null&&!(2&c.__u)&&(c.__e==r&&(r=me(c)),hn(c,c));return r}function dn(t,e,n){var r,i;if(typeof t.type=="function"){for(r=t.__k,i=0;r&&i<r.length;i++)r[i]&&(r[i].__=t,e=dn(r[i],e,n));return e}t.__e!=e&&(e&&t.type&&!n.contains(e)&&(e=me(t)),n.insertBefore(t.__e,e||null),e=t.__e);do e=e&&e.nextSibling;while(e!=null&&e.nodeType==8);return e}function li(t,e,n,r){var i,o,a=t.key,c=t.type,d=e[n];if(d===null||d&&a==d.key&&c===d.type&&!(2&d.__u))return n;if(r>(d!=null&&!(2&d.__u)?1:0))for(i=n-1,o=n+1;i>=0||o<e.length;){if(i>=0){if((d=e[i])&&!(2&d.__u)&&a==d.key&&c===d.type)return i;i--}if(o<e.length){if((d=e[o])&&!(2&d.__u)&&a==d.key&&c===d.type)return o;o++}}return-1}function un(t,e,n){e[0]=="-"?t.setProperty(e,n??""):t[e]=n==null?"":typeof n!="number"||si.test(e)?n:n+"px"}function je(t,e,n,r,i){var o;e:if(e=="style")if(typeof n=="string")t.style.cssText=n;else{if(typeof r=="string"&&(t.style.cssText=r=""),r)for(e in r)n&&e in n||un(t.style,e,"");if(n)for(e in n)r&&n[e]===r[e]||un(t.style,e,n[e])}else if(e[0]=="o"&&e[1]=="n")o=e!=(e=e.replace(on,"$1")),e=e.toLowerCase()in t||e=="onFocusOut"||e=="onFocusIn"?e.toLowerCase().slice(2):e.slice(2),t.l||(t.l={}),t.l[e+o]=n,n?r?n.u=r.u:(n.u=ut,t.addEventListener(e,o?ft:pt,o)):t.removeEventListener(e,o?ft:pt,o);else{if(i=="http://www.w3.org/2000/svg")e=e.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(e!="width"&&e!="height"&&e!="href"&&e!="list"&&e!="form"&&e!="tabIndex"&&e!="download"&&e!="rowSpan"&&e!="colSpan"&&e!="role"&&e!="popover"&&e in t)try{t[e]=n??"";break e}catch{}typeof n=="function"||(n==null||n===!1&&e[4]!="-"?t.removeAttribute(e):t.setAttribute(e,e=="popover"&&n==1?"":n))}}function pn(t){return function(e){if(this.l){var n=this.l[e.type+t];if(e.t==null)e.t=ut++;else if(e.t<n.u)return;return n(N.event?N.event(e):e)}}}function vt(t,e,n,r,i,o,a,c,d,p){var m,u,h,w,x,k,_,T,y,I,P,Q,W,ae,ie,Y,K,H=e.type;if(e.constructor!==void 0)return null;128&n.__u&&(d=!!(32&n.__u),o=[c=e.__e=n.__e]),(m=N.__b)&&m(e);e:if(typeof H=="function")try{if(T=e.props,y="prototype"in H&&H.prototype.render,I=(m=H.contextType)&&r[m.__c],P=m?I?I.props.value:m.__:r,n.__c?_=(u=e.__c=n.__c).__=u.__E:(y?e.__c=u=new H(T,P):(e.__c=u=new ze(T,P),u.constructor=H,u.render=ui),I&&I.sub(u),u.props=T,u.state||(u.state={}),u.context=P,u.__n=r,h=u.__d=!0,u.__h=[],u._sb=[]),y&&u.__s==null&&(u.__s=u.state),y&&H.getDerivedStateFromProps!=null&&(u.__s==u.state&&(u.__s=se({},u.__s)),se(u.__s,H.getDerivedStateFromProps(T,u.__s))),w=u.props,x=u.state,u.__v=e,h)y&&H.getDerivedStateFromProps==null&&u.componentWillMount!=null&&u.componentWillMount(),y&&u.componentDidMount!=null&&u.__h.push(u.componentDidMount);else{if(y&&H.getDerivedStateFromProps==null&&T!==w&&u.componentWillReceiveProps!=null&&u.componentWillReceiveProps(T,P),!u.__e&&(u.shouldComponentUpdate!=null&&u.shouldComponentUpdate(T,u.__s,P)===!1||e.__v==n.__v)){for(e.__v!=n.__v&&(u.props=T,u.state=u.__s,u.__d=!1),e.__e=n.__e,e.__k=n.__k,e.__k.some(function(X){X&&(X.__=e)}),Q=0;Q<u._sb.length;Q++)u.__h.push(u._sb[Q]);u._sb=[],u.__h.length&&a.push(u);break e}u.componentWillUpdate!=null&&u.componentWillUpdate(T,u.__s,P),y&&u.componentDidUpdate!=null&&u.__h.push(function(){u.componentDidUpdate(w,x,k)})}if(u.context=P,u.props=T,u.__P=t,u.__e=!1,W=N.__r,ae=0,y){for(u.state=u.__s,u.__d=!1,W&&W(e),m=u.render(u.props,u.state,u.context),ie=0;ie<u._sb.length;ie++)u.__h.push(u._sb[ie]);u._sb=[]}else do u.__d=!1,W&&W(e),m=u.render(u.props,u.state,u.context),u.state=u.__s;while(u.__d&&++ae<25);u.state=u.__s,u.getChildContext!=null&&(r=se(se({},r),u.getChildContext())),y&&!h&&u.getSnapshotBeforeUpdate!=null&&(k=u.getSnapshotBeforeUpdate(w,x)),c=ln(t,ht(Y=m!=null&&m.type===B&&m.key==null?m.props.children:m)?Y:[Y],e,n,r,i,o,a,c,d,p),u.base=e.__e,e.__u&=-161,u.__h.length&&a.push(u),_&&(u.__E=u.__=null)}catch(X){if(e.__v=null,d||o!=null)if(X.then){for(e.__u|=d?160:128;c&&c.nodeType==8&&c.nextSibling;)c=c.nextSibling;o[o.indexOf(c)]=null,e.__e=c}else for(K=o.length;K--;)gt(o[K]);else e.__e=n.__e,e.__k=n.__k;N.__e(X,e,n)}else o==null&&e.__v==n.__v?(e.__k=n.__k,e.__e=n.__e):c=e.__e=di(n.__e,e,n,r,i,o,a,d,p);return(m=N.diffed)&&m(e),128&e.__u?void 0:c}function fn(t,e,n){for(var r=0;r<n.length;r++)yt(n[r],n[++r],n[++r]);N.__c&&N.__c(e,t),t.some(function(i){try{t=i.__h,i.__h=[],t.some(function(o){o.call(i)})}catch(o){N.__e(o,i.__v)}})}function di(t,e,n,r,i,o,a,c,d){var p,m,u,h,w,x,k,_=n.props,T=e.props,y=e.type;if(y=="svg"?i="http://www.w3.org/2000/svg":y=="math"?i="http://www.w3.org/1998/Math/MathML":i||(i="http://www.w3.org/1999/xhtml"),o!=null){for(p=0;p<o.length;p++)if((w=o[p])&&"setAttribute"in w==!!y&&(y?w.localName==y:w.nodeType==3)){t=w,o[p]=null;break}}if(t==null){if(y==null)return document.createTextNode(T);t=document.createElementNS(i,y,T.is&&T),c&&(N.__m&&N.__m(e,o),c=!1),o=null}if(y===null)_===T||c&&t.data===T||(t.data=T);else{if(o=o&&Pe.call(t.childNodes),_=n.props||Ee,!c&&o!=null)for(_={},p=0;p<t.attributes.length;p++)_[(w=t.attributes[p]).name]=w.value;for(p in _)if(w=_[p],p!="children"){if(p=="dangerouslySetInnerHTML")u=w;else if(!(p in T)){if(p=="value"&&"defaultValue"in T||p=="checked"&&"defaultChecked"in T)continue;je(t,p,null,w,i)}}for(p in T)w=T[p],p=="children"?h=w:p=="dangerouslySetInnerHTML"?m=w:p=="value"?x=w:p=="checked"?k=w:c&&typeof w!="function"||_[p]===w||je(t,p,w,_[p],i);if(m)c||u&&(m.__html===u.__html||m.__html===t.innerHTML)||(t.innerHTML=m.__html),e.__k=[];else if(u&&(t.innerHTML=""),ln(t,ht(h)?h:[h],e,n,r,y=="foreignObject"?"http://www.w3.org/1999/xhtml":i,o,a,o?o[0]:n.__k&&me(n,0),c,d),o!=null)for(p=o.length;p--;)gt(o[p]);c||(p="value",y=="progress"&&x==null?t.removeAttribute("value"):x!==void 0&&(x!==t[p]||y=="progress"&&!x||y=="option"&&x!==_[p])&&je(t,p,x,_[p],i),p="checked",k!==void 0&&k!==t[p]&&je(t,p,k,_[p],i))}return t}function yt(t,e,n){try{if(typeof t=="function"){var r=typeof t.__u=="function";r&&t.__u(),r&&e==null||(t.__u=t(e))}else t.current=e}catch(i){N.__e(i,n)}}function hn(t,e,n){var r,i;if(N.unmount&&N.unmount(t),(r=t.ref)&&(r.current&&r.current!==t.__e||yt(r,null,e)),(r=t.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(o){N.__e(o,e)}r.base=r.__P=null}if(r=t.__k)for(i=0;i<r.length;i++)r[i]&&hn(r[i],e,n||typeof t.type!="function");n||gt(t.__e),t.__c=t.__=t.__e=void 0}function ui(t,e,n){return this.constructor(t,n)}function pi(t,e,n){var r,i,o,a;e==document&&(e=document.documentElement),N.__&&N.__(t,e),i=(r=typeof n=="function")?null:e.__k,o=[],a=[],vt(e,t=(!r&&n||e).__k=ai(B,null,[t]),i||Ee,Ee,e.namespaceURI,!r&&n?[n]:i?null:e.firstChild?Pe.call(e.childNodes):null,o,!r&&n?n:i?i.__e:e.firstChild,r,a),fn(o,t,a)}function gn(t,e){var n={__c:e="__cC"+sn++,__:t,Consumer:function(r,i){return r.children(i)},Provider:function(r){var i,o;return this.getChildContext||(i=new Set,(o={})[e]=this,this.getChildContext=function(){return o},this.componentWillUnmount=function(){i=null},this.shouldComponentUpdate=function(a){this.props.value!==a.value&&i.forEach(function(c){c.__e=!0,mt(c)})},this.sub=function(a){i.add(a);var c=a.componentWillUnmount;a.componentWillUnmount=function(){i&&i.delete(a),c&&c.call(a)}}),r.children}};return n.Provider.__=n.Consumer.contextType=n}Pe=an.slice,N={__e:function(t,e,n,r){for(var i,o,a;e=e.__;)if((i=e.__c)&&!i.__)try{if((o=i.constructor)&&o.getDerivedStateFromError!=null&&(i.setState(o.getDerivedStateFromError(t)),a=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(t,r||{}),a=i.__d),a)return i.__E=i}catch(c){t=c}throw t}},tn=0,ze.prototype.setState=function(t,e){var n;n=this.__s!=null&&this.__s!==this.state?this.__s:this.__s=se({},this.state),typeof t=="function"&&(t=t(se({},n),this.props)),t&&se(n,t),t!=null&&this.__v&&(e&&this._sb.push(e),mt(this))},ze.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),mt(this))},ze.prototype.render=B,le=[],rn=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,dt=function(t,e){return t.__v.__b-e.__v.__b},Fe.__r=0,on=/(PointerCapture)$|Capture$/i,ut=0,pt=pn(!1),ft=pn(!0),sn=0;var fi=0;function s(t,e,n,r,i,o){e||(e={});var a,c,d=e;if("ref"in d)for(c in d={},e)c=="ref"?a=e[c]:d[c]=e[c];var p={type:t,props:d,key:n,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--fi,__i:-1,__u:0,__source:i,__self:o};if(typeof t=="function"&&(a=t.defaultProps))for(c in a)d[c]===void 0&&(d[c]=a[c]);return N.vnode&&N.vnode(p),p}const hi=':host{all:initial}.dc{--dc-accent: #5865f2;--dc-accent-2: #4a55cc;--dc-on-accent: #fff;--dc-on-grad: #fff;--dc-accent-soft: rgba(88,101,242,.14);--dc-accent-text: #4a55cc;--w-bg: #ffffff;--w-raised: #ffffff;--w-sunken: #f2f3f7;--w-bubble: #f0f1f5;--w-line: rgba(18,22,33,.08);--w-line-strong: rgba(18,22,33,.15);--w-fg: #14171f;--w-fg-2: #3b404c;--w-muted: #6a7080;--w-faint: #9499a5;--w-online: #23a55a;--w-idle: #f0b232;--w-dnd: #f23f43;--w-offline: #80848e;--w-danger: #e5484d;--w-success: #1f9d55;--w-warn: #c98a0c;--w-badge: #f23f43;--w-shadow: 0 1px 2px rgba(16,20,30,.06), 0 10px 28px -8px rgba(16,20,30,.18), 0 30px 70px -18px rgba(16,20,30,.28);--w-card-shadow: 0 1px 2px rgba(16,20,30,.05), 0 6px 18px -10px rgba(16,20,30,.2);--ease-out: cubic-bezier(.22,1,.36,1);--ease-spring: cubic-bezier(.34,1.45,.64,1);--font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;--mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;--edge: 20px;position:fixed;inset:0;z-index:2147483000;pointer-events:none;font-family:var(--font);color:var(--w-fg);font-size:14px;line-height:1.4;text-align:left;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;color-scheme:light}.dc[data-theme=dark]{--w-bg: #232428;--w-raised: #2b2d31;--w-sunken: #1c1d21;--w-bubble: #34363c;--w-line: rgba(255,255,255,.07);--w-line-strong: rgba(255,255,255,.13);--w-fg: #f2f3f5;--w-fg-2: #d5d7dc;--w-muted: #a4a8b2;--w-faint: #7d828d;--w-shadow: 0 1px 2px rgba(0,0,0,.3), 0 14px 34px -8px rgba(0,0,0,.55), 0 30px 80px -18px rgba(0,0,0,.6);--w-card-shadow: 0 1px 2px rgba(0,0,0,.25);color-scheme:dark}.dc *,.dc *:before,.dc *:after{box-sizing:border-box}:where(.dc) button{font:inherit;color:inherit;margin:0}:where(.dc) :is(p,h1,h2,h3,h4,ul,ol,form){margin:0;padding:0}.dc :focus-visible{outline:2px solid var(--dc-accent);outline-offset:2px}.dc [hidden]{display:none!important}.dc svg{display:block;flex:none}.dc img{max-width:100%}.dc-sr{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}.dc-launcher{pointer-events:auto;position:absolute;bottom:calc(var(--edge) + env(safe-area-inset-bottom,0px));right:var(--edge);width:56px;height:56px;border-radius:50%;border:0;padding:0;cursor:pointer;background:linear-gradient(145deg,var(--dc-accent) 0%,var(--dc-accent-2) 100%);color:var(--dc-on-grad);box-shadow:0 2px 4px #10141e1f,0 10px 26px -6px color-mix(in srgb,var(--dc-accent) 60%,transparent);transition:transform .35s var(--ease-spring),opacity .2s}.dc[data-pos=left] .dc-launcher{right:auto;left:var(--edge)}.dc-launcher:hover{transform:translateY(-2px) scale(1.04)}.dc-launcher:active{transform:scale(.93);transition-duration:.1s}.dc-launcher .ic{position:absolute;inset:0;display:grid;place-items:center;transition:transform .4s var(--ease-spring),opacity .2s}.dc-launcher .ic-close{opacity:0;transform:rotate(-90deg) scale(.6)}.dc-launcher.is-open .ic-chat{opacity:0;transform:rotate(90deg) scale(.6)}.dc-launcher.is-open .ic-close{opacity:1;transform:none}.dc-launcher.has-unread:after{content:"";position:absolute;inset:0;border-radius:50%;border:2px solid var(--dc-accent);animation:dc-halo 2.4s var(--ease-out) infinite;pointer-events:none}@keyframes dc-halo{0%{transform:scale(1);opacity:.7}70%,to{transform:scale(1.55);opacity:0}}.dc-badge{position:absolute;top:-3px;right:-3px;min-width:22px;height:22px;padding:0 6px;border-radius:11px;background:var(--w-badge);color:#fff;font:700 12px/22px var(--font);text-align:center;font-variant-numeric:tabular-nums;box-shadow:0 0 0 2.5px #fff}.dc-preview{pointer-events:auto;position:absolute;right:var(--edge);bottom:calc(var(--edge) + 70px + env(safe-area-inset-bottom,0px));width:300px;max-width:calc(100% - 2 * var(--edge));background:var(--w-raised);color:var(--w-fg);border:1px solid var(--w-line);border-radius:18px 18px 6px;padding:12px 14px;box-shadow:var(--w-shadow);cursor:pointer;display:grid;grid-template-columns:34px 1fr;gap:10px;transform-origin:bottom right}.dc[data-pos=left] .dc-preview{right:auto;left:var(--edge);border-radius:18px 18px 18px 6px;transform-origin:bottom left}.dc-preview .who{font-size:12.5px;color:var(--w-muted);margin-bottom:2px}.dc-preview .who b{color:var(--w-fg);font-weight:600}.dc-preview .txt{font-size:14px;color:var(--w-fg-2);display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical;overflow:hidden;overflow-wrap:anywhere}.dc-preview .x{position:absolute;top:-8px;right:-8px;width:24px;height:24px;border-radius:50%;border:0;background:var(--w-fg);color:var(--w-bg);display:grid;place-items:center;cursor:pointer;opacity:0;transition:opacity .15s;padding:0}.dc-preview:hover .x,.dc-preview:focus-within .x{opacity:1}@media (hover: none){.dc-preview .x{opacity:1}}.dc-panel{pointer-events:auto;position:absolute;right:var(--edge);bottom:calc(var(--edge) + 70px + env(safe-area-inset-bottom,0px));width:384px;height:min(680px,calc(100% - 110px));max-width:calc(100% - 2 * var(--edge));background:var(--w-bg);border-radius:22px;box-shadow:var(--w-shadow);border:1px solid var(--w-line);overflow:hidden;display:flex;flex-direction:column;transform-origin:bottom right}.dc[data-pos=left] .dc-panel{right:auto;left:var(--edge);transform-origin:bottom left}.dc[data-theme=dark] .dc-panel{border:0}.dc-views{position:relative;flex:1;min-height:0}.dc-view{position:absolute;inset:0;display:flex;flex-direction:column;background:var(--w-bg)}.dc-head{background:linear-gradient(160deg,var(--dc-accent) 0%,var(--dc-accent-2) 100%);color:var(--dc-on-grad);position:relative;flex:none;isolation:isolate}.dc-head:before{content:"";position:absolute;inset:0;z-index:-1;pointer-events:none;background:radial-gradient(120% 90% at 100% 0%,rgba(255,255,255,.22),transparent 55%),radial-gradient(80% 60% at 0% 100%,rgba(0,0,0,.12),transparent 60%)}.dc[data-flat] .dc-head:before{display:none}.dc-hbtn{width:34px;height:34px;border-radius:10px;border:0;background:transparent;display:grid;place-items:center;cursor:pointer;color:inherit;flex:none;padding:0;transition:background .15s,transform .2s var(--ease-spring)}.dc-hbtn:hover{background:color-mix(in srgb,currentColor 16%,transparent)}.dc-hbtn:active{transform:scale(.9)}.dc-hbtn .ic-down{display:none}.dc-head--compact{display:flex;align-items:center;gap:6px;padding:12px 10px;min-height:66px}.dc-head-id{flex:1;min-width:0;display:flex;align-items:center;gap:10px;padding-left:4px}.dc-head-id .tx{min-width:0}.dc-head-id .t{font-weight:650;font-size:15.5px;line-height:1.2;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dc-head-id .s{font-size:12.5px;opacity:.85;display:flex;align-items:center;gap:6px;white-space:nowrap;overflow:hidden;margin-top:1px}.dc-head-id .s span:last-child{overflow:hidden;text-overflow:ellipsis}.dc-head-id .mini{display:flex;flex:none}.dc-head-id .mini .dc-av{margin-left:-5px;box-shadow:0 0 0 1.5px var(--dc-accent)}.dc-head-id .mini .dc-av:first-child{margin-left:0}.dc-av{--s: 28px;width:var(--s);height:var(--s);border-radius:50%;flex:none;position:relative;display:grid;place-items:center;font:650 calc(var(--s) * .4) / 1 var(--font);color:#fff;letter-spacing:-.02em;background:linear-gradient(140deg,hsl(var(--h, 230) 72% 64%),hsl(calc(var(--h, 230) + 28) 62% 46%))}.dc-av img{width:100%;height:100%;border-radius:50%;object-fit:cover;display:block}.dc-av .dot{position:absolute;right:-2px;bottom:-2px;width:calc(var(--s) * .34);height:calc(var(--s) * .34);min-width:9px;min-height:9px;border-radius:50%;box-shadow:0 0 0 2.5px var(--ring, var(--w-bg))}.dot.online{background:var(--w-online)}.dot.idle{background:var(--w-idle)}.dot.dnd{background:var(--w-dnd)}.dot.offline,.dot.invisible{background:var(--w-offline)}.dc-head .dc-av .dot{--ring: var(--dc-accent-2)}.dc-guild{--s: 36px;width:var(--s);height:var(--s);border-radius:calc(var(--s) * .3);background:var(--dc-accent-2);color:var(--dc-on-grad);display:grid;place-items:center;flex:none;position:relative;font:700 calc(var(--s) * .42) / 1 var(--font);box-shadow:0 0 0 1px #ffffff24 inset}.dc-guild img{width:100%;height:100%;object-fit:cover;border-radius:inherit;display:block}.dc-guild .dot{position:absolute;right:-3px;bottom:-3px;width:11px;height:11px;border-radius:50%;box-shadow:0 0 0 2.5px var(--ring, var(--dc-accent-2))}.dc-hero{padding:16px 16px 58px}.dc-hero .top{display:flex;align-items:center;justify-content:space-between}.dc-hero h2{font:700 26px/1.12 var(--font);letter-spacing:-.02em;margin:22px 4px 6px;text-wrap:balance;color:inherit}.dc-hero p{margin:0 4px;font-size:14.5px;opacity:.88;line-height:1.45}.dc-team{display:flex;align-items:center;gap:10px;margin:16px 4px 0;font-size:13px}.dc-team .stack{display:flex}.dc-team .stack .dc-av{--s: 30px;margin-left:-8px;box-shadow:0 0 0 2px var(--dc-accent-2)}.dc-team .stack .dc-av:first-child{margin-left:0}.dc-team .stack .dc-av .dot{--ring: var(--dc-accent-2)}.dc-home-body{flex:1;min-height:0;overflow-y:auto;margin-top:-40px;padding:0 12px 12px;display:flex;flex-direction:column;gap:10px;position:relative;scrollbar-width:thin}.dc-card{background:var(--w-raised);border:1px solid var(--w-line);border-radius:16px;box-shadow:var(--w-card-shadow)}.dc-cta{display:flex;align-items:center;gap:12px;width:100%;padding:14px 14px 14px 16px;text-align:left;cursor:pointer;color:var(--w-fg);transition:transform .25s var(--ease-spring),box-shadow .2s}.dc-cta:hover{transform:translateY(-1px);box-shadow:var(--w-shadow)}.dc-cta .tx{flex:1;min-width:0}.dc-cta b{display:block;font-size:15px;font-weight:650}.dc-cta small{display:block;font-size:13px;color:var(--w-muted);margin-top:2px}.dc-cta .go{width:36px;height:36px;border-radius:50%;background:var(--dc-accent);color:var(--dc-on-accent);display:grid;place-items:center;flex:none;transition:transform .3s var(--ease-spring)}.dc-cta:hover .go{transform:translate(3px)}.dc-cta.is-paused{cursor:default}.dc-cta.is-paused:hover{transform:none;box-shadow:var(--w-card-shadow)}.dc-eyebrow{font-size:11px;font-weight:600;letter-spacing:.07em;text-transform:uppercase;color:var(--w-faint);padding:12px 16px 2px}.dc-list{padding:4px}.dc-conv{display:flex;gap:12px;align-items:center;width:100%;padding:12px 14px 12px 12px;border:0;background:transparent;text-align:left;cursor:pointer;border-radius:12px;color:var(--w-fg);position:relative;transition:background .15s}.dc-conv:hover{background:var(--w-sunken)}.dc-conv .tx{flex:1;min-width:0}.dc-conv .l1{display:flex;gap:8px;align-items:baseline}.dc-conv .l1 b{font-size:14px;font-weight:600;flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dc-conv .l1 time{font-size:12px;color:var(--w-faint);flex:none}.dc-conv .l2{display:block;font-size:13px;color:var(--w-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;margin-top:2px}.dc-conv.is-unread .l2{color:var(--w-fg);font-weight:550}.dc-conv .count{background:var(--w-badge);color:#fff;font:700 11px/20px var(--font);min-width:20px;height:20px;border-radius:10px;text-align:center;padding:0 6px;flex:none}.dc-conv .chev{color:var(--w-faint);flex:none}.dc-list .dc-conv+.dc-conv:before{content:"";position:absolute;left:64px;right:14px;top:0;height:1px;background:var(--w-line)}.dc-pill{display:inline-flex;align-items:center;gap:4px;font-size:11px;font-weight:600;padding:1px 7px;border-radius:999px;background:var(--w-sunken);color:var(--w-muted);margin-right:4px;vertical-align:1px}.dc-pill.ok{color:var(--w-success);background:color-mix(in srgb,var(--w-success) 12%,transparent)}.dc-empty{padding:14px 16px 16px;font-size:13px;color:var(--w-muted)}.dc-empty button{border:0;background:none;padding:0;color:var(--dc-accent-text);font-weight:600;cursor:pointer;text-decoration:underline;text-underline-offset:2px}.dc-skel-row{display:flex;gap:12px;align-items:center;padding:12px}.dc-skel-row i,.dc-skel i{display:block;border-radius:999px;background:linear-gradient(90deg,var(--w-sunken) 0%,var(--w-bubble) 40%,var(--w-sunken) 80%);background-size:300% 100%;animation:dc-shimmer 1.2s linear infinite}.dc-skel-row i:first-child{width:40px;height:40px;flex:none}.dc-skel-row span{flex:1;display:flex;flex-direction:column;gap:7px}.dc-skel-row span i{height:10px;width:60%}.dc-skel-row span i+i{width:85%}@keyframes dc-shimmer{0%{background-position:100% 0}to{background-position:-50% 0}}.dc-conn{overflow:hidden;flex:none;font-size:12.5px;font-weight:550;display:flex;align-items:center;justify-content:center;gap:8px;padding:7px 12px}.dc-conn.is-down{background:color-mix(in srgb,var(--w-warn) 14%,var(--w-bg));color:var(--w-warn)}.dc-conn.is-up{background:color-mix(in srgb,var(--w-success) 13%,var(--w-bg));color:var(--w-success)}.dc-spin{width:13px;height:13px;border-radius:50%;border:2px solid currentColor;border-right-color:transparent;animation:dc-rot .8s linear infinite}@keyframes dc-rot{to{transform:rotate(360deg)}}.dc-scroll-wrap{flex:1;min-height:0;position:relative;display:flex;flex-direction:column}.dc-scroll{flex:1;min-height:0;overflow-y:auto;overflow-x:hidden;position:relative;scrollbar-width:thin;scrollbar-color:var(--w-line-strong) transparent;overscroll-behavior:contain}.dc-welcome{padding:34px 28px 10px;text-align:center;display:flex;flex-direction:column;align-items:center;gap:6px}.dc-welcome .stack{display:flex;margin-bottom:8px}.dc-welcome .stack .dc-av{--s: 44px;margin-left:-12px;box-shadow:0 0 0 3px var(--w-bg)}.dc-welcome .stack .dc-av:first-child{margin-left:0}.dc-welcome .stack .dc-av .dot{--ring: var(--w-bg)}.dc-welcome h3{margin:0;font-size:19px;font-weight:700;letter-spacing:-.015em;text-wrap:balance;color:var(--w-fg)}.dc-welcome p{margin:0;font-size:13.5px;color:var(--w-muted);max-width:30ch;line-height:1.5;text-wrap:balance}.dc-msgs{display:flex;flex-direction:column;padding:6px 14px}.dc-day{display:flex;align-items:center;gap:10px;font-size:11px;font-weight:600;letter-spacing:.07em;text-transform:uppercase;color:var(--w-faint);margin:16px 6px 2px}.dc-day:before,.dc-day:after{content:"";flex:1;height:1px;background:var(--w-line)}.dc-row{display:flex;gap:8px;align-items:flex-end;margin-top:2px}.dc-row.is-first{margin-top:12px}.dc-row--me{justify-content:flex-end}.dc-row.is-deleted{animation:dc-collapse .38s var(--ease-out) forwards;overflow:hidden}@keyframes dc-collapse{0%{max-height:600px;opacity:1}to{max-height:0;opacity:0;margin-top:0;transform:scale(.96)}}.dc-row-av{width:28px;flex:none;visibility:hidden}.dc-row.is-last .dc-row-av{visibility:visible}.dc-stack{display:flex;flex-direction:column;gap:3px;max-width:80%;min-width:0;align-items:flex-start}.dc-row--me .dc-stack{align-items:flex-end}.dc-name{display:none;font-size:12px;color:var(--w-muted);margin:0 0 1px 4px}.dc-name b{color:var(--w-fg-2);font-weight:600;margin-right:4px}.dc-row.is-first .dc-name{display:block}.dc-bubble{padding:8px 13px 9px;font-size:14.5px;line-height:1.42;overflow-wrap:anywhere;background:var(--w-bubble);color:var(--w-fg);border-radius:6px 18px 18px 6px;max-width:100%;white-space:normal;transition:background .6s}.dc-row--agent.is-first .dc-bubble{border-top-left-radius:18px}.dc-row--agent.is-last .dc-bubble{border-bottom-left-radius:18px}.dc-row--me .dc-bubble{background:var(--dc-accent);color:var(--dc-on-accent);border-radius:18px 6px 6px 18px}.dc-row--me.is-first .dc-bubble{border-top-right-radius:18px}.dc-row--me.is-last .dc-bubble{border-bottom-right-radius:18px}.dc-row.is-pending .dc-bubble,.dc-row.is-pending .dc-img,.dc-row.is-pending .dc-file{opacity:.62}.dc-bubble a{color:var(--dc-accent-text);text-decoration:underline;text-decoration-thickness:1px;text-underline-offset:2px}.dc-row--me .dc-bubble a{color:inherit}.dc-bubble code{font:12.5px/1.4 var(--mono);background:color-mix(in srgb,currentColor 11%,transparent);padding:1px 5px;border-radius:5px}.dc-bubble pre{margin:6px 0 2px;padding:9px 11px;border-radius:9px;background:color-mix(in srgb,currentColor 8%,transparent);overflow-x:auto;white-space:pre}.dc-bubble pre code{background:none;padding:0;font-size:12px}.dc-bubble strong{font-weight:650}.dc-bubble .dc-quote{display:inline-block;border-left:3px solid color-mix(in srgb,currentColor 30%,transparent);padding-left:8px}.dc-cemoji{width:20px;height:20px;vertical-align:-5px;display:inline-block;object-fit:contain}.dc-bubble.is-jumbo{background:none!important;padding:0 2px;font-size:40px;line-height:1.15}.dc-bubble.is-jumbo .dc-cemoji{width:46px;height:46px}.dc-spoiler{background:var(--w-fg);color:transparent;border-radius:4px;cursor:pointer;transition:background .25s,color .25s;padding:0 2px}.dc-row--me .dc-spoiler{background:var(--dc-on-accent)}.dc-spoiler.is-shown{background:color-mix(in srgb,currentColor 12%,transparent)!important;color:inherit;cursor:auto}.dc-edited{font-size:11px;color:var(--w-faint);margin-left:4px}.dc-row--me .dc-edited{color:inherit;opacity:.7}.dc-bubble.is-flash{background:color-mix(in srgb,var(--dc-accent) 22%,var(--w-bubble));transition:none}.dc-status{display:none;align-items:center;gap:4px;font-size:11.5px;color:var(--w-faint);margin:1px 4px 0}.dc-row.show-status .dc-status,.dc-status.is-failed,.dc-status.is-pending{display:flex}.dc-status.is-failed{color:var(--w-danger)}.dc-status button{border:0;background:none;padding:0;color:inherit;font-weight:650;text-decoration:underline;text-underline-offset:2px;cursor:pointer}.dc-event{align-self:center;display:flex;align-items:center;gap:7px;font-size:12.5px;color:var(--w-muted);margin:14px 0 4px;padding:5px 12px 5px 6px;border-radius:999px;background:var(--w-sunken);max-width:92%}.dc-event .dc-av{--s: 20px}.dc-event .ic{width:20px;height:20px;border-radius:50%;display:grid;place-items:center;background:var(--w-bg);color:var(--w-muted);flex:none}.dc-event.ok .ic{background:var(--w-success);color:#fff}.dc-event b{color:var(--w-fg-2);font-weight:600}.dc-event time{color:var(--w-faint)}.dc-event.note{border-radius:14px;padding:9px 12px;text-align:center;line-height:1.45}.dc-gallery{display:grid;grid-template-columns:1fr 1fr;gap:4px;width:236px;max-width:100%}.dc-img{position:relative;display:block;width:min(var(--w, 232px),232px);max-width:100%;border:0;padding:0;border-radius:14px;overflow:hidden;background:var(--w-sunken);cursor:zoom-in}.dc-gallery .dc-img{width:100%;aspect-ratio:1!important}.dc-img img{display:block;width:100%;height:100%;object-fit:cover;transition:transform .4s var(--ease-out)}.dc-img:hover img{transform:scale(1.035)}.dc-img.is-uploading,.dc-img.is-failed{cursor:default}.dc-img.is-uploading:after{content:"";position:absolute;inset:0;background:#080a106b}.dc-ring{position:absolute;left:50%;top:50%;width:44px;height:44px;margin:-22px 0 0 -22px;z-index:1;transform:rotate(-90deg)}.dc-ring circle{fill:none;stroke-width:3.2}.dc-ring .bg{stroke:#ffffff4d}.dc-ring .fg{stroke:#fff;stroke-linecap:round;stroke-dasharray:100;transition:stroke-dashoffset .25s var(--ease-out)}.dc-img .pct{position:absolute;left:0;right:0;top:50%;z-index:1;margin-top:26px;text-align:center;color:#fff;font:600 11px/1 var(--font);font-variant-numeric:tabular-nums}.dc-img .fail{position:absolute;inset:0;z-index:1;display:grid;place-items:center;align-content:center;gap:6px;background:color-mix(in srgb,var(--w-danger) 62%,rgba(0,0,0,.4));color:#fff;font-size:12.5px;font-weight:650}.dc-file{position:relative;display:flex;align-items:center;gap:11px;width:248px;max-width:100%;padding:10px;border-radius:14px;background:var(--w-raised);border:1px solid var(--w-line-strong);color:var(--w-fg);text-decoration:none;cursor:pointer;overflow:hidden;text-align:left;transition:transform .25s var(--ease-spring),box-shadow .2s}.dc-file:hover{transform:translateY(-1px);box-shadow:var(--w-card-shadow)}.dc-ftype{width:34px;height:40px;flex:none;position:relative;border-radius:6px;background:#e5484d;color:#fff;font:800 8.5px/1 var(--font);letter-spacing:.04em;display:grid;place-items:end center;padding-bottom:7px;clip-path:polygon(0 0,66% 0,100% 28%,100% 100%,0 100%)}.dc-ftype:after{content:"";position:absolute;top:0;right:0;width:34%;height:28%;background:#fff6;border-bottom-left-radius:4px}.dc-ftype.is-image{background:#3f8cff}.dc-file .tx{flex:1;min-width:0}.dc-file b{display:block;font-size:13.5px;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dc-file small{display:block;font-size:12px;color:var(--w-muted);margin-top:2px;font-variant-numeric:tabular-nums}.dc-file .dl{width:32px;height:32px;border-radius:50%;background:var(--w-sunken);color:var(--w-muted);display:grid;place-items:center;flex:none;transition:background .15s,color .15s}.dc-file:hover .dl{background:var(--dc-accent);color:var(--dc-on-accent)}.dc-file .bar{position:absolute;left:0;bottom:0;height:3px;width:100%;background:var(--w-sunken)}.dc-file .bar i{display:block;height:100%;background:var(--dc-accent);transition:width .25s var(--ease-out);border-radius:0 2px 2px 0}.dc-file.is-failed{border-color:color-mix(in srgb,var(--w-danger) 50%,transparent)}.dc-file.is-failed small{color:var(--w-danger)}.dc-inline-img{display:block;max-width:232px;max-height:232px;border-radius:14px}.dc-skel{display:flex;flex-direction:column;gap:10px;padding:18px 14px}.dc-skel i{height:34px;border-radius:16px}.dc-skel i:nth-child(odd){width:62%}.dc-skel i:nth-child(2n){width:48%;align-self:flex-end}.dc-skel i:nth-child(3){width:70%;height:52px}.dc-intro{align-self:stretch;display:flex;gap:8px;align-items:flex-end;margin-top:12px}.dc-intro .card{flex:1;min-width:0;background:var(--w-raised);border:1px solid var(--w-line-strong);border-radius:18px 18px 18px 6px;padding:14px;box-shadow:var(--w-card-shadow)}.dc-intro h4{margin:0 0 3px;font-size:14.5px;font-weight:650;color:var(--w-fg)}.dc-intro p{margin:0 0 12px;font-size:13px;color:var(--w-muted);line-height:1.45}.dc-intro form{display:flex;flex-direction:column;gap:8px}.dc-in{display:flex;flex-direction:column;gap:4px}.dc-in span{font-size:12px;font-weight:600;color:var(--w-fg-2)}.dc-in input{font:16px/1.3 var(--font);color:var(--w-fg);background:var(--w-bg);border:1px solid var(--w-line-strong);border-radius:11px;padding:9px 11px;outline:0;width:100%;transition:border-color .15s,box-shadow .15s}@media (pointer: fine){.dc-in input{font-size:14.5px}}.dc-in input:focus{border-color:var(--dc-accent);box-shadow:0 0 0 4px var(--dc-accent-soft)}.dc-in input:focus-visible{outline:none}.dc-in.is-err input{border-color:var(--w-danger)}.dc-in em{font-style:normal;font-size:12px;color:var(--w-danger)}.dc-btn{display:inline-flex;align-items:center;justify-content:center;gap:7px;border:0;border-radius:12px;padding:10px 14px;font-weight:650;font-size:14px;background:var(--dc-accent);color:var(--dc-on-accent);cursor:pointer;transition:transform .25s var(--ease-spring),filter .15s}.dc-btn:hover{filter:brightness(1.06)}.dc-btn:active{transform:scale(.96)}.dc-intro .done{display:flex;align-items:center;gap:8px;font-size:13px;color:var(--w-muted)}.dc-intro .done .ok{width:20px;height:20px;border-radius:50%;background:var(--w-success);color:#fff;display:grid;place-items:center;flex:none}.dc-intro .done b{color:var(--w-fg);font-weight:600}.dc-shake{animation:dc-shake .4s}@keyframes dc-shake{20%{transform:translate(-5px)}40%{transform:translate(5px)}60%{transform:translate(-3px)}80%{transform:translate(2px)}}.dc-typing{display:flex;gap:8px;align-items:flex-end;padding:2px 14px 8px}.dc-typing .dots{display:flex;gap:4px;padding:13px 14px;background:var(--w-bubble);border-radius:18px 18px 18px 6px}.dc-typing .dots i{width:7px;height:7px;border-radius:50%;background:var(--w-muted);animation:dc-bounce 1.1s infinite var(--ease-out)}.dc-typing .dots i:nth-child(2){animation-delay:.14s}.dc-typing .dots i:nth-child(3){animation-delay:.28s}@keyframes dc-bounce{0%,60%,to{transform:translateY(0);opacity:.5}30%{transform:translateY(-4px);opacity:1}}.dc-jump{position:absolute;left:50%;bottom:10px;transform:translate(-50%);z-index:2;display:flex;align-items:center;gap:6px;border:0;border-radius:999px;padding:7px 12px 7px 10px;font-size:12.5px;font-weight:600;background:var(--w-fg);color:var(--w-bg);box-shadow:var(--w-card-shadow);cursor:pointer}.dc-composer{flex:none;padding:6px 12px calc(8px + env(safe-area-inset-bottom,0px));position:relative;background:var(--w-bg)}.dc-field{border:1px solid var(--w-line-strong);background:var(--w-raised);border-radius:22px;transition:border-color .2s,box-shadow .2s}.dc-field:focus-within{border-color:color-mix(in srgb,var(--dc-accent) 70%,transparent);box-shadow:0 0 0 4px var(--dc-accent-soft)}.dc-tray{display:flex;gap:10px;padding:12px 12px 2px;overflow-x:auto;scrollbar-width:none}.dc-chip{position:relative;flex:none;height:58px;border-radius:13px;background:var(--w-sunken);border:1px solid var(--w-line)}.dc-chip.img{width:58px}.dc-chip.img img{width:100%;height:100%;object-fit:cover;border-radius:12px;display:block}.dc-chip.file{display:flex;align-items:center;gap:9px;padding:0 30px 0 10px;max-width:200px}.dc-chip.file .dc-ftype{width:28px;height:33px;padding-bottom:5px;font-size:7.5px}.dc-chip.file .tx{min-width:0}.dc-chip.file b{display:block;font-size:12.5px;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:var(--w-fg)}.dc-chip.file small{font-size:11.5px;color:var(--w-muted)}.dc-chip .rm{position:absolute;top:-7px;right:-7px;width:22px;height:22px;border-radius:50%;border:2px solid var(--w-raised);background:var(--w-fg);color:var(--w-bg);display:grid;place-items:center;cursor:pointer;padding:0;transition:transform .2s var(--ease-spring)}.dc-chip .rm:hover{transform:scale(1.12)}.dc-input-row{display:flex;align-items:flex-end;gap:2px;padding:5px 5px 5px 15px}.dc-input-row textarea{flex:1;min-width:0;border:0;outline:0;resize:none;background:transparent;color:var(--w-fg);font:16px/1.4 var(--font);padding:7px 0;height:37px;max-height:128px;margin:0}@media (pointer: fine){.dc-input-row textarea{font-size:15px;height:35px}}.dc-input-row textarea::placeholder{color:var(--w-faint)}.dc-input-row textarea:focus-visible{outline:none}.dc-tool{width:34px;height:34px;border-radius:50%;border:0;background:transparent;color:var(--w-muted);display:grid;place-items:center;cursor:pointer;flex:none;padding:0;transition:background .15s,color .15s,transform .2s var(--ease-spring)}.dc-tool:hover{background:var(--w-sunken);color:var(--w-fg)}.dc-tool:active{transform:scale(.9)}.dc-tool[aria-expanded=true]{color:var(--dc-accent-text);background:var(--dc-accent-soft)}.dc-send{width:34px;height:34px;border-radius:50%;border:0;display:grid;place-items:center;flex:none;cursor:pointer;margin-left:2px;padding:0;background:var(--dc-accent);color:var(--dc-on-accent);transition:transform .35s var(--ease-spring),background .2s,color .2s,box-shadow .2s;box-shadow:0 4px 12px -4px color-mix(in srgb,var(--dc-accent) 70%,transparent)}.dc-send:disabled{background:var(--w-sunken);color:var(--w-faint);transform:scale(.86);cursor:default;box-shadow:none}.dc-send:not(:disabled):hover{transform:scale(1.07)}.dc-send:not(:disabled):active{transform:scale(.92)}.dc-powered{display:flex;justify-content:center;align-items:center;gap:5px;margin-top:7px;font-size:11px;color:var(--w-faint);text-decoration:none;transition:color .15s}.dc-powered svg{height:9px;width:auto}.dc-powered:hover{color:var(--w-fg-2)}.dc-toast{position:absolute;left:12px;right:12px;bottom:calc(100% + 4px);display:flex;justify-content:center;pointer-events:none;z-index:3}.dc-toast span{display:flex;align-items:center;gap:7px;background:var(--w-fg);color:var(--w-bg);font-size:12.5px;font-weight:550;padding:8px 12px;border-radius:12px;box-shadow:var(--w-shadow);max-width:100%}.dc-toast span svg{color:#ff8b8e}.dc-resolved{display:flex;flex-direction:column;align-items:center;gap:10px;padding:10px 8px 2px;text-align:center}.dc-resolved p{margin:0;font-size:13px;color:var(--w-muted)}.dc-emoji{position:absolute;right:12px;bottom:calc(100% - 2px);width:300px;max-width:calc(100% - 24px);height:268px;background:var(--w-raised);border:1px solid var(--w-line-strong);border-radius:18px;box-shadow:var(--w-shadow);display:flex;flex-direction:column;overflow:hidden;z-index:4;transform-origin:bottom right}.dc-emoji .grid{flex:1;overflow-y:auto;display:grid;grid-template-columns:repeat(8,1fr);padding:8px;gap:2px;align-content:start;scrollbar-width:thin}.dc-emoji .grid button{border:0;background:transparent;font-size:22px;line-height:1;height:34px;border-radius:9px;cursor:pointer;padding:0;transition:background .12s,transform .2s var(--ease-spring)}.dc-emoji .grid button:hover{background:var(--w-sunken);transform:scale(1.18)}.dc-emoji .tabs{display:flex;border-top:1px solid var(--w-line);padding:4px;gap:2px}.dc-emoji .tabs button{flex:1;border:0;background:transparent;font-size:17px;height:32px;border-radius:9px;cursor:pointer;padding:0;filter:grayscale(1);opacity:.6;transition:filter .15s,opacity .15s,background .15s}.dc-emoji .tabs button[aria-pressed=true]{filter:none;opacity:1;background:var(--w-sunken)}.dc-emoji .cat{grid-column:1 / -1;font-size:11px;font-weight:600;letter-spacing:.06em;text-transform:uppercase;color:var(--w-faint);padding:6px 4px 4px}.dc-drop{position:absolute;inset:8px;z-index:6;border-radius:18px;display:grid;place-items:center;align-content:center;gap:6px;text-align:center;color:var(--dc-accent-text);background-color:color-mix(in srgb,var(--w-bg) 86%,transparent);backdrop-filter:blur(6px);background-image:linear-gradient(90deg,var(--dc-accent) 50%,transparent 0),linear-gradient(90deg,var(--dc-accent) 50%,transparent 0),linear-gradient(0deg,var(--dc-accent) 50%,transparent 0),linear-gradient(0deg,var(--dc-accent) 50%,transparent 0);background-repeat:repeat-x,repeat-x,repeat-y,repeat-y;background-size:14px 2px,14px 2px,2px 14px,2px 14px;background-position:0 0,0 100%,0 0,100% 0;animation:dc-march .6s linear infinite;pointer-events:none}@keyframes dc-march{to{background-position:14px 0,-14px 100%,0 -14px,100% 14px}}.dc-drop .ic{width:56px;height:56px;border-radius:18px;background:var(--dc-accent);color:var(--dc-on-accent);display:grid;place-items:center;margin:0 auto 6px;animation:dc-float 1.4s ease-in-out infinite}@keyframes dc-float{50%{transform:translateY(-5px)}}.dc-drop b{font-size:16px;color:var(--w-fg)}.dc-drop small{font-size:12.5px;color:var(--w-muted)}.dc-lightbox{pointer-events:auto;position:fixed;inset:0;z-index:20;display:flex;flex-direction:column}.dc-lightbox .bd{position:absolute;inset:0;background:#08090cdb;backdrop-filter:blur(4px)}.dc-lightbox .bar{position:relative;display:flex;align-items:center;gap:10px;padding:calc(12px + env(safe-area-inset-top,0px)) 14px 12px;color:#fff;font-size:13px}.dc-lightbox .bar span{flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;opacity:.85}.dc-lightbox .bar a,.dc-lightbox .bar button{color:#fff;border:0;background:#ffffff1f;border-radius:10px;height:34px;padding:0 12px;display:inline-flex;align-items:center;gap:6px;cursor:pointer;text-decoration:none;font-size:13px}.dc-lightbox .bar button.x{width:34px;padding:0;justify-content:center}.dc-lightbox .pic{position:relative;flex:1;min-height:0;display:grid;place-items:center;padding:8px 20px 28px}.dc-lightbox img{max-width:100%;max-height:100%;border-radius:10px;box-shadow:0 30px 80px #00000080;transform-origin:top left}@media (max-width: 520px),(max-height: 540px){.dc-panel{inset:0;width:auto;height:auto;max-width:none;border-radius:0;border:0;padding-top:env(safe-area-inset-top,0px)}.dc-launcher.is-open{opacity:0;pointer-events:none;transform:scale(.6)}.dc-hbtn .ic-x{display:none}.dc-hbtn .ic-down{display:block}}@media (prefers-reduced-motion: reduce){.dc *,.dc *:before,.dc *:after{animation-duration:.001ms!important;animation-iteration-count:1!important;transition-duration:.001ms!important}}',gi="https://api.deskcord.chat";function mi(){const t=window.deskcord?.settings;if(!t?.app_id)return console.error("[Deskcord] window.deskcord.settings.app_id is missing: check the embed snippet."),null;const e=t.theme==="dark"||t.theme==="auto"?t.theme:"light";return{appId:String(t.app_id),domain:(t.domain??gi).replace(/\/+$/,""),user:t.user,theme:e}}const vi="DESKCORD_UNAVAILABLE",yi="DESKCORD_QUOTA_REACHED";class ve extends Error{constructor(e,n){super(`Request failed (${e})`),this.status=e,this.body=n}}class mn extends Error{constructor(){super("Deskcord is temporarily unavailable")}}class vn extends Error{constructor(){super("This team isn't taking new conversations right now")}}class bt extends Error{}function yn(t){if(!t)return null;try{return JSON.parse(t)}catch{return t}}function bi(t,e){function n(o,a){if(o===503&&a?.code===vi)throw e(),new mn;if(o===403&&a?.code===yi)throw new vn;if(o<200||o>=300)throw new ve(o,a)}async function r(o,a,c,d){const p={};c!==void 0&&(p["Content-Type"]="application/json"),d&&(p.Authorization=`Bearer ${d}`);let m;try{m=await fetch(t+a,{method:o,headers:p,body:c===void 0?void 0:JSON.stringify(c)})}catch(h){throw new bt(String(h))}const u=yn(await m.text());return n(m.status,u),u}function i(o,a,c,d,p){return new Promise((m,u)=>{const h=new XMLHttpRequest;h.open("POST",t+o),h.setRequestHeader("Authorization",`Bearer ${c}`),h.upload.onprogress=x=>{x.lengthComputable&&d(x.loaded/x.total)},h.onload=()=>{const x=yn(h.responseText);try{n(h.status,x),m(x)}catch(k){u(k)}},h.onerror=()=>u(new bt("Upload failed"));const w=new FormData;w.append("file",a),p&&w.append("pageUrl",p),h.send(w)})}return{get:(o,a)=>r("GET",o,void 0,a),post:(o,a,c)=>r("POST",o,a,c),upload:i}}const xi=2048;function xt(t=typeof window>"u"?void 0:window.location){if(!t||t.protocol!=="https:"&&t.protocol!=="http:")return;const e=`${t.origin}${t.pathname}`;return e.length<=xi?e:void 0}const bn=t=>t instanceof ve&&t.status===404;function wi(t,e){const n=bi(t.domain,e),r=t.appId,i=({name:o,email:a,avatarUrl:c,metadata:d})=>({name:o,email:a,...c?{avatarUrl:c}:{},...d?{metadata:d}:{}});return{async status(){return!!(await n.get(`/guildSettings/status/${encodeURIComponent(r)}`))?.active},settings(){return n.get(`/guildSettings/${encodeURIComponent(r)}`)},async token(o,a){const c=await n.post("/auth/token",{guildId:r,...i(o)},a);if(!c?.token||c.token==="undefined")throw new Error("No token in /auth/token response");return c.token},async identify(o,a){try{return(await n.post("/auth/identify",{guildId:r,userId:o.userId,userHash:o.userHash,...i(o)},a))?.token??null}catch(c){if(c instanceof ve&&c.status<500)return null;throw c}},async current(o){try{return(await n.get("/conversations/current",o))?.currentConversation??null}catch(a){if(bn(a))return null;throw a}},async past(o){try{return(await n.get("/conversations/past",o))?.pastConversations??[]}catch(a){if(bn(a))return[];throw a}},async unreadCount(o){const a=await n.get("/conversations/unread-count",o);return Number(a?.unreadCount)||0},async markRead(o,a){await n.post("/conversations/mark-read",{timestamp:a},o)},send(o,a,c){const d=xt();return n.post("/conversations/sendMessage",{name:a,content:c,...d?{pageUrl:d}:{}},o)},upload(o,a,c){return n.upload("/conversations/uploadAttachment",a,o,c,xt())}}}const xn=20,wn=40,_n=200,_i=1024,ki=t=>new TextEncoder().encode(t).length;function kn(t,e=Ai){if(t==null)return null;if(typeof t!="object"||Array.isArray(t))return e("metadata ignored: it must be a flat object."),null;const n=[],r={};let i=0,o=2;for(const[a,c]of Object.entries(t)){const d=a.trim(),p=c===null||typeof c=="boolean"||typeof c=="number"&&Number.isFinite(c)||typeof c=="string"&&c.length<=_n;if(!d||d.length>wn||d==="__proto__"||d in r){n.push(`"${a.slice(0,wn)}" (invalid key)`);continue}if(!p){n.push(`"${d}" (values must be strings of at most ${_n} characters, numbers, booleans or null)`);continue}const m=ki(`${JSON.stringify(d)}:${JSON.stringify(c)},`);if(i>=xn||o+m>_i){n.push(`"${d}" (too much metadata: ${xn} keys and about 1 KB at most)`);continue}o+=m,i++,r[d]=c}return n.length&&e(`metadata dropped: ${n.join(", ")}.`),i?r:null}function Ai(t){console.warn(`[Deskcord] ${t}`)}const te=Object.create(null);te.open="0",te.close="1",te.ping="2",te.pong="3",te.message="4",te.upgrade="5",te.noop="6";const He=Object.create(null);Object.keys(te).forEach(t=>{He[te[t]]=t});const wt={type:"error",data:"parser error"},An=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",En=typeof ArrayBuffer=="function",Tn=t=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(t):t&&t.buffer instanceof ArrayBuffer,_t=({type:t,data:e},n,r)=>An&&e instanceof Blob?n?r(e):Sn(e,r):En&&(e instanceof ArrayBuffer||Tn(e))?n?r(e):Sn(new Blob([e]),r):r(te[t]+(e||"")),Sn=(t,e)=>{const n=new FileReader;return n.onload=function(){const r=n.result.split(",")[1];e("b"+(r||""))},n.readAsDataURL(t)};function Cn(t){return t instanceof Uint8Array?t:t instanceof ArrayBuffer?new Uint8Array(t):new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}let kt;function Ei(t,e){if(An&&t.data instanceof Blob)return t.data.arrayBuffer().then(Cn).then(e);if(En&&(t.data instanceof ArrayBuffer||Tn(t.data)))return e(Cn(t.data));_t(t,!1,n=>{kt||(kt=new TextEncoder),e(kt.encode(n))})}const Rn="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Te=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let t=0;t<Rn.length;t++)Te[Rn.charCodeAt(t)]=t;const Ti=t=>{let e=t.length*.75,n=t.length,r,i=0,o,a,c,d;t[t.length-1]==="="&&(e--,t[t.length-2]==="="&&e--);const p=new ArrayBuffer(e),m=new Uint8Array(p);for(r=0;r<n;r+=4)o=Te[t.charCodeAt(r)],a=Te[t.charCodeAt(r+1)],c=Te[t.charCodeAt(r+2)],d=Te[t.charCodeAt(r+3)],m[i++]=o<<2|a>>4,m[i++]=(a&15)<<4|c>>2,m[i++]=(c&3)<<6|d&63;return p},Si=typeof ArrayBuffer=="function",At=(t,e)=>{if(typeof t!="string")return{type:"message",data:In(t,e)};const n=t.charAt(0);return n==="b"?{type:"message",data:Ci(t.substring(1),e)}:He[n]?t.length>1?{type:He[n],data:t.substring(1)}:{type:He[n]}:wt},Ci=(t,e)=>{if(Si){const n=Ti(t);return In(n,e)}else return{base64:!0,data:t}},In=(t,e)=>{switch(e){case"blob":return t instanceof Blob?t:new Blob([t]);case"arraybuffer":default:return t instanceof ArrayBuffer?t:t.buffer}},Nn="",Ri=(t,e)=>{const n=t.length,r=new Array(n);let i=0;t.forEach((o,a)=>{_t(o,!1,c=>{r[a]=c,++i===n&&e(r.join(Nn))})})},Ii=(t,e)=>{const n=t.split(Nn),r=[];for(let i=0;i<n.length;i++){const o=At(n[i],e);if(r.push(o),o.type==="error")break}return r};function Ni(){return new TransformStream({transform(t,e){Ei(t,n=>{const r=n.length;let i;if(r<126)i=new Uint8Array(1),new DataView(i.buffer).setUint8(0,r);else if(r<65536){i=new Uint8Array(3);const o=new DataView(i.buffer);o.setUint8(0,126),o.setUint16(1,r)}else{i=new Uint8Array(9);const o=new DataView(i.buffer);o.setUint8(0,127),o.setBigUint64(1,BigInt(r))}t.data&&typeof t.data!="string"&&(i[0]|=128),e.enqueue(i),e.enqueue(n)})}})}let Et;function qe(t){return t.reduce((e,n)=>e+n.length,0)}function Ve(t,e){if(t[0].length===e)return t.shift();const n=new Uint8Array(e);let r=0;for(let i=0;i<e;i++)n[i]=t[0][r++],r===t[0].length&&(t.shift(),r=0);return t.length&&r<t[0].length&&(t[0]=t[0].slice(r)),n}function Li(t,e){Et||(Et=new TextDecoder);const n=[];let r=0,i=-1,o=!1;return new TransformStream({transform(a,c){for(n.push(a);;){if(r===0){if(qe(n)<1)break;const d=Ve(n,1);o=(d[0]&128)===128,i=d[0]&127,i<126?r=3:i===126?r=1:r=2}else if(r===1){if(qe(n)<2)break;const d=Ve(n,2);i=new DataView(d.buffer,d.byteOffset,d.length).getUint16(0),r=3}else if(r===2){if(qe(n)<8)break;const d=Ve(n,8),p=new DataView(d.buffer,d.byteOffset,d.length),m=p.getUint32(0);if(m>Math.pow(2,21)-1){c.enqueue(wt);break}i=m*Math.pow(2,32)+p.getUint32(4),r=3}else{if(qe(n)<i)break;const d=Ve(n,i);c.enqueue(At(o?d:Et.decode(d),e)),r=0}if(i===0||i>t){c.enqueue(wt);break}}}})}const Ln=4;function D(t){if(t)return Oi(t)}function Oi(t){for(var e in D.prototype)t[e]=D.prototype[e];return t}D.prototype.on=D.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+t]=this._callbacks["$"+t]||[]).push(e),this},D.prototype.once=function(t,e){function n(){this.off(t,n),e.apply(this,arguments)}return n.fn=e,this.on(t,n),this},D.prototype.off=D.prototype.removeListener=D.prototype.removeAllListeners=D.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var n=this._callbacks["$"+t];if(!n)return this;if(arguments.length==1)return delete this._callbacks["$"+t],this;for(var r,i=0;i<n.length;i++)if(r=n[i],r===e||r.fn===e){n.splice(i,1);break}return n.length===0&&delete this._callbacks["$"+t],this},D.prototype.emit=function(t){this._callbacks=this._callbacks||{};for(var e=new Array(arguments.length-1),n=this._callbacks["$"+t],r=1;r<arguments.length;r++)e[r-1]=arguments[r];if(n){n=n.slice(0);for(var r=0,i=n.length;r<i;++r)n[r].apply(this,e)}return this},D.prototype.emitReserved=D.prototype.emit,D.prototype.listeners=function(t){return this._callbacks=this._callbacks||{},this._callbacks["$"+t]||[]},D.prototype.hasListeners=function(t){return!!this.listeners(t).length};const Z=typeof self<"u"?self:typeof window<"u"?window:Function("return this")();function On(t,...e){return e.reduce((n,r)=>(t.hasOwnProperty(r)&&(n[r]=t[r]),n),{})}const $i=Z.setTimeout,Mi=Z.clearTimeout;function We(t,e){e.useNativeTimers?(t.setTimeoutFn=$i.bind(Z),t.clearTimeoutFn=Mi.bind(Z)):(t.setTimeoutFn=Z.setTimeout.bind(Z),t.clearTimeoutFn=Z.clearTimeout.bind(Z))}const Ui=1.33;function Di(t){return typeof t=="string"?Pi(t):Math.ceil((t.byteLength||t.size)*Ui)}function Pi(t){let e=0,n=0;for(let r=0,i=t.length;r<i;r++)e=t.charCodeAt(r),e<128?n+=1:e<2048?n+=2:e<55296||e>=57344?n+=3:(r++,n+=4);return n}function Bi(t){let e="";for(let n in t)t.hasOwnProperty(n)&&(e.length&&(e+="&"),e+=encodeURIComponent(n)+"="+encodeURIComponent(t[n]));return e}function zi(t){let e={},n=t.split("&");for(let r=0,i=n.length;r<i;r++){let o=n[r].split("=");e[decodeURIComponent(o[0])]=decodeURIComponent(o[1])}return e}class Fi extends Error{constructor(e,n,r){super(e),this.description=n,this.context=r,this.type="TransportError"}}class Tt extends D{constructor(e){super(),this.writable=!1,We(this,e),this.opts=e,this.query=e.query,this.socket=e.socket}onError(e,n,r){return super.emitReserved("error",new Fi(e,n,r)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(e){this.readyState==="open"&&this.write(e)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){const n=At(e,this.socket.binaryType);this.onPacket(n)}onPacket(e){super.emitReserved("packet",e)}onClose(e){this.readyState="closed",super.emitReserved("close",e)}pause(e){}createUri(e,n={}){return e+"://"+this._hostname()+this._port()+this.opts.path+this._query(n)}_hostname(){const e=this.opts.hostname;return e.indexOf(":")===-1?e:"["+e+"]"}_port(){return this.opts.port&&(this.opts.secure&&+(this.opts.port!==443)||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(e){const n=Bi(e);return n.length?"?"+n:""}}const $n="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),St=64,ji={};let Mn=0,Ye=0,Un;function Dn(t){let e="";do e=$n[t%St]+e,t=Math.floor(t/St);while(t>0);return e}function Pn(){const t=Dn(+new Date);return t!==Un?(Mn=0,Un=t):t+"."+Dn(Mn++)}for(;Ye<St;Ye++)ji[$n[Ye]]=Ye;let Bn=!1;try{Bn=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const Hi=Bn;function zn(t){const e=t.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!e||Hi))return new XMLHttpRequest}catch{}if(!e)try{return new Z[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}function pa(){}function qi(){}const Vi=function(){return new zn({xdomain:!1}).responseType!=null}();class Wi extends Tt{constructor(e){if(super(e),this.polling=!1,typeof location<"u"){const r=location.protocol==="https:";let i=location.port;i||(i=r?"443":"80"),this.xd=typeof location<"u"&&e.hostname!==location.hostname||i!==e.port}const n=e&&e.forceBase64;this.supportsBinary=Vi&&!n,this.opts.withCredentials&&(this.cookieJar=void 0)}get name(){return"polling"}doOpen(){this.poll()}pause(e){this.readyState="pausing";const n=()=>{this.readyState="paused",e()};if(this.polling||!this.writable){let r=0;this.polling&&(r++,this.once("pollComplete",function(){--r||n()})),this.writable||(r++,this.once("drain",function(){--r||n()}))}else n()}poll(){this.polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){const n=r=>{if(this.readyState==="opening"&&r.type==="open"&&this.onOpen(),r.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(r)};Ii(e,this.socket.binaryType).forEach(n),this.readyState!=="closed"&&(this.polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this.poll())}doClose(){const e=()=>{this.write([{type:"close"}])};this.readyState==="open"?e():this.once("open",e)}write(e){this.writable=!1,Ri(e,n=>{this.doWrite(n,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const e=this.opts.secure?"https":"http",n=this.query||{};return this.opts.timestampRequests!==!1&&(n[this.opts.timestampParam]=Pn()),!this.supportsBinary&&!n.sid&&(n.b64=1),this.createUri(e,n)}request(e={}){return Object.assign(e,{xd:this.xd,cookieJar:this.cookieJar},this.opts),new ne(this.uri(),e)}doWrite(e,n){const r=this.request({method:"POST",data:e});r.on("success",n),r.on("error",(i,o)=>{this.onError("xhr post error",i,o)})}doPoll(){const e=this.request();e.on("data",this.onData.bind(this)),e.on("error",(n,r)=>{this.onError("xhr poll error",n,r)}),this.pollXhr=e}}class ne extends D{constructor(e,n){super(),We(this,n),this.opts=n,this.method=n.method||"GET",this.uri=e,this.data=n.data!==void 0?n.data:null,this.create()}create(){var e;const n=On(this.opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");n.xdomain=!!this.opts.xd;const r=this.xhr=new zn(n);try{r.open(this.method,this.uri,!0);try{if(this.opts.extraHeaders){r.setDisableHeaderCheck&&r.setDisableHeaderCheck(!0);for(let i in this.opts.extraHeaders)this.opts.extraHeaders.hasOwnProperty(i)&&r.setRequestHeader(i,this.opts.extraHeaders[i])}}catch{}if(this.method==="POST")try{r.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{r.setRequestHeader("Accept","*/*")}catch{}(e=this.opts.cookieJar)===null||e===void 0||e.addCookies(r),"withCredentials"in r&&(r.withCredentials=this.opts.withCredentials),this.opts.requestTimeout&&(r.timeout=this.opts.requestTimeout),r.onreadystatechange=()=>{var i;r.readyState===3&&((i=this.opts.cookieJar)===null||i===void 0||i.parseCookies(r)),r.readyState===4&&(r.status===200||r.status===1223?this.onLoad():this.setTimeoutFn(()=>{this.onError(typeof r.status=="number"?r.status:0)},0))},r.send(this.data)}catch(i){this.setTimeoutFn(()=>{this.onError(i)},0);return}typeof document<"u"&&(this.index=ne.requestsCount++,ne.requests[this.index]=this)}onError(e){this.emitReserved("error",e,this.xhr),this.cleanup(!0)}cleanup(e){if(!(typeof this.xhr>"u"||this.xhr===null)){if(this.xhr.onreadystatechange=qi,e)try{this.xhr.abort()}catch{}typeof document<"u"&&delete ne.requests[this.index],this.xhr=null}}onLoad(){const e=this.xhr.responseText;e!==null&&(this.emitReserved("data",e),this.emitReserved("success"),this.cleanup())}abort(){this.cleanup()}}if(ne.requestsCount=0,ne.requests={},typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",Fn);else if(typeof addEventListener=="function"){const t="onpagehide"in Z?"pagehide":"unload";addEventListener(t,Fn,!1)}}function Fn(){for(let t in ne.requests)ne.requests.hasOwnProperty(t)&&ne.requests[t].abort()}const Ct=typeof Promise=="function"&&typeof Promise.resolve=="function"?e=>Promise.resolve().then(e):(e,n)=>n(e,0),Ke=Z.WebSocket||Z.MozWebSocket,jn=!0,Yi="arraybuffer",Hn=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class Ki extends Tt{constructor(e){super(e),this.supportsBinary=!e.forceBase64}get name(){return"websocket"}doOpen(){if(!this.check())return;const e=this.uri(),n=this.opts.protocols,r=Hn?{}:On(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(r.headers=this.opts.extraHeaders);try{this.ws=jn&&!Hn?n?new Ke(e,n):new Ke(e):new Ke(e,n,r)}catch(i){return this.emitReserved("error",i)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:"websocket connection closed",context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError("websocket error",e)}write(e){this.writable=!1;for(let n=0;n<e.length;n++){const r=e[n],i=n===e.length-1;_t(r,this.supportsBinary,o=>{const a={};try{jn&&this.ws.send(o)}catch{}i&&Ct(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.close(),this.ws=null)}uri(){const e=this.opts.secure?"wss":"ws",n=this.query||{};return this.opts.timestampRequests&&(n[this.opts.timestampParam]=Pn()),this.supportsBinary||(n.b64=1),this.createUri(e,n)}check(){return!!Ke}}class Xi extends Tt{get name(){return"webtransport"}doOpen(){typeof WebTransport=="function"&&(this.transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name]),this.transport.closed.then(()=>{this.onClose()}).catch(e=>{this.onError("webtransport error",e)}),this.transport.ready.then(()=>{this.transport.createBidirectionalStream().then(e=>{const n=Li(Number.MAX_SAFE_INTEGER,this.socket.binaryType),r=e.readable.pipeThrough(n).getReader(),i=Ni();i.readable.pipeTo(e.writable),this.writer=i.writable.getWriter();const o=()=>{r.read().then(({done:c,value:d})=>{c||(this.onPacket(d),o())}).catch(c=>{})};o();const a={type:"open"};this.query.sid&&(a.data=`{"sid":"${this.query.sid}"}`),this.writer.write(a).then(()=>this.onOpen())})}))}write(e){this.writable=!1;for(let n=0;n<e.length;n++){const r=e[n],i=n===e.length-1;this.writer.write(r).then(()=>{i&&Ct(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var e;(e=this.transport)===null||e===void 0||e.close()}}const Ji={websocket:Ki,webtransport:Xi,polling:Wi},Zi=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,Gi=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function Rt(t){if(t.length>2e3)throw"URI too long";const e=t,n=t.indexOf("["),r=t.indexOf("]");n!=-1&&r!=-1&&(t=t.substring(0,n)+t.substring(n,r).replace(/:/g,";")+t.substring(r,t.length));let i=Zi.exec(t||""),o={},a=14;for(;a--;)o[Gi[a]]=i[a]||"";return n!=-1&&r!=-1&&(o.source=e,o.host=o.host.substring(1,o.host.length-1).replace(/;/g,":"),o.authority=o.authority.replace("[","").replace("]","").replace(/;/g,":"),o.ipv6uri=!0),o.pathNames=Qi(o,o.path),o.queryKey=eo(o,o.query),o}function Qi(t,e){const n=/\/{2,9}/g,r=e.replace(n,"/").split("/");return(e.slice(0,1)=="/"||e.length===0)&&r.splice(0,1),e.slice(-1)=="/"&&r.splice(r.length-1,1),r}function eo(t,e){const n={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(r,i,o){i&&(n[i]=o)}),n}let qn=class Ae extends D{constructor(e,n={}){super(),this.binaryType=Yi,this.writeBuffer=[],e&&typeof e=="object"&&(n=e,e=null),e?(e=Rt(e),n.hostname=e.host,n.secure=e.protocol==="https"||e.protocol==="wss",n.port=e.port,e.query&&(n.query=e.query)):n.host&&(n.hostname=Rt(n.host).host),We(this,n),this.secure=n.secure!=null?n.secure:typeof location<"u"&&location.protocol==="https:",n.hostname&&!n.port&&(n.port=this.secure?"443":"80"),this.hostname=n.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=n.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=n.transports||["polling","websocket","webtransport"],this.writeBuffer=[],this.prevBufferLen=0,this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},n),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=zi(this.opts.query)),this.id=null,this.upgrades=null,this.pingInterval=null,this.pingTimeout=null,this.pingTimeoutTimer=null,typeof addEventListener=="function"&&(this.opts.closeOnBeforeunload&&(this.beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this.beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this.offlineEventListener=()=>{this.onClose("transport close",{description:"network connection lost"})},addEventListener("offline",this.offlineEventListener,!1))),this.open()}createTransport(e){const n=Object.assign({},this.opts.query);n.EIO=Ln,n.transport=e,this.id&&(n.sid=this.id);const r=Object.assign({},this.opts,{query:n,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return new Ji[e](r)}open(){let e;if(this.opts.rememberUpgrade&&Ae.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1)e="websocket";else if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}else e=this.transports[0];this.readyState="opening";try{e=this.createTransport(e)}catch{this.transports.shift(),this.open();return}e.open(),this.setTransport(e)}setTransport(e){this.transport&&this.transport.removeAllListeners(),this.transport=e,e.on("drain",this.onDrain.bind(this)).on("packet",this.onPacket.bind(this)).on("error",this.onError.bind(this)).on("close",n=>this.onClose("transport close",n))}probe(e){let n=this.createTransport(e),r=!1;Ae.priorWebsocketSuccess=!1;const i=()=>{r||(n.send([{type:"ping",data:"probe"}]),n.once("packet",u=>{if(!r)if(u.type==="pong"&&u.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",n),!n)return;Ae.priorWebsocketSuccess=n.name==="websocket",this.transport.pause(()=>{r||this.readyState!=="closed"&&(m(),this.setTransport(n),n.send([{type:"upgrade"}]),this.emitReserved("upgrade",n),n=null,this.upgrading=!1,this.flush())})}else{const h=new Error("probe error");h.transport=n.name,this.emitReserved("upgradeError",h)}}))};function o(){r||(r=!0,m(),n.close(),n=null)}const a=u=>{const h=new Error("probe error: "+u);h.transport=n.name,o(),this.emitReserved("upgradeError",h)};function c(){a("transport closed")}function d(){a("socket closed")}function p(u){n&&u.name!==n.name&&o()}const m=()=>{n.removeListener("open",i),n.removeListener("error",a),n.removeListener("close",c),this.off("close",d),this.off("upgrading",p)};n.once("open",i),n.once("error",a),n.once("close",c),this.once("close",d),this.once("upgrading",p),this.upgrades.indexOf("webtransport")!==-1&&e!=="webtransport"?this.setTimeoutFn(()=>{r||n.open()},200):n.open()}onOpen(){if(this.readyState="open",Ae.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush(),this.readyState==="open"&&this.opts.upgrade){let e=0;const n=this.upgrades.length;for(;e<n;e++)this.probe(this.upgrades[e])}}onPacket(e){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",e),this.emitReserved("heartbeat"),this.resetPingTimeout(),e.type){case"open":this.onHandshake(JSON.parse(e.data));break;case"ping":this.sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong");break;case"error":const n=new Error("server error");n.code=e.data,this.onError(n);break;case"message":this.emitReserved("data",e.data),this.emitReserved("message",e.data);break}}onHandshake(e){this.emitReserved("handshake",e),this.id=e.sid,this.transport.query.sid=e.sid,this.upgrades=this.filterUpgrades(e.upgrades),this.pingInterval=e.pingInterval,this.pingTimeout=e.pingTimeout,this.maxPayload=e.maxPayload,this.onOpen(),this.readyState!=="closed"&&this.resetPingTimeout()}resetPingTimeout(){this.clearTimeoutFn(this.pingTimeoutTimer),this.pingTimeoutTimer=this.setTimeoutFn(()=>{this.onClose("ping timeout")},this.pingInterval+this.pingTimeout),this.opts.autoUnref&&this.pingTimeoutTimer.unref()}onDrain(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const e=this.getWritablePackets();this.transport.send(e),this.prevBufferLen=e.length,this.emitReserved("flush")}}getWritablePackets(){if(!(this.maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let n=1;for(let r=0;r<this.writeBuffer.length;r++){const i=this.writeBuffer[r].data;if(i&&(n+=Di(i)),r>0&&n>this.maxPayload)return this.writeBuffer.slice(0,r);n+=2}return this.writeBuffer}write(e,n,r){return this.sendPacket("message",e,n,r),this}send(e,n,r){return this.sendPacket("message",e,n,r),this}sendPacket(e,n,r,i){if(typeof n=="function"&&(i=n,n=void 0),typeof r=="function"&&(i=r,r=null),this.readyState==="closing"||this.readyState==="closed")return;r=r||{},r.compress=r.compress!==!1;const o={type:e,data:n,options:r};this.emitReserved("packetCreate",o),this.writeBuffer.push(o),i&&this.once("flush",i),this.flush()}close(){const e=()=>{this.onClose("forced close"),this.transport.close()},n=()=>{this.off("upgrade",n),this.off("upgradeError",n),e()},r=()=>{this.once("upgrade",n),this.once("upgradeError",n)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?r():e()}):this.upgrading?r():e()),this}onError(e){Ae.priorWebsocketSuccess=!1,this.emitReserved("error",e),this.onClose("transport error",e)}onClose(e,n){(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")&&(this.clearTimeoutFn(this.pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),typeof removeEventListener=="function"&&(removeEventListener("beforeunload",this.beforeunloadEventListener,!1),removeEventListener("offline",this.offlineEventListener,!1)),this.readyState="closed",this.id=null,this.emitReserved("close",e,n),this.writeBuffer=[],this.prevBufferLen=0)}filterUpgrades(e){const n=[];let r=0;const i=e.length;for(;r<i;r++)~this.transports.indexOf(e[r])&&n.push(e[r]);return n}};qn.protocol=Ln;function to(t,e="",n){let r=t;n=n||typeof location<"u"&&location,t==null&&(t=n.protocol+"//"+n.host),typeof t=="string"&&(t.charAt(0)==="/"&&(t.charAt(1)==="/"?t=n.protocol+t:t=n.host+t),/^(https?|wss?):\/\//.test(t)||(typeof n<"u"?t=n.protocol+"//"+t:t="https://"+t),r=Rt(t)),r.port||(/^(http|ws)$/.test(r.protocol)?r.port="80":/^(http|ws)s$/.test(r.protocol)&&(r.port="443")),r.path=r.path||"/";const o=r.host.indexOf(":")!==-1?"["+r.host+"]":r.host;return r.id=r.protocol+"://"+o+":"+r.port+e,r.href=r.protocol+"://"+o+(n&&n.port===r.port?"":":"+r.port),r}const no=typeof ArrayBuffer=="function",ro=t=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(t):t.buffer instanceof ArrayBuffer,Vn=Object.prototype.toString,io=typeof Blob=="function"||typeof Blob<"u"&&Vn.call(Blob)==="[object BlobConstructor]",oo=typeof File=="function"||typeof File<"u"&&Vn.call(File)==="[object FileConstructor]";function It(t){return no&&(t instanceof ArrayBuffer||ro(t))||io&&t instanceof Blob||oo&&t instanceof File}function Xe(t,e){if(!t||typeof t!="object")return!1;if(Array.isArray(t)){for(let n=0,r=t.length;n<r;n++)if(Xe(t[n]))return!0;return!1}if(It(t))return!0;if(t.toJSON&&typeof t.toJSON=="function"&&arguments.length===1)return Xe(t.toJSON(),!0);for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&Xe(t[n]))return!0;return!1}function so(t){const e=[],n=t.data,r=t;return r.data=Nt(n,e),r.attachments=e.length,{packet:r,buffers:e}}function Nt(t,e){if(!t)return t;if(It(t)){const n={_placeholder:!0,num:e.length};return e.push(t),n}else if(Array.isArray(t)){const n=new Array(t.length);for(let r=0;r<t.length;r++)n[r]=Nt(t[r],e);return n}else if(typeof t=="object"&&!(t instanceof Date)){const n={};for(const r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=Nt(t[r],e));return n}return t}function ao(t,e){return t.data=Lt(t.data,e),delete t.attachments,t}function Lt(t,e){if(!t)return t;if(t&&t._placeholder===!0){if(typeof t.num=="number"&&t.num>=0&&t.num<e.length)return e[t.num];throw new Error("illegal attachments")}else if(Array.isArray(t))for(let n=0;n<t.length;n++)t[n]=Lt(t[n],e);else if(typeof t=="object")for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&(t[n]=Lt(t[n],e));return t}const co=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],lo=5;var C;(function(t){t[t.CONNECT=0]="CONNECT",t[t.DISCONNECT=1]="DISCONNECT",t[t.EVENT=2]="EVENT",t[t.ACK=3]="ACK",t[t.CONNECT_ERROR=4]="CONNECT_ERROR",t[t.BINARY_EVENT=5]="BINARY_EVENT",t[t.BINARY_ACK=6]="BINARY_ACK"})(C||(C={}));class uo{constructor(e){this.replacer=e}encode(e){return(e.type===C.EVENT||e.type===C.ACK)&&Xe(e)?this.encodeAsBinary({type:e.type===C.EVENT?C.BINARY_EVENT:C.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):[this.encodeAsString(e)]}encodeAsString(e){let n=""+e.type;return(e.type===C.BINARY_EVENT||e.type===C.BINARY_ACK)&&(n+=e.attachments+"-"),e.nsp&&e.nsp!=="/"&&(n+=e.nsp+","),e.id!=null&&(n+=e.id),e.data!=null&&(n+=JSON.stringify(e.data,this.replacer)),n}encodeAsBinary(e){const n=so(e),r=this.encodeAsString(n.packet),i=n.buffers;return i.unshift(r),i}}function Wn(t){return Object.prototype.toString.call(t)==="[object Object]"}class Ot extends D{constructor(e){super(),this.reviver=e}add(e){let n;if(typeof e=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");n=this.decodeString(e);const r=n.type===C.BINARY_EVENT;r||n.type===C.BINARY_ACK?(n.type=r?C.EVENT:C.ACK,this.reconstructor=new po(n),n.attachments===0&&super.emitReserved("decoded",n)):super.emitReserved("decoded",n)}else if(It(e)||e.base64)if(this.reconstructor)n=this.reconstructor.takeBinaryData(e),n&&(this.reconstructor=null,super.emitReserved("decoded",n));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+e)}decodeString(e){let n=0;const r={type:Number(e.charAt(0))};if(C[r.type]===void 0)throw new Error("unknown packet type "+r.type);if(r.type===C.BINARY_EVENT||r.type===C.BINARY_ACK){const o=n+1;for(;e.charAt(++n)!=="-"&&n!=e.length;);const a=e.substring(o,n);if(a!=Number(a)||e.charAt(n)!=="-")throw new Error("Illegal attachments");r.attachments=Number(a)}if(e.charAt(n+1)==="/"){const o=n+1;for(;++n&&!(e.charAt(n)===","||n===e.length););r.nsp=e.substring(o,n)}else r.nsp="/";const i=e.charAt(n+1);if(i!==""&&Number(i)==i){const o=n+1;for(;++n;){const a=e.charAt(n);if(a==null||Number(a)!=a){--n;break}if(n===e.length)break}r.id=Number(e.substring(o,n+1))}if(e.charAt(++n)){const o=this.tryParse(e.substr(n));if(Ot.isPayloadValid(r.type,o))r.data=o;else throw new Error("invalid payload")}return r}tryParse(e){try{return JSON.parse(e,this.reviver)}catch{return!1}}static isPayloadValid(e,n){switch(e){case C.CONNECT:return Wn(n);case C.DISCONNECT:return n===void 0;case C.CONNECT_ERROR:return typeof n=="string"||Wn(n);case C.EVENT:case C.BINARY_EVENT:return Array.isArray(n)&&(typeof n[0]=="number"||typeof n[0]=="string"&&co.indexOf(n[0])===-1);case C.ACK:case C.BINARY_ACK:return Array.isArray(n)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class po{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){const n=ao(this.reconPack,this.buffers);return this.finishedReconstruction(),n}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const fo=Object.freeze(Object.defineProperty({__proto__:null,Decoder:Ot,Encoder:uo,get PacketType(){return C},protocol:lo},Symbol.toStringTag,{value:"Module"}));function ee(t,e,n){return t.on(e,n),function(){t.off(e,n)}}const ho=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class Yn extends D{constructor(e,n,r){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=n,r&&r.auth&&(this.auth=r.auth),this._opts=Object.assign({},r),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const e=this.io;this.subs=[ee(e,"open",this.onopen.bind(this)),ee(e,"packet",this.onpacket.bind(this)),ee(e,"error",this.onerror.bind(this)),ee(e,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...e){return e.unshift("message"),this.emit.apply(this,e),this}emit(e,...n){if(ho.hasOwnProperty(e))throw new Error('"'+e.toString()+'" is a reserved event name');if(n.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(n),this;const r={type:C.EVENT,data:n};if(r.options={},r.options.compress=this.flags.compress!==!1,typeof n[n.length-1]=="function"){const a=this.ids++,c=n.pop();this._registerAckCallback(a,c),r.id=a}const i=this.io.engine&&this.io.engine.transport&&this.io.engine.transport.writable;return this.flags.volatile&&(!i||!this.connected)||(this.connected?(this.notifyOutgoingListeners(r),this.packet(r)):this.sendBuffer.push(r)),this.flags={},this}_registerAckCallback(e,n){var r;const i=(r=this.flags.timeout)!==null&&r!==void 0?r:this._opts.ackTimeout;if(i===void 0){this.acks[e]=n;return}const o=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let c=0;c<this.sendBuffer.length;c++)this.sendBuffer[c].id===e&&this.sendBuffer.splice(c,1);n.call(this,new Error("operation has timed out"))},i),a=(...c)=>{this.io.clearTimeoutFn(o),n.apply(this,c)};a.withError=!0,this.acks[e]=a}emitWithAck(e,...n){return new Promise((r,i)=>{const o=(a,c)=>a?i(a):r(c);o.withError=!0,n.push(o),this.emit(e,...n)})}_addToQueue(e){let n;typeof e[e.length-1]=="function"&&(n=e.pop());const r={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((i,...o)=>r!==this._queue[0]?void 0:(i!==null?r.tryCount>this._opts.retries&&(this._queue.shift(),n&&n(i)):(this._queue.shift(),n&&n(null,...o)),r.pending=!1,this._drainQueue())),this._queue.push(r),this._drainQueue()}_drainQueue(e=!1){if(!this.connected||this._queue.length===0)return;const n=this._queue[0];n.pending&&!e||(n.pending=!0,n.tryCount++,this.flags=n.flags,this.emit.apply(this,n.args))}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){typeof this.auth=="function"?this.auth(e=>{this._sendConnectPacket(e)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:C.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved("connect_error",e)}onclose(e,n){this.connected=!1,delete this.id,this.emitReserved("disconnect",e,n),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(e=>{if(!this.sendBuffer.some(r=>String(r.id)===e)){const r=this.acks[e];delete this.acks[e],r.withError&&r.call(this,new Error("socket has been disconnected"))}})}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case C.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case C.EVENT:case C.BINARY_EVENT:this.onevent(e);break;case C.ACK:case C.BINARY_ACK:this.onack(e);break;case C.DISCONNECT:this.ondisconnect();break;case C.CONNECT_ERROR:this.destroy();const r=new Error(e.data.message);r.data=e.data.data,this.emitReserved("connect_error",r);break}}onevent(e){const n=e.data||[];e.id!=null&&n.push(this.ack(e.id)),this.connected?this.emitEvent(n):this.receiveBuffer.push(Object.freeze(n))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){const n=this._anyListeners.slice();for(const r of n)r.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&typeof e[e.length-1]=="string"&&(this._lastOffset=e[e.length-1])}ack(e){const n=this;let r=!1;return function(...i){r||(r=!0,n.packet({type:C.ACK,id:e,data:i}))}}onack(e){const n=this.acks[e.id];typeof n=="function"&&(delete this.acks[e.id],n.withError&&e.data.unshift(null),n.apply(this,e.data))}onconnect(e,n){this.id=e,this.recovered=n&&this._pid===n,this._pid=n,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach(e=>this.emitEvent(e)),this.receiveBuffer=[],this.sendBuffer.forEach(e=>{this.notifyOutgoingListeners(e),this.packet(e)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(e=>e()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:C.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){const n=this._anyListeners;for(let r=0;r<n.length;r++)if(e===n[r])return n.splice(r,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){const n=this._anyOutgoingListeners;for(let r=0;r<n.length;r++)if(e===n[r])return n.splice(r,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const n=this._anyOutgoingListeners.slice();for(const r of n)r.apply(this,e.data)}}}function ye(t){t=t||{},this.ms=t.min||100,this.max=t.max||1e4,this.factor=t.factor||2,this.jitter=t.jitter>0&&t.jitter<=1?t.jitter:0,this.attempts=0}ye.prototype.duration=function(){var t=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var e=Math.random(),n=Math.floor(e*this.jitter*t);t=Math.floor(e*10)&1?t+n:t-n}return Math.min(t,this.max)|0},ye.prototype.reset=function(){this.attempts=0},ye.prototype.setMin=function(t){this.ms=t},ye.prototype.setMax=function(t){this.max=t},ye.prototype.setJitter=function(t){this.jitter=t};class $t extends D{constructor(e,n){var r;super(),this.nsps={},this.subs=[],e&&typeof e=="object"&&(n=e,e=void 0),n=n||{},n.path=n.path||"/socket.io",this.opts=n,We(this,n),this.reconnection(n.reconnection!==!1),this.reconnectionAttempts(n.reconnectionAttempts||1/0),this.reconnectionDelay(n.reconnectionDelay||1e3),this.reconnectionDelayMax(n.reconnectionDelayMax||5e3),this.randomizationFactor((r=n.randomizationFactor)!==null&&r!==void 0?r:.5),this.backoff=new ye({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(n.timeout==null?2e4:n.timeout),this._readyState="closed",this.uri=e;const i=n.parser||fo;this.encoder=new i.Encoder,this.decoder=new i.Decoder,this._autoConnect=n.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,this):this._reconnection}reconnectionAttempts(e){return e===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var n;return e===void 0?this._reconnectionDelay:(this._reconnectionDelay=e,(n=this.backoff)===null||n===void 0||n.setMin(e),this)}randomizationFactor(e){var n;return e===void 0?this._randomizationFactor:(this._randomizationFactor=e,(n=this.backoff)===null||n===void 0||n.setJitter(e),this)}reconnectionDelayMax(e){var n;return e===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,(n=this.backoff)===null||n===void 0||n.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(e){if(~this._readyState.indexOf("open"))return this;this.engine=new qn(this.uri,this.opts);const n=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;const i=ee(n,"open",function(){r.onopen(),e&&e()}),o=c=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",c),e?e(c):this.maybeReconnectOnOpen()},a=ee(n,"error",o);if(this._timeout!==!1){const c=this._timeout,d=this.setTimeoutFn(()=>{i(),o(new Error("timeout")),n.close()},c);this.opts.autoUnref&&d.unref(),this.subs.push(()=>{this.clearTimeoutFn(d)})}return this.subs.push(i),this.subs.push(a),this}connect(e){return this.open(e)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const e=this.engine;this.subs.push(ee(e,"ping",this.onping.bind(this)),ee(e,"data",this.ondata.bind(this)),ee(e,"error",this.onerror.bind(this)),ee(e,"close",this.onclose.bind(this)),ee(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(e){try{this.decoder.add(e)}catch(n){this.onclose("parse error",n)}}ondecoded(e){Ct(()=>{this.emitReserved("packet",e)},this.setTimeoutFn)}onerror(e){this.emitReserved("error",e)}socket(e,n){let r=this.nsps[e];return r?this._autoConnect&&!r.active&&r.connect():(r=new Yn(this,e,n),this.nsps[e]=r),r}_destroy(e){const n=Object.keys(this.nsps);for(const r of n)if(this.nsps[r].active)return;this._close()}_packet(e){const n=this.encoder.encode(e);for(let r=0;r<n.length;r++)this.engine.write(n[r],e.options)}cleanup(){this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close"),this.engine&&this.engine.close()}disconnect(){return this._close()}onclose(e,n){this.cleanup(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",e,n),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const e=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const n=this.backoff.duration();this._reconnecting=!0;const r=this.setTimeoutFn(()=>{e.skipReconnect||(this.emitReserved("reconnect_attempt",e.backoff.attempts),!e.skipReconnect&&e.open(i=>{i?(e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",i)):e.onreconnect()}))},n);this.opts.autoUnref&&r.unref(),this.subs.push(()=>{this.clearTimeoutFn(r)})}}onreconnect(){const e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}}const Se={};function Je(t,e){typeof t=="object"&&(e=t,t=void 0),e=e||{};const n=to(t,e.path||"/socket.io"),r=n.source,i=n.id,o=n.path,a=Se[i]&&o in Se[i].nsps,c=e.forceNew||e["force new connection"]||e.multiplex===!1||a;let d;return c?d=new $t(r,e):(Se[i]||(Se[i]=new $t(r,e)),d=Se[i]),n.query&&!e.query&&(e.query=n.queryKey),d.socket(n.path,e)}Object.assign(Je,{Manager:$t,Socket:Yn,io:Je,connect:Je});const go=["new-support-message","updated-support-message","deleted-support-message","new-customer-message","thread-closed","thread-reopened","thread-assigned","thread-reassigned","support-typing","presence-updated","conversations-paused"];function mo(t,e,n){const r=Je(t,{path:"/socket"});let i=!1,o=0,a;for(const c of go)r.on(c,d=>n.event(c,d));return r.on("connect",()=>{o=0;const c=xt();r.emit("identify",{jwt:e,...c?{pageUrl:c}:{}}),n.status(!0)}),r.on("disconnect",c=>{n.status(!1),c==="io server disconnect"&&!i&&(a=setTimeout(()=>r.connect(),Math.min(3e4,1e3*2**o++)))}),r.on("connect_error",()=>n.status(!1)),r.on("error",c=>{c?.message==="Invalid token"&&n.invalidToken()}),{close(){i=!0,clearTimeout(a),r.removeAllListeners(),r.disconnect()}}}const vo="Customer support";function Kn(t){const e=t;return!e?.displayName||e.displayName===vo?null:{displayName:e.displayName,displayAvatarURL:e.displayAvatarURL??"",status:e.status??"offline"}}function yo(t){let e=5381;for(let n=0;n<t.length;n++)e=(e<<5)+e+t.charCodeAt(n)|0;return(e>>>0).toString(36)}function Xn(t){return t.id?`id:${t.id}`:`d:${t.date}:${t.support?"s":"c"}:${yo(t.content??"")}:${t.attachments?.length??0}`}function Ze(t,e){const n=Xn(t);return{key:e.get(n)??n,sid:n,from:t.support?"agent":"me",authorName:t.authorName??"",...t.authorAvatarURL?{authorAvatarURL:t.authorAvatarURL}:{},text:t.content??"",date:Number(t.date),attachments:Array.isArray(t.attachments)?t.attachments:[],emojis:t.emojis??{}}}const Jn=(t,e)=>t.date-e.date;function Zn(t,e){return{threadId:t,status:"open",csMember:null,messages:[],lastMessageDate:e}}function Gn(t,e){const n=new Set,r=[];for(const i of t.messages??[]){if(!Number.isFinite(Number(i?.date)))continue;const o=Ze(i,e);n.has(o.sid)||(n.add(o.sid),r.push(o))}return r.sort(Jn),{threadId:t.threadId,status:t.status==="closed"?"closed":"open",csMember:Kn(t.csMember),messages:r,lastMessageDate:r[r.length-1]?.date??(Number(t.lastMessageDate)||Date.now())}}function Qn(t,e){const n=t.messages.findIndex(i=>i.sid===e.sid),r=n===-1?[...t.messages,e].sort(Jn):t.messages.map((i,o)=>o===n?{...e,key:i.key}:i);return{...t,messages:r,lastMessageDate:Math.max(t.lastMessageDate,e.date)}}function er(t,e,n){if(e){const r=t.messages.find(i=>i.sid===`id:${e}`);if(r)return r}return t.messages.find(r=>r.from==="agent"&&r.date===n)}function tr(t,e,n){return{...t,messages:t.messages.map(r=>r.sid===e?{...r,...n}:r)}}function bo(t,e){return{...t,messages:t.messages.filter(n=>n.sid!==e)}}function Ge(t,e){let n=!1;const r={...t};for(const i of Object.values(t))i.status==="open"&&i.threadId!==e&&(r[i.threadId]={...i,status:"closed"},n=!0);return n?r:t}function nr(t){return Object.values(t).sort((e,n)=>n.lastMessageDate-e.lastMessageDate)}function Qe(t){return nr(t).find(e=>e.status==="open")??null}function et(t){return t.guild.acceptingConversations!==!1}function rr(t){return et(t)||t.open||Qe(t.conversations)!==null}function xo(t){if(!t)return 0;for(let e=t.messages.length-1;e>=0;e--)if(t.messages[e].from==="agent")return t.messages[e].date;return 0}function ir(t,e){const n=Qe(t);return n?n.messages.filter(r=>r.from==="agent"&&!r.deleted&&r.date>e).length:0}function wo(t,e){const n=t.messages.filter(r=>r.from==="agent").map(r=>r.date).sort((r,i)=>i-r);return e<=0?n[0]??0:e>=n.length?0:n[e]}function _o(t){for(let e=t.messages.length-1;e>=0;e--)if(t.messages[e].from==="agent"&&t.messages[e].authorName)return t.messages[e].authorName;return null}function or(t){try{const e=localStorage.getItem(t);return e?JSON.parse(e):null}catch{return null}}function ko(t,e){try{localStorage.setItem(t,JSON.stringify(e))}catch{}}function Mt(t){try{localStorage.removeItem(t)}catch{}}function Ao(t){try{const e=document.cookie.split("; ").find(n=>n.startsWith(`${t}=`));return e?decodeURIComponent(e.slice(t.length+1)):null}catch{return null}}function Eo(t){try{document.cookie=`${t}=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/`}catch{}}const sr={name:"",email:"",avatarUrl:"",verifiedUserId:null,metadata:null};function To(){return{boot:"loading",activeAt:null,guild:{},dark:!1,open:!1,view:"chat",nav:0,navPrev:null,activeThreadId:null,identity:sr,token:null,conversations:{},synced:!1,past:"idle",outbox:[],tray:[],typing:{},connection:"off",lastReadAt:0,events:{},preview:null,lightbox:null,notice:null}}const So=30,ar=200,Ut=t=>`deskcord:${t}`,q=t=>typeof t=="string",Ce=t=>typeof t=="number"&&Number.isFinite(t);function Co(t){return!t||!q(t.sid)||!q(t.key)||!Ce(t.date)?null:{key:t.key,sid:t.sid,from:t.from==="me"?"me":"agent",authorName:q(t.authorName)?t.authorName:"",...q(t.authorAvatarURL)?{authorAvatarURL:t.authorAvatarURL}:{},text:q(t.text)?t.text:"",date:t.date,attachments:Array.isArray(t.attachments)?t.attachments:[],emojis:t.emojis&&typeof t.emojis=="object"?t.emojis:{},...t.edited?{edited:!0}:{}}}function Ro(t){if(!t||!q(t.threadId)||!t.threadId)return null;const e=(Array.isArray(t.messages)?t.messages:[]).map(Co).filter(n=>!!n).slice(-ar);return{threadId:t.threadId,status:t.status==="open"?"open":"closed",csMember:t.csMember??null,messages:e,lastMessageDate:Ce(t.lastMessageDate)?t.lastMessageDate:e[e.length-1]?.date??0}}function cr(t){return{name:q(t?.name)?t.name:"",email:q(t?.email)?t.email:"",avatarUrl:q(t?.avatarUrl)?t.avatarUrl:"",verifiedUserId:q(t?.verifiedUserId)?t.verifiedUserId:null,metadata:kn(t?.metadata,()=>{})}}function Io(){const t=or("discord-widget-storage"),e=Ao("discord-widget");if(!t&&!e)return null;const n=t?.state??{},r=e||(q(n.token)&&n.token?n.token:null);return Mt("discord-widget-storage"),Mt("deskcord_last_read"),Mt("deskcord_unread_count"),Eo("discord-widget"),{token:r,identity:cr({name:n.username,email:n.email,avatarUrl:n.avatarUrl,verifiedUserId:n.verifiedUserId}),conversations:{},lastReadAt:0,guild:{},activeAt:null,outbox:[]}}function lr(t){const e=or(Ut(t));if(!e||e.v!==1)return Io();const n={};for(const i of Array.isArray(e.conversations)?e.conversations:[]){const o=Ro(i);o&&(n[o.threadId]=o)}const r=(Array.isArray(e.outbox)?e.outbox:[]).filter(i=>q(i?.localId)&&q(i?.text)&&i.text).map(i=>({localId:i.localId,text:i.text,state:i.state==="held"||i.state==="queued"?i.state:"failed",progress:0,attempts:0,createdAt:Ce(i.createdAt)?i.createdAt:Date.now()}));return{token:q(e.token)&&e.token?e.token:null,identity:cr(e.identity),conversations:n,lastReadAt:Ce(e.lastReadAt)?e.lastReadAt:0,guild:e.guild&&typeof e.guild=="object"?e.guild:{},activeAt:Ce(e.activeAt)?e.activeAt:null,outbox:r}}function No(t,e){const n=Object.values(e.conversations).sort((i,o)=>o.lastMessageDate-i.lastMessageDate).slice(0,So).map(i=>({...i,messages:i.messages.filter(o=>!o.deleted).slice(-ar)})),r={v:1,token:e.token,identity:e.identity,conversations:n,lastReadAt:e.lastReadAt,guild:e.guild,activeAt:e.activeAt,outbox:e.outbox.filter(i=>!i.file&&i.text).map(({localId:i,text:o,state:a,createdAt:c})=>({localId:i,text:o,state:a,createdAt:c}))};ko(Ut(t),r)}var de,$,Dt,dr,tt=0,ur=[],U=N,pr=U.__b,fr=U.__r,hr=U.diffed,gr=U.__c,mr=U.unmount,vr=U.__;function Re(t,e){U.__h&&U.__h($,t,tt||e),tt=0;var n=$.__H||($.__H={__:[],__h:[]});return t>=n.__.length&&n.__.push({}),n.__[t]}function z(t){return tt=1,yr(wr,t)}function yr(t,e,n){var r=Re(de++,2);if(r.t=t,!r.__c&&(r.__=[wr(void 0,e),function(c){var d=r.__N?r.__N[0]:r.__[0],p=r.t(d,c);d!==p&&(r.__N=[p,r.__[1]],r.__c.setState({}))}],r.__c=$,!$.u)){var i=function(c,d,p){if(!r.__c.__H)return!0;var m=r.__c.__H.__.filter(function(h){return!!h.__c});if(m.every(function(h){return!h.__N}))return!o||o.call(this,c,d,p);var u=r.__c.props!==c;return m.forEach(function(h){if(h.__N){var w=h.__[0];h.__=h.__N,h.__N=void 0,w!==h.__[0]&&(u=!0)}}),o&&o.call(this,c,d,p)||u};$.u=!0;var o=$.shouldComponentUpdate,a=$.componentWillUpdate;$.componentWillUpdate=function(c,d,p){if(this.__e){var m=o;o=void 0,i(c,d,p),o=m}a&&a.call(this,c,d,p)},$.shouldComponentUpdate=i}return r.__N||r.__}function ue(t,e){var n=Re(de++,3);!U.__s&&Bt(n.__H,e)&&(n.__=t,n.i=e,$.__H.__h.push(n))}function L(t,e){var n=Re(de++,4);!U.__s&&Bt(n.__H,e)&&(n.__=t,n.i=e,$.__h.push(n))}function A(t){return tt=5,nt(function(){return{current:t}},[])}function nt(t,e){var n=Re(de++,7);return Bt(n.__H,e)&&(n.__=t(),n.__H=e,n.__h=t),n.__}function br(t){var e=$.context[t.__c],n=Re(de++,9);return n.c=t,e?(n.__==null&&(n.__=!0,e.sub($)),e.props.value):t.__}function Lo(){for(var t;t=ur.shift();)if(t.__P&&t.__H)try{t.__H.__h.forEach(rt),t.__H.__h.forEach(Pt),t.__H.__h=[]}catch(e){t.__H.__h=[],U.__e(e,t.__v)}}U.__b=function(t){$=null,pr&&pr(t)},U.__=function(t,e){t&&e.__k&&e.__k.__m&&(t.__m=e.__k.__m),vr&&vr(t,e)},U.__r=function(t){fr&&fr(t),de=0;var e=($=t.__c).__H;e&&(Dt===$?(e.__h=[],$.__h=[],e.__.forEach(function(n){n.__N&&(n.__=n.__N),n.i=n.__N=void 0})):(e.__h.forEach(rt),e.__h.forEach(Pt),e.__h=[],de=0)),Dt=$},U.diffed=function(t){hr&&hr(t);var e=t.__c;e&&e.__H&&(e.__H.__h.length&&(ur.push(e)!==1&&dr===U.requestAnimationFrame||((dr=U.requestAnimationFrame)||Oo)(Lo)),e.__H.__.forEach(function(n){n.i&&(n.__H=n.i),n.i=void 0})),Dt=$=null},U.__c=function(t,e){e.some(function(n){try{n.__h.forEach(rt),n.__h=n.__h.filter(function(r){return!r.__||Pt(r)})}catch(r){e.some(function(i){i.__h&&(i.__h=[])}),e=[],U.__e(r,n.__v)}}),gr&&gr(t,e)},U.unmount=function(t){mr&&mr(t);var e,n=t.__c;n&&n.__H&&(n.__H.__.forEach(function(r){try{rt(r)}catch(i){e=i}}),n.__H=void 0,e&&U.__e(e,n.__v))};var xr=typeof requestAnimationFrame=="function";function Oo(t){var e,n=function(){clearTimeout(r),xr&&cancelAnimationFrame(e),setTimeout(t)},r=setTimeout(n,100);xr&&(e=requestAnimationFrame(n))}function rt(t){var e=$,n=t.__c;typeof n=="function"&&(t.__c=void 0,n()),$=e}function Pt(t){var e=$;t.__c=t.__(),$=e}function Bt(t,e){return!t||t.length!==e.length||e.some(function(n,r){return n!==t[r]})}function wr(t,e){return typeof e=="function"?e(t):e}function $o(t){let e=t;const n=new Set;return{get:()=>e,set(r){const i=typeof r=="function"?r(e):r;e={...e,...i},n.forEach(o=>o())},subscribe(r){return n.add(r),()=>n.delete(r)}}}function Mo(t,e){if(Object.is(t,e))return!0;if(typeof t!="object"||typeof e!="object"||t===null||e===null||Array.isArray(t)!==Array.isArray(e))return!1;const n=Object.keys(t);return n.length!==Object.keys(e).length?!1:n.every(r=>Object.is(t[r],e[r]))}function Uo(t,e,n=Mo){const[,r]=yr(c=>c+1,0),i=A(e);i.current=e;const o=e(t.get()),a=A(o);return a.current=o,L(()=>{const c=()=>{n(i.current(t.get()),a.current)||r(0)},d=t.subscribe(c);return c(),d},[t,n]),o}const _r=["image/png","image/jpeg","image/gif","image/webp","application/pdf"],Do=10*1024*1024,kr=10,be=2e3,Po=8e3,Bo=12*60*60*1e3,zo=5*60*1e3,Fo=/^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/,Ar=256,jo=2048,Er=t=>Fo.test(t.trim()),zt=t=>`${t}${Date.now().toString(36)}${Math.random().toString(36).slice(2,8)}`,Ho=()=>document.visibilityState==="visible"&&document.hasFocus();function Tr(t){try{const e=JSON.parse(atob(t.split(".")[1].replace(/-/g,"+").replace(/_/g,"/")));return Number.isFinite(e.exp)?e.exp*1e3:null}catch{return null}}function qo(t){return typeof t!="string"||!t?"":!/^https:\/\/\S+$/i.test(t)||t.length>jo?(console.warn("[Deskcord] avatarUrl ignored: it must be an https:// URL of at most 2048 characters."),""):t}function Vo(t){const e=[];let n=t;for(;n.length>be;){let r=n.lastIndexOf(`
|
|
2
|
-
`,be);r<be/2&&(r=n.lastIndexOf(" ",be)),r<be/2&&(r=be),e.push(n.slice(0,r).trim()),n=n.slice(r).trim()}return n&&e.push(n),e}function Wo(t){const e=$o(To()),{get:n,set:r}=e,i=wi(t,()=>ie()),o=new Map,a=new Map,c=new Map;let d=null,p=0,m=!1,u,h=null,w=0;const x=[];let k,_,T=0,y=0,I=!1,P=!1;function Q(l){w>0?x.push(l):l()}function W(){for(;w===0&&x.length;)x.shift()()}function ae(){et(n())&&r(l=>({guild:{...l.guild,acceptingConversations:!1}}))}function ie(){r({boot:"hidden",open:!1,activeAt:null}),S()}function Y(l,f,v=!1){let g=!0;return r(b=>{const E=b.conversations[l];if(!E&&!v)return g=!1,{};g=!!E;const R=E??Zn(l,Date.now());let F={...b.conversations,[l]:f(R)};return E||(F=Ge(F,l)),{conversations:F}}),g}function K(l){const f=Qe(l.conversations);return f?{view:"chat",activeThreadId:f.threadId}:Object.keys(l.conversations).length||l.token?{view:"home",activeThreadId:null}:{view:"chat",activeThreadId:null}}function H(){I||n().open||r(l=>K(l))}function X(){const l=n().token;if(!l)return;d?.close();const f=p;r({connection:"connecting"}),setTimeout(()=>{f===p&&!n().synced&&_e()},3e3),d=mo(t.domain,l,{event:(v,g)=>{f===p&&Xs(v,g)},status:v=>{f===p&&oe(v)},invalidToken:()=>{f===p&&Gt()}})}function S(){d?.close(),d=null,n().connection!=="off"&&r({connection:"off"})}function oe(l){const f=n().connection;l?(r({connection:"up"}),_e(),ge()):f==="up"&&r({connection:"down"})}async function _e(){const{token:l,synced:f}=n();if(!l)return;const v=p;T=Date.now();try{const[g,b]=await Promise.all([i.current(l),f?Promise.resolve(null):i.unreadCount(l).catch(()=>null)]);if(v!==p)return;Q(()=>Ks(g,b))}catch(g){if(v!==p)return;g instanceof ve&&(g.status===401||g.status===403)&&Gt()}}function Oe(){clearTimeout(k),k=setTimeout(()=>void _e(),400)}function Ks(l,f){let v=!1;r(g=>{let b=Ge(g.conversations,l?.threadId??null),E=g.lastReadAt;if(l){const R=Gn(l,o);if(b={...b,[R.threadId]:R},f!==null){const F=wo(R,f);v=g.lastReadAt>F,E=Math.max(g.lastReadAt,F)}}return{conversations:b,lastReadAt:E,synced:!0}}),v&&ii(),H()}async function Gt(){const l=n();if(l.identity.verifiedUserId){Ue();return}if(S(),r({token:null}),l.identity.name&&l.identity.email)try{await Xr()}catch{}}function Xr(){const l=n().token;if(l)return Promise.resolve(l);if(!h){const f=p;h=(async()=>{const{name:v,email:g,avatarUrl:b,metadata:E}=n().identity;if(!v||!g)throw new Error("Missing name or email");const R=await i.token({name:v,email:g,avatarUrl:b,metadata:E});if(f!==p)throw new Error("Visitor changed");return r({token:R}),X(),R})().finally(()=>{h=null})}return h}function Xs(l,f){const v=f??{},g=v.threadId;switch(l){case"conversations-paused":ae();return;case"presence-updated":r(b=>({guild:{...b.guild,onlineCsMembers:Array.isArray(v.onlineCsMembers)?v.onlineCsMembers:[]}}));return;case"new-support-message":g&&v.message&&Js(g,v.message);return;case"new-customer-message":if(g&&v.message){const b=v.message;Q(()=>Zr(g,b))}return;case"updated-support-message":g&&v.message&&Zs(g,v.message);return;case"deleted-support-message":g&&Gs(g,v.messageId,v.messageDate);return;case"thread-closed":g&&(Y(g,b=>({...b,status:"closed"})),Qt(g));return;case"thread-reopened":g&&(r(b=>({conversations:Ge(b.conversations,g),events:Jr(b,g,"reopened")})),Y(g,b=>({...b,status:"open"}))||Oe());return;case"thread-assigned":case"thread-reassigned":{if(!g)return;const b=Kn(v.csMember);Y(g,R=>({...R,csMember:b}),!0)||Oe(),l==="thread-reassigned"&&b&&r(R=>({events:Jr(R,g,"handoff",b.displayName)}));return}case"support-typing":g&&Qs(g);return}}function Jr(l,f,v,g){return{...l.events,[f]:[...l.events[f]??[],{key:zt("e"),kind:v,date:Date.now(),name:g}]}}function Zr(l,f){const v=Ze(f,o);return Number.isFinite(v.date)?(Y(l,b=>Qn({...b,status:"open"},v),!0)||Oe(),v):null}function Js(l,f){const v=Zr(l,f);if(Qt(l),!v)return;n().open||r({preview:{threadId:l,key:v.key}})}function Zs(l,f){const v=n().conversations[l],g=v&&er(v,f.id,f.date);if(!g)return;const b=Ze(f,o);Y(l,E=>tr(E,g.sid,{text:b.text,attachments:b.attachments,emojis:b.emojis,edited:!0}))}function Gs(l,f,v){const g=n().conversations[l],b=g&&er(g,f,v);b&&(Y(l,E=>tr(E,b.sid,{deleted:!0})),setTimeout(()=>Y(l,E=>bo(E,b.sid)),400))}function Qs(l){clearTimeout(c.get(l)),c.set(l,setTimeout(()=>Qt(l),Po)),n().typing[l]||r(f=>({typing:{...f.typing,[l]:!0}}))}function Qt(l){clearTimeout(c.get(l)),c.delete(l),n().typing[l]&&r(f=>({typing:{...f.typing,[l]:!1}}))}function Gr(l){const f={localId:zt("l"),progress:0,attempts:0,createdAt:Date.now(),...l};return r(v=>({outbox:[...v.outbox,f]})),f}function $e(l,f){r(v=>({outbox:v.outbox.map(g=>g.localId===l?{...g,...f}:g)}))}function Qr(l){r(f=>({outbox:f.outbox.filter(v=>v.localId!==l)}))}async function ge(){if(!m){m=!0;try{for(;;){const l=n();if(l.boot==="hidden")break;const f=l.outbox.find(v=>v.state==="queued");if(!f||!await ea(f))break}}finally{m=!1}}}async function ea(l){const f=p,v=l.attempts+1;$e(l.localId,{state:"sending",progress:0,attempts:v}),w++;try{const g=await Xr();if(l.file){const b=await i.upload(g,l.file,E=>$e(l.localId,{progress:E}));f===p&&ei(l,{threadId:b.threadId,id:b.id,date:Number.isFinite(b.date)?b.date:Date.now(),content:"",attachments:b.attachments??[]})}else{const b=await i.send(g,n().identity.name,l.text??"");f===p&&ei(l,{threadId:b.threadId,id:b.id,date:b.date,content:l.text??"",attachments:[]})}return!0}catch(g){return f!==p?!0:g instanceof mn?(Qr(l.localId),!1):g instanceof vn?(r(E=>({outbox:E.outbox.map(R=>R.localId===l.localId||R.state==="queued"?{...R,state:"failed"}:R)})),ae(),!1):(g instanceof bt||g instanceof ve&&(g.status===401||g.status>=500))&&v<3?($e(l.localId,{state:"queued"}),g instanceof ve&&g.status===401&&await Gt(),clearTimeout(u),u=setTimeout(()=>void ge(),2e3*v),!1):($e(l.localId,{state:"failed"}),!0)}finally{w--,W()}}function ei(l,f){const v={id:f.id,content:f.content,authorName:n().identity.name,support:!1,date:f.date,attachments:f.attachments};o.set(Xn(v),l.localId),l.fileInfo?.previewUrl&&a.set(l.localId,l.fileInfo.previewUrl);const g=Ze(v,o);r(b=>{const E=Ge(b.conversations,f.threadId),R=E[f.threadId]??Zn(f.threadId,f.date),F=b.activeThreadId,J=F===null||F===f.threadId||b.conversations[F]?.status==="open";return{conversations:{...E,[f.threadId]:Qn({...R,status:"open"},g)},outbox:b.outbox.filter(ce=>ce.localId!==l.localId),activeThreadId:J?f.threadId:F}})}function ti(){n().outbox.some(l=>l.state==="held")&&(r(l=>({outbox:l.outbox.map(f=>f.state==="held"?{...f,state:"queued"}:f)})),ge())}let Me=Promise.resolve();function ni(l){return Me=Me.then(l).catch(f=>console.error("[Deskcord]",f)),Me}async function ta(){let l;do l=Me,await l;while(l!==Me)}function Ue(){p++,S(),o.clear(),a.forEach(l=>URL.revokeObjectURL(l)),a.clear(),c.forEach(clearTimeout),c.clear(),x.length=0,I=!1,r(l=>({token:null,identity:sr,conversations:{},outbox:[],tray:[],typing:{},lastReadAt:0,events:{},preview:null,synced:!1,past:"idle",view:"chat",activeThreadId:null,nav:l.nav+1})),lt()}function na(l){const{identity:f,token:v}=n();if(f.verifiedUserId){const g=v?Tr(v):null,b=!!v&&(g===null||g>Date.now()),E=l?.userId===f.verifiedUserId&&!!l?.userHash;(l===null||!b&&!E)&&Ue()}l&&ri(l)}function ri(l){return ni(()=>ia(l))}function ra(){return ni(Ue)}async function ia(l){if(typeof l?.name!="string"||!l.name.trim()||typeof l.email!="string"||!Er(l.email)){console.error("[Deskcord] identify() needs at least a name and a valid email.");return}const f=!!(l.userId&&l.userHash),v=n().identity;v.verifiedUserId&&(!f||String(l.userId)!==v.verifiedUserId)&&Ue();const g={name:l.name.trim().slice(0,Ar),email:l.email.trim(),avatarUrl:qo(l.avatarUrl),metadata:kn(l.metadata)},b=n().identity,E=b.name!==g.name||b.email!==g.email||b.avatarUrl!==g.avatarUrl||JSON.stringify(b.metadata)!==JSON.stringify(g.metadata);r(J=>({identity:{...g,verifiedUserId:J.identity.verifiedUserId}})),ti();const R=n().token;if(f){const J=String(l.userId),ce=R?Tr(R):null;if(b.verifiedUserId===J&&!E&&ce!==null&&ce-Date.now()>Bo)return;const la=p,oi=await i.identify({...g,userId:J,userHash:String(l.userHash)},R);if(la!==p)return;if(oi){const da=b.verifiedUserId!==J;r(ua=>({token:oi,identity:{...ua.identity,verifiedUserId:J}})),da&&(r({past:"idle",synced:!1}),y=0,n().boot==="ready"&&X());return}console.warn("[Deskcord] Identity verification failed: check that it's enabled (/identity-verification enable) and that userHash is HMAC-SHA256(secret, userId) computed on your server. Continuing without it."),b.verifiedUserId&&(Ue(),r({identity:{...g,verifiedUserId:null}}))}const F=n().token;if(F&&E)try{const J=await i.token(g,F);r({token:J})}catch{}}function De(){const l=n();if(!l.open||l.view!=="chat"||!l.activeThreadId||!Ho())return;const f=xo(l.conversations[l.activeThreadId]);f>l.lastReadAt&&(r({lastReadAt:f}),ii())}function ii(){clearTimeout(_),_=setTimeout(()=>{const{token:l,lastReadAt:f}=n();l&&f&&i.markRead(l,f).catch(()=>{})},600)}let en,ct=null;function oa(l){return{token:l.token,identity:l.identity,conversations:l.conversations,lastReadAt:l.lastReadAt,guild:l.guild,activeAt:l.activeAt,outbox:l.outbox}}function lt(){clearTimeout(en);const l=oa(n());ct=l,No(t.appId,l)}function sa(){const l=n(),f=ct;f&&f.token===l.token&&f.identity===l.identity&&f.conversations===l.conversations&&f.lastReadAt===l.lastReadAt&&f.guild===l.guild&&f.activeAt===l.activeAt&&f.outbox===l.outbox||(clearTimeout(en),en=setTimeout(lt,300))}function aa(l){if(l.key!==Ut(t.appId))return;const f=lr(t.appId),v=n();!f||f.token===v.token||(p++,S(),o.clear(),ct=f,r({token:f.token,identity:f.identity,conversations:f.conversations,lastReadAt:f.lastReadAt,outbox:[],synced:!1,past:"idle",activeThreadId:null,view:"chat",nav:v.nav+1}),r(g=>K(g)),f.token&&v.boot==="ready"&&X())}async function ca(){const l=lr(t.appId);l&&(r({...l}),ct=null),r(b=>K(b)),na(t.user),e.subscribe(sa),e.subscribe(De),lt();const f=n().activeAt;f&&Date.now()-f<7*24*60*60*1e3&&r({boot:"ready"});let v=!1,g=null;try{[v,g]=await Promise.all([i.status(),i.settings().catch(()=>null)])}catch{v=!1}if(!v){ie();return}r(b=>({boot:"ready",activeAt:Date.now(),guild:g?{...b.guild,...g}:b.guild})),P&&ke.open(),await ta(),n().token&&X(),ge()}if(typeof window<"u"){window.addEventListener("storage",aa),window.addEventListener("pagehide",lt),window.addEventListener("online",()=>void ge());const l=()=>{De(),document.visibilityState==="visible"&&n().connection==="up"&&Date.now()-T>3e4&&_e()};document.addEventListener("visibilitychange",l),window.addEventListener("focus",l)}const ke={open(){if(n().boot!=="ready"){P=n().boot==="loading";return}rr(n())&&(P=!1,r({open:!0,preview:null}),De(),n().view==="home"&&ke.loadPast())},close(){r({open:!1,lightbox:null})},toggle(){n().open?ke.close():ke.open()},goHome(){I=!0,r(l=>({view:"home",nav:l.nav+1,navPrev:l.activeThreadId})),ke.loadPast()},openConversation(l){I=!0;const f=n();if(f.view==="chat"&&f.activeThreadId===l){r({preview:null}),De();return}r(v=>({view:"chat",activeThreadId:l,nav:v.nav+1,navPrev:v.activeThreadId,preview:null})),De()},newConversation(){I=!0;const l=Qe(n().conversations);r(f=>({view:"chat",activeThreadId:l?.threadId??null,nav:f.nav+1,navPrev:f.activeThreadId}))},dismissPreview(){r({preview:null})},async loadPast(l=!1){const f=n();if(!f.token||f.past==="loading"||!l&&f.past==="done"&&Date.now()-y<zo)return;const v=p;r({past:"loading"});try{const g=await i.past(f.token);if(v!==p)return;y=Date.now(),r(b=>{const E={...b.conversations};for(const R of g)!R?.threadId||E[R.threadId]?.status==="open"||(E[R.threadId]={...Gn(R,o),status:"closed"});return{conversations:E,past:"done"}})}catch{v===p&&r({past:"error"})}},send(l){const f=n(),v=!f.identity.name||!f.identity.email,g=v?"held":"queued";f.activeThreadId&&f.conversations[f.activeThreadId]?.status==="closed"&&r({activeThreadId:null});for(const b of Vo(l.trim()))Gr({text:b,state:g});for(const b of f.tray)Gr({state:g,file:b.file,fileInfo:{name:b.file.name||"image.png",size:b.file.size,type:b.file.type,previewUrl:b.previewUrl,width:b.width,height:b.height}});r({tray:[]}),v||ge()},completeIntro(l,f){r(v=>({identity:{...v.identity,name:l.trim().slice(0,Ar),email:f.trim()}})),ti()},retry(l){$e(l,{state:"queued",attempts:0}),ge()},discard(l){const f=n().outbox.find(v=>v.localId===l);f?.fileInfo?.previewUrl&&URL.revokeObjectURL(f.fileInfo.previewUrl),Qr(l)},addFiles(l){let f=null;const v=[];for(const g of l){if(!_r.includes(g.type)){f=`“${g.name}” can't be sent. Send an image or a PDF.`;continue}if(g.size>Do){f=`“${g.name}” is over 10 MB.`;continue}if(n().tray.length+v.length>=kr){f=`You can attach up to ${kr} files at once.`;break}const b=g.type.startsWith("image/"),E={id:zt("f"),file:g,previewUrl:b?URL.createObjectURL(g):null,width:4,height:3};if(v.push(E),E.previewUrl){const R=new Image;R.onload=()=>{const F=R.naturalWidth||4,J=R.naturalHeight||3;r(ce=>({tray:ce.tray.map(re=>re.id===E.id?{...re,width:F,height:J}:re)})),r(ce=>({outbox:ce.outbox.map(re=>re.fileInfo&&re.fileInfo.previewUrl===E.previewUrl?{...re,fileInfo:{...re.fileInfo,width:F,height:J}}:re)}))},R.src=E.previewUrl}}return v.length&&r(g=>({tray:[...g.tray,...v]})),f&&r({notice:{text:f,at:Date.now()}}),f},removeFromTray(l){const f=n().tray.find(v=>v.id===l);f?.previewUrl&&URL.revokeObjectURL(f.previewUrl),r(v=>({tray:v.tray.filter(g=>g.id!==l)}))},openLightbox(l,f,v){r({lightbox:{url:l,name:f,from:v}})},closeLightbox(){r({lightbox:null})},clearNotice(){r({notice:null})},setDark(l){n().dark!==l&&r({dark:l})}};return{store:e,actions:ke,boot:ca,identify:ri,logout:ra,localPreview:l=>a.get(l)??null}}const Yo="#5865F2",Ko=/^#?([0-9a-f]{3}|[0-9a-f]{6})$/i;function it(t){const e=t?.trim().match(Ko);if(!e)return null;let n=e[1];n.length===3&&(n=[...n].map(i=>i+i).join(""));const r=parseInt(n,16);return[r>>16&255,r>>8&255,r&255]}function Sr([t,e,n]){const r=i=>(i/=255,i<=.03928?i/12.92:((i+.055)/1.055)**2.4);return .2126*r(t)+.7152*r(e)+.0722*r(n)}function xe(t,e){const[n,r]=[Sr(t),Sr(e)].sort((i,o)=>o-i);return(n+.05)/(r+.05)}const Cr=(t,e,n)=>t.map((r,i)=>Math.round(r+(e[i]-r)*n)),Ie=t=>`rgb(${t.join(",")})`,pe=[255,255,255],ot=[17,19,24],Rr=[0,0,0];function Xo(t){const e=it(t.primary)??it(Yo),n=it(t.gradient)??Cr(e,Rr,.17),r=xe(e,pe)>=2.6?pe:ot,i=Math.min(xe(e,pe),xe(n,pe)),o=Math.min(xe(e,ot),xe(n,ot)),a=it(t.headerText)??(i>=2.6||i>=o?pe:ot),c=t.dark?[43,45,49]:pe;let d=e;for(let p=0;p<24&&xe(d,c)<4.5;p++)d=Cr(d,t.dark?pe:Rr,.08);return{vars:{"--dc-accent":Ie(e),"--dc-accent-2":Ie(n),"--dc-on-accent":Ie(r),"--dc-on-grad":Ie(a),"--dc-accent-text":Ie(d),"--dc-accent-soft":`rgba(${e.join(",")},${t.dark?.24:.14})`},flat:e.join()===n.join()}}const G={out:"cubic-bezier(.22,1,.36,1)",spring:"cubic-bezier(.34,1.45,.64,1)",in:"cubic-bezier(.4,0,1,1)"},Jo=typeof matchMedia=="function"?matchMedia("(prefers-reduced-motion: reduce)"):null;function Ft(){return!Jo?.matches}function M(t,e,n={}){return!t||typeof t.animate!="function"?null:t.animate(e,{duration:300,easing:G.out,fill:"backwards",...n,...Ft()?{}:{duration:1,delay:0}})}function Zo(t){return t?t.finished.then(()=>{},()=>{}):Promise.resolve()}function Ir(t){return t.replace(/[&<>"']/g,e=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[e])}const Go=/\.(gif|jpe?g|png|webp|apng)$/i,Nr=/https?:\/\/[^\s<]+[^\s<.,:;!?"')\]]/g;function Qo(t){try{const{protocol:e,pathname:n}=new URL(t);return(e==="https:"||e==="http:")&&Go.test(n)}catch{return!1}}function es(t){const e=[],n=t.replace(Nr,r=>Qo(r)?(e.push(r),""):r);return{text:e.length?n.replace(/[ \t]{2,}/g," ").trim():t,images:e}}function ts(t,e,n,r){return r[t]?.imageURL??`https://cdn.discordapp.com/emojis/${n}.${e?"gif":"webp"}?size=48`}function Lr(t,e={}){let n=Ir(t);const r=[],i=o=>`${r.push(o)-1}`;return n=n.replace(/```(?:[a-z0-9+-]*\n)?([\s\S]*?)```/gi,(o,a)=>i(`<pre><code>${a.replace(/^\n+|\n+$/g,"")}</code></pre>`)),n=n.replace(/`([^`\n]+)`/g,(o,a)=>i(`<code>${a}</code>`)),n=n.replace(/<(a?):(\w+):(\d+)>/g,(o,a,c,d)=>i(`<img class="dc-cemoji" alt=":${c}:" title=":${c}:" src="${Ir(ts(`<${a}:${c}:${d}>`,a==="a",d,e))}">`)),n=n.replace(/\[([^\]\n]+)\]\((https?:\/\/[^\s)]+)\)/g,(o,a,c)=>i(`<a href="${c}" target="_blank" rel="noopener noreferrer nofollow">${a}</a>`)),n=n.replace(Nr,o=>i(`<a href="${o}" target="_blank" rel="noopener noreferrer nofollow">${o.replace(/^https?:\/\//,"")}</a>`)),n=n.replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>").replace(/__(.+?)__/g,"<u>$1</u>").replace(/\*(?!\s)(.+?)\*/g,"<em>$1</em>").replace(/(^|[\s(])_(?!\s)(.+?)_(?=$|[\s).,!?])/gm,"$1<em>$2</em>").replace(/~~(.+?)~~/g,"<s>$1</s>").replace(/\|\|(.+?)\|\|/g,'<span class="dc-spoiler" tabindex="0" role="button" aria-label="Spoiler, click to reveal">$1</span>').replace(/^> (.*)$/gm,'<span class="dc-quote">$1</span>').replace(/^[-*] (?=\S)/gm,"• ").replace(/\n/g,"<br>"),n.replace(/\u0001(\d+)\u0001/g,(o,a)=>r[Number(a)])}const Or=Intl.Segmenter,$r=Or?new Or:null;function ns(t){const e=t.replace(/<a?:\w+:\d+>/g,"⭐").replace(/\s+/g,"");return!e||!/^(?:\p{Extended_Pictographic}|\p{Emoji_Modifier}|[\u{1F1E6}-\u{1F1FF}]||️|⃣)+$/u.test(e)?!1:($r?[...$r.segment(e)].length:[...e].length)<=3}function Mr(t){return t.replace(/<a?:(\w+):\d+>/g,":$1:").replace(/```[\s\S]*?```/g,"[code]").replace(/[*_`|~]/g,"").replace(/\s+/g," ").trim()}const rs={x:"M6 6l12 12M18 6 6 18",down:"m6 9 6 6 6-6",left:"m15 18-6-6 6-6",right:"m9 18 6-6-6-6",send:"M12 19V5M5.5 11.5 12 5l6.5 6.5",arrow:"M5 12h14M13 6l6 6-6 6",clip:"m20.5 11.5-8.3 8.3a5.2 5.2 0 0 1-7.4-7.4l8.6-8.6a3.5 3.5 0 0 1 4.9 4.9l-8.5 8.6a1.75 1.75 0 0 1-2.5-2.5l7.9-7.9",check:"m5 12.5 4.5 4.5L19 7.5",dl:"M12 4v11m-5-5 5 5 5-5M5 20h14",retry:"M4 12a8 8 0 0 1 14-5.3M20 4v4h-4M20 12a8 8 0 0 1-14 5.3M4 20v-4h4",plus:"M12 5v14M5 12h14",upload:"M12 16V4m-5 5 5-5 5 5M5 20h14",ext:"M14 4h6v6M20 4l-9 9M18 14v5a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h5"};function O({name:t,size:e=18,class:n}){const r={width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":2,"stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",class:n};return t==="smile"?s("svg",{...r,children:[s("circle",{cx:"12",cy:"12",r:"9"}),s("path",{d:"M8.5 14.5a4.5 4.5 0 0 0 7 0"}),s("circle",{cx:"9",cy:"9.8",r:"1.1",fill:"currentColor",stroke:"none"}),s("circle",{cx:"15",cy:"9.8",r:"1.1",fill:"currentColor",stroke:"none"})]}):t==="clock"?s("svg",{...r,children:[s("circle",{cx:"12",cy:"12",r:"8.5"}),s("path",{d:"M12 7.5V12l3 2"})]}):t==="alert"?s("svg",{...r,children:[s("circle",{cx:"12",cy:"12",r:"9"}),s("path",{d:"M12 7.5v5.5"}),s("circle",{cx:"12",cy:"16.3",r:"1.2",fill:"currentColor",stroke:"none"})]}):s("svg",{...r,children:s("path",{d:rs[t]})})}function is(){return s("svg",{width:"26",height:"26",viewBox:"0 0 24 24","aria-hidden":"true",children:[s("path",{fill:"currentColor",d:"M12 3.5c4.97 0 9 3.36 9 7.5s-4.03 7.5-9 7.5c-.98 0-1.92-.13-2.8-.37L5.1 20.1c-.5.25-1.06-.22-.9-.75l1.02-3.34C3.84 14.7 3 12.93 3 11c0-4.14 4.03-7.5 9-7.5Z"}),s("circle",{cx:"8.6",cy:"11",r:"1.25",fill:"var(--dc-accent)"}),s("circle",{cx:"12",cy:"11",r:"1.25",fill:"var(--dc-accent)"}),s("circle",{cx:"15.4",cy:"11",r:"1.25",fill:"var(--dc-accent)"})]})}function Ur(){return s("svg",{viewBox:"0 0 642 74","aria-label":"Deskcord",children:s("path",{fill:"currentColor",d:"M23.9 73.2C19.43 73.2 15.37 72.07 11.7 69.8 8.1 67.53 5.23 64.43 3.1 60.5 1.03 56.5 0 51.97 0 46.9c0-5.13 1.07-9.67 3.2-13.6 2.13-4 5.03-7.13 8.7-9.4 3.73-2.33 7.87-3.5 12.4-3.5 3.47 0 6.5.63 9.1 1.9 2.6 1.2 4.73 2.97 6.4 5.3V0h15v72H41.5l-1.7-6.5c-1 1.4-2.23 2.7-3.7 3.9-1.4 1.13-3.1 2.03-5.1 2.7-2 .73-4.37 1.1-7.1 1.1Zm3.9-13.1c2.47 0 4.63-.57 6.5-1.7 1.93-1.13 3.4-2.7 4.4-4.7 1.07-2 1.6-4.3 1.6-6.9s-.53-4.9-1.6-6.9c-1-2-2.47-3.57-4.4-4.7-1.87-1.13-4.03-1.7-6.5-1.7-2.4 0-4.57.57-6.5 1.7-1.87 1.13-3.33 2.7-4.4 4.7-1.07 2-1.6 4.27-1.6 6.8 0 2.6.53 4.93 1.6 7 1.07 2 2.53 3.57 4.4 4.7 1.93 1.13 4.1 1.7 6.5 1.7Zm58.81 13.1c-5.2 0-9.77-1.07-13.7-3.2-3.93-2.2-7.03-5.23-9.3-9.1-2.2-3.93-3.3-8.43-3.3-13.5 0-5.2 1.1-9.83 3.3-13.9 2.2-4.07 5.27-7.27 9.2-9.6 3.93-2.33 8.5-3.5 13.7-3.5 5.07 0 9.5 1.1 13.3 3.3 3.8 2.2 6.77 5.2 8.9 9 2.2 3.73 3.3 8.07 3.3 13 0 .67-.03 1.43-.1 2.3 0 .8-.07 1.63-.2 2.5H71.01v-8.7h25.7c-.13-2.8-1.17-5.03-3.1-6.7-1.87-1.73-4.2-2.6-7-2.6-2.13 0-4.07.5-5.8 1.5-1.73 1-3.13 2.5-4.2 4.5-1 2-1.5 4.53-1.5 7.6v3c0 2.33.43 4.4 1.3 6.2.93 1.8 2.23 3.2 3.9 4.2 1.73 1 3.77 1.5 6.1 1.5 2.2 0 4-.43 5.4-1.3 1.47-.93 2.6-2.1 3.4-3.5h15.3c-.93 3.2-2.53 6.1-4.8 8.7-2.27 2.53-5.030 4.57-8.3 6.1-3.27 1.47-6.87 2.2-10.8 2.2Zm51.43 0c-4.73 0-8.83-.73-12.3-2.2-3.4-1.53-6.1-3.6-8.1-6.2-1.93-2.6-3.03-5.53-3.3-8.8h14.9c.27 1.13.73 2.17 1.4 3.1.73.87 1.7 1.57 2.9 2.1 1.27.47 2.67.7 4.2.7 1.67 0 3-.2 4-.6 1.07-.47 1.87-1.07 2.4-1.8.53-.73.8-1.5.8-2.3 0-1.27-.4-2.23-1.2-2.9-.73-.67-1.83-1.2-3.3-1.6-1.47-.47-3.23-.9-5.3-1.3-2.4-.53-4.8-1.13-7.2-1.8-2.33-.73-4.43-1.630-6.3-2.7-1.8-1.07-3.27-2.43-4.4-4.1-1.07-1.73-1.6-3.83-1.6-6.3 0-3 .83-5.7 2.5-8.1 1.67-2.47 4.07-4.4 7.2-5.8 3.13-1.47 6.93-2.2 11.4-2.2 6.33 0 11.3 1.4 14.9 4.2 3.6 2.8 5.73 6.57 6.4 11.3h-14c-.4-1.33-1.23-2.33-2.5-3-1.27-.73-2.87-1.1-4.8-1.1-2.2 0-3.87.37-5 1.1-1.13.73-1.7 1.7-1.7 2.9 0 .8.37 1.53 1.1 2.2.8.6 1.93 1.13 3.4 1.6 1.47.47 3.27.93 5.4 1.4 4.07.87 7.57 1.8 10.5 2.8 3 1 5.33 2.47 7 4.4 1.67 1.87 2.47 4.6 2.4 8.2.07 3.27-.8 6.17-2.6 8.7-1.73 2.53-4.23 4.53-7.5 6-3.27 1.4-7.17 2.1-11.7 2.1Zm60.6-1.2-20.8-27.6 18.5-22.8h17.7l-24.9 29.2v-12L217.24 72h-18.6Zm-33.6 0V0h15v72h-15Zm74.47 1.2c-5.2 0-9.8-1.13-13.8-3.4-3.93-2.27-7.03-5.37-9.3-9.3-2.2-3.93-3.3-8.43-3.3-13.5 0-5.2 1.1-9.77 3.3-13.7 2.27-4 5.37-7.13 9.3-9.4 4-2.33 8.6-3.5 13.8-3.5 6.6 0 12.13 1.73 16.6 5.2 4.53 3.47 7.4 8.3 8.6 14.5h-15.9c-.6-2.13-1.73-3.8-3.4-5-1.67-1.2-3.67-1.8-6-1.8-2.2 0-4.13.57-5.8 1.7-1.6 1.07-2.87 2.63-3.8 4.7-.93 2-1.4 4.37-1.4 7.1 0 2.07.27 3.93.8 5.6.53 1.67 1.27 3.1 2.2 4.3 1 1.2 2.17 2.13 3.5 2.8 1.33.6 2.83.9 4.5.9 1.6 0 3-.27 4.2-.8 1.27-.53 2.33-1.3 3.2-2.3.93-1 1.6-2.23 2-3.7h15.9c-1.2 6-4.07 10.77-8.6 14.3-4.53 3.53-10.07 5.3-16.6 5.3Zm55.02 0c-4.87 0-9.23-1.13-13.1-3.4-3.87-2.27-6.93-5.37-9.2-9.3-2.27-4-3.4-8.53-3.4-13.6 0-5.2 1.13-9.77 3.4-13.7 2.27-4 5.33-7.13 9.2-9.4 3.93-2.27 8.3-3.4 13.1-3.4 4.93 0 9.33 1.13 13.2 3.4 3.87 2.27 6.93 5.4 9.2 9.4 2.27 3.93 3.4 8.47 3.4 13.6 0 5.13-1.13 9.7-3.4 13.7-2.27 3.93-5.33 7.03-9.2 9.3-3.87 2.27-8.27 3.4-13.2 3.4Zm0-13c2 0 3.77-.5 5.3-1.5 1.6-1 2.87-2.5 3.8-4.5.93-2 1.4-4.47 1.4-7.4s-.47-5.4-1.4-7.4c-.93-2-2.17-3.5-3.7-4.5-1.53-1-3.3-1.5-5.3-1.5s-3.8.5-5.4 1.5c-1.53 1-2.77 2.5-3.7 4.5-.93 2-1.4 4.47-1.4 7.4s.47 5.4 1.4 7.4c.93 2 2.17 3.5 3.7 4.5 1.6 1 3.37 1.5 5.3 1.5Zm31.32 11.8V21.6h13.3l1.4 9.2c1.33-2.13 2.9-3.97 4.7-5.5 1.8-1.53 3.87-2.73 6.2-3.6 2.4-.87 4.97-1.3 7.7-1.3v15.9h-5c-2 0-3.83.23-5.5.7-1.6.4-3 1.1-4.2 2.1-1.13 1-2.03 2.37-2.7 4.1-.6 1.67-.9 3.77-.9 6.3V72h-15Zm58 1.2c-4.47 0-8.53-1.13-12.2-3.4-3.6-2.27-6.47-5.37-8.6-9.3-2.07-4-3.1-8.53-3.1-13.6 0-5.13 1.07-9.67 3.2-13.6 2.13-4 5.03-7.13 8.7-9.4 3.73-2.33 7.87-3.5 12.4-3.5 3.47 0 6.5.63 9.1 1.9 2.6 1.2 4.73 2.97 6.4 5.3V0h15v72h-13.3l-1.7-6.5c-1 1.4-2.23 2.7-3.7 3.9-1.4 1.13-3.1 2.03-5.1 2.7-2 .73-4.37 1.1-7.1 1.1Zm3.9-13.1c2.47 0 4.63-.57 6.5-1.7 1.93-1.13 3.4-2.7 4.4-4.7 1.07-2 1.6-4.3 1.6-6.9s-.53-4.9-1.6-6.9c-1-2-2.47-3.57-4.4-4.7-1.87-1.13-4.03-1.7-6.5-1.7-2.4 0-4.57.57-6.5 1.7-1.87 1.13-3.33 2.7-4.4 4.7-1.07 2-1.6 4.27-1.6 6.8 0 2.6.53 4.93 1.6 7 1.07 2 2.53 3.57 4.4 4.7 1.93 1.13 4.1 1.7 6.5 1.7Zm41.01 12.4c-2.73 0-4.97-.8-6.7-2.4-1.67-1.67-2.5-3.67-2.5-6 0-2.4.83-4.4 2.5-6 1.73-1.67 3.97-2.5 6.7-2.5 2.67 0 4.83.83 6.5 2.5 1.67 1.6 2.5 3.6 2.5 6 0 2.33-.83 4.33-2.5 6-1.67 1.6-3.83 2.4-6.5 2.4Zm38.66.7c-5.2 0-9.8-1.13-13.8-3.4-3.93-2.27-7.03-5.37-9.3-9.3-2.2-3.93-3.3-8.43-3.3-13.5 0-5.2 1.1-9.77 3.3-13.7 2.27-4 5.37-7.13 9.3-9.4 4-2.33 8.6-3.5 13.8-3.5 6.6 0 12.13 1.73 16.6 5.2 4.53 3.47 7.4 8.3 8.6 14.5h-15.9c-.6-2.13-1.73-3.8-3.4-5-1.67-1.2-3.67-1.8-6-1.8-2.2 0-4.13.57-5.8 1.7-1.6 1.07-2.87 2.63-3.8 4.7-.93 2-1.4 4.37-1.4 7.1 0 2.070.27 3.93.8 5.6.53 1.67 1.27 3.1 2.2 4.3 1 1.2 2.17 2.13 3.5 2.8 1.33.6 2.83.9 4.5.9 1.6 0 3-.27 4.2-.8 1.27-.53 2.33-1.3 3.2-2.3.93-1 1.6-2.23 2-3.7h15.9c-1.2 6-4.07 10.77-8.6 14.3-4.53 3.53-10.07 5.3-16.6 5.3ZM498.24 72V0h15v28.8c1.6-2.53 3.77-4.57 6.5-6.1 2.73-1.53 5.93-2.3 9.6-2.3 4.27 0 7.83.9 10.7 2.7 2.87 1.8 5.03 4.43 6.5 7.9 1.47 3.4 2.2 7.53 2.2 12.4V72h-14.9V44.8c0-3.73-.8-6.63-2.4-8.7-1.53-2.07-4-3.1-7.4-3.1-2 0-3.83.5-5.5 1.5-1.67 1-2.97 2.43-3.9 4.3-.93 1.8-1.4 3.97-1.4 6.5V72h-15Zm74.19 1.2c-4.2 0-7.7-.67-10.5-2-2.73-1.33-4.77-3.13-6.1-5.4-1.27-2.33-1.9-4.9-1.9-7.7 0-3 .73-5.63 2.2-7.9 1.53-2.33 3.9-4.17 7.1-5.5 3.2-1.4 7.23-2.1 12.1-2.1h12.2c0-2.27-.3-4.13-.9-5.6-.53-1.47-1.43-2.57-2.7-3.3-1.27-.73-3-1.1-5.2-1.1-2.33 0-4.3.47-5.9 1.4-1.6.93-2.6 2.4-3 4.4h-14.4c.33-3.6 1.5-6.73 3.5-9.4 2.07-2.67 4.8-4.77 8.2-6.3 3.4-1.53 7.3-2.3 11.7-2.3 4.8 0 8.97.8 12.5 2.4 3.53 1.53 6.27 3.8 8.2 6.8 2 3 3 6.73 3 11.2V72h-12.5l-1.8-7.3c-.73 1.27-1.6 2.43-2.6 3.5-1 1-2.17 1.9-3.5 2.7-1.33.73-2.8 1.3-4.4 1.7-1.6.4-3.37.6-5.3.6Zm3.7-11.4c1.6 0 3-.27 4.2-.8 1.2-.53 2.23-1.27 3.1-2.2.87-.93 1.57-2 2.1-3.2.6-1.27 1.03-2.63 1.3-4.1v-.1h-9.7c-1.67 0-3.07.23-4.2.7-1.07.4-1.87 1-2.4 1.8-.53.8-.8 1.73-.8 2.8 0 1.13.27 2.1.8 2.9.6.73 1.37 1.3 2.3 1.7 1 .33 2.1.5 3.3.5ZM632.3 72c-3.67 0-6.9-.57-9.7-1.7-2.8-1.2-4.97-3.13-6.5-5.8-1.53-2.67-2.3-6.3-2.3-10.9V34.1h-8.6V21.6h8.6l1.6-14.2h13.4v14.2h12.9v12.5h-12.9v19.7c0 2 .43 3.43 1.3 4.3.93.8 2.5 1.2 4.7 1.2h6.9V72h-9.4Z"})})}const Dr=gn(null),V=()=>br(Dr);function j(t){return Uo(V().store,t)}function os(t){const[,e]=z(0);ue(()=>{const n=setInterval(()=>e(r=>r+1),t);return()=>clearInterval(n)},[t])}function ss(t,e,n,r,i={}){const[o,a]=z(t),c=A(t);c.current=t;const d=A(null);return L(()=>{if(t){d.current?.cancel(),d.current=null,o||a(!0);return}if(!o)return;const p=M(e.current,r,{duration:160,fill:"forwards",...i.exit});d.current=p,Zo(p).then(()=>{!c.current&&d.current===p&&a(!1)})},[t]),L(()=>{t&&o&&M(e.current,n,{duration:380,...i.enter})},[t,o]),o}function as(){const t=()=>document.visibilityState==="visible"&&document.hasFocus(),[e,n]=z(t);return ue(()=>{const r=()=>n(t());return document.addEventListener("visibilitychange",r),window.addEventListener("focus",r),window.addEventListener("blur",r),()=>{document.removeEventListener("visibilitychange",r),window.removeEventListener("focus",r),window.removeEventListener("blur",r)}},[]),e}const Pr=()=>typeof matchMedia=="function"&&matchMedia("(pointer: fine)").matches;function cs(t){let e=0;for(let n=0;n<t.length;n++)e=(e*31+t.charCodeAt(n))%360;return e}const Br=t=>(t.trim()[0]??"?").toUpperCase();function fe({name:t,url:e,size:n=28,status:r}){const[i,o]=z(!1);return s("span",{class:"dc-av",style:`--s:${n}px;--h:${cs(t)}`,title:t,children:[e&&!i?s("img",{src:e,alt:"",loading:"lazy",onError:()=>o(!0)}):Br(t),r&&s("i",{class:`dot ${r}`})]})}function he({member:t,size:e,withStatus:n}){return s(fe,{name:t.displayName,url:t.displayAvatarURL,size:e,status:n?t.status:null})}function Ne({size:t=36,dot:e}){const{iconURL:n,name:r}=j(a=>({iconURL:a.guild.iconURL,name:a.guild.name})),[i,o]=z(!1);return s("span",{class:"dc-guild",style:`--s:${t}px`,children:[n&&!i?s("img",{src:n,alt:"",onError:()=>o(!0)}):Br(r||"S"),e&&s("i",{class:`dot ${e}`})]})}const st={online:3,idle:2,dnd:1};function jt(t,e=3){return[...t].sort((n,r)=>(st[r.status]??0)-(st[n.status]??0)).slice(0,e).reverse()}function Ht(t){const e=[...t].sort((r,i)=>(st[i.status]??0)-(st[r.status]??0)).map(r=>r.displayName);if(e.length===1)return`${e[0]} is online`;if(e.length===2)return`${e[0]} and ${e[1]} are online`;const n=e.length-2;return`${e[0]}, ${e[1]} and ${n===1?e[2]:`${n} others`} are online`}const ls={online:"Online",idle:"Away",dnd:"Busy",invisible:"Offline",offline:"Offline"},ds="Hi there 👋",us="We typically reply within a few minutes.",qt="No one is online right now. Leave a message and we'll get back to you here.",at=6e4,Vt=60*at,Le=24*Vt;function we(t){return new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function ps(t,e=Date.now()){if(!Number.isFinite(t))return"";const n=e-t;return n<at?"now":n<Vt?`${Math.floor(n/at)} min`:n<Le&&new Date(t).getDate()===new Date(e).getDate()?we(t):n<7*Le?`${Math.max(1,Math.floor(n/Le))}d`:new Date(t).toLocaleDateString([],{day:"numeric",month:"short"})}function fs(t,e=Date.now()){const n=new Date(e);return n.setHours(0,0,0,0),t>=n.getTime()?"Today":t>=n.getTime()-Le?"Yesterday":new Date(t).toLocaleDateString([],{weekday:"short",day:"numeric",month:"short"})}function hs(t){const e=new Date(t);return`${e.getFullYear()}-${e.getMonth()}-${e.getDate()}`}function Wt(t){return Number.isFinite(t)?t<1024*1024?`${Math.max(1,Math.round(t/1024))} KB`:`${(t/1024/1024).toFixed(1)} MB`:""}function Yt(t){const e=t.lastIndexOf(".");return e>0&&e<t.length-1?t.slice(e+1).toUpperCase().slice(0,4):"FILE"}const gs={MIN:at,HOUR:Vt,DAY:Le};function zr(){const{actions:t}=V();return s("button",{class:"dc-hbtn","aria-label":"Close chat",onClick:t.close,children:[s(O,{name:"x",size:20,class:"ic-x"}),s(O,{name:"down",size:22,class:"ic-down"})]})}function ms(){const{actions:t}=V(),{guild:e,identity:n,conversations:r,past:i,lastReadAt:o,accepting:a}=j(_=>({guild:_.guild,accepting:et(_),identity:_.identity,conversations:_.conversations,past:_.past,lastReadAt:_.lastReadAt}));os(3e4);const c=nt(()=>nr(r),[r]),d=c.find(_=>_.status==="open"),p=c.filter(_=>_.status==="closed"&&_.messages.length),m=e.onlineCsMembers,u=Array.isArray(m)&&m.length===0,h=n.name.trim().split(/\s+/)[0],w=e.header_title||(h?`Hi ${h} 👋`:ds),x=u?e.offline_message||qt:e.header_subtitle||us,k=d?d.messages.filter(_=>_.from==="agent"&&_.date>o).length:0;return s(B,{children:[s("header",{class:"dc-head dc-hero",children:[s("div",{class:"top",children:[s(Ne,{size:36}),s(zr,{})]}),s("h2",{children:w}),s("p",{children:x}),m&&m.length>0&&s("div",{class:"dc-team",children:[s("span",{class:"stack",children:jt(m).map(_=>s(he,{member:_,size:30,withStatus:!0},_.displayName))}),s("span",{children:Ht(m)})]}),u&&s("div",{class:"dc-team",children:"The team is away right now"})]}),s("div",{class:"dc-home-body",children:[d?s("div",{class:"dc-card",children:[s("div",{class:"dc-eyebrow",children:"Ongoing conversation"}),s("div",{class:"dc-list",children:s(jr,{conv:d,unread:k,onOpen:()=>t.openConversation(d.threadId)})})]}):a?s("button",{class:"dc-card dc-cta",onClick:t.newConversation,children:[s("span",{class:"tx",children:[s("b",{children:"Send us a message"}),s("small",{children:u?"We'll reply as soon as we're back":"We typically reply within a few minutes"})]}),s("span",{class:"go",children:s(O,{name:"arrow",size:18})})]}):s("div",{class:"dc-card dc-cta is-paused","aria-live":"polite",children:s("span",{class:"tx",children:[s("b",{children:"We're not taking new conversations right now"}),s("small",{children:"Please come back a little later"})]})}),(p.length>0||i==="loading"||i==="error")&&s("div",{class:"dc-card",children:[s("div",{class:"dc-eyebrow",children:"Previous conversations"}),s("div",{class:"dc-list",children:[p.map(_=>s(jr,{conv:_,unread:0,onOpen:()=>t.openConversation(_.threadId)},_.threadId)),i==="loading"&&p.length===0&&s(B,{children:[s(Fr,{}),s(Fr,{})]})]}),i==="error"&&s("p",{class:"dc-empty",children:["Couldn't load your previous conversations."," ",s("button",{onClick:()=>void t.loadPast(!0),children:"Try again"})]})]}),s("a",{class:"dc-powered",href:"https://deskcord.chat",target:"_blank",rel:"noopener",children:["Powered by ",s(Ur,{})]})]})]})}function Fr(){return s("div",{class:"dc-skel-row","aria-hidden":"true",children:[s("i",{}),s("span",{children:[s("i",{}),s("i",{})]})]})}function vs(t){for(let e=t.messages.length-1;e>=0;e--){const n=t.messages[e];if(n.deleted)continue;const r=n.from==="me"?"You: ":"";if(n.text)return r+Mr(n.text);if(n.attachments.length)return r+(n.attachments[0].contentType?.startsWith("image/")?"📷 Image":`📄 ${n.attachments[0].name}`)}return""}function jr({conv:t,unread:e,onOpen:n}){const r=j(a=>a.guild.name),i=t.status==="closed",o=t.csMember?.displayName??_o(t);return s("button",{class:`dc-conv${e?" is-unread":""}`,onClick:n,children:[t.csMember?s(he,{member:t.csMember,size:40,withStatus:!i}):o?s(fe,{name:o,size:40}):s(Ne,{size:40}),s("span",{class:"tx",children:[s("span",{class:"l1",children:[s("b",{children:o??r??"Support"}),s("time",{children:ps(t.lastMessageDate)})]}),s("span",{class:"l2",children:[i&&s("span",{class:"dc-pill ok",children:"Resolved"}),vs(t)]})]}),e>0?s("span",{class:"count",children:e}):s("span",{class:"chev",children:s(O,{name:"right",size:16})})]})}const ys=5*gs.MIN;function bs(t,e,n,r){const i=[];let o="",a=null,c=!1,d=!1,p=!1;const m=x=>{const k=hs(x);k!==o&&(i.push({type:"day",key:`day-${k}`,date:x}),o=k,a=null)},u=(x,k)=>{const _=a,T=!!_&&_.side===x&&k-_.date<ys;if(T){const y=i[i.length-1];(y.type==="msg"||y.type==="out")&&(y.last=!1)}return a={side:x,date:k},!T},h=[...(t?.messages??[]).map(x=>({date:x.date,m:x})),...n.map(x=>({date:x.date,e:x}))].sort((x,k)=>x.date-k.date);for(const x of h){if(m(x.date),x.e){i.push({type:"event",key:x.e.key,e:x.e}),a=null;continue}const k=x.m;k.from==="agent"?(d=!0,c||(c=!0,i.push({type:"joined",key:`joined-${k.key}`,name:k.authorName,avatar:k.authorAvatarURL,date:k.date}),a=null)):p=!0;const _=u(k.from==="me"?"me":`a:${k.authorName}`,k.date);i.push({type:"msg",key:k.key,m:k,first:_,last:!0,status:!1})}let w=!1;for(const x of e){m(x.createdAt),p=!0;const k=u("me",x.createdAt);i.push({type:"out",key:x.localId,o:x,first:k,last:!0}),x.state==="held"&&(w=!0)}if(!e.length)for(let x=i.length-1;x>=0;x--){const k=i[x];if(k.type==="msg"&&k.m.from==="me"){k.status=!0;break}}return w&&i.push({type:"intro",key:"intro"}),r&&p&&!d&&t?.status!=="closed"&&i.push({type:"note",key:"offline-note",text:r}),t?.status==="closed"&&i.push({type:"resolved",key:"resolved",date:t.lastMessageDate}),i}const Hr=gn({mounted:{current:!1}});function xs({items:t,member:e}){const n=A(!1);return L(()=>{n.current=!0},[]),s(Hr.Provider,{value:{mounted:n},children:s("div",{class:"dc-msgs",onClick:r=>{const i=r.target.closest?.(".dc-spoiler");i&&i.classList.add("is-shown")},onKeyDown:r=>{const i=r.target;(r.key==="Enter"||r.key===" ")&&i.classList?.contains("dc-spoiler")&&(r.preventDefault(),i.classList.add("is-shown"))},children:t.map(r=>s(ws,{item:r,member:e},r.key))})})}function ws({item:t,member:e}){const{mounted:n}=br(Hr),r=A(null);switch(L(()=>{if(!n.current)return;const i=t.type==="out"||t.type==="msg"&&t.m.from==="me",o=t.type==="msg"||t.type==="out";r.current&&(r.current.style.transformOrigin=i?"bottom right":o?"bottom left":"center"),M(r.current,[{opacity:0,transform:`translateY(10px) scale(${o?.94:.98})`},{opacity:1,transform:"none"}],{duration:420,easing:G.spring})},[]),t.type){case"day":return s("div",{ref:r,class:"dc-day",children:fs(t.date)});case"joined":return s("div",{ref:r,class:"dc-event",children:[s(fe,{name:t.name,url:t.avatar??(e?.displayName===t.name?e.displayAvatarURL:null),size:20}),s("span",{children:[s("b",{children:t.name})," joined the conversation"]}),s("time",{children:we(t.date)})]});case"event":return s("div",{ref:r,class:"dc-event",children:[t.e.kind==="handoff"?s(B,{children:[s(fe,{name:t.e.name??"?",size:20}),s("span",{children:[s("b",{children:t.e.name})," took over the conversation"]})]}):s(B,{children:[s("span",{class:"ic",children:s(O,{name:"retry",size:12})}),s("span",{children:"Conversation reopened"})]}),s("time",{children:we(t.e.date)})]});case"resolved":return s("div",{ref:r,class:"dc-event ok",children:[s("span",{class:"ic",children:s(O,{name:"check",size:12})}),s("span",{children:"Conversation resolved"})]});case"note":return s("div",{ref:r,class:"dc-event note",children:s("span",{children:t.text})});case"intro":return s("div",{ref:r,children:s(Cs,{})});case"msg":return t.m.from==="me"?s(ks,{ref_:r,m:t.m,first:t.first,last:t.last,status:t.status}):s(_s,{ref_:r,m:t.m,first:t.first,last:t.last,member:e});case"out":return s(As,{ref_:r,o:t.o,first:t.first,last:t.last})}}function Kt({text:t,emojis:e,edited:n}){const r=A(null),i=A(!0),{text:o,images:a}=es(t);return L(()=>{if(i.current){i.current=!1;return}M(r.current,[{filter:"brightness(1.25) saturate(1.3)"},{filter:"none"}],{duration:900})},[t]),s(B,{children:[o&&s("div",{ref:r,class:`dc-bubble${ns(o)?" is-jumbo":""}`,dangerouslySetInnerHTML:{__html:Lr(o,e)+(n?'<span class="dc-edited">(edited)</span>':"")}}),a.map(c=>s("img",{class:"dc-inline-img",src:c,alt:"",loading:"lazy"},c))]})}function Xt(t,e,n,r=""){return`dc-row dc-row--${t}${e?" is-first":""}${n?" is-last":""}${r}`}function _s({ref_:t,m:e,first:n,last:r,member:i}){const o=i&&i.displayName===e.authorName?i:null;return s("div",{ref:t,class:Xt("agent",n,r,e.deleted?" is-deleted":""),title:we(e.date),children:[s("div",{class:"dc-row-av",children:e.authorAvatarURL||!o?s(fe,{name:e.authorName||"?",url:e.authorAvatarURL,size:28}):s(he,{member:o,size:28})}),s("div",{class:"dc-stack",children:[s("div",{class:"dc-name",children:[s("b",{children:e.authorName}),we(e.date)]}),s(Kt,{text:e.text,emojis:e.emojis,edited:e.edited}),s(Vr,{list:e.attachments,localUrl:null})]})]})}function ks({ref_:t,m:e,first:n,last:r,status:i}){const{localPreview:o}=V();return s("div",{ref:t,class:Xt("me",n,r,i?" show-status":""),title:we(e.date),children:s("div",{class:"dc-stack",children:[s(Kt,{text:e.text,emojis:e.emojis,edited:e.edited}),s(Vr,{list:e.attachments,localUrl:o(e.key)}),s("div",{class:"dc-status",children:[s(O,{name:"check",size:12})," Sent"]})]})})}function As({ref_:t,o:e,first:n,last:r}){const{actions:i}=V(),o=e.state==="failed",a=e.fileInfo,c=Math.round(e.progress*100);return s("div",{ref:t,class:Xt("me",n,r,o?"":" is-pending"),children:s("div",{class:"dc-stack",children:[e.text&&s(Kt,{text:e.text,emojis:{}}),a&&(a.previewUrl?s("div",{class:`dc-img is-${o?"failed":"uploading"}`,style:`--w:${qr(a.width,a.height)}px;aspect-ratio:${a.width}/${a.height}`,children:[s("img",{src:a.previewUrl,alt:a.name}),!o&&s(Es,{value:e.state==="sending"?c:0}),o&&s("span",{class:"fail",children:[s(O,{name:"retry",size:20}),"Not sent"]})]}):s("div",{class:`dc-file is-${o?"failed":"uploading"}`,children:[s("span",{class:"dc-ftype",children:Yt(a.name)}),s("span",{class:"tx",children:[s("b",{children:a.name}),s("small",{children:o?"Not sent":e.state==="sending"?`Uploading · ${c}%`:Wt(a.size)})]}),!o&&s("span",{class:"bar",children:s("i",{style:`width:${e.state==="sending"?c:0}%`})})]})),o?s("div",{class:"dc-status is-failed",children:[s(O,{name:"alert",size:13})," Not sent ·"," ",s("button",{onClick:()=>i.retry(e.localId),children:"Retry"})," ·"," ",s("button",{onClick:()=>i.discard(e.localId),children:"Remove"})]}):s("div",{class:"dc-status is-pending",children:[s(O,{name:"clock",size:12})," ",e.state==="held"?"Waiting for your details":"Sending…"]})]})})}function Es({value:t}){return s(B,{children:[s("svg",{class:"dc-ring",viewBox:"0 0 36 36","aria-hidden":"true",children:[s("circle",{class:"bg",cx:"18",cy:"18",r:"15"}),s("circle",{class:"fg",cx:"18",cy:"18",r:"15",pathLength:100,style:`stroke-dashoffset:${100-t}`})]}),s("span",{class:"pct",children:[t,"%"]})]})}const Jt=t=>t.contentType?t.contentType.startsWith("image/"):/\.(png|jpe?g|gif|webp)$/i.test(t.name);function qr(t,e){return!t||!e?232:e>t?Math.max(120,Math.round(232*t/e)):232}function Vr({list:t,localUrl:e}){if(!t.length)return null;const n=t.filter(Jt),r=t.filter(i=>!Jt(i));return s(B,{children:[n.length>1?s("div",{class:"dc-gallery",children:n.map(i=>s(Wr,{a:i,src:i.proxyURL||i.url},i.url))}):n[0]&&s(Wr,{a:n[0],src:e??(n[0].proxyURL||n[0].url)}),r.map(i=>s(Ss,{a:i},i.url))]})}function Wr({a:t,src:e}){const{actions:n}=V(),r=t.width&&t.height?`${t.width}/${t.height}`:"4/3";return s("button",{class:"dc-img",style:`--w:${qr(t.width,t.height)}px;aspect-ratio:${r}`,"aria-label":`Open image ${t.name}`,onClick:i=>n.openLightbox(t.url||e,t.name,i.currentTarget.getBoundingClientRect()),children:s("img",{src:e,alt:t.name,loading:"lazy"})})}async function Ts(t){try{const e=await fetch(t.url);if(!e.ok)throw new Error(String(e.status));const n=URL.createObjectURL(await e.blob()),r=document.createElement("a");r.href=n,r.download=t.name,document.body.appendChild(r),r.click(),r.remove(),setTimeout(()=>URL.revokeObjectURL(n),1e3)}catch{window.open(t.url,"_blank","noopener,noreferrer")}}function Ss({a:t}){return s("button",{class:"dc-file",onClick:()=>void Ts(t),"aria-label":`Download ${t.name}`,children:[s("span",{class:`dc-ftype${Jt(t)?" is-image":""}`,children:Yt(t.name)}),s("span",{class:"tx",children:[s("b",{children:t.name}),s("small",{children:[Wt(t.size)," · ",Yt(t.name)]})]}),s("span",{class:"dl",children:s(O,{name:"dl",size:16})})]})}function Cs(){const{actions:t}=V(),e=j(u=>u.identity),[n,r]=z(e.name),[i,o]=z(e.email),[a,c]=z({}),d=A(null),p=A(null);return L(()=>{Pr()&&setTimeout(()=>p.current?.focus({preventScroll:!0}),350)},[]),s("div",{class:"dc-intro",children:[s(Ne,{size:28}),s("div",{class:"card",ref:d,children:[s("h4",{children:"Who should we reply to?"}),s("p",{children:"Your message is ready. Add your name and email so the team knows who they're talking to."}),s("form",{onSubmit:u=>{u.preventDefault();const h={name:n.trim()?void 0:"Tell us what to call you.",email:Er(i)?void 0:"That email doesn't look right."};if(c(h),h.name||h.email){M(d.current,[{transform:"translateX(-5px)"},{transform:"translateX(5px)"},{transform:"translateX(-3px)"},{transform:"none"}],{duration:360});return}t.completeIntro(n,i)},noValidate:!0,children:[s("label",{class:`dc-in${a.name?" is-err":""}`,children:[s("span",{children:"Name"}),s("input",{ref:p,id:"dc-name",name:"name",autocomplete:"name",placeholder:"Ada Lovelace",maxLength:256,value:n,onInput:u=>r(u.currentTarget.value)}),a.name&&s("em",{children:a.name})]}),s("label",{class:`dc-in${a.email?" is-err":""}`,children:[s("span",{children:"Email"}),s("input",{id:"dc-email",name:"email",type:"email",autocomplete:"email",placeholder:"ada@example.com",value:i,onInput:u=>o(u.currentTarget.value)}),a.email&&s("em",{children:a.email})]}),s("button",{class:"dc-btn",type:"submit",children:[s(O,{name:"send",size:15})," Send message"]})]})]})]})}const Yr=[["😀","Smileys","😀 😃 😄 😁 😆 😅 😂 🤣 😊 😇 🙂 😉 😍 🥰 😘 😋 😜 🤪 🤓 😎 🥳 😏 😒 😔 😕 🙁 😣 😩 🥺 😢 😭 😤 😠 🤯 😳 😱 🤗 🤔 🤫 😐 🙄 😬 😴 😷"],["👋","People","👋 🤚 ✋ 👌 🤌 ✌️ 🤞 🤟 🤘 👈 👉 👆 👇 👍 👎 ✊ 👊 👏 🙌 🫶 🙏 💪 ✍️ 👀"],["🎮","Objects","💻 🖥️ ⌨️ 🖱️ 📱 🎮 🕹️ 🎧 📦 📎 📌 📝 📅 🔒 🔑 🛠️ ⚙️ 🧪 💡 🔋 📈 📉 🧾 💳 🗂️"],["❤️","Symbols","❤️ 🧡 💛 💚 💙 💜 🖤 🤍 💯 ✅ ❌ ⚠️ ❓ ❗ 🔥 ✨ ⭐ 🎉 🎊 🚀 💬 🆗 🆒 ⏳ 🌊"]];function Rs({closed:t,paused:e,placeholder:n}){const{actions:r}=V(),{tray:i,notice:o}=j(y=>({tray:y.tray,notice:y.notice})),[a,c]=z(""),[d,p]=z(!1),m=A(null),u=A(null),h=A(null),w=A(null),x=A(t);L(()=>{const y=m.current;y&&(y.style.height="",y.style.height=`${Math.min(y.scrollHeight,128)}px`)},[a,t]),L(()=>{x.current!==t&&(M(w.current,[{opacity:0,transform:"translateY(10px)"},{opacity:1,transform:"none"}],{duration:380}),x.current=t)},[t]),ue(()=>{if(!o)return;M(h.current,[{transform:"translateX(-5px)"},{transform:"translateX(5px)"},{transform:"translateX(-3px)"},{transform:"none"}],{duration:360});const y=setTimeout(r.clearNotice,3200);return()=>clearTimeout(y)},[o,r]);const k=!!a.trim()||i.length>0,_=()=>{k&&(r.send(a),c(""),p(!1),m.current?.focus({preventScroll:!0}))},T=y=>{const I=m.current,P=I?.selectionStart??a.length,Q=I?.selectionEnd??a.length,W=a.slice(0,P)+y+a.slice(Q);c(W),requestAnimationFrame(()=>{I&&(I.focus({preventScroll:!0}),I.selectionStart=I.selectionEnd=P+y.length)})};return e?s("footer",{class:"dc-composer",ref:w,children:[s("div",{class:"dc-resolved","aria-live":"polite",children:s("p",{children:[t?"This conversation was resolved. ":"","We're not taking new conversations right now. Please come back a little later."]})}),s(Zt,{})]}):t?s("footer",{class:"dc-composer",ref:w,children:[s("div",{class:"dc-resolved",children:[s("p",{children:"This conversation was resolved. Need anything else?"}),s("button",{class:"dc-btn",onClick:r.newConversation,children:[s(O,{name:"plus",size:16})," Start a new conversation"]})]}),s(Zt,{})]}):s("footer",{class:"dc-composer",ref:w,children:[o&&s(Is,{text:o.text},o.at),d&&s(Ls,{onPick:T,onClose:()=>p(!1)}),s("div",{class:"dc-field",ref:h,children:[i.length>0&&s("div",{class:"dc-tray",children:i.map(y=>s(Ns,{id:y.id,file:y.file,previewUrl:y.previewUrl,onRemove:()=>r.removeFromTray(y.id)},y.id))}),s("div",{class:"dc-input-row",children:[s("textarea",{ref:m,id:"dc-input",rows:1,"aria-label":"Message",placeholder:n,value:a,onInput:y=>c(y.currentTarget.value),onKeyDown:y=>{y.key==="Enter"&&!y.shiftKey&&!y.isComposing&&Pr()&&(y.preventDefault(),_()),y.key==="Escape"&&d&&(y.preventDefault(),p(!1))},onPaste:y=>{const I=[...y.clipboardData?.files??[]];I.length&&(y.preventDefault(),r.addFiles(I))}}),s("button",{class:"dc-tool","aria-label":"Attach a file",onClick:()=>u.current?.click(),children:s(O,{name:"clip",size:20})}),s("button",{class:"dc-tool","data-emoji-toggle":!0,"aria-label":"Emoji","aria-expanded":d,onClick:()=>p(y=>!y),children:s(O,{name:"smile",size:20})}),s("button",{class:"dc-send","aria-label":"Send",disabled:!k,onClick:_,children:s(O,{name:"send",size:18})})]})]}),s("input",{ref:u,type:"file",multiple:!0,hidden:!0,accept:_r.join(","),onChange:y=>{const I=y.currentTarget;r.addFiles([...I.files??[]]),I.value="",m.current?.focus({preventScroll:!0})}}),s(Zt,{})]})}function Zt(){return s("a",{class:"dc-powered",href:"https://deskcord.chat",target:"_blank",rel:"noopener",children:["Powered by ",s(Ur,{})]})}function Is({text:t}){const e=A(null);return L(()=>{M(e.current,[{opacity:0,transform:"translateY(6px) scale(.96)"},{opacity:1,transform:"none"}],{duration:320,easing:G.spring})},[]),s("div",{class:"dc-toast",role:"alert",children:s("span",{ref:e,children:[s(O,{name:"alert",size:15}),t]})})}function Ns({file:t,previewUrl:e,onRemove:n}){const r=A(null);L(()=>{M(r.current,[{opacity:0,transform:"scale(.6)"},{opacity:1,transform:"none"}],{duration:420,easing:G.spring})},[]);const i=()=>{const c=M(r.current,[{opacity:1,transform:"none"},{opacity:0,transform:"scale(.6)"}],{duration:180,easing:G.in,fill:"forwards"});c?c.onfinish=n:n()},o=t.name||"image.png",a=s("button",{class:"rm","aria-label":`Remove ${o}`,onClick:i,children:s(O,{name:"x",size:11})});return e?s("div",{class:"dc-chip img",ref:r,children:[s("img",{src:e,alt:o}),a]}):s("div",{class:"dc-chip file",ref:r,children:[s("span",{class:"dc-ftype",children:"PDF"}),s("span",{class:"tx",children:[s("b",{children:o}),s("small",{children:Wt(t.size)})]}),a]})}function Ls({onPick:t,onClose:e}){const[n,r]=z(0),i=A(null);L(()=>{M(i.current,[{opacity:0,transform:"translateY(8px) scale(.94)"},{opacity:1,transform:"none"}],{duration:340,easing:G.spring})},[]),ue(()=>{const c=d=>{const p=d.composedPath();p.includes(i.current)||p.some(m=>m instanceof Element&&m.hasAttribute("data-emoji-toggle"))||e()};return document.addEventListener("pointerdown",c,!0),()=>document.removeEventListener("pointerdown",c,!0)},[e]);const[,o,a]=Yr[n];return s("div",{class:"dc-emoji",ref:i,role:"dialog","aria-label":"Emoji",onKeyDown:c=>{c.key==="Escape"&&(c.preventDefault(),e())},children:[s("div",{class:"grid",children:[s("div",{class:"cat",children:o}),a.split(" ").map(c=>s("button",{"aria-label":c,onClick:()=>t(c),children:c},c))]}),s("div",{class:"tabs",children:Yr.map(([c,d],p)=>s("button",{"aria-label":d,"aria-pressed":p===n,onClick:()=>r(p),children:c},d))})]})}const Os=[],$s=[];function Ms({frozenThreadId:t}){const{actions:e}=V(),n=j(S=>S.activeThreadId),r=t!==void 0?t:n,i=j(S=>{const oe=r?S.conversations[r]??null:null,_e=!oe||oe.status==="open";return{conv:oe,outbox:_e?S.outbox:Os,events:r&&S.events[r]||$s,typing:!!(r&&S.typing[r]),guild:S.guild,identity:S.identity,open:S.open,accepting:et(S),canGoBack:!!S.token||Object.keys(S.conversations).some(Oe=>Oe!==r)}}),{conv:o,outbox:a,events:c,typing:d,guild:p,identity:m,accepting:u}=i,h=p.onlineCsMembers,w=Array.isArray(h)&&h.length===0,x=w?p.offline_message||qt:null,k=nt(()=>bs(o,a,c,x),[o,a,c,x]),_=k.length===0,T=o?.status==="closed",y=o?.csMember??null,I=A(null),P=A(!0),[Q,W]=z(!1),ae=k[k.length-1],ie=ae?.key,Y=(()=>{const S=ae;return!!S&&(S.type==="out"||S.type==="intro"||S.type==="msg"&&S.m.from==="me")})(),K=S=>{const oe=I.current;oe&&oe.scrollTo({top:oe.scrollHeight,behavior:S&&Ft()?"smooth":"auto"})},H=A(!1);L(()=>{if(!H.current){H.current=!0,K(!1);return}P.current||Y?K(!0):W(!0)},[ie,k.length]),L(()=>{d&&P.current&&K(!0)},[d]),L(()=>{i.open&&K(!1)},[i.open]);const X=m.name.trim().split(/\s+/)[0];return s(B,{children:[s("header",{class:"dc-head dc-head--compact",children:[i.canGoBack&&s("button",{class:"dc-hbtn","aria-label":"All conversations",onClick:e.goHome,children:s(O,{name:"left",size:22})}),s(Us,{memberKey:y?`${y.displayName}:${y.status}`:`g:${h?.length??"?"}`,children:y?s(B,{children:[s(he,{member:y,size:38,withStatus:!0}),s("div",{class:"tx",children:[s("div",{class:"t",children:y.displayName}),s("div",{class:"s",children:s("span",{children:[p.name?`${p.name} · `:"",ls[y.status]]})})]})]}):s(B,{children:[s(Ne,{size:38,dot:h?h.length?"online":"offline":null}),s("div",{class:"tx",children:[s("div",{class:"t",children:p.name||"Support"}),s("div",{class:"s",children:h&&h.length>0?s(B,{children:[s("span",{class:"mini",children:jt(h).map(S=>s(he,{member:S,size:16},S.displayName))}),s("span",{children:Ht(h)})]}):s("span",{children:w?"Away · we'll reply as soon as we can":"We typically reply within a few minutes"})})]})]})}),s(zr,{})]}),s(Ps,{}),s("div",{class:"dc-scroll-wrap",children:[s("div",{class:"dc-scroll",ref:I,role:"log","aria-live":"polite",onScroll:()=>{const S=I.current;S&&(P.current=S.scrollHeight-S.scrollTop-S.clientHeight<90,P.current&&Q&&W(!1))},children:[_&&s("div",{class:"dc-welcome",children:[s("div",{class:"stack",children:h&&h.length>0?jt(h).map(S=>s(he,{member:S,size:44,withStatus:!0},S.displayName)):s(Ne,{size:48})}),s("h3",{children:X&&m.verifiedUserId?`Hi ${X}, how can we help?`:"How can we help?"}),s("p",{children:w?p.offline_message||qt:h&&h.length?`${Ht(h)}. We typically reply within a few minutes.`:"We typically reply within a few minutes."})]}),s(xs,{items:k,member:y}),d&&!T&&s(Ds,{name:y?.displayName??"Support",avatar:y?.displayAvatarURL})]}),Q&&s("button",{class:"dc-jump",onClick:()=>{K(!0),W(!1)},children:[s(O,{name:"down",size:16})," New message"]})]}),s(Rs,{closed:T,paused:!u&&o?.status!=="open",placeholder:w?"Leave a message…":`Message ${p.name||"us"}…`})]})}function Us({memberKey:t,children:e}){const n=A(null),r=A(!0);return L(()=>{if(r.current){r.current=!1;return}M(n.current,[{opacity:0,transform:"translateY(6px)"},{opacity:1,transform:"none"}],{duration:340})},[t]),s("div",{class:"dc-head-id",ref:n,children:e})}function Ds({name:t,avatar:e}){const n=A(null);return L(()=>{n.current&&(n.current.style.transformOrigin="bottom left"),M(n.current,[{opacity:0,transform:"translateY(8px) scale(.9)"},{opacity:1,transform:"none"}],{duration:380,easing:G.spring})},[]),s("div",{class:"dc-typing",ref:n,role:"status","aria-label":`${t} is typing`,children:[s(fe,{name:t,url:e,size:28}),s("div",{class:"dots",children:[s("i",{}),s("i",{}),s("i",{})]})]})}function Ps(){const t=j(a=>a.connection),[e,n]=z("none"),r=A(t),i=A(null);ue(()=>{let a;return t==="down"?n("down"):t==="up"&&r.current==="down"?(n("back"),a=setTimeout(()=>n("none"),2200)):t==="off"&&n("none"),r.current=t,()=>clearTimeout(a)},[t]);const o=e!=="none";return L(()=>{o&&M(i.current,[{opacity:0,transform:"translateY(-100%)"},{opacity:1,transform:"none"}],{duration:300})},[o]),e==="none"?null:s("div",{ref:i,class:`dc-conn ${e==="down"?"is-down":"is-up"}`,role:"status",children:e==="down"?s(B,{children:[s("span",{class:"dc-spin"})," Connection lost. Reconnecting…"]}):s(B,{children:[s(O,{name:"check",size:14})," Back online"]})})}function Bs(){const{actions:t}=V(),e=j(c=>c.lightbox),n=A(null),r=A(null),i=A(!1),o=c=>{const d=e?.from,p=r.current;if(!d||!p||!Ft())return null;const m=p.getBoundingClientRect();if(!m.width)return null;const h=[{transform:`translate(${d.left-m.left}px, ${d.top-m.top}px) scale(${d.width/m.width}, ${d.height/m.height})`,borderRadius:"28px"},{transform:"none",borderRadius:"10px"}];return p.animate(c?h.reverse():h,{duration:c?320:460,easing:G.out,fill:c?"forwards":"backwards"})},a=()=>{if(i.current)return;i.current=!0;const c=o(!0);n.current?.querySelectorAll(".bd, .bar").forEach(d=>d.animate([{opacity:1},{opacity:0}],{duration:240,fill:"forwards"})),c?c.onfinish=()=>t.closeLightbox():t.closeLightbox()};return L(()=>{if(!e)return;i.current=!1,M(n.current?.querySelector(".bd"),[{opacity:0},{opacity:1}],{duration:300}),M(n.current?.querySelector(".bar"),[{opacity:0,transform:"translateY(-8px)"},{opacity:1,transform:"none"}],{duration:300,delay:120});const c=r.current;c?.complete?o(!1):c&&(c.onload=()=>o(!1))},[e]),ue(()=>{if(!e)return;const c=d=>{d.key==="Escape"&&(d.preventDefault(),d.stopPropagation(),a())};return document.addEventListener("keydown",c,!0),()=>document.removeEventListener("keydown",c,!0)},[e]),e?s("div",{class:"dc-lightbox",ref:n,role:"dialog","aria-label":e.name,children:[s("div",{class:"bd",onClick:a}),s("div",{class:"bar",children:[s("span",{children:e.name}),s("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",children:[s(O,{name:"ext",size:15})," Open original"]}),s("button",{class:"x","aria-label":"Close",onClick:a,children:s(O,{name:"x",size:18})})]}),s("div",{class:"pic",onClick:a,children:s("img",{ref:r,src:e.url,alt:e.name})})]}):null}function zs(){const{boot:t,dark:e,guild:n,available:r}=j(a=>({boot:a.boot,dark:a.dark,guild:a.guild,available:rr(a)})),i=nt(()=>Xo({primary:n.primary_color,gradient:n.gradient_color,headerText:n.header_text_color,dark:e}),[n.primary_color,n.gradient_color,n.header_text_color,e]),o=Object.entries(i.vars).map(([a,c])=>`${a}:${c}`).join(";");return Fs(),t!=="ready"||!r?null:s("div",{class:"dc","data-theme":e?"dark":"light","data-pos":n.widget_position==="bottom-left"?"left":"right","data-flat":i.flat?"":void 0,style:o,children:[s(Hs,{}),s(qs,{}),s(js,{}),s(Bs,{})]})}function Fs(){const{open:t,unread:e}=j(i=>({open:i.open,unread:ir(i.conversations,i.lastReadAt)})),n=as(),r=e>0&&(!t||!n);ue(()=>{if(!r)return;const i=`(${e}) New message${e>1?"s":""}`;let o=document.title,a=!1;const c=()=>{!a&&document.title!==i&&(o=document.title),a=!a,document.title=a?i:o};c();const d=setInterval(c,2500);return()=>{clearInterval(d),document.title===i&&(document.title=o)}},[r,e])}function js(){const{actions:t}=V(),{open:e,unread:n}=j(c=>({open:c.open,unread:ir(c.conversations,c.lastReadAt)})),r=A(null),i=A(null),o=A(n);L(()=>{M(r.current,[{opacity:0,transform:"scale(.4)"},{opacity:1,transform:"none"}],{duration:520,delay:120,easing:G.spring})},[]),L(()=>{n>o.current&&M(i.current,[{transform:"scale(0)"},{transform:"scale(1.25)",offset:.6},{transform:"scale(1)"}],{duration:420}),o.current=n},[n]);const a=n>0&&!e;return s("button",{ref:r,class:`dc-launcher${e?" is-open":""}${a?" has-unread":""}`,"aria-label":e?"Close chat":a?`Open chat, ${n} unread`:"Open chat","aria-expanded":e,onClick:t.toggle,children:[s("span",{class:"ic ic-chat",children:s(is,{})}),s("span",{class:"ic ic-close",children:s(O,{name:"down",size:24})}),a&&s("span",{class:"dc-badge",ref:i,"aria-hidden":"true",children:n>99?"99+":n})]})}function Hs(){const{actions:t}=V(),e=j(u=>{if(!u.preview||u.open)return null;const h=u.conversations[u.preview.threadId],w=h?.messages.find(x=>x.key===u.preview.key&&!x.deleted);return w?{threadId:h.threadId,message:w,member:h.csMember}:null}),n=A(null),r=A(e);e&&(r.current=e);const i=ss(!!e,n,[{opacity:0,transform:"translateY(12px) scale(.94)"},{opacity:1,transform:"none"}],[{opacity:1},{opacity:0,transform:"translateY(6px) scale(.97)"}],{enter:{duration:460,easing:G.spring}}),o=e??r.current;if(!i||!o)return null;const{message:a,member:c,threadId:d}=o,p=c?.displayName??a.authorName,m=a.text?Lr(Mr(a.text),a.emojis):a.attachments.some(u=>!u.contentType?.startsWith("image/"))?"📄 Sent a file":"📷 Sent an image";return s("div",{ref:n,class:"dc-preview",role:"button",tabIndex:0,"aria-label":`New message from ${p}`,onClick:()=>{t.openConversation(d),t.open()},onKeyDown:u=>{u.key==="Enter"&&u.currentTarget.click()},children:[c?s(he,{member:c,size:34,withStatus:!0}):s(fe,{name:p,size:34}),s("div",{style:"min-width:0",children:[s("div",{class:"who",children:s("b",{children:p})}),s("div",{class:"txt",dangerouslySetInnerHTML:{__html:m}})]}),s("button",{class:"x","aria-label":"Dismiss",onClick:u=>{u.stopPropagation(),t.dismissPreview()},children:s(O,{name:"x",size:12})})]})}function qs(){const{actions:t}=V(),{open:e,view:n}=j(h=>({open:h.open,view:h.view})),r=A(null),[i,o]=z(e),[a,c]=z(e),[d,p]=z(!1),m=A(0);if(L(()=>{if(e){o(!0),c(!0);return}if(!a)return;const h=r.current?.animate([{opacity:1,transform:"none"},{opacity:0,transform:"translateY(10px) scale(.96)"}],{duration:170,easing:G.in});if(!h){c(!1);return}return h.onfinish=()=>c(!1),()=>h.cancel()},[e]),L(()=>{if(!e||!a)return;const h=r.current;M(h,[{opacity:0},{opacity:1}],{duration:180}),M(h,[{transform:"translateY(18px) scale(.92)"},{transform:"none"}],{duration:520,easing:G.spring,composite:"add"}),h?.querySelectorAll(".dc-hero > *, .dc-home-body > *, .dc-welcome > *, .dc-head-id, .dc-composer").forEach((w,x)=>M(w,[{opacity:0,transform:"translateY(8px)"},{opacity:1,transform:"none"}],{duration:420,delay:60+x*35}))},[e,a]),!i)return null;const u=h=>n==="chat"&&!!h.dataTransfer?.types.includes("Files");return s("section",{ref:r,class:"dc-panel",role:"dialog","aria-label":"Chat",hidden:!a,onKeyDown:h=>{h.key==="Escape"&&!h.defaultPrevented&&t.close()},onDragEnter:h=>{u(h)&&(h.preventDefault(),m.current++===0&&p(!0))},onDragOver:h=>{d&&h.preventDefault()},onDragLeave:()=>{m.current>0&&--m.current===0&&p(!1)},onDrop:h=>{d&&(h.preventDefault(),m.current=0,p(!1),t.addFiles([...h.dataTransfer?.files??[]]))},children:[s(Ws,{}),d&&s(Vs,{})]})}function Vs(){const t=A(null);return L(()=>{M(t.current,[{opacity:0,transform:"scale(.98)"},{opacity:1,transform:"none"}],{duration:200})},[]),s("div",{class:"dc-drop",ref:t,children:[s("div",{class:"ic",children:s(O,{name:"upload",size:26})}),s("b",{children:"Drop to attach"}),s("small",{children:"Images or PDFs, up to 10 MB each"})]})}function Ws(){const{store:t}=V(),{view:e,nav:n}=j(a=>({view:a.view,nav:a.nav})),r=`${e}:${n}`,[i,o]=z(()=>[{key:r,view:e,threadId:t.get().activeThreadId}]);return L(()=>{o(a=>a[a.length-1].key===r?a:[{...a[a.length-1],threadId:t.get().navPrev},{key:r,view:e,threadId:null}])},[r]),s("div",{class:"dc-views",children:i.map((a,c)=>s(Ys,{leaving:c<i.length-1,animateIn:i.length>1,back:e==="home",onGone:()=>o(d=>d.filter(p=>p.key!==a.key)),children:a.view==="home"?s(ms,{}):s(Ms,{frozenThreadId:c<i.length-1?a.threadId:void 0})},a.key))})}function Ys({leaving:t,animateIn:e,back:n,onGone:r,children:i}){const o=A(null),a=n?-28:28;return L(()=>{e&&M(o.current,[{transform:`translateX(${a}%)`,opacity:0},{transform:"none",opacity:1}],{duration:340})},[]),L(()=>{if(!t)return;const c=M(o.current,[{transform:"none",opacity:1},{transform:`translateX(${-a}%)`,opacity:0}],{duration:300,fill:"forwards"}),d=setTimeout(r,340);return c&&(c.onfinish=r),()=>clearTimeout(d)},[t]),s("div",{ref:o,class:"dc-view",inert:t,style:t?"pointer-events:none":void 0,children:i})}function Kr(){if(document.getElementById("deskcord-root"))return;const t=mi();if(!t)return;const e=Wo(t),n=window.deskcord;n.openChatbox=()=>e.actions.open(),n.closeChatbox=()=>e.actions.close(),n.identify=e.identify,n.logout=()=>{e.logout()};let r=t.theme;const i=matchMedia("(prefers-color-scheme: dark)"),o=()=>e.actions.setDark(r==="dark"||r==="auto"&&i.matches);n.setTheme=m=>{if(m!=="light"&&m!=="dark"&&m!=="auto"){console.error(`[Deskcord] setTheme: unknown theme "${String(m)}" (use "light", "dark" or "auto").`);return}r=m,o()},o(),i.addEventListener("change",o);const a=document.createElement("div");a.id="deskcord-root",a.style.cssText="position:fixed;top:0;left:0;width:0;height:0;z-index:2147483000;",document.body.appendChild(a);const c=a.attachShadow({mode:"open"}),d=document.createElement("style");d.textContent=hi,c.appendChild(d);const p=document.createElement("div");c.appendChild(p),pi(s(Dr.Provider,{value:e,children:s(zs,{})}),p),e.boot()}document.body?Kr():document.addEventListener("DOMContentLoaded",Kr,{once:!0})})();
|
|
1
|
+
(function(){"use strict";var ze,$,tn,de,nn,rn,dt,on,ut,pt,ft,sn,Ae={},an=[],ai=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,ht=Array.isArray;function ae(t,e){for(var n in e)t[n]=e[n];return t}function gt(t){t&&t.parentNode&&t.parentNode.removeChild(t)}function ci(t,e,n){var r,i,o,a={};for(o in e)o=="key"?r=e[o]:o=="ref"?i=e[o]:a[o]=e[o];if(arguments.length>2&&(a.children=arguments.length>3?ze.call(arguments,2):n),typeof t=="function"&&t.defaultProps!=null)for(o in t.defaultProps)a[o]===void 0&&(a[o]=t.defaultProps[o]);return Pe(t,a,r,i,null)}function Pe(t,e,n,r,i){var o={type:t,props:e,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++tn,__i:-1,__u:0};return i==null&&$.vnode!=null&&$.vnode(o),o}function H(t){return t.children}function Be(t,e){this.props=t,this.context=e}function me(t,e){if(e==null)return t.__?me(t.__,t.__i+1):null;for(var n;e<t.__k.length;e++)if((n=t.__k[e])!=null&&n.__e!=null)return n.__e;return typeof t.type=="function"?me(t):null}function cn(t){var e,n;if((t=t.__)!=null&&t.__c!=null){for(t.__e=t.__c.base=null,e=0;e<t.__k.length;e++)if((n=t.__k[e])!=null&&n.__e!=null){t.__e=t.__c.base=n.__e;break}return cn(t)}}function mt(t){(!t.__d&&(t.__d=!0)&&de.push(t)&&!Fe.__r++||nn!==$.debounceRendering)&&((nn=$.debounceRendering)||rn)(Fe)}function Fe(){var t,e,n,r,i,o,a,c;for(de.sort(dt);t=de.shift();)t.__d&&(e=de.length,r=void 0,o=(i=(n=t).__v).__e,a=[],c=[],n.__P&&((r=ae({},i)).__v=i.__v+1,$.vnode&&$.vnode(r),vt(n.__P,r,i,n.__n,n.__P.namespaceURI,32&i.__u?[o]:null,a,o??me(i),!!(32&i.__u),c),r.__v=i.__v,r.__.__k[r.__i]=r,fn(a,r,c),r.__e!=o&&cn(r)),de.length>e&&de.sort(dt));Fe.__r=0}function ln(t,e,n,r,i,o,a,c,d,u,g){var p,h,x,w,k,_,A=r&&r.__k||an,y=e.length;for(d=li(n,e,A,d,y),p=0;p<y;p++)(x=n.__k[p])!=null&&(h=x.__i===-1?Ae:A[x.__i]||Ae,x.__i=p,_=vt(t,x,h,i,o,a,c,d,u,g),w=x.__e,x.ref&&h.ref!=x.ref&&(h.ref&&yt(h.ref,null,x),g.push(x.ref,x.__c||w,x)),k==null&&w!=null&&(k=w),4&x.__u||h.__k===x.__k?d=dn(x,d,t):typeof x.type=="function"&&_!==void 0?d=_:w&&(d=w.nextSibling),x.__u&=-7);return n.__e=k,d}function li(t,e,n,r,i){var o,a,c,d,u,g=n.length,p=g,h=0;for(t.__k=new Array(i),o=0;o<i;o++)(a=e[o])!=null&&typeof a!="boolean"&&typeof a!="function"?(d=o+h,(a=t.__k[o]=typeof a=="string"||typeof a=="number"||typeof a=="bigint"||a.constructor==String?Pe(null,a,null,null,null):ht(a)?Pe(H,{children:a},null,null,null):a.constructor===void 0&&a.__b>0?Pe(a.type,a.props,a.key,a.ref?a.ref:null,a.__v):a).__=t,a.__b=t.__b+1,c=null,(u=a.__i=di(a,n,d,p))!==-1&&(p--,(c=n[u])&&(c.__u|=2)),c==null||c.__v===null?(u==-1&&h--,typeof a.type!="function"&&(a.__u|=4)):u!=d&&(u==d-1?h--:u==d+1?h++:(u>d?h--:h++,a.__u|=4))):t.__k[o]=null;if(p)for(o=0;o<g;o++)(c=n[o])!=null&&!(2&c.__u)&&(c.__e==r&&(r=me(c)),hn(c,c));return r}function dn(t,e,n){var r,i;if(typeof t.type=="function"){for(r=t.__k,i=0;r&&i<r.length;i++)r[i]&&(r[i].__=t,e=dn(r[i],e,n));return e}t.__e!=e&&(e&&t.type&&!n.contains(e)&&(e=me(t)),n.insertBefore(t.__e,e||null),e=t.__e);do e=e&&e.nextSibling;while(e!=null&&e.nodeType==8);return e}function di(t,e,n,r){var i,o,a=t.key,c=t.type,d=e[n];if(d===null||d&&a==d.key&&c===d.type&&!(2&d.__u))return n;if(r>(d!=null&&!(2&d.__u)?1:0))for(i=n-1,o=n+1;i>=0||o<e.length;){if(i>=0){if((d=e[i])&&!(2&d.__u)&&a==d.key&&c===d.type)return i;i--}if(o<e.length){if((d=e[o])&&!(2&d.__u)&&a==d.key&&c===d.type)return o;o++}}return-1}function un(t,e,n){e[0]=="-"?t.setProperty(e,n??""):t[e]=n==null?"":typeof n!="number"||ai.test(e)?n:n+"px"}function He(t,e,n,r,i){var o;e:if(e=="style")if(typeof n=="string")t.style.cssText=n;else{if(typeof r=="string"&&(t.style.cssText=r=""),r)for(e in r)n&&e in n||un(t.style,e,"");if(n)for(e in n)r&&n[e]===r[e]||un(t.style,e,n[e])}else if(e[0]=="o"&&e[1]=="n")o=e!=(e=e.replace(on,"$1")),e=e.toLowerCase()in t||e=="onFocusOut"||e=="onFocusIn"?e.toLowerCase().slice(2):e.slice(2),t.l||(t.l={}),t.l[e+o]=n,n?r?n.u=r.u:(n.u=ut,t.addEventListener(e,o?ft:pt,o)):t.removeEventListener(e,o?ft:pt,o);else{if(i=="http://www.w3.org/2000/svg")e=e.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(e!="width"&&e!="height"&&e!="href"&&e!="list"&&e!="form"&&e!="tabIndex"&&e!="download"&&e!="rowSpan"&&e!="colSpan"&&e!="role"&&e!="popover"&&e in t)try{t[e]=n??"";break e}catch{}typeof n=="function"||(n==null||n===!1&&e[4]!="-"?t.removeAttribute(e):t.setAttribute(e,e=="popover"&&n==1?"":n))}}function pn(t){return function(e){if(this.l){var n=this.l[e.type+t];if(e.t==null)e.t=ut++;else if(e.t<n.u)return;return n($.event?$.event(e):e)}}}function vt(t,e,n,r,i,o,a,c,d,u){var g,p,h,x,w,k,_,A,y,L,E,O,P,V,te,F,J,Y=e.type;if(e.constructor!==void 0)return null;128&n.__u&&(d=!!(32&n.__u),o=[c=e.__e=n.__e]),(g=$.__b)&&g(e);e:if(typeof Y=="function")try{if(A=e.props,y="prototype"in Y&&Y.prototype.render,L=(g=Y.contextType)&&r[g.__c],E=g?L?L.props.value:g.__:r,n.__c?_=(p=e.__c=n.__c).__=p.__E:(y?e.__c=p=new Y(A,E):(e.__c=p=new Be(A,E),p.constructor=Y,p.render=pi),L&&L.sub(p),p.props=A,p.state||(p.state={}),p.context=E,p.__n=r,h=p.__d=!0,p.__h=[],p._sb=[]),y&&p.__s==null&&(p.__s=p.state),y&&Y.getDerivedStateFromProps!=null&&(p.__s==p.state&&(p.__s=ae({},p.__s)),ae(p.__s,Y.getDerivedStateFromProps(A,p.__s))),x=p.props,w=p.state,p.__v=e,h)y&&Y.getDerivedStateFromProps==null&&p.componentWillMount!=null&&p.componentWillMount(),y&&p.componentDidMount!=null&&p.__h.push(p.componentDidMount);else{if(y&&Y.getDerivedStateFromProps==null&&A!==x&&p.componentWillReceiveProps!=null&&p.componentWillReceiveProps(A,E),!p.__e&&(p.shouldComponentUpdate!=null&&p.shouldComponentUpdate(A,p.__s,E)===!1||e.__v==n.__v)){for(e.__v!=n.__v&&(p.props=A,p.state=p.__s,p.__d=!1),e.__e=n.__e,e.__k=n.__k,e.__k.some(function(Z){Z&&(Z.__=e)}),O=0;O<p._sb.length;O++)p.__h.push(p._sb[O]);p._sb=[],p.__h.length&&a.push(p);break e}p.componentWillUpdate!=null&&p.componentWillUpdate(A,p.__s,E),y&&p.componentDidUpdate!=null&&p.__h.push(function(){p.componentDidUpdate(x,w,k)})}if(p.context=E,p.props=A,p.__P=t,p.__e=!1,P=$.__r,V=0,y){for(p.state=p.__s,p.__d=!1,P&&P(e),g=p.render(p.props,p.state,p.context),te=0;te<p._sb.length;te++)p.__h.push(p._sb[te]);p._sb=[]}else do p.__d=!1,P&&P(e),g=p.render(p.props,p.state,p.context),p.state=p.__s;while(p.__d&&++V<25);p.state=p.__s,p.getChildContext!=null&&(r=ae(ae({},r),p.getChildContext())),y&&!h&&p.getSnapshotBeforeUpdate!=null&&(k=p.getSnapshotBeforeUpdate(x,w)),c=ln(t,ht(F=g!=null&&g.type===H&&g.key==null?g.props.children:g)?F:[F],e,n,r,i,o,a,c,d,u),p.base=e.__e,e.__u&=-161,p.__h.length&&a.push(p),_&&(p.__E=p.__=null)}catch(Z){if(e.__v=null,d||o!=null)if(Z.then){for(e.__u|=d?160:128;c&&c.nodeType==8&&c.nextSibling;)c=c.nextSibling;o[o.indexOf(c)]=null,e.__e=c}else for(J=o.length;J--;)gt(o[J]);else e.__e=n.__e,e.__k=n.__k;$.__e(Z,e,n)}else o==null&&e.__v==n.__v?(e.__k=n.__k,e.__e=n.__e):c=e.__e=ui(n.__e,e,n,r,i,o,a,d,u);return(g=$.diffed)&&g(e),128&e.__u?void 0:c}function fn(t,e,n){for(var r=0;r<n.length;r++)yt(n[r],n[++r],n[++r]);$.__c&&$.__c(e,t),t.some(function(i){try{t=i.__h,i.__h=[],t.some(function(o){o.call(i)})}catch(o){$.__e(o,i.__v)}})}function ui(t,e,n,r,i,o,a,c,d){var u,g,p,h,x,w,k,_=n.props,A=e.props,y=e.type;if(y=="svg"?i="http://www.w3.org/2000/svg":y=="math"?i="http://www.w3.org/1998/Math/MathML":i||(i="http://www.w3.org/1999/xhtml"),o!=null){for(u=0;u<o.length;u++)if((x=o[u])&&"setAttribute"in x==!!y&&(y?x.localName==y:x.nodeType==3)){t=x,o[u]=null;break}}if(t==null){if(y==null)return document.createTextNode(A);t=document.createElementNS(i,y,A.is&&A),c&&($.__m&&$.__m(e,o),c=!1),o=null}if(y===null)_===A||c&&t.data===A||(t.data=A);else{if(o=o&&ze.call(t.childNodes),_=n.props||Ae,!c&&o!=null)for(_={},u=0;u<t.attributes.length;u++)_[(x=t.attributes[u]).name]=x.value;for(u in _)if(x=_[u],u!="children"){if(u=="dangerouslySetInnerHTML")p=x;else if(!(u in A)){if(u=="value"&&"defaultValue"in A||u=="checked"&&"defaultChecked"in A)continue;He(t,u,null,x,i)}}for(u in A)x=A[u],u=="children"?h=x:u=="dangerouslySetInnerHTML"?g=x:u=="value"?w=x:u=="checked"?k=x:c&&typeof x!="function"||_[u]===x||He(t,u,x,_[u],i);if(g)c||p&&(g.__html===p.__html||g.__html===t.innerHTML)||(t.innerHTML=g.__html),e.__k=[];else if(p&&(t.innerHTML=""),ln(t,ht(h)?h:[h],e,n,r,y=="foreignObject"?"http://www.w3.org/1999/xhtml":i,o,a,o?o[0]:n.__k&&me(n,0),c,d),o!=null)for(u=o.length;u--;)gt(o[u]);c||(u="value",y=="progress"&&w==null?t.removeAttribute("value"):w!==void 0&&(w!==t[u]||y=="progress"&&!w||y=="option"&&w!==_[u])&&He(t,u,w,_[u],i),u="checked",k!==void 0&&k!==t[u]&&He(t,u,k,_[u],i))}return t}function yt(t,e,n){try{if(typeof t=="function"){var r=typeof t.__u=="function";r&&t.__u(),r&&e==null||(t.__u=t(e))}else t.current=e}catch(i){$.__e(i,n)}}function hn(t,e,n){var r,i;if($.unmount&&$.unmount(t),(r=t.ref)&&(r.current&&r.current!==t.__e||yt(r,null,e)),(r=t.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(o){$.__e(o,e)}r.base=r.__P=null}if(r=t.__k)for(i=0;i<r.length;i++)r[i]&&hn(r[i],e,n||typeof t.type!="function");n||gt(t.__e),t.__c=t.__=t.__e=void 0}function pi(t,e,n){return this.constructor(t,n)}function fi(t,e,n){var r,i,o,a;e==document&&(e=document.documentElement),$.__&&$.__(t,e),i=(r=typeof n=="function")?null:e.__k,o=[],a=[],vt(e,t=(!r&&n||e).__k=ci(H,null,[t]),i||Ae,Ae,e.namespaceURI,!r&&n?[n]:i?null:e.firstChild?ze.call(e.childNodes):null,o,!r&&n?n:i?i.__e:e.firstChild,r,a),fn(o,t,a)}function gn(t,e){var n={__c:e="__cC"+sn++,__:t,Consumer:function(r,i){return r.children(i)},Provider:function(r){var i,o;return this.getChildContext||(i=new Set,(o={})[e]=this,this.getChildContext=function(){return o},this.componentWillUnmount=function(){i=null},this.shouldComponentUpdate=function(a){this.props.value!==a.value&&i.forEach(function(c){c.__e=!0,mt(c)})},this.sub=function(a){i.add(a);var c=a.componentWillUnmount;a.componentWillUnmount=function(){i&&i.delete(a),c&&c.call(a)}}),r.children}};return n.Provider.__=n.Consumer.contextType=n}ze=an.slice,$={__e:function(t,e,n,r){for(var i,o,a;e=e.__;)if((i=e.__c)&&!i.__)try{if((o=i.constructor)&&o.getDerivedStateFromError!=null&&(i.setState(o.getDerivedStateFromError(t)),a=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(t,r||{}),a=i.__d),a)return i.__E=i}catch(c){t=c}throw t}},tn=0,Be.prototype.setState=function(t,e){var n;n=this.__s!=null&&this.__s!==this.state?this.__s:this.__s=ae({},this.state),typeof t=="function"&&(t=t(ae({},n),this.props)),t&&ae(n,t),t!=null&&this.__v&&(e&&this._sb.push(e),mt(this))},Be.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),mt(this))},Be.prototype.render=H,de=[],rn=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,dt=function(t,e){return t.__v.__b-e.__v.__b},Fe.__r=0,on=/(PointerCapture)$|Capture$/i,ut=0,pt=pn(!1),ft=pn(!0),sn=0;var hi=0;function s(t,e,n,r,i,o){e||(e={});var a,c,d=e;if("ref"in d)for(c in d={},e)c=="ref"?a=e[c]:d[c]=e[c];var u={type:t,props:d,key:n,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--hi,__i:-1,__u:0,__source:i,__self:o};if(typeof t=="function"&&(a=t.defaultProps))for(c in a)d[c]===void 0&&(d[c]=a[c]);return $.vnode&&$.vnode(u),u}const gi=':host{all:initial}.dc{--dc-accent: #5865f2;--dc-accent-2: #4a55cc;--dc-on-accent: #fff;--dc-on-grad: #fff;--dc-accent-soft: rgba(88,101,242,.14);--dc-accent-text: #4a55cc;--w-bg: #ffffff;--w-raised: #ffffff;--w-sunken: #f2f3f7;--w-bubble: #f0f1f5;--w-line: rgba(18,22,33,.08);--w-line-strong: rgba(18,22,33,.15);--w-fg: #14171f;--w-fg-2: #3b404c;--w-muted: #6a7080;--w-faint: #9499a5;--w-online: #23a55a;--w-idle: #f0b232;--w-dnd: #f23f43;--w-offline: #80848e;--w-danger: #e5484d;--w-success: #1f9d55;--w-warn: #c98a0c;--w-badge: #f23f43;--w-shadow: 0 1px 2px rgba(16,20,30,.06), 0 10px 28px -8px rgba(16,20,30,.18), 0 30px 70px -18px rgba(16,20,30,.28);--w-card-shadow: 0 1px 2px rgba(16,20,30,.05), 0 6px 18px -10px rgba(16,20,30,.2);--ease-out: cubic-bezier(.22,1,.36,1);--ease-spring: cubic-bezier(.34,1.45,.64,1);--font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;--mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;--edge: 20px;position:fixed;inset:0;z-index:2147483000;pointer-events:none;font-family:var(--font);color:var(--w-fg);font-size:14px;line-height:1.4;text-align:left;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;color-scheme:light}.dc[data-theme=dark]{--w-bg: #232428;--w-raised: #2b2d31;--w-sunken: #1c1d21;--w-bubble: #34363c;--w-line: rgba(255,255,255,.07);--w-line-strong: rgba(255,255,255,.13);--w-fg: #f2f3f5;--w-fg-2: #d5d7dc;--w-muted: #a4a8b2;--w-faint: #7d828d;--w-shadow: 0 1px 2px rgba(0,0,0,.3), 0 14px 34px -8px rgba(0,0,0,.55), 0 30px 80px -18px rgba(0,0,0,.6);--w-card-shadow: 0 1px 2px rgba(0,0,0,.25);color-scheme:dark}.dc *,.dc *:before,.dc *:after{box-sizing:border-box}:where(.dc) button{font:inherit;color:inherit;margin:0}:where(.dc) :is(p,h1,h2,h3,h4,ul,ol,form){margin:0;padding:0}.dc :focus-visible{outline:2px solid var(--dc-accent);outline-offset:2px}.dc [hidden]{display:none!important}.dc svg{display:block;flex:none}.dc img{max-width:100%}.dc-sr{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}.dc-launcher{pointer-events:auto;position:absolute;bottom:calc(var(--edge) + env(safe-area-inset-bottom,0px));right:var(--edge);width:56px;height:56px;border-radius:50%;border:0;padding:0;cursor:pointer;background:linear-gradient(145deg,var(--dc-accent) 0%,var(--dc-accent-2) 100%);color:var(--dc-on-grad);box-shadow:0 2px 4px #10141e1f,0 10px 26px -6px color-mix(in srgb,var(--dc-accent) 60%,transparent);transition:transform .35s var(--ease-spring),opacity .2s}.dc[data-pos=left] .dc-launcher{right:auto;left:var(--edge)}.dc-launcher:hover{transform:translateY(-2px) scale(1.04)}.dc-launcher:active{transform:scale(.93);transition-duration:.1s}.dc-launcher .ic{position:absolute;inset:0;display:grid;place-items:center;transition:transform .4s var(--ease-spring),opacity .2s}.dc-launcher .ic-close{opacity:0;transform:rotate(-90deg) scale(.6)}.dc-launcher.is-open .ic-chat{opacity:0;transform:rotate(90deg) scale(.6)}.dc-launcher.is-open .ic-close{opacity:1;transform:none}.dc-launcher.has-unread:after{content:"";position:absolute;inset:0;border-radius:50%;border:2px solid var(--dc-accent);animation:dc-halo 2.4s var(--ease-out) infinite;pointer-events:none}@keyframes dc-halo{0%{transform:scale(1);opacity:.7}70%,to{transform:scale(1.55);opacity:0}}.dc-badge{position:absolute;top:-3px;right:-3px;min-width:22px;height:22px;padding:0 6px;border-radius:11px;background:var(--w-badge);color:#fff;font:700 12px/22px var(--font);text-align:center;font-variant-numeric:tabular-nums;box-shadow:0 0 0 2.5px #fff}.dc-preview{pointer-events:auto;position:absolute;right:var(--edge);bottom:calc(var(--edge) + 70px + env(safe-area-inset-bottom,0px));width:300px;max-width:calc(100% - 2 * var(--edge));background:var(--w-raised);color:var(--w-fg);border:1px solid var(--w-line);border-radius:18px 18px 6px;padding:12px 14px;box-shadow:var(--w-shadow);cursor:pointer;display:grid;grid-template-columns:34px 1fr;gap:10px;transform-origin:bottom right}.dc[data-pos=left] .dc-preview{right:auto;left:var(--edge);border-radius:18px 18px 18px 6px;transform-origin:bottom left}.dc-preview .who{font-size:12.5px;color:var(--w-muted);margin-bottom:2px}.dc-preview .who b{color:var(--w-fg);font-weight:600}.dc-preview .txt{font-size:14px;color:var(--w-fg-2);display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical;overflow:hidden;overflow-wrap:anywhere}.dc-preview .x{position:absolute;top:-8px;right:-8px;width:24px;height:24px;border-radius:50%;border:0;background:var(--w-fg);color:var(--w-bg);display:grid;place-items:center;cursor:pointer;opacity:0;transition:opacity .15s;padding:0}.dc-preview:hover .x,.dc-preview:focus-within .x{opacity:1}@media (hover: none){.dc-preview .x{opacity:1}}.dc-panel{pointer-events:auto;position:absolute;right:var(--edge);bottom:calc(var(--edge) + 70px + env(safe-area-inset-bottom,0px));width:384px;height:min(680px,calc(100% - 110px));max-width:calc(100% - 2 * var(--edge));background:var(--w-bg);border-radius:22px;box-shadow:var(--w-shadow);border:1px solid var(--w-line);overflow:hidden;display:flex;flex-direction:column;transform-origin:bottom right}.dc[data-pos=left] .dc-panel{right:auto;left:var(--edge);transform-origin:bottom left}.dc[data-theme=dark] .dc-panel{border:0}.dc-views{position:relative;flex:1;min-height:0}.dc-view{position:absolute;inset:0;display:flex;flex-direction:column;background:var(--w-bg)}.dc-head{background:linear-gradient(160deg,var(--dc-accent) 0%,var(--dc-accent-2) 100%);color:var(--dc-on-grad);position:relative;flex:none;isolation:isolate}.dc-head:before{content:"";position:absolute;inset:0;z-index:-1;pointer-events:none;background:radial-gradient(120% 90% at 100% 0%,rgba(255,255,255,.22),transparent 55%),radial-gradient(80% 60% at 0% 100%,rgba(0,0,0,.12),transparent 60%)}.dc[data-flat] .dc-head:before{display:none}.dc-hbtn{width:34px;height:34px;border-radius:10px;border:0;background:transparent;display:grid;place-items:center;cursor:pointer;color:inherit;flex:none;padding:0;transition:background .15s,transform .2s var(--ease-spring)}.dc-hbtn:hover{background:color-mix(in srgb,currentColor 16%,transparent)}.dc-hbtn:active{transform:scale(.9)}.dc-hbtn .ic-down{display:none}.dc-head--compact{display:flex;align-items:center;gap:6px;padding:12px 10px;min-height:66px}.dc-head-id{flex:1;min-width:0;display:flex;align-items:center;gap:10px;padding-left:4px}.dc-head-id .tx{min-width:0}.dc-head-id .t{font-weight:650;font-size:15.5px;line-height:1.2;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dc-head-id .s{font-size:12.5px;opacity:.85;display:flex;align-items:center;gap:6px;white-space:nowrap;overflow:hidden;margin-top:1px}.dc-head-id .s span:last-child{overflow:hidden;text-overflow:ellipsis}.dc-head-id .mini{display:flex;flex:none}.dc-head-id .mini .dc-av{margin-left:-5px;box-shadow:0 0 0 1.5px var(--dc-accent)}.dc-head-id .mini .dc-av:first-child{margin-left:0}.dc-av{--s: 28px;width:var(--s);height:var(--s);border-radius:50%;flex:none;position:relative;display:grid;place-items:center;font:650 calc(var(--s) * .4) / 1 var(--font);color:#fff;letter-spacing:-.02em;background:linear-gradient(140deg,hsl(var(--h, 230) 72% 64%),hsl(calc(var(--h, 230) + 28) 62% 46%))}.dc-av img{width:100%;height:100%;border-radius:50%;object-fit:cover;display:block}.dc-av .dot{position:absolute;right:-2px;bottom:-2px;width:calc(var(--s) * .34);height:calc(var(--s) * .34);min-width:9px;min-height:9px;border-radius:50%;box-shadow:0 0 0 2.5px var(--ring, var(--w-bg))}.dot.online{background:var(--w-online)}.dot.idle{background:var(--w-idle)}.dot.dnd{background:var(--w-dnd)}.dot.offline,.dot.invisible{background:var(--w-offline)}.dc-head .dc-av .dot{--ring: var(--dc-accent-2)}.dc-guild{--s: 36px;width:var(--s);height:var(--s);border-radius:calc(var(--s) * .3);background:var(--dc-accent-2);color:var(--dc-on-grad);display:grid;place-items:center;flex:none;position:relative;font:700 calc(var(--s) * .42) / 1 var(--font);box-shadow:0 0 0 1px #ffffff24 inset}.dc-guild img{width:100%;height:100%;object-fit:cover;border-radius:inherit;display:block}.dc-guild .dot{position:absolute;right:-3px;bottom:-3px;width:11px;height:11px;border-radius:50%;box-shadow:0 0 0 2.5px var(--ring, var(--dc-accent-2))}.dc-hero{padding:16px 16px 58px}.dc-hero .top{display:flex;align-items:center;justify-content:space-between}.dc-hero h2{font:700 26px/1.12 var(--font);letter-spacing:-.02em;margin:22px 4px 6px;text-wrap:balance;color:inherit}.dc-hero p{margin:0 4px;font-size:14.5px;opacity:.88;line-height:1.45}.dc-team{display:flex;align-items:center;gap:10px;margin:16px 4px 0;font-size:13px}.dc-team .stack{display:flex}.dc-team .stack .dc-av{--s: 30px;margin-left:-8px;box-shadow:0 0 0 2px var(--dc-accent-2)}.dc-team .stack .dc-av:first-child{margin-left:0}.dc-team .stack .dc-av .dot{--ring: var(--dc-accent-2)}.dc-home-body{flex:1;min-height:0;overflow-y:auto;margin-top:-40px;padding:0 12px 12px;display:flex;flex-direction:column;gap:10px;position:relative;scrollbar-width:thin}.dc-card{background:var(--w-raised);border:1px solid var(--w-line);border-radius:16px;box-shadow:var(--w-card-shadow)}.dc-cta{display:flex;align-items:center;gap:12px;width:100%;padding:14px 14px 14px 16px;text-align:left;cursor:pointer;color:var(--w-fg);transition:transform .25s var(--ease-spring),box-shadow .2s}.dc-cta:hover{transform:translateY(-1px);box-shadow:var(--w-shadow)}.dc-cta .tx{flex:1;min-width:0}.dc-cta b{display:block;font-size:15px;font-weight:650}.dc-cta small{display:block;font-size:13px;color:var(--w-muted);margin-top:2px}.dc-cta .go{width:36px;height:36px;border-radius:50%;background:var(--dc-accent);color:var(--dc-on-accent);display:grid;place-items:center;flex:none;transition:transform .3s var(--ease-spring)}.dc-cta:hover .go{transform:translate(3px)}.dc-cta.is-paused{cursor:default}.dc-cta.is-paused:hover{transform:none;box-shadow:var(--w-card-shadow)}.dc-eyebrow{font-size:11px;font-weight:600;letter-spacing:.07em;text-transform:uppercase;color:var(--w-faint);padding:12px 16px 2px}.dc-list{padding:4px}.dc-conv{display:flex;gap:12px;align-items:center;width:100%;padding:12px 14px 12px 12px;border:0;background:transparent;text-align:left;cursor:pointer;border-radius:12px;color:var(--w-fg);position:relative;transition:background .15s}.dc-conv:hover{background:var(--w-sunken)}.dc-conv .tx{flex:1;min-width:0}.dc-conv .l1{display:flex;gap:8px;align-items:baseline}.dc-conv .l1 b{font-size:14px;font-weight:600;flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dc-conv .l1 time{font-size:12px;color:var(--w-faint);flex:none}.dc-conv .l2{display:block;font-size:13px;color:var(--w-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;margin-top:2px}.dc-conv.is-unread .l2{color:var(--w-fg);font-weight:550}.dc-conv .count{background:var(--w-badge);color:#fff;font:700 11px/20px var(--font);min-width:20px;height:20px;border-radius:10px;text-align:center;padding:0 6px;flex:none}.dc-conv .chev{color:var(--w-faint);flex:none}.dc-list .dc-conv+.dc-conv:before{content:"";position:absolute;left:64px;right:14px;top:0;height:1px;background:var(--w-line)}.dc-pill{display:inline-flex;align-items:center;gap:4px;font-size:11px;font-weight:600;padding:1px 7px;border-radius:999px;background:var(--w-sunken);color:var(--w-muted);margin-right:4px;vertical-align:1px}.dc-pill.ok{color:var(--w-success);background:color-mix(in srgb,var(--w-success) 12%,transparent)}.dc-empty{padding:14px 16px 16px;font-size:13px;color:var(--w-muted)}.dc-empty button{border:0;background:none;padding:0;color:var(--dc-accent-text);font-weight:600;cursor:pointer;text-decoration:underline;text-underline-offset:2px}.dc-skel-row{display:flex;gap:12px;align-items:center;padding:12px}.dc-skel-row i,.dc-skel i{display:block;border-radius:999px;background:linear-gradient(90deg,var(--w-sunken) 0%,var(--w-bubble) 40%,var(--w-sunken) 80%);background-size:300% 100%;animation:dc-shimmer 1.2s linear infinite}.dc-skel-row i:first-child{width:40px;height:40px;flex:none}.dc-skel-row span{flex:1;display:flex;flex-direction:column;gap:7px}.dc-skel-row span i{height:10px;width:60%}.dc-skel-row span i+i{width:85%}@keyframes dc-shimmer{0%{background-position:100% 0}to{background-position:-50% 0}}.dc-conn{overflow:hidden;flex:none;font-size:12.5px;font-weight:550;display:flex;align-items:center;justify-content:center;gap:8px;padding:7px 12px}.dc-conn.is-down{background:color-mix(in srgb,var(--w-warn) 14%,var(--w-bg));color:var(--w-warn)}.dc-conn.is-up{background:color-mix(in srgb,var(--w-success) 13%,var(--w-bg));color:var(--w-success)}.dc-spin{width:13px;height:13px;border-radius:50%;border:2px solid currentColor;border-right-color:transparent;animation:dc-rot .8s linear infinite}@keyframes dc-rot{to{transform:rotate(360deg)}}.dc-scroll-wrap{flex:1;min-height:0;position:relative;display:flex;flex-direction:column}.dc-scroll{flex:1;min-height:0;overflow-y:auto;overflow-x:hidden;position:relative;scrollbar-width:thin;scrollbar-color:var(--w-line-strong) transparent;overscroll-behavior:contain}.dc-welcome{padding:34px 28px 10px;text-align:center;display:flex;flex-direction:column;align-items:center;gap:6px}.dc-welcome .stack{display:flex;margin-bottom:8px}.dc-welcome .stack .dc-av{--s: 44px;margin-left:-12px;box-shadow:0 0 0 3px var(--w-bg)}.dc-welcome .stack .dc-av:first-child{margin-left:0}.dc-welcome .stack .dc-av .dot{--ring: var(--w-bg)}.dc-welcome h3{margin:0;font-size:19px;font-weight:700;letter-spacing:-.015em;text-wrap:balance;color:var(--w-fg)}.dc-welcome p{margin:0;font-size:13.5px;color:var(--w-muted);max-width:30ch;line-height:1.5;text-wrap:balance}.dc-msgs{display:flex;flex-direction:column;padding:6px 14px}.dc-day{display:flex;align-items:center;gap:10px;font-size:11px;font-weight:600;letter-spacing:.07em;text-transform:uppercase;color:var(--w-faint);margin:16px 6px 2px}.dc-day:before,.dc-day:after{content:"";flex:1;height:1px;background:var(--w-line)}.dc-row{display:flex;gap:8px;align-items:flex-end;margin-top:2px}.dc-row.is-first{margin-top:12px}.dc-row--me{justify-content:flex-end}.dc-row.is-deleted{animation:dc-collapse .38s var(--ease-out) forwards;overflow:hidden}@keyframes dc-collapse{0%{max-height:600px;opacity:1}to{max-height:0;opacity:0;margin-top:0;transform:scale(.96)}}.dc-row-av{width:28px;flex:none;visibility:hidden}.dc-row.is-last .dc-row-av{visibility:visible}.dc-stack{display:flex;flex-direction:column;gap:3px;max-width:80%;min-width:0;align-items:flex-start}.dc-row--me .dc-stack{align-items:flex-end}.dc-name{display:none;font-size:12px;color:var(--w-muted);margin:0 0 1px 4px}.dc-name b{color:var(--w-fg-2);font-weight:600;margin-right:4px}.dc-row.is-first .dc-name{display:block}.dc-bubble{padding:8px 13px 9px;font-size:14.5px;line-height:1.42;overflow-wrap:anywhere;background:var(--w-bubble);color:var(--w-fg);border-radius:6px 18px 18px 6px;max-width:100%;white-space:normal;transition:background .6s}.dc-row--agent.is-first .dc-bubble{border-top-left-radius:18px}.dc-row--agent.is-last .dc-bubble{border-bottom-left-radius:18px}.dc-row--me .dc-bubble{background:var(--dc-accent);color:var(--dc-on-accent);border-radius:18px 6px 6px 18px}.dc-row--me.is-first .dc-bubble{border-top-right-radius:18px}.dc-row--me.is-last .dc-bubble{border-bottom-right-radius:18px}.dc-row.is-pending .dc-bubble,.dc-row.is-pending .dc-img,.dc-row.is-pending .dc-file{opacity:.62}.dc-bubble a{color:var(--dc-accent-text);text-decoration:underline;text-decoration-thickness:1px;text-underline-offset:2px}.dc-row--me .dc-bubble a{color:inherit}.dc-bubble code{font:12.5px/1.4 var(--mono);background:color-mix(in srgb,currentColor 11%,transparent);padding:1px 5px;border-radius:5px}.dc-bubble pre{margin:6px 0 2px;padding:9px 11px;border-radius:9px;background:color-mix(in srgb,currentColor 8%,transparent);overflow-x:auto;white-space:pre}.dc-bubble pre code{background:none;padding:0;font-size:12px}.dc-bubble strong{font-weight:650}.dc-bubble .dc-quote{display:inline-block;border-left:3px solid color-mix(in srgb,currentColor 30%,transparent);padding-left:8px}.dc-cemoji{width:20px;height:20px;vertical-align:-5px;display:inline-block;object-fit:contain}.dc-bubble.is-jumbo{background:none!important;padding:0 2px;font-size:40px;line-height:1.15}.dc-bubble.is-jumbo .dc-cemoji{width:46px;height:46px}.dc-spoiler{background:var(--w-fg);color:transparent;border-radius:4px;cursor:pointer;transition:background .25s,color .25s;padding:0 2px}.dc-row--me .dc-spoiler{background:var(--dc-on-accent)}.dc-spoiler.is-shown{background:color-mix(in srgb,currentColor 12%,transparent)!important;color:inherit;cursor:auto}.dc-edited{font-size:11px;color:var(--w-faint);margin-left:4px}.dc-row--me .dc-edited{color:inherit;opacity:.7}.dc-bubble.is-flash{background:color-mix(in srgb,var(--dc-accent) 22%,var(--w-bubble));transition:none}.dc-status{display:none;align-items:center;gap:4px;font-size:11.5px;color:var(--w-faint);margin:1px 4px 0}.dc-row.show-status .dc-status,.dc-status.is-failed,.dc-status.is-pending{display:flex}.dc-status.is-failed{color:var(--w-danger)}.dc-status button{border:0;background:none;padding:0;color:inherit;font-weight:650;text-decoration:underline;text-underline-offset:2px;cursor:pointer}.dc-event{align-self:center;display:flex;align-items:center;gap:7px;font-size:12.5px;color:var(--w-muted);margin:14px 0 4px;padding:5px 12px 5px 6px;border-radius:999px;background:var(--w-sunken);max-width:92%}.dc-event .dc-av{--s: 20px}.dc-event .ic{width:20px;height:20px;border-radius:50%;display:grid;place-items:center;background:var(--w-bg);color:var(--w-muted);flex:none}.dc-event.ok .ic{background:var(--w-success);color:#fff}.dc-event b{color:var(--w-fg-2);font-weight:600}.dc-event time{color:var(--w-faint)}.dc-event.note{border-radius:14px;padding:9px 12px;text-align:center;line-height:1.45}.dc-gallery{display:grid;grid-template-columns:1fr 1fr;gap:4px;width:236px;max-width:100%}.dc-img{position:relative;display:block;width:min(var(--w, 232px),232px);max-width:100%;border:0;padding:0;border-radius:14px;overflow:hidden;background:var(--w-sunken);cursor:zoom-in}.dc-gallery .dc-img{width:100%;aspect-ratio:1!important}.dc-img img{display:block;width:100%;height:100%;object-fit:cover;transition:transform .4s var(--ease-out)}.dc-img:hover img{transform:scale(1.035)}.dc-img.is-uploading,.dc-img.is-failed{cursor:default}.dc-img.is-uploading:after{content:"";position:absolute;inset:0;background:#080a106b}.dc-ring{position:absolute;left:50%;top:50%;width:44px;height:44px;margin:-22px 0 0 -22px;z-index:1;transform:rotate(-90deg)}.dc-ring circle{fill:none;stroke-width:3.2}.dc-ring .bg{stroke:#ffffff4d}.dc-ring .fg{stroke:#fff;stroke-linecap:round;stroke-dasharray:100;transition:stroke-dashoffset .25s var(--ease-out)}.dc-img .pct{position:absolute;left:0;right:0;top:50%;z-index:1;margin-top:26px;text-align:center;color:#fff;font:600 11px/1 var(--font);font-variant-numeric:tabular-nums}.dc-img .fail{position:absolute;inset:0;z-index:1;display:grid;place-items:center;align-content:center;gap:6px;background:color-mix(in srgb,var(--w-danger) 62%,rgba(0,0,0,.4));color:#fff;font-size:12.5px;font-weight:650}.dc-file{position:relative;display:flex;align-items:center;gap:11px;width:248px;max-width:100%;padding:10px;border-radius:14px;background:var(--w-raised);border:1px solid var(--w-line-strong);color:var(--w-fg);text-decoration:none;cursor:pointer;overflow:hidden;text-align:left;transition:transform .25s var(--ease-spring),box-shadow .2s}.dc-file:hover{transform:translateY(-1px);box-shadow:var(--w-card-shadow)}.dc-ftype{width:34px;height:40px;flex:none;position:relative;border-radius:6px;background:#e5484d;color:#fff;font:800 8.5px/1 var(--font);letter-spacing:.04em;display:grid;place-items:end center;padding-bottom:7px;clip-path:polygon(0 0,66% 0,100% 28%,100% 100%,0 100%)}.dc-ftype:after{content:"";position:absolute;top:0;right:0;width:34%;height:28%;background:#fff6;border-bottom-left-radius:4px}.dc-ftype.is-image{background:#3f8cff}.dc-file .tx{flex:1;min-width:0}.dc-file b{display:block;font-size:13.5px;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dc-file small{display:block;font-size:12px;color:var(--w-muted);margin-top:2px;font-variant-numeric:tabular-nums}.dc-file .dl{width:32px;height:32px;border-radius:50%;background:var(--w-sunken);color:var(--w-muted);display:grid;place-items:center;flex:none;transition:background .15s,color .15s}.dc-file:hover .dl{background:var(--dc-accent);color:var(--dc-on-accent)}.dc-file .bar{position:absolute;left:0;bottom:0;height:3px;width:100%;background:var(--w-sunken)}.dc-file .bar i{display:block;height:100%;background:var(--dc-accent);transition:width .25s var(--ease-out);border-radius:0 2px 2px 0}.dc-file.is-failed{border-color:color-mix(in srgb,var(--w-danger) 50%,transparent)}.dc-file.is-failed small{color:var(--w-danger)}.dc-inline-img{display:block;max-width:232px;max-height:232px;border-radius:14px}.dc-skel{display:flex;flex-direction:column;gap:10px;padding:18px 14px}.dc-skel i{height:34px;border-radius:16px}.dc-skel i:nth-child(odd){width:62%}.dc-skel i:nth-child(2n){width:48%;align-self:flex-end}.dc-skel i:nth-child(3){width:70%;height:52px}.dc-intro{align-self:stretch;display:flex;gap:8px;align-items:flex-end;margin-top:12px}.dc-intro .card{flex:1;min-width:0;background:var(--w-raised);border:1px solid var(--w-line-strong);border-radius:18px 18px 18px 6px;padding:14px;box-shadow:var(--w-card-shadow)}.dc-intro h4{margin:0 0 3px;font-size:14.5px;font-weight:650;color:var(--w-fg)}.dc-intro p{margin:0 0 12px;font-size:13px;color:var(--w-muted);line-height:1.45}.dc-intro form{display:flex;flex-direction:column;gap:8px}.dc-in{display:flex;flex-direction:column;gap:4px}.dc-in span{font-size:12px;font-weight:600;color:var(--w-fg-2)}.dc-in input{font:16px/1.3 var(--font);color:var(--w-fg);background:var(--w-bg);border:1px solid var(--w-line-strong);border-radius:11px;padding:9px 11px;outline:0;width:100%;transition:border-color .15s,box-shadow .15s}@media (pointer: fine){.dc-in input{font-size:14.5px}}.dc-in input:focus{border-color:var(--dc-accent);box-shadow:0 0 0 4px var(--dc-accent-soft)}.dc-in input:focus-visible{outline:none}.dc-in.is-err input{border-color:var(--w-danger)}.dc-in em{font-style:normal;font-size:12px;color:var(--w-danger)}.dc-in span small{font-size:11.5px;font-weight:500;color:var(--w-muted);margin-left:3px}.dc-in>small{font-size:12px;color:var(--w-muted);line-height:1.4}.dc-btn{display:inline-flex;align-items:center;justify-content:center;gap:7px;border:0;border-radius:12px;padding:10px 14px;font-weight:650;font-size:14px;background:var(--dc-accent);color:var(--dc-on-accent);cursor:pointer;transition:transform .25s var(--ease-spring),filter .15s}.dc-btn:hover{filter:brightness(1.06)}.dc-btn:active{transform:scale(.96)}.dc-intro .done{display:flex;align-items:center;gap:8px;font-size:13px;color:var(--w-muted)}.dc-intro .done .ok{width:20px;height:20px;border-radius:50%;background:var(--w-success);color:#fff;display:grid;place-items:center;flex:none}.dc-intro .done b{color:var(--w-fg);font-weight:600}.dc-shake{animation:dc-shake .4s}@keyframes dc-shake{20%{transform:translate(-5px)}40%{transform:translate(5px)}60%{transform:translate(-3px)}80%{transform:translate(2px)}}.dc-typing{display:flex;gap:8px;align-items:flex-end;padding:2px 14px 8px}.dc-typing .dots{display:flex;gap:4px;padding:13px 14px;background:var(--w-bubble);border-radius:18px 18px 18px 6px}.dc-typing .dots i{width:7px;height:7px;border-radius:50%;background:var(--w-muted);animation:dc-bounce 1.1s infinite var(--ease-out)}.dc-typing .dots i:nth-child(2){animation-delay:.14s}.dc-typing .dots i:nth-child(3){animation-delay:.28s}@keyframes dc-bounce{0%,60%,to{transform:translateY(0);opacity:.5}30%{transform:translateY(-4px);opacity:1}}.dc-jump{position:absolute;left:50%;bottom:10px;transform:translate(-50%);z-index:2;display:flex;align-items:center;gap:6px;border:0;border-radius:999px;padding:7px 12px 7px 10px;font-size:12.5px;font-weight:600;background:var(--w-fg);color:var(--w-bg);box-shadow:var(--w-card-shadow);cursor:pointer}.dc-composer{flex:none;padding:6px 12px calc(8px + env(safe-area-inset-bottom,0px));position:relative;background:var(--w-bg)}.dc-field{border:1px solid var(--w-line-strong);background:var(--w-raised);border-radius:22px;transition:border-color .2s,box-shadow .2s}.dc-field:focus-within{border-color:color-mix(in srgb,var(--dc-accent) 70%,transparent);box-shadow:0 0 0 4px var(--dc-accent-soft)}.dc-tray{display:flex;gap:10px;padding:12px 12px 2px;overflow-x:auto;scrollbar-width:none}.dc-chip{position:relative;flex:none;height:58px;border-radius:13px;background:var(--w-sunken);border:1px solid var(--w-line)}.dc-chip.img{width:58px}.dc-chip.img img{width:100%;height:100%;object-fit:cover;border-radius:12px;display:block}.dc-chip.file{display:flex;align-items:center;gap:9px;padding:0 30px 0 10px;max-width:200px}.dc-chip.file .dc-ftype{width:28px;height:33px;padding-bottom:5px;font-size:7.5px}.dc-chip.file .tx{min-width:0}.dc-chip.file b{display:block;font-size:12.5px;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:var(--w-fg)}.dc-chip.file small{font-size:11.5px;color:var(--w-muted)}.dc-chip .rm{position:absolute;top:-7px;right:-7px;width:22px;height:22px;border-radius:50%;border:2px solid var(--w-raised);background:var(--w-fg);color:var(--w-bg);display:grid;place-items:center;cursor:pointer;padding:0;transition:transform .2s var(--ease-spring)}.dc-chip .rm:hover{transform:scale(1.12)}.dc-input-row{display:flex;align-items:flex-end;gap:2px;padding:5px 5px 5px 15px}.dc-input-row textarea{flex:1;min-width:0;border:0;outline:0;resize:none;background:transparent;color:var(--w-fg);font:16px/1.4 var(--font);padding:7px 0;height:37px;max-height:128px;margin:0}@media (pointer: fine){.dc-input-row textarea{font-size:15px;height:35px}}.dc-input-row textarea::placeholder{color:var(--w-faint)}.dc-input-row textarea:focus-visible{outline:none}.dc-tool{width:34px;height:34px;border-radius:50%;border:0;background:transparent;color:var(--w-muted);display:grid;place-items:center;cursor:pointer;flex:none;padding:0;transition:background .15s,color .15s,transform .2s var(--ease-spring)}.dc-tool:hover{background:var(--w-sunken);color:var(--w-fg)}.dc-tool:active{transform:scale(.9)}.dc-tool[aria-expanded=true]{color:var(--dc-accent-text);background:var(--dc-accent-soft)}.dc-send{width:34px;height:34px;border-radius:50%;border:0;display:grid;place-items:center;flex:none;cursor:pointer;margin-left:2px;padding:0;background:var(--dc-accent);color:var(--dc-on-accent);transition:transform .35s var(--ease-spring),background .2s,color .2s,box-shadow .2s;box-shadow:0 4px 12px -4px color-mix(in srgb,var(--dc-accent) 70%,transparent)}.dc-send:disabled{background:var(--w-sunken);color:var(--w-faint);transform:scale(.86);cursor:default;box-shadow:none}.dc-send:not(:disabled):hover{transform:scale(1.07)}.dc-send:not(:disabled):active{transform:scale(.92)}.dc-powered{display:flex;justify-content:center;align-items:center;gap:5px;margin-top:7px;font-size:11px;color:var(--w-faint);text-decoration:none;transition:color .15s}.dc-powered svg{height:9px;width:auto}.dc-powered:hover{color:var(--w-fg-2)}.dc-toast{position:absolute;left:12px;right:12px;bottom:calc(100% + 4px);display:flex;justify-content:center;pointer-events:none;z-index:3}.dc-toast span{display:flex;align-items:center;gap:7px;background:var(--w-fg);color:var(--w-bg);font-size:12.5px;font-weight:550;padding:8px 12px;border-radius:12px;box-shadow:var(--w-shadow);max-width:100%}.dc-toast span svg{color:#ff8b8e}.dc-resolved{display:flex;flex-direction:column;align-items:center;gap:10px;padding:10px 8px 2px;text-align:center}.dc-resolved p{margin:0;font-size:13px;color:var(--w-muted)}.dc-emoji{position:absolute;right:12px;bottom:calc(100% - 2px);width:300px;max-width:calc(100% - 24px);height:268px;background:var(--w-raised);border:1px solid var(--w-line-strong);border-radius:18px;box-shadow:var(--w-shadow);display:flex;flex-direction:column;overflow:hidden;z-index:4;transform-origin:bottom right}.dc-emoji .grid{flex:1;overflow-y:auto;display:grid;grid-template-columns:repeat(8,1fr);padding:8px;gap:2px;align-content:start;scrollbar-width:thin}.dc-emoji .grid button{border:0;background:transparent;font-size:22px;line-height:1;height:34px;border-radius:9px;cursor:pointer;padding:0;transition:background .12s,transform .2s var(--ease-spring)}.dc-emoji .grid button:hover{background:var(--w-sunken);transform:scale(1.18)}.dc-emoji .tabs{display:flex;border-top:1px solid var(--w-line);padding:4px;gap:2px}.dc-emoji .tabs button{flex:1;border:0;background:transparent;font-size:17px;height:32px;border-radius:9px;cursor:pointer;padding:0;filter:grayscale(1);opacity:.6;transition:filter .15s,opacity .15s,background .15s}.dc-emoji .tabs button[aria-pressed=true]{filter:none;opacity:1;background:var(--w-sunken)}.dc-emoji .cat{grid-column:1 / -1;font-size:11px;font-weight:600;letter-spacing:.06em;text-transform:uppercase;color:var(--w-faint);padding:6px 4px 4px}.dc-drop{position:absolute;inset:8px;z-index:6;border-radius:18px;display:grid;place-items:center;align-content:center;gap:6px;text-align:center;color:var(--dc-accent-text);background-color:color-mix(in srgb,var(--w-bg) 86%,transparent);backdrop-filter:blur(6px);background-image:linear-gradient(90deg,var(--dc-accent) 50%,transparent 0),linear-gradient(90deg,var(--dc-accent) 50%,transparent 0),linear-gradient(0deg,var(--dc-accent) 50%,transparent 0),linear-gradient(0deg,var(--dc-accent) 50%,transparent 0);background-repeat:repeat-x,repeat-x,repeat-y,repeat-y;background-size:14px 2px,14px 2px,2px 14px,2px 14px;background-position:0 0,0 100%,0 0,100% 0;animation:dc-march .6s linear infinite;pointer-events:none}@keyframes dc-march{to{background-position:14px 0,-14px 100%,0 -14px,100% 14px}}.dc-drop .ic{width:56px;height:56px;border-radius:18px;background:var(--dc-accent);color:var(--dc-on-accent);display:grid;place-items:center;margin:0 auto 6px;animation:dc-float 1.4s ease-in-out infinite}@keyframes dc-float{50%{transform:translateY(-5px)}}.dc-drop b{font-size:16px;color:var(--w-fg)}.dc-drop small{font-size:12.5px;color:var(--w-muted)}.dc-lightbox{pointer-events:auto;position:fixed;inset:0;z-index:20;display:flex;flex-direction:column}.dc-lightbox .bd{position:absolute;inset:0;background:#08090cdb;backdrop-filter:blur(4px)}.dc-lightbox .bar{position:relative;display:flex;align-items:center;gap:10px;padding:calc(12px + env(safe-area-inset-top,0px)) 14px 12px;color:#fff;font-size:13px}.dc-lightbox .bar span{flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;opacity:.85}.dc-lightbox .bar a,.dc-lightbox .bar button{color:#fff;border:0;background:#ffffff1f;border-radius:10px;height:34px;padding:0 12px;display:inline-flex;align-items:center;gap:6px;cursor:pointer;text-decoration:none;font-size:13px}.dc-lightbox .bar button.x{width:34px;padding:0;justify-content:center}.dc-lightbox .pic{position:relative;flex:1;min-height:0;display:grid;place-items:center;padding:8px 20px 28px}.dc-lightbox img{max-width:100%;max-height:100%;border-radius:10px;box-shadow:0 30px 80px #00000080;transform-origin:top left}@media (max-width: 520px),(max-height: 540px){.dc-panel{inset:0;width:auto;height:auto;max-width:none;border-radius:0;border:0;box-shadow:none;padding-top:env(safe-area-inset-top,0px);padding-bottom:max(0px,var(--dc-keyboard, 0px) - env(safe-area-inset-bottom,0px))}@supports (-webkit-touch-callout: none){.dc-panel{transition:padding-bottom .3s cubic-bezier(.2,.85,.4,1)}}.dc-launcher.is-open{opacity:0;pointer-events:none;transform:scale(.6)}.dc-hbtn .ic-x{display:none}.dc-hbtn .ic-down{display:block}}@media (prefers-reduced-motion: reduce){.dc *,.dc *:before,.dc *:after{animation-duration:.001ms!important;animation-iteration-count:1!important;transition-duration:.001ms!important}}',mi="https://api.deskcord.chat";function vi(){const t=window.deskcord?.settings;if(!t?.app_id)return console.error("[Deskcord] window.deskcord.settings.app_id is missing: check the embed snippet."),null;const e=t.theme==="dark"||t.theme==="auto"?t.theme:"light";return{appId:String(t.app_id),domain:(t.domain??mi).replace(/\/+$/,""),user:t.user,theme:e}}const yi="DESKCORD_UNAVAILABLE",bi="DESKCORD_QUOTA_REACHED";class ve extends Error{constructor(e,n){super(`Request failed (${e})`),this.status=e,this.body=n}}class mn extends Error{constructor(){super("Deskcord is temporarily unavailable")}}class vn extends Error{constructor(){super("This team isn't taking new conversations right now")}}class bt extends Error{}function yn(t){if(!t)return null;try{return JSON.parse(t)}catch{return t}}function xi(t,e){function n(o,a){if(o===503&&a?.code===yi)throw e(),new mn;if(o===403&&a?.code===bi)throw new vn;if(o<200||o>=300)throw new ve(o,a)}async function r(o,a,c,d){const u={};c!==void 0&&(u["Content-Type"]="application/json"),d&&(u.Authorization=`Bearer ${d}`);let g;try{g=await fetch(t+a,{method:o,headers:u,body:c===void 0?void 0:JSON.stringify(c)})}catch(h){throw new bt(String(h))}const p=yn(await g.text());return n(g.status,p),p}function i(o,a,c,d,u){return new Promise((g,p)=>{const h=new XMLHttpRequest;h.open("POST",t+o),h.setRequestHeader("Authorization",`Bearer ${c}`),h.upload.onprogress=w=>{w.lengthComputable&&d(w.loaded/w.total)},h.onload=()=>{const w=yn(h.responseText);try{n(h.status,w),g(w)}catch(k){p(k)}},h.onerror=()=>p(new bt("Upload failed"));const x=new FormData;x.append("file",a),u&&x.append("pageUrl",u),h.send(x)})}return{get:(o,a)=>r("GET",o,void 0,a),post:(o,a,c)=>r("POST",o,a,c),upload:i}}const wi=2048;function xt(t=typeof window>"u"?void 0:window.location){if(!t||t.protocol!=="https:"&&t.protocol!=="http:")return;const e=`${t.origin}${t.pathname}`;return e.length<=wi?e:void 0}const bn=t=>t instanceof ve&&t.status===404;function _i(t,e){const n=xi(t.domain,e),r=t.appId,i=({name:o,email:a,avatarUrl:c,metadata:d})=>({name:o,...a?{email:a}:{},...c?{avatarUrl:c}:{},...d?{metadata:d}:{}});return{async status(){return!!(await n.get(`/guildSettings/status/${encodeURIComponent(r)}`))?.active},settings(){return n.get(`/guildSettings/${encodeURIComponent(r)}`)},async token(o,a){const c=await n.post("/auth/token",{guildId:r,...i(o)},a);if(!c?.token||c.token==="undefined")throw new Error("No token in /auth/token response");return c.token},async identify(o,a){try{return(await n.post("/auth/identify",{guildId:r,userId:o.userId,userHash:o.userHash,...i(o)},a))?.token??null}catch(c){if(c instanceof ve&&c.status<500)return null;throw c}},async current(o){try{return(await n.get("/conversations/current",o))?.currentConversation??null}catch(a){if(bn(a))return null;throw a}},async past(o){try{return(await n.get("/conversations/past",o))?.pastConversations??[]}catch(a){if(bn(a))return[];throw a}},async unreadCount(o){const a=await n.get("/conversations/unread-count",o);return Number(a?.unreadCount)||0},async markRead(o,a){await n.post("/conversations/mark-read",{timestamp:a},o)},send(o,a,c){const d=xt();return n.post("/conversations/sendMessage",{name:a,content:c,...d?{pageUrl:d}:{}},o)},upload(o,a,c){return n.upload("/conversations/uploadAttachment",a,o,c,xt())}}}const xn=20,wn=40,_n=200,ki=1024,Ei=t=>new TextEncoder().encode(t).length;function kn(t,e=Ai){if(t==null)return null;if(typeof t!="object"||Array.isArray(t))return e("metadata ignored: it must be a flat object."),null;const n=[],r={};let i=0,o=2;for(const[a,c]of Object.entries(t)){const d=a.trim(),u=c===null||typeof c=="boolean"||typeof c=="number"&&Number.isFinite(c)||typeof c=="string"&&c.length<=_n;if(!d||d.length>wn||d==="__proto__"||d in r){n.push(`"${a.slice(0,wn)}" (invalid key)`);continue}if(!u){n.push(`"${d}" (values must be strings of at most ${_n} characters, numbers, booleans or null)`);continue}const g=Ei(`${JSON.stringify(d)}:${JSON.stringify(c)},`);if(i>=xn||o+g>ki){n.push(`"${d}" (too much metadata: ${xn} keys and about 1 KB at most)`);continue}o+=g,i++,r[d]=c}return n.length&&e(`metadata dropped: ${n.join(", ")}.`),i?r:null}function Ai(t){console.warn(`[Deskcord] ${t}`)}const ie=Object.create(null);ie.open="0",ie.close="1",ie.ping="2",ie.pong="3",ie.message="4",ie.upgrade="5",ie.noop="6";const je=Object.create(null);Object.keys(ie).forEach(t=>{je[ie[t]]=t});const wt={type:"error",data:"parser error"},En=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",An=typeof ArrayBuffer=="function",Tn=t=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(t):t&&t.buffer instanceof ArrayBuffer,_t=({type:t,data:e},n,r)=>En&&e instanceof Blob?n?r(e):Sn(e,r):An&&(e instanceof ArrayBuffer||Tn(e))?n?r(e):Sn(new Blob([e]),r):r(ie[t]+(e||"")),Sn=(t,e)=>{const n=new FileReader;return n.onload=function(){const r=n.result.split(",")[1];e("b"+(r||""))},n.readAsDataURL(t)};function Cn(t){return t instanceof Uint8Array?t:t instanceof ArrayBuffer?new Uint8Array(t):new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}let kt;function Ti(t,e){if(En&&t.data instanceof Blob)return t.data.arrayBuffer().then(Cn).then(e);if(An&&(t.data instanceof ArrayBuffer||Tn(t.data)))return e(Cn(t.data));_t(t,!1,n=>{kt||(kt=new TextEncoder),e(kt.encode(n))})}const Rn="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Te=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let t=0;t<Rn.length;t++)Te[Rn.charCodeAt(t)]=t;const Si=t=>{let e=t.length*.75,n=t.length,r,i=0,o,a,c,d;t[t.length-1]==="="&&(e--,t[t.length-2]==="="&&e--);const u=new ArrayBuffer(e),g=new Uint8Array(u);for(r=0;r<n;r+=4)o=Te[t.charCodeAt(r)],a=Te[t.charCodeAt(r+1)],c=Te[t.charCodeAt(r+2)],d=Te[t.charCodeAt(r+3)],g[i++]=o<<2|a>>4,g[i++]=(a&15)<<4|c>>2,g[i++]=(c&3)<<6|d&63;return u},Ci=typeof ArrayBuffer=="function",Et=(t,e)=>{if(typeof t!="string")return{type:"message",data:In(t,e)};const n=t.charAt(0);return n==="b"?{type:"message",data:Ri(t.substring(1),e)}:je[n]?t.length>1?{type:je[n],data:t.substring(1)}:{type:je[n]}:wt},Ri=(t,e)=>{if(Ci){const n=Si(t);return In(n,e)}else return{base64:!0,data:t}},In=(t,e)=>{switch(e){case"blob":return t instanceof Blob?t:new Blob([t]);case"arraybuffer":default:return t instanceof ArrayBuffer?t:t.buffer}},Ln="",Ii=(t,e)=>{const n=t.length,r=new Array(n);let i=0;t.forEach((o,a)=>{_t(o,!1,c=>{r[a]=c,++i===n&&e(r.join(Ln))})})},Li=(t,e)=>{const n=t.split(Ln),r=[];for(let i=0;i<n.length;i++){const o=Et(n[i],e);if(r.push(o),o.type==="error")break}return r};function Ni(){return new TransformStream({transform(t,e){Ti(t,n=>{const r=n.length;let i;if(r<126)i=new Uint8Array(1),new DataView(i.buffer).setUint8(0,r);else if(r<65536){i=new Uint8Array(3);const o=new DataView(i.buffer);o.setUint8(0,126),o.setUint16(1,r)}else{i=new Uint8Array(9);const o=new DataView(i.buffer);o.setUint8(0,127),o.setBigUint64(1,BigInt(r))}t.data&&typeof t.data!="string"&&(i[0]|=128),e.enqueue(i),e.enqueue(n)})}})}let At;function qe(t){return t.reduce((e,n)=>e+n.length,0)}function Ve(t,e){if(t[0].length===e)return t.shift();const n=new Uint8Array(e);let r=0;for(let i=0;i<e;i++)n[i]=t[0][r++],r===t[0].length&&(t.shift(),r=0);return t.length&&r<t[0].length&&(t[0]=t[0].slice(r)),n}function Oi(t,e){At||(At=new TextDecoder);const n=[];let r=0,i=-1,o=!1;return new TransformStream({transform(a,c){for(n.push(a);;){if(r===0){if(qe(n)<1)break;const d=Ve(n,1);o=(d[0]&128)===128,i=d[0]&127,i<126?r=3:i===126?r=1:r=2}else if(r===1){if(qe(n)<2)break;const d=Ve(n,2);i=new DataView(d.buffer,d.byteOffset,d.length).getUint16(0),r=3}else if(r===2){if(qe(n)<8)break;const d=Ve(n,8),u=new DataView(d.buffer,d.byteOffset,d.length),g=u.getUint32(0);if(g>Math.pow(2,21)-1){c.enqueue(wt);break}i=g*Math.pow(2,32)+u.getUint32(4),r=3}else{if(qe(n)<i)break;const d=Ve(n,i);c.enqueue(Et(o?d:At.decode(d),e)),r=0}if(i===0||i>t){c.enqueue(wt);break}}}})}const Nn=4;function B(t){if(t)return $i(t)}function $i(t){for(var e in B.prototype)t[e]=B.prototype[e];return t}B.prototype.on=B.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+t]=this._callbacks["$"+t]||[]).push(e),this},B.prototype.once=function(t,e){function n(){this.off(t,n),e.apply(this,arguments)}return n.fn=e,this.on(t,n),this},B.prototype.off=B.prototype.removeListener=B.prototype.removeAllListeners=B.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var n=this._callbacks["$"+t];if(!n)return this;if(arguments.length==1)return delete this._callbacks["$"+t],this;for(var r,i=0;i<n.length;i++)if(r=n[i],r===e||r.fn===e){n.splice(i,1);break}return n.length===0&&delete this._callbacks["$"+t],this},B.prototype.emit=function(t){this._callbacks=this._callbacks||{};for(var e=new Array(arguments.length-1),n=this._callbacks["$"+t],r=1;r<arguments.length;r++)e[r-1]=arguments[r];if(n){n=n.slice(0);for(var r=0,i=n.length;r<i;++r)n[r].apply(this,e)}return this},B.prototype.emitReserved=B.prototype.emit,B.prototype.listeners=function(t){return this._callbacks=this._callbacks||{},this._callbacks["$"+t]||[]},B.prototype.hasListeners=function(t){return!!this.listeners(t).length};const Q=typeof self<"u"?self:typeof window<"u"?window:Function("return this")();function On(t,...e){return e.reduce((n,r)=>(t.hasOwnProperty(r)&&(n[r]=t[r]),n),{})}const Mi=Q.setTimeout,Ui=Q.clearTimeout;function We(t,e){e.useNativeTimers?(t.setTimeoutFn=Mi.bind(Q),t.clearTimeoutFn=Ui.bind(Q)):(t.setTimeoutFn=Q.setTimeout.bind(Q),t.clearTimeoutFn=Q.clearTimeout.bind(Q))}const Di=1.33;function zi(t){return typeof t=="string"?Pi(t):Math.ceil((t.byteLength||t.size)*Di)}function Pi(t){let e=0,n=0;for(let r=0,i=t.length;r<i;r++)e=t.charCodeAt(r),e<128?n+=1:e<2048?n+=2:e<55296||e>=57344?n+=3:(r++,n+=4);return n}function Bi(t){let e="";for(let n in t)t.hasOwnProperty(n)&&(e.length&&(e+="&"),e+=encodeURIComponent(n)+"="+encodeURIComponent(t[n]));return e}function Fi(t){let e={},n=t.split("&");for(let r=0,i=n.length;r<i;r++){let o=n[r].split("=");e[decodeURIComponent(o[0])]=decodeURIComponent(o[1])}return e}class Hi extends Error{constructor(e,n,r){super(e),this.description=n,this.context=r,this.type="TransportError"}}class Tt extends B{constructor(e){super(),this.writable=!1,We(this,e),this.opts=e,this.query=e.query,this.socket=e.socket}onError(e,n,r){return super.emitReserved("error",new Hi(e,n,r)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(e){this.readyState==="open"&&this.write(e)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){const n=Et(e,this.socket.binaryType);this.onPacket(n)}onPacket(e){super.emitReserved("packet",e)}onClose(e){this.readyState="closed",super.emitReserved("close",e)}pause(e){}createUri(e,n={}){return e+"://"+this._hostname()+this._port()+this.opts.path+this._query(n)}_hostname(){const e=this.opts.hostname;return e.indexOf(":")===-1?e:"["+e+"]"}_port(){return this.opts.port&&(this.opts.secure&&+(this.opts.port!==443)||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(e){const n=Bi(e);return n.length?"?"+n:""}}const $n="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),St=64,ji={};let Mn=0,Ye=0,Un;function Dn(t){let e="";do e=$n[t%St]+e,t=Math.floor(t/St);while(t>0);return e}function zn(){const t=Dn(+new Date);return t!==Un?(Mn=0,Un=t):t+"."+Dn(Mn++)}for(;Ye<St;Ye++)ji[$n[Ye]]=Ye;let Pn=!1;try{Pn=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const qi=Pn;function Bn(t){const e=t.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!e||qi))return new XMLHttpRequest}catch{}if(!e)try{return new Q[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}function ma(){}function Vi(){}const Wi=function(){return new Bn({xdomain:!1}).responseType!=null}();class Yi extends Tt{constructor(e){if(super(e),this.polling=!1,typeof location<"u"){const r=location.protocol==="https:";let i=location.port;i||(i=r?"443":"80"),this.xd=typeof location<"u"&&e.hostname!==location.hostname||i!==e.port}const n=e&&e.forceBase64;this.supportsBinary=Wi&&!n,this.opts.withCredentials&&(this.cookieJar=void 0)}get name(){return"polling"}doOpen(){this.poll()}pause(e){this.readyState="pausing";const n=()=>{this.readyState="paused",e()};if(this.polling||!this.writable){let r=0;this.polling&&(r++,this.once("pollComplete",function(){--r||n()})),this.writable||(r++,this.once("drain",function(){--r||n()}))}else n()}poll(){this.polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){const n=r=>{if(this.readyState==="opening"&&r.type==="open"&&this.onOpen(),r.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(r)};Li(e,this.socket.binaryType).forEach(n),this.readyState!=="closed"&&(this.polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this.poll())}doClose(){const e=()=>{this.write([{type:"close"}])};this.readyState==="open"?e():this.once("open",e)}write(e){this.writable=!1,Ii(e,n=>{this.doWrite(n,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const e=this.opts.secure?"https":"http",n=this.query||{};return this.opts.timestampRequests!==!1&&(n[this.opts.timestampParam]=zn()),!this.supportsBinary&&!n.sid&&(n.b64=1),this.createUri(e,n)}request(e={}){return Object.assign(e,{xd:this.xd,cookieJar:this.cookieJar},this.opts),new oe(this.uri(),e)}doWrite(e,n){const r=this.request({method:"POST",data:e});r.on("success",n),r.on("error",(i,o)=>{this.onError("xhr post error",i,o)})}doPoll(){const e=this.request();e.on("data",this.onData.bind(this)),e.on("error",(n,r)=>{this.onError("xhr poll error",n,r)}),this.pollXhr=e}}class oe extends B{constructor(e,n){super(),We(this,n),this.opts=n,this.method=n.method||"GET",this.uri=e,this.data=n.data!==void 0?n.data:null,this.create()}create(){var e;const n=On(this.opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");n.xdomain=!!this.opts.xd;const r=this.xhr=new Bn(n);try{r.open(this.method,this.uri,!0);try{if(this.opts.extraHeaders){r.setDisableHeaderCheck&&r.setDisableHeaderCheck(!0);for(let i in this.opts.extraHeaders)this.opts.extraHeaders.hasOwnProperty(i)&&r.setRequestHeader(i,this.opts.extraHeaders[i])}}catch{}if(this.method==="POST")try{r.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{r.setRequestHeader("Accept","*/*")}catch{}(e=this.opts.cookieJar)===null||e===void 0||e.addCookies(r),"withCredentials"in r&&(r.withCredentials=this.opts.withCredentials),this.opts.requestTimeout&&(r.timeout=this.opts.requestTimeout),r.onreadystatechange=()=>{var i;r.readyState===3&&((i=this.opts.cookieJar)===null||i===void 0||i.parseCookies(r)),r.readyState===4&&(r.status===200||r.status===1223?this.onLoad():this.setTimeoutFn(()=>{this.onError(typeof r.status=="number"?r.status:0)},0))},r.send(this.data)}catch(i){this.setTimeoutFn(()=>{this.onError(i)},0);return}typeof document<"u"&&(this.index=oe.requestsCount++,oe.requests[this.index]=this)}onError(e){this.emitReserved("error",e,this.xhr),this.cleanup(!0)}cleanup(e){if(!(typeof this.xhr>"u"||this.xhr===null)){if(this.xhr.onreadystatechange=Vi,e)try{this.xhr.abort()}catch{}typeof document<"u"&&delete oe.requests[this.index],this.xhr=null}}onLoad(){const e=this.xhr.responseText;e!==null&&(this.emitReserved("data",e),this.emitReserved("success"),this.cleanup())}abort(){this.cleanup()}}if(oe.requestsCount=0,oe.requests={},typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",Fn);else if(typeof addEventListener=="function"){const t="onpagehide"in Q?"pagehide":"unload";addEventListener(t,Fn,!1)}}function Fn(){for(let t in oe.requests)oe.requests.hasOwnProperty(t)&&oe.requests[t].abort()}const Ct=typeof Promise=="function"&&typeof Promise.resolve=="function"?e=>Promise.resolve().then(e):(e,n)=>n(e,0),Ke=Q.WebSocket||Q.MozWebSocket,Hn=!0,Ki="arraybuffer",jn=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class Xi extends Tt{constructor(e){super(e),this.supportsBinary=!e.forceBase64}get name(){return"websocket"}doOpen(){if(!this.check())return;const e=this.uri(),n=this.opts.protocols,r=jn?{}:On(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(r.headers=this.opts.extraHeaders);try{this.ws=Hn&&!jn?n?new Ke(e,n):new Ke(e):new Ke(e,n,r)}catch(i){return this.emitReserved("error",i)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:"websocket connection closed",context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError("websocket error",e)}write(e){this.writable=!1;for(let n=0;n<e.length;n++){const r=e[n],i=n===e.length-1;_t(r,this.supportsBinary,o=>{const a={};try{Hn&&this.ws.send(o)}catch{}i&&Ct(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.close(),this.ws=null)}uri(){const e=this.opts.secure?"wss":"ws",n=this.query||{};return this.opts.timestampRequests&&(n[this.opts.timestampParam]=zn()),this.supportsBinary||(n.b64=1),this.createUri(e,n)}check(){return!!Ke}}class Ji extends Tt{get name(){return"webtransport"}doOpen(){typeof WebTransport=="function"&&(this.transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name]),this.transport.closed.then(()=>{this.onClose()}).catch(e=>{this.onError("webtransport error",e)}),this.transport.ready.then(()=>{this.transport.createBidirectionalStream().then(e=>{const n=Oi(Number.MAX_SAFE_INTEGER,this.socket.binaryType),r=e.readable.pipeThrough(n).getReader(),i=Ni();i.readable.pipeTo(e.writable),this.writer=i.writable.getWriter();const o=()=>{r.read().then(({done:c,value:d})=>{c||(this.onPacket(d),o())}).catch(c=>{})};o();const a={type:"open"};this.query.sid&&(a.data=`{"sid":"${this.query.sid}"}`),this.writer.write(a).then(()=>this.onOpen())})}))}write(e){this.writable=!1;for(let n=0;n<e.length;n++){const r=e[n],i=n===e.length-1;this.writer.write(r).then(()=>{i&&Ct(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var e;(e=this.transport)===null||e===void 0||e.close()}}const Zi={websocket:Xi,webtransport:Ji,polling:Yi},Gi=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,Qi=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function Rt(t){if(t.length>2e3)throw"URI too long";const e=t,n=t.indexOf("["),r=t.indexOf("]");n!=-1&&r!=-1&&(t=t.substring(0,n)+t.substring(n,r).replace(/:/g,";")+t.substring(r,t.length));let i=Gi.exec(t||""),o={},a=14;for(;a--;)o[Qi[a]]=i[a]||"";return n!=-1&&r!=-1&&(o.source=e,o.host=o.host.substring(1,o.host.length-1).replace(/;/g,":"),o.authority=o.authority.replace("[","").replace("]","").replace(/;/g,":"),o.ipv6uri=!0),o.pathNames=eo(o,o.path),o.queryKey=to(o,o.query),o}function eo(t,e){const n=/\/{2,9}/g,r=e.replace(n,"/").split("/");return(e.slice(0,1)=="/"||e.length===0)&&r.splice(0,1),e.slice(-1)=="/"&&r.splice(r.length-1,1),r}function to(t,e){const n={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(r,i,o){i&&(n[i]=o)}),n}let qn=class Ee extends B{constructor(e,n={}){super(),this.binaryType=Ki,this.writeBuffer=[],e&&typeof e=="object"&&(n=e,e=null),e?(e=Rt(e),n.hostname=e.host,n.secure=e.protocol==="https"||e.protocol==="wss",n.port=e.port,e.query&&(n.query=e.query)):n.host&&(n.hostname=Rt(n.host).host),We(this,n),this.secure=n.secure!=null?n.secure:typeof location<"u"&&location.protocol==="https:",n.hostname&&!n.port&&(n.port=this.secure?"443":"80"),this.hostname=n.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=n.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=n.transports||["polling","websocket","webtransport"],this.writeBuffer=[],this.prevBufferLen=0,this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},n),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=Fi(this.opts.query)),this.id=null,this.upgrades=null,this.pingInterval=null,this.pingTimeout=null,this.pingTimeoutTimer=null,typeof addEventListener=="function"&&(this.opts.closeOnBeforeunload&&(this.beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this.beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this.offlineEventListener=()=>{this.onClose("transport close",{description:"network connection lost"})},addEventListener("offline",this.offlineEventListener,!1))),this.open()}createTransport(e){const n=Object.assign({},this.opts.query);n.EIO=Nn,n.transport=e,this.id&&(n.sid=this.id);const r=Object.assign({},this.opts,{query:n,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return new Zi[e](r)}open(){let e;if(this.opts.rememberUpgrade&&Ee.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1)e="websocket";else if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}else e=this.transports[0];this.readyState="opening";try{e=this.createTransport(e)}catch{this.transports.shift(),this.open();return}e.open(),this.setTransport(e)}setTransport(e){this.transport&&this.transport.removeAllListeners(),this.transport=e,e.on("drain",this.onDrain.bind(this)).on("packet",this.onPacket.bind(this)).on("error",this.onError.bind(this)).on("close",n=>this.onClose("transport close",n))}probe(e){let n=this.createTransport(e),r=!1;Ee.priorWebsocketSuccess=!1;const i=()=>{r||(n.send([{type:"ping",data:"probe"}]),n.once("packet",p=>{if(!r)if(p.type==="pong"&&p.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",n),!n)return;Ee.priorWebsocketSuccess=n.name==="websocket",this.transport.pause(()=>{r||this.readyState!=="closed"&&(g(),this.setTransport(n),n.send([{type:"upgrade"}]),this.emitReserved("upgrade",n),n=null,this.upgrading=!1,this.flush())})}else{const h=new Error("probe error");h.transport=n.name,this.emitReserved("upgradeError",h)}}))};function o(){r||(r=!0,g(),n.close(),n=null)}const a=p=>{const h=new Error("probe error: "+p);h.transport=n.name,o(),this.emitReserved("upgradeError",h)};function c(){a("transport closed")}function d(){a("socket closed")}function u(p){n&&p.name!==n.name&&o()}const g=()=>{n.removeListener("open",i),n.removeListener("error",a),n.removeListener("close",c),this.off("close",d),this.off("upgrading",u)};n.once("open",i),n.once("error",a),n.once("close",c),this.once("close",d),this.once("upgrading",u),this.upgrades.indexOf("webtransport")!==-1&&e!=="webtransport"?this.setTimeoutFn(()=>{r||n.open()},200):n.open()}onOpen(){if(this.readyState="open",Ee.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush(),this.readyState==="open"&&this.opts.upgrade){let e=0;const n=this.upgrades.length;for(;e<n;e++)this.probe(this.upgrades[e])}}onPacket(e){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",e),this.emitReserved("heartbeat"),this.resetPingTimeout(),e.type){case"open":this.onHandshake(JSON.parse(e.data));break;case"ping":this.sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong");break;case"error":const n=new Error("server error");n.code=e.data,this.onError(n);break;case"message":this.emitReserved("data",e.data),this.emitReserved("message",e.data);break}}onHandshake(e){this.emitReserved("handshake",e),this.id=e.sid,this.transport.query.sid=e.sid,this.upgrades=this.filterUpgrades(e.upgrades),this.pingInterval=e.pingInterval,this.pingTimeout=e.pingTimeout,this.maxPayload=e.maxPayload,this.onOpen(),this.readyState!=="closed"&&this.resetPingTimeout()}resetPingTimeout(){this.clearTimeoutFn(this.pingTimeoutTimer),this.pingTimeoutTimer=this.setTimeoutFn(()=>{this.onClose("ping timeout")},this.pingInterval+this.pingTimeout),this.opts.autoUnref&&this.pingTimeoutTimer.unref()}onDrain(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const e=this.getWritablePackets();this.transport.send(e),this.prevBufferLen=e.length,this.emitReserved("flush")}}getWritablePackets(){if(!(this.maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let n=1;for(let r=0;r<this.writeBuffer.length;r++){const i=this.writeBuffer[r].data;if(i&&(n+=zi(i)),r>0&&n>this.maxPayload)return this.writeBuffer.slice(0,r);n+=2}return this.writeBuffer}write(e,n,r){return this.sendPacket("message",e,n,r),this}send(e,n,r){return this.sendPacket("message",e,n,r),this}sendPacket(e,n,r,i){if(typeof n=="function"&&(i=n,n=void 0),typeof r=="function"&&(i=r,r=null),this.readyState==="closing"||this.readyState==="closed")return;r=r||{},r.compress=r.compress!==!1;const o={type:e,data:n,options:r};this.emitReserved("packetCreate",o),this.writeBuffer.push(o),i&&this.once("flush",i),this.flush()}close(){const e=()=>{this.onClose("forced close"),this.transport.close()},n=()=>{this.off("upgrade",n),this.off("upgradeError",n),e()},r=()=>{this.once("upgrade",n),this.once("upgradeError",n)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?r():e()}):this.upgrading?r():e()),this}onError(e){Ee.priorWebsocketSuccess=!1,this.emitReserved("error",e),this.onClose("transport error",e)}onClose(e,n){(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")&&(this.clearTimeoutFn(this.pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),typeof removeEventListener=="function"&&(removeEventListener("beforeunload",this.beforeunloadEventListener,!1),removeEventListener("offline",this.offlineEventListener,!1)),this.readyState="closed",this.id=null,this.emitReserved("close",e,n),this.writeBuffer=[],this.prevBufferLen=0)}filterUpgrades(e){const n=[];let r=0;const i=e.length;for(;r<i;r++)~this.transports.indexOf(e[r])&&n.push(e[r]);return n}};qn.protocol=Nn;function no(t,e="",n){let r=t;n=n||typeof location<"u"&&location,t==null&&(t=n.protocol+"//"+n.host),typeof t=="string"&&(t.charAt(0)==="/"&&(t.charAt(1)==="/"?t=n.protocol+t:t=n.host+t),/^(https?|wss?):\/\//.test(t)||(typeof n<"u"?t=n.protocol+"//"+t:t="https://"+t),r=Rt(t)),r.port||(/^(http|ws)$/.test(r.protocol)?r.port="80":/^(http|ws)s$/.test(r.protocol)&&(r.port="443")),r.path=r.path||"/";const o=r.host.indexOf(":")!==-1?"["+r.host+"]":r.host;return r.id=r.protocol+"://"+o+":"+r.port+e,r.href=r.protocol+"://"+o+(n&&n.port===r.port?"":":"+r.port),r}const ro=typeof ArrayBuffer=="function",io=t=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(t):t.buffer instanceof ArrayBuffer,Vn=Object.prototype.toString,oo=typeof Blob=="function"||typeof Blob<"u"&&Vn.call(Blob)==="[object BlobConstructor]",so=typeof File=="function"||typeof File<"u"&&Vn.call(File)==="[object FileConstructor]";function It(t){return ro&&(t instanceof ArrayBuffer||io(t))||oo&&t instanceof Blob||so&&t instanceof File}function Xe(t,e){if(!t||typeof t!="object")return!1;if(Array.isArray(t)){for(let n=0,r=t.length;n<r;n++)if(Xe(t[n]))return!0;return!1}if(It(t))return!0;if(t.toJSON&&typeof t.toJSON=="function"&&arguments.length===1)return Xe(t.toJSON(),!0);for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&Xe(t[n]))return!0;return!1}function ao(t){const e=[],n=t.data,r=t;return r.data=Lt(n,e),r.attachments=e.length,{packet:r,buffers:e}}function Lt(t,e){if(!t)return t;if(It(t)){const n={_placeholder:!0,num:e.length};return e.push(t),n}else if(Array.isArray(t)){const n=new Array(t.length);for(let r=0;r<t.length;r++)n[r]=Lt(t[r],e);return n}else if(typeof t=="object"&&!(t instanceof Date)){const n={};for(const r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=Lt(t[r],e));return n}return t}function co(t,e){return t.data=Nt(t.data,e),delete t.attachments,t}function Nt(t,e){if(!t)return t;if(t&&t._placeholder===!0){if(typeof t.num=="number"&&t.num>=0&&t.num<e.length)return e[t.num];throw new Error("illegal attachments")}else if(Array.isArray(t))for(let n=0;n<t.length;n++)t[n]=Nt(t[n],e);else if(typeof t=="object")for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&(t[n]=Nt(t[n],e));return t}const lo=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],uo=5;var R;(function(t){t[t.CONNECT=0]="CONNECT",t[t.DISCONNECT=1]="DISCONNECT",t[t.EVENT=2]="EVENT",t[t.ACK=3]="ACK",t[t.CONNECT_ERROR=4]="CONNECT_ERROR",t[t.BINARY_EVENT=5]="BINARY_EVENT",t[t.BINARY_ACK=6]="BINARY_ACK"})(R||(R={}));class po{constructor(e){this.replacer=e}encode(e){return(e.type===R.EVENT||e.type===R.ACK)&&Xe(e)?this.encodeAsBinary({type:e.type===R.EVENT?R.BINARY_EVENT:R.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):[this.encodeAsString(e)]}encodeAsString(e){let n=""+e.type;return(e.type===R.BINARY_EVENT||e.type===R.BINARY_ACK)&&(n+=e.attachments+"-"),e.nsp&&e.nsp!=="/"&&(n+=e.nsp+","),e.id!=null&&(n+=e.id),e.data!=null&&(n+=JSON.stringify(e.data,this.replacer)),n}encodeAsBinary(e){const n=ao(e),r=this.encodeAsString(n.packet),i=n.buffers;return i.unshift(r),i}}function Wn(t){return Object.prototype.toString.call(t)==="[object Object]"}class Ot extends B{constructor(e){super(),this.reviver=e}add(e){let n;if(typeof e=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");n=this.decodeString(e);const r=n.type===R.BINARY_EVENT;r||n.type===R.BINARY_ACK?(n.type=r?R.EVENT:R.ACK,this.reconstructor=new fo(n),n.attachments===0&&super.emitReserved("decoded",n)):super.emitReserved("decoded",n)}else if(It(e)||e.base64)if(this.reconstructor)n=this.reconstructor.takeBinaryData(e),n&&(this.reconstructor=null,super.emitReserved("decoded",n));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+e)}decodeString(e){let n=0;const r={type:Number(e.charAt(0))};if(R[r.type]===void 0)throw new Error("unknown packet type "+r.type);if(r.type===R.BINARY_EVENT||r.type===R.BINARY_ACK){const o=n+1;for(;e.charAt(++n)!=="-"&&n!=e.length;);const a=e.substring(o,n);if(a!=Number(a)||e.charAt(n)!=="-")throw new Error("Illegal attachments");r.attachments=Number(a)}if(e.charAt(n+1)==="/"){const o=n+1;for(;++n&&!(e.charAt(n)===","||n===e.length););r.nsp=e.substring(o,n)}else r.nsp="/";const i=e.charAt(n+1);if(i!==""&&Number(i)==i){const o=n+1;for(;++n;){const a=e.charAt(n);if(a==null||Number(a)!=a){--n;break}if(n===e.length)break}r.id=Number(e.substring(o,n+1))}if(e.charAt(++n)){const o=this.tryParse(e.substr(n));if(Ot.isPayloadValid(r.type,o))r.data=o;else throw new Error("invalid payload")}return r}tryParse(e){try{return JSON.parse(e,this.reviver)}catch{return!1}}static isPayloadValid(e,n){switch(e){case R.CONNECT:return Wn(n);case R.DISCONNECT:return n===void 0;case R.CONNECT_ERROR:return typeof n=="string"||Wn(n);case R.EVENT:case R.BINARY_EVENT:return Array.isArray(n)&&(typeof n[0]=="number"||typeof n[0]=="string"&&lo.indexOf(n[0])===-1);case R.ACK:case R.BINARY_ACK:return Array.isArray(n)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class fo{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){const n=co(this.reconPack,this.buffers);return this.finishedReconstruction(),n}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const ho=Object.freeze(Object.defineProperty({__proto__:null,Decoder:Ot,Encoder:po,get PacketType(){return R},protocol:uo},Symbol.toStringTag,{value:"Module"}));function re(t,e,n){return t.on(e,n),function(){t.off(e,n)}}const go=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class Yn extends B{constructor(e,n,r){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=n,r&&r.auth&&(this.auth=r.auth),this._opts=Object.assign({},r),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const e=this.io;this.subs=[re(e,"open",this.onopen.bind(this)),re(e,"packet",this.onpacket.bind(this)),re(e,"error",this.onerror.bind(this)),re(e,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...e){return e.unshift("message"),this.emit.apply(this,e),this}emit(e,...n){if(go.hasOwnProperty(e))throw new Error('"'+e.toString()+'" is a reserved event name');if(n.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(n),this;const r={type:R.EVENT,data:n};if(r.options={},r.options.compress=this.flags.compress!==!1,typeof n[n.length-1]=="function"){const a=this.ids++,c=n.pop();this._registerAckCallback(a,c),r.id=a}const i=this.io.engine&&this.io.engine.transport&&this.io.engine.transport.writable;return this.flags.volatile&&(!i||!this.connected)||(this.connected?(this.notifyOutgoingListeners(r),this.packet(r)):this.sendBuffer.push(r)),this.flags={},this}_registerAckCallback(e,n){var r;const i=(r=this.flags.timeout)!==null&&r!==void 0?r:this._opts.ackTimeout;if(i===void 0){this.acks[e]=n;return}const o=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let c=0;c<this.sendBuffer.length;c++)this.sendBuffer[c].id===e&&this.sendBuffer.splice(c,1);n.call(this,new Error("operation has timed out"))},i),a=(...c)=>{this.io.clearTimeoutFn(o),n.apply(this,c)};a.withError=!0,this.acks[e]=a}emitWithAck(e,...n){return new Promise((r,i)=>{const o=(a,c)=>a?i(a):r(c);o.withError=!0,n.push(o),this.emit(e,...n)})}_addToQueue(e){let n;typeof e[e.length-1]=="function"&&(n=e.pop());const r={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((i,...o)=>r!==this._queue[0]?void 0:(i!==null?r.tryCount>this._opts.retries&&(this._queue.shift(),n&&n(i)):(this._queue.shift(),n&&n(null,...o)),r.pending=!1,this._drainQueue())),this._queue.push(r),this._drainQueue()}_drainQueue(e=!1){if(!this.connected||this._queue.length===0)return;const n=this._queue[0];n.pending&&!e||(n.pending=!0,n.tryCount++,this.flags=n.flags,this.emit.apply(this,n.args))}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){typeof this.auth=="function"?this.auth(e=>{this._sendConnectPacket(e)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:R.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved("connect_error",e)}onclose(e,n){this.connected=!1,delete this.id,this.emitReserved("disconnect",e,n),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(e=>{if(!this.sendBuffer.some(r=>String(r.id)===e)){const r=this.acks[e];delete this.acks[e],r.withError&&r.call(this,new Error("socket has been disconnected"))}})}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case R.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case R.EVENT:case R.BINARY_EVENT:this.onevent(e);break;case R.ACK:case R.BINARY_ACK:this.onack(e);break;case R.DISCONNECT:this.ondisconnect();break;case R.CONNECT_ERROR:this.destroy();const r=new Error(e.data.message);r.data=e.data.data,this.emitReserved("connect_error",r);break}}onevent(e){const n=e.data||[];e.id!=null&&n.push(this.ack(e.id)),this.connected?this.emitEvent(n):this.receiveBuffer.push(Object.freeze(n))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){const n=this._anyListeners.slice();for(const r of n)r.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&typeof e[e.length-1]=="string"&&(this._lastOffset=e[e.length-1])}ack(e){const n=this;let r=!1;return function(...i){r||(r=!0,n.packet({type:R.ACK,id:e,data:i}))}}onack(e){const n=this.acks[e.id];typeof n=="function"&&(delete this.acks[e.id],n.withError&&e.data.unshift(null),n.apply(this,e.data))}onconnect(e,n){this.id=e,this.recovered=n&&this._pid===n,this._pid=n,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach(e=>this.emitEvent(e)),this.receiveBuffer=[],this.sendBuffer.forEach(e=>{this.notifyOutgoingListeners(e),this.packet(e)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(e=>e()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:R.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){const n=this._anyListeners;for(let r=0;r<n.length;r++)if(e===n[r])return n.splice(r,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){const n=this._anyOutgoingListeners;for(let r=0;r<n.length;r++)if(e===n[r])return n.splice(r,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const n=this._anyOutgoingListeners.slice();for(const r of n)r.apply(this,e.data)}}}function ye(t){t=t||{},this.ms=t.min||100,this.max=t.max||1e4,this.factor=t.factor||2,this.jitter=t.jitter>0&&t.jitter<=1?t.jitter:0,this.attempts=0}ye.prototype.duration=function(){var t=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var e=Math.random(),n=Math.floor(e*this.jitter*t);t=Math.floor(e*10)&1?t+n:t-n}return Math.min(t,this.max)|0},ye.prototype.reset=function(){this.attempts=0},ye.prototype.setMin=function(t){this.ms=t},ye.prototype.setMax=function(t){this.max=t},ye.prototype.setJitter=function(t){this.jitter=t};class $t extends B{constructor(e,n){var r;super(),this.nsps={},this.subs=[],e&&typeof e=="object"&&(n=e,e=void 0),n=n||{},n.path=n.path||"/socket.io",this.opts=n,We(this,n),this.reconnection(n.reconnection!==!1),this.reconnectionAttempts(n.reconnectionAttempts||1/0),this.reconnectionDelay(n.reconnectionDelay||1e3),this.reconnectionDelayMax(n.reconnectionDelayMax||5e3),this.randomizationFactor((r=n.randomizationFactor)!==null&&r!==void 0?r:.5),this.backoff=new ye({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(n.timeout==null?2e4:n.timeout),this._readyState="closed",this.uri=e;const i=n.parser||ho;this.encoder=new i.Encoder,this.decoder=new i.Decoder,this._autoConnect=n.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,this):this._reconnection}reconnectionAttempts(e){return e===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var n;return e===void 0?this._reconnectionDelay:(this._reconnectionDelay=e,(n=this.backoff)===null||n===void 0||n.setMin(e),this)}randomizationFactor(e){var n;return e===void 0?this._randomizationFactor:(this._randomizationFactor=e,(n=this.backoff)===null||n===void 0||n.setJitter(e),this)}reconnectionDelayMax(e){var n;return e===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,(n=this.backoff)===null||n===void 0||n.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(e){if(~this._readyState.indexOf("open"))return this;this.engine=new qn(this.uri,this.opts);const n=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;const i=re(n,"open",function(){r.onopen(),e&&e()}),o=c=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",c),e?e(c):this.maybeReconnectOnOpen()},a=re(n,"error",o);if(this._timeout!==!1){const c=this._timeout,d=this.setTimeoutFn(()=>{i(),o(new Error("timeout")),n.close()},c);this.opts.autoUnref&&d.unref(),this.subs.push(()=>{this.clearTimeoutFn(d)})}return this.subs.push(i),this.subs.push(a),this}connect(e){return this.open(e)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const e=this.engine;this.subs.push(re(e,"ping",this.onping.bind(this)),re(e,"data",this.ondata.bind(this)),re(e,"error",this.onerror.bind(this)),re(e,"close",this.onclose.bind(this)),re(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(e){try{this.decoder.add(e)}catch(n){this.onclose("parse error",n)}}ondecoded(e){Ct(()=>{this.emitReserved("packet",e)},this.setTimeoutFn)}onerror(e){this.emitReserved("error",e)}socket(e,n){let r=this.nsps[e];return r?this._autoConnect&&!r.active&&r.connect():(r=new Yn(this,e,n),this.nsps[e]=r),r}_destroy(e){const n=Object.keys(this.nsps);for(const r of n)if(this.nsps[r].active)return;this._close()}_packet(e){const n=this.encoder.encode(e);for(let r=0;r<n.length;r++)this.engine.write(n[r],e.options)}cleanup(){this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close"),this.engine&&this.engine.close()}disconnect(){return this._close()}onclose(e,n){this.cleanup(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",e,n),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const e=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const n=this.backoff.duration();this._reconnecting=!0;const r=this.setTimeoutFn(()=>{e.skipReconnect||(this.emitReserved("reconnect_attempt",e.backoff.attempts),!e.skipReconnect&&e.open(i=>{i?(e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",i)):e.onreconnect()}))},n);this.opts.autoUnref&&r.unref(),this.subs.push(()=>{this.clearTimeoutFn(r)})}}onreconnect(){const e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}}const Se={};function Je(t,e){typeof t=="object"&&(e=t,t=void 0),e=e||{};const n=no(t,e.path||"/socket.io"),r=n.source,i=n.id,o=n.path,a=Se[i]&&o in Se[i].nsps,c=e.forceNew||e["force new connection"]||e.multiplex===!1||a;let d;return c?d=new $t(r,e):(Se[i]||(Se[i]=new $t(r,e)),d=Se[i]),n.query&&!e.query&&(e.query=n.queryKey),d.socket(n.path,e)}Object.assign(Je,{Manager:$t,Socket:Yn,io:Je,connect:Je});const mo=["new-support-message","updated-support-message","deleted-support-message","new-customer-message","thread-closed","thread-reopened","thread-assigned","thread-reassigned","support-typing","presence-updated","conversations-paused"];function vo(t,e,n){const r=Je(t,{path:"/socket"});let i=!1,o=0,a;for(const c of mo)r.on(c,d=>n.event(c,d));return r.on("connect",()=>{o=0;const c=xt();r.emit("identify",{jwt:e,...c?{pageUrl:c}:{}}),n.status(!0)}),r.on("disconnect",c=>{n.status(!1),c==="io server disconnect"&&!i&&(a=setTimeout(()=>r.connect(),Math.min(3e4,1e3*2**o++)))}),r.on("connect_error",()=>n.status(!1)),r.on("error",c=>{c?.message==="Invalid token"&&n.invalidToken()}),{close(){i=!0,clearTimeout(a),r.removeAllListeners(),r.disconnect()}}}const yo="Customer support";function Kn(t){const e=t;return!e?.displayName||e.displayName===yo?null:{displayName:e.displayName,displayAvatarURL:e.displayAvatarURL??"",status:e.status??"offline"}}function bo(t){let e=5381;for(let n=0;n<t.length;n++)e=(e<<5)+e+t.charCodeAt(n)|0;return(e>>>0).toString(36)}function Xn(t){return t.id?`id:${t.id}`:`d:${t.date}:${t.support?"s":"c"}:${bo(t.content??"")}:${t.attachments?.length??0}`}function Ze(t,e){const n=Xn(t);return{key:e.get(n)??n,sid:n,from:t.support?"agent":"me",authorName:t.authorName??"",...t.authorAvatarURL?{authorAvatarURL:t.authorAvatarURL}:{},text:t.content??"",date:Number(t.date),attachments:Array.isArray(t.attachments)?t.attachments:[],emojis:t.emojis??{}}}const Jn=(t,e)=>t.date-e.date;function Zn(t,e){return{threadId:t,status:"open",csMember:null,messages:[],lastMessageDate:e}}function Gn(t,e){const n=new Set,r=[];for(const i of t.messages??[]){if(!Number.isFinite(Number(i?.date)))continue;const o=Ze(i,e);n.has(o.sid)||(n.add(o.sid),r.push(o))}return r.sort(Jn),{threadId:t.threadId,status:t.status==="closed"?"closed":"open",csMember:Kn(t.csMember),messages:r,lastMessageDate:r[r.length-1]?.date??(Number(t.lastMessageDate)||Date.now())}}function Qn(t,e){const n=t.messages.findIndex(i=>i.sid===e.sid),r=n===-1?[...t.messages,e].sort(Jn):t.messages.map((i,o)=>o===n?{...e,key:i.key}:i);return{...t,messages:r,lastMessageDate:Math.max(t.lastMessageDate,e.date)}}function er(t,e,n){if(e){const r=t.messages.find(i=>i.sid===`id:${e}`);if(r)return r}return t.messages.find(r=>r.from==="agent"&&r.date===n)}function tr(t,e,n){return{...t,messages:t.messages.map(r=>r.sid===e?{...r,...n}:r)}}function xo(t,e){return{...t,messages:t.messages.filter(n=>n.sid!==e)}}function Ge(t,e){let n=!1;const r={...t};for(const i of Object.values(t))i.status==="open"&&i.threadId!==e&&(r[i.threadId]={...i,status:"closed"},n=!0);return n?r:t}function nr(t){return Object.values(t).sort((e,n)=>n.lastMessageDate-e.lastMessageDate)}function Qe(t){return nr(t).find(e=>e.status==="open")??null}function et(t){return t.guild.acceptingConversations!==!1}function rr(t){return et(t)||t.open||Qe(t.conversations)!==null}function wo(t){if(!t)return 0;for(let e=t.messages.length-1;e>=0;e--)if(t.messages[e].from==="agent")return t.messages[e].date;return 0}function ir(t,e){const n=Qe(t);return n?n.messages.filter(r=>r.from==="agent"&&!r.deleted&&r.date>e).length:0}function _o(t,e){const n=t.messages.filter(r=>r.from==="agent").map(r=>r.date).sort((r,i)=>i-r);return e<=0?n[0]??0:e>=n.length?0:n[e]}function ko(t){for(let e=t.messages.length-1;e>=0;e--)if(t.messages[e].from==="agent"&&t.messages[e].authorName)return t.messages[e].authorName;return null}function or(t){try{const e=localStorage.getItem(t);return e?JSON.parse(e):null}catch{return null}}function Eo(t,e){try{localStorage.setItem(t,JSON.stringify(e))}catch{}}function Mt(t){try{localStorage.removeItem(t)}catch{}}function Ao(t){try{const e=document.cookie.split("; ").find(n=>n.startsWith(`${t}=`));return e?decodeURIComponent(e.slice(t.length+1)):null}catch{return null}}function To(t){try{document.cookie=`${t}=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/`}catch{}}const sr={name:"",email:"",avatarUrl:"",verifiedUserId:null,metadata:null};function So(){return{boot:"loading",activeAt:null,guild:{},dark:!1,open:!1,view:"chat",nav:0,navPrev:null,activeThreadId:null,identity:sr,token:null,conversations:{},synced:!1,past:"idle",outbox:[],tray:[],typing:{},connection:"off",lastReadAt:0,events:{},preview:null,lightbox:null,notice:null}}const Co=30,ar=200,Ut=t=>`deskcord:${t}`,K=t=>typeof t=="string",Ce=t=>typeof t=="number"&&Number.isFinite(t);function Ro(t){return!t||!K(t.sid)||!K(t.key)||!Ce(t.date)?null:{key:t.key,sid:t.sid,from:t.from==="me"?"me":"agent",authorName:K(t.authorName)?t.authorName:"",...K(t.authorAvatarURL)?{authorAvatarURL:t.authorAvatarURL}:{},text:K(t.text)?t.text:"",date:t.date,attachments:Array.isArray(t.attachments)?t.attachments:[],emojis:t.emojis&&typeof t.emojis=="object"?t.emojis:{},...t.edited?{edited:!0}:{}}}function Io(t){if(!t||!K(t.threadId)||!t.threadId)return null;const e=(Array.isArray(t.messages)?t.messages:[]).map(Ro).filter(n=>!!n).slice(-ar);return{threadId:t.threadId,status:t.status==="open"?"open":"closed",csMember:t.csMember??null,messages:e,lastMessageDate:Ce(t.lastMessageDate)?t.lastMessageDate:e[e.length-1]?.date??0}}function cr(t){return{name:K(t?.name)?t.name:"",email:K(t?.email)?t.email:"",avatarUrl:K(t?.avatarUrl)?t.avatarUrl:"",verifiedUserId:K(t?.verifiedUserId)?t.verifiedUserId:null,metadata:kn(t?.metadata,()=>{})}}function Lo(){const t=or("discord-widget-storage"),e=Ao("discord-widget");if(!t&&!e)return null;const n=t?.state??{},r=e||(K(n.token)&&n.token?n.token:null);return Mt("discord-widget-storage"),Mt("deskcord_last_read"),Mt("deskcord_unread_count"),To("discord-widget"),{token:r,identity:cr({name:n.username,email:n.email,avatarUrl:n.avatarUrl,verifiedUserId:n.verifiedUserId}),conversations:{},lastReadAt:0,guild:{},activeAt:null,outbox:[]}}function lr(t){const e=or(Ut(t));if(!e||e.v!==1)return Lo();const n={};for(const i of Array.isArray(e.conversations)?e.conversations:[]){const o=Io(i);o&&(n[o.threadId]=o)}const r=(Array.isArray(e.outbox)?e.outbox:[]).filter(i=>K(i?.localId)&&K(i?.text)&&i.text).map(i=>({localId:i.localId,text:i.text,state:i.state==="held"||i.state==="queued"?i.state:"failed",progress:0,attempts:0,createdAt:Ce(i.createdAt)?i.createdAt:Date.now()}));return{token:K(e.token)&&e.token?e.token:null,identity:cr(e.identity),conversations:n,lastReadAt:Ce(e.lastReadAt)?e.lastReadAt:0,guild:e.guild&&typeof e.guild=="object"?e.guild:{},activeAt:Ce(e.activeAt)?e.activeAt:null,outbox:r}}function No(t,e){const n=Object.values(e.conversations).sort((i,o)=>o.lastMessageDate-i.lastMessageDate).slice(0,Co).map(i=>({...i,messages:i.messages.filter(o=>!o.deleted).slice(-ar)})),r={v:1,token:e.token,identity:e.identity,conversations:n,lastReadAt:e.lastReadAt,guild:e.guild,activeAt:e.activeAt,outbox:e.outbox.filter(i=>!i.file&&i.text).map(({localId:i,text:o,state:a,createdAt:c})=>({localId:i,text:o,state:a,createdAt:c}))};Eo(Ut(t),r)}var ue,U,Dt,dr,tt=0,ur=[],z=$,pr=z.__b,fr=z.__r,hr=z.diffed,gr=z.__c,mr=z.unmount,vr=z.__;function Re(t,e){z.__h&&z.__h(U,t,tt||e),tt=0;var n=U.__H||(U.__H={__:[],__h:[]});return t>=n.__.length&&n.__.push({}),n.__[t]}function j(t){return tt=1,yr(wr,t)}function yr(t,e,n){var r=Re(ue++,2);if(r.t=t,!r.__c&&(r.__=[wr(void 0,e),function(c){var d=r.__N?r.__N[0]:r.__[0],u=r.t(d,c);d!==u&&(r.__N=[u,r.__[1]],r.__c.setState({}))}],r.__c=U,!U.u)){var i=function(c,d,u){if(!r.__c.__H)return!0;var g=r.__c.__H.__.filter(function(h){return!!h.__c});if(g.every(function(h){return!h.__N}))return!o||o.call(this,c,d,u);var p=r.__c.props!==c;return g.forEach(function(h){if(h.__N){var x=h.__[0];h.__=h.__N,h.__N=void 0,x!==h.__[0]&&(p=!0)}}),o&&o.call(this,c,d,u)||p};U.u=!0;var o=U.shouldComponentUpdate,a=U.componentWillUpdate;U.componentWillUpdate=function(c,d,u){if(this.__e){var g=o;o=void 0,i(c,d,u),o=g}a&&a.call(this,c,d,u)},U.shouldComponentUpdate=i}return r.__N||r.__}function ce(t,e){var n=Re(ue++,3);!z.__s&&Pt(n.__H,e)&&(n.__=t,n.i=e,U.__H.__h.push(n))}function N(t,e){var n=Re(ue++,4);!z.__s&&Pt(n.__H,e)&&(n.__=t,n.i=e,U.__h.push(n))}function S(t){return tt=5,nt(function(){return{current:t}},[])}function nt(t,e){var n=Re(ue++,7);return Pt(n.__H,e)&&(n.__=t(),n.__H=e,n.__h=t),n.__}function br(t){var e=U.context[t.__c],n=Re(ue++,9);return n.c=t,e?(n.__==null&&(n.__=!0,e.sub(U)),e.props.value):t.__}function Oo(){for(var t;t=ur.shift();)if(t.__P&&t.__H)try{t.__H.__h.forEach(rt),t.__H.__h.forEach(zt),t.__H.__h=[]}catch(e){t.__H.__h=[],z.__e(e,t.__v)}}z.__b=function(t){U=null,pr&&pr(t)},z.__=function(t,e){t&&e.__k&&e.__k.__m&&(t.__m=e.__k.__m),vr&&vr(t,e)},z.__r=function(t){fr&&fr(t),ue=0;var e=(U=t.__c).__H;e&&(Dt===U?(e.__h=[],U.__h=[],e.__.forEach(function(n){n.__N&&(n.__=n.__N),n.i=n.__N=void 0})):(e.__h.forEach(rt),e.__h.forEach(zt),e.__h=[],ue=0)),Dt=U},z.diffed=function(t){hr&&hr(t);var e=t.__c;e&&e.__H&&(e.__H.__h.length&&(ur.push(e)!==1&&dr===z.requestAnimationFrame||((dr=z.requestAnimationFrame)||$o)(Oo)),e.__H.__.forEach(function(n){n.i&&(n.__H=n.i),n.i=void 0})),Dt=U=null},z.__c=function(t,e){e.some(function(n){try{n.__h.forEach(rt),n.__h=n.__h.filter(function(r){return!r.__||zt(r)})}catch(r){e.some(function(i){i.__h&&(i.__h=[])}),e=[],z.__e(r,n.__v)}}),gr&&gr(t,e)},z.unmount=function(t){mr&&mr(t);var e,n=t.__c;n&&n.__H&&(n.__H.__.forEach(function(r){try{rt(r)}catch(i){e=i}}),n.__H=void 0,e&&z.__e(e,n.__v))};var xr=typeof requestAnimationFrame=="function";function $o(t){var e,n=function(){clearTimeout(r),xr&&cancelAnimationFrame(e),setTimeout(t)},r=setTimeout(n,100);xr&&(e=requestAnimationFrame(n))}function rt(t){var e=U,n=t.__c;typeof n=="function"&&(t.__c=void 0,n()),U=e}function zt(t){var e=U;t.__c=t.__(),U=e}function Pt(t,e){return!t||t.length!==e.length||e.some(function(n,r){return n!==t[r]})}function wr(t,e){return typeof e=="function"?e(t):e}function Mo(t){let e=t;const n=new Set;return{get:()=>e,set(r){const i=typeof r=="function"?r(e):r;e={...e,...i},n.forEach(o=>o())},subscribe(r){return n.add(r),()=>n.delete(r)}}}function Uo(t,e){if(Object.is(t,e))return!0;if(typeof t!="object"||typeof e!="object"||t===null||e===null||Array.isArray(t)!==Array.isArray(e))return!1;const n=Object.keys(t);return n.length!==Object.keys(e).length?!1:n.every(r=>Object.is(t[r],e[r]))}function Do(t,e,n=Uo){const[,r]=yr(c=>c+1,0),i=S(e);i.current=e;const o=e(t.get()),a=S(o);return a.current=o,N(()=>{const c=()=>{n(i.current(t.get()),a.current)||r(0)},d=t.subscribe(c);return c(),d},[t,n]),o}const _r=["image/png","image/jpeg","image/gif","image/webp","application/pdf"],zo=10*1024*1024,kr=10,be=2e3,Po=8e3,Bo=12*60*60*1e3,Fo=5*60*1e3,Ho=/^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/,Er=256,jo=2048,Ar=t=>Ho.test(t.trim()),Bt=t=>`${t}${Date.now().toString(36)}${Math.random().toString(36).slice(2,8)}`,qo=()=>document.visibilityState==="visible"&&document.hasFocus();function Tr(t){try{const e=JSON.parse(atob(t.split(".")[1].replace(/-/g,"+").replace(/_/g,"/")));return Number.isFinite(e.exp)?e.exp*1e3:null}catch{return null}}function Vo(t){return typeof t!="string"||!t?"":!/^https:\/\/\S+$/i.test(t)||t.length>jo?(console.warn("[Deskcord] avatarUrl ignored: it must be an https:// URL of at most 2048 characters."),""):t}function Wo(t){const e=[];let n=t;for(;n.length>be;){let r=n.lastIndexOf(`
|
|
2
|
+
`,be);r<be/2&&(r=n.lastIndexOf(" ",be)),r<be/2&&(r=be),e.push(n.slice(0,r).trim()),n=n.slice(r).trim()}return n&&e.push(n),e}function Yo(t){const e=Mo(So()),{get:n,set:r}=e,i=_i(t,()=>te()),o=new Map,a=new Map,c=new Map;let d=null,u=0,g=!1,p,h=null,x=0;const w=[];let k,_,A=0,y=0,L=!1,E=!1;function O(l){x>0?w.push(l):l()}function P(){for(;x===0&&w.length;)w.shift()()}function V(){et(n())&&r(l=>({guild:{...l.guild,acceptingConversations:!1}}))}function te(){r({boot:"hidden",open:!1,activeAt:null}),T()}function F(l,f,v=!1){let m=!0;return r(b=>{const C=b.conversations[l];if(!C&&!v)return m=!1,{};m=!!C;const I=C??Zn(l,Date.now());let q={...b.conversations,[l]:f(I)};return C||(q=Ge(q,l)),{conversations:q}}),m}function J(l){const f=Qe(l.conversations);return f?{view:"chat",activeThreadId:f.threadId}:Object.keys(l.conversations).length||l.token?{view:"home",activeThreadId:null}:{view:"chat",activeThreadId:null}}function Y(){L||n().open||r(l=>J(l))}function Z(){const l=n().token;if(!l)return;d?.close();const f=u;r({connection:"connecting"}),setTimeout(()=>{f===u&&!n().synced&&_e()},3e3),d=vo(t.domain,l,{event:(v,m)=>{f===u&&Qs(v,m)},status:v=>{f===u&&ne(v)},invalidToken:()=>{f===u&&Gt()}})}function T(){d?.close(),d=null,n().connection!=="off"&&r({connection:"off"})}function ne(l){const f=n().connection;l?(r({connection:"up"}),_e(),ge()):f==="up"&&r({connection:"down"})}async function _e(){const{token:l,synced:f}=n();if(!l)return;const v=u;A=Date.now();try{const[m,b]=await Promise.all([i.current(l),f?Promise.resolve(null):i.unreadCount(l).catch(()=>null)]);if(v!==u)return;O(()=>Gs(m,b))}catch(m){if(v!==u)return;m instanceof ve&&(m.status===401||m.status===403)&&Gt()}}function Oe(){clearTimeout(k),k=setTimeout(()=>void _e(),400)}function Gs(l,f){let v=!1;r(m=>{let b=Ge(m.conversations,l?.threadId??null),C=m.lastReadAt;if(l){const I=Gn(l,o);if(b={...b,[I.threadId]:I},f!==null){const q=_o(I,f);v=m.lastReadAt>q,C=Math.max(m.lastReadAt,q)}}return{conversations:b,lastReadAt:C,synced:!0}}),v&&oi(),Y()}async function Gt(){const l=n();if(l.identity.verifiedUserId){Ue();return}if(T(),r({token:null}),l.identity.name)try{await Jr()}catch{}}function Jr(){const l=n().token;if(l)return Promise.resolve(l);if(!h){const f=u;h=(async()=>{const{name:v,email:m,avatarUrl:b,metadata:C}=n().identity;if(!v)throw new Error("Missing name");const I=await i.token({name:v,email:m,avatarUrl:b,metadata:C});if(f!==u)throw new Error("Visitor changed");return r({token:I}),Z(),I})().finally(()=>{h=null})}return h}function Qs(l,f){const v=f??{},m=v.threadId;switch(l){case"conversations-paused":V();return;case"presence-updated":r(b=>({guild:{...b.guild,onlineCsMembers:Array.isArray(v.onlineCsMembers)?v.onlineCsMembers:[]}}));return;case"new-support-message":m&&v.message&&ea(m,v.message);return;case"new-customer-message":if(m&&v.message){const b=v.message;O(()=>Gr(m,b))}return;case"updated-support-message":m&&v.message&&ta(m,v.message);return;case"deleted-support-message":m&&na(m,v.messageId,v.messageDate);return;case"thread-closed":m&&(F(m,b=>({...b,status:"closed"})),Qt(m));return;case"thread-reopened":m&&(r(b=>({conversations:Ge(b.conversations,m),events:Zr(b,m,"reopened")})),F(m,b=>({...b,status:"open"}))||Oe());return;case"thread-assigned":case"thread-reassigned":{if(!m)return;const b=Kn(v.csMember);F(m,I=>({...I,csMember:b}),!0)||Oe(),l==="thread-reassigned"&&b&&r(I=>({events:Zr(I,m,"handoff",b.displayName)}));return}case"support-typing":m&&ra(m);return}}function Zr(l,f,v,m){return{...l.events,[f]:[...l.events[f]??[],{key:Bt("e"),kind:v,date:Date.now(),name:m}]}}function Gr(l,f){const v=Ze(f,o);return Number.isFinite(v.date)?(F(l,b=>Qn({...b,status:"open"},v),!0)||Oe(),v):null}function ea(l,f){const v=Gr(l,f);if(Qt(l),!v)return;n().open||r({preview:{threadId:l,key:v.key}})}function ta(l,f){const v=n().conversations[l],m=v&&er(v,f.id,f.date);if(!m)return;const b=Ze(f,o);F(l,C=>tr(C,m.sid,{text:b.text,attachments:b.attachments,emojis:b.emojis,edited:!0}))}function na(l,f,v){const m=n().conversations[l],b=m&&er(m,f,v);b&&(F(l,C=>tr(C,b.sid,{deleted:!0})),setTimeout(()=>F(l,C=>xo(C,b.sid)),400))}function ra(l){clearTimeout(c.get(l)),c.set(l,setTimeout(()=>Qt(l),Po)),n().typing[l]||r(f=>({typing:{...f.typing,[l]:!0}}))}function Qt(l){clearTimeout(c.get(l)),c.delete(l),n().typing[l]&&r(f=>({typing:{...f.typing,[l]:!1}}))}function Qr(l){const f={localId:Bt("l"),progress:0,attempts:0,createdAt:Date.now(),...l};return r(v=>({outbox:[...v.outbox,f]})),f}function $e(l,f){r(v=>({outbox:v.outbox.map(m=>m.localId===l?{...m,...f}:m)}))}function ei(l){r(f=>({outbox:f.outbox.filter(v=>v.localId!==l)}))}async function ge(){if(!g){g=!0;try{for(;;){const l=n();if(l.boot==="hidden")break;const f=l.outbox.find(v=>v.state==="queued");if(!f||!await ia(f))break}}finally{g=!1}}}async function ia(l){const f=u,v=l.attempts+1;$e(l.localId,{state:"sending",progress:0,attempts:v}),x++;try{const m=await Jr();if(l.file){const b=await i.upload(m,l.file,C=>$e(l.localId,{progress:C}));f===u&&ti(l,{threadId:b.threadId,id:b.id,date:Number.isFinite(b.date)?b.date:Date.now(),content:"",attachments:b.attachments??[]})}else{const b=await i.send(m,n().identity.name,l.text??"");f===u&&ti(l,{threadId:b.threadId,id:b.id,date:b.date,content:l.text??"",attachments:[]})}return!0}catch(m){return f!==u?!0:m instanceof mn?(ei(l.localId),!1):m instanceof vn?(r(C=>({outbox:C.outbox.map(I=>I.localId===l.localId||I.state==="queued"?{...I,state:"failed"}:I)})),V(),!1):(m instanceof bt||m instanceof ve&&(m.status===401||m.status>=500))&&v<3?($e(l.localId,{state:"queued"}),m instanceof ve&&m.status===401&&await Gt(),clearTimeout(p),p=setTimeout(()=>void ge(),2e3*v),!1):($e(l.localId,{state:"failed"}),!0)}finally{x--,P()}}function ti(l,f){const v={id:f.id,content:f.content,authorName:n().identity.name,support:!1,date:f.date,attachments:f.attachments};o.set(Xn(v),l.localId),l.fileInfo?.previewUrl&&a.set(l.localId,l.fileInfo.previewUrl);const m=Ze(v,o);r(b=>{const C=Ge(b.conversations,f.threadId),I=C[f.threadId]??Zn(f.threadId,f.date),q=b.activeThreadId,G=q===null||q===f.threadId||b.conversations[q]?.status==="open";return{conversations:{...C,[f.threadId]:Qn({...I,status:"open"},m)},outbox:b.outbox.filter(le=>le.localId!==l.localId),activeThreadId:G?f.threadId:q}})}function ni(){n().outbox.some(l=>l.state==="held")&&(r(l=>({outbox:l.outbox.map(f=>f.state==="held"?{...f,state:"queued"}:f)})),ge())}let Me=Promise.resolve();function ri(l){return Me=Me.then(l).catch(f=>console.error("[Deskcord]",f)),Me}async function oa(){let l;do l=Me,await l;while(l!==Me)}function Ue(){u++,T(),o.clear(),a.forEach(l=>URL.revokeObjectURL(l)),a.clear(),c.forEach(clearTimeout),c.clear(),w.length=0,L=!1,r(l=>({token:null,identity:sr,conversations:{},outbox:[],tray:[],typing:{},lastReadAt:0,events:{},preview:null,synced:!1,past:"idle",view:"chat",activeThreadId:null,nav:l.nav+1})),lt()}function sa(l){const{identity:f,token:v}=n();if(f.verifiedUserId){const m=v?Tr(v):null,b=!!v&&(m===null||m>Date.now()),C=l?.userId===f.verifiedUserId&&!!l?.userHash;(l===null||!b&&!C)&&Ue()}l&&ii(l)}function ii(l){return ri(()=>ca(l))}function aa(){return ri(Ue)}async function ca(l){if(typeof l?.name!="string"||!l.name.trim()||typeof l.email!="string"||!Ar(l.email)){console.error("[Deskcord] identify() needs at least a name and a valid email.");return}const f=!!(l.userId&&l.userHash),v=n().identity;v.verifiedUserId&&(!f||String(l.userId)!==v.verifiedUserId)&&Ue();const m={name:l.name.trim().slice(0,Er),email:l.email.trim(),avatarUrl:Vo(l.avatarUrl),metadata:kn(l.metadata)},b=n().identity,C=b.name!==m.name||b.email!==m.email||b.avatarUrl!==m.avatarUrl||JSON.stringify(b.metadata)!==JSON.stringify(m.metadata);r(G=>({identity:{...m,verifiedUserId:G.identity.verifiedUserId}})),ni();const I=n().token;if(f){const G=String(l.userId),le=I?Tr(I):null;if(b.verifiedUserId===G&&!C&&le!==null&&le-Date.now()>Bo)return;const fa=u,si=await i.identify({...m,userId:G,userHash:String(l.userHash)},I);if(fa!==u)return;if(si){const ha=b.verifiedUserId!==G;r(ga=>({token:si,identity:{...ga.identity,verifiedUserId:G}})),ha&&(r({past:"idle",synced:!1}),y=0,n().boot==="ready"&&Z());return}console.warn("[Deskcord] Identity verification failed: check that it's enabled (/identity-verification enable) and that userHash is HMAC-SHA256(secret, userId) computed on your server. Continuing without it."),b.verifiedUserId&&(Ue(),r({identity:{...m,verifiedUserId:null}}))}const q=n().token;if(q&&C)try{const G=await i.token(m,q);r({token:G})}catch{}}function De(){const l=n();if(!l.open||l.view!=="chat"||!l.activeThreadId||!qo())return;const f=wo(l.conversations[l.activeThreadId]);f>l.lastReadAt&&(r({lastReadAt:f}),oi())}function oi(){clearTimeout(_),_=setTimeout(()=>{const{token:l,lastReadAt:f}=n();l&&f&&i.markRead(l,f).catch(()=>{})},600)}let en,ct=null;function la(l){return{token:l.token,identity:l.identity,conversations:l.conversations,lastReadAt:l.lastReadAt,guild:l.guild,activeAt:l.activeAt,outbox:l.outbox}}function lt(){clearTimeout(en);const l=la(n());ct=l,No(t.appId,l)}function da(){const l=n(),f=ct;f&&f.token===l.token&&f.identity===l.identity&&f.conversations===l.conversations&&f.lastReadAt===l.lastReadAt&&f.guild===l.guild&&f.activeAt===l.activeAt&&f.outbox===l.outbox||(clearTimeout(en),en=setTimeout(lt,300))}function ua(l){if(l.key!==Ut(t.appId))return;const f=lr(t.appId),v=n();!f||f.token===v.token||(u++,T(),o.clear(),ct=f,r({token:f.token,identity:f.identity,conversations:f.conversations,lastReadAt:f.lastReadAt,outbox:[],synced:!1,past:"idle",activeThreadId:null,view:"chat",nav:v.nav+1}),r(m=>J(m)),f.token&&v.boot==="ready"&&Z())}async function pa(){const l=lr(t.appId);l&&(r({...l}),ct=null),r(b=>J(b)),sa(t.user),e.subscribe(da),e.subscribe(De),lt();const f=n().activeAt;f&&Date.now()-f<7*24*60*60*1e3&&r({boot:"ready"});let v=!1,m=null;try{[v,m]=await Promise.all([i.status(),i.settings().catch(()=>null)])}catch{v=!1}if(!v){te();return}r(b=>({boot:"ready",activeAt:Date.now(),guild:m?{...b.guild,...m}:b.guild})),E&&ke.open(),await oa(),n().token&&Z(),ge()}if(typeof window<"u"){window.addEventListener("storage",ua),window.addEventListener("pagehide",lt),window.addEventListener("online",()=>void ge());const l=()=>{De(),document.visibilityState==="visible"&&n().connection==="up"&&Date.now()-A>3e4&&_e()};document.addEventListener("visibilitychange",l),window.addEventListener("focus",l)}const ke={open(){if(n().boot!=="ready"){E=n().boot==="loading";return}rr(n())&&(E=!1,r({open:!0,preview:null}),De(),n().view==="home"&&ke.loadPast())},close(){r({open:!1,lightbox:null})},toggle(){n().open?ke.close():ke.open()},goHome(){L=!0,r(l=>({view:"home",nav:l.nav+1,navPrev:l.activeThreadId})),ke.loadPast()},openConversation(l){L=!0;const f=n();if(f.view==="chat"&&f.activeThreadId===l){r({preview:null}),De();return}r(v=>({view:"chat",activeThreadId:l,nav:v.nav+1,navPrev:v.activeThreadId,preview:null})),De()},newConversation(){L=!0;const l=Qe(n().conversations);r(f=>({view:"chat",activeThreadId:l?.threadId??null,nav:f.nav+1,navPrev:f.activeThreadId}))},dismissPreview(){r({preview:null})},async loadPast(l=!1){const f=n();if(!f.token||f.past==="loading"||!l&&f.past==="done"&&Date.now()-y<Fo)return;const v=u;r({past:"loading"});try{const m=await i.past(f.token);if(v!==u)return;y=Date.now(),r(b=>{const C={...b.conversations};for(const I of m)!I?.threadId||C[I.threadId]?.status==="open"||(C[I.threadId]={...Gn(I,o),status:"closed"});return{conversations:C,past:"done"}})}catch{v===u&&r({past:"error"})}},send(l){const f=n(),v=!f.identity.name,m=v?"held":"queued";f.activeThreadId&&f.conversations[f.activeThreadId]?.status==="closed"&&r({activeThreadId:null});for(const b of Wo(l.trim()))Qr({text:b,state:m});for(const b of f.tray)Qr({state:m,file:b.file,fileInfo:{name:b.file.name||"image.png",size:b.file.size,type:b.file.type,previewUrl:b.previewUrl,width:b.width,height:b.height}});r({tray:[]}),v||ge()},completeIntro(l,f){r(v=>({identity:{...v.identity,name:l.trim().slice(0,Er),email:f.trim()}})),ni()},retry(l){$e(l,{state:"queued",attempts:0}),ge()},discard(l){const f=n().outbox.find(v=>v.localId===l);f?.fileInfo?.previewUrl&&URL.revokeObjectURL(f.fileInfo.previewUrl),ei(l)},addFiles(l){let f=null;const v=[];for(const m of l){if(!_r.includes(m.type)){f=`“${m.name}” can't be sent. Send an image or a PDF.`;continue}if(m.size>zo){f=`“${m.name}” is over 10 MB.`;continue}if(n().tray.length+v.length>=kr){f=`You can attach up to ${kr} files at once.`;break}const b=m.type.startsWith("image/"),C={id:Bt("f"),file:m,previewUrl:b?URL.createObjectURL(m):null,width:4,height:3};if(v.push(C),C.previewUrl){const I=new Image;I.onload=()=>{const q=I.naturalWidth||4,G=I.naturalHeight||3;r(le=>({tray:le.tray.map(se=>se.id===C.id?{...se,width:q,height:G}:se)})),r(le=>({outbox:le.outbox.map(se=>se.fileInfo&&se.fileInfo.previewUrl===C.previewUrl?{...se,fileInfo:{...se.fileInfo,width:q,height:G}}:se)}))},I.src=C.previewUrl}}return v.length&&r(m=>({tray:[...m.tray,...v]})),f&&r({notice:{text:f,at:Date.now()}}),f},removeFromTray(l){const f=n().tray.find(v=>v.id===l);f?.previewUrl&&URL.revokeObjectURL(f.previewUrl),r(v=>({tray:v.tray.filter(m=>m.id!==l)}))},openLightbox(l,f,v){r({lightbox:{url:l,name:f,from:v}})},closeLightbox(){r({lightbox:null})},clearNotice(){r({notice:null})},setDark(l){n().dark!==l&&r({dark:l})}};return{store:e,actions:ke,boot:pa,identify:ii,logout:aa,localPreview:l=>a.get(l)??null}}const Ko="#5865F2",Xo=/^#?([0-9a-f]{3}|[0-9a-f]{6})$/i;function it(t){const e=t?.trim().match(Xo);if(!e)return null;let n=e[1];n.length===3&&(n=[...n].map(i=>i+i).join(""));const r=parseInt(n,16);return[r>>16&255,r>>8&255,r&255]}function Sr([t,e,n]){const r=i=>(i/=255,i<=.03928?i/12.92:((i+.055)/1.055)**2.4);return .2126*r(t)+.7152*r(e)+.0722*r(n)}function xe(t,e){const[n,r]=[Sr(t),Sr(e)].sort((i,o)=>o-i);return(n+.05)/(r+.05)}const Cr=(t,e,n)=>t.map((r,i)=>Math.round(r+(e[i]-r)*n)),Ie=t=>`rgb(${t.join(",")})`,pe=[255,255,255],ot=[17,19,24],Rr=[0,0,0];function Jo(t){const e=it(t.primary)??it(Ko),n=it(t.gradient)??Cr(e,Rr,.17),r=xe(e,pe)>=2.6?pe:ot,i=Math.min(xe(e,pe),xe(n,pe)),o=Math.min(xe(e,ot),xe(n,ot)),a=it(t.headerText)??(i>=2.6||i>=o?pe:ot),c=t.dark?[43,45,49]:pe;let d=e;for(let u=0;u<24&&xe(d,c)<4.5;u++)d=Cr(d,t.dark?pe:Rr,.08);return{vars:{"--dc-accent":Ie(e),"--dc-accent-2":Ie(n),"--dc-on-accent":Ie(r),"--dc-on-grad":Ie(a),"--dc-accent-text":Ie(d),"--dc-accent-soft":`rgba(${e.join(",")},${t.dark?.24:.14})`},flat:e.join()===n.join()}}const ee={out:"cubic-bezier(.22,1,.36,1)",spring:"cubic-bezier(.34,1.45,.64,1)",in:"cubic-bezier(.4,0,1,1)"},Zo=typeof matchMedia=="function"?matchMedia("(prefers-reduced-motion: reduce)"):null;function Ft(){return!Zo?.matches}function D(t,e,n={}){return!t||typeof t.animate!="function"?null:t.animate(e,{duration:300,easing:ee.out,fill:"backwards",...n,...Ft()?{}:{duration:1,delay:0}})}function Go(t){return t?t.finished.then(()=>{},()=>{}):Promise.resolve()}function Ir(t){return t.replace(/[&<>"']/g,e=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[e])}const Qo=/\.(gif|jpe?g|png|webp|apng)$/i,Lr=/https?:\/\/[^\s<]+[^\s<.,:;!?"')\]]/g;function es(t){try{const{protocol:e,pathname:n}=new URL(t);return(e==="https:"||e==="http:")&&Qo.test(n)}catch{return!1}}function ts(t){const e=[],n=t.replace(Lr,r=>es(r)?(e.push(r),""):r);return{text:e.length?n.replace(/[ \t]{2,}/g," ").trim():t,images:e}}function ns(t,e,n,r){return r[t]?.imageURL??`https://cdn.discordapp.com/emojis/${n}.${e?"gif":"webp"}?size=48`}function Nr(t,e={}){let n=Ir(t);const r=[],i=o=>`${r.push(o)-1}`;return n=n.replace(/```(?:[a-z0-9+-]*\n)?([\s\S]*?)```/gi,(o,a)=>i(`<pre><code>${a.replace(/^\n+|\n+$/g,"")}</code></pre>`)),n=n.replace(/`([^`\n]+)`/g,(o,a)=>i(`<code>${a}</code>`)),n=n.replace(/<(a?):(\w+):(\d+)>/g,(o,a,c,d)=>i(`<img class="dc-cemoji" alt=":${c}:" title=":${c}:" src="${Ir(ns(`<${a}:${c}:${d}>`,a==="a",d,e))}">`)),n=n.replace(/\[([^\]\n]+)\]\((https?:\/\/[^\s)]+)\)/g,(o,a,c)=>i(`<a href="${c}" target="_blank" rel="noopener noreferrer nofollow">${a}</a>`)),n=n.replace(Lr,o=>i(`<a href="${o}" target="_blank" rel="noopener noreferrer nofollow">${o.replace(/^https?:\/\//,"")}</a>`)),n=n.replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>").replace(/__(.+?)__/g,"<u>$1</u>").replace(/\*(?!\s)(.+?)\*/g,"<em>$1</em>").replace(/(^|[\s(])_(?!\s)(.+?)_(?=$|[\s).,!?])/gm,"$1<em>$2</em>").replace(/~~(.+?)~~/g,"<s>$1</s>").replace(/\|\|(.+?)\|\|/g,'<span class="dc-spoiler" tabindex="0" role="button" aria-label="Spoiler, click to reveal">$1</span>').replace(/^> (.*)$/gm,'<span class="dc-quote">$1</span>').replace(/^[-*] (?=\S)/gm,"• ").replace(/\n/g,"<br>"),n.replace(/\u0001(\d+)\u0001/g,(o,a)=>r[Number(a)])}const Or=Intl.Segmenter,$r=Or?new Or:null;function rs(t){const e=t.replace(/<a?:\w+:\d+>/g,"⭐").replace(/\s+/g,"");return!e||!/^(?:\p{Extended_Pictographic}|\p{Emoji_Modifier}|[\u{1F1E6}-\u{1F1FF}]||️|⃣)+$/u.test(e)?!1:($r?[...$r.segment(e)].length:[...e].length)<=3}function Mr(t){return t.replace(/<a?:(\w+):\d+>/g,":$1:").replace(/```[\s\S]*?```/g,"[code]").replace(/[*_`|~]/g,"").replace(/\s+/g," ").trim()}const is={x:"M6 6l12 12M18 6 6 18",down:"m6 9 6 6 6-6",left:"m15 18-6-6 6-6",right:"m9 18 6-6-6-6",send:"M12 19V5M5.5 11.5 12 5l6.5 6.5",arrow:"M5 12h14M13 6l6 6-6 6",clip:"m20.5 11.5-8.3 8.3a5.2 5.2 0 0 1-7.4-7.4l8.6-8.6a3.5 3.5 0 0 1 4.9 4.9l-8.5 8.6a1.75 1.75 0 0 1-2.5-2.5l7.9-7.9",check:"m5 12.5 4.5 4.5L19 7.5",dl:"M12 4v11m-5-5 5 5 5-5M5 20h14",retry:"M4 12a8 8 0 0 1 14-5.3M20 4v4h-4M20 12a8 8 0 0 1-14 5.3M4 20v-4h4",plus:"M12 5v14M5 12h14",upload:"M12 16V4m-5 5 5-5 5 5M5 20h14",ext:"M14 4h6v6M20 4l-9 9M18 14v5a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h5"};function M({name:t,size:e=18,class:n}){const r={width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":2,"stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",class:n};return t==="smile"?s("svg",{...r,children:[s("circle",{cx:"12",cy:"12",r:"9"}),s("path",{d:"M8.5 14.5a4.5 4.5 0 0 0 7 0"}),s("circle",{cx:"9",cy:"9.8",r:"1.1",fill:"currentColor",stroke:"none"}),s("circle",{cx:"15",cy:"9.8",r:"1.1",fill:"currentColor",stroke:"none"})]}):t==="clock"?s("svg",{...r,children:[s("circle",{cx:"12",cy:"12",r:"8.5"}),s("path",{d:"M12 7.5V12l3 2"})]}):t==="alert"?s("svg",{...r,children:[s("circle",{cx:"12",cy:"12",r:"9"}),s("path",{d:"M12 7.5v5.5"}),s("circle",{cx:"12",cy:"16.3",r:"1.2",fill:"currentColor",stroke:"none"})]}):s("svg",{...r,children:s("path",{d:is[t]})})}function os(){return s("svg",{width:"26",height:"26",viewBox:"0 0 24 24","aria-hidden":"true",children:[s("path",{fill:"currentColor",d:"M12 3.5c4.97 0 9 3.36 9 7.5s-4.03 7.5-9 7.5c-.98 0-1.92-.13-2.8-.37L5.1 20.1c-.5.25-1.06-.22-.9-.75l1.02-3.34C3.84 14.7 3 12.93 3 11c0-4.14 4.03-7.5 9-7.5Z"}),s("circle",{cx:"8.6",cy:"11",r:"1.25",fill:"var(--dc-accent)"}),s("circle",{cx:"12",cy:"11",r:"1.25",fill:"var(--dc-accent)"}),s("circle",{cx:"15.4",cy:"11",r:"1.25",fill:"var(--dc-accent)"})]})}function Ur(){return s("svg",{viewBox:"0 0 642 74","aria-label":"Deskcord",children:s("path",{fill:"currentColor",d:"M23.9 73.2C19.43 73.2 15.37 72.07 11.7 69.8 8.1 67.53 5.23 64.43 3.1 60.5 1.03 56.5 0 51.97 0 46.9c0-5.13 1.07-9.67 3.2-13.6 2.13-4 5.03-7.13 8.7-9.4 3.73-2.33 7.87-3.5 12.4-3.5 3.47 0 6.5.63 9.1 1.9 2.6 1.2 4.73 2.97 6.4 5.3V0h15v72H41.5l-1.7-6.5c-1 1.4-2.23 2.7-3.7 3.9-1.4 1.13-3.1 2.03-5.1 2.7-2 .73-4.37 1.1-7.1 1.1Zm3.9-13.1c2.47 0 4.63-.57 6.5-1.7 1.93-1.13 3.4-2.7 4.4-4.7 1.07-2 1.6-4.3 1.6-6.9s-.53-4.9-1.6-6.9c-1-2-2.47-3.57-4.4-4.7-1.87-1.13-4.03-1.7-6.5-1.7-2.4 0-4.57.57-6.5 1.7-1.87 1.13-3.33 2.7-4.4 4.7-1.07 2-1.6 4.27-1.6 6.8 0 2.6.53 4.93 1.6 7 1.07 2 2.53 3.57 4.4 4.7 1.93 1.13 4.1 1.7 6.5 1.7Zm58.81 13.1c-5.2 0-9.77-1.07-13.7-3.2-3.93-2.2-7.03-5.23-9.3-9.1-2.2-3.93-3.3-8.43-3.3-13.5 0-5.2 1.1-9.83 3.3-13.9 2.2-4.07 5.27-7.27 9.2-9.6 3.93-2.33 8.5-3.5 13.7-3.5 5.07 0 9.5 1.1 13.3 3.3 3.8 2.2 6.77 5.2 8.9 9 2.2 3.73 3.3 8.07 3.3 13 0 .67-.03 1.43-.1 2.3 0 .8-.07 1.63-.2 2.5H71.01v-8.7h25.7c-.13-2.8-1.17-5.03-3.1-6.7-1.87-1.73-4.2-2.6-7-2.6-2.13 0-4.07.5-5.8 1.5-1.73 1-3.13 2.5-4.2 4.5-1 2-1.5 4.53-1.5 7.6v3c0 2.33.43 4.4 1.3 6.2.93 1.8 2.23 3.2 3.9 4.2 1.73 1 3.77 1.5 6.1 1.5 2.2 0 4-.43 5.4-1.3 1.47-.93 2.6-2.1 3.4-3.5h15.3c-.93 3.2-2.53 6.1-4.8 8.7-2.27 2.53-5.030 4.57-8.3 6.1-3.27 1.47-6.87 2.2-10.8 2.2Zm51.43 0c-4.73 0-8.83-.73-12.3-2.2-3.4-1.53-6.1-3.6-8.1-6.2-1.93-2.6-3.03-5.53-3.3-8.8h14.9c.27 1.13.73 2.17 1.4 3.1.73.87 1.7 1.57 2.9 2.1 1.27.47 2.67.7 4.2.7 1.67 0 3-.2 4-.6 1.07-.47 1.87-1.07 2.4-1.8.53-.73.8-1.5.8-2.3 0-1.27-.4-2.23-1.2-2.9-.73-.67-1.83-1.2-3.3-1.6-1.47-.47-3.23-.9-5.3-1.3-2.4-.53-4.8-1.13-7.2-1.8-2.33-.73-4.43-1.630-6.3-2.7-1.8-1.07-3.27-2.43-4.4-4.1-1.07-1.73-1.6-3.83-1.6-6.3 0-3 .83-5.7 2.5-8.1 1.67-2.47 4.07-4.4 7.2-5.8 3.13-1.47 6.93-2.2 11.4-2.2 6.33 0 11.3 1.4 14.9 4.2 3.6 2.8 5.73 6.57 6.4 11.3h-14c-.4-1.33-1.23-2.33-2.5-3-1.27-.73-2.87-1.1-4.8-1.1-2.2 0-3.87.37-5 1.1-1.13.73-1.7 1.7-1.7 2.9 0 .8.37 1.53 1.1 2.2.8.6 1.93 1.13 3.4 1.6 1.47.47 3.27.93 5.4 1.4 4.07.87 7.57 1.8 10.5 2.8 3 1 5.33 2.47 7 4.4 1.67 1.87 2.47 4.6 2.4 8.2.07 3.27-.8 6.17-2.6 8.7-1.73 2.53-4.23 4.53-7.5 6-3.27 1.4-7.17 2.1-11.7 2.1Zm60.6-1.2-20.8-27.6 18.5-22.8h17.7l-24.9 29.2v-12L217.24 72h-18.6Zm-33.6 0V0h15v72h-15Zm74.47 1.2c-5.2 0-9.8-1.13-13.8-3.4-3.93-2.27-7.03-5.37-9.3-9.3-2.2-3.93-3.3-8.43-3.3-13.5 0-5.2 1.1-9.77 3.3-13.7 2.27-4 5.37-7.13 9.3-9.4 4-2.33 8.6-3.5 13.8-3.5 6.6 0 12.13 1.73 16.6 5.2 4.53 3.47 7.4 8.3 8.6 14.5h-15.9c-.6-2.13-1.73-3.8-3.4-5-1.67-1.2-3.67-1.8-6-1.8-2.2 0-4.13.57-5.8 1.7-1.6 1.07-2.87 2.63-3.8 4.7-.93 2-1.4 4.37-1.4 7.1 0 2.07.27 3.93.8 5.6.53 1.67 1.27 3.1 2.2 4.3 1 1.2 2.17 2.13 3.5 2.8 1.33.6 2.83.9 4.5.9 1.6 0 3-.27 4.2-.8 1.27-.53 2.33-1.3 3.2-2.3.93-1 1.6-2.23 2-3.7h15.9c-1.2 6-4.07 10.77-8.6 14.3-4.53 3.53-10.07 5.3-16.6 5.3Zm55.02 0c-4.87 0-9.23-1.13-13.1-3.4-3.87-2.27-6.93-5.37-9.2-9.3-2.27-4-3.4-8.53-3.4-13.6 0-5.2 1.13-9.77 3.4-13.7 2.27-4 5.33-7.13 9.2-9.4 3.93-2.27 8.3-3.4 13.1-3.4 4.93 0 9.33 1.13 13.2 3.4 3.87 2.27 6.93 5.4 9.2 9.4 2.27 3.93 3.4 8.47 3.4 13.6 0 5.13-1.13 9.7-3.4 13.7-2.27 3.93-5.33 7.03-9.2 9.3-3.87 2.27-8.27 3.4-13.2 3.4Zm0-13c2 0 3.77-.5 5.3-1.5 1.6-1 2.87-2.5 3.8-4.5.93-2 1.4-4.47 1.4-7.4s-.47-5.4-1.4-7.4c-.93-2-2.17-3.5-3.7-4.5-1.53-1-3.3-1.5-5.3-1.5s-3.8.5-5.4 1.5c-1.53 1-2.77 2.5-3.7 4.5-.93 2-1.4 4.47-1.4 7.4s.47 5.4 1.4 7.4c.93 2 2.17 3.5 3.7 4.5 1.6 1 3.37 1.5 5.3 1.5Zm31.32 11.8V21.6h13.3l1.4 9.2c1.33-2.13 2.9-3.97 4.7-5.5 1.8-1.53 3.87-2.73 6.2-3.6 2.4-.87 4.97-1.3 7.7-1.3v15.9h-5c-2 0-3.83.23-5.5.7-1.6.4-3 1.1-4.2 2.1-1.13 1-2.03 2.37-2.7 4.1-.6 1.67-.9 3.77-.9 6.3V72h-15Zm58 1.2c-4.47 0-8.53-1.13-12.2-3.4-3.6-2.27-6.47-5.37-8.6-9.3-2.07-4-3.1-8.53-3.1-13.6 0-5.13 1.07-9.67 3.2-13.6 2.13-4 5.03-7.13 8.7-9.4 3.73-2.33 7.87-3.5 12.4-3.5 3.47 0 6.5.63 9.1 1.9 2.6 1.2 4.73 2.97 6.4 5.3V0h15v72h-13.3l-1.7-6.5c-1 1.4-2.23 2.7-3.7 3.9-1.4 1.13-3.1 2.03-5.1 2.7-2 .73-4.37 1.1-7.1 1.1Zm3.9-13.1c2.47 0 4.63-.57 6.5-1.7 1.93-1.13 3.4-2.7 4.4-4.7 1.07-2 1.6-4.3 1.6-6.9s-.53-4.9-1.6-6.9c-1-2-2.47-3.57-4.4-4.7-1.87-1.13-4.03-1.7-6.5-1.7-2.4 0-4.57.57-6.5 1.7-1.87 1.13-3.33 2.7-4.4 4.7-1.07 2-1.6 4.27-1.6 6.8 0 2.6.53 4.93 1.6 7 1.07 2 2.53 3.57 4.4 4.7 1.93 1.13 4.1 1.7 6.5 1.7Zm41.01 12.4c-2.73 0-4.97-.8-6.7-2.4-1.67-1.67-2.5-3.67-2.5-6 0-2.4.83-4.4 2.5-6 1.73-1.67 3.97-2.5 6.7-2.5 2.67 0 4.83.83 6.5 2.5 1.67 1.6 2.5 3.6 2.5 6 0 2.33-.83 4.33-2.5 6-1.67 1.6-3.83 2.4-6.5 2.4Zm38.66.7c-5.2 0-9.8-1.13-13.8-3.4-3.93-2.27-7.03-5.37-9.3-9.3-2.2-3.93-3.3-8.43-3.3-13.5 0-5.2 1.1-9.77 3.3-13.7 2.27-4 5.37-7.13 9.3-9.4 4-2.33 8.6-3.5 13.8-3.5 6.6 0 12.13 1.73 16.6 5.2 4.53 3.47 7.4 8.3 8.6 14.5h-15.9c-.6-2.13-1.73-3.8-3.4-5-1.67-1.2-3.67-1.8-6-1.8-2.2 0-4.13.57-5.8 1.7-1.6 1.07-2.87 2.63-3.8 4.7-.93 2-1.4 4.37-1.4 7.1 0 2.070.27 3.93.8 5.6.53 1.67 1.27 3.1 2.2 4.3 1 1.2 2.17 2.13 3.5 2.8 1.33.6 2.83.9 4.5.9 1.6 0 3-.27 4.2-.8 1.27-.53 2.33-1.3 3.2-2.3.93-1 1.6-2.23 2-3.7h15.9c-1.2 6-4.07 10.77-8.6 14.3-4.53 3.53-10.07 5.3-16.6 5.3ZM498.24 72V0h15v28.8c1.6-2.53 3.77-4.57 6.5-6.1 2.73-1.53 5.93-2.3 9.6-2.3 4.27 0 7.83.9 10.7 2.7 2.87 1.8 5.03 4.43 6.5 7.9 1.47 3.4 2.2 7.53 2.2 12.4V72h-14.9V44.8c0-3.73-.8-6.63-2.4-8.7-1.53-2.07-4-3.1-7.4-3.1-2 0-3.83.5-5.5 1.5-1.67 1-2.97 2.43-3.9 4.3-.93 1.8-1.4 3.97-1.4 6.5V72h-15Zm74.19 1.2c-4.2 0-7.7-.67-10.5-2-2.73-1.33-4.77-3.13-6.1-5.4-1.27-2.33-1.9-4.9-1.9-7.7 0-3 .73-5.63 2.2-7.9 1.53-2.33 3.9-4.17 7.1-5.5 3.2-1.4 7.23-2.1 12.1-2.1h12.2c0-2.27-.3-4.13-.9-5.6-.53-1.47-1.43-2.57-2.7-3.3-1.27-.73-3-1.1-5.2-1.1-2.33 0-4.3.47-5.9 1.4-1.6.93-2.6 2.4-3 4.4h-14.4c.33-3.6 1.5-6.73 3.5-9.4 2.07-2.67 4.8-4.77 8.2-6.3 3.4-1.53 7.3-2.3 11.7-2.3 4.8 0 8.97.8 12.5 2.4 3.53 1.53 6.27 3.8 8.2 6.8 2 3 3 6.73 3 11.2V72h-12.5l-1.8-7.3c-.73 1.27-1.6 2.43-2.6 3.5-1 1-2.17 1.9-3.5 2.7-1.33.73-2.8 1.3-4.4 1.7-1.6.4-3.37.6-5.3.6Zm3.7-11.4c1.6 0 3-.27 4.2-.8 1.2-.53 2.23-1.27 3.1-2.2.87-.93 1.57-2 2.1-3.2.6-1.27 1.03-2.63 1.3-4.1v-.1h-9.7c-1.67 0-3.07.23-4.2.7-1.07.4-1.87 1-2.4 1.8-.53.8-.8 1.73-.8 2.8 0 1.13.27 2.1.8 2.9.6.73 1.37 1.3 2.3 1.7 1 .33 2.1.5 3.3.5ZM632.3 72c-3.67 0-6.9-.57-9.7-1.7-2.8-1.2-4.97-3.13-6.5-5.8-1.53-2.67-2.3-6.3-2.3-10.9V34.1h-8.6V21.6h8.6l1.6-14.2h13.4v14.2h12.9v12.5h-12.9v19.7c0 2 .43 3.43 1.3 4.3.93.8 2.5 1.2 4.7 1.2h6.9V72h-9.4Z"})})}const Dr=gn(null),X=()=>br(Dr);function W(t){return Do(X().store,t)}function ss(t){const[,e]=j(0);ce(()=>{const n=setInterval(()=>e(r=>r+1),t);return()=>clearInterval(n)},[t])}function as(t,e,n,r,i={}){const[o,a]=j(t),c=S(t);c.current=t;const d=S(null);return N(()=>{if(t){d.current?.cancel(),d.current=null,o||a(!0);return}if(!o)return;const u=D(e.current,r,{duration:160,fill:"forwards",...i.exit});d.current=u,Go(u).then(()=>{!c.current&&d.current===u&&a(!1)})},[t]),N(()=>{t&&o&&D(e.current,n,{duration:380,...i.enter})},[t,o]),o}function cs(){const t=()=>document.visibilityState==="visible"&&document.hasFocus(),[e,n]=j(t);return ce(()=>{const r=()=>n(t());return document.addEventListener("visibilitychange",r),window.addEventListener("focus",r),window.addEventListener("blur",r),()=>{document.removeEventListener("visibilitychange",r),window.removeEventListener("focus",r),window.removeEventListener("blur",r)}},[]),e}const zr=()=>typeof matchMedia=="function"&&matchMedia("(pointer: fine)").matches,ls="(max-width: 520px), (max-height: 540px)",Pr="input:not([type=checkbox]):not([type=radio]):not([type=file]), textarea";function ds(t,e,n){const r=getComputedStyle(t);return Math.abs(n)>=Math.abs(e)?!/auto|scroll/.test(r.overflowY)||t.scrollHeight<=t.clientHeight?!1:n>0?t.scrollTop>0:t.scrollTop+t.clientHeight<t.scrollHeight-1:!/auto|scroll/.test(r.overflowX)||t.scrollWidth<=t.clientWidth?!1:e>0?t.scrollLeft>0:t.scrollLeft+t.clientWidth<t.scrollWidth-1}function us(t,e){N(()=>{const n=window.visualViewport,r=t.current,i=r?.parentElement;if(!e||!n||!r||!i||typeof matchMedia!="function")return;const o=matchMedia(ls),a=r.getRootNode(),c=()=>{const E=a.activeElement;return E?.matches(Pr)&&r.contains(E)?E:null},d=()=>{const E=c(),O=E?.closest(".dc-scroll");if(!E||!O)return;const P=E.getBoundingClientRect(),V=O.getBoundingClientRect();P.bottom>V.bottom?O.scrollTop+=P.bottom-V.bottom+12:P.top<V.top&&(O.scrollTop-=V.top-P.top+12)};let u=0;const g=()=>{let E=0;if(o.matches&&c()&&(E=Math.round(window.innerHeight-n.height-n.offsetTop),E<80&&(E=0)),E===u)return;const O=E>u;u=E,r.style.setProperty("--dc-keyboard",`${E}px`),O&&d()};let p=0;const h=()=>{cancelAnimationFrame(p),p=requestAnimationFrame(g)},x=E=>{E.target===r&&E.propertyName==="padding-bottom"&&u&&d()};let w=0,k=0,_=!1;const A=E=>{w=E.touches[0].clientX,k=E.touches[0].clientY,_=!1},y=E=>{if(!o.matches||E.touches.length>1||!E.cancelable)return;const{clientX:O,clientY:P}=E.touches[0],V=O-w,te=P-k;Math.abs(V)+Math.abs(te)>6&&(_=!0),w=O,k=P;for(let F=E.target;F&&F!==i;F=F.parentElement)if(ds(F,V,te))return;E.preventDefault()},L=E=>{const O=E.target;!o.matches||_||!E.cancelable||!O.matches(Pr)||c()===O&&u||(E.preventDefault(),c()===O&&O.blur(),O.focus({preventScroll:!0}))};return g(),n.addEventListener("resize",g),n.addEventListener("scroll",g),o.addEventListener("change",g),i.addEventListener("focusin",h),i.addEventListener("focusout",h),r.addEventListener("transitionend",x),i.addEventListener("touchstart",A,{passive:!0}),i.addEventListener("touchmove",y,{passive:!1}),i.addEventListener("touchend",L),()=>{cancelAnimationFrame(p),n.removeEventListener("resize",g),n.removeEventListener("scroll",g),o.removeEventListener("change",g),i.removeEventListener("focusin",h),i.removeEventListener("focusout",h),r.removeEventListener("transitionend",x),i.removeEventListener("touchstart",A),i.removeEventListener("touchmove",y),i.removeEventListener("touchend",L),r.style.removeProperty("--dc-keyboard")}},[e])}function ps(t){let e=0;for(let n=0;n<t.length;n++)e=(e*31+t.charCodeAt(n))%360;return e}const Br=t=>(t.trim()[0]??"?").toUpperCase();function fe({name:t,url:e,size:n=28,status:r}){const[i,o]=j(!1);return s("span",{class:"dc-av",style:`--s:${n}px;--h:${ps(t)}`,title:t,children:[e&&!i?s("img",{src:e,alt:"",loading:"lazy",onError:()=>o(!0)}):Br(t),r&&s("i",{class:`dot ${r}`})]})}function he({member:t,size:e,withStatus:n}){return s(fe,{name:t.displayName,url:t.displayAvatarURL,size:e,status:n?t.status:null})}function Le({size:t=36,dot:e}){const{iconURL:n,name:r}=W(a=>({iconURL:a.guild.iconURL,name:a.guild.name})),[i,o]=j(!1);return s("span",{class:"dc-guild",style:`--s:${t}px`,children:[n&&!i?s("img",{src:n,alt:"",onError:()=>o(!0)}):Br(r||"S"),e&&s("i",{class:`dot ${e}`})]})}const st={online:3,idle:2,dnd:1};function Ht(t,e=3){return[...t].sort((n,r)=>(st[r.status]??0)-(st[n.status]??0)).slice(0,e).reverse()}function jt(t){const e=[...t].sort((r,i)=>(st[i.status]??0)-(st[r.status]??0)).map(r=>r.displayName);if(e.length===1)return`${e[0]} is online`;if(e.length===2)return`${e[0]} and ${e[1]} are online`;const n=e.length-2;return`${e[0]}, ${e[1]} and ${n===1?e[2]:`${n} others`} are online`}const fs={online:"Online",idle:"Away",dnd:"Busy",invisible:"Offline",offline:"Offline"},hs="Hi there 👋",gs="We typically reply within a few minutes.",qt="No one is online right now. Leave a message and we'll get back to you here.",at=6e4,Vt=60*at,Ne=24*Vt;function we(t){return new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function ms(t,e=Date.now()){if(!Number.isFinite(t))return"";const n=e-t;return n<at?"now":n<Vt?`${Math.floor(n/at)} min`:n<Ne&&new Date(t).getDate()===new Date(e).getDate()?we(t):n<7*Ne?`${Math.max(1,Math.floor(n/Ne))}d`:new Date(t).toLocaleDateString([],{day:"numeric",month:"short"})}function vs(t,e=Date.now()){const n=new Date(e);return n.setHours(0,0,0,0),t>=n.getTime()?"Today":t>=n.getTime()-Ne?"Yesterday":new Date(t).toLocaleDateString([],{weekday:"short",day:"numeric",month:"short"})}function ys(t){const e=new Date(t);return`${e.getFullYear()}-${e.getMonth()}-${e.getDate()}`}function Wt(t){return Number.isFinite(t)?t<1024*1024?`${Math.max(1,Math.round(t/1024))} KB`:`${(t/1024/1024).toFixed(1)} MB`:""}function Yt(t){const e=t.lastIndexOf(".");return e>0&&e<t.length-1?t.slice(e+1).toUpperCase().slice(0,4):"FILE"}const bs={MIN:at,HOUR:Vt,DAY:Ne};function Fr(){const{actions:t}=X();return s("button",{class:"dc-hbtn","aria-label":"Close chat",onClick:t.close,children:[s(M,{name:"x",size:20,class:"ic-x"}),s(M,{name:"down",size:22,class:"ic-down"})]})}function xs(){const{actions:t}=X(),{guild:e,identity:n,conversations:r,past:i,lastReadAt:o,accepting:a}=W(_=>({guild:_.guild,accepting:et(_),identity:_.identity,conversations:_.conversations,past:_.past,lastReadAt:_.lastReadAt}));ss(3e4);const c=nt(()=>nr(r),[r]),d=c.find(_=>_.status==="open"),u=c.filter(_=>_.status==="closed"&&_.messages.length),g=e.onlineCsMembers,p=Array.isArray(g)&&g.length===0,h=n.name.trim().split(/\s+/)[0],x=e.header_title||(h?`Hi ${h} 👋`:hs),w=p?e.offline_message||qt:e.header_subtitle||gs,k=d?d.messages.filter(_=>_.from==="agent"&&_.date>o).length:0;return s(H,{children:[s("header",{class:"dc-head dc-hero",children:[s("div",{class:"top",children:[s(Le,{size:36}),s(Fr,{})]}),s("h2",{children:x}),s("p",{children:w}),g&&g.length>0&&s("div",{class:"dc-team",children:[s("span",{class:"stack",children:Ht(g).map(_=>s(he,{member:_,size:30,withStatus:!0},_.displayName))}),s("span",{children:jt(g)})]}),p&&s("div",{class:"dc-team",children:"The team is away right now"})]}),s("div",{class:"dc-home-body",children:[d?s("div",{class:"dc-card",children:[s("div",{class:"dc-eyebrow",children:"Ongoing conversation"}),s("div",{class:"dc-list",children:s(jr,{conv:d,unread:k,onOpen:()=>t.openConversation(d.threadId)})})]}):a?s("button",{class:"dc-card dc-cta",onClick:t.newConversation,children:[s("span",{class:"tx",children:[s("b",{children:"Send us a message"}),s("small",{children:p?"We'll reply as soon as we're back":"We typically reply within a few minutes"})]}),s("span",{class:"go",children:s(M,{name:"arrow",size:18})})]}):s("div",{class:"dc-card dc-cta is-paused","aria-live":"polite",children:s("span",{class:"tx",children:[s("b",{children:"We're not taking new conversations right now"}),s("small",{children:"Please come back a little later"})]})}),(u.length>0||i==="loading"||i==="error")&&s("div",{class:"dc-card",children:[s("div",{class:"dc-eyebrow",children:"Previous conversations"}),s("div",{class:"dc-list",children:[u.map(_=>s(jr,{conv:_,unread:0,onOpen:()=>t.openConversation(_.threadId)},_.threadId)),i==="loading"&&u.length===0&&s(H,{children:[s(Hr,{}),s(Hr,{})]})]}),i==="error"&&s("p",{class:"dc-empty",children:["Couldn't load your previous conversations."," ",s("button",{onClick:()=>void t.loadPast(!0),children:"Try again"})]})]}),s("a",{class:"dc-powered",href:"https://deskcord.chat",target:"_blank",rel:"noopener",children:["Powered by ",s(Ur,{})]})]})]})}function Hr(){return s("div",{class:"dc-skel-row","aria-hidden":"true",children:[s("i",{}),s("span",{children:[s("i",{}),s("i",{})]})]})}function ws(t){for(let e=t.messages.length-1;e>=0;e--){const n=t.messages[e];if(n.deleted)continue;const r=n.from==="me"?"You: ":"";if(n.text)return r+Mr(n.text);if(n.attachments.length)return r+(n.attachments[0].contentType?.startsWith("image/")?"📷 Image":`📄 ${n.attachments[0].name}`)}return""}function jr({conv:t,unread:e,onOpen:n}){const r=W(a=>a.guild.name),i=t.status==="closed",o=t.csMember?.displayName??ko(t);return s("button",{class:`dc-conv${e?" is-unread":""}`,onClick:n,children:[t.csMember?s(he,{member:t.csMember,size:40,withStatus:!i}):o?s(fe,{name:o,size:40}):s(Le,{size:40}),s("span",{class:"tx",children:[s("span",{class:"l1",children:[s("b",{children:o??r??"Support"}),s("time",{children:ms(t.lastMessageDate)})]}),s("span",{class:"l2",children:[i&&s("span",{class:"dc-pill ok",children:"Resolved"}),ws(t)]})]}),e>0?s("span",{class:"count",children:e}):s("span",{class:"chev",children:s(M,{name:"right",size:16})})]})}const _s=5*bs.MIN;function ks(t,e,n,r){const i=[];let o="",a=null,c=!1,d=!1,u=!1;const g=w=>{const k=ys(w);k!==o&&(i.push({type:"day",key:`day-${k}`,date:w}),o=k,a=null)},p=(w,k)=>{const _=a,A=!!_&&_.side===w&&k-_.date<_s;if(A){const y=i[i.length-1];(y.type==="msg"||y.type==="out")&&(y.last=!1)}return a={side:w,date:k},!A},h=[...(t?.messages??[]).map(w=>({date:w.date,m:w})),...n.map(w=>({date:w.date,e:w}))].sort((w,k)=>w.date-k.date);for(const w of h){if(g(w.date),w.e){i.push({type:"event",key:w.e.key,e:w.e}),a=null;continue}const k=w.m;k.from==="agent"?(d=!0,c||(c=!0,i.push({type:"joined",key:`joined-${k.key}`,name:k.authorName,avatar:k.authorAvatarURL,date:k.date}),a=null)):u=!0;const _=p(k.from==="me"?"me":`a:${k.authorName}`,k.date);i.push({type:"msg",key:k.key,m:k,first:_,last:!0,status:!1})}let x=!1;for(const w of e){g(w.createdAt),u=!0;const k=p("me",w.createdAt);i.push({type:"out",key:w.localId,o:w,first:k,last:!0}),w.state==="held"&&(x=!0)}if(!e.length)for(let w=i.length-1;w>=0;w--){const k=i[w];if(k.type==="msg"&&k.m.from==="me"){k.status=!0;break}}return x&&i.push({type:"intro",key:"intro"}),r&&u&&!d&&t?.status!=="closed"&&i.push({type:"note",key:"offline-note",text:r}),t?.status==="closed"&&i.push({type:"resolved",key:"resolved",date:t.lastMessageDate}),i}const qr=gn({mounted:{current:!1}});function Es({items:t,member:e}){const n=S(!1);return N(()=>{n.current=!0},[]),s(qr.Provider,{value:{mounted:n},children:s("div",{class:"dc-msgs",onClick:r=>{const i=r.target.closest?.(".dc-spoiler");i&&i.classList.add("is-shown")},onKeyDown:r=>{const i=r.target;(r.key==="Enter"||r.key===" ")&&i.classList?.contains("dc-spoiler")&&(r.preventDefault(),i.classList.add("is-shown"))},children:t.map(r=>s(As,{item:r,member:e},r.key))})})}function As({item:t,member:e}){const{mounted:n}=br(qr),r=S(null);switch(N(()=>{if(!n.current)return;const i=t.type==="out"||t.type==="msg"&&t.m.from==="me",o=t.type==="msg"||t.type==="out";r.current&&(r.current.style.transformOrigin=i?"bottom right":o?"bottom left":"center"),D(r.current,[{opacity:0,transform:`translateY(10px) scale(${o?.94:.98})`},{opacity:1,transform:"none"}],{duration:420,easing:ee.spring})},[]),t.type){case"day":return s("div",{ref:r,class:"dc-day",children:vs(t.date)});case"joined":return s("div",{ref:r,class:"dc-event",children:[s(fe,{name:t.name,url:t.avatar??(e?.displayName===t.name?e.displayAvatarURL:null),size:20}),s("span",{children:[s("b",{children:t.name})," joined the conversation"]}),s("time",{children:we(t.date)})]});case"event":return s("div",{ref:r,class:"dc-event",children:[t.e.kind==="handoff"?s(H,{children:[s(fe,{name:t.e.name??"?",size:20}),s("span",{children:[s("b",{children:t.e.name})," took over the conversation"]})]}):s(H,{children:[s("span",{class:"ic",children:s(M,{name:"retry",size:12})}),s("span",{children:"Conversation reopened"})]}),s("time",{children:we(t.e.date)})]});case"resolved":return s("div",{ref:r,class:"dc-event ok",children:[s("span",{class:"ic",children:s(M,{name:"check",size:12})}),s("span",{children:"Conversation resolved"})]});case"note":return s("div",{ref:r,class:"dc-event note",children:s("span",{children:t.text})});case"intro":return s("div",{ref:r,children:s(Ns,{})});case"msg":return t.m.from==="me"?s(Ss,{ref_:r,m:t.m,first:t.first,last:t.last,status:t.status}):s(Ts,{ref_:r,m:t.m,first:t.first,last:t.last,member:e});case"out":return s(Cs,{ref_:r,o:t.o,first:t.first,last:t.last})}}function Kt({text:t,emojis:e,edited:n}){const r=S(null),i=S(!0),{text:o,images:a}=ts(t);return N(()=>{if(i.current){i.current=!1;return}D(r.current,[{filter:"brightness(1.25) saturate(1.3)"},{filter:"none"}],{duration:900})},[t]),s(H,{children:[o&&s("div",{ref:r,class:`dc-bubble${rs(o)?" is-jumbo":""}`,dangerouslySetInnerHTML:{__html:Nr(o,e)+(n?'<span class="dc-edited">(edited)</span>':"")}}),a.map(c=>s("img",{class:"dc-inline-img",src:c,alt:"",loading:"lazy"},c))]})}function Xt(t,e,n,r=""){return`dc-row dc-row--${t}${e?" is-first":""}${n?" is-last":""}${r}`}function Ts({ref_:t,m:e,first:n,last:r,member:i}){const o=i&&i.displayName===e.authorName?i:null;return s("div",{ref:t,class:Xt("agent",n,r,e.deleted?" is-deleted":""),title:we(e.date),children:[s("div",{class:"dc-row-av",children:e.authorAvatarURL||!o?s(fe,{name:e.authorName||"?",url:e.authorAvatarURL,size:28}):s(he,{member:o,size:28})}),s("div",{class:"dc-stack",children:[s("div",{class:"dc-name",children:[s("b",{children:e.authorName}),we(e.date)]}),s(Kt,{text:e.text,emojis:e.emojis,edited:e.edited}),s(Wr,{list:e.attachments,localUrl:null})]})]})}function Ss({ref_:t,m:e,first:n,last:r,status:i}){const{localPreview:o}=X();return s("div",{ref:t,class:Xt("me",n,r,i?" show-status":""),title:we(e.date),children:s("div",{class:"dc-stack",children:[s(Kt,{text:e.text,emojis:e.emojis,edited:e.edited}),s(Wr,{list:e.attachments,localUrl:o(e.key)}),s("div",{class:"dc-status",children:[s(M,{name:"check",size:12})," Sent"]})]})})}function Cs({ref_:t,o:e,first:n,last:r}){const{actions:i}=X(),o=e.state==="failed",a=e.fileInfo,c=Math.round(e.progress*100);return s("div",{ref:t,class:Xt("me",n,r,o?"":" is-pending"),children:s("div",{class:"dc-stack",children:[e.text&&s(Kt,{text:e.text,emojis:{}}),a&&(a.previewUrl?s("div",{class:`dc-img is-${o?"failed":"uploading"}`,style:`--w:${Vr(a.width,a.height)}px;aspect-ratio:${a.width}/${a.height}`,children:[s("img",{src:a.previewUrl,alt:a.name}),!o&&s(Rs,{value:e.state==="sending"?c:0}),o&&s("span",{class:"fail",children:[s(M,{name:"retry",size:20}),"Not sent"]})]}):s("div",{class:`dc-file is-${o?"failed":"uploading"}`,children:[s("span",{class:"dc-ftype",children:Yt(a.name)}),s("span",{class:"tx",children:[s("b",{children:a.name}),s("small",{children:o?"Not sent":e.state==="sending"?`Uploading · ${c}%`:Wt(a.size)})]}),!o&&s("span",{class:"bar",children:s("i",{style:`width:${e.state==="sending"?c:0}%`})})]})),o?s("div",{class:"dc-status is-failed",children:[s(M,{name:"alert",size:13})," Not sent ·"," ",s("button",{onClick:()=>i.retry(e.localId),children:"Retry"})," ·"," ",s("button",{onClick:()=>i.discard(e.localId),children:"Remove"})]}):s("div",{class:"dc-status is-pending",children:[s(M,{name:"clock",size:12})," ",e.state==="held"?"Waiting for your details":"Sending…"]})]})})}function Rs({value:t}){return s(H,{children:[s("svg",{class:"dc-ring",viewBox:"0 0 36 36","aria-hidden":"true",children:[s("circle",{class:"bg",cx:"18",cy:"18",r:"15"}),s("circle",{class:"fg",cx:"18",cy:"18",r:"15",pathLength:100,style:`stroke-dashoffset:${100-t}`})]}),s("span",{class:"pct",children:[t,"%"]})]})}const Jt=t=>t.contentType?t.contentType.startsWith("image/"):/\.(png|jpe?g|gif|webp)$/i.test(t.name);function Vr(t,e){return!t||!e?232:e>t?Math.max(120,Math.round(232*t/e)):232}function Wr({list:t,localUrl:e}){if(!t.length)return null;const n=t.filter(Jt),r=t.filter(i=>!Jt(i));return s(H,{children:[n.length>1?s("div",{class:"dc-gallery",children:n.map(i=>s(Yr,{a:i,src:i.proxyURL||i.url},i.url))}):n[0]&&s(Yr,{a:n[0],src:e??(n[0].proxyURL||n[0].url)}),r.map(i=>s(Ls,{a:i},i.url))]})}function Yr({a:t,src:e}){const{actions:n}=X(),r=t.width&&t.height?`${t.width}/${t.height}`:"4/3";return s("button",{class:"dc-img",style:`--w:${Vr(t.width,t.height)}px;aspect-ratio:${r}`,"aria-label":`Open image ${t.name}`,onClick:i=>n.openLightbox(t.url||e,t.name,i.currentTarget.getBoundingClientRect()),children:s("img",{src:e,alt:t.name,loading:"lazy"})})}async function Is(t){try{const e=await fetch(t.url);if(!e.ok)throw new Error(String(e.status));const n=URL.createObjectURL(await e.blob()),r=document.createElement("a");r.href=n,r.download=t.name,document.body.appendChild(r),r.click(),r.remove(),setTimeout(()=>URL.revokeObjectURL(n),1e3)}catch{window.open(t.url,"_blank","noopener,noreferrer")}}function Ls({a:t}){return s("button",{class:"dc-file",onClick:()=>void Is(t),"aria-label":`Download ${t.name}`,children:[s("span",{class:`dc-ftype${Jt(t)?" is-image":""}`,children:Yt(t.name)}),s("span",{class:"tx",children:[s("b",{children:t.name}),s("small",{children:[Wt(t.size)," · ",Yt(t.name)]})]}),s("span",{class:"dl",children:s(M,{name:"dl",size:16})})]})}function Ns(){const{actions:t}=X(),e=W(p=>p.identity),[n,r]=j(e.name),[i,o]=j(e.email),[a,c]=j({}),d=S(null),u=S(null);return N(()=>{zr()&&setTimeout(()=>u.current?.focus({preventScroll:!0}),350)},[]),s("div",{class:"dc-intro",children:[s(Le,{size:28}),s("div",{class:"card",ref:d,children:[s("h4",{children:"Who should we reply to?"}),s("p",{children:"Your message is ready. Add your name so the team knows who they're talking to."}),s("form",{onSubmit:p=>{p.preventDefault();const h={name:n.trim()?void 0:"Tell us what to call you.",email:!i.trim()||Ar(i)?void 0:"That email doesn't look right."};if(c(h),h.name||h.email){D(d.current,[{transform:"translateX(-5px)"},{transform:"translateX(5px)"},{transform:"translateX(-3px)"},{transform:"none"}],{duration:360});return}t.completeIntro(n,i)},noValidate:!0,children:[s("label",{class:`dc-in${a.name?" is-err":""}`,children:[s("span",{children:"Name"}),s("input",{ref:u,id:"dc-name",name:"name",autocomplete:"name",placeholder:"Ada Lovelace",maxLength:256,value:n,onInput:p=>r(p.currentTarget.value)}),a.name&&s("em",{children:a.name})]}),s("label",{class:`dc-in${a.email?" is-err":""}`,children:[s("span",{children:["Email ",s("small",{children:"Optional"})]}),s("input",{id:"dc-email",name:"email",type:"email",autocomplete:"email",placeholder:"ada@example.com","aria-describedby":"dc-email-hint",value:i,onInput:p=>o(p.currentTarget.value)}),a.email?s("em",{children:a.email}):s("small",{id:"dc-email-hint",children:"Strongly recommended, so the team can reply by email after you leave."})]}),s("button",{class:"dc-btn",type:"submit",children:[s(M,{name:"send",size:15})," Send message"]})]})]})]})}const Kr=[["😀","Smileys","😀 😃 😄 😁 😆 😅 😂 🤣 😊 😇 🙂 😉 😍 🥰 😘 😋 😜 🤪 🤓 😎 🥳 😏 😒 😔 😕 🙁 😣 😩 🥺 😢 😭 😤 😠 🤯 😳 😱 🤗 🤔 🤫 😐 🙄 😬 😴 😷"],["👋","People","👋 🤚 ✋ 👌 🤌 ✌️ 🤞 🤟 🤘 👈 👉 👆 👇 👍 👎 ✊ 👊 👏 🙌 🫶 🙏 💪 ✍️ 👀"],["🎮","Objects","💻 🖥️ ⌨️ 🖱️ 📱 🎮 🕹️ 🎧 📦 📎 📌 📝 📅 🔒 🔑 🛠️ ⚙️ 🧪 💡 🔋 📈 📉 🧾 💳 🗂️"],["❤️","Symbols","❤️ 🧡 💛 💚 💙 💜 🖤 🤍 💯 ✅ ❌ ⚠️ ❓ ❗ 🔥 ✨ ⭐ 🎉 🎊 🚀 💬 🆗 🆒 ⏳ 🌊"]];function Os({closed:t,paused:e,placeholder:n}){const{actions:r}=X(),{tray:i,notice:o}=W(y=>({tray:y.tray,notice:y.notice})),[a,c]=j(""),[d,u]=j(!1),g=S(null),p=S(null),h=S(null),x=S(null),w=S(t);N(()=>{const y=g.current;y&&(y.style.height="",y.style.height=`${Math.min(y.scrollHeight,128)}px`)},[a,t]),N(()=>{w.current!==t&&(D(x.current,[{opacity:0,transform:"translateY(10px)"},{opacity:1,transform:"none"}],{duration:380}),w.current=t)},[t]),ce(()=>{if(!o)return;D(h.current,[{transform:"translateX(-5px)"},{transform:"translateX(5px)"},{transform:"translateX(-3px)"},{transform:"none"}],{duration:360});const y=setTimeout(r.clearNotice,3200);return()=>clearTimeout(y)},[o,r]);const k=!!a.trim()||i.length>0,_=()=>{k&&(r.send(a),c(""),u(!1),g.current?.focus({preventScroll:!0}))},A=y=>{const L=g.current,E=L?.selectionStart??a.length,O=L?.selectionEnd??a.length,P=a.slice(0,E)+y+a.slice(O);c(P),requestAnimationFrame(()=>{L&&(L.focus({preventScroll:!0}),L.selectionStart=L.selectionEnd=E+y.length)})};return e?s("footer",{class:"dc-composer",ref:x,children:[s("div",{class:"dc-resolved","aria-live":"polite",children:s("p",{children:[t?"This conversation was resolved. ":"","We're not taking new conversations right now. Please come back a little later."]})}),s(Zt,{})]}):t?s("footer",{class:"dc-composer",ref:x,children:[s("div",{class:"dc-resolved",children:[s("p",{children:"This conversation was resolved. Need anything else?"}),s("button",{class:"dc-btn",onClick:r.newConversation,children:[s(M,{name:"plus",size:16})," Start a new conversation"]})]}),s(Zt,{})]}):s("footer",{class:"dc-composer",ref:x,children:[o&&s($s,{text:o.text},o.at),d&&s(Us,{onPick:A,onClose:()=>u(!1)}),s("div",{class:"dc-field",ref:h,children:[i.length>0&&s("div",{class:"dc-tray",children:i.map(y=>s(Ms,{id:y.id,file:y.file,previewUrl:y.previewUrl,onRemove:()=>r.removeFromTray(y.id)},y.id))}),s("div",{class:"dc-input-row",children:[s("textarea",{ref:g,id:"dc-input",rows:1,"aria-label":"Message",placeholder:n,value:a,onInput:y=>c(y.currentTarget.value),onKeyDown:y=>{y.key==="Enter"&&!y.shiftKey&&!y.isComposing&&zr()&&(y.preventDefault(),_()),y.key==="Escape"&&d&&(y.preventDefault(),u(!1))},onPaste:y=>{const L=[...y.clipboardData?.files??[]];L.length&&(y.preventDefault(),r.addFiles(L))}}),s("button",{class:"dc-tool","aria-label":"Attach a file",onClick:()=>p.current?.click(),children:s(M,{name:"clip",size:20})}),s("button",{class:"dc-tool","data-emoji-toggle":!0,"aria-label":"Emoji","aria-expanded":d,onClick:()=>u(y=>!y),children:s(M,{name:"smile",size:20})}),s("button",{class:"dc-send","aria-label":"Send",disabled:!k,onClick:_,children:s(M,{name:"send",size:18})})]})]}),s("input",{ref:p,type:"file",multiple:!0,hidden:!0,accept:_r.join(","),onChange:y=>{const L=y.currentTarget;r.addFiles([...L.files??[]]),L.value="",g.current?.focus({preventScroll:!0})}}),s(Zt,{})]})}function Zt(){return s("a",{class:"dc-powered",href:"https://deskcord.chat",target:"_blank",rel:"noopener",children:["Powered by ",s(Ur,{})]})}function $s({text:t}){const e=S(null);return N(()=>{D(e.current,[{opacity:0,transform:"translateY(6px) scale(.96)"},{opacity:1,transform:"none"}],{duration:320,easing:ee.spring})},[]),s("div",{class:"dc-toast",role:"alert",children:s("span",{ref:e,children:[s(M,{name:"alert",size:15}),t]})})}function Ms({file:t,previewUrl:e,onRemove:n}){const r=S(null);N(()=>{D(r.current,[{opacity:0,transform:"scale(.6)"},{opacity:1,transform:"none"}],{duration:420,easing:ee.spring})},[]);const i=()=>{const c=D(r.current,[{opacity:1,transform:"none"},{opacity:0,transform:"scale(.6)"}],{duration:180,easing:ee.in,fill:"forwards"});c?c.onfinish=n:n()},o=t.name||"image.png",a=s("button",{class:"rm","aria-label":`Remove ${o}`,onClick:i,children:s(M,{name:"x",size:11})});return e?s("div",{class:"dc-chip img",ref:r,children:[s("img",{src:e,alt:o}),a]}):s("div",{class:"dc-chip file",ref:r,children:[s("span",{class:"dc-ftype",children:"PDF"}),s("span",{class:"tx",children:[s("b",{children:o}),s("small",{children:Wt(t.size)})]}),a]})}function Us({onPick:t,onClose:e}){const[n,r]=j(0),i=S(null);N(()=>{D(i.current,[{opacity:0,transform:"translateY(8px) scale(.94)"},{opacity:1,transform:"none"}],{duration:340,easing:ee.spring})},[]),ce(()=>{const c=d=>{const u=d.composedPath();u.includes(i.current)||u.some(g=>g instanceof Element&&g.hasAttribute("data-emoji-toggle"))||e()};return document.addEventListener("pointerdown",c,!0),()=>document.removeEventListener("pointerdown",c,!0)},[e]);const[,o,a]=Kr[n];return s("div",{class:"dc-emoji",ref:i,role:"dialog","aria-label":"Emoji",onKeyDown:c=>{c.key==="Escape"&&(c.preventDefault(),e())},children:[s("div",{class:"grid",children:[s("div",{class:"cat",children:o}),a.split(" ").map(c=>s("button",{"aria-label":c,onClick:()=>t(c),children:c},c))]}),s("div",{class:"tabs",children:Kr.map(([c,d],u)=>s("button",{"aria-label":d,"aria-pressed":u===n,onClick:()=>r(u),children:c},d))})]})}const Ds=[],zs=[];function Ps({frozenThreadId:t}){const{actions:e}=X(),n=W(T=>T.activeThreadId),r=t!==void 0?t:n,i=W(T=>{const ne=r?T.conversations[r]??null:null,_e=!ne||ne.status==="open";return{conv:ne,outbox:_e?T.outbox:Ds,events:r&&T.events[r]||zs,typing:!!(r&&T.typing[r]),guild:T.guild,identity:T.identity,open:T.open,accepting:et(T),canGoBack:!!T.token||Object.keys(T.conversations).some(Oe=>Oe!==r)}}),{conv:o,outbox:a,events:c,typing:d,guild:u,identity:g,accepting:p}=i,h=u.onlineCsMembers,x=Array.isArray(h)&&h.length===0,w=x?u.offline_message||qt:null,k=nt(()=>ks(o,a,c,w),[o,a,c,w]),_=k.length===0,A=o?.status==="closed",y=o?.csMember??null,L=S(null),E=S(!0),[O,P]=j(!1),V=k[k.length-1],te=V?.key,F=(()=>{const T=V;return!!T&&(T.type==="out"||T.type==="intro"||T.type==="msg"&&T.m.from==="me")})(),J=T=>{const ne=L.current;ne&&ne.scrollTo({top:ne.scrollHeight,behavior:T&&Ft()?"smooth":"auto"})},Y=S(!1);N(()=>{if(!Y.current){Y.current=!0,J(!1);return}E.current||F?J(!0):P(!0)},[te,k.length]),N(()=>{d&&E.current&&J(!0)},[d]),N(()=>{i.open&&J(!1)},[i.open]),ce(()=>{const T=L.current;if(!T||typeof ResizeObserver!="function")return;const ne=new ResizeObserver(()=>{E.current&&J(!1)});return ne.observe(T),()=>ne.disconnect()},[]);const Z=g.name.trim().split(/\s+/)[0];return s(H,{children:[s("header",{class:"dc-head dc-head--compact",children:[i.canGoBack&&s("button",{class:"dc-hbtn","aria-label":"All conversations",onClick:e.goHome,children:s(M,{name:"left",size:22})}),s(Bs,{memberKey:y?`${y.displayName}:${y.status}`:`g:${h?.length??"?"}`,children:y?s(H,{children:[s(he,{member:y,size:38,withStatus:!0}),s("div",{class:"tx",children:[s("div",{class:"t",children:y.displayName}),s("div",{class:"s",children:s("span",{children:[u.name?`${u.name} · `:"",fs[y.status]]})})]})]}):s(H,{children:[s(Le,{size:38,dot:h?h.length?"online":"offline":null}),s("div",{class:"tx",children:[s("div",{class:"t",children:u.name||"Support"}),s("div",{class:"s",children:h&&h.length>0?s(H,{children:[s("span",{class:"mini",children:Ht(h).map(T=>s(he,{member:T,size:16},T.displayName))}),s("span",{children:jt(h)})]}):s("span",{children:x?"Away · we'll reply as soon as we can":"We typically reply within a few minutes"})})]})]})}),s(Fr,{})]}),s(Hs,{}),s("div",{class:"dc-scroll-wrap",children:[s("div",{class:"dc-scroll",ref:L,role:"log","aria-live":"polite",onScroll:()=>{const T=L.current;T&&(E.current=T.scrollHeight-T.scrollTop-T.clientHeight<90,E.current&&O&&P(!1))},children:[_&&s("div",{class:"dc-welcome",children:[s("div",{class:"stack",children:h&&h.length>0?Ht(h).map(T=>s(he,{member:T,size:44,withStatus:!0},T.displayName)):s(Le,{size:48})}),s("h3",{children:Z&&g.verifiedUserId?`Hi ${Z}, how can we help?`:"How can we help?"}),s("p",{children:x?u.offline_message||qt:h&&h.length?`${jt(h)}. We typically reply within a few minutes.`:"We typically reply within a few minutes."})]}),s(Es,{items:k,member:y}),d&&!A&&s(Fs,{name:y?.displayName??"Support",avatar:y?.displayAvatarURL})]}),O&&s("button",{class:"dc-jump",onClick:()=>{J(!0),P(!1)},children:[s(M,{name:"down",size:16})," New message"]})]}),s(Os,{closed:A,paused:!p&&o?.status!=="open",placeholder:x?"Leave a message…":`Message ${u.name||"us"}…`})]})}function Bs({memberKey:t,children:e}){const n=S(null),r=S(!0);return N(()=>{if(r.current){r.current=!1;return}D(n.current,[{opacity:0,transform:"translateY(6px)"},{opacity:1,transform:"none"}],{duration:340})},[t]),s("div",{class:"dc-head-id",ref:n,children:e})}function Fs({name:t,avatar:e}){const n=S(null);return N(()=>{n.current&&(n.current.style.transformOrigin="bottom left"),D(n.current,[{opacity:0,transform:"translateY(8px) scale(.9)"},{opacity:1,transform:"none"}],{duration:380,easing:ee.spring})},[]),s("div",{class:"dc-typing",ref:n,role:"status","aria-label":`${t} is typing`,children:[s(fe,{name:t,url:e,size:28}),s("div",{class:"dots",children:[s("i",{}),s("i",{}),s("i",{})]})]})}function Hs(){const t=W(a=>a.connection),[e,n]=j("none"),r=S(t),i=S(null);ce(()=>{let a;return t==="down"?n("down"):t==="up"&&r.current==="down"?(n("back"),a=setTimeout(()=>n("none"),2200)):t==="off"&&n("none"),r.current=t,()=>clearTimeout(a)},[t]);const o=e!=="none";return N(()=>{o&&D(i.current,[{opacity:0,transform:"translateY(-100%)"},{opacity:1,transform:"none"}],{duration:300})},[o]),e==="none"?null:s("div",{ref:i,class:`dc-conn ${e==="down"?"is-down":"is-up"}`,role:"status",children:e==="down"?s(H,{children:[s("span",{class:"dc-spin"})," Connection lost. Reconnecting…"]}):s(H,{children:[s(M,{name:"check",size:14})," Back online"]})})}function js(){const{actions:t}=X(),e=W(c=>c.lightbox),n=S(null),r=S(null),i=S(!1),o=c=>{const d=e?.from,u=r.current;if(!d||!u||!Ft())return null;const g=u.getBoundingClientRect();if(!g.width)return null;const h=[{transform:`translate(${d.left-g.left}px, ${d.top-g.top}px) scale(${d.width/g.width}, ${d.height/g.height})`,borderRadius:"28px"},{transform:"none",borderRadius:"10px"}];return u.animate(c?h.reverse():h,{duration:c?320:460,easing:ee.out,fill:c?"forwards":"backwards"})},a=()=>{if(i.current)return;i.current=!0;const c=o(!0);n.current?.querySelectorAll(".bd, .bar").forEach(d=>d.animate([{opacity:1},{opacity:0}],{duration:240,fill:"forwards"})),c?c.onfinish=()=>t.closeLightbox():t.closeLightbox()};return N(()=>{if(!e)return;i.current=!1,D(n.current?.querySelector(".bd"),[{opacity:0},{opacity:1}],{duration:300}),D(n.current?.querySelector(".bar"),[{opacity:0,transform:"translateY(-8px)"},{opacity:1,transform:"none"}],{duration:300,delay:120});const c=r.current;c?.complete?o(!1):c&&(c.onload=()=>o(!1))},[e]),ce(()=>{if(!e)return;const c=d=>{d.key==="Escape"&&(d.preventDefault(),d.stopPropagation(),a())};return document.addEventListener("keydown",c,!0),()=>document.removeEventListener("keydown",c,!0)},[e]),e?s("div",{class:"dc-lightbox",ref:n,role:"dialog","aria-label":e.name,children:[s("div",{class:"bd",onClick:a}),s("div",{class:"bar",children:[s("span",{children:e.name}),s("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",children:[s(M,{name:"ext",size:15})," Open original"]}),s("button",{class:"x","aria-label":"Close",onClick:a,children:s(M,{name:"x",size:18})})]}),s("div",{class:"pic",onClick:a,children:s("img",{ref:r,src:e.url,alt:e.name})})]}):null}function qs(){const{boot:t,dark:e,guild:n,available:r}=W(a=>({boot:a.boot,dark:a.dark,guild:a.guild,available:rr(a)})),i=nt(()=>Jo({primary:n.primary_color,gradient:n.gradient_color,headerText:n.header_text_color,dark:e}),[n.primary_color,n.gradient_color,n.header_text_color,e]),o=Object.entries(i.vars).map(([a,c])=>`${a}:${c}`).join(";");return Vs(),t!=="ready"||!r?null:s("div",{class:"dc","data-theme":e?"dark":"light","data-pos":n.widget_position==="bottom-left"?"left":"right","data-flat":i.flat?"":void 0,style:o,children:[s(Ys,{}),s(Ks,{}),s(Ws,{}),s(js,{})]})}function Vs(){const{open:t,unread:e}=W(i=>({open:i.open,unread:ir(i.conversations,i.lastReadAt)})),n=cs(),r=e>0&&(!t||!n);ce(()=>{if(!r)return;const i=`(${e}) New message${e>1?"s":""}`;let o=document.title,a=!1;const c=()=>{!a&&document.title!==i&&(o=document.title),a=!a,document.title=a?i:o};c();const d=setInterval(c,2500);return()=>{clearInterval(d),document.title===i&&(document.title=o)}},[r,e])}function Ws(){const{actions:t}=X(),{open:e,unread:n}=W(c=>({open:c.open,unread:ir(c.conversations,c.lastReadAt)})),r=S(null),i=S(null),o=S(n);N(()=>{D(r.current,[{opacity:0,transform:"scale(.4)"},{opacity:1,transform:"none"}],{duration:520,delay:120,easing:ee.spring})},[]),N(()=>{n>o.current&&D(i.current,[{transform:"scale(0)"},{transform:"scale(1.25)",offset:.6},{transform:"scale(1)"}],{duration:420}),o.current=n},[n]);const a=n>0&&!e;return s("button",{ref:r,class:`dc-launcher${e?" is-open":""}${a?" has-unread":""}`,"aria-label":e?"Close chat":a?`Open chat, ${n} unread`:"Open chat","aria-expanded":e,onClick:t.toggle,children:[s("span",{class:"ic ic-chat",children:s(os,{})}),s("span",{class:"ic ic-close",children:s(M,{name:"down",size:24})}),a&&s("span",{class:"dc-badge",ref:i,"aria-hidden":"true",children:n>99?"99+":n})]})}function Ys(){const{actions:t}=X(),e=W(p=>{if(!p.preview||p.open)return null;const h=p.conversations[p.preview.threadId],x=h?.messages.find(w=>w.key===p.preview.key&&!w.deleted);return x?{threadId:h.threadId,message:x,member:h.csMember}:null}),n=S(null),r=S(e);e&&(r.current=e);const i=as(!!e,n,[{opacity:0,transform:"translateY(12px) scale(.94)"},{opacity:1,transform:"none"}],[{opacity:1},{opacity:0,transform:"translateY(6px) scale(.97)"}],{enter:{duration:460,easing:ee.spring}}),o=e??r.current;if(!i||!o)return null;const{message:a,member:c,threadId:d}=o,u=c?.displayName??a.authorName,g=a.text?Nr(Mr(a.text),a.emojis):a.attachments.some(p=>!p.contentType?.startsWith("image/"))?"📄 Sent a file":"📷 Sent an image";return s("div",{ref:n,class:"dc-preview",role:"button",tabIndex:0,"aria-label":`New message from ${u}`,onClick:()=>{t.openConversation(d),t.open()},onKeyDown:p=>{p.key==="Enter"&&p.currentTarget.click()},children:[c?s(he,{member:c,size:34,withStatus:!0}):s(fe,{name:u,size:34}),s("div",{style:"min-width:0",children:[s("div",{class:"who",children:s("b",{children:u})}),s("div",{class:"txt",dangerouslySetInnerHTML:{__html:g}})]}),s("button",{class:"x","aria-label":"Dismiss",onClick:p=>{p.stopPropagation(),t.dismissPreview()},children:s(M,{name:"x",size:12})})]})}function Ks(){const{actions:t}=X(),{open:e,view:n}=W(h=>({open:h.open,view:h.view})),r=S(null),[i,o]=j(e),[a,c]=j(e),[d,u]=j(!1),g=S(0);if(us(r,a),N(()=>{if(e){o(!0),c(!0);return}if(!a)return;const h=r.current?.getRootNode()?.activeElement;h&&r.current?.contains(h)&&h.blur();const x=r.current?.animate([{opacity:1,transform:"none"},{opacity:0,transform:"translateY(10px) scale(.96)"}],{duration:170,easing:ee.in});if(!x){c(!1);return}return x.onfinish=()=>c(!1),()=>x.cancel()},[e]),N(()=>{if(!e||!a)return;const h=r.current;D(h,[{opacity:0},{opacity:1}],{duration:180}),D(h,[{transform:"translateY(18px) scale(.92)"},{transform:"none"}],{duration:520,easing:ee.spring,composite:"add"}),h?.querySelectorAll(".dc-hero > *, .dc-home-body > *, .dc-welcome > *, .dc-head-id, .dc-composer").forEach((x,w)=>D(x,[{opacity:0,transform:"translateY(8px)"},{opacity:1,transform:"none"}],{duration:420,delay:60+w*35}))},[e,a]),!i)return null;const p=h=>n==="chat"&&!!h.dataTransfer?.types.includes("Files");return s("section",{ref:r,class:"dc-panel",role:"dialog","aria-label":"Chat",hidden:!a,onKeyDown:h=>{h.key==="Escape"&&!h.defaultPrevented&&t.close()},onDragEnter:h=>{p(h)&&(h.preventDefault(),g.current++===0&&u(!0))},onDragOver:h=>{d&&h.preventDefault()},onDragLeave:()=>{g.current>0&&--g.current===0&&u(!1)},onDrop:h=>{d&&(h.preventDefault(),g.current=0,u(!1),t.addFiles([...h.dataTransfer?.files??[]]))},children:[s(Js,{}),d&&s(Xs,{})]})}function Xs(){const t=S(null);return N(()=>{D(t.current,[{opacity:0,transform:"scale(.98)"},{opacity:1,transform:"none"}],{duration:200})},[]),s("div",{class:"dc-drop",ref:t,children:[s("div",{class:"ic",children:s(M,{name:"upload",size:26})}),s("b",{children:"Drop to attach"}),s("small",{children:"Images or PDFs, up to 10 MB each"})]})}function Js(){const{store:t}=X(),{view:e,nav:n}=W(a=>({view:a.view,nav:a.nav})),r=`${e}:${n}`,[i,o]=j(()=>[{key:r,view:e,threadId:t.get().activeThreadId}]);return N(()=>{o(a=>a[a.length-1].key===r?a:[{...a[a.length-1],threadId:t.get().navPrev},{key:r,view:e,threadId:null}])},[r]),s("div",{class:"dc-views",children:i.map((a,c)=>s(Zs,{leaving:c<i.length-1,animateIn:i.length>1,back:e==="home",onGone:()=>o(d=>d.filter(u=>u.key!==a.key)),children:a.view==="home"?s(xs,{}):s(Ps,{frozenThreadId:c<i.length-1?a.threadId:void 0})},a.key))})}function Zs({leaving:t,animateIn:e,back:n,onGone:r,children:i}){const o=S(null),a=n?-28:28;return N(()=>{e&&D(o.current,[{transform:`translateX(${a}%)`,opacity:0},{transform:"none",opacity:1}],{duration:340})},[]),N(()=>{if(!t)return;const c=D(o.current,[{transform:"none",opacity:1},{transform:`translateX(${-a}%)`,opacity:0}],{duration:300,fill:"forwards"}),d=setTimeout(r,340);return c&&(c.onfinish=r),()=>clearTimeout(d)},[t]),s("div",{ref:o,class:"dc-view",inert:t,style:t?"pointer-events:none":void 0,children:i})}function Xr(){if(document.getElementById("deskcord-root"))return;const t=vi();if(!t)return;const e=Yo(t),n=window.deskcord;n.openChatbox=()=>e.actions.open(),n.closeChatbox=()=>e.actions.close(),n.identify=e.identify,n.logout=()=>{e.logout()};let r=t.theme;const i=matchMedia("(prefers-color-scheme: dark)"),o=()=>e.actions.setDark(r==="dark"||r==="auto"&&i.matches);n.setTheme=g=>{if(g!=="light"&&g!=="dark"&&g!=="auto"){console.error(`[Deskcord] setTheme: unknown theme "${String(g)}" (use "light", "dark" or "auto").`);return}r=g,o()},o(),i.addEventListener("change",o);const a=document.createElement("div");a.id="deskcord-root",a.style.cssText="position:fixed;top:0;left:0;width:0;height:0;z-index:2147483000;",document.body.appendChild(a);const c=a.attachShadow({mode:"open"}),d=document.createElement("style");d.textContent=gi,c.appendChild(d);const u=document.createElement("div");c.appendChild(u),fi(s(Dr.Provider,{value:e,children:s(qs,{})}),u),e.boot()}document.body?Xr():document.addEventListener("DOMContentLoaded",Xr,{once:!0})})();
|