var __values = (this && this.__values) || function(o) { var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; if (m) return m.call(o); if (o && typeof o.length === "number") return { next: function () { if (o && i >= o.length) o = void 0; return { value: o && o[i++], done: !o }; } }; throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); }; if (typeof Function !== "undefined") { Function.prototype.getArgumentNames = function () { var code = this.toString(); var args = code .slice(code.indexOf("(") + 1, code.indexOf(")")) .match(/([^\s,]+)/g); return args || []; }; } if (typeof Array !== "undefined") { Array.prototype.last = function () { return this[this.length - 1]; }; Array.prototype.sortBy = function (project) { return this.sort(function (a, b) { var a1 = project(a); var b1 = project(b); if (a1 < b1) return -1; if (a1 > b1) return 1; return 0; }); }; Array.prototype.distinct = function (project) { var e_1, _a; if (!project) project = function (item) { return item; }; var result = []; var map = new Map(); try { for (var _b = __values(this), _c = _b.next(); !_c.done; _c = _b.next()) { var item = _c.value; var key = project ? project(item) : item; if (!map.has(key)) { map.set(key, true); result.push(item); } } } catch (e_1_1) { e_1 = { error: e_1_1 }; } finally { try { if (_c && !_c.done && (_a = _b.return)) _a.call(_b); } finally { if (e_1) throw e_1.error; } } return result; }; Array.prototype.stringify = function () { return JSON.stringify(this); }; } var util = { date: { timeAgo: function (ts) { if (typeof ts !== "number") ts = ts.valueOf(); var seconds = Math.floor((new Date().valueOf() - ts) / 1000); var interval = Math.floor(seconds / 31536000); if (interval > 1) return "".concat(interval, " years"); interval = Math.floor(seconds / 2592000); if (interval > 1) return "".concat(interval, " months"); interval = Math.floor(seconds / 86400); if (interval > 1) return "".concat(interval, " days"); interval = Math.floor(seconds / 3600); if (interval > 1) return "".concat(interval, " hours"); interval = Math.floor(seconds / 60); if (interval > 1) return "".concat(interval, " minutes"); return "".concat(Math.floor(seconds), " seconds"); }, }, number: { friendly: function (num) { if (num < 1000) return num; if (num < 1000000) return "".concat((num / 1000).toFixed(2), "k"); if (num < 1000000000) return "".concat((num / 1000000).toFixed(2), "m"); }, }, removeDuplicateSpaces: function (s) { return s.replace(/\s+/g, " "); }, toUrlFriendly: function (s) { return s.replace(/\s+/g, "-"); }, };