text: !function(n){var a={};function o(e){if(a[e])return a[e].exports;var t=a[e]={i:e,l:!1,exports:{}};return n[e].call(t.exports,t,t.exports,o),t.l=!0,t.exports}o.m=n,o.c=a,o.d=function(e,t,n){o.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(t,e){if(1&e&&(t=o(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var a in t)o.d(n,a,function(e){return t[e]}.bind(null,a));return n},o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,"a",t),t},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.p="",o(o.s=7)}([function(e,t){e.exports=React},function(e,t){e.exports=ReactIntl},function(t,e,n){(function(e){t.exports=function(){var v={exports:{}},p=[{name:"ST",start:/(?:^|\W)(\*)[^\s*]/,end:/[^\s*](\*)(?=$|\W)/},{name:"EM",start:/(?:^|[\W_])(_)[^\s_]/,end:/[^\s_](_)(?=$|[\W_])/},{name:"DL",start:/(?:^|\W)(~)[^\s~]/,end:/[^\s~](~)(?=$|\W)/},{name:"CO",start:/(?:^|\W)(`)[^`]/,end:/[^`](`)(?=$|\W)/}],h=[{name:"LN",dataName:"url",pack:function(e){return/^[a-z]+:\/\//i.test(e)||(e="http://"+e),{url:e}},re:/(?:(?:https?|ftp):\/\/|www\.|ftp\.)[-A-Z0-9+&@#\/%=~_|$?!:,.]*[A-Z0-9+&@#\/%=~_|$]/gi},{name:"MN",dataName:"val",pack:function(e){return{val:e.slice(1)}},re:/\B@(\w\w+)/g},{name:"HT",dataName:"val",pack:function(e){return{val:e.slice(1)}},re:/\B#(\w\w+)/g}],f={ST:{name:"b",isVoid:!1},EM:{name:"i",isVoid:!1},DL:{name:"del",isVoid:!1},CO:{name:"tt",isVoid:!1},BR:{name:"br",isVoid:!0},LN:{name:"a",isVoid:!1},MN:{name:"a",isVoid:!1},HT:{name:"a",isVoid:!1},IM:{name:"img",isVoid:!0},FM:{name:"div",isVoid:!1},RW:{name:"div",isVoid:!1},BN:{name:"button",isVoid:!1},HD:{name:"",isVoid:!1}};function a(e,t){var n;try{for(var a=(n=atob(e)).length,o=new ArrayBuffer(a),r=new Uint8Array(o),i=0;i<a;i++)r[i]=n.charCodeAt(i);return URL.createObjectURL(new Blob([o],{type:t}))}catch(e){console.log("Drafty: failed to convert object.",e.message)}return null}var m={ST:{open:function(){return"<b>"},close:function(){return"</b>"}},EM:{open:function(){return"<i>"},close:function(){return"</i>"}},DL:{open:function(){return"<del>"},close:function(){return"</del>"}},CO:{open:function(){return"<tt>"},close:function(){return"</tt>"}},BR:{open:function(){return"<br/>"},close:function(){return""}},HD:{open:function(){return""},close:function(){return""}},LN:{open:function(e){return'<a href="'+e.url+'">'},close:function(e){return"</a>"},props:function(e){return e?{href:e.url,target:"_blank"}:null}},MN:{open:function(e){return'<a href="#'+e.val+'">'},close:function(e){return"</a>"},props:function(e){return e?{name:e.val}:null}},HT:{open:function(e){return'<a href="#'+e.val+'">'},close:function(e){return"</a>"},props:function(e){return e?{name:e.val}:null}},BN:{open:function(e){return"<button>"},close:function(e){return"</button>"},props:function(e){return e?{"data-act":e.act,"data-val":e.val,"data-name":e.name,"data-ref":e.ref}:null}},IM:{open:function(e){var t=a(e.val,e.mime),n=e.ref?e.ref:t;return(e.name?'<a href="'+n+'" download="'+e.name+'">':"")+'<img src="'+t+'"'+(e.width?' width="'+e.width+'"':"")+(e.height?' height="'+e.height+'"':"")+' border="0" />'},close:function(e){return e.name?"</a>":""},props:function(e){return e?{src:a(e.val,e.mime),title:e.name,"data-width":e.width,"data-height":e.height,"data-name":e.name,"data-size":e.val?.75*e.val.length|0:0,"data-mime":e.mime}:null}},FM:{open:function(e){return"<div>"},close:function(e){return"</div>"}},RW:{open:function(e){return"<div>"},close:function(e){return"</div>"}}},l=function(){};l.parse=function(e){if("string"!=typeof e)return null;var t=e.split(/\r?\n/),c=[],u={},d=[];t.map(function(t){var e,n,a=[];if(p.map(function(e){a=a.concat(function(e,t,n,a){for(var o=[],r=0,i=e.slice(0);0<i.length;){var s=t.exec(i);if(null==s)break;var l=s.index+s[0].lastIndexOf(s[1]);i=i.slice(l+1),r=(l+=r)+1;var c=n?n.exec(i):null;if(null==c)break;var u=c.index+c[0].indexOf(c[1]);i=i.slice(u+1),r=(u+=r)+1,o.push({text:e.slice(l+1,u),children:[],start:l,end:u,type:a})}return o}(t,e.start,e.end,e.name))}),0==a.length)n={txt:t};else{a.sort(function(e,t){return e.start-t.start}),a=function e(t){if(0==t.length)return[];for(var n=[t[0]],a=t[0],o=1;o<t.length;o++)t[o].start>a.end?(n.push(t[o]),a=t[o]):t[o].end<a.end&&a.children.push(t[o]);for(var o in n)n[o].children=e(n[o].children);return n}(a);var o=function e(t,n){var a="",o=[];for(var r in t){var i=t[r];if(!i.text){var s=e(i.children,a.length+n);i.text=s.txt,o=o.concat(s.fmt)}i.type&&o.push({at:a.length+n,len:i.text.length,tp:i.type}),a+=i.text}return{txt:a,fmt:o}}(function e(t,n,a,o){var r=[];if(0==o.length)return[];for(var i in o){var s=o[i];s.start>n&&r.push({text:t.slice(n,s.start)});var l={type:s.type},c=e(t,s.start+1,s.end-1,s.children);0<c.length?l.children=c:l.text=s.text,r.push(l),n=s.end+1}return n<a&&r.push({text:t.slice(n,a)}),r}(t,0,t.length,a),0);n={txt:o.txt,fmt:o.fmt}}if(0<(e=function(t){var n,a=[];if(h.map(function(e){for(;null!==(n=e.re.exec(t));)a.push({offset:n.index,len:n[0].length,unique:n[0],data:e.pack(n[0]),type:e.name})}),0==a.length)return a;a.sort(function(e,t){return e.offset-t.offset});var o=-1;return a=a.filter(function(e){var t=e.offset>o;return o=e.offset+e.len,t})}(n.txt)).length){var r=[];for(var i in e){var s=e[i],l=u[s.unique];l||(l=c.length,u[s.unique]=l,c.push({tp:s.type,data:s.data})),r.push({at:s.offset,len:s.len,key:l})}n.ent=r}d.push(n)});var n={txt:""};if(0<d.length){n.txt=d[0].txt,n.fmt=(d[0].fmt||[]).concat(d[0].ent||[]);for(var a=1;a<d.length;a++){var o=d[a],r=n.txt.length+1;n.fmt.push({tp:"BR",len:1,at:r-1}),n.txt+=" "+o.txt,o.fmt&&(n.fmt=n.fmt.concat(o.fmt.map(function(e){return e.at+=r,e}))),o.ent&&(n.fmt=n.fmt.concat(o.ent.map(function(e){return e.at+=r,e})))}0==n.fmt.length&&delete n.fmt,0<c.length&&(n.ent=c)}return n},l.insertImage=function(e,t,n,a,o,r,i,s,l){return(e=e||{txt:" "}).ent=e.ent||[],e.fmt=e.fmt||[],e.fmt.push({at:t,len:1,key:e.ent.length}),e.ent.push({tp:"IM",data:{mime:n,val:a,width:o,height:r,name:i,ref:l,size:0|s}}),e},l.appendImage=function(e,t,n,a,o,r,i,s){return(e=e||{txt:""}).txt+=" ",l.insertImage(e,e.txt.length-1,t,n,a,o,r,i,s)},l.attachFile=function(e,t,n,a,o,r){(e=e||{txt:""}).ent=e.ent||[],e.fmt=e.fmt||[],e.fmt.push({at:-1,len:0,key:e.ent.length});var i={tp:"EX",data:{mime:t,val:n,name:a,ref:r,size:0|o}};return r instanceof Promise&&(i.data.ref=r.then(function(e){i.data.ref=e},function(e){})),e.ent.push(i),e},l.wrapAsForm=function(e,t,n){return"string"==typeof e&&(e={txt:e}),e.fmt=e.fmt||[],e.fmt.push({at:t,len:n,tp:"FM"}),e},l.insertButton=function(e,t,n,a,o,r,i){return"string"==typeof e&&(e={txt:e}),!e||!e.txt||e.txt.length<t+n?null:n<=0||-1==["url","pub"].indexOf(o)?null:"url"!=o||i?(i=""+i,e.ent=e.ent||[],e.fmt=e.fmt||[],e.fmt.push({at:t,len:n,key:e.ent.length}),e.ent.push({tp:"BN",data:{act:o,val:r,ref:i,name:a}}),e):null},l.appendButton=function(e,t,n,a,o,r){var i=(e=e||{txt:""}).txt.length;return e.txt+=t,l.insertButton(e,i,t.length,n,a,o,r)},l.attachJSON=function(e,t){return(e=e||{txt:""}).ent=e.ent||[],e.fmt=e.fmt||[],e.fmt.push({at:-1,len:0,key:e.ent.length}),e.ent.push({tp:"EX",data:{mime:"application/json",val:t}}),e},l.appendLineBreak=function(e){return(e=e||{txt:""}).fmt=e.fmt||[],e.fmt.push({at:e.txt.length,len:1,tp:"BR"}),e.txt+=" ",e},l.UNSAFE_toHTML=function(e){var t,n,a,o=e.txt,r=e.fmt,i=e.ent,s=[];if(r)for(var l in r){var c=r[l],u=c.tp,d=void 0;if(!u){var p=i[0|c.key];p&&(u=p.tp,d=p.data)}m[u]&&(s.push({idx:c.at+c.len,len:-c.len,what:m[u].close(d)}),s.push({idx:c.at,len:c.len,what:m[u].open(d)}))}for(var h in s.sort(function(e,t){return t.idx==e.idx?t.len-e.len:t.idx-e.idx}),s)s[h].what&&(t=o,n=s[h].idx,a=s[h].what,o=t.slice(0,n)+a+t.slice(n));return o},l.format=function(e,t,n){var a=e.txt,o=e.fmt,r=e.ent;if(a=a||"",Array.isArray(r)||(r=[]),!Array.isArray(o)){if(1!=r.length)return[a];o=[{at:0,len:0,key:0}]}var i=[].concat(o);return i.map(function(e){e.at=e.at||0,e.len=e.len||0,e.len<0&&(e.len=0),e.at<-1&&(e.at=-1)}),i.sort(function(e,t){return e.at-t.at==0?t.len-e.len:e.at-t.at}),i=i.map(function(e){var t,n=e.tp;return n||(e.key=e.key||0,r[e.key]&&(t=r[e.key].data,n=r[e.key].tp)),{tp:n=n||"HD",data:t,at:e.at,len:e.len}}),function e(t,n,a,o,r,i){for(var s=[],l=0;l<o.length;l++){var c=o[l];if(!(c.at<0)){n<c.at&&(s.push(r.call(i,null,void 0,t.slice(n,c.at),s.length)),n=c.at);for(var u=[],d=l+1;d<o.length&&o[d].at<c.at+c.len;d++)u.push(o[d]),l=d;var p=f[c.tp]||{};s.push(r.call(i,c.tp,c.data,p.isVoid?null:e(t,n,c.at+c.len,u,r,i),s.length)),n=c.at+c.len}}return n<a&&s.push(r.call(i,null,void 0,t.slice(n,a),s.length)),s}(a,0,a.length,i,t,n)},l.toPlainText=function(e){return"string"==typeof e?e:e.txt},l.isPlainText=function(e){return"string"==typeof e||!(e.fmt||e.ent)},l.hasAttachments=function(e){if(e.ent&&0<e.ent.length)for(var t in e.ent)if(e.ent[t]&&"EX"==e.ent[t].tp)return!0;return!1},l.attachments=function(e,t,n){if(e.ent&&0<e.ent.length)for(var a in e.ent)e.ent[a]&&"EX"==e.ent[a].tp&&t.call(n,e.ent[a].data,a)},l.getDownloadUrl=function(e){var t=null;return"application/json"!=e.mime&&e.val?t=a(e.val,e.mime):"string"==typeof e.ref&&(t=e.ref),t},l.isUploading=function(e){return e.ref instanceof Promise},l.getPreviewUrl=function(e){return e.val?a(e.val,e.mime):null},l.getEntitySize=function(e){return e.size?e.size:e.val?.75*e.val.length|0:0},l.getEntityMimeType=function(e){return e.mime||"text/plain"},l.tagName=function(e){return f[e]?f[e].name:void 0},l.attrValue=function(e,t){if(t&&m[e])return m[e].props(t)},l.getContentType=function(){return"text/x-drafty"},v.exports=l,v=v.exports;var y={exports:{}};return function(e){"use strict";function w(e){return(w="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var S,t="0.15.13";"undefined"!=typeof WebSocket&&(S=WebSocket),"undefined"==typeof btoa&&(e.btoa=function(){for(var e,t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"",n="",a=0,o=0,r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";t.charAt(0|o)||(r="=",o%1);n+=r.charAt(63&a>>8-o%1*8)){if(255<(e=t.charCodeAt(o+=.75)))throw new Error("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range.");a=a<<8|e}return n}),"undefined"==typeof atob&&(e.atob=function(){var e=(0<arguments.length&&void 0!==arguments[0]?arguments[0]:"").replace(/=+$/,""),t="";if(e.length%4==1)throw new Error("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,a=0,o=0,r=0;n=e.charAt(r++);~n&&(o=a%4?64*o+n:n,a++%4)?t+=String.fromCharCode(255&o>>(-2*a&6)):0)n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(n);return t}),"undefined"==typeof window&&(e.window={WebSocket:S,URL:{createObjectURL:function(){throw new Error("Unable to use window.URL in a non browser application")}}});var l="0",h=t||"0.15",f="tinodejs/"+h,E="Connection failed",k="Disconnected by client";function o(e){return btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,function(e,t){return String.fromCharCode("0x"+t)}))}function m(e,t,n){if("object"!=w(t)){if(t===c.DEL_CHAR)return;return void 0===t?e:t}if(null===t)return t;if(t instanceof Date)return e&&e instanceof Date&&!(e<t)?e:t;if(t instanceof u)return new u(t);if(t instanceof Array)return t;for(var a in e&&e!==c.DEL_CHAR||(e=t.constructor()),t)!t.hasOwnProperty(a)||n&&n[a]||"_noForwarding"==a||(e[a]=m(e[a],t[a]));return e}function s(e,t,n,a){return e[t]=m(e[t],n,a),e[t]}function M(){var e=null;if("withCredentials"in new XMLHttpRequest)e=new XMLHttpRequest;else{if("undefined"==typeof XDomainRequest)throw new Error("Browser not supported");e=new XDomainRequest}return e}function C(e,t){if("ts"===e&&"string"==typeof t&&20<=t.length&&t.length<=24){var n=new Date(t);if(n)return n}else if("acs"===e&&"object"===w(t))return new u(t);return t}function g(e,t){return"string"==typeof t&&128<t.length?"<"+t.length+", bytes: "+t.substring(0,12)+"..."+t.substring(t.length-12)+">":function(e,t){if(t instanceof Date)t=function(e){if(e&&0!=e.getTime()){var t=e.getUTCMilliseconds();return e.getUTCFullYear()+"-"+n(e.getUTCMonth()+1)+"-"+n(e.getUTCDate())+"T"+n(e.getUTCHours())+":"+n(e.getUTCMinutes())+":"+n(e.getUTCSeconds())+(t?"."+n(t,3):"")+"Z"}function n(e,t){return"0".repeat((t=t||2)-(""+e).length)+e}}(t);else if(null==t||!1===t||Array.isArray(t)&&0==t.length||"object"==w(t)&&0==Object.keys(t).length)return;return t}(0,t)}function T(e,t,n){var a=null;return"http"!==t&&"https"!==t&&"ws"!==t&&"wss"!==t||(a=t+"://","/"!==(a+=e).charAt(a.length-1)&&(a+="/"),a+="v"+l+"/channels","http"!==t&&"https"!==t||(a+="/lp"),a+="?apikey="+n),a}var b=function(e,t,n,a,o){var r=this,i=e,s=a,l=t,p=o,c=2e3,u=10,d=.3,h=null,f=0,m=!1,g=function(e){r.logger&&r.logger(e)};function b(){var t=this;clearTimeout(h);var n=c*(Math.pow(2,f)*(1+d*Math.random()));f=u<=f?f:f+1,this.onAutoreconnectIteration&&this.onAutoreconnectIteration(n),h=setTimeout(function(){if(g("Reconnecting, iter="+f+", timeout="+n),m)t.onAutoreconnectIteration&&t.onAutoreconnectIteration(-1);else{var e=t.connect();t.onAutoreconnectIteration?t.onAutoreconnectIteration(0,e):e.catch(function(){})}},n)}function v(){clearTimeout(h),h=null,f=0}function y(o){var r=null;o.connect=function(e){return m=!1,r&&r.readyState==r.OPEN?Promise.resolve():(e&&(i=e),new Promise(function(t,n){var e=T(i,s?"wss":"ws",l);g("Connecting to: "+e);var a=new S(e);a.onopen=function(e){o.onOpen&&o.onOpen(),t(),p&&v()},a.onclose=function(e){if(r=null,o.onDisconnect){var t=m?418:503;o.onDisconnect(new Error(m?k:E+" ("+t+")"),t)}!m&&p&&b.call(o)},a.onerror=function(e){n(e)},a.onmessage=function(e){o.onMessage&&o.onMessage(e.data)},r=a}))},o.reconnect=function(){v(),o.connect()},o.disconnect=function(){m=!0,r&&(v(),r.close(),r=null)},o.sendText=function(e){if(!r||r.readyState!=r.OPEN)throw new Error("Websocket is not connected");r.send(e)},o.isConnected=function(){return r&&r.readyState==r.OPEN},o.transport=function(){return"ws"},o.probe=function(){o.sendText("1")}}function _(u){var d=null,a=null,o=null;u.connect=function(e){return m=!1,a?Promise.resolve():(e&&(i=e),new Promise(function(e,t){var n=T(i,s?"https":"http",l);g("Connecting to: "+n),(a=function o(r,i,s){var l=M(),c=!1;return l.onreadystatechange=function(e){if(4==l.readyState)if(201==l.status){var t=JSON.parse(l.responseText,C);d=r+"&sid="+t.ctrl.params.sid,(l=o(d)).send(null),u.onOpen&&u.onOpen(),i&&(c=!0,i()),p&&v()}else if(l.status<400)u.onMessage&&u.onMessage(l.responseText),(l=o(d)).send(null);else{if(s&&!c&&(c=!0,s(l.responseText)),u.onMessage&&l.responseText&&u.onMessage(l.responseText),u.onDisconnect){var n=l.status||(m?418:503),a=l.responseText||(m?k:E);u.onDisconnect(new Error(a+" ("+n+")"),n)}l=null,!m&&p&&b.call(u)}},l.open("GET",r,!0),l}(n,e,t)).send(null)}).catch(function(){}))},u.reconnect=function(){v(),u.connect()},u.disconnect=function(){m=!0,v(),o&&(o.onreadystatechange=void 0,o.abort(),o=null),a&&(a.onreadystatechange=void 0,a.abort(),a=null),u.onDisconnect&&u.onDisconnect(new Error(k+" (418)"),418),d=null},u.sendText=function(e){var t,n;if(t=d,(n=M()).onreadystatechange=function(e){if(4==n.readyState&&400<=n.status)throw new Error("LP sender failed, "+n.status)},n.open("POST",t,!0),!(o=n)||1!=o.readyState)throw new Error("Long poller failed to connect");o.send(e)},u.isConnected=function(){return a&&!0},u.transport=function(){return"lp"},u.probe=function(){u.sendText("1")}}"lp"===n?_(this):"ws"===n?y(this):"object"==("undefined"==typeof window?"undefined":w(window))&&window.WebSocket?y(this):_(this),this.onMessage=void 0,this.onDisconnect=void 0,this.onOpen=void 0,this.onAutoreconnectIteration=void 0,this.logger=void 0},c=function(e,t,n,a,o,r){var l=this;this._appName=e||"Undefined",this._apiKey=n,this._browser="",this._platform=r,this._hwos="undefined",this._humanLanguage="xx","undefined"!=typeof navigator&&(this._browser=function(e,t){e=e||"";var n="";/reactnative/i.test(t)&&(n="ReactNative; ");var a,o=(e=e.replace(" (KHTML, like Gecko)","")).match(/(AppleWebKit\/[.\d]+)/i);if(o){for(var r=["chrome","safari","mobile","version"],i=e.substr(o.index+o[0].length).split(" "),s=[],l=function(e){var t=/([\w.]+)[\/]([\.\d]+)/.exec(i[e]);t&&s.push([t[1],t[2],r.findIndex(function(e){return e==t[1].toLowerCase()})])},c=0;c<i.length;c++)l(c);s.sort(function(e,t){var n=e[2]-t[2];return 0!=n?n:t[0].length-e[0].length}),a=0<s.length?s[0][0]+"/"+s[0][1]:o[1]}else a=/trident/i.test(e)?(o=/(?:\brv[ :]+([.\d]+))|(?:\bMSIE ([.\d]+))/g.exec(e))?"MSIE/"+(o[1]||o[2]):"MSIE/?":/firefox/i.test(e)?(o=/Firefox\/([.\d]+)/g.exec(e))?"Firefox/"+o[1]:"Firefox/?":/presto/i.test(e)?(o=/Opera\/([.\d]+)/g.exec(e))?"Opera/"+o[1]:"Opera/?":(o=/([\w.]+)\/([.\d]+)/.exec(e))?o[1]+"/"+o[2]:(o=e.split(" "))[0];if(1<(o=a.split("/")).length){var u=o[1].split(".");a=o[0]+"/"+u[0]+(u[1]?"."+u[1]:"")}return n+a}(navigator.userAgent,navigator.product),this._hwos=navigator.platform,this._humanLanguage=navigator.language||"en-US"),this._loggingEnabled=!1,this._trimLongStrings=!1,this._myUID=null,this._authenticated=!1,this._login=null,this._authToken=null,this._inPacketCount=0,this._messageId=Math.floor(65535*Math.random()+65535),this._serverInfo=null,this._deviceToken=null,this._pendingPromises={},this._connection=new b(t,n,a,o,!0),this.logger=function(e){if(l._loggingEnabled){var t=new Date,n=("0"+t.getUTCHours()).slice(-2)+":"+("0"+t.getUTCMinutes()).slice(-2)+":"+("0"+t.getUTCSeconds()).slice(-2)+":"+("0"+t.getUTCMilliseconds()).slice(-3);console.log("["+n+"] "+e)}},this._connection.logger=this.logger,this._cache={};var i=this.cachePut=function(e,t,n){l._cache[e+":"+t]=n},c=this.cacheGet=function(e,t){return l._cache[e+":"+t]},s=this.cacheDel=function(e,t){delete l._cache[e+":"+t]},u=this.cacheMap=function(e,t){for(var n in l._cache)if(e(l._cache[n],n,t))break};this.attachCacheToTopic=function(e){e._tinode=l,e._cacheGetUser=function(e){var t=c("user",e);if(t)return{user:e,public:m({},t)}},e._cachePutUser=function(e,t){return i("user",e,m({},t.public))},e._cacheDelUser=function(e){return s("user",e)},e._cachePutSelf=function(){return i("topic",e.name,e)},e._cacheDelSelf=function(){return s("topic",e.name)}};var d=function(e,t,n,a){var o=l._pendingPromises[e];o&&(delete l._pendingPromises[e],200<=t&&t<400?o.resolve&&o.resolve(n):o.reject&&o.reject(new Error("Error: "+a+" ("+t+")")))},p=this.getNextUniqueId=function(){return 0!=l._messageId?""+l._messageId++:void 0};this.initPacket=function(e,t){switch(e){case"hi":return{hi:{id:p(),ver:h,ua:l._appName+" ("+(l._browser?l._browser+"; ":"")+l._hwos+"); "+f,dev:l._deviceToken,lang:l._humanLanguage,platf:l._platform}};case"acc":return{acc:{id:p(),user:null,scheme:null,secret:null,login:!1,tags:null,desc:{},cred:{}}};case"login":return{login:{id:p(),scheme:null,secret:null}};case"sub":return{sub:{id:p(),topic:t,set:{},get:{}}};case"leave":return{leave:{id:p(),topic:t,unsub:!1}};case"pub":return{pub:{id:p(),topic:t,noecho:!1,head:null,content:{}}};case"get":return{get:{id:p(),topic:t,what:null,desc:{},sub:{},data:{}}};case"set":return{set:{id:p(),topic:t,desc:{},sub:{},tags:[]}};case"del":return{del:{id:p(),topic:t,what:null,delseq:null,user:null,hard:!1}};case"note":return{note:{topic:t,what:null,seq:void 0}};default:throw new Error("Unknown packet type requested: "+e)}},this.send=function(e,t){var n,a,o;t&&(o=null,(a=t)&&(o=new Promise(function(e,t){l._pendingPromises[a]={resolve:e,reject:t}})),n=o),e=function t(n){return Object.keys(n).forEach(function(e){"_"==e[0]?delete n[e]:n[e]?Array.isArray(n[e])&&0==n[e].length?delete n[e]:n[e]?"object"!=w(n[e])||n[e]instanceof Date||(t(n[e]),0==Object.getOwnPropertyNames(n[e]).length&&delete n[e]):delete n[e]:delete n[e]}),n}(e);var r=JSON.stringify(e);l.logger("out: "+(l._trimLongStrings?JSON.stringify(e,g):r));try{l._connection.sendText(r)}catch(e){if(!t)throw e;d(t,503,null,e.message)}return n},this.loginSuccessful=function(e){e.params&&e.params.user&&(l._myUID=e.params.user,l._authenticated=e&&200<=e.code&&e.code<300,e.params&&e.params.token&&e.params.expires?l._authToken={token:e.params.token,expires:new Date(e.params.expires)}:l._authToken=null,l.onLogin&&l.onLogin(e.code,e.text))},this._connection.onMessage=function(e){if(e)if(l._inPacketCount++,l.onRawMessage&&l.onRawMessage(e),"0"!==e){var t=JSON.parse(e,C);if(t)if(l.logger("in: "+(l._trimLongStrings?JSON.stringify(t,g):e)),l.onMessage&&l.onMessage(t),t.ctrl){if(l.onCtrlMessage&&l.onCtrlMessage(t.ctrl),t.ctrl.id&&d(t.ctrl.id,t.ctrl.code,t.ctrl,t.ctrl.text),205==t.ctrl.code&&"evicted"==t.ctrl.text){var n=c("topic",t.ctrl.topic);n&&n._resetSub()}else if(t.ctrl.params&&"data"==t.ctrl.params.what){var a=c("topic",t.ctrl.topic);a&&a._allMessagesReceived(t.ctrl.params.count)}}else if(t.meta){var o=c("topic",t.meta.topic);o&&o._routeMeta(t.meta),l.onMetaMessage&&l.onMetaMessage(t.meta)}else if(t.data){var r=c("topic",t.data.topic);r&&r._routeData(t.data),l.onDataMessage&&l.onDataMessage(t.data)}else if(t.pres){var i=c("topic",t.pres.topic);i&&i._routePres(t.pres),l.onPresMessage&&l.onPresMessage(t.pres)}else if(t.info){var s=c("topic",t.info.topic);s&&s._routeInfo(t.info),l.onInfoMessage&&l.onInfoMessage(t.info)}else l.logger("ERROR: Unknown packet received.");else l.logger("in: "+e),l.logger("ERROR: failed to parse data")}else l.onNetworkProbe&&l.onNetworkProbe()},this._connection.onOpen=function(){l.hello()},this._connection.onAutoreconnectIteration=function(e,t){l.onAutoreconnectIteration&&l.onAutoreconnectIteration(e,t)},this._connection.onDisconnect=function(e,t){for(var n in l._inPacketCount=0,l._serverInfo=null,l._authenticated=!1,u(function(e,t){0===t.lastIndexOf("topic:",0)&&e._resetSub()}),l._pendingPromises){var a=l._pendingPromises[n];a&&a.reject&&a.reject(e)}l._pendingPromises={},l.onDisconnect&&l.onDisconnect(e)}};c.credential=function(e,t,n,a){if("object"==w(e)){var o=e;t=o.val,n=o.params,a=o.resp,e=o.meth}return e&&(t||a)?[{meth:e,val:t,resp:a,params:n}]:null},c.topicType=function(e){return{me:"me",fnd:"fnd",grp:"grp",new:"grp",usr:"p2p"}["string"==typeof e?e.substring(0,3):"xxx"]},c.isNewGroupTopicName=function(e){return"string"==typeof e&&"new"==e.substring(0,3)},c.getVersion=function(){return h},c.setWebSocketProvider=function(e){S=e},c.getLibrary=function(){return f},c.MESSAGE_STATUS_NONE=0,c.MESSAGE_STATUS_QUEUED=1,c.MESSAGE_STATUS_SENDING=2,c.MESSAGE_STATUS_FAILED=3,c.MESSAGE_STATUS_SENT=4,c.MESSAGE_STATUS_RECEIVED=5,c.MESSAGE_STATUS_READ=6,c.MESSAGE_STATUS_TO_ME=7,c.DEL_CHAR="␡",c.prototype={connect:function(e){return this._connection.connect(e)},reconnect:function(){this._connection.reconnect()},disconnect:function(){this._connection.disconnect()},networkProbe:function(){this._connection.probe()},isConnected:function(){return this._connection.isConnected()},isAuthenticated:function(){return this._authenticated},account:function(e,t,n,a,o){var r=this.initPacket("acc");return r.acc.user=e,r.acc.scheme=t,r.acc.secret=n,r.acc.login=a,o&&(r.acc.desc.defacs=o.defacs,r.acc.desc.public=o.public,r.acc.desc.private=o.private,r.acc.tags=o.tags,r.acc.cred=o.cred,r.acc.token=o.token),this.send(r,r.acc.id)},createAccount:function(e,t,n,a){var o=this,r=this.account("new",e,t,n,a);return n&&(r=r.then(function(e){return o.loginSuccessful(e),e})),r},createAccountBasic:function(e,t,n){return e=e||"",t=t||"",this.createAccount("basic",o(e+":"+t),!0,n)},updateAccountBasic:function(e,t,n,a){return t=t||"",n=n||"",this.account(e,"basic",o(t+":"+n),!1,a)},hello:function(){var t=this,e=this.initPacket("hi");return this.send(e,e.hi.id).then(function(e){return e.params&&(t._serverInfo=e.params),t.onConnect&&t.onConnect(),e}).catch(function(e){t.onDisconnect&&t.onDisconnect(e)})},setDeviceToken:function(e,t){var n=!1;return e&&e!=this._deviceToken&&(this._deviceToken=e,t&&this.isConnected()&&this.isAuthenticated()&&(this.send({hi:{dev:e}}),n=!0)),n},login:function(e,t,n){var a=this,o=this.initPacket("login");return o.login.scheme=e,o.login.secret=t,o.login.cred=n,this.send(o,o.login.id).then(function(e){return a.loginSuccessful(e),e})},loginBasic:function(t,e,n){var a=this;return this.login("basic",o(t+":"+e),n).then(function(e){return a._login=t,e})},loginToken:function(e,t){return this.login("token",e,t)},requestResetAuthSecret:function(e,t,n){return this.login("reset",o(e+":"+t+":"+n))},getAuthToken:function(){return this._authToken&&this._authToken.expires.getTime()>Date.now()?this._authToken:this._authToken=null},setAuthToken:function(e){this._authToken=e},subscribe:function(e,t,n){var a=this.initPacket("sub",e);return e||(e="new"),a.sub.get=t,n&&(n.sub&&(a.sub.set.sub=n.sub),n.desc&&(c.isNewGroupTopicName(e)?a.sub.set.desc=n.desc:"p2p"==c.topicType(e)&&n.desc.defacs&&(a.sub.set.desc={defacs:n.desc.defacs})),n.tags&&(a.sub.set.tags=n.tags)),this.send(a,a.sub.id)},leave:function(e,t){var n=this.initPacket("leave",e);return n.leave.unsub=t,this.send(n,n.leave.id)},createMessage:function(e,t,n){var a=this.initPacket("pub",e),o="string"==typeof t?v.parse(t):t;return o&&!v.isPlainText(o)&&(a.pub.head={mime:v.getContentType()},t=o),a.pub.noecho=n,a.pub.content=t,a.pub},publish:function(e,t,n){return this.publishMessage(this.createMessage(e,t,n))},publishMessage:function(e){return(e=Object.assign({},e)).seq=void 0,e.from=void 0,e.ts=void 0,this.send({pub:e},e.id)},getMeta:function(e,t){var n=this.initPacket("get",e);return n.get=m(n.get,t),this.send(n,n.get.id)},setMeta:function(e,t){var n=this.initPacket("set",e),a=[];return t&&["desc","sub","tags"].map(function(e){t.hasOwnProperty(e)&&(a.push(e),n.set[e]=t[e])}),0==a.length?Promise.reject(new Error("Invalid {set} parameters")):this.send(n,n.set.id)},delMessages:function(e,t,n){var a=this.initPacket("del",e);return a.del.what="msg",a.del.delseq=t,a.del.hard=n,this.send(a,a.del.id)},delTopic:function(t){var n=this,e=this.initPacket("del",t);return e.del.what="topic",this.send(e,e.del.id).then(function(e){return n.cacheDel("topic",t),n.ctrl})},delSubscription:function(e,t){var n=this.initPacket("del",e);return n.del.what="sub",n.del.user=t,this.send(n,n.del.id)},note:function(e,t,n){if(n<=0||268435455<=n)throw new Error("Invalid message id "+n);var a=this.initPacket("note",e);a.note.what=t,a.note.seq=n,this.send(a)},noteKeyPress:function(e){var t=this.initPacket("note",e);t.note.what="kp",this.send(t)},getTopic:function(e){var t=this.cacheGet("topic",e);return!t&&e&&(t="me"==e?new r:"fnd"==e?new i:new a(e),this.cachePut("topic",e,t),this.attachCacheToTopic(t)),t},newTopic:function(e){var t=new a("new",e);return this.attachCacheToTopic(t),t},newGroupTopicName:function(){return"new"+this.getNextUniqueId()},newTopicWith:function(e,t){var n=new a(e,t);return this.attachCacheToTopic(n),n},getMeTopic:function(){return this.getTopic("me")},getFndTopic:function(){return this.getTopic("fnd")},getLargeFileHelper:function(){return new d(this)},getCurrentUserID:function(){return this._myUID},isMe:function(e){return this._myUID===e},getCurrentLogin:function(){return this._login},getServerInfo:function(){return this._serverInfo},enableLogging:function(e,t){this._loggingEnabled=e,this._trimLongStrings=e&&t},isTopicOnline:function(e){var t=this.getMeTopic(),n=t&&t.getContact(e);return n&&n.online},wantAkn:function(e){this._messageId=e?Math.floor(16777215*Math.random()+16777215):0},onWebsocketOpen:void 0,onConnect:void 0,onDisconnect:void 0,onLogin:void 0,onCtrlMessage:void 0,onDataMessage:void 0,onPresMessage:void 0,onMessage:void 0,onRawMessage:void 0,onNetworkProbe:void 0,onAutoreconnectIteration:void 0};var n=function(e){var t=(this.topic=e)._tinode.getMeTopic();this.contact=t&&t.getContact(e.name),this.what={}};n.prototype={_get_ims:function(){var e=this.contact&&this.contact.updated,t=this.topic._lastDescUpdate||0;return t<e?e:t},withData:function(e,t,n){return this.what.data={since:e,before:t,limit:n},this},withLaterData:function(e){return this.withData(0<this.topic._maxSeq?this.topic._maxSeq+1:void 0,void 0,e)},withEarlierData:function(e){return this.withData(void 0,0<this.topic._minSeq?this.topic._minSeq:void 0,e)},withDesc:function(e){return this.what.desc={ims:e},this},withLaterDesc:function(){return this.withDesc(this._get_ims())},withSub:function(e,t,n){var a={ims:e,limit:t};return"me"==this.topic.getType()?a.topic=n:a.user=n,this.what.sub=a,this},withOneSub:function(e,t){return this.withSub(e,void 0,t)},withLaterOneSub:function(e){return this.withOneSub(this.topic._lastSubsUpdate,e)},withLaterSub:function(e){return this.withSub("p2p"==this.topic.getType()?this._get_ims():this.topic._lastSubsUpdate,e)},withTags:function(){return this.what.tags=!0,this},withDel:function(e,t){return(e||t)&&(this.what.del={since:e,limit:t}),this},withLaterDel:function(e){return this.withDel(0<this.topic._maxSeq?this.topic._maxDel+1:void 0,e)},build:function(){var t=[],n=this,a={};return["data","sub","desc","tags","del"].map(function(e){n.what.hasOwnProperty(e)&&(t.push(e),0<Object.getOwnPropertyNames(n.what[e]).length&&(a[e]=n.what[e]))}),0<t.length?a.what=t.join(" "):a=void 0,a}};var u=function e(t){t&&(this.given="number"==typeof t.given?t.given:e.decode(t.given),this.want="number"==typeof t.want?t.want:e.decode(t.want),this.mode=t.mode?"number"==typeof t.mode?t.mode:e.decode(t.mode):this.given&this.want)};u._NONE=0,u._JOIN=1,u._READ=2,u._WRITE=4,u._PRES=8,u._APPROVE=16,u._SHARE=32,u._DELETE=64,u._OWNER=128,u._BITMASK=u._JOIN|u._READ|u._WRITE|u._PRES|u._APPROVE|u._SHARE|u._DELETE|u._OWNER,u._INVALID=1048576,u._checkFlag=function(e,t,n){if(["given","want","mode"].includes(t=t||"mode"))return 0!=(e[t]&n);throw new Error("Invalid AccessMode component '"+t+"'")},u.decode=function(e){if(!e)return null;if("number"==typeof e)return e&u._BITMASK;if("N"===e||"n"===e)return u._NONE;for(var t={J:u._JOIN,R:u._READ,W:u._WRITE,P:u._PRES,A:u._APPROVE,S:u._SHARE,D:u._DELETE,O:u._OWNER},n=u._NONE,a=0;a<e.length;a++){var o=t[e.charAt(a).toUpperCase()];o&&(n|=o)}return n},u.encode=function(e){if(null===e||e===u._INVALID)return null;if(e===u._NONE)return"N";for(var t=["J","R","W","P","A","S","D","O"],n="",a=0;a<t.length;a++)0!=(e&1<<a)&&(n+=t[a]);return n},u.update=function(e,t){if(!t||"string"!=typeof t)return e;var n=t.charAt(0);if("+"==n||"-"==n){for(var a=e,o=t.split(/([-+])/),r=1;r<o.length-1;r+=2){n=o[r];var i=u.decode(o[r+1]);if(i==u._INVALID)return e;null!=i&&("+"===n?a|=i:"-"===n&&(a&=~i))}e=a}else{var s=u.decode(t);s!=u._INVALID&&(e=s)}return e},u.prototype={toString:function(){return'{mode: "'+u.encode(this.mode)+'", given: "'+u.encode(this.given)+'", want: "'+u.encode(this.want)+'"}'},setMode:function(e){return this.mode=u.decode(e),this},updateMode:function(e){return this.mode=u.update(this.mode,e),this},getMode:function(){return u.encode(this.mode)},setGiven:function(e){return this.given=u.decode(e),this},updateGiven:function(e){return this.given=u.update(this.given,e),this},getGiven:function(){return u.encode(this.given)},setWant:function(e){return this.want=u.decode(e),this},updateWant:function(e){return this.want=u.update(this.want,e),this},getWant:function(){return u.encode(this.want)},getMissing:function(){return u.encode(this.want&~this.given)},getExcessive:function(){return u.encode(this.given&~this.want)},updateAll:function(e){return e&&(this.updateGiven(e.given),this.updateWant(e.want),this.mode=this.given&this.want),this},isOwner:function(e){return u._checkFlag(this,e,u._OWNER)},isPresencer:function(e){return u._checkFlag(this,e,u._PRES)},isMuted:function(e){return!this.isPresencer(e)},isJoiner:function(e){return u._checkFlag(this,e,u._JOIN)},isReader:function(e){return u._checkFlag(this,e,u._READ)},isWriter:function(e){return u._checkFlag(this,e,u._WRITE)},isApprover:function(e){return u._checkFlag(this,e,u._APPROVE)},isAdmin:function(e){return this.isOwner(e)||this.isApprover(e)},isSharer:function(e){return this.isAdmin(e)||u._checkFlag(this,e,u._SHARE)},isDeleter:function(e){return u._checkFlag(this,e,u._DELETE)}};var a=function(e,t){this._tinode=null,this.name=e,this.created=null,this.updated=null,this.touched=null,this.acs=new u(null),this.private=null,this.public=null,this._users={},this._queuedSeqId=268435455,this._maxSeq=0,this._minSeq=0,this._noEarlierMsgs=!1,this._maxDel=0,this._tags=[],this._messages=function(l){var r=[];function o(e,t,n){for(var a=0,o=t.length-1,r=0,i=0,s=!1;a<=o;)if((i=l(t[r=(a+o)/2|0],e))<0)a=r+1;else{if(!(0<i)){s=!0;break}o=r-1}return s?r:n?-1:i<0?r+1:r}return l=l||function(e,t){return e===t?0:e<t?-1:1},{getAt:function(e){return r[e]},put:function(){var e,t,n;for(var a in e=1==arguments.length&&Array.isArray(arguments[0])?arguments[0]:arguments)t=e[a],(n=r).splice(o(t,n,!1),0,t)},delAt:function(e){var t=r.splice(e,1);if(t&&0<t.length)return t[0]},delRange:function(e,t){return r.splice(e,t-e)},size:function(){return r.length},reset:function(e){r=[]},forEach:function(e,t,n,a){t|=0,n=n||r.length;for(var o=t;o<n;o++)e.call(a,r[o],o)},find:function(e,t){return o(e,r,!t)}}}(function(e,t){return e.seq-t.seq}),this._subscribed=!1,this._lastDescUpdate=null,this._lastSubsUpdate=null,this._new=!0,t&&(this.onData=t.onData,this.onMeta=t.onMeta,this.onPres=t.onPres,this.onInfo=t.onInfo,this.onMetaDesc=t.onMetaDesc,this.onMetaSub=t.onMetaSub,this.onSubsUpdated=t.onSubsUpdated,this.onTagsUpdated=t.onTagsUpdated,this.onDeleteTopic=t.onDeleteTopic,this.onAllMessagesReceived=t.onAllMessagesReceived)};a.prototype={isSubscribed:function(){return this._subscribed},subscribe:function(e,n){var a=this;return this._subscribed?Promise.resolve(this):this._tinode.subscribe(this.name||"new",e,n).then(function(e){if(300<=e.code)return e;if(a._subscribed=!0,a.acs=e.params&&e.params.acs?e.params.acs:a.acs,a._new){a._new=!1,a.name=e.topic,a.created=e.ts,a.updated=e.ts,a._cachePutSelf();var t=a._tinode.getMeTopic();t&&t._processMetaSub([{_noForwarding:!0,topic:a.name,created:e.ts,updated:e.ts,acs:a.acs}]),n&&n.desc&&(n.desc._noForwarding=!0,a._processMetaDesc(n.desc))}return e})},createMessage:function(e,t){return this._tinode.createMessage(this.name,e,t)},publish:function(e,t){return this.publishMessage(this.createMessage(e,t))},publishMessage:function(t){var n=this;if(!this._subscribed)return Promise.reject(new Error("Cannot publish on inactive topic"));if(v.hasAttachments(t.content)&&!t.head.attachments){var a=[];v.attachments(t.content,function(e){a.push(e.ref)}),t.head.attachments=a}return t._sending=!0,t._failed=!1,this._tinode.publishMessage(t).then(function(e){return t._sending=!1,t.seq=e.params.seq,t.ts=e.ts,n._routeData(t),e}).catch(function(e){console.log("Message rejected by the server",e),t._sending=!1,t._failed=!0,n.onData&&n.onData()})},publishDraft:function(t,e){var n=this;if(!e&&!this._subscribed)return Promise.reject(new Error("Cannot publish on inactive topic"));var a=t.seq||this._getQueuedSeqId();return t._noForwarding||(t._noForwarding=!0,t.seq=a,t.ts=new Date,t.from=this._tinode.getCurrentUserID(),t.noecho=!0,this._messages.put(t),this.onData&&this.onData(t)),(e||Promise.resolve()).then(function(){return t._cancelled?{code:300,text:"cancelled"}:n.publishMessage(t)},function(e){console.log("Message draft rejected by the server",e),t._sending=!1,t._failed=!0,n._messages.delAt(n._messages.find(t)),n.onData&&n.onData()})},leave:function(t){var n=this;return this._subscribed||t?this._tinode.leave(this.name,t).then(function(e){return n._resetSub(),t&&n._gone(),e}):Promise.reject(new Error("Cannot leave inactive topic"))},getMeta:function(e){return this._tinode.getMeta(this.name,e)},getMessagesPage:function(e,t){var n=this,a=this.startMetaQuery();t?a.withLaterData(e):a.withEarlierData(e);var o=this.getMeta(a.build());return t||(o=o.then(function(e){e&&e.params&&!e.params.count&&(n._noEarlierMsgs=!0)})),o},setMeta:function(t){var n=this;return t.tags&&(t.tags=function(e){var t=[];if(Array.isArray(e)){for(var n=0,a=e.length;n<a;n++){var o=e[n];o&&1<(o=o.trim().toLowerCase()).length&&t.push(o)}t.sort().filter(function(e,t,n){return!t||e!=n[t-1]})}return 0==t.length&&t.push(c.DEL_CHAR),t}(t.tags)),this._tinode.setMeta(this.name,t).then(function(e){return e&&300<=e.code||(t.sub&&(e.params&&e.params.acs&&(t.sub.acs=e.params.acs,t.sub.updated=e.ts),t.sub.user||(t.sub.user=n._tinode.getCurrentUserID(),t.desc||(t.desc={})),t.sub._noForwarding=!0,n._processMetaSub([t.sub])),t.desc&&(e.params&&e.params.acs&&(t.desc.acs=e.params.acs,t.desc.updated=e.ts),n._processMetaDesc(t.desc)),t.tags&&n._processMetaTags(t.tags)),e})},invite:function(e,t){return this.setMeta({sub:{user:e,mode:t}})},archive:function(e){return this.private&&this.private.arch==e?Promise.resolve(e):this.setMeta({desc:{private:{arch:!!e||c.DEL_CHAR}}})},delMessages:function(t,e){var n=this;if(!this._subscribed)return Promise.reject(new Error("Cannot delete messages in inactive topic"));t.sort(function(e,t){return e.low<t.low||e.low==t.low&&(!t.hi||e.hi>=t.hi)});var a=t.reduce(function(e,t){return t.low<268435455&&(!t.hi||t.hi<268435455?e.push(t):e.push({low:t.low,hi:n._maxSeq+1})),e},[]);return(0<a.length?this._tinode.delMessages(this.name,a,e):Promise.resolve({params:{del:0}})).then(function(e){return e.params.del>n._maxDel&&(n._maxDel=e.params.del),t.map(function(e){e.hi?n.flushMessageRange(e.low,e.hi):n.flushMessage(e.low)}),n.onData&&n.onData(),e})},delMessagesAll:function(e){return this.delMessages([{low:1,hi:this._maxSeq+1,_all:!0}],e)},delMessagesList:function(e,t){e.sort(function(e,t){return e-t});var n=e.reduce(function(e,t){if(0==e.length)e.push({low:t});else{var n=e[e.length-1];!n.hi&&t!=n.low+1||t>n.hi?e.push({low:t}):n.hi=n.hi?Math.max(n.hi,t+1):t+1}return e},[]);return this.delMessages(n,t)},delTopic:function(){var t=this;return this._tinode.delTopic(this.name).then(function(e){return t._resetSub(),t._gone(),e})},delSubscription:function(t){var n=this;return this._subscribed?this._tinode.delSubscription(this.name,t).then(function(e){return delete n._users[t],n.onSubsUpdated&&n.onSubsUpdated(Object.keys(n._users)),e}):Promise.reject(new Error("Cannot delete subscription in inactive topic"))},note:function(e,t){var n=this._users[this._tinode.getCurrentUserID()];n?(!n[e]||n[e]<t)&&(this._subscribed?this._tinode.note(this.name,e,t):this._tinode.logger("Not sending {note} on inactive topic"),n[e]=t):this._tinode.logger("note(): user not found "+this._tinode.getCurrentUserID());var a=this._tinode.getMeTopic();a&&a.setMsgReadRecv(this.name,e,t)},noteRecv:function(e){this.note("recv",e)},noteRead:function(e){this.note("read",e)},noteKeyPress:function(){this._subscribed?this._tinode.noteKeyPress(this.name):this._tinode.logger("Cannot send notification in inactive topic")},userDesc:function(e){var t=this._cacheGetUser(e);if(t)return t},p2pPeerDesc:function(){if("p2p"==this.getType())return this._users[this.name]},subscribers:function(e,t){var n=e||this.onMetaSub;if(n)for(var a in this._users)n.call(t,this._users[a],a,this._users)},tags:function(){return this._tags.slice(0)},subscriber:function(e){return this._users[e]},messages:function(e,t,n,a){var o=e||this.onData;if(o){var r="number"==typeof t?this._messages.find({seq:t}):void 0,i="number"==typeof n?this._messages.find({seq:n},!0):void 0;-1!=r&&-1!=i&&this._messages.forEach(o,r,i,a)}},queuedMessages:function(e,t){if(!e)throw new Error("Callback must be provided");this.messages(e,268435455,void 0,t)},msgReceiptCount:function(e,t){var n=0;if(0<t){var a=this._tinode.getCurrentUserID();for(var o in this._users){var r=this._users[o];r.user!==a&&r[e]>=t&&n++}}return n},msgReadCount:function(e){return this.msgReceiptCount("read",e)},msgRecvCount:function(e){return this.msgReceiptCount("recv",e)},msgHasMoreMessages:function(e){return e?this.seq>this._maxSeq:1<this._minSeq&&!this._noEarlierMsgs},isNewMessage:function(e){return this._maxSeq<=e},flushMessage:function(e){var t=this._messages.find({seq:e});return 0<=t?this._messages.delAt(t):void 0},flushMessageRange:function(e,t){var n=this._messages.find({seq:e});return 0<=n?this._messages.delRange(n,this._messages.find({seq:t},!0)):[]},cancelSend:function(e){var t=this._messages.find({seq:e});if(0<=t){var n=this._messages.getAt(t),a=this.msgStatus(n);if(1==a||3==a)return n._cancelled=!0,this._messages.delAt(t),this.onData&&this.onData(),!0}return!1},getType:function(){return c.topicType(this.name)},getAccessMode:function(){return this.acs},getDefaultAccess:function(){return this.defacs},startMetaQuery:function(){return new n(this)},isArchived:function(){return!(!this.private||!this.private.arch)},msgStatus:function(e){var t=0;return this._tinode.isMe(e.from)?e._sending?t=2:e._failed?t=3:268435455<=e.seq?t=1:0<this.msgReadCount(e.seq)?t=6:0<this.msgRecvCount(e.seq)?t=5:0<e.seq&&(t=4):t=7,t},_routeData:function(e){e.content&&((!this.touched||this.touched<e.ts)&&(this.touched=e.ts),e._noForwarding||this._messages.put(e)),e.seq>this._maxSeq&&(this._maxSeq=e.seq),(e.seq<this._minSeq||0==this._minSeq)&&(this._minSeq=e.seq),this.onData&&this.onData(e);var t=this._tinode.getMeTopic();t&&t.setMsgReadRecv(this.name,this._tinode.isMe(e.from)?"read":"msg",e.seq,e.ts)},_routeMeta:function(e){e.desc&&(this._lastDescUpdate=e.ts,this._processMetaDesc(e.desc)),e.sub&&0<e.sub.length&&(this._lastSubsUpdate=e.ts,this._processMetaSub(e.sub)),e.del&&this._processDelMessages(e.del.clear,e.del.delseq),e.tags&&this._processMetaTags(e.tags),this.onMeta&&this.onMeta(e)},_routePres:function(e){var t;switch(e.what){case"del":this._processDelMessages(e.clear,e.delseq);break;case"on":case"off":(t=this._users[e.src])?t.online="on"==e.what:this._tinode.logger("Presence update for an unknown user",this.name,e.src);break;case"acs":if(t=this._users[e.src])t.acs.updateAll(e.dacs),this._processMetaSub([{user:e.src,updated:new Date,acs:t.acs}]);else{var n=(new u).updateAll(e.dacs);n&&n.mode!=u._NONE&&((t=this._cacheGetUser(e.src))?t.acs=n:(t={user:e.src,acs:n},this.getMeta(this.startMetaQuery().withOneSub(void 0,e.src).build())),t.updated=new Date,this._processMetaSub([t]))}break;default:this._tinode.logger("Ignored presence update",e.what)}this.onPres&&this.onPres(e)},_routeInfo:function(e){if("kp"!==e.what){var t=this._users[e.from];if(t&&(t[e.what]=e.seq,t.recv<t.read&&(t.recv=t.read)),this._tinode.isMe(e.from)){var n=this._tinode.getMeTopic();n&&n.setMsgReadRecv(e.topic,e.what,e.seq)}}this.onInfo&&this.onInfo(e)},_processMetaDesc:function(e){if("p2p"==this.getType()&&delete e.defacs,m(this,e),"string"==typeof this.created&&(this.created=new Date(this.created)),"string"==typeof this.updated&&(this.updated=new Date(this.updated)),"string"==typeof this.touched&&(this.touched=new Date(this.touched)),"me"!==this.name&&!e._noForwarding){var t=this._tinode.getMeTopic();t&&t._processMetaSub([{_noForwarding:!0,topic:this.name,updated:this.updated,touched:this.touched,acs:e.acs,public:e.public,private:e.private}])}this.onMetaDesc&&this.onMetaDesc(this)},_processMetaSub:function(e){for(var t in e){var n=e[t];n.updated=new Date(n.updated),n.deleted=n.deleted?new Date(n.deleted):null;var a=null;a=n.deleted?(delete this._users[n.user],n):(this._tinode.isMe(n.user)&&n.acs&&this._processMetaDesc({updated:n.updated||new Date,touched:n.updated,acs:n.acs}),this._updateCachedUser(n.user,n)),this.onMetaSub&&this.onMetaSub(a)}this.onSubsUpdated&&this.onSubsUpdated(Object.keys(this._users))},_processMetaTags:function(e){1==e.length&&e[0]==c.DEL_CHAR&&(e=[]),this._tags=e,this.onTagsUpdated&&this.onTagsUpdated(e)},_processDelMessages:function(e,t){this._maxDel=Math.max(e,this._maxDel),this.clear=Math.max(e,this.clear);var n=this,a=0;Array.isArray(t)&&t.map(function(e){if(e.hi)for(var t=e.low;t<e.hi;t++)a++,n.flushMessage(t);else a++,n.flushMessage(e.low)}),0<a&&this.onData&&this.onData()},_allMessagesReceived:function(e){this.onAllMessagesReceived&&this.onAllMessagesReceived(e)},_resetSub:function(){this._subscribed=!1},_gone:function(){this._messages.reset(),this._users={},this.acs=new u(null),this.private=null,this.public=null,this._maxSeq=0,this._minSeq=0,this._subscribed=!1;var e=this._tinode.getMeTopic();e&&e._routePres({_noForwarding:!0,what:"gone",topic:"me",src:this.name}),this.onDeleteTopic&&this.onDeleteTopic()},_updateCachedUser:function(e,t){var n=this._cacheGetUser(e);return n=m(n||{},t),this._cachePutUser(e,n),s(this._users,e,n)},_getQueuedSeqId:function(){return this._queuedSeqId++}};var r=function(e){a.call(this,"me",e),this._contacts={},e&&(this.onContactUpdate=e.onContactUpdate)};r.prototype=Object.create(a.prototype,{_processMetaSub:{value:function(e){var t=0;for(var n in e){var a=e[n],o=a.topic;if("fnd"!=o&&"me"!=o){a.updated=new Date(a.updated),a.touched=a.touched?new Date(a.touched):void 0,a.deleted=a.deleted?new Date(a.deleted):null;var r=null;if(a.deleted)r=a,delete this._contacts[o];else if(a.acs&&!a.acs.isJoiner())(r=a).deleted=new Date,delete this._contacts[o];else if(void 0!==a.seq&&(a.seq=0|a.seq,a.recv=0|a.recv,a.read=0|a.read,a.unread=a.seq-a.read),a.seen&&a.seen.when&&(a.seen.when=new Date(a.seen.when)),r=s(this._contacts,o,a),"p2p"==c.topicType(o)&&this._cachePutUser(o,r),!a._noForwarding){var i=this._tinode.getTopic(o);i&&(a._noForwarding=!0,i._processMetaDesc(a))}t++,this.onMetaSub&&this.onMetaSub(r)}}0<t&&this.onSubsUpdated&&this.onSubsUpdated(Object.keys(this._contacts))},enumerable:!0,configurable:!0,writable:!1},_routePres:{value:function(e){var t=this._contacts[e.src];if(t){switch(e.what){case"on":t.online=!0;break;case"off":t.online&&(t.online=!1,t.seen?t.seen.when=new Date:t.seen={when:new Date});break;case"msg":t.touched=new Date,t.seq=0|e.seq,t.unread=t.seq-t.read;break;case"upd":this.getMeta(this.startMetaQuery().withLaterOneSub(e.src).build());break;case"acs":t.acs?t.acs.updateAll(e.dacs):t.acs=(new u).updateAll(e.dacs),t.touched=new Date;break;case"ua":t.seen={when:new Date,ua:e.ua};break;case"recv":t.recv=t.recv?Math.max(t.recv,e.seq):0|e.seq;break;case"read":t.read=t.read?Math.max(t.read,e.seq):0|e.seq,t.unread=t.seq-t.read;break;case"gone":delete this._contacts[e.src]}this.onContactUpdate&&this.onContactUpdate(e.what,t)}else if("acs"==e.what){var n=new u(e.dacs);if(!n||n.mode==u._INVALID)return void this._tinode.logger("Invalid access mode update",e.src,e.dacs);if(n.mode==u._NONE)return void this._tinode.logger("Removing non-existent subscription",e.src,e.dacs);this.getMeta(this.startMetaQuery().withOneSub(void 0,e.src).build()),this._contacts[e.src]={touched:new Date,topic:e.src,online:!1,acs:n}}this.onPres&&this.onPres(e)},enumerable:!0,configurable:!0,writable:!1},publish:{value:function(){return Promise.reject(new Error("Publishing to 'me' is not supported"))},enumerable:!0,configurable:!0,writable:!1},contacts:{value:function(e,t,n){var a=e||this.onMetaSub;if(a)for(var o in this._contacts)(t||this._contacts[o]&&this._contacts[o].acs&&this._contacts[o].acs.isJoiner())&&a.call(n,this._contacts[o],o,this._contacts)},enumerable:!0,configurable:!0,writable:!0},setMsgReadRecv:{value:function(e,t,n,a){var o,r=this._contacts[e],i=!1;if(r){switch(n|=0,r.seq=0|r.seq,r.read=0|r.read,r.recv=0|r.recv,t){case"recv":o=r.recv,r.recv=Math.max(r.recv,n),i=o!=r.recv;break;case"read":o=r.read,r.read=Math.max(r.read,n),i=o!=r.read;break;case"msg":o=r.seq,r.seq=Math.max(r.seq,n),(!r.touched||r.touched<a)&&(r.touched=a),i=o!=r.seq}r.recv<r.read&&(r.recv=r.read,i=!0),r.seq<r.recv&&(r.seq=r.recv,i=!0),r.unread=r.seq-r.read,!i||r.acs&&r.acs.isMuted()||!this.onContactUpdate||this.onContactUpdate(t,r)}},enumerable:!0,configurable:!0,writable:!0},getContact:{value:function(e){return this._contacts[e]},enumerable:!0,configurable:!0,writable:!0},getAccessMode:{value:function(e){var t=this._contacts[e];return t?t.acs:null},enumerable:!0,configurable:!0,writable:!0},isArchived:{value:function(e){var t=this._contacts[e];return t?!(!t.private||!t.private.arch):null},enumerable:!0,configurable:!0,writable:!0}}),r.prototype.constructor=r;var i=function(e){a.call(this,"fnd",e),this._contacts={}};i.prototype=Object.create(a.prototype,{_processMetaSub:{value:function(e){var t=Object.getOwnPropertyNames(this._contacts).length;for(var n in this._contacts={},e){var a=e[n],o=a.topic?a.topic:a.user;a.updated=new Date(a.updated),a.seen&&a.seen.when&&(a.seen.when=new Date(a.seen.when)),a=s(this._contacts,o,a),t++,this.onMetaSub&&this.onMetaSub(a)}0<t&&this.onSubsUpdated&&this.onSubsUpdated(Object.keys(this._contacts))},enumerable:!0,configurable:!0,writable:!1},publish:{value:function(){return Promise.reject(new Error("Publishing to 'fnd' is not supported"))},enumerable:!0,configurable:!0,writable:!1},setMeta:{value:function(e){var t=this;return Object.getPrototypeOf(i.prototype).setMeta.call(this,e).then(function(){0<Object.keys(t._contacts).length&&(t._contacts={},t.onSubsUpdated&&t.onSubsUpdated([]))})},enumerable:!0,configurable:!0,writable:!1},contacts:{value:function(e,t){var n=e||this.onMetaSub;if(n)for(var a in this._contacts)n.call(t,this._contacts[a],a,this._contacts)},enumerable:!0,configurable:!0,writable:!0}}),i.prototype.constructor=i;var d=function(e){this._tinode=e,this._apiKey=e._apiKey,this._authToken=e.getAuthToken(),this._msgId=e.getNextUniqueId(),this.xhr=M(),this.toResolve=null,this.toReject=null,this.onProgress=null,this.onSuccess=null,this.onFailure=null};d.prototype={upload:function(e,t,n,a){var o=this;if(!this._authToken)throw new Error("Must authenticate first");var r=this;this.xhr.open("POST","/v"+l+"/file/u/",!0),this.xhr.setRequestHeader("X-Tinode-APIKey",this._apiKey),this.xhr.setRequestHeader("X-Tinode-Auth","Token "+this._authToken.token);var i=new Promise(function(e,t){o.toResolve=e,o.toReject=t});this.onProgress=t,this.onSuccess=n,this.onFailure=a,this.xhr.upload.onprogress=function(e){e.lengthComputable&&r.onProgress&&r.onProgress(e.loaded/e.total)},this.xhr.onload=function(){var e;try{e=JSON.parse(this.response,C)}catch(e){r._tinode.logger("Invalid server response in LargeFileHelper",this.response)}200<=this.status&&this.status<300?(r.toResolve&&r.toResolve(e.ctrl.params.url),r.onSuccess&&r.onSuccess(e.ctrl)):400<=this.status?(r.toReject&&r.toReject(new Error(e.ctrl.text+" ("+e.ctrl.code+")")),r.onFailure&&r.onFailure(e.ctrl)):r._tinode.logger("Unexpected server response status",this.status,this.response)},this.xhr.onerror=function(e){r.toReject&&r.toReject(new Error("failed")),r.onFailure&&r.onFailure(null)},this.xhr.onabort=function(e){r.toReject&&r.toReject(new Error("upload cancelled by user")),r.onFailure&&r.onFailure(null)};try{var s=new FormData;s.append("file",e),s.set("id",this._msgId),this.xhr.send(s)}catch(e){this.toReject&&this.toReject(e),this.onFailure&&this.onFailure(null)}return i},download:function(e,n,a,t){var o=this;if(/^(?:(?:[a-z]+:)?\/\/)/i.test(e))throw new Error("The URL '"+e+"' must be relative, not absolute");if(!this._authToken)throw new Error("Must authenticate first");var r=this;this.xhr.open("GET",e,!0),this.xhr.setRequestHeader("X-Tinode-APIKey",this._apiKey),this.xhr.setRequestHeader("X-Tinode-Auth","Token "+this._authToken.token),this.xhr.responseType="blob",this.onProgress=t,this.xhr.onprogress=function(e){r.onProgress&&r.onProgress(e.loaded)};var i=new Promise(function(e,t){o.toResolve=e,o.toReject=t});this.xhr.onload=function(){if(200==this.status){var e=document.createElement("a");e.href=window.URL.createObjectURL(new Blob([this.response],{type:a})),e.style.display="none",e.setAttribute("download",n),document.body.appendChild(e),e.click(),document.body.removeChild(e),window.URL.revokeObjectURL(e.href),r.toResolve&&r.toResolve()}else if(400<=this.status&&r.toReject){var t=new FileReader;t.onload=function(){try{var e=JSON.parse(this.result,C);r.toReject(new Error(e.ctrl.text+" ("+e.ctrl.code+")"))}catch(e){r._tinode.logger("Invalid server response in LargeFileHelper",this.result),r.toReject(e)}},t.readAsText(this.response)}},this.xhr.onerror=function(e){r.toReject&&r.toReject(new Error("failed"))},this.xhr.onabort=function(){r.toReject&&r.toReject(null)};try{this.xhr.send()}catch(e){this.toReject&&this.toReject(e)}return i},cancel:function(){this.xhr&&this.xhr.readyState<4&&this.xhr.abort()},getId:function(){return this._msgId}};var p=function e(t,n){this.status=e.STATUS_NONE,this.topic=t,this.content=n};p.STATUS_NONE=0,p.STATUS_QUEUED=1,p.STATUS_SENDING=2,p.STATUS_FAILED=3,p.STATUS_SENT=4,p.STATUS_RECEIVED=5,p.STATUS_READ=6,p.STATUS_TO_ME=7,(p.prototype={toJSON:function(){},fromJSON:function(e){}}).constructor=p,y.exports=c,y.exports.Drafty=v}.call(this,void 0!==e?e:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{}),y=y.exports}()}).call(this,n(9))},function(e,t){e.exports=ReactDOM},function(e){e.exports={en:{archived_contacts:"Archived contacts ({count})",contacts_not_found:"You have no chats<br />¯∖_(ツ)_/¯",full_name_prompt:"Full name, e.g. John Doe",email_prompt:"Email, e.g. jdoe@example.com",button_sign_up:"Sign up",label_your_name:"Your name",label_password:"Password",password_unchanged_prompt:"Unchanged",label_user_id:"Address:",label_default_access_mode:"Default access mode:",label_message_sound:"Message sound:",label_push_notifications:"Notification alerts:",label_push_notifications_disabled:"Notification alerts (requires HTTPS):",title_tag_manager:"Tags (user discovery)",button_logout:"Logout",requested_permissions:"Requested",granted_permissions:"Granted",menu_item_edit_permissions:"Edit permissions",label_other_user:"Other",title_info:"Info",label_topic_name:"Name",label_private:"Private comment",private_editing_placeholder:"Visible to you only",label_muting_topic:"Muted:",action_more:"More",label_your_permissions:"Your permissions:",label_permissions:"Permissions:",label_you:"You:",label_default_access:"Default access mode:",label_group_members:"Group members:",button_add_members:"Add members",button_leave:"Leave",group_has_no_members:"No members",action_leave_chat:"Leave",login_prompt:"Login",password_prompt:"Password",stay_logged_in:"Stay logged in",forgot_password_link:"Forgot password?",button_sign_in:"Sign in",label_client:"Client:",label_server:"Server:",online_now:"online now",last_seen_timestamp:"Last seen",title_not_found:"Not found",unnamed_topic:"Unnamed",messages_not_readable:"no access to messages",peers_messaging_disabled:"Peer's messaging is disabled.",enable_peers_messaging:"Enable",tabtitle_find_user:"find",tabtitle_new_group:"new group",tabtitle_group_by_id:"by id",search_for_contacts:"Use search to find contacts",new_password_placeholder:"Enter new password",label_reset_password:"Send a password reset email:",credential_email_prompt:"Your registration email",button_reset:"Reset",button_send_request:"Send request",label_server_to_use:"Server to use:",label_wire_transport:"Wire transport:",button_update:"Update",sidepanel_title_login:"Sign In",sidepanel_title_register:"Create Account",sidepanel_title_settings:"Settings",sidepanel_title_edit_account:"Edit Account",sidepanel_title_newtpk:"Start New Chat",sidepanel_title_cred:"Confirm Credentials",sidepanel_title_reset:"Reset Password",sidepanel_title_archive:"Archived Chats",update_available:'Update available. <a href="">Reload</a>.',reconnect_countdown:"Disconnected. Reconnecting in {seconds}s…",reconnect_now:"Try now",phone_dative:"phone",email_dative:"email",enter_confirmation_code_prompt:"Enter confirmation code sent to you by {method}:",numeric_confirmation_code_prompt:"Numbers only",button_confirm:"Confirm",save_attachment:"save",invalid_content:"invalid content",user_not_found:"Not found",badge_you:"you",badge_owner:"owner",menu_item_info:"Info",menu_item_clear_messages:"Clear messages",menu_item_clear_messages_for_all:"Clear for All",menu_item_delete:"Delete",menu_item_delete_for_all:"Delete for All",menu_item_mute:"Mute",menu_item_unmute:"Unmute",menu_item_delete_topic:"Delete",menu_item_unblock:"Unblock",menu_item_block:"Block",menu_item_member_delete:"Remove",menu_item_archive_topic:"Archive",action_cancel:"cancel",upload_finishing:"finishing...",no_contacts:"You have no contacts :-(",contacts_not_found_short:"No contacts match '{query}'",title_group_members:"Group Members",title_all_contacts:"All Contacts",button_ok:"OK",button_cancel:"Cancel",download_action:"download",label_file_name:"File name:",label_content_type:"Content type:",label_size:"Size:",chat_invitation:"You are invited to start a new chat. What would you like to do?",chat_invitation_accept:"Accept",chat_invitation_ignore:"Ignore",chat_invitation_block:"Block",error_invalid_id:"Invalid ID",group_user_id_prompt:"Group or User ID",button_subscribe:"Subscribe",topic_name_editing_placeholder:"Freeform name of the group",button_create:"Create",permission_join:"Join ({val})",permission_read:"Read ({val})",permission_write:"Write ({val})",permission_pres:"Get notified ({val})",permission_admin:"Approve ({val})",permission_share:"Share ({val})",permission_delete:"Delete ({val})",permission_owner:"Owner ({val})",title_permissions:"Permissions",message_sending:"sending...",message_sending_failed:"failed",search_placeholder:"List like email:alice@example.com, tel:17025550003...",messaging_disabled_prompt:"Messaging disabled",new_message_prompt:"New message",file_attachment_too_large:"The file size {size} exceeds the {limit} limit.",cannot_initiate_file_upload:"Cannot initiate file upload.",tags_not_found:"No tags defined. Add some.",tags_editor_no_tags:"Add some tags",title_manage_tags:"Manage tags"},ru:{contacts_not_found:"Чатов нет<br />¯∖_(ツ)_/¯",full_name_prompt:"Полное имя, напр. Иван Петров",email_prompt:"Email, напр. ivan@example.com",button_sign_up:"Создать счет",label_your_name:"Ваше имя",label_password:"Пароль",password_unchanged_prompt:"Не изменен",label_user_id:"Адрес:",label_default_access_mode:"Доступ по умолчанию:",label_message_sound:"Звук нового сообщения:",label_push_notifications:"Уведомления:",label_push_notifications_disabled:"Уведомления (требуют HTTPS):",title_tag_manager:"Таги для поиска",button_logout:"Выйти",login_prompt:"Логин",password_prompt:"Пароль",stay_logged_in:"Запомнить",forgot_password_link:"Напомнить пароль",button_sign_in:"Войти",label_client:"Клиент:",label_server:"Сервер:",online_now:"онлайн",last_seen_timestamp:"Был активен",title_not_found:"Не найден",unnamed_topic:"Без названия",messages_not_readable:"нет доступа к сообщениям",tabtitle_find_user:"найти",tabtitle_new_group:"создать",tabtitle_group_by_id:"по id",label_server_to_use:"Использовать сервер:",label_wire_transport:"Соединение:",button_update:"Применить",sidepanel_title_login:"Авторизация",sidepanel_title_register:"Зарегистрироваться",sidepanel_title_settings:"Настройки",sidepanel_title_edit_account:"Редактировать счет",sidepanel_title_newtpk:"Новый чат",sidepanel_title_cred:"Подтвердить",sidepanel_title_reset:"Сменить пароль",tags_not_found:"Тагов нет. Добавьте",tags_editor_no_tags:"Добавьте таги",title_manage_tags:"Редактор тагов",message_sending:"в пути...",message_sending_failed:"ошибка",search_placeholder:"Список, напр. email:alice@example.com, tel:17025550003...",messaging_disabled_prompt:"Отправка недоступна",new_message_prompt:"Новое сообщение",file_attachment_too_large:"Размер файла {size} превышает {limit} лимит.",cannot_initiate_file_upload:"Ошибка загрузки файла.",search_for_contacts:"Поиск контактов",enter_confirmation_code_prompt:"Код подтверждения, полученный по {method}:",numeric_confirmation_code_prompt:"Только цифры",button_confirm:"Подтвердить",button_ok:"OK",button_cancel:"Отменить",invalid_content:"сообщение не читается",label_file_name:"Имя файла:",label_content_type:"Тип:",label_size:"Размер:",phone_dative:"телефону",email_dative:"емейлу",title_group_members:"Участники",download_action:"скачать",permission_join:"Подписываться ({val})",permission_read:"Читать ({val})",permission_write:"Писать ({val})",permission_pres:"Уведомлять ({val})",permission_admin:"Подтверждать ({val})",permission_share:"Приглашать ({val})",permission_delete:"Удалять ({val})",permission_owner:"Владелец ({val})",title_permissions:"Права доступа",requested_permissions:"Требуются",granted_permissions:"Получены",menu_item_edit_permissions:"Права доступа",label_other_user:"Второй",label_topic_name:"Название",label_private:"Комментарий",private_editing_placeholder:"Виден только вам",label_muting_topic:"Без уведомлений",action_more:"Ещё",label_your_permissions:"Ваши права доступа:",label_permissions:"Права доступа:",label_you:"Вы:",label_default_access:"Права по умолчанию:",label_group_members:"Участники чата:",button_add_members:"Добавить",button_leave:"Отписаться",group_has_no_members:"Нет участников",action_leave_chat:"Уйти из чата",menu_item_info:"Информация",menu_item_clear_messages:"Удалить сообщения",menu_item_clear_messages_for_all:"Удалить для всех",menu_item_delete:"Удалить",menu_item_delete_for_all:"Удалить для всех",menu_item_mute:"Не уведомлять",menu_item_unmute:"Уведомлять",menu_item_delete_topic:"Удалить чат",menu_item_unblock:"Разблокировать",menu_item_block:"Заблокировать",menu_item_member_delete:"Отписать",title_info:"Подробности",new_password_placeholder:"Введите новый пароль",label_reset_password:"Отправить емейл для смены пароля:",credential_email_prompt:"Регистрационный емейл",button_reset:"Изменить",button_send_request:"Отправить",action_cancel:"отменить",upload_finishing:"завершение...",no_contacts:"Ничего нет :-(",contacts_not_found_short:"Нет контактов для запроса '{query}'",title_all_contacts:"Все контакты",error_invalid_id:"Неверный ID",group_user_id_prompt:"ID чата или пользователя",button_subscribe:"Подписаться",topic_name_editing_placeholder:"Название чата",button_create:"Создать",badge_you:"вы",badge_owner:"влад.",update_available:'Есть новая версия приложения. <a href="">Обновить</a>.',user_not_found:"Не найден",reconnect_countdown:"Нет связи. Подключение через {seconds}с…",reconnect_now:"Подключить сейчас.",save_attachment:"сохранить",menu_item_archive_topic:"В архив",archived_contacts:"Чаты в архиве ({count})",sidepanel_title_archive:"Архив чатов",chat_invitation:"Вас пригласили начать новый чат. Как вы хотите поступить?",chat_invitation_accept:"Принять",chat_invitation_ignore:"Игнорировать",chat_invitation_block:"Заблокировать",peers_messaging_disabled:"Чат заблокирован у корреспондента.",enable_peers_messaging:"Разблокировать."}}},function(e,t){e.exports=firebase},function(e,t,n){e.exports=function(){"use strict";return[{locale:"ru",pluralRuleFunction:function(e,t){var n=String(e).split("."),a=n[0],o=!n[1],r=a.slice(-1),i=a.slice(-2);return t?"other":o&&1==r&&11!=i?"one":o&&2<=r&&r<=4&&(i<12||14<i)?"few":o&&0==r||o&&5<=r&&r<=9||o&&11<=i&&i<=14?"many":"other"},fields:{year:{displayName:"год",relative:{0:"в этом году",1:"в следующем году","-1":"в прошлом году"},relativeTime:{future:{one:"через {0} год",few:"через {0} года",many:"через {0} лет",other:"через {0} года"},past:{one:"{0} год назад",few:"{0} года назад",many:"{0} лет назад",other:"{0} года назад"}}},"year-short":{displayName:"г.",relative:{0:"в этом г.",1:"в след. г.","-1":"в прошлом г."},relativeTime:{future:{one:"через {0} г.",few:"через {0} г.",many:"через {0} л.",other:"через {0} г."},past:{one:"{0} г. назад",few:"{0} г. назад",many:"{0} л. назад",other:"{0} г. назад"}}},month:{displayName:"месяц",relative:{0:"в этом месяце",1:"в следующем месяце","-1":"в прошлом месяце"},relativeTime:{future:{one:"через {0} месяц",few:"через {0} месяца",many:"через {0} месяцев",other:"через {0} месяца"},past:{one:"{0} месяц назад",few:"{0} месяца назад",many:"{0} месяцев назад",other:"{0} месяца назад"}}},"month-short":{displayName:"мес.",relative:{0:"в этом мес.",1:"в следующем мес.","-1":"в прошлом мес."},relativeTime:{future:{one:"через {0} мес.",few:"через {0} мес.",many:"через {0} мес.",other:"через {0} мес."},past:{one:"{0} мес. назад",few:"{0} мес. назад",many:"{0} мес. назад",other:"{0} мес. назад"}}},day:{displayName:"день",relative:{0:"сегодня",1:"завтра",2:"послезавтра","-2":"позавчера","-1":"вчера"},relativeTime:{future:{one:"через {0} день",few:"через {0} дня",many:"через {0} дней",other:"через {0} дня"},past:{one:"{0} день назад",few:"{0} дня назад",many:"{0} дней назад",other:"{0} дня назад"}}},"day-short":{displayName:"дн.",relative:{0:"сегодня",1:"завтра",2:"послезавтра","-2":"позавчера","-1":"вчера"},relativeTime:{future:{one:"через {0} дн.",few:"через {0} дн.",many:"через {0} дн.",other:"через {0} дн."},past:{one:"{0} дн. назад",few:"{0} дн. назад",many:"{0} дн. назад",other:"{0} дн. назад"}}},hour:{displayName:"час",relative:{0:"в этот час"},relativeTime:{future:{one:"через {0} час",few:"через {0} часа",many:"через {0} часов",other:"через {0} часа"},past:{one:"{0} час назад",few:"{0} часа назад",many:"{0} часов назад",other:"{0} часа назад"}}},"hour-short":{displayName:"ч",relative:{0:"в этот час"},relativeTime:{future:{one:"через {0} ч.",few:"через {0} ч.",many:"через {0} ч.",other:"через {0} ч."},past:{one:"{0} ч. назад",few:"{0} ч. назад",many:"{0} ч. назад",other:"{0} ч. назад"}}},minute:{displayName:"минута",relative:{0:"в эту минуту"},relativeTime:{future:{one:"через {0} минуту",few:"через {0} минуты",many:"через {0} минут",other:"через {0} минуты"},past:{one:"{0} минуту назад",few:"{0} минуты назад",many:"{0} минут назад",other:"{0} минуты назад"}}},"minute-short":{displayName:"мин.",relative:{0:"в эту минуту"},relativeTime:{future:{one:"через {0} мин.",few:"через {0} мин.",many:"через {0} мин.",other:"через {0} мин."},past:{one:"{0} мин. назад",few:"{0} мин. назад",many:"{0} мин. назад",other:"{0} мин. назад"}}},second:{displayName:"секунда",relative:{0:"сейчас"},relativeTime:{future:{one:"через {0} секунду",few:"через {0} секунды",many:"через {0} секунд",other:"через {0} секунды"},past:{one:"{0} секунду назад",few:"{0} секунды назад",many:"{0} секунд назад",other:"{0} секунды назад"}}},"second-short":{displayName:"сек.",relative:{0:"сейчас"},relativeTime:{future:{one:"через {0} сек.",few:"через {0} сек.",many:"через {0} сек.",other:"через {0} сек."},past:{one:"{0} сек. назад",few:"{0} сек. назад",many:"{0} сек. назад",other:"{0} сек. назад"}}}}},{locale:"ru-BY",parentLocale:"ru"},{locale:"ru-KG",parentLocale:"ru"},{locale:"ru-KZ",parentLocale:"ru"},{locale:"ru-MD",parentLocale:"ru"},{locale:"ru-UA",parentLocale:"ru"}]}()},function(e,t,n){e.exports=n(10)},function(e,t){e.exports=firebase.messaging},function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t,n){"use strict";n.r(t);var a=n(0),w=n.n(a),o=n(3),i=n.n(o),S=n(1),r=n(6),s=n.n(r),l=n(4),c=n(5),u=(n(8),n(2)),E=n.n(u),d="TinodeWeb/0.15.13",p={hosted:"api.tinode.co",local:"localhost:6060"},h=p.hosted,f="JRWPS",m=195840;function g(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}var b=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}var t,n,a;return t=e,a=[{key:"parseUrlHash",value:function(e){var t=e.split("?",2),n={},a=[];return t[0]&&(a=t[0].substr(1).split("/")),t[1]&&t[1].split("&").forEach(function(e){var t=e.split("=");t[0]&&(n[decodeURIComponent(t[0])]=decodeURIComponent(t[1]))}),{path:a,params:n}}},{key:"navigateTo",value:function(e){window.location.hash=e}},{key:"composeUrlHash",value:function(e,t){var n=e.join("/"),a=[];for(var o in t)t.hasOwnProperty(o)&&a.push(o+"="+t[o]);return 0<a.length&&(n+="?"+a.join("&")),n}},{key:"addUrlParam",value:function(e,t,n){var a=this.parseUrlHash(e);return a.params[t]=n,this.composeUrlHash(a.path,a.params)}},{key:"removeUrlParam",value:function(e,t){var n=this.parseUrlHash(e);return delete n.params[t],this.composeUrlHash(n.path,n.params)}},{key:"setUrlSidePanel",value:function(e,t){var n=this.parseUrlHash(e);return n.path[0]=t,this.composeUrlHash(n.path,n.params)}},{key:"setUrlTopic",value:function(e,t){var n=this.parseUrlHash(e);return n.path[1]=t,delete n.params.info,this.composeUrlHash(n.path,n.params)}}],(n=null)&&g(t.prototype,n),a&&g(t,a),e}();function v(e){return(v="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function y(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function _(e){return(_=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function k(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function M(e,t){return(M=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var C=Object(S.defineMessages)({info:{id:"menu_item_info",defaultMessage:"Info"},clear_messages:{id:"menu_item_clear_messages",defaultMessage:"Clear messages"},clear_for_all:{id:"menu_item_clear_messages_for_all",defaultMessage:"Clear for All"},delete:{id:"menu_item_delete",defaultMessage:"Delete"},delete_for_all:{id:"menu_item_delete_for_all",defaultMessage:"Delete for All"},mute:{id:"menu_item_mute",defaultMessage:"Mute"},unmute:{id:"menu_item_unmute",defaultMessage:"Unmute"},topic_delete:{id:"menu_item_delete_topic",defaultMessage:"Delete"},unblock:{id:"menu_item_unblock",defaultMessage:"Unblock"},block:{id:"menu_item_block",defaultMessage:"Block"},member_delete:{id:"menu_item_member_delete",defaultMessage:"Remove"},archive:{id:"menu_item_archive_topic",defaultMessage:"Archive"}}),T=function(e){function r(e){var a,t,n;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,r),t=this,n=_(r).call(this,e),a=!n||"object"!==v(n)&&"function"!=typeof n?k(t):n;var o=e.intl.formatMessage;return a.handlePageClick=a.handlePageClick.bind(k(a)),a.handleEscapeKey=a.handleEscapeKey.bind(k(a)),a.handleClick=a.handleClick.bind(k(a)),a.MenuItems={topic_info:{id:"topic_info",title:o(C.info),handler:null},messages_clear:{id:"messages_clear",title:o(C.clear_messages),handler:function(e,t){return a.deleteMessages(!0,!1,e,t)}},messages_clear_hard:{id:"messages_clear_hard",title:o(C.clear_for_all),handler:function(e,t){return a.deleteMessages(!0,!0,e,t)}},message_delete:{id:"message_delete",title:o(C.delete),handler:function(e,t){return a.deleteMessages(!1,!1,e,t)}},message_delete_hard:{id:"message_delete_hard",title:o(C.delete_for_all),handler:function(e,t){return a.deleteMessages(!1,!0,e,t)}},topic_unmute:{id:"topic_unmute",title:o(C.unmute),handler:a.topicPermissionSetter.bind(k(a),"+P")},topic_mute:{id:"topic_mute",title:o(C.mute),handler:a.topicPermissionSetter.bind(k(a),"-P")},topic_unblock:{id:"topic_unblock",title:o(C.unblock),handler:a.topicPermissionSetter.bind(k(a),"+JP")},topic_block:{id:"topic_block",title:o(C.block),handler:function(t,e){return a.topicPermissionSetter("-JP",t,e).then(function(e){return a.props.onTopicRemoved(t.topicName),e})}},topic_delete:{id:"topic_delete",title:o(C.topic_delete),handler:function(e,t){var n=a.props.tinode.getTopic(e.topicName);if(n)return n.delTopic().catch(function(e){t&&t(e.message,"err")});console.log("Topic not found: ",e.topicName)}},topic_archive:{id:"topic_archive",title:o(C.archive),handler:function(e,t){var n=a.props.tinode.getTopic(e.topicName);if(n)return n.archive(!0).catch(function(e){t&&t(e.message,"err")});console.log("Topic not found: ",e.topicName)}},permissions:{id:"permissions",title:o({id:"menu_item_edit_permissions"}),handler:null},member_delete:{id:"member_delete",title:o(C.member_delete),handler:function(e,t){var n=a.props.tinode.getTopic(e.topicName);if(n&&e.user)return n.delSubscription(e.user).catch(function(e){t&&t(e.message,"err")});console.log("Topic or user not found: '"+e.topicName+"', '"+e.user+"'")}},member_mute:{id:"member_mute",title:o(C.mute),handler:a.topicPermissionSetter.bind(k(a),"-P")},member_unmute:{id:"member_unmute",title:o(C.unmute),handler:a.topicPermissionSetter.bind(k(a),"+P")},member_block:{id:"member_block",title:o(C.block),handler:a.topicPermissionSetter.bind(k(a),"-J")},member_unblock:{id:"member_unblock",title:o(C.unblock),handler:a.topicPermissionSetter.bind(k(a),"+J")}},a}var t,n,a;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&M(e,t)}(r,w.a.Component),t=r,(n=[{key:"componentDidMount",value:function(){document.addEventListener("mousedown",this.handlePageClick,!1),document.addEventListener("keyup",this.handleEscapeKey,!1)}},{key:"componentWillUnmount",value:function(){document.removeEventListener("mousedown",this.handlePageClick,!1),document.removeEventListener("keyup",this.handleEscapeKey,!1)}},{key:"handlePageClick",value:function(e){i.a.findDOMNode(this).contains(e.target)||(e.preventDefault(),e.stopPropagation(),this.props.hide())}},{key:"handleEscapeKey",value:function(e){27===e.keyCode&&this.props.hide()}},{key:"handleClick",value:function(e){e.preventDefault(),e.stopPropagation(),this.props.hide();var 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.log("Invalid menu item ID",e.currentTarget.dataset.id)}},{key:"deleteMessages",value:function(e,t,n,a){var o=this.props.tinode.getTopic(n.topicName);if(o){if(e||!o.cancelSend(n.seq))return(e?o.delMessagesAll(t):o.delMessagesList([n.seq],t)).catch(function(e){a&&a(e.message,"err")})}else console.log("Topic not found: ",n.topicName)}},{key:"topicPermissionSetter",value:function(e,t,n){var a=this.props.tinode.getTopic(t.topicName);if(a){var o,r;if(t.user){if(!(r=a.subscriber(t.user)))return void console.log("Subscriber not found",t.topicName+"["+t.user+"]");o=r.acs.updateGiven(e).getGiven()}else o=a.getAccessMode().updateWant(e).getWant();var i=a.setMeta({sub:{user:t.user,mode:o}});return n&&(i=i.catch(function(e){n(e.message,"err")})),i}console.log("Topic not found",t.topicName)}},{key:"render",value:function(){var t=this,n=0,a=[];this.props.items.map(function(e){"string"==typeof e&&(e=t.MenuItems[e]),e&&e.title&&a.push("-"==e.title?w.a.createElement("li",{className:"separator",key:n}):w.a.createElement("li",{onClick:t.handleClick,"data-id":n,key:n},e.title)),n++});var e=13*(.7+2.5*a.length),o={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.y<e?this.props.clickAt.y-this.props.bounds.top-e:this.props.clickAt.y-this.props.bounds.top)+"px"};return w.a.createElement("ul",{className:"menu",style:o},a)}}])&&y(t.prototype,n),a&&y(t,a),r}(),O=Object(S.injectIntl)(T);function P(e,t){t=t||window.navigator.userLanguage||window.navigator.language;var n=new Date;return e.getFullYear()==n.getFullYear()?e.getMonth()==n.getMonth()&&e.getDate()==n.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,{hour12:!1,year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function j(e){if(!e||0==e)return"0 Bytes";var t=["Bytes","KB","MB","GB","TB","PB"],n=Math.min(0|Math.floor(Math.log2(e)/10),t.length-1),a=e/Math.pow(1024,n),o=0<n?a<3?2:a<30?1:0:0;return a.toFixed(o)+" "+t[n]}function N(e){return(N="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function A(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function x(e,t){return!t||"object"!==N(t)&&"function"!=typeof t?function(e){if(void 0!==e)return e;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}(e):t}function D(e){return(D=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function U(e,t){return(U=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var R=function(e){function t(){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),x(this,D(t).apply(this,arguments))}var n,a,o;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&U(e,t)}(t,w.a.PureComponent),n=t,(a=[{key:"render",value:function(){var e;if(!0===this.props.avatar)if(this.props.topic&&this.props.title&&this.props.title.trim()){var t=this.props.title.trim().charAt(0),n="lettertile dark-color"+Math.abs(function(e){var t=0;e=""+e;for(var n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t&=t;return t}(this.props.topic))%16;e=w.a.createElement("div",{className:n},w.a.createElement("div",null,t))}else e="grp"==E.a.topicType(this.props.topic)?w.a.createElement("i",{className:"material-icons"},"group"):w.a.createElement("i",{className:"material-icons"},"person");else e=this.props.avatar?w.a.createElement("img",{className:"avatar",alt:"avatar",src:this.props.avatar,onError:function(e){e.target.onerror=null,e.target.src="/img/broken_image.png"}}):null;return e}}])&&A(n.prototype,a),o&&A(n,o),t}(),F=["image/jpeg","image/gif","image/png","image/svg","image/svg+xml"],I=["jpg","gif","png","svg","svg"];function L(e){return e&&e.type&&e.data?"data:image/"+e.type+";base64,"+e.data:null}function q(e,t,n,a,o){if(t|=0,n|=0,a|=0,(e|=0)<=0||t<=0||n<=0||a<=0)return null;o&&(n=a=Math.min(n,a));var r=Math.min(Math.min(e,n)/e,Math.min(t,a)/t),i={dstWidth:e*r|0,dstHeight:t*r|0};return o?(i.dstWidth=i.dstHeight=Math.min(i.dstWidth,i.dstHeight),i.srcWidth=i.srcHeight=Math.min(e,t),i.xoffset=(e-i.srcWidth)/2|0,i.yoffset=(t-i.srcWidth)/2|0):(i.xoffset=i.yoffset=0,i.srcWidth=e,i.srcHeight=t),i}function H(e,t){var n=F.indexOf(t),a=I[n],o=e.lastIndexOf(".");return 0<=o&&(e=e.substring(0,o)),e+"."+a}function W(i,s,l,c,u,d){var e=new Image;e.crossOrigin="Anonymous",e.onerror=function(e){d("Image format unrecognized")},e.onload=function(){var e=q(this.width,this.height,s,l,c);if(e){var t=document.createElement("canvas");t.width=e.dstWidth,t.height=e.dstHeight;var n=t.getContext("2d");n.imageSmoothingEnabled=!0,n.drawImage(this,e.xoffset,e.yoffset,e.srcWidth,e.srcHeight,0,0,e.dstWidth,e.dstHeight);var a=this.width!=e.dstWidth||this.height!=e.dstHeight||F.indexOf(i.type)<0?"image/jpeg":i.type,o=t.toDataURL(a);if(a=B(o.split(",")[0])){var r=.78;if(K(o.length)>m&&(a="image/jpeg"),"image/jpeg"==a)for(;K(o.length)>m&&.45<r;)o=t.toDataURL(a,r),r*=.84;K(o.length)>m?d("The image size "+bytesToHumanSize(K(o.length))+" exceeds the "+bytesToHumanSize(m)+" limit.","err"):(t=null,u(o.split(",")[1],a,e.dstWidth,e.dstHeight,H(i.name,a)))}else d("Unsupported image format")}else d("Invalid image")},e.src=URL.createObjectURL(i)}function G(a,o,r){var i=new FileReader;i.addEventListener("load",function(){var e=i.result.split(","),t=B(e[0]);if(t){var n=new Image;n.crossOrigin="Anonymous",n.onload=function(){o(e[1],t,this.width,this.height,H(a.name,t))},n.onerror=function(e){r("Image format not recognized")},n.src=URL.createObjectURL(a)}else r("Failed to process image file")},!1),i.readAsDataURL(a)}function V(e,t,n){var a=new FileReader;a.addEventListener("load",function(){t(e.type,a.result.split(",")[1],e.name)}),a.readAsDataURL(e)}function B(e){var t=/^data:(image\/[-+a-z0-9.]+);base64/.exec(e);return t&&1<t.length?t[1]:null}function K(e){return 3*Math.floor(e/4)}function z(e){return(z="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function J(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function Y(e){return(Y=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function Q(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function X(e,t){return(X=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var $=function(e){function o(e){var t,n,a;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,o),n=this,(t=!(a=Y(o).call(this,e))||"object"!==z(a)&&"function"!=typeof a?Q(n):a).state={dataUrl:e.avatar},t.handleFileUpload=t.handleFileUpload.bind(Q(t)),t.handleClear=t.handleClear.bind(Q(t)),t}var t,n,a;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&X(e,t)}(o,w.a.Component),t=o,a=[{key:"getDerivedStateFromProps",value:function(e,t){return t.dataUrl!=e.avatar?{dataUrl:e.avatar}:null}}],(n=[{key:"handleFileUpload",value:function(e){var a=this;W(e.target.files[0],128,128,!0,function(e,t){var n=L({data:e,type:t});a.setState({dataUrl:n}),a.props.onImageChanged(n)},function(e){a.props.onError(e,"err")}),e.target.value=""}},{key:"handleClear",value:function(){this.props.onImageChanged(null)}},{key:"render",value:function(){var e="file-input-avatar-"+(Math.random()+"").substr(2);return w.a.createElement("div",{className:"avatar-upload"},this.props.readOnly||!this.state.dataUrl?null:w.a.createElement("a",{href:"javascript:;",className:"clear-avatar",onClick:this.handleClear},w.a.createElement("i",{className:"material-icons"},"clear")),this.state.dataUrl?w.a.createElement("img",{src:this.state.dataUrl,className:"preview"}):this.props.readOnly&&this.props.uid?w.a.createElement("div",{className:"avatar-box"},w.a.createElement(R,{avatar:!0,topic:this.props.uid,title:this.props.title})):w.a.createElement("div",{className:"blank"},128,"×",128),this.props.readOnly?null:w.a.createElement("input",{type:"file",id:e,className:"inputfile hidden",accept:"image/*",onChange:this.handleFileUpload}),this.props.readOnly?null:w.a.createElement("label",{htmlFor:e,className:"round"},w.a.createElement("i",{className:"material-icons"},"file_upload")))}}])&&J(t.prototype,n),a&&J(t,a),o}();function Z(e){return(Z="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function ee(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function te(e){return(te=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function ne(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function ae(e,t){return(ae=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var oe=function(e){function o(e){var t,n,a;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,o),n=this,(t=!(a=te(o).call(this,e))||"object"!==Z(a)&&"function"!=typeof a?ne(n):a).handleChange=t.handleChange.bind(ne(t)),t}var t,n,a;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&ae(e,t)}(o,w.a.PureComponent),t=o,(n=[{key:"handleChange",value:function(){this.props.onChange(this.props.name,!this.props.checked)}},{key:"render",value:function(){return this.props.onChange?this.props.checked?w.a.createElement("i",{className:"material-icons blue clickable",onClick:this.handleChange},"check_box"):w.a.createElement("i",{className:"material-icons blue clickable",onClick:this.handleChange},"check_box_outline_blank"):this.props.checked?w.a.createElement("i",{className:"material-icons"},"check_box"):w.a.createElement("i",{className:"material-icons"},"check_box_outline_blank")}}])&&ee(t.prototype,n),a&&ee(t,a),o}();function re(e){return(re="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function ie(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function se(e,t){return!t||"object"!==re(t)&&"function"!=typeof t?function(e){if(void 0!==e)return e;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}(e):t}function le(e){return(le=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function ce(e,t){return(ce=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var ue=function(e){function t(){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),se(this,le(t).apply(this,arguments))}var n,a,o;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&ce(e,t)}(t,w.a.PureComponent),n=t,(a=[{key:"render",value:function(){var n=null;return this.props.badges&&0<this.props.badges.length&&(n=[],this.props.badges.map(function(e){var t="badge"+(e.color?" "+e.color:"");n.push(w.a.createElement("span",{className:t,key:e.key||e.name},e.name))})),w.a.createElement("span",null,n)}}])&&ie(n.prototype,a),o&&ie(n,o),t}();function de(e){return(de="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function pe(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function he(e,t){return!t||"object"!==de(t)&&"function"!=typeof t?function(e){if(void 0!==e)return e;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}(e):t}function fe(e){return(fe=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function me(e,t){return(me=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var ge=function(e){function t(){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),he(this,fe(t).apply(this,arguments))}var n,a,o;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&me(e,t)}(t,w.a.PureComponent),n=t,(a=[{key:"render",value:function(){return 0<this.props.count?w.a.createElement("span",{className:"unread"},9<this.props.count?"9+":this.props.count):null}}])&&pe(n.prototype,a),o&&pe(n,o),t}();function be(e){return(be="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function ve(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function ye(e){return(ye=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function _e(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function we(e,t){return(we=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var Se=function(e){function o(e){var t,n,a;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,o),n=this,(t=!(a=ye(o).call(this,e))||"object"!==be(a)&&"function"!=typeof a?_e(n):a).handleClick=t.handleClick.bind(_e(t)),t.handleContextClick=t.handleContextClick.bind(_e(t)),t}var t,n,a;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&we(e,t)}(o,w.a.Component),t=o,(n=[{key:"handleClick",value:function(e){e.preventDefault(),e.stopPropagation(),this.props.onSelected&&this.props.onSelected(this.props.item,this.props.index,this.props.now,this.props.acs)}},{key:"handleContextClick",value:function(e){e.preventDefault(),e.stopPropagation(),this.props.showContextMenu({topicName:this.props.item,y:e.pageY,x:e.pageX})}},{key:"render",value:function(){var e=this.props.title;e?30<e.length&&(e=e.substring(0,28)+"..."):e=w.a.createElement("i",null,w.a.createElement(S.FormattedMessage,{id:"unnamed_topic"}));var t=this.props.now?"online":"offline",n=!this.props.avatar||this.props.avatar,a=this.props.badges?this.props.badges.slice():[];return this.props.showMode&&this.props.acs&&a.push({name:this.props.acs.getMode(),key:"mode"}),w.a.createElement("li",{className:!this.props.showCheckmark&&this.props.selected?"selected":null,onClick:this.handleClick},w.a.createElement("div",{className:"avatar-box"},w.a.createElement(R,{avatar:n,title:this.props.title,topic:this.props.item}),this.props.showOnline?w.a.createElement("span",{className:t}):this.props.showCheckmark&&this.props.selected?w.a.createElement("i",{className:"checkmark material-icons"},"check_circle"):null),w.a.createElement("div",{className:"text-box"},w.a.createElement("div",null,w.a.createElement("span",{className:"contact-title"},e),0<this.props.unread?w.a.createElement(ge,{count:this.props.unread}):null),this.props.comment?w.a.createElement("div",{className:"contact-comment"},this.props.comment):null,w.a.createElement(ue,{badges:a})),this.props.showContextMenu?w.a.createElement("span",{className:"menuTrigger"},w.a.createElement("a",{href:"javascript:;",onClick:this.handleContextClick},w.a.createElement("i",{className:"material-icons"},"expand_more"))):null)}}])&&ve(t.prototype,n),a&&ve(t,a),o}();function Ee(e){return(Ee="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function ke(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function Me(e){return(Me=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function Ce(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Te(e,t){return(Te=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var Oe=function(e){function o(e){var t,n,a;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,o),n=this,(t=!(a=Me(o).call(this,e))||"object"!==Ee(a)&&"function"!=typeof a?Ce(n):a).handleClick=t.handleClick.bind(Ce(t)),t}var t,n,a;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&Te(e,t)}(o,w.a.PureComponent),t=o,(n=[{key:"handleClick",value:function(e){e.preventDefault(),e.stopPropagation(),this.props.onAction(this.props.action)}},{key:"render",value:function(){var e=this.props.intl.formatMessage;return w.a.createElement("li",{onClick:this.handleClick,className:"action"},w.a.createElement("div",{className:"action-text"},e(this.props.title,this.props.values)))}}])&&ke(t.prototype,n),a&&ke(t,a),o}(),Pe=Object(S.injectIntl)(Oe);function je(e){return(je="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Ne(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function Ae(e,t){return!t||"object"!==je(t)&&"function"!=typeof t?function(e){if(void 0!==e)return e;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}(e):t}function xe(e){return(xe=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function De(e,t){return(De=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var Ue=Object(S.defineMessages)({badge_you:{id:"badge_you",defaultMessage:"you"},badge_owner:{id:"badge_owner",defaultMessage:"owner"}}),Re=function(e){function t(){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),Ae(this,xe(t).apply(this,arguments))}var n,a,o;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&De(e,t)}(t,w.a.Component),n=t,(a=[{key:"render",value:function(){var i=this,s=this.props.intl.formatMessage,l=Array.isArray(this.props.topicSelected),c=[],u=0;return this.props.contacts&&0<this.props.contacts.length&&this.props.contacts.map(function(e){if(e.action)c.push(w.a.createElement(Pe,{title:e.title,action:e.action,values:e.values,key:e.action,onAction:i.props.onAction}));else{var t=e.topic?e.topic:e.user;if(i.props.filterFunc&&i.props.filter){var n=[t];if(e.private&&e.private.comment&&n.push((""+e.private.comment).toLowerCase()),e.public&&e.public.fn&&n.push((""+e.public.fn).toLowerCase()),!i.props.filterFunc(i.props.filter,n))return}var a=l?-1<i.props.topicSelected.indexOf(t):i.props.topicSelected===t,o=[];i.props.showMode&&(t===i.props.myUserId&&o.push({name:s(Ue.badge_you),color:"green"}),e.acs&&e.acs.isOwner()&&o.push({name:s(Ue.badge_owner),color:"blue"}));var r=Array.isArray(e.private)?e.private.join(","):e.private?e.private.comment:null;c.push(w.a.createElement(Se,{title:e.public?e.public.fn:null,avatar:L(e.public?e.public.photo:null),comment:r,unread:i.props.showUnread?e.unread:0,now:e.online&&i.props.connected,acs:e.acs,showMode:i.props.showMode,badges:o,showCheckmark:l,selected:a,showOnline:i.props.showOnline,onSelected:i.props.onTopicSelected,showContextMenu:i.props.showContextMenu,item:t,index:c.length,key:t})),u++}},this),w.a.createElement("div",{className:this.props.noScroll?null:"scrollable-panel"},0==u?w.a.createElement("div",{className:"center-medium-text",dangerouslySetInnerHTML:{__html:this.props.emptyListMessage}}):null,0<c.length?w.a.createElement("ul",{className:"contact-box"},c):null)}}])&&Ne(n.prototype,a),o&&Ne(n,o),t}(),Fe=Object(S.injectIntl)(Re);function Ie(e){return(Ie="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Le(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function qe(e,t){return!t||"object"!==Ie(t)&&"function"!=typeof t?function(e){if(void 0!==e)return e;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}(e):t}function He(e){return(He=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function We(e,t){return(We=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var Ge=function(e){function t(e){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),qe(this,He(t).call(this,e))}var n,a,o;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&We(e,t)}(t,w.a.PureComponent),n=t,(a=[{key:"render",value:function(){return w.a.createElement("a",{href:"javascript:;",onClick:this.props.onCancel},w.a.createElement("i",{className:"material-icons"},"close"))}}])&&Le(n.prototype,a),o&&Le(n,o),t}();function Ve(e){return(Ve="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Be(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function Ke(e){return(Ke=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function ze(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Je(e,t){return(Je=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var Ye=function(e){function o(e){var t,n,a;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,o),n=this,(t=!(a=Ke(o).call(this,e))||"object"!==Ve(a)&&"function"!=typeof a?ze(n):a).state={show:!1},t.hide=t.hide.bind(ze(t)),t}var t,n,a;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&Je(e,t)}(o,w.a.PureComponent),t=o,a=[{key:"getDerivedStateFromProps",value:function(e,t){return{show:!!e.level}}}],(n=[{key:"hide",value:function(){this.setState({show:!1}),this.props.onClearError&&this.props.onClearError()}},{key:"render",value:function(){var e={err:"error",warn:"warning",info:"info"}[this.props.level]||"",t="alert-box "+e;return w.a.createElement("div",{className:t},w.a.createElement("div",{className:"icon"},w.a.createElement("i",{className:"material-icons"},e)),w.a.createElement("span",null,w.a.createElement("span",{dangerouslySetInnerHTML:{__html:this.props.text}}),this.props.action?w.a.createElement("a",{href:"javascript:;",onClick:this.props.action},this.props.actionText):null),w.a.createElement("div",{className:"cancel"},w.a.createElement(Ge,{onCancel:this.hide})))}}])&&Be(t.prototype,n),a&&Be(t,a),o}();function Qe(e){return(Qe="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Xe(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function $e(e){return($e=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function Ze(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function et(e,t){return(et=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var tt=function(e){function o(e){var t,n,a;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,o),n=this,(t=!(a=$e(o).call(this,e))||"object"!==Qe(a)&&"function"!=typeof a?Ze(n):a).handleCancel=t.handleCancel.bind(Ze(t)),t}var t,n,a;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&et(e,t)}(o,w.a.PureComponent),t=o,(n=[{key:"handleCancel",value:function(){this.props.onCancel(this.props.topic,this.props.index)}},{key:"render",value:function(){var e=this.props.title||this.props.topic;return w.a.createElement("div",{className:"chip"},this.props.noAvatar?w.a.createElement("span",{className:"spacer"}):w.a.createElement("div",{className:"avatar-box"},w.a.createElement(R,{avatar:this.props.avatar||!0,topic:this.props.topic,title:this.props.title})),w.a.createElement("span",null,e),this.props.onCancel&&!this.props.required?w.a.createElement("a",{href:"javascript:;",onClick:this.handleCancel},"×"):w.a.createElement("span",{className:"spacer"}))}}])&&Xe(t.prototype,n),a&&Xe(t,a),o}();function nt(e){return(nt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function at(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function ot(e){return(ot=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function rt(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function it(e,t){return(it=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var st=function(e){function o(e){var t,n,a;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,o),n=this,(t=!(a=ot(o).call(this,e))||"object"!==nt(a)&&"function"!=typeof a?rt(n):a).state=o.getDerivedStateFromProps(e),t.handleTextInput=t.handleTextInput.bind(rt(t)),t.removeChipAt=t.removeChipAt.bind(rt(t)),t.handleChipCancel=t.handleChipCancel.bind(rt(t)),t.handleFocusGained=t.handleFocusGained.bind(rt(t)),t.handleFocusLost=t.handleFocusLost.bind(rt(t)),t.handleKeyDown=t.handleKeyDown.bind(rt(t)),t}var t,n,a;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&it(e,t)}(o,w.a.Component),t=o,a=[{key:"getDerivedStateFromProps",value:function(e,t){var n={placeholder:e.chips?"":e.prompt,sortedChips:o.sortChips(e.chips,e.required),chipIndex:o.indexChips(e.chips),focused:t&&t.focused};return(!t||e.chips.length>t.sortedChips.length)&&(n.input=""),n}},{key:"indexChips",value:function(e){var t={},n=0;return e.map(function(e){t[e.user]=n,n++}),t}},{key:"sortChips",value:function(e,t){var n=[],a=[];return e.map(function(e){e.user===t?n.push(e):a.push(e)}),n.concat(a)}}],(n=[{key:"handleTextInput",value:function(e){this.setState({input:e.target.value}),this.props.filterFunc&&this.props.filterFunc(e.target.value)}},{key:"removeChipAt",value:function(e){var t=this.state.sortedChips[e];this.props.onChipRemoved(t.user,this.state.chipIndex[t.user])}},{key:"handleChipCancel",value:function(e,t){this.removeChipAt(t)}},{key:"handleFocusGained",value:function(){this.setState({focused:!0})}},{key:"handleFocusLost",value:function(){this.setState({focused:!1}),this.props.onFocusLost&&this.props.onFocusLost(this.state.input)}},{key:"handleKeyDown",value:function(e){if("Backspace"===e.key){if(0==this.state.input.length&&0<this.state.sortedChips.length){var t=this.state.sortedChips.length-1;this.state.sortedChips[t].user!==this.props.required&&this.removeChipAt(t)}}else"Enter"===e.key?this.props.onEnter&&this.props.onEnter(this.state.input):"Escape"===e.key&&this.props.onCancel&&this.props.onCancel()}},{key:"render",value:function(){var t=this,n=[],a=0;this.state.sortedChips.map(function(e){n.push(w.a.createElement(tt,{onCancel:t.handleChipCancel,avatar:L(e.public?e.public.photo:null),title:e.public?e.public.fn:void 0,noAvatar:t.props.avatarDisabled,topic:e.user,required:e.user===t.props.required,index:a,key:e.user})),a++});var e="chip-input"+(this.state.focused?" focused":"");return w.a.createElement("div",{className:e},n,w.a.createElement("input",{type:"text",placeholder:this.state.placeholder,onChange:this.handleTextInput,onFocus:this.handleFocusGained,onBlur:this.handleFocusLost,onKeyDown:this.handleKeyDown,value:this.state.input,autoFocus:!0}))}}])&&at(t.prototype,n),a&&at(t,a),o}();function lt(e){return(lt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function ct(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function ut(e){return(ut=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function dt(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function pt(e,t){return(pt=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var ht=Object(S.defineMessages)({no_contacts:{id:"no_contacts",defaultMessage:"You have no contacts :-("},contacts_not_found:{id:"contacts_not_found_short",defaultMessage:"No contacts match '{query}'"}}),ft=function(e){function i(e){var t,n,a;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,i),n=this,(t=!(a=ut(i).call(this,e))||"object"!==lt(a)&&"function"!=typeof a?dt(n):a).state={members:e.members,index:i.indexMembers(e.members),contactFilter:"",noContactsMessage:e.intl.formatMessage(ht.no_contacts),selectedContacts:i.selectedContacts(e.members)},t.handleContactSelected=t.handleContactSelected.bind(dt(t)),t.handleMemberRemoved=t.handleMemberRemoved.bind(dt(t)),t.handleContactFilter=t.handleContactFilter.bind(dt(t)),t.handleSubmit=t.handleSubmit.bind(dt(t)),t.handleCancel=t.handleCancel.bind(dt(t)),t}var t,n,a;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&pt(e,t)}(i,w.a.Component),t=i,a=[{key:"indexMembers",value:function(e){var t={};return e.map(function(e){t[e.user]={delta:0,present:!0}}),t}},{key:"selectedContacts",value:function(e){var t=[];return e.map(function(e){t.push(e.user)}),t}},{key:"doContactFiltering",value:function(e,t){if(e){for(var n=0;n<t.length;n++)if(0<=t[n].indexOf(e))return!0;return!1}return!0}}],(n=[{key:"handleContactSelected",value:function(e,t){var n=this.state.index[e];if(n){if(n.present)return;n.delta+=1,n.present=!0}else n={delta:1,present:!0};var a=this.state.members.slice();a.push(this.props.contacts[t]);var o=i.selectedContacts(a),r=this.state.index;r[e]=n,this.setState({members:a,index:r,selectedContacts:o})}},{key:"handleMemberRemoved",value:function(e,t){var n=this.state.index[e];if(n&&n.present){n.present=!1,n.delta-=1;var a=this.state.members.slice();a.splice(t,1);var o=i.selectedContacts(a),r=this.state.index;r[e]=n,this.setState({members:a,index:r,selectedContacts:o})}}},{key:"handleContactFilter",value:function(e){var t=this.props.intl.formatMessage,n=e?t(ht.contacts_not_found,{query:e}):t(ht.no_contacts);this.setState({contactFilter:e,noContactsMessage:n})}},{key:"handleSubmit",value:function(){var t=this,n=[],a=[],o=[];Object.keys(this.state.index).map(function(e){t.state.index[e].present&&n.push(e),0<t.state.index[e].delta?a.push(e):t.state.index[e].delta<0&&o.push(e)}),this.props.onSubmit(n,a,o)}},{key:"handleCancel",value:function(){this.props.onCancel()}},{key:"render",value:function(){this.props.intl.formatMessage;return w.a.createElement("div",{id:"group-manager"},w.a.createElement("div",{className:"panel-form-row"},w.a.createElement("label",{className:"small"},w.a.createElement(S.FormattedMessage,{id:"title_group_members",defaultMessage:"Group Members"}))),w.a.createElement("div",{className:"panel-form-row"},w.a.createElement(st,{chips:this.state.members,required:this.props.requiredMember,prompt:"add members",filterFunc:this.handleContactFilter,onChipRemoved:this.handleMemberRemoved})),w.a.createElement("div",{className:"panel-form-row"},w.a.createElement("label",{className:"small"},w.a.createElement(S.FormattedMessage,{id:"title_all_contacts",defaultMessage:"All Contacts"}))),w.a.createElement(Fe,{contacts:this.props.contacts,myUserId:this.props.myUserId,topicSelected:this.state.selectedContacts,filter:this.state.contactFilter,filterFunc:i.doContactFiltering,emptyListMessage:this.state.noContactsMessage,showOnline:!1,showUnread:!1,onTopicSelected:this.handleContactSelected}),w.a.createElement("div",{id:"group-manager-buttons",className:"panel-form-row"},w.a.createElement("button",{className:"blue",onClick:this.handleSubmit},w.a.createElement(S.FormattedMessage,{id:"button_ok",defaultMessage:"OK"})),w.a.createElement("button",{className:"white",onClick:this.handleCancel},w.a.createElement(S.FormattedMessage,{id:"button_cancel",defaultMessage:"Cancel"}))))}}])&&ct(t.prototype,n),a&&ct(t,a),i}(),mt=Object(S.injectIntl)(ft);function gt(e){return(gt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function bt(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function vt(e){return(vt=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function yt(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _t(e,t){return(_t=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var wt=function(e){function o(e){var t,n,a;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,o),n=this,(t=!(a=vt(o).call(this,e))||"object"!==gt(a)&&"function"!=typeof a?yt(n):a).state={value:t.props.value,visible:!1},t.handleVisibility=t.handleVisibility.bind(yt(t)),t.handeTextChange=t.handeTextChange.bind(yt(t)),t.handleKeyDown=t.handleKeyDown.bind(yt(t)),t.handleEditingFinished=t.handleEditingFinished.bind(yt(t)),t}var t,n,a;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&_t(e,t)}(o,w.a.PureComponent),t=o,(n=[{key:"handeTextChange",value:function(e){this.setState({value:e.target.value}),this.props.onChange&&this.props.onChange(e)}},{key:"handleVisibility",value:function(e){e.preventDefault(),this.setState({visible:!this.state.visible})}},{key:"handleKeyDown",value:function(e){27==e.keyCode?(this.setState({value:this.props.value,visible:!1}),this.props.onFinished&&this.props.onFinished()):13==e.keyCode&&this.handleEditingFinished()}},{key:"handleEditingFinished",value:function(e){var t=this;if(e){var n=e.currentTarget;setTimeout(function(){n.contains(document.activeElement)||t.props.onFinished&&t.props.onFinished(t.state.value)},0)}else this.props.onFinished&&this.props.onFinished(this.state.value.trim())}},{key:"render",value:function(){return w.a.createElement("div",{tabIndex:"-1",className:"group-focus",onBlur:this.handleEditingFinished},w.a.createElement("input",{className:"with-visibility",type:this.state.visible?"text":"password",value:this.state.value,placeholder:this.props.placeholder,required:this.props.required?"required":"",autoFocus:this.props.autoFocus?"autoFocus":"",autoComplete:this.props.autoComplete,onChange:this.handeTextChange,onKeyDown:this.handleKeyDown}),w.a.createElement("span",{onClick:this.handleVisibility},w.a.createElement("i",{className:"material-icons clickable light-gray"},this.state.visible?"visibility":"visibility_off")))}}])&&bt(t.prototype,n),a&&bt(t,a),o}();function St(e){return(St="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Et(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function kt(e){return(kt=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function Mt(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Ct(e,t){return(Ct=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var Tt=function(e){function o(e){var t,n,a;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,o),n=this,(t=!(a=kt(o).call(this,e))||"object"!==St(a)&&"function"!=typeof a?Mt(n):a).state={active:e.active,initialValue:e.value||"",value:e.value||""},t.handeTextChange=t.handeTextChange.bind(Mt(t)),t.handleKeyDown=t.handleKeyDown.bind(Mt(t)),t.handleStartEditing=t.handleStartEditing.bind(Mt(t)),t.handleEditingFinished=t.handleEditingFinished.bind(Mt(t)),t.handlePasswordFinished=t.handlePasswordFinished.bind(Mt(t)),t}var t,n,a;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&Ct(e,t)}(o,w.a.Component),t=o,a=[{key:"getDerivedStateFromProps",value:function(e,t){return t.initialValue==e.value||t.active?null:{initialValue:e.value||"",value:e.value||""}}}],(n=[{key:"handeTextChange",value:function(e){this.setState({value:e.target.value})}},{key:"handleKeyDown",value:function(e){27===e.keyCode?this.setState({value:this.props.value,active:!1}):13===e.keyCode&&this.handleEditingFinished(e)}},{key:"handleStartEditing",value:function(){this.props.readOnly||(i.a.findDOMNode(this).focus(),this.setState({active:!0}))}},{key:"handleEditingFinished",value:function(e){if(!this.props.required||e.target.checkValidity()){this.setState({active:!1});var t=this.state.value.trim();(t||this.props.value)&&t!==this.props.value&&this.props.onFinished(t)}else this.setState({value:this.props.value,active:!1})}},{key:"handlePasswordFinished",value:function(e){this.setState({active:!1}),e&&e!==this.props.value&&this.props.onFinished(e)}},{key:"render",value:function(){if(this.state.active)var e=this.props.type||"text";else{var t="password"==this.props.type?"••••••••":this.state.value,n="in-place-edit"+(this.props.readOnly?" disabled":"");t||(t=this.props.placeholder,n+=" placeholder"),20<t.length&&(t=t.substring(0,19)+"...")}return this.state.active?"password"==e?w.a.createElement(wt,{value:this.state.value,placeholder:this.props.placeholder,required:this.props.required?"required":"",autoComplete:this.props.autoComplete,autoFocus:!0,onFinished:this.handlePasswordFinished}):w.a.createElement("input",{type:e,value:this.state.value,placeholder:this.props.placeholder,required:this.props.required?"required":"",autoComplete:this.props.autoComplete,autoFocus:!0,onChange:this.handeTextChange,onKeyDown:this.handleKeyDown,onBlur:this.handleEditingFinished}):w.a.createElement("span",{className:n,onClick:this.handleStartEditing},w.a.createElement("span",{className:"content"},t))}}])&&Et(t.prototype,n),a&&Et(t,a),o}();function Ot(e){return(Ot="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Pt(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function jt(e){return(jt=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function Nt(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function At(e,t){return(At=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var xt=function(e){function o(e){var t,n,a;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,o),n=this,(t=!(a=jt(o).call(this,e))||"object"!==Ot(a)&&"function"!=typeof a?Nt(n):a).state={open:e.open},t.handleToggle=t.handleToggle.bind(Nt(t)),t}var t,n,a;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&At(e,t)}(o,w.a.PureComponent),t=o,(n=[{key:"handleToggle",value:function(){var e=!this.state.open;this.setState({open:e}),this.props.onToggle&&this.props.onToggle(e)}},{key:"render",value:function(){return w.a.createElement("label",{className:"small clean-clickable",onClick:this.handleToggle},this.props.title,"...",this.state.open?w.a.createElement("i",{className:"material-icons"},"expand_more"):w.a.createElement("i",{className:"material-icons"},"chevron_right"))}}])&&Pt(t.prototype,n),a&&Pt(t,a),o}();function Dt(e){return(Dt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Ut(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function Rt(e){return(Rt=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function Ft(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function It(e,t){return(It=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var Lt=Object(S.defineMessages)({joiner:{id:"permission_join",defaultMessage:"Join ({val})"},reader:{id:"permission_read",defaultMessage:"Read ({val})"},writer:{id:"permission_write",defaultMessage:"Write ({val})"},preser:{id:"permission_pres",defaultMessage:"Get notified ({val})"},approver:{id:"permission_admin",defaultMessage:"Approve ({val})"},sharer:{id:"permission_share",defaultMessage:"Share ({val})"},deleter:{id:"permission_delete",defaultMessage:"Delete ({val})"},owner:{id:"permission_owner",defaultMessage:"Owner ({val})"}}),qt=function(e){function o(e){var t,n,a;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,o),n=this,(t=!(a=Rt(o).call(this,e))||"object"!==Dt(a)&&"function"!=typeof a?Ft(n):a).state={mode:(e.mode||"").replace("N","")},t.handleChange=t.handleChange.bind(Ft(t)),t.handleSubmit=t.handleSubmit.bind(Ft(t)),t.handleCancel=t.handleCancel.bind(Ft(t)),t}var t,n,a;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&It(e,t)}(o,w.a.Component),t=o,(n=[{key:"handleChange",value:function(e){var t=this.state.mode;-1==t.indexOf(e)?t+=e:t=t.replace(e,""),this.setState({mode:t})}},{key:"handleSubmit",value:function(){var e=(this.state.mode||"N").split("").sort().join("");e!==(this.props.mode||"N").split("").sort().join("")?this.props.onSubmit(e):this.props.onCancel()}},{key:"handleCancel",value:function(){this.props.onCancel()}},{key:"render",value:function(){for(var e=this.props.intl.formatMessage,t="JRWPASDO",n={J:e(Lt.joiner,{val:"J"}),R:e(Lt.reader,{val:"R"}),W:e(Lt.writer,{val:"W"}),P:e(Lt.preser,{val:"P"}),A:e(Lt.approver,{val:"A"}),S:e(Lt.sharer,{val:"S"}),D:e(Lt.deleter,{val:"D"}),O:e(Lt.owner,{val:"O"})},a=this.props.skip||"",o=this.state.mode,r=(this.props.compare||"").replace("N",""),i=[],s=0;s<t.length;s++){var l=t.charAt(s);0<=a.indexOf(l)&&o.indexOf(l)<0||i.push(w.a.createElement("tr",{key:l},w.a.createElement("td",null,n[l]),w.a.createElement("td",{className:"checkbox"},a.indexOf(l)<0?w.a.createElement(oe,{name:l,checked:0<=o.indexOf(l),onChange:this.handleChange}):w.a.createElement(oe,{name:l,checked:0<=o.indexOf(l)})),this.props.compare?w.a.createElement("td",{className:"checkbox"},w.a.createElement(oe,{name:l,checked:0<=r.indexOf(l)})):null))}return w.a.createElement("div",{className:"panel-form-column"},this.props.userTitle?w.a.createElement("ul",{className:"contact-box"},w.a.createElement(Se,{item:this.props.item,title:this.props.userTitle,avatar:L(this.props.userAvatar?this.props.userAvatar:null)})):null,w.a.createElement("label",{className:"small"},w.a.createElement(S.FormattedMessage,{id:"title_permissions",defaultMessage:"Permissions"})),w.a.createElement("table",{className:"permission-editor"},this.props.compare?w.a.createElement("thead",null,w.a.createElement("tr",null,w.a.createElement("th",null),w.a.createElement("th",null,this.props.modeTitle),w.a.createElement("th",null,this.props.compareTitle))):null,w.a.createElement("tbody",null,i)),w.a.createElement("br",null),w.a.createElement("div",{className:"dialog-buttons"},w.a.createElement("button",{className:"blue",onClick:this.handleSubmit},w.a.createElement(S.FormattedMessage,{id:"button_ok"})),w.a.createElement("button",{className:"white",onClick:this.handleCancel},w.a.createElement(S.FormattedMessage,{id:"button_cancel"}))))}}])&&Ut(t.prototype,n),a&&Ut(t,a),o}(),Ht=Object(S.injectIntl)(qt);function Wt(e){var t=document.getElementById("shortcut-icon"),n=document.head||document.getElementsByTagName("head")[0],a=document.createElement("link");a.type="image/png",a.id="shortcut-icon",a.rel="shortcut icon",a.href="img/logo32x32"+(0<e?"a":"")+".png",t&&n.removeChild(t),n.appendChild(a),document.title=(0<e?"("+e+") ":"")+"Tinode"}function Gt(e,t){var n=null;if((e&&e.trim()||t)&&(n={},e&&(n.fn=e.trim()),t)){var a=t.indexOf(",");n.photo={data:t.substring(a+1),type:"jpg"}}return n}function Vt(e){return(Vt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Bt(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function Kt(e){return(Kt=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function zt(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Jt(e,t){return(Jt=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var Yt=function(e){function o(e){var t,n,a;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,o),n=this,(t=!(a=Kt(o).call(this,e))||"object"!==Vt(a)&&"function"!=typeof a?zt(n):a).state={tags:t.props.tags,tagInput:"",activated:t.props.activated},t.handleShowTagManager=t.handleShowTagManager.bind(zt(t)),t.handleTagInput=t.handleTagInput.bind(zt(t)),t.handleAddTag=t.handleAddTag.bind(zt(t)),t.handleRemoveTag=t.handleRemoveTag.bind(zt(t)),t.handleSubmit=t.handleSubmit.bind(zt(t)),t.handleCancel=t.handleCancel.bind(zt(t)),t}var t,n,a;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&Jt(e,t)}(o,w.a.Component),t=o,a=[{key:"getDerivedStateFromProps",value:function(e,t){return function(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(var n=0,a=e.length;n<a;n++)if(e[n]!==t[n])return!1;return!0}(e.tags,t.tags)||t.activated?null:{tags:e.tags}}}],(n=[{key:"handleShowTagManager",value:function(){this.setState({activated:!0})}},{key:"handleTagInput",value:function(e){if(this.setState({tagInput:e}),0<e.length){var t=e[e.length-1];if(","==t||" "==t||";"==t){var n=e.substr(0,e.length-1).trim();4<=n.length&&this.handleAddTag(n)}}}},{key:"handleAddTag",value:function(e){if(0<(e=e.trim()).length){var t=this.state.tags.slice(0);t.push(e),this.setState({tags:t,tagInput:""}),this.props.onTagsChanged&&this.props.onTagsChanged(t)}}},{key:"handleRemoveTag",value:function(e,t){var n=this.state.tags.slice(0);n.splice(t,1),this.setState({tags:n}),this.props.onTagsChanged&&this.props.onTagsChanged(n)}},{key:"handleSubmit",value:function(){var e=this.state.tags.slice(0),t=this.state.tagInput.trim();0<t.length&&(e.push(t),this.props.onTagsChanged&&this.props.onTagsChanged(e)),this.props.onSubmit(e),this.setState({activated:!1,tagInput:"",tags:this.props.tags})}},{key:"handleCancel",value:function(){this.setState({activated:!1,tagInput:"",tags:this.props.tags}),this.props.onCancel&&this.props.onCancel()}},{key:"render",value:function(){var t=this,n=[];return this.state.activated?this.state.tags.map(function(e){n.push({user:e})}):(this.state.tags.map(function(e){n.push(w.a.createElement("span",{className:"badge",key:n.length},e))}),0==n.length&&(n=w.a.createElement("i",null,w.a.createElement(S.FormattedMessage,{id:"tags_not_found",defaultMessage:"No tags defined. Add some."})))),w.a.createElement("div",{className:"panel-form-column"},w.a.createElement("div",{className:"panel-form-row"},w.a.createElement("label",{className:"small"},this.props.title)),this.state.activated?w.a.createElement("div",null,w.a.createElement(S.FormattedMessage,{id:"tags_editor_no_tags",defaultMessage:"Add some tags"},function(e){return w.a.createElement(st,{chips:n,avatarDisabled:!0,prompt:e,onEnter:t.handleAddTag,onFocusLost:t.handleAddTag,onCancel:t.handleCancel,onChipRemoved:t.handleRemoveTag,filterFunc:t.handleTagInput})}),this.props.onSubmit||this.props.onCancel?w.a.createElement("div",{id:"tag-manager-buttons",className:"panel-form-row"},w.a.createElement("button",{className:"blue",onClick:this.handleSubmit},w.a.createElement(S.FormattedMessage,{id:"button_ok",defautMessage:"OK",description:"Confirmation button [OK]"})),w.a.createElement("button",{className:"white",onClick:this.handleCancel},w.a.createElement(S.FormattedMessage,{id:"button_cancel",defautMessage:"Cancel",description:"Rejection button [Cancel]"}))):null):w.a.createElement("div",null,w.a.createElement("a",{href:"javascript:;",className:"flat-button",onClick:this.handleShowTagManager},w.a.createElement("i",{className:"material-icons"},"edit")," ",w.a.createElement(S.FormattedMessage,{id:"title_manage_tags",defaultMessage:"Manage tags"})),w.a.createElement("span",null,n)))}}])&&Bt(t.prototype,n),a&&Bt(t,a),o}();function Qt(e){return(Qt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Xt(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function $t(e){return($t=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function Zt(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function en(e,t){return(en=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var tn=Object(S.defineMessages)({requested:{id:"requested_permissions",defaultMessage:"Requested"},granted:{id:"granted_permissions",defaultMessage:"Granted"},edit_permissions:{id:"menu_item_edit_permissions",defaultMessage:"Edit permissions"},other_user:{id:"label_other_user",defaultMessage:"Other"}}),nn=function(e){function o(e){var t,n,a;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,o),n=this,(t=!(a=$t(o).call(this,e))||"object"!==Qt(a)&&"function"!=typeof a?Zt(n):a).state={topic:null,owner:!1,admin:!1,sharer:!1,muted:!1,address:null,groupTopic:void 0,fullName:void 0,avatar:null,private:null,selectedContact:null,access:null,modeGiven:null,modeWant:null,modeGiven2:null,modeWant2:null,auth:null,anon:null,contactList:[],tags:[],showMemberPanel:!1,showPermissionEditorFor:void 0,moreInfoExpanded:!1,previousMetaDesc:void 0,previousSubsUpdated:void 0,previousTagsUpdated:void 0},t.resetSubs=t.resetSubs.bind(Zt(t)),t.resetDesc=t.resetDesc.bind(Zt(t)),t.onMetaDesc=t.onMetaDesc.bind(Zt(t)),t.onSubsUpdated=t.onSubsUpdated.bind(Zt(t)),t.onTagsUpdated=t.onTagsUpdated.bind(Zt(t)),t.handleFullNameUpdate=t.handleFullNameUpdate.bind(Zt(t)),t.handlePrivateUpdate=t.handlePrivateUpdate.bind(Zt(t)),t.handleImageChanged=t.handleImageChanged.bind(Zt(t)),t.handleMuted=t.handleMuted.bind(Zt(t)),t.handlePermissionsChanged=t.handlePermissionsChanged.bind(Zt(t)),t.handleLaunchPermissionsEditor=t.handleLaunchPermissionsEditor.bind(Zt(t)),t.handleHidePermissionsEditor=t.handleHidePermissionsEditor.bind(Zt(t)),t.handleShowAddMembers=t.handleShowAddMembers.bind(Zt(t)),t.handleHideAddMembers=t.handleHideAddMembers.bind(Zt(t)),t.handleMemberUpdateRequest=t.handleMemberUpdateRequest.bind(Zt(t)),t.handleLeave=t.handleLeave.bind(Zt(t)),t.handleMemberSelected=t.handleMemberSelected.bind(Zt(t)),t.handleMoreInfo=t.handleMoreInfo.bind(Zt(t)),t.handleTagsUpdated=t.handleTagsUpdated.bind(Zt(t)),t.handleContextMenu=t.handleContextMenu.bind(Zt(t)),t}var t,n,a;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&en(e,t)}(o,w.a.Component),t=o,(n=[{key:"componentDidUpdate",value:function(e){var t=this.props.tinode.getTopic(e.topic);t&&(this.onMetaDesc!=t.onMetaDesc&&(this.previousMetaDesc=t.onMetaDesc,t.onMetaDesc=this.onMetaDesc,this.previousSubsUpdated=t.onSubsUpdated,t.onSubsUpdated=this.onSubsUpdated,"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}),this.resetDesc(t,e),this.resetSubs(t,e)))}},{key:"componentWillUnmount",value:function(){var e=this.props.tinode.getTopic(this.props.topic);e&&(this.setState({topic:null}),e.onMetaDesc=this.previousMetaDesc,e.onSubsUpdated=this.previousSubsUpdated,e.onTagsUpdated=this.previousTagsUpdated)}},{key:"resetSubs",value:function(e,t){var n={contactList:[]};if("p2p"==e.getType()){var a=e.subscriber(t.topic);n.modeWant2=a?(n.modeGiven2=a.acs.getGiven(),a.acs.getWant()):n.modeGiven2="N"}else e.subscribers(function(e){n.contactList.push(e)},this);this.setState(n)}},{key:"resetDesc",value:function(e,t){var n=e.getDefaultAccess()||{},a=e.getAccessMode();this.setState({owner:a&&a.isOwner(),admin:a&&a.isAdmin(),sharer:a&&a.isSharer(),muted:a&&a.isMuted(),fullName:e.public?e.public.fn:void 0,avatar:L(e.public?e.public.photo:null),private:e.private?e.private.comment:null,address:e.name,groupTopic:"grp"==e.getType(),showMemberPanel:!1,access:a?a.getMode():void 0,modeGiven:a?a.getGiven():void 0,modeWant:a?a.getWant():void 0,auth:n.auth,anon:n.anon}),"grp"==e.getType()&&a&&a.isOwner()&&e.getMeta(e.startMetaQuery().withTags().build())}},{key:"onMetaDesc",value:function(e){var t=this.props.tinode.getTopic(this.props.topic);t&&(this.resetDesc(t,this.props),this.previousMetaDesc&&this.previousMetaDesc!=this.onMetaDesc&&this.previousMetaDesc(e))}},{key:"onSubsUpdated",value:function(e){var t=this.props.tinode.getTopic(this.props.topic);t&&(this.resetSubs(t,this.props),this.previousSubsUpdated&&this.previousSubsUpdated!=this.onSubsUpdated&&this.previousSubsUpdated(e))}},{key:"onTagsUpdated",value:function(e){this.setState({tags:e}),this.previousTagsUpdated&&this.previousTagsUpdated!=this.onTagsUpdated&&this.previousTagsUpdated()}},{key:"handleFullNameUpdate",value:function(e){e=e.trim(),this.state.fullName!==e&&(this.setState({fullName:e}),this.props.onTopicDescUpdate(this.props.topic,Gt(e,null),null))}},{key:"handlePrivateUpdate",value:function(e){this.state.priv!==e&&(this.setState({private:e}),this.props.onTopicDescUpdate(this.props.topic,null,e||E.a.DEL_CHAR))}},{key:"handleImageChanged",value:function(e){this.setState({avatar:e}),this.props.onTopicDescUpdate(this.props.topic,Gt(null,e),null)}},{key:"handleMuted",value:function(e,t){this.setState({muted:t}),this.props.onChangePermissions(this.props.topic,t?"-P":"+P")}},{key:"handlePermissionsChanged",value:function(e){switch(this.state.showPermissionEditorFor){case"auth":this.props.onTopicDescUpdate(this.props.topic,null,null,{auth:e});break;case"anon":this.props.onTopicDescUpdate(this.props.topic,null,null,{anon:e});break;case"mode":case"want":this.props.onChangePermissions(this.props.topic,e);break;case"given":this.props.onChangePermissions(this.props.topic,e,this.props.topic);break;case"user":this.props.onChangePermissions(this.props.topic,e,this.state.userPermissionsEdited)}this.setState({showPermissionEditorFor:void 0})}},{key:"handleLaunchPermissionsEditor",value:function(e,t){var n,a,o,r,i,s,l,c=this.props.intl.formatMessage;switch(e){case"mode":n=this.state.access;break;case"want":n=this.state.modeWant,a=this.state.modeGiven,o=this.state.groupTopic?"O":"ASDO",r=c(tn.requested),i=c(tn.granted);break;case"given":n=this.state.modeGiven2,a=this.state.modeWant2,o=this.state.groupTopic?this.state.owner?"":"O":"ASDO",r=c(tn.granted),i=c(tn.requested);break;case"auth":n=this.state.auth,o="O";break;case"anon":n=this.state.anon,o="O";break;case"user":var u=this.props.tinode.getTopic(this.props.topic);if(!u)return;var d=u.subscriber(t);if(!d||!d.acs)return;n=d.acs.getGiven(),a=d.acs.getWant(),o=this.state.owner?"":"O",r=c(tn.granted),i=c(tn.requested),d.public&&(s=d.public.fn,l=d.public.photo);break;default:console.log("Unknown permission editing mode '"+e+"'")}this.setState({showPermissionEditorFor:e,userPermissionsEdited:t,userPermissionsTitle:s,userPermissionsAvatar:l,editedPermissions:n,immutablePermissions:a,editedPermissionsTitle:r,immutablePermissionsTitle:i,editedPermissionsSkipped:o})}},{key:"handleHidePermissionsEditor",value:function(){this.setState({showPermissionEditorFor:void 0})}},{key:"handleShowAddMembers",value:function(){this.props.onInitFind(),this.setState({showMemberPanel:!0})}},{key:"handleHideAddMembers",value:function(){this.setState({showMemberPanel:!1})}},{key:"handleMemberUpdateRequest",value:function(e,t,n){this.props.onMemberUpdateRequest(this.props.topic,t,n),this.setState({showMemberPanel:!1})}},{key:"handleLeave",value:function(){this.props.onLeaveTopic(this.props.topic)}},{key:"handleMemberSelected",value:function(e){this.setState({selectedContact:e})}},{key:"handleMoreInfo",value:function(e){this.setState({moreInfoExpanded:e})}},{key:"handleTagsUpdated",value:function(e){arrayEqual(this.state.tags.slice(0),e.slice(0))||this.props.onTopicTagsUpdate(this.props.topic,e)}},{key:"handleContextMenu",value:function(e){var t=this.props.intl.formatMessage,n=this,a=this.props.tinode.getTopic(this.props.topic);if(a){var o=a.subscriber(e.topicName);if(o&&o.acs){var r=[{title:t(tn.edit_permissions),handler:function(){n.handleLaunchPermissionsEditor("user",e.topicName)}},"member_delete",o.acs.isMuted()?"member_unmute":"member_mute",o.acs.isJoiner()?"member_block":"member_unblock"];this.props.showContextMenu({topicName:this.props.topic,x:e.x,y:e.y,user:e.topicName},r)}}}},{key:"render",value:function(){var t=this,e=this.props.intl.formatMessage;return w.a.createElement("div",{id:"info-view"},w.a.createElement("div",{className:"caption-panel",id:"info-caption-panel"},w.a.createElement("div",{className:"panel-title",id:"info-title"},w.a.createElement(S.FormattedMessage,{id:"title_info",defaultMessage:"Info"})),w.a.createElement("div",null,w.a.createElement(Ge,{onCancel:this.props.onCancel}))),this.props.displayMobile?w.a.createElement(Ye,{level:this.props.errorLevel,text:this.props.errorText,onClearError:this.props.onError}):null,this.state.showMemberPanel?w.a.createElement(mt,{members:this.state.contactList,requiredMember:this.props.myUserId,myUserId:this.props.myUserId,contacts:this.props.searchableContacts,onCancel:this.handleHideAddMembers,onSubmit:this.handleMemberUpdateRequest}):this.state.showPermissionEditorFor?w.a.createElement(Ht,{mode:this.state.editedPermissions,compare:this.state.immutablePermissions,skip:this.state.editedPermissionsSkipped,modeTitle:this.state.editedPermissionsTitle,compareTitle:this.state.immutablePermissionsTitle,userTitle:this.state.userPermissionsTitle,item:this.state.userPermissionsEdited,userAvatar:this.state.userPermissionsAvatar,onSubmit:this.handlePermissionsChanged,onCancel:this.handleHidePermissionsEditor}):w.a.createElement("div",{id:"info-view-content",className:"scrollable-panel"},w.a.createElement("div",{className:"panel-form-row"},w.a.createElement("div",{className:"panel-form-column"},w.a.createElement("div",null,w.a.createElement("label",{className:"small"},w.a.createElement(S.FormattedMessage,{id:"label_topic_name",defaultMessage:"Name"}))),w.a.createElement("div",null,w.a.createElement(Tt,{placeholder:this.state.groupTopic?"Group name":w.a.createElement("i",null,"Unknown"),readOnly:!this.state.owner,value:this.state.fullName,required:!0,onFinished:this.handleFullNameUpdate})),w.a.createElement("div",null,w.a.createElement("label",{className:"small"},w.a.createElement(S.FormattedMessage,{id:"label_private",defaultMessage:"Private comment"}))),w.a.createElement("div",null,w.a.createElement(S.FormattedMessage,{id:"private_editing_placeholder",defaultMessage:"Visible to you only"},function(e){return w.a.createElement(Tt,{placeholder:e,value:t.state.private,onFinished:t.handlePrivateUpdate})}))),w.a.createElement($,{avatar:this.state.avatar,readOnly:!this.state.owner,uid:this.props.topic,title:this.state.fullName,onImageChanged:this.handleImageChanged,onError:this.props.onError})),w.a.createElement("div",{className:"hr"}),w.a.createElement("div",{className:"panel-form-column"},w.a.createElement("div",{className:"panel-form-row"},w.a.createElement("label",null,w.a.createElement(S.FormattedMessage,{id:"label_muting_topic",defaultMessage:"Muted:"})),w.a.createElement(oe,{name:"P",checked:this.state.muted,onChange:this.handleMuted})),w.a.createElement(S.FormattedMessage,{id:"action_more",defaultMessage:"More"},function(e){return w.a.createElement(xt,{title:e,open:t.state.moreInfoExpanded,onToggle:t.handleMoreInfo})}),this.state.moreInfoExpanded?w.a.createElement("div",{className:"panel-form-column"},w.a.createElement("div",{className:"panel-form-row"},w.a.createElement("label",null,w.a.createElement(S.FormattedMessage,{id:"label_user_id"})),w.a.createElement("tt",null,this.state.address)),this.state.groupTopic?w.a.createElement("div",{className:"panel-form-row"},w.a.createElement("label",null,w.a.createElement(S.FormattedMessage,{id:"label_your_permissions",defaultMessage:"Your permissions:"})),w.a.createElement("tt",{className:"clickable",onClick:this.handleLaunchPermissionsEditor.bind(this,"want")},this.state.access)):w.a.createElement("div",null,w.a.createElement("div",null,w.a.createElement("label",{className:"small"},w.a.createElement(S.FormattedMessage,{id:"label_permissions",defaultMessage:"Permissions:"}))),w.a.createElement("div",{className:"quoted"},w.a.createElement("div",null,w.a.createElement(S.FormattedMessage,{id:"label_you",defaultMessage:"You:"}),"  ",w.a.createElement("tt",{className:"clickable",onClick:this.handleLaunchPermissionsEditor.bind(this,"want")},this.state.access)),w.a.createElement("div",null,this.state.fullName?this.state.fullName:e(tn.other_user),":  ",w.a.createElement("tt",{className:"clickable",onClick:this.handleLaunchPermissionsEditor.bind(this,"given")},this.state.modeGiven2)))),this.state.sharer&&(this.state.auth||this.state.anon)?w.a.createElement("div",null,w.a.createElement("div",null,w.a.createElement("label",{className:"small"},w.a.createElement(S.FormattedMessage,{id:"label_default_access",defaultMessage:"Default access mode:"}))),w.a.createElement("div",{className:"quoted"},w.a.createElement("div",null,"Auth: ",this.state.admin?w.a.createElement("tt",{className:"clickable",onClick:this.handleLaunchPermissionsEditor.bind(this,"auth")},this.state.auth):w.a.createElement("tt",null,this.state.auth)),w.a.createElement("div",null,"Anon: ",this.state.admin?w.a.createElement("tt",{className:"clickable",onClick:this.handleLaunchPermissionsEditor.bind(this,"anon")},this.state.anon):w.a.createElement("tt",null,this.state.anon)))):null):null),w.a.createElement("div",{className:"hr"}),this.state.owner?w.a.createElement(S.FormattedMessage,{id:"title_tag_manager"},function(e){return w.a.createElement(Yt,{title:e,tags:t.state.tags,activated:!1,onSubmit:t.handleTagsUpdated})}):null,this.state.owner?w.a.createElement("div",{className:"hr"}):null,this.state.groupTopic?w.a.createElement("div",{className:"panel-form-column"},w.a.createElement("div",{className:"panel-form-row"},w.a.createElement("label",{className:"small"},w.a.createElement(S.FormattedMessage,{id:"label_group_members",defaultMessage:"Group members:"}))),w.a.createElement("div",{className:"panel-form-row"},this.state.sharer?w.a.createElement("a",{href:"javascript:;",className:"flat-button",onClick:this.handleShowAddMembers},w.a.createElement("i",{className:"material-icons"},"person_add")," ",w.a.createElement(S.FormattedMessage,{id:"button_add_members",defaultMessage:"Add members"})):null,this.state.owner?null:w.a.createElement("a",{href:"javascript:;",className:"red flat-button",onClick:this.handleLeave},w.a.createElement("i",{className:"material-icons"},"exit_to_app")," ",w.a.createElement(S.FormattedMessage,{id:"button_leave",defaultMessage:"Leave"}))),w.a.createElement(S.FormattedMessage,{id:"group_has_no_members",defaultMessage:"No members"},function(e){return w.a.createElement(Fe,{contacts:t.state.contactList,myUserId:t.props.myUserId,emptyListMessage:e,topicSelected:t.state.selectedContact,showOnline:!1,showUnread:!1,showMode:!0,noScroll:!0,onTopicSelected:t.handleMemberSelected,showContextMenu:!!t.state.admin&&t.handleContextMenu})})):w.a.createElement("div",{className:"panel-form-row"},w.a.createElement("a",{href:"javascript:;",className:"red flat-button",onClick:this.handleLeave},w.a.createElement("i",{className:"material-icons"},"exit_to_app")," ",w.a.createElement(S.FormattedMessage,{id:"action_leave_chat",defaultMessage:"Leave"})))))}}])&&Xt(t.prototype,n),a&&Xt(t,a),o}(),an=Object(S.injectIntl)(nn);function on(e){return(on="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function rn(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function sn(e,t){return!t||"object"!==on(t)&&"function"!=typeof t?function(e){if(void 0!==e)return e;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}(e):t}function ln(e){return(ln=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function cn(e,t){return(cn=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var un=function(e){function t(){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),sn(this,ln(t).apply(this,arguments))}var n,a,o;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&cn(e,t)}(t,w.a.PureComponent),n=t,(a=[{key:"render",value:function(){return w.a.createElement("div",{className:"uploader"},w.a.createElement("div",null,w.a.createElement("span",{style:{width:100*this.props.progress+"%"}})),this.props.progress<.999?w.a.createElement("a",{href:"javascript:;",onClick:this.props.onCancel},w.a.createElement("i",{className:"material-icons"},"close")," ",w.a.createElement(S.FormattedMessage,{id:"action_cancel",defaultMessage:"cancel"})):w.a.createElement(S.FormattedMessage,{id:"upload_finishing",defaultMessage:"finishing..."}))}}])&&rn(n.prototype,a),o&&rn(n,o),t}();function dn(e){return(dn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function pn(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function hn(e){return(hn=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function fn(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function mn(e,t){return(mn=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var gn=function(e){function o(e){var t,n,a;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,o),n=this,(t=!(a=hn(o).call(this,e))||"object"!==dn(a)&&"function"!=typeof a?fn(n):a).state={downloader:null,progress:0},t.downloadFile=t.downloadFile.bind(fn(t)),t.handleCancel=t.handleCancel.bind(fn(t)),t}var t,n,a;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&mn(e,t)}(o,w.a.Component),t=o,(n=[{key:"downloadFile",value:function(e,t,n){var a=this,o=this.props.tinode.getLargeFileHelper();this.setState({downloader:o}),o.download(e,t,n,function(e){a.setState({progress:e/a.props.size})}).then(function(){a.setState({downloader:null,progress:0})}).catch(function(e){e&&a.props.onError("Error downloading file: "+e.message,"err"),a.setState({downloader:null,progress:0})})}},{key:"handleCancel",value:function(){this.props.uploader?this.props.onCancelUpload():this.state.downloader&&this.state.downloader.cancel()}},{key:"render",value:function(){var t=this,e=this.props.filename||"file_attachment";36<e.length&&(e=e.substr(0,16)+"..."+e.substr(-16));var n,a,o=0<this.props.size?w.a.createElement("span",{className:"small gray"},"(",j(this.props.size),")"):null;return a=this.props.uploader||this.state.downloader||/^(?:(?:[a-z]+:)?\/\/)/i.test(this.props.downloadUrl)?(n=this.props.downloadUrl,null):(n="javascript:;",function(e){t.downloadFile(t.props.downloadUrl,t.props.filename,t.props.mimetype)}),w.a.createElement("div",{className:"attachment"},w.a.createElement("div",null,w.a.createElement("i",{className:"material-icons big gray"},"insert_drive_file")),w.a.createElement("div",{className:"flex-column"},w.a.createElement("div",null,e," ",o),this.props.uploader||this.state.downloader?w.a.createElement(un,{progress:this.props.uploader?this.props.progress:this.state.progress,onCancel:this.handleCancel}):w.a.createElement("div",null,w.a.createElement("a",{href:n,download:this.props.filename,onClick:a},w.a.createElement("i",{className:"material-icons"},"file_download")," ",w.a.createElement(S.FormattedMessage,{id:"save_attachment",defaultMessage:"save"})))))}}])&&pn(t.prototype,n),a&&pn(t,a),o}();function bn(e){return(bn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function vn(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function yn(e,t){return!t||"object"!==bn(t)&&"function"!=typeof t?function(e){if(void 0!==e)return e;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}(e):t}function _n(e){return(_n=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function wn(e,t){return(wn=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var Sn=Object(S.defineMessages)({sending:{id:"message_sending",defaultMessage:"sending..."},failed:{id:"message_sending_failed",defaultMessage:"failed"}}),En=function(e){function t(){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),yn(this,_n(t).apply(this,arguments))}var n,a,o;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&wn(e,t)}(t,w.a.PureComponent),n=t,(a=[{key:"render",value:function(){var e,t=this.props.intl.formatMessage;e=this.props.received<=E.a.MESSAGE_STATUS_SENDING?t(Sn.sending):this.props.received==E.a.MESSAGE_STATUS_FAILED?t(Sn.failed):P(this.props.timestamp,this.props.intl.locale);var n=null;return this.props.received<=E.a.MESSAGE_STATUS_SENDING?n=w.a.createElement("i",{className:"material-icons small"},"access_time"):this.props.received==E.a.MESSAGE_STATUS_FAILED?n=w.a.createElement("i",{className:"material-icons small amber"},"warning"):this.props.received==E.a.MESSAGE_STATUS_SENT?n=w.a.createElement("i",{className:"material-icons small"},"done"):this.props.received==E.a.MESSAGE_STATUS_RECEIVED?n=w.a.createElement("i",{className:"material-icons small"},"done_all"):this.props.received==E.a.MESSAGE_STATUS_READ&&(n=w.a.createElement("i",{className:"material-icons small blue"},"done_all")),w.a.createElement("span",{className:"timestamp"},e," ",n)}}])&&vn(n.prototype,a),o&&vn(n,o),t}(),kn=Object(S.injectIntl)(En);function Mn(e){return(Mn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Cn(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function Tn(e){return(Tn=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function On(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Pn(e,t){return(Pn=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var jn=function(e){function o(e){var t,n,a;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,o),n=this,(t=!(a=Tn(o).call(this,e))||"object"!==Mn(a)&&"function"!=typeof a?On(n):a).state={progress:0},e.uploader&&(e.uploader.onProgress=t.handleProgress.bind(On(t))),t.handlePreviewImage=t.handlePreviewImage.bind(On(t)),t.handleFormButtonClick=t.handleFormButtonClick.bind(On(t)),t.handleContextClick=t.handleContextClick.bind(On(t)),t.handleCancelUpload=t.handleCancelUpload.bind(On(t)),t}var t,n,a;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&Pn(e,t)}(o,w.a.Component),t=o,(n=[{key:"handlePreviewImage",value:function(e){e.preventDefault(),this.props.onImagePreview({url:e.target.src,filename:e.target.title,width:e.target.dataset.width,height:e.target.dataset.height,size:e.target.dataset.size,type:e.target.dataset.mime})}},{key:"handleFormButtonClick",value:function(e){e.preventDefault();var t={seq:this.props.seq,resp:{}};e.target.dataset.name&&(t.resp[e.target.dataset.name]=e.target.dataset.val?e.target.dataset.val:void 0===e.target.dataset.val?1:""+e.target.dataset.val),"url"==e.target.dataset.act&&(t.ref=""+e.target.dataset.ref);var n=e.target.dataset.title||"unknown";this.props.onFormResponse(e.target.dataset.act,n,t)}},{key:"handleContextClick",value:function(e){e.preventDefault(),e.stopPropagation(),this.props.showContextMenu({seq:this.props.seq,y:e.pageY,x:e.pageX})}},{key:"handleProgress",value:function(e){this.setState({progress:e})}},{key:"handleCancelUpload",value:function(){this.props.uploader.cancel()}},{key:"render",value:function(){var t=this,e=this.props.sequence+" "+(this.props.response?"left":"right"),n="single"==this.props.sequence||"last"==this.props.sequence?"bubble tip":"bubble",a=this.props.userAvatar||!0,o=this.props.userFrom&&this.props.response&&("single"==this.props.sequence||"last"==this.props.sequence),r=this.props.content,i=[];return this.props.mimeType==u.Drafty.getContentType()?(u.Drafty.attachments(r,function(e,t){"application/json"!=e.mime&&i.push(w.a.createElement(gn,{tinode:this.props.tinode,downloadUrl:u.Drafty.getDownloadUrl(e),filename:e.name,uploader:u.Drafty.isUploading(e),mimetype:e.mime,size:u.Drafty.getEntitySize(e),progress:this.state.progress,onCancelUpload:this.handleCancelUpload,onError:this.props.onError,key:t}))},this),r=w.a.createElement("span",null,u.Drafty.format(r,Nn,this))):"string"!=typeof r&&(r=w.a.createElement("span",null,w.a.createElement("i",{className:"material-icons"},"error_outline")," ",w.a.createElement("i",null,w.a.createElement(S.FormattedMessage,{id:"invalid_content",defaultMessage:"invalid content"})))),w.a.createElement("li",{className:e},this.props.userFrom&&this.props.response?w.a.createElement("div",{className:"avatar-box"},o?w.a.createElement(R,{topic:this.props.userFrom,title:this.props.userName,avatar:a}):null):null,w.a.createElement("div",null,w.a.createElement("div",{className:n},w.a.createElement("div",{className:"message-content"},r,i,w.a.createElement(kn,{timestamp:this.props.timestamp,received:this.props.received})),w.a.createElement("span",{className:"menuTrigger"},w.a.createElement("a",{href:"javascript:;",onClick:this.handleContextClick},w.a.createElement("i",{className:"material-icons"},"expand_more")))),o?w.a.createElement("div",{className:"author"},w.a.createElement(S.FormattedMessage,{id:"user_not_found",defaultMessage:"Not found"},function(e){return t.props.userName||w.a.createElement("i",null,e)})):null))}}])&&Cn(t.prototype,n),a&&Cn(t,a),o}();function Nn(e,t,n,a){var o=u.Drafty.tagName(e);if(o){var r=u.Drafty.attrValue(e,t)||{};switch(r.key=a,e){case"IM":if(t){r.className="inline-image";var i=q(t.width,t.height,Math.min(this.props.viewportWidth-52,468),312,!1);i=i||{dstWidth:32,dstHeight:32},r.style={width:i.dstWidth+"px",height:i.dstHeight+"px"},r.src?(r.onClick=this.handlePreviewImage,r.className+=" image-clickable"):r.src="img/broken_image.png"}break;case"BN":r.onClick=this.handleFormButtonClick;var s=w.a.Children.map(n,function(e){return"string"==typeof e?e:void 0});s&&0!=s.length||(s=[r.name]),r["data-title"]=s.join("");break;case"FM":r.className="bot-form"}return w.a.createElement(o,r,n)}return n}function An(e){return(An="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function xn(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function Dn(e,t){return!t||"object"!==An(t)&&"function"!=typeof t?function(e){if(void 0!==e)return e;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}(e):t}function Un(e){return(Un=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function Rn(e,t){return(Rn=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var Fn=function(e){function t(e){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),Dn(this,Un(t).call(this,e))}var n,a,o;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&Rn(e,t)}(t,w.a.Component),n=t,(a=[{key:"render",value:function(){var t=[];return(this.props.subscribers||[]).map(function(e){t.push(w.a.createElement("div",{className:"avatar-box",key:e.user},w.a.createElement(R,{topic:e.user,avatar:L(e.public?e.public.photo:null)||!0,title:e.public?e.public.fn:null})))}),w.a.createElement("div",{id:"topic-users"},t)}}])&&xn(n.prototype,a),o&&xn(n,o),t}();function In(e){return(In="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Ln(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function qn(e,t){return!t||"object"!==In(t)&&"function"!=typeof t?function(e){if(void 0!==e)return e;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}(e):t}function Hn(e){return(Hn=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function Wn(e,t){return(Wn=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var Gn=function(e){function n(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,n),(t=qn(this,Hn(n).call(this,e))).state={},t}var t,a,o;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&Wn(e,t)}(n,w.a.PureComponent),t=n,(a=[{key:"componentDidMount",value:function(){this.setState({width:this.container.clientWidth,height:this.container.clientHeight})}},{key:"render",value:function(){if(!this.props.content)return null;var t=this,e=q(this.props.content.width,this.props.content.height,this.state.width,this.state.height,!1),n=e?{width:e.dstWidth+"px",height:e.dstHeight+"px"}:this.props.content.width>this.props.content.height?{width:"100%"}:{height:"100%"};n.maxWidth="100%",n.maxHeight="100%";var a=this.props.content.filename,o=this.props.content.width/13|0;a.length>o&&(a=a.slice(0,o-2)+"..."+a.slice(2-o));var r=this.props.content.width||"-",i=this.props.content.height||"-";return w.a.createElement("div",{id:"image-preview",onClick:this.props.onClose},w.a.createElement("div",{id:"image-preview-caption-panel"},w.a.createElement("a",{href:this.props.content.url,download:this.props.content.filename},w.a.createElement("i",{className:"material-icons"},"file_download")," ",w.a.createElement(S.FormattedMessage,{id:"download_action",defaultMessage:"download"})),w.a.createElement("a",{href:"javascript:;",onClick:this.props.onClose},w.a.createElement("i",{className:"material-icons gray"},"close"))),w.a.createElement("div",{id:"image-preview-container",ref:function(e){t.container=e}},w.a.createElement("img",{src:this.props.content.url,style:n})),w.a.createElement("div",{id:"image-preview-footer"},w.a.createElement("div",null,w.a.createElement("div",null,w.a.createElement("b",null,w.a.createElement(S.FormattedMessage,{id:"label_file_name",defaultMessage:"File name:"}))),w.a.createElement("div",null,w.a.createElement("span",{title:this.props.content.filename},a||"-"))),w.a.createElement("div",null,w.a.createElement("div",null,w.a.createElement("b",null,w.a.createElement(S.FormattedMessage,{id:"label_content_type",defaultMessage:"Content type:"}))),w.a.createElement("div",null,this.props.content.type)),w.a.createElement("div",null,w.a.createElement("div",null,w.a.createElement("b",null,w.a.createElement(S.FormattedMessage,{id:"label_size",defaultMessage:"Size:"}))),w.a.createElement("div",null,r," × ",i," px; ",j(this.props.content.size)))))}}])&&Ln(t.prototype,a),o&&Ln(t,o),n}();function Vn(e){return(Vn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Bn(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function Kn(e){return(Kn=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function zn(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Jn(e,t){return(Jn=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var Yn=function(e){function o(e){var t,n,a;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,o),n=this,(t=!(a=Kn(o).call(this,e))||"object"!==Vn(a)&&"function"!=typeof a?zn(n):a).handleButtonAction=t.handleButtonAction.bind(zn(t)),t}var t,n,a;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&Jn(e,t)}(o,w.a.PureComponent),t=o,(n=[{key:"handleButtonAction",value:function(e,t){e.preventDefault(),this.props.onAction(t)}},{key:"render",value:function(){var t=this;return w.a.createElement("div",{className:"accept-invite-panel"},w.a.createElement("div",{className:"title"},w.a.createElement(S.FormattedMessage,{id:"chat_invitation",defaultMessage:"You are invited to start a new chat. What would you like to do?"})),w.a.createElement("div",{className:"footer"},w.a.createElement("button",{className:"blue",onClick:function(e){t.handleButtonAction(e,"accept")}},w.a.createElement(S.FormattedMessage,{id:"chat_invitation_accept",defaultMessage:"Accept"})),w.a.createElement("button",{className:"white",onClick:function(e){t.handleButtonAction(e,"delete")}},w.a.createElement(S.FormattedMessage,{id:"chat_invitation_ignore",defaultMessage:"Ignore"})),w.a.createElement("button",{className:"white",onClick:function(e){t.handleButtonAction(e,"block")}},w.a.createElement(S.FormattedMessage,{id:"chat_invitation_block",defaultMessage:"Block"}))))}}])&&Bn(t.prototype,n),a&&Bn(t,a),o}();function Qn(e){return(Qn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Xn(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function $n(e,t){return!t||"object"!==Qn(t)&&"function"!=typeof t?function(e){if(void 0!==e)return e;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}(e):t}function Zn(e){return(Zn=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function ea(e,t){return(ea=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var ta=function(e){function t(){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),$n(this,Zn(t).apply(this,arguments))}var n,a,o;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&ea(e,t)}(t,w.a.PureComponent),n=t,(a=[{key:"render",value:function(){return this.props.show?w.a.createElement("div",{className:"load-spinner-box"},w.a.createElement("div",{className:"loader-spinner"})):null}}])&&Xn(n.prototype,a),o&&Xn(n,o),t}();function na(e){return(na="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function aa(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function oa(e,t){return!t||"object"!==na(t)&&"function"!=typeof t?function(e){if(void 0!==e)return e;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}(e):t}function ra(e){return(ra=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function ia(e,t){return(ia=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var sa=function(e){function t(){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),oa(this,ra(t).apply(this,arguments))}var n,a,o;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&ia(e,t)}(t,w.a.PureComponent),n=t,(a=[{key:"render",value:function(){var e=d+" ("+E.a.getLibrary()+")";return w.a.createElement("div",{id:"dummy-view",className:this.props.hideSelf?"nodisplay":null},w.a.createElement("div",null,w.a.createElement("a",{href:"https://github.com/tinode/chat/"},w.a.createElement("img",{id:"logo",alt:"logo",src:"img/logo.svg"}),w.a.createElement("h2",null,"Tinode Web")),w.a.createElement("p",null,w.a.createElement(S.FormattedMessage,{id:"label_client",defaultMessage:"Client:"})," ",e),w.a.createElement("p",null,w.a.createElement(S.FormattedMessage,{id:"label_server",defaultMessage:"Server:"})," ",this.props.serverVersion," (",this.props.serverAddress,")")))}}])&&aa(n.prototype,a),o&&aa(n,o),t}();function la(e){return(la="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function ca(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function ua(e){return(ua=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function da(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function pa(e,t){return(pa=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var ha=Object(S.defineMessages)({messaging_disabled:{id:"messaging_disabled_prompt",defaultMessage:"Messaging disabled"},type_new_message:{id:"new_message_prompt",defaultMessage:"New message"},file_attachment_too_large:{id:"file_attachment_too_large",defaultMessage:"The file size {size} exceeds the {limit} limit."},cannot_initiate_upload:{id:"cannot_initiate_file_upload",defaultMessage:"Cannot initiate file upload."}}),fa=function(e){function o(e){var t,n,a;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,o),n=this,(t=!(a=ua(o).call(this,e))||"object"!==la(a)&&"function"!=typeof a?da(n):a).state={message:"",keypressTimestamp:(new Date).getTime()-3e3-1},t.handlePasteEvent=t.handlePasteEvent.bind(da(t)),t.handleAttachImage=t.handleAttachImage.bind(da(t)),t.handleAttachFile=t.handleAttachFile.bind(da(t)),t.handleSend=t.handleSend.bind(da(t)),t.handleKeyPress=t.handleKeyPress.bind(da(t)),t.handleMessageTyping=t.handleMessageTyping.bind(da(t)),t}var t,n,a;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&pa(e,t)}(o,w.a.PureComponent),t=o,(n=[{key:"componentDidMount",value:function(){this.messageEditArea.addEventListener("paste",this.handlePasteEvent,!1)}},{key:"componentWillUnmount",value:function(){this.messageEditArea.removeEventListener("paste",this.handlePasteEvent,!1)}},{key:"componentDidUpdate",value:function(){this.messageEditArea.focus()}},{key:"handlePasteEvent",value:function(e){var r=this;this.props.disabled||function(e,t,n,a){var o=(e.clipboardData||e.originalEvent.clipboardData||{}).items;for(var r in o){var i=o[r];if("file"!==i.kind);else{var s=i.getAsFile();if(s)return s.type&&"image"==s.type.split("/")[0]?s.size>m||F.indexOf(s.type)<0?W(s,768,768,!1,t,a):G(s,t,a):V(s,n),!0;console.log("Failed to get file object from pasted file item",i.kind,i.type)}}return!1}(e,function(e,t,n,a,o){r.props.sendMessage(u.Drafty.insertImage(null,0,t,e,n,a,o))},function(e,t,n){r.props.sendMessage(u.Drafty.attachFile(null,e,t,n))},this.props.onError)&&e.preventDefault()}},{key:"handleAttachImage",value:function(e){var r=this;if(e.target.files&&0<e.target.files.length){var t=e.target.files[0];t.size>m||F.indexOf(t.type)<0?W(t,768,768,!1,function(e,t,n,a,o){r.props.sendMessage(u.Drafty.insertImage(null,0,t,e,n,a,o))},function(e){r.props.onError(e,"err")}):G(t,function(e,t,n,a,o){r.props.sendMessage(u.Drafty.insertImage(null,0,t,e,n,a,o))},function(e){r.props.onError(e,"err")})}e.target.value=""}},{key:"handleAttachFile",value:function(e){var a=this,t=this.props.intl.formatMessage;if(e.target.files&&0<e.target.files.length){var n=e.target.files[0];if(n.size>1<<23)this.props.onError(t(ha.file_attachment_too_large,{size:j(n.size),limit:j(1<<23)}),"err");else if(n.size>m){var o=this.props.tinode.getLargeFileHelper();if(!o)return void this.props.onError(t(ha.cannot_initiate_upload));var r=o.upload(n),i=u.Drafty.attachFile(null,n.type,null,n.name,n.size,r);this.props.sendMessage(i,r,o)}else V(n,function(e,t,n){a.props.sendMessage(u.Drafty.attachFile(null,e,t,n))},this.props.onError)}e.target.value=""}},{key:"handleSend",value:function(){this.state.message.trim()&&(this.props.sendMessage(this.state.message.trim()),this.setState({message:""}))}},{key:"handleKeyPress",value:function(e){"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),e.stopPropagation(),this.handleSend()))}},{key:"handleMessageTyping",value:function(e){var t={message:e.target.value},n=(new Date).getTime();if(3e3<n-this.state.keypressTimestamp){var a=this.props.tinode.getTopic(this.props.topic);a.isSubscribed()&&a.noteKeyPress(),t.keypressTimestamp=n}this.setState(t)}},{key:"render",value:function(){var t=this,e=this.props.intl.formatMessage,n=this.props.disabled?e(ha.messaging_disabled):e(ha.type_new_message);return w.a.createElement("div",{id:"send-message-panel"},this.props.disabled?w.a.createElement("i",{className:"material-icons disabled"},"photo"):w.a.createElement("a",{href:"javascript:;",onClick:function(e){t.attachImage.click()},title:"Add image"},w.a.createElement("i",{className:"material-icons secondary"},"photo")),this.props.disabled?w.a.createElement("i",{className:"material-icons disabled"},"attach_file"):w.a.createElement("a",{href:"javascript:;",onClick:function(e){t.attachFile.click()},title:"Attach file"},w.a.createElement("i",{className:"material-icons secondary"},"attach_file")),w.a.createElement("textarea",{id:"sendMessage",placeholder:n,disabled:this.props.disabled,value:this.state.message,onChange:this.handleMessageTyping,onKeyPress:this.handleKeyPress,ref:function(e){t.messageEditArea=e},autoFocus:!0}),this.props.disabled?w.a.createElement("i",{className:"material-icons disabled"},"send"):w.a.createElement("a",{href:"javascript:;",onClick:this.handleSend,title:"Send"},w.a.createElement("i",{className:"material-icons"},"send")),w.a.createElement("input",{type:"file",ref:function(e){t.attachFile=e},onChange:this.handleAttachFile,style:{display:"none"}}),w.a.createElement("input",{type:"file",ref:function(e){t.attachImage=e},accept:"image/*",onChange:this.handleAttachImage,style:{display:"none"}}))}}])&&ca(t.prototype,n),a&&ca(t,a),o}(),ma=Object(S.injectIntl)(fa);function ga(e){return(ga="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function ba(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function va(e){return(va=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function ya(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _a(e,t){return(_a=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var wa=E.a.Drafty,Sa=Object(S.defineMessages)({online_now:{id:"online_now",defaultMessage:"online now"},last_seen:{id:"last_seen_timestamp",defaultMessage:"Last seen"},not_found:{id:"title_not_found",defaultMessage:"Not found"}});function Ea(e){if(e){var t=e.getExcessive()||"";return e.isJoiner("given")&&(t.includes("R")||t.includes("W"))}return!1}function ka(e){if(e){var t=e.getMissing()||"";return e.isJoiner("want")&&(t.includes("R")||t.includes("W"))}return!1}var Ma=function(e){function i(e){var t,n,a;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,i),n=this,(t=!(a=va(i).call(this,e))||"object"!==ga(a)&&"function"!=typeof a?ya(n):a).state=i.getDerivedStateFromProps(e,{}),t.leave=t.leave.bind(ya(t)),t.handleScrollReference=t.handleScrollReference.bind(ya(t)),t.handleScrollEvent=t.handleScrollEvent.bind(ya(t)),t.handleDescChange=t.handleDescChange.bind(ya(t)),t.handleSubsUpdated=t.handleSubsUpdated.bind(ya(t)),t.handleNewMessage=t.handleNewMessage.bind(ya(t)),t.handleAllMessagesReceived=t.handleAllMessagesReceived.bind(ya(t)),t.handleInfoReceipt=t.handleInfoReceipt.bind(ya(t)),t.handleImagePreview=t.handleImagePreview.bind(ya(t)),t.handleCloseImagePreview=t.handleCloseImagePreview.bind(ya(t)),t.handleFormResponse=t.handleFormResponse.bind(ya(t)),t.handleContextClick=t.handleContextClick.bind(ya(t)),t.handleShowContextMenuMessage=t.handleShowContextMenuMessage.bind(ya(t)),t.handleBackNavigation=t.handleBackNavigation.bind(ya(t)),t.handleNewChatAcceptance=t.handleNewChatAcceptance.bind(ya(t)),t.handleEnablePeer=t.handleEnablePeer.bind(ya(t)),t}var t,n,a;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&_a(e,t)}(i,w.a.Component),t=i,a=[{key:"getDerivedStateFromProps",value:function(t,e){var n={};if(t.topic){if(t.topic!=e.topic){var a=t.tinode.getTopic(t.topic);if(n={topic:t.topic,imagePreview:null,typingIndicator:!1,scrollPosition:0,fetchingMessages:!1},a){var o=[],r=[];t.connected&&a.subscribers(function(e){e.online&&e.user!=t.myUserId&&r.push(e)}),a.messages(function(e){e.deleted||o.push(e)}),Object.assign(n,{messages:o,onlineSubs:r}),a.public?Object.assign(n,{title:a.public.fn,avatar:L(a.public.photo)}):Object.assign(n,{title:"",avatar:null});var i=a.p2pPeerDesc();i?Object.assign(n,{peerMessagingDisabled:ka(i.acs)}):e.peerMessagingDisabled&&Object.assign(n,{peerMessagingDisabled:!1})}else Object.assign(n,{messages:[],onlineSubs:[],title:"",avatar:null,peerMessagingDisabled:!1})}}else n={messages:[],onlineSubs:[],topic:null,title:"",avatar:null,imagePreview:null,typingIndicator:!1,scrollPosition:0,fetchingMessages:!1,peerMessagingDisabled:!1};return t.acs?(t.acs.isWriter()!=e.isWriter&&(n.isWriter=!e.isWriter),t.acs.isReader()!=e.isReader&&(n.isReader=!e.isReader),!t.acs.isReader("given")!=e.readingBlocked&&(n.readingBlocked=!e.readingBlocked)):(e.isWriter&&(n.isWriter=!1),e.isReader&&(n.isReader=!1),e.readingBlocked||(e.readingBlocked=!0)),Ea(t.acs)==!e.unconformed&&(n.unconfirmed=!e.unconformed),!t.connected&&e.onlineSubs&&0<e.onlineSubs.length&&(n.onlineSubs=[]),n}}],(n=[{key:"componentDidMount",value:function(){this.messagesScroller&&this.messagesScroller.addEventListener("scroll",this.handleScrollEvent)}},{key:"componentWillUnmount",value:function(){this.leave(this.state.topic),this.messagesScroller&&this.messagesScroller.removeEventListener("scroll",this.handleScrollEvent)}},{key:"componentDidUpdate",value:function(e,t){var n=this;this.messagesScroller&&(t.topic!=this.state.topic||t.messages.length!=this.state.messages.length?this.messagesScroller.scrollTop=this.messagesScroller.scrollHeight-this.state.scrollPosition:e.viewportHeight>this.props.viewportHeight&&(this.messagesScroller.scrollTop+=e.viewportHeight-this.props.viewportHeight));var a=this.props.tinode.getTopic(this.state.topic);if(this.state.topic!=t.topic&&(t.topic&&(this.leave(t.topic),this.props.readTimerHandler(null)),a&&(a.onData=this.handleNewMessage,a.onAllMessagesReceived=this.handleAllMessagesReceived,a.onInfo=this.handleInfoReceipt,a.onMetaDesc=this.handleDescChange,a.onSubsUpdated=this.handleSubsUpdated,a.onPres=this.handleSubsUpdated)),a&&!a.isSubscribed()&&this.props.ready&&(this.state.topic!=t.topic||!e.ready)){var o=a.startMetaQuery().withLaterDesc().withLaterSub();this.state.isReader&&(o=o.withLaterData(24).withLaterDel(),this.setState({fetchingMessages:!0}));var r=this.props.newTopicParams&&this.props.newTopicParams._topicName==this.props.topic?this.props.newTopicParams:void 0;a.subscribe(o.build(),r).then(function(e){n.state.topic!=e.topic&&n.setState({topic:e.topic}),n.props.onNewTopicCreated(n.props.topic,e.topic),a.queuedMessages(function(e){!e._sending&&a.isSubscribed()&&a.publishMessage(e)})}).catch(function(e){console.log("Failed subscription to",n.state.topic),n.props.onError(e.message,"err");var t=i.getDerivedStateFromProps({},{});t.title=n.props.intl.formatMessage(Sa.not_found),n.setState(t)})}}},{key:"leave",value:function(e){var t=this;if(e){var n=this.props.tinode.getTopic(e);n&&n.isSubscribed()&&n.leave(!1).catch(function(){}).finally(function(){t.setState({fetchingMessages:!1}),n.onData=void 0,n.onAllMessagesReceived=void 0,n.onInfo=void 0,n.onMetaDesc=void 0,n.onSubsUpdated=void 0,n.onPres=void 0})}}},{key:"handleScrollReference",value:function(e){e&&(e.addEventListener("scroll",this.handleScrollEvent),this.messagesScroller=e)}},{key:"handleScrollEvent",value:function(e){var o=this;this.setState({scrollPosition:e.target.scrollHeight-e.target.scrollTop}),e.target.scrollTop<=0&&this.setState(function(e,t){var n={};if(!e.fetchingMessages){var a=o.props.tinode.getTopic(o.state.topic);a&&a.isSubscribed()&&a.msgHasMoreMessages()&&(n.fetchingMessages=!0,a.getMessagesPage(24).catch(function(e){o.setState({fetchingMessages:!1}),o.props.onError(e.message,"err")}))}return n})}},{key:"handleDescChange",value:function(e){e.public?this.setState({title:e.public.fn,avatar:L(e.public.photo)}):this.setState({title:"",avatar:null}),e.acs&&this.setState({isWriter:e.acs.isWriter(),isReader:e.acs.isReader(),readingBlocked:!e.acs.isReader("given"),unconfirmed:Ea(e.acs)})}},{key:"handleSubsUpdated",value:function(){var t=this;if(this.state.topic){var n=[],e=this.props.tinode.getTopic(this.state.topic);e.subscribers(function(e){e.online&&e.user!=t.props.myUserId&&n.push(e)});var a={onlineSubs:n},o=e.p2pPeerDesc();o?Object.assign(a,{peerMessagingDisabled:ka(o.acs)}):this.state.peerMessagingDisabled&&Object.assign(a,{peerMessagingDisabled:!1}),this.setState(a)}}},{key:"handleNewMessage",value:function(e){var t=this.props.tinode.getTopic(this.state.topic),n={messages:[]};(t.messages(function(e){e.deleted||(n.messages=n.messages.concat(e))}),e&&!e.deleted)&&(t.isNewMessage(e.seq)&&(n.scrollPosition=0),t.msgStatus(e)>=E.a.MESSAGE_STATUS_SENT&&e.from!=this.props.myUserId&&this.props.readTimerHandler(function(){t.noteRead(e.seq)}),this.props.onData(e));this.setState(n)}},{key:"handleAllMessagesReceived",value:function(e){this.setState({fetchingMessages:!1})}},{key:"handleInfoReceipt",value:function(e){switch(e.what){case"kp":clearTimeout(this.keyPressTimer);var t=this;this.keyPressTimer=setTimeout(function(){t.setState({typingIndicator:!1})},4e3),this.state.typingIndicator||this.setState({typingIndicator:!0});break;case"read":case"recv":this.forceUpdate();break;default:console.log("Other change in topic: ",e.what)}}},{key:"handleImagePreview",value:function(e){this.setState({imagePreview:e})}},{key:"handleCloseImagePreview",value:function(){this.setState({imagePreview:null})}},{key:"handleFormResponse",value:function(e,t,n){if("pub"==e)this.props.sendMessage(wa.attachJSON(wa.parse(t),n));else if("url"==e){var a=new URL(n.ref),o=a.searchParams;for(var r in n.resp)n.resp.hasOwnProperty(r)&&o.set(r,n.resp[r]);["name","seq"].map(function(e){n[e]&&o.set(e,n[e])}),o.set("uid",this.props.myUserId),a.search=o,window.open(a,"_blank")}else console.log("Unknown action in form",e)}},{key:"handleContextClick",value:function(e){e.preventDefault(),e.stopPropagation(),this.props.showContextMenu({topicName:this.state.topic,y:e.pageY,x:e.pageX})}},{key:"handleShowContextMenuMessage",value:function(e){e.topicName=this.state.topic;var t=["message_delete"],n=this.props.tinode.getTopic(e.topicName);if(n){var a=n.getAccessMode();a&&a.isDeleter()&&t.push("message_delete_hard")}this.props.showContextMenu(e,t)}},{key:"handleBackNavigation",value:function(){this.props.onHideMessagesView()}},{key:"handleNewChatAcceptance",value:function(e){this.props.onNewChat(this.state.topic,e)}},{key:"handleEnablePeer",value:function(){this.props.onChangePermissions(this.state.topic,f,this.state.topic)}},{key:"render",value:function(){var e,t=this.props.intl.formatMessage;if(this.state.topic){for(var n=this.props.tinode.getTopic(this.state.topic),a="grp"==n.getType(),o=[],r=null,i=null,s=0;s<this.state.messages.length;s++){var l=this.state.messages[s],c=null;s+1<this.state.messages.length&&(c=this.state.messages[s+1].from);var u="single";l.from==r?u=l.from==c?"middle":"last":l.from==c&&(u="first"),r=l.from;var d=!(l.from==this.props.myUserId),p=n.msgStatus(l),h=void 0,f=void 0,m=void 0;if(a){var g=n.userDesc(l.from);g&&g.public&&(h=g.public.fn,f=L(g.public.photo)),m=l.from,i="chat-box group"}else i="chat-box";o.push(w.a.createElement(jn,{tinode:this.props.tinode,content:l.content,mimeType:l.head?l.head.mime:null,timestamp:l.ts,response:d,seq:l.seq,userFrom:m,userName:h,userAvatar:f,sequence:u,received:p,uploader:l._uploader,viewportWidth:this.props.viewportWidth,showContextMenu:this.handleShowContextMenuMessage,onImagePreview:this.handleImagePreview,onFormResponse:this.handleFormResponse,onError:this.props.onError,key:l.seq}))}var b=null,v=this.props.tinode.getMeTopic().getContact(this.state.topic);v&&"p2p"==E.a.topicType(v.topic)&&(v.online?b=t(Sa.online_now):v.seen&&(b=t(Sa.last_seen)+": "+P(v.seen.when,this.props.intl.locale)));var y=this.state.avatar||!0,_=this.props.online?"online"+(this.state.typingIndicator?" typing":""):"offline";e=w.a.createElement("div",{id:"topic-view",className:this.props.hideSelf?"nodisplay":null},w.a.createElement("div",{id:"topic-caption-panel",className:"caption-panel"},this.props.displayMobile?w.a.createElement("a",{href:"javascript:;",id:"hide-message-view",onClick:this.handleBackNavigation},w.a.createElement("i",{className:"material-icons"},"arrow_back")):null,w.a.createElement("div",{className:"avatar-box"},w.a.createElement(R,{avatar:y,topic:this.state.topic,title:this.state.title}),w.a.createElement("span",{className:_})),w.a.createElement("div",{id:"topic-title-group"},w.a.createElement("div",{id:"topic-title",className:"panel-title"},this.state.title||w.a.createElement("i",null,w.a.createElement(S.FormattedMessage,{id:"unnamed_topic",defaultMessage:"Unnamed"}))),w.a.createElement("div",{id:"topic-last-seen"},b)),a?w.a.createElement(Fn,{subscribers:this.state.onlineSubs}):w.a.createElement("div",{id:"topic-users"}),w.a.createElement("div",null,w.a.createElement("a",{href:"javascript:;",onClick:this.handleContextClick},w.a.createElement("i",{className:"material-icons"},"more_vert")))),this.props.displayMobile?w.a.createElement(Ye,{level:this.props.errorLevel,text:this.props.errorText,onClearError:this.props.onError}):null,w.a.createElement(ta,{show:this.state.fetchingMessages}),w.a.createElement("div",{id:"messages-container"},w.a.createElement("div",{id:"messages-panel",ref:this.handleScrollReference},w.a.createElement("ul",{id:"scroller",className:i},o)),this.state.isReader?null:w.a.createElement("div",{id:"write-only-background"},this.state.readingBlocked?w.a.createElement("div",{id:"write-only-note"},w.a.createElement(S.FormattedMessage,{id:"messages_not_readable",defaultMessage:"no access to messages"})):null)),this.state.peerMessagingDisabled&&!this.state.unconfirmed?w.a.createElement("div",{id:"peer-messaging-disabled-note"},w.a.createElement("i",{className:"material-icons secondary"},"block")," ",w.a.createElement(S.FormattedMessage,{id:"peers_messaging_disabled",defaultMessage:"Peer's messaging is disabled."})," ",w.a.createElement("a",{href:"javascript:;",onClick:this.handleEnablePeer},w.a.createElement(S.FormattedMessage,{id:"enable_peers_messaging",defaultMessage:"Enable"})),"."):null,this.state.unconfirmed?w.a.createElement(Yn,{onAction:this.handleNewChatAcceptance}):w.a.createElement(ma,{tinode:this.props.tinode,topic:this.props.topic,disabled:!this.state.isWriter,sendMessage:this.props.sendMessage,onError:this.props.onError}),this.state.imagePreview?w.a.createElement(Gn,{content:this.state.imagePreview,onClose:this.handleCloseImagePreview}):null)}else e=w.a.createElement(sa,{hideSelf:this.props.hideSelf,serverVersion:this.props.serverVersion,serverAddress:this.props.serverAddress});return e}}])&&ba(t.prototype,n),a&&ba(t,a),i}(),Ca=Object(S.injectIntl)(Ma);function Ta(e){return(Ta="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Oa(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function Pa(e,t){return!t||"object"!==Ta(t)&&"function"!=typeof t?function(e){if(void 0!==e)return e;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}(e):t}function ja(e){return(ja=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function Na(e,t){return(Na=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var Aa=function(e){function t(){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),Pa(this,ja(t).apply(this,arguments))}var n,a,o;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&Na(e,t)}(t,w.a.PureComponent),n=t,(a=[{key:"render",value:function(){return w.a.createElement("div",null,w.a.createElement("a",{href:"javascript:;",onClick:this.props.onNewTopic},w.a.createElement("i",{className:"material-icons"},"chat"))," ",w.a.createElement("a",{href:"javascript:;",onClick:this.props.onSettings},w.a.createElement("i",{className:"material-icons"},"settings")))}}])&&Oa(n.prototype,a),o&&Oa(n,o),t}();function xa(e){return(xa="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Da(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function Ua(e,t){return!t||"object"!==xa(t)&&"function"!=typeof t?function(e){if(void 0!==e)return e;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}(e):t}function Ra(e){return(Ra=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function Fa(e,t){return(Fa=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var Ia=function(e){function t(){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),Ua(this,Ra(t).apply(this,arguments))}var n,a,o;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&Fa(e,t)}(t,w.a.PureComponent),n=t,(a=[{key:"render",value:function(){return w.a.createElement("div",null,w.a.createElement("a",{href:"javascript:;",onClick:this.props.onSignUp},w.a.createElement("i",{className:"material-icons"},"person_add"))," ",w.a.createElement("a",{href:"javascript:;",onClick:this.props.onSettings},w.a.createElement("i",{className:"material-icons"},"settings")))}}])&&Da(n.prototype,a),o&&Da(n,o),t}();function La(e){return(La="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function qa(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function Ha(e,t){return!t||"object"!==La(t)&&"function"!=typeof t?function(e){if(void 0!==e)return e;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}(e):t}function Wa(e){return(Wa=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function Ga(e,t){return(Ga=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var Va=function(e){function t(){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),Ha(this,Wa(t).apply(this,arguments))}var n,a,o;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&Ga(e,t)}(t,w.a.PureComponent),n=t,(a=[{key:"render",value:function(){return w.a.createElement("div",{id:"side-caption-panel",className:"caption-panel"},w.a.createElement("div",{id:"self-avatar",className:"avatar-box"},w.a.createElement(R,{avatar:this.props.avatar,topic:this.props.myUserId,title:this.props.title})),w.a.createElement("div",{id:"sidepanel-title",className:"panel-title"},this.props.title),"login"===this.props.state?w.a.createElement(Ia,{onSignUp:this.props.onSignUp,onSettings:this.props.onSettings}):"contacts"===this.props.state?w.a.createElement(Aa,{onNewTopic:this.props.onNewTopic,onSettings:this.props.onSettings}):null,this.props.onCancel?w.a.createElement(Ge,{onCancel:this.props.onCancel}):null)}}])&&qa(n.prototype,a),o&&qa(n,o),t}();function Ba(e){return(Ba="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Ka(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function za(e){return(za=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function Ja(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Ya(e,t){return(Ya=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var Qa=Object(S.defineMessages)({archived_contacts_title:{id:"archived_contacts",defaultMessage:"Archived contacts ({count})"}}),Xa=function(e){function o(e){var t,n,a;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,o),n=this,(t=!(a=za(o).call(this,e))||"object"!==Ba(a)&&"function"!=typeof a?Ja(n):a).handleAction=t.handleAction.bind(Ja(t)),t.state=o.getDerivedStateFromProps(e,{}),t}var t,n,a;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&Ya(e,t)}(o,w.a.Component),t=o,a=[{key:"getDerivedStateFromProps",value:function(t,e){var n=[],a=0,o=0;return t.chatList.map(function(e){e.private&&e.private.arch?t.archive?n.push(e):o++:t.archive||(n.push(e),a+=0<e.unread?1:0)}),n.sort(function(e,t){return(t.touched||0)-(e.touched||0)}),0<o&&n.push({action:"archive",title:Qa.archived_contacts_title,values:{count:o}}),Wt(a),{contactList:n,archivedCount:o}}}],(n=[{key:"handleAction",value:function(e){this.props.onShowArchive()}},{key:"render",value:function(){var t=this;return w.a.createElement(S.FormattedHTMLMessage,{id:"contacts_not_found",defaultMessage:"You have no chats<br />¯∖_(ツ)_/¯"},function(e){return w.a.createElement(Fe,{connected:t.props.connected,contacts:t.state.contactList,emptyListMessage:e,topicSelected:t.props.topicSelected,myUserId:t.props.myUserId,showOnline:!0,showUnread:!0,onTopicSelected:t.props.onTopicSelected,showContextMenu:t.props.showContextMenu,onAction:t.handleAction})})}}])&&Ka(t.prototype,n),a&&Ka(t,a),o}();function $a(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}var Za=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}var t,n,a;return t=e,a=[{key:"setObject",value:function(e,t){localStorage.setItem(e,JSON.stringify(t))}},{key:"getObject",value:function(e){var t=localStorage.getItem(e);return t&&JSON.parse(t)}},{key:"updateObject",value:function(e,t){var n=this.getObject(e);this.setObject(e,Object.assign(n||{},t))}},{key:"removeItem",value:function(e){localStorage.removeItem(e)}}],(n=null)&&$a(t.prototype,n),a&&$a(t,a),e}();function eo(e){return(eo="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function to(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function no(e){return(no=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function ao(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function oo(e,t){return(oo=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var ro=function(e){function o(e){var t,n,a;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,o),n=this,(t=!(a=no(o).call(this,e))||"object"!==eo(a)&&"function"!=typeof a?ao(n):a).state={login:"",password:"",email:"",fn:"",imageDataUrl:null,errorCleared:!1,saveToken:Za.getObject("keep-logged-in")},t.handleLoginChange=t.handleLoginChange.bind(ao(t)),t.handlePasswordChange=t.handlePasswordChange.bind(ao(t)),t.handleEmailChange=t.handleEmailChange.bind(ao(t)),t.handleFnChange=t.handleFnChange.bind(ao(t)),t.handleImageChanged=t.handleImageChanged.bind(ao(t)),t.handleToggleSaveToken=t.handleToggleSaveToken.bind(ao(t)),t.handleSubmit=t.handleSubmit.bind(ao(t)),t}var t,n,a;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&oo(e,t)}(o,w.a.PureComponent),t=o,(n=[{key:"handleLoginChange",value:function(e){this.setState({login:e.target.value})}},{key:"handlePasswordChange",value:function(e){this.setState({password:e})}},{key:"handleEmailChange",value:function(e){this.setState({email:e.target.value})}},{key:"handleFnChange",value:function(e){this.setState({fn:e.target.value})}},{key:"handleImageChanged",value:function(e){this.setState({imageDataUrl:e})}},{key:"handleToggleSaveToken",value:function(){Za.setObject("keep-logged-in",!this.state.saveToken),this.setState({saveToken:!this.state.saveToken})}},{key:"handleSubmit",value:function(e){e.preventDefault(),this.setState({errorCleared:!1}),this.props.onCreateAccount(this.state.login.trim(),this.state.password.trim(),Gt(this.state.fn,this.state.imageDataUrl),{meth:"email",val:this.state.email})}},{key:"render",value:function(){var t=this,e="blue";return this.props.disabled&&(e+=" disabled"),w.a.createElement("form",{className:"panel-form-column",onSubmit:this.handleSubmit},w.a.createElement("div",{className:"panel-form-row"},w.a.createElement("div",{className:"panel-form-column"},w.a.createElement(S.FormattedMessage,{id:"login_prompt"},function(e){return w.a.createElement("input",{type:"text",placeholder:e,autoComplete:"user-name",value:t.state.login,onChange:t.handleLoginChange,required:!0,autoFocus:!0})}),w.a.createElement(S.FormattedMessage,{id:"password_prompt"},function(e){return w.a.createElement(wt,{placeholder:e,autoComplete:"new-password",value:t.state.password,onFinished:t.handlePasswordChange,required:!0})})),w.a.createElement($,{onImageChanged:this.handleImageChanged,onError:this.props.onError})),w.a.createElement("div",{className:"panel-form-row"},w.a.createElement(S.FormattedMessage,{id:"full_name_prompt",defaultMessage:"Full name, e.g. John Doe"},function(e){return w.a.createElement("input",{type:"text",placeholder:e,autoComplete:"name",value:t.state.fn,onChange:t.handleFnChange,required:!0})})),w.a.createElement("div",{className:"panel-form-row"},w.a.createElement(S.FormattedMessage,{id:"email_prompt",defaultMessage:"Email, e.g. jdoe@example.com"},function(e){return w.a.createElement("input",{type:"email",placeholder:e,autoComplete:"email",value:t.state.email,onChange:t.handleEmailChange,required:!0})})),w.a.createElement("div",{className:"panel-form-row"},w.a.createElement(oe,{id:"save-token",name:"save-token",checked:this.state.saveToken,onChange:this.handleToggleSaveToken}),w.a.createElement(S.FormattedMessage,{id:"stay_logged_in"},function(e){return w.a.createElement("label",{htmlFor:"save-token"}," ",e)})),w.a.createElement("div",{className:"dialog-buttons"},w.a.createElement("button",{className:e,type:"submit"},w.a.createElement(S.FormattedMessage,{id:"button_sign_up",defaultMessage:"Sign up"}))))}}])&&to(t.prototype,n),a&&to(t,a),o}();function io(e){return(io="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function so(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function lo(e){return(lo=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function co(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function uo(e,t){return(uo=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var po=function(e){function s(e){var t,n,a;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,s),n=this;var o=(t=!(a=lo(s).call(this,e))||"object"!==io(a)&&"function"!=typeof a?co(n):a).props.tinode.getMeTopic(),r=o?o.getDefaultAccess():null,i=t.props.tinode.getFndTopic();return t.state={fullName:o.public?o.public.fn:void 0,avatar:L(o.public?o.public.photo:null),auth:r?r.auth:null,anon:r?r.anon:null,fndSubscribed:!1,tags:i.tags(),showPermissionEditorFor:void 0,previousOnTags:i.onTagsUpdated},t.tnNewTags=t.tnNewTags.bind(co(t)),t.handleFullNameUpdate=t.handleFullNameUpdate.bind(co(t)),t.handlePasswordUpdate=t.handlePasswordUpdate.bind(co(t)),t.handleImageChanged=t.handleImageChanged.bind(co(t)),t.handleCheckboxClick=t.handleCheckboxClick.bind(co(t)),t.handleLaunchPermissionsEditor=t.handleLaunchPermissionsEditor.bind(co(t)),t.handleHidePermissionsEditor=t.handleHidePermissionsEditor.bind(co(t)),t.handlePermissionsChanged=t.handlePermissionsChanged.bind(co(t)),t.handleTagsUpdated=t.handleTagsUpdated.bind(co(t)),t}var t,n,a;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&uo(e,t)}(s,w.a.Component),t=s,(n=[{key:"componentDidMount",value:function(){var t=this,e=this.props.tinode.getFndTopic();e.onTagsUpdated=this.tnNewTags,e.isSubscribed()||e.subscribe(e.startMetaQuery().withTags().build()).then(function(e){t.setState({fndSubscribed:!0})}).catch(function(e){t.props.onError(e.message,"err")})}},{key:"componentWillUnmount",value:function(){var e=this.props.tinode.getFndTopic();e.onTagsUpdated=this.state.previousOnTags,e.isSubscribed()&&this.state.fndSubscribed&&e.leave()}},{key:"tnNewTags",value:function(e){this.setState({tags:e})}},{key:"handleFullNameUpdate",value:function(e){this.setState({fullName:e}),this.props.onUpdateAccount(void 0,Gt(e,null))}},{key:"handlePasswordUpdate",value:function(e){this.setState({password:e}),this.props.onUpdateAccount(e)}},{key:"handleImageChanged",value:function(e){this.setState({avatar:e}),this.props.onUpdateAccount(void 0,Gt(null,e))}},{key:"handleCheckboxClick",value:function(e,t){"sound"==e?this.props.onToggleMessageSounds(t):"alert"==e&&this.props.onTogglePushNotifications(t)}},{key:"handleLaunchPermissionsEditor",value:function(e){this.setState({showPermissionEditorFor:e,editedPermissions:this.state[e]})}},{key:"handleHidePermissionsEditor",value:function(){this.setState({showPermissionEditorFor:void 0})}},{key:"handlePermissionsChanged",value:function(e){var t={};t[this.state.showPermissionEditorFor]=e,this.props.onUpdateAccount(void 0,void 0,t);var n={showPermissionEditorFor:void 0};n[this.state.showPermissionEditorFor]=e,this.setState(n)}},{key:"handleTagsUpdated",value:function(e){arrayEqual(this.state.tags.slice(0),e.slice(0))||this.props.onUpdateTags(e)}},{key:"render",value:function(){var t=this,n=[];return this.state.tags.map(function(e){n.push(w.a.createElement("span",{className:"badge",key:n.length},e))}),0==n.length&&(n=w.a.createElement("i",null,w.a.createElement(S.FormattedMessage,{id:"tags_not_found"}))),w.a.createElement(w.a.Fragment,null,this.state.showPermissionEditorFor?w.a.createElement(Ht,{mode:this.state.editedPermissions,skip:"O",onSubmit:this.handlePermissionsChanged,onCancel:this.handleHidePermissionsEditor}):w.a.createElement("div",{id:"edit-account",className:"scrollable-panel"},w.a.createElement("div",{className:"panel-form-row"},w.a.createElement("div",{className:"panel-form-column"},w.a.createElement("div",null,w.a.createElement("label",{className:"small"},w.a.createElement(S.FormattedMessage,{id:"label_your_name",defaultMessage:"Your name"}))),w.a.createElement("div",null,w.a.createElement(S.FormattedMessage,{id:"full_name_prompt"},function(e){return w.a.createElement(Tt,{placeholder:e,value:t.state.fullName,onFinished:t.handleFullNameUpdate})})),w.a.createElement("div",null,w.a.createElement("label",{className:"small"},w.a.createElement(S.FormattedMessage,{id:"label_password",defaultMessage:"Password"}))),w.a.createElement("div",null,w.a.createElement(S.FormattedMessage,{id:"password_unchanged_prompt",defaultMessage:"Unchanged"},function(e){return w.a.createElement(Tt,{placeholder:e,type:"password",onFinished:t.handlePasswordUpdate})}))),w.a.createElement($,{avatar:this.state.avatar,uid:this.props.myUserId,title:this.state.fullName,onImageChanged:this.handleImageChanged,onError:this.props.onError})),w.a.createElement("div",{className:"hr"}),w.a.createElement("div",{className:"panel-form-column"},w.a.createElement("div",{className:"panel-form-row"},w.a.createElement("label",null,w.a.createElement(S.FormattedMessage,{id:"label_user_id",defaultMessage:"Address:"})),w.a.createElement("tt",null,this.props.myUserId)),w.a.createElement("div",null,w.a.createElement("label",{className:"small"},w.a.createElement(S.FormattedMessage,{id:"label_default_access_mode",defaultMessage:"Default access mode:"}))),w.a.createElement("div",{className:"quoted"},w.a.createElement("div",null,"Auth: ",w.a.createElement("tt",{className:"clickable",onClick:this.handleLaunchPermissionsEditor.bind(this,"auth")},this.state.auth)),w.a.createElement("div",null,"Anon: ",w.a.createElement("tt",{className:"clickable",onClick:this.handleLaunchPermissionsEditor.bind(this,"anon")},this.state.anon)))),w.a.createElement("div",{className:"hr"}),w.a.createElement("div",{className:"panel-form-row"},w.a.createElement("label",{htmlFor:"message-sound"},w.a.createElement(S.FormattedMessage,{id:"label_message_sound",defaultMessage:"Message sound:"})),w.a.createElement(oe,{name:"sound",id:"message-sound",checked:this.props.messageSounds,onChange:this.handleCheckboxClick})),w.a.createElement("div",{className:"panel-form-row"},w.a.createElement("label",{htmlFor:"desktop-alerts"},this.props.desktopAlertsEnabled?w.a.createElement(S.FormattedMessage,{id:"label_push_notifications",defaultMessage:"Notification alerts:"}):w.a.createElement(S.FormattedMessage,{id:"label_push_notifications_disabled",defaultMessage:"Notification alerts (requires HTTPS):"})),w.a.createElement(oe,{name:"alert",id:"desktop-alerts",checked:this.props.desktopAlerts,onChange:this.props.desktopAlertsEnabled?this.handleCheckboxClick:null})),w.a.createElement("div",{className:"hr"}),w.a.createElement(S.FormattedMessage,{id:"title_tag_manager",defaultMessage:"Tags (user discovery)"},function(e){return w.a.createElement(Yt,{title:e,activated:!1,tags:t.state.tags,onSubmit:t.handleTagsUpdated})}),w.a.createElement("div",{className:"hr"}),w.a.createElement("div",{className:"panel-form-column"},w.a.createElement("a",{href:"javascript:;",className:"red flat-button",onClick:this.props.onLogout},w.a.createElement("i",{className:"material-icons"},"exit_to_app")," ",w.a.createElement(S.FormattedMessage,{id:"button_logout",defaultMessage:"Logout"})))))}}])&&so(t.prototype,n),a&&so(t,a),s}();function ho(e){return(ho="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function fo(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function mo(e){return(mo=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function go(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function bo(e,t){return(bo=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var vo=function(e){function o(e){var t,n,a;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,o),n=this,(t=!(a=mo(o).call(this,e))||"object"!==ho(a)&&"function"!=typeof a?go(n):a).state={login:e.login,password:"",hostName:e.serverAddress,saveToken:Za.getObject("keep-logged-in")},t.handleLoginChange=t.handleLoginChange.bind(go(t)),t.handlePasswordChange=t.handlePasswordChange.bind(go(t)),t.handleToggleSaveToken=t.handleToggleSaveToken.bind(go(t)),t.handleSubmit=t.handleSubmit.bind(go(t)),t}var t,n,a;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&bo(e,t)}(o,w.a.Component),t=o,(n=[{key:"handleLoginChange",value:function(e){this.setState({login:e.target.value})}},{key:"handlePasswordChange",value:function(e){this.setState({password:e.target.value})}},{key:"handleToggleSaveToken",value:function(){Za.setObject("keep-logged-in",!this.state.saveToken),this.setState({saveToken:!this.state.saveToken})}},{key:"handleSubmit",value:function(e){e.preventDefault(),this.props.onLogin(this.state.login.trim(),this.state.password.trim())}},{key:"render",value:function(){var t=this,e="blue";return this.props.disabled&&(e+=" disabled"),w.a.createElement("form",{id:"login-form",onSubmit:this.handleSubmit},w.a.createElement(S.FormattedMessage,{id:"login_prompt",defaultMessage:"Login"},function(e){return w.a.createElement("input",{type:"text",id:"inputLogin",placeholder:e,autoComplete:"username",value:t.state.login,onChange:t.handleLoginChange,required:!0,autoFocus:!0})}),w.a.createElement(S.FormattedMessage,{id:"password_prompt",defaultMessage:"Password"},function(e){return w.a.createElement(wt,{type:"password",id:"inputPassword",placeholder:e,autoComplete:"current-password",value:t.state.password,onChange:t.handlePasswordChange,required:!0})}),w.a.createElement("div",{className:"panel-form-row"},w.a.createElement(oe,{id:"save-token",name:"save-token",checked:this.state.saveToken,onChange:this.handleToggleSaveToken}),w.a.createElement("label",{htmlFor:"save-token"}," ",w.a.createElement(S.FormattedMessage,{id:"stay_logged_in",defaultMessage:"Stay logged in"})),w.a.createElement("a",{href:"#reset"},w.a.createElement(S.FormattedMessage,{id:"forgot_password_link",defaultMessage:"Forgot password?"}))),w.a.createElement("div",{className:"dialog-buttons"},w.a.createElement("button",{className:e,type:"submit"},w.a.createElement(S.FormattedMessage,{id:"button_sign_in",defaultMessage:"Sign in"}))))}}])&&fo(t.prototype,n),a&&fo(t,a),o}();function yo(e){return(yo="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function _o(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function wo(e){return(wo=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function So(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Eo(e,t){return(Eo=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var ko=Object(S.defineMessages)({invalid_id:{id:"error_invalid_id",defaultMessage:"Invalid ID"}}),Mo=function(e){function o(e){var t,n,a;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,o),n=this,(t=!(a=wo(o).call(this,e))||"object"!==yo(a)&&"function"!=typeof a?So(n):a).state={groupId:""},t.handleChange=t.handleChange.bind(So(t)),t.handleKeyPress=t.handleKeyPress.bind(So(t)),t.handleSubmit=t.handleSubmit.bind(So(t)),t}var t,n,a;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&Eo(e,t)}(o,w.a.PureComponent),t=o,(n=[{key:"handleChange",value:function(e){this.setState({groupId:e.target.value})}},{key:"handleKeyPress",value:function(e){"Enter"===e.key&&this.handleSubmit(e)}},{key:"handleSubmit",value:function(e){if(e.preventDefault(),this.state.groupId){var t=this.state.groupId.trim();3<t.length&&("usr"==t.substr(0,3)||"grp"==t.substr(0,3))?this.props.onSubmit(t):this.props.onError(this.props.intl.formatMessage(ko.invalid_id),"err")}}},{key:"render",value:function(){var t=this;return w.a.createElement("div",{className:"panel-form"},w.a.createElement("div",{className:"panel-form-row"},w.a.createElement(S.FormattedMessage,{id:"group_user_id_prompt",defaultMessage:"Group or User ID"},function(e){return w.a.createElement("input",{type:"text",placeholder:e,value:t.state.groupId,onChange:t.handleChange,onKeyPress:t.handleKeyPress,required:!0})})),w.a.createElement("div",{className:"dialog-buttons"},w.a.createElement("button",{className:"blue",onClick:this.handleSubmit},w.a.createElement(S.FormattedMessage,{id:"button_subscribe",defaultMessage:"Subscribe"}))))}}])&&_o(t.prototype,n),a&&_o(t,a),o}(),Co=Object(S.injectIntl)(Mo);function To(e){return(To="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Oo(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function Po(e){return(Po=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function jo(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function No(e,t){return(No=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var Ao=function(e){function o(e){var t,n,a;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,o),n=this,(t=!(a=Po(o).call(this,e))||"object"!==To(a)&&"function"!=typeof a?jo(n):a).state={fn:"",private:"",imageDataUrl:null,tags:[]},t.handleFnChange=t.handleFnChange.bind(jo(t)),t.handlePrivateChange=t.handlePrivateChange.bind(jo(t)),t.handleImageChanged=t.handleImageChanged.bind(jo(t)),t.handleTagsChanged=t.handleTagsChanged.bind(jo(t)),t.handleTagsChanged=t.handleTagsChanged.bind(jo(t)),t.handleSubmit=t.handleSubmit.bind(jo(t)),t}var t,n,a;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&No(e,t)}(o,w.a.PureComponent),t=o,(n=[{key:"handleFnChange",value:function(e){this.setState({fn:e.target.value})}},{key:"handlePrivateChange",value:function(e){this.setState({private:e.target.value})}},{key:"handleImageChanged",value:function(e){this.setState({imageDataUrl:e})}},{key:"handleTagsChanged",value:function(e){this.setState({tags:e})}},{key:"handleSubmit",value:function(e){e.preventDefault(),this.state.fn&&this.state.fn.trim()&&this.props.onSubmit(this.state.fn.trim(),this.state.imageDataUrl,this.state.private.trim(),this.state.tags)}},{key:"render",value:function(){var t=this,e="blue";return this.props.disabled&&(e+=" disabled"),w.a.createElement("form",{className:"panel-form",onSubmit:this.handleSubmit},w.a.createElement("div",{className:"panel-form-row"},w.a.createElement("div",{className:"panel-form-column"},w.a.createElement("label",{className:"small",htmlFor:"new-topic-fn"},w.a.createElement(S.FormattedMessage,{id:"label_topic_name"})),w.a.createElement(S.FormattedMessage,{id:"topic_name_editing_placeholder",defaultMessage:"Freeform name of the group"},function(e){return w.a.createElement("input",{type:"text",id:"new-topic-fn",placeholder:e,value:t.state.fn,onChange:t.handleFnChange,autoFocus:!0,required:!0})}),w.a.createElement("br",null),w.a.createElement("label",{className:"small",htmlFor:"new-topic-priv"},w.a.createElement(S.FormattedMessage,{id:"label_private"})),w.a.createElement(S.FormattedMessage,{id:"private_editing_placeholder"},function(e){return w.a.createElement("input",{type:"text",id:"new-topic-priv",placeholder:e,value:t.state.private,onChange:t.handlePrivateChange})})),w.a.createElement($,{onError:this.props.onError,onImageChanged:this.handleImageChanged})),w.a.createElement(S.FormattedMessage,{id:"title_tag_manager"},function(e){return w.a.createElement(Yt,{tags:t.state.tags,activated:!0,onTagsChanged:t.handleTagsChanged,title:e})}),w.a.createElement("div",{className:"dialog-buttons"},w.a.createElement("button",{className:e},w.a.createElement(S.FormattedMessage,{id:"button_create",defaultMessage:"Create"}))))}}])&&Oo(t.prototype,n),a&&Oo(t,a),o}();function xo(e){return(xo="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Do(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function Uo(e){return(Uo=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function Ro(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Fo(e,t){return(Fo=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var Io=function(e){function o(e){var t,n,a;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,o),n=this,(t=!(a=Uo(o).call(this,e))||"object"!==xo(a)&&"function"!=typeof a?Ro(n):a).state={edited:!1,search:""},t.handleSearchChange=t.handleSearchChange.bind(Ro(t)),t.handleSearch=t.handleSearch.bind(Ro(t)),t.handleClear=t.handleClear.bind(Ro(t)),t.handleKeyDown=t.handleKeyDown.bind(Ro(t)),t}var t,n,a;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&Fo(e,t)}(o,w.a.PureComponent),t=o,(n=[{key:"componentWillUnmount",value:function(){this.state.edited&&(this.setState({search:"",edited:!1}),this.props.onSearchContacts(E.a.DEL_CHAR))}},{key:"handleSearchChange",value:function(e){this.setState({search:e.target.value})}},{key:"handleSearch",value:function(e){e.preventDefault();var t=this.state.search.trim();this.setState({edited:0<t.length}),this.props.onSearchContacts(0<t.length?t:E.a.DEL_CHAR)}},{key:"handleClear",value:function(){this.state.edited&&this.props.onSearchContacts(E.a.DEL_CHAR),this.setState({search:"",edited:!1})}},{key:"handleKeyDown",value:function(e){"Enter"===e.key?this.handleSearch(e):"Escape"===e.key&&this.handleClear()}},{key:"render",value:function(){var t=this;return w.a.createElement("div",{className:"panel-form"},w.a.createElement("div",{className:"panel-form-row"},w.a.createElement("i",{className:"material-icons search"},"search"),w.a.createElement(S.FormattedMessage,{id:"search_placeholder",defaultMessage:"List like email:alice@example.com, tel:17025550003..."},function(e){return w.a.createElement("input",{className:"search",type:"text",placeholder:e,value:t.state.search,onChange:t.handleSearchChange,onKeyDown:t.handleKeyDown,required:!0,autoFocus:!0})}),w.a.createElement("a",{href:"javascript:;",onClick:this.handleClear},w.a.createElement("i",{className:"material-icons"},"close"))))}}])&&Do(t.prototype,n),a&&Do(t,a),o}();function Lo(e){return(Lo="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function qo(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function Ho(e){return(Ho=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function Wo(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Go(e,t){return(Go=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var Vo=function(e){function o(e){var t,n,a;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,o),n=this,(t=!(a=Ho(o).call(this,e))||"object"!==Lo(a)&&"function"!=typeof a?Wo(n):a).state={tabSelected:"p2p"},t.handleTabClick=t.handleTabClick.bind(Wo(t)),t.handleContactSelected=t.handleContactSelected.bind(Wo(t)),t.handleNewGroupSubmit=t.handleNewGroupSubmit.bind(Wo(t)),t.handleGroupByID=t.handleGroupByID.bind(Wo(t)),t}var t,n,a;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&Go(e,t)}(o,w.a.Component),t=o,(n=[{key:"componentDidMount",value:function(){this.props.onInitFind()}},{key:"handleTabClick",value:function(e){e.preventDefault(),b.navigateTo(b.addUrlParam(window.location.hash,"tab",e.currentTarget.dataset.id)),this.setState({tabSelected:e.currentTarget.dataset.id})}},{key:"handleContactSelected",value:function(e){"p2p"===this.state.tabSelected&&(b.navigateTo(b.removeUrlParam(window.location.hash,"tab")),this.props.onCreateTopic(e,void 0))}},{key:"handleNewGroupSubmit",value:function(e,t,n,a){b.navigateTo(b.removeUrlParam(window.location.hash,"tab")),this.props.onCreateTopic(void 0,Gt(e,t),n,a)}},{key:"handleGroupByID",value:function(e){b.navigateTo(b.removeUrlParam(window.location.hash,"tab")),this.props.onCreateTopic(e)}},{key:"render",value:function(){var t=this;return w.a.createElement("div",{className:"flex-column"},w.a.createElement("ul",{className:"tabbar"},w.a.createElement("li",{className:"p2p"===this.state.tabSelected?"active":null},w.a.createElement("a",{href:"javascript:;","data-id":"p2p",onClick:this.handleTabClick},w.a.createElement(S.FormattedMessage,{id:"tabtitle_find_user",defaultMessage:"find"}))),w.a.createElement("li",{className:"grp"===this.state.tabSelected?"active":null},w.a.createElement("a",{href:"javascript:;","data-id":"grp",onClick:this.handleTabClick},w.a.createElement(S.FormattedMessage,{id:"tabtitle_new_group",defaultMessage:"new group"}))),w.a.createElement("li",{className:"byid"===this.state.tabSelected?"active":null},w.a.createElement("a",{href:"javascript:;","data-id":"byid",onClick:this.handleTabClick},w.a.createElement(S.FormattedMessage,{id:"tabtitle_group_by_id",defaultMessage:"by id"})))),"grp"===this.state.tabSelected?w.a.createElement(Ao,{onSubmit:this.handleNewGroupSubmit}):"byid"===this.state.tabSelected?w.a.createElement(Co,{onSubmit:this.handleGroupByID,onError:this.props.onError}):w.a.createElement("div",{className:"flex-column"},w.a.createElement(Io,{type:"p2p",onSearchContacts:this.props.onSearchContacts}),w.a.createElement(S.FormattedMessage,{id:"search_for_contacts",defaultMessage:"Use search to find contacts"},function(e){return w.a.createElement(Fe,{contacts:t.props.searchResults,myUserId:t.props.myUserId,emptyListMessage:e,showOnline:!1,showUnread:!1,showContextMenu:!1,onTopicSelected:t.handleContactSelected})})))}}])&&qo(t.prototype,n),a&&qo(t,a),o}();function Bo(e){return(Bo="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Ko(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function zo(e){return(zo=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function Jo(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Yo(e,t){return(Yo=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var Qo=function(e){function o(e){var t,n,a;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,o),n=this,(t=!(a=zo(o).call(this,e))||"object"!==Bo(a)&&"function"!=typeof a?Jo(n):a).state={email:"",password:""},t.handleSubmit=t.handleSubmit.bind(Jo(t)),t.handleEmailChange=t.handleEmailChange.bind(Jo(t)),t.handlePasswordChange=t.handlePasswordChange.bind(Jo(t)),t}var t,n,a;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&Yo(e,t)}(o,w.a.PureComponent),t=o,(n=[{key:"componentDidMount",value:function(){var e=b.parseUrlHash(window.location.hash);this.setState({token:e.params.token,scheme:e.params.scheme})}},{key:"handleSubmit",value:function(e){e.preventDefault(),this.state.token?this.props.onReset(this.state.scheme,this.state.password.trim(),this.state.token):this.props.onRequest("email",this.state.email.trim())}},{key:"handleEmailChange",value:function(e){this.setState({email:e.target.value})}},{key:"handlePasswordChange",value:function(e){this.setState({password:e.target.value})}},{key:"render",value:function(){var t=this,e=this.state.token&&this.state.scheme;return w.a.createElement("form",{id:"password-reset-form",onSubmit:this.handleSubmit},e?w.a.createElement(S.FormattedMessage,{id:"new_password_placeholder",defaultMessage:"Enter new password"},function(e){return w.a.createElement(wt,{placeholder:e,autoComplete:"new-password",value:t.state.password,required:!0,autoFocus:!0,onChange:t.handlePasswordChange})}):w.a.createElement(w.a.Fragment,null,w.a.createElement("label",{htmlFor:"inputEmail"},w.a.createElement(S.FormattedMessage,{id:"label_reset_password",defaultMessage:"Send a password reset email:"})),w.a.createElement(S.FormattedMessage,{id:"credential_email_prompt",defaultMessage:"Your registration email"},function(e){return w.a.createElement("input",{type:"email",id:"inputEmail",placeholder:e,autoComplete:"email",value:t.state.email,onChange:t.handleEmailChange,required:!0,autoFocus:!0})})),w.a.createElement("div",{className:"dialog-buttons"},w.a.createElement("button",{className:"blue",type:"submit"},e?w.a.createElement(S.FormattedMessage,{id:"button_reset",defaultMessage:"Reset"}):w.a.createElement(S.FormattedMessage,{id:"button_send_request",defaultMessage:"Send request"}))))}}])&&Ko(t.prototype,n),a&&Ko(t,a),o}();function Xo(e){return(Xo="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function $o(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function Zo(e){return(Zo=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function er(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function tr(e,t){return(tr=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var nr=function(e){function o(e){var t,n,a;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,o),n=this,(t=!(a=Zo(o).call(this,e))||"object"!==Xo(a)&&"function"!=typeof a?er(n):a).state={hostName:e.serverAddress,changed:!1},t.handleHostNameChange=t.handleHostNameChange.bind(er(t)),t.handleEditingFinished=t.handleEditingFinished.bind(er(t)),t}var t,n,a;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&tr(e,t)}(o,w.a.PureComponent),t=o,(n=[{key:"handleHostNameChange",value:function(e){this.setState({hostName:e.target.value,changed:!0})}},{key:"handleEditingFinished",value:function(){this.state.changed&&(this.setState({changed:!1}),this.props.onServerAddressChange(this.state.hostName.trim()))}},{key:"render",value:function(){var e=[];for(var t in p){var n=p[t];e.push(w.a.createElement("option",{key:n,value:n}))}return w.a.createElement("div",{className:"panel-form-row"},w.a.createElement("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,required:!0}),w.a.createElement("datalist",{id:"known-hosts"},e))}}])&&$o(t.prototype,n),a&&$o(t,a),o}();function ar(e){return(ar="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function or(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function rr(e){return(rr=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function ir(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function sr(e,t){return(sr=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var lr=function(e){function o(e){var t,n,a;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,o),n=this,(t=!(a=rr(o).call(this,e))||"object"!==ar(a)&&"function"!=typeof a?ir(n):a).state={transport:e.transport||"def",serverAddress:e.serverAddress},t.handleSubmit=t.handleSubmit.bind(ir(t)),t.handleTransportSelected=t.handleTransportSelected.bind(ir(t)),t.handleServerAddressChange=t.handleServerAddressChange.bind(ir(t)),t}var t,n,a;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&sr(e,t)}(o,w.a.PureComponent),t=o,(n=[{key:"handleSubmit",value:function(e){e.preventDefault(),this.props.onUpdate({transport:this.state.transport,serverAddress:this.state.serverAddress})}},{key:"handleTransportSelected",value:function(e){this.setState({transport:e.currentTarget.value})}},{key:"handleServerAddressChange",value:function(e){this.setState({serverAddress:e})}},{key:"render",value:function(){var a={def:"default",ws:"websocket",lp:"long polling"},o=[],r=this;return["def","ws","lp"].map(function(e){var t="transport-"+e,n=a[e];o.push(w.a.createElement("li",{key:e},w.a.createElement("input",{type:"radio",id:t,name:"transport-select",value:e,checked:r.state.transport===e,onChange:r.handleTransportSelected}),w.a.createElement("label",{htmlFor:t},n)))}),w.a.createElement("form",{id:"settings-form",className:"panel-form",onSubmit:this.handleSubmit},w.a.createElement("div",{className:"panel-form-row"},w.a.createElement("label",{className:"small"},w.a.createElement(S.FormattedMessage,{id:"label_server_to_use",defaultMessage:"Server to use:"}))),w.a.createElement(nr,{serverAddress:this.state.serverAddress,onServerAddressChange:this.handleServerAddressChange}),w.a.createElement("div",{className:"panel-form-row"},w.a.createElement("label",{className:"small"},w.a.createElement(S.FormattedMessage,{id:"label_wire_transport",defaultMessage:"Wire transport:"}))),w.a.createElement("div",{className:"panel-form-row"},w.a.createElement("ul",{className:"quoted"},o)),w.a.createElement("div",{className:"dialog-buttons"},w.a.createElement("button",{type:"submit",className:"blue"},w.a.createElement(S.FormattedMessage,{id:"button_update",defaultMessage:"Update"}))))}}])&&or(t.prototype,n),a&&or(t,a),o}();function cr(e){return(cr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function ur(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function dr(e){return(dr=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function pr(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function hr(e,t){return(hr=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var fr=Object(S.defineMessages)({phone:{id:"phone_dative",defaultMessage:"phone"},email:{id:"email_dative",defaultMessage:"email"}}),mr=function(e){function o(e){var t,n,a;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,o),n=this,(t=!(a=dr(o).call(this,e))||"object"!==cr(a)&&"function"!=typeof a?pr(n):a).state={code:e.credCode||""},t.handleChange=t.handleChange.bind(pr(t)),t.handleKeyPress=t.handleKeyPress.bind(pr(t)),t.handleSubmit=t.handleSubmit.bind(pr(t)),t}var t,n,a;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&hr(e,t)}(o,w.a.PureComponent),t=o,(n=[{key:"handleChange",value:function(e){this.setState({code:e.target.value})}},{key:"handleKeyPress",value:function(e){"Enter"===e.key&&this.handleSubmit(e)}},{key:"handleSubmit",value:function(e){e.preventDefault(),this.state.code&&this.state.code.trim()&&this.props.onSubmit(this.props.credMethod,this.state.code.trim())}},{key:"render",value:function(){var t=this,e=this.props.intl.formatMessage,n={email:e(fr.email),tel:e(fr.phone)}[this.props.credMethod]||this.props.credMethod;return w.a.createElement("div",{className:"panel-form"},w.a.createElement("div",{className:"panel-form-row"},w.a.createElement("label",{className:"small",htmlFor:"enter-confirmation-code"},w.a.createElement(S.FormattedMessage,{id:"enter_confirmation_code_prompt",defaultMessage:"Enter confirmation code sent to you by {method}:",values:{method:n}}))),w.a.createElement("div",{className:"panel-form-row"},w.a.createElement(S.FormattedMessage,{id:"numeric_confirmation_code_prompt",defaultMessage:"Numbers only"},function(e){return w.a.createElement("input",{type:"text",id:"enter-confirmation-code",placeholder:e,value:t.state.code,onChange:t.handleChange,onKeyPress:t.handleKeyPress,required:!0})})),w.a.createElement("div",{className:"dialog-buttons"},w.a.createElement("button",{className:"blue",onClick:this.handleSubmit},w.a.createElement(S.FormattedMessage,{id:"button_confirm",defaultMessage:"Confirm"}))))}}])&&ur(t.prototype,n),a&&ur(t,a),o}(),gr=Object(S.injectIntl)(mr);function br(e){return(br="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function vr(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function yr(e){return(yr=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function _r(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function wr(e,t){return(wr=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var Sr=Object(S.defineMessages)({login:{id:"sidepanel_title_login",defaultMessage:"Sign In"},register:{id:"sidepanel_title_register",defaultMessage:"Create Account"},settings:{id:"sidepanel_title_settings",defaultMessage:"Settings"},edit:{id:"sidepanel_title_edit_account",defaultMessage:"Edit Account"},newtpk:{id:"sidepanel_title_newtpk",defaultMessage:"Start New Chat"},cred:{id:"sidepanel_title_cred",defaultMessage:"Confirm Credentials"},reset:{id:"sidepanel_title_reset",defaultMessage:"Reset Password"},archive:{id:"sidepanel_title_archive",defaultMessage:"Archived Chats"}}),Er=function(e){function o(e){var t,n,a;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,o),n=this,(t=!(a=yr(o).call(this,e))||"object"!==br(a)&&"function"!=typeof a?_r(n):a).handleLoginRequested=t.handleLoginRequested.bind(_r(t)),t}var t,n,a;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&wr(e,t)}(o,w.a.Component),t=o,(n=[{key:"handleLoginRequested",value:function(e,t){this.props.onLoginRequest(e,t)}},{key:"render",value:function(){var e,t,n,a=this.props.intl.formatMessage,o=this.props.state||(this.props.myUserId?"contacts":"login");return t="contacts"==o?(e=this.props.title,!this.props.avatar||this.props.avatar):(e=a(Sr[o]),!1),-1==["login","contacts"].indexOf(o)&&(n=this.props.onCancel),w.a.createElement("div",{id:"sidepanel",className:this.props.hideSelf?"nodisplay":null},w.a.createElement(Va,{state:o,title:e,avatar:t,myUserId:this.props.myUserId,onSignUp:this.props.onSignUp,onSettings:this.props.onSettings,onNewTopic:this.props.onNewTopic,onCancel:n}),w.a.createElement(Ye,{level:this.props.errorLevel,text:this.props.errorText,action:this.props.errorAction,actionText:this.props.errorActionText,onClearError:this.props.onError}),"login"===o?w.a.createElement(vo,{login:this.props.login,disabled:this.props.loginDisabled,onLogin:this.handleLoginRequested}):"register"===o?w.a.createElement(ro,{onCreateAccount:this.props.onCreateAccount,onCancel:this.props.onCancel,onError:this.props.onError}):"settings"===o?w.a.createElement(lr,{transport:this.props.transport,serverAddress:this.props.serverAddress,onCancel:this.props.onCancel,onUpdate:this.props.onGlobalSettings}):"edit"===o?w.a.createElement(po,{tinode:this.props.tinode,myUserId:this.props.myUserId,messageSounds:this.props.messageSounds,desktopAlerts:this.props.desktopAlerts,desktopAlertsEnabled:this.props.desktopAlertsEnabled,onUpdateAccount:this.props.onUpdateAccount,onUpdateTags:this.props.onUpdateAccountTags,onTogglePushNotifications:this.props.onTogglePushNotifications,onToggleMessageSounds:this.props.onToggleMessageSounds,onLogout:this.props.onLogout,onCancel:this.props.onCancel,onError:this.props.onError}):"contacts"===o||"archive"==o?w.a.createElement(Xa,{tinode:this.props.tinode,myUserId:this.props.myUserId,connected:this.props.connected,topicSelected:this.props.topicSelected,archive:"archive"==o,chatList:this.props.chatList,showContextMenu:this.props.showContextMenu,onTopicSelected:this.props.onTopicSelected,onShowArchive:this.props.onShowArchive}):"newtpk"===o?w.a.createElement(Vo,{searchResults:this.props.searchResults,onInitFind:this.props.onInitFind,onSearchContacts:this.props.onSearchContacts,onCreateTopic:this.props.onCreateTopic,onError:this.props.onError}):"cred"===o?w.a.createElement(gr,{credCode:this.props.credCode,credMethod:this.props.credMethod,onSubmit:this.props.onValidateCredentials,onCancel:this.props.onCancel,onError:this.props.onError}):"reset"===o?w.a.createElement(Qo,{onRequest:this.props.onPasswordResetRequest,onReset:this.props.onResetPassword}):null)}}])&&vr(t.prototype,n),a&&vr(t,a),o}(),kr=Object(S.injectIntl)(Er);function Mr(e){return(Mr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Cr(){return"object"==Mr(window.location)&&"https:"==window.location.protocol}function Tr(e){return(Tr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Or(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Pr(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function jr(e){return(jr=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function Nr(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Ar(e,t){return(Ar=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var xr=new Audio("audio/msg.mp3"),Dr=Object(S.defineMessages)({update_available:{id:"update_available",defaultMessage:'Update available. <a href="">Reload</a>.'},reconnect_countdown:{id:"reconnect_countdown",defaultMessage:"Disconnected. Reconnecting in {seconds}s…"},reconnect_now:{id:"reconnect_now",defaultMessage:"Try now"}}),Ur=function(e){function o(e){var t,n,a;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,o),n=this,(t=!(a=jr(o).call(this,e))||"object"!==Tr(a)&&"function"!=typeof a?Nr(n):a).state=t.getBlankState(),t.handleResize=t.handleResize.bind(Nr(t)),t.handleHashRoute=t.handleHashRoute.bind(Nr(t)),t.handleOnline=t.handleOnline.bind(Nr(t)),t.checkForAppUpdate=t.checkForAppUpdate.bind(Nr(t)),t.handleAppVisibility=t.handleAppVisibility.bind(Nr(t)),t.handleReadTimer=t.handleReadTimer.bind(Nr(t)),t.handleVisibilityEvent=t.handleVisibilityEvent.bind(Nr(t)),t.handleError=t.handleError.bind(Nr(t)),t.handleLoginRequest=t.handleLoginRequest.bind(Nr(t)),t.handleConnected=t.handleConnected.bind(Nr(t)),t.handleAutoreconnectIteration=t.handleAutoreconnectIteration.bind(Nr(t)),t.doLogin=t.doLogin.bind(Nr(t)),t.handleCredentialsRequest=t.handleCredentialsRequest.bind(Nr(t)),t.handleLoginSuccessful=t.handleLoginSuccessful.bind(Nr(t)),t.handleDisconnect=t.handleDisconnect.bind(Nr(t)),t.tnMeMetaDesc=t.tnMeMetaDesc.bind(Nr(t)),t.tnMeContactUpdate=t.tnMeContactUpdate.bind(Nr(t)),t.tnMeSubsUpdated=t.tnMeSubsUpdated.bind(Nr(t)),t.resetContactList=t.resetContactList.bind(Nr(t)),t.tnData=t.tnData.bind(Nr(t)),t.tnInitFind=t.tnInitFind.bind(Nr(t)),t.tnFndSubsUpdated=t.tnFndSubsUpdated.bind(Nr(t)),t.handleSearchContacts=t.handleSearchContacts.bind(Nr(t)),t.handleTopicSelected=t.handleTopicSelected.bind(Nr(t)),t.handleHideMessagesView=t.handleHideMessagesView.bind(Nr(t)),t.handleSendMessage=t.handleSendMessage.bind(Nr(t)),t.handleNewChatInvitation=t.handleNewChatInvitation.bind(Nr(t)),t.handleNewAccount=t.handleNewAccount.bind(Nr(t)),t.handleNewAccountRequest=t.handleNewAccountRequest.bind(Nr(t)),t.handleUpdateAccountRequest=t.handleUpdateAccountRequest.bind(Nr(t)),t.handleUpdateAccountTagsRequest=t.handleUpdateAccountTagsRequest.bind(Nr(t)),t.handleSettings=t.handleSettings.bind(Nr(t)),t.handleGlobalSettings=t.handleGlobalSettings.bind(Nr(t)),t.handleShowArchive=t.handleShowArchive.bind(Nr(t)),t.handleToggleMessageSounds=t.handleToggleMessageSounds.bind(Nr(t)),t.initDesktopAlerts=t.initDesktopAlerts.bind(Nr(t)),t.togglePushToken=t.togglePushToken.bind(Nr(t)),t.requestPushToken=t.requestPushToken.bind(Nr(t)),t.handleSidepanelCancel=t.handleSidepanelCancel.bind(Nr(t)),t.handleNewTopic=t.handleNewTopic.bind(Nr(t)),t.handleNewTopicRequest=t.handleNewTopicRequest.bind(Nr(t)),t.handleNewTopicCreated=t.handleNewTopicCreated.bind(Nr(t)),t.handleTopicUpdateRequest=t.handleTopicUpdateRequest.bind(Nr(t)),t.handleChangePermissions=t.handleChangePermissions.bind(Nr(t)),t.handleTagsUpdated=t.handleTagsUpdated.bind(Nr(t)),t.handleLogout=t.handleLogout.bind(Nr(t)),t.handleLeaveUnsubRequest=t.handleLeaveUnsubRequest.bind(Nr(t)),t.handleDialogCancel=t.handleDialogCancel.bind(Nr(t)),t.handleShowContextMenu=t.handleShowContextMenu.bind(Nr(t)),t.defaultTopicContextMenu=t.defaultTopicContextMenu.bind(Nr(t)),t.handleHideContextMenu=t.handleHideContextMenu.bind(Nr(t)),t.handleShowInfoView=t.handleShowInfoView.bind(Nr(t)),t.handleHideInfoView=t.handleHideInfoView.bind(Nr(t)),t.handleMemberUpdateRequest=t.handleMemberUpdateRequest.bind(Nr(t)),t.handleValidateCredentialsRequest=t.handleValidateCredentialsRequest.bind(Nr(t)),t.handlePasswordResetRequest=t.handlePasswordResetRequest.bind(Nr(t)),t.handleResetPassword=t.handleResetPassword.bind(Nr(t)),t.handleContextMenuAction=t.handleContextMenuAction.bind(Nr(t)),t}var t,n,a;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&Ar(e,t)}(o,w.a.Component),t=o,a=[{key:"tnSetup",value:function(e,t){var n=new E.a(d,e,"AQEAAAABAAD_rAp4DJh05a1HAwFT3A6K",t,Cr());return n.enableLogging(!0,!0),n}},{key:"prepareSearchableContacts",value:function(e,t){var n={},a=!0,o=!1,r=void 0;try{for(var i,s=e[Symbol.iterator]();!(a=(i=s.next()).done);a=!0){var l=i.value;"p2p"==E.a.topicType(l.topic)&&(n[l.topic]={user:l.topic,updated:l.updated,public:l.public,private:l.private,acs:l.acs})}}catch(e){o=!0,r=e}finally{try{a||null==s.return||s.return()}finally{if(o)throw r}}var c=!0,u=!1,d=void 0;try{for(var p,h=t[Symbol.iterator]();!(c=(p=h.next()).done);c=!0){var f=p.value;n[f.user]||(n[f.user]=f)}}catch(e){u=!0,d=e}finally{try{c||null==h.return||h.return()}finally{if(u)throw d}}return Object.values(n)}}],(n=[{key:"getBlankState",value:function(){var e,t,n=Za.getObject("settings")||{};return Or(e={connected:!1,ready:!1,transport:n.transport||null,serverAddress:n.serverAddress||(t=h,"object"==Mr(window.location)&&("file:"==window.location.protocol||"localhost"==window.location.hostname?t=p.local:window.location.hostname&&(t=window.location.hostname+(window.location.port?":"+window.location.port:""))),t),serverVersion:"no connection",messageSounds:!n.messageSoundsOff,desktopAlerts:n.desktopAlerts,desktopAlertsEnabled:(Cr()||"object"==Mr(window.location)&&"localhost"==window.location.hostname)&&void 0!==c&&"undefined"!=typeof navigator&&"undefined"!=typeof FIREBASE_INIT,firebaseToken:Za.getObject("firebase-token"),errorText:"",errorLevel:null,errorAction:void 0,errorActionText:null,sidePanelSelected:"login",sidePanelTitle:null,sidePanelAvatar:null,dialogSelected:null,contextMenuVisible:!1,login:"",password:"",myUserId:null,liveConnection:navigator.onLine,topicSelected:"",topicSelectedOnline:!1,topicSelectedAcs:null,newTopicParams:null,loginDisabled:!1,displayMobile:window.innerWidth<=640,showInfoPanel:!1,mobilePanel:"sidepanel"},"contextMenuVisible",!1),Or(e,"contextMenuBounds",null),Or(e,"contextMenuClickAt",null),Or(e,"contextMenuParams",null),Or(e,"contextMenuItems",[]),Or(e,"chatList",[]),Or(e,"searchResults",[]),Or(e,"searchableContacts",[]),Or(e,"credMethod",void 0),Or(e,"credCode",void 0),e}},{key:"componentDidMount",value:function(){var t=this;if(window.addEventListener("resize",this.handleResize),window.addEventListener("online",function(e){t.handleOnline(!0)}),window.addEventListener("offline",function(e){t.handleOnline(!1)}),window.addEventListener("hashchange",this.handleHashRoute),document.addEventListener("visibilitychange",this.handleVisibilityEvent),this.setState({viewportWidth:document.documentElement.clientWidth,viewportHeight:document.documentElement.clientHeight}),this.tinode=o.tnSetup(this.state.serverAddress,this.state.transport),this.tinode.onConnect=this.handleConnected,this.tinode.onDisconnect=this.handleDisconnect,this.tinode.onAutoreconnectIteration=this.handleAutoreconnectIteration,this.state.desktopAlertsEnabled)try{this.fbPush=c.initializeApp(FIREBASE_INIT,d).messaging(),this.fbPush.usePublicVapidKey(FIREBASE_INIT.messagingVapidKey),navigator.serviceWorker.register("/service-worker.js").then(function(e){t.checkForAppUpdate(e),t.fbPush.useServiceWorker(e),t.initDesktopAlerts(),t.state.desktopAlerts&&(t.state.firebaseToken?t.tinode.setDeviceToken(t.state.firebaseToken,!0):t.togglePushToken(!0))}).catch(function(e){console.log("Failed to register service worker:",e)})}catch(e){this.handleError("Failed to initialize push notifications","err"),console.log("Failed to initialize push notifications",e),this.setState({desktopAlertsEnabled:!1})}var e=Za.getObject("keep-logged-in")?Za.getObject("auth-token"):void 0,n=b.parseUrlHash(window.location.hash);e?(e.expires=new Date(e.expires),this.tinode.setAuthToken(e),this.tinode.connect().catch(function(e){t.handleError(e.message,"err")}),delete n.params.info,delete n.params.tab,n.path[0]="",b.navigateTo(b.composeUrlHash(n.path,n.params))):n.params.token||b.navigateTo(""),this.readTimer=null,this.readTimerCallback=null,this.handleHashRoute()}},{key:"componentWillUnmount",value:function(){window.removeEventListener("resize",this.handleResize),window.removeEventListener("hashchange",this.handleHashRoute),document.removeEventListener("visibilitychange",this.handleVisibilityEvent)}},{key:"handleResize",value:function(){var e=document.documentElement.clientWidth<=640;this.setState({viewportWidth:document.documentElement.clientWidth,viewportHeight:document.documentElement.clientHeight}),this.state.displayMobile!=e&&this.setState({displayMobile:e})}},{key:"checkForAppUpdate",value:function(t){var n=this,a=this.props.intl.formatHTMLMessage;t.onupdatefound=function(){var e=t.installing;e.onstatechange=function(){"installed"==e.state&&navigator.serviceWorker.controller&&n.handleError(a(Dr.update_available),"info")}}}},{key:"handleHashRoute",value:function(){var e=b.parseUrlHash(window.location.hash);e.path&&0<e.path.length?(["register","settings","edit","cred","reset","newtpk","archive","contacts",""].includes(e.path[0])?this.setState({sidePanelSelected:e.path[0]}):console.log("Unknown sidepanel view",e.path[0]),1<e.path.length&&e.path[1]!=this.state.topicSelected&&this.setState({topicSelected:E.a.topicType(e.path[1])?e.path[1]:null})):this.setState({sidePanelSelected:""}),e.params.method&&this.setState({credMethod:e.params.method}),e.params.code&&this.setState({credCode:e.params.code}),this.setState({showInfoPanel:e.params.info,newTopicTabSelected:e.params.tab})}},{key:"handleOnline",value:function(e){e?this.handleError("",null):this.handleError("No connection","warn"),this.setState({liveConnection:e})}},{key:"handleAppVisibility",value:function(e,t){clearTimeout(this.readTimer),this.readTimerCallback=t,this.readTimer=e&&t?setTimeout(t,1e3):null}},{key:"handleReadTimer",value:function(e){this.handleAppVisibility(!document.hidden,e)}},{key:"handleVisibilityEvent",value:function(){this.handleAppVisibility(!document.hidden,this.readTimerCallback)}},{key:"handleError",value:function(e,t,n,a){this.setState({errorText:e,errorLevel:t,errorAction:n,errorActionText:a})}},{key:"handleLoginRequest",value:function(e,t){var n=this;this.setState({loginDisabled:!0,login:e,password:t}),this.handleError("",null),this.tinode.isConnected()?this.doLogin(e,t,{meth:this.state.credMethod,resp:this.state.credCode}):this.tinode.connect().catch(function(e){n.setState({loginDisabled:!1}),n.handleError(e.message,"err")})}},{key:"handleConnected",value:function(){var e=this.tinode.getServerInfo();this.setState({serverVersion:e.ver+" "+(e.build?e.build:"none")+"; "}),this.doLogin(this.state.login,this.state.password,{meth:this.state.credMethod,resp:this.state.credCode})}},{key:"handleAutoreconnectIteration",value:function(e,t){var n=this;if(clearInterval(this.reconnectCountdown),e<0)this.handleError();else if(t)t.then(function(){n.handleError()}).catch(function(e){n.handleError(e.message,"err")});else{var a=this.props.intl.formatHTMLMessage,o=e/1e3;o|=o,this.reconnectCountdown=setInterval(function(){n.handleError(a(Dr.reconnect_countdown,{seconds:o}),"warn",function(){clearInterval(n.reconnectCountdown),n.tinode.reconnect()},a(Dr.reconnect_now)),o-=1},1e3)}}},{key:"handleDisconnect",value:function(e){this.setState({connected:!1,ready:!1,topicSelectedOnline:!1,dialogSelected:null,errorText:e&&e.message?e.message:"Disconnected",errorLevel:e&&e.message?"err":"warn",loginDisabled:!1,contextMenuVisible:!1,serverVersion:"no connection"})}},{key:"doLogin",value:function(e,t,n){var a=this;if(this.tinode.isAuthenticated())b.navigateTo("");else{n=E.a.credential(n);var o=null,r=this.tinode.getAuthToken();e&&t?(this.setState({password:null}),o=this.tinode.loginBasic(e,t,n)):r&&(o=this.tinode.loginToken(r.token,n)),o?o.then(function(e){300<=e.code&&"validate credentials"===e.text?(n&&a.handleError("Code does not match","warn"),a.handleCredentialsRequest(e.params)):a.handleLoginSuccessful()}).catch(function(e){a.setState({loginDisabled:!1,credMethod:void 0,credCode:void 0}),a.handleError(e.message,"err"),localStorage.removeItem("auth-token"),b.navigateTo("")}):(b.navigateTo(""),this.setState({loginDisabled:!1}))}}},{key:"handleCredentialsRequest",value:function(e){var t=b.parseUrlHash(window.location.hash);t.path[0]="cred",t.params.method=e.cred[0],b.navigateTo(b.composeUrlHash(t.path,t.params))}},{key:"handleLoginSuccessful",value:function(){var t=this;this.handleError("",null),Za.getObject("keep-logged-in")&&Za.setObject("auth-token",this.tinode.getAuthToken());var e=this.tinode.getMeTopic();e.onMetaDesc=this.tnMeMetaDesc,e.onContactUpdate=this.tnMeContactUpdate,e.onSubsUpdated=this.tnMeSubsUpdated,this.setState({connected:!0,credMethod:void 0,credCode:void 0,myUserId:this.tinode.getCurrentUserID()}),e.subscribe(e.startMetaQuery().withLaterSub().withDesc().build()).catch(function(e){localStorage.removeItem("auth-token"),t.handleError(e.message,"err"),b.navigateTo("")}),b.navigateTo(b.setUrlSidePanel(window.location.hash,"contacts"))}},{key:"tnMeMetaDesc",value:function(e){e&&e.public&&this.setState({sidePanelTitle:e.public.fn,sidePanelAvatar:L(e.public.photo)})}},{key:"tnMeContactUpdate",value:function(e,t){"on"==e||"off"==e?(this.resetContactList(),this.state.topicSelected==t.topic&&this.setState({topicSelectedOnline:"on"==e})):"read"==e?this.resetContactList():"msg"==e?this.state.topicSelected!=t.topic?(this.state.messageSounds&&xr.play(),this.resetContactList()):document.hidden&&this.state.messageSounds&&xr.play():"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||console.log("Unsupported (yet) presence update:"+e+" in: "+t.topic))}},{key:"tnMeSubsUpdated",value:function(e){this.resetContactList()}},{key:"resetContactList",value:function(){var t=this,n={chatList:[]};this.state.ready||(n.ready=!0),this.tinode.getMeTopic().contacts(function(e){n.chatList.push(e),t.state.topicSelected==e.topic&&(n.topicSelectedOnline=e.online,n.topicSelectedAcs=e.acs)}),n.searchableContacts=o.prepareSearchableContacts(n.chatList,this.state.searchResults),this.setState(n)}},{key:"tnData",value:function(e){var t=this,n=this.tinode.getTopic(e.topic);n.msgStatus(e)>=E.a.MESSAGE_STATUS_SENT&&e.from!=this.state.myUserId&&(clearTimeout(this.receivedTimer),this.receivedTimer=setTimeout(function(){t.receivedTimer=void 0,n.noteRecv(e.seq)},500))}},{key:"tnInitFind",value:function(){var t=this,e=this.tinode.getFndTopic();e.onSubsUpdated=this.tnFndSubsUpdated,e.isSubscribed()?this.tnFndSubsUpdated():e.subscribe(e.startMetaQuery().withSub().withTags().build()).catch(function(e){t.handleError(e.message,"err")})}},{key:"tnFndSubsUpdated",value:function(){var t=[];this.tinode.getFndTopic().contacts(function(e){t.push(e)}),this.setState({searchResults:t,searchableContacts:o.prepareSearchableContacts(this.state.chatList,t)})}},{key:"handleSearchContacts",value:function(e){var t=this,n=this.tinode.getFndTopic();n.setMeta({desc:{public:e}}).then(function(e){return n.getMeta(n.startMetaQuery().withSub().build())}).catch(function(e){t.handleError(e.message,"err")})}},{key:"handleTopicSelected",value:function(e,t,n,a){this.state.newTopicParams&&this.state.newTopicParams._topicName!=e&&this.setState({newTopicParams:null}),e?(this.setState({errorText:"",errorLevel:null,mobilePanel:"topic-view",showInfoPanel:!1}),this.state.topicSelected!=e&&(this.setState({topicSelectedOnline:n,topicSelectedAcs:a}),b.navigateTo(b.setUrlTopic("",e)))):(this.setState({errorText:"",errorLevel:null,mobilePanel:"sidepanel",topicSelectedOnline:!1,topicSelectedAcs:null,showInfoPanel:!1}),b.navigateTo(b.setUrlTopic("",null)))}},{key:"handleHideMessagesView",value:function(){this.setState({mobilePanel:"sidepanel"}),b.navigateTo(b.setUrlTopic(window.location.hash,null))}},{key:"handleSendMessage",value:function(e,t,n){var a=this,o=this.tinode.getTopic(this.state.topicSelected);(e=o.createMessage(e,!1))._uploader=n,o.isSubscribed()||(t||(t=Promise.resolve()),t=t.then(function(){return o.subscribe()})),t&&(t=t.catch(function(e){a.handleError(e.message,"err")})),o.publishDraft(e,t).then(function(e){if(o.isArchived())return o.archive(!1)}).catch(function(e){a.handleError(e.message,"err")})}},{key:"handleNewChatInvitation",value:function(t,e){var n=this,a=this.tinode.getTopic(t),o=null;switch(e){case"accept":var r=a.getAccessMode().getGiven();o=a.setMeta({sub:{mode:r}}),"p2p"==a.getType()&&(o=o.then(function(e){a.setMeta({sub:{user:t,mode:r}})}));break;case"delete":o=a.delTopic();break;case"block":var i=a.getAccessMode().updateWant("-JP").getWant();o=a.setMeta({sub:{mode:i}}).then(function(e){return n.handleTopicSelected(null)});break;default:console.log("Unknown invitation action",'"'+e+'""')}null!=o&&o.catch(function(e){n.handleError(e.message,"err")})}},{key:"handleNewAccount",value:function(){b.navigateTo(b.setUrlSidePanel(window.location.hash,"register"))}},{key:"handleNewAccountRequest",value:function(e,t,n,a,o){var r=this;this.tinode.connect(this.state.serverAddress).then(function(){return r.tinode.createAccountBasic(e,t,{public:n,tags:o,cred:E.a.credential(a)})}).then(function(e){300<=e.code&&"validate credentials"==e.text?r.handleCredentialsRequest(e.params):r.handleLoginSuccessful(r)}).catch(function(e){r.handleError(e.message,"err")})}},{key:"handleUpdateAccountRequest",value:function(e,t,n){var a=this;if(t||n){var o={};t&&(o.public=t),n&&(o.defacs=n),this.tinode.getMeTopic().setMeta({desc:o}).catch(function(e){a.handleError(e.message,"err")})}e&&this.tinode.updateAccountBasic(null,this.tinode.getCurrentLogin(),e).catch(function(e){a.handleError(e.message,"err")})}},{key:"handleUpdateAccountTagsRequest",value:function(e){var t=this;this.tinode.getFndTopic().setMeta({tags:e}).catch(function(e){t.handleError(e.message,"err")})}},{key:"handleSettings",value:function(){b.navigateTo(b.setUrlSidePanel(window.location.hash,this.state.myUserId?"edit":"settings"))}},{key:"handleGlobalSettings",value:function(e){var t=e.serverAddress||this.state.serverAddress,n=e.transport||this.state.transport;this.tinode&&(this.tinode.onDisconnect=void 0,this.tinode.disconnect()),this.tinode=o.tnSetup(t,n),this.tinode.onConnect=this.handleConnected,this.tinode.onDisconnect=this.handleDisconnect,this.setState({serverAddress:t,transport:n}),Za.setObject("settings",{serverAddress:t,transport:n}),b.navigateTo(b.setUrlSidePanel(window.location.hash,""))}},{key:"handleShowArchive",value:function(){b.navigateTo(b.setUrlSidePanel(window.location.hash,this.state.myUserId?"archive":""))}},{key:"initDesktopAlerts",value:function(){var e=this;this.fbPush.onTokenRefresh(function(){e.requestPushToken()}),this.fbPush.onMessage(function(e){})}},{key:"togglePushToken",value:function(e){var t=this;e?this.state.firebaseToken?(this.setState({desktopAlerts:!0}),Za.updateObject("settings",{desktopAlerts:!0})):this.fbPush.requestPermission().then(function(){t.requestPushToken()}).catch(function(e){t.handleError(e.message,"err"),t.setState({desktopAlerts:!1,firebaseToken:null}),Za.updateObject("settings",{desktopAlerts:!1}),console.log("Failed to get permission to notify.",e)}):this.state.firebaseToken?this.fbPush.deleteToken(this.state.firebaseToken).catch(function(e){console.log("Unable to delete token.",e)}).finally(function(){Za.updateObject("settings",{desktopAlerts:!1}),localStorage.removeItem("firebase-token"),t.setState({desktopAlerts:!1,firebaseToken:null})}):(this.setState({desktopAlerts:!1,firebaseToken:null}),Za.updateObject("settings",{desktopAlerts:!1}))}},{key:"requestPushToken",value:function(){var t=this;this.fbPush.getToken().then(function(e){e!=t.state.firebaseToken&&(t.tinode.setDeviceToken(e,!0),Za.setObject("firebase-token",e)),t.setState({firebaseToken:e,desktopAlerts:!0}),Za.updateObject("settings",{desktopAlerts:!0})}).catch(function(e){t.handleError(e.message,"err"),console.log("Failed to retrieve firebase token",e)})}},{key:"handleToggleMessageSounds",value:function(e){this.setState({messageSounds:e}),Za.updateObject("settings",{messageSoundsOff:!e})}},{key:"handleSidepanelCancel",value:function(){var e=b.parseUrlHash(window.location.hash);e.path[0]=this.state.myUserId?"contacts":"",e.params&&(delete e.params.code,delete e.params.method,delete e.params.tab),b.navigateTo(b.composeUrlHash(e.path,e.params)),this.setState({errorText:"",errorLevel:null})}},{key:"handleNewTopic",value:function(){b.navigateTo(b.setUrlSidePanel(window.location.hash,"newtpk"))}},{key:"handleNewTopicRequest",value:function(e,t,n,a){var o=this,r=e||this.tinode.newGroupTopicName(),i={_topicName:r};e?(i.sub={mode:f},i.desc={defacs:{auth:f}}):(i.desc={public:t,private:{comment:n}},i.tags=a),this.setState({newTopicParams:i},function(){o.handleTopicSelected(r)})}},{key:"handleNewTopicCreated",value:function(e,t){this.state.topicSelected==e&&e!=t&&this.setState({topicSelected:t},function(){b.navigateTo(b.setUrlTopic("",t))})}},{key:"handleTopicUpdateRequest",value:function(e,t,n,a){var o=this,r=this.tinode.getTopic(e);if(r){var i={};t&&(i.public=t),n&&(i.private=n===E.a.DEL_CHAR?E.a.DEL_CHAR:{comment:n}),a&&(i.defacs=a),r.setMeta({desc:i}).catch(function(e){o.handleError(e.message,"err")})}}},{key:"handleChangePermissions",value:function(e,t,n){var a=this,o=this.tinode.getTopic(e);if(o){var r=o.getAccessMode();t=n?(r.updateGiven(t),r.getGiven()):(r.updateWant(t),r.getWant()),o.setMeta({sub:{user:n,mode:t}}).catch(function(e){a.handleError(e.message,"err")})}}},{key:"handleTagsUpdated",value:function(e,t){var n=this,a=this.tinode.getTopic(e);a&&a.setMeta({tags:t}).catch(function(e){n.handleError(e.message,"err")})}},{key:"handleLogout",value:function(){Wt(0),localStorage.removeItem("auth-token"),localStorage.removeItem("firebase-token"),localStorage.removeItem("settings"),this.state.firebaseToken&&this.fbPush.deleteToken(this.state.firebaseToken),this.tinode&&(this.tinode.onDisconnect=void 0,this.tinode.disconnect()),this.setState(this.getBlankState()),this.tinode=o.tnSetup(this.state.serverAddress,this.state.transport),this.tinode.onConnect=this.handleConnected,this.tinode.onDisconnect=this.handleDisconnect,b.navigateTo("")}},{key:"handleLeaveUnsubRequest",value:function(e){var t=this,n=this.tinode.getTopic(e);n&&n.leave(!0).then(function(e){b.navigateTo(b.setUrlTopic(window.location.hash,""))}).catch(function(e){t.handleError(e.message,"err")})}},{key:"handleDialogCancel",value:function(){this.setState({dialogSelected:null})}},{key:"handleShowContextMenu",value:function(e,t){this.setState({contextMenuVisible:!0,contextMenuClickAt:{x:e.x,y:e.y},contextMenuParams:e,contextMenuItems:t||this.defaultTopicContextMenu(e.topicName),contextMenuBounds:i.a.findDOMNode(this).getBoundingClientRect()})}},{key:"defaultTopicContextMenu",value:function(e){var t=this.tinode.getTopic(e),n=this.props.intl.formatMessage,a=!1,o=!1,r=!1,i=!1,s=!1,l=!1;if(t){i=t.isSubscribed(),l=t.isArchived();var c=t.getAccessMode();c&&(a=c.isMuted(),o=!c.isJoiner(),r=!c.isJoiner("want"),s=c.isDeleter())}return[i?{title:n({id:"menu_item_info"}),handler:this.handleShowInfoView}:null,i?"messages_clear":null,i&&s?"messages_clear_hard":null,a?o?null:"topic_unmute":"topic_mute",r?"topic_unblock":"topic_block",l?null:"topic_archive","topic_delete"]}},{key:"handleHideContextMenu",value:function(){this.setState({contextMenuVisible:!1,contextMenuClickAt:null,contextMenuParams:null,contextMenuBounds:null})}},{key:"handleContextMenuAction",value:function(e,t,n){var a=this;"topic_archive"==e&&t&&n.topicName&&n.topicName==this.state.topicSelected&&t.then(function(){a.handleTopicSelected(null)})}},{key:"handleShowInfoView",value:function(){b.navigateTo(b.addUrlParam(window.location.hash,"info",!0)),this.setState({showInfoPanel:!0})}},{key:"handleHideInfoView",value:function(){b.navigateTo(b.removeUrlParam(window.location.hash,"info")),this.setState({showInfoPanel:!1})}},{key:"handleMemberUpdateRequest",value:function(e,t,n){var a=this;if(e){var o=this.tinode.getTopic(e);o&&(t&&0<t.length&&t.map(function(e){o.invite(e,null).catch(function(e){a.handleError(e.message,"err")})}),n&&0<n.length&&n.map(function(e){o.delSubscription(e).catch(function(e){a.handleError(e.message,"err")})}))}}},{key:"handleValidateCredentialsRequest",value:function(e,t){this.setState({credMethod:e,credCode:t}),this.doLogin(null,null,{meth:e,resp:t})}},{key:"handlePasswordResetRequest",value:function(e,t){var n=this;this.tinode.connect().then(function(){return n.tinode.requestResetAuthSecret("basic",e,t)}).catch(function(e){n.handleError(e.message,"err")})}},{key:"handleResetPassword",value:function(e,t,n){var a=this;(n=base64ReEncode(n))?this.tinode.connect().then(function(){return a.tinode.updateAccountBasic(null,null,t,{token:n})}).catch(function(e){a.handleError(e.message,"err")}):this.handleError("Invalid security token","err")}},{key:"render",value:function(){var t=this;return w.a.createElement("div",{id:"app-container"},this.state.contextMenuVisible?w.a.createElement(O,{tinode:this.tinode,bounds:this.state.contextMenuBounds,clickAt:this.state.contextMenuClickAt,params:this.state.contextMenuParams,items:this.state.contextMenuItems,hide:this.handleHideContextMenu,onAction:this.handleContextMenuAction,onTopicRemoved:function(e){e==t.state.topicSelected&&t.handleTopicSelected(null)},onError:this.handleError}):null,w.a.createElement(kr,{tinode:this.tinode,connected:this.state.connected,displayMobile:this.state.displayMobile,hideSelf:this.state.displayMobile&&"sidepanel"!==this.state.mobilePanel,state:this.state.sidePanelSelected,title:this.state.sidePanelTitle,avatar:this.state.sidePanelAvatar,login:this.state.login,myUserId:this.state.myUserId,loginDisabled:this.state.loginDisabled,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,transport:this.state.transport,messageSounds:this.state.messageSounds,desktopAlerts:this.state.desktopAlerts,desktopAlertsEnabled:this.state.desktopAlertsEnabled,serverAddress:this.state.serverAddress,onGlobalSettings:this.handleGlobalSettings,onSignUp:this.handleNewAccount,onSettings:this.handleSettings,onLoginRequest:this.handleLoginRequest,onCreateAccount:this.handleNewAccountRequest,onUpdateAccount:this.handleUpdateAccountRequest,onUpdateAccountTags:this.handleUpdateAccountTagsRequest,onTogglePushNotifications:this.togglePushToken,onToggleMessageSounds:this.handleToggleMessageSounds,onTopicSelected:this.handleTopicSelected,onCreateTopic:this.handleNewTopicRequest,onNewTopic:this.handleNewTopic,onLogout:this.handleLogout,onCancel:this.handleSidepanelCancel,onError:this.handleError,onValidateCredentials:this.handleValidateCredentialsRequest,onPasswordResetRequest:this.handlePasswordResetRequest,onResetPassword:this.handleResetPassword,onShowArchive:this.handleShowArchive,onInitFind:this.tnInitFind,searchResults:this.state.searchResults,onSearchContacts:this.handleSearchContacts,showContextMenu:this.handleShowContextMenu}),w.a.createElement(Ca,{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,hideSelf:this.state.displayMobile&&("topic-view"!==this.state.mobilePanel||this.state.showInfoPanel),topic:this.state.topicSelected,myUserId:this.state.myUserId,serverVersion:this.state.serverVersion,serverAddress:this.state.serverAddress,errorText:this.state.errorText,errorLevel:this.state.errorLevel,errorAction:this.state.errorAction,errorActionText:this.state.errorActionText,newTopicParams:this.state.newTopicParams,onHideMessagesView:this.handleHideMessagesView,onData:this.tnData,onError:this.handleError,onNewTopicCreated:this.handleNewTopicCreated,readTimerHandler:this.handleReadTimer,showContextMenu:this.handleShowContextMenu,onChangePermissions:this.handleChangePermissions,onNewChat:this.handleNewChatInvitation,sendMessage:this.handleSendMessage}),this.state.showInfoPanel?w.a.createElement(an,{tinode:this.tinode,connected:this.state.connected,displayMobile:this.state.displayMobile,topic:this.state.topicSelected,searchableContacts:this.state.searchableContacts,myUserId:this.state.myUserId,errorText:this.state.errorText,errorLevel:this.state.errorLevel,errorAction:this.state.errorAction,errorActionText:this.state.errorActionText,onTopicDescUpdate:this.handleTopicUpdateRequest,onCancel:this.handleHideInfoView,onChangePermissions:this.handleChangePermissions,onMemberUpdateRequest:this.handleMemberUpdateRequest,onLeaveTopic:this.handleLeaveUnsubRequest,onAddMember:this.handleManageGroupMembers,onTopicTagsUpdate:this.handleTagsUpdated,onInitFind:this.tnInitFind,onError:this.handleError,showContextMenu:this.handleShowContextMenu}):null)}}])&&Pr(t.prototype,n),a&&Pr(t,a),o}(),Rr=Object(S.injectIntl)(Ur);Object(S.addLocaleData)(s.a);var Fr=b.parseUrlHash(window.location.hash).params,Ir=Fr&&Fr.hl||navigator.languages&&navigator.languages[0]||navigator.language||navigator.userLanguage,Lr=Ir.toLowerCase().split(/[-_]+/)[0],qr=l[Ir]||l[Lr]||l.en;i.a.render(w.a.createElement(S.IntlProvider,{locale:Ir,messages:qr,textComponent:w.a.Fragment},w.a.createElement(Rr,null)),document.getElementById("mountPoint"))}]);
  //# sourceMappingURL=index.prod.js.map