소스 검색

[quickfix] edited ts
[add] change background with context

B Thibault 8 년 전
부모
커밋
ca6ac4cc17
18개의 변경된 파일1018개의 추가작업 그리고 153개의 파일을 삭제
  1. 3 0
      .gitmodules
  2. 2 2
      cli/contextBackground.js
  3. 14 5
      cli/data.js
  4. 3 5
      cli/dom.js
  5. 1 0
      cli/highlight-js
  6. 8 6
      cli/lang/en.js
  7. 4 1
      cli/lang/fr.js
  8. 10 7
      cli/ui.js
  9. 3 1
      cli/uiMessage.js
  10. 816 0
      srv/public/hljs.js
  11. 1 0
      srv/public/index.html
  12. 89 89
      srv/public/slack.min.js
  13. 0 3
      srv/src/context.js
  14. 17 17
      srv/src/httpServ.js
  15. 4 7
      srv/src/message.js
  16. 22 3
      srv/src/multichatManager.js
  17. 6 7
      srv/src/slack.js
  18. 15 0
      srv/src/slackHistory.js

+ 3 - 0
.gitmodules

@@ -1,3 +1,6 @@
 [submodule "cli/msgFormatter"]
 	path = cli/msgFormatter
 	url = git.knacki.info:isundil/msgFormatter
+[submodule "cli/highlight-js"]
+	path = cli/highlight-js
+	url = https://github.com/isagalaev/highlight.js

+ 2 - 2
cli/contextBackground.js

