Explorar o código

[bugfix] stop sending notifications when the new message is from me ...
[add] add usercount and userlist to roominfo panel
[bugfix] duplicateDom lazy create it if necessary
[bugfix] long polling

B Thibault %!s(int64=8) %!d(string=hai) anos
pai
achega
99b8417c01

+ 8 - 6
cli/data.js

@@ -196,13 +196,15 @@ function onMsgReceived(ctx, chan, msg) {
             if (parseFloat(i["ts"]) <= chan.lastRead) {
                 return;
             }
-            areNew = true;
-            if (chan instanceof PrivateMessageRoom || (i["text"] && (i["text"].match(selfReg) || isHighlighted(ctx, i["text"])))) {
-                if (HIGHLIGHTED_CHANS.indexOf(chan) === -1) {
-                    newHighlited = true;
-                    HIGHLIGHTED_CHANS.push(chan);
+            if (i["userId"] === ctx.self.id) {
+                areNew = true;
+                if (chan instanceof PrivateMessageRoom || (i["text"] && (i["text"].match(selfReg) || isHighlighted(ctx, i["text"])))) {
+                    if (HIGHLIGHTED_CHANS.indexOf(chan) === -1) {
+                        newHighlited = true;
+                        HIGHLIGHTED_CHANS.push(chan);
+                    }
+                    highligted = true;
                 }
-                highligted = true;
             }
         });
         if (areNew) {

+ 1 - 2
cli/dom.js

@@ -183,10 +183,9 @@ function addHoverButtons(hover, msg) {
 
 /**
  * @param {UiMessage|UiMeMessage|UiNoticeMessage} msg
- * @param {boolean=} skipAttachment
  * @return {Element}
 **/
-function doCreateMessageDom(msg, skipAttachment) {
+function doCreateMessageDom(msg) {
     var channelId = msg.channelId;
     var dom = document.createElement("div")
         ,msgBlock = document.createElement("div")

+ 6 - 0
cli/lang/en.js

@@ -70,6 +70,12 @@ lang["en"].pinCount = function(count) {
     return count + (count === 1 ? " pinned message" : " pinned messages");
 };
 
+lang["en"].userCount = function(count) {
+    if (count === 0)
+        return "No users in this room";
+    return count + (count === 1 ? " user" : " users");
+};
+
 lang["en"].edited = function(ts) {
     return "(edited " +lang["en"].formatDate(ts) +")";
 };

+ 6 - 0
cli/lang/fr.js

@@ -70,6 +70,12 @@ lang["fr"].pinCount = function(count) {
     return count + (count === 1 ? " message épinglé" : " messages épinglés");
 };
 
+lang["fr"].userCount = function(count) {
+    if (count === 0)
+        return "Pas de chatteur";
+    return count + (count === 1 ? " chatteur" : " chatteurs");
+};
+
 lang["fr"].edited = function(ts) {
     return "(edit&eacute; " +lang["fr"].formatDate(ts) +")";
 };

+ 29 - 1
cli/roomInfo.js

@@ -86,7 +86,7 @@ var roomInfo = (function() {
                 unpinButton.addEventListener("click", removePin);
                 unpinButton.className = R.klass.button +' ' +R.klass.chatList.roomInfo.unpin;
                 li.className = R.klass.chatList.roomInfo.pinItem;
-                li.appendChild(uiMsg.getDom());
+                li.appendChild(uiMsg.duplicateDom());
                 li.appendChild(unpinButton);
                 pinFrag.appendChild(li);
             });
@@ -117,6 +117,34 @@ var roomInfo = (function() {
         domHeader.style.backgroundImage = "";
         headerContent.classList.remove(R.klass.presenceIndicator);
 
+        userCount.textContent = locale.userCount(currentChan.users ? Object.keys(currentChan.users).length : 0);
+        /** @type {Array<Chatter>} */
+        var memberIds = [];
+        if (currentChan.users)
+            for (var id in currentChan.users)
+                memberIds.push(currentChan.users[id]);
+        memberIds.sort(function(a, b) {
+            if (a.presence && !b.presence)
+                return -1;
+            if (b.presence && !a.presence)
+                return 1;
+            return a.getName().localeCompare(b.getName());
+        });
+        var userFrag = document.createDocumentFragment();
+        memberIds.forEach(function(user) {
+            var li = document.createElement("li"),
+                link = document.createElement("a");
+            link.href = '#' +user.id;
+            link.textContent = user.getName();
+            li.appendChild(link);
+            li.classList.add(R.klass.presenceIndicator);
+            if (!user.presence)
+                li.classList.add(R.klass.presenceAway);
+            userFrag.appendChild(li);
+        });
+        userList.textContent = "";
+        userList.appendChild(userFrag);
+
         dom.classList.add(R.klass.chatList.roomInfo.type.channel);
         dom.classList.remove(R.klass.chatList.roomInfo.type.user);
 

+ 4 - 4
cli/uiMessage.js

@@ -222,7 +222,7 @@ var AbstractUiMessage = (function() {
         },
 
         duplicateDom: function(_this) {
-            return _this.dom.cloneNode(true);
+            return _this.getDom().cloneNode(true);
         },
 
         formatText: function(_this, text) {
@@ -270,7 +270,7 @@ UiMeMessage.prototype.getDom = function() {
 };
 
 UiMeMessage.prototype.createDom = function() {
-    this.dom = doCreateMessageDom(this, false);
+    this.dom = doCreateMessageDom(this);
     this.dom.classList.add(R.klass.msg.meMessage);
     return this;
 };
@@ -330,7 +330,7 @@ UiMessage.prototype.getDom = function() {
 };
 
 UiMessage.prototype.createDom = function() {
-    this.dom = doCreateMessageDom(this, false);
+    this.dom = doCreateMessageDom(this);
     return this;
 };
 
@@ -425,7 +425,7 @@ UiNoticeMessage.prototype.duplicateDom = function() {
 };
 
 UiNoticeMessage.prototype.createDom = function() {
-    this.dom = doCreateMessageDom(this, false);
+    this.dom = doCreateMessageDom(this);
     this.domWrapper = document.createElement("span");
     this.dom.classList.add(R.klass.msg.notice);
     this.domWrapper.className = R.klass.msg.notice;

+ 115 - 114
srv/public/mimouchat.min.js

@@ -1,128 +1,129 @@
 "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 ba(a){this.jb=a.desc;this.name=a.name;this.type=a.type;this.usage=a.usage;this.U=a.category}function ca(){this.a={};this.B=[];this.version=0}
-ca.prototype.update=function(a,b){a.emoji_use&&(this.a=JSON.parse(a.emoji_use));a.highlight_words?this.B=(a.highlight_words||"").split(",").filter(function(a){return""!==a.trim()}):a.highlights&&(this.B=a.highlights);this.version=Math.max(this.version,b)};function da(){this.a=null;this.l={};this.j={};this.self=null;this.b={version:0,data:{}};this.h={version:0,data:{}};this.u={};this.Y={};this.o=0}function ea(a,b){return b.pv?new t(b.id,a.j[b.user]):new v(b.id)}
-function ga(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;e<f;e++){var g=a.j[d+b.users[e].id];g||(g=a.j[d+b.users[e].id]=new y(b.users[e].id));g.update(b.users[e],c)}if(b.channels)for(e=0,f=b.channels.length;e<f;e++)(g=a.l[d+b.channels[e].id])||(g=a.l[d+b.channels[e].id]=ea(a,b.channels[e])),g.update(b.channels[e],a,c,d);b.emojis&&(a.b.data=b.emojis,a.b.version=c);if(void 0!==b.commands){a.h.data={};for(e in b.commands)a.h.data[e]=
-new ba(b.commands[e]);a.h.version=c}b.self&&(a.self=a.j[d+b.self.id]||null,a.self.R||(a.self.R=new ca),b.self.prefs&&a.self.R.update(b.self.prefs,c));b.capacities&&(a.Y={},b.capacities.forEach(function(a){this.Y[a]=!0},a));a.o=Math.max(a.o,c)}"undefined"!==typeof module&&(module.H.wb=da,module.H.xb=aa,module.H.zb=ba);function v(a){this.id=a;this.A=!1;this.C=0;this.j={};this.version=0}
-v.prototype.update=function(a,b,c,d){d=d||"";void 0!==a.name&&(this.name=a.name);void 0!==a.is_archived&&(this.da=a.is_archived);void 0!==a.is_member&&(this.$=a.is_member);void 0!==a.last_read&&(this.C=Math.max(parseFloat(a.last_read),this.C));void 0!==a.last_msg&&(this.P=parseFloat(a.last_msg));void 0!==a.is_private&&(this.h=a.is_private);void 0!==a.pins&&(this.b=a.pins);this.A=!!a.is_starred;if(a.members&&(this.j={},a.members))for(var e=0,f=a.members.length;e<f;e++){var g=b.j[d+a.members[e]];this.j[g.id]=
-g;g.l[this.id]=this}a.topic&&(this.ma=a.topic.value,this.I=b.j[d+a.topic.creator],this.ca=a.topic.last_set);a.purpose&&(this.ja=a.purpose.value,this.o=b.j[d+a.purpose.creator],this.ba=a.purpose.last_set);this.version=Math.max(this.version,c)};function ha(a,b){var c=ia;return{name:c.fa(b,a.name),ia:c.fa(b,Object.values(a.j),function(a){return a?a.getName():null}),ma:c.fa(b,a.ma),ja:c.fa(b,a.ja)}}function t(a,b){v.call(this,a);this.a=b;this.name=b.getName();this.h=!0;b.V=this}t.prototype=Object.create(v.prototype);
-t.prototype.constructor=t;"undefined"!==typeof module&&(module.H.Fb=v,module.H.Eb=t);function z(a,b){this.L=a.user;this.username=a.username;this.id=a.id||a.ts;this.m=parseFloat(a.ts);this.text="";this.s=[];this.A=a.is_starred||!1;this.h=this.F=!1;this.D={};this.version=b;this.update(a,b)}function B(a,b){z.call(this,a,b)}function C(a,b){z.call(this,a,b)}
-z.prototype.update=function(a,b){if(a){if(this.text=a.text||"",a.attachments&&(this.s=a.attachments),this.A=!!a.is_starred,this.F=void 0===a.edited?!1:a.edited,this.h=!!a.removed,a.reactions){var c={};a.reactions.forEach(function(a){c[a.name]=[];a.users.forEach(function(b){c[a.name].push(b)})});this.D=c}}else this.h=!0;this.version=b};function D(a,b,c,d,e){this.id="string"===typeof a?a:a.id;this.a=[];this.h=c;this.fb=0;this.o=b;d&&ja(this,d,e)}
-function ja(a,b,c){var d=0;b.forEach(function(a){d=Math.max(this.push(a,c),d)}.bind(a));ka(a);return d}D.prototype.b=function(a,b){return!0===a.isMeMessage?new B(a,b):!0===a.isNotice?new C(a,b):new z(a,b)};
-D.prototype.push=function(a,b){for(var c,d=!1,e,f=0,g=this.a.length;f<g;f++)if(c=this.a[f],c.id===a.id){e=c.update(a,b);d=!0;break}d||(c=this.b(a,b),this.a.push(c),e=c.m);for(;this.a.length>this.o;)this.a.shift();if(this.h)for(a=0;a<this.a.length;a++)this.a[a].version<b-this.h&&this.a.splice(a--,1);return e||0};function la(a){return a.a[a.a.length-1]}function ma(a,b){for(var c=0,d=a.a.length;c<d;c++)if(a.a[c].id==b)return a.a[c];return null}function ka(a){a.a.sort(function(a,c){return a.m-c.m})}
-B.prototype=Object.create(z.prototype);B.prototype.constructor=B;C.prototype=Object.create(z.prototype);C.prototype.constructor=C;"undefined"!==typeof module&&(module.H={Bb:z,Ab:B,Db:C,Gb:D});function y(a){this.id=a;this.l={};this.V=this.R=null;this.version=0}
-y.prototype.update=function(a,b){void 0!==a.name&&(this.name=a.name);void 0!==a.deleted&&(this.Oa=a.deleted);void 0!==a.status&&(this.status=a.status);void 0!==a.goal&&(this.lb=a.goal);void 0!==a.phone&&(this.rb=a.phone);void 0!==a.first_name&&(this.Qa=a.first_name);void 0!==a.last_name&&(this.Va=a.last_name);void 0!==a.real_name&&(this.cb=a.real_name);void 0!==a.isPresent&&(this.wa=a.isPresent);a.isBot&&(this.nb=a.isBot);this.version=Math.max(this.version,b)};
-y.prototype.getName=function(){return this.name||this.cb||this.Qa||this.Va};"undefined"!==typeof module&&(module.H.yb=y);function na(){this.a=[]}na.prototype.push=function(a){this.a.push(a)};function oa(a,b){for(var c=0,d=a.a.length;c<d;c++)if(b===pa(a.a[c]))return a.a[c];return null}function qa(a,b){for(var c=0,d=a.a.length;c<d;c++){var e=a.a[c],f;for(f in e.l)if(!0===b(e.l[f],f))return}}function ra(a){for(var b=E.context,c=0,d=b.a.length;c<d&&!0!==a(b.a[c]);c++);}function I(a,b){for(var c=0,d=a.a.length;c<d;c++)if(a.a[c].l[b])return a.a[c];return null}
-function sa(a){for(var b=E.context,c=0,d=b.a.length;c<d;c++){var e=b.a[c].l[a];if(e)return e}return null}function ta(a){for(var b=E.context,c=[],d=0,e=b.a.length;d<e;d++){var f=b.a[d].l,g;for(g in f)a&&!a(f[g],b.a[d],g)||c.push(g)}return c}function J(a){for(var b=E.context,c=0,d=b.a.length;c<d;c++){var e=b.a[c].j[a];if(e)return e}return null}"undefined"!==typeof module&&(module.H.Cb=na);var ia=function(){function a(b,c,d){if(Array.isArray(c)){for(var e=0,f=0,g=c.length;f<g;f++){var h=a(b,c[f],d);if(1===h)return 1;e=Math.max(h,e)}return e}return(c=d?d(c):c)&&void 0!==b&&null!==b?b.length?-1===c.indexOf(b)?0:b.length/c.length:1:0}return{fa:a}}();"undefined"!==typeof module&&(module.H.Hb=ia);var L={},M,ua=[];function va(){if(!c){for(var a=0,b=navigator.languages.length;a<b;a++)if(L.hasOwnProperty(navigator.languages[a])){var c=navigator.languages[a];break}c||(c="en")}M=L[c];console.log("Loading language pack: "+c);if(M.c)for(var d in M.c)if(c=document.getElementById(d))c.textContent=M.c[d];ua.forEach(function(a){a()})};L.fr={vb:"Utilisateur inconnu",ub:"Channel inconnu",Xa:"Nouveau message",message:"Message",Wa:"Reseau",Ya:"(visible seulement par vous)",A:"Favoris",l:"Discutions",ia:"Membres",bb:"Discutions priv\u00e9es",eb:"Partage sa position GPS",ok:"Ok",Pa:"Annuler",N: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()?"hier, "+
-a.toLocaleTimeString():a.toLocaleString()},ua: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"}};L.fr.Za=function(a){return 0===a?"Pas de message \u00e9pingl\u00e9":a+(1===a?" message \u00e9pingl\u00e9":" messages \u00e9pingl\u00e9s")};L.fr.F=function(a){return"(edit&eacute; "+L.fr.N(a)+")"};L.fr.za=function(a,b){return"par "+a.getName()+" le "+L.fr.N(b)};L.en={vb:"Unknown member",ub:"Unknown channel",Xa:"New message",message:"Message",Wa:"Network",Ya:"(only visible to you)",A:"Starred",l:"Channels",ia:"Members",bb:"Direct messages",eb:"Share your GPS location",ok:"Ok",Pa:"Cancel",N: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()},ua: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"}};L.en.Za=function(a){return 0===a?"No pinned messages":a+(1===a?" pinned message":" pinned messages")};L.en.F=function(a){return"(edited "+L.en.N(a)+")"};L.en.za=function(a,b){return"by "+a.getName()+" on "+L.en.N(b)};var wa=function(){function a(a){this.text="";this.g=a}function b(b,c,d){this.X=c;this.f=null;this.i=[];this.a=d||"";this.pa="<"===this.a;this.xa="*"===this.a;this.oa="_"===this.a;this.qa="~"===this.a||"-"===this.a;this.h=">"===this.a||"&gt;"===this.a;this.I=":"===this.a;this.Aa="`"===this.a;this.La="```"===this.a;this.Ba="\n"===this.a;this.na=void 0!==d&&-1!==l.B.indexOf(d);this.g=b;this.ra=null;this.b=this.Ba||this.na?c+d.length-1:!1;this.na&&(this.f=new a(this),this.i.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||n;for(var c=0,e=a.i.length;c<e;c++){var m=
-a.i[c];if(m instanceof b)if(m.b){if(m=d(m))return m}else return m}return null}function e(a,c){a.g instanceof b&&(a.g.i.splice(a.g.i.indexOf(a)+(c?1:0)),a.g.f=a.g.i[a.g.i.length-1],e(a.g,!0))}function f(a){return a}function g(a){return{link:a,text:a,Ta:!1}}var h,n,l={B:[],Z:f,la:f,ha:g};b.prototype.Da=function(){return this.xa&&!!this.b||this.g instanceof b&&this.g.Da()};b.prototype.Ga=function(){return this.oa&&!!this.b||this.g instanceof b&&this.g.Ga()};b.prototype.Ha=function(){return this.qa&&
-!!this.b||this.g instanceof b&&this.g.Ha()};b.prototype.ca=function(){return this.I&&!!this.b||this.g instanceof b&&this.g.ca()};b.prototype.Fa=function(){return this.na&&!!this.b||this.g instanceof b&&this.g.Fa()};b.prototype.Ea=function(){return this.Aa&&!!this.b||this.g instanceof b&&this.g.Ea()};b.prototype.ba=function(){return this.La&&!!this.b||this.g instanceof b&&this.g.ba()};b.prototype.Ia=function(){for(var a=0,c=this.i.length;a<c;a++)if(this.i[a]instanceof b&&(!this.i[a].b||this.i[a].Ia()))return!0;
-return!1};b.prototype.Ja=function(a){if("<"===this.a&&">"===h[a])return!0;var b=c(h[a-1]);if(!this.h&&h.substr(a,this.a.length)===this.a){if(!b&&(this.xa||this.oa||this.qa))return!1;if(this.f&&this.Ia())return this.f.Ma();if(this.gb())return!0}return"\n"===h[a]&&this.h?!0:!1};b.prototype.gb=function(){for(var a=this;a;){for(var c=0,d=a.i.length;c<d;c++)if(a.i[c]instanceof b||a.i[c].text.length)return!0;a=a.ra}return!1};b.prototype.Ma=function(){var a=new b(this.g,this.X,this.a);a.ra=this;this.f&&
-this.f instanceof b&&(a.f=this.f.Ma(),a.i=[a.f]);return a};b.prototype.hb=function(a){return this.I&&(" "===h[a]||"\t"===h[a])||(this.I||this.pa||this.xa||this.oa||this.qa||this.Aa)&&"\n"===h[a]?!1:!0};b.prototype.ib=function(b){if(this.Aa||this.I||this.La||this.pa)return null;if(!this.f||this.f.b||this.f instanceof a){var d=c(h[b-1]),e=c(h[b+1]);if("```"===h.substr(b,3))return"```";var f=n.va();if(void 0===f||f){if("&gt;"===h.substr(b,4))return"&gt;";if(">"===h[b])return h[b]}if("`"===h[b]&&!d||
-"\n"===h[b]||!(-1===["*","~","-","_"].indexOf(h[b])||!e&&void 0!==h[b+1]&&-1==="*~-_<&".split("").indexOf(h[b+1])||d&&void 0!==h[b-1]&&-1==="*~-_<&".split("").indexOf(h[b-1]))||-1!==[":"].indexOf(h[b])&&e||-1!==["<"].indexOf(h[b]))return h[b];d=0;for(e=l.B.length;d<e;d++)if(f=l.B[d],h.substr(b,f.length)===f)return f}return null};a.prototype.va=function(){if(""!==this.text.trim())return!1};b.prototype.va=function(){for(var a=this.i.length-1;0<=a;a--){var b=this.i[a].va();if(void 0!==b)return b}if(this.Ba||
-this.h)return!0};a.prototype.o=function(a){this.text+=h[a];return 1};b.prototype.o=function(c){var d=this.f&&!this.f.b&&this.f.Ja?this.f.Ja(c):null;if(d){var e=this.f.a.length;this.f.Ca(c);d instanceof b&&(this.f=d,this.i.push(d));return e}if(!this.f||this.f.b||this.f instanceof a||this.f.hb(c)){if(d=this.ib(c))return this.f=new b(this,c,d),this.i.push(this.f),this.f.a.length;if(!this.f||this.f.b)this.f=new a(this),this.i.push(this.f);return this.f.o(c)}d=this.f.X+1;n.$(this.f.X);this.f=new a(this);
-this.f.o(d-1);this.i.pop();this.i.push(this.f);return d-c};b.prototype.Ca=function(a){for(var b=this;b;)b.b=a,b=b.ra};b.prototype.$=function(a){this.b&&this.b>=a&&(this.b=!1);this.i.forEach(function(c){c instanceof b&&c.$(a)})};a.prototype.innerHTML=function(){if(this.g.ca()){for(var a=this.g;a&&!a.I;)a=a.g;if(a){var a=a.a+this.text+a.a,b=l.Z(a);return b?b:a}return(a=l.Z(this.text))?a:this.text}if(this.g.ba()){if("undefined"!==typeof hljs)try{return a=this.text.match(/^\w+/),hljs.configure({useBR:!0,
-tabReplace:"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"}),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,"<br/>")}return l.la(this.text)};a.prototype.outerHTML=function(){var a="span",b=[],c="";if(this.g.ba()){a="pre";b.push("codeblock");var d=this.innerHTML()}else this.g.Ea()?(b.push("code"),d=this.innerHTML()):(this.g.pa&&(d=l.ha(this.text))?
-(a="a",c=' href="'+d.link+'"',d.Ta||(c+=' target="_blank"'),d=l.la(d.text)):d=this.innerHTML(),this.g.Da()&&b.push("bold"),this.g.Ga()&&b.push("italic"),this.g.Ha()&&b.push("strike"),this.g.ca()&&b.push("emoji"),this.g.Fa()&&b.push("highlight"));return"<"+a+c+(b.length?' class="'+b.join(" ")+'"':"")+">"+d+"</"+a+">"};b.prototype.outerHTML=function(){var a="";this.h&&(a+='<span class="quote">');this.Ba&&(a+="<br/>");this.i.forEach(function(b){a+=b.outerHTML()});this.h&&(a+="</span>");return a};b.prototype.Ka=
-function(a){this.h&&!this.b&&this.Ca(a);this.i.forEach(function(c){c instanceof b&&c.Ka(a)})};return function(c,k){k||(k={});l.B=k.B||[];l.Z=k.Z||f;l.la=k.la||f;l.ha=k.ha||g;h=c;n=new b(this,0);k=0;c=h.length;do{for(;k<c;)k+=n.o(k);n.Ka(h.length);if(k=d()){e(k,!1);n.$(k.X);var m=new a(k.g);m.o(k.X);k.g.i.push(m);k.g.f=m;k=k.X+1}else k=void 0}while(void 0!==k);return n.outerHTML()}}();"undefined"!==typeof module&&(module.H.w=wa);function xa(a,b){this.h=a;this.content=b;this.c=ya(this);this.b=za(this);this.a=[];this.o=[]}
-function ya(a){var b=document.createElement("div"),c=document.createElement("header"),d=document.createElement("span"),e=document.createElement("span"),f=document.createElement("div"),g=document.createElement("footer");b.a=document.createElement("span");b.b=document.createElement("span");d.textContent=a.h;"string"==typeof a.content?f.innerHTML=a.content:f.appendChild(a.content);c.className=Aa;d.className=Ba;e.className=Ca;e.textContent="x";c.appendChild(d);c.appendChild(e);b.appendChild(c);f.className=
-Da;b.appendChild(f);b.b.className=Ea;b.b.textContent=M.Pa;b.b.addEventListener("click",function(){Fa(a,!1)});e.addEventListener("click",function(){Fa(a,!1)});b.a.addEventListener("click",function(){Fa(a,!0)});g.appendChild(b.b);b.a.className=Ea;b.a.textContent=M.ok;g.appendChild(b.a);g.className=Ga+" "+Ha;b.appendChild(g);b.className=Ia;return b}function Fa(a,b){(b?a.a:a.o).forEach(function(a){a()});a.close()}
-function za(a){var b=document.createElement("div");b.className=Ja;b.addEventListener("click",function(){Fa(this,!1)}.bind(a));return b}function Ka(a,b,c){a.c.a.textContent=b;a.c.b.textContent=c;return a}xa.prototype.ka=function(a){a=a||document.body;a.appendChild(this.b);a.appendChild(this.c);return this};xa.prototype.close=function(){this.c.remove();this.b.remove();return this};function La(a,b){a.a.push(b);return a};var Ea="button",Ga="button-container",Ia="dialog",Ja="dialog-overlay",Aa="dialog-title",Ba="dialog-title-label",Ca="dialog-title-close",Da="dialog-body",Ha="dialog-footer";var Ma=[],Na=0;
-function Oa(){var a=document.createDocumentFragment(),b=ta(function(a){return!a.da&&!1!==a.$}),c=[],d=[],e=[],f=[],g={};b.sort(function(a,b){if(a[0]!==b[0])return a[0]-b[0];var c=I(E.context,a),d=I(E.context,b);a=c.l[a];b=d.l[b];return a.name===b.name?(g[a.id]=M.ua(c.a.name,a.name),g[b.id]=M.ua(d.a.name,b.name),c.a.name.localeCompare(d.a.name)):a.name.localeCompare(b.name)});b.forEach(function(a){a=sa(a);if(a instanceof t){var b;if(b=!a.a.Oa){var h=g[a.id];b=document.createElement("li");var m=document.createElement("a");
-b.id="room_"+a.id;m.href="#"+a.id;b.className="chat-context-room chat-ims presence-indicator";m.textContent=h||a.a.getName();b.appendChild(Pa());b.appendChild(m);a.a.wa||b.classList.add("presence-away");N===a&&b.classList.add("selected");a.P>a.C&&(b.classList.add("unread"),b.classList.add("unreadHi"));b=h=b}b&&(a.A?c.push(h):f.push(h))}else if(h=g[a.id],b=document.createElement("li"),m=document.createElement("a"),b.id="room_"+a.id,m.href="#"+a.id,a.h?(b.className="chat-context-room chat-group",b.dataset.count=
-Object.keys(a.j||{}).length):b.className="chat-context-room chat-channel",N===a&&b.classList.add("selected"),m.textContent=h||a.name,b.appendChild(Pa()),b.appendChild(m),a.P>a.C&&(b.classList.add("unread"),0<=P.indexOf(a)&&b.classList.add("unreadHi")),h=b)a.A?c.push(h):a.h?e.push(h):d.push(h)});c.length&&a.appendChild(Qa(M.A));c.forEach(function(b){a.appendChild(b)});d.length&&a.appendChild(Qa(M.l));d.forEach(function(b){a.appendChild(b)});e.forEach(function(b){a.appendChild(b)});f.length&&a.appendChild(Qa(M.bb));
-f.forEach(function(b){a.appendChild(b)});document.getElementById("chanList").textContent="";document.getElementById("chanList").appendChild(a);Ra.apply(document.getElementById("chanSearch"));Sa();Q();R&&Ta(R.a.id,R.j,function(a){document.getElementById("chatCtx").style.backgroundImage="url("+a+")"})}
-function Ua(){ra(function(a){var b=a.u,c;for(c in a.self.l)if(!a.self.l[c].da){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.j)(c=a.j[e].V)&&!c.da&&(d=document.getElementById("room_"+c.id))&&(b[c.id]?d.classList.add("chat-context-typing"):d.classList.remove("chat-context-typing"))});Va()}
-function Va(){var a;document.getElementById("whoistyping").textContent="";if(R&&N&&(a=R.u[N.id])){var b=document.createDocumentFragment(),c=!1,d;for(d in a)(a=J(d))?b.appendChild(Wa(a)):c=!0;c&&(E.b=0);document.getElementById("whoistyping").appendChild(b)}}function Xa(a){a?document.body.classList.remove("no-network"):document.body.classList.add("no-network");Q()}
-function Ya(){var a=N.name||(N.a?N.a.getName():void 0);if(!a){console.error("No name provided for ",N);var a=[],b;for(b in N.j)a.push(N.j[b].getName());a=a.join(", ")}document.getElementById("currentRoomTitle").textContent=a;S();T();document.getElementById("fileUploadContainer").classList.add("hidden");Za();U&&(U=null,V());W&&(W=null,V());Q();Va()}
-function V(){if(U){document.body.classList.add("replyingTo");var a=document.getElementById("replyToContainer"),b=document.createElement("a");b.addEventListener("click",function(){U=null;V()});b.className="replyto-close";b.textContent="x";a.textContent="";a.appendChild(b);a.appendChild(U.M())}else document.body.classList.remove("replyingTo"),document.getElementById("replyToContainer").textContent="";T()}
-function $a(){if(W){document.body.classList.add("replyingTo");var a=document.getElementById("replyToContainer"),b=document.createElement("a");b.addEventListener("click",function(){W=null;$a()});b.className="replyto-close";b.textContent="x";a.textContent="";a.appendChild(b);a.appendChild(W.M());document.getElementById("msgInput").value=W.text}else document.body.classList.remove("replyingTo"),document.getElementById("replyToContainer").textContent="";T()}
-window.toggleReaction=function(a,b,c){var d=E.a[a],e,f;(d=E.a[a])&&(e=ma(d,b))&&(f=I(E.context,a))&&(e.D[c]&&-1!==e.D[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))};
+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 ba(a){this.kb=a.desc;this.name=a.name;this.type=a.type;this.usage=a.usage;this.V=a.category}function ca(){this.a={};this.B=[];this.version=0}
+ca.prototype.update=function(a,b){a.emoji_use&&(this.a=JSON.parse(a.emoji_use));a.highlight_words?this.B=(a.highlight_words||"").split(",").filter(function(a){return""!==a.trim()}):a.highlights&&(this.B=a.highlights);this.version=Math.max(this.version,b)};function da(){this.a=null;this.l={};this.h={};this.self=null;this.b={version:0,data:{}};this.i={version:0,data:{}};this.u={};this.Z={};this.o=0}function ea(a,b){return b.pv?new t(b.id,a.h[b.user]):new v(b.id)}
+function ga(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;e<f;e++){var h=a.h[d+b.users[e].id];h||(h=a.h[d+b.users[e].id]=new y(b.users[e].id));h.update(b.users[e],c)}if(b.channels)for(e=0,f=b.channels.length;e<f;e++)(h=a.l[d+b.channels[e].id])||(h=a.l[d+b.channels[e].id]=ea(a,b.channels[e])),h.update(b.channels[e],a,c,d);b.emojis&&(a.b.data=b.emojis,a.b.version=c);if(void 0!==b.commands){a.i.data={};for(e in b.commands)a.i.data[e]=
+new ba(b.commands[e]);a.i.version=c}b.self&&(a.self=a.h[d+b.self.id]||null,a.self.S||(a.self.S=new ca),b.self.prefs&&a.self.S.update(b.self.prefs,c));b.capacities&&(a.Z={},b.capacities.forEach(function(a){this.Z[a]=!0},a));a.o=Math.max(a.o,c)}"undefined"!==typeof module&&(module.H.xb=da,module.H.yb=aa,module.H.Ab=ba);function v(a){this.id=a;this.A=!1;this.C=0;this.h={};this.version=0}
+v.prototype.update=function(a,b,c,d){d=d||"";void 0!==a.name&&(this.name=a.name);void 0!==a.is_archived&&(this.ea=a.is_archived);void 0!==a.is_member&&(this.aa=a.is_member);void 0!==a.last_read&&(this.C=Math.max(parseFloat(a.last_read),this.C));void 0!==a.last_msg&&(this.R=parseFloat(a.last_msg));void 0!==a.is_private&&(this.i=a.is_private);void 0!==a.pins&&(this.b=a.pins);this.A=!!a.is_starred;if(a.members&&(this.h={},a.members))for(var e=0,f=a.members.length;e<f;e++){var h=b.h[d+a.members[e]];this.h[h.id]=
+h;h.l[this.id]=this}a.topic&&(this.na=a.topic.value,this.J=b.h[d+a.topic.creator],this.da=a.topic.last_set);a.purpose&&(this.ka=a.purpose.value,this.o=b.h[d+a.purpose.creator],this.ca=a.purpose.last_set);this.version=Math.max(this.version,c)};function ha(a,b){var c=ia;return{name:c.ga(b,a.name),ja:c.ga(b,Object.values(a.h),function(a){return a?a.getName():null}),na:c.ga(b,a.na),ka:c.ga(b,a.ka)}}function t(a,b){v.call(this,a);this.a=b;this.name=b.getName();this.i=!0;b.W=this}t.prototype=Object.create(v.prototype);
+t.prototype.constructor=t;"undefined"!==typeof module&&(module.H.Gb=v,module.H.Fb=t);function A(a,b){this.N=a.user;this.username=a.username;this.id=a.id||a.ts;this.m=parseFloat(a.ts);this.text="";this.s=[];this.A=a.is_starred||!1;this.i=this.F=!1;this.D={};this.version=b;this.update(a,b)}function B(a,b){A.call(this,a,b)}function D(a,b){A.call(this,a,b)}
+A.prototype.update=function(a,b){if(a){if(this.text=a.text||"",a.attachments&&(this.s=a.attachments),this.A=!!a.is_starred,this.F=void 0===a.edited?!1:a.edited,this.i=!!a.removed,a.reactions){var c={};a.reactions.forEach(function(a){c[a.name]=[];a.users.forEach(function(b){c[a.name].push(b)})});this.D=c}}else this.i=!0;this.version=b};function E(a,b,c,d,e){this.id="string"===typeof a?a:a.id;this.a=[];this.i=c;this.gb=0;this.o=b;d&&ja(this,d,e)}
+function ja(a,b,c){var d=0;b.forEach(function(a){d=Math.max(this.push(a,c),d)}.bind(a));ka(a);return d}E.prototype.b=function(a,b){return!0===a.isMeMessage?new B(a,b):!0===a.isNotice?new D(a,b):new A(a,b)};
+E.prototype.push=function(a,b){for(var c,d=!1,e,f=0,h=this.a.length;f<h;f++)if(c=this.a[f],c.id===a.id){e=c.update(a,b);d=!0;break}d||(c=this.b(a,b),this.a.push(c),e=c.m);for(;this.a.length>this.o;)this.a.shift();if(this.i)for(a=0;a<this.a.length;a++)this.a[a].version<b-this.i&&this.a.splice(a--,1);return e||0};function la(a){return a.a[a.a.length-1]}function ma(a,b){for(var c=0,d=a.a.length;c<d;c++)if(a.a[c].id==b)return a.a[c];return null}function ka(a){a.a.sort(function(a,c){return a.m-c.m})}
+B.prototype=Object.create(A.prototype);B.prototype.constructor=B;D.prototype=Object.create(A.prototype);D.prototype.constructor=D;"undefined"!==typeof module&&(module.H={Cb:A,Bb:B,Eb:D,Hb:E});function y(a){this.id=a;this.l={};this.W=this.S=null;this.version=0}
+y.prototype.update=function(a,b){void 0!==a.name&&(this.name=a.name);void 0!==a.deleted&&(this.Oa=a.deleted);void 0!==a.status&&(this.status=a.status);void 0!==a.goal&&(this.mb=a.goal);void 0!==a.phone&&(this.sb=a.phone);void 0!==a.first_name&&(this.Qa=a.first_name);void 0!==a.last_name&&(this.Va=a.last_name);void 0!==a.real_name&&(this.cb=a.real_name);void 0!==a.isPresent&&(this.L=a.isPresent);a.isBot&&(this.ob=a.isBot);this.version=Math.max(this.version,b)};
+y.prototype.getName=function(){return this.name||this.cb||this.Qa||this.Va};"undefined"!==typeof module&&(module.H.zb=y);function na(){this.a=[]}na.prototype.push=function(a){this.a.push(a)};function oa(a,b){for(var c=0,d=a.a.length;c<d;c++)if(b===pa(a.a[c]))return a.a[c];return null}function qa(a,b){for(var c=0,d=a.a.length;c<d;c++){var e=a.a[c],f;for(f in e.l)if(!0===b(e.l[f],f))return}}function ra(a){for(var b=H.context,c=0,d=b.a.length;c<d&&!0!==a(b.a[c]);c++);}function J(a,b){for(var c=0,d=a.a.length;c<d;c++)if(a.a[c].l[b])return a.a[c];return null}
+function sa(a){for(var b=H.context,c=0,d=b.a.length;c<d;c++){var e=b.a[c].l[a];if(e)return e}return null}function ta(a){for(var b=H.context,c=[],d=0,e=b.a.length;d<e;d++){var f=b.a[d].l,h;for(h in f)a&&!a(f[h],b.a[d],h)||c.push(h)}return c}function K(a){for(var b=H.context,c=0,d=b.a.length;c<d;c++){var e=b.a[c].h[a];if(e)return e}return null}"undefined"!==typeof module&&(module.H.Db=na);var ia=function(){function a(b,c,d){if(Array.isArray(c)){for(var e=0,f=0,h=c.length;f<h;f++){var g=a(b,c[f],d);if(1===g)return 1;e=Math.max(g,e)}return e}return(c=d?d(c):c)&&void 0!==b&&null!==b?b.length?-1===c.indexOf(b)?0:b.length/c.length:1:0}return{ga:a}}();"undefined"!==typeof module&&(module.H.Ib=ia);var L={},M,ua=[];function va(){if(!c){for(var a=0,b=navigator.languages.length;a<b;a++)if(L.hasOwnProperty(navigator.languages[a])){var c=navigator.languages[a];break}c||(c="en")}M=L[c];console.log("Loading language pack: "+c);if(M.c)for(var d in M.c)if(c=document.getElementById(d))c.textContent=M.c[d];ua.forEach(function(a){a()})};L.fr={wb:"Utilisateur inconnu",vb:"Channel inconnu",Xa:"Nouveau message",message:"Message",Wa:"Reseau",Ya:"(visible seulement par vous)",A:"Favoris",l:"Discutions",ja:"Membres",bb:"Discutions priv\u00e9es",eb:"Partage sa position GPS",ok:"Ok",Pa:"Annuler",O: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()?"hier, "+
+a.toLocaleTimeString():a.toLocaleString()},va: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"}};L.fr.Za=function(a){return 0===a?"Pas de message \u00e9pingl\u00e9":a+(1===a?" message \u00e9pingl\u00e9":" messages \u00e9pingl\u00e9s")};L.fr.fb=function(a){return 0===a?"Pas de chatteur":a+(1===a?" chatteur":" chatteurs")};L.fr.F=function(a){return"(edit&eacute; "+L.fr.O(a)+")"};L.fr.za=function(a,b){return"par "+a.getName()+" le "+L.fr.O(b)};L.en={wb:"Unknown member",vb:"Unknown channel",Xa:"New message",message:"Message",Wa:"Network",Ya:"(only visible to you)",A:"Starred",l:"Channels",ja:"Members",bb:"Direct messages",eb:"Share your GPS location",ok:"Ok",Pa:"Cancel",O: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()},va: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"}};L.en.Za=function(a){return 0===a?"No pinned messages":a+(1===a?" pinned message":" pinned messages")};L.en.fb=function(a){return 0===a?"No users in this room":a+(1===a?" user":" users")};L.en.F=function(a){return"(edited "+L.en.O(a)+")"};L.en.za=function(a,b){return"by "+a.getName()+" on "+L.en.O(b)};var wa=function(){function a(a){this.text="";this.g=a}function b(b,c,d){this.Y=c;this.f=null;this.j=[];this.a=d||"";this.qa="<"===this.a;this.xa="*"===this.a;this.pa="_"===this.a;this.ra="~"===this.a||"-"===this.a;this.i=">"===this.a||"&gt;"===this.a;this.J=":"===this.a;this.Aa="`"===this.a;this.La="```"===this.a;this.Ba="\n"===this.a;this.oa=void 0!==d&&-1!==k.B.indexOf(d);this.g=b;this.sa=null;this.b=this.Ba||this.oa?c+d.length-1:!1;this.oa&&(this.f=new a(this),this.j.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||n;for(var c=0,e=a.j.length;c<e;c++){var m=
+a.j[c];if(m instanceof b)if(m.b){if(m=d(m))return m}else return m}return null}function e(a,c){a.g instanceof b&&(a.g.j.splice(a.g.j.indexOf(a)+(c?1:0)),a.g.f=a.g.j[a.g.j.length-1],e(a.g,!0))}function f(a){return a}function h(a){return{link:a,text:a,Ta:!1}}var g,n,k={B:[],$:f,ma:f,ia:h};b.prototype.Da=function(){return this.xa&&!!this.b||this.g instanceof b&&this.g.Da()};b.prototype.Ga=function(){return this.pa&&!!this.b||this.g instanceof b&&this.g.Ga()};b.prototype.Ha=function(){return this.ra&&
+!!this.b||this.g instanceof b&&this.g.Ha()};b.prototype.da=function(){return this.J&&!!this.b||this.g instanceof b&&this.g.da()};b.prototype.Fa=function(){return this.oa&&!!this.b||this.g instanceof b&&this.g.Fa()};b.prototype.Ea=function(){return this.Aa&&!!this.b||this.g instanceof b&&this.g.Ea()};b.prototype.ca=function(){return this.La&&!!this.b||this.g instanceof b&&this.g.ca()};b.prototype.Ia=function(){for(var a=0,c=this.j.length;a<c;a++)if(this.j[a]instanceof b&&(!this.j[a].b||this.j[a].Ia()))return!0;
+return!1};b.prototype.Ja=function(a){if("<"===this.a&&">"===g[a])return!0;var b=c(g[a-1]);if(!this.i&&g.substr(a,this.a.length)===this.a){if(!b&&(this.xa||this.pa||this.ra))return!1;if(this.f&&this.Ia())return this.f.Ma();if(this.hb())return!0}return"\n"===g[a]&&this.i?!0:!1};b.prototype.hb=function(){for(var a=this;a;){for(var c=0,d=a.j.length;c<d;c++)if(a.j[c]instanceof b||a.j[c].text.length)return!0;a=a.sa}return!1};b.prototype.Ma=function(){var a=new b(this.g,this.Y,this.a);a.sa=this;this.f&&
+this.f instanceof b&&(a.f=this.f.Ma(),a.j=[a.f]);return a};b.prototype.ib=function(a){return this.J&&(" "===g[a]||"\t"===g[a])||(this.J||this.qa||this.xa||this.pa||this.ra||this.Aa)&&"\n"===g[a]?!1:!0};b.prototype.jb=function(b){if(this.Aa||this.J||this.La||this.qa)return null;if(!this.f||this.f.b||this.f instanceof a){var d=c(g[b-1]),e=c(g[b+1]);if("```"===g.substr(b,3))return"```";var f=n.wa();if(void 0===f||f){if("&gt;"===g.substr(b,4))return"&gt;";if(">"===g[b])return g[b]}if("`"===g[b]&&!d||
+"\n"===g[b]||!(-1===["*","~","-","_"].indexOf(g[b])||!e&&void 0!==g[b+1]&&-1==="*~-_<&".split("").indexOf(g[b+1])||d&&void 0!==g[b-1]&&-1==="*~-_<&".split("").indexOf(g[b-1]))||-1!==[":"].indexOf(g[b])&&e||-1!==["<"].indexOf(g[b]))return g[b];d=0;for(e=k.B.length;d<e;d++)if(f=k.B[d],g.substr(b,f.length)===f)return f}return null};a.prototype.wa=function(){if(""!==this.text.trim())return!1};b.prototype.wa=function(){for(var a=this.j.length-1;0<=a;a--){var b=this.j[a].wa();if(void 0!==b)return b}if(this.Ba||
+this.i)return!0};a.prototype.o=function(a){this.text+=g[a];return 1};b.prototype.o=function(c){var d=this.f&&!this.f.b&&this.f.Ja?this.f.Ja(c):null;if(d){var e=this.f.a.length;this.f.Ca(c);d instanceof b&&(this.f=d,this.j.push(d));return e}if(!this.f||this.f.b||this.f instanceof a||this.f.ib(c)){if(d=this.jb(c))return this.f=new b(this,c,d),this.j.push(this.f),this.f.a.length;if(!this.f||this.f.b)this.f=new a(this),this.j.push(this.f);return this.f.o(c)}d=this.f.Y+1;n.aa(this.f.Y);this.f=new a(this);
+this.f.o(d-1);this.j.pop();this.j.push(this.f);return d-c};b.prototype.Ca=function(a){for(var b=this;b;)b.b=a,b=b.sa};b.prototype.aa=function(a){this.b&&this.b>=a&&(this.b=!1);this.j.forEach(function(c){c instanceof b&&c.aa(a)})};a.prototype.innerHTML=function(){if(this.g.da()){for(var a=this.g;a&&!a.J;)a=a.g;if(a){var a=a.a+this.text+a.a,b=k.$(a);return b?b:a}return(a=k.$(this.text))?a:this.text}if(this.g.ca()){if("undefined"!==typeof hljs)try{return a=this.text.match(/^\w+/),hljs.configure({useBR:!0,
+tabReplace:"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"}),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,"<br/>")}return k.ma(this.text)};a.prototype.outerHTML=function(){var a="span",b=[],c="";if(this.g.ca()){a="pre";b.push("codeblock");var d=this.innerHTML()}else this.g.Ea()?(b.push("code"),d=this.innerHTML()):(this.g.qa&&(d=k.ia(this.text))?
+(a="a",c=' href="'+d.link+'"',d.Ta||(c+=' target="_blank"'),d=k.ma(d.text)):d=this.innerHTML(),this.g.Da()&&b.push("bold"),this.g.Ga()&&b.push("italic"),this.g.Ha()&&b.push("strike"),this.g.da()&&b.push("emoji"),this.g.Fa()&&b.push("highlight"));return"<"+a+c+(b.length?' class="'+b.join(" ")+'"':"")+">"+d+"</"+a+">"};b.prototype.outerHTML=function(){var a="";this.i&&(a+='<span class="quote">');this.Ba&&(a+="<br/>");this.j.forEach(function(b){a+=b.outerHTML()});this.i&&(a+="</span>");return a};b.prototype.Ka=
+function(a){this.i&&!this.b&&this.Ca(a);this.j.forEach(function(c){c instanceof b&&c.Ka(a)})};return function(c,l){l||(l={});k.B=l.B||[];k.$=l.$||f;k.ma=l.ma||f;k.ia=l.ia||h;g=c;n=new b(this,0);l=0;c=g.length;do{for(;l<c;)l+=n.o(l);n.Ka(g.length);if(l=d()){e(l,!1);n.aa(l.Y);var m=new a(l.g);m.o(l.Y);l.g.j.push(m);l.g.f=m;l=l.Y+1}else l=void 0}while(void 0!==l);return n.outerHTML()}}();"undefined"!==typeof module&&(module.H.w=wa);function xa(a,b){this.i=a;this.content=b;this.c=ya(this);this.b=za(this);this.a=[];this.o=[]}
+function ya(a){var b=document.createElement("div"),c=document.createElement("header"),d=document.createElement("span"),e=document.createElement("span"),f=document.createElement("div"),h=document.createElement("footer");b.a=document.createElement("span");b.b=document.createElement("span");d.textContent=a.i;"string"==typeof a.content?f.innerHTML=a.content:f.appendChild(a.content);c.className=Aa;d.className=Ba;e.className=Ca;e.textContent="x";c.appendChild(d);c.appendChild(e);b.appendChild(c);f.className=
+Da;b.appendChild(f);b.b.className=Ea;b.b.textContent=M.Pa;b.b.addEventListener("click",function(){Fa(a,!1)});e.addEventListener("click",function(){Fa(a,!1)});b.a.addEventListener("click",function(){Fa(a,!0)});h.appendChild(b.b);b.a.className=Ea;b.a.textContent=M.ok;h.appendChild(b.a);h.className=Ga+" "+Ha;b.appendChild(h);b.className=Ia;return b}function Fa(a,b){(b?a.a:a.o).forEach(function(a){a()});a.close()}
+function za(a){var b=document.createElement("div");b.className=Ja;b.addEventListener("click",function(){Fa(this,!1)}.bind(a));return b}function Ka(a,b,c){a.c.a.textContent=b;a.c.b.textContent=c;return a}xa.prototype.la=function(a){a=a||document.body;a.appendChild(this.b);a.appendChild(this.c);return this};xa.prototype.close=function(){this.c.remove();this.b.remove();return this};function La(a,b){a.a.push(b);return a};var Ea="button",Ga="button-container",Ia="dialog",Ja="dialog-overlay",Aa="dialog-title",Ba="dialog-title-label",Ca="dialog-title-close",Da="dialog-body",Ha="dialog-footer";var Ma=[],Na=0;
+function Oa(){var a=document.createDocumentFragment(),b=ta(function(a){return!a.ea&&!1!==a.aa}),c=[],d=[],e=[],f=[],h={};b.sort(function(a,b){if(a[0]!==b[0])return a[0]-b[0];var c=J(H.context,a),d=J(H.context,b);a=c.l[a];b=d.l[b];return a.name===b.name?(h[a.id]=M.va(c.a.name,a.name),h[b.id]=M.va(d.a.name,b.name),c.a.name.localeCompare(d.a.name)):a.name.localeCompare(b.name)});b.forEach(function(a){a=sa(a);if(a instanceof t){var b;if(b=!a.a.Oa){var g=h[a.id];b=document.createElement("li");var m=document.createElement("a");
+b.id="room_"+a.id;m.href="#"+a.id;b.className="chat-context-room chat-ims presence-indicator";m.textContent=g||a.a.getName();b.appendChild(Pa());b.appendChild(m);a.a.L||b.classList.add("presence-away");N===a&&b.classList.add("selected");a.R>a.C&&(b.classList.add("unread"),b.classList.add("unreadHi"));b=g=b}b&&(a.A?c.push(g):f.push(g))}else if(g=h[a.id],b=document.createElement("li"),m=document.createElement("a"),b.id="room_"+a.id,m.href="#"+a.id,a.i?(b.className="chat-context-room chat-group",b.dataset.count=
+Object.keys(a.h||{}).length):b.className="chat-context-room chat-channel",N===a&&b.classList.add("selected"),m.textContent=g||a.name,b.appendChild(Pa()),b.appendChild(m),a.R>a.C&&(b.classList.add("unread"),0<=P.indexOf(a)&&b.classList.add("unreadHi")),g=b)a.A?c.push(g):a.i?e.push(g):d.push(g)});c.length&&a.appendChild(Qa(M.A));c.forEach(function(b){a.appendChild(b)});d.length&&a.appendChild(Qa(M.l));d.forEach(function(b){a.appendChild(b)});e.forEach(function(b){a.appendChild(b)});f.length&&a.appendChild(Qa(M.bb));
+f.forEach(function(b){a.appendChild(b)});document.getElementById("chanList").textContent="";document.getElementById("chanList").appendChild(a);Ra.apply(document.getElementById("chanSearch"));Sa();Q();R&&Ta(R.a.id,R.h,function(a){document.getElementById("chatCtx").style.backgroundImage="url("+a+")"})}
+function Ua(){ra(function(a){var b=a.u,c;for(c in a.self.l)if(!a.self.l[c].ea){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.h)(c=a.h[e].W)&&!c.ea&&(d=document.getElementById("room_"+c.id))&&(b[c.id]?d.classList.add("chat-context-typing"):d.classList.remove("chat-context-typing"))});Va()}
+function Va(){var a;document.getElementById("whoistyping").textContent="";if(R&&N&&(a=R.u[N.id])){var b=document.createDocumentFragment(),c=!1,d;for(d in a)(a=K(d))?b.appendChild(Wa(a)):c=!0;c&&(H.b=0);document.getElementById("whoistyping").appendChild(b)}}function Xa(a){a?document.body.classList.remove("no-network"):document.body.classList.add("no-network");Q()}
+function Ya(){var a=N.name||(N.a?N.a.getName():void 0);if(!a){console.error("No name provided for ",N);var a=[],b;for(b in N.h)a.push(N.h[b].getName());a=a.join(", ")}document.getElementById("currentRoomTitle").textContent=a;S();T();document.getElementById("fileUploadContainer").classList.add("hidden");Za();U&&(U=null,V());W&&(W=null,V());Q();Va()}
+function V(){if(U){document.body.classList.add("replyingTo");var a=document.getElementById("replyToContainer"),b=document.createElement("a");b.addEventListener("click",function(){U=null;V()});b.className="replyto-close";b.textContent="x";a.textContent="";a.appendChild(b);a.appendChild(U.I())}else document.body.classList.remove("replyingTo"),document.getElementById("replyToContainer").textContent="";T()}
+function $a(){if(W){document.body.classList.add("replyingTo");var a=document.getElementById("replyToContainer"),b=document.createElement("a");b.addEventListener("click",function(){W=null;$a()});b.className="replyto-close";b.textContent="x";a.textContent="";a.appendChild(b);a.appendChild(W.I());document.getElementById("msgInput").value=W.text}else document.body.classList.remove("replyingTo"),document.getElementById("replyToContainer").textContent="";T()}
+window.toggleReaction=function(a,b,c){var d=H.a[a],e,f;(d=H.a[a])&&(e=ma(d,b))&&(f=J(H.context,a))&&(e.D[c]&&-1!==e.D[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(R)for(var c=R;!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 Q(){var a=P.length,b="";if(X)b="!"+M.Wa+" - Mimouchat",document.getElementById("linkFavicon").href="favicon_err.png";else if(a)b="(!"+a+")",cb(a,a);else{var c=0;qa(E.context,function(a){a.P>a.C&&c++});c&&(b="("+c+")");cb(0,c)}!b.length&&N&&(b=N.name);document.title=b.length?b:"Mimouchat"}
+function Q(){var a=P.length,b="";if(X)b="!"+M.Wa+" - Mimouchat",document.getElementById("linkFavicon").href="favicon_err.png";else if(a)b="(!"+a+")",cb(a,a);else{var c=0;qa(H.context,function(a){a.R>a.C&&c++});c&&(b="("+c+")");cb(0,c)}!b.length&&N&&(b=N.name);document.title=b.length?b:"Mimouchat"}
 function db(){if("Notification"in window)if("granted"===Notification.permission){var a=Date.now();if(Na+3E4<a){var b=new Notification(M.Xa);Na=a;setTimeout(function(){b.close()},5E3)}}else"denied"!==Notification.permission&&Notification.requestPermission()}
-function S(){var a=document.createDocumentFragment(),b=N.id,c=null,d=0,e=null,f;N.A?document.getElementById("chatSystemContainer").classList.add("starred"):document.getElementById("chatSystemContainer").classList.remove("starred");Ma=[];E.a[b]&&E.a[b].a.forEach(function(b){if(b.h)b.W();else{var h=b.J(),g=!1;c&&c.L===b.L&&b.L?30>Math.abs(d-b.m)&&!(b instanceof B)?e.classList.add("chatmsg-same-ts"):d=b.m:(d=b.m,g=!0);(!c||c.m<=N.C)&&b.m>N.C?h.classList.add("chatmsg-first-unread"):h.classList.remove("chatmsg-first-unread");
-if(b instanceof B)e=c=null,d=0,a.appendChild(h),f=null;else{if(g||!f){var g=J(b.L),l=b.username,m=document.createElement("div"),k=document.createElement("div"),q=document.createElement("a"),u=document.createElement("img");m.ea=document.createElement("span");m.ea.className="chatmsg-author-img-wrapper";u.className="chatmsg-author-img";q.className="chatmsg-author-name";q.href="#"+g.id;g?(q.textContent=g.getName(),u.src="api/avatar?user="+g.id):(q.textContent=l||"?",u.src="");m.ea.appendChild(u);k.appendChild(m.ea);
-k.appendChild(q);k.className="chatmsg-author";m.className="chatmsg-authorGroup";m.appendChild(k);m.content=document.createElement("div");m.content.className="chatmsg-author-messages";m.appendChild(m.content);f=m;Ma.push(f);a.appendChild(f)}c=b;e=h;f.content.appendChild(h)}}});b=document.getElementById("chatWindow");b.textContent="";b.appendChild(a);b.scrollTop=b.scrollHeight-b.clientHeight;eb();window.hasFocus&&Za()}
-function fb(a,b){if(a.classList.contains("chatmsg-hover-reply"))W&&(W=null,$a()),U!==b&&(U=b,V());else if(a.classList.contains("chatmsg-hover-reaction")){var c=N.id,d=b.id;gb.ka(document.body,R,function(a){a&&ab(c,d,a)})}else a.classList.contains("chatmsg-hover-edit")?(U&&(U=null,V()),W!==b&&(W=b,$a())):a.classList.contains("chatmsg-hover-star")?b.A?hb(b):ib(b):a.classList.contains("chatmsg-hover-pin")?b.pinned?jb(N,b):kb(b):a.classList.contains("chatmsg-hover-remove")&&(U&&(U=null,V()),W&&(W=null,
+function S(){var a=document.createDocumentFragment(),b=N.id,c=null,d=0,e=null,f;N.A?document.getElementById("chatSystemContainer").classList.add("starred"):document.getElementById("chatSystemContainer").classList.remove("starred");Ma=[];H.a[b]&&H.a[b].a.forEach(function(b){if(b.i)b.X();else{var g=b.K(),h=!1;c&&c.N===b.N&&b.N?30>Math.abs(d-b.m)&&!(b instanceof B)?e.classList.add("chatmsg-same-ts"):d=b.m:(d=b.m,h=!0);(!c||c.m<=N.C)&&b.m>N.C?g.classList.add("chatmsg-first-unread"):g.classList.remove("chatmsg-first-unread");
+if(b instanceof B)e=c=null,d=0,a.appendChild(g),f=null;else{if(h||!f){var h=K(b.N),k=b.username,m=document.createElement("div"),l=document.createElement("div"),q=document.createElement("a"),u=document.createElement("img");m.fa=document.createElement("span");m.fa.className="chatmsg-author-img-wrapper";u.className="chatmsg-author-img";q.className="chatmsg-author-name";q.href="#"+h.id;h?(q.textContent=h.getName(),u.src="api/avatar?user="+h.id):(q.textContent=k||"?",u.src="");m.fa.appendChild(u);l.appendChild(m.fa);
+l.appendChild(q);l.className="chatmsg-author";m.className="chatmsg-authorGroup";m.appendChild(l);m.content=document.createElement("div");m.content.className="chatmsg-author-messages";m.appendChild(m.content);f=m;Ma.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&&Za()}
+function fb(a,b){if(a.classList.contains("chatmsg-hover-reply"))W&&(W=null,$a()),U!==b&&(U=b,V());else if(a.classList.contains("chatmsg-hover-reaction")){var c=N.id,d=b.id;gb.la(document.body,R,function(a){a&&ab(c,d,a)})}else a.classList.contains("chatmsg-hover-edit")?(U&&(U=null,V()),W!==b&&(W=b,$a())):a.classList.contains("chatmsg-hover-star")?b.A?hb(b):ib(b):a.classList.contains("chatmsg-hover-pin")?b.pinned?jb(N,b):kb(b):a.classList.contains("chatmsg-hover-remove")&&(U&&(U=null,V()),W&&(W=null,
 $a()),lb(b))}
-function mb(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=ma(E.a[N.id],d))&&a.s[e]&&a.s[e].actions&&a.s[e].actions[f]&&
-nb(a,a.s[e],a.s[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=ma(E.a[N.id],d))&&fb(c,a);break}c=c.parentElement}}
-function nb(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 C,message_ts:a.id},g=new XMLHttpRequest;g.open("POST","api/attachmentAction?serviceId="+a.L);g.send(JSON.stringify(d))}var e=N.id;c.confirm?La(Ka(new xa(c.confirm.title,c.confirm.text),c.confirm.ok_text,c.confirm.dismiss_text),d).ka():d()}function T(){document.getElementById("msgInput").focus()}
-function eb(){var a=document.getElementById("chatWindow").getBoundingClientRect().top;Ma.forEach(function(b){var c=b.ea,d=c.clientHeight;b=b.getBoundingClientRect();c.style.top=Math.max(0,Math.min(a-b.top,b.height-d-d/2))+"px"})}
-function ob(a){var b=document.getElementById("slashList");b.dataset.cursor&&delete b.dataset.cursor;var c=[],d=a.value;if("/"===a.value[0]){var e=d.indexOf(" "),f=-1!==e,e=-1===e?d.length:e,d=d.substr(0,e);if(f){var g=pb.Ra(d);g&&c.push(g)}else c=pb.kb(d),b.dataset.cursor=JSON.stringify([0,a.selectionEnd]);var g=R?R.h.data:{},h;for(h in g){var n=g[h];(!f&&n.name.substr(0,e)===d||f&&n.name===d)&&c.push(n)}}c.sort(function(a,b){return a.U.localeCompare(b.U)||a.name.localeCompare(b.name)});if(!c.length&&
-a.selectionStart===a.selectionEnd&&a.selectionStart){e=a.selectionStart;for(f=a.selectionEnd;e&&" "!==a.value[e-1];e--);for(h=a.value.length;f<h&&" "!==a.value[f];f++);if(e!==f){if("#"===a.value[e]){h=R.l;a=a.value.substr(e+1,f-e-1);for(var l in h)h[l].name.length>=a.length&&h[l].name.substr(0,a.length)===a&&c.push(h[l])}else if("@"===a.value[e])for(l in h=N instanceof t?R.j:N.j,a=a.value.substr(e+1,f-e-1),h)d=h[l].getName(),d.length>=a.length&&d.substr(0,a.length)===a&&c.push(h[l]);c.length&&(b.dataset.cursor=
-JSON.stringify([e,f]))}}b.textContent="";if(c.length){a=document.createDocumentFragment();l=0;for(e=c.length;l<e;l++)if(f=c[l],f instanceof y){if(!m){var m=!0;a.appendChild(qb(M.ia))}a.appendChild(rb("@"+f.getName()))}else f instanceof v?(m||(m=!0,a.appendChild(qb(M.l))),a.appendChild(rb("#"+f.name))):(m!==f.U&&(m=f.U,a.appendChild(qb(f.U))),a.appendChild(rb(f)));b.appendChild(a)}}
-document.addEventListener("DOMContentLoaded",function(){va();sb();var a=document.getElementById("chanSearch");a.addEventListener("input",Ra);a.addEventListener("blur",Ra);document.getElementById("chatWindow").addEventListener("click",mb);window.addEventListener("hashchange",function(){document.location.hash&&"#"===document.location.hash[0]&&Sa()});document.addEventListener("mouseover",function(a){a=a.target;if(!tb.ob(a)){for(;a&&a!==this;){if("A"===a.nodeName){var b=a.href,c=b.indexOf("#");if(0<=
-c){b=b.substr(c+1);if(c=I(E.context,b)){tb.$a(c,c.l[b]).show(a);return}a:{for(var c=E.context,f=0,g=c.a.length;f<g;f++)if(c.a[f].j[b]){c=c.a[f];break a}c=null}if(c&&(b=c.j[b].V)){tb.$a(c,b).show(a);return}}break}a=a.parentElement}tb.Sa()}});document.getElementById("currentRoomStar").addEventListener("click",function(a){a.preventDefault();N&&(N.A?(a=new XMLHttpRequest,a.open("POST","api/unstarChannel?room="+N.id,!0)):(a=new XMLHttpRequest,a.open("POST","api/starChannel?room="+N.id,!0)),a.send(null));
+function mb(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=ma(H.a[N.id],d))&&a.s[e]&&a.s[e].actions&&a.s[e].actions[f]&&
+nb(a,a.s[e],a.s[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=ma(H.a[N.id],d))&&fb(c,a);break}c=c.parentElement}}
+function nb(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 D,message_ts:a.id},h=new XMLHttpRequest;h.open("POST","api/attachmentAction?serviceId="+a.N);h.send(JSON.stringify(d))}var e=N.id;c.confirm?La(Ka(new xa(c.confirm.title,c.confirm.text),c.confirm.ok_text,c.confirm.dismiss_text),d).la():d()}function T(){document.getElementById("msgInput").focus()}
+function eb(){var a=document.getElementById("chatWindow").getBoundingClientRect().top;Ma.forEach(function(b){var c=b.fa,d=c.clientHeight;b=b.getBoundingClientRect();c.style.top=Math.max(0,Math.min(a-b.top,b.height-d-d/2))+"px"})}
+function ob(a){var b=document.getElementById("slashList");b.dataset.cursor&&delete b.dataset.cursor;var c=[],d=a.value;if("/"===a.value[0]){var e=d.indexOf(" "),f=-1!==e,e=-1===e?d.length:e,d=d.substr(0,e);if(f){var h=pb.Ra(d);h&&c.push(h)}else c=pb.lb(d),b.dataset.cursor=JSON.stringify([0,a.selectionEnd]);var h=R?R.i.data:{},g;for(g in h){var n=h[g];(!f&&n.name.substr(0,e)===d||f&&n.name===d)&&c.push(n)}}c.sort(function(a,b){return a.V.localeCompare(b.V)||a.name.localeCompare(b.name)});if(!c.length&&
+a.selectionStart===a.selectionEnd&&a.selectionStart){e=a.selectionStart;for(f=a.selectionEnd;e&&" "!==a.value[e-1];e--);for(g=a.value.length;f<g&&" "!==a.value[f];f++);if(e!==f){if("#"===a.value[e]){g=R.l;a=a.value.substr(e+1,f-e-1);for(var k in g)g[k].name.length>=a.length&&g[k].name.substr(0,a.length)===a&&c.push(g[k])}else if("@"===a.value[e])for(k in g=N instanceof t?R.h:N.h,a=a.value.substr(e+1,f-e-1),g)d=g[k].getName(),d.length>=a.length&&d.substr(0,a.length)===a&&c.push(g[k]);c.length&&(b.dataset.cursor=
+JSON.stringify([e,f]))}}b.textContent="";if(c.length){a=document.createDocumentFragment();k=0;for(e=c.length;k<e;k++)if(f=c[k],f instanceof y){if(!m){var m=!0;a.appendChild(qb(M.ja))}a.appendChild(rb("@"+f.getName()))}else f instanceof v?(m||(m=!0,a.appendChild(qb(M.l))),a.appendChild(rb("#"+f.name))):(m!==f.V&&(m=f.V,a.appendChild(qb(f.V))),a.appendChild(rb(f)));b.appendChild(a)}}
+document.addEventListener("DOMContentLoaded",function(){va();sb();var a=document.getElementById("chanSearch");a.addEventListener("input",Ra);a.addEventListener("blur",Ra);document.getElementById("chatWindow").addEventListener("click",mb);window.addEventListener("hashchange",function(){document.location.hash&&"#"===document.location.hash[0]&&Sa()});document.addEventListener("mouseover",function(a){a=a.target;if(!tb.pb(a)){for(;a&&a!==this;){if("A"===a.nodeName){var b=a.href,c=b.indexOf("#");if(0<=
+c){b=b.substr(c+1);if(c=J(H.context,b)){tb.$a(c,c.l[b]).show(a);return}a:{for(var c=H.context,f=0,h=c.a.length;f<h;f++)if(c.a[f].h[b]){c=c.a[f];break a}c=null}if(c&&(b=c.h[b].W)){tb.$a(c,b).show(a);return}}break}a=a.parentElement}tb.Sa()}});document.getElementById("currentRoomStar").addEventListener("click",function(a){a.preventDefault();N&&(N.A?(a=new XMLHttpRequest,a.open("POST","api/unstarChannel?room="+N.id,!0)):(a=new XMLHttpRequest,a.open("POST","api/starChannel?room="+N.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();ub.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),vb(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();N&&document.getElementById("fileUploadContainer").classList.remove("hidden");
 return!1});document.getElementById("msgForm").addEventListener("submit",function(a){a.preventDefault();a=document.getElementById("msgInput");N&&a.value&&wb(a.value)&&(a.value="",U&&(U=null,V()),W&&(W=null,V()),document.getElementById("slashList").textContent="");T();return!1});window.addEventListener("blur",function(){window.hasFocus=!1});window.addEventListener("focus",function(){window.hasFocus=!0;Na=0;N&&Za();T()});document.getElementById("chatWindow").addEventListener("scroll",eb);var b=0;document.getElementById("msgInput").addEventListener("input",
-function(){if(N){var a=Date.now();if(b+3E3<a&&(R.self.wa||N instanceof t)){var d=new XMLHttpRequest;d.open("POST","api/typing?room="+N.id,!0);d.send(null);b=a}ob(this)}});document.getElementById("slashList").addEventListener("click",function(a){if(N){var b=a.target;if(a=this.dataset.cursor)for(a=JSON.parse(a);b&&b!==this;){if(b.dataset.input){var c=document.getElementById("msgInput"),b=b.dataset.input;if(c.value.length<=a[1]||" "!==c.value[a[1]])b+=" ";c.value=c.value.substr(0,a[0])+b+c.value.substr(a[1]);
-c.selectionStart=c.selectionEnd=a[0]+b.length;ob(c);c.focus();break}b=b.parentElement}}});window.hasFocus=!0;(function(){var a=document.getElementById("emojiButton");if("makeEmoji"in window){var b=window.makeEmoji("smile");b?a.innerHTML="<span class='emoji-small'>"+b.outerHTML+"</span>":a.style.backgroundImage='url("smile.svg")';(b=window.makeEmoji("paperclip"))?document.getElementById("attachFile").innerHTML="<span class='emoji-small'>"+b.outerHTML+"</span>":document.getElementById("attachFile").style.backgroundImage=
-'url("public/paperclip.svg")';a.addEventListener("click",function(){R&&gb.ka(document.body,R,function(a){a&&(document.getElementById("msgInput").value+=":"+a+":");T()})})}else a.classList.add("hidden")})();xb()});var ub=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={S:"services",display:"display",Ib:"privacy"};document.getElementById("settingMenuItems").addEventListener("click",
+function(){if(N){var a=Date.now();if(b+3E3<a&&(R.self.L||N instanceof t)){var d=new XMLHttpRequest;d.open("POST","api/typing?room="+N.id,!0);d.send(null);b=a}ob(this)}});document.getElementById("slashList").addEventListener("click",function(a){if(N){var b=a.target;if(a=this.dataset.cursor)for(a=JSON.parse(a);b&&b!==this;){if(b.dataset.input){var c=document.getElementById("msgInput"),b=b.dataset.input;c.value.length<=a[1]&&(b+=" ");c.value=c.value.substr(0,a[0])+b+c.value.substr(a[1]);c.selectionStart=
+c.selectionEnd=a[0]+b.length;ob(c);c.focus();break}b=b.parentElement}}});window.hasFocus=!0;(function(){var a=document.getElementById("emojiButton");if("makeEmoji"in window){var b=window.makeEmoji("smile");b?a.innerHTML="<span class='emoji-small'>"+b.outerHTML+"</span>":a.style.backgroundImage='url("smile.svg")';(b=window.makeEmoji("paperclip"))?document.getElementById("attachFile").innerHTML="<span class='emoji-small'>"+b.outerHTML+"</span>":document.getElementById("attachFile").style.backgroundImage=
+'url("public/paperclip.svg")';a.addEventListener("click",function(){R&&gb.la(document.body,R,function(a){a&&(document.getElementById("msgInput").value+=":"+a+":");T()})})}else a.classList.add("hidden")})();xb()});var ub=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={T:"services",display:"display",Jb:"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.S);return this},tb:function(){return this},qb:d}}();function yb(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.O=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"),h=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)))},n=function(a,d,e,m){g.fillStyle="#808080";g.fillRect(0,0,300,300);f.fillStyle="#808080";f.fillRect(0,0,300,300);var k=Math.pow(2,a),n=(e+180)/360*k,l=(1-Math.log(Math.tan(d*Math.PI/180)+1/Math.cos(d*Math.PI/180))/Math.PI)/2*k,q=Math.floor(n),G=Math.floor(l),
-fa=m?100*m/h(180/Math.PI*Math.atan(.5*(Math.exp(Math.PI-2*Math.PI*G/k)-Math.exp(-(Math.PI-2*Math.PI*G/k)))),q/k*360-180,(q+1)/k*360-180):0;d=b;for(e=0;3>e;e++)for(m=0;3>m;m++)c(a,q+e-1,G+m-1,{mb:e,pb:m,fb:d}).then(function(a){if(a.fb===b){g.drawImage(a.O,100*a.mb,100*a.pb,100,100);a=n-q;var c=l-G;a=100*a+100;c=100*c+100;f.putImageData(g.getImageData(0,0,300,300),0,0);void 0!==fa&&(f.beginPath(),f.arc(a,c,Math.max(fa,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===fa||25<fa)f.strokeStyle="rgba(244, 146, 66, 1)",f.beginPath(),f.moveTo(a-5,c-5),f.lineTo(a+5,c+5),f.stroke(),f.moveTo(a+5,c-5),f.lineTo(a-5,c+5),f.stroke()}})},l,m=function(c){c=Math.max(4,Math.min(19,c));l!==c&&(b++,l=c,n(l,Number(a.latitude),Number(a.longitude),Number(a.accuracy)))};m(12);var e=document.createElement("div"),k=document.createElement("div"),q=document.createElement("button"),u=document.createElement("button");e.className=
-"OSM-wrapper";d.className="OSM-canvas";k.className="OSM-controls";u.className="OSM-controls-zoomMin";q.className="OSM-controls-zoomPlus";u.addEventListener("click",function(){m(l-1)});q.addEventListener("click",function(){m(l+1)});k.appendChild(u);k.appendChild(q);e.appendChild(d);e.appendChild(k);return e}};function Pa(){var a=document.createElement("span"),b=document.createElement("span"),c=document.createElement("span"),d=document.createElement("span");a.className="typing-container";b.className="typing-dot1";c.className="typing-dot2";d.className="typing-dot3";b.textContent=c.textContent=d.textContent=".";a.appendChild(b);a.appendChild(c);a.appendChild(d);return a}var Qa=function(){var a={};return function(b){var c=a[b];c||(c=a[b]=document.createElement("header"),c.textContent=b);return c}}();
-function zb(a){var b=a.b,c=document.createElement("div"),d=document.createElement("div");c.aa=document.createElement("ul");c.s=document.createElement("ul");c.D=document.createElement("ul");c.m=document.createElement("div");c.ya=document.createElement("div");c.ta=document.createElement("span");c.id=b+"_"+a.id;c.className="chatmsg-item";c.m.className="chatmsg-ts";c.ya.className="chatmsg-msg";c.ta.className="chatmsg-author-name";var b=c.aa,e=a.context.Y;a:{for(var f=E.context,g=0,h=f.a.length;g<h;g++)if(f.a[g].self.id===
-a.L){a=!0;break a}a=!1}e.replyToMsg&&(f=document.createElement("li"),f.className="chatmsg-hover-reply",f.style.backgroundImage='url("repl.svg")',b.appendChild(f));e.reactMsg&&(f=document.createElement("li"),f.className="chatmsg-hover-reaction",f.style.backgroundImage='url("smile.svg")',b.appendChild(f));if(a&&e.editMsg||e.editOtherMsg)f=document.createElement("li"),f.className="chatmsg-hover-edit",f.style.backgroundImage='url("edit.svg")',b.appendChild(f);e.starMsg&&(b.ga=document.createElement("li"),
-b.ga.className="chatmsg-hover-star",b.appendChild(b.ga));e.pinMsg&&(f=document.createElement("li"),f.className="chatmsg-hover-pin",b.appendChild(f),f.style.backgroundImage='url("pin.svg")');if(a&&e.removeMsg||e.moderate)e=document.createElement("li"),e.className="chatmsg-hover-remove",e.style.backgroundImage='url("remove.svg")',b.appendChild(e);c.aa.className="chatmsg-hover";d.appendChild(c.ta);d.appendChild(c.ya);d.appendChild(c.m);d.appendChild(c.s);c.F=document.createElement("div");c.F.className=
-"chatmsg-edited";d.appendChild(c.F);d.appendChild(c.D);d.className="chatmsg-content";c.s.className="chatmsg-attachments";c.D.className="chatmsg-reactions";c.appendChild(d);c.appendChild(c.aa);return c}function Ab(a){var b={good:"#2fa44f",warning:"#de9e31",danger:"#d50200"};if(a){if("#"===a[0])return a;if(b[a])return b[a]}return"#e3e4e6"}
-function Bb(a,b,c){var d=document.createElement("li"),e=document.createElement("div"),f=document.createElement("div"),g=document.createElement("a"),h=document.createElement("div"),n=document.createElement("img"),l=document.createElement("a"),m=document.createElement("div"),k=document.createElement("div"),q=document.createElement("div"),u=document.createElement("img"),x=document.createElement("div");d.className="chatmsg-attachment";e.style.borderColor=Ab(b.color||"");e.className="chatmsg-attachment-block";
-f.className="chatmsg-attachment-pretext";b.pretext?f.innerHTML=a.w(b.pretext):f.classList.add("hidden");g.target="_blank";b.title?(g.innerHTML=a.w(b.title),b.title_link&&(g.href=b.title_link),g.className="chatmsg-attachment-title"):g.className="hidden chatmsg-attachment-title";l.target="_blank";h.className="chatmsg-author";b.author_name&&(l.innerHTML=a.w(b.author_name),l.href=b.author_link||"",l.className="chatmsg-author-name",n.className="chatmsg-author-img",b.author_icon&&(n.src=b.author_icon,h.appendChild(n)),
-h.appendChild(l));q.className="chatmsg-attachment-thumb";b.thumb_url?(n=document.createElement("img"),n.src=b.thumb_url,q.appendChild(n),e.classList.add("has-thumb"),b.video_html&&(q.dataset.video=b.video_html)):q.classList.add("hidden");m.className="chatmsg-attachment-content";n=a.w(b.text||"");k.className="chatmsg-attachment-text";n&&""!=n?k.innerHTML=n:k.classList.add("hidden");m.appendChild(q);m.appendChild(k);b.geo&&(k=yb(b.geo))&&m.appendChild(k);u.className="chatmsg-attachment-img";b.image_url?
-u.src=b.image_url:u.classList.add("hidden");x.className="chatmsg-attachment-footer";b.footer&&(k=document.createElement("span"),k.className="chatmsg-attachment-footer-text",k.innerHTML=a.w(b.footer),b.footer_icon&&(q=document.createElement("img"),q.src=b.footer_icon,q.className="chatmsg-attachment-footer-icon",x.appendChild(q)),x.appendChild(k));b.ts&&(k=document.createElement("span"),k.className="chatmsg-ts",k.innerHTML=M.N(b.ts),x.appendChild(k));e.appendChild(g);e.appendChild(h);e.appendChild(m);
+return!1});return{display:function(c){b||(document.getElementById("settings").classList.remove("hidden"),b=!0);a(c||d.T);return this},ub:function(){return this},rb:d}}();function yb(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.P=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"),h=e.getContext("2d"),g=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)))},n=function(a,d,e,m){h.fillStyle="#808080";h.fillRect(0,0,300,300);f.fillStyle="#808080";f.fillRect(0,0,300,300);var n=Math.pow(2,a),l=(e+180)/360*n,r=(1-Math.log(Math.tan(d*Math.PI/180)+1/Math.cos(d*Math.PI/180))/Math.PI)/2*n,k=Math.floor(l),G=Math.floor(r),
+fa=m?100*m/g(180/Math.PI*Math.atan(.5*(Math.exp(Math.PI-2*Math.PI*G/n)-Math.exp(-(Math.PI-2*Math.PI*G/n)))),k/n*360-180,(k+1)/n*360-180):0;d=b;for(e=0;3>e;e++)for(m=0;3>m;m++)c(a,k+e-1,G+m-1,{nb:e,qb:m,gb:d}).then(function(a){if(a.gb===b){h.drawImage(a.P,100*a.nb,100*a.qb,100,100);a=l-k;var c=r-G;a=100*a+100;c=100*c+100;f.putImageData(h.getImageData(0,0,300,300),0,0);void 0!==fa&&(f.beginPath(),f.arc(a,c,Math.max(fa,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===fa||25<fa)f.strokeStyle="rgba(244, 146, 66, 1)",f.beginPath(),f.moveTo(a-5,c-5),f.lineTo(a+5,c+5),f.stroke(),f.moveTo(a+5,c-5),f.lineTo(a-5,c+5),f.stroke()}})},k,m=function(c){c=Math.max(4,Math.min(19,c));k!==c&&(b++,k=c,n(k,Number(a.latitude),Number(a.longitude),Number(a.accuracy)))};m(12);var e=document.createElement("div"),l=document.createElement("div"),q=document.createElement("button"),u=document.createElement("button");e.className=
+"OSM-wrapper";d.className="OSM-canvas";l.className="OSM-controls";u.className="OSM-controls-zoomMin";q.className="OSM-controls-zoomPlus";u.addEventListener("click",function(){m(k-1)});q.addEventListener("click",function(){m(k+1)});l.appendChild(u);l.appendChild(q);e.appendChild(d);e.appendChild(l);return e}};function Pa(){var a=document.createElement("span"),b=document.createElement("span"),c=document.createElement("span"),d=document.createElement("span");a.className="typing-container";b.className="typing-dot1";c.className="typing-dot2";d.className="typing-dot3";b.textContent=c.textContent=d.textContent=".";a.appendChild(b);a.appendChild(c);a.appendChild(d);return a}var Qa=function(){var a={};return function(b){var c=a[b];c||(c=a[b]=document.createElement("header"),c.textContent=b);return c}}();
+function zb(a){var b=a.b,c=document.createElement("div"),d=document.createElement("div");c.ba=document.createElement("ul");c.s=document.createElement("ul");c.D=document.createElement("ul");c.m=document.createElement("div");c.ya=document.createElement("div");c.ua=document.createElement("span");c.id=b+"_"+a.id;c.className="chatmsg-item";c.m.className="chatmsg-ts";c.ya.className="chatmsg-msg";c.ua.className="chatmsg-author-name";var b=c.ba,e=a.context.Z;a:{for(var f=H.context,h=0,g=f.a.length;h<g;h++)if(f.a[h].self.id===
+a.N){a=!0;break a}a=!1}e.replyToMsg&&(f=document.createElement("li"),f.className="chatmsg-hover-reply",f.style.backgroundImage='url("repl.svg")',b.appendChild(f));e.reactMsg&&(f=document.createElement("li"),f.className="chatmsg-hover-reaction",f.style.backgroundImage='url("smile.svg")',b.appendChild(f));if(a&&e.editMsg||e.editOtherMsg)f=document.createElement("li"),f.className="chatmsg-hover-edit",f.style.backgroundImage='url("edit.svg")',b.appendChild(f);e.starMsg&&(b.ha=document.createElement("li"),
+b.ha.className="chatmsg-hover-star",b.appendChild(b.ha));e.pinMsg&&(f=document.createElement("li"),f.className="chatmsg-hover-pin",b.appendChild(f),f.style.backgroundImage='url("pin.svg")');if(a&&e.removeMsg||e.moderate)e=document.createElement("li"),e.className="chatmsg-hover-remove",e.style.backgroundImage='url("remove.svg")',b.appendChild(e);c.ba.className="chatmsg-hover";d.appendChild(c.ua);d.appendChild(c.ya);d.appendChild(c.m);d.appendChild(c.s);c.F=document.createElement("div");c.F.className=
+"chatmsg-edited";d.appendChild(c.F);d.appendChild(c.D);d.className="chatmsg-content";c.s.className="chatmsg-attachments";c.D.className="chatmsg-reactions";c.appendChild(d);c.appendChild(c.ba);return c}function Ab(a){var b={good:"#2fa44f",warning:"#de9e31",danger:"#d50200"};if(a){if("#"===a[0])return a;if(b[a])return b[a]}return"#e3e4e6"}
+function Bb(a,b,c){var d=document.createElement("li"),e=document.createElement("div"),f=document.createElement("div"),h=document.createElement("a"),g=document.createElement("div"),n=document.createElement("img"),k=document.createElement("a"),m=document.createElement("div"),l=document.createElement("div"),q=document.createElement("div"),u=document.createElement("img"),z=document.createElement("div");d.className="chatmsg-attachment";e.style.borderColor=Ab(b.color||"");e.className="chatmsg-attachment-block";
+f.className="chatmsg-attachment-pretext";b.pretext?f.innerHTML=a.w(b.pretext):f.classList.add("hidden");h.target="_blank";b.title?(h.innerHTML=a.w(b.title),b.title_link&&(h.href=b.title_link),h.className="chatmsg-attachment-title"):h.className="hidden chatmsg-attachment-title";k.target="_blank";g.className="chatmsg-author";b.author_name&&(k.innerHTML=a.w(b.author_name),k.href=b.author_link||"",k.className="chatmsg-author-name",n.className="chatmsg-author-img",b.author_icon&&(n.src=b.author_icon,g.appendChild(n)),
+g.appendChild(k));q.className="chatmsg-attachment-thumb";b.thumb_url?(n=document.createElement("img"),n.src=b.thumb_url,q.appendChild(n),e.classList.add("has-thumb"),b.video_html&&(q.dataset.video=b.video_html)):q.classList.add("hidden");m.className="chatmsg-attachment-content";n=a.w(b.text||"");l.className="chatmsg-attachment-text";n&&""!=n?l.innerHTML=n:l.classList.add("hidden");m.appendChild(q);m.appendChild(l);b.geo&&(l=yb(b.geo))&&m.appendChild(l);u.className="chatmsg-attachment-img";b.image_url?
+u.src=b.image_url:u.classList.add("hidden");z.className="chatmsg-attachment-footer";b.footer&&(l=document.createElement("span"),l.className="chatmsg-attachment-footer-text",l.innerHTML=a.w(b.footer),b.footer_icon&&(q=document.createElement("img"),q.src=b.footer_icon,q.className="chatmsg-attachment-footer-icon",z.appendChild(q)),z.appendChild(l));b.ts&&(l=document.createElement("span"),l.className="chatmsg-ts",l.innerHTML=M.O(b.ts),z.appendChild(l));e.appendChild(h);e.appendChild(g);e.appendChild(m);
 e.appendChild(u);if(b.fields&&b.fields.length){var w=document.createElement("ul");e.appendChild(w);w.className="chatmsg-attachment-fields";b.fields.forEach(function(b){var c=b.title||"",d=b.value||"";b=!!b["short"];var e=document.createElement("li"),f=document.createElement("div"),g=document.createElement("div");e.className="field";b||e.classList.add("field-long");f.className="field-title";f.textContent=c;g.className="field-text";g.innerHTML=a.w(d);e.appendChild(f);e.appendChild(g);e&&w.appendChild(e)})}if(b.actions&&
-b.actions.length)for(g=document.createElement("ul"),g.className="chatmsg-attachment-actions "+Ga,e.appendChild(g),h=0,m=b.actions.length;h<m;h++)(u=b.actions[h])&&(u=Cb(c,h,u))&&g.appendChild(u);e.appendChild(x);d.appendChild(f);d.appendChild(e);return d}
+b.actions.length)for(h=document.createElement("ul"),h.className="chatmsg-attachment-actions "+Ga,e.appendChild(h),g=0,m=b.actions.length;g<m;g++)(u=b.actions[g])&&(u=Cb(c,g,u))&&h.appendChild(u);e.appendChild(z);d.appendChild(f);d.appendChild(e);return d}
 function Cb(a,b,c){var d=document.createElement("li"),e=Ab(c.style);d.textContent=c.text;e!==Ab()&&(d.style.color=e);d.style.borderColor=e;d.dataset.attachmentIndex=a;d.dataset.actionIndex=b;d.className="chatmsg-attachment-actions-item "+Ea;return d}function Wa(a){var b=document.createElement("li"),c=document.createElement("span");c.textContent=a.getName();b.appendChild(Pa());b.appendChild(c);return b}
 function qb(a){var b=document.createElement("lh");b.textContent=a;b.className="chat-command-header";return b}
-function rb(a){var b=document.createElement("li"),c=document.createElement("span");c.className="chat-command-name";b.appendChild(c);if("string"===typeof a)c.textContent=a;else{var d=document.createElement("span"),e=document.createElement("span");c.textContent=a.name;d.textContent=a.usage;e.textContent=a.jb;d.className="chat-command-usage";e.className="chat-command-desc";b.appendChild(d);b.appendChild(e)}b.dataset.input=c.textContent;b.className="chat-command-item";return b};var gb=function(){function a(a,b){for(a=a.target;a!==l&&a&&"LI"!==a.nodeName;)a=a.parentElement;a&&"LI"===a.nodeName&&a.id&&"emojibar-"===a.id.substr(0,9)?b(a.id.substr(9)):b(null)}function b(){w={};k.textContent="";window.emojiProviderHeader&&(k.appendChild(h(window.emojiProviderHeader)),q.textContent="",k.appendChild(q));k.appendChild(h("emojicustom.png"));k.appendChild(u)}function c(){if(!d())return!1;H&&H(null);return!0}function d(){return l.parentElement?(l.parentElement.removeChild(m),l.parentElement.removeChild(l),
-!0):!1}function e(a){var b=0;a=void 0===a?x.value:a;if(n()){var c=0,d=window.searchEmojis(a),e=f(d,O?O.self.R.a:[]),h;for(m in w)w[m].visible&&(w[m].visible=!1,q.removeChild(w[m].c));var m=0;for(h=e.length;m<h;m++){var k=e[m].name,l=w[k];if(!l){var l=w,G=k;var H=k;var k=window.makeEmoji(d[k]),F=document.createElement("span");F.appendChild(k);F.className="emoji-medium";H=g(H,F);l=l[G]=H}l.visible||(l.visible=!0,q.appendChild(l.c));c++}b+=c}m=b;c=0;for(r in A)A[r].visible&&(A[r].visible=!1,u.removeChild(A[r].c));
-if(O){d=f(O.b.data,O?O.self.R.a:[]);var r=0;for(b=d.length;r<b;r++)G=d[r].name,""!==a&&G.substr(0,a.length)!==a||"alias:"===O.b.data[G].substr(0,6)||(e=A[G],e||(e=A,l=h=G,G=O.b.data[G],H=document.createElement("span"),k=document.createElement("span"),H.className="emoji emoji-custom",H.style.backgroundImage='url("'+G+'")',k.appendChild(H),k.className="emoji-medium",l=g(l,k),e=e[h]=l),e.visible||(e.visible=!0,u.appendChild(e.c)),c++);r=c}else r=0;return m+r}function f(a,b){var c=[],d;for(d in a){var e=
-{name:d,ab:0,count:0};if(a[d].names)for(var f=0,g=a[d].names.length;f<g;f++)e.count+=b[a[d].names[f]]||0;c.push(e)}return c=c.sort(function(a,b){var c=b.count-a.count;return c?c:a.ab-b.ab})}function g(a,b){var c=document.createElement("li");c.appendChild(b);c.className="emojibar-list-item";c.id="emojibar-"+a;return{visible:!1,c:c}}function h(a){var b=document.createElement("img"),c=document.createElement("div");b.src=a;c.appendChild(b);c.className="emojibar-header";return c}function n(){return"searchEmojis"in
-window}var l=document.createElement("div"),m=document.createElement("div"),k=document.createElement("div"),q=document.createElement("ul"),u=document.createElement("ul"),x=document.createElement("input"),w={},A={},K=document.createElement("div"),F=document.createElement("span"),r=document.createElement("span"),H,O;m.addEventListener("click",function(a){var b=l.getBoundingClientRect();(a.screenY<b.top||a.screenY>b.bottom||a.screenX<b.left||a.screenX>b.right)&&c()});m.className="emojibar-overlay";l.className=
-"emojibar";k.className="emojibar-emojis";q.className=u.className="emojibar-list";x.className="emojibar-search";K.className="emojibar-detail";F.className="emojibar-detail-img";r.className="emojibar-detail-name";K.appendChild(F);K.appendChild(r);b();l.appendChild(k);l.appendChild(K);l.appendChild(x);x.addEventListener("keyup",function(){e()});l.addEventListener("mousemove",function(b){a(b,function(a){var b=a?w[a]||A[a]:null;b?(F.innerHTML=b.c.outerHTML,r.textContent=":"+a+":"):(F.textContent="",r.textContent=
-"")})});l.addEventListener("click",function(b){a(b,function(a){a&&d()&&H&&H(a)})});return{isSupported:n,ka:function(a,b,c){return n()?(O=b,H=c,a.appendChild(m),a.appendChild(l),x.value="",e(),x.focus(),!0):!1},search:e,close:c,reset:function(){b();e()}}}();var E,P=[];function Db(){da.call(this)}Db.prototype=Object.create(da.prototype);Db.prototype.constructor=Db;function pa(a){return a.a?a.a.id:null}function Eb(){this.b=0;this.context=new na;this.a={}}
-Eb.prototype.update=function(a){var b=Date.now();a.v&&(this.b=a.v);if(a["static"])for(n in a["static"]){var c=oa(this.context,n);c||(c=new Db,this.context.push(c));var d={};a["static"][n].channels&&a["static"][n].channels.forEach(function(a){a.pins&&(d[a.id]=a.pins,a.pins=void 0)});ga(c,a["static"][n],b);for(var e in d){var f=[],g=this.a[e];g||(g=this.a[e]=new Y(e,250,null,b));d[e].forEach(function(a){f.push(g.b(a,b))});c.l[e].b=f}}qa(this.context,function(a){a.P===a.C&&(a=P.indexOf(a),-1!==a&&P.splice(a,
-1))});if(a.live){for(n in a.live)(c=this.a[n])?ja(c,a.live[n],b):c=this.a[n]=new Y(n,250,a.live[n],b);for(var h in a.live){var n=I(this.context,h);(c=n.l[h])?(this.a[h].a.length&&(c.P=Math.max(c.P,la(this.a[h]).m)),c.da||(Fb(n,c,a.live[h]),N&&a.live[N.id]&&S())):E.b=0}}a["static"]&&Oa();var l=!1;a.typing&&this.context.a.forEach(function(c){var d=l,e=a.typing,f=!1;if(c.u)for(var g in c.u)e[g]||(delete c.u[g],f=!0);if(e)for(g in e)if(c.l[g]){c.u[g]||(c.u[g]={});for(var h in e[g])c.u[g][h]||(f=!0),c.u[g][h]=
-b}l=d|f},this);(a["static"]||l)&&Ua();a.config&&(Gb=new Hb(a.config),Ib()&&ub.tb(!1).display(ub.qb.S),Jb());if(R&&N&&a["static"]&&a["static"][R.a.id]&&a["static"][R.a.id].channels&&a["static"][R.a.id].channels)for(h=a["static"][R.a.id].channels,n=0,c=h.length;n<c;n++)if(h[n].id===N.id){S();break}};
-setInterval(function(){var a=!1,b=Date.now();ra(function(c){var d=!1,e;for(e in c.u){var f=!0,g;for(g in c.u[e])c.u[e][g]+3E3<b?(delete c.u[e][g],d=!0):f=!1;f&&(delete c.u[e],d=!0)}d&&(a=!0)});a&&Ua()},1E3);
-function Fb(a,b,c){if(b!==N||!window.hasFocus){var d=new RegExp("<@"+a.self.id),e=!1,f=!1,g=!1;c.forEach(function(c){if(!(parseFloat(c.ts)<=b.C)){f=!0;var h;if(!(h=b instanceof t)&&(h=c.text)&&!(h=c.text.match(d)))a:{h=a.self.R.B;for(var l=0,m=h.length;l<m;l++)if(-1!==c.text.indexOf(h[l])){h=!0;break a}h=!1}h&&(-1===P.indexOf(b)&&(g=!0,P.push(b)),e=!0)}});if(f){Q();if(c=document.getElementById("room_"+b.id))c.classList.add("unread"),e&&c.classList.add("unreadHi");g&&!window.hasFocus&&db()}}}
-function Za(){var a=N,b=P.indexOf(a);if(a.P>a.C){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.m,!0);d.send(null);a.C=c.m}}0<=b&&(P.splice(b,1),Q());a=document.getElementById("room_"+a.id);a.classList.remove("unread");a.classList.remove("unreadHi")}E=new Eb;var Ta=function(){function a(a,c){c.sort(function(){return Math.random()-.5});for(var d=0,e=20;e<l-40;e+=k)for(var f=0;f+k<=m;f+=k)g(a,c[d],e,f),d++,d===c.length&&(c.sort(b),d=0)}function b(a,b){return a.O?b.O?Math.random()-.5:-1:1}function c(a,b){for(var e=0,f=a.length;e<f;e++)if(void 0===a[e].O){d(a[e].src,function(d){a[e].O=d;c(a,b)});return}var g=[];a.forEach(function(a){a.O&&g.push(a.O)});b(g)}function d(a,b){var c=new XMLHttpRequest;c.responseType="blob";c.onreadystatechange=function(){if(4===
-c.readyState)if(c.response){var a=new Image;a.onload=function(){var c=document.createElement("canvas");c.height=c.width=x;c=c.getContext("2d");c.drawImage(a,0,0,x,x);var c=c.getImageData(0,0,x,x),d=0,e;for(e=0;e<c.width*c.height*4;e+=4)c.data[e]=c.data[e+1]=c.data[e+2]=(c.data[e]+c.data[e+1]+c.data[e+2])/3,c.data[e+3]=50,d+=c.data[e];if(50>d/(c.height*c.width))for(e=0;e<c.width*c.height*4;e+=4)c.data[e]=c.data[e+1]=c.data[e+2]=255-c.data[e];b(c)};a.onerror=function(){b(null)};a.src=window.URL.createObjectURL(c.response)}else b(null)};
-c.open("GET",a,!0);c.send(null)}function e(){var a=n.createLinearGradient(0,0,0,m);a.addColorStop(0,"#4D394B");a.addColorStop(1,"#201820");n.fillStyle=a;n.fillRect(0,0,l,m);return n.getImageData(0,0,l,m)}function f(a,b){for(var c=(a.height-b.height)/2,d=0;d<b.height;d++)for(var e=0;e<b.width;e++){var f=b.data[4*(d*b.width+e)]/255,g=4*((d+c)*a.width+e+c);a.data[g]*=f;a.data[g+1]*=f;a.data[g+2]*=f}return a}function g(a,b,c,d){var e=Math.floor(d);a=[a.data[e*l*4+0],a.data[e*l*4+1],a.data[e*l*4+2]];n.fillStyle=
-"#"+(1.1*a[0]<<16|1.1*a[1]<<8|1.1*a[2]).toString(16);n.beginPath();n.moveTo(c+k/2,d+q);n.lineTo(c-q+k,d+k/2);n.lineTo(c+k/2,d-q+k);n.lineTo(c+q,d+k/2);n.closePath();n.fill();n.putImageData(f(n.getImageData(c+q,d+q,u,u),b),c+q,d+q)}var h=document.createElement("canvas"),n=h.getContext("2d"),l=h.width=250,m=h.height=290,k=(l-40)/3,q=.1*k,u=Math.floor(k-2*q),x=.5*u,w={},A={},K={};return function(b,d,f){if(w[b])f(w[b]);else if(K[b])A[b]?A[b].push(f):A[b]=[f];else{var g=e(),k=[];K[b]=!0;A[b]?A[b].push(f):
-A[b]=[f];for(var l in d)d[l].Oa||d[l].nb||k.push({src:"api/avatar?user="+d[l].id});c(k,function(c){a(g,c);w[b]=h.toDataURL();A[b].forEach(function(a){a(w[b])})})}}}();var X=0,N=null,R=null,U=null,W=null;function sb(){var a=new XMLHttpRequest;a.timeout=6E4;a.onreadystatechange=function(){if(4===a.readyState){var b=document.createElement("script"),c=document.createElement("link");b.innerHTML=a.response;b.language="text/javascript";c.href="hljs-androidstudio.css";c.rel="stylesheet";document.head.appendChild(c);document.body.appendChild(b)}};a.open("GET","highlight.pack.js",!0);a.send(null)}
-function Kb(){var a=N,b=new XMLHttpRequest;b.open("GET","api/hist?room="+a.id,!0);b.onreadystatechange=function(){if(4===b.readyState&&b.response){var c=b.response;try{c=JSON.parse(c)}catch(e){}var d=E.a[a.id];d?d=!!ja(d,c,Date.now()):(E.a[a.id]=new Y(a,100,c,Date.now()),d=!0);d&&(Fb(I(E.context,a.id),a,c),a===N&&S())}};b.send(null)}
-function Lb(a){var b=new XMLHttpRequest;b.timeout=6E4;b.onreadystatechange=function(){if(4===b.readyState)if(b.status){var c=null,d=2===Math.floor(b.status/100);if(d){X&&(X=0,Xa(!0));c=b.response;try{c=JSON.parse(c)}catch(e){c=null}}else X?(X+=Math.floor((X||5)/2),X=Math.min(60,X)):(X=5,Xa(!1));a(d,c)}else X&&(X=0,Xa(!0)),Lb(a)};b.open("GET","api?v="+E.b,!0);b.send(null)}function Mb(a,b){a?(b&&E.update(b),xb()):setTimeout(xb,1E3*X)}function xb(){Lb(Mb)}
-function Nb(a){N&&(document.getElementById("room_"+N.id).classList.remove("selected"),document.getElementById("chatSystemContainer").classList.add("no-room-selected"));document.getElementById("room_"+a.id).classList.add("selected");document.body.classList.remove("no-room-selected");N=a;R=I(E.context,a.id);Ya();tb.Sa();Ta(R.a.id,R.j,function(a){document.getElementById("chatCtx").style.backgroundImage="url("+a+")"});(!E.a[N.id]||100>E.a[N.id].a.length)&&Kb();document.getElementById("chatSystemContainer").classList.remove("no-room-selected")}
-function Sa(){var a=document.location.hash.substr(1),b=sa(a);b&&b!==N?Nb(b):(a=J(a))&&a.V&&Nb(a.V)}function vb(a,b,c){var d=N;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 Ob(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:J(c.L).getName(),text:c.text,footer:a.h?M.message:a.name,ts:c.m}])));d.open("POST",b,!0);d.send(null)}
-function wb(a){if(W){var b=new XMLHttpRequest;b.open("PUT","api/msg?room="+N.id+"&ts="+W.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=R,d=pb.Ra(b);return d?(d.exec(c,N,a.trim()),!0):c&&(b=c.h.data[b])?(c=new XMLHttpRequest,c.open("POST","api/cmd?room="+N.id+"&cmd="+encodeURIComponent(b.name.substr(1))+"&args="+encodeURIComponent(a.trim()),!0),c.send(null),!0):!1}Ob(N,a,U);return!0}
+function rb(a){var b=document.createElement("li"),c=document.createElement("span");c.className="chat-command-name";b.appendChild(c);if("string"===typeof a)c.textContent=a;else{var d=document.createElement("span"),e=document.createElement("span");c.textContent=a.name;d.textContent=a.usage;e.textContent=a.kb;d.className="chat-command-usage";e.className="chat-command-desc";b.appendChild(d);b.appendChild(e)}b.dataset.input=c.textContent;b.className="chat-command-item";return b};var gb=function(){function a(a,b){for(a=a.target;a!==k&&a&&"LI"!==a.nodeName;)a=a.parentElement;a&&"LI"===a.nodeName&&a.id&&"emojibar-"===a.id.substr(0,9)?b(a.id.substr(9)):b(null)}function b(){w={};l.textContent="";window.emojiProviderHeader&&(l.appendChild(g(window.emojiProviderHeader)),q.textContent="",l.appendChild(q));l.appendChild(g("emojicustom.png"));l.appendChild(u)}function c(){if(!d())return!1;r&&r(null);return!0}function d(){return k.parentElement?(k.parentElement.removeChild(m),k.parentElement.removeChild(k),
+!0):!1}function e(a){var b=0;a=void 0===a?z.value:a;if(n()){var c=0,d=window.searchEmojis(a),e=f(d,O?O.self.S.a:[]),g;for(m in w)w[m].visible&&(w[m].visible=!1,q.removeChild(w[m].c));var m=0;for(g=e.length;m<g;m++){var l=e[m].name,G=w[l];if(!G){var G=w,k=l;var r=l;var l=window.makeEmoji(d[l]),F=document.createElement("span");F.appendChild(l);F.className="emoji-medium";r=h(r,F);G=G[k]=r}G.visible||(G.visible=!0,q.appendChild(G.c));c++}b+=c}m=b;c=0;for(C in x)x[C].visible&&(x[C].visible=!1,u.removeChild(x[C].c));
+if(O){d=f(O.b.data,O?O.self.S.a:[]);var C=0;for(b=d.length;C<b;C++)k=d[C].name,""!==a&&k.substr(0,a.length)!==a||"alias:"===O.b.data[k].substr(0,6)||(e=x[k],e||(e=x,G=g=k,k=O.b.data[k],r=document.createElement("span"),l=document.createElement("span"),r.className="emoji emoji-custom",r.style.backgroundImage='url("'+k+'")',l.appendChild(r),l.className="emoji-medium",G=h(G,l),e=e[g]=G),e.visible||(e.visible=!0,u.appendChild(e.c)),c++);C=c}else C=0;return m+C}function f(a,b){var c=[],d;for(d in a){var e=
+{name:d,ab:0,count:0};if(a[d].names)for(var f=0,g=a[d].names.length;f<g;f++)e.count+=b[a[d].names[f]]||0;c.push(e)}return c=c.sort(function(a,b){var c=b.count-a.count;return c?c:a.ab-b.ab})}function h(a,b){var c=document.createElement("li");c.appendChild(b);c.className="emojibar-list-item";c.id="emojibar-"+a;return{visible:!1,c:c}}function g(a){var b=document.createElement("img"),c=document.createElement("div");b.src=a;c.appendChild(b);c.className="emojibar-header";return c}function n(){return"searchEmojis"in
+window}var k=document.createElement("div"),m=document.createElement("div"),l=document.createElement("div"),q=document.createElement("ul"),u=document.createElement("ul"),z=document.createElement("input"),w={},x={},I=document.createElement("div"),F=document.createElement("span"),C=document.createElement("span"),r,O;m.addEventListener("click",function(a){var b=k.getBoundingClientRect();(a.screenY<b.top||a.screenY>b.bottom||a.screenX<b.left||a.screenX>b.right)&&c()});m.className="emojibar-overlay";k.className=
+"emojibar";l.className="emojibar-emojis";q.className=u.className="emojibar-list";z.className="emojibar-search";I.className="emojibar-detail";F.className="emojibar-detail-img";C.className="emojibar-detail-name";I.appendChild(F);I.appendChild(C);b();k.appendChild(l);k.appendChild(I);k.appendChild(z);z.addEventListener("keyup",function(){e()});k.addEventListener("mousemove",function(b){a(b,function(a){var b=a?w[a]||x[a]:null;b?(F.innerHTML=b.c.outerHTML,C.textContent=":"+a+":"):(F.textContent="",C.textContent=
+"")})});k.addEventListener("click",function(b){a(b,function(a){a&&d()&&r&&r(a)})});return{isSupported:n,la:function(a,b,c){return n()?(O=b,r=c,a.appendChild(m),a.appendChild(k),z.value="",e(),z.focus(),!0):!1},search:e,close:c,reset:function(){b();e()}}}();var H,P=[];function Db(){da.call(this)}Db.prototype=Object.create(da.prototype);Db.prototype.constructor=Db;function pa(a){return a.a?a.a.id:null}function Eb(){this.b=0;this.context=new na;this.a={}}
+Eb.prototype.update=function(a){var b=Date.now();a.v&&(this.b=a.v);if(a["static"])for(n in a["static"]){var c=oa(this.context,n);c||(c=new Db,this.context.push(c));var d={};a["static"][n].channels&&a["static"][n].channels.forEach(function(a){a.pins&&(d[a.id]=a.pins,a.pins=void 0)});ga(c,a["static"][n],b);for(var e in d){var f=[],h=this.a[e];h||(h=this.a[e]=new Y(e,250,null,b));d[e].forEach(function(a){f.push(h.b(a,b))});c.l[e].b=f}}qa(this.context,function(a){a.R===a.C&&(a=P.indexOf(a),-1!==a&&P.splice(a,
+1))});if(a.live){for(n in a.live)(c=this.a[n])?ja(c,a.live[n],b):c=this.a[n]=new Y(n,250,a.live[n],b);for(var g in a.live){var n=J(this.context,g);(c=n.l[g])?(this.a[g].a.length&&(c.R=Math.max(c.R,la(this.a[g]).m)),c.ea||(Fb(n,c,a.live[g]),N&&a.live[N.id]&&S())):H.b=0}}a["static"]&&Oa();var k=!1;a.typing&&this.context.a.forEach(function(c){var d=k,e=a.typing,f=!1;if(c.u)for(var g in c.u)e[g]||(delete c.u[g],f=!0);if(e)for(g in e)if(c.l[g]){c.u[g]||(c.u[g]={});for(var h in e[g])c.u[g][h]||(f=!0),c.u[g][h]=
+b}k=d|f},this);(a["static"]||k)&&Ua();a.config&&(Gb=new Hb(a.config),Ib()&&ub.ub(!1).display(ub.rb.T),Jb());if(R&&N&&a["static"]&&a["static"][R.a.id]&&a["static"][R.a.id].channels&&a["static"][R.a.id].channels)for(g=a["static"][R.a.id].channels,n=0,c=g.length;n<c;n++)if(g[n].id===N.id){S();break}};
+setInterval(function(){var a=!1,b=Date.now();ra(function(c){var d=!1,e;for(e in c.u){var f=!0,h;for(h in c.u[e])c.u[e][h]+3E3<b?(delete c.u[e][h],d=!0):f=!1;f&&(delete c.u[e],d=!0)}d&&(a=!0)});a&&Ua()},1E3);
+function Fb(a,b,c){if(b!==N||!window.hasFocus){var d=new RegExp("<@"+a.self.id),e=!1,f=!1,h=!1;c.forEach(function(c){if(!(parseFloat(c.ts)<=b.C)&&c.userId===a.self.id){f=!0;var g;if(!(g=b instanceof t)&&(g=c.text)&&!(g=c.text.match(d)))a:{g=a.self.S.B;for(var k=0,m=g.length;k<m;k++)if(-1!==c.text.indexOf(g[k])){g=!0;break a}g=!1}g&&(-1===P.indexOf(b)&&(h=!0,P.push(b)),e=!0)}});if(f){Q();if(c=document.getElementById("room_"+b.id))c.classList.add("unread"),e&&c.classList.add("unreadHi");h&&!window.hasFocus&&
+db()}}}function Za(){var a=N,b=P.indexOf(a);if(a.R>a.C){var c=H.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.m,!0);d.send(null);a.C=c.m}}0<=b&&(P.splice(b,1),Q());a=document.getElementById("room_"+a.id);a.classList.remove("unread");a.classList.remove("unreadHi")}H=new Eb;var Ta=function(){function a(a,c){c.sort(function(){return Math.random()-.5});for(var d=0,e=20;e<k-40;e+=l)for(var f=0;f+l<=m;f+=l)h(a,c[d],e,f),d++,d===c.length&&(c.sort(b),d=0)}function b(a,b){return a.P?b.P?Math.random()-.5:-1:1}function c(a,b){for(var e=0,f=a.length;e<f;e++)if(void 0===a[e].P){d(a[e].src,function(d){a[e].P=d;c(a,b)});return}var g=[];a.forEach(function(a){a.P&&g.push(a.P)});b(g)}function d(a,b){var c=new XMLHttpRequest;c.responseType="blob";c.onreadystatechange=function(){if(4===
+c.readyState)if(c.response){var a=new Image;a.onload=function(){var c=document.createElement("canvas");c.height=c.width=z;c=c.getContext("2d");c.drawImage(a,0,0,z,z);var c=c.getImageData(0,0,z,z),d=0,e;for(e=0;e<c.width*c.height*4;e+=4)c.data[e]=c.data[e+1]=c.data[e+2]=(c.data[e]+c.data[e+1]+c.data[e+2])/3,c.data[e+3]=50,d+=c.data[e];if(50>d/(c.height*c.width))for(e=0;e<c.width*c.height*4;e+=4)c.data[e]=c.data[e+1]=c.data[e+2]=255-c.data[e];b(c)};a.onerror=function(){b(null)};a.src=window.URL.createObjectURL(c.response)}else b(null)};
+c.open("GET",a,!0);c.send(null)}function e(){var a=n.createLinearGradient(0,0,0,m);a.addColorStop(0,"#4D394B");a.addColorStop(1,"#201820");n.fillStyle=a;n.fillRect(0,0,k,m);return n.getImageData(0,0,k,m)}function f(a,b){for(var c=(a.height-b.height)/2,d=0;d<b.height;d++)for(var e=0;e<b.width;e++){var f=b.data[4*(d*b.width+e)]/255,g=4*((d+c)*a.width+e+c);a.data[g]*=f;a.data[g+1]*=f;a.data[g+2]*=f}return a}function h(a,b,c,d){var e=Math.floor(d);a=[a.data[e*k*4+0],a.data[e*k*4+1],a.data[e*k*4+2]];n.fillStyle=
+"#"+(1.1*a[0]<<16|1.1*a[1]<<8|1.1*a[2]).toString(16);n.beginPath();n.moveTo(c+l/2,d+q);n.lineTo(c-q+l,d+l/2);n.lineTo(c+l/2,d-q+l);n.lineTo(c+q,d+l/2);n.closePath();n.fill();n.putImageData(f(n.getImageData(c+q,d+q,u,u),b),c+q,d+q)}var g=document.createElement("canvas"),n=g.getContext("2d"),k=g.width=250,m=g.height=290,l=(k-40)/3,q=.1*l,u=Math.floor(l-2*q),z=.5*u,w={},x={},I={};return function(b,d,f){if(w[b])f(w[b]);else if(I[b])x[b]?x[b].push(f):x[b]=[f];else{var h=e(),l=[];I[b]=!0;x[b]?x[b].push(f):
+x[b]=[f];for(var k in d)d[k].Oa||d[k].ob||l.push({src:"api/avatar?user="+d[k].id});c(l,function(c){a(h,c);w[b]=g.toDataURL();x[b].forEach(function(a){a(w[b])})})}}}();var X=0,N=null,R=null,U=null,W=null;function sb(){var a=new XMLHttpRequest;a.timeout=6E4;a.onreadystatechange=function(){if(4===a.readyState){var b=document.createElement("script"),c=document.createElement("link");b.innerHTML=a.response;b.language="text/javascript";c.href="hljs-androidstudio.css";c.rel="stylesheet";document.head.appendChild(c);document.body.appendChild(b)}};a.open("GET","highlight.pack.js",!0);a.send(null)}
+function Kb(){var a=N,b=new XMLHttpRequest;b.open("GET","api/hist?room="+a.id,!0);b.onreadystatechange=function(){if(4===b.readyState&&b.response){var c=b.response;try{c=JSON.parse(c)}catch(e){}var d=H.a[a.id];d?d=!!ja(d,c,Date.now()):(H.a[a.id]=new Y(a,100,c,Date.now()),d=!0);d&&(Fb(J(H.context,a.id),a,c),a===N&&S())}};b.send(null)}
+function Lb(a){var b=new XMLHttpRequest;b.timeout=6E4;b.onreadystatechange=function(){if(4===b.readyState)if(b.status){var c=null,d=2===Math.floor(b.status/100);if(d){X&&(X=0,Xa(!0));c=b.response;try{c=JSON.parse(c)}catch(e){c=null}}else X?(X+=Math.floor((X||5)/2),X=Math.min(60,X)):(X=5,Xa(!1));a(d,c)}else X&&(X=0,Xa(!0)),Lb(a)};b.open("GET","api?v="+H.b,!0);b.send(null)}function Mb(a,b){a?(b&&H.update(b),xb()):setTimeout(xb,1E3*X)}function xb(){Lb(Mb)}
+function Nb(a){N&&(document.getElementById("room_"+N.id).classList.remove("selected"),document.getElementById("chatSystemContainer").classList.add("no-room-selected"));document.getElementById("room_"+a.id).classList.add("selected");document.body.classList.remove("no-room-selected");N=a;R=J(H.context,a.id);Ya();tb.Sa();Ta(R.a.id,R.h,function(a){document.getElementById("chatCtx").style.backgroundImage="url("+a+")"});(!H.a[N.id]||100>H.a[N.id].a.length)&&Kb();document.getElementById("chatSystemContainer").classList.remove("no-room-selected")}
+function Sa(){var a=document.location.hash.substr(1),b=sa(a);b&&b!==N?Nb(b):(a=K(a))&&a.W&&Nb(a.W)}function vb(a,b,c){var d=N;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 Ob(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:K(c.N).getName(),text:c.text,footer:a.i?M.message:a.name,ts:c.m}])));d.open("POST",b,!0);d.send(null)}
+function wb(a){if(W){var b=new XMLHttpRequest;b.open("PUT","api/msg?room="+N.id+"&ts="+W.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=R,d=pb.Ra(b);return d?(d.exec(c,N,a.trim()),!0):c&&(b=c.i.data[b])?(c=new XMLHttpRequest,c.open("POST","api/cmd?room="+N.id+"&cmd="+encodeURIComponent(b.name.substr(1))+"&args="+encodeURIComponent(a.trim()),!0),c.send(null),!0):!1}Ob(N,a,U);return!0}
 function lb(a){var b=new XMLHttpRequest;b.open("DELETE","api/msg?room="+N.id+"&ts="+a.id,!0);b.send(null)}function kb(a){var b=new XMLHttpRequest;b.open("POST","api/pinMsg?room="+N.id+"&msgId="+a.id,!0);b.send(null)}function ib(a){var b=new XMLHttpRequest;b.open("POST","api/starMsg?room="+N.id+"&msgId="+a.id,!0);b.send(null)}function jb(a,b){var c=new XMLHttpRequest;c.open("DELETE","api/pinMsg?room="+a.id+"&msgId="+b.id,!0);c.send(null)}
 function hb(a){var b=new XMLHttpRequest;b.open("DELETE","api/starMsg?room="+N.id+"&msgId="+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 Ra(){var a={},b=[],c=this.value;qa(E.context,function(b){a[b.id]=ha(b,c)});for(var d in a){var e=document.getElementById("room_"+d);e&&(a[d].name+a[d].ia+a[d].ma+a[d].ja?(e.classList.remove("hidden"),b.push(d)):e.classList.add("hidden"))}};var Pb={emojione_v2_3:{Ua:"emojione_v2.3.sprites.js",Na:"emojione_v2.3.sprites.css",name:"Emojione v2.3"},emojione_v3:{Ua:"emojione_v3.sprites.js",Na:"emojione_v3.sprites.css",name:"Emojione v3"}},Qb=Pb.emojione_v2_3,Rb;
-function Sb(a){if(Rb!==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.Na;d.rel="stylesheet";document.head.appendChild(d);document.body.appendChild(c);for(var e in E.a)Tb(E.a[e]);N&&S();gb.reset()}};b.open("GET",a.Ua,!0);b.send(null);Rb=a}}
-function Jb(){a:{var a=Gb;for(var b in a.S){var c=a.S[b].emojiProvider;if(c&&Pb[c]){a=c;break a}}a=void 0}Sb(a&&Pb[a]?Pb[a]:Qb)};var tb=function(){function a(){b();if(r instanceof t)e.style.backgroundImage="url(api/avatar?size=l&user="+r.a.id+")",n.textContent=(r.a.cb||(r.a.Qa||"")+" "+r.a.Va).trim(),f.classList.add("presence-indicator"),r.a.wa?f.classList.remove("presence-away"):f.classList.add("presence-away"),h.classList.remove("hidden"),m.classList.remove("hidden"),m.textContent=r.a.rb||"",q.textContent=r.a.lb||"",k.classList.remove("hidden"),d.classList.remove("roominfo-channel"),d.classList.add("roominfo-user");else{var a=
-F;a.Y.topic?(h.classList.remove("hidden"),n.textContent=r.ma||"",l.textContent=r.I?M.za(r.I,r.ca):""):h.classList.add("hidden");a.Y.purpose?(k.classList.remove("hidden"),q.textContent=r.ja||"",u.textContent=r.o?M.za(r.o,r.ba):""):k.classList.add("hidden");e.style.backgroundImage="";f.classList.remove("presence-indicator");d.classList.add("roominfo-channel");d.classList.remove("roominfo-user")}}function b(){f.textContent=r.name;if(r.b){x.textContent=M.Za(r.b.length);x.classList.remove("hidden");w.classList.remove("hidden");
-var a=document.createDocumentFragment();r.b.forEach(function(b){var d=document.createElement("li"),e=document.createElement("a");e.href="javascript:void(0)";e.dataset.msgId=b.id;e.addEventListener("click",c);e.className=Ea+" roominfo-unpin";d.className="roominfo-pinlist-item";d.appendChild(b.J());d.appendChild(e);a.appendChild(d)});w.textContent="";w.appendChild(a)}else x.classList.add("hidden"),w.classList.add("hidden")}function c(){if(r.b)for(var a=0,b=r.b.length;a<b;a++)if(r.b[a].id===this.dataset.msgId){jb(r,
-r.b[a]);break}}var d=document.createElement("div"),e=document.createElement("header"),f=document.createElement("h3"),g=document.createElement("div"),h=document.createElement("div"),n=document.createElement("span"),l=document.createElement("span"),m=document.createElement("div"),k=document.createElement("div"),q=document.createElement("span"),u=document.createElement("span"),x=document.createElement("div"),w=document.createElement("ul"),A=document.createElement("div"),K=document.createElement("ul"),
-F,r;d.className="chat-context-roominfo";e.className="roominfo-title";h.className="roominfo-topic";k.className="roominfo-purpose";m.className="roominfo-phone";x.className="roominfo-pincount";w.className="roominfo-pinlist";A.className="roominfo-usercount";K.className="roominfo-userlist";u.className=l.className="roominfo-author";e.appendChild(f);d.appendChild(e);d.appendChild(g);h.appendChild(n);h.appendChild(l);k.appendChild(q);k.appendChild(u);g.appendChild(h);g.appendChild(m);g.appendChild(k);g.appendChild(x);
-g.appendChild(w);g.appendChild(A);g.appendChild(K);return{$a:function(b,c){F=b;r=c;a();return this},update:function(){a();return this},show:function(a){a.appendChild(d);d.classList.remove("hidden");return this},Sa:function(){d.classList.add("hidden");return this},ob:function(a){for(;a;){if(a===d)return!0;a=a.parentNode}return!1}}}();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.b=function(a,b){return!0===a.isMeMessage?new Ub(this.id,a,b):!0===a.isNotice?new Vb(this.id,a,b):new Wb(this.id,a,b)};function Tb(a){a.a.forEach(function(a){a.G()})}
-var Z=function(){function a(a,d){return wa(d,{B:a.context.self.R.B,Z: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},ha: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=pa(a.context)+"|"+d.substr(1),g=J(d))a=!0,d="#"+g.V.id,g="@"+g.getName();else return null;
-else if("#"===d[0])if(d=pa(a.context)+"|"+d.substr(1),g=sa(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,Ta:a}}return{G:function(a){a.T=!0;return a},W:function(a){a.c&&a.c.parentElement&&(a.c.remove(),delete a.c);return a},J:function(a){a.c?a.T&&(a.T=!1,a.K()):a.sa().K();return a.c},K:function(b){var c=J(b.L);b.c.m.innerHTML=M.N(b.m);b.c.ya.innerHTML=a(b,b.text);b.c.ta.textContent=c?c.getName():b.username||"?";for(var c=
-document.createDocumentFragment(),e=0,f=b.s.length;e<f;e++){var g=b.s[e];g&&(g=Bb(b,g,e))&&c.appendChild(g)}b.c.s.textContent="";b.c.s.appendChild(c);c=b.b;e=document.createDocumentFragment();if(b.D)for(var h in b.D){var f=c,g=b.id,n=h,l=b.D[h],m=bb(n);if(m){for(var k=document.createElement("li"),q=document.createElement("a"),u=document.createElement("span"),x=document.createElement("span"),w=[],A=0,K=l.length;A<K;A++){var F=J(l[A]);F&&w.push(F.getName())}w.sort();x.textContent=w.join(", ");u.appendChild(m);
-u.className="emoji-small";q.href="javascript:toggleReaction('"+f+"', '"+g+"', '"+n+"')";q.appendChild(u);q.appendChild(x);k.className="chatmsg-reaction-item";k.appendChild(q);f=k}else console.warn("Reaction id not found: "+n),f=null;f&&e.appendChild(f)}b.c.D.textContent="";b.c.D.appendChild(e);b.c.aa.ga&&(b.c.aa.ga.style.backgroundImage=b.A?'url("star_full.png")':'url("star_empty.png")');b.F&&(b.c.F.innerHTML=M.F(b.F),b.c.classList.add("edited"));return b},M:function(a){return a.c.cloneNode(!0)},
-w:function(b,d){return a(b,d)}}}();function Ub(a,b,c){z.call(this,b,c);this.context=I(E.context,a);this.b=a;this.c=Z.c;this.T=Z.T}Ub.prototype=Object.create(B.prototype);p=Ub.prototype;p.constructor=Ub;p.G=function(){return Z.G(this)};p.w=function(a){return Z.w(this,a)};p.W=function(){return Z.W(this)};p.J=function(){return Z.J(this)};p.sa=function(){this.c=zb(this);this.c.classList.add("chatmsg-me_message");return this};p.M=function(){return Z.M(this)};p.K=function(){Z.K(this);return this};
-p.update=function(a,b){B.prototype.update.call(this,a,b);this.G()};function Wb(a,b,c){z.call(this,b,c);this.context=I(E.context,a);this.b=a;this.c=Z.c;this.T=Z.T}Wb.prototype=Object.create(z.prototype);p=Wb.prototype;p.constructor=Wb;p.G=function(){return Z.G(this)};p.w=function(a){return Z.w(this,a)};p.W=function(){return Z.W(this)};p.J=function(){return Z.J(this)};p.sa=function(){this.c=zb(this);return this};p.M=function(){return Z.M(this)};p.K=function(){Z.K(this);return this};
-p.update=function(a,b){z.prototype.update.call(this,a,b);this.G();if(a=this.text.match(/^<?https:\/\/www\.openstreetmap\.org\/\?mlat=(-?[0-9\.]+)(&amp;|&)mlon=(-?[0-9\.]+)(&amp;|&)macc=([0-9\.]+)[^\s]*/))this.text=this.text.substr(0,a.index)+this.text.substr(a.index+a[0].length).trim(),this.s.unshift({color:"#008000",text:a[0],footer:"Open Street Map",footer_icon:"https://www.openstreetmap.org/assets/favicon-32x32-36d06d8a01933075bc7093c9631cffd02d49b03b659f767340f256bb6839d990.png",geo:{latitude:a[1],
-longitude:a[3],accuracy:a[5]}})};function Vb(a,b,c){z.call(this,b,c);this.context=I(E.context,a);this.b=a;this.a=null;this.T=!0}Vb.prototype=Object.create(C.prototype);p=Vb.prototype;p.constructor=Vb;p.G=function(){return Z.G(this)};p.w=function(a){return Z.w(this,a)};p.W=function(){this.a&&this.a.parentElement&&(this.a.remove(),delete this.a);this.c&&delete this.c;return this};p.J=function(){Z.J(this);return this.a};p.M=function(){return this.a.cloneNode(!0)};
-p.sa=function(){this.c=zb(this);this.a=document.createElement("span");this.c.classList.add("chatmsg-notice");this.a.className="chatmsg-notice";this.a.textContent=M.Ya;this.a.appendChild(this.c);return this};p.K=function(){Z.K(this);return this};p.update=function(a,b){C.prototype.update.call(this,a,b);this.G()};function Ib(){var a=Gb.S,b;for(b in a)if(a.hasOwnProperty(b))return!1;return!0};var Gb;function Hb(a){this.S={};for(var b=0,c=a.length;b<c;b++)if(null===a[b].service&&null===a[b].device){var d=void 0,e=JSON.parse(a[b].config);if(e.services)for(d in e.services)this.S[d]=e.services[d]}};var pb=function(){var a=[];return{Ra:function(b){for(var c=0,d=a.length;c<d;c++)if(-1!==a[c].names.indexOf(b))return a[c];return null},kb:function(b){var c=[];a.forEach(function(a){for(var d=0,f=a.names.length;d<f;d++)if(a.names[d].substr(0,b.length)===b){c.push(a);break}});return c},sb:function(b){b.U="client";b.exec=b.exec.bind(b);a.push(b)}}}();function Xb(){return new Promise(function(a,b){"geolocation"in window.navigator?navigator.geolocation.getCurrentPosition(function(c){c?a(c):b("denied")}):b("geolocation not available")})}
-ua.push(function(){pb.sb({name:"/sherlock",names:["/sherlock","/sharelock"],usage:"",description:M.eb,exec:function(a,b){Xb().then(function(a){var c=a.coords.latitude,e=a.coords.longitude;Ob(b,"https://www.openstreetmap.org/?mlat="+c+"&mlon="+e+"&macc="+a.coords.accuracy+"#map=17/"+c+"/"+e)}).catch(function(a){console.error("Error: ",a)})}})});
+function Ra(){var a={},b=[],c=this.value;qa(H.context,function(b){a[b.id]=ha(b,c)});for(var d in a){var e=document.getElementById("room_"+d);e&&(a[d].name+a[d].ja+a[d].na+a[d].ka?(e.classList.remove("hidden"),b.push(d)):e.classList.add("hidden"))}};var Pb={emojione_v2_3:{Ua:"emojione_v2.3.sprites.js",Na:"emojione_v2.3.sprites.css",name:"Emojione v2.3"},emojione_v3:{Ua:"emojione_v3.sprites.js",Na:"emojione_v3.sprites.css",name:"Emojione v3"}},Qb=Pb.emojione_v2_3,Rb;
+function Sb(a){if(Rb!==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.Na;d.rel="stylesheet";document.head.appendChild(d);document.body.appendChild(c);for(var e in H.a)Tb(H.a[e]);N&&S();gb.reset()}};b.open("GET",a.Ua,!0);b.send(null);Rb=a}}
+function Jb(){a:{var a=Gb;for(var b in a.T){var c=a.T[b].emojiProvider;if(c&&Pb[c]){a=c;break a}}a=void 0}Sb(a&&Pb[a]?Pb[a]:Qb)};var tb=function(){function a(){c();r instanceof t?(f.style.backgroundImage="url(api/avatar?size=l&user="+r.a.id+")",k.textContent=(r.a.cb||(r.a.Qa||"")+" "+r.a.Va).trim(),h.classList.add("presence-indicator"),r.a.L?h.classList.remove("presence-away"):h.classList.add("presence-away"),n.classList.remove("hidden"),l.classList.remove("hidden"),l.textContent=r.a.sb||"",u.textContent=r.a.mb||"",q.classList.remove("hidden"),e.classList.remove("roominfo-channel"),e.classList.add("roominfo-user")):b()}function b(){var a=
+C;a.Z.topic?(n.classList.remove("hidden"),k.textContent=r.na||"",m.textContent=r.J?M.za(r.J,r.da):""):n.classList.add("hidden");a.Z.purpose?(q.classList.remove("hidden"),u.textContent=r.ka||"",z.textContent=r.o?M.za(r.o,r.ca):""):q.classList.add("hidden");f.style.backgroundImage="";h.classList.remove("presence-indicator");I.textContent=M.fb(r.h?Object.keys(r.h).length:0);a=[];if(r.h)for(var b in r.h)a.push(r.h[b]);a.sort(function(a,b){return a.L&&!b.L?-1:b.L&&!a.L?1:a.getName().localeCompare(b.getName())});
+var c=document.createDocumentFragment();a.forEach(function(a){var b=document.createElement("li"),d=document.createElement("a");d.href="#"+a.id;d.textContent=a.getName();b.appendChild(d);b.classList.add("presence-indicator");a.L||b.classList.add("presence-away");c.appendChild(b)});F.textContent="";F.appendChild(c);e.classList.add("roominfo-channel");e.classList.remove("roominfo-user")}function c(){h.textContent=r.name;if(r.b){w.textContent=M.Za(r.b.length);w.classList.remove("hidden");x.classList.remove("hidden");
+var a=document.createDocumentFragment();r.b.forEach(function(b){var c=document.createElement("li"),e=document.createElement("a");e.href="javascript:void(0)";e.dataset.msgId=b.id;e.addEventListener("click",d);e.className=Ea+" roominfo-unpin";c.className="roominfo-pinlist-item";c.appendChild(b.I());c.appendChild(e);a.appendChild(c)});x.textContent="";x.appendChild(a)}else w.classList.add("hidden"),x.classList.add("hidden")}function d(){if(r.b)for(var a=0,b=r.b.length;a<b;a++)if(r.b[a].id===this.dataset.msgId){jb(r,
+r.b[a]);break}}var e=document.createElement("div"),f=document.createElement("header"),h=document.createElement("h3"),g=document.createElement("div"),n=document.createElement("div"),k=document.createElement("span"),m=document.createElement("span"),l=document.createElement("div"),q=document.createElement("div"),u=document.createElement("span"),z=document.createElement("span"),w=document.createElement("div"),x=document.createElement("ul"),I=document.createElement("div"),F=document.createElement("ul"),
+C,r;e.className="chat-context-roominfo";f.className="roominfo-title";n.className="roominfo-topic";q.className="roominfo-purpose";l.className="roominfo-phone";w.className="roominfo-pincount";x.className="roominfo-pinlist";I.className="roominfo-usercount";F.className="roominfo-userlist";z.className=m.className="roominfo-author";f.appendChild(h);e.appendChild(f);e.appendChild(g);n.appendChild(k);n.appendChild(m);q.appendChild(u);q.appendChild(z);g.appendChild(n);g.appendChild(l);g.appendChild(q);g.appendChild(w);
+g.appendChild(x);g.appendChild(I);g.appendChild(F);return{$a:function(b,c){C=b;r=c;a();return this},update:function(){a();return this},show:function(a){a.appendChild(e);e.classList.remove("hidden");return this},Sa:function(){e.classList.add("hidden");return this},pb:function(a){for(;a;){if(a===e)return!0;a=a.parentNode}return!1}}}();function Y(a,b,c,d){E.call(this,a,b,0,c,d)}Y.prototype=Object.create(E.prototype);Y.prototype.constructor=Y;Y.prototype.b=function(a,b){return!0===a.isMeMessage?new Ub(this.id,a,b):!0===a.isNotice?new Vb(this.id,a,b):new Wb(this.id,a,b)};function Tb(a){a.a.forEach(function(a){a.G()})}
+var Z=function(){function a(a,d){return wa(d,{B:a.context.self.S.B,$: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},ia: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 h=b.substr(c+1)}if("@"===d[0])if(d=pa(a.context)+"|"+d.substr(1),h=K(d))a=!0,d="#"+h.W.id,h="@"+h.getName();else return null;
+else if("#"===d[0])if(d=pa(a.context)+"|"+d.substr(1),h=sa(d))a=!0,d="#"+d,h="#"+h.name;else return null;else{if(!d.match(/^(https?|mailto):\/\//i))return null;a=!1}return{link:d,text:h||d,Ta:a}}return{G:function(a){a.U=!0;return a},X:function(a){a.c&&a.c.parentElement&&(a.c.remove(),delete a.c);return a},K:function(a){a.c?a.U&&(a.U=!1,a.M()):a.ta().M();return a.c},M:function(b){var c=K(b.N);b.c.m.innerHTML=M.O(b.m);b.c.ya.innerHTML=a(b,b.text);b.c.ua.textContent=c?c.getName():b.username||"?";for(var c=
+document.createDocumentFragment(),e=0,f=b.s.length;e<f;e++){var h=b.s[e];h&&(h=Bb(b,h,e))&&c.appendChild(h)}b.c.s.textContent="";b.c.s.appendChild(c);c=b.b;e=document.createDocumentFragment();if(b.D)for(var g in b.D){var f=c,h=b.id,n=g,k=b.D[g],m=bb(n);if(m){for(var l=document.createElement("li"),q=document.createElement("a"),u=document.createElement("span"),z=document.createElement("span"),w=[],x=0,I=k.length;x<I;x++){var F=K(k[x]);F&&w.push(F.getName())}w.sort();z.textContent=w.join(", ");u.appendChild(m);
+u.className="emoji-small";q.href="javascript:toggleReaction('"+f+"', '"+h+"', '"+n+"')";q.appendChild(u);q.appendChild(z);l.className="chatmsg-reaction-item";l.appendChild(q);f=l}else console.warn("Reaction id not found: "+n),f=null;f&&e.appendChild(f)}b.c.D.textContent="";b.c.D.appendChild(e);b.c.ba.ha&&(b.c.ba.ha.style.backgroundImage=b.A?'url("star_full.png")':'url("star_empty.png")');b.F&&(b.c.F.innerHTML=M.F(b.F),b.c.classList.add("edited"));return b},I:function(a){return a.K().cloneNode(!0)},
+w:function(b,d){return a(b,d)}}}();function Ub(a,b,c){A.call(this,b,c);this.context=J(H.context,a);this.b=a;this.c=Z.c;this.U=Z.U}Ub.prototype=Object.create(B.prototype);p=Ub.prototype;p.constructor=Ub;p.G=function(){return Z.G(this)};p.w=function(a){return Z.w(this,a)};p.X=function(){return Z.X(this)};p.K=function(){return Z.K(this)};p.ta=function(){this.c=zb(this);this.c.classList.add("chatmsg-me_message");return this};p.I=function(){return Z.I(this)};p.M=function(){Z.M(this);return this};
+p.update=function(a,b){B.prototype.update.call(this,a,b);this.G()};function Wb(a,b,c){A.call(this,b,c);this.context=J(H.context,a);this.b=a;this.c=Z.c;this.U=Z.U}Wb.prototype=Object.create(A.prototype);p=Wb.prototype;p.constructor=Wb;p.G=function(){return Z.G(this)};p.w=function(a){return Z.w(this,a)};p.X=function(){return Z.X(this)};p.K=function(){return Z.K(this)};p.ta=function(){this.c=zb(this);return this};p.I=function(){return Z.I(this)};p.M=function(){Z.M(this);return this};
+p.update=function(a,b){A.prototype.update.call(this,a,b);this.G();if(a=this.text.match(/^<?https:\/\/www\.openstreetmap\.org\/\?mlat=(-?[0-9\.]+)(&amp;|&)mlon=(-?[0-9\.]+)(&amp;|&)macc=([0-9\.]+)[^\s]*/))this.text=this.text.substr(0,a.index)+this.text.substr(a.index+a[0].length).trim(),this.s.unshift({color:"#008000",text:a[0],footer:"Open Street Map",footer_icon:"https://www.openstreetmap.org/assets/favicon-32x32-36d06d8a01933075bc7093c9631cffd02d49b03b659f767340f256bb6839d990.png",geo:{latitude:a[1],
+longitude:a[3],accuracy:a[5]}})};function Vb(a,b,c){A.call(this,b,c);this.context=J(H.context,a);this.b=a;this.a=null;this.U=!0}Vb.prototype=Object.create(D.prototype);p=Vb.prototype;p.constructor=Vb;p.G=function(){return Z.G(this)};p.w=function(a){return Z.w(this,a)};p.X=function(){this.a&&this.a.parentElement&&(this.a.remove(),delete this.a);this.c&&delete this.c;return this};p.K=function(){Z.K(this);return this.a};p.I=function(){return this.a.cloneNode(!0)};
+p.ta=function(){this.c=zb(this);this.a=document.createElement("span");this.c.classList.add("chatmsg-notice");this.a.className="chatmsg-notice";this.a.textContent=M.Ya;this.a.appendChild(this.c);return this};p.M=function(){Z.M(this);return this};p.update=function(a,b){D.prototype.update.call(this,a,b);this.G()};function Ib(){var a=Gb.T,b;for(b in a)if(a.hasOwnProperty(b))return!1;return!0};var Gb;function Hb(a){this.T={};for(var b=0,c=a.length;b<c;b++)if(null===a[b].service&&null===a[b].device){var d=void 0,e=JSON.parse(a[b].config);if(e.services)for(d in e.services)this.T[d]=e.services[d]}};var pb=function(){var a=[];return{Ra:function(b){for(var c=0,d=a.length;c<d;c++)if(-1!==a[c].names.indexOf(b))return a[c];return null},lb:function(b){var c=[];a.forEach(function(a){for(var d=0,f=a.names.length;d<f;d++)if(a.names[d].substr(0,b.length)===b){c.push(a);break}});return c},tb:function(b){b.V="client";b.exec=b.exec.bind(b);a.push(b)}}}();function Xb(){return new Promise(function(a,b){"geolocation"in window.navigator?navigator.geolocation.getCurrentPosition(function(c){c?a(c):b("denied")}):b("geolocation not available")})}
+ua.push(function(){pb.tb({name:"/sherlock",names:["/sherlock","/sharelock"],usage:"",description:M.eb,exec:function(a,b){Xb().then(function(a){var c=a.coords.latitude,e=a.coords.longitude;Ob(b,"https://www.openstreetmap.org/?mlat="+c+"&mlon="+e+"&macc="+a.coords.accuracy+"#map=17/"+c+"/"+e)}).catch(function(a){console.error("Error: ",a)})}})});
 })();

