Просмотр исходного кода

[add] room and user informations
[bugfix] use realname if name is not defined
[add] you can click on a users' nick in messages to go in their private room
[bugfix] init emojibar with no emoji provider
[bugfix] switch emoji provider with wmoji picker open
[add] can jump to a private room using user'id in hashbang
[add] user phone and their modo
[bugfix] removed slack-like profile blob
[add] search along channels with their names, topic, purpose, members

B Thibault 8 лет назад
Родитель
Сommit
05bc0b30e9
17 измененных файлов с 413 добавлено и 171 удалено
  1. 1 0
      Makefile
  2. 7 6
      cli/dom.js
  3. 24 9
      cli/emojiBar.js
  4. 1 0
      cli/emojiEngine.js
  5. 3 0
      cli/lang/en.js
  6. 4 0
      cli/lang/fr.js
  7. 21 2
      cli/resources.js
  8. 135 0
      cli/roomInfo.js
  9. 35 15
      cli/ui.js
  10. 2 2
      cli/uiMessage.js
  11. 15 1
      cli/workflow.js
  12. 114 106
      srv/public/mimouchat.min.js
  13. 18 5
      srv/public/style.css
  14. 21 19
      srv/src/chatter.js
  15. 2 2
      srv/src/room.js
  16. 10 3
      srv/src/slackData.js
  17. 0 1
      srv/src/template/index.js

+ 1 - 0
Makefile

@@ -23,6 +23,7 @@ SRC=		srv/src/context.js			\
 			cli/contextBackground.js	\
 			cli/workflow.js				\
 			cli/emojiEngine.js			\
+			cli/roomInfo.js				\
 			cli/uiMessage.js			\
 			cli/utils.js				\
 			cli/config.js				\

+ 7 - 6
cli/dom.js