@@ -173,7 +173,7 @@ var createContextBackground = (function() {
 
     return function(ctxId, users, cb) {
         if (RESULT[ctxId]) {
-            cb(RESULT);
+            cb(RESULT[ctxId]);
         } else if (isLoading[ctxId]) {
             if (!callbacks[ctxId])
                 callbacks[ctxId] = [ cb ];
@@ -199,7 +199,7 @@ var createContextBackground = (function() {
                 renderAvatars(background, imgs);
                 RESULT[ctxId] = canvas.toDataURL();
                 callbacks[ctxId].forEach(function(i) {
-                    i();
+                    i(RESULT[ctxId]);
                 });
             });
         }

+ 14 - 5
cli/data.js

@@ -62,10 +62,12 @@ SlackWrapper.prototype.update = function(data) {
         this.lastServerVersion = data["v"];
     if (data["static"]) {
         for (var i in data["static"]) {
-            var ctx = this.context[i];
-            if (!ctx)
-                ctx = this.context[i] = new SimpleChatSystem();
-            ctx.updateStatic(data["static"], now);
+            var ctx = this.context.getById(i);
+            if (!ctx) {
+                ctx = new SimpleChatSystem();
+                this.context.push(ctx);
+            }
+            ctx.getChatContext().updateStatic(data["static"][i], now);
         }
     }
     this.context.foreachChannels(function(chan) {
@@ -111,7 +113,14 @@ SlackWrapper.prototype.update = function(data) {
 };
 
 setInterval(function() {
-    if (DATA.context.cleanTyping(Date.now()))
+    var updated = false
+        ,now = Date.now();
+
+    DATA.context.foreachContext(function(ctx) {
+        if (ctx.getChatContext().cleanTyping(now))
+            updated = true;
+    });
+    if (updated)
         onTypingUpdated();
 }, 1000);
 

+ 3 - 5
cli/dom.js

@@ -219,10 +219,9 @@ function doCreateMessageDom(msg, skipAttachment) {
     msgBlock.appendChild(dom.ts);
     msgBlock.appendChild(dom.attachments);
 
-    var edited = document.createElement("div");
-    edited.innerHTML = locale.edited;
-    edited.className = R.klass.msg.edited;
-    msgBlock.appendChild(edited);
+    dom.edited = document.createElement("div");
+    dom.edited.className = R.klass.msg.edited;
+    msgBlock.appendChild(dom.edited);
 
     msgBlock.appendChild(dom.reactions);
     msgBlock.className = R.klass.msg.content;
@@ -284,7 +283,6 @@ function getColor(colorText) {
     return "#e3e4e6";
 }
 
-
 /**
  * @param {string} channelId
  * @param {UiNoticeMessage|UiMessage} msg

+ 1 - 0
cli/highlight-js

@@ -0,0 +1 @@
+Subproject commit cf4b46e5b7acfe2626a07914e1d0d4ef269aed4a

+ 8 - 6
cli/lang/en.js

@@ -3,7 +3,6 @@ lang["en"] = {
     ,unknownChannel: "Unknown channel"
     ,newMessage: "New message"
     ,netErrorShort: "Network"
-    ,edited: "(edited)"
     ,onlyVisible: "(only visible to you)"
 
     ,starred: "Starred"
@@ -18,12 +17,10 @@ lang["en"] = {
             ts = parseFloat(ts);
         var today = new Date()
             ,yesterday = new Date()
-            ,dateObj = new Date(ts * 1000);
+            ,dateObj = new Date(ts);
 
-        today.setHours(0);
-        today.setMinutes(0);
-        today.setSeconds(0);
-        today.setMilliseconds(0);
+        today.setHours(12, 0, 0, 0);
+        today.setTime(today.getTime() - 12 * 60 * 60 *1000);
         yesterday.setTime(today.getTime());
         yesterday.setDate(yesterday.getDate() -1);
 
@@ -43,3 +40,8 @@ lang["en"] = {
     }
 };
 
+lang["en"].edited = function(ts) {
+    return "(edited " +lang["en"].formatDate(ts) +")";
+};
+
+

+ 4 - 1
cli/lang/fr.js

@@ -3,7 +3,6 @@ lang["fr"] = {
     ,unknownChannel: "Channel inconnu"
     ,newMessage: "Nouveau message"
     ,netErrorShort: "Reseau"
-    ,edited: "(edité)"
     ,onlyVisible: "(visible seulement par vous)"
 
     ,starred: "Favoris"
@@ -43,3 +42,7 @@ lang["fr"] = {
     }
 };
 
+lang["fr"].edited = function(ts) {
+    return "(edité " +lang["fr"].formatDate(ts) +")";
+};
+

+ 10 - 7
cli/ui.js

@@ -434,7 +434,7 @@ function chatClickDelegate(e) {
                         onReplyingToUpdated();
                     }
                 } else if (msg && target.classList.contains(R.klass.msg.hover.reaction)) {
-                    EMOJI_BAR.spawn(document.body, function(emoji) {
+                    EMOJI_BAR.spawn(document.body, SELECTED_CONTEXT.getChatContext(), function(emoji) {
                         if (emoji)
                             addReaction(SELECTED_ROOM.id, msg.id, emoji);
                     });
@@ -603,11 +603,13 @@ document.addEventListener('DOMContentLoaded', function() {
                 endCmd = endCmd === -1 ? input.length : endCmd;
                 var inputCmd = input.substr(0, endCmd);
 
-                (SELECTED_CONTEXT ? SELECTED_CONTEXT.getChatContext().commands.data : []).forEach(function(currentCmd) {
+                var availableCommands = (SELECTED_CONTEXT ? SELECTED_CONTEXT.getChatContext().commands.data : {});
+                for (var currentCmdId in availableCommands) {
+                    var currentCmd = availableCommands[currentCmdId];
                     if ((!inputFinished && currentCmd.name.substr(0, endCmd) === inputCmd) ||
                         (inputFinished && currentCmd.name === inputCmd))
                         commands.push(currentCmd);
-                });
+                }
             }
             commands.sort(function(a, b) {
                 return a.category.localeCompare(b.category) || a.name.localeCompare(b.name);
@@ -650,10 +652,11 @@ document.addEventListener('DOMContentLoaded', function() {
             }
 
             emojiButton.addEventListener("click", function() {
-                EMOJI_BAR.spawn(document.body, function(e) {
-                    if (e) document.getElementById(R.id.message.input).value += ":"+e+":";
-                    focusInput();
-                });
+                if (SELECTED_CONTEXT)
+                    EMOJI_BAR.spawn(document.body, SELECTED_CONTEXT.getChatContext(), function(e) {
+                        if (e) document.getElementById(R.id.message.input).value += ":"+e+":";
+                        focusInput();
+                    });
             });
         } else {
             emojiButton.classList.add(R.klass.hidden);

+ 3 - 1
cli/uiMessage.js

@@ -200,8 +200,10 @@ var AbstractUiMessage = (function() {
             updateCommon(_this, sender);
             updateAttachments(_this, _this.channelId);
             updateReactions(_this, _this.channelId);
-            if (_this.edited)
+            if (_this.edited) {
+                _this.dom.edited.innerHTML = locale.edited(_this.edited);
                 _this.dom.classList.add(R.klass.msg.editedStatus);
+            }
             return _this;
         },
 

+ 816 - 0
srv/public/hljs.js

@@ -0,0 +1,816 @@
+/*
+Syntax highlighting with language autodetection.
+https://highlightjs.org/
+*/
+
+(function(factory) {
+
+  // Find the global object for export to both the browser and web workers.
+  var globalObject = typeof window === 'object' && window ||
+                     typeof self === 'object' && self;
+
+  // Setup highlight.js for different environments. First is Node.js or
+  // CommonJS.
+  if(typeof exports !== 'undefined') {
+    factory(exports);
+  } else if(globalObject) {
+    // Export hljs globally even when using AMD for cases when this script
+    // is loaded with others that may still expect a global hljs.
+    globalObject.hljs = factory({});
+
+    // Finally register the global hljs with AMD.
+    if(typeof define === 'function' && define.amd) {
+      define([], function() {
+        return globalObject.hljs;
+      });
+    }
+  }
+
+}(function(hljs) {
+  // Convenience variables for build-in objects
+  var ArrayProto = [],
+      objectKeys = Object.keys;
+
+  // Global internal variables used within the highlight.js library.
+  var languages = {},
+      aliases   = {};
+
+  // Regular expressions used throughout the highlight.js library.
+  var noHighlightRe    = /^(no-?highlight|plain|text)$/i,
+      languagePrefixRe = /\blang(?:uage)?-([\w-]+)\b/i,
+      fixMarkupRe      = /((^(<[^>]+>|\t|)+|(?:\n)))/gm;
+
+  var spanEndTag = '</span>';
+
+  // Global options used when within external APIs. This is modified when
+  // calling the `hljs.configure` function.
+  var options = {
+    classPrefix: 'hljs-',
+    tabReplace: null,
+    useBR: false,
+    languages: undefined
+  };
+
+
+  /* Utility functions */
+
+  function escape(value) {
+    return value.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
+  }
+
+  function tag(node) {
+    return node.nodeName.toLowerCase();
+  }
+
+  function testRe(re, lexeme) {
+    var match = re && re.exec(lexeme);
+    return match && match.index === 0;
+  }
+
+  function isNotHighlighted(language) {
+    return noHighlightRe.test(language);
+  }
+
+  function blockLanguage(block) {
+    var i, match, length, _class;
+    var classes = block.className + ' ';
+
+    classes += block.parentNode ? block.parentNode.className : '';
+
+    // language-* takes precedence over non-prefixed class names.
+    match = languagePrefixRe.exec(classes);
+    if (match) {
+      return getLanguage(match[1]) ? match[1] : 'no-highlight';
+    }
+
+    classes = classes.split(/\s+/);
+
+    for (i = 0, length = classes.length; i < length; i++) {
+      _class = classes[i]
+
+      if (isNotHighlighted(_class) || getLanguage(_class)) {
+        return _class;
+      }
+    }
+  }
+
+  function inherit(parent) {  // inherit(parent, override_obj, override_obj, ...)
+    var key;
+    var result = {};
+    var objects = Array.prototype.slice.call(arguments, 1);
+
+    for (key in parent)
+      result[key] = parent[key];
+    objects.forEach(function(obj) {
+      for (key in obj)
+        result[key] = obj[key];
+    });
+    return result;
+  }
+
+  /* Stream merging */
+
+  function nodeStream(node) {
+    var result = [];
+    (function _nodeStream(node, offset) {
+      for (var child = node.firstChild; child; child = child.nextSibling) {
+        if (child.nodeType === 3)
+          offset += child.nodeValue.length;
+        else if (child.nodeType === 1) {
+          result.push({
+            event: 'start',
+            offset: offset,
+            node: child
+          });
+          offset = _nodeStream(child, offset);
+          // Prevent void elements from having an end tag that would actually
+          // double them in the output. There are more void elements in HTML
+          // but we list only those realistically expected in code display.
+          if (!tag(child).match(/br|hr|img|input/)) {
+            result.push({
+              event: 'stop',
+              offset: offset,
+              node: child
+            });
+          }
+        }
+      }
+      return offset;
+    })(node, 0);
+    return result;
+  }
+
+  function mergeStreams(original, highlighted, value) {
+    var processed = 0;
+    var result = '';
+    var nodeStack = [];
+
+    function selectStream() {
+      if (!original.length || !highlighted.length) {
+        return original.length ? original : highlighted;
+      }
+      if (original[0].offset !== highlighted[0].offset) {
+        return (original[0].offset < highlighted[0].offset) ? original : highlighted;
+      }
+
+      /*
+      To avoid starting the stream just before it should stop the order is
+      ensured that original always starts first and closes last:
+
+      if (event1 == 'start' && event2 == 'start')
+        return original;
+      if (event1 == 'start' && event2 == 'stop')
+        return highlighted;
+      if (event1 == 'stop' && event2 == 'start')
+        return original;
+      if (event1 == 'stop' && event2 == 'stop')
+        return highlighted;
+
+      ... which is collapsed to:
+      */
+      return highlighted[0].event === 'start' ? original : highlighted;
+    }
+
+    function open(node) {
+      function attr_str(a) {return ' ' + a.nodeName + '="' + escape(a.value).replace('"', '&quot;') + '"';}
+      result += '<' + tag(node) + ArrayProto.map.call(node.attributes, attr_str).join('') + '>';
+    }
+
+    function close(node) {
+      result += '</' + tag(node) + '>';
+    }
+
+    function render(event) {
+      (event.event === 'start' ? open : close)(event.node);
+    }
+
+    while (original.length || highlighted.length) {
+      var stream = selectStream();
+      result += escape(value.substring(processed, stream[0].offset));
+      processed = stream[0].offset;
+      if (stream === original) {
+        /*
+        On any opening or closing tag of the original markup we first close
+        the entire highlighted node stack, then render the original tag along
+        with all the following original tags at the same offset and then
+        reopen all the tags on the highlighted stack.
+        */
+        nodeStack.reverse().forEach(close);
+        do {
+          render(stream.splice(0, 1)[0]);
+          stream = selectStream();
+        } while (stream === original && stream.length && stream[0].offset === processed);
+        nodeStack.reverse().forEach(open);
+      } else {
+        if (stream[0].event === 'start') {
+          nodeStack.push(stream[0].node);
+        } else {
+          nodeStack.pop();
+        }
+        render(stream.splice(0, 1)[0]);
+      }
+    }
+    return result + escape(value.substr(processed));
+  }
+
+  /* Initialization */
+
+  function expand_mode(mode) {
+    if (mode.variants && !mode.cached_variants) {
+      mode.cached_variants = mode.variants.map(function(variant) {
+        return inherit(mode, {variants: null}, variant);
+      });
+    }
+    return mode.cached_variants || (mode.endsWithParent && [inherit(mode)]) || [mode];
+  }
+
+  function compileLanguage(language) {
+
+    function reStr(re) {
+        return (re && re.source) || re;
+    }
+
+    function langRe(value, global) {
+      return new RegExp(
+        reStr(value),
+        'm' + (language.case_insensitive ? 'i' : '') + (global ? 'g' : '')
+      );
+    }
+
+    function compileMode(mode, parent) {
+      if (mode.compiled)
+        return;
+      mode.compiled = true;
+
+      mode.keywords = mode.keywords || mode.beginKeywords;
+      if (mode.keywords) {
+        var compiled_keywords = {};
+
+        var flatten = function(className, str) {
+          if (language.case_insensitive) {
+            str = str.toLowerCase();
+          }
+          str.split(' ').forEach(function(kw) {
+            var pair = kw.split('|');
+            compiled_keywords[pair[0]] = [className, pair[1] ? Number(pair[1]) : 1];
+          });
+        };
+
+        if (typeof mode.keywords === 'string') { // string
+          flatten('keyword', mode.keywords);
+        } else {
+          objectKeys(mode.keywords).forEach(function (className) {
+            flatten(className, mode.keywords[className]);
+          });
+        }
+        mode.keywords = compiled_keywords;
+      }
+      mode.lexemesRe = langRe(mode.lexemes || /\w+/, true);
+
+      if (parent) {
+        if (mode.beginKeywords) {
+          mode.begin = '\\b(' + mode.beginKeywords.split(' ').join('|') + ')\\b';
+        }
+        if (!mode.begin)
+          mode.begin = /\B|\b/;
+        mode.beginRe = langRe(mode.begin);
+        if (!mode.end && !mode.endsWithParent)
+          mode.end = /\B|\b/;
+        if (mode.end)
+          mode.endRe = langRe(mode.end);
+        mode.terminator_end = reStr(mode.end) || '';
+        if (mode.endsWithParent && parent.terminator_end)
+          mode.terminator_end += (mode.end ? '|' : '') + parent.terminator_end;
+      }
+      if (mode.illegal)
+        mode.illegalRe = langRe(mode.illegal);
+      if (mode.relevance == null)
+        mode.relevance = 1;
+      if (!mode.contains) {
+        mode.contains = [];
+      }
+      mode.contains = Array.prototype.concat.apply([], mode.contains.map(function(c) {
+        return expand_mode(c === 'self' ? mode : c)
+      }));
+      mode.contains.forEach(function(c) {compileMode(c, mode);});
+
+      if (mode.starts) {
+        compileMode(mode.starts, parent);
+      }
+
+      var terminators =
+        mode.contains.map(function(c) {
+          return c.beginKeywords ? '\\.?(' + c.begin + ')\\.?' : c.begin;
+        })
+        .concat([mode.terminator_end, mode.illegal])
+        .map(reStr)
+        .filter(Boolean);
+      mode.terminators = terminators.length ? langRe(terminators.join('|'), true) : {exec: function(/*s*/) {return null;}};
+    }
+
+    compileMode(language);
+  }
+
+  /*
+  Core highlighting function. Accepts a language name, or an alias, and a
+  string with the code to highlight. Returns an object with the following
+  properties:
+
+  - relevance (int)
+  - value (an HTML string with highlighting markup)
+
+  */
+  function highlight(name, value, ignore_illegals, continuation) {
+
+    function subMode(lexeme, mode) {
+      var i, length;
+
+      for (i = 0, length = mode.contains.length; i < length; i++) {
+        if (testRe(mode.contains[i].beginRe, lexeme)) {
+          return mode.contains[i];
+        }
+      }
+    }
+
+    function endOfMode(mode, lexeme) {
+      if (testRe(mode.endRe, lexeme)) {
+        while (mode.endsParent && mode.parent) {
+          mode = mode.parent;
+        }
+        return mode;
+      }
+      if (mode.endsWithParent) {
+        return endOfMode(mode.parent, lexeme);
+      }
+    }
+
+    function isIllegal(lexeme, mode) {
+      return !ignore_illegals && testRe(mode.illegalRe, lexeme);
+    }
+
+    function keywordMatch(mode, match) {
+      var match_str = language.case_insensitive ? match[0].toLowerCase() : match[0];
+      return mode.keywords.hasOwnProperty(match_str) && mode.keywords[match_str];
+    }
+
+    function buildSpan(classname, insideSpan, leaveOpen, noPrefix) {
+      var classPrefix = noPrefix ? '' : options.classPrefix,
+          openSpan    = '<span class="' + classPrefix,
+          closeSpan   = leaveOpen ? '' : spanEndTag
+
+      openSpan += classname + '">';
+
+      return openSpan + insideSpan + closeSpan;
+    }
+
+    function processKeywords() {
+      var keyword_match, last_index, match, result;
+
+      if (!top.keywords)
+        return escape(mode_buffer);
+
+      result = '';
+      last_index = 0;
+      top.lexemesRe.lastIndex = 0;
+      match = top.lexemesRe.exec(mode_buffer);
+
+      while (match) {
+        result += escape(mode_buffer.substring(last_index, match.index));
+        keyword_match = keywordMatch(top, match);
+        if (keyword_match) {
+          relevance += keyword_match[1];
+          result += buildSpan(keyword_match[0], escape(match[0]));
+        } else {
+          result += escape(match[0]);
+        }
+        last_index = top.lexemesRe.lastIndex;
+        match = top.lexemesRe.exec(mode_buffer);
+      }
+      return result + escape(mode_buffer.substr(last_index));
+    }
+
+    function processSubLanguage() {
+      var explicit = typeof top.subLanguage === 'string';
+      if (explicit && !languages[top.subLanguage]) {
+        return escape(mode_buffer);
+      }
+
+      var result = explicit ?
+                   highlight(top.subLanguage, mode_buffer, true, continuations[top.subLanguage]) :
+                   highlightAuto(mode_buffer, top.subLanguage.length ? top.subLanguage : undefined);
+
+      // Counting embedded language score towards the host language may be disabled
+      // with zeroing the containing mode relevance. Usecase in point is Markdown that
+      // allows XML everywhere and makes every XML snippet to have a much larger Markdown
+      // score.
+      if (top.relevance > 0) {
+        relevance += result.relevance;
+      }
+      if (explicit) {
+        continuations[top.subLanguage] = result.top;
+      }
+      return buildSpan(result.language, result.value, false, true);
+    }
+
+    function processBuffer() {
+      result += (top.subLanguage != null ? processSubLanguage() : processKeywords());
+      mode_buffer = '';
+    }
+
+    function startNewMode(mode) {
+      result += mode.className? buildSpan(mode.className, '', true): '';
+      top = Object.create(mode, {parent: {value: top}});
+    }
+
+    function processLexeme(buffer, lexeme) {
+
+      mode_buffer += buffer;
+
+      if (lexeme == null) {
+        processBuffer();
+        return 0;
+      }
+
+      var new_mode = subMode(lexeme, top);
+      if (new_mode) {
+        if (new_mode.skip) {
+          mode_buffer += lexeme;
+        } else {
+          if (new_mode.excludeBegin) {
+            mode_buffer += lexeme;
+          }
+          processBuffer();
+          if (!new_mode.returnBegin && !new_mode.excludeBegin) {
+            mode_buffer = lexeme;
+          }
+        }
+        startNewMode(new_mode, lexeme);
+        return new_mode.returnBegin ? 0 : lexeme.length;
+      }
+
+      var end_mode = endOfMode(top, lexeme);
+      if (end_mode) {
+        var origin = top;
+        if (origin.skip) {
+          mode_buffer += lexeme;
+        } else {
+          if (!(origin.returnEnd || origin.excludeEnd)) {
+            mode_buffer += lexeme;
+          }
+          processBuffer();
+          if (origin.excludeEnd) {
+            mode_buffer = lexeme;
+          }
+        }
+        do {
+          if (top.className) {
+            result += spanEndTag;
+          }
+          if (!top.skip && !top.subLanguage) {
+            relevance += top.relevance;
+          }
+          top = top.parent;
+        } while (top !== end_mode.parent);
+        if (end_mode.starts) {
+          startNewMode(end_mode.starts, '');
+        }
+        return origin.returnEnd ? 0 : lexeme.length;
+      }
+
+      if (isIllegal(lexeme, top))
+        throw new Error('Illegal lexeme "' + lexeme + '" for mode "' + (top.className || '<unnamed>') + '"');
+
+      /*
+      Parser should not reach this point as all types of lexemes should be caught
+      earlier, but if it does due to some bug make sure it advances at least one
+      character forward to prevent infinite looping.
+      */
+      mode_buffer += lexeme;
+      return lexeme.length || 1;
+    }
+
+    var language = getLanguage(name);
+    if (!language) {
+      throw new Error('Unknown language: "' + name + '"');
+    }
+
+    compileLanguage(language);
+    var top = continuation || language;
+    var continuations = {}; // keep continuations for sub-languages
+    var result = '', current;
+    for(current = top; current !== language; current = current.parent) {
+      if (current.className) {
+        result = buildSpan(current.className, '', true) + result;
+      }
+    }
+    var mode_buffer = '';
+    var relevance = 0;
+    try {
+      var match, count, index = 0;
+      while (true) {
+        top.terminators.lastIndex = index;
+        match = top.terminators.exec(value);
+        if (!match)
+          break;
+        count = processLexeme(value.substring(index, match.index), match[0]);
+        index = match.index + count;
+      }
+      processLexeme(value.substr(index));
+      for(current = top; current.parent; current = current.parent) { // close dangling modes
+        if (current.className) {
+          result += spanEndTag;
+        }
+      }
+      return {
+        relevance: relevance,
+        value: result,
+        language: name,
+        top: top
+      };
+    } catch (e) {
+      if (e.message && e.message.indexOf('Illegal') !== -1) {
+        return {
+          relevance: 0,
+          value: escape(value)
+        };
+      } else {
+        throw e;
+      }
+    }
+  }
+
+  /*
+  Highlighting with language detection. Accepts a string with the code to
+  highlight. Returns an object with the following properties:
+
+  - language (detected language)
+  - relevance (int)
+  - value (an HTML string with highlighting markup)
+  - second_best (object with the same structure for second-best heuristically
+    detected language, may be absent)
+
+  */
+  function highlightAuto(text, languageSubset) {
+    languageSubset = languageSubset || options.languages || objectKeys(languages);
+    var result = {
+      relevance: 0,
+      value: escape(text)
+    };
+    var second_best = result;
+    languageSubset.filter(getLanguage).forEach(function(name) {
+      var current = highlight(name, text, false);
+      current.language = name;
+      if (current.relevance > second_best.relevance) {
+        second_best = current;
+      }
+      if (current.relevance > result.relevance) {
+        second_best = result;
+        result = current;
+      }
+    });
+    if (second_best.language) {
+      result.second_best = second_best;
+    }
+    return result;
+  }
+
+  /*
+  Post-processing of the highlighted markup:
+
+  - replace TABs with something more useful
+  - replace real line-breaks with '<br>' for non-pre containers
+
+  */
+  function fixMarkup(value) {
+    return !(options.tabReplace || options.useBR)
+      ? value
+      : value.replace(fixMarkupRe, function(match, p1) {
+          if (options.useBR && match === '\n') {
+            return '<br>';
+          } else if (options.tabReplace) {
+            return p1.replace(/\t/g, options.tabReplace);
+          }
+          return '';
+      });
+  }
+
+  function buildClassName(prevClassName, currentLang, resultLang) {
+    var language = currentLang ? aliases[currentLang] : resultLang,
+        result   = [prevClassName.trim()];
+
+    if (!prevClassName.match(/\bhljs\b/)) {
+      result.push('hljs');
+    }
+
+    if (prevClassName.indexOf(language) === -1) {
+      result.push(language);
+    }
+
+    return result.join(' ').trim();
+  }
+
+  /*
+  Applies highlighting to a DOM node containing code. Accepts a DOM node and
+  two optional parameters for fixMarkup.
+  */
+  function highlightBlock(block) {
+    var node, originalStream, result, resultNode, text;
+    var language = blockLanguage(block);
+
+    if (isNotHighlighted(language))
+        return;
+
+    if (options.useBR) {
+      node = document.createElementNS('http://www.w3.org/1999/xhtml', 'div');
+      node.innerHTML = block.innerHTML.replace(/\n/g, '').replace(/<br[ \/]*>/g, '\n');
+    } else {
+      node = block;
+    }
+    text = node.textContent;
+    result = language ? highlight(language, text, true) : highlightAuto(text);
+
+    originalStream = nodeStream(node);
+    if (originalStream.length) {
+      resultNode = document.createElementNS('http://www.w3.org/1999/xhtml', 'div');
+      resultNode.innerHTML = result.value;
+      result.value = mergeStreams(originalStream, nodeStream(resultNode), text);
+    }
+    result.value = fixMarkup(result.value);
+
+    block.innerHTML = result.value;
+    block.className = buildClassName(block.className, language, result.language);
+    block.result = {
+      language: result.language,
+      re: result.relevance
+    };
+    if (result.second_best) {
+      block.second_best = {
+        language: result.second_best.language,
+        re: result.second_best.relevance
+      };
+    }
+  }
+
+  /*
+  Updates highlight.js global options with values passed in the form of an object.
+  */
+  function configure(user_options) {
+    options = inherit(options, user_options);
+  }
+
+  /*
+  Applies highlighting to all <pre><code>..</code></pre> blocks on a page.
+  */
+  function initHighlighting() {
+    if (initHighlighting.called)
+      return;
+    initHighlighting.called = true;
+
+    var blocks = document.querySelectorAll('pre code');
+    ArrayProto.forEach.call(blocks, highlightBlock);
+  }
+
+  /*
+  Attaches highlighting to the page load event.
+  */
+  function initHighlightingOnLoad() {
+    addEventListener('DOMContentLoaded', initHighlighting, false);
+    addEventListener('load', initHighlighting, false);
+  }
+
+  function registerLanguage(name, language) {
+    var lang = languages[name] = language(hljs);
+    if (lang.aliases) {
+      lang.aliases.forEach(function(alias) {aliases[alias] = name;});
+    }
+  }
+
+  function listLanguages() {
+    return objectKeys(languages);
+  }
+
+  function getLanguage(name) {
+    name = (name || '').toLowerCase();
+    return languages[name] || languages[aliases[name]];
+  }
+
+  /* Interface definition */
+
+  hljs.highlight = highlight;
+  hljs.highlightAuto = highlightAuto;
+  hljs.fixMarkup = fixMarkup;
+  hljs.highlightBlock = highlightBlock;
+  hljs.configure = configure;
+  hljs.initHighlighting = initHighlighting;
+  hljs.initHighlightingOnLoad = initHighlightingOnLoad;
+  hljs.registerLanguage = registerLanguage;
+  hljs.listLanguages = listLanguages;
+  hljs.getLanguage = getLanguage;
+  hljs.inherit = inherit;
+
+  // Common regexps
+  hljs.IDENT_RE = '[a-zA-Z]\\w*';
+  hljs.UNDERSCORE_IDENT_RE = '[a-zA-Z_]\\w*';
+  hljs.NUMBER_RE = '\\b\\d+(\\.\\d+)?';
+  hljs.C_NUMBER_RE = '(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)'; // 0x..., 0..., decimal, float
+  hljs.BINARY_NUMBER_RE = '\\b(0b[01]+)'; // 0b...
+  hljs.RE_STARTERS_RE = '!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~';
+
+  // Common modes
+  hljs.BACKSLASH_ESCAPE = {
+    begin: '\\\\[\\s\\S]', relevance: 0
+  };
+  hljs.APOS_STRING_MODE = {
+    className: 'string',
+    begin: '\'', end: '\'',
+    illegal: '\\n',
+    contains: [hljs.BACKSLASH_ESCAPE]
+  };
+  hljs.QUOTE_STRING_MODE = {
+    className: 'string',
+    begin: '"', end: '"',
+    illegal: '\\n',
+    contains: [hljs.BACKSLASH_ESCAPE]
+  };
+  hljs.PHRASAL_WORDS_MODE = {
+    begin: /\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/
+  };
+  hljs.COMMENT = function (begin, end, inherits) {
+    var mode = hljs.inherit(
+      {
+        className: 'comment',
+        begin: begin, end: end,
+        contains: []
+      },
+      inherits || {}
+    );
+    mode.contains.push(hljs.PHRASAL_WORDS_MODE);
+    mode.contains.push({
+      className: 'doctag',
+      begin: '(?:TODO|FIXME|NOTE|BUG|XXX):',
+      relevance: 0
+    });
+    return mode;
+  };
+  hljs.C_LINE_COMMENT_MODE = hljs.COMMENT('//', '$');
+  hljs.C_BLOCK_COMMENT_MODE = hljs.COMMENT('/\\*', '\\*/');
+  hljs.HASH_COMMENT_MODE = hljs.COMMENT('#', '$');
+  hljs.NUMBER_MODE = {
+    className: 'number',
+    begin: hljs.NUMBER_RE,
+    relevance: 0
+  };
+  hljs.C_NUMBER_MODE = {
+    className: 'number',
+    begin: hljs.C_NUMBER_RE,
+    relevance: 0
+  };
+  hljs.BINARY_NUMBER_MODE = {
+    className: 'number',
+    begin: hljs.BINARY_NUMBER_RE,
+    relevance: 0
+  };
+  hljs.CSS_NUMBER_MODE = {
+    className: 'number',
+    begin: hljs.NUMBER_RE + '(' +
+      '%|em|ex|ch|rem'  +
+      '|vw|vh|vmin|vmax' +
+      '|cm|mm|in|pt|pc|px' +
+      '|deg|grad|rad|turn' +
+      '|s|ms' +
+      '|Hz|kHz' +
+      '|dpi|dpcm|dppx' +
+      ')?',
+    relevance: 0
+  };
+  hljs.REGEXP_MODE = {
+    className: 'regexp',
+    begin: /\//, end: /\/[gimuy]*/,
+    illegal: /\n/,
+    contains: [
+      hljs.BACKSLASH_ESCAPE,
+      {
+        begin: /\[/, end: /\]/,
+        relevance: 0,
+        contains: [hljs.BACKSLASH_ESCAPE]
+      }
+    ]
+  };
+  hljs.TITLE_MODE = {
+    className: 'title',
+    begin: hljs.IDENT_RE,
+    relevance: 0
+  };
+  hljs.UNDERSCORE_TITLE_MODE = {
+    className: 'title',
+    begin: hljs.UNDERSCORE_IDENT_RE,
+    relevance: 0
+  };
+  hljs.METHOD_GUARD = {
+    // excludes method names from keyword processing
+    begin: '\\.\\s*' + hljs.UNDERSCORE_IDENT_RE,
+    relevance: 0
+  };
+
+  return hljs;
+}));

+ 1 - 0
srv/public/index.html

@@ -39,6 +39,7 @@
         <div class="error" id="neterror"></div>
         <script src="emojione_v2.3.sprites.js"></script>
         <script src="openpgp.min.js"></script>
+        <script src="hljs.js"></script>
         <script src="slack.min.js"></script>
     </body>
 </html>

+ 89 - 89
srv/public/slack.min.js

@@ -1,94 +1,94 @@
 "use strict";(function(){
-var p;function aa(a){this.id=a;this.version=0}aa.prototype.update=function(a,b){void 0!==a.name&&(this.name=a.name);this.version=Math.max(this.version,b)};function ba(a){this.a=a.desc;this.name=a.name;this.type=a.type;this.usage=a.usage;this.S=a.category}function ca(){this.fa={};this.u=[]}
-ca.prototype.update=function(a,b){this.fa=JSON.parse(a.emoji_use);a.highlight_words?this.u=(a.highlight_words||"").split(",").filter(function(a){return""!==a.trim()}):a.highlights&&(this.u=a.highlights);this.version=Math.max(this.version,b)};function da(){this.b=null;this.l={};this.m={};this.self=null;this.a={version:0,data:{}};this.i={version:0,data:{}};this.D={};this.A=0}
-function ea(a,b,c){var d=d||"";b.team&&(a.b||(a.b=new aa(b.team.id)),a.b.update(b.team,c));if(b.users)for(var e=0,g=b.users.length;e<g;e++){var f=a.m[d+b.users[e].id];f||(f=a.m[d+b.users[e].id]=new fa(b.users[e].id));f.update(b.users[e],c)}if(b.channels)for(e=0,g=b.channels.length;e<g;e++){f=a.l[d+b.channels[e].id];if(!f){var f=a.l,l=d+b.channels[e].id;var h=b.channels[e];h=h.pv?new q(h.id,a.m[h.user]):new r(h.id);f=f[l]=h}f.update(b.channels[e],a,c,d)}b.emojis&&(a.a.data=b.emojis,a.a.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}a.A=Math.max(a.A,c);b.self&&(a.self=a.m[d+b.self.id]||null,a.self?(a.self.M||(a.self.M=new ca),a.self.M.update(b.self.prefs,c)):a.A=0);if(void 0!==b.typing)for(e in a.D={},b.typing){a.D[e]={};for(var n in b.typing[e])a.D[e][n]=c}}"undefined"!==typeof module&&(module.H.Ra=da,module.H.Sa=aa,module.H.Ua=ba);function r(a){this.id=a;this.I=!1;this.w=this.B=0;this.m={};this.version=0}
-r.prototype.update=function(a,b,c,d){d=d||"";void 0!==a.name&&(this.name=a.name);void 0!==a.is_archived&&(this.X=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.w=parseFloat(a.last_msg));void 0!==a.is_private&&(this.b=a.is_private);a.latest&&(this.w=parseFloat(a.latest.ts));void 0!==a.is_starred&&(this.I=a.is_starred);if(a.members&&(this.m={},a.members))for(var e=0,g=a.members.length;e<g;e++){var f=
-b.m[d+a.members[e]];this.m[f.id]=f;f.l[this.id]=this}this.version=Math.max(this.version,c)};function q(a,b){r.call(this,a);this.a=b;this.name=this.a.name;this.b=!0;b.Ja=this}q.prototype=Object.create(r.prototype);q.prototype.constructor=q;"undefined"!==typeof module&&(module.H.$a=r,module.H.Za=q);function x(a,b){this.G=a.user;this.username=a.username;this.id=a.id||a.ts;this.j=parseFloat(a.ts);this.text="";this.o=[];this.i=this.T=this.I=!1;this.C={};this.version=b;this.update(a,b)}function z(a,b){x.call(this,a,b)}function A(a,b){x.call(this,a,b)}
-x.prototype.update=function(a,b){if(a){if(this.text=a.text||"",a.attachments&&(this.o=a.attachments),this.I=!!a.is_starred,this.T=!!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){this.id="string"===typeof a?a:a.id;this.a=[];this.i=b;c&&ga(this,c,d)}
+var p;function aa(a){this.id=a;this.version=0}aa.prototype.update=function(a,b){void 0!==a.name&&(this.name=a.name);this.version=Math.max(this.version,b)};function ba(a){this.a=a.desc;this.name=a.name;this.type=a.type;this.usage=a.usage;this.T=a.category}function ca(){this.ga={};this.u=[]}
+ca.prototype.update=function(a,b){this.ga=JSON.parse(a.emoji_use);a.highlight_words?this.u=(a.highlight_words||"").split(",").filter(function(a){return""!==a.trim()}):a.highlights&&(this.u=a.highlights);this.version=Math.max(this.version,b)};function da(){this.b=null;this.l={};this.m={};this.self=null;this.a={version:0,data:{}};this.i={version:0,data:{}};this.F={};this.A=0}
+function ea(a,b,c){var d=d||"";b.team&&(a.b||(a.b=new aa(b.team.id)),a.b.update(b.team,c));if(b.users)for(var e=0,g=b.users.length;e<g;e++){var f=a.m[d+b.users[e].id];f||(f=a.m[d+b.users[e].id]=new fa(b.users[e].id));f.update(b.users[e],c)}if(b.channels)for(e=0,g=b.channels.length;e<g;e++){f=a.l[d+b.channels[e].id];if(!f){var f=a.l,k=d+b.channels[e].id;var h=b.channels[e];h=h.pv?new q(h.id,a.m[h.user]):new r(h.id);f=f[k]=h}f.update(b.channels[e],a,c,d)}b.emojis&&(a.a.data=b.emojis,a.a.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}a.A=Math.max(a.A,c);b.self&&(a.self=a.m[d+b.self.id]||null,a.self?(a.self.N||(a.self.N=new ca),a.self.N.update(b.self.prefs,c)):a.A=0);if(void 0!==b.typing)for(e in a.F={},b.typing){a.F[e]={};for(var n in b.typing[e])a.F[e][n]=c}}"undefined"!==typeof module&&(module.I.Ra=da,module.I.Sa=aa,module.I.Ua=ba);function r(a){this.id=a;this.J=!1;this.w=this.B=0;this.m={};this.version=0}
+r.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.w=parseFloat(a.last_msg));void 0!==a.is_private&&(this.b=a.is_private);a.latest&&(this.w=parseFloat(a.latest.ts));void 0!==a.is_starred&&(this.J=a.is_starred);if(a.members&&(this.m={},a.members))for(var e=0,g=a.members.length;e<g;e++){var f=
+b.m[d+a.members[e]];this.m[f.id]=f;f.l[this.id]=this}this.version=Math.max(this.version,c)};function q(a,b){r.call(this,a);this.a=b;this.name=this.a.name;this.b=!0;b.Ja=this}q.prototype=Object.create(r.prototype);q.prototype.constructor=q;"undefined"!==typeof module&&(module.I.$a=r,module.I.Za=q);function x(a,b){this.H=a.user;this.username=a.username;this.id=a.id||a.ts;this.j=a.ts;this.text="";this.o=[];this.i=this.D=this.J=!1;this.C={};this.version=b;this.update(a,b)}function z(a,b){x.call(this,a,b)}function A(a,b){x.call(this,a,b)}
+x.prototype.update=function(a,b){if(a){if(this.text=a.text||"",a.attachments&&(this.o=a.attachments),this.J=!!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){this.id="string"===typeof a?a:a.id;this.a=[];this.i=b;c&&ga(this,c,d)}
 function ga(a,b,c){var d=0;b.forEach(function(a){d=Math.max(this.push(a,c),d)}.bind(a));ha(a)}B.prototype.b=function(a,b){return!0===a.isMeMessage?new z(a,b):!0===a.isNotice?new A(a,b):new x(a,b)};B.prototype.push=function(a,b){for(var c,d=!1,e,g=0,f=this.a.length;g<f;g++)if(c=this.a[g],c.id===a.id){e=c.update(a,b);d=!0;break}d||(c=this.b(a,b),this.a.push(c),e=c.j);for(;this.a.length>this.i;)this.a.shift();return e||0};function ia(a){return a.a[a.a.length-1]}
-function ja(a){for(var b=C.a[E.id],c=0,d=b.a.length;c<d&&a>=b.a[c].j;c++)if(b.a[c].j===a)return b.a[c];return null}function ha(a){a.a.sort(function(a,c){return a.j-c.j})}z.prototype=Object.create(x.prototype);z.prototype.constructor=z;A.prototype=Object.create(x.prototype);A.prototype.constructor=A;"undefined"!==typeof module&&(module.H={Wa:x,Va:z,Ya:A,ab:B});function fa(a){this.id=a;this.l={};this.Ja=this.M=null;this.version=0}fa.prototype.update=function(a,b){void 0!==a.name&&(this.name=a.name);void 0!==a.deleted&&(this.Ca=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.Na=a.isBot);this.version=Math.max(this.version,b)};"undefined"!==typeof module&&(module.H.Ta=fa);function ka(){this.a=[]}ka.prototype.push=function(a){this.a.push(a)};function la(a,b){for(var c=0,d=a.a.length;c<d;c++){var e=a.a[c],g;for(g in e.l)if(!0===b(e.l[g],g))return}}function ma(a){for(var b=C.context,c=0,d=b.a.length;c<d&&!0!==a(b.a[c]);c++);}function F(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 H(a){for(var b=C.context,c=0,d=b.a.length;c<d;c++){var e=b.a[c].l[a];if(e)return e}return null}
-function na(a){for(var b=C.context,c=[],d=0,e=b.a.length;d<e;d++){var g=b.a[d].l,f;for(f in g)a&&!a(g[f],b.a[d],f)||c.push(f)}return c}function I(a){for(var b=C.context,c=0,d=b.a.length;c<d;c++){var e=b.a[c].m[a];if(e)return e}return null}function oa(a){for(var b=C.context,c=0,d=b.a.length;c<d;c++)if(b.a[c].self.id===a)return!0;return!1}module.H.Xa=ka;var K={},L;function pa(){if(!c){for(var a=0,b=navigator.languages.length;a<b;a++)if(K.hasOwnProperty(navigator.languages[a])){var c=navigator.languages[a];break}c||(c="en")}L=K[c];console.log("Loading language pack: "+c);if(L.c)for(a in L.c)document.getElementById(a).textContent=L.c[a]};K.fr={Qa:"Utilisateur inconnu",Pa:"Channel inconnu",Fa:"Nouveau message",Ea:"Reseau",T:"(edit&eacute;)",Ga:"(visible seulement par vous)",I:"Favoris",l:"Discutions",Ia:"Discutions priv\u00e9es",ok:"Ok",Da:"Annuler",ga:function(a){"string"!==typeof a&&(a=parseFloat(a));var b=new Date,c=new Date;a=new Date(1E3*a);b.setHours(0);b.setMinutes(0);b.setSeconds(0);b.setMilliseconds(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()},c:{fileUploadCancel:"Annuler",neterror:"Impossible de se connecter au chat !"}};K.en={Qa:"Unknown member",Pa:"Unknown channel",Fa:"New message",Ea:"Network",T:"(edited)",Ga:"(only visible to you)",I:"Starred",l:"Channels",Ia:"Direct messages",ok:"Ok",Da:"Cancel",ga:function(a){"string"!==typeof a&&(a=parseFloat(a));var b=new Date,c=new Date;a=new Date(1E3*a);b.setHours(0);b.setMinutes(0);b.setSeconds(0);b.setMilliseconds(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()},c:{fileUploadCancel:"Cancel",neterror:"Cannot connect to chat !"}};var qa=function(){function a(a){this.text="";this.g=a}function b(b,c,d){this.P=c;this.f=null;this.h=[];this.a=d||"";this.aa="<"===this.a;this.la="*"===this.a;this.qa="_"===this.a;this.ba="~"===this.a||"-"===this.a;this.i=">"===this.a||"&gt;"===this.a;this.V=":"===this.a;this.ma="`"===this.a;this.Aa="```"===this.a;this.na="\n"===this.a;this.pa=void 0!==d&&-1!==n.u.indexOf(d);this.g=b;this.ca=null;this.b=this.na||this.pa?c+d.length-1:!1;this.pa&&(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 g(a){return a}function f(a){return{link:a,text:a,Oa:!1}}var l,h,n={u:[],U:g,$:g,Y:f};b.prototype.sa=function(){return this.la&&!!this.b||this.g instanceof b&&this.g.sa()};b.prototype.va=function(){return this.qa&&!!this.b||this.g instanceof b&&this.g.va()};b.prototype.wa=function(){return this.ba&&!!this.b||
-this.g instanceof b&&this.g.wa()};b.prototype.ja=function(){return this.V&&!!this.b||this.g instanceof b&&this.g.ja()};b.prototype.ua=function(){return this.pa&&!!this.b||this.g instanceof b&&this.g.ua()};b.prototype.ta=function(){return this.ma&&!!this.b||this.g instanceof b&&this.g.ta()};b.prototype.ia=function(){return this.Aa&&!!this.b||this.g instanceof b&&this.g.ia()};b.prototype.xa=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].xa()))return!0;
-return!1};b.prototype.ya=function(a){if("<"===this.a&&">"===l[a])return!0;var b=c(l[a-1]);if(!this.i&&l.substr(a,this.a.length)===this.a){if(!b&&(this.la||this.qa||this.ba))return!1;if(this.f&&this.xa())return this.f.Ba();if(this.Ka())return!0}return"\n"===l[a]&&this.i?!0:!1};b.prototype.Ka=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.ca}return!1};b.prototype.Ba=function(){var a=new b(this.g,this.P,this.a);a.ca=this;this.f&&
-this.f instanceof b&&(a.f=this.f.Ba(),a.h=[a.f]);return a};b.prototype.La=function(a){return this.V&&(" "===l[a]||"\t"===l[a])||(this.V||this.aa||this.la||this.qa||this.ba||this.ma)&&"\n"===l[a]?!1:!0};b.prototype.Ma=function(b){if(this.ma||this.V||this.Aa||this.aa)return null;if(!this.f||this.f.b||this.f instanceof a){var d=c(l[b+1]);if("```"===l.substr(b,3))return"```";var e=h.ka();if(void 0===e||e){if("&gt;"===l.substr(b,4))return"&gt;";if(">"===l[b])return l[b]}if(-1!==["`","\n"].indexOf(l[b])||
--1!==["*","~","-","_"].indexOf(l[b])&&(d||-1!=="*~-_<&".split("").indexOf(l[b+1]))||-1!==[":"].indexOf(l[b])&&d||-1!==["<"].indexOf(l[b]))return l[b];d=0;for(e=n.u.length;d<e;d++){var f=n.u[d];if(l.substr(b,f.length)===f)return f}}return null};a.prototype.ka=function(){if(""!==this.text.trim())return!1};b.prototype.ka=function(){for(var a=this.h.length-1;0<=a;a--){var b=this.h[a].ka();if(void 0!==b)return b}if(this.na||this.i)return!0};a.prototype.A=function(a){this.text+=l[a];return 1};b.prototype.A=
-function(c){var d=this.f&&!this.f.b&&this.f.ya?this.f.ya(c):null;if(d){var e=this.f.a.length;this.f.ra(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.La(c)){if(d=this.Ma(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.A(c)}d=this.f.P+1;h.ha(this.f.P);this.f=new a(this);this.f.A(d-1);this.h.pop();this.h.push(this.f);return d-c};b.prototype.ra=function(a){for(var b=
-this;b;)b.b=a,b=b.ca};b.prototype.ha=function(a){this.b&&this.b>=a&&(this.b=!1);this.h.forEach(function(c){c instanceof b&&c.ha(a)})};a.prototype.innerHTML=function(){var a;if(this.g.ja()){for(a=this.g;a&&!a.V;)a=a.g;if(a){var b=a.a+this.text+a.a;return(a=n.U(b))?a:b}return(a=n.U(this.text))?a:this.text}return this.g.ia()?this.text.replace(/\n/g,"<br/>"):n.$(this.text)};a.prototype.outerHTML=function(){var a="span",b=[],c="";if(this.g.ia()){b.push("codeblock");var d=this.innerHTML()}else this.g.ta()?
-(b.push("code"),d=this.innerHTML()):(this.g.aa&&(d=n.Y(this.text))?(a="a",c=' href="'+d.link+'"',d.bb&&(c+=' target="_blank"'),d=n.$(d.text)):d=this.innerHTML(),this.g.sa()&&b.push("bold"),this.g.va()&&b.push("italic"),this.g.wa()&&b.push("strike"),this.g.ja()&&b.push("emoji"),this.g.ua()&&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.na&&(a+="<br/>");this.h.forEach(function(b){a+=
-b.outerHTML()});this.i&&(a+="</span>");return a};b.prototype.za=function(a){this.i&&!this.b&&this.ra(a);this.h.forEach(function(c){c instanceof b&&c.za(a)})};return function(c,m){m||(m={});n.u=m.u||[];n.U=m.U||g;n.$=m.$||g;n.Y=m.Y||f;l=c;h=new b(this,0);m=0;c=l.length;do{for(;m<c;)m+=h.A(m);h.za(l.length);if(m=d()){e(m,!1);h.ha(m.P);var k=new a(m.g);k.A(m.P);m.g.h.push(k);m.g.f=k;m=m.P+1}else m=void 0}while(void 0!==m);return h.outerHTML()}}();
-window._formatText=function(a,b){return qa(a,{u:b?b.highlights:void 0})};"undefined"!==typeof module&&(module.H.s=qa);function ra(a,b){this.i=a;this.content=b;this.c=sa(this);this.b=ta(this);this.a=[];this.A=[]}
-function sa(a){var b=document.createElement("div"),c=document.createElement("header"),d=document.createElement("span"),e=document.createElement("span"),g=document.createElement("div"),f=document.createElement("footer");b.a=document.createElement("span");b.b=document.createElement("span");d.textContent=a.i;"string"==typeof a.content?g.innerHTML=a.content:g.appendChild(a.content);c.className=ua;d.className=va;e.className=wa;e.textContent="x";c.appendChild(d);c.appendChild(e);b.appendChild(c);g.className=
-xa;b.appendChild(g);b.b.className=ya;b.b.textContent=L.Da;b.b.addEventListener("click",function(){M(a,!1)});e.addEventListener("click",function(){M(a,!1)});b.a.addEventListener("click",function(){M(a,!0)});f.appendChild(b.b);b.a.className=ya;b.a.textContent=L.ok;f.appendChild(b.a);f.className=za+" "+Aa;b.appendChild(f);b.className=Ba;return b}function M(a,b){(b?a.a:a.A).forEach(function(a){a()});a.close()}
-function ta(a){var b=document.createElement("div");b.className=Ca;b.addEventListener("click",function(){M(this,!1)}.bind(a));return b}function Da(a,b,c){a.c.a.textContent=b;a.c.b.textContent=c;return a}ra.prototype.Z=function(a){a=a||document.body;a.appendChild(this.b);a.appendChild(this.c);return this};ra.prototype.close=function(){this.c.remove();this.b.remove();return this};function Ea(a,b){a.a.push(b);return a};var ya="button",za="button-container",Ba="dialog",Ca="dialog-overlay",ua="dialog-title",va="dialog-title-label",wa="dialog-title-close",xa="dialog-body",Aa="dialog-footer";var Fa=[],Ga=0;
-function Ha(){var a=document.createDocumentFragment(),b=na(function(a){return!a.X&&!1!==a.i}),c=[],d=[],e=[],g=[];b.sort(function(a,b){return a[0]!==b[0]?a[0]-b[0]:H(a).name.localeCompare(H(b).name)});b.forEach(function(a){a=H(a);if(a instanceof q){if(!a.a.Ca){var b=document.createElement("li");var f=document.createElement("a");b.id="room_"+a.id;f.href="#"+a.id;b.className="slack-context-room slack-ims";f.textContent=a.a.name;b.appendChild(Ia());b.appendChild(f);a.a.a||b.classList.add("away");E===
-a&&b.classList.add("selected");a.w>a.B&&(b.classList.add("unread"),0<=N.indexOf(a)&&b.classList.add("unreadHi"));b&&(a.I?c.push(b):g.push(b))}}else b=document.createElement("li"),f=document.createElement("a"),b.id="room_"+a.id,f.href="#"+a.id,a.b?(b.className="slack-context-room slack-group",b.dataset.count=Object.keys(a.m||{}).length):b.className="slack-context-room slack-channel",E===a&&b.classList.add("selected"),f.textContent=a.name,b.appendChild(Ia()),b.appendChild(f),a.w>a.B&&(b.classList.add("unread"),
-0<=N.indexOf(a)&&b.classList.add("unreadHi")),b&&(a.I?c.push(b):a.b?e.push(b):d.push(b))});c.length&&a.appendChild(Ja(L.I));c.forEach(function(b){a.appendChild(b)});d.length&&a.appendChild(Ja(L.l));d.forEach(function(b){a.appendChild(b)});e.forEach(function(b){a.appendChild(b)});g.length&&a.appendChild(Ja(L.Ia));g.forEach(function(b){a.appendChild(b)});document.getElementById("chanList").textContent="";document.getElementById("chanList").appendChild(a);Ka();O();P&&La(P.b.id,P.m,function(a){document.getElementById("slackCtx").style.backgroundImage=
-"url("+a+")"})}function Ma(){ma(function(a){var b=a.D,c;for(c in a.self.l)if(!a.self.l[c].X){var d=document.getElementById("room_"+c);b[c]?d.classList.add("slack-context-typing"):d.classList.remove("slack-context-typing")}for(var e in a.m)(c=a.m[e].Ja)&&!c.X&&(d=document.getElementById("room_"+c.id))&&(b[c.id]?d.classList.add("slack-context-typing"):d.classList.remove("slack-context-typing"))});Na()}
-function Na(){var a;document.getElementById("whoistyping").textContent="";if(P&&E&&(a=P.D[E.id])){var b=document.createDocumentFragment(),c=!1,d;for(d in a[E.id])(a=I(d))?b.appendChild(Oa(a)):c=!0;c&&(C.b=0);document.getElementById("whoistyping").appendChild(b)}}function Pa(a){a?document.body.classList.remove("no-network"):document.body.classList.add("no-network");O()}
-function Qa(){var a=E.name||(E.a?E.a.name:void 0);if(!a){var b=[];E.m.forEach(function(a){b.push(a.name)});a=b.join(", ")}document.getElementById("currentRoomTitle").textContent=a;Ra();R();document.getElementById("fileUploadContainer").classList.add("hidden");Sa();S&&(S=null,T());U&&(U=null,T());Na()}
-function T(){if(S){document.body.classList.add("replyingTo");var a=document.getElementById("replyToContainer"),b=document.createElement("a");b.addEventListener("click",function(){S=null;T()});b.className="replyto-close";b.textContent="x";a.textContent="";a.appendChild(b);a.appendChild(S.K())}else document.body.classList.remove("replyingTo"),document.getElementById("replyToContainer").textContent="";R()}
-function V(){if(U){document.body.classList.add("replyingTo");var a=document.getElementById("replyToContainer"),b=document.createElement("a");b.addEventListener("click",function(){U=null;V()});b.className="replyto-close";b.textContent="x";a.textContent="";a.appendChild(b);a.appendChild(U.K());document.getElementById("msgInput").value=U.text}else document.body.classList.remove("replyingTo"),document.getElementById("replyToContainer").textContent="";R()}
-window.toggleReaction=function(a,b,c){var d,e,g;if(g=d=C.a[a]){a:{var f=0;for(g=d.a.length;f<g;f++)if(d.a[f].id==b){d=d.a[f];break a}d=null}g=f=d}g&&(e=F(C.context,a))&&(f.C[c]&&-1!==f.C[c].indexOf(e.self.id)?(e=new XMLHttpRequest,e.open("DELETE","api/reaction?room="+a+"&msg="+b+"&reaction="+encodeURIComponent(c),!0),e.send(null)):Ta(a,b,c))};
-function Ua(a){a:{var b={};if(P){var c;for(c=P;!b[a];){if(c=c.a.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 Va(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(W)b="!"+L.Ea+" - ",document.getElementById("linkFavicon").href="favicon_err.png";else if(a)b="(!"+a+") - ",Va(a,a);else{var c=0;la(C.context,function(a){a.w>a.B&&c++});c&&(b="("+c+") - ");Va(0,c)}C.context.b&&(b+=C.context.b.name);document.title=b}
-function Wa(){if("Notification"in window)if("granted"===Notification.permission){var a=Date.now();if(Ga+3E4<a){var b=new Notification(L.Fa);Ga=a;setTimeout(function(){b.close()},5E3)}}else"denied"!==Notification.permission&&Notification.requestPermission()}
-function Ra(){var a=document.createDocumentFragment(),b=E.id,c=null,d=0,e=null,g;Fa=[];C.a[b]&&C.a[b].a.forEach(function(b){if(b.i)b.O();else{var f=b.L(),h=!1;c&&c.G===b.G&&b.G?30>Math.abs(d-b.j)&&!(b instanceof z)?e.classList.add("slackmsg-same-ts"):d=b.j:(d=b.j,h=!0);(!c||c.j<=E.B)&&b.j>E.B?f.classList.add("slackmsg-first-unread"):f.classList.remove("slackmsg-first-unread");if(b instanceof z)e=c=null,d=0,a.appendChild(f),g=null;else{if(h||!g){var h=I(b.G),n=b.username,k=document.createElement("div"),
-m=document.createElement("div"),t=document.createElement("span");k.R=document.createElement("img");k.R.className="slackmsg-author-img";t.className="slackmsg-author-name";h?(t.textContent=h.name,k.R.src="api/avatar?user="+h.id):(t.textContent=n||"?",k.R.src="");m.appendChild(k.R);m.appendChild(t);m.className="slackmsg-author";k.className="slackmsg-authorGroup";k.appendChild(m);k.content=document.createElement("div");k.content.className="slackmsg-author-messages";k.appendChild(k.content);g=k;Fa.push(g);
-a.appendChild(g)}c=b;e=f;g.content.appendChild(f)}}});b=document.getElementById("chatWindow");b.textContent="";b.appendChild(a);b.scrollTop=b.scrollHeight-b.clientHeight;window.hasFocus&&Sa()}
-function Xa(a){function b(a,b){for(b=b||a.target;b!==a.currentTarget&&b;){if(b.classList.contains("slackmsg-item"))return b.id;b=b.parentElement}}for(var c,d,e=a.target;e!==a.currentTarget&&e&&!e.classList.contains("slackmsg-hover");){if(e.parentElement&&e.classList.contains("slackmsg-attachment-actions-item")){d=b(a,e);var g=e.dataset.attachmentIndex,f=e.dataset.actionIndex;if(d&&void 0!==g&&void 0!==f){d=parseFloat(d.split("_")[1]);(c=ja(d))&&c.o[g]&&c.o[g].actions&&c.o[g].actions[f]&&Ya(c,c.o[g],
-c.o[g].actions[f]);break}}if(e.parentElement&&e.parentElement.classList.contains("slackmsg-hover")){if(d=b(a,e))d=parseFloat(d.split("_")[1]),(c=ja(d))&&e.classList.contains("slackmsg-hover-reply")?(U&&(U=null,V()),S!==c&&(S=c,T())):c&&e.classList.contains("slackmsg-hover-reaction")?Za.Z(document.body,function(a){a&&Ta(E.id,c.id,a)}):c&&e.classList.contains("slackmsg-hover-edit")?(S&&(S=null,T()),U!==c&&(U=c,V())):c&&e.classList.contains("slackmsg-hover-remove")&&(S&&(S=null,T()),U&&(U=null,V()),
-$a(c));break}e=e.parentElement}}function Ya(a,b,c){function d(){var d=JSON.stringify({actions:[c],attachment_id:b.id,callback_id:b.callback_id,channel_id:e,is_ephemeral:a instanceof A,message_ts:a.id}),f=a.G,l=new FormData,h=new XMLHttpRequest;l.append("payload",d);l.append("service_id",f);h.open("POST","api/attachmentAction");h.send(l)}var e=E.id;c.confirm?Ea(Da(new ra(c.confirm.title,c.confirm.text),c.confirm.ok_text,c.confirm.dismiss_text),d).Z():d()}
-function R(){document.getElementById("msgInput").focus()}function Ka(){var a=document.location.hash.substr(1),b=H(a);b&&b!==E?ab(b):(a=I(a))&&a.b&&ab(a.b)}function bb(){var a=document.getElementById("chatWindow").getBoundingClientRect().top;Fa.forEach(function(b){var c=b.R,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(){pa();document.getElementById("chatWindow").addEventListener("click",Xa);window.addEventListener("hashchange",function(){document.location.hash&&"#"===document.location.hash[0]&&Ka()});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("fileUploadForm").addEventListener("submit",function(a){a.preventDefault();a=document.getElementById("fileUploadInput");var b=a.value;b&&(b=b.substr(b.lastIndexOf("\\")+1),cb(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();E&&document.getElementById("fileUploadContainer").classList.remove("hidden");return!1});document.getElementById("msgForm").addEventListener("submit",function(a){a.preventDefault();a=document.getElementById("msgInput");E&&a.value&&db(a.value)&&(a.value="",S&&(S=null,T()),U&&(U=null,T()),document.getElementById("slashList").textContent="");R();return!1});window.addEventListener("blur",function(){window.hasFocus=
-!1});window.addEventListener("focus",function(){window.hasFocus=!0;Ga=0;E&&Sa();R()});document.getElementById("chatWindow").addEventListener("scroll",bb);var a=0;document.getElementById("msgInput").addEventListener("input",function(){if(E){var b=Date.now();a+3E3<b&&(P.self.a||E instanceof q)&&(eb(),a=b);var c=[],b=this.value;if("/"===this.value[0]){var d=b.indexOf(" "),e=-1!==d,d=-1===d?b.length:d,g=b.substr(0,d);(P?P.i.data:[]).forEach(function(a){(!e&&a.name.substr(0,d)===g||e&&a.name===g)&&c.push(a)})}c.sort(function(a,
-b){return a.S.localeCompare(b.S)||a.name.localeCompare(b.name)});var b=document.getElementById("slashList"),f=document.createDocumentFragment();b.textContent="";for(var l=0,h=c.length;l<h;l++){var n=c[l];if(k!==n.S){var k=n.S;f.appendChild(fb(n.S))}f.appendChild(gb(n))}b.appendChild(f)}});window.hasFocus=!0;(function(){var a=document.getElementById("emojiButton");if("makeEmoji"in window){var c=window.makeEmoji("smile");c?a.innerHTML="<span class='emoji-small'>"+c.outerHTML+"</span>":a.style.backgroundImage=
-'url("smile.svg")';(c=window.makeEmoji("paperclip"))?document.getElementById("attachFile").innerHTML="<span class='emoji-small'>"+c.outerHTML+"</span>":document.getElementById("attachFile").style.backgroundImage='url("public/paperclip.svg")';a.addEventListener("click",function(){Za.Z(document.body,function(a){a&&(document.getElementById("msgInput").value+=":"+a+":");R()})})}else a.classList.add("hidden")})();hb()});function Ia(){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 Ja=function(){var a={};return function(b){var c=a[b];c||(c=a[b]=document.createElement("header"),c.textContent=b);return c}}();
-function ib(a){var b=a.b,c=document.createElement("div"),d=document.createElement("div"),e=document.createElement("ul"),g=document.createElement("li");c.o=document.createElement("ul");c.C=document.createElement("ul");c.j=document.createElement("div");c.oa=document.createElement("div");c.ea=document.createElement("span");c.id=b+"_"+a.id;c.className="slackmsg-item";c.j.className="slackmsg-ts";c.oa.className="slackmsg-msg";c.ea.className="slackmsg-author-name";e.className="slackmsg-hover";g.className=
-"slackmsg-hover-reply";e.appendChild(g);if("makeEmoji"in window){var f=document.createElement("li"),l=window.makeEmoji("arrow_heading_down"),h=window.makeEmoji("smile"),n=window.makeEmoji("pencil2"),b=window.makeEmoji("x");f.className="slackmsg-hover-reaction";h?(f.classList.add("emoji-small"),f.appendChild(h)):f.style.backgroundImage='url("smile.svg")';l?(g.classList.add("emoji-small"),g.appendChild(l)):g.style.backgroundImage='url("repl.svg")';e.appendChild(f);oa(a.G)&&(a=document.createElement("li"),
-a.className="slackmsg-hover-edit",n?a.classList.add("emoji-small"):a.style.backgroundImage='url("edit.svg")',a.appendChild(n),e.appendChild(a),a=document.createElement("li"),a.className="slackmsg-hover-remove",b?a.classList.add("emoji-small"):a.style.backgroundImage='url("remove.svg")',a.appendChild(b),e.appendChild(a))}else g.style.backgroundImage='url("repl.svg")',oa(a.G)&&(a=document.createElement("li"),a.className="slackmsg-hover-edit",a.style.backgroundImage='url("edit.svg")',e.appendChild(a),
-a=document.createElement("li"),a.className="slackmsg-hover-remove",a.style.backgroundImage='url("remove.svg")',e.appendChild(a));d.appendChild(c.ea);d.appendChild(c.oa);d.appendChild(c.j);d.appendChild(c.o);b=document.createElement("div");b.innerHTML=L.T;b.className="slackmsg-edited";d.appendChild(b);d.appendChild(c.C);d.className="slackmsg-content";c.o.className="slackmsg-attachments";c.C.className="slackmsg-reactions";c.appendChild(d);c.appendChild(e);return c}
-function jb(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 kb(a,b,c){var d=document.createElement("li"),e=document.createElement("div"),g=document.createElement("div"),f=document.createElement("a"),l=document.createElement("div"),h=document.createElement("img"),n=document.createElement("a"),k=document.createElement("div"),m=document.createElement("div"),t=document.createElement("div"),w=document.createElement("img"),v=document.createElement("div");d.className="slackmsg-attachment";e.style.borderColor=jb(b.color||"");e.className="slackmsg-attachment-block";
-g.className="slackmsg-attachment-pretext";b.pretext?g.innerHTML=a.s(b.pretext):g.classList.add("hidden");f.target="_blank";b.title?(f.innerHTML=a.s(b.title),b.title_link&&(f.href=b.title_link),f.className="slackmsg-attachment-title"):f.className="hidden slackmsg-attachment-title";n.target="_blank";l.className="slackmsg-author";b.author_name&&(n.innerHTML=a.s(b.author_name),n.href=b.author_link||"",n.className="slackmsg-author-name",h.className="slackmsg-author-img",b.author_icon&&(h.src=b.author_icon,
-l.appendChild(h)),l.appendChild(n));t.className="slackmsg-attachment-thumb";b.thumb_url?(h=document.createElement("img"),h.src=b.thumb_url,t.appendChild(h),e.classList.add("has-thumb"),b.video_html&&(t.dataset.video=b.video_html)):t.classList.add("hidden");k.className="slackmsg-attachment-content";h=a.s(b.text||"");m.className="slackmsg-attachment-text";h&&""!=h?m.innerHTML=h:m.classList.add("hidden");w.className="slackmsg-attachment-img";b.image_url?w.src=b.image_url:w.classList.add("hidden");v.className=
-"slackmsg-attachment-footer";b.footer&&(h=document.createElement("span"),h.className="slackmsg-attachment-footer-text",h.innerHTML=a.s(b.footer),b.footer_icon&&(n=document.createElement("img"),n.src=b.footer_icon,n.className="slackmsg-attachment-footer-icon",v.appendChild(n)),v.appendChild(h));b.ts&&(h=document.createElement("span"),h.className="slackmsg-ts",h.innerHTML=L.ga(b.ts),v.appendChild(h));k.appendChild(t);k.appendChild(m);e.appendChild(f);e.appendChild(l);e.appendChild(k);e.appendChild(w);
+function ja(a){for(var b=C.a[E.id],c=0,d=b.a.length;c<d&&a>=b.a[c].j;c++)if(b.a[c].j===a)return b.a[c];return null}function ha(a){a.a.sort(function(a,c){return a.j-c.j})}z.prototype=Object.create(x.prototype);z.prototype.constructor=z;A.prototype=Object.create(x.prototype);A.prototype.constructor=A;"undefined"!==typeof module&&(module.I={Wa:x,Va:z,Ya:A,ab:B});function fa(a){this.id=a;this.l={};this.Ja=this.N=null;this.version=0}fa.prototype.update=function(a,b){void 0!==a.name&&(this.name=a.name);void 0!==a.deleted&&(this.Ca=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.Na=a.isBot);this.version=Math.max(this.version,b)};"undefined"!==typeof module&&(module.I.Ta=fa);function ka(){this.a=[]}ka.prototype.push=function(a){this.a.push(a)};function la(a,b){for(var c=0,d=a.a.length;c<d;c++)if(b===ma(a.a[c]))return a.a[c];return null}function na(a,b){for(var c=0,d=a.a.length;c<d;c++){var e=a.a[c],g;for(g in e.l)if(!0===b(e.l[g],g))return}}function oa(a){for(var b=C.context,c=0,d=b.a.length;c<d&&!0!==a(b.a[c]);c++);}function F(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 H(a){for(var b=C.context,c=0,d=b.a.length;c<d;c++){var e=b.a[c].l[a];if(e)return e}return null}function pa(a){for(var b=C.context,c=[],d=0,e=b.a.length;d<e;d++){var g=b.a[d].l,f;for(f in g)a&&!a(g[f],b.a[d],f)||c.push(f)}return c}function I(a){for(var b=C.context,c=0,d=b.a.length;c<d;c++){var e=b.a[c].m[a];if(e)return e}return null}function qa(a){for(var b=C.context,c=0,d=b.a.length;c<d;c++)if(b.a[c].self.id===a)return!0;return!1}"undefined"!==typeof module&&(module.I.Xa=ka);var K={},L;function ra(){if(!c){for(var a=0,b=navigator.languages.length;a<b;a++)if(K.hasOwnProperty(navigator.languages[a])){var c=navigator.languages[a];break}c||(c="en")}L=K[c];console.log("Loading language pack: "+c);if(L.c)for(a in L.c)document.getElementById(a).textContent=L.c[a]};K.fr={Qa:"Utilisateur inconnu",Pa:"Channel inconnu",Fa:"Nouveau message",Ea:"Reseau",Ga:"(visible seulement par vous)",J:"Favoris",l:"Discutions",Ia:"Discutions priv\u00e9es",ok:"Ok",Da:"Annuler",V:function(a){"string"!==typeof a&&(a=parseFloat(a));var b=new Date,c=new Date;a=new Date(1E3*a);b.setHours(0);b.setMinutes(0);b.setSeconds(0);b.setMilliseconds(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()},c:{fileUploadCancel:"Annuler",neterror:"Impossible de se connecter au chat !"}};K.fr.D=function(a){return"(edit&eacute; "+K.fr.V(a)+")"};K.en={Qa:"Unknown member",Pa:"Unknown channel",Fa:"New message",Ea:"Network",Ga:"(only visible to you)",J:"Starred",l:"Channels",Ia:"Direct messages",ok:"Ok",Da:"Cancel",V:function(a){"string"!==typeof a&&(a=parseFloat(a));var b=new Date,c=new Date;a=new Date(a);b.setHours(12,0,0,0);b.setTime(b.getTime()-432E5);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()},c:{fileUploadCancel:"Cancel",
+neterror:"Cannot connect to chat !"}};K.en.D=function(a){return"(edited "+K.en.V(a)+")"};var sa=function(){function a(a){this.text="";this.g=a}function b(b,c,d){this.R=c;this.f=null;this.h=[];this.a=d||"";this.ba="<"===this.a;this.la="*"===this.a;this.qa="_"===this.a;this.ca="~"===this.a||"-"===this.a;this.i=">"===this.a||"&gt;"===this.a;this.W=":"===this.a;this.ma="`"===this.a;this.Aa="```"===this.a;this.na="\n"===this.a;this.pa=void 0!==d&&-1!==n.u.indexOf(d);this.g=b;this.da=null;this.b=this.na||this.pa?c+d.length-1:!1;this.pa&&(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 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 g(a){return a}function f(a){return{link:a,text:a,Oa:!1}}var k,h,n={u:[],U:g,aa:g,Z:f};b.prototype.sa=function(){return this.la&&!!this.b||this.g instanceof b&&this.g.sa()};b.prototype.va=function(){return this.qa&&!!this.b||this.g instanceof b&&this.g.va()};b.prototype.wa=function(){return this.ca&&!!this.b||
+this.g instanceof b&&this.g.wa()};b.prototype.ja=function(){return this.W&&!!this.b||this.g instanceof b&&this.g.ja()};b.prototype.ua=function(){return this.pa&&!!this.b||this.g instanceof b&&this.g.ua()};b.prototype.ta=function(){return this.ma&&!!this.b||this.g instanceof b&&this.g.ta()};b.prototype.ia=function(){return this.Aa&&!!this.b||this.g instanceof b&&this.g.ia()};b.prototype.xa=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].xa()))return!0;
+return!1};b.prototype.ya=function(a){if("<"===this.a&&">"===k[a])return!0;var b=c(k[a-1]);if(!this.i&&k.substr(a,this.a.length)===this.a){if(!b&&(this.la||this.qa||this.ca))return!1;if(this.f&&this.xa())return this.f.Ba();if(this.Ka())return!0}return"\n"===k[a]&&this.i?!0:!1};b.prototype.Ka=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.da}return!1};b.prototype.Ba=function(){var a=new b(this.g,this.R,this.a);a.da=this;this.f&&
+this.f instanceof b&&(a.f=this.f.Ba(),a.h=[a.f]);return a};b.prototype.La=function(a){return this.W&&(" "===k[a]||"\t"===k[a])||(this.W||this.ba||this.la||this.qa||this.ca||this.ma)&&"\n"===k[a]?!1:!0};b.prototype.Ma=function(b){if(this.ma||this.W||this.Aa||this.ba)return null;if(!this.f||this.f.b||this.f instanceof a){var d=c(k[b+1]);if("```"===k.substr(b,3))return"```";var e=h.ka();if(void 0===e||e){if("&gt;"===k.substr(b,4))return"&gt;";if(">"===k[b])return k[b]}if(-1!==["`","\n"].indexOf(k[b])||
+-1!==["*","~","-","_"].indexOf(k[b])&&(d||-1!=="*~-_<&".split("").indexOf(k[b+1]))||-1!==[":"].indexOf(k[b])&&d||-1!==["<"].indexOf(k[b]))return k[b];d=0;for(e=n.u.length;d<e;d++){var f=n.u[d];if(k.substr(b,f.length)===f)return f}}return null};a.prototype.ka=function(){if(""!==this.text.trim())return!1};b.prototype.ka=function(){for(var a=this.h.length-1;0<=a;a--){var b=this.h[a].ka();if(void 0!==b)return b}if(this.na||this.i)return!0};a.prototype.A=function(a){this.text+=k[a];return 1};b.prototype.A=
+function(c){var d=this.f&&!this.f.b&&this.f.ya?this.f.ya(c):null;if(d){var e=this.f.a.length;this.f.ra(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.La(c)){if(d=this.Ma(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.A(c)}d=this.f.R+1;h.ha(this.f.R);this.f=new a(this);this.f.A(d-1);this.h.pop();this.h.push(this.f);return d-c};b.prototype.ra=function(a){for(var b=
+this;b;)b.b=a,b=b.da};b.prototype.ha=function(a){this.b&&this.b>=a&&(this.b=!1);this.h.forEach(function(c){c instanceof b&&c.ha(a)})};a.prototype.innerHTML=function(){var a;if(this.g.ja()){for(a=this.g;a&&!a.W;)a=a.g;if(a){var b=a.a+this.text+a.a;return(a=n.U(b))?a:b}return(a=n.U(this.text))?a:this.text}return this.g.ia()?this.text.replace(/\n/g,"<br/>"):n.aa(this.text)};a.prototype.outerHTML=function(){var a="span",b=[],c="";if(this.g.ia()){b.push("codeblock");var d=this.innerHTML()}else this.g.ta()?
+(b.push("code"),d=this.innerHTML()):(this.g.ba&&(d=n.Z(this.text))?(a="a",c=' href="'+d.link+'"',d.bb&&(c+=' target="_blank"'),d=n.aa(d.text)):d=this.innerHTML(),this.g.sa()&&b.push("bold"),this.g.va()&&b.push("italic"),this.g.wa()&&b.push("strike"),this.g.ja()&&b.push("emoji"),this.g.ua()&&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.na&&(a+="<br/>");this.h.forEach(function(b){a+=
+b.outerHTML()});this.i&&(a+="</span>");return a};b.prototype.za=function(a){this.i&&!this.b&&this.ra(a);this.h.forEach(function(c){c instanceof b&&c.za(a)})};return function(c,m){m||(m={});n.u=m.u||[];n.U=m.U||g;n.aa=m.aa||g;n.Z=m.Z||f;k=c;h=new b(this,0);m=0;c=k.length;do{for(;m<c;)m+=h.A(m);h.za(k.length);if(m=d()){e(m,!1);h.ha(m.R);var l=new a(m.g);l.A(m.R);m.g.h.push(l);m.g.f=l;m=m.R+1}else m=void 0}while(void 0!==m);return h.outerHTML()}}();
+window._formatText=function(a,b){return sa(a,{u:b?b.highlights:void 0})};"undefined"!==typeof module&&(module.I.s=sa);function ta(a,b){this.i=a;this.content=b;this.c=ua(this);this.b=va(this);this.a=[];this.A=[]}
+function ua(a){var b=document.createElement("div"),c=document.createElement("header"),d=document.createElement("span"),e=document.createElement("span"),g=document.createElement("div"),f=document.createElement("footer");b.a=document.createElement("span");b.b=document.createElement("span");d.textContent=a.i;"string"==typeof a.content?g.innerHTML=a.content:g.appendChild(a.content);c.className=wa;d.className=xa;e.className=ya;e.textContent="x";c.appendChild(d);c.appendChild(e);b.appendChild(c);g.className=
+za;b.appendChild(g);b.b.className=Aa;b.b.textContent=L.Da;b.b.addEventListener("click",function(){M(a,!1)});e.addEventListener("click",function(){M(a,!1)});b.a.addEventListener("click",function(){M(a,!0)});f.appendChild(b.b);b.a.className=Aa;b.a.textContent=L.ok;f.appendChild(b.a);f.className=Ba+" "+Ca;b.appendChild(f);b.className=Da;return b}function M(a,b){(b?a.a:a.A).forEach(function(a){a()});a.close()}
+function va(a){var b=document.createElement("div");b.className=Ea;b.addEventListener("click",function(){M(this,!1)}.bind(a));return b}function Fa(a,b,c){a.c.a.textContent=b;a.c.b.textContent=c;return a}ta.prototype.$=function(a){a=a||document.body;a.appendChild(this.b);a.appendChild(this.c);return this};ta.prototype.close=function(){this.c.remove();this.b.remove();return this};function Ga(a,b){a.a.push(b);return a};var Aa="button",Ba="button-container",Da="dialog",Ea="dialog-overlay",wa="dialog-title",xa="dialog-title-label",ya="dialog-title-close",za="dialog-body",Ca="dialog-footer";var Ha=[],Ia=0;
+function Ja(){var a=document.createDocumentFragment(),b=pa(function(a){return!a.Y&&!1!==a.i}),c=[],d=[],e=[],g=[];b.sort(function(a,b){return a[0]!==b[0]?a[0]-b[0]:H(a).name.localeCompare(H(b).name)});b.forEach(function(a){a=H(a);if(a instanceof q){if(!a.a.Ca){var b=document.createElement("li");var f=document.createElement("a");b.id="room_"+a.id;f.href="#"+a.id;b.className="slack-context-room slack-ims";f.textContent=a.a.name;b.appendChild(Ka());b.appendChild(f);a.a.a||b.classList.add("away");E===
+a&&b.classList.add("selected");a.w>a.B&&(b.classList.add("unread"),0<=N.indexOf(a)&&b.classList.add("unreadHi"));b&&(a.J?c.push(b):g.push(b))}}else b=document.createElement("li"),f=document.createElement("a"),b.id="room_"+a.id,f.href="#"+a.id,a.b?(b.className="slack-context-room slack-group",b.dataset.count=Object.keys(a.m||{}).length):b.className="slack-context-room slack-channel",E===a&&b.classList.add("selected"),f.textContent=a.name,b.appendChild(Ka()),b.appendChild(f),a.w>a.B&&(b.classList.add("unread"),
+0<=N.indexOf(a)&&b.classList.add("unreadHi")),b&&(a.J?c.push(b):a.b?e.push(b):d.push(b))});c.length&&a.appendChild(La(L.J));c.forEach(function(b){a.appendChild(b)});d.length&&a.appendChild(La(L.l));d.forEach(function(b){a.appendChild(b)});e.forEach(function(b){a.appendChild(b)});g.length&&a.appendChild(La(L.Ia));g.forEach(function(b){a.appendChild(b)});document.getElementById("chanList").textContent="";document.getElementById("chanList").appendChild(a);Ma();O();P&&Na(P.b.id,P.m,function(a){document.getElementById("slackCtx").style.backgroundImage=
+"url("+a+")"})}function Oa(){oa(function(a){var b=a.F,c;for(c in a.self.l)if(!a.self.l[c].Y){var d=document.getElementById("room_"+c);b[c]?d.classList.add("slack-context-typing"):d.classList.remove("slack-context-typing")}for(var e in a.m)(c=a.m[e].Ja)&&!c.Y&&(d=document.getElementById("room_"+c.id))&&(b[c.id]?d.classList.add("slack-context-typing"):d.classList.remove("slack-context-typing"))});Pa()}
+function Pa(){var a;document.getElementById("whoistyping").textContent="";if(P&&E&&(a=P.F[E.id])){var b=document.createDocumentFragment(),c=!1,d;for(d in a[E.id])(a=I(d))?b.appendChild(Qa(a)):c=!0;c&&(C.b=0);document.getElementById("whoistyping").appendChild(b)}}function Ra(a){a?document.body.classList.remove("no-network"):document.body.classList.add("no-network");O()}
+function Sa(){var a=E.name||(E.a?E.a.name:void 0);if(!a){var b=[];E.m.forEach(function(a){b.push(a.name)});a=b.join(", ")}document.getElementById("currentRoomTitle").textContent=a;Ta();Q();document.getElementById("fileUploadContainer").classList.add("hidden");Ua();S&&(S=null,T());U&&(U=null,T());Pa()}
+function T(){if(S){document.body.classList.add("replyingTo");var a=document.getElementById("replyToContainer"),b=document.createElement("a");b.addEventListener("click",function(){S=null;T()});b.className="replyto-close";b.textContent="x";a.textContent="";a.appendChild(b);a.appendChild(S.L())}else document.body.classList.remove("replyingTo"),document.getElementById("replyToContainer").textContent="";Q()}
+function V(){if(U){document.body.classList.add("replyingTo");var a=document.getElementById("replyToContainer"),b=document.createElement("a");b.addEventListener("click",function(){U=null;V()});b.className="replyto-close";b.textContent="x";a.textContent="";a.appendChild(b);a.appendChild(U.L());document.getElementById("msgInput").value=U.text}else document.body.classList.remove("replyingTo"),document.getElementById("replyToContainer").textContent="";Q()}
+window.toggleReaction=function(a,b,c){var d,e,g;if(g=d=C.a[a]){a:{var f=0;for(g=d.a.length;f<g;f++)if(d.a[f].id==b){d=d.a[f];break a}d=null}g=f=d}g&&(e=F(C.context,a))&&(f.C[c]&&-1!==f.C[c].indexOf(e.self.id)?(e=new XMLHttpRequest,e.open("DELETE","api/reaction?room="+a+"&msg="+b+"&reaction="+encodeURIComponent(c),!0),e.send(null)):Va(a,b,c))};
+function Wa(a){a:{var b={};if(P){var c;for(c=P;!b[a];){if(c=c.a.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 Xa(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(W)b="!"+L.Ea+" - ",document.getElementById("linkFavicon").href="favicon_err.png";else if(a)b="(!"+a+") - ",Xa(a,a);else{var c=0;na(C.context,function(a){a.w>a.B&&c++});c&&(b="("+c+") - ");Xa(0,c)}C.context.b&&(b+=C.context.b.name);document.title=b}
+function Ya(){if("Notification"in window)if("granted"===Notification.permission){var a=Date.now();if(Ia+3E4<a){var b=new Notification(L.Fa);Ia=a;setTimeout(function(){b.close()},5E3)}}else"denied"!==Notification.permission&&Notification.requestPermission()}
+function Ta(){var a=document.createDocumentFragment(),b=E.id,c=null,d=0,e=null,g;Ha=[];C.a[b]&&C.a[b].a.forEach(function(b){if(b.i)b.P();else{var f=b.M(),h=!1;c&&c.H===b.H&&b.H?30>Math.abs(d-b.j)&&!(b instanceof z)?e.classList.add("slackmsg-same-ts"):d=b.j:(d=b.j,h=!0);(!c||c.j<=E.B)&&b.j>E.B?f.classList.add("slackmsg-first-unread"):f.classList.remove("slackmsg-first-unread");if(b instanceof z)e=c=null,d=0,a.appendChild(f),g=null;else{if(h||!g){var h=I(b.H),n=b.username,l=document.createElement("div"),
+m=document.createElement("div"),t=document.createElement("span");l.S=document.createElement("img");l.S.className="slackmsg-author-img";t.className="slackmsg-author-name";h?(t.textContent=h.name,l.S.src="api/avatar?user="+h.id):(t.textContent=n||"?",l.S.src="");m.appendChild(l.S);m.appendChild(t);m.className="slackmsg-author";l.className="slackmsg-authorGroup";l.appendChild(m);l.content=document.createElement("div");l.content.className="slackmsg-author-messages";l.appendChild(l.content);g=l;Ha.push(g);
+a.appendChild(g)}c=b;e=f;g.content.appendChild(f)}}});b=document.getElementById("chatWindow");b.textContent="";b.appendChild(a);b.scrollTop=b.scrollHeight-b.clientHeight;window.hasFocus&&Ua()}
+function Za(a){function b(a,b){for(b=b||a.target;b!==a.currentTarget&&b;){if(b.classList.contains("slackmsg-item"))return b.id;b=b.parentElement}}for(var c,d,e=a.target;e!==a.currentTarget&&e&&!e.classList.contains("slackmsg-hover");){if(e.parentElement&&e.classList.contains("slackmsg-attachment-actions-item")){d=b(a,e);var g=e.dataset.attachmentIndex,f=e.dataset.actionIndex;if(d&&void 0!==g&&void 0!==f){d=parseFloat(d.split("_")[1]);(c=ja(d))&&c.o[g]&&c.o[g].actions&&c.o[g].actions[f]&&$a(c,c.o[g],
+c.o[g].actions[f]);break}}if(e.parentElement&&e.parentElement.classList.contains("slackmsg-hover")){if(d=b(a,e))d=parseFloat(d.split("_")[1]),(c=ja(d))&&e.classList.contains("slackmsg-hover-reply")?(U&&(U=null,V()),S!==c&&(S=c,T())):c&&e.classList.contains("slackmsg-hover-reaction")?ab.$(document.body,P,function(a){a&&Va(E.id,c.id,a)}):c&&e.classList.contains("slackmsg-hover-edit")?(S&&(S=null,T()),U!==c&&(U=c,V())):c&&e.classList.contains("slackmsg-hover-remove")&&(S&&(S=null,T()),U&&(U=null,V()),
+bb(c));break}e=e.parentElement}}function $a(a,b,c){function d(){var d=JSON.stringify({actions:[c],attachment_id:b.id,callback_id:b.callback_id,channel_id:e,is_ephemeral:a instanceof A,message_ts:a.id}),f=a.H,k=new FormData,h=new XMLHttpRequest;k.append("payload",d);k.append("service_id",f);h.open("POST","api/attachmentAction");h.send(k)}var e=E.id;c.confirm?Ga(Fa(new ta(c.confirm.title,c.confirm.text),c.confirm.ok_text,c.confirm.dismiss_text),d).$():d()}
+function Q(){document.getElementById("msgInput").focus()}function Ma(){var a=document.location.hash.substr(1),b=H(a);b&&b!==E?cb(b):(a=I(a))&&a.b&&cb(a.b)}function db(){var a=document.getElementById("chatWindow").getBoundingClientRect().top;Ha.forEach(function(b){var c=b.S,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(){ra();document.getElementById("chatWindow").addEventListener("click",Za);window.addEventListener("hashchange",function(){document.location.hash&&"#"===document.location.hash[0]&&Ma()});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("fileUploadForm").addEventListener("submit",function(a){a.preventDefault();a=document.getElementById("fileUploadInput");var b=a.value;b&&(b=b.substr(b.lastIndexOf("\\")+1),eb(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();E&&document.getElementById("fileUploadContainer").classList.remove("hidden");return!1});document.getElementById("msgForm").addEventListener("submit",function(a){a.preventDefault();a=document.getElementById("msgInput");E&&a.value&&fb(a.value)&&(a.value="",S&&(S=null,T()),U&&(U=null,T()),document.getElementById("slashList").textContent="");Q();return!1});window.addEventListener("blur",function(){window.hasFocus=
+!1});window.addEventListener("focus",function(){window.hasFocus=!0;Ia=0;E&&Ua();Q()});document.getElementById("chatWindow").addEventListener("scroll",db);var a=0;document.getElementById("msgInput").addEventListener("input",function(){if(E){var b=Date.now();a+3E3<b&&(P.self.a||E instanceof q)&&(gb(),a=b);var b=[],c=this.value;if("/"===this.value[0]){var d=c.indexOf(" "),e=-1!==d,d=-1===d?c.length:d,c=c.substr(0,d),g=P?P.i.data:{};for(k in g){var f=g[k];(!e&&f.name.substr(0,d)===c||e&&f.name===c)&&
+b.push(f)}}b.sort(function(a,b){return a.T.localeCompare(b.T)||a.name.localeCompare(b.name)});var k=document.getElementById("slashList");var d=document.createDocumentFragment();k.textContent="";e=0;for(c=b.length;e<c;e++){g=b[e];if(h!==g.T){var h=g.T;d.appendChild(hb(g.T))}d.appendChild(ib(g))}k.appendChild(d)}});window.hasFocus=!0;(function(){var a=document.getElementById("emojiButton");if("makeEmoji"in window){var c=window.makeEmoji("smile");c?a.innerHTML="<span class='emoji-small'>"+c.outerHTML+
+"</span>":a.style.backgroundImage='url("smile.svg")';(c=window.makeEmoji("paperclip"))?document.getElementById("attachFile").innerHTML="<span class='emoji-small'>"+c.outerHTML+"</span>":document.getElementById("attachFile").style.backgroundImage='url("public/paperclip.svg")';a.addEventListener("click",function(){P&&ab.$(document.body,P,function(a){a&&(document.getElementById("msgInput").value+=":"+a+":");Q()})})}else a.classList.add("hidden")})();jb()});function Ka(){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 La=function(){var a={};return function(b){var c=a[b];c||(c=a[b]=document.createElement("header"),c.textContent=b);return c}}();
+function kb(a){var b=a.b,c=document.createElement("div"),d=document.createElement("div"),e=document.createElement("ul"),g=document.createElement("li");c.o=document.createElement("ul");c.C=document.createElement("ul");c.j=document.createElement("div");c.oa=document.createElement("div");c.fa=document.createElement("span");c.id=b+"_"+a.id;c.className="slackmsg-item";c.j.className="slackmsg-ts";c.oa.className="slackmsg-msg";c.fa.className="slackmsg-author-name";e.className="slackmsg-hover";g.className=
+"slackmsg-hover-reply";e.appendChild(g);if("makeEmoji"in window){var f=document.createElement("li"),k=window.makeEmoji("arrow_heading_down"),h=window.makeEmoji("smile"),n=window.makeEmoji("pencil2"),b=window.makeEmoji("x");f.className="slackmsg-hover-reaction";h?(f.classList.add("emoji-small"),f.appendChild(h)):f.style.backgroundImage='url("smile.svg")';k?(g.classList.add("emoji-small"),g.appendChild(k)):g.style.backgroundImage='url("repl.svg")';e.appendChild(f);qa(a.H)&&(a=document.createElement("li"),
+a.className="slackmsg-hover-edit",n?a.classList.add("emoji-small"):a.style.backgroundImage='url("edit.svg")',a.appendChild(n),e.appendChild(a),a=document.createElement("li"),a.className="slackmsg-hover-remove",b?a.classList.add("emoji-small"):a.style.backgroundImage='url("remove.svg")',a.appendChild(b),e.appendChild(a))}else g.style.backgroundImage='url("repl.svg")',qa(a.H)&&(a=document.createElement("li"),a.className="slackmsg-hover-edit",a.style.backgroundImage='url("edit.svg")',e.appendChild(a),
+a=document.createElement("li"),a.className="slackmsg-hover-remove",a.style.backgroundImage='url("remove.svg")',e.appendChild(a));d.appendChild(c.fa);d.appendChild(c.oa);d.appendChild(c.j);d.appendChild(c.o);c.D=document.createElement("div");c.D.className="slackmsg-edited";d.appendChild(c.D);d.appendChild(c.C);d.className="slackmsg-content";c.o.className="slackmsg-attachments";c.C.className="slackmsg-reactions";c.appendChild(d);c.appendChild(e);return c}
+function lb(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 mb(a,b,c){var d=document.createElement("li"),e=document.createElement("div"),g=document.createElement("div"),f=document.createElement("a"),k=document.createElement("div"),h=document.createElement("img"),n=document.createElement("a"),l=document.createElement("div"),m=document.createElement("div"),t=document.createElement("div"),w=document.createElement("img"),v=document.createElement("div");d.className="slackmsg-attachment";e.style.borderColor=lb(b.color||"");e.className="slackmsg-attachment-block";
+g.className="slackmsg-attachment-pretext";b.pretext?g.innerHTML=a.s(b.pretext):g.classList.add("hidden");f.target="_blank";b.title?(f.innerHTML=a.s(b.title),b.title_link&&(f.href=b.title_link),f.className="slackmsg-attachment-title"):f.className="hidden slackmsg-attachment-title";n.target="_blank";k.className="slackmsg-author";b.author_name&&(n.innerHTML=a.s(b.author_name),n.href=b.author_link||"",n.className="slackmsg-author-name",h.className="slackmsg-author-img",b.author_icon&&(h.src=b.author_icon,
+k.appendChild(h)),k.appendChild(n));t.className="slackmsg-attachment-thumb";b.thumb_url?(h=document.createElement("img"),h.src=b.thumb_url,t.appendChild(h),e.classList.add("has-thumb"),b.video_html&&(t.dataset.video=b.video_html)):t.classList.add("hidden");l.className="slackmsg-attachment-content";h=a.s(b.text||"");m.className="slackmsg-attachment-text";h&&""!=h?m.innerHTML=h:m.classList.add("hidden");w.className="slackmsg-attachment-img";b.image_url?w.src=b.image_url:w.classList.add("hidden");v.className=
+"slackmsg-attachment-footer";b.footer&&(h=document.createElement("span"),h.className="slackmsg-attachment-footer-text",h.innerHTML=a.s(b.footer),b.footer_icon&&(n=document.createElement("img"),n.src=b.footer_icon,n.className="slackmsg-attachment-footer-icon",v.appendChild(n)),v.appendChild(h));b.ts&&(h=document.createElement("span"),h.className="slackmsg-ts",h.innerHTML=L.V(b.ts),v.appendChild(h));l.appendChild(t);l.appendChild(m);e.appendChild(f);e.appendChild(k);e.appendChild(l);e.appendChild(w);
 if(b.fields&&b.fields.length){var u=document.createElement("ul");e.appendChild(u);u.className="slackmsg-attachment-fields";b.fields.forEach(function(b){var c=b.title||"",d=b.value||"";b=!!b["short"];var e=document.createElement("li"),g=document.createElement("div"),f=document.createElement("div");e.className="field";b||e.classList.add("field-long");g.className="field-title";g.textContent=c;f.className="field-text";f.innerHTML=a.s(d);e.appendChild(g);e.appendChild(f);e&&u.appendChild(e)})}if(b.actions&&
-b.actions.length)for(f=document.createElement("ul"),f.className="slackmsg-attachment-actions "+za,e.appendChild(f),l=0,k=b.actions.length;l<k;l++)(m=b.actions[l])&&(m=lb(c,l,m))&&f.appendChild(m);e.appendChild(v);d.appendChild(g);d.appendChild(e);return d}
-function lb(a,b,c){var d=document.createElement("li"),e=jb(c.style);d.textContent=c.text;e!==jb()&&(d.style.color=e);d.style.borderColor=e;d.dataset.attachmentIndex=a;d.dataset.actionIndex=b;d.className="slackmsg-attachment-actions-item "+ya;return d}function Oa(a){var b=document.createElement("li"),c=document.createElement("span");c.textContent=a.name;b.appendChild(Ia());b.appendChild(c);return b}
-function fb(a){var b=document.createElement("lh");b.textContent=a;b.className="slack-command-header";return b}
-function gb(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="slack-command-item";c.className="slack-command-name";d.className="slack-command-usage";e.className="slack-command-desc";return b};var Za=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;D&&D(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?w.value:a;if(l()){var c=window.searchEmojis(a);var d=e(c,Q.self.M.fa);for(var f in v)v[f].visible&&(v[f].visible=!1,m.removeChild(v[f].c));
-f=0;for(var h=d.length;f<h;f++){var y=d[f].name;var k=v[y];if(!k){k=v;var G=y,n=y;y=window.makeEmoji(c[y]);var D=document.createElement("span");D.appendChild(y);D.className="emoji-medium";y=g(n,D);k=k[G]=y}k.visible||(k.visible=!0,m.appendChild(k.c));b++}}for(f in u)u[f].visible&&(u[f].visible=!1,t.removeChild(u[f].c));d=e(Q.a.data,Q.self.M.fa);f=0;for(h=d.length;f<h;f++)y=d[f].name,""!==a&&y.substr(0,a.length)!==a||"alias:"===Q.a.data[y].substr(0,6)||(k=u[y],k||(c=u,G=k=y,y=Q.a.data[y],n=document.createElement("span"),
-D=document.createElement("span"),n.className="emoji emoji-custom",n.style.backgroundImage='url("'+y+'")',D.appendChild(n),D.className="emoji-medium",y=g(G,D),k=c[k]=y),k.visible||(k.visible=!0,t.appendChild(k.c)),b++);return b}function e(a,b){var c=[],d;for(d in a){var e={name:d,Ha:0,count:0};a[d].names&&a[d].names.forEach(function(a){e.count+=b[a]||0});c.push(e)}return c=c.sort(function(a,b){var c=b.count-a.count;return c?c:a.Ha-b.Ha})}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 f(a){var b=document.createElement("img"),c=document.createElement("div");b.src=a;c.appendChild(b);c.className="emojibar-header";return c}function l(){return"searchEmojis"in window}var h=document.createElement("div"),n=document.createElement("div"),k=document.createElement("div"),m=document.createElement("ul"),t=document.createElement("ul"),w=document.createElement("input"),v={},u={},J=document.createElement("div"),
-G=document.createElement("span"),Z=document.createElement("span"),D,Q;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";J.className="emojibar-detail";G.className="emojibar-detail-img";Z.className="emojibar-detail-name";m.className=t.className="emojibar-list";w.className="emojibar-search";J.appendChild(G);J.appendChild(Z);
-k.appendChild(f(window.emojiProviderHeader));k.appendChild(m);k.appendChild(f("emojicustom.png"));k.appendChild(t);h.appendChild(k);h.appendChild(J);h.appendChild(w);w.addEventListener("keyup",function(){d()});h.addEventListener("mousemove",function(b){a(b,function(a){var b=a?v[a]||u[a]:null;b?(G.innerHTML=b.c.outerHTML,Z.textContent=":"+a+":"):(G.textContent="",Z.textContent="")})});h.addEventListener("click",function(b){a(b,function(a){a&&c()&&D&&D(a)})});return{isSupported:l,Z:function(a,b,c){return l()?
-(Q=b,D=c,a.appendChild(n),a.appendChild(h),w.value="",d(),w.focus(),!0):!1},search:d,close:b}}();var C,N=[];function mb(){da.call(this)}mb.prototype=Object.create(da.prototype);mb.prototype.constructor=mb;function nb(a){return a.b?a.b.id:null}function ob(){this.b=0;this.context=new ka;this.a={}}
-ob.prototype.update=function(a){var b,c=Date.now();a.v&&(this.b=a.v);if(a["static"])for(var d in a["static"])(b=this.context[d])||(b=this.context[d]=new mb),ea(b,a["static"],c);la(this.context,function(a){a.w===a.B&&(a=N.indexOf(a),-1!==a&&N.splice(a,1))});if(a.live){for(d in a.live)(b=this.a[d])?ga(b,a.live[d],c):b=this.a[d]=new X(d,250,a.live[d],c);for(var e in a.live)b=F(this.context,e),(c=b.l[e])?(this.a[e].a.length&&(c.w=Math.max(c.w,ia(this.a[e]).j)),c.X||(pb(b,c,a.live[e]),E&&a.live[E.id]&&
-Ra())):C.b=0}if(a["static"])for(d in Ha(),a["static"])if(a["static"][d].typing){Ma();break}};setInterval(function(){var a=C.context,b=Date.now(),c=!1,d;for(d in a.D){var e=!0,g;for(g in a.D[d])a.D[d][g]+3E3<b?(delete a.D[d][g],c=!0):e=!1;e&&(delete a.D[d],c=!0)}c&&Ma()},1E3);
-function pb(a,b,c){if(b!==E||!window.hasFocus){var d=new RegExp("<@"+a.self.id),e=!1,g=!1,f=!1;c.forEach(function(c){if(!(parseFloat(c.ts)<=b.B)){g=!0;var h;if(!(h=b instanceof q)&&(h=c.text)&&!(h=c.text.match(d)))a:{h=a.self.M.u;for(var l=0,k=h.length;l<k;l++)if(-1!==c.text.indexOf(h[l])){h=!0;break a}h=!1}h&&(-1===N.indexOf(b)&&(f=!0,N.push(b)),e=!0)}});if(g){O();if(c=document.getElementById("room_"+b.id))c.classList.add("unread"),e&&c.classList.add("unreadHi");f&&!window.hasFocus&&Wa()}}}
-function Sa(){var a=E,b=N.indexOf(a);if(a.w>a.B){var c=new XMLHttpRequest;c.open("POST","api/markread?room="+a.id+"&ts="+a.w,!0);c.send(null);a.B=a.w}0<=b&&(N.splice(b,1),O());a=document.getElementById("room_"+a.id);a.classList.remove("unread");a.classList.remove("unreadHi")}C=new ob;var La=function(){function a(a,b){b.sort(function(){return Math.random()-.5});for(var c=0,d=20;d<h-40;d+=k)for(var e=0;e+k<=n;e+=k)g(a,b[c],d,e),c++,c===b.length&&(b.sort(function(a,b){return a.W?b.W?Math.random()-.5:-1:1}),c=0)}function b(a,d){for(var e=0,f=a.length;e<f;e++)if(void 0===a[e].W){c(a[e].src,function(c){a[e].W=c;b(a,d)});return}var g=[];a.forEach(function(a){a.W&&g.push(a.W)});d(g)}function c(a,b){var c=new XMLHttpRequest;c.responseType="blob";c.onreadystatechange=function(){if(4===
+b.actions.length)for(f=document.createElement("ul"),f.className="slackmsg-attachment-actions "+Ba,e.appendChild(f),k=0,l=b.actions.length;k<l;k++)(m=b.actions[k])&&(m=nb(c,k,m))&&f.appendChild(m);e.appendChild(v);d.appendChild(g);d.appendChild(e);return d}
+function nb(a,b,c){var d=document.createElement("li"),e=lb(c.style);d.textContent=c.text;e!==lb()&&(d.style.color=e);d.style.borderColor=e;d.dataset.attachmentIndex=a;d.dataset.actionIndex=b;d.className="slackmsg-attachment-actions-item "+Aa;return d}function Qa(a){var b=document.createElement("li"),c=document.createElement("span");c.textContent=a.name;b.appendChild(Ka());b.appendChild(c);return b}
+function hb(a){var b=document.createElement("lh");b.textContent=a;b.className="slack-command-header";return b}
+function ib(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="slack-command-item";c.className="slack-command-name";d.className="slack-command-usage";e.className="slack-command-desc";return b};var ab=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;D&&D(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?w.value:a;if(k()){var c=window.searchEmojis(a);var d=e(c,R.self.N.ga);for(var f in v)v[f].visible&&(v[f].visible=!1,m.removeChild(v[f].c));
+f=0;for(var h=d.length;f<h;f++){var y=d[f].name;var l=v[y];if(!l){l=v;var G=y,n=y;y=window.makeEmoji(c[y]);var D=document.createElement("span");D.appendChild(y);D.className="emoji-medium";y=g(n,D);l=l[G]=y}l.visible||(l.visible=!0,m.appendChild(l.c));b++}}for(f in u)u[f].visible&&(u[f].visible=!1,t.removeChild(u[f].c));d=e(R.a.data,R.self.N.ga);f=0;for(h=d.length;f<h;f++)y=d[f].name,""!==a&&y.substr(0,a.length)!==a||"alias:"===R.a.data[y].substr(0,6)||(l=u[y],l||(c=u,G=l=y,y=R.a.data[y],n=document.createElement("span"),
+D=document.createElement("span"),n.className="emoji emoji-custom",n.style.backgroundImage='url("'+y+'")',D.appendChild(n),D.className="emoji-medium",y=g(G,D),l=c[l]=y),l.visible||(l.visible=!0,t.appendChild(l.c)),b++);return b}function e(a,b){var c=[],d;for(d in a){var e={name:d,Ha:0,count:0};a[d].names&&a[d].names.forEach(function(a){e.count+=b[a]||0});c.push(e)}return c=c.sort(function(a,b){var c=b.count-a.count;return c?c:a.Ha-b.Ha})}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 f(a){var b=document.createElement("img"),c=document.createElement("div");b.src=a;c.appendChild(b);c.className="emojibar-header";return c}function k(){return"searchEmojis"in window}var h=document.createElement("div"),n=document.createElement("div"),l=document.createElement("div"),m=document.createElement("ul"),t=document.createElement("ul"),w=document.createElement("input"),v={},u={},J=document.createElement("div"),
+G=document.createElement("span"),Z=document.createElement("span"),D,R;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";l.className="emojibar-emojis";J.className="emojibar-detail";G.className="emojibar-detail-img";Z.className="emojibar-detail-name";m.className=t.className="emojibar-list";w.className="emojibar-search";J.appendChild(G);J.appendChild(Z);
+l.appendChild(f(window.emojiProviderHeader));l.appendChild(m);l.appendChild(f("emojicustom.png"));l.appendChild(t);h.appendChild(l);h.appendChild(J);h.appendChild(w);w.addEventListener("keyup",function(){d()});h.addEventListener("mousemove",function(b){a(b,function(a){var b=a?v[a]||u[a]:null;b?(G.innerHTML=b.c.outerHTML,Z.textContent=":"+a+":"):(G.textContent="",Z.textContent="")})});h.addEventListener("click",function(b){a(b,function(a){a&&c()&&D&&D(a)})});return{isSupported:k,$:function(a,b,c){return k()?
+(R=b,D=c,a.appendChild(n),a.appendChild(h),w.value="",d(),w.focus(),!0):!1},search:d,close:b}}();var C,N=[];function ob(){da.call(this)}ob.prototype=Object.create(da.prototype);ob.prototype.constructor=ob;function ma(a){return a.b?a.b.id:null}function pb(){this.b=0;this.context=new ka;this.a={}}
+pb.prototype.update=function(a){var b=Date.now();a.v&&(this.b=a.v);if(a["static"])for(var c in a["static"]){var d=la(this.context,c);d||(d=new ob,this.context.push(d));ea(d,a["static"][c],b)}na(this.context,function(a){a.w===a.B&&(a=N.indexOf(a),-1!==a&&N.splice(a,1))});if(a.live){for(c in a.live)(d=this.a[c])?ga(d,a.live[c],b):d=this.a[c]=new X(c,250,a.live[c],b);for(var e in a.live)d=F(this.context,e),(b=d.l[e])?(this.a[e].a.length&&(b.w=Math.max(b.w,ia(this.a[e]).j)),b.Y||(qb(d,b,a.live[e]),E&&
+a.live[E.id]&&Ta())):C.b=0}if(a["static"])for(c in Ja(),a["static"])if(a["static"][c].typing){Oa();break}};setInterval(function(){var a=!1,b=Date.now();oa(function(c){var d=!1,e;for(e in c.F){var g=!0,f;for(f in c.F[e])c.F[e][f]+3E3<b?(delete c.F[e][f],d=!0):g=!1;g&&(delete c.F[e],d=!0)}d&&(a=!0)});a&&Oa()},1E3);
+function qb(a,b,c){if(b!==E||!window.hasFocus){var d=new RegExp("<@"+a.self.id),e=!1,g=!1,f=!1;c.forEach(function(c){if(!(parseFloat(c.ts)<=b.B)){g=!0;var h;if(!(h=b instanceof q)&&(h=c.text)&&!(h=c.text.match(d)))a:{h=a.self.N.u;for(var k=0,l=h.length;k<l;k++)if(-1!==c.text.indexOf(h[k])){h=!0;break a}h=!1}h&&(-1===N.indexOf(b)&&(f=!0,N.push(b)),e=!0)}});if(g){O();if(c=document.getElementById("room_"+b.id))c.classList.add("unread"),e&&c.classList.add("unreadHi");f&&!window.hasFocus&&Ya()}}}
+function Ua(){var a=E,b=N.indexOf(a);if(a.w>a.B){var c=new XMLHttpRequest;c.open("POST","api/markread?room="+a.id+"&ts="+a.w,!0);c.send(null);a.B=a.w}0<=b&&(N.splice(b,1),O());a=document.getElementById("room_"+a.id);a.classList.remove("unread");a.classList.remove("unreadHi")}C=new pb;var Na=function(){function a(a,b){b.sort(function(){return Math.random()-.5});for(var c=0,d=20;d<h-40;d+=l)for(var e=0;e+l<=n;e+=l)g(a,b[c],d,e),c++,c===b.length&&(b.sort(function(a,b){return a.X?b.X?Math.random()-.5:-1:1}),c=0)}function b(a,d){for(var e=0,f=a.length;e<f;e++)if(void 0===a[e].X){c(a[e].src,function(c){a[e].X=c;b(a,d)});return}var g=[];a.forEach(function(a){a.X&&g.push(a.X)});d(g)}function c(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);for(var c=c.getImageData(0,0,w,w),d=0,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 d(){var a=l.createLinearGradient(0,0,0,n);a.addColorStop(0,"#4D394B");a.addColorStop(1,"#201820");l.fillStyle=a;l.fillRect(0,0,h,n);return l.getImageData(0,0,h,n)}function e(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 f=Math.floor(d);a=[a.data[f*h*4+0],a.data[f*h*4+1],a.data[f*h*4+2]];l.fillStyle=
-"#"+(1.1*a[0]<<16|1.1*a[1]<<8|1.1*a[2]).toString(16);l.beginPath();l.moveTo(c+k/2,d+m);l.lineTo(c-m+k,d+k/2);l.lineTo(c+k/2,d-m+k);l.lineTo(c+m,d+k/2);l.closePath();l.fill();l.putImageData(e(l.getImageData(c+m,d+m,t,t),b),c+m,d+m)}var f=document.createElement("canvas"),l=f.getContext("2d"),h=f.width=250,n=f.height=290,k=(h-40)/3,m=.1*k,t=Math.floor(k-2*m),w=.5*t,v={},u={},J={};return function(c,e,g){if(v[c])g(v);else if(J[c])u[c]?u[c].push(g):u[c]=[g];else{var h=d(),l=[];J[c]=!0;u[c]?u[c].push(g):
-u[c]=[g];for(var k in e)e[k].Ca||e[k].Na||l.push({src:"api/avatar?user="+e[k].id});b(l,function(b){a(h,b);v[c]=f.toDataURL();u[c].forEach(function(a){a()})})}}}();var W=0,E=null,P=null,S=null,U=null;function qb(){var a=new XMLHttpRequest;a.open("GET","api/hist?room="+E.id,!0);a.send(null)}
-function rb(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,Pa(!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,Pa(!1));a(d,c)}else W&&(W=0,Pa(!0)),rb(a)};b.open("GET","api?v="+C.b,!0);b.send(null)}function eb(){var a=new XMLHttpRequest;a.open("POST","api/typing?room="+E.id,!0);a.send(null)}
-function sb(a,b){a?(b&&C.update(b),hb()):setTimeout(hb,1E3*W)}function hb(){rb(sb)}function ab(a){E&&document.getElementById("room_"+E.id).classList.remove("selected");document.getElementById("room_"+a.id).classList.add("selected");document.body.classList.remove("no-room-selected");E=a;P=F(C.context,a.id);Qa();La(P.b.id,P.m,function(a){document.getElementById("slackCtx").style.backgroundImage="url("+a+")"});E.w&&!C.a[E.id]&&qb()}
-function cb(a,b,c){var d=E;new FileReader;var e=new FormData,g=new XMLHttpRequest;e.append("file",b);e.append("filename",a);g.onreadystatechange=function(){4===g.readyState&&(204===g.status?c(null):c(g.statusText))};g.open("POST","api/file?room="+d.id);g.send(e)}
-function db(a){if(U){var b=new XMLHttpRequest;b.open("PUT","api/msg?room="+E.id+"&ts="+U.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);return(b=(c=P)?c.i.data[b]:null)?(c=new XMLHttpRequest,c.open("POST","api/cmd?room="+E.id+"&cmd="+encodeURIComponent(b.name.substr(1))+"&args="+encodeURIComponent(a.trim()),!0),c.send(null),!0):!1}var b=E,c=S,d=new XMLHttpRequest;a="api/msg?room="+b.id+"&text="+
-encodeURIComponent(a);if(c){var e=I(c.G);a+="&attachments="+encodeURIComponent(JSON.stringify([{fallback:c.text,author_name:"<@"+e.id+"|"+e.name+">",text:c.text,footer:b.b?"Private message":b.name,ts:c.j}]))}d.open("POST",a,!0);d.send(null);return!0}function $a(a){var b=new XMLHttpRequest;b.open("DELETE","api/msg?room="+E.id+"&ts="+a.id,!0);b.send(null)}function Ta(a,b,c){var d=new XMLHttpRequest;d.open("POST","api/reaction?room="+a+"&msg="+b+"&reaction="+encodeURIComponent(c),!0);d.send(null)};function X(a,b,c,d){B.call(this,a,b,c,d)}X.prototype=Object.create(B.prototype);X.prototype.constructor=X;X.prototype.b=function(a,b){return!0===a.isMeMessage?new tb(this.id,a,b):!0===a.isNotice?new ub(this.id,a,b):new vb(this.id,a,b)};
-var Y=function(){function a(a,c){return qa(c,{u:a.context.self.M.u,U:function(a){":"===a[0]&&":"===a[a.length-1]&&(a=a.substr(1,a.length-2));if(a=Ua(a)){var b=document.createElement("span");b.className="emoji-small";b.appendChild(a);return b.outerHTML}return null},Y:function(b){a:{var c=b.indexOf("|");if(-1===c)var d=b;else{d=b.substr(0,c);var f=b.substr(c+1)}if("@"===d[0])if(d=nb(a.context)+"|"+d.substr(1),f=I(d))b=!0,f="@"+f.name;else{d=null;break a}else if("#"===d[0])if(d=nb(a.context)+"|"+d.substr(1),
-f=H(d))b=!0,f="#"+f.name;else{d=null;break a}else b=!1;d={link:d,text:f||d,Oa:b}}return d}})}return{F:function(a){a.N=!0;return a},O:function(a){a.c&&a.c.parentElement&&(a.c.remove(),delete a.c);return a},L:function(a){a.c?a.N&&(a.N=!1,a.J()):a.da().J();return a.c},J:function(b){var c=I(b.G);b.c.j.innerHTML=L.ga(b.j);b.c.oa.innerHTML=a(b,b.text);b.c.ea.textContent=c?c.name:b.username||"?";for(var c=document.createDocumentFragment(),d=0,e=b.o.length;d<e;d++){var g=b.o[d];g&&(g=kb(b,g,d))&&c.appendChild(g)}b.c.o.textContent=
-"";b.c.o.appendChild(c);c=b.b;d=document.createDocumentFragment();if(b.C)for(var f in b.C){var e=c,g=b.id,l=f,h=b.C[f],n=Ua(l);if(n){for(var k=document.createElement("li"),m=document.createElement("a"),t=document.createElement("span"),w=document.createElement("span"),v=[],u=0,J=h.length;u<J;u++){var G=I(h[u]);G&&v.push(G.name)}v.sort();w.textContent=v.join(", ");t.appendChild(n);t.className="emoji-small";m.href="javascript:toggleReaction('"+e+"', '"+g+"', '"+l+"')";m.appendChild(t);m.appendChild(w);
-k.className="slackmsg-reaction-item";k.appendChild(m);e=k}else console.warn("Reaction id not found: "+l),e=null;e&&d.appendChild(e)}b.c.C.textContent="";b.c.C.appendChild(d);b.T&&b.c.classList.add("edited");return b},K:function(a){return a.c.cloneNode(!0)},s:function(b,c){return a(b,c)}}}();function tb(a,b,c){x.call(this,b,c);this.context=F(C.context,a);this.b=a;this.c=Y.c;this.N=Y.N}tb.prototype=Object.create(z.prototype);p=tb.prototype;p.constructor=tb;p.F=function(){return Y.F(this)};
-p.s=function(a){return Y.s(this,a)};p.O=function(){return Y.O(this)};p.L=function(){return Y.L(this)};p.da=function(){this.c=ib(this);this.c.classList.add("slackmsg-me_message");return this};p.K=function(){return Y.K(this)};p.J=function(){Y.J(this);return this};p.update=function(a,b){z.prototype.update.call(this,a,b);this.F()};function vb(a,b,c){x.call(this,b,c);this.context=F(C.context,a);this.b=a;this.c=Y.c;this.N=Y.N}vb.prototype=Object.create(x.prototype);p=vb.prototype;p.constructor=vb;p.F=function(){return Y.F(this)};
-p.s=function(a){return Y.s(this,a)};p.O=function(){return Y.O(this)};p.L=function(){return Y.L(this)};p.da=function(){this.c=ib(this);return this};p.K=function(){return Y.K(this)};p.J=function(){Y.J(this);return this};p.update=function(a,b){x.prototype.update.call(this,a,b);this.F()};function ub(a,b,c){x.call(this,b,c);this.context=F(C.context,a);this.b=a;this.a=null;this.N=!0}ub.prototype=Object.create(A.prototype);p=ub.prototype;p.constructor=ub;p.F=function(){return Y.F(this)};
-p.s=function(a){return Y.s(this,a)};p.O=function(){this.a&&this.a.parentElement&&(this.a.remove(),delete this.a);this.c&&delete this.c;return this};p.L=function(){Y.L(this);return this.a};p.K=function(){return this.a.cloneNode(!0)};p.da=function(){this.c=ib(this);this.a=document.createElement("span");this.c.classList.add("slackmsg-notice");this.a.className="slackmsg-notice";this.a.textContent=L.Ga;this.a.appendChild(this.c);return this};p.J=function(){Y.J(this);return this};
-p.update=function(a,b){A.prototype.update.call(this,a,b);this.F()};
+c.open("GET",a,!0);c.send(null)}function d(){var a=k.createLinearGradient(0,0,0,n);a.addColorStop(0,"#4D394B");a.addColorStop(1,"#201820");k.fillStyle=a;k.fillRect(0,0,h,n);return k.getImageData(0,0,h,n)}function e(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 f=Math.floor(d);a=[a.data[f*h*4+0],a.data[f*h*4+1],a.data[f*h*4+2]];k.fillStyle=
+"#"+(1.1*a[0]<<16|1.1*a[1]<<8|1.1*a[2]).toString(16);k.beginPath();k.moveTo(c+l/2,d+m);k.lineTo(c-m+l,d+l/2);k.lineTo(c+l/2,d-m+l);k.lineTo(c+m,d+l/2);k.closePath();k.fill();k.putImageData(e(k.getImageData(c+m,d+m,t,t),b),c+m,d+m)}var f=document.createElement("canvas"),k=f.getContext("2d"),h=f.width=250,n=f.height=290,l=(h-40)/3,m=.1*l,t=Math.floor(l-2*m),w=.5*t,v={},u={},J={};return function(c,e,g){if(v[c])g(v[c]);else if(J[c])u[c]?u[c].push(g):u[c]=[g];else{var h=d(),k=[];J[c]=!0;u[c]?u[c].push(g):
+u[c]=[g];for(var l in e)e[l].Ca||e[l].Na||k.push({src:"api/avatar?user="+e[l].id});b(k,function(b){a(h,b);v[c]=f.toDataURL();u[c].forEach(function(a){a(v[c])})})}}}();var W=0,E=null,P=null,S=null,U=null;function rb(){var a=new XMLHttpRequest;a.open("GET","api/hist?room="+E.id,!0);a.send(null)}
+function sb(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,Ra(!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,Ra(!1));a(d,c)}else W&&(W=0,Ra(!0)),sb(a)};b.open("GET","api?v="+C.b,!0);b.send(null)}function gb(){var a=new XMLHttpRequest;a.open("POST","api/typing?room="+E.id,!0);a.send(null)}
+function tb(a,b){a?(b&&C.update(b),jb()):setTimeout(jb,1E3*W)}function jb(){sb(tb)}function cb(a){E&&document.getElementById("room_"+E.id).classList.remove("selected");document.getElementById("room_"+a.id).classList.add("selected");document.body.classList.remove("no-room-selected");E=a;P=F(C.context,a.id);Sa();Na(P.b.id,P.m,function(a){document.getElementById("slackCtx").style.backgroundImage="url("+a+")"});E.w&&!C.a[E.id]&&rb()}
+function eb(a,b,c){var d=E;new FileReader;var e=new FormData,g=new XMLHttpRequest;e.append("file",b);e.append("filename",a);g.onreadystatechange=function(){4===g.readyState&&(204===g.status?c(null):c(g.statusText))};g.open("POST","api/file?room="+d.id);g.send(e)}
+function fb(a){if(U){var b=new XMLHttpRequest;b.open("PUT","api/msg?room="+E.id+"&ts="+U.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);return(b=(c=P)?c.i.data[b]:null)?(c=new XMLHttpRequest,c.open("POST","api/cmd?room="+E.id+"&cmd="+encodeURIComponent(b.name.substr(1))+"&args="+encodeURIComponent(a.trim()),!0),c.send(null),!0):!1}var b=E,c=S,d=new XMLHttpRequest;a="api/msg?room="+b.id+"&text="+
+encodeURIComponent(a);if(c){var e=I(c.H);a+="&attachments="+encodeURIComponent(JSON.stringify([{fallback:c.text,author_name:"<@"+e.id+"|"+e.name+">",text:c.text,footer:b.b?"Private message":b.name,ts:c.j}]))}d.open("POST",a,!0);d.send(null);return!0}function bb(a){var b=new XMLHttpRequest;b.open("DELETE","api/msg?room="+E.id+"&ts="+a.id,!0);b.send(null)}function Va(a,b,c){var d=new XMLHttpRequest;d.open("POST","api/reaction?room="+a+"&msg="+b+"&reaction="+encodeURIComponent(c),!0);d.send(null)};function X(a,b,c,d){B.call(this,a,b,c,d)}X.prototype=Object.create(B.prototype);X.prototype.constructor=X;X.prototype.b=function(a,b){return!0===a.isMeMessage?new ub(this.id,a,b):!0===a.isNotice?new vb(this.id,a,b):new wb(this.id,a,b)};
+var Y=function(){function a(a,c){return sa(c,{u:a.context.self.N.u,U:function(a){":"===a[0]&&":"===a[a.length-1]&&(a=a.substr(1,a.length-2));if(a=Wa(a)){var b=document.createElement("span");b.className="emoji-small";b.appendChild(a);return b.outerHTML}return null},Z:function(b){a:{var c=b.indexOf("|");if(-1===c)var d=b;else{d=b.substr(0,c);var f=b.substr(c+1)}if("@"===d[0])if(d=ma(a.context)+"|"+d.substr(1),f=I(d))b=!0,f="@"+f.name;else{d=null;break a}else if("#"===d[0])if(d=ma(a.context)+"|"+d.substr(1),
+f=H(d))b=!0,f="#"+f.name;else{d=null;break a}else b=!1;d={link:d,text:f||d,Oa:b}}return d}})}return{G:function(a){a.O=!0;return a},P:function(a){a.c&&a.c.parentElement&&(a.c.remove(),delete a.c);return a},M:function(a){a.c?a.O&&(a.O=!1,a.K()):a.ea().K();return a.c},K:function(b){var c=I(b.H);b.c.j.innerHTML=L.V(b.j);b.c.oa.innerHTML=a(b,b.text);b.c.fa.textContent=c?c.name:b.username||"?";for(var c=document.createDocumentFragment(),d=0,e=b.o.length;d<e;d++){var g=b.o[d];g&&(g=mb(b,g,d))&&c.appendChild(g)}b.c.o.textContent=
+"";b.c.o.appendChild(c);c=b.b;d=document.createDocumentFragment();if(b.C)for(var f in b.C){var e=c,g=b.id,k=f,h=b.C[f],n=Wa(k);if(n){for(var l=document.createElement("li"),m=document.createElement("a"),t=document.createElement("span"),w=document.createElement("span"),v=[],u=0,J=h.length;u<J;u++){var G=I(h[u]);G&&v.push(G.name)}v.sort();w.textContent=v.join(", ");t.appendChild(n);t.className="emoji-small";m.href="javascript:toggleReaction('"+e+"', '"+g+"', '"+k+"')";m.appendChild(t);m.appendChild(w);
+l.className="slackmsg-reaction-item";l.appendChild(m);e=l}else console.warn("Reaction id not found: "+k),e=null;e&&d.appendChild(e)}b.c.C.textContent="";b.c.C.appendChild(d);b.D&&(b.c.D.innerHTML=L.D(b.D),b.c.classList.add("edited"));return b},L:function(a){return a.c.cloneNode(!0)},s:function(b,c){return a(b,c)}}}();function ub(a,b,c){x.call(this,b,c);this.context=F(C.context,a);this.b=a;this.c=Y.c;this.O=Y.O}ub.prototype=Object.create(z.prototype);p=ub.prototype;p.constructor=ub;p.G=function(){return Y.G(this)};
+p.s=function(a){return Y.s(this,a)};p.P=function(){return Y.P(this)};p.M=function(){return Y.M(this)};p.ea=function(){this.c=kb(this);this.c.classList.add("slackmsg-me_message");return this};p.L=function(){return Y.L(this)};p.K=function(){Y.K(this);return this};p.update=function(a,b){z.prototype.update.call(this,a,b);this.G()};function wb(a,b,c){x.call(this,b,c);this.context=F(C.context,a);this.b=a;this.c=Y.c;this.O=Y.O}wb.prototype=Object.create(x.prototype);p=wb.prototype;p.constructor=wb;p.G=function(){return Y.G(this)};
+p.s=function(a){return Y.s(this,a)};p.P=function(){return Y.P(this)};p.M=function(){return Y.M(this)};p.ea=function(){this.c=kb(this);return this};p.L=function(){return Y.L(this)};p.K=function(){Y.K(this);return this};p.update=function(a,b){x.prototype.update.call(this,a,b);this.G()};function vb(a,b,c){x.call(this,b,c);this.context=F(C.context,a);this.b=a;this.a=null;this.O=!0}vb.prototype=Object.create(A.prototype);p=vb.prototype;p.constructor=vb;p.G=function(){return Y.G(this)};
+p.s=function(a){return Y.s(this,a)};p.P=function(){this.a&&this.a.parentElement&&(this.a.remove(),delete this.a);this.c&&delete this.c;return this};p.M=function(){Y.M(this);return this.a};p.L=function(){return this.a.cloneNode(!0)};p.ea=function(){this.c=kb(this);this.a=document.createElement("span");this.c.classList.add("slackmsg-notice");this.a.className="slackmsg-notice";this.a.textContent=L.Ga;this.a.appendChild(this.c);return this};p.K=function(){Y.K(this);return this};
+p.update=function(a,b){A.prototype.update.call(this,a,b);this.G()};
 })();

+ 0 - 3
srv/src/context.js

@@ -93,9 +93,6 @@ function ChatContext() {
     /** @type {ChatInfo} */
     this.team = null;
 
-    /** @type {Object<string, ChatInfo>} */
-    this.teams = {};
-
     /** @type {Object.<string, Room>} */
     this.channels = {};
 

+ 17 - 17
srv/src/httpServ.js

@@ -130,7 +130,7 @@ Server.prototype.onRequest = function(req, res) {
             } else {
                 var ctx = res.chatContext.getChannelContext(req.urlObj.queryTokens.room[0]);
                 if (ctx) {
-                    ctx.fetchHistory(ctx.channels[targetId]);
+                    ctx.fetchHistory(ctx.getChatContext().channels[req.urlObj.queryTokens.room[0]]);
                     res.writeHeader("204", "No Content");
                 } else {
                     res.writeHeader("404", "Channel not found");
@@ -148,7 +148,7 @@ Server.prototype.onRequest = function(req, res) {
                 if (!ctx) {
                     res.writeHeader("404", "Chan not found");
                 } else {
-                    ctx.sendTyping(ctx.channels[req.urlObj.queryTokens.room[0]);
+                    ctx.sendTyping(ctx.getChatContext().channels[req.urlObj.queryTokens.room[0]]);
                     res.writeHeader("204", "No Content");
                 }
                 res.end();
@@ -160,7 +160,7 @@ Server.prototype.onRequest = function(req, res) {
                 res.end();
             } else {
                 var ctx = res.chatContext.getChannelContext(req.urlObj.queryTokens.room[0])
-                    ,cmd = res.chatContext.data.commands.data['/' +req.urlObj.queryTokens.cmd[0]];
+                    ,cmd = ctx.getChatContext().commands.data['/' +req.urlObj.queryTokens.cmd[0]];
 
                 if (!ctx) {
                     res.writeHeader("404", "Chan not found");
@@ -170,7 +170,7 @@ Server.prototype.onRequest = function(req, res) {
                     var args = req.urlObj.queryTokens.args ? req.urlObj.queryTokens.args[0] : "";
                     if (args === true)
                         args = "";
-                    ctx.sendCommand(ctx.channels[req.urlObj.queryTokens.room[0]], cmd, args);
+                    ctx.sendCommand(ctx.getChatContext().channels[req.urlObj.queryTokens.room[0]], cmd, args);
                     res.writeHeader("204", "No Content");
                 }
                 res.end();
@@ -183,12 +183,12 @@ Server.prototype.onRequest = function(req, res) {
                 var ctx = res.chatContext.getChannelContext(req.urlObj.queryTokens.room[0])
                     ,ts = parseFloat(req.urlObj.queryTokens.ts[0]);
 
-                if (!chan) {
+                if (!ctx) {
                     res.writeHeader("404", "Chan Not Found");
                 } else if (isNaN(ts)) {
                     res.writeHeader("400", "Invalid date");
                 } else {
-                    ctx.markRead(ctx.channels[req.urlObj.queryTokens.room[0]], ts);
+                    ctx.markRead(ctx.getChatContext().channels[req.urlObj.queryTokens.room[0]], ts);
                     res.writeHeader("204", "No Content");
                 }
                 res.end();
@@ -233,9 +233,9 @@ Server.prototype.onRequest = function(req, res) {
                             catch (e) {}
                         }
                         if (req.urlObj.queryTokens.me)
-                            ctx.sendMeMsg(ctx.channels[req.urlObj.queryTokens.room[0]], req.urlObj.queryTokens.text);
+                            ctx.sendMeMsg(ctx.getChatContext().channels[req.urlObj.queryTokens.room[0]], req.urlObj.queryTokens.text);
                         else
-                            ctx.sendMsg(ctx.channels[req.urlObj.queryTokens.room[0]], req.urlObj.queryTokens.text, attachments);
+                            ctx.sendMsg(ctx.getChatContext().channels[req.urlObj.queryTokens.room[0]], req.urlObj.queryTokens.text, attachments);
                         res.writeHeader("204", "No Content");
                     } else {
                         res.writeHeader("404", "Channel not found");
@@ -246,8 +246,8 @@ Server.prototype.onRequest = function(req, res) {
                     res.writeHeader("400", "Bad request");
                 } else {
                     var ctx = res.chatContext.getChannelContext(req.urlObj.queryTokens.room[0]);
-                    if (chan) {
-                        ctx.removeMsg(ctx.channels[req.urlObj.queryTokens.room[0]], req.urlObj.queryTokens.ts[0]);
+                    if (ctx) {
+                        ctx.removeMsg(ctx.getChatContext().channels[req.urlObj.queryTokens.room[0]], req.urlObj.queryTokens.ts[0]);
                         res.writeHeader("204", "No Content");
                     } else {
                         res.writeHeader("404", "Channel not found");
@@ -259,7 +259,7 @@ Server.prototype.onRequest = function(req, res) {
                 } else {
                     var ctx = res.chatContext.getChannelContext(req.urlObj.queryTokens.room[0]);
                     if (ctx) {
-                        ctx.editMsg(ctx.channels[req.urlObj.queryTokens.room[0]], req.urlObj.queryTokens.ts[0], req.urlObj.queryTokens.text);
+                        ctx.editMsg(ctx.getChatContext().channels[req.urlObj.queryTokens.room[0]], req.urlObj.queryTokens.ts[0], req.urlObj.queryTokens.text);
                         res.writeHeader("204", "No Content");
                     } else {
                         res.writeHeader("404", "Channel not found");
@@ -281,10 +281,10 @@ Server.prototype.onRequest = function(req, res) {
                     res.writeHeader("404", "Channel Not Found");
                 } else if (req.method === 'POST') {
                     res.writeHeader("204", "No Content");
-                    ctx.addReaction(chan, msgId, reaction);
+                    ctx.addReaction(ctx.getChatContext().channels[chanId], msgId, reaction);
                 } else if (req.method === 'DELETE') {
                     res.writeHeader("204", "No Content");
-                    ctx.removeReaction(chan, msgId, reaction);
+                    ctx.removeReaction(ctx.getChatContext().channels[chanId], msgId, reaction);
                 } else {
                     res.writeHeader("405", "Method not allowed");
                 }
@@ -295,10 +295,10 @@ Server.prototype.onRequest = function(req, res) {
             res.end();
         } else if (req.urlObj.match(["api", "file"])) {
             sessionManager.saveSession(req.session);
-            if (req.urlObj.queryTokens["room"]) {
-                var ctx = res.chatContext.getChannelContext(req.urlObj.queryTokens["room"][0]);
+            if (req.urlObj.queryTokens.room) {
+                var ctx = res.chatContext.getChannelContext(req.urlObj.queryTokens.room[0]);
                 if (ctx) {
-                    var uploadRequest = ctx.openUploadFileStream(chan, req.headers["content-type"], (errorMsg) => {
+                    var uploadRequest = ctx.openUploadFileStream(ctx.getChatContext().channels[req.urlObj.queryTokens.room[0]], req.headers["content-type"], (errorMsg) => {
                         if (!errorMsg)
                             res.writeHeader("204", "No Content");
                         else
@@ -326,7 +326,7 @@ Server.prototype.onRequest = function(req, res) {
             });
         } else if (req.urlObj.match(["api"])) {
             res.chatContext.poll(
-                (req.urlObj.queryTokens.v ? req.urlObj.queryTokens.v[0] : 0) || 0
+                (req.urlObj.queryTokens.v ? parseInt(req.urlObj.queryTokens.v[0], 10) : 0) || 0
                 , (newData) => {
                 if (!res.ended) {
                     try {

+ 4 - 7
srv/src/message.js

@@ -15,7 +15,7 @@ function Message(e, ts) {
     this.id = e["id"] || e["ts"];
 
     /** @const @type {number} **/
-    this.ts = parseFloat(e["ts"]);
+    this.ts = e["ts"];
 
     /** @type {string} */
     this.text = "";
@@ -29,7 +29,7 @@ function Message(e, ts) {
     /** @type {boolean} */
     this.pinned = false;
 
-    /** @type {boolean} */
+    /** @type {number|boolean} */
     this.edited = false;
 
     /** @type {boolean} */
@@ -73,7 +73,7 @@ Message.prototype.update = function(e, ts) {
         if (e["attachments"]) this.attachments = e["attachments"];
         this.starred = !!e["is_starred"];
         this.pinned = false; // TODO
-        this.edited = !!e["edited"];
+        this.edited = e["edited"] === undefined ? false : e["edited"];
         this.removed = !!e["removed"];
 
         if (e["reactions"]) {
@@ -109,14 +109,11 @@ Message.prototype.toStatic = function() {
         ,"text": this.text
         ,"attachments": this.attachments.length ? this.attachments : undefined
         ,"is_starred": this.is_starred || undefined
-        ,"edited": this.edited || undefined
+        ,"edited": this.edited === false ? undefined : this.edited
         ,"removed": this.removed || undefined
         ,"reactions": reactions
         ,"isMeMessage": this instanceof MeMessage || undefined
         ,"isNotice": this instanceof NoticeMessage || undefined
-
-        // FIXME debug purpose only
-        ,"v": this.version
     };
 };
 

+ 22 - 3
srv/src/multichatManager.js

@@ -115,6 +115,17 @@ MultiChatManager.prototype.push = function(chatSystem) {
     this.contexts.push(chatSystem);
 };
 
+/**
+ * @param {string} id
+ * @return {ChatSystem|null}
+**/
+MultiChatManager.prototype.getById = function(id) {
+    for (var i = 0, nbContexts = this.contexts.length; i < nbContexts; i++)
+        if (id === this.contexts[i].getId())
+            return this.contexts[i];
+    return null;
+};
+
 /**
  * You may want to return true to break the loop
 **/
@@ -210,6 +221,7 @@ MultiChatManager.prototype.poll = function(knownVersion, callback) {
     });
     setTimeout((function() {
         var liveFeed = {}
+            ,hasLive = false
             ,staticFeed = {}
             ,v = 0
             ,updated = false;
@@ -223,8 +235,10 @@ MultiChatManager.prototype.poll = function(knownVersion, callback) {
                     if (res["static"])
                         staticFeed[id] = res["static"];
                     if (res["live"])
-                        for (var i in res["live"])
+                        for (var i in res["live"]) {
                             liveFeed[i] = res["live"][i];
+                            hasLive = true;
+                        }
                     v = Math.max(v, (res["v"] || 0));
                     updated = true;
                 }
@@ -232,7 +246,7 @@ MultiChatManager.prototype.poll = function(knownVersion, callback) {
         });
         if (updated)
             callback({
-                "live": liveFeed.length ? liveFeed : undefined,
+                "live": hasLive ? liveFeed : undefined,
                 "static": staticFeed,
                 "v": Math.max(v, knownVersion)
             });
@@ -243,5 +257,10 @@ MultiChatManager.prototype.poll = function(knownVersion, callback) {
     }).bind(this), 2000);
 };
 
-module.exports.MultiChatManager = MultiChatManager;
+/** @suppress {undefinedVars,checkTypes} */
+(function() {
+    if (typeof module !== "undefined") {
+        module.exports.MultiChatManager = MultiChatManager;
+    }
+})();
 

+ 6 - 7
srv/src/slack.js

@@ -172,15 +172,14 @@ Slack.prototype.getEmojis = function(cb) {
 Slack.prototype.poll = function(knownVersion) {
     if (this.connected) {
         var updatedCtx = this.data.getUpdates(knownVersion, Date.now())
-            ,updatedLive = this.getLiveUpdates(knownVersion)
-            ,updated;
+            ,updatedLive = this.getLiveUpdates(knownVersion);
 
         if (updatedCtx || updatedLive) {
-            updated = {};
-            updated["static"] = updatedCtx;
-            updated["live"] = updatedLive;
-            updated["v"] = Math.max(this.data.liveV, this.data.staticV);
-            return updated;
+            return {
+                "static": updatedCtx,
+                "live": updatedLive,
+                "v": Math.max(this.data.liveV, this.data.staticV)
+            };
         }
     }
 };

+ 15 - 0
srv/src/slackHistory.js

@@ -29,6 +29,12 @@ SlackHistory.prototype.messageFactory = function(ev, ts) {
     if (!ev["user"])
         ev["user"] = ev["bot_id"];
     ev["user"] = this.idPrefix +ev["user"];
+    if (ev["reactions"]) {
+        ev["reactions"].forEach((r) => {
+            for (var i =0, nbUsers =r["users"].length; i < nbUsers; i++)
+                r["users"][i] = this.idPrefix +r["users"][i];
+        });
+    }
     if (ev["is_ephemeral"] === true)
         return new NoticeMessage(ev, ts);
     if (ev["subtype"] === "me_message")
@@ -60,6 +66,15 @@ SlackHistory.prototype.push = function(ev, t) {
                 targetId = ev["deleted_ts"];
             modifArg = null;
         }
+        if (modifArg["edited"])
+            modifArg["edited"] = Math.round(parseFloat(modifArg["edited"]["ts"]) * 1000);
+        if (modifArg["ts"])
+            modifArg["ts"] = Math.round(parseFloat(modifArg["ts"]) * 1000);
+        if (!modifArg["id"])
+            modifArg["id"] = targetId;
+        if (modifArg["attachments"])
+            console.log(modifArg);
+        //FIXME attachment ts
         for (var i =0, nbMsg = this.messages.length; i < nbMsg; i++) {
             msg = this.messages[i];
             if (msg.id === targetId) {