"use strict";(function(){ var p;function aa(a){this.id=a;this.version=0}aa.prototype.update=function(a,b){void 0!==a.name&&(this.name=a.name);this.version=Math.max(this.version,b)};function da(a){this.a=a.desc;this.name=a.name;this.type=a.type;this.usage=a.usage;this.S=a.category}function ea(){this.a={};this.A=[];this.version=0} ea.prototype.update=function(a,b){a.emoji_use&&(this.a=JSON.parse(a.emoji_use));a.highlight_words?this.A=(a.highlight_words||"").split(",").filter(function(a){return""!==a.trim()}):a.highlights&&(this.A=a.highlights);this.version=Math.max(this.version,b)};function fa(){this.a=null;this.j={};this.m={};this.self=null;this.b={version:0,data:{}};this.i={version:0,data:{}};this.s={};this.Ha={};this.w=0}function ga(a,b){return b.pv?new r(b.id,a.m[b.user]):new u(b.id)} function ha(a,b,c){var d=d||"";b.team&&(a.a||(a.a=new aa(b.team.id)),a.a.update(b.team,c));if(b.users)for(var e=0,f=b.users.length;ethis.w;)this.a.shift();if(this.b)for(a=0;ab.getTime()?a.toLocaleTimeString():a.getTime()>c.getTime()?"hier, "+a.toLocaleTimeString(): a.toLocaleString()},ka:function(a,b){return a+"/"+b},c:{fileUploadCancel:"Annuler",neterror:"Impossible de se connecter au chat !",ctxMenuSettings:"Configuration",settingTitle:"Configuration","setting-menu-services":"Services","settings-services-title":"Services","setting-menu-display":"Affichage","settings-display-title":"Affichage","setting-menu-privacy":"Vie priv\u00e9e","settings-privacy-title":"Vie priv\u00e9e",settingCommit:"Appliquer","settings-serviceAddButton":"Ajouter un service","settings-serviceListEmpty":"Vous n'avez pas encore ajout\u00e9 de service. Ajouter un service pour continuer.", "settings-serviceAddConfirm":"Suivant"}};J.fr.D=function(a){return"(edité "+J.fr.W(a)+")"};J.en={hb:"Unknown member",gb:"Unknown channel",Pa:"New message",message:"Message",Oa:"Network",Qa:"(only visible to you)",G:"Starred",j:"Channels",Sa:"Direct messages",Ta:"Share your GPS location",ok:"Ok",Ka:"Cancel",W:function(a){"string"!==typeof a&&(a=parseFloat(a));var b=new Date,c=new Date;a=new Date(a);b.setHours(0,0,0,0);c.setTime(b.getTime());c.setDate(c.getDate()-1);return a.getTime()>b.getTime()?a.toLocaleTimeString():a.getTime()>c.getTime()?"yesterday, "+a.toLocaleTimeString():a.toLocaleString()}, ka:function(a,b){return a+"/"+b},c:{fileUploadCancel:"Cancel",neterror:"Cannot connect to chat !",ctxMenuSettings:"Settings",settingTitle:"Settings","setting-menu-services":"Services","settings-services-title":"Services","setting-menu-display":"Display","settings-display-title":"Display","setting-menu-privacy":"Privacy","settings-privacy-title":"Privacy",settingCommit:"Apply","settings-serviceAddButton":"Add a service","settings-serviceListEmpty":"You don't have any service yet. Please add a service to continue.", "settings-serviceAddConfirm":"Next"}};J.en.D=function(a){return"(edited "+J.en.W(a)+")"};var ya=function(){function a(a){this.text="";this.g=a}function b(b,c,d){this.U=c;this.f=null;this.h=[];this.a=d||"";this.fa="<"===this.a;this.ra="*"===this.a;this.ea="_"===this.a;this.ga="~"===this.a||"-"===this.a;this.i=">"===this.a||">"===this.a;this.X=":"===this.a;this.ua="`"===this.a;this.Fa="```"===this.a;this.va="\n"===this.a;this.da=void 0!==d&&-1!==n.A.indexOf(d);this.g=b;this.ha=null;this.b=this.va||this.da?c+d.length-1:!1;this.da&&(this.f=new a(this),this.h.push(this.f),this.f.text=d)} function c(a){return"A"<=a&&"Z">=a||"a"<=a&&"z">=a||"0"<=a&&"9">=a||-1!=="\u00e0\u00e8\u00ec\u00f2\u00f9\u00c0\u00c8\u00cc\u00d2\u00d9\u00e1\u00e9\u00ed\u00f3\u00fa\u00fd\u00c1\u00c9\u00cd\u00d3\u00da\u00dd\u00e2\u00ea\u00ee\u00f4\u00fb\u00c2\u00ca\u00ce\u00d4\u00db\u00e3\u00f1\u00f5\u00c3\u00d1\u00d5\u00e4\u00eb\u00ef\u00f6\u00fc\u00ff\u00c4\u00cb\u00cf\u00d6\u00dc\u0178\u00e7\u00c7\u00df\u00d8\u00f8\u00c5\u00e5\u00c6\u00e6\u0153".indexOf(a)}function d(a){a=a||h;for(var c=0,e=a.h.length;c"===m[a])return!0;var b=c(m[a-1]);if(!this.i&&m.substr(a,this.a.length)===this.a){if(!b&&(this.ra||this.ea||this.ga))return!1;if(this.f&&this.Ca())return this.f.Ga();if(this.Va())return!0}return"\n"===m[a]&&this.i?!0:!1};b.prototype.Va=function(){for(var a=this;a;){for(var c=0,d=a.h.length;c"===m[b])return m[b]}if("`"===m[b]&&!d|| "\n"===m[b]||!(-1===["*","~","-","_"].indexOf(m[b])||!e&&void 0!==m[b+1]&&-1==="*~-_<&".split("").indexOf(m[b+1])||d&&void 0!==m[b-1]&&-1==="*~-_<&".split("").indexOf(m[b-1]))||-1!==[":"].indexOf(m[b])&&e||-1!==["<"].indexOf(m[b]))return m[b];d=0;for(e=n.A.length;d=a&&(this.b=!1);this.h.forEach(function(c){c instanceof b&&c.la(a)})};a.prototype.innerHTML=function(){if(this.g.na()){for(var a=this.g;a&&!a.X;)a=a.g;if(a){var a=a.a+this.text+a.a,b=n.V(a);return b?b:a}return(a=n.V(this.text))?a:this.text}if(this.g.ma()){if("undefined"!==typeof hljs)try{return a=this.text.match(/^\w+/),hljs.configure({useBR:!0, tabReplace:"      "}),a&&hljs.getLanguage(a[0])?hljs.fixMarkup(hljs.highlight(a[0],this.text.substr(a[0].length)).value):hljs.fixMarkup(hljs.highlightAuto(this.text).value)}catch(q){console.error(q)}return this.text.replace(/\n/g,"
")}return n.ca(this.text)};a.prototype.outerHTML=function(){var a="span",b=[],c="";if(this.g.ma()){a="pre";b.push("codeblock");var d=this.innerHTML()}else this.g.ya()?(b.push("code"),d=this.innerHTML()):(this.g.fa&&(d=n.aa(this.text))? (a="a",c=' href="'+d.link+'"',d.Ma||(c+=' target="_blank"'),d=n.ca(d.text)):d=this.innerHTML(),this.g.xa()&&b.push("bold"),this.g.Aa()&&b.push("italic"),this.g.Ba()&&b.push("strike"),this.g.na()&&b.push("emoji"),this.g.za()&&b.push("highlight"));return"<"+a+c+(b.length?' class="'+b.join(" ")+'"':"")+">"+d+""};b.prototype.outerHTML=function(){var a="";this.i&&(a+='');this.va&&(a+="
");this.h.forEach(function(b){a+=b.outerHTML()});this.i&&(a+="
");return a};b.prototype.Ea= function(a){this.i&&!this.b&&this.wa(a);this.h.forEach(function(c){c instanceof b&&c.Ea(a)})};return function(c,l){l||(l={});n.A=l.A||[];n.V=l.V||f;n.ca=l.ca||f;n.aa=l.aa||g;m=c;h=new b(this,0);l=0;c=m.length;do{for(;la.B&&(b.classList.add("unread"),b.classList.add("unreadHi"));b=m=b}b&&(a.G?c.push(m):f.push(m))}else if(m=g[a.id],b=document.createElement("li"),k=document.createElement("a"),b.id="room_"+a.id,k.href="#"+a.id,a.b?(b.className="chat-context-room chat-group",b.dataset.count=Object.keys(a.m||{}).length): b.className="chat-context-room chat-channel",M===a&&b.classList.add("selected"),k.textContent=m||a.name,b.appendChild(Qa()),b.appendChild(k),a.N>a.B&&(b.classList.add("unread"),0<=N.indexOf(a)&&b.classList.add("unreadHi")),m=b)a.G?c.push(m):a.b?e.push(m):d.push(m)});c.length&&a.appendChild(Ra(K.G));c.forEach(function(b){a.appendChild(b)});d.length&&a.appendChild(Ra(K.j));d.forEach(function(b){a.appendChild(b)});e.forEach(function(b){a.appendChild(b)});f.length&&a.appendChild(Ra(K.Sa));f.forEach(function(b){a.appendChild(b)}); document.getElementById("chanList").textContent="";document.getElementById("chanList").appendChild(a);Sa.apply(document.getElementById("chanSearch"));Ta();O();P&&Ua(P.a.id,P.m,function(a){document.getElementById("chatCtx").style.backgroundImage="url("+a+")"})} function Va(){ta(function(a){var b=a.s,c;for(c in a.self.j)if(!a.self.j[c].Y){var d=document.getElementById("room_"+c);b[c]?d.classList.add("chat-context-typing"):d.classList.remove("chat-context-typing")}for(var e in a.m)(c=a.m[e].pa)&&!c.Y&&(d=document.getElementById("room_"+c.id))&&(b[c.id]?d.classList.add("chat-context-typing"):d.classList.remove("chat-context-typing"))});Wa()} function Wa(){var a;document.getElementById("whoistyping").textContent="";if(P&&M&&(a=P.s[M.id])){var b=document.createDocumentFragment(),c=!1,d;for(d in a)(a=I(d))?b.appendChild(Xa(a)):c=!0;c&&(E.b=0);document.getElementById("whoistyping").appendChild(b)}}function Ya(a){a?document.body.classList.remove("no-network"):document.body.classList.add("no-network");O()} function Za(){var a=M.name||(M.a?M.a.name:void 0);if(!a){var b=[];M.m.forEach(function(a){b.push(a.name)});a=b.join(", ")}document.getElementById("currentRoomTitle").textContent=a;Q();R();document.getElementById("fileUploadContainer").classList.add("hidden");$a();T&&(T=null,U());V&&(V=null,U());O();Wa()} function U(){if(T){document.body.classList.add("replyingTo");var a=document.getElementById("replyToContainer"),b=document.createElement("a");b.addEventListener("click",function(){T=null;U()});b.className="replyto-close";b.textContent="x";a.textContent="";a.appendChild(b);a.appendChild(T.K())}else document.body.classList.remove("replyingTo"),document.getElementById("replyToContainer").textContent="";R()} function W(){if(V){document.body.classList.add("replyingTo");var a=document.getElementById("replyToContainer"),b=document.createElement("a");b.addEventListener("click",function(){V=null;W()});b.className="replyto-close";b.textContent="x";a.textContent="";a.appendChild(b);a.appendChild(V.K());document.getElementById("msgInput").value=V.text}else document.body.classList.remove("replyingTo"),document.getElementById("replyToContainer").textContent="";R()} window.toggleReaction=function(a,b,c){var d=E.a[a],e,f;(d=E.a[a])&&(e=oa(d,b))&&(f=H(E.context,a))&&(e.C[c]&&-1!==e.C[c].indexOf(f.self.id)?(d=new XMLHttpRequest,d.open("DELETE","api/reaction?room="+a+"&msg="+b+"&reaction="+encodeURIComponent(c),!0),d.send(null)):ab(a,b,c))}; function bb(a){a:{var b={};if(P){var c;for(c=P;!b[a];){if(c=c.b.data[a])if("alias:"==c.substr(0,6))b[a]=!0,a=c.substr(6);else{a=document.createElement("span");a.className="emoji-custom emoji";a.style.backgroundImage="url('"+c+"')";break a}break}}}"string"===typeof a&&"makeEmoji"in window&&(a=window.makeEmoji(a));return"string"===typeof a?null:a}function cb(a,b){document.getElementById("linkFavicon").href=a||b?"favicon.png?h="+a+"&m="+b:"favicon_ok.png"} function O(){var a=N.length,b="";if(X)b="!"+K.Oa+" - Mimouchat",document.getElementById("linkFavicon").href="favicon_err.png";else if(a)b="(!"+a+")",cb(a,a);else{var c=0;sa(E.context,function(a){a.N>a.B&&c++});c&&(b="("+c+")");cb(0,c)}!b.length&&M&&(b=M.name);document.title=b.length?b:"Mimouchat"} function db(){if("Notification"in window)if("granted"===Notification.permission){var a=Date.now();if(Oa+3E4Math.abs(d-b.l)&&!(b instanceof z)?e.classList.add("chatmsg-same-ts"):d=b.l:(d=b.l,h=!0);(!c||c.l<=M.B)&&b.l>M.B?g.classList.add("chatmsg-first-unread"):g.classList.remove("chatmsg-first-unread"); if(b instanceof z)e=c=null,d=0,a.appendChild(g),f=null;else{if(h||!f){var h=I(b.J),n=b.username,k=document.createElement("div"),l=document.createElement("div"),q=document.createElement("span"),t=document.createElement("img");k.Z=document.createElement("span");k.Z.className="chatmsg-author-img-wrapper";t.className="chatmsg-author-img";q.className="chatmsg-author-name";h?(q.textContent=h.name,t.src="api/avatar?user="+h.id):(q.textContent=n||"?",t.src="");k.Z.appendChild(t);l.appendChild(k.Z);l.appendChild(q); l.className="chatmsg-author";k.className="chatmsg-authorGroup";k.appendChild(l);k.content=document.createElement("div");k.content.className="chatmsg-author-messages";k.appendChild(k.content);f=k;Na.push(f);a.appendChild(f)}c=b;e=g;f.content.appendChild(g)}}});b=document.getElementById("chatWindow");b.textContent="";b.appendChild(a);b.scrollTop=b.scrollHeight-b.clientHeight;eb();window.hasFocus&&$a()} function fb(a,b){if(a.classList.contains("chatmsg-hover-reply"))V&&(V=null,W()),T!==b&&(T=b,U());else if(a.classList.contains("chatmsg-hover-reaction")){var c=M.id,d=b.id;gb.ba(document.body,P,function(a){a&&ab(c,d,a)})}else a.classList.contains("chatmsg-hover-edit")?(T&&(T=null,U()),V!==b&&(V=b,W())):a.classList.contains("chatmsg-hover-star")||a.classList.contains("chatmsg-hover-pin")||!a.classList.contains("chatmsg-hover-remove")||(T&&(T=null,U()),V&&(V=null,W()),hb(b))} function ib(a){function b(a,b){for(b=b||a.target;b!==a.currentTarget&&b;){if(b.id&&b.classList.contains("chatmsg-item"))return b.id;b=b.parentElement}}for(var c=a.target;c!==a.currentTarget&&c&&!c.classList.contains("chatmsg-hover");){var d;if(c.parentElement&&c.classList.contains("chatmsg-attachment-actions-item")){var e=c.dataset.attachmentIndex,f=c.dataset.actionIndex;if((d=b(a,c))&&void 0!==e&&void 0!==f){d=d.substr(d.lastIndexOf("_")+1);(a=oa(E.a[M.id],d))&&a.o[e]&&a.o[e].actions&&a.o[e].actions[f]&& jb(a,a.o[e],a.o[e].actions[f]);break}}if(c.parentElement&&c.parentElement.classList.contains("chatmsg-hover")){if(d=b(a,c))d=d.substr(d.lastIndexOf("_")+1),(a=oa(E.a[M.id],d))&&fb(c,a);break}c=c.parentElement}} function jb(a,b,c){function d(){var d={actions:[c],attachment_id:b.id,callback_id:b.callback_id,channel_id:e,is_ephemeral:a instanceof A,message_ts:a.id},g=new XMLHttpRequest;g.open("POST","api/attachmentAction?serviceId="+a.J);g.send(JSON.stringify(d))}var e=M.id;c.confirm?Ma(La(new za(c.confirm.title,c.confirm.text),c.confirm.ok_text,c.confirm.dismiss_text),d).ba():d()}function R(){document.getElementById("msgInput").focus()} function Ta(){var a=document.location.hash.substr(1),b=ua(a);b&&b!==M?kb(b):(a=I(a))&&a.b&&kb(a.b)}function eb(){var a=document.getElementById("chatWindow").getBoundingClientRect().top;Na.forEach(function(b){var c=b.Z,d=c.clientHeight;b=b.getBoundingClientRect();c.style.top=Math.max(0,Math.min(a-b.top,b.height-d-d/2))+"px"})} document.addEventListener("DOMContentLoaded",function(){xa();lb();var a=document.getElementById("chanSearch");a.addEventListener("input",Sa);a.addEventListener("blur",Sa);document.getElementById("chatWindow").addEventListener("click",ib);window.addEventListener("hashchange",function(){document.location.hash&&"#"===document.location.hash[0]&&Ta()});document.getElementById("currentRoomStar").addEventListener("click",function(a){a.preventDefault();M&&(M.G?(a=new XMLHttpRequest,a.open("POST","api/unstarChannel?room="+ M.id,!0)):(a=new XMLHttpRequest,a.open("POST","api/starChannel?room="+M.id,!0)),a.send(null));return!1});document.getElementById("fileUploadCancel").addEventListener("click",function(a){a.preventDefault();document.getElementById("fileUploadError").classList.add("hidden");document.getElementById("fileUploadContainer").classList.add("hidden");document.getElementById("fileUploadInput").value="";return!1});document.getElementById("ctxMenuSettings").addEventListener("click",function(a){a.preventDefault(); mb.display()});document.getElementById("fileUploadForm").addEventListener("submit",function(a){a.preventDefault();a=document.getElementById("fileUploadInput");var b=a.value;b&&(b=b.substr(b.lastIndexOf("\\")+1),nb(b,a.files[0],function(a){var b=document.getElementById("fileUploadError");a?(b.textContent=a,b.classList.remove("hidden")):(b.classList.add("hidden"),document.getElementById("fileUploadInput").value="",document.getElementById("fileUploadContainer").classList.add("hidden"))}));return!1}); document.getElementById("attachFile").addEventListener("click",function(a){a.preventDefault();M&&document.getElementById("fileUploadContainer").classList.remove("hidden");return!1});document.getElementById("msgForm").addEventListener("submit",function(a){a.preventDefault();a=document.getElementById("msgInput");M&&a.value&&ob(a.value)&&(a.value="",T&&(T=null,U()),V&&(V=null,U()),document.getElementById("slashList").textContent="");R();return!1});window.addEventListener("blur",function(){window.hasFocus= !1});window.addEventListener("focus",function(){window.hasFocus=!0;Oa=0;M&&$a();R()});document.getElementById("chatWindow").addEventListener("scroll",eb);var b=0;document.getElementById("msgInput").addEventListener("input",function(){if(M){var a=Date.now();b+3E3"+b.outerHTML+"":a.style.backgroundImage='url("smile.svg")';(b=window.makeEmoji("paperclip"))?document.getElementById("attachFile").innerHTML=""+b.outerHTML+"":document.getElementById("attachFile").style.backgroundImage='url("public/paperclip.svg")';a.addEventListener("click",function(){P&&gb.ba(document.body,P,function(a){a&&(document.getElementById("msgInput").value+=":"+a+":");R()})})}else a.classList.add("hidden")})();tb()});var mb=function(){function a(a){c&&(document.getElementById("settings").classList.remove("display-"+c),document.getElementById("setting-menu-"+c).classList.remove("selected"),document.getElementById("settings-serviceAddSection").classList.add("hidden"));document.getElementById("settings").classList.add("display-"+a);document.getElementById("setting-menu-"+a).classList.add("selected");c=a}var b=!1,c=null,d={P:"services",display:"display",ub:"privacy"};document.getElementById("settingMenuItems").addEventListener("click", function(b){for(var c=b.target;b.currentTarget!==c&&c;c=c.parentNode)if(c.dataset&&c.dataset.target)for(var e in d)if(d[e]===c.dataset.target){a(d[e]);return}});document.getElementById("settings-serviceAddButton").addEventListener("click",function(a){a.preventDefault();document.getElementById("settings-serviceAddSection").classList.remove("hidden");return!1});document.getElementById("settings-serviceAddConfirm").addEventListener("click",function(a){a.preventDefault();document.location.href=document.getElementById("settings-serviceAddServiceList").value; return!1});return{display:function(c){b||(document.getElementById("settings").classList.remove("hidden"),b=!0);a(c||d.P);return this},fb:function(){return this},cb:d}}();function ub(a){if(void 0!==a.latitude&&void 0!==a.longitude&&-90<=a.latitude&&90>=a.latitude&&-180<=a.longitude&&180>=a.longitude){var b=0,c=function(a,b,c,d){return new Promise(function(e,f){var g=new Image;g.addEventListener("load",function(){d.M=g;e(d)});g.addEventListener("error",function(){console.warn("Error loading tile ",{zoom:a,x:b,y:c});f(g)});g.crossOrigin="anonymous";g.src="https://c.tile.openstreetmap.org/"+a+"/"+b+"/"+c+".png"})},d=document.createElement("canvas"),e=document.createElement("canvas"); d.height=d.width=e.height=e.width=300;var f=d.getContext("2d"),g=e.getContext("2d"),m=function(a,b,c){a=a*Math.PI/180;b=b*Math.PI/180;c=c*Math.PI/180;return Math.abs(6371E3*Math.acos(Math.pow(Math.sin(a),2)+Math.pow(Math.cos(a),2)*Math.cos(c-b)))},h=function(a,d,e,h){g.fillStyle="#808080";g.fillRect(0,0,300,300);f.fillStyle="#808080";f.fillRect(0,0,300,300);var l=Math.pow(2,a),k=(e+180)/360*l,n=(1-Math.log(Math.tan(d*Math.PI/180)+1/Math.cos(d*Math.PI/180))/Math.PI)/2*l,F=Math.floor(k),ba=Math.floor(n), ca=h?100*h/m(180/Math.PI*Math.atan(.5*(Math.exp(Math.PI-2*Math.PI*ba/l)-Math.exp(-(Math.PI-2*Math.PI*ba/l)))),F/l*360-180,(F+1)/l*360-180):0;d=b;for(e=0;3>e;e++)for(h=0;3>h;h++)c(a,F+e-1,ba+h-1,{Za:e,ab:h,Ua:d}).then(function(a){if(a.Ua===b){g.drawImage(a.M,100*a.Za,100*a.ab,100,100);a=k-F;var c=n-ba;a=100*a+100;c=100*c+100;f.putImageData(g.getImageData(0,0,300,300),0,0);void 0!==ca&&(f.beginPath(),f.arc(a,c,Math.max(ca,10),0,2*Math.PI,!1),f.lineWidth=2,f.fillStyle="rgba(244, 146, 66, 0.4)",f.strokeStyle= "rgba(244, 146, 66, 0.8)",f.stroke(),f.fill());if(void 0===ca||25c.bottom||a.screenXc.right)&&b()});n.className="emojibar-overlay";h.className="emojibar";k.className="emojibar-emojis";y.className="emojibar-detail";C.className="emojibar-detail-img";B.className="emojibar-detail-name";l.className=q.className="emojibar-list";t.className="emojibar-search"; y.appendChild(C);y.appendChild(B);k.appendChild(g(window.emojiProviderHeader));k.appendChild(l);k.appendChild(g("emojicustom.png"));k.appendChild(q);h.appendChild(k);h.appendChild(y);h.appendChild(t);t.addEventListener("keyup",function(){d()});h.addEventListener("mousemove",function(b){a(b,function(a){var b=a?w[a]||x[a]:null;b?(C.innerHTML=b.c.outerHTML,B.textContent=":"+a+":"):(C.textContent="",B.textContent="")})});h.addEventListener("click",function(b){a(b,function(a){a&&c()&&G&&G(a)})});return{isSupported:m, ba:function(a,b,c){return m()?(S=b,G=c,a.appendChild(n),a.appendChild(h),t.value="",d(),t.focus(),!0):!1},search:d,close:b}}();var E,N=[];function zb(){fa.call(this)}zb.prototype=Object.create(fa.prototype);zb.prototype.constructor=zb;function ra(a){return a.a?a.a.id:null}function Ab(){this.b=0;this.context=new pa;this.a={}} Ab.prototype.update=function(a){var b=Date.now();a.v&&(this.b=a.v);if(a["static"])for(e in a["static"]){var c=qa(this.context,e);c||(c=new zb,this.context.push(c));ha(c,a["static"][e],b)}sa(this.context,function(a){a.N===a.B&&(a=N.indexOf(a),-1!==a&&N.splice(a,1))});if(a.live){for(e in a.live)(c=this.a[e])?la(c,a.live[e],b):c=this.a[e]=new Y(e,250,a.live[e],b);for(var d in a.live){var e=H(this.context,d);(c=e.j[d])?(this.a[d].a.length&&(c.N=Math.max(c.N,na(this.a[d]).l)),c.Y||(Bb(e,c,a.live[d]),M&& a.live[M.id]&&Q())):E.b=0}}a["static"]&&Pa();var f=!1;a.typing&&this.context.a.forEach(function(c){var d=f,e=a.typing,g=!1;if(c.s)for(var k in c.s)e[k]||(delete c.s[k],g=!0);if(e)for(k in e)if(c.j[k]){c.s[k]||(c.s[k]={});for(var l in e[k])c.s[k][l]||(g=!0),c.s[k][l]=b}f=d|g},this);(a["static"]||f)&&Va();a.config&&(Cb=new Db(a.config),Eb()&&mb.fb(!1).display(mb.cb.P),Fb());if(P&&M&&a["static"]&&a["static"][P.a.id]&&a["static"][P.a.id].channels&&a["static"][P.a.id].channels)for(d=a["static"][P.a.id].channels, e=0,c=d.length;ea.B){var c=E.a[a.id];if(c&&(c=c.a[c.a.length-1])){var d=new XMLHttpRequest;d.open("POST","api/markread?room="+a.id+"&id="+c.id+"&ts="+c.l,!0);d.send(null);a.B=c.l}}0<=b&&(N.splice(b,1),O());a=document.getElementById("room_"+a.id);a.classList.remove("unread");a.classList.remove("unreadHi")}E=new Ab;var Ua=function(){function a(a,c){c.sort(function(){return Math.random()-.5});for(var d=0,e=20;ed/(c.height*c.width))for(e=0;eE.a[M.id].a.length)&&Gb()} function nb(a,b,c){var d=M;new FileReader;var e=new FormData,f=new XMLHttpRequest;e.append("file",b);e.append("filename",a);f.onreadystatechange=function(){4===f.readyState&&(204===f.status?c(null):c(f.statusText))};f.open("POST","api/file?room="+d.id);f.send(e)} function Jb(a,b,c){var d=new XMLHttpRequest;b="api/msg?room="+a.id+"&text="+encodeURIComponent(b);c&&(b+="&attachments="+encodeURIComponent(JSON.stringify([{fallback:c.text,author_name:I(c.J).name,text:c.text,footer:a.b?K.message:a.name,ts:c.l}])));d.open("POST",b,!0);d.send(null)} function ob(a){if(V){var b=new XMLHttpRequest;b.open("PUT","api/msg?room="+M.id+"&ts="+V.id+"&text="+encodeURIComponent(a),!0);b.send(null);return!0}if("/"===a[0]){var c=a.indexOf(" "),b=a.substr(0,-1===c?void 0:c);a=-1===c?"":a.substr(c);var c=P,d=qb.La(b);return d?(d.exec(c,M,a.trim()),!0):c&&(b=c.i.data[b])?(c=new XMLHttpRequest,c.open("POST","api/cmd?room="+M.id+"&cmd="+encodeURIComponent(b.name.substr(1))+"&args="+encodeURIComponent(a.trim()),!0),c.send(null),!0):!1}Jb(M,a,T);return!0} function hb(a){var b=new XMLHttpRequest;b.open("DELETE","api/msg?room="+M.id+"&ts="+a.id,!0);b.send(null)}function ab(a,b,c){var d=new XMLHttpRequest;d.open("POST","api/reaction?room="+a+"&msg="+b+"&reaction="+encodeURIComponent(c),!0);d.send(null)}function Sa(){var a={},b=[],c=this.value;sa(E.context,function(b){a[b.id]=ja(b,c)});for(var d in a){var e=document.getElementById("room_"+d);e&&(a[d].name+a[d].bb+a[d].ta+a[d].qa?(e.classList.remove("hidden"),b.push(d)):e.classList.add("hidden"))}};var Kb={emojione_v2_3:{Na:"emojione_v2.3.sprites.js",Ia:"emojione_v2.3.sprites.css",name:"Emojione v2.3"},emojione_v3:{Na:"emojione_v3.sprites.js",Ia:"emojione_v3.sprites.css",name:"Emojione v3"}},Lb=Kb.emojione_v2_3,Mb; function Nb(a){if(Mb!==a){console.log("Loading emoji pack "+a.name);var b=new XMLHttpRequest;b.timeout=6E4;b.onreadystatechange=function(){if(4===b.readyState){var c=document.createElement("script"),d=document.createElement("link");c.innerHTML=b.response;c.language="text/javascript";d.href=a.Ia;d.rel="stylesheet";document.head.appendChild(d);document.body.appendChild(c);for(var e in E.a)Ob(E.a[e]);Q()}};b.open("GET",a.Na,!0);b.send(null);Mb=a}} function Fb(){a:{var a=Cb;for(var b in a.P){var c=a.P[b].emojiProvider;if(c&&Kb[c]){a=c;break a}}a=void 0}Nb(a&&Kb[a]?Kb[a]:Lb)};function Y(a,b,c,d){D.call(this,a,b,0,c,d)}Y.prototype=Object.create(D.prototype);Y.prototype.constructor=Y;Y.prototype.i=function(a,b){return!0===a.isMeMessage?new Pb(this.id,a,b):!0===a.isNotice?new Qb(this.id,a,b):new Rb(this.id,a,b)};function Ob(a){a.a.forEach(function(a){a.F()})} var Z=function(){function a(a,d){return ya(d,{A:a.context.self.O.A,V:function(a){":"===a[0]&&":"===a[a.length-1]&&(a=a.substr(1,a.length-2));if(a=bb(a)){var b=document.createElement("span");b.className="emoji-small";b.appendChild(a);return b.outerHTML}return null},aa:function(c){return b(a,c)}})}function b(a,b){var c=b.indexOf("|");if(-1===c)var d=b;else{d=b.substr(0,c);var g=b.substr(c+1)}if("@"===d[0])if(d=ra(a.context)+"|"+d.substr(1),g=I(d))a=!0,d="#"+g.pa.id,g="@"+g.name;else return null;else if("#"=== d[0])if(d=ra(a.context)+"|"+d.substr(1),g=ua(d))a=!0,d="#"+d,g="#"+g.name;else return null;else{if(!d.match(/^(https?|mailto):\/\//i))return null;a=!1}return{link:d,text:g||d,Ma:a}}return{F:function(a){a.R=!0;return a},T:function(a){a.c&&a.c.parentElement&&(a.c.remove(),delete a.c);return a},L:function(a){a.c?a.R&&(a.R=!1,a.I()):a.ia().I();return a.c},I:function(b){var c=I(b.J);b.c.l.innerHTML=K.W(b.l);b.c.sa.innerHTML=a(b,b.text);b.c.ja.textContent=c?c.name:b.username||"?";for(var c=document.createDocumentFragment(), e=0,f=b.o.length;e