/*! For license information please see index.prod.js.LICENSE.txt */ !function(){"use strict";var e,t,s,i,n={3272:function(e,t,s){const i="TinodeWeb",n=i+"/0.25.3",a={hosted:"web.tinode.co",local:"localhost:6060"},o=a.hosted;s.d(t,["C3",0,n,"HX",0,o,"Lq",0,"AQEAAAABAAD_rAp4DJh05a1HAwFT3A6K","RS",0,"https://tinode.co/privacy.html","S",0,{type:"patt",index:0,path:"img/bkg/"},"SE",0,a,"Uv",0,"application/json","V9",0,"https://tinode.co/terms.html","Yd",0,"data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48c3ZnIHZpZXdCb3g9IjAgMCAxNyAxNyIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cGF0aCBkPSJNMy41NjIgMXYxNS40NTlsNC42ODYtMy4yNyA0Ljc1MiAzLjI2di0xNS40NDloLTkuNDM4ek0xMiAxNC41NTFsLTMuNzU2LTIuNTc4LTMuNjgxIDIuNTY4di0xMi41NDFoNy40Mzd2MTIuNTUxeiIgZmlsbD0iIzU1NTU1NSIgLz48L3N2Zz4=","fi",0,"mailto:support@tinode.co","iv",0,i,"kA",0,["http","https","ftp","ftps"],"qy",0,1<<23])},7981:function(e,t,s){s.d(t,{$Z:function(){return g},CO:function(){return d},F8:function(){return b},Pv:function(){return f},QJ:function(){return v},Sk:function(){return p},ae:function(){return r},ag:function(){return c},bB:function(){return h},i:function(){return m},iJ:function(){return u},to:function(){return o}});var i=s(4532);const n=["image/jpeg","image/gif","image/png","image/svg","image/svg+xml"],a=["jpg","gif","png","svg","svg"];function o(e){if(e&&"object"==typeof e){if(e.ref)return e.ref;if(e.data&&e.type)return"data:"+(e.type.startsWith("image/")?e.type:"image/"+e.type)+";base64,"+e.data}return null}function r(e,t,s,i,n){if(t|=0,s|=0,i|=0,(e|=0)<=0||t<=0||s<=0||i<=0)return null;n&&(s=i=Math.min(s,i));const a=Math.min(Math.min(e,s)/e,Math.min(t,i)/t),o={dstWidth:e*a|0,dstHeight:t*a|0};return n?(o.dstWidth=o.dstHeight=Math.min(o.dstWidth,o.dstHeight),o.srcWidth=o.srcHeight=Math.min(e,t),o.xoffset=(e-o.srcWidth)/2|0,o.yoffset=(t-o.srcWidth)/2|0):(o.xoffset=o.yoffset=0,o.srcWidth=e,o.srcHeight=t),o}function l(e,t){const s=n.indexOf(t);if(s<0||!e)return e;const i=a[s],o=e.lastIndexOf(".");return o>=0&&(e=e.substring(0,o)),e+"."+i}function c(e,t,s,i,a){return new Promise((o,c)=>{const d=new Image;d.crossOrigin="Anonymous",d.onerror=function(e){c(new Error("Image format unrecognized"))},d.onload=async function(){URL.revokeObjectURL(d.src);const h=r(d.width,d.height,t,s,a);if(!h)return void c(new Error("Invalid image"));let p=document.createElement("canvas");p.width=h.dstWidth,p.height=h.dstHeight;let u=p.getContext("2d");u.imageSmoothingEnabled=!0,u.drawImage(d,h.xoffset,h.yoffset,h.srcWidth,h.srcHeight,0,0,h.dstWidth,h.dstHeight);const g=n.includes(e.type)?e.type:"image/jpeg";let m=await new Promise(e=>p.toBlob(e,g));if(m){for(;i>0&&m.length>i;)h.dstWidth=.70710678118*h.dstWidth|0,h.dstHeight=.70710678118*h.dstHeight|0,p.width=h.dstWidth,p.height=h.dstHeight,u=p.getContext("2d"),u.clearRect(0,0,p.width,p.height),u.drawImage(d,h.xoffset,h.yoffset,h.srcWidth,h.srcHeight,0,0,h.dstWidth,h.dstHeight),m=await new Promise(e=>p.toBlob(e,g));p=null,o({mime:g,blob:m,width:h.dstWidth,height:h.dstHeight,name:l(e.name,g)})}else c(new Error("Unsupported image format"))},d.src=URL.createObjectURL(e)})}function d(e,t,s,i,a,o,r){return new Promise((l,c)=>{const d=new Image;d.crossOrigin="Anonymous",d.onerror=e=>{c(new Error("Image format unrecognized"))},d.onload=t=>{URL.revokeObjectURL(d.src);let h=document.createElement("canvas");h.width=a*r,h.height=o*r;let p=h.getContext("2d");p.imageSmoothingEnabled=!0,p.drawImage(d,s,i,a,o,0,0,h.width,h.height),e=n.includes(e)?e:"image/jpeg",h.toBlob(t=>{h=null,t?l({mime:e,blob:t,width:a,height:o}):c(new Error("Unsupported image format"))},e)},d.src=t})}function h(e){return new Promise((t,s)=>{const i=new FileReader;i.onerror=e=>{s(i.error)},i.onload=s=>{t({mime:e.type,bits:i.result.split(",")[1],name:e.name})},i.readAsDataURL(e)})}function p(e){return new Promise((t,s)=>{const i=new FileReader;i.onerror=e=>{s(i.error)},i.onload=s=>{t({mime:e.type,bits:i.result.split(",")[1]})},i.readAsDataURL(e)})}function u(e,t,s,i){const n=(e.clipboardData||e.originalEvent.clipboardData||{}).items;if(!n||!n.length)return!1;for(let e in n){const a=n[e];if("file"===a.kind){const e=a.getAsFile();if(!e){console.error("Failed to get file object from pasted file item",a.kind,a.type),i("Failed to get file object from pasted file item");continue}return e.type&&"image"==e.type.split("/")[0]?t(e):s(e),!0}}return!1}function g(e){if(e){e=e.replace(/-/g,"+").replace(/_/g,"/");try{e=btoa(atob(e))}catch(t){console.error("Failed to base64 re-encode string.",t),e=null}}return e}function m(e,t){if(!e)return null;try{const s=atob(e),i=s.length,n=new ArrayBuffer(i),a=new Uint8Array(n);for(let e=0;et+=String.fromCharCode(e)),window.btoa(t)}catch(e){}return null}function b(e){const t=[];try{return[...window.atob(e)].forEach(e=>{t.push(e.charCodeAt(0))}),t}catch(e){}return null}function v(e){return new Promise((t,s)=>{const n=new FileReader;n.onerror=e=>{s(n.error)},n.onload=e=>{const a=i.TheCard.importVCard(n.result);a?t(a):s(new Error("Failed to parse vCard"))},n.readAsText(e)})}},2067:function(e,t,s){s.d(t,{e3:function(){return _},TU:function(){return j},NV:function(){return I}});var i=s(1594),n=s.n(i),a=s(8181),o=s(4532),r=s(8492),l=s(7256),c=s(4848);class d extends n().PureComponent{render(){const e=["busy","declined","disconnected","missed"].includes(this.props.callState),t="material-icons medium "+(e?"red":"green"),s=this.props.incoming?e?"call_missed":"call_received":e?"call_missed_outgoing":"call_made",i=this.props.incoming?(0,c.jsx)(a.FormattedMessage,{id:"calls_incoming",defaultMessage:"Incoming call",description:"Incoming call label"}):(0,c.jsx)(a.FormattedMessage,{id:"calls_outgoing",defaultMessage:"Outgoing call",description:"Outgoing call label"});let n;if(e)switch(this.props.callState){case"busy":n=(0,c.jsx)(a.FormattedMessage,{id:"call_busy",defaultMessage:"busy",description:"Label for busy call line"});break;case"declined":n=(0,c.jsx)(a.FormattedMessage,{id:"call_declined",defaultMessage:"declined",description:"Label for declined call"});break;case"missed":n=this.props.incoming?(0,c.jsx)(a.FormattedMessage,{id:"call_missed",defaultMessage:"missed",description:"Label for missed incoming call"}):(0,c.jsx)(a.FormattedMessage,{id:"call_cancelled",defaultMessage:"cancelled",description:"Label for cancelled outgoing call"});break;default:n=(0,c.jsx)(a.FormattedMessage,{id:"call_disconnected",defaultMessage:"disconnected",description:"Label for disconnected call"})}else n=(0,c.jsx)("span",{children:(0,l.Ye)(this.props.duration/1e3)});return(0,c.jsxs)("div",{className:"call-message",children:[(0,c.jsx)("div",{children:(0,c.jsx)("i",{className:"material-icons big gray",children:"call"})}),(0,c.jsxs)("div",{className:"flex-column narrow",children:[(0,c.jsx)("div",{children:i}),(0,c.jsxs)("div",{className:"duration",children:[(0,c.jsx)("i",{className:t,children:s})," ",n]})]})]})}}class h extends n().PureComponent{render(){const e=["busy","declined","disconnected","missed"].includes(this.props.callState),t=this.props.incoming?e?"call_missed":"call_received":e?"call_missed_outgoing":"call_made";let s;if(e)switch(this.props.callState){case"busy":s=(0,c.jsx)(a.FormattedMessage,{id:"call_busy",defaultMessage:"busy",description:"Label for busy call line"});break;case"declined":s=(0,c.jsx)(a.FormattedMessage,{id:"call_declined",defaultMessage:"declined",description:"Label for declined call"});break;case"missed":s=this.props.incoming?(0,c.jsx)(a.FormattedMessage,{id:"call_missed",defaultMessage:"missed",description:"Label for missed incoming call"}):(0,c.jsx)(a.FormattedMessage,{id:"call_cancelled",defaultMessage:"cancelled",description:"Label for cancelled outgoing call"});break;default:s=(0,c.jsx)(a.FormattedMessage,{id:"call_disconnected",defaultMessage:"disconnected",description:"Label for disconnected call"})}else s=["accepted","started"].includes(this.props.callState)&&!this.props.duration?(0,c.jsx)(a.FormattedMessage,{id:"call_in_progress",defaultMessage:"in progress",description:"Label for call in progress"}):(0,c.jsx)("span",{children:(0,l.Ye)(this.props.duration/1e3)});return(0,c.jsxs)(c.Fragment,{children:[(0,c.jsxs)("div",{className:"composed-material",children:[(0,c.jsx)("i",{className:"material-icons",children:"call"}),(0,c.jsx)("i",{className:"material-icons second",children:t})]})," ",s]})}}class p extends n().PureComponent{constructor(e){super(e),this.videoRef=n().createRef(),this.handleClick=this.handleClick.bind(this)}handleClick(e){this.props.onClick&&this.props.onClick(e)}render(){const e=(0,l.Ye)(this.props["data-duration"]/1e3),t="inline-video"+(this.props.onClick?" image-clickable":"");return(0,c.jsxs)("div",{className:t,children:[n().createElement("img",this.props),(0,c.jsx)("div",{className:"play-control",children:this.props.onClick?(0,c.jsx)("i",{className:"material-icons white x-big",children:"play_arrow"}):(0,c.jsx)("img",{src:"img/broken_video.png",style:{filter:"invert(100%)"},width:"36",height:"36"})}),e?(0,c.jsx)("div",{className:"duration",children:e}):null]})}}class u extends n().PureComponent{constructor(e){super(e),this.state={src:this.props.isvideo?"img/blankvid.png":"img/blankimg.png",style:Object.assign({padding:"4px"},this.props.style),className:this.props.className,alt:this.props.alt,onClick:this.props.onClick}}componentDidMount(){this.props.whenDone.promise.then(e=>this.setState({src:e.src,style:{...this.state.style,padding:0}})).catch(e=>this.setState({src:this.props.isvideo?"img/broken_video.png":"img/broken_image.png"}))}componentWillUnmount(){this.props.whenDone.cancel()}componentDidUpdate(e){e.whenDone!=this.props.whenDone&&(this.setState({src:this.props.isvideo?"img/blankvid.png":"img/blankimg.png",style:{...this.state.style,padding:"4px"}}),this.props.whenDone.promise.then(e=>this.setState({src:e.src,style:{...this.state.style,padding:0}})).catch(e=>this.setState({src:this.props.isvideo?"img/broken_video.png":"img/broken_image.png"})))}render(){return n().createElement("img",this.state)}}var g=s(5247);const m=(0,a.defineMessages)({unknown_name:{id:"unknown_name",defaultMessage:"Unknown",description:"Name to show when the name is missing"}});class f extends n().PureComponent{constructor(e){super(e),this.handleDownload=this.handleDownload.bind(this),this.handleMessage=this.handleMessage.bind(this)}handleDownload(e){e.preventDefault();try{const e=o.TheCard.exportVCard(this.props.content),t=new Blob([e],{type:"text/vcard"}),s=URL.createObjectURL(t),i=document.createElement("a");i.style.display="none",i.href=s,i.download=(this.props.content.fn||"contact")+".vcf",document.body.appendChild(i),i.click(),window.URL.revokeObjectURL(s),document.body.removeChild(i)}catch(e){console.error("Failed to download vcard",e),this.props.onError&&this.props.onError("Failed to download vcard","err")}}handleMessage(e){}render(){const e=this.props.content;if(!e)return null;const t=o.TheCard.getFirstTinodeID(e),s=o.TheCard.getEmails(e).concat(o.TheCard.getPhones(e)),i=o.TheCard.getOrg(e);return(0,c.jsxs)("div",{className:"contact-card",children:[(0,c.jsxs)("div",{className:"contact-body",children:[(0,c.jsx)("div",{className:"avatar-box",children:(0,c.jsx)(g.A,{authorizeURL:this.props.authorizeURL,topic:t||"usr123XXX",avatar:o.TheCard.getPhotoUrl(e)||!0,title:e.fn})}),(0,c.jsxs)("div",{className:"name-box",children:[(0,c.jsx)("div",{className:"name",children:e.fn||(0,c.jsx)(a.FormattedMessage,{...m.unknown_name})}),i&&(0,c.jsx)("div",{className:"org",children:i})]})]}),(0,c.jsxs)("div",{className:"contact-actions",children:[t?(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)("a",{className:"flat-button","data-val":t,onClick:this.props.onChatClick,children:(0,c.jsx)(a.FormattedMessage,{id:"chat_now",defaultMessage:"Chat",description:"Label for message button in contact card"})}),(0,c.jsx)("div",{className:"divider"})]}):s.length>0?(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)("a",{className:"flat-button","data-val":s.join(","),onClick:this.props.onFindClick,children:(0,c.jsx)(a.FormattedMessage,{id:"find_user",defaultMessage:"Find",description:"Label for search button in contact card"})}),(0,c.jsx)("div",{className:"divider"})]}):null,(0,c.jsx)("a",{className:"flat-button",onClick:this.handleDownload,children:(0,c.jsx)(a.FormattedMessage,{id:"save_action",defaultMessage:"Save",description:"Label for Save button"})})]})]})}}var b=(0,a.injectIntl)(f),v=s(4752);class w extends n().PureComponent{constructor(e){super(e)}render(){return(0,c.jsxs)("div",{className:"inline-image",children:[n().createElement("img",this.props),(0,c.jsx)("div",{className:"rounded-container",children:(0,c.jsx)(v.A,{progress:this.props.progress,onCancel:this.props.onCancelUpload})})]})}}var S=s(3272),C=s(7981),y=s(7849);const x=(0,a.defineMessages)({drafty_form:{id:"drafty_form",defaultMessage:"Form: ",description:"Comment for form in Drafty"},drafty_attachment:{id:"drafty_attachment",defaultMessage:"Attachment",description:"Comment for attachment in Drafty"},drafty_image:{id:"drafty_image",defaultMessage:"Picture",description:"Comment for embedded images in Drafty"},drafty_video:{id:"drafty_video",defaultMessage:"Video recording",description:"Comment for videos embedded in Drafty"},drafty_unknown:{id:"drafty_unknown",defaultMessage:"Unsupported",description:"Unsupported entity in drafty"}});function _(e,t,s,i,a){if(a.includes("QQ"))return E.call(this,e,t,s,i);if(!e)return s;let c=o.Drafty.tagName(e),h=o.Drafty.attrValue(e,t)||{};switch(h.key=i,e){case"AU":h.src&&(h.src=this.authorizeURL((0,y.wk)(h.src,"audio")),h.duration=t.duration>0?0|t.duration:void 0,h.preview=t.preview,h.loading="lazy"),c=r.A,s=null;break;case"BR":s=null;break;case"EX":case"RW":break;case"HL":h.className="highlight";break;case"HD":c=null,s=null;break;case"IM":c=M.call(this,c,t,h),s=null;break;case"BN":h.onClick=e=>this.onHandleClick(e,"form_button");let e=n().Children.map(s,e=>"string"==typeof e?e:void 0);e&&0!=e.length||(e=[h.name]),h["data-title"]=e.join("");break;case"LN":h&&(h.href="string"==typeof h.href?(0,y.Jf)(h.href,S.kA):"");break;case"MN":h.className="mention",t&&(h.className+=" "+(0,l.kJ)(t.val,!1,!0));break;case"FM":h.className="bot-form";break;case"QQ":h.className="reply-quote",h.onClick=e=>this.onHandleClick(e,"quote");break;case"TC":c=b,h.content=t,h.authorizeURL=this.authorizeURL,h.onChatClick=e=>this.onHandleClick(e,"contact_chat"),h.onFindClick=e=>this.onHandleClick(e,"contact_find"),s=null;break;case"VC":c=d,s=null,t&&(h.callState=t.state,h.incoming=t.incoming,h.duration=t.duration);break;case"VD":c=T.call(this,c,t,h),s=null;break;default:if(!c){c=n().Fragment,h={key:i};let e=s;Array.isArray(s)&&s.join("").trim()||(e=[n().createElement("span",{key:"x1",className:"gray"},this.formatMessage(x.drafty_unknown))]),s=[n().createElement("i",{key:"x0",className:"material-icons gray"},"extension")," "].concat(e)}}return c?n().createElement(c,h,s):s}function M(e,t,s){if(!t)return s.src="img/broken_image.png",s.style={width:"36px",height:"36px"},e;s.className="inline-image";const i=(0,C.ae)(t.width,t.height,this.viewportWidth>0?Math.min(this.viewportWidth-84.5,448.5):448.5,312,!1)||{dstWidth:32,dstHeight:32};return s.style={width:i.dstWidth+"px",height:i.dstHeight+"px",minWidth:i.dstWidth+"px",minHeight:i.dstHeight+"px"},o.Drafty.isProcessing(t)?e=w:(s.src=this.authorizeURL((0,y.wk)(s.src,"image")),s.alt=t.name,s.src?(Math.max(t.width||0,t.height||0)>36&&(s.onClick=e=>this.onHandleClick(e,"image"),s.className+=" image-clickable"),s.loading="lazy"):s.src=null),e}function T(e,t,s){if(!t)return s.src="img/broken_video.png",s.style={width:"36px",height:"36px"},e;s.className="inline-image";const i=(0,C.ae)(t.width,t.height,this.viewportWidth>0?Math.min(this.viewportWidth-84.5,448.5):448.5,312,!1)||{dstWidth:128,dstHeight:128};return s.style={width:i.dstWidth+"px",height:i.dstHeight+"px",minWidth:i.dstWidth+"px",minHeight:i.dstHeight+"px"},o.Drafty.isProcessing(t)?e=w:(s.src=this.authorizeURL((0,y.wk)(s.src,"image")),s.alt=t.name,(t.ref||t.val)&&(s.onClick=e=>this.onHandleClick(e,"video"),s.loading="lazy"),e=p),e}function j(e,t,s,i){if(!e)return s;let a=o.Drafty.tagName(e);const r={key:i};switch(e){case"AU":a=n().Fragment,s=[n().createElement("i",{key:"au",className:"material-icons"},"mic")," ",(0,l.Ye)(t.duration/1e3)];break;case"BR":a=n().Fragment,s=[" "];break;case"HL":r.className="highlight preview";break;case"LN":case"MN":a="span";break;case"IM":a=n().Fragment,s=[n().createElement("i",{key:"im",className:"material-icons"},"photo")," ",this.formatMessage(x.drafty_image)];break;case"BN":a="span",r.className="flat-button faux";break;case"FM":a=n().Fragment,s=[n().createElement("i",{key:"fm",className:"material-icons"},"dashboard"),this.formatMessage(x.drafty_form)].concat(" ",s||[]);break;case"RW":a=n().Fragment;break;case"EX":if(t){if(o.Drafty.isFormResponseType(t.mime))return null;delete t.val,delete t.ref}a=n().Fragment,s=[n().createElement("i",{key:"ex",className:"material-icons"},"attachment")," ",this.formatMessage(x.drafty_attachment)];break;case"VC":a=h,t&&(r.callState=t.state,r.incoming=t.incoming,r.duration=t.duration),s=null;break;case"QQ":case"HD":a=null,s=null;break;case"TC":a=n().Fragment,s=[n().createElement("i",{key:"tc",className:"material-icons"},"contact_mail")," ",o.TheCard.getFn(t)||this.formatMessage(x.drafty_unknown)];break;case"VD":a=n().Fragment,s=[n().createElement("i",{key:"im",className:"material-icons"},"play_circle_outline")," ",this.formatMessage(x.drafty_video)];break;default:a||(a=n().Fragment,s=[n().createElement("i",{key:"x0",className:"material-icons gray"},"extension")," ",this.formatMessage(x.drafty_unknown)])}return a?n().createElement(a,r,s):s}function A(e,t){return e.style={width:"36px",height:"36px",maxWidth:"36px",maxHeight:"36px"},e.className="inline-image",e.alt=this.formatMessage(x.drafty_image),e.src=t&&e.src||"img/broken_image.png",e.title=e.alt,e}function k(e,t){const s=(0,C.ae)(t.width,t.height,48,36);return e.style={width:s.width+"px",height:s.height+"px",maxWidth:"48px",maxHeight:"36px"},e.className="inline-image",e.alt=this.formatMessage(x.drafty_video),e.title=e.alt,e.src=t&&e.src||"img/broken_video.png",e}function E(e,t,s,i){if(["BR","EX","IM","MN","VD"].includes(e)){let a=o.Drafty.tagName(e),r=o.Drafty.attrValue(e,t)||{};switch(r.key=i,e){case"BR":s=null;break;case"IM":r=A.call(this,r,t),s=[n().createElement("img",r,null)," ",r.alt],a=n().Fragment,r={key:i};break;case"VD":r=k.call(this,r,t),s=[n().createElement("img",r,null)," ",r.alt],a=n().Fragment,r={key:i};break;case"MN":a="span",r.className="mention",t&&(r.className+=" "+(0,l.kJ)(t.val,!1,!0));break;case"EX":let e;if(t){if(o.Drafty.isFormResponseType(t.mime))return null;e=t.name,delete t.val,delete t.ref}a=n().Fragment,s=[n().createElement("i",{key:"ex",className:"material-icons"},"attachment"),(0,l.Tu)(e,16)||this.formatMessage(x.drafty_attachment)]}return n().createElement(a,r,s)}return j.call(this,e,t,s,i)}function N(e,t){let s,i,n,a;if(t?(i=e.preview,a=e.premime||"image/jpeg",n=e.preref):(i=e.val,a=e.mime,n=e.ref),i){const e=(0,C.i)(i,a);if(!e)throw new Error("Invalid image");s=Promise.resolve(e)}else{if(!n)throw new Error("Missing image data");s=fetch(this.authorizeURL((0,y.wk)(n,"image"))).then(e=>{if(e.ok)return e.blob();throw new Error(`Image fetch unsuccessful: ${e.status} ${e.statusText}`)})}return s.then(e=>(0,C.ag)(e,t?48:36,36,-1,!t)).then(s=>(t?e.premime=s.mime:e.mime=s.mime,e.size=s.blob.size,e.width=s.width,e.height=s.height,delete e.ref,delete e.preref,e.src=URL.createObjectURL(s.blob),(0,C.Sk)(s.blob))).then(s=>(t?e.preview=s.bits:e.val=s.bits,e)).catch(t=>{throw delete e.val,delete e.preview,delete e.src,e.width=36,e.height=36,t})}function I(e,t,s,i,a){if("IM"==e||"VD"==e){const a="IM"==e?A.call(this,{key:i},t):k.call(this,{key:i},t);let o;try{o=(0,y.iE)(N.call(this,t,"VD"==e))}catch(e){console.warn("Failed to quote image:",e.message),o=(0,y.iE)(e)}return a.whenDone=o,s=[n().createElement(u,a,null)," ",a.alt],n().createElement(n().Fragment,{key:i},s)}if("QQ"==e){if(a.includes("QQ"))return n().createElement("span",{key:i},[n().createElement("i",{key:"qq",className:"material-icons"},"format_quote")," "]);const e=o.Drafty.attrValue("QQ",t)||{};return e.key=i,e.className="reply-quote",n().createElement(o.Drafty.tagName("QQ"),e,s)}return E.call(this,e,t,s,i)}},99:function(e,t,s){s.d(t,{A:function(){return i}});class i{static setObject(e,t){localStorage.setItem(e,JSON.stringify(t))}static getObject(e){const t=localStorage.getItem(e);return t&&JSON.parse(t)}static updateObject(e,t){const s=this.getObject(e);this.setObject(e,Object.assign(s||{},t))}static removeItem(e){localStorage.removeItem(e)}}},184:function(e,t,s){s.d(t,{A:function(){return i}});class i{static parseUrlHash(e){const t=e.split("?",2),s={};let i=[];return t[0]&&(i=t[0].replace("#","").split("/")),t[1]&&t[1].split("&").forEach(e=>{const t=e.indexOf("=");t>0&&(s[e.slice(0,t)]=decodeURIComponent(e.slice(t+1)))}),{path:i,params:s}}static navigateTo(e){window.location.hash=e}static composeUrlHash(e,t){let s=e.join("/");const i=[];for(const e in t)t.hasOwnProperty(e)&&void 0!==t[e]&&i.push(e+"="+encodeURIComponent(t[e]));return i.length>0&&(s+="?"+i.join("&")),s}static addUrlParam(e,t,s){const n=i.parseUrlHash(e);return n.params[t]=s,i.composeUrlHash(n.path,n.params)}static removeUrlParam(e,t){const s=i.parseUrlHash(e);return delete s.params[t],i.composeUrlHash(s.path,s.params)}static removeUrlParams(e,t){Array.isArray(t)||(t=[t]);const s=i.parseUrlHash(e);for(const e of t)delete s.params[e];return i.composeUrlHash(s.path,s.params)}static setUrlSidePanel(e,t){const s=i.parseUrlHash(e);return s.path[0]=t,i.composeUrlHash(s.path,s.params)}static setUrlInfoPanel(e,t){const s=i.parseUrlHash(e);return t?s.params.info=t:delete s.params.info,i.composeUrlHash(s.path,s.params)}static setUrlTopic(e,t){const s=i.parseUrlHash(e);return s.path[1]=t,delete s.params.info,i.composeUrlHash(s.path,s.params)}}},7256:function(e,t,s){function i(e,t){t=t||window.navigator.userLanguage||window.navigator.language;const s=new Date;return e.getFullYear()==s.getFullYear()?e.getMonth()==s.getMonth()&&e.getDate()==s.getDate()?e.toLocaleTimeString(t,{hour12:!1,hour:"2-digit",minute:"2-digit"}):e.toLocaleDateString(t,{hour12:!1,month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}):e.toLocaleDateString(t,{year:"numeric",month:"short",day:"numeric"})}function n(e,t){t=t||window.navigator.userLanguage||window.navigator.language;const s=new Date,i=Math.floor((e.getTime()-6e4*e.getTimezoneOffset())/864e5)-Math.floor((s.getTime()-6e4*s.getTimezoneOffset())/864e5);return Math.abs(i)<2?new Intl.RelativeTimeFormat(t,{numeric:"auto"}).format(i,"day"):new Intl.DateTimeFormat(t).format(e)}function a(e,t){if("number"!=typeof e)return"";let s=(0|Math.floor(e/60))%60,i=0|Math.floor(e/3600);(t||i>0)&&(s=s<10?`0${s}`:s);let n=(0|e)%60;return n=n<10?`0${n}`:n,0==i?`${s}:${n}`:`${i}:${s}:${n}`}function o(e){if(!e||0==e)return"0 Bytes";const t=["Bytes","KB","MB","GB","TB","PB"],s=Math.min(0|Math.floor(Math.log2(e)/10),t.length-1),i=e/Math.pow(1024,s),n=s>0?i<3?2:i<30?1:0:0;return i.toFixed(n)+" "+t[s]}function r(e,t){return"string"!=typeof e?e:e.length>t?e.slice(0,t/2-1)+"…"+e.slice(1-t/2):e}function l(e,t,s){return(t?"lt-":"dk-")+(s?"fg-":"bg-")+(i=e,Math.abs(function(e){let t=0;e=""+e;for(let s=0;s127397+e.charCodeAt());return String.fromCodePoint(...t)}function d(e,t){return"string"!=typeof e||e.length<=t?e:/[\u0590-\u05FF\u0600-\u06FF\u0750-\u077F\u08A0-\u08FF\uFB50-\uFDFF\uFE70-\uFEFF]/.test(e)?"…"+e.slice(0,t-1):e.slice(0,t-1)+"…"}s.d(t,{Tu:function(){return r},W5:function(){return d},Ye:function(){return a},cq:function(){return i},kJ:function(){return l},lX:function(){return o},lb:function(){return c},mf:function(){return n}})},7849:function(e,t,s){s.d(t,{FH:function(){return u},Jf:function(){return h},Jt:function(){return l},KY:function(){return f},LO:function(){return g},MC:function(){return v},OM:function(){return a},YO:function(){return d},af:function(){return r},iE:function(){return m},k6:function(){return o},t7:function(){return b},wk:function(){return p},xH:function(){return c}});var i=s(4532),n=s(3272);function a(e){const t=document.getElementById("shortcut-icon"),s=document.head||document.getElementsByTagName("head")[0],i=document.createElement("link");i.type="image/png",i.id="shortcut-icon",i.rel="shortcut icon",i.href="img/logo32x32"+(e>0?"a":"")+".png",t&&s.removeChild(t),s.appendChild(i),document.title=(e>0?"("+e+") ":"")+"Tinode"}function o(e,t,s,n){let a=null;if((e=e&&e.trim())&&(a={fn:e}),"string"==typeof(n=n&&n.trim())&&(a=a||{},a.note=n||i.Tinode.DEL_CHAR),t){a=a||{};let e=s;const n=/^data:(image\/[-a-z0-9+.]+)?(;base64)?,/i.exec(t);n?(e=n[1],a.photo={data:t.substring(t.indexOf(",")+1),ref:i.Tinode.DEL_CHAR}):a.photo={data:i.Tinode.DEL_CHAR,ref:t},a.photo.type=(e||"image/jpeg").substring(6)}return a}function r(e,t){if(e===t)return!0;if(!Array.isArray(e)||!Array.isArray(t))return!1;if(e.length!=t.length)return!1;e.sort(),t.sort();for(let s=0,i=e.length;s0&&(s=e.substring(i+1),e=e.substring(0,i));const n=e.indexOf("?");n>0&&(t=e.substring(n+1),e=e.substring(0,n));const a=new URLSearchParams(t);return a.append("asatt","1"),`${e}?${a.toString()}`+(s?`#${s}`:"")}function g(e){switch(e){case i.Tinode.MESSAGE_STATUS_SENDING:return{name:"access_time"};case i.Tinode.MESSAGE_STATUS_FAILED:case i.Tinode.MESSAGE_STATUS_FATAL:return{name:"warning",color:"danger-color"};case i.Tinode.MESSAGE_STATUS_SENT:return{name:"done"};case i.Tinode.MESSAGE_STATUS_RECEIVED:return{name:"done_all"};case i.Tinode.MESSAGE_STATUS_READ:return{name:"done_all",color:"blue"}}return null}function m(e){let t=!1;return{promise:e instanceof Error?Promise.reject(e):new Promise((s,i)=>{e.then(e=>t?i({isCanceled:!0}):s(e),e=>i(t?{isCanceled:!0}:e))}),cancel(){t=!0}}}function f(){const e=s(1781)[n.S.type][n.S.index];return{name:`../${n.S.path}${e.name}`,size:e.size}}function b(e){const t=e.split("/");return t[t.length-1]}function v(e){const t=b(e),i=s(1781);for(const e in i)for(let s=0;s{let{mime:t,blob:s}=e;s.size>4096?this.props.tinode.getLargeFileHelper().upload(s).then(e=>this.props.onUpdateTopicDesc(this.props.topic,(0,g.k6)(null,e))).catch(e=>this.props.onError(e.message,"err")):(0,p.Sk)(s).then(e=>{const s=(0,p.to)({data:e.bits,type:t});this.setState({source:s}),this.props.onUpdateTopicDesc(this.props.topic,(0,g.k6)(null,s))})};s>384||i>384||s!=i?(0,p.ag)(t,384,384,h.qy,!0).then(e=>n(e)).catch(e=>this.props.onError(e.message,"err")):n({mime:e,blob:t,width:s,height:i})}handleAvatarCropCancel(){this.setState({newAvatar:null,newAvatarMime:null})}handleAliasUpdate(e){const t=(e=(e||"").trim())?o.Tinode.setUniqueTag(this.state.tags,o.Tinode.TAG_ALIAS+e.toLowerCase()):o.Tinode.clearTagPrefix(this.state.tags,o.Tinode.TAG_ALIAS);this.handleTagsUpdated(t)}validateAlias(e){if(this.cancelValidator(),!(e=e.trim()))return this.setState({aliasError:""}),!0;if(!o.Tinode.isValidTagValue(e))return this.setState({aliasError:this.props.intl.formatMessage(f.alias_invalid)}),!1;this.setState({aliasError:""});const t=this.props.tinode.getFndTopic();if(!t)return this.setState({aliasError:""}),!0;this.aliasCheckPromise={};const s=new Promise((e,t)=>{this.aliasCheckPromise.resolve=e,this.aliasCheckPromise.reject=t});return this.aliasCheckTimer=setTimeout(s=>{this.aliasCheckTimer=null,t.checkTagUniqueness(`${o.Tinode.TAG_ALIAS}${e}`,this.props.topic).then(e=>{this.aliasCheckPromise.resolve(e),this.setState({aliasError:e?"":this.props.intl.formatMessage(f.alias_already_taken)})}).catch(e=>{this.aliasCheckPromise.reject(e),this.setState({aliasError:e.message})})},1e3),s}cancelValidator(){this.aliasCheckTimer&&(clearTimeout(this.aliasCheckTimer),this.aliasCheckTimer=null,this.aliasCheckPromise.reject(null))}handleTagsUpdated(e){(0,g.af)(this.state.tags.slice(0),e.slice(0))||this.props.onUpdateTags(e)}render(){if(this.state.newAvatar)return(0,m.jsx)(r.A,{avatar:this.state.newAvatar,mime:this.state.newAvatarMime,onSubmit:this.handleAvatarCropped,onCancel:this.handleAvatarCropCancel,onError:this.props.onError});const e=this.state.isMe||this.state.owner&&!this.state.isSelf;let t=this.state.tags&&this.state.tags.find(e=>e.startsWith("alias:"));return t&&(t=t.substring(6)),(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)("div",{className:"panel-form-column",children:[(0,m.jsx)("center",{children:(0,m.jsx)(l.A,{tinode:this.props.tinode,avatar:this.state.avatar,readOnly:!e,uid:this.props.topic,title:this.state.fullName,onImageUpdated:this.handleImageUpdated,onError:this.props.onError})}),this.state.isMe?(0,m.jsxs)("div",{className:"group",children:[(0,m.jsx)("label",{className:"small",children:(0,m.jsx)(a.FormattedMessage,{id:"label_your_name",defaultMessage:"Your name",description:"Label for full name editing"})}),(0,m.jsx)("div",{children:(0,m.jsx)(a.FormattedMessage,{id:"full_name_prompt",defaultMessage:"Full name, e.g. John Doe",description:"Input placeholder for person's full name",children:e=>(0,m.jsx)(c.A,{placeholder:e,value:this.state.fullName,required:!0,onFinished:this.handleFullNameUpdate})})})]}):(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)("div",{className:"group",children:[(0,m.jsx)("div",{children:(0,m.jsx)("label",{className:"small",children:(0,m.jsx)(a.FormattedMessage,{id:"label_topic_name",defaultMessage:"Name",description:"Label for editing topic name"})})}),(0,m.jsx)("div",{children:(0,m.jsx)(a.FormattedMessage,{id:"topic_name_editing_placeholder",defaultMessage:"Freeform name of the group",description:"Prompt for entering topic name",children:t=>(0,m.jsx)(c.A,{placeholder:t,readOnly:!e,value:this.state.fullName,required:!0,maxLength:32,onFinished:this.handleFullNameUpdate})})})]}),(0,m.jsxs)("div",{className:"group",children:[(0,m.jsx)("div",{children:(0,m.jsx)("label",{className:"small",children:(0,m.jsx)(a.FormattedMessage,{id:"label_private",defaultMessage:"Private comment",description:"Label for editing 'private'"})})}),(0,m.jsx)("div",{children:(0,m.jsx)(a.FormattedMessage,{id:"private_editing_placeholder",defaultMessage:"Visible to you only",description:"Placeholder for editing 'private'",children:e=>(0,m.jsx)(c.A,{placeholder:e,value:this.state.private,onFinished:this.handlePrivateUpdate})})})]})]}),e||t?(0,m.jsxs)("div",{className:"group",children:[(0,m.jsx)("div",{children:(0,m.jsxs)("label",{className:"small "+(this.state.aliasError?"invalid":""),children:[(0,m.jsx)(a.FormattedMessage,{id:"label_alias_edit",defaultMessage:"Alias",description:"Label for editing user or topic alias"})," ",this.state.aliasError]})}),(0,m.jsx)("div",{children:(0,m.jsx)(a.FormattedMessage,{id:"alias_editing_placeholder",defaultMessage:"Alias (optional)",description:"Placeholder for editing user or topic alias",children:s=>(0,m.jsx)(c.A,{placeholder:s,readOnly:!e,value:t,validator:this.validateAlias,iconLeft:"alternate_email",maxLength:24,spellCheck:!1,onFinished:this.handleAliasUpdate})})})]}):null,e||this.state.description?(0,m.jsxs)("div",{className:"group",children:[(0,m.jsx)("div",{children:(0,m.jsx)("label",{className:"small",children:(0,m.jsx)(a.FormattedMessage,{id:"label_description",defaultMessage:"Description",description:"Label for description of user or topic"})})}),(0,m.jsx)("div",{children:(0,m.jsx)(a.FormattedMessage,{id:"description_editing_placeholder",defaultMessage:"Description (optional)",description:"Placeholder for editing topic description",children:t=>(0,m.jsx)(c.A,{placeholder:t,readOnly:!e,value:this.state.description,multiline:2,onFinished:this.handleDescriptionUpdate})})})]}):null]}),e&&!this.state.isMe?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)("div",{className:"hr"}),(0,m.jsx)(a.FormattedMessage,{id:"title_tag_manager",defaultMessage:"Tags (search & discovery)",description:"Section title for TagManager",children:e=>(0,m.jsx)(d.A,{tinode:this.props.tinode,title:e,activated:!1,tags:this.state.tags,onSubmit:this.handleTagsUpdated})})]}):null]})}}var v=(0,a.injectIntl)(b);class w extends n().Component{constructor(e){super(e),this.props.tinode.getTopic(this.props.topic).getAccessMode(),this.state={tags:[]},this.previousTagsUpdated=void 0,this.onTagsUpdated=this.onTagsUpdated.bind(this),this.handleTagsUpdated=this.handleTagsUpdated.bind(this)}componentDidUpdate(e){const t=this.props.tinode.getTopic(e.topic);t&&(t.onTagsUpdated!=this.onTagsUpdated&&("grp"==t.getType()?(this.previousTagsUpdated=t.onTagsUpdated,t.onTagsUpdated=this.onTagsUpdated):this.previousTagsUpdated=void 0),this.state.topic!=e.topic&&this.setState({topic:e.topic}))}componentWillUnmount(){this.props.tinode.getTopic(this.props.topic).onTagsUpdated=this.previousTagsUpdated}onTagsUpdated(e){this.setState({tags:e}),this.previousTagsUpdated&&this.previousTagsUpdated!=this.onTagsUpdated&&this.previousTagsUpdated(e)}handleTagsUpdated(e){(0,g.af)(this.state.tags.slice(0),e.slice(0))||this.props.onUpdateTagsRequest(this.props.topic,e)}render(){return(0,m.jsx)("div",{className:"scrollable-panel",children:(0,m.jsx)(v,{tinode:this.props.tinode,topic:this.props.topic,onUpdateTopicDesc:this.props.onUpdateTopicDesc,onUpdateTags:this.handleTagsUpdated,onError:this.props.onError})})}}},8492:function(e,t,s){var i=s(1594),n=s.n(i),a=s(8181),o=s(7256),r=s(7981),l=s(4848);const c="#666C",d=(0,a.defineMessages)({icon_title_play:{id:"icon_title_play",defaultMessage:"Play recording",description:"Icon tool tip for starting audio playback"}});class h extends n().PureComponent{constructor(e){super(e);let t=(0,r.F8)(this.props.preview);(!Array.isArray(t)||t.length<16)&&(t=null),this.state={canPlay:!1,playing:!1,currentTime:"0:00",duration:this.props.duration>0?(0,o.Ye)(this.props.duration/1e3):"-:--",longMin:this.props.duration>=6e5,preview:t},this.initAudio=this.initAudio.bind(this),this.initCanvas=this.initCanvas.bind(this),this.resampleBars=this.resampleBars.bind(this),this.visualize=this.visualize.bind(this),this.handlePlay=this.handlePlay.bind(this),this.handleSeek=this.handleSeek.bind(this),this.handleError=this.handleError.bind(this),this.audioPlayer=null,this.viewBuffer=[],this.canvasRef=n().createRef()}componentDidMount(){this.props.src&&this.initAudio(),this.initCanvas()}componentWillUnmount(){this.audioPlayer&&(this.audioPlayer.onloadedmetadata=null,this.audioPlayer.ontimeupdate=null,this.audioPlayer.onended=null,this.audioPlayer.pause(),this.audioPlayer=null)}componentDidUpdate(e){if(this.props.src!=e.src&&this.initAudio(),this.props.preview!=e.preview){let e=(0,r.F8)(this.props.preview);(!Array.isArray(e)||e.length<16)&&(e=null),this.setState({preview:e},this.initCanvas)}}initAudio(){this.audioPlayer=new Audio(this.props.src),this.audioPlayer.onloadedmetadata=e=>this.setState({canPlay:!0}),this.audioPlayer.ontimeupdate=e=>this.setState({currentTime:(0,o.Ye)(this.audioPlayer.currentTime,this.state.longMin)}),this.audioPlayer.onended=e=>{this.audioPlayer.currentTime=0,this.setState({playing:!1,currentTime:(0,o.Ye)(0,this.state.longMin)})}}initCanvas(){this.canvasRef.current.width=2*this.canvasRef.current.offsetWidth,this.canvasRef.current.height=2*this.canvasRef.current.offsetHeight,this.canvasContext=this.canvasRef.current.getContext("2d"),this.canvasContext.lineCap="round",this.viewBuffer=this.resampleBars(this.state.preview),this.visualize()}visualize(){if(!this.canvasRef.current)return;const e=this.effectiveWidth,t=this.canvasRef.current.height;this.canvasContext.lineWidth=6;const s=i=>{if(this.canvasRef.current&&this.audioPlayer&&(this.canvasContext.clearRect(0,0,this.canvasRef.current.width,t),this.viewBuffer)){this.state.playing&&window.requestAnimationFrame(s);const i=this.props.duration?Math.max(0,Math.min(1e3*this.audioPlayer.currentTime/this.props.duration,1))*(e-12):-1;this.canvasContext.beginPath(),this.canvasContext.strokeStyle=c;for(let e=0;e.01);const s=e.length/t;let i=[],n=-1;for(let a=0;a0?i.map(e=>e/n):Array.apply(null,Array(t)).map(e=>.01)}handlePlay(e){e.preventDefault(),this.state.canPlay&&(this.state.playing?(this.audioPlayer.pause(),this.setState({playing:!1})):this.audioPlayer.readyState>=2&&(this.audioPlayer.play(),this.setState({playing:!0},this.visualize)))}handleError(e){console.error(e)}handleSeek(e){if(e.preventDefault(),e.target&&this.props.duration){const t=e.target.getBoundingClientRect(),s=(e.clientX-t.left)/this.effectiveWidth*2;this.audioPlayer.currentTime=this.props.duration*s/1e3,this.setState({currentTime:(0,o.Ye)(this.audioPlayer.currentTime,this.state.longMin)}),this.state.playing||this.visualize()}}render(){const e="material-icons"+(this.props.short?"":" large")+(this.state.canPlay?"":" disabled"),t=(0,l.jsx)("a",{href:"#",onClick:this.handlePlay,title:this.props.intl.formatMessage(d.icon_title_play),children:(0,l.jsx)("i",{className:e,children:this.state.playing?"pause_circle":this.state.canPlay?"play_circle":"not_interested"})});return(0,l.jsx)("div",{className:"audio-player",children:this.props.short?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("canvas",{className:"playback",ref:this.canvasRef,onClick:this.handleSeek}),t]}):(0,l.jsxs)(l.Fragment,{children:[t,(0,l.jsxs)("div",{children:[(0,l.jsx)("canvas",{className:"playback",ref:this.canvasRef,onClick:this.handleSeek}),(0,l.jsxs)("div",{className:"timer",children:[this.state.currentTime,"/",this.state.duration]})]})]})})}}t.A=(0,a.injectIntl)(h)},995:function(e,t,s){s.d(t,{A:function(){return c}});var i=s(1594),n=s.n(i),a=s(8181),o=s(4848);class r extends n().Component{constructor(e){super(e),this.state={panX:0,panY:0,originX:0,originY:0,zoom:1,minZoom:.001,maxZoom:8},this.overlay=n().createRef(),this.cutout=n().createRef(),this.preview=n().createRef(),this.boundingBox=n().createRef(),this.imageWidth=0,this.imageHeight=0,this.mouseX=0,this.mouseY=0,this.prevDistance=0,this.cutoutRect={},this.bBoxRect={},this.originX=0,this.originY=0,this.initScaling=this.initScaling.bind(this),this.onZoom=this.onZoom.bind(this),this.handleZoom=this.handleZoom.bind(this),this.mouseDown=this.mouseDown.bind(this),this.mouseUp=this.mouseUp.bind(this),this.mouseMove=this.mouseMove.bind(this),this.mouseTouch=this.mouseTouch.bind(this),this.positionAll=this.positionAll.bind(this),this.translate=this.translate.bind(this)}componentDidMount(){this.overlay.current.addEventListener("mousedown",this.mouseDown,{passive:!0}),this.overlay.current.addEventListener("touchstart",this.mouseDown,{passive:!0}),this.bBoxRect=this.boundingBox.current.getBoundingClientRect(),this.originX=this.bBoxRect.width/2,this.originY=this.bBoxRect.height/2,this.cutoutRect=this.cutout.current.getBoundingClientRect()}componentWillUnmount(){this.overlay.current&&(this.overlay.current.removeEventListener("mousedown",this.mouseDown),this.overlay.current.removeEventListener("touchstart",this.mouseDown))}positionAll(e,t,s){this.setState({panX:e,panY:t,zoom:s,originX:this.originX-e,originY:this.originY-t});const i=(this.originX-e)*s-this.originX,n=(this.originY-t)*s-this.originY;this.props.onChange((i+this.cutoutRect.left-this.bBoxRect.left)/s,(n+this.cutoutRect.top-this.bBoxRect.top)/s,this.cutoutRect.width/s,this.cutoutRect.height/s,s)}static checkBound(e,t,s,i){let n=Math.min(0,s[0]-t[0]-i,t[1]-s[1]+i);return(0==n||Math.min(0,s[0]-t[0],t[1]-s[1])n&&(t+=(l-n)/e),co&&(s+=(d-o)/e),this.positionAll(t,s,e)}mouseDown(e){e.touches?(this.mouseX=e.touches[0].pageX,this.mouseY=e.touches[0].pageY):(this.mouseX=e.pageX,this.mouseY=e.pageY),window.addEventListener("mousemove",this.mouseMove,{passive:!1}),window.addEventListener("touchmove",this.mouseTouch,{passive:!1}),window.addEventListener("mouseup",this.mouseUp,{passive:!0}),window.addEventListener("touchend",this.mouseUp,{passive:!0}),document.body.style.userSelect="none"}translate(e,t){const s=(e-this.mouseX)/this.state.zoom,i=(t-this.mouseY)/this.state.zoom;this.mouseX=e,this.mouseY=t;const n=this.preview.current.getBoundingClientRect(),a=r.checkBound(this.state.panX,[n.left,n.right],[this.cutoutRect.left,this.cutoutRect.right],s),o=r.checkBound(this.state.panY,[n.top,n.bottom],[this.cutoutRect.top,this.cutoutRect.bottom],i);this.positionAll(a,o,this.state.zoom)}mouseMove(e){e.preventDefault(),this.translate(e.pageX,e.pageY)}mouseTouch(e){if(e.preventDefault(),1==e.touches.length)return void this.translate(e.touches[0].pageX,e.touches[0].pageY);const[t,s]=e.touches,i=Math.sqrt((t.pageX-s.pageX)*(t.pageX-s.pageX)+(t.pageY-s.pageY)*(t.pageY-s.pageY));this.prevDistance||(this.prevDistance=i/this.state.zoom);let n=i/this.prevDistance;this.handleZoom(Math.max(this.minZoom,Math.min(this.maxZoom,n)))}mouseUp(e){window.removeEventListener("mousemove",this.mouseMove),window.removeEventListener("touchmove",this.mouseTouch),window.removeEventListener("mouseup",this.mouseUp),window.removeEventListener("touchend",this.mouseUp),document.body.style.userSelect="",this.positionAll(this.state.panX,this.state.panY,this.state.zoom)}render(){const e=`translate3d(${this.state.panX}px, ${this.state.panY}px, 0) scale(${this.state.zoom})`,t=`${this.state.originX}px ${this.state.originY}px`,s={top:this.originY-this.state.originY*this.state.zoom+"px",left:this.originX-this.state.originX*this.state.zoom+"px",width:this.imageWidth*this.state.zoom+"px",height:this.imageHeight*this.state.zoom+"px"};return(0,o.jsxs)("div",{className:"cropper",children:[(0,o.jsxs)("div",{className:"bounding-box",ref:this.boundingBox,children:[(0,o.jsx)("img",{src:this.props.source,className:"preview",alt:"",style:{transform:e,transformOrigin:t},ref:this.preview,onLoad:this.initScaling}),(0,o.jsx)("div",{className:"cutout circle",ref:this.cutout}),(0,o.jsx)("div",{className:"overlay",style:s,ref:this.overlay})]}),(0,o.jsx)("div",{className:"zoom-wrapper",children:(0,o.jsx)("input",{type:"range",className:"zoomer",step:"0.001",min:this.state.minZoom,max:this.state.maxZoom,value:this.state.zoom,onChange:this.onZoom})})]})}}var l=s(7981);class c extends n().PureComponent{constructor(e){super(e),this.state={top:0,left:0,width:0,height:0,scale:1},this.handleSubmit=this.handleSubmit.bind(this),this.handleChange=this.handleChange.bind(this)}handleChange(e,t,s,i,n){this.setState({left:e,top:t,width:s,height:i,scale:n})}handleSubmit(){(0,l.CO)(this.props.mime,this.props.avatar,this.state.left,this.state.top,this.state.width,this.state.height,this.state.scale).then(e=>{this.props.onSubmit(e.mime,e.blob,e.width,e.height)}).catch(e=>{this.props.onError(e)})}render(){return(0,o.jsxs)("div",{className:"panel-form",children:[(0,o.jsx)("div",{className:"panel-form-row",children:(0,o.jsx)(r,{source:this.props.avatar,onChange:this.handleChange})}),(0,o.jsxs)("div",{className:"dialog-buttons",children:[this.props.onCancel?(0,o.jsx)("button",{className:"secondary",onClick:this.props.onCancel,children:(0,o.jsx)(a.FormattedMessage,{id:"button_cancel",defaultMessage:"Cancel",description:"Button [Cancel]"})}):null,(0,o.jsx)("button",{className:"primary",onClick:this.handleSubmit,children:(0,o.jsx)(a.FormattedMessage,{id:"button_ok",defaultMessage:"OK",description:"Button [OK]"})})]})]})}}},3889:function(e,t,s){s.d(t,{A:function(){return c}});var i=s(1594),n=s.n(i),a=s(5247),o=s(9304),r=s(7849),l=(s(3272),s(4848));class c extends n().Component{constructor(e){super(e),this.state={source:e.avatar},this.handleFileReceived=this.handleFileReceived.bind(this)}componentDidUpdate(e){this.props.avatar!=e.avatar&&this.setState({source:this.props.avatar})}handleFileReceived(e){const t=e.target.files[0];this.props.onImageUpdated(t.type,URL.createObjectURL(t),t.name),e.target.value=""}render(){const e="file-input-avatar-"+(""+Math.random()).substring(0,4),t="avatar-upload"+(this.props.readOnly?" read-only":"");return(0,l.jsxs)("div",{className:t,children:[this.props.readOnly||!this.state.source?null:(0,l.jsx)("a",{href:"#",className:"clear-avatar",onClick:e=>{e.preventDefault(),this.props.onImageUpdated()},children:(0,l.jsx)("i",{className:"material-icons",children:"clear"})}),this.state.source?(0,l.jsx)("img",{src:this.props.tinode.authorizeURL((0,r.wk)(this.state.source,"image")),className:"preview"}):this.props.readOnly&&this.props.uid?(0,l.jsx)("div",{className:"avatar-box",children:(0,l.jsx)(a.A,{authorizeURL:this.props.tinode.authorizeURL,avatar:!0,topic:this.props.uid,title:this.props.title})}):(0,l.jsxs)("div",{className:"blank",children:[384,"×",384]}),this.props.readOnly?null:(0,l.jsx)("input",{type:"file",id:e,className:"inputfile hidden",accept:"image/*",onChange:this.handleFileReceived}),this.props.readOnly?null:(0,l.jsx)("label",{htmlFor:e,className:"round",children:(0,l.jsx)("i",{className:"material-icons",children:"file_upload"})}),(0,l.jsx)(o.A,{show:this.props.uploading,large:!0,clear:!0,centered:!0})]})}}},6686:function(e,t,s){var i=s(1594),n=s.n(i),a=s(8181),o=s(4848);const r={staff:"verified_user"},l=(0,a.defineMessages)({badge_verified:{id:"badge_verified",defaultMessage:"Verified/official",description:"Explanation of a verified account or topic badge"},badge_staff:{id:"badge_staff",defaultMessage:"Staff-managed",description:"Explanation of a staff-managed account or topic badge"},badge_danger:{id:"badge_danger",defaultMessage:"Untrustworthy",description:"Suspicious or untrustworthy account or topic badge"}});class c extends n().PureComponent{render(){const{formatMessage:e}=this.props.intl;let t=null;return this.props.trustedBadges&&this.props.trustedBadges.length>0?(t=[],this.props.trustedBadges.forEach(s=>{const i=this.props.short?null:e(l["badge_"+s]),n="material-icons "+s+"-color";t.push((0,o.jsxs)("div",{className:"trusted-badge",children:[(0,o.jsx)("i",{className:n,children:r[s]||s})," ",i]},s))}),(0,o.jsx)(o.Fragment,{children:t})):null}}t.A=(0,a.injectIntl)(c)},3207:function(e,t,s){s.d(t,{A:function(){return a}});var i=s(1594),n=s.n(i);class a extends n().PureComponent{constructor(e){super(e),this.handleChange=this.handleChange.bind(this)}handleChange(){this.props.onChange(this.props.name,!this.props.checked)}render(){let e,t=["material-icons"];Array.isArray(this.props.className)?t.push(...this.props.className):this.props.className&&t.push(this.props.className),this.props.onChange?this.props.checked?(t.push("blue","clickable"),e="check_box"):!1===this.props.checked?(t.push("blue","clickable"),e="check_box_outline_blank"):(t.push("lt-blue"),e="indeterminate_check_box"):e=this.props.checked?"check_box":"check_box_outline_blank";let s={className:t.join(" "),id:this.props.id};return this.props.onChange&&(s.onClick=this.handleChange),n().createElement("i",s,e)}}},4306:function(e,t,s){s.d(t,{A:function(){return c}});var i=s(1594),n=s.n(i),a=s(5247),o=s(4848);class r extends n().PureComponent{constructor(e){super(e),this.handleCancel=this.handleCancel.bind(this)}handleCancel(e){e.preventDefault(),this.props.onCancel(this.props.topic,this.props.index)}render(){const e=this.props.title||this.props.topic,t=this.props.invalid?"chip invalid":"chip";return(0,o.jsxs)("div",{className:t,children:[this.props.noAvatar?(0,o.jsx)("span",{className:"spacer"}):(0,o.jsx)("div",{className:"avatar-box",children:(0,o.jsx)(a.A,{authorizeURL:this.props.tinode.authorizeURL,avatar:this.props.avatar||!0,topic:this.props.topic,title:this.props.title})}),(0,o.jsx)("span",{children:e}),this.props.onCancel&&!this.props.required?(0,o.jsx)("a",{href:"#",onClick:this.handleCancel,children:"×"}):(0,o.jsx)("span",{className:"spacer"})]})}}var l=s(7981);class c extends n().Component{constructor(e){super(e),this.state=c.deriveStateFromProps(e),this.state.input="",this.state.focused=!1,this.handleTextInput=this.handleTextInput.bind(this),this.removeChipAt=this.removeChipAt.bind(this),this.handleChipCancel=this.handleChipCancel.bind(this),this.handleFocusGained=this.handleFocusGained.bind(this),this.handleFocusLost=this.handleFocusLost.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this)}static deriveStateFromProps(e){return{sortedChips:c.sortChips(e.chips,e.staticMembers),chipIndex:c.indexChips(e.chips)}}componentDidUpdate(e,t){e.chips==this.props.chips&&e.staticMembers==this.props.staticMembers&&e.prompt==this.props.prompt||this.setState(c.deriveStateFromProps(this.props)),(!t||this.props.chips.length>t.sortedChips.length)&&this.setState({input:""})}static indexChips(e){const t={};let s=0;return e.forEach(e=>{t[e.user]=s,s++}),t}static sortChips(e,t){const s=[],i=[];return e.forEach(e=>{t&&t.includes(e.user)?s.push(e):i.push(e)}),s.concat(i)}handleTextInput(e){this.setState({input:e.target.value}),this.props.filterFunc&&this.props.filterFunc(e.target.value)}removeChipAt(e){const t=this.state.sortedChips[e];this.props.onChipRemoved(t.user,this.state.chipIndex[t.user])}handleChipCancel(e,t){this.removeChipAt(t)}handleFocusGained(){this.setState({focused:!0})}handleFocusLost(){this.setState({focused:!1}),this.props.onFocusLost&&this.props.onFocusLost(this.state.input)}handleKeyDown(e){if("Backspace"===e.key){if(0==this.state.input.length&&this.state.sortedChips.length>0){const e=this.state.sortedChips.length-1;this.state.sortedChips[e].user!==this.props.staticMembers&&this.removeChipAt(e)}}else"Enter"===e.key?this.props.onEnter&&this.props.onEnter(this.state.input):"Escape"===e.key&&this.props.onCancel&&this.props.onCancel()}render(){const e=[];let t=0;const s=this.props.staticMembers||[];this.state.sortedChips.forEach(i=>{e.push((0,o.jsx)(r,{tinode:this.props.tinode,onCancel:this.handleChipCancel,avatar:(0,l.to)(i.public?i.public.photo:null),title:i.public?i.public.fn:void 0,noAvatar:this.props.avatarDisabled,topic:i.user,required:s.includes(i.user),invalid:i.invalid,index:t},i.user)),t++});const i="chip-input"+(this.state.focused?" focused":""),n=!(this.props.tabIndex>0);return(0,o.jsxs)("div",{className:i,children:[e,(0,o.jsx)("input",{type:"text",placeholder:this.props.prompt,onChange:this.handleTextInput,onFocus:this.handleFocusGained,onBlur:this.handleFocusLost,onKeyDown:this.handleKeyDown,value:this.state.input,tabIndex:this.props.tabIndex,autoFocus:n})]})}}},6565:function(e,t,s){s.d(t,{A:function(){return r}});var i=s(1594),n=s.n(i),a=s(4848);const o={muted:"notifications_off",banned:"block",staff:"verified_user"};class r extends n().PureComponent{render(){let e=null;return this.props.badges&&this.props.badges.length>0?(e=[],this.props.badges.forEach(t=>{const s=t.color?" "+t.color:"";t.icon?e.push((0,a.jsx)("i",{className:"material-icons as-badge"+s,children:o[t.icon]||t.icon},t.key||t.icon)):e.push((0,a.jsx)("span",{className:"badge"+s,children:t.name},t.key||t.name))}),(0,a.jsx)(a.Fragment,{children:e})):null}}},3717:function(e,t,s){s.d(t,{A:function(){return g}});var i=s(1594),n=s.n(i),a=s(8181),o=s(4532),r=s(1974),l=s(4848);class c extends n().PureComponent{constructor(e){super(e),this.handleClick=this.handleClick.bind(this)}handleClick(e){e.preventDefault(),e.stopPropagation(),this.props.onAction(this.props.action)}render(){const{formatMessage:e}=this.props.intl;return(0,l.jsx)("li",{onClick:this.handleClick,className:"action",children:(0,l.jsx)("div",{className:"action-text",children:e(this.props.title,this.props.values)})})}}var d=(0,a.injectIntl)(c),h=s(7981);s(3272);const p=(0,a.defineMessages)({badge_you:{id:"badge_you",defaultMessage:"you",description:"Badge for indicating the current user"},badge_owner:{id:"badge_owner",defaultMessage:"owner",description:"Badge for indicating the owner"}});class u extends n().PureComponent{render(){const{formatMessage:e}=this.props.intl,t=Array.isArray(this.props.topicSelected),s=[];let i=0;if(this.props.showSelfTopic){const e=t?this.props.topicSelected.indexOf("slf")>-1:"slf"===this.props.topicSelected;s.push((0,l.jsx)(r.A,{tinode:this.props.tinode,avatar:!0,showMode:this.props.showMode,selected:e,showCheckmark:t,onSelected:this.props.onTopicSelected,showContextMenu:this.props.showContextMenu,index:s.length,item:"slf"},"slf")),i++}if(this.props.contacts&&this.props.contacts.length>0){const n={};this.props.contacts.forEach(a=>{if(a.action)s.push((0,l.jsx)(d,{title:a.title,action:a.action,values:a.values,onAction:this.props.onAction},a.action));else{const c=this.props.showMode?a.user:a.topic||a.user;if(n[c])return;if(n[c]=!0,this.props.filterFunc&&this.props.filter){const e=[c];if(a.private&&a.private.comment&&e.push((""+a.private.comment).toLowerCase()),a.public&&a.public.fn&&e.push((""+a.public.fn).toLowerCase()),!this.props.filterFunc(this.props.filter,e))return}const d=o.Tinode.isChannelTopicName(c),u=!d&&o.Tinode.isGroupTopicName(c),g=t?this.props.topicSelected.indexOf(c)>-1:this.props.topicSelected===c,m=[];this.props.showMode&&(c==this.props.myUserId&&m.push({name:e(p.badge_you),color:"green"}),a.acs&&a.acs.isOwner()&&m.push({name:e(p.badge_owner),color:"blue"}));const f=Array.isArray(a.private)?a.private.join(","):a.private?a.private.comment:null;let b,v,w,S;if(!this.props.showMode&&a.latestMessage){const e=a.latestMessage();e&&(v=e.head?e.head.forwarded:null,S=e._status||a.msgStatus(e,!0),w=e.from!=this.props.myUserId,e.content&&(b="string"==typeof e.content?e.content.substr(0,80):o.Drafty.preview(e.content,80)))}s.push((0,l.jsx)(r.A,{tinode:this.props.tinode,title:a.public?a.public.fn:null,avatar:(0,h.to)(a.public?a.public.photo:null),comment:f,preview:b,previewIsResponse:w,forwarded:v,received:S,unread:this.props.showUnread?a.unread:0,now:a.online&&this.props.connected,acs:a.acs,showMode:this.props.showMode,badges:m,showCheckmark:t,selected:g,pinned:a.pinned,showOnline:this.props.showOnline&&!d,isChannel:d,isGroup:u,showContextMenu:this.props.showContextMenu,isVerified:a.trusted&&a.trusted.verified,isStaff:a.trusted&&a.trusted.staff,isDangerous:a.trusted&&a.trusted.danger,deleted:a._deleted,onSelected:this.props.onTopicSelected,item:c,index:s.length},c)),i++}},this)}return(0,l.jsxs)("div",{className:this.props.noScroll?null:"scrollable-panel",children:[0==i?(0,l.jsx)("div",{className:"center-medium-text",style:{whiteSpace:"pre-line"},children:this.props.emptyListMessage}):null,s.length>0?(0,l.jsx)("ul",{className:"contact-box",children:s}):null]})}}var g=(0,a.injectIntl)(u)},1974:function(e,t,s){s.d(t,{A:function(){return f}});var i=s(1594),n=s.n(i),a=s(8181),o=s(4532),r=s(6565),l=s(5247),c=s(4848);class d extends n().PureComponent{render(){return this.props.count>0?(0,c.jsx)("span",{className:"unread",children:this.props.count>9?"9+":this.props.count}):null}}var h=s(2067),p=s(7849),u=s(7256);const g=(0,a.defineMessages)({self_topic_name:{id:"self_topic_name",defaultMessage:"Saved messages",description:"Name of self topic for UI"},self_topic_comment:{id:"self_topic_comment",defaultMessage:"Notes, messages, links, files saved for posterity",description:"Comment for self topic for UI"}});class m extends n().Component{constructor(e){super(e),this.handleClick=this.handleClick.bind(this),this.handleContextClick=this.handleContextClick.bind(this)}handleClick(e){e.preventDefault(),e.stopPropagation(),this.props.onSelected&&this.props.onSelected(this.props.item,this.props.index)}handleContextClick(e){e.preventDefault(),e.stopPropagation(),this.props.showContextMenu({topicName:this.props.item,topicTitle:this.props.title,y:e.pageY,x:e.pageX})}render(){let e=this.props.title;const t=o.Tinode.isSelfTopicName(this.props.item);e?e.length>30&&(e=(0,u.W5)(e,30)):e=t?this.props.intl.formatMessage(g.self_topic_name):(0,c.jsx)("i",{children:(0,c.jsx)(a.FormattedMessage,{id:"unnamed_topic",defaultMessage:"Unnamed",description:"Title shown when the topic has no name"})});const s=this.props.now?"online":"offline",i=!this.props.avatar||this.props.avatar,m=this.props.badges?this.props.badges.slice():[],f=[];let b;this.props.isVerified&&f.push({icon:"verified",color:"verified-color"}),this.props.isStaff&&f.push({icon:"staff",color:"staff-color"}),this.props.isDangerous&&f.push({icon:"dangerous",color:"danger-color"}),this.props.acs&&(this.props.showMode&&m.push({name:this.props.acs.getMode(),key:"mode"}),this.props.acs.isMuted()&&f.push({icon:"muted"}),this.props.acs.isJoiner()||f.push({icon:"banned"})),"string"==typeof this.props.preview?b=this.props.preview:o.Drafty.isValid(this.props.preview)?b=n().createElement(n().Fragment,null,o.Drafty.format(this.props.preview,h.TU,{formatMessage:this.props.intl.formatMessage,previewIsResponse:this.props.previewIsResponse})):this.props.preview&&(b=(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)("i",{className:"material-icons gray",children:"warning_amber"})," ",(0,c.jsx)("i",{className:"gray",children:(0,c.jsx)(a.FormattedMessage,{id:"invalid_content",defaultMessage:"invalid content",description:"Shown when the message is unreadable"})})]}));const v=(0,p.LO)(this.props.received),w=v?(0,c.jsx)("i",{className:"material-icons small space-right"+(v.color?" "+v.color:""),children:v.name}):null,S="contact-title"+(this.props.deleted?" deleted":""),C=b||this.props.comment||(t?this.props.intl.formatMessage(g.self_topic_comment):" "),y=this.props.showCheckmark?null:this.props.selected?"selected":this.props.pinned?"tpinned":null;return(0,c.jsxs)("li",{className:y,onClick:this.handleClick,children:[(0,c.jsxs)("div",{className:"avatar-box",children:[(0,c.jsx)(l.A,{authorizeURL:this.props.tinode.authorizeURL,avatar:i,title:this.props.title,topic:this.props.item,deleted:this.props.deleted}),this.props.deleted?(0,c.jsx)("i",{className:"deleted material-icons",children:"cancel"}):!t&&this.props.showOnline?(0,c.jsx)("span",{className:s}):this.props.showCheckmark&&this.props.selected?(0,c.jsx)("i",{className:"checkmark material-icons",children:"check_circle"}):null]}),(0,c.jsxs)("div",{className:"text-box",children:[(0,c.jsxs)("div",{children:[(0,c.jsx)("span",{className:S,children:e}),this.props.isGroup?(0,c.jsx)("i",{className:"material-icons as-badge",children:"group"}):null,this.props.isChannel?(0,c.jsx)("i",{className:"material-icons as-badge",children:"podcasts"}):null,t?null:(0,c.jsx)(r.A,{badges:f}),this.props.deleted?null:(0,c.jsx)(d,{count:this.props.unread})]}),this.props.showMode?(0,c.jsx)("span",{children:(0,c.jsx)(r.A,{badges:m})}):this.props.small?null:(0,c.jsxs)("div",{className:"contact-comment",children:[w,(0,c.jsx)("span",{children:C})]})]}),this.props.showContextMenu?(0,c.jsx)("span",{className:"menuTrigger",children:(0,c.jsx)("a",{href:"#",onClick:this.handleContextClick,children:(0,c.jsx)("i",{className:"material-icons",children:"expand_more"})})}):null]})}}var f=(0,a.injectIntl)(m)},3405:function(e,t,s){s.d(t,{A:function(){return r}});var i=s(1594),n=s.n(i),a=s(5370),o=s(4848);class r extends n().PureComponent{constructor(e){super(e),this.state={show:!1},this.hide=this.hide.bind(this)}componentDidUpdate(e){e.level!==this.props.level&&this.setState({show:!!this.props.level})}hide(){this.setState({show:!1}),this.props.onClearError&&this.props.onClearError()}render(){const e={err:"error",warn:"warning",info:"info"}[this.props.level]||"",t="info-box "+e;return(0,o.jsxs)("div",{className:t,children:[(0,o.jsx)("div",{className:"icon",children:(0,o.jsx)("i",{className:"material-icons",children:e})}),(0,o.jsxs)("span",{children:[this.props.text,this.props.action?(0,o.jsxs)(o.Fragment,{children:["  ",(0,o.jsx)("a",{href:"#",style:{whiteSpace:"nowrap"},onClick:e=>{e.preventDefault(),this.props.action()},children:this.props.actionText})]}):null]}),(0,o.jsx)("div",{className:"cancel",children:(0,o.jsx)(a.A,{onCancel:this.hide})})]})}}},4752:function(e,t,s){s.d(t,{A:function(){return r}});var i=s(1594),n=s.n(i),a=s(8181),o=s(4848);class r extends n().PureComponent{render(){return(0,o.jsxs)("div",{className:"uploader",children:[(0,o.jsx)("div",{children:(0,o.jsx)("span",{style:{width:100*this.props.progress+"%"}})}),this.props.progress<.999?(0,o.jsxs)("a",{href:"#",onClick:e=>{e.preventDefault(),this.props.onCancel()},children:[(0,o.jsx)("i",{className:"material-icons",children:"close"})," ",(0,o.jsx)(a.FormattedMessage,{id:"action_cancel",defaultMessage:"cancel",description:"Call to action [cancel]"})]}):(0,o.jsx)(a.FormattedMessage,{id:"upload_finishing",defaultMessage:"finishing...",description:"Notification that upload is finishing"})]})}}},2514:function(e,t,s){s.d(t,{A:function(){return r}});var i=s(1594),n=s.n(i),a=s(8568),o=s(4848);class r extends n().Component{constructor(e){super(e),this.selfRef=n().createRef(),this.state={active:e.active,initialValue:e.value||"",value:e.value||"",valid:!0},this.handeTextChange=this.handeTextChange.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleStartEditing=this.handleStartEditing.bind(this),this.handleEditingFinished=this.handleEditingFinished.bind(this),this.handlePasswordFinished=this.handlePasswordFinished.bind(this)}componentDidUpdate(e,t){const s=this.props.value||"";t.initialValue==s||t.active||this.setState({initialValue:s,value:s})}handeTextChange(e){this.setState({value:e.target.value||""}),this.props.validator&&Promise.resolve(this.props.validator(e.target.value)).then(e=>{this.setState({valid:e})}).catch(e=>{e&&this.setState({valid:!1})})}handleKeyDown(e){27===e.keyCode?this.setState({value:this.props.value,active:!1}):13===e.keyCode&&this.handleEditingFinished(e)}handleStartEditing(){this.props.readOnly||this.setState({active:!0},e=>{this.selfRef.current&&this.selfRef.current.focus()})}handleEditingFinished(e){const t=this.state.value.trim();!this.props.required||e.target.checkValidity()&&t?(this.setState({active:!1}),(t||this.props.value)&&t!==this.props.value&&this.state.valid&&this.props.onFinished(t)):this.setState({value:this.props.value,active:!1})}handlePasswordFinished(e){this.setState({active:!1}),e&&e!==this.props.value&&this.props.onFinished(e)}render(){if(!this.state.active){let e="password"==this.props.type?"••••••••":this.state.value,t="in-place-edit"+(this.props.readOnly?" disabled":"");return e||(e=this.props.placeholder,t+=" placeholder"),this.props.multiline&&1!=this.props.multiline||(t+=" short"),(0,o.jsxs)("span",{className:t,onClick:this.handleStartEditing,children:[this.props.iconLeft&&(0,o.jsx)("i",{className:"material-icons light-gray",children:this.props.iconLeft}),(0,o.jsx)("span",{children:e}),this.props.iconRight&&(0,o.jsx)("i",{className:"material-icons light-gray",children:this.props.iconRight})]})}let e;const t={};return"password"==this.props.type?(e=a.A,t.onFinished=this.handlePasswordFinished):(this.props.multiline>1?(e="textarea",t.rows=this.props.multiline,t.className="in-place-edit"):(e="input",t.type=this.props.type||"text",t.className="in-place-edit"+(this.props.iconLeft?" with-icon-left":this.props.iconRight?" with-icon-right":""),this.props.maxLength&&(t.maxLength=this.props.maxLength)),t.value=this.state.value,t.className+=this.state.valid?"":" invalid",t.ref=this.selfRef,t.onChange=this.handeTextChange,t.onKeyDown=this.handleKeyDown,t.onBlur=this.handleEditingFinished),t.placeholder=this.props.placeholder,t.required=this.props.required?"required":"",t.autoComplete=this.props.autoComplete,t.autoFocus=!0,void 0!==this.props.spellCheck&&(t.spellCheck=this.props.spellCheck?"true":"false"),this.props.iconLeft||this.props.iconRight?(0,o.jsxs)(o.Fragment,{children:[this.props.iconLeft&&(0,o.jsx)("i",{className:"material-icons light-gray",children:this.props.iconLeft}),n().createElement(e,t,null),this.props.iconRight&&(0,o.jsx)("i",{className:"material-icons light-gray",children:this.props.iconRight})]}):n().createElement(e,t,null)}}},5247:function(e,t,s){s.d(t,{A:function(){return d}});var i=s(1594),n=s.n(i),a=s(4532),o=s(7256),r=s(7849),l=s(3272),c=s(4848);class d extends n().PureComponent{render(){let e;if(!0===this.props.avatar)if(a.Tinode.isSelfTopicName(this.props.topic))e=(0,c.jsx)("img",{className:"avatar self",alt:"avatar",src:l.Yd});else{const t=a.Tinode.isGroupTopicName(this.props.topic),s=(0,o.kJ)(this.props.topic,t);if(this.props.topic&&this.props.title&&this.props.title.trim()){const t=this.props.title.trim().charAt(0),i="lettertile "+s+(this.props.deleted?" disabled":"");e=(0,c.jsx)("div",{className:i,children:(0,c.jsx)("div",{children:t})})}else{const i="material-icons "+s+(this.props.deleted?" disabled":"");e=t?(0,c.jsx)("i",{className:i,children:"group"}):(0,c.jsx)("i",{className:i,children:"person"})}}else if(this.props.avatar){const t=this.props.authorizeURL((0,r.wk)(this.props.avatar,"image")),s="avatar"+(this.props.deleted?" deleted":"");e=(0,c.jsx)("img",{className:s,alt:"avatar",src:t,onError:e=>{e.target.onerror=null,e.target.src="img/broken_image.png"}})}else e=null;return e}}},9304:function(e,t,s){s.d(t,{A:function(){return o}});var i=s(1594),n=s.n(i),a=s(4848);class o extends n().PureComponent{render(){const e="load-spinner-box"+(this.props.large?" large":"")+(this.props.clear?" clear":"")+(this.props.centered?" centered":"");return this.props.show?(0,a.jsx)("div",{className:e,children:(0,a.jsx)("div",{className:"loader-spinner"})}):null}}},5370:function(e,t,s){s.d(t,{A:function(){return o}});var i=s(1594),n=s.n(i),a=s(4848);class o extends n().PureComponent{render(){return(0,a.jsx)("a",{href:"#",onClick:e=>{e.preventDefault(),this.props.onCancel()},children:(0,a.jsx)("i",{className:"material-icons",children:"close"})})}}},1192:function(e,t,s){s.d(t,{A:function(){return d}});var i=s(1594),n=s.n(i),a=s(8181),o=s(4306),r=s(4532),l=(s(3272),s(7849)),c=s(4848);class d extends n().Component{constructor(e){super(e),this.state={tags:this.props.tags||[],alias:r.Tinode.tagByPrefix(this.props.tags,r.Tinode.TAG_ALIAS)||"",tagInput:"",activated:this.props.activated},this.handleTagInput=this.handleTagInput.bind(this),this.handleAddTag=this.handleAddTag.bind(this),this.handleRemoveTag=this.handleRemoveTag.bind(this),this.handleSubmit=this.handleSubmit.bind(this),this.handleCancel=this.handleCancel.bind(this)}static getDerivedStateFromProps(e,t){const s=e.tags||[];return(0,l.af)(s,t.tags)||t.activated?null:{tags:s||[],alias:r.Tinode.tagByPrefix(s,r.Tinode.TAG_ALIAS)||""}}handleTagInput(e){if(this.setState({tagInput:e}),e.length>0){const t=e[e.length-1];'"'==e[0]?e.length>1&&'"'==t&&this.handleAddTag(e.substring(1,e.length-1)):","!=t&&" "!=t&&";"!=t&&'"'!=t||this.handleAddTag(e.substring(0,e.length-1).trim())}}handleAddTag(e){const t=this.props.tinode.getServerParam(r.Tinode.MAX_TAG_COUNT,16);if(e.length>0&&this.state.tags.length{i!=this.state.alias&&s.push({user:i,invalid:i.lengtht})}):(this.state.tags.forEach(e=>{e!=this.state.alias&&s.push((0,c.jsx)("span",{className:"badge",children:e},s.length))}),0==s.length&&(s=(0,c.jsx)("i",{children:(0,c.jsx)(a.FormattedMessage,{id:"tags_not_found",defaultMessage:"No tags defined. Add some.",description:""})}))),(0,c.jsxs)("div",{className:"panel-form-column",children:[(0,c.jsx)("div",{className:"panel-form-row",children:(0,c.jsx)("label",{className:"small",children:this.props.title})}),this.state.activated?(0,c.jsxs)("div",{children:[(0,c.jsx)(a.FormattedMessage,{id:"tags_editor_no_tags",defaultMessage:"Add some tags",description:"Tag editor prompt when no tags are found.",children:e=>(0,c.jsx)(o.A,{tinode:this.props.tinode,chips:s,avatarDisabled:!0,prompt:e,tabIndex:this.props.tabIndex,onEnter:this.handleAddTag,onFocusLost:this.handleAddTag,onCancel:this.handleCancel,onChipRemoved:this.handleRemoveTag,filterFunc:this.handleTagInput})}),this.props.onSubmit||this.props.onCancel?(0,c.jsxs)("div",{id:"tag-manager-buttons",className:"dialog-buttons panel-form-row",children:[(0,c.jsx)("button",{className:"outline",onClick:this.handleCancel,children:(0,c.jsx)(a.FormattedMessage,{id:"button_cancel",defaultMessage:"Cancel",description:"Button [Cancel]"})}),(0,c.jsx)("button",{className:"primary",onClick:this.handleSubmit,children:(0,c.jsx)(a.FormattedMessage,{id:"button_ok",defaultMessage:"OK",description:"Button [OK]"})})]}):null]}):(0,c.jsxs)("div",{className:"quoted",children:[(0,c.jsxs)("a",{href:"#",className:"flat-button",onClick:e=>{e.preventDefault(),this.setState({activated:!0})},children:[(0,c.jsx)("i",{className:"material-icons",children:"edit"}),"  ",(0,c.jsx)(a.FormattedMessage,{id:"title_manage_tags",defaultMessage:"Manage",description:"Section title for the list of tags"})]}),(0,c.jsx)(c.Fragment,{children:s})]})]})}}},8568:function(e,t,s){s.d(t,{A:function(){return o}});var i=s(1594),n=s.n(i),a=s(4848);class o extends n().PureComponent{constructor(e){super(e),this.inputRef=n().createRef(),this.state={value:this.props.value||"",visible:!1},this.handleVisibility=this.handleVisibility.bind(this),this.handeTextChange=this.handeTextChange.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleEditingFinished=this.handleEditingFinished.bind(this)}componentDidMount(){this.props.autoFocus&&this.inputRef.current.focus()}handeTextChange(e){this.setState({value:e.target.value}),this.props.onChange&&this.props.onChange(e)}handleVisibility(e){e.preventDefault(),this.setState({visible:!this.state.visible})}handleKeyDown(e){27==e.keyCode?(this.setState({value:this.props.value||"",visible:!1}),this.props.onFinished&&this.props.onFinished()):13==e.keyCode&&this.handleEditingFinished()}handleEditingFinished(e){if(e){let t=e.currentTarget;setTimeout(e=>{t.contains(document.activeElement)||this.props.onFinished&&this.props.onFinished(this.state.value)},0)}else this.props.onFinished&&this.props.onFinished(this.state.value.trim())}render(){return(0,a.jsxs)("div",{tabIndex:"-1",className:"group-focus",onBlur:this.handleEditingFinished,children:[(0,a.jsx)("input",{className:"with-icon-right",type:this.state.visible?"text":"password",value:this.state.value,placeholder:this.props.placeholder,maxLength:32,required:this.props.required?"required":"",autoFocus:this.props.autoFocus?"autoFocus":"",autoComplete:this.props.autoComplete,onChange:this.handeTextChange,onKeyDown:this.handleKeyDown,ref:this.inputRef}),(0,a.jsx)("span",{onClick:this.handleVisibility,children:(0,a.jsx)("i",{className:"material-icons clickable light-gray",children:this.state.visible?"visibility":"visibility_off"})})]})}}},5338:function(e,t,s){var i=s(5206);t.H=i.createRoot,i.hydrateRoot},1020:function(e,t,s){var i=s(1594),n=Symbol.for("react.element"),a=Symbol.for("react.fragment"),o=Object.prototype.hasOwnProperty,r=i.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function c(e,t,s){var i,a={},c=null,d=null;for(i in void 0!==s&&(c=""+s),void 0!==t.key&&(c=""+t.key),void 0!==t.ref&&(d=t.ref),t)o.call(t,i)&&!l.hasOwnProperty(i)&&(a[i]=t[i]);if(e&&e.defaultProps)for(i in t=e.defaultProps)void 0===a[i]&&(a[i]=t[i]);return{$$typeof:n,type:e,key:c,ref:d,props:a,_owner:r.current}}t.Fragment=a,t.jsx=c,t.jsxs=c},4848:function(e,t,s){e.exports=s(1020)},9593:function(e){e.exports=QRCode},1594:function(e){e.exports=React},5206:function(e){e.exports=ReactDOM},8181:function(e){e.exports=ReactIntl},4532:function(e){e.exports=tinode},1781:function(e){e.exports=JSON.parse('{"patt":[{"name":"a00.png","size":200},{"name":"a01.jpg","size":384},{"name":"a02.jpg","size":384},{"name":"a03.jpg","size":384},{"name":"a04.png","size":400},{"name":"a05.jpg","size":400},{"name":"a06.jpg","size":256},{"name":"a07.jpg","size":384},{"name":"a08.jpg","size":384},{"name":"a09.jpg","size":400},{"name":"a10.jpg","size":256},{"name":"a11.png","size":200}],"img":[{"name":"w01.jpg","pr":"p01.jpg"},{"name":"w02.jpg","pr":"p02.jpg"},{"name":"w03.jpg","pr":"p03.jpg"},{"name":"w04.jpg","pr":"p04.jpg"},{"name":"w05.jpg","pr":"p05.jpg"},{"name":"w06.jpg","pr":"p06.jpg"},{"name":"w07.jpg","pr":"p07.jpg"},{"name":"w08.jpg","pr":"p08.jpg"},{"name":"w09.jpg","pr":"p09.jpg"},{"name":"w10.jpg","pr":"p10.jpg"},{"name":"w11.jpg","pr":"p11.jpg"},{"name":"w12.jpg","pr":"p12.jpg"},{"name":"w13.jpg","pr":"p13.jpg"},{"name":"w14.jpg","pr":"p14.jpg"},{"name":"w15.jpg","pr":"p15.jpg"},{"name":"w16.jpg","pr":"p16.jpg"},{"name":"w17.jpg","pr":"p17.jpg"},{"name":"w18.jpg","pr":"p18.jpg"},{"name":"w19.jpg","pr":"p19.jpg"},{"name":"w20.jpg","pr":"p20.jpg"},{"name":"w21.jpg","pr":"p21.jpg"},{"name":"w22.jpg","pr":"p22.jpg"},{"name":"w23.jpg","pr":"p23.jpg"},{"name":"w24.jpg","pr":"p24.jpg"}]}')}},a={};function o(e){var t=a[e];if(void 0!==t)return t.exports;var s=a[e]={exports:{}};return n[e].call(s.exports,s,s.exports,o),s.exports}o.m=n,o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,{a:t}),t},t=Object.getPrototypeOf?function(e){return Object.getPrototypeOf(e)}:function(e){return e.__proto__},o.t=function(s,i){if(1&i&&(s=this(s)),8&i)return s;if("object"==typeof s&&s){if(4&i&&s.__esModule)return s;if(16&i&&"function"==typeof s.then)return s}var n=Object.create(null);o.r(n);var a={};e=e||[null,t({}),t([]),t(t)];for(var r=2&i&&s;("object"==typeof r||"function"==typeof r)&&!~e.indexOf(r);r=t(r))Object.getOwnPropertyNames(r).forEach(function(e){a[e]=function(){return s[e]}});return a.default=function(){return s},o.d(n,a),n},o.d=function(e,t){if(Array.isArray(t))for(var s=0;s>6|192,t[s++]=63&n|128):55296==(64512&n)&&i+1>18|240,t[s++]=n>>12&63|128,t[s++]=n>>6&63|128,t[s++]=63&n|128):(t[s++]=n>>12|224,t[s++]=n>>6&63|128,t[s++]=63&n|128)}return t},p={byteToCharMap_:null,charToByteMap_:null,byteToCharMapWebSafe_:null,charToByteMapWebSafe_:null,ENCODED_VALS_BASE:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",get ENCODED_VALS(){return this.ENCODED_VALS_BASE+"+/="},get ENCODED_VALS_WEBSAFE(){return this.ENCODED_VALS_BASE+"-_."},HAS_NATIVE_SUPPORT:"function"==typeof atob,encodeByteArray(e,t){if(!Array.isArray(e))throw Error("encodeByteArray takes an array as a parameter");this.init_();const s=t?this.byteToCharMapWebSafe_:this.byteToCharMap_,i=[];for(let t=0;t>2,d=(3&n)<<4|o>>4;let h=(15&o)<<2|l>>6,p=63&l;r||(p=64,a||(h=64)),i.push(s[c],s[d],s[h],s[p])}return i.join("")},encodeString(e,t){return this.HAS_NATIVE_SUPPORT&&!t?btoa(e):this.encodeByteArray(h(e),t)},decodeString(e,t){return this.HAS_NATIVE_SUPPORT&&!t?atob(e):function(e){const t=[];let s=0,i=0;for(;s191&&n<224){const a=e[s++];t[i++]=String.fromCharCode((31&n)<<6|63&a)}else if(n>239&&n<365){const a=((7&n)<<18|(63&e[s++])<<12|(63&e[s++])<<6|63&e[s++])-65536;t[i++]=String.fromCharCode(55296+(a>>10)),t[i++]=String.fromCharCode(56320+(1023&a))}else{const a=e[s++],o=e[s++];t[i++]=String.fromCharCode((15&n)<<12|(63&a)<<6|63&o)}}return t.join("")}(this.decodeStringToByteArray(e,t))},decodeStringToByteArray(e,t){this.init_();const s=t?this.charToByteMapWebSafe_:this.charToByteMap_,i=[];for(let t=0;t>4;if(i.push(l),64!==o){const e=a<<4&240|o>>2;if(i.push(e),64!==r){const e=o<<6&192|r;i.push(e)}}}return i},init_(){if(!this.byteToCharMap_){this.byteToCharMap_={},this.charToByteMap_={},this.byteToCharMapWebSafe_={},this.charToByteMapWebSafe_={};for(let e=0;e=this.ENCODED_VALS_BASE.length&&(this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(e)]=e,this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(e)]=e)}}};class u extends Error{constructor(){super(...arguments),this.name="DecodeBase64StringError"}}const g=function(e){return function(e){const t=h(e);return p.encodeByteArray(t,!0)}(e).replace(/\./g,"")},m=()=>{try{return function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==o.g)return o.g;throw new Error("Unable to locate global object.")}().__FIREBASE_DEFAULTS__||(()=>{if("undefined"==typeof process||void 0===process.env)return;const e=process.env.__FIREBASE_DEFAULTS__;return e?JSON.parse(e):void 0})()||(()=>{if("undefined"==typeof document)return;let e;try{e=document.cookie.match(/__FIREBASE_DEFAULTS__=([^;]+)/)}catch(e){return}const t=e&&function(e){try{return p.decodeString(e,!0)}catch(e){console.error("base64Decode failed: ",e)}return null}(e[1]);return t&&JSON.parse(t)})()}catch(e){return void console.info(`Unable to get __FIREBASE_DEFAULTS__ due to: ${e}`)}},f=()=>m()?.config;class b{constructor(){this.reject=()=>{},this.resolve=()=>{},this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}wrapCallback(e){return(t,s)=>{t?this.reject(t):this.resolve(s),"function"==typeof e&&(this.promise.catch(()=>{}),1===e.length?e(t):e(t,s))}}}function v(){try{return"object"==typeof indexedDB}catch(e){return!1}}function w(){return new Promise((e,t)=>{try{let s=!0;const i="validate-browser-context-for-indexeddb-analytics-module",n=self.indexedDB.open(i);n.onsuccess=()=>{n.result.close(),s||self.indexedDB.deleteDatabase(i),e(!0)},n.onupgradeneeded=()=>{s=!1},n.onerror=()=>{t(n.error?.message||"")}}catch(e){t(e)}})}class S extends Error{constructor(e,t,s){super(t),this.code=e,this.customData=s,this.name="FirebaseError",Object.setPrototypeOf(this,S.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,C.prototype.create)}}class C{constructor(e,t,s){this.service=e,this.serviceName=t,this.errors=s}create(e,...t){const s=t[0]||{},i=`${this.service}/${e}`,n=this.errors[e],a=n?function(e,t){return e.replace(y,(e,s)=>{const i=t[s];return null!=i?String(i):`<${s}?>`})}(n,s):"Error",o=`${this.serviceName}: ${a} (${i}).`;return new S(i,o,s)}}const y=/\{\$([^}]+)}/g;function x(e,t){if(e===t)return!0;const s=Object.keys(e),i=Object.keys(t);for(const n of s){if(!i.includes(n))return!1;const s=e[n],a=t[n];if(_(s)&&_(a)){if(!x(s,a))return!1}else if(s!==a)return!1}for(const e of i)if(!s.includes(e))return!1;return!0}function _(e){return null!==e&&"object"==typeof e}function M(e){return e&&e._delegate?e._delegate:e}class T{constructor(e,t,s){this.name=e,this.instanceFactory=t,this.type=s,this.multipleInstances=!1,this.serviceProps={},this.instantiationMode="LAZY",this.onInstanceCreated=null}setInstantiationMode(e){return this.instantiationMode=e,this}setMultipleInstances(e){return this.multipleInstances=e,this}setServiceProps(e){return this.serviceProps=e,this}setInstanceCreatedCallback(e){return this.onInstanceCreated=e,this}}const j="[DEFAULT]";class A{constructor(e,t){this.name=e,this.container=t,this.component=null,this.instances=new Map,this.instancesDeferred=new Map,this.instancesOptions=new Map,this.onInitCallbacks=new Map}get(e){const t=this.normalizeInstanceIdentifier(e);if(!this.instancesDeferred.has(t)){const e=new b;if(this.instancesDeferred.set(t,e),this.isInitialized(t)||this.shouldAutoInitialize())try{const s=this.getOrInitializeService({instanceIdentifier:t});s&&e.resolve(s)}catch(e){}}return this.instancesDeferred.get(t).promise}getImmediate(e){const t=this.normalizeInstanceIdentifier(e?.identifier),s=e?.optional??!1;if(!this.isInitialized(t)&&!this.shouldAutoInitialize()){if(s)return null;throw Error(`Service ${this.name} is not available`)}try{return this.getOrInitializeService({instanceIdentifier:t})}catch(e){if(s)return null;throw e}}getComponent(){return this.component}setComponent(e){if(e.name!==this.name)throw Error(`Mismatching Component ${e.name} for Provider ${this.name}.`);if(this.component)throw Error(`Component for ${this.name} has already been provided`);if(this.component=e,this.shouldAutoInitialize()){if(function(e){return"EAGER"===e.instantiationMode}(e))try{this.getOrInitializeService({instanceIdentifier:j})}catch(e){}for(const[e,t]of this.instancesDeferred.entries()){const s=this.normalizeInstanceIdentifier(e);try{const e=this.getOrInitializeService({instanceIdentifier:s});t.resolve(e)}catch(e){}}}}clearInstance(e=j){this.instancesDeferred.delete(e),this.instancesOptions.delete(e),this.instances.delete(e)}async delete(){const e=Array.from(this.instances.values());await Promise.all([...e.filter(e=>"INTERNAL"in e).map(e=>e.INTERNAL.delete()),...e.filter(e=>"_delete"in e).map(e=>e._delete())])}isComponentSet(){return null!=this.component}isInitialized(e=j){return this.instances.has(e)}getOptions(e=j){return this.instancesOptions.get(e)||{}}initialize(e={}){const{options:t={}}=e,s=this.normalizeInstanceIdentifier(e.instanceIdentifier);if(this.isInitialized(s))throw Error(`${this.name}(${s}) has already been initialized`);if(!this.isComponentSet())throw Error(`Component ${this.name} has not been registered yet`);const i=this.getOrInitializeService({instanceIdentifier:s,options:t});for(const[e,t]of this.instancesDeferred.entries())s===this.normalizeInstanceIdentifier(e)&&t.resolve(i);return i}onInit(e,t){const s=this.normalizeInstanceIdentifier(t),i=this.onInitCallbacks.get(s)??new Set;i.add(e),this.onInitCallbacks.set(s,i);const n=this.instances.get(s);return n&&e(n,s),()=>{i.delete(e)}}invokeOnInitCallbacks(e,t){const s=this.onInitCallbacks.get(t);if(s)for(const i of s)try{i(e,t)}catch{}}getOrInitializeService({instanceIdentifier:e,options:t={}}){let s=this.instances.get(e);if(!s&&this.component&&(s=this.component.instanceFactory(this.container,{instanceIdentifier:(i=e,i===j?void 0:i),options:t}),this.instances.set(e,s),this.instancesOptions.set(e,t),this.invokeOnInitCallbacks(s,e),this.component.onInstanceCreated))try{this.component.onInstanceCreated(this.container,e,s)}catch{}var i;return s||null}normalizeInstanceIdentifier(e=j){return this.component?this.component.multipleInstances?e:j:e}shouldAutoInitialize(){return!!this.component&&"EXPLICIT"!==this.component.instantiationMode}}class k{constructor(e){this.name=e,this.providers=new Map}addComponent(e){const t=this.getProvider(e.name);if(t.isComponentSet())throw new Error(`Component ${e.name} has already been registered with ${this.name}`);t.setComponent(e)}addOrOverwriteComponent(e){this.getProvider(e.name).isComponentSet()&&this.providers.delete(e.name),this.addComponent(e)}getProvider(e){if(this.providers.has(e))return this.providers.get(e);const t=new A(e,this);return this.providers.set(e,t),t}getProviders(){return Array.from(this.providers.values())}}const E=[];var N;!function(e){e[e.DEBUG=0]="DEBUG",e[e.VERBOSE=1]="VERBOSE",e[e.INFO=2]="INFO",e[e.WARN=3]="WARN",e[e.ERROR=4]="ERROR",e[e.SILENT=5]="SILENT"}(N||(N={}));const I={debug:N.DEBUG,verbose:N.VERBOSE,info:N.INFO,warn:N.WARN,error:N.ERROR,silent:N.SILENT},D=N.INFO,P={[N.DEBUG]:"log",[N.VERBOSE]:"log",[N.INFO]:"info",[N.WARN]:"warn",[N.ERROR]:"error"},R=(e,t,...s)=>{if(t{const i=()=>{e.removeEventListener("complete",n),e.removeEventListener("error",a),e.removeEventListener("abort",a)},n=()=>{t(),i()},a=()=>{s(e.error||new DOMException("AbortError","AbortError")),i()};e.addEventListener("complete",n),e.addEventListener("error",a),e.addEventListener("abort",a)});O.set(e,t)}(e),s=e,(F||(F=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])).some(e=>s instanceof e)?new Proxy(e,z):e);var t,s}function W(e){if(e instanceof IDBRequest)return function(e){const t=new Promise((t,s)=>{const i=()=>{e.removeEventListener("success",n),e.removeEventListener("error",a)},n=()=>{t(W(e.result)),i()},a=()=>{s(e.error),i()};e.addEventListener("success",n),e.addEventListener("error",a)});return t.then(t=>{t instanceof IDBCursor&&L.set(t,e)}).catch(()=>{}),q.set(t,e),t}(e);if(H.has(e))return H.get(e);const t=V(e);return t!==e&&(H.set(e,t),q.set(t,e)),t}const K=e=>q.get(e);function $(e,t,{blocked:s,upgrade:i,blocking:n,terminated:a}={}){const o=indexedDB.open(e,t),r=W(o);return i&&o.addEventListener("upgradeneeded",e=>{i(W(o.result),e.oldVersion,e.newVersion,W(o.transaction),e)}),s&&o.addEventListener("blocked",e=>s(e.oldVersion,e.newVersion,e)),r.then(e=>{a&&e.addEventListener("close",()=>a()),n&&e.addEventListener("versionchange",e=>n(e.oldVersion,e.newVersion,e))}).catch(()=>{}),r}function G(e,{blocked:t}={}){const s=indexedDB.deleteDatabase(e);return t&&s.addEventListener("blocked",e=>t(e.oldVersion,e)),W(s).then(()=>{})}const Y=["get","getKey","getAll","getAllKeys","count"],X=["put","add","delete","clear"],J=new Map;function Q(e,t){if(!(e instanceof IDBDatabase)||t in e||"string"!=typeof t)return;if(J.get(t))return J.get(t);const s=t.replace(/FromIndex$/,""),i=t!==s,n=X.includes(s);if(!(s in(i?IDBIndex:IDBObjectStore).prototype)||!n&&!Y.includes(s))return;const a=async function(e,...t){const a=this.transaction(e,n?"readwrite":"readonly");let o=a.store;return i&&(o=o.index(t.shift())),(await Promise.all([o[s](...t),n&&a.done]))[0]};return J.set(t,a),a}var Z;Z=z,z={...Z,get:(e,t,s)=>Q(e,t)||Z.get(e,t,s),has:(e,t)=>!!Q(e,t)||Z.has(e,t)};class ee{constructor(e){this.container=e}getPlatformInfoString(){return this.container.getProviders().map(e=>{if(function(e){const t=e.getComponent();return"VERSION"===t?.type}(e)){const t=e.getImmediate();return`${t.library}/${t.version}`}return null}).filter(e=>e).join(" ")}}const te="@firebase/app",se="0.15.0",ie=new class{constructor(e){this.name=e,this._logLevel=D,this._logHandler=R,this._userLogHandler=null,E.push(this)}get logLevel(){return this._logLevel}set logLevel(e){if(!(e in N))throw new TypeError(`Invalid value "${e}" assigned to \`logLevel\``);this._logLevel=e}setLogLevel(e){this._logLevel="string"==typeof e?I[e]:e}get logHandler(){return this._logHandler}set logHandler(e){if("function"!=typeof e)throw new TypeError("Value assigned to `logHandler` must be a function");this._logHandler=e}get userLogHandler(){return this._userLogHandler}set userLogHandler(e){this._userLogHandler=e}debug(...e){this._userLogHandler&&this._userLogHandler(this,N.DEBUG,...e),this._logHandler(this,N.DEBUG,...e)}log(...e){this._userLogHandler&&this._userLogHandler(this,N.VERBOSE,...e),this._logHandler(this,N.VERBOSE,...e)}info(...e){this._userLogHandler&&this._userLogHandler(this,N.INFO,...e),this._logHandler(this,N.INFO,...e)}warn(...e){this._userLogHandler&&this._userLogHandler(this,N.WARN,...e),this._logHandler(this,N.WARN,...e)}error(...e){this._userLogHandler&&this._userLogHandler(this,N.ERROR,...e),this._logHandler(this,N.ERROR,...e)}}("@firebase/app"),ne="@firebase/app-compat",ae="@firebase/analytics-compat",oe="@firebase/analytics",re="@firebase/app-check-compat",le="@firebase/app-check",ce="@firebase/auth",de="@firebase/auth-compat",he="@firebase/database",pe="@firebase/data-connect",ue="@firebase/database-compat",ge="@firebase/functions",me="@firebase/functions-compat",fe="@firebase/installations",be="@firebase/installations-compat",ve="@firebase/messaging",we="@firebase/messaging-compat",Se="@firebase/performance",Ce="@firebase/performance-compat",ye="@firebase/remote-config",xe="@firebase/remote-config-compat",_e="@firebase/storage",Me="@firebase/storage-compat",Te="@firebase/firestore",je="@firebase/ai",Ae="@firebase/firestore-compat",ke="firebase",Ee="[DEFAULT]",Ne={[te]:"fire-core",[ne]:"fire-core-compat",[oe]:"fire-analytics",[ae]:"fire-analytics-compat",[le]:"fire-app-check",[re]:"fire-app-check-compat",[ce]:"fire-auth",[de]:"fire-auth-compat",[he]:"fire-rtdb",[pe]:"fire-data-connect",[ue]:"fire-rtdb-compat",[ge]:"fire-fn",[me]:"fire-fn-compat",[fe]:"fire-iid",[be]:"fire-iid-compat",[ve]:"fire-fcm",[we]:"fire-fcm-compat",[Se]:"fire-perf",[Ce]:"fire-perf-compat",[ye]:"fire-rc",[xe]:"fire-rc-compat",[_e]:"fire-gcs",[Me]:"fire-gcs-compat",[Te]:"fire-fst",[Ae]:"fire-fst-compat",[je]:"fire-vertex","fire-js":"fire-js",[ke]:"fire-js-all"},Ie=new Map,De=new Map,Pe=new Map;function Re(e,t){try{e.container.addComponent(t)}catch(s){ie.debug(`Component ${t.name} failed to register with FirebaseApp ${e.name}`,s)}}function Fe(e){const t=e.name;if(Pe.has(t))return ie.debug(`There were multiple attempts to register component ${t}.`),!1;Pe.set(t,e);for(const t of Ie.values())Re(t,e);for(const t of De.values())Re(t,e);return!0}function Ue(e,t){const s=e.container.getProvider("heartbeat").getImmediate({optional:!0});return s&&s.triggerHeartbeat(),e.container.getProvider(t)}const Le=new C("app","Firebase",{"no-app":"No Firebase App '{$appName}' has been created - call initializeApp() first","bad-app-name":"Illegal App name: '{$appName}'","duplicate-app":"Firebase App named '{$appName}' already exists with different options or config","app-deleted":"Firebase App named '{$appName}' already deleted","server-app-deleted":"Firebase Server App has been deleted","no-options":"Need to provide options, when not being deployed to hosting via source.","invalid-app-argument":"firebase.{$appName}() takes either no argument or a Firebase App instance.","invalid-log-argument":"First argument to `onLog` must be null or a function.","idb-open":"Error thrown when opening IndexedDB. Original error: {$originalErrorMessage}.","idb-get":"Error thrown when reading from IndexedDB. Original error: {$originalErrorMessage}.","idb-set":"Error thrown when writing to IndexedDB. Original error: {$originalErrorMessage}.","idb-delete":"Error thrown when deleting from IndexedDB. Original error: {$originalErrorMessage}.","finalization-registry-not-supported":"FirebaseServerApp deleteOnDeref field defined but the JS runtime does not support FinalizationRegistry.","invalid-server-app-environment":"FirebaseServerApp is not for use in browser environments."});class Oe{constructor(e,t,s){this._isDeleted=!1,this._options={...e},this._config={...t},this._name=t.name,this._automaticDataCollectionEnabled=t.automaticDataCollectionEnabled,this._container=s,this.container.addComponent(new T("app",()=>this,"PUBLIC"))}get automaticDataCollectionEnabled(){return this.checkDestroyed(),this._automaticDataCollectionEnabled}set automaticDataCollectionEnabled(e){this.checkDestroyed(),this._automaticDataCollectionEnabled=e}get name(){return this.checkDestroyed(),this._name}get options(){return this.checkDestroyed(),this._options}get config(){return this.checkDestroyed(),this._config}get container(){return this._container}get isDeleted(){return this._isDeleted}set isDeleted(e){this._isDeleted=e}checkDestroyed(){if(this.isDeleted)throw Le.create("app-deleted",{appName:this._name})}}function Be(e,t={}){let s=e;"object"!=typeof t&&(t={name:t});const i={name:Ee,automaticDataCollectionEnabled:!0,...t},n=i.name;if("string"!=typeof n||!n)throw Le.create("bad-app-name",{appName:String(n)});if(s||(s=f()),!s)throw Le.create("no-options");const a=Ie.get(n);if(a){if(x(s,a.options)&&x(i,a.config))return a;throw Le.create("duplicate-app",{appName:n})}const o=new k(n);for(const e of Pe.values())o.addComponent(e);const r=new Oe(s,i,o);return Ie.set(n,r),r}function He(e,t,s){let i=Ne[e]??e;s&&(i+=`-${s}`);const n=i.match(/\s|\//),a=t.match(/\s|\//);if(n||a){const e=[`Unable to register library "${i}" with version "${t}":`];return n&&e.push(`library name "${i}" contains illegal characters (whitespace or "/")`),n&&a&&e.push("and"),a&&e.push(`version name "${t}" contains illegal characters (whitespace or "/")`),void ie.warn(e.join(" "))}Fe(new T(`${i}-version`,()=>({library:i,version:t}),"VERSION"))}const qe="firebase-heartbeat-store";let ze=null;function Ve(){return ze||(ze=$("firebase-heartbeat-database",1,{upgrade:(e,t)=>{if(0===t)try{e.createObjectStore(qe)}catch(e){console.warn(e)}}}).catch(e=>{throw Le.create("idb-open",{originalErrorMessage:e.message})})),ze}async function We(e,t){try{const s=(await Ve()).transaction(qe,"readwrite"),i=s.objectStore(qe);await i.put(t,Ke(e)),await s.done}catch(e){if(e instanceof S)ie.warn(e.message);else{const t=Le.create("idb-set",{originalErrorMessage:e?.message});ie.warn(t.message)}}}function Ke(e){return`${e.name}!${e.options.appId}`}class $e{constructor(e){this.container=e,this._heartbeatsCache=null;const t=this.container.getProvider("app").getImmediate();this._storage=new Ye(t),this._heartbeatsCachePromise=this._storage.read().then(e=>(this._heartbeatsCache=e,e))}async triggerHeartbeat(){try{const e=this.container.getProvider("platform-logger").getImmediate().getPlatformInfoString(),t=Ge();if(null==this._heartbeatsCache?.heartbeats&&(this._heartbeatsCache=await this._heartbeatsCachePromise,null==this._heartbeatsCache?.heartbeats))return;if(this._heartbeatsCache.lastSentHeartbeatDate===t||this._heartbeatsCache.heartbeats.some(e=>e.date===t))return;if(this._heartbeatsCache.heartbeats.push({date:t,agent:e}),this._heartbeatsCache.heartbeats.length>30){const e=function(e){if(0===e.length)return-1;let t=0,s=e[0].date;for(let i=1;ie.agent===n.agent);if(e){if(e.dates.push(n.date),Xe(s)>t){e.dates.pop();break}}else if(s.push({agent:n.agent,dates:[n.date]}),Xe(s)>t){s.pop();break}i=i.slice(1)}return{heartbeatsToSend:s,unsentEntries:i}}(this._heartbeatsCache.heartbeats),i=g(JSON.stringify({version:2,heartbeats:t}));return this._heartbeatsCache.lastSentHeartbeatDate=e,s.length>0?(this._heartbeatsCache.heartbeats=s,await this._storage.overwrite(this._heartbeatsCache)):(this._heartbeatsCache.heartbeats=[],this._storage.overwrite(this._heartbeatsCache)),i}catch(e){return ie.warn(e),""}}}function Ge(){return(new Date).toISOString().substring(0,10)}class Ye{constructor(e){this.app=e,this._canUseIndexedDBPromise=this.runIndexedDBEnvironmentCheck()}async runIndexedDBEnvironmentCheck(){return!!v()&&w().then(()=>!0).catch(()=>!1)}async read(){if(await this._canUseIndexedDBPromise){const e=await async function(e){try{const t=(await Ve()).transaction(qe),s=await t.objectStore(qe).get(Ke(e));return await t.done,s}catch(e){if(e instanceof S)ie.warn(e.message);else{const t=Le.create("idb-get",{originalErrorMessage:e?.message});ie.warn(t.message)}}}(this.app);return e?.heartbeats?e:{heartbeats:[]}}return{heartbeats:[]}}async overwrite(e){if(await this._canUseIndexedDBPromise){const t=await this.read();return We(this.app,{lastSentHeartbeatDate:e.lastSentHeartbeatDate??t.lastSentHeartbeatDate,heartbeats:e.heartbeats})}}async add(e){if(await this._canUseIndexedDBPromise){const t=await this.read();return We(this.app,{lastSentHeartbeatDate:e.lastSentHeartbeatDate??t.lastSentHeartbeatDate,heartbeats:[...t.heartbeats,...e.heartbeats]})}}}function Xe(e){return g(JSON.stringify({version:2,heartbeats:e})).length}Fe(new T("platform-logger",e=>new ee(e),"PRIVATE")),Fe(new T("heartbeat",e=>new $e(e),"PRIVATE")),He(te,se,""),He(te,se,"esm2020"),He("fire-js",""),He("firebase","12.15.0","app");const Je="@firebase/installations",Qe="0.6.22",Ze=`w:${Qe}`,et="FIS_v2",tt=new C("installations","Installations",{"missing-app-config-values":'Missing App configuration value: "{$valueName}"',"not-registered":"Firebase Installation is not registered.","installation-not-found":"Firebase Installation not found.","request-failed":'{$requestName} request failed with error "{$serverCode} {$serverStatus}: {$serverMessage}"',"app-offline":"Could not process request. Application offline.","delete-pending-registration":"Can't delete installation while there is a pending registration request."});function st(e){return e instanceof S&&e.code.includes("request-failed")}function it({projectId:e}){return`https://firebaseinstallations.googleapis.com/v1/projects/${e}/installations`}function nt(e){return{token:e.token,requestStatus:2,expiresIn:(t=e.expiresIn,Number(t.replace("s","000"))),creationTime:Date.now()};var t}async function at(e,t){const s=(await t.json()).error;return tt.create("request-failed",{requestName:e,serverCode:s.code,serverMessage:s.message,serverStatus:s.status})}function ot({apiKey:e}){return new Headers({"Content-Type":"application/json",Accept:"application/json","x-goog-api-key":e})}async function rt(e){const t=await e();return t.status>=500&&t.status<600?e():t}function lt(e){return new Promise(t=>{setTimeout(t,e)})}const ct=/^[cdef][\w-]{21}$/;function dt(){try{const e=new Uint8Array(17);(self.crypto||self.msCrypto).getRandomValues(e),e[0]=112+e[0]%16;const t=function(e){var t;return(t=e,btoa(String.fromCharCode(...t)).replace(/\+/g,"-").replace(/\//g,"_")).substr(0,22)}(e);return ct.test(t)?t:""}catch{return""}}function ht(e){return`${e.appName}!${e.appId}`}const pt=new Map;function ut(e,t){const s=ht(e);gt(s,t),function(e,t){const s=ft();s&&s.postMessage({key:e,fid:t}),bt()}(s,t)}function gt(e,t){const s=pt.get(e);if(s)for(const e of s)e(t)}let mt=null;function ft(){return!mt&&"BroadcastChannel"in self&&(mt=new BroadcastChannel("[Firebase] FID Change"),mt.onmessage=e=>{gt(e.data.key,e.data.fid)}),mt}function bt(){0===pt.size&&mt&&(mt.close(),mt=null)}const vt="firebase-installations-store";let wt=null;function St(){return wt||(wt=$("firebase-installations-database",1,{upgrade:(e,t)=>{0===t&&e.createObjectStore(vt)}})),wt}async function Ct(e,t){const s=ht(e),i=(await St()).transaction(vt,"readwrite"),n=i.objectStore(vt),a=await n.get(s);return await n.put(t,s),await i.done,a&&a.fid===t.fid||ut(e,t.fid),t}async function yt(e){const t=ht(e),s=(await St()).transaction(vt,"readwrite");await s.objectStore(vt).delete(t),await s.done}async function xt(e,t){const s=ht(e),i=(await St()).transaction(vt,"readwrite"),n=i.objectStore(vt),a=await n.get(s),o=t(a);return void 0===o?await n.delete(s):await n.put(o,s),await i.done,!o||a&&a.fid===o.fid||ut(e,o.fid),o}async function _t(e){let t;const s=await xt(e.appConfig,s=>{const i=function(e){return jt(e||{fid:dt(),registrationStatus:0})}(s),n=function(e,t){if(0===t.registrationStatus){if(!navigator.onLine)return{installationEntry:t,registrationPromise:Promise.reject(tt.create("app-offline"))};const s={fid:t.fid,registrationStatus:1,registrationTime:Date.now()},i=async function(e,t){try{const s=await async function({appConfig:e,heartbeatServiceProvider:t},{fid:s}){const i=it(e),n=ot(e),a=t.getImmediate({optional:!0});if(a){const e=await a.getHeartbeatsHeader();e&&n.append("x-firebase-client",e)}const o={fid:s,authVersion:et,appId:e.appId,sdkVersion:Ze},r={method:"POST",headers:n,body:JSON.stringify(o)},l=await rt(()=>fetch(i,r));if(l.ok){const e=await l.json();return{fid:e.fid||s,registrationStatus:2,refreshToken:e.refreshToken,authToken:nt(e.authToken)}}throw await at("Create Installation",l)}(e,t);return Ct(e.appConfig,s)}catch(s){throw st(s)&&409===s.customData.serverCode?await yt(e.appConfig):await Ct(e.appConfig,{fid:t.fid,registrationStatus:0}),s}}(e,s);return{installationEntry:s,registrationPromise:i}}return 1===t.registrationStatus?{installationEntry:t,registrationPromise:Mt(e)}:{installationEntry:t}}(e,i);return t=n.registrationPromise,n.installationEntry});return""===s.fid?{installationEntry:await t}:{installationEntry:s,registrationPromise:t}}async function Mt(e){let t=await Tt(e.appConfig);for(;1===t.registrationStatus;)await lt(100),t=await Tt(e.appConfig);if(0===t.registrationStatus){const{installationEntry:t,registrationPromise:s}=await _t(e);return s||t}return t}function Tt(e){return xt(e,e=>{if(!e)throw tt.create("installation-not-found");return jt(e)})}function jt(e){return 1===(t=e).registrationStatus&&t.registrationTime+1e4fetch(i,r));if(l.ok)return nt(await l.json());throw await at("Generate Auth Token",l)}async function kt(e,t=!1){let s;const i=await xt(e.appConfig,i=>{if(!Nt(i))throw tt.create("not-registered");const n=i.authToken;if(!t&&(2===(a=n).requestStatus&&!function(e){const t=Date.now();return t{if(!Nt(e))throw tt.create("not-registered");return 1===(t=e.authToken).requestStatus&&t.requestTime+1e4{const t=e.getProvider("app").getImmediate(),s=function(e){if(!e||!e.options)throw It("App Configuration");if(!e.name)throw It("App Name");const t=["projectId","apiKey","appId"];for(const s of t)if(!e.options[s])throw It(s);return{appName:e.name,projectId:e.options.projectId,apiKey:e.options.apiKey,appId:e.options.appId}}(t);return{app:t,appConfig:s,heartbeatServiceProvider:Ue(t,"heartbeat"),_delete:()=>Promise.resolve()}},"PUBLIC")),Fe(new T("installations-internal",e=>{const t=Ue(e.getProvider("app").getImmediate(),Dt).getImmediate();return{getId:()=>async function(e){const t=e,{installationEntry:s,registrationPromise:i}=await _t(t);return i?i.catch(console.error):kt(t).catch(console.error),s.fid}(t),getToken:e=>async function(e,t=!1){const s=e;return await async function(e){const{registrationPromise:t}=await _t(e);t&&await t}(s),(await kt(s,t)).token}(t,e)}},"PRIVATE")),He(Je,Qe),He(Je,Qe,"esm2020");const Pt="BDOU99-h67HcA6JeFXHbSNMu7e2yNNu3RzoMj8TM4W88jITfq7ZmPvIM1Iv-4_l2LxQcYwhqby2xGpWwzjfAnG4",Rt="google.c.a.c_id";var Ft,Ut;function Lt(e){const t=new Uint8Array(e);return btoa(String.fromCharCode(...t)).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function Ot(e){const t=(e+"=".repeat((4-e.length%4)%4)).replace(/\-/g,"+").replace(/_/g,"/"),s=atob(t),i=new Uint8Array(s.length);for(let e=0;e{!function(e,t,s){switch(t){case 0:if(e.createObjectStore(Vt),1===s)break;case 1:2===s&&e.createObjectStore(Wt)}}(t,s,e)},blocked:()=>{},blocking:(e,t,s)=>{$t=null,s.target?.close()},terminated:()=>{$t=null}}}function Yt(){if(!$t){const e=Kt.openDB(zt,2,Gt(2));$t=e.catch(()=>Kt.openDB(zt,1,Gt(1)))}return $t}function Xt(e,t){return e.objectStoreNames.contains(t)}function Jt(e){if(!Xt(e,Wt))throw qt.create("fid-registration-idb-schema-unavailable")}async function Qt(e){const t=ts(e),s=await Yt(),i=await s.transaction(Vt).objectStore(Vt).get(t);if(i)return i;{const t=await async function(e){if("databases"in indexedDB){const e=(await indexedDB.databases()).map(e=>e.name);if(!e.includes(Bt))return null}let t=null;return(await $(Bt,5,{upgrade:async(s,i,n,a)=>{if(i<2)return;if(!s.objectStoreNames.contains(Ht))return;const o=a.objectStore(Ht),r=await o.index("fcmSenderId").get(e);if(await o.clear(),r)if(2===i){const e=r;if(!e.auth||!e.p256dh||!e.endpoint)return;t={token:e.fcmToken,createTime:e.createTime??Date.now(),subscriptionOptions:{auth:e.auth,p256dh:e.p256dh,endpoint:e.endpoint,swScope:e.swScope,vapidKey:"string"==typeof e.vapidKey?e.vapidKey:Lt(e.vapidKey)}}}else if(3===i){const e=r;t={token:e.fcmToken,createTime:e.createTime,subscriptionOptions:{auth:Lt(e.auth),p256dh:Lt(e.p256dh),endpoint:e.endpoint,swScope:e.swScope,vapidKey:Lt(e.vapidKey)}}}else if(4===i){const e=r;t={token:e.fcmToken,createTime:e.createTime,subscriptionOptions:{auth:Lt(e.auth),p256dh:Lt(e.p256dh),endpoint:e.endpoint,swScope:e.swScope,vapidKey:Lt(e.vapidKey)}}}}})).close(),await G(Bt),await G("fcm_vapid_details_db"),await G("undefined"),function(e){if(!e||!e.subscriptionOptions)return!1;const{subscriptionOptions:t}=e;return"number"==typeof e.createTime&&e.createTime>0&&"string"==typeof e.token&&e.token.length>0&&"string"==typeof t.auth&&t.auth.length>0&&"string"==typeof t.p256dh&&t.p256dh.length>0&&"string"==typeof t.endpoint&&t.endpoint.length>0&&"string"==typeof t.swScope&&t.swScope.length>0&&"string"==typeof t.vapidKey&&t.vapidKey.length>0}(t)?t:null}(e.appConfig.senderId);if(t)return await Zt(e,t),t}}async function Zt(e,t){const s=ts(e),i=await Yt(),n=[Vt],a=Xt(i,Wt);a&&n.push(Wt);const o=i.transaction(n,"readwrite");return await o.objectStore(Vt).put(t,s),a&&await o.objectStore(Wt).delete(s),await o.done,t}async function es(e){const t=ts(e),s=await Yt();return Jt(s),await s.transaction(Wt).objectStore(Wt).get(t)}function ts({appConfig:e}){return e.appId}const ss="@firebase/messaging",is="0.13.0";async function ns(e,t){const s=await ls(e),i=ds(t,e.appConfig.appName,!0),n={method:"POST",headers:s,body:JSON.stringify(i)};let a,o;try{a=await async function(e){let t;for(let s=0;s<3;s++)try{return await e()}catch(e){if(t=e,s<2){const e=1e3*Math.pow(2,s);await new Promise(t=>setTimeout(t,e))}}throw t}(()=>fetch(rs(e.appConfig),n))}catch(e){throw qt.create("fid-registration-failed",{errorInfo:e?.toString()})}if(a.ok){const e=await async function(e){const t=await e.text();if(!t.trim())throw qt.create("fid-registration-failed",{errorInfo:"CreateRegistration succeeded but response body is empty"});let s;try{s=JSON.parse(t)}catch{throw qt.create("fid-registration-failed",{errorInfo:"CreateRegistration succeeded but response body is not valid JSON"})}const i=s.name;if("string"!=typeof i||0===i.length)throw qt.create("fid-registration-failed",{errorInfo:"CreateRegistration succeeded but response did not include a non-empty name"});return function(e){const t=e.indexOf(as);if(-1!==t){const s=e.slice(t+as.length);if(s.length>0)return s}throw qt.create("fid-registration-failed",{errorInfo:"CreateRegistration succeeded but response name is not a valid registration resource name"})}(i)}(a);return{responseFid:e}}try{o=await a.json()}catch(e){throw qt.create("fid-registration-failed",{errorInfo:a.statusText})}const r=o.error?.message??a.statusText;throw qt.create("fid-registration-failed",{errorInfo:r})}const as="/registrations/";async function os(e,t){const s={method:"DELETE",headers:await ls(e)};try{const i=await fetch(`${rs(e.appConfig)}/${t}`,s),n=await i.json();if(n.error){const e=n.error.message;throw qt.create("token-unsubscribe-failed",{errorInfo:e})}}catch(e){throw qt.create("token-unsubscribe-failed",{errorInfo:e?.toString()})}}function rs({projectId:e}){return`https://fcmregistrations.googleapis.com/v1/projects/${e}/registrations`}async function ls({appConfig:e,installations:t}){const s=await t.getToken();return new Headers({"Content-Type":"application/json",Accept:"application/json","x-goog-api-key":e.apiKey,"x-goog-firebase-installations-auth":`FIS ${s}`})}function cs(e,t){try{if(/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(e))return new URL(e).host}catch{}try{if("undefined"!=typeof self&&self.location?.href)return new URL(e,self.location.origin).host}catch{}return"undefined"!=typeof self&&self.location?.host?self.location.host:t}function ds({p256dh:e,auth:t,endpoint:s,vapidKey:i,swScope:n},a,o){const r={web:{origin:cs(n,a),endpoint:s,auth:t,p256dh:e}};return o&&(r.fcm_sdk_version=is),i!==Pt&&(r.web.applicationPubKey=i),r}async function hs(e){const t=await Qt(e.firebaseDependencies);t?await async function(e,t){await os(e.firebaseDependencies,t.token),await async function(e){const t=ts(e),s=(await Yt()).transaction(Vt,"readwrite");await s.objectStore(Vt).delete(t),await s.done}(e.firebaseDependencies),await us(e.firebaseDependencies)}(e,t):await async function(e){const t=await es(e.firebaseDependencies).catch(()=>{}),s=t?.fid;s&&await async function(e,t){const s={method:"DELETE",headers:await ls(e)};let i;try{i=await fetch(`${rs(e.appConfig)}/${t}`,s)}catch(e){throw qt.create("fid-unregister-failed",{errorInfo:e?.toString()})}if(!i.ok)try{const e=await i.json();throw e.error?.message??i.statusText}catch(e){throw qt.create("fid-unregister-failed",{errorInfo:"string"==typeof e&&e||i.statusText||e?.toString()})}}(e.firebaseDependencies,s),await us(e.firebaseDependencies),s&&function(e,t){const s=e.onUnregisteredHandler;s&&("function"==typeof s?s(t):s.next(t))}(e,s)}(e);const s=await e.swRegistration.pushManager.getSubscription();return!s||s.unsubscribe()}async function ps(e,t){const s=await async function(e,t){const s=await ls(e),i=ds(t,e.appConfig.appName,!1),n={method:"POST",headers:s,body:JSON.stringify(i)};let a;try{const t=await fetch(rs(e.appConfig),n);a=await t.json()}catch(e){throw qt.create("token-subscribe-failed",{errorInfo:e?.toString()})}if(a.error){const e=a.error.message;throw qt.create("token-subscribe-failed",{errorInfo:e})}if(!a.token)throw qt.create("token-subscribe-no-token");return a.token}(e,t),i={token:s,createTime:Date.now(),subscriptionOptions:t};return await Zt(e,i),i.token}async function us(e){try{await async function(e){const t=ts(e),s=await Yt();Jt(s);const i=s.transaction(Wt,"readwrite");await i.objectStore(Wt).delete(t),await i.done}(e)}catch{}}async function gs(e){try{e.swRegistration=await navigator.serviceWorker.register("/firebase-messaging-sw.js",{scope:"/firebase-cloud-messaging-push-scope"}),e.swRegistration.update().catch(()=>{}),await async function(e){return new Promise((t,s)=>{const i=setTimeout(()=>s(new Error("Service worker not registered after 10000 ms")),1e4),n=e.installing||e.waiting;e.active?(clearTimeout(i),t()):n?n.onstatechange=e=>{"activated"===e.target?.state&&(n.onstatechange=null,clearTimeout(i),t())}:(clearTimeout(i),s(new Error("No incoming service worker found.")))})}(e.swRegistration)}catch(e){throw qt.create("failed-service-worker-registration",{browserErrorMessage:e?.message})}}async function ms(e,t){if(t||e.swRegistration||await gs(e),t||!e.swRegistration){if(!(t instanceof ServiceWorkerRegistration))throw qt.create("invalid-sw-registration");e.swRegistration=t}}async function fs(e,t){t?e.vapidKey=t:e.vapidKey||(e.vapidKey=Pt)}async function bs(e,t){if(!navigator)throw qt.create("only-available-in-window");if("default"===Notification.permission&&await Notification.requestPermission(),"granted"!==Notification.permission)throw qt.create("permission-blocked");if(!e.onRegisteredHandler)throw qt.create("invalid-on-registered-handler");await fs(e,t?.vapidKey),await ms(e,t?.serviceWorkerRegistration);const s=e._registerNotifyChain.catch(()=>{});return e._registerNotifyChain=s.then(async()=>{const t=await e.firebaseDependencies.installations.getId(),s=await es(e.firebaseDependencies),i=Date.now();if((!s||s.fid!==t||i>=s.lastRegisterTime+6048e5)&&(await async function(e,t){const s=await async function(e,t){return await e.pushManager.getSubscription()||e.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:Ot(t)})}(e.swRegistration,e.vapidKey),i={vapidKey:e.vapidKey,swScope:e.swRegistration.scope,endpoint:s.endpoint,auth:Lt(s.getKey("auth")),p256dh:Lt(s.getKey("p256dh"))},n=e.firebaseDependencies.installations;for(let s=0;s<3;s++){const{responseFid:a}=await ns(e.firebaseDependencies,i);if(a===t)return;s<2&&await n.getToken(!0)}throw qt.create("fid-registration-failed",{errorInfo:"CreateRegistration response FID does not match Firebase Installation ID"})}(e,t),await async function(e,t){const s=ts(e),i=await Yt();Jt(i);const n=i.transaction([Vt,Wt],"readwrite");return await n.objectStore(Wt).put(t,s),await n.objectStore(Vt).delete(s),await n.done,t}(e.firebaseDependencies,{fid:t,lastRegisterTime:i,vapidKey:e.vapidKey})),!e.onRegisteredHandler)throw qt.create("invalid-on-registered-handler");!function(e,t){const s=e.onRegisteredHandler;s&&("function"==typeof s?s(t):s.next(t))}(e,t)}),e._registerNotifyChain}function vs(e){const t={from:e.from,collapseKey:e.collapse_key,messageId:e.fcmMessageId};return function(e,t){if(!t.notification)return;e.notification={};const s=t.notification.title;s&&(e.notification.title=s);const i=t.notification.body;i&&(e.notification.body=i);const n=t.notification.image;n&&(e.notification.image=n);const a=t.notification.icon;a&&(e.notification.icon=a)}(t,e),function(e,t){t.data&&(e.data=t.data)}(t,e),function(e,t){if(!t.fcmOptions&&!t.notification?.click_action)return;e.fcmOptions={};const s=t.fcmOptions?.link??t.notification?.click_action;s&&(e.fcmOptions.link=s);const i=t.fcmOptions?.analytics_label;i&&(e.fcmOptions.analyticsLabel=i)}(t,e),t}function ws(e){return qt.create("missing-app-config-values",{valueName:e})}!function(e,t){const s=[];for(let i=0;i<20;i++)s.push(e.charAt(i)),i<19&&s.push(t.charAt(i));s.join("")}("AzSCbw63g1R0nCw85jG8","Iaya3yLKwmgvh7cF0q4");class Ss{constructor(e,t,s){this.deliveryMetricsExportedToBigQueryEnabled=!1,this.onBackgroundMessageHandler=null,this.onMessageHandler=null,this.onRegisteredHandler=null,this.onUnregisteredHandler=null,this._registerNotifyChain=Promise.resolve(),this._fidChangeUnsubscribe=null,this.logEvents=[],this.logQueue={state:"stopped"};const i=function(e){if(!e||!e.options)throw ws("App Configuration Object");if(!e.name)throw ws("App Name");const t=["projectId","apiKey","appId","messagingSenderId"],{options:s}=e;for(const e of t)if(!s[e])throw ws(e);return{appName:e.name,projectId:s.projectId,apiKey:s.apiKey,appId:s.appId,senderId:s.messagingSenderId}}(e);this.firebaseDependencies={app:e,appConfig:i,installations:t,analyticsProvider:s}}_delete(){return this._fidChangeUnsubscribe&&(this._fidChangeUnsubscribe(),this._fidChangeUnsubscribe=null),"scheduled"===this.logQueue.state&&clearTimeout(this.logQueue.timerId),this.logQueue={state:"stopped"},Promise.resolve()}}async function Cs(e,t){if(!navigator)throw qt.create("only-available-in-window");if("default"===Notification.permission&&await Notification.requestPermission(),"granted"!==Notification.permission)throw qt.create("permission-blocked");return await fs(e,t?.vapidKey),await ms(e,t?.serviceWorkerRegistration),async function(e){const t=await async function(e,t){return await e.pushManager.getSubscription()||e.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:Ot(t)})}(e.swRegistration,e.vapidKey),s={vapidKey:e.vapidKey,swScope:e.swRegistration.scope,endpoint:t.endpoint,auth:Lt(t.getKey("auth")),p256dh:Lt(t.getKey("p256dh"))},i=await Qt(e.firebaseDependencies);if(i){if(function(e,t){const s=t.vapidKey===e.vapidKey,i=t.endpoint===e.endpoint,n=t.auth===e.auth,a=t.p256dh===e.p256dh;return s&&i&&n&&a}(i.subscriptionOptions,s))return Date.now()>=i.createTime+6048e5?async function(e,t){try{const s=await async function(e,t){const s=await ls(e),i=ds(t.subscriptionOptions,e.appConfig.appName,!1),n={method:"PATCH",headers:s,body:JSON.stringify(i)};let a;try{const s=await fetch(`${rs(e.appConfig)}/${t.token}`,n);a=await s.json()}catch(e){throw qt.create("token-update-failed",{errorInfo:e?.toString()})}if(a.error){const e=a.error.message;throw qt.create("token-update-failed",{errorInfo:e})}if(!a.token)throw qt.create("token-update-no-token");return a.token}(e.firebaseDependencies,t),i={...t,token:s,createTime:Date.now()};return await Zt(e.firebaseDependencies,i),s}catch(e){throw e}}(e,{token:i.token,createTime:Date.now(),subscriptionOptions:s}):i.token;try{await os(e.firebaseDependencies,i.token)}catch(e){console.warn(e)}return ps(e.firebaseDependencies,s)}return ps(e.firebaseDependencies,s)}(e)}async function ys(e,t){const s=t.data;if(!s.isFirebaseMessaging)return;if(e.onMessageHandler&&s.messageType===Ut.PUSH_RECEIVED&&("function"==typeof e.onMessageHandler?e.onMessageHandler(vs(s)):e.onMessageHandler.next(vs(s))),e.onRegisteredHandler&&s.messageType===Ut.FID_REGISTERED){const t=s.fid;"function"==typeof e.onRegisteredHandler?e.onRegisteredHandler(t):e.onRegisteredHandler.next(t)}const i=s.data;var n;"object"==typeof(n=i)&&n&&Rt in n&&"1"===i["google.c.a.e"]&&await async function(e,t,s){const i=function(e){switch(e){case Ut.NOTIFICATION_CLICKED:return"notification_open";case Ut.PUSH_RECEIVED:return"notification_foreground";default:throw new Error}}(t);(await e.firebaseDependencies.analyticsProvider.get()).logEvent(i,{message_id:s[Rt],message_name:s["google.c.a.c_l"],message_time:s["google.c.a.ts"],message_device_time:Math.floor(Date.now()/1e3)})}(e,s.messageType,i)}function xs(e=function(e=Ee){const t=Ie.get(e);if(!t&&e===Ee&&f())return Be();if(!t)throw Le.create("no-app",{appName:e});return t}()){return async function(){try{await w()}catch(e){return!1}return"undefined"!=typeof window&&v()&&!("undefined"==typeof navigator||!navigator.cookieEnabled)&&"serviceWorker"in navigator&&"PushManager"in window&&"Notification"in window&&"fetch"in window&&ServiceWorkerRegistration.prototype.hasOwnProperty("showNotification")&&PushSubscription.prototype.hasOwnProperty("getKey")}().then(e=>{if(!e)throw qt.create("unsupported-browser")},e=>{throw qt.create("indexed-db-unsupported")}),Ue(M(e),"messaging").getImmediate()}async function _s(e,t){return Cs(e=M(e),t)}function Ms(e){return async function(e){if(!navigator)throw qt.create("only-available-in-window");return e.swRegistration||await gs(e),hs(e)}(e=M(e))}Fe(new T("messaging",e=>{const t=new Ss(e.getProvider("app").getImmediate(),e.getProvider("installations-internal").getImmediate(),e.getProvider("analytics-internal"));return navigator.serviceWorker.addEventListener("message",e=>ys(t,e)),t._fidChangeUnsubscribe=function(e,t){return function(e,t){const{appConfig:s}=e;return function(e,t){ft();const s=ht(e);let i=pt.get(s);i||(i=new Set,pt.set(s,i)),i.add(t)}(s,t),()=>{!function(e,t){const s=ht(e),i=pt.get(s);i&&(i.delete(t),0===i.size&&pt.delete(s),bt())}(s,t)}}(t,()=>{(async()=>{e.onRegisteredHandler&&await es(e.firebaseDependencies)&&await bs(e).catch(()=>{})})()})}(t,e.getProvider("installations").getImmediate()),t},"PUBLIC")),Fe(new T("messaging-internal",e=>{const t=e.getProvider("messaging").getImmediate();return{getToken:e=>Cs(t,e),register:e=>bs(t,e)}},"PRIVATE")),He(ss,is),He(ss,is,"esm2020");var Ts=o(4532),js=o(4848);class As extends l().PureComponent{render(){return(0,js.jsx)("div",{className:"alert-container",children:(0,js.jsxs)("div",{className:"alert",children:[(0,js.jsx)("div",{className:"title",children:this.props.title}),(0,js.jsx)("div",{className:"content",children:this.props.content}),(0,js.jsxs)("div",{className:"dialog-buttons",children:[this.props.onReject?(0,js.jsx)("button",{className:"outline",onClick:this.props.onReject,children:this.props.reject||(0,js.jsx)(d.FormattedMessage,{id:"button_cancel",defaultMessage:"Cancel",description:"Button [Cancel]"})}):null,this.props.onConfirm?(0,js.jsx)("button",{className:"primary",onClick:this.props.onConfirm,children:this.props.confirm||(0,js.jsx)(d.FormattedMessage,{id:"button_ok",defaultMessage:"OK",description:"Button [OK]"})}):null]})]})})}}var ks=o(3272);const Es=(0,d.defineMessages)({info:{id:"menu_item_info",defaultMessage:"Info",description:"Show extended topic information"},clear_messages:{id:"menu_item_clear_messages",defaultMessage:"Clear messages",description:"Delete all messages"},clear_for_all:{id:"menu_item_clear_messages_for_all",defaultMessage:"Clear for All",description:"Delete all message(s) for all members"},delete:{id:"menu_item_delete",defaultMessage:"Delete",description:"Delete selected messages"},delete_for_all:{id:"menu_item_delete_for_all",defaultMessage:"Delete for All",description:"Delete selected message(s) for all members"},send_retry:{id:"menu_item_send_retry",defaultMessage:"Retry",description:"Retry sending message"},mute:{id:"menu_item_mute",defaultMessage:"Mute",description:"Turn off notifications"},unmute:{id:"menu_item_unmute",defaultMessage:"Unmute",description:"Turn notifications on"},reply:{id:"menu_item_reply",defaultMessage:"Reply",description:"Reply to message"},forward:{id:"menu_item_forward",defaultMessage:"Forward",description:"Forward message"},edit:{id:"menu_item_edit",defaultMessage:"Edit",description:"Edit message"},topic_delete:{id:"menu_item_delete_topic",defaultMessage:"Delete",description:"Delete entire topic"},topic_delete_warning:{id:"topic_delete_warning",defaultMessage:"Are you sure you want to delete this conversation? It cannot be undone.",description:"Alert warning when deleting entire topic"},delete_messages_warning:{id:"delete_messages_warning",defaultMessage:"Are you sure you want to delete all messages for everyone? It cannot be undone.",description:"Alert dialog warning when hard-deleting all messages."},unblock:{id:"menu_item_unblock",defaultMessage:"Unblock",description:"Unblock topic or user"},block:{id:"menu_item_block",defaultMessage:"Block",description:"Block topic or user"},topic_block_warning:{id:"topic_block_warning",defaultMessage:"Are you sure you want to block this conversation?",description:"Alert warning when blocking a topic."},member_delete:{id:"menu_item_member_delete",defaultMessage:"Remove",description:"Remove user from topic"},archive:{id:"menu_item_archive_topic",defaultMessage:"Archive",description:"Move topic from the list of active chats to archive"},unarchive:{id:"menu_item_restore_topic",defaultMessage:"Restore",description:"Restore topic from archive"},edit_permissions:{id:"menu_item_edit_permissions",defaultMessage:"Edit permissions",description:"Menu item [Edit permissions]"},clear_messages_warning:{id:"clear_messages_warning",defaultMessage:"Are you sure you want to clear all messages? It cannot be undone.",description:"Alert dialog warning when deleting all messages."},pin_message:{id:"pin_message",defaultMessage:"Pin",description:"Menu item [Pin] for pinning message to the top."},unpin_message:{id:"unpin_message",defaultMessage:"Unpin",description:"Menu item [Unpin] for un-pinning the message."},pin_chat:{id:"pin_chat",defaultMessage:"Pin",description:"Menu item [Pin] for pinning chat to the top."},unpin_chat:{id:"unpin_chat",defaultMessage:"Unpin",description:"Menu item [Unpin] for un-pinning the chat."}});class Ns extends l().Component{constructor(e){super(e),this.selfRef=l().createRef();const{formatMessage:t}=e.intl;this.handlePageClick=this.handlePageClick.bind(this),this.handleEscapeKey=this.handleEscapeKey.bind(this),this.handleClick=this.handleClick.bind(this),this.MenuItems={topic_info:{id:"topic_info",title:t(Es.info),handler:null},messages_clear:{id:"messages_clear",title:t(Es.clear_messages),handler:(s,i)=>e.onShowAlert(s.topicTitle||t(Es.clear_messages),t(Es.clear_messages_warning),e=>{this.deleteMessages(!0,!1,s,i)},null,!0,null)},messages_clear_hard:{id:"messages_clear_hard",title:t(Es.clear_for_all),handler:(s,i)=>e.onShowAlert(s.topicTitle||t(Es.clear_for_all),t(Es.delete_messages_warning),e=>this.deleteMessages(!0,!0,s,i),null,!0,null)},message_delete:{id:"message_delete",title:t(Es.delete),handler:(e,t)=>this.deleteMessages(!1,!1,e,t)},message_delete_hard:{id:"message_delete_hard",title:t(Es.delete_for_all),handler:(e,t)=>this.deleteMessages(!1,!0,e,t)},message_delete_generic:{id:"message_delete_generic",title:t(Es.delete),handler:(e,t)=>this.deleteMessages(!1,!0,e,t)},menu_item_send_retry:{id:"menu_item_send_retry",title:t(Es.send_retry),handler:(e,t)=>this.retryMessage(e,t)},menu_item_reply:{id:"menu_item_reply",title:t(Es.reply),handler:(e,t)=>this.replyToMessage(e,t)},menu_item_forward:{id:"menu_item_forward",title:t(Es.forward),handler:e=>{}},menu_item_edit:{id:"menu_item_edit",title:t(Es.edit),handler:(e,t)=>this.editMessage(e,t)},menu_item_pin:{id:"menu_item_pin",title:t(Es.pin_message),handler:(e,t)=>this.pinMessage(!0,e,t)},menu_item_unpin:{id:"menu_item_unpin",title:t(Es.unpin_message),handler:(e,t)=>this.pinMessage(!1,e,t)},topic_unmute:{id:"topic_unmute",title:t(Es.unmute),handler:this.topicPermissionSetter.bind(this,"+P")},topic_mute:{id:"topic_mute",title:t(Es.mute),handler:this.topicPermissionSetter.bind(this,"-P")},topic_unblock:{id:"topic_unblock",title:t(Es.unblock),handler:this.topicPermissionSetter.bind(this,"+JP")},topic_block:{id:"topic_block",title:t(Es.block),handler:(s,i)=>e.onShowAlert(s.topicTitle||t(Es.block),t(Es.topic_block_warning),e=>this.topicPermissionSetter("-JP",s,i).then(e=>(this.props.onTopicRemoved(s.topicName),e)),null,!0,null)},topic_delete:{id:"topic_delete",title:t(Es.topic_delete),handler:(s,i)=>e.onShowAlert(s.topicTitle||t(Es.topic_delete),t(Es.topic_delete_warning),e=>{const t=this.props.tinode.getTopic(s.topicName);if(t)return t.delTopic(!0).catch(e=>{i&&i(e.message,"err")});console.warn("Topic not found: ",s.topicName)},null,!0,null)},topic_archive:{id:"topic_archive",title:t(Es.archive),handler:(e,t)=>{const s=this.props.tinode.getTopic(e.topicName);if(s)return s.archive(!0).catch(e=>{t&&t(e.message,"err")});console.warn("Topic not found: ",e.topicName)}},topic_restore:{id:"topic_restore",title:t(Es.unarchive),handler:(e,t)=>{const s=this.props.tinode.getTopic(e.topicName);if(s)return s.archive(!1).catch(e=>{t&&t(e.message,"err")});console.warn("Topic not found: ",e.topicName)}},topic_pin:{id:"topic_pin",title:t(Es.pin_chat),handler:(e,t)=>{const s=this.props.tinode.getMeTopic();if(s)return s.pinTopic(e.topicName,!0).catch(e=>{t&&t(e.message,"err")});console.warn("'me' topic not found")}},topic_unpin:{id:"topic_unpin",title:t(Es.unpin_chat),handler:(e,t)=>{const s=this.props.tinode.getMeTopic();if(s)return s.pinTopic(e.topicName,!1).catch(e=>{t&&t(e.message,"err")});console.warn("'me' topic not found")}},permissions:{id:"permissions",title:t(Es.edit_permissions),handler:null},member_delete:{id:"member_delete",title:t(Es.member_delete),handler:(e,t)=>{const s=this.props.tinode.getTopic(e.topicName);if(s&&e.user)return s.delSubscription(e.user).catch(e=>{t&&t(e.message,"err")});console.warn("Topic or user not found: '"+e.topicName+"', '"+e.user+"'")}},member_mute:{id:"member_mute",title:t(Es.mute),handler:this.topicPermissionSetter.bind(this,"-P")},member_unmute:{id:"member_unmute",title:t(Es.unmute),handler:this.topicPermissionSetter.bind(this,"+P")},member_block:{id:"member_block",title:t(Es.block),handler:this.topicPermissionSetter.bind(this,"-JP")},member_unblock:{id:"member_unblock",title:t(Es.unblock),handler:this.topicPermissionSetter.bind(this,"+JP")}}}componentDidMount(){document.addEventListener("mousedown",this.handlePageClick,!1),document.addEventListener("keyup",this.handleEscapeKey,!1)}componentWillUnmount(){document.removeEventListener("mousedown",this.handlePageClick,!1),document.removeEventListener("keyup",this.handleEscapeKey,!1)}handlePageClick(e){this.selfRef.current.contains(e.target)||(e.preventDefault(),e.stopPropagation(),this.props.hide())}handleEscapeKey(e){27===e.keyCode&&this.props.hide()}handleClick(e){e.preventDefault(),e.stopPropagation(),this.props.hide();let t=this.props.items[e.currentTarget.dataset.id];"string"==typeof t&&(t=this.MenuItems[t]),t?this.props.onAction(t.id,t.handler(this.props.params,this.props.onError),this.props.params):console.error("Invalid menu item ID",e.currentTarget.dataset.id)}deleteMessages(e,t,s,i){const n=this.props.tinode.getTopic(s.topicName);if(n){if(e||!n.cancelSend(s.seq))return(e?n.delMessagesAll(t):s.replace>0?n.delMessagesEdits(s.replace,t):n.delMessagesList([s.seq],t)).catch(e=>{i&&i(e.message,"err")})}else console.warn("Topic not found: ",s.topicName)}retryMessage(e,t){const s=this.props.tinode.getTopic(e.topicName);if(!s||!s.flushMessage(e.seq))return;const i=s.createMessage(e.content,!1);return s.publishDraft(i).catch(e=>{t&&t(e.message,"err")})}pinMessage(e,t,s){const i=this.props.tinode.getTopic(t.topicName);i&&i.pinMessage(t.seq,e).catch(e=>s?s(e.message,"err"):null)}topicPermissionSetter(e,t,s){const i=this.props.tinode.getTopic(t.topicName);if(!i)return void console.warn("Topic not found",t.topicName);let n=i.updateMode(t.user,e);return s&&(n=n.catch(e=>s(e.message,"err"))),n}replyToMessage(e,t){e.pickReply(e.seq,e.content,e.userFrom,e.userName,t)}editMessage(e,t){e.editMessage(e.replace||e.seq,e.content,t)}render(){const e=[];let t=0;this.props.items.forEach(s=>{if("string"==typeof s&&(s=this.MenuItems[s]),s&&s.title){const i=s.disabled?"disabled":void 0;e.push("-"==s.title?(0,js.jsx)("li",{className:"separator"},t):(0,js.jsx)("li",{className:i,onClick:this.handleClick,"data-id":t,children:s.title},t))}t++});const s=13*(.7+2.5*e.length),i={left:(this.props.bounds.right-this.props.clickAt.x<156?this.props.clickAt.x-this.props.bounds.left-156:this.props.clickAt.x-this.props.bounds.left)+"px",top:(this.props.bounds.bottom-this.props.clickAt.y0}),this.props.onSearchContacts(t.length>0?t:Ts.Tinode.DEL_CHAR)}handleClear(e){e.preventDefault(),this.state.edited&&this.props.onSearchContacts(Ts.Tinode.DEL_CHAR),this.setState({search:"",edited:!1})}handleKeyDown(e){"Enter"===e.key?this.handleSearch(e):"Escape"===e.key&&(e.stopPropagation(),this.handleClear(e))}render(){return(0,js.jsx)("div",{className:"panel-form",children:(0,js.jsxs)("div",{className:"panel-form-row",children:[(0,js.jsx)("i",{className:"material-icons search",children:"search"}),(0,js.jsx)("input",{className:"search",type:"text",placeholder:this.props.placeholder,value:this.state.search,onChange:this.handleSearchChange,onKeyDown:this.handleKeyDown,required:!0,autoFocus:!0}),this.state.search?(0,js.jsx)("a",{href:"#",onClick:this.handleClear,children:(0,js.jsx)("i",{className:"material-icons",children:"highlight_off"})}):(0,js.jsx)("span",{children:(0,js.jsx)("i",{className:"material-icons",children:" "})})]})})}}class Rs extends l().Component{constructor(e){super(e),this.state={query:null},this.handleEscapeKey=this.handleEscapeKey.bind(this),this.handleClose=this.handleClose.bind(this),this.handleSearchContacts=this.handleSearchContacts.bind(this),this.handleContactSelected=this.handleContactSelected.bind(this)}componentDidMount(){this.props.onInitFind()}handleEscapeKey(e){27===e.keyCode&&this.props.hide(!1)}handleClose(e){e.preventDefault(),this.props.hide(!1)}handleSearchContacts(e){this.setState({query:Ts.Tinode.isNullValue(e)?null:e}),this.props.onSearchContacts(e)}handleContactSelected(e){this.props.onTopicSelected(e),this.props.hide(!0)}render(){let e=null!=this.state.query?this.props.searchResults:this.props.contacts;return e=e.filter(e=>e.name!=this.props.topicSelected&&e.acs.isJoiner()&&e.acs.isWriter()),(0,js.jsx)("div",{className:"alert-container",children:(0,js.jsxs)("div",{className:"forward-dialog",children:[(0,js.jsxs)("div",{className:"title with-control",children:[(0,js.jsx)("div",{children:(0,js.jsx)(d.FormattedMessage,{id:"forward_to",defaultMessage:"Forward to",desription:"Title of the contact selector dialog when forwarding a message"})}),(0,js.jsx)("div",{children:(0,js.jsx)("a",{href:"#",onClick:this.handleClose,children:(0,js.jsx)("i",{className:"material-icons",children:"close"})})})]}),(0,js.jsx)(d.FormattedMessage,{id:"forward_to_search_placeholder",defaultMessage:"Search contacts",description:"Contact search prompt when forwarding a message.",children:e=>(0,js.jsx)(Ps,{placeholder:e,onSearchContacts:this.handleSearchContacts})}),(0,js.jsx)(d.FormattedMessage,{id:"search_no_results",defaultMessage:"Search returned no results",description:"Text shown in contacts view when query returned no results.",children:t=>(0,js.jsx)(Ds.A,{tinode:this.props.tinode,contacts:e,myUserId:this.props.myUserId,emptyListMessage:t,showOnline:!1,showUnread:!1,showContextMenu:!1,onTopicSelected:this.handleContactSelected})})]})})}}var Fs=o(6686),Us=o(5247),Ls=o(7981),Os=o(7256);const Bs=new Audio("audio/call-in.m4a");class Hs extends l().Component{constructor(e){super(e),this.state={topic:null,fullName:void 0,avatar:null,trustedBadges:[],previousMetaDesc:void 0},this.resetDesc=this.resetDesc.bind(this),this.onMetaDesc=this.onMetaDesc.bind(this),this.handleRejectCall=this.handleRejectCall.bind(this),this.handleAcceptCall=this.handleAcceptCall.bind(this),this.ringTimer=null}componentDidMount(){const e=this.props.tinode.getTopic(this.props.topic);e&&(this.resetDesc(e),2==this.props.callState&&(Bs.play().catch(e=>{}),this.ringTimer=setInterval(e=>{Bs.play().catch(e=>{})},2e3),this.props.onRinging(this.props.topic,this.props.seq)))}componentDidUpdate(e){const t=this.props.tinode.getTopic(e.topic);t&&(this.onMetaDesc!=t.onMetaDesc&&(this.previousMetaDesc=t.onMetaDesc,t.onMetaDesc=this.onMetaDesc),this.state.topic!=e.topic&&(this.setState({topic:e.topic}),this.resetDesc(t,e)))}componentWillUnmount(){null!=this.ringTimer&&(clearInterval(this.ringTimer),Bs.pause());const e=this.props.tinode.getTopic(this.props.topic);e&&(this.setState({topic:null}),e.onMetaDesc=this.previousMetaDesc)}resetDesc(e){const t=[];if(e.trusted)for(const[s,i]of Object.entries(e.trusted))i&&t.push(s);this.setState({fullName:(0,Os.W5)(e.public?e.public.fn:void 0,60),avatar:(0,Ls.to)(e.public?e.public.photo:null),trustedBadges:t})}onMetaDesc(e){const t=this.props.tinode.getTopic(this.props.topic);t&&(this.resetDesc(t),this.previousMetaDesc&&this.previousMetaDesc!=this.onMetaDesc&&this.previousMetaDesc(e))}handleAcceptCall(){this.props.onAcceptCall(this.props.topic)}handleRejectCall(){this.props.onReject(this.props.topic,this.props.seq),this.props.onClose()}render(){return(0,js.jsx)("div",{className:"alert-container",children:(0,js.jsxs)("div",{className:"incoming-call",children:[(0,js.jsxs)("div",{className:"caller-card incoming pulse",children:[(0,js.jsx)("div",{className:"avatar-box",children:(0,js.jsx)(Us.A,{authorizeURL:this.props.tinode.authorizeURL,avatar:this.state.avatar||!0,topic:this.props.topic,title:this.state.fullName})}),(0,js.jsxs)("div",{className:"caller-name",children:[(0,Os.W5)(this.state.fullName,24),(0,js.jsx)(Fs.A,{short:!0,trustedBadges:this.state.trustedBadges})]})]}),(0,js.jsx)("div",{id:"controls",children:2==this.props.callState?(0,js.jsxs)(js.Fragment,{children:[(0,js.jsx)("button",{className:"danger",onClick:this.handleRejectCall,children:(0,js.jsx)("i",{className:"material-icons",children:"call_end"})}),(0,js.jsx)("button",{className:"positive",onClick:this.handleAcceptCall,children:(0,js.jsx)("i",{className:"material-icons",children:"call"})})]}):null})]})})}}var qs=o(3405),zs=o(9304);class Vs extends l().PureComponent{render(){return(0,js.jsx)("a",{href:"#",onClick:e=>{e.preventDefault(),this.props.onBack()},children:(0,js.jsx)("i",{className:"material-icons",children:"arrow_back"})})}}var Ws=o(6565);class Ks extends l().PureComponent{render(){return(0,js.jsxs)("div",{children:[(0,js.jsx)("a",{href:"#",onClick:e=>{e.preventDefault(),this.props.onNewTopic()},children:(0,js.jsx)("i",{className:"material-icons",children:"chat"})})," ",(0,js.jsx)("a",{href:"#",onClick:e=>{e.preventDefault(),this.props.onSettings()},children:(0,js.jsx)("i",{className:"material-icons",children:"settings"})})]})}}class $s extends l().PureComponent{render(){return(0,js.jsxs)("div",{children:[(0,js.jsx)("a",{href:"#",onClick:e=>{e.preventDefault(),this.props.onSignUp()},children:(0,js.jsx)("i",{className:"material-icons",children:"person_add"})})," ",(0,js.jsx)("a",{href:"#",onClick:e=>{e.preventDefault(),this.props.onSettings()},children:(0,js.jsx)("i",{className:"material-icons",children:"settings"})})]})}}var Gs=o(7849);class Ys extends l().PureComponent{render(){const e=[];this.props.trustedBadges&&this.props.trustedBadges.forEach(t=>{e.push({icon:t,color:"badge-inv"})});let t=null;return this.props.tinode&&(t=this.props.tinode.authorizeURL((0,Gs.wk)(this.props.avatar,"image"))),(0,js.jsxs)("div",{id:"side-caption-panel",className:"caption-panel",children:[this.props.onCancel?(0,js.jsx)(Vs,{onBack:this.props.onCancel}):null,t?(0,js.jsx)("div",{id:"self-avatar",className:"avatar-box",children:(0,js.jsx)(Us.A,{authorizeURL:this.props.tinode.authorizeURL,avatar:t,topic:this.props.myUserId,title:this.props.title})}):null,(0,js.jsxs)("div",{id:"sidepanel-title",className:"panel-title",children:[this.props.title,(0,js.jsx)(Ws.A,{badges:e})]}),"login"===this.props.state?(0,js.jsx)($s,{onSignUp:this.props.onSignUp,onSettings:this.props.onSettings}):"contacts"===this.props.state?(0,js.jsx)(Ks,{onNewTopic:this.props.onNewTopic,onSettings:this.props.onSettings}):null]})}}var Xs=o(6916);const Js=(0,d.defineMessages)({archived_contacts_title:{id:"archived_contacts",defaultMessage:"Archived contacts ({count})",description:"Label for archived chats"}});class Qs extends l().Component{constructor(e){super(e),this.handleAction=this.handleAction.bind(this),this.state=Qs.deriveStateFromProps(e)}static deriveStateFromProps(e){const t=[];let s=0,i=0;const n=e.tinode.getMeTopic();return e.chatList.forEach(a=>{const o=a.acs&&!a.acs.isJoiner();a.pinned=n.pinnedTopicRank(a.topic),o&&e.blocked&&t.push(a),o||e.blocked||(a.private&&a.private.arch?e.archive?t.push(a):i++:e.archive||(t.push(a),s+=a.unread>0?1:0))}),t.sort((e,t)=>{const s=t.pinned-e.pinned;return 0!=s?s:(t.touched||0)-(e.touched||0)}),i>0&&t.push({action:"archive",title:Js.archived_contacts_title,values:{count:i}}),{contactList:t,unreadThreads:s}}componentDidUpdate(e,t){if(e.chatList!=this.props.chatList||e.archive!=this.props.archive||e.blocked!=this.props.blocked){const e=Qs.deriveStateFromProps(this.props);this.setState(e),e.unreadThreads!=t.unreadThreads&&(0,Gs.OM)(e.unreadThreads)}}handleAction(e){this.props.onShowArchive()}render(){return(0,js.jsx)(d.FormattedMessage,{id:"contacts_not_found",defaultMessage:"You have no chats\\n¯∖_(ツ)_/¯",description:"HTML message shown in ContactList when no contacts are found",children:e=>(0,js.jsx)(Ds.A,{tinode:this.props.tinode,connected:this.props.connected,contacts:this.state.contactList,emptyListMessage:e,topicSelected:this.props.topicSelected,myUserId:this.props.myUserId,showOnline:!0,showUnread:!0,onTopicSelected:this.props.onTopicSelected,showContextMenu:this.props.showContextMenu,onAction:this.handleAction})})}}class Zs extends l().PureComponent{constructor(e){super(e),this.state={colorSchema:e.colorSchema||"auto",textSize:10*e.textSize||"100",sendOnEnter:e.sendOnEnter||"plain"},this.isMac=(navigator.userAgentData&&navigator.userAgentData.platform||navigator.platform).toLowerCase().startsWith("mac"),this.handleColorSchemaSelected=this.handleColorSchemaSelected.bind(this),this.handleTextSizeChanged=this.handleTextSizeChanged.bind(this),this.handleSendOnEnterSelected=this.handleSendOnEnterSelected.bind(this)}handleColorSchemaSelected(e){this.setState({colorSchema:e.currentTarget.value}),this.props.onChangeColorSchema(e.currentTarget.value)}handleTextSizeChanged(e){this.setState({textSize:e.currentTarget.value}),this.props.onTextSizeChanged(e.currentTarget.value/10|0)}handleSendOnEnterSelected(e){this.setState({sendOnEnter:e.currentTarget.value}),this.props.onSendOnEnterChanged(e.currentTarget.value)}render(){return(0,js.jsxs)("div",{id:"settings-form",className:"scrollable-panel",children:[(0,js.jsxs)("div",{className:"panel-form-column",children:[(0,js.jsx)("div",{className:"panel-form-row",children:(0,js.jsx)("label",{className:"small",children:(0,js.jsx)(d.FormattedMessage,{id:"label_color_schema",defaultMessage:"Theme:",description:"Label for selecting color scheme (dark, light) in Settings"})})}),(0,js.jsx)("div",{className:"panel-form-row",children:(0,js.jsxs)("ul",{className:"quoted",children:[(0,js.jsxs)("li",{children:[(0,js.jsx)("input",{type:"radio",id:"system",name:"color-scheme-select",value:"auto",checked:"auto"==this.state.colorSchema,onChange:this.handleColorSchemaSelected})," ",(0,js.jsxs)("label",{htmlFor:"system",children:[(0,js.jsx)(d.FormattedMessage,{id:"color_schema_system",defaultMessage:"System default",description:"Name of the color schema"})," ",(0,js.jsx)("img",{src:"img/routine.svg",style:{verticalAlign:"top",width:"1.6rem",height:"1.6rem"}})]})]},"system"),(0,js.jsxs)("li",{children:[(0,js.jsx)("input",{type:"radio",id:"light",name:"color-scheme-select",value:"light",checked:"light"==this.state.colorSchema,onChange:this.handleColorSchemaSelected})," ",(0,js.jsxs)("label",{htmlFor:"light",children:[(0,js.jsx)(d.FormattedMessage,{id:"color_schema_light",defaultMessage:"Light",description:"Name of the color schema"})," ",(0,js.jsx)("i",{className:"material-icons orange large",children:"light_mode"})]})]},"light"),(0,js.jsxs)("li",{children:[(0,js.jsx)("input",{type:"radio",id:"dark",name:"color-scheme-select",value:"dark",checked:"dark"==this.state.colorSchema,onChange:this.handleColorSchemaSelected})," ",(0,js.jsxs)("label",{htmlFor:"dark",children:[(0,js.jsx)(d.FormattedMessage,{id:"color_schema_dark",defaultMessage:"Dark",description:"Name of the color schema"})," ",(0,js.jsx)("i",{className:"material-icons blue large",children:"dark_mode"})]})]},"dark")]})})]}),(0,js.jsx)("div",{className:"hr"}),(0,js.jsx)("div",{className:"panel-form-row clean-clickable",children:(0,js.jsxs)("a",{onClick:this.props.onSelectWallpapers,className:"flat-button",children:[(0,js.jsx)("i",{className:"material-icons",children:"wallpaper"})," ",(0,js.jsx)(d.FormattedMessage,{id:"wallpapers",defaultMessage:"Wallpapers",description:"Link or title for working with wallpapers."})]})}),(0,js.jsx)("div",{className:"hr"}),(0,js.jsxs)("div",{className:"panel-form-column",children:[(0,js.jsx)("div",{className:"panel-form-row",children:(0,js.jsx)("label",{className:"small",children:(0,js.jsx)(d.FormattedMessage,{id:"label_text_size",defaultMessage:"Text size:",description:"Label adjusting text size"})})}),(0,js.jsx)("div",{className:"panel-form-row",children:(0,js.jsx)("input",{type:"range",id:"text_size",name:"text_size",min:"80",max:"120",step:"10",list:"text_size_options",value:this.state.textSize,onChange:this.handleTextSizeChanged})}),(0,js.jsx)("div",{className:"panel-form-row",children:(0,js.jsxs)("datalist",{id:"text_size_options",children:[(0,js.jsx)("option",{value:"80",label:"80%"}),(0,js.jsx)("option",{value:"90",label:"90%"}),(0,js.jsx)("option",{value:"100",label:"100%"}),(0,js.jsx)("option",{value:"110",label:"110%"}),(0,js.jsx)("option",{value:"120",label:"120%"})]})})]}),(0,js.jsx)("div",{className:"hr"}),(0,js.jsx)("div",{className:"panel-form-row",children:(0,js.jsx)("label",{className:"small",children:(0,js.jsx)(d.FormattedMessage,{id:"label_keyboard",defaultMessage:"Keyboard:",description:"Label for send on enter settings"})})}),(0,js.jsx)("div",{className:"panel-form-row",children:(0,js.jsxs)("ul",{className:"quoted",children:[(0,js.jsxs)("li",{children:[(0,js.jsx)("input",{type:"radio",id:"plain",name:"send-select",value:"plain",checked:"plain"==this.state.sendOnEnter,onChange:this.handleSendOnEnterSelected})," ",(0,js.jsxs)("label",{htmlFor:"send_plain",children:[(0,js.jsx)(d.FormattedMessage,{id:"send_plain",defaultMessage:"Send on Enter",description:"Config option to send message on hitting Enter"})," "]}),(0,js.jsx)("div",{className:"panel-form-row",children:(0,js.jsx)("span",{className:"small gray",children:(0,js.jsx)(d.FormattedMessage,{id:"send_plain_explained",defaultMessage:"Press Shift + Enter for new line",description:"Explanation how to enter newline when [Send on Enter] is enabled"})})})]},"plain"),(0,js.jsxs)("li",{children:[(0,js.jsx)("input",{type:"radio",id:"command",name:"send-select",value:"command",checked:"command"==this.state.sendOnEnter,onChange:this.handleSendOnEnterSelected})," ",(0,js.jsxs)("label",{htmlFor:"send_command",children:[(0,js.jsx)(d.FormattedMessage,{id:"send_command",defaultMessage:"Send on {key}",values:{key:this.isMac?"⌘ + Enter":"Ctrl + Enter"},description:"Config option to send message on hitting CTRL(or Cmd)-Enter"})," "]}),(0,js.jsx)("div",{className:"panel-form-row",children:(0,js.jsx)("span",{className:"small gray",children:(0,js.jsx)(d.FormattedMessage,{id:"send_command_explained",defaultMessage:"Press Enter for new line",description:"Explanation how to enter newline when [Send on CTRL-Enter] is enabled"})})})]},"command")]})})]})}}var ei=o(3207);class ti extends l().PureComponent{constructor(e){super(e),this.handleCheckboxClick=this.handleCheckboxClick.bind(this)}handleCheckboxClick(e,t){"sound"==e?this.props.onToggleMessageSounds(t):"alert"==e&&this.props.onTogglePushNotifications(t)}render(){return(0,js.jsxs)("div",{className:"scrollable-panel",children:[(0,js.jsxs)("div",{className:"panel-form-row",children:[(0,js.jsx)("label",{htmlFor:"message-sound",children:(0,js.jsx)(d.FormattedMessage,{id:"label_message_sound",defaultMessage:"Message sound:",description:"Label for message sounds toggle"})}),(0,js.jsx)(ei.A,{name:"sound",id:"message-sound",checked:this.props.messageSounds,onChange:this.handleCheckboxClick})]}),(0,js.jsxs)("div",{className:"panel-form-row",children:[(0,js.jsx)("label",{htmlFor:"desktop-alerts",children:this.props.desktopAlertsEnabled?(0,js.jsx)(d.FormattedMessage,{id:"label_push_notifications",defaultMessage:"Notification alerts:",description:"Label for push notifications switch"}):(0,js.jsx)(d.FormattedMessage,{id:"label_push_notifications_disabled",defaultMessage:"Notification alerts (requires HTTPS):",description:"Label for push notifications switch"})}),(0,js.jsx)(ei.A,{name:"alert",id:"desktop-alerts",checked:this.props.desktopAlerts,onChange:this.props.desktopAlertsEnabled?this.handleCheckboxClick:null})]})]})}}class si extends l().PureComponent{render(){return(0,js.jsxs)("div",{className:"scrollable-panel",children:[(0,js.jsxs)("div",{className:"panel-form-column",children:[(0,js.jsxs)("a",{href:ks.fi,className:"flat-button",target:"_blank",children:[(0,js.jsx)("i",{className:"material-icons",children:"email"}),"  ",(0,js.jsx)(d.FormattedMessage,{id:"link_contact_us",defaultMessage:"Contact Us",description:"Ancor text for contacting us by email"})]}),(0,js.jsxs)("a",{href:ks.V9,className:"flat-button",target:"_blank",children:[(0,js.jsx)("i",{className:"material-icons",children:"description"}),"  ",(0,js.jsx)(d.FormattedMessage,{id:"link_terms_of_service",defaultMessage:"Terms of Service",description:"Ancor text for terms of service link"})]}),(0,js.jsxs)("a",{href:ks.RS,className:"flat-button",target:"_blank",children:[(0,js.jsx)("i",{className:"material-icons",children:"policy"}),"  ",(0,js.jsx)(d.FormattedMessage,{id:"link_privacy_policy",defaultMessage:"Privacy Policy",description:"Ancor text for privacy policy link"})]})]}),(0,js.jsx)("div",{className:"hr"}),(0,js.jsxs)("div",{className:"panel-form-column",children:[(0,js.jsxs)("div",{className:"panel-form-row",children:[(0,js.jsx)("label",{className:"small",children:(0,js.jsx)(d.FormattedMessage,{id:"label_client",defaultMessage:"Client:",description:"Label for a client version"})}),ks.C3]}),(0,js.jsxs)("div",{className:"panel-form-row",children:[(0,js.jsx)("label",{className:"small",children:(0,js.jsx)(d.FormattedMessage,{id:"label_sdk",defaultMessage:"SDK:"})}),Ts.Tinode.getLibrary()]}),(0,js.jsxs)("div",{className:"panel-form-row",children:[(0,js.jsx)("label",{className:"small",children:(0,js.jsx)(d.FormattedMessage,{id:"label_server",defaultMessage:"Server:",description:"Label for a server version"})}),this.props.serverVersion]}),(0,js.jsxs)("div",{className:"panel-form-row",children:[(0,js.jsx)("label",{className:"small",children:(0,js.jsx)(d.FormattedMessage,{id:"label_server_address",defaultMessage:"Server address:"})}),this.props.serverAddress]})]})]})}}var ii=o(8568);class ni extends l().Component{constructor(e){super(e),this.state={login:e.login,password:"",hostName:e.serverAddress,saveToken:e.persist},this.handleLoginChange=this.handleLoginChange.bind(this),this.handlePasswordChange=this.handlePasswordChange.bind(this),this.handleToggleSaveToken=this.handleToggleSaveToken.bind(this),this.handleSubmit=this.handleSubmit.bind(this)}handleLoginChange(e){this.setState({login:e.target.value})}handlePasswordChange(e){this.setState({password:e.target.value})}handleToggleSaveToken(){this.props.onPersistenceChange(!this.state.saveToken),this.setState({saveToken:!this.state.saveToken})}handleSubmit(e){e.preventDefault(),this.props.onLogin(this.state.login.trim(),this.state.password.trim())}render(){let e="primary";return this.props.disabled&&(e+=" disabled"),(0,js.jsxs)("form",{id:"login-form",onSubmit:this.handleSubmit,children:[(0,js.jsx)(d.FormattedMessage,{id:"login_prompt",defaultMessage:"Login",description:"Placeholer for username/login",children:e=>(0,js.jsx)("input",{type:"text",id:"inputLogin",placeholder:e,autoComplete:"username",autoCorrect:"off",autoCapitalize:"none",value:this.state.login,onChange:this.handleLoginChange,required:!0,autoFocus:!0})}),(0,js.jsx)(d.FormattedMessage,{id:"password_prompt",defaultMessage:"Password",description:"Placeholder/prompt for entering password",children:e=>(0,js.jsx)(ii.A,{type:"password",id:"inputPassword",placeholder:e,autoComplete:"current-password",value:this.state.password,onChange:this.handlePasswordChange,required:!0})}),(0,js.jsxs)("div",{className:"panel-form-row",children:[(0,js.jsx)(ei.A,{id:"save-token",name:"save-token",checked:this.state.saveToken,onChange:this.handleToggleSaveToken}),(0,js.jsxs)("label",{htmlFor:"save-token",children:[" ",(0,js.jsx)(d.FormattedMessage,{id:"stay_logged_in",defaultMessage:"Stay logged in",description:"Label for a checkbox"})]}),(0,js.jsx)("a",{href:"#reset",children:(0,js.jsx)(d.FormattedMessage,{id:"forgot_password_link",defaultMessage:"Forgot password?",description:"Link to Reset password form"})})]}),(0,js.jsx)("div",{className:"dialog-buttons",children:(0,js.jsx)("button",{className:e,type:"submit",children:(0,js.jsx)(d.FormattedMessage,{id:"button_sign_in",defaultMessage:"Sign in",description:"Button [Sign In]"})})})]})}}var ai=o(9593),oi=o.n(ai);const ri=(0,d.defineMessages)({invalid_id:{id:"error_invalid_id",defaultMessage:"Invalid ID",description:"Error message"}});class li extends l().PureComponent{constructor(e){super(e),this.qrCodeRef=l().createRef(),this.state={groupId:""},this.handleChange=this.handleChange.bind(this),this.handleKeyPress=this.handleKeyPress.bind(this),this.handleSubmit=this.handleSubmit.bind(this)}componentDidMount(){new(oi())(this.qrCodeRef.current,{text:this.props.myURI,width:128,height:128})}handleChange(e){this.setState({groupId:e.target.value})}handleKeyPress(e){"Enter"===e.key&&this.handleSubmit(e)}handleSubmit(e){if(e.preventDefault(),this.state.groupId){const e=this.state.groupId.trim(),t=e.substring(0,3);e.length>3&&["usr","grp","chn"].includes(t)?this.props.onSubmit(e):this.props.onError(this.props.intl.formatMessage(ri.invalid_id),"err")}}render(){return(0,js.jsxs)("div",{className:"panel-form",children:[(0,js.jsx)("div",{className:"panel-form-row",children:(0,js.jsx)(d.FormattedMessage,{id:"group_user_id_prompt",defaultMessage:"Group or User ID",description:"Prompt for entering user or group ID",children:e=>(0,js.jsx)("input",{type:"text",placeholder:e,value:this.state.groupId,onChange:this.handleChange,onKeyDown:this.handleKeyPress,required:!0,autoFocus:!0})})}),(0,js.jsx)("div",{className:"dialog-buttons",children:(0,js.jsx)("button",{className:"primary",onClick:this.handleSubmit,children:(0,js.jsx)(d.FormattedMessage,{id:"button_subscribe",defaultMessage:"Subscribe",description:"Button [Subscribe]"})})}),(0,js.jsx)("br",{}),(0,js.jsxs)("div",{className:"panel-form-column",children:[(0,js.jsx)("label",{className:"small",children:(0,js.jsx)(d.FormattedMessage,{id:"label_scan_id",defaultMessage:"Scan my ID:",description:"Label [Scan my ID:]"})}),(0,js.jsx)("div",{className:"qr-code",ref:this.qrCodeRef})]})]})}}var ci=(0,d.injectIntl)(li),di=o(995),hi=o(3889),pi=o(1192);class ui extends l().PureComponent{constructor(e){super(e),this.fullName=l().createRef(),this.state={fullName:"",private:"",description:"",imageUrl:null,tags:[],isChannel:!1,newAvatar:null,newAvatarMime:null},this.handleFieldEdit=this.handleFieldEdit.bind(this),this.handleImageChanged=this.handleImageChanged.bind(this),this.handleAvatarCropped=this.handleAvatarCropped.bind(this),this.handleAvatarCropCancel=this.handleAvatarCropCancel.bind(this),this.uploadAvatar=this.uploadAvatar.bind(this),this.handleTagsChanged=this.handleTagsChanged.bind(this),this.handleChannelToggle=this.handleChannelToggle.bind(this),this.handleSubmit=this.handleSubmit.bind(this)}componentDidMount(){}handleFieldEdit(e,t){this.setState({[e]:t.target.value||""})}handleImageChanged(e,t){this.setState({newAvatar:t,newAvatarMime:e})}handleAvatarCropped(e,t,s,i){const n=t?URL.createObjectURL(t):null;this.setState({imageUrl:n,newAvatar:null,newAvatarMime:null}),t&&this.uploadAvatar(e,t,s,i)}handleAvatarCropCancel(){this.setState({newAvatar:null,newAvatarMime:null})}uploadAvatar(e,t,s,i){const n=e=>{let{mime:t,blob:s}=e;s.size>4096?this.props.tinode.getLargeFileHelper().upload(s).then(e=>this.setState({imageUrl:e})).catch(e=>this.props.onError(e.message,"err")):(0,Ls.Sk)(s).then(e=>this.setState({imageUrl:(0,Ls.to)({data:e.bits,type:t})}))};s>384||i>384||s!=i?(0,Ls.ag)(t,384,384,ks.qy,!0).then(e=>n(e)).catch(e=>this.props.onError(e.message,"err")):n({mime:e,blob:t,width:s,height:i})}handleTagsChanged(e){this.setState({tags:e})}handleChannelToggle(){this.setState({isChannel:!this.state.isChannel})}handleSubmit(e){e.preventDefault();const t=(0,Os.W5)(this.state.fullName.trim(),60),s=(0,Os.W5)(this.state.private.trim(),60),i=(0,Os.W5)(this.state.description.trim(),360);t&&this.props.onSubmit(t,i,this.state.imageUrl,s,this.state.tags,this.state.isChannel)}render(){if(this.state.newAvatar)return(0,js.jsx)(di.A,{avatar:this.state.newAvatar,mime:this.state.newAvatarMime,onSubmit:this.handleAvatarCropped,onCancel:this.handleAvatarCropCancel,onError:this.props.onError});let e="primary";return this.props.disabled&&(e+=" disabled"),(0,js.jsxs)("form",{className:"panel-form",onSubmit:this.handleSubmit,children:[(0,js.jsxs)("div",{className:"panel-form-column",children:[(0,js.jsx)("center",{children:(0,js.jsx)(hi.A,{tinode:this.props.tinode,avatar:this.state.imageUrl,onError:this.props.onError,onImageUpdated:this.handleImageChanged})}),(0,js.jsxs)("div",{className:"group",children:[(0,js.jsx)("label",{className:"small",htmlFor:"new-topic-fn",children:(0,js.jsx)(d.FormattedMessage,{id:"label_topic_name",defaultMessage:"Name",description:"Label for editing topic name"})}),(0,js.jsx)(d.FormattedMessage,{id:"topic_name_editing_placeholder",defaultMessage:"Freeform name of the group",description:"Prompt for entering topic name",children:e=>(0,js.jsx)("input",{type:"text",id:"new-topic-fn",placeholder:e,ref:this.fullName,value:this.state.fullName,onChange:this.handleFieldEdit.bind(this,"fullName"),autoFocus:!0,required:!0,tabIndex:0})})]}),(0,js.jsxs)("div",{className:"group",children:[(0,js.jsx)("label",{className:"small",htmlFor:"new-topic-priv",children:(0,js.jsx)(d.FormattedMessage,{id:"label_private",defaultMessage:"Private comment",description:"Label for editing 'private'"})}),(0,js.jsx)(d.FormattedMessage,{id:"private_editing_placeholder",defaultMessage:"Visible to you only",description:"Placeholder for editing 'private'",children:e=>(0,js.jsx)("input",{type:"text",id:"new-topic-priv",placeholder:e,value:this.state.private,onChange:this.handleFieldEdit.bind(this,"private"),tabIndex:1})})]}),(0,js.jsxs)("div",{className:"group",children:[(0,js.jsx)("label",{className:"small",htmlFor:"new-topic-desc",children:(0,js.jsx)(d.FormattedMessage,{id:"label_description",defaultMessage:"Description",description:"Label for description of user or topic"})}),(0,js.jsx)(d.FormattedMessage,{id:"description_editing_placeholder",defaultMessage:"Description (optional)",description:"Placeholder for editing topic description",children:e=>(0,js.jsx)("input",{type:"text",id:"new-topic-desc",placeholder:e,value:this.state.description,onChange:this.handleFieldEdit.bind(this,"description"),tabIndex:2})})]})]}),(0,js.jsxs)("div",{className:"panel-form-row",children:[(0,js.jsx)(ei.A,{checked:this.state.isChannel,tabIndex:3,onChange:this.handleChannelToggle})," ",(0,js.jsx)("label",{onClick:this.handleChannelToggle,children:(0,js.jsx)(d.FormattedMessage,{id:"channel_prompt",defaultMessage:"This is a channel",description:"Checkbox label when creating a channel"})})]}),(0,js.jsx)(d.FormattedMessage,{id:"title_tag_manager",defaultMessage:"Tags (search & discovery)",description:"Section title for TagManager",children:e=>(0,js.jsx)(pi.A,{tinode:this.props.tinode,tags:this.state.tags,activated:!0,onTagsChanged:this.handleTagsChanged,tabIndex:4,title:e})}),(0,js.jsx)("div",{className:"dialog-buttons",children:(0,js.jsx)("button",{className:e,children:(0,js.jsx)(d.FormattedMessage,{id:"button_create",defaultMessage:"Create",description:"Button [Create]"})})})]})}}var gi=o(184);const mi=(0,d.defineMessages)({search_for_contacts:{id:"search_for_contacts",defaultMessage:"Use search to find contacts",description:"Text shown in contacts view when user entered no search query."},search_no_results:{id:"search_no_results",defaultMessage:"Search returned no results",description:"Text shown in contacts view when query returned no results."},search_placeholder:{id:"search_placeholder",defaultMessage:"List like alice@example.com, +17025550003...",description:"Placeholder in contacts search field"}});class fi extends l().Component{constructor(e){super(e);const t=gi.A.parseUrlHash(window.location.hash).params,s=t.tab||"find",i="find"==s&&t.q||null;this.state={tabSelected:s,searchQuery:i},this.handleTabClick=this.handleTabClick.bind(this),this.handleSearchContacts=this.handleSearchContacts.bind(this),this.handleSearchResultSelected=this.handleSearchResultSelected.bind(this),this.handleNewGroupSubmit=this.handleNewGroupSubmit.bind(this),this.handleGroupByID=this.handleGroupByID.bind(this)}componentDidMount(){this.props.onInitFind()}handleTabClick(e){e.preventDefault(),gi.A.navigateTo(gi.A.addUrlParam(window.location.hash,"tab",e.currentTarget.dataset.id)),this.setState({tabSelected:e.currentTarget.dataset.id})}handleSearchContacts(e){if(e=e.trim()||Ts.Tinode.DEL_CHAR,!/[\s,:]/.test(e)&&e!=Ts.Tinode.DEL_CHAR){const t=(0,Gs.xH)(e);if(t)e=`${Ts.Tinode.TAG_EMAIL}${t}`;else{const t=(0,Gs.Jt)(e);t?e=`${Ts.Tinode.TAG_PHONE}${t}`:("@"==e[0]&&(e=e.substring(1)),e=`${Ts.Tinode.TAG_ALIAS}${e},${e}`)}}this.props.onSearchContacts(e),this.setState({searchQuery:Ts.Tinode.isNullValue(e)?null:e})}handleSearchResultSelected(e){"find"==this.state.tabSelected&&(gi.A.navigateTo(gi.A.removeUrlParams(window.location.hash,["tab","q"])),this.props.onCreateTopic(e))}handleNewGroupSubmit(e,t,s,i,n,a){gi.A.navigateTo(gi.A.removeUrlParams(window.location.hash,["tab","q"])),this.props.onCreateTopic(void 0,{public:(0,Gs.k6)(e,s,null,t),private:i,tags:n},a)}handleGroupByID(e){gi.A.navigateTo(gi.A.removeUrlParams(window.location.hash,["tab","q"])),this.props.onCreateTopic(e)}render(){const{formatMessage:e}=this.props.intl,t=e(this.state.searchQuery?mi.search_no_results:mi.search_for_contacts),s=e(mi.search_placeholder);return(0,js.jsxs)("div",{className:"flex-column",children:[(0,js.jsxs)("ul",{className:"tabbar",children:[(0,js.jsx)("li",{className:"find"===this.state.tabSelected?"active":null,children:(0,js.jsx)("a",{href:"#","data-id":"find",onClick:this.handleTabClick,children:(0,js.jsx)(d.FormattedMessage,{id:"tabtitle_find_user",defaultMessage:"find",description:"Tab title Find"})})}),(0,js.jsx)("li",{className:"grp"===this.state.tabSelected?"active":null,children:(0,js.jsx)("a",{href:"#","data-id":"grp",onClick:this.handleTabClick,children:(0,js.jsx)(d.FormattedMessage,{id:"tabtitle_new_group",defaultMessage:"new group",description:"Tab title New Group"})})}),(0,js.jsx)("li",{className:"byid"===this.state.tabSelected?"active":null,children:(0,js.jsx)("a",{href:"#","data-id":"byid",onClick:this.handleTabClick,children:(0,js.jsx)(d.FormattedMessage,{id:"tabtitle_group_by_id",defaultMessage:"by id",description:"Tab title Find topic by ID"})})})]}),"grp"===this.state.tabSelected?(0,js.jsx)(ui,{tinode:this.props.tinode,onSubmit:this.handleNewGroupSubmit,onError:this.props.onError}):"byid"===this.state.tabSelected?(0,js.jsx)(ci,{myURI:Ts.Tinode.URI_TOPIC_ID_PREFIX+this.props.tinode.getCurrentUserID(),onSubmit:this.handleGroupByID,onError:this.props.onError}):(0,js.jsxs)("div",{className:"flex-column",children:[(0,js.jsx)(Ps,{placeholder:s,initialQuery:this.state.searchQuery||"",onSearchContacts:this.handleSearchContacts}),(0,js.jsx)(Ds.A,{tinode:this.props.tinode,contacts:this.props.searchResults,myUserId:this.props.myUserId,emptyListMessage:t,showSelfTopic:!this.state.searchQuery,showOnline:!1,showUnread:!1,showContextMenu:!1,onTopicSelected:this.handleSearchResultSelected})]})]})}}var bi=(0,d.injectIntl)(fi);class vi extends l().PureComponent{constructor(e){super(e),this.state={hostName:e.serverAddress,changed:!1},this.handleHostNameChange=this.handleHostNameChange.bind(this),this.handleEditingFinished=this.handleEditingFinished.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this)}handleHostNameChange(e){this.setState({hostName:e.target.value,changed:!0})}handleEditingFinished(){this.state.changed&&(this.setState({changed:!1}),this.props.onServerAddressChange(this.state.hostName.trim()))}handleKeyDown(e){"Enter"==e.key&&this.handleEditingFinished()}render(){const e=[];for(let t in ks.SE){let s=ks.SE[t];e.push((0,js.jsx)("option",{value:s},s))}return(0,js.jsxs)("div",{className:"panel-form-row",children:[(0,js.jsx)("input",{type:"search",id:"host-name",placeholder:this.props.hostName,list:"known-hosts",className:"quoted",value:this.state.hostName,onChange:this.handleHostNameChange,onBlur:this.handleEditingFinished,onKeyDown:this.handleKeyDown,required:!0}),(0,js.jsx)("datalist",{id:"known-hosts",children:e})]})}}class wi extends l().PureComponent{constructor(e){super(e),this.state={transport:e.transport||"def",serverAddress:e.serverAddress,secureConnection:e.secureConnection},this.handleSubmit=this.handleSubmit.bind(this),this.handleTransportSelected=this.handleTransportSelected.bind(this),this.handleServerAddressChange=this.handleServerAddressChange.bind(this),this.handleToggleSecure=this.handleToggleSecure.bind(this)}handleSubmit(e){e.preventDefault(),this.props.onUpdate({transport:this.state.transport,serverAddress:this.state.serverAddress,secureConnection:this.state.secureConnection})}handleTransportSelected(e){this.setState({transport:e.currentTarget.value})}handleServerAddressChange(e){this.setState({serverAddress:e})}handleToggleSecure(e){this.setState({secureConnection:!this.state.secureConnection})}render(){const e={def:"default",ws:"websocket",lp:"long polling"},t=[];return["def","ws","lp"].forEach(s=>{const i="transport-"+s,n=e[s];t.push((0,js.jsxs)("li",{children:[(0,js.jsx)("input",{type:"radio",id:i,name:"transport-select",value:s,checked:this.state.transport===s,onChange:this.handleTransportSelected}),(0,js.jsx)("label",{htmlFor:i,children:n})]},s))}),(0,js.jsxs)("form",{id:"settings-form",className:"panel-form",onSubmit:this.handleSubmit,children:[(0,js.jsx)("div",{className:"panel-form-row",children:(0,js.jsx)("label",{className:"small",children:(0,js.jsx)(d.FormattedMessage,{id:"label_server_to_use",defaultMessage:"Server to use:",description:"Label for server selector in SettingsView"})})}),(0,js.jsx)(vi,{serverAddress:this.state.serverAddress,onServerAddressChange:this.handleServerAddressChange}),(0,js.jsxs)("div",{className:"panel-form-row",children:[(0,js.jsx)(ei.A,{id:"secure-connection",name:"secure-connection",checked:this.state.secureConnection,className:"quoted",onChange:this.handleToggleSecure}),(0,js.jsx)("label",{htmlFor:"secure-connection",children:(0,js.jsx)(d.FormattedMessage,{id:"label_use_secure_connection",defaultMessage:"Use secure connection",description:"Label for WS/WSS connection type in SettingsView"})})]}),(0,js.jsx)("div",{className:"panel-form-row",children:(0,js.jsx)("label",{className:"small",children:(0,js.jsx)(d.FormattedMessage,{id:"label_wire_transport",defaultMessage:"Wire transport:",description:"Label for wire transport selection in SettingsView"})})}),(0,js.jsx)("div",{className:"panel-form-row",children:(0,js.jsx)("ul",{className:"quoted",children:t})}),(0,js.jsx)("div",{className:"dialog-buttons",children:(0,js.jsx)("button",{type:"submit",className:"primary",children:(0,js.jsx)(d.FormattedMessage,{id:"button_update",defaultMessage:"Update",description:"Button [Update]"})})})]})}}const Si=(0,d.defineMessages)({phone:{id:"phone_dative",defaultMessage:"phone",description:"Dative case of 'phone', i.e. 'phone' in 'by phone'"},email:{id:"email_dative",defaultMessage:"email",description:"Dative case of 'email', i.e. 'email' in 'by email'"}});class Ci extends l().PureComponent{constructor(e){super(e),this.state={code:e.credCode||"",codeReceived:e.credCode},this.handleCodeChange=this.handleCodeChange.bind(this),this.handleKeyPress=this.handleKeyPress.bind(this),this.handleSubmit=this.handleSubmit.bind(this),this.handleCancel=this.handleCancel.bind(this)}static getDerivedStateFromProps(e,t){return e.credCode!=t.codeReceived?{code:e.credCode||"",codeReceived:e.credCode}:t}componentDidMount(){this.props.credCode&&this.props.onSubmit(this.props.credMethod,this.props.credCode,this.props.credToken)}componentDidUpdate(e,t){this.state.codeReceived&&this.state.code&&this.state.code!=t.code&&this.props.onSubmit(this.props.credMethod,this.state.code,this.props.credToken)}handleCodeChange(e){this.setState({code:e.target.value.replace(/[^\d]/g,"")})}handleKeyPress(e){"Enter"===e.key?this.handleSubmit(e):"Escape"==e.key&&this.handleCancel(e)}handleSubmit(e){e.preventDefault(),this.state.code&&this.state.code.trim()&&this.props.onSubmit(this.props.credMethod,this.state.code.trim(),this.props.credToken)}handleCancel(e){e.preventDefault(),this.props.onCancel()}render(){const{formatMessage:e}=this.props.intl,t={email:e(Si.email),tel:e(Si.phone)}[this.props.credMethod]||this.props.credMethod;return(0,js.jsxs)("div",{className:"panel-form",children:[(0,js.jsx)("div",{className:"panel-form-row",children:(0,js.jsx)("label",{className:"small gray",htmlFor:"enter-confirmation-code",children:(0,js.jsx)(d.FormattedMessage,{id:"enter_confirmation_code_prompt",defaultMessage:"Confirmation code",description:"Request to enter confirmation code",values:{method:t}})})}),(0,js.jsx)("div",{className:"panel-form-row",children:(0,js.jsx)(d.FormattedMessage,{id:"numeric_confirmation_code_prompt",defaultMessage:"Numbers only",description:"Prompt for numeric conformation code",children:e=>(0,js.jsx)("input",{type:"text",id:"enter-confirmation-code",placeholder:e,value:this.state.code,onChange:this.handleCodeChange,onKeyDown:this.handleKeyPress,required:!0})})}),(0,js.jsxs)("div",{className:"dialog-buttons",children:[(0,js.jsx)("button",{className:"secondary",onClick:this.handleCancel,children:(0,js.jsx)(d.FormattedMessage,{id:"button_cancel",defaultMessage:"Cancel",description:"Button [Cancel]"})}),(0,js.jsx)("button",{className:"primary",onClick:this.handleSubmit,children:(0,js.jsx)(d.FormattedMessage,{id:"button_confirm",defaultMessage:"Confirm",description:"Button [Confirm]"})})]})]})}}var yi=(0,d.injectIntl)(Ci);const xi=l().lazy(e=>Promise.all([o.e(892),o.e(330),o.e(983)]).then(o.bind(o,7983))),_i=l().lazy(e=>Promise.all([o.e(892),o.e(330),o.e(627)]).then(o.bind(o,3627))),Mi=l().lazy(e=>o.e(331).then(o.bind(o,6331))),Ti=l().lazy(e=>Promise.all([o.e(892),o.e(330),o.e(806)]).then(o.bind(o,3806))),ji=l().lazy(e=>o.e(686).then(o.bind(o,3686))),Ai=(0,d.defineMessages)({login:{id:"sidepanel_title_login",description:"Sidepanel title for LoginView.",defaultMessage:"Sign In"},register:{id:"sidepanel_title_register",description:"Sidepanel title for CreateAccountView.",defaultMessage:"Create Account"},settings:{id:"sidepanel_title_settings",description:"Sidepanel title for SettingsView.",defaultMessage:"Settings"},edit:{id:"sidepanel_title_account_settings",description:"Sidepanel title for AccountSettingsView.",defaultMessage:"Account Settings"},general:{id:"panel_title_general",description:"Title for TopicCommon.",defaultMessage:"General"},security:{id:"panel_title_security",description:"Title for TopicSecirity and AccSecurity.",defaultMessage:"Security"},crop:{id:"panel_title_crop",description:"Title for AvatarCropView.",defaultMessage:"Drag to Adjust"},notif:{id:"sidepanel_title_acc_notifications",description:"Sidepanel title for AccNotificationsView.",defaultMessage:"Notifications"},acc_general:{id:"sidepanel_title_acc_general",description:"Sidepanel title for AccGeneralView.",defaultMessage:"General"},support:{id:"sidepanel_title_acc_support",description:"Sidepanel title for AccSupportView.",defaultMessage:"Support"},newtpk:{id:"sidepanel_title_newtpk",description:"Sidepanel title for NewTopicView.",defaultMessage:"Start New Chat"},cred:{id:"sidepanel_title_cred",description:"Sidepanel title for ValidationView.",defaultMessage:"Confirm Credentials"},reset:{id:"sidepanel_title_reset",description:"Sidepanel title for PasswordResetView.",defaultMessage:"Reset Password"},archive:{id:"sidepanel_title_archive",description:"Sidepanel title for ContactsView-Archive.",defaultMessage:"Archived Chats"},blocked:{id:"sidepanel_title_blocked",description:"Sidepanel title for ContactsView-Blocked.",defaultMessage:"Blocked Chats"},wallpapers:{id:"wallpapers",description:"Link or title for working with wallpapers.",defaultMessage:"Wallpapers"}});class ki extends l().PureComponent{constructor(e){super(e),this.handleNewTopic=this.handleNewTopic.bind(this)}handleNewTopic(){this.props.onNavigate("newtpk")}render(){const{formatMessage:e}=this.props.intl,t=this.props.state||(this.props.myUserId?"contacts":"login");let s,i,n,a;return"contacts"==t?(s=this.props.title,i=!this.props.avatar||this.props.avatar,n=this.props.trustedBadges):(s=e(Ai[t]),i=!1,n=null),-1==["login","contacts"].indexOf(t)&&(a=this.props.onCancel),(0,js.jsxs)("div",{id:"sidepanel",children:[(0,js.jsx)(Ys,{state:t,title:s,avatar:i,tinode:this.props.tinode,trustedBadges:n,myUserId:this.props.myUserId,onSignUp:this.props.onSignUp,onSettings:this.props.onSettings,onNewTopic:this.handleNewTopic,onCancel:a}),(0,js.jsx)(qs.A,{level:this.props.errorLevel,text:this.props.errorText,action:this.props.errorAction,actionText:this.props.errorActionText,onClearError:this.props.onError}),(0,js.jsx)(zs.A,{show:this.props.loadSpinnerVisible}),"login"===t?(0,js.jsx)(ni,{login:this.props.login,disabled:this.props.loginDisabled,persist:this.props.persist,onLogin:this.props.onLoginRequest,onPersistenceChange:this.props.onPersistenceChange}):"register"===t?(0,js.jsx)(r.Suspense,{fallback:(0,js.jsx)("div",{className:"panel-form-row",children:(0,js.jsx)(d.FormattedMessage,{id:"loading_note",defaultMessage:"Loading...",description:"Message shown when component is loading"})}),children:(0,js.jsx)(_i,{tinode:this.props.tinode,reqCredMethod:this.props.reqCredMethod,onShowCountrySelector:this.props.onShowCountrySelector,onCreateAccount:this.props.onCreateAccount,onCancel:this.props.onCancel,onError:this.props.onError})}):"settings"===t?(0,js.jsx)(wi,{transport:this.props.transport,serverAddress:this.props.serverAddress,secureConnection:this.props.secureConnection,onCancel:this.props.onCancel,onUpdate:this.props.onGlobalSettings}):"edit"===t?(0,js.jsx)(r.Suspense,{fallback:(0,js.jsx)("div",{className:"panel-form-row",children:(0,js.jsx)(d.FormattedMessage,{id:"loading_note",defaultMessage:"Loading...",description:"Message shown when component is loading"})}),children:(0,js.jsx)(xi,{tinode:this.props.tinode,myUserId:this.props.myUserId,trustedBadges:this.props.trustedBadges,reqCredMethod:this.props.reqCredMethod,onShowCountrySelector:this.props.onShowCountrySelector,onNavigate:this.props.onNavigate,onCredAdd:this.props.onCredAdd,onCredDelete:this.props.onCredDelete,onCredConfirm:this.props.onCredConfirm,onError:this.props.onError})}):"general"===t||"crop"===t?(0,js.jsx)(Xs.A,{topic:"me",tinode:this.props.tinode,myUserId:this.props.myUserId,reqCredMethod:this.props.reqCredMethod,onUpdateTopicDesc:this.props.onUpdateAccountDesc,onUpdateTagsRequest:this.props.onUpdateAccountTags,onError:this.props.onError}):"acc_general"===t?(0,js.jsx)(Zs,{colorSchema:this.props.colorSchema,onSelectWallpapers:this.props.onSelectWallpapers,textSize:this.props.textSize,sendOnEnter:this.props.sendOnEnter,onChangeColorSchema:this.props.onChangeColorSchema,onTextSizeChanged:this.props.onTextSizeChanged,onSendOnEnterChanged:this.props.onSendOnEnterChanged}):"notif"===t?(0,js.jsx)(ti,{messageSounds:this.props.messageSounds,desktopAlerts:this.props.desktopAlerts,desktopAlertsEnabled:this.props.desktopAlertsEnabled,onTogglePushNotifications:this.props.onTogglePushNotifications,onToggleMessageSounds:this.props.onToggleMessageSounds}):"security"===t?(0,js.jsx)(r.Suspense,{fallback:(0,js.jsx)("div",{className:"panel-form-row",children:(0,js.jsx)(d.FormattedMessage,{id:"loading_note",defaultMessage:"Loading...",description:"Message shown when component is loading"})}),children:(0,js.jsx)(Mi,{tinode:this.props.tinode,incognitoMode:this.props.incognitoMode,onUpdateAccountDesc:this.props.onUpdateAccountDesc,onUpdatePassword:this.props.onUpdatePassword,onLogout:this.props.onLogout,onDeleteAccount:this.props.onDeleteAccount,onShowAlert:this.props.onShowAlert,onShowBlocked:this.props.onShowBlocked,onToggleIncognitoMode:this.props.onToggleIncognitoMode})}):"support"===t?(0,js.jsx)(si,{serverAddress:this.props.serverAddress,serverVersion:this.props.serverVersion}):"wallpapers"===t?(0,js.jsx)(r.Suspense,{fallback:(0,js.jsx)("div",{className:"panel-form-row",children:(0,js.jsx)(d.FormattedMessage,{id:"loading_note",defaultMessage:"Loading...",description:"Message shown when component is loading"})}),children:(0,js.jsx)(ji,{wallpaper:this.props.wallpaper,wallpaperSize:this.props.wallpaperSize,wallpaperBlur:this.props.wallpaperBlur,colorSchema:"auto"!==this.props.colorSchema?this.props.colorSchema:this.props.systemColorSchema,onWallpaperSelected:this.props.onWallpaperSelected})}):"contacts"===t||"archive"==t||"blocked"==t?(0,js.jsx)(Qs,{tinode:this.props.tinode,myUserId:this.props.myUserId,connected:this.props.connected,topicSelected:this.props.topicSelected,archive:"archive"==t,blocked:"blocked"==t,chatList:this.props.chatList,showContextMenu:this.props.showContextMenu,onTopicSelected:this.props.onTopicSelected,onShowArchive:this.props.onShowArchive}):"newtpk"===t?(0,js.jsx)(bi,{tinode:this.props.tinode,searchResults:this.props.searchResults,onInitFind:this.props.onInitFind,onSearchContacts:this.props.onSearchContacts,onCreateTopic:this.props.onCreateTopic,onError:this.props.onError}):"cred"===t?(0,js.jsx)(yi,{credCode:this.props.credCode,credMethod:this.props.credMethod,credToken:this.props.credToken,onSubmit:this.props.onValidateCredentials,onCancel:this.props.onCancel}):"reset"===t?(0,js.jsx)(r.Suspense,{fallback:(0,js.jsx)("div",{className:"panel-form-row",children:(0,js.jsx)(d.FormattedMessage,{id:"loading_note",defaultMessage:"Loading...",description:"Message shown when component is loading"})}),children:(0,js.jsx)(Ti,{tinode:this.props.tinode,reqCredMethod:this.props.reqCredMethod,onShowCountrySelector:this.props.onShowCountrySelector,onRequest:this.props.onPasswordResetRequest,onReset:this.props.onResetPassword,onCancel:this.props.onCancel,onError:this.props.onError})}):null]})}}var Ei=(0,d.injectIntl)(ki);const Ni="started";function Ii(){let e=ks.HX;return"object"==typeof window.location&&("file:"==window.location.protocol||"localhost"==window.location.hostname?e=ks.SE.local:window.location.hostname&&(e=window.location.hostname+(window.location.port?":"+window.location.port:""))),e}function Di(){return"object"==typeof window.location&&"https:"==window.location.protocol}var Pi=o(99);const Ri=l().lazy(e=>o.e(125).then(o.bind(o,9125))),Fi=l().lazy(e=>o.e(158).then(o.bind(o,158))),Ui=l().lazy(e=>o.e(523).then(o.bind(o,7523))),Li=new Audio("audio/msg.m4a"),Oi=(0,d.defineMessages)({reconnect_countdown:{id:"reconnect_countdown",defaultMessage:"Disconnected. Reconnecting in {seconds}…",description:"Message shown when an app update is available."},reconnect_now:{id:"reconnect_now",defaultMessage:"Try now",description:"Prompt for reconnecting now"},push_init_failed:{id:"push_init_failed",defaultMessage:"Failed to initialize push notifications",description:"Error message when push notifications have failed to initialize."},invalid_security_token:{id:"invalid_security_token",defaultMessage:"Invalid security token",description:"Error message when resetting password."},no_connection:{id:"no_connection",defaultMessage:"No connection",description:"Warning that the user is offline."},code_doesnot_match:{id:"code_doesnot_match",defaultMessage:"Code does not match",description:"Error message when the credential validation code is incorrect."},menu_item_info:{id:"menu_item_info",defaultMessage:"Info",description:"Show extended topic information"},menu_item_audio_call:{id:"menu_item_audio_call",defaultMessage:"Call",description:"Start audio call"},menu_item_video_call:{id:"menu_item_video_call",defaultMessage:"Video call",description:"Start video call"},cred_confirmed_successfully:{id:"cred_confirmed_successfully",defaultMessage:"Confirmed successfully",description:"Notification message that the credential was successfully validated."},password_reset_success:{id:"password_reset_success",defaultMessage:"Password reset successfully",description:"Notification message that the password was successfully reset."},select_country:{id:"select_country",defaultMessage:"Select country",description:"Placeholder for the country selector"}});class Bi extends l().Component{constructor(e){super(e),this.selfRef=l().createRef(),this.state=this.getBlankState(),this.handleResize=this.handleResize.bind(this),this.handleHashRoute=this.handleHashRoute.bind(this),this.handleOnline=this.handleOnline.bind(this),this.handleEscapeKey=this.handleEscapeKey.bind(this),this.handleColorSchemeChange=this.handleColorSchemeChange.bind(this),this.checkForAppUpdate=this.checkForAppUpdate.bind(this),this.handleVisibilityEvent=this.handleVisibilityEvent.bind(this),this.handleError=this.handleError.bind(this),this.handleLoginRequest=this.handleLoginRequest.bind(this),this.handlePersistenceChange=this.handlePersistenceChange.bind(this),this.handleConnected=this.handleConnected.bind(this),this.handleAutoreconnectIteration=this.handleAutoreconnectIteration.bind(this),this.doLogin=this.doLogin.bind(this),this.handleLoginSuccessful=this.handleLoginSuccessful.bind(this),this.handleDisconnect=this.handleDisconnect.bind(this),this.tnMeMetaDesc=this.tnMeMetaDesc.bind(this),this.tnMeContactUpdate=this.tnMeContactUpdate.bind(this),this.tnMeSubsUpdated=this.tnMeSubsUpdated.bind(this),this.resetContactList=this.resetContactList.bind(this),this.tnInitFind=this.tnInitFind.bind(this),this.tnFndSubsUpdated=this.tnFndSubsUpdated.bind(this),this.handleSearchContacts=this.handleSearchContacts.bind(this),this.handleTopicSelected=this.handleTopicSelected.bind(this),this.handleHideMessagesView=this.handleHideMessagesView.bind(this),this.handleSendMessage=this.handleSendMessage.bind(this),this.handleNewChatInvitation=this.handleNewChatInvitation.bind(this),this.handleNewAccount=this.handleNewAccount.bind(this),this.handleNewAccountRequest=this.handleNewAccountRequest.bind(this),this.handleUpdatePasswordRequest=this.handleUpdatePasswordRequest.bind(this),this.handleUpdateAccountTagsRequest=this.handleUpdateAccountTagsRequest.bind(this),this.handleToggleIncognitoMode=this.handleToggleIncognitoMode.bind(this),this.handleChangeColorSchema=this.handleChangeColorSchema.bind(this),this.handleChangeTextSize=this.handleChangeTextSize.bind(this),this.handleSendOnEnter=this.handleSendOnEnter.bind(this),this.handleSelectWallpapers=this.handleSelectWallpapers.bind(this),this.handleWallpaperSelected=this.handleWallpaperSelected.bind(this),this.handleSettings=this.handleSettings.bind(this),this.handleGlobalSettings=this.handleGlobalSettings.bind(this),this.handleShowArchive=this.handleShowArchive.bind(this),this.handleShowBlocked=this.handleShowBlocked.bind(this),this.handleToggleMessageSounds=this.handleToggleMessageSounds.bind(this),this.handleCredAdd=this.handleCredAdd.bind(this),this.handleCredDelete=this.handleCredDelete.bind(this),this.handleCredConfirm=this.handleCredConfirm.bind(this),this.initFCMessaging=this.initFCMessaging.bind(this),this.toggleFCMToken=this.toggleFCMToken.bind(this),this.handlePushMessage=this.handlePushMessage.bind(this),this.handleSidepanelCancel=this.handleSidepanelCancel.bind(this),this.handleStartTopicRequest=this.handleStartTopicRequest.bind(this),this.handleNewTopicCreated=this.handleNewTopicCreated.bind(this),this.handleTopicUpdateRequest=this.handleTopicUpdateRequest.bind(this),this.handleUnarchive=this.handleUnarchive.bind(this),this.handleChangePermissions=this.handleChangePermissions.bind(this),this.handleTagsUpdateRequest=this.handleTagsUpdateRequest.bind(this),this.handleLogout=this.handleLogout.bind(this),this.handleDeleteAccount=this.handleDeleteAccount.bind(this),this.handleDeleteTopicRequest=this.handleDeleteTopicRequest.bind(this),this.handleDeleteMessagesRequest=this.handleDeleteMessagesRequest.bind(this),this.handleLeaveUnsubRequest=this.handleLeaveUnsubRequest.bind(this),this.handleBlockTopicRequest=this.handleBlockTopicRequest.bind(this),this.handleReportTopic=this.handleReportTopic.bind(this),this.handleShareTheCard=this.handleShareTheCard.bind(this),this.handleShowContextMenu=this.handleShowContextMenu.bind(this),this.defaultTopicContextMenu=this.defaultTopicContextMenu.bind(this),this.handleHideContextMenu=this.handleHideContextMenu.bind(this),this.handleShowAlert=this.handleShowAlert.bind(this),this.handleShowInfoView=this.handleShowInfoView.bind(this),this.handleMemberUpdateRequest=this.handleMemberUpdateRequest.bind(this),this.handleValidateCredentialsRequest=this.handleValidateCredentialsRequest.bind(this),this.handlePasswordResetRequest=this.handlePasswordResetRequest.bind(this),this.handleResetPassword=this.handleResetPassword.bind(this),this.handleContextMenuAction=this.handleContextMenuAction.bind(this),this.handleShowCountrySelector=this.handleShowCountrySelector.bind(this),this.handleShowForwardDialog=this.handleShowForwardDialog.bind(this),this.handleHideForwardDialog=this.handleHideForwardDialog.bind(this),this.handleStartVideoCall=this.handleStartVideoCall.bind(this),this.handleStartAudioCall=this.handleStartAudioCall.bind(this),this.handleInfoMessage=this.handleInfoMessage.bind(this),this.handleDataMessage=this.handleDataMessage.bind(this),this.handleCallClose=this.handleCallClose.bind(this),this.handleCallInvite=this.handleCallInvite.bind(this),this.handleCallRinging=this.handleCallRinging.bind(this),this.handleCallHangup=this.handleCallHangup.bind(this),this.handleCallSendOffer=this.handleCallSendOffer.bind(this),this.handleCallIceCandidate=this.handleCallIceCandidate.bind(this),this.handleCallSendAnswer=this.handleCallSendAnswer.bind(this),this.handleCallAccept=this.handleCallAccept.bind(this),this.sendMessageToTopic=this.sendMessageToTopic.bind(this),this.callTimeoutTimer=null}getBlankState(){const e=Pi.A.getObject("settings")||{},t=!!Pi.A.getObject("keep-logged-in");if(!e.wallpaper){const t=(0,Gs.KY)();e.wallpaper=t.name||"",e.wallpaperSize=t.size||0,e.wallpaperBlur=0}return{connected:!1,ready:!1,autoLogin:!1,transport:e.transport||null,serverAddress:e.serverAddress||Ii(),secureConnection:void 0===e.secureConnection?Di():e.secureConnection,serverVersion:"no connection",messageSounds:!e.messageSoundsOff,incognitoMode:!1,colorSchema:e.colorSchema||"auto",systemColorSchema:window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",wallpaper:e.wallpaper,wallpaperSize:e.wallpaperSize,wallpaperBlur:0,textSize:e.textSize||10,sendOnEnter:e.sendOnEnter||"plain",desktopAlerts:t&&!!e.desktopAlerts,desktopAlertsEnabled:(Di()||"object"==typeof window.location&&"localhost"==window.location.hostname)&&void 0!==Be&&"undefined"!=typeof navigator&&"undefined"!=typeof FIREBASE_INIT,firebaseToken:t?Pi.A.getObject("firebase-token"):null,applicationVisible:!document.hidden,errorText:"",errorLevel:null,errorAction:void 0,errorActionText:null,sidePanelSelected:"login",sidePanelTitle:null,sidePanelAvatar:null,myTrustedBadges:[],loadSpinnerVisible:!1,login:"",password:"",persist:t,myUserId:null,liveConnection:navigator.onLine,topicSelected:"",topicSelectedOnline:!1,topicSelectedAcs:null,newTopicParams:null,loginDisabled:!1,displayMobile:window.innerWidth<=640,infoPanel:void 0,mobilePanel:"sidepanel",callTopic:void 0,callState:0,callAudioOnly:void 0,callShouldStart:!1,contextMenuVisible:!1,contextMenuBounds:null,contextMenuClickAt:null,contextMenuParams:null,contextMenuItems:[],forwardDialogVisible:!1,forwardMessage:null,alertVisible:!1,alertParams:{},chatList:[],searchResults:[],searchableContacts:[],reqCredMethod:void 0,credMethod:void 0,credCode:void 0,credToken:void 0,requestedTopic:void 0}}componentDidMount(){window.addEventListener("resize",this.handleResize),this.handleOnlineOn=e=>{this.handleOnline(!0)},window.addEventListener("online",this.handleOnlineOn),this.handleOnlineOff=e=>{this.handleOnline(!1)},window.addEventListener("offline",this.handleOnlineOff),window.addEventListener("hashchange",this.handleHashRoute),window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",this.handleColorSchemeChange),document.addEventListener("visibilitychange",this.handleVisibilityEvent),document.addEventListener("keydown",this.handleEscapeKey),document.documentElement.style.colorScheme="auto"==this.state.colorSchema?"light dark":this.state.colorSchema,document.documentElement.style.setProperty("--message-text-size",`${this.state.textSize}pt`),this.applyWallpaperSettings(this.state.wallpaper,this.state.wallpaperSize,this.state.wallpaperBlur,"auto"==this.state.colorSchema?this.state.systemColorSchema:this.state.colorSchema),"function"==typeof BroadcastChannel?new BroadcastChannel("tinode-sw").addEventListener("message",this.handlePushMessage):console.warn("Your browser does not support BroadcastChannel. Some features will not be available"),this.lastWakeUpCheck=(new Date).getTime(),this.wakeUpTicker=setInterval(e=>{const t=(new Date).getTime();t-this.lastWakeUpCheck>8e4&&this.handleOnlineOn(),this.lastWakeUpCheck=t},1e3),this.setState({viewportWidth:document.documentElement.clientWidth,viewportHeight:document.documentElement.clientHeight}),new Promise((e,t)=>{this.tinode=Bi.tnSetup(this.state.serverAddress,Di(),this.state.transport,this.props.intl.locale,this.state.persist,e),this.tinode.onConnect=this.handleConnected,this.tinode.onDisconnect=this.handleDisconnect,this.tinode.onAutoreconnectIteration=this.handleAutoreconnectIteration,this.tinode.onInfoMessage=this.handleInfoMessage,this.tinode.onDataMessage=this.handleDataMessage}).then(e=>{this.state.desktopAlertsEnabled&&this.initFCMessaging().catch(e=>{}),this.resetContactList();const t=this.state.persist?Pi.A.getObject("auth-token"):void 0;t&&(this.setState({autoLogin:!0}),t.expires=new Date(t.expires),this.tinode.setAuthToken(t),this.tinode.connect().catch(e=>{this.handleError(e.message,"err")}));const s=gi.A.parseUrlHash(window.location.hash);if(["cred","reset","register"].includes(s.path[0]))this.handleHashRoute();else{this.setState({requestedTopic:s.path[1]});const e=s.params&&s.params.cred_done?gi.A.addUrlParam("","cred_done",s.params.cred_done):"";gi.A.navigateTo(e)}})}componentWillUnmount(){window.removeEventListener("resize",this.handleResize),window.removeEventListener("hashchange",this.handleHashRoute),window.removeEventListener("online",this.handleOnlineOn),window.removeEventListener("offline",this.handleOnlineOff),window.matchMedia("(prefers-color-scheme: dark)").removeEventListener("change",this.handleColorSchemeChange),document.removeEventListener("visibilitychange",this.handleVisibilityEvent),document.removeEventListener("keydown",this.handleEscapeKey),clearInterval(this.wakeUpTicker)}static tnSetup(e,t,s,i,n,a){const o=new Ts.Tinode({appName:ks.C3,host:e,apiKey:ks.Lq,transport:s,secure:t,persist:n},a);return o.setHumanLanguage(i),o.enableLogging(!0,!0),o}handlePushMessage(e){this.tinode.oobNotification(e.data||{})}initFCMessaging(){const{formatMessage:e,locale:t}=this.props.intl,s=(t,s)=>{console.error(t,s),this.handleError(e(Oi.push_init_failed),"err"),this.setState({firebaseToken:null}),Pi.A.updateObject("settings",{desktopAlerts:!1})};try{return this.fcm=xs(Be(FIREBASE_INIT,ks.iv)),navigator.serviceWorker.getRegistration("/service-worker.js").then(e=>e||navigator.serviceWorker.register("/service-worker.js").then(e=>(this.checkForAppUpdate(e),e))).then(e=>((e.active||e.installing).postMessage(JSON.stringify({locale:t,version:"0.25.3"})),Bi.requestFCMToken(this.fcm,e))).then(e=>{const t=Pi.A.getObject("keep-logged-in");var s,i;e!=this.state.firebaseToken&&(this.tinode.setDeviceToken(e),t&&Pi.A.setObject("firebase-token",e)),this.setState({firebaseToken:e,desktopAlerts:!0}),t&&Pi.A.updateObject("settings",{desktopAlerts:!0}),s=this.fcm,i=e=>{this.handlePushMessage(e)},function(e,t){if(!navigator)throw qt.create("only-available-in-window");e.onMessageHandler=t}(s=M(s),i)}).catch(e=>{throw s(e),e})}catch(e){return s(e),Promise.reject(e)}}static requestFCMToken(e,t){return _s(e,{serviceWorkerRegistration:t,vapidKey:FIREBASE_INIT.messagingVapidKey}).then(s=>{if(s)return s;if("undefined"!=typeof Notification)return Notification.requestPermission().then(s=>{if("granted"===s)return _s(e,{serviceWorkerRegistration:t,vapidKey:FIREBASE_INIT.messagingVapidKey}).then(e=>{if(e)return e;throw new Error("Failed to initialize notifications")});throw new Error("No permission to send notifications: "+s)});throw new Error("Notifications are not supported")})}handleResize(){const e=document.documentElement.clientWidth<=640;this.setState({viewportWidth:document.documentElement.clientWidth,viewportHeight:document.documentElement.clientHeight}),this.state.displayMobile!=e&&this.setState({displayMobile:e})}handleEscapeKey(e){"Escape"!==e.key&&27!==e.keyCode||(this.setState({topicSelected:null,errorText:"",errorLevel:null,mobilePanel:"sidepanel",topicSelectedOnline:!1,topicSelectedAcs:null,infoPanel:void 0,forwardMessage:null,contextMenuVisible:!1,forwardDialogVisible:!1,alertVisible:!1}),gi.A.navigateTo(gi.A.setUrlTopic("",null)))}checkForAppUpdate(e){e.onupdatefound=t=>{const s=e.installing;s.onstatechange=e=>{if("installed"==s.state&&navigator.serviceWorker.controller){const e=(0,js.jsxs)(js.Fragment,{children:[(0,js.jsx)(d.FormattedMessage,{id:"update_available",defaultMessage:"Update available.",description:"Message shown when an app update is available."})," ",(0,js.jsx)("a",{href:"",children:(0,js.jsx)(d.FormattedMessage,{id:"reload_update",defaultMessage:"Reload",description:"Call to action to reload application when update is available."})}),"."]});this.handleError(e,"info")}}}}handleHashRoute(){const e=gi.A.parseUrlHash(window.location.hash),t={infoPanel:e.params.info,newTopicTabSelected:e.params.tab};if(e.path&&e.path.length>0){["acc_general","archive","blocked","contacts","cred","crop","edit","general","newtpk","notif","register","reset","security","settings","support","wallpapers",""].includes(e.path[0])?t.sidePanelSelected=e.path[0]:console.warn("Unknown sidepanel view",e.path[0]);let s=e.path[1]||null;s!=this.state.topicSelected&&(Ts.Tinode.topicType(s)?t.mobilePanel="topic-view":(s=null,t.mobilePanel="sidepanel"),Object.assign(t,{topicSelected:s,topicSelectedAcs:this.tinode.getTopicAccessMode(s)}))}else Object.assign(t,{sidePanelSelected:"",topicSelected:null});e.params.method&&(t.credMethod=e.params.method),e.params.code&&(t.credCode=e.params.code),e.params.token&&(t.credToken=e.params.token),e.params.cred_done&&Object.assign(t,Bi.stateForError(this.props.intl.formatMessage(Oi.cred_confirmed_successfully),"info")),this.setState(t)}handleOnline(e){e?(this.handleError(),clearInterval(this.reconnectCountdown),this.tinode.reconnect()):this.handleError(this.props.intl.formatMessage(Oi.no_connection),"warn"),this.setState({liveConnection:e})}handleVisibilityEvent(){this.setState({applicationVisible:!document.hidden})}static stateForError(e,t,s,i){return{errorText:e,errorLevel:t,errorAction:s,errorActionText:i,callShouldStart:!1}}handleError(e,t,s,i){this.setState(Bi.stateForError(e,t,s,i))}handleLoginRequest(e,t){this.setState({loginDisabled:!0,login:e,password:t,loadSpinnerVisible:!0,autoLogin:!0}),this.handleError("",null),this.tinode.isConnected()?this.doLogin(e,t,null,{meth:this.state.credMethod,resp:this.state.credCode}):this.tinode.connect().catch(e=>{this.setState({loginDisabled:!1,autoLogin:!1,loadSpinnerVisible:!1}),this.handleError(e.message,"err")}),this.state.desktopAlertsEnabled&&!this.state.firebaseToken&&this.initFCMessaging()}handlePersistenceChange(e){e?this.tinode.initStorage().then(e=>{Pi.A.setObject("keep-logged-in",!0),this.setState({persist:!0})}):this.tinode.clearStorage().then(e=>{Pi.A.setObject("keep-logged-in",!1),this.setState({persist:!1})})}handleConnected(){clearInterval(this.reconnectCountdown),this.handleError();const e=this.tinode.getServerInfo();this.setState({serverVersion:e.ver+" "+(e.build?e.build:"none"),reqCredMethod:((e.reqCred||{}).auth||[])[0]||"email"}),this.state.autoLogin&&this.doLogin(this.state.login,this.state.password,null,{meth:this.state.credMethod,resp:this.state.credCode})}handleAutoreconnectIteration(e,t){if(clearInterval(this.reconnectCountdown),e<0)return void this.handleError();if(t)return void t.then(e=>{this.handleError()}).catch(e=>{this.handleError(e.message,"err")});const{formatMessage:s}=this.props.intl;let i=e/1e3;i|=i,this.reconnectCountdown=setInterval(e=>{if(i<-10)return clearInterval(this.reconnectCountdown),void this.tinode.reconnect();const t=i>99?(0,Os.Ye)(i):i;this.handleError(s(Oi.reconnect_countdown,{seconds:t}),"warn",e=>{clearInterval(this.reconnectCountdown),this.tinode.reconnect()},s(Oi.reconnect_now)),i-=1},1e3)}handleDisconnect(e){this.setState({connected:!1,ready:!1,topicSelectedOnline:!1,errorText:e&&e.message?e.message:"Disconnected",errorLevel:e&&e.message?"err":"warn",loginDisabled:!1,contextMenuVisible:!1,forwardDialogVisible:!1,serverVersion:"no connection"})}doLogin(e,t,s,i){if(this.tinode.isAuthenticated())return void gi.A.navigateTo("");let n=s||(this.tinode.getAuthToken()||{}).token;if(!(e&&t||n))return gi.A.navigateTo(""),void this.setState({loginDisabled:!1});i=Ts.Tinode.credential(i);let a,o=this.tinode.isConnected()?Promise.resolve():this.tinode.connect();e&&t?(n=null,this.setState({password:null}),a=o.then(s=>this.tinode.loginBasic(e,t,i))):a=o.then(e=>this.tinode.loginToken(n,i)),a.then(e=>{e.code>=300&&"validate credentials"===e.text?(this.setState({loadSpinnerVisible:!1}),i&&this.handleError(this.props.intl.formatMessage(Oi.code_doesnot_match),"warn"),Bi.navigateToCredentialsView(e.params)):this.handleLoginSuccessful()}).catch(e=>{const t=e.code>=500;this.setState({loginDisabled:!1,credMethod:void 0,credCode:void 0,loadSpinnerVisible:!1,autoLogin:t}),this.handleError(e.message,"err"),console.warn("Login failed",e),t||(n&&this.handleLogout(),gi.A.navigateTo(""))})}static navigateToCredentialsView(e){const t=gi.A.parseUrlHash(window.location.hash);t.path[0]="cred",t.params.method=e.cred[0],t.params.token=e.token,t.params.code=e.code,gi.A.navigateTo(gi.A.composeUrlHash(t.path,t.params))}handleLoginSuccessful(){this.handleError(),Pi.A.getObject("keep-logged-in")&&Pi.A.setObject("auth-token",this.tinode.getAuthToken());const e=this.state.requestedTopic||this.state.topicSelected,t=this.tinode.getMeTopic();t.onMetaDesc=this.tnMeMetaDesc,t.onContactUpdate=this.tnMeContactUpdate,t.onSubsUpdated=this.tnMeSubsUpdated,this.setState({connected:!0,credMethod:void 0,credCode:void 0,credToken:void 0,myUserId:this.tinode.getCurrentUserID(),autoLogin:!0,requestedTopic:void 0}),t.subscribe(t.startMetaQuery().withLaterSub().withDesc().withTags().withCred().build()).catch(e=>{this.tinode.disconnect(),localStorage.removeItem("auth-token"),this.handleError(e.message,"err"),gi.A.navigateTo("")}).finally(e=>{this.setState({loadSpinnerVisible:!1})});let s=gi.A.setUrlSidePanel(window.location.hash,"contacts");e&&(s=gi.A.setUrlTopic(s,e)),gi.A.navigateTo(s)}tnMeMetaDesc(e){if(e){if(e.public&&this.setState({sidePanelTitle:e.public.fn,sidePanelAvatar:(0,Ls.to)(e.public.photo)}),e.trusted){const t=[];for(const[s,i]of Object.entries(e.trusted))i&&t.push(s);this.setState({myTrustedBadges:t})}e.acs&&this.setState({incognitoMode:!e.acs.isPresencer()}),Bi.checkIfPinsUpdated(e,this.state.chatList)&&this.resetContactList()}}tnMeContactUpdate(e,t){if("on"==e||"off"==e)this.resetContactList(),this.state.topicSelected==t.topic&&this.setState({topicSelectedOnline:"on"==e});else if("read"==e)this.resetContactList();else if("msg"==e&&t){const e=this.tinode.getTopic(t.topic),s=e&&e.isArchived();t.unread>0&&this.state.messageSounds&&!s&&(document.hidden||this.state.topicSelected!=t.topic)&&Li.play().catch(e=>{}),this.resetContactList()}else"recv"==e||("gone"==e||"unsub"==e?(this.state.topicSelected==t.topic&&this.handleTopicSelected(null),this.resetContactList()):"acs"==e?this.state.topicSelected==t.topic&&this.setState({topicSelectedAcs:t.acs}):"del"==e||"upd"==e||"call"==e||console.info("Unsupported (yet) presence update:",e,"in",(t||{}).topic))}tnMeSubsUpdated(e){this.resetContactList()}static prepareSearchableContacts(e,t){const s={};for(const t of e)Ts.Tinode.isP2PTopicName(t.topic)&&(s[t.topic]={user:t.topic,updated:t.updated,public:t.public,private:t.private,acs:t.acs});for(const e of t)s[e.user]||(s[e.user]=e);return Object.values(s)}resetContactList(){const e={chatList:[]};this.state.ready||(e.ready=!0);const t=this.tinode.getMeTopic();t.contacts(t=>{t.topic||t.user||(t.topic=t.name),e.chatList.push(t),this.state.topicSelected==t.topic&&(e.topicSelectedOnline=t.online,e.topicSelectedAcs=t.acs)});const s=new Date(0);e.chatList.sort((e,i)=>{const n=t.pinnedTopicRank(i.topic)-t.pinnedTopicRank(e.topic);return 0!=n?n:(i.touched||s).getTime()-(e.touched||s).getTime()}),e.searchableContacts=Bi.prepareSearchableContacts(e.chatList,this.state.searchResults),this.setState(e)}static checkIfPinsUpdated(e,t){for(let s=0;s{this.handleError(e.message,"err")})}tnFndSubsUpdated(){const e=[];this.tinode.getFndTopic().contacts(t=>{e.push(t)}),this.setState({searchResults:e,searchableContacts:Bi.prepareSearchableContacts(this.state.chatList,e)})}handleSearchContacts(e){const t=this.tinode.getFndTopic();t.setMeta({desc:{public:e}}).then(e=>t.getMeta(t.startMetaQuery().withSub().build())).catch(e=>this.handleError(e.message,"err"))}handleTopicSelected(e){this.state.newTopicParams&&this.state.newTopicParams._topicName!=e&&this.setState({newTopicParams:null}),e?(this.setState({errorText:"",errorLevel:null,mobilePanel:"topic-view",infoPanel:void 0}),this.state.topicSelected!=e&&(this.setState({topicSelectedOnline:this.tinode.isTopicOnline(e),topicSelectedAcs:this.tinode.getTopicAccessMode(e),forwardMessage:null}),gi.A.navigateTo(gi.A.setUrlTopic("",e)))):(this.setState({topicSelected:null,errorText:"",errorLevel:null,mobilePanel:"sidepanel",topicSelectedOnline:!1,topicSelectedAcs:null,infoPanel:void 0,forwardMessage:null}),gi.A.navigateTo(gi.A.setUrlTopic("",null)))}handleHideMessagesView(){this.setState({mobilePanel:"sidepanel"}),gi.A.navigateTo(gi.A.setUrlTopic(window.location.hash,null))}handleSendMessage(e,t,s,i){const n=this.tinode.getTopic(this.state.topicSelected);return this.sendMessageToTopic(n,e,t,s,i)}sendMessageToTopic(e,t,s,i,n){(t=e.createMessage(t,!1))._uploader=i,n&&(t.head=Object.assign(t.head||{},n));const a=[];if(s&&a.push(s),!e.isSubscribed()){const s=e.subscribe().then(s=>{let i=[];e.queuedMessages(s=>{s._sending||s.seq==t.seq||(s.head&&s.head.webrtc?i.push(s.seq):e.isSubscribed()&&e.publishMessage(s))}),i.length>0&&e.delMessagesList(i,!0)});a.push(s)}return e.publishDraft(t,Promise.all(a)).then(t=>(e.isArchived()&&e.archive(!1),t)).catch(e=>this.handleError(e.message,"err"))}handleNewChatInvitation(e,t){const s=this.tinode.getTopic(e);let i=null;switch(t){case"accept":const n=s.getAccessMode().getGiven();i=s.setMeta({sub:{mode:n}}),s.isP2PType()&&(i=i.then(t=>s.setMeta({sub:{user:e,mode:n}})));break;case"delete":i=s.delTopic(!0);break;case"block":const a=s.getAccessMode().updateWant("-JP").getWant();i=s.setMeta({sub:{mode:a}}).then(e=>this.handleTopicSelected(null));break;default:console.warn("Unknown invitation action",'"'+t+'""')}null!=i&&i.catch(e=>this.handleError(e.message,"err"))}handleNewAccount(){this.handleError(),gi.A.navigateTo(gi.A.setUrlSidePanel(window.location.hash,"register"))}handleNewAccountRequest(e,t,s,i,n){this.handleError(),this.tinode.connect(this.state.serverAddress).then(a=>{let o;return s&&s.photo&&s.photo.ref&&(o=[s.photo.ref]),this.tinode.createAccountBasic(e,t,{public:s,tags:n,cred:Ts.Tinode.credential(i),attachments:o})}).then(e=>{e.code>=300&&"validate credentials"==e.text?Bi.navigateToCredentialsView(e.params):this.handleLoginSuccessful(this)}).catch(e=>{this.handleError(e.message,"err")})}handleToggleIncognitoMode(e){this.setState({incognitoMode:null});const t=this.tinode.getMeTopic(),s=t.getAccessMode().updateWant(e?"-P":"+P").getWant();t.setMeta({sub:{mode:s}}).catch(t=>{this.setState({incognitoMode:!e}),this.handleError(t.message,"err")})}handleChangeColorSchema(e){this.setState({colorSchema:e}),Pi.A.updateObject("settings",{colorSchema:e}),document.documentElement.style.colorScheme="auto"==e?"light dark":e,this.applyColorSchema(e,this.state.systemColorSchema,this.state.wallpaperSize)}handleColorSchemeChange(e){const t=e.matches?"dark":"light";this.setState({systemColorSchema:t}),this.applyColorSchema(this.state.colorSchema,t,this.state.wallpaperSize)}applyColorSchema(e,t,s){const i="auto"==e?t:e;document.documentElement.style.setProperty("--wallpaper-invert","dark"==i&&s?"1":"0"),document.documentElement.style.setProperty("--wallpaper-brightness","dark"!=i||s?"1":"0.5")}handleSelectWallpapers(){this.handleError(),gi.A.navigateTo(gi.A.setUrlSidePanel(window.location.hash,"wallpapers"))}applyWallpaperSettings(e,t,s,i){document.documentElement.style.setProperty("--wallpaper-url",`url('${e}')`),document.documentElement.style.setProperty("--wallpaper-repeat",t?"repeat":"no-repeat"),document.documentElement.style.setProperty("--wallpaper-blur",t?"0px":`${s}px`),document.documentElement.style.setProperty("--wallpaper-size",t?`${t}px`:"cover"),document.documentElement.style.setProperty("--wallpaper-position",t?"unset":"center"),document.documentElement.style.setProperty("--wallpaper-invert","dark"==i&&t?"1":"0"),document.documentElement.style.setProperty("--wallpaper-brightness","dark"!=i||t?"1":"0.5")}handleWallpaperSelected(e,t,s){this.handleError(),Pi.A.updateObject("settings",{wallpaper:e,wallpaperSize:t,wallpaperBlur:s}),this.setState({wallpaper:e,wallpaperSize:t,wallpaperBlur:s}),this.applyWallpaperSettings(e,t,s,"auto"==this.state.colorSchema?this.state.systemColorSchema:this.state.colorSchema)}handleChangeTextSize(e){this.setState({textSize:0|e}),Pi.A.updateObject("settings",{textSize:e}),document.documentElement.style.setProperty("--message-text-size",`${e}pt`)}handleSendOnEnter(e){this.setState({sendOnEnter:e}),Pi.A.updateObject("settings",{sendOnEnter:e})}handleUpdateAccountTagsRequest(e,t){this.tinode.getMeTopic().setMeta({tags:t}).catch(e=>this.handleError(e.message,"err"))}handleSettings(){this.handleError(),gi.A.navigateTo(gi.A.setUrlSidePanel(window.location.hash,this.state.myUserId?"edit":"settings"))}handleGlobalSettings(e){const t=e.serverAddress||this.state.serverAddress,s=e.transport||this.state.transport,i=void 0===e.secureConnection?this.state.secureConnection:e.secureConnection;this.tinode&&(this.tinode.clearStorage(),this.tinode.onDisconnect=void 0,this.tinode.disconnect()),this.tinode=Bi.tnSetup(t,i,s,this.props.intl.locale,Pi.A.getObject("keep-logged-in")),this.tinode.onConnect=this.handleConnected,this.tinode.onDisconnect=this.handleDisconnect,this.tinode.onAutoreconnectIteration=this.handleAutoreconnectIteration,this.tinode.onInfoMessage=this.handleInfoMessage,this.tinode.onDataMessage=this.handleDataMessage,this.setState({serverAddress:t,transport:s,secureConnection:i}),Pi.A.setObject("settings",{serverAddress:t,transport:s,secureConnection:i}),gi.A.navigateTo(gi.A.setUrlSidePanel(window.location.hash,""))}handleShowArchive(){gi.A.navigateTo(gi.A.setUrlSidePanel(window.location.hash,this.state.myUserId?"archive":""))}handleShowBlocked(){gi.A.navigateTo(gi.A.setUrlSidePanel(window.location.hash,this.state.myUserId?"blocked":""))}toggleFCMToken(e){e?(this.setState({desktopAlerts:null}),this.state.firebaseToken?(this.setState({desktopAlerts:!0}),Pi.A.getObject("keep-logged-in")&&Pi.A.updateObject("settings",{desktopAlerts:!0})):this.initFCMessaging()):this.state.firebaseToken&&this.fcm?Ms(this.fcm).catch(e=>{console.error("Unable to delete token.",e)}).finally(e=>{Pi.A.updateObject("settings",{desktopAlerts:!1}),localStorage.removeItem("firebase-token"),this.setState({desktopAlerts:!1,firebaseToken:null}),this.tinode.setDeviceToken(null)}):(this.setState({desktopAlerts:!1,firebaseToken:null}),Pi.A.updateObject("settings",{desktopAlerts:!1}))}handleToggleMessageSounds(e){this.setState({messageSounds:e}),Pi.A.updateObject("settings",{messageSoundsOff:!e})}handleCredAdd(e,t){this.tinode.getMeTopic().setMeta({cred:{meth:e,val:t}}).catch(e=>this.handleError(e.message,"err"))}handleCredDelete(e,t){this.tinode.getMeTopic().delCredential(e,t).catch(e=>this.handleError(e.message,"err"))}handleCredConfirm(e,t){Bi.navigateToCredentialsView({cred:[e],code:t})}handleSidepanelCancel(){const e=gi.A.parseUrlHash(window.location.hash);let t="";["security","support","general","notif","acc_general"].includes(e.path[0])?t="edit":"crop"==e.path[0]?t="general":"blocked"==e.path[0]?t="security":"wallpapers"==e.path[0]?t="acc_general":this.state.myUserId&&(t="contacts"),e.path[0]=t,e.params&&(delete e.params.code,delete e.params.method,delete e.params.tab,delete e.params.scheme,delete e.params.token),gi.A.navigateTo(gi.A.composeUrlHash(e.path,e.params)),this.setState({errorText:"",errorLevel:null})}basicNavigator(e){gi.A.navigateTo(gi.A.setUrlSidePanel(window.location.hash,e))}infoNavigator(e){gi.A.navigateTo(gi.A.setUrlInfoPanel(window.location.hash,e))}handleStartTopicRequest(e,t,s){if(e&&this.tinode.isTopicCached(e))return void this.handleTopicSelected(e);const i={};Ts.Tinode.isP2PTopicName(e)?(i.sub={mode:"JRWPS"},i.desc={defacs:{auth:"JRWPS"}}):(e=e||this.tinode.newGroupTopicName(s),t&&(i.desc={public:t.public,private:{comment:t.private}},i.tags=t.tags)),i._topicName=e,this.setState({newTopicParams:i},t=>{this.handleTopicSelected(e)})}handleNewTopicCreated(e,t){let s={};this.state.callShouldStart&&(s={callState:3,callShouldStart:!1}),this.state.topicSelected==e&&e!=t&&(s.topicSelected=t),this.setState(s,e=>{gi.A.navigateTo(gi.A.setUrlTopic("",t))})}handleTopicUpdateRequest(e,t,s,i){this.handleError();const n=this.tinode.getTopic(e);if(n){const e={};let a;t&&(t.photo&&(t.photo.ref&&t.photo.ref!=Ts.Tinode.DEL_CHAR?a=[t.photo.ref]:t.photo.data&&t.photo.data!=Ts.Tinode.DEL_CHAR||(t.photo=Ts.Tinode.DEL_CHAR)),e.public=t),"string"==typeof s&&(e.private=s===Ts.Tinode.DEL_CHAR?Ts.Tinode.DEL_CHAR:{comment:s}),i&&(e.defacs=i),n.setMeta({desc:e,attachments:a}).catch(e=>this.handleError(e.message,"err"))}}handleUnarchive(e){const t=this.tinode.getTopic(e);t&&t.archive(!1).catch(e=>this.handleError(e.message,"err"))}handleUpdatePasswordRequest(e){this.handleError(),e&&this.tinode.updateAccountBasic(null,this.tinode.getCurrentLogin(),e).catch(e=>this.handleError(e.message,"err"))}handleChangePermissions(e,t,s){const i=this.tinode.getTopic(e);if(i){const e=i.getAccessMode();s?(e.updateGiven(t),t=e.getGiven()):(e.updateWant(t),t=e.getWant()),i.setMeta({sub:{user:s,mode:t}}).catch(e=>this.handleError(e.message,"err"))}}handleTagsUpdateRequest(e,t){const s=this.tinode.getTopic(e);s&&s.setMeta({tags:t}).catch(e=>this.handleError(e.message,"err"))}handleLogout(){let e;(0,Gs.OM)(0),localStorage.removeItem("auth-token"),localStorage.removeItem("firebase-token"),localStorage.removeItem("settings"),this.state.firebaseToken&&this.fcm&&Ms(this.fcm).catch(e=>{console.warn("Failed to delete FCM token on logout",e)}),document.documentElement.style.colorScheme="light dark",document.documentElement.style.setProperty("--message-text-size","10pt"),clearInterval(this.reconnectCountdown),this.tinode?(e=this.tinode.clearStorage(),this.tinode.onDisconnect=void 0,this.tinode.disconnect()):e=Promise.resolve(),this.setState(this.getBlankState()),e.then(e=>{this.tinode=Bi.tnSetup(this.state.serverAddress,Di(),this.state.transport,this.props.intl.locale,Pi.A.getObject("keep-logged-in"),e=>{this.tinode.onConnect=this.handleConnected,this.tinode.onDisconnect=this.handleDisconnect,this.tinode.onAutoreconnectIteration=this.handleAutoreconnectIteration,this.tinode.onInfoMessage=this.handleInfoMessage,this.tinode.onDataMessage=this.handleDataMessage,gi.A.navigateTo("")})})}handleDeleteAccount(){this.tinode.delCurrentUser(!0).then(e=>{this.handleLogout()})}handleDeleteTopicRequest(e){const t=this.tinode.getTopic(e);t&&t.delTopic(!0).then(e=>{gi.A.navigateTo(gi.A.setUrlTopic(window.location.hash,""))}).catch(e=>{this.handleError(e.message,"err")})}handleDeleteMessagesRequest(e){const t=this.tinode.getTopic(e);t&&t.delMessagesAll(!0).catch(e=>this.handleError(e.message,"err"))}handleLeaveUnsubRequest(e){const t=this.tinode.getTopic(e);t&&t.leave(!0).then(e=>{gi.A.navigateTo(gi.A.setUrlTopic(window.location.hash,""))}).catch(e=>{this.handleError(e.message,"err")})}handleBlockTopicRequest(e){const t=this.tinode.getTopic(e);t&&t.updateMode(null,"-JP").then(e=>{gi.A.navigateTo(gi.A.setUrlTopic(window.location.hash,""))}).catch(e=>this.handleError(e.message,"err"))}handleReportTopic(e){const t=this.tinode.getTopic(e);t&&(this.tinode.report("report",e),t.updateMode(null,"-JP").then(e=>{gi.A.navigateTo(gi.A.setUrlTopic(window.location.hash,""))}).catch(e=>this.handleError(e.message,"err")))}handleShowContextMenu(e,t){this.setState({contextMenuVisible:!0,contextMenuClickAt:{x:e.x,y:e.y},contextMenuParams:e,contextMenuItems:t||this.defaultTopicContextMenu(e.topicName),contextMenuBounds:this.selfRef.current.getBoundingClientRect()})}handleShowForwardDialog(e){"newtpk"==this.state.sidePanelSelected&&this.handleSidepanelCancel();const t=e.userName?"➦ "+e.userName:"",s="string"==typeof e.content?Ts.Drafty.init(e.content):Ts.Drafty.forwardedContent(e.content),i=Ts.Drafty.preview(s,84,!0),n=Ts.Drafty.append(Ts.Drafty.appendLineBreak(Ts.Drafty.mention(t,e.userFrom)),s),a=Ts.Drafty.quote(t,e.userFrom,i),o={forwarded:e.topicName+":"+e.seq};this.setState({forwardDialogVisible:!0,forwardMessage:{head:o,msg:n,preview:a}})}handleShareTheCard(e){this.setState({forwardDialogVisible:!0,forwardMessage:{content:e,type:e.contentType}})}defaultTopicContextMenu(e){const t=this.tinode.getTopic(e);if(t._deleted)return["topic_delete"];const s=this.tinode.getMeTopic();let i=!1,n=!1,a=!1,o=!1,r=!1,l=!1,c=!1,d=!1,h=!1,p=!1,u=!1;if(t){o=t.isSubscribed(),l=t.isArchived(),c=s.pinnedTopicRank(e)>0;const d=t.getAccessMode();d&&(i=d.isMuted(),n=!d.isJoiner(),a=!d.isJoiner("want"),r=d.isDeleter(),h=d.isWriter())}return d=h&&!!this.tinode.getServerParam("iceServers"),p=Ts.Tinode.isP2PTopicName(e),u=Ts.Tinode.isSelfTopicName(e),[o?{title:this.props.intl.formatMessage(Oi.menu_item_info),handler:this.handleShowInfoView}:null,o&&p&&d?{title:this.props.intl.formatMessage(Oi.menu_item_audio_call),handler:this.handleStartAudioCall}:null,o&&p&&d?{title:this.props.intl.formatMessage(Oi.menu_item_video_call),handler:this.handleStartVideoCall}:null,o?"messages_clear":null,o&&r&&!u?"messages_clear_hard":null,u?null:i?n?null:"topic_unmute":"topic_mute",u?null:a?"topic_unblock":"topic_block",c?"topic_unpin":"topic_pin",l?"topic_restore":"topic_archive","topic_delete"]}handleHideContextMenu(){this.setState({contextMenuVisible:!1,contextMenuClickAt:null,contextMenuParams:null,contextMenuBounds:null})}handleHideForwardDialog(e){this.setState({forwardDialogVisible:!1,forwardMessage:e?this.state.forwardMessage:null})}handleContextMenuAction(e,t,s){"topic_archive"==e?t&&s.topicName&&s.topicName==this.state.topicSelected&&t.then(e=>{this.handleTopicSelected(null)}):"menu_item_forward"==e&&this.handleShowForwardDialog(s)}handleShowAlert(e,t,s,i,n,a){this.setState({alertVisible:!0,alertParams:{title:e,content:t,onConfirm:s,confirm:i,onReject:n,reject:a}})}handleShowInfoView(){gi.A.navigateTo(gi.A.addUrlParam(window.location.hash,"info","info")),this.setState({infoPanel:"info"})}handleMemberUpdateRequest(e,t,s){if(!e)return;const i=this.tinode.getTopic(e);i&&(t&&t.length>0&&t.forEach(e=>{i.invite(e,null).catch(e=>this.handleError(e.message,"err"))}),s&&s.length>0&&s.forEach(e=>{i.delSubscription(e).catch(e=>this.handleError(e.message,"err"))}))}handleValidateCredentialsRequest(e,t,s){this.tinode.isAuthenticated()?this.tinode.getMeTopic().setMeta({cred:{meth:e,resp:t}}).then(e=>gi.A.navigateTo(gi.A.setUrlSidePanel(window.location.hash,"contacts"))).catch(e=>this.handleError(e.message,"err")):(this.setState({credMethod:e,credCode:t,credToken:s}),this.doLogin(null,null,s,{meth:e,resp:t}))}handlePasswordResetRequest(e,t){return this.tinode.connect().then(s=>this.tinode.requestResetAuthSecret("basic",e,t)).catch(e=>{this.handleError(e.message,"err")})}handleResetPassword(e,t){const s=(0,Ls.$Z)(t.secret);s&&t.scheme?this.tinode.connect().then(i=>this.tinode.updateAccountBasic(null,null,e,{scheme:t.scheme,secret:s})).then(e=>{this.handleError(this.props.intl.formatMessage(Oi.password_reset_success),"info"),gi.A.navigateTo("")}).catch(e=>{this.handleError(e.message,"err")}):this.handleError(this.props.intl.formatMessage(Oi.invalid_security_token),"err")}handleShowCountrySelector(e,t,s){this.handleShowAlert(this.props.intl.formatMessage(Oi.select_country),(0,js.jsx)(r.Suspense,{fallback:(0,js.jsx)("div",{children:(0,js.jsx)(d.FormattedMessage,{id:"loading_note",defaultMessage:"Loading...",description:"Message shown when component is loading"})}),children:(0,js.jsx)(Ri,{selected:e,onSubmit:(e,t)=>{this.setState({alertVisible:!1}),s(e,t)}})}),null,null,e=>{},null)}handleStartVideoCall(){this.setState({callTopic:this.state.topicSelected,callState:1,callAudioOnly:!1})}handleStartAudioCall(){this.setState({callTopic:this.state.topicSelected,callState:1,callAudioOnly:!0})}handleCallInvite(e,t,s,i){switch(s){case 1:const s={webrtc:Ni,aonly:!!i};return this.handleSendMessage(Ts.Drafty.videoCall(i),void 0,void 0,s).then(e=>e.code<200||e.code>=300||!e.params||!e.params.seq?(this.handleCallClose(),e):(this.setState({callSeq:e.params.seq}),e));case 3:const n=this.tinode.getTopic(e);if(!n)return;n.videoCall("accept",t)}}handleCallRinging(e,t){const s=this.tinode.getTopic(e);s&&s.videoCall("ringing",t)}handleCallHangup(e,t){const s=this.tinode.getTopic(e);s&&s.videoCall("hang-up",t)}handleCallSendOffer(e,t,s){const i=this.tinode.getTopic(e);i&&i.videoCall("offer",t,s)}handleCallIceCandidate(e,t,s){const i=this.tinode.getTopic(e);i&&i.videoCall("ice-candidate",t,s)}handleCallSendAnswer(e,t,s){const i=this.tinode.getTopic(e);i&&i.videoCall("answer",t,s)}handleCallClose(){this.callTimeoutTimer&&clearTimeout(this.callTimeoutTimer),this.setState({callTopic:void 0,callState:0,callAudioOnly:void 0})}handleCallAccept(e,t,s){const i=this.tinode.getTopic(e);if(i)if(i.isSubscribed()){this.handleTopicSelected(t?e:this.state.callTopic);const i={callState:3};t&&(i.callTopic=e,i.callSeq=s),this.setState(i)}else this.setState({callShouldStart:!0},e=>this.handleTopicSelected(this.state.callTopic))}handleInfoMessage(e){if("call"==e.what)switch(e.event){case"accept":if(Ts.Tinode.isMeTopicName(e.topic)&&this.tinode.isMe(e.from))return void this.setState({callTopic:null,callState:0,callSeq:null,callAudioOnly:void 0});e.topic==this.state.callTopic&&this.setState({callState:3});break;case"hang-up":this.handleCallClose()}}handleDataMessage(e){if(e.head&&e.head.webrtc&&e.head.webrtc==Ni&&Ts.Tinode.isP2PTopicName(e.topic)){const t=this.tinode.getTopic(e.topic);if(t){const s=t.latestMsgVersion(e.seq)||e;s.head&&s.head.webrtc&&s.head.webrtc==Ni&&e.from!=this.state.myUserId&&(0==this.state.callState?this.setState({callTopic:e.topic,callState:2,callSeq:e.seq,callAudioOnly:!!s.head.aonly}):this.handleCallHangup(e.topic,e.seq))}else console.warn("Received vc data message from unknown topic",e.topic)}}render(){const e="auto"!==this.state.colorSchema?this.state.colorSchema:this.state.systemColorSchema;return(0,js.jsxs)("div",{id:"app-container",ref:this.selfRef,children:[this.state.contextMenuVisible?(0,js.jsx)(Is,{tinode:this.tinode,bounds:this.state.contextMenuBounds,clickAt:this.state.contextMenuClickAt,params:this.state.contextMenuParams,items:this.state.contextMenuItems,hide:this.handleHideContextMenu,onShowAlert:this.handleShowAlert,onAction:this.handleContextMenuAction,onTopicRemoved:e=>{e==this.state.topicSelected&&this.handleTopicSelected(null)},onError:this.handleError}):null,this.state.forwardDialogVisible?(0,js.jsx)(Rs,{tinode:this.tinode,contacts:this.state.chatList,topicSelected:this.state.topicSelected,myUserId:this.state.myUserId,hide:this.handleHideForwardDialog,onInitFind:this.tnInitFind,searchResults:this.state.searchResults,onSearchContacts:this.handleSearchContacts,onTopicSelected:this.handleStartTopicRequest}):null,this.state.callTopic&&2==this.state.callState?(0,js.jsx)(Hs,{tinode:this.tinode,topic:this.state.callTopic,seq:this.state.callSeq,callState:this.state.callState,audioOnly:this.state.callAudioOnly,onClose:this.handleCallClose,onRinging:this.handleCallRinging,onAcceptCall:this.handleCallAccept,onReject:this.handleCallHangup}):null,this.state.alertVisible?(0,js.jsx)(As,{title:this.state.alertParams.title,content:this.state.alertParams.content,onReject:this.state.alertParams.onReject?e=>this.setState({alertVisible:!1}):null,reject:this.state.alertParams.reject,onConfirm:this.state.alertParams.onConfirm?e=>{this.setState({alertVisible:!1}),this.state.alertParams.onConfirm()}:null,confirm:this.state.alertParams.confirm}):null,this.state.displayMobile&&"sidepanel"!=this.state.mobilePanel?null:(0,js.jsx)(Ei,{tinode:this.tinode,connected:this.state.connected,displayMobile:this.state.displayMobile,state:this.state.sidePanelSelected,title:this.state.sidePanelTitle,avatar:this.state.sidePanelAvatar,trustedBadges:this.state.myTrustedBadges,login:this.state.login,persist:this.state.persist,myUserId:this.state.myUserId,loginDisabled:this.state.loginDisabled,loadSpinnerVisible:this.state.loadSpinnerVisible,errorText:this.state.errorText,errorLevel:this.state.errorLevel,errorAction:this.state.errorAction,errorActionText:this.state.errorActionText,topicSelected:this.state.topicSelected,chatList:this.state.chatList,credMethod:this.state.credMethod,credCode:this.state.credCode,credToken:this.state.credToken,transport:this.state.transport,messageSounds:this.state.messageSounds,desktopAlerts:this.state.desktopAlerts,desktopAlertsEnabled:this.state.desktopAlertsEnabled,incognitoMode:this.state.incognitoMode,serverAddress:this.state.serverAddress,secureConnection:this.state.secureConnection,serverVersion:this.state.serverVersion,reqCredMethod:this.state.reqCredMethod,textSize:this.state.textSize,colorSchema:this.state.colorSchema,wallpaper:this.state.wallpaper,wallpaperSize:this.state.wallpaperSize,wallpaperBlur:this.state.wallpaperBlur,systemColorSchema:this.state.systemColorSchema,sendOnEnter:this.state.sendOnEnter,onGlobalSettings:this.handleGlobalSettings,onSignUp:this.handleNewAccount,onSettings:this.handleSettings,onNavigate:this.basicNavigator,onLoginRequest:this.handleLoginRequest,onPersistenceChange:this.handlePersistenceChange,onCreateAccount:this.handleNewAccountRequest,onUpdateAccountDesc:this.handleTopicUpdateRequest,onUpdatePassword:this.handleUpdatePasswordRequest,onUpdateAccountTags:this.handleUpdateAccountTagsRequest,onTogglePushNotifications:this.toggleFCMToken,onToggleMessageSounds:this.handleToggleMessageSounds,onToggleIncognitoMode:this.handleToggleIncognitoMode,onChangeColorSchema:this.handleChangeColorSchema,onTextSizeChanged:this.handleChangeTextSize,onSendOnEnterChanged:this.handleSendOnEnter,onSelectWallpapers:this.handleSelectWallpapers,onWallpaperSelected:this.handleWallpaperSelected,onCredAdd:this.handleCredAdd,onCredDelete:this.handleCredDelete,onCredConfirm:this.handleCredConfirm,onTopicSelected:this.handleTopicSelected,onCreateTopic:this.handleStartTopicRequest,onLogout:this.handleLogout,onDeleteAccount:this.handleDeleteAccount,onShowAlert:this.handleShowAlert,onCancel:this.handleSidepanelCancel,onError:this.handleError,onValidateCredentials:this.handleValidateCredentialsRequest,onPasswordResetRequest:this.handlePasswordResetRequest,onResetPassword:this.handleResetPassword,onShowArchive:this.handleShowArchive,onShowBlocked:this.handleShowBlocked,onShowCountrySelector:this.handleShowCountrySelector,onInitFind:this.tnInitFind,searchResults:this.state.searchResults,onSearchContacts:this.handleSearchContacts,showContextMenu:this.handleShowContextMenu}),!this.state.displayMobile||"topic-view"==this.state.mobilePanel&&!this.state.infoPanel?(0,js.jsx)(r.Suspense,{fallback:(0,js.jsx)("div",{children:(0,js.jsx)(d.FormattedMessage,{id:"loading_note",defaultMessage:"Loading...",description:"Message shown when component is loading"})}),children:(0,js.jsx)(Ui,{tinode:this.tinode,connected:this.state.connected,ready:this.state.ready,online:this.state.topicSelectedOnline,acs:this.state.topicSelectedAcs,displayMobile:this.state.displayMobile,viewportWidth:this.state.viewportWidth,viewportHeight:this.state.viewportHeight,topic:this.state.topicSelected,myUserId:this.state.myUserId,myUserName:this.state.sidePanelTitle,serverVersion:this.state.serverVersion,serverAddress:this.state.serverAddress,applicationVisible:this.state.applicationVisible,colorSchema:e,sendOnEnter:this.state.sendOnEnter,wallpaper:this.state.wallpaper,forwardMessage:this.state.forwardMessage,onCancelForwardMessage:this.handleHideForwardDialog,callTopic:this.state.callTopic,callSeq:this.state.callSeq,callState:this.state.callState,callAudioOnly:this.state.callAudioOnly,onCallHangup:this.handleCallHangup,onAcceptCall:this.handleCallAccept,onCallInvite:this.handleCallInvite,onCallSendOffer:this.handleCallSendOffer,onCallIceCandidate:this.handleCallIceCandidate,onCallSendAnswer:this.handleCallSendAnswer,errorText:this.state.errorText,errorLevel:this.state.errorLevel,errorAction:this.state.errorAction,errorActionText:this.state.errorActionText,newTopicParams:this.state.newTopicParams,onHideMessagesView:this.handleHideMessagesView,onError:this.handleError,onNewTopicCreated:this.handleNewTopicCreated,showContextMenu:this.handleShowContextMenu,onChangePermissions:this.handleChangePermissions,onNewChat:this.handleNewChatInvitation,sendMessage:this.handleSendMessage,onVideoCallClosed:this.handleCallClose})}):null,this.state.infoPanel?(0,js.jsx)(r.Suspense,{fallback:(0,js.jsx)("div",{children:(0,js.jsx)(d.FormattedMessage,{id:"loading_note",defaultMessage:"Loading...",description:"Message shown when component is loading"})}),children:(0,js.jsx)(Fi,{tinode:this.tinode,connected:this.state.connected,displayMobile:this.state.displayMobile,topic:this.state.topicSelected,searchableContacts:this.state.searchableContacts,myUserId:this.state.myUserId,panel:this.state.infoPanel,errorText:this.state.errorText,errorLevel:this.state.errorLevel,errorAction:this.state.errorAction,errorActionText:this.state.errorActionText,onNavigate:this.infoNavigator,onTopicDescUpdateRequest:this.handleTopicUpdateRequest,onShowAlert:this.handleShowAlert,onChangePermissions:this.handleChangePermissions,onMemberUpdateRequest:this.handleMemberUpdateRequest,onDeleteTopic:this.handleDeleteTopicRequest,onDeleteMessages:this.handleDeleteMessagesRequest,onLeaveTopic:this.handleLeaveUnsubRequest,onBlockTopic:this.handleBlockTopicRequest,onReportTopic:this.handleReportTopic,onShareTheCard:this.handleShareTheCard,onTopicTagsUpdateRequest:this.handleTagsUpdateRequest,onTopicUnArchive:this.handleUnarchive,onInitFind:this.tnInitFind,onError:this.handleError,showContextMenu:this.handleShowContextMenu})}):null]})}}var Hi=(0,d.injectIntl)(Bi);if("undefined"!=typeof FIREBASE_INIT&&FIREBASE_INIT&&FIREBASE_INIT.measurementId){const Xi=document.getElementsByTagName("head")[0];let Ji=document.createElement("script");function Qi(){dataLayer.push(arguments)}Ji.src="https://www.googletagmanager.com/gtag/js?id="+FIREBASE_INIT.measurementId,Ji.async=!0,Xi.prepend(Ji),window.dataLayer=window.dataLayer||[],Qi("js",new Date),Qi("config",FIREBASE_INIT.measurementId)}const qi={ar:e=>o.e(143).then(o.t.bind(o,7143,19)),de:e=>o.e(175).then(o.t.bind(o,2175,19)),en:e=>o.e(399).then(o.t.bind(o,3399,19)),es:e=>o.e(64).then(o.t.bind(o,6064,19)),fr:e=>o.e(500).then(o.t.bind(o,2500,19)),it:e=>o.e(197).then(o.t.bind(o,7197,19)),ko:e=>o.e(186).then(o.t.bind(o,1186,19)),ro:e=>o.e(780).then(o.t.bind(o,8399,19)),ru:e=>o.e(553).then(o.t.bind(o,5553,19)),th:e=>o.e(536).then(o.t.bind(o,2536,19)),uk:e=>o.e(552).then(o.t.bind(o,4552,19)),vi:e=>o.e(297).then(o.t.bind(o,6297,19)),zh:e=>o.e(570).then(o.t.bind(o,570,19)),"zh-TW":e=>o.e(744).then(o.t.bind(o,5744,19))},{params:zi}=gi.A.parseUrlHash(window.location.hash),Vi=zi&&zi.hl||navigator.languages&&navigator.languages[0]||navigator.language||navigator.userLanguage||"en",Wi=Vi.replace("_","-"),Ki=Wi.split("-")[0].toLowerCase(),$i=qi[Wi]?Vi:qi[Ki]?Ki:"en",Gi=document.getElementsByTagName("html")[0];Gi.setAttribute("lang",$i),["ar","fa","he","ur"].includes(Ki)&&Gi.setAttribute("dir","rtl");const Yi=(0,c.H)(document.getElementById("mountPoint"));qi[$i]().then(e=>Yi.render(l().createElement(d.IntlProvider,{locale:Vi,messages:e,textComponent:l().Fragment},l().createElement(Hi,null))))}(); //# sourceMappingURL=index.prod.js.map