@nethesis/chat-island 0.1.0 โ 0.1.1
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/README.md +2 -0
- package/dist/ChatIsland.d.ts +4 -3
- package/dist/index.d.ts +1 -0
- package/dist/index.js +623 -582
- package/dist/theme.d.ts +3 -0
- package/dist-widget/index.widget.js +1 -1
- package/package.json +1 -1
package/dist/theme.d.ts
ADDED
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
`).replace(bi,``)}function Si(e,t,n){if(t=xi(t),xi(e)!==t&&n)throw Error(r(425))}function Ci(){}var wi=null,Ti=null;function Ei(e,t){return e===`textarea`||e===`noscript`||typeof t.children==`string`||typeof t.children==`number`||typeof t.dangerouslySetInnerHTML==`object`&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var Di=typeof setTimeout==`function`?setTimeout:void 0,Oi=typeof clearTimeout==`function`?clearTimeout:void 0,ki=typeof Promise==`function`?Promise:void 0,Ai=typeof queueMicrotask==`function`?queueMicrotask:ki===void 0?Di:function(e){return ki.resolve(null).then(e).catch(ji)};function ji(e){setTimeout(function(){throw e})}function Mi(e,t){var n=t,r=0;do{var i=n.nextSibling;if(e.removeChild(n),i&&i.nodeType===8){if(n=i.data,n===`/$`){if(r===0){e.removeChild(i),bn(t);return}r--}else n!==`$`&&n!==`$?`&&n!==`$!`||r++}n=i}while(n);bn(t)}function Ni(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t===`$`||t===`$!`||t===`$?`)break;if(t===`/$`)return null}}return e}function Pi(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`$`||n===`$!`||n===`$?`){if(t===0)return e;t--}else n===`/$`&&t++}e=e.previousSibling}return null}var Fi=Math.random().toString(36).slice(2),Ii=`__reactFiber$`+Fi,Li=`__reactProps$`+Fi,Ri=`__reactContainer$`+Fi,zi=`__reactEvents$`+Fi,Bi=`__reactListeners$`+Fi,Vi=`__reactHandles$`+Fi;function Hi(e){var t=e[Ii];if(t)return t;for(var n=e.parentNode;n;){if(t=n[Ri]||n[Ii]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=Pi(e);e!==null;){if(n=e[Ii])return n;e=Pi(e)}return t}e=n,n=e.parentNode}return null}function Ui(e){return e=e[Ii]||e[Ri],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function Wi(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(r(33))}function Gi(e){return e[Li]||null}var Ki=[],qi=-1;function Ji(e){return{current:e}}function B(e){0>qi||(e.current=Ki[qi],Ki[qi]=null,qi--)}function V(e,t){qi++,Ki[qi]=e.current,e.current=t}var Yi={},Xi=Ji(Yi),Zi=Ji(!1),Qi=Yi;function $i(e,t){var n=e.type.contextTypes;if(!n)return Yi;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var i={},a;for(a in n)i[a]=t[a];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=i),i}function ea(e){return e=e.childContextTypes,e!=null}function ta(){B(Zi),B(Xi)}function na(e,t,n){if(Xi.current!==Yi)throw Error(r(168));V(Xi,t),V(Zi,n)}function ra(e,t,n){var i=e.stateNode;if(t=t.childContextTypes,typeof i.getChildContext!=`function`)return n;for(var a in i=i.getChildContext(),i)if(!(a in t))throw Error(r(108,ge(e)||`Unknown`,a));return O({},n,i)}function ia(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Yi,Qi=Xi.current,V(Xi,e),V(Zi,Zi.current),!0}function aa(e,t,n){var i=e.stateNode;if(!i)throw Error(r(169));n?(e=ra(e,t,Qi),i.__reactInternalMemoizedMergedChildContext=e,B(Zi),B(Xi),V(Xi,e)):B(Zi),V(Zi,n)}var oa=null,sa=!1,ca=!1;function la(e){oa===null?oa=[e]:oa.push(e)}function ua(e){sa=!0,la(e)}function da(){if(!ca&&oa!==null){ca=!0;var e=0,t=M;try{var n=oa;for(M=1;e<n.length;e++){var r=n[e];do r=r(!0);while(r!==null)}oa=null,sa=!1}catch(t){throw oa!==null&&(oa=oa.slice(e+1)),xt(Et,da),t}finally{M=t,ca=!1}}return null}var fa=[],pa=0,ma=null,ha=0,ga=[],_a=0,va=null,ya=1,ba=``;function xa(e,t){fa[pa++]=ha,fa[pa++]=ma,ma=e,ha=t}function Sa(e,t,n){ga[_a++]=ya,ga[_a++]=ba,ga[_a++]=va,va=e;var r=ya;e=ba;var i=32-Pt(r)-1;r&=~(1<<i),n+=1;var a=32-Pt(t)+i;if(30<a){var o=i-i%5;a=(r&(1<<o)-1).toString(32),r>>=o,i-=o,ya=1<<32-Pt(t)+i|n<<i|r,ba=a+e}else ya=1<<a|n<<i|r,ba=e}function Ca(e){e.return!==null&&(xa(e,1),Sa(e,1,0))}function wa(e){for(;e===ma;)ma=fa[--pa],fa[pa]=null,ha=fa[--pa],fa[pa]=null;for(;e===va;)va=ga[--_a],ga[_a]=null,ba=ga[--_a],ga[_a]=null,ya=ga[--_a],ga[_a]=null}var Ta=null,Ea=null,H=!1,Da=null;function Oa(e,t){var n=Kl(5,null,null,0);n.elementType=`DELETED`,n.stateNode=t,n.return=e,t=e.deletions,t===null?(e.deletions=[n],e.flags|=16):t.push(n)}function ka(e,t){switch(e.tag){case 5:var n=e.type;return t=t.nodeType!==1||n.toLowerCase()!==t.nodeName.toLowerCase()?null:t,t!==null&&(e.stateNode=t,Ta=e,Ea=Ni(t.firstChild),!0);case 6:return t=e.pendingProps===``||t.nodeType!==3?null:t,t!==null&&(e.stateNode=t,Ta=e,Ea=null,!0);case 13:return t=t.nodeType===8?t:null,t!==null&&(n=va===null?null:{id:ya,overflow:ba},e.memoizedState={dehydrated:t,treeContext:n,retryLane:1073741824},n=Kl(18,null,null,0),n.stateNode=t,n.return=e,e.child=n,Ta=e,Ea=null,!0);default:return!1}}function Aa(e){return!!(e.mode&1)&&!(e.flags&128)}function ja(e){if(H){var t=Ea;if(t){var n=t;if(!ka(e,t)){if(Aa(e))throw Error(r(418));t=Ni(n.nextSibling);var i=Ta;t&&ka(e,t)?Oa(i,n):(e.flags=e.flags&-4097|2,H=!1,Ta=e)}}else{if(Aa(e))throw Error(r(418));e.flags=e.flags&-4097|2,H=!1,Ta=e}}}function Ma(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;Ta=e}function Na(e){if(e!==Ta)return!1;if(!H)return Ma(e),H=!0,!1;var t;if((t=e.tag!==3)&&!(t=e.tag!==5)&&(t=e.type,t=t!==`head`&&t!==`body`&&!Ei(e.type,e.memoizedProps)),t&&=Ea){if(Aa(e))throw Pa(),Error(r(418));for(;t;)Oa(e,t),t=Ni(t.nextSibling)}if(Ma(e),e.tag===13){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(r(317));a:{for(e=e.nextSibling,t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`/$`){if(t===0){Ea=Ni(e.nextSibling);break a}t--}else n!==`$`&&n!==`$!`&&n!==`$?`||t++}e=e.nextSibling}Ea=null}}else Ea=Ta?Ni(e.stateNode.nextSibling):null;return!0}function Pa(){for(var e=Ea;e;)e=Ni(e.nextSibling)}function Fa(){Ea=Ta=null,H=!1}function Ia(e){Da===null?Da=[e]:Da.push(e)}var La=C.ReactCurrentBatchConfig;function Ra(e,t,n){if(e=n.ref,e!==null&&typeof e!=`function`&&typeof e!=`object`){if(n._owner){if(n=n._owner,n){if(n.tag!==1)throw Error(r(309));var i=n.stateNode}if(!i)throw Error(r(147,e));var a=i,o=``+e;return t!==null&&t.ref!==null&&typeof t.ref==`function`&&t.ref._stringRef===o?t.ref:(t=function(e){var t=a.refs;e===null?delete t[o]:t[o]=e},t._stringRef=o,t)}if(typeof e!=`string`)throw Error(r(284));if(!n._owner)throw Error(r(290,e))}return e}function za(e,t){throw e=Object.prototype.toString.call(t),Error(r(31,e===`[object Object]`?`object with keys {`+Object.keys(t).join(`, `)+`}`:e))}function Ba(e){var t=e._init;return t(e._payload)}function Va(e){function t(t,n){if(e){var r=t.deletions;r===null?(t.deletions=[n],t.flags|=16):r.push(n)}}function n(n,r){if(!e)return null;for(;r!==null;)t(n,r),r=r.sibling;return null}function i(e,t){for(e=new Map;t!==null;)t.key===null?e.set(t.index,t):e.set(t.key,t),t=t.sibling;return e}function a(e,t){return e=Yl(e,t),e.index=0,e.sibling=null,e}function o(t,n,r){return t.index=r,e?(r=t.alternate,r===null?(t.flags|=2,n):(r=r.index,r<n?(t.flags|=2,n):r)):(t.flags|=1048576,n)}function s(t){return e&&t.alternate===null&&(t.flags|=2),t}function c(e,t,n,r){return t===null||t.tag!==6?(t=$l(n,e.mode,r),t.return=e,t):(t=a(t,n),t.return=e,t)}function l(e,t,n,r){var i=n.type;return i===ee?d(e,t,n.props.children,r,n.key):t!==null&&(t.elementType===i||typeof i==`object`&&i&&i.$$typeof===se&&Ba(i)===t.type)?(r=a(t,n.props),r.ref=Ra(e,t,n),r.return=e,r):(r=Xl(n.type,n.key,n.props,null,e.mode,r),r.ref=Ra(e,t,n),r.return=e,r)}function u(e,t,n,r){return t===null||t.tag!==4||t.stateNode.containerInfo!==n.containerInfo||t.stateNode.implementation!==n.implementation?(t=eu(n,e.mode,r),t.return=e,t):(t=a(t,n.children||[]),t.return=e,t)}function d(e,t,n,r,i){return t===null||t.tag!==7?(t=Zl(n,e.mode,r,i),t.return=e,t):(t=a(t,n),t.return=e,t)}function f(e,t,n){if(typeof t==`string`&&t!==``||typeof t==`number`)return t=$l(``+t,e.mode,n),t.return=e,t;if(typeof t==`object`&&t){switch(t.$$typeof){case w:return n=Xl(t.type,t.key,t.props,null,e.mode,n),n.ref=Ra(e,null,t),n.return=e,n;case T:return t=eu(t,e.mode,n),t.return=e,t;case se:var r=t._init;return f(e,r(t._payload),n)}if(Oe(t)||ue(t))return t=Zl(t,e.mode,n,null),t.return=e,t;za(e,t)}return null}function p(e,t,n,r){var i=t===null?null:t.key;if(typeof n==`string`&&n!==``||typeof n==`number`)return i===null?c(e,t,``+n,r):null;if(typeof n==`object`&&n){switch(n.$$typeof){case w:return n.key===i?l(e,t,n,r):null;case T:return n.key===i?u(e,t,n,r):null;case se:return i=n._init,p(e,t,i(n._payload),r)}if(Oe(n)||ue(n))return i===null?d(e,t,n,r,null):null;za(e,n)}return null}function m(e,t,n,r,i){if(typeof r==`string`&&r!==``||typeof r==`number`)return e=e.get(n)||null,c(t,e,``+r,i);if(typeof r==`object`&&r){switch(r.$$typeof){case w:return e=e.get(r.key===null?n:r.key)||null,l(t,e,r,i);case T:return e=e.get(r.key===null?n:r.key)||null,u(t,e,r,i);case se:var a=r._init;return m(e,t,n,a(r._payload),i)}if(Oe(r)||ue(r))return e=e.get(n)||null,d(t,e,r,i,null);za(t,r)}return null}function h(r,a,s,c){for(var l=null,u=null,d=a,h=a=0,g=null;d!==null&&h<s.length;h++){d.index>h?(g=d,d=null):g=d.sibling;var _=p(r,d,s[h],c);if(_===null){d===null&&(d=g);break}e&&d&&_.alternate===null&&t(r,d),a=o(_,a,h),u===null?l=_:u.sibling=_,u=_,d=g}if(h===s.length)return n(r,d),H&&xa(r,h),l;if(d===null){for(;h<s.length;h++)d=f(r,s[h],c),d!==null&&(a=o(d,a,h),u===null?l=d:u.sibling=d,u=d);return H&&xa(r,h),l}for(d=i(r,d);h<s.length;h++)g=m(d,r,h,s[h],c),g!==null&&(e&&g.alternate!==null&&d.delete(g.key===null?h:g.key),a=o(g,a,h),u===null?l=g:u.sibling=g,u=g);return e&&d.forEach(function(e){return t(r,e)}),H&&xa(r,h),l}function g(a,s,c,l){var u=ue(c);if(typeof u!=`function`)throw Error(r(150));if(c=u.call(c),c==null)throw Error(r(151));for(var d=u=null,h=s,g=s=0,_=null,v=c.next();h!==null&&!v.done;g++,v=c.next()){h.index>g?(_=h,h=null):_=h.sibling;var y=p(a,h,v.value,l);if(y===null){h===null&&(h=_);break}e&&h&&y.alternate===null&&t(a,h),s=o(y,s,g),d===null?u=y:d.sibling=y,d=y,h=_}if(v.done)return n(a,h),H&&xa(a,g),u;if(h===null){for(;!v.done;g++,v=c.next())v=f(a,v.value,l),v!==null&&(s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return H&&xa(a,g),u}for(h=i(a,h);!v.done;g++,v=c.next())v=m(h,a,g,v.value,l),v!==null&&(e&&v.alternate!==null&&h.delete(v.key===null?g:v.key),s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return e&&h.forEach(function(e){return t(a,e)}),H&&xa(a,g),u}function _(e,r,i,o){if(typeof i==`object`&&i&&i.type===ee&&i.key===null&&(i=i.props.children),typeof i==`object`&&i){switch(i.$$typeof){case w:a:{for(var c=i.key,l=r;l!==null;){if(l.key===c){if(c=i.type,c===ee){if(l.tag===7){n(e,l.sibling),r=a(l,i.props.children),r.return=e,e=r;break a}}else if(l.elementType===c||typeof c==`object`&&c&&c.$$typeof===se&&Ba(c)===l.type){n(e,l.sibling),r=a(l,i.props),r.ref=Ra(e,l,i),r.return=e,e=r;break a}n(e,l);break}t(e,l),l=l.sibling}i.type===ee?(r=Zl(i.props.children,e.mode,o,i.key),r.return=e,e=r):(o=Xl(i.type,i.key,i.props,null,e.mode,o),o.ref=Ra(e,r,i),o.return=e,e=o)}return s(e);case T:a:{for(l=i.key;r!==null;){if(r.key===l){if(r.tag===4&&r.stateNode.containerInfo===i.containerInfo&&r.stateNode.implementation===i.implementation){n(e,r.sibling),r=a(r,i.children||[]),r.return=e,e=r;break a}n(e,r);break}t(e,r),r=r.sibling}r=eu(i,e.mode,o),r.return=e,e=r}return s(e);case se:return l=i._init,_(e,r,l(i._payload),o)}if(Oe(i))return h(e,r,i,o);if(ue(i))return g(e,r,i,o);za(e,i)}return typeof i==`string`&&i!==``||typeof i==`number`?(i=``+i,r!==null&&r.tag===6?(n(e,r.sibling),r=a(r,i),r.return=e,e=r):(n(e,r),r=$l(i,e.mode,o),r.return=e,e=r),s(e)):n(e,r)}return _}var Ha=Va(!0),Ua=Va(!1),Wa=Ji(null),Ga=null,Ka=null,qa=null;function Ja(){qa=Ka=Ga=null}function Ya(e){var t=Wa.current;B(Wa),e._currentValue=t}function Xa(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)===t?r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t):(e.childLanes|=t,r!==null&&(r.childLanes|=t)),e===n)break;e=e.return}}function Za(e,t){Ga=e,qa=Ka=null,e=e.dependencies,e!==null&&e.firstContext!==null&&((e.lanes&t)!==0&&(Ls=!0),e.firstContext=null)}function Qa(e){var t=e._currentValue;if(qa!==e){if(e={context:e,memoizedValue:t,next:null},Ka===null){if(Ga===null)throw Error(r(308));Ka=e,Ga.dependencies={lanes:0,firstContext:e}}else Ka=Ka.next=e}return t}var $a=null;function eo(e){$a===null?$a=[e]:$a.push(e)}function to(e,t,n,r){var i=t.interleaved;return i===null?(n.next=n,eo(t)):(n.next=i.next,i.next=n),t.interleaved=n,no(e,r)}function no(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var ro=!1;function io(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function ao(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function oo(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function so(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,Y&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,no(e,n)}return i=r.interleaved,i===null?(t.next=t,eo(r)):(t.next=i.next,i.next=t),r.interleaved=t,no(e,n)}function co(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,n&4194240)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Yt(e,n)}}function lo(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var o={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};a===null?i=a=o:a=a.next=o,n=n.next}while(n!==null);a===null?i=a=t:a=a.next=t}else i=a=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:a,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function uo(e,t,n,r){var i=e.updateQueue;ro=!1;var a=i.firstBaseUpdate,o=i.lastBaseUpdate,s=i.shared.pending;if(s!==null){i.shared.pending=null;var c=s,l=c.next;c.next=null,o===null?a=l:o.next=l,o=c;var u=e.alternate;u!==null&&(u=u.updateQueue,s=u.lastBaseUpdate,s!==o&&(s===null?u.firstBaseUpdate=l:s.next=l,u.lastBaseUpdate=c))}if(a!==null){var d=i.baseState;o=0,u=l=c=null,s=a;do{var f=s.lane,p=s.eventTime;if((r&f)===f){u!==null&&(u=u.next={eventTime:p,lane:0,tag:s.tag,payload:s.payload,callback:s.callback,next:null});a:{var m=e,h=s;switch(f=t,p=n,h.tag){case 1:if(m=h.payload,typeof m==`function`){d=m.call(p,d,f);break a}d=m;break a;case 3:m.flags=m.flags&-65537|128;case 0:if(m=h.payload,f=typeof m==`function`?m.call(p,d,f):m,f==null)break a;d=O({},d,f);break a;case 2:ro=!0}}s.callback!==null&&s.lane!==0&&(e.flags|=64,f=i.effects,f===null?i.effects=[s]:f.push(s))}else p={eventTime:p,lane:f,tag:s.tag,payload:s.payload,callback:s.callback,next:null},u===null?(l=u=p,c=d):u=u.next=p,o|=f;if(s=s.next,s===null){if(s=i.shared.pending,s===null)break;f=s,s=f.next,f.next=null,i.lastBaseUpdate=f,i.shared.pending=null}}while(1);if(u===null&&(c=d),i.baseState=c,i.firstBaseUpdate=l,i.lastBaseUpdate=u,t=i.shared.interleaved,t!==null){i=t;do o|=i.lane,i=i.next;while(i!==t)}else a===null&&(i.shared.lanes=0);Yc|=o,e.lanes=o,e.memoizedState=d}}function fo(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;t<e.length;t++){var i=e[t],a=i.callback;if(a!==null){if(i.callback=null,i=n,typeof a!=`function`)throw Error(r(191,a));a.call(i)}}}var po={},mo=Ji(po),ho=Ji(po),go=Ji(po);function _o(e){if(e===po)throw Error(r(174));return e}function vo(e,t){switch(V(go,t),V(ho,e),V(mo,po),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:Fe(null,``);break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=Fe(t,e)}B(mo),V(mo,t)}function yo(){B(mo),B(ho),B(go)}function bo(e){_o(go.current);var t=_o(mo.current),n=Fe(t,e.type);t!==n&&(V(ho,e),V(mo,n))}function xo(e){ho.current===e&&(B(mo),B(ho))}var U=Ji(0);function So(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||n.data===`$?`||n.data===`$!`))return t}else if(t.tag===19&&t.memoizedProps.revealOrder!==void 0){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var Co=[];function wo(){for(var e=0;e<Co.length;e++)Co[e]._workInProgressVersionPrimary=null;Co.length=0}var To=C.ReactCurrentDispatcher,Eo=C.ReactCurrentBatchConfig,Do=0,W=null,G=null,K=null,Oo=!1,ko=!1,Ao=0,jo=0;function Mo(){throw Error(r(321))}function No(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!Mr(e[n],t[n]))return!1;return!0}function Po(e,t,n,i,a,o){if(Do=o,W=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,To.current=e===null||e.memoizedState===null?_s:vs,e=n(i,a),ko){o=0;do{if(ko=!1,Ao=0,25<=o)throw Error(r(301));o+=1,K=G=null,t.updateQueue=null,To.current=ys,e=n(i,a)}while(ko)}if(To.current=gs,t=G!==null&&G.next!==null,Do=0,K=G=W=null,Oo=!1,t)throw Error(r(300));return e}function Fo(){var e=Ao!==0;return Ao=0,e}function Io(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return K===null?W.memoizedState=K=e:K=K.next=e,K}function Lo(){if(G===null){var e=W.alternate;e=e===null?null:e.memoizedState}else e=G.next;var t=K===null?W.memoizedState:K.next;if(t!==null)K=t,G=e;else{if(e===null)throw Error(r(310));G=e,e={memoizedState:G.memoizedState,baseState:G.baseState,baseQueue:G.baseQueue,queue:G.queue,next:null},K===null?W.memoizedState=K=e:K=K.next=e}return K}function Ro(e,t){return typeof t==`function`?t(e):t}function zo(e){var t=Lo(),n=t.queue;if(n===null)throw Error(r(311));n.lastRenderedReducer=e;var i=G,a=i.baseQueue,o=n.pending;if(o!==null){if(a!==null){var s=a.next;a.next=o.next,o.next=s}i.baseQueue=a=o,n.pending=null}if(a!==null){o=a.next,i=i.baseState;var c=s=null,l=null,u=o;do{var d=u.lane;if((Do&d)===d)l!==null&&(l=l.next={lane:0,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),i=u.hasEagerState?u.eagerState:e(i,u.action);else{var f={lane:d,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null};l===null?(c=l=f,s=i):l=l.next=f,W.lanes|=d,Yc|=d}u=u.next}while(u!==null&&u!==o);l===null?s=i:l.next=c,Mr(i,t.memoizedState)||(Ls=!0),t.memoizedState=i,t.baseState=s,t.baseQueue=l,n.lastRenderedState=i}if(e=n.interleaved,e!==null){a=e;do o=a.lane,W.lanes|=o,Yc|=o,a=a.next;while(a!==e)}else a===null&&(n.lanes=0);return[t.memoizedState,n.dispatch]}function Bo(e){var t=Lo(),n=t.queue;if(n===null)throw Error(r(311));n.lastRenderedReducer=e;var i=n.dispatch,a=n.pending,o=t.memoizedState;if(a!==null){n.pending=null;var s=a=a.next;do o=e(o,s.action),s=s.next;while(s!==a);Mr(o,t.memoizedState)||(Ls=!0),t.memoizedState=o,t.baseQueue===null&&(t.baseState=o),n.lastRenderedState=o}return[o,i]}function Vo(){}function Ho(e,t){var n=W,i=Lo(),a=t(),o=!Mr(i.memoizedState,a);if(o&&(i.memoizedState=a,Ls=!0),i=i.queue,es(Go.bind(null,n,i,e),[e]),i.getSnapshot!==t||o||K!==null&&K.memoizedState.tag&1){if(n.flags|=2048,Yo(9,Wo.bind(null,n,i,a,t),void 0,null),X===null)throw Error(r(349));Do&30||Uo(n,t,a)}return a}function Uo(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=W.updateQueue,t===null?(t={lastEffect:null,stores:null},W.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function Wo(e,t,n,r){t.value=n,t.getSnapshot=r,Ko(t)&&qo(e)}function Go(e,t,n){return n(function(){Ko(t)&&qo(e)})}function Ko(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!Mr(e,n)}catch{return!0}}function qo(e){var t=no(e,1);t!==null&&hl(t,e,1,-1)}function Jo(e){var t=Io();return typeof e==`function`&&(e=e()),t.memoizedState=t.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Ro,lastRenderedState:e},t.queue=e,e=e.dispatch=fs.bind(null,W,e),[t.memoizedState,e]}function Yo(e,t,n,r){return e={tag:e,create:t,destroy:n,deps:r,next:null},t=W.updateQueue,t===null?(t={lastEffect:null,stores:null},W.updateQueue=t,t.lastEffect=e.next=e):(n=t.lastEffect,n===null?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e)),e}function Xo(){return Lo().memoizedState}function Zo(e,t,n,r){var i=Io();W.flags|=e,i.memoizedState=Yo(1|t,n,void 0,r===void 0?null:r)}function Qo(e,t,n,r){var i=Lo();r=r===void 0?null:r;var a=void 0;if(G!==null){var o=G.memoizedState;if(a=o.destroy,r!==null&&No(r,o.deps)){i.memoizedState=Yo(t,n,a,r);return}}W.flags|=e,i.memoizedState=Yo(1|t,n,a,r)}function $o(e,t){return Zo(8390656,8,e,t)}function es(e,t){return Qo(2048,8,e,t)}function ts(e,t){return Qo(4,2,e,t)}function ns(e,t){return Qo(4,4,e,t)}function rs(e,t){if(typeof t==`function`)return e=e(),t(e),function(){t(null)};if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function is(e,t,n){return n=n==null?null:n.concat([e]),Qo(4,4,rs.bind(null,t,e),n)}function as(){}function os(e,t){var n=Lo();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&No(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function ss(e,t){var n=Lo();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&No(t,r[1])?r[0]:(e=e(),n.memoizedState=[e,t],e)}function cs(e,t,n){return Do&21?(Mr(n,t)||(n=Gt(),W.lanes|=n,Yc|=n,e.baseState=!0),t):(e.baseState&&(e.baseState=!1,Ls=!0),e.memoizedState=n)}function ls(e,t){var n=M;M=n!==0&&4>n?n:4,e(!0);var r=Eo.transition;Eo.transition={};try{e(!1),t()}finally{M=n,Eo.transition=r}}function us(){return Lo().memoizedState}function ds(e,t,n){var r=ml(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},ps(e))ms(t,n);else if(n=to(e,t,n,r),n!==null){var i=pl();hl(n,e,r,i),hs(n,t,r)}}function fs(e,t,n){var r=ml(e),i={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(ps(e))ms(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var o=t.lastRenderedState,s=a(o,n);if(i.hasEagerState=!0,i.eagerState=s,Mr(s,o)){var c=t.interleaved;c===null?(i.next=i,eo(t)):(i.next=c.next,c.next=i),t.interleaved=i;return}}catch{}n=to(e,t,i,r),n!==null&&(i=pl(),hl(n,e,r,i),hs(n,t,r))}}function ps(e){var t=e.alternate;return e===W||t!==null&&t===W}function ms(e,t){ko=Oo=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function hs(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Yt(e,n)}}var gs={readContext:Qa,useCallback:Mo,useContext:Mo,useEffect:Mo,useImperativeHandle:Mo,useInsertionEffect:Mo,useLayoutEffect:Mo,useMemo:Mo,useReducer:Mo,useRef:Mo,useState:Mo,useDebugValue:Mo,useDeferredValue:Mo,useTransition:Mo,useMutableSource:Mo,useSyncExternalStore:Mo,useId:Mo,unstable_isNewReconciler:!1},_s={readContext:Qa,useCallback:function(e,t){return Io().memoizedState=[e,t===void 0?null:t],e},useContext:Qa,useEffect:$o,useImperativeHandle:function(e,t,n){return n=n==null?null:n.concat([e]),Zo(4194308,4,rs.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Zo(4194308,4,e,t)},useInsertionEffect:function(e,t){return Zo(4,2,e,t)},useMemo:function(e,t){var n=Io();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=Io();return t=n===void 0?t:n(t),r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=ds.bind(null,W,e),[r.memoizedState,e]},useRef:function(e){var t=Io();return e={current:e},t.memoizedState=e},useState:Jo,useDebugValue:as,useDeferredValue:function(e){return Io().memoizedState=e},useTransition:function(){var e=Jo(!1),t=e[0];return e=ls.bind(null,e[1]),Io().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var i=W,a=Io();if(H){if(n===void 0)throw Error(r(407));n=n()}else{if(n=t(),X===null)throw Error(r(349));Do&30||Uo(i,t,n)}a.memoizedState=n;var o={value:n,getSnapshot:t};return a.queue=o,$o(Go.bind(null,i,o,e),[e]),i.flags|=2048,Yo(9,Wo.bind(null,i,o,n,t),void 0,null),n},useId:function(){var e=Io(),t=X.identifierPrefix;if(H){var n=ba,r=ya;n=(r&~(1<<32-Pt(r)-1)).toString(32)+n,t=`:`+t+`R`+n,n=Ao++,0<n&&(t+=`H`+n.toString(32)),t+=`:`}else n=jo++,t=`:`+t+`r`+n.toString(32)+`:`;return e.memoizedState=t},unstable_isNewReconciler:!1},vs={readContext:Qa,useCallback:os,useContext:Qa,useEffect:es,useImperativeHandle:is,useInsertionEffect:ts,useLayoutEffect:ns,useMemo:ss,useReducer:zo,useRef:Xo,useState:function(){return zo(Ro)},useDebugValue:as,useDeferredValue:function(e){return cs(Lo(),G.memoizedState,e)},useTransition:function(){return[zo(Ro)[0],Lo().memoizedState]},useMutableSource:Vo,useSyncExternalStore:Ho,useId:us,unstable_isNewReconciler:!1},ys={readContext:Qa,useCallback:os,useContext:Qa,useEffect:es,useImperativeHandle:is,useInsertionEffect:ts,useLayoutEffect:ns,useMemo:ss,useReducer:Bo,useRef:Xo,useState:function(){return Bo(Ro)},useDebugValue:as,useDeferredValue:function(e){var t=Lo();return G===null?t.memoizedState=e:cs(t,G.memoizedState,e)},useTransition:function(){return[Bo(Ro)[0],Lo().memoizedState]},useMutableSource:Vo,useSyncExternalStore:Ho,useId:us,unstable_isNewReconciler:!1};function bs(e,t){if(e&&e.defaultProps){for(var n in t=O({},t),e=e.defaultProps,e)t[n]===void 0&&(t[n]=e[n]);return t}return t}function xs(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:O({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var Ss={isMounted:function(e){return(e=e._reactInternals)?ht(e)===e:!1},enqueueSetState:function(e,t,n){e=e._reactInternals;var r=pl(),i=ml(e),a=oo(r,i);a.payload=t,n!=null&&(a.callback=n),t=so(e,a,i),t!==null&&(hl(t,e,i,r),co(t,e,i))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=pl(),i=ml(e),a=oo(r,i);a.tag=1,a.payload=t,n!=null&&(a.callback=n),t=so(e,a,i),t!==null&&(hl(t,e,i,r),co(t,e,i))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=pl(),r=ml(e),i=oo(n,r);i.tag=2,t!=null&&(i.callback=t),t=so(e,i,r),t!==null&&(hl(t,e,r,n),co(t,e,r))}};function Cs(e,t,n,r,i,a,o){return e=e.stateNode,typeof e.shouldComponentUpdate==`function`?e.shouldComponentUpdate(r,a,o):t.prototype&&t.prototype.isPureReactComponent?!Nr(n,r)||!Nr(i,a):!0}function ws(e,t,n){var r=!1,i=Yi,a=t.contextType;return typeof a==`object`&&a?a=Qa(a):(i=ea(t)?Qi:Xi.current,r=t.contextTypes,a=(r=r!=null)?$i(e,i):Yi),t=new t(n,a),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=Ss,e.stateNode=t,t._reactInternals=e,r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=i,e.__reactInternalMemoizedMaskedChildContext=a),t}function Ts(e,t,n,r){e=t.state,typeof t.componentWillReceiveProps==`function`&&t.componentWillReceiveProps(n,r),typeof t.UNSAFE_componentWillReceiveProps==`function`&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&Ss.enqueueReplaceState(t,t.state,null)}function Es(e,t,n,r){var i=e.stateNode;i.props=n,i.state=e.memoizedState,i.refs={},io(e);var a=t.contextType;typeof a==`object`&&a?i.context=Qa(a):(a=ea(t)?Qi:Xi.current,i.context=$i(e,a)),i.state=e.memoizedState,a=t.getDerivedStateFromProps,typeof a==`function`&&(xs(e,t,a,n),i.state=e.memoizedState),typeof t.getDerivedStateFromProps==`function`||typeof i.getSnapshotBeforeUpdate==`function`||typeof i.UNSAFE_componentWillMount!=`function`&&typeof i.componentWillMount!=`function`||(t=i.state,typeof i.componentWillMount==`function`&&i.componentWillMount(),typeof i.UNSAFE_componentWillMount==`function`&&i.UNSAFE_componentWillMount(),t!==i.state&&Ss.enqueueReplaceState(i,i.state,null),uo(e,n,i,r),i.state=e.memoizedState),typeof i.componentDidMount==`function`&&(e.flags|=4194308)}function Ds(e,t){try{var n=``,r=t;do n+=me(r),r=r.return;while(r);var i=n}catch(e){i=`
|
|
7
7
|
Error generating stack: `+e.message+`
|
|
8
8
|
`+e.stack}return{value:e,source:t,stack:i,digest:null}}function Os(e,t,n){return{value:e,source:null,stack:n??null,digest:t??null}}function ks(e,t){try{console.error(t.value)}catch(e){setTimeout(function(){throw e})}}var As=typeof WeakMap==`function`?WeakMap:Map;function js(e,t,n){n=oo(-1,n),n.tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){rl||(rl=!0,il=r),ks(e,t)},n}function Ms(e,t,n){n=oo(-1,n),n.tag=3;var r=e.type.getDerivedStateFromError;if(typeof r==`function`){var i=t.value;n.payload=function(){return r(i)},n.callback=function(){ks(e,t)}}var a=e.stateNode;return a!==null&&typeof a.componentDidCatch==`function`&&(n.callback=function(){ks(e,t),typeof r!=`function`&&(al===null?al=new Set([this]):al.add(this));var n=t.stack;this.componentDidCatch(t.value,{componentStack:n===null?``:n})}),n}function Ns(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new As;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(i.add(n),e=zl.bind(null,e,t,n),t.then(e,e))}function Ps(e){do{var t;if((t=e.tag===13)&&(t=e.memoizedState,t=t===null||t.dehydrated!==null),t)return e;e=e.return}while(e!==null);return null}function Fs(e,t,n,r,i){return e.mode&1?(e.flags|=65536,e.lanes=i,e):(e===t?e.flags|=65536:(e.flags|=128,n.flags|=131072,n.flags&=-52805,n.tag===1&&(n.alternate===null?n.tag=17:(t=oo(-1,1),t.tag=2,so(n,t,1))),n.lanes|=1),e)}var Is=C.ReactCurrentOwner,Ls=!1;function Rs(e,t,n,r){t.child=e===null?Ua(t,null,n,r):Ha(t,e.child,n,r)}function zs(e,t,n,r,i){n=n.render;var a=t.ref;return Za(t,i),r=Po(e,t,n,r,a,i),n=Fo(),e!==null&&!Ls?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~i,ac(e,t,i)):(H&&n&&Ca(t),t.flags|=1,Rs(e,t,r,i),t.child)}function Bs(e,t,n,r,i){if(e===null){var a=n.type;return typeof a==`function`&&!ql(a)&&a.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(t.tag=15,t.type=a,Vs(e,t,a,r,i)):(e=Xl(n.type,null,r,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(a=e.child,(e.lanes&i)===0){var o=a.memoizedProps;if(n=n.compare,n=n===null?Nr:n,n(o,r)&&e.ref===t.ref)return ac(e,t,i)}return t.flags|=1,e=Yl(a,r),e.ref=t.ref,e.return=t,t.child=e}function Vs(e,t,n,r,i){if(e!==null){var a=e.memoizedProps;if(Nr(a,r)&&e.ref===t.ref){if(Ls=!1,t.pendingProps=r=a,(e.lanes&i)!==0)e.flags&131072&&(Ls=!0);else return t.lanes=e.lanes,ac(e,t,i)}}return Ws(e,t,n,r,i)}function Hs(e,t,n){var r=t.pendingProps,i=r.children,a=e===null?null:e.memoizedState;if(r.mode===`hidden`){if(!(t.mode&1))t.memoizedState={baseLanes:0,cachePool:null,transitions:null},V(qc,Kc),Kc|=n;else{if(!(n&1073741824))return e=a===null?n:a.baseLanes|n,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,V(qc,Kc),Kc|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=a===null?n:a.baseLanes,V(qc,Kc),Kc|=r}}else a===null?r=n:(r=a.baseLanes|n,t.memoizedState=null),V(qc,Kc),Kc|=r;return Rs(e,t,i,n),t.child}function Us(e,t){var n=t.ref;(e===null&&n!==null||e!==null&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function Ws(e,t,n,r,i){var a=ea(n)?Qi:Xi.current;return a=$i(t,a),Za(t,i),n=Po(e,t,n,r,a,i),r=Fo(),e!==null&&!Ls?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~i,ac(e,t,i)):(H&&r&&Ca(t),t.flags|=1,Rs(e,t,n,i),t.child)}function Gs(e,t,n,r,i){if(ea(n)){var a=!0;ia(t)}else a=!1;if(Za(t,i),t.stateNode===null)ic(e,t),ws(t,n,r),Es(t,n,r,i),r=!0;else if(e===null){var o=t.stateNode,s=t.memoizedProps;o.props=s;var c=o.context,l=n.contextType;typeof l==`object`&&l?l=Qa(l):(l=ea(n)?Qi:Xi.current,l=$i(t,l));var u=n.getDerivedStateFromProps,d=typeof u==`function`||typeof o.getSnapshotBeforeUpdate==`function`;d||typeof o.UNSAFE_componentWillReceiveProps!=`function`&&typeof o.componentWillReceiveProps!=`function`||(s!==r||c!==l)&&Ts(t,o,r,l),ro=!1;var f=t.memoizedState;o.state=f,uo(t,r,o,i),c=t.memoizedState,s!==r||f!==c||Zi.current||ro?(typeof u==`function`&&(xs(t,n,u,r),c=t.memoizedState),(s=ro||Cs(t,n,s,r,f,c,l))?(d||typeof o.UNSAFE_componentWillMount!=`function`&&typeof o.componentWillMount!=`function`||(typeof o.componentWillMount==`function`&&o.componentWillMount(),typeof o.UNSAFE_componentWillMount==`function`&&o.UNSAFE_componentWillMount()),typeof o.componentDidMount==`function`&&(t.flags|=4194308)):(typeof o.componentDidMount==`function`&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=c),o.props=r,o.state=c,o.context=l,r=s):(typeof o.componentDidMount==`function`&&(t.flags|=4194308),r=!1)}else{o=t.stateNode,ao(e,t),s=t.memoizedProps,l=t.type===t.elementType?s:bs(t.type,s),o.props=l,d=t.pendingProps,f=o.context,c=n.contextType,typeof c==`object`&&c?c=Qa(c):(c=ea(n)?Qi:Xi.current,c=$i(t,c));var p=n.getDerivedStateFromProps;(u=typeof p==`function`||typeof o.getSnapshotBeforeUpdate==`function`)||typeof o.UNSAFE_componentWillReceiveProps!=`function`&&typeof o.componentWillReceiveProps!=`function`||(s!==d||f!==c)&&Ts(t,o,r,c),ro=!1,f=t.memoizedState,o.state=f,uo(t,r,o,i);var m=t.memoizedState;s!==d||f!==m||Zi.current||ro?(typeof p==`function`&&(xs(t,n,p,r),m=t.memoizedState),(l=ro||Cs(t,n,l,r,f,m,c)||!1)?(u||typeof o.UNSAFE_componentWillUpdate!=`function`&&typeof o.componentWillUpdate!=`function`||(typeof o.componentWillUpdate==`function`&&o.componentWillUpdate(r,m,c),typeof o.UNSAFE_componentWillUpdate==`function`&&o.UNSAFE_componentWillUpdate(r,m,c)),typeof o.componentDidUpdate==`function`&&(t.flags|=4),typeof o.getSnapshotBeforeUpdate==`function`&&(t.flags|=1024)):(typeof o.componentDidUpdate!=`function`||s===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof o.getSnapshotBeforeUpdate!=`function`||s===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=m),o.props=r,o.state=m,o.context=c,r=l):(typeof o.componentDidUpdate!=`function`||s===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof o.getSnapshotBeforeUpdate!=`function`||s===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),r=!1)}return Ks(e,t,n,r,a,i)}function Ks(e,t,n,r,i,a){Us(e,t);var o=!!(t.flags&128);if(!r&&!o)return i&&aa(t,n,!1),ac(e,t,a);r=t.stateNode,Is.current=t;var s=o&&typeof n.getDerivedStateFromError!=`function`?null:r.render();return t.flags|=1,e!==null&&o?(t.child=Ha(t,e.child,null,a),t.child=Ha(t,null,s,a)):Rs(e,t,s,a),t.memoizedState=r.state,i&&aa(t,n,!0),t.child}function qs(e){var t=e.stateNode;t.pendingContext?na(e,t.pendingContext,t.pendingContext!==t.context):t.context&&na(e,t.context,!1),vo(e,t.containerInfo)}function Js(e,t,n,r,i){return Fa(),Ia(i),t.flags|=256,Rs(e,t,n,r),t.child}var Ys={dehydrated:null,treeContext:null,retryLane:0};function Xs(e){return{baseLanes:e,cachePool:null,transitions:null}}function Zs(e,t,n){var r=t.pendingProps,i=U.current,a=!1,o=!!(t.flags&128),s;if((s=o)||(s=e!==null&&e.memoizedState===null?!1:!!(i&2)),s?(a=!0,t.flags&=-129):(e===null||e.memoizedState!==null)&&(i|=1),V(U,i&1),e===null)return ja(t),e=t.memoizedState,e!==null&&(e=e.dehydrated,e!==null)?(t.lanes=t.mode&1?e.data===`$!`?8:1073741824:1,null):(o=r.children,e=r.fallback,a?(r=t.mode,a=t.child,o={mode:`hidden`,children:o},!(r&1)&&a!==null?(a.childLanes=0,a.pendingProps=o):a=Ql(o,r,0,null),e=Zl(e,r,n,null),a.return=t,e.return=t,a.sibling=e,t.child=a,t.child.memoizedState=Xs(n),t.memoizedState=Ys,e):Qs(t,o));if(i=e.memoizedState,i!==null&&(s=i.dehydrated,s!==null))return ec(e,t,o,r,s,i,n);if(a){a=r.fallback,o=t.mode,i=e.child,s=i.sibling;var c={mode:`hidden`,children:r.children};return!(o&1)&&t.child!==i?(r=t.child,r.childLanes=0,r.pendingProps=c,t.deletions=null):(r=Yl(i,c),r.subtreeFlags=i.subtreeFlags&14680064),s===null?(a=Zl(a,o,n,null),a.flags|=2):a=Yl(s,a),a.return=t,r.return=t,r.sibling=a,t.child=r,r=a,a=t.child,o=e.child.memoizedState,o=o===null?Xs(n):{baseLanes:o.baseLanes|n,cachePool:null,transitions:o.transitions},a.memoizedState=o,a.childLanes=e.childLanes&~n,t.memoizedState=Ys,r}return a=e.child,e=a.sibling,r=Yl(a,{mode:`visible`,children:r.children}),!(t.mode&1)&&(r.lanes=n),r.return=t,r.sibling=null,e!==null&&(n=t.deletions,n===null?(t.deletions=[e],t.flags|=16):n.push(e)),t.child=r,t.memoizedState=null,r}function Qs(e,t){return t=Ql({mode:`visible`,children:t},e.mode,0,null),t.return=e,e.child=t}function $s(e,t,n,r){return r!==null&&Ia(r),Ha(t,e.child,null,n),e=Qs(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function ec(e,t,n,i,a,o,s){if(n)return t.flags&256?(t.flags&=-257,i=Os(Error(r(422))),$s(e,t,s,i)):t.memoizedState===null?(o=i.fallback,a=t.mode,i=Ql({mode:`visible`,children:i.children},a,0,null),o=Zl(o,a,s,null),o.flags|=2,i.return=t,o.return=t,i.sibling=o,t.child=i,t.mode&1&&Ha(t,e.child,null,s),t.child.memoizedState=Xs(s),t.memoizedState=Ys,o):(t.child=e.child,t.flags|=128,null);if(!(t.mode&1))return $s(e,t,s,null);if(a.data===`$!`){if(i=a.nextSibling&&a.nextSibling.dataset,i)var c=i.dgst;return i=c,o=Error(r(419)),i=Os(o,i,void 0),$s(e,t,s,i)}if(c=(s&e.childLanes)!==0,Ls||c){if(i=X,i!==null){switch(s&-s){case 4:a=2;break;case 16:a=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:a=32;break;case 536870912:a=268435456;break;default:a=0}a=(a&(i.suspendedLanes|s))===0?a:0,a!==0&&a!==o.retryLane&&(o.retryLane=a,no(e,a),hl(i,e,a,-1))}return kl(),i=Os(Error(r(421))),$s(e,t,s,i)}return a.data===`$?`?(t.flags|=128,t.child=e.child,t=Vl.bind(null,e),a._reactRetry=t,null):(e=o.treeContext,Ea=Ni(a.nextSibling),Ta=t,H=!0,Da=null,e!==null&&(ga[_a++]=ya,ga[_a++]=ba,ga[_a++]=va,ya=e.id,ba=e.overflow,va=t),t=Qs(t,i.children),t.flags|=4096,t)}function tc(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),Xa(e.return,t,n)}function nc(e,t,n,r,i){var a=e.memoizedState;a===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i}:(a.isBackwards=t,a.rendering=null,a.renderingStartTime=0,a.last=r,a.tail=n,a.tailMode=i)}function rc(e,t,n){var r=t.pendingProps,i=r.revealOrder,a=r.tail;if(Rs(e,t,r.children,n),r=U.current,r&2)r=r&1|2,t.flags|=128;else{if(e!==null&&e.flags&128)a:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&tc(e,n,t);else if(e.tag===19)tc(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break a;for(;e.sibling===null;){if(e.return===null||e.return===t)break a;e=e.return}e.sibling.return=e.return,e=e.sibling}r&=1}if(V(U,r),!(t.mode&1))t.memoizedState=null;else switch(i){case`forwards`:for(n=t.child,i=null;n!==null;)e=n.alternate,e!==null&&So(e)===null&&(i=n),n=n.sibling;n=i,n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),nc(t,!1,i,n,a);break;case`backwards`:for(n=null,i=t.child,t.child=null;i!==null;){if(e=i.alternate,e!==null&&So(e)===null){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}nc(t,!0,n,null,a);break;case`together`:nc(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function ic(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function ac(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),Yc|=t.lanes,(n&t.childLanes)===0)return null;if(e!==null&&t.child!==e.child)throw Error(r(153));if(t.child!==null){for(e=t.child,n=Yl(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=Yl(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function oc(e,t,n){switch(t.tag){case 3:qs(t),Fa();break;case 5:bo(t);break;case 1:ea(t.type)&&ia(t);break;case 4:vo(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,i=t.memoizedProps.value;V(Wa,r._currentValue),r._currentValue=i;break;case 13:if(r=t.memoizedState,r!==null)return r.dehydrated===null?(n&t.child.childLanes)===0?(V(U,U.current&1),e=ac(e,t,n),e===null?null:e.sibling):Zs(e,t,n):(V(U,U.current&1),t.flags|=128,null);V(U,U.current&1);break;case 19:if(r=(n&t.childLanes)!==0,e.flags&128){if(r)return rc(e,t,n);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),V(U,U.current),r)break;return null;case 22:case 23:return t.lanes=0,Hs(e,t,n)}return ac(e,t,n)}var sc=function(e,t){for(var n=t.child;n!==null;){if(n.tag===5||n.tag===6)e.appendChild(n.stateNode);else if(n.tag!==4&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===t)break;for(;n.sibling===null;){if(n.return===null||n.return===t)return;n=n.return}n.sibling.return=n.return,n=n.sibling}},cc=function(e,t,n,r){var i=e.memoizedProps;if(i!==r){e=t.stateNode,_o(mo.current);var o=null;switch(n){case`input`:i=Se(e,i),r=Se(e,r),o=[];break;case`select`:i=O({},i,{value:void 0}),r=O({},r,{value:void 0}),o=[];break;case`textarea`:i=Ae(e,i),r=Ae(e,r),o=[];break;default:typeof i.onClick!=`function`&&typeof r.onClick==`function`&&(e.onclick=Ci)}We(n,r);var s;for(u in n=null,i)if(!r.hasOwnProperty(u)&&i.hasOwnProperty(u)&&i[u]!=null){if(u===`style`){var c=i[u];for(s in c)c.hasOwnProperty(s)&&(n||={},n[s]=``)}else u!==`dangerouslySetInnerHTML`&&u!==`children`&&u!==`suppressContentEditableWarning`&&u!==`suppressHydrationWarning`&&u!==`autoFocus`&&(a.hasOwnProperty(u)?o||=[]:(o||=[]).push(u,null))}for(u in r){var l=r[u];if(c=i?.[u],r.hasOwnProperty(u)&&l!==c&&(l!=null||c!=null)){if(u===`style`){if(c){for(s in c)!c.hasOwnProperty(s)||l&&l.hasOwnProperty(s)||(n||={},n[s]=``);for(s in l)l.hasOwnProperty(s)&&c[s]!==l[s]&&(n||={},n[s]=l[s])}else n||(o||=[],o.push(u,n)),n=l}else u===`dangerouslySetInnerHTML`?(l=l?l.__html:void 0,c=c?c.__html:void 0,l!=null&&c!==l&&(o||=[]).push(u,l)):u===`children`?typeof l!=`string`&&typeof l!=`number`||(o||=[]).push(u,``+l):u!==`suppressContentEditableWarning`&&u!==`suppressHydrationWarning`&&(a.hasOwnProperty(u)?(l!=null&&u===`onScroll`&&z(`scroll`,e),o||c===l||(o=[])):(o||=[]).push(u,l))}}n&&(o||=[]).push(`style`,n);var u=o;(t.updateQueue=u)&&(t.flags|=4)}},lc=function(e,t,n,r){n!==r&&(t.flags|=4)};function uc(e,t){if(!H)switch(e.tailMode){case`hidden`:t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case`collapsed`:n=e.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null}}function dc(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags&14680064,r|=i.flags&14680064,i.return=e,i=i.sibling;else for(i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=e,i=i.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function fc(e,t,n){var i=t.pendingProps;switch(wa(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return dc(t),null;case 1:return ea(t.type)&&ta(),dc(t),null;case 3:return i=t.stateNode,yo(),B(Zi),B(Xi),wo(),i.pendingContext&&(i.context=i.pendingContext,i.pendingContext=null),(e===null||e.child===null)&&(Na(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,Da!==null&&(yl(Da),Da=null))),dc(t),null;case 5:xo(t);var o=_o(go.current);if(n=t.type,e!==null&&t.stateNode!=null)cc(e,t,n,i,o),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!i){if(t.stateNode===null)throw Error(r(166));return dc(t),null}if(e=_o(mo.current),Na(t)){i=t.stateNode,n=t.type;var s=t.memoizedProps;switch(i[Ii]=t,i[Li]=s,e=!!(t.mode&1),n){case`dialog`:z(`cancel`,i),z(`close`,i);break;case`iframe`:case`object`:case`embed`:z(`load`,i);break;case`video`:case`audio`:for(o=0;o<oi.length;o++)z(oi[o],i);break;case`source`:z(`error`,i);break;case`img`:case`image`:case`link`:z(`error`,i),z(`load`,i);break;case`details`:z(`toggle`,i);break;case`input`:Ce(i,s),z(`invalid`,i);break;case`select`:i._wrapperState={wasMultiple:!!s.multiple},z(`invalid`,i);break;case`textarea`:je(i,s),z(`invalid`,i)}for(var c in We(n,s),o=null,s)if(s.hasOwnProperty(c)){var l=s[c];c===`children`?typeof l==`string`?i.textContent!==l&&(!0!==s.suppressHydrationWarning&&Si(i.textContent,l,e),o=[`children`,l]):typeof l==`number`&&i.textContent!==``+l&&(!0!==s.suppressHydrationWarning&&Si(i.textContent,l,e),o=[`children`,``+l]):a.hasOwnProperty(c)&&l!=null&&c===`onScroll`&&z(`scroll`,i)}switch(n){case`input`:ye(i),Ee(i,s,!0);break;case`textarea`:ye(i),Ne(i);break;case`select`:case`option`:break;default:typeof s.onClick==`function`&&(i.onclick=Ci)}i=o,t.updateQueue=i,i!==null&&(t.flags|=4)}else{c=o.nodeType===9?o:o.ownerDocument,e===`http://www.w3.org/1999/xhtml`&&(e=Pe(n)),e===`http://www.w3.org/1999/xhtml`?n===`script`?(e=c.createElement(`div`),e.innerHTML=`<script><\/script>`,e=e.removeChild(e.firstChild)):typeof i.is==`string`?e=c.createElement(n,{is:i.is}):(e=c.createElement(n),n===`select`&&(c=e,i.multiple?c.multiple=!0:i.size&&(c.size=i.size))):e=c.createElementNS(e,n),e[Ii]=t,e[Li]=i,sc(e,t,!1,!1),t.stateNode=e;a:{switch(c=Ge(n,i),n){case`dialog`:z(`cancel`,e),z(`close`,e),o=i;break;case`iframe`:case`object`:case`embed`:z(`load`,e),o=i;break;case`video`:case`audio`:for(o=0;o<oi.length;o++)z(oi[o],e);o=i;break;case`source`:z(`error`,e),o=i;break;case`img`:case`image`:case`link`:z(`error`,e),z(`load`,e),o=i;break;case`details`:z(`toggle`,e),o=i;break;case`input`:Ce(e,i),o=Se(e,i),z(`invalid`,e);break;case`option`:o=i;break;case`select`:e._wrapperState={wasMultiple:!!i.multiple},o=O({},i,{value:void 0}),z(`invalid`,e);break;case`textarea`:je(e,i),o=Ae(e,i),z(`invalid`,e);break;default:o=i}for(s in We(n,o),l=o,l)if(l.hasOwnProperty(s)){var u=l[s];s===`style`?He(e,u):s===`dangerouslySetInnerHTML`?(u=u?u.__html:void 0,u!=null&&Le(e,u)):s===`children`?typeof u==`string`?(n!==`textarea`||u!==``)&&Re(e,u):typeof u==`number`&&Re(e,``+u):s!==`suppressContentEditableWarning`&&s!==`suppressHydrationWarning`&&s!==`autoFocus`&&(a.hasOwnProperty(s)?u!=null&&s===`onScroll`&&z(`scroll`,e):u!=null&&S(e,s,u,c))}switch(n){case`input`:ye(e),Ee(e,i,!1);break;case`textarea`:ye(e),Ne(e);break;case`option`:i.value!=null&&e.setAttribute(`value`,``+A(i.value));break;case`select`:e.multiple=!!i.multiple,s=i.value,s==null?i.defaultValue!=null&&ke(e,!!i.multiple,i.defaultValue,!0):ke(e,!!i.multiple,s,!1);break;default:typeof o.onClick==`function`&&(e.onclick=Ci)}switch(n){case`button`:case`input`:case`select`:case`textarea`:i=!!i.autoFocus;break a;case`img`:i=!0;break a;default:i=!1}}i&&(t.flags|=4)}t.ref!==null&&(t.flags|=512,t.flags|=2097152)}return dc(t),null;case 6:if(e&&t.stateNode!=null)lc(e,t,e.memoizedProps,i);else{if(typeof i!=`string`&&t.stateNode===null)throw Error(r(166));if(n=_o(go.current),_o(mo.current),Na(t)){if(i=t.stateNode,n=t.memoizedProps,i[Ii]=t,(s=i.nodeValue!==n)&&(e=Ta,e!==null))switch(e.tag){case 3:Si(i.nodeValue,n,!!(e.mode&1));break;case 5:!0!==e.memoizedProps.suppressHydrationWarning&&Si(i.nodeValue,n,!!(e.mode&1))}s&&(t.flags|=4)}else i=(n.nodeType===9?n:n.ownerDocument).createTextNode(i),i[Ii]=t,t.stateNode=i}return dc(t),null;case 13:if(B(U),i=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(H&&Ea!==null&&t.mode&1&&!(t.flags&128))Pa(),Fa(),t.flags|=98560,s=!1;else if(s=Na(t),i!==null&&i.dehydrated!==null){if(e===null){if(!s)throw Error(r(318));if(s=t.memoizedState,s=s===null?null:s.dehydrated,!s)throw Error(r(317));s[Ii]=t}else Fa(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;dc(t),s=!1}else Da!==null&&(yl(Da),Da=null),s=!0;if(!s)return t.flags&65536?t:null}return t.flags&128?(t.lanes=n,t):(i=i!==null,i!==(e!==null&&e.memoizedState!==null)&&i&&(t.child.flags|=8192,t.mode&1&&(e===null||U.current&1?Q===0&&(Q=3):kl())),t.updateQueue!==null&&(t.flags|=4),dc(t),null);case 4:return yo(),e===null&&fi(t.stateNode.containerInfo),dc(t),null;case 10:return Ya(t.type._context),dc(t),null;case 17:return ea(t.type)&&ta(),dc(t),null;case 19:if(B(U),s=t.memoizedState,s===null)return dc(t),null;if(i=!!(t.flags&128),c=s.rendering,c===null){if(i)uc(s,!1);else{if(Q!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(c=So(e),c!==null){for(t.flags|=128,uc(s,!1),i=c.updateQueue,i!==null&&(t.updateQueue=i,t.flags|=4),t.subtreeFlags=0,i=n,n=t.child;n!==null;)s=n,e=i,s.flags&=14680066,c=s.alternate,c===null?(s.childLanes=0,s.lanes=e,s.child=null,s.subtreeFlags=0,s.memoizedProps=null,s.memoizedState=null,s.updateQueue=null,s.dependencies=null,s.stateNode=null):(s.childLanes=c.childLanes,s.lanes=c.lanes,s.child=c.child,s.subtreeFlags=0,s.deletions=null,s.memoizedProps=c.memoizedProps,s.memoizedState=c.memoizedState,s.updateQueue=c.updateQueue,s.type=c.type,e=c.dependencies,s.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext}),n=n.sibling;return V(U,U.current&1|2),t.child}e=e.sibling}s.tail!==null&&j()>tl&&(t.flags|=128,i=!0,uc(s,!1),t.lanes=4194304)}}else{if(!i){if(e=So(c),e!==null){if(t.flags|=128,i=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),uc(s,!0),s.tail===null&&s.tailMode===`hidden`&&!c.alternate&&!H)return dc(t),null}else 2*j()-s.renderingStartTime>tl&&n!==1073741824&&(t.flags|=128,i=!0,uc(s,!1),t.lanes=4194304)}s.isBackwards?(c.sibling=t.child,t.child=c):(n=s.last,n===null?t.child=c:n.sibling=c,s.last=c)}return s.tail===null?(dc(t),null):(t=s.tail,s.rendering=t,s.tail=t.sibling,s.renderingStartTime=j(),t.sibling=null,n=U.current,V(U,i?n&1|2:n&1),t);case 22:case 23:return Tl(),i=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==i&&(t.flags|=8192),i&&t.mode&1?Kc&1073741824&&(dc(t),t.subtreeFlags&6&&(t.flags|=8192)):dc(t),null;case 24:return null;case 25:return null}throw Error(r(156,t.tag))}function pc(e,t){switch(wa(t),t.tag){case 1:return ea(t.type)&&ta(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return yo(),B(Zi),B(Xi),wo(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return xo(t),null;case 13:if(B(U),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(r(340));Fa()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return B(U),null;case 4:return yo(),null;case 10:return Ya(t.type._context),null;case 22:case 23:return Tl(),null;case 24:return null;default:return null}}var mc=!1,hc=!1,gc=typeof WeakSet==`function`?WeakSet:Set,q=null;function _c(e,t){var n=e.ref;if(n!==null){if(typeof n==`function`)try{n(null)}catch(n){$(e,t,n)}else n.current=null}}function vc(e,t,n){try{n()}catch(n){$(e,t,n)}}var yc=!1;function bc(e,t){if(wi=xn,e=Lr(),Rr(e)){if(`selectionStart`in e)var n={start:e.selectionStart,end:e.selectionEnd};else a:{n=(n=e.ownerDocument)&&n.defaultView||window;var i=n.getSelection&&n.getSelection();if(i&&i.rangeCount!==0){n=i.anchorNode;var a=i.anchorOffset,o=i.focusNode;i=i.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break a}var s=0,c=-1,l=-1,u=0,d=0,f=e,p=null;b:for(;;){for(var m;f!==n||a!==0&&f.nodeType!==3||(c=s+a),f!==o||i!==0&&f.nodeType!==3||(l=s+i),f.nodeType===3&&(s+=f.nodeValue.length),(m=f.firstChild)!==null;)p=f,f=m;for(;;){if(f===e)break b;if(p===n&&++u===a&&(c=s),p===o&&++d===i&&(l=s),(m=f.nextSibling)!==null)break;f=p,p=f.parentNode}f=m}n=c===-1||l===-1?null:{start:c,end:l}}else n=null}n||={start:0,end:0}}else n=null;for(Ti={focusedElem:e,selectionRange:n},xn=!1,q=t;q!==null;)if(t=q,e=t.child,t.subtreeFlags&1028&&e!==null)e.return=t,q=e;else for(;q!==null;){t=q;try{var h=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(h!==null){var g=h.memoizedProps,_=h.memoizedState,v=t.stateNode;v.__reactInternalSnapshotBeforeUpdate=v.getSnapshotBeforeUpdate(t.elementType===t.type?g:bs(t.type,g),_)}break;case 3:var y=t.stateNode.containerInfo;y.nodeType===1?y.textContent=``:y.nodeType===9&&y.documentElement&&y.removeChild(y.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(r(163))}}catch(e){$(t,t.return,e)}if(e=t.sibling,e!==null){e.return=t.return,q=e;break}q=t.return}return h=yc,yc=!1,h}function xc(e,t,n){var r=t.updateQueue;if(r=r===null?null:r.lastEffect,r!==null){var i=r=r.next;do{if((i.tag&e)===e){var a=i.destroy;i.destroy=void 0,a!==void 0&&vc(t,n,a)}i=i.next}while(i!==r)}}function Sc(e,t){if(t=t.updateQueue,t=t===null?null:t.lastEffect,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function Cc(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t==`function`?t(e):t.current=e}}function wc(e){var t=e.alternate;t!==null&&(e.alternate=null,wc(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Ii],delete t[Li],delete t[zi],delete t[Bi],delete t[Vi])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function Tc(e){return e.tag===5||e.tag===3||e.tag===4}function Ec(e){a:for(;;){for(;e.sibling===null;){if(e.return===null||Tc(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue a;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Dc(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=Ci));else if(r!==4&&(e=e.child,e!==null))for(Dc(e,t,n),e=e.sibling;e!==null;)Dc(e,t,n),e=e.sibling}function Oc(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(Oc(e,t,n),e=e.sibling;e!==null;)Oc(e,t,n),e=e.sibling}var J=null,kc=!1;function Ac(e,t,n){for(n=n.child;n!==null;)jc(e,t,n),n=n.sibling}function jc(e,t,n){if(Mt&&typeof Mt.onCommitFiberUnmount==`function`)try{Mt.onCommitFiberUnmount(jt,n)}catch{}switch(n.tag){case 5:hc||_c(n,t);case 6:var r=J,i=kc;J=null,Ac(e,t,n),J=r,kc=i,J!==null&&(kc?(e=J,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):J.removeChild(n.stateNode));break;case 18:J!==null&&(kc?(e=J,n=n.stateNode,e.nodeType===8?Mi(e.parentNode,n):e.nodeType===1&&Mi(e,n),bn(e)):Mi(J,n.stateNode));break;case 4:r=J,i=kc,J=n.stateNode.containerInfo,kc=!0,Ac(e,t,n),J=r,kc=i;break;case 0:case 11:case 14:case 15:if(!hc&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){i=r=r.next;do{var a=i,o=a.destroy;a=a.tag,o!==void 0&&(a&2||a&4)&&vc(n,t,o),i=i.next}while(i!==r)}Ac(e,t,n);break;case 1:if(!hc&&(_c(n,t),r=n.stateNode,typeof r.componentWillUnmount==`function`))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(e){$(n,t,e)}Ac(e,t,n);break;case 21:Ac(e,t,n);break;case 22:n.mode&1?(hc=(r=hc)||n.memoizedState!==null,Ac(e,t,n),hc=r):Ac(e,t,n);break;default:Ac(e,t,n)}}function Mc(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new gc),t.forEach(function(t){var r=Hl.bind(null,e,t);n.has(t)||(n.add(t),t.then(r,r))})}}function Nc(e,t){var n=t.deletions;if(n!==null)for(var i=0;i<n.length;i++){var a=n[i];try{var o=e,s=t,c=s;a:for(;c!==null;){switch(c.tag){case 5:J=c.stateNode,kc=!1;break a;case 3:J=c.stateNode.containerInfo,kc=!0;break a;case 4:J=c.stateNode.containerInfo,kc=!0;break a}c=c.return}if(J===null)throw Error(r(160));jc(o,s,a),J=null,kc=!1;var l=a.alternate;l!==null&&(l.return=null),a.return=null}catch(e){$(a,t,e)}}if(t.subtreeFlags&12854)for(t=t.child;t!==null;)Pc(t,e),t=t.sibling}function Pc(e,t){var n=e.alternate,i=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(Nc(t,e),Fc(e),i&4){try{xc(3,e,e.return),Sc(3,e)}catch(t){$(e,e.return,t)}try{xc(5,e,e.return)}catch(t){$(e,e.return,t)}}break;case 1:Nc(t,e),Fc(e),i&512&&n!==null&&_c(n,n.return);break;case 5:if(Nc(t,e),Fc(e),i&512&&n!==null&&_c(n,n.return),e.flags&32){var a=e.stateNode;try{Re(a,``)}catch(t){$(e,e.return,t)}}if(i&4&&(a=e.stateNode,a!=null)){var o=e.memoizedProps,s=n===null?o:n.memoizedProps,c=e.type,l=e.updateQueue;if(e.updateQueue=null,l!==null)try{c===`input`&&o.type===`radio`&&o.name!=null&&we(a,o),Ge(c,s);var u=Ge(c,o);for(s=0;s<l.length;s+=2){var d=l[s],f=l[s+1];d===`style`?He(a,f):d===`dangerouslySetInnerHTML`?Le(a,f):d===`children`?Re(a,f):S(a,d,f,u)}switch(c){case`input`:Te(a,o);break;case`textarea`:Me(a,o);break;case`select`:var p=a._wrapperState.wasMultiple;a._wrapperState.wasMultiple=!!o.multiple;var m=o.value;m==null?p!==!!o.multiple&&(o.defaultValue==null?ke(a,!!o.multiple,o.multiple?[]:``,!1):ke(a,!!o.multiple,o.defaultValue,!0)):ke(a,!!o.multiple,m,!1)}a[Li]=o}catch(t){$(e,e.return,t)}}break;case 6:if(Nc(t,e),Fc(e),i&4){if(e.stateNode===null)throw Error(r(162));a=e.stateNode,o=e.memoizedProps;try{a.nodeValue=o}catch(t){$(e,e.return,t)}}break;case 3:if(Nc(t,e),Fc(e),i&4&&n!==null&&n.memoizedState.isDehydrated)try{bn(t.containerInfo)}catch(t){$(e,e.return,t)}break;case 4:Nc(t,e),Fc(e);break;case 13:Nc(t,e),Fc(e),a=e.child,a.flags&8192&&(o=a.memoizedState!==null,a.stateNode.isHidden=o,!o||a.alternate!==null&&a.alternate.memoizedState!==null||(el=j())),i&4&&Mc(e);break;case 22:if(d=n!==null&&n.memoizedState!==null,e.mode&1?(hc=(u=hc)||d,Nc(t,e),hc=u):Nc(t,e),Fc(e),i&8192){if(u=e.memoizedState!==null,(e.stateNode.isHidden=u)&&!d&&e.mode&1)for(q=e,d=e.child;d!==null;){for(f=q=d;q!==null;){switch(p=q,m=p.child,p.tag){case 0:case 11:case 14:case 15:xc(4,p,p.return);break;case 1:_c(p,p.return);var h=p.stateNode;if(typeof h.componentWillUnmount==`function`){i=p,n=p.return;try{t=i,h.props=t.memoizedProps,h.state=t.memoizedState,h.componentWillUnmount()}catch(e){$(i,n,e)}}break;case 5:_c(p,p.return);break;case 22:if(p.memoizedState!==null){zc(f);continue}}m===null?zc(f):(m.return=p,q=m)}d=d.sibling}a:for(d=null,f=e;;){if(f.tag===5){if(d===null){d=f;try{a=f.stateNode,u?(o=a.style,typeof o.setProperty==`function`?o.setProperty(`display`,`none`,`important`):o.display=`none`):(c=f.stateNode,l=f.memoizedProps.style,s=l!=null&&l.hasOwnProperty(`display`)?l.display:null,c.style.display=Ve(`display`,s))}catch(t){$(e,e.return,t)}}}else if(f.tag===6){if(d===null)try{f.stateNode.nodeValue=u?``:f.memoizedProps}catch(t){$(e,e.return,t)}}else if((f.tag!==22&&f.tag!==23||f.memoizedState===null||f===e)&&f.child!==null){f.child.return=f,f=f.child;continue}if(f===e)break a;for(;f.sibling===null;){if(f.return===null||f.return===e)break a;d===f&&(d=null),f=f.return}d===f&&(d=null),f.sibling.return=f.return,f=f.sibling}}break;case 19:Nc(t,e),Fc(e),i&4&&Mc(e);break;case 21:break;default:Nc(t,e),Fc(e)}}function Fc(e){var t=e.flags;if(t&2){try{a:{for(var n=e.return;n!==null;){if(Tc(n)){var i=n;break a}n=n.return}throw Error(r(160))}switch(i.tag){case 5:var a=i.stateNode;i.flags&32&&(Re(a,``),i.flags&=-33),Oc(e,Ec(e),a);break;case 3:case 4:var o=i.stateNode.containerInfo;Dc(e,Ec(e),o);break;default:throw Error(r(161))}}catch(t){$(e,e.return,t)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function Ic(e,t,n){q=e,Lc(e,t,n)}function Lc(e,t,n){for(var r=!!(e.mode&1);q!==null;){var i=q,a=i.child;if(i.tag===22&&r){var o=i.memoizedState!==null||mc;if(!o){var s=i.alternate,c=s!==null&&s.memoizedState!==null||hc;s=mc;var l=hc;if(mc=o,(hc=c)&&!l)for(q=i;q!==null;)o=q,c=o.child,o.tag===22&&o.memoizedState!==null||c===null?Bc(i):(c.return=o,q=c);for(;a!==null;)q=a,Lc(a,t,n),a=a.sibling;q=i,mc=s,hc=l}Rc(e,t,n)}else i.subtreeFlags&8772&&a!==null?(a.return=i,q=a):Rc(e,t,n)}}function Rc(e){for(;q!==null;){var t=q;if(t.flags&8772){var n=t.alternate;try{if(t.flags&8772)switch(t.tag){case 0:case 11:case 15:hc||Sc(5,t);break;case 1:var i=t.stateNode;if(t.flags&4&&!hc){if(n===null)i.componentDidMount();else{var a=t.elementType===t.type?n.memoizedProps:bs(t.type,n.memoizedProps);i.componentDidUpdate(a,n.memoizedState,i.__reactInternalSnapshotBeforeUpdate)}}var o=t.updateQueue;o!==null&&fo(t,o,i);break;case 3:var s=t.updateQueue;if(s!==null){if(n=null,t.child!==null)switch(t.child.tag){case 5:n=t.child.stateNode;break;case 1:n=t.child.stateNode}fo(t,s,n)}break;case 5:var c=t.stateNode;if(n===null&&t.flags&4){n=c;var l=t.memoizedProps;switch(t.type){case`button`:case`input`:case`select`:case`textarea`:l.autoFocus&&n.focus();break;case`img`:l.src&&(n.src=l.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(t.memoizedState===null){var u=t.alternate;if(u!==null){var d=u.memoizedState;if(d!==null){var f=d.dehydrated;f!==null&&bn(f)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(r(163))}hc||t.flags&512&&Cc(t)}catch(e){$(t,t.return,e)}}if(t===e){q=null;break}if(n=t.sibling,n!==null){n.return=t.return,q=n;break}q=t.return}}function zc(e){for(;q!==null;){var t=q;if(t===e){q=null;break}var n=t.sibling;if(n!==null){n.return=t.return,q=n;break}q=t.return}}function Bc(e){for(;q!==null;){var t=q;try{switch(t.tag){case 0:case 11:case 15:var n=t.return;try{Sc(4,t)}catch(e){$(t,n,e)}break;case 1:var r=t.stateNode;if(typeof r.componentDidMount==`function`){var i=t.return;try{r.componentDidMount()}catch(e){$(t,i,e)}}var a=t.return;try{Cc(t)}catch(e){$(t,a,e)}break;case 5:var o=t.return;try{Cc(t)}catch(e){$(t,o,e)}}}catch(e){$(t,t.return,e)}if(t===e){q=null;break}var s=t.sibling;if(s!==null){s.return=t.return,q=s;break}q=t.return}}var Vc=Math.ceil,Hc=C.ReactCurrentDispatcher,Uc=C.ReactCurrentOwner,Wc=C.ReactCurrentBatchConfig,Y=0,X=null,Z=null,Gc=0,Kc=0,qc=Ji(0),Q=0,Jc=null,Yc=0,Xc=0,Zc=0,Qc=null,$c=null,el=0,tl=1/0,nl=null,rl=!1,il=null,al=null,ol=!1,sl=null,cl=0,ll=0,ul=null,dl=-1,fl=0;function pl(){return Y&6?j():dl===-1?dl=j():dl}function ml(e){return e.mode&1?Y&2&&Gc!==0?Gc&-Gc:La.transition===null?(e=M,e===0?(e=window.event,e=e===void 0?16:En(e.type),e):e):(fl===0&&(fl=Gt()),fl):1}function hl(e,t,n,i){if(50<ll)throw ll=0,ul=null,Error(r(185));qt(e,n,i),(!(Y&2)||e!==X)&&(e===X&&(!(Y&2)&&(Xc|=n),Q===4&&xl(e,Gc)),gl(e,i),n===1&&Y===0&&!(t.mode&1)&&(tl=j()+500,sa&&da()))}function gl(e,t){var n=e.callbackNode;Ut(e,t);var r=Vt(e,e===X?Gc:0);if(r===0)n!==null&&St(n),e.callbackNode=null,e.callbackPriority=0;else if(t=r&-r,e.callbackPriority!==t){if(n!=null&&St(n),t===1)e.tag===0?ua(Sl.bind(null,e)):la(Sl.bind(null,e)),Ai(function(){!(Y&6)&&da()}),n=null;else{switch(Xt(r)){case 1:n=Et;break;case 4:n=Dt;break;case 16:n=Ot;break;case 536870912:n=At;break;default:n=Ot}n=Wl(n,_l.bind(null,e))}e.callbackPriority=t,e.callbackNode=n}}function _l(e,t){if(dl=-1,fl=0,Y&6)throw Error(r(327));var n=e.callbackNode;if(Ll()&&e.callbackNode!==n)return null;var i=Vt(e,e===X?Gc:0);if(i===0)return null;if(i&30||(i&e.expiredLanes)!==0||t)t=Al(e,i);else{t=i;var a=Y;Y|=2;var o=Ol();(X!==e||Gc!==t)&&(nl=null,tl=j()+500,El(e,t));do try{Ml();break}catch(t){Dl(e,t)}while(1);Ja(),Hc.current=o,Y=a,Z===null?(X=null,Gc=0,t=Q):t=0}if(t!==0){if(t===2&&(a=Wt(e),a!==0&&(i=a,t=vl(e,a))),t===1)throw n=Jc,El(e,0),xl(e,i),gl(e,j()),n;if(t===6)xl(e,i);else{if(a=e.current.alternate,!(i&30)&&!bl(a)&&(t=Al(e,i),t===2&&(o=Wt(e),o!==0&&(i=o,t=vl(e,o))),t===1))throw n=Jc,El(e,0),xl(e,i),gl(e,j()),n;switch(e.finishedWork=a,e.finishedLanes=i,t){case 0:case 1:throw Error(r(345));case 2:Fl(e,$c,nl);break;case 3:if(xl(e,i),(i&130023424)===i&&(t=el+500-j(),10<t)){if(Vt(e,0)!==0)break;if(a=e.suspendedLanes,(a&i)!==i){pl(),e.pingedLanes|=e.suspendedLanes&a;break}e.timeoutHandle=Di(Fl.bind(null,e,$c,nl),t);break}Fl(e,$c,nl);break;case 4:if(xl(e,i),(i&4194240)===i)break;for(t=e.eventTimes,a=-1;0<i;){var s=31-Pt(i);o=1<<s,s=t[s],s>a&&(a=s),i&=~o}if(i=a,i=j()-i,i=(120>i?120:480>i?480:1080>i?1080:1920>i?1920:3e3>i?3e3:4320>i?4320:1960*Vc(i/1960))-i,10<i){e.timeoutHandle=Di(Fl.bind(null,e,$c,nl),i);break}Fl(e,$c,nl);break;case 5:Fl(e,$c,nl);break;default:throw Error(r(329))}}}return gl(e,j()),e.callbackNode===n?_l.bind(null,e):null}function vl(e,t){var n=Qc;return e.current.memoizedState.isDehydrated&&(El(e,t).flags|=256),e=Al(e,t),e!==2&&(t=$c,$c=n,t!==null&&yl(t)),e}function yl(e){$c===null?$c=e:$c.push.apply($c,e)}function bl(e){for(var t=e;;){if(t.flags&16384){var n=t.updateQueue;if(n!==null&&(n=n.stores,n!==null))for(var r=0;r<n.length;r++){var i=n[r],a=i.getSnapshot;i=i.value;try{if(!Mr(a(),i))return!1}catch{return!1}}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function xl(e,t){for(t&=~Zc,t&=~Xc,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var n=31-Pt(t),r=1<<n;e[n]=-1,t&=~r}}function Sl(e){if(Y&6)throw Error(r(327));Ll();var t=Vt(e,0);if(!(t&1))return gl(e,j()),null;var n=Al(e,t);if(e.tag!==0&&n===2){var i=Wt(e);i!==0&&(t=i,n=vl(e,i))}if(n===1)throw n=Jc,El(e,0),xl(e,t),gl(e,j()),n;if(n===6)throw Error(r(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,Fl(e,$c,nl),gl(e,j()),null}function Cl(e,t){var n=Y;Y|=1;try{return e(t)}finally{Y=n,Y===0&&(tl=j()+500,sa&&da())}}function wl(e){sl!==null&&sl.tag===0&&!(Y&6)&&Ll();var t=Y;Y|=1;var n=Wc.transition,r=M;try{if(Wc.transition=null,M=1,e)return e()}finally{M=r,Wc.transition=n,Y=t,!(Y&6)&&da()}}function Tl(){Kc=qc.current,B(qc)}function El(e,t){e.finishedWork=null,e.finishedLanes=0;var n=e.timeoutHandle;if(n!==-1&&(e.timeoutHandle=-1,Oi(n)),Z!==null)for(n=Z.return;n!==null;){var r=n;switch(wa(r),r.tag){case 1:r=r.type.childContextTypes,r!=null&&ta();break;case 3:yo(),B(Zi),B(Xi),wo();break;case 5:xo(r);break;case 4:yo();break;case 13:B(U);break;case 19:B(U);break;case 10:Ya(r.type._context);break;case 22:case 23:Tl()}n=n.return}if(X=e,Z=e=Yl(e.current,null),Gc=Kc=t,Q=0,Jc=null,Zc=Xc=Yc=0,$c=Qc=null,$a!==null){for(t=0;t<$a.length;t++)if(n=$a[t],r=n.interleaved,r!==null){n.interleaved=null;var i=r.next,a=n.pending;if(a!==null){var o=a.next;a.next=i,r.next=o}n.pending=r}$a=null}return e}function Dl(e,t){do{var n=Z;try{if(Ja(),To.current=gs,Oo){for(var i=W.memoizedState;i!==null;){var a=i.queue;a!==null&&(a.pending=null),i=i.next}Oo=!1}if(Do=0,K=G=W=null,ko=!1,Ao=0,Uc.current=null,n===null||n.return===null){Q=1,Jc=t,Z=null;break}a:{var o=e,s=n.return,c=n,l=t;if(t=Gc,c.flags|=32768,typeof l==`object`&&l&&typeof l.then==`function`){var u=l,d=c,f=d.tag;if(!(d.mode&1)&&(f===0||f===11||f===15)){var p=d.alternate;p?(d.updateQueue=p.updateQueue,d.memoizedState=p.memoizedState,d.lanes=p.lanes):(d.updateQueue=null,d.memoizedState=null)}var m=Ps(s);if(m!==null){m.flags&=-257,Fs(m,s,c,o,t),m.mode&1&&Ns(o,u,t),t=m,l=u;var h=t.updateQueue;if(h===null){var g=new Set;g.add(l),t.updateQueue=g}else h.add(l);break a}if(!(t&1)){Ns(o,u,t),kl();break a}l=Error(r(426))}else if(H&&c.mode&1){var _=Ps(s);if(_!==null){!(_.flags&65536)&&(_.flags|=256),Fs(_,s,c,o,t),Ia(Ds(l,c));break a}}o=l=Ds(l,c),Q!==4&&(Q=2),Qc===null?Qc=[o]:Qc.push(o),o=s;do{switch(o.tag){case 3:o.flags|=65536,t&=-t,o.lanes|=t;var v=js(o,l,t);lo(o,v);break a;case 1:c=l;var y=o.type,b=o.stateNode;if(!(o.flags&128)&&(typeof y.getDerivedStateFromError==`function`||b!==null&&typeof b.componentDidCatch==`function`&&(al===null||!al.has(b)))){o.flags|=65536,t&=-t,o.lanes|=t;var x=Ms(o,c,t);lo(o,x);break a}}o=o.return}while(o!==null)}Pl(n)}catch(e){t=e,Z===n&&n!==null&&(Z=n=n.return);continue}break}while(1)}function Ol(){var e=Hc.current;return Hc.current=gs,e===null?gs:e}function kl(){(Q===0||Q===3||Q===2)&&(Q=4),X===null||!(Yc&268435455)&&!(Xc&268435455)||xl(X,Gc)}function Al(e,t){var n=Y;Y|=2;var i=Ol();(X!==e||Gc!==t)&&(nl=null,El(e,t));do try{jl();break}catch(t){Dl(e,t)}while(1);if(Ja(),Y=n,Hc.current=i,Z!==null)throw Error(r(261));return X=null,Gc=0,Q}function jl(){for(;Z!==null;)Nl(Z)}function Ml(){for(;Z!==null&&!Ct();)Nl(Z)}function Nl(e){var t=Ul(e.alternate,e,Kc);e.memoizedProps=e.pendingProps,t===null?Pl(e):Z=t,Uc.current=null}function Pl(e){var t=e;do{var n=t.alternate;if(e=t.return,t.flags&32768){if(n=pc(n,t),n!==null){n.flags&=32767,Z=n;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{Q=6,Z=null;return}}else if(n=fc(n,t,Kc),n!==null){Z=n;return}if(t=t.sibling,t!==null){Z=t;return}Z=t=e}while(t!==null);Q===0&&(Q=5)}function Fl(e,t,n){var r=M,i=Wc.transition;try{Wc.transition=null,M=1,Il(e,t,n,r)}finally{Wc.transition=i,M=r}return null}function Il(e,t,n,i){do Ll();while(sl!==null);if(Y&6)throw Error(r(327));n=e.finishedWork;var a=e.finishedLanes;if(n===null)return null;if(e.finishedWork=null,e.finishedLanes=0,n===e.current)throw Error(r(177));e.callbackNode=null,e.callbackPriority=0;var o=n.lanes|n.childLanes;if(Jt(e,o),e===X&&(Z=X=null,Gc=0),!(n.subtreeFlags&2064)&&!(n.flags&2064)||ol||(ol=!0,Wl(Ot,function(){return Ll(),null})),o=!!(n.flags&15990),n.subtreeFlags&15990||o){o=Wc.transition,Wc.transition=null;var s=M;M=1;var c=Y;Y|=4,Uc.current=null,bc(e,n),Pc(n,e),zr(Ti),xn=!!wi,Ti=wi=null,e.current=n,Ic(n,e,a),wt(),Y=c,M=s,Wc.transition=o}else e.current=n;if(ol&&(ol=!1,sl=e,cl=a),o=e.pendingLanes,o===0&&(al=null),Nt(n.stateNode,i),gl(e,j()),t!==null)for(i=e.onRecoverableError,n=0;n<t.length;n++)a=t[n],i(a.value,{componentStack:a.stack,digest:a.digest});if(rl)throw rl=!1,e=il,il=null,e;return cl&1&&e.tag!==0&&Ll(),o=e.pendingLanes,o&1?e===ul?ll++:(ll=0,ul=e):ll=0,da(),null}function Ll(){if(sl!==null){var e=Xt(cl),t=Wc.transition,n=M;try{if(Wc.transition=null,M=16>e?16:e,sl===null)var i=!1;else{if(e=sl,sl=null,cl=0,Y&6)throw Error(r(331));var a=Y;for(Y|=4,q=e.current;q!==null;){var o=q,s=o.child;if(q.flags&16){var c=o.deletions;if(c!==null){for(var l=0;l<c.length;l++){var u=c[l];for(q=u;q!==null;){var d=q;switch(d.tag){case 0:case 11:case 15:xc(8,d,o)}var f=d.child;if(f!==null)f.return=d,q=f;else for(;q!==null;){d=q;var p=d.sibling,m=d.return;if(wc(d),d===u){q=null;break}if(p!==null){p.return=m,q=p;break}q=m}}}var h=o.alternate;if(h!==null){var g=h.child;if(g!==null){h.child=null;do{var _=g.sibling;g.sibling=null,g=_}while(g!==null)}}q=o}}if(o.subtreeFlags&2064&&s!==null)s.return=o,q=s;else b:for(;q!==null;){if(o=q,o.flags&2048)switch(o.tag){case 0:case 11:case 15:xc(9,o,o.return)}var v=o.sibling;if(v!==null){v.return=o.return,q=v;break b}q=o.return}}var y=e.current;for(q=y;q!==null;){s=q;var b=s.child;if(s.subtreeFlags&2064&&b!==null)b.return=s,q=b;else b:for(s=y;q!==null;){if(c=q,c.flags&2048)try{switch(c.tag){case 0:case 11:case 15:Sc(9,c)}}catch(e){$(c,c.return,e)}if(c===s){q=null;break b}var x=c.sibling;if(x!==null){x.return=c.return,q=x;break b}q=c.return}}if(Y=a,da(),Mt&&typeof Mt.onPostCommitFiberRoot==`function`)try{Mt.onPostCommitFiberRoot(jt,e)}catch{}i=!0}return i}finally{M=n,Wc.transition=t}}return!1}function Rl(e,t,n){t=Ds(n,t),t=js(e,t,1),e=so(e,t,1),t=pl(),e!==null&&(qt(e,1,t),gl(e,t))}function $(e,t,n){if(e.tag===3)Rl(e,e,n);else for(;t!==null;){if(t.tag===3){Rl(t,e,n);break}if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(al===null||!al.has(r))){e=Ds(n,e),e=Ms(t,e,1),t=so(t,e,1),e=pl(),t!==null&&(qt(t,1,e),gl(t,e));break}}t=t.return}}function zl(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),t=pl(),e.pingedLanes|=e.suspendedLanes&n,X===e&&(Gc&n)===n&&(Q===4||Q===3&&(Gc&130023424)===Gc&&500>j()-el?El(e,0):Zc|=n),gl(e,t)}function Bl(e,t){t===0&&(e.mode&1?(t=zt,zt<<=1,!(zt&130023424)&&(zt=4194304)):t=1);var n=pl();e=no(e,t),e!==null&&(qt(e,t,n),gl(e,n))}function Vl(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Bl(e,n)}function Hl(e,t){var n=0;switch(e.tag){case 13:var i=e.stateNode,a=e.memoizedState;a!==null&&(n=a.retryLane);break;case 19:i=e.stateNode;break;default:throw Error(r(314))}i!==null&&i.delete(t),Bl(e,n)}var Ul=function(e,t,n){if(e!==null){if(e.memoizedProps!==t.pendingProps||Zi.current)Ls=!0;else{if((e.lanes&n)===0&&!(t.flags&128))return Ls=!1,oc(e,t,n);Ls=!!(e.flags&131072)}}else Ls=!1,H&&t.flags&1048576&&Sa(t,ha,t.index);switch(t.lanes=0,t.tag){case 2:var i=t.type;ic(e,t),e=t.pendingProps;var a=$i(t,Xi.current);Za(t,n),a=Po(null,t,i,e,a,n);var o=Fo();return t.flags|=1,typeof a==`object`&&a&&typeof a.render==`function`&&a.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,ea(i)?(o=!0,ia(t)):o=!1,t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,io(t),a.updater=Ss,t.stateNode=a,a._reactInternals=t,Es(t,i,e,n),t=Ks(null,t,i,!0,o,n)):(t.tag=0,H&&o&&Ca(t),Rs(null,t,a,n),t=t.child),t;case 16:i=t.elementType;a:{switch(ic(e,t),e=t.pendingProps,a=i._init,i=a(i._payload),t.type=i,a=t.tag=Jl(i),e=bs(i,e),a){case 0:t=Ws(null,t,i,e,n);break a;case 1:t=Gs(null,t,i,e,n);break a;case 11:t=zs(null,t,i,e,n);break a;case 14:t=Bs(null,t,i,bs(i.type,e),n);break a}throw Error(r(306,i,``))}return t;case 0:return i=t.type,a=t.pendingProps,a=t.elementType===i?a:bs(i,a),Ws(e,t,i,a,n);case 1:return i=t.type,a=t.pendingProps,a=t.elementType===i?a:bs(i,a),Gs(e,t,i,a,n);case 3:a:{if(qs(t),e===null)throw Error(r(387));i=t.pendingProps,o=t.memoizedState,a=o.element,ao(e,t),uo(t,i,null,n);var s=t.memoizedState;if(i=s.element,o.isDehydrated){if(o={element:i,isDehydrated:!1,cache:s.cache,pendingSuspenseBoundaries:s.pendingSuspenseBoundaries,transitions:s.transitions},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){a=Ds(Error(r(423)),t),t=Js(e,t,i,n,a);break a}if(i!==a){a=Ds(Error(r(424)),t),t=Js(e,t,i,n,a);break a}for(Ea=Ni(t.stateNode.containerInfo.firstChild),Ta=t,H=!0,Da=null,n=Ua(t,null,i,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling}else{if(Fa(),i===a){t=ac(e,t,n);break a}Rs(e,t,i,n)}t=t.child}return t;case 5:return bo(t),e===null&&ja(t),i=t.type,a=t.pendingProps,o=e===null?null:e.memoizedProps,s=a.children,Ei(i,a)?s=null:o!==null&&Ei(i,o)&&(t.flags|=32),Us(e,t),Rs(e,t,s,n),t.child;case 6:return e===null&&ja(t),null;case 13:return Zs(e,t,n);case 4:return vo(t,t.stateNode.containerInfo),i=t.pendingProps,e===null?t.child=Ha(t,null,i,n):Rs(e,t,i,n),t.child;case 11:return i=t.type,a=t.pendingProps,a=t.elementType===i?a:bs(i,a),zs(e,t,i,a,n);case 7:return Rs(e,t,t.pendingProps,n),t.child;case 8:return Rs(e,t,t.pendingProps.children,n),t.child;case 12:return Rs(e,t,t.pendingProps.children,n),t.child;case 10:a:{if(i=t.type._context,a=t.pendingProps,o=t.memoizedProps,s=a.value,V(Wa,i._currentValue),i._currentValue=s,o!==null){if(Mr(o.value,s)){if(o.children===a.children&&!Zi.current){t=ac(e,t,n);break a}}else for(o=t.child,o!==null&&(o.return=t);o!==null;){var c=o.dependencies;if(c!==null){s=o.child;for(var l=c.firstContext;l!==null;){if(l.context===i){if(o.tag===1){l=oo(-1,n&-n),l.tag=2;var u=o.updateQueue;if(u!==null){u=u.shared;var d=u.pending;d===null?l.next=l:(l.next=d.next,d.next=l),u.pending=l}}o.lanes|=n,l=o.alternate,l!==null&&(l.lanes|=n),Xa(o.return,n,t),c.lanes|=n;break}l=l.next}}else if(o.tag===10)s=o.type===t.type?null:o.child;else if(o.tag===18){if(s=o.return,s===null)throw Error(r(341));s.lanes|=n,c=s.alternate,c!==null&&(c.lanes|=n),Xa(s,n,t),s=o.sibling}else s=o.child;if(s!==null)s.return=o;else for(s=o;s!==null;){if(s===t){s=null;break}if(o=s.sibling,o!==null){o.return=s.return,s=o;break}s=s.return}o=s}}Rs(e,t,a.children,n),t=t.child}return t;case 9:return a=t.type,i=t.pendingProps.children,Za(t,n),a=Qa(a),i=i(a),t.flags|=1,Rs(e,t,i,n),t.child;case 14:return i=t.type,a=bs(i,t.pendingProps),a=bs(i.type,a),Bs(e,t,i,a,n);case 15:return Vs(e,t,t.type,t.pendingProps,n);case 17:return i=t.type,a=t.pendingProps,a=t.elementType===i?a:bs(i,a),ic(e,t),t.tag=1,ea(i)?(e=!0,ia(t)):e=!1,Za(t,n),ws(t,i,a),Es(t,i,a,n),Ks(null,t,i,!0,e,n);case 19:return rc(e,t,n);case 22:return Hs(e,t,n)}throw Error(r(156,t.tag))};function Wl(e,t){return xt(e,t)}function Gl(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Kl(e,t,n,r){return new Gl(e,t,n,r)}function ql(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Jl(e){if(typeof e==`function`)return+!!ql(e);if(e!=null){if(e=e.$$typeof,e===ie)return 11;if(e===D)return 14}return 2}function Yl(e,t){var n=e.alternate;return n===null?(n=Kl(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function Xl(e,t,n,i,a,o){var s=2;if(i=e,typeof e==`function`)ql(e)&&(s=1);else if(typeof e==`string`)s=5;else a:switch(e){case ee:return Zl(n.children,a,o,t);case E:s=8,a|=8;break;case te:return e=Kl(12,n,t,a|2),e.elementType=te,e.lanes=o,e;case ae:return e=Kl(13,n,t,a),e.elementType=ae,e.lanes=o,e;case oe:return e=Kl(19,n,t,a),e.elementType=oe,e.lanes=o,e;case ce:return Ql(n,a,o,t);default:if(typeof e==`object`&&e)switch(e.$$typeof){case ne:s=10;break a;case re:s=9;break a;case ie:s=11;break a;case D:s=14;break a;case se:s=16,i=null;break a}throw Error(r(130,e==null?e:typeof e,``))}return t=Kl(s,n,t,a),t.elementType=e,t.type=i,t.lanes=o,t}function Zl(e,t,n,r){return e=Kl(7,e,r,t),e.lanes=n,e}function Ql(e,t,n,r){return e=Kl(22,e,r,t),e.elementType=ce,e.lanes=n,e.stateNode={isHidden:!1},e}function $l(e,t,n){return e=Kl(6,e,null,t),e.lanes=n,e}function eu(e,t,n){return t=Kl(4,e.children===null?[]:e.children,e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function tu(e,t,n,r,i){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Kt(0),this.expirationTimes=Kt(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Kt(0),this.identifierPrefix=r,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function nu(e,t,n,r,i,a,o,s,c){return e=new tu(e,t,n,s,c),t===1?(t=1,!0===a&&(t|=8)):t=0,a=Kl(3,null,null,t),e.current=a,a.stateNode=e,a.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},io(a),e}function ru(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:T,key:r==null?null:``+r,children:e,containerInfo:t,implementation:n}}function iu(e){if(!e)return Yi;e=e._reactInternals;a:{if(ht(e)!==e||e.tag!==1)throw Error(r(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break a;case 1:if(ea(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break a}}t=t.return}while(t!==null);throw Error(r(171))}if(e.tag===1){var n=e.type;if(ea(n))return ra(e,n,t)}return t}function au(e,t,n,r,i,a,o,s,c){return e=nu(n,r,!0,e,i,a,o,s,c),e.context=iu(null),n=e.current,r=pl(),i=ml(n),a=oo(r,i),a.callback=t??null,so(n,a,i),e.current.lanes=i,qt(e,i,r),gl(e,r),e}function ou(e,t,n,r){var i=t.current,a=pl(),o=ml(i);return n=iu(n),t.context===null?t.context=n:t.pendingContext=n,t=oo(a,o),t.payload={element:e},r=r===void 0?null:r,r!==null&&(t.callback=r),e=so(i,t,o),e!==null&&(hl(e,i,o,a),co(e,i,o)),o}function su(e){if(e=e.current,!e.child)return null;switch(e.child.tag){case 5:return e.child.stateNode;default:return e.child.stateNode}}function cu(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function lu(e,t){cu(e,t),(e=e.alternate)&&cu(e,t)}function uu(){return null}var du=typeof reportError==`function`?reportError:function(e){console.error(e)};function fu(e){this._internalRoot=e}pu.prototype.render=fu.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(r(409));ou(e,t,null,null)},pu.prototype.unmount=fu.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;wl(function(){ou(null,e,null,null)}),t[Ri]=null}};function pu(e){this._internalRoot=e}pu.prototype.unstable_scheduleHydration=function(e){if(e){var t=en();e={blockedOn:null,target:e,priority:t};for(var n=0;n<un.length&&t!==0&&t<un[n].priority;n++);un.splice(n,0,e),n===0&&hn(e)}};function mu(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function hu(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==` react-mount-point-unstable `))}function gu(){}function _u(e,t,n,r,i){if(i){if(typeof r==`function`){var a=r;r=function(){var e=su(o);a.call(e)}}var o=au(t,r,e,0,null,!1,!1,``,gu);return e._reactRootContainer=o,e[Ri]=o.current,fi(e.nodeType===8?e.parentNode:e),wl(),o}for(;i=e.lastChild;)e.removeChild(i);if(typeof r==`function`){var s=r;r=function(){var e=su(c);s.call(e)}}var c=nu(e,0,!1,null,null,!1,!1,``,gu);return e._reactRootContainer=c,e[Ri]=c.current,fi(e.nodeType===8?e.parentNode:e),wl(function(){ou(t,c,n,r)}),c}function vu(e,t,n,r,i){var a=n._reactRootContainer;if(a){var o=a;if(typeof i==`function`){var s=i;i=function(){var e=su(o);s.call(e)}}ou(t,o,e,i)}else o=_u(n,t,e,i,r);return su(o)}Zt=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var n=Bt(t.pendingLanes);n!==0&&(Yt(t,n|1),gl(t,j()),!(Y&6)&&(tl=j()+500,da()))}break;case 13:wl(function(){var t=no(e,1);t!==null&&hl(t,e,1,pl())}),lu(e,1)}},Qt=function(e){if(e.tag===13){var t=no(e,134217728);t!==null&&hl(t,e,134217728,pl()),lu(e,134217728)}},$t=function(e){if(e.tag===13){var t=ml(e),n=no(e,t);n!==null&&hl(n,e,t,pl()),lu(e,t)}},en=function(){return M},tn=function(e,t){var n=M;try{return M=e,t()}finally{M=n}},Je=function(e,t,n){switch(t){case`input`:if(Te(e,n),t=n.name,n.type===`radio`&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll(`input[name=`+JSON.stringify(``+t)+`][type="radio"]`),t=0;t<n.length;t++){var i=n[t];if(i!==e&&i.form===e.form){var a=Gi(i);if(!a)throw Error(r(90));be(i),Te(i,a)}}}break;case`textarea`:Me(e,n);break;case`select`:t=n.value,t!=null&&ke(e,!!n.multiple,t,!1)}},et=Cl,tt=wl;var yu={usingClientEntryPoint:!1,Events:[Ui,Wi,Gi,Qe,$e,Cl]},bu={findFiberByHostInstance:Hi,bundleType:0,version:`18.3.1`,rendererPackageName:`react-dom`},xu={bundleType:bu.bundleType,version:bu.version,rendererPackageName:bu.rendererPackageName,rendererConfig:bu.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:C.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=yt(e),e===null?null:e.stateNode},findFiberByHostInstance:bu.findFiberByHostInstance||uu,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:`18.3.1-next-f1338f8080-20240426`};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`){var Su=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Su.isDisabled&&Su.supportsFiber)try{jt=Su.inject(xu),Mt=Su}catch{}}e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=yu,e.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!mu(t))throw Error(r(200));return ru(e,t,null,n)},e.createRoot=function(e,t){if(!mu(e))throw Error(r(299));var n=!1,i=``,a=du;return t!=null&&(!0===t.unstable_strictMode&&(n=!0),t.identifierPrefix!==void 0&&(i=t.identifierPrefix),t.onRecoverableError!==void 0&&(a=t.onRecoverableError)),t=nu(e,1,!1,null,null,n,!1,i,a),e[Ri]=t.current,fi(e.nodeType===8?e.parentNode:e),new fu(t)},e.findDOMNode=function(e){if(e==null)return null;if(e.nodeType===1)return e;var t=e._reactInternals;if(t===void 0)throw typeof e.render==`function`?Error(r(188)):(e=Object.keys(e).join(`,`),Error(r(268,e)));return e=yt(t),e=e===null?null:e.stateNode,e},e.flushSync=function(e){return wl(e)},e.hydrate=function(e,t,n){if(!hu(t))throw Error(r(200));return vu(null,e,t,!0,n)},e.hydrateRoot=function(e,t,n){if(!mu(e))throw Error(r(405));var i=n!=null&&n.hydratedSources||null,a=!1,o=``,s=du;if(n!=null&&(!0===n.unstable_strictMode&&(a=!0),n.identifierPrefix!==void 0&&(o=n.identifierPrefix),n.onRecoverableError!==void 0&&(s=n.onRecoverableError)),t=au(t,null,e,1,n??null,a,!1,o,s),e[Ri]=t.current,fi(e),i)for(e=0;e<i.length;e++)n=i[e],a=n._getVersion,a=a(n._source),t.mutableSourceEagerHydrationData==null?t.mutableSourceEagerHydrationData=[n,a]:t.mutableSourceEagerHydrationData.push(n,a);return new pu(t)},e.render=function(e,t,n){if(!hu(t))throw Error(r(200));return vu(null,e,t,!1,n)},e.unmountComponentAtNode=function(e){if(!hu(e))throw Error(r(40));return e._reactRootContainer?(wl(function(){vu(null,null,e,!1,function(){e._reactRootContainer=null,e[Ri]=null})}),!0):!1},e.unstable_batchedUpdates=Cl,e.unstable_renderSubtreeIntoContainer=function(e,t,n,i){if(!hu(n))throw Error(r(200));if(e==null||e._reactInternals===void 0)throw Error(r(38));return vu(e,t,n,!1,i)},e.version=`18.3.1-next-f1338f8080-20240426`})),m=o(((e,t)=>{function n(){if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE==`function`)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=p()})),h=o((e=>{var t=m();e.createRoot=t.createRoot,e.hydrateRoot=t.hydrateRoot}))(),g=c(u(),1);function _(e,t){if(Object.is(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(let[n,r]of e)if(!Object.is(r,t.get(n)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!Object.is(e[r],t[r]))return!1;return!0}var{useRef:v}=g.default;function y(e){let t=v();return n=>{let r=e(n);return _(t.current,r)?t.current:t.current=r}}var b=8;function x(e,t){let[n,r]=(0,g.useState)(()=>{try{let e=localStorage.getItem(t);return e?JSON.parse(e):null}catch{return null}}),i=(0,g.useRef)(!1),a=(0,g.useCallback)(t=>{let n=e.current,r=n?.offsetWidth??0,i=n?.offsetHeight??0;return{right:Math.min(Math.max(b,t.right),Math.max(b,window.innerWidth-r-b)),bottom:Math.min(Math.max(b,t.bottom),Math.max(b,window.innerHeight-i-b))}},[e]);return(0,g.useEffect)(()=>{let e=()=>r(e=>e&&a(e));return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[a]),{anchor:n,start:(0,g.useCallback)(n=>{if(n.button!==0)return;let o=e.current;if(!o)return;let s=o.getBoundingClientRect(),c={x:n.clientX,y:n.clientY,right:window.innerWidth-s.right,bottom:window.innerHeight-s.bottom};i.current=!1;let l=e=>{let t=e.clientX-c.x,n=e.clientY-c.y;!i.current&&Math.hypot(t,n)<5||(i.current=!0,r(a({right:c.right-t,bottom:c.bottom-n})))},u=null,d=e=>{l(e),i.current&&(u=a({right:c.right-(e.clientX-c.x),bottom:c.bottom-(e.clientY-c.y)}))},f=()=>{if(window.removeEventListener(`pointermove`,d),window.removeEventListener(`pointerup`,f),window.removeEventListener(`pointercancel`,f),i.current&&u)try{localStorage.setItem(t,JSON.stringify(u))}catch{}};window.addEventListener(`pointermove`,d),window.addEventListener(`pointerup`,f),window.addEventListener(`pointercancel`,f)},[e,a,t]),onClickCapture:(0,g.useCallback)(e=>{i.current&&=(e.stopPropagation(),e.preventDefault(),!1)},[])}}var S=o((e=>{var t={"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`};function n(e){return t[e]}var r={"&":`&`,"<":`<`,">":`>`,""":`"`,"'":`'`};function i(e){if(e[1]===`#`){let t=e[2]===`x`?parseInt(e.slice(3),16):parseInt(e.slice(2),10);if(t===9||t===10||t===13||t>=32&&t<=55295||t>=57344&&t<=65533||t>=65536&&t<=1114111)return String.fromCodePoint(t);throw Error(`Illegal XML character 0x`+t.toString(16))}if(r[e])return r[e]||e;throw Error(`Illegal XML entity `+e)}function a(e){return e.replace(/["&'<>]/g,n)}function o(e){let t=``,n=-1,r=-1,a=0;for(;(n=e.indexOf(`&`,a))!==-1&&(r=e.indexOf(`;`,n+1))!==-1;)t=t+e.slice(a,n)+i(e.slice(n,r+1)),a=r+1;return a===0?e:(t+=e.substring(a),t)}function s(e){return e.replace(/[&<>]/g,n)}function c(e){return e.replace(/&(amp|#38|lt|#60|gt|#62);/g,i)}e.escapeXML=a,e.escapeXMLText=s,e.unescapeXML=o,e.unescapeXMLText=c})),C=o(((e,t)=>{var n=S(),r=class e{constructor(e,t){this.name=e,this.parent=null,this.children=[],this.attrs={},this.setAttrs(t)}is(e,t){return this.getName()===e&&(!t||this.getNS()===t)}getName(){let e=this.name.indexOf(`:`);return e>=0?this.name.slice(e+1):this.name}getNS(){let e=this.name.indexOf(`:`);if(e>=0){let t=this.name.slice(0,e);return this.findNS(t)}return this.findNS()}findNS(e){if(e){let t=`xmlns:`+e;if(this.attrs[t])return this.attrs[t];if(this.parent)return this.parent.findNS(e)}else{if(this.attrs.xmlns)return this.attrs.xmlns;if(this.parent)return this.parent.findNS()}}getXmlns(){let e={};this.parent&&(e=this.parent.getXmlns());for(let t in this.attrs){let n=t.match(`xmlns:?(.*)`);this.attrs.hasOwnProperty(t)&&n&&(e[this.attrs[t]]=n[1])}return e}setAttrs(e){typeof e==`string`?this.attrs.xmlns=e:e&&Object.assign(this.attrs,e)}getAttr(e,t){if(!t)return this.attrs[e];let n=this.getXmlns();return n[t]?this.attrs[[n[t],e].join(`:`)]:null}getChild(e,t){return this.getChildren(e,t)[0]}getChildren(e,t){let n=[];for(let r of this.children)r.getName&&r.getName()===e&&(!t||r.getNS()===t)&&n.push(r);return n}getChildByAttr(e,t,n,r){return this.getChildrenByAttr(e,t,n,r)[0]}getChildrenByAttr(e,t,n,r){let i=[];for(let a of this.children)a.attrs&&a.attrs[e]===t&&(!n||a.getNS()===n)&&i.push(a),r&&a.getChildrenByAttr&&i.push(a.getChildrenByAttr(e,t,n,!0));return r&&(i=i.flat()),i}getChildrenByFilter(e,t){let n=[];for(let r of this.children)e(r)&&n.push(r),t&&r.getChildrenByFilter&&n.push(r.getChildrenByFilter(e,!0));return t&&(n=n.flat()),n}getText(){let e=``;for(let t of this.children)(typeof t==`string`||typeof t==`number`)&&(e+=t);return e}getChildText(e,t){let n=this.getChild(e,t);return n?n.getText():null}getChildElements(){return this.getChildrenByFilter(t=>t instanceof e)}root(){return this.parent?this.parent.root():this}up(){return this.parent?this.parent:this}c(t,n){return this.cnode(new e(t,n))}cnode(e){return this.children.push(e),typeof e==`object`&&(e.parent=this),e}append(...e){for(let t of e)this.children.push(t),typeof t==`object`&&(t.parent=this)}prepend(...e){for(let t of e)this.children.unshift(t),typeof t==`object`&&(t.parent=this)}t(e){return this.children.push(e),this}remove(e,t){let n=typeof e==`string`?n=>!(n.is&&n.is(e,t)):t=>t!==e;return this.children=this.children.filter(n),this}text(e){return e&&this.children.length===1?(this.children[0]=e,this):this.getText()}attr(e,t){return t!==void 0||t===null?(this.attrs||={},this.attrs[e]=t,this):this.attrs[e]}toString(){let e=``;return this.write(t=>{e+=t}),e}_addChildren(e){e(`>`);for(let t of this.children)t!=null&&(t.write?t.write(e):typeof t==`string`?e(n.escapeXMLText(t)):t.toString&&e(n.escapeXMLText(t.toString(10))));e(`</`),e(this.name),e(`>`)}write(e){e(`<`),e(this.name);for(let t in this.attrs){let r=this.attrs[t];r!=null&&(e(` `),e(t),e(`="`),e(n.escapeXML(typeof r==`string`?r:r.toString(10))),e(`"`))}this.children.length===0?e(`/>`):this._addChildren(e)}};r.prototype.tree=r.prototype.root,t.exports=r})),w=o(((e,t)=>{var n=C();function r(e,t){if(Array.isArray(t)){for(let n of t)r(e,n);return}t!==``&&t!=null&&t!==!0&&t!==!1&&e.cnode(t)}function i(e,t,...i){if(typeof t==`object`&&t){delete t.__source,delete t.__self;for(let[e,n]of Object.entries(t))n==null?delete t[e]:t[e]=n.toString(10)}let a=new n(e,t);for(let e of i)r(a,e);return a}t.exports=i})),T=o(((e,t)=>{var n=typeof Reflect==`object`?Reflect:null,r=n&&typeof n.apply==`function`?n.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)},i=n&&typeof n.ownKeys==`function`?n.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};function a(e){console&&console.warn&&console.warn(e)}var o=Number.isNaN||function(e){return e!==e};function s(){s.init.call(this)}t.exports=s,t.exports.once=y,s.EventEmitter=s,s.prototype._events=void 0,s.prototype._eventsCount=0,s.prototype._maxListeners=void 0;var c=10;function l(e){if(typeof e!=`function`)throw TypeError(`The "listener" argument must be of type Function. Received type `+typeof e)}Object.defineProperty(s,"defaultMaxListeners",{enumerable:!0,get:function(){return c},set:function(e){if(typeof e!=`number`||e<0||o(e))throw RangeError(`The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received `+e+`.`);c=e}}),s.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},s.prototype.setMaxListeners=function(e){if(typeof e!=`number`||e<0||o(e))throw RangeError(`The value of "n" is out of range. It must be a non-negative number. Received `+e+`.`);return this._maxListeners=e,this};function u(e){return e._maxListeners===void 0?s.defaultMaxListeners:e._maxListeners}s.prototype.getMaxListeners=function(){return u(this)},s.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t.push(arguments[n]);var i=e===`error`,a=this._events;if(a!==void 0)i&&=a.error===void 0;else if(!i)return!1;if(i){var o;if(t.length>0&&(o=t[0]),o instanceof Error)throw o;var s=Error(`Unhandled error.`+(o?` (`+o.message+`)`:``));throw s.context=o,s}var c=a[e];if(c===void 0)return!1;if(typeof c==`function`)r(c,this,t);else for(var l=c.length,u=g(c,l),n=0;n<l;++n)r(u[n],this,t);return!0};function d(e,t,n,r){var i,o,s;if(l(n),o=e._events,o===void 0?(o=e._events=Object.create(null),e._eventsCount=0):(o.newListener!==void 0&&(e.emit(`newListener`,t,n.listener?n.listener:n),o=e._events),s=o[t]),s===void 0)s=o[t]=n,++e._eventsCount;else if(typeof s==`function`?s=o[t]=r?[n,s]:[s,n]:r?s.unshift(n):s.push(n),i=u(e),i>0&&s.length>i&&!s.warned){s.warned=!0;var c=Error(`Possible EventEmitter memory leak detected. `+s.length+` `+String(t)+` listeners added. Use emitter.setMaxListeners() to increase limit`);c.name=`MaxListenersExceededWarning`,c.emitter=e,c.type=t,c.count=s.length,a(c)}return e}s.prototype.addListener=function(e,t){return d(this,e,t,!1)},s.prototype.on=s.prototype.addListener,s.prototype.prependListener=function(e,t){return d(this,e,t,!0)};function f(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function p(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},i=f.bind(r);return i.listener=n,r.wrapFn=i,i}s.prototype.once=function(e,t){return l(t),this.on(e,p(this,e,t)),this},s.prototype.prependOnceListener=function(e,t){return l(t),this.prependListener(e,p(this,e,t)),this},s.prototype.removeListener=function(e,t){var n,r,i,a,o;if(l(t),r=this._events,r===void 0||(n=r[e],n===void 0))return this;if(n===t||n.listener===t)--this._eventsCount===0?this._events=Object.create(null):(delete r[e],r.removeListener&&this.emit(`removeListener`,e,n.listener||t));else if(typeof n!=`function`){for(i=-1,a=n.length-1;a>=0;a--)if(n[a]===t||n[a].listener===t){o=n[a].listener,i=a;break}if(i<0)return this;i===0?n.shift():_(n,i),n.length===1&&(r[e]=n[0]),r.removeListener!==void 0&&this.emit(`removeListener`,e,o||t)}return this},s.prototype.off=s.prototype.removeListener,s.prototype.removeAllListeners=function(e){var t,n=this._events,r;if(n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[e]),this;if(arguments.length===0){var i=Object.keys(n),a;for(r=0;r<i.length;++r)a=i[r],a!==`removeListener`&&this.removeAllListeners(a);return this.removeAllListeners(`removeListener`),this._events=Object.create(null),this._eventsCount=0,this}if(t=n[e],typeof t==`function`)this.removeListener(e,t);else if(t!==void 0)for(r=t.length-1;r>=0;r--)this.removeListener(e,t[r]);return this};function m(e,t,n){var r=e._events;if(r===void 0)return[];var i=r[t];return i===void 0?[]:typeof i==`function`?n?[i.listener||i]:[i]:n?v(i):g(i,i.length)}s.prototype.listeners=function(e){return m(this,e,!0)},s.prototype.rawListeners=function(e){return m(this,e,!1)},s.listenerCount=function(e,t){return typeof e.listenerCount==`function`?e.listenerCount(t):h.call(e,t)},s.prototype.listenerCount=h;function h(e){var t=this._events;if(t!==void 0){var n=t[e];if(typeof n==`function`)return 1;if(n!==void 0)return n.length}return 0}s.prototype.eventNames=function(){return this._eventsCount>0?i(this._events):[]};function g(e,t){for(var n=Array(t),r=0;r<t;++r)n[r]=e[r];return n}function _(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}function v(e){for(var t=Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}function y(e,t){return new Promise(function(n,r){function i(n){e.removeListener(t,a),r(n)}function a(){typeof e.removeListener==`function`&&e.removeListener(`error`,i),n([].slice.call(arguments))}x(e,t,a,{once:!0}),t!==`error`&&b(e,i,{once:!0})})}function b(e,t,n){typeof e.on==`function`&&x(e,`error`,t,n)}function x(e,t,n,r){if(typeof e.on==`function`)r.once?e.once(t,n):e.on(t,n);else if(typeof e.addEventListener==`function`)e.addEventListener(t,function i(a){r.once&&e.removeEventListener(t,i),n(a)});else throw TypeError(`The "emitter" argument must be of type EventEmitter. Received type `+typeof e)}})),ee=o(((e,t)=>{var n=T(),r=S(),i=0,a=1,o=2,s=3,c=4,l=5,u=6,d=7,f=8,p=9,m=10;t.exports=class extends n.EventEmitter{constructor(){super();let e=i,t,n,h,g,_,v,y,b,x=0,S;this._handleTagOpening=function(e,t,n){e?this.emit(`endElement`,t,!1):(this.emit(`startElement`,t,n),v&&this.emit(`endElement`,t,!0))},this.write=function(C){typeof C!=`string`&&(C=C.toString());let w=0;t&&=(C=t+C,w+=n?0:t.length,n=!1,null);function T(){if(typeof x==`number`){let e=C.slice(x,w);return x=void 0,e}}for(;w<C.length;w++){switch(e){case i:{let e=C.indexOf(`<`,w);e!==-1&&w!==e&&(w=e);break}case f:{let e=C.indexOf(b,w);e!==-1&&(w=e);break}case a:{let e=C.indexOf(`-->`,w);e!==-1&&(w=e+2);break}case m:{let e=C.indexOf(`]]>`,w);e!==-1&&(w=e+2);break}}let t=C.charCodeAt(w);switch(e){case i:if(t===60){let t=T();t&&this.emit(`text`,r.unescapeXML(t)),e=s,x=w+1,g={}}break;case p:if(t===93){if(C.substr(w+1,2)===`]>`){let t=T();t&&this.emit(`text`,t),e=i}else C.length<w+2&&(n=!0,w=C.length)}break;case s:t===47&&x===w?(x=w+1,_=!0):t===33?C.substr(w+1,7)===`[CDATA[`?(x=w+8,e=p):C.length<w+8&&`[CDATA[`.startsWith(C.slice(w+1))?(n=!0,w=C.length):(x=void 0,e=a):t===63?(x=void 0,e=o):(t<=32||t===47||t===62)&&(h=T(),w--,e=c);break;case a:if(t===62){let t=C.charCodeAt(w-1),n=C.charCodeAt(w-2);(t===45&&n===45||t===93&&n===93)&&(e=i)}break;case o:t===62&&C.charCodeAt(w-1)===63&&(e=i);break;case c:t===62?(this._handleTagOpening(_,h,g),h=void 0,g=void 0,_=void 0,v=void 0,e=i,x=w+1):t===47?v=!0:t>32&&(x=w,e=l);break;case l:(t<=32||t===61)&&(S=T(),w--,e=u);break;case u:t===61&&(e=d);break;case d:(t===34||t===39)&&(y=t,b=t===34?`"`:`'`,e=f,x=w+1);break;case f:if(t===y){let t=r.unescapeXML(T());g[S]=t,S=void 0,e=c}}}typeof x==`number`&&x<=C.length&&(t=C.slice(x),x=0)}}end(e){e&&this.write(e),this.write=function(){}}}})),E=S(),te=c(C(),1),ne=c(w(),1),re=T(),ie=c(ee(),1),ae=class extends Error{constructor(e){super(e),this.name=`TimeoutError`}};function oe(e){let t,n=new Promise(n=>{t=setTimeout(n,e)});return n.timeout=t,n}function D(e,t){let n=oe(t);function r(){clearTimeout(n.timeout)}let i=new ae;return Promise.race([e.finally(r),n.then(()=>{throw i})])}var se=new WeakMap;function ce(e){let t=se.get(e);return t||(t={on:(e.addEventListener??e.addListener).bind(e),off:(e.removeEventListener??e.removeListener).bind(e),once:(e.once??((t,n)=>e.addEventListener(t,n,{once:!0}))).bind(e)},se.set(e,t)),t}function le(e,t,n=`error`,r){return new Promise((i,a)=>{let o,{off:s,once:c}=ce(e),l=()=>{clearTimeout(o),s(t,d),s(n,u)};function u(e){a(e),l()}function d(e){i(e),l()}if(c(t,d),n&&c(n,u),r){let e=new ae;o=setTimeout(()=>{l(),a(e)},r)}})}function ue(){this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}function O(e,t=null,n){return new Promise((r,i)=>{function a(t){e.removeListener(`nonza`,s),i(t)}function o(...t){e.removeListener(`nonza`,s),r(...t)}async function s(e){try{await n(e,o)}catch(e){a(e)}}t&&e.send(t).catch(a),e.on(`nonza`,s)})}function de(e){return{subscribe(t){let{on:n}=ce(t);for(let[t,r]of Object.entries(e))n(t,r)},unsubscribe(t){let{off:n}=ce(t);for(let[t,r]of Object.entries(e))n(t,r)}}}var fe=class extends Error{constructor(...e){super(...e),this.name=`XMLError`}},pe=class extends re.EventEmitter{constructor(){super();let e=new ie.default;this.root=null,this.cursor=null,e.on(`startElement`,this.onStartElement.bind(this)),e.on(`endElement`,this.onEndElement.bind(this)),e.on(`text`,this.onText.bind(this)),this.parser=e}onStartElement(e,t){let n=new te.default(e,t),{root:r,cursor:i}=this;r?i!==r&&i.append(n):(this.root=n,this.emit(`start`,n)),this.cursor=n}onEndElement(e){let{root:t,cursor:n}=this;if(e!==n.name){this.emit(`error`,new fe(`${n.name} must be closed.`));return}if(n===t){this.emit(`end`,t);return}if(!n.parent){n.parent=t,this.emit(`element`,n),this.cursor=t;return}this.cursor=n.parent}onText(e){let{cursor:t}=this;if(!t){this.emit(`error`,new fe(`${e} must be a child.`));return}t.t(e)}write(e){this.parser.write(e)}end(e){e&&this.parser.write(e)}};pe.XMLError=fe;function k(...e){return(0,ne.default)(...e)}Object.assign(k,{Element:te.default,createElement:ne.default,Parser:pe,escapeXML:E.escapeXML,unescapeXML:E.unescapeXML,escapeXMLText:E.escapeXMLText,unescapeXMLText:E.unescapeXMLText,XMLError:fe,xml:k});function me(e){return!(!e||e.replaceAll(String.raw`\20`,``).replaceAll(String.raw`\22`,``).replaceAll(String.raw`\26`,``).replaceAll(String.raw`\27`,``).replaceAll(String.raw`\2f`,``).replaceAll(String.raw`\3a`,``).replaceAll(String.raw`\3c`,``).replaceAll(String.raw`\3e`,``).replaceAll(String.raw`\40`,``).replaceAll(String.raw`\5c`,``).search(/[ "&'/:<>@\\]/g)===-1)}function he(e){return e===null?null:e.replaceAll(/^\s+|\s+$/g,``).replaceAll(`\\`,String.raw`\5c`).replaceAll(` `,String.raw`\20`).replaceAll(`"`,String.raw`\22`).replaceAll(`&`,String.raw`\26`).replaceAll(`'`,String.raw`\27`).replaceAll(`/`,String.raw`\2f`).replaceAll(`:`,String.raw`\3a`).replaceAll(`<`,String.raw`\3c`).replaceAll(`>`,String.raw`\3e`).replaceAll(`@`,String.raw`\40`)}function ge(e){return e===null?null:e.replaceAll(String.raw`\20`,` `).replaceAll(String.raw`\22`,`"`).replaceAll(String.raw`\26`,`&`).replaceAll(String.raw`\27`,`'`).replaceAll(String.raw`\2f`,`/`).replaceAll(String.raw`\3a`,`:`).replaceAll(String.raw`\3c`,`<`).replaceAll(String.raw`\3e`,`>`).replaceAll(String.raw`\40`,`@`).replaceAll(String.raw`\5c`,`\\`)}var A=class e{constructor(e,t,n){if(typeof t!=`string`||!t)throw TypeError(`Invalid domain.`);this.setDomain(t),this.setLocal(typeof e==`string`?e:``),this.setResource(typeof n==`string`?n:``)}[Symbol.toPrimitive](e){return e===`number`?NaN:this.toString()}toString(e){let t=this._domain;return this._local&&(t=this.getLocal(e)+`@`+t),this._resource&&(t=t+`/`+this._resource),t}bare(){return this._resource?new e(this._local,this._domain,null):this}equals(e){return this._local===e._local&&this._domain===e._domain&&this._resource===e._resource}setLocal(e,t){return t||=me(e),t&&(e=he(e)),this._local=e&&e.toLowerCase(),this}getLocal(e=!1){let t=null;return t=e?ge(this._local):this._local,t}setDomain(e){return this._domain=e.toLowerCase(),this}getDomain(){return this._domain}setResource(e){return this._resource=e,this}getResource(){return this._resource}};Object.defineProperty(A.prototype,"local",{get:A.prototype.getLocal,set:A.prototype.setLocal}),Object.defineProperty(A.prototype,"domain",{get:A.prototype.getDomain,set:A.prototype.setDomain}),Object.defineProperty(A.prototype,"resource",{get:A.prototype.getResource,set:A.prototype.setResource});function _e(e){let t,n,r=e.indexOf(`/`);r!==-1&&(n=e.slice(r+1),e=e.slice(0,r));let i=e.indexOf(`@`);return i!==-1&&(t=e.slice(0,i),e=e.slice(i+1)),new A(t,e,n)}function ve(e,t){return e.equals(t)}function ye(...e){return!e[1]&&!e[2]?_e(...e):new A(...e)}var be=ye.bind();be.jid=ye,be.JID=A,be.parse=_e,be.equal=ve,be.detectEscape=me,be.escapeLocal=he,be.unescapeLocal=ge;var xe=class extends Error{constructor(e,t,n){super(e+(t?` - ${t}`:``)),this.name=`XMPPError`,this.condition=e,this.text=t,this.application=n}static fromElement(e){let[t,n,r]=e.getChildElements(),i,a;n&&(n.is(`text`)?i=n:n&&(a=n),r&&(a=r));let o=new this(t.name,i?i.text():``,a);return o.element=e,o}},Se=class extends xe{constructor(...e){super(...e),this.name=`StreamError`}};function Ce(e){let{port:t,hostname:n,protocol:r}=new URL(e);return n===`[::1]`&&(n=`::1`),{port:t,hostname:n,protocol:r}}function we(e){let{port:t,hostname:n}=Ce(`http://${e}`);return{port:t,hostname:n}}function Te(e){return e.includes(`://`)?Ce(e):we(e)}var Ee=`urn:ietf:params:xml:ns:xmpp-streams`,De=`http://etherx.jabber.org/streams`,Oe=class extends re.EventEmitter{#e=null;#t=null;constructor(e={}){super(),typeof e==`string`&&(e={domain:e}),this.jid=null,this.timeout=e.timeout||2e3,this.options=e,this.status=`offline`,this.socket=null,this.parser=null,this.root=null}isSecure(){return this.socket?.secure===!0}async _streamError(e,t){try{await this.send(k(`stream:error`,{},[k(e,{xmlns:Ee},t)]))}catch{}return this.disconnect()}_onData(e){let t=e.toString(`utf8`);this.parser.write(t)}#n(e){this._streamError(`bad-format`),this._detachParser(),this.emit(`error`,e)}#r(e,t){this._detachSocket(),this._status(`disconnect`,{clean:!e,reason:t})}#i(e,t){this._detachParser(),this._status(`close`,{clean:!e,reason:t})}_attachSocket(e){this.socket=e,this.#e??=de({data:this._onData.bind(this),close:this.#r.bind(this),connect:()=>this._status(`connect`),error:e=>this.emit(`error`,e)}),this.#e.subscribe(this.socket)}_detachSocket(){this.socket&&this.#e?.unsubscribe(this.socket),this.socket=null}_onElement(e){let t=e.is(`error`,De);t&&this._onStreamError(e),this.emit(`element`,e),this.emit(this.isStanza(e)?`stanza`:`nonza`,e),t&&this.disconnect()}_onStreamError(e){let t=Se.fromElement(e);if(t.condition===`see-other-host`)return this._onSeeOtherHost(t);this.emit(`error`,t)}async _onSeeOtherHost(e){let{protocol:t}=Te(this.options.service),n=e.element.getChildText(`see-other-host`),{port:r}=we(n),i;i=r?`${t||`xmpp:`}//${n}`:(t?`${t}//`:``)+n;try{await le(this,`disconnect`);let{domain:e,lang:t}=this.options;await this.connect(i),await this.open({domain:e,lang:t})}catch(e){this.emit(`error`,e)}}_attachParser(e){this.parser=e,this.#t??=de({element:this._onElement.bind(this),error:this.#n.bind(this),end:this.#i.bind(this),start:e=>this._status(`open`,e)}),this.#t.subscribe(this.parser)}_detachParser(){this.parser&&this.#t?.unsubscribe(this.parser),this.parser=null,this.root=null}_jid(e){return this.jid=be(e),this.jid}_status(e,...t){this.status!==e&&(this.status=e,this.emit(`status`,e,...t),this.emit(e,...t))}_ready(e=!1){e?this.status=`online`:this._status(`online`,this.jid)}async disconnect(){let e;try{e=await this._closeStream()}catch(e){this.#i(e)}try{await this._closeSocket()}catch(e){this.#r(!0,e)}return e}async start(){if(this.status!==`offline`)throw Error(`Connection is not offline`);let{service:e,domain:t,lang:n}=this.options;await this.connect(e);let r=le(this,`online`);return await this.open({domain:t,lang:n}),r}async connect(e){this._status(`connecting`,e);let t=new this.Socket;return this._attachSocket(t),t.connect(this.socketParameters(e)),le(t,`connect`)}async _closeSocket(e=this.timeout){this._status(`disconnecting`),this.socket.end(),await le(this.socket,`close`,`error`,e)}async open(e){this._status(`opening`);let{domain:t,lang:n}=e,r=this.headerElement();return r.attrs.to=t,r.attrs[`xml:lang`]=n,this.root=r,this._attachParser(new this.Parser),await this.write(this.header(r)),le(this,`open`,`error`,this.timeout)}async stop(){let e=await this.disconnect();return this._status(`offline`,e),e}async _closeStream(e=this.timeout){await this.#c(`close`);let t=this.footer(this.footerElement());return await this.write(t),this._status(`closing`),le(this.parser,`end`,`error`,e)}async restart(){this._detachParser();let{domain:e,lang:t}=this.options;return this.open({domain:e,lang:t})}async send(e){e.parent=this.root,await this.write(e.toString()),this.emit(`send`,e)}sendReceive(e,t=this.timeout){return Promise.all([this.send(e),le(this,`element`,`error`,t)]).then(([,e])=>e)}async write(e){if(this.status===`closing`)throw Error(`Connection is closing`);return new Promise((t,n)=>{this.socket.write(e,e=>e?n(e):t())})}isStanza(e){let{name:t}=e;return t===`iq`||t===`message`||t===`presence`}isNonza(e){return!this.isStanza(e)}header(e){return e.toString()}headerElement(){return new k.Element(``,{version:`1.0`,xmlns:this.NS})}footer(e){return e.toString()}footerElement(){}socketParameters(){}#a=new Map;#o=new Set([`close`]);hook(e,t){this.#s(e),this.#a.has(e)||this.#a.set(e,new Set),this.#a.get(e).add([t])}#s(e){if(!this.#o.has(e))throw Error(`Hook event name "${e}" is unknown.`)}unhook(e,t){this.#s(e);let n=this.#a.get(`event`),r=[...n].find(e=>e.handler===t);n.remove(r)}async#c(e,...t){this.#s(e);let n=this.#a.get(e);n&&await Promise.all([...n].map(async([e])=>{try{await e(...t)}catch(e){this.emit(`error`,e)}}))}};Oe.prototype.NS=``,Oe.prototype.Socket=null,Oe.prototype.Parser=null;var ke=class extends Oe{constructor(e){super(e),this.transports=[]}send(e,...t){return this.Transport.prototype.send.call(this,e,...t)}sendMany(...e){return this.Transport.prototype.sendMany.call(this,...e)}_findTransport(e){return this.transports.find(t=>{try{return t.prototype.socketParameters(e)!==void 0}catch{return!1}})}connect(e){let t=this._findTransport(e);if(!t)throw Error(`No compatible connection method found.`);return this.Transport=t,this.Socket=t.prototype.Socket,this.Parser=t.prototype.Parser,super.connect(e)}socketParameters(...e){return this.Transport.prototype.socketParameters(...e)}header(e,...t){let n=this.isSecure()&&this.jid?.bare().toString();return n&&(e.attrs.from=n),this.Transport.prototype.header(e,...t)}headerElement(...e){return this.Transport.prototype.headerElement(...e)}footer(...e){return this.Transport.prototype.footer(...e)}footerElement(...e){return this.Transport.prototype.footerElement(...e)}};ke.prototype.NS=`jabber:client`;var Ae=class extends re.EventEmitter{constructor(e){super(),this.delay=1e3,this.entity=e,this._timeout=null}#e=()=>{this.scheduleReconnect()};scheduleReconnect(){let{entity:e,delay:t,_timeout:n}=this;clearTimeout(n),this._timeout=setTimeout(async()=>{if(e.status===`disconnect`)try{await this.reconnect()}catch{}},t)}async reconnect(){let{entity:e}=this;this.emit(`reconnecting`);let{service:t,domain:n,lang:r}=e.options;await e.connect(t),await e.open({domain:n,lang:r}),this.emit(`reconnected`)}start(){let{entity:e}=this;e.on(`disconnect`,this.#e)}stop(){let{entity:e,_timeout:t}=this;e.removeListener(`disconnect`,this.#e),clearTimeout(t)}};function je({entity:e}){let t=new Ae(e);return t.start(),t}var Me=`ECONNERROR`;function Ne(e){let t=Ce(e);return!!(t.protocol===`wss:`||[`localhost`,`127.0.0.1`,`::1`].includes(t.hostname))}var Pe=class extends re.EventEmitter{#e=null;socket=null;url=null;secure=!1;connect(e){this.url=e,this.secure=Ne(e),this._attachSocket(new WebSocket(e,[`xmpp`]))}_attachSocket(e){this.socket=e,this.#e??=de({open:()=>this.emit(`connect`),message:({data:e})=>this.emit(`data`,e),error:e=>{let{url:t}=this,{error:n}=e;n||(n=Error(e.message||`WebSocket ${Me} ${t}`),n.errno=Me,n.code=Me),n.event=e,n.url=t,this.emit(`error`,n)},close:e=>{this._detachSocket(),this.emit(`close`,!e.wasClean,e)}}),this.#e.subscribe(this.socket)}_detachSocket(){this.url=null,this.secure=!1,this.socket&&this.#e?.unsubscribe(this.socket),this.socket=null}end(){this.socket.close()}write(e,t){function n(e){t&&Promise.resolve().then(()=>t(e))}try{this.socket.send(e)}catch(e){n(e);return}n()}},Fe=class extends pe{onStartElement(e,t){let n=new te.default(e,t),{cursor:r}=this;r&&r.append(n),this.cursor=n}onEndElement(e){let{cursor:t}=this;if(e!==t.name){this.emit(`error`,new fe(`${t.name} must be closed.`));return}if(t.parent){this.cursor=t.parent;return}t.is(`open`,`urn:ietf:params:xml:ns:xmpp-framing`)?this.emit(`start`,t):t.is(`close`,`urn:ietf:params:xml:ns:xmpp-framing`)?this.emit(`end`,t):this.emit(`element`,t),this.cursor=null}},Ie=`urn:ietf:params:xml:ns:xmpp-framing`,Le=class extends Oe{send(e,...t){return e.attrs.xmlns??=this.NS,super.send(e,...t)}async sendMany(e){for(let t of e)t.attrs.xmlns??=this.NS,t.parent=this.root,this.socket.write(t.toString()),this.emit(`send`,t)}footerElement(){return new k.Element(`close`,{xmlns:Ie})}headerElement(){let e=super.headerElement();return e.name=`open`,e.attrs.xmlns=Ie,e}socketParameters(e){return/^wss?:\/\//.test(e)?e:void 0}};Le.prototype.Socket=Pe,Le.prototype.NS=`jabber:client`,Le.prototype.Parser=Fe;function Re({entity:e}){e.transports.push(Le)}var ze=o(((e,t)=>{t.exports={}})),Be=o(((e,t)=>{t.exports=n;function n(e){if(!Array.isArray(e))throw TypeError(`Middleware stack must be an array!`);for(let t of e)if(typeof t!=`function`)throw TypeError(`Middleware must be composed of functions!`);return function(t,n){let r=-1;return i(0);function i(a){if(a<=r)return Promise.reject(Error(`next() called multiple times`));r=a;let o=e[a];if(a===e.length&&(o=n),!o)return Promise.resolve();try{return Promise.resolve(o(t,i.bind(null,a+1)))}catch(e){return Promise.reject(e)}}}}})),Ve=c(ze(),1),He=c(Be(),1),Ue=class{constructor(e,t){this.stanza=t,this.entity=e;let{name:n,attrs:r}=t,{type:i,id:a}=r;this.name=n,this.id=a||``,this.type=n===`message`?i||`normal`:n===`presence`?i||`available`:i||``,this.from=null,this.to=null,this.local=``,this.domain=``,this.resource=``}},We=class extends Ue{constructor(e,t){super(e,t);let{jid:n}=e,{domain:r}=e.options??{},i=t.attrs.to||n?.toString(),a=t.attrs.from||r;i&&(this.to=new be(i)),a&&(this.from=new be(a),this.local=this.from.local,this.domain=this.from.domain,this.resource=this.from.resource)}},Ge=class extends Ue{constructor(e,t){super(e,t);let{jid:n}=e,{domain:r}=e.options??{},i=t.attrs.from||n?.toString(),a=t.attrs.to||r;i&&(this.from=new be(i)),a&&(this.to=new be(a),this.local=this.to.local,this.domain=this.to.domain,this.resource=this.to.resource)}};function Ke(e,t,n){return r=>{let i=new n(e,r);return(0,He.default)(t)(i)}}function qe(e){return(t,n)=>{n().then(t=>t&&e.send(t)).catch(t=>e.emit(`error`,t))}}function Je({entity:e}){let t=[qe(e)],n=[],r=Ke(e,t,We),i=Ke(e,n,Ge);return e.on(`element`,r),e.on(`send`,i),{use(e){return t.push(e),e},filter(e){return n.push(e),e}}}function Ye({middleware:e}){function t(t,n,r){return e.use((e,i)=>{let{stanza:a}=e;if(!a.is(`features`,`http://etherx.jabber.org/streams`))return i();let o=a.getChild(t,n);return o?r(e,i,o):i()})}return{use:t}}function Xe(){let e;for(;!e;)e=Math.random().toString(36).slice(2,12);return e}var Ze=class extends xe{constructor(e,t,n,r){super(e,t,n),this.type=r,this.name=`StanzaError`}static fromElement(e){let t=super.fromElement(e);return t.type=e.attrs.type,t}};function Qe({name:e,type:t}){return!(e!==`iq`||t!==`error`&&t!==`result`)}var $e=class{constructor({entity:e,middleware:t}){this.handlers=new Map,this.entity=e,this.middleware=t}start(){this.middleware.use(this._route.bind(this))}_route({type:e,name:t,id:n,stanza:r},i){if(!Qe({name:t,type:e}))return i();let a=this.handlers.get(n);if(!a)return i();e===`error`?a.reject(Ze.fromElement(r.getChild(`error`))):a.resolve(r),this.handlers.delete(n)}async request(e,t=3e4){e.attrs.id||(e.attrs.id=Xe());let n=new ue;this.handlers.set(e.attrs.id,n);try{await this.entity.send(e),await D(n.promise,t)}catch(t){throw this.handlers.delete(e.attrs.id),t}return n.promise}_childRequest(e,t,n,...r){let{name:i,attrs:{xmlns:a}}=t;return this.request(k(`iq`,{type:e,to:n},t),...r).then(e=>e.getChild(i,a))}async get(...e){return this._childRequest(`get`,...e)}async set(...e){return this._childRequest(`set`,...e)}};function et(...e){let t=new $e(...e);return t.start(),t}var tt=`urn:ietf:params:xml:ns:xmpp-stanzas`;function nt({name:e,type:t}){return e===`iq`&&t!==`error`&&t!==`result`}function rt({type:e},t,n){return!(e!==`get`&&e!==`set`||t.length!==1||!n)}function it({stanza:e}){return k(`iq`,{to:e.attrs.from,from:e.attrs.to,id:e.attrs.id})}function at(e,t){let n=it(e);return n.attrs.type=`result`,t&&n.append(t),n}function ot(e,t,n){let r=it(e);return r.attrs.type=`error`,n&&r.append(n),r.append(t),r}function st(e,t){return k(`error`,{type:e},k(t,tt))}function ct(e){return async function(t,n){if(!nt(t))return n();let{stanza:r}=t,i=r.getChildElements(),[a]=i;if(!rt(t,i,a))return ot(t,st(`modify`,`bad-request`),a);t.element=a;let o;try{o=await n()}catch(t){e.emit(`error`,t),o=st(`cancel`,`internal-server-error`)}return o||=st(`cancel`,`service-unavailable`),o instanceof k.Element&&o.is(`error`)?ot(t,o,a):at(t,o instanceof k.Element?o:void 0)}}function lt(e,t,n,r){return(i,a)=>i.type!==e|!i.element||!i.element.is(n,t)?a():r(i,a)}function ut({middleware:e,entity:t}){return e.use(ct(t)),{get(t,n,r){e.use(lt(`get`,t,n,r))},set(t,n,r){e.use(lt(`set`,t,n,r))}}}var dt=[`ENOTFOUND`,`ENODATA`];function ft(e,t={}){return t.all=!0,new Promise((n,r)=>{Ve.default.lookup(e,t,(e,t)=>{if(e)return r(e);let i=[];for(let{family:e,address:n}of t){let t=`://${e===4?n:`[`+n+`]`}:`;i.push({family:e,address:n,uri:`xmpps`+t+`5223`},{family:e,address:n,uri:`xmpp`+t+`5222`})}n(i)})})}function pt(e,{service:t,protocol:n}){return new Promise((r,i)=>{Ve.default.resolveSrv(`_${t}._${n}.${e}`,(e,a)=>{e&&dt.includes(e.code)?r([]):e?i(e):r(a.map(e=>Object.assign(e,{service:t,protocol:n})))})})}function mt(e){return e.toSorted((e,t)=>{let n=e.priority-t.priority;if(n!==0)return n;let r=t.weight-e.weight;return r===0?0:r})}function ht(e,t){let n=[];return Promise.all(e.map(async e=>{let r=await ft(e.name,t);for(let t of r){let{port:r,service:i}=e,a=t.address;n.push({...t,...e,uri:`${i.split(`-`)[0]}://${t.family===6?`[`+a+`]`:a}:${r}`})}})).then(()=>n)}function gt(e,t={}){t.srv||=[{service:`xmpps-client`,protocol:`tcp`},{service:`xmpp-client`,protocol:`tcp`},{service:`xmpps-server`,protocol:`tcp`},{service:`xmpp-server`,protocol:`tcp`},{service:`stun`,protocol:`tcp`},{service:`stun`,protocol:`udp`},{service:`stuns `,protcol:`tcp`},{service:`turn`,protocol:`tcp`},{service:`turn`,protocol:`udp`},{service:`turns`,protcol:`tcp`}];let n={options:t};return ft(e,t).then(r=>Promise.all(t.srv.map(r=>pt(e,{...r,family:n}).then(e=>ht(e,t)))).then(e=>[...mt(e.flat()),...r]))}function _t(e){let t=new pe,n=null,r=null;if(t.on(`start`,e=>{n=e}),t.on(`element`,e=>{n.append(e)}),t.on(`error`,e=>{r=e}),t.write(e),t.end(),r)throw r;return n}function vt(e){return e.startsWith(`https`)||e.startsWith(`wss`)}function yt(e,t){let n;if(n=vt(e.uri)&&!vt(t.uri)?-1:!vt(e.uri)&&vt(t.uri)?1:0,n!==0)return n;let r;return r=e.method===t.method?0:e.method===`websocket`?-1:t.method===`websocket`?1:e.method===`xbosh`?-1:t.method===`xbosh`?1:e.method===`httppoll`?-1:+(t.method===`httppoll`),r===0?0:r}function bt(e){return fetch(`https://${e}/.well-known/host-meta`).then(e=>e.text()).then(e=>_t(e).getChildren(`Link`).filter(e=>[`urn:xmpp:alt-connections:websocket`,`urn:xmpp:alt-connections:httppoll`,`urn:xmpp:alt-connections:xbosh`].includes(e.attrs.rel)).map(({attrs:e})=>({rel:e.rel,href:e.href,method:e.rel.split(`:`).pop(),uri:e.href})).toSorted(yt)).catch(()=>[])}function xt(...e){return Promise.all([gt?gt(...e):Promise.resolve([]),bt(...e)]).then(([e,t])=>[...e,...t])}async function St(e){let t=await xt(e,{srv:[{service:`xmpps-client`,protocol:`tcp`},{service:`xmpp-client`,protocol:`tcp`}]});return[...new Set(t.map(e=>e.uri))]}function Ct(e,t){return t.filter(t=>e._findTransport(t))}async function wt(e,t){if(t.length===0)throw Error(`Couldn't connect`);let n=t.shift(),r=e._findTransport(n);if(!r)return wt(e,t);e._status(`connecting`,n);let i=r.prototype.socketParameters(n),a=new r.prototype.Socket;try{a.connect(i),await le(a,`connect`)}catch{return wt(e,t)}e._attachSocket(a),a.emit(`connect`),e.Transport=r,e.Socket=r.prototype.Socket,e.Parser=r.prototype.Parser}function j({entity:e}){let t=e.connect;e.connect=async function(n){if(!n||/:\/\//.test(n))return t.call(this,n);let r=Ct(e,await St(n));if(r.length===0)throw Error(`No compatible transport found.`);try{await wt(e,r)}catch(t){throw await e.disconnect(),e._status(`disconnect`),t}}}function Tt(e){return globalThis.btoa(e)}function Et(e){return globalThis.atob(e)}var Dt=class extends xe{constructor(...e){super(...e),this.name=`SASLError`}},Ot=`urn:ietf:params:xml:ns:xmpp-sasl`;function kt(e,t,n){let r=new Set(e.getChildren(`mechanism`,t).map(e=>e.text()));return n._mechs.map(({name:e})=>e).filter(e=>r.has(e))}async function At({saslFactory:e,entity:t,mechanism:n,credentials:r}){let i=e.create([n]);if(!i)throw Error(`SASL: Mechanism ${n} not found.`);let{domain:a}=t.options,o={username:null,password:null,server:a,host:a,realm:a,serviceType:`xmpp`,serviceName:a,...r};await O(t,i.clientFirst&&k(`auth`,{xmlns:Ot,mechanism:i.name},Tt(await i.response(o))),async(e,n)=>{if(e.getNS()===Ot){if(e.name===`challenge`){await i.challenge(Et(e.text()));let n=await i.response(o);await t.send(k(`response`,{xmlns:Ot,mechanism:i.name},typeof n==`string`?Tt(n):``));return}if(e.name===`failure`)throw Dt.fromElement(e);if(e.name===`success`)return n()}})}function jt({streamFeatures:e,saslFactory:t},n){e.use(`mechanisms`,Ot,async({entity:e},r,i)=>{let a=kt(i,Ot,t);if(a.length===0)throw new Dt(`SASL: No compatible mechanism available.`);async function o(n,r){await At({saslFactory:t,entity:e,mechanism:r,credentials:n})}await n(o,a,null,e),await e.restart()})}var Mt=`urn:xmpp:sasl:2`;async function Nt({saslFactory:e,entity:t,mechanism:n,credentials:r,userAgent:i,streamFeatures:a,features:o}){let s=e.create([n]);if(!s)throw Error(`SASL: Mechanism ${n} not found.`);let{domain:c}=t.options,l={username:null,password:null,server:c,host:c,realm:c,serviceType:`xmpp`,serviceName:c,...r};await O(t,k(`authenticate`,{xmlns:Mt,mechanism:s.name},[s.clientFirst&&k(`initial-response`,{},Tt(await s.response(l))),i,...a]),async(e,n)=>{if(e.getNS()===Mt){if(e.name===`challenge`){await s.challenge(Et(e.text()));let n=await s.response(l);await t.send(k(`response`,{xmlns:Mt,mechanism:s.name},typeof n==`string`?Tt(n):``));return}if(e.name===`failure`)throw Dt.fromElement(e);if(e.name===`continue`)throw Error(`SASL continue is not supported yet`);if(e.name===`success`){let r=e.getChild(`additional-data`)?.text();r&&s.final&&await s.final(Et(r));let i=e.getChildText(`authorization-identifier`);i&&t._jid(i);for(let t of e.getChildElements())o.get(t.getNS())?.[1]?.(t);return n()}}})}function Pt({streamFeatures:e,saslFactory:t},n){let r=new Map,i;return e.use(`authentication`,Mt,async({entity:e},a,o)=>{let s=kt(o,Mt,t),c=await Ft({element:o,features:r}),l=!!i?.mechanism;if(s.length===0&&!l)throw new Dt(`SASL: No compatible mechanism available.`);await n(u,s,l?i:null,e);async function u(n,a,o){await i.auth({authenticate:Nt,entity:e,userAgent:o,streamFeatures:c,features:r,credentials:n})||await Nt({entity:e,userAgent:o,streamFeatures:c,features:r,saslFactory:t,mechanism:a,credentials:n})}}),{use(e,t,n){r.set(e,[t,n])},setup({fast:e}){i=e}}}async function Ft({element:e,features:t}){let n=[],r=e.getChild(`inline`);if(!r)return n;for(let e of r.getChildElements()){let r=e.getNS(),i=t.get(r);i&&n.push(i[0](e))}return Promise.all(n)}var It=`urn:ietf:params:xml:ns:xmpp-bind`;function Lt(e){return k(`bind`,{xmlns:It},e&&k(`resource`,{},e))}async function Rt(e,t,n){let r=(await t.set(Lt(n))).getChildText(`jid`);return e._jid(r),e._ready(!1),r}function zt({iqCaller:e},t){return async({entity:n},r)=>{t=typeof t==`function`?await t():t,await Rt(n,e,t),r()}}function Bt({streamFeatures:e,iqCaller:t},n){e.use(`bind`,It,zt({iqCaller:t},n))}function Vt(e=new Date){return typeof e==`string`&&(e=new Date(e)),new Date(e).toISOString().split(`.`)[0]+`Z`}function Ht({bind2:e,sm:t,failed:n,enabled:r}){e.use(qt,e=>Jt({sm:t}),async e=>{e.is(`enabled`)?r(e.attrs):e.is(`failed`)&&n()})}function Ut({sasl2:e,sm:t,failed:n,resumed:r}){e.use(qt,e=>{if(e.is(`sm`)&&t.id)return Yt({sm:t})},e=>{e.is(`resumed`)?r(e):e.is(`failed`)&&n()})}function Wt({streamFeatures:e,sm:t,entity:n,resumed:r,failed:i,enabled:a}){e.use(`sm`,qt,async(e,o)=>{if(t.id)try{await r(await Kt(n,t));return}catch{i()}await o();let s=Gt(n,t);if(t.outbound_q.length>0)throw Error(`Stream Management assertion failure, queue should be empty after enable`);t.outbound=0;try{a((await s).attrs)}catch{t.enabled=!1,t.enableSent=!1}})}function Gt(e,t){return O(e,Jt({sm:t}),(e,t)=>{if(e.is(`enabled`,`urn:xmpp:sm:3`))return t(e);if(e.is(`failed`,`urn:xmpp:sm:3`))throw xe.fromElement(e)})}async function Kt(e,t){return O(e,Yt({sm:t}),(e,t)=>{if(e.is(`resumed`,`urn:xmpp:sm:3`))return t(e);if(e.is(`failed`,`urn:xmpp:sm:3`))throw xe.fromElement(e)})}var qt=`urn:xmpp:sm:3`;function Jt({sm:e}){return k(`enable`,{xmlns:qt,max:e.preferredMaximum,resume:`true`})}function Yt({sm:e}){return k(`resume`,{xmlns:qt,h:e.inbound,previd:e.id})}function M({streamFeatures:e,entity:t,middleware:n,bind2:r,sasl2:i}){let a=null,o=null,s=null,c=new re.EventEmitter;Object.assign(c,{preferredMaximum:null,enabled:!1,enableSent:!1,id:``,outbound_q:[],outbound:0,inbound:0,max:null,timeout:6e4,requestAckInterval:3e4,requestAckDebounce:250});async function l(){try{await t.send(k(`a`,{xmlns:qt,h:c.inbound}))}catch{}}t.on(`disconnect`,()=>{clearTimeout(a),clearTimeout(o),clearTimeout(s),c.enabled=!1,c.enableSent=!1}),t.hook(`close`,async()=>{c.enabled&&await l()});async function u(e){c.enabled=!0,f(+e.attrs.h);let n=c.outbound_q;c.outbound_q=[],await t.sendMany(n.map(e=>Xt({entity:t,item:e}))),c.emit(`resumed`),t._ready(!0),h()}function d(){c.enabled=!1,c.enableSent=!1,c.id=``,p()}function f(e){let t=c.outbound;for(let n=0;n<+e-t;n++){let e=c.outbound_q.shift();c.outbound++,c.emit(`ack`,e.stanza)}}function p(){let e;for(;e=c.outbound_q.shift();)c.emit(`fail`,e.stanza);c.outbound=0}function m({id:e,max:t}){c.enabled=!0,c.id=e,c.max=t,c.inbound=0,h()}t.on(`offline`,()=>{p(),c.inbound=0,c.enabled=!1,c.enableSent=!1,c.id=``}),n.use(async(e,t)=>{let{stanza:n}=e;return clearTimeout(a),a=null,[`presence`,`message`,`iq`].includes(n.name)?c.inbound+=1:n.is(`r`,`urn:xmpp:sm:3`)?await l():n.is(`a`,`urn:xmpp:sm:3`)&&f(+n.attrs.h),h(),t()}),r&&Ht({bind2:r,sm:c,failed:d,enabled:m}),i&&Ut({sasl2:i,sm:c,failed:d,resumed:u});function h(e=c.requestAckInterval){clearTimeout(o),c.enabled&&e&&(o=setTimeout(g,e))}function g(){clearTimeout(o),clearTimeout(s),c.enabled&&(c.timeout&&!a&&(a=setTimeout(()=>{clearTimeout(o),t.disconnect().catch(()=>{})},c.timeout)),t.send(k(`r`,{xmlns:qt})).catch(()=>{}),h())}return n.filter((e,t)=>{let{stanza:n}=e;return n.is(`enable`,`urn:xmpp:sm:3`)&&(c.enableSent=!0),!c.enabled&&!c.enableSent||![`presence`,`message`,`iq`].includes(n.name)?t():(c.outbound_q.push({stanza:n,stamp:Vt()}),clearTimeout(o),clearTimeout(s),s=setTimeout(g,c.requestAckDebounce),t())}),e&&Wt({streamFeatures:e,sm:c,entity:t,resumed:u,failed:d,enabled:m}),c}function Xt({entity:e,item:t}){let{stanza:n,stamp:r}=t;return n.name===`message`&&!n.getChild(`delay`,`urn:xmpp:delay`)&&n.append(k(`delay`,{xmlns:`urn:xmpp:delay`,from:e.jid.toString(),stamp:r})),n}var Zt=`urn:xmpp:bind:0`;function Qt({sasl2:e,entity:t},n){let r=new Map;return e.use(Zt,async e=>{if(!e.is(`bind`,Zt))return;n=typeof n==`function`?await n():n;let t=await $t({element:e,features:r});return k(`bind`,{xmlns:`urn:xmpp:bind:0`},n&&k(`tag`,null,n),...t)},e=>{if(e.is(`bound`)){t._ready(!1);for(let t of e.getChildElements())r.get(t.getNS())?.[1]?.(t)}}),{use(e,t,n){r.set(e,[t,n])}}}function $t({element:e,features:t}){let n=[],r=e.getChild(`inline`);if(!r)return n;for(let e of r.getChildElements()){let r=e.attrs.var,i=t.get(r);i&&n.push(i[0](e))}return Promise.all(n)}var en=o(((e,t)=>{(function(n,r){typeof e==`object`?r(e,t):typeof define==`function`&&define.amd&&define([`exports`,`module`],r)})(e,function(e,t){function n(){this._mechs=[]}n.prototype.use=function(e,t){return t||(t=e,e=t.prototype.name),this._mechs.push({name:e,mech:t}),this},n.prototype.create=function(e){for(var t=0,n=this._mechs.length;t<n;t++)for(var r=0,i=e.length;r<i;r++){var a=this._mechs[t];if(a.name==e[r])return new a.mech}return null},e=t.exports=n})})),tn=c(o(((e,t)=>{(function(n,r){typeof e==`object`?r(e,t,en()):typeof define==`function`&&define.amd&&define([`exports`,`module`,`./lib/factory`],r)})(e,function(e,t,n){e=t.exports=n,e.Factory=n})}))(),1),nn=`urn:xmpp:fast:0`;function rn({sasl2:e,entity:t}){let n=new tn.default,r,i=new re.EventEmitter;Object.assign(i,{mechanism:null,mechanisms:[],async saveToken(e){r=e},async fetchToken(){return r},async deleteToken(){r=null},async save(e){try{await this.saveToken(e)}catch(e){t.emit(`error`,e)}},async fetch(){try{return this.fetchToken()}catch(e){t.emit(`error`,e)}},async delete(){try{await this.deleteToken()}catch(e){t.emit(`error`,e)}},saslFactory:n,async auth({authenticate:e,entity:t,userAgent:n,credentials:r,streamFeatures:o,features:s}){if(!i.mechanism)return!1;let{token:c}=r;if(!an(c,i.mechanisms))return l();try{return await e({saslFactory:i.saslFactory,mechanism:c.mechanism,credentials:{...r,password:c.token},streamFeatures:[...o,k(`fast`,{xmlns:nn})],entity:t,userAgent:n,features:s}),!0}catch(e){return e instanceof Dt&&[`not-authorized`,`credentials-expired`].includes(e.condition)?l():(t.emit(`error`,e),!1)}async function l(){return await i.delete(),a(o),!1}}});function a(e){e.push(k(`request-token`,{xmlns:nn,mechanism:i.mechanism}))}function o(){i.mechanism=null,i.mechanisms=[]}return o(),e.use(nn,async e=>{if(!e.is(`fast`,nn))return o();i.available=!0;let t=kt(e,nn,n),r=t[0];if(!r)return o();i.mechanisms=t,i.mechanism=r},async e=>{e.is(`token`,nn)&&await i.save({mechanism:i.mechanism,token:e.attrs.token,expiry:e.attrs.expiry})}),i}function an(e,t){return!(!e||!t.includes(e.mechanism)||new Date(e.expiry)<=new Date)}var on=o(((e,t)=>{(function(n,r){typeof e==`object`?r(e,t):typeof define==`function`&&define.amd&&define([`exports`,`module`],r)})(e,function(e,t){function n(){}n.prototype.name=`PLAIN`,n.prototype.clientFirst=!0,n.prototype.response=function(e){var t=``;return t+=e.authzid||``,t+=`\0`,t+=e.username,t+=`\0`,t+=e.password,t},n.prototype.challenge=function(e){return this},e=t.exports=n})})),sn=c(o(((e,t)=>{(function(n,r){typeof e==`object`?r(e,t,on()):typeof define==`function`&&define.amd&&define([`exports`,`module`,`./lib/mechanism`],r)})(e,function(e,t,n){e=t.exports=n,e.Mechanism=n})}))(),1);function cn(e){e.use(sn.default)}var ln=o(((e,t)=>{(function(n,r){typeof e==`object`?r(e,t):typeof define==`function`&&define.amd&&define([`exports`,`module`],r)})(e,function(e,t){function n(){}n.prototype.name=`ANONYMOUS`,n.prototype.clientFirst=!0,n.prototype.response=function(e){return e.trace||``},n.prototype.challenge=function(e){},e=t.exports=n})})),un=c(o(((e,t)=>{(function(n,r){typeof e==`object`?r(e,t,ln()):typeof define==`function`&&define.amd&&define([`exports`,`module`,`./lib/mechanism`],r)})(e,function(e,t,n){e=t.exports=n,e.Mechanism=n})}))(),1);function dn(e){e.use(un.default)}function fn(){}fn.prototype.Mechanism=fn,fn.prototype.name=`HT-SHA-256-NONE`,fn.prototype.clientFirst=!0,fn.prototype.response=async function({username:e,password:t}){this.key=await crypto.subtle.importKey(`raw`,new TextEncoder().encode(t),{name:`HMAC`,hash:`SHA-256`},!1,[`sign`,`verify`]);let n=await crypto.subtle.sign(`HMAC`,this.key,new TextEncoder().encode(`Initiator`));return`${e}\0${String.fromCodePoint(...new Uint8Array(n))}`},fn.prototype.final=async function(e){let t=Uint8Array.from(e,e=>e.codePointAt(0));if(await crypto.subtle.verify(`HMAC`,this.key,t,new TextEncoder().encode(`Responder`))!==!0)throw Error(`Responder message from server was wrong`)};function pn(e){e.use(fn)}var mn=`ANONYMOUS`,hn=`PLAIN`;function gn(e,t){return async function(...n){if(typeof e==`function`){await e(...n);return}let[r,i,a,o]=n;e.token??=await a?.fetch(),await r(e,_n({mechanisms:i,entity:o,credentials:e}),t)}}function _n({mechanisms:e,entity:t,credentials:n}){return!n?.username&&!n?.password&&!n?.token&&e.includes(mn)?mn:t.isSecure()?e[0]:e.find(e=>e!==hn)}function vn(e){return(e.split(`://`)[1]||e).split(`:`)[0].split(`/`)[0]}function yn(e={}){let{resource:t,credentials:n,username:r,password:i,userAgent:a,...o}=e,{domain:s,service:c}=o;!s&&c&&(o.domain=vn(c));let l=new ke(o);r&&o.domain&&(l.jid=be(r,o.domain));let u=je({entity:l}),d=Re({entity:l}),f=bn(Ve.default,{entity:l}),p=bn(Ve.default,{entity:l}),m=Je({entity:l}),h=Ye({middleware:m}),g=et({middleware:m,entity:l}),_=ut({middleware:m,entity:l}),v=j({entity:l}),y=new tn.default,b=Object.entries({...typeof Ve.default==`function`&&{scramsha1:Ve.default},plain:cn,anonymous:dn}).map(([e,t])=>({[e]:t(y)}));a??=k(`user-agent`,{id:globalThis.crypto.randomUUID()});let x=bn(Ve.default,{streamFeatures:h}),S=Pt({streamFeatures:h,saslFactory:y},gn(n??{username:r,password:i},a)),C=rn({sasl2:S,entity:l});S.setup({fast:C});let w=Qt({sasl2:S,entity:l},t);pn(C.saslFactory);let T=jt({streamFeatures:h,saslFactory:y},gn(n??{username:r,password:i},a)),ee=M({streamFeatures:h,entity:l,middleware:m,bind2:w,sasl2:S}),E=Bt({iqCaller:g,streamFeatures:h},t);return _?.get(`urn:xmpp:ping`,`ping`,()=>({})),Object.assign(l,{entity:l,reconnect:u,tcp:f,websocket:d,tls:p,middleware:m,streamFeatures:h,iqCaller:g,iqCallee:_,resolve:v,starttls:x,saslFactory:y,sasl2:S,sasl:T,resourceBinding:E,streamManagement:ee,mechanisms:b,bind2:w,fast:C})}function bn(e,...t){if(typeof e==`function`)return e(...t)}var N={carbons:`urn:xmpp:carbons:2`,forward:`urn:xmpp:forward:0`,mam:`urn:xmpp:mam:2`,rsm:`http://jabber.org/protocol/rsm`,sid:`urn:xmpp:sid:0`,hints:`urn:xmpp:hints`,chatstates:`http://jabber.org/protocol/chatstates`,oob:`jabber:x:oob`,upload:`urn:xmpp:http:upload:0`,delay:`urn:xmpp:delay`,disco:`http://jabber.org/protocol/disco#items`,discoInfo:`http://jabber.org/protocol/disco#info`,push:`urn:xmpp:push:0`,hello:`urn:nethvoice:chat:presence`,data:`jabber:x:data`,muc:`http://jabber.org/protocol/muc`,mucOwner:`http://jabber.org/protocol/muc#owner`,mucAdmin:`http://jabber.org/protocol/muc#admin`,mucsub:`urn:xmpp:mucsub:0`,pubsubEvent:`http://jabber.org/protocol/pubsub#event`,mucsubMessages:`urn:xmpp:mucsub:nodes:messages`,conference:`jabber:x:conference`,vcard:`vcard-temp`,ping:`urn:xmpp:ping`,reactions:`urn:xmpp:reactions:0`},xn=3e4,Sn=class{xmpp;me;domain;mucHost;uploadService;mamQueries=new Map;mamReactions=new Map;stopped=!1;attempt=0;retryTimer;pingTimer;unauthorized=!1;connected=!1;online=new Map;cfg;h;constructor(e,t){this.cfg=e,this.h=t,this.domain=e.host,this.mucHost=`conference.${e.host}`,this.me=`${e.username}@${e.host}`,this.xmpp=yn({service:`wss://${e.host}/xmpp-websocket`,domain:e.host,username:e.username,password:e.token,resource:`chat-island.`+Math.random().toString(36).slice(2,8)}),this.xmpp.reconnect?.stop(),this.xmpp.on(`status`,e=>{this.stopped||this.unauthorized||((e===`connecting`||e===`opening`||e===`connect`)&&this.h.status(`connecting`),(e===`disconnect`||e===`close`)&&(this.connected=!1,window.clearInterval(this.pingTimer),this.forgetPresence(),this.h.status(`offline`)),e===`disconnect`&&this.scheduleRetry())}),this.xmpp.on(`error`,e=>{if(!this.stopped){if(Cn(e)){this.unauthorized=!0,window.clearTimeout(this.retryTimer),this.h.status(`unauthorized`,e.message);return}this.h.status(`error`,e.message)}}),this.xmpp.on(`online`,async()=>{if(this.stopped){await this.xmpp.stop().catch(()=>{});return}this.attempt=0,this.connected=!0;try{await this.xmpp.send(k(`iq`,{type:`set`,id:`carbons`},k(`enable`,{xmlns:N.carbons}))),await this.xmpp.send(k(`presence`))}catch{return}window.clearInterval(this.pingTimer),this.pingTimer=window.setInterval(()=>this.ping(),xn),this.h.status(`online`)}),this.xmpp.on(`stanza`,e=>this.onStanza(e))}start(){window.addEventListener(`online`,this.wake),document.addEventListener(`visibilitychange`,this.onVisible),this.h.status(`connecting`),setTimeout(()=>this.connectNow(),0)}stop(){return this.stopped=!0,window.clearTimeout(this.retryTimer),window.clearInterval(this.pingTimer),window.removeEventListener(`online`,this.wake),document.removeEventListener(`visibilitychange`,this.onVisible),this.xmpp.stop().catch(()=>{})}wake=()=>{if(!(this.stopped||this.unauthorized)){if(this.connected){this.ping();return}window.clearTimeout(this.retryTimer),this.attempt=0,this.connectNow()}};onVisible=()=>{document.visibilityState===`visible`&&this.wake()};ping(){this.connected&&this.xmpp.iqCaller.request(k(`iq`,{type:`get`,to:this.domain},k(`ping`,{xmlns:N.ping})),1e4).catch(e=>{!this.stopped&&this.connected&&e.name!==`StanzaError`&&this.xmpp.disconnect().catch(()=>{})})}forgetPresence(){for(let e of this.online.keys())this.h.presence(e,!1);this.online.clear()}connectNow(){if(this.stopped||this.unauthorized)return;this.retryTimer=void 0;let e=this.xmpp;(e.status===`offline`?this.xmpp.start():e.connect(e.options.service).then(()=>e.open({domain:e.options.domain}))).catch(e=>{if(!this.stopped){if(Cn(e)){this.unauthorized=!0,this.h.status(`unauthorized`,e.message);return}this.h.status(`error`,e.message),this.scheduleRetry()}})}scheduleRetry(){if(this.stopped||this.unauthorized||this.retryTimer!==void 0)return;let e=Math.min(6e4,1e3*2**this.attempt)*(.7+Math.random()*.6);this.attempt++,this.retryTimer=window.setTimeout(()=>this.connectNow(),e)}isGroup(e){return e.endsWith(`@`+this.mucHost)}async send(e,t,n){let r=crypto.randomUUID(),i=[k(`body`,{},t),k(`origin-id`,{xmlns:N.sid,id:r}),k(`store`,{xmlns:N.hints})];return n&&i.push(k(`x`,{xmlns:N.oob},k(`url`,{},n))),this.isGroup(e)?(await this.xmpp.send(k(`message`,{to:e,type:`groupchat`,id:r},...i)),{id:r,oid:r,from:e,to:this.cfg.username,body:t,ts:Date.now(),mine:!0,oob:n,room:e,nick:this.cfg.username}):(i.push(k(`active`,{xmlns:N.chatstates})),await this.xmpp.send(k(`message`,{to:`${e}@${this.domain}`,type:`chat`,id:r},...i)),{id:r,oid:r,from:this.cfg.username,to:e,body:t,ts:Date.now(),mine:!0,oob:n})}async react(e,t,n){let r=this.isGroup(e),i=k(`reactions`,{xmlns:N.reactions,id:t},...n.map(e=>k(`reaction`,{},e)));await this.xmpp.send(k(`message`,{to:r?e:`${e}@${this.domain}`,type:r?`groupchat`:`chat`,id:crypto.randomUUID()},i,k(`store`,{xmlns:N.hints})))}async announce(e){for(let t of e)await this.xmpp.send(k(`presence`,{to:`${t}@${this.domain}`},k(`x`,{xmlns:N.hello}))).catch(()=>{})}typing(e,t){return this.isGroup(e)?Promise.resolve():this.xmpp.send(k(`message`,{to:`${e}@${this.domain}`,type:`chat`},k(t?`composing`:`paused`,{xmlns:N.chatstates})))}enablePush(e,t){return this.xmpp.iqCaller.request(k(`iq`,{type:`set`},k(`enable`,{xmlns:N.push,jid:e,node:t})),15e3)}disablePush(e,t){return this.xmpp.iqCaller.request(k(`iq`,{type:`set`},k(`disable`,{xmlns:N.push,jid:e,node:t})),5e3)}async recent(e=200){return this.mam(void 0,void 0,e)}history(e,t,n=30){return this.mam(e,t,n)}async mam(e,t,n){let r=crypto.randomUUID();this.mamQueries.set(r,[]),this.mamReactions.set(r,[]);let i=k(`set`,{xmlns:N.rsm},k(`max`,{},String(n)),k(`before`,{},t??``)),a=[k(`field`,{var:`FORM_TYPE`,type:`hidden`},k(`value`,{},N.mam))];e&&a.push(k(`field`,{var:`with`},k(`value`,{},this.isGroup(e)?e:`${e}@${this.domain}`)));let o=k(`x`,{xmlns:N.data,type:`submit`},...a),s,c,l;try{s=await this.xmpp.iqCaller.request(k(`iq`,{type:`set`,id:r},k(`query`,{xmlns:N.mam,queryid:r},o,i)),3e4)}finally{c=this.mamQueries.get(r)??[],l=this.mamReactions.get(r)??[],this.mamQueries.delete(r),this.mamReactions.delete(r)}let u=s.getChild(`fin`,N.mam),d=u?.getChild(`set`,N.rsm)?.getChildText(`first`)??void 0;return{messages:c,reactions:l,complete:u?.attrs.complete===`true`,first:d}}async createGroup(e,t,n){let r=`g-${Math.random().toString(36).slice(2,10)}@${this.mucHost}`,i=this.cfg.username,a=this.waitFor(e=>e.is(`presence`)&&P(e.attrs.from)===r,1e4);await this.xmpp.send(k(`presence`,{to:`${r}/${i}`},k(`x`,{xmlns:N.muc}))),await a;let o=(e,t)=>k(`field`,{var:e},k(`value`,{},t));await this.xmpp.iqCaller.request(k(`iq`,{type:`set`,to:r},k(`query`,{xmlns:N.mucOwner},k(`x`,{xmlns:N.data,type:`submit`},o(`FORM_TYPE`,`http://jabber.org/protocol/muc#roomconfig`),o(`muc#roomconfig_roomname`,e),o(`muc#roomconfig_persistentroom`,`1`),o(`muc#roomconfig_membersonly`,`1`),o(`muc#roomconfig_publicroom`,`0`),o(`muc#roomconfig_whois`,`anyone`),o(`allow_subscription`,`1`),o(`mam`,`1`)))),15e3),n&&await this.setGroupAvatar(r,n).catch(()=>{});let s=t.filter(e=>e&&e!==this.cfg.username);await this.xmpp.iqCaller.request(k(`iq`,{type:`set`,to:r},k(`query`,{xmlns:N.mucAdmin},...s.map(e=>k(`item`,{affiliation:`member`,jid:`${e}@${this.domain}`})))),15e3);for(let e of s)await this.xmpp.iqCaller.request(k(`iq`,{type:`set`,to:r},k(`subscribe`,{xmlns:N.mucsub,jid:`${e}@${this.domain}`,nick:e},k(`event`,{node:N.mucsubMessages}))),15e3).catch(()=>{});await this.xmpp.iqCaller.request(k(`iq`,{type:`set`,to:r},k(`subscribe`,{xmlns:N.mucsub,nick:i},k(`event`,{node:N.mucsubMessages}))),15e3),await this.xmpp.send(k(`presence`,{to:`${r}/${i}`,type:`unavailable`}));for(let t of s)await this.xmpp.send(k(`message`,{to:`${t}@${this.domain}`},k(`x`,{xmlns:N.conference,jid:r,reason:e}))).catch(()=>{});return r}async leaveGroup(e,t){t?await this.xmpp.iqCaller.request(k(`iq`,{type:`set`,to:e},k(`query`,{xmlns:N.mucOwner},k(`destroy`,{}))),1e4):await this.xmpp.iqCaller.request(k(`iq`,{type:`set`,to:e},k(`unsubscribe`,{xmlns:N.mucsub})),1e4)}async setGroupAvatar(e,t){let n=/^data:(image\/[a-z+]+);base64,(.+)$/i.exec(t);n&&await this.xmpp.iqCaller.request(k(`iq`,{type:`set`,to:e},k(`vCard`,{xmlns:N.vcard},k(`PHOTO`,{},k(`TYPE`,{},n[1]),k(`BINVAL`,{},n[2])))),15e3)}async groupAvatar(e){let t=(await this.xmpp.iqCaller.request(k(`iq`,{type:`get`,to:e},k(`vCard`,{xmlns:N.vcard})),1e4)).getChild(`vCard`,N.vcard)?.getChild(`PHOTO`),n=t?.getChildText(`BINVAL`);return n?`data:${t?.getChildText(`TYPE`)||`image/jpeg`};base64,${n.replace(/\s+/g,``)}`:void 0}async listGroups(){let e=((await this.xmpp.iqCaller.request(k(`iq`,{type:`get`,to:this.mucHost},k(`subscriptions`,{xmlns:N.mucsub})),15e3)).getChild(`subscriptions`,N.mucsub)?.getChildren(`subscription`)??[]).map(e=>e.attrs.jid);return Promise.all(e.map(e=>this.groupInfo(e)))}async subscribed(e){return((await this.xmpp.iqCaller.request(k(`iq`,{type:`get`,to:this.mucHost},k(`subscriptions`,{xmlns:N.mucsub})),15e3)).getChild(`subscriptions`,N.mucsub)?.getChildren(`subscription`)??[]).some(t=>P(t.attrs.jid)===e)}async groupInfo(e){let t=e.split(`@`)[0],n=[],r=!1;try{t=(await this.xmpp.iqCaller.request(k(`iq`,{type:`get`,to:e},k(`query`,{xmlns:N.discoInfo})),1e4)).getChild(`query`,N.discoInfo)?.getChild(`identity`)?.attrs.name||t}catch{}try{n=((await this.xmpp.iqCaller.request(k(`iq`,{type:`get`,to:e},k(`query`,{xmlns:N.mucAdmin},k(`item`,{affiliation:`member`}))),1e4)).getChild(`query`,N.mucAdmin)?.getChildren(`item`)??[]).map(e=>wn(e.attrs.jid));let t=await this.xmpp.iqCaller.request(k(`iq`,{type:`get`,to:e},k(`query`,{xmlns:N.mucAdmin},k(`item`,{affiliation:`owner`}))),1e4);for(let e of t.getChild(`query`,N.mucAdmin)?.getChildren(`item`)??[])n.push(wn(e.attrs.jid)),wn(e.attrs.jid)===this.cfg.username&&(r=!0)}catch{}let i=await this.groupAvatar(e).catch(()=>void 0);return{peer:e,name:t,members:[...new Set(n)],avatar:i,owner:r}}async upload(e){let t=await this.findUploadService(),n=(await this.xmpp.iqCaller.request(k(`iq`,{type:`get`,to:t},k(`request`,{xmlns:N.upload,filename:e.name,size:String(e.size),"content-type":e.type||`application/octet-stream`})),3e4)).getChild(`slot`,N.upload),r=n?.getChild(`put`),i=n?.getChild(`get`)?.attrs.url;if(!r||!i)throw Error(`upload: no slot`);let a={"Content-Type":e.type||`application/octet-stream`};for(let e of r.getChildren(`header`))a[e.attrs.name]=e.text();let o=await fetch(r.attrs.url,{method:`PUT`,headers:a,body:e});if(!o.ok)throw Error(`upload: HTTP ${o.status}`);return i}async findUploadService(){if(this.uploadService)return this.uploadService;let e=async e=>{try{return(await this.xmpp.iqCaller.request(k(`iq`,{type:`get`,to:e},k(`query`,{xmlns:N.discoInfo})),1e4)).getChild(`query`,N.discoInfo)?.getChildren(`feature`).some(e=>e.attrs.var===N.upload)??!1}catch{return!1}},t=[`upload.${this.domain}`];try{let e=await this.xmpp.iqCaller.request(k(`iq`,{type:`get`,to:this.domain},k(`query`,{xmlns:N.disco})),1e4);for(let n of e.getChild(`query`,N.disco)?.getChildren(`item`)??[])t.includes(n.attrs.jid)||t.push(n.attrs.jid)}catch{}for(let n of t)if(await e(n))return this.uploadService=n,n;throw Error(`upload: service not found`)}waiters=[];waitFor(e,t){return new Promise((n,r)=>{let i={test:e,resolve:n};this.waiters.push(i),setTimeout(()=>{let e=this.waiters.indexOf(i);e>=0&&(this.waiters.splice(e,1),r(Error(`timeout`)))},t)})}onStanza(e){for(let t of[...this.waiters])t.test(e)&&(this.waiters.splice(this.waiters.indexOf(t),1),t.resolve());if(e.is(`presence`)){let t=e.attrs.from??``,n=P(t);if(!n||n===this.me||n.endsWith(`@`+this.mucHost)||e.attrs.type===`error`||e.attrs.type?.startsWith(`subscribe`))return;let r=wn(n),i=this.online.get(r)??new Set;e.attrs.type===`unavailable`?i.delete(t):i.add(t),this.online.set(r,i),this.h.presence(r,i.size>0);let a=e.getChild(`x`,N.hello);a&&!a.attrs.reply&&e.attrs.type!==`unavailable`&&this.xmpp.send(k(`presence`,{to:n},k(`x`,{xmlns:N.hello,reply:`1`}))).catch(()=>{});return}if(!e.is(`message`))return;let t=!e.attrs.from||P(e.attrs.from)===this.me,n=e.getChild(`result`,N.mam);if(n){if(!t)return;let e=n.getChild(`forwarded`,N.forward)?.getChild(`message`),r=this.mamQueries.get(n.attrs.queryid);if(e&&r){let t=this.reactionOf(e);t&&this.mamReactions.get(n.attrs.queryid)?.push(t);let i=t?void 0:this.toMessage(e,n.attrs.id,Tn(n.getChild(`forwarded`,N.forward)));i&&r.push(i)}return}let r=e.getChild(`received`,N.carbons)??e.getChild(`sent`,N.carbons);if(r){if(!t)return;let e=r.getChild(`forwarded`,N.forward)?.getChild(`message`);e&&this.deliver(e);return}let i=e.getChild(`x`,N.conference);if(i){let e=P(i.attrs.jid);this.isGroup(e)&&this.h.groupInvite(e);return}this.deliver(e)}deliver(e){let t=this.reactionOf(e);if(t){this.h.reaction(t);return}let n=this.toMessage(e,e.getChild(`stanza-id`,N.sid)?.attrs.id,Tn(e));if(n){this.h.message(n);return}if(e.attrs.type!==`chat`)return;let r=P(e.attrs.from),i=r===this.me?P(e.attrs.to):r,a=e.getChildByAttr(`xmlns`,N.chatstates);!e.getChild(`body`)&&a&&this.h.typing(wn(i),a.name===`composing`)}reactionOf(e){let t=e.getChild(`event`,N.pubsubEvent),n=e,r;if(t&&t.getChild(`items`)?.attrs.node===N.mucsubMessages){r=P(e.attrs.from);let i=En(t);if(!this.isGroup(r)||!i||P(i.attrs.from)!==r)return;n=i}else if(e.attrs.type===`groupchat`&&(r=P(e.attrs.from),!this.isGroup(r)))return;let i=n.getChild(`reactions`,N.reactions),a=i?.attrs.id;if(!i||!a)return;let o=[...new Set(i.getChildren(`reaction`).map(e=>e.text().trim()).filter(e=>e&&e.length<=16))].slice(0,5);if(r){let e=(n.attrs.from??``).split(`/`)[1]??``;return e?{peer:r,target:a,user:e,emojis:o}:void 0}if(n.attrs.type!==`chat`)return;let s=P(n.attrs.from),c=s===this.me||!n.attrs.from,l=wn(c?P(n.attrs.to):s);return l?{peer:l,target:a,user:c?this.cfg.username:wn(s),emojis:o}:void 0}toMessage(e,t,n){let r=e.getChild(`event`,N.pubsubEvent);if(r&&r.getChild(`items`)?.attrs.node===N.mucsubMessages){let i=P(e.attrs.from);if(!this.isGroup(i))return;let a=En(r);if(!a||P(a.attrs.from)!==i)return;let o=(a.attrs.from??``).split(`/`)[1]??``,s=a.getChildText(`body`);return s==null?void 0:{id:a.getChild(`origin-id`,N.sid)?.attrs.id??t??a.getChild(`stanza-id`,N.sid)?.attrs.id??a.attrs.id??crypto.randomUUID(),oid:a.getChild(`origin-id`,N.sid)?.attrs.id??a.attrs.id,from:i,to:this.cfg.username,body:s,ts:Tn(a)!==n&&a.getChild(`delay`,N.delay)?Tn(a):n,mine:o===this.cfg.username,oob:a.getChild(`x`,N.oob)?.getChildText(`url`)??void 0,room:i,nick:o}}let i=e.getChildText(`body`);if(i==null)return;let a=P(e.attrs.from);if(e.attrs.type===`groupchat`){if(!this.isGroup(a))return;let r=(e.attrs.from??``).split(`/`)[1]??``;return{id:t??e.getChild(`origin-id`,N.sid)?.attrs.id??e.attrs.id??crypto.randomUUID(),oid:e.getChild(`origin-id`,N.sid)?.attrs.id??e.attrs.id,from:a,to:this.cfg.username,body:i,ts:n,mine:r===this.cfg.username,oob:e.getChild(`x`,N.oob)?.getChildText(`url`)??void 0,room:a,nick:r}}if(e.attrs.type!==`chat`)return;let o=a===this.me;return{id:t??e.getChild(`origin-id`,N.sid)?.attrs.id??e.attrs.id??crypto.randomUUID(),oid:e.getChild(`origin-id`,N.sid)?.attrs.id??e.attrs.id,from:wn(a),to:wn(P(e.attrs.to)),body:i,ts:n,mine:o,oob:e.getChild(`x`,N.oob)?.getChildText(`url`)??void 0}}},P=(e=``)=>e.split(`/`)[0],Cn=e=>e.name===`SASLError`||e.condition===`not-authorized`,wn=(e=``)=>e.split(`@`)[0],Tn=e=>{let t=e?.getChild(`delay`,N.delay)?.attrs.stamp;return t?Date.parse(t):Date.now()};function En(e){for(let t of e.children){if(typeof t==`string`)continue;if(t.name===`message`)return t;let e=En(t);if(e)return e}}var Dn;function On(){try{Dn??=new AudioContext,Dn.state===`suspended`&&Dn.resume();let e=Dn.currentTime;for(let[t,n,r]of[[880,0,.09],[1174.7,.1,.16]]){let i=Dn.createOscillator(),a=Dn.createGain();i.type=`sine`,i.frequency.value=t,a.gain.setValueAtTime(1e-4,e+n),a.gain.exponentialRampToValueAtTime(.12,e+n+.01),a.gain.exponentialRampToValueAtTime(1e-4,e+n+r),i.connect(a).connect(Dn.destination),i.start(e+n),i.stop(e+n+r+.02)}}catch{}}var kn=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e)),destroy:()=>{n.clear()}},o=t=e(r,i,a);return a},An=e=>e?kn(e):kn,jn=o((e=>{var t=u();function n(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var r=typeof Object.is==`function`?Object.is:n,i=t.useState,a=t.useEffect,o=t.useLayoutEffect,s=t.useDebugValue;function c(e,t){var n=t(),r=i({inst:{value:n,getSnapshot:t}}),c=r[0].inst,u=r[1];return o(function(){c.value=n,c.getSnapshot=t,l(c)&&u({inst:c})},[e,n,t]),a(function(){return l(c)&&u({inst:c}),e(function(){l(c)&&u({inst:c})})},[e]),s(n),n}function l(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!r(e,n)}catch{return!0}}function d(e,t){return t()}var f=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?d:c;e.useSyncExternalStore=t.useSyncExternalStore===void 0?f:t.useSyncExternalStore})),Mn=o(((e,t)=>{t.exports=jn()})),Nn=o((e=>{var t=u(),n=Mn();function r(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var i=typeof Object.is==`function`?Object.is:r,a=n.useSyncExternalStore,o=t.useRef,s=t.useEffect,c=t.useMemo,l=t.useDebugValue;e.useSyncExternalStoreWithSelector=function(e,t,n,r,u){var d=o(null);if(d.current===null){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=c(function(){function e(e){if(!a){if(a=!0,o=e,e=r(e),u!==void 0&&f.hasValue){var t=f.value;if(u(t,e))return s=t}return s=e}if(t=s,i(o,e))return t;var n=r(e);return u!==void 0&&u(t,n)?(o=e,t):(o=e,s=n)}var a=!1,o,s,c=n===void 0?null:n;return[function(){return e(t())},c===null?void 0:function(){return e(c())}]},[t,n,r,u]);var p=a(e,d[0],d[1]);return s(function(){f.hasValue=!0,f.value=p},[p]),l(p),p}})),Pn=c(o(((e,t)=>{t.exports=Nn()}))(),1),{useDebugValue:Fn}=g.default,{useSyncExternalStoreWithSelector:In}=Pn.default,Ln=e=>e;function Rn(e,t=Ln,n){let r=In(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return Fn(r),r}var zn=e=>{let t=typeof e==`function`?An(e):e,n=(e,n)=>Rn(t,e,n);return Object.assign(n,t),n},Bn=e=>e?zn(e):zn,Vn=e=>e.room??(e.mine?e.to:e.from),Hn=(e,t)=>({peer:e,kind:t&&e.endsWith(`@`+t)?`group`:`chat`,messages:[],unread:0,typing:!1,loaded:!1,complete:!1}),Un=(e,t,n,r)=>{if(e.includes(t))return e;let i=[t,...e];if(i.length<=n)return i;let a=[...i].reverse().find(e=>e!==r);return i.filter(e=>e!==a)},F=Bn((e,t)=>({me:``,mucHost:``,status:`connecting`,contacts:{},online:{},mobile:{},conversations:{},order:[],open:null,picker:!1,push:`unavailable`,enablePush:()=>{},maxHeads:5,newChatButton:!0,setStatus:(t,n)=>e({status:t,error:n}),reset:()=>e({status:`connecting`,error:void 0,contacts:{},online:{},mobile:{},conversations:{},order:[],open:null,picker:!1}),setContacts:t=>e({contacts:Object.fromEntries(t.filter(e=>e?.username).map(e=>[e.username,{...e,name:e.name||e.username}]))}),setMobile:t=>e({mobile:Object.fromEntries(t.map(e=>[e,!0]))}),setOnline:(t,n)=>e(e=>e.online[t]===n?{}:{online:{...e.online,[t]:n}}),ensure:n=>{let r=t().conversations[n];if(r)return r;let i=Hn(n,t().mucHost);return e(e=>({conversations:{...e.conversations,[n]:i}})),i},setGroup:(t,n,r,i,a)=>e(e=>{let o=e.conversations[t]??Hn(t,e.mucHost);return{conversations:{...e.conversations,[t]:{...o,kind:`group`,name:n,members:r,avatar:i??o.avatar,owner:a??o.owner}}}}),seed:(t,n)=>e(e=>{let r={...e.conversations};for(let i of t){let t=Vn(i);if(!t||t===n)continue;let a=r[t]??Hn(t,e.mucHost);if(a.messages.some(e=>e.id===i.id))continue;if(a.loaded){r[t]={...a,messages:[...a.messages,i].sort((e,t)=>e.ts-t.ts)};continue}let o=a.messages[a.messages.length-1];r[t]={...a,messages:!o||o.ts<=i.ts?[i]:a.messages}}return{conversations:r}}),addMessage:(t,n,r)=>e(e=>{let i=e.conversations[t]??Hn(t,e.mucHost),a=i.messages.filter(e=>e.id!==n.id&&!(e.pending&&n.mine&&e.body===n.body&&e.oob===n.oob)),o=a.length;for(;o>0&&a[o-1].ts>n.ts;)o--;a.splice(o,0,n);let s=e.open===t,c=r?.live&&!n.mine&&!s?i.unread+1:i.unread,l=Un(e.order,t,e.maxHeads,e.open);return{conversations:{...e.conversations,[t]:{...i,messages:a,unread:c,typing:n.mine?i.typing:!1}},order:l}}),prependHistory:(t,n,r,i)=>e(e=>{let a=e.conversations[t]??Hn(t,e.mucHost),o=new Set(a.messages.map(e=>e.id)),s=[...n.filter(e=>!o.has(e.id)),...a.messages].sort((e,t)=>e.ts-t.ts);return{conversations:{...e.conversations,[t]:{...a,messages:s,loaded:!0,complete:r,oldest:i??a.oldest}}}}),applyReactions:t=>e(e=>{if(!t.length)return{};let n={...e.conversations};for(let r of t){let t=n[r.peer]??Hn(r.peer,e.mucHost),i={...t.reactions??{}},a={...i[r.target]??{}};r.emojis.length?a[r.user]=r.emojis:delete a[r.user],i[r.target]=a,n[r.peer]={...t,reactions:i}}return{conversations:n}}),setTyping:(t,n)=>e(e=>e.conversations[t]?{conversations:{...e.conversations,[t]:{...e.conversations[t],typing:n}}}:{}),openChat:t=>e(e=>({conversations:e.conversations[t]?e.conversations:{...e.conversations,[t]:Hn(t,e.mucHost)},order:Un(e.order,t,e.maxHeads,e.open),open:t,picker:!1})),closeChat:()=>e({open:null}),removeConversation:t=>e(e=>{let n={...e.conversations};return delete n[t],{conversations:n,order:e.order.filter(e=>e!==t),open:e.open===t?null:e.open}}),removeHead:t=>e(e=>({order:e.order.filter(e=>e!==t),open:e.open===t?null:e.open})),markRead:t=>e(e=>e.conversations[t]&&e.conversations[t].unread?{conversations:{...e.conversations,[t]:{...e.conversations[t],unread:0}}}:{}),setPicker:t=>e({picker:t}),totalUnread:()=>Object.values(t().conversations).reduce((e,t)=>e+t.unread,0)}));async function Wn(e,t,n){let r=await fetch(`https://${e}/api${n}`,{headers:{Authorization:`Bearer ${t}`}});if(!r.ok)throw Error(`${n}: HTTP ${r.status}`);return await r.json()}async function Gn(e,t,n){let r=await Wn(e,t,`/user/endpoints/all`),i={};try{i=await Wn(e,t,`/user/all_avatars`)}catch{}return Object.values(r).filter(e=>e.username&&e.username!==n).map(e=>({username:e.username,name:e.name||e.username,avatar:i[e.username],presence:e.mainPresence})).sort((e,t)=>e.name.localeCompare(t.name))}async function Kn(e,t){let n=await fetch(`https://${e}/chat-gw/push/mobile`,{headers:{Authorization:`Bearer ${t}`}});if(!n.ok)throw Error(`push/mobile: HTTP ${n.status}`);return(await n.json()).users}async function qn(e,t,n){let r=await fetch(`https://${e}/chat-gw/conversations/${encodeURIComponent(n)}`,{method:`DELETE`,headers:{Authorization:`Bearer ${t}`}});if(!r.ok)throw Error(`delete: HTTP ${r.status}`)}var Jn=e=>{let t=atob((e+`=`.repeat((4-e.length%4)%4)).replace(/-/g,`+`).replace(/_/g,`/`));return Uint8Array.from(t,e=>e.charCodeAt(0))},Yn=!1;function Xn(){Yn||(Yn=!0,navigator.serviceWorker.addEventListener(`message`,e=>{e.data?.type===`chat-island-open`&&typeof e.data.username==`string`&&window.dispatchEvent(new CustomEvent(`chat-island-open`,{detail:{username:e.data.username}}))}))}async function Zn(e,t){if(!(`serviceWorker`in navigator)||!(`PushManager`in window))throw Error(`push not supported by this browser`);if(Notification.permission===`denied`||Notification.permission!==`granted`&&await Notification.requestPermission()!==`granted`)return null;let n=`https://${e.host}/chat-gw`,r=await fetch(`${n}/push/vapid`);if(!r.ok)throw Error(`vapid: HTTP ${r.status}`);let i=await r.json(),a=await navigator.serviceWorker.register(t);await navigator.serviceWorker.ready;let o=await a.pushManager.getSubscription()??await a.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:Jn(i.publicKey)}),s=await fetch(`${n}/push/web`,{method:`POST`,headers:{"Content-Type":`application/json`,Authorization:`Bearer ${e.token}`},body:JSON.stringify(o.toJSON())});if(!s.ok)throw Error(`push/web: HTTP ${s.status} ${(await s.text()).slice(0,120)}`);let c=await s.json();return Xn(),{node:c.node,service:c.service}}function I(e,t){window.dispatchEvent(new CustomEvent(e,{detail:t}))}function Qn(e,t){let n=e=>t(e.detail);return window.addEventListener(e,n),()=>window.removeEventListener(e,n)}var $n=o((e=>{var t=u(),n=Symbol.for(`react.element`),r=Symbol.for(`react.fragment`),i=Object.prototype.hasOwnProperty,a=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,o={key:!0,ref:!0,__self:!0,__source:!0};function s(e,t,r){var s,c={},l=null,u=null;for(s in r!==void 0&&(l=``+r),t.key!==void 0&&(l=``+t.key),t.ref!==void 0&&(u=t.ref),t)i.call(t,s)&&!o.hasOwnProperty(s)&&(c[s]=t[s]);if(e&&e.defaultProps)for(s in t=e.defaultProps,t)c[s]===void 0&&(c[s]=t[s]);return{$$typeof:n,type:e,key:l,ref:u,props:c,_owner:a.current}}e.Fragment=r,e.jsx=s,e.jsxs=s})),L=o(((e,t)=>{t.exports=$n()}))(),er=e=>e.split(/\s+/).slice(0,2).map(e=>e[0]?.toUpperCase()??``).join(``);function tr({contact:e,username:t,size:n=40}){let r=e?.name||t,i={width:n,height:n,fontSize:n/2.6};return e?.avatar?(0,L.jsx)(`img`,{src:e.avatar,alt:r,style:i,className:`ci-rounded-full ci-object-cover ci-shrink-0`}):(0,L.jsx)(`div`,{style:i,className:`ci-rounded-full ci-shrink-0 ci-flex ci-items-center ci-justify-center ci-font-medium ci-bg-gray-700 ci-text-gray-50 dark:ci-bg-gray-300 dark:ci-text-gray-900`,children:er(r)})}function nr({online:e,presence:t,mobile:n}){return(0,L.jsx)(`span`,{className:`ci-absolute ci-bottom-0 ci-right-0 ci-w-3 ci-h-3 ci-rounded-full ci-ring-2 ci-ring-gray-50 dark:ci-ring-gray-950 ${t===`dnd`||t===`busy`?`ci-bg-phoneIslandClose dark:ci-bg-phoneIslandCloseDark`:e||n?`ci-bg-phoneIslandCall dark:ci-bg-phoneIslandCallDark`:`ci-bg-gray-400 dark:ci-bg-gray-600`}`})}function rr({name:e,size:t=40,avatar:n}){let r={width:t,height:t,fontSize:t/2.8};return n?(0,L.jsx)(`img`,{src:n,alt:e,style:r,className:`ci-rounded-full ci-object-cover ci-shrink-0`}):(0,L.jsx)(`div`,{style:r,className:`ci-rounded-full ci-shrink-0 ci-flex ci-items-center ci-justify-center ci-font-medium ci-bg-iconSecondary dark:ci-bg-iconSecondaryDark ci-text-white`,children:er(e||`G`)})}var ir=`ci-flex ci-content-center ci-items-center ci-justify-center ci-tracking-wide ci-duration-200 ci-transform ci-outline-none focus:ci-ring-2 focus:ci-z-20 focus:ci-ring-offset-2 disabled:ci-opacity-40 disabled:ci-cursor-not-allowed ci-border ci-border-transparent focus:ci-ring-offset-white dark:focus:ci-ring-offset-black ci-text-sm ci-leading-4 ci-transition-colors ci-shrink-0 ci-font-light`,ar={default:`ci-bg-phoneIslandActive dark:ci-bg-phoneIslandActiveDark hover:ci-bg-gray-500 dark:hover:ci-bg-gray-50 focus:ci-ring-emerald-500 dark:focus:ci-ring-emerald-300 ci-text-primaryInvert dark:ci-text-primaryInvertDark ci-h-12 ci-w-12 ci-rounded-full`,green:`ci-bg-phoneIslandCall dark:ci-bg-phoneIslandCallDark hover:ci-bg-phoneIslandCallHover dark:hover:ci-bg-phoneIslandCallHoverDark focus:ci-ring-green-500 ci-text-white dark:ci-text-gray-950 ci-h-12 ci-w-12 ci-rounded-full`,red:`ci-bg-phoneIslandClose dark:ci-bg-phoneIslandCloseDark hover:ci-bg-phoneIslandCloseHover dark:hover:ci-bg-phoneIslandCloseHoverDark focus:ci-ring-emerald-500 ci-text-white dark:ci-text-gray-950 ci-h-12 ci-w-12 ci-rounded-full`,neutral:`ci-bg-transparent enabled:hover:ci-bg-gray-500 enabled:hover:ci-border-gray-500 ci-border ci-border-gray-700 focus:ci-ring-0 ci-text-secondaryNeutral dark:ci-text-secondaryNeutralDark ci-h-12 ci-w-12 ci-rounded-full`,transparent:`ci-bg-transparent dark:enabled:hover:ci-bg-gray-700/30 enabled:hover:ci-bg-gray-300/70 focus:ci-ring-gray-400 dark:focus:ci-ring-gray-500 ci-text-secondaryNeutral dark:ci-text-secondaryNeutralDark ci-h-12 ci-w-12 ci-rounded-full`,call:`ci-bg-phoneIslandCall dark:ci-bg-phoneIslandCallDark hover:ci-bg-phoneIslandCallHover dark:hover:ci-bg-phoneIslandCallHoverDark focus:ci-ring-green-500 ci-text-white dark:ci-text-gray-950 ci-h-8 ci-w-8 ci-rounded-full`,small:`ci-bg-transparent dark:hover:ci-bg-gray-600 hover:ci-bg-gray-300 focus:ci-ring-gray-400 dark:focus:ci-ring-gray-500 ci-text-gray-700 dark:ci-text-white ci-h-8 ci-w-8 ci-rounded`};function or({variant:e,className:t=``,children:n,...r}){return(0,L.jsx)(`button`,{type:`button`,"aria-label":r[`aria-label`]??r.title,className:`${ir} ${ar[e]} ${t}`,...r,children:n})}var R={chat:(0,L.jsx)(`svg`,{width:`22`,height:`22`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,L.jsx)(`path`,{d:`M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z`})}),bell:(0,L.jsx)(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,L.jsx)(`path`,{d:`M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9M13.73 21a2 2 0 0 1-3.46 0`})}),clip:(0,L.jsx)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,L.jsx)(`path`,{d:`M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48`})}),send:(0,L.jsx)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,L.jsx)(`path`,{d:`M22 2L11 13M22 2l-7 20-4-9-9-4 20-7z`})}),phone:(0,L.jsx)(`svg`,{width:`15`,height:`15`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,L.jsx)(`path`,{d:`M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72c.13.96.36 1.9.7 2.81a2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45c.91.34 1.85.57 2.81.7A2 2 0 0 1 22 16.92z`})}),mic:(0,L.jsxs)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,L.jsx)(`path`,{d:`M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z`}),(0,L.jsx)(`path`,{d:`M19 10v2a7 7 0 0 1-14 0v-2M12 19v4M8 23h8`})]}),camera:(0,L.jsxs)(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,L.jsx)(`path`,{d:`M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z`}),(0,L.jsx)(`circle`,{cx:`12`,cy:`13`,r:`4`})]}),trash:(0,L.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,L.jsx)(`path`,{d:`M3 6h18M8 6V4h8v2M19 6l-1 14H6L5 6M10 11v6M14 11v6`})}),minus:(0,L.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,children:(0,L.jsx)(`path`,{d:`M5 12h14`})}),close:(0,L.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,children:(0,L.jsx)(`path`,{d:`M18 6L6 18M6 6l12 12`})}),smile:(0,L.jsxs)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,L.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,L.jsx)(`path`,{d:`M8 14s1.5 2 4 2 4-2 4-2M9 9h.01M15 9h.01`})]}),react:(0,L.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,L.jsx)(`path`,{d:`M20.5 11A8.5 8.5 0 1 1 13 3.5`}),(0,L.jsx)(`path`,{d:`M8 14s1.5 2 4 2 4-2 4-2M9 9h.01M15 9h.01M19 2v6M16 5h6`})]}),search:(0,L.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,children:[(0,L.jsx)(`circle`,{cx:`11`,cy:`11`,r:`8`}),(0,L.jsx)(`path`,{d:`M21 21l-4.35-4.35`})]})};function sr({onDragStart:e,pushButton:t=!0}){let{order:n,open:r,conversations:i,contacts:a,online:o,mobile:s,openChat:c,removeHead:l,picker:u,setPicker:d,status:f,push:p,enablePush:m,newChatButton:h}=F(y(e=>({order:e.order,open:e.open,conversations:e.conversations,contacts:e.contacts,online:e.online,mobile:e.mobile,openChat:e.openChat,removeHead:e.removeHead,picker:e.picker,setPicker:e.setPicker,status:e.status,push:e.push,enablePush:e.enablePush,newChatButton:e.newChatButton})));return(0,L.jsxs)(`div`,{className:`ci-flex ci-flex-col-reverse ci-items-center ci-gap-3 ci-mb-3 ci-cursor-grab active:ci-cursor-grabbing ci-touch-none`,onPointerDown:e,children:[n.map(e=>{let t=i[e],n=r===e;return(0,L.jsxs)(`div`,{className:`ci-relative ci-group`,children:[(0,L.jsxs)(`button`,{type:`button`,title:t?.kind===`group`?t.name??e:a[e]?.name??e,onClick:()=>n?F.getState().closeChat():c(e),className:`ci-relative ci-rounded-full ci-shadow-lg ci-transition-transform hover:ci-scale-105 ci-ring-2 ci-border-0 ci-p-0 ci-bg-transparent ${n?`ci-ring-iconSecondary dark:ci-ring-iconSecondaryDark`:`ci-ring-gray-50 dark:ci-ring-gray-950`}`,children:[t?.kind===`group`?(0,L.jsx)(rr,{name:t.name??e,size:48,avatar:t.avatar}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(tr,{contact:a[e],username:e,size:48}),(0,L.jsx)(nr,{online:o[e],presence:a[e]?.presence,mobile:s[e]})]}),t?.unread>0&&(0,L.jsx)(`span`,{className:`ci-absolute ci--top-1 ci--right-1 ci-min-w-5 ci-h-5 ci-px-1 ci-rounded-full ci-bg-phoneIslandClose dark:ci-bg-phoneIslandCloseDark ci-text-white dark:ci-text-gray-950 ci-text-xs ci-font-medium ci-flex ci-items-center ci-justify-center`,children:t.unread>99?`99+`:t.unread})]}),(0,L.jsx)(`button`,{type:`button`,"aria-label":`Remove ${t?.kind===`group`?t.name??e:a[e]?.name??e} from the dock`,onClick:()=>l(e),className:`ci-absolute ci--top-1 ci--left-1 ci-hidden group-hover:ci-flex group-focus-within:ci-flex ci-w-5 ci-h-5 ci-rounded-full ci-border-0 ci-p-0 ci-bg-gray-700 dark:ci-bg-gray-300 ci-text-gray-50 dark:ci-text-gray-900 ci-items-center ci-justify-center`,children:R.close})]},e)}),h&&(0,L.jsxs)(or,{variant:`default`,title:f===`online`?`New chat`:`Chat ${f}`,onClick:()=>d(!u),className:`ci-relative ci-shadow-lg`,children:[R.chat,f!==`online`&&(0,L.jsx)(`span`,{className:`ci-absolute ci-bottom-0 ci-right-0 ci-w-3 ci-h-3 ci-rounded-full ci-bg-phoneIslandClose dark:ci-bg-phoneIslandCloseDark ci-ring-2 ci-ring-gray-50 dark:ci-ring-gray-950`})]}),t&&p===`ask`&&f===`online`&&(0,L.jsx)(or,{variant:`neutral`,title:`Enable notifications when the tab is closed`,onClick:m,className:`ci-shadow-lg ci-bg-gray-50 dark:ci-bg-gray-950`,children:R.bell})]})}var cr={"+1":`๐`,thumbsup:`๐`,"-1":`๐`,thumbsdown:`๐`,ok_hand:`๐`,clap:`๐`,pray:`๐`,wave:`๐`,raised_hands:`๐`,muscle:`๐ช`,point_up:`โ๏ธ`,point_right:`๐`,point_left:`๐`,point_down:`๐`,v:`โ๏ธ`,crossed_fingers:`๐ค`,handshake:`๐ค`,eyes:`๐`,facepalm:`๐คฆ`,shrug:`๐คท`,raising_hand:`๐`,heart:`โค๏ธ`,broken_heart:`๐`,orange_heart:`๐งก`,yellow_heart:`๐`,green_heart:`๐`,blue_heart:`๐`,purple_heart:`๐`,black_heart:`๐ค`,white_heart:`๐ค`,sparkling_heart:`๐`,two_hearts:`๐`,100:`๐ฏ`,fire:`๐ฅ`,star:`โญ`,star2:`๐`,sparkles:`โจ`,zap:`โก`,boom:`๐ฅ`,tada:`๐`,confetti_ball:`๐`,balloon:`๐`,gift:`๐`,birthday:`๐`,cake:`๐ฐ`,trophy:`๐`,medal:`๐
`,rocket:`๐`,white_check_mark:`โ
`,heavy_check_mark:`โ๏ธ`,x:`โ`,warning:`โ ๏ธ`,question:`โ`,exclamation:`โ`,no_entry:`โ`,ok:`๐`,new:`๐`,sos:`๐`,heavy_plus_sign:`โ`,heavy_minus_sign:`โ`,smile:`๐`,smiley:`๐`,grinning:`๐`,grin:`๐`,laughing:`๐`,satisfied:`๐`,sweat_smile:`๐
`,joy:`๐`,rofl:`๐คฃ`,slightly_smiling_face:`๐`,upside_down_face:`๐`,wink:`๐`,blush:`๐`,innocent:`๐`,heart_eyes:`๐`,star_struck:`๐คฉ`,kissing_heart:`๐`,yum:`๐`,stuck_out_tongue:`๐`,stuck_out_tongue_winking_eye:`๐`,zany_face:`๐คช`,money_mouth_face:`๐ค`,hugs:`๐ค`,hugging_face:`๐ค`,shushing_face:`๐คซ`,thinking:`๐ค`,thinking_face:`๐ค`,zipper_mouth_face:`๐ค`,raised_eyebrow:`๐คจ`,neutral_face:`๐`,expressionless:`๐`,no_mouth:`๐ถ`,smirk:`๐`,unamused:`๐`,roll_eyes:`๐`,grimacing:`๐ฌ`,relieved:`๐`,pensive:`๐`,sleepy:`๐ช`,sleeping:`๐ด`,mask:`๐ท`,face_with_thermometer:`๐ค`,nauseated_face:`๐คข`,sneezing_face:`๐คง`,hot_face:`๐ฅต`,cold_face:`๐ฅถ`,dizzy_face:`๐ต`,exploding_head:`๐คฏ`,cowboy_hat_face:`๐ค `,partying_face:`๐ฅณ`,sunglasses:`๐`,nerd_face:`๐ค`,confused:`๐`,worried:`๐`,slightly_frowning_face:`๐`,open_mouth:`๐ฎ`,astonished:`๐ฒ`,flushed:`๐ณ`,pleading_face:`๐ฅบ`,fearful:`๐จ`,cold_sweat:`๐ฐ`,cry:`๐ข`,sob:`๐ญ`,scream:`๐ฑ`,disappointed:`๐`,weary:`๐ฉ`,tired_face:`๐ซ`,yawning_face:`๐ฅฑ`,triumph:`๐ค`,rage:`๐ก`,angry:`๐ `,cursing_face:`๐คฌ`,smiling_imp:`๐`,skull:`๐`,poop:`๐ฉ`,hankey:`๐ฉ`,clown_face:`๐คก`,ghost:`๐ป`,alien:`๐ฝ`,robot:`๐ค`,see_no_evil:`๐`,hear_no_evil:`๐`,speak_no_evil:`๐`,coffee:`โ`,tea:`๐ต`,beer:`๐บ`,beers:`๐ป`,wine_glass:`๐ท`,clinking_glasses:`๐ฅ`,pizza:`๐`,hamburger:`๐`,sunny:`โ๏ธ`,cloud:`โ๏ธ`,rainbow:`๐`,snowflake:`โ๏ธ`,umbrella:`โ`,phone:`โ๏ธ`,telephone_receiver:`๐`,iphone:`๐ฑ`,computer:`๐ป`,email:`๐ง`,calendar:`๐
`,memo:`๐`,pencil2:`โ๏ธ`,paperclip:`๐`,pushpin:`๐`,lock:`๐`,key:`๐`,bulb:`๐ก`,hourglass:`โ`,hourglass_flowing_sand:`โณ`,alarm_clock:`โฐ`,stopwatch:`โฑ๏ธ`,bell:`๐`,mega:`๐ฃ`,loudspeaker:`๐ข`,speech_balloon:`๐ฌ`,thought_balloon:`๐ญ`,moneybag:`๐ฐ`,car:`๐`,airplane:`โ๏ธ`,house:`๐ `,office:`๐ข`,earth_africa:`๐`,globe_with_meridians:`๐`,arrow_right:`โก๏ธ`,arrow_left:`โฌ
๏ธ`,arrow_up:`โฌ๏ธ`,arrow_down:`โฌ๏ธ`,recycle:`โป๏ธ`,zzz:`๐ค`,sweat_drops:`๐ฆ`,dash:`๐จ`},lr=/(```[\s\S]*?(?:```|$)|`[^`\n]*`?)/g,ur=/:([a-z0-9_+-]+):/g,dr=e=>e.replace(ur,(e,t)=>cr[t]??e);function fr(e){return e.includes(`:`)?e.split(lr).map((e,t)=>t%2?e:dr(e)).join(``):e}var pr=[{label:`Smileys`,icon:`๐`,emojis:`๐ ๐ ๐ ๐ ๐ ๐
๐คฃ ๐ ๐ ๐ ๐ ๐ ๐ ๐ฅฐ ๐ ๐คฉ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐คช ๐ ๐ค ๐ค ๐คญ ๐คซ ๐ค ๐ค ๐คจ ๐ ๐ ๐ถ ๐ ๐ ๐ ๐ฌ ๐ ๐ ๐ช ๐คค ๐ด ๐ท ๐ค ๐ค ๐คข ๐คฎ ๐คง ๐ฅต ๐ฅถ ๐ฅด ๐ต ๐คฏ ๐ค ๐ฅณ ๐ ๐ค ๐ง ๐ ๐ ๐ โน๏ธ ๐ฎ ๐ฏ ๐ฒ ๐ณ ๐ฅบ ๐ฆ ๐ง ๐จ ๐ฐ ๐ฅ ๐ข ๐ญ ๐ฑ ๐ ๐ฃ ๐ ๐ ๐ฉ ๐ซ ๐ฅฑ ๐ค ๐ก ๐ ๐คฌ ๐ ๐ ๐ฉ ๐คก ๐ป ๐ฝ ๐ค`},{label:`Gestures`,icon:`๐`,emojis:`๐ ๐ ๐ ๐ค ๐ค โ๏ธ ๐ค ๐ค ๐ค ๐ค ๐ ๐ ๐ ๐ โ๏ธ โ ๐ค ๐๏ธ ๐ ๐ ๐ ๐ ๐ ๐คฒ ๐ค ๐ โ๏ธ ๐ช ๐ซถ ๐ ๐ง ๐ ๐ ๐
๐คท ๐คฆ ๐`},{label:`Hearts and symbols`,icon:`โค๏ธ`,emojis:`โค๏ธ ๐งก ๐ ๐ ๐ ๐ ๐ค ๐ค ๐ค ๐ โฃ๏ธ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ฏ ๐ข ๐ฅ ๐ซ ๐ฆ ๐จ ๐ฅ โจ โญ ๐ โ
โ โ ๏ธ โ โ โ โ ๐ ๐ ๐ด ๐ข ๐ก ๐ต`},{label:`Celebrations`,icon:`๐`,emojis:`๐ ๐ ๐ ๐ ๐ ๐ฐ ๐ฅ ๐พ ๐ป ๐บ ๐ท ๐ ๐ฅ ๐ฅ ๐ฅ ๐
๐ฏ ๐ฎ โฝ ๐ ๐พ ๐ด ๐ ๐ต ๐ถ ๐ธ ๐ฌ`},{label:`Work`,icon:`๐ผ`,emojis:`๐ผ ๐ โ๏ธ ๐ฑ ๐ป ๐ฅ๏ธ โจ๏ธ ๐จ๏ธ ๐ง ๐จ ๐ฉ ๐
๐ ๐๏ธ ๐ ๐ ๐ โ๏ธ ๐ โ๏ธ ๐ ๐ ๐๏ธ ๐ ๐ ๐ ๐ ๐ ๐ ๐ง ๐ ๏ธ โ๏ธ ๐ก ๐ โฐ โณ โ ๐งพ ๐ถ ๐ฐ`},{label:`Food and places`,icon:`โ`,emojis:`โ ๐ต ๐ฅค ๐ ๐ ๐ ๐ญ ๐ฅช ๐ฎ ๐ ๐ฃ ๐ฉ ๐ช ๐ซ ๐ ๐ ๐ ๐ฅ ๐ ๐ ๐ ๐ โ๏ธ ๐ ๐ ๐ข ๐๏ธ ๐ โ๏ธ ๐ค๏ธ ๐ง๏ธ โ๏ธ โ๏ธ โก ๐ ๐`}],mr=[`๐`,`โค๏ธ`,`๐`,`๐ฎ`,`๐ข`,`๐`];function hr({onPick:e,onClose:t,className:n=``}){let[r,i]=(0,g.useState)(0),a=(0,g.useRef)(null);return(0,g.useEffect)(()=>{let e=e=>a.current&&!a.current.contains(e.target)&&t(),n=e=>{e.key===`Escape`&&(e.stopPropagation(),t())};return document.addEventListener(`pointerdown`,e,!0),document.addEventListener(`keydown`,n,!0),()=>{document.removeEventListener(`pointerdown`,e,!0),document.removeEventListener(`keydown`,n,!0)}},[t]),(0,L.jsxs)(`div`,{ref:a,role:`dialog`,"aria-label":`Emoji`,className:`ci-z-30 ci-w-[21rem] ci-max-w-full ci-rounded-2xl ci-bg-gray-50 dark:ci-bg-gray-950 ci-shadow-2xl ci-ring-1 ci-ring-gray-300 dark:ci-ring-gray-700 ci-select-none ${n}`,children:[(0,L.jsx)(`div`,{className:`ci-flex ci-gap-1 ci-px-2 ci-pt-2 ci-border-b ci-border-gray-300 dark:ci-border-gray-700`,children:pr.map((e,t)=>(0,L.jsx)(`button`,{type:`button`,title:e.label,"aria-label":e.label,onClick:()=>i(t),style:{fontSize:20,lineHeight:`28px`},className:`ci-flex-1 ci-pb-1.5 ci-border-0 ci-bg-transparent ci-border-b-2 ci-border-solid ${t===r?`ci-border-iconSecondary dark:ci-border-iconSecondaryDark`:`ci-border-transparent ci-opacity-60 hover:ci-opacity-100`}`,children:e.icon},e.label))}),(0,L.jsx)(`div`,{className:`ci-grid ci-grid-cols-7 ci-gap-1 ci-p-2 ci-h-64 ci-overflow-y-auto`,children:pr[r].emojis.split(` `).map(t=>(0,L.jsx)(`button`,{type:`button`,onClick:()=>e(t),style:{fontSize:26,lineHeight:`36px`},className:`ci-h-10 ci-w-10 ci-flex ci-items-center ci-justify-center ci-rounded-lg ci-border-0 ci-bg-transparent hover:ci-bg-gray-200 dark:hover:ci-bg-gray-800`,children:t},t))})]})}var gr=e=>/\.(png|jpe?g|gif|webp|avif|svg)(\?|$)/i.test(e),_r=e=>/\.(webm|ogg|oga|opus|mp3|m4a|wav)(\?|$)/i.test(e),vr=e=>{let t=e.split(`/`).pop()||`file`;try{return decodeURIComponent(t)}catch{return t}},yr=e=>{try{return new URL(e).protocol===`https:`}catch{return!1}},br=e=>new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}),xr=e=>new Date(e).toLocaleDateString([],{weekday:`short`,day:`numeric`,month:`short`}),Sr=(e,t)=>new Date(e).toDateString()===new Date(t).toDateString(),Cr=e=>{if(!e.startsWith(`{"`))return null;try{let t=JSON.parse(e);return!Array.isArray(t.attachments)||!t.attachments.length?null:{text:typeof t.body==`string`&&t.body?t.body:void 0,count:t.attachments.length}}catch{return null}},wr=(0,g.memo)(function({url:e}){return yr(e)?gr(e)?(0,L.jsx)(`a`,{href:e,target:`_blank`,rel:`noreferrer`,children:(0,L.jsx)(`img`,{src:e,alt:vr(e),className:`ci-max-w-full ci-max-h-60 ci-rounded-2xl ci-block`})}):_r(e)?(0,L.jsx)(`audio`,{controls:!0,src:e,className:`ci-max-w-full`}):(0,L.jsxs)(`a`,{href:e,target:`_blank`,rel:`noreferrer`,className:`ci-underline ci-break-all ci-flex ci-items-center ci-gap-1`,children:[(0,L.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,children:(0,L.jsx)(`path`,{d:`M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48`})}),vr(e)]}):(0,L.jsx)(`span`,{className:`ci-break-all`,children:e})}),Tr=/(`[^`\n]+`)|(\*\*[^*\n]+\*\*|__[^_\n]+__)|(~~[^~\n]+~~)|(\*[^*\s][^*\n]*\*|_[^_\s][^_\n]*_)|\[([^\]\n]+)\]\((https?:\/\/[^\s)]+)\)|(https?:\/\/[^\s<]+)/g;function Er({text:e}){let t=[],n=0;for(let r of e.matchAll(Tr)){let i=r[0],a=r.index??0;a>n&&t.push(fr(e.slice(n,a))),r[1]?t.push((0,L.jsx)(`code`,{className:`ci-px-1 ci-py-0.5 ci-rounded ci-bg-black/10 dark:ci-bg-white/10 ci-font-mono ci-text-[0.85em]`,children:i.slice(1,-1)},a)):r[2]?t.push((0,L.jsx)(`strong`,{children:i.slice(2,-2)},a)):r[3]?t.push((0,L.jsx)(`s`,{children:i.slice(2,-2)},a)):r[4]?t.push((0,L.jsx)(`em`,{children:i.slice(1,-1)},a)):r[5]?t.push((0,L.jsx)(`a`,{href:r[6],target:`_blank`,rel:`noreferrer`,className:`ci-underline`,children:r[5]},a)):t.push((0,L.jsx)(`a`,{href:i,target:`_blank`,rel:`noreferrer`,className:`ci-underline ci-break-all`,children:i},a)),n=a+i.length}return n<e.length&&t.push(fr(e.slice(n))),(0,L.jsx)(L.Fragment,{children:t})}var Dr=(0,g.memo)(function({text:e}){let t=e.split(/```[^\n]*\n?([\s\S]*?)```/g);return(0,L.jsx)(`span`,{className:`ci-whitespace-pre-wrap ci-break-words`,children:t.map((e,t)=>t%2?(0,L.jsx)(`pre`,{className:`ci-my-1 ci-p-2 ci-rounded-xl ci-bg-black/10 dark:ci-bg-white/10 ci-font-mono ci-text-xs ci-overflow-x-auto ci-whitespace-pre`,children:e.replace(/\n$/,``)},t):(0,L.jsx)(Er,{text:e.replace(/^(\s*)[-*] (?=\S)/gm,`$1โข `)},t))})});function Or({text:e,count:t}){return(0,L.jsxs)(`span`,{className:`ci-italic ci-opacity-80`,children:[e&&(0,L.jsx)(`span`,{className:`ci-not-italic ci-block`,children:e}),t>1?`${t} attachments`:`Attachment`,` from the mobile app, not available here`]})}function kr({forMsg:e,me:t,onReact:n,nameOf:r,mine:i}){if(!e)return null;let a=new Map;for(let[t,n]of Object.entries(e))for(let e of n)a.set(e,[...a.get(e)??[],t]);return a.size?(0,L.jsx)(`div`,{className:`ci-flex ci-flex-wrap ci-gap-1 ci--mt-1.5 ci-relative ci-z-[1] ${i?`ci-justify-end ci-pr-2`:`ci-pl-2`}`,children:[...a.entries()].map(([e,i])=>{let a=i.includes(t);return(0,L.jsxs)(`button`,{type:`button`,title:i.map(e=>e===t?`You`:r(e)).join(`, `),"aria-label":`${e} ${i.length}${a?`, yours: press to remove`:``}`,onClick:()=>n(e),className:`ci-flex ci-items-center ci-gap-0.5 ci-h-6 ci-px-1.5 ci-rounded-full ci-text-xs ci-border ci-border-solid ci-shadow-sm ${a?`ci-bg-emerald-50 ci-border-emerald-400 dark:ci-bg-emerald-950 dark:ci-border-emerald-600`:`ci-bg-gray-50 ci-border-gray-300 dark:ci-bg-gray-900 dark:ci-border-gray-700`} ci-text-gray-900 dark:ci-text-white`,children:[(0,L.jsx)(`span`,{style:{fontSize:16,lineHeight:`20px`},children:e}),i.length>1&&(0,L.jsx)(`span`,{children:i.length})]},e)})}):null}function Ar({messages:e,typing:t,onLoadOlder:n,hasOlder:r,group:i,reactions:a,me:o=``,onReact:s}){let c=F(e=>e.contacts),l=(0,g.useRef)(null),u=(0,g.useRef)(!0),[d,f]=(0,g.useState)(null),[p,m]=(0,g.useState)(null),h=e=>c[e]?.name??e;(0,g.useEffect)(()=>{let e=l.current;e&&u.current&&(e.scrollTop=e.scrollHeight)},[e.length,t,a]),(0,g.useEffect)(()=>{if(!d)return;let e=()=>f(null),t=window.setTimeout(()=>document.addEventListener(`click`,e,{once:!0}),0);return()=>{window.clearTimeout(t),document.removeEventListener(`click`,e)}},[d]);let _=()=>{let e=l.current;e&&(u.current=e.scrollHeight-e.scrollTop-e.clientHeight<40,e.scrollTop<30&&r&&n())},v=(e,t)=>{f(null),m(null),s?.(e,t)};return(0,L.jsxs)(`div`,{className:`ci-relative ci-flex-1 ci-min-h-0 ci-flex ci-flex-col`,children:[(0,L.jsxs)(`div`,{ref:l,onScroll:_,className:`ci-flex-1 ci-overflow-y-auto ci-px-4 ci-py-2 ci-space-y-1`,children:[r&&(0,L.jsx)(`div`,{className:`ci-text-center ci-text-xs ci-text-gray-500 dark:ci-text-gray-400 ci-py-1`,children:`Scroll up for older messages`}),e.map((t,n)=>{let r=e[n-1],l=!r||!Sr(r.ts,t.ts),u=r&&!l&&r.mine===t.mine&&r.nick===t.nick&&t.ts-r.ts<12e4,p=i&&!t.mine&&t.nick?h(t.nick):null,g=t.oid,_=!!s&&!!g&&!t.pending,y=_&&(0,L.jsx)(`button`,{type:`button`,title:`React`,"aria-label":`React to this message`,onClick:e=>{e.stopPropagation(),f(d===g?null:g)},className:`ci-self-center ci-h-7 ci-w-7 ci-shrink-0 ci-flex ci-items-center ci-justify-center ci-rounded-full ci-border-0 ci-bg-transparent ci-text-gray-500 dark:ci-text-gray-400 hover:ci-bg-gray-200 dark:hover:ci-bg-gray-800 focus:ci-opacity-100 ${d===g?`ci-opacity-100`:`ci-opacity-0 group-hover:ci-opacity-100`}`,children:R.react});return(0,L.jsxs)(`div`,{children:[l&&(0,L.jsx)(`div`,{className:`ci-text-center ci-text-xs ci-text-gray-500 dark:ci-text-gray-400 ci-py-2`,children:xr(t.ts)}),(0,L.jsxs)(`div`,{className:`ci-group ci-flex ci-items-start ci-gap-1.5 ${t.mine?`ci-justify-end`:`ci-justify-start`} ${u?`ci-mt-0.5`:`ci-mt-2`}`,children:[p&&(0,L.jsx)(`span`,{className:`ci-w-7 ci-shrink-0`,title:p,children:!u&&(0,L.jsx)(tr,{contact:c[t.nick],username:t.nick,size:28})}),t.mine&&y,(0,L.jsxs)(`div`,{className:`ci-relative ci-flex ci-flex-col ci-max-w-[80%] ${t.mine?`ci-items-end`:`ci-items-start`}`,children:[d===g&&g&&(0,L.jsxs)(`div`,{role:`menu`,onClick:e=>e.stopPropagation(),className:`ci-absolute ci-bottom-full ci-mb-1 ci-z-20 ci-flex ci-items-center ci-gap-0.5 ci-p-1 ci-rounded-full ci-bg-gray-50 dark:ci-bg-gray-950 ci-shadow-xl ci-ring-1 ci-ring-gray-300 dark:ci-ring-gray-700 ${t.mine?`ci-right-0`:`ci-left-0`}`,children:[mr.map(e=>(0,L.jsx)(`button`,{type:`button`,role:`menuitem`,"aria-label":e,onClick:()=>v(g,e),style:{fontSize:22,lineHeight:`32px`},className:`ci-h-9 ci-w-9 ci-flex ci-items-center ci-justify-center ci-rounded-full ci-border-0 hover:ci-scale-125 ci-transition-transform ${a?.[g]?.[o]?.includes(e)?`ci-bg-gray-200 dark:ci-bg-gray-800`:`ci-bg-transparent`}`,children:e},e)),(0,L.jsx)(`button`,{type:`button`,role:`menuitem`,title:`More emojis`,"aria-label":`More emojis`,onClick:()=>{f(null),m(g)},className:`ci-h-8 ci-w-8 ci-flex ci-items-center ci-justify-center ci-rounded-full ci-border-0 ci-bg-gray-200 dark:ci-bg-gray-800 ci-text-gray-700 dark:ci-text-gray-200 ci-text-lg`,children:`+`})]}),(0,L.jsxs)(`div`,{title:br(t.ts),onDoubleClick:()=>_&&v(g,mr[0]),className:`ci-px-3.5 ci-py-2 ci-rounded-3xl ci-text-sm ci-select-text ci-cursor-text ${t.mine?`ci-bg-gray-700 ci-text-gray-50 dark:ci-bg-gray-300 dark:ci-text-gray-900 ci-rounded-br-lg`:`ci-bg-elevationL2 ci-text-gray-900 dark:ci-bg-elevationL2Dark dark:ci-text-white ci-rounded-bl-lg`} ${t.pending?`ci-opacity-60`:``}`,children:[t.oob?(0,L.jsx)(wr,{url:t.oob}):Cr(t.body)?(0,L.jsx)(Or,{...Cr(t.body)}):(0,L.jsx)(Dr,{text:t.body}),t.oob&&t.body&&t.body!==t.oob&&t.body!==vr(t.oob)&&(0,L.jsx)(`div`,{className:`ci-text-xs ci-opacity-80 ci-mt-1`,children:t.body}),(0,L.jsx)(`span`,{className:`ci-block ci-text-right ci-text-[10px] ci-leading-none ci-opacity-60 ci-mt-1`,children:br(t.ts)})]}),g&&(0,L.jsx)(kr,{forMsg:a?.[g],me:o,mine:t.mine,nameOf:h,onReact:e=>_&&v(g,e)})]}),!t.mine&&y]})]},t.id)}),t&&(0,L.jsx)(`div`,{className:`ci-flex ci-justify-start ci-mt-2`,children:(0,L.jsx)(`div`,{className:`ci-px-3.5 ci-py-2 ci-rounded-3xl ci-bg-elevationL2 dark:ci-bg-elevationL2Dark ci-text-gray-500 dark:ci-text-gray-400 ci-text-xs ci-italic`,children:`typingโฆ`})})]}),p&&(0,L.jsx)(hr,{className:`ci-absolute ci-bottom-2 ci-left-1/2 ci--translate-x-1/2`,onPick:e=>v(p,e),onClose:()=>m(null)})]})}function jr(e,t,n){let r=e[t];if(r===void 0)return null;let i=1;for(;i<=8&&!(r&128>>i-1);)i++;if(i>8||t+i>e.length)return null;let a=n?r:r&255>>i,o=a===255>>i;for(let n=1;n<i;n++)a=a*256+e[t+n],e[t+n]!==255&&(o=!1);return{value:a,len:i,unknown:!n&&o}}var Mr=new Set([408125543,524531317,374648427,174,225,160]);function Nr(e){let t={channels:1,packets:[]},n=0;for(;n<e.length;){let r=jr(e,n,!0);if(!r)break;let i=jr(e,n+r.len,!1);if(!i)break;let a=n+r.len+i.len;if(Mr.has(r.value)){n=a;continue}if(i.unknown)break;let o=Math.min(e.length,a+i.value);if(r.value===25506)t.head=e.slice(a,o);else if(r.value===159)t.channels=e[a]||1;else if(r.value===163||r.value===161){let n=jr(e,a,!1);n&&(e[a+n.len+2]>>1&3||t.packets.push(e.slice(a+n.len+3,o)))}n=o}return t}function Pr(e){if(!e.length)return 0;let t=e[0],n=t>>3,r;r=n<12?[10,20,40,60][n%4]:n<16?[10,20][n%2]:[2.5,5,10,20][n%4];let i=t&3,a=i===0?1:i===3?(e[1]??0)&63:2;return Math.round(a*r*48)}var Fr=(()=>{let e=new Uint32Array(256);for(let t=0;t<256;t++){let n=t<<24;for(let e=0;e<8;e++)n=n&2147483648?n<<1^79764919:n<<1;e[t]=n>>>0}return e})();function Ir(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<8^Fr[(t>>>24^e[n])&255])>>>0;return t}function Lr(e,t,n,r,i){let a=[];for(let t of e){let e=t.length;for(;e>=255;)a.push(255),e-=255;a.push(e)}let o=e.reduce((e,t)=>e+t.length,0),s=new Uint8Array(27+a.length+o),c=new DataView(s.buffer);s.set([79,103,103,83],0),s[5]=i,c.setUint32(6,t%4294967296,!0),c.setUint32(10,Math.floor(t/4294967296),!0),c.setUint32(14,n,!0),c.setUint32(18,r,!0),s[26]=a.length,s.set(a,27);let l=27+a.length;for(let t of e)s.set(t,l),l+=t.length;return c.setUint32(22,Ir(s),!0),s}function Rr(e){let t=new Uint8Array(19),n=new DataView(t.buffer);return t.set(new TextEncoder().encode(`OpusHead`),0),t[8]=1,t[9]=e,n.setUint16(10,312,!0),n.setUint32(12,48e3,!0),t}function zr(){let e=new TextEncoder().encode(`chat-island`),t=new Uint8Array(12+e.length+4);return t.set(new TextEncoder().encode(`OpusTags`),0),new DataView(t.buffer).setUint32(8,e.length,!0),t.set(e,12),t}function Br(e){let{head:t,channels:n,packets:r}=Nr(e);if(!r.length)return null;let i=t&&t.length>=19&&new TextDecoder().decode(t.slice(0,8))===`OpusHead`,a=Math.random()*4294967295>>>0,o=[Lr([i?t:Rr(n)],0,a,0,2),Lr([zr()],0,a,1,0)],s=0,c=2;for(let e=0;e<r.length;){let t=[],n=0;for(;e<r.length&&t.length<50;){let i=Math.floor(r[e].length/255)+1;if(n+i>255)break;t.push(r[e]),n+=i,s+=Pr(r[e]),e++}if(!t.length)return null;o.push(Lr(t,s,a,c++,e>=r.length?4:0))}let l=o.reduce((e,t)=>e+t.length,0),u=new Uint8Array(l),d=0;for(let e of o)u.set(e,d),d+=e.length;return u}var Vr=[`audio/ogg;codecs=opus`,`audio/webm;codecs=opus`,`audio/mp4`,`audio/webm`];async function Hr(e,t){let n=Date.now();if(/webm/.test(t)&&/opus/.test(t))try{let t=Br(new Uint8Array(await new Blob(e).arrayBuffer()));if(t)return new File([t],`voice-${n}.ogg`,{type:`audio/ogg`})}catch{}return new File(e,`voice-${n}.${Ur(t)}`,{type:t.split(`;`)[0]})}var Ur=e=>/mp4/.test(e)?`m4a`:/ogg/.test(e)?`ogg`:`webm`,Wr=e=>`${Math.floor(e/6e4)}:${String(Math.floor(e%6e4/1e3)).padStart(2,`0`)}`;function Gr({onSend:e,onTyping:t,onFile:n,disabled:r}){let[i,a]=(0,g.useState)(``),[o,s]=(0,g.useState)(!1),c=(0,g.useRef)(null),l=(0,g.useRef)(null),u=(0,g.useRef)(null),d=(0,g.useRef)(),f=(0,g.useRef)(!1),[p,m]=(0,g.useState)(null),[h,_]=(0,g.useState)(0),v=(0,g.useRef)(!1),y=(0,g.useRef)(!1),b=(0,g.useRef)(!1),x=(0,g.useRef)({});(0,g.useEffect)(()=>u.current?.focus(),[]),(0,g.useEffect)(()=>()=>{b.current=!0,v.current=!0,window.clearTimeout(d.current);let{r:e,stream:t}=x.current;e&&e.state!==`inactive`&&e.stop(),t?.getTracks().forEach(e=>e.stop()),x.current={}},[]),(0,g.useEffect)(()=>{if(!p)return;let e=window.setInterval(()=>_(Date.now()-p.since),250);return()=>window.clearInterval(e)},[p]);let S=e=>{f.current!==e&&(f.current=e,t(e))},C=e=>{let t=e.includes(`:`)?fr(e):e;t!==e&&(c.current=Math.max(0,(u.current?.selectionStart??e.length)-(e.length-t.length))),a(t),t?(S(!0),window.clearTimeout(d.current),d.current=window.setTimeout(()=>S(!1),4e3)):S(!1)};(0,g.useLayoutEffect)(()=>{c.current!==null&&(u.current?.setSelectionRange(c.current,c.current),c.current=null)},[i]);let w=e=>{let t=u.current,n=t?.selectionStart??i.length,r=t?.selectionEnd??n;C(i.slice(0,n)+e+i.slice(r)),requestAnimationFrame(()=>{t?.focus(),t?.setSelectionRange(n+e.length,n+e.length)})},T=()=>{let t=i.trim();t&&(a(``),Promise.resolve(e(t)).catch(()=>a(e=>e||t)),window.clearTimeout(d.current),f.current=!1)},ee=async()=>{if(y.current||p)return;y.current=!0;let e;try{e=await navigator.mediaDevices.getUserMedia({audio:!0});let t=e;if(b.current){t.getTracks().forEach(e=>e.stop());return}let r=Vr.find(e=>MediaRecorder.isTypeSupported(e)),i=new MediaRecorder(e,r?{mimeType:r}:void 0),a=[];i.ondataavailable=e=>e.data.size&&a.push(e.data),i.onstop=()=>{t.getTracks().forEach(e=>e.stop()),x.current={},m(null),!v.current&&a.length&&Hr(a,i.mimeType||r||``).then(n)},v.current=!1,i.start(),x.current={r:i,stream:t},_(0),m({r:i,since:Date.now()})}catch{e?.getTracks().forEach(e=>e.stop())}finally{y.current=!1}},E=e=>{v.current=e,p?.r.stop()};return p?(0,L.jsxs)(`div`,{className:`ci-flex ci-items-center ci-gap-2 ci-px-3 ci-py-3`,children:[(0,L.jsx)(or,{variant:`transparent`,title:`Discard`,"aria-label":`Discard`,onClick:()=>E(!0),className:`ci-h-10 ci-w-10`,children:R.close}),(0,L.jsxs)(`div`,{className:`ci-flex-1 ci-flex ci-items-center ci-gap-2 ci-px-4 ci-py-2.5 ci-rounded-3xl ci-bg-elevationL2 dark:ci-bg-elevationL2Dark ci-text-sm`,children:[(0,L.jsx)(`span`,{className:`ci-w-2.5 ci-h-2.5 ci-rounded-full ci-bg-phoneIslandClose dark:ci-bg-phoneIslandCloseDark ci-animate-pulse`}),(0,L.jsxs)(`span`,{children:[`Recording `,Wr(h)]})]}),(0,L.jsx)(or,{variant:`green`,title:`Send voice note`,"aria-label":`Send voice note`,onClick:()=>E(!1),className:`ci-h-10 ci-w-10`,children:R.send})]}):(0,L.jsxs)(`div`,{className:`ci-relative ci-flex ci-items-center ci-gap-2 ci-px-3 ci-py-3`,children:[o&&(0,L.jsx)(hr,{className:`ci-absolute ci-bottom-full ci-left-3 ci-mb-1`,onPick:w,onClose:()=>s(!1)}),(0,L.jsx)(`input`,{ref:l,type:`file`,hidden:!0,onChange:e=>e.target.files?.[0]&&(n(e.target.files[0]),e.target.value=``)}),(0,L.jsx)(or,{variant:`transparent`,disabled:r,title:`Attach a file`,onClick:()=>l.current?.click(),className:`ci-h-10 ci-w-10`,children:R.clip}),(0,L.jsxs)(`div`,{className:`ci-relative ci-flex-1 ci-min-w-0`,children:[(0,L.jsx)(`button`,{type:`button`,disabled:r,title:`Emoji`,"aria-label":`Emoji`,"aria-expanded":o,onClick:()=>s(e=>!e),className:`ci-absolute ci-left-2 ci-bottom-1 ci-z-10 ci-h-8 ci-w-8 ci-flex ci-items-center ci-justify-center ci-rounded-full ci-border-0 ci-bg-transparent ci-text-secondaryNeutral dark:ci-text-secondaryNeutralDark hover:ci-bg-gray-300/70 dark:hover:ci-bg-gray-700/30 disabled:ci-opacity-40`,children:R.smile}),(0,L.jsx)(`textarea`,{ref:u,value:i,disabled:r,rows:1,placeholder:r?`Connectingโฆ`:`Write a message`,onChange:e=>C(e.target.value),onKeyDown:e=>{let t=(i.match(/```/g)??[]).length%2==1;e.key===`Enter`&&!e.shiftKey&&!t&&(e.preventDefault(),T())},className:`ci-block ci-w-full ci-resize-none ci-max-h-32 ci-pl-11 ci-pr-4 ci-py-2.5 ci-rounded-3xl ci-border-0 ci-bg-elevationL2 dark:ci-bg-elevationL2Dark ci-text-gray-900 dark:ci-text-white placeholder:ci-text-gray-500 dark:placeholder:ci-text-gray-400 ci-outline-none focus:ci-ring-2 focus:ci-ring-gray-400 dark:focus:ci-ring-gray-500 ci-text-sm`,style:{height:Math.min(128,40+20*(i.split(`
|
|
9
|
-
`).length-1))}})]}),i.trim()?(0,L.jsx)(or,{variant:`default`,disabled:r,onClick:T,title:`Send`,className:`ci-h-10 ci-w-10`,children:R.send}):(0,L.jsx)(or,{variant:`default`,disabled:r||typeof MediaRecorder>`u`,onClick:ee,title:`Record a voice note`,"aria-label":`Record a voice note`,className:`ci-h-10 ci-w-10`,children:R.mic})]})}var Kr=e=>!!e&&![`offline`,`dnd`,`busy`,`ringing`,`onhold`].includes(e);function qr({peer:e,actions:t,onDragStart:n}){let{c:r,contacts:i,online:a,mobile:o,status:s,closeChat:c,openChat:l,markRead:u,order:d,me:f}=F(y(t=>({c:t.conversations[e],contacts:t.contacts,online:t.online,mobile:t.mobile,status:t.status,closeChat:t.closeChat,openChat:t.openChat,markRead:t.markRead,order:t.order,me:t.me}))),p=Math.max(0,d.indexOf(e)),m=i[e],[h,_]=(0,g.useState)(!1),v=e=>e===f?`You`:i[e]?.name??e,b=[...r?.members??[]].sort((e,t)=>Number(e===f)-Number(t===f));return(0,g.useEffect)(()=>{r&&!r.loaded&&t.loadOlder(e)},[e,r?.loaded]),(0,g.useEffect)(()=>{u(e)},[e,r?.messages.length]),(0,g.useEffect)(()=>_(!1),[e]),r?(0,L.jsxs)(`div`,{role:`dialog`,"aria-label":r.kind===`group`?r.name??e:m?.name??e,onKeyDown:e=>{e.key===`Escape`&&(e.stopPropagation(),h?_(!1):c())},className:`ci-relative ci-w-[22rem] ci-h-[30rem] ci-flex ci-flex-col ci-rounded-3xl ci-shadow-2xl ci-bg-gray-50 dark:ci-bg-gray-950 ci-text-gray-900 dark:ci-text-white`,children:[(0,L.jsx)(`span`,{className:`ci-absolute ci--right-1.5 ci-w-3 ci-h-3 ci-rotate-45 ci-bg-gray-50 dark:ci-bg-gray-950 ci-shadow-2xl ci-transition-all ci-duration-200`,style:{bottom:`calc(1.875rem + ${p} * 3.75rem)`},"aria-hidden":`true`}),(0,L.jsxs)(`div`,{className:`ci-flex ci-items-center ci-gap-3 ci-px-4 ci-py-3 ci-cursor-grab active:ci-cursor-grabbing ci-touch-none ci-rounded-t-3xl`,onPointerDown:n,children:[r.kind===`group`?(0,L.jsx)(rr,{name:r.name??e,size:36,avatar:r.avatar}):(0,L.jsxs)(`span`,{className:`ci-relative`,children:[(0,L.jsx)(tr,{contact:m,username:e,size:36}),(0,L.jsx)(nr,{online:a[e],presence:m?.presence,mobile:o[e]})]}),(0,L.jsxs)(`div`,{className:`ci-flex-1 ci-min-w-0 ${r.kind===`group`?`ci-cursor-pointer`:``}`,...r.kind===`group`?{role:`button`,tabIndex:0,"aria-expanded":h,onKeyDown:e=>(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),_(e=>!e))}:{},onClick:()=>r.kind===`group`&&_(e=>!e),children:[(0,L.jsx)(`div`,{className:`ci-font-medium ci-truncate ci-text-sm`,children:r.kind===`group`?r.name??e:m?.name??e}),(0,L.jsx)(`div`,{className:`ci-text-xs ci-text-gray-500 dark:ci-text-gray-400 ci-truncate`,children:s===`online`?r.kind===`group`?b.map(v).join(`, `):r.typing?`typingโฆ`:a[e]?`online`:o[e]?`Mobile`:`offline`:s})]}),r.kind!==`group`&&m?.number&&Kr(m.presence)&&(0,L.jsx)(or,{variant:`call`,title:`Call ${m.number}`,"aria-label":`Call`,onClick:()=>I(`chat-island-call`,{username:e,number:m.number}),children:R.phone}),(0,L.jsx)(or,{variant:`small`,onClick:()=>c(),"aria-label":`Close`,children:R.close})]}),(0,L.jsx)(`div`,{className:`ci-border-t ci-border-gray-300 dark:ci-border-gray-700`}),h&&r.kind===`group`&&(0,L.jsx)(`div`,{className:`ci-absolute ci-left-3 ci-right-3 ci-top-16 ci-z-10 ci-max-h-64 ci-overflow-y-auto ci-rounded-2xl ci-bg-gray-50 dark:ci-bg-gray-950 ci-shadow-2xl ci-ring-1 ci-ring-gray-300 dark:ci-ring-gray-700 ci-p-2`,children:b.map(e=>(0,L.jsxs)(`div`,{className:`ci-flex ci-items-center ci-gap-3 ci-px-2 ci-py-1.5 ci-text-sm`,children:[(0,L.jsxs)(`span`,{className:`ci-relative`,children:[(0,L.jsx)(tr,{contact:i[e],username:e,size:28}),e!==f&&(0,L.jsx)(nr,{online:a[e],presence:i[e]?.presence,mobile:o[e]})]}),(0,L.jsx)(`span`,{className:`ci-truncate ci-flex-1`,children:v(e)}),e!==f&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(or,{variant:`small`,title:`Chat`,"aria-label":`Chat`,onClick:()=>l(e),children:R.chat}),i[e]?.number&&Kr(i[e]?.presence)&&(0,L.jsx)(or,{variant:`call`,title:`Call ${i[e]?.number}`,"aria-label":`Call`,onClick:()=>I(`chat-island-call`,{username:e,number:i[e].number}),children:R.phone})]})]},e))}),(0,L.jsxs)(`div`,{className:`ci-flex-1 ci-min-h-0 ci-flex ci-flex-col ci-overflow-hidden ci-rounded-b-3xl`,children:[(0,L.jsx)(Ar,{messages:r.messages,typing:r.typing,group:r.kind===`group`,hasOlder:r.loaded&&!r.complete,onLoadOlder:()=>t.loadOlder(e),reactions:r.reactions,me:f,onReact:(n,r)=>t.react(e,n,r)}),(0,L.jsx)(Gr,{disabled:s!==`online`,onSend:n=>t.send(e,n),onTyping:n=>t.typing(e,n),onFile:n=>t.upload(e,n)},e)]})]}):null}async function Jr(e){let t=await createImageBitmap(e),n=Math.min(t.width,t.height),r=document.createElement(`canvas`);return r.width=r.height=128,r.getContext(`2d`)?.drawImage(t,(t.width-n)/2,(t.height-n)/2,n,n,0,0,128,128),r.toDataURL(`image/jpeg`,.8)}function Yr({onOpen:e,onCreateGroup:t}){let{contacts:n,online:r,mobile:i,setPicker:a}=F(),[o,s]=(0,g.useState)(``),[c,l]=(0,g.useState)([]),[u,d]=(0,g.useState)(``),[f,p]=(0,g.useState)(!1),[m,h]=(0,g.useState)(),_=(0,g.useRef)(null),v=(0,g.useMemo)(()=>{let e=Object.values(n),t=o.trim().toLowerCase();return t?e.filter(e=>(e.name??``).toLowerCase().includes(t)||e.username.includes(t)):e},[n,o]),y=e=>l(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]),b=async()=>{p(!0);try{await t(u.trim(),c,m)}finally{p(!1)}};return(0,L.jsxs)(`div`,{className:`ci-w-[22rem] ci-max-h-[30rem] ci-flex ci-flex-col ci-rounded-3xl ci-shadow-2xl ci-overflow-hidden ci-bg-gray-50 dark:ci-bg-gray-950 ci-text-gray-900 dark:ci-text-white`,children:[(0,L.jsxs)(`div`,{className:`ci-px-4 ci-py-3 ci-flex ci-items-center ci-gap-2`,children:[(0,L.jsxs)(`div`,{className:`ci-flex-1 ci-flex ci-items-center ci-gap-2 ci-px-4 ci-py-2 ci-rounded-3xl ci-bg-elevationL2 dark:ci-bg-elevationL2Dark ci-text-gray-500 dark:ci-text-gray-400`,children:[R.search,(0,L.jsx)(`input`,{autoFocus:!0,value:o,onChange:e=>s(e.target.value),placeholder:`Search colleagues`,className:`ci-flex-1 ci-bg-transparent ci-border-0 ci-outline-none ci-text-sm ci-text-gray-900 dark:ci-text-white placeholder:ci-text-gray-500 dark:placeholder:ci-text-gray-400`})]}),(0,L.jsx)(or,{variant:`small`,onClick:()=>a(!1),"aria-label":`Close`,children:R.close})]}),c.length>0&&(0,L.jsx)(`div`,{className:`ci-px-4 ci-pb-2 ci-flex ci-flex-wrap ci-gap-1.5`,children:c.map(e=>(0,L.jsxs)(`button`,{type:`button`,onClick:()=>y(e),className:`ci-flex ci-items-center ci-gap-1 ci-pl-2.5 ci-pr-1.5 ci-py-1 ci-rounded-full ci-text-xs ci-bg-gray-700 ci-text-gray-50 dark:ci-bg-gray-300 dark:ci-text-gray-900 ci-border-0`,children:[n[e]?.name??e,R.close]},e))}),(0,L.jsx)(`div`,{className:`ci-border-t ci-border-gray-300 dark:ci-border-gray-700`}),(0,L.jsxs)(`ul`,{className:`ci-overflow-y-auto ci-py-1 ci-m-0 ci-p-0 ci-list-none ci-flex-1`,children:[v.length===0&&(0,L.jsx)(`li`,{className:`ci-px-4 ci-py-6 ci-text-center ci-text-sm ci-text-gray-500 dark:ci-text-gray-400`,children:`No colleagues found`}),v.map(e=>{let t=c.includes(e.username);return(0,L.jsx)(`li`,{children:(0,L.jsxs)(`button`,{type:`button`,onClick:()=>y(e.username),className:`ci-w-full ci-flex ci-items-center ci-gap-3 ci-px-4 ci-py-2 ci-bg-transparent ci-border-0 ci-text-left hover:ci-bg-gray-300/70 dark:hover:ci-bg-gray-700/30 ci-text-inherit`,children:[(0,L.jsxs)(`span`,{className:`ci-relative`,children:[(0,L.jsx)(tr,{contact:e,username:e.username,size:36}),(0,L.jsx)(nr,{online:r[e.username],presence:e.presence,mobile:i[e.username]})]}),(0,L.jsxs)(`span`,{className:`ci-flex ci-flex-col ci-min-w-0 ci-flex-1`,children:[(0,L.jsx)(`span`,{className:`ci-text-sm ci-font-medium ci-truncate`,children:e.name}),(0,L.jsx)(`span`,{className:`ci-text-xs ci-text-gray-500 dark:ci-text-gray-400 ci-truncate`,children:e.username})]}),(0,L.jsx)(`span`,{className:`ci-w-5 ci-h-5 ci-rounded-full ci-border ci-flex ci-items-center ci-justify-center ${t?`ci-bg-phoneIslandCall dark:ci-bg-phoneIslandCallDark ci-border-transparent ci-text-white dark:ci-text-gray-950`:`ci-border-gray-400 dark:ci-border-gray-600`}`,children:t&&(0,L.jsx)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`3`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,L.jsx)(`path`,{d:`M20 6L9 17l-5-5`})})})]})},e.username)})]}),c.length>0&&(0,L.jsx)(`div`,{className:`ci-border-t ci-border-gray-300 dark:ci-border-gray-700 ci-px-4 ci-py-3 ci-flex ci-items-center ci-gap-2`,children:c.length===1?(0,L.jsx)(or,{variant:`default`,className:`ci-w-auto ci-h-10 ci-px-5`,onClick:()=>e(c[0]),children:`Open chat`}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`input`,{ref:_,type:`file`,accept:`image/*`,hidden:!0,onChange:e=>e.target.files?.[0]&&Jr(e.target.files[0]).then(h).catch(()=>{})}),(0,L.jsx)(`button`,{type:`button`,title:`Group picture`,onClick:()=>_.current?.click(),className:`ci-w-10 ci-h-10 ci-shrink-0 ci-rounded-full ci-border-0 ci-p-0 ci-overflow-hidden ci-bg-elevationL2 dark:ci-bg-elevationL2Dark ci-text-gray-500 dark:ci-text-gray-400 ci-flex ci-items-center ci-justify-center`,children:m?(0,L.jsx)(`img`,{src:m,alt:``,className:`ci-w-full ci-h-full ci-object-cover`}):R.camera}),(0,L.jsx)(`input`,{value:u,onChange:e=>d(e.target.value),placeholder:`Group name`,onKeyDown:e=>e.key===`Enter`&&u.trim()&&!f&&b(),className:`ci-flex-1 ci-min-w-0 ci-w-0 ci-px-4 ci-py-2 ci-rounded-3xl ci-border-0 ci-bg-elevationL2 dark:ci-bg-elevationL2Dark ci-text-sm ci-text-gray-900 dark:ci-text-white placeholder:ci-text-gray-500 dark:placeholder:ci-text-gray-400 ci-outline-none focus:ci-ring-2 focus:ci-ring-gray-400 dark:focus:ci-ring-gray-500`}),(0,L.jsx)(or,{variant:`green`,className:`ci-w-auto ci-h-10 ci-px-4 ci-shrink-0 ci-whitespace-nowrap`,disabled:!u.trim()||f,onClick:b,children:f?`โฆ`:`Create group`})]})})]})}function Xr(){let e=F.getState();return Object.values(e.conversations).map(t=>{let n=t.messages[t.messages.length-1],r=e.contacts[t.peer];return{peer:t.peer,kind:t.kind,name:t.kind===`group`?t.name??t.peer.split(`@`)[0]:r?.name??t.peer,avatar:t.kind===`group`?t.avatar:r?.avatar,online:t.kind!==`group`&&!!e.online[t.peer],mobile:t.kind!==`group`&&!!e.mobile[t.peer],owner:t.kind===`group`?!!t.owner:void 0,unread:t.unread,members:t.members,last:n?{body:$r(n.body),ts:n.ts,mine:n.mine,oob:n.oob,nick:n.nick}:void 0}}).filter(e=>e.last||e.kind===`group`).sort((e,t)=>(t.last?.ts??0)-(e.last?.ts??0))}var Zr=class extends g.Component{state={failed:!1};failures=[];static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(e){I(`chat-island-error`,{scope:`render`,message:e.message});let t=Date.now();this.failures=[...this.failures.filter(e=>t-e<1e4),t],!(this.failures.length>=3)&&(F.getState().closeChat(),window.setTimeout(()=>this.setState({failed:!1}),0))}render(){return this.state.failed?null:this.props.children}};function Qr(e){try{let[t,n,r]=atob(e).split(`:`);return t&&n&&r?{host:t,username:n,token:r}:null}catch{return null}}var $r=e=>(Cr(e)?`Attachment`:fr(e)).replace(/```[^\n]*\n?/g,``).replace(/(\*\*|__|~~|`)/g,``).replace(/(^|\s)[*_](\S[^*_]*)[*_]/g,`$1$2`).replace(/\s+/g,` `).trim();function ei({dataConfig:e,position:t=`bottom-right`,dark:n,serviceWorker:r,maxHeads:i=5,newChatButton:a=!0,notifications:o=`click`,sound:s=!0}){let c=(0,g.useMemo)(()=>Qr(e),[e]),l=(0,g.useRef)(c),u=(0,g.useRef)(s),d=(0,g.useRef)(o);(0,g.useEffect)(()=>{l.current=c,u.current=s,d.current=o},[c,s,o]),(0,g.useEffect)(()=>F.setState({maxHeads:i,newChatButton:a}),[i,a]);let[f,p]=(0,g.useState)(0);(0,g.useEffect)(()=>{let e=e=>e.persisted&&p(e=>e+1);return window.addEventListener(`pageshow`,e),()=>window.removeEventListener(`pageshow`,e)},[]);let m=(0,g.useRef)(null),h=(0,g.useRef)(new Set),_=(0,g.useRef)(!1),v=(0,g.useRef)(null),b=(0,g.useRef)(null),S=x(b,`chat-island-pos:${c?.host??``}:${c?.username??``}`),{open:C,picker:w,status:T}=F(y(e=>({open:e.open,picker:e.picker,status:e.status}))),ee=(0,g.useMemo)(()=>({send:async(e,t)=>{let n=m.current;if(!n)throw Error(`not connected`);try{F.getState().addMessage(e,await n.send(e,fr(t)))}catch(e){throw I(`chat-island-error`,{scope:`send`,message:e.message}),e}},typing:(e,t)=>F.getState().online[e]&&m.current?.typing(e,t).catch(()=>{}),upload:async(e,t)=>{let n=m.current;if(n)try{let r=await n.upload(t);F.getState().addMessage(e,await n.send(e,t.name,r))}catch(e){I(`chat-island-error`,{scope:`upload`,message:e.message})}},createGroup:async(e,t,n)=>{let r=m.current,i=l.current;if(r&&i)try{let a=await r.createGroup(e,t,n),o=F.getState();o.setGroup(a,e,[...t,i.username],n),o.openChat(a)}catch(e){I(`chat-island-error`,{scope:`group`,message:e.message})}},remove:async e=>{let t=m.current,n=l.current;if(!t||!n)return;let r=F.getState().conversations[e];try{r?.kind===`group`&&await t.leaveGroup(e,!!r.owner).catch(()=>{}),await qn(n.host,n.token,e),F.getState().removeConversation(e)}catch(e){I(`chat-island-error`,{scope:`delete`,message:e.message})}},react:async(e,t,n)=>{let r=m.current,i=l.current?.username;if(!r||!i)return;let a=(F.getState().conversations[e]?.reactions?.[t]?.[i]??[]).includes(n)?[]:[n];try{await r.react(e,t,a),F.getState().applyReactions([{peer:e,target:t,user:i,emojis:a}])}catch(e){I(`chat-island-error`,{scope:`reaction`,message:e.message})}},loadOlder:async e=>{let t=m.current,n=F.getState().ensure(e);if(!(!t||n.complete||h.current.has(e))){h.current.add(e);try{let r=await t.history(e,n.oldest);F.getState().prependHistory(e,r.messages,r.complete,r.first),F.getState().applyReactions(r.reactions)}catch(e){I(`chat-island-error`,{scope:`history`,message:e.message})}finally{h.current.delete(e)}}}}),[]);(0,g.useEffect)(()=>{if(!c)return;let e=F.getState();e.reset(),F.setState({me:c.username,mucHost:`conference.${c.host}`,maxHeads:i,newChatButton:a});let t=new Sn(c,{status:(n,i)=>{if(e.setStatus(n,i),I(`chat-island-status`,{status:n,error:i}),n===`online`&&r&&!_.current&&typeof Notification<`u`){let e=Notification.permission;(e===`granted`||d.current===`auto`&&e==="default")&&o()}n===`online`&&t.listGroups().then(t=>t.forEach(t=>e.setGroup(t.peer,t.name,t.members,t.avatar,t.owner))).catch(()=>{}).then(()=>t.recent()).then(e=>{e&&(F.getState().seed(e.messages,c.username),F.getState().applyReactions(e.reactions))}).catch(()=>{})},typing:(t,n)=>e.setTyping(t,n),reaction:t=>e.applyReactions([t]),presence:(t,n)=>e.setOnline(t,n),groupInvite:n=>{t.subscribed(n).then(async r=>{if(!r)return;let i=await t.groupInfo(n);e.setGroup(i.peer,i.name,i.members,i.avatar,i.owner)}).catch(()=>{})},message:r=>{let i=Vn(r);r.room&&!F.getState().conversations[r.room]?.name&&t.groupInfo(r.room).then(t=>e.setGroup(t.peer,t.name,t.members,t.avatar,t.owner)).catch(()=>{}),e.addMessage(i,r,{live:!0}),I(`chat-island-message`,{...r,peer:i}),I(`chat-island-unread`,{total:F.getState().totalUnread()}),r.mine||n(i,r)}}),n=(e,t)=>{let n=F.getState(),r=document.visibilityState===`visible`;if(r&&n.open===e)return;let i=n.conversations[e],a=i?.kind===`group`?i.name??e:n.contacts[e]?.name??e,o=t.oob?`Attachment`:fr(t.body),s=i?.kind===`group`&&t.nick?`${n.contacts[t.nick]?.name??t.nick}: ${o}`:o;if(u.current&&On(),I(`chat-island-notify`,{peer:e,name:a,body:s}),!r&&typeof Notification<`u`&&Notification.permission===`granted`)try{let t=new Notification(a,{body:s,tag:`chat-${e}`});t.onclick=()=>{window.focus(),F.getState().openChat(e),t.close()}}catch{}};m.current=t;let o=()=>{r&&!_.current&&(_.current=!0,Zn(c,r).then(e=>{if(!e){_.current=!1,F.setState({push:Notification.permission===`denied`?`denied`:`ask`});return}return t.enablePush(e.service,e.node).then(()=>{v.current=e,F.setState({push:`enabled`}),I(`chat-island-push`,{enabled:!0})})}).catch(e=>{_.current=!1,I(`chat-island-error`,{scope:`push`,message:e.message})}))},s=!!r&&`serviceWorker`in navigator&&`PushManager`in window&&typeof Notification<`u`;F.setState({push:s?Notification.permission===`denied`?`denied`:`ask`:`unavailable`,enablePush:o});let l=()=>t.stop();window.addEventListener(`pagehide`,l),t.start();let f=()=>Kn(c.host,c.token).then(e.setMobile).catch(()=>{});f();let p=window.setInterval(f,12e4);Gn(c.host,c.token,c.username).then(e.setContacts).catch(e=>I(`chat-island-error`,{scope:`contacts`,message:e.message}));let h=Qn(`chat-island-open`,({username:t})=>t&&e.openChat(t)),g=Qn(`chat-island-close`,()=>e.closeChat()),y=Qn(`chat-island-new`,()=>e.setPicker(!0)),b=Qn(`chat-island-delete`,({username:e})=>e&&ee.remove(e)),x=Qn(`chat-island-contacts`,({contacts:t})=>t&&e.setContacts(t)),S=Qn(`chat-island-conversations-request`,()=>I(`chat-island-conversations`,{conversations:Xr()}));return()=>{window.removeEventListener(`pagehide`,l),window.clearInterval(p),S(),y(),b(),h(),g(),x(),v.current&&t.disablePush(v.current.service,v.current.node).catch(()=>{}),v.current=null,t.stop(),m.current=null,_.current=!1}},[c,r,f]);let E=F(e=>Object.keys(e.contacts).join(`,`));(0,g.useEffect)(()=>{T===`online`&&E&&m.current?.announce(E.split(`,`))},[T,E]);let te=F(e=>Object.values(e.conversations).map(e=>`${e.peer}:${e.kind}:${e.name??``}:${(e.members??[]).length}:${e.unread}:${e.messages[e.messages.length-1]?.id??``}`).join(`|`)+`#`+Object.keys(e.contacts).length+`#`+Object.values(e.online).filter(Boolean).length);(0,g.useEffect)(()=>I(`chat-island-conversations`,{conversations:Xr()}),[te]);let ne=F(e=>Object.values(e.conversations).reduce((e,t)=>e+t.unread,0));if((0,g.useEffect)(()=>I(`chat-island-unread`,{total:ne}),[ne]),!c)return null;let re=S.anchor?{right:S.anchor.right,bottom:S.anchor.bottom}:void 0,ie=re?``:t===`bottom-left`?`ci-left-4 ci-bottom-5`:`ci-right-4 ci-bottom-5`;return(0,L.jsx)(`div`,{ref:b,style:re,onClickCapture:S.onClickCapture,className:`chat-island-root ${n?`dark`:``} ci-fixed ${ie} ci-z-[9999] ci-flex ci-items-end ci-gap-3 ci-font-sans ci-select-none`,"data-status":T,children:(0,L.jsxs)(Zr,{children:[C&&(0,L.jsx)(qr,{peer:C,actions:ee,onDragStart:S.start}),w&&(0,L.jsx)(Yr,{onOpen:e=>F.getState().openChat(e),onCreateGroup:ee.createGroup}),(0,L.jsx)(sr,{onDragStart:S.start,pushButton:o!==`auto`})]})})}document.querySelectorAll(`.chat-island`).forEach(e=>{(0,h.createRoot)(e).render((0,L.jsx)(g.StrictMode,{children:(0,L.jsx)(ei,{dataConfig:e.dataset.config??``,position:e.dataset.position===`bottom-left`?`bottom-left`:`bottom-right`,dark:e.dataset.dark===`true`,serviceWorker:e.dataset.serviceWorker})}))})})();
|
|
9
|
+
`).length-1))}})]}),i.trim()?(0,L.jsx)(or,{variant:`default`,disabled:r,onClick:T,title:`Send`,className:`ci-h-10 ci-w-10`,children:R.send}):(0,L.jsx)(or,{variant:`default`,disabled:r||typeof MediaRecorder>`u`,onClick:ee,title:`Record a voice note`,"aria-label":`Record a voice note`,className:`ci-h-10 ci-w-10`,children:R.mic})]})}var Kr=e=>!!e&&![`offline`,`dnd`,`busy`,`ringing`,`onhold`].includes(e);function qr({peer:e,actions:t,onDragStart:n}){let{c:r,contacts:i,online:a,mobile:o,status:s,closeChat:c,openChat:l,markRead:u,order:d,me:f}=F(y(t=>({c:t.conversations[e],contacts:t.contacts,online:t.online,mobile:t.mobile,status:t.status,closeChat:t.closeChat,openChat:t.openChat,markRead:t.markRead,order:t.order,me:t.me}))),p=Math.max(0,d.indexOf(e)),m=i[e],[h,_]=(0,g.useState)(!1),v=e=>e===f?`You`:i[e]?.name??e,b=[...r?.members??[]].sort((e,t)=>Number(e===f)-Number(t===f));return(0,g.useEffect)(()=>{r&&!r.loaded&&t.loadOlder(e)},[e,r?.loaded]),(0,g.useEffect)(()=>{u(e)},[e,r?.messages.length]),(0,g.useEffect)(()=>_(!1),[e]),r?(0,L.jsxs)(`div`,{role:`dialog`,"aria-label":r.kind===`group`?r.name??e:m?.name??e,onKeyDown:e=>{e.key===`Escape`&&(e.stopPropagation(),h?_(!1):c())},className:`ci-relative ci-w-[22rem] ci-h-[30rem] ci-flex ci-flex-col ci-rounded-3xl ci-shadow-2xl ci-bg-gray-50 dark:ci-bg-gray-950 ci-text-gray-900 dark:ci-text-white`,children:[(0,L.jsx)(`span`,{className:`ci-absolute ci--right-1.5 ci-w-3 ci-h-3 ci-rotate-45 ci-bg-gray-50 dark:ci-bg-gray-950 ci-shadow-2xl ci-transition-all ci-duration-200`,style:{bottom:`calc(1.875rem + ${p} * 3.75rem)`},"aria-hidden":`true`}),(0,L.jsxs)(`div`,{className:`ci-flex ci-items-center ci-gap-3 ci-px-4 ci-py-3 ci-cursor-grab active:ci-cursor-grabbing ci-touch-none ci-rounded-t-3xl`,onPointerDown:n,children:[r.kind===`group`?(0,L.jsx)(rr,{name:r.name??e,size:36,avatar:r.avatar}):(0,L.jsxs)(`span`,{className:`ci-relative`,children:[(0,L.jsx)(tr,{contact:m,username:e,size:36}),(0,L.jsx)(nr,{online:a[e],presence:m?.presence,mobile:o[e]})]}),(0,L.jsxs)(`div`,{className:`ci-flex-1 ci-min-w-0 ${r.kind===`group`?`ci-cursor-pointer`:``}`,...r.kind===`group`?{role:`button`,tabIndex:0,"aria-expanded":h,onKeyDown:e=>(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),_(e=>!e))}:{},onClick:()=>r.kind===`group`&&_(e=>!e),children:[(0,L.jsx)(`div`,{className:`ci-font-medium ci-truncate ci-text-sm`,children:r.kind===`group`?r.name??e:m?.name??e}),(0,L.jsx)(`div`,{className:`ci-text-xs ci-text-gray-500 dark:ci-text-gray-400 ci-truncate`,children:s===`online`?r.kind===`group`?b.map(v).join(`, `):r.typing?`typingโฆ`:a[e]?`online`:o[e]?`Mobile`:`offline`:s})]}),r.kind!==`group`&&m?.number&&Kr(m.presence)&&(0,L.jsx)(or,{variant:`call`,title:`Call ${m.number}`,"aria-label":`Call`,onClick:()=>I(`chat-island-call`,{username:e,number:m.number}),children:R.phone}),(0,L.jsx)(or,{variant:`small`,onClick:()=>c(),"aria-label":`Close`,children:R.close})]}),(0,L.jsx)(`div`,{className:`ci-border-t ci-border-gray-300 dark:ci-border-gray-700`}),h&&r.kind===`group`&&(0,L.jsx)(`div`,{className:`ci-absolute ci-left-3 ci-right-3 ci-top-16 ci-z-10 ci-max-h-64 ci-overflow-y-auto ci-rounded-2xl ci-bg-gray-50 dark:ci-bg-gray-950 ci-shadow-2xl ci-ring-1 ci-ring-gray-300 dark:ci-ring-gray-700 ci-p-2`,children:b.map(e=>(0,L.jsxs)(`div`,{className:`ci-flex ci-items-center ci-gap-3 ci-px-2 ci-py-1.5 ci-text-sm`,children:[(0,L.jsxs)(`span`,{className:`ci-relative`,children:[(0,L.jsx)(tr,{contact:i[e],username:e,size:28}),e!==f&&(0,L.jsx)(nr,{online:a[e],presence:i[e]?.presence,mobile:o[e]})]}),(0,L.jsx)(`span`,{className:`ci-truncate ci-flex-1`,children:v(e)}),e!==f&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(or,{variant:`small`,title:`Chat`,"aria-label":`Chat`,onClick:()=>l(e),children:R.chat}),i[e]?.number&&Kr(i[e]?.presence)&&(0,L.jsx)(or,{variant:`call`,title:`Call ${i[e]?.number}`,"aria-label":`Call`,onClick:()=>I(`chat-island-call`,{username:e,number:i[e].number}),children:R.phone})]})]},e))}),(0,L.jsxs)(`div`,{className:`ci-flex-1 ci-min-h-0 ci-flex ci-flex-col ci-overflow-hidden ci-rounded-b-3xl`,children:[(0,L.jsx)(Ar,{messages:r.messages,typing:r.typing,group:r.kind===`group`,hasOlder:r.loaded&&!r.complete,onLoadOlder:()=>t.loadOlder(e),reactions:r.reactions,me:f,onReact:(n,r)=>t.react(e,n,r)}),(0,L.jsx)(Gr,{disabled:s!==`online`,onSend:n=>t.send(e,n),onTyping:n=>t.typing(e,n),onFile:n=>t.upload(e,n)},e)]})]}):null}async function Jr(e){let t=await createImageBitmap(e),n=Math.min(t.width,t.height),r=document.createElement(`canvas`);return r.width=r.height=128,r.getContext(`2d`)?.drawImage(t,(t.width-n)/2,(t.height-n)/2,n,n,0,0,128,128),r.toDataURL(`image/jpeg`,.8)}function Yr({onOpen:e,onCreateGroup:t}){let{contacts:n,online:r,mobile:i,setPicker:a}=F(),[o,s]=(0,g.useState)(``),[c,l]=(0,g.useState)([]),[u,d]=(0,g.useState)(``),[f,p]=(0,g.useState)(!1),[m,h]=(0,g.useState)(),_=(0,g.useRef)(null),v=(0,g.useMemo)(()=>{let e=Object.values(n),t=o.trim().toLowerCase();return t?e.filter(e=>(e.name??``).toLowerCase().includes(t)||e.username.includes(t)):e},[n,o]),y=e=>l(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]),b=async()=>{p(!0);try{await t(u.trim(),c,m)}finally{p(!1)}};return(0,L.jsxs)(`div`,{className:`ci-w-[22rem] ci-max-h-[30rem] ci-flex ci-flex-col ci-rounded-3xl ci-shadow-2xl ci-overflow-hidden ci-bg-gray-50 dark:ci-bg-gray-950 ci-text-gray-900 dark:ci-text-white`,children:[(0,L.jsxs)(`div`,{className:`ci-px-4 ci-py-3 ci-flex ci-items-center ci-gap-2`,children:[(0,L.jsxs)(`div`,{className:`ci-flex-1 ci-flex ci-items-center ci-gap-2 ci-px-4 ci-py-2 ci-rounded-3xl ci-bg-elevationL2 dark:ci-bg-elevationL2Dark ci-text-gray-500 dark:ci-text-gray-400`,children:[R.search,(0,L.jsx)(`input`,{autoFocus:!0,value:o,onChange:e=>s(e.target.value),placeholder:`Search colleagues`,className:`ci-flex-1 ci-bg-transparent ci-border-0 ci-outline-none ci-text-sm ci-text-gray-900 dark:ci-text-white placeholder:ci-text-gray-500 dark:placeholder:ci-text-gray-400`})]}),(0,L.jsx)(or,{variant:`small`,onClick:()=>a(!1),"aria-label":`Close`,children:R.close})]}),c.length>0&&(0,L.jsx)(`div`,{className:`ci-px-4 ci-pb-2 ci-flex ci-flex-wrap ci-gap-1.5`,children:c.map(e=>(0,L.jsxs)(`button`,{type:`button`,onClick:()=>y(e),className:`ci-flex ci-items-center ci-gap-1 ci-pl-2.5 ci-pr-1.5 ci-py-1 ci-rounded-full ci-text-xs ci-bg-gray-700 ci-text-gray-50 dark:ci-bg-gray-300 dark:ci-text-gray-900 ci-border-0`,children:[n[e]?.name??e,R.close]},e))}),(0,L.jsx)(`div`,{className:`ci-border-t ci-border-gray-300 dark:ci-border-gray-700`}),(0,L.jsxs)(`ul`,{className:`ci-overflow-y-auto ci-py-1 ci-m-0 ci-p-0 ci-list-none ci-flex-1`,children:[v.length===0&&(0,L.jsx)(`li`,{className:`ci-px-4 ci-py-6 ci-text-center ci-text-sm ci-text-gray-500 dark:ci-text-gray-400`,children:`No colleagues found`}),v.map(e=>{let t=c.includes(e.username);return(0,L.jsx)(`li`,{children:(0,L.jsxs)(`button`,{type:`button`,onClick:()=>y(e.username),className:`ci-w-full ci-flex ci-items-center ci-gap-3 ci-px-4 ci-py-2 ci-bg-transparent ci-border-0 ci-text-left hover:ci-bg-gray-300/70 dark:hover:ci-bg-gray-700/30 ci-text-inherit`,children:[(0,L.jsxs)(`span`,{className:`ci-relative`,children:[(0,L.jsx)(tr,{contact:e,username:e.username,size:36}),(0,L.jsx)(nr,{online:r[e.username],presence:e.presence,mobile:i[e.username]})]}),(0,L.jsxs)(`span`,{className:`ci-flex ci-flex-col ci-min-w-0 ci-flex-1`,children:[(0,L.jsx)(`span`,{className:`ci-text-sm ci-font-medium ci-truncate`,children:e.name}),(0,L.jsx)(`span`,{className:`ci-text-xs ci-text-gray-500 dark:ci-text-gray-400 ci-truncate`,children:e.username})]}),(0,L.jsx)(`span`,{className:`ci-w-5 ci-h-5 ci-rounded-full ci-border ci-flex ci-items-center ci-justify-center ${t?`ci-bg-phoneIslandCall dark:ci-bg-phoneIslandCallDark ci-border-transparent ci-text-white dark:ci-text-gray-950`:`ci-border-gray-400 dark:ci-border-gray-600`}`,children:t&&(0,L.jsx)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`3`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,L.jsx)(`path`,{d:`M20 6L9 17l-5-5`})})})]})},e.username)})]}),c.length>0&&(0,L.jsx)(`div`,{className:`ci-border-t ci-border-gray-300 dark:ci-border-gray-700 ci-px-4 ci-py-3 ci-flex ci-items-center ci-gap-2`,children:c.length===1?(0,L.jsx)(or,{variant:`default`,className:`ci-w-auto ci-h-10 ci-px-5`,onClick:()=>e(c[0]),children:`Open chat`}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`input`,{ref:_,type:`file`,accept:`image/*`,hidden:!0,onChange:e=>e.target.files?.[0]&&Jr(e.target.files[0]).then(h).catch(()=>{})}),(0,L.jsx)(`button`,{type:`button`,title:`Group picture`,onClick:()=>_.current?.click(),className:`ci-w-10 ci-h-10 ci-shrink-0 ci-rounded-full ci-border-0 ci-p-0 ci-overflow-hidden ci-bg-elevationL2 dark:ci-bg-elevationL2Dark ci-text-gray-500 dark:ci-text-gray-400 ci-flex ci-items-center ci-justify-center`,children:m?(0,L.jsx)(`img`,{src:m,alt:``,className:`ci-w-full ci-h-full ci-object-cover`}):R.camera}),(0,L.jsx)(`input`,{value:u,onChange:e=>d(e.target.value),placeholder:`Group name`,onKeyDown:e=>e.key===`Enter`&&u.trim()&&!f&&b(),className:`ci-flex-1 ci-min-w-0 ci-w-0 ci-px-4 ci-py-2 ci-rounded-3xl ci-border-0 ci-bg-elevationL2 dark:ci-bg-elevationL2Dark ci-text-sm ci-text-gray-900 dark:ci-text-white placeholder:ci-text-gray-500 dark:placeholder:ci-text-gray-400 ci-outline-none focus:ci-ring-2 focus:ci-ring-gray-400 dark:focus:ci-ring-gray-500`}),(0,L.jsx)(or,{variant:`green`,className:`ci-w-auto ci-h-10 ci-px-4 ci-shrink-0 ci-whitespace-nowrap`,disabled:!u.trim()||f,onClick:b,children:f?`โฆ`:`Create group`})]})})]})}var Xr=`chat-island-theme`,Zr=()=>{try{let e=localStorage.getItem(Xr);return e===`light`||e===`dark`||e===`system`?e:void 0}catch{return}};function Qr(e){let[t,n]=(0,g.useState)(()=>e??Zr()),[r,i]=(0,g.useState)(!1);return(0,g.useEffect)(()=>n(e??Zr()),[e]),(0,g.useEffect)(()=>{let e=e=>{let t=e.detail?.theme;if(t===`light`||t===`dark`||t===`system`){try{localStorage.setItem(Xr,t)}catch{}n(t)}};return window.addEventListener(`chat-island-theme-change`,e),()=>window.removeEventListener(`chat-island-theme-change`,e)},[]),(0,g.useEffect)(()=>{if(t===`light`||t===`dark`){i(t===`dark`);return}if(t===`system`){let e=window.matchMedia(`(prefers-color-scheme: dark)`),t=()=>i(e.matches);return t(),e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)}let e=document.documentElement,n=()=>i(e.classList.contains(`dark`));n();let r=new MutationObserver(n);return r.observe(e,{attributes:!0,attributeFilter:[`class`]}),()=>r.disconnect()},[t]),r}function $r(){let e=F.getState();return Object.values(e.conversations).map(t=>{let n=t.messages[t.messages.length-1],r=e.contacts[t.peer];return{peer:t.peer,kind:t.kind,name:t.kind===`group`?t.name??t.peer.split(`@`)[0]:r?.name??t.peer,avatar:t.kind===`group`?t.avatar:r?.avatar,online:t.kind!==`group`&&!!e.online[t.peer],mobile:t.kind!==`group`&&!!e.mobile[t.peer],owner:t.kind===`group`?!!t.owner:void 0,unread:t.unread,members:t.members,last:n?{body:ni(n.body),ts:n.ts,mine:n.mine,oob:n.oob,nick:n.nick}:void 0}}).filter(e=>e.last||e.kind===`group`).sort((e,t)=>(t.last?.ts??0)-(e.last?.ts??0))}var ei=class extends g.Component{state={failed:!1};failures=[];static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(e){I(`chat-island-error`,{scope:`render`,message:e.message});let t=Date.now();this.failures=[...this.failures.filter(e=>t-e<1e4),t],!(this.failures.length>=3)&&(F.getState().closeChat(),window.setTimeout(()=>this.setState({failed:!1}),0))}render(){return this.state.failed?null:this.props.children}};function ti(e){try{let[t,n,r]=atob(e).split(`:`);return t&&n&&r?{host:t,username:n,token:r}:null}catch{return null}}var ni=e=>(Cr(e)?`Attachment`:fr(e)).replace(/```[^\n]*\n?/g,``).replace(/(\*\*|__|~~|`)/g,``).replace(/(^|\s)[*_](\S[^*_]*)[*_]/g,`$1$2`).replace(/\s+/g,` `).trim();function ri({dataConfig:e,position:t=`bottom-right`,theme:n,serviceWorker:r,maxHeads:i=5,newChatButton:a=!0,notifications:o=`click`,sound:s=!0}){let c=(0,g.useMemo)(()=>ti(e),[e]),l=Qr(n),u=(0,g.useRef)(c),d=(0,g.useRef)(s),f=(0,g.useRef)(o);(0,g.useEffect)(()=>{u.current=c,d.current=s,f.current=o},[c,s,o]),(0,g.useEffect)(()=>F.setState({maxHeads:i,newChatButton:a}),[i,a]);let[p,m]=(0,g.useState)(0);(0,g.useEffect)(()=>{let e=e=>e.persisted&&m(e=>e+1);return window.addEventListener(`pageshow`,e),()=>window.removeEventListener(`pageshow`,e)},[]);let h=(0,g.useRef)(null),_=(0,g.useRef)(new Set),v=(0,g.useRef)(!1),b=(0,g.useRef)(null),S=(0,g.useRef)(null),C=x(S,`chat-island-pos:${c?.host??``}:${c?.username??``}`),{open:w,picker:T,status:ee}=F(y(e=>({open:e.open,picker:e.picker,status:e.status}))),E=(0,g.useMemo)(()=>({send:async(e,t)=>{let n=h.current;if(!n)throw Error(`not connected`);try{F.getState().addMessage(e,await n.send(e,fr(t)))}catch(e){throw I(`chat-island-error`,{scope:`send`,message:e.message}),e}},typing:(e,t)=>F.getState().online[e]&&h.current?.typing(e,t).catch(()=>{}),upload:async(e,t)=>{let n=h.current;if(n)try{let r=await n.upload(t);F.getState().addMessage(e,await n.send(e,t.name,r))}catch(e){I(`chat-island-error`,{scope:`upload`,message:e.message})}},createGroup:async(e,t,n)=>{let r=h.current,i=u.current;if(r&&i)try{let a=await r.createGroup(e,t,n),o=F.getState();o.setGroup(a,e,[...t,i.username],n),o.openChat(a)}catch(e){I(`chat-island-error`,{scope:`group`,message:e.message})}},remove:async e=>{let t=h.current,n=u.current;if(!t||!n)return;let r=F.getState().conversations[e];try{r?.kind===`group`&&await t.leaveGroup(e,!!r.owner).catch(()=>{}),await qn(n.host,n.token,e),F.getState().removeConversation(e)}catch(e){I(`chat-island-error`,{scope:`delete`,message:e.message})}},react:async(e,t,n)=>{let r=h.current,i=u.current?.username;if(!r||!i)return;let a=(F.getState().conversations[e]?.reactions?.[t]?.[i]??[]).includes(n)?[]:[n];try{await r.react(e,t,a),F.getState().applyReactions([{peer:e,target:t,user:i,emojis:a}])}catch(e){I(`chat-island-error`,{scope:`reaction`,message:e.message})}},loadOlder:async e=>{let t=h.current,n=F.getState().ensure(e);if(!(!t||n.complete||_.current.has(e))){_.current.add(e);try{let r=await t.history(e,n.oldest);F.getState().prependHistory(e,r.messages,r.complete,r.first),F.getState().applyReactions(r.reactions)}catch(e){I(`chat-island-error`,{scope:`history`,message:e.message})}finally{_.current.delete(e)}}}}),[]);(0,g.useEffect)(()=>{if(!c)return;let e=F.getState();e.reset(),F.setState({me:c.username,mucHost:`conference.${c.host}`,maxHeads:i,newChatButton:a});let t=new Sn(c,{status:(n,i)=>{if(e.setStatus(n,i),I(`chat-island-status`,{status:n,error:i}),n===`online`&&r&&!v.current&&typeof Notification<`u`){let e=Notification.permission;(e===`granted`||f.current===`auto`&&e==="default")&&o()}n===`online`&&t.listGroups().then(t=>t.forEach(t=>e.setGroup(t.peer,t.name,t.members,t.avatar,t.owner))).catch(()=>{}).then(()=>t.recent()).then(e=>{e&&(F.getState().seed(e.messages,c.username),F.getState().applyReactions(e.reactions))}).catch(()=>{})},typing:(t,n)=>e.setTyping(t,n),reaction:t=>e.applyReactions([t]),presence:(t,n)=>e.setOnline(t,n),groupInvite:n=>{t.subscribed(n).then(async r=>{if(!r)return;let i=await t.groupInfo(n);e.setGroup(i.peer,i.name,i.members,i.avatar,i.owner)}).catch(()=>{})},message:r=>{let i=Vn(r);r.room&&!F.getState().conversations[r.room]?.name&&t.groupInfo(r.room).then(t=>e.setGroup(t.peer,t.name,t.members,t.avatar,t.owner)).catch(()=>{}),e.addMessage(i,r,{live:!0}),I(`chat-island-message`,{...r,peer:i}),I(`chat-island-unread`,{total:F.getState().totalUnread()}),r.mine||n(i,r)}}),n=(e,t)=>{let n=F.getState(),r=document.visibilityState===`visible`;if(r&&n.open===e)return;let i=n.conversations[e],a=i?.kind===`group`?i.name??e:n.contacts[e]?.name??e,o=t.oob?`Attachment`:fr(t.body),s=i?.kind===`group`&&t.nick?`${n.contacts[t.nick]?.name??t.nick}: ${o}`:o;if(d.current&&On(),I(`chat-island-notify`,{peer:e,name:a,body:s}),!r&&typeof Notification<`u`&&Notification.permission===`granted`)try{let t=new Notification(a,{body:s,tag:`chat-${e}`});t.onclick=()=>{window.focus(),F.getState().openChat(e),t.close()}}catch{}};h.current=t;let o=()=>{r&&!v.current&&(v.current=!0,Zn(c,r).then(e=>{if(!e){v.current=!1,F.setState({push:Notification.permission===`denied`?`denied`:`ask`});return}return t.enablePush(e.service,e.node).then(()=>{b.current=e,F.setState({push:`enabled`}),I(`chat-island-push`,{enabled:!0})})}).catch(e=>{v.current=!1,I(`chat-island-error`,{scope:`push`,message:e.message})}))},s=!!r&&`serviceWorker`in navigator&&`PushManager`in window&&typeof Notification<`u`;F.setState({push:s?Notification.permission===`denied`?`denied`:`ask`:`unavailable`,enablePush:o});let l=()=>t.stop();window.addEventListener(`pagehide`,l),t.start();let u=()=>Kn(c.host,c.token).then(e.setMobile).catch(()=>{});u();let p=window.setInterval(u,12e4);Gn(c.host,c.token,c.username).then(e.setContacts).catch(e=>I(`chat-island-error`,{scope:`contacts`,message:e.message}));let m=Qn(`chat-island-open`,({username:t})=>t&&e.openChat(t)),g=Qn(`chat-island-close`,()=>e.closeChat()),_=Qn(`chat-island-new`,()=>e.setPicker(!0)),y=Qn(`chat-island-delete`,({username:e})=>e&&E.remove(e)),x=Qn(`chat-island-contacts`,({contacts:t})=>t&&e.setContacts(t)),S=Qn(`chat-island-conversations-request`,()=>I(`chat-island-conversations`,{conversations:$r()}));return()=>{window.removeEventListener(`pagehide`,l),window.clearInterval(p),S(),_(),y(),m(),g(),x(),b.current&&t.disablePush(b.current.service,b.current.node).catch(()=>{}),b.current=null,t.stop(),h.current=null,v.current=!1}},[c,r,p]);let te=F(e=>Object.keys(e.contacts).join(`,`));(0,g.useEffect)(()=>{ee===`online`&&te&&h.current?.announce(te.split(`,`))},[ee,te]);let ne=F(e=>Object.values(e.conversations).map(e=>`${e.peer}:${e.kind}:${e.name??``}:${(e.members??[]).length}:${e.unread}:${e.messages[e.messages.length-1]?.id??``}`).join(`|`)+`#`+Object.keys(e.contacts).length+`#`+Object.values(e.online).filter(Boolean).length);(0,g.useEffect)(()=>I(`chat-island-conversations`,{conversations:$r()}),[ne]);let re=F(e=>Object.values(e.conversations).reduce((e,t)=>e+t.unread,0));if((0,g.useEffect)(()=>I(`chat-island-unread`,{total:re}),[re]),!c)return null;let ie=C.anchor?{right:C.anchor.right,bottom:C.anchor.bottom}:void 0,ae=ie?``:t===`bottom-left`?`ci-left-4 ci-bottom-5`:`ci-right-4 ci-bottom-5`;return(0,L.jsx)(`div`,{ref:S,style:ie,onClickCapture:C.onClickCapture,className:`chat-island-root ${l?`ci-dark`:``} ci-fixed ${ae} ci-z-[9999] ci-flex ci-items-end ci-gap-3 ci-font-sans ci-select-none`,"data-status":ee,children:(0,L.jsxs)(ei,{children:[w&&(0,L.jsx)(qr,{peer:w,actions:E,onDragStart:C.start}),T&&(0,L.jsx)(Yr,{onOpen:e=>F.getState().openChat(e),onCreateGroup:E.createGroup}),(0,L.jsx)(sr,{onDragStart:C.start,pushButton:o!==`auto`})]})})}document.querySelectorAll(`.chat-island`).forEach(e=>{(0,h.createRoot)(e).render((0,L.jsx)(g.StrictMode,{children:(0,L.jsx)(ri,{dataConfig:e.dataset.config??``,position:e.dataset.position===`bottom-left`?`bottom-left`:`bottom-right`,theme:e.dataset.theme,serviceWorker:e.dataset.serviceWorker})}))})})();
|