فهرست منبع

[add] pending message id to manage pending messages
[add][wip] responsive design
[bugfix] decode URI params
[add] unfur uploaded images
[bugfix] keep starred messages on slack msg_changed event

B Thibault 8 سال پیش
والد
کامیت
baad99f715

+ 1 - 1
cli/data.js

@@ -226,7 +226,7 @@ function onMsgReceived(ctx, chan, msg) {
         if (!selfId || selfId === m.userId) {
             for (var i =0, nbPending = PENDING_MESSAGES.length; i < nbPending; i++) {
                 var current = PENDING_MESSAGES[i];
-                if (current.channel === chan.id && m["text"] && m["text"].trim() === current.text && !!m["isMeMessage"] === current.isMe) {
+                if (current.channel === chan.id && !!m["isMeMessage"] === current.isMe && ((m["pendingId"] === current.pendingId && current.pendingId) || (!current.pendingId && m["text"].trim() === current.text))) {
                     PENDING_MESSAGES.splice(i, 1);
                     return;
                 }

+ 2 - 2
cli/msgInput.js

@@ -216,8 +216,8 @@ function onTextEntered(input, skipCommand) {
         }
         return false;
     }
-    displayTmpMessage(SELECTED_ROOM, input, false);
-    sendMsg(SELECTED_ROOM, input, REPLYING_TO);
+    var tmpMsg = displayTmpMessage(SELECTED_ROOM, input, false);
+    sendMsg(SELECTED_ROOM, input, tmpMsg, REPLYING_TO);
     return true;
 }
 

+ 3 - 0
cli/resources.js

@@ -3,10 +3,12 @@ var R = {
         stylesheet: "customsheet",
         chanList: "chanList",
         context: "chatCtx",
+        contextButton: "chatCtxButton",
         chatList: "chatList",
         roomInfoPopin: "ctxRoomInfo",
         mainSection: "chatSystemContainer",
         currentRoom: {
+            header: "chatsystemHeader",
             title: "currentRoomTitle",
             starButton: "currentRoomStar",
             content: "chatWindow"
@@ -57,6 +59,7 @@ var R = {
     },
     klass: {
         selected: "selected",
+        opened: "opened",
         hidden: "hidden",
         button: "button",
         buttonContainer: "button-container",

+ 12 - 2
cli/ui.js

@@ -434,14 +434,16 @@ function onMsgClicked(target, msg) {
  * @param {boolean} isMeMessage
 **/
 function displayTmpMessage(channel, input, isMeMessage) {
-    PENDING_MESSAGES.push({
+    var obj = {
         channel: channel.id,
         text: input.trim(),
         isMe: isMeMessage,
         dom: createTmpMsgDom(input, isMeMessage)
-    });
+    };
+    PENDING_MESSAGES.push(obj);
     if (channel === SELECTED_ROOM)
         onRoomUpdated();
+    return obj;
 }
 
 function chatClickDelegate(e) {
@@ -587,6 +589,14 @@ document.addEventListener('DOMContentLoaded', function() {
         roomInfo.hideDelayed();
     });
 
+    document.getElementById(R.id.contextButton).addEventListener("click", function(e) {
+        var menu = document.getElementById(R.id.context);
+        if (menu.classList.contains(R.klass.opened))
+            menu.classList.remove(R.klass.opened);
+        else
+            menu.classList.add(R.klass.opened);
+    });
+
     document.getElementById(R.id.currentRoom.starButton).addEventListener("click", function(e) {
         e.preventDefault();
         if (SELECTED_ROOM) {

+ 9 - 3
cli/workflow.js

@@ -25,7 +25,7 @@ var
     /** @const @type {number} */
     KEEP_MESSAGES = 100,
 
-    /** @type {Array<{channel: string, text: string, isMe: boolean, dom: Element}>} */
+    /** @type {Array<{channel: string, text: string, isMe: boolean, pendingId: (string|undefined), dom: Element}>} */
     PENDING_MESSAGES = []
 ;
 
@@ -164,6 +164,7 @@ function selectRoom(room) {
     if (!DATA.history[SELECTED_ROOM.id] || DATA.history[SELECTED_ROOM.id].messages.length < KEEP_MESSAGES)
         fetchHistory(SELECTED_ROOM, function(success) {});
     document.getElementById(R.id.mainSection).classList.remove(R.klass.noRoomSelected);
+    document.getElementById(R.id.context).classList.remove(R.klass.opened);
 }
 
 function setRoomFromHashBang() {
@@ -256,9 +257,10 @@ function doCommand(chan, cmd, args) {
 /**
  * @param {Room} chan
  * @param {string} msg
+ * @param {Object=} pendingObj
  * @param {Message|null=} replyTo
 **/
-function sendMsg(chan, msg, replyTo) {
+function sendMsg(chan, msg, pendingObj, replyTo) {
     var url = 'api/msg?room=' +chan.id +"&text=" +encodeURIComponent(msg);
     if (replyTo) {
         var sender = DATA.context.getUser(replyTo.userId),
@@ -273,7 +275,11 @@ function sendMsg(chan, msg, replyTo) {
         };
         url += "&attachments=" +encodeURIComponent(JSON.stringify([attachment]));
     }
-    new HttpRequest(HttpRequestMethod.POST, url).send();
+    new HttpRequest(HttpRequestMethod.POST, url).setResponseType(HttpRequestResponseType.JSON).callbackSuccess(function(code, text, resp) {
+        if (resp && resp["pendingId"] !== undefined) {
+            pendingObj.pendingId = resp["pendingId"];
+        }
+    }).send();
 }
 
 /**

+ 123 - 121
srv/public/mimouchat.min.js

@@ -1,143 +1,145 @@
 "use strict";(function(){
-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.ob=a.desc;this.name=a.name;this.type=a.type;this.usage=a.usage;this.W=a.category}function ca(){this.a={};this.B=[];this.version=0}
+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.pb=a.desc;this.name=a.name;this.type=a.type;this.usage=a.usage;this.W=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.j={};this.i={};this.self=null;this.b={version:0,data:{}};this.h={version:0,data:{}};this.u={};this.aa={};this.o=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 h=a.i[d+b.users[e].id];h||(h=a.i[d+b.users[e].id]=new ga(b.users[e].id));h.update(b.users[e],c)}if(b.channels)for(e=0,f=b.channels.length;e<f;e++)(h=a.j[d+b.channels[e].id])||(h=a.j[d+b.channels[e].id]=ea(a,b.channels[e])),h.update(b.channels[e],a,c,d);b.emojis&&(a.b.data=b.emojis,a.b.version=c);if(void 0!==b.commands){a.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.aa={},b.capacities.forEach(function(a){this.aa[a]=!0},a));a.o=Math.max(a.o,c)}"undefined"!==typeof module&&(module.J.Db=da,module.J.Eb=aa,module.J.Gb=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}
+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.aa={},b.capacities.forEach(function(a){this.aa[a]=!0},a));a.o=Math.max(a.o,c)}"undefined"!==typeof module&&(module.J.Eb=da,module.J.Fb=aa,module.J.Hb=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 h=b.i[d+a.members[e]];this.i[h.id]=
-h;h.j[this.id]=this}a.topic&&(this.sa=a.topic.value,this.G=b.i[d+a.topic.creator],this.ea=a.topic.last_set);a.purpose&&(this.oa=a.purpose.value,this.o=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.ja(b,a.name),ma:c.ja(b,Object.values(a.i),function(a){return a?a.getName():null}),sa:c.ja(b,a.sa),oa:c.ja(b,a.oa)}}function t(a,b){v.call(this,a);this.a=b;this.name=b.getName();this.h=!0;b.O=this}t.prototype=Object.create(v.prototype);
-t.prototype.constructor=t;"undefined"!==typeof module&&(module.J.Mb=v,module.J.Lb=t);function w(a,b){this.K=a.user;this.username=a.username;this.id=a.id||a.ts;this.m=parseFloat(a.ts);this.text="";this.s=[];this.A=a.is_starred||!1;this.h=this.F=!1;this.D={};this.version=b;this.update(a,b)}function z(a,b){w.call(this,a,b)}function B(a,b){w.call(this,a,b)}
-w.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.kb=0;this.o=b;d&&la(this,d,e)}
+h;h.j[this.id]=this}a.topic&&(this.ta=a.topic.value,this.G=b.i[d+a.topic.creator],this.ea=a.topic.last_set);a.purpose&&(this.pa=a.purpose.value,this.o=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.ja(b,a.name),ma:c.ja(b,Object.values(a.i),function(a){return a?a.getName():null}),ta:c.ja(b,a.ta),pa:c.ja(b,a.pa)}}function t(a,b){v.call(this,a);this.a=b;this.name=b.getName();this.h=!0;b.O=this}t.prototype=Object.create(v.prototype);
+t.prototype.constructor=t;"undefined"!==typeof module&&(module.J.Nb=v,module.J.Mb=t);function w(a,b){this.K=a.user;this.username=a.username;this.id=a.id||a.ts;this.m=parseFloat(a.ts);this.text="";this.s=[];this.A=a.is_starred||!1;this.h=this.F=!1;this.D={};this.version=b;this.update(a,b)}function z(a,b){w.call(this,a,b)}function B(a,b){w.call(this,a,b)}
+w.prototype.update=function(a,b){if(a){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;if(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}a.pendingId&&(this.na=a.pendingId)}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.lb=0;this.o=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 w(a,b)};
 ka.prototype.push=function(a,b){for(var c,d=!1,e,f=0,h=this.a.length;f<h;f++)if(c=this.a[f],c.id===a.id){e=c.update(a,b);d=!0;break}d||(c=this.b(a,b),this.a.push(c),e=c.m);for(;this.a.length>this.o;)this.a.shift();if(this.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 na(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 ma(a){a.a.sort(function(a,c){return a.m-c.m})}z.prototype=Object.create(w.prototype);z.prototype.constructor=z;B.prototype=Object.create(w.prototype);B.prototype.constructor=B;"undefined"!==typeof module&&(module.J={Ib:w,Hb:z,Kb:B,Nb:ka});function ga(a){this.id=a;this.j={};this.O=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.Ua=a.deleted);void 0!==a.status&&(this.status=a.status);void 0!==a.goal&&(this.qb=a.goal);void 0!==a.phone&&(this.yb=a.phone);void 0!==a.first_name&&(this.Wa=a.first_name);void 0!==a.last_name&&(this.Za=a.last_name);void 0!==a.real_name&&(this.hb=a.real_name);void 0!==a.isPresent&&(this.N=a.isPresent);a.isBot&&(this.ub=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.hb||this.Wa||this.Za};"undefined"!==typeof module&&(module.J.Fb=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.j)if(!0===b(e.j[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].j[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].j[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].j,h;for(h in f)a&&!a(f[h],b.a[d],h)||c.push(h)}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}ra.prototype.Ba=function(a){for(var b=0,c=this.a.length;b<c;b++){var d=this.a[b];if(d.self&&d.self.id===a)return!0}return!1};
-"undefined"!==typeof module&&(module.J.Jb=ra);var ja=function(){function a(b,c,d){if(Array.isArray(c)){for(var e=0,f=0,h=c.length;f<h;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{ja:a}}();"undefined"!==typeof module&&(module.J.Ob=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={Cb:"Utilisateur inconnu",Bb:"Channel inconnu",ab:"Nouveau message",message:"Message",$a:"Reseau",bb:"(visible seulement par vous)",A:"Favoris",j:"Discutions",ma:"Membres",gb:"Discutions priv\u00e9es",ib:"Partage sa position GPS",ok:"Ok",Va:"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()},za: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","settings-displayEmojiProviderLbl":"Gestionnaire d'emojis","settings-displayDisplayAvatarLbl":"Afficher les avatars","settings-displayColorfulNamesLbl":"Afficher les nomes en couleur"}};G.fr.cb=function(a){return 0===a?"Pas de message \u00e9pingl\u00e9":a+(1===a?" message \u00e9pingl\u00e9":" messages \u00e9pingl\u00e9s")};
-G.fr.jb=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.Fa=function(a,b){return"par "+a.getName()+" le "+G.fr.R(b)};G.en={Cb:"Unknown member",Bb:"Unknown channel",ab:"New message",message:"Message",$a:"Network",bb:"(only visible to you)",A:"Starred",j:"Channels",ma:"Members",gb:"Direct messages",ib:"Share your GPS location",ok:"Ok",Va:"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()},za: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","settings-displayEmojiProviderLbl":"Emoji provider","settings-displayDisplayAvatarLbl":"Display avatars","settings-displayColorfulNamesLbl":"Colorful names"}};G.en.cb=function(a){return 0===a?"No pinned messages":a+(1===a?" pinned message":" pinned messages")};G.en.jb=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.Fa=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.Z=c;this.f=null;this.l=[];this.a=d||"";this.va="<"===this.a;this.Ea="*"===this.a;this.ua="_"===this.a;this.wa="~"===this.a||"-"===this.a;this.h=">"===this.a||"&gt;"===this.a;this.G=":"===this.a;this.Ga="`"===this.a;this.Ra="```"===this.a;this.Ha="\n"===this.a;this.ta=void 0!==d&&-1!==p.B.indexOf(d);this.g=b;this.xa=null;this.b=this.Ha||this.ta?c+d.length-1:!1;this.ta&&(this.f=new a(this),this.l.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||m;for(var c=0,e=a.l.length;c<e;c++){var f=
-a.l[c];if(f instanceof b)if(f.b){if(f=d(f))return f}else return f}return null}function e(a,c){a.g instanceof b&&(a.g.l.splice(a.g.l.indexOf(a)+(c?1:0)),a.g.f=a.g.l[a.g.l.length-1],e(a.g,!0))}function f(a){return a.replace("<","&lt;")}function h(a){return a}function k(a){return{link:a,text:a,Ya:!1}}var g,m,p={B:[],X:h,ra:h,la:k};b.prototype.Ja=function(){return this.Ea&&!!this.b||this.g instanceof b&&this.g.Ja()};b.prototype.Ma=function(){return this.ua&&!!this.b||this.g instanceof b&&this.g.Ma()};
-b.prototype.Na=function(){return this.wa&&!!this.b||this.g instanceof b&&this.g.Na()};b.prototype.ea=function(){return this.G&&!!this.b||this.g instanceof b&&this.g.ea()};b.prototype.La=function(){return this.ta&&!!this.b||this.g instanceof b&&this.g.La()};b.prototype.Ka=function(){return this.Ga&&!!this.b||this.g instanceof b&&this.g.Ka()};b.prototype.da=function(){return this.Ra&&!!this.b||this.g instanceof b&&this.g.da()};b.prototype.Oa=function(){for(var a=0,c=this.l.length;a<c;a++)if(this.l[a]instanceof
-b&&(!this.l[a].b||this.l[a].Oa()))return!0;return!1};b.prototype.Pa=function(a){if("<"===this.a&&">"===g[a])return!0;var b=c(g[a-1]);if(!this.h&&g.substr(a,this.a.length)===this.a){if(!b&&(this.Ea||this.ua||this.wa))return!1;if(this.f&&this.Oa())return this.f.Sa();if(this.lb())return!0}return"\n"===g[a]&&this.h?!0:!1};b.prototype.lb=function(){for(var a=this;a;){for(var c=0,d=a.l.length;c<d;c++)if(a.l[c]instanceof b||a.l[c].text.length)return!0;a=a.xa}return!1};b.prototype.Sa=function(){var a=new b(this.g,
-this.Z,this.a);a.xa=this;this.f&&this.f instanceof b&&(a.f=this.f.Sa(),a.l=[a.f]);return a};b.prototype.mb=function(a){return this.G&&(" "===g[a]||"\t"===g[a])||(this.G||this.va||this.Ea||this.ua||this.wa||this.Ga)&&"\n"===g[a]?!1:!0};b.prototype.nb=function(b){if(this.Ga||this.G||this.Ra||this.va)return null;if(!this.f||this.f.b||this.f instanceof a){var d=c(g[b-1]),e=c(g[b+1]);if("```"===g.substr(b,3))return"```";var f=m.Da();if(void 0===f||f){if("&gt;"===g.substr(b,4))return"&gt;";if(">"===g[b])return g[b]}if("`"===
-g[b]&&!d||"\n"===g[b]||!(-1===["*","~","-","_"].indexOf(g[b])||!e&&void 0!==g[b+1]&&-1==="*~-_<&".split("").indexOf(g[b+1])||d&&void 0!==g[b-1]&&-1==="*~-_<&".split("").indexOf(g[b-1]))||-1!==[":"].indexOf(g[b])&&e||-1!==["<"].indexOf(g[b]))return g[b];d=0;for(e=p.B.length;d<e;d++)if(f=p.B[d],g.substr(b,f.length)===f)return f}return null};a.prototype.Da=function(){if(""!==this.text.trim())return!1};b.prototype.Da=function(){for(var a=this.l.length-1;0<=a;a--){var b=this.l[a].Da();if(void 0!==b)return b}if(this.Ha||
-this.h)return!0};a.prototype.o=function(a){this.text+=g[a];return 1};b.prototype.o=function(c){var d=this.f&&!this.f.b&&this.f.Pa?this.f.Pa(c):null;if(d){var e=this.f.a.length;this.f.Ia(c);d instanceof b&&(this.f=d,this.l.push(d));return e}if(!this.f||this.f.b||this.f instanceof a||this.f.mb(c)){if(d=this.nb(c))return this.f=new b(this,c,d),this.l.push(this.f),this.f.a.length;if(!this.f||this.f.b)this.f=new a(this),this.l.push(this.f);return this.f.o(c)}d=this.f.Z+1;m.ba(this.f.Z);this.f=new a(this);
-this.f.o(d-1);this.l.pop();this.l.push(this.f);return d-c};b.prototype.Ia=function(a){for(var b=this;b;)b.b=a,b=b.xa};b.prototype.ba=function(a){this.b&&this.b>=a&&(this.b=!1);this.l.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=p.X(a);return b?b:a}return(a=p.X(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(u){console.error(u)}return this.text.replace(/\n/g,"<br/>")}return p.ra(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.Ka()?(b.push("code"),d=this.innerHTML()):(this.g.va&&(d=p.la(this.text))?
-(a="a",c=' href="'+d.link+'"',d.style&&(c+=' style="'+d.style+'"'),d.Ya||(c+=' target="_blank"'),d.Ta&&d.Ta.forEach(function(a){b.push(a)}),d=p.ra(d.text)):d=this.innerHTML(),this.g.Ja()&&b.push("bold"),this.g.Ma()&&b.push("italic"),this.g.Na()&&b.push("strike"),this.g.ea()&&b.push("emoji"),this.g.La()&&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.Ha&&(a+="<br/>");this.l.forEach(function(b){a+=
-b.outerHTML()});this.h&&(a+="</span>");return a};b.prototype.Qa=function(a){this.h&&!this.b&&this.Ia(a);this.l.forEach(function(c){c instanceof b&&c.Qa(a)})};return function(c,n){n||(n={});p.B=n.B||[];p.X=n.X||h;p.ra=n.ra||f;p.la=n.la||k;g=c;m=new b(this,0);n=0;c=g.length;do{for(;n<c;)n+=m.o(n);m.Qa(g.length);if(n=d()){e(n,!1);m.ba(n.Z);var l=new a(n.g);l.o(n.Z);n.g.l.push(l);n.g.f=l;n=n.Z+1}else n=void 0}while(void 0!==n);return m.outerHTML()}}();"undefined"!==typeof module&&(module.J.w=Aa);function K(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.o,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.o||(a.o=[]);a.o.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.title=a;this.content=b;this.c=Ia(this);this.b=Ja(this);this.a=[];this.h=[]}
-function Ia(a){var b=document.createElement("div"),c=document.createElement("header"),d=document.createElement("span"),e=document.createElement("span"),f=document.createElement("div"),h=document.createElement("footer");b.a=document.createElement("span");b.b=document.createElement("span");d.textContent=a.title;"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.Va;b.b.addEventListener("click",function(){Pa(a,!1)});e.addEventListener("click",function(){Pa(a,!1)});b.a.addEventListener("click",function(){Pa(a,!0)});h.appendChild(b.b);b.a.className=Oa;b.a.textContent=J.ok;h.appendChild(b.a);h.className=Qa+" "+Ra;b.appendChild(h);b.className=Sa;return b}function Pa(a,b){(b?a.a:a.h).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.pa=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.ob;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 ma(a){a.a.sort(function(a,c){return a.m-c.m})}z.prototype=Object.create(w.prototype);z.prototype.constructor=z;B.prototype=Object.create(w.prototype);B.prototype.constructor=B;"undefined"!==typeof module&&(module.J={Jb:w,Ib:z,Lb:B,Ob:ka});function ga(a){this.id=a;this.j={};this.O=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.Va=a.deleted);void 0!==a.status&&(this.status=a.status);void 0!==a.goal&&(this.rb=a.goal);void 0!==a.phone&&(this.zb=a.phone);void 0!==a.first_name&&(this.Xa=a.first_name);void 0!==a.last_name&&(this.$a=a.last_name);void 0!==a.real_name&&(this.ib=a.real_name);void 0!==a.isPresent&&(this.N=a.isPresent);a.isBot&&(this.vb=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.ib||this.Xa||this.$a};"undefined"!==typeof module&&(module.J.Gb=ga);function qa(){this.a=[]}qa.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.j)if(!0===b(e.j[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].j[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].j[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].j,h;for(h in f)a&&!a(f[h],b.a[d],h)||c.push(h)}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}qa.prototype.Ca=function(a){for(var b=0,c=this.a.length;b<c;b++){var d=this.a[b];if(d.self&&d.self.id===a)return!0}return!1};
+"undefined"!==typeof module&&(module.J.Kb=qa);var ja=function(){function a(b,c,d){if(Array.isArray(c)){for(var e=0,f=0,h=c.length;f<h;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{ja:a}}();"undefined"!==typeof module&&(module.J.Pb=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={Db:"Utilisateur inconnu",Cb:"Channel inconnu",bb:"Nouveau message",message:"Message",ab:"Reseau",cb:"(visible seulement par vous)",A:"Favoris",j:"Discutions",ma:"Membres",hb:"Discutions priv\u00e9es",jb:"Partage sa position GPS",ok:"Ok",Wa:"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()},Aa: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","settings-displayEmojiProviderLbl":"Gestionnaire d'emojis","settings-displayDisplayAvatarLbl":"Afficher les avatars","settings-displayColorfulNamesLbl":"Afficher les nomes en couleur"}};G.fr.eb=function(a){return 0===a?"Pas de message \u00e9pingl\u00e9":a+(1===a?" message \u00e9pingl\u00e9":" messages \u00e9pingl\u00e9s")};
+G.fr.kb=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.Ga=function(a,b){return"par "+a.getName()+" le "+G.fr.R(b)};G.en={Db:"Unknown member",Cb:"Unknown channel",bb:"New message",message:"Message",ab:"Network",cb:"(only visible to you)",A:"Starred",j:"Channels",ma:"Members",hb:"Direct messages",jb:"Share your GPS location",ok:"Ok",Wa:"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()},Aa: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","settings-displayEmojiProviderLbl":"Emoji provider","settings-displayDisplayAvatarLbl":"Display avatars","settings-displayColorfulNamesLbl":"Colorful names"}};G.en.eb=function(a){return 0===a?"No pinned messages":a+(1===a?" pinned message":" pinned messages")};G.en.kb=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.Ga=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.Z=c;this.f=null;this.l=[];this.a=d||"";this.wa="<"===this.a;this.Fa="*"===this.a;this.va="_"===this.a;this.xa="~"===this.a||"-"===this.a;this.h=">"===this.a||"&gt;"===this.a;this.G=":"===this.a;this.Ha="`"===this.a;this.Sa="```"===this.a;this.Ia="\n"===this.a;this.ua=void 0!==d&&-1!==p.B.indexOf(d);this.g=b;this.ya=null;this.b=this.Ia||this.ua?c+d.length-1:!1;this.ua&&(this.f=new a(this),this.l.push(this.f),this.f.text=d)}
+function c(a){return"A"<=a&&"Z">=a||"a"<=a&&"z">=a||"0"<=a&&"9">=a||-1!=="\u00e0\u00e8\u00ec\u00f2\u00f9\u00c0\u00c8\u00cc\u00d2\u00d9\u00e1\u00e9\u00ed\u00f3\u00fa\u00fd\u00c1\u00c9\u00cd\u00d3\u00da\u00dd\u00e2\u00ea\u00ee\u00f4\u00fb\u00c2\u00ca\u00ce\u00d4\u00db\u00e3\u00f1\u00f5\u00c3\u00d1\u00d5\u00e4\u00eb\u00ef\u00f6\u00fc\u00ff\u00c4\u00cb\u00cf\u00d6\u00dc\u0178\u00e7\u00c7\u00df\u00d8\u00f8\u00c5\u00e5\u00c6\u00e6\u0153+".indexOf(a)}function d(a){a=a||n;for(var c=0,e=a.l.length;c<e;c++){var f=
+a.l[c];if(f instanceof b)if(f.b){if(f=d(f))return f}else return f}return null}function e(a,c){a.g instanceof b&&(a.g.l.splice(a.g.l.indexOf(a)+(c?1:0)),a.g.f=a.g.l[a.g.l.length-1],e(a.g,!0))}function f(a){return a.replace("<","&lt;")}function h(a){return a}function k(a){return{link:a,text:a,Za:!1}}var g,n,p={B:[],X:h,sa:h,la:k};b.prototype.Ka=function(){return this.Fa&&!!this.b||this.g instanceof b&&this.g.Ka()};b.prototype.Na=function(){return this.va&&!!this.b||this.g instanceof b&&this.g.Na()};
+b.prototype.Oa=function(){return this.xa&&!!this.b||this.g instanceof b&&this.g.Oa()};b.prototype.ea=function(){return this.G&&!!this.b||this.g instanceof b&&this.g.ea()};b.prototype.Ma=function(){return this.ua&&!!this.b||this.g instanceof b&&this.g.Ma()};b.prototype.La=function(){return this.Ha&&!!this.b||this.g instanceof b&&this.g.La()};b.prototype.da=function(){return this.Sa&&!!this.b||this.g instanceof b&&this.g.da()};b.prototype.Pa=function(){for(var a=0,c=this.l.length;a<c;a++)if(this.l[a]instanceof
+b&&(!this.l[a].b||this.l[a].Pa()))return!0;return!1};b.prototype.Qa=function(a){if("<"===this.a&&">"===g[a])return!0;var b=c(g[a-1]);if(!this.h&&g.substr(a,this.a.length)===this.a){if(!b&&(this.Fa||this.va||this.xa))return!1;if(this.f&&this.Pa())return this.f.Ta();if(this.mb())return!0}return"\n"===g[a]&&this.h?!0:!1};b.prototype.mb=function(){for(var a=this;a;){for(var c=0,d=a.l.length;c<d;c++)if(a.l[c]instanceof b||a.l[c].text.length)return!0;a=a.ya}return!1};b.prototype.Ta=function(){var a=new b(this.g,
+this.Z,this.a);a.ya=this;this.f&&this.f instanceof b&&(a.f=this.f.Ta(),a.l=[a.f]);return a};b.prototype.nb=function(a){return this.G&&(" "===g[a]||"\t"===g[a])||(this.G||this.wa||this.Fa||this.va||this.xa||this.Ha)&&"\n"===g[a]?!1:!0};b.prototype.ob=function(b){if(this.Ha||this.G||this.Sa||this.wa)return null;if(!this.f||this.f.b||this.f instanceof a){var d=c(g[b-1]),e=c(g[b+1]);if("```"===g.substr(b,3))return"```";var f=n.Ea();if(void 0===f||f){if("&gt;"===g.substr(b,4))return"&gt;";if(">"===g[b])return g[b]}if("`"===
+g[b]&&!d||"\n"===g[b]||!(-1===["*","~","-","_"].indexOf(g[b])||!e&&void 0!==g[b+1]&&-1==="*~-_<&".split("").indexOf(g[b+1])||d&&void 0!==g[b-1]&&-1==="*~-_<&".split("").indexOf(g[b-1]))||-1!==[":"].indexOf(g[b])&&e||-1!==["<"].indexOf(g[b]))return g[b];d=0;for(e=p.B.length;d<e;d++)if(f=p.B[d],g.substr(b,f.length)===f)return f}return null};a.prototype.Ea=function(){if(""!==this.text.trim())return!1};b.prototype.Ea=function(){for(var a=this.l.length-1;0<=a;a--){var b=this.l[a].Ea();if(void 0!==b)return b}if(this.Ia||
+this.h)return!0};a.prototype.o=function(a){this.text+=g[a];return 1};b.prototype.o=function(c){var d=this.f&&!this.f.b&&this.f.Qa?this.f.Qa(c):null;if(d){var e=this.f.a.length;this.f.Ja(c);d instanceof b&&(this.f=d,this.l.push(d));return e}if(!this.f||this.f.b||this.f instanceof a||this.f.nb(c)){if(d=this.ob(c))return this.f=new b(this,c,d),this.l.push(this.f),this.f.a.length;if(!this.f||this.f.b)this.f=new a(this),this.l.push(this.f);return this.f.o(c)}d=this.f.Z+1;n.ba(this.f.Z);this.f=new a(this);
+this.f.o(d-1);this.l.pop();this.l.push(this.f);return d-c};b.prototype.Ja=function(a){for(var b=this;b;)b.b=a,b=b.ya};b.prototype.ba=function(a){this.b&&this.b>=a&&(this.b=!1);this.l.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=p.X(a);return b?b:a}return(a=p.X(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(u){console.error(u)}return this.text.replace(/\n/g,"<br/>")}return p.sa(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.La()?(b.push("code"),d=this.innerHTML()):(this.g.wa&&(d=p.la(this.text))?
+(a="a",c=' href="'+d.link+'"',d.style&&(c+=' style="'+d.style+'"'),d.Za||(c+=' target="_blank"'),d.Ua&&d.Ua.forEach(function(a){b.push(a)}),d=p.sa(d.text)):d=this.innerHTML(),this.g.Ka()&&b.push("bold"),this.g.Na()&&b.push("italic"),this.g.Oa()&&b.push("strike"),this.g.ea()&&b.push("emoji"),this.g.Ma()&&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.Ia&&(a+="<br/>");this.l.forEach(function(b){a+=
+b.outerHTML()});this.h&&(a+="</span>");return a};b.prototype.Ra=function(a){this.h&&!this.b&&this.Ja(a);this.l.forEach(function(c){c instanceof b&&c.Ra(a)})};return function(c,m){m||(m={});p.B=m.B||[];p.X=m.X||h;p.sa=m.sa||f;p.la=m.la||k;g=c;n=new b(this,0);m=0;c=g.length;do{for(;m<c;)m+=n.o(m);n.Ra(g.length);if(m=d()){e(m,!1);n.ba(m.Z);var l=new a(m.g);l.o(m.Z);m.g.l.push(l);m.g.f=l;m=m.Z+1}else m=void 0}while(void 0!==m);return n.outerHTML()}}();"undefined"!==typeof module&&(module.J.w=Aa);function K(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.o,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 N(a,b){a.o||(a.o=[]);a.o.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 O(a,b){a.a.open(a.method,a.G,!0);a.a.send(b)};function Ga(a,b){this.title=a;this.content=b;this.c=Ha(this);this.b=Ia(this);this.a=[];this.h=[]}
+function Ha(a){var b=document.createElement("div"),c=document.createElement("header"),d=document.createElement("span"),e=document.createElement("span"),f=document.createElement("div"),h=document.createElement("footer");b.a=document.createElement("span");b.b=document.createElement("span");d.textContent=a.title;"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.Wa;b.b.addEventListener("click",function(){Oa(a,!1)});e.addEventListener("click",function(){Oa(a,!1)});b.a.addEventListener("click",function(){Oa(a,!0)});h.appendChild(b.b);b.a.className=Na;b.a.textContent=J.ok;h.appendChild(b.a);h.className=Pa+" "+Qa;b.appendChild(h);b.className=Ra;return b}function Oa(a,b){(b?a.a:a.h).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.qa=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.pb;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 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,h=a.selectionEnd;f&&" "!==e[f-1];f--);for(b=e.length;h<b&&" "!==e[h];h++);if(f!==h&&0<h-f-1){if("#"===e[f]){var k=O.j;b=e.substr(f+1,h-f-1);for(var g in k)k[g].name.length>=b.length&&k[g].name.substr(0,b.length)===b&&d.push(k[g])}else if("@"===e[f])for(g in k=P instanceof t?O.i:P.i,b=e.substr(f+1,
-h-f-1),k){var m=k[g].getName();m.length>=b.length&&m.substr(0,b.length)===b&&d.push(k[g])}else if(":"===e[f]&&window.searchEmojis){b=e.substr(f+1,h-f-1);m=window.searchEmojis(b);for(k in m){var m=window.makeEmoji(k,!1),p=document.createElement("span");p.appendChild(m);p.className="emoji-small";d.push({name:":"+k+":",Aa:p,na:Za.name})}for(g in O.b.data)g.length>=b.length&&g.substr(0,b.length)===b&&(k=document.createElement("span"),k.className="emoji-small",k.appendChild($a(g)),d.push({name:":"+g+":",
-Aa:k,na:"custom"}))}d.length&&(c.dataset.cursor=JSON.stringify([f,h]))}}if(!d.length&&"/"===e[0]){g=e.indexOf(" ");f=-1!==g;g=-1===g?e.length:g;b=e.substr(0,g);f?(a=ab.Xa(b))&&d.push(a):(d=ab.pb(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,g)===b||f&&e.name===b)&&d.push(e);d.sort(function(a,b){return a.W.localeCompare(b.W)||a.name.localeCompare(b.name)})}c.textContent="";if(d.length){l=document.createDocumentFragment();g=0;for(a=
-d.length;g<a;g++)if(e=d[g],e instanceof ga){if(!n){var n=!0;l.appendChild(Wa(J.ma))}b=document.createElement("span");b.className="chat-command-userIcon";b.style.backgroundImage='url("'+pa(e)+'")';l.appendChild(Xa("@"+e.getName(),b))}else e instanceof v?(n||(n=!0,l.appendChild(Wa(J.j))),l.appendChild(Xa("#"+e.name))):e.Aa?(n!==e.na&&(n=e.na,l.appendChild(Wa(e.na))),l.appendChild(Xa(e.name,e.Aa))):(n!==e.W&&(n=e.W,l.appendChild(Wa(e.W))),l.appendChild(Xa(e)));c.appendChild(l)}}
-function bb(a){if(Q)return N(new K("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.Xa(c);if(d)return a=a.trim(),d.exec(b,P,a),!0;if(b&&(c=b.h.data[c])){if("/me"===c.name)cb(P,a,!0);else if("/msg"===c.name){a=a.trim();var b=/(\S+)\s+(.*)/.exec(a);a:{var e=b[1],d=O,f=e,h=[];"#"===f[0]&&(f=f.substr(1));for(var k in d.j)d.j[k].name===f&&h.push(d.j[k]);if(h.length)var g=h[0];
-else{k=[];"@"===e[0]&&(e=e.substr(1));for(g in d.i)d.i[g].getName()===e&&k.push(d.j[g]);if(k.length)for(g=0,d=k.length;g<d;g++)if(k[g].O){g=k[g].O;break a}g=null}}g&&cb(g,b[2],!1)}N(new K("POST","api/cmd?room="+P.id+"&cmd="+encodeURIComponent(c.name.substr(1))+"&args="+encodeURIComponent(a)));return!0}return!1}cb(P,a,!1);db(P,a,R);return!0}function S(){document.getElementById("msgInput").focus()}
-function eb(){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 K("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?(b=this.selectionStart,
-this.value=this.value.substr(0,b)+"\n"+this.value.substr(this.selectionEnd),a(this),this.selectionStart=this.selectionEnd=b+1):fb(),!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 gb=[],hb=0;
-function ib(){var a=document.createDocumentFragment(),b=xa(function(a){return!a.fa&&!1!==a.ba}),c=[],d=[],e=[],f=[],h={};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.j[a];b=d.j[b];return a.name===b.name?(h[a.id]=J.za(c.a.name,a.name),h[b.id]=J.za(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.Ua){var k=h[a.id];b=document.createElement("li");var p=document.createElement("a");
-b.id="room_"+a.id;p.href="#"+a.id;b.className="chat-context-room chat-ims presence-indicator";p.textContent=k||a.a.getName();b.appendChild(jb());b.appendChild(p);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=h[a.id],b=document.createElement("li"),p=document.createElement("a"),b.id="room_"+a.id,p.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"),p.textContent=k||a.name,b.appendChild(jb()),b.appendChild(p),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(kb(J.A));c.forEach(function(b){a.appendChild(b)});d.length&&a.appendChild(kb(J.j));d.forEach(function(b){a.appendChild(b)});e.forEach(function(b){a.appendChild(b)});
-f.length&&a.appendChild(kb(J.gb));f.forEach(function(b){a.appendChild(b)});document.getElementById("chanList").textContent="";document.getElementById("chanList").appendChild(a);lb.apply(document.getElementById("chanSearch"));mb();nb();O&&ob(O.a.id,O.i,function(a){document.getElementById("chatCtx").style.backgroundImage="url("+a+")"})}
-function pb(){va(function(a){var b=a.u,c;for(c in a.self.j)if(!a.self.j[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].O)&&!c.fa&&(d=document.getElementById("room_"+c.id))&&(b[c.id]?d.classList.add("chat-context-typing"):d.classList.remove("chat-context-typing"))});qb()}
-function qb(){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(rb(a)):c=!0;c&&(C.b=0);document.getElementById("whoistyping").appendChild(b)}}function sb(a){a?document.body.classList.remove("no-network"):document.body.classList.add("no-network");nb()}
-function tb(){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;U();S();document.getElementById("fileUploadContainer").classList.add("hidden");ub();R&&(R=null,V());Q&&(Q=null,V());nb();qb()}
-function V(){if(R){document.body.classList.add("replyingTo");var a=document.getElementById("replyToContainer"),b=document.createElement("a");b.addEventListener("click",function(){R=null;V()});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=oa(d,b))&&(f=D(C.context,a))&&(e.D[c]&&-1!==e.D[c].indexOf(f.self.id)?N(new K("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 nb(){var a=T.length,b="";if(W)b="!"+J.$a+" - 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(hb+3E4<a){var b=new Notification(J.ab);hb=a;setTimeout(function(){b.close()},5E3)}}else"denied"!==Notification.permission&&Notification.requestPermission()}
-function U(){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");gb=[];C.a[b]&&C.a[b].a.forEach(function(b){if(b.h)b.Y();else{var g=b.M(),h=!1;c&&c.K===b.K&&b.K?30>Math.abs(d-b.m)&&!(b instanceof z)?e.classList.add("chatmsg-same-ts"):d=b.m:(d=b.m,h=!0);(!c||c.m<=P.C)&&b.m>P.C?g.classList.add("chatmsg-first-unread"):g.classList.remove("chatmsg-first-unread");
-if(b instanceof z)e=c=null,d=0,a.appendChild(g),f=null;else{if(h||!f)f=zb(F(b.K),b.username),gb.push(f),a.appendChild(f);c=b;e=g;f.content.appendChild(g)}}});var h=!0;Ab.forEach(function(b){b.channel===P.id&&(h&&(f=zb(O.self,""),a.appendChild(f),h=!1),f.content.appendChild(b.c))});b=document.getElementById("chatWindow");b.textContent="";b.appendChild(a);b.scrollTop=b.scrollHeight-b.clientHeight;Bb();window.hasFocus&&ub()}
-function Cb(a,b){if(a.classList.contains("chatmsg-hover-reply"))Q&&(Q=null,vb()),R!==b&&(R=b,V());else if(a.classList.contains("chatmsg-hover-reaction")){var c=P.id,d=b.id;Db.pa(document.body,O,function(a){a&&wb(c,d,a)})}else a.classList.contains("chatmsg-hover-edit")?(R&&(R=null,V()),Q!==b&&(Q=b,vb())):a.classList.contains("chatmsg-hover-star")?b.A?N(new K("DELETE","api/starMsg?room="+P.id+"&msgId="+b.id)):N(new K("POST","api/starMsg?room="+P.id+"&msgId="+b.id)):a.classList.contains("chatmsg-hover-pin")?
-b.pinned?Eb(P,b):N(new K("POST","api/pinMsg?room="+P.id+"&msgId="+b.id)):a.classList.contains("chatmsg-hover-remove")&&(R&&(R=null,V()),Q&&(Q=null,vb()),N(new K("DELETE","api/msg?room="+P.id+"&ts="+b.id)))}function cb(a,b,c){Ab.push({channel:a.id,text:b.trim(),Ba:c,c:Fb(b,c)});a===P&&U()}
-function Gb(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]&&
-Hb(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))&&Cb(c,a);break}c=c.parentElement}}
-function Hb(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},h=new K("POST","api/attachmentAction?serviceId="+a.K);N(h,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).pa():d()}
-function Bb(){if(!1!==X.a){var a=document.getElementById("chatWindow").getBoundingClientRect().top;gb.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();Ib();eb();var a=document.getElementById("chanSearch");a.addEventListener("input",lb);a.addEventListener("blur",lb);document.getElementById("chatWindow").addEventListener("click",Gb);window.addEventListener("hashchange",function(){document.location.hash&&"#"===document.location.hash[0]&&mb()});document.addEventListener("mouseover",function(a){a=a.target;if(Jb.vb(a))Jb.$();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)){Jb.eb(d,d.j[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].O)){Jb.eb(d,b).show(a);return}}}a=a.parentElement}Jb.sb()}});document.getElementById("currentRoomStar").addEventListener("click",function(a){a.preventDefault();P&&(P.A?N(new K("POST","api/unstarChannel?room="+P.id)):N(new K("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",Kb);document.getElementById("ctxMenuSettings").addEventListener("click",function(a){a.preventDefault();Lb.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),Mb(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();fb();return!1});document.getElementById("msgForm").addEventListener("submit",function(a){a.preventDefault();fb();return!1});window.addEventListener("blur",function(){window.hasFocus=!1});window.addEventListener("focus",function(){window.hasFocus=!0;hb=0;P&&ub();S()});document.getElementById("chatWindow").addEventListener("scroll",Bb);window.hasFocus=!0;document.getElementById("emojiButton").addEventListener("click",
-function(){O&&Db.pa(document.body,O,function(a){a&&(document.getElementById("msgInput").value+=":"+a+":");S()})});Nb()});function fb(){var a=document.getElementById("msgInput");P&&a.value&&bb(a.value)&&(a.value="",R&&(R=null,V()),Q&&(Q=null,V()),document.getElementById("slashList").textContent="");S()};var Lb=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={U:"services",
-display:"display",Pb:"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");
+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,h=a.selectionEnd;f&&" "!==e[f-1];f--);for(b=e.length;h<b&&" "!==e[h];h++);if(f!==h&&0<h-f-1){if("#"===e[f]){var k=P.j;b=e.substr(f+1,h-f-1);for(var g in k)k[g].name.length>=b.length&&k[g].name.substr(0,b.length)===b&&d.push(k[g])}else if("@"===e[f])for(g in k=Q instanceof t?P.i:Q.i,b=e.substr(f+1,
+h-f-1),k){var n=k[g].getName();n.length>=b.length&&n.substr(0,b.length)===b&&d.push(k[g])}else if(":"===e[f]&&window.searchEmojis){b=e.substr(f+1,h-f-1);n=window.searchEmojis(b);for(k in n){var n=window.makeEmoji(k,!1),p=document.createElement("span");p.appendChild(n);p.className="emoji-small";d.push({name:":"+k+":",Ba:p,oa:Ya.name})}for(g in P.b.data)g.length>=b.length&&g.substr(0,b.length)===b&&(k=document.createElement("span"),k.className="emoji-small",k.appendChild(Za(g)),d.push({name:":"+g+":",
+Ba:k,oa:"custom"}))}d.length&&(c.dataset.cursor=JSON.stringify([f,h]))}}if(!d.length&&"/"===e[0]){g=e.indexOf(" ");f=-1!==g;g=-1===g?e.length:g;b=e.substr(0,g);f?(a=$a.Ya(b))&&d.push(a):(d=$a.qb(b),c.dataset.cursor=JSON.stringify([0,a.selectionEnd]));a=P?P.h.data:{};for(var l in a)e=a[l],(!f&&e.name.substr(0,g)===b||f&&e.name===b)&&d.push(e);d.sort(function(a,b){return a.W.localeCompare(b.W)||a.name.localeCompare(b.name)})}c.textContent="";if(d.length){l=document.createDocumentFragment();g=0;for(a=
+d.length;g<a;g++)if(e=d[g],e instanceof ga){if(!m){var m=!0;l.appendChild(Va(J.ma))}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?(m||(m=!0,l.appendChild(Va(J.j))),l.appendChild(Wa("#"+e.name))):e.Ba?(m!==e.oa&&(m=e.oa,l.appendChild(Va(e.oa))),l.appendChild(Wa(e.name,e.Ba))):(m!==e.W&&(m=e.W,l.appendChild(Va(e.W))),l.appendChild(Wa(e)));c.appendChild(l)}}
+function ab(a){if(R)return O(new K("PUT","api/msg?room="+Q.id+"&ts="+R.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=P,d=$a.Ya(c);if(d)return a=a.trim(),d.exec(b,Q,a),!0;if(b&&(c=b.h.data[c])){if("/me"===c.name)bb(Q,a,!0);else if("/msg"===c.name){a=a.trim();var b=/(\S+)\s+(.*)/.exec(a);a:{var e=b[1],d=P,f=e,h=[];"#"===f[0]&&(f=f.substr(1));for(var k in d.j)d.j[k].name===f&&h.push(d.j[k]);if(h.length)var g=h[0];
+else{k=[];"@"===e[0]&&(e=e.substr(1));for(g in d.i)d.i[g].getName()===e&&k.push(d.j[g]);if(k.length)for(g=0,d=k.length;g<d;g++)if(k[g].O){g=k[g].O;break a}g=null}}g&&bb(g,b[2],!1)}O(new K("POST","api/cmd?room="+Q.id+"&cmd="+encodeURIComponent(c.name.substr(1))+"&args="+encodeURIComponent(a)));return!0}return!1}g=bb(Q,a,!1);cb(Q,a,g,S);return!0}function T(){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(Q){var c=Date.now();b+3E3<c&&(P.self.N||Q instanceof t)&&(O(new K("POST","api/typing?room="+Q.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?(b=this.selectionStart,
+this.value=this.value.substr(0,b)+"\n"+this.value.substr(this.selectionEnd),a(this),this.selectionStart=this.selectionEnd=b+1):eb(),!1});document.getElementById("slashList").addEventListener("click",function(a){if(Q){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 fb=[],gb=0;
+function hb(){var a=document.createDocumentFragment(),b=xa(function(a){return!a.fa&&!1!==a.ba}),c=[],d=[],e=[],f=[],h={};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.j[a];b=d.j[b];return a.name===b.name?(h[a.id]=J.Aa(c.a.name,a.name),h[b.id]=J.Aa(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.Va){var k=h[a.id];b=document.createElement("li");var p=document.createElement("a");
+b.id="room_"+a.id;p.href="#"+a.id;b.className="chat-context-room chat-ims presence-indicator";p.textContent=k||a.a.getName();b.appendChild(ib());b.appendChild(p);a.a.N||b.classList.add("presence-away");Q===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=h[a.id],b=document.createElement("li"),p=document.createElement("a"),b.id="room_"+a.id,p.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",Q===a&&b.classList.add("selected"),p.textContent=k||a.name,b.appendChild(ib()),b.appendChild(p),a.I!==a.C&&void 0!==a.I&&(b.classList.add("unread"),0<=U.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.j));d.forEach(function(b){a.appendChild(b)});e.forEach(function(b){a.appendChild(b)});
+f.length&&a.appendChild(jb(J.hb));f.forEach(function(b){a.appendChild(b)});document.getElementById("chanList").textContent="";document.getElementById("chanList").appendChild(a);kb.apply(document.getElementById("chanSearch"));lb();mb();P&&nb(P.a.id,P.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.j)if(!a.self.j[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].O)&&!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(P&&Q&&(a=P.u[Q.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=Q.name||(Q.a?Q.a.getName():void 0);if(!a){console.error("No name provided for ",Q);var a=[],b;for(b in Q.i)a.push(Q.i[b].getName());a=a.join(", ")}document.getElementById("currentRoomTitle").textContent=a;tb();T();document.getElementById("fileUploadContainer").classList.add("hidden");ub();S&&(S=null,V());R&&(R=null,V());mb();pb()}
+function V(){if(S){document.body.classList.add("replyingTo");var a=document.getElementById("replyToContainer"),b=document.createElement("a");b.addEventListener("click",function(){S=null;V()});b.className="replyto-close";b.textContent="x";a.textContent="";a.appendChild(b);a.appendChild(S.L())}else document.body.classList.remove("replyingTo"),document.getElementById("replyToContainer").textContent="";T()}
+function vb(){if(R){document.body.classList.add("replyingTo");var a=document.getElementById("replyToContainer"),b=document.createElement("a");b.addEventListener("click",function(){R=null;vb()});b.className="replyto-close";b.textContent="x";a.textContent="";a.appendChild(b);a.appendChild(R.L());document.getElementById("msgInput").value=R.text}else document.body.classList.remove("replyingTo"),document.getElementById("replyToContainer").textContent="";T()}
+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)?O(new K("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=U.length,b="";if(W)b="!"+J.ab+" - 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&&Q&&(b=Q.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.bb);gb=a;setTimeout(function(){b.close()},5E3)}}else"denied"!==Notification.permission&&Notification.requestPermission()}
+function tb(){var a=document.createDocumentFragment(),b=Q.id,c=null,d=0,e=null,f;Q.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.Y();else{var h=b.M(),k=!1;c&&c.K===b.K&&b.K?30>Math.abs(d-b.m)&&!(b instanceof z)?e.classList.add("chatmsg-same-ts"):d=b.m:(d=b.m,k=!0);(!c||c.m<=Q.C)&&b.m>Q.C?h.classList.add("chatmsg-first-unread"):h.classList.remove("chatmsg-first-unread");
+if(b instanceof z)e=c=null,d=0,a.appendChild(h),f=null;else{if(k||!f)f=zb(F(b.K),b.username),fb.push(f),a.appendChild(f);c=b;e=h;f.content.appendChild(h)}}});var h=!0;Ab.forEach(function(b){b.channel===Q.id&&(h&&(f=zb(P.self,""),a.appendChild(f),h=!1),f.content.appendChild(b.c))});b=document.getElementById("chatWindow");b.textContent="";b.appendChild(a);b.scrollTop=b.scrollHeight-b.clientHeight;Bb();window.hasFocus&&ub()}
+function Cb(a,b){if(a.classList.contains("chatmsg-hover-reply"))R&&(R=null,vb()),S!==b&&(S=b,V());else if(a.classList.contains("chatmsg-hover-reaction")){var c=Q.id,d=b.id;Db.qa(document.body,P,function(a){a&&wb(c,d,a)})}else a.classList.contains("chatmsg-hover-edit")?(S&&(S=null,V()),R!==b&&(R=b,vb())):a.classList.contains("chatmsg-hover-star")?b.A?O(new K("DELETE","api/starMsg?room="+Q.id+"&msgId="+b.id)):O(new K("POST","api/starMsg?room="+Q.id+"&msgId="+b.id)):a.classList.contains("chatmsg-hover-pin")?
+b.pinned?Eb(Q,b):O(new K("POST","api/pinMsg?room="+Q.id+"&msgId="+b.id)):a.classList.contains("chatmsg-hover-remove")&&(S&&(S=null,V()),R&&(R=null,vb()),O(new K("DELETE","api/msg?room="+Q.id+"&ts="+b.id)))}function bb(a,b,c){b={channel:a.id,text:b.trim(),Ca:c,c:Fb(b,c)};Ab.push(b);a===Q&&tb();return b}
+function Gb(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[Q.id],d))&&a.s[e]&&a.s[e].actions&&a.s[e].actions[f]&&
+Hb(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[Q.id],d))&&Cb(c,a);break}c=c.parentElement}}
+function Hb(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},h=new K("POST","api/attachmentAction?serviceId="+a.K);O(h,JSON.stringify(d))}var e=Q.id;c.confirm?Ua(Ta(new Ga(c.confirm.title,c.confirm.text),c.confirm.ok_text,c.confirm.dismiss_text),d).qa():d()}
+function Bb(){if(!1!==X.a){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();Ib();db();var a=document.getElementById("chanSearch");a.addEventListener("input",kb);a.addEventListener("blur",kb);document.getElementById("chatWindow").addEventListener("click",Gb);window.addEventListener("hashchange",function(){document.location.hash&&"#"===document.location.hash[0]&&lb()});document.addEventListener("mouseover",function(a){a=a.target;if(Jb.wb(a))Jb.$();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)){Jb.fb(d,d.j[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].O)){Jb.fb(d,b).show(a);return}}}a=a.parentElement}Jb.tb()}});document.getElementById("chatCtxButton").addEventListener("click",function(){var a=document.getElementById("chatCtx");a.classList.contains("opened")?a.classList.remove("opened"):a.classList.add("opened")});document.getElementById("currentRoomStar").addEventListener("click",
+function(a){a.preventDefault();Q&&(Q.A?O(new K("POST","api/unstarChannel?room="+Q.id)):O(new K("POST","api/starChannel?room="+Q.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",
+Kb);document.getElementById("ctxMenuSettings").addEventListener("click",function(a){a.preventDefault();Lb.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),Mb(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();Q&&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;Q&&ub();T()});document.getElementById("chatWindow").addEventListener("scroll",Bb);window.hasFocus=!0;document.getElementById("emojiButton").addEventListener("click",function(){P&&Db.qa(document.body,P,function(a){a&&(document.getElementById("msgInput").value+=":"+a+":");T()})});Nb()});
+function eb(){var a=document.getElementById("msgInput");Q&&a.value&&ab(a.value)&&(a.value="",S&&(S=null,V()),R&&(R=null,V()),document.getElementById("slashList").textContent="");T()};var Lb=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={U:"services",
+display:"display",Qb:"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(){var b={};document.getElementById("settings-displayEmojiProvider").value!==X.h&&(b.emojiProvider=document.getElementById("settings-displayEmojiProvider").value);var c=!!document.getElementById("settings-displayDisplayAvatar").checked;
-c!==(!1!==X.a)&&(b.displayAvatar=c);c=!!document.getElementById("settings-displayColorfulNames").checked;c!==(!0===X.b)&&(b.colorfulNames=c);var c=X,d;for(d in b){Ob(c,b);Pb();N(new K("POST","api/settings?service=null&device=null"),JSON.stringify(b));break}a()});return{display:function(a){if(!c){document.getElementById("settings").classList.remove("hidden");var d=document.createDocumentFragment(),f=!1,g;for(g in X.U){var m=X.U[g];for(n in m){var f=document.createElement("li"),p=document.createElement("span"),
-l=document.createElement("span");p.textContent=g;l.textContent=m[n];f.className="settings-service-list-item";p.className="settings-service-list-item-provider";l.className="settings-service-list-item-service";f.appendChild(p);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(g in Qb){var n=document.createElement("option");n.value=g;n.textContent=Qb[g].name;Qb[g]===Za&&(n.selected=!0);d.appendChild(n)}m.textContent="";m.appendChild(d);document.getElementById("settings-displayDisplayAvatar").checked=!1!==X.a;document.getElementById("settings-displayColorfulNames").checked=!0===X.b;c=!0}b(a||e.U);return this},Ab:function(){return this},xb:e}}();function Rb(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"),h=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)))},g=function(a,d,e,g){h.fillStyle="#808080";h.fillRect(0,0,300,300);f.fillStyle="#808080";f.fillRect(0,0,300,300);var p=Math.pow(2,a),n=(e+180)/360*p,m=(1-Math.log(Math.tan(d*Math.PI/180)+1/Math.cos(d*Math.PI/180))/Math.PI)/2*p,l=Math.floor(n),L=Math.floor(m),
-qa=g?100*g/k(180/Math.PI*Math.atan(.5*(Math.exp(Math.PI-2*Math.PI*L/p)-Math.exp(-(Math.PI-2*Math.PI*L/p)))),l/p*360-180,(l+1)/p*360-180):0;d=b;for(e=0;3>e;e++)for(g=0;3>g;g++)c(a,l+e-1,L+g-1,{tb:e,wb:g,kb:d}).then(function(a){if(a.kb===b){h.drawImage(a.S,100*a.tb,100*a.wb,100,100);a=n-l;var c=m-L;a=100*a+100;c=100*c+100;f.putImageData(h.getImageData(0,0,300,300),0,0);void 0!==qa&&(f.beginPath(),f.arc(a,c,Math.max(qa,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===qa||25<qa)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,p=function(c){c=Math.max(4,Math.min(19,c));m!==c&&(b++,m=c,g(m,Number(a.latitude),Number(a.longitude),Number(a.accuracy)))};p(12);var e=document.createElement("div"),l=document.createElement("div"),n=document.createElement("button"),u=document.createElement("button");e.className=
-"OSM-wrapper";d.className="OSM-canvas";l.className="OSM-controls";u.className="OSM-controls-zoomMin";n.className="OSM-controls-zoomPlus";u.addEventListener("click",function(){p(m-1)});n.addEventListener("click",function(){p(m+1)});l.appendChild(u);l.appendChild(n);e.appendChild(d);e.appendChild(l);return e}};function jb(){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 kb=function(){var a={};return function(b){var c=a[b];c||(c=a[b]=document.createElement("header"),c.textContent=b);return c}}();
-function Sb(a){var b={},c=a;if(O)for(var d=O;!b[a];){var e=d.b.data[a];if(e)if("alias:"==e.substr(0,6))b[a]=!0,a=e.substr(6);else return a=document.createElement("span"),a.className="emoji-custom emoji",a.style.backgroundImage="url('"+e+"')",a.textContent=":"+c+":",a.title=c,a;else return a}return c}function $a(a){return"makeEmoji"in window?(a=Sb(a),"string"===typeof a&&(a=window.makeEmoji(a)),"string"===typeof a?null:a):null}
-function Tb(a){var b=document.createElement("div"),c=document.createElement("div");b.ca=document.createElement("ul");b.s=document.createElement("ul");b.D=document.createElement("ul");b.m=document.createElement("div");b.qa=document.createElement("div");b.ha=document.createElement("span");b.className="chatmsg-item";b.m.className="chatmsg-ts";b.qa.className="chatmsg-msg";b.ha.className="chatmsg-author-name";if(a){b.id=a.b+"_"+a.id;var d=b.ca,e=a.context.aa;a=C.context.Ba(a.K);if(e.replyToMsg){var f=
+c!==(!1!==X.a)&&(b.displayAvatar=c);c=!!document.getElementById("settings-displayColorfulNames").checked;c!==(!0===X.b)&&(b.colorfulNames=c);var c=X,d;for(d in b){Ob(c,b);Pb();O(new K("POST","api/settings?service=null&device=null"),JSON.stringify(b));break}a()});return{display:function(a){if(!c){document.getElementById("settings").classList.remove("hidden");var d=document.createDocumentFragment(),f=!1,g;for(g in X.U){var n=X.U[g];for(m in n){var f=document.createElement("li"),p=document.createElement("span"),
+l=document.createElement("span");p.textContent=g;l.textContent=n[m];f.className="settings-service-list-item";p.className="settings-service-list-item-provider";l.className="settings-service-list-item-service";f.appendChild(p);f.appendChild(l);d.appendChild(f);f=!0}}n=document.getElementById("settings-serviceList");n.textContent="";f?(document.getElementById("settings-serviceListEmpty").classList.remove("hidden"),n.appendChild(d)):document.getElementById("settings-serviceListEmpty").classList.add("hidden");
+d=document.createDocumentFragment();n=document.getElementById("settings-displayEmojiProvider");for(g in Qb){var m=document.createElement("option");m.value=g;m.textContent=Qb[g].name;Qb[g]===Ya&&(m.selected=!0);d.appendChild(m)}n.textContent="";n.appendChild(d);document.getElementById("settings-displayDisplayAvatar").checked=!1!==X.a;document.getElementById("settings-displayColorfulNames").checked=!0===X.b;c=!0}b(a||e.U);return this},Bb:function(){return this},yb:e}}();function Rb(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"),h=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)))},g=function(a,d,e,g){h.fillStyle="#808080";h.fillRect(0,0,300,300);f.fillStyle="#808080";f.fillRect(0,0,300,300);var p=Math.pow(2,a),m=(e+180)/360*p,n=(1-Math.log(Math.tan(d*Math.PI/180)+1/Math.cos(d*Math.PI/180))/Math.PI)/2*p,l=Math.floor(m),L=Math.floor(n),
+ra=g?100*g/k(180/Math.PI*Math.atan(.5*(Math.exp(Math.PI-2*Math.PI*L/p)-Math.exp(-(Math.PI-2*Math.PI*L/p)))),l/p*360-180,(l+1)/p*360-180):0;d=b;for(e=0;3>e;e++)for(g=0;3>g;g++)c(a,l+e-1,L+g-1,{ub:e,xb:g,lb:d}).then(function(a){if(a.lb===b){h.drawImage(a.S,100*a.ub,100*a.xb,100,100);a=m-l;var c=n-L;a=100*a+100;c=100*c+100;f.putImageData(h.getImageData(0,0,300,300),0,0);void 0!==ra&&(f.beginPath(),f.arc(a,c,Math.max(ra,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===ra||25<ra)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()}})},n,p=function(c){c=Math.max(4,Math.min(19,c));n!==c&&(b++,n=c,g(n,Number(a.latitude),Number(a.longitude),Number(a.accuracy)))};p(12);var e=document.createElement("div"),l=document.createElement("div"),m=document.createElement("button"),u=document.createElement("button");e.className=
+"OSM-wrapper";d.className="OSM-canvas";l.className="OSM-controls";u.className="OSM-controls-zoomMin";m.className="OSM-controls-zoomPlus";u.addEventListener("click",function(){p(n-1)});m.addEventListener("click",function(){p(n+1)});l.appendChild(u);l.appendChild(m);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 Sb(a){var b={},c=a;if(P)for(var d=P;!b[a];){var e=d.b.data[a];if(e)if("alias:"==e.substr(0,6))b[a]=!0,a=e.substr(6);else return a=document.createElement("span"),a.className="emoji-custom emoji",a.style.backgroundImage="url('"+e+"')",a.textContent=":"+c+":",a.title=c,a;else return a}return c}function Za(a){return"makeEmoji"in window?(a=Sb(a),"string"===typeof a&&(a=window.makeEmoji(a)),"string"===typeof a?null:a):null}
+function Tb(a){var b=document.createElement("div"),c=document.createElement("div");b.ca=document.createElement("ul");b.s=document.createElement("ul");b.D=document.createElement("ul");b.m=document.createElement("div");b.ra=document.createElement("div");b.ha=document.createElement("span");b.className="chatmsg-item";b.m.className="chatmsg-ts";b.ra.className="chatmsg-msg";b.ha.className="chatmsg-author-name";if(a){b.id=a.b+"_"+a.id;var d=b.ca,e=a.context.aa;a=C.context.Ca(a.K);if(e.replyToMsg){var f=
 document.createElement("li");f.className="chatmsg-hover-reply";f.style.backgroundImage='url("repl.svg")';d.appendChild(f)}e.reactMsg&&(f=document.createElement("li"),f.className="chatmsg-hover-reaction",f.style.backgroundImage='url("smile.svg")',d.appendChild(f));if(a&&e.editMsg||e.editOtherMsg)f=document.createElement("li"),f.className="chatmsg-hover-edit",f.style.backgroundImage='url("edit.svg")',d.appendChild(f);e.starMsg&&(d.ka=document.createElement("li"),d.ka.className="chatmsg-hover-star",
-d.appendChild(d.ka));e.pinMsg&&(f=document.createElement("li"),f.className="chatmsg-hover-pin",d.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")',d.appendChild(e);b.ca.className="chatmsg-hover"}c.appendChild(b.ha);c.appendChild(b.qa);c.appendChild(b.m);c.appendChild(b.s);b.F=document.createElement("div");b.F.className="chatmsg-edited";c.appendChild(b.F);
+d.appendChild(d.ka));e.pinMsg&&(f=document.createElement("li"),f.className="chatmsg-hover-pin",d.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")',d.appendChild(e);b.ca.className="chatmsg-hover"}c.appendChild(b.ha);c.appendChild(b.ra);c.appendChild(b.m);c.appendChild(b.s);b.F=document.createElement("div");b.F.className="chatmsg-edited";c.appendChild(b.F);
 c.appendChild(b.D);c.className="chatmsg-content";b.s.className="chatmsg-attachments";b.D.className="chatmsg-reactions";b.appendChild(c);b.appendChild(b.ca);return b}
 function Ub(a){if(!a.length)return"black";for(var b=0,c=0,c=[],d=0,e=0,f=0,h,k=0,g=a.length;k<g;k++)c[k]=a.charCodeAt(k),d+=c[k];h=d/a.length;c.forEach(function(a){var c=Math.abs(h-a);e+=c;f=Math.max(c,f);b=a+((b<<5)-b)});e/=a.length;b=Math.abs(b-60)%199*360/199;c=f?Math.round(Math.min(100,Math.max(75,e/f*25+75))):100;return"hsl("+b+", 100%, "+c+"%)"}
 function zb(a,b){var c=document.createElement("div"),d=document.createElement("div"),e=document.createElement("a"),f=document.createElement("img");c.ga=document.createElement("span");c.ga.className="chatmsg-author-img-wrapper";f.className="chatmsg-author-img";e.className="chatmsg-author-name";e.href="#"+a.id;a?(e.textContent=a.getName(),e.style.backgroundColor=Ub(a.getName()),f.src=pa(a)):(e.textContent=b||"?",f.src="");c.ga.appendChild(f);d.appendChild(c.ga);d.appendChild(e);d.className="chatmsg-author";
 c.className="chatmsg-authorGroup";c.appendChild(d);c.content=document.createElement("div");c.content.className="chatmsg-author-messages";c.appendChild(c.content);return c}function Vb(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 Wb(a,b,c){var d=document.createElement("li"),e=document.createElement("div"),f=document.createElement("div"),h=document.createElement("a"),k=document.createElement("div"),g=document.createElement("img"),m=document.createElement("a"),p=document.createElement("div"),l=document.createElement("div"),n=document.createElement("div"),u=document.createElement("img"),A=document.createElement("div");d.className="chatmsg-attachment";e.style.borderColor=Vb(b.color||"");e.className="chatmsg-attachment-block";
-f.className="chatmsg-attachment-pretext";b.pretext?f.innerHTML=a.w(b.pretext):f.classList.add("hidden");h.target="_blank";b.title?(h.innerHTML=a.w(b.title),b.title_link&&(h.href=b.title_link),h.className="chatmsg-attachment-title"):h.className="hidden chatmsg-attachment-title";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",g.className="chatmsg-author-img",b.author_icon&&(g.src=b.author_icon,k.appendChild(g)),
-k.appendChild(m));n.className="chatmsg-attachment-thumb";b.thumb_url?(g=document.createElement("img"),g.src=b.thumb_url,n.appendChild(g),e.classList.add("has-thumb"),b.video_html&&(n.dataset.video=b.video_html)):n.classList.add("hidden");p.className="chatmsg-attachment-content";g=a.w(b.text||"");l.className="chatmsg-attachment-text";g&&""!=g?l.innerHTML=g:l.classList.add("hidden");p.appendChild(n);p.appendChild(l);b.geo&&(l=Rb(b.geo))&&p.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&&(n=document.createElement("img"),n.src=b.footer_icon,n.className="chatmsg-attachment-footer-icon",A.appendChild(n)),A.appendChild(l));b.ts&&(l=document.createElement("span"),l.className="chatmsg-ts",l.innerHTML=J.R(b.ts),A.appendChild(l));e.appendChild(h);e.appendChild(k);e.appendChild(p);
+function Wb(a,b,c){var d=document.createElement("li"),e=document.createElement("div"),f=document.createElement("div"),h=document.createElement("a"),k=document.createElement("div"),g=document.createElement("img"),n=document.createElement("a"),p=document.createElement("div"),l=document.createElement("div"),m=document.createElement("div"),u=document.createElement("img"),A=document.createElement("div");d.className="chatmsg-attachment";e.style.borderColor=Vb(b.color||"");e.className="chatmsg-attachment-block";
+f.className="chatmsg-attachment-pretext";b.pretext?f.innerHTML=a.w(b.pretext):f.classList.add("hidden");h.target="_blank";b.title?(h.innerHTML=a.w(b.title),b.title_link&&(h.href=b.title_link),h.className="chatmsg-attachment-title"):h.className="hidden chatmsg-attachment-title";n.target="_blank";k.className="chatmsg-author";b.author_name&&(n.innerHTML=a.w(b.author_name),n.href=b.author_link||"",n.className="chatmsg-author-name",g.className="chatmsg-author-img",b.author_icon&&(g.src=b.author_icon,k.appendChild(g)),
+k.appendChild(n));m.className="chatmsg-attachment-thumb";b.thumb_url?(g=document.createElement("img"),g.src=b.thumb_url,m.appendChild(g),e.classList.add("has-thumb"),b.video_html&&(m.dataset.video=b.video_html)):m.classList.add("hidden");p.className="chatmsg-attachment-content";g=a.w(b.text||"");l.className="chatmsg-attachment-text";g&&""!=g?l.innerHTML=g:l.classList.add("hidden");p.appendChild(m);p.appendChild(l);b.geo&&(l=Rb(b.geo))&&p.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&&(m=document.createElement("img"),m.src=b.footer_icon,m.className="chatmsg-attachment-footer-icon",A.appendChild(m)),A.appendChild(l));b.ts&&(l=document.createElement("span"),l.className="chatmsg-ts",l.innerHTML=J.R(b.ts),A.appendChild(l));e.appendChild(h);e.appendChild(k);e.appendChild(p);
 e.appendChild(u);if(b.fields&&b.fields.length){var x=document.createElement("ul");e.appendChild(x);x.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&&x.appendChild(e)})}if(b.actions&&
-b.actions.length)for(h=document.createElement("ul"),h.className="chatmsg-attachment-actions "+Qa,e.appendChild(h),k=0,p=b.actions.length;k<p;k++)(u=b.actions[k])&&(u=Xb(c,k,u))&&h.appendChild(u);e.appendChild(A);d.appendChild(f);d.appendChild(e);return d}
-function Xb(a,b,c){var d=document.createElement("li"),e=Vb(c.style);d.textContent=c.text;e!==Vb()&&(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 rb(a){var b=document.createElement("li"),c=document.createElement("span");c.textContent=a.getName();b.appendChild(jb());b.appendChild(c);return b};var Db=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(){x={};l.textContent="";window.emojiProviderHeader&&(l.appendChild(k(window.emojiProviderHeader)),n.textContent="",l.appendChild(n));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(p),m.parentElement.removeChild(m),
-!0):!1}function e(a){var b=0;a=void 0===a?A.value:a;if(g()){var c=0,d=window.searchEmojis(a),e=f(d,I?I.self.T.a:[]),p;for(k in x)x[k].visible&&(x[k].visible=!1,n.removeChild(x[k].c));var k=0;for(p=e.length;k<p;k++){var m=e[k].name,l=x[m];if(!l){var l=x,L=m;var r=m;var m=window.makeEmoji(d[m]),H=document.createElement("span");H.appendChild(m);H.className="emoji-medium";r=h(r,H);l=l[L]=r}l.visible||(l.visible=!0,n.appendChild(l.c));c++}b+=c}k=b;c=0;for(E in y)y[E].visible&&(y[E].visible=!1,u.removeChild(y[E].c));
-if(I){d=f(I.b.data,I?I.self.T.a:[]);var E=0;for(b=d.length;E<b;E++)L=d[E].name,""!==a&&L.substr(0,a.length)!==a||"alias:"===I.b.data[L].substr(0,6)||(e=y[L],e||(e=y,l=p=L,L=I.b.data[L],r=document.createElement("span"),m=document.createElement("span"),r.className="emoji emoji-custom",r.style.backgroundImage='url("'+L+'")',r.textContent=":"+l+":",r.title=l,m.appendChild(r),m.className="emoji-medium",l=h(l,m),e=e[p]=l),e.visible||(e.visible=!0,u.appendChild(e.c)),c++);E=c}else E=0;return k+E}function f(a,
-b){var c=[],d;for(d in a){var e={name:d,fb: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.fb-b.fb})}function h(a,b){var c=document.createElement("li");c.appendChild(b);c.className="emojibar-list-item";c.id="emojibar-"+a;return{visible:!1,c:c}}function k(a){var b=document.createElement("img"),c=document.createElement("div");b.src=a;c.appendChild(b);c.className="emojibar-header";
-return c}function g(){return"searchEmojis"in window}var m=document.createElement("div"),p=document.createElement("div"),l=document.createElement("div"),n=document.createElement("ul"),u=document.createElement("ul"),A=document.createElement("input"),x={},y={},M=document.createElement("div"),H=document.createElement("span"),E=document.createElement("span"),r,I;p.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()});p.className="emojibar-overlay";m.className="emojibar";l.className="emojibar-emojis";n.className=u.className="emojibar-list";A.className="emojibar-search";M.className="emojibar-detail";H.className="emojibar-detail-img";E.className="emojibar-detail-name";M.appendChild(H);M.appendChild(E);b();m.appendChild(l);m.appendChild(M);m.appendChild(A);A.addEventListener("keyup",function(){e()});m.addEventListener("mousemove",function(b){a(b,function(a){var b=a?x[a]||y[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:g,pa:function(a,b,c){return g()?(I=b,r=c,a.appendChild(p),a.appendChild(m),A.value="",e(),A.focus(),!0):!1},search:e,close:c,reset:function(){b();e()}}}();var C,T=[];function Yb(){da.call(this)}Yb.prototype=Object.create(da.prototype);Yb.prototype.constructor=Yb;function ta(a){return a.a?a.a.id:null}function Zb(){this.b=0;this.context=new ra;this.a={}}
-Zb.prototype.update=function(a){var b=Date.now();a.v&&(this.b=a.v);if(a["static"])for(g in a["static"]){var c=sa(this.context,g);c||(c=new Yb,this.context.push(c));var d={};a["static"][g].channels&&a["static"][g].channels.forEach(function(a){a.pins&&(d[a.id]=a.pins,a.pins=void 0)});fa(c,a["static"][g],b);for(var e in d){var f=[],h=this.a[e];h||(h=this.a[e]=new Y(e,250,null,b));d[e].forEach(function(a){f.push(h.b(a,b))});c.j[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(g in a.live)(c=this.a[g])?la(c,a.live[g],b):c=this.a[g]=new Y(g,250,a.live[g],b);for(var k in a.live){var g=D(this.context,k);(c=g.j[k])?(this.a[k].a.length&&ha(c,na(this.a[k]).m,b),c.fa||($b(g,c,a.live[k]),P&&a.live[P.id]&&U())):C.b=0}}a["static"]&&ib();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&&!e[g]&&(delete c.u[g],f=!0);if(e)for(g in e)if(c.j[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)&&pb();a.config&&(X=new ac(a.config),Pb());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,g=0,c=k.length;g<c;g++)if(k[g].id===P.id){U();break}};setInterval(function(){var a=!1,b=Date.now();va(function(c){var d=!1,e;for(e in c.u){var f=!0,h;for(h in c.u[e])c.u[e][h]+6500<b?(delete c.u[e][h],d=!0):f=!1;f&&(delete c.u[e],d=!0)}d&&(a=!0)});a&&pb()},1E3);
-function $b(a,b,c){var d;if(b!==P||!window.hasFocus){var e=(d=a.self?a.self.id:null)?new RegExp("<@"+d):null,f=!1,h=!1,k=!1;c.forEach(function(c){if(!(parseFloat(c.ts)<=b.C)&&c.user!==a.self.id){h=!0;var d;if(!(d=b instanceof t)&&(d=c.text)&&!(d=e&&c.text.match(e)))a:{d=a.self.T.B;for(var g=0,m=d.length;g<m;g++)if(-1!==c.text.indexOf(d[g])){d=!0;break a}d=!1}d&&(-1===T.indexOf(b)&&(k=!0,T.push(b)),f=!0)}});if(h){nb();var g=document.getElementById("room_"+b.id);g&&(g.classList.add("unread"),f&&g.classList.add("unreadHi"));
-k&&!window.hasFocus&&yb()}}c.forEach(function(a){if(!d||d===a.K)for(var c=0,e=Ab.length;c<e;c++){var f=Ab[c];if(f.channel===b.id&&a.text&&a.text.trim()===f.text&&!!a.isMeMessage===f.Ba){Ab.splice(c,1);break}}})}function ub(){var a=P,b=T.indexOf(a);if(a.I>a.C){var c=C.a[a.id];c&&(c=na(c))&&(N(new K("POST","api/markread?room="+a.id+"&id="+c.id+"&ts="+c.m)),a.C=c.m)}0<=b&&(T.splice(b,1),nb());a=document.getElementById("room_"+a.id);a.classList.remove("unread");a.classList.remove("unreadHi")}C=new Zb;var ob=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<=p;f+=l)h(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 K(a),function(a,c,d){if(d){var e=new Image;e.onload=function(){var a=
+b.actions.length)for(h=document.createElement("ul"),h.className="chatmsg-attachment-actions "+Pa,e.appendChild(h),k=0,p=b.actions.length;k<p;k++)(u=b.actions[k])&&(u=Xb(c,k,u))&&h.appendChild(u);e.appendChild(A);d.appendChild(f);d.appendChild(e);return d}
+function Xb(a,b,c){var d=document.createElement("li"),e=Vb(c.style);d.textContent=c.text;e!==Vb()&&(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 qb(a){var b=document.createElement("li"),c=document.createElement("span");c.textContent=a.getName();b.appendChild(ib());b.appendChild(c);return b};var Db=function(){function a(a,b){for(a=a.target;a!==n&&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(){x={};l.textContent="";window.emojiProviderHeader&&(l.appendChild(k(window.emojiProviderHeader)),m.textContent="",l.appendChild(m));l.appendChild(k("emojicustom.png"));l.appendChild(u)}function c(){if(!d())return!1;r&&r(null);return!0}function d(){return n.parentElement?(n.parentElement.removeChild(p),n.parentElement.removeChild(n),
+!0):!1}function e(a){var b=0;a=void 0===a?A.value:a;if(g()){var c=0,d=window.searchEmojis(a),e=f(d,I?I.self.T.a:[]),p;for(k in x)x[k].visible&&(x[k].visible=!1,m.removeChild(x[k].c));var k=0;for(p=e.length;k<p;k++){var n=e[k].name,l=x[n];if(!l){var l=x,L=n;var r=n;var n=window.makeEmoji(d[n]),H=document.createElement("span");H.appendChild(n);H.className="emoji-medium";r=h(r,H);l=l[L]=r}l.visible||(l.visible=!0,m.appendChild(l.c));c++}b+=c}k=b;c=0;for(E in y)y[E].visible&&(y[E].visible=!1,u.removeChild(y[E].c));
+if(I){d=f(I.b.data,I?I.self.T.a:[]);var E=0;for(b=d.length;E<b;E++)L=d[E].name,""!==a&&L.substr(0,a.length)!==a||"alias:"===I.b.data[L].substr(0,6)||(e=y[L],e||(e=y,l=p=L,L=I.b.data[L],r=document.createElement("span"),n=document.createElement("span"),r.className="emoji emoji-custom",r.style.backgroundImage='url("'+L+'")',r.textContent=":"+l+":",r.title=l,n.appendChild(r),n.className="emoji-medium",l=h(l,n),e=e[p]=l),e.visible||(e.visible=!0,u.appendChild(e.c)),c++);E=c}else E=0;return k+E}function f(a,
+b){var c=[],d;for(d in a){var e={name:d,gb: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.gb-b.gb})}function h(a,b){var c=document.createElement("li");c.appendChild(b);c.className="emojibar-list-item";c.id="emojibar-"+a;return{visible:!1,c:c}}function k(a){var b=document.createElement("img"),c=document.createElement("div");b.src=a;c.appendChild(b);c.className="emojibar-header";
+return c}function g(){return"searchEmojis"in window}var n=document.createElement("div"),p=document.createElement("div"),l=document.createElement("div"),m=document.createElement("ul"),u=document.createElement("ul"),A=document.createElement("input"),x={},y={},M=document.createElement("div"),H=document.createElement("span"),E=document.createElement("span"),r,I;p.addEventListener("click",function(a){var b=n.getBoundingClientRect();(a.screenY<b.top||a.screenY>b.bottom||a.screenX<b.left||a.screenX>b.right)&&
+c()});p.className="emojibar-overlay";n.className="emojibar";l.className="emojibar-emojis";m.className=u.className="emojibar-list";A.className="emojibar-search";M.className="emojibar-detail";H.className="emojibar-detail-img";E.className="emojibar-detail-name";M.appendChild(H);M.appendChild(E);b();n.appendChild(l);n.appendChild(M);n.appendChild(A);A.addEventListener("keyup",function(){e()});n.addEventListener("mousemove",function(b){a(b,function(a){var b=a?x[a]||y[a]:null;b?(H.innerHTML=b.c.outerHTML,
+E.textContent=":"+a+":"):(H.textContent="",E.textContent="")})});n.addEventListener("click",function(b){a(b,function(a){a&&d()&&r&&r(a)})});return{isSupported:g,qa:function(a,b,c){return g()?(I=b,r=c,a.appendChild(p),a.appendChild(n),A.value="",e(),A.focus(),!0):!1},search:e,close:c,reset:function(){b();e()}}}();var C,U=[];function Yb(){da.call(this)}Yb.prototype=Object.create(da.prototype);Yb.prototype.constructor=Yb;function ta(a){return a.a?a.a.id:null}function Zb(){this.b=0;this.context=new qa;this.a={}}
+Zb.prototype.update=function(a){var b=Date.now();a.v&&(this.b=a.v);if(a["static"])for(g in a["static"]){var c=sa(this.context,g);c||(c=new Yb,this.context.push(c));var d={};a["static"][g].channels&&a["static"][g].channels.forEach(function(a){a.pins&&(d[a.id]=a.pins,a.pins=void 0)});fa(c,a["static"][g],b);for(var e in d){var f=[],h=this.a[e];h||(h=this.a[e]=new Y(e,250,null,b));d[e].forEach(function(a){f.push(h.b(a,b))});c.j[e].b=f}}ua(this.context,function(a){a.I===a.C&&(a=U.indexOf(a),-1!==a&&U.splice(a,
+1))});if(a.live){for(g in a.live)(c=this.a[g])?la(c,a.live[g],b):c=this.a[g]=new Y(g,250,a.live[g],b);for(var k in a.live){var g=D(this.context,k);(c=g.j[k])?(this.a[k].a.length&&ha(c,na(this.a[k]).m,b),c.fa||($b(g,c,a.live[k]),Q&&a.live[Q.id]&&tb())):C.b=0}}a["static"]&&hb();var n=!1;a.typing&&this.context.a.forEach(function(c){var d=n,e=a.typing,f=!1;if(c.u)for(var g in c.u)e&&!e[g]&&(delete c.u[g],f=!0);if(e)for(g in e)if(c.j[g]){c.u[g]||(c.u[g]={});for(var h in e[g])c.u[g][h]||(f=!0),c.u[g][h]=
+b}n=d|f},this);(a["static"]||n)&&ob();a.config&&(X=new ac(a.config),Pb());if(P&&Q&&a["static"]&&a["static"][P.a.id]&&a["static"][P.a.id].channels&&a["static"][P.a.id].channels)for(k=a["static"][P.a.id].channels,g=0,c=k.length;g<c;g++)if(k[g].id===Q.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,h;for(h in c.u[e])c.u[e][h]+6500<b?(delete c.u[e][h],d=!0):f=!1;f&&(delete c.u[e],d=!0)}d&&(a=!0)});a&&ob()},1E3);
+function $b(a,b,c){var d;if(b!==Q||!window.hasFocus){var e=(d=a.self?a.self.id:null)?new RegExp("<@"+d):null,f=!1,h=!1,k=!1;c.forEach(function(c){if(!(parseFloat(c.ts)<=b.C)&&c.user!==a.self.id){h=!0;var d;if(!(d=b instanceof t)&&(d=c.text)&&!(d=e&&c.text.match(e)))a:{d=a.self.T.B;for(var g=0,m=d.length;g<m;g++)if(-1!==c.text.indexOf(d[g])){d=!0;break a}d=!1}d&&(-1===U.indexOf(b)&&(k=!0,U.push(b)),f=!0)}});if(h){mb();var g=document.getElementById("room_"+b.id);g&&(g.classList.add("unread"),f&&g.classList.add("unreadHi"));
+k&&!window.hasFocus&&yb()}}c.forEach(function(a){if(!d||d===a.K)for(var c=0,e=Ab.length;c<e;c++){var f=Ab[c];if(f.channel===b.id&&!!a.isMeMessage===f.Ca&&(a.pendingId===f.na&&f.na||!f.na&&a.text.trim()===f.text)){Ab.splice(c,1);break}}})}
+function ub(){var a=Q,b=U.indexOf(a);if(a.I>a.C){var c=C.a[a.id];c&&(c=na(c))&&(O(new K("POST","api/markread?room="+a.id+"&id="+c.id+"&ts="+c.m)),a.C=c.m)}0<=b&&(U.splice(b,1),mb());a=document.getElementById("room_"+a.id);a.classList.remove("unread");a.classList.remove("unreadHi")}C=new Zb;var nb=function(){function a(a,c){c.sort(function(){return Math.random()-.5});for(var d=0,e=20;e<n-40;e+=l)for(var f=0;f+l<=p;f+=l)h(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){O(Fa(Da(N(new K(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=
-g.createLinearGradient(0,0,0,p);a.addColorStop(0,"#4D394B");a.addColorStop(1,"#201820");g.fillStyle=a;g.fillRect(0,0,m,p);return g.getImageData(0,0,m,p)}function f(a,b){for(var c=(a.height-b.height)/2,d=0;d<b.height;d++)for(var e=0;e<b.width;e++){var f=b.data[4*(d*b.width+e)]/255,g=4*((d+c)*a.width+e+c);a.data[g]*=f;a.data[g+1]*=f;a.data[g+2]*=f}return a}function h(a,b,c,d){var e=Math.floor(d);a=[a.data[e*m*4+0],a.data[e*m*4+1],a.data[e*m*4+2]];g.fillStyle="#"+(1.1*a[0]<<16|1.1*a[1]<<8|1.1*a[2]).toString(16);
-g.beginPath();g.moveTo(c+l/2,d+n);g.lineTo(c-n+l,d+l/2);g.lineTo(c+l/2,d-n+l);g.lineTo(c+n,d+l/2);g.closePath();g.fill();g.putImageData(f(g.getImageData(c+n,d+n,u,u),b),c+n,d+n)}var k=document.createElement("canvas"),g=k.getContext("2d"),m=k.width=250,p=k.height=290,l=(m-40)/3,n=.1*l,u=Math.floor(l-2*n),A=.5*u,x={},y={},M={};return function(b,d,f){if(x[b])f(x[b]);else if(M[b])y[b]?y[b].push(f):y[b]=[f];else{var g=e(),h=[];M[b]=!0;y[b]?y[b].push(f):y[b]=[f];for(var l in d)d[l].Ua||d[l].ub||h.push({src:pa(d[l])});
-c(h,function(c){a(g,c);x[b]=k.toDataURL();y[b].forEach(function(a){a(x[b])})})}}}();var W=0,P=null,O=null,R=null,Q=null,Ab=[];function Ib(){N(Fa(Ea(Da(new K("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 bc(){var a=P;N(Ca(Da(Ga(new K("api/hist?room="+a.id),"json"),function(b,c,d){if(d){b=C.a[a.id];var e=Date.now();b?c=!!la(b,d,e):(b=C.a[a.id]=new Y(a,100,d,e),c=!0);c&&(b.a.length&&ha(a,na(b).m,e),$b(D(C.context,a.id),a,d),a===P&&U())}}),function(){}))}function Pb(){a:{var a=X.U;for(var b in a)if(a.hasOwnProperty(b)){a=!1;break a}a=!0}a&&Lb.Ab(!1).display(Lb.xb.U);a=X.h;cc(a&&Qb[a]?Qb[a]:dc);document.getElementById("customsheet").innerHTML=ec()}
-function Nb(){var a=fc;N(Fa(Ga(Ca(new K("api?v="+C.b),function(b,c,d){(b=2===Math.floor(b/100))?W&&(W=0,sb(!0)):W?(W+=Math.floor((W||5)/2),W=Math.min(60,W)):(W=5,sb(!1));a(b,d)}),"json")))}function fc(a,b){a?(b&&C.update(b),Nb()):setTimeout(gc,1E3*W)}function gc(){Nb()}
-function hc(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);tb();Jb.rb();ob(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)&&bc();document.getElementById("chatSystemContainer").classList.remove("no-room-selected")}
-function mb(){var a=document.location.hash.substr(1),b=wa(a);b&&b!==P?hc(b):(a=F(a))&&a.O&&hc(a.O)}function Mb(a,b,c){var d=P;new FileReader;var e=new FormData;e.append("file",b);e.append("filename",a);N(Ea(Da(new K("POST","api/file?room="+d.id),function(){c(null)}),function(a,b){c(b)}),e)}
-function db(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.K).getName(),text:c.text,footer:a.h?J.message:a.name,ts:c.m}])));N(new K("POST",b))}function Eb(a,b){N(new K("DELETE","api/pinMsg?room="+a.id+"&msgId="+b.id))}function wb(a,b,c){N(new K("POST","api/reaction?room="+a+"&msg="+b+"&reaction="+encodeURIComponent(c)))}
-function Kb(){N(new K("POST","api/logout"));document.cookie="sessID=;Path=/;expires=Thu, 01 Jan 1970 00:00:01 GMT;";document.location.reload()}function lb(){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].ma+a[d].sa+a[d].oa?(e.classList.remove("hidden"),b.push(d)):e.classList.add("hidden"))}};var Qb={noemoji:{Ca:"noemoji.js",ia:null,name:"None"},emojione_v2_3:{Ca:"emojione_v2.3.sprites.js",ia:"emojione_v2.3.sprites.css",name:"Emojione v2.3"},emojione_v3:{Ca:"emojione_v3.sprites.js",ia:"emojione_v3.sprites.css",name:"Emojione v3"}},dc=Qb.emojione_v2_3,Za;
-function cc(a){Za!==a&&(console.log("Loading emoji pack "+a.name),N(Fa(Da(new K(a.Ca),function(b,c,d){b=document.createElement("script");b.innerHTML=d;b.language="text/javascript";document.body.appendChild(b);a.ia&&(d=document.createElement("link"),d.href=a.ia,d.rel="stylesheet",document.head.appendChild(d));d=document.getElementById("emojiButton");for(var e in C.a)ic(C.a[e]);P&&U();Db.reset();"makeEmoji"in window?(d.style.backgroundImage='url("smile.svg")',d.classList.remove("hidden")):d.classList.add("hidden")}))),
-Za=a)};var Jb=function(){function a(){c();r instanceof t?(f.style.backgroundImage="url(api/avatar?size=l&user="+r.a.id+")",m.textContent=(r.a.hb||(r.a.Wa||"")+" "+r.a.Za).trim(),h.classList.add("presence-indicator"),r.a.N?h.classList.remove("presence-away"):h.classList.add("presence-away"),g.classList.remove("hidden"),l.classList.remove("hidden"),l.textContent=r.a.yb||"",u.textContent=r.a.qb||"",n.classList.remove("hidden"),e.classList.remove("roominfo-channel"),e.classList.add("roominfo-user")):b()}function b(){var a=
-E;a.aa.topic?(g.classList.remove("hidden"),m.textContent=r.sa||"",p.textContent=r.G?J.Fa(r.G,r.ea):""):g.classList.add("hidden");a.aa.purpose?(n.classList.remove("hidden"),u.textContent=r.oa||"",A.textContent=r.o?J.Fa(r.o,r.da):""):n.classList.add("hidden");f.style.backgroundImage="";h.classList.remove("presence-indicator");M.textContent=J.jb(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(){h.textContent=r.name;if(r.b){x.textContent=J.cb(r.b.length);x.classList.remove("hidden");y.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)});y.textContent="";y.appendChild(a)}else x.classList.add("hidden"),y.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){Eb(r,
-r.b[a]);break}}var e=document.createElement("div"),f=document.createElement("header"),h=document.createElement("h3"),k=document.createElement("div"),g=document.createElement("div"),m=document.createElement("span"),p=document.createElement("span"),l=document.createElement("div"),n=document.createElement("div"),u=document.createElement("span"),A=document.createElement("span"),x=document.createElement("div"),y=document.createElement("ul"),M=document.createElement("div"),H=document.createElement("ul"),
-E,r;e.className="chat-context-roominfo";f.className="roominfo-title";g.className="roominfo-topic";n.className="roominfo-purpose";l.className="roominfo-phone";x.className="roominfo-pincount";y.className="roominfo-pinlist";M.className="roominfo-usercount";H.className="roominfo-userlist";A.className=p.className="roominfo-author";f.appendChild(h);e.appendChild(f);e.appendChild(k);g.appendChild(m);g.appendChild(p);n.appendChild(u);n.appendChild(A);k.appendChild(g);k.appendChild(l);k.appendChild(n);k.appendChild(x);
-k.appendChild(y);k.appendChild(M);k.appendChild(H);var I=null;return{eb:function(b,c){this.$();E=b;r=c;a();return this},update:function(){this.$();a();return this},show:function(a){this.$();a.appendChild(e);e.classList.remove("hidden");return this},rb:function(){this.$();e.classList.add("hidden");return this},$:function(){I&&clearTimeout(I);I=null;return this},sb:function(){I||(I=setTimeout(function(){e.classList.add("hidden");I=null},300));return this},vb:function(a){for(;a;){if(a===e)return!0;a=
+g.createLinearGradient(0,0,0,p);a.addColorStop(0,"#4D394B");a.addColorStop(1,"#201820");g.fillStyle=a;g.fillRect(0,0,n,p);return g.getImageData(0,0,n,p)}function f(a,b){for(var c=(a.height-b.height)/2,d=0;d<b.height;d++)for(var e=0;e<b.width;e++){var f=b.data[4*(d*b.width+e)]/255,g=4*((d+c)*a.width+e+c);a.data[g]*=f;a.data[g+1]*=f;a.data[g+2]*=f}return a}function h(a,b,c,d){var e=Math.floor(d);a=[a.data[e*n*4+0],a.data[e*n*4+1],a.data[e*n*4+2]];g.fillStyle="#"+(1.1*a[0]<<16|1.1*a[1]<<8|1.1*a[2]).toString(16);
+g.beginPath();g.moveTo(c+l/2,d+m);g.lineTo(c-m+l,d+l/2);g.lineTo(c+l/2,d-m+l);g.lineTo(c+m,d+l/2);g.closePath();g.fill();g.putImageData(f(g.getImageData(c+m,d+m,u,u),b),c+m,d+m)}var k=document.createElement("canvas"),g=k.getContext("2d"),n=k.width=250,p=k.height=290,l=(n-40)/3,m=.1*l,u=Math.floor(l-2*m),A=.5*u,x={},y={},M={};return function(b,d,f){if(x[b])f(x[b]);else if(M[b])y[b]?y[b].push(f):y[b]=[f];else{var g=e(),h=[];M[b]=!0;y[b]?y[b].push(f):y[b]=[f];for(var l in d)d[l].Va||d[l].vb||h.push({src:pa(d[l])});
+c(h,function(c){a(g,c);x[b]=k.toDataURL();y[b].forEach(function(a){a(x[b])})})}}}();var W=0,Q=null,P=null,S=null,R=null,Ab=[];function Ib(){O(Ea(Da(N(new K("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 bc(){var a=Q;O(Ca(N(Fa(new K("api/hist?room="+a.id),"json"),function(b,c,d){if(d){b=C.a[a.id];var e=Date.now();b?c=!!la(b,d,e):(b=C.a[a.id]=new Y(a,100,d,e),c=!0);c&&(b.a.length&&ha(a,na(b).m,e),$b(D(C.context,a.id),a,d),a===Q&&tb())}}),function(){}))}function Pb(){a:{var a=X.U;for(var b in a)if(a.hasOwnProperty(b)){a=!1;break a}a=!0}a&&Lb.Bb(!1).display(Lb.yb.U);a=X.h;cc(a&&Qb[a]?Qb[a]:dc);document.getElementById("customsheet").innerHTML=ec()}
+function Nb(){var a=fc;O(Ea(Fa(Ca(new K("api?v="+C.b),function(b,c,d){(b=2===Math.floor(b/100))?W&&(W=0,rb(!0)):W?(W+=Math.floor((W||5)/2),W=Math.min(60,W)):(W=5,rb(!1));a(b,d)}),"json")))}function fc(a,b){a?(b&&C.update(b),Nb()):setTimeout(gc,1E3*W)}function gc(){Nb()}
+function hc(a){Q&&(document.getElementById("room_"+Q.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");Q=a;P=D(C.context,a.id);sb();Jb.sb();nb(P.a.id,P.i,function(a){document.getElementById("chatCtx").style.backgroundImage="url("+a+")"});(!C.a[Q.id]||100>C.a[Q.id].a.length)&&bc();document.getElementById("chatSystemContainer").classList.remove("no-room-selected");
+document.getElementById("chatCtx").classList.remove("opened")}function lb(){var a=document.location.hash.substr(1),b=wa(a);b&&b!==Q?hc(b):(a=F(a))&&a.O&&hc(a.O)}function Mb(a,b,c){var d=Q;new FileReader;var e=new FormData;e.append("file",b);e.append("filename",a);O(Da(N(new K("POST","api/file?room="+d.id),function(){c(null)}),function(a,b){c(b)}),e)}
+function cb(a,b,c,d){b="api/msg?room="+a.id+"&text="+encodeURIComponent(b);d&&(b+="&attachments="+encodeURIComponent(JSON.stringify([{fallback:d.text,author_name:F(d.K).getName(),text:d.text,footer:a.h?J.message:a.name,ts:d.m}])));O(N(Fa(new K("POST",b),"json"),function(a,b,d){d&&void 0!==d.pendingId&&(c.na=d.pendingId)}))}function Eb(a,b){O(new K("DELETE","api/pinMsg?room="+a.id+"&msgId="+b.id))}
+function wb(a,b,c){O(new K("POST","api/reaction?room="+a+"&msg="+b+"&reaction="+encodeURIComponent(c)))}function Kb(){O(new K("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].ma+a[d].ta+a[d].pa?(e.classList.remove("hidden"),b.push(d)):e.classList.add("hidden"))}};var Qb={noemoji:{Da:"noemoji.js",ia:null,name:"None"},emojione_v2_3:{Da:"emojione_v2.3.sprites.js",ia:"emojione_v2.3.sprites.css",name:"Emojione v2.3"},emojione_v3:{Da:"emojione_v3.sprites.js",ia:"emojione_v3.sprites.css",name:"Emojione v3"}},dc=Qb.emojione_v2_3,Ya;
+function cc(a){Ya!==a&&(console.log("Loading emoji pack "+a.name),O(Ea(N(new K(a.Da),function(b,c,d){b=document.createElement("script");b.innerHTML=d;b.language="text/javascript";document.body.appendChild(b);a.ia&&(d=document.createElement("link"),d.href=a.ia,d.rel="stylesheet",document.head.appendChild(d));d=document.getElementById("emojiButton");for(var e in C.a)ic(C.a[e]);Q&&tb();Db.reset();"makeEmoji"in window?(d.style.backgroundImage='url("smile.svg")',d.classList.remove("hidden")):d.classList.add("hidden")}))),
+Ya=a)};var Jb=function(){function a(){c();r instanceof t?(f.style.backgroundImage="url(api/avatar?size=l&user="+r.a.id+")",n.textContent=(r.a.ib||(r.a.Xa||"")+" "+r.a.$a).trim(),h.classList.add("presence-indicator"),r.a.N?h.classList.remove("presence-away"):h.classList.add("presence-away"),g.classList.remove("hidden"),l.classList.remove("hidden"),l.textContent=r.a.zb||"",u.textContent=r.a.rb||"",m.classList.remove("hidden"),e.classList.remove("roominfo-channel"),e.classList.add("roominfo-user")):b()}function b(){var a=
+E;a.aa.topic?(g.classList.remove("hidden"),n.textContent=r.ta||"",p.textContent=r.G?J.Ga(r.G,r.ea):""):g.classList.add("hidden");a.aa.purpose?(m.classList.remove("hidden"),u.textContent=r.pa||"",A.textContent=r.o?J.Ga(r.o,r.da):""):m.classList.add("hidden");f.style.backgroundImage="";h.classList.remove("presence-indicator");M.textContent=J.kb(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(){h.textContent=r.name;if(r.b){x.textContent=J.eb(r.b.length);x.classList.remove("hidden");y.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.L());c.appendChild(e);a.appendChild(c)});y.textContent="";y.appendChild(a)}else x.classList.add("hidden"),y.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){Eb(r,
+r.b[a]);break}}var e=document.createElement("div"),f=document.createElement("header"),h=document.createElement("h3"),k=document.createElement("div"),g=document.createElement("div"),n=document.createElement("span"),p=document.createElement("span"),l=document.createElement("div"),m=document.createElement("div"),u=document.createElement("span"),A=document.createElement("span"),x=document.createElement("div"),y=document.createElement("ul"),M=document.createElement("div"),H=document.createElement("ul"),
+E,r;e.className="chat-context-roominfo";f.className="roominfo-title";g.className="roominfo-topic";m.className="roominfo-purpose";l.className="roominfo-phone";x.className="roominfo-pincount";y.className="roominfo-pinlist";M.className="roominfo-usercount";H.className="roominfo-userlist";A.className=p.className="roominfo-author";f.appendChild(h);e.appendChild(f);e.appendChild(k);g.appendChild(n);g.appendChild(p);m.appendChild(u);m.appendChild(A);k.appendChild(g);k.appendChild(l);k.appendChild(m);k.appendChild(x);
+k.appendChild(y);k.appendChild(M);k.appendChild(H);var I=null;return{fb:function(b,c){this.$();E=b;r=c;a();return this},update:function(){this.$();a();return this},show:function(a){this.$();a.appendChild(e);e.classList.remove("hidden");return this},sb:function(){this.$();e.classList.add("hidden");return this},$:function(){I&&clearTimeout(I);I=null;return this},tb:function(){I||(I=setTimeout(function(){e.classList.add("hidden");I=null},300));return this},wb:function(a){for(;a;){if(a===e)return!0;a=
 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 jc(this.id,a,b):!0===a.isNotice?new kc(this.id,a,b):new lc(this.id,a,b)};function ic(a){a.a.forEach(function(a){a.H()})}
-var Z=function(){function a(a,d){return Aa(d,{B:a.context.self.T.B,X: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},la:function(c){return b(a,c)}})}function b(a,b){var c=b.indexOf("|"),d;if(-1===c)var h=b;else{h=b.substr(0,c);var k=b.substr(c+1)}if("@"===h[0])if(h=ta(a.context)+"|"+h.substr(1),d=F(h))a=!0,h="#"+d.O.id,k="@"+d.getName(),d="background-color:"+
-Ub(d.getName()),b=["chatmsg-link-user","chatmsg-link"];else return null;else if("#"===h[0])if(h=ta(a.context)+"|"+h.substr(1),k=wa(h))a=!0,h="#"+h,k="#"+k.name,b=["chatmsg-link-chan","chatmsg-link"];else return null;else{if(!h.match(/^(https?|mailto):\/\//i))return null;b=["chatmsg-link"];a=!1}return{link:h,text:k||h,style:d,Ta:b,Ya:a}}return{H:function(a){a.V=!0;return a},Y:function(a){a.c&&a.c.parentElement&&(a.c.remove(),delete a.c);return a},M:function(a){a.c?a.V&&(a.V=!1,a.P()):a.ya().P();return a.c},
-P:function(b){var c=F(b.K);b.c.m.innerHTML=J.R(b.m);b.c.qa.innerHTML=a(b,b.text);b.c.ha.textContent=c?c.getName():b.username||"?";for(var c=document.createDocumentFragment(),e=0,f=b.s.length;e<f;e++){var h=b.s[e];h&&(h=Wb(b,h,e))&&c.appendChild(h)}b.c.s.textContent="";b.c.s.appendChild(c);c=b.b;e=document.createDocumentFragment();if(b.D)for(var k in b.D){var f=c,h=b.id,g=k,m=b.D[k],p=$a(g);if(p){for(var l=document.createElement("li"),n=document.createElement("a"),u=document.createElement("span"),
-A=document.createElement("span"),x=[],y=0,M=m.length;y<M;y++){var H=F(m[y]);H&&x.push(H.getName())}x.sort();A.textContent=x.join(", ");u.appendChild(p);u.className="emoji-small";n.href="javascript:toggleReaction('"+f+"', '"+h+"', '"+g+"')";n.appendChild(u);n.appendChild(A);l.className="chatmsg-reaction-item";l.appendChild(n);f=l}else console.warn("Reaction id not found: "+g),f=null;f&&e.appendChild(f)}b.c.D.textContent="";b.c.D.appendChild(e);b.c.ca.ka&&(b.c.ca.ka.style.backgroundImage=b.A?'url("star_full.png")':
+var Z=function(){function a(a,d){return Aa(d,{B:a.context.self.T.B,X: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},la:function(c){return b(a,c)}})}function b(a,b){var c=b.indexOf("|"),d;if(-1===c)var h=b;else{h=b.substr(0,c);var k=b.substr(c+1)}if("@"===h[0])if(h=ta(a.context)+"|"+h.substr(1),d=F(h))a=!0,h="#"+d.O.id,k="@"+d.getName(),d="background-color:"+
+Ub(d.getName()),b=["chatmsg-link-user","chatmsg-link"];else return null;else if("#"===h[0])if(h=ta(a.context)+"|"+h.substr(1),k=wa(h))a=!0,h="#"+h,k="#"+k.name,b=["chatmsg-link-chan","chatmsg-link"];else return null;else{if(!h.match(/^(https?|mailto):\/\//i))return null;b=["chatmsg-link"];a=!1}return{link:h,text:k||h,style:d,Ua:b,Za:a}}return{H:function(a){a.V=!0;return a},Y:function(a){a.c&&a.c.parentElement&&(a.c.remove(),delete a.c);return a},M:function(a){a.c?a.V&&(a.V=!1,a.P()):a.za().P();return a.c},
+P:function(b){var c=F(b.K);b.c.m.innerHTML=J.R(b.m);b.c.ra.innerHTML=a(b,b.text);b.c.ha.textContent=c?c.getName():b.username||"?";for(var c=document.createDocumentFragment(),e=0,f=b.s.length;e<f;e++){var h=b.s[e];h&&(h=Wb(b,h,e))&&c.appendChild(h)}b.c.s.textContent="";b.c.s.appendChild(c);c=b.b;e=document.createDocumentFragment();if(b.D)for(var k in b.D){var f=c,h=b.id,g=k,n=b.D[k],p=Za(g);if(p){for(var l=document.createElement("li"),m=document.createElement("a"),u=document.createElement("span"),
+A=document.createElement("span"),x=[],y=0,M=n.length;y<M;y++){var H=F(n[y]);H&&x.push(H.getName())}x.sort();A.textContent=x.join(", ");u.appendChild(p);u.className="emoji-small";m.href="javascript:toggleReaction('"+f+"', '"+h+"', '"+g+"')";m.appendChild(u);m.appendChild(A);l.className="chatmsg-reaction-item";l.appendChild(m);f=l}else console.warn("Reaction id not found: "+g),f=null;f&&e.appendChild(f)}b.c.D.textContent="";b.c.D.appendChild(e);b.c.ca.ka&&(b.c.ca.ka.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 jc(a,b,c){w.call(this,b,c);this.context=D(C.context,a);this.b=a;this.c=Z.c;this.V=Z.V}jc.prototype=Object.create(z.prototype);q=jc.prototype;q.constructor=jc;q.H=function(){return Z.H(this)};q.w=function(a){return Z.w(this,a)};q.Y=function(){return Z.Y(this)};q.M=function(){return Z.M(this)};
-q.ya=function(){this.c=Tb(this);this.c.classList.add("chatmsg-me_message");return this};q.L=function(){return Z.L(this)};q.P=function(){Z.P(this);return this};q.update=function(a,b){z.prototype.update.call(this,a,b);this.H()};function lc(a,b,c){w.call(this,b,c);this.context=D(C.context,a);this.b=a;this.c=Z.c;this.V=Z.V}lc.prototype=Object.create(w.prototype);q=lc.prototype;q.constructor=lc;q.H=function(){return Z.H(this)};q.w=function(a){return Z.w(this,a)};q.Y=function(){return Z.Y(this)};q.M=function(){return Z.M(this)};
-q.ya=function(){this.c=Tb(this);return this};q.L=function(){return Z.L(this)};q.P=function(){Z.P(this);return this};
+q.za=function(){this.c=Tb(this);this.c.classList.add("chatmsg-me_message");return this};q.L=function(){return Z.L(this)};q.P=function(){Z.P(this);return this};q.update=function(a,b){z.prototype.update.call(this,a,b);this.H()};function lc(a,b,c){w.call(this,b,c);this.context=D(C.context,a);this.b=a;this.c=Z.c;this.V=Z.V}lc.prototype=Object.create(w.prototype);q=lc.prototype;q.constructor=lc;q.H=function(){return Z.H(this)};q.w=function(a){return Z.w(this,a)};q.Y=function(){return Z.Y(this)};q.M=function(){return Z.M(this)};
+q.za=function(){this.c=Tb(this);return this};q.L=function(){return Z.L(this)};q.P=function(){Z.P(this);return this};
 q.update=function(a,b){w.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 kc(a,b,c){w.call(this,b,c);this.context=D(C.context,a);this.b=a;this.a=null;this.V=!0}kc.prototype=Object.create(B.prototype);q=kc.prototype;q.constructor=kc;q.H=function(){return Z.H(this)};q.w=function(a){return Z.w(this,a)};q.Y=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.ya=function(){this.c=Tb(this);this.a=document.createElement("span");this.c.classList.add("chatmsg-notice");this.a.className="chatmsg-notice";this.a.textContent=J.bb;this.a.appendChild(this.c);return this};q.P=function(){Z.P(this);return this};q.update=function(a,b){B.prototype.update.call(this,a,b);this.H()};
-function Fb(a,b){var c=Tb(null);c.classList.add("chatmsg-pending");b&&c.classList.add("chatmsg-me_message");c.qa.innerHTML=Aa(a,{X: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}});c.ha.textContent=O.self?O.self.getName():"";a=document.createElement("span");a.className="typing-dot1";a.textContent=".";c.m.appendChild(a);a=document.createElement("span");
+q.za=function(){this.c=Tb(this);this.a=document.createElement("span");this.c.classList.add("chatmsg-notice");this.a.className="chatmsg-notice";this.a.textContent=J.cb;this.a.appendChild(this.c);return this};q.P=function(){Z.P(this);return this};q.update=function(a,b){B.prototype.update.call(this,a,b);this.H()};
+function Fb(a,b){var c=Tb(null);c.classList.add("chatmsg-pending");b&&c.classList.add("chatmsg-me_message");c.ra.innerHTML=Aa(a,{X: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}});c.ha.textContent=P.self?P.self.getName():"";a=document.createElement("span");a.className="typing-dot1";a.textContent=".";c.m.appendChild(a);a=document.createElement("span");
 a.className="typing-dot2";a.textContent=".";c.m.appendChild(a);a=document.createElement("span");a.className="typing-dot3";a.textContent=".";c.m.appendChild(a);c.m.classList.add("typing-container");return c};var X;function ac(a){this.U={};for(var b=0,c=a.length;b<c;b++)null===a[b].service&&null===a[b].device&&Ob(this,JSON.parse(a[b].config))}function Ob(a,b){if(b.services)for(var c in b.services)a.U[c]=b.services[c];void 0!==b.emojiProvider&&(a.h=b.emojiProvider);void 0!==b.displayAvatar&&(a.a=b.displayAvatar);void 0!==b.colorfulNames&&(a.b=b.colorfulNames)}
 function ec(){var a=X,b={},c="";!1===a.a&&(b[".chatsystem-content .chatmsg-authorGroup .chatmsg-author-img-wrapper"]=["display: none"],b[".chatsystem-content .chatmsg-authorGroup"]=["display: flex"],b[".chatsystem-content .chatmsg-authorGroup .chatmsg-author"]=["position:initial","vertical-align:top","min-width:75px"],b[".chatsystem-content .chatmsg-authorGroup .chatmsg-author-messages"]=["padding-top:0","padding-left:0","display:inline-block","margin-top:-4px","flex:1"],b[".chatmsg-author-name::before"]=
-["content:'<'"],b[".chatmsg-author-name::after"]=["content:'>'"]);!0===a.b||(b[".chatmsg-authorGroup .chatmsg-item .chatmsg-link-user, .chatsystem-content a.chatmsg-author-name, .chatmsg-author-name"]=["background-color: transparent !important;"]);for(var d in b)c+=d+"{",b[d].forEach(function(a){c+=a+";"}),c+="}";return c}X=new ac([]);var ab=function(){var a=[];return{Xa:function(b){for(var c=0,d=a.length;c<d;c++)if(-1!==a[c].names.indexOf(b))return a[c];return null},pb: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},zb:function(b){b.W="client";b.exec=b.exec.bind(b);a.push(b)}}}();function mc(){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.zb({name:"/sherlock",names:["/sherlock","/sharelock"],usage:"",description:J.ib,exec:function(a,b){mc().then(function(a){var c=a.coords.latitude,e=a.coords.longitude;db(b,"https://www.openstreetmap.org/?mlat="+c+"&mlon="+e+"&macc="+a.coords.accuracy+"#map=17/"+c+"/"+e)}).catch(function(a){console.error("Error: ",a)})}})});
+["content:'<'"],b[".chatmsg-author-name::after"]=["content:'>'"]);!0===a.b||(b[".chatmsg-authorGroup .chatmsg-item .chatmsg-link-user, .chatsystem-content a.chatmsg-author-name, .chatmsg-author-name"]=["background-color: transparent !important;"]);for(var d in b)c+=d+"{",b[d].forEach(function(a){c+=a+";"}),c+="}";return c}X=new ac([]);var $a=function(){var a=[];return{Ya:function(b){for(var c=0,d=a.length;c<d;c++)if(-1!==a[c].names.indexOf(b))return a[c];return null},qb: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},Ab:function(b){b.W="client";b.exec=b.exec.bind(b);a.push(b)}}}();function mc(){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(){$a.Ab({name:"/sherlock",names:["/sherlock","/sharelock"],usage:"",description:J.jb,exec:function(a,b){mc().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 - 9
srv/public/style.css

@@ -26,6 +26,7 @@ button, .button { border: 1px solid black; border-radius: 3px; background: rgb(2
 .chan-search-input { width: 100%; border-style: none; padding: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 0; border-bottom-left-radius: 0; }
 .chan-search-wrapper::before { display: inline-block; position: absolute; left: -25px; bottom: 0; width: 25px; height: 100%; content: " "; background: transparent; } /* FIXME icon */
 
+.chat-context-menuButton { display: none; position: fixed; top: 0; right: 0; width: 62px; height: 62px; z-index: 500; cursor: pointer; }
 .chat-context-menu a { display: block; padding: 1em 0 0 1.5em; color: #AB9BA9; text-transform: uppercase; text-decoration: none; }
 .chat-context-menu a:last-child { padding-bottom: 1em; }
 .chat-context-channellist { padding-left: 0; list-style: none; }
@@ -65,10 +66,6 @@ button, .button { border: 1px solid black; border-radius: 3px; background: rgb(2
 .roominfo-pinlist-item { position: relative; }
 .roominfo-pinlist-item .roominfo-unpin { position: absolute; top: 0; right: 0; height: 1.25em; width: 1.25em; background-image: url("pin.svg"); background-size: contain; background-repeat: no-repeat; background-position: center center; }
 
-@media screen and (max-width: 635px) {
-    .chat-context-roominfo { position: static; width: 100%; display: block; color: white; }
-}
-
 .chat-context .typing-container { position: absolute; left: 6.5px; display: none; }
 .chat-context .chat-context-typing .typing-container { display: block; }
 
@@ -259,8 +256,3 @@ button, .button { border: 1px solid black; border-radius: 3px; background: rgb(2
 .settings-service-list-empty { display: none; }
 .settings-service-list:empty +.settings-service-list-empty { display: block; }
 
-@media screen and (max-width: 500px) {
-    .maci-wrapper { position: fixed; z-index: 5000; top: 50%; left: 0; width: 100%; transform: translate(0, -50%); }
-    .login-services { display: block; width: 100%; }
-}
-

+ 59 - 0
srv/public/styleResponsive.css

@@ -0,0 +1,59 @@
+
+@media screen and (max-width: 720px) {
+    .chat-context {
+        display: none;
+        position: absolute;
+        z-index: 500;
+        top: 0;
+        bottom: 0;
+        left: 0;
+        right: 0;
+        width: auto;
+
+        padding-top: 62px;
+
+        background-repeat: repeat-x;
+    }
+
+    .chat-context.opened {
+        display: block;
+    }
+
+    .chat-context-menuButton {
+        display: inline-block;
+    }
+
+    .chatsystem-container {
+        position: fixed;
+        top: 0;
+        bottom: 0;
+        left: 0;
+        right: 0;
+    }
+
+    .chat-context .chat-context-roominfo {
+        position: static;
+        display: block;
+        width: 100%;
+        color: white;
+    }
+
+    .chatsystem-content .chat-context-roominfo, .chatsystem-content .chatmsg-item:hover .chatmsg-hover {
+        display: none;
+    }
+
+    .maci-wrapper {
+        position: fixed;
+        z-index: 5000;
+        top: 50%;
+        left: 0;
+        width: 100%;
+        transform: translate(0, -50%);
+    }
+
+    .login-services {
+        display: block;
+        width: 100%;
+    }
+}
+

+ 9 - 5
srv/src/controller/apiController.js

@@ -173,16 +173,20 @@ module.exports.ApiController = {
                     let ctx = res.chatContext.getChannelContext(req.urlObj.queryTokens.room[0]);
 
                     if (ctx) {
-                        let attachments = null;
+                        let attachments = null,
+                            pendingId;
                         if (req.urlObj.queryTokens.attachments) {
-                            try { attachments = JSON.parse(decodeURIComponent(req.urlObj.queryTokens.attachments[0])); }
+                            try { attachments = JSON.parse(req.urlObj.queryTokens.attachments[0]); }
                             catch (e) {}
                         }
                         if (req.urlObj.queryTokens.me)
-                            ctx.sendMeMsg(ctx.getChatContext().channels[req.urlObj.queryTokens.room[0]], req.urlObj.queryTokens.text);
+                            pendingId = ctx.sendMeMsg(ctx.getChatContext().channels[req.urlObj.queryTokens.room[0]], req.urlObj.queryTokens.text);
                         else
-                            ctx.sendMsg(ctx.getChatContext().channels[req.urlObj.queryTokens.room[0]], req.urlObj.queryTokens.text, attachments);
-                        res.writeHeader("204", "No Content");
+                            pendingId = ctx.sendMsg(ctx.getChatContext().channels[req.urlObj.queryTokens.room[0]], req.urlObj.queryTokens.text, attachments);
+                        if (pendingId)
+                            res.end("{\"pendingId\":\"" +pendingId +"\"}");
+                        else
+                            res.writeHeader("204", "No Content");
                     } else {
                         res.writeHeader("404", "Channel not found");
                     }

+ 2 - 0
srv/src/ircServer/ircConnection.js

@@ -298,9 +298,11 @@ IrcConnection.prototype.parse = function(str) {
                                             msg = msg.substr(8, msg.length -9);
                                         else
                                             msg = msg.substr(8);
+                                        // FIXME id
                                         msg = ctx.sendMeMsg(chan, [ msg ]);
                                         this.pendingMsgs.push({isMe: true, chan: chan.id, msg: msg});
                                     } else {
+                                        // FIXME id
                                         msg = ctx.sendMsg(chan, [ msg ]);
                                         this.pendingMsgs.push({isMe: false, chan: chan.id, msg: msg});
                                     }

+ 7 - 0
srv/src/message.js

@@ -20,6 +20,9 @@ function Message(e, ts) {
     /** @type {string} */
     this.text = "";
 
+    /** @type {string|undefined} */
+    this.pendingId;
+
     /** @type {Array.<*>} */
     this.attachments = [];
 
@@ -82,6 +85,9 @@ Message.prototype.update = function(e, ts) {
             });
             this.reactions = reactions;
         }
+
+        if (e["pendingId"])
+            this.pendingId = e["pendingId"];
     } else {
         this.removed = true;
     }
@@ -103,6 +109,7 @@ Message.prototype.toStatic = function() {
         ,"username": this.username
         ,"ts": this.ts
         ,"text": this.text
+        ,"pendingId": this.pendingId
         ,"attachments": this.attachments.length ? this.attachments : undefined
         ,"is_starred": this.starred || undefined
         ,"edited": this.edited === false ? undefined : this.edited

+ 25 - 19
srv/src/slack.js

@@ -192,7 +192,7 @@ Slack.prototype.sendCommand = function(room, cmd, arg) {
         +"&command=" +encodeURIComponent(cmd.name)
         +"&disp=" +encodeURIComponent(cmd.name)
         +"&channel=" +room.remoteId
-        +"&text=" +arg);
+        +"&text=" +encodeURIComponent(arg));
 }
 
 Slack.prototype.sendTyping = function(room) {
@@ -282,12 +282,17 @@ Slack.prototype.resetVersions = function(v) {
 };
 
 Slack.prototype.onMessage = function(msg, t) {
-    if (msg["reply_to"] && this.pendingRtm[msg["reply_to"]]) {
-        var ts = msg["ts"]
-            ,rtmId = msg["reply_to"];
-        msg = this.pendingRtm[rtmId];
-        msg["ts"] = ts;
-        delete this.pendingRtm[rtmId];
+    if (msg["reply_to"] !== undefined) {
+        let rtmId = msg["reply_to"];
+        if (this.pendingRtm[rtmId]) {
+            let ts = msg["ts"]
+            msg = this.pendingRtm[rtmId];
+            msg["ts"] = ts;
+            msg["pendingId"] = this.data.team.id +'_' +rtmId;
+            delete this.pendingRtm[rtmId];
+        } else {
+            delete msg["reply_to"];
+        }
     }
     if (msg["type"] === "hello" && msg["start"] && msg["start"]["rtm_start"]) {
         var _this = this;
@@ -654,9 +659,11 @@ Slack.prototype.sendMeMsg = function(channel, text) {
     httpsRequest(SLACK_ENDPOINT +GETAPI.postMeMsg
         +"?token=" +this.token
         +"&channel=" +channel.remoteId
-        +"&text=" +text
+        +"&text=" +encodeURIComponent(text)
         +"&as_user=true");
-    return text;
+    let id = channel.id +'_' +text +'_' +Date.now();
+    // FIXME store if
+    return id;
 };
 
 /**
@@ -760,21 +767,20 @@ Slack.prototype.sendMsg = function(channel, text, attachments) {
             +"&link_names=true"
             + (attachments ? ("&attachments=" +encodeURIComponent(JSON.stringify(attachments))) : "")
             +"&as_user=true");
-        return fullDecodedText;
+        // FIXME store if
+        let msgId = channel.id +'_' +decodedText +'_' +Date.now();
+        return msgId;
     } else {
-        var decodedText = [];
-        text.forEach(function(i) {
-            decodedText.push(decodeURIComponent(i));
-        });
-        var fullDecodedText = idify(this.data, decodedText.join("\n"));
-        this.pendingRtm[this.rtmId] = {
+        var fullDecodedText = idify(this.data, text.join("\n")),
+            rtmId = this.rtmId++;
+        this.pendingRtm[rtmId] = {
             type: 'message',
             channel: channel.remoteId,
             user: this.data.self.remoteId,
             text: fullDecodedText
         };
-        this.send('{"id":' +this.rtmId++ +',"type":"message","channel":"' +channel.remoteId +'", "text":' +JSON.stringify(fullDecodedText) +'}', true);
-        return fullDecodedText;
+        this.send('{"id":' +rtmId +',"type":"message","channel":"' +channel.remoteId +'", "text":' +JSON.stringify(fullDecodedText) +'}', true);
+        return this.data.team.id +'_' +rtmId;
     }
 };
 
@@ -800,7 +806,7 @@ Slack.prototype.editMsg = function(channel, msgId, text) {
         +"?token=" +this.token
         +"&channel=" +channel.remoteId
         +"&ts=" +msgId
-        +"&text=" +text.join("\n")
+        +"&text=" +encodeURIComponent(idify(this.data, text.join("\n")))
         +"&as_user=true");
 };
 

+ 12 - 0
srv/src/slackHistory.js

@@ -47,6 +47,16 @@ SlackHistory.prototype.prepareMessage = function(ev, targetId) {
 }
 
 SlackHistory.prototype.messageFactory = function(ev, ts) {
+    let img;
+    if (ev["file"] && ev["file"]["mimetype"].indexOf("image/") >= 0)
+        img = ev["file"]["thumb_360"] || ev["file"]["url_private"] || ev["file"]["permalink"] || undefined;
+    if (img) {
+        if (!ev["attachments"])
+            ev["attachments"] = [];
+        ev["attachments"].push({
+            "image_url": img
+        });
+    }
     if (!ev["user"]) {
         if (ev["bot_id"])
             ev["user"] = ev["bot_id"];
@@ -98,6 +108,8 @@ SlackHistory.prototype.push = function(ev, t, resultRef) {
         }
         msg = this.getMessageById(targetId);
         if (msg) {
+            if (ev["subtype"] === "message_changed" && msg.starred)
+                modifArg["is_starred"] = true;
             msg.update(this.prepareMessage(modifArg), t);
             exists = true;
         } else {

+ 2 - 3
srv/src/template/_templates.js

@@ -11,9 +11,8 @@ module.exports = {
                 res += '<link href="' +config.rootUrl +i +'" rel="stylesheet"/>';
             }
         });
-        (moreHeader || []).forEach(function(i) {
-            res += '<link href="favicon_err.png" type="image/png" rel="icon" id="linkFavicon" />';
-        });
+        (moreHeader || []).forEach(function(i) {});
+        res += '<link href="favicon_err.png" type="image/png" rel="icon" id="linkFavicon" /><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">';
         return res +`</head><body>`;
     }
     ,footer: function(jsFiles, rawJs) {

+ 5 - 2
srv/src/template/index.js

@@ -23,7 +23,7 @@ module.exports.exec = function(req, res) {
         serviceProviderOptionList += `<option value="${config.services[serviceName].connectLink}">${serviceName}</option>`;
     return {
         status: 200
-        ,body: templates.header("Mimouchat", ["style.css", "_customsheet"], ['<link href="favicon_err.png" type="image/png" rel="icon" id="linkFavicon" />'])
+        ,body: templates.header("Mimouchat", ["style.css", "styleResponsive.css", "_customsheet"], ['<link href="favicon_err.png" type="image/png" rel="icon" id="linkFavicon" />'])
         +`<aside class="chat-context" id="chatCtx">
               <div class="chat-context-rooms" id="chatList">
                   <div class="chan-search-wrapper"><input type="search" id="chanSearch" class="chan-search-input" /></div>
@@ -34,6 +34,7 @@ module.exports.exec = function(req, res) {
                   <a id="ctxMenuLogout" href="javascript:void(0);"></a>
               </nav>
           </aside>
+          <div class="chat-context-menuButton" id="chatCtxButton"></div>
           <section id="settings" class="maci-setting hidden">
               <header class="settingHead">
                   <h3 id="settingTitle"></h3>
@@ -76,7 +77,9 @@ module.exports.exec = function(req, res) {
               </footer>
           </section>
           <div class="chatsystem-container no-room-selected" id="chatSystemContainer">
-              <header class="chatsystem-header"><span class="chatsystem-title" id="currentRoomTitle"></span><span id="currentRoomStar" class="chatsystem-header-star"></span></header>
+              <header class="chatsystem-header" id="chatsystemHeader">
+                  <span class="chatsystem-title" id="currentRoomTitle"></span><span id="currentRoomStar" class="chatsystem-header-star"></span>
+              </header>
               <div class="chatsystem-content" id="chatWindow"></div>
               <ul class="chatsystem-whoistyping" id="whoistyping"></ul>
               <div class="chatsystem-control">

+ 1 - 1
srv/src/url.js

@@ -26,7 +26,7 @@ function Url(url) {
             if (!this.queryTokens[token[0]]) {
                 this.queryTokens[token[0]] = [];
             }
-            this.queryTokens[token[0]].push(token[1] || true);
+            this.queryTokens[token[0]].push(token[1] ? decodeURIComponent(token[1]) : true);
         }
     }
     this.serve = null;