User:Jim Carter/WikiChat.js

(function {   var e = this,        t = e._,        n = Array.prototype,        a = Object.prototype,        r = Function.prototype,        i = n.push,        s = n.slice,        o = n.concat,        c = a.toString,        l = a.hasOwnProperty,        u = Array.isArray,        h = Object.keys,        d = r.bind,        f = function(e) {            return e instanceof f ? e : this instanceof f ? void(this._wrapped = e) : new f(e)        };    "undefined" != typeof exports ? ("undefined" != typeof module && module.exports && (exports = module.exports = f), exports._ = f) : e._ = f, f.VERSION = "1.7.0";    var p = function(e, t, n) {        if (void 0 === t) return e;        switch (null == n ? 3 : n) {           case 1:                return function(n) {                    return e.call(t, n)                };            case 2:                return function(n, a) {                    return e.call(t, n, a)                };            case 3:                return function(n, a, r) {                    return e.call(t, n, a, r)                };            case 4:                return function(n, a, r, i) {                    return e.call(t, n, a, r, i)                }        }        return function {            return e.apply(t, arguments)        }    };    f.iteratee = function(e, t, n) {        return null == e ? f.identity : f.isFunction(e) ? p(e, t, n) : f.isObject(e) ? f.matches(e) : f.property(e)    }, f.each = f.forEach = function(e, t, n) {        if (null == e) return e;        t = p(t, n);        var a, r = e.length;        if (r === +r)            for (a = 0; r > a; a++) t(e[a], a, e); else { var i = f.keys(e); for (a = 0, r = i.length; r > a; a++) t(e[i[a]], i[a], e)       } return e   }, f.map = f.collect = function(e, t, n) { if (null == e) return []; t = f.iteratee(t, n); for (var a, r = e.length !== +e.length && f.keys(e), i = (r || e).length, s = Array(i), o = 0; i > o; o++) a = r ? r[o] : o, s[o] = t(e[a], a, e); return s   }; var m = "Reduce of empty array with no initial value"; f.reduce = f.foldl = f.inject = function(e, t, n, a) { null == e && (e = []), t = p(t, a, 4); var r, i = e.length !== +e.length && f.keys(e), s = (i || e).length, o = 0; if (3 > arguments.length) { if (!s) throw new TypeError(m); n = e[i ? i[o++] : o++] }       for (s > o; o++) r = i ? i[o] : o, n = t(n, e[r], r, e); return n   }, f.reduceRight = f.foldr = function(e, t, n, a) { null == e && (e = []), t = p(t, a, 4); var r, i = e.length !== +e.length && f.keys(e), s = (i || e).length; if (3 > arguments.length) { if (!s) throw new TypeError(m); n = e[i ? i[--s] : --s] }       for (s--;) r = i ? i[s] : s, n = t(n, e[r], r, e); return n   }, f.find = f.detect = function(e, t, n) { var a;       return t = f.iteratee(t, n), f.some(e, function(e, n, r) {            return t(e, n, r) ? (a = e, !0) : void 0        }), a    }, f.filter = f.select = function(e, t, n) { var a = []; return null == e ? a : (t = f.iteratee(t, n), f.each(e, function(e, n, r) { t(e, n, r) && a.push(e) }), a)   }, f.reject = function(e, t, n) { return f.filter(e, f.negate(f.iteratee(t)), n)   }, f.every = f.all = function(e, t, n) { if (null == e) return !0; t = f.iteratee(t, n); var a, r, i = e.length !== +e.length && f.keys(e), s = (i || e).length; for (a = 0; s > a; a++) if (r = i ? i[a] : a, !t(e[r], r, e)) return !1; return !0 }, f.some = f.any = function(e, t, n) { if (null == e) return !1; t = f.iteratee(t, n); var a, r, i = e.length !== +e.length && f.keys(e), s = (i || e).length; for (a = 0; s > a; a++) if (r = i ? i[a] : a, t(e[r], r, e)) return !0; return !1 }, f.contains = f.include = function(e, t) { return null == e ? !1 : (e.length !== +e.length && (e = f.values(e)), f.indexOf(e, t) >= 0) }, f.invoke = function(e, t) { var n = s.call(arguments, 2), a = f.isFunction(t); return f.map(e, function(e) {           return (a ? t : e[t]).apply(e, n)       }) }, f.pluck = function(e, t) { return f.map(e, f.property(t)) }, f.where = function(e, t) { return f.filter(e, f.matches(t)) }, f.findWhere = function(e, t) { return f.find(e, f.matches(t)) }, f.max = function(e, t, n) { var a, r, i = -1 / 0, s = -1 / 0; if (null == t && null != e) { e = e.length === +e.length ? e : f.values(e); for (var o = 0, c = e.length; c > o; o++) a = e[o], a > i && (i = a)       } else t = f.iteratee(t, n), f.each(e, function(e, n, a) {            r = t(e, n, a), (r > s || r === -1 / 0 && i === -1 / 0) && (i = e, s = r)        }); return i   }, f.min = function(e, t, n) { var a, r, i = 1 / 0, s = 1 / 0; if (null == t && null != e) { e = e.length === +e.length ? e : f.values(e); for (var o = 0, c = e.length; c > o; o++) a = e[o], i > a && (i = a)       } else t = f.iteratee(t, n), f.each(e, function(e, n, a) {            r = t(e, n, a), (s > r || 1 / 0 === r && 1 / 0 === i) && (i = e, s = r)        }); return i   }, f.shuffle = function(e) { for (var t, n = e && e.length === +e.length ? e : f.values(e), a = n.length, r = Array(a), i = 0; a > i; i++) t = f.random(0, i), t !== i && (r[i] = r[t]), r[t] = n[i]; return r   }, f.sample = function(e, t, n) { return null == t || n ? (e.length !== +e.length && (e = f.values(e)), e[f.random(e.length - 1)]) : f.shuffle(e).slice(0, Math.max(0, t)) }, f.sortBy = function(e, t, n) { return t = f.iteratee(t, n), f.pluck(f.map(e, function(e, n, a) { return { value: e,               index: n,                criteria: t(e, n, a)            } }).sort(function(e, t) { var n = e.criteria, a = t.criteria; if (n !== a) { if (n > a || void 0 === n) return 1; if (a > n || void 0 === a) return -1 }           return e.index - t.index }), "value") };   var v = function(e) { return function(t, n, a) { var r = {}; return n = f.iteratee(n, a), f.each(t, function(a, i) {               var s = n(a, i, t);                e(r, a, s)            }), r        } };   f.groupBy = v(function(e, t, n) {        f.has(e, n) ? e[n].push(t) : e[n] = [t]    }), f.indexBy = v(function(e, t, n) {        e[n] = t    }), f.countBy = v(function(e, t, n) {        f.has(e, n) ? e[n]++ : e[n] = 1    }), f.sortedIndex = function(e, t, n, a) { n = f.iteratee(n, a, 1); for (var r = n(t), i = 0, s = e.length; s > i;) { var o = i + s >>> 1; r > n(e[o]) ? i = o + 1 : s = o       } return i   }, f.toArray = function(e) { return e ? f.isArray(e) ? s.call(e) : e.length === +e.length ? f.map(e, f.identity) : f.values(e) : [] }, f.size = function(e) { return null == e ? 0 : e.length === +e.length ? e.length : f.keys(e).length }, f.partition = function(e, t, n) { t = f.iteratee(t, n); var a = [], r = []; return f.each(e, function(e, n, i) {           (t(e, n, i) ? a : r).push(e)       }), [a, r]    }, f.first = f.head = f.take = function(e, t, n) { return null == e ? void 0 : null == t || n ? e[0] : 0 > t ? [] : s.call(e, 0, t)   }, f.initial = function(e, t, n) { return s.call(e, 0, Math.max(0, e.length - (null == t || n ? 1 : t))) }, f.last = function(e, t, n) { return null == e ? void 0 : null == t || n ? e[e.length - 1] : s.call(e, Math.max(e.length - t, 0)) }, f.rest = f.tail = f.drop = function(e, t, n) { return s.call(e, null == t || n ? 1 : t)   }, f.compact = function(e) { return f.filter(e, f.identity) };   var _ = function(e, t, n, a) { if (t && f.every(e, f.isArray)) return o.apply(a, e); for (var r = 0, s = e.length; s > r; r++) { var c = e[r]; f.isArray(c) || f.isArguments(c) ? t ? i.apply(a, c) : _(c, t, n, a) : n || a.push(c) }       return a    }; f.flatten = function(e, t) { return _(e, t, !1, []) }, f.without = function(e) { return f.difference(e, s.call(arguments, 1)) }, f.uniq = f.unique = function(e, t, n, a) { if (null == e) return []; f.isBoolean(t) || (a = n, n = t, t = !1), null != n && (n = f.iteratee(n, a)); for (var r = [], i = [], s = 0, o = e.length; o > s; s++) { var c = e[s]; if (t) s && i === c || r.push(c), i = c;           else if (n) { var l = n(c, s, e); 0 > f.indexOf(i, l) && (i.push(l), r.push(c)) } else 0 > f.indexOf(r, c) && r.push(c) }       return r    }, f.union = function { return f.uniq(_(arguments, !0, !0, [])) }, f.intersection = function(e) { if (null == e) return []; for (var t = [], n = arguments.length, a = 0, r = e.length; r > a; a++) { var i = e[a]; if (!f.contains(t, i)) { for (var s = 1; n > s && f.contains(arguments[s], i); s++); s === n && t.push(i) }       }        return t    }, f.difference = function(e) { var t = _(s.call(arguments, 1), !0, !0, []); return f.filter(e, function(e) {           return !f.contains(t, e)        }) }, f.zip = function(e) { if (null == e) return []; for (var t = f.max(arguments, "length").length, n = Array(t), a = 0; t > a; a++) n[a] = f.pluck(arguments, a); return n   }, f.object = function(e, t) { if (null == e) return {}; for (var n = {}, a = 0, r = e.length; r > a; a++) t ? n[e[a]] = t[a] : n[e[a][0]] = e[a][1]; return n   }, f.indexOf = function(e, t, n) { if (null == e) return -1; var a = 0, r = e.length; if (n) { if ("number" != typeof n) return a = f.sortedIndex(e, t), e[a] === t ? a : -1; a = 0 > n ? Math.max(0, r + n) : n       } for (r > a; a++) if (e[a] === t) return a;       return -1 }, f.lastIndexOf = function(e, t, n) { if (null == e) return -1; var a = e.length; for ("number" == typeof n && (a = 0 > n ? a + n + 1 : Math.min(a, n + 1)); --a >= 0;) if (e[a] === t) return a;       return -1 }, f.range = function(e, t, n) { 1 >= arguments.length && (t = e || 0, e = 0), n = n || 1; for (var a = Math.max(Math.ceil((t - e) / n), 0), r = Array(a), i = 0; a > i; i++, e += n) r[i] = e;       return r    }; var g = function {}; f.bind = function(e, t) { var n, a;       if (d && e.bind === d) return d.apply(e, s.call(arguments, 1)); if (!f.isFunction(e)) throw new TypeError("Bind must be called on a function"); return n = s.call(arguments, 2), a = function { if (!(this instanceof a)) return e.apply(t, n.concat(s.call(arguments))); g.prototype = e.prototype; var r = new g;           g.prototype = null; var i = e.apply(r, n.concat(s.call(arguments))); return f.isObject(i) ? i : r       } }, f.partial = function(e) { var t = s.call(arguments, 1); return function { for (var n = 0, a = t.slice, r = 0, i = a.length; i > r; r++) a[r] === f && (a[r] = arguments[n++]); for (arguments.length > n;) a.push(arguments[n++]); return e.apply(this, a)       } }, f.bindAll = function(e) { var t, n, a = arguments.length; if (1 >= a) throw Error("bindAll must be passed function names"); for (t = 1; a > t; t++) n = arguments[t], e[n] = f.bind(e[n], e); return e   }, f.memoize = function(e, t) { var n = function(a) { var r = n.cache, i = t ? t.apply(this, arguments) : a;           return f.has(r, i) || (r[i] = e.apply(this, arguments)), r[i] };       return n.cache = {}, n    }, f.delay = function(e, t) { var n = s.call(arguments, 2); return setTimeout(function {           return e.apply(null, n)        }, t)    }, f.defer = function(e) { return f.delay.apply(f, [e, 1].concat(s.call(arguments, 1))) }, f.throttle = function(e, t, n) { var a, r, i, s = null, o = 0; n || (n = {}); var c = function { o = n.leading === !1 ? 0 : f.now, s = null, i = e.apply(a, r), s || (a = r = null) };       return function { var l = f.now; o || n.leading !== !1 || (o = l); var u = t - (l - o); return a = this, r = arguments, 0 >= u || u > t ? (clearTimeout(s), s = null, o = l, i = e.apply(a, r), s || (a = r = null)) : s || n.trailing === !1 || (s = setTimeout(c, u)), i       } }, f.debounce = function(e, t, n) { var a, r, i, s, o, c = function { var l = f.now - s;           t > l && l > 0 ? a = setTimeout(c, t - l) : (a = null, n || (o = e.apply(i, r), a || (i = r = null))) };       return function { i = this, r = arguments, s = f.now; var l = n && !a; return a || (a = setTimeout(c, t)), l && (o = e.apply(i, r), i = r = null), o       } }, f.wrap = function(e, t) { return f.partial(t, e)   }, f.negate = function(e) { return function { return !e.apply(this, arguments) }   }, f.compose = function { var e = arguments, t = e.length - 1; return function { for (var n = t, a = e[t].apply(this, arguments); n--;) a = e[n].call(this, a); return a       } }, f.after = function(e, t) { return function { return 1 > --e ? t.apply(this, arguments) : void 0 }   }, f.before = function(e, t) { var n;       return function { return --e > 0 ? n = t.apply(this, arguments) : t = null, n       } }, f.once = f.partial(f.before, 2), f.keys = function(e) { if (!f.isObject(e)) return []; if (h) return h(e); var t = []; for (var n in e) f.has(e, n) && t.push(n); return t   }, f.values = function(e) { for (var t = f.keys(e), n = t.length, a = Array(n), r = 0; n > r; r++) a[r] = e[t[r]]; return a   }, f.pairs = function(e) { for (var t = f.keys(e), n = t.length, a = Array(n), r = 0; n > r; r++) a[r] = [t[r], e[t[r]]]; return a   }, f.invert = function(e) { for (var t = {}, n = f.keys(e), a = 0, r = n.length; r > a; a++) t[e[n[a]]] = n[a]; return t   }, f.functions = f.methods = function(e) { var t = []; for (var n in e) f.isFunction(e[n]) && t.push(n); return t.sort }, f.extend = function(e) { if (!f.isObject(e)) return e;       for (var t, n, a = 1, r = arguments.length; r > a; a++) { t = arguments[a]; for (n in t) l.call(t, n) && (e[n] = t[n]) }       return e    }, f.pick = function(e, t, n) { var a, r = {}; if (null == e) return r;       if (f.isFunction(t)) { t = p(t, n); for (a in e) { var i = e[a]; t(i, a, e) && (r[a] = i)           } } else { var c = o.apply([], s.call(arguments, 1)); e = Object(e); for (var l = 0, u = c.length; u > l; l++) a = c[l], a in e && (r[a] = e[a]) }       return r    }, f.omit = function(e, t, n) { if (f.isFunction(t)) t = f.negate(t); else { var a = f.map(o.apply([], s.call(arguments, 1)), String); t = function(e, t) { return !f.contains(a, t)           } }       return f.pick(e, t, n)    }, f.defaults = function(e) { if (!f.isObject(e)) return e;       for (var t = 1, n = arguments.length; n > t; t++) { var a = arguments[t]; for (var r in a) void 0 === e[r] && (e[r] = a[r]) }       return e    }, f.clone = function(e) { return f.isObject(e) ? f.isArray(e) ? e.slice : f.extend({}, e) : e   }, f.tap = function(e, t) { return t(e), e   }; var b = function(e, t, n, a) { if (e === t) return 0 !== e || 1 / e === 1 / t;       if (null == e || null == t) return e === t;        e instanceof f && (e = e._wrapped), t instanceof f && (t = t._wrapped); var r = c.call(e); if (r !== c.call(t)) return !1; switch (r) { case "[object RegExp]": case "[object String]": return "" + e == "" + t;           case "[object Number]": return +e !== +e ? +t !== +t : 0 === +e ? 1 / +e === 1 / t : +e === +t; case "[object Date]": case "[object Boolean]": return +e === +t }       if ("object" != typeof e || "object" != typeof t) return !1; for (var i = n.length; i--;) if (n[i] === e) return a[i] === t;       var s = e.constructor, o = t.constructor; if (s !== o && "constructor" in e && "constructor" in t && !(f.isFunction(s) && s instanceof s && f.isFunction(o) && o instanceof o)) return !1; n.push(e), a.push(t); var l, u;       if ("[object Array]" === r) { if (l = e.length, u = l === t.length) for (l-- && (u = b(e[l], t[l], n, a));); } else { var h, d = f.keys(e); if (l = d.length, u = f.keys(t).length === l)               for (l-- && (h = d[l], u = f.has(t, h) && b(e[h], t[h], n, a));); }       return n.pop, a.pop, u    }; f.isEqual = function(e, t) { return b(e, t, [], []) }, f.isEmpty = function(e) { if (null == e) return !0; if (f.isArray(e) || f.isString(e) || f.isArguments(e)) return 0 === e.length; for (var t in e)           if (f.has(e, t)) return !1; return !0 }, f.isElement = function(e) { return !(!e || 1 !== e.nodeType) }, f.isArray = u || function(e) { return "[object Array]" === c.call(e) }, f.isObject = function(e) { var t = typeof e;       return "function" === t || "object" === t && !!e }, f.each(["Arguments", "Function", "String", "Number", "Date", "RegExp"], function(e) {       f["is" + e] = function(t) {            return c.call(t) === "[object " + e + "]"        }    }), f.isArguments(arguments) || (f.isArguments = function(e) {        return f.has(e, "callee")    }), true && (f.isFunction = function(e) {        return "function" == typeof e || !1    }), f.isFinite = function(e) { return isFinite(e) && !isNaN(parseFloat(e)) }, f.isNaN = function(e) { return f.isNumber(e) && e !== +e }, f.isBoolean = function(e) { return e === !0 || e === !1 || "[object Boolean]" === c.call(e) }, f.isNull = function(e) { return null === e   }, f.isUndefined = function(e) { return void 0 === e   }, f.has = function(e, t) { return null != e && l.call(e, t)   }, f.noConflict = function { return e._ = t, this }, f.identity = function(e) { return e   }, f.constant = function(e) { return function { return e       } }, f.noop = function {}, f.property = function(e) { return function(t) { return t[e] }   }, f.matches = function(e) { var t = f.pairs(e), n = t.length; return function(e) { if (null == e) return !n; e = Object(e); for (var a = 0; n > a; a++) { var r = t[a], i = r[0]; if (r[1] !== e[i] || !(i in e)) return !1 }           return !0 }   }, f.times = function(e, t, n) { var a = Array(Math.max(0, e)); t = p(t, n, 1); for (var r = 0; e > r; r++) a[r] = t(r); return a   }, f.random = function(e, t) { return null == t && (t = e, e = 0), e + Math.floor(Math.random * (t - e + 1)) }, f.now = Date.now || function { return (new Date).getTime };   var y = { "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;",           "'": "&#x27;",            "`": "&#x60;"        },        w = f.invert(y),        x = function(e) {            var t = function(t) {                    return e[t]                },                n = "(?:" + f.keys(e).join("|") + ")",                a = RegExp(n),                r = RegExp(n, "g");            return function(e) {                return e = null == e ? "" : "" + e, a.test(e) ? e.replace(r, t) : e            }        };    f.escape = x(y), f.unescape = x(w), f.result = function(e, t) {        if (null == e) return void 0;        var n = e[t];        return f.isFunction(n) ? e[t] : n    };    var j = 0;    f.uniqueId = function(e) {        var t = ++j + "";        return e ? e + t : t    }, f.templateSettings = {        evaluate: /<%([\s\S]+?)%>/g,        interpolate: /<%=([\s\S]+?)%>/g,        escape: /<%-([\s\S]+?)%>/g    };    var R = /(.)^/, k = { "'": "'",           "\\": "\\",            "\r": "r", "\n": "n", "\u2028": "u2028", "\u2029": "u2029" },       I = /\\|'|\r|\n|\u2028|\u2029/g, T = function(e) { return "\\" + k[e] };   f.template = function(e, t, n) { !t && n && (t = n), t = f.defaults({}, t, f.templateSettings); var a = RegExp([(t.escape || R).source, (t.interpolate || R).source, (t.evaluate || R).source].join("|") + "|$", "g"), r = 0, i = "__p+='"; e.replace(a, function(t, n, a, s, o) {           return i += e.slice(r, o).replace(I, T), r = o + t.length, n ? i += "'+\n((__t=(" + n + "))==null?:_.escape(__t))+\n'" : a ? i += "'+\n((__t=(" + a + "))==null?:__t)+\n'" : s && (i += "';\n" + s + "\n__p+='"), t        }), i += "';\n", t.variable || (i = "with(obj||{}){\n" + i + "}\n"), i = "var __t,__p=,__j=Array.prototype.join,print=function{__p+=__j.call(arguments,);};\n" + i + "return __p;\n"; try { var s = Function(t.variable || "obj", "_", i)       } catch (o) { throw o.source = i, o       } var c = function(e) { return s.call(this, e, f)           }, l = t.variable || "obj"; return c.source = "function(" + l + "){\n" + i + "}", c   }, f.chain = function(e) { var t = f(e); return t._chain = !0, t   }; var F = function(e) { return this._chain ? f(e).chain : e   }; f.mixin = function(e) { f.each(f.functions(e), function(t) {           var n = f[t] = e[t];            f.prototype[t] = function {                var e = [this._wrapped];                return i.apply(e, arguments), F.call(this, n.apply(f, e))            }        }) }, f.mixin(f), f.each(["pop", "push", "reverse", "shift", "sort", "splice", "unshift"], function(e) {       var t = n[e];        f.prototype[e] = function {            var n = this._wrapped;            return t.apply(n, arguments), "shift" !== e && "splice" !== e || 0 !== n.length || delete n[0], F.call(this, n)        }    }), f.each(["concat", "join", "slice"], function(e) {        var t = n[e];        f.prototype[e] = function {            return F.call(this, t.apply(this._wrapped, arguments))        }    }), f.prototype.value = function { return this._wrapped }, "function" == typeof define && define.amd && define("underscore", [], function {       return f    }) }).call(this), this.FirechatDefaultTemplates = this.FirechatDefaultTemplates || {}, this.FirechatDefaultTemplates["templates/layout-full.html"] = function(obj) {       obj || (obj = {});        var __p = "";        with(_.escape, obj) __p += " \n \n  \n\n \nChat Rooms\n \n\n  \nCreate Room \n   \n \n\n \nVisitors\n \n\n \n \n \n \n\n \n \n \n \n \nNext \n \n Use \"+ Invite\" button within chat rooms for regular invites. \n \n \n \n \n \n \n \n\n \n \n ";        return __p    }, this.FirechatDefaultTemplates["templates/layout-popout.html"] = function(obj) {        obj || (obj = {});        var __p = "";        with(_.escape, obj) __p += " \n \n</ul>\n \n \n ";        return __p    }, this.FirechatDefaultTemplates["templates/message-context-menu.html"] = function(obj) {        obj || (obj = {});        var __p = "",            __e = _.escape;        with(Array.prototype.join, obj) __p += "<div data-toggle='firechat-contextmenu' class='contextmenu' data-message-id='" + __e(id) + "'>\n<ul>\n<li><a href='#!' data-event='firechat-user-warn'>Warn User</a></li>\n", allowKick && (__p += "\n<li><a href='#!' data-event='firechat-user-kick'>Kick User</a></li>\n"), __p += "\n<li><a href='#!' data-event='firechat-user-suspend-hour'>Suspend User (1 Hour)</a></li>\n<li><a href='#!' data-event='firechat-user-suspend-day'>Suspend User (1 Day)</a></li>\n<li><a href='#!' data-event='firechat-message-delete'>Delete Message</a></li>\n</ul>\n "; return __p }, this.FirechatDefaultTemplates["templates/message.html"] = function(obj) { obj || (obj = {}); var __t, __p = "", __e = _.escape; with(Array.prototype.join, obj) __p += "<div class='message message-" + __e(type) + " ", isSelfMessage && (__p += " message-self "), __p += "' data-message-id='" + __e(id) + "' data-user-id='" + __e(userId) + "' data-user-name='" + __e(name) + "' data-class=\"firechat-message\">\n \n<label class='fourfifth'>\n<strong class='name' title='" + __e(name) + "'>" + __e(name) + " \n (" + __e(localtime) + ") :\n ", disableActions || (__p += "\n<label class='fifth alignright'>\n<a href='#!' data-event='firechat-user-chat' class='icon user-chat' title='Invite to Private Chat'> </a>\n<a href='#!' data-event='firechat-user-mute-toggle' class='icon user-mute' title='Mute User'> </a>\n \n"), __p += " \n \n" + (null == (__t = message) ? "" : __t) + "\n \n "; return __p }, this.FirechatDefaultTemplates["templates/prompt-alert.html"] = function(obj) { obj || (obj = {}); var __p = "", __e = _.escape; with(obj) __p += " \n " + __e(message) + " \n<p class='clearfix'>\n<button type='button' class='btn quarter right close'>Close \n \n "; return __p }, this.FirechatDefaultTemplates["templates/prompt-create-room.html"] = function(obj) { obj || (obj = {}); var __p = "", __e = _.escape; with(obj) __p += " \n Give your chat room a name: \n<input data-input='firechat-room-name' type='text' placeholder='Room name...' style='margin-bottom: 5px;' maxlength='" + __e(maxLengthRoomName) + "'>\n "; return __p }, this.FirechatDefaultTemplates["templates/prompt-invitation.html"] = function(obj) { obj || (obj = {}); var __p = "", __e = _.escape; with(obj) __p += " \n " + __e(fromUserName) + " \n invited you to join \n " + __e(toRoomName) + " \n<p class='clearfix'>\n<button data-toggle='accept' type='button' class='btn'>Accept \n<button data-toggle='decline' type='button' class='btn'>Decline \n \n "; return __p }, this.FirechatDefaultTemplates["templates/prompt-invite-private.html"] = function(obj) { obj || (obj = {}); var __p = "", __e = _.escape; with(obj) __p += " \n Invite " + __e(userName) + " to " + __e(roomName) + "? \n<p class='clearfix'>\n<button data-toggle='accept' type='button' class='btn'>Invite \n<button data-toggle='decline' type='button' class='close btn'>Cancel \n \n "; return __p }, this.FirechatDefaultTemplates["templates/prompt-invite-reply.html"] = function(obj) { obj || (obj = {}); var __p = "", __e = _.escape; with(Array.prototype.join, obj) __p += " \n " + __e(toUserName) + " \n \n", __p += "accepted" === status ? " accepted your invite. " : " declined your invite. ", __p += "\n \n "; return __p }, this.FirechatDefaultTemplates["templates/prompt-user-mute.html"] = function(obj) { obj || (obj = {}); var __p = "", __e = _.escape; with(obj) __p += " \n " + __e(userName) + " \n<p class='clearfix'>\n<button data-toggle='accept' type='button' class='btn'>Mute \n<button data-toggle='decline' type='button' class='btn'>Cancel \n \n "; return __p }, this.FirechatDefaultTemplates["templates/prompt.html"] = function(obj) { obj || (obj = {}); var __t, __p = "", __e = _.escape; with(obj) __p += " \n \n" + __e(title) + "\n<a href='#!' class='close right'>X</a>\n \n \n" + (null == (__t = content) ? "" : __t) + "\n \n \n "; return __p }, this.FirechatDefaultTemplates["templates/room-list-item.html"] = function(obj) { obj || (obj = {}); var __p = "", __e = _.escape; with(Array.prototype.join, obj) __p += "<li data-room-type='" + __e(type) + "' data-room-id='" + __e(id) + "' data-room-name='" + __e(name) + "'>\n<a href='#!' class='clearfix ", isRoomOpen && (__p += " highlight "), __p += "'>\n<span class='left' title='" + __e(name) + "'>" + __e(name) + " \n</a>\n</li>"; return __p }, this.FirechatDefaultTemplates["templates/room-user-list-item.html"] = function(obj) { obj || (obj = {}); var __p = "", __e = _.escape; with(Array.prototype.join, obj) __p += "<li data-user-id='" + __e(id) + "' data-user-name='" + __e(name) + "'>\n<a href='#!' class='clearfix'>\n<span class='left twothird clipped' title='" + __e(name) + "'>" + __e(name) + " ", disableActions || (__p += "\n<span data-event='firechat-user-mute-toggle' class='icon user-mute right ", isMuted && (__p += " red "), __p += "' title='Toggle User Mute'> \n \n"), __p += "\n</a>\n</li>"; return __p }, this.FirechatDefaultTemplates["templates/room-user-search-list-item.html"] = function(obj) { obj || (obj = {}); var __p = "", __e = _.escape; with(Array.prototype.join, obj) __p += "<li data-user-id='" + __e(id) + "' data-user-name='" + __e(name) + "'>\n<a href='#!' class='clearfix'>\n", __p += disableActions ? "\n<span class='left fourfifth clipped' title='" + __e(name) + "'>" + __e(name) + " \n" : "\n<span data-event='firechat-user-invite' class='left fourfifth clipped' title='" + __e(name) + "'>" + __e(name) + " \n + \n", __p += "\n</a>\n</li>"; return __p }, this.FirechatDefaultTemplates["templates/tab-content.html"] = function(obj) { obj || (obj = {}); var __p = "", __e = _.escape; with(obj) __p += "<div id='" + __e(id) + "' data-room-id='" + __e(id) + "' class='tab-pane'>\n \n<a data-event='firechat-user-room-list-btn' class='full btn firechat-dropdown-toggle' data-toggle=\"firechat-dropdown\" href='#' data-target='firechat-room-user-list-" + __e(id) + "'>\n \nIn Room\n \n</a>\n \n<ul id='firechat-room-user-list-" + __e(id) + "' class='full'></ul>\n \n \n<a data-event='firechat-user-search-btn' class='full btn firechat-dropdown-toggle' data-toggle=\"firechat-dropdown\" href='#'>\n + \nInvite\n \n</a> \n \n \n \n<input type='text' data-event='firechat-user-search' data-template='templates/room-user-search-list-item.html' data-target='firechat-room-user-search-" + __e(id) + "' data-controls='firechat-room-user-search-controls-" + __e(id) + "' class='center fivesixth'>\n \n \n<ul id='firechat-room-user-search-" + __e(id) + "'></ul> \n<div id='firechat-room-user-search-controls-" + __e(id) + "' class='clearfix'><span class=\"quarter\"> \n\n<button type='button' class='btn half disabled' data-event='firechat-user-search' data-template='templates/room-user-search-list-item.html' data-target='firechat-room-user-search-" + __e(id) + "' data-controls='firechat-room-user-search-controls-" + __e(id) + "' data-toggle='firechat-pagination-next'  disabled=disabled>Next \n \n \n \n <a href='#!' data-event='firechat-close-tab' class='icon close right' style='15px 5px' title='Leave Room'></a> \n<div id='firechat-messages" + __e(id) + "' class='chat'> \n \n Your message: \n<textarea id='textarea" + __e(id) + "' placeholder='Type your message here...'> \n \n "; return __p }, this.FirechatDefaultTemplates["templates/tab-menu-item.html"] = function(obj) { obj || (obj = {}); var __p = "", __e = _.escape; with(obj) __p += "<li data-room-id='" + __e(id) + "'>\n<a href='#" + __e(id) + "' data-toggle='firechat-tab' title='" + __e(name) + "'>" + __e(name) + "</a>\n</li>"; return __p }, this.FirechatDefaultTemplates["templates/user-search-list-item.html"] = function(obj) { obj || (obj = {}); var __p = "", __e = _.escape; with(Array.prototype.join, obj) __p += "<li data-user-id='" + __e(id) + "' data-user-name='" + __e(name) + "'>\n<a href='#!' class='clearfix'>\n", __p += disableActions ? "\n<span class='left fivesixth clipped' title='" + __e(name) + "'>" + __e(name) + " \n" : "\n<span data-event='firechat-user-chat' class='left fivesixth clipped' title='" + __e(name) + "'>" + __e(name) + " \n \n", __p += "\n</a>\n</li>"; return __p },   function { Function.prototype.bind || (Function.prototype.bind = function(e) {           if ("function" != typeof this) throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");            var t = Array.prototype.slice.call(arguments, 1),                n = this,                a = function {},                r = function {                    return n.apply(this instanceof a && e ? this : e, t.concat(Array.prototype.slice.call(arguments)))               };            return a.prototype = this.prototype, r.prototype = new a, r        }), Object.keys = Object.keys || function(e) { var t = []; for (var n in e) e.hasOwnProperty(n) && t.push(n); return t       } },   function(e) { function t(e, t) { this._firebase = e, this._user = null, this._userId = null, this._userName = null, this._isModerator = !1, this._sessionId = null, this._events = {}, this._rooms = {}, this._presenceBits = {}, this._userRef = null, this._messageRef = this._firebase.child("room-messages"), this._roomRef = this._firebase.child("room-metadata"), this._privateRoomRef = this._firebase.child("room-private-metadata"), this._moderatorsRef = this._firebase.child("moderators"), this._suspensionsRef = this._firebase.child("suspensions"), this._usersOnlineRef = this._firebase.child("user-names-online"), this._options = t || {}, this._options.numMaxMessages = this._options.numMaxMessages || 50 }       var n = this, a = n.Firechat; t.noConflict = function { return n.Firechat = a, t       }, n.Firechat = t, t.prototype = { _loadUserMetadata: function(e) { var t = this; this._userRef.transaction(function(e) {                   return e && e.id && e.name ? void 0 : {                        id: t._userId,                        name: t._userName                    }                }, function(a, r, i) {                    t._user = i.val, t._moderatorsRef.child(t._userId).once("value", function(a) { t._isModerator = !!a.val, n.setTimeout(e, 0) })               })            },            _setupDataEvents: function { this._firebase.root.child(".info/connected").on("value", function(e) {                   if (e.val === !0)                        for (var t = 0; this._presenceBits > t; t++) {                            var n = this._presenceBits[t],                                a = this._firebase.root.child(n.ref);                            a.onDisconnect.set(n.offlineValue), a.set(n.onlineValue)                        }                }, this); var e = this._userRef.child("sessions").push; this._sessionId = e.key, this._queuePresenceOperation(e, !0, null); var t = this._usersOnlineRef.child(this._userName.toLowerCase), n = t.child(this._sessionId); this._queuePresenceOperation(n, {                   id: this._userId,                    name: this._userName                }, null), this._userRef.on("value", this._onUpdateUser, this), this._userRef.child("invites").on("child_added", this._onFirechatInvite, this), this._userRef.child("notifications").on("child_added", this._onNotification, this) },           _addEventCallback: function(e, t) { this._events[e] = this._events[e] || [], this._events[e].push(t) },           _getEventCallbacks: function(e) { return this._events.hasOwnProperty(e) ? this._events[e] : [] },           _invokeEventCallbacks: function(e) { var t = [], n = this._getEventCallbacks(e); Array.prototype.push.apply(t, arguments), t = t.slice(1); for (var a = 0; n.length > a; a += 1) n[a].apply(null, t)           }, _queuePresenceOperation: function(e, t, n) { e.onDisconnect.set(n), e.set(t), this._presenceBits["" + e] = { ref: e,                   onlineValue: t,                    offlineValue: n                } },           _removePresenceOperation: function(t, n) { var a = new e(t); a.onDisconnect.cancel, a.set(n), delete this._presenceBits[t] },           _onUpdateUser: function(e) { this._user = e.val, this._invokeEventCallbacks("user-update", this._user) },           _onAuthRequired: function { this._invokeEventCallbacks("auth-required") },           _onEnterRoom: function(e) { this._invokeEventCallbacks("room-enter", e)           }, _onNewMessage: function(e, t) { var n = t.val; n.id = t.key, this._invokeEventCallbacks("message-add", e, n)           }, _onRemoveMessage: function(e, t) { var n = t.key; this._invokeEventCallbacks("message-remove", e, n)           }, _onLeaveRoom: function(e) { this._invokeEventCallbacks("room-exit", e)           }, _onNotification: function(e) { var t = e.val; t.read || (("suspension" !== t.notificationType || t.data.suspendedUntil < (new Date).getTime) && e.ref.child("read").set(!0), this._invokeEventCallbacks("notification", t)) },           _onFirechatInvite: function(e) { var t = this, n = e.val; n.status || (n.id = n.id || e.key, t.getRoom(n.roomId, function(e) { n.toRoomName = e.name, t._invokeEventCallbacks("room-invite", n)               })) },           _onFirechatInviteResponse: function(e) { var t = e.val; t.id = t.id || e.key, this._invokeEventCallbacks("room-invite-response", t)           } }, t.prototype.setUser = function(e, t, a) { var r = this; r._firebase.onAuth(function(i) {               i ? (r._userId = "" + e, r._userName = "" + t, r._userRef = r._firebase.child("users").child(r._userId), r._loadUserMetadata(function {                    n.setTimeout(function { a(r._user), r._setupDataEvents }, 0)               })) : r.warn("Firechat requires an authenticated Firebase reference. Pass an authenticated reference before loading.")            }) }, t.prototype.resumeSession = function { this._userRef.child("rooms").once("value", function(e) {               var t = e.val;                for (var n in t) this.enterRoom(t[n].id)            }, function {}, this) }, t.prototype.on = function(e, t) { this._addEventCallback(e, t)       }, t.prototype.createRoom = function(t, n, a) { var r = this, i = this._roomRef.push, s = { id: i.key, name: t,                   type: n || "public", createdByUserId: this._userId, createdAt: e.ServerValue.TIMESTAMP };           "private" === n && (s.authorizedUsers = {}, s.authorizedUsers[this._userId] = !0), i.set(s, function(e) {                e || r.enterRoom(i.key), a && a(i.key)            }) }, t.prototype.enterRoom = function(e) { var t = this; t.getRoom(e, function(n) {               var a = n.name;                if (e && a && !t._rooms[e]) {                    if (t._rooms[e] = !0, t._user) {                        t._userRef.child("rooms").child(e).set({ id: e,                           name: a,                            active: !0 });                       var r = t._firebase.child("room-users").child(e).child(t._userId).child(t._sessionId);                        t._queuePresenceOperation(r, { id: t._userId, name: t._userName }, null)                   }                    t._onEnterRoom({ id: e,                       name: a                    }), t._roomRef.child(e).once("value", function { t._messageRef.child(e).limitToLast(t._options.numMaxMessages).on("child_added", function(n) {                           t._onNewMessage(e, n)                        }, function {                            t.leaveRoom(e)                        }, t), t._messageRef.child(e).limitToLast(t._options.numMaxMessages).on("child_removed", function(n) {                            t._onRemoveMessage(e, n)                        }, function {}, t)                    }, function {}, t)                }            }) }, t.prototype.leaveRoom = function(e) { var t = this, n = t._firebase.child("room-users").child(e); if (t._messageRef.child(e).off, t._user) { var a = n.child(t._userId).child(t._sessionId); t._removePresenceOperation("" + a, null), t._userRef.child("rooms").child(e).remove }           delete t._rooms[e], t._onLeaveRoom(e) }, t.prototype.sendMessage = function(t, n, a, r) { var i, s = this, o = { userId: s._userId, name: s._userName, timestamp: e.ServerValue.TIMESTAMP, message: n,                   type: a || "default" };           return s._user ? (i = s._messageRef.child(t).push, i.setWithPriority(o, e.ServerValue.TIMESTAMP, r), void 0) : (s._onAuthRequired, r && r(Error("Not authenticated or user not set!")), void 0) }, t.prototype.deleteMessage = function(e, t, n) { var a = this; a._messageRef.child(e).child(t).remove(n) }, t.prototype.toggleUserMute = function(e, t) { var n = this; return n._user ? (n._userRef.child("muted").child(e).transaction(function(e) { return e ? null : !0 }, t), void 0) : (n._onAuthRequired, t && t(Error("Not authenticated or user not set!")), void 0) }, t.prototype.sendSuperuserNotification = function(t, n, a, r) { var i = this, s = i._firebase.child("users").child(t).child("notifications"); s.push({               fromUserId: i._userId,                timestamp: e.ServerValue.TIMESTAMP,                notificationType: n,                data: a || {}            }, r)        }, t.prototype.warnUser = function(e) { var t = this; t.sendSuperuserNotification(e, "warning") }, t.prototype.suspendUser = function(e, t, n) { var a = this, r = (new Date).getTime + 1e3 * t;           a._suspensionsRef.child(e).set(r, function(t) {                return t && n ? n(t) : (a.sendSuperuserNotification(e, "suspension", {                    suspendedUntil: r                }), n(null))            }) }, t.prototype.inviteUser = function(e, t) { var n = this, a = function { var a = n._firebase.child("users").child(e).child("invites").push; a.set({                       id: a.key,                        fromUserId: n._userId,                        fromUserName: n._userName,                        roomId: t                    }), a.on("value", n._onFirechatInviteResponse, function {}, n)                }; return n._user ? (n.getRoom(t, function(r) { if ("private" === r.type) { var i = n._roomRef.child(t).child("authorizedUsers"); i.child(e).set(!0, function(e) {                       e || a                    }) } else a }), void 0) : (n._onAuthRequired, void 0) }, t.prototype.acceptInvite = function(e, t) { var n = this; n._userRef.child("invites").child(e).once("value", function(a) {               var r = a.val;                return null === r && t ? t(Error("acceptInvite(" + e + "): invalid invite id")) : (n.enterRoom(r.roomId), n._userRef.child("invites").child(e).update({                    status: "accepted",                    toUserName: n._userName                }, t), void 0)            }, n)        }, t.prototype.declineInvite = function(e, t) { var n = this, a = { status: "declined", toUserName: n._userName };           n._userRef.child("invites").child(e).update(a, t)        }, t.prototype.getRoomList = function(e) { var t = this; t._roomRef.once("value", function(t) {               e(t.val)            }) }, t.prototype.getUsersByRoom = function { var e = this, t = arguments[0], a = e._firebase.child("room-users").child(t), r = arguments[arguments.length - 1], i = null; arguments.length > 2 && (i = arguments[1]), a = i ? a.limitToLast(i) : a, a.once("value", function(e) {               var t = e.val || {},                    a = {};                for (var i in t)                    for (var s in t[i]) {                        a[i] = t[i][s];                        break                    }                n.setTimeout(function { r(a) }, 0)           })        }, t.prototype.getUsersByPrefix = function(e, t, a, r, i) { var s = this._usersOnlineRef, o = e.toLowerCase; s = t ? s.startAt(null, t) : a ? s.endAt(null, a) : o ? s.startAt(null, o) : s.startAt, s = r ? s.limitToLast(r) : s, s.once("value", function(t) {               var a = t.val || {},                    r = {};                for (var s in a) {                    var c, l, u = a[s];                    for (var h in u) {                        c = u[h].name, l = u[h].id;                        break                    }                    e.length > 0 && 0 !== c.toLowerCase.indexOf(o) || (r[c] = { name: c,                       id: l                    })                }                n.setTimeout(function { i(r) }, 0)           })        }, t.prototype.getRoom = function(e, t) { this._roomRef.child(e).once("value", function(e) {               t(e.val)            }) }, t.prototype.userIsModerator = function { return this._isModerator }, t.prototype.warn = function(e) { console && (e = "Firechat Warning: " + e, "function" == typeof console.warn ? console.warn(e) : "function" == typeof console.log && console.log(e)) }   }(Firebase), function(e) { function t(t, n, a) { if (!t) throw Error("FirechatUI: Missing required argument `firebaseRef`"); if (!n) throw Error("FirechatUI: Missing required argument `el`"); a = a || {}, this._options = a, this._el = n, this._user = null, this._chat = new Firechat(t, a), this._roomQueue = [], this.maxLengthUsername = 15, this.maxLengthUsernameDisplay = 15, this.maxLengthRoomName = 24, this.maxLengthMessage = 120, this.maxUserSearchResults = 100, this.urlPattern = /\b(?:https?|ftp):\/\/[a-z0-9-+&@#\/%?=~_|!:,.;]*[a-z0-9-+&@#\/%=~_|]/gim, this.pseudoUrlPattern = /(^|[^\/])(www\.[\S]+(\b|$))/gim, this._renderLayout, this.$wrapper = e("#firechat"), this.$roomList = e("#firechat-room-list"), this.$tabList = e("#firechat-tab-list"), this.$tabContent = e("#firechat-tab-content"), this.$messages = {}, this.$rateLimit = { limitCount: 10, limitInterval: 1e4, limitWaitTime: 3e4, history: {} }, this._bindUIEvents, this._bindDataEvents }       if (!e || 170 > parseInt(e.jquery.replace(/\./g, ""), 10)) throw Error("jQuery 1.7 or later required!"); var n = this, a = n.FirechatUI; if (n.FirechatUI = t, !self.FirechatDefaultTemplates) throw Error("Unable to find chat templates!"); t.noConflict = function { return n.FirechatUI = a, t       }, t.prototype = { _bindUIEvents: function { this._bindForHeightChange, this._bindForTabControls, this._bindForRoomList, this._bindForUserRoomList, this._bindForUserSearch, this._bindForUserMuting, this._bindForChatInvites, this._bindForRoomListing, this._setupTabs, this._setupDropdowns, this._bindTextInputFieldLimits },           _bindDataEvents: function { this._chat.on("user-update", this._onUpdateUser.bind(this)), this._chat.on("room-enter", this._onEnterRoom.bind(this)), this._chat.on("room-exit", this._onLeaveRoom.bind(this)), this._chat.on("message-add", this._onNewMessage.bind(this)), this._chat.on("message-remove", this._onRemoveMessage.bind(this)), this._chat.on("room-invite", this._onChatInvite.bind(this)), this._chat.on("room-invite-response", this._onChatInviteResponse.bind(this)), this._chat.on("notification", this._onNotification.bind(this)) },           _renderLayout: function { var t = FirechatDefaultTemplates["templates/layout-full.html"]; e(this._el).html(t({ maxLengthUsername: this.maxLengthUsername }))           },            _onUpdateUser: function(t) { this._user = t;               var n = this._user.muted || {}; e('[data-event="firechat-user-mute-toggle"]').each(function {                   var t = e(this).closest("[data-user-id]").data("user-id");                    e(this).toggleClass("red", !!n[t])                }); for (var a in n) e('.message[data-user-id="' + a + '"]').fadeOut },           _onEnterRoom: function(e) { this.attachTab(e.id, e.name) },           _onLeaveRoom: function(e) { this.removeTab(e), this._roomQueue.length > 0 && this._chat.enterRoom(this._roomQueue.shift(e)) },           _onNewMessage: function(e, t) { var n = t.userId; this._user && this._user.muted && this._user.muted[n] || this.showMessage(e, t)           }, _onRemoveMessage: function(e, t) { this.removeMessage(e, t)           }, _onChatInvite: function(e) { var t = this, n = FirechatDefaultTemplates["templates/prompt-invitation.html"], a = this.prompt("Invite", n(e)); a.find("a.close").click(function {                   return a.remove, t._chat.declineInvite(e.id), !1                }), a.find("[data-toggle=accept]").click(function {                    return a.remove, t._chat.acceptInvite(e.id), !1                }), a.find("[data-toggle=decline]").click(function {                    return a.remove, t._chat.declineInvite(e.id), !1                }) },           _onChatInviteResponse: function(e) { if (e.status) { var t, n = this, a = FirechatDefaultTemplates["templates/prompt-invite-reply.html"]; e.status && "accepted" === e.status ? (t = this.prompt("Accepted", a(e)), this._chat.getRoom(e.roomId, function(t) { n.attachTab(e.roomId, t.name) })) : t = this.prompt("Declined", a(e)), t.find("a.close").click(function {                       return t.remove, !1                    }) }           },            _onNotification: function(e) { if ("warning" === e.notificationType) this.renderAlertPrompt("Warning", "You are being warned for inappropriate messaging. Further violation may result in temporary or permanent ban of service."); else if ("suspension" === e.notificationType) { var t = e.data.suspendedUntil, n = Math.round((t - (new Date).getTime) / 1e3), a = ""; if (n > 0) { if (n > 7200) { var r = Math.floor(n / 3600); a = r + " hours, ", n -= 3600 * r                       } a += Math.floor(n / 60) + " minutes", this.renderAlertPrompt("Suspended", "A moderator has suspended you for violating site rules. You cannot send messages for another " + a + ".") }               }            }        }, t.prototype.setUser = function(e, t) { var n = this; n._chat.setUser(e, t, function(e) {               n._user = e, n._chat.userIsModerator && n._bindSuperuserUIEvents, n._chat.resumeSession            }) }, t.prototype.on = function(e, t) { this._chat.on(e, t)       }, t.prototype._bindSuperuserUIEvents = function { var t = this, n = function { var t = e(this), n = t.closest("[data-message-id]").data("message-id"), a = e('[data-message-id="' + n + '"]').closest("[data-user-id]").data("user-id"), r = e('[data-message-id="' + n + '"]').closest("[data-room-id]").data("room-id"); return { messageId: n,                       userId: a,                        roomId: r                    } },               a = function { e('[data-toggle="firechat-contextmenu"]').each(function {                       e(this).remove                    }), e("#firechat .message.highlighted").each(function {                        e(this).removeClass("highlighted")                    }) },               r = function(r) { var i, s = e(this), o = s.closest("[data-message-id]"), c = FirechatDefaultTemplates["templates/message-context-menu.html"], l = n.call(this, r); r.preventDefault, a, s.addClass("highlighted"), t._chat.getRoom(l.roomId, function {                       i = e(c({                            id: o.data("message-id")                        })), i.css({ left: r.clientX, top: r.clientY }).appendTo(t.$wrapper)                   }) };           e(document).bind("click", {                self: this            }, function(e) {                e.button && 2 == e.button || a            }), e(document).delegate('[data-class="firechat-message"]', "contextmenu", r), e(document).delegate('[data-event="firechat-user-warn"]', "click", function(e) {                var a = n.call(this, e);                t._chat.warnUser(a.userId)            }), e(document).delegate('[data-event="firechat-user-suspend-hour"]', "click", function(e) {                var a = n.call(this, e);                t._chat.suspendUser(a.userId, 3600)            }), e(document).delegate('[data-event="firechat-user-suspend-day"]', "click", function(e) {                var a = n.call(this, e);                t._chat.suspendUser(a.userId, 86400)            }), e(document).delegate('[data-event="firechat-message-delete"]', "click", function(e) { var a = n.call(this, e); t._chat.deleteMessage(a.roomId, a.messageId) })       }, t.prototype._bindForHeightChange = function {            var t = e(this._el),                n = null;            setInterval(function { var a = t.height; a != n && (n = a, e(".chat").each(function {})) }, 500)       }, t.prototype._bindForTabControls = function {            var t = this;            e(document).delegate('[data-event="firechat-close-tab"]', "click", function { var n = e(this).closest("[data-room-id]").data("room-id"); return t._chat.leaveRoom(n), !1 })       }, t.prototype._bindForRoomList = function {            var t = this;            e("#firechat-btn-rooms").bind("click", function { if (!e(this).parent.hasClass("open")) { var n = (e(this), FirechatDefaultTemplates["templates/room-list-item.html"]), a = function { var n = e(this).parent, a = n.data("room-id"), r = n.data("room-name"); return t.$messages[a] ? t.focusTab(a) : t._chat.enterRoom(a, r), !1 };                   t._chat.getRoomList(function(r) {                        t.$roomList.empty;                        for (var i in r) {                            var s = r[i];                            if ("public" == s.type) {                                s.isRoomOpen = !!t.$messages[s.id];                                var o = e(n(s));                                o.children("a").bind("click", a), t.$roomList.append(o.toggle(!0))                            }                        }                    }) }           })        }, t.prototype._bindForUserRoomList = function {            var t = this;            e(document).delegate('[data-event="firechat-user-room-list-btn"]', "click", function(n) { n.stopPropagation; var a = e(this), r = a.closest("[data-room-id]").data("room-id"), i = FirechatDefaultTemplates["templates/room-user-list-item.html"], s = a.data("target"), o = e("#" + s); o.empty, t._chat.getUsersByRoom(r, function(n) {                   for (var a in n) user = n[a], user.disableActions = !t._user || user.id === t._user.id, user.nameTrimmed = t.trimWithEllipsis(user.name, t.maxLengthUsernameDisplay), user.isMuted = t._user && t._user.muted && t._user.muted[user.id], o.append(e(i(user)));                    t.sortListLexicographically("#" + s)                }) })       }, t.prototype._bindForUserSearch = function {            var t = this,                n = function(t) {                    var n = e(this),                        r = n.data("target"),                        i = n.data("controls"),                        s = n.data("template"),                        o = n.val || n.data("prefix") || "",                        c = n.data("startAt") || null,                        l = n.data("endAt") || null;                    t.preventDefault, a(r, s, i, o, c, l)                },                a = function(n, a, r, i, s, o) {                    var c = e("#" + n),                        l = e("#" + r),                        u = FirechatDefaultTemplates[a];                    t._chat.getUsersByPrefix(i, s, o, t.maxUserSearchResults, function(e) { var n, a, r, s, o, h = 0; c.empty; for (r in e) { var d = e[r]; if (d.disableActions = !t._user || d.id === t._user.id, h += 1, c.append(u(d)), 1 === h) s = d.name.toLowerCase; else if (h >= t.maxUserSearchResults) { o = d.name.toLowerCase; break }                       }                        l && (n = l.find('[data-toggle="firechat-pagination-prev"]'), a = l.find('[data-toggle="firechat-pagination-next"]'), o ? a.data("event", "firechat-user-search").data("startAt", o).data("prefix", i).removeClass("disabled").prop("disabled", false) : a.data("event", null).data("startAt", null).data("prefix", null).addClass("disabled").attr("disabled", "disabled")) })               };            e(document).delegate('[data-event="firechat-user-search"]', "keyup", n), e(document).delegate('[data-event="firechat-user-search"]', "click", n), e(document).delegate('[data-event="firechat-user-search-btn"]', "click", function(t) { t.stopPropagation; var n = e(this).next("div.firechat-dropdown-menu").find("input"); n.focus, n.trigger(jQuery.Event("keyup")) }), e(document).delegate('[data-event="firechat-user-search"]', "click", function(e) { e.stopPropagation })       }, t.prototype._bindForUserMuting = function {            var t = this;            e(document).delegate('[data-event="firechat-user-mute-toggle"]', "click", function(n) { var a = e(this), r = a.closest("[data-user-id]").data("user-id"), i = a.closest("[data-user-name]").data("user-name"), s = a.hasClass("red"), o = FirechatDefaultTemplates["templates/prompt-user-mute.html"]; if (n.preventDefault, s) t._chat.toggleUserMute(r); else { var c = t.prompt("Mute User?", o({ userName: i                   })); c.find("a.close").first.click(function {                       return c.remove, !1                    }), c.find("[data-toggle=decline]").first.click(function {                        return c.remove, !1                    }), c.find("[data-toggle=accept]").first.click(function {                        return t._chat.toggleUserMute(r), c.remove, !1                    }) }           })        }, t.prototype._bindForChatInvites = function {            var t = this,                n = function {                    var n, a = e(this),                        r = a.closest("[data-user-id]").data("user-id"),                        i = a.closest("[data-room-id]").data("room-id"),                        s = a.closest("[data-user-name]").data("user-name"),                        o = FirechatDefaultTemplates["templates/prompt-invite-private.html"];                    return t._chat.getRoom(i, function(e) { return n = t.prompt("Invite", o({ userName: s,                           roomName: e.name })), n.find("a.close").click(function {                           return n.remove, !1                        }), n.find("[data-toggle=decline]").click(function {                            return n.remove, !1                        }), n.find("[data-toggle=accept]").first.click(function {                            return n.remove, t._chat.inviteUser(r, i, e.name), !1                        }), !1 }), !1               },                a = function {                    var n, a = e(this),                        r = a.closest("[data-user-id]").data("user-id"),                        i = a.closest("[data-user-name]").data("user-name"),                        s = FirechatDefaultTemplates["templates/prompt-invite-private.html"];                    return r && i && (n = t.prompt("Private Invite", s({ userName: i,                       roomName: "Private Chat" })), n.find("a.close").click(function {                       return n.remove, !1                    }), n.find("[data-toggle=decline]").click(function {                        return n.remove, !1                    }), n.find("[data-toggle=accept]").first.click(function {                        n.remove;                        var e = "Private Chat";                        return t._chat.createRoom(e, "private", function(n) { t._chat.inviteUser(r, n, e)                       }), !1                    })), !1                };            e(document).delegate('[data-event="firechat-user-chat"]', "click", a), e(document).delegate('[data-event="firechat-user-invite"]', "click", n)        }, t.prototype._bindForRoomListing = function {            var t = this,                n = e("#firechat-btn-create-room-prompt"),                a = e("#firechat-btn-create-room");            n.bind("click", function { return t.promptCreateRoom, !1 }), a.bind("click", function { var n = e("#firechat-input-room-name").val; return e("#firechat-prompt-create-room").remove, t._chat.createRoom(n), !1 })       }, t.prototype._setupTabs = function {            var t = function(t) {                    var a, r, i = t,                        s = i.closest("ul:not(.firechat-dropdown-menu)"),                        o = i.attr("data-target"),                        c = s.find(".active:last a")[0];                    o || (o = i.attr("href"), o = o && o.replace(/.*(?=#[^\s]*$)/, "")), i.parent("li").hasClass("active") || (r = e.Event("show", {                        relatedTarget: c                    }), i.trigger(r), r.isDefaultPrevented || (a = e(o), n(i.parent("li"), s), n(a, a.parent, function { i.trigger({                           type: "shown",                            relatedTarget: c                        }) })))               },                n = function(t, n, a) {                    function r {                        i.removeClass("active").find("> .firechat-dropdown-menu > .active").removeClass("active"), t.addClass("active"), s ? t.addClass("in") : t.removeClass("fade"), t.parent(".firechat-dropdown-menu") && t.closest("li.firechat-dropdown").addClass("active"), a && a                    }                    var i = n.find("> .active"),                        s = a && e.support.transition && i.hasClass("fade");                    s ? i.one(e.support.transition.end, r) : r, i.removeClass("in")                };            e(document).delegate('[data-toggle="firechat-tab"]', "click", function(n) { n.preventDefault, t(e(this)) })       }, t.prototype._setupDropdowns = function {            var t = function {                    var t = e(this),                        r = a(t),                        i = r.hasClass("open");                    if (!t.is(".disabled, :disabled")) return n, i || r.toggleClass("open"), t.focus, !1                },                n = function {                    e("[data-toggle=firechat-dropdown]").each(function { a(e(this)).removeClass("open") })               },                a = function(t) {                    var n, a = t.attr("data-target");                    return a || (a = t.attr("href"), a = a && /#/.test(a) && a.replace(/.*(?=#[^\s]*$)/, "")), n = a && e(a), n && n.length || (n = t.parent), n                };            e(document).bind("click", n).delegate(".firechat-dropdown-menu", "click", function(e) { e.stopPropagation }).delegate("[data-toggle=firechat-dropdown]", "click", t)       }, t.prototype._bindTextInputFieldLimits = function {            e("body").delegate('input[data-provide="limit"], textarea[data-provide="limit"]', "keyup", function { var t = e(this), n = e(t.data("counter")), a = t.attr("maxlength"), r = t.val.length; n.html(Math.max(0, a - r)) })       }, t.prototype.renderAlertPrompt = function(e, t) {            var n = FirechatDefaultTemplates["templates/prompt-alert.html"],                a = this.prompt(e, n({                    message: t                }));            a.find(".close").click(function { return a.remove, !1 })       }, t.prototype.toggleInputs = function(t) {            e("#firechat-tab-content textarea").each(function { var n = e(this); t ? e(this).val("") : e(this).val("You have exceeded the message limit, please wait before sending."), n.prop("disabled", !t) }), e("#firechat-input-name").prop("disabled", !t)       }, t.prototype.attachTab = function(t, n) {            var a = this;            if (this.$messages[t]) return this.focusTab(t), void 0;            var r = {                    id: t,                    name: n                },                i = FirechatDefaultTemplates["templates/tab-content.html"],                s = e(i(r));            this.$tabContent.prepend(s);            var o = e("#firechat-messages" + t);            this.$messages[t] = o;            var c = s.find("textarea").first;            c.bind("keydown", function(e) { var n = a.trimWithEllipsis(c.val, a.maxLengthMessage); return 13 === e.which && "" !== n ? (c.val(""), a._chat.sendMessage(t, n), !1) : void 0 });           var l = FirechatDefaultTemplates["templates/tab-menu-item.html"],                u = e(l(r));            this.$tabList.prepend(u), u.bind("shown", function { o.scrollTop(o[0].scrollHeight) });           var h = this.$tabList.children("li"),                d = Math.floor(e("#firechat-tab-list").width / h.length);            this.$tabList.children("li").css("width", d), this.$roomList.children("[data-room-id=" + t + "]").children("a").addClass("highlight"), e("#firechat-btn-room-user-list-" + t).bind("click", function { return a.sortListLexicographically("#firechat-room-user-list-" + t), !1 }), this.focusTab(t)       }, t.prototype.focusTab = function(e) {            if (this.$messages[e]) {                var t = this.$tabList.find("[data-room-id=" + e + "]").find("a");                t.length && t.first.trigger("click")            }        }, t.prototype.removeTab = function(t) {            delete this.$messages[t], this.$tabContent.find("[data-room-id=" + t + "]").remove, this.$tabList.find("[data-room-id=" + t + "]").remove;            var n = this.$tabList.children("li"),                a = Math.floor(e("#firechat-tab-list").width / n.length);            this.$tabList.children("li").css("width", a), this.$tabList.find('[data-toggle="firechat-tab"]').first.trigger("click"), this.$roomList.children("[data-room-id=" + t + "]").children("a").removeClass("highlight")        }, t.prototype.showMessage = function(t, n) {            var a = this,                r = { id: n.id, localtime: a.formatTime(n.timestamp), message: n.message || "", userId: n.userId, name: n.name, type: n.type || "default", isSelfMessage: a._user && n.userId == a._user.id, disableActions: !a._user || n.userId == a._user.id               }; r.message = _.map(r.message.split(" "), function(e) {               return a.urlPattern.test(e) || a.pseudoUrlPattern.test(e) ? a.linkify(encodeURI(e)) : _.escape(e)            }).join(" "), r.message = a.trimWithEllipsis(r.message, a.maxLengthMessage); var i = FirechatDefaultTemplates["templates/message.html"], s = e(i(r)), o = a.$messages[t]; if (o) { var c = !1; o.scrollTop / (o[0].scrollHeight - o[0].offsetHeight) >= .95 ? c = !0 : o[0].scrollHeight <= o.height && (c = !0), o.append(s), c && o.scrollTop(o[0].scrollHeight) }       }, t.prototype.removeMessage = function(t, n) { e('.message[data-message-id="' + n + '"]').remove }, t.prototype.sortListLexicographically = function(t) { e(t).children("li").sort(function(t, n) {               var a = e(t).text.toUpperCase,                    r = e(n).text.toUpperCase;                return r > a ? -1 : a > r ? 1 : 0            }).appendTo(t) }, t.prototype.trimWithEllipsis = function(e, t) { return e = e.replace(/^\s\s*/, "").replace(/\s\s*$/, ""), t && t >= e.length ? e : e.substring(0, t) + "..." }, t.prototype.formatTime = function(e) { var t = e ? new Date(e) : new Date, n = t.getHours || 12, a = "" + t.getMinutes, r = t.getHours >= 12 ? "pm" : "am"; return n = n > 12 ? n - 12 : n, a = 2 > a.length ? "0" + a : a, "" + n + ":" + a + r       }, t.prototype.promptCreateRoom = function { var e = this, t = FirechatDefaultTemplates["templates/prompt-create-room.html"], n = this.prompt("Create Public Room", t({ maxLengthRoomName: this.maxLengthRoomName, isModerator: e._chat.userIsModerator }));           n.find("a.close").first.click(function {                return n.remove, !1            }), n.find("[data-toggle=submit]").first.click(function {                var t = n.find("[data-input=firechat-room-name]").first.val;                return "" !== t && (e._chat.createRoom(t, "public"), n.remove), !1            }), n.find("[data-input=firechat-room-name]").first.focus, n.find("[data-input=firechat-room-name]").first.bind("keydown", function(t) {                if (13 === t.which) {                    var a = n.find("[data-input=firechat-room-name]").first.val;                    if ("" !== a) return e._chat.createRoom(a, "public"), n.remove, !1                }            }) }, t.prototype.prompt = function(t, n) { var a, r = FirechatDefaultTemplates["templates/prompt.html"]; return a = e(r({ title: t,               content: n            })).css({                top: this.$wrapper.position.top + .333 * this.$wrapper.height,                left: this.$wrapper.position.left + .125 * this.$wrapper.width,                width: .75 * this.$wrapper.width            }), this.$wrapper.append(a.removeClass("hidden")), a        }, t.prototype.linkify = function(e) { var t = this; return e.replace(t.urlPattern, '<a target="_blank" href="$&">$&</a>').replace(t.pseudoUrlPattern, '$1<a target="_blank" href="http://$2">$2</a>') }   }(jQuery);