@@ -76,8 +76,8 @@ function createImsListItem(ims, alternateChanName) {
 
     dom.id = "room_" +ims.id;
     link.href = '#' +ims.id;
-    dom.className = R.klass.chatList.entry + " " +R.klass.chatList.typeDirect;
-    link.textContent = alternateChanName || ims.user.name;
+    dom.className = R.klass.chatList.entry + " " +R.klass.chatList.typeDirect +" " +R.klass.presenceIndicator;
+    link.textContent = alternateChanName || ims.user.getName();
     dom.appendChild(createTypingDisplay());
     dom.appendChild(link);
 
@@ -112,7 +112,7 @@ function createReactionDom(chanId, msgId, reaction, users) {
         for (var i =0, nbUser = users.length; i < nbUser; i++) {
             var user = DATA.context.getUser(users[i]);
             if (user)
-                userNames.push(user.name);
+                userNames.push(user.getName());
         }
         userNames.sort();
         userList.textContent = userNames.join(", ");
@@ -212,15 +212,16 @@ function doCreateMessageDom(msg, skipAttachment) {
 function createMessageGroupDom(user, userName) {
     var dom = document.createElement("div")
         ,authorBlock = document.createElement("div")
-        ,authorName = document.createElement("span")
+        ,authorName = document.createElement("a")
         ,authorImg = document.createElement("img");
 
     dom.authorImgWrapper = document.createElement("span")
     dom.authorImgWrapper.className = R.klass.msg.authorAvatarWrapper;
     authorImg.className = R.klass.msg.authorAvatar;
     authorName.className = R.klass.msg.authorname;
+    authorName.href = "#" +user.id;
     if (user) {
-        authorName.textContent = user.name;
+        authorName.textContent = user.getName();
         authorImg.src = user.getSmallIcon();
     } else {
         authorName.textContent = userName || "?";
@@ -488,7 +489,7 @@ function createActionButtonDom(attachmentIndex, actionIndex, action) {
 function makeUserIsTypingDom(user) {
     var dom = document.createElement("li")
         ,userName = document.createElement("span");
-    userName.textContent = user.name;
+    userName.textContent = user.getName();
     dom.appendChild(createTypingDisplay());
     dom.appendChild(userName);
     return dom;

+ 24 - 9
cli/emojiBar.js

@@ -94,7 +94,7 @@ var EMOJI_BAR = (function() {
         /** @type {Object.<string, *>} */
         foundEmojis = window['searchEmojis'](queryString),
         /** @type {Array.<{name:string, pos:number, count:number}>} */
-        sortedEmojiNames = sortEmojis(foundEmojis, context.self.prefs.favoriteEmojis),
+        sortedEmojiNames = sortEmojis(foundEmojis, context ? context.self.prefs.favoriteEmojis : []),
         i,
         nbEmojis;
 
@@ -130,8 +130,10 @@ var EMOJI_BAR = (function() {
                 customEmojis.removeChild(emojiCache.custom[i].dom);
             }
         }
+        if (!context)
+            return 0;
         /** @type {Array.<{name:string, pos:number, count:number}>} */
-        var sortedEmojiNames = sortEmojis(context.emojis.data, context.self.prefs.favoriteEmojis);
+        var sortedEmojiNames = sortEmojis(context.emojis.data, context ? context.self.prefs.favoriteEmojis : []);
         for (i =0, nbEmojis = sortedEmojiNames.length; i < nbEmojis; i++) {
             var emojiName = sortedEmojiNames[i].name;
             if ((queryString === '' || emojiName.substr(0, queryString.length) === queryString) && context.emojis.data[emojiName].substr(0, 6) !== 'alias:') {
@@ -203,6 +205,18 @@ var EMOJI_BAR = (function() {
     onEmojiSelected = function(emojiName) {
         if (doClose() && emojiSelectedHandler)
             emojiSelectedHandler(emojiName);
+    },
+
+    reset = function() {
+        emojiCache.unicode = {};
+        emojisDom.textContent = "";
+        if (window['emojiProviderHeader']) {
+            emojisDom.appendChild(makeHeader(window['emojiProviderHeader']));
+            unicodeEmojis.textContent = "";
+            emojisDom.appendChild(unicodeEmojis);
+        }
+        emojisDom.appendChild(makeHeader("emojicustom.png"));
+        emojisDom.appendChild(customEmojis);
     }
     ;
 
@@ -216,17 +230,14 @@ var EMOJI_BAR = (function() {
     overlay.className = R.klass.emojibar.overlay;
     dom.className = R.klass.emojibar.container;
     emojisDom.className = R.klass.emojibar.emojis;
+    unicodeEmojis.className = customEmojis.className = R.klass.emojibar.list;
+    searchBar.className = R.klass.emojibar.search;
     emojiDetail.className = R.klass.emojibar.detail.container;
     emojiDetailImg.className = R.klass.emojibar.detail.img;
     emojiDetailName.className = R.klass.emojibar.detail.name;
-    unicodeEmojis.className = customEmojis.className = R.klass.emojibar.list;
-    searchBar.className = R.klass.emojibar.search;
     emojiDetail.appendChild(emojiDetailImg);
     emojiDetail.appendChild(emojiDetailName);
-    emojisDom.appendChild(makeHeader(window['emojiProviderHeader']));
-    emojisDom.appendChild(unicodeEmojis);
-    emojisDom.appendChild(makeHeader("emojicustom.png"));
-    emojisDom.appendChild(customEmojis);
+    reset();
     dom.appendChild(emojisDom);
     dom.appendChild(emojiDetail);
     dom.appendChild(searchBar);
@@ -269,7 +280,11 @@ var EMOJI_BAR = (function() {
         isSupported: isSupported,
         spawn: spawn,
         search: search,
-        close: close
+        close: close,
+        reset: function() {
+            reset();
+            search();
+        }
     };
 })();
 

+ 1 - 0
cli/emojiEngine.js

@@ -41,6 +41,7 @@ function setEmojiProvider(provider) {
                 document.head.appendChild(link);
                 document.body.appendChild(script);
                 invalidateAllMessages();
+                EMOJI_BAR.reset();
             }
         };
         xhr.open('GET', provider.js, true);

+ 3 - 0
cli/lang/en.js

@@ -67,4 +67,7 @@ lang["en"].edited = function(ts) {
     return "(edited " +lang["en"].formatDate(ts) +")";
 };
 
+lang["en"].topicDetail = function(creator, ts) {
+    return "by " +creator.getName() +" on " +lang["en"].formatDate(ts);
+};
 

+ 4 - 0
cli/lang/fr.js

@@ -67,3 +67,7 @@ lang["fr"].edited = function(ts) {
     return "(edit&eacute; " +lang["fr"].formatDate(ts) +")";
 };
 
+lang["fr"].topicDetail = function(creator, ts) {
+    return "par " +creator.getName() +" le " +lang["fr"].formatDate(ts);
+};
+

+ 21 - 2
cli/resources.js

@@ -50,11 +50,12 @@ var R = {
         buttonContainer: "button-container",
         noRoomSelected: "no-room-selected",
         noNetwork: "no-network",
+        presenceIndicator: "presence-indicator",
         starred: "starred",
         unread: "unread",
         unreadHi: "unreadHi",
         replyingTo: "replyingTo",
-        presenceAway: "away",
+        presenceAway: "presence-away",
         typing: {
             container: "typing-container",
             dot1: "typing-dot1",
@@ -94,7 +95,25 @@ var R = {
             typeChannel: "chat-channel",
             typePrivate: "chat-group",
             typeDirect: "chat-ims",
-            typing: "chat-context-typing"
+            typing: "chat-context-typing",
+
+            roomInfo: {
+                container: "chat-context-roominfo",
+                title: "roominfo-title",
+                presence: "roominfo-presence",
+                topic: "roominfo-topic",
+                topicCreator: "roominfo-topic-creator",
+                purpose: "roominfo-purpose",
+                purposeCreator: "roominfo-purpose-creator",
+                userCount: "roominfo-usercount",
+                userList: "roominfo-userlist",
+                author: "roominfo-author",
+                phone: "roominfo-phone",
+                type: {
+                    channel: "roominfo-channel",
+                    user: "roominfo-user"
+                }
+            }
         },
         msg: {
             item: "chatmsg-item",

+ 135 - 0
cli/roomInfo.js

@@ -0,0 +1,135 @@
+
+var roomInfo = (function() {
+    var /** @const @type {Element} */
+        dom = document.createElement("div"),
+        /** @const @type {Element} */
+        domHeader = document.createElement("header"), // Contain chan name + backgroundImg if any
+        /** @const @type {Element} */
+        headerContent = document.createElement("h3"), // Contain chan name + backgroundImg if any
+        /** @const @type {Element} */
+        section = document.createElement("div"),
+        /** @const @type {Element} */
+        topicDom = document.createElement("div"),
+        /** @const @type {Element} */
+        topicContent = document.createElement("span"),
+        /** @const @type {Element} */
+        topicDetails = document.createElement("span"),
+        /** @const @type {Element} */
+        phone = document.createElement("div"),
+        /** @const @type {Element} */
+        purposeDom = document.createElement("div"),
+        /** @const @type {Element} */
+        purposeContent = document.createElement("span"),
+        /** @const @type {Element} */
+        purposeDetails = document.createElement("span"),
+        /** @const @type {Element} */
+        userCount = document.createElement("div"),
+        /** @const @type {Element} */
+        userList = document.createElement("ul"),
+        /** @type {ChatSystem} */
+        currentChatCtx,
+        /** @type {Room} */
+        currentChan;
+
+    dom.className = R.klass.chatList.roomInfo.container;
+    domHeader.className = R.klass.chatList.roomInfo.title;
+    topicDom.className = R.klass.chatList.roomInfo.topic;
+    purposeDom.className = R.klass.chatList.roomInfo.purpose;
+    phone.className = R.klass.chatList.roomInfo.phone;
+    userCount.className = R.klass.chatList.roomInfo.userCount;
+    userList.className = R.klass.chatList.roomInfo.userList;
+    purposeDetails.className = topicDetails.className = R.klass.chatList.roomInfo.author;
+
+    domHeader.appendChild(headerContent);
+    dom.appendChild(domHeader);
+    dom.appendChild(section);
+    topicDom.appendChild(topicContent);
+    topicDom.appendChild(topicDetails);
+    purposeDom.appendChild(purposeContent);
+    purposeDom.appendChild(purposeDetails);
+    section.appendChild(topicDom);
+    section.appendChild(phone);
+    section.appendChild(purposeDom);
+    section.appendChild(userCount);
+    section.appendChild(userList);
+
+    var updateCommon = function() {
+        headerContent.textContent = currentChan.name;
+
+    }, updateForChannel = function() {
+        var ctx = currentChatCtx.getChatContext();
+
+        if (ctx.capacities["topic"]) {
+            topicDom.classList.remove(R.klass.hidden);
+            topicContent.textContent = currentChan.topic || "";
+            topicDetails.textContent = currentChan.topicCreator ? locale.topicDetail(currentChan.topicCreator, currentChan.topicTs) : "";
+        } else {
+            topicDom.classList.add(R.klass.hidden);
+        }
+        if (ctx.capacities["purpose"]) {
+            purposeDom.classList.remove(R.klass.hidden);
+            purposeContent.textContent = currentChan.purpose || "";
+            purposeDetails.textContent = currentChan.purposeCreator ? locale.topicDetail(currentChan.purposeCreator, currentChan.purposeTs) : "";
+        } else {
+            purposeDom.classList.add(R.klass.hidden);
+        }
+        domHeader.style.backgroundImage = "";
+        headerContent.classList.remove(R.klass.presenceIndicator);
+        userCount.classList.remove(R.klass.hidden);
+        userList.classList.remove(R.klass.hidden);
+
+        dom.classList.add(R.klass.chatList.roomInfo.type.channel);
+        dom.classList.remove(R.klass.chatList.roomInfo.type.user);
+
+    }, updateForDm = function() {
+        domHeader.style.backgroundImage = "url(" +currentChan.user.getLargeIcon() +")";
+        topicContent.textContent = (currentChan.user.realName || ((currentChan.user.firstName || "") +' ' +(currentChan.user.lastName))).trim();
+        headerContent.classList.add(R.klass.presenceIndicator);
+        if (currentChan.user.presence)
+            headerContent.classList.remove(R.klass.presenceAway);
+        else
+            headerContent.classList.add(R.klass.presenceAway);
+        topicDom.classList.remove(R.klass.hidden);
+        phone.classList.remove(R.klass.hidden);
+        phone.textContent = currentChan.user.phone || "";
+        purposeContent.textContent = currentChan.user.goal || "";
+        purposeDom.classList.remove(R.klass.hidden);
+        userCount.classList.add(R.klass.hidden);
+        userList.classList.add(R.klass.hidden);
+
+        dom.classList.remove(R.klass.chatList.roomInfo.type.channel);
+        dom.classList.add(R.klass.chatList.roomInfo.type.user);
+
+    }, _update = function() {
+        updateCommon();
+        if (currentChan instanceof PrivateMessageRoom)
+            updateForDm();
+        else
+            updateForChannel();
+    };
+
+    return {
+        /** @type {function(ChatSystem, Room)} */
+        populate: function(channelContext, channel) {
+            currentChatCtx = channelContext;
+            currentChan = channel;
+            _update();
+            return this;
+        },
+        update: function() {
+            _update();
+            return this;
+        },
+        /** @type {function(Element)} */
+        show: function(domParent) {
+            domParent.appendChild(dom);
+            dom.classList.remove(R.klass.hidden);
+            return this;
+        },
+        hide: function() {
+            dom.classList.add(R.klass.hidden);
+            return this;
+        }
+    }
+})();
+

+ 35 - 15
cli/ui.js

@@ -155,12 +155,12 @@ function onNetworkStateUpdated(isNetworkWorking) {
 }
 
 function onRoomSelected() {
-    var name = SELECTED_ROOM.name || (SELECTED_ROOM.user ? SELECTED_ROOM.user.name : undefined);
+    var name = SELECTED_ROOM.name || (SELECTED_ROOM.user ? SELECTED_ROOM.user.getName() : undefined);
     if (!name) {
         /** @type {Array.<string>} */
         var members = [];
         SELECTED_ROOM.users.forEach(function(i) {
-            members.push(i.name);
+            members.push(i.getName());
         });
         name = members.join(", ");
     }
@@ -516,19 +516,6 @@ function focusInput() {
     document.getElementById(R.id.message.input).focus();
 }
 
-function setRoomFromHashBang() {
-    var hashId = document.location.hash.substr(1),
-        room = DATA.context.getChannel(hashId);
-
-    if (room && room !== SELECTED_ROOM)
-        selectRoom(room);
-    else {
-        var user = DATA.context.getUser(hashId);
-        if (user && user.ims)
-            selectRoom(user.ims);
-    }
-}
-
 function updateAuthorAvatarImsOffset() {
     var chatDom = document.getElementById(R.id.currentRoom.content),
         chatTop = chatDom.getBoundingClientRect().top;
@@ -559,6 +546,39 @@ document.addEventListener('DOMContentLoaded', function() {
             setRoomFromHashBang();
         }
     });
+
+    document.addEventListener("mouseover", function(e) {
+        var t = e.target;
+        while (t && t !== this) {
+            if (t.nodeName === 'A') {
+                var href = t.href,
+                    sepPosition = href.indexOf('#');
+                if (sepPosition >= 0) {
+                    href = href.substr(sepPosition +1);
+                    var channelCtx = DATA.context.getChannelContext(href);
+                    if (channelCtx) {
+                        roomInfo.populate(channelCtx, channelCtx.getChatContext().channels[href]).show(t);
+                        return;
+                    }
+                    channelCtx = DATA.context.getUserContext(href);
+                    if (channelCtx) {
+                        var room = channelCtx.getChatContext().users[href].privateRoom;
+                        if (room) {
+                            roomInfo.populate(channelCtx, room).show(t);
+                            return;
+                        }
+                    }
+                }
+                break;
+            }
+            t = t.parentElement;
+        }
+        roomInfo.hide();
+    });
+    document.addEventListener("mouseleave", function() {
+        roomInfo.hide();
+    });
+
     document.getElementById(R.id.currentRoom.starButton).addEventListener("click", function(e) {
         e.preventDefault();
         if (SELECTED_ROOM) {

+ 2 - 2
cli/uiMessage.js

@@ -97,7 +97,7 @@ var AbstractUiMessage = (function() {
             if (user) {
                 isInternal = true;
                 link = '#' +user.privateRoom.id;
-                text = '@' +user.name;
+                text = '@' +user.getName();
             } else {
                 return null;
             }
@@ -163,7 +163,7 @@ var AbstractUiMessage = (function() {
     updateCommon = function(_this, sender) {
         _this.dom.ts.innerHTML = locale.formatDate(_this.ts);
         _this.dom.textDom.innerHTML = _formatText(_this, _this.text);
-        _this.dom.authorName.textContent = sender ? sender.name : (_this.username || "?");
+        _this.dom.authorName.textContent = sender ? sender.getName() : (_this.username || "?");
     };
 
     return {

+ 15 - 1
cli/workflow.js

@@ -174,6 +174,7 @@ function selectRoom(room) {
     SELECTED_ROOM = room;
     SELECTED_CONTEXT = /** @type {SimpleChatSystem} */ (DATA.context.getChannelContext(room.id));
     onRoomSelected();
+    roomInfo.hide();
     createContextBackground(SELECTED_CONTEXT.getChatContext().team.id, SELECTED_CONTEXT.getChatContext().users, function(imgData) {
         document.getElementById(R.id.context).style.backgroundImage = 'url(' +imgData +')';
     });
@@ -182,6 +183,19 @@ function selectRoom(room) {
     document.getElementById(R.id.mainSection).classList.remove(R.klass.noRoomSelected);
 }
 
+function setRoomFromHashBang() {
+    var hashId = document.location.hash.substr(1),
+        room = DATA.context.getChannel(hashId);
+
+    if (room && room !== SELECTED_ROOM)
+        selectRoom(room);
+    else {
+        var user = DATA.context.getUser(hashId);
+        if (user && user.privateRoom)
+            selectRoom(user.privateRoom);
+    }
+}
+
 /**
  * @param {Room} room
 **/
@@ -294,7 +308,7 @@ function sendMsg(chan, msg, replyTo) {
 
         var attachment = {
             "fallback": replyTo.text,
-            "author_name": sender.name,
+            "author_name": sender.getName(),
             "text": replyTo.text,
             "footer": footer,
             "ts": replyTo.ts

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

@@ -1,112 +1,120 @@
 "use strict";(function(){
-var p;function aa(a){this.id=a;this.version=0}aa.prototype.update=function(a,b){void 0!==a.name&&(this.name=a.name);this.version=Math.max(this.version,b)};function da(a){this.a=a.desc;this.name=a.name;this.type=a.type;this.usage=a.usage;this.S=a.category}function ea(){this.a={};this.A=[];this.version=0}
-ea.prototype.update=function(a,b){a.emoji_use&&(this.a=JSON.parse(a.emoji_use));a.highlight_words?this.A=(a.highlight_words||"").split(",").filter(function(a){return""!==a.trim()}):a.highlights&&(this.A=a.highlights);this.version=Math.max(this.version,b)};function fa(){this.a=null;this.j={};this.m={};this.self=null;this.b={version:0,data:{}};this.i={version:0,data:{}};this.s={};this.Ha={};this.w=0}function ga(a,b){return b.pv?new r(b.id,a.m[b.user]):new u(b.id)}
-function ha(a,b,c){var d=d||"";b.team&&(a.a||(a.a=new aa(b.team.id)),a.a.update(b.team,c));if(b.users)for(var e=0,f=b.users.length;e<f;e++){var g=a.m[d+b.users[e].id];g||(g=a.m[d+b.users[e].id]=new ia(b.users[e].id));g.update(b.users[e],c)}if(b.channels)for(e=0,f=b.channels.length;e<f;e++)(g=a.j[d+b.channels[e].id])||(g=a.j[d+b.channels[e].id]=ga(a,b.channels[e])),g.update(b.channels[e],a,c,d);b.emojis&&(a.b.data=b.emojis,a.b.version=c);if(void 0!==b.commands){a.i.data={};for(e in b.commands)a.i.data[e]=
-new da(b.commands[e]);a.i.version=c}b.self&&(a.self=a.m[d+b.self.id]||null,a.self.O||(a.self.O=new ea),b.self.prefs&&a.self.O.update(b.self.prefs,c));b.capacities&&(a.Ha={},b.capacities.forEach(function(a){this.Ha[a]=!0},a));a.w=Math.max(a.w,c)}"undefined"!==typeof module&&(module.H.ib=fa,module.H.jb=aa,module.H.lb=da);function u(a){this.id=a;this.G=!1;this.B=0;this.m={};this.version=0}
-u.prototype.update=function(a,b,c,d){d=d||"";void 0!==a.name&&(this.name=a.name);void 0!==a.is_archived&&(this.Y=a.is_archived);void 0!==a.is_member&&(this.i=a.is_member);void 0!==a.last_read&&(this.B=Math.max(parseFloat(a.last_read),this.B));void 0!==a.last_msg&&(this.N=parseFloat(a.last_msg));void 0!==a.is_private&&(this.b=a.is_private);this.G=!!a.is_starred;if(a.members&&(this.m={},a.members))for(var e=0,f=a.members.length;e<f;e++){var g=b.m[d+a.members[e]];this.m[g.id]=g;g.j[this.id]=this}a.topic&&
-(this.ta=a.topic.value);a.purpose&&(this.qa=a.purpose.value);this.version=Math.max(this.version,c)};function ja(a,b){var c=ka;return{name:c.$(b,a.name),bb:c.$(b,Object.values(a.m),function(a){return a?a.name:null}),ta:c.$(b,a.ta),qa:c.$(b,a.qa)}}function r(a,b){u.call(this,a);this.a=b;this.name=this.a.name;this.b=!0;b.pa=this}r.prototype=Object.create(u.prototype);r.prototype.constructor=r;"undefined"!==typeof module&&(module.H.rb=u,module.H.qb=r);function v(a,b){this.J=a.user;this.username=a.username;this.id=a.id||a.ts;this.l=parseFloat(a.ts);this.text="";this.o=[];this.i=this.D=this.G=!1;this.C={};this.version=b;this.update(a,b)}function z(a,b){v.call(this,a,b)}function A(a,b){v.call(this,a,b)}
-v.prototype.update=function(a,b){if(a){if(this.text=a.text||"",a.attachments&&(this.o=a.attachments),this.G=!!a.is_starred,this.D=void 0===a.edited?!1:a.edited,this.i=!!a.removed,a.reactions){var c={};a.reactions.forEach(function(a){c[a.name]=[];a.users.forEach(function(b){c[a.name].push(b)})});this.C=c}}else this.i=!0;this.version=b};function D(a,b,c,d,e){this.id="string"===typeof a?a:a.id;this.a=[];this.b=c;this.Ua=0;this.w=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}D.prototype.i=function(a,b){return!0===a.isMeMessage?new z(a,b):!0===a.isNotice?new A(a,b):new v(a,b)};
-D.prototype.push=function(a,b){for(var c,d=!1,e,f=0,g=this.a.length;f<g;f++)if(c=this.a[f],c.id===a.id){e=c.update(a,b);d=!0;break}d||(c=this.i(a,b),this.a.push(c),e=c.l);for(;this.a.length>this.w;)this.a.shift();if(this.b)for(a=0;a<this.a.length;a++)this.a[a].version<b-this.b&&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.l-c.l})}
-z.prototype=Object.create(v.prototype);z.prototype.constructor=z;A.prototype=Object.create(v.prototype);A.prototype.constructor=A;"undefined"!==typeof module&&(module.H={nb:v,mb:z,pb:A,sb:D});function ia(a){this.id=a;this.j={};this.pa=this.O=null;this.version=0}ia.prototype.update=function(a,b){void 0!==a.name&&(this.name=a.name);void 0!==a.deleted&&(this.Ja=a.deleted);void 0!==a.status&&(this.status=a.status);void 0!==a.presence&&(this.a="away"!==a.presence);void 0!==a.isPresent&&(this.a=a.isPresent);a.isBot&&(this.$a=a.isBot);this.version=Math.max(this.version,b)};"undefined"!==typeof module&&(module.H.kb=ia);function pa(){this.a=[]}pa.prototype.push=function(a){this.a.push(a)};function qa(a,b){for(var c=0,d=a.a.length;c<d;c++)if(b===ra(a.a[c]))return a.a[c];return null}function sa(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 ta(a){for(var b=E.context,c=0,d=b.a.length;c<d&&!0!==a(b.a[c]);c++);}function H(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 ua(a){for(var b=E.context,c=0,d=b.a.length;c<d;c++){var e=b.a[c].j[a];if(e)return e}return null}function va(a){for(var b=E.context,c=[],d=0,e=b.a.length;d<e;d++){var f=b.a[d].j,g;for(g in f)a&&!a(f[g],b.a[d],g)||c.push(g)}return c}function I(a){for(var b=E.context,c=0,d=b.a.length;c<d;c++){var e=b.a[c].m[a];if(e)return e}return null}"undefined"!==typeof module&&(module.H.ob=pa);var ka=function(){function a(b,c,d){if(Array.isArray(c)){for(var e=0,f=0,g=c.length;f<g;f++){var m=a(b,c[f],d);if(1===m)return 1;e=Math.max(m,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{$:a}}();"undefined"!==typeof module&&(module.H.tb=ka);var J={},K,wa=[];function xa(){if(!c){for(var a=0,b=navigator.languages.length;a<b;a++)if(J.hasOwnProperty(navigator.languages[a])){var c=navigator.languages[a];break}c||(c="en")}K=J[c];console.log("Loading language pack: "+c);if(K.c)for(var d in K.c)if(c=document.getElementById(d))c.textContent=K.c[d];wa.forEach(function(a){a()})};J.fr={hb:"Utilisateur inconnu",gb:"Channel inconnu",Pa:"Nouveau message",message:"Message",Oa:"Reseau",Qa:"(visible seulement par vous)",G:"Favoris",j:"Discutions",Sa:"Discutions priv\u00e9es",Ta:"Partage sa position GPS",ok:"Ok",Ka:"Annuler",W:function(a){"string"!==typeof a&&(a=parseFloat(a));var b=new Date,c=new Date;a=new Date(a);b.setHours(0,0,0,0);c.setTime(b.getTime());c.setDate(c.getDate()-1);return a.getTime()>b.getTime()?a.toLocaleTimeString():a.getTime()>c.getTime()?"hier, "+a.toLocaleTimeString():
-a.toLocaleString()},ka:function(a,b){return a+"/"+b},c:{fileUploadCancel:"Annuler",neterror:"Impossible de se connecter au chat !",ctxMenuSettings:"Configuration",settingTitle:"Configuration","setting-menu-services":"Services","settings-services-title":"Services","setting-menu-display":"Affichage","settings-display-title":"Affichage","setting-menu-privacy":"Vie priv\u00e9e","settings-privacy-title":"Vie priv\u00e9e",settingCommit:"Appliquer","settings-serviceAddButton":"Ajouter un service","settings-serviceListEmpty":"Vous n'avez pas encore ajout\u00e9 de service. Ajouter un service pour continuer.",
-"settings-serviceAddConfirm":"Suivant"}};J.fr.D=function(a){return"(edit&eacute; "+J.fr.W(a)+")"};J.en={hb:"Unknown member",gb:"Unknown channel",Pa:"New message",message:"Message",Oa:"Network",Qa:"(only visible to you)",G:"Starred",j:"Channels",Sa:"Direct messages",Ta:"Share your GPS location",ok:"Ok",Ka:"Cancel",W:function(a){"string"!==typeof a&&(a=parseFloat(a));var b=new Date,c=new Date;a=new Date(a);b.setHours(0,0,0,0);c.setTime(b.getTime());c.setDate(c.getDate()-1);return a.getTime()>b.getTime()?a.toLocaleTimeString():a.getTime()>c.getTime()?"yesterday, "+a.toLocaleTimeString():a.toLocaleString()},
-ka:function(a,b){return a+"/"+b},c:{fileUploadCancel:"Cancel",neterror:"Cannot connect to chat !",ctxMenuSettings:"Settings",settingTitle:"Settings","setting-menu-services":"Services","settings-services-title":"Services","setting-menu-display":"Display","settings-display-title":"Display","setting-menu-privacy":"Privacy","settings-privacy-title":"Privacy",settingCommit:"Apply","settings-serviceAddButton":"Add a service","settings-serviceListEmpty":"You don't have any service yet. Please add a service to continue.",
-"settings-serviceAddConfirm":"Next"}};J.en.D=function(a){return"(edited "+J.en.W(a)+")"};var ya=function(){function a(a){this.text="";this.g=a}function b(b,c,d){this.U=c;this.f=null;this.h=[];this.a=d||"";this.fa="<"===this.a;this.ra="*"===this.a;this.ea="_"===this.a;this.ga="~"===this.a||"-"===this.a;this.i=">"===this.a||"&gt;"===this.a;this.X=":"===this.a;this.ua="`"===this.a;this.Fa="```"===this.a;this.va="\n"===this.a;this.da=void 0!==d&&-1!==n.A.indexOf(d);this.g=b;this.ha=null;this.b=this.va||this.da?c+d.length-1:!1;this.da&&(this.f=new a(this),this.h.push(this.f),this.f.text=d)}
-function c(a){return"A"<=a&&"Z">=a||"a"<=a&&"z">=a||"0"<=a&&"9">=a||-1!=="\u00e0\u00e8\u00ec\u00f2\u00f9\u00c0\u00c8\u00cc\u00d2\u00d9\u00e1\u00e9\u00ed\u00f3\u00fa\u00fd\u00c1\u00c9\u00cd\u00d3\u00da\u00dd\u00e2\u00ea\u00ee\u00f4\u00fb\u00c2\u00ca\u00ce\u00d4\u00db\u00e3\u00f1\u00f5\u00c3\u00d1\u00d5\u00e4\u00eb\u00ef\u00f6\u00fc\u00ff\u00c4\u00cb\u00cf\u00d6\u00dc\u0178\u00e7\u00c7\u00df\u00d8\u00f8\u00c5\u00e5\u00c6\u00e6\u0153".indexOf(a)}function d(a){a=a||h;for(var c=0,e=a.h.length;c<e;c++){var k=
-a.h[c];if(k instanceof b)if(k.b){if(k=d(k))return k}else return k}return null}function e(a,c){a.g instanceof b&&(a.g.h.splice(a.g.h.indexOf(a)+(c?1:0)),a.g.f=a.g.h[a.g.h.length-1],e(a.g,!0))}function f(a){return a}function g(a){return{link:a,text:a,Ma:!1}}var m,h,n={A:[],V:f,ca:f,aa:g};b.prototype.xa=function(){return this.ra&&!!this.b||this.g instanceof b&&this.g.xa()};b.prototype.Aa=function(){return this.ea&&!!this.b||this.g instanceof b&&this.g.Aa()};b.prototype.Ba=function(){return this.ga&&
-!!this.b||this.g instanceof b&&this.g.Ba()};b.prototype.na=function(){return this.X&&!!this.b||this.g instanceof b&&this.g.na()};b.prototype.za=function(){return this.da&&!!this.b||this.g instanceof b&&this.g.za()};b.prototype.ya=function(){return this.ua&&!!this.b||this.g instanceof b&&this.g.ya()};b.prototype.ma=function(){return this.Fa&&!!this.b||this.g instanceof b&&this.g.ma()};b.prototype.Ca=function(){for(var a=0,c=this.h.length;a<c;a++)if(this.h[a]instanceof b&&(!this.h[a].b||this.h[a].Ca()))return!0;
-return!1};b.prototype.Da=function(a){if("<"===this.a&&">"===m[a])return!0;var b=c(m[a-1]);if(!this.i&&m.substr(a,this.a.length)===this.a){if(!b&&(this.ra||this.ea||this.ga))return!1;if(this.f&&this.Ca())return this.f.Ga();if(this.Va())return!0}return"\n"===m[a]&&this.i?!0:!1};b.prototype.Va=function(){for(var a=this;a;){for(var c=0,d=a.h.length;c<d;c++)if(a.h[c]instanceof b||a.h[c].text.length)return!0;a=a.ha}return!1};b.prototype.Ga=function(){var a=new b(this.g,this.U,this.a);a.ha=this;this.f&&
-this.f instanceof b&&(a.f=this.f.Ga(),a.h=[a.f]);return a};b.prototype.Wa=function(a){return this.X&&(" "===m[a]||"\t"===m[a])||(this.X||this.fa||this.ra||this.ea||this.ga||this.ua)&&"\n"===m[a]?!1:!0};b.prototype.Xa=function(b){if(this.ua||this.X||this.Fa||this.fa)return null;if(!this.f||this.f.b||this.f instanceof a){var d=c(m[b-1]),e=c(m[b+1]);if("```"===m.substr(b,3))return"```";var f=h.oa();if(void 0===f||f){if("&gt;"===m.substr(b,4))return"&gt;";if(">"===m[b])return m[b]}if("`"===m[b]&&!d||
-"\n"===m[b]||!(-1===["*","~","-","_"].indexOf(m[b])||!e&&void 0!==m[b+1]&&-1==="*~-_<&".split("").indexOf(m[b+1])||d&&void 0!==m[b-1]&&-1==="*~-_<&".split("").indexOf(m[b-1]))||-1!==[":"].indexOf(m[b])&&e||-1!==["<"].indexOf(m[b]))return m[b];d=0;for(e=n.A.length;d<e;d++)if(f=n.A[d],m.substr(b,f.length)===f)return f}return null};a.prototype.oa=function(){if(""!==this.text.trim())return!1};b.prototype.oa=function(){for(var a=this.h.length-1;0<=a;a--){var b=this.h[a].oa();if(void 0!==b)return b}if(this.va||
-this.i)return!0};a.prototype.w=function(a){this.text+=m[a];return 1};b.prototype.w=function(c){var d=this.f&&!this.f.b&&this.f.Da?this.f.Da(c):null;if(d){var e=this.f.a.length;this.f.wa(c);d instanceof b&&(this.f=d,this.h.push(d));return e}if(!this.f||this.f.b||this.f instanceof a||this.f.Wa(c)){if(d=this.Xa(c))return this.f=new b(this,c,d),this.h.push(this.f),this.f.a.length;if(!this.f||this.f.b)this.f=new a(this),this.h.push(this.f);return this.f.w(c)}d=this.f.U+1;h.la(this.f.U);this.f=new a(this);
-this.f.w(d-1);this.h.pop();this.h.push(this.f);return d-c};b.prototype.wa=function(a){for(var b=this;b;)b.b=a,b=b.ha};b.prototype.la=function(a){this.b&&this.b>=a&&(this.b=!1);this.h.forEach(function(c){c instanceof b&&c.la(a)})};a.prototype.innerHTML=function(){if(this.g.na()){for(var a=this.g;a&&!a.X;)a=a.g;if(a){var a=a.a+this.text+a.a,b=n.V(a);return b?b:a}return(a=n.V(this.text))?a:this.text}if(this.g.ma()){if("undefined"!==typeof hljs)try{return a=this.text.match(/^\w+/),hljs.configure({useBR:!0,
-tabReplace:"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"}),a&&hljs.getLanguage(a[0])?hljs.fixMarkup(hljs.highlight(a[0],this.text.substr(a[0].length)).value):hljs.fixMarkup(hljs.highlightAuto(this.text).value)}catch(q){console.error(q)}return this.text.replace(/\n/g,"<br/>")}return n.ca(this.text)};a.prototype.outerHTML=function(){var a="span",b=[],c="";if(this.g.ma()){a="pre";b.push("codeblock");var d=this.innerHTML()}else this.g.ya()?(b.push("code"),d=this.innerHTML()):(this.g.fa&&(d=n.aa(this.text))?
-(a="a",c=' href="'+d.link+'"',d.Ma||(c+=' target="_blank"'),d=n.ca(d.text)):d=this.innerHTML(),this.g.xa()&&b.push("bold"),this.g.Aa()&&b.push("italic"),this.g.Ba()&&b.push("strike"),this.g.na()&&b.push("emoji"),this.g.za()&&b.push("highlight"));return"<"+a+c+(b.length?' class="'+b.join(" ")+'"':"")+">"+d+"</"+a+">"};b.prototype.outerHTML=function(){var a="";this.i&&(a+='<span class="quote">');this.va&&(a+="<br/>");this.h.forEach(function(b){a+=b.outerHTML()});this.i&&(a+="</span>");return a};b.prototype.Ea=
-function(a){this.i&&!this.b&&this.wa(a);this.h.forEach(function(c){c instanceof b&&c.Ea(a)})};return function(c,l){l||(l={});n.A=l.A||[];n.V=l.V||f;n.ca=l.ca||f;n.aa=l.aa||g;m=c;h=new b(this,0);l=0;c=m.length;do{for(;l<c;)l+=h.w(l);h.Ea(m.length);if(l=d()){e(l,!1);h.la(l.U);var k=new a(l.g);k.w(l.U);l.g.h.push(k);l.g.f=k;l=l.U+1}else l=void 0}while(void 0!==l);return h.outerHTML()}}();"undefined"!==typeof module&&(module.H.u=ya);function za(a,b){this.i=a;this.content=b;this.c=Aa(this);this.b=Ba(this);this.a=[];this.w=[]}
-function Aa(a){var b=document.createElement("div"),c=document.createElement("header"),d=document.createElement("span"),e=document.createElement("span"),f=document.createElement("div"),g=document.createElement("footer");b.a=document.createElement("span");b.b=document.createElement("span");d.textContent=a.i;"string"==typeof a.content?f.innerHTML=a.content:f.appendChild(a.content);c.className=Ca;d.className=Da;e.className=Ea;e.textContent="x";c.appendChild(d);c.appendChild(e);b.appendChild(c);f.className=
-Fa;b.appendChild(f);b.b.className=Ga;b.b.textContent=K.Ka;b.b.addEventListener("click",function(){L(a,!1)});e.addEventListener("click",function(){L(a,!1)});b.a.addEventListener("click",function(){L(a,!0)});g.appendChild(b.b);b.a.className=Ga;b.a.textContent=K.ok;g.appendChild(b.a);g.className=Ha+" "+Ia;b.appendChild(g);b.className=Ja;return b}function L(a,b){(b?a.a:a.w).forEach(function(a){a()});a.close()}
-function Ba(a){var b=document.createElement("div");b.className=Ka;b.addEventListener("click",function(){L(this,!1)}.bind(a));return b}function La(a,b,c){a.c.a.textContent=b;a.c.b.textContent=c;return a}za.prototype.ba=function(a){a=a||document.body;a.appendChild(this.b);a.appendChild(this.c);return this};za.prototype.close=function(){this.c.remove();this.b.remove();return this};function Ma(a,b){a.a.push(b);return a};var Ga="button",Ha="button-container",Ja="dialog",Ka="dialog-overlay",Ca="dialog-title",Da="dialog-title-label",Ea="dialog-title-close",Fa="dialog-body",Ia="dialog-footer";var Na=[],Oa=0;
-function Pa(){var a=document.createDocumentFragment(),b=va(function(a){return!a.Y&&!1!==a.i}),c=[],d=[],e=[],f=[],g={};b.sort(function(a,b){if(a[0]!==b[0])return a[0]-b[0];var c=H(E.context,a),d=H(E.context,b);a=c.j[a];b=d.j[b];return a.name===b.name?(g[a.id]=K.ka(c.a.name,a.name),g[b.id]=K.ka(d.a.name,b.name),c.a.name.localeCompare(d.a.name)):a.name.localeCompare(b.name)});b.forEach(function(a){a=ua(a);if(a instanceof r){var b;if(b=!a.a.Ja){var m=g[a.id];b=document.createElement("li");var k=document.createElement("a");
-b.id="room_"+a.id;k.href="#"+a.id;b.className="chat-context-room chat-ims";k.textContent=m||a.a.name;b.appendChild(Qa());b.appendChild(k);a.a.a||b.classList.add("away");M===a&&b.classList.add("selected");a.N>a.B&&(b.classList.add("unread"),b.classList.add("unreadHi"));b=m=b}b&&(a.G?c.push(m):f.push(m))}else if(m=g[a.id],b=document.createElement("li"),k=document.createElement("a"),b.id="room_"+a.id,k.href="#"+a.id,a.b?(b.className="chat-context-room chat-group",b.dataset.count=Object.keys(a.m||{}).length):
-b.className="chat-context-room chat-channel",M===a&&b.classList.add("selected"),k.textContent=m||a.name,b.appendChild(Qa()),b.appendChild(k),a.N>a.B&&(b.classList.add("unread"),0<=N.indexOf(a)&&b.classList.add("unreadHi")),m=b)a.G?c.push(m):a.b?e.push(m):d.push(m)});c.length&&a.appendChild(Ra(K.G));c.forEach(function(b){a.appendChild(b)});d.length&&a.appendChild(Ra(K.j));d.forEach(function(b){a.appendChild(b)});e.forEach(function(b){a.appendChild(b)});f.length&&a.appendChild(Ra(K.Sa));f.forEach(function(b){a.appendChild(b)});
-document.getElementById("chanList").textContent="";document.getElementById("chanList").appendChild(a);Sa.apply(document.getElementById("chanSearch"));Ta();O();P&&Ua(P.a.id,P.m,function(a){document.getElementById("chatCtx").style.backgroundImage="url("+a+")"})}
-function Va(){ta(function(a){var b=a.s,c;for(c in a.self.j)if(!a.self.j[c].Y){var d=document.getElementById("room_"+c);b[c]?d.classList.add("chat-context-typing"):d.classList.remove("chat-context-typing")}for(var e in a.m)(c=a.m[e].pa)&&!c.Y&&(d=document.getElementById("room_"+c.id))&&(b[c.id]?d.classList.add("chat-context-typing"):d.classList.remove("chat-context-typing"))});Wa()}
-function Wa(){var a;document.getElementById("whoistyping").textContent="";if(P&&M&&(a=P.s[M.id])){var b=document.createDocumentFragment(),c=!1,d;for(d in a)(a=I(d))?b.appendChild(Xa(a)):c=!0;c&&(E.b=0);document.getElementById("whoistyping").appendChild(b)}}function Ya(a){a?document.body.classList.remove("no-network"):document.body.classList.add("no-network");O()}
-function Za(){var a=M.name||(M.a?M.a.name:void 0);if(!a){var b=[];M.m.forEach(function(a){b.push(a.name)});a=b.join(", ")}document.getElementById("currentRoomTitle").textContent=a;Q();R();document.getElementById("fileUploadContainer").classList.add("hidden");$a();T&&(T=null,U());V&&(V=null,U());O();Wa()}
-function U(){if(T){document.body.classList.add("replyingTo");var a=document.getElementById("replyToContainer"),b=document.createElement("a");b.addEventListener("click",function(){T=null;U()});b.className="replyto-close";b.textContent="x";a.textContent="";a.appendChild(b);a.appendChild(T.K())}else document.body.classList.remove("replyingTo"),document.getElementById("replyToContainer").textContent="";R()}
-function W(){if(V){document.body.classList.add("replyingTo");var a=document.getElementById("replyToContainer"),b=document.createElement("a");b.addEventListener("click",function(){V=null;W()});b.className="replyto-close";b.textContent="x";a.textContent="";a.appendChild(b);a.appendChild(V.K());document.getElementById("msgInput").value=V.text}else document.body.classList.remove("replyingTo"),document.getElementById("replyToContainer").textContent="";R()}
-window.toggleReaction=function(a,b,c){var d=E.a[a],e,f;(d=E.a[a])&&(e=oa(d,b))&&(f=H(E.context,a))&&(e.C[c]&&-1!==e.C[c].indexOf(f.self.id)?(d=new XMLHttpRequest,d.open("DELETE","api/reaction?room="+a+"&msg="+b+"&reaction="+encodeURIComponent(c),!0),d.send(null)):ab(a,b,c))};
-function bb(a){a:{var b={};if(P){var c;for(c=P;!b[a];){if(c=c.b.data[a])if("alias:"==c.substr(0,6))b[a]=!0,a=c.substr(6);else{a=document.createElement("span");a.className="emoji-custom emoji";a.style.backgroundImage="url('"+c+"')";break a}break}}}"string"===typeof a&&"makeEmoji"in window&&(a=window.makeEmoji(a));return"string"===typeof a?null:a}function cb(a,b){document.getElementById("linkFavicon").href=a||b?"favicon.png?h="+a+"&m="+b:"favicon_ok.png"}
-function O(){var a=N.length,b="";if(X)b="!"+K.Oa+" - Mimouchat",document.getElementById("linkFavicon").href="favicon_err.png";else if(a)b="(!"+a+")",cb(a,a);else{var c=0;sa(E.context,function(a){a.N>a.B&&c++});c&&(b="("+c+")");cb(0,c)}!b.length&&M&&(b=M.name);document.title=b.length?b:"Mimouchat"}
-function db(){if("Notification"in window)if("granted"===Notification.permission){var a=Date.now();if(Oa+3E4<a){var b=new Notification(K.Pa);Oa=a;setTimeout(function(){b.close()},5E3)}}else"denied"!==Notification.permission&&Notification.requestPermission()}
-function Q(){var a=document.createDocumentFragment(),b=M.id,c=null,d=0,e=null,f;M.G?document.getElementById("chatSystemContainer").classList.add("starred"):document.getElementById("chatSystemContainer").classList.remove("starred");Na=[];E.a[b]&&E.a[b].a.forEach(function(b){if(b.i)b.T();else{var g=b.L(),h=!1;c&&c.J===b.J&&b.J?30>Math.abs(d-b.l)&&!(b instanceof z)?e.classList.add("chatmsg-same-ts"):d=b.l:(d=b.l,h=!0);(!c||c.l<=M.B)&&b.l>M.B?g.classList.add("chatmsg-first-unread"):g.classList.remove("chatmsg-first-unread");
-if(b instanceof z)e=c=null,d=0,a.appendChild(g),f=null;else{if(h||!f){var h=I(b.J),n=b.username,k=document.createElement("div"),l=document.createElement("div"),q=document.createElement("span"),t=document.createElement("img");k.Z=document.createElement("span");k.Z.className="chatmsg-author-img-wrapper";t.className="chatmsg-author-img";q.className="chatmsg-author-name";h?(q.textContent=h.name,t.src="api/avatar?user="+h.id):(q.textContent=n||"?",t.src="");k.Z.appendChild(t);l.appendChild(k.Z);l.appendChild(q);
-l.className="chatmsg-author";k.className="chatmsg-authorGroup";k.appendChild(l);k.content=document.createElement("div");k.content.className="chatmsg-author-messages";k.appendChild(k.content);f=k;Na.push(f);a.appendChild(f)}c=b;e=g;f.content.appendChild(g)}}});b=document.getElementById("chatWindow");b.textContent="";b.appendChild(a);b.scrollTop=b.scrollHeight-b.clientHeight;eb();window.hasFocus&&$a()}
-function fb(a,b){if(a.classList.contains("chatmsg-hover-reply"))V&&(V=null,W()),T!==b&&(T=b,U());else if(a.classList.contains("chatmsg-hover-reaction")){var c=M.id,d=b.id;gb.ba(document.body,P,function(a){a&&ab(c,d,a)})}else a.classList.contains("chatmsg-hover-edit")?(T&&(T=null,U()),V!==b&&(V=b,W())):a.classList.contains("chatmsg-hover-star")||a.classList.contains("chatmsg-hover-pin")||!a.classList.contains("chatmsg-hover-remove")||(T&&(T=null,U()),V&&(V=null,W()),hb(b))}
-function ib(a){function b(a,b){for(b=b||a.target;b!==a.currentTarget&&b;){if(b.id&&b.classList.contains("chatmsg-item"))return b.id;b=b.parentElement}}for(var c=a.target;c!==a.currentTarget&&c&&!c.classList.contains("chatmsg-hover");){var d;if(c.parentElement&&c.classList.contains("chatmsg-attachment-actions-item")){var e=c.dataset.attachmentIndex,f=c.dataset.actionIndex;if((d=b(a,c))&&void 0!==e&&void 0!==f){d=d.substr(d.lastIndexOf("_")+1);(a=oa(E.a[M.id],d))&&a.o[e]&&a.o[e].actions&&a.o[e].actions[f]&&
-jb(a,a.o[e],a.o[e].actions[f]);break}}if(c.parentElement&&c.parentElement.classList.contains("chatmsg-hover")){if(d=b(a,c))d=d.substr(d.lastIndexOf("_")+1),(a=oa(E.a[M.id],d))&&fb(c,a);break}c=c.parentElement}}
-function jb(a,b,c){function d(){var d={actions:[c],attachment_id:b.id,callback_id:b.callback_id,channel_id:e,is_ephemeral:a instanceof A,message_ts:a.id},g=new XMLHttpRequest;g.open("POST","api/attachmentAction?serviceId="+a.J);g.send(JSON.stringify(d))}var e=M.id;c.confirm?Ma(La(new za(c.confirm.title,c.confirm.text),c.confirm.ok_text,c.confirm.dismiss_text),d).ba():d()}function R(){document.getElementById("msgInput").focus()}
-function Ta(){var a=document.location.hash.substr(1),b=ua(a);b&&b!==M?kb(b):(a=I(a))&&a.b&&kb(a.b)}function eb(){var a=document.getElementById("chatWindow").getBoundingClientRect().top;Na.forEach(function(b){var c=b.Z,d=c.clientHeight;b=b.getBoundingClientRect();c.style.top=Math.max(0,Math.min(a-b.top,b.height-d-d/2))+"px"})}
-document.addEventListener("DOMContentLoaded",function(){xa();lb();var a=document.getElementById("chanSearch");a.addEventListener("input",Sa);a.addEventListener("blur",Sa);document.getElementById("chatWindow").addEventListener("click",ib);window.addEventListener("hashchange",function(){document.location.hash&&"#"===document.location.hash[0]&&Ta()});document.getElementById("currentRoomStar").addEventListener("click",function(a){a.preventDefault();M&&(M.G?(a=new XMLHttpRequest,a.open("POST","api/unstarChannel?room="+
-M.id,!0)):(a=new XMLHttpRequest,a.open("POST","api/starChannel?room="+M.id,!0)),a.send(null));return!1});document.getElementById("fileUploadCancel").addEventListener("click",function(a){a.preventDefault();document.getElementById("fileUploadError").classList.add("hidden");document.getElementById("fileUploadContainer").classList.add("hidden");document.getElementById("fileUploadInput").value="";return!1});document.getElementById("ctxMenuSettings").addEventListener("click",function(a){a.preventDefault();
-mb.display()});document.getElementById("fileUploadForm").addEventListener("submit",function(a){a.preventDefault();a=document.getElementById("fileUploadInput");var b=a.value;b&&(b=b.substr(b.lastIndexOf("\\")+1),nb(b,a.files[0],function(a){var b=document.getElementById("fileUploadError");a?(b.textContent=a,b.classList.remove("hidden")):(b.classList.add("hidden"),document.getElementById("fileUploadInput").value="",document.getElementById("fileUploadContainer").classList.add("hidden"))}));return!1});
-document.getElementById("attachFile").addEventListener("click",function(a){a.preventDefault();M&&document.getElementById("fileUploadContainer").classList.remove("hidden");return!1});document.getElementById("msgForm").addEventListener("submit",function(a){a.preventDefault();a=document.getElementById("msgInput");M&&a.value&&ob(a.value)&&(a.value="",T&&(T=null,U()),V&&(V=null,U()),document.getElementById("slashList").textContent="");R();return!1});window.addEventListener("blur",function(){window.hasFocus=
-!1});window.addEventListener("focus",function(){window.hasFocus=!0;Oa=0;M&&$a();R()});document.getElementById("chatWindow").addEventListener("scroll",eb);var b=0;document.getElementById("msgInput").addEventListener("input",function(){if(M){var a=Date.now();b+3E3<a&&(P.self.a||M instanceof r)&&(pb(),b=a);var a=[],d=this.value;if("/"===this.value[0]){var e=d.indexOf(" "),f=-1!==e,e=-1===e?d.length:e,d=d.substr(0,e);if(f){var g=qb.La(d);g&&a.push(g)}else a=qb.Ya(d);var g=P?P.i.data:{};for(h in g){var m=
-g[h];(!f&&m.name.substr(0,e)===d||f&&m.name===d)&&a.push(m)}}a.sort(function(a,b){return a.S.localeCompare(b.S)||a.name.localeCompare(b.name)});var h=document.getElementById("slashList");var e=document.createDocumentFragment();h.textContent="";f=0;for(d=a.length;f<d;f++){g=a[f];if(n!==g.S){var n=g.S;e.appendChild(rb(g.S))}e.appendChild(sb(g))}h.appendChild(e)}});window.hasFocus=!0;(function(){var a=document.getElementById("emojiButton");if("makeEmoji"in window){var b=window.makeEmoji("smile");b?a.innerHTML=
-"<span class='emoji-small'>"+b.outerHTML+"</span>":a.style.backgroundImage='url("smile.svg")';(b=window.makeEmoji("paperclip"))?document.getElementById("attachFile").innerHTML="<span class='emoji-small'>"+b.outerHTML+"</span>":document.getElementById("attachFile").style.backgroundImage='url("public/paperclip.svg")';a.addEventListener("click",function(){P&&gb.ba(document.body,P,function(a){a&&(document.getElementById("msgInput").value+=":"+a+":");R()})})}else a.classList.add("hidden")})();tb()});var mb=function(){function a(a){c&&(document.getElementById("settings").classList.remove("display-"+c),document.getElementById("setting-menu-"+c).classList.remove("selected"),document.getElementById("settings-serviceAddSection").classList.add("hidden"));document.getElementById("settings").classList.add("display-"+a);document.getElementById("setting-menu-"+a).classList.add("selected");c=a}var b=!1,c=null,d={P:"services",display:"display",ub:"privacy"};document.getElementById("settingMenuItems").addEventListener("click",
+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.a=a.desc;this.name=a.name;this.type=a.type;this.usage=a.usage;this.U=a.category}function ca(){this.a={};this.A=[];this.version=0}
+ca.prototype.update=function(a,b){a.emoji_use&&(this.a=JSON.parse(a.emoji_use));a.highlight_words?this.A=(a.highlight_words||"").split(",").filter(function(a){return""!==a.trim()}):a.highlights&&(this.A=a.highlights);this.version=Math.max(this.version,b)};function da(){this.a=null;this.l={};this.j={};this.self=null;this.b={version:0,data:{}};this.i={version:0,data:{}};this.u={};this.ca={};this.o=0}function fa(a,b){return b.pv?new t(b.id,a.j[b.user]):new v(b.id)}
+function ga(a,b,c){var d=d||"";b.team&&(a.a||(a.a=new aa(b.team.id)),a.a.update(b.team,c));if(b.users)for(var e=0,f=b.users.length;e<f;e++){var g=a.j[d+b.users[e].id];g||(g=a.j[d+b.users[e].id]=new ha(b.users[e].id));g.update(b.users[e],c)}if(b.channels)for(e=0,f=b.channels.length;e<f;e++)(g=a.l[d+b.channels[e].id])||(g=a.l[d+b.channels[e].id]=fa(a,b.channels[e])),g.update(b.channels[e],a,c,d);b.emojis&&(a.b.data=b.emojis,a.b.version=c);if(void 0!==b.commands){a.i.data={};for(e in b.commands)a.i.data[e]=
+new ba(b.commands[e]);a.i.version=c}b.self&&(a.self=a.j[d+b.self.id]||null,a.self.R||(a.self.R=new ca),b.self.prefs&&a.self.R.update(b.self.prefs,c));b.capacities&&(a.ca={},b.capacities.forEach(function(a){this.ca[a]=!0},a));a.o=Math.max(a.o,c)}"undefined"!==typeof module&&(module.H.rb=da,module.H.sb=aa,module.H.ub=ba);function v(a){this.id=a;this.G=!1;this.B=0;this.j={};this.version=0}
+v.prototype.update=function(a,b,c,d){d=d||"";void 0!==a.name&&(this.name=a.name);void 0!==a.is_archived&&(this.aa=a.is_archived);void 0!==a.is_member&&(this.M=a.is_member);void 0!==a.last_read&&(this.B=Math.max(parseFloat(a.last_read),this.B));void 0!==a.last_msg&&(this.P=parseFloat(a.last_msg));void 0!==a.is_private&&(this.b=a.is_private);this.G=!!a.is_starred;if(a.members&&(this.j={},a.members))for(var e=0,f=a.members.length;e<f;e++){var g=b.j[d+a.members[e]];this.j[g.id]=g;g.l[this.id]=this}a.topic&&
+(this.ia=a.topic.value,this.o=b.j[d+a.topic.creator],this.$=a.topic.last_set);a.purpose&&(this.fa=a.purpose.value,this.i=b.j[d+a.purpose.creator],this.Z=a.purpose.last_set);this.version=Math.max(this.version,c)};function ia(a,b){var c=ja;return{name:c.da(b,a.name),kb:c.da(b,Object.values(a.j),function(a){return a?a.getName():null}),ia:c.da(b,a.ia),fa:c.da(b,a.fa)}}function t(a,b){v.call(this,a);this.a=b;this.name=b.getName();this.b=!0;b.V=this}t.prototype=Object.create(v.prototype);
+t.prototype.constructor=t;"undefined"!==typeof module&&(module.H.Ab=v,module.H.zb=t);function x(a,b){this.J=a.user;this.username=a.username;this.id=a.id||a.ts;this.m=parseFloat(a.ts);this.text="";this.s=[];this.i=this.D=this.G=!1;this.C={};this.version=b;this.update(a,b)}function y(a,b){x.call(this,a,b)}function z(a,b){x.call(this,a,b)}
+x.prototype.update=function(a,b){if(a){if(this.text=a.text||"",a.attachments&&(this.s=a.attachments),this.G=!!a.is_starred,this.D=void 0===a.edited?!1:a.edited,this.i=!!a.removed,a.reactions){var c={};a.reactions.forEach(function(a){c[a.name]=[];a.users.forEach(function(b){c[a.name].push(b)})});this.C=c}}else this.i=!0;this.version=b};function B(a,b,c,d,e){this.id="string"===typeof a?a:a.id;this.a=[];this.b=c;this.ab=0;this.o=b;d&&ka(this,d,e)}
+function ka(a,b,c){var d=0;b.forEach(function(a){d=Math.max(this.push(a,c),d)}.bind(a));la(a);return d}B.prototype.i=function(a,b){return!0===a.isMeMessage?new y(a,b):!0===a.isNotice?new z(a,b):new x(a,b)};
+B.prototype.push=function(a,b){for(var c,d=!1,e,f=0,g=this.a.length;f<g;f++)if(c=this.a[f],c.id===a.id){e=c.update(a,b);d=!0;break}d||(c=this.i(a,b),this.a.push(c),e=c.m);for(;this.a.length>this.o;)this.a.shift();if(this.b)for(a=0;a<this.a.length;a++)this.a[a].version<b-this.b&&this.a.splice(a--,1);return e||0};function ma(a){return a.a[a.a.length-1]}function na(a,b){for(var c=0,d=a.a.length;c<d;c++)if(a.a[c].id==b)return a.a[c];return null}function la(a){a.a.sort(function(a,c){return a.m-c.m})}
+y.prototype=Object.create(x.prototype);y.prototype.constructor=y;z.prototype=Object.create(x.prototype);z.prototype.constructor=z;"undefined"!==typeof module&&(module.H={wb:x,vb:y,yb:z,Bb:B});function ha(a){this.id=a;this.l={};this.V=this.R=null;this.version=0}
+ha.prototype.update=function(a,b){void 0!==a.name&&(this.name=a.name);void 0!==a.deleted&&(this.Ma=a.deleted);void 0!==a.status&&(this.status=a.status);void 0!==a.goal&&(this.gb=a.goal);void 0!==a.phone&&(this.mb=a.phone);void 0!==a.first_name&&(this.Oa=a.first_name);void 0!==a.last_name&&(this.Sa=a.last_name);void 0!==a.real_name&&(this.Za=a.real_name);void 0!==a.isPresent&&(this.ua=a.isPresent);a.isBot&&(this.ib=a.isBot);this.version=Math.max(this.version,b)};
+ha.prototype.getName=function(){return this.name||this.Za||this.Oa||this.Sa};"undefined"!==typeof module&&(module.H.tb=ha);function oa(){this.a=[]}oa.prototype.push=function(a){this.a.push(a)};function pa(a,b){for(var c=0,d=a.a.length;c<d;c++)if(b===qa(a.a[c]))return a.a[c];return null}function ra(a,b){for(var c=0,d=a.a.length;c<d;c++){var e=a.a[c],f;for(f in e.l)if(!0===b(e.l[f],f))return}}function sa(a){for(var b=E.context,c=0,d=b.a.length;c<d&&!0!==a(b.a[c]);c++);}function G(a,b){for(var c=0,d=a.a.length;c<d;c++)if(a.a[c].l[b])return a.a[c];return null}
+function ta(a){for(var b=E.context,c=0,d=b.a.length;c<d;c++){var e=b.a[c].l[a];if(e)return e}return null}function ua(a){for(var b=E.context,c=[],d=0,e=b.a.length;d<e;d++){var f=b.a[d].l,g;for(g in f)a&&!a(f[g],b.a[d],g)||c.push(g)}return c}function H(a){for(var b=E.context,c=0,d=b.a.length;c<d;c++){var e=b.a[c].j[a];if(e)return e}return null}"undefined"!==typeof module&&(module.H.xb=oa);var ja=function(){function a(b,c,d){if(Array.isArray(c)){for(var e=0,f=0,g=c.length;f<g;f++){var h=a(b,c[f],d);if(1===h)return 1;e=Math.max(h,e)}return e}return(c=d?d(c):c)&&void 0!==b&&null!==b?b.length?-1===c.indexOf(b)?0:b.length/c.length:1:0}return{da:a}}();"undefined"!==typeof module&&(module.H.Cb=ja);var I={},J,va=[];function wa(){if(!c){for(var a=0,b=navigator.languages.length;a<b;a++)if(I.hasOwnProperty(navigator.languages[a])){var c=navigator.languages[a];break}c||(c="en")}J=I[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];va.forEach(function(a){a()})};I.fr={qb:"Utilisateur inconnu",pb:"Channel inconnu",Ua:"Nouveau message",message:"Message",Ta:"Reseau",Va:"(visible seulement par vous)",G:"Favoris",l:"Discutions",Ya:"Discutions priv\u00e9es",$a:"Partage sa position GPS",ok:"Ok",Na:"Annuler",L: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()},qa:function(a,b){return a+"/"+b},c:{fileUploadCancel:"Annuler",neterror:"Impossible de se connecter au chat !",ctxMenuSettings:"Configuration",settingTitle:"Configuration","setting-menu-services":"Services","settings-services-title":"Services","setting-menu-display":"Affichage","settings-display-title":"Affichage","setting-menu-privacy":"Vie priv\u00e9e","settings-privacy-title":"Vie priv\u00e9e",settingCommit:"Appliquer","settings-serviceAddButton":"Ajouter un service","settings-serviceListEmpty":"Vous n'avez pas encore ajout\u00e9 de service. Ajouter un service pour continuer.",
+"settings-serviceAddConfirm":"Suivant"}};I.fr.D=function(a){return"(edit&eacute; "+I.fr.L(a)+")"};I.fr.xa=function(a,b){return"par "+a.getName()+" le "+I.fr.L(b)};I.en={qb:"Unknown member",pb:"Unknown channel",Ua:"New message",message:"Message",Ta:"Network",Va:"(only visible to you)",G:"Starred",l:"Channels",Ya:"Direct messages",$a:"Share your GPS location",ok:"Ok",Na:"Cancel",L: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()},
+qa:function(a,b){return a+"/"+b},c:{fileUploadCancel:"Cancel",neterror:"Cannot connect to chat !",ctxMenuSettings:"Settings",settingTitle:"Settings","setting-menu-services":"Services","settings-services-title":"Services","setting-menu-display":"Display","settings-display-title":"Display","setting-menu-privacy":"Privacy","settings-privacy-title":"Privacy",settingCommit:"Apply","settings-serviceAddButton":"Add a service","settings-serviceListEmpty":"You don't have any service yet. Please add a service to continue.",
+"settings-serviceAddConfirm":"Next"}};I.en.D=function(a){return"(edited "+I.en.L(a)+")"};I.en.xa=function(a,b){return"by "+a.getName()+" on "+I.en.L(b)};var xa=function(){function a(a){this.text="";this.g=a}function b(b,c,d){this.X=c;this.f=null;this.h=[];this.a=d||"";this.la="<"===this.a;this.va="*"===this.a;this.ka="_"===this.a;this.ma="~"===this.a||"-"===this.a;this.i=">"===this.a||"&gt;"===this.a;this.M=":"===this.a;this.ya="`"===this.a;this.Ja="```"===this.a;this.za="\n"===this.a;this.ja=void 0!==d&&-1!==m.A.indexOf(d);this.g=b;this.na=null;this.b=this.za||this.ja?c+d.length-1:!1;this.ja&&(this.f=new a(this),this.h.push(this.f),this.f.text=d)}
+function c(a){return"A"<=a&&"Z">=a||"a"<=a&&"z">=a||"0"<=a&&"9">=a||-1!=="\u00e0\u00e8\u00ec\u00f2\u00f9\u00c0\u00c8\u00cc\u00d2\u00d9\u00e1\u00e9\u00ed\u00f3\u00fa\u00fd\u00c1\u00c9\u00cd\u00d3\u00da\u00dd\u00e2\u00ea\u00ee\u00f4\u00fb\u00c2\u00ca\u00ce\u00d4\u00db\u00e3\u00f1\u00f5\u00c3\u00d1\u00d5\u00e4\u00eb\u00ef\u00f6\u00fc\u00ff\u00c4\u00cb\u00cf\u00d6\u00dc\u0178\u00e7\u00c7\u00df\u00d8\u00f8\u00c5\u00e5\u00c6\u00e6\u0153".indexOf(a)}function d(a){a=a||n;for(var c=0,e=a.h.length;c<e;c++){var l=
+a.h[c];if(l instanceof b)if(l.b){if(l=d(l))return l}else return l}return null}function e(a,c){a.g instanceof b&&(a.g.h.splice(a.g.h.indexOf(a)+(c?1:0)),a.g.f=a.g.h[a.g.h.length-1],e(a.g,!0))}function f(a){return a}function g(a){return{link:a,text:a,Qa:!1}}var h,n,m={A:[],Y:f,ha:f,ea:g};b.prototype.Ba=function(){return this.va&&!!this.b||this.g instanceof b&&this.g.Ba()};b.prototype.Ea=function(){return this.ka&&!!this.b||this.g instanceof b&&this.g.Ea()};b.prototype.Fa=function(){return this.ma&&
+!!this.b||this.g instanceof b&&this.g.Fa()};b.prototype.sa=function(){return this.M&&!!this.b||this.g instanceof b&&this.g.sa()};b.prototype.Da=function(){return this.ja&&!!this.b||this.g instanceof b&&this.g.Da()};b.prototype.Ca=function(){return this.ya&&!!this.b||this.g instanceof b&&this.g.Ca()};b.prototype.$=function(){return this.Ja&&!!this.b||this.g instanceof b&&this.g.$()};b.prototype.Ga=function(){for(var a=0,c=this.h.length;a<c;a++)if(this.h[a]instanceof b&&(!this.h[a].b||this.h[a].Ga()))return!0;
+return!1};b.prototype.Ha=function(a){if("<"===this.a&&">"===h[a])return!0;var b=c(h[a-1]);if(!this.i&&h.substr(a,this.a.length)===this.a){if(!b&&(this.va||this.ka||this.ma))return!1;if(this.f&&this.Ga())return this.f.Ka();if(this.bb())return!0}return"\n"===h[a]&&this.i?!0:!1};b.prototype.bb=function(){for(var a=this;a;){for(var c=0,d=a.h.length;c<d;c++)if(a.h[c]instanceof b||a.h[c].text.length)return!0;a=a.na}return!1};b.prototype.Ka=function(){var a=new b(this.g,this.X,this.a);a.na=this;this.f&&
+this.f instanceof b&&(a.f=this.f.Ka(),a.h=[a.f]);return a};b.prototype.cb=function(a){return this.M&&(" "===h[a]||"\t"===h[a])||(this.M||this.la||this.va||this.ka||this.ma||this.ya)&&"\n"===h[a]?!1:!0};b.prototype.eb=function(b){if(this.ya||this.M||this.Ja||this.la)return null;if(!this.f||this.f.b||this.f instanceof a){var d=c(h[b-1]),e=c(h[b+1]);if("```"===h.substr(b,3))return"```";var f=n.ta();if(void 0===f||f){if("&gt;"===h.substr(b,4))return"&gt;";if(">"===h[b])return h[b]}if("`"===h[b]&&!d||
+"\n"===h[b]||!(-1===["*","~","-","_"].indexOf(h[b])||!e&&void 0!==h[b+1]&&-1==="*~-_<&".split("").indexOf(h[b+1])||d&&void 0!==h[b-1]&&-1==="*~-_<&".split("").indexOf(h[b-1]))||-1!==[":"].indexOf(h[b])&&e||-1!==["<"].indexOf(h[b]))return h[b];d=0;for(e=m.A.length;d<e;d++)if(f=m.A[d],h.substr(b,f.length)===f)return f}return null};a.prototype.ta=function(){if(""!==this.text.trim())return!1};b.prototype.ta=function(){for(var a=this.h.length-1;0<=a;a--){var b=this.h[a].ta();if(void 0!==b)return b}if(this.za||
+this.i)return!0};a.prototype.o=function(a){this.text+=h[a];return 1};b.prototype.o=function(c){var d=this.f&&!this.f.b&&this.f.Ha?this.f.Ha(c):null;if(d){var e=this.f.a.length;this.f.Aa(c);d instanceof b&&(this.f=d,this.h.push(d));return e}if(!this.f||this.f.b||this.f instanceof a||this.f.cb(c)){if(d=this.eb(c))return this.f=new b(this,c,d),this.h.push(this.f),this.f.a.length;if(!this.f||this.f.b)this.f=new a(this),this.h.push(this.f);return this.f.o(c)}d=this.f.X+1;n.Z(this.f.X);this.f=new a(this);
+this.f.o(d-1);this.h.pop();this.h.push(this.f);return d-c};b.prototype.Aa=function(a){for(var b=this;b;)b.b=a,b=b.na};b.prototype.Z=function(a){this.b&&this.b>=a&&(this.b=!1);this.h.forEach(function(c){c instanceof b&&c.Z(a)})};a.prototype.innerHTML=function(){if(this.g.sa()){for(var a=this.g;a&&!a.M;)a=a.g;if(a){var a=a.a+this.text+a.a,b=m.Y(a);return b?b:a}return(a=m.Y(this.text))?a:this.text}if(this.g.$()){if("undefined"!==typeof hljs)try{return a=this.text.match(/^\w+/),hljs.configure({useBR:!0,
+tabReplace:"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"}),a&&hljs.getLanguage(a[0])?hljs.fixMarkup(hljs.highlight(a[0],this.text.substr(a[0].length)).value):hljs.fixMarkup(hljs.highlightAuto(this.text).value)}catch(p){console.error(p)}return this.text.replace(/\n/g,"<br/>")}return m.ha(this.text)};a.prototype.outerHTML=function(){var a="span",b=[],c="";if(this.g.$()){a="pre";b.push("codeblock");var d=this.innerHTML()}else this.g.Ca()?(b.push("code"),d=this.innerHTML()):(this.g.la&&(d=m.ea(this.text))?(a=
+"a",c=' href="'+d.link+'"',d.Qa||(c+=' target="_blank"'),d=m.ha(d.text)):d=this.innerHTML(),this.g.Ba()&&b.push("bold"),this.g.Ea()&&b.push("italic"),this.g.Fa()&&b.push("strike"),this.g.sa()&&b.push("emoji"),this.g.Da()&&b.push("highlight"));return"<"+a+c+(b.length?' class="'+b.join(" ")+'"':"")+">"+d+"</"+a+">"};b.prototype.outerHTML=function(){var a="";this.i&&(a+='<span class="quote">');this.za&&(a+="<br/>");this.h.forEach(function(b){a+=b.outerHTML()});this.i&&(a+="</span>");return a};b.prototype.Ia=
+function(a){this.i&&!this.b&&this.Aa(a);this.h.forEach(function(c){c instanceof b&&c.Ia(a)})};return function(c,k){k||(k={});m.A=k.A||[];m.Y=k.Y||f;m.ha=k.ha||f;m.ea=k.ea||g;h=c;n=new b(this,0);k=0;c=h.length;do{for(;k<c;)k+=n.o(k);n.Ia(h.length);if(k=d()){e(k,!1);n.Z(k.X);var l=new a(k.g);l.o(k.X);k.g.h.push(l);k.g.f=l;k=k.X+1}else k=void 0}while(void 0!==k);return n.outerHTML()}}();"undefined"!==typeof module&&(module.H.w=xa);function ya(a,b){this.i=a;this.content=b;this.c=za(this);this.b=Aa(this);this.a=[];this.o=[]}
+function za(a){var b=document.createElement("div"),c=document.createElement("header"),d=document.createElement("span"),e=document.createElement("span"),f=document.createElement("div"),g=document.createElement("footer");b.a=document.createElement("span");b.b=document.createElement("span");d.textContent=a.i;"string"==typeof a.content?f.innerHTML=a.content:f.appendChild(a.content);c.className=Ba;d.className=Ca;e.className=Da;e.textContent="x";c.appendChild(d);c.appendChild(e);b.appendChild(c);f.className=
+Ea;b.appendChild(f);b.b.className=Fa;b.b.textContent=J.Na;b.b.addEventListener("click",function(){Ga(a,!1)});e.addEventListener("click",function(){Ga(a,!1)});b.a.addEventListener("click",function(){Ga(a,!0)});g.appendChild(b.b);b.a.className=Fa;b.a.textContent=J.ok;g.appendChild(b.a);g.className=Ha+" "+Ia;b.appendChild(g);b.className=Ja;return b}function Ga(a,b){(b?a.a:a.o).forEach(function(a){a()});a.close()}
+function Aa(a){var b=document.createElement("div");b.className=Ka;b.addEventListener("click",function(){Ga(this,!1)}.bind(a));return b}function La(a,b,c){a.c.a.textContent=b;a.c.b.textContent=c;return a}ya.prototype.ga=function(a){a=a||document.body;a.appendChild(this.b);a.appendChild(this.c);return this};ya.prototype.close=function(){this.c.remove();this.b.remove();return this};function Ma(a,b){a.a.push(b);return a};var Fa="button",Ha="button-container",Ja="dialog",Ka="dialog-overlay",Ba="dialog-title",Ca="dialog-title-label",Da="dialog-title-close",Ea="dialog-body",Ia="dialog-footer";var Na=[],Oa=0;
+function Pa(){var a=document.createDocumentFragment(),b=ua(function(a){return!a.aa&&!1!==a.M}),c=[],d=[],e=[],f=[],g={};b.sort(function(a,b){if(a[0]!==b[0])return a[0]-b[0];var c=G(E.context,a),d=G(E.context,b);a=c.l[a];b=d.l[b];return a.name===b.name?(g[a.id]=J.qa(c.a.name,a.name),g[b.id]=J.qa(d.a.name,b.name),c.a.name.localeCompare(d.a.name)):a.name.localeCompare(b.name)});b.forEach(function(a){a=ta(a);if(a instanceof t){var b;if(b=!a.a.Ma){var h=g[a.id];b=document.createElement("li");var l=document.createElement("a");
+b.id="room_"+a.id;l.href="#"+a.id;b.className="chat-context-room chat-ims presence-indicator";l.textContent=h||a.a.getName();b.appendChild(Qa());b.appendChild(l);a.a.ua||b.classList.add("presence-away");K===a&&b.classList.add("selected");a.P>a.B&&(b.classList.add("unread"),b.classList.add("unreadHi"));b=h=b}b&&(a.G?c.push(h):f.push(h))}else if(h=g[a.id],b=document.createElement("li"),l=document.createElement("a"),b.id="room_"+a.id,l.href="#"+a.id,a.b?(b.className="chat-context-room chat-group",b.dataset.count=
+Object.keys(a.j||{}).length):b.className="chat-context-room chat-channel",K===a&&b.classList.add("selected"),l.textContent=h||a.name,b.appendChild(Qa()),b.appendChild(l),a.P>a.B&&(b.classList.add("unread"),0<=L.indexOf(a)&&b.classList.add("unreadHi")),h=b)a.G?c.push(h):a.b?e.push(h):d.push(h)});c.length&&a.appendChild(Ra(J.G));c.forEach(function(b){a.appendChild(b)});d.length&&a.appendChild(Ra(J.l));d.forEach(function(b){a.appendChild(b)});e.forEach(function(b){a.appendChild(b)});f.length&&a.appendChild(Ra(J.Ya));
+f.forEach(function(b){a.appendChild(b)});document.getElementById("chanList").textContent="";document.getElementById("chanList").appendChild(a);Sa.apply(document.getElementById("chanSearch"));Ta();P();Q&&Ua(Q.a.id,Q.j,function(a){document.getElementById("chatCtx").style.backgroundImage="url("+a+")"})}
+function Va(){sa(function(a){var b=a.u,c;for(c in a.self.l)if(!a.self.l[c].aa){var d=document.getElementById("room_"+c);b[c]?d.classList.add("chat-context-typing"):d.classList.remove("chat-context-typing")}for(var e in a.j)(c=a.j[e].V)&&!c.aa&&(d=document.getElementById("room_"+c.id))&&(b[c.id]?d.classList.add("chat-context-typing"):d.classList.remove("chat-context-typing"))});Wa()}
+function Wa(){var a;document.getElementById("whoistyping").textContent="";if(Q&&K&&(a=Q.u[K.id])){var b=document.createDocumentFragment(),c=!1,d;for(d in a)(a=H(d))?b.appendChild(Xa(a)):c=!0;c&&(E.b=0);document.getElementById("whoistyping").appendChild(b)}}function Ya(a){a?document.body.classList.remove("no-network"):document.body.classList.add("no-network");P()}
+function Za(){var a=K.name||(K.a?K.a.getName():void 0);if(!a){var b=[];K.j.forEach(function(a){b.push(a.getName())});a=b.join(", ")}document.getElementById("currentRoomTitle").textContent=a;R();S();document.getElementById("fileUploadContainer").classList.add("hidden");$a();T&&(T=null,U());V&&(V=null,U());P();Wa()}
+function U(){if(T){document.body.classList.add("replyingTo");var a=document.getElementById("replyToContainer"),b=document.createElement("a");b.addEventListener("click",function(){T=null;U()});b.className="replyto-close";b.textContent="x";a.textContent="";a.appendChild(b);a.appendChild(T.K())}else document.body.classList.remove("replyingTo"),document.getElementById("replyToContainer").textContent="";S()}
+function ab(){if(V){document.body.classList.add("replyingTo");var a=document.getElementById("replyToContainer"),b=document.createElement("a");b.addEventListener("click",function(){V=null;ab()});b.className="replyto-close";b.textContent="x";a.textContent="";a.appendChild(b);a.appendChild(V.K());document.getElementById("msgInput").value=V.text}else document.body.classList.remove("replyingTo"),document.getElementById("replyToContainer").textContent="";S()}
+window.toggleReaction=function(a,b,c){var d=E.a[a],e,f;(d=E.a[a])&&(e=na(d,b))&&(f=G(E.context,a))&&(e.C[c]&&-1!==e.C[c].indexOf(f.self.id)?(d=new XMLHttpRequest,d.open("DELETE","api/reaction?room="+a+"&msg="+b+"&reaction="+encodeURIComponent(c),!0),d.send(null)):bb(a,b,c))};
+function cb(a){a:{var b={};if(Q)for(var c=Q;!b[a];){if(c=c.b.data[a])if("alias:"==c.substr(0,6))b[a]=!0,a=c.substr(6);else{a=document.createElement("span");a.className="emoji-custom emoji";a.style.backgroundImage="url('"+c+"')";break a}break}}"string"===typeof a&&"makeEmoji"in window&&(a=window.makeEmoji(a));return"string"===typeof a?null:a}function db(a,b){document.getElementById("linkFavicon").href=a||b?"favicon.png?h="+a+"&m="+b:"favicon_ok.png"}
+function P(){var a=L.length,b="";if(W)b="!"+J.Ta+" - Mimouchat",document.getElementById("linkFavicon").href="favicon_err.png";else if(a)b="(!"+a+")",db(a,a);else{var c=0;ra(E.context,function(a){a.P>a.B&&c++});c&&(b="("+c+")");db(0,c)}!b.length&&K&&(b=K.name);document.title=b.length?b:"Mimouchat"}
+function eb(){if("Notification"in window)if("granted"===Notification.permission){var a=Date.now();if(Oa+3E4<a){var b=new Notification(J.Ua);Oa=a;setTimeout(function(){b.close()},5E3)}}else"denied"!==Notification.permission&&Notification.requestPermission()}
+function R(){var a=document.createDocumentFragment(),b=K.id,c=null,d=0,e=null,f;K.G?document.getElementById("chatSystemContainer").classList.add("starred"):document.getElementById("chatSystemContainer").classList.remove("starred");Na=[];E.a[b]&&E.a[b].a.forEach(function(b){if(b.i)b.W();else{var g=b.N(),n=!1;c&&c.J===b.J&&b.J?30>Math.abs(d-b.m)&&!(b instanceof y)?e.classList.add("chatmsg-same-ts"):d=b.m:(d=b.m,n=!0);(!c||c.m<=K.B)&&b.m>K.B?g.classList.add("chatmsg-first-unread"):g.classList.remove("chatmsg-first-unread");
+if(b instanceof y)e=c=null,d=0,a.appendChild(g),f=null;else{if(n||!f){var n=H(b.J),m=b.username,l=document.createElement("div"),k=document.createElement("div"),p=document.createElement("a"),u=document.createElement("img");l.ba=document.createElement("span");l.ba.className="chatmsg-author-img-wrapper";u.className="chatmsg-author-img";p.className="chatmsg-author-name";p.href="#"+n.id;n?(p.textContent=n.getName(),u.src="api/avatar?user="+n.id):(p.textContent=m||"?",u.src="");l.ba.appendChild(u);k.appendChild(l.ba);
+k.appendChild(p);k.className="chatmsg-author";l.className="chatmsg-authorGroup";l.appendChild(k);l.content=document.createElement("div");l.content.className="chatmsg-author-messages";l.appendChild(l.content);f=l;Na.push(f);a.appendChild(f)}c=b;e=g;f.content.appendChild(g)}}});b=document.getElementById("chatWindow");b.textContent="";b.appendChild(a);b.scrollTop=b.scrollHeight-b.clientHeight;fb();window.hasFocus&&$a()}
+function gb(a,b){if(a.classList.contains("chatmsg-hover-reply"))V&&(V=null,ab()),T!==b&&(T=b,U());else if(a.classList.contains("chatmsg-hover-reaction")){var c=K.id,d=b.id;hb.ga(document.body,Q,function(a){a&&bb(c,d,a)})}else a.classList.contains("chatmsg-hover-edit")?(T&&(T=null,U()),V!==b&&(V=b,ab())):a.classList.contains("chatmsg-hover-star")||a.classList.contains("chatmsg-hover-pin")||!a.classList.contains("chatmsg-hover-remove")||(T&&(T=null,U()),V&&(V=null,ab()),ib(b))}
+function jb(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=na(E.a[K.id],d))&&a.s[e]&&a.s[e].actions&&a.s[e].actions[f]&&
+kb(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=na(E.a[K.id],d))&&gb(c,a);break}c=c.parentElement}}
+function kb(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 z,message_ts:a.id},g=new XMLHttpRequest;g.open("POST","api/attachmentAction?serviceId="+a.J);g.send(JSON.stringify(d))}var e=K.id;c.confirm?Ma(La(new ya(c.confirm.title,c.confirm.text),c.confirm.ok_text,c.confirm.dismiss_text),d).ga():d()}function S(){document.getElementById("msgInput").focus()}
+function fb(){var a=document.getElementById("chatWindow").getBoundingClientRect().top;Na.forEach(function(b){var c=b.ba,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(){wa();lb();var a=document.getElementById("chanSearch");a.addEventListener("input",Sa);a.addEventListener("blur",Sa);document.getElementById("chatWindow").addEventListener("click",jb);window.addEventListener("hashchange",function(){document.location.hash&&"#"===document.location.hash[0]&&Ta()});document.addEventListener("mouseover",function(a){for(a=a.target;a&&a!==this;){if("A"===a.nodeName){var b=a.href,c=b.indexOf("#");if(0<=c){b=b.substr(c+
+1);if(c=G(E.context,b)){X.Wa(c,c.l[b]).show(a);return}a:{for(var c=E.context,f=0,g=c.a.length;f<g;f++)if(c.a[f].j[b]){c=c.a[f];break a}c=null}if(c&&(b=c.j[b].V)){X.Wa(c,b).show(a);return}}break}a=a.parentElement}X.ra()});document.addEventListener("mouseleave",function(){X.ra()});document.getElementById("currentRoomStar").addEventListener("click",function(a){a.preventDefault();K&&(K.G?(a=new XMLHttpRequest,a.open("POST","api/unstarChannel?room="+K.id,!0)):(a=new XMLHttpRequest,a.open("POST","api/starChannel?room="+
+K.id,!0)),a.send(null));return!1});document.getElementById("fileUploadCancel").addEventListener("click",function(a){a.preventDefault();document.getElementById("fileUploadError").classList.add("hidden");document.getElementById("fileUploadContainer").classList.add("hidden");document.getElementById("fileUploadInput").value="";return!1});document.getElementById("ctxMenuSettings").addEventListener("click",function(a){a.preventDefault();mb.display()});document.getElementById("fileUploadForm").addEventListener("submit",
+function(a){a.preventDefault();a=document.getElementById("fileUploadInput");var b=a.value;b&&(b=b.substr(b.lastIndexOf("\\")+1),nb(b,a.files[0],function(a){var b=document.getElementById("fileUploadError");a?(b.textContent=a,b.classList.remove("hidden")):(b.classList.add("hidden"),document.getElementById("fileUploadInput").value="",document.getElementById("fileUploadContainer").classList.add("hidden"))}));return!1});document.getElementById("attachFile").addEventListener("click",function(a){a.preventDefault();
+K&&document.getElementById("fileUploadContainer").classList.remove("hidden");return!1});document.getElementById("msgForm").addEventListener("submit",function(a){a.preventDefault();a=document.getElementById("msgInput");K&&a.value&&ob(a.value)&&(a.value="",T&&(T=null,U()),V&&(V=null,U()),document.getElementById("slashList").textContent="");S();return!1});window.addEventListener("blur",function(){window.hasFocus=!1});window.addEventListener("focus",function(){window.hasFocus=!0;Oa=0;K&&$a();S()});document.getElementById("chatWindow").addEventListener("scroll",
+fb);var b=0;document.getElementById("msgInput").addEventListener("input",function(){if(K){var a=Date.now();b+3E3<a&&(Q.self.ua||K instanceof t)&&(pb(),b=a);var a=[],d=this.value;if("/"===this.value[0]){var e=d.indexOf(" "),f=-1!==e,e=-1===e?d.length:e,d=d.substr(0,e);if(f){var g=qb.Pa(d);g&&a.push(g)}else a=qb.fb(d);var g=Q?Q.i.data:{};for(n in g){var h=g[n];(!f&&h.name.substr(0,e)===d||f&&h.name===d)&&a.push(h)}}a.sort(function(a,b){return a.U.localeCompare(b.U)||a.name.localeCompare(b.name)});var n=
+document.getElementById("slashList");var e=document.createDocumentFragment();n.textContent="";f=0;for(d=a.length;f<d;f++){g=a[f];if(m!==g.U){var m=g.U;e.appendChild(rb(g.U))}e.appendChild(sb(g))}n.appendChild(e)}});window.hasFocus=!0;(function(){var a=document.getElementById("emojiButton");if("makeEmoji"in window){var b=window.makeEmoji("smile");b?a.innerHTML="<span class='emoji-small'>"+b.outerHTML+"</span>":a.style.backgroundImage='url("smile.svg")';(b=window.makeEmoji("paperclip"))?document.getElementById("attachFile").innerHTML=
+"<span class='emoji-small'>"+b.outerHTML+"</span>":document.getElementById("attachFile").style.backgroundImage='url("public/paperclip.svg")';a.addEventListener("click",function(){Q&&hb.ga(document.body,Q,function(a){a&&(document.getElementById("msgInput").value+=":"+a+":");S()})})}else a.classList.add("hidden")})();tb()});var mb=function(){function a(a){c&&(document.getElementById("settings").classList.remove("display-"+c),document.getElementById("setting-menu-"+c).classList.remove("selected"),document.getElementById("settings-serviceAddSection").classList.add("hidden"));document.getElementById("settings").classList.add("display-"+a);document.getElementById("setting-menu-"+a).classList.add("selected");c=a}var b=!1,c=null,d={S:"services",display:"display",Db:"privacy"};document.getElementById("settingMenuItems").addEventListener("click",
 function(b){for(var c=b.target;b.currentTarget!==c&&c;c=c.parentNode)if(c.dataset&&c.dataset.target)for(var e in d)if(d[e]===c.dataset.target){a(d[e]);return}});document.getElementById("settings-serviceAddButton").addEventListener("click",function(a){a.preventDefault();document.getElementById("settings-serviceAddSection").classList.remove("hidden");return!1});document.getElementById("settings-serviceAddConfirm").addEventListener("click",function(a){a.preventDefault();document.location.href=document.getElementById("settings-serviceAddServiceList").value;
-return!1});return{display:function(c){b||(document.getElementById("settings").classList.remove("hidden"),b=!0);a(c||d.P);return this},fb:function(){return this},cb:d}}();function ub(a){if(void 0!==a.latitude&&void 0!==a.longitude&&-90<=a.latitude&&90>=a.latitude&&-180<=a.longitude&&180>=a.longitude){var b=0,c=function(a,b,c,d){return new Promise(function(e,f){var g=new Image;g.addEventListener("load",function(){d.M=g;e(d)});g.addEventListener("error",function(){console.warn("Error loading tile ",{zoom:a,x:b,y:c});f(g)});g.crossOrigin="anonymous";g.src="https://c.tile.openstreetmap.org/"+a+"/"+b+"/"+c+".png"})},d=document.createElement("canvas"),e=document.createElement("canvas");
-d.height=d.width=e.height=e.width=300;var f=d.getContext("2d"),g=e.getContext("2d"),m=function(a,b,c){a=a*Math.PI/180;b=b*Math.PI/180;c=c*Math.PI/180;return Math.abs(6371E3*Math.acos(Math.pow(Math.sin(a),2)+Math.pow(Math.cos(a),2)*Math.cos(c-b)))},h=function(a,d,e,h){g.fillStyle="#808080";g.fillRect(0,0,300,300);f.fillStyle="#808080";f.fillRect(0,0,300,300);var l=Math.pow(2,a),k=(e+180)/360*l,n=(1-Math.log(Math.tan(d*Math.PI/180)+1/Math.cos(d*Math.PI/180))/Math.PI)/2*l,F=Math.floor(k),ba=Math.floor(n),
-ca=h?100*h/m(180/Math.PI*Math.atan(.5*(Math.exp(Math.PI-2*Math.PI*ba/l)-Math.exp(-(Math.PI-2*Math.PI*ba/l)))),F/l*360-180,(F+1)/l*360-180):0;d=b;for(e=0;3>e;e++)for(h=0;3>h;h++)c(a,F+e-1,ba+h-1,{Za:e,ab:h,Ua:d}).then(function(a){if(a.Ua===b){g.drawImage(a.M,100*a.Za,100*a.ab,100,100);a=k-F;var c=n-ba;a=100*a+100;c=100*c+100;f.putImageData(g.getImageData(0,0,300,300),0,0);void 0!==ca&&(f.beginPath(),f.arc(a,c,Math.max(ca,10),0,2*Math.PI,!1),f.lineWidth=2,f.fillStyle="rgba(244, 146, 66, 0.4)",f.strokeStyle=
-"rgba(244, 146, 66, 0.8)",f.stroke(),f.fill());if(void 0===ca||25<ca)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,k=function(c){c=Math.max(4,Math.min(19,c));n!==c&&(b++,n=c,h(n,Number(a.latitude),Number(a.longitude),Number(a.accuracy)))};k(12);var e=document.createElement("div"),l=document.createElement("div"),q=document.createElement("button"),t=document.createElement("button");e.className=
-"OSM-wrapper";d.className="OSM-canvas";l.className="OSM-controls";t.className="OSM-controls-zoomMin";q.className="OSM-controls-zoomPlus";t.addEventListener("click",function(){k(n-1)});q.addEventListener("click",function(){k(n+1)});l.appendChild(t);l.appendChild(q);e.appendChild(d);e.appendChild(l);return e}};function Qa(){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 Ra=function(){var a={};return function(b){var c=a[b];c||(c=a[b]=document.createElement("header"),c.textContent=b);return c}}();
-function vb(a){var b=a.b,c=document.createElement("div"),d=document.createElement("div"),e=document.createElement("ul");c.o=document.createElement("ul");c.C=document.createElement("ul");c.l=document.createElement("div");c.sa=document.createElement("div");c.ja=document.createElement("span");c.id=b+"_"+a.id;c.className="chatmsg-item";c.l.className="chatmsg-ts";c.sa.className="chatmsg-msg";c.ja.className="chatmsg-author-name";b=document.createElement("li");b.className="chatmsg-hover-reply";b.style.backgroundImage=
+return!1});return{display:function(c){b||(document.getElementById("settings").classList.remove("hidden"),b=!0);a(c||d.S);return this},ob:function(){return this},lb:d}}();function ub(a){if(void 0!==a.latitude&&void 0!==a.longitude&&-90<=a.latitude&&90>=a.latitude&&-180<=a.longitude&&180>=a.longitude){var b=0,c=function(a,b,c,d){return new Promise(function(e,f){var g=new Image;g.addEventListener("load",function(){d.O=g;e(d)});g.addEventListener("error",function(){console.warn("Error loading tile ",{zoom:a,x:b,y:c});f(g)});g.crossOrigin="anonymous";g.src="https://c.tile.openstreetmap.org/"+a+"/"+b+"/"+c+".png"})},d=document.createElement("canvas"),e=document.createElement("canvas");
+d.height=d.width=e.height=e.width=300;var f=d.getContext("2d"),g=e.getContext("2d"),h=function(a,b,c){a=a*Math.PI/180;b=b*Math.PI/180;c=c*Math.PI/180;return Math.abs(6371E3*Math.acos(Math.pow(Math.sin(a),2)+Math.pow(Math.cos(a),2)*Math.cos(c-b)))},n=function(a,d,e,k){g.fillStyle="#808080";g.fillRect(0,0,300,300);f.fillStyle="#808080";f.fillRect(0,0,300,300);var n=Math.pow(2,a),l=(e+180)/360*n,m=(1-Math.log(Math.tan(d*Math.PI/180)+1/Math.cos(d*Math.PI/180))/Math.PI)/2*n,p=Math.floor(l),F=Math.floor(m),
+ea=k?100*k/h(180/Math.PI*Math.atan(.5*(Math.exp(Math.PI-2*Math.PI*F/n)-Math.exp(-(Math.PI-2*Math.PI*F/n)))),p/n*360-180,(p+1)/n*360-180):0;d=b;for(e=0;3>e;e++)for(k=0;3>k;k++)c(a,p+e-1,F+k-1,{hb:e,jb:k,ab:d}).then(function(a){if(a.ab===b){g.drawImage(a.O,100*a.hb,100*a.jb,100,100);a=l-p;var c=m-F;a=100*a+100;c=100*c+100;f.putImageData(g.getImageData(0,0,300,300),0,0);void 0!==ea&&(f.beginPath(),f.arc(a,c,Math.max(ea,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===ea||25<ea)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,l=function(c){c=Math.max(4,Math.min(19,c));m!==c&&(b++,m=c,n(m,Number(a.latitude),Number(a.longitude),Number(a.accuracy)))};l(12);var e=document.createElement("div"),k=document.createElement("div"),p=document.createElement("button"),u=document.createElement("button");e.className=
+"OSM-wrapper";d.className="OSM-canvas";k.className="OSM-controls";u.className="OSM-controls-zoomMin";p.className="OSM-controls-zoomPlus";u.addEventListener("click",function(){l(m-1)});p.addEventListener("click",function(){l(m+1)});k.appendChild(u);k.appendChild(p);e.appendChild(d);e.appendChild(k);return e}};function Qa(){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 Ra=function(){var a={};return function(b){var c=a[b];c||(c=a[b]=document.createElement("header"),c.textContent=b);return c}}();
+function vb(a){var b=a.b,c=document.createElement("div"),d=document.createElement("div"),e=document.createElement("ul");c.s=document.createElement("ul");c.C=document.createElement("ul");c.m=document.createElement("div");c.wa=document.createElement("div");c.pa=document.createElement("span");c.id=b+"_"+a.id;c.className="chatmsg-item";c.m.className="chatmsg-ts";c.wa.className="chatmsg-msg";c.pa.className="chatmsg-author-name";b=document.createElement("li");b.className="chatmsg-hover-reply";b.style.backgroundImage=
 'url("repl.svg")';e.appendChild(b);b=document.createElement("li");b.className="chatmsg-hover-reaction";b.style.backgroundImage='url("smile.svg")';e.appendChild(b);a:{for(var b=E.context,f=0,g=b.a.length;f<g;f++)if(b.a[f].self.id===a.J){a=!0;break a}a=!1}a&&(a=document.createElement("li"),a.className="chatmsg-hover-edit",a.style.backgroundImage='url("edit.svg")',e.appendChild(a),a=document.createElement("li"),a.className="chatmsg-hover-remove",a.style.backgroundImage='url("remove.svg")',e.appendChild(a));
-e.className="chatmsg-hover";d.appendChild(c.ja);d.appendChild(c.sa);d.appendChild(c.l);d.appendChild(c.o);c.D=document.createElement("div");c.D.className="chatmsg-edited";d.appendChild(c.D);d.appendChild(c.C);d.className="chatmsg-content";c.o.className="chatmsg-attachments";c.C.className="chatmsg-reactions";c.appendChild(d);c.appendChild(e);return c}function wb(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 xb(a,b,c){var d=document.createElement("li"),e=document.createElement("div"),f=document.createElement("div"),g=document.createElement("a"),m=document.createElement("div"),h=document.createElement("img"),n=document.createElement("a"),k=document.createElement("div"),l=document.createElement("div"),q=document.createElement("div"),t=document.createElement("img"),w=document.createElement("div");d.className="chatmsg-attachment";e.style.borderColor=wb(b.color||"");e.className="chatmsg-attachment-block";
-f.className="chatmsg-attachment-pretext";b.pretext?f.innerHTML=a.u(b.pretext):f.classList.add("hidden");g.target="_blank";b.title?(g.innerHTML=a.u(b.title),b.title_link&&(g.href=b.title_link),g.className="chatmsg-attachment-title"):g.className="hidden chatmsg-attachment-title";n.target="_blank";m.className="chatmsg-author";b.author_name&&(n.innerHTML=a.u(b.author_name),n.href=b.author_link||"",n.className="chatmsg-author-name",h.className="chatmsg-author-img",b.author_icon&&(h.src=b.author_icon,m.appendChild(h)),
-m.appendChild(n));q.className="chatmsg-attachment-thumb";b.thumb_url?(h=document.createElement("img"),h.src=b.thumb_url,q.appendChild(h),e.classList.add("has-thumb"),b.video_html&&(q.dataset.video=b.video_html)):q.classList.add("hidden");k.className="chatmsg-attachment-content";h=a.u(b.text||"");l.className="chatmsg-attachment-text";h&&""!=h?l.innerHTML=h:l.classList.add("hidden");k.appendChild(q);k.appendChild(l);b.geo&&(l=ub(b.geo))&&k.appendChild(l);t.className="chatmsg-attachment-img";b.image_url?
-t.src=b.image_url:t.classList.add("hidden");w.className="chatmsg-attachment-footer";b.footer&&(l=document.createElement("span"),l.className="chatmsg-attachment-footer-text",l.innerHTML=a.u(b.footer),b.footer_icon&&(q=document.createElement("img"),q.src=b.footer_icon,q.className="chatmsg-attachment-footer-icon",w.appendChild(q)),w.appendChild(l));b.ts&&(l=document.createElement("span"),l.className="chatmsg-ts",l.innerHTML=K.W(b.ts),w.appendChild(l));e.appendChild(g);e.appendChild(m);e.appendChild(k);
-e.appendChild(t);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.u(d);e.appendChild(f);e.appendChild(g);e&&x.appendChild(e)})}if(b.actions&&
-b.actions.length)for(g=document.createElement("ul"),g.className="chatmsg-attachment-actions "+Ha,e.appendChild(g),m=0,k=b.actions.length;m<k;m++)(t=b.actions[m])&&(t=yb(c,m,t))&&g.appendChild(t);e.appendChild(w);d.appendChild(f);d.appendChild(e);return d}
-function yb(a,b,c){var d=document.createElement("li"),e=wb(c.style);d.textContent=c.text;e!==wb()&&(d.style.color=e);d.style.borderColor=e;d.dataset.attachmentIndex=a;d.dataset.actionIndex=b;d.className="chatmsg-attachment-actions-item "+Ga;return d}function Xa(a){var b=document.createElement("li"),c=document.createElement("span");c.textContent=a.name;b.appendChild(Qa());b.appendChild(c);return b}
+e.className="chatmsg-hover";d.appendChild(c.pa);d.appendChild(c.wa);d.appendChild(c.m);d.appendChild(c.s);c.D=document.createElement("div");c.D.className="chatmsg-edited";d.appendChild(c.D);d.appendChild(c.C);d.className="chatmsg-content";c.s.className="chatmsg-attachments";c.C.className="chatmsg-reactions";c.appendChild(d);c.appendChild(e);return c}function wb(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 xb(a,b,c){var d=document.createElement("li"),e=document.createElement("div"),f=document.createElement("div"),g=document.createElement("a"),h=document.createElement("div"),n=document.createElement("img"),m=document.createElement("a"),l=document.createElement("div"),k=document.createElement("div"),p=document.createElement("div"),u=document.createElement("img"),w=document.createElement("div");d.className="chatmsg-attachment";e.style.borderColor=wb(b.color||"");e.className="chatmsg-attachment-block";
+f.className="chatmsg-attachment-pretext";b.pretext?f.innerHTML=a.w(b.pretext):f.classList.add("hidden");g.target="_blank";b.title?(g.innerHTML=a.w(b.title),b.title_link&&(g.href=b.title_link),g.className="chatmsg-attachment-title"):g.className="hidden chatmsg-attachment-title";m.target="_blank";h.className="chatmsg-author";b.author_name&&(m.innerHTML=a.w(b.author_name),m.href=b.author_link||"",m.className="chatmsg-author-name",n.className="chatmsg-author-img",b.author_icon&&(n.src=b.author_icon,h.appendChild(n)),
+h.appendChild(m));p.className="chatmsg-attachment-thumb";b.thumb_url?(n=document.createElement("img"),n.src=b.thumb_url,p.appendChild(n),e.classList.add("has-thumb"),b.video_html&&(p.dataset.video=b.video_html)):p.classList.add("hidden");l.className="chatmsg-attachment-content";n=a.w(b.text||"");k.className="chatmsg-attachment-text";n&&""!=n?k.innerHTML=n:k.classList.add("hidden");l.appendChild(p);l.appendChild(k);b.geo&&(k=ub(b.geo))&&l.appendChild(k);u.className="chatmsg-attachment-img";b.image_url?
+u.src=b.image_url:u.classList.add("hidden");w.className="chatmsg-attachment-footer";b.footer&&(k=document.createElement("span"),k.className="chatmsg-attachment-footer-text",k.innerHTML=a.w(b.footer),b.footer_icon&&(p=document.createElement("img"),p.src=b.footer_icon,p.className="chatmsg-attachment-footer-icon",w.appendChild(p)),w.appendChild(k));b.ts&&(k=document.createElement("span"),k.className="chatmsg-ts",k.innerHTML=J.L(b.ts),w.appendChild(k));e.appendChild(g);e.appendChild(h);e.appendChild(l);
+e.appendChild(u);if(b.fields&&b.fields.length){var r=document.createElement("ul");e.appendChild(r);r.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&&r.appendChild(e)})}if(b.actions&&
+b.actions.length)for(g=document.createElement("ul"),g.className="chatmsg-attachment-actions "+Ha,e.appendChild(g),h=0,l=b.actions.length;h<l;h++)(u=b.actions[h])&&(u=yb(c,h,u))&&g.appendChild(u);e.appendChild(w);d.appendChild(f);d.appendChild(e);return d}
+function yb(a,b,c){var d=document.createElement("li"),e=wb(c.style);d.textContent=c.text;e!==wb()&&(d.style.color=e);d.style.borderColor=e;d.dataset.attachmentIndex=a;d.dataset.actionIndex=b;d.className="chatmsg-attachment-actions-item "+Fa;return d}function Xa(a){var b=document.createElement("li"),c=document.createElement("span");c.textContent=a.getName();b.appendChild(Qa());b.appendChild(c);return b}
 function rb(a){var b=document.createElement("lh");b.textContent=a;b.className="chat-command-header";return b}
-function sb(a){var b=document.createElement("li"),c=document.createElement("span"),d=document.createElement("span"),e=document.createElement("span");c.textContent=a.name;d.textContent=a.usage;e.textContent=a.a;b.appendChild(c);b.appendChild(d);b.appendChild(e);b.className="chat-command-item";c.className="chat-command-name";d.className="chat-command-usage";e.className="chat-command-desc";return b};var gb=function(){function a(a,b){for(a=a.target;a!==h&&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(){if(!c())return!1;G&&G(null);return!0}function c(){return h.parentElement?(h.parentElement.removeChild(n),h.parentElement.removeChild(h),!0):!1}function d(a){var b=0;a=void 0===a?t.value:a;if(m()){var c=0,d=window.searchEmojis(a),g=e(d,S.self.O.a),h;for(k in w)w[k].visible&&(w[k].visible=!1,l.removeChild(w[k].c));
-var k=0;for(h=g.length;k<h;k++){var B=g[k].name,n=w[B];if(!n){var n=w,F=B;var G=B;var B=window.makeEmoji(d[B]),y=document.createElement("span");y.appendChild(B);y.className="emoji-medium";G=f(G,y);n=n[F]=G}n.visible||(n.visible=!0,l.appendChild(n.c));c++}b+=c}k=b;var c=0;for(C in x)x[C].visible&&(x[C].visible=!1,q.removeChild(x[C].c));d=e(S.b.data,S.self.O.a);var C=0;for(b=d.length;C<b;C++)F=d[C].name,""!==a&&F.substr(0,a.length)!==a||"alias:"===S.b.data[F].substr(0,6)||(g=x[F],g||(g=x,n=h=F,F=S.b.data[F],
-G=document.createElement("span"),B=document.createElement("span"),G.className="emoji emoji-custom",G.style.backgroundImage='url("'+F+'")',B.appendChild(G),B.className="emoji-medium",n=f(n,B),g=g[h]=n),g.visible||(g.visible=!0,q.appendChild(g.c)),c++);return k+c}function e(a,b){var c=[],d;for(d in a){var e={name:d,Ra: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.Ra-b.Ra})}function f(a,
-b){var c=document.createElement("li");c.appendChild(b);c.className="emojibar-list-item";c.id="emojibar-"+a;return{visible:!1,c:c}}function g(a){var b=document.createElement("img"),c=document.createElement("div");b.src=a;c.appendChild(b);c.className="emojibar-header";return c}function m(){return"searchEmojis"in window}var h=document.createElement("div"),n=document.createElement("div"),k=document.createElement("div"),l=document.createElement("ul"),q=document.createElement("ul"),t=document.createElement("input"),
-w={},x={},y=document.createElement("div"),C=document.createElement("span"),B=document.createElement("span"),G,S;n.addEventListener("click",function(a){var c=h.getBoundingClientRect();(a.screenY<c.top||a.screenY>c.bottom||a.screenX<c.left||a.screenX>c.right)&&b()});n.className="emojibar-overlay";h.className="emojibar";k.className="emojibar-emojis";y.className="emojibar-detail";C.className="emojibar-detail-img";B.className="emojibar-detail-name";l.className=q.className="emojibar-list";t.className="emojibar-search";
-y.appendChild(C);y.appendChild(B);k.appendChild(g(window.emojiProviderHeader));k.appendChild(l);k.appendChild(g("emojicustom.png"));k.appendChild(q);h.appendChild(k);h.appendChild(y);h.appendChild(t);t.addEventListener("keyup",function(){d()});h.addEventListener("mousemove",function(b){a(b,function(a){var b=a?w[a]||x[a]:null;b?(C.innerHTML=b.c.outerHTML,B.textContent=":"+a+":"):(C.textContent="",B.textContent="")})});h.addEventListener("click",function(b){a(b,function(a){a&&c()&&G&&G(a)})});return{isSupported:m,
-ba:function(a,b,c){return m()?(S=b,G=c,a.appendChild(n),a.appendChild(h),t.value="",d(),t.focus(),!0):!1},search:d,close:b}}();var E,N=[];function zb(){fa.call(this)}zb.prototype=Object.create(fa.prototype);zb.prototype.constructor=zb;function ra(a){return a.a?a.a.id:null}function Ab(){this.b=0;this.context=new pa;this.a={}}
-Ab.prototype.update=function(a){var b=Date.now();a.v&&(this.b=a.v);if(a["static"])for(e in a["static"]){var c=qa(this.context,e);c||(c=new zb,this.context.push(c));ha(c,a["static"][e],b)}sa(this.context,function(a){a.N===a.B&&(a=N.indexOf(a),-1!==a&&N.splice(a,1))});if(a.live){for(e in a.live)(c=this.a[e])?la(c,a.live[e],b):c=this.a[e]=new Y(e,250,a.live[e],b);for(var d in a.live){var e=H(this.context,d);(c=e.j[d])?(this.a[d].a.length&&(c.N=Math.max(c.N,na(this.a[d]).l)),c.Y||(Bb(e,c,a.live[d]),M&&
-a.live[M.id]&&Q())):E.b=0}}a["static"]&&Pa();var f=!1;a.typing&&this.context.a.forEach(function(c){var d=f,e=a.typing,g=!1;if(c.s)for(var k in c.s)e[k]||(delete c.s[k],g=!0);if(e)for(k in e)if(c.j[k]){c.s[k]||(c.s[k]={});for(var l in e[k])c.s[k][l]||(g=!0),c.s[k][l]=b}f=d|g},this);(a["static"]||f)&&Va();a.config&&(Cb=new Db(a.config),Eb()&&mb.fb(!1).display(mb.cb.P),Fb());if(P&&M&&a["static"]&&a["static"][P.a.id]&&a["static"][P.a.id].channels&&a["static"][P.a.id].channels)for(d=a["static"][P.a.id].channels,
-e=0,c=d.length;e<c;e++)if(d[e].id===M.id){Q();break}};setInterval(function(){var a=!1,b=Date.now();ta(function(c){var d=!1,e;for(e in c.s){var f=!0,g;for(g in c.s[e])c.s[e][g]+3E3<b?(delete c.s[e][g],d=!0):f=!1;f&&(delete c.s[e],d=!0)}d&&(a=!0)});a&&Va()},1E3);
-function Bb(a,b,c){if(b!==M||!window.hasFocus){var d=new RegExp("<@"+a.self.id),e=!1,f=!1,g=!1;c.forEach(function(c){if(!(parseFloat(c.ts)<=b.B)){f=!0;var h;if(!(h=b instanceof r)&&(h=c.text)&&!(h=c.text.match(d)))a:{h=a.self.O.A;for(var m=0,k=h.length;m<k;m++)if(-1!==c.text.indexOf(h[m])){h=!0;break a}h=!1}h&&(-1===N.indexOf(b)&&(g=!0,N.push(b)),e=!0)}});if(f){O();if(c=document.getElementById("room_"+b.id))c.classList.add("unread"),e&&c.classList.add("unreadHi");g&&!window.hasFocus&&db()}}}
-function $a(){var a=M,b=N.indexOf(a);if(a.N>a.B){var c=E.a[a.id];if(c&&(c=c.a[c.a.length-1])){var d=new XMLHttpRequest;d.open("POST","api/markread?room="+a.id+"&id="+c.id+"&ts="+c.l,!0);d.send(null);a.B=c.l}}0<=b&&(N.splice(b,1),O());a=document.getElementById("room_"+a.id);a.classList.remove("unread");a.classList.remove("unreadHi")}E=new Ab;var Ua=function(){function a(a,c){c.sort(function(){return Math.random()-.5});for(var d=0,e=20;e<n-40;e+=l)for(var f=0;f+l<=k;f+=l)g(a,c[d],e,f),d++,d===c.length&&(c.sort(b),d=0)}function b(a,b){return a.M?b.M?Math.random()-.5:-1:1}function c(a,b){for(var e=0,f=a.length;e<f;e++)if(void 0===a[e].M){d(a[e].src,function(d){a[e].M=d;c(a,b)});return}var g=[];a.forEach(function(a){a.M&&g.push(a.M)});b(g)}function d(a,b){var c=new XMLHttpRequest;c.responseType="blob";c.onreadystatechange=function(){if(4===
+function sb(a){var b=document.createElement("li"),c=document.createElement("span"),d=document.createElement("span"),e=document.createElement("span");c.textContent=a.name;d.textContent=a.usage;e.textContent=a.a;b.appendChild(c);b.appendChild(d);b.appendChild(e);b.className="chat-command-item";c.className="chat-command-name";d.className="chat-command-usage";e.className="chat-command-desc";return b};var hb=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(){r={};k.textContent="";window.emojiProviderHeader&&(k.appendChild(h(window.emojiProviderHeader)),p.textContent="",k.appendChild(p));k.appendChild(h("emojicustom.png"));k.appendChild(u)}function c(){if(!d())return!1;N&&N(null);return!0}function d(){return m.parentElement?(m.parentElement.removeChild(l),m.parentElement.removeChild(m),
+!0):!1}function e(a){var b=0;a=void 0===a?w.value:a;if(n()){var c=0,d=window.searchEmojis(a),e=f(d,O?O.self.R.a:[]),k;for(h in r)r[h].visible&&(r[h].visible=!1,p.removeChild(r[h].c));var h=0;for(k=e.length;h<k;h++){var l=e[h].name,m=r[l];if(!m){var m=r,F=l;var C=l;var l=window.makeEmoji(d[l]),N=document.createElement("span");N.appendChild(l);N.className="emoji-medium";C=g(C,N);m=m[F]=C}m.visible||(m.visible=!0,p.appendChild(m.c));c++}b+=c}h=b;c=0;for(D in A)A[D].visible&&(A[D].visible=!1,u.removeChild(A[D].c));
+if(O){d=f(O.b.data,O?O.self.R.a:[]);var D=0;for(b=d.length;D<b;D++)F=d[D].name,""!==a&&F.substr(0,a.length)!==a||"alias:"===O.b.data[F].substr(0,6)||(e=A[F],e||(e=A,m=k=F,F=O.b.data[F],C=document.createElement("span"),l=document.createElement("span"),C.className="emoji emoji-custom",C.style.backgroundImage='url("'+F+'")',l.appendChild(C),l.className="emoji-medium",m=g(m,l),e=e[k]=m),e.visible||(e.visible=!0,u.appendChild(e.c)),c++);D=c}else D=0;return h+D}function f(a,b){var c=[],d;for(d in a){var e=
+{name:d,Xa: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.Xa-b.Xa})}function g(a,b){var c=document.createElement("li");c.appendChild(b);c.className="emojibar-list-item";c.id="emojibar-"+a;return{visible:!1,c:c}}function h(a){var b=document.createElement("img"),c=document.createElement("div");b.src=a;c.appendChild(b);c.className="emojibar-header";return c}function n(){return"searchEmojis"in
+window}var m=document.createElement("div"),l=document.createElement("div"),k=document.createElement("div"),p=document.createElement("ul"),u=document.createElement("ul"),w=document.createElement("input"),r={},A={},M=document.createElement("div"),C=document.createElement("span"),D=document.createElement("span"),N,O;l.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()});l.className="emojibar-overlay";m.className=
+"emojibar";k.className="emojibar-emojis";p.className=u.className="emojibar-list";w.className="emojibar-search";M.className="emojibar-detail";C.className="emojibar-detail-img";D.className="emojibar-detail-name";M.appendChild(C);M.appendChild(D);b();m.appendChild(k);m.appendChild(M);m.appendChild(w);w.addEventListener("keyup",function(){e()});m.addEventListener("mousemove",function(b){a(b,function(a){var b=a?r[a]||A[a]:null;b?(C.innerHTML=b.c.outerHTML,D.textContent=":"+a+":"):(C.textContent="",D.textContent=
+"")})});m.addEventListener("click",function(b){a(b,function(a){a&&d()&&N&&N(a)})});return{isSupported:n,ga:function(a,b,c){return n()?(O=b,N=c,a.appendChild(l),a.appendChild(m),w.value="",e(),w.focus(),!0):!1},search:e,close:c,reset:function(){b();e()}}}();var E,L=[];function zb(){da.call(this)}zb.prototype=Object.create(da.prototype);zb.prototype.constructor=zb;function qa(a){return a.a?a.a.id:null}function Ab(){this.b=0;this.context=new oa;this.a={}}
+Ab.prototype.update=function(a){var b=Date.now();a.v&&(this.b=a.v);if(a["static"])for(e in a["static"]){var c=pa(this.context,e);c||(c=new zb,this.context.push(c));ga(c,a["static"][e],b)}ra(this.context,function(a){a.P===a.B&&(a=L.indexOf(a),-1!==a&&L.splice(a,1))});if(a.live){for(e in a.live)(c=this.a[e])?ka(c,a.live[e],b):c=this.a[e]=new Y(e,250,a.live[e],b);for(var d in a.live){var e=G(this.context,d);(c=e.l[d])?(this.a[d].a.length&&(c.P=Math.max(c.P,ma(this.a[d]).m)),c.aa||(Bb(e,c,a.live[d]),
+K&&a.live[K.id]&&R())):E.b=0}}a["static"]&&Pa();var f=!1;a.typing&&this.context.a.forEach(function(c){var d=f,e=a.typing,g=!1;if(c.u)for(var l in c.u)e[l]||(delete c.u[l],g=!0);if(e)for(l in e)if(c.l[l]){c.u[l]||(c.u[l]={});for(var k in e[l])c.u[l][k]||(g=!0),c.u[l][k]=b}f=d|g},this);(a["static"]||f)&&Va();a.config&&(Cb=new Db(a.config),Eb()&&mb.ob(!1).display(mb.lb.S),Fb());if(Q&&K&&a["static"]&&a["static"][Q.a.id]&&a["static"][Q.a.id].channels&&a["static"][Q.a.id].channels)for(d=a["static"][Q.a.id].channels,
+e=0,c=d.length;e<c;e++)if(d[e].id===K.id){R();break}};setInterval(function(){var a=!1,b=Date.now();sa(function(c){var d=!1,e;for(e in c.u){var f=!0,g;for(g in c.u[e])c.u[e][g]+3E3<b?(delete c.u[e][g],d=!0):f=!1;f&&(delete c.u[e],d=!0)}d&&(a=!0)});a&&Va()},1E3);
+function Bb(a,b,c){if(b!==K||!window.hasFocus){var d=new RegExp("<@"+a.self.id),e=!1,f=!1,g=!1;c.forEach(function(c){if(!(parseFloat(c.ts)<=b.B)){f=!0;var h;if(!(h=b instanceof t)&&(h=c.text)&&!(h=c.text.match(d)))a:{h=a.self.R.A;for(var m=0,l=h.length;m<l;m++)if(-1!==c.text.indexOf(h[m])){h=!0;break a}h=!1}h&&(-1===L.indexOf(b)&&(g=!0,L.push(b)),e=!0)}});if(f){P();if(c=document.getElementById("room_"+b.id))c.classList.add("unread"),e&&c.classList.add("unreadHi");g&&!window.hasFocus&&eb()}}}
+function $a(){var a=K,b=L.indexOf(a);if(a.P>a.B){var c=E.a[a.id];if(c&&(c=c.a[c.a.length-1])){var d=new XMLHttpRequest;d.open("POST","api/markread?room="+a.id+"&id="+c.id+"&ts="+c.m,!0);d.send(null);a.B=c.m}}0<=b&&(L.splice(b,1),P());a=document.getElementById("room_"+a.id);a.classList.remove("unread");a.classList.remove("unreadHi")}E=new Ab;var Ua=function(){function a(a,c){c.sort(function(){return Math.random()-.5});for(var d=0,e=20;e<m-40;e+=k)for(var f=0;f+k<=l;f+=k)g(a,c[d],e,f),d++,d===c.length&&(c.sort(b),d=0)}function b(a,b){return a.O?b.O?Math.random()-.5:-1:1}function c(a,b){for(var e=0,f=a.length;e<f;e++)if(void 0===a[e].O){d(a[e].src,function(d){a[e].O=d;c(a,b)});return}var g=[];a.forEach(function(a){a.O&&g.push(a.O)});b(g)}function d(a,b){var c=new XMLHttpRequest;c.responseType="blob";c.onreadystatechange=function(){if(4===
 c.readyState)if(c.response){var a=new Image;a.onload=function(){var c=document.createElement("canvas");c.height=c.width=w;c=c.getContext("2d");c.drawImage(a,0,0,w,w);var c=c.getImageData(0,0,w,w),d=0,e;for(e=0;e<c.width*c.height*4;e+=4)c.data[e]=c.data[e+1]=c.data[e+2]=(c.data[e]+c.data[e+1]+c.data[e+2])/3,c.data[e+3]=50,d+=c.data[e];if(50>d/(c.height*c.width))for(e=0;e<c.width*c.height*4;e+=4)c.data[e]=c.data[e+1]=c.data[e+2]=255-c.data[e];b(c)};a.onerror=function(){b(null)};a.src=window.URL.createObjectURL(c.response)}else b(null)};
-c.open("GET",a,!0);c.send(null)}function e(){var a=h.createLinearGradient(0,0,0,k);a.addColorStop(0,"#4D394B");a.addColorStop(1,"#201820");h.fillStyle=a;h.fillRect(0,0,n,k);return h.getImageData(0,0,n,k)}function f(a,b){for(var c=(a.height-b.height)/2,d=0;d<b.height;d++)for(var e=0;e<b.width;e++){var f=b.data[4*(d*b.width+e)]/255,g=4*((d+c)*a.width+e+c);a.data[g]*=f;a.data[g+1]*=f;a.data[g+2]*=f}return a}function g(a,b,c,d){var e=Math.floor(d);a=[a.data[e*n*4+0],a.data[e*n*4+1],a.data[e*n*4+2]];h.fillStyle=
-"#"+(1.1*a[0]<<16|1.1*a[1]<<8|1.1*a[2]).toString(16);h.beginPath();h.moveTo(c+l/2,d+q);h.lineTo(c-q+l,d+l/2);h.lineTo(c+l/2,d-q+l);h.lineTo(c+q,d+l/2);h.closePath();h.fill();h.putImageData(f(h.getImageData(c+q,d+q,t,t),b),c+q,d+q)}var m=document.createElement("canvas"),h=m.getContext("2d"),n=m.width=250,k=m.height=290,l=(n-40)/3,q=.1*l,t=Math.floor(l-2*q),w=.5*t,x={},y={},C={};return function(b,d,f){if(x[b])f(x[b]);else if(C[b])y[b]?y[b].push(f):y[b]=[f];else{var g=e(),h=[];C[b]=!0;y[b]?y[b].push(f):
-y[b]=[f];for(var k in d)d[k].Ja||d[k].$a||h.push({src:"api/avatar?user="+d[k].id});c(h,function(c){a(g,c);x[b]=m.toDataURL();y[b].forEach(function(a){a(x[b])})})}}}();var X=0,M=null,P=null,T=null,V=null;function lb(){var a=new XMLHttpRequest;a.timeout=6E4;a.onreadystatechange=function(){if(4===a.readyState){var b=document.createElement("script"),c=document.createElement("link");b.innerHTML=a.response;b.language="text/javascript";c.href="hljs-androidstudio.css";c.rel="stylesheet";document.head.appendChild(c);document.body.appendChild(b)}};a.open("GET","highlight.pack.js",!0);a.send(null)}
-function Gb(){var a=M,b=new XMLHttpRequest;b.open("GET","api/hist?room="+a.id,!0);b.onreadystatechange=function(){if(4===b.readyState&&b.response){var c=b.response;try{c=JSON.parse(c)}catch(e){}var d=E.a[a.id];d?d=!!la(d,c,Date.now()):(E.a[a.id]=new Y(a,100,c,Date.now()),d=!0);d&&(Bb(H(E.context,a.id),a,c),a===M&&Q())}};b.send(null)}
-function Hb(a){var b=new XMLHttpRequest;b.timeout=6E4;b.onreadystatechange=function(){if(4===b.readyState)if(b.status){var c=null,d=2===Math.floor(b.status/100);if(d){X&&(X=0,Ya(!0));c=b.response;try{c=JSON.parse(c)}catch(e){c=null}}else X?(X+=Math.floor((X||5)/2),X=Math.min(60,X)):(X=5,Ya(!1));a(d,c)}else X&&(X=0,Ya(!0)),Hb(a)};b.open("GET","api?v="+E.b,!0);b.send(null)}function pb(){var a=new XMLHttpRequest;a.open("POST","api/typing?room="+M.id,!0);a.send(null)}
-function Ib(a,b){a?(b&&E.update(b),tb()):setTimeout(tb,1E3*X)}function tb(){Hb(Ib)}
-function kb(a){M&&(document.getElementById("room_"+M.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");M=a;P=H(E.context,a.id);Za();Ua(P.a.id,P.m,function(a){document.getElementById("chatCtx").style.backgroundImage="url("+a+")"});(!E.a[M.id]||100>E.a[M.id].a.length)&&Gb();document.getElementById("chatSystemContainer").classList.remove("no-room-selected")}
-function nb(a,b,c){var d=M;new FileReader;var e=new FormData,f=new XMLHttpRequest;e.append("file",b);e.append("filename",a);f.onreadystatechange=function(){4===f.readyState&&(204===f.status?c(null):c(f.statusText))};f.open("POST","api/file?room="+d.id);f.send(e)}
-function Jb(a,b,c){var d=new XMLHttpRequest;b="api/msg?room="+a.id+"&text="+encodeURIComponent(b);c&&(b+="&attachments="+encodeURIComponent(JSON.stringify([{fallback:c.text,author_name:I(c.J).name,text:c.text,footer:a.b?K.message:a.name,ts:c.l}])));d.open("POST",b,!0);d.send(null)}
-function ob(a){if(V){var b=new XMLHttpRequest;b.open("PUT","api/msg?room="+M.id+"&ts="+V.id+"&text="+encodeURIComponent(a),!0);b.send(null);return!0}if("/"===a[0]){var c=a.indexOf(" "),b=a.substr(0,-1===c?void 0:c);a=-1===c?"":a.substr(c);var c=P,d=qb.La(b);return d?(d.exec(c,M,a.trim()),!0):c&&(b=c.i.data[b])?(c=new XMLHttpRequest,c.open("POST","api/cmd?room="+M.id+"&cmd="+encodeURIComponent(b.name.substr(1))+"&args="+encodeURIComponent(a.trim()),!0),c.send(null),!0):!1}Jb(M,a,T);return!0}
-function hb(a){var b=new XMLHttpRequest;b.open("DELETE","api/msg?room="+M.id+"&ts="+a.id,!0);b.send(null)}function ab(a,b,c){var d=new XMLHttpRequest;d.open("POST","api/reaction?room="+a+"&msg="+b+"&reaction="+encodeURIComponent(c),!0);d.send(null)}function Sa(){var a={},b=[],c=this.value;sa(E.context,function(b){a[b.id]=ja(b,c)});for(var d in a){var e=document.getElementById("room_"+d);e&&(a[d].name+a[d].bb+a[d].ta+a[d].qa?(e.classList.remove("hidden"),b.push(d)):e.classList.add("hidden"))}};var Kb={emojione_v2_3:{Na:"emojione_v2.3.sprites.js",Ia:"emojione_v2.3.sprites.css",name:"Emojione v2.3"},emojione_v3:{Na:"emojione_v3.sprites.js",Ia:"emojione_v3.sprites.css",name:"Emojione v3"}},Lb=Kb.emojione_v2_3,Mb;
-function Nb(a){if(Mb!==a){console.log("Loading emoji pack "+a.name);var b=new XMLHttpRequest;b.timeout=6E4;b.onreadystatechange=function(){if(4===b.readyState){var c=document.createElement("script"),d=document.createElement("link");c.innerHTML=b.response;c.language="text/javascript";d.href=a.Ia;d.rel="stylesheet";document.head.appendChild(d);document.body.appendChild(c);for(var e in E.a)Ob(E.a[e]);Q()}};b.open("GET",a.Na,!0);b.send(null);Mb=a}}
-function Fb(){a:{var a=Cb;for(var b in a.P){var c=a.P[b].emojiProvider;if(c&&Kb[c]){a=c;break a}}a=void 0}Nb(a&&Kb[a]?Kb[a]:Lb)};function Y(a,b,c,d){D.call(this,a,b,0,c,d)}Y.prototype=Object.create(D.prototype);Y.prototype.constructor=Y;Y.prototype.i=function(a,b){return!0===a.isMeMessage?new Pb(this.id,a,b):!0===a.isNotice?new Qb(this.id,a,b):new Rb(this.id,a,b)};function Ob(a){a.a.forEach(function(a){a.F()})}
-var Z=function(){function a(a,d){return ya(d,{A:a.context.self.O.A,V:function(a){":"===a[0]&&":"===a[a.length-1]&&(a=a.substr(1,a.length-2));if(a=bb(a)){var b=document.createElement("span");b.className="emoji-small";b.appendChild(a);return b.outerHTML}return null},aa:function(c){return b(a,c)}})}function b(a,b){var c=b.indexOf("|");if(-1===c)var d=b;else{d=b.substr(0,c);var g=b.substr(c+1)}if("@"===d[0])if(d=ra(a.context)+"|"+d.substr(1),g=I(d))a=!0,d="#"+g.pa.id,g="@"+g.name;else return null;else if("#"===
-d[0])if(d=ra(a.context)+"|"+d.substr(1),g=ua(d))a=!0,d="#"+d,g="#"+g.name;else return null;else{if(!d.match(/^(https?|mailto):\/\//i))return null;a=!1}return{link:d,text:g||d,Ma:a}}return{F:function(a){a.R=!0;return a},T:function(a){a.c&&a.c.parentElement&&(a.c.remove(),delete a.c);return a},L:function(a){a.c?a.R&&(a.R=!1,a.I()):a.ia().I();return a.c},I:function(b){var c=I(b.J);b.c.l.innerHTML=K.W(b.l);b.c.sa.innerHTML=a(b,b.text);b.c.ja.textContent=c?c.name:b.username||"?";for(var c=document.createDocumentFragment(),
-e=0,f=b.o.length;e<f;e++){var g=b.o[e];g&&(g=xb(b,g,e))&&c.appendChild(g)}b.c.o.textContent="";b.c.o.appendChild(c);c=b.b;e=document.createDocumentFragment();if(b.C)for(var m in b.C){var f=c,g=b.id,h=m,n=b.C[m],k=bb(h);if(k){for(var l=document.createElement("li"),q=document.createElement("a"),t=document.createElement("span"),w=document.createElement("span"),x=[],y=0,C=n.length;y<C;y++){var B=I(n[y]);B&&x.push(B.name)}x.sort();w.textContent=x.join(", ");t.appendChild(k);t.className="emoji-small";q.href=
-"javascript:toggleReaction('"+f+"', '"+g+"', '"+h+"')";q.appendChild(t);q.appendChild(w);l.className="chatmsg-reaction-item";l.appendChild(q);f=l}else console.warn("Reaction id not found: "+h),f=null;f&&e.appendChild(f)}b.c.C.textContent="";b.c.C.appendChild(e);b.D&&(b.c.D.innerHTML=K.D(b.D),b.c.classList.add("edited"));return b},K:function(a){return a.c.cloneNode(!0)},u:function(b,d){return a(b,d)}}}();
-function Pb(a,b,c){v.call(this,b,c);this.context=H(E.context,a);this.b=a;this.c=Z.c;this.R=Z.R}Pb.prototype=Object.create(z.prototype);p=Pb.prototype;p.constructor=Pb;p.F=function(){return Z.F(this)};p.u=function(a){return Z.u(this,a)};p.T=function(){return Z.T(this)};p.L=function(){return Z.L(this)};p.ia=function(){this.c=vb(this);this.c.classList.add("chatmsg-me_message");return this};p.K=function(){return Z.K(this)};p.I=function(){Z.I(this);return this};
-p.update=function(a,b){z.prototype.update.call(this,a,b);this.F()};function Rb(a,b,c){v.call(this,b,c);this.context=H(E.context,a);this.b=a;this.c=Z.c;this.R=Z.R}Rb.prototype=Object.create(v.prototype);p=Rb.prototype;p.constructor=Rb;p.F=function(){return Z.F(this)};p.u=function(a){return Z.u(this,a)};p.T=function(){return Z.T(this)};p.L=function(){return Z.L(this)};p.ia=function(){this.c=vb(this);return this};p.K=function(){return Z.K(this)};p.I=function(){Z.I(this);return this};
-p.update=function(a,b){v.prototype.update.call(this,a,b);this.F();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.o.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 Qb(a,b,c){v.call(this,b,c);this.context=H(E.context,a);this.b=a;this.a=null;this.R=!0}Qb.prototype=Object.create(A.prototype);p=Qb.prototype;p.constructor=Qb;p.F=function(){return Z.F(this)};p.u=function(a){return Z.u(this,a)};p.T=function(){this.a&&this.a.parentElement&&(this.a.remove(),delete this.a);this.c&&delete this.c;return this};p.L=function(){Z.L(this);return this.a};p.K=function(){return this.a.cloneNode(!0)};
-p.ia=function(){this.c=vb(this);this.a=document.createElement("span");this.c.classList.add("chatmsg-notice");this.a.className="chatmsg-notice";this.a.textContent=K.Qa;this.a.appendChild(this.c);return this};p.I=function(){Z.I(this);return this};p.update=function(a,b){A.prototype.update.call(this,a,b);this.F()};function Eb(){var a=Cb.P,b;for(b in a)if(a.hasOwnProperty(b))return!1;return!0};var Cb;function Db(a){this.P={};for(var b=0,c=a.length;b<c;b++)if(null===a[b].service&&null===a[b].device){var d=void 0,e=JSON.parse(a[b].config);if(e.services)for(d in e.services)this.P[d]=e.services[d]}};var qb=function(){var a=[];return{La:function(b){for(var c=0,d=a.length;c<d;c++)if(-1!==a[c].names.indexOf(b))return a[c];return null},Ya: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},eb:function(b){b.S="client";b.exec=b.exec.bind(b);a.push(b)}}}();function Sb(){return new Promise(function(a,b){"geolocation"in window.navigator?navigator.geolocation.getCurrentPosition(function(c){c?a(c):b("denied")}):b("geolocation not available")})}
-wa.push(function(){qb.eb({name:"/sherlock",names:["/sherlock","/sharelock"],usage:"",description:K.Ta,exec:function(a,b){Sb().then(function(a){var c=a.coords.latitude,e=a.coords.longitude;Jb(b,"https://www.openstreetmap.org/?mlat="+c+"&mlon="+e+"&macc="+a.coords.accuracy+"#map=17/"+c+"/"+e)}).catch(function(a){console.error("Error: ",a)})}})});
+c.open("GET",a,!0);c.send(null)}function e(){var a=n.createLinearGradient(0,0,0,l);a.addColorStop(0,"#4D394B");a.addColorStop(1,"#201820");n.fillStyle=a;n.fillRect(0,0,m,l);return n.getImageData(0,0,m,l)}function f(a,b){for(var c=(a.height-b.height)/2,d=0;d<b.height;d++)for(var e=0;e<b.width;e++){var f=b.data[4*(d*b.width+e)]/255,g=4*((d+c)*a.width+e+c);a.data[g]*=f;a.data[g+1]*=f;a.data[g+2]*=f}return a}function g(a,b,c,d){var e=Math.floor(d);a=[a.data[e*m*4+0],a.data[e*m*4+1],a.data[e*m*4+2]];n.fillStyle=
+"#"+(1.1*a[0]<<16|1.1*a[1]<<8|1.1*a[2]).toString(16);n.beginPath();n.moveTo(c+k/2,d+p);n.lineTo(c-p+k,d+k/2);n.lineTo(c+k/2,d-p+k);n.lineTo(c+p,d+k/2);n.closePath();n.fill();n.putImageData(f(n.getImageData(c+p,d+p,u,u),b),c+p,d+p)}var h=document.createElement("canvas"),n=h.getContext("2d"),m=h.width=250,l=h.height=290,k=(m-40)/3,p=.1*k,u=Math.floor(k-2*p),w=.5*u,r={},A={},M={};return function(b,d,f){if(r[b])f(r[b]);else if(M[b])A[b]?A[b].push(f):A[b]=[f];else{var g=e(),k=[];M[b]=!0;A[b]?A[b].push(f):
+A[b]=[f];for(var l in d)d[l].Ma||d[l].ib||k.push({src:"api/avatar?user="+d[l].id});c(k,function(c){a(g,c);r[b]=h.toDataURL();A[b].forEach(function(a){a(r[b])})})}}}();var W=0,K=null,Q=null,T=null,V=null;function lb(){var a=new XMLHttpRequest;a.timeout=6E4;a.onreadystatechange=function(){if(4===a.readyState){var b=document.createElement("script"),c=document.createElement("link");b.innerHTML=a.response;b.language="text/javascript";c.href="hljs-androidstudio.css";c.rel="stylesheet";document.head.appendChild(c);document.body.appendChild(b)}};a.open("GET","highlight.pack.js",!0);a.send(null)}
+function Gb(){var a=K,b=new XMLHttpRequest;b.open("GET","api/hist?room="+a.id,!0);b.onreadystatechange=function(){if(4===b.readyState&&b.response){var c=b.response;try{c=JSON.parse(c)}catch(e){}var d=E.a[a.id];d?d=!!ka(d,c,Date.now()):(E.a[a.id]=new Y(a,100,c,Date.now()),d=!0);d&&(Bb(G(E.context,a.id),a,c),a===K&&R())}};b.send(null)}
+function Hb(a){var b=new XMLHttpRequest;b.timeout=6E4;b.onreadystatechange=function(){if(4===b.readyState)if(b.status){var c=null,d=2===Math.floor(b.status/100);if(d){W&&(W=0,Ya(!0));c=b.response;try{c=JSON.parse(c)}catch(e){c=null}}else W?(W+=Math.floor((W||5)/2),W=Math.min(60,W)):(W=5,Ya(!1));a(d,c)}else W&&(W=0,Ya(!0)),Hb(a)};b.open("GET","api?v="+E.b,!0);b.send(null)}function pb(){var a=new XMLHttpRequest;a.open("POST","api/typing?room="+K.id,!0);a.send(null)}
+function Ib(a,b){a?(b&&E.update(b),tb()):setTimeout(tb,1E3*W)}function tb(){Hb(Ib)}
+function Jb(a){K&&(document.getElementById("room_"+K.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");K=a;Q=G(E.context,a.id);Za();X.ra();Ua(Q.a.id,Q.j,function(a){document.getElementById("chatCtx").style.backgroundImage="url("+a+")"});(!E.a[K.id]||100>E.a[K.id].a.length)&&Gb();document.getElementById("chatSystemContainer").classList.remove("no-room-selected")}
+function Ta(){var a=document.location.hash.substr(1),b=ta(a);b&&b!==K?Jb(b):(a=H(a))&&a.V&&Jb(a.V)}function nb(a,b,c){var d=K;new FileReader;var e=new FormData,f=new XMLHttpRequest;e.append("file",b);e.append("filename",a);f.onreadystatechange=function(){4===f.readyState&&(204===f.status?c(null):c(f.statusText))};f.open("POST","api/file?room="+d.id);f.send(e)}
+function Kb(a,b,c){var d=new XMLHttpRequest;b="api/msg?room="+a.id+"&text="+encodeURIComponent(b);c&&(b+="&attachments="+encodeURIComponent(JSON.stringify([{fallback:c.text,author_name:H(c.J).getName(),text:c.text,footer:a.b?J.message:a.name,ts:c.m}])));d.open("POST",b,!0);d.send(null)}
+function ob(a){if(V){var b=new XMLHttpRequest;b.open("PUT","api/msg?room="+K.id+"&ts="+V.id+"&text="+encodeURIComponent(a),!0);b.send(null);return!0}if("/"===a[0]){var c=a.indexOf(" "),b=a.substr(0,-1===c?void 0:c);a=-1===c?"":a.substr(c);var c=Q,d=qb.Pa(b);return d?(d.exec(c,K,a.trim()),!0):c&&(b=c.i.data[b])?(c=new XMLHttpRequest,c.open("POST","api/cmd?room="+K.id+"&cmd="+encodeURIComponent(b.name.substr(1))+"&args="+encodeURIComponent(a.trim()),!0),c.send(null),!0):!1}Kb(K,a,T);return!0}
+function ib(a){var b=new XMLHttpRequest;b.open("DELETE","api/msg?room="+K.id+"&ts="+a.id,!0);b.send(null)}function bb(a,b,c){var d=new XMLHttpRequest;d.open("POST","api/reaction?room="+a+"&msg="+b+"&reaction="+encodeURIComponent(c),!0);d.send(null)}function Sa(){var a={},b=[],c=this.value;ra(E.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].kb+a[d].ia+a[d].fa?(e.classList.remove("hidden"),b.push(d)):e.classList.add("hidden"))}};var Lb={emojione_v2_3:{Ra:"emojione_v2.3.sprites.js",La:"emojione_v2.3.sprites.css",name:"Emojione v2.3"},emojione_v3:{Ra:"emojione_v3.sprites.js",La:"emojione_v3.sprites.css",name:"Emojione v3"}},Mb=Lb.emojione_v2_3,Nb;
+function Ob(a){if(Nb!==a){console.log("Loading emoji pack "+a.name);var b=new XMLHttpRequest;b.timeout=6E4;b.onreadystatechange=function(){if(4===b.readyState){var c=document.createElement("script"),d=document.createElement("link");c.innerHTML=b.response;c.language="text/javascript";d.href=a.La;d.rel="stylesheet";document.head.appendChild(d);document.body.appendChild(c);for(var e in E.a)Pb(E.a[e]);R();hb.reset()}};b.open("GET",a.Ra,!0);b.send(null);Nb=a}}
+function Fb(){a:{var a=Cb;for(var b in a.S){var c=a.S[b].emojiProvider;if(c&&Lb[c]){a=c;break a}}a=void 0}Ob(a&&Lb[a]?Lb[a]:Mb)};var X=function(){function a(){d.textContent=r.name;if(r instanceof t)c.style.backgroundImage="url(api/avatar?size=l&user="+r.a.id+")",g.textContent=(r.a.Za||(r.a.Oa||"")+" "+r.a.Sa).trim(),d.classList.add("presence-indicator"),r.a.ua?d.classList.remove("presence-away"):d.classList.add("presence-away"),f.classList.remove("hidden"),n.classList.remove("hidden"),n.textContent=r.a.mb||"",l.textContent=r.a.gb||"",m.classList.remove("hidden"),p.classList.add("hidden"),u.classList.add("hidden"),b.classList.remove("roominfo-channel"),
+b.classList.add("roominfo-user");else{var a=w;a.ca.topic?(f.classList.remove("hidden"),g.textContent=r.ia||"",h.textContent=r.o?J.xa(r.o,r.$):""):f.classList.add("hidden");a.ca.purpose?(m.classList.remove("hidden"),l.textContent=r.fa||"",k.textContent=r.i?J.xa(r.i,r.Z):""):m.classList.add("hidden");c.style.backgroundImage="";d.classList.remove("presence-indicator");p.classList.remove("hidden");u.classList.remove("hidden");b.classList.add("roominfo-channel");b.classList.remove("roominfo-user")}}var b=
+document.createElement("div"),c=document.createElement("header"),d=document.createElement("h3"),e=document.createElement("div"),f=document.createElement("div"),g=document.createElement("span"),h=document.createElement("span"),n=document.createElement("div"),m=document.createElement("div"),l=document.createElement("span"),k=document.createElement("span"),p=document.createElement("div"),u=document.createElement("ul"),w,r;b.className="chat-context-roominfo";c.className="roominfo-title";f.className="roominfo-topic";
+m.className="roominfo-purpose";n.className="roominfo-phone";p.className="roominfo-usercount";u.className="roominfo-userlist";k.className=h.className="roominfo-author";c.appendChild(d);b.appendChild(c);b.appendChild(e);f.appendChild(g);f.appendChild(h);m.appendChild(l);m.appendChild(k);e.appendChild(f);e.appendChild(n);e.appendChild(m);e.appendChild(p);e.appendChild(u);return{Wa:function(b,c){w=b;r=c;a();return this},update:function(){a();return this},show:function(a){a.appendChild(b);b.classList.remove("hidden");
+return this},ra:function(){b.classList.add("hidden");return this}}}();function Y(a,b,c,d){B.call(this,a,b,0,c,d)}Y.prototype=Object.create(B.prototype);Y.prototype.constructor=Y;Y.prototype.i=function(a,b){return!0===a.isMeMessage?new Qb(this.id,a,b):!0===a.isNotice?new Rb(this.id,a,b):new Sb(this.id,a,b)};function Pb(a){a.a.forEach(function(a){a.F()})}
+var Z=function(){function a(a,d){return xa(d,{A:a.context.self.R.A,Y:function(a){":"===a[0]&&":"===a[a.length-1]&&(a=a.substr(1,a.length-2));if(a=cb(a)){var b=document.createElement("span");b.className="emoji-small";b.appendChild(a);return b.outerHTML}return null},ea:function(c){return b(a,c)}})}function b(a,b){var c=b.indexOf("|");if(-1===c)var d=b;else{d=b.substr(0,c);var g=b.substr(c+1)}if("@"===d[0])if(d=qa(a.context)+"|"+d.substr(1),g=H(d))a=!0,d="#"+g.V.id,g="@"+g.getName();else return null;
+else if("#"===d[0])if(d=qa(a.context)+"|"+d.substr(1),g=ta(d))a=!0,d="#"+d,g="#"+g.name;else return null;else{if(!d.match(/^(https?|mailto):\/\//i))return null;a=!1}return{link:d,text:g||d,Qa:a}}return{F:function(a){a.T=!0;return a},W:function(a){a.c&&a.c.parentElement&&(a.c.remove(),delete a.c);return a},N:function(a){a.c?a.T&&(a.T=!1,a.I()):a.oa().I();return a.c},I:function(b){var c=H(b.J);b.c.m.innerHTML=J.L(b.m);b.c.wa.innerHTML=a(b,b.text);b.c.pa.textContent=c?c.getName():b.username||"?";for(var c=
+document.createDocumentFragment(),e=0,f=b.s.length;e<f;e++){var g=b.s[e];g&&(g=xb(b,g,e))&&c.appendChild(g)}b.c.s.textContent="";b.c.s.appendChild(c);c=b.b;e=document.createDocumentFragment();if(b.C)for(var h in b.C){var f=c,g=b.id,n=h,m=b.C[h],l=cb(n);if(l){for(var k=document.createElement("li"),p=document.createElement("a"),u=document.createElement("span"),w=document.createElement("span"),r=[],A=0,M=m.length;A<M;A++){var C=H(m[A]);C&&r.push(C.getName())}r.sort();w.textContent=r.join(", ");u.appendChild(l);
+u.className="emoji-small";p.href="javascript:toggleReaction('"+f+"', '"+g+"', '"+n+"')";p.appendChild(u);p.appendChild(w);k.className="chatmsg-reaction-item";k.appendChild(p);f=k}else console.warn("Reaction id not found: "+n),f=null;f&&e.appendChild(f)}b.c.C.textContent="";b.c.C.appendChild(e);b.D&&(b.c.D.innerHTML=J.D(b.D),b.c.classList.add("edited"));return b},K:function(a){return a.c.cloneNode(!0)},w:function(b,d){return a(b,d)}}}();
+function Qb(a,b,c){x.call(this,b,c);this.context=G(E.context,a);this.b=a;this.c=Z.c;this.T=Z.T}Qb.prototype=Object.create(y.prototype);q=Qb.prototype;q.constructor=Qb;q.F=function(){return Z.F(this)};q.w=function(a){return Z.w(this,a)};q.W=function(){return Z.W(this)};q.N=function(){return Z.N(this)};q.oa=function(){this.c=vb(this);this.c.classList.add("chatmsg-me_message");return this};q.K=function(){return Z.K(this)};q.I=function(){Z.I(this);return this};
+q.update=function(a,b){y.prototype.update.call(this,a,b);this.F()};function Sb(a,b,c){x.call(this,b,c);this.context=G(E.context,a);this.b=a;this.c=Z.c;this.T=Z.T}Sb.prototype=Object.create(x.prototype);q=Sb.prototype;q.constructor=Sb;q.F=function(){return Z.F(this)};q.w=function(a){return Z.w(this,a)};q.W=function(){return Z.W(this)};q.N=function(){return Z.N(this)};q.oa=function(){this.c=vb(this);return this};q.K=function(){return Z.K(this)};q.I=function(){Z.I(this);return this};
+q.update=function(a,b){x.prototype.update.call(this,a,b);this.F();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 Rb(a,b,c){x.call(this,b,c);this.context=G(E.context,a);this.b=a;this.a=null;this.T=!0}Rb.prototype=Object.create(z.prototype);q=Rb.prototype;q.constructor=Rb;q.F=function(){return Z.F(this)};q.w=function(a){return Z.w(this,a)};q.W=function(){this.a&&this.a.parentElement&&(this.a.remove(),delete this.a);this.c&&delete this.c;return this};q.N=function(){Z.N(this);return this.a};q.K=function(){return this.a.cloneNode(!0)};
+q.oa=function(){this.c=vb(this);this.a=document.createElement("span");this.c.classList.add("chatmsg-notice");this.a.className="chatmsg-notice";this.a.textContent=J.Va;this.a.appendChild(this.c);return this};q.I=function(){Z.I(this);return this};q.update=function(a,b){z.prototype.update.call(this,a,b);this.F()};function Eb(){var a=Cb.S,b;for(b in a)if(a.hasOwnProperty(b))return!1;return!0};var Cb;function Db(a){this.S={};for(var b=0,c=a.length;b<c;b++)if(null===a[b].service&&null===a[b].device){var d=void 0,e=JSON.parse(a[b].config);if(e.services)for(d in e.services)this.S[d]=e.services[d]}};var qb=function(){var a=[];return{Pa:function(b){for(var c=0,d=a.length;c<d;c++)if(-1!==a[c].names.indexOf(b))return a[c];return null},fb: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},nb:function(b){b.U="client";b.exec=b.exec.bind(b);a.push(b)}}}();function Tb(){return new Promise(function(a,b){"geolocation"in window.navigator?navigator.geolocation.getCurrentPosition(function(c){c?a(c):b("denied")}):b("geolocation not available")})}
+va.push(function(){qb.nb({name:"/sherlock",names:["/sherlock","/sharelock"],usage:"",description:J.$a,exec:function(a,b){Tb().then(function(a){var c=a.coords.latitude,e=a.coords.longitude;Kb(b,"https://www.openstreetmap.org/?mlat="+c+"&mlon="+e+"&macc="+a.coords.accuracy+"#map=17/"+c+"/"+e)}).catch(function(a){console.error("Error: ",a)})}})});
 })();

+ 18 - 5
srv/public/style.css

@@ -34,7 +34,7 @@ button, .button { border: 1px solid black; border-radius: 3px; background: rgb(2
 .chat-context-room { position: relative; color: #AB9BA9; }
 .chat-context-room > a { display: block; padding: 3px 0 3px 1.5em; text-decoration: none; color: #AB9BA9; margin-right: 15px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; }
 .chat-context-room.chat-ims { color: #4c9689; }
-.chat-context-room.chat-ims.away { color: #AB9BA9; font-style: italic; }
+.chat-context-room.chat-ims.presence-away { color: #AB9BA9; font-style: italic; }
 .chat-context-room > a:hover { background-color: rgba(10, 5, 10, .6); }
 .chat-context-room.selected { color: #fff; }
 .chat-context-room.selected > a { background-color: #4c9689; color: #fff; border-top-right-radius: 3px; border-bottom-right-radius: 3px; }
@@ -42,10 +42,22 @@ button, .button { border: 1px solid black; border-radius: 3px; background: rgb(2
 .chat-context-room.chat-context-typing::before { display: none; }
 .chat-context-room.chat-channel::before { content: "#"; }
 .chat-context-room.chat-group::before { content: attr(data-count); font-size: 12px; height: 12px; line-height: 12px; padding: 2px; overflow: hidden; background: #AB9BA9; color: white; border-radius: 5px; }
-.chat-context-room.chat-ims::before { content: " "; height: 6px; width: 6px; padding: 0; border: 2px solid currentColor; background: currentColor; border-radius: 5px; }
 .chat-context-room.chat-ims.selected::before { background-color: white; border-color: white; }
-.chat-context-room.chat-ims.away::before { background: transparent; }
-.chat-context-roominfo { position: absolute; display: block; left: 250px; width: 100%; max-width: 300px; top: 0; height: 100%; z-index: 100; background-color: #4D394B; }
+.presence-indicator::before { content: " "; display: inline-block; height: 6px; width: 6px; padding: 0; border: 2px solid currentColor; vertical-align: middle; background: currentColor; border-radius: 5px; }
+.presence-indicator.presence-away::before { background: transparent; }
+
+.chat-context .chat-context-roominfo { position: fixed; display: block; left: 235px; width: 400px; top: 0; bottom: 0; z-index: 100; background-color: #4D394B; color: white; overflow: auto; }
+.chatsystem-content .chat-context-roominfo { position: absolute; display: block; width: 400px; z-index: 100; background-color: #4D394B; color: white; overflow: auto; }
+.roominfo-title { background-position: center center; background-size: cover; padding: 250px 15px 0 15px; font-size: 1.75em; }
+.roominfo-topic,.roominfo-purpose,.roominfo-phone { margin: 20px 15px 0 15px; }
+.roominfo-topic *,.roominfo-purpose * { display: block; }
+.roominfo-author { color: #c1c1c1; }
+.roominfo-channel .roominfo-phone { display: none; }
+.roominfo-user .roominfo-author { display: none; }
+
+@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; }
@@ -88,7 +100,7 @@ button, .button { border: 1px solid black; border-radius: 3px; background: rgb(2
 .chatmsg-author { display: inline-block; }
 .chatmsg-author-img-wrapper { height: 36px; width: 36px; margin-right: 10px; }
 .chatmsg-author-img { max-height: 36px; max-width: 36px; border-radius: 3px; }
-.chatmsg-author-name { display: inline; font-weight: bold; }
+.chatsystem-content a.chatmsg-author-name, .chatmsg-author-name { text-decoration: none; display: inline; font-weight: bold; color: #000; }
 .chatmsg-msg { display: block; vertical-align: top; }
 .chatmsg-reactions:empty,.chatmsg-attachments:empty { display: none; }
 .chatmsg-reactions { padding: 0 0 0 24px; margin: 5px 0; list-style: none; }
@@ -234,5 +246,6 @@ button, .button { border: 1px solid black; border-radius: 3px; background: rgb(2
 
 @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%; }
 }
 

+ 21 - 19
srv/src/chatter.js

@@ -12,6 +12,10 @@ function Chatter(id) {
     this.status;
     /** @type {string} */
     this.realName;
+    /** @type {string} */
+    this.goal;
+    /** @type {string} */
+    this.phone;
     /** @type {boolean} */
     this.presence;
     /** @type {string} */
@@ -38,14 +42,14 @@ Chatter.prototype.toStatic = function(t) {
         ,"name": this.name
         ,"deleted": this.deleted
         ,"status": this.status
-        ,"real_name": this.realName // FIXME move to profile (or remove profile)
+        ,"real_name": this.realName
         ,"isPresent": this.presence
         ,"isBot": this.isBot
-        ,"profile": {
-            "email": this.email
-            ,"first_name": this.firstName
-            ,"last_name": this.lastName
-        }
+        ,"email": this.email
+        ,"phone": this.phone
+        ,"goal": this.goal
+        ,"first_name": this.firstName
+        ,"last_name": this.lastName
     };
 };
 
@@ -57,20 +61,14 @@ Chatter.prototype.update = function(userData, t) {
     if (userData["name"] !== undefined) this.name = userData["name"];
     if (userData["deleted"] !== undefined) this.deleted = userData["deleted"];
     if (userData["status"] !== undefined) this.status = userData["status"];
-    if (userData["real_name"] !== undefined)
-        this.realName = userData["real_name"];
-    else if (userData["profile"] && userData["profile"]["real_name"] !== undefined)
-        this.realName = userData["profile"]["real_name"];
-    if (userData["presence"] !== undefined)
-        this.presence = userData["presence"] !== 'away';
-    if (userData["isPresent"] !== undefined)
-        this.presence = userData["isPresent"];
+    if (userData["goal"] !== undefined) this.goal = userData["goal"];
+    if (userData["phone"] !== undefined) this.phone = userData["phone"];
+    if (userData["email"] !== undefined) this.email = userData["email"];
+    if (userData["first_name"] !== undefined) this.firstName = userData["first_name"];
+    if (userData["last_name"] !== undefined) this.lastName = userData["last_name"];
+    if (userData["real_name"] !== undefined) this.realName = userData["real_name"];
+    if (userData["isPresent"] !== undefined) this.presence = userData["isPresent"];
     if (userData["isBot"]) this.isBot = userData["isBot"];
-    if (userData["profile"]) {
-        this.email = userData["profile"]["email"];
-        this.firstName = userData["profile"]["first_name"];
-        this.lastName = userData["profile"]["last_name"];
-    }
     this.version = Math.max(this.version, t);
 };
 
@@ -82,6 +80,10 @@ Chatter.prototype.getLargeIcon = function() {
     return "api/avatar?size=l&user=" +this.id;
 };
 
+Chatter.prototype.getName = function() {
+    return this.name || this.realName || this.firstName || this.lastName;
+};
+
 /** @suppress {undefinedVars,checkTypes} */
 (function() {
     if (typeof module !== "undefined") {

+ 2 - 2
srv/src/room.js

@@ -129,7 +129,7 @@ Room.prototype.update = function(chanData, ctx, t, idPrefix) {
 Room.prototype.matchString = function(str, Utils) {
     return {
         name: Utils.getClosestDistanceString(str, this.name),
-        members: Utils.getClosestDistanceString(str, Object.values(/** @type {Object<string, Chatter|null>!} */ (this.users)), function(m) { return m ? m.name : null; }),
+        members: Utils.getClosestDistanceString(str, Object.values(/** @type {Object<string, Chatter|null>!} */ (this.users)), function(m) { return m ? m.getName() : null; }),
         topic: Utils.getClosestDistanceString(str, this.topic),
         purpose: Utils.getClosestDistanceString(str, this.purpose)
     };
@@ -145,7 +145,7 @@ function PrivateMessageRoom(id, user) {
     Room.call(this, id);
     /** @const @type {Chatter} */
     this.user = user;
-    this.name = this.user.name;
+    this.name = user.getName();
     this.isPrivate = true;
     user.privateRoom = this;
 };

+ 10 - 3
srv/src/slackData.js

@@ -142,13 +142,18 @@ SlackChatter.prototype.setPresence = function(presenceStr, t) {
 };
 
 SlackChatter.prototype.update = function(userData, t) {
-    Chatter.prototype.update.call(this, userData, t);
-
+    if (userData["presence"] !== undefined)
+        userData["isPresent"] = userData["presence"] !== 'away';
     if (userData["profile"]) {
         this.email = userData["profile"]["email"];
         this.firstName = userData["profile"]["first_name"];
         this.lastName = userData["profile"]["last_name"];
+        userData["name"] = userData["profile"]["display_name"];
+        userData["real_name"] = userData["profile"]["real_name"];
+        userData["phone"] = userData["profile"]["phone"];
+        userData["goal"] = userData["profile"]["title"];
     }
+    Chatter.prototype.update.call(this, userData, t);
 };
 
 SlackChatter.prototype.getSmallIcon = function() {
@@ -221,7 +226,9 @@ function SlackData(slack) {
         msgReactions: true,
         editMsg: true,
         removeMsg: true,
-        replyToMsg: true
+        replyToMsg: true,
+        topic: true,
+        purpose: true
     };
 };
 SlackData.prototype = Object.create(ChatContext.prototype);

+ 0 - 1
srv/src/template/index.js

@@ -29,7 +29,6 @@ module.exports.exec = function(req, res) {
                   <div class="chan-search-wrapper"><input type="search" id="chanSearch" class="chan-search-input" /></div>
                   <ul class="chat-context-channellist" id="chanList"></ul>
               </div>
-              <div id="ctxRoomInfo" class="chat-context-roominfo hidden"></div>
               <nav class="chat-context-menu">
                   <a id="ctxMenuSettings" href="javascript:void(0);"></a>
               </nav>