From 7c9018bb7542153fb66b77909307fe35b8225834 Mon Sep 17 00:00:00 2001 From: HoonBaek Date: Thu, 23 Sep 2021 13:06:29 +0900 Subject: [PATCH 01/42] Add replyType --- src/index.d.ts | 1 + src/ui/MessageItemMenu/index.tsx | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/index.d.ts b/src/index.d.ts index b5f0dc48e..aeebf1738 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -108,6 +108,7 @@ export type Logger = { }; export type SendbirdError = Sendbird.SendBirdError; +export type ReplyType = "NONE" | "QUOTE_REPLY" | "THREAD"; export interface RenderOpenChannelTitleProps { channel: Sendbird.OpenChannel; diff --git a/src/ui/MessageItemMenu/index.tsx b/src/ui/MessageItemMenu/index.tsx index 073b14e66..0f9a760f5 100644 --- a/src/ui/MessageItemMenu/index.tsx +++ b/src/ui/MessageItemMenu/index.tsx @@ -13,6 +13,7 @@ import { isPendingMessage, } from '../../utils/index'; import { LocalizationContext } from '../../lib/LocalizationContext'; +import { ReplyType } from '../../index'; interface Props { className?: string | Array; @@ -20,6 +21,7 @@ interface Props { channel: GroupChannel | OpenChannel; isByMe?: boolean; disabled?: boolean; + replyType?: ReplyType; showEdit?: (bool: boolean) => void; showRemove?: (bool: boolean) => void; resendMessage?: (message: UserMessage | FileMessage) => void; @@ -32,6 +34,7 @@ export default function MessageItemMenu({ channel, isByMe = false, disabled = false, + replyType, showEdit, showRemove, resendMessage, @@ -42,7 +45,7 @@ export default function MessageItemMenu({ const containerRef = useRef(null); const showMenuItemCopy: boolean = isUserMessage(message as UserMessage); - const showMenuItemReply: boolean = false && !isFailedMessage(channel, message) && !isPendingMessage(channel, message); + const showMenuItemReply: boolean = !isFailedMessage(channel, message) && !isPendingMessage(channel, message); const showMenuItemEdit: boolean = (isUserMessage(message as UserMessage) && isSentMessage(channel, message) && isByMe); const showMenuItemResend: boolean = (isFailedMessage(channel, message) && message.isResendable() && isByMe); const showMenuItemDelete: boolean = (isSentMessage(channel, message) && isByMe); From bc30e858c55a0b81a61ca05f8d679dac4a85fe08 Mon Sep 17 00:00:00 2001 From: HoonBaek Date: Thu, 23 Sep 2021 13:23:12 +0900 Subject: [PATCH 02/42] Add and use min.js instead of sendbird to apply not released change from sdk --- src/lib/dux/sdk/thunks.js | 3 +- src/sendbird.min.js | 23668 ++++++++++++++++ .../components/MessageInputWrapper.tsx | 3 +- .../hooks/useGetSearchedMessages.ts | 3 +- .../components/MessageHOC.tsx | 3 +- .../components/MessageInpuetWrapper.tsx | 3 +- .../dux/initialState.ts | 3 +- .../hooks/useFileUploadCallback.ts | 3 +- .../hooks/useSendMessageCallback.ts | 3 +- .../hooks/useUpdateMessageCallback.ts | 3 +- .../OpenchannelConversation/utils.ts | 3 +- src/ui/EmojiReactions/index.tsx | 3 +- src/ui/FileMessageItemBody/index.tsx | 3 +- src/ui/MessageContent/index.tsx | 3 +- src/ui/MessageItemMenu/index.tsx | 3 +- src/ui/MessageItemReactionMenu/index.tsx | 3 +- src/ui/OGMessageItemBody/index.tsx | 3 +- src/ui/OpenChannelMessageContent/index.tsx | 3 +- src/ui/OpenchannelOGMessage/utils.ts | 3 +- .../ReplyingMessageThumbnail.tsx | 3 +- src/ui/ReplyingMessageAttachment/index.tsx | 3 +- src/ui/ReplyingMessageItemBody/index.tsx | 3 +- src/ui/TextMessageItemBody/index.tsx | 3 +- src/ui/ThumbnailMessageItemBody/index.tsx | 3 +- src/utils/openChannelUtils.ts | 3 +- 25 files changed, 23716 insertions(+), 24 deletions(-) create mode 100644 src/sendbird.min.js diff --git a/src/lib/dux/sdk/thunks.js b/src/lib/dux/sdk/thunks.js index 7ffd292a3..ed7050ca5 100644 --- a/src/lib/dux/sdk/thunks.js +++ b/src/lib/dux/sdk/thunks.js @@ -1,4 +1,5 @@ -import Sb from 'sendbird'; +// import Sb from 'sendbird'; +import Sb from '../../../sendbird.min.js'; import { INIT_SDK, diff --git a/src/sendbird.min.js b/src/sendbird.min.js new file mode 100644 index 000000000..3ee5c1474 --- /dev/null +++ b/src/sendbird.min.js @@ -0,0 +1,23668 @@ +/** + * Copyright (c) 2016 Sendbird DBA (Smile Family, Inc.) + * Sendbird JavaScript SDK v3.0.155 + */ + +!(function (e, n) { + "object" == typeof exports && "undefined" != typeof module + ? (module.exports = n( + require("axios"), + require("form-data"), + require("ws") + )) + : "function" == typeof define && define.amd + ? define(["axios", "form-data", "ws"], n) + : ((e = + "undefined" != typeof globalThis ? globalThis : e || self).SendBird = n( + e.axios, + e.FormData, + e.WebSocket + )); +})(this, function (e, n, t) { + "use strict"; + function i(e) { + return e && "object" == typeof e && "default" in e ? e : { default: e }; + } + var r = i(e), + a = i(n), + s = i(t); + function o(e, n) { + var t = Object.keys(e); + if (Object.getOwnPropertySymbols) { + var i = Object.getOwnPropertySymbols(e); + n && + (i = i.filter(function (n) { + return Object.getOwnPropertyDescriptor(e, n).enumerable; + })), + t.push.apply(t, i); + } + return t; + } + function l(e) { + for (var n = 1; n < arguments.length; n++) { + var t = null != arguments[n] ? arguments[n] : {}; + n % 2 + ? o(Object(t), !0).forEach(function (n) { + p(e, n, t[n]); + }) + : Object.getOwnPropertyDescriptors + ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) + : o(Object(t)).forEach(function (n) { + Object.defineProperty(e, n, Object.getOwnPropertyDescriptor(t, n)); + }); + } + return e; + } + function u(e) { + return ( + (u = + "function" == typeof Symbol && "symbol" == typeof Symbol.iterator + ? function (e) { + return typeof e; + } + : function (e) { + return e && + "function" == typeof Symbol && + e.constructor === Symbol && + e !== Symbol.prototype + ? "symbol" + : typeof e; + }), + u(e) + ); + } + function c(e, n) { + if (!(e instanceof n)) + throw new TypeError("Cannot call a class as a function"); + } + function d(e, n) { + for (var t = 0; t < n.length; t++) { + var i = n[t]; + (i.enumerable = i.enumerable || !1), + (i.configurable = !0), + "value" in i && (i.writable = !0), + Object.defineProperty(e, i.key, i); + } + } + function h(e, n, t) { + return n && d(e.prototype, n), t && d(e, t), e; + } + function p(e, n, t) { + return ( + n in e + ? Object.defineProperty(e, n, { + value: t, + enumerable: !0, + configurable: !0, + writable: !0, + }) + : (e[n] = t), + e + ); + } + function f(e, n) { + if ("function" != typeof n && null !== n) + throw new TypeError("Super expression must either be null or a function"); + (e.prototype = Object.create(n && n.prototype, { + constructor: { value: e, writable: !0, configurable: !0 }, + })), + n && g(e, n); + } + function y(e) { + return ( + (y = Object.setPrototypeOf + ? Object.getPrototypeOf + : function (e) { + return e.__proto__ || Object.getPrototypeOf(e); + }), + y(e) + ); + } + function g(e, n) { + return ( + (g = + Object.setPrototypeOf || + function (e, n) { + return (e.__proto__ = n), e; + }), + g(e, n) + ); + } + function _() { + if ("undefined" == typeof Reflect || !Reflect.construct) return !1; + if (Reflect.construct.sham) return !1; + if ("function" == typeof Proxy) return !0; + try { + return ( + Boolean.prototype.valueOf.call( + Reflect.construct(Boolean, [], function () {}) + ), + !0 + ); + } catch (e) { + return !1; + } + } + function m(e, n, t) { + return ( + (m = _() + ? Reflect.construct + : function (e, n, t) { + var i = [null]; + i.push.apply(i, n); + var r = new (Function.bind.apply(e, i))(); + return t && g(r, t.prototype), r; + }), + m.apply(null, arguments) + ); + } + function v(e) { + var n = "function" == typeof Map ? new Map() : void 0; + return ( + (v = function (e) { + if ( + null === e || + ((t = e), -1 === Function.toString.call(t).indexOf("[native code]")) + ) + return e; + var t; + if ("function" != typeof e) + throw new TypeError( + "Super expression must either be null or a function" + ); + if (void 0 !== n) { + if (n.has(e)) return n.get(e); + n.set(e, i); + } + function i() { + return m(e, arguments, y(this).constructor); + } + return ( + (i.prototype = Object.create(e.prototype, { + constructor: { + value: i, + enumerable: !1, + writable: !0, + configurable: !0, + }, + })), + g(i, e) + ); + }), + v(e) + ); + } + function E(e) { + if (void 0 === e) + throw new ReferenceError( + "this hasn't been initialised - super() hasn't been called" + ); + return e; + } + function C(e, n) { + if (n && ("object" == typeof n || "function" == typeof n)) return n; + if (void 0 !== n) + throw new TypeError( + "Derived constructors may only return object or undefined" + ); + return E(e); + } + function b(e) { + var n = _(); + return function () { + var t, + i = y(e); + if (n) { + var r = y(this).constructor; + t = Reflect.construct(i, arguments, r); + } else t = i.apply(this, arguments); + return C(this, t); + }; + } + function U(e, n, t) { + return ( + (U = + "undefined" != typeof Reflect && Reflect.get + ? Reflect.get + : function (e, n, t) { + var i = (function (e, n) { + for ( + ; + !Object.prototype.hasOwnProperty.call(e, n) && + null !== (e = y(e)); + + ); + return e; + })(e, n); + if (i) { + var r = Object.getOwnPropertyDescriptor(i, n); + return r.get ? r.get.call(t) : r.value; + } + }), + U(e, n, t || e) + ); + } + function A(e, n) { + return ( + (function (e) { + if (Array.isArray(e)) return e; + })(e) || + (function (e, n) { + var t = + null == e + ? null + : ("undefined" != typeof Symbol && e[Symbol.iterator]) || + e["@@iterator"]; + if (null == t) return; + var i, + r, + a = [], + s = !0, + o = !1; + try { + for ( + t = t.call(e); + !(s = (i = t.next()).done) && + (a.push(i.value), !n || a.length !== n); + s = !0 + ); + } catch (e) { + (o = !0), (r = e); + } finally { + try { + s || null == t.return || t.return(); + } finally { + if (o) throw r; + } + } + return a; + })(e, n) || + S(e, n) || + (function () { + throw new TypeError( + "Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method." + ); + })() + ); + } + function I(e) { + return ( + (function (e) { + if (Array.isArray(e)) return k(e); + })(e) || + (function (e) { + if ( + ("undefined" != typeof Symbol && null != e[Symbol.iterator]) || + null != e["@@iterator"] + ) + return Array.from(e); + })(e) || + S(e) || + (function () { + throw new TypeError( + "Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method." + ); + })() + ); + } + function S(e, n) { + if (e) { + if ("string" == typeof e) return k(e, n); + var t = Object.prototype.toString.call(e).slice(8, -1); + return ( + "Object" === t && e.constructor && (t = e.constructor.name), + "Map" === t || "Set" === t + ? Array.from(e) + : "Arguments" === t || + /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) + ? k(e, n) + : void 0 + ); + } + } + function k(e, n) { + (null == n || n > e.length) && (n = e.length); + for (var t = 0, i = new Array(n); t < n; t++) i[t] = e[t]; + return i; + } + function O(e, n) { + var t = + ("undefined" != typeof Symbol && e[Symbol.iterator]) || e["@@iterator"]; + if (!t) { + if ( + Array.isArray(e) || + (t = S(e)) || + (n && e && "number" == typeof e.length) + ) { + t && (e = t); + var i = 0, + r = function () {}; + return { + s: r, + n: function () { + return i >= e.length ? { done: !0 } : { done: !1, value: e[i++] }; + }, + e: function (e) { + throw e; + }, + f: r, + }; + } + throw new TypeError( + "Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method." + ); + } + var a, + s = !0, + o = !1; + return { + s: function () { + t = t.call(e); + }, + n: function () { + var e = t.next(); + return (s = e.done), e; + }, + e: function (e) { + (o = !0), (a = e); + }, + f: function () { + try { + s || null == t.return || t.return(); + } finally { + if (o) throw a; + } + }, + }; + } + var N = (function () { + function e() { + c(this, e); + } + return ( + h(e, null, [ + { + key: "OS_VERSION", + get: function () { + return "undefined" != typeof navigator && navigator.userAgent + ? navigator.userAgent.replace(/,/g, ".") + : "noAgent"; + }, + }, + { + key: "SDK_VERSION", + get: function () { + return "3.0.155"; + }, + }, + { + key: "SDK_MAJOR_VERSION", + get: function () { + return e.SDK_VERSION.split(".")[0]; + }, + }, + { + key: "DEFAULT_MAX_UNREAD_COUNT_OF_SUPER_GROUP_CHANNEL", + get: function () { + return 100; + }, + }, + { + key: "INTERNAL_CALL", + get: function () { + return "ic"; + }, + }, + ]), + e + ); + })(), + R = {}, + T = new WeakMap(), + M = (function () { + function e() { + var n = + arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {}; + c(this, e), T.set(this, "object" === u(n) && n ? n : {}); + } + return ( + h( + e, + [ + { + key: "container", + get: function () { + return T.get(this); + }, + }, + { + key: "get", + value: function (e) { + return T.get(this)[e]; + }, + }, + { + key: "set", + value: function (e, n) { + T.get(this)[e] = n; + }, + }, + { + key: "remove", + value: function (e) { + var n = T.get(this); + n.hasOwnProperty(e) && delete n[e]; + }, + }, + ], + [ + { + key: "create", + value: function (n, t) { + return (R[n] = new e(t)), R[n]; + }, + }, + { + key: "get", + value: function (e) { + return e || (e = ft.getInstance()._iid), R[e]; + }, + }, + ] + ), + e + ); + })(), + P = (function (e) { + f(t, e); + var n = b(t); + function t(e, i) { + var r; + return ( + c(this, t), + ((r = n.call(this, i)).name = "SendBirdException"), + (r.code = i || 0), + (r.message = e), + r + ); + } + return ( + h( + t, + [ + { + key: "isSessionKeyExpiredError", + get: function () { + return 400309 === this.code; + }, + }, + { + key: "isSessionTokenExpiredError", + get: function () { + return 400302 === this.code; + }, + }, + ], + [ + { + key: "INVALID_INITIALIZATION", + get: function () { + return 800100; + }, + }, + { + key: "CONNECTION_REQUIRED", + get: function () { + return 800101; + }, + }, + { + key: "CONNECTION_CANCELED", + get: function () { + return 800102; + }, + }, + { + key: "INVALID_PARAMETER", + get: function () { + return 800110; + }, + }, + { + key: "NETWORK_ERROR", + get: function () { + return 800120; + }, + }, + { + key: "NETWORK_ROUTING_ERROR", + get: function () { + return 800121; + }, + }, + { + key: "MALFORMED_DATA", + get: function () { + return 800130; + }, + }, + { + key: "MALFORMED_ERROR_DATA", + get: function () { + return 800140; + }, + }, + { + key: "WRONG_CHANNEL_TYPE", + get: function () { + return 800150; + }, + }, + { + key: "MARK_AS_READ_RATE_LIMIT_EXCEEDED", + get: function () { + return 800160; + }, + }, + { + key: "QUERY_IN_PROGRESS", + get: function () { + return 800170; + }, + }, + { + key: "ACK_TIMEOUT", + get: function () { + return 800180; + }, + }, + { + key: "LOGIN_TIMEOUT", + get: function () { + return 800190; + }, + }, + { + key: "WEBSOCKET_CONNECTION_CLOSED", + get: function () { + return 800200; + }, + }, + { + key: "WEBSOCKET_CONNECTION_FAILED", + get: function () { + return 800210; + }, + }, + { + key: "REQUEST_FAILED", + get: function () { + return 800220; + }, + }, + { + key: "FILE_UPLOAD_CANCEL_FAILED", + get: function () { + return 800230; + }, + }, + { + key: "REQUEST_CANCELED", + get: function () { + return 800240; + }, + }, + { + key: "REQUEST_DUPLICATED", + get: function () { + return 800250; + }, + }, + { + key: "FILE_SIZE_LIMIT_EXCEEDED", + get: function () { + return 800260; + }, + }, + { + key: "SESSION_TOKEN_REQUEST_FAILED", + get: function () { + return 800500; + }, + }, + { + key: "SESSION_TOKEN_REFRESHED", + get: function () { + return 800501; + }, + }, + { + key: "SESSION_TOKEN_REFRESH_FAILED", + get: function () { + return 800502; + }, + }, + ] + ), + t + ); + })(v(Error)), + L = (function () { + function e() { + c(this, e), + (this.sessionToken = null), + (this.sessionKey = null), + (this.eKey = null); + } + return ( + h(e, [ + { + key: "hasSession", + value: function () { + return !!this.sessionKey; + }, + }, + ]), + e + ); + })(), + w = {}, + D = (function () { + function e(n) { + var t = this, + i = + arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {}; + c(this, e), + (this._iid = n), + Object.keys(i).forEach(function (e) { + var n = i[e]; + "function" == typeof n && (t[e] = t.getClonedClass(n)); + }), + (w[n] = this); + } + return ( + h( + e, + [ + { + key: "getClonedClass", + value: function (e) { + var n = this._iid, + t = (function (t) { + f(r, t); + var i = b(r); + function r() { + return c(this, r), i.apply(this, arguments); + } + return ( + h( + r, + [ + { + key: "_iid", + get: function () { + return n; + }, + }, + ], + [ + { + key: "_iid", + get: function () { + return n; + }, + }, + { + key: "_name", + get: function () { + return e.name; + }, + }, + ] + ), + r + ); + })(e); + return t; + }, + }, + ], + [ + { + key: "get", + value: function (e) { + return e ? w[e] : {}; + }, + }, + ] + ), + e + ); + })(), + H = { + verbose: "VERBOSE", + info: "INFO", + debug: "DEBUG", + warn: "WARN", + error: "ERROR", + none: "NONE", + }, + F = (function (e) { + f(t, e); + var n = b(t); + function t() { + return c(this, t), n.apply(this, arguments); + } + return ( + h(t, [ + { + key: "log", + value: function (e) { + for ( + var n, t, i, r, a, s = this.getLogLevelText(e); + s.length < 8; + + ) + s += " "; + for ( + var o = arguments.length, + l = new Array(o > 1 ? o - 1 : 0), + u = 1; + u < o; + u++ + ) + l[u - 1] = arguments[u]; + switch ((l.unshift("[".concat(s, "]")), e)) { + case "verbose": + (n = console).log.apply(n, l); + break; + case "debug": + (t = console).log.apply(t, l); + break; + case "info": + (i = console).info.apply(i, l); + break; + case "warn": + (r = console).warn.apply(r, l); + break; + case "error": + (a = console).error.apply(a, l); + } + }, + }, + { + key: "groupStart", + value: function () { + var e; + (e = console).group.apply(e, arguments); + }, + }, + { + key: "groupEnd", + value: function () { + var e; + (e = console).groupEnd.apply(e, arguments); + }, + }, + ]), + t + ); + })( + (function () { + function e() { + c(this, e); + } + return ( + h(e, [ + { + key: "getLogLevelText", + value: function (e) { + return H[e]; + }, + }, + ]), + e + ); + })() + ), + G = { DEBUG: "debug", PRODUCTION: "production" }, + j = G.PRODUCTION, + B = { + VERBOSE: "verbose", + DEBUG: "debug", + INFO: "info", + WARN: "warn", + ERROR: "error", + NONE: "none", + }, + x = [B.NONE, B.ERROR, B.WARN, B.INFO, B.DEBUG, B.VERBOSE], + q = B.WARN, + z = x.indexOf(q), + Q = [new F()], + V = (function () { + function e() { + c(this, e); + } + return ( + h(e, null, [ + { + key: "Mode", + get: function () { + return G; + }, + }, + { + key: "mode", + get: function () { + return j; + }, + set: function (n) { + Object.keys(e.Mode) + .map(function (n) { + return e.Mode[n]; + }) + .indexOf(n) > -1 && (j = n); + }, + }, + { + key: "supportedLogLevels", + get: function () { + return B; + }, + }, + { + key: "logLevel", + get: function () { + return x[z]; + }, + set: function (e) { + x.includes(e) || (e = q), (z = x.indexOf(e)); + }, + }, + { + key: "defaultLogLevel", + get: function () { + return q; + }, + }, + { + key: "isDisplayableLogLevel", + value: function (e) { + var n = x.indexOf(e); + return 0 <= n && n <= z; + }, + }, + { + key: "log", + value: function (n) { + for ( + var t = arguments.length, + i = new Array(t > 1 ? t - 1 : 0), + r = 1; + r < t; + r++ + ) + i[r - 1] = arguments[r]; + e.isDisplayableLogLevel(n) && + Q.forEach(function (e) { + return e.log.apply(e, [n].concat(i)); + }); + }, + }, + { + key: "verbose", + value: function () { + for ( + var n = arguments.length, t = new Array(n), i = 0; + i < n; + i++ + ) + t[i] = arguments[i]; + e.log.apply(e, [B.VERBOSE].concat(t)); + }, + }, + { + key: "debug", + value: function () { + for ( + var n = arguments.length, t = new Array(n), i = 0; + i < n; + i++ + ) + t[i] = arguments[i]; + e.log.apply(e, [B.DEBUG].concat(t)); + }, + }, + { + key: "info", + value: function () { + for ( + var n = arguments.length, t = new Array(n), i = 0; + i < n; + i++ + ) + t[i] = arguments[i]; + e.log.apply(e, [B.INFO].concat(t)); + }, + }, + { + key: "warn", + value: function () { + for ( + var n = arguments.length, t = new Array(n), i = 0; + i < n; + i++ + ) + t[i] = arguments[i]; + e.log.apply(e, [B.WARN].concat(t)); + }, + }, + { + key: "error", + value: function () { + for ( + var n = arguments.length, t = new Array(n), i = 0; + i < n; + i++ + ) + t[i] = arguments[i]; + e.log.apply(e, [B.ERROR].concat(t)); + }, + }, + { + key: "group", + value: function () { + for ( + var n = arguments.length, t = new Array(n), i = 0; + i < n; + i++ + ) + t[i] = arguments[i]; + var r = []; + Array.isArray(t[t.length - 1]) && (r = t.pop()), + r.some(function (n) { + return e.isDisplayableLogLevel(n.level); + }) && + Q.filter(function (e) { + return e instanceof F; + }).forEach(function (e) { + e.groupStart.apply(e, t), + r.forEach(function (n) { + return e.log.apply(e, [n.level].concat(I(n.messages))); + }), + e.groupEnd(); + }); + }, + }, + ]), + e + ); + })(), + Y = (function () { + function e() { + c(this, e), (this._queue = []), (this.locked = !1); + } + return ( + h(e, [ + { + key: "lock", + value: function (e) { + var n = this; + this.locked + ? this._queue.push(e) + : ((this.locked = !0), + e(function () { + return n.unlock(); + })); + }, + }, + { + key: "unlock", + value: function () { + if (((this.locked = !1), this._queue.length > 0)) { + var e = this._queue.shift(); + this.lock(e); + } + }, + }, + ]), + e + ); + })(), + K = (function () { + function e(n) { + c(this, e), + (this.sb = n), + (this.mutex = new Y()), + (this.pingTimer = null), + (this.pingTimeoutTimer = null); + } + return ( + h(e, [ + { + key: "ping", + value: function () { + var e = this, + n = D.get(this.sb._iid).Command.bPing(), + t = M.get(this.sb._iid).container, + i = t.wsAdapter, + r = t.pongTimeout; + i.client.send(n), + V.debug("`PING`"), + (this.pingTimeoutTimer = setTimeout(function () { + V.debug("`PING` timeout."), + e.stop(), + i.client.handler && i.client.handler.onError(); + }, r)); + }, + }, + { + key: "pong", + value: function () { + this.pingTimeoutTimer && + (clearTimeout(this.pingTimeoutTimer), + (this.pingTimeoutTimer = null)); + }, + }, + { + key: "refreshTimer", + value: function () { + var e = this, + n = M.get(this.sb._iid).container.pingInterval; + this.mutex.lock(function (t) { + e.stop(), + (e.pingTimer = setInterval(function () { + e.ping(); + }, n)), + t(); + }); + }, + }, + { + key: "start", + value: function () { + this.refreshTimer(), this.ping(); + }, + }, + { + key: "stop", + value: function () { + this.pingTimer && + (clearInterval(this.pingTimer), (this.pingTimer = null)), + this.pingTimeoutTimer && + (clearTimeout(this.pingTimeoutTimer), + (this.pingTimeoutTimer = null)); + }, + }, + ]), + e + ); + })(); + function W() { + return ( + "undefined" == typeof window && + "undefined" != typeof process && + ("node" === process.title || + (void 0 !== process.versions && process.versions.node) || + "[object process]" === String(process)) + ); + } + var J = [ + P.CONNECTION_REQUIRED, + P.NETWORK_ERROR, + P.ACK_TIMEOUT, + P.WEBSOCKET_CONNECTION_CLOSED, + P.WEBSOCKET_CONNECTION_FAILED, + P.FILE_UPLOAD_CANCEL_FAILED, + P.REQUEST_CANCELED, + 500901, + 500910, + 900200, + ], + X = (function () { + function e() { + c(this, e); + } + return ( + h(e, null, [ + { + key: "deepEqual", + value: function (e, n) { + if (e !== n) { + var t = l({}, e), + i = l({}, n); + return ( + (!t.messageId || + !i.messageId || + t.messageId === i.messageId) && + (!t.reqId || !i.reqId || t.reqId === i.reqId) && + (t.hasOwnProperty("messageId") && delete t.messageId, + t.hasOwnProperty("reqId") && delete t.reqId, + i.hasOwnProperty("messageId") && delete i.messageId, + i.hasOwnProperty("reqId") && delete i.reqId, + JSON.stringify(t) === JSON.stringify(i)) + ); + } + return !0; + }, + }, + { + key: "isResendableError", + value: function (e) { + return e > 0 && J.indexOf(e) >= 0; + }, + }, + { + key: "isFile", + value: function (e) { + var n = + "object" === u(e) && + null !== e && + "string" == typeof e.name && + "string" == typeof e.uri && + "string" == typeof e.type; + if (!n) + if (W()) { + if ("undefined" != typeof Buffer) return e instanceof Buffer; + } else { + if ("undefined" != typeof Blob) return e instanceof Blob; + if ("undefined" != typeof File) return e instanceof File; + } + return n; + }, + }, + ]), + e + ); + })(), + Z = (function () { + function e(n) { + var t = this; + c(this, e), + (this.fields = {}), + n && + Object.keys(n).forEach(function (e) { + (t.fields[e] = { value: n[e] }), + X.isFile(n[e]) && (t.fields[e].filename = n[e].name); + }), + (this.options = {}), + (this.internal = !1), + (this.upload = { + reqId: null, + deleteRequest: null, + progressHandler: null, + }); + } + return ( + h(e, [ + { + key: "add", + value: function (e, n) { + var t = + arguments.length > 2 && void 0 !== arguments[2] + ? arguments[2] + : null; + this.fields[e] = { value: n, filename: t }; + }, + }, + { + key: "remove", + value: function (e) { + this.fields.hasOwnProperty(e) && delete this.fields[e]; + }, + }, + { + key: "yield", + value: function () { + for ( + var e = this, n = !1, t = Object.keys(this.fields), i = 0; + i < t.length; + i++ + ) { + var r = t[i]; + if (X.isFile(this.fields[r].value)) { + n = !0; + break; + } + } + if (n) { + var s = new a.default(); + return ( + Object.keys(this.fields).forEach(function (n) { + var t = e.fields[n]; + if (X.isFile(t.value)) { + var i = t.value; + i.filename || i.name + ? s.append(n, t.value, i.filename || i.name) + : i.data + ? s.append(n, t.value, i.data.name) + : s.append(n, t.value, "unnamed"); + } else s.append(n, t.value); + }), + s + ); + } + var o = {}; + return ( + Object.keys(this.fields).forEach(function (n) { + o[n] = e.fields[n].value; + }), + o + ); + }, + }, + ]), + e + ); + })(), + $ = 888e3, + ee = (function () { + function e(n) { + c(this, e), (this.sb = n), (this.cls = D.get(this.sb._iid)); + } + return ( + h( + e, + [ + { + key: "checkRouting", + value: function (e) { + if (this.sb.customApiHost && this.sb.customWsHost) + "function" == typeof e && + e(null, { + apiHost: this.sb.customApiHost, + wsHost: this.sb.customWsHost, + }); + else { + var n = this.sb.getApplicationId(); + e(null, { + apiHost: "https://api-".concat(n, ".sendbird.com"), + wsHost: "wss://ws-".concat(n, ".sendbird.com"), + }); + } + }, + }, + { + key: "_buildUrl", + value: function (e) { + var n = e.apiHost, + t = e.url, + i = e.params; + return t + ? i && i.internal + ? "" + .concat(n, "/v") + .concat(N.SDK_MAJOR_VERSION, "/sdk") + .concat(t) + : "".concat(n, "/v").concat(N.SDK_MAJOR_VERSION).concat(t) + : n; + }, + }, + { + key: "_createHeader", + value: function () { + var e = + arguments.length > 0 && void 0 !== arguments[0] + ? arguments[0] + : {}, + n = + arguments.length > 1 && void 0 !== arguments[1] + ? arguments[1] + : {}, + t = n.noSessionKey, + i = void 0 !== t && t, + r = n.accessToken, + s = void 0 === r ? null : r, + o = + e instanceof a.default && "function" == typeof e.getHeaders + ? e.getHeaders() + : {}, + l = M.get(this.sb._iid), + u = l.container, + c = u.appId, + d = u.auth, + h = u.extensions, + p = u.getUserAgentWithExtensions; + return ( + (o.SendBird = "JS," + .concat(N.OS_VERSION, ",") + .concat(N.SDK_VERSION, ",") + .concat(c)), + (o["SB-User-Agent"] = encodeURIComponent(p(h))), + !i && d.sessionKey && (o["Session-Key"] = d.sessionKey), + s && ((o["App-Id"] = c), (o["Access-Token"] = s)), + (o[ + "Request-Sent-Timestamp" + ] = new Date().getTime().toString()), + o + ); + }, + }, + { + key: "_createQuery", + value: function (e) { + var n = + arguments.length > 1 && void 0 !== arguments[1] + ? arguments[1] + : {}; + try { + var t = []; + return ( + Object.keys(n).forEach(function (e) { + var i = n[e]; + if (null != i) { + var r = ""; + (r = + "object" === u(i) + ? Array.isArray(i) + ? i + .map(function (e) { + return encodeURIComponent( + "string" == typeof e ? e.trim() : e + ); + }) + .join(",") + : encodeURIComponent(JSON.stringify(i)) + : encodeURIComponent(i)), + t.push("".concat(e, "=").concat(r)); + } + }), + t.length > 0 ? "".concat(e, "?").concat(t.join("&")) : e + ); + } catch (n) { + return ( + V.debug("createWithEncodedGetParams is failed. - ", n), e + ); + } + }, + }, + { + key: "_request", + value: function (e, n, t, i) { + var s = this; + this.checkRouting(function (o, l) { + if (o) i(new P("Request failed.", P.REQUEST_FAILED), null); + else { + var u = s._buildUrl({ + apiHost: l.apiHost, + url: n, + params: t, + }), + c = t ? t.yield() : {}, + d = s._createHeader(c, t ? t.options : {}), + h = [ + { + level: V.supportedLogLevels.DEBUG, + messages: ["url:", n], + }, + { + level: V.supportedLogLevels.DEBUG, + messages: ["data:", c], + }, + ], + p = null; + switch (e) { + case "GET": + p = s._createQuery(u, c); + break; + case "POST": + case "PUT": + p = u; + break; + case "DELETE": + p = s._createQuery(u, c); + } + var f = null; + if ( + "undefined" == typeof ServiceWorker || + "undefined" == typeof ServiceWorkerRegistration || + "undefined" != typeof ServiceWorkerContainer || + W() || + "function" != typeof fetch + ) + switch (e) { + case "GET": + f = r.default.get(p, { + headers: d, + validateStatus: s._validateStatus, + }); + break; + case "POST": + var y = null; + if (c instanceof a.default) { + var g = r.default.CancelToken.source(); + y = g.token; + var _ = s.cls.FileMessageQueue, + m = t.upload.reqId; + m && + (h.push({ + level: V.supportedLogLevels.DEBUG, + messages: ["request id:", m], + }), + (_.uploadRequest[m] = g)); + } + f = r.default.post( + p, + "function" == typeof c.getBuffer + ? c.getBuffer() + : c, + { + headers: d, + validateStatus: s._validateStatus, + cancelToken: y, + onUploadProgress: function (e) { + t.upload.progressHandler && + t.upload.progressHandler(e, t.upload.reqId); + }, + } + ); + break; + case "PUT": + f = r.default.put(p, c, { + headers: d, + validateStatus: s._validateStatus, + }); + break; + case "DELETE": + f = r.default.delete(p, { + headers: d, + validateStatus: s._validateStatus, + }); + } + else { + var v = { method: e, headers: d }; + switch (e) { + case "GET": + break; + case "POST": + if (c instanceof a.default) { + if ("function" == typeof AbortController) { + var E = new AbortController(), + C = E.signal; + v.signal = C; + var b = s.cls.FileMessageQueue, + U = t.upload.reqId; + U && + (h.push({ + level: V.supportedLogLevels.DEBUG, + messages: ["request id:", U], + }), + (b.uploadRequest[U] = E)); + } + v.body = + "function" == typeof c.getBuffer + ? c.getBuffer() + : c; + } else + (d["Content-Type"] = + "application/json; charset=utf-8"), + (v.body = JSON.stringify(c)); + break; + case "PUT": + c instanceof a.default + ? (v.body = + "function" == typeof c.getBuffer + ? c.getBuffer() + : c) + : ((d["Content-Type"] = + "application/json; charset=utf-8"), + (v.body = JSON.stringify(c))); + } + f = fetch(p, v).then(function (e) { + return e.json().then(function (n) { + if (!s._validateStatus(e.status)) + throw { + request: { isAbort: !1 }, + response: { data: n }, + }; + return Promise.resolve({ data: n }); + }); + }); + } + V.group("".concat(e, " request"), h), + (h = []), + f + .then(function (n) { + try { + var r = n.data; + "POST" === e && + "function" == typeof t.upload.deleteRequest && + t.upload.deleteRequest(), + h.push({ + level: V.supportedLogLevels.DEBUG, + messages: ["data:", r], + }), + i(null, r); + } catch (e) { + throw { code: $, rawError: e }; + } + }) + .catch(function (r) { + if (r.code === $) throw r.rawError; + "POST" === e && + "function" == typeof t.upload.deleteRequest && + t.upload.deleteRequest(); + var a = s._handleError(r); + h.push({ + level: V.supportedLogLevels.DEBUG, + messages: ["error:", a], + }), + n && t && a.isSessionKeyExpiredError + ? M.get( + s.sb._iid + ).container.sessionManager.refresh(function ( + e + ) { + return i(e, null); + }) + : i(a, null); + }) + .finally(function () { + return V.group("".concat(e, " response"), h); + }); + } + }); + }, + }, + { + key: "_validateStatus", + value: function (e) { + return e >= 200 && e < 400; + }, + }, + { + key: "_handleError", + value: function (e) { + var n = e.request, + t = e.response; + if (n) { + if (n.isAbort || n.aborted) + return new P( + "Request has been canceled.", + P.REQUEST_CANCELED + ); + if (t) { + var i = t.data, + r = i ? i.message : "Request failed.", + a = i ? i.code : P.REQUEST_FAILED; + return new P(r, a); + } + return new P("Request failed.", P.REQUEST_FAILED); + } + return new P("There was a network error.", P.NETWORK_ERROR); + }, + }, + { + key: "get", + value: function (e, n, t) { + this._request("GET", e, n, t); + }, + }, + { + key: "dummyCall", + value: function (e) { + this._request("GET", null, null, e); + }, + }, + { + key: "post", + value: function (e, n, t) { + this._request("POST", e, n, t); + }, + }, + { + key: "put", + value: function (e, n, t) { + this._request("PUT", e, n, t); + }, + }, + { + key: "delete", + value: function (e, n, t) { + this._request("DELETE", e, n, t); + }, + }, + { + key: "refreshSessionKey", + value: function (n, t) { + var i = this, + r = n.accessToken; + this.sb.ConnectionManager.ready(function (n, a) { + if (n) t(n, null); + else { + var s = e.Path.USERS_USERID_SESSION_KEY.replace( + "%s", + encodeURIComponent(a.userId) + ), + o = new Z(); + (o.options.noSessionKey = !0), + (o.options.accessToken = r), + i.post(s, o, t); + } + }); + }, + }, + { + key: "updateCurrentUserInfo", + value: function (n, t) { + var i = this, + r = n.nickname, + a = n.profileUrl, + s = n.profileImage, + o = n.preferredLanguages; + this.sb.ConnectionManager.ready(function (n, l) { + if (n) t(n, null); + else { + var u = e.Path.USERS_USERID.replace( + "%s", + encodeURIComponent(l.userId) + ), + c = new Z(); + r && c.add("nickname", r), + a && c.add("profile_url", a), + s && c.add("profile_file", s, s.name), + o && c.add("preferred_languages", o), + i.put(u, c, t); + } + }); + }, + }, + { + key: "getMyGroupChannelChangeLogs", + value: function (n, t) { + var i = this, + r = n.ts, + a = n.token, + s = n.customTypes, + o = n.includeEmpty, + l = n.includeFrozen; + this.sb.ConnectionManager.ready(function (n, u) { + if (n) t(n, null); + else { + var c = e.Path.USERS_USERID_MY_GROUP_CHANNEL_CHANGELOGS.replace( + "%s", + encodeURIComponent(u.userId) + ), + d = new Z({ + show_read_receipt: !0, + show_delivery_receipt: !0, + show_member: !0, + }); + a && d.add("token", a), + r && d.add("change_ts", r), + s && s.length > 0 && d.add("custom_types", s), + "boolean" == typeof o && d.add("show_empty", o), + "boolean" == typeof l && d.add("show_frozen", l), + i.get(c, d, t); + } + }); + }, + }, + { + key: "getChannelInvitationPreference", + value: function (n, t) { + var i = this; + this.sb.ConnectionManager.ready(function (n, r) { + if (n) t(n, null); + else { + var a = e.Path.USERS_USERID_GROUP_CHANNEL_INVITATION_PREFERENCE.replace( + "%s", + encodeURIComponent(r.userId) + ); + i.get(a, null, t); + } + }); + }, + }, + { + key: "getGroupChannelCount", + value: function (n, t) { + var i = this, + r = n.memberStateFilter; + this.sb.ConnectionManager.ready(function (n, a) { + if (n) t(n, null); + else { + var s = i.cls.GroupChannel, + o = e.Path.USERS_USERID_GROUP_CHANNEL_COUNT.replace( + "%s", + encodeURIComponent(a.userId) + ), + l = ""; + switch (r) { + case s.MemberStateFilter.JOINED: + l = "joined"; + break; + case s.MemberStateFilter.INVITED: + l = "invited"; + break; + case s.MemberStateFilter.INVITED_BY_FRIEND: + l = "invited_by_friend"; + break; + case s.MemberStateFilter.INVITED_BY_NON_FRIEND: + l = "invited_by_non_friend"; + break; + default: + l = "all"; + } + var u = new Z({ state: l }); + i.get(o, u, t); + } + }); + }, + }, + { + key: "getUnreadItemCount", + value: function (n, t) { + var i = this, + r = n.keys; + this.sb.ConnectionManager.ready(function (n, a) { + if (n) t(n, null); + else { + var s = e.Path.USERS_USERID_UNREAD_ITEM_COUNT.replace( + "%s", + encodeURIComponent(a.userId) + ), + o = new Z({ item_keys: r }); + i.get(s, o, t); + } + }); + }, + }, + { + key: "getTotalUnreadMessageCount", + value: function (n, t) { + var i = this, + r = n.customTypesFilter, + a = n.superChannelFilter; + this.sb.ConnectionManager.ready(function (n, s) { + if (n) t(n, null); + else { + var o = e.Path.USERS_USERID_UNREAD_MESSAGE_COUNT.replace( + "%s", + encodeURIComponent(s.userId) + ), + l = new Z({ super_mode: a }); + null !== r && r.length > 0 && l.add("custom_types", r), + i.get(o, l, t); + } + }); + }, + }, + { + key: "getTotalUnreadChannelCount", + value: function (n, t) { + var i = this; + this.sb.ConnectionManager.ready(function (n, r) { + if (n) t(n, null); + else { + var a = e.Path.USERS_USERID_UNREAD_CHANNEL_COUNT.replace( + "%s", + encodeURIComponent(r.userId) + ); + i.get(a, null, t); + } + }); + }, + }, + { + key: "searchMessages", + value: function (n, t) { + var i = this, + r = n.keyword, + a = n.limit, + s = n.reverse, + o = n.exactMatch, + l = n.channelUrl, + u = n.channelCustomType, + c = n.messageTimestampFrom, + d = n.messageTimestampTo, + h = n.order, + p = n.nextToken, + f = n.advancedQuery, + y = n.targetFields; + this.sb.ConnectionManager.ready(function (n, g) { + if (n) t(n, null); + else { + var _ = e.Path.SEARCH_MESSAGE, + m = new Z({ + limit: a, + reverse: s, + query: r, + custom_type: u, + }); + c && m.add("message_ts_from", c), + d && m.add("message_ts_to", d), + l && m.add("channel_url", l), + h && m.add("sort_field", h), + "boolean" == typeof o && m.add("exact_match", o), + null !== p && p.length > 0 && m.add("after", p), + "boolean" == typeof f && m.add("advanced_query", f), + y && Array.isArray(y) && m.add("target_fields", y), + i.get(_, m, t); + } + }); + }, + }, + { + key: "markAsReadAll", + value: function (n, t) { + var i = this, + r = n.channelUrls; + this.sb.ConnectionManager.ready(function (n, a) { + if (n) t(n, null); + else { + var s = e.Path.USERS_USERID_MARKASREADALL.replace( + "%s", + encodeURIComponent(a.userId) + ), + o = new Z(); + r && o.add("channel_urls", r), i.put(s, o, t); + } + }); + }, + }, + { + key: "markAsDelivered", + value: function (n, t) { + var i = this, + r = n.channelUrl, + a = n.userId; + this.sb.ConnectionManager.ready(function (n, s) { + if (n) t(n, null); + else { + var o = e.Path.GROUPCHANNELS_CHANNELURL_MESSAGES_MARKASDELIVERED.replace( + "%s", + encodeURIComponent(r) + ), + l = new Z(); + a && l.add("user_id", a), i.put(o, l, t); + } + }); + }, + }, + { + key: "setChannelInvitationPreference", + value: function (n, t) { + var i = this, + r = n.isAutoAccept; + this.sb.ConnectionManager.ready(function (n, a) { + if (n) t(n, null); + else { + var s = e.Path.USERS_USERID_GROUP_CHANNEL_INVITATION_PREFERENCE.replace( + "%s", + encodeURIComponent(a.userId) + ), + o = new Z({ auto_accept: r }); + i.put(s, o, t); + } + }); + }, + }, + { + key: "blockUser", + value: function (n, t) { + var i = this, + r = n.blockedUserId; + this.sb.ConnectionManager.ready(function (n, a) { + if (n) t(n, null); + else { + var s = e.Path.USERS_USERID_BLOCK.replace( + "%s", + encodeURIComponent(a.userId) + ), + o = new Z({ target_id: r }); + i.post(s, o, t); + } + }); + }, + }, + { + key: "unblockUser", + value: function (n, t) { + var i = this, + r = n.unblockedUserId; + this.sb.ConnectionManager.ready(function (n, a) { + if (n) t(n, null); + else { + var s = e.Path.USERS_USERID_BLOCK_TARGETID.replace( + "%s", + encodeURIComponent(a.userId) + ).replace("%s", encodeURIComponent(r)); + i.delete(s, null, t); + } + }); + }, + }, + { + key: "getPushTriggerOption", + value: function (n, t) { + var i = this; + this.sb.ConnectionManager.ready(function (n, r) { + if (n) t(n, null); + else { + var a = e.Path.USERS_USERID_PUSHPREFERENCE.replace( + "%s", + encodeURIComponent(r.userId) + ); + i.get(a, null, t); + } + }); + }, + }, + { + key: "setPushTriggerOption", + value: function (n, t) { + var i = this, + r = n.pushTriggerOption; + this.sb.ConnectionManager.ready(function (n, a) { + if (n) t(n, null); + else { + var s = e.Path.USERS_USERID_PUSHPREFERENCE.replace( + "%s", + encodeURIComponent(a.userId) + ), + o = new Z({ push_trigger_option: r }); + i.put(s, o, t); + } + }); + }, + }, + { + key: "getPushTokens", + value: function (n, t) { + var i = this, + r = n.ts, + a = n.token, + s = n.type; + this.sb.ConnectionManager.ready(function (n, o) { + if (n) t(n, null); + else { + var l = e.Path.USERS_USERID_PUSH_DEVICE_TOKENS.replace( + "%s", + encodeURIComponent(o.userId) + ).replace("%s", encodeURIComponent(s)), + u = new Z(); + a && u.add("token", a), + r && u.add("created_ts", r), + i.get(l, u, t); + } + }); + }, + }, + { + key: "getPushTemplate", + value: function (n, t) { + var i = this; + this.sb.ConnectionManager.ready(function (n, r) { + if (n) t(n, null); + else { + var a = e.Path.USERS_USERID_PUSH_TEMPLATE.replace( + "%s", + encodeURIComponent(r.userId) + ); + i.get(a, null, t); + } + }); + }, + }, + { + key: "setPushTemplate", + value: function (n, t) { + var i = this, + r = n.templateName; + this.sb.ConnectionManager.ready(function (n, a) { + if (n) t(n, null); + else { + var s = e.Path.USERS_USERID_PUSH_TEMPLATE.replace( + "%s", + encodeURIComponent(a.userId) + ), + o = new Z({ name: r }); + i.put(s, o, t); + } + }); + }, + }, + { + key: "getDoNotDisturb", + value: function (n, t) { + var i = this; + this.sb.ConnectionManager.ready(function (n, r) { + if (n) t(n, null); + else { + var a = e.Path.USERS_USERID_PUSHPREFERENCE.replace( + "%s", + encodeURIComponent(r.userId) + ); + i.get(a, null, t); + } + }); + }, + }, + { + key: "setDoNotDisturb", + value: function (n, t) { + var i = this, + r = n.doNotDisturbOn, + a = n.startHour, + s = n.startMin, + o = n.endHour, + l = n.endMin, + u = n.timezone; + this.sb.ConnectionManager.ready(function (n, c) { + if (n) t(n, null); + else { + var d = e.Path.USERS_USERID_PUSHPREFERENCE.replace( + "%s", + encodeURIComponent(c.userId) + ), + h = new Z({ + do_not_disturb: r, + start_hour: a, + start_min: s, + end_hour: o, + end_min: l, + timezone: u, + }); + i.put(d, h, t); + } + }); + }, + }, + { + key: "getSnoozePeriod", + value: function (n, t) { + var i = this; + this.sb.ConnectionManager.ready(function (n, r) { + if (n) t(n, null); + else { + var a = e.Path.USERS_USERID_PUSHPREFERENCE.replace( + "%s", + encodeURIComponent(r.userId) + ); + i.get(a, null, t); + } + }); + }, + }, + { + key: "setSnoozePeriod", + value: function (n, t) { + var i = this, + r = n.snoozeOn, + a = n.startTs, + s = n.endTs; + this.sb.ConnectionManager.ready(function (n, o) { + if (n) t(n, null); + else { + var l = e.Path.USERS_USERID_PUSHPREFERENCE.replace( + "%s", + encodeURIComponent(o.userId) + ), + u = new Z({ + snooze_enabled: r, + snooze_start_ts: a, + snooze_end_ts: s, + }); + i.put(l, u, t); + } + }); + }, + }, + { + key: "registerGCMPushToken", + value: function (n, t) { + var i = this, + r = n.token; + this.sb.ConnectionManager.ready(function (n, a) { + if (n) t(n, null); + else { + var s = e.Path.USERS_USERID_PUSH_GCM.replace( + "%s", + encodeURIComponent(a.userId) + ), + o = new Z({ gcm_reg_token: r, always_push: !0 }); + i.post(s, o, t); + } + }); + }, + }, + { + key: "unregisterGCMPushToken", + value: function (n, t) { + var i = this, + r = n.token; + this.sb.ConnectionManager.ready(function (n, a) { + if (n) t(n, null); + else { + var s = e.Path.USERS_USERID_PUSH_GCM_TOKEN.replace( + "%s", + encodeURIComponent(a.userId) + ).replace("%s", encodeURIComponent(r)); + i.delete(s, null, t); + } + }); + }, + }, + { + key: "unregisterAllGCMPushTokens", + value: function (n, t) { + var i = this; + this.sb.ConnectionManager.ready(function (n, r) { + if (n) t(n, null); + else { + var a = e.Path.USERS_USERID_PUSH_GCM.replace( + "%s", + encodeURIComponent(r.userId) + ); + i.delete(a, null, t); + } + }); + }, + }, + { + key: "registerAPNSPushToken", + value: function (n, t) { + var i = this, + r = n.token; + this.sb.ConnectionManager.ready(function (n, a) { + if (n) t(n, null); + else { + var s = e.Path.USERS_USERID_PUSH_APNS.replace( + "%s", + encodeURIComponent(a.userId) + ), + o = new Z({ apns_device_token: r, always_push: !0 }); + i.post(s, o, t); + } + }); + }, + }, + { + key: "unregisterAPNSPushToken", + value: function (n, t) { + var i = this, + r = n.token; + this.sb.ConnectionManager.ready(function (n, a) { + if (n) t(n, null); + else { + var s = e.Path.USERS_USERID_PUSH_APNS_TOKEN.replace( + "%s", + encodeURIComponent(a.userId) + ).replace("%s", encodeURIComponent(r)); + i.delete(s, null, t); + } + }); + }, + }, + { + key: "unregisterAllAPNSPushTokens", + value: function (n, t) { + var i = this; + this.sb.ConnectionManager.ready(function (n, r) { + if (n) t(n, null); + else { + var a = e.Path.USERS_USERID_PUSH_APNS.replace( + "%s", + encodeURIComponent(r.userId) + ); + i.delete(a, null, t); + } + }); + }, + }, + { + key: "unregisterAllPushTokens", + value: function (n, t) { + var i = this; + this.sb.ConnectionManager.ready(function (n, r) { + if (n) t(n, null); + else { + var a = e.Path.USERS_USERID_PUSH.replace( + "%s", + encodeURIComponent(r.userId) + ); + i.delete(a, null, t); + } + }); + }, + }, + { + key: "loadFriendList", + value: function (n, t) { + var i = this, + r = n.token, + a = n.limit; + this.sb.ConnectionManager.ready(function (n, s) { + if (n) t(n, null); + else { + var o = e.Path.FRIENDS.replace( + "%s", + encodeURIComponent(s.userId) + ), + l = new Z({ limit: a, token: r }); + i.get(o, l, t); + } + }); + }, + }, + { + key: "getFriendChangeLogsByToken", + value: function (n, t) { + var i = this, + r = n.token; + this.sb.ConnectionManager.ready(function (n, a) { + if (n) t(n, null); + else { + var s = e.Path.FRIENDS_CHANGE_LOGS.replace( + "%s", + encodeURIComponent(a.userId) + ), + o = new Z(); + r && o.add("token", r), i.get(s, o, t); + } + }); + }, + }, + { + key: "addFriends", + value: function (n, t) { + var i = this, + r = n.userIds; + this.sb.ConnectionManager.ready(function (n, a) { + if (n) t(n, null); + else { + var s = e.Path.FRIENDS.replace( + "%s", + encodeURIComponent(a.userId) + ), + o = new Z({ user_ids: r }); + i.post(s, o, t); + } + }); + }, + }, + { + key: "deleteFriends", + value: function (n, t) { + var i = this, + r = n.userIds; + this.sb.ConnectionManager.ready(function (n, a) { + if (n) t(n, null); + else { + var s = e.Path.FRIENDS.replace( + "%s", + encodeURIComponent(a.userId) + ), + o = new Z({ user_ids: r }); + i.delete(s, o, t); + } + }); + }, + }, + { + key: "uploadFriendDiscoveries", + value: function (n, t) { + var i = this, + r = n.discoveries; + this.sb.ConnectionManager.ready(function (n, a) { + if (n) t(n, null); + else { + var s = e.Path.FRIENDS_DISCOVERIES.replace( + "%s", + encodeURIComponent(a.userId) + ), + o = []; + r.forEach(function (e) { + o.push({ + friend_discovery_key: e.friendDiscoveryKey, + friend_name: + "string" == typeof e.friendName || e.friendName + ? e.friendName + : null, + }); + }); + var l = new Z({ friend_discoveries: o }); + i.put(s, l, t); + } + }); + }, + }, + { + key: "deleteFriendDiscoveries", + value: function (n, t) { + var i = this, + r = n.discoveryKeys; + this.sb.ConnectionManager.ready(function (n, a) { + if (n) t(n, null); + else { + var s = e.Path.FRIENDS_DISCOVERIES.replace( + "%s", + encodeURIComponent(a.userId) + ), + o = new Z({ friend_discovery_keys: r }); + i.delete(s, o, t); + } + }); + }, + }, + { + key: "loadUserList", + value: function (n, t) { + var i = this, + r = n.token, + a = n.limit, + s = n.userIdsFilter, + o = n.metaDataKeyFilter, + l = n.metaDataValuesFilter, + u = n.nicknameStartsWithFilter; + this.sb.ConnectionManager.ready(function (n, c) { + if (n) t(n, null); + else { + var d = e.Path.USERS, + h = new Z({ token: r, limit: a }); + s && s.length > 0 && h.add("user_ids", s), + o && + l && + l.length > 0 && + (h.add("metadatakey", o), + h.add("metadatavalues_in", l)), + u && h.add("nickname_startswith", u), + i.get(d, h, t); + } + }); + }, + }, + { + key: "loadBlockedUserList", + value: function (n, t) { + var i = this, + r = n.token, + a = n.limit, + s = n.userIdsFilter; + this.sb.ConnectionManager.ready(function (n, o) { + if (n) t(n, null); + else { + var l = e.Path.USERS_USERID_BLOCK.replace( + "%s", + encodeURIComponent(o.userId) + ), + u = new Z({ token: r, limit: a }); + s && s.length > 0 && u.add("user_ids", s), i.get(l, u, t); + } + }); + }, + }, + { + key: "createUserMetaData", + value: function (n, t) { + var i = this, + r = n.metaData; + this.sb.ConnectionManager.ready(function (n, a) { + if (n) t(n, null); + else { + var s = e.Path.USERS_USERID_METADATA.replace( + "%s", + encodeURIComponent(a.userId) + ), + o = new Z({ metadata: r }); + i.post(s, o, t); + } + }); + }, + }, + { + key: "updateUserMetaData", + value: function (n, t) { + var i = this, + r = n.metaData, + a = n.upsert; + this.sb.ConnectionManager.ready(function (n, s) { + if (n) t(n, null); + else { + var o = e.Path.USERS_USERID_METADATA.replace( + "%s", + encodeURIComponent(s.userId) + ), + l = new Z({ metadata: r, upsert: a }); + i.put(o, l, t); + } + }); + }, + }, + { + key: "deleteUserMetaData", + value: function (n, t) { + var i = this, + r = n.metaDataKey; + this.sb.ConnectionManager.ready(function (n, a) { + if (n) t(n, null); + else { + var s = e.Path.USERS_USERID_METADATA_KEY.replace( + "%s", + encodeURIComponent(a.userId) + ).replace("%s", encodeURIComponent(r)); + i.delete(s, null, t); + } + }); + }, + }, + { + key: "deleteAllUserMetaData", + value: function (n, t) { + var i = this; + this.sb.ConnectionManager.ready(function (n, r) { + if (n) t(n, null); + else { + var a = e.Path.USERS_USERID_METADATA.replace( + "%s", + encodeURIComponent(r.userId) + ); + i.delete(a, null, t); + } + }); + }, + }, + { + key: "getMessageChangeLogs", + value: function (n, t) { + var i = this, + r = n.channelUrl, + a = n.ts, + s = n.timestamp, + o = n.token, + l = n.isOpenChannel, + u = n.includeMetaArray, + c = n.includeReactions, + d = n.includeThreadInfo, + h = n.replyTypeFilter, + p = n.includeParentMessageInfo, + f = n.includePollDetails; + this.sb.ConnectionManager.ready(function (n, y) { + if (n) t(n, null); + else { + var g = l + ? e.Path.OPENCHANNELS_CHANNELURL_MESSAGES_CHANGELOGS.replace( + "%s", + encodeURIComponent(r) + ) + : e.Path.GROUPCHANNELS_CHANNELURL_MESSAGES_CHANGELOGS.replace( + "%s", + encodeURIComponent(r) + ), + _ = new Z(); + o && _.add("token", o), + a && _.add("change_ts", a), + s && _.add("change_ts", s), + "boolean" == typeof u && + _.add("with_sorted_meta_array", u), + "boolean" == typeof c && _.add("include_reactions", c), + "boolean" == typeof d && _.add("include_thread_info", d), + "string" == typeof h && _.add("include_reply_type", h), + "boolean" == typeof p && + _.add("include_parent_message_info", p), + "boolean" == typeof f && _.add("include_poll_details", f), + i.get(g, _, t); + } + }); + }, + }, + { + key: "getMyMutedInfo", + value: function (n, t) { + var i = this, + r = n.channelUrl, + a = n.userId, + s = n.isGroupChannel; + this.sb.ConnectionManager.ready(function (n, o) { + if (n) t(n, null); + else { + var l = s + ? e.Path.GROUPCHANNELS_CHANNELURL_MUTE_USERID.replace( + "%s", + encodeURIComponent(r) + ).replace("%s", encodeURIComponent(a)) + : e.Path.OPENCHANNELS_CHANNELURL_MUTE_USERID.replace( + "%s", + encodeURIComponent(r) + ).replace("%s", encodeURIComponent(a)); + i.get(l, null, t); + } + }); + }, + }, + { + key: "loadBannedUserList", + value: function (n, t) { + var i = this, + r = n.token, + a = n.limit, + s = n.channelUrl, + o = n.isOpenChannel; + this.sb.ConnectionManager.ready(function (n, l) { + if (n) t(n, null); + else { + var u = o + ? e.Path.OPENCHANNELS_CHANNELURL_BAN.replace( + "%s", + encodeURIComponent(s) + ) + : e.Path.GROUPCHANNELS_CHANNELURL_BAN.replace( + "%s", + encodeURIComponent(s) + ), + c = new Z({ token: r, limit: a }); + i.get(u, c, t); + } + }); + }, + }, + { + key: "loadMutedUserList", + value: function (n, t) { + var i = this, + r = n.token, + a = n.limit, + s = n.channelUrl, + o = n.isOpenChannel; + this.sb.ConnectionManager.ready(function (n, l) { + if (n) t(n, null); + else { + var u = o + ? e.Path.OPENCHANNELS_CHANNELURL_MUTE.replace( + "%s", + encodeURIComponent(s) + ) + : e.Path.GROUPCHANNELS_CHANNELURL_MUTE.replace( + "%s", + encodeURIComponent(s) + ), + c = new Z({ token: r, limit: a }); + i.get(u, c, t); + } + }); + }, + }, + { + key: "getMessageList", + value: function (n, t) { + var i = this, + r = n.channel, + a = n.token, + s = n.tokenType, + o = n.isInclusive, + l = n.prevResultSize, + u = void 0 === l ? 0 : l, + c = n.nextResultSize, + d = void 0 === c ? 0 : c, + h = n.shouldReverse, + p = n.messageType, + f = n.customType, + y = n.customTypes, + g = n.senderUserIds, + _ = n.includeMetaArray, + m = n.includeReactions, + v = n.includeThreadInfo, + E = n.replyTypeFilter, + C = n.includeParentMessageInfo, + b = n.showSubchannelMessagesOnly, + U = n.includePollDetails, + A = n.rootMessageId, + I = n.parentMessageId; + this.sb.ConnectionManager.ready(function (n, l) { + if (n) t(n, null); + else { + var c = r.isOpenChannel() + ? e.Path.OPENCHANNELS_CHANNELURL_MESSAGES.replace( + "%s", + r.url + ) + : e.Path.GROUPCHANNELS_CHANNELURL_MESSAGES.replace( + "%s", + r.url + ), + S = new Z({ + is_sdk: String(!0), + prev_limit: String(u), + next_limit: String(d), + include: String(o), + reverse: String(h), + }); + "timestamp" === s + ? S.add("message_ts", a) + : "messageId" === s && S.add("message_id", String(a)), + p && S.add("message_type", String(p)), + Array.isArray(y) && + (0 === y.length && + ("string" == typeof f ? y.push(f) : y.push("*")), + S.add("custom_types", y)), + Array.isArray(g) && + g.length > 0 && + S.add("sender_ids", g), + "boolean" == typeof _ && + S.add("with_sorted_meta_array", _), + "boolean" == typeof m && S.add("include_reactions", m), + "boolean" == typeof v && S.add("include_thread_info", v), + "string" == typeof E && S.add("include_reply_type", E), + "boolean" == typeof C && + S.add("include_parent_message_info", C), + "boolean" == typeof b && + r.isOpenChannel() && + S.add("show_subchannel_messages_only", b), + "boolean" == typeof U && S.add("include_poll_details", U), + A && S.add("root_message_id", A), + I && S.add("parent_message_id", I), + i.get(c, S, t); + } + }); + }, + }, + { + key: "translateUserMessage", + value: function (n, t) { + var i = this, + r = n.channelUrl, + a = n.isOpenChannel, + s = n.messageId, + o = n.translationTargetLanguages; + this.sb.ConnectionManager.ready(function (n, l) { + if (n) t(n, null); + else { + var u = a + ? e.Path.OPENCHANNELS_CHANNELURL_MESSAGES_MESSAGEID_TRANSLATION.replace( + "%s", + encodeURIComponent(r) + ).replace("%s", s) + : e.Path.GROUPCHANNELS_CHANNELURL_MESSAGES_MESSAGEID_TRANSLATION.replace( + "%s", + encodeURIComponent(r) + ).replace("%s", s), + c = new Z({ target_langs: o }); + i.post(u, c, t); + } + }); + }, + }, + { + key: "getMessage", + value: function (n, t) { + var i = this, + r = n.channel, + a = n.messageId, + s = n.includeMetaArray, + o = n.includeReactions, + l = n.includeThreadInfo, + u = n.includeParentMessageInfo, + c = n.includePollDetails; + this.sb.ConnectionManager.ready(function (n, d) { + if (n) t(n, null); + else { + var h = r.isOpenChannel() + ? e.Path.OPENCHANNELS_CHANNELURL_MESSAGES_MESSAGEID.replace( + "%s", + encodeURIComponent(r.url) + ).replace("%s", encodeURIComponent(a)) + : e.Path.GROUPCHANNELS_CHANNELURL_MESSAGES_MESSAGEID.replace( + "%s", + encodeURIComponent(r.url) + ).replace("%s", encodeURIComponent(a)), + p = new Z({ is_sdk: String(!0) }); + "boolean" == typeof s && p.add("with_sorted_meta_array", s), + "boolean" == typeof o && p.add("include_reactions", o), + "boolean" == typeof l && p.add("include_thread_info", l), + "boolean" == typeof u && + p.add("include_parent_message_info", u), + "boolean" == typeof c && p.add("include_poll_details", c), + i.get(h, p, t); + } + }); + }, + }, + { + key: "deleteMessage", + value: function (n, t) { + var i = this, + r = n.channelUrl, + a = n.isOpenChannel, + s = n.messageId; + this.sb.ConnectionManager.ready(function (n, o) { + if (n) t(n, null); + else { + var l = a + ? e.Path.OPENCHANNELS_CHANNELURL_MESSAGES_MESSAGEID.replace( + "%s", + encodeURIComponent(r) + ).replace("%s", encodeURIComponent(s)) + : e.Path.GROUPCHANNELS_CHANNELURL_MESSAGES_MESSAGEID.replace( + "%s", + encodeURIComponent(r) + ).replace("%s", encodeURIComponent(s)); + i.delete(l, null, t); + } + }); + }, + }, + { + key: "muteUser", + value: function (n, t) { + var i = this, + r = n.channelUrl, + a = n.userId, + s = n.description, + o = n.seconds, + l = n.isGroupChannel; + this.sb.ConnectionManager.ready(function (n, u) { + if (n) t(n, null); + else { + var c = l + ? e.Path.GROUPCHANNELS_CHANNELURL_MUTE.replace( + "%s", + encodeURIComponent(r) + ) + : e.Path.OPENCHANNELS_CHANNELURL_MUTE.replace( + "%s", + encodeURIComponent(r) + ), + d = new Z({ user_id: a }); + o && (o > 0 || -1 !== o) && d.add("seconds", o), + s && d.add("description", s), + i.post(c, d, t); + } + }); + }, + }, + { + key: "unmuteUser", + value: function (n, t) { + var i = this, + r = n.channelUrl, + a = n.userId, + s = n.isGroupChannel; + this.sb.ConnectionManager.ready(function (n, o) { + if (n) t(n, null); + else { + var l = s + ? e.Path.GROUPCHANNELS_CHANNELURL_MUTE_USERID.replace( + "%s", + encodeURIComponent(r) + ).replace("%s", encodeURIComponent(a)) + : e.Path.OPENCHANNELS_CHANNELURL_MUTE_USERID.replace( + "%s", + encodeURIComponent(r) + ).replace("%s", encodeURIComponent(a)); + i.delete(l, null, t); + } + }); + }, + }, + { + key: "banUser", + value: function (n, t) { + var i = this, + r = n.channelUrl, + a = n.userId, + s = n.description, + o = n.seconds, + l = n.isGroupChannel; + this.sb.ConnectionManager.ready(function (n, u) { + if (n) t(n, null); + else { + var c = l + ? e.Path.GROUPCHANNELS_CHANNELURL_BAN.replace( + "%s", + encodeURIComponent(r) + ) + : e.Path.OPENCHANNELS_CHANNELURL_BAN.replace( + "%s", + encodeURIComponent(r) + ), + d = new Z({ user_id: a }); + s && d.add("description", s), + d.add("seconds", String(o)), + i.post(c, d, t); + } + }); + }, + }, + { + key: "unbanUser", + value: function (n, t) { + var i = this, + r = n.channelUrl, + a = n.userId, + s = n.isGroupChannel; + this.sb.ConnectionManager.ready(function (n, o) { + if (n) t(n, null); + else { + var l = s + ? e.Path.GROUPCHANNELS_CHANNELURL_BAN_USERID.replace( + "%s", + encodeURIComponent(r) + ).replace("%s", encodeURIComponent(a)) + : e.Path.OPENCHANNELS_CHANNELURL_BAN_USERID.replace( + "%s", + encodeURIComponent(r) + ).replace("%s", encodeURIComponent(a)); + i.delete(l, null, t); + } + }); + }, + }, + { + key: "getMetaCounters", + value: function (n, t) { + var i = this, + r = n.channelUrl, + a = n.isOpenChannel, + s = n.keys; + this.sb.ConnectionManager.ready(function (n, o) { + if (n) t(n, null); + else { + var l = a + ? e.Path.OPENCHANNELS_CHANNELURL_METACOUNTER.replace( + "%s", + encodeURIComponent(r) + ) + : e.Path.GROUPCHANNELS_CHANNELURL_METACOUNTER.replace( + "%s", + encodeURIComponent(r) + ), + u = new Z({ keys: s }); + i.get(l, u, t); + } + }); + }, + }, + { + key: "createMetaCounters", + value: function (n, t) { + var i = this, + r = n.channelUrl, + a = n.isOpenChannel, + s = n.metaCounter; + this.sb.ConnectionManager.ready(function (n, o) { + if (n) t(n, null); + else { + var l = a + ? e.Path.OPENCHANNELS_CHANNELURL_METACOUNTER.replace( + "%s", + encodeURIComponent(r) + ) + : e.Path.GROUPCHANNELS_CHANNELURL_METACOUNTER.replace( + "%s", + encodeURIComponent(r) + ), + u = new Z({ metacounter: s }); + i.post(l, u, t); + } + }); + }, + }, + { + key: "updateMetaCounters", + value: function (n, t) { + var i = this, + r = n.channelUrl, + a = n.isOpenChannel, + s = n.metaCounter, + o = n.upsert, + l = n.mode; + this.sb.ConnectionManager.ready(function (n, u) { + if (n) t(n, null); + else { + var c = a + ? e.Path.OPENCHANNELS_CHANNELURL_METACOUNTER.replace( + "%s", + encodeURIComponent(r) + ) + : e.Path.GROUPCHANNELS_CHANNELURL_METACOUNTER.replace( + "%s", + encodeURIComponent(r) + ), + d = new Z({ metacounter: s, upsert: o, mode: l }); + i.put(c, d, t); + } + }); + }, + }, + { + key: "deleteMetaCounter", + value: function (n, t) { + var i = this, + r = n.channelUrl, + a = n.isOpenChannel, + s = n.key; + this.sb.ConnectionManager.ready(function (n, o) { + if (n) t(n, null); + else { + var l = a + ? e.Path.OPENCHANNELS_CHANNELURL_METACOUNTER_KEY.replace( + "%s", + encodeURIComponent(r) + ).replace("%s", s) + : e.Path.GROUPCHANNELS_CHANNELURL_METACOUNTER_KEY.replace( + "%s", + encodeURIComponent(r) + ).replace("%s", s); + i.delete(l, null, t); + } + }); + }, + }, + { + key: "deleteAllMetaCounters", + value: function (n, t) { + var i = this, + r = n.channelUrl, + a = n.isOpenChannel; + this.sb.ConnectionManager.ready(function (n, s) { + if (n) t(n, null); + else { + var o = a + ? e.Path.OPENCHANNELS_CHANNELURL_METACOUNTER.replace( + "%s", + encodeURIComponent(r) + ) + : e.Path.GROUPCHANNELS_CHANNELURL_METACOUNTER.replace( + "%s", + encodeURIComponent(r) + ); + i.delete(o, null, t); + } + }); + }, + }, + { + key: "getMetaData", + value: function (n, t) { + var i = this, + r = n.channelUrl, + a = n.isOpenChannel, + s = n.keys; + this.sb.ConnectionManager.ready(function (n, o) { + if (n) t(n, null); + else { + var l = a + ? e.Path.OPENCHANNELS_CHANNELURL_METADATA.replace( + "%s", + encodeURIComponent(r) + ) + : e.Path.GROUPCHANNELS_CHANNELURL_METADATA.replace( + "%s", + encodeURIComponent(r) + ), + u = new Z({ keys: s, include_ts: !0 }); + i.get(l, u, t); + } + }); + }, + }, + { + key: "createMetaData", + value: function (n, t) { + var i = this, + r = n.channelUrl, + a = n.isOpenChannel, + s = n.metaData; + this.sb.ConnectionManager.ready(function (n, o) { + if (n) t(n, null); + else { + var l = a + ? e.Path.OPENCHANNELS_CHANNELURL_METADATA.replace( + "%s", + encodeURIComponent(r) + ) + : e.Path.GROUPCHANNELS_CHANNELURL_METADATA.replace( + "%s", + encodeURIComponent(r) + ), + u = new Z({ metadata: s, include_ts: !0 }); + i.post(l, u, t); + } + }); + }, + }, + { + key: "updateMetaData", + value: function (n, t) { + var i = this, + r = n.channelUrl, + a = n.isOpenChannel, + s = n.metaData, + o = n.upsert; + this.sb.ConnectionManager.ready(function (n, l) { + if (n) t(n, null); + else { + var u = a + ? e.Path.OPENCHANNELS_CHANNELURL_METADATA.replace( + "%s", + encodeURIComponent(r) + ) + : e.Path.GROUPCHANNELS_CHANNELURL_METADATA.replace( + "%s", + encodeURIComponent(r) + ), + c = new Z({ metadata: s, upsert: o, include_ts: !0 }); + i.put(u, c, t); + } + }); + }, + }, + { + key: "deleteMetaData", + value: function (n, t) { + var i = this, + r = n.channelUrl, + a = n.isOpenChannel, + s = n.key; + this.sb.ConnectionManager.ready(function (n, o) { + if (n) t(n, null); + else { + var l = a + ? e.Path.OPENCHANNELS_CHANNELURL_METADATA_KEY.replace( + "%s", + encodeURIComponent(r) + ).replace("%s", s) + : e.Path.GROUPCHANNELS_CHANNELURL_METADATA_KEY.replace( + "%s", + encodeURIComponent(r) + ).replace("%s", s), + u = new Z({ include_ts: !0 }); + i.delete(l, u, t); + } + }); + }, + }, + { + key: "deleteAllMetaData", + value: function (n, t) { + var i = this, + r = n.channelUrl, + a = n.isOpenChannel; + this.sb.ConnectionManager.ready(function (n, s) { + if (n) t(n, null); + else { + var o = a + ? e.Path.OPENCHANNELS_CHANNELURL_METADATA.replace( + "%s", + encodeURIComponent(r) + ) + : e.Path.GROUPCHANNELS_CHANNELURL_METADATA.replace( + "%s", + encodeURIComponent(r) + ), + l = new Z({ include_ts: !0 }); + i.delete(o, l, t); + } + }); + }, + }, + { + key: "loadOperatorList", + value: function (n, t) { + var i = this, + r = n.channelUrl, + a = n.isOpenChannel, + s = n.token, + o = n.limit; + this.sb.ConnectionManager.ready(function (n, l) { + if (n) t(n, null); + else { + var u = a + ? e.Path.OPENCHANNELS_OPERATORS.replace( + "%s", + encodeURIComponent(r) + ) + : e.Path.GROUPCHANNELS_OPERATORS.replace( + "%s", + encodeURIComponent(r) + ), + c = new Z({ token: s, limit: o }); + i.get(u, c, t); + } + }); + }, + }, + { + key: "getOpenChannel", + value: function (n, t) { + var i = this, + r = n.channelUrl, + a = n.internalCall; + this.sb.ConnectionManager.ready(function (n, s) { + if (n) t(n, null); + else { + var o = e.Path.OPENCHANNELS_CHANNELURL.replace( + "%s", + encodeURIComponent(r) + ), + l = new Z({}); + (l.internal = a === N.INTERNAL_CALL), i.get(o, l, t); + } + }); + }, + }, + { + key: "loadOpenChannelList", + value: function (n, t) { + var i = this, + r = n.token, + a = n.limit, + s = n.nameKeyword, + o = n.urlKeyword, + l = n.customTypes, + u = n.includeFrozen, + c = n.includeMetaData; + this.sb.ConnectionManager.ready(function (n, d) { + if (n) t(n, null); + else { + var h = e.Path.OPENCHANNELS, + p = new Z({ token: r, limit: a }); + s && p.add("name_contains", s), + o && p.add("url_contains", o), + l && l.length > 0 && p.add("custom_types", l), + "boolean" == typeof u && p.add("show_frozen", u), + "boolean" == typeof c && p.add("show_metadata", c), + i.get(h, p, t); + } + }); + }, + }, + { + key: "loadParticipantList", + value: function (n, t) { + var i = this, + r = n.token, + a = n.limit, + s = n.channelUrl; + this.sb.ConnectionManager.ready(function (n, o) { + if (n) t(n, null); + else { + var l = e.Path.OPENCHANNELS_CHANNELURL_PARTICIPANTS.replace( + "%s", + encodeURIComponent(s) + ), + u = new Z({ token: r, limit: a }); + i.get(l, u, t); + } + }); + }, + }, + { + key: "createOpenChannel", + value: function (n, t) { + var i = this, + r = n.name, + a = n.coverUrlOrImage, + s = n.data, + o = n.operatorUserIds, + l = n.customType, + u = n.channelUrl; + this.sb.ConnectionManager.ready(function (n, c) { + if (n) t(n, null); + else { + var d = e.Path.OPENCHANNELS, + h = new Z(); + "string" == typeof a && h.add("cover_url", a), + X.isFile(a) && h.add("cover_file", a), + null !== u && + "string" == typeof u && + h.add("channel_url", u), + null !== r && "string" == typeof r && h.add("name", r), + s && h.add("data", s), + o && + (Array.isArray(o) + ? h.add("operators", o) + : h.add("operators", [o])), + l && h.add("custom_type", l), + i.post(d, h, t); + } + }); + }, + }, + { + key: "updateOpenChannel", + value: function (n, t) { + var i = this, + r = n.channelUrl, + a = n.name, + s = n.coverUrlOrImage, + o = n.data, + l = n.operatorUserIds, + u = n.customType; + this.sb.ConnectionManager.ready(function (n, c) { + if (n) t(n, null); + else { + var d = e.Path.OPENCHANNELS_CHANNELURL.replace( + "%s", + encodeURIComponent(r) + ), + h = new Z(); + "string" == typeof s && h.add("cover_url", s), + X.isFile(s) && h.add("cover_file", s, s.name), + null !== a && "string" == typeof a && h.add("name", a), + null !== o && "string" == typeof o && h.add("data", o), + null !== l && + (Array.isArray(l) + ? h.add("operator_ids", l) + : h.add("operator_ids", [l])), + null !== u && + "string" == typeof u && + h.add("custom_type", u), + i.put(d, h, t); + } + }); + }, + }, + { + key: "deleteOpenChannel", + value: function (n, t) { + var i = this, + r = n.channelUrl; + this.sb.ConnectionManager.ready(function (n, a) { + if (n) t(n, null); + else { + var s = e.Path.OPENCHANNELS_CHANNELURL.replace( + "%s", + encodeURIComponent(r) + ); + i.delete(s, null, t); + } + }); + }, + }, + { + key: "getGroupChannel", + value: function (n, t) { + var i = this, + r = n.channelUrl, + a = n.showMember, + s = n.internalCall; + this.sb.ConnectionManager.ready(function (n, o) { + if (n) t(n, null); + else { + var l = e.Path.GROUPCHANNELS_CHANNELURL.replace( + "%s", + encodeURIComponent(r) + ), + u = new Z({ + show_member: a, + show_read_receipt: !0, + show_delivery_receipt: !0, + }); + (u.internal = s === N.INTERNAL_CALL), i.get(l, u, t); + } + }); + }, + }, + { + key: "loadGroupChannelList", + value: function (n, t) { + var i = this, + r = n.token, + a = n.limit, + s = n.includeEmpty, + o = n.order, + l = n.userIdsFilter, + u = n.nicknameContainsFilter, + c = n.channelNameContainsFilter, + d = n.channelUrlsFilter, + h = n.customTypesFilter, + p = n.customTypeStartsWithFilter, + f = n.memberStateFilter, + y = n.superChannelFilter, + g = n.publicChannelFilter, + _ = n.unreadChannelFilter, + m = n.metadataOrderKeyFilter, + v = n.metadataKey, + E = n.metadataValues, + C = n.metadataValueStartsWith, + b = n.hiddenChannelFilter, + U = n.searchFilter, + A = n.includeFrozen, + I = n.includeMetaData; + this.sb.ConnectionManager.ready(function (n, S) { + if (n) t(n, null); + else { + var k = e.Path.MYGROUPCHANNELS.replace( + "%s", + encodeURIComponent(S.userId) + ), + O = new Z({ + token: r, + limit: a, + order: o, + show_member: !0, + show_read_receipt: !0, + show_delivery_receipt: !0, + show_empty: String(s), + member_state_filter: f, + }); + h && h.length > 0 && O.add("custom_types", h), + u && O.add("members_nickname_contains", u), + c && O.add("name_contains", c), + U.hasOwnProperty("search_query") && + U.hasOwnProperty("search_fields") && + (O.add("search_query", U.search_query), + O.add("search_fields", U.search_fields)), + l.userIds && + l.userIds.length > 0 && + (l.includeMode + ? (O.add("members_include_in", l.userIds), + O.add("query_type", l.queryType.toUpperCase())) + : O.add("members_exactly_in", l.userIds)), + d && d.length > 0 && O.add("channel_urls", d), + O.add("super_mode", y), + O.add("public_mode", g), + O.add("unread_filter", _), + m && O.add("metadata_order_key", m), + v && O.add("metadata_key", v), + E && E.length > 0 && O.add("metadata_values", E), + C && O.add("metadata_value_startswith", C), + p && O.add("custom_type_startswith", p), + b && O.add("hidden_mode", b), + "boolean" == typeof A && O.add("show_frozen", A), + "boolean" == typeof I && O.add("show_metadata", I), + i.get(k, O, t); + } + }); + }, + }, + { + key: "loadPublicGroupChannelList", + value: function (n, t) { + var i = this, + r = n.token, + a = n.limit, + s = n.includeEmpty, + o = n.order, + l = n.channelNameContainsFilter, + u = n.channelUrlsFilter, + c = n.customTypesFilter, + d = n.customTypeStartsWithFilter, + h = n.superChannelFilter, + p = n.membershipFilter, + f = n.metadataOrderKeyFilter, + y = n.metadataKey, + g = n.metadataValues, + _ = n.metadataValueStartsWith, + m = n.includeFrozen, + v = n.includeMetaData; + this.sb.ConnectionManager.ready(function (n, E) { + if (n) t(n, null); + else { + var C = i.cls.GroupChannel, + b = e.Path.GROUPCHANNELS, + U = new Z({ + token: r, + limit: a, + order: o, + show_member: !0, + show_read_receipt: !0, + show_delivery_receipt: !0, + show_empty: String(s), + public_mode: C.PublicChannelFilter.PUBLIC, + public_membership_mode: p, + }); + c && c.length > 0 && U.add("custom_types", c), + l && U.add("name_contains", l), + u && u.length > 0 && U.add("channel_urls", u), + U.add("super_mode", h), + f && U.add("metadata_order_key", f), + y && U.add("metadata_key", y), + g && g.length > 0 && U.add("metadata_values", g), + _ && U.add("metadata_value_startswith", _), + d && U.add("custom_type_startswith", d), + "boolean" == typeof m && U.add("show_frozen", m), + "boolean" == typeof v && U.add("show_metadata", v), + i.get(b, U, t); + } + }); + }, + }, + { + key: "createGroupChannel", + value: function (n, t) { + var i = this, + r = n.isDistinct, + a = n.isSuper, + s = n.isBroadcast, + o = n.isPublic, + l = n.channelUrl, + u = n.isDiscoverable, + c = n.isStrict, + d = n.name, + h = n.data, + p = n.customType, + f = n.coverUrl, + y = n.coverImage, + g = n.accessCode, + _ = n.isEphemeral, + m = n._invitedUserIds, + v = void 0 === m ? [] : m, + E = n.operatorUserIds, + C = n.messageSurvivalSeconds; + this.sb.ConnectionManager.ready(function (n, m) { + if (n) t(n, null); + else { + var b = e.Path.GROUPCHANNELS, + U = new Z({ + user_ids: [m.userId] + .concat(I(v)) + .filter(function (e, n, t) { + return n === t.indexOf(e); + }), + }); + null !== f && "string" == typeof f && U.add("cover_url", f), + X.isFile(y) && U.add("cover_file", y, y.name), + null !== l && U.add("channel_url", l), + null !== r && U.add("is_distinct", r), + null !== a && U.add("is_super", a), + null !== s && U.add("is_broadcast", s), + null !== o && U.add("is_public", o), + null !== u && U.add("is_discoverable", u), + null !== c && U.add("strict", c), + null !== _ && U.add("is_ephemeral", _), + g && U.add("access_code", g), + null !== d && "string" == typeof d && U.add("name", d), + h && U.add("data", h), + p && U.add("custom_type", p), + Array.isArray(E) && + E.length > 0 && + U.add("operator_ids", E), + null !== C && + C > -1 && + U.add("message_survival_seconds", C), + i.post(b, U, t); + } + }); + }, + }, + { + key: "updateGroupChannel", + value: function (n, t) { + var i = this, + r = n.isDistinct, + a = n.isPublic, + s = n.channelUrl, + o = n.isDiscoverable, + l = n.name, + u = n.data, + c = n.customType, + d = n.coverUrl, + h = n.coverImage, + p = n.accessCode, + f = n.operatorUserIds, + y = n.messageSurvivalSeconds; + this.sb.ConnectionManager.ready(function (n, g) { + if (n) t(n, null); + else { + var _ = e.Path.GROUPCHANNELS_CHANNELURL.replace( + "%s", + encodeURIComponent(s) + ), + m = new Z(); + null !== r && m.add("is_distinct", r), + null !== a && m.add("is_public", a), + null !== o && m.add("is_discoverable", o), + null !== p && m.add("access_code", p), + null !== d && + "string" == typeof d && + m.add("cover_url", d), + X.isFile(h) && m.add("cover_file", h, h.name), + null !== l && "string" == typeof l && m.add("name", l), + null !== u && "string" == typeof u && m.add("data", u), + null !== c && + "string" == typeof c && + m.add("custom_type", c), + null !== f && + (Array.isArray(f) + ? m.add("operator_ids", f) + : f && m.add("operator_ids", [f])), + null !== y && + y > -1 && + m.add("message_survival_seconds", y), + i.put(_, m, t); + } + }); + }, + }, + { + key: "addOperators", + value: function (n, t) { + var i = this, + r = n.channelUrl, + a = n.isOpenChannel, + s = void 0 !== a && a, + o = n.operatorUserIds; + this.sb.ConnectionManager.ready(function (n, a) { + if (!n) { + var l = (s + ? e.Path.OPENCHANNELS_CHANNELURL_OPERATORS + : e.Path.GROUPCHANNELS_CHANNELURL_OPERATORS + ).replace("%s", encodeURIComponent(r)), + u = new Z({ operator_ids: o }); + i.post(l, u, t); + } + }); + }, + }, + { + key: "removeOperators", + value: function (n, t) { + var i = this, + r = n.channelUrl, + a = n.isOpenChannel, + s = void 0 !== a && a, + o = n.operatorUserIds; + this.sb.ConnectionManager.ready(function (n, a) { + if (!n) { + var l = (s + ? e.Path.OPENCHANNELS_CHANNELURL_OPERATORS + : e.Path.GROUPCHANNELS_CHANNELURL_OPERATORS + ).replace("%s", encodeURIComponent(r)), + u = new Z({ operator_ids: o }); + i.delete(l, u, t); + } + }); + }, + }, + { + key: "inviteToGroupChannel", + value: function (n, t) { + var i = this, + r = n.channelUrl, + a = n.userIds; + this.sb.ConnectionManager.ready(function (n, s) { + if (n) t(n, null); + else { + var o = e.Path.GROUPCHANNELS_CHANNELURL_INVITE.replace( + "%s", + encodeURIComponent(r) + ), + l = new Z({ user_ids: a }); + i.post(o, l, t); + } + }); + }, + }, + { + key: "acceptInvitation", + value: function (n, t) { + var i = this, + r = n.channelUrl, + a = n.accessCode; + this.sb.ConnectionManager.ready(function (n, s) { + if (n) t(n, null); + else { + var o = e.Path.GROUPCHANNELS_CHANNELURL_ACCEPT_INVITATION.replace( + "%s", + encodeURIComponent(r) + ), + l = new Z({ user_id: s.userId }); + a && l.add("access_code", a), i.put(o, l, t); + } + }); + }, + }, + { + key: "declineInvitation", + value: function (n, t) { + var i = this, + r = n.channelUrl; + this.sb.ConnectionManager.ready(function (n, a) { + if (n) t(n, null); + else { + var s = e.Path.GROUPCHANNELS_CHANNELURL_DECLINE_INVITATION.replace( + "%s", + encodeURIComponent(r) + ), + o = new Z({ user_id: a.userId }); + i.put(s, o, t); + } + }); + }, + }, + { + key: "joinGroupChannel", + value: function (n, t) { + var i = this, + r = n.channelUrl, + a = n.accessCode; + this.sb.ConnectionManager.ready(function (n, s) { + if (n) t(n, null); + else { + var o = e.Path.GROUPCHANNELS_CHANNELURL_JOIN.replace( + "%s", + encodeURIComponent(r) + ), + l = new Z({ user_id: s.userId }); + a && l.add("access_code", a), i.put(o, l, t); + } + }); + }, + }, + { + key: "leaveGroupChannel", + value: function (n, t) { + var i = this, + r = n.channelUrl; + this.sb.ConnectionManager.ready(function (n, a) { + if (n) t(n, null); + else { + var s = e.Path.GROUPCHANNELS_CHANNELURL_LEAVE.replace( + "%s", + encodeURIComponent(r) + ), + o = new Z({ user_id: a.userId }); + i.put(s, o, t); + } + }); + }, + }, + { + key: "hideGroupChannel", + value: function (n, t) { + var i = this, + r = n.channelUrl, + a = n.hidePreviousMessages, + s = n.allowAutoUnhide; + this.sb.ConnectionManager.ready(function (n, o) { + if (n) t(n, null); + else { + var l = e.Path.GROUPCHANNELS_CHANNELURL_HIDE.replace( + "%s", + encodeURIComponent(r) + ), + u = new Z({ + user_id: o.userId, + hide_previous_messages: a, + allow_auto_unhide: s, + }); + i.put(l, u, t); + } + }); + }, + }, + { + key: "unhideGroupChannel", + value: function (n, t) { + var i = this, + r = n.channelUrl; + this.sb.ConnectionManager.ready(function (n, a) { + if (n) t(n, null); + else { + var s = e.Path.GROUPCHANNELS_CHANNELURL_HIDE.replace( + "%s", + encodeURIComponent(r) + ); + i.delete(s, null, t); + } + }); + }, + }, + { + key: "freeze", + value: function (n, t) { + var i = this, + r = n.channelUrl, + a = n.isGroupChannel, + s = n.freezing; + this.sb.ConnectionManager.ready(function (n, o) { + if (n) t(n, null); + else { + var l = a + ? e.Path.GROUPCHANNELS_CHANNELURL_FREEZE.replace( + "%s", + encodeURIComponent(r) + ) + : e.Path.OPENCHANNELS_CHANNELURL_FREEZE.replace( + "%s", + encodeURIComponent(r) + ), + u = new Z({ freeze: s }); + i.put(l, u, t); + } + }); + }, + }, + { + key: "deleteGroupChannel", + value: function (n, t) { + var i = this, + r = n.channelUrl; + this.sb.ConnectionManager.ready(function (n, a) { + if (n) t(n, null); + else { + var s = e.Path.GROUPCHANNELS_CHANNELURL.replace( + "%s", + encodeURIComponent(r) + ); + i.delete(s, null, t); + } + }); + }, + }, + { + key: "loadMemberList", + value: function (n, t) { + var i = this, + r = n.channelUrl, + a = n.token, + s = n.limit, + o = n.mutedMemberFilter, + l = n.order, + u = n.memberStateFilter, + c = n.nicknameStartsWithFilter; + this.sb.ConnectionManager.ready(function (n, d) { + if (n) t(n, null); + else { + var h = e.Path.GROUPCHANNELS_MEMBERS.replace( + "%s", + encodeURIComponent(r) + ), + p = new Z({ + token: a, + limit: s, + order: l.toLowerCase(), + muted_member_filter: o.toLowerCase(), + member_state_filter: u, + show_member_is_muted: !0, + show_read_receipt: !0, + show_delivery_receipt: !0, + }); + c && p.add("nickname_startswith", c), i.get(h, p, t); + } + }); + }, + }, + { + key: "report", + value: function (n, t) { + var i = this, + r = n.channelUrl, + a = n.isOpenChannel, + s = n.reportCategory, + o = n.reportingUserId, + l = n.reportDescription; + this.sb.ConnectionManager.ready(function (n, u) { + if (n) t(n, null); + else { + var c = e.Path.REPORT_CHANNELS.replace( + "%s", + encodeURIComponent( + a ? "open_channels" : "group_channels" + ) + ).replace("%s", encodeURIComponent(r)), + d = new Z({ report_category: s }); + null != o && d.add("reporting_user_id", o), + null != l && d.add("report_description", l), + i.post(c, d, t); + } + }); + }, + }, + { + key: "reportUser", + value: function (n, t) { + var i = this, + r = n.offendingUserId, + a = n.channelUrl, + s = n.isOpenChannel, + o = n.reportCategory, + l = n.reportingUserId, + u = n.reportDescription; + this.sb.ConnectionManager.ready(function (n, c) { + if (n) t(n, null); + else { + var d = e.Path.REPORT_USERS.replace( + "%s", + encodeURIComponent(r) + ), + h = new Z({ + channel_url: a, + channel_type: s ? "open_channels" : "group_channels", + report_category: o, + }); + null != l && h.add("reporting_user_id", l), + null != u && h.add("report_description", u), + i.post(d, h, t); + } + }); + }, + }, + { + key: "reportMessage", + value: function (n, t) { + var i = this, + r = n.channelUrl, + a = n.isOpenChannel, + s = n.messageId, + o = n.reportCategory, + l = n.reportingUserId, + u = n.reportDescription, + c = n.offendingUserId; + this.sb.ConnectionManager.ready(function (n, d) { + if (n) t(n, null); + else { + var h = e.Path.REPORT_MESSAGES.replace( + "%s", + encodeURIComponent( + a ? "open_channels" : "group_channels" + ) + ) + .replace("%s", encodeURIComponent(r)) + .replace("%s", encodeURIComponent(s)), + p = new Z({ report_category: o, offending_user_id: c }); + null != l && p.add("reporting_user_id", l), + null != u && p.add("report_description", u), + i.post(h, p, t); + } + }); + }, + }, + { + key: "sendUserMessage", + value: function (n, t) { + var i = this, + r = n.channelUrl, + a = n.isOpenChannel, + s = n.message, + o = n.data, + l = n.customType, + u = n.translationTargetLanguages, + c = n.metaArrays, + d = n.mentionType, + h = n.mentionedUserIds, + p = n.pushNotificationDeliveryOption, + f = n.rootMessageId, + y = n.parentMessageId, + g = n.appleCriticalAlertOptions, + _ = n.pollId, + m = n.isReplyToChannel; + this.sb.ConnectionManager.ready(function (n, v) { + if (n) t(n, null); + else { + var E = i.cls.FileMessageParams, + C = a + ? e.Path.OPENCHANNELS_CHANNELURL_MESSAGES.replace( + "%s", + encodeURIComponent(r) + ) + : e.Path.GROUPCHANNELS_CHANNELURL_MESSAGES.replace( + "%s", + encodeURIComponent(r) + ), + b = new Z({ + message_type: "MESG", + user_id: v.userId, + message: s, + mention_type: d, + mentioned_user_ids: [], + }); + null != o && b.add("data", o), + null != l && b.add("custom_type", l), + u && b.add("translation_target_langs", u), + c && + c.length > 0 && + b.add( + "sorted_metaarray", + c.map(function (e) { + return e.encode(); + }) + ), + d === i.cls.BaseMessageParams.MentionType.CHANNEL + ? b.add("mentioned_user_ids", []) + : Array.isArray(h) && + h.length > 0 && + b.add("mentioned_user_ids", h), + p && + p !== E.PushNotificationDeliveryOption.DEFAULT && + b.add("push_option", p), + f && b.add("root_message_id", f), + y && b.add("parent_message_id", y), + g && b.add("apple_critical_alert_options", g.serialize()), + "number" == typeof _ + ? b.add("poll_id", _) + : null === _ && b.add("poll_id", -1), + m && b.add("reply_to_channel", m), + i.post(C, b, t); + } + }); + }, + }, + { + key: "sendFileMessage", + value: function (n, t) { + var i = this, + r = n.channelUrl, + a = n.isOpenChannel, + s = n.fileUrl, + o = n.fileName, + l = n.fileSize, + u = n.fileType, + c = n.data, + d = n.customType, + h = n.thumbnailSizes, + p = n.requireAuth, + f = n.metaArrays, + y = n.mentionType, + g = n.mentionedUserIds, + _ = n.pushNotificationDeliveryOption, + m = n.rootMessageId, + v = n.parentMessageId, + E = n.appleCriticalAlertOptions, + C = n.isReplyToChannel; + this.sb.ConnectionManager.ready(function (n, b) { + if (n) t(n, null); + else { + var U = i.cls.FileMessageParams, + A = a + ? e.Path.OPENCHANNELS_CHANNELURL_MESSAGES.replace( + "%s", + encodeURIComponent(r) + ) + : e.Path.GROUPCHANNELS_CHANNELURL_MESSAGES.replace( + "%s", + encodeURIComponent(r) + ), + I = new Z({ + message_type: "FILE", + user_id: b.userId, + url: s, + mention_type: y, + mentioned_user_ids: [], + }); + null != o && I.add("file_name", o), + null != l && I.add("file_size", l), + null != u && I.add("file_type", u), + null != c && I.add("custom_field", c), + null != d && I.add("custom_type", d), + h && I.add("thumbnails", h), + p && I.add("require_auth", p), + f && + f.length > 0 && + I.add( + "sorted_metaarray", + f.map(function (e) { + return e.encode(); + }) + ), + y === i.cls.BaseMessageParams.MentionType.CHANNEL + ? I.add("mentioned_user_ids", []) + : Array.isArray(g) && + g.length > 0 && + I.add("mentioned_user_ids", g), + _ && + _ !== U.PushNotificationDeliveryOption.DEFAULT && + I.add("push_option", _), + m && I.add("root_message_id", m), + v && I.add("parent_message_id", v), + E && I.add("apple_critical_alert_options", E.serialize()), + C && I.add("reply_to_channel", C), + i.post(A, I, t); + } + }); + }, + }, + { + key: "uploadFile", + value: function (n, t) { + var i = this, + r = n.file, + a = n.thumbnailSizes, + s = n.channelUrl, + o = n.progressHandler, + l = n.reqId; + this.sb.ConnectionManager.ready(function (n, u) { + if (n) t(n, null); + else { + var c = M.get(i.sb._iid).container.appInfo; + if (c) + if ( + ("number" == typeof r.size || r.size || (r.size = 0), + "number" == typeof r.size) + ) + if (r.size <= c.uploadSizeLimit) { + var d = e.Path.STORAGE_FILE, + h = new Z(); + if ( + (h.add("file", r, r.name), + s && + "string" == typeof s && + h.add("channel_url", s), + a) + ) + for (var p = 0; p < a.length; p++) + h.add( + "thumbnail" + (p + 1), + a[p].maxWidth + "," + a[p].maxHeight + ); + (h.upload.reqId = l), + (h.upload.deleteRequest = function () { + var e = i.cls.FileMessageQueue; + e.uploadRequest[l] && delete e.uploadRequest[l]; + }), + (h.upload.progressHandler = function (e) { + o && "function" == typeof o && o(e, l); + }), + i.post(d, h, t); + } else + t( + new P( + "The file size exceeded the upload limit: ".concat( + c.uploadSizeLimit + ), + P.FILE_SIZE_LIMIT_EXCEEDED + ), + null + ); + else + t( + new P( + "Invalid file size: ".concat(r.size), + P.INVALID_PARAMETER + ), + null + ); + else + t( + new P( + "Connection should be made first.", + P.CONNECTION_REQUIRED + ), + null + ); + } + }); + }, + }, + { + key: "registerScheduledUserMessage", + value: function (n, t) { + var i = this, + r = n.groupChannelParams, + a = n.channelUrl, + s = n.isOpenChannel; + this.sb.ConnectionManager.ready(function (n, o) { + if (n) t(n, null); + else { + var l = s + ? e.Path.OPENCHANNELS_CHANNELURL_SCHEDULED_MESSAGES.replace( + "%s", + encodeURIComponent(a) + ) + : e.Path.GROUPCHANNELS_CHANNELURL_SCHEDULED_MESSAGES.replace( + "%s", + encodeURIComponent(a) + ), + u = new Z({ + scheduled_dt: r._getScheduleString(), + user_id: o.userId, + message: r.message, + data: r.data, + }); + r.customType && u.add("custom_type", r.customType), + r.metaArrayKeys && + Object.keys(r.metaArrayKeys).length > 0 && + u.add("metaarray", r.metaArrayKeys), + r.mentionType && u.add("mention_type", r._mentionType), + r._mentionType === + i.cls.BaseMessageParams.MentionType.CHANNEL + ? u.add("mentioned_user_ids", []) + : Array.isArray(r._mentionedUserIds) && + r._mentionedUserIds.length > 0 && + u.add("mentioned_user_ids", r._mentionedUserIds), + r.translationTargetLanguages && + r.translationTargetLanguages.length > 0 && + u.add( + "translation_target_langs", + r.translationTargetLanguages + ), + r.pushNotificationDeliveryOption && + r.pushNotificationDeliveryOption !== + i.cls.BaseMessageParams.PushNotificationDeliveryOption + .DEFAULT && + u.add("push_option", r.pushNotificationDeliveryOption), + r.appleCriticalAlertOptions && + u.add( + "apple_critical_alert_options", + r.appleCriticalAlertOptions.serialize() + ), + i.post(l, u, t); + } + }); + }, + }, + { + key: "getMyPushTriggerOption", + value: function (n, t) { + var i = this, + r = n.channelUrl; + this.sb.ConnectionManager.ready(function (n, a) { + if (n) t(n, null); + else { + var s = e.Path.USERS_USERID_PUSHPREFERENCE_CHANNELURL.replace( + "%s", + encodeURIComponent(a.userId) + ).replace("%s", encodeURIComponent(r)); + i.get(s, null, t); + } + }); + }, + }, + { + key: "setMyPushTriggerOption", + value: function (n, t) { + var i = this, + r = n.channelUrl, + a = n.pushTriggerOption, + s = n.enable; + this.sb.ConnectionManager.ready(function (n, o) { + if (n) t(n, null); + else { + var l = e.Path.USERS_USERID_PUSHPREFERENCE_CHANNELURL.replace( + "%s", + encodeURIComponent(o.userId) + ).replace("%s", encodeURIComponent(r)), + u = new Z(); + a && u.add("push_trigger_option", a), + "boolean" == typeof s && u.add("enable", s), + i.put(l, u, t); + } + }); + }, + }, + { + key: "setMyCountPreference", + value: function (n, t) { + var i = this, + r = n.channelUrl, + a = n.countPreference; + this.sb.ConnectionManager.ready(function (n, s) { + if (n) t(n, null); + else { + var o = e.Path.USERS_COUNT_PREFERENCE.replace( + "%s", + encodeURIComponent(s.userId) + ).replace("%s", encodeURIComponent(r)), + l = new Z({ count_preference: a }); + i.put(o, l, t); + } + }); + }, + }, + { + key: "resetMyHistory", + value: function (n, t) { + var i = this, + r = n.channelUrl; + this.sb.ConnectionManager.ready(function (n, a) { + if (n) t(n, null); + else { + var s = e.Path.GROUPCHANNELS_RESET_USER_HISTORY.replace( + "%s", + encodeURIComponent(r) + ); + i.put(s, null, t); + } + }); + }, + }, + { + key: "addReaction", + value: function (n, t) { + var i = this, + r = n.isGroupChannel, + a = n.channelUrl, + s = n.messageId, + o = n.key; + this.sb.ConnectionManager.ready(function (n, l) { + if (n) t(n, null); + else { + var u = r + ? e.Path.GROUPCHANNELS_CHANNELURL_MESSAGES_MESSAGEID_REACTION.replace( + "%s", + encodeURIComponent(a) + ).replace("%s", encodeURIComponent(s)) + : e.Path.OPENCHANNELS_CHANNELURL_MESSAGES_MESSAGEID_REACTION.replace( + "%s", + encodeURIComponent(a) + ).replace("%s", encodeURIComponent(s)), + c = new Z({ reaction: o }); + i.post(u, c, t); + } + }); + }, + }, + { + key: "deleteReaction", + value: function (n, t) { + var i = this, + r = n.isGroupChannel, + a = n.channelUrl, + s = n.messageId, + o = n.key; + this.sb.ConnectionManager.ready(function (n, l) { + if (n) t(n, null); + else { + var u = r + ? e.Path.GROUPCHANNELS_CHANNELURL_MESSAGES_MESSAGEID_REACTION.replace( + "%s", + encodeURIComponent(a) + ).replace("%s", encodeURIComponent(s)) + : e.Path.OPENCHANNELS_CHANNELURL_MESSAGES_MESSAGEID_REACTION.replace( + "%s", + encodeURIComponent(a) + ).replace("%s", encodeURIComponent(s)), + c = new Z({ reaction: o }); + i.delete(u, c, t); + } + }); + }, + }, + { + key: "getAllEmoji", + value: function (n) { + var t = this; + this.sb.ConnectionManager.ready(function (i, r) { + i ? n(i, null) : t.get(e.Path.EMOJI_CATEGORIES, null, n); + }); + }, + }, + { + key: "getEmojiCategory", + value: function (n, t) { + var i = this, + r = n.categoryId; + this.sb.ConnectionManager.ready(function (n, a) { + if (n) t(n, null); + else { + var s = e.Path.EMOJI_CATEGORIES_CATEGORYID.replace("%s", r); + i.get(s, null, t); + } + }); + }, + }, + { + key: "getEmoji", + value: function (n, t) { + var i = this, + r = n.emojiKey; + this.sb.ConnectionManager.ready(function (n, a) { + if (n) t(n, null); + else { + var s = e.Path.EMOJIS_EMOJIKEY.replace("%s", r); + i.get(s, null, t); + } + }); + }, + }, + { + key: "getAllowFriendDiscovery", + value: function (n) { + var t = this; + this.sb.ConnectionManager.ready(function (i, r) { + if (i) n(i, null); + else { + var a = e.Path.USERS_USERID_ALLOW_FRIEND_DISCOVERY.replace( + "%s", + encodeURIComponent(r.userId) + ); + t.get(a, null, n); + } + }); + }, + }, + { + key: "setAllowFriendDiscovery", + value: function (n, t) { + var i = this, + r = n.allowFriendDiscovery; + this.sb.ConnectionManager.ready(function (n, a) { + if (n) t(n, null); + else { + var s = e.Path.USERS_USERID_ALLOW_FRIEND_DISCOVERY.replace( + "%s", + encodeURIComponent(a.userId) + ), + o = new Z(); + "boolean" == typeof r && o.add("allow_friend_discovery", r), + i.put(s, o, t); + } + }); + }, + }, + { + key: "getPollList", + value: function (n, t) { + var i = this, + r = n.channelUrl, + a = n.token, + s = n.limit; + this.sb.ConnectionManager.ready(function (n, o) { + if (n) t(n, null); + else { + var l = e.Path.POLLS, + u = new Z({ channel_url: r }); + a && u.add("token", a), + s && u.add("limit", s), + i.get(l, u, t); + } + }); + }, + }, + { + key: "getPoll", + value: function (n, t) { + var i = this, + r = n.channelUrl, + a = n.pollId, + s = n.showPartialVoters; + this.sb.ConnectionManager.ready(function (n, o) { + if (n) t(n, null); + else { + var l = e.Path.POLLS_POLLID.replace("%s", a), + u = new Z({ channel_url: r }); + "boolean" == typeof s && + u.add("show_partial_voter_list", s), + i.get(l, u, t); + } + }); + }, + }, + { + key: "createPoll", + value: function (n, t) { + var i = this, + r = n.title, + a = n.options, + s = n.data, + o = n.isAnonymous, + l = n.allowUserSuggestion, + u = n.allowMultipleVotes, + c = n.closeAt; + this.sb.ConnectionManager.ready(function (n, d) { + if (n) t(n, null); + else { + var h = e.Path.POLLS, + p = new Z({ title: r, options: a }); + "string" == typeof s && p.add("data", s), + "boolean" == typeof o && p.add("is_anonymous", o), + "boolean" == typeof l && + p.add("allow_user_suggestion", l), + "boolean" == typeof u && p.add("allow_multiple_votes", u), + "number" == typeof c && p.add("close_at", c), + i.post(h, p, t); + } + }); + }, + }, + { + key: "updatePoll", + value: function (n, t) { + var i = this, + r = n.pollId, + a = n.title, + s = n.options, + o = n.data, + l = n.isAnonymous, + u = n.allowUserSuggestion, + c = n.allowMultipleVotes, + d = n.closeAt; + this.sb.ConnectionManager.ready(function (n, h) { + if (n) t(n, null); + else { + var p = e.Path.POLLS_POLLID.replace("%s", r), + f = new Z(); + "string" == typeof a && f.add("title", a), + Array.isArray(s) && f.add("options", s), + "string" == typeof o && f.add("data", o), + "boolean" == typeof l && f.add("is_anonymous", l), + "boolean" == typeof u && + f.add("allow_user_suggestion", u), + "boolean" == typeof c && f.add("allow_multiple_votes", c), + "number" == typeof d && f.add("close_at", d), + i.put(p, f, t); + } + }); + }, + }, + { + key: "deletePoll", + value: function (n, t) { + var i = this, + r = n.pollId; + this.sb.ConnectionManager.ready(function (n, a) { + if (n) t(n, null); + else { + var s = e.Path.POLLS_POLLID.replace("%s", r); + i.delete(s, null, t); + } + }); + }, + }, + { + key: "votePoll", + value: function (n, t) { + var i = this, + r = n.channelUrl, + a = n.pollId, + s = n.optionIds; + this.sb.ConnectionManager.ready(function (n, o) { + if (n) t(n, null); + else { + var l = e.Path.POLLS_POLLID_VOTE.replace("%s", a), + u = new Z({ channel_url: r }); + Array.isArray(s) && u.add("option_ids", s), i.put(l, u, t); + } + }); + }, + }, + { + key: "closePoll", + value: function (n, t) { + var i = this, + r = n.pollId; + this.sb.ConnectionManager.ready(function (n, a) { + if (n) t(n, null); + else { + var s = e.Path.POLLS_POLLID_CLOSE.replace("%s", r); + i.put(s, null, t); + } + }); + }, + }, + { + key: "getPollOption", + value: function (n, t) { + var i = this, + r = n.channelUrl, + a = n.pollId, + s = n.optionId; + this.sb.ConnectionManager.ready(function (n, o) { + if (n) t(n, null); + else { + var l = e.Path.POLLS_POLLID_OPTIONS_OPTIONID.replace( + "%s", + a + ).replace("%s", s), + u = new Z({ channel_url: r }); + i.get(l, u, t); + } + }); + }, + }, + { + key: "addPollOption", + value: function (n, t) { + var i = this, + r = n.channelUrl, + a = n.pollId, + s = n.text; + this.sb.ConnectionManager.ready(function (n, o) { + if (n) t(n, null); + else { + var l = e.Path.POLLS_POLLID_OPTIONS.replace("%s", a), + u = new Z({ channel_url: r, text: s }); + i.post(l, u, t); + } + }); + }, + }, + { + key: "updatePollOption", + value: function (n, t) { + var i = this, + r = n.pollId, + a = n.optionId, + s = n.text; + this.sb.ConnectionManager.ready(function (n, o) { + if (n) t(n, null); + else { + var l = e.Path.POLLS_POLLID_OPTIONS_OPTIONID.replace( + "%s", + r + ).replace("%s", a), + u = new Z({ text: s }); + i.put(l, u, t); + } + }); + }, + }, + { + key: "deletePollOption", + value: function (n, t) { + var i = this, + r = n.pollId, + a = n.optionId; + this.sb.ConnectionManager.ready(function (n, s) { + if (n) t(n, null); + else { + var o = e.Path.POLLS_POLLID_OPTIONS_OPTIONID.replace( + "%s", + r + ).replace("%s", a); + i.delete(o, null, t); + } + }); + }, + }, + { + key: "getPollOptionVoterList", + value: function (n, t) { + var i = this, + r = n.channelUrl, + a = n.pollId, + s = n.optionId, + o = n.token, + l = n.limit; + this.sb.ConnectionManager.ready(function (n, u) { + if (n) t(n, null); + else { + var c = e.Path.POLLS_POLLID_OPTIONS_OPTIONID_VOTERS.replace( + "%s", + a + ).replace("%s", s), + d = new Z({ channel_url: r }); + o && d.add("token", o), + l && d.add("limit", l), + i.get(c, d, t); + } + }); + }, + }, + ], + [ + { + key: "Path", + get: function () { + return { + USERS: "/users", + USERS_USERID: "/users/%s", + USERS_USERID_LOGIN: "/users/%s/login", + USERS_USERID_SESSION_KEY: "/users/%s/session_key", + USERS_USERID_METADATA: "/users/%s/metadata", + USERS_USERID_METADATA_KEY: "/users/%s/metadata/%s", + USERS_USERID_MARKASREADALL: "/users/%s/mark_as_read_all", + USERS_USERID_MY_GROUP_CHANNEL_CHANGELOGS: + "/users/%s/my_group_channels/changelogs", + USERS_USERID_UNREAD_ITEM_COUNT: "/users/%s/unread_item_count", + USERS_USERID_UNREAD_MESSAGE_COUNT: + "/users/%s/unread_message_count", + USERS_USERID_UNREAD_CHANNEL_COUNT: + "/users/%s/unread_channel_count", + USERS_USERID_PUSH_GCM_TOKEN: "/users/%s/push/gcm/%s", + USERS_USERID_PUSH_GCM: "/users/%s/push/gcm", + USERS_USERID_PUSH_DEVICE_TOKENS: + "/users/%s/push/%s/device_tokens", + USERS_USERID_PUSHPREFERENCE_CHANNELURL: + "/users/%s/push_preference/%s", + USERS_USERID_PUSHPREFERENCE: "/users/%s/push_preference/", + USERS_USERID_PUSH_TEMPLATE: "/users/%s/push/template", + USERS_USERID_BLOCK: "/users/%s/block", + USERS_USERID_BLOCK_TARGETID: "/users/%s/block/%s", + USERS_USERID_PUSH_APNS_TOKEN: "/users/%s/push/apns/%s", + USERS_USERID_PUSH_APNS: "/users/%s/push/apns", + USERS_USERID_PUSH: "/users/%s/push", + USERS_USERID_GROUP_CHANNEL_INVITATION_PREFERENCE: + "/users/%s/channel_invitation_preference", + USERS_USERID_GROUP_CHANNEL_COUNT: + "/users/%s/group_channel_count", + USERS_COUNT_PREFERENCE: "/users/%s/count_preference/%s", + USERS_USERID_ALLOW_FRIEND_DISCOVERY: + "/users/%s/allow_friend_discovery", + OPENCHANNELS: "/open_channels", + OPENCHANNELS_CHANNELURL: "/open_channels/%s", + OPENCHANNELS_CHANNELURL_MESSAGES: + "/open_channels/%s/messages", + OPENCHANNELS_CHANNELURL_MESSAGES_MESSAGEID: + "/open_channels/%s/messages/%s", + OPENCHANNELS_CHANNELURL_MESSAGES_MESSAGEID_TRANSLATION: + "/open_channels/%s/messages/%s/translation", + OPENCHANNELS_CHANNELURL_MESSAGES_CHANGELOGS: + "/open_channels/%s/messages/changelogs", + OPENCHANNELS_CHANNELURL_SCHEDULED_MESSAGES: + "/open_channels/%s/scheduled_messages", + OPENCHANNELS_CHANNELURL_PARTICIPANTS: + "/open_channels/%s/participants", + OPENCHANNELS_CHANNELURL_OPERATORS: + "/open_channels/%s/operators", + OPENCHANNELS_CHANNELURL_METADATA: + "/open_channels/%s/metadata", + OPENCHANNELS_CHANNELURL_METADATA_KEY: + "/open_channels/%s/metadata/%s", + OPENCHANNELS_CHANNELURL_METACOUNTER: + "/open_channels/%s/metacounter", + OPENCHANNELS_CHANNELURL_METACOUNTER_KEY: + "/open_channels/%s/metacounter/%s", + OPENCHANNELS_CHANNELURL_BAN: "/open_channels/%s/ban", + OPENCHANNELS_CHANNELURL_BAN_USERID: + "/open_channels/%s/ban/%s", + OPENCHANNELS_CHANNELURL_MUTE: "/open_channels/%s/mute", + OPENCHANNELS_CHANNELURL_MUTE_USERID: + "/open_channels/%s/mute/%s", + OPENCHANNELS_CHANNELURL_FREEZE: "/open_channels/%s/freeze", + OPENCHANNELS_OPERATORS: "/open_channels/%s/operators", + OPENCHANNELS_CHANNELURL_MESSAGES_MESSAGEID_REACTION: + "/open_channels/%s/messages/%s/reactions", + GROUPCHANNELS: "/group_channels", + MYGROUPCHANNELS: "/users/%s/my_group_channels", + GROUPCHANNELS_CHANNELURL: "/group_channels/%s", + GROUPCHANNELS_CHANNELURL_INVITE: "/group_channels/%s/invite", + GROUPCHANNELS_CHANNELURL_ACCEPT_INVITATION: + "/group_channels/%s/accept", + GROUPCHANNELS_CHANNELURL_DECLINE_INVITATION: + "/group_channels/%s/decline", + GROUPCHANNELS_CHANNELURL_HIDE: "/group_channels/%s/hide", + GROUPCHANNELS_CHANNELURL_LEAVE: "/group_channels/%s/leave", + GROUPCHANNELS_CHANNELURL_JOIN: "/group_channels/%s/join", + GROUPCHANNELS_CHANNELURL_OPERATORS: + "/group_channels/%s/operators", + GROUPCHANNELS_CHANNELURL_MESSAGES: + "/group_channels/%s/messages", + GROUPCHANNELS_CHANNELURL_MESSAGES_MARKASREAD: + "/group_channels/%s/messages/mark_as_read", + GROUPCHANNELS_CHANNELURL_MESSAGES_MARKASDELIVERED: + "/group_channels/%s/messages/mark_as_delivered", + GROUPCHANNELS_CHANNELURL_MESSAGES_TOTALCOUNT: + "/group_channels/%s/messages/total_count", + GROUPCHANNELS_CHANNELURL_MESSAGES_UNREADCOUNT: + "/group_channels/%s/messages/unread_count", + GROUPCHANNELS_CHANNELURL_MESSAGES_MESSAGEID: + "/group_channels/%s/messages/%s", + GROUPCHANNELS_CHANNELURL_MESSAGES_MESSAGEID_TRANSLATION: + "/group_channels/%s/messages/%s/translation", + GROUPCHANNELS_CHANNELURL_MESSAGES_CHANGELOGS: + "/group_channels/%s/messages/changelogs", + GROUPCHANNELS_CHANNELURL_SCHEDULED_MESSAGES: + "/group_channels/%s/scheduled_messages", + GROUPCHANNELS_CHANNELURL_MEMBERS: + "/group_channels/%s/members", + GROUPCHANNELS_CHANNELURL_METADATA: + "/group_channels/%s/metadata", + GROUPCHANNELS_CHANNELURL_METADATA_KEY: + "/group_channels/%s/metadata/%s", + GROUPCHANNELS_CHANNELURL_METACOUNTER: + "/group_channels/%s/metacounter", + GROUPCHANNELS_CHANNELURL_METACOUNTER_KEY: + "/group_channels/%s/metacounter/%s", + GROUPCHANNELS_RESET_USER_HISTORY: + "/group_channels/%s/reset_user_history", + GROUPCHANNELS_OPERATORS: "/group_channels/%s/operators", + GROUPCHANNELS_MEMBERS: "/group_channels/%s/members", + GROUPCHANNELS_CHANNELURL_BAN: "/group_channels/%s/ban", + GROUPCHANNELS_CHANNELURL_BAN_USERID: + "/group_channels/%s/ban/%s", + GROUPCHANNELS_CHANNELURL_MUTE: "/group_channels/%s/mute", + GROUPCHANNELS_CHANNELURL_MUTE_USERID: + "/group_channels/%s/mute/%s", + GROUPCHANNELS_CHANNELURL_FREEZE: "/group_channels/%s/freeze", + GROUPCHANNELS_CHANNELURL_MESSAGES_MESSAGEID_REACTION: + "/group_channels/%s/messages/%s/reactions", + STORAGE_FILE: "/storage/file", + STORAGE_PROFILE: "/storage/profile_image", + FRIENDS: "/users/%s/friends", + FRIENDS_CHANGE_LOGS: "/users/%s/friends/changelogs", + FRIENDS_DISCOVERIES: "/users/%s/friend_discoveries", + SEARCH_MESSAGE: "/search/messages", + REPORT_USERS: "/report/users/%s", + REPORT_CHANNELS: "/report/%s/%s", + REPORT_MESSAGES: "/report/%s/%s/messages/%s", + EMOJIS_EMOJIKEY: "/emojis/%s", + EMOJI_CATEGORIES: "/emoji_categories", + EMOJI_CATEGORIES_CATEGORYID: "/emoji_categories/%s", + POLLS: "/polls", + POLLS_POLLID: "/polls/%s", + POLLS_POLLID_VOTE: "/polls/%s/vote", + POLLS_POLLID_CLOSE: "/polls/%s/close", + POLLS_POLLID_OPTIONS: "/polls/%s/options", + POLLS_POLLID_OPTIONS_OPTIONID: "/polls/%s/options/%s", + POLLS_POLLID_OPTIONS_OPTIONID_VOTERS: + "/polls/%s/options/%s/voters", + }; + }, + }, + ] + ), + e + ); + })(), + ne = (function () { + function e(n, t) { + c(this, e), + (this.sb = n), + (this.ws = null), + (this.wsHost = null), + (this.WebSocket = null), + (this.handler = t || new e.ConnectionHandler()), + (this.explicitDisconnect = !1), + (this.lastActiveMillis = 0); + try { + this.WebSocket = + "undefined" == typeof WebSocket ? s.default : WebSocket; + } catch (e) { + this.WebSocket = WebSocket; + } + } + return ( + h(e, [ + { + key: "connect", + value: function (e, n, t) { + var i = this; + V.debug("`WebSocketClient.connect` called."); + var r = M.get(this.sb._iid).container, + a = r.pinger, + s = r.auth, + o = r.extensions, + l = r.getUserAgentWithExtensions, + u = r.sessionManager; + this.wsHost = t; + try { + var c = + "/?p=JS&pv=" + + encodeURIComponent(N.OS_VERSION) + + "&sv=" + + encodeURIComponent(N.SDK_VERSION) + + "&ai=" + + encodeURIComponent(this.sb.getApplicationId()); + if ( + (s.sessionKey + ? (c += "&key=" + encodeURIComponent(s.sessionKey)) + : (c += + "&user_id=" + + encodeURIComponent(e) + + "&access_token=" + + encodeURIComponent(n)), + (c += "&active=1"), + (c += "&SB-User-Agent=" + encodeURIComponent(l(o))), + (c += + "&Request-Sent-Timestamp=" + + new Date().getTime().toString()), + (c += + "&include_extra_data=" + + encodeURIComponent( + [ + "premium_feature_list", + "file_upload_size_limit", + "application_attributes", + "emoji_hash", + ].join(",") + )), + u.handler && (c += "&expiring_session=1"), + this.sb.Options.includePollDetails && + (c += "&include_poll_details=1"), + (this.ws = new this.WebSocket(this.wsHost + c)), + !this.ws) + ) + return ( + (this.sb.isReconnectingOnError = !0), + void this.handler.onError("ws does not exist.") + ); + } catch (e) { + return ( + (this.sb.isReconnectingOnError = !0), + void this.handler.onError(e) + ); + } + try { + this.sb.getDebugMode() && + "undefined" != typeof window && + (window.ws = this.ws); + } catch (e) { + V.debug("`window` object does not exist."); + } + var d = !1; + (this.ws.onopen = function (e) { + V.debug("`WebSocket.onopen` called."), i.handler.onOpen(e); + }), + (this.ws.onmessage = function (e) { + i.active(); + for (var n = e.data.split("\n"), t = 0; t < n.length; t++) { + var r = n[t]; + if (r && "string" == typeof r) { + try { + if ("PONG" === r.substring(0, 4)) { + a.pong(); + continue; + } + } catch (e) { + V.debug( + "`WebSocket.onmessage` command check error:", + e + ); + } + i.handler.onMessage(r); + } + } + }), + (this.ws.onerror = function (e) { + V.debug("`WebSocket.onerror` called:", e), + a && a.stop(), + (d = !0), + (i.sb.isReconnectingOnError = !0), + i.handler.onError(e); + }), + (this.ws.onclose = function (e) { + V.group("`WebSocket.onclose` called.", [ + { level: V.supportedLogLevels.DEBUG, messages: ["e", e] }, + { + level: V.supportedLogLevels.DEBUG, + messages: ["explicitDisconnect", i.explicitDisconnect], + }, + ]), + a && a.stop(), + i.explicitDisconnect + ? i.handler.onClose(e) + : d || i.handler.onError(e), + (i.explicitDisconnect = !1); + }); + }, + }, + { + key: "disconnect", + value: function (e, n) { + V.group("`WebSocketClient.onclose` called.", [ + { + level: V.supportedLogLevels.DEBUG, + messages: ["explicit", e], + }, + ]); + var t = M.get(this.sb._iid).container.pinger; + t && t.stop(), + (this.explicitDisconnect = !0 === e), + this.ws && + ((this.ws.onopen = function () {}), + (this.ws.onmessage = function () {}), + (this.ws.onclose = function () { + n && n(); + }), + (this.ws.onerror = function () {}), + this.ws.close(), + (this.ws = null)), + this.explicitDisconnect + ? this.handler.onClose() + : this.handler.onError(), + (this.explicitDisconnect = !1); + }, + }, + { + key: "send", + value: function (e, n) { + if (1 !== this.ws.readyState) + n && + n( + new P( + "Connection is not valid. Please reconnect.", + P.WEBSOCKET_CONNECTION_CLOSED + ), + null + ); + else { + var t = M.get(this.sb._iid).container.pinger; + this.ws.send(e.encode()), + "PING" !== e.command && t.refreshTimer(), + n && n(null, null); + } + }, + }, + { + key: "active", + value: function () { + this.lastActiveMillis = new Date().getTime(); + }, + }, + { + key: "getConnectionState", + value: function () { + try { + return 1 === this.ws.readyState + ? this.sb.ConnectionState.OPEN + : 0 === this.ws.readyState + ? this.sb.ConnectionState.CONNECTING + : this.sb.ConnectionState.CLOSED; + } catch (e) { + return this.sb.ConnectionState.CLOSED; + } + }, + }, + ]), + e + ); + })(); + ne.ConnectionHandler = (function () { + return function e() { + c(this, e), + (this.onReady = function () {}), + (this.onOpen = function () {}), + (this.onClose = function () {}), + (this.onMessage = function () {}), + (this.onError = function () {}); + }; + })(); + var te = (function () { + function e(n) { + c(this, e), + (this.sb = n), + (this.cls = D.get(this.sb._iid)), + (this.client = new ne(this.sb)), + (this.connectParams = { retryCount: 1 }), + (this.reconnectParams = { + interval: 3, + retryCount: 3, + multiplier: 2, + maxInterval: 24, + }), + (this.connectCount = 0), + (this.reconnectCount = 0), + (this.reconnectDelay = 0); + } + return ( + h(e, [ + { + key: "isConnected", + get: function () { + return ( + this.client && + this.client.getConnectionState() === + this.sb.ConnectionState.OPEN + ); + }, + }, + { + key: "connect", + value: function (e, n) { + var t = this, + i = M.get(this.sb._iid).container, + r = i.auth, + a = i.apiClient, + s = i.commandHandler; + r.sessionToken = n || null; + var o = this.cls.GroupChannel, + l = null, + u = new ne.ConnectionHandler(); + (this.client = new ne(this.sb, u)), + (u.onMessage = function (e) { + s.onRawCommandReceived(e); + }), + (this.sb.loginHandler = function (e, n) { + if (((t.sb.connecting = !1), e)) + t.disconnect({ clearSession: !0, err: e }, null); + else { + clearInterval(t.sb.globalTimer); + var i = function () { + o.cachedChannels && + Object.keys(o.cachedChannels).forEach(function (e) { + var n = o.cachedChannels[e]; + n.invalidateTypingStatus() && + Object.keys(t.sb.channelHandlers).forEach(function ( + e + ) { + t.sb.channelHandlers[e].onTypingStatusUpdated(n); + }); + }); + }; + i(), + (t.sb.globalTimer = setInterval(function () { + return i(); + }, 1e3)), + t.flushConnectionCallbacks(null, n), + (t.sb.connecting = !1), + (t.sb.reconnecting = !1), + t.sb.ConnectionManager.processAllReadyHandler(null); + } + }), + (u.onOpen = function () { + (t.connectCount = 0), + (t.sb.loginTimer = setTimeout(function () { + (t.sb.loginTimer = null), + (t.sb.onLoginTimerCancel = null), + t.flushConnectionCallbacks( + new P("Connection timeout.", P.LOGIN_TIMEOUT), + null + ), + t.sb.disconnect(null); + }, t.sb.Options.websocketResponseTimeout)), + (t.sb.onLoginTimerCancel = function () { + (t.connectCount = 0), + t.flushConnectionCallbacks( + new P( + "Connection has been canceled.", + P.REQUEST_FAILED + ), + null + ); + }), + (t.sb.connecting = !1); + }), + (u.onError = function (i) { + V.debug( + "Connect: `WebSocketClient.ConnectionHandler.onError` called.", + i + ), + r.sessionKey + ? ((t.sb.isReconnectingOnError = !0), + t.sb.ConnectionManager.errorAllReadyHandler(), + t.reconnect(e, !0), + (t.sb.connecting = !1)) + : t.connectCount < t.connectParams.retryCount + ? (t.connectCount++, t.client.connect(e, n, l)) + : ((t.connectCount = 0), + t.flushConnectionCallbacks( + new P( + "Websocket connection failed.", + P.WEBSOCKET_CONNECTION_FAILED + ), + null + ), + (t.sb.connecting = !1)); + }), + (u.onClose = function () { + V.debug( + "Connect: `WebSocketClient.ConnectionHandler.onClose` called." + ), + (t.connectCount = 0), + (t.sb.connecting = !1); + }), + a.checkRouting(function (i, r) { + if (i) + return ( + (t.sb.connecting = !1), + void t.flushConnectionCallbacks( + new P("Connection routing failed.", P.REQUEST_FAILED), + null + ) + ); + (l = r.wsHost), + a.dummyCall(function (e) { + e && V.error("API dummy call failed:", e); + }), + t.client.connect(e, n, l); + }); + }, + }, + { + key: "reconnect", + value: function (e) { + var n = this, + t = + !(arguments.length > 1 && void 0 !== arguments[1]) || + arguments[1], + i = M.get(this.sb._iid), + r = i.container, + a = r.auth, + s = r.apiClient, + o = r.commandHandler, + l = r.sessionManager, + u = this.cls.OpenChannel; + if (((this.sb.reconnecting = !0), this.sb.reconnectTimer)) + V.debug("Reconnect: still reconnecting."); + else { + if ( + ((this.reconnectCount += 1), + this.reconnectCount <= 1 + ? (t && + Object.keys(this.sb.connectionHandlers).forEach( + function (e) { + n.sb.connectionHandlers[e].onReconnectStarted(); + } + ), + (this.reconnectDelay = 0)) + : (this.reconnectDelay = Math.min( + 1e3 * + this.reconnectParams.interval * + Math.pow( + this.reconnectParams.multiplier, + this.reconnectCount - 2 + ), + this.reconnectParams.maxInterval > 0 + ? 1e3 * this.reconnectParams.maxInterval + : Number.MAX_SAFE_INTEGER + )), + !e || + !a.sessionKey || + (this.reconnectParams.retryCount > 0 && + this.reconnectCount > this.reconnectParams.retryCount)) + ) + return ( + this.disconnect( + { + clearSession: !1, + err: new P( + "Websocket connection failed.", + P.WEBSOCKET_CONNECTION_FAILED + ), + }, + null + ), + (this.reconnectCount = 0), + Object.keys(this.sb.connectionHandlers).forEach(function ( + e + ) { + n.sb.connectionHandlers[e].onReconnectFailed(); + }), + (this.sb.connecting = !1), + (this.sb.reconnecting = !1), + (this.sb.isReconnectingOnError = !1), + void this.sb.ConnectionManager.errorAllReadyHandler() + ); + (this.sb.onReconnectTimerCancel = function () { + n.reconnectCount = 0; + }), + (this.sb.reconnectTimer = setTimeout(function () { + (n.sb.reconnectTimer = null), + (n.sb.onReconnectTimerCancel = null), + n.client && n.client.disconnect(!0); + var t = new ne.ConnectionHandler(); + (n.client = new ne(n.sb, t)), + (n.sb.loginHandler = function (t, i) { + t + ? t.isSessionKeyExpiredError + ? l.refresh(function () {}) + : (clearTimeout(n.sb.reconnectTimer), + (n.sb.reconnectTimer = null), + n.reconnect(e, !1)) + : ((n.reconnectCount = 0), + (n.sb.connecting = !1), + (n.sb.reconnecting = !1), + (n.sb.isReconnectingOnError = !1), + Object.keys(n.sb.connectionHandlers).forEach( + function (e) { + n.sb.connectionHandlers[ + e + ].onReconnectSucceeded(); + } + ), + n.sb.ConnectionManager.processAllReadyHandler(null), + n.sb.isReconnectingOnError && + Object.keys( + n.sb.ConnectionManager.networkHandlers + ).forEach(function (e) { + n.sb.ConnectionManager.networkHandlers[ + e + ].onReconnected(); + }), + Object.keys(u.enteredChannels).forEach(function ( + e + ) { + u.enteredChannels[e].enter(function (t, i) { + if (t) { + var r = n.cls.FileMessageQueue; + delete u.enteredChannels[e], r.delete(e); + } + }); + })); + }), + (t.onOpen = function () { + V.debug( + "Reconnect: `WebSocketClient.ConnectionHandler.onOpen` called." + ), + (n.sb.loginTimer = setTimeout(function () { + V.debug("Reconnect: `loginTimer` timeout."), + (n.sb.loginTimer = null), + n.reconnect(e, !0); + }, n.sb.Options.websocketResponseTimeout)), + (n.sb.onLoginTimerCancel = null), + (n.sb.reconnecting = !1); + }), + (t.onMessage = function (e) { + o.onRawCommandReceived(e); + }), + (t.onError = function (t) { + V.debug( + "Reconnect: `WebSocketClient.ConnectionHandler.onError` called.", + t + ), + (n.sb.isReconnectingOnError = !0), + n.sb.ConnectionManager.errorAllReadyHandler(), + n.reconnect(e, !0); + }), + (t.onClose = function () { + V.debug( + "Reconnect: `WebSocketClient.ConnectionHandler.onClose` called." + ), + (n.sb.reconnecting = !1); + }), + s.checkRouting(function (t, i) { + t + ? n.reconnect(e, !0) + : (n.sb.getCurrentApiHost() !== i.apiHost && + s.get("/", null, function () {}), + n.client.connect(e, null, i.wsHost)); + }); + }, this.reconnectDelay)); + } + }, + }, + { + key: "disconnect", + value: function (e, n) { + var t = M.get(this.sb._iid), + i = t.container.ackStateMap, + r = this.cls, + a = r.GroupChannel, + s = r.OpenChannel, + o = e.clearSession, + l = e.err; + this.sb.loginTimer && + (clearTimeout(this.sb.loginTimer), + this.sb.onLoginTimerCancel && + (this.sb.onLoginTimerCancel(), + (this.sb.onLoginTimerCancel = null)), + (this.sb.loginTimer = null)), + this.sb.reconnectTimer && + (clearTimeout(this.sb.reconnectTimer), + this.sb.onReconnectTimerCancel && + (this.sb.onReconnectTimerCancel(), + (this.sb.onReconnectTimerCancel = null)), + (this.sb.reconnectTimer = null)), + this.client && + ((this.reconnectCount = 0), + this.client.disconnect(!0), + (this.client = null)), + o && + (s.clearEnteredChannels(), + s.clearCache(), + a.clearCache(), + this.sb.globalTimer && + (clearInterval(this.sb.globalTimer), + (this.sb.globalTimer = null)), + Object.keys(i).forEach(function (e) { + clearTimeout(i[e].timer); + }), + (this.sb.currentUser = null), + t.set("ackStateMap", {}), + t.set("subscribedUnreadMessageCount", { + all: 0, + custom_types: {}, + ts: 0, + }), + t.set("auth", new L())), + l && + (this.flushConnectionCallbacks(l, null), + (this.sb.connecting = !1), + (this.sb.reconnecting = !1), + (this.sb.isReconnectingOnError = !1)), + n && n(null, null); + }, + }, + { + key: "flushConnectionCallbacks", + value: function (e, n) { + var t = this.sb.connectionCallbacks; + (this.sb.connectionCallbacks = []), + t.forEach(function (t) { + return t(e, n); + }); + }, + }, + ]), + e + ); + })(), + ie = (function () { + function e(n) { + var t = n.type, + i = n.nullable, + r = void 0 !== i && i, + a = n.optional, + s = void 0 !== a && a, + o = n.optionalIf, + l = void 0 === o ? null : o, + u = n.ignoreIf, + d = void 0 === u ? null : u, + h = n.defaultValue, + p = void 0 === h ? null : h, + f = n.constraint, + y = void 0 === f ? null : f; + c(this, e), + (this.type = t), + (this.nullable = r), + (this.optional = s), + (this.optionalIf = l), + (this.ignoreIf = d), + (this.defaultValue = p), + (this.constraint = y); + } + return ( + h( + e, + [ + { + key: "isMatchingType", + value: function (e) { + var n = function (n, t) { + return "string" == typeof t + ? u(n) === t || + ("array" === t && Array.isArray(n)) || + ("file" === t && X.isFile(n)) || + ("null" === t && null === n) || + ("date" === t && n instanceof Date) + : "function" == typeof t + ? n instanceof t + : "object" === u(t) && + Object.keys(t) + .map(function (e) { + return t[e]; + }) + .indexOf(e) > -1; + }; + return ( + n(e, this.type) || + (Array.isArray(this.type) && + this.type.some(function (t) { + return n(e, t); + })) || + (this.nullable && null === e) + ); + }, + }, + ], + [ + { + key: "parse", + value: function (n, t) { + for ( + n = e.toArray(n); + n.length > 0 && void 0 === n[n.length - 1]; + + ) + n.pop(); + var i = !1, + r = null; + "callback" === t[t.length - 1].type && + ("function" == typeof n[n.length - 1] && (r = n.pop()), + t.pop(), + (i = !0)); + var a = [], + s = null, + o = 0; + return ( + t.forEach(function (t) { + "function" == typeof t.ignoreIf && t.ignoreIf(n) + ? a.push( + t.hasOwnProperty("defaultValue") + ? t.defaultValue + : null + ) + : t.isMatchingType(n[o]) + ? ((t.nullable && null === n[o]) || + !t.constraint || + t.constraint(n[o]) || + (s = e.error), + a.push(n[o]), + o++) + : t.optional || + ("function" == typeof t.optionalIf && t.optionalIf(n)) + ? a.push( + t.hasOwnProperty("defaultValue") + ? t.defaultValue + : null + ) + : ((s = e.error), a.push(n[o]), o++); + }), + i && r && a.push(r), + n.length !== o && (s = e.error), + [s].concat(a) + ); + }, + }, + { + key: "error", + get: function () { + return new P("Invalid parameter.", P.INVALID_PARAMETER); + }, + }, + { + key: "toArray", + value: function (e) { + for (var n = [], t = 0; t < e.length; t++) n.push(e[t]); + return n; + }, + }, + ] + ), + e + ); + })(), + re = (function () { + function e(n) { + c(this, e), + (this.sb = n), + (this.authCount = 0), + (this.readyHandlers = []), + (this.networkHandlers = {}), + (this.authenticateTimer = 1e4), + (this.authInfoRequester = null); + } + return ( + h(e, [ + { + key: "addReadyHandler", + value: function (e) { + e && "function" == typeof e && this.readyHandlers.push(e); + }, + }, + { + key: "ready", + value: function (e) { + var n = + !(arguments.length > 1 && void 0 !== arguments[1]) || + arguments[1], + t = M.get(this.sb._iid), + i = t.container, + r = i.auth, + a = i.isInBackground; + n && r.hasSession() + ? e && + (this.sb.currentUser + ? e(null, this.sb.currentUser) + : (this.addReadyHandler(e), this.errorAllReadyHandler()), + this.sb.getConnectionState() !== + this.sb.ConnectionState.CLOSED || + a || + this.sb.reconnect()) + : (this.addReadyHandler(e), + this.sb.isReconnectingOnError + ? this.errorAllReadyHandler() + : this.sb.getConnectionState() === + this.sb.ConnectionState.OPEN + ? this.processAllReadyHandler(null) + : this.sb.getConnectionState() === + this.sb.ConnectionState.CONNECTING || + this.errorAllReadyHandler()); + }, + }, + { + key: "processAllReadyHandler", + value: function (e) { + if (this.readyHandlers.length > 0) { + var n = this.sb.currentUser, + t = this.readyHandlers; + (this.readyHandlers = []), + t.forEach(function (t) { + t && "function" == typeof t && t(e, n); + }); + } + }, + }, + { + key: "errorAllReadyHandler", + value: function () { + this.processAllReadyHandler( + new P("Connection should be made first.", P.CONNECTION_REQUIRED) + ); + }, + }, + { + key: "NetworkHandler", + value: function () { + this.onReconnected = function () {}; + }, + }, + { + key: "addNetworkHandler", + value: function (e, n) { + this.networkHandlers[e] = n; + }, + }, + { + key: "removeNetworkHandler", + value: function (e) { + delete this.networkHandlers[e]; + }, + }, + { + key: "removeAllNetworkHandler", + value: function () { + this.networkHandlers = {}; + }, + }, + { + key: "authenticate", + value: function (e) { + var n = this; + if ( + this.sb.getConnectionState() === this.sb.ConnectionState.OPEN || + this.sb.reconnecting + ) + (this.sb.connecting = !1), e(null, this.sb.currentUser); + else if ( + this.authInfoRequester && + "function" == typeof this.authInfoRequester + ) { + (this.sb.connecting = !0), this.authCount++; + var t = setTimeout(function () { + (t = null), + n.authCount--, + 0 === n.authCount && + 0 === n.sb.connectionCallbacks.length && + (n.sb.connecting = !1), + n.errorAllReadyHandler(), + e( + new P( + "Connection should be made first.", + P.CONNECTION_REQUIRED + ), + null + ); + }, this.authenticateTimer); + this.authInfoRequester(function (i) { + if (t) { + clearTimeout(t), (t = null), n.authCount--; + var r = function (t, i) { + (n.sb.connecting = !1), e(t, null); + }; + i && i.hasOwnProperty("userId") + ? i.accessToken + ? i.apiHost && i.wsHost + ? n.sb.connect( + i.userId, + i.accessToken, + i.apiHost, + i.wsHost, + r + ) + : n.sb.connect(i.userId, i.accessToken, r) + : i.apiHost && i.wsHost + ? n.sb.connect(i.userId, i.apiHost, i.wsHost, r) + : n.sb.connect(i.userId, r) + : e(ie.error, null); + } + }); + } else e(ie.error, null); + }, + }, + ]), + e + ); + })(), + ae = function e() { + c(this, e), + (this.onSessionExpired = function () {}), + (this.onSessionTokenRequired = function (e, n) { + return e(null); + }), + (this.onSessionError = function (e) {}), + (this.onSessionRefreshed = function () {}), + (this.onSessionClosed = function () {}); + }, + se = (function () { + function e(n) { + c(this, e), (this.sb = n), (this.handler = null), (this.callbacks = []); + } + return ( + h(e, [ + { + key: "_refreshSessionKey", + value: function () { + var e = this; + M.get(this._iid).container.wsAdapter.isConnected + ? this._refreshSessionKeyByCommand(function (n) { + n + ? n.isSessionTokenExpiredError + ? e._handleRefreshError(n) + : e._refreshSessionKeyByApi(function (n) { + n + ? e._handleRefreshError(n) + : e._handleRefreshSuccess(); + }) + : e._handleRefreshSuccess(); + }) + : this._refreshSessionKeyByApi(function (n) { + n ? e._handleRefreshError(n) : e._handleRefreshSuccess(); + }); + }, + }, + { + key: "_refreshSessionKeyByCommand", + value: function (e) { + var n = this.sb, + t = M.get(this._iid).container.auth, + i = D.get(this._iid).Command, + r = i.bSessionRefresh({ + token: t.sessionToken, + requestId: i.generateRequestId(), + }); + n.sendCommand(r, function (i, r) { + if (n.getErrorFirstCallback()) { + var a = [i, r]; + (r = a[0]), (i = a[1]); + } + i && + (i.hasOwnProperty("error") + ? (r = new P( + "Failed to refresh the session key.", + P.SESSION_TOKEN_REFRESH_FAILED + )) + : i.hasOwnProperty("new_key") && + (t.sessionKey = i.new_key)), + e(r); + }); + }, + }, + { + key: "_refreshSessionKeyByApi", + value: function (e) { + var n = this; + !(function t(i) { + if (i < 3) { + var r = M.get(n._iid).container, + a = r.auth, + s = r.apiClient, + o = {}; + a.sessionToken && (o.accessToken = a.sessionToken), + s.refreshSessionKey(o, function (n, r) { + if (n) + n.isSessionTokenExpiredError + ? e( + new P( + "Failed to refresh the session key.", + P.SESSION_TOKEN_REFRESH_FAILED + ) + ) + : t(i + 1); + else { + var s = r.key; + (a.sessionKey = s), e(null); + } + }); + } else + e( + new P( + "Failed to refresh the session key.", + P.SESSION_TOKEN_REFRESH_FAILED + ) + ); + })(0); + }, + }, + { + key: "_handleRefreshSuccess", + value: function () { + var e = this.sb; + e.reconnectTimer && + (clearTimeout(e.reconnectTimer), (e.reconnectTimer = null)), + e.reconnect(), + this._flushCallbacks( + new P("Session key refreshed.", P.SESSION_TOKEN_REFRESHED) + ), + this.handler && this.handler.onSessionRefreshed(); + }, + }, + { + key: "_handleRefreshError", + value: function (e) { + this._flushCallbacks(e), + this.handler && this.handler.onSessionError(e); + }, + }, + { + key: "_handleClose", + value: function () { + var e = this; + this.sb.disconnect(function () { + e._flushCallbacks( + new P( + "Failed to refresh the session key.", + P.SESSION_TOKEN_REFRESH_FAILED + ) + ), + e.handler && e.handler.onSessionClosed(); + }); + }, + }, + { + key: "_flushCallbacks", + value: function (e) { + this.callbacks.forEach(function (n) { + return n(e); + }), + (this.callbacks = []); + }, + }, + { + key: "setHandler", + value: function (e) { + e instanceof ae && (this.handler = e); + }, + }, + { + key: "refresh", + value: function (e) { + var n = this, + t = this.sb, + i = M.get(this._iid).container.auth; + if (this.handler) { + if ((this.callbacks.push(e), 1 === this.callbacks.length)) { + this.handler.onSessionExpired(), + i.sessionToken + ? this.handler.onSessionTokenRequired( + function (e) { + e + ? ((i.sessionToken = e), n._refreshSessionKey()) + : n._handleClose(); + }, + function () { + t.reconnectTimer && + (clearTimeout(t.reconnectTimer), + (t.reconnectTimer = null)); + var e = new P( + "Failed to get the session token.", + P.SESSION_TOKEN_REQUEST_FAILED + ); + n._flushCallbacks(e), + n.handler && n.handler.onSessionError(e); + } + ) + : this._refreshSessionKey(); + } + } else e(null); + }, + }, + ]), + e + ); + })(), + oe = (function () { + function e(n) { + c(this, e), (this.sb = n); + } + return ( + h(e, [ + { + key: "onlineWorker", + value: function () { + try { + if ("undefined" != typeof navigator && navigator.onLine) { + var e = M.get(this.sb._iid).container.auth; + this.sb.reconnecting || + this.sb.connecting || + !e.sessionKey || + this.sb.getConnectionState() === + this.sb.ConnectionState.OPEN || + this.sb.reconnect(); + } + } catch (e) { + V.debug( + "There is no `window.addEventListener.ononline` or `navigator.onLine`" + ); + } + }, + }, + { + key: "offlineWorker", + value: function () { + try { + if ("undefined" != typeof navigator && !navigator.onLine) { + var e = M.get(this.sb._iid).container, + n = e.auth, + t = e.pinger; + this.sb.reconnecting || + this.sb.connecting || + !n.sessionKey || + (t && t.stop(), this.sb.reconnect()); + } + } catch (e) { + V.debug( + "There is no `window.addEventListener.ononline` or `navigator.onLine`" + ); + } + }, + }, + { + key: "start", + value: function () { + try { + "undefined" != typeof window && + window.addEventListener && + "ononline" in window && + "onoffline" in window && + "undefined" != typeof navigator && + "boolean" == typeof navigator.onLine && + (window.addEventListener("online", this.onlineWorker), + window.addEventListener("offline", this.offlineWorker)); + } catch (e) { + V.debug( + "There is no `window.addEventListener.ononline` or `navigator.onLine`" + ); + } + }, + }, + { + key: "stop", + value: function () { + try { + window.removeEventListener("online", this.onlineWorker, !1), + window.removeEventListener("offline", this.offlineWorker, !1); + } catch (e) { + V.debug( + "There is no `window.addEventListener.ononline` or `navigator.onLine`" + ); + } + }, + }, + ]), + e + ); + })(), + le = new Date().getTime(), + ue = (function () { + function e(n, t) { + var i = + arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : null; + switch ( + (c(this, e), + (this.command = n), + (this.requestId = i), + arguments.length) + ) { + case 1: + if (!n || n.length <= 4) + (this.command = "NOOP"), (this.payload = "{}"); + else if ((this.decode(n), this.isRequestIdCommand)) { + var r = this.getJsonElement(); + r && (this.requestId = r.req_id || ""); + } + break; + case 2: + case 3: + !this.requestId && + this.isRequestIdCommand && + (this.requestId = e.generateRequestId()), + (t.req_id = this.requestId || ""), + (this.payload = JSON.stringify(t)); + } + } + return ( + h( + e, + [ + { + key: "isRequestIdCommand", + get: function () { + return this.isAckRequired || "EROR" === this.command; + }, + }, + { + key: "isAckRequired", + get: function () { + return ( + "MESG" === this.command || + "FILE" === this.command || + "ENTR" === this.command || + "EXIT" === this.command || + "READ" === this.command || + "MEDI" === this.command || + "FEDI" === this.command + ); + }, + }, + { + key: "encode", + value: function () { + return this.command + this.payload + "\n"; + }, + }, + { + key: "decode", + value: function (e) { + (e = e.trim()), + (this.command = e.substring(0, 4)), + (this.payload = e.substring(4)); + }, + }, + { + key: "getJsonElement", + value: function () { + return JSON.parse(this.payload); + }, + }, + ], + [ + { + key: "bSessionRefresh", + value: function (e) { + return new this("LOGI", { token: e.token }, e.requestId); + }, + }, + { + key: "bPing", + value: function () { + return new this("PING", { + id: new Date().getTime(), + active: 1, + }); + }, + }, + { + key: "bMessage", + value: function (e) { + var n = e.channelUrl, + t = e.message, + i = e.data, + r = e.customType, + a = e.metaArrays, + s = e.mentionType, + o = e.mentionedUserIds, + l = e.translationTargetLanguages, + u = e.pushNotificationDeliveryOption, + c = e.appleCriticalAlertOptions, + d = e.requestId, + h = void 0 === d ? null : d, + p = e.silent, + f = void 0 !== p && p, + y = e.rootMessageId, + g = void 0 === y ? null : y, + _ = e.parentMessageId, + m = void 0 === _ ? null : _, + v = e.pollId, + E = e.isReplyToChannel, + C = void 0 !== E && E, + b = D.get(this._iid), + U = b.UserMessageParams, + A = b.BaseMessageParams, + I = {}; + return ( + (I.channel_url = n), + (I.message = t), + (I.data = i), + a && + a.length > 0 && + (I.metaarray = a.map(function (e) { + return e.encode(); + })), + s && (I.mention_type = s), + (I.mentioned_user_ids = []), + s === A.MentionType.CHANNEL + ? (I.mentioned_user_ids = []) + : Array.isArray(o) && + o.length > 0 && + (I.mentioned_user_ids = o), + r && (I.custom_type = r), + l && l.length > 0 && (I.target_langs = l), + u && + u !== U.PushNotificationDeliveryOption.DEFAULT && + (I.push_option = u), + c && (I.apple_critical_alert_options = c.serialize()), + f && (I.silent = f), + g && (I.root_message_id = g), + m && (I.parent_message_id = m), + "number" == typeof v + ? (I.poll_id = v) + : null === v && (I.poll_id = -1), + C && (I.reply_to_channel = C), + new this("MESG", I, h) + ); + }, + }, + { + key: "bFile", + value: function (e) { + var n = e.channelUrl, + t = e.url, + i = e.name, + r = e.type, + a = e.size, + s = e.data, + o = e.customType, + l = e.thumbnailSizes, + u = e.requireAuth, + c = e.metaArrays, + d = e.mentionType, + h = e.mentionedUserIds, + p = e.pushNotificationDeliveryOption, + f = e.appleCriticalAlertOptions, + y = e.requestId, + g = void 0 === y ? null : y, + _ = e.silent, + m = void 0 !== _ && _, + v = e.rootMessageId, + E = void 0 === v ? null : v, + C = e.parentMessageId, + b = void 0 === C ? null : C, + U = e.isReplyToChannel, + A = void 0 !== U && U, + I = D.get(this._iid), + S = I.BaseMessageParams, + k = I.FileMessageParams, + O = {}; + return ( + (O.channel_url = n), + (O.url = t), + (O.name = i || ""), + (O.type = r || ""), + (O.size = a || 0), + (O.custom = s), + o && (O.custom_type = o), + l && (O.thumbnails = l), + u && (O.require_auth = u), + c && + c.length > 0 && + (O.metaarray = c.map(function (e) { + return e.encode(); + })), + d && (O.mention_type = d), + (O.mentioned_user_ids = []), + d === S.MentionType.CHANNEL + ? (O.mentioned_user_ids = []) + : Array.isArray(h) && + h.length > 0 && + (O.mentioned_user_ids = h), + p && + p !== k.PushNotificationDeliveryOption.DEFAULT && + (O.push_option = p), + f && (O.apple_critical_alert_options = f.serialize()), + m && (O.silent = m), + E && (O.root_message_id = E), + b && (O.parent_message_id = b), + A && (O.reply_to_channel = A), + new this("FILE", O, g) + ); + }, + }, + { + key: "bUpdateUserMessage", + value: function (e) { + var n = e.channelUrl, + t = e.messageId, + i = e.appleCriticalAlertOptions, + r = e.message, + a = void 0 === r ? null : r, + s = e.data, + o = void 0 === s ? null : s, + l = e.customType, + u = void 0 === l ? null : l, + c = e.mentionType, + d = void 0 === c ? null : c, + h = e.mentionedUserIds, + p = void 0 === h ? null : h, + f = e.metaArrayParams, + y = void 0 === f ? null : f, + g = e.pollId, + _ = D.get(this._iid).BaseMessageParams, + m = {}; + return ( + (m.channel_url = n), + (m.msg_id = t), + null != a && void 0 !== a && (m.message = a), + null != o && void 0 !== o && (m.data = o), + null != u && void 0 !== u && (m.custom_type = u), + d && (m.mention_type = d), + d === _.MentionType.CHANNEL + ? (m.mentioned_user_ids = []) + : Array.isArray(p) && + p.length > 0 && + (m.mentioned_user_ids = p), + y && (m.metaarray = y), + i && (m.apple_critical_alert_options = i.serialize()), + "number" == typeof g + ? (m.poll_id = g) + : null === g && (m.poll_id = -1), + new this("MEDI", m) + ); + }, + }, + { + key: "bUpdateFileMessage", + value: function (e) { + var n = e.channelUrl, + t = e.messageId, + i = e.appleCriticalAlertOptions, + r = e.data, + a = void 0 === r ? null : r, + s = e.customType, + o = void 0 === s ? null : s, + l = e.mentionType, + u = void 0 === l ? null : l, + c = e.mentionedUserIds, + d = void 0 === c ? null : c, + h = e.metaArrayParams, + p = void 0 === h ? null : h, + f = D.get(this._iid).BaseMessageParams, + y = {}; + return ( + (y.channel_url = n), + (y.msg_id = t), + null != a && void 0 !== a && (y.data = a), + null != o && void 0 !== o && (y.custom_type = o), + u && (y.mention_type = u), + u === f.MentionType.CHANNEL + ? (y.mentioned_user_ids = []) + : Array.isArray(d) && + d.length > 0 && + (y.mentioned_user_ids = d), + p && (y.metaarray = p), + i && (y.apple_critical_alert_options = i.serialize()), + new this("FEDI", y) + ); + }, + }, + { + key: "bRead", + value: function (e) { + var n = e.channelUrl, + t = {}; + return (t.channel_url = n), new this("READ", t); + }, + }, + { + key: "bMessageAck", + value: function (e) { + var n = e.channelUrl, + t = e.messageId, + i = {}; + return (i.channel_url = n), (i.msg_id = t), new this("MACK", i); + }, + }, + { + key: "bTypeStart", + value: function (e) { + var n = e.channelUrl, + t = e.time, + i = {}; + return (i.channel_url = n), (i.time = t), new this("TPST", i); + }, + }, + { + key: "bTypeEnd", + value: function (e) { + var n = e.channelUrl, + t = e.time, + i = {}; + return (i.channel_url = n), (i.time = t), new this("TPEN", i); + }, + }, + { + key: "bEnter", + value: function (e) { + var n = e.channelUrl, + t = {}; + return (t.channel_url = n), new this("ENTR", t); + }, + }, + { + key: "bExit", + value: function (e) { + var n = e.channelUrl, + t = {}; + return (t.channel_url = n), new this("EXIT", t); + }, + }, + { + key: "generateRequestId", + value: function () { + return le++, String(le); + }, + }, + ] + ), + e + ); + })(), + ce = 1048576, + de = new WeakMap(), + he = (function () { + function e() { + var n = + arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {}; + c(this, e); + var t = []; + if ( + n.hasOwnProperty("premium_feature_list") && + Array.isArray(n.premium_feature_list) + ) + try { + var i = n.premium_feature_list; + t.push.apply(t, I(i)); + } catch (e) {} + var r = []; + if ( + n.hasOwnProperty("application_attributes") && + Array.isArray(n.application_attributes) + ) + try { + var a = n.application_attributes; + r.push.apply(r, I(a)); + } catch (e) {} + var s = !1; + n.hasOwnProperty("disable_supergroup_mack") && + "boolean" == typeof n.disable_supergroup_mack && + (s = n.disable_supergroup_mack), + de.set(this, { + emojiHash: n.hasOwnProperty("emoji_hash") ? n.emoji_hash : "", + uploadSizeLimit: n.hasOwnProperty("file_upload_size_limit") + ? n.file_upload_size_limit * ce + : Number.MAX_VALUE, + useReaction: n.hasOwnProperty("use_reaction") && n.use_reaction, + disableSupergroupMack: s, + applicationAttributes: r, + premiumFeatureList: t, + }); + } + return ( + h(e, [ + { + key: "emojiHash", + get: function () { + return de.get(this).emojiHash; + }, + }, + { + key: "uploadSizeLimit", + get: function () { + return de.get(this).uploadSizeLimit; + }, + }, + { + key: "premiumFeatureList", + get: function () { + return de.get(this).premiumFeatureList; + }, + }, + { + key: "applicationAttributes", + get: function () { + return de.get(this).applicationAttributes; + }, + }, + { + key: "isUsingReaction", + get: function () { + return de.get(this).useReaction; + }, + }, + { + key: "isSupergroupMackDisabled", + get: function () { + return de.get(this).disableSupergroupMack; + }, + }, + ]), + e + ); + })(), + pe = (function () { + function e() { + c(this, e), + (this.messageId = null), + (this.userId = null), + (this.key = null), + (this.operation = ""), + (this.updatedAt = null); + } + return ( + h(e, null, [ + { + key: "createFromJson", + value: function (e) { + var n = parseInt(e.msg_id), + t = e.user_id, + i = e.operation, + r = e.reaction, + a = e.updated_at; + if ( + n && + "string" == typeof t && + "string" == typeof i && + ["add", "delete"].indexOf(i.toLowerCase()) >= 0 && + "string" == typeof r && + r && + "number" == typeof a + ) { + var s = new this(); + return ( + (s.messageId = n), + (s.userId = t), + (s.key = r), + (s.operation = i.toLowerCase()), + (s.updatedAt = a), + s + ); + } + return null; + }, + }, + ]), + e + ); + })(); + function fe(e) { + return ( + Object.keys(e).forEach(function (n) { + e[n] && "object" === u(e[n]) && fe(e[n]); + }), + Object.freeze(e) + ); + } + var ye = (function () { + function e() { + c(this, e); + } + return ( + h(e, null, [ + { + key: "serialize", + value: function (e) { + var n = + arguments.length > 1 && void 0 !== arguments[1] + ? arguments[1] + : null, + t = JSON.parse(JSON.stringify(e)); + return n && n(t), fe(t); + }, + }, + { + key: "deserialize", + value: function (e) { + var n = + arguments.length > 1 && void 0 !== arguments[1] + ? arguments[1] + : null, + t = JSON.parse(JSON.stringify(e)); + return n && n(t), t; + }, + }, + ]), + e + ); + })(), + ge = function (e, n, t) { + return new Promise(function (i, r) { + n(function (n, a) { + t && + "function" == typeof t && + (M.get(e).container.isErrorFirstInCallback ? t(n, a) : t(a, n)); + n ? r(n) : i(a); + }); + }); + }, + _e = { TIMESTAMP: "timestamp", MESSAGE_ID: "messageId" }, + me = new WeakMap(), + ve = (function () { + function e(n) { + c(this, e), + (this.messageId = 0), + (this.messageType = e.MESSAGE_TYPE_BASE), + (this.channelUrl = ""), + (this.data = null), + (this.customType = null), + (this.silent = !1), + (this.createdAt = 0), + (this.updatedAt = 0), + (this.channelType = null), + (this.metaArrays = []), + (this.reactions = []), + (this.mentionType = null), + (this.mentionedUsers = []), + (this.sendingStatus = null), + me.set(this, 0), + (this.parentMessageId = 0), + (this.parentMessageText = null), + (this.threadInfo = null), + (this.isReplyToChannel = !1), + (this.parentMessage = null), + (this.ogMetaData = null), + (this.isOperatorMessage = !1), + (this.appleCriticalAlertOptions = null), + n && this.__update(n); + } + return ( + h( + e, + [ + { + key: "serialize", + value: function () { + return ye.serialize(this, function (e) { + e.hasOwnProperty("_sender") && + ((e.sender = e._sender), delete e._sender); + }); + }, + }, + { + key: "isIdentical", + value: function (e) { + return ( + !("object" !== u(e) || !e.hasOwnProperty("messageId")) && + (0 !== this.messageId && 0 !== e.messageId + ? this.messageId === e.messageId + : this.reqId === e.reqId) + ); + }, + }, + { + key: "isEqual", + value: function (e) { + return X.deepEqual(this, e); + }, + }, + { + key: "isOpenChannel", + value: function () { + var e = D.get(this._iid).BaseChannel; + return this.channelType === e.CHANNEL_TYPE_OPEN; + }, + }, + { + key: "isGroupChannel", + value: function () { + var e = D.get(this._iid).BaseChannel; + return this.channelType === e.CHANNEL_TYPE_GROUP; + }, + }, + { + key: "isUserMessage", + value: function () { + return this.messageType === e.MESSAGE_TYPE_USER; + }, + }, + { + key: "isAdminMessage", + value: function () { + return this.messageType === e.MESSAGE_TYPE_ADMIN; + }, + }, + { + key: "isFileMessage", + value: function () { + return this.messageType === e.MESSAGE_TYPE_FILE; + }, + }, + { + key: "__update", + value: function (e) { + var n = this, + t = ft.getInstance(this._iid), + i = D.get(this._iid), + r = i.User, + a = i.BaseChannel, + s = i.BaseMessageParams, + o = i.BaseMessage, + l = i.Reaction, + u = i.MessageMetaArray, + c = i.ThreadInfo, + d = i.OGMetaData, + h = i.AppleCriticalAlertOptions; + e.hasOwnProperty("msg_id") && + (this.messageId = parseInt(e.msg_id)), + e.hasOwnProperty("message_id") && + (this.messageId = parseInt(e.message_id)), + (this.channelUrl = e.hasOwnProperty("channel_url") + ? String(e.channel_url) + : ""), + (this.data = e.hasOwnProperty("data") ? String(e.data) : ""), + (this.customType = e.hasOwnProperty("custom_type") + ? String(e.custom_type) + : ""), + (this.silent = !!e.hasOwnProperty("silent") && e.silent), + (this.createdAt = e.hasOwnProperty("ts") + ? parseInt(e.ts) + : 0), + e.hasOwnProperty("created_at") && + (this.createdAt = parseInt(e.created_at)), + (this.updatedAt = e.hasOwnProperty("updated_at") + ? parseInt(e.updated_at) + : 0), + (this.channelType = e.hasOwnProperty("channel_type") + ? String(e.channel_type) + : a.CHANNEL_TYPE_GROUP); + var p = e.hasOwnProperty("metaarray") ? e.metaarray : {}, + f = e.hasOwnProperty("metaarray_key_order") + ? e.metaarray_key_order + : Object.keys(p).sort(function (e, n) { + return e.localeCompare(n); + }); + this.metaArrays = []; + for (var y = 0; y < f.length; y++) { + var g = f[y]; + this.metaArrays.push(new u(g, p[g] || [])); + } + if (e.hasOwnProperty("sorted_metaarray")) { + var _ = e.sorted_metaarray; + Array.isArray(_) && + (this.metaArrays = _.map(function (e) { + return new u(e.key, e.value); + })); + } + if ( + ((this.reactions = []), + e.hasOwnProperty("reactions") && Array.isArray(e.reactions)) + ) + for (var m = 0; m < e.reactions.length; m++) { + var v = l.createFromJson(e.reactions[m]); + v && this.reactions.push(v); + } + ((this.mentionType = e.hasOwnProperty("mention_type") + ? e.mention_type + : s.MentionType.USERS), + (this.mentionedUsers = []), + e.hasOwnProperty("mentioned_users")) && + e.mentioned_users.forEach(function (e) { + var t = new r(e); + n.mentionedUsers.push(t); + }); + if ( + ((this.sendingStatus = + this.messageId > 0 + ? t.MessageSendingStatus.SUCCEEDED + : t.MessageSendingStatus.FAILED), + e.hasOwnProperty("sending_status") && + (this.sendingStatus = e.sending_status), + e.hasOwnProperty("root_message_id") && + me.set(this, parseInt(e.root_message_id)), + e.hasOwnProperty("parent_message_id") && + (this.parentMessageId = parseInt(e.parent_message_id)), + (this.threadInfo = new c(e.thread_info)), + (this.isReplyToChannel = + !!e.hasOwnProperty("is_reply_to_channel") && + e.is_reply_to_channel), + e.hasOwnProperty("parent_message_info")) + ) { + var E = { + channelType: this.channelType, + channelUrl: this.channelUrl, + }; + switch ( + ((this.parentMessage = a.buildMessage( + e.parent_message_info, + E + )), + this.parentMessage.messageType) + ) { + case o.MESSAGE_TYPE_USER: + this.parentMessageText = this.parentMessage.message; + break; + case o.MESSAGE_TYPE_FILE: + this.parentMessageText = this.parentMessage.name; + } + } + e.hasOwnProperty("og_tag") && + (this.ogMetaData = new d(e.og_tag)), + (this.isOperatorMessage = + !!e.hasOwnProperty("is_op_msg") && e.is_op_msg), + e.hasOwnProperty("apple_critical_alert_options") && + (this.appleCriticalAlertOptions = new h( + e.apple_critical_alert_options + )); + }, + }, + { + key: "getMetaArraysByKeys", + value: function (e) { + return Array.isArray(e) + ? this.metaArrays.filter(function (n) { + return e.indexOf(n.key) > -1; + }) + : []; + }, + }, + { + key: "metaArray", + get: function () { + var e = {}; + return ( + this.metaArrays.forEach(function (n) { + e[n.key] = n.value; + }), + e + ); + }, + set: function (e) { + if ("object" === u(e) && e) { + var n = D.get(this._iid).MessageMetaArray, + t = []; + Object.keys(e).forEach(function (i) { + t.push(new n(i, e[i])); + }), + (this.metaArrays = t); + } + }, + }, + { + key: "getMetaArrayByKeys", + value: function (e) { + var n = {}; + return ( + this.getMetaArraysByKeys(e).forEach(function (e) { + n[e.key] = e.value; + }), + n + ); + }, + }, + { + key: "applyReactionEvent", + value: function (e) { + var n = this, + t = D.get(this._iid), + i = t.Reaction, + r = null, + a = ie.parse(arguments, [ + new ie({ + type: pe, + constraint: function (e) { + return parseInt(e.messageId) === parseInt(n.messageId); + }, + }), + ]), + s = A(a, 2); + if (((r = s[0]), (e = s[1]), !r)) { + for (var o = !1, l = 0; l < this.reactions.length; l++) + if (this.reactions[l].key === e.key) { + this.reactions[l]._applyEvent(e), + this.reactions[l].isEmpty && + this.reactions.splice(l, 1), + (o = !0); + break; + } + o || + "add" !== e.operation || + this.reactions.push(new i(e.key, [e.userId], e.updatedAt)); + } + }, + }, + { + key: "_getThreadedMessageList", + value: function (n, t, i, r) { + var a = this, + s = D.get(this._iid), + o = s.ThreadedMessageListParams, + u = null, + c = ie.parse(arguments, [ + new ie({ type: "number" }), + new ie({ + type: "string", + constraint: function (e) { + return Object.values(_e).includes(e); + }, + }), + new ie({ + type: o, + constraint: function (e) { + return e._validate(); + }, + }), + new ie({ type: "callback" }), + ]), + d = A(c, 5); + return ( + (u = d[0]), + (n = d[1]), + (t = d[2]), + (i = d[3]), + (r = d[4]), + ge( + this._iid, + function (r) { + if (u) r(u, null); + else { + var s = D.get(a._iid), + o = s.GroupChannel, + c = s.OpenChannel; + a.isGroupChannel() + ? o.getChannel( + a.channelUrl, + N.INTERNAL_CALL, + function (s, o) { + if ( + ft.getInstance(a._iid).getErrorFirstCallback() + ) { + var u = [s, o]; + (o = u[0]), (s = u[1]); + } + o + ? r(o, null) + : M.get( + a._iid + ).container.apiClient.getMessageList( + l( + l( + { + channel: s, + token: n, + tokenType: t, + }, + i + ), + {}, + { + shouldReverse: i.reverse, + rootMessageId: a.messageId, + includeThreadInfo: !0, + replyTypeFilter: e.ReplyType.ALL, + } + ), + function (e, n) { + if (e) r(e, null); + else { + var t = D.get(a._iid).BaseChannel, + i = n.messages + .map(function (e) { + return t.buildMessage(e, s); + }) + .filter(function (e) { + return null !== e; + }), + o = i.filter(function (e) { + return ( + e.messageId === a.messageId + ); + })[0], + l = i.filter(function (e) { + return ( + e.parentMessageId === + a.messageId + ); + }); + r(null, { + parentMessage: o, + threadedReplies: l, + }); + } + } + ); + } + ) + : a.isOpenChannel() && + c.getChannel( + a.channelUrl, + N.INTERNAL_CALL, + function (s, o) { + if ( + ft.getInstance(a._iid).getErrorFirstCallback() + ) { + var u = [s, o]; + (o = u[0]), (s = u[1]); + } + o + ? r(o, null) + : M.get( + a._iid + ).container.apiClient.getMessageList( + l( + l( + { + channel: s, + token: n, + tokenType: t, + }, + i + ), + {}, + { + shouldReverse: i.reverse, + rootMessageId: a.messageId, + includeThreadInfo: !0, + replyTypeFilter: e.ReplyType.ALL, + } + ), + function (e, n) { + if (e) r(e, null); + else { + var t = D.get(a._iid).BaseChannel, + i = n.messages + .map(function (e) { + return t.buildMessage(e, s); + }) + .filter(function (e) { + return null !== e; + }), + o = i.filter(function (e) { + return ( + e.messageId === a.messageId + ); + })[0], + l = i.filter(function (e) { + return ( + e.parentMessageId === + a.messageId + ); + }); + r(null, { + parentMessage: o, + threadedReplies: l, + }); + } + } + ); + } + ); + } + }, + r + ) + ); + }, + }, + { + key: "getThreadedMessagesByTimestamp", + value: function (e, n, t) { + return this._getThreadedMessageList(e, _e.TIMESTAMP, n, t); + }, + }, + { + key: "applyThreadInfoUpdateEvent", + value: function (e) { + var n = D.get(this._iid), + t = n.ThreadInfo, + i = n.ThreadInfoUpdateEvent, + r = me.get(this), + a = null, + s = ie.parse(arguments, [ + new ie({ + type: i, + constraint: function (e) { + return parseInt(e.targetMessageId) === parseInt(r); + }, + }), + ]), + o = A(s, 2); + if (((a = o[0]), (e = o[1]), !a)) { + var l = e, + u = l.threadInfo; + return (this.threadInfo = new t(u)), !0; + } + return !1; + }, + }, + ], + [ + { + key: "MESSAGE_TYPE_BASE", + get: function () { + return "base"; + }, + }, + { + key: "MESSAGE_TYPE_ADMIN", + get: function () { + return "admin"; + }, + }, + { + key: "MESSAGE_TYPE_USER", + get: function () { + return "user"; + }, + }, + { + key: "MESSAGE_TYPE_FILE", + get: function () { + return "file"; + }, + }, + { + key: "SendingStatus", + get: function () { + return { + NONE: "none", + PENDING: "pending", + FAILED: "failed", + CANCELED: "canceled", + SUCCEEDED: "succeeded", + }; + }, + }, + { + key: "ReplyType", + get: function () { + return { + ALL: "all", + NONE: "none", + ONLY_REPLY_TO_CHANNEL: "only_reply_to_channel", + }; + }, + }, + { + key: "getMessage", + value: function (e, n) { + var t = this, + i = D.get(this._iid), + r = i.BaseChannel, + a = i.MessageRetrievalParams, + s = null, + o = ie.parse(arguments, [ + new ie({ + type: a, + constraint: function (e) { + return e._validate(); + }, + }), + new ie({ type: "callback" }), + ]), + u = A(o, 3); + return ( + (s = u[0]), + (e = u[1]), + (n = u[2]), + ge( + this._iid, + function (n) { + if (s) n(s, null); + else { + var i = D.get(t._iid), + a = i.GroupChannel, + o = i.OpenChannel; + switch (e.channelType) { + case r.CHANNEL_TYPE_GROUP: + a.getChannel( + e.channelUrl, + N.INTERNAL_CALL, + function (i, a) { + if ( + ft.getInstance(t._iid).getErrorFirstCallback() + ) { + var s = [i, a]; + (a = s[0]), (i = s[1]); + } + a + ? n(a, null) + : M.get( + t._iid + ).container.apiClient.getMessage( + l({ channel: i }, e), + function (e, t) { + if (e) n(e, null); + else { + var a = r.buildMessage(t, i); + n(null, a); + } + } + ); + } + ); + break; + case r.CHANNEL_TYPE_OPEN: + o.getChannel( + e.channelUrl, + N.INTERNAL_CALL, + function (i, a) { + if ( + ft.getInstance(t._iid).getErrorFirstCallback() + ) { + var s = [i, a]; + (a = s[0]), (i = s[1]); + } + a + ? n(a, null) + : M.get( + t._iid + ).container.apiClient.getMessage( + l({ channel: i }, e), + function (e, t) { + if (e) n(e, null); + else { + var a = r.buildMessage(t, i); + n(null, a); + } + } + ); + } + ); + } + } + }, + n + ) + ); + }, + }, + ] + ), + e + ); + })(), + Ee = (function () { + function e(n) { + c(this, e), + (this.nickname = ""), + (this.plainProfileUrl = ""), + (this.userId = ""), + (this.connectionStatus = ""), + (this.lastSeenAt = null), + (this.metaData = {}), + (this.isActive = !0), + (this.friendDiscoveryKey = null), + (this.friendName = null), + (this._preferredLanguages = null), + (this.requireAuth = null), + n && this.__update(n); + } + return ( + h( + e, + [ + { + key: "preferredLanguages", + get: function () { + return this._preferredLanguages; + }, + }, + { + key: "__update", + value: function (n) { + var t = M.get(this._iid).container.auth; + n.hasOwnProperty("guest_id") && + (this.userId = String(n.guest_id)), + n.hasOwnProperty("user_id") && + (this.userId = String(n.user_id)), + n.hasOwnProperty("name") && (this.nickname = String(n.name)), + n.hasOwnProperty("nickname") && + (this.nickname = String(n.nickname)), + n.hasOwnProperty("require_auth_for_profile_image") + ? (this.requireAuth = n.require_auth_for_profile_image) + : (this.requireAuth = null), + (n.hasOwnProperty("image") || + n.hasOwnProperty("profile_url")) && + ((this.plainProfileUrl = String( + n.image || n.profile_url || "" + )), + Object.defineProperty(this, "profileUrl", { + value: this.requireAuth + ? "" + .concat(this.plainProfileUrl, "?auth=") + .concat(t.eKey) + : this.plainProfileUrl, + configurable: !0, + writable: !1, + })), + n.hasOwnProperty("is_online") + ? n.is_online === e.NON_AVAILABLE + ? (this.connectionStatus = e.NON_AVAILABLE) + : (this.connectionStatus = n.is_online + ? e.ONLINE + : e.OFFLINE) + : (this.connectionStatus = e.NON_AVAILABLE), + n.hasOwnProperty("last_seen_at") + ? (this.lastSeenAt = parseInt(n.last_seen_at)) + : (this.lastSeenAt = 0), + n.hasOwnProperty("metadata") + ? (this.metaData = n.metadata) + : (this.metaData = {}), + n.hasOwnProperty("is_active") + ? (this.isActive = void 0 === n.is_active || n.is_active) + : (this.isActive = !0), + n.hasOwnProperty("friend_discovery_key") + ? (this.friendDiscoveryKey = n.friend_discovery_key) + : (this.friendDiscoveryKey = null), + n.hasOwnProperty("friend_name") + ? (this.friendName = n.friend_name) + : (this.friendName = null), + n.hasOwnProperty("preferred_languages") + ? (this._preferredLanguages = n.preferred_languages || null) + : (this._preferredLanguages = null); + }, + }, + { + key: "_updateMetaData", + value: function (e) { + var n = this, + t = + arguments.length > 1 && + void 0 !== arguments[1] && + arguments[1], + i = D.get(this._iid), + r = i.GroupChannel; + Object.keys(e).forEach(function (i) { + t ? delete n.metaData[i] : (n.metaData[i] = e[i]); + }), + Object.keys(r.cachedChannels).forEach(function (e) { + if (r.cachedChannels.hasOwnProperty(e)) { + var t = r.cachedChannels[e]; + if (t.memberMap.hasOwnProperty(n.userId)) + t.memberMap[n.userId].metaData = n.metaData; + } + }); + }, + }, + { + key: "serialize", + value: function () { + return ye.serialize(this, function (e) { + e.hasOwnProperty("_preferredLanguages") && + ((e.preferredLanguages = e._preferredLanguages), + delete e._preferredLanguages); + }); + }, + }, + { + key: "getOriginalProfileUrl", + value: function () { + var e = ""; + if ( + ((e = (e = + this.plainProfileUrl.indexOf("://") > -1 + ? this.plainProfileUrl.split("/")[2] + : this.plainProfileUrl.split("/")[0]).split( + "?" + )[0]).indexOf("sendbird.com") > -1 || + e.indexOf("sendbirdtest.com") > -1 || + e.indexOf("intoz.com") > -1 || + e.indexOf("file-local") > -1) && + this.plainProfileUrl.indexOf(e + "/profile_images/") > -1 + ) { + var n = this.plainProfileUrl.replace("profile_images/", ""); + return n === this.plainProfileUrl ? "" : n; + } + return ""; + }, + }, + { + key: "createMetaData", + value: function (e, n) { + var t = this, + i = null, + r = ie.parse(arguments, [ + new ie({ + type: "object", + constraint: function (e) { + return Object.keys(e).length > 0 && !Array.isArray(e); + }, + }), + new ie({ type: "callback" }), + ]), + a = A(r, 3); + return ( + (i = a[0]), + (e = a[1]), + (n = a[2]), + ge( + this._iid, + function (n) { + i + ? n(i, null) + : M.get(t._iid).container.apiClient.createUserMetaData( + { metaData: e }, + function (e, i) { + e || t._updateMetaData(i), n(e, i); + } + ); + }, + n + ) + ); + }, + }, + { + key: "updateMetaData", + value: function (e, n, t) { + var i = this, + r = null, + a = ie.parse(arguments, [ + new ie({ + type: "object", + constraint: function (e) { + return ( + !Array.isArray(e) && + Object.keys(e).length > 0 && + Object.keys(e) + .map(function (n) { + return e[n]; + }) + .every(function (e) { + return "string" == typeof e; + }) + ); + }, + }), + new ie({ type: "boolean", optional: !0, defaultValue: !1 }), + new ie({ type: "callback" }), + ]), + s = A(a, 4); + return ( + (r = s[0]), + (e = s[1]), + (n = s[2]), + (t = s[3]), + ge( + this._iid, + function (t) { + r + ? t(r, null) + : M.get(i._iid).container.apiClient.updateUserMetaData( + { metaData: e, upsert: n }, + function (e, n) { + e || i._updateMetaData(n), t(e, n); + } + ); + }, + t + ) + ); + }, + }, + { + key: "deleteMetaData", + value: function (e, n) { + var t = this, + i = null, + r = ie.parse(arguments, [ + new ie({ + type: "string", + constraint: function (e) { + return e.length > 0; + }, + }), + new ie({ type: "callback" }), + ]), + a = A(r, 3); + return ( + (i = a[0]), + (e = a[1]), + (n = a[2]), + ge( + this._iid, + function (n) { + if (i) n(i, null); + else { + var r = {}; + (r[e] = ""), + M.get(t._iid).container.apiClient.deleteUserMetaData( + { metaDataKey: e }, + function (e, i) { + e || t._updateMetaData(r, !0), n(e, i); + } + ); + } + }, + n + ) + ); + }, + }, + { + key: "deleteAllMetaData", + value: function (e) { + var n = this; + return ge( + this._iid, + function (e) { + var t = n.metaData; + M.get(n._iid).container.apiClient.deleteAllUserMetaData( + {}, + function (i, r) { + i || n._updateMetaData(t, !0), e(i, r); + } + ); + }, + e + ); + }, + }, + ], + [ + { + key: "objectify", + value: function (e) { + var n = e.userId, + t = void 0 === n ? null : n, + i = e.nickname, + r = void 0 === i ? "" : i, + a = e.plainProfileUrl, + s = void 0 === a ? "" : a, + o = e.connectionStatus, + l = void 0 === o ? "" : o, + u = e.lastSeenAt, + c = void 0 === u ? 0 : u, + d = e.metaData, + h = void 0 === d ? {} : d, + p = e.isActive, + f = void 0 === p || p, + y = e.friendDiscoveryKey, + g = void 0 === y ? null : y, + _ = e.friendName, + m = void 0 === _ ? null : _, + v = e.preferredLanguages, + E = void 0 === v ? null : v, + C = e.requireAuth; + return { + user_id: t, + nickname: r, + profile_url: s, + is_online: l, + last_seen_at: c, + metadata: h, + is_active: f, + friend_discovery_key: g, + friend_name: m, + preferred_languages: E, + require_auth_for_profile_image: void 0 !== C && C, + }; + }, + }, + { + key: "build", + value: function (e, n, t, i, r, a, s, o, l, u, c) { + return this.objectify({ + userId: e, + nickname: n, + plainProfileUrl: t, + connectionStatus: i, + lastSeenAt: r, + metaData: a, + isActive: s, + friendDiscoveryKey: o, + friendName: l, + preferredLanguages: u, + requireAuth: c, + }); + }, + }, + { + key: "buildFromSerializedData", + value: function (e) { + var n = D.get(this._iid).User, + t = ye.deserialize(e); + return new n(n.objectify(t)); + }, + }, + { + key: "NON_AVAILABLE", + get: function () { + return "nonavailable"; + }, + }, + { + key: "ONLINE", + get: function () { + return "online"; + }, + }, + { + key: "OFFLINE", + get: function () { + return "offline"; + }, + }, + ] + ), + e + ); + })(), + Ce = { TIMESTAMP: "timestamp", MESSAGE_ID: "messageId" }, + be = new WeakMap(), + Ue = (function () { + function e(n) { + c(this, e), + (this.url = ""), + (this.channelType = e.CHANNEL_TYPE_BASE), + (this.name = ""), + (this.coverUrl = ""), + (this.creator = null), + (this.createdAt = 0), + (this.data = null), + (this.customType = null), + (this.isFrozen = !1), + (this.isEphemeral = !1), + be.set(this, {}), + n && this.__update(n); + } + return ( + h( + e, + [ + { + key: "__update", + value: function (e) { + (this.url = e.hasOwnProperty("channel_url") + ? String(e.channel_url) + : ""), + (this.name = e.hasOwnProperty("name") ? String(e.name) : ""), + (this.coverUrl = e.hasOwnProperty("cover_url") + ? String(e.cover_url) + : ""), + (this.createdAt = e.hasOwnProperty("created_at") + ? 1e3 * e.created_at + : 0), + (this.data = e.hasOwnProperty("data") ? String(e.data) : ""), + (this.customType = e.hasOwnProperty("custom_type") + ? e.custom_type + : ""), + (this.isFrozen = !!e.hasOwnProperty("freeze") && e.freeze), + (this.isEphemeral = + !!e.hasOwnProperty("is_ephemeral") && e.is_ephemeral), + e.hasOwnProperty("created_by") && + null !== e.created_by && + "object" === u(e.created_by) && + Object.keys(e.created_by).length > 0 + ? (this.creator = new Ee(e.created_by)) + : (this.creator = null), + e.hasOwnProperty("metadata") && + null !== e.metadata && + e.hasOwnProperty("ts") && + "number" == typeof e.ts && + this._refreshMetaData(e.metadata, e.ts); + }, + }, + { + key: "_addOrUpdateCachedMetaData", + value: function (e, n) { + var t = be.get(this); + Object.keys(e).forEach(function (i) { + var r = t[i], + a = e[i]; + r + ? n > r.updatedAt && + ((r.value = a), (r.updatedAt = n), (r.isRemoved = !1)) + : (t[i] = { value: a, updatedAt: n, isRemoved: !1 }); + }); + }, + }, + { + key: "_markAsDeletedCachedMetaData", + value: function (e, n) { + var t = be.get(this); + e.forEach(function (e) { + var i = t[e]; + i + ? n > i.updatedAt && ((i.isRemoved = !0), (i.updatedAt = n)) + : (t[e] = { value: null, updatedAt: n, isRemoved: !0 }); + }); + }, + }, + { + key: "_refreshMetaData", + value: function (e, n) { + var t = {}; + Object.keys(e).forEach(function (i) { + t[i] = { value: e[i], updatedAt: n, isRemoved: !1 }; + }), + be.set(this, t); + }, + }, + { + key: "isGroupChannel", + value: function () { + var e = D.get(this._iid).BaseChannel; + return this.channelType === e.CHANNEL_TYPE_GROUP; + }, + }, + { + key: "isOpenChannel", + value: function () { + var e = D.get(this._iid).BaseChannel; + return this.channelType === e.CHANNEL_TYPE_OPEN; + }, + }, + { + key: "createOperatorListQuery", + value: function () { + return new (0, D.get(this._iid).OperatorListQuery)(this); + }, + }, + { + key: "createMessageListQuery", + value: function () { + return new (0, D.get(this._iid).MessageListQuery)(this); + }, + }, + { + key: "createPreviousMessageListQuery", + value: function () { + return new (0, D.get(this._iid).PreviousMessageListQuery)(this); + }, + }, + { + key: "createPollListQuery", + value: function () { + return new (0, D.get(this._iid).PollListQuery)({ + channelUrl: this.url, + }); + }, + }, + { + key: "createPollVoterListQuery", + value: function (e, n) { + return new (0, D.get(this._iid).PollVoterListQuery)({ + channelUrl: this.url, + pollId: e, + optionId: n, + }); + }, + }, + { + key: "serialize", + value: function () { + return ye.serialize(this, function (e) { + if (null !== e.lastMessage && "object" === u(e.lastMessage)) { + var n = e.lastMessage; + n.hasOwnProperty("_sender") && + ((n.sender = n._sender), + delete n._sender, + (e.lastMessage = n)); + } + e.hasOwnProperty("_messageOffsetTimestamp") && + ((e.messageOffsetTimestamp = e._messageOffsetTimestamp), + delete e._messageOffsetTimestamp); + }); + }, + }, + { + key: "getMessageChangeLogsByTimestamp", + value: function (e, n, t, i) { + var r = this, + a = null, + s = ie.parse(arguments, [ + new ie({ + type: "number", + constraint: function (e) { + return e >= 0; + }, + }), + new ie({ type: "boolean", optional: !0, defaultValue: !1 }), + new ie({ type: "boolean", optional: !0, defaultValue: !1 }), + new ie({ type: "callback" }), + ]), + o = A(s, 5); + return ( + (a = o[0]), + (e = o[1]), + (n = o[2]), + (t = o[3]), + (i = o[4]), + ge( + this._iid, + function (i) { + a + ? i(a, null) + : M.get( + r._iid + ).container.apiClient.getMessageChangeLogs( + { + channelUrl: r.url, + ts: e, + token: null, + isOpenChannel: r.isOpenChannel(), + includeMetaArray: n, + includeReactions: t, + }, + function (e, n) { + var t = null; + if (!e) { + var a = D.get(r._iid).BaseChannel; + t = { + updatedMessages: n.updated.map(function (e) { + return a.buildMessage(e, r); + }), + deletedMessageIds: n.deleted.map(function ( + e + ) { + return parseInt(e.message_id); + }), + hasMore: n.has_more, + token: n.next, + }; + } + i(e, t); + } + ); + }, + i + ) + ); + }, + }, + { + key: "getMessageChangeLogsByToken", + value: function (e, n, t, i) { + var r = this, + a = null, + s = ie.parse(arguments, [ + new ie({ type: "string", nullable: !0 }), + new ie({ type: "boolean", optional: !0, defaultValue: !1 }), + new ie({ type: "boolean", optional: !0, defaultValue: !1 }), + new ie({ type: "callback" }), + ]), + o = A(s, 5); + return ( + (a = o[0]), + (e = o[1]), + (n = o[2]), + (t = o[3]), + (i = o[4]), + ge( + this._iid, + function (i) { + a + ? i(a, null) + : M.get( + r._iid + ).container.apiClient.getMessageChangeLogs( + { + channelUrl: r.url, + ts: null, + token: e, + isOpenChannel: r.isOpenChannel(), + includeMetaArray: n, + includeReactions: t, + }, + function (e, n) { + var t = null; + if (!e) { + var a = D.get(r._iid).BaseChannel; + t = { + updatedMessages: n.updated.map(function (e) { + return a.buildMessage(e, r); + }), + deletedMessageIds: n.deleted.map(function ( + e + ) { + return parseInt(e.message_id); + }), + hasMore: n.has_more, + token: n.next, + }; + } + i(e, t); + } + ); + }, + i + ) + ); + }, + }, + { + key: "getMessageChangeLogsSinceToken", + value: function (e, n, t) { + var i = this, + r = D.get(this._iid), + a = r.BaseChannel, + s = r.MessageChangeLogsParams, + o = null, + u = ie.parse(arguments, [ + new ie({ type: "string", nullable: !0 }), + new ie({ type: s }), + new ie({ type: "callback" }), + ]), + c = A(u, 4); + return ( + (o = c[0]), + (e = c[1]), + (n = c[2]), + (t = c[3]), + ge( + this._iid, + function (t) { + o + ? t(o, null) + : M.get( + i._iid + ).container.apiClient.getMessageChangeLogs( + l( + { + channelUrl: i.url, + ts: null, + token: e, + isOpenChannel: i.isOpenChannel(), + }, + n + ), + function (e, n) { + var r = null; + e || + (r = { + updatedMessages: n.updated.map(function (e) { + return a.buildMessage(e, i); + }), + deletedMessageIds: n.deleted.map(function ( + e + ) { + return parseInt(e.message_id); + }), + hasMore: n.has_more, + token: n.next, + }), + t(e, r); + } + ); + }, + t + ) + ); + }, + }, + { + key: "getMessageChangeLogsSinceTimestamp", + value: function (e, n, t) { + var i = this, + r = D.get(this._iid), + a = r.BaseChannel, + s = r.MessageChangeLogsParams, + o = null, + u = ie.parse(arguments, [ + new ie({ + type: "number", + constraint: function (e) { + return e >= 0; + }, + }), + new ie({ type: s }), + new ie({ type: "callback" }), + ]), + c = A(u, 4); + return ( + (o = c[0]), + (e = c[1]), + (n = c[2]), + (t = c[3]), + ge( + this._iid, + function (t) { + o + ? t(o, null) + : M.get( + i._iid + ).container.apiClient.getMessageChangeLogs( + l( + { + channelUrl: i.url, + timestamp: e, + token: null, + isOpenChannel: i.isOpenChannel(), + }, + n + ), + function (e, n) { + var r = null; + e || + (r = { + updatedMessages: n.updated.map(function (e) { + return a.buildMessage(e, i); + }), + deletedMessageIds: n.deleted.map(function ( + e + ) { + return parseInt(e.message_id); + }), + hasMore: n.has_more, + token: n.next, + }), + t(e, r); + } + ); + }, + t + ) + ); + }, + }, + { + key: "getMyMutedInfo", + value: function (e) { + var n = this; + return ge( + this._iid, + function (e) { + var t = ft.getInstance(n._iid); + M.get(n._iid).container.apiClient.getMyMutedInfo( + { + channelUrl: n.url, + userId: t.currentUser ? t.currentUser.userId : null, + isGroupChannel: n.isGroupChannel(), + }, + function (n, t) { + var i = null; + n || + (i = { + isMuted: t.is_muted, + startAt: t.start_at, + endAt: t.end_at, + remainingDuration: t.remaining_duration, + description: t.description, + }), + e(n, i); + } + ); + }, + e + ); + }, + }, + { + key: "_parseMessageListParams", + value: function (e) { + for ( + var n = D.get(this._iid), + t = n.MessageListParams, + i = new t(), + r = null, + a = !1, + s = 0, + o = 0, + l = !1, + u = "", + c = "", + d = null, + h = !1, + p = !1, + f = null, + y = arguments.length, + g = new Array(y > 1 ? y - 1 : 0), + _ = 1; + _ < y; + _++ + ) + g[_ - 1] = arguments[_]; + switch (e) { + case "prev": + var m = ie.parse(g, [ + new ie({ type: "number" }), + new ie({ type: "boolean" }), + new ie({ type: "number" }), + new ie({ type: "boolean" }), + new ie({ type: "string" }), + new ie({ type: "string" }), + new ie({ type: "array", optional: !0 }), + new ie({ + type: "boolean", + optional: !0, + defaultValue: !1, + }), + new ie({ + type: "boolean", + optional: !0, + defaultValue: !1, + }), + new ie({ type: "callback" }), + ]), + v = A(m, 11); + (r = v[0]), + (a = v[2]), + (s = v[3]), + (l = v[4]), + (u = v[5]), + (c = v[6]), + (d = v[7]), + (h = v[8]), + (p = v[9]), + (f = v[10]); + break; + case "next": + var E = ie.parse(g, [ + new ie({ type: "number" }), + new ie({ type: "boolean" }), + new ie({ type: "number" }), + new ie({ type: "boolean" }), + new ie({ type: "string" }), + new ie({ type: "string" }), + new ie({ type: "array", optional: !0 }), + new ie({ + type: "boolean", + optional: !0, + defaultValue: !1, + }), + new ie({ + type: "boolean", + optional: !0, + defaultValue: !1, + }), + new ie({ type: "callback" }), + ]), + C = A(E, 11); + (r = C[0]), + (a = C[2]), + (o = C[3]), + (l = C[4]), + (u = C[5]), + (c = C[6]), + (d = C[7]), + (h = C[8]), + (p = C[9]), + (f = C[10]); + break; + case "prevnext": + var b = ie.parse(g, [ + new ie({ type: "number" }), + new ie({ type: "number" }), + new ie({ type: "number" }), + new ie({ type: "boolean" }), + new ie({ type: "string" }), + new ie({ type: "string" }), + new ie({ type: "array", optional: !0 }), + new ie({ + type: "boolean", + optional: !0, + defaultValue: !1, + }), + new ie({ + type: "boolean", + optional: !0, + defaultValue: !1, + }), + new ie({ type: "callback" }), + ]), + U = A(b, 11); + (r = U[0]), + (s = U[2]), + (o = U[3]), + (l = U[4]), + (u = U[5]), + (c = U[6]), + (d = U[7]), + (h = U[8]), + (p = U[9]), + (f = U[10]), + (a = !0); + } + return r + ? [null, f] + : ((i.isInclusive = a), + (i.prevResultSize = s), + (i.nextResultSize = o), + (i.reverse = l), + (i.messageType = u), + (i.customType = c), + "" === i.customType && (i.customType = "*"), + (i.senderUserIds = d), + (i.includeMetaArray = h), + (i.includeReactions = p), + [i, f]); + }, + }, + { + key: "_getMessageList", + value: function (e, n, t, i) { + var r = this, + a = D.get(this._iid), + s = a.MessageListParams, + o = null, + u = ie.parse(arguments, [ + new ie({ type: "number" }), + new ie({ + type: "string", + constraint: function (e) { + return Object.values(Ce).includes(e); + }, + }), + new ie({ + type: s, + constraint: function (e) { + return e._validate(); + }, + }), + new ie({ type: "callback" }), + ]), + c = A(u, 5); + return ( + (o = c[0]), + (e = c[1]), + (n = c[2]), + (t = c[3]), + (i = c[4]), + ge( + this._iid, + function (i) { + o + ? i(o, null) + : M.get(r._iid).container.apiClient.getMessageList( + l( + l({ channel: r, token: e, tokenType: n }, t), + {}, + { shouldReverse: t.reverse } + ), + function (e, n) { + if (e) i(e, null); + else { + var t = D.get(r._iid).BaseChannel, + a = n.messages + .map(function (e) { + return t.buildMessage(e, r); + }) + .filter(function (e) { + return null !== e; + }); + i(null, a); + } + } + ); + }, + i + ) + ); + }, + }, + { + key: "getPreviousMessagesByTimestamp", + value: function (e) { + var n = this._parseMessageListParams.apply( + this, + ["prev"].concat(I(ie.toArray(arguments))) + ), + t = A(n, 2), + i = t[0], + r = t[1]; + return this._getMessageList(e, Ce.TIMESTAMP, i, r); + }, + }, + { + key: "getNextMessagesByTimestamp", + value: function (e) { + var n = this._parseMessageListParams.apply( + this, + ["next"].concat(I(ie.toArray(arguments))) + ), + t = A(n, 2), + i = t[0], + r = t[1]; + return this._getMessageList(e, Ce.TIMESTAMP, i, r); + }, + }, + { + key: "getPreviousAndNextMessagesByTimestamp", + value: function (e) { + var n = this._parseMessageListParams.apply( + this, + ["prevnext"].concat(I(ie.toArray(arguments))) + ), + t = A(n, 2), + i = t[0], + r = t[1]; + return this._getMessageList(e, Ce.TIMESTAMP, i, r); + }, + }, + { + key: "getPreviousMessagesByID", + value: function (e) { + var n = this._parseMessageListParams.apply( + this, + ["prev"].concat(I(ie.toArray(arguments))) + ), + t = A(n, 2), + i = t[0], + r = t[1]; + return this._getMessageList(e, Ce.MESSAGE_ID, i, r); + }, + }, + { + key: "getNextMessagesByID", + value: function (e) { + var n = this._parseMessageListParams.apply( + this, + ["next"].concat(I(ie.toArray(arguments))) + ), + t = A(n, 2), + i = t[0], + r = t[1]; + return this._getMessageList(e, Ce.MESSAGE_ID, i, r); + }, + }, + { + key: "getPreviousAndNextMessagesByID", + value: function (e) { + var n = this._parseMessageListParams.apply( + this, + ["prevnext"].concat(I(ie.toArray(arguments))) + ), + t = A(n, 2), + i = t[0], + r = t[1]; + return this._getMessageList(e, Ce.MESSAGE_ID, i, r); + }, + }, + { + key: "getMessagesByTimestamp", + value: function (e, n, t) { + return this._getMessageList(e, Ce.TIMESTAMP, n, t); + }, + }, + { + key: "getMessagesByMessageId", + value: function (e, n, t) { + return this._getMessageList(e, Ce.MESSAGE_ID, n, t); + }, + }, + { + key: "_sendUserMessage", + value: function (e) { + var n = this, + t = e.reqId, + i = e.message, + r = e.data, + a = e.customType, + s = e.metaArrays, + o = e.mentionType, + l = e.mentionedUserIds, + u = e.pushNotificationDeliveryOption, + c = e.rootMessageId, + d = e.parentMessageId, + h = e.translationTargetLanguages, + p = e.appleCriticalAlertOptions, + f = e.pollId, + y = e.silent, + g = void 0 !== y && y, + _ = e.isReplyToChannel, + m = e.callback, + v = D.get(this._iid), + E = v.Command, + C = v.UserMessage; + t || (t = E.generateRequestId()); + var b = ft.getInstance(this._iid), + U = {}; + Array.isArray(h) && + h.forEach(function (e) { + return (U[e] = ""); + }); + var A = C.objectify({ + messageId: 0, + reqId: t, + user: b.currentUser || {}, + channel: this, + message: i, + data: r, + customType: a, + metaArrays: s, + mentionType: o, + mentionedUserIds: l, + rootMessageId: c, + parentMessageId: d, + translations: U, + silent: g, + appleCriticalAlertOptions: p, + isReplyToChannel: _, + createdAt: new Date().getTime(), + }), + I = new C(A); + if ( + ((I.requestState = b.MessageRequestState.PENDING), + (I.sendingStatus = b.MessageSendingStatus.PENDING), + (I.requestedMentionUserIds = l), + !b.currentUser) + ) { + var S = new P( + "Connection should be made first.", + P.CONNECTION_REQUIRED + ), + k = new C(A); + return ( + (k.requestState = b.MessageRequestState.FAILED), + (k.sendingStatus = b.MessageSendingStatus.FAILED), + (k.requestedMentionUserIds = l), + (k.errorCode = S.code), + m(S, k), + I + ); + } + var O = E.bMessage({ + channelUrl: this.url, + message: i, + data: r, + customType: a, + metaArrays: s, + mentionType: o, + mentionedUserIds: l, + requestId: t, + rootMessageId: c, + parentMessageId: d, + silent: g, + translationTargetLanguages: h, + pushNotificationDeliveryOption: u, + appleCriticalAlertOptions: p, + pollId: f, + isReplyToChannel: _, + }); + ((I.reqId = O.requestId), + this.isGroupChannel() && + b.getConnectionState() !== b.ConnectionState.OPEN && + b.currentUser && + !b.connecting && + !b.reconnecting && + "string" == typeof a && + 0 === a.indexOf("SB_VIDEOCHAT")) + ? M.get(b._iid).container.apiClient.sendUserMessage( + { + channelUrl: this.url, + isOpenChannel: this.isOpenChannel(), + message: i, + data: r, + customType: a, + translationTargetLanguages: h, + metaArrays: s, + mentionType: o, + mentionedUserIds: l, + pushNotificationDeliveryOption: u, + rootMessageId: c, + parentMessageId: d, + appleCriticalAlertOptions: p, + pollId: f, + isReplyToChannel: _, + }, + function (e, n) { + var t = null; + e + ? (((t = new C(A)).requestState = + b.MessageRequestState.FAILED), + (t.sendingStatus = b.MessageSendingStatus.FAILED), + e.code === P.REQUEST_CANCELED && + (t.sendingStatus = + b.MessageSendingStatus.CANCELED), + (t.requestedMentionUserIds = l), + (t.errorCode = e.code)) + : (((t = new C(n)).requestState = + b.MessageRequestState.SUCCEEDED), + (t.sendingStatus = + b.MessageSendingStatus.SUCCEEDED)), + m(e, t); + } + ) + : b.sendCommand(O, function (e, t) { + if (b.getErrorFirstCallback()) { + var i = [e, t]; + (t = i[0]), (e = i[1]); + } + if (t) { + var r = new C(A); + (r.reqId = O.requestId), + (r.requestState = b.MessageRequestState.FAILED), + (r.sendingStatus = b.MessageSendingStatus.FAILED), + t.code === P.REQUEST_CANCELED && + (r.sendingStatus = b.MessageSendingStatus.CANCELED), + (r.requestedMentionUserIds = l), + (r.errorCode = t.code), + m(new P(t.message, t.code), r); + } else { + var a = new C(e.getJsonElement()), + s = b.currentUser; + s && + a._sender && + s.userId === a._sender.userId && + (s.nickname !== a._sender.nickname && + (s.nickname = a._sender.nickname), + s.plainProfileUrl !== a._sender.plainProfileUrl && + (s.plainProfileUrl = a._sender.plainProfileUrl), + X.deepEqual(s.metaData, a._sender.metaData) || + (s.metaData = a._sender.metaData)), + n.isGroupChannel() && + ((n.lastMessage = a), + Object.keys(b.channelHandlers).forEach(function ( + e + ) { + b.channelHandlers[e].onChannelChanged(n); + })), + (a.requestState = b.MessageRequestState.SUCCEEDED), + (a.sendingStatus = b.MessageSendingStatus.SUCCEEDED), + m(null, a); + } + }); + return I; + }, + }, + { + key: "sendUserMessage", + value: function () { + var e = ie.toArray(arguments), + n = e.pop(), + t = null, + i = null, + r = D.get(this._iid), + a = r.UserMessageParams; + if ("function" == typeof n) + if (e[0] instanceof a) + null === (i = e[0]).data && (i.data = ""), + null === i.customType && (i.customType = ""); + else if ("string" == typeof e[0]) + switch ((((i = new a()).message = e[0]), e.length)) { + case 1: + break; + case 2: + i.data = e[1] || ""; + break; + case 3: + (i.data = e[1] || ""), (i.customType = e[2] || ""); + break; + case 4: + (i.data = e[1] || ""), + (i.customType = e[2] || ""), + (i.translationTargetLanguages = Array.isArray(e[3]) + ? e[3] + : [e[3]]); + break; + default: + t = ie.error; + } + else t = ie.error; + else t = ie.error; + var s = M.get(this._iid), + o = s.container.isErrorFirstInCallback; + return !t && i._validate() && i.message + ? this._sendUserMessage( + l( + l({}, i), + {}, + { + metaArrays: i.metaArrays, + mentionType: i.mentionType, + mentionedUserIds: i._mentionedUserIds, + rootMessageId: i.rootMessageId, + parentMessageId: i.parentMessageId, + translationTargetLanguages: + i._translationTargetLanguages, + callback: function (e, t) { + o ? n(e, t) : n(t, e); + }, + } + ) + ) + : (o ? n(ie.error, null) : n(null, ie.error), null); + }, + }, + { + key: "resendUserMessage", + value: function (e, n) { + var t = this, + i = D.get(this._iid), + r = i.UserMessage, + a = i.UserMessageParams, + s = null, + o = ie.parse(arguments, [ + new ie({ + type: r, + constraint: function (e) { + return ( + 0 === e.messageId && + e.isResendable() && + e.reqId && + e.channelUrl === t.url && + "string" == typeof e.message && + "string" == typeof e.data && + "string" == typeof e.customType && + "object" === u(e.translations) && + !Array.isArray(e.translations) + ); + }, + }), + new ie({ type: "callback" }), + ]), + c = A(o, 3); + return ( + (s = c[0]), + (e = c[1]), + (n = c[2]), + ge( + this._iid, + function (n) { + if (s) + (s.message += + " Please check if the failed message is resend-able with `message.isResendable().`"), + n(s, null); + else { + var i = Object.keys(e.translations), + r = a.PushNotificationDeliveryOption.DEFAULT; + t._sendUserMessage( + l( + l({}, e), + {}, + { + mentionedUserIds: e.requestedMentionUserIds, + translationTargetLanguages: i, + pushNotificationDeliveryOption: r, + reqId: e.reqId, + callback: n, + } + ) + ); + } + }, + n + ) + ); + }, + }, + { + key: "updateUserMessage", + value: function (e, n, t, i, r) { + var a = this, + s = D.get(this._iid), + o = s.Command, + u = s.UserMessage, + c = s.UserMessageParams, + d = arguments, + h = null, + p = null; + if ("number" == typeof e) + switch (d.length) { + case 3: + var f = ie.parse(d, [ + new ie({ type: "number" }), + new ie({ type: c }), + new ie({ type: "callback" }), + ]), + y = A(f, 4); + (h = y[0]), (e = y[1]), (p = y[2]), (r = y[3]); + break; + case 5: + p = new c(); + var g = ie.parse(d, [ + new ie({ type: "number" }), + new ie({ type: "string", nullable: !0 }), + new ie({ type: "string", nullable: !0 }), + new ie({ type: "string", nullable: !0 }), + new ie({ type: "callback" }), + ]), + _ = A(g, 6); + (h = _[0]), + (e = _[1]), + (n = _[2]), + (t = _[3]), + (i = _[4]), + (r = _[5]), + (p.message = n), + (p.data = t), + (p.customType = i); + } + return ge( + this._iid, + function (n) { + if (!h && p && p._validate()) { + var t = o.bUpdateUserMessage( + l( + l({ channelUrl: a.url, messageId: e }, p), + {}, + { + mentionType: p._mentionType, + mentionedUserIds: p._mentionedUserIds, + } + ) + ), + i = ft.getInstance(a._iid); + i.sendCommand(t, function (e, t) { + if (i.getErrorFirstCallback()) { + var r = [e, t]; + (t = r[0]), (e = r[1]); + } + var a = null; + t || (a = new u(e.getJsonElement())), n(t, a); + }); + } else n(ie.error, null); + }, + r + ); + }, + }, + { + key: "translateUserMessage", + value: function (e, n, t) { + var i = this, + r = ft.getInstance(this._iid), + a = D.get(this._iid), + s = a.UserMessage, + o = null, + l = ie.parse(arguments, [ + new ie({ + type: s, + constraint: function (e) { + return ( + e.channelUrl === i.url && + e.sendingStatus === r.MessageSendingStatus.SUCCEEDED + ); + }, + }), + new ie({ + type: "array", + constraint: function (e) { + return e.every(function (e) { + return "string" == typeof e; + }); + }, + }), + new ie({ type: "callback" }), + ]), + u = A(l, 4); + return ( + (o = u[0]), + (e = u[1]), + (n = u[2]), + (t = u[3]), + ge( + this._iid, + function (t) { + o + ? t(o, null) + : M.get( + i._iid + ).container.apiClient.translateUserMessage( + { + channelUrl: i.url, + isOpenChannel: i.isOpenChannel(), + messageId: e.messageId, + translationTargetLanguages: n, + }, + function (e, n) { + var i = null; + e || (i = new s(n)), t(e, i); + } + ); + }, + t + ) + ); + }, + }, + { + key: "_parseFileMessageArguments", + value: function (e) { + var n = D.get(this._iid), + t = n.BaseMessageParams, + i = n.FileMessageParams, + r = { + error: null, + file: null, + name: null, + type: null, + size: null, + data: "", + customType: "", + thumbnailSizes: [], + metaArrays: [], + mentionType: t.MentionType.USERS, + mentionedUserIds: [], + pushNotificationDeliveryOption: + i.PushNotificationDeliveryOption.DEFAULT, + rootMessageId: null, + parentMessageId: null, + progressHandler: null, + silent: !1, + appleCriticalAlertOptions: null, + isReplyToChannel: !1, + callback: null, + }; + if ( + ("function" == typeof e[e.length - 1] && + (r.callback = e.pop()), + "function" == typeof e[e.length - 1] && + (r.progressHandler = e.pop()), + e[0] instanceof i) + ) + (r.file = e[0].file || e[0].fileUrl), + (r.name = e[0].fileName), + (r.type = e[0].mimeType), + (r.size = e[0].fileSize), + (r.data = e[0].data), + (r.customType = e[0].customType), + (r.thumbnailSizes = e[0].thumbnailSizes), + (r.metaArrays = e[0].metaArrays), + (r.mentionType = e[0]._mentionType), + (r.mentionedUserIds = e[0]._mentionedUserIds), + (r.pushNotificationDeliveryOption = e[0] + .pushNotificationDeliveryOption + ? e[0].pushNotificationDeliveryOption + : i.PushNotificationDeliveryOption.DEFAULT), + (r.rootMessageId = e[0].rootMessageId), + (r.parentMessageId = e[0].parentMessageId), + (r.silent = e[0].silent), + e[0]._validate() || (r.error = ie.error), + (r.appleCriticalAlertOptions = + e[0].appleCriticalAlertOptions), + (r.isReplyToChannel = e[0].isReplyToChannel); + else if (X.isFile(e[0]) || "string" == typeof e[0]) { + switch (((r.file = e[0]), e.length)) { + case 1: + break; + case 2: + r.data = e[1]; + break; + case 3: + (r.data = e[1]), (r.customType = e[2]); + break; + case 4: + (r.data = e[1]), + (r.customType = e[2]), + (r.thumbnailSizes = e[3]); + break; + case 5: + (r.name = e[1]), + (r.type = e[2]), + (r.size = e[3]), + (r.data = e[4]); + break; + case 6: + (r.name = e[1]), + (r.type = e[2]), + (r.size = e[3]), + (r.data = e[4]), + (r.customType = e[5]); + break; + case 7: + (r.name = e[1]), + (r.type = e[2]), + (r.size = e[3]), + (r.data = e[4]), + (r.customType = e[5]), + (r.thumbnailSizes = e[6]); + } + var a = A( + ie.parse( + [ + r.file, + r.name, + r.type, + r.size, + r.data, + r.customType, + r.thumbnailSizes, + ], + [ + new ie({ type: ["file", "string"] }), + new ie({ type: "string", nullable: !0 }), + new ie({ type: "string", nullable: !0 }), + new ie({ + type: "number", + nullable: !0, + constraint: function (e) { + return e >= 0; + }, + }), + new ie({ type: "string", nullable: !0 }), + new ie({ type: "string", nullable: !0 }), + new ie({ type: "array" }), + ] + ), + 8 + ); + (r.error = a[0]), + (r.file = a[1]), + (r.name = a[2]), + (r.type = a[3]), + (r.size = a[4]), + (r.data = a[5]), + (r.customType = a[6]), + (r.thumbnailSizes = a[7]); + } else r.error = ie.error; + return ( + X.isFile(r.file) && + ((r.name = r.name || r.file.name), + (r.type = r.type || r.file.type), + (r.size = r.size || r.file.size)), + r + ); + }, + }, + { + key: "_createTempFileMessage", + value: function (e) { + try { + var n = ft.getInstance(this._iid), + t = D.get(this._iid), + i = t.Command, + r = t.FileMessage, + a = r.objectify( + l( + l({}, e), + {}, + { + messageId: 0, + reqId: i.generateRequestId(), + user: n.currentUser || {}, + channel: this, + plainUrl: "string" == typeof e.file ? e.file : "", + thumbnails: e.thumbnailSizes.map(function (e) { + return { + url: "", + plainUrl: "", + width: e.maxWidth, + height: e.maxHeight, + real_width: 0, + real_height: 0, + }; + }), + sendingStatus: n.MessageSendingStatus.PENDING, + createdAt: new Date().getTime(), + } + ) + ); + return new r(a); + } catch (e) { + return null; + } + }, + }, + { + key: "sendFileMessage", + value: function () { + var e = this._parseFileMessageArguments(ie.toArray(arguments)), + n = D.get(this._iid), + t = n.Command, + i = null, + r = t.generateRequestId(); + e.error || + (((i = this._createTempFileMessage( + e + )).requestedMentionUserIds = e.mentionedUserIds), + (r = i.reqId)); + var a = ft.getInstance(this._iid); + (a && a.currentUser) || + (e.error = new P( + "Connection should be made first.", + P.CONNECTION_REQUIRED + )); + var s = D.get(this._iid), + o = s.FileMessageQueue, + l = o.create(this); + return ( + l.addJob( + new o.Job({ + fileInfo: e, + pendingMessage: i, + requestId: r, + error: e.error, + response: null, + }) + ), + i + ); + }, + }, + { + key: "sendFileMessages", + value: function (e) { + var n = this, + t = + arguments.length > 1 && void 0 !== arguments[1] + ? arguments[1] + : {}, + i = t.progress ? t.progress : function () {}, + r = t.sent ? t.sent : function () {}, + a = t.complete ? t.complete : function () {}; + if (Array.isArray(e) && e.length > 0 && e.length <= 20) { + var s = []; + return ( + e.forEach(function (t, o) { + s.push( + n.sendFileMessage(t, i, function (n, t) { + r(n, t), o === e.length - 1 && a(null); + }) + ); + }), + s + ); + } + return a(ie.error), null; + }, + }, + { + key: "resendFileMessage", + value: function (e, n, t) { + var i = this, + r = D.get(this._iid), + a = r.FileMessage, + s = r.FileMessageParams, + o = null, + l = ie.parse(arguments, [ + new ie({ + type: a, + constraint: function (e) { + return ( + 0 === e.messageId && + e.isResendable() && + e.reqId && + e.channelUrl === i.url && + "string" == typeof e.data && + "string" == typeof e.customType && + Array.isArray(e.thumbnails) + ); + }, + }), + new ie({ + type: "file", + optionalIf: function (e) { + return !!e[0].url; + }, + defaultValue: null, + }), + new ie({ type: "callback" }), + ]), + u = A(l, 4); + return ( + (o = u[0]), + (e = u[1]), + (n = u[2]), + (t = u[3]), + ge( + this._iid, + function (t) { + if (o) + (o.message += + " Please check if the failed message is resend-able with `message.isResendable().`"), + t(o, null); + else { + var r = new s(); + e.url ? (r.fileUrl = e.url) : (r.file = n), + (r.fileName = e.name), + (r.fileSize = e.size), + (r.mimeType = e.type), + (r.data = e.data), + (r.customType = e.customType), + (r.mentionType = e.mentionType), + (r.mentionedUserIds = e.requestedMentionUserIds), + (r.metaArrays = e.metaArrays), + (r.thumbnailSizes = e.thumbnails.map(function (e) { + return { maxWidth: e.width, maxHeight: e.height }; + })), + (r.appleCriticalAlertOptions = + e.appleCriticalAlertOptions), + i.sendFileMessage(r, t); + } + }, + t + ) + ); + }, + }, + { + key: "updateFileMessage", + value: function (e, n, t, i) { + var r = this, + a = D.get(this._iid), + s = a.Command, + o = a.FileMessage, + u = a.FileMessageParams, + c = arguments, + d = null, + h = null; + if ("number" == typeof e) + switch (c.length) { + case 3: + var p = ie.parse(c, [ + new ie({ type: "number" }), + new ie({ type: u }), + new ie({ type: "callback" }), + ]), + f = A(p, 4); + (d = f[0]), + (e = f[1]), + (h = f[2]), + (i = f[3]), + h && (h._isUpdate = !0); + break; + case 4: + h = new u(); + var y = ie.parse(c, [ + new ie({ type: "number" }), + new ie({ type: "string", nullable: !0 }), + new ie({ type: "string", nullable: !0 }), + new ie({ type: "callback" }), + ]), + g = A(y, 5); + (d = g[0]), + (e = g[1]), + (n = g[2]), + (t = g[3]), + (i = g[4]), + (h.data = n), + (h.customType = t), + (h._isUpdate = !0); + } + return ge( + this._iid, + function (n) { + if (!d && h && h._validate()) { + var t = s.bUpdateFileMessage( + l( + l({ channelUrl: r.url, messageId: e }, h), + {}, + { + mentionType: h._mentionType, + mentionedUserIds: h._mentionedUserIds, + } + ) + ), + i = ft.getInstance(r._iid); + i.sendCommand(t, function (e, t) { + if (i.getErrorFirstCallback()) { + var r = [e, t]; + (t = r[0]), (e = r[1]); + } + var a = null; + t || (a = new o(e.getJsonElement())), n(t, a); + }); + } else n(ie.error, null); + }, + i + ); + }, + }, + { + key: "cancelUploadingFileMessage", + value: function (e, n) { + var t = null, + i = ie.parse(arguments, [ + new ie({ type: ["number", "string"] }), + new ie({ type: "callback" }), + ]), + r = A(i, 3); + (t = r[0]), (e = r[1]), (n = r[2]); + var a = M.get(this._iid), + s = a.container.isErrorFirstInCallback; + if (t) return s ? n(t, null) : n(null, t), !1; + var o = D.get(this._iid), + l = o.FileMessageQueue, + u = l.create(this); + return u.cancelUploadItemByRequestId(e, function (e, t) { + return s ? n(e, t) : n(t, e); + }); + }, + }, + { + key: "addReaction", + value: function (e, n, t) { + var i = this, + r = ft.getInstance(this._iid), + a = D.get(this._iid), + s = a.ReactionEvent, + o = null, + u = ie.parse(arguments, [ + new ie({ type: ve }), + new ie({ + type: "string", + constraint: function (e) { + return e.length > 0; + }, + }), + new ie({ type: "callback" }), + ]), + c = A(u, 4); + return ( + (o = c[0]), + (e = c[1]), + (n = c[2]), + (t = c[3]), + ge( + this._iid, + function (t) { + o + ? t(o, null) + : e.sendingStatus === r.MessageSendingStatus.SUCCEEDED + ? M.get(i._iid).container.apiClient.addReaction( + { + isGroupChannel: e.isGroupChannel(), + channelUrl: e.channelUrl, + messageId: e.messageId, + key: n, + }, + function (n, i) { + var r = null; + n || + (r = s.createFromJson( + l(l({}, i), {}, { msg_id: e.messageId }) + )), + t(n, r); + } + ) + : t( + new P( + "Cannot add reaction to a non-succeeded message.", + P.REQUEST_FAILED + ), + null + ); + }, + t + ) + ); + }, + }, + { + key: "deleteReaction", + value: function (e, n, t) { + var i = this, + r = ft.getInstance(this._iid), + a = D.get(this._iid), + s = a.ReactionEvent, + o = null, + u = ie.parse(arguments, [ + new ie({ type: ve }), + new ie({ + type: "string", + constraint: function (e) { + return e.length > 0; + }, + }), + new ie({ type: "callback" }), + ]), + c = A(u, 4); + return ( + (o = c[0]), + (e = c[1]), + (n = c[2]), + (t = c[3]), + ge( + this._iid, + function (t) { + o + ? t(o, null) + : e.sendingStatus === r.MessageSendingStatus.SUCCEEDED + ? M.get(i._iid).container.apiClient.deleteReaction( + { + isGroupChannel: e.isGroupChannel(), + channelUrl: e.channelUrl, + messageId: e.messageId, + key: n, + }, + function (n, i) { + var r = null; + n || + (r = s.createFromJson( + l(l({}, i), {}, { msg_id: e.messageId }) + )), + t(n, r); + } + ) + : t( + new P( + "Cannot remove reaction to a non-succeeded message.", + P.REQUEST_FAILED + ), + null + ); + }, + t + ) + ); + }, + }, + { + key: "deleteMessage", + value: function (e, n) { + var t = this, + i = null, + r = ie.parse(arguments, [ + new ie({ + type: "object", + constraint: function (e) { + return ( + !Array.isArray(e) && + null !== e && + e.hasOwnProperty("messageId") + ); + }, + }), + new ie({ type: "callback" }), + ]), + a = A(r, 3); + return ( + (i = a[0]), + (e = a[1]), + (n = a[2]), + ge( + this._iid, + function (n) { + i + ? n(i, null) + : M.get(t._iid).container.apiClient.deleteMessage( + { + channelUrl: t.url, + isOpenChannel: t.isOpenChannel(), + messageId: e.messageId, + }, + function (e, t) { + return n(e, null); + } + ); + }, + n + ) + ); + }, + }, + { + key: "copyUserMessage", + value: function (n, t, i) { + var r = D.get(this._iid); + r.Command; + var a = r.UserMessage, + s = r.BaseMessageParams, + o = null, + u = ie.parse(arguments, [ + new ie({ type: e }), + new ie({ type: a }), + new ie({ type: "callback" }), + ]), + c = A(u, 4); + (o = c[0]), (n = c[1]), (t = c[2]), (i = c[3]); + var d = M.get(this._iid), + h = d.container.isErrorFirstInCallback; + if (o) return h ? i(ie.error, null) : i(null, ie.error), null; + if (this.url !== t.channelUrl) { + var p = new P( + "The message does not belong to this channel", + P.INVALID_PARAMETER + ); + return h ? i(p, null) : i(null, p), null; + } + var f = {}, + y = Object.keys(t.translations); + y.forEach(function (e) { + return (f[e] = ""); + }); + var g = s.PushNotificationDeliveryOption.DEFAULT; + return n._sendUserMessage( + l( + l({}, t), + {}, + { + reqId: null, + pushNotificationDeliveryOption: g, + translationTargetLanguages: y, + rootMessageId: null, + parentMessageId: null, + parentMessageText: null, + callback: i, + } + ) + ); + }, + }, + { + key: "copyFileMessage", + value: function (n, t, i) { + var r = D.get(this._iid), + a = r.Command; + r.GroupChannel; + var s = r.FileMessage, + o = r.BaseMessageParams; + r.FileMessageParams; + var l = r.User, + u = null, + c = ie.parse(arguments, [ + new ie({ type: e }), + new ie({ type: s }), + new ie({ type: "callback" }), + ]), + d = A(c, 4); + (u = d[0]), (n = d[1]), (t = d[2]), (i = d[3]); + var h = M.get(this._iid), + p = h.container.isErrorFirstInCallback; + if (u) return p ? i(ie.error, null) : i(null, ie.error), null; + if (this.url !== t.channelUrl) { + var f = new P("The message does not belong to this channel"); + return p ? i(f, null) : i(null, f), null; + } + var y = ft.getInstance(this._iid), + g = t, + _ = g.url, + m = g.name, + v = g.type, + E = g.size, + C = g.data, + b = g.customType, + U = g.mentionType, + I = g.mentionedUserIds, + S = g.mentionedUsers, + k = g.metaArrays, + O = g.thumbnails, + N = g.requireAuth, + R = g.messageSurvivalSeconds, + T = g.silent, + L = g.appleCriticalAlertOptions, + w = a.generateRequestId(), + H = y.currentUser || {}, + F = n.url, + G = n.isOpenChannel(), + j = S.filter(function (e) { + return new l(l.objectify(e)); + }), + B = o.PushNotificationDeliveryOption.DEFAULT, + x = s.objectify({ + messageId: 0, + reqId: w, + user: H, + channel: n, + plainUrl: _, + name: m, + type: v, + size: E, + data: C, + customType: b, + mentionType: U, + mentionedUserIds: I, + mentionedUsers: j, + requestedMentionUserIds: I, + metaArrays: k, + thumbnails: O, + requireAuth: N, + messageSurvivalSeconds: R, + silent: T, + createdAt: new Date().getTime(), + appleCriticalAlertOptions: L, + }), + q = new s(x); + if ( + ((q.requestState = y.MessageRequestState.PENDING), + (q.sendingStatus = y.MessageSendingStatus.PENDING), + !y.currentUser) + ) { + var z = new P( + "Connection should be made first.", + P.CONNECTION_REQUIRED + ), + Q = new s(x); + return ( + (Q.requestState = y.MessageRequestState.FAILED), + (Q.sendingStatus = y.MessageSendingStatus.FAILED), + (Q.errorCode = z.code), + p ? i(z, Q) : i(Q, z), + q + ); + } + var V = a.bFile({ + requestId: w, + channelUrl: F, + url: _, + name: m, + type: v, + size: E, + data: C, + customType: b, + metaArrays: k, + mentionType: U, + mentionedUserIds: I, + thumbnailSizes: O, + requireAuth: N, + pushNotificationDeliveryOption: B, + silent: T, + appleCriticalAlertOptions: L, + }); + return ( + y.getConnectionState() === y.ConnectionState.OPEN || + y.connecting || + y.reconnecting + ? y.sendCommand(V, function (e, t) { + if (y.getErrorFirstCallback()) { + var r = [e, t]; + (t = r[0]), (e = r[1]); + } + if (t) + if (t.code !== P.INVALID_PARAMETER) { + var a = new s(x); + (a.requestState = y.MessageRequestState.FAILED), + (a.sendingStatus = y.MessageSendingStatus.FAILED), + (t.code !== P.FILE_UPLOAD_CANCEL_FAILED && + t.code !== P.REQUEST_CANCELED) || + (a.sendingStatus = + y.MessageSendingStatus.CANCELED), + (a.errorCode = t.code), + p ? i(t, a) : i(a, t); + } else p ? i(t, null) : i(null, t); + else { + var o = new s(e.getJsonElement()), + l = o._sender; + H && + l && + H.userId === l.userId && + (H.nickname !== l.nickname && + (H.nickname = l.nickname), + H.plainProfileUrl !== l.plainProfileUrl && + (H.plainProfileUrl = l.plainProfileUrl)), + n.isGroupChannel() && + ((n.lastMessage = o), + Object.keys(y.channelHandlers).forEach(function ( + e + ) { + y.channelHandlers[e].onChannelChanged(n); + })), + p ? i(null, o) : i(o, null); + } + }) + : h.container.apiClient.sendFileMessage( + { + channelUrl: F, + isOpenChannel: G, + fileUrl: _, + fileName: m, + fileType: v, + fileSize: E, + data: C, + customType: b, + metaArrays: k, + mentionType: U, + mentionedUserIds: I, + thumbnailSizes: O, + requireAuth: N, + pushNotificationDeliveryOption: B, + appleCriticalAlertOptions: L, + }, + function (e, t) { + if (e) + if (e.code !== P.INVALID_PARAMETER) { + var r = new s(commnad.getJsonElement()); + (r.requestState = y.MessageRequestState.FAILED), + (r.sendingStatus = + y.MessageSendingStatus.FAILED), + (e.code !== P.FILE_UPLOAD_CANCEL_FAILED && + e.code !== P.REQUEST_CANCELED) || + (r.sendingStatus = + y.MessageSendingStatus.CANCELED), + (r.errorCode = e.code), + p ? i(e, r) : i(r, e); + } else p ? i(e, null) : i(null, e); + else { + var a = new s(t), + o = a._sender; + H && + o && + H.userId === o.userId && + (H.nickname !== o.nickname && + (H.nickname = o.nickname), + H.plainProfileUrl !== o.plainProfileUrl && + (H.plainProfileUrl = o.plainProfileUrl)), + n.isGroupChannel() && + ((n.lastMessage = a), + Object.keys(y.channelHandlers).forEach( + function (e) { + y.channelHandlers[e].onChannelChanged(n); + } + )), + p ? i(null, a) : i(a, null); + } + } + ), + q + ); + }, + }, + { + key: "addOperators", + value: function (e, n) { + var t = this, + i = null, + r = ie.parse(arguments, [ + new ie({ + type: "array", + constraint: function (e) { + return Object.keys(e) + .map(function (n) { + return e[n]; + }) + .every(function (e) { + return "string" == typeof e; + }); + }, + }), + new ie({ type: "callback" }), + ]), + a = A(r, 3); + return ( + (i = a[0]), + (e = a[1]), + (n = a[2]), + ge( + this._iid, + function (n) { + i + ? n(i, null) + : M.get(t._iid).container.apiClient.addOperators( + { + channelUrl: t.url, + isOpenChannel: t.isOpenChannel(), + operatorUserIds: e, + }, + function (e, t) { + return n(e, t); + } + ); + }, + n + ) + ); + }, + }, + { + key: "removeOperators", + value: function (e, n) { + var t = this, + i = null, + r = ie.parse(arguments, [ + new ie({ + type: "array", + constraint: function (e) { + return Object.keys(e) + .map(function (n) { + return e[n]; + }) + .every(function (e) { + return "string" == typeof e; + }); + }, + }), + new ie({ type: "callback" }), + ]), + a = A(r, 3); + return ( + (i = a[0]), + (e = a[1]), + (n = a[2]), + ge( + this._iid, + function (n) { + i + ? n(i, null) + : M.get(t._iid).container.apiClient.removeOperators( + { + channelUrl: t.url, + isOpenChannel: t.isOpenChannel(), + operatorUserIds: e, + }, + function (e, t) { + return n(e, t); + } + ); + }, + n + ) + ); + }, + }, + { + key: "getMetaCounters", + value: function (e, n) { + var t = this, + i = null, + r = ie.parse(arguments, [ + new ie({ + type: "array", + constraint: function (e) { + return Object.keys(e) + .map(function (n) { + return e[n]; + }) + .every(function (e) { + return "string" == typeof e; + }); + }, + }), + new ie({ type: "callback" }), + ]), + a = A(r, 3); + return ( + (i = a[0]), + (e = a[1]), + (n = a[2]), + ge( + this._iid, + function (n) { + i + ? n(i, null) + : M.get(t._iid).container.apiClient.getMetaCounters( + { + channelUrl: t.url, + isOpenChannel: t.isOpenChannel(), + keys: e, + }, + function (e, t) { + return n(e, t); + } + ); + }, + n + ) + ); + }, + }, + { + key: "getAllMetaCounters", + value: function (e) { + var n = this; + return ge( + this._iid, + function (e) { + M.get(n._iid).container.apiClient.getMetaCounters( + { + channelUrl: n.url, + isOpenChannel: n.isOpenChannel(), + keys: [], + }, + function (n, t) { + return e(n, t); + } + ); + }, + e + ); + }, + }, + { + key: "createMetaCounters", + value: function (e, n) { + var t = this, + i = null, + r = ie.parse(arguments, [ + new ie({ + type: "object", + constraint: function (e) { + return ( + e && + !Array.isArray(e) && + Object.keys(e).length > 0 && + Object.keys(e) + .map(function (n) { + return e[n]; + }) + .every(function (e) { + return "number" == typeof e; + }) + ); + }, + }), + new ie({ type: "callback" }), + ]), + a = A(r, 3); + return ( + (i = a[0]), + (e = a[1]), + (n = a[2]), + ge( + this._iid, + function (n) { + i + ? n(i, null) + : M.get(t._iid).container.apiClient.createMetaCounters( + { + channelUrl: t.url, + isOpenChannel: t.isOpenChannel(), + metaCounter: e, + }, + function (e, t) { + return n(e, t); + } + ); + }, + n + ) + ); + }, + }, + { + key: "updateMetaCounters", + value: function (e, n, t) { + var i = this, + r = null, + a = ie.parse(arguments, [ + new ie({ + type: "object", + constraint: function (e) { + return ( + e && + !Array.isArray(e) && + Object.keys(e).length > 0 && + Object.keys(e) + .map(function (n) { + return e[n]; + }) + .every(function (e) { + return "number" == typeof e; + }) + ); + }, + }), + new ie({ type: "boolean", optional: !0, defaultValue: !1 }), + new ie({ type: "callback" }), + ]), + s = A(a, 4); + return ( + (r = s[0]), + (e = s[1]), + (n = s[2]), + (t = s[3]), + ge( + this._iid, + function (t) { + r + ? t(r, null) + : M.get(i._iid).container.apiClient.updateMetaCounters( + { + channelUrl: i.url, + isOpenChannel: i.isOpenChannel(), + metaCounter: e, + upsert: n, + mode: "set", + }, + function (e, n) { + return t(e, n); + } + ); + }, + t + ) + ); + }, + }, + { + key: "increaseMetaCounters", + value: function (e, n) { + var t = this, + i = null, + r = ie.parse(arguments, [ + new ie({ + type: "object", + constraint: function (e) { + return ( + e && + !Array.isArray(e) && + Object.keys(e).length > 0 && + Object.keys(e) + .map(function (n) { + return e[n]; + }) + .every(function (e) { + return "number" == typeof e; + }) + ); + }, + }), + new ie({ type: "callback" }), + ]), + a = A(r, 3); + return ( + (i = a[0]), + (e = a[1]), + (n = a[2]), + ge( + this._iid, + function (n) { + i + ? n(i, null) + : M.get(t._iid).container.apiClient.updateMetaCounters( + { + channelUrl: t.url, + isOpenChannel: t.isOpenChannel(), + metaCounter: e, + upsert: !1, + mode: "increase", + }, + function (e, t) { + return n(e, t); + } + ); + }, + n + ) + ); + }, + }, + { + key: "decreaseMetaCounters", + value: function (e, n) { + var t = this, + i = null, + r = ie.parse(arguments, [ + new ie({ + type: "object", + constraint: function (e) { + return ( + e && + !Array.isArray(e) && + Object.keys(e).length > 0 && + Object.keys(e) + .map(function (n) { + return e[n]; + }) + .every(function (e) { + return "number" == typeof e; + }) + ); + }, + }), + new ie({ type: "callback" }), + ]), + a = A(r, 3); + return ( + (i = a[0]), + (e = a[1]), + (n = a[2]), + ge( + this._iid, + function (n) { + i + ? n(i, null) + : M.get(t._iid).container.apiClient.updateMetaCounters( + { + channelUrl: t.url, + isOpenChannel: t.isOpenChannel(), + metaCounter: e, + upsert: !1, + mode: "decrease", + }, + function (e, t) { + var i = null; + e || + ((i = {}), + Object.keys(t).forEach(function (e) { + i[e] = t[e]; + })), + n(e, i); + } + ); + }, + n + ) + ); + }, + }, + { + key: "deleteMetaCounter", + value: function (e, n) { + var t = this, + i = null, + r = ie.parse(arguments, [ + new ie({ type: "string" }), + new ie({ type: "callback" }), + ]), + a = A(r, 3); + return ( + (i = a[0]), + (e = a[1]), + (n = a[2]), + ge( + this._iid, + function (n) { + i + ? n(i, null) + : M.get(t._iid).container.apiClient.deleteMetaCounter( + { + channelUrl: t.url, + isOpenChannel: t.isOpenChannel(), + key: e, + }, + function (e, t) { + return n(e, t); + } + ); + }, + n + ) + ); + }, + }, + { + key: "deleteAllMetaCounters", + value: function (e) { + var n = this; + return ge( + this._iid, + function (e) { + M.get(n._iid).container.apiClient.deleteAllMetaCounters( + { channelUrl: n.url, isOpenChannel: n.isOpenChannel() }, + function (n, t) { + return e(n, t); + } + ); + }, + e + ); + }, + }, + { + key: "getCachedMetaData", + value: function () { + var e = be.get(this), + n = {}; + return ( + Object.keys(e).forEach(function (t) { + var i = e[t]; + i.isRemoved || (n[t] = i.value); + }), + n + ); + }, + }, + { + key: "getMetaData", + value: function (e, n) { + var t = this, + i = null, + r = ie.parse(arguments, [ + new ie({ + type: "array", + constraint: function (e) { + return Object.keys(e) + .map(function (n) { + return e[n]; + }) + .every(function (e) { + return "string" == typeof e; + }); + }, + }), + new ie({ type: "callback" }), + ]), + a = A(r, 3); + return ( + (i = a[0]), + (e = a[1]), + (n = a[2]), + ge( + this._iid, + function (n) { + i + ? n(i, null) + : M.get(t._iid).container.apiClient.getMetaData( + { + channelUrl: t.url, + isOpenChannel: t.isOpenChannel(), + keys: e, + }, + function (e, t) { + n(e, t && t.ts ? t.metadata : t); + } + ); + }, + n + ) + ); + }, + }, + { + key: "getAllMetaData", + value: function (e) { + var n = this; + return ge( + this._iid, + function (e) { + M.get(n._iid).container.apiClient.getMetaData( + { + channelUrl: n.url, + isOpenChannel: n.isOpenChannel(), + keys: [], + }, + function (n, t) { + e(n, t && t.ts ? t.metadata : t); + } + ); + }, + e + ); + }, + }, + { + key: "createMetaData", + value: function (e, n) { + var t = this, + i = null, + r = ie.parse(arguments, [ + new ie({ + type: "object", + constraint: function (e) { + return ( + e && !Array.isArray(e) && Object.keys(e).length > 0 + ); + }, + }), + new ie({ type: "callback" }), + ]), + a = A(r, 3); + return ( + (i = a[0]), + (e = a[1]), + (n = a[2]), + ge( + this._iid, + function (n) { + i + ? n(i, null) + : M.get(t._iid).container.apiClient.createMetaData( + { + channelUrl: t.url, + isOpenChannel: t.isOpenChannel(), + metaData: e, + }, + function (e, t) { + n(e, t && t.ts ? t.metadata : t); + } + ); + }, + n + ) + ); + }, + }, + { + key: "updateMetaData", + value: function (e, n, t) { + var i = this, + r = null, + a = ie.parse(arguments, [ + new ie({ + type: "object", + constraint: function (e) { + return ( + e && !Array.isArray(e) && Object.keys(e).length > 0 + ); + }, + }), + new ie({ type: "boolean", optional: !0, defaultValue: !1 }), + new ie({ type: "callback" }), + ]), + s = A(a, 4); + return ( + (r = s[0]), + (e = s[1]), + (n = s[2]), + (t = s[3]), + ge( + this._iid, + function (t) { + r + ? t(r, null) + : M.get(i._iid).container.apiClient.updateMetaData( + { + channelUrl: i.url, + isOpenChannel: i.isOpenChannel(), + metaData: e, + upsert: n, + }, + function (e, n) { + t(e, n && n.ts ? n.metadata : n); + } + ); + }, + t + ) + ); + }, + }, + { + key: "deleteMetaData", + value: function (e, n) { + var t = this, + i = null, + r = ie.parse(arguments, [ + new ie({ type: "string" }), + new ie({ type: "callback" }), + ]), + a = A(r, 3); + return ( + (i = a[0]), + (e = a[1]), + (n = a[2]), + ge( + this._iid, + function (n) { + i + ? n(i, null) + : M.get(t._iid).container.apiClient.deleteMetaData( + { + channelUrl: t.url, + isOpenChannel: t.isOpenChannel(), + key: e, + }, + function (e, t) { + n(e, t && t.ts ? {} : t); + } + ); + }, + n + ) + ); + }, + }, + { + key: "deleteAllMetaData", + value: function (e) { + var n = this; + return ge( + this._iid, + function (e) { + M.get(n._iid).container.apiClient.deleteAllMetaData( + { channelUrl: n.url, isOpenChannel: n.isOpenChannel() }, + function (n, t) { + return e(n, t && t.ts ? {} : t); + } + ); + }, + e + ); + }, + }, + { + key: "_updateMessageMetaArray", + value: function (e, n, t, i) { + var r = this; + return ge( + this._iid, + function (i) { + var a = D.get(r._iid), + s = a.Command, + o = a.UserMessage, + l = a.FileMessage, + u = a.AdminMessage, + c = null; + if ( + (n.isUserMessage() + ? (c = s.bUpdateUserMessage({ + channelUrl: e, + messageId: n.messageId, + metaArrayParams: t, + })) + : n.isFileMessage() && + (c = s.bUpdateFileMessage({ + channelUrl: e, + messageId: n.messageId, + metaArrayParams: t, + })), + c) + ) { + var d = ft.getInstance(r._iid); + d.sendCommand(c, function (e, t) { + if (d.getErrorFirstCallback()) { + var r = [e, t]; + (t = r[0]), (e = r[1]); + } + var a = null; + t || + (n.isUserMessage() + ? (a = new o(e.getJsonElement())) + : n.isFileMessage() + ? (a = new l(e.getJsonElement())) + : n.isAdminMessage() && + (a = new u(e.getJsonElement()))), + i(t, a); + }); + } else i(ie.error, null); + }, + i + ); + }, + }, + { + key: "createMessageMetaArrayKeys", + value: function (e, n, t) { + var i = D.get(this._iid), + r = i.MessageMetaArray, + a = null, + s = ie.parse(arguments, [ + new ie({ type: ve }), + new ie({ + type: "array", + constraint: function (e) { + return e.every(function (e) { + return "string" == typeof e && "" !== e; + }); + }, + }), + new ie({ type: "callback" }), + ]), + o = A(s, 4); + if (((a = o[0]), (e = o[1]), (n = o[2]), (t = o[3]), a)) + return ge( + this._iid, + function (e) { + e(a, null); + }, + t + ); + var l = []; + if (Array.isArray(n)) + for (var u = 0; u < n.length; u++) { + var c = n[u]; + l.push(new r(c, [])); + } + return this._updateMessageMetaArray( + this.url, + e, + { + array: l.map(function (e) { + return e.encode(); + }), + mode: "add", + upsert: !0, + }, + t + ); + }, + }, + { + key: "deleteMessageMetaArrayKeys", + value: function (e, n, t) { + var i = D.get(this._iid), + r = i.MessageMetaArray, + a = null, + s = ie.parse(arguments, [ + new ie({ type: ve }), + new ie({ + type: "array", + constraint: function (e) { + return e.every(function (e) { + return "string" == typeof e && "" !== e; + }); + }, + }), + new ie({ type: "callback" }), + ]), + o = A(s, 4); + if (((a = o[0]), (e = o[1]), (n = o[2]), (t = o[3]), a)) + return ge( + this._iid, + function (e) { + e(a, null); + }, + t + ); + var l = []; + if (Array.isArray(n)) + for (var u = 0; u < n.length; u++) { + var c = n[u]; + l.push(new r(c, [])); + } + return this._updateMessageMetaArray( + this.url, + e, + { + array: l.map(function (e) { + return e.encode(); + }), + mode: "remove", + upsert: !0, + }, + t + ); + }, + }, + { + key: "addMessageMetaArrayValues", + value: function (e, n, t) { + var i = D.get(this._iid), + r = i.MessageMetaArray, + a = null, + s = ie.parse(arguments, [ + new ie({ type: ve }), + new ie({ + type: "object", + constraint: function (e) { + return ( + e && + ((Array.isArray(e) && + e.length > 0 && + e.every(function (e) { + return e instanceof r; + })) || + (Object.keys(e).length > 0 && + Object.keys(e).every(function (n) { + return ( + Array.isArray(e[n]) && + e[n].length > 0 && + e[n].every(function (e) { + return "string" == typeof e && e.length > 0; + }) + ); + }))) + ); + }, + }), + new ie({ type: "callback" }), + ]), + o = A(s, 4); + if (((a = o[0]), (e = o[1]), (n = o[2]), (t = o[3]), a)) + return ge( + this._iid, + function (e) { + e(a, null); + }, + t + ); + var l = Array.isArray(n) + ? n.map(function (e) { + return e.encode(); + }) + : Object.keys(n).map(function (e) { + return { key: e, value: n[e] }; + }); + return this._updateMessageMetaArray( + this.url, + e, + { array: l, mode: "add", upsert: !0 }, + t + ); + }, + }, + { + key: "removeMessageMetaArrayValues", + value: function (e, n, t) { + var i = D.get(this._iid), + r = i.MessageMetaArray, + a = null, + s = ie.parse(arguments, [ + new ie({ type: ve }), + new ie({ + type: "object", + constraint: function (e) { + return ( + e && + ((Array.isArray(e) && + e.length > 0 && + e.every(function (e) { + return e instanceof r; + })) || + (Object.keys(e).length > 0 && + Object.keys(e).every(function (n) { + return ( + Array.isArray(e[n]) && + e[n].length > 0 && + e[n].every(function (e) { + return "string" == typeof e && e.length > 0; + }) + ); + }))) + ); + }, + }), + new ie({ type: "callback" }), + ]), + o = A(s, 4); + if (((a = o[0]), (e = o[1]), (n = o[2]), (t = o[3]), a)) + return ge( + this._iid, + function (e) { + e(a, null); + }, + t + ); + var l = Array.isArray(n) + ? n.map(function (e) { + return e.encode(); + }) + : Object.keys(n).map(function (e) { + return { key: e, value: n[e] }; + }); + return this._updateMessageMetaArray( + this.url, + e, + { array: l, mode: "remove", upsert: !0 }, + t + ); + }, + }, + { + key: "report", + value: function (e, n, t) { + var i = this, + r = D.get(this._iid), + a = r.BaseChannel, + s = null, + o = ie.parse(arguments, [ + new ie({ type: a.ReportCategory }), + new ie({ type: "string" }), + new ie({ type: "callback" }), + ]), + l = A(o, 4); + return ( + (s = l[0]), + (e = l[1]), + (n = l[2]), + (t = l[3]), + ge( + this._iid, + function (t) { + if (s) t(s, null); + else { + var r = ft.getInstance(i._iid); + M.get(i._iid).container.apiClient.report( + { + channelUrl: i.url, + isOpenChannel: i.isOpenChannel(), + reportCategory: e, + reportingUserId: r.currentUser + ? r.currentUser.userId + : null, + reportDescription: n, + }, + function (e, n) { + t(e, null); + } + ); + } + }, + t + ) + ); + }, + }, + { + key: "reportUser", + value: function (e, n, t, i) { + var r = this, + a = D.get(this._iid), + s = a.BaseChannel, + o = null, + l = ie.parse(arguments, [ + new ie({ type: Ee }), + new ie({ type: s.ReportCategory }), + new ie({ type: "string" }), + new ie({ type: "callback" }), + ]), + u = A(l, 5); + return ( + (o = u[0]), + (e = u[1]), + (n = u[2]), + (t = u[3]), + (i = u[4]), + ge( + this._iid, + function (i) { + if (o) i(o, null); + else { + var a = ft.getInstance(r._iid); + M.get(r._iid).container.apiClient.reportUser( + { + channelUrl: r.url, + isOpenChannel: r.isOpenChannel(), + reportCategory: n, + offendingUserId: e.userId, + reportingUserId: a.currentUser + ? a.currentUser.userId + : null, + reportDescription: t, + }, + function (e, n) { + i(e, null); + } + ); + } + }, + i + ) + ); + }, + }, + { + key: "reportMessage", + value: function (e, n, t, i) { + var r = this, + a = D.get(this._iid), + s = a.BaseChannel, + o = null, + l = ie.parse(arguments, [ + new ie({ type: ve }), + new ie({ type: s.ReportCategory }), + new ie({ type: "string" }), + new ie({ type: "callback" }), + ]), + u = A(l, 5); + return ( + (o = u[0]), + (e = u[1]), + (n = u[2]), + (t = u[3]), + (i = u[4]), + ge( + this._iid, + function (i) { + if (o) i(o, null); + else { + var a = ft.getInstance(r._iid); + M.get(r._iid).container.apiClient.reportMessage( + { + messageId: e.messageId, + channelUrl: r.url, + isOpenChannel: r.isOpenChannel(), + reportCategory: n, + offendingUserId: e.sender.userId, + reportingUserId: a.currentUser + ? a.currentUser.userId + : null, + reportDescription: t, + }, + function (e, n) { + i(e, null); + } + ); + } + }, + i + ) + ); + }, + }, + ], + [ + { + key: "CHANNEL_TYPE_OPEN", + get: function () { + return "open"; + }, + }, + { + key: "CHANNEL_TYPE_GROUP", + get: function () { + return "group"; + }, + }, + { + key: "CHANNEL_TYPE_BASE", + get: function () { + return "base"; + }, + }, + { + key: "MessageTypeFilter", + get: function () { + return { ALL: "", USER: "MESG", FILE: "FILE", ADMIN: "ADMM" }; + }, + }, + { + key: "ReportCategory", + get: function () { + return { + SPAM: "spam", + HARASSING: "harassing", + SUSPICIOUS: "suspicious", + INAPPROPRIATE: "inappropriate", + }; + }, + }, + { + key: "buildMessage", + value: function (e, n) { + var t = D.get(this._iid), + i = t.UserMessage, + r = t.FileMessage, + a = t.AdminMessage; + if (e) + switch ( + (e.hasOwnProperty("channel_type") || + (e.channel_type = n.channelType), + e.type) + ) { + case "MESG": + return new i(e); + case "FILE": + var s = e.file; + return new r( + l( + l({}, e), + {}, + { + url: String(s.url), + name: String(s.name), + type: String(s.type), + size: parseInt(s.size), + data: String(s.data), + } + ) + ); + case "BRDM": + case "ADMM": + return new a(e); + } + return null; + }, + }, + ] + ), + e + ); + })(), + Ae = (function () { + function e(n) { + c(this, e), + n && + ((this.category = n.hasOwnProperty("cat") ? parseInt(n.cat) : 0), + (this.data = n.hasOwnProperty("data") ? n.data : null), + (this.channelUrl = n.hasOwnProperty("channel_url") + ? String(n.channel_url) + : ""), + (this.channelType = n.hasOwnProperty("channel_type") + ? String(n.channel_type) + : Ue.CHANNEL_TYPE_GROUP)); + } + return ( + h(e, [ + { + key: "isGroupChannel", + value: function () { + return this.channelType === Ue.CHANNEL_TYPE_GROUP; + }, + }, + { + key: "isOpenChannel", + value: function () { + return this.channelType === Ue.CHANNEL_TYPE_OPEN; + }, + }, + ]), + e + ); + })(); + (Ae.CATEGORY_NONE = 0), + (Ae.CATEGORY_CHANNEL_ENTER = 10102), + (Ae.CATEGORY_CHANNEL_EXIT = 10103), + (Ae.CATEGORY_USER_CHANNEL_MUTE = 10201), + (Ae.CATEGORY_USER_CHANNEL_UNMUTE = 10200), + (Ae.CATEGORY_USER_CHANNEL_BAN = 10601), + (Ae.CATEGORY_USER_CHANNEL_UNBAN = 10600), + (Ae.CATEGORY_CHANNEL_FREEZE = 10701), + (Ae.CATEGORY_CHANNEL_UNFREEZE = 10700), + (Ae.CATEGORY_TYPING_START = 10900), + (Ae.CATEGORY_TYPING_END = 10901), + (Ae.CATEGORY_CHANNEL_JOIN = 1e4), + (Ae.CATEGORY_CHANNEL_LEAVE = 10001), + (Ae.CATEGORY_CHANNEL_OPERATOR_UPDATE = 10002), + (Ae.CATEGORY_CHANNEL_INVITE = 10020), + (Ae.CATEGORY_CHANNEL_DECLINE_INVITE = 10022), + (Ae.CATEGORY_CHANNEL_PROP_CHANGED = 11e3), + (Ae.CATEGORY_CHANNEL_DELETED = 12e3), + (Ae.CATEGORY_CHANNEL_META_DATA_CHANGED = 11100), + (Ae.CATEGORY_CHANNEL_META_COUNTERS_CHANGED = 11200), + (Ae.CATEGORY_CHANNEL_HIDE = 13e3), + (Ae.CATEGORY_CHANNEL_UNHIDE = 13001); + var Ie = function e(n) { + c(this, e), + n && (this.category = n.hasOwnProperty("cat") ? parseInt(n.cat) : 0); + }; + (Ie.CATEGORY_USER_BLOCK = 20001), + (Ie.CATEGORY_USER_UNBLOCK = 2e4), + (Ie.CATEGORY_FRIEND_DISCOVERED = 20900); + var Se = (function () { + function e(n) { + c(this, e), (this.sb = n), (this.cls = D.get(this.sb._iid)); + } + return ( + h(e, [ + { + key: "onRawCommandReceived", + value: function (e) { + var n = this, + t = this.cls, + i = t.Command, + r = t.User, + a = t.Member, + s = t.BaseChannel, + o = t.GroupChannel, + l = t.OpenChannel, + c = t.UserMessage, + d = t.FileMessage, + h = t.AdminMessage, + p = t.BaseMessageParams, + f = t.ReactionEvent, + y = t.ReadStatus, + g = t.ThreadInfoUpdateEvent, + _ = t.PollUpdateEvent, + m = t.PollVoteEvent, + v = M.get(this.sb._iid), + E = v.container, + C = E.pinger, + b = E.auth, + U = E.subscribedUnreadMessageCount, + A = E.sessionManager, + I = E.ackStateMap, + S = new i(e), + k = S.getJsonElement(); + if ( + k.hasOwnProperty("unread_cnt") && + "object" === u(k.unread_cnt) + ) { + var R = !1, + T = k.unread_cnt.ts; + "number" == typeof T && + T > U.ts && + (U.all !== k.unread_cnt.all && (R = !0), + (U.all = k.unread_cnt.all >= 0 ? k.unread_cnt.all : 0), + k.unread_cnt.custom_types && + Object.keys(k.unread_cnt.custom_types).forEach(function ( + e + ) { + U.custom_types[e] !== k.unread_cnt.custom_types[e] && + (R = !0), + (U.custom_types[e] = k.unread_cnt.custom_types[e]); + }), + (R = R && U.ts > 0), + (U.ts = T)), + R && + Object.keys(this.sb.userEventHandlers).forEach(function ( + e + ) { + n.sb.userEventHandlers[ + e + ].onTotalUnreadMessageCountUpdated(U.all, U.custom_types); + }); + } + var L = S.requestId; + if (L) { + var w = I[L]; + if (w) { + clearTimeout(w.timer); + var D = w.handler; + D && + ("EROR" === S.command + ? D(new P(k.message, k.code), null) + : D(null, S)), + I.hasOwnProperty(L) && delete I[L]; + } + } else + switch ( + (C && "LOGI" !== S.command && C.refreshTimer(), S.command) + ) { + case "LOGI": + this.sb.loginTimer && + (clearTimeout(this.sb.loginTimer), + (this.sb.loginTimer = null), + (this.sb.onLoginTimerCancel = null), + k.hasOwnProperty("error") + ? ((this.sb.isSessionOpened = !1), + this.sb.loginHandler(new P(k.message, k.code), null)) + : ((this.sb.isSessionOpened = !0), + k.hasOwnProperty("key") && (b.sessionKey = k.key), + k.hasOwnProperty("ekey") && (b.eKey = k.ekey), + k.hasOwnProperty("user_id") && + (this.sb.currentUser = new r(k)), + "number" == typeof k.ping_interval && + k.ping_interval > 0 && + v.set("pingInterval", 1e3 * k.ping_interval), + "number" == typeof k.pong_timeout && + k.pong_timeout > 0 && + v.set("pongTimeout", 1e3 * k.pong_timeout), + "number" == typeof k.login_ts && + v.set("connectedAt", 1e3 * k.login_ts), + "number" == typeof k.max_unread_cnt_on_super_group + ? v.set( + "maxUnreadCountOfSuperGroupChannel", + k.max_unread_cnt_on_super_group + ) + : v.set( + "maxUnreadCountOfSuperGroupChannel", + N.DEFAULT_MAX_UNREAD_COUNT_OF_SUPER_GROUP_CHANNEL + ), + k.profile_image_encryption && + v.set("profileImageEncryption", !0), + C && C.start(), + k.hasOwnProperty("file_upload_size_limit") && + k.hasOwnProperty("premium_feature_list") && + k.hasOwnProperty("emoji_hash") && + v.set("appInfo", new he(k)), + this.sb.loginHandler(null, this.sb.currentUser)), + (this.sb.connecting = !1), + (this.sb.reconnecting = !1)); + break; + case "EXPR": + k.hasOwnProperty("expires_in") && + "number" == typeof k.expires_in && + k.expires_in > 0 && + A.refresh(function () {}); + break; + case "MESG": + case "FILE": + case "BRDM": + case "ADMM": + var H = null; + if ( + ("MESG" === S.command + ? (H = new c(k)) + : "FILE" === S.command + ? (H = new d(k)) + : ("BRDM" !== S.command && "ADMM" !== S.command) || + (H = new h(k)), + H) + ) { + var F = this.sb.currentUser + ? this.sb.currentUser.userId + : null, + G = H.silent, + j = !!k.force_update_last_message, + B = H._sender && H._sender.userId === F; + if (H.isGroupChannel()) { + var x = o.cachedChannels.hasOwnProperty(H.channelUrl); + o.getChannel( + H.channelUrl, + N.INTERNAL_CALL, + function (e, t) { + if (n.sb.getErrorFirstCallback()) { + var r = [e, t]; + (t = r[0]), (e = r[1]); + } + if (!t) { + if ( + !v.container.appInfo.isSupergroupMackDisabled || + !e.isSuper || + e.isBroadcast + ) { + var a = i.bMessageAck({ + channelUrl: H.channelUrl, + messageId: H.messageId, + }); + n.sb.sendCommand(a); + } + if ( + ((e.isHidden = !1), + (e.hiddenState = o.HiddenState.UNHIDDEN), + (o.cachedChannels[e.url] = e), + H._sender && + e.memberMap.hasOwnProperty(H._sender.userId)) + ) { + var s = e.memberMap[H._sender.userId]; + s.nickname !== H._sender.nickname && + (s.nickname = H._sender.nickname), + s.plainProfileUrl !== + H._sender.plainProfileUrl && + (s.plainProfileUrl = + H._sender.plainProfileUrl), + X.deepEqual(s.metaData, H._sender.metaData) || + (s.metaData = H._sender.metaData), + s.isBlockedByMe !== H._sender.isBlockedByMe && + (s.isBlockedByMe = H._sender.isBlockedByMe); + } + var l = n.sb.currentUser; + l && + B && + (l.nickname !== H._sender.nickname && + (l.nickname = H._sender.nickname), + l.plainProfileUrl !== + H._sender.plainProfileUrl && + (l.plainProfileUrl = + H._sender.plainProfileUrl), + X.deepEqual(l.metaData, H._sender.metaData) || + (l.metaData = H._sender.metaData)); + var u = !1; + if (H.mentionType === p.MentionType.CHANNEL) + B || (u = !0); + else if (H.mentionType === p.MentionType.USERS) + for ( + var c = 0; + c < H.mentionedUsers.length; + c++ + ) + if (!B && H.mentionedUsers[c].userId === F) { + u = !0; + break; + } + (G && !B) || + ((e.isEphemeral || x) && + ((!e.lastMessage || + e.lastMessage.createdAt < H.createdAt) && + (e.lastMessage = H), + B || + e._setGroupChannelUnreadCount( + e.unreadMessageCount + 1, + e.unreadMentionCount + (u ? 1 : 0) + ))), + j && + (!e.lastMessage || + e.lastMessage.createdAt < H.createdAt) && + (e.lastMessage = H), + (G && !B) || + Object.keys(n.sb.channelHandlers).forEach( + function (t) { + n.sb.channelHandlers[t].onChannelChanged( + e + ); + } + ), + Object.keys(n.sb.channelHandlers).forEach( + function (t) { + var i = n.sb.channelHandlers[t]; + i.onMessageReceived(e, H), + u && i.onMentionReceived(e, H); + } + ); + } + } + ); + } else + H.isOpenChannel() && + l.getChannel( + H.channelUrl, + N.INTERNAL_CALL, + function (e, t) { + if (n.sb.getErrorFirstCallback()) { + var i = [e, t]; + (t = i[0]), (e = i[1]); + } + if (!t) { + var r = !1; + if (H.mentionType === p.MentionType.CHANNEL) + r = !0; + else if (H.mentionType === p.MentionType.USERS) + for ( + var a = 0; + a < H.mentionedUsers.length; + a++ + ) + if (H.mentionedUsers[a].userId === F) { + r = !0; + break; + } + Object.keys(n.sb.channelHandlers).forEach( + function (t) { + var i = n.sb.channelHandlers[t]; + l.enteredChannels[e.url] && + i.onMessageReceived(e, H), + r && i.onMentionReceived(e, H); + } + ); + } + } + ); + } + break; + case "MEDI": + case "FEDI": + case "AEDI": + var q = null; + if ( + ("MEDI" === S.command + ? (q = new c(k)) + : "FEDI" === S.command + ? (q = new d(k)) + : "AEDI" === S.command && (q = new h(k)), + q) + ) { + var z = this.sb.currentUser + ? this.sb.currentUser.userId + : null, + Q = q.silent, + Y = q.sender && q.sender.userId === z; + if (q.isGroupChannel()) { + var K = o.cachedChannels.hasOwnProperty(q.channelUrl); + o.getChannel( + q.channelUrl, + N.INTERNAL_CALL, + function (e, t) { + if (n.sb.getErrorFirstCallback()) { + var i = [e, t]; + (t = i[0]), (e = i[1]); + } + if (!t) { + var r = e.cachedReadReceiptStatus[z], + a = r && r >= q.createAt, + s = n.sb.currentUser; + s && + Y && + (s.nickname !== q._sender.nickname && + (s.nickname = q._sender.nickname), + s.plainProfileUrl !== + q._sender.plainProfileUrl && + (s.plainProfileUrl = + q._sender.plainProfileUrl), + X.deepEqual(s.metaData, q._sender.metaData) || + (s.metaData = q._sender.metaData)); + var o = !1, + l = !1; + if ( + !Y && + !a && + k && + k.hasOwnProperty("old_values") + ) { + var u = + k.old_values.mention_type || q.mentionType, + c = + k.old_values.mentioned_user_ids || + q.mentionedUsers.map(function (e) { + return e.userId; + }); + if ( + u === p.MentionType.USERS && + q.mentionType === p.MentionType.USERS + ) { + for ( + var d = !1, h = !1, f = 0; + f < c.length; + f++ + ) + if (c[f] === z) { + d = !0; + break; + } + for ( + var y = 0; + y < q.mentionedUsers.length; + y++ + ) + if (q.mentionedUsers[y].userId === z) { + h = !0; + break; + } + !d && + h && + ((l = !0), + !Q && + K && + (e._setGroupChannelUnreadCount( + e.unreadMessageCount, + e.unreadMentionCount + 1 + ), + (o = !0))); + } else if ( + u === p.MentionType.USERS && + q.mentionType === p.MentionType.CHANNEL + ) { + for (var g = !1, _ = 0; _ < c.length; _++) + if (c[_] === z) { + g = !0; + break; + } + g || + ((l = !0), + !Q && + K && + (e._setGroupChannelUnreadCount( + e.unreadMessageCount, + e.unreadMentionCount + 1 + ), + (o = !0))); + } + } + e.lastMessage + ? e.lastMessage.createdAt < q.createdAt + ? ((e.lastMessage = q), (o = !0)) + : e.lastMessage.createdAt === q.createdAt && + e.lastMessage.messageId === q.messageId && + (K + ? e.lastMessage.updatedAt < q.updatedAt && + ((e.lastMessage = q), (o = !0)) + : (o = !0)) + : ((e.lastMessage = q), (o = !0)), + (Q && !Y) || + !o || + Object.keys(n.sb.channelHandlers).forEach( + function (t) { + n.sb.channelHandlers[t].onChannelChanged( + e + ); + } + ), + Object.keys(n.sb.channelHandlers).forEach( + function (t) { + var i = n.sb.channelHandlers[t]; + i.onMessageUpdated(e, q), + l && i.onMentionReceived(e, q); + } + ); + } + } + ); + } else + q.isOpenChannel() && + l.getChannel( + q.channelUrl, + N.INTERNAL_CALL, + function (e, t) { + if (n.sb.getErrorFirstCallback()) { + var i = [e, t]; + (t = i[0]), (e = i[1]); + } + t || + Object.keys(n.sb.channelHandlers).forEach( + function (t) { + n.sb.channelHandlers[t].onMessageUpdated( + e, + q + ); + } + ); + } + ); + } + break; + case "DELM": + var W = String(k.channel_type), + J = String(k.channel_url), + Z = parseInt(k.msg_id); + switch (W) { + case s.CHANNEL_TYPE_GROUP: + o.getChannel(J, N.INTERNAL_CALL, function (e, t) { + if (n.sb.getErrorFirstCallback()) { + var i = [e, t]; + (t = i[0]), (e = i[1]); + } + t + ? V.debug( + "Discard command:", + "`".concat(S.command, "`") + ) + : Object.keys(n.sb.channelHandlers).forEach( + function (t) { + n.sb.channelHandlers[t].onMessageDeleted( + e, + Z + ); + } + ); + }); + break; + case s.CHANNEL_TYPE_OPEN: + l.getChannel(J, N.INTERNAL_CALL, function (e, t) { + if (n.sb.getErrorFirstCallback()) { + var i = [e, t]; + (t = i[0]), (e = i[1]); + } + t + ? V.debug( + "Discard command:", + "`".concat(S.command, "`") + ) + : Object.keys(n.sb.channelHandlers).forEach( + function (t) { + n.sb.channelHandlers[t].onMessageDeleted( + e, + Z + ); + } + ); + }); + } + break; + case "READ": + var $ = new y(k), + ee = o.cachedChannels.hasOwnProperty($.channelUrl); + o.getChannel( + $.channelUrl, + N.INTERNAL_CALL, + function (e, t) { + if (n.sb.getErrorFirstCallback()) { + var i = [e, t]; + (t = i[0]), (e = i[1]); + } + t || + (ee && + e.updateReadReceipt($.reader.userId, $.timestamp), + n.sb.currentUser && + ($.reader.userId === n.sb.currentUser.userId + ? ee + ? (e.unreadMessageCount > 0 || + e.unreadMentionCount > 0) && + (e._setGroupChannelUnreadCount(0, 0), + Object.keys(n.sb.channelHandlers).forEach( + function (t) { + n.sb.channelHandlers[t].onChannelChanged( + e + ); + } + )) + : (0 !== e.unreadMessageCount && + 0 !== e.unreadMentionCount) || + Object.keys(n.sb.channelHandlers).forEach( + function (t) { + n.sb.channelHandlers[t].onChannelChanged( + e + ); + } + ) + : Object.keys(n.sb.channelHandlers).forEach( + function (t) { + n.sb.channelHandlers[ + t + ].onReadReceiptUpdated(e); + } + ))); + } + ); + break; + case "MRCT": + var ne = String(k.channel_type), + te = String(k.channel_url), + ie = f.createFromJson(k); + switch (ne) { + case s.CHANNEL_TYPE_GROUP: + o.getChannel(te, N.INTERNAL_CALL, function (e, t) { + if (n.sb.getErrorFirstCallback()) { + var i = [e, t]; + (t = i[0]), (e = i[1]); + } + t + ? V.debug( + "Discard command:", + "`".concat(S.command, "`") + ) + : Object.keys(n.sb.channelHandlers).forEach( + function (t) { + n.sb.channelHandlers[t].onReactionUpdated( + e, + ie + ); + } + ); + }); + break; + case s.CHANNEL_TYPE_OPEN: + l.getChannel(te, N.INTERNAL_CALL, function (e, t) { + if (n.sb.getErrorFirstCallback()) { + var i = [e, t]; + (t = i[0]), (e = i[1]); + } + t + ? V.debug( + "Discard command:", + "`".concat(S.command, "`") + ) + : Object.keys(n.sb.channelHandlers).forEach( + function (t) { + n.sb.channelHandlers[t].onReactionUpdated( + e, + ie + ); + } + ); + }); + } + break; + case "DLVR": + var re = String(k.channel_url), + ae = k.hasOwnProperty("updated") ? k.updated : null, + se = o.cachedChannels.hasOwnProperty(re); + o.getChannel(re, N.INTERNAL_CALL, function (e, t) { + if (n.sb.getErrorFirstCallback()) { + var i = [e, t]; + (t = i[0]), (e = i[1]); + } + if (!t) { + var r = !1; + Object.keys(ae).forEach(function (t) { + n.sb.currentUser && + t === n.sb.currentUser.userId && + (r = !0), + se && e.updateDeliveryReceipt(t, parseInt(ae[t])); + }), + (o.cachedChannels[e.url] = e), + (r && 1 === Object.keys(ae).length) || + Object.keys(n.sb.channelHandlers).forEach(function ( + t + ) { + n.sb.channelHandlers[t].onDeliveryReceiptUpdated( + e + ); + }); + } + }); + break; + case "MTHD": + var oe = String(k.channel_url), + le = String(k.channel_type), + ue = g.createFromJson(k); + switch (le) { + case s.CHANNEL_TYPE_GROUP: + o.getChannel(oe, N.INTERNAL_CALL, function (e, t) { + if (n.sb.getErrorFirstCallback()) { + var i = [e, t]; + (t = i[0]), (e = i[1]); + } + t || + Object.keys(n.sb.channelHandlers).forEach(function ( + t + ) { + n.sb.channelHandlers[t].onThreadInfoUpdated( + e, + ue + ); + }); + }); + break; + case s.CHANNEL_TYPE_OPEN: + l.getChannel(oe, N.INTERNAL_CALL, function (e, t) { + if (n.sb.getErrorFirstCallback()) { + var i = [e, t]; + (t = i[0]), (e = i[1]); + } + t || + Object.keys(n.sb.channelHandlers).forEach(function ( + t + ) { + n.sb.channelHandlers[t].onThreadInfoUpdated( + e, + ue + ); + }); + }); + } + break; + case "MCNT": + if ( + k.hasOwnProperty("group_channels") && + Array.isArray(k.group_channels) + ) { + var ce, + de = [], + pe = O(k.group_channels); + try { + for (pe.s(); !(ce = pe.n()).done; ) { + var fe = ce.value; + if (fe) { + fe.hasOwnProperty("joined_member_count") && + fe.joined_member_count, + fe.hasOwnProperty("member_count") && + fe.member_count; + var ye = o.cachedChannels[fe.channel_url]; + if (ye && ye.isBroadcast) + ye.setLatestMemberCount( + fe.member_count, + fe.joined_member_count, + fe.ts + ) && de.push(ye); + } + } + } catch (e) { + pe.e(e); + } finally { + pe.f(); + } + de.length > 0 && + Object.keys(this.sb.channelHandlers).forEach(function ( + e + ) { + n.sb.channelHandlers[e].onChannelMemberCountChanged( + de + ); + }); + } + if ( + k.hasOwnProperty("open_channels") && + Array.isArray(k.open_channels) + ) { + var ge, + _e = [], + me = O(k.open_channels); + try { + for (me.s(); !(ge = me.n()).done; ) { + var ve = ge.value; + if (ve) { + ve.hasOwnProperty("participant_count") && + ve.participant_count; + var Ee = l.cachedChannels[ve.channel_url]; + if (Ee) + Ee.setLatestParticipantCount( + ve.participant_count, + ve.ts + ) && _e.push(Ee); + } + } + } catch (e) { + me.e(e); + } finally { + me.f(); + } + _e.length > 0 && + Object.keys(this.sb.channelHandlers).forEach(function ( + e + ) { + n.sb.channelHandlers[ + e + ].onChannelParticipantCountChanged(_e); + }); + } + break; + case "PEDI": + var Ce = _.createFromJson(k); + Object.keys(this.sb.channelHandlers).forEach(function (e) { + n.sb.channelHandlers[e].onPollUpdated(Ce); + }); + break; + case "VOTE": + var be = m.createFromJson(k); + Object.keys(this.sb.channelHandlers).forEach(function (e) { + n.sb.channelHandlers[e].onPollVoted(be); + }); + break; + case "SYEV": + var Ue = new Ae(k), + Se = k.ts; + switch (Ue.category) { + case Ae.CATEGORY_CHANNEL_JOIN: + case Ae.CATEGORY_CHANNEL_LEAVE: + o.getChannel( + Ue.channelUrl, + N.INTERNAL_CALL, + function (e, t) { + if (n.sb.getErrorFirstCallback()) { + var i = [e, t]; + (t = i[0]), (e = i[1]); + } + if (t) + V.debug( + "Discard command:", + "`".concat(S.command, "`"), + Ue.category + ); + else { + var s = Ue.data.hasOwnProperty("member_count") + ? Ue.data.member_count + : null, + l = Ue.data.hasOwnProperty( + "joined_member_count" + ) + ? Ue.data.joined_member_count + : null, + u = !1; + if (Ue.category === Ae.CATEGORY_CHANNEL_JOIN) { + (Ue.data.hasOwnProperty("users") + ? Ue.data.users + : [Ue.data] + ).forEach(function (t) { + e.isSuper || e.isBroadcast + ? (u = e.setLatestMemberCount(s, l, k.ts)) + : ((t.state = a.JOINED), + e.addMember(new a(t), Se), + e.updateJoinedMemberCount()); + var i = new r(t); + n.sb.currentUser && + i.userId === n.sb.currentUser.userId && + ((e.myMemberState = "joined"), + (o.cachedChannels[e.url] = e)), + Object.keys(n.sb.channelHandlers).forEach( + function (t) { + var r = n.sb.channelHandlers[t]; + r.onUserJoined(e, i), + e.isBroadcast && + u && + r.onChannelMemberCountChanged([e]); + } + ); + }); + } else { + var c = new r(Ue.data); + n.sb.currentUser && + c.userId === n.sb.currentUser.userId + ? (e.isPublic || + o.removeCachedChannel(Ue.channelUrl), + (e.myMemberState = "none"), + (e.invitedAt = 0), + (e.joinedAt = 0), + e._setGroupChannelUnreadCount(0, 0)) + : (o.cachedChannels[e.url] = e), + e.isSuper || e.isBroadcast + ? (u = e.setLatestMemberCount(s, l, k.ts)) + : (e.removeMember(c), + e.updateJoinedMemberCount()), + Object.keys(n.sb.channelHandlers).forEach( + function (t) { + var i = n.sb.channelHandlers[t]; + i.onUserLeft(e, c), + e.isBroadcast && + u && + i.onChannelMemberCountChanged([e]); + } + ); + } + } + } + ); + break; + case Ae.CATEGORY_CHANNEL_OPERATOR_UPDATE: + Ue.isGroupChannel() + ? o.getChannel( + Ue.channelUrl, + N.INTERNAL_CALL, + function (e, t) { + if (n.sb.getErrorFirstCallback()) { + var i = [e, t]; + (t = i[0]), (e = i[1]); + } + if (t) + V.debug( + "Discard command:", + "`".concat(S.command, "`"), + Ue.category + ); + else { + for ( + var a = Ue.data.operators.map(function (e) { + return new r(e); + }), + s = a.map(function (e) { + return e.userId; + }), + l = 0; + l < e.members.length; + l++ + ) + e.members[l].role = + s.indexOf(e.members[l].userId) >= 0 + ? o.Role.OPERATOR + : o.Role.NONE; + (e.myRole = + n.sb.currentUser && + s.indexOf(n.sb.currentUser.userId) >= 0 + ? o.Role.OPERATOR + : o.Role.NONE), + Object.keys(n.sb.channelHandlers).forEach( + function (t) { + n.sb.channelHandlers[ + t + ].onOperatorUpdated(e, a); + } + ); + } + } + ) + : Ue.isOpenChannel() && + l.getChannel( + Ue.channelUrl, + N.INTERNAL_CALL, + function (e, t) { + if (n.sb.getErrorFirstCallback()) { + var i = [e, t]; + (t = i[0]), (e = i[1]); + } + t + ? V.debug( + "Discard command:", + "`".concat(S.command, "`"), + Ue.category + ) + : ((e.operators = Ue.data.operators.map( + function (e) { + return new r(e); + } + )), + Object.keys(n.sb.channelHandlers).forEach( + function (t) { + n.sb.channelHandlers[ + t + ].onOperatorUpdated(e, e.operators); + } + )); + } + ); + break; + case Ae.CATEGORY_CHANNEL_INVITE: + o.getChannel( + Ue.channelUrl, + N.INTERNAL_CALL, + function (e, t) { + if (n.sb.getErrorFirstCallback()) { + var i = [e, t]; + (t = i[0]), (e = i[1]); + } + if (t) + V.debug( + "Discard command:", + "`".concat(S.command, "`"), + Ue.category + ); + else { + var s = null; + Ue.data && + Ue.data.inviter && + Object.keys(Ue.data.inviter).length > 0 && + (s = new r(Ue.data.inviter)); + for ( + var l = [], u = 0; + u < Ue.data.invitees.length; + u++ + ) { + var c = new r(Ue.data.invitees[u]); + l.push(c), + (Ue.data.invitees[u].state = a.INVITED); + var d = new a(Ue.data.invitees[u]); + if (e.isSuper || e.isBroadcast) { + var h = Ue.data.hasOwnProperty("member_count") + ? Ue.data.member_count + : null, + p = Ue.data.hasOwnProperty( + "joined_member_count" + ) + ? Ue.data.joined_member_count + : null; + e.setLatestMemberCount(h, p, k.ts); + } else e.addMember(d, Se); + n.sb.currentUser && + d.userId === n.sb.currentUser.userId && + ((e.isHidden = !1), + "joined" !== e.myMemberState && + (e.myMemberState = "invited"), + (e.invitedAt = k.ts), + (o.cachedChannels[e.url] = e)); + } + Object.keys(n.sb.channelHandlers).forEach( + function (t) { + n.sb.channelHandlers[ + t + ].onUserReceivedInvitation(e, s, l); + } + ); + } + } + ); + break; + case Ae.CATEGORY_CHANNEL_DECLINE_INVITE: + o.getChannel( + Ue.channelUrl, + N.INTERNAL_CALL, + function (e, t) { + if (n.sb.getErrorFirstCallback()) { + var i = [e, t]; + (t = i[0]), (e = i[1]); + } + if (t) + V.debug( + "Discard command:", + "`".concat(S.command, "`"), + Ue.category + ); + else { + var a = null; + Ue.data && + Ue.data.inviter && + Object.keys(Ue.data.inviter).length > 0 && + (a = new r(Ue.data.inviter)); + var s = new r(Ue.data.invitee); + if ( + (n.sb.currentUser && + s.userId === n.sb.currentUser.userId && + ((e.invitedAt = 0), + (e.myMemberState = "none"), + e.isPublic || + o.removeCachedChannel(Ue.channelUrl)), + e.isSuper || e.isBroadcast) + ) { + var l = Ue.data.hasOwnProperty("member_count") + ? Ue.data.member_count + : null, + u = Ue.data.hasOwnProperty( + "joined_member_count" + ) + ? Ue.data.joined_member_count + : null; + e.setLatestMemberCount(l, u, k.ts); + } else e.removeMember(s); + n.sb.currentUser && + s.userId !== n.sb.currentUser.userId && + (o.cachedChannels[e.url] = e), + Object.keys(n.sb.channelHandlers).forEach( + function (t) { + n.sb.channelHandlers[ + t + ].onUserDeclinedInvitation(e, a, s); + } + ); + } + } + ); + break; + case Ae.CATEGORY_TYPING_START: + case Ae.CATEGORY_TYPING_END: + o.getChannel( + Ue.channelUrl, + N.INTERNAL_CALL, + function (e, t) { + if (n.sb.getErrorFirstCallback()) { + var i = [e, t]; + (t = i[0]), (e = i[1]); + } + if (t) + V.debug( + "Discard command:", + "`".concat(S.command, "`"), + Ue.category + ); + else { + var a = new r(Ue.data); + Ue.category === Ae.CATEGORY_TYPING_START + ? e.updateTypingStatus(a, !0) + : e.updateTypingStatus(a, !1), + Object.keys(n.sb.channelHandlers).forEach( + function (t) { + n.sb.channelHandlers[ + t + ].onTypingStatusUpdated(e); + } + ); + } + } + ); + break; + case Ae.CATEGORY_CHANNEL_ENTER: + case Ae.CATEGORY_CHANNEL_EXIT: + l.getChannel( + Ue.channelUrl, + N.INTERNAL_CALL, + function (e, t) { + if (n.sb.getErrorFirstCallback()) { + var i = [e, t]; + (t = i[0]), (e = i[1]); + } + if (t) + V.debug( + "Discard command:", + "`".concat(S.command, "`"), + Ue.category + ); + else { + var a = Ue.data.hasOwnProperty( + "participant_count" + ) + ? Ue.data.participant_count + : null, + s = e.setLatestParticipantCount(a, k.ts), + o = new r(Ue.data); + Ue.category === Ae.CATEGORY_CHANNEL_ENTER + ? Object.keys(n.sb.channelHandlers).forEach( + function (t) { + var i = n.sb.channelHandlers[t]; + i.onUserEntered(e, o), + s && + i.onChannelParticipantCountChanged([ + e, + ]); + } + ) + : Object.keys(n.sb.channelHandlers).forEach( + function (t) { + var i = n.sb.channelHandlers[t]; + i.onUserExited(e, o), + s && + i.onChannelParticipantCountChanged([ + e, + ]); + } + ); + } + } + ); + break; + case Ae.CATEGORY_USER_CHANNEL_MUTE: + case Ae.CATEGORY_USER_CHANNEL_UNMUTE: + Ue.isOpenChannel() + ? l.getChannel( + Ue.channelUrl, + N.INTERNAL_CALL, + function (e, t) { + if (n.sb.getErrorFirstCallback()) { + var i = [e, t]; + (t = i[0]), (e = i[1]); + } + if (t) + V.debug( + "Discard command:", + "`".concat(S.command, "`"), + Ue.category + ); + else { + var a = new r(Ue.data); + Ue.category === Ae.CATEGORY_USER_CHANNEL_MUTE + ? Object.keys(n.sb.channelHandlers).forEach( + function (t) { + n.sb.channelHandlers[t].onUserMuted( + e, + a + ); + } + ) + : Object.keys(n.sb.channelHandlers).forEach( + function (t) { + n.sb.channelHandlers[t].onUserUnmuted( + e, + a + ); + } + ); + } + } + ) + : o.getChannel( + Ue.channelUrl, + N.INTERNAL_CALL, + function (e, t) { + if (n.sb.getErrorFirstCallback()) { + var i = [e, t]; + (t = i[0]), (e = i[1]); + } + if (t) + V.debug( + "Discard command:", + "`".concat(S.command, "`"), + Ue.category + ); + else { + var a = new r(Ue.data); + n.sb.currentUser && + a.userId === n.sb.currentUser.userId && + (e.myMutedState = + Ue.category === + Ae.CATEGORY_USER_CHANNEL_MUTE + ? "muted" + : "unmuted"), + Array.isArray(e.members) && + e.members.forEach(function (e) { + e && + e.userId === a.userId && + (e.isMuted = + Ue.category === + Ae.CATEGORY_USER_CHANNEL_MUTE); + }), + Ue.category === + Ae.CATEGORY_USER_CHANNEL_MUTE + ? Object.keys( + n.sb.channelHandlers + ).forEach(function (t) { + n.sb.channelHandlers[t].onUserMuted( + e, + a + ); + }) + : Object.keys( + n.sb.channelHandlers + ).forEach(function (t) { + n.sb.channelHandlers[t].onUserUnmuted( + e, + a + ); + }); + } + } + ); + break; + case Ae.CATEGORY_USER_CHANNEL_BAN: + case Ae.CATEGORY_USER_CHANNEL_UNBAN: + Ue.isOpenChannel() + ? l.getChannel( + Ue.channelUrl, + N.INTERNAL_CALL, + function (e, t) { + if (n.sb.getErrorFirstCallback()) { + var i = [e, t]; + (t = i[0]), (e = i[1]); + } + if (t) + V.debug( + "Discard command:", + "`".concat(S.command, "`"), + Ue.category + ); + else { + var a = new r(Ue.data); + if ( + Ue.category === Ae.CATEGORY_USER_CHANNEL_BAN + ) { + if ( + n.sb.currentUser && + a.userId === n.sb.currentUser.userId + ) + delete l.enteredChannels[Ue.channelUrl], + n.cls.FileMessageQueue.delete( + Ue.channelUrl + ); + Object.keys(n.sb.channelHandlers).forEach( + function (t) { + n.sb.channelHandlers[t].onUserBanned( + e, + a + ); + } + ); + } else + Object.keys(n.sb.channelHandlers).forEach( + function (t) { + n.sb.channelHandlers[t].onUserUnbanned( + e, + a + ); + } + ); + } + } + ) + : o.getChannel( + Ue.channelUrl, + N.INTERNAL_CALL, + function (e, t) { + if (n.sb.getErrorFirstCallback()) { + var i = [e, t]; + (t = i[0]), (e = i[1]); + } + if (t) + V.debug( + "Discard command:", + "`".concat(S.command, "`"), + Ue.category + ); + else { + var a = new r(Ue.data); + if ( + Ue.category === Ae.CATEGORY_USER_CHANNEL_BAN + ) { + if ( + (n.sb.currentUser && + a.userId === n.sb.currentUser.userId && + (e.isPublic || + o.removeCachedChannel(Ue.channelUrl), + (e.myMemberState = "none"), + (e.invitedAt = 0), + (e.joinedAt = 0), + e._setGroupChannelUnreadCount(0, 0)), + e.isSuper || e.isBroadcast) + ) { + var s = Ue.data.hasOwnProperty( + "member_count" + ) + ? Ue.data.member_count + : null, + l = Ue.data.hasOwnProperty( + "joined_member_count" + ) + ? Ue.data.joined_member_count + : null; + e.setLatestMemberCount(s, l, k.ts); + } else + e.removeMember(a), + e.updateJoinedMemberCount(); + Object.keys(n.sb.channelHandlers).forEach( + function (t) { + n.sb.channelHandlers[t].onUserBanned( + e, + a + ); + } + ); + } else + Object.keys(n.sb.channelHandlers).forEach( + function (t) { + n.sb.channelHandlers[t].onUserUnbanned( + e, + a + ); + } + ); + } + } + ); + break; + case Ae.CATEGORY_CHANNEL_FREEZE: + case Ae.CATEGORY_CHANNEL_UNFREEZE: + Ue.isOpenChannel() + ? l.getChannel( + Ue.channelUrl, + N.INTERNAL_CALL, + function (e, t) { + if (n.sb.getErrorFirstCallback()) { + var i = [e, t]; + (t = i[0]), (e = i[1]); + } + t + ? V.debug( + "Discard command:", + "`".concat(S.command, "`"), + Ue.category + ) + : ((e.isFrozen = Ue.data.freeze), + (l.cachedChannels[e.url] = e), + Ue.category === Ae.CATEGORY_CHANNEL_FREEZE + ? Object.keys( + n.sb.channelHandlers + ).forEach(function (t) { + n.sb.channelHandlers[ + t + ].onChannelFrozen(e); + }) + : Object.keys( + n.sb.channelHandlers + ).forEach(function (t) { + n.sb.channelHandlers[ + t + ].onChannelUnfrozen(e); + })); + } + ) + : o.getChannel( + Ue.channelUrl, + N.INTERNAL_CALL, + function (e, t) { + if (n.sb.getErrorFirstCallback()) { + var i = [e, t]; + (t = i[0]), (e = i[1]); + } + t + ? V.debug( + "Discard command:", + "`".concat(S.command, "`"), + Ue.category + ) + : ((e.isFrozen = Ue.data.freeze), + (o.cachedChannels[e.url] = e), + Ue.category === Ae.CATEGORY_CHANNEL_FREEZE + ? Object.keys( + n.sb.channelHandlers + ).forEach(function (t) { + n.sb.channelHandlers[ + t + ].onChannelFrozen(e); + }) + : Object.keys( + n.sb.channelHandlers + ).forEach(function (t) { + n.sb.channelHandlers[ + t + ].onChannelUnfrozen(e); + })); + } + ); + break; + case Ae.CATEGORY_CHANNEL_DELETED: + Ue.isGroupChannel() + ? o.removeCachedChannel(Ue.channelUrl) + : l.removeCachedChannel(Ue.channelUrl), + Object.keys(this.sb.channelHandlers).forEach( + function (e) { + n.sb.channelHandlers[e].onChannelDeleted( + Ue.channelUrl, + Ue.isGroupChannel() ? "group" : "open" + ); + } + ); + break; + case Ae.CATEGORY_CHANNEL_PROP_CHANGED: + Ue.isOpenChannel() + ? l.getChannelWithoutCache( + Ue.channelUrl, + function (e, t) { + if (n.sb.getErrorFirstCallback()) { + var i = [e, t]; + (t = i[0]), (e = i[1]); + } + t + ? V.debug( + "Discard command:", + "`".concat(S.command, "`"), + Ue.category + ) + : Object.keys(n.sb.channelHandlers).forEach( + function (t) { + n.sb.channelHandlers[ + t + ].onChannelChanged(e); + } + ); + } + ) + : o.getChannelWithoutCache( + Ue.channelUrl, + function (e, t) { + if (n.sb.getErrorFirstCallback()) { + var i = [e, t]; + (t = i[0]), (e = i[1]); + } + if (t) + V.debug( + "Discard command:", + "`".concat(S.command, "`"), + Ue.category + ); + else { + var r = e.unreadMessageCount, + a = e.unreadMentionCount; + e.myCountPreference !== + o.CountPreference.ALL && + (e.myCountPreference === + o.CountPreference.UNREAD_MESSAGE_COUNT_ONLY + ? (a = 0) + : e.myCountPreference === + o.CountPreference + .UNREAD_MENTION_COUNT_ONLY + ? (r = 0) + : ((r = 0), (a = 0))), + e._setGroupChannelUnreadCount(r, a), + Object.keys(n.sb.channelHandlers).forEach( + function (t) { + n.sb.channelHandlers[ + t + ].onChannelChanged(e); + } + ); + } + } + ); + break; + case Ae.CATEGORY_CHANNEL_META_DATA_CHANGED: + case Ae.CATEGORY_CHANNEL_META_COUNTERS_CHANGED: + var ke = Ue.data.hasOwnProperty("created"), + Oe = Ue.data.hasOwnProperty("updated"), + Ne = Ue.data.hasOwnProperty("deleted"); + (Ue.isOpenChannel() + ? l.getChannel(Ue.channelUrl, N.INTERNAL_CALL) + : o.getChannel(Ue.channelUrl, N.INTERNAL_CALL) + ) + .then(function (e) { + var t = Ue.data.created, + i = Ue.data.updated, + r = Ue.data.deleted, + a = k.ts; + ke && e._addOrUpdateCachedMetaData(t, a), + Oe && e._addOrUpdateCachedMetaData(i, a), + Ne && e._markAsDeletedCachedMetaData(r, a), + Object.keys(n.sb.channelHandlers).forEach( + function (a) { + var s = n.sb.channelHandlers[a]; + Ue.category === + Ae.CATEGORY_CHANNEL_META_DATA_CHANGED + ? (ke && s.onMetaDataCreated(e, t), + Oe && s.onMetaDataUpdated(e, i), + Ne && s.onMetaDataDeleted(e, r)) + : (ke && s.onMetaCountersCreated(e, t), + Oe && s.onMetaCountersUpdated(e, i), + Ne && s.onMetaCountersDeleted(e, r)); + } + ); + }) + .catch(function (e) { + return V.debug( + "Discard command:", + "`".concat(S.command, "`"), + Ue.category + ); + }); + break; + case Ae.CATEGORY_CHANNEL_HIDE: + case Ae.CATEGORY_CHANNEL_UNHIDE: + o.getChannel( + Ue.channelUrl, + N.INTERNAL_CALL, + function (e, t) { + if (n.sb.getErrorFirstCallback()) { + var i = [e, t]; + (t = i[0]), (e = i[1]); + } + t + ? V.debug( + "Discard command:", + "`".concat(S.command, "`"), + Ue.category + ) + : Ue.category === Ae.CATEGORY_CHANNEL_HIDE + ? ((e.isHidden = !0), + Ue.data && + (Ue.data.hasOwnProperty( + "allow_auto_unhide" + ) && + (e.hiddenState = Ue.data.allow_auto_unhide + ? o.HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE + : o.HiddenState + .HIDDEN_PREVENT_AUTO_UNHIDE), + Ue.data.hasOwnProperty( + "hide_previous_messages" + ) && + Ue.data.hide_previous_messages && + e._setGroupChannelUnreadCount(0, 0)), + k.hasOwnProperty("ts_message_offset") && + (e._messageOffsetTimestamp = + k.ts_message_offset), + (o.cachedChannels[e.url] = e), + Object.keys(n.sb.channelHandlers).forEach( + function (t) { + n.sb.channelHandlers[t].onChannelHidden(e); + } + )) + : ((e.isHidden = !1), + (e.hiddenState = o.HiddenState.UNHIDDEN), + (o.cachedChannels[e.url] = e), + Object.keys(n.sb.channelHandlers).forEach( + function (t) { + n.sb.channelHandlers[t].onChannelChanged(e); + } + )); + } + ); + } + break; + case "USEV": + var Re = new Ae(k); + switch (Re.category) { + case Ie.CATEGORY_USER_BLOCK: + case Ie.CATEGORY_USER_UNBLOCK: + var Te = Re.data.blocker.user_id, + Me = Re.data.blockee.user_id; + Object.keys(o.cachedChannels).forEach(function (e) { + var t = o.cachedChannels[e]; + try { + n.sb.currentUser && + (n.sb.currentUser.userId === Te + ? (t.memberMap[Me].isBlockedByMe = + Re.category === Ie.CATEGORY_USER_BLOCK) + : n.sb.currentUser.userId === Me && + (t.memberMap[Te].isBlockingMe = + Re.category === Ie.CATEGORY_USER_BLOCK)); + } catch (e) {} + }); + break; + case Ie.CATEGORY_FRIEND_DISCOVERED: + var Pe = Re.data.friend_discoveries.map(function (e) { + return new r(e); + }); + Object.keys(this.sb.userEventHandlers).forEach( + function (e) { + n.sb.userEventHandlers[e].onFriendsDiscovered(Pe); + } + ); + } + break; + case "LEAV": + case "JOIN": + case "PONG": + case "MTIO": + case "TPST": + case "TPEN": + break; + default: + V.debug("Discard command:", "`".concat(S.command, "`")); + } + }, + }, + ]), + e + ); + })(), + ke = {}, + Oe = {}, + Ne = (function () { + function e(n) { + c(this, e), + (this.channel = n), + (this.uploadQueue = []), + (this.messageQueue = []), + (this.latestTimestampToSendMessage = 0), + (D.get(this._iid).FileMessageQueue.queueMap[n.url] = this); + } + return ( + h( + e, + [ + { + key: "_handleMessageQueueUpdated", + value: function (e) { + var n = this; + switch ( + (V.debug( + "`fileMessageQueue` message queue updated:", + this.messageQueue + ), + e) + ) { + case "add": + this.uploadQueue.length < 6 && + this._moveFirstPendingMessageToUploadQueue(); + break; + case "update": + case "remove": + if (this.messageQueue.length > 0) { + var t = D.get(this._iid).FileMessageQueue, + i = this.messageQueue[0]; + if (i) + if (i.state === t.State.UPLOADED) { + if (i && i.state === t.State.UPLOADED) { + for ( + i.state = t.State.SENDING, + 0 === this.latestTimestampToSendMessage && + (this.latestTimestampToSendMessage = + new Date().getTime() - 200); + new Date().getTime() - + this.latestTimestampToSendMessage < + 200; + + ); + (this.latestTimestampToSendMessage = new Date().getTime()), + this._sendUploadedMessage(i, function (e, r) { + (i.state = t.State.SENT), + (i.error = e || null), + (i.response = r || null), + n._handleMessageQueueUpdated("update"); + }); + } + } else + i.state === t.State.SENT && this._finalizeMessage(); + } + } + }, + }, + { + key: "_handleUploadQueueUpdated", + value: function (e, n) { + var t = this; + switch ( + (V.debug( + "`fileMessageQueue` upload queue updated:", + this.uploadQueue + ), + e) + ) { + case "add": + var i = D.get(this._iid).FileMessageQueue; + if (((n.state = i.State.UPLOADING), n.error)) { + var r = this.messageQueue + .map(function (e) { + return e.requestId; + }) + .indexOf(n.requestId); + r > -1 && + ((n.state = i.State.SENT), + this._handleMessageQueueUpdated("update")), + this._finalizeUpload(n.requestId); + } else + this._uploadFile(n, function (e) { + (n.error && n.state === i.State.SENT) || + (n.state = i.State.UPLOADED), + (n.fileInfo = e), + t._handleMessageQueueUpdated("update"), + t._finalizeUpload(n.requestId); + }); + break; + case "update": + break; + case "remove": + this.uploadQueue.length < 6 && + this._moveFirstPendingMessageToUploadQueue(); + } + }, + }, + { + key: "_moveFirstPendingMessageToUploadQueue", + value: function () { + var e = D.get(this._iid).FileMessageQueue, + n = this.messageQueue.filter(function (n) { + return n.state === e.State.PENDING; + }); + if (n.length > 0) { + var t = n[0]; + this.uploadQueue.push(t), + this._handleUploadQueueUpdated("add", t); + } + }, + }, + { + key: "_sendUploadedMessage", + value: function (e, n) { + var t = D.get(this._iid), + i = t.Command, + r = t.FileMessage, + a = e.fileInfo, + s = i.bFile( + l( + l({}, a), + {}, + { + requestId: e.requestId, + channelUrl: this.channel.url, + url: a.file, + metaArrays: a.metaArrays, + } + ) + ), + o = ft.getInstance(this._iid), + u = M.get(this._iid); + o.getConnectionState() === o.ConnectionState.OPEN || + !o.currentUser || + o.connecting || + o.reconnecting + ? o.sendCommand(s, function (e, t) { + if (o.getErrorFirstCallback()) { + var i = [e, t]; + (t = i[0]), (e = i[1]); + } + if (t) { + var l = new r(s.getJsonElement()); + (l.requestedMentionUserIds = a.mentionedUserIds), + n(t, l); + } else { + var u = new r(e.getJsonElement()); + n(null, u); + } + }) + : u.container.apiClient.sendFileMessage( + l( + l( + { + channelUrl: this.channel.url, + isOpenChannel: this.channel.isOpenChannel(), + }, + a + ), + {}, + { + fileUrl: a.file, + fileName: a.name, + fileSize: a.size, + fileType: a.type, + metaArrays: a.metaArrays, + } + ), + function (e, t) { + var i = new r(e ? s.getJsonElement() : t); + e && (i.requestedMentionUserIds = a.mentionedUserIds), + n(e, i); + } + ); + }, + }, + { + key: "_uploadFile", + value: function (e, n) { + var t = e.fileInfo, + i = e.pendingMessage; + if ("string" != typeof t.file && t.file) { + var r = D.get(this._iid).FileMessageQueue; + M.get(this._iid).container.apiClient.uploadFile( + l( + l({}, t), + {}, + { + fileType: t.type, + channelUrl: this.channel.url, + reqId: i ? i.reqId : null, + } + ), + function (i, a) { + if (i) + (e.state = r.State.SENT), + (e.error = i), + (e.response = null), + n(t); + else { + var s = "object" === u(a) ? a : JSON.parse(a); + (t.file = s.url), + (t.thumbnailSizes = s.hasOwnProperty("thumbnails") + ? s.thumbnails + : []), + (t.requireAuth = + !!s.hasOwnProperty("require_auth") && + s.require_auth), + (t.size = s.hasOwnProperty("file_size") + ? s.file_size + : t.size), + n(t); + } + } + ); + } else (t.thumbnailSizes = []), (t.requireAuth = !1), n(t); + }, + }, + { + key: "_finalizeUpload", + value: function (e) { + var n = this.uploadQueue + .map(function (e) { + return e.requestId; + }) + .indexOf(e); + if (n > -1) { + var t = this.uploadQueue.splice(n, 1); + t.length > 0 && + this._handleUploadQueueUpdated("remove", t[0]); + } + }, + }, + { + key: "_finalizeMessage", + value: function () { + var e = this, + n = M.get(this._iid).container.isErrorFirstInCallback, + t = ft.getInstance(this._iid), + i = D.get(this._iid).FileMessageQueue, + r = this.messageQueue[0]; + if (r && r.state === i.State.SENT) { + r.state = i.State.DONE; + var a = r.response, + s = r.error, + o = r.fileInfo.callback; + if (a && !s) { + var l = t.currentUser; + return ( + l && + a._sender && + l.userId === a._sender.userId && + (l.nickname !== a._sender.nickname && + (l.nickname = a._sender.nickname), + l.plainProfileUrl !== a._sender.plainProfileUrl && + (l.plainProfileUrl = a._sender.plainProfileUrl)), + this.channel.isGroupChannel() && + ((this.channel.lastMessage = a), + Object.keys(t.channelHandlers).forEach(function (n) { + t.channelHandlers[n].onChannelChanged(e.channel); + })), + n ? o(null, a) : o(a, null), + this.messageQueue.shift(), + void this._handleMessageQueueUpdated("remove") + ); + } + s && + (a = r.pendingMessage) && + (s.code !== P.INVALID_PARAMETER + ? ((a.requestState = t.MessageRequestState.FAILED), + (a.sendingStatus = t.MessageSendingStatus.FAILED), + (s.code !== P.FILE_UPLOAD_CANCEL_FAILED && + s.code !== P.REQUEST_CANCELED) || + (a.sendingStatus = t.MessageSendingStatus.CANCELED), + (a.requestedMentionUserIds = + r.fileInfo.mentionedUserIds), + (a.errorCode = s.code)) + : (a = null)), + n ? o(s, a) : o(a, s), + this.messageQueue.shift(), + this._handleMessageQueueUpdated("remove"); + } + }, + }, + { + key: "addJob", + value: function (e) { + this.messageQueue.push(e), + this._handleMessageQueueUpdated("add"); + }, + }, + { + key: "cancelUploadItemByRequestId", + value: function (e, n) { + this._finalizeUpload(e); + var t = this.messageQueue + .map(function (e) { + return e.requestId; + }) + .indexOf(e); + if (t > -1) { + var i = D.get(this._iid).FileMessageQueue, + r = this.messageQueue[t]; + !r || + (r.state !== i.State.UPLOADING && + r.state !== i.State.PENDING) || + ((r.state = i.State.SENT), + (r.response = null), + (r.error = new P( + "Uploading has been completed or canceled.", + P.FILE_UPLOAD_CANCEL_FAILED + )), + this._handleMessageQueueUpdated("update")); + var a = i.uploadRequest[e]; + if (a) + return ( + "function" == typeof a.abort + ? a.abort() + : "function" == typeof a.cancel && + a.cancel("Upload has been canceled."), + n(null, !0), + !0 + ); + n( + new P( + "Uploading has been completed or canceled.", + P.FILE_UPLOAD_CANCEL_FAILED + ), + !1 + ); + } else + n( + new P( + "Uploading has been completed or canceled.", + P.FILE_UPLOAD_CANCEL_FAILED + ), + !1 + ); + return !1; + }, + }, + ], + [ + { + key: "State", + get: function () { + return { + PENDING: "pending", + UPLOADING: "uploading", + UPLOADED: "uploaded", + SENDING: "sending", + SENT: "sent", + DONE: "done", + }; + }, + }, + { + key: "getByChannelUrl", + value: function (e) { + return D.get(this._iid).FileMessageQueue.queueMap[e]; + }, + }, + { + key: "create", + value: function (e) { + var n = D.get(this._iid).FileMessageQueue; + return ( + n.queueMap.hasOwnProperty(e.url) || + (n.queueMap[e.url] = new n(e)), + n.queueMap[e.url] + ); + }, + }, + { + key: "delete", + value: function (e) { + var n = D.get(this._iid).FileMessageQueue; + n.queueMap.hasOwnProperty(e) && delete n.queueMap[e]; + }, + }, + { + key: "clear", + value: function () { + Oe[this._iid] = {}; + }, + }, + { + key: "queueMap", + get: function () { + return Oe[this._iid] || (Oe[this._iid] = {}), Oe[this._iid]; + }, + }, + { + key: "uploadRequest", + get: function () { + return ke[this._iid] || (ke[this._iid] = {}), ke[this._iid]; + }, + }, + ] + ), + e + ); + })(); + Ne.Job = (function () { + return function e(n) { + var t = n.fileInfo, + i = n.requestId, + r = n.pendingMessage, + a = n.state, + s = n.error, + o = void 0 === s ? null : s, + l = n.response, + u = void 0 === l ? null : l; + c(this, e), + (this.fileInfo = t), + (this.requestId = i), + (this.pendingMessage = r), + (this.state = a || Ne.State.PENDING), + (this.error = o), + (this.response = u); + }; + })(); + var Re = (function () { + function e() { + c(this, e); + } + return ( + h(e, null, [ + { + key: "create", + value: function () { + return "" + .concat(parseInt(1e5 * Math.random()), "-") + .concat(new Date().getTime()); + }, + }, + ]), + e + ); + })(), + Te = {}, + Me = {}, + Pe = new WeakMap(), + Le = new WeakMap(), + we = new WeakMap(), + De = (function (e) { + f(t, e); + var n = b(t); + function t(e) { + var i; + return ( + c(this, t), + ((i = n.call(this, e)).channelType = Ue.CHANNEL_TYPE_GROUP), + (i.isDistinct = !1), + (i.isSuper = !1), + (i.isBroadcast = !1), + (i.isPublic = !1), + (i.unreadMessageCount = 0), + (i.inviter = null), + (i.members = []), + (i.memberMap = {}), + (i.lastMessage = null), + (i.memberCount = 0), + (i.joinedMemberCount = 0), + (i.cachedReadReceiptStatus = {}), + (i.cachedDeliveryReceiptStatus = null), + (i.myPushTriggerOption = t.PushTriggerOption.DEFAULT), + i.isPushEnabled, + (i.isHidden = !1), + (i.hiddenState = t.HiddenState.UNHIDDEN), + (i.isDiscoverable = !0), + (i.myLastRead = 0), + (i.messageSurvivalSeconds = -1), + (i.invitedAt = 0), + (i.joinedAt = 0), + (i._messageOffsetTimestamp = 0), + (i._cachedLastDeliveredReceipt = { sentAt: 0, timeout: null }), + Pe.set(E(i), {}), + Le.set(E(i), { start: 0, end: 0 }), + we.set(E(i), 0), + e && i._update(e), + i + ); + } + return ( + h( + t, + [ + { + key: "messageOffsetTimestamp", + get: function () { + return this._messageOffsetTimestamp; + }, + }, + { + key: "_setGroupChannelUnreadCount", + value: function (e, n) { + try { + if ("number" == typeof e && e >= 0) + if ( + "all" === this.myCountPreference || + "unread_message_count_only" === this.myCountPreference + ) + if (this.isSuper || this.isBroadcast) { + var t = M.get(this._iid).container + .maxUnreadCountOfSuperGroupChannel; + this.unreadMessageCount = e >= t ? t : e; + } else this.unreadMessageCount = e; + else this.unreadMessageCount = 0; + "number" == typeof n && + n >= 0 && + ("all" === this.myCountPreference || + "unread_mention_count_only" === this.myCountPreference + ? (this.unreadMentionCount = n) + : (this.unreadMentionCount = 0)); + } catch (e) {} + }, + }, + { + key: "_update", + value: function (e) { + var n = this, + t = D.get(this._iid), + i = t.BaseChannel, + r = t.GroupChannel, + a = t.User, + s = t.Member; + if ( + ((this.isAccessCodeRequired = + !!e.is_access_code_required && e.is_access_code_required), + (this.isDistinct = !!e.is_distinct && e.is_distinct), + (this.isPushEnabled = + !!e.is_push_enabled && e.is_push_enabled), + (this.isHidden = + !!e.hasOwnProperty("is_hidden") && e.is_hidden), + (this.myPushTriggerOption = e.push_trigger_option + ? e.push_trigger_option + : r.PushTriggerOption.DEFAULT), + (this.myCountPreference = e.hasOwnProperty("count_preference") + ? e.count_preference + : r.CountPreference.ALL), + (this.unreadMessageCount = 0), + (this.unreadMentionCount = 0), + this._setGroupChannelUnreadCount( + parseInt(e.unread_message_count), + parseInt(e.unread_mention_count) + ), + e.hasOwnProperty("read_receipt") && + ((this.cachedReadReceiptStatus = {}), + Object.keys(e.read_receipt).forEach(function (t) { + var i = e.read_receipt[t]; + n.updateReadReceipt(t, parseInt(i)); + })), + e.hasOwnProperty("delivery_receipt") && + "object" === u(e.delivery_receipt) && + null !== e.delivery_receipt && + (this.cachedDeliveryReceiptStatus || + (this.cachedDeliveryReceiptStatus = {}), + Object.keys(e.delivery_receipt).forEach(function (t) { + var i = e.delivery_receipt[t]; + n.updateDeliveryReceipt(t, parseInt(i)); + })), + e.hasOwnProperty("user_last_read") && + "number" == typeof e.user_last_read + ? (this.myLastRead = e.user_last_read) + : (this.myLastRead = 0), + e.hasOwnProperty("members")) + ) { + (this.members = []), (this.memberMap = {}); + for (var o = 0; o < e.members.length; o++) { + var l = new s(e.members[o]); + this.members.push(l), (this.memberMap[l.userId] = l); + } + } + (this.myMemberState = e.member_state || "none"), + (this.myRole = e.my_role || r.Role.NONE), + e.hasOwnProperty("is_muted") + ? "string" == typeof e.is_muted + ? (this.myMutedState = e.is_muted) + : "boolean" == typeof e.is_muted + ? (this.myMutedState = e.is_muted ? "muted" : "unmuted") + : (this.myMutedState = "unmuted") + : (this.myMutedState = "unmuted"), + e.hasOwnProperty("member_count") && + (this.memberCount = parseInt(e.member_count)), + e.hasOwnProperty("joined_member_count") && + (this.joinedMemberCount = parseInt(e.joined_member_count)), + e.hasOwnProperty("last_message") && + "object" === u(e.last_message) && + e.last_message + ? e.last_message instanceof ve + ? (this.lastMessage = e.last_message) + : (this.lastMessage = i.buildMessage( + e.last_message, + this + )) + : (this.lastMessage = null), + e.hasOwnProperty("inviter") && + null !== e.inviter && + "object" === u(e.inviter) && + Object.keys(e.inviter).length > 0 + ? (this.inviter = new a(e.inviter)) + : (this.inviter = null), + (this.invitedAt = e.invited_at || 0), + (this.joinedAt = e.joined_ts || 0), + e.hasOwnProperty("is_super") && "boolean" == typeof e.is_super + ? (this.isSuper = e.is_super) + : (this.isSuper = !1), + e.hasOwnProperty("is_broadcast") && + "boolean" == typeof e.is_broadcast + ? (this.isBroadcast = e.is_broadcast) + : (this.isBroadcast = !1), + e.hasOwnProperty("is_public") && + "boolean" == typeof e.is_public + ? (this.isPublic = e.is_public) + : (this.isPublic = !1), + e.hasOwnProperty("hidden_state") + ? (this.hiddenState = e.hidden_state) + : (this.hiddenState = r.HiddenState.UNHIDDEN), + e.hasOwnProperty("is_discoverable") && + "boolean" == typeof e.is_discoverable + ? (this.isDiscoverable = e.is_discoverable) + : (this.isDiscoverable = this.isPublic), + e.hasOwnProperty("ts_message_offset") && + (this._messageOffsetTimestamp = e.ts_message_offset), + e.hasOwnProperty("message_survival_seconds") && + "number" == typeof e.message_survival_seconds && + (this.messageSurvivalSeconds = e.message_survival_seconds); + }, + }, + { + key: "addMember", + value: function (e) { + var n = + arguments.length > 1 && void 0 !== arguments[1] + ? arguments[1] + : 0; + if (!this.isSuper && !this.isBroadcast) { + var t = D.get(this._iid), + i = t.Member, + r = this.removeMember(e); + r && r.state === i.JOINED && (e.state = i.JOINED), + (this.memberMap[e.userId] = e), + this.members.push(e), + this.memberCount++, + this.updateReadReceipt(e.userId, n), + this.updateDeliveryReceipt(e.userId, n); + } + }, + }, + { + key: "removeMember", + value: function (e) { + var n = null; + if ( + !this.isSuper && + !this.isBroadcast && + this.memberMap.hasOwnProperty(e.userId) + ) { + delete this.memberMap[e.userId]; + for (var t = 0; t < this.members.length; t++) { + var i = this.members[t]; + if (i.userId === e.userId) { + (n = i), this.members.splice(t, 1); + break; + } + } + this.memberCount--; + } + return n; + }, + }, + { + key: "parse", + value: function (e) { + this._update(e); + }, + }, + { + key: "update", + value: function (e) { + this.__update(e), this._update(e); + }, + }, + { + key: "isIdentical", + value: function (e) { + return e && this.url === e.url; + }, + }, + { + key: "isEqual", + value: function (e) { + return X.deepEqual(this, e); + }, + }, + { + key: "createMemberListQuery", + value: function () { + return new (0, D.get(this._iid).MemberListQuery)(this.url); + }, + }, + { + key: "createBannedUserListQuery", + value: function () { + return new (0, D.get(this._iid).BannedUserListQuery)({ + channelUrl: this.url, + isOpenChannel: this.isOpenChannel(), + }); + }, + }, + { + key: "refresh", + value: function (e) { + return D.get(this._iid).GroupChannel.getChannelWithoutCache( + this.url, + e + ); + }, + }, + { + key: "updateChannel", + value: function () { + var e = this, + n = ie.toArray(arguments), + t = void 0; + "function" == typeof n[n.length - 1] && (t = n.pop()); + var i = D.get(this._iid), + r = i.GroupChannel, + a = i.GroupChannelParams; + if (n[0] instanceof a && 1 === n.length) + return ge( + this._iid, + function (t) { + var i = n[0]; + ((i.channelUrl = e.url), i._validate()) + ? M.get(e._iid).container.apiClient.updateGroupChannel( + l( + l({}, i), + {}, + { operatorUserIds: i.operatorUserIds } + ), + function (e, n) { + var i = null; + e || (i = r.upsert(n)), t(e, i); + } + ) + : t(ie.error, null); + }, + t + ); + if (3 === n.length) { + var s = new a(); + return ( + (s.channelUrl = this.url), + (s.name = n[0]), + "string" == typeof n[1] + ? (s.coverUrl = n[1]) + : (s.coverImage = n[1]), + (s.data = n[2]), + this.updateChannel(s, t) + ); + } + if (4 === n.length) { + var o = new a(); + return ( + (o.channelUrl = this.url), + (o.isDistinct = n[0]), + (o.name = n[1]), + "string" == typeof n[1] + ? (o.coverUrl = n[2]) + : (o.coverImage = n[2]), + (o.data = n[3]), + this.updateChannel(o, t) + ); + } + if (5 === n.length) { + var u = new a(); + return ( + (u.channelUrl = this.url), + (u.isDistinct = n[0]), + (u.name = n[1]), + "string" == typeof n[2] + ? (u.coverUrl = n[2]) + : (u.coverImage = n[2]), + (u.data = n[3]), + (u.customType = n[4]), + this.updateChannel(u, t) + ); + } + return ge( + this._iid, + function (e) { + return e(ie.error, null); + }, + t + ); + }, + }, + { + key: "invite", + value: function (e, n) { + var t = null, + i = ie.parse(arguments, [ + new ie({ + type: "array", + constraint: function (e) { + return ( + e.length > 0 && + e.every(function (e) { + return !!e.userId && "string" == typeof e.userId; + }) + ); + }, + }), + new ie({ type: "callback" }), + ]), + r = A(i, 3); + return ( + (t = r[0]), + (e = r[1]), + (n = r[2]), + t + ? ge( + this._iid, + function (e) { + return e(ie.error, null); + }, + n + ) + : this.inviteWithUserIds( + e.map(function (e) { + return e.userId; + }), + n + ) + ); + }, + }, + { + key: "inviteWithUserIds", + value: function (e, n) { + var t = this, + i = null, + r = ie.parse(arguments, [ + new ie({ + type: "array", + constraint: function (e) { + return e.every(function (e) { + return "string" == typeof e; + }); + }, + }), + new ie({ type: "callback" }), + ]), + a = A(r, 3); + return ( + (i = a[0]), + (e = a[1]), + (n = a[2]), + ge( + this._iid, + function (n) { + i + ? n(i, null) + : M.get( + t._iid + ).container.apiClient.inviteToGroupChannel( + { channelUrl: t.url, userIds: e }, + function (e, i) { + var r = null; + e || (r = D.get(t._iid).GroupChannel.upsert(i)); + n(e, r); + } + ); + }, + n + ) + ); + }, + }, + { + key: "acceptInvitation", + value: function (e, n) { + var t = this, + i = null, + r = ie.parse(arguments, [ + new ie({ + type: "string", + optional: !0, + defaultValue: null, + }), + new ie({ type: "callback" }), + ]), + a = A(r, 3); + return ( + (i = a[0]), + (e = a[1]), + (n = a[2]), + ge( + this._iid, + function (n) { + i + ? n(i, null) + : M.get(t._iid).container.apiClient.acceptInvitation( + { channelUrl: t.url, accessCode: e }, + function (e, i) { + var r = null; + e || + ((r = D.get(t._iid).GroupChannel.upsert( + i + )).myMemberState = "joined"); + n(e, r); + } + ); + }, + n + ) + ); + }, + }, + { + key: "declineInvitation", + value: function (e) { + var n = this; + return ge( + this._iid, + function (e) { + M.get(n._iid).container.apiClient.declineInvitation( + { channelUrl: n.url }, + function (t, i) { + var r = null; + if (!t) { + var a = D.get(n._iid).GroupChannel; + ((r = a.upsert(i)).myMemberState = "none"), + n.isPublic || a.removeCachedChannel(n.url); + } + e(t, r); + } + ); + }, + e + ); + }, + }, + { + key: "join", + value: function (e, n) { + var t = this, + i = null, + r = ie.parse(arguments, [ + new ie({ + type: "string", + optional: !0, + defaultValue: null, + }), + new ie({ type: "callback" }), + ]), + a = A(r, 3); + return ( + (i = a[0]), + (e = a[1]), + (n = a[2]), + ge( + this._iid, + function (n) { + i + ? n(i, null) + : M.get(t._iid).container.apiClient.joinGroupChannel( + { channelUrl: t.url, accessCode: e }, + function (e, i) { + var r = null; + e || + ((r = D.get(t._iid).GroupChannel.upsert( + i + )).myMemberState = "joined"); + n(e, r); + } + ); + }, + n + ) + ); + }, + }, + { + key: "leave", + value: function (e) { + var n = this; + return ge( + this._iid, + function (e) { + M.get(n._iid).container.apiClient.leaveGroupChannel( + { channelUrl: n.url }, + function (n, t) { + return e(n, null); + } + ); + }, + e + ); + }, + }, + { + key: "muteUser", + value: function (e, n, t, i) { + return this.muteUserWithUserId(e ? e.userId : null, n, t, i); + }, + }, + { + key: "muteUserWithUserId", + value: function (e, n, t, i) { + var r = this, + a = null, + s = ie.parse(arguments, [ + new ie({ type: "string" }), + new ie({ + type: "number", + optional: !0, + defaultValue: -1, + constraint: function (e) { + return e >= -1; + }, + }), + new ie({ type: "string", optional: !0, defaultValue: "" }), + new ie({ type: "callback" }), + ]), + o = A(s, 5); + return ( + (a = o[0]), + (e = o[1]), + (n = o[2]), + (t = o[3]), + (i = o[4]), + ge( + this._iid, + function (i) { + a + ? i(a, null) + : M.get(r._iid).container.apiClient.muteUser( + { + channelUrl: r.url, + userId: e, + description: t, + seconds: n, + isGroupChannel: !0, + }, + function (e, n) { + i(e, null); + } + ); + }, + i + ) + ); + }, + }, + { + key: "unmuteUser", + value: function (e, n) { + return this.unmuteUserWithUserId(e ? e.userId : null, n); + }, + }, + { + key: "unmuteUserWithUserId", + value: function (e, n) { + var t = this, + i = null, + r = ie.parse(arguments, [ + new ie({ type: "string" }), + new ie({ type: "callback" }), + ]), + a = A(r, 3); + return ( + (i = a[0]), + (e = a[1]), + (n = a[2]), + ge( + this._iid, + function (n) { + i + ? n(i, null) + : M.get(t._iid).container.apiClient.unmuteUser( + { + channelUrl: t.url, + userId: e, + isGroupChannel: !0, + }, + function (e, t) { + n(e, null); + } + ); + }, + n + ) + ); + }, + }, + { + key: "banUser", + value: function (e, n, t, i) { + return this.banUserWithUserId(e ? e.userId : null, n, t, i); + }, + }, + { + key: "banUserWithUserId", + value: function (e, n, t, i) { + var r = this, + a = null, + s = ie.parse(arguments, [ + new ie({ type: "string" }), + new ie({ + type: "number", + optional: !0, + defaultValue: -1, + constraint: function (e) { + return e >= -1; + }, + }), + new ie({ type: "string" }), + new ie({ type: "callback" }), + ]), + o = A(s, 5); + return ( + (a = o[0]), + (e = o[1]), + (n = o[2]), + (t = o[3]), + (i = o[4]), + ge( + this._iid, + function (i) { + a + ? i(a, null) + : M.get(r._iid).container.apiClient.banUser( + { + channelUrl: r.url, + userId: e, + description: t, + seconds: n, + isGroupChannel: !0, + }, + function (e, n) { + i(e, null); + } + ); + }, + i + ) + ); + }, + }, + { + key: "unbanUser", + value: function (e, n) { + return this.unbanUserWithUserId(e ? e.userId : null, n); + }, + }, + { + key: "unbanUserWithUserId", + value: function (e, n) { + var t = this, + i = null, + r = ie.parse(arguments, [ + new ie({ type: "string" }), + new ie({ type: "callback" }), + ]), + a = A(r, 3); + return ( + (i = a[0]), + (e = a[1]), + (n = a[2]), + ge( + this._iid, + function (n) { + i + ? n(i, null) + : M.get(t._iid).container.apiClient.unbanUser( + { + channelUrl: t.url, + userId: e, + isGroupChannel: !0, + }, + function (e, t) { + n(e, null); + } + ); + }, + n + ) + ); + }, + }, + { + key: "updateJoinedMemberCount", + value: function () { + if (!this.isSuper && !this.isBroadcast) { + var e = D.get(this._iid).Member; + this.joinedMemberCount = this.members.filter(function (n) { + return n.state === e.JOINED; + }).length; + } + }, + }, + { + key: "setLatestMemberCount", + value: function (e, n, t) { + var i = !1; + return ( + "number" == typeof e && + "number" == typeof n && + "number" == typeof t && + t >= we.get(this) && + (we.set(this, t), + (i = + n !== this.joinedMemberCount || e !== this.memberCount), + (this.memberCount = e), + (this.joinedMemberCount = n)), + i + ); + }, + }, + { + key: "hide", + value: function (e, n, t) { + var i = this, + r = null, + a = ie.parse(arguments, [ + new ie({ type: "boolean", optional: !0, defaultValue: !1 }), + new ie({ type: "boolean", optional: !0, defaultValue: !0 }), + new ie({ type: "callback" }), + ]), + s = A(a, 4); + return ( + (r = s[0]), + (e = s[1]), + (n = s[2]), + (t = s[3]), + ge( + this._iid, + function (t) { + r + ? t(r, null) + : M.get(i._iid).container.apiClient.hideGroupChannel( + { + channelUrl: i.url, + hidePreviousMessages: e, + allowAutoUnhide: n, + }, + function (r, a) { + if (!r) { + var s = D.get(i._iid).GroupChannel; + (i.isHidden = !0), + (i.hiddenState = n + ? s.HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE + : s.HiddenState.HIDDEN_PREVENT_AUTO_UNHIDE), + e && i._setGroupChannelUnreadCount(0, 0), + a.hasOwnProperty("ts_message_offset") && + (i._messageOffsetTimestamp = + a.ts_message_offset), + (s.cachedChannels[i.url] = i); + } + t(r, a); + } + ); + }, + t + ) + ); + }, + }, + { + key: "unhide", + value: function (e) { + var n = this; + return ge( + this._iid, + function (e) { + M.get(n._iid).container.apiClient.unhideGroupChannel( + { channelUrl: n.url }, + function (t, i) { + if (!t) { + var r = D.get(n._iid).GroupChannel; + (n.isHidden = !1), + (n.hiddenState = r.HiddenState.UNHIDDEN), + (r.cachedChannels[n.url] = n); + } + e(t, i); + } + ); + }, + e + ); + }, + }, + { + key: "freeze", + value: function (e) { + var n = this; + return ge( + this._iid, + function (e) { + M.get(n._iid).container.apiClient.freeze( + { channelUrl: n.url, isGroupChannel: !0, freezing: !0 }, + function (t, i) { + if (!t) { + var r = D.get(n._iid).GroupChannel; + (n.isFrozen = !0), (r.cachedChannels[n.url] = n); + } + e(t, null); + } + ); + }, + e + ); + }, + }, + { + key: "unfreeze", + value: function (e) { + var n = this; + return ge( + this._iid, + function (e) { + M.get(n._iid).container.apiClient.freeze( + { channelUrl: n.url, isGroupChannel: !0, freezing: !1 }, + function (t, i) { + if (!t) { + var r = D.get(n._iid).GroupChannel; + (n.isFrozen = !1), (r.cachedChannels[n.url] = n); + } + e(t, null); + } + ); + }, + e + ); + }, + }, + { + key: "delete", + value: function (e) { + var n = this; + return ge( + this._iid, + function (e) { + M.get(n._iid).container.apiClient.deleteGroupChannel( + { channelUrl: n.url }, + function (t, i) { + t || + D.get(n._iid).GroupChannel.removeCachedChannel(n.url); + e(t, i); + } + ); + }, + e + ); + }, + }, + { + key: "markAsRead", + value: function () { + var e = this, + n = D.get(this._iid).Command, + t = ft.getInstance(this._iid), + i = n.bRead({ channelUrl: this.url }); + t.sendCommand(i, function (n, i) { + if (t.getErrorFirstCallback()) { + var r = [n, i]; + (i = r[0]), (n = r[1]); + } + i || + (t.currentUser && + (e.updateReadReceipt( + t.currentUser.userId, + n.getJsonElement().ts + ), + (e.unreadMessageCount > 0 || e.unreadMentionCount > 0) && + (e._setGroupChannelUnreadCount(0, 0), + Object.keys(t.channelHandlers).forEach(function (n) { + t.channelHandlers[n].onChannelChanged(e); + })))); + }); + }, + }, + { + key: "getUnreadMemberCount", + value: function (e) { + var n = ft.getInstance(this._iid), + t = D.get(this._iid).Member; + if ( + e instanceof ve && + !e.isAdminMessage() && + n.currentUser && + !this.isSuper && + !this.isBroadcast + ) { + for ( + var i = 0, r = e.createdAt, a = this.members, s = 0; + s < a.length; + s++ + ) { + var o = a[s]; + if ( + n.currentUser.userId !== o.userId && + o.state === t.JOINED && + (!e.sender || e.sender.userId !== o.userId) + ) + (this.cachedReadReceiptStatus[o.userId] || 0) < r && i++; + } + return i; + } + return 0; + }, + }, + { + key: "getReadReceipt", + value: function (e) { + return this.getUnreadMemberCount(e); + }, + }, + { + key: "markAsDelivered", + value: function () { + var e = this, + n = ft.getInstance(this._iid), + t = n.currentUser ? n.currentUser.userId : null; + M.get(this._iid).container.apiClient.markAsDelivered( + { channelUrl: this.url, userId: t }, + function (n, i) { + if (n) V.debug(n); + else { + var r = i.hasOwnProperty("ts") ? i.ts : 0; + e.updateDeliveryReceipt(t, r); + } + } + ); + }, + }, + { + key: "getUndeliveredMemberCount", + value: function (e) { + var n = ft.getInstance(this._iid), + t = D.get(this._iid).Member; + if ( + this.cachedDeliveryReceiptStatus && + e instanceof ve && + !e.isAdminMessage() && + n.currentUser && + !this.isSuper && + !this.isBroadcast + ) { + var i, + r = e.createdAt, + a = 0, + s = O(this.members); + try { + for (s.s(); !(i = s.n()).done; ) { + var o = i.value; + n.currentUser.userId === o.userId || + o.state !== t.JOINED || + (e.sender && e.sender.userId === o.userId) || + (this.cachedDeliveryReceiptStatus[o.userId] < r && a++); + } + } catch (e) { + s.e(e); + } finally { + s.f(); + } + return a; + } + return 0; + }, + }, + { + key: "getDeliveryReceipt", + value: function (e) { + return this.getUndeliveredMemberCount(e); + }, + }, + { + key: "getReadMembers", + value: function (e) { + var n = + arguments.length > 1 && + void 0 !== arguments[1] && + arguments[1], + t = ft.getInstance(this._iid); + if ( + t.currentUser && + !this.isSuper && + !this.isBroadcast && + e instanceof ve && + !e.isAdminMessage() + ) { + for (var i = [], r = 0; r < this.members.length; r++) { + var a = this.members[r]; + if ( + n || + (a.userId !== t.currentUser.userId && + a.userId !== e.sender.userId) + ) { + var s = this.cachedReadReceiptStatus[a.userId] || 0; + s >= e.createdAt && i.push(a); + } + } + return i; + } + return []; + }, + }, + { + key: "getUnreadMembers", + value: function (e) { + var n = + arguments.length > 1 && + void 0 !== arguments[1] && + arguments[1], + t = ft.getInstance(this._iid); + if ( + t.currentUser && + !this.isSuper && + !this.isBroadcast && + e instanceof ve && + !e.isAdminMessage() + ) { + for (var i = [], r = 0; r < this.members.length; r++) { + var a = this.members[r]; + if ( + n || + (a.userId !== t.currentUser.userId && + a.userId !== e.sender.userId) + ) { + var s = this.cachedReadReceiptStatus[a.userId] || 0; + s < e.createdAt && i.push(a); + } + } + return i; + } + return []; + }, + }, + { + key: "getReadStatus", + value: function () { + var e = this, + n = + arguments.length > 0 && + void 0 !== arguments[0] && + arguments[0], + t = ft.getInstance(this._iid); + if (t.currentUser && !this.isSuper && !this.isBroadcast) { + for ( + var i = {}, + r = Object.keys(this.cachedReadReceiptStatus), + a = function (a) { + var s = r[a]; + if (!n && s === t.currentUser.userId) return "continue"; + var o = e.cachedReadReceiptStatus[s], + l = e.members.filter(function (e) { + return e.userId === s; + }); + i[s] = { + user: l.length > 0 ? l[0] : null, + last_seen_at: parseInt(o), + }; + }, + s = 0; + s < r.length; + s++ + ) + a(s); + return i; + } + return {}; + }, + }, + { + key: "updateReadReceipt", + value: function (e, n) { + var t = this.cachedReadReceiptStatus[e]; + if (!t || t < n) { + this.cachedReadReceiptStatus[e] = n; + var i = ft.getInstance(this._iid); + i.currentUser && + e === i.currentUser.userId && + (this.myLastRead = n); + } + }, + }, + { + key: "updateDeliveryReceipt", + value: function (e, n) { + if (this.cachedDeliveryReceiptStatus) + if (this.cachedDeliveryReceiptStatus.hasOwnProperty(e)) { + var t = this.cachedDeliveryReceiptStatus[e]; + (!t || t < n) && (this.cachedDeliveryReceiptStatus[e] = n); + } else this.cachedDeliveryReceiptStatus[e] = n; + }, + }, + { + key: "startTyping", + value: function () { + var e = ft.getInstance(this._iid), + n = new Date().getTime(), + t = e.Options.typingIndicatorThrottle; + ("number" != typeof t || t < 1e3 || t > 9e3) && (t = 1e3); + var i = Le.get(this); + if (n - i.start >= t) { + (i.end = 0), (i.start = n); + var r = D.get(this._iid).Command.bTypeStart({ + channelUrl: this.url, + time: i.start, + }); + e.sendCommand(r, null); + } + }, + }, + { + key: "endTyping", + value: function () { + var e = ft.getInstance(this._iid), + n = new Date().getTime(), + t = e.Options.typingIndicatorThrottle; + ("number" != typeof t || t < 1e3 || t > 9e3) && (t = 1e3); + var i = Le.get(this); + if (n - i.end >= t) { + (i.start = 0), (i.end = n); + var r = D.get(this._iid).Command.bTypeEnd({ + channelUrl: this.url, + time: i.end, + }); + e.sendCommand(r, null); + } + }, + }, + { + key: "invalidateTypingStatus", + value: function () { + var e = Pe.get(this), + n = new Date().getTime(), + t = !1; + return ( + Object.keys(e).forEach(function (i) { + var r = e[i].ts; + n - r >= 1e4 && (delete e[i], (t = !0)); + }), + t + ); + }, + }, + { + key: "getTypingMembers", + value: function () { + var e = this, + n = Pe.get(this), + t = []; + return ( + Object.keys(n).forEach(function (n) { + var i = e.memberMap[n]; + i && t.push(i); + }), + t + ); + }, + }, + { + key: "getTypingUsers", + value: function () { + var e = Pe.get(this), + n = []; + return ( + Object.keys(e).forEach(function (t) { + var i = e[t].user; + n.push(i); + }), + n + ); + }, + }, + { + key: "updateTypingStatus", + value: function (e, n) { + var t = Pe.get(this); + n + ? (t[e.userId] = { user: e, ts: new Date().getTime() }) + : delete t[e.userId]; + }, + }, + { + key: "isTyping", + value: function () { + var e = Pe.get(this); + return 0 !== Object.keys(e).length; + }, + }, + { + key: "registerScheduledUserMessage", + value: function (e, n) { + var t = this, + i = D.get(this._iid), + r = i.ScheduledUserMessage, + a = i.ScheduledUserMessageParams, + s = null, + o = ie.parse(arguments, [ + new ie({ + type: a, + constraint: function (e) { + return ( + "string" == typeof e.message && + "string" == typeof e._getScheduleString() + ); + }, + }), + new ie({ type: "callback" }), + ]), + l = A(o, 3); + return ( + (s = l[0]), + (e = l[1]), + (n = l[2]), + ge( + this._iid, + function (n) { + s + ? n(s, null) + : M.get( + t._iid + ).container.apiClient.registerScheduledUserMessage( + { + groupChannelParams: e, + channelUrl: t.url, + isOpenChannel: !1, + }, + function (e, i) { + var a = null; + if (!e) { + a = new r(i); + var s = ft.getInstance(t._iid).currentUser; + s && + a._sender && + s.userId === a._sender.userId && + ((s.nickname = a._sender.nickname), + (s.plainProfileUrl = + a._sender.plainProfileUrl), + (s.metaData = a._sender.metaData)); + } + n(e, a); + } + ); + }, + n + ) + ); + }, + }, + { + key: "getPushPreference", + value: function (e) { + var n = this; + return ge( + this._iid, + function (e) { + M.get(n._iid).container.apiClient.getMyPushTriggerOption( + { channelUrl: n.url }, + function (t, i) { + var r = null; + if (!t) { + try { + r = i.enable; + } catch (e) { + r = !1; + } + n.isPushEnabled = r; + } + e && e(t, r); + } + ); + }, + e + ); + }, + }, + { + key: "setPushPreference", + value: function (e, n) { + var t = this; + return ge( + this._iid, + function (n) { + var i = D.get(t._iid).GroupChannel; + M.get(t._iid).container.apiClient.setMyPushTriggerOption( + { channelUrl: t.url, enable: e }, + function (e, r) { + e || + ((t.isPushEnabled = r.enable), + t.isPushEnabled || + (t.myPushTriggerOption = i.PushTriggerOption.OFF)), + n(e, r); + } + ); + }, + n + ); + }, + }, + { + key: "getMyPushTriggerOption", + value: function (e) { + var n = this; + return ge( + this._iid, + function (e) { + M.get(n._iid).container.apiClient.getMyPushTriggerOption( + { channelUrl: n.url }, + function (i, r) { + var a = null; + if (!i) { + try { + a = + r.push_trigger_option || + t.PushTriggerOption.DEFAULT; + } catch (e) { + V.debug(e); + } + n.myPushTriggerOption = a; + } + e(i, a); + } + ); + }, + e + ); + }, + }, + { + key: "setMyPushTriggerOption", + value: function (e, n) { + var t = this, + i = D.get(this._iid), + r = i.GroupChannel, + a = null, + s = ie.parse(arguments, [ + new ie({ type: r.PushTriggerOption }), + new ie({ type: "callback" }), + ]), + o = A(s, 3); + return ( + (a = o[0]), + (e = o[1]), + (n = o[2]), + ge( + this._iid, + function (n) { + a + ? n(a, null) + : M.get( + t._iid + ).container.apiClient.setMyPushTriggerOption( + { channelUrl: t.url, pushTriggerOption: e }, + function (e, i) { + var r = null; + if (!e) { + try { + r = i.push_trigger_option; + } catch (e) { + V.debug(e); + } + t.myPushTriggerOption = r; + } + n(e, r); + } + ); + }, + n + ) + ); + }, + }, + { + key: "setMyCountPreference", + value: function (e, n) { + var t = this, + i = D.get(this._iid), + r = i.GroupChannel, + a = null, + s = ie.parse(arguments, [ + new ie({ type: r.CountPreference }), + new ie({ type: "callback" }), + ]), + o = A(s, 3); + return ( + (a = o[0]), + (e = o[1]), + (n = o[2]), + ge( + this._iid, + function (n) { + a + ? n(a, null) + : M.get( + t._iid + ).container.apiClient.setMyCountPreference( + { channelUrl: t.url, countPreference: e }, + function (e, i) { + var a = null; + e || + ((a = t.myCountPreference = i.count_preference), + t._setGroupChannelUnreadCount( + t.unreadMessageCount, + t.unreadMentionCount + ), + (r.cachedChannels[t.url] = t)), + n(e, a); + } + ); + }, + n + ) + ); + }, + }, + { + key: "resetMyHistory", + value: function (e) { + var n = this; + return ge( + this._iid, + function (e) { + M.get(n._iid).container.apiClient.resetMyHistory( + { channelUrl: n.url }, + function (t, i) { + if (!t && i.hasOwnProperty("ts_message_offset")) { + var r = D.get(n._iid).GroupChannel; + (n._messageOffsetTimestamp = i.ts_message_offset), + (r.cachedChannels[n.url] = n); + } + e(t, i); + } + ); + }, + e + ); + }, + }, + ], + [ + { + key: "MemberStateFilter", + get: function () { + return { + ALL: "all", + JOINED: "joined_only", + INVITED: "invited_only", + INVITED_BY_FRIEND: "invited_by_friend", + INVITED_BY_NON_FRIEND: "invited_by_non_friend", + }; + }, + }, + { + key: "PushTriggerOption", + get: function () { + return { + DEFAULT: "default", + ALL: "all", + MENTION_ONLY: "mention_only", + OFF: "off", + }; + }, + }, + { + key: "CountPreference", + get: function () { + return { + ALL: "all", + UNREAD_MESSAGE_COUNT_ONLY: "unread_message_count_only", + UNREAD_MENTION_COUNT_ONLY: "unread_mention_count_only", + OFF: "off", + }; + }, + }, + { + key: "HiddenState", + get: function () { + return { + UNHIDDEN: "unhidden", + HIDDEN_ALLOW_AUTO_UNHIDE: "hidden_allow_auto_unhide", + HIDDEN_PREVENT_AUTO_UNHIDE: "hidden_prevent_auto_unhide", + }; + }, + }, + { + key: "PublicChannelFilter", + get: function () { + return { ALL: "all", PUBLIC: "public", PRIVATE: "private" }; + }, + }, + { + key: "SuperChannelFilter", + get: function () { + return { + ALL: "all", + SUPER: "super", + NON_SUPER: "nonsuper", + BROADCAST_ONLY: "broadcast_only", + }; + }, + }, + { + key: "UnreadChannelFilter", + get: function () { + return { ALL: "all", UNREAD_MESSAGE: "unread_message" }; + }, + }, + { + key: "HiddenChannelFilter", + get: function () { + return { + UNHIDDEN: "unhidden_only", + HIDDEN: "hidden_only", + HIDDEN_ALLOW_AUTO_UNHIDE: "hidden_allow_auto_unhide", + HIDDEN_PREVENT_AUTO_UNHIDE: "hidden_prevent_auto_unhide", + }; + }, + }, + { + key: "Role", + get: function () { + return { OPERATOR: "operator", NONE: "none" }; + }, + }, + { + key: "UnreadItemKey", + get: function () { + return { + GROUP_CHANNEL_UNREAD_MENTION_COUNT: + "group_channel_unread_mention_count", + NONSUPER_UNREAD_MENTION_COUNT: + "non_super_group_channel_unread_mention_count", + SUPER_UNREAD_MENTION_COUNT: + "super_group_channel_unread_mention_count", + GROUP_CHANNEL_UNREAD_MESSAGE_COUNT: + "group_channel_unread_message_count", + NONSUPER_UNREAD_MESSAGE_COUNT: + "non_super_group_channel_unread_message_count", + SUPER_UNREAD_MESSAGE_COUNT: + "super_group_channel_unread_message_count", + GROUP_CHANNEL_INVITATION_COUNT: + "group_channel_invitation_count", + NONSUPER_INVITATION_COUNT: + "non_super_group_channel_invitation_count", + SUPER_INVITATION_COUNT: + "super_group_channel_invitation_count", + }; + }, + }, + { + key: "cachedChannels", + get: function () { + return Te[this._iid] || (Te[this._iid] = {}), Te[this._iid]; + }, + }, + { + key: "buildFromSerializedData", + value: function (e) { + var n = D.get(this._iid), + t = n.User, + i = n.Member, + r = n.GroupChannel, + a = n.BaseMessage, + s = n.UserMessage, + o = n.FileMessage, + c = n.AdminMessage, + d = ye.deserialize(e), + h = (function (e) { + return null != e && "object" === u(e) + ? e.messageType === a.MESSAGE_TYPE_USER + ? new s( + s.objectify( + l( + l({}, e), + {}, + { + channel: { + url: e.channelUrl, + channelType: e.channelType, + }, + user: e.sender, + mentionedUsers: e.mentionedUsers, + } + ) + ) + ) + : e.messageType === a.MESSAGE_TYPE_FILE + ? new o( + o.objectify( + l( + l({}, e), + {}, + { + channel: { + url: e.channelUrl, + channelType: e.channelType, + }, + user: e.sender, + mentionedUsers: e.mentionedUsers, + } + ) + ) + ) + : new c( + c.objectify( + l( + l({}, e), + {}, + { + channel: { + url: e.channelUrl, + channelType: e.channelType, + }, + mentionedUsers: e.mentionedUsers, + } + ) + ) + ) + : null; + })(d.lastMessage); + return new r({ + channel_url: d.url, + name: d.name, + cover_url: d.coverUrl, + data: d.data, + custom_type: d.customType, + invited_at: d.invitedAt, + created_at: d.createdAt / 1e3, + joined_ts: d.joinedAt, + is_access_code_required: d.isAccessCodeRequired, + is_distinct: d.isDistinct, + is_super: d.isSuper, + is_broadcast: d.isBroadcast, + is_public: d.isPublic, + is_discoverable: d.isDiscoverable, + is_hidden: d.isHidden, + is_ephemeral: d.isEphemeral, + is_muted: d.myMutedState, + is_push_enabled: d.isPushEnabled, + freeze: d.isFrozen, + unread_message_count: d.unreadMessageCount, + unread_mention_count: d.unreadMentionCount, + push_trigger_option: d.myPushTriggerOption, + count_preference: d.myCountPreference, + hidden_state: d.hiddenState, + member_count: d.memberCount, + joined_member_count: d.joinedMemberCount, + member_state: d.myMemberState, + my_role: d.myRole, + user_last_read: d.myLastRead, + ts_message_offset: d.messageOffsetTimestamp, + message_survival_seconds: d.messageSurvivalSeconds, + read_receipt: d.cachedReadReceiptStatus, + delivery_receipt: d.cachedDeliveryReceiptStatus, + members: d.members.map(function (e) { + return i.objectify(l({ user: e }, e)); + }), + last_message: h, + created_by: + null !== d.creator && + void 0 !== d.creator && + "object" === u(d.creator) + ? t.objectify(d.creator) + : null, + inviter: + null !== d.inviter && + void 0 !== d.inviter && + "object" === u(d.inviter) + ? t.objectify(d.inviter) + : null, + }); + }, + }, + { + key: "upsert", + value: function (e) { + var n = D.get(this._iid).GroupChannel, + t = new n(e); + if (n.cachedChannels.hasOwnProperty(t.url)) { + if (t.isEphemeral) { + var i = n.cachedChannels[t.url]; + (e.last_message = i.lastMessage), + (e.unread_message_count = i.unreadMessageCount); + } + n.cachedChannels[t.url].update(e); + } else n.cachedChannels[t.url] = t; + return n.cachedChannels[t.url]; + }, + }, + { + key: "removeCachedChannel", + value: function (e) { + var n = D.get(this._iid), + t = n.GroupChannel, + i = n.FileMessageQueue; + t.cachedChannels[e] && delete t.cachedChannels[e], i.delete(e); + }, + }, + { + key: "clearCache", + value: function () { + (Te[this._iid] = {}), D.get(this._iid).FileMessageQueue.clear(); + }, + }, + { + key: "getChannel", + value: function (e, n) { + var t = null, + i = null, + r = ie.parse(arguments, [ + new ie({ + type: "string", + constraint: function (e) { + return e.length > 0; + }, + }), + new ie({ + type: "string", + optional: !0, + nullable: !0, + defaultValue: null, + }), + new ie({ type: "callback" }), + ]), + a = A(r, 4); + if (((t = a[0]), (e = a[1]), (i = a[2]), (n = a[3]), t)) + return ge( + this._iid, + function (e) { + e(t, null); + }, + n + ); + var s = D.get(this._iid), + o = s.GroupChannel; + return o.cachedChannels[e] + ? ge( + this._iid, + function (n) { + n(null, o.cachedChannels[e]); + }, + n + ) + : o.getChannelWithoutCache(e, i, n); + }, + }, + { + key: "getChannelWithoutCache", + value: function (e, n) { + var t = this, + i = null, + r = null, + a = ie.parse(arguments, [ + new ie({ + type: "string", + constraint: function (e) { + return e.length > 0; + }, + }), + new ie({ + type: "string", + optional: !0, + nullable: !0, + defaultValue: null, + }), + new ie({ type: "callback" }), + ]), + s = A(a, 4); + return ( + (i = s[0]), + (e = s[1]), + (r = s[2]), + (n = s[3]), + ge( + this._iid, + function (n) { + i + ? n(i, null) + : M.get(t._iid).container.apiClient.getGroupChannel( + { channelUrl: e, internalCall: r, showMember: !0 }, + function (e, i) { + var r = null; + e || (r = t.upsert(i)), n(e, r); + } + ); + }, + n + ) + ); + }, + }, + { + key: "createDistinctChannelIfNotExist", + value: function (e, n) { + var t = this, + i = D.get(this._iid), + r = i.GroupChannelParams, + a = null, + s = ie.parse(arguments, [ + new ie({ + type: r, + constraint: function (e) { + return e._validate(); + }, + }), + new ie({ type: "callback" }), + ]), + o = A(s, 3); + return ( + (a = o[0]), + (e = o[1]), + (n = o[2]), + ge( + this._iid, + function (n) { + a + ? n(a, null) + : (e.isPublic || (e.accessCode = null), + M.get(t._iid).container.apiClient.createGroupChannel( + l(l({}, e), {}, { isDistinct: !0 }), + function (e, i) { + var r = null; + if (!e) { + var a = D.get(t._iid).GroupChannel; + (r = { + channel: new a(i), + isCreated: i.is_created, + }), + (a.cachedChannels[r.channel.url] = r.channel); + } + n(e, r); + } + )); + }, + n + ) + ); + }, + }, + { + key: "createChannel", + value: function () { + var e = this, + n = ie.toArray(arguments), + t = void 0; + "function" == typeof n[n.length - 1] && (t = n.pop()); + var i = D.get(this._iid), + r = i.GroupChannel, + a = i.GroupChannelParams; + if (n[0] instanceof a && 1 === n.length) + return ge( + this._iid, + function (t) { + var i = n[0]; + (i.isPublic || (i.accessCode = null), i._validate()) + ? M.get(e._iid).container.apiClient.createGroupChannel( + i, + function (e, n) { + var i = null; + e || + ((i = new r(n)), (r.cachedChannels[i.url] = i)), + t(e, i); + } + ) + : t(ie.error, null); + }, + t + ); + if (Array.isArray(n[0])) { + var s = new a(); + switch (n.length) { + case 1: + s.addUsers(n[0]); + break; + case 2: + s.addUsers(n[0]), (s.isDistinct = n[1]); + break; + case 3: + s.addUsers(n[0]), + (s.isDistinct = n[1]), + (s.customType = n[2]); + break; + case 5: + s.addUsers(n[0]), + (s.isDistinct = n[1]), + (s.name = n[2]), + "string" == typeof n[3] + ? (s.coverUrl = n[3]) + : (s.coverImage = n[3]), + (s.data = n[4]); + break; + case 6: + s.addUsers(n[0]), + (s.isDistinct = n[1]), + (s.name = n[2]), + "string" == typeof n[3] + ? (s.coverUrl = n[3]) + : (s.coverImage = n[3]), + (s.data = n[4]), + (s.customType = n[5]); + break; + default: + return ge( + this._iid, + function (e) { + return e(ie.error, null); + }, + t + ); + } + return t ? r.createChannel(s, t) : r.createChannel(s); + } + return ge( + this._iid, + function (e) { + return e(ie.error, null); + }, + t + ); + }, + }, + { + key: "createChannelWithUserIds", + value: function () { + var e = ie.toArray(arguments), + n = void 0; + "function" == typeof e[e.length - 1] && (n = e.pop()); + var t = D.get(this._iid), + i = t.GroupChannel, + r = t.GroupChannelParams, + a = new r(); + switch (e.length) { + case 1: + a.addUserIds(e[0]); + break; + case 2: + a.addUserIds(e[0]), (a.isDistinct = e[1]); + break; + case 3: + a.addUserIds(e[0]), + (a.isDistinct = e[1]), + (a.customType = e[2]); + break; + case 5: + a.addUserIds(e[0]), + (a.isDistinct = e[1]), + (a.name = e[2]), + "string" == typeof e[3] + ? (a.coverUrl = e[3]) + : (a.coverImage = e[3]), + (a.data = e[4]); + break; + case 6: + a.addUserIds(e[0]), + (a.isDistinct = e[1]), + (a.name = e[2]), + "string" == typeof e[3] + ? (a.coverUrl = e[3]) + : (a.coverImage = e[3]), + (a.data = e[4]), + (a.customType = e[5]); + break; + default: + return ge( + this._iid, + function (e) { + return e(ie.error, null); + }, + n + ); + } + return i.createChannel(a, n); + }, + }, + { + key: "createMyGroupChannelListQuery", + value: function () { + return new (0, D.get(this._iid).GroupChannelListQuery)(); + }, + }, + { + key: "createPublicGroupChannelListQuery", + value: function () { + return new (0, D.get(this._iid).PublicGroupChannelListQuery)(); + }, + }, + { + key: "markAsReadAllLastSentAt", + get: function () { + return Me[this._iid] || 0; + }, + set: function (e) { + Me[this._iid] = e; + }, + }, + { + key: "getChannelCount", + value: function (e, n) { + return ft.getInstance(this._iid).getGroupChannelCount(e, n); + }, + }, + { + key: "getUnreadItemCount", + value: function (e, n) { + return ft.getInstance(this._iid).getUnreadItemCount(e, n); + }, + }, + { + key: "getTotalUnreadMessageCount", + value: function () { + var e = ie.toArray(arguments), + n = "function" == typeof e[e.length - 1] ? e.pop() : null, + t = ft.getInstance(this._iid); + return t.getTotalUnreadMessageCount.apply(t, I(e).concat([n])); + }, + }, + { + key: "getTotalUnreadChannelCount", + value: function (e) { + return ft.getInstance(this._iid).getTotalUnreadChannelCount(e); + }, + }, + ] + ), + t + ); + })(Ue), + He = (function (e) { + f(t, e); + var n = b(t); + function t(e) { + var i; + return ( + c(this, t), + ((i = n.call(this, e)).state = ""), + (i.role = ""), + (i.isMuted = !1), + (i.isBlockedByMe = !1), + (i.isBlockingMe = !1), + e && i._update(e), + i + ); + } + return ( + h( + t, + [ + { + key: "_update", + value: function (e) { + (this.state = e.state), + (this.role = e.role || De.Role.NONE), + e.hasOwnProperty("is_muted") && (this.isMuted = e.is_muted), + e.hasOwnProperty("is_blocked_by_me") && + (this.isBlockedByMe = e.is_blocked_by_me), + e.hasOwnProperty("is_blocking_me") && + (this.isBlockingMe = e.is_blocking_me); + }, + }, + { + key: "parse", + value: function (e) { + this._update(e); + }, + }, + ], + [ + { + key: "objectify", + value: function (e) { + var n = D.get(this._iid).User, + t = e.user, + i = e.state, + r = e.role, + a = void 0 === r ? "" : r, + s = e.isMuted, + o = void 0 !== s && s, + l = e.isBlockedByMe, + u = void 0 !== l && l, + c = e.isBlockingMe, + d = void 0 !== c && c, + h = n.objectify(t); + return ( + (h.state = i), + (h.role = a), + (h.is_muted = o), + (h.is_blocked_by_me = u), + (h.is_blocking_me = d), + h + ); + }, + }, + { + key: "build", + value: function (e, n, t, i, r, a) { + var s = D.get(this._iid).User; + return this.objectify({ + user: new s(e), + state: n, + role: t, + isMuted: i, + isBlockedByMe: r, + isBlockingMe: a, + }); + }, + }, + { + key: "buildFromSerializedData", + value: function (e) { + var n = D.get(this._iid).Member, + t = ye.deserialize(e); + return new n(n.objectify(l({ user: t }, t))); + }, + }, + { + key: "JOINED", + get: function () { + return "joined"; + }, + }, + { + key: "INVITED", + get: function () { + return "invited"; + }, + }, + ] + ), + t + ); + })(Ee), + Fe = (function (e) { + f(t, e); + var n = b(t); + function t(e) { + var i; + return ( + c(this, t), + ((i = n.call(this, e)).role = ""), + (i.isBlockedByMe = !1), + e && i._update(e), + i + ); + } + return ( + h( + t, + [ + { + key: "parse", + value: function (e) { + this._update(e); + }, + }, + { + key: "_update", + value: function (e) { + (this.role = e.role || De.Role.NONE), + e.hasOwnProperty("is_blocked_by_me") && + (this.isBlockedByMe = e.is_blocked_by_me); + }, + }, + ], + [ + { + key: "objectify", + value: function (e) { + var n = D.get(this._iid).User, + t = e.user, + i = e.role, + r = void 0 === i ? "" : i, + a = e.isBlockedByMe, + s = void 0 !== a && a, + o = n.objectify(t); + return (o.role = r), (o.is_blocked_by_me = s), o; + }, + }, + { + key: "build", + value: function (e, n) { + var t = D.get(this._iid).User; + return this.objectify({ user: new t(e), isBlockedByMe: n }); + }, + }, + { + key: "buildFromSerializedData", + value: function (e) { + var n = D.get(this._iid).Sender, + t = ye.deserialize(e); + return new n(n.objectify(l({ user: t }, t))); + }, + }, + ] + ), + t + ); + })(Ee), + Ge = (function () { + function e(n) { + c(this, e), + (this.emojiHash = null), + (this.emojiCategories = null), + n && this._update(n); + } + return ( + h(e, [ + { + key: "_update", + value: function (e) { + var n = D.get(this._iid).EmojiCategory; + (this.emojiHash = e.emoji_hash || ""), + (this.emojiCategories = e.emoji_categories + ? e.emoji_categories.map(function (e) { + return new n(e); + }) + : []); + }, + }, + ]), + e + ); + })(), + je = (function () { + function e(n) { + c(this, e), + (this.id = null), + (this.name = null), + (this.url = null), + (this.emojis = null), + n && this._update(n); + } + return ( + h(e, [ + { + key: "_update", + value: function (e) { + var n = D.get(this._iid).Emoji; + (this.id = e.id || 0), + (this.name = e.name || ""), + (this.url = e.url || ""), + (this.emojis = e.emojis + ? e.emojis.map(function (e) { + return new n(e); + }) + : []); + }, + }, + ]), + e + ); + })(), + Be = (function () { + function e(n) { + c(this, e), (this.key = null), (this.url = null), n && this._update(n); + } + return ( + h(e, [ + { + key: "_update", + value: function (e) { + (this.key = e.key), (this.url = e.url); + }, + }, + ]), + e + ); + })(), + xe = {}, + qe = {}, + ze = new WeakMap(), + Qe = (function (e) { + f(t, e); + var n = b(t); + function t(e) { + var i; + return ( + c(this, t), + ((i = n.call(this, e)).channelType = Ue.CHANNEL_TYPE_OPEN), + (i.participantCount = 0), + ze.set(E(i), 0), + (i.operators = []), + e && i._update(e), + i + ); + } + return ( + h( + t, + [ + { + key: "_update", + value: function (e) { + var n = D.get(this._iid).User; + e.hasOwnProperty("participant_count") && + (this.participantCount = parseInt(e.participant_count)), + e.hasOwnProperty("operators") && + Array.isArray(e.operators) && + (this.operators = e.operators.map(function (e) { + return new n(e); + })); + }, + }, + { + key: "parse", + value: function (e) { + this._update(e); + }, + }, + { + key: "update", + value: function (e) { + this.__update(e), this._update(e); + }, + }, + { + key: "createParticipantListQuery", + value: function () { + return new (0, D.get(this._iid).ParticipantListQuery)({ + channelUrl: this.url, + }); + }, + }, + { + key: "createMutedUserListQuery", + value: function () { + return new (0, D.get(this._iid).MutedUserListQuery)({ + channelUrl: this.url, + isOpenChannel: !0, + }); + }, + }, + { + key: "createBannedUserListQuery", + value: function () { + return new (0, D.get(this._iid).BannedUserListQuery)({ + channelUrl: this.url, + isOpenChannel: !0, + }); + }, + }, + { + key: "isOperator", + value: function (e) { + return !!e && this.isOperatorWithUserId(e.userId); + }, + }, + { + key: "isOperatorWithUserId", + value: function (e) { + return ( + this.operators + .map(function (e) { + return e.userId; + }) + .indexOf(e) > -1 + ); + }, + }, + { + key: "refresh", + value: function (e) { + return D.get(this._iid).OpenChannel.getChannelWithoutCache( + this.url, + e + ); + }, + }, + { + key: "enter", + value: function (e) { + var n = this; + return ge( + this._iid, + function (e) { + var t = D.get(n._iid).Command.bEnter({ channelUrl: n.url }), + i = ft.getInstance(n._iid); + i.sendCommand(t, function (t, r) { + if (i.getErrorFirstCallback()) { + var a = [t, r]; + (r = a[0]), (t = a[1]); + } + r + ? ((r = r ? new P(r.message, r.code) : null), + e(r, null)) + : ((D.get(n._iid).OpenChannel.enteredChannels[ + n.url + ] = n), + n.refresh(function () { + return e(null, null); + })); + }); + }, + e + ); + }, + }, + { + key: "exit", + value: function (e) { + var n = this; + return ge( + this._iid, + function (e) { + var t = D.get(n._iid), + i = t.Command, + r = t.FileMessageQueue, + a = i.bExit({ channelUrl: n.url }), + s = ft.getInstance(n._iid); + s.sendCommand(a, function (t, i) { + if (s.getErrorFirstCallback()) { + var a = [t, i]; + (i = a[0]), (t = a[1]); + } + i + ? ((i = i ? new P(i.message, i.code) : null), + e(i, null)) + : (delete D.get(n._iid).OpenChannel.enteredChannels[ + n.url + ], + r.delete(n.url), + e(null, null)); + }); + }, + e + ); + }, + }, + { + key: "updateChannel", + value: function () { + var e = this, + n = ie.toArray(arguments), + t = null; + "function" == typeof n[n.length - 1] && (t = n.pop()); + var i = D.get(this._iid), + r = i.OpenChannel, + a = i.OpenChannelParams; + if (n[0] instanceof a && 1 === n.length) + return ge( + this._iid, + function (t) { + var i = n[0]; + ((i.channelUrl = e.url), i._validate()) + ? M.get(e._iid).container.apiClient.updateOpenChannel( + i, + function (e, n) { + var i = null; + e || (i = r.upsert(n)), t(e, i); + } + ) + : t(ie.error, null); + }, + t + ); + if (3 === n.length) { + var s = new a(); + return ( + (s.channelUrl = this.url), + (s.name = n[0]), + (s.coverUrlOrImage = n[1]), + (s.data = n[2]), + (s.operatorUserIds = this.operators.map(function (e) { + return e.userId; + })), + this.updateChannel(s, t) + ); + } + if (4 === n.length) { + var o = new a(); + return ( + (o.channelUrl = this.url), + (o.name = n[0]), + (o.coverUrlOrImage = n[1]), + (o.data = n[2]), + Array.isArray(n[3]) && (o.operatorUserIds = n[3]), + this.updateChannel(o, t) + ); + } + if (5 === n.length) { + var l = new a(); + return ( + (l.channelUrl = this.url), + (l.name = n[0]), + (l.coverUrlOrImage = n[1]), + (l.data = n[2]), + Array.isArray(n[3]) && (l.operatorUserIds = n[3]), + (l.customType = n[4]), + this.updateChannel(l, t) + ); + } + return ge( + this._iid, + function (e) { + return e(ie.error, null); + }, + t + ); + }, + }, + { + key: "updateChannelWithOperatorUserIds", + value: function () { + var e = ie.toArray(arguments), + n = void 0; + switch ( + ("function" == typeof e[e.length - 1] && (n = e.pop()), + e.length) + ) { + case 4: + case 5: + return this.updateChannel.apply(this, I(e).concat([n])); + default: + return ge( + this._iid, + function (e) { + return e(ie.error, null); + }, + n + ); + } + }, + }, + { + key: "muteUser", + value: function (e, n, t, i) { + return this.muteUserWithUserId(e ? e.userId : null, n, t, i); + }, + }, + { + key: "muteUserWithUserId", + value: function (e, n, t, i) { + var r = this, + a = null, + s = ie.parse(arguments, [ + new ie({ type: "string" }), + new ie({ + type: "number", + optional: !0, + defaultValue: -1, + constraint: function (e) { + return e >= -1; + }, + }), + new ie({ type: "string", optional: !0, defaultValue: "" }), + new ie({ type: "callback" }), + ]), + o = A(s, 5); + return ( + (a = o[0]), + (e = o[1]), + (n = o[2]), + (t = o[3]), + (i = o[4]), + ge( + this._iid, + function (i) { + a + ? i(a, null) + : M.get(r._iid).container.apiClient.muteUser( + { + channelUrl: r.url, + userId: e, + description: t, + seconds: n, + isGroupChannel: !1, + }, + function (e, n) { + i(e, null); + } + ); + }, + i + ) + ); + }, + }, + { + key: "unmuteUser", + value: function (e, n) { + return this.unmuteUserWithUserId(e ? e.userId : null, n); + }, + }, + { + key: "unmuteUserWithUserId", + value: function (e, n) { + var t = this, + i = null, + r = ie.parse(arguments, [ + new ie({ type: "string" }), + new ie({ type: "callback" }), + ]), + a = A(r, 3); + return ( + (i = a[0]), + (e = a[1]), + (n = a[2]), + ge( + this._iid, + function (n) { + i + ? n(i, null) + : M.get(t._iid).container.apiClient.unmuteUser( + { + channelUrl: t.url, + userId: e, + isGroupChannel: !1, + }, + function (e, t) { + n(e, null); + } + ); + }, + n + ) + ); + }, + }, + { + key: "banUser", + value: function (e, n, t) { + return this.banUserWithUserId(e ? e.userId : null, n, t); + }, + }, + { + key: "banUserWithUserId", + value: function (e, n, t) { + var i = this, + r = null, + a = ie.parse(arguments, [ + new ie({ type: "string" }), + new ie({ + type: "number", + optional: !0, + defaultValue: -1, + constraint: function (e) { + return e >= -1; + }, + }), + new ie({ type: "callback" }), + ]), + s = A(a, 4); + return ( + (r = s[0]), + (e = s[1]), + (n = s[2]), + (t = s[3]), + ge( + this._iid, + function (t) { + r + ? t(r, null) + : M.get(i._iid).container.apiClient.banUser( + { + channelUrl: i.url, + userId: e, + description: null, + seconds: n, + isGroupChannel: !1, + }, + function (e, n) { + t(e, null); + } + ); + }, + t + ) + ); + }, + }, + { + key: "unbanUser", + value: function (e, n) { + return this.unbanUserWithUserId(e ? e.userId : null, n); + }, + }, + { + key: "unbanUserWithUserId", + value: function (e, n) { + var t = this, + i = null, + r = ie.parse(arguments, [ + new ie({ type: "string" }), + new ie({ type: "callback" }), + ]), + a = A(r, 3); + return ( + (i = a[0]), + (e = a[1]), + (n = a[2]), + ge( + this._iid, + function (n) { + i + ? n(i, null) + : M.get(t._iid).container.apiClient.unbanUser( + { + channelUrl: t.url, + userId: e, + isGroupChannel: !1, + }, + function (e, t) { + n(e, null); + } + ); + }, + n + ) + ); + }, + }, + { + key: "setLatestParticipantCount", + value: function (e, n) { + var t = !1; + return ( + "number" == typeof e && + "number" == typeof n && + n >= ze.get(this) && + (ze.set(this, n), + (t = e !== this.participantCount), + (this.participantCount = e)), + t + ); + }, + }, + { + key: "delete", + value: function (e) { + var n = this; + return ge( + this._iid, + function (e) { + M.get(n._iid).container.apiClient.deleteOpenChannel( + { channelUrl: n.url }, + function (t, i) { + t || + (delete D.get(n._iid).OpenChannel.cachedChannels[ + n.url + ], + D.get(n._iid).FileMessageQueue.delete(n.url)); + e(t, i); + } + ); + }, + e + ); + }, + }, + ], + [ + { + key: "cachedChannels", + get: function () { + return xe[this._iid] || (xe[this._iid] = {}), xe[this._iid]; + }, + }, + { + key: "enteredChannels", + get: function () { + return qe[this._iid] || (qe[this._iid] = {}), qe[this._iid]; + }, + }, + { + key: "buildFromSerializedData", + value: function (e) { + var n = D.get(this._iid), + t = n.User, + i = n.OpenChannel, + r = ye.deserialize(e); + return new i({ + channel_url: r.url, + name: r.name, + cover_url: r.coverUrl, + data: r.data, + custom_type: r.customType, + created_at: r.createdAt / 1e3, + freeze: r.isFrozen, + is_ephemeral: r.isEphemeral, + participant_count: r.participantCount, + operators: r.operators.map(function (e) { + return t.objectify(e); + }), + }); + }, + }, + { + key: "getChannel", + value: function (e, n) { + var t = null, + i = null, + r = ie.parse(arguments, [ + new ie({ + type: "string", + constraint: function (e) { + return e.length > 0; + }, + }), + new ie({ + type: "string", + optional: !0, + nullable: !0, + defaultValue: null, + }), + new ie({ type: "callback" }), + ]), + a = A(r, 4); + if (((t = a[0]), (e = a[1]), (i = a[2]), (n = a[3]), t)) + return ge( + this._iid, + function (e) { + e(t, null); + }, + n + ); + var s = D.get(this._iid), + o = s.OpenChannel; + return o.cachedChannels[e] + ? ge( + this._iid, + function (n) { + n(null, o.cachedChannels[e]); + }, + n + ) + : o.getChannelWithoutCache(e, i, n); + }, + }, + { + key: "getChannelWithoutCache", + value: function (e, n) { + var t = this, + i = null, + r = null, + a = ie.parse(arguments, [ + new ie({ + type: "string", + constraint: function (e) { + return e.length > 0; + }, + }), + new ie({ + type: "string", + optional: !0, + nullable: !0, + defaultValue: null, + }), + new ie({ type: "callback" }), + ]), + s = A(a, 4); + return ( + (i = s[0]), + (e = s[1]), + (r = s[2]), + (n = s[3]), + ge( + this._iid, + function (n) { + i + ? n(i, null) + : M.get(t._iid).container.apiClient.getOpenChannel( + { channelUrl: e, internalCall: r }, + function (e, i) { + var r = null; + e || (r = D.get(t._iid).OpenChannel.upsert(i)); + n(e, r); + } + ); + }, + n + ) + ); + }, + }, + { + key: "createChannel", + value: function () { + var e = this, + n = ie.toArray(arguments), + t = null; + "function" == typeof n[n.length - 1] && (t = n.pop()); + var i = D.get(this._iid), + r = i.OpenChannel, + a = i.OpenChannelParams; + if (n[0] instanceof a && 1 === n.length) + return ge( + this._iid, + function (t) { + var i = n[0]; + i._validate() + ? M.get(e._iid).container.apiClient.createOpenChannel( + i, + function (n, i) { + var r = null; + n || (r = D.get(e._iid).OpenChannel.upsert(i)); + t(n, r); + } + ) + : t(ie.error, null); + }, + t + ); + var s = new a(); + switch (n.length) { + case 0: + break; + case 1: + s.name = n[0]; + break; + case 2: + (s.name = n[0]), (s.coverUrlOrImage = n[1]); + break; + case 3: + (s.name = n[0]), + (s.coverUrlOrImage = n[1]), + (s.data = n[2]); + break; + case 4: + (s.name = n[0]), + (s.coverUrlOrImage = n[1]), + (s.data = n[2]), + (s.operatorUserIds = n[3]); + break; + case 5: + (s.name = n[0]), + (s.coverUrlOrImage = n[1]), + (s.data = n[2]), + (s.operatorUserIds = n[3]), + (s.customType = n[4]); + break; + default: + return ge( + this._iid, + function (e) { + return e(ie.error, null); + }, + t + ); + } + return t ? r.createChannel(s, t) : r.createChannel(s); + }, + }, + { + key: "createChannelWithOperatorUserIds", + value: function () { + var e = ie.toArray(arguments), + n = void 0; + switch ( + ("function" == typeof e[e.length - 1] && (n = e.pop()), + e.length) + ) { + case 4: + case 5: + return this.createChannel.apply(this, I(e).concat([n])); + default: + return ge( + this._iid, + function (e) { + return e(ie.error, null); + }, + n + ); + } + }, + }, + { + key: "upsert", + value: function (e) { + var n = new (0, D.get(this._iid).OpenChannel)(e); + return ( + this.cachedChannels.hasOwnProperty(n.url) + ? this.cachedChannels[n.url].update(e) + : (this.cachedChannels[n.url] = n), + this.cachedChannels[n.url] + ); + }, + }, + { + key: "removeCachedChannel", + value: function (e) { + this.cachedChannels[e] && delete this.cachedChannels[e], + D.get(this._iid).FileMessageQueue.delete(e); + }, + }, + { + key: "clearCache", + value: function () { + (xe[this._iid] = {}), D.get(this._iid).FileMessageQueue.clear(); + }, + }, + { + key: "clearEnteredChannels", + value: function () { + qe[this._iid] = {}; + }, + }, + { + key: "createOpenChannelListQuery", + value: function () { + return new (0, D.get(this._iid).OpenChannelListQuery)(); + }, + }, + ] + ), + t + ); + })(Ue), + Ve = (function (e) { + f(t, e); + var n = b(t); + function t(e) { + var i; + return ( + c(this, t), + ((i = n.call(this, e)).messageType = ve.MESSAGE_TYPE_USER), + (i.message = null), + (i._sender = null), + (i.reqId = ""), + (i.translations = {}), + (i.requestState = null), + (i.requestedMentionUserIds = []), + (i.errorCode = 0), + (i.messageSurvivalSeconds = -1), + (i.plugins = []), + (i.poll = null), + e && i._update(e), + i + ); + } + return ( + h( + t, + [ + { + key: "applyPollUpdateEvent", + value: function (e) { + var n = D.get(this._iid), + t = n.Poll, + i = n.PollUpdateEvent, + r = null, + a = ie.parse(arguments, [ + new ie({ + type: i, + constraint: function (e) { + return Object.values(t.Status).includes(e.status); + }, + }), + ]), + s = A(a, 2); + if ( + ((r = s[0]), + (e = s[1]), + !r && this.poll && this.poll.id === e.poll.id) + ) { + if (e.status === t.Status.REMOVED) + return ( + (this.poll = new t(t.objectify(this.poll))), + (this.poll.details.status = e.status), + !0 + ); + if (this.poll.details.updatedAt < e.poll.details.updatedAt) + return (this.poll = e.poll), !0; + } + return !1; + }, + }, + { + key: "applyPollVoteEvent", + value: function (e) { + var n = D.get(this._iid), + t = n.PollVoteEvent, + i = null, + r = ie.parse(arguments, [new ie({ type: t })]), + a = A(r, 2); + if ( + ((i = a[0]), + (e = a[1]), + !i && this.poll && this.poll.id === e.pollId) + ) { + var s, + o = O(this.poll.details.options); + try { + for (o.s(); !(s = o.n()).done; ) { + var l = s.value; + if (l._applyEvent(e)) return !0; + } + } catch (i) { + o.e(i); + } finally { + o.f(); + } + } + return !1; + }, + }, + { + key: "_update", + value: function (e) { + var n = ft.getInstance(this._iid), + t = D.get(this._iid), + i = t.Sender, + r = t.Plugin, + a = t.Poll; + (this.message = String(e.message)), + (this._sender = new i(e.user)), + (this.reqId = e.hasOwnProperty("req_id") + ? String(e.req_id) + : ""), + (this.translations = e.hasOwnProperty("translations") + ? e.translations + : {}), + (this.requestState = + this.messageId > 0 + ? n.MessageRequestState.SUCCEEDED + : n.MessageRequestState.FAILED), + e.hasOwnProperty("sending_status") && + ((this.requestState = e.sending_status), + this.requestState === n.MessageSendingStatus.CANCELED && + (this.requestState = n.MessageRequestState.FAILED)), + (this.requestedMentionUserIds = []), + e.hasOwnProperty("requested_mention_user_ids") && + (this.requestedMentionUserIds = + e.requested_mention_user_ids), + (this.errorCode = 0), + e.hasOwnProperty("error_code") && + (this.errorCode = e.error_code), + (this.messageSurvivalSeconds = -1), + e.hasOwnProperty("message_survival_seconds") && + (this.messageSurvivalSeconds = e.message_survival_seconds), + (this.plugins = []), + e.hasOwnProperty("plugins") && + Array.isArray(e.plugins) && + (this.plugins = e.plugins.map(function (e) { + return new r(e); + })), + (this.poll = null), + e.hasOwnProperty("poll") && (this.poll = new a(e.poll)); + }, + }, + { + key: "sender", + get: function () { + var e = ft.getInstance(this._iid), + n = D.get(this._iid).GroupChannel; + if ( + e.Options.useMemberAsMessageSender && + this.isGroupChannel() + ) { + var t = n.cachedChannels[this.channelUrl]; + if (t) { + var i = t.memberMap[this._sender.userId]; + i && + (this._sender.nickname !== i.nickname && + (this._sender.nickname = i.nickname), + this._sender.plainProfileUrl !== i.plainProfileUrl && + (this._sender.plainProfileUrl = i.plainProfileUrl), + X.deepEqual(this._sender.metaData, i.metaData) || + (this._sender.metaData = i.metaData)); + } + } + return this._sender; + }, + set: function (e) { + this._sender = e; + }, + }, + { + key: "isResendable", + value: function () { + var e = ft.getInstance(this._iid); + return ( + this.sendingStatus === e.MessageSendingStatus.FAILED && + X.isResendableError(this.errorCode) + ); + }, + }, + ], + [ + { + key: "objectify", + value: function (e) { + var n = ft.getInstance(this._iid), + t = D.get(this._iid), + i = t.BaseChannel, + r = t.BaseMessageParams, + a = t.Sender, + s = t.User, + o = t.UserMessage, + l = t.FileMessage, + u = t.AdminMessage, + c = t.ThreadInfo, + d = t.OGMetaData, + h = t.Plugin, + p = t.AppleCriticalAlertOptions, + f = t.Poll, + y = e.messageId, + g = e.reqId, + _ = void 0 === g ? "" : g, + m = e.user, + v = e.channel, + E = e.message, + C = e.data, + b = void 0 === C ? "" : C, + U = e.customType, + A = void 0 === U ? "" : U, + I = e.mentionType, + S = void 0 === I ? r.MentionType.USERS : I, + k = e.mentionedUsers, + O = void 0 === k ? [] : k, + N = e.mentionedUserIds, + R = void 0 === N ? [] : N, + T = e.requestedMentionUserIds, + M = void 0 === T ? [] : T, + P = e.reactions, + L = void 0 === P ? [] : P, + w = e.metaArrays, + H = void 0 === w ? [] : w, + F = e.rootMessageId, + G = void 0 === F ? 0 : F, + j = e.parentMessageId, + B = void 0 === j ? 0 : j, + x = e.parentMessageText, + q = void 0 === x ? "" : x, + z = e.threadInfo, + Q = void 0 === z ? null : z, + V = e.isReplyToChannel, + Y = void 0 !== V && V, + K = e.parentMessage, + W = void 0 === K ? null : K, + J = e.translations, + X = void 0 === J ? {} : J, + Z = e.sendingStatus, + $ = e.errorCode, + ee = void 0 === $ ? 0 : $, + ne = e.silent, + te = void 0 !== ne && ne, + ie = e.isGlobalBlocked, + re = void 0 !== ie && ie, + ae = e.messageSurvivalSeconds, + se = void 0 === ae ? -1 : ae, + oe = e.ogMetaData, + le = void 0 === oe ? null : oe, + ue = e.isOperatorMessage, + ce = void 0 !== ue && ue, + de = e.plugins, + he = void 0 === de ? [] : de, + pe = e.appleCriticalAlertOptions, + fe = e.poll, + ye = void 0 === fe ? null : fe, + ge = e.createdAt, + _e = e.updatedAt, + me = void 0 === _e ? 0 : _e, + ve = {}; + if ( + ((ve.req_id = _), + (ve.msg_id = y), + (ve.user = a.objectify({ + user: m, + role: + n.currentUser && n.currentUser.userId === m.userId + ? v.myRole + : m.role, + isBlockedByMe: m.isBlockedByMe, + })), + (ve.channel_url = v.url), + (ve.channel_type = + v.channelType === i.CHANNEL_TYPE_OPEN + ? i.CHANNEL_TYPE_OPEN + : i.CHANNEL_TYPE_GROUP), + (ve.message = E), + (ve.data = b), + (ve.custom_type = A), + (ve.translations = X), + (ve.is_global_block = !!re), + (ve.ts = ge), + (ve.updated_at = me), + (ve.mention_type = S), + (ve.mentioned_users = O.map(function (e) { + return s.objectify(e); + })), + (ve.mentioned_user_ids = R), + (ve.requested_mention_user_ids = M), + (ve.reactions = L.map(function (e) { + return e.serialize(); + })), + (ve.metaarray = {}), + H.forEach(function (e) { + var n = e.key; + ve.metaarray[n] = e.value; + }), + (ve.metaarray_key_order = H.map(function (e) { + return e.key; + })), + (ve.root_message_id = G), + (ve.parent_message_id = B), + (ve.parent_message_text = q), + Q && (ve.thread_info = c.objectify(Q)), + (ve.is_reply_to_channel = Y), + W) + ) + switch (W.messageType) { + case i.MESSAGE_TYPE_USER: + ve.parent_message_info = o.objectify(W); + break; + case i.MESSAGE_TYPE_FILE: + ve.parent_message_info = l.objectify(W); + break; + case i.MESSAGE_TYPE_ADMIN: + ve.parent_message_info = u.objectify(W); + } + return ( + (ve.sending_status = + y > 0 + ? n.MessageSendingStatus.SUCCEEDED + : n.MessageSendingStatus.FAILED), + Z && (ve.sending_status = Z), + (ve.silent = !!te), + (ve.error_code = ee), + (ve.message_survival_seconds = se), + le && (ve.og_tag = d.objectify(le)), + (ve.is_op_msg = !!ce), + (ve.plugins = he.map(function (e) { + return h.objectify(e); + })), + ye && (ve.poll = f.objectify(ye)), + pe && (ve.apple_critical_alert_options = p.objectify(pe)), + ve + ); + }, + }, + { + key: "build", + value: function ( + e, + n, + t, + i, + r, + a, + s, + o, + l, + u, + c, + d, + h, + p, + f, + y, + g, + _, + m, + v, + E, + C, + b, + U, + A, + I, + S, + k, + O + ) { + return this.objectify({ + messageId: n, + reqId: e, + user: t, + channel: i, + message: r, + data: a, + customType: s, + mentionType: p, + mentionedUsers: f, + mentionedUserIds: v, + requestedMentionUserIds: C, + reactions: h, + metaArrays: d, + rootMessageId: y, + parentMessageId: g, + parentMessageText: _, + threadInfo: m, + translations: o, + sendingStatus: E, + errorCode: b, + isGlobalBlocked: l, + messageSurvivalSeconds: U, + ogMetaData: A, + isOperatorMessage: I, + plugins: S, + appleCriticalAlertOptions: k, + poll: O, + createdAt: u, + updatedAt: c, + }); + }, + }, + { + key: "buildFromSerializedData", + value: function (e) { + var n = D.get(this._iid).UserMessage, + t = ye.deserialize(e); + return new n( + n.objectify( + l( + l({}, t), + {}, + { + channel: { + url: t.channelUrl, + channelType: t.channelType, + }, + user: t.sender, + } + ) + ) + ); + }, + }, + ] + ), + t + ); + })(ve), + Ye = (function (e) { + f(t, e); + var n = b(t); + function t(e) { + var i; + return ( + c(this, t), + ((i = n.call(this, e)).messageType = ve.MESSAGE_TYPE_FILE), + (i.plainUrl = null), + (i.name = "File"), + (i.size = 0), + (i.type = null), + (i.thumbnails = []), + (i._sender = null), + (i.reqId = ""), + (i.requireAuth = null), + (i.requestState = null), + (i.requestedMentionUserIds = []), + (i.errorCode = 0), + (i.messageSurvivalSeconds = -1), + e && i._update(e), + i + ); + } + return ( + h( + t, + [ + { + key: "_update", + value: function (e) { + var n = ft.getInstance(this._iid), + t = M.get(this._iid).container.auth, + i = D.get(this._iid).Sender; + if ( + ((this._sender = new i(e.user)), + (this.requireAuth = + !!e.hasOwnProperty("require_auth") && e.require_auth), + (this.plainUrl = String(e.url).split("?auth=")[0]), + Object.defineProperty(this, "url", { + value: this.requireAuth + ? "".concat(this.plainUrl, "?auth=").concat(t.eKey) + : this.plainUrl, + configurable: !0, + writable: !1, + }), + (this.name = e.hasOwnProperty("name") ? e.name : "File"), + (this.size = parseInt(e.size) || 0), + (this.type = String(e.type)), + e.hasOwnProperty("custom") && (this.data = String(e.custom)), + (this.reqId = e.hasOwnProperty("req_id") + ? String(e.req_id) + : ""), + (this.thumbnails = e.hasOwnProperty("thumbnails") + ? e.thumbnails + : []), + this.requireAuth) + ) + for (var r = 0; r < this.thumbnails.length; r++) + (this.thumbnails[r].plainUrl = String( + this.thumbnails[r].url + ).split("?auth=")[0]), + (this.thumbnails[r].url = this.requireAuth + ? "" + .concat(this.thumbnails[r].plainUrl, "?auth=") + .concat(t.eKey) + : this.thumbnails[r].plainUrl); + (this.requestState = + this.messageId > 0 + ? n.MessageRequestState.SUCCEEDED + : n.MessageRequestState.FAILED), + e.hasOwnProperty("sending_status") && + ((this.requestState = e.sending_status), + this.requestState === n.MessageSendingStatus.CANCELED && + (this.requestState = n.MessageRequestState.FAILED)), + (this.requestedMentionUserIds = []), + e.hasOwnProperty("requested_mention_user_ids") && + (this.requestedMentionUserIds = + e.requested_mention_user_ids), + (this.errorCode = 0), + e.hasOwnProperty("error_code") && + (this.errorCode = e.error_code), + (this.messageSurvivalSeconds = -1), + e.hasOwnProperty("message_survival_seconds") && + (this.messageSurvivalSeconds = e.message_survival_seconds); + }, + }, + { + key: "sender", + get: function () { + var e = ft.getInstance(this._iid), + n = D.get(this._iid).GroupChannel; + if ( + e.Options.useMemberAsMessageSender && + this.isGroupChannel() + ) { + var t = n.cachedChannels[this.channelUrl]; + if (t) { + var i = t.memberMap[this._sender.userId]; + i && + (this._sender.nickname !== i.nickname && + (this._sender.nickname = i.nickname), + this._sender.plainProfileUrl !== i.plainProfileUrl && + (this._sender.plainProfileUrl = i.plainProfileUrl), + X.deepEqual(this._sender.metaData, i.metaData) || + (this._sender.metaData = i.metaData)); + } + } + return this._sender; + }, + set: function (e) { + this._sender = e; + }, + }, + { + key: "isResendable", + value: function () { + var e = ft.getInstance(this._iid); + return ( + this.sendingStatus === e.MessageSendingStatus.FAILED && + X.isResendableError(this.errorCode) + ); + }, + }, + ], + [ + { + key: "objectify", + value: function (e) { + var n = ft.getInstance(this._iid), + i = D.get(this._iid), + r = i.BaseChannel, + a = i.BaseMessageParams, + s = i.Sender, + o = i.User, + l = i.ThreadInfo, + u = i.OGMetaData, + c = i.AppleCriticalAlertOptions, + d = e.messageId, + h = e.reqId, + p = void 0 === h ? "" : h, + f = e.user, + y = void 0 === f ? {} : f, + g = e.channel, + _ = e.plainUrl, + m = e.name, + v = e.type, + E = e.size, + C = void 0 === E ? 0 : E, + b = e.data, + U = void 0 === b ? "" : b, + A = e.customType, + I = void 0 === A ? "" : A, + S = e.mentionType, + k = void 0 === S ? a.MentionType.USERS : S, + O = e.mentionedUsers, + N = void 0 === O ? [] : O, + R = e.mentionedUserIds, + T = void 0 === R ? [] : R, + M = e.requestedMentionUserIds, + P = void 0 === M ? [] : M, + L = e.reactions, + w = void 0 === L ? [] : L, + H = e.metaArrays, + F = void 0 === H ? [] : H, + G = e.rootMessageId, + j = void 0 === G ? 0 : G, + B = e.parentMessageId, + x = void 0 === B ? 0 : B, + q = e.parentMessageText, + z = void 0 === q ? "" : q, + Q = e.threadInfo, + V = void 0 === Q ? null : Q, + Y = e.isReplyToChannel, + K = void 0 !== Y && Y, + W = e.parentMessage, + J = void 0 === W ? null : W, + X = e.thumbnails, + Z = void 0 === X ? [] : X, + $ = e.requireAuth, + ee = void 0 !== $ && $, + ne = e.sendingStatus, + te = e.errorCode, + ie = void 0 === te ? 0 : te, + re = e.silent, + ae = void 0 !== re && re, + se = e.isGlobalBlocked, + oe = void 0 !== se && se, + le = e.messageSurvivalSeconds, + ue = void 0 === le ? -1 : le, + ce = e.ogMetaData, + de = void 0 === ce ? null : ce, + he = e.isOperatorMessage, + pe = void 0 !== he && he, + fe = e.appleCriticalAlertOptions, + ye = e.createdAt, + ge = e.updatedAt, + _e = void 0 === ge ? 0 : ge, + me = {}; + (me.req_id = p), + (me.msg_id = d), + (me.user = s.objectify({ + user: y, + role: + n.currentUser && n.currentUser.userId === y.userId + ? g.myRole + : y.role, + isBlockedByMe: y.isBlockedByMe, + })), + (me.channel_url = g.url), + (me.channel_type = + g.channelType === r.CHANNEL_TYPE_OPEN + ? r.CHANNEL_TYPE_OPEN + : r.CHANNEL_TYPE_GROUP), + (me.url = _), + (me.name = m), + (me.type = v), + (me.size = C), + (me.custom = U), + (me.custom_type = I), + (me.thumbnails = Z), + (me.require_auth = ee), + (me.is_global_block = !!oe), + (me.ts = ye), + (me.updated_at = _e), + (me.mention_type = k), + (me.mentioned_users = N.map(function (e) { + return o.objectify(e); + })), + (me.mentioned_user_ids = T), + (me.requested_mention_user_ids = P), + (me.reactions = w.map(function (e) { + return e.serialize(); + })), + (me.metaarray = {}); + for (var ve = 0; ve < F.length; ve++) { + var Ee = F[ve].key; + me.metaarray[Ee] = F[ve].value; + } + if ( + ((me.metaarray_key_order = F.map(function (e) { + return e.key; + })), + (me.root_message_id = j), + (me.parent_message_id = x), + (me.parent_message_text = z), + V && (me.thread_info = l.objectify(V)), + (me.is_reply_to_channel = K), + J) + ) + switch (J.messageType) { + case r.MESSAGE_TYPE_USER: + me.parent_message_info = UserMessage.objectify(J); + break; + case r.MESSAGE_TYPE_FILE: + me.parent_message_info = t.objectify(J); + break; + case r.MESSAGE_TYPE_ADMIN: + me.parent_message_info = AdminMessage.objectify(J); + } + return ( + (me.sending_status = + d > 0 + ? n.MessageSendingStatus.SUCCEEDED + : n.MessageSendingStatus.FAILED), + ne && (me.sending_status = ne), + (me.silent = !!ae), + (me.error_code = ie), + (me.message_survival_seconds = ue), + de && (me.og_tag = u.objectify(de)), + (me.is_op_msg = !!pe), + fe && (me.apple_critical_alert_options = c.objectify(fe)), + me + ); + }, + }, + { + key: "build", + value: function ( + e, + n, + t, + i, + r, + a, + s, + o, + l, + u, + c, + d, + h, + p, + f, + y, + g, + _, + m, + v, + E, + C, + b, + U, + A, + I, + S, + k, + O, + N, + R + ) { + return this.objectify({ + messageId: n, + reqId: e, + user: t, + channel: i, + plainUrl: r, + name: a, + type: s, + size: o, + data: l, + customType: u, + mentionType: _, + mentionedUsers: m, + mentionedUserIds: U, + requestedMentionUserIds: I, + reactions: g, + metaArrays: y, + rootMessageId: v, + parentMessageId: E, + parentMessageText: C, + threadInfo: b, + thumbnails: h, + requireAuth: p, + sendingStatus: A, + errorCode: S, + isGlobalBlocked: c, + messageSurvivalSeconds: k, + ogMetaData: O, + isOperatorMessage: N, + appleCriticalAlertOptions: R, + createdAt: d, + updatedAt: f, + }); + }, + }, + { + key: "buildFromSerializedData", + value: function (e) { + var n = D.get(this._iid).FileMessage, + t = ye.deserialize(e); + return new n( + n.objectify( + l( + l({}, t), + {}, + { + channel: { + url: t.channelUrl, + channelType: t.channelType, + }, + user: t.sender, + } + ) + ) + ); + }, + }, + ] + ), + t + ); + })(ve), + Ke = (function (e) { + f(t, e); + var n = b(t); + function t(e) { + var i; + return ( + c(this, t), + ((i = n.call(this, e)).messageType = ve.MESSAGE_TYPE_ADMIN), + (i.message = ""), + (i.translations = {}), + e && i._update(e), + i + ); + } + return ( + h( + t, + [ + { + key: "_update", + value: function (e) { + (this.message = String(e.message)), + (this.translations = e.hasOwnProperty("translations") + ? e.translations + : {}); + }, + }, + ], + [ + { + key: "objectify", + value: function (e) { + var n = D.get(this._iid), + t = n.BaseChannel, + i = n.BaseMessageParams, + r = n.UserMessage, + a = n.FileMessage, + s = n.AdminMessage, + o = n.User, + l = n.ThreadInfo, + u = n.OGMetaData, + c = e.messageId, + d = e.channel, + h = e.message, + p = e.data, + f = void 0 === p ? "" : p, + y = e.customType, + g = void 0 === y ? "" : y, + _ = e.mentionType, + m = void 0 === _ ? i.MentionType.USERS : _, + v = e.mentionedUsers, + E = void 0 === v ? [] : v, + C = e.reactions, + b = void 0 === C ? [] : C, + U = e.metaArrays, + A = void 0 === U ? [] : U, + I = e.rootMessageId, + S = void 0 === I ? 0 : I, + k = e.parentMessageId, + O = void 0 === k ? 0 : k, + N = e.parentMessageText, + R = void 0 === N ? "" : N, + T = e.threadInfo, + M = void 0 === T ? null : T, + P = e.isReplyToChannel, + L = void 0 !== P && P, + w = e.parentMessage, + H = void 0 === w ? null : w, + F = e.translations, + G = void 0 === F ? {} : F, + j = e.silent, + B = void 0 !== j && j, + x = e.ogMetaData, + q = void 0 === x ? null : x, + z = e.createdAt, + Q = e.updatedAt, + V = void 0 === Q ? 0 : Q, + Y = { + msg_id: c, + channel_url: d.url, + channel_type: + d.channelType === t.CHANNEL_TYPE_OPEN + ? t.CHANNEL_TYPE_OPEN + : t.CHANNEL_TYPE_GROUP, + message: h, + data: f, + custom_type: g, + silent: B, + ts: z, + updated_at: V, + }; + (Y.translations = G), + (Y.mention_type = m), + (Y.mentioned_users = E.map(function (e) { + return o.objectify(e); + })), + (Y.reactions = b.map(function (e) { + return e.serialize(); + })), + (Y.metaarray = {}); + for (var K = 0; K < A.length; K++) { + var W = A[K].key; + Y.metaarray[W] = A[K].value; + } + if ( + ((Y.metaarray_key_order = A.map(function (e) { + return e.key; + })), + (Y.root_message_id = S), + (Y.parent_message_id = O), + (Y.parent_message_text = R), + M && (Y.thread_info = l.objectify(M)), + (Y.is_reply_to_channel = L), + H) + ) + switch (H.messageType) { + case t.MESSAGE_TYPE_USER: + Y.parent_message_info = r.objectify(H); + break; + case t.MESSAGE_TYPE_FILE: + Y.parent_message_info = a.objectify(H); + break; + case t.MESSAGE_TYPE_ADMIN: + Y.parent_message_info = s.objectify(H); + } + return q && (Y.og_tag = u.objectify(q)), Y; + }, + }, + { + key: "build", + value: function ( + e, + n, + t, + i, + r, + a, + s, + o, + l, + u, + c, + d, + h, + p, + f, + y, + g + ) { + return this.objectify({ + messageId: e, + channel: n, + message: t, + data: i, + customType: r, + mentionType: c, + mentionedUsers: d, + reactions: u, + metaArrays: l, + rootMessageId: h, + parentMessageId: p, + parentMessageText: f, + threadInfo: y, + translations: a, + ogMetaData: g, + createdAt: s, + updatedAt: o, + }); + }, + }, + { + key: "buildFromSerializedData", + value: function (e) { + var n = D.get(this._iid).AdminMessage, + t = ye.deserialize(e); + return new n( + n.objectify( + l( + l({}, t), + {}, + { + channel: { + url: t.channelUrl, + channelType: t.channelType, + }, + } + ) + ) + ); + }, + }, + ] + ), + t + ); + })(ve), + We = (function () { + function e(n) { + c(this, e); + var t = D.get(this._iid), + i = t.BaseMessage, + r = t.BaseMessageParams; + (this.scheduledId = 0), + (this.scheduledDateTimeString = ""), + (this.scheduledTimezone = ""), + (this.status = e.Status.SCHEDULED), + (this.createdAt = 0), + (this.updatedAt = 0), + (this._messageType = i.MESSAGE_TYPE_BASE), + (this._sender = null), + (this._channelType = ""), + (this.channelUrl = ""), + (this.message = ""), + (this.customType = ""), + (this.data = ""), + (this.metaArrays = []), + (this.mentionType = r.MentionType.USERS), + (this.mentionedUsers = []), + (this.pushNotificationDeliveryOption = + r.PushNotificationDeliveryOption.DEFAULT), + (this.translationTargetLanguages = []), + (this.errorMessage = ""), + (this.errorCode = 0), + (this.appleCriticalAlertOptions = null), + n && this._update(n); + } + return ( + h( + e, + [ + { + key: "sender", + get: function () { + var e = ft.getInstance(this._iid), + n = D.get(this._iid).GroupChannel; + if ( + e.Options.useMemberAsMessageSender && + this.isGroupChannel() + ) { + var t = n.cachedChannels[this.channelUrl]; + if (t) { + var i = t.memberMap[this._sender.userId]; + i && + (this._sender.nickname !== i.nickname && + (this._sender.nickname = i.nickname), + this._sender.plainProfileUrl !== i.plainProfileUrl && + (this._sender.plainProfileUrl = i.plainProfileUrl), + X.deepEqual(this._sender.metaData, i.metaData) || + (this._sender.metaData = i.metaData)); + } + } + return this._sender; + }, + set: function (e) { + this._sender = e; + }, + }, + { + key: "_update", + value: function (n) { + var t = this, + i = D.get(this._iid), + r = i.User, + a = i.Sender, + s = i.BaseMessageParams, + o = i.MessageMetaArray, + l = i.AppleCriticalAlertOptions; + (this.scheduledId = n.hasOwnProperty("scheduled_id") + ? parseInt(n.scheduled_id) + : 0), + (this.scheduledDateTimeString = n.hasOwnProperty( + "scheduled_dt" + ) + ? String(n.scheduled_dt) + : ""), + (this.scheduledTimezone = n.hasOwnProperty( + "scheduled_timezone" + ) + ? String(n.scheduled_timezone) + : ""), + (this.status = n.hasOwnProperty("status") + ? String(n.status) + : ""), + (this.createdAt = n.hasOwnProperty("created_at") + ? parseInt(n.created_at) + : 0), + (this.updatedAt = n.hasOwnProperty("updated_at") + ? parseInt(n.updated_at) + : 0), + (this.channelUrl = n.hasOwnProperty("channel_url") + ? String(n.channel_url) + : ""), + (this._channelType = n.hasOwnProperty("channel_type") + ? String(n.channel_type) + : ""), + (this._messageType = n.hasOwnProperty("type") + ? String(n.type) + : ""), + (this._sender = n.hasOwnProperty("user") + ? new a(n.user) + : null), + (this.message = n.hasOwnProperty("message") + ? String(n.message) + : ""), + (this.customType = n.hasOwnProperty("custom_type") + ? String(n.custom_type) + : ""), + (this.data = n.hasOwnProperty("data") ? String(n.data) : ""); + var u = n.hasOwnProperty("metaarray") ? n.metaarray : {}, + c = n.hasOwnProperty("metaarray_key_order") + ? n.metaarray_key_order + : Object.keys(u).sort(function (e, n) { + return e.localeCompare(n); + }); + this.metaArrays = []; + for (var d = 0; d < c.length; d++) { + var h = c[d]; + this.metaArrays.push(new o(h, u[h] || [])); + } + ((this.mentionType = n.hasOwnProperty("mention_type") + ? n.mention_type + : s.MentionType.USERS), + (this.mentionedUsers = []), + n.hasOwnProperty("mentioned_users")) && + n.mentioned_users.forEach(function (e) { + var n = new r(e); + t.mentionedUsers.push(n); + }); + (this.pushNotificationDeliveryOption = n.hasOwnProperty( + "push_option" + ) + ? n.push_option + : s.PushNotificationDeliveryOption.DEFAULT), + (this.translationTargetLanguages = n.hasOwnProperty( + "translation_target_langs" + ) + ? n.translation_target_langs + : []), + this.status === e.Status.FAILED && + (n.hasOwnProperty("error") && + n.error.hasOwnProperty("message") && + (this.errorMessage = String(n.error.message)), + n.hasOwnProperty("error") && + n.error.hasOwnProperty("code") && + (this.errorCode = parseInt(n.error.code))), + n.hasOwnProperty("apple_critical_alert_options") && + (this.appleCriticalAlertOptions = new l( + n.apple_critical_alert_options + )); + }, + }, + { + key: "isOpenChannel", + value: function () { + var e = D.get(this._iid).BaseChannel; + return this._channelType === e.CHANNEL_TYPE_OPEN; + }, + }, + { + key: "isGroupChannel", + value: function () { + var e = D.get(this._iid).BaseChannel; + return this._channelType === e.CHANNEL_TYPE_GROUP; + }, + }, + { + key: "metaArray", + get: function () { + var e = {}; + return ( + this.metaArrays.forEach(function (n) { + e[n.key] = n.value; + }), + e + ); + }, + set: function (e) { + if ("object" === u(e) && e) { + var n = D.get(this._iid).MessageMetaArray, + t = []; + Object.keys(e).forEach(function (i) { + t.push(new n(i, e[i])); + }), + (this.metaArrays = t); + } + }, + }, + ], + [ + { + key: "Status", + get: function () { + return { + SCHEDULED: "scheduled", + SENT: "sent", + CANCELED: "canceled", + FAILED: "failed", + }; + }, + }, + ] + ), + e + ); + })(), + Je = (function () { + function e() { + c(this, e), + (this.threadInfo = null), + (this.targetMessageId = 0), + (this.channelUrl = null), + (this.channelType = null); + } + return ( + h(e, null, [ + { + key: "createFromJson", + value: function (e) { + var n = D.get(this._iid), + t = n.BaseChannel, + i = n.ThreadInfo, + r = e.thread_info, + a = e.root_message_id, + s = e.channel_url, + o = e.channel_type; + if ( + r && + "object" === u(r) && + ("string" == typeof a || "number" == typeof a) && + "string" == typeof s && + "string" == typeof o && + [t.CHANNEL_TYPE_GROUP].includes(o) + ) { + var l = new this(); + return ( + (l.threadInfo = new i(r)), + (l.targetMessageId = parseInt(a)), + (l.channelUrl = s), + (l.channelType = o), + l + ); + } + return null; + }, + }, + ]), + e + ); + })(), + Xe = (function () { + function e() { + c(this, e), (this.poll = null), (this.status = null); + } + return ( + h(e, null, [ + { + key: "createFromJson", + value: function (e) { + var n = D.get(this._iid).Poll, + t = e.poll; + if ("object" === u(t)) { + var i = new this(); + return (i.poll = new n(t)), (i.status = t.status), i; + } + return null; + }, + }, + ]), + e + ); + })(), + Ze = (function () { + function e() { + c(this, e), + (this.pollId = null), + (this.updatedVoteCounts = null), + (this.votedAt = null); + } + return ( + h(e, null, [ + { + key: "createFromJson", + value: function (e) { + var n = e.poll_id, + t = e.updated_vote_counts, + i = e.ts; + if ( + "number" == typeof n && + Array.isArray(e.updated_vote_counts) && + "number" == typeof i + ) { + var r = new this(); + return ( + (r.pollId = n), + (r.updatedVoteCounts = t.map(function (e) { + return { optionId: e.option_id, voteCount: e.vote_count }; + })), + (r.votedAt = i), + r + ); + } + return null; + }, + }, + ]), + e + ); + })(), + $e = (function () { + function e() { + c(this, e), + (this.isLoading = !1), + (this.hasNext = !0), + (this.limit = 20), + (this.userIdsFilter = []), + (this.metaDataKeyFilter = ""), + (this.metaDataValuesFilter = []), + (this.nicknameStartsWithFilter = null), + (this._token = ""); + } + return ( + h(e, [ + { + key: "next", + value: function (e) { + var n = this; + return ge( + this._iid, + function (e) { + "number" == typeof n.limit && + n.limit > 0 && + Array.isArray(n.userIdsFilter) && + "string" == typeof n.metaDataKeyFilter && + Array.isArray(n.metaDataValuesFilter) && + !!n.metaDataKeyFilter == n.metaDataValuesFilter.length > 0 && + ("string" == typeof n.nicknameStartsWithFilter || + null === n.nicknameStartsWithFilter) + ? n.isLoading + ? e( + new P("Query in progress.", P.QUERY_IN_PROGRESS), + null + ) + : n.hasNext + ? ((n.isLoading = !0), + M.get(n._iid).container.apiClient.loadUserList( + l(l({}, n), {}, { token: n._token }), + function (t, i) { + var r = null; + if (!t) { + var a = D.get(n._iid).User, + s = String(i.next); + (n._token = s), + (n.hasNext = !!s), + (r = i.users.map(function (e) { + return new a(e); + })); + } + (n.isLoading = !1), e(t, r); + } + )) + : e(null, []) + : e(ie.error, null); + }, + e + ); + }, + }, + ]), + e + ); + })(), + en = (function () { + function e(n) { + c(this, e), + (this.isLoading = !1), + (this.hasNext = !0), + (this.limit = 20), + (this._isOpenChannel = !1), + (this._channelUrl = null), + (this._token = ""), + n.channelUrl && (this._channelUrl = n.channelUrl), + n.isOpenChannel && (this._isOpenChannel = n.isOpenChannel); + } + return ( + h(e, [ + { + key: "next", + value: function (e) { + var n = this; + return ge( + this._iid, + function (e) { + "number" == typeof n.limit && n.limit > 0 + ? n.isLoading + ? e( + new P("Query in progress.", P.QUERY_IN_PROGRESS), + null + ) + : n.hasNext + ? ((n.isLoading = !0), + M.get(n._iid).container.apiClient.loadBannedUserList( + l( + l({}, n), + {}, + { + channelUrl: n._channelUrl, + isOpenChannel: n._isOpenChannel, + token: n._token, + } + ), + function (t, i) { + var r = null; + if (!t) { + var a = D.get(n._iid).User, + s = String(i.next); + (n._token = s), + (n.hasNext = !!s), + (r = i.banned_list.map(function (e) { + return new a(e.user); + })); + } + (n.isLoading = !1), e(t, r); + } + )) + : e(null, []) + : e(ie.error, null); + }, + e + ); + }, + }, + ]), + e + ); + })(), + nn = (function () { + function e() { + c(this, e), + (this.isLoading = !1), + (this.hasNext = !0), + (this.limit = 20), + (this.userIdsFilter = []), + (this._token = ""); + } + return ( + h(e, [ + { + key: "next", + value: function (e) { + var n = this; + return ge( + this._iid, + function (e) { + "number" == typeof n.limit && + n.limit > 0 && + Array.isArray(n.userIdsFilter) + ? n.isLoading + ? e( + new P("Query in progress.", P.QUERY_IN_PROGRESS), + null + ) + : n.hasNext + ? ((n.isLoading = !0), + M.get(n._iid).container.apiClient.loadBlockedUserList( + l(l({}, n), {}, { token: n._token }), + function (t, i) { + var r = null; + if (!t) { + var a = D.get(n._iid).User, + s = String(i.next); + (n._token = s), + (n.hasNext = !!s), + (r = i.users.map(function (e) { + return new a(e); + })); + } + (n.isLoading = !1), e(t, r); + } + )) + : e(null, []) + : e(ie.error, null); + }, + e + ); + }, + }, + ]), + e + ); + })(), + tn = (function () { + function e() { + c(this, e), + (this.isLoading = !1), + (this.hasMore = !0), + (this.limit = 20), + (this._token = ""); + } + return ( + h(e, [ + { + key: "next", + value: function (e) { + var n = this; + return ge( + this._iid, + function (e) { + "number" == typeof n.limit && n.limit > 0 + ? n.isLoading + ? e( + new P("Query in progress.", P.QUERY_IN_PROGRESS), + null + ) + : n.hasMore + ? ((n.isLoading = !0), + M.get(n._iid).container.apiClient.loadFriendList( + l(l({}, n), {}, { token: n._token }), + function (t, i) { + var r = null; + if (!t) { + var a = D.get(n._iid).User, + s = String(i.next); + (n._token = s), + (n.hasMore = !!s), + (r = i.users.map(function (e) { + return new a(e); + })); + } + (n.isLoading = !1), e(t, r); + } + )) + : e(null, []) + : e(ie.error, null); + }, + e + ); + }, + }, + ]), + e + ); + })(), + rn = (function () { + function e() { + c(this, e), + (this.isLoading = !1), + (this.hasNext = !0), + (this.limit = 20), + (this.includeEmpty = !1), + (this.order = e.ORDER_LATEST_LAST_MESSAGE), + (this._token = ""), + (this._searchFilter = {}), + (this._userIdsFilter = { + userIds: [], + includeMode: !0, + queryType: e.QueryType.AND, + }), + (this._userIdsExactFilter = []), + (this._userIdsIncludeFilter = []), + (this._userIdsIncludeFilterQueryType = e.QueryType.AND), + (this.nicknameContainsFilter = ""), + (this.channelNameContainsFilter = ""), + (this.memberStateFilter = De.MemberStateFilter.ALL), + (this.customTypesFilter = []), + (this.channelUrlsFilter = []), + (this.superChannelFilter = De.SuperChannelFilter.ALL), + (this.publicChannelFilter = De.PublicChannelFilter.ALL), + (this.customTypeStartsWithFilter = null), + (this.unreadChannelFilter = De.UnreadChannelFilter.ALL), + (this.metadataOrderKeyFilter = null), + (this.metadataKey = null), + (this.metadataValues = []), + (this.metadataValueStartsWith = null), + (this.hiddenChannelFilter = De.HiddenChannelFilter.UNHIDDEN), + (this.includeFrozen = !0), + (this.includeMetaData = !0); + } + return ( + h( + e, + [ + { + key: "userIdsExactFilter", + get: function () { + return this._userIdsExactFilter; + }, + set: function (e) { + Array.isArray(e) && + ((this._userIdsExactFilter = e), + (this._userIdsIncludeFilter = []), + (this._userIdsFilter.userIds = this._userIdsExactFilter), + (this._userIdsFilter.includeMode = !1)); + }, + }, + { + key: "userIdsIncludeFilter", + get: function () { + return this._userIdsIncludeFilter; + }, + set: function (e) { + Array.isArray(e) && + ((this._userIdsIncludeFilter = e), + (this._userIdsExactFilter = []), + (this._userIdsFilter.userIds = this._userIdsIncludeFilter), + (this._userIdsFilter.includeMode = !0)); + }, + }, + { + key: "userIdsIncludeFilterQueryType", + get: function () { + return this._userIdsIncludeFilterQueryType; + }, + set: function (n) { + Object.keys(e.QueryType) + .map(function (n) { + return e.QueryType[n]; + }) + .indexOf(n) > -1 && + ((this._userIdsIncludeFilterQueryType = n.toUpperCase()), + (this._userIdsFilter.queryType = this._userIdsIncludeFilterQueryType)); + }, + }, + { + key: "setSearchFilter", + value: function (e, n) { + Array.isArray(e) && + 0 !== e.length && + "string" == typeof n && + n && + (this._searchFilter = { + search_query: n, + search_fields: e.join(",").toLocaleLowerCase(), + }); + }, + }, + { + key: "serialize", + value: function () { + return ye.serialize(this, function (e) { + e.isLoading = !1; + }); + }, + }, + { + key: "next", + value: function (e) { + var n = this; + return ge( + this._iid, + function (e) { + var t = D.get(n._iid), + i = t.GroupChannel, + r = t.GroupChannelListQuery; + !( + "number" == typeof n.limit && + n.limit > 0 && + "boolean" == typeof n.includeEmpty && + "string" == typeof n.order && + [ + r.ORDER_CHRONOLOGICAL, + r.ORDER_LATEST_LAST_MESSAGE, + r.CHANNEL_NAME_ALPHABETICAL, + r.METADATA_VALUE_ALPHABETICAL, + ].indexOf(n.order.toLowerCase()) > -1 && + Array.isArray(n._userIdsExactFilter) && + Array.isArray(n._userIdsIncludeFilter) && + Array.isArray(n.customTypesFilter) && + Array.isArray(n.channelUrlsFilter) && + Object.keys(r.QueryType) + .map(function (e) { + return r.QueryType[e]; + }) + .indexOf( + n._userIdsIncludeFilterQueryType.toUpperCase() + ) > -1 && + Object.keys(i.MemberStateFilter) + .map(function (e) { + return i.MemberStateFilter[e]; + }) + .indexOf(n.memberStateFilter) > -1 && + Object.keys(i.SuperChannelFilter) + .map(function (e) { + return i.SuperChannelFilter[e]; + }) + .indexOf(n.superChannelFilter) > -1 && + Object.keys(i.PublicChannelFilter) + .map(function (e) { + return i.PublicChannelFilter[e]; + }) + .indexOf(n.publicChannelFilter) > -1 && + Object.keys(i.UnreadChannelFilter) + .map(function (e) { + return i.UnreadChannelFilter[e]; + }) + .indexOf(n.unreadChannelFilter) > -1 && + Object.keys(i.HiddenChannelFilter) + .map(function (e) { + return i.HiddenChannelFilter[e]; + }) + .indexOf(n.hiddenChannelFilter) > -1 + ) || + ("string" != typeof n.customTypeStartsWithFilter && + null !== n.customTypeStartsWithFilter) || + "string" != typeof n.nicknameContainsFilter || + "string" != typeof n.channelNameContainsFilter || + ("string" != typeof n.metadataOrderKeyFilter && + null !== n.metadataOrderKeyFilter) || + ("string" != typeof n.metadataKey && + null !== n.metadataKey) || + !Array.isArray(n.metadataValues) || + !n.metadataValues.every(function (e) { + return "string" == typeof e; + }) || + ("string" != typeof n.metadataValueStartsWith && + null !== n.metadataValueStartsWith) || + "boolean" != typeof n.includeFrozen || + "boolean" != typeof n.includeMetaData + ? e(ie.error, null) + : n.isLoading + ? e( + new P("Query in progress.", P.QUERY_IN_PROGRESS), + null + ) + : n.hasNext + ? ((n.isLoading = !0), + M.get(n._iid).container.apiClient.loadGroupChannelList( + l( + l({}, n), + {}, + { + token: n._token, + userIdsFilter: n._userIdsFilter, + searchFilter: n._searchFilter, + } + ), + function (t, i) { + var r = null; + if (!t) { + var a = D.get(n._iid).GroupChannel, + s = String(i.next); + (n._token = s), (n.hasNext = !!s); + var o = i.channels; + o && Array.isArray(o) + ? (r = o.map(function (e) { + return ( + "number" == typeof i.ts && (e.ts = i.ts), + a.upsert(e) + ); + })) + : (t = new P( + "Failed at loading group channels.", + P.MALFORMED_DATA + )); + } + (n.isLoading = !1), e(t, r); + } + )) + : e(null, []); + }, + e + ); + }, + }, + ], + [ + { + key: "ORDER_LATEST_LAST_MESSAGE", + get: function () { + return "latest_last_message"; + }, + }, + { + key: "ORDER_CHRONOLOGICAL", + get: function () { + return "chronological"; + }, + }, + { + key: "CHANNEL_NAME_ALPHABETICAL", + get: function () { + return "channel_name_alphabetical"; + }, + }, + { + key: "METADATA_VALUE_ALPHABETICAL", + get: function () { + return "metadata_value_alphabetical"; + }, + }, + { + key: "QueryType", + get: function () { + return { AND: "AND", OR: "OR" }; + }, + }, + { + key: "SearchField", + get: function () { + return { + MEMBER_NICKNAME: "member_nickname", + CHANNEL_NAME: "channel_name", + }; + }, + }, + { + key: "buildFromSerializedData", + value: function (e) { + var n = D.get(this._iid).GroupChannel, + t = ye.deserialize(e), + i = n.createMyGroupChannelListQuery(); + return ( + Object.keys(t).forEach(function (e) { + i.hasOwnProperty(e) && (i[e] = t[e]); + }), + i + ); + }, + }, + ] + ), + e + ); + })(), + an = (function () { + function e(n) { + c(this, e), + (this.isLoading = !1), + (this.hasNext = !0), + (this.limit = 20), + (this.mutedMemberFilter = e.MutedMemberFilter.ALL), + (this.memberStateFilter = De.MemberStateFilter.ALL), + (this.nicknameStartsWithFilter = null), + (this.order = e.Order.MEMBER_NICKNAME_ALPHABETICAL), + (this._token = ""), + (this._channelUrl = n); + } + return ( + h( + e, + [ + { + key: "next", + value: function (e) { + var n = this; + return ge( + this._iid, + function (e) { + var t = D.get(n._iid), + i = t.GroupChannel, + r = t.Member, + a = t.MemberListQuery; + "number" == typeof n.limit && + n.limit > 0 && + Object.keys(a.MutedMemberFilter) + .map(function (e) { + return a.MutedMemberFilter[e]; + }) + .indexOf(n.mutedMemberFilter) > -1 && + Object.keys(i.MemberStateFilter) + .map(function (e) { + return i.MemberStateFilter[e]; + }) + .indexOf(n.memberStateFilter) > -1 && + Object.keys(a.Order) + .map(function (e) { + return a.Order[e]; + }) + .indexOf(n.order) > -1 && + ("string" == typeof n.nicknameStartsWithFilter || + null === n.nicknameStartsWithFilter) + ? n.isLoading + ? e( + new P("Query in progress.", P.QUERY_IN_PROGRESS), + null + ) + : n.hasNext + ? ((n.isLoading = !0), + M.get(n._iid).container.apiClient.loadMemberList( + l( + l({}, n), + {}, + { channelUrl: n._channelUrl, token: n._token } + ), + function (t, i) { + var a = null; + if (!t) { + var s = String(i.next); + (n._token = s), + (n.hasNext = !!s), + (a = i.members.map(function (e) { + return new r(e); + })); + } + (n.isLoading = !1), e(t, a); + } + )) + : e(null, []) + : e(ie.error, null); + }, + e + ); + }, + }, + ], + [ + { + key: "MutedMemberFilter", + get: function () { + return { ALL: "all", MUTED: "muted", UNMUTED: "unmuted" }; + }, + }, + { + key: "Order", + get: function () { + return { + MEMBER_NICKNAME_ALPHABETICAL: "member_nickname_alphabetical", + OPERATOR_THEN_MEMBER_ALPHABETICAL: + "operator_then_member_alphabetical", + }; + }, + }, + ] + ), + e + ); + })(), + sn = (function () { + function e(n) { + c(this, e), + (this.isLoading = !1), + (this.hasNext = !0), + (this.limit = 20), + (this._token = ""), + n.channelUrl && (this._channelUrl = n.channelUrl), + n.isOpenChannel && (this._isOpenChannel = n.isOpenChannel); + } + return ( + h(e, [ + { + key: "next", + value: function (e) { + var n = this; + return ge( + this._iid, + function (e) { + "number" == typeof n.limit && n.limit > 0 + ? n.isLoading + ? e( + new P("Query in progress.", P.QUERY_IN_PROGRESS), + null + ) + : n.hasNext + ? ((n.isLoading = !0), + M.get(n._iid).container.apiClient.loadMutedUserList( + l( + l({}, n), + {}, + { + channelUrl: n._channelUrl, + isOpenChannel: n._isOpenChannel, + token: n._token, + } + ), + function (t, i) { + var r = null; + if (!t) { + var a = D.get(n._iid).User, + s = String(i.next); + (n._token = s), + (n.hasNext = !!s), + (r = i.muted_list.map(function (e) { + return new a(e); + })); + } + (n.isLoading = !1), e(t, r); + } + )) + : e(null, []) + : e(ie.error, null); + }, + e + ); + }, + }, + ]), + e + ); + })(), + on = (function () { + function e() { + c(this, e), + (this.limit = 20), + (this.isLoading = !1), + (this.hasNext = !0), + (this.nameKeyword = null), + (this.urlKeyword = null), + (this.customTypes = []), + (this.includeFrozen = !0), + (this.includeMetaData = !0); + } + return ( + h(e, [ + { + key: "next", + value: function (e) { + var n = this; + return ge( + this._iid, + function (e) { + !( + "number" == typeof n.limit && + n.limit > 0 && + Array.isArray(n.customTypes) + ) || + ("string" != typeof n.nameKeyword && + null !== n.nameKeyword) || + ("string" != typeof n.urlKeyword && null !== n.urlKeyword) || + "boolean" != typeof n.includeFrozen || + "boolean" != typeof n.includeMetaData + ? e(ie.error, null) + : n.isLoading + ? e(new P("Query in progress.", P.QUERY_IN_PROGRESS), null) + : n.hasNext + ? ((n.isLoading = !0), + M.get(n._iid).container.apiClient.loadOpenChannelList( + l(l({}, n), {}, { token: n._token }), + function (t, i) { + var r = null; + if (!t) { + var a = D.get(n._iid).OpenChannel, + s = String(i.next); + (n._token = s), (n.hasNext = !!s); + var o = i.channels; + o && Array.isArray(o) + ? (r = o.map(function (e) { + return ( + "number" == typeof i.ts && (e.ts = i.ts), + a.upsert(e) + ); + })) + : (t = new P( + "Failed at loading open channels.", + P.MALFORMED_DATA + )); + } + (n.isLoading = !1), e(t, r); + } + )) + : e(null, []); + }, + e + ); + }, + }, + ]), + e + ); + })(), + ln = new WeakMap(), + un = (function () { + function e(n) { + c(this, e), + (this.isLoading = !1), + (this.hasNext = !0), + (this.limit = 20), + (this._token = ""), + ln.set(this, n); + } + return ( + h(e, [ + { + key: "next", + value: function (e) { + var n = this; + return ge( + this._iid, + function (e) { + if ("number" == typeof n.limit && n.limit > 0) + if (n.isLoading) + e(new P("Query in progress.", P.QUERY_IN_PROGRESS), null); + else if (n.hasNext) { + n.isLoading = !0; + var t = ln.get(n); + M.get(n._iid).container.apiClient.loadOperatorList( + l( + l({}, n), + {}, + { + token: n._token, + channelUrl: t.url, + isOpenChannel: t.isOpenChannel(), + } + ), + function (t, i) { + var r = null; + if (!t) { + var a = D.get(n._iid).User, + s = String(i.next); + (n._token = s), + (n.hasNext = !!s), + (r = i.operators.map(function (e) { + return new a(e); + })); + } + (n.isLoading = !1), e(t, r); + } + ); + } else e(null, []); + else e(ie.error, null); + }, + e + ); + }, + }, + ]), + e + ); + })(), + cn = new WeakMap(), + dn = (function () { + function e(n) { + c(this, e), + (this.isLoading = !1), + (this.hasNext = !0), + (this.limit = 20), + (this._token = ""), + n && cn.set(this, n.channelUrl); + } + return ( + h(e, [ + { + key: "next", + value: function (e) { + var n = this; + return ge( + this._iid, + function (e) { + "number" == typeof n.limit && n.limit > 0 + ? n.isLoading + ? e( + new P("Query in progress.", P.QUERY_IN_PROGRESS), + null + ) + : n.hasNext + ? ((n.isLoading = !0), + M.get(n._iid).container.apiClient.loadParticipantList( + l( + l({}, n), + {}, + { channelUrl: cn.get(n), token: n._token } + ), + function (t, i) { + var r = null; + if (!t) { + var a = D.get(n._iid).User, + s = String(i.next); + (n._token = s), + (n.hasNext = !!s), + (r = i.participants.map(function (e) { + return new a(e); + })); + } + (n.isLoading = !1), e(t, r); + } + )) + : e(null, []) + : e(ie.error, null); + }, + e + ); + }, + }, + ]), + e + ); + })(), + hn = new WeakMap(), + pn = (function () { + function e(n, t) { + var i = t.limit, + r = void 0 === i ? 20 : i, + a = t.reverse, + s = void 0 !== a && a, + o = t.exactMatch, + l = void 0 !== o && o, + u = t.channelUrl, + d = void 0 === u ? "" : u, + h = t.channelCustomType, + p = void 0 === h ? "" : h, + f = t.messageTimestampFrom, + y = void 0 === f ? null : f, + g = t.messageTimestampTo, + _ = void 0 === g ? null : g, + m = t.order, + v = void 0 === m ? "score" : m, + E = t.advancedQuery, + C = void 0 !== E && E, + b = t.targetFields, + U = void 0 === b ? null : b; + c(this, e), + (this.isLoading = !1), + (this.hasNext = !0), + hn.set(this, { + keyword: n, + limit: r, + reverse: s, + exactMatch: l, + channelUrl: d, + channelCustomType: p, + messageTimestampFrom: y, + messageTimestampTo: _, + order: v, + advancedQuery: C, + targetFields: U, + previousToken: "", + nextToken: "", + }); + } + return ( + h(e, [ + { + key: "key", + get: function () { + return hn.get(this).keyword; + }, + }, + { + key: "limit", + get: function () { + return hn.get(this).limit; + }, + }, + { + key: "reverse", + get: function () { + return hn.get(this).reverse; + }, + }, + { + key: "exactMatch", + get: function () { + return hn.get(this).exactMatch; + }, + }, + { + key: "channelUrl", + get: function () { + return hn.get(this).channelUrl; + }, + }, + { + key: "channelCustomType", + get: function () { + return hn.get(this).channelCustomType; + }, + }, + { + key: "messageTimestampFrom", + get: function () { + return hn.get(this).messageTimestampFrom; + }, + }, + { + key: "messageTimestampTo", + get: function () { + return hn.get(this).messageTimestampTo; + }, + }, + { + key: "order", + get: function () { + return hn.get(this).order; + }, + }, + { + key: "next", + value: function (e) { + var n = this, + t = D.get(this._iid), + i = t.BaseChannel, + r = t.GroupChannel, + a = t.OpenChannel; + return ge( + this._iid, + function (e) { + var t = hn.get(n), + s = t.keyword, + o = t.limit, + l = t.reverse, + u = t.exactMatch, + c = t.channelUrl, + d = t.channelCustomType, + h = t.messageTimestampFrom, + p = t.messageTimestampTo, + f = t.order, + y = t.advancedQuery, + g = t.targetFields, + _ = t.nextToken; + !( + "number" == typeof o && + o > 0 && + o <= 1e3 && + "boolean" == typeof l && + "boolean" == typeof u + ) || + ("string" != typeof c && null !== c) || + ("string" != typeof d && null !== d) || + ("number" != typeof h && null !== h) || + ("number" != typeof p && null !== p) || + !(["score", "ts"].indexOf(f) >= 0) || + ("boolean" != typeof y && null !== y) || + (!Array.isArray(g) && null !== g) + ? e(ie.error, null) + : n.isLoading + ? e(new P("Query in progress.", P.QUERY_IN_PROGRESS), null) + : n.hasNext + ? ((n.isLoading = !0), + M.get(n._iid).container.apiClient.searchMessages( + { + keyword: s, + limit: o, + reverse: l, + exactMatch: u, + channelUrl: c, + channelCustomType: d, + messageTimestampFrom: h, + messageTimestampTo: p, + order: f, + advancedQuery: y, + targetFields: g, + nextToken: _, + }, + function (t, s) { + var o = null; + t || + ((o = []), + s.results.forEach(function (e) { + if (e.channel.hasOwnProperty("members")) { + var n = new r(e.channel); + (r.cachedChannels[n.url] = n), + o.push(i.buildMessage(e, n)); + } else { + var t = new a(e.channel); + (a.cachedChannels[t.url] = t), + o.push(i.buildMessage(e, t)); + } + }), + (n.hasNext = s.has_next), + (hn.get(n).nextToken = s.end_cursor)), + (n.isLoading = !1), + e(t, o); + } + )) + : e(null, []); + }, + e + ); + }, + }, + ]), + e + ); + })(), + fn = new WeakMap(), + yn = new WeakMap(), + gn = (function () { + function e(n) { + c(this, e), + (this.isLoading = !1), + (this.hasMore = !0), + (this.limit = 20), + yn.set(this, Number.MAX_SAFE_INTEGER), + fn.set(this, n), + (this.reverse = !1), + (this.messageTypeFilter = null), + (this.customTypeFilter = null), + (this.customTypesFilter = []), + (this.senderUserIdsFilter = []), + (this.includeMetaArray = !1), + (this.includeReaction = null), + (this.includeReactions = !1), + (this.includeReplies = null), + (this.includeParentMessageText = null), + (this.includeThreadInfo = !1), + (this.replyTypeFilter = null), + (this.includeParentMessageInfo = null), + (this.showSubchannelMessagesOnly = !1), + (this.includePollDetails = !1); + } + return ( + h(e, [ + { + key: "load", + value: function (e, n, t, i) { + var r = this, + a = D.get(this._iid), + s = a.BaseChannel, + o = a.BaseMessage, + l = null, + u = ie.parse(arguments, [ + new ie({ + type: "number", + optional: !0, + defaultValue: this.limit, + }), + new ie({ + type: "boolean", + optional: !0, + defaultValue: this.reverse, + }), + new ie({ + type: ["string", "number"], + optional: !0, + defaultValue: this.messageTypeFilter, + constraint: function (e) { + return ( + Object.keys(s.MessageTypeFilter) + .map(function (e) { + return s.MessageTypeFilter[e]; + }) + .indexOf(e) > -1 || [0, 1, 2, 3].indexOf(e) > -1 + ); + }, + }), + new ie({ type: "callback" }), + ]), + c = A(u, 5); + return ( + (l = c[0]), + (e = c[1]), + (n = c[2]), + (t = c[3]), + (i = c[4]), + ge( + this._iid, + function (i) { + if ( + ("boolean" == typeof r.includeReaction && + r.includeReaction && + (r.includeReactions = r.includeReaction), + null === r.replyTypeFilter && + (r.replyTypeFilter = + "boolean" == typeof r.includeReplies && + r.includeReplies + ? o.ReplyType.ALL + : o.ReplyType.NONE), + null === r.includeParentMessageInfo && + (r.includeParentMessageInfo = + "boolean" == typeof r.includeParentMessageText && + r.includeParentMessageText), + (Array.isArray(r.customTypesFilter) && + r.customTypesFilter.every(function (e) { + return "string" == typeof e || null === e; + }) && + Array.isArray(r.senderUserIdsFilter) && + r.senderUserIdsFilter.every(function (e) { + return "string" == typeof e; + }) && + "boolean" == typeof r.includeMetaArray && + "boolean" == typeof r.includeReactions && + "boolean" == typeof r.includeThreadInfo && + "string" == typeof r.replyTypeFilter && + Object.values(o.ReplyType).includes( + r.replyTypeFilter + ) && + "boolean" == typeof r.includeParentMessageInfo && + "boolean" == typeof r.showSubchannelMessagesOnly) || + (l = ie.error), + l) + ) + i(l, null); + else { + if ( + ((r.limit = e), + (r.reverse = n), + (r.messageTypeFilter = t), + "number" == typeof r.messageTypeFilter) + ) + switch (r.messageTypeFilter) { + case 0: + r.messageTypeFilter = s.MessageTypeFilter.ALL; + break; + case 1: + r.messageTypeFilter = s.MessageTypeFilter.USER; + break; + case 2: + r.messageTypeFilter = s.MessageTypeFilter.FILE; + break; + case 3: + r.messageTypeFilter = s.MessageTypeFilter.ADMIN; + } + if (r.isLoading) + i( + new P("Query in progress.", P.QUERY_IN_PROGRESS), + null + ); + else if (r.hasMore) { + r.isLoading = !0; + var a = fn.get(r); + M.get(r._iid).container.apiClient.getMessageList( + { + channel: a, + token: yn.get(r) || new Date().getTime() + 1e4, + tokenType: "timestamp", + isInclusive: !1, + prevResultSize: e, + nextResultSize: 0, + shouldReverse: n, + messageType: r.messageTypeFilter, + customType: r.customTypeFilter, + customTypes: r.customTypesFilter, + senderUserIds: r.senderUserIdsFilter, + includeMetaArray: r.includeMetaArray, + includeReactions: r.includeReactions, + includeThreadInfo: r.includeThreadInfo, + replyTypeFilter: r.replyTypeFilter, + includeParentMessageInfo: + r.includeParentMessageInfo, + showSubchannelMessagesOnly: + r.showSubchannelMessagesOnly, + includePollDetails: r.includePollDetails, + }, + function (n, t) { + var o = null; + if (!n) { + (0 === + (o = t.messages.map(function (e) { + return s.buildMessage(e, a); + })).length || + o.length < e) && + (r.hasMore = !1); + var l = yn.get(r); + yn.set( + r, + Math.min.apply( + Math, + I( + o.map(function (e) { + return e.createdAt; + }) + ).concat([l]) + ) + ); + } + (r.isLoading = !1), i(n, o); + } + ); + } else i(null, []); + } + }, + i + ) + ); + }, + }, + ]), + e + ); + })(), + _n = (function () { + function e() { + c(this, e), + (this.isLoading = !1), + (this.hasNext = !0), + (this.limit = 20), + (this.includeEmpty = !1), + (this.order = rn.ORDER_LATEST_LAST_MESSAGE), + (this._token = ""), + (this.channelNameContainsFilter = ""), + (this.channelUrlsFilter = []), + (this.customTypesFilter = []), + (this.customTypeStartsWithFilter = null), + (this.superChannelFilter = De.SuperChannelFilter.ALL), + (this.membershipFilter = e.MembershipType.JOINED), + (this.metadataOrderKeyFilter = null), + (this.metadataKey = null), + (this.metadataValues = []), + (this.metadataValueStartsWith = null), + (this.includeFrozen = !0), + (this.includeMetaData = !0); + } + return ( + h( + e, + [ + { + key: "next", + value: function (n) { + var t = this; + return ge( + this._iid, + function (n) { + var i = D.get(t._iid).GroupChannel; + !( + "number" == typeof t.limit && + t.limit > 0 && + "boolean" == typeof t.includeEmpty && + "string" == typeof t.order && + [ + e.ORDER_CHRONOLOGICAL, + e.CHANNEL_NAME_ALPHABETICAL, + e.METADATA_VALUE_ALPHABETICAL, + e.ORDER_LATEST_LAST_MESSAGE, + ].indexOf(t.order.toLowerCase()) > -1 && + Array.isArray(t.customTypesFilter) && + Array.isArray(t.channelUrlsFilter) && + Object.keys(e.MembershipType) + .map(function (n) { + return e.MembershipType[n]; + }) + .indexOf(t.membershipFilter) > -1 && + Object.keys(i.SuperChannelFilter) + .map(function (e) { + return i.SuperChannelFilter[e]; + }) + .indexOf(t.superChannelFilter) > -1 + ) || + ("string" != typeof t.customTypeStartsWithFilter && + null !== t.customTypeStartsWithFilter) || + "string" != typeof t.channelNameContainsFilter || + ("string" != typeof t.metadataOrderKeyFilter && + null !== t.metadataOrderKeyFilter) || + ("string" != typeof t.metadataKey && + null !== t.metadataKey) || + !Array.isArray(t.metadataValues) || + !t.metadataValues.every(function (e) { + return "string" == typeof e; + }) || + ("string" != typeof t.metadataValueStartsWith && + null !== t.metadataValueStartsWith) || + "boolean" != typeof t.includeFrozen || + "boolean" != typeof t.includeMetaData + ? n(ie.error, null) + : t.isLoading + ? n( + new P("Query in progress.", P.QUERY_IN_PROGRESS), + null + ) + : t.hasNext + ? ((t.isLoading = !0), + M.get( + t._iid + ).container.apiClient.loadPublicGroupChannelList( + l(l({}, t), {}, { token: t._token }), + function (e, r) { + var a = null; + if (!e) { + var s = String(r.next); + (t._token = s), (t.hasNext = !!s); + var o = r.channels; + o && Array.isArray(o) + ? (a = o.map(function (e) { + return ( + "number" == typeof r.ts && (e.ts = r.ts), + i.upsert(e) + ); + })) + : (e = new P( + "Failed at loading group channels.", + P.MALFORMED_DATA + )); + } + (t.isLoading = !1), n(e, a); + } + )) + : n(null, []); + }, + n + ); + }, + }, + ], + [ + { + key: "MembershipType", + get: function () { + return { ALL: "all", JOINED: "joined" }; + }, + }, + { + key: "ORDER_LATEST_LAST_MESSAGE", + get: function () { + return "latest_last_message"; + }, + }, + { + key: "ORDER_CHRONOLOGICAL", + get: function () { + return "chronological"; + }, + }, + { + key: "CHANNEL_NAME_ALPHABETICAL", + get: function () { + return "channel_name_alphabetical"; + }, + }, + { + key: "METADATA_VALUE_ALPHABETICAL", + get: function () { + return "metadata_value_alphabetical"; + }, + }, + ] + ), + e + ); + })(), + mn = new WeakMap(), + vn = new WeakMap(), + En = (function () { + function e() { + var n = + arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {}, + t = n.channelUrl, + i = void 0 === t ? null : t, + r = n.token, + a = void 0 === r ? "" : r, + s = n.limit, + o = void 0 === s ? 20 : s; + c(this, e), + (this.channelUrl = i), + (this.token = a), + (this.limit = o), + mn.set(this, !1), + vn.set(this, !0); + } + return ( + h(e, [ + { + key: "isLoading", + get: function () { + return !!mn.get(this); + }, + }, + { + key: "hasNext", + get: function () { + return !!vn.get(this); + }, + }, + { + key: "next", + value: function (e) { + var n = this; + return ge( + this._iid, + function (e) { + "string" == typeof n.channelUrl && + "number" == typeof n.limit && + n.limit > 0 && + n.limit <= 100 + ? n.isLoading + ? e( + new P("Query in progress.", P.QUERY_IN_PROGRESS), + null + ) + : n.hasNext + ? (mn.set(n, !0), + M.get(n._iid).container.apiClient.getPollList( + l({}, n), + function (t, i) { + if (t) mn.set(n, !1), e(t, null); + else { + var r = D.get(n._iid).Poll, + a = + i.hasOwnProperty("polls") && + Array.isArray(i.polls) + ? i.polls.map(function (e) { + return new r(e); + }) + : [], + s = + i.hasOwnProperty("next") && i.next + ? String(i.next) + : ""; + (n.token = s), + mn.set(n, !1), + vn.set(n, !!s), + e(null, a); + } + } + )) + : e(null, []) + : e(ie.error, null); + }, + e + ); + }, + }, + ]), + e + ); + })(), + Cn = new WeakMap(), + bn = new WeakMap(), + Un = (function () { + function e() { + var n = + arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {}, + t = n.channelUrl, + i = void 0 === t ? null : t, + r = n.pollId, + a = void 0 === r ? null : r, + s = n.optionId, + o = void 0 === s ? null : s, + l = n.token, + u = void 0 === l ? "" : l, + d = n.limit, + h = void 0 === d ? 100 : d; + c(this, e), + (this.channelUrl = i), + (this.pollId = a), + (this.optionId = o), + (this.token = u), + (this.limit = h), + Cn.set(this, !1), + bn.set(this, !0); + } + return ( + h(e, [ + { + key: "isLoading", + get: function () { + return !!Cn.get(this); + }, + }, + { + key: "hasNext", + get: function () { + return !!bn.get(this); + }, + }, + { + key: "next", + value: function (e) { + var n = this; + return ge( + this._iid, + function (e) { + "string" == typeof n.channelUrl && + "number" == typeof n.pollId && + "number" == typeof n.optionId && + "number" == typeof n.limit && + n.limit > 0 && + n.limit <= 100 + ? n.isLoading + ? e( + new P("Query in progress.", P.QUERY_IN_PROGRESS), + null + ) + : n.hasNext + ? (Cn.set(n, !0), + M.get( + n._iid + ).container.apiClient.getPollOptionVoterList( + l({}, n), + function (t, i) { + if (t) Cn.set(n, !1), e(t, null); + else { + var r = D.get(n._iid).User, + a = + i.hasOwnProperty("voters") && + Array.isArray(i.voters) + ? i.voters.map(function (e) { + return new r(e); + }) + : [], + s = + i.hasOwnProperty("next") && i.next + ? String(i.next) + : ""; + (n.token = s), + Cn.set(n, !1), + bn.set(n, !!s), + e(null, a); + } + } + )) + : e(null, []) + : e(ie.error, null); + }, + e + ); + }, + }, + ]), + e + ); + })(), + An = (function () { + function e() { + c(this, e), + (this.isDistinct = null), + (this.isSuper = null), + (this.isBroadcast = null), + (this.isPublic = null), + (this.channelUrl = null), + (this.isEphemeral = null), + (this.isDiscoverable = null), + (this.isStrict = null), + (this.name = null), + (this.data = null), + (this.customType = null), + (this.channelCover = null), + (this.coverUrl = null), + (this.coverImage = null), + (this.accessCode = null), + (this.messageSurvivalSeconds = null), + (this._invitedUserIds = []); + var n = null; + Object.defineProperty(this, "operators", { + set: function (e) { + Array.isArray(e) && + e.filter(function (e) { + return e.hasOwnProperty("userId"); + }).length === e.length && + (n = e.map(function (e) { + return e.userId; + })); + }, + }), + Object.defineProperty(this, "operatorUserIds", { + get: function () { + return n; + }, + set: function (e) { + Array.isArray(e) && + e.filter(function (e) { + return "string" == typeof e; + }).length === e.length && + (n = e); + }, + }); + } + return ( + h(e, [ + { + key: "_validate", + value: function () { + return ( + Array.isArray(this._invitedUserIds) && + this._invitedUserIds.every(function (e) { + return "string" == typeof e; + }) && + ("string" == typeof this.channelUrl || + null === this.channelUrl) && + ("string" == typeof this.coverUrl || null === this.coverUrl) && + (X.isFile(this.coverImage) || null === this.coverImage) && + ("string" == typeof this.name || null === this.name) && + ("string" == typeof this.data || null === this.data) && + ("string" == typeof this.customType || + null === this.customType) && + ("boolean" == typeof this.isDistinct || + null === this.isDistinct) && + ("boolean" == typeof this.isSuper || null === this.isSuper) && + ("boolean" == typeof this.isBroadcast || + null === this.isBroadcast) && + ("boolean" == typeof this.isPublic || null === this.isPublic) && + ("boolean" == typeof this.isEphemeral || + null === this.isEphemeral) && + ("boolean" == typeof this.isDiscoverable || + null === this.isDiscoverable) && + ("boolean" == typeof this.isStrict || null === this.isStrict) && + ((Array.isArray(this.operatorUserIds) && + this.operatorUserIds.every(function (e) { + return "string" == typeof e; + })) || + null === this.operatorUserIds) && + ("string" == typeof this.accessCode || + null === this.accessCode) && + ("number" == typeof this.messageSurvivalSeconds || + null === this.messageSurvivalSeconds) + ); + }, + }, + { + key: "addUsers", + value: function (e) { + if (Array.isArray(e)) { + var n, + t = e + .filter(function (e) { + return ( + e.hasOwnProperty("userId") && + "string" == typeof e.userId + ); + }) + .map(function (e) { + return e.userId; + }); + (n = this._invitedUserIds).push.apply(n, I(t)); + } + }, + }, + { + key: "addUser", + value: function (e) { + e.hasOwnProperty("userId") && + "string" == typeof e.userId && + this._invitedUserIds.push(e.userId); + }, + }, + { + key: "addUserIds", + value: function (e) { + if (Array.isArray(e)) { + var n, + t = e.filter(function (e) { + return "string" == typeof e; + }); + (n = this._invitedUserIds).push.apply(n, I(t)); + } + }, + }, + { + key: "addUserId", + value: function (e) { + "string" == typeof e && this._invitedUserIds.push(e); + }, + }, + ]), + e + ); + })(), + In = (function () { + function e() { + c(this, e), + (this.channelUrl = null), + (this.name = null), + (this.coverUrlOrImage = null), + (this.data = null), + (this.customType = null), + (this._operatorUserIds = []); + } + return ( + h(e, [ + { + key: "operatorUserIds", + get: function () { + return this._operatorUserIds; + }, + set: function (e) { + Array.isArray(e) && + e.every(function (e) { + return "string" == typeof e; + }) && + (this._operatorUserIds = e); + }, + }, + { + key: "operators", + set: function (e) { + Array.isArray(e) && + e.every(function (e) { + return e.hasOwnProperty("userId"); + }) && + (this._operatorUserIds = e.map(function (e) { + return e.userId; + })); + }, + }, + { + key: "_validate", + value: function () { + return ( + ((Array.isArray(this.operatorUserIds) && + this.operatorUserIds.every(function (e) { + return "string" == typeof e; + })) || + null === this.operatorUserIds) && + ("string" == typeof this.coverUrlOrImage || + X.isFile(this.coverUrlOrImage) || + null === this.coverUrlOrImage) && + ("string" == typeof this.name || null === this.name) && + ("string" == typeof this.data || null === this.data) && + ("string" == typeof this.customType || + null === this.customType) && + (("string" == typeof this.channelUrl && + /^\w+$/.test(this.channelUrl)) || + null === this.channelUrl) + ); + }, + }, + ]), + e + ); + })(), + Sn = new WeakMap(), + kn = (function () { + function e() { + c(this, e), + (this._mentionType = e.MentionType.USERS), + (this._mentionedUserIds = []), + (this._cachedMentionedUsers = []), + (this._cachedMentionedUserIds = []), + (this._metaArrays = []), + Sn.set(this, null), + (this._parentMessageId = null), + (this.isReplyTochannel = !1); + } + return ( + h( + e, + [ + { + key: "mentionType", + get: function () { + return this._mentionType; + }, + set: function (e) { + var n = D.get(this._iid).BaseMessageParams; + Object.keys(n.MentionType) + .map(function (e) { + return n.MentionType[e]; + }) + .indexOf(e) > -1 && (this._mentionType = e); + }, + }, + { + key: "mentionedUserIds", + get: function () { + return this._cachedMentionedUserIds; + }, + set: function (e) { + if (Array.isArray(e)) + for ( + var n = ft.getInstance(this._iid), t = 0; + t < e.length; + t++ + ) { + var i = e[t]; + if ("string" != typeof i) { + (this._cachedMentionedUserIds = []), + (this._mentionedUserIds = []); + break; + } + this._mentionedUserIds.indexOf(i) < 0 && + n.currentUser && + n.currentUser.userId !== i && + (this._cachedMentionedUserIds.push(i), + this._mentionedUserIds.push(i)); + } + }, + }, + { + key: "mentionedUsers", + get: function () { + return this._cachedMentionedUsers; + }, + set: function (e) { + if (Array.isArray(e)) + for ( + var n = ft.getInstance(this._iid), t = 0; + t < e.length; + t++ + ) { + var i = e[t]; + if (!i.hasOwnProperty("userId")) { + (this._cachedMentionedUsers = []), + (this._mentionedUserIds = []); + break; + } + this._mentionedUserIds.indexOf(i.userId) < 0 && + n.currentUser && + n.currentUser.userId !== i.userId && + (this._cachedMentionedUsers.push(i), + this._mentionedUserIds.push(i.userId)); + } + }, + }, + { + key: "metaArrayKeys", + get: function () { + return this._metaArrays.map(function (e) { + return e.key; + }); + }, + set: function (e) { + var n = D.get(this._iid).MessageMetaArray, + t = {}; + if (Array.isArray(e)) { + this._metaArrays = []; + for (var i = 0; i < e.length; i++) + "string" != typeof e[i] || + t[e[i]] || + ((t[e[i]] = !0), this._metaArrays.push(new n(e[i]))); + } + }, + }, + { + key: "metaArrays", + get: function () { + return this._metaArrays; + }, + set: function (e) { + var n = D.get(this._iid).MessageMetaArray; + if (Array.isArray(e)) { + this._metaArrays = []; + for (var t = 0; t < e.length; t++) { + var i = e[t]; + if (i instanceof n) { + var r, + a = this._metaArrays + .map(function (e) { + return e.key; + }) + .indexOf(i.key); + if (a < 0) this._metaArrays.push(i); + else + (r = this._metaArrays[a].value).push.apply( + r, + I(i.value) + ); + } + } + } + }, + }, + { + key: "rootMessageId", + get: function () { + return Sn.get(this); + }, + }, + { + key: "parentMessageId", + get: function () { + return this._parentMessageId; + }, + set: function (e) { + Sn.set(this, e), (this._parentMessageId = e); + }, + }, + { + key: "_validate", + value: function () { + var e = D.get(this._iid), + n = e.BaseMessageParams, + t = e.MessageMetaArray, + i = Sn.get(this); + return ( + Object.keys(n.MentionType) + .map(function (e) { + return n.MentionType[e]; + }) + .indexOf(this.mentionType) > -1 && + this._mentionedUserIds.every(function (e) { + return "string" == typeof e; + }) && + Array.isArray(this._metaArrays) && + this._metaArrays.every(function (e) { + return e instanceof t; + }) && + ("number" == typeof i || null === i) && + ("number" == typeof this._parentMessageId || + null === this._parentMessageId) && + "boolean" == typeof this.isReplyTochannel + ); + }, + }, + ], + [ + { + key: "MentionType", + get: function () { + return { USERS: "users", CHANNEL: "channel" }; + }, + }, + { + key: "PushNotificationDeliveryOption", + get: function () { + return { DEFAULT: "default", SUPPRESS: "suppress" }; + }, + }, + ] + ), + e + ); + })(), + On = (function (e) { + f(t, e); + var n = b(t); + function t() { + var e; + return ( + c(this, t), + ((e = n.call(this)).message = null), + (e.data = null), + (e.customType = null), + (e.pushNotificationDeliveryOption = null), + (e.appleCriticalAlertOptions = null), + (e.pollId = void 0), + (e._translationTargetLanguages = []), + e + ); + } + return ( + h(t, [ + { + key: "targetLanguages", + get: function () { + return this.translationTargetLanguages; + }, + set: function (e) { + this.translationTargetLanguages = e; + }, + }, + { + key: "translationTargetLanguages", + get: function () { + return this._translationTargetLanguages; + }, + set: function (e) { + if (Array.isArray(e)) { + for (var n = 0; n < e.length; n++) + if ("string" != typeof e[n]) + return void (this._translationTargetLanguages = []); + this._translationTargetLanguages = e; + } + }, + }, + { + key: "_validate", + value: function () { + var e = D.get(this._iid), + n = e.BaseMessageParams, + i = e.AppleCriticalAlertOptions; + return ( + U(y(t.prototype), "_validate", this).call(this) && + ("string" == typeof this.message || null === this.message) && + ("string" == typeof this.data || null === this.data) && + ("string" == typeof this.customType || + null === this.customType) && + Array.isArray(this.translationTargetLanguages) && + this.translationTargetLanguages.every(function (e) { + return "string" == typeof e; + }) && + (null === this.pushNotificationDeliveryOption || + Object.keys(n.PushNotificationDeliveryOption) + .map(function (e) { + return n.PushNotificationDeliveryOption[e]; + }) + .indexOf(this.pushNotificationDeliveryOption) > -1) && + (null === this.appleCriticalAlertOptions || + this.appleCriticalAlertOptions instanceof i) && + ("number" == typeof this.pollId || + null === this.pollId || + void 0 === this.pollId) + ); + }, + }, + ]), + t + ); + })(kn), + Nn = (function (e) { + f(t, e); + var n = b(t); + function t() { + var e; + return ( + c(this, t), + ((e = n.call(this)).fileName = null), + (e.mimeType = null), + (e.fileSize = null), + (e.data = null), + (e.customType = null), + (e.pushNotificationDeliveryOption = null), + (e.appleCriticalAlertOptions = null), + (e._isUpdate = !1), + (e._file = null), + (e._fileUrl = null), + (e._thumbnailSizes = []), + e + ); + } + return ( + h(t, [ + { + key: "file", + get: function () { + return this._file; + }, + set: function (e) { + X.isFile(e) && ((this._fileUrl = null), (this._file = e)); + }, + }, + { + key: "fileUrl", + get: function () { + return this._fileUrl; + }, + set: function (e) { + "string" == typeof e && + ((this._fileUrl = e), (this._file = null)); + }, + }, + { + key: "thumbnailSizes", + get: function () { + return this._thumbnailSizes; + }, + set: function (e) { + if (Array.isArray(e)) { + for (var n = 0; n < e.length; n++) + if ( + "object" !== u(e[n]) || + "number" != typeof e[n].maxWidth || + "number" != typeof e[n].maxHeight + ) + return void (this._thumbnailSizes = []); + this._thumbnailSizes = e; + } + }, + }, + { + key: "_validate", + value: function () { + var e = D.get(this._iid), + n = e.BaseMessageParams, + i = e.AppleCriticalAlertOptions; + return ( + U(y(t.prototype), "_validate", this).call(this) && + (this._isUpdate || + X.isFile(this.file) || + "string" == typeof this.fileUrl) && + ("string" == typeof this.fileName || null === this.fileName) && + ("string" == typeof this.mimeType || null === this.mimeType) && + ("number" == typeof this.fileSize || null === this.fileSize) && + ("string" == typeof this.data || null === this.data) && + ("string" == typeof this.customType || + null === this.customType) && + (null === this._thumbnailSizes || + this._thumbnailSizes.every(function (e) { + return ( + "object" === u(e) && e.maxWidth > 0 && e.maxHeight > 0 + ); + })) && + (null === this.pushNotificationDeliveryOption || + Object.keys(n.PushNotificationDeliveryOption) + .map(function (e) { + return n.PushNotificationDeliveryOption[e]; + }) + .indexOf(this.pushNotificationDeliveryOption) > -1) && + (null === this.appleCriticalAlertOptions || + this.appleCriticalAlertOptions instanceof i) + ); + }, + }, + ]), + t + ); + })(kn), + Rn = (function (e) { + f(t, e); + var n = b(t); + function t(e) { + var i; + return ( + c(this, t), + ((i = n.call(this)).year = null), + (i.month = null), + (i.day = null), + (i.hour = null), + (i.min = null), + (i.timezone = null), + (i._scheduledDateTimeString = null), + e && i._update(e), + i + ); + } + return ( + h(t, [ + { + key: "scheduledDateTimeString", + get: function () { + return this._scheduledDateTimeString + ? this._scheduledDateTimeString + : "number" == typeof this.year && + 4 === this.year.toString().length && + "number" == typeof this.month && + this.month >= 1 && + this.month <= 12 && + "number" == typeof this.day && + this.day >= 1 && + this.day <= 31 && + "number" == typeof this.hour && + this.hour >= 0 && + this.hour <= 24 && + "number" == typeof this.min && + this.min >= 0 && + this.min <= 60 && + "string" == typeof this.timezone && + this.timezone.length > 0 + ? this.year.toString() + + "-" + + ("0" + this.month.toString()).substr(-2) + + "-" + + ("0" + this.day.toString()).substr(-2) + + " " + + ("0" + this.hour.toString()).substr(-2) + + ":" + + ("0" + this.min.toString()).substr(-2) + : null; + }, + set: function (e) { + e && "string" == typeof e && (this._scheduledDateTimeString = e); + }, + }, + { + key: "_update", + value: function (e) { + e.hasOwnProperty("message") && (this.message = e.message), + e.hasOwnProperty("year") && (this.year = e.year), + e.hasOwnProperty("month") && (this.month = e.month), + e.hasOwnProperty("day") && (this.day = e.day), + e.hasOwnProperty("hour") && (this.hour = e.hour), + e.hasOwnProperty("min") && (this.min = e.min), + e.hasOwnProperty("timezone") && (this.timezone = e.timezone); + }, + }, + { + key: "_getScheduleString", + value: function () { + return this.scheduledDateTimeString + ? this.scheduledDateTimeString + " " + this.timezone + : "number" == typeof this.year && + 4 === this.year.toString().length && + "number" == typeof this.month && + this.month >= 1 && + this.month <= 12 && + "number" == typeof this.day && + this.day >= 1 && + this.day <= 31 && + "number" == typeof this.hour && + this.hour >= 0 && + this.hour <= 24 && + "number" == typeof this.min && + this.min >= 0 && + this.min <= 60 && + "string" == typeof this.timezone && + this.timezone.length > 0 + ? this.year.toString() + + "-" + + ("0" + this.month.toString()).substr(-2) + + "-" + + ("0" + this.day.toString()).substr(-2) + + " " + + ("0" + this.hour.toString()).substr(-2) + + ":" + + ("0" + this.min.toString()).substr(-2) + + " " + + this.timezone + : null; + }, + }, + { + key: "setSchedule", + value: function (e, n, t, i, r, a) { + "number" == typeof e && + 4 === e.toString().length && + "number" == typeof n && + n >= 1 && + n <= 12 && + "number" == typeof t && + t >= 1 && + t <= 31 && + "number" == typeof i && + i >= 0 && + i <= 24 && + "number" == typeof r && + r >= 0 && + r <= 60 && + "string" == typeof a && + a.length > 0 && + ((this.scheduledDateTimeString = + e.toString() + + "-" + + ("0" + n.toString()).substr(-2) + + "-" + + ("0" + t.toString()).substr(-2) + + " " + + ("0" + i.toString()).substr(-2) + + ":" + + ("0" + r.toString()).substr(-2)), + (this.timezone = a)); + }, + }, + ]), + t + ); + })(On), + Tn = function e() { + c(this, e), + (this.channelCustomTypesFilter = []), + (this.superChannelFilter = De.SuperChannelFilter.ALL); + }, + Mn = (function () { + function e() { + c(this, e), + (this.channelUrl = null), + (this.channelType = null), + (this.messageId = 0), + (this.includeMetaArray = !1), + (this.includeReactions = !1), + (this.includeParentMessageText = null), + (this.includeThreadInfo = !1), + (this.includeParentMessageInfo = null), + (this.includePollDetails = !1); + } + return ( + h(e, [ + { + key: "_validate", + value: function () { + var e = D.get(this._iid).BaseChannel; + return ( + null === this.includeParentMessageInfo && + (this.includeParentMessageInfo = + "boolean" == typeof this.includeParentMessageText && + this.includeParentMessageText), + "string" == typeof this.channelUrl && + "string" == typeof this.channelType && + [ + e.CHANNEL_TYPE_BASE, + e.CHANNEL_TYPE_OPEN, + e.CHANNEL_TYPE_GROUP, + ].includes(this.channelType) && + "number" == typeof this.messageId && + "boolean" == typeof this.includeMetaArray && + "boolean" == typeof this.includeReactions && + "boolean" == typeof this.includeThreadInfo && + "boolean" == typeof this.includeParentMessageInfo && + "boolean" == typeof this.includePollDetails + ); + }, + }, + ]), + e + ); + })(), + Pn = (function () { + function e() { + c(this, e); + var n = D.get(this._iid).BaseChannel; + (this.prevResultSize = 0), + (this.nextResultSize = 0), + (this.isInclusive = !1), + (this.reverse = !1), + (this.messageType = n.MessageTypeFilter.ALL), + (this.customType = null), + (this.customTypes = []), + (this.senderUserIds = null), + (this.includeMetaArray = !1), + (this.includeReaction = null), + (this.includeReactions = !1), + (this.includeReplies = null), + (this.includeParentMessageText = null), + (this.includeThreadInfo = !1), + (this.replyTypeFilter = null), + (this.includeParentMessageInfo = null), + (this.showSubchannelMessagesOnly = !1), + (this.includePollDetails = !1); + } + return ( + h(e, [ + { + key: "_validate", + value: function () { + var e = D.get(this._iid), + n = e.BaseChannel, + t = e.BaseMessage; + return ( + "boolean" == typeof this.includeReaction && + this.includeReaction && + (this.includeReactions = this.includeReaction), + null === this.replyTypeFilter && + (this.replyTypeFilter = + "boolean" == typeof this.includeReplies && + this.includeReplies + ? t.ReplyType.ALL + : t.ReplyType.NONE), + null === this.includeParentMessageInfo && + (this.includeParentMessageInfo = + "boolean" == typeof this.includeParentMessageText && + this.includeParentMessageText), + "number" == typeof this.prevResultSize && + "number" == typeof this.nextResultSize && + "boolean" == typeof this.isInclusive && + "boolean" == typeof this.reverse && + "string" == typeof this.messageType && + Object.values(n.MessageTypeFilter).includes( + this.messageType + ) && + ("string" == typeof this.customType || + null === this.customType) && + Array.isArray(this.customTypes) && + this.customTypes.every(function (e) { + return "string" == typeof e || null === e; + }) && + ((Array.isArray(this.senderUserIds) && + this.senderUserIds.every(function (e) { + return "string" == typeof e; + })) || + null === this.senderUserIds) && + "boolean" == typeof this.includeMetaArray && + "boolean" == typeof this.includeReactions && + "boolean" == typeof this.includeThreadInfo && + "string" == typeof this.replyTypeFilter && + Object.values(t.ReplyType).includes(this.replyTypeFilter) && + "boolean" == typeof this.includeParentMessageInfo && + "boolean" == typeof this.showSubchannelMessagesOnly && + "boolean" == typeof this.includePollDetails + ); + }, + }, + ]), + e + ); + })(), + Ln = (function () { + function e() { + c(this, e); + var n = D.get(this._iid).BaseChannel; + (this.prevResultSize = 0), + (this.nextResultSize = 0), + (this.isInclusive = !1), + (this.reverse = !1), + (this.messageType = n.MessageTypeFilter.ALL), + (this.customType = null), + (this.customTypes = []), + (this.senderUserIds = null), + (this.includeMetaArray = !1), + (this.includeReaction = null), + (this.includeReactions = !1), + (this.includeParentMessageText = null), + (this.includeParentMessageInfo = null), + (this.includePollDetails = !1); + } + return ( + h(e, [ + { + key: "_validate", + value: function () { + var e = D.get(this._iid).BaseChannel; + return ( + "boolean" == typeof this.includeReaction && + this.includeReaction && + (this.includeReactions = this.includeReaction), + null === this.includeParentMessageInfo && + (this.includeParentMessageInfo = + "boolean" == typeof this.includeParentMessageText && + this.includeParentMessageText), + "number" == typeof this.prevResultSize && + "number" == typeof this.nextResultSize && + "boolean" == typeof this.isInclusive && + "boolean" == typeof this.reverse && + "string" == typeof this.messageType && + Object.values(e.MessageTypeFilter).includes( + this.messageType + ) && + ("string" == typeof this.customType || + null === this.customType) && + Array.isArray(this.customTypes) && + this.customTypes.every(function (e) { + return "string" == typeof e || null === e; + }) && + ((Array.isArray(this.senderUserIds) && + this.senderUserIds.every(function (e) { + return "string" == typeof e; + })) || + null === this.senderUserIds) && + "boolean" == typeof this.includeMetaArray && + "boolean" == typeof this.includeReactions && + "boolean" == typeof this.includeParentMessageInfo && + "boolean" == typeof this.includePollDetails + ); + }, + }, + ]), + e + ); + })(), + wn = (function () { + function e() { + c(this, e), + (this.includeMetaArray = !1), + (this.includeReaction = null), + (this.includeReactions = !1), + (this.includeReplies = null), + (this.includeParentMessageText = null), + (this.includeThreadInfo = !1), + (this.replyTypeFilter = null), + (this.includeParentMessageInfo = null), + (this.includePollDetails = !1); + } + return ( + h(e, [ + { + key: "_validate", + value: function () { + var e = ClassHolder.get(this._iid).BaseMessage; + return ( + "boolean" == typeof this.includeReaction && + this.includeReaction && + (this.includeReactions = this.includeReaction), + null === this.replyTypeFilter && + (this.replyTypeFilter = + "boolean" == typeof this.includeReplies && + this.includeReplies + ? e.ReplyType.ALL + : e.ReplyType.NONE), + null === this.includeParentMessageInfo && + (this.includeParentMessageInfo = + "boolean" == typeof this.includeParentMessageText && + this.includeParentMessageText), + "boolean" == typeof this.includeMetaArray && + "boolean" == typeof this.includeReactions && + "boolean" == typeof this.includeThreadInfo && + "string" == typeof this.replyTypeFilter && + Object.values(e.ReplyType).includes(this.replyTypeFilter) && + "boolean" == typeof this.includeParentMessageInfo && + "boolean" == typeof this.includePollDetails + ); + }, + }, + ]), + e + ); + })(), + Dn = (function () { + function e() { + c(this, e), + (this.customTypes = []), + (this.includeEmpty = !1), + (this.includeFrozen = !0); + } + return ( + h(e, [ + { + key: "_validate", + value: function () { + return ( + ((Array.isArray(this.customTypes) && + this.customTypes.every(function (e) { + return "string" == typeof e; + })) || + null === this.customTypes) && + ("boolean" == typeof this.includeEmpty || + null === this.includeEmpty) && + "boolean" == typeof this.includeFrozen + ); + }, + }, + ]), + e + ); + })(), + Hn = (function () { + function e() { + var n = + arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {}, + t = n.title, + i = void 0 === t ? null : t, + r = n.options, + a = void 0 === r ? null : r, + s = n.data, + o = void 0 === s ? null : s, + l = n.isAnonymous, + u = void 0 === l ? null : l, + d = n.allowUserSuggestion, + h = void 0 === d ? null : d, + p = n.allowMultipleVotes, + f = void 0 === p ? null : p, + y = n.closeAt, + g = void 0 === y ? null : y; + c(this, e), + (this.title = i), + (this.options = a), + (this.data = o), + (this.isAnonymous = u), + (this.allowUserSuggestion = h), + (this.allowMultipleVotes = f), + (this.closeAt = g); + } + return ( + h(e, [ + { + key: "_validate", + value: function () { + return ( + "string" == typeof this.title && + ((Array.isArray(this.options) && + this.options.length > 0 && + this.options.every(function (e) { + return "string" == typeof e; + })) || + null === this.options) && + ("string" == typeof this.data || null == this.data) && + ("boolean" == typeof this.isAnonymous || + null === this.isAnonymous) && + ("boolean" == typeof this.allowUserSuggestion || + null === this.allowUserSuggestion) && + ("boolean" == typeof this.allowMultipleVotes || + null === this.allowMultipleVotes) && + ("number" == typeof this.closeAt || null === this.closeAt) + ); + }, + }, + ]), + e + ); + })(), + Fn = (function () { + function e() { + var n = + arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {}, + t = n.channelUrl, + i = void 0 === t ? null : t, + r = n.pollId, + a = void 0 === r ? null : r, + s = n.showPartialVoters, + o = void 0 !== s && s; + c(this, e), + (this.channelUrl = i), + (this.pollId = a), + (this.showPartialVoters = o); + } + return ( + h(e, [ + { + key: "_validate", + value: function () { + return ( + "string" == typeof this.channelUrl && + "number" == typeof this.pollId && + "boolean" == typeof this.showPartialVoters + ); + }, + }, + ]), + e + ); + })(), + Gn = function e() { + c(this, e), + (this.onReconnectStarted = function () {}), + (this.onReconnectSucceeded = function () {}), + (this.onReconnectFailed = function () {}); + }, + jn = function e() { + c(this, e), + (this.onFriendsDiscovered = function (e) {}), + (this.onTotalUnreadMessageCountUpdated = function (e, n) {}); + }, + Bn = function e() { + c(this, e), + (this.onMessageReceived = function (e, n) {}), + (this.onMessageUpdated = function (e, n) {}), + (this.onMessageDeleted = function (e, n) {}), + (this.onReadReceiptUpdated = function (e) {}), + (this.onReactionUpdated = function (e, n) {}), + (this.onDeliveryReceiptUpdated = function (e) {}), + (this.onTypingStatusUpdated = function (e) {}), + (this.onUserJoined = function (e, n) {}), + (this.onUserLeft = function (e, n) {}), + (this.onOperatorUpdated = function (e, n) {}), + (this.onUserEntered = function (e, n) {}), + (this.onUserExited = function (e, n) {}), + (this.onUserMuted = function (e, n) {}), + (this.onUserUnmuted = function (e, n) {}), + (this.onUserBanned = function (e, n) {}), + (this.onUserUnbanned = function (e, n) {}), + (this.onChannelFrozen = function (e) {}), + (this.onChannelUnfrozen = function (e) {}), + (this.onChannelChanged = function (e) {}), + (this.onChannelDeleted = function (e, n) {}), + (this.onUserReceivedInvitation = function (e, n, t) {}), + (this.onUserDeclinedInvitation = function (e, n, t) {}), + (this.onMetaDataCreated = function (e, n) {}), + (this.onMetaDataUpdated = function (e, n) {}), + (this.onMetaDataDeleted = function (e, n) {}), + (this.onMetaCountersCreated = function (e, n) {}), + (this.onMetaCountersUpdated = function (e, n) {}), + (this.onMetaCountersDeleted = function (e, n) {}), + (this.onChannelHidden = function (e) {}), + (this.onMentionReceived = function (e, n) {}), + (this.onThreadInfoUpdated = function (e, n) {}), + (this.onChannelMemberCountChanged = function (e) {}), + (this.onChannelParticipantCountChanged = function (e) {}), + (this.onPollUpdated = function (e) {}), + (this.onPollVoted = function (e) {}); + }, + xn = function e(n) { + if ((c(this, e), n)) { + var t = D.get(this._iid), + i = t.User, + r = t.BaseChannel; + (this.reader = new i(n.user)), + (this.timestamp = parseInt(n.ts)), + (this.channelUrl = n.hasOwnProperty("channel_url") + ? String(n.channel_url) + : ""), + (this.channelType = n.hasOwnProperty("channel_type") + ? String(n.channel_type) + : r.CHANNEL_TYPE_GROUP); + } + }, + qn = (function () { + function e(n) { + var t = + arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : []; + c(this, e), + (this.key = n), + (this.value = + Array.isArray(t) && + t.every(function (e) { + return "string" == typeof e; + }) + ? t + : []); + } + return ( + h(e, [ + { + key: "encode", + value: function () { + return { key: this.key, value: this.value || [] }; + }, + }, + ]), + e + ); + })(), + zn = new WeakMap(), + Qn = (function () { + function e(n) { + var t = this, + i = + arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : [], + r = + arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : 0; + c(this, e), (this.key = n), (this.userIds = i), (this.updatedAt = r); + var a = {}; + this.userIds.forEach(function (e) { + a[e] = t.updatedAt; + }), + zn.set(this, a); + } + return ( + h( + e, + [ + { + key: "isEmpty", + get: function () { + return 0 === this.userIds.length; + }, + }, + { + key: "serialize", + value: function () { + return { + key: this.key, + user_ids: this.userIds, + updated_at: this.updatedAt, + }; + }, + }, + { + key: "_applyEvent", + value: function (e) { + if (e instanceof pe) { + var n = zn.get(this); + if ( + e.key === this.key && + (!n[e.userId] || n[e.userId] < e.updatedAt) + ) { + var t = this.userIds.indexOf(e.userId); + switch (e.operation) { + case "add": + t < 0 && this.userIds.push(e.userId); + break; + case "delete": + t >= 0 && this.userIds.splice(t, 1); + } + n[e.userId] = e.updatedAt; + } + } + }, + }, + ], + [ + { + key: "createFromJson", + value: function (e) { + var n = e.key, + t = e.user_ids, + i = e.updated_at; + return "string" == typeof n && + n && + Array.isArray(t) && + t.length > 0 && + "number" == typeof i + ? new this(n, t, i) + : null; + }, + }, + ] + ), + e + ); + })(), + Vn = (function () { + function e(n) { + c(this, e), + (this.replyCount = 0), + (this.mostRepliedUsers = []), + (this.lastRepliedAt = 0), + (this.updatedAt = 0), + n && this._update(n); + } + return ( + h( + e, + [ + { + key: "_update", + value: function (e) { + var n = D.get(this._iid).User; + e.hasOwnProperty("reply_count") && + (this.replyCount = parseInt(e.reply_count)), + e.hasOwnProperty("most_replies") && + Array.isArray(e.most_replies) && + e.most_replies.every(function (e) { + return "object" === u(e); + }) && + (this.mostRepliedUsers = e.most_replies.map(function (e) { + return new n(e); + })), + e.hasOwnProperty("last_replied_at") && + (this.lastRepliedAt = parseInt(e.last_replied_at)), + e.hasOwnProperty("updated_at") && + (this.updatedAt = parseInt(e.updated_at)); + }, + }, + ], + [ + { + key: "objectify", + value: function (e) { + var n = D.get(this._iid).User, + t = e.replyCount, + i = e.mostRepliedUsers, + r = e.lastRepliedAt, + a = e.updatedAt, + s = {}; + return ( + (s.reply_count = t), + Array.isArray(i) && + i.every(function (e) { + return e instanceof n; + }) && + (s.most_replies = i.map(function (e) { + return n.objectify(e); + })), + (s.last_replied_at = r), + (s.updated_at = a), + s + ); + }, + }, + { + key: "build", + value: function (e, n, t, i) { + return this.objectify({ + replyCount: e, + mostRepliedUsers: n, + lastRepliedAt: t, + updatedAt: i, + }); + }, + }, + ] + ), + e + ); + })(), + Yn = (function () { + function e(n) { + c(this, e), + (this.title = null), + (this.url = null), + (this.description = null), + (this.defaultImage = null), + n && this._update(n); + } + return ( + h( + e, + [ + { + key: "_update", + value: function (e) { + var n = D.get(this._iid).OGImage; + e.hasOwnProperty("og:title") && (this.title = e["og:title"]), + e.hasOwnProperty("og:url") && (this.url = e["og:url"]), + e.hasOwnProperty("og:description") && + (this.description = e["og:description"]), + e.hasOwnProperty("og:image") && + (this.defaultImage = new n(e["og:image"])); + }, + }, + ], + [ + { + key: "objectify", + value: function (e) { + var n = D.get(this._iid).OGImage, + t = e.title, + i = void 0 === t ? null : t, + r = e.url, + a = void 0 === r ? null : r, + s = e.description, + o = void 0 === s ? null : s, + l = e.defaultImage, + u = void 0 === l ? null : l, + c = {}; + return ( + (c["og:title"] = i), + (c["og:url"] = a), + (c["og:description"] = o), + u && (c["og:image"] = n.objectify(u)), + c + ); + }, + }, + ] + ), + e + ); + })(), + Kn = (function () { + function e(n) { + c(this, e), + (this.url = null), + (this.secureUrl = null), + (this.type = null), + (this.width = 0), + (this.height = 0), + (this.alt = null), + n && this._update(n); + } + return ( + h( + e, + [ + { + key: "_update", + value: function (e) { + e.hasOwnProperty("url") && (this.url = e.url), + e.hasOwnProperty("secure_url") && + (this.secureUrl = e.secure_url), + e.hasOwnProperty("type") && (this.type = e.type), + e.hasOwnProperty("width") && (this.width = parseInt(e.width)), + e.hasOwnProperty("height") && + (this.height = parseInt(e.height)), + e.hasOwnProperty("alt") && (this.alt = e.alt); + }, + }, + ], + [ + { + key: "objectify", + value: function (e) { + var n = e.url, + t = void 0 === n ? null : n, + i = e.secureUrl, + r = void 0 === i ? null : i, + a = e.type, + s = void 0 === a ? null : a, + o = e.width, + l = void 0 === o ? 0 : o, + u = e.height, + c = void 0 === u ? 0 : u, + d = e.alt, + h = void 0 === d ? null : d, + p = {}; + return ( + (p.url = t), + (p.secure_url = r), + (p.type = s), + (p.width = l), + (p.height = c), + (p.alt = h), + p + ); + }, + }, + ] + ), + e + ); + })(), + Wn = (function () { + function e(n) { + c(this, e), + (this.type = null), + (this.vendor = null), + (this.detail = {}), + n && this._update(n); + } + return ( + h( + e, + [ + { + key: "_update", + value: function (e) { + (this.type = e.hasOwnProperty("type") ? e.type : ""), + (this.vendor = e.hasOwnProperty("vendor") ? e.vendor : ""), + e.hasOwnProperty("detail") && + "object" === u(e.detail) && + !Array.isArray(e.detail) && + (this.detail = e.detail); + }, + }, + ], + [ + { + key: "objectify", + value: function (e) { + var n = e.type, + t = void 0 === n ? "" : n, + i = e.vendor, + r = void 0 === i ? "" : i, + a = e.detail, + s = void 0 === a ? {} : a, + o = {}; + return (o.type = t), (o.vendor = r), (o.detail = s), o; + }, + }, + ] + ), + e + ); + })(), + Jn = (function () { + function e(n) { + c(this, e), + (this.id = 0), + (this.title = ""), + (this.details = null), + this._update(n); + } + return ( + h( + e, + [ + { + key: "update", + value: function (e, n) { + var t = this, + i = D.get(this._iid), + r = i.PollParams, + a = null, + s = ie.parse(arguments, [ + new ie({ + type: r, + constraint: function (e) { + return e._validate(); + }, + }), + new ie({ type: "callback" }), + ]), + o = A(s, 3); + return ( + (a = o[0]), + (e = o[1]), + (n = o[2]), + ge( + this._iid, + function (n) { + a + ? n(a, null) + : M.get(t._iid).container.apiClient.updatePoll( + l({ pollId: t.id }, e), + function (e, i) { + if (e) n(e, null); + else { + var r = new (0, D.get(t._iid).Poll)(i); + n(null, r); + } + } + ); + }, + n + ) + ); + }, + }, + { + key: "delete", + value: function (e) { + var n = this, + t = null, + i = ie.parse(arguments, [new ie({ type: "callback" })]), + r = A(i, 2); + return ( + (t = r[0]), + (e = r[1]), + ge( + this._iid, + function (e) { + t + ? e(t, null) + : M.get(n._iid).container.apiClient.deletePoll( + { pollId: n.id }, + function (n, t) { + e(n || null, null); + } + ); + }, + e + ) + ); + }, + }, + { + key: "addOption", + value: function (e, n, t) { + var i = this, + r = null, + a = ie.parse(arguments, [ + new ie({ type: "string" }), + new ie({ type: "string" }), + new ie({ type: "callback" }), + ]), + s = A(a, 4); + return ( + (r = s[0]), + (e = s[1]), + (n = s[2]), + (t = s[3]), + ge( + this._iid, + function (t) { + r + ? t(r, null) + : M.get(i._iid).container.apiClient.addPollOption( + { channelUrl: e, pollId: i.id, text: n }, + function (e, n) { + if (e) t(e, null); + else { + var r = new (0, D.get(i._iid).Poll)(n); + t(null, r); + } + } + ); + }, + t + ) + ); + }, + }, + { + key: "vote", + value: function (e, n, t) { + var i = this, + r = null, + a = ie.parse(arguments, [ + new ie({ type: "string" }), + new ie({ + type: "array", + constraint: function (e) { + return e.every(function (e) { + return "number" == typeof e; + }); + }, + }), + new ie({ type: "callback" }), + ]), + s = A(a, 4); + return ( + (r = s[0]), + (e = s[1]), + (n = s[2]), + (t = s[3]), + ge( + this._iid, + function (t) { + r + ? t(r, null) + : M.get(i._iid).container.apiClient.votePoll( + { channelUrl: e, pollId: i.id, optionIds: n }, + function (e, n) { + if (e) t(e, null); + else { + var r = new (0, D.get(i._iid).Poll)(n); + t(null, r); + } + } + ); + }, + t + ) + ); + }, + }, + { + key: "close", + value: function (e) { + var n = this, + t = null, + i = ie.parse(arguments, [new ie({ type: "callback" })]), + r = A(i, 2); + return ( + (t = r[0]), + (e = r[1]), + ge( + this._iid, + function (e) { + t + ? e(t, null) + : M.get(n._iid).container.apiClient.closePoll( + { pollId: n.id }, + function (t, i) { + if (t) e(t, null); + else { + var r = new (0, D.get(n._iid).Poll)(i); + e(null, r); + } + } + ); + }, + e + ) + ); + }, + }, + { + key: "_update", + value: function (e) { + var n = D.get(this._iid).PollDetails; + (this.id = parseInt(e.id)), + (this.title = e.title), + e.hasOwnProperty("options") && + e.hasOwnProperty("is_anonymous") && + e.hasOwnProperty("allow_user_suggestion") && + e.hasOwnProperty("allow_multiple_votes") && + e.hasOwnProperty("close_at") && + e.hasOwnProperty("voter_count") && + e.hasOwnProperty("status") && + e.hasOwnProperty("created_by") && + e.hasOwnProperty("created_at") && + e.hasOwnProperty("updated_at") && + (this.details = new n(e)); + }, + }, + ], + [ + { + key: "Status", + get: function () { + return { OPEN: "open", CLOSED: "closed", REMOVED: "removed" }; + }, + }, + { + key: "objectify", + value: function (e) { + var n = D.get(this._iid).PollDetails, + t = e.id, + i = void 0 === t ? 0 : t, + r = e.title, + a = void 0 === r ? "" : r, + s = e.details, + o = void 0 === s ? null : s, + u = l({}, o ? n.objectify(o) : {}); + return (u.id = i), (u.title = a), u; + }, + }, + { + key: "get", + value: function (e, n) { + var t = this, + i = D.get(this._iid), + r = i.PollRetrievalParams, + a = null, + s = ie.parse(arguments, [ + new ie({ + type: r, + constraint: function (e) { + return e._validate(); + }, + }), + new ie({ type: "callback" }), + ]), + o = A(s, 3); + return ( + (a = o[0]), + (e = o[1]), + (n = o[2]), + ge( + this._iid, + function (n) { + a + ? n(a, null) + : M.get(t._iid).container.apiClient.getPoll( + l({}, e), + function (e, i) { + if (e) n(e, null); + else { + var r = new (0, D.get(t._iid).Poll)(i); + n(null, r); + } + } + ); + }, + n + ) + ); + }, + }, + { + key: "create", + value: function (e, n) { + var t = this, + i = D.get(this._iid), + r = i.PollParams, + a = null, + s = ie.parse(arguments, [ + new ie({ + type: r, + constraint: function (e) { + return e._validate(); + }, + }), + new ie({ type: "callback" }), + ]), + o = A(s, 3); + return ( + (a = o[0]), + (e = o[1]), + (n = o[2]), + ge( + this._iid, + function (n) { + a + ? n(a, null) + : M.get(t._iid).container.apiClient.createPoll( + l({}, e), + function (e, i) { + if (e) n(e, null); + else { + var r = new (0, D.get(t._iid).Poll)(i); + n(null, r); + } + } + ); + }, + n + ) + ); + }, + }, + ] + ), + e + ); + })(), + Xn = (function () { + function e(n) { + c(this, e), + (this.options = []), + (this.data = null), + (this.isAnonymous = !1), + (this.allowUserSuggestion = !1), + (this.allowMultipleVotes = !1), + (this.closeAt = -1), + (this.voterCount = 0), + (this.votedOptionIds = []), + (this.status = ""), + (this.createdBy = null), + (this.createdAt = 0), + (this.updatedAt = 0), + this._update(n); + } + return ( + h( + e, + [ + { + key: "_update", + value: function (e) { + var n = D.get(this._iid).PollOption; + e.hasOwnProperty("options") && + Array.isArray(e.options) && + (this.options = e.options.map(function (e) { + return new n(e); + })); + try { + this.data = JSON.parse(e.data); + } catch (n) { + this.data = e.data; + } + (this.isAnonymous = + !!e.hasOwnProperty("is_anonymous") && e.is_anonymous), + (this.allowUserSuggestion = + !!e.hasOwnProperty("allow_user_suggestion") && + e.allow_user_suggestion), + (this.allowMultipleVotes = + !!e.hasOwnProperty("allow_multiple_votes") && + e.allow_multiple_votes), + (this.closeAt = parseInt(e.close_at)), + (this.voterCount = parseInt(e.voter_count)), + e.hasOwnProperty("voted_option_ids") && + Array.isArray(e.voted_option_ids) && + (this.votedOptionIds = e.voted_option_ids.map(function (e) { + return parseInt(e); + })), + (this.status = e.status), + (this.createdBy = e.created_by), + (this.createdAt = parseInt(e.created_at)), + (this.updatedAt = parseInt(e.updated_at)); + }, + }, + ], + [ + { + key: "objectify", + value: function (e) { + var n = D.get(this._iid).PollOption, + t = e.options, + i = void 0 === t ? [] : t, + r = e.data, + a = void 0 === r ? null : r, + s = e.isAnonymous, + o = void 0 !== s && s, + l = e.allowUserSuggestion, + u = void 0 !== l && l, + c = e.allowMultipleVotes, + d = void 0 !== c && c, + h = e.closeAt, + p = void 0 === h ? -1 : h, + f = e.voterCount, + y = void 0 === f ? 0 : f, + g = e.votedOptionIds, + _ = void 0 === g ? [] : g, + m = e.status, + v = void 0 === m ? "" : m, + E = e.createdBy, + C = void 0 === E ? "" : E, + b = e.createdAt, + U = void 0 === b ? 0 : b, + A = e.updatedAt, + I = void 0 === A ? 0 : A, + S = {}; + return ( + (S.options = i.map(function (e) { + return n.objectify(e); + })), + (S.data = JSON.stringify(a)), + (S.is_anonymous = o), + (S.allow_user_suggestion = u), + (S.allow_multiple_votes = d), + (S.close_at = p), + (S.voter_count = y), + (S.voted_option_ids = _), + (S.status = v), + (S.created_by = C), + (S.created_at = U), + (S.updated_at = I), + S + ); + }, + }, + ] + ), + e + ); + })(), + Zn = new WeakMap(), + $n = (function () { + function e(n) { + c(this, e), + (this.pollId = 0), + (this.id = 0), + (this.text = ""), + (this.voteCount = 0), + (this.partialVoters = []), + (this.createdBy = ""), + (this.createdAt = 0), + (this.updatedAt = 0), + Zn.set(this, null), + this._update(n); + } + return ( + h( + e, + [ + { + key: "lastVotedAt", + get: function () { + return Zn.get(this); + }, + }, + { + key: "update", + value: function (e, n) { + var t = this, + i = null, + r = ie.parse(arguments, [ + new ie({ type: "string" }), + new ie({ type: "callback" }), + ]), + a = A(r, 3); + return ( + (i = a[0]), + (e = a[1]), + (n = a[2]), + ge( + this._iid, + function (n) { + i + ? n(i, null) + : M.get(t._iid).container.apiClient.updatePollOption( + { pollId: t.pollId, optionId: t.id, text: e }, + function (e, i) { + if (e) n(e, null); + else { + var r = new (0, D.get(t._iid).Poll)(i); + n(null, r); + } + } + ); + }, + n + ) + ); + }, + }, + { + key: "delete", + value: function (e) { + var n = this, + t = null, + i = ie.parse(arguments, [new ie({ type: "callback" })]), + r = A(i, 2); + return ( + (t = r[0]), + (e = r[1]), + ge( + this._iid, + function (e) { + t + ? e(t, null) + : M.get(n._iid).container.apiClient.deletePollOption( + { pollId: n.pollId, optionId: n.id }, + function (n, t) { + e(n || null, null); + } + ); + }, + e + ) + ); + }, + }, + { + key: "_applyEvent", + value: function (e) { + return ( + this.id === e.optionId && + this.lastVotedAt < e.votedAt && + ((this.voteCount = e.voteCount), Zn.set(this, e.votedAt), !0) + ); + }, + }, + { + key: "_update", + value: function (e) { + var n = D.get(this._iid).User; + (this.pollId = parseInt(e.poll_id)), + (this.id = parseInt(e.id)), + (this.text = e.text), + (this.voteCount = parseInt(e.vote_count)), + e.hasOwnProperty("partial_voter_list") && + Array.isArray(e.partial_voter_list) && + (this.partialVoters = e.partial_voter_list.map(function ( + e + ) { + return new n(e); + })), + (this.createdBy = e.created_by), + (this.createdAt = parseInt(e.created_at)), + (this.updatedAt = parseInt(e.updated_at)); + }, + }, + ], + [ + { + key: "VoteAction", + get: function () { + return { CAST: "cast", CANCEL: "cancel" }; + }, + }, + { + key: "objectify", + value: function (e) { + var n = D.get(this._iid).User, + t = e.pollId, + i = void 0 === t ? 0 : t, + r = e.id, + a = void 0 === r ? 0 : r, + s = e.text, + o = void 0 === s ? "" : s, + l = e.voteCount, + u = void 0 === l ? 0 : l, + c = e.partialVoters, + d = void 0 === c ? [] : c, + h = e.createdBy, + p = void 0 === h ? "" : h, + f = e.createdAt, + y = void 0 === f ? 0 : f, + g = e.updatedAt, + _ = void 0 === g ? 0 : g, + m = {}; + return ( + (m.poll_id = i), + (m.id = a), + (m.text = o), + (m.vote_count = u), + Array.isArray(d) && + (m.partial_voter_list = d + .filter(function (e) { + return e instanceof n; + }) + .map(function (e) { + return n.objectify(e); + })), + (m.created_by = p), + (m.created_at = y), + (m.updated_at = _), + m + ); + }, + }, + { + key: "get", + value: function (e, n, t, i) { + var r = this, + a = null, + s = ie.parse(arguments, [ + new ie({ type: "string" }), + new ie({ type: "number" }), + new ie({ type: "number" }), + new ie({ type: "callback" }), + ]), + o = A(s, 5); + return ( + (a = o[0]), + (e = o[1]), + (n = o[2]), + (t = o[3]), + (i = o[4]), + ge( + this._iid, + function (i) { + a + ? i(a, null) + : M.get(r._iid).container.apiClient.getPollOption( + { channelUrl: e, pollId: n, optionId: t }, + function (e, n) { + if (e) i(e, null); + else { + var t = new (0, D.get(r._iid).PollOption)(n); + i(null, t); + } + } + ); + }, + i + ) + ); + }, + }, + ] + ), + e + ); + })(), + et = "default", + nt = (function () { + function e(n) { + c(this, e), (this.name = et), (this.volume = 1), n && this._update(n); + } + return ( + h( + e, + [ + { + key: "_update", + value: function (e) { + e.hasOwnProperty("name") && (this.name = e.name), + e.hasOwnProperty("volume") && (this.volume = e.volume); + }, + }, + { + key: "serialize", + value: function () { + return ye.serialize(this); + }, + }, + ], + [ + { + key: "objectify", + value: function (e) { + var n = e.name, + t = void 0 === n ? et : n, + i = e.volume; + return { name: t, volume: void 0 === i ? 1 : i }; + }, + }, + ] + ), + e + ); + })(), + tt = (function () { + function e() { + var n = + arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : []; + c(this, e), + (this.isLoading = !1), + (this.hasNext = !0), + (this.limit = 20), + (this.userIds = n), + (this.metaDataKey = ""), + (this.metaDataValues = []), + (this._token = ""); + } + return ( + h(e, [ + { + key: "next", + value: function (e) { + var n = this; + return ge( + this._iid, + function (e) { + "number" == typeof n.limit && + n.limit > 0 && + Array.isArray(n.userIds) && + "string" == typeof n.metaDataKey && + Array.isArray(n.metaDataValues) && + !!n.metaDataKey == n.metaDataValues.length > 0 + ? n.isLoading + ? e( + new P("Query in progress.", P.QUERY_IN_PROGRESS), + null + ) + : n.hasNext + ? ((n.isLoading = !0), + M.get(n._iid).container.apiClient.loadUserList( + l( + l({}, n), + {}, + { + userIdsFilter: n.userIds, + metaDataKeyFilter: n.metaDataKey, + metaDataValuesFilter: n.metaDataValues, + token: n._token, + } + ), + function (t, i) { + var r = null; + if (!t) { + var a = D.get(n._iid).User, + s = String(i.next); + (n._token = s), + (n.hasNext = !!s), + (r = i.users.map(function (e) { + return new a(e); + })); + } + (n.isLoading = !1), e(t, r); + } + )) + : e(null, []) + : e(ie.error, null); + }, + e + ); + }, + }, + ]), + e + ); + })(), + it = new WeakMap(), + rt = (function () { + function e(n) { + c(this, e), (this.isLoading = !1), it.set(this, n); + } + return ( + h(e, [ + { + key: "prev", + value: function (e, n, t, i) { + var r = arguments, + a = this; + return ge( + this._iid, + function (i) { + var s, + o = D.get(a._iid).BaseChannel, + l = A( + ie.parse(r, [ + new ie({ type: "number" }), + new ie({ type: "number" }), + new ie({ type: "boolean" }), + new ie({ type: "function" }), + ]), + 5 + ); + if ( + ((s = l[0]), + (e = l[1]), + (n = l[2]), + (t = l[3]), + (i = l[4]), + s) + ) + i(s, null); + else if (a.isLoading) + i(new P("Query in progress.", P.QUERY_IN_PROGRESS), null); + else { + a.isLoading = !0; + var u = it.get(a); + M.get(a._iid).container.apiClient.getMessageList( + { + channelUrl: u.url, + channelType: u.channelType, + token: e, + tokenType: "timestamp", + isInclusive: !1, + prevResultSize: n, + nextResultSize: 0, + shouldReverse: t, + messageType: "", + customType: "", + }, + function (e, n) { + var t = null; + e || + (t = n.messages.map(function (e) { + return o.buildMessage(e, u); + })), + (a.isLoading = !1), + i(e, t); + } + ); + } + }, + i + ); + }, + }, + { + key: "next", + value: function (e, n, t, i) { + var r = arguments, + a = this; + return ge( + this._iid, + function (i) { + var s, + o = D.get(a._iid).BaseChannel, + l = A( + ie.parse(r, [ + new ie({ type: "number" }), + new ie({ type: "number" }), + new ie({ type: "boolean" }), + new ie({ type: "function" }), + ]), + 5 + ); + if ( + ((s = l[0]), + (e = l[1]), + (n = l[2]), + (t = l[3]), + (i = l[4]), + s) + ) + i(s, null); + else if (a.isLoading) + i(new P("Query in progress.", P.QUERY_IN_PROGRESS), null); + else { + a.isLoading = !0; + var u = it.get(a); + M.get(a._iid).container.apiClient.getMessageList( + { + channelUrl: u.url, + channelType: u.channelType, + token: e, + tokenType: "timestamp", + isInclusive: !1, + prevResultSize: 0, + nextResultSize: n, + shouldReverse: t, + messageType: "", + customType: "", + }, + function (e, n) { + var t = null; + e || + (t = n.messages.map(function (e) { + return o.buildMessage(e, u); + })), + (a.isLoading = !1), + i(e, t); + } + ); + } + }, + i + ); + }, + }, + { + key: "load", + value: function (e, n, t, i, r) { + var a = arguments, + s = this; + return ge( + this._iid, + function (r) { + var o, + l = D.get(s._iid).BaseChannel, + u = A( + ie.parse(a, [ + new ie({ type: "number" }), + new ie({ type: "number" }), + new ie({ type: "number" }), + new ie({ type: "boolean" }), + new ie({ type: "callback" }), + ]), + 6 + ); + if ( + ((o = u[0]), + (e = u[1]), + (n = u[2]), + (t = u[3]), + (i = u[4]), + (r = u[5]), + o) + ) + r(o, null); + else if (s.isLoading) + r(new P("Query in progress.", P.QUERY_IN_PROGRESS), null); + else { + s.isLoading = !0; + var c = it.get(s); + M.get(s._iid).container.apiClient.getMessageList( + { + channelUrl: c.url, + channelType: c.channelType, + token: e, + tokenType: "timestamp", + isInclusive: !1, + prevResultSize: n, + nextResultSize: t, + shouldReverse: i, + messageType: "", + customType: "", + }, + function (e, n) { + var t = null; + e || + (t = n.messages.map(function (e) { + return l.buildMessage(e, c); + })), + (s.isLoading = !1), + r(e, t); + } + ); + } + }, + r + ); + }, + }, + ]), + e + ); + })(), + at = 0, + st = 1, + ot = 2, + lt = (function () { + function e(n) { + var t = this; + c(this, e), + (this.state = at), + (this._value = null), + (this._reason = null); + if ("function" != typeof n) + throw "Promise resolver ".concat(n, " is not a function"); + n( + function (e) { + t.state === at && ((t.state = st), (t._value = e)); + }, + function (e) { + t.state === at && ((t.state = ot), (t._reason = e)); + } + ); + } + return ( + h( + e, + [ + { + key: "length", + get: function () { + return 1; + }, + }, + { + key: "then", + value: function (n, t) { + var i = this, + r = this; + switch (this.state) { + case at: + setTimeout(function () { + return i.then(n, t); + }, 100); + break; + case st: + n && "function" == typeof n && (r = n(this._value)); + break; + case ot: + t && "function" == typeof t && (r = t(this._reason)); + } + return r instanceof e ? r : this; + }, + }, + { + key: "catch", + value: function (n) { + var t = this, + i = this; + switch (this.state) { + case at: + setTimeout(function () { + return t.catch(n); + }, 100); + break; + case st: + break; + case ot: + i = n(this._reason); + } + return i instanceof e ? i : this; + }, + }, + { + key: "finally", + value: function (n) { + var t = this, + i = this; + switch (this.state) { + case at: + setTimeout(function () { + return t.finally(n); + }, 100); + break; + case st: + case ot: + i = n(); + } + return i instanceof e ? i : this; + }, + }, + ], + [ + { + key: "all", + value: function (n) { + return new e(function (t, i) { + if (Array.isArray(n) || "string" == typeof n) + if (n.length > 0) { + for (var r = [], a = 0; a < n.length; a++) + n[a] instanceof e + ? r.push(n[a]) + : r.push(e.resolve(n[a])); + var s = new Array(r.length).fill(null), + o = r.length, + l = function (e, n, r) { + n ? i(n) : (o--, (s[e] = r), o <= 0 && t(s)); + }; + r.forEach(function (e, n) { + e.then(function (e) { + l(n, null, e); + }).catch(function (e) { + l(n, e, null); + }); + }); + } else t([]); + else + i( + new Error( + "Uncaught (in promise) TypeError: " + .concat(u(n), " ") + .concat(n, " is not iterable") + ) + ); + }); + }, + }, + { + key: "resolve", + value: function (n) { + return new e(function (e) { + e(n); + }); + }, + }, + { + key: "reject", + value: function (n) { + return new e(function (e, t) { + t(n); + }); + }, + }, + ] + ), + e + ); + })(), + ut = function () { + "undefined" == typeof Promise && + ("undefined" != typeof window + ? (window.Promise = lt) + : "undefined" != typeof global + ? (global.Promise = lt) + : "undefined" != typeof self + ? (self.Promise = lt) + : "undefined" != typeof globalThis && (globalThis.Promise = lt)), + Object.values || + (Object.values = function (e) { + return Object.keys(e).map(function (n) { + return e[n]; + }); + }), + Number.MAX_SAFE_INTEGER || + Object.defineProperty(Number, "MAX_SAFE_INTEGER", { + value: Math.pow(2, 53) - 1, + }); + }, + ct = 3e5, + dt = null, + ht = {}, + pt = !1, + ft = (function () { + function e() { + var n = this, + t = + arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {}; + c(this, e), ut(); + var i = !1; + if ( + ((t.newInstance || + !dt || + (dt && + t.appId !== dt.getApplicationId() && + dt.getConnectionState() === dt.ConnectionState.CLOSED)) && + ((i = !0), (dt = this)), + i) + ) { + try { + if (!t.hasOwnProperty("appId")) + return V.warn("Must be set appId."), (dt = null), null; + } catch (e) { + return V.warn("Must be set appId."), (dt = null), null; + } + var r = Re.create(); + Object.defineProperty(this, "_iid", { + get: function () { + return r; + }, + }), + (ht[r] = this), + (this.customApiHost = null), + (this.customWsHost = null), + (this.connecting = !1), + (this.reconnecting = !1), + (this.isReconnectingOnError = !1), + (this.connectionCallbacks = []), + (this.ConnectionManager = new re(this)), + (this.GCMPushToken = ""), + (this.APNSPushToken = ""), + (this.PUSH_TEMPLATE_DEFAULT = "default"), + (this.PUSH_TEMPLATE_ALTERNATIVE = "alternative"), + (this.currentUser = null), + (this.isSessionOpened = !1), + this.globalTimer, + this.loginTimer, + this.reconnectTimer, + (this.loginHandler = null), + this.onLoginTimerCancel, + this.onReconnectTimerCancel, + (this.BaseChannel = { MessageTypeFilter: Ue.MessageTypeFilter }); + var a = { + User: Ee, + Member: He, + GroupChannel: De, + OpenChannel: Qe, + UserMessage: Ve, + FileMessage: Ye, + AdminMessage: Ke, + GroupChannelListQuery: rn, + MemberListQuery: an, + GroupChannelParams: An, + OpenChannelParams: In, + BaseMessageParams: kn, + UserMessageParams: On, + FileMessageParams: Nn, + ScheduledUserMessageParams: Rn, + GroupChannelTotalUnreadMessageCountParams: Tn, + MessageRetrievalParams: Mn, + MessageListParams: Pn, + ThreadedMessageListParams: Ln, + MessageChangeLogsParams: wn, + GroupChannelChangeLogsParams: Dn, + PollParams: Hn, + PollRetrievalParams: Fn, + MessageMetaArray: qn, + UserEventHandler: jn, + SessionHandler: ae, + ChannelHandler: Bn, + ConnectionHandler: Gn, + AppleCriticalAlertOptions: nt, + Poll: Jn, + PollOption: $n, + }, + s = { + SessionManager: se, + BaseChannel: Ue, + BaseMessage: ve, + UserListQuery: tt, + ApplicationUserListQuery: $e, + BannedUserListQuery: en, + BlockedUserListQuery: nn, + FriendListQuery: tn, + MutedUserListQuery: sn, + OpenChannelListQuery: on, + OperatorListQuery: un, + ParticipantListQuery: dn, + MessageListQuery: rt, + PreviousMessageListQuery: gn, + MessageSearchQuery: pn, + PublicGroupChannelListQuery: _n, + PollListQuery: En, + PollVoterListQuery: Un, + ScheduledUserMessage: We, + ThreadInfo: Vn, + ThreadInfoUpdateEvent: Je, + OGMetaData: Yn, + OGImage: Kn, + Plugin: Wn, + Command: ue, + Sender: Fe, + ReadStatus: xn, + Reaction: Qn, + ReactionEvent: pe, + Emoji: Be, + EmojiCategory: je, + EmojiContainer: Ge, + PollDetails: Xn, + PollUpdateEvent: Xe, + PollVoteEvent: Ze, + FileMessageQueue: Ne, + }, + o = new D(this._iid, l(l({}, a), s)); + (this.BaseMessage = { + ReplyType: ve.ReplyType, + getMessage: o.BaseMessage.getMessage.bind(o.BaseMessage), + }), + Object.keys(o).forEach(function (e) { + a[e] && (n[e] = o[e]); + }), + M.create(r, { + appId: t.appId, + pinger: new K(this), + apiClient: new ee(this), + wsAdapter: new te(this), + commandHandler: new Se(this), + onlineDetector: new oe(this), + ackStateMap: {}, + subscribedUnreadMessageCount: { all: 0, custom_types: {}, ts: 0 }, + maxUnreadCountOfSuperGroupChannel: + N.DEFAULT_MAX_UNREAD_COUNT_OF_SUPER_GROUP_CHANNEL, + auth: new L(), + appInfo: null, + pingInterval: 15e3, + pongTimeout: 5e3, + connectedAt: 0, + extensions: {}, + supportedExtensionKeys: ["sb_uikit", "sb_syncmanager"], + getUserAgentWithExtensions: function (e) { + var n = e.sb_syncmanager ? "s".concat(e.sb_syncmanager) : "", + t = e.sb_uikit ? "u".concat(e.sb_uikit) : ""; + return "JS/c" + .concat(N.SDK_VERSION, "/") + .concat(n, "/") + .concat(t); + }, + sessionManager: new o.SessionManager(this), + stateChangeEnabled: !0, + isInBackground: !1, + closedByGoingBackground: !1, + isErrorFirstInCallback: !1, + }), + (this.userEventHandlers = {}), + (this.channelHandlers = {}), + (this.connectionHandlers = {}), + (this.Options = { + _useMemberAsMessageSender: !0, + get UseMemberAsMessageSender() { + return this._useMemberAsMessageSender; + }, + set UseMemberAsMessageSender(e) { + "boolean" == typeof e && (this._useMemberAsMessageSender = e); + }, + get useMemberAsMessageSender() { + return this._useMemberAsMessageSender; + }, + set useMemberAsMessageSender(e) { + "boolean" == typeof e && (this._useMemberAsMessageSender = e); + }, + _typingIndicatorThrottle: 1e3, + get typingIndicatorThrottle() { + return this._typingIndicatorThrottle; + }, + set typingIndicatorThrottle(e) { + "number" == typeof e && + e >= 1e3 && + e <= 9e3 && + (this._typingIndicatorThrottle = e); + }, + _websocketResponseTimeout: 1e4, + get websocketResponseTimeout() { + return this._websocketResponseTimeout; + }, + set websocketResponseTimeout(e) { + "number" == typeof e && + e >= 5e3 && + e <= ct && + (this._websocketResponseTimeout = e); + }, + includePollDetails: !1, + }); + } + return dt; + } + return ( + h( + e, + [ + { + key: "ConnectionState", + get: function () { + return { + CONNECTING: "CONNECTING", + OPEN: "OPEN", + CLOSED: "CLOSED", + }; + }, + }, + { + key: "MessageRequestState", + get: function () { + return { + NONE: "none", + PENDING: "pending", + FAILED: "failed", + SUCCEEDED: "succeeded", + }; + }, + }, + { + key: "MessageSendingStatus", + get: function () { + return { + NONE: "none", + PENDING: "pending", + FAILED: "failed", + CANCELED: "canceled", + SUCCEEDED: "succeeded", + }; + }, + }, + { + key: "pushTokenRegistrationState", + get: function () { + return { + SUCCESS: "success", + PENDING: "pending", + ERROR: "error", + }; + }, + }, + { + key: "PushTriggerOption", + get: function () { + return { ALL: "all", MENTION_ONLY: "mention_only", OFF: "off" }; + }, + }, + { + key: "appInfo", + get: function () { + return M.get(this._iid).container.appInfo; + }, + }, + { + key: "ekey", + get: function () { + var e = M.get(this._iid).container.auth; + return e ? e.eKey : ""; + }, + }, + { + key: "getApplicationId", + value: function () { + return M.get(this._iid).get("appId"); + }, + }, + { + key: "getCurrentUserId", + value: function () { + return this.currentUser ? this.currentUser.userId : null; + }, + }, + { + key: "getDebugMode", + value: function () { + return pt; + }, + }, + { + key: "setDebugMode", + value: function (e) { + (pt = e), (V.mode = e ? V.Mode.DEBUG : V.Mode.PRODUCTION); + }, + }, + { + key: "getErrorFirstCallback", + value: function () { + return M.get(this._iid).container.isErrorFirstInCallback; + }, + }, + { + key: "setErrorFirstCallback", + value: function (e) { + "boolean" == typeof e && + M.get(this._iid).set("isErrorFirstInCallback", e); + }, + }, + { + key: "getCurrentApiHost", + value: function () { + return this.customApiHost + ? this.customApiHost + : "https://api.sendbird.com"; + }, + }, + { + key: "clearCurrentApiHost", + value: function () { + this.customApiHost = null; + }, + }, + { + key: "getCurrentWsHost", + value: function () { + return this.customWsHost + ? this.customWsHost + : "wss://ws.sendbird.com"; + }, + }, + { + key: "clearCurrentWsHost", + value: function () { + this.customWsHost = null; + }, + }, + { + key: "getConnectionState", + value: function () { + try { + var e = M.get(this._iid).container.wsAdapter; + return this.connecting || this.reconnecting + ? this.ConnectionState.CONNECTING + : e.client + ? this.connecting || this.reconnecting + ? this.ConnectionState.CONNECTING + : this.isSessionOpened + ? e.client.getConnectionState() + : this.ConnectionState.CLOSED + : this.ConnectionState.CLOSED; + } catch (e) { + return this.ConnectionState.CLOSED; + } + }, + }, + { + key: "getPendingGCMToken", + value: function () { + return this.GCMPushToken; + }, + }, + { + key: "getPendingAPNSToken", + value: function () { + return this.APNSPushToken; + }, + }, + { + key: "hasLoggedIn", + value: function () { + var e = M.get(this._iid); + return this.currentUser && e.get("auth").hasSession(); + }, + }, + { + key: "getLastConnectedAt", + value: function () { + var e = M.get(this._iid); + return this.getConnectionState() === + this.ConnectionState.OPEN && this.currentUser + ? e.get("connectedAt") + : 0; + }, + }, + { + key: "connect", + value: function (e, n, t, i, r) { + var a = this, + s = M.get(this._iid), + o = s.container, + l = o.wsAdapter, + u = o.onlineDetector; + u && u.start(); + var c = null, + d = ie.parse(arguments, [ + new ie({ + type: "string", + constraint: function (e) { + return e.length > 0; + }, + }), + new ie({ + type: "string", + nullable: !0, + ignoreIf: function (e) { + return 1 === e.length || 3 === e.length; + }, + }), + new ie({ + type: "string", + nullable: !0, + ignoreIf: function (e) { + return 1 === e.length || 2 === e.length; + }, + }), + new ie({ + type: "string", + nullable: !0, + ignoreIf: function (e) { + return 1 === e.length || 2 === e.length; + }, + }), + new ie({ type: "callback" }), + ]), + h = A(d, 6); + return ( + (c = h[0]), + (e = h[1]), + (n = h[2]), + (t = h[3]), + (i = h[4]), + (r = h[5]), + ge( + this._iid, + function (r) { + c + ? r(c, null) + : ((a.customApiHost = t), + (a.customWsHost = i), + (a.connecting = !0), + (a.reconnecting = !1), + (a.isReconnectingOnError = !1), + a.reconnectTimer && + (clearTimeout(a.reconnectTimer), + (a.reconnectTimer = null), + (a.onReconnectTimerCancel = null)), + a.getConnectionState() === a.ConnectionState.OPEN && + a.currentUser && + a.currentUser.userId === e + ? ((a.connecting = !1), r(null, a.currentUser)) + : (a.connectionCallbacks.push(r), + 1 === a.connectionCallbacks.length && + (l.disconnect( + { clearSession: !0, err: null }, + null + ), + l.connect(e, n)))); + }, + r + ) + ); + }, + }, + { + key: "reconnect", + value: function () { + var e = M.get(this._iid).container, + n = e.wsAdapter; + if (e.auth.sessionKey && this.currentUser) { + var t = !0; + return ( + n.reconnectCount > 0 && (t = !1), + n.disconnect( + { + clearSession: !1, + err: new P( + "Connection has been canceled.", + P.CONNECTION_CANCELED + ), + }, + null + ), + (n.reconnectCount = 0), + n.reconnect(this.currentUser.userId, t), + !0 + ); + } + return !1; + }, + }, + { + key: "disconnect", + value: function (e) { + var n = this; + return ge( + this._iid, + function (e) { + var t = M.get(n._iid).container, + i = t.wsAdapter, + r = t.onlineDetector; + r && r.stop(), + i.disconnect( + { + clearSession: !0, + err: new P( + "Connection has been canceled.", + P.CONNECTION_CANCELED + ), + }, + e + ); + }, + e + ); + }, + }, + { + key: "setBackgroundState", + value: function () { + var e = M.get(this._iid), + n = e.container, + t = n.wsAdapter, + i = n.stateChangeEnabled; + !n.isInBackground && + i && + (e.set("isInBackground", !0), + this.getConnectionState() !== this.ConnectionState.CLOSED + ? (e.set("closedByGoingBackground", !0), + t.disconnect( + { + clearSession: !1, + err: new P( + "Websocket connection failed.", + P.WEBSOCKET_CONNECTION_FAILED + ), + }, + null + )) + : e.set("closedByGoingBackground", !1)); + }, + }, + { + key: "setForegroundState", + value: function () { + var e = M.get(this._iid), + n = e.container, + t = n.wsAdapter, + i = n.stateChangeEnabled, + r = n.isInBackground, + a = n.closedByGoingBackground; + r && + i && + (e.set("isInBackground", !1), + a && + this.currentUser && + t.reconnect(this.currentUser.userId, !0)); + }, + }, + { + key: "enableStateChange", + value: function () { + M.get(this._iid).set("enableStateChange", !0); + }, + }, + { + key: "disableStateChange", + value: function () { + M.get(this._iid).set("enableStateChange", !1); + }, + }, + { + key: "addExtension", + value: function (e, n) { + var t = M.get(this._iid).container, + i = t.extensions; + t.supportedExtensionKeys.indexOf(e) > -1 && (i[e] = n); + }, + }, + { + key: "createUserListQuery", + value: function (e) { + return new (0, D.get(this._iid).UserListQuery)(e); + }, + }, + { + key: "createApplicationUserListQuery", + value: function () { + return new (0, D.get(this._iid).ApplicationUserListQuery)(); + }, + }, + { + key: "createBlockedUserListQuery", + value: function () { + return new (0, D.get(this._iid).BlockedUserListQuery)(); + }, + }, + { + key: "createFriendListQuery", + value: function () { + return new (0, D.get(this._iid).FriendListQuery)(); + }, + }, + { + key: "createMessageSearchQuery", + value: function (e, n) { + return new (0, D.get(this._iid).MessageSearchQuery)(e, n); + }, + }, + { + key: "sendCommand", + value: function (e, n) { + var t = this; + return ge( + this._iid, + function (n) { + t.ConnectionManager.ready(function (i, r) { + if (i) n(i, null); + else { + var a = M.get(t._iid).container, + s = a.wsAdapter, + o = a.ackStateMap; + if ( + null == s || + null == s.client || + s.client.getConnectionState() !== + t.ConnectionState.OPEN || + t.getConnectionState() !== t.ConnectionState.OPEN + ) + return void n( + new P( + "Connection is not valid. Please reconnect.", + P.WEBSOCKET_CONNECTION_CLOSED + ), + null + ); + if (e.isAckRequired) { + var l = e.requestId, + u = { + handler: n, + timer: setTimeout(function () { + n( + new P( + "Command received no ack.", + P.ACK_TIMEOUT + ), + null + ), + delete o[l]; + }, t.Options.websocketResponseTimeout), + }; + (o[l] = u), + s.client.send(e, function (e) { + e && (clearTimeout(u.timer), n(e, null)); + }); + } else s.client.send(e, n); + } + }, !1); + }, + n + ); + }, + }, + { + key: "setSessionHandler", + value: function (e) { + M.get(this._iid).container.sessionManager.handler = e; + }, + }, + { + key: "addUserEventHandler", + value: function (e, n) { + n instanceof D.get(this._iid).UserEventHandler && + (this.userEventHandlers[e] = n); + }, + }, + { + key: "removeUserEventHandler", + value: function (e) { + delete this.userEventHandlers[e]; + }, + }, + { + key: "removeAllUserEventHandler", + value: function () { + this.userEventHandlers = {}; + }, + }, + { + key: "addChannelHandler", + value: function (e, n) { + n instanceof D.get(this._iid).ChannelHandler && + (this.channelHandlers[e] = n); + }, + }, + { + key: "removeChannelHandler", + value: function (e) { + delete this.channelHandlers[e]; + }, + }, + { + key: "removeAllChannelHandlers", + value: function () { + this.channelHandlers = {}; + }, + }, + { + key: "addConnectionHandler", + value: function (e, n) { + n instanceof D.get(this._iid).ConnectionHandler && + (this.connectionHandlers[e] = n); + }, + }, + { + key: "removeConnectionHandler", + value: function (e) { + delete this.connectionHandlers[e]; + }, + }, + { + key: "removeAllConnectionHandlers", + value: function () { + this.connectionHandlers = {}; + }, + }, + { + key: "updateCurrentUserInfo", + value: function (e, n, t) { + var i = this, + r = null, + a = ie.parse(arguments, [ + new ie({ type: "string", nullable: !0 }), + new ie({ type: "string", nullable: !0 }), + new ie({ type: "callback" }), + ]), + s = A(a, 4); + return ( + (r = s[0]), + (e = s[1]), + (n = s[2]), + (t = s[3]), + ge( + this._iid, + function (t) { + r + ? t(r, null) + : M.get( + i._iid + ).container.apiClient.updateCurrentUserInfo( + { nickname: e, profileUrl: n }, + function (r, a) { + var s = null; + r || + (i.currentUser && + (e && (i.currentUser.nickname = e), + n && (i.currentUser.plainProfileUrl = n)), + (s = i.currentUser)), + t(r, s); + } + ); + }, + t + ) + ); + }, + }, + { + key: "updateCurrentUserInfoWithProfileImage", + value: function (e, n, t) { + var i = this, + r = null, + a = ie.parse(arguments, [ + new ie({ type: "string", nullable: !0 }), + new ie({ type: "file", nullable: !0 }), + new ie({ type: "callback" }), + ]), + s = A(a, 4); + return ( + (r = s[0]), + (e = s[1]), + (n = s[2]), + (t = s[3]), + ge( + this._iid, + function (t) { + r + ? t(r, null) + : M.get( + i._iid + ).container.apiClient.updateCurrentUserInfo( + { nickname: e, profileImage: n }, + function (n, r) { + var a = null; + n || + (i.currentUser && + (e && (i.currentUser.nickname = e), + r.profile_url && + (i.currentUser.plainProfileUrl = + r.profile_url)), + (a = i.currentUser)), + t(n, a); + } + ); + }, + t + ) + ); + }, + }, + { + key: "updateCurrentUserInfoWithPreferredLanguages", + value: function (e, n) { + var t = this, + i = null, + r = ie.parse(arguments, [ + new ie({ + type: "array", + constraint: function (e) { + return e.every(function (e) { + return "string" == typeof e; + }); + }, + }), + new ie({ type: "callback" }), + ]), + a = A(r, 3); + return ( + (i = a[0]), + (e = a[1]), + (n = a[2]), + ge( + this._iid, + function (n) { + i + ? n(i, null) + : M.get( + t._iid + ).container.apiClient.updateCurrentUserInfo( + { preferredLanguages: e }, + function (i, r) { + var a = null; + i || + (t.currentUser && + e && + (t.currentUser._preferredLanguages = e), + (a = t.currentUser)), + n(i, a); + } + ); + }, + n + ) + ); + }, + }, + { + key: "registerGCMPushTokenForCurrentUser", + value: function (e, n) { + var t = this, + i = null, + r = ie.parse(arguments, [ + new ie({ + type: "string", + constraint: function (e) { + return e.length > 0; + }, + }), + new ie({ type: "callback" }), + ]), + a = A(r, 3); + return ( + (i = a[0]), + (e = a[1]), + (n = a[2]), + ge( + this._iid, + function (n) { + i + ? n(i, t.pushTokenRegistrationState.ERROR) + : t.currentUser + ? M.get( + t._iid + ).container.apiClient.registerGCMPushToken( + { token: e }, + function (e, i) { + var r = t.pushTokenRegistrationState.ERROR; + e || + ((t.GCMPushToken = ""), + (r = t.pushTokenRegistrationState.SUCCESS)), + n(e, r); + } + ) + : ((t.GCMPushToken = e), + n(null, t.pushTokenRegistrationState.PENDING)); + }, + n + ) + ); + }, + }, + { + key: "unregisterGCMPushTokenForCurrentUser", + value: function (e, n) { + var t = this, + i = null, + r = ie.parse(arguments, [ + new ie({ + type: "string", + constraint: function (e) { + return e.length > 0; + }, + }), + new ie({ type: "callback" }), + ]), + a = A(r, 3); + return ( + (i = a[0]), + (e = a[1]), + (n = a[2]), + ge( + this._iid, + function (n) { + i + ? n(i, null) + : t.currentUser + ? M.get( + t._iid + ).container.apiClient.unregisterGCMPushToken( + { token: e }, + function (e, t) { + n(e, null); + } + ) + : ((t.GCMPushToken = e), + n(null, t.pushTokenRegistrationState.PENDING)); + }, + n + ) + ); + }, + }, + { + key: "unregisterGCMPushTokenAllForCurrentUser", + value: function (e) { + var n = this; + return ge( + this._iid, + function (e) { + M.get( + n._iid + ).container.apiClient.unregisterAllGCMPushTokens( + {}, + function (n, t) { + e(n, null); + } + ); + }, + e + ); + }, + }, + { + key: "registerAPNSPushTokenForCurrentUser", + value: function (e, n) { + var t = this, + i = null, + r = ie.parse(arguments, [ + new ie({ + type: "string", + constraint: function (e) { + return e.length > 0; + }, + }), + new ie({ type: "callback" }), + ]), + a = A(r, 3); + return ( + (i = a[0]), + (e = a[1]), + (n = a[2]), + ge( + this._iid, + function (n) { + i + ? n(i, t.pushTokenRegistrationState.ERROR) + : t.currentUser + ? M.get( + t._iid + ).container.apiClient.registerAPNSPushToken( + { token: e }, + function (e, i) { + var r = t.pushTokenRegistrationState.ERROR; + e || + ((t.APNSPushToken = ""), + (r = t.pushTokenRegistrationState.SUCCESS)), + n(e, r); + } + ) + : ((t.APNSPushToken = e), + n(null, t.pushTokenRegistrationState.PENDING)); + }, + n + ) + ); + }, + }, + { + key: "unregisterAPNSPushTokenForCurrentUser", + value: function (e, n) { + var t = this, + i = null, + r = ie.parse(arguments, [ + new ie({ + type: "string", + constraint: function (e) { + return e.length > 0; + }, + }), + new ie({ type: "callback" }), + ]), + a = A(r, 3); + return ( + (i = a[0]), + (e = a[1]), + (n = a[2]), + ge( + this._iid, + function (n) { + i + ? n(i, null) + : t.currentUser + ? M.get( + t._iid + ).container.apiClient.unregisterAPNSPushToken( + { token: e }, + function (e, t) { + n(e, null); + } + ) + : ((t.APNSPushToken = e), + n(null, t.pushTokenRegistrationState.PENDING)); + }, + n + ) + ); + }, + }, + { + key: "unregisterAPNSPushTokenAllForCurrentUser", + value: function (e) { + var n = this; + return ge( + this._iid, + function (e) { + M.get( + n._iid + ).container.apiClient.unregisterAllAPNSPushTokens( + {}, + function (n, t) { + e(n, null); + } + ); + }, + e + ); + }, + }, + { + key: "unregisterPushTokenAllForCurrentUser", + value: function (e) { + var n = this; + return ge( + this._iid, + function (e) { + M.get(n._iid).container.apiClient.unregisterAllPushTokens( + {}, + function (n, t) { + e(n, null); + } + ); + }, + e + ); + }, + }, + { + key: "getMyGroupChannelChangeLogsByToken", + value: function (e, n, t, i) { + var r = this, + a = null, + s = ie.parse(arguments, [ + new ie({ type: "string", nullable: !0 }), + new ie({ + type: "array", + optional: !0, + nullable: !0, + defaultValue: null, + }), + new ie({ + type: "boolean", + nullable: !0, + optional: !0, + defaultValue: null, + }), + new ie({ type: "callback" }), + ]), + o = A(s, 5); + (a = o[0]), (e = o[1]), (n = o[2]), (t = o[3]), (i = o[4]); + var u = D.get(this._iid), + c = u.GroupChannelChangeLogsParams, + d = null; + if (a) { + var h = ie.parse(arguments, [ + new ie({ type: "string", nullable: !0 }), + new ie({ + type: c, + constraint: function (e) { + return e._validate(); + }, + }), + new ie({ type: "callback" }), + ]), + p = A(h, 4); + (a = p[0]), (e = p[1]), (d = p[2]), (i = p[3]); + } else + ((d = new c()).customTypes = n), + (d.includeEmpty = t), + (d.includeFrozen = !0); + return ge( + this._iid, + function (n) { + a + ? n(a, null) + : M.get( + r._iid + ).container.apiClient.getMyGroupChannelChangeLogs( + l({ ts: null, token: e }, d), + function (e, t) { + if (e) n(e, null); + else { + var i = D.get(r._iid).GroupChannel, + a = t.updated.map(function (e) { + return new i(e); + }), + s = t.deleted, + o = t.has_more, + l = t.next; + n(null, { + updatedChannels: a, + deletedChannelUrls: s, + hasMore: o, + token: l, + }); + } + } + ); + }, + i + ); + }, + }, + { + key: "getMyGroupChannelChangeLogsByTimestamp", + value: function (e, n, t, i) { + var r = this, + a = null, + s = ie.parse(arguments, [ + new ie({ + type: "number", + constraint: function (e) { + return e >= 0; + }, + }), + new ie({ + type: "array", + optional: !0, + nullable: !0, + defaultValue: null, + }), + new ie({ + type: "boolean", + nullable: !0, + optional: !0, + defaultValue: null, + }), + new ie({ type: "callback" }), + ]), + o = A(s, 5); + (a = o[0]), (e = o[1]), (n = o[2]), (t = o[3]), (i = o[4]); + var u = D.get(this._iid), + c = u.GroupChannelChangeLogsParams, + d = null; + if (a) { + var h = ie.parse(arguments, [ + new ie({ + type: "number", + constraint: function (e) { + return e >= 0; + }, + }), + new ie({ + type: c, + constraint: function (e) { + return e._validate(); + }, + }), + new ie({ type: "callback" }), + ]), + p = A(h, 4); + (a = p[0]), (e = p[1]), (d = p[2]), (i = p[3]); + } else + ((d = new c()).customTypes = n), + (d.includeEmpty = t), + (d.includeFrozen = !0); + return ge( + this._iid, + function (n) { + a + ? n(a, null) + : M.get( + r._iid + ).container.apiClient.getMyGroupChannelChangeLogs( + l({ ts: e, token: null }, d), + function (e, t) { + if (e) n(e, null); + else { + var i = D.get(r._iid).GroupChannel, + a = t.updated.map(function (e) { + return new i(e); + }), + s = t.deleted, + o = t.has_more, + l = t.next; + n(null, { + updatedChannels: a, + deletedChannelUrls: s, + hasMore: o, + token: l, + }); + } + } + ); + }, + i + ); + }, + }, + { + key: "getChannelInvitationPreference", + value: function (e) { + var n = this; + return ge( + this._iid, + function (e) { + M.get( + n._iid + ).container.apiClient.getChannelInvitationPreference( + {}, + function (n, t) { + var i = null; + n || (i = { autoAccept: t.auto_accept }), e(n, i); + } + ); + }, + e + ); + }, + }, + { + key: "setChannelInvitationPreference", + value: function (e, n) { + var t = this, + i = null, + r = ie.parse(arguments, [ + new ie({ type: "boolean" }), + new ie({ type: "callback" }), + ]), + a = A(r, 3); + return ( + (i = a[0]), + (e = a[1]), + (n = a[2]), + ge( + this._iid, + function (n) { + i + ? n(i, null) + : M.get( + t._iid + ).container.apiClient.setChannelInvitationPreference( + { isAutoAccept: e }, + function (e, t) { + var i = null; + e || (i = { autoAccept: t.auto_accept }), n(e, i); + } + ); + }, + n + ) + ); + }, + }, + { + key: "getDoNotDisturb", + value: function (e) { + var n = this; + return ge( + this._iid, + function (e) { + M.get(n._iid).container.apiClient.getDoNotDisturb( + {}, + function (n, t) { + var i = null; + n || + (i = { + doNotDisturbOn: t.do_not_disturb, + startHour: t.start_hour, + startMin: t.start_min, + endHour: t.end_hour, + endMin: t.end_min, + timezone: t.timezone, + }), + e(n, i); + } + ); + }, + e + ); + }, + }, + { + key: "setDoNotDisturb", + value: function (e, n, t, i, r, a, s) { + var o = this, + l = null, + u = ie.parse(arguments, [ + new ie({ type: "boolean" }), + new ie({ + type: "number", + constraint: function (e) { + return 0 <= e && e <= 23; + }, + }), + new ie({ + type: "number", + constraint: function (e) { + return 0 <= e && e <= 59; + }, + }), + new ie({ + type: "number", + constraint: function (e) { + return 0 <= e && e <= 23; + }, + }), + new ie({ + type: "number", + constraint: function (e) { + return 0 <= e && e <= 59; + }, + }), + new ie({ type: "string" }), + new ie({ type: "callback" }), + ]), + c = A(u, 8); + return ( + (l = c[0]), + (e = c[1]), + (n = c[2]), + (t = c[3]), + (i = c[4]), + (r = c[5]), + (a = c[6]), + (s = c[7]), + ge( + this._iid, + function (s) { + l + ? s(l, null) + : M.get(o._iid).container.apiClient.setDoNotDisturb( + { + doNotDisturbOn: e, + startHour: n, + startMin: t, + endHour: i, + endMin: r, + timezone: a, + }, + function (e, n) { + var t = null; + e || + (t = { + doNotDisturbOn: n.do_not_disturb, + startHour: n.start_hour, + startMin: n.start_min, + endHour: n.end_hour, + endMin: n.end_min, + timezone: n.timezone, + }), + s(e, t); + } + ); + }, + s + ) + ); + }, + }, + { + key: "getSnoozePeriod", + value: function (e) { + var n = this; + return ge( + this._iid, + function (e) { + M.get(n._iid).container.apiClient.getSnoozePeriod( + {}, + function (n, t) { + var i = null; + n || + (i = { + isSnoozeOn: t.snooze_enabled, + startTs: t.snooze_start_ts, + endTs: t.snooze_end_ts, + }), + e(n, i); + } + ); + }, + e + ); + }, + }, + { + key: "setSnoozePeriod", + value: function (e, n, t, i) { + var r = this, + a = null, + s = ie.parse(arguments, [ + new ie({ type: "boolean" }), + new ie({ + type: "number", + constraint: function (e) { + return e > 0; + }, + }), + new ie({ + type: "number", + constraint: function (e) { + return e > 0; + }, + }), + new ie({ type: "callback" }), + ]), + o = A(s, 5); + return ( + (a = o[0]), + (e = o[1]), + (n = o[2]), + (t = o[3]), + (i = o[4]), + ge( + this._iid, + function (i) { + a + ? i(a, null) + : M.get(r._iid).container.apiClient.setSnoozePeriod( + { snoozeOn: e, startTs: n, endTs: t }, + function (e, n) { + var t = null; + e || + (t = { + isSnoozeOn: n.snooze_enabled, + startTs: n.snooze_start_ts, + endTs: n.snooze_end_ts, + }), + i(e, t); + } + ); + }, + i + ) + ); + }, + }, + { + key: "blockUser", + value: function (e, n) { + var t = null, + i = ie.parse(arguments, [ + new ie({ + type: "object", + constraint: function (e) { + return e && e.hasOwnProperty("userId"); + }, + }), + new ie({ type: "callback" }), + ]), + r = A(i, 3); + return ( + (t = r[0]), + (e = r[1]), + (n = r[2]), + t + ? ge( + this._iid, + function (e) { + e(t, null); + }, + n + ) + : this.blockUserWithUserId(e.userId, n) + ); + }, + }, + { + key: "blockUserWithUserId", + value: function (e, n) { + var t = this, + i = null, + r = ie.parse(arguments, [ + new ie({ + type: "string", + constraint: function (e) { + return ( + e && (!t.currentUser || e !== t.currentUser.userId) + ); + }, + }), + new ie({ type: "callback" }), + ]), + a = A(r, 3); + return ( + (i = a[0]), + (e = a[1]), + (n = a[2]), + ge( + this._iid, + function (n) { + i + ? n(i, null) + : M.get(t._iid).container.apiClient.blockUser( + { blockedUserId: e }, + function (e, t) { + var i = null; + e || (i = new Ee(t)), n(e, i); + } + ); + }, + n + ) + ); + }, + }, + { + key: "unblockUser", + value: function (e, n) { + var t = null, + i = ie.parse(arguments, [ + new ie({ + type: "object", + constraint: function (e) { + return e && e.hasOwnProperty("userId"); + }, + }), + new ie({ type: "callback" }), + ]), + r = A(i, 3); + return ( + (t = r[0]), + (e = r[1]), + (n = r[2]), + t + ? ge( + this._iid, + function (e) { + e(t, null); + }, + n + ) + : this.unblockUserWithUserId(e.userId, n) + ); + }, + }, + { + key: "unblockUserWithUserId", + value: function (e, n) { + var t = this, + i = null, + r = ie.parse(arguments, [ + new ie({ + type: "string", + constraint: function (e) { + return ( + e && (!t.currentUser || e !== t.currentUser.userId) + ); + }, + }), + new ie({ type: "callback" }), + ]), + a = A(r, 3); + return ( + (i = a[0]), + (e = a[1]), + (n = a[2]), + ge( + this._iid, + function (n) { + i + ? n(i, null) + : M.get(t._iid).container.apiClient.unblockUser( + { unblockedUserId: e }, + function (e, t) { + n(e, null); + } + ); + }, + n + ) + ); + }, + }, + { + key: "getPushTriggerOption", + value: function (e) { + var n = this; + return ge( + this._iid, + function (e) { + M.get(n._iid).container.apiClient.getPushTriggerOption( + {}, + function (n, t) { + e(n, t ? t.push_trigger_option : null); + } + ); + }, + e + ); + }, + }, + { + key: "setPushTriggerOption", + value: function (e, n) { + var t = this; + return ge( + this._iid, + function (n) { + Object.keys(t.PushTriggerOption) + .map(function (e) { + return t.PushTriggerOption[e]; + }) + .indexOf(e) > -1 + ? M.get(t._iid).container.apiClient.setPushTriggerOption( + { pushTriggerOption: e }, + function (e, t) { + n(e, t ? t.push_trigger_option : null); + } + ) + : n(ie.error, null); + }, + n + ); + }, + }, + { + key: "getGroupChannelCount", + value: function (e, n) { + var t = this, + i = D.get(this._iid), + r = i.GroupChannel, + a = null, + s = ie.parse(arguments, [ + new ie({ + type: r.MemberStateFilter, + optional: !0, + defaultValue: r.MemberStateFilter.ALL, + }), + new ie({ type: "callback" }), + ]), + o = A(s, 3); + return ( + (a = o[0]), + (e = o[1]), + (n = o[2]), + ge( + this._iid, + function (n) { + a + ? n(a, null) + : M.get( + t._iid + ).container.apiClient.getGroupChannelCount( + { memberStateFilter: e }, + function (e, t) { + var i = null; + e || (i = parseInt(t.group_channel_count)), + n(e, i); + } + ); + }, + n + ) + ); + }, + }, + { + key: "getTotalUnreadChannelCount", + value: function (e) { + var n = this; + return ge( + this._iid, + function (e) { + M.get( + n._iid + ).container.apiClient.getTotalUnreadChannelCount( + {}, + function (n, t) { + var i = null; + n || (i = parseInt(t.unread_count)), e(n, i); + } + ); + }, + e + ); + }, + }, + { + key: "getTotalUnreadMessageCount", + value: function (e, n) { + var t = this, + i = D.get(this._iid), + r = i.GroupChannel, + a = i.GroupChannelTotalUnreadMessageCountParams, + s = null, + o = ie.parse(arguments, [ + new ie({ + type: "object", + optional: !0, + defaultValue: null, + constraint: function (e) { + return ( + (Array.isArray(e) && + e.every(function (e) { + return "string" == typeof e; + })) || + e instanceof a + ); + }, + }), + new ie({ type: "callback" }), + ]), + l = A(o, 3); + return ( + (s = l[0]), + (e = l[1]), + (n = l[2]), + ge( + this._iid, + function (n) { + if (s) n(s, null); + else { + var i = r.SuperChannelFilter.ALL; + if (e instanceof a) { + var o = e; + (e = o.channelCustomTypesFilter), + (i = o.superChannelFilter); + } + M.get( + t._iid + ).container.apiClient.getTotalUnreadMessageCount( + { customTypesFilter: e, superChannelFilter: i }, + function (e, t) { + var i = null; + e || (i = parseInt(t.unread_count)), n(e, i); + } + ); + } + }, + n + ) + ); + }, + }, + { + key: "getUnreadItemCount", + value: function (e, n) { + var t = this, + i = null, + r = ie.parse(arguments, [ + new ie({ + type: "array", + constraint: function (e) { + return ( + e.length > 0 && + e.every(function (e) { + return ( + Object.keys(De.UnreadItemKey) + .map(function (e) { + return De.UnreadItemKey[e]; + }) + .indexOf(e) > -1 + ); + }) + ); + }, + }), + new ie({ type: "callback" }), + ]), + a = A(r, 3); + return ( + (i = a[0]), + (e = a[1]), + (n = a[2]), + ge( + this._iid, + function (n) { + if (i) n(i, null); + else { + var r = e.filter(function (n, t) { + return e.indexOf(n) === t; + }); + M.get(t._iid).container.apiClient.getUnreadItemCount( + { keys: r }, + function (e, t) { + n(e, t); + } + ); + } + }, + n + ) + ); + }, + }, + { + key: "getSubscribedTotalUnreadMessageCount", + value: function () { + var e = M.get(this._iid).container.subscribedUnreadMessageCount; + return e.all >= 0 ? e.all : 0; + }, + }, + { + key: "getSubscribedCustomTypeTotalUnreadMessageCount", + value: function () { + var e = M.get(this._iid).container.subscribedUnreadMessageCount; + if (Object.keys(e.custom_types).length > 0) { + var n = 0; + return ( + Object.keys(e.custom_types).forEach(function (t) { + n += e.custom_types[t]; + }), + n + ); + } + return 0; + }, + }, + { + key: "getSubscribedCustomTypeUnreadMessageCount", + value: function (e) { + if (e && "string" == typeof e) { + var n = M.get(this._iid).container + .subscribedUnreadMessageCount; + return n.custom_types.hasOwnProperty(e) + ? n.custom_types[e] + : 0; + } + return 0; + }, + }, + { + key: "getMyPushTokensByToken", + value: function (e, n, t) { + var i = this, + r = null, + a = ie.parse(arguments, [ + new ie({ type: "string" }), + new ie({ + type: "string", + constraint: function (e) { + return ["gcm", "apns", "apns_voip"].indexOf(e) > -1; + }, + }), + new ie({ type: "callback" }), + ]), + s = A(a, 4); + return ( + (r = s[0]), + (e = s[1]), + (n = s[2]), + (t = s[3]), + ge( + this._iid, + function (t) { + r + ? t(r, null) + : M.get(i._iid).container.apiClient.getPushTokens( + { ts: null, token: e, type: n }, + function (e, n) { + if (e) t(e, null); + else { + var i = n.type; + t(null, { + deviceTokens: n.device_tokens, + type: i ? i.toLowerCase() : "unknown", + hasMore: n.has_more, + token: n.token, + }); + } + } + ); + }, + t + ) + ); + }, + }, + { + key: "getPushTemplate", + value: function (e) { + var n = this; + return ge( + this._iid, + function (e) { + M.get(n._iid).container.apiClient.getPushTemplate( + {}, + function (n, t) { + var i = null; + n || (i = t.name.toString()), e(n, i); + } + ); + }, + e + ); + }, + }, + { + key: "setPushTemplate", + value: function (e, n) { + var t = this; + return ge( + this._iid, + function (n) { + [ + t.PUSH_TEMPLATE_DEFAULT, + t.PUSH_TEMPLATE_ALTERNATIVE, + ].indexOf(e) > -1 + ? M.get(t._iid).container.apiClient.setPushTemplate( + { templateName: e }, + function (e, t) { + var i = null; + e || (i = t.name.toString()), n(e, i); + } + ) + : n(ie.error, null); + }, + n + ); + }, + }, + { + key: "markAsReadAll", + value: function (e) { + var n = this; + return ge( + this._iid, + function (e) { + var t = D.get(n._iid).GroupChannel, + i = new Date().getTime(); + i - t.markAsReadAllLastSentAt < 1e3 + ? e( + new P( + "MarkAsRead rate limit exceeded.", + P.MARK_AS_READ_RATE_LIMIT_EXCEEDED + ), + null + ) + : ((t.markAsReadAllLastSentAt = i), + M.get(n._iid).container.apiClient.markAsReadAll( + { channelUrls: null }, + function (r, a) { + r || + Object.keys(t.cachedChannels).forEach(function ( + e + ) { + n.currentUser && + t.cachedChannels[e].updateReadReceipt( + n.currentUser.userId, + i + ), + t.cachedChannels[ + e + ]._setGroupChannelUnreadCount(0, 0); + }), + e(r, null); + } + )); + }, + e + ); + }, + }, + { + key: "markAsReadWithChannelUrls", + value: function (e, n) { + var t = this, + i = null, + r = ie.parse(arguments, [ + new ie({ + type: "array", + constraint: function (e) { + return e.every(function (e) { + return "string" == typeof e; + }); + }, + }), + new ie({ type: "callback" }), + ]), + a = A(r, 3); + return ( + (i = a[0]), + (e = a[1]), + (n = a[2]), + ge( + this._iid, + function (n) { + if (i) n(i, null); + else { + var r = new Date().getTime(); + M.get(t._iid).container.apiClient.markAsReadAll( + { channelUrls: e }, + function (i, a) { + i || + e.forEach(function (e) { + De.cachedChannels[e] && + (t.currentUser && + De.cachedChannels[e].updateReadReceipt( + t.currentUser.userId, + r + ), + De.cachedChannels[ + e + ]._setGroupChannelUnreadCount(0, 0)); + }), + n(i, null); + } + ); + } + }, + n + ) + ); + }, + }, + { + key: "markAsDelivered", + value: function (e) { + "string" == typeof e && + D.get(this._iid).GroupChannel.getChannel( + e, + N.INTERNAL_CALL, + function (e, n) { + e || n.markAsDelivered(); + } + ); + }, + }, + { + key: "getFriendChangeLogsByToken", + value: function (e, n) { + var t = this, + i = null, + r = ie.parse(arguments, [ + new ie({ + type: "string", + optional: !0, + defaultValue: null, + }), + new ie({ type: "callback" }), + ]), + a = A(r, 3); + return ( + (i = a[0]), + (e = a[1]), + (n = a[2]), + ge( + this._iid, + function (n) { + i + ? n(i, null) + : M.get( + t._iid + ).container.apiClient.getFriendChangeLogsByToken( + { token: e }, + function (e, i) { + var r = null; + if (!e) { + var a = D.get(t._iid).User; + r = { + updatedUsers: i.updated.map(function (e) { + return new a(e); + }), + deletedUserIds: i.deleted, + hasMore: i.has_more, + token: i.next, + }; + } + n(e, r); + } + ); + }, + n + ) + ); + }, + }, + { + key: "uploadFriendDiscoveries", + value: function (e, n) { + var t = this, + i = null, + r = ie.parse(arguments, [ + new ie({ + type: "array", + constraint: function (e) { + return e.every(function (e) { + return e.hasOwnProperty("friendDiscoveryKey"); + }); + }, + }), + new ie({ type: "callback" }), + ]), + a = A(r, 3); + return ( + (i = a[0]), + (e = a[1]), + (n = a[2]), + ge( + this._iid, + function (n) { + i + ? n(i, null) + : M.get( + t._iid + ).container.apiClient.uploadFriendDiscoveries( + { discoveries: e }, + function (e, t) { + n(e, t); + } + ); + }, + n + ) + ); + }, + }, + { + key: "deleteFriendDiscovery", + value: function (e, n) { + var t = null, + i = ie.parse(arguments, [ + new ie({ type: "string" }), + new ie({ type: "callback" }), + ]), + r = A(i, 3); + return ( + (t = r[0]), + (e = r[1]), + (n = r[2]), + t + ? ge( + this._iid, + function (e) { + e(t, null); + }, + n + ) + : this.deleteFriendDiscoveries([e], n) + ); + }, + }, + { + key: "deleteFriendDiscoveries", + value: function (e, n) { + var t = this, + i = null, + r = ie.parse(arguments, [ + new ie({ + type: "array", + constraint: function (e) { + return e.every(function (e) { + return "string" == typeof e; + }); + }, + }), + new ie({ type: "callback" }), + ]), + a = A(r, 3); + return ( + (i = a[0]), + (e = a[1]), + (n = a[2]), + ge( + this._iid, + function (n) { + i + ? n(i, null) + : M.get( + t._iid + ).container.apiClient.deleteFriendDiscoveries( + { discoveryKeys: e }, + function (e, t) { + n(e, t); + } + ); + }, + n + ) + ); + }, + }, + { + key: "addFriends", + value: function (e, n) { + var t = this, + i = null, + r = ie.parse(arguments, [ + new ie({ + type: "array", + constraint: function (e) { + return e.every(function (e) { + return "string" == typeof e; + }); + }, + }), + new ie({ type: "callback" }), + ]), + a = A(r, 3); + return ( + (i = a[0]), + (e = a[1]), + (n = a[2]), + ge( + this._iid, + function (n) { + i + ? n(i, null) + : M.get(t._iid).container.apiClient.addFriends( + { userIds: e }, + function (e, i) { + var r = null; + if (!e) { + var a = D.get(t._iid).User; + r = i.users.map(function (e) { + return new a(e); + }); + } + n(e, r); + } + ); + }, + n + ) + ); + }, + }, + { + key: "deleteFriend", + value: function (e, n) { + var t = null, + i = ie.parse(arguments, [ + new ie({ type: "string" }), + new ie({ type: "callback" }), + ]), + r = A(i, 3); + return ( + (t = r[0]), + (e = r[1]), + (n = r[2]), + t + ? ge( + this._iid, + function (e) { + e(t, null); + }, + n + ) + : this.deleteFriends([e], n) + ); + }, + }, + { + key: "deleteFriends", + value: function (e, n) { + var t = this, + i = null, + r = ie.parse(arguments, [ + new ie({ + type: "array", + constraint: function (e) { + return e.every(function (e) { + return "string" == typeof e; + }); + }, + }), + new ie({ type: "callback" }), + ]), + a = A(r, 3); + return ( + (i = a[0]), + (e = a[1]), + (n = a[2]), + ge( + this._iid, + function (n) { + i + ? n(i, null) + : M.get(t._iid).container.apiClient.deleteFriends( + { userIds: e }, + function (e, t) { + n(e, t); + } + ); + }, + n + ) + ); + }, + }, + { + key: "getAllEmoji", + value: function (e) { + var n = this, + t = null, + i = ie.parse(arguments, [new ie({ type: "callback" })]), + r = A(i, 2); + return ( + (t = r[0]), + (e = r[1]), + ge( + this._iid, + function (e) { + t + ? e(t, null) + : M.get(n._iid).container.apiClient.getAllEmoji( + function (t, i) { + if (t) e(t, null); + else { + var r = new (0, D.get(n._iid).EmojiContainer)( + i + ); + e(null, r); + } + } + ); + }, + e + ) + ); + }, + }, + { + key: "getEmojiCategory", + value: function (e, n) { + var t = this, + i = null, + r = ie.parse(arguments, [ + new ie({ + type: "number", + constraint: function (e) { + return e >= 0; + }, + }), + new ie({ type: "callback" }), + ]), + a = A(r, 3); + return ( + (i = a[0]), + (e = a[1]), + (n = a[2]), + ge( + this._iid, + function (n) { + i + ? n(i, null) + : M.get(t._iid).container.apiClient.getEmojiCategory( + { categoryId: e }, + function (e, i) { + if (e) n(e, null); + else { + var r = new (0, D.get(t._iid).EmojiCategory)(i); + n(null, r); + } + } + ); + }, + n + ) + ); + }, + }, + { + key: "getEmoji", + value: function (e, n) { + var t = this, + i = null, + r = ie.parse(arguments, [ + new ie({ type: "string" }), + new ie({ type: "callback" }), + ]), + a = A(r, 3); + return ( + (i = a[0]), + (e = a[1]), + (n = a[2]), + ge( + this._iid, + function (n) { + i + ? n(i, null) + : M.get(t._iid).container.apiClient.getEmoji( + { emojiKey: e }, + function (e, i) { + if (e) n(e, null); + else { + var r = new (0, D.get(t._iid).Emoji)(i); + n(null, r); + } + } + ); + }, + n + ) + ); + }, + }, + { + key: "getAllowFriendDiscovery", + value: function (e) { + var n = this, + t = null, + i = ie.parse(arguments, [new ie({ type: "callback" })]), + r = A(i, 2); + return ( + (t = r[0]), + (e = r[1]), + ge( + this._iid, + function (e) { + t + ? e(t, null) + : M.get( + n._iid + ).container.apiClient.getAllowFriendDiscovery( + function (n, t) { + var i = t.allow_friend_discovery; + n ? e(n, null) : e(null, i); + } + ); + }, + e + ) + ); + }, + }, + { + key: "setAllowFriendDiscovery", + value: function (e, n) { + var t = this, + i = null, + r = ie.parse(arguments, [ + new ie({ type: "boolean" }), + new ie({ type: "callback" }), + ]), + a = A(r, 3); + return ( + (i = a[0]), + (e = a[1]), + (n = a[2]), + ge( + this._iid, + function (n) { + i + ? n(i, null) + : M.get( + t._iid + ).container.apiClient.setAllowFriendDiscovery( + { allowFriendDiscovery: e }, + function (t, i) { + t ? n(t, null) : n(null, e); + } + ); + }, + n + ) + ); + }, + }, + ], + [ + { + key: "version", + get: function () { + return N.SDK_VERSION; + }, + }, + { + key: "LogLevel", + get: function () { + return V.supportedLogLevels; + }, + }, + { + key: "getInstance", + value: function (e) { + return e ? ht[e] : dt; + }, + }, + { + key: "getLogLevel", + value: function () { + return V.logLevel; + }, + }, + { + key: "setLogLevel", + value: function (e) { + var n = Object.values(V.supportedLogLevels); + if (n.includes(e)) V.logLevel = e; + else { + V.logLevel = V.defaultLogLevel; + var t = n + .map(function (e) { + return "'".concat(e, "'"); + }) + .join(", "); + V.warn( + "`logLevel` parameter should be one of", + "".concat(t, ","), + "not `'".concat(e, "'`."), + "Set to default log level", + "`".concat(V.defaultLogLevel, "`.") + ); + } + }, + }, + ] + ), + e + ); + })(); + return ft; +}); diff --git a/src/smart-components/Conversation/components/MessageInputWrapper.tsx b/src/smart-components/Conversation/components/MessageInputWrapper.tsx index 19031ec09..12463200c 100644 --- a/src/smart-components/Conversation/components/MessageInputWrapper.tsx +++ b/src/smart-components/Conversation/components/MessageInputWrapper.tsx @@ -1,7 +1,8 @@ // Logic required to handle message input rendering import React, { useContext } from 'react'; -import Sendbird from 'sendbird'; +// import Sendbird from 'sendbird'; +import Sendbird from '../../../sendbird.min.js'; import { RenderGroupChannelMessageInputProps } from '../../../index'; import * as utils from '../utils.js'; diff --git a/src/smart-components/MessageSearch/hooks/useGetSearchedMessages.ts b/src/smart-components/MessageSearch/hooks/useGetSearchedMessages.ts index 7a996f08f..71beef808 100644 --- a/src/smart-components/MessageSearch/hooks/useGetSearchedMessages.ts +++ b/src/smart-components/MessageSearch/hooks/useGetSearchedMessages.ts @@ -1,7 +1,8 @@ import { useEffect } from 'react'; import * as messageActionTypes from '../dux/actionTypes'; import SendbirdUIKit from '../../../index'; -import SendBird from 'sendbird'; +// import SendBird from 'sendbird'; +import SendBird from '../../../sendbird.min.js'; interface MainProps { currentChannel: SendbirdUIKit.GroupChannelType; diff --git a/src/smart-components/OpenchannelConversation/components/MessageHOC.tsx b/src/smart-components/OpenchannelConversation/components/MessageHOC.tsx index 8ba95d442..a62d4b85b 100644 --- a/src/smart-components/OpenchannelConversation/components/MessageHOC.tsx +++ b/src/smart-components/OpenchannelConversation/components/MessageHOC.tsx @@ -26,7 +26,8 @@ import { SendingMessageStatus, getMessageType, } from './types'; -import { OpenChannel } from 'sendbird'; +// import { OpenChannel } from 'sendbird'; +import { OpenChannel } from '../../../sendbird.min.js'; interface Props { message: types.EveryMessage; diff --git a/src/smart-components/OpenchannelConversation/components/MessageInpuetWrapper.tsx b/src/smart-components/OpenchannelConversation/components/MessageInpuetWrapper.tsx index 0243d9986..d636ba59a 100644 --- a/src/smart-components/OpenchannelConversation/components/MessageInpuetWrapper.tsx +++ b/src/smart-components/OpenchannelConversation/components/MessageInpuetWrapper.tsx @@ -1,5 +1,6 @@ import React, { useContext } from 'react'; -import Sendbird from 'sendbird'; +// import Sendbird from 'sendbird'; +import Sendbird from '../../../sendbird.min.js'; import { RenderOpenChannelMessageInputProps } from '../../../index'; import { LocalizationContext } from '../../../lib/LocalizationContext'; import MessageInput from '../../../ui/MessageInput'; diff --git a/src/smart-components/OpenchannelConversation/dux/initialState.ts b/src/smart-components/OpenchannelConversation/dux/initialState.ts index 80a495cca..d74635faa 100644 --- a/src/smart-components/OpenchannelConversation/dux/initialState.ts +++ b/src/smart-components/OpenchannelConversation/dux/initialState.ts @@ -1,4 +1,5 @@ -import Sendbird from 'sendbird'; +// import Sendbird from 'sendbird'; +import Sendbird from '../../../sendbird.min.js'; import { EveryMessage } from '../../../index'; export interface State { diff --git a/src/smart-components/OpenchannelConversation/hooks/useFileUploadCallback.ts b/src/smart-components/OpenchannelConversation/hooks/useFileUploadCallback.ts index 233fe24e2..18507cb03 100644 --- a/src/smart-components/OpenchannelConversation/hooks/useFileUploadCallback.ts +++ b/src/smart-components/OpenchannelConversation/hooks/useFileUploadCallback.ts @@ -1,4 +1,5 @@ -import Sendbird from 'sendbird'; +// import Sendbird from 'sendbird'; +import Sendbird from '../../../sendbird.min.js'; import { useCallback } from 'react'; import * as messageActionTypes from '../dux/actionTypes'; import * as utils from '../utils'; diff --git a/src/smart-components/OpenchannelConversation/hooks/useSendMessageCallback.ts b/src/smart-components/OpenchannelConversation/hooks/useSendMessageCallback.ts index 7ff393069..3b1483f41 100644 --- a/src/smart-components/OpenchannelConversation/hooks/useSendMessageCallback.ts +++ b/src/smart-components/OpenchannelConversation/hooks/useSendMessageCallback.ts @@ -1,4 +1,5 @@ -import Sendbird from 'sendbird'; +// import Sendbird from 'sendbird'; +import Sendbird from '../../../sendbird.min.js'; import { useCallback } from 'react'; import * as messageActionTypes from '../dux/actionTypes'; import * as utils from '../utils'; diff --git a/src/smart-components/OpenchannelConversation/hooks/useUpdateMessageCallback.ts b/src/smart-components/OpenchannelConversation/hooks/useUpdateMessageCallback.ts index c46dabd15..31dea9cc6 100644 --- a/src/smart-components/OpenchannelConversation/hooks/useUpdateMessageCallback.ts +++ b/src/smart-components/OpenchannelConversation/hooks/useUpdateMessageCallback.ts @@ -1,4 +1,5 @@ -import Sendbird from 'sendbird'; +// import Sendbird from 'sendbird'; +import Sendbird from '../../../sendbird.min.js'; import { useCallback } from 'react'; import * as messageActionTypes from '../dux/actionTypes'; diff --git a/src/smart-components/OpenchannelConversation/utils.ts b/src/smart-components/OpenchannelConversation/utils.ts index 63decefbc..7172ad1c9 100644 --- a/src/smart-components/OpenchannelConversation/utils.ts +++ b/src/smart-components/OpenchannelConversation/utils.ts @@ -1,5 +1,6 @@ import format from 'date-fns/format'; -import Sendbird from 'sendbird'; +// import Sendbird from 'sendbird'; +import Sendbird from '../../sendbird.min.js'; import SendbirdUIKit from '../../index'; export const getMessageCreatedAt = (message: SendbirdUIKit.EveryMessage): string => format(message.createdAt, 'p'); diff --git a/src/ui/EmojiReactions/index.tsx b/src/ui/EmojiReactions/index.tsx index 48721ddf8..6e2e37b48 100644 --- a/src/ui/EmojiReactions/index.tsx +++ b/src/ui/EmojiReactions/index.tsx @@ -1,5 +1,6 @@ import React, { ReactElement, useContext, useRef } from 'react'; -import { Emoji, EmojiContainer, FileMessage, Reaction, UserMessage } from 'sendbird'; +// import { Emoji, EmojiContainer, FileMessage, Reaction, UserMessage } from 'sendbird'; +import { Emoji, EmojiContainer, FileMessage, Reaction, UserMessage } from '../../sendbird.min.js'; import './index.scss'; import Tooltip from '../Tooltip'; diff --git a/src/ui/FileMessageItemBody/index.tsx b/src/ui/FileMessageItemBody/index.tsx index a4d205634..183f32c4d 100644 --- a/src/ui/FileMessageItemBody/index.tsx +++ b/src/ui/FileMessageItemBody/index.tsx @@ -1,5 +1,6 @@ import React, { ReactElement } from 'react'; -import { FileMessage } from 'sendbird'; +// import { FileMessage } from 'sendbird'; +import { FileMessage } from '../../sendbird.min.js'; import './index.scss'; import Label, { LabelTypography, LabelColors } from '../Label'; diff --git a/src/ui/MessageContent/index.tsx b/src/ui/MessageContent/index.tsx index 91931f763..f904408aa 100644 --- a/src/ui/MessageContent/index.tsx +++ b/src/ui/MessageContent/index.tsx @@ -1,5 +1,6 @@ import React, { ReactElement, useContext, useRef, useState } from 'react'; -import { GroupChannel, AdminMessage, UserMessage, FileMessage, EmojiContainer } from 'sendbird'; +// import { GroupChannel, AdminMessage, UserMessage, FileMessage, EmojiContainer } from 'sendbird'; +import { GroupChannel, AdminMessage, UserMessage, FileMessage, EmojiContainer } from '../../sendbird.min.js'; import './index.scss'; import Avatar from '../Avatar'; diff --git a/src/ui/MessageItemMenu/index.tsx b/src/ui/MessageItemMenu/index.tsx index 0f9a760f5..581798435 100644 --- a/src/ui/MessageItemMenu/index.tsx +++ b/src/ui/MessageItemMenu/index.tsx @@ -1,5 +1,6 @@ import React, { ReactElement, useContext, useRef } from 'react'; -import { FileMessage, GroupChannel, OpenChannel, UserMessage } from 'sendbird'; +// import { FileMessage, GroupChannel, OpenChannel, UserMessage } from 'sendbird'; +import { FileMessage, GroupChannel, OpenChannel, UserMessage } from '../../sendbird.min.js'; import ContextMenu, { MenuItems, MenuItem } from '../ContextMenu'; import Icon, { IconTypes, IconColors } from '../Icon'; diff --git a/src/ui/MessageItemReactionMenu/index.tsx b/src/ui/MessageItemReactionMenu/index.tsx index 828505491..3dbee1e54 100644 --- a/src/ui/MessageItemReactionMenu/index.tsx +++ b/src/ui/MessageItemReactionMenu/index.tsx @@ -1,5 +1,6 @@ import React, { ReactElement, useRef } from 'react'; -import { FileMessage, UserMessage, Emoji, Reaction, EmojiContainer } from 'sendbird'; +// import { FileMessage, UserMessage, Emoji, Reaction, EmojiContainer } from 'sendbird'; +import { FileMessage, UserMessage, Emoji, Reaction, EmojiContainer } from '../../sendbird.min.js'; import './index.scss'; import ContextMenu, { EmojiListItems } from '../ContextMenu'; diff --git a/src/ui/OGMessageItemBody/index.tsx b/src/ui/OGMessageItemBody/index.tsx index 33ce97a3f..ee0a00c26 100644 --- a/src/ui/OGMessageItemBody/index.tsx +++ b/src/ui/OGMessageItemBody/index.tsx @@ -1,5 +1,6 @@ import React, { ReactElement, useContext } from 'react'; -import { UserMessage } from 'sendbird'; +// import { UserMessage } from 'sendbird'; +import { UserMessage } from '../../sendbird.min.js'; import './index.scss'; import Label, { LabelTypography, LabelColors } from '../Label'; diff --git a/src/ui/OpenChannelMessageContent/index.tsx b/src/ui/OpenChannelMessageContent/index.tsx index c07598a8a..810972b2c 100644 --- a/src/ui/OpenChannelMessageContent/index.tsx +++ b/src/ui/OpenChannelMessageContent/index.tsx @@ -1,5 +1,6 @@ import React, { ReactElement } from 'react'; -import { OpenChannel } from 'sendbird'; +// import { OpenChannel } from 'sendbird'; +import { OpenChannel } from '../../sendbird.min.js'; import './index.scss'; interface Props { diff --git a/src/ui/OpenchannelOGMessage/utils.ts b/src/ui/OpenchannelOGMessage/utils.ts index 04c45ff49..5504c44db 100644 --- a/src/ui/OpenchannelOGMessage/utils.ts +++ b/src/ui/OpenchannelOGMessage/utils.ts @@ -1,4 +1,5 @@ -import Sendbird from 'sendbird'; +// import Sendbird from 'sendbird'; +import Sendbird from '../../sendbird.min.js'; export const URL_REG = /[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/; export const createUrlTester = (regexp: RegExp) => (text: string): boolean => regexp.test(text); diff --git a/src/ui/ReplyingMessageAttachment/ReplyingMessageThumbnail.tsx b/src/ui/ReplyingMessageAttachment/ReplyingMessageThumbnail.tsx index b30128465..820d61a8d 100644 --- a/src/ui/ReplyingMessageAttachment/ReplyingMessageThumbnail.tsx +++ b/src/ui/ReplyingMessageAttachment/ReplyingMessageThumbnail.tsx @@ -1,5 +1,6 @@ import React, { ReactElement } from 'react'; -import { FileMessage } from 'sendbird'; +// import { FileMessage } from 'sendbird'; +import { FileMessage } from '../../sendbird.min.js'; import Icon, { IconTypes, IconColors } from '../Icon'; import ImageRenderer from '../ImageRenderer'; diff --git a/src/ui/ReplyingMessageAttachment/index.tsx b/src/ui/ReplyingMessageAttachment/index.tsx index af4cba7bd..5ee3d9596 100644 --- a/src/ui/ReplyingMessageAttachment/index.tsx +++ b/src/ui/ReplyingMessageAttachment/index.tsx @@ -1,5 +1,6 @@ import React, { ReactElement, useContext } from 'react'; -import { FileMessage, UserMessage } from 'sendbird'; +// import { FileMessage, UserMessage } from 'sendbird'; +import { FileMessage, UserMessage } from '../../sendbird.min.js'; import { CoreMessageType, getClassName, diff --git a/src/ui/ReplyingMessageItemBody/index.tsx b/src/ui/ReplyingMessageItemBody/index.tsx index bdde240ba..d813f9851 100644 --- a/src/ui/ReplyingMessageItemBody/index.tsx +++ b/src/ui/ReplyingMessageItemBody/index.tsx @@ -1,5 +1,6 @@ import React, { ReactElement, useContext } from 'react'; -import { FileMessage, User, UserMessage } from 'sendbird'; +// import { FileMessage, User, UserMessage } from 'sendbird'; +import { FileMessage, User, UserMessage } from '../../sendbird.min.js'; import './index.scss'; import Icon, { IconTypes, IconColors } from '../Icon'; diff --git a/src/ui/TextMessageItemBody/index.tsx b/src/ui/TextMessageItemBody/index.tsx index 7aed648bb..331e15a77 100644 --- a/src/ui/TextMessageItemBody/index.tsx +++ b/src/ui/TextMessageItemBody/index.tsx @@ -1,5 +1,6 @@ import React, { ReactElement, useContext } from 'react'; -import { UserMessage } from 'sendbird'; +// import { UserMessage } from 'sendbird'; +import { UserMessage } from '../../sendbird.min.js'; import './index.scss'; import Label, { LabelTypography, LabelColors } from '../Label'; diff --git a/src/ui/ThumbnailMessageItemBody/index.tsx b/src/ui/ThumbnailMessageItemBody/index.tsx index 0bf0a8a72..9e88a5c53 100644 --- a/src/ui/ThumbnailMessageItemBody/index.tsx +++ b/src/ui/ThumbnailMessageItemBody/index.tsx @@ -1,5 +1,6 @@ import React, { ReactElement } from 'react'; -import { FileMessage } from 'sendbird'; +// import { FileMessage } from 'sendbird'; +import { FileMessage } from '../../sendbird.min.js'; import './index.scss'; import Icon, { IconTypes, IconColors } from '../Icon'; diff --git a/src/utils/openChannelUtils.ts b/src/utils/openChannelUtils.ts index 5effdcbad..c9865f4e6 100644 --- a/src/utils/openChannelUtils.ts +++ b/src/utils/openChannelUtils.ts @@ -1,4 +1,5 @@ -import Sendbird from 'sendbird'; +// import Sendbird from 'sendbird'; +import Sendbird from '../sendbird.min.js'; import { ClientUserMessage, ClientFileMessage } from '../index'; const OpenChannelMessageStatusTypes = { From f7b14022eff7efeaef122aeb0242437e4756b754 Mon Sep 17 00:00:00 2001 From: HoonBaek Date: Tue, 28 Sep 2021 14:22:33 +0900 Subject: [PATCH 03/42] Change name ReplyingMessage to QuoteMessage --- .../__tests__/QuoteMessage.spec.js} | 5 +- .../__snapshots__/QuoteMessage.spec.js.snap | 49 +++++++++++++++++++ .../index.scss | 30 ++++++------ .../index.tsx | 34 ++++++------- .../stories/QuoteMessage.stories.js} | 22 +++++---- 5 files changed, 95 insertions(+), 45 deletions(-) rename src/ui/{ReplyingMessageItemBody/__tests__/ReplyingMessageItemBody.spec.js => QuoteMessageItemBody/__tests__/QuoteMessage.spec.js} (88%) create mode 100644 src/ui/QuoteMessageItemBody/__tests__/__snapshots__/QuoteMessage.spec.js.snap rename src/ui/{ReplyingMessageItemBody => QuoteMessageItemBody}/index.scss (68%) rename src/ui/{ReplyingMessageItemBody => QuoteMessageItemBody}/index.tsx (70%) rename src/ui/{ReplyingMessageItemBody/stories/ReplyingMessageItemBody.stories.js => QuoteMessageItemBody/stories/QuoteMessage.stories.js} (88%) diff --git a/src/ui/ReplyingMessageItemBody/__tests__/ReplyingMessageItemBody.spec.js b/src/ui/QuoteMessageItemBody/__tests__/QuoteMessage.spec.js similarity index 88% rename from src/ui/ReplyingMessageItemBody/__tests__/ReplyingMessageItemBody.spec.js rename to src/ui/QuoteMessageItemBody/__tests__/QuoteMessage.spec.js index 5a0cb4ee9..281bf2d7a 100644 --- a/src/ui/ReplyingMessageItemBody/__tests__/ReplyingMessageItemBody.spec.js +++ b/src/ui/QuoteMessageItemBody/__tests__/QuoteMessage.spec.js @@ -1,13 +1,12 @@ import React from 'react'; // import {shallow} from 'enzyme'; import renderer from 'react-test-renderer'; - -import ReplyingMessageItemBody from "../index"; +import QuoteMessageItemBody from '../index'; describe('ReplyingMessageItemBody', () => { it('should do a snapshot test of the ReplyingMessageItemBody DOM', function() { const component = renderer.create( - `; + +exports[`ReplyingMessageItemBody should do a snapshot test of the ReplyingMessageItemBody DOM 1`] = ` +
+
+
+ +
+ + Simon replied to Gabie + +
+
+
+ + Hello nice to meet you + +
+
+
+`; diff --git a/src/ui/ReplyingMessageItemBody/index.scss b/src/ui/QuoteMessageItemBody/index.scss similarity index 68% rename from src/ui/ReplyingMessageItemBody/index.scss rename to src/ui/QuoteMessageItemBody/index.scss index b046cdef0..7e4ae86f9 100644 --- a/src/ui/ReplyingMessageItemBody/index.scss +++ b/src/ui/QuoteMessageItemBody/index.scss @@ -1,6 +1,6 @@ @import '../../styles/variables'; -.sendbird-replying-message-item-body { +.sendbird-quote-message-item-body { position: relative; display: inline-flex; box-sizing: border-box; @@ -9,19 +9,19 @@ &.outgoing { align-items: flex-end; } max-width: 400px; - .sendbird-replying-message-item-body__replied-to { + .sendbird-quote-message-item-body__replied-to { position: relative; display: inline-flex; flex-direction: row; align-items: center; height: 16px; padding: 0px 12px; - .sendbird-replying-message-item-body__replied-to__icon { + .sendbird-quote-message-item-body__replied-to__icon { position: relative; margin-bottom: 4px; margin-right: 4px; } - .sendbird-replying-message-item-body__replied-to__text { + .sendbird-quote-message-item-body__replied-to__text { position: relative; max-width: 360px; overflow: hidden; @@ -33,12 +33,12 @@ } } - .sendbird-replying-message-item-body__replied-message { + .sendbird-quote-message-item-body__replied-message { position: relative; display: inline-flex; // text message - .sendbird-replying-message-item-body__replied-message__text-message { + .sendbird-quote-message-item-body__replied-message__text-message { position: relative; white-space: pre-wrap; word-break: break-all; @@ -48,27 +48,27 @@ @include themed() { background-color: t(bg-1); } - .sendbird-replying-message-item-body__replied-message__text-message__word { + .sendbird-quote-message-item-body__replied-message__text-message__word { max-height: 32px; overflow: hidden; text-overflow: ellipsis; } } // thumbnail message - .sendbird-replying-message-item-body__replied-message__thumbnail-message { + .sendbird-quote-message-item-body__replied-message__thumbnail-message { position: relative; width: 144px; height: 108px; border-radius: 6.4px; overflow: hidden; - .sendbird-replying-message-item-body__replied-message__thumbnail-message__placeholder { + .sendbird-quote-message-item-body__replied-message__thumbnail-message__placeholder { position: absolute; display: inline-flex; width: 100%; height: 100%; justify-content: center; align-items: center; - .sendbird-replying-message-item-body__replied-message__thumbnail-message__placeholder__icon { + .sendbird-quote-message-item-body__replied-message__thumbnail-message__placeholder__icon { display: inline-flex; justify-content: center; align-items: center; @@ -78,7 +78,7 @@ background-color: var(--sendbird-light-background-50); } } - .sendbird-replying-message-item-body__replied-message__thumbnail-message__cover { + .sendbird-quote-message-item-body__replied-message__thumbnail-message__cover { position: absolute; display: inline-flex; width: 100%; @@ -87,7 +87,7 @@ align-items: center; top: 0px; background-color: rgba(256, 256, 256, 0.4); - .sendbird-replying-message-item-body__replied-message__thumbnail-message__cover__icon { + .sendbird-quote-message-item-body__replied-message__thumbnail-message__cover__icon { position: relative; display: inline-flex; justify-content: center; @@ -100,7 +100,7 @@ } } // file message - .sendbird-replying-message-item-body__replied-message__file-message { + .sendbird-quote-message-item-body__replied-message__file-message { position: relative; display: inline-flex; flex-direction: row; @@ -110,10 +110,10 @@ @include themed() { background-color: t(bg-1); } - .sendbird-replying-message-item-body__replied-message__file-message__type-icon { + .sendbird-quote-message-item-body__replied-message__file-message__type-icon { margin-right: 2px; } - .sendbird-replying-message-item-body__replied-message__file-message__file-name { + .sendbird-quote-message-item-body__replied-message__file-message__file-name { } } diff --git a/src/ui/ReplyingMessageItemBody/index.tsx b/src/ui/QuoteMessageItemBody/index.tsx similarity index 70% rename from src/ui/ReplyingMessageItemBody/index.tsx rename to src/ui/QuoteMessageItemBody/index.tsx index d813f9851..eb64054ca 100644 --- a/src/ui/ReplyingMessageItemBody/index.tsx +++ b/src/ui/QuoteMessageItemBody/index.tsx @@ -18,7 +18,7 @@ interface Props { className?: string | Array; } -export default function ReplyingMessageItemBody({ +export default function QuoteMessageItemBody({ message, parentMessageType, parentMessageText, @@ -34,29 +34,29 @@ export default function ReplyingMessageItemBody({ const splitUrl = parentMessageUrl.split('/'); return ( -
-
+
+
-
+
{/* text message */} {(!parentMessageType && parentMessageText?.length > 0) && ( -
+