+ 11 - 4
srv/public/style.css

@@ -46,10 +46,16 @@ button, .button { border: 1px solid black; border-radius: 3px; background: rgb(2
 .presence-indicator::before { content: " "; display: inline-block; height: 6px; width: 6px; padding: 0; border: 2px solid currentColor; vertical-align: middle; background: currentColor; border-radius: 5px; }
 .presence-indicator.presence-away::before { background: transparent; }
 
-.chat-context .chat-context-roominfo { position: fixed; display: block; left: 235px; width: 400px; top: 0; bottom: 0; z-index: 100; background-color: #4D394B; color: white; overflow: auto; }
+.chat-context .chat-context-roominfo { position: fixed; display: block; left: 235px; width: 400px; top: 0; bottom: 0; z-index: 100; background-color: #4D394B; color: white; overflow: auto; font-style: initial; }
 .chatsystem-content .chat-context-roominfo { position: absolute; display: block; width: 400px; z-index: 100; background-color: #4D394B; color: white; overflow: auto; }
-.roominfo-title { background-position: center center; background-size: cover; padding: 250px 15px 0 15px; font-size: 1.75em; }
-.roominfo-topic,.roominfo-purpose,.roominfo-phone,.roominfo-pincount { margin: 20px 15px 0 15px; }
+.roominfo-title { background-position: center center; background-size: cover; padding: 250px 0 0 0; font-size: 1.75em; }
+.roominfo-title > h3 { padding: 0 15px; background: rgba(0, 0, 0, 0.5); }
+.chat-context-roominfo a { color: white; }
+.chat-context-roominfo .roominfo-userlist { padding: 0; list-style: none; }
+.chat-context-roominfo .roominfo-userlist a, .chat-context-roominfo .presence-indicator { color: #4c9689; text-decoration: none; }
+.chat-context-roominfo .roominfo-userlist .presence-away a, .chat-context-roominfo .presence-away { color: #AB9BA9; font-style: italic; }
+.chat-context-roominfo .presence-indicator::before { margin-right: 5px; }
+.roominfo-topic,.roominfo-purpose,.roominfo-phone,.roominfo-pincount,.roominfo-usercount,.roominfo-userlist { margin: 20px 15px 0 15px; }
 .roominfo-topic *,.roominfo-purpose * { display: block; }
 .roominfo-author, .chat-context-roominfo .chatmsg-author-name, .chat-context-roominfo .chatmsg-content a  { color: #c1c1c1; }
 .roominfo-channel .roominfo-phone { display: none; }
@@ -95,7 +101,8 @@ button, .button { border: 1px solid black; border-radius: 3px; background: rgb(2
 .chatmsg-authorGroup, .chatmsg-me_message { padding: 10px; }
 .chatmsg-authorGroup .chatmsg-item { padding: 4px 10px; }
 .chatmsg-item { display: flex; position: relative; }
-.chatsystem-content .chatmsg-item:hover { background: #F9F9F9; }
+.chatmsg-item:hover { background: #F9F9F9; }
+.chat-context-roominfo .chatmsg-item:hover { background: inherit; }
 .chatmsg-item.chatmsg-first-unread { border-top: 1px solid rgba(255,135,109,.5); }
 .chatmsg-item.chatmsg-first-unread::before { display: inline-block; position: absolute; right: 0; top: -0.8em; content: "New"; color: rgba(255,135,109,.5); background: white; padding: 0 5px 0 3px; font-style: italic; }
 .chatmsg-content { display: inline-block; width: 100%; }

+ 1 - 1
srv/src/controller/apiController.js

@@ -354,7 +354,7 @@ module.exports.ApiController = {
             }
         } else if (req.urlObj.match(["api"])) {
             res.chatContext.poll(
-                (req.urlObj.queryTokens.v ? parseInt(req.urlObj.queryTokens.v[0], 10) : 0) || 0, (newData) => {
+                (req.urlObj.queryTokens.v ? parseInt(req.urlObj.queryTokens.v[0], 10) : 0) || 0, req.reqT, (newData) => {
                 if (!res.ended) {
                     try {
                         res.writeHeader("200", {

+ 86 - 59
srv/src/multichatManager.js

@@ -1,4 +1,7 @@
 
+/** @const */
+var POLL_TIMEOUT = 55000;
+
 /** @interface */
 function ChatSystem() {
 };
@@ -243,71 +246,77 @@ MultiChatManager.prototype.isMe = function(userId) {
     return false;
 };
 
+MultiChatManager.prototype.pollPeriodical = function(knownVersion) {
+    var liveFeed
+        ,staticFeed
+        ,allTyping
+        ,v = 0
+        ,now = Date.now()
+        ,updated = false;
+
+    this.contexts.forEach(function(ctx) {
+        var id = ctx.getId();
+        if (id) {
+            var res = ctx.poll(knownVersion, now);
+
+            if (res) {
+                if (res["static"]) {
+                    if (!staticFeed)
+                        staticFeed = {};
+                    staticFeed[id] = res["static"];
+                }
+                if (res["live"])
+                    if (!liveFeed)
+                        liveFeed = {};
+                    for (var i in res["live"]) {
+                        liveFeed[i] = res["live"][i];
+                    }
+                if (res["typing"]) {
+                    if (!allTyping)
+                        allTyping = {};
+                    for (var i in res["typing"])
+                        allTyping[i] = res["typing"][i];
+                }
+                v = Math.max(v, (res["v"] || 0));
+                updated = true;
+            }
+        }
+    });
+    if (updated)
+        return ({
+            "live": liveFeed,
+            "static": staticFeed,
+            "typing": allTyping,
+            "v": Math.max(v, knownVersion)
+        });
+};
+
+MultiChatManager.prototype.startPolling = function(knownVersion, reqT, callback) {
+    var _this = this;
+    var res = _this.pollPeriodical(knownVersion),
+        now = Date.now();
+    if (res) {
+        callback(res);
+    } else if (now -reqT > POLL_TIMEOUT) {
+        callback({
+            "v": knownVersion
+        });
+    } else {
+        setTimeout(function() { _this.startPolling(knownVersion, reqT, callback); }, 2000);
+    }
+};
+
 /**
  * @param {number} knownVersion
  * @param {Function} callback
  * @param {(function(number, function((Array<{expose:Function, modified: number}>|null))))=} checkConfigUpdate
 **/
-MultiChatManager.prototype.poll = function(knownVersion, callback, checkConfigUpdate) {
+MultiChatManager.prototype.poll = function(knownVersion, reqT, callback, checkConfigUpdate) {
     this.contexts.forEach(function(ctx) {
         ctx.onRequest();
     });
-    var configFeed = { config: null };
-    setTimeout((function() {
-        //FIXME polling
-        var liveFeed
-            ,staticFeed
-            ,allTyping
-            ,v = 0
-            ,updated = !!configFeed
-            ,now = Date.now();
-
-        this.contexts.forEach(function(ctx) {
-            var id = ctx.getId();
-            if (id) {
-                var res = ctx.poll(knownVersion, now);
-
-                if (res) {
-                    if (res["static"]) {
-                        if (!staticFeed)
-                            staticFeed = {};
-                        staticFeed[id] = res["static"];
-                    }
-                    if (res["live"])
-                        if (!liveFeed)
-                            liveFeed = {};
-                        for (var i in res["live"]) {
-                            liveFeed[i] = res["live"][i];
-                        }
-                    if (res["typing"]) {
-                        if (!allTyping)
-                            allTyping = {};
-                        for (var i in res["typing"])
-                            allTyping[i] = res["typing"][i];
-                    }
-                    v = Math.max(v, (res["v"] || 0));
-                    updated = true;
-                }
-            }
-        });
-        if (configFeed.config) {
-            v = Math.max(v, configFeed.v);
-            updated = true;
-        }
-        if (updated)
-            callback({
-                "live": liveFeed,
-                "static": staticFeed,
-                "config": configFeed.config || undefined,
-                "typing": allTyping,
-                "v": Math.max(v, knownVersion)
-            });
-        else
-            callback({
-                "v": knownVersion
-            });
-    }).bind(this), 2000);
-    if (checkConfigUpdate)
+    var _this = this;
+    if (checkConfigUpdate) {
         checkConfigUpdate(knownVersion, function(config) {
             if (config) {
                 var exposedConfig = [],
@@ -317,10 +326,28 @@ MultiChatManager.prototype.poll = function(knownVersion, callback, checkConfigUp
                     exposedConfig.push(conf.expose());
                     v = Math.max(v, conf.modified);
                 });
-                configFeed.config = exposedConfig;
-                configFeed.v = v;
+
+                var res = _this.pollPeriodical(knownVersion);
+                if (res) {
+                    res["config"] = exposedConfig;
+                    callback(res);
+                } else {
+                    callback({
+                        "config": exposedConfig,
+                        "v": v
+                    });
+                }
+            } else {
+                // FIXME start Polling now (actually some loop appens because of typing conception)
+                //_this.startPolling(knownVersion, reqT, callback);
+                setTimeout(function() { _this.startPolling(knownVersion, reqT, callback); }, 1000);
             }
         });
+    } else {
+        // FIXME start Polling now (actually some loop appens because of typing conception)
+        //_this.startPolling(knownVersion, reqT, callback);
+        setTimeout(function() { _this.startPolling(knownVersion, reqT, callback); }, 1000);
+    }
 };
 
 /** @suppress {undefinedVars,checkTypes} */