Bläddra i källkod

[bugfix] slack do not send last message any more, found a hacky work around :(
[bugfix] do not notify or mark unread when the unread message is mine
[bugfix] better handling of network issues

B Thibault 8 år sedan
förälder
incheckning
d4df3420d8
7 ändrade filer med 146 tillägg och 124 borttagningar
  1. 2 2
      cli/data.js
  2. 2 2
      cli/dom.js
  3. 0 8
      cli/workflow.js
  4. 97 97
      srv/public/mimouchat.min.js
  5. 1 1
      srv/src/room.js
  6. 30 12
      srv/src/slack.js
  7. 14 2
      srv/src/slackData.js

+ 2 - 2
cli/data.js

@@ -115,7 +115,7 @@ SlackWrapper.prototype.update = function(data) {
 
             if (chan) {
                 if (this.history[roomId].messages.length)
-                    chan.lastMsg = Math.max(chan.lastMsg, this.history[roomId].lastMessage().ts);
+                    chan.setLastMsg(this.history[roomId].lastMessage().ts, now);
                 if (!chan.archived) {
                     onMsgReceived(liveCtx, chan, data["live"][roomId]);
                     if (SELECTED_ROOM && data["live"][SELECTED_ROOM.id])
@@ -196,7 +196,7 @@ function onMsgReceived(ctx, chan, msg) {
             if (parseFloat(i["ts"]) <= chan.lastRead) {
                 return;
             }
-            if (i["userId"] !== ctx.self.id) {
+            if (i["user"] !== 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) {

+ 2 - 2
cli/dom.js

@@ -43,7 +43,7 @@ function createChanListItem(chan, alternateChanName) {
     link.textContent = alternateChanName || chan.name;
     dom.appendChild(createTypingDisplay());
     dom.appendChild(link);
-    if (chan.lastMsg > chan.lastRead) {
+    if (chan.lastMsg !== chan.lastRead && chan.lastMsg !== undefined) {
         dom.classList.add(R.klass.unread);
         if (HIGHLIGHTED_CHANS.indexOf(chan) >= 0)
             dom.classList.add(R.klass.unreadHi);
@@ -86,7 +86,7 @@ function createImsListItem(ims, alternateChanName) {
     if (SELECTED_ROOM === ims)
         dom.classList.add(R.klass.selected);
 
-    if (ims.lastMsg > ims.lastRead) {
+    if (ims.lastMsg !== ims.lastRead && ims.lastMsg !== undefined) {
         dom.classList.add(R.klass.unread);
         dom.classList.add(R.klass.unreadHi); // Always HI on private message
     }

+ 0 - 8
cli/workflow.js

@@ -86,14 +86,6 @@ function onConfigUpdated() {
 function poll(callback) {
     new HttpRequest("api?v=" +DATA.lastServerVersion)
         .callback(function(statusCode, statusText, resp) {
-            if (statusCode === 0) {
-                if (NEXT_RETRY) {
-                    NEXT_RETRY = 0;
-                    onNetworkStateUpdated(true);
-                }
-                poll(callback); // retry on timeout
-                return;
-            }
             var success = Math.floor(statusCode / 100) === 2;
 
             if (success) {

+ 97 - 97
srv/public/mimouchat.min.js

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

+ 1 - 1
srv/src/room.js

@@ -48,7 +48,7 @@ function Room(id) {
  * @param {number} t
 **/
 Room.prototype.setLastMsg = function(lastMsg, t) {
-    if (this.lastMsg < lastMsg) {
+    if (!this.lastMsg || this.lastMsg < lastMsg) {
         this.lastMsg = lastMsg;
         this.version = t;
         return true;

+ 30 - 12
srv/src/slack.js

@@ -39,6 +39,7 @@ const SLACK_ENDPOINT = "https://slack.com/api/"
         ,listMpims: "mpim.list"
         ,slashExec: "chat.command"
         ,addReaction: "reactions.add"
+        ,channelList: "users.counts"
         ,removeReaction: "reactions.remove"
         ,sendAction: "chat.attachmentAction"
         ,read: {
@@ -105,18 +106,35 @@ Slack.prototype.connect = function(cb) {
             console.error("Slack api responded " +status);
             cb && cb(_this);
         } else {
-            this.data = new SlackData(this);
-
-            _this.data.updateStatic({
-                team: body["team"],
-                users: body["users"],
-                bots: body["bots"],
-                self: body["self"],
-                channels: body["channels"],
-                groups: body["groups"]
-            }, Date.now());
-            _this.connectRtm(body.url);
-        }
+            httpsRequest(SLACK_ENDPOINT +GETAPI.channelList +"?mpim_aware=true" /*+"&include_threads=true"*/ +"&token=" +this.token, (status, channels) => {
+                if (!channels || !channels.ok) {
+                    _this.error = "Slack API error";
+                    _this.connected = false;
+                    console.error("Slack api responded " +status +" with body " +JSON.stringify(body));
+                    cb && cb(_this);
+                } else if (status !== 200) {
+                    _this.error = body.error;
+                    _this.connected = false;
+                    console.error("Slack api responded " +status);
+                    cb && cb(_this);
+                } else {
+                    this.data = new SlackData(this);
+
+                    // TODO deal with channels["threads"]
+                    _this.data.updateStatic({
+                        team: body["team"],
+                        users: body["users"],
+                        bots: body["bots"],
+                        self: body["self"],
+                        channels: channels["channels"],
+                        groups: channels["groups"],
+                        ims: channels["ims"],
+                        mpims: channels["mpims"]
+                    }, Date.now());
+                    _this.connectRtm(body.url);
+                }
+            });
+    }
     });
 };
 

+ 14 - 2
srv/src/slackData.js

@@ -83,8 +83,14 @@ SlackChan.prototype.setNameFromMembers = function() {
 SlackChan.prototype.update = function(chanData, ctx, t, idPrefix) {
     if (chanData["last_read"] !== undefined)
         chanData["last_read"] = parseFloat(chanData["last_read"]) * 1000;
-    if (chanData["latest"] !== undefined)
+    if (chanData["latest"])
         chanData["last_msg"] = parseFloat(chanData["latest"]) * 1000;
+    if (!chanData["last_msg"] && chanData["unread_count"] !== undefined) {
+        if (chanData["unread_count"])
+            chanData["last_msg"] = Math.max(chanData["last_msg"] || 0, 0);
+        else
+            chanData["last_msg"] = chanData["last_read"];
+    }
     return Room.prototype.update.call(this, chanData, ctx, t, idPrefix);
 };
 
@@ -112,8 +118,14 @@ SlackIms.prototype.constructor = SlackIms;
 SlackIms.prototype.update = function(chanData, ctx, t, idPrefix) {
     if (chanData["last_read"] !== undefined)
         chanData["last_read"] = parseFloat(chanData["last_read"]) * 1000;
-    if (chanData["latest"] !== undefined)
+    if (chanData["latest"])
         chanData["last_msg"] = parseFloat(chanData["latest"]) * 1000;
+    if (!chanData["last_msg"] && chanData["unread_count"] !== undefined) {
+        if (chanData["unread_count"])
+            chanData["last_msg"] = Math.max(chanData["last_msg"] || 0, 0);
+        else
+            chanData["last_msg"] = chanData["last_read"];
+    }
     return PrivateMessageRoom.prototype.update.call(this, chanData, ctx, t, idPrefix);
 };