forked from sendbird/SendBird-SDK-JavaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSendBird.min.js
6 lines (5 loc) · 356 KB
/
SendBird.min.js
1
2
3
4
5
6
/**
* Copyright (c) 2016 Sendbird DBA (Smile Family, Inc.)
* Sendbird JavaScript SDK v3.0.160
*/
!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})(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)})(e)}function g(e,n){return(g=Object.setPrototypeOf||function(e,n){return e.__proto__=n,e})(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}).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)})(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}})(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.160"}},{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}(),T={},R=new WeakMap,M=function(){function e(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};c(this,e),R.set(this,"object"===u(n)&&n?n:{})}return h(e,[{key:"container",get:function(){return R.get(this)}},{key:"get",value:function(e){return R.get(this)[e]}},{key:"set",value:function(e,n){R.get(this)[e]=n}},{key:"remove",value:function(e){var n=R.get(this);n.hasOwnProperty(e)&&delete n[e]}}],[{key:"create",value:function(n,t){return T[n]=new e(t),T[n]}},{key:"get",value:function(e){return e||(e=gt.getInstance()._iid),T[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 this.code===t.SESSION_KEY_EXPIRED}},{key:"isSessionTokenExpiredError",get:function(){return this.code===t.SESSION_TOKEN_EXPIRED}},{key:"isSessionTokenRevokedError",get:function(){return this.code===t.SESSION_TOKEN_REVOKED}}],[{key:"SESSION_KEY_EXPIRED",get:function(){return 400309}},{key:"SESSION_TOKEN_EXPIRED",get:function(){return 400302}},{key:"SESSION_TOKEN_REVOKED",get:function(){return 400310}},{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_REFRESH_SUCCESS",get:function(){return 800501}},{key:"SESSION_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;return 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)}}],[{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);if(h.push({level:V.supportedLogLevels.DEBUG,messages:["error:",a]}),n&&t)if(t.options&&t.options.isSessionRefresh)i(a);else{var o=M.get(s.sb._iid).container.sessionManager;o.isSessionError(a)?o.refreshSessionIfExpiredError(a).then((function(){return i(new P("Session is refreshed successfully.",P.SESSION_REFRESH_SUCCESS))})).catch((function(e){return i(new P("Session refresh failed.",P.SESSION_REFRESH_FAILED))})):i(a)}else 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.isSessionRefresh=!0,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.includeReaction,d=n.includeReactions,h=n.includeReplies,p=n.includeParentMessageText,f=n.includeThreadInfo,y=n.replyType,g=n.includeParentMessageInfo,_=n.includePollDetails;this.sb.ConnectionManager.ready((function(n,m){if(n)t(n,null);else{var v=l?e.Path.OPENCHANNELS_CHANNELURL_MESSAGES_CHANGELOGS.replace("%s",encodeURIComponent(r)):e.Path.GROUPCHANNELS_CHANNELURL_MESSAGES_CHANGELOGS.replace("%s",encodeURIComponent(r)),E=new Z;o&&E.add("token",o),a&&E.add("change_ts",a),s&&E.add("change_ts",s),"boolean"==typeof u&&E.add("with_sorted_meta_array",u),"boolean"==typeof d?E.add("include_reactions",d):E.add("include_reactions","boolean"==typeof c&&c),"boolean"==typeof f&&E.add("include_thread_info",f),"string"==typeof y?E.add("include_reply_type",y):E.add("include_reply_type","boolean"==typeof h&&h?i.cls.BaseMessage.ReplyType.ALL:i.cls.BaseMessage.ReplyType.NONE),"boolean"==typeof g?E.add("include_parent_message_info",g):E.add("include_parent_message_info","boolean"==typeof p&&p),"boolean"==typeof _&&E.add("include_poll_details",_),i.get(v,E,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.includeReaction,v=n.includeReactions,E=n.includeReplies,C=n.includeParentMessageText,b=n.includeThreadInfo,U=n.replyType,A=n.includeParentMessageInfo,I=n.showSubchannelMessagesOnly,S=n.includePollDetails,k=n.rootMessageId,O=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),N=new Z({is_sdk:String(!0),prev_limit:String(u),next_limit:String(d),include:String(o),reverse:String(h)});"timestamp"===s?N.add("message_ts",a):"messageId"===s&&N.add("message_id",String(a)),p&&N.add("message_type",String(p)),Array.isArray(y)&&(0===y.length&&("string"==typeof f?y.push(f):y.push("*")),N.add("custom_types",y)),Array.isArray(g)&&g.length>0&&N.add("sender_ids",g),"boolean"==typeof _&&N.add("with_sorted_meta_array",_),"boolean"==typeof v?N.add("include_reactions",v):N.add("include_reactions","boolean"==typeof m&&m),"boolean"==typeof b&&N.add("include_thread_info",b),"string"==typeof U?N.add("include_reply_type",U):N.add("include_reply_type","boolean"==typeof E&&E?i.cls.BaseMessage.ReplyType.ALL:i.cls.BaseMessage.ReplyType.NONE),"boolean"==typeof A?N.add("include_parent_message_info",A):N.add("include_parent_message_info","boolean"==typeof C&&C),"boolean"==typeof I&&r.isOpenChannel()&&N.add("show_subchannel_messages_only",I),"boolean"==typeof S&&N.add("include_poll_details",S),k&&N.add("root_message_id",k),O&&N.add("parent_message_id",O),i.get(c,N,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.includeParentMessageText,u=n.includeThreadInfo,c=n.includeParentMessageInfo,d=n.includePollDetails;this.sb.ConnectionManager.ready((function(n,h){if(n)t(n,null);else{var p=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)),f=new Z({is_sdk:String(!0)});"boolean"==typeof s&&f.add("with_sorted_meta_array",s),"boolean"==typeof o&&f.add("include_reactions",o),"boolean"==typeof u&&f.add("include_thread_info",u),"boolean"==typeof c?f.add("include_parent_message_info",c):f.add("include_parent_message_info","boolean"==typeof l&&l),"boolean"==typeof d&&f.add("include_poll_details",d),i.get(p,f,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,c=n.allowMultipleVotes,d=n.closeAt;this.sb.ConnectionManager.ready((function(n,h){if(n)t(n,null);else{var p=e.Path.POLLS,f=new Z({title:r,options:a});"object"===u(s)&&f.add("data",s),"boolean"==typeof o&&f.add("is_anonymous",o),"boolean"==typeof l&&f.add("allow_user_suggestion",l),"boolean"==typeof c&&f.add("allow_multiple_votes",c),"number"==typeof d&&f.add("close_at",d),i.post(p,f,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,c=n.allowUserSuggestion,d=n.allowMultipleVotes,h=n.closeAt;this.sb.ConnectionManager.ready((function(n,p){if(n)t(n,null);else{var f=e.Path.POLLS_POLLID.replace("%s",r),y=new Z;"string"==typeof a&&y.add("title",a),Array.isArray(s)&&y.add("options",s),"object"===u(o)&&y.add("data",o),"boolean"==typeof l&&y.add("is_anonymous",l),"boolean"==typeof c&&y.add("allow_user_suggestion",c),"boolean"==typeof d&&y.add("allow_multiple_votes",d),"number"==typeof h&&y.add("close_at",h),i.put(f,y,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,t.sb.reconnecting=!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.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.ackStateMap,u=r.sessionManager,c=this.cls.OpenChannel;if(this.sb.connecting=!1,this.sb.reconnecting=!0,this.sb.reconnectTimer)V.debug("Reconnect: still reconnecting.");else{if(this.reconnectCount+=1,this.reconnectCount<=1?(t&&(Object.keys(l).forEach((function(e){var n=l[e];n&&(clearTimeout(n.timer),(0,n.handler)(new P("Command received no ack.",P.ACK_TIMEOUT),null));delete l[e]})),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?u.isSessionError(t)?u.refreshSessionIfExpiredError(t).then((function(){clearTimeout(n.sb.reconnectTimer),n.sb.reconnectTimer=null,n.reconnectCount=0,n.reconnect(e,!1)})).catch((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(c.enteredChannels).forEach((function(e){c.enteredChannels[e].enter((function(t,i){if(t){var r=n.cls.FileMessageQueue;delete c.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},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(){c(this,e),this.handler=null,this.resolvers=[]}return h(e,[{key:"_refreshSessionToken",value:function(){var n=this;return new Promise((function(t,i){var r=null,a=function(){r&&(clearTimeout(r),r=null)},s=function(){r&&(a(),i(e.sessionTokenRequestFailedError))};r=setTimeout((function(){return s()}),3e4),n.handler.onSessionTokenRequired((function(e){r&&(a(),t(e))}),s)}))}},{key:"_refreshSessionKey",value:function(){var n=this;return new Promise((function(t,i){var r=M.get(n._iid).container,a=r.auth,s=r.wsAdapter;a.sessionToken?s.isConnected?n._refreshSessionKeyByCommand().then((function(){return t()})).catch((function(e){e.isSessionTokenExpiredError?i(e):n._refreshSessionKeyByApi().then((function(){return t()})).catch((function(e){return i(e)}))})):n._refreshSessionKeyByApi().then((function(){return t()})).catch((function(e){return i(e)})):i(e.sessionTokenNotFoundError)}))}},{key:"_refreshSessionKeyByCommand",value:function(){var n=this;return new Promise((function(t,i){var r=gt.getInstance(n._iid),a=M.get(n._iid).container.auth,s=D.get(n._iid).Command,o=s.bSessionRefresh({token:a.sessionToken,requestId:s.generateRequestId()});r.sendCommand(o,(function(n,s){if(!r.getErrorFirstCallback()){var o=[n,s];s=o[0],n=o[1]}n?i(n):s?s.hasOwnProperty("error")?i(e.sessionKeyRefreshFailedError):(s.hasOwnProperty("new_key")&&(a.sessionKey=s.new_key),t()):i(e.sessionKeyRefreshFailedError)}))}))}},{key:"_refreshSessionKeyByApi",value:function(){var n=this;return new Promise((function(t,i){!function r(a){if(a<3){var s=M.get(n._iid).container,o=s.auth,l=s.apiClient,u={};o.sessionToken&&(u.accessToken=o.sessionToken),l.refreshSessionKey(u,(function(e,n){if(e)e.isSessionTokenExpiredError||e.isSessionTokenRevokedError?i(e):r(a+1);else{var s=n.key;o.sessionKey=s,t()}}))}else i(e.sessionKeyRefreshFailedError)}(0)}))}},{key:"_handleSessionToken",value:function(n){var t=this;n?(M.get(this._iid).container.auth.sessionToken=n,this._refreshSessionKey().then((function(){return t._handleSessionRefreshSuccess()})).catch((function(){return t._handleSessionRefreshError(e.sessionTokenRequestFailedError)}))):this._handleSessionClosed(e.sessionTokenRequestFailedError)}},{key:"_handleSessionRefreshSuccess",value:function(){this.handler.onSessionRefreshed(),this._flushResolvers(null)}},{key:"_handleSessionRefreshError",value:function(e){this._cancelConnection(),this.handler.onSessionError(e),this._flushResolvers(e)}},{key:"_handleSessionClosed",value:function(e){this._cancelConnection(),this.handler.onSessionClosed(),this._flushResolvers(e)}},{key:"_cancelConnection",value:function(){var e=gt.getInstance(this._iid);e.reconnecting&&(Object.keys(e.connectionHandlers).forEach((function(n){e.connectionHandlers[n].onReconnectFailed()})),e.reconnecting=!1),e.disconnect()}},{key:"_flushResolvers",value:function(e){for(var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,t=0;t<this.resolvers.length;t++)e?this.resolvers[t].reject(e):this.resolvers[t].resolve(n);this.resolvers=[]}},{key:"setHandler",value:function(e){e instanceof ae&&(this.handler=e)}},{key:"isSessionError",value:function(e){return e.isSessionTokenExpiredError||e.isSessionTokenRevokedError||e.isSessionKeyExpiredError}},{key:"refreshSessionToken",value:function(){var n=this;return new Promise((function(t,i){n.handler?(n.resolvers.push({resolve:t,reject:i}),1===n.resolvers.length&&n._refreshSessionToken().then((function(e){return n._handleSessionToken(e)})).catch((function(){return n._handleSessionRefreshError(e.sessionTokenRequestFailedError)}))):t()}))}},{key:"refreshSessionKey",value:function(){var e=this;return new Promise((function(n,t){e.handler?(e.resolvers.push({resolve:n,reject:t}),1===e.resolvers.length&&e._refreshSessionKey().then((function(){return e._handleSessionRefreshSuccess()})).catch((function(n){n.isSessionTokenExpiredError?e._refreshSessionToken().then((function(n){return e._handleSessionToken(n)})).catch((function(n){return e._handleSessionRefreshError(n)})):n.isSessionTokenRevokedError?e._handleSessionClosed(n):e._handleSessionRefreshError(n)}))):n()}))}},{key:"refreshSessionIfExpiredError",value:function(e){var n=this;return e.isSessionTokenExpiredError?this.refreshSessionToken():e.isSessionKeyExpiredError?this.refreshSessionKey():e.isSessionTokenRevokedError?new Promise((function(e,t){return t(n.closeSession())})):Promise.reject(e)}},{key:"closeSession",value:function(){var n=e.sessionTokenRequestFailedError;return this._handleSessionClosed(n),n}}],[{key:"sessionTokenNotFoundError",get:function(){return new P("Session token is not found.",P.SESSION_TOKEN_EXPIRED)}},{key:"sessionTokenExpiredError",get:function(){return new P("Session token is expired.",P.SESSION_TOKEN_EXPIRED)}},{key:"sessionKeyRefreshFailedError",get:function(){return new P("Failed to refresh the session key.",P.SESSION_KEY_REFRESH_FAILED)}},{key:"sessionTokenRequestFailedError",get:function(){return new P("Failed to get the session token.",P.SESSION_TOKEN_REQUEST_FAILED)}}]),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"LOGI"===this.command||"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=gt.getInstance(this._iid),i=D.get(this._iid),r=i.User,a=i.BaseChannel,s=i.BaseMessageParams,o=i.BaseMessage,u=i.Reaction,c=i.MessageMetaArray,d=i.ThreadInfo,h=i.OGMetaData,p=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 f=e.hasOwnProperty("metaarray")?e.metaarray:{},y=e.hasOwnProperty("metaarray_key_order")?e.metaarray_key_order:Object.keys(f).sort((function(e,n){return e.localeCompare(n)}));this.metaArrays=[];for(var g=0;g<y.length;g++){var _=y[g];this.metaArrays.push(new c(_,f[_]||[]))}if(e.hasOwnProperty("sorted_metaarray")){var m=e.sorted_metaarray;Array.isArray(m)&&(this.metaArrays=m.map((function(e){return new c(e.key,e.value)})))}if(this.reactions=[],e.hasOwnProperty("reactions")&&Array.isArray(e.reactions))for(var v=0;v<e.reactions.length;v++){var E=u.createFromJson(e.reactions[v]);E&&this.reactions.push(E)}(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 d(e.thread_info),this.isReplyToChannel=!!e.hasOwnProperty("is_reply_to_channel")&&e.is_reply_to_channel,e.hasOwnProperty("parent_message_info")){var C=l({},e.parent_message_info);e.parent_message_info.hasOwnProperty("file")&&(C.require_auth=!!e.parent_message_info.file.require_auth);var b={channelType:this.channelType,channelUrl:this.channelUrl};switch(this.parentMessage=a.buildMessage(C,b),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 h(e.og_tag)),this.isOperatorMessage=!!e.hasOwnProperty("is_op_msg")&&e.is_op_msg,e.hasOwnProperty("apple_critical_alert_options")&&(this.appleCriticalAlertOptions=new p(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(gt.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,parentMessageId:a.messageId,includeThreadInfo:!0,replyType: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(gt.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,parentMessageId:a.messageId,includeThreadInfo:!0,replyType: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=this,t=D.get(this._iid),i=t.ThreadInfoUpdateEvent,r=null,a=ie.parse(arguments,[new ie({type:i,constraint:function(e){return parseInt(e.targetMessageId)===parseInt(n.messageId)}})]),s=A(a,2);return r=s[0],e=s[1],!r&&(this.threadInfo=e.threadInfo,!0)}}],[{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(gt.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(gt.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,constraint:function(e){return e._validate()}}),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,constraint:function(e){return e._validate()}}),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=gt.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=gt.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=gt.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=gt.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=gt.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=gt.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=gt.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=gt.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=gt.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=gt.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,T=g.messageSurvivalSeconds,R=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:T,silent:R,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:R,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=gt.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=gt.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=gt.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=gt.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.RestrictedUser,o=t.BaseChannel,c=t.GroupChannel,d=t.OpenChannel,h=t.UserMessage,p=t.FileMessage,f=t.AdminMessage,y=t.BaseMessageParams,g=t.ReactionEvent,_=t.ReadStatus,m=t.ThreadInfoUpdateEvent,v=t.PollUpdateEvent,E=t.PollVoteEvent,C=t.RestrictionInfo,b=M.get(this.sb._iid),U=b.container,A=U.pinger,I=U.auth,S=U.subscribedUnreadMessageCount,k=U.sessionManager,T=U.ackStateMap,R=new i(e),L=R.getJsonElement();if(L.hasOwnProperty("unread_cnt")&&"object"===u(L.unread_cnt)){var w=!1,D=L.unread_cnt.ts;"number"==typeof D&&D>S.ts&&(S.all!==L.unread_cnt.all&&(w=!0),S.all=L.unread_cnt.all>=0?L.unread_cnt.all:0,L.unread_cnt.custom_types&&Object.keys(L.unread_cnt.custom_types).forEach((function(e){S.custom_types[e]!==L.unread_cnt.custom_types[e]&&(w=!0),S.custom_types[e]=L.unread_cnt.custom_types[e]})),w=w&&S.ts>0,S.ts=D),w&&Object.keys(this.sb.userEventHandlers).forEach((function(e){n.sb.userEventHandlers[e].onTotalUnreadMessageCountUpdated(S.all,S.custom_types)}))}var H=R.requestId;if(H){var F=T[H];if(F){clearTimeout(F.timer);var G=F.handler;G&&("EROR"===R.command?G(new P(L.message,L.code),null):G(null,R)),T.hasOwnProperty(H)&&delete T[H]}}else switch(A&&"LOGI"!==R.command&&A.refreshTimer(),R.command){case"LOGI":this.sb.loginTimer&&(clearTimeout(this.sb.loginTimer),this.sb.loginTimer=null,this.sb.onLoginTimerCancel=null,L.hasOwnProperty("error")?(this.sb.isSessionOpened=!1,this.sb.loginHandler(new P(L.message,L.code),null)):(this.sb.isSessionOpened=!0,L.hasOwnProperty("key")&&(I.sessionKey=L.key),L.hasOwnProperty("ekey")&&(I.eKey=L.ekey),L.hasOwnProperty("user_id")&&(this.sb.currentUser=new r(L)),"number"==typeof L.ping_interval&&L.ping_interval>0&&b.set("pingInterval",1e3*L.ping_interval),"number"==typeof L.pong_timeout&&L.pong_timeout>0&&b.set("pongTimeout",1e3*L.pong_timeout),"number"==typeof L.login_ts&&b.set("connectedAt",1e3*L.login_ts),"number"==typeof L.max_unread_cnt_on_super_group?b.set("maxUnreadCountOfSuperGroupChannel",L.max_unread_cnt_on_super_group):b.set("maxUnreadCountOfSuperGroupChannel",N.DEFAULT_MAX_UNREAD_COUNT_OF_SUPER_GROUP_CHANNEL),L.profile_image_encryption&&b.set("profileImageEncryption",!0),A&&A.start(),L.hasOwnProperty("file_upload_size_limit")&&L.hasOwnProperty("premium_feature_list")&&L.hasOwnProperty("emoji_hash")&&b.set("appInfo",new he(L)),this.sb.loginHandler(null,this.sb.currentUser)));break;case"EXPR":var j=new P("The session would be expired.",L.reason||P.SESSION_KEY_EXPIRED);k.refreshSessionIfExpiredError(j).then((function(){})).catch((function(){}));break;case"MESG":case"FILE":case"BRDM":case"ADMM":var B=null;if("MESG"===R.command?B=new h(L):"FILE"===R.command?B=new p(L):"BRDM"!==R.command&&"ADMM"!==R.command||(B=new f(L)),B){var x=this.sb.currentUser?this.sb.currentUser.userId:null,q=B.silent,z=!!L.force_update_last_message,Q=B._sender&&B._sender.userId===x;if(B.isGroupChannel()){var Y=c.cachedChannels.hasOwnProperty(B.channelUrl);c.getChannel(B.channelUrl,N.INTERNAL_CALL,(function(e,t){if(n.sb.getErrorFirstCallback()){var r=[e,t];t=r[0],e=r[1]}if(!t){if(!b.container.appInfo.isSupergroupMackDisabled||!e.isSuper||e.isBroadcast){var a=i.bMessageAck({channelUrl:B.channelUrl,messageId:B.messageId});n.sb.sendCommand(a)}if(e.isHidden=!1,e.hiddenState=c.HiddenState.UNHIDDEN,c.cachedChannels[e.url]=e,B._sender&&e.memberMap.hasOwnProperty(B._sender.userId)){var s=e.memberMap[B._sender.userId];s.nickname!==B._sender.nickname&&(s.nickname=B._sender.nickname),s.plainProfileUrl!==B._sender.plainProfileUrl&&(s.plainProfileUrl=B._sender.plainProfileUrl),X.deepEqual(s.metaData,B._sender.metaData)||(s.metaData=B._sender.metaData),s.isBlockedByMe!==B._sender.isBlockedByMe&&(s.isBlockedByMe=B._sender.isBlockedByMe)}var o=n.sb.currentUser;o&&Q&&(o.nickname!==B._sender.nickname&&(o.nickname=B._sender.nickname),o.plainProfileUrl!==B._sender.plainProfileUrl&&(o.plainProfileUrl=B._sender.plainProfileUrl),X.deepEqual(o.metaData,B._sender.metaData)||(o.metaData=B._sender.metaData));var l=!1;if(B.mentionType===y.MentionType.CHANNEL)Q||(l=!0);else if(B.mentionType===y.MentionType.USERS)for(var u=0;u<B.mentionedUsers.length;u++)if(!Q&&B.mentionedUsers[u].userId===x){l=!0;break}q&&!Q||(e.isEphemeral||Y)&&((!e.lastMessage||e.lastMessage.createdAt<B.createdAt)&&(e.lastMessage=B),Q||e._setGroupChannelUnreadCount(e.unreadMessageCount+1,e.unreadMentionCount+(l?1:0))),z&&(!e.lastMessage||e.lastMessage.createdAt<B.createdAt)&&(e.lastMessage=B),q&&!Q||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,B),l&&i.onMentionReceived(e,B)}))}}))}else B.isOpenChannel()&&d.getChannel(B.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(B.mentionType===y.MentionType.CHANNEL)r=!0;else if(B.mentionType===y.MentionType.USERS)for(var a=0;a<B.mentionedUsers.length;a++)if(B.mentionedUsers[a].userId===x){r=!0;break}Object.keys(n.sb.channelHandlers).forEach((function(t){var i=n.sb.channelHandlers[t];d.enteredChannels[e.url]&&i.onMessageReceived(e,B),r&&i.onMentionReceived(e,B)}))}}))}break;case"MEDI":case"FEDI":case"AEDI":var K=null;if("MEDI"===R.command?K=new h(L):"FEDI"===R.command?K=new p(L):"AEDI"===R.command&&(K=new f(L)),K){var W=this.sb.currentUser?this.sb.currentUser.userId:null,J=K.silent,Z=K.sender&&K.sender.userId===W;if(K.isGroupChannel()){var $=c.cachedChannels.hasOwnProperty(K.channelUrl);c.getChannel(K.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[W],a=r&&r>=K.createAt,s=n.sb.currentUser;s&&Z&&(s.nickname!==K._sender.nickname&&(s.nickname=K._sender.nickname),s.plainProfileUrl!==K._sender.plainProfileUrl&&(s.plainProfileUrl=K._sender.plainProfileUrl),X.deepEqual(s.metaData,K._sender.metaData)||(s.metaData=K._sender.metaData));var o=!1,l=!1;if(!Z&&!a&&L&&L.hasOwnProperty("old_values")){var u=L.old_values.mention_type||K.mentionType,c=L.old_values.mentioned_user_ids||K.mentionedUsers.map((function(e){return e.userId}));if(u===y.MentionType.USERS&&K.mentionType===y.MentionType.USERS){for(var d=!1,h=!1,p=0;p<c.length;p++)if(c[p]===W){d=!0;break}for(var f=0;f<K.mentionedUsers.length;f++)if(K.mentionedUsers[f].userId===W){h=!0;break}!d&&h&&(l=!0,!J&&$&&(e._setGroupChannelUnreadCount(e.unreadMessageCount,e.unreadMentionCount+1),o=!0))}else if(u===y.MentionType.USERS&&K.mentionType===y.MentionType.CHANNEL){for(var g=!1,_=0;_<c.length;_++)if(c[_]===W){g=!0;break}g||(l=!0,!J&&$&&(e._setGroupChannelUnreadCount(e.unreadMessageCount,e.unreadMentionCount+1),o=!0))}}e.lastMessage?e.lastMessage.createdAt<K.createdAt?(e.lastMessage=K,o=!0):e.lastMessage.createdAt===K.createdAt&&e.lastMessage.messageId===K.messageId&&($?e.lastMessage.updatedAt<K.updatedAt&&(e.lastMessage=K,o=!0):o=!0):(e.lastMessage=K,o=!0),J&&!Z||!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,K),l&&i.onMentionReceived(e,K)}))}}))}else K.isOpenChannel()&&d.getChannel(K.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,K)}))}))}break;case"DELM":var ee=String(L.channel_type),ne=String(L.channel_url),te=parseInt(L.msg_id);switch(ee){case o.CHANNEL_TYPE_GROUP:c.getChannel(ne,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(R.command,"`")):Object.keys(n.sb.channelHandlers).forEach((function(t){n.sb.channelHandlers[t].onMessageDeleted(e,te)}))}));break;case o.CHANNEL_TYPE_OPEN:d.getChannel(ne,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(R.command,"`")):Object.keys(n.sb.channelHandlers).forEach((function(t){n.sb.channelHandlers[t].onMessageDeleted(e,te)}))}))}break;case"READ":var ie=new _(L),re=c.cachedChannels.hasOwnProperty(ie.channelUrl);c.getChannel(ie.channelUrl,N.INTERNAL_CALL,(function(e,t){if(n.sb.getErrorFirstCallback()){var i=[e,t];t=i[0],e=i[1]}t||(re&&e.updateReadReceipt(ie.reader.userId,ie.timestamp),n.sb.currentUser&&(ie.reader.userId===n.sb.currentUser.userId?re?(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 ae=String(L.channel_type),se=String(L.channel_url),oe=g.createFromJson(L);switch(ae){case o.CHANNEL_TYPE_GROUP:c.getChannel(se,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(R.command,"`")):Object.keys(n.sb.channelHandlers).forEach((function(t){n.sb.channelHandlers[t].onReactionUpdated(e,oe)}))}));break;case o.CHANNEL_TYPE_OPEN:d.getChannel(se,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(R.command,"`")):Object.keys(n.sb.channelHandlers).forEach((function(t){n.sb.channelHandlers[t].onReactionUpdated(e,oe)}))}))}break;case"DLVR":var le=String(L.channel_url),ue=L.hasOwnProperty("updated")?L.updated:null,ce=c.cachedChannels.hasOwnProperty(le);c.getChannel(le,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(ue).forEach((function(t){n.sb.currentUser&&t===n.sb.currentUser.userId&&(r=!0),ce&&e.updateDeliveryReceipt(t,parseInt(ue[t]))})),c.cachedChannels[e.url]=e,r&&1===Object.keys(ue).length||Object.keys(n.sb.channelHandlers).forEach((function(t){n.sb.channelHandlers[t].onDeliveryReceiptUpdated(e)}))}}));break;case"MTHD":var de=String(L.channel_url),pe=String(L.channel_type),fe=m.createFromJson(L);switch(pe){case o.CHANNEL_TYPE_GROUP:c.getChannel(de,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,fe)}))}));break;case o.CHANNEL_TYPE_OPEN:d.getChannel(de,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,fe)}))}))}break;case"MCNT":if(L.hasOwnProperty("group_channels")&&Array.isArray(L.group_channels)){var ye,ge=[],_e=O(L.group_channels);try{for(_e.s();!(ye=_e.n()).done;){var me=ye.value;if(me){me.hasOwnProperty("joined_member_count")&&me.joined_member_count,me.hasOwnProperty("member_count")&&me.member_count;var ve=c.cachedChannels[me.channel_url];if(ve&&ve.isBroadcast)ve.setLatestMemberCount(me.member_count,me.joined_member_count,me.ts)&&ge.push(ve)}}}catch(e){_e.e(e)}finally{_e.f()}ge.length>0&&Object.keys(this.sb.channelHandlers).forEach((function(e){n.sb.channelHandlers[e].onChannelMemberCountChanged(ge)}))}if(L.hasOwnProperty("open_channels")&&Array.isArray(L.open_channels)){var Ee,Ce=[],be=O(L.open_channels);try{for(be.s();!(Ee=be.n()).done;){var Ue=Ee.value;if(Ue){Ue.hasOwnProperty("participant_count")&&Ue.participant_count;var Se=d.cachedChannels[Ue.channel_url];if(Se)Se.setLatestParticipantCount(Ue.participant_count,Ue.ts)&&Ce.push(Se)}}}catch(e){be.e(e)}finally{be.f()}Ce.length>0&&Object.keys(this.sb.channelHandlers).forEach((function(e){n.sb.channelHandlers[e].onChannelParticipantCountChanged(Ce)}))}break;case"PEDI":var ke=v.createFromJson(L);Object.keys(this.sb.channelHandlers).forEach((function(e){n.sb.channelHandlers[e].onPollUpdated(ke)}));break;case"VOTE":var Oe=E.createFromJson(L);Object.keys(this.sb.channelHandlers).forEach((function(e){n.sb.channelHandlers[e].onPollVoted(Oe)}));break;case"SYEV":var Ne=new Ae(L),Te=L.ts;switch(Ne.category){case Ae.CATEGORY_CHANNEL_JOIN:case Ae.CATEGORY_CHANNEL_LEAVE:c.getChannel(Ne.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(R.command,"`"),Ne.category);else{var s=Ne.data.hasOwnProperty("member_count")?Ne.data.member_count:null,o=Ne.data.hasOwnProperty("joined_member_count")?Ne.data.joined_member_count:null,l=!1;if(Ne.category===Ae.CATEGORY_CHANNEL_JOIN){(Ne.data.hasOwnProperty("users")?Ne.data.users:[Ne.data]).forEach((function(t){e.isSuper||e.isBroadcast?l=e.setLatestMemberCount(s,o,L.ts):(t.state=a.JOINED,e.addMember(new a(t),Te),e.updateJoinedMemberCount());var i=new r(t);n.sb.currentUser&&i.userId===n.sb.currentUser.userId&&(e.myMemberState="joined",c.cachedChannels[e.url]=e),Object.keys(n.sb.channelHandlers).forEach((function(t){var r=n.sb.channelHandlers[t];r.onUserJoined(e,i),e.isBroadcast&&l&&r.onChannelMemberCountChanged([e])}))}))}else{var u=new r(Ne.data);n.sb.currentUser&&u.userId===n.sb.currentUser.userId?(e.isPublic||c.removeCachedChannel(Ne.channelUrl),e.myMemberState="none",e.invitedAt=0,e.joinedAt=0,e._setGroupChannelUnreadCount(0,0)):c.cachedChannels[e.url]=e,e.isSuper||e.isBroadcast?l=e.setLatestMemberCount(s,o,L.ts):(e.removeMember(u),e.updateJoinedMemberCount()),Object.keys(n.sb.channelHandlers).forEach((function(t){var i=n.sb.channelHandlers[t];i.onUserLeft(e,u),e.isBroadcast&&l&&i.onChannelMemberCountChanged([e])}))}}}));break;case Ae.CATEGORY_CHANNEL_OPERATOR_UPDATE:Ne.isGroupChannel()?c.getChannel(Ne.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(R.command,"`"),Ne.category);else{for(var a=Ne.data.operators.map((function(e){return new r(e)})),s=a.map((function(e){return e.userId})),o=0;o<e.members.length;o++)e.members[o].role=s.indexOf(e.members[o].userId)>=0?c.Role.OPERATOR:c.Role.NONE;e.myRole=n.sb.currentUser&&s.indexOf(n.sb.currentUser.userId)>=0?c.Role.OPERATOR:c.Role.NONE,Object.keys(n.sb.channelHandlers).forEach((function(t){n.sb.channelHandlers[t].onOperatorUpdated(e,a)}))}})):Ne.isOpenChannel()&&d.getChannel(Ne.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(R.command,"`"),Ne.category):(e.operators=Ne.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:c.getChannel(Ne.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(R.command,"`"),Ne.category);else{var s=null;Ne.data&&Ne.data.inviter&&Object.keys(Ne.data.inviter).length>0&&(s=new r(Ne.data.inviter));for(var o=[],l=0;l<Ne.data.invitees.length;l++){var u=new r(Ne.data.invitees[l]);o.push(u),Ne.data.invitees[l].state=a.INVITED;var d=new a(Ne.data.invitees[l]);if(e.isSuper||e.isBroadcast){var h=Ne.data.hasOwnProperty("member_count")?Ne.data.member_count:null,p=Ne.data.hasOwnProperty("joined_member_count")?Ne.data.joined_member_count:null;e.setLatestMemberCount(h,p,L.ts)}else e.addMember(d,Te);n.sb.currentUser&&d.userId===n.sb.currentUser.userId&&(e.isHidden=!1,"joined"!==e.myMemberState&&(e.myMemberState="invited"),e.invitedAt=L.ts,c.cachedChannels[e.url]=e)}Object.keys(n.sb.channelHandlers).forEach((function(t){n.sb.channelHandlers[t].onUserReceivedInvitation(e,s,o)}))}}));break;case Ae.CATEGORY_CHANNEL_DECLINE_INVITE:c.getChannel(Ne.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(R.command,"`"),Ne.category);else{var a=null;Ne.data&&Ne.data.inviter&&Object.keys(Ne.data.inviter).length>0&&(a=new r(Ne.data.inviter));var s=new r(Ne.data.invitee);if(n.sb.currentUser&&s.userId===n.sb.currentUser.userId&&(e.invitedAt=0,e.myMemberState="none",e.isPublic||c.removeCachedChannel(Ne.channelUrl)),e.isSuper||e.isBroadcast){var o=Ne.data.hasOwnProperty("member_count")?Ne.data.member_count:null,l=Ne.data.hasOwnProperty("joined_member_count")?Ne.data.joined_member_count:null;e.setLatestMemberCount(o,l,L.ts)}else e.removeMember(s);n.sb.currentUser&&s.userId!==n.sb.currentUser.userId&&(c.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:c.getChannel(Ne.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(R.command,"`"),Ne.category);else{var a=new r(Ne.data);Ne.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:d.getChannel(Ne.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(R.command,"`"),Ne.category);else{var a=Ne.data.hasOwnProperty("participant_count")?Ne.data.participant_count:null,s=e.setLatestParticipantCount(a,L.ts),o=new r(Ne.data);Ne.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:var Re=Ne.category===Ae.CATEGORY_USER_CHANNEL_MUTE,Me=l({},Ne.data);Re&&(Me.restriction_type=s.RestrictionType.MUTED);var Pe=Re?new s(Me):new r(Ne.data),Le=Re?"muted":"unmuted";Ne.isOpenChannel()?d.getChannel(Ne.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(R.command,"`"),Ne.category):Re?Object.keys(n.sb.channelHandlers).forEach((function(t){n.sb.channelHandlers[t].onUserMuted(e,Pe)})):Object.keys(n.sb.channelHandlers).forEach((function(t){n.sb.channelHandlers[t].onUserUnmuted(e,Pe)}))})):c.getChannel(Ne.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(R.command,"`"),Ne.category):(n.sb.currentUser&&Pe.userId===n.sb.currentUser.userId&&(e.myMutedState=Le),Array.isArray(e.members)&&e.members.filter((function(e){return e&&e.userId===Pe.userId})).forEach((function(e){e.isMuted=Re,e.restrictionInfo=new C(Me)})),Re?Object.keys(n.sb.channelHandlers).forEach((function(t){n.sb.channelHandlers[t].onUserMuted(e,Pe)})):Object.keys(n.sb.channelHandlers).forEach((function(t){n.sb.channelHandlers[t].onUserUnmuted(e,Pe)})))}));break;case Ae.CATEGORY_USER_CHANNEL_BAN:case Ae.CATEGORY_USER_CHANNEL_UNBAN:var we=Ne.category===Ae.CATEGORY_USER_CHANNEL_BAN,De=l({},Ne.data);we&&(De.restriction_type=s.RestrictionType.BANNED);var He=we?new s(De):new r(Ne.data);Ne.isOpenChannel()?d.getChannel(Ne.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(R.command,"`"),Ne.category);else if(we){if(n.sb.currentUser&&He.userId===n.sb.currentUser.userId)delete d.enteredChannels[Ne.channelUrl],n.cls.FileMessageQueue.delete(Ne.channelUrl);Object.keys(n.sb.channelHandlers).forEach((function(t){n.sb.channelHandlers[t].onUserBanned(e,He)}))}else Object.keys(n.sb.channelHandlers).forEach((function(t){n.sb.channelHandlers[t].onUserUnbanned(e,He)}))})):c.getChannel(Ne.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(R.command,"`"),Ne.category);else if(we){if(n.sb.currentUser&&He.userId===n.sb.currentUser.userId&&(e.isPublic||c.removeCachedChannel(Ne.channelUrl),e.myMemberState="none",e.invitedAt=0,e.joinedAt=0,e._setGroupChannelUnreadCount(0,0)),e.isSuper||e.isBroadcast){var r=Ne.data.hasOwnProperty("member_count")?Ne.data.member_count:null,a=Ne.data.hasOwnProperty("joined_member_count")?Ne.data.joined_member_count:null;e.setLatestMemberCount(r,a,L.ts)}else e.removeMember(He),e.updateJoinedMemberCount();Object.keys(n.sb.channelHandlers).forEach((function(t){n.sb.channelHandlers[t].onUserBanned(e,He)}))}else Object.keys(n.sb.channelHandlers).forEach((function(t){n.sb.channelHandlers[t].onUserUnbanned(e,He)}))}));break;case Ae.CATEGORY_CHANNEL_FREEZE:case Ae.CATEGORY_CHANNEL_UNFREEZE:Ne.isOpenChannel()?d.getChannel(Ne.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(R.command,"`"),Ne.category):(e.isFrozen=Ne.data.freeze,d.cachedChannels[e.url]=e,Ne.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)})))})):c.getChannel(Ne.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(R.command,"`"),Ne.category):(e.isFrozen=Ne.data.freeze,c.cachedChannels[e.url]=e,Ne.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:Ne.isGroupChannel()?c.removeCachedChannel(Ne.channelUrl):d.removeCachedChannel(Ne.channelUrl),Object.keys(this.sb.channelHandlers).forEach((function(e){n.sb.channelHandlers[e].onChannelDeleted(Ne.channelUrl,Ne.isGroupChannel()?"group":"open")}));break;case Ae.CATEGORY_CHANNEL_PROP_CHANGED:Ne.isOpenChannel()?d.getChannelWithoutCache(Ne.channelUrl,(function(e,t){if(n.sb.getErrorFirstCallback()){var i=[e,t];t=i[0],e=i[1]}t?V.debug("Discard command:","`".concat(R.command,"`"),Ne.category):Object.keys(n.sb.channelHandlers).forEach((function(t){n.sb.channelHandlers[t].onChannelChanged(e)}))})):c.getChannelWithoutCache(Ne.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(R.command,"`"),Ne.category);else{var r=e.unreadMessageCount,a=e.unreadMentionCount;e.myCountPreference!==c.CountPreference.ALL&&(e.myCountPreference===c.CountPreference.UNREAD_MESSAGE_COUNT_ONLY?a=0:e.myCountPreference===c.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 Fe=Ne.data.hasOwnProperty("created"),Ge=Ne.data.hasOwnProperty("updated"),je=Ne.data.hasOwnProperty("deleted");(Ne.isOpenChannel()?d.getChannel(Ne.channelUrl,N.INTERNAL_CALL):c.getChannel(Ne.channelUrl,N.INTERNAL_CALL)).then((function(e){var t=Ne.data.created,i=Ne.data.updated,r=Ne.data.deleted,a=L.ts;Fe&&e._addOrUpdateCachedMetaData(t,a),Ge&&e._addOrUpdateCachedMetaData(i,a),je&&e._markAsDeletedCachedMetaData(r,a),Object.keys(n.sb.channelHandlers).forEach((function(a){var s=n.sb.channelHandlers[a];Ne.category===Ae.CATEGORY_CHANNEL_META_DATA_CHANGED?(Fe&&s.onMetaDataCreated(e,t),Ge&&s.onMetaDataUpdated(e,i),je&&s.onMetaDataDeleted(e,r)):(Fe&&s.onMetaCountersCreated(e,t),Ge&&s.onMetaCountersUpdated(e,i),je&&s.onMetaCountersDeleted(e,r))}))})).catch((function(e){return V.debug("Discard command:","`".concat(R.command,"`"),Ne.category)}));break;case Ae.CATEGORY_CHANNEL_HIDE:case Ae.CATEGORY_CHANNEL_UNHIDE:c.getChannel(Ne.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(R.command,"`"),Ne.category):Ne.category===Ae.CATEGORY_CHANNEL_HIDE?(e.isHidden=!0,Ne.data&&(Ne.data.hasOwnProperty("allow_auto_unhide")&&(e.hiddenState=Ne.data.allow_auto_unhide?c.HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE:c.HiddenState.HIDDEN_PREVENT_AUTO_UNHIDE),Ne.data.hasOwnProperty("hide_previous_messages")&&Ne.data.hide_previous_messages&&e._setGroupChannelUnreadCount(0,0)),L.hasOwnProperty("ts_message_offset")&&(e._messageOffsetTimestamp=L.ts_message_offset),c.cachedChannels[e.url]=e,Object.keys(n.sb.channelHandlers).forEach((function(t){n.sb.channelHandlers[t].onChannelHidden(e)}))):(e.isHidden=!1,e.hiddenState=c.HiddenState.UNHIDDEN,c.cachedChannels[e.url]=e,Object.keys(n.sb.channelHandlers).forEach((function(t){n.sb.channelHandlers[t].onChannelChanged(e)})))}))}break;case"USEV":var Be=new Ae(L);switch(Be.category){case Ie.CATEGORY_USER_BLOCK:case Ie.CATEGORY_USER_UNBLOCK:var xe=Be.data.blocker.user_id,qe=Be.data.blockee.user_id;Object.keys(c.cachedChannels).forEach((function(e){var t=c.cachedChannels[e];try{n.sb.currentUser&&(n.sb.currentUser.userId===xe?t.memberMap[qe].isBlockedByMe=Be.category===Ie.CATEGORY_USER_BLOCK:n.sb.currentUser.userId===qe&&(t.memberMap[xe].isBlockingMe=Be.category===Ie.CATEGORY_USER_BLOCK))}catch(e){}}));break;case Ie.CATEGORY_FRIEND_DISCOVERED:var ze=Be.data.friend_discoveries.map((function(e){return new r(e)}));Object.keys(this.sb.userEventHandlers).forEach((function(e){n.sb.userEventHandlers[e].onFriendsDiscovered(ze)}))}break;case"LEAV":case"JOIN":case"PONG":case"MTIO":case"TPST":case"TPEN":break;default:V.debug("Discard command:","`".concat(R.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)this.messageQueue.map((function(e){return e.requestId})).indexOf(n.requestId)>-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=gt.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=gt.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 Te=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}(),Re={},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(e){var n=this;return ge(this._iid,(function(e){var t=D.get(n._iid).Command,i=gt.getInstance(n._iid),r=t.bRead({channelUrl:n.url});i.sendCommand(r,(function(t,r){if(i.getErrorFirstCallback()){var a=[t,r];r=a[0],t=a[1]}if(r)e(r,null);else if(i.currentUser)n.updateReadReceipt(i.currentUser.userId,t.getJsonElement().ts),(n.unreadMessageCount>0||n.unreadMentionCount>0)&&(n._setGroupChannelUnreadCount(0,0),Object.keys(i.channelHandlers).forEach((function(e){i.channelHandlers[e].onChannelChanged(n)}))),e(null,null);else{var s=new SendBirdException("Connection should be made first.",SendBirdException.CONNECTION_REQUIRED);e(s,null)}}))}),e)}},{key:"getUnreadMemberCount",value:function(e){var n=gt.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=gt.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=gt.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=gt.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=gt.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=gt.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=gt.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=gt.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=gt.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=gt.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 Re[this._iid]||(Re[this._iid]={}),Re[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(){Re[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 gt.getInstance(this._iid).getGroupChannelCount(e,n)}},{key:"getUnreadItemCount",value:function(e,n){return gt.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=gt.getInstance(this._iid);return t.getTotalUnreadMessageCount.apply(t,I(e).concat([n]))}},{key:"getTotalUnreadChannelCount",value:function(e){return gt.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,i.restrictionInfo=null,e&&i._update(e),i}return h(t,[{key:"_update",value:function(e){var n=D.get(this._iid),t=n.RestrictedUser,i=n.RestrictionInfo;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),this.isMuted&&(this.restrictionInfo=new i(e),this.restrictionInfo.restrictionType=t.RestrictionType.MUTED)}},{key:"parse",value:function(e){this._update(e)}}],[{key:"objectify",value:function(e){var n=D.get(this._iid),t=n.User,i=n.RestrictedUser,r=n.RestrictionInfo,a=e.user,s=e.state,o=e.role,l=void 0===o?"":o,u=e.isMuted,c=void 0!==u&&u,d=e.isBlockedByMe,h=void 0!==d&&d,p=e.isBlockingMe,f=void 0!==p&&p,y=e.restrictionInfo,g=void 0===y?null:y,_=c?i.objectify(a):t.objectify(a);if(_.state=s,_.role=l,_.is_muted=c,_.is_blocked_by_me=h,_.is_blocking_me=f,g){var m=r.objectify(g);_.restriction_type=m.restriction_type,_.muted_description=m.description,_.muted_end_at=m.end_at}return _}},{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(e){f(t,e);var n=b(t);function t(e){var i;return c(this,t),(i=n.call(this,e)).restrictionInfo=null,e&&i._update(e),i}return h(t,[{key:"_update",value:function(e){var n=D.get(this._iid).RestrictionInfo;this.restrictionInfo=new n(e)}}],[{key:"RestrictionType",get:function(){return{MUTED:"muted",BANNED:"banned"}}},{key:"objectify",value:function(e){var n=D.get(this._iid),t=n.User,i=n.RestrictionInfo,r=e.restrictionInfo,a=void 0===r?{}:r;return l(l({},t.objectify(e)),i.objectify(a))}}]),t}(Ee),je=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}(),Be=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}(),xe=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}(),qe={},ze={},Qe=new WeakMap,Ve=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,Qe.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=gt.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=gt.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>=Qe.get(this)&&(Qe.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 qe[this._iid]||(qe[this._iid]={}),qe[this._iid]}},{key:"enteredChannels",get:function(){return ze[this._iid]||(ze[this._iid]={}),ze[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(){qe[this._iid]={},D.get(this._iid).FileMessageQueue.clear()}},{key:"clearEnteredChannels",value:function(){ze[this._iid]={}}},{key:"createOpenChannelListQuery",value:function(){return new(0,D.get(this._iid).OpenChannelListQuery)}}]),t}(Ue),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_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=gt.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=gt.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=gt.getInstance(this._iid);return this.sendingStatus===e.MessageSendingStatus.FAILED&&X.isResendableError(this.errorCode)}}],[{key:"objectify",value:function(e){var n=gt.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,T=void 0===N?[]:N,R=e.requestedMentionUserIds,M=void 0===R?[]:R,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=T,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),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_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=gt.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=gt.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=gt.getInstance(this._iid);return this.sendingStatus===e.MessageSendingStatus.FAILED&&X.isResendableError(this.errorCode)}}],[{key:"objectify",value:function(e){var n=gt.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.AppleCriticalAlertOptions,p=e.messageId,f=e.reqId,y=void 0===f?"":f,g=e.user,_=void 0===g?{}:g,m=e.channel,v=e.plainUrl,E=e.name,C=e.type,b=e.size,U=void 0===b?0:b,A=e.data,I=void 0===A?"":A,S=e.customType,k=void 0===S?"":S,O=e.mentionType,N=void 0===O?r.MentionType.USERS:O,T=e.mentionedUsers,R=void 0===T?[]:T,M=e.mentionedUserIds,P=void 0===M?[]:M,L=e.requestedMentionUserIds,w=void 0===L?[]:L,H=e.reactions,F=void 0===H?[]:H,G=e.metaArrays,j=void 0===G?[]:G,B=e.rootMessageId,x=void 0===B?0:B,q=e.parentMessageId,z=void 0===q?0:q,Q=e.parentMessageText,V=void 0===Q?"":Q,Y=e.threadInfo,K=void 0===Y?null:Y,W=e.isReplyToChannel,J=void 0!==W&&W,X=e.parentMessage,Z=void 0===X?null:X,$=e.thumbnails,ee=void 0===$?[]:$,ne=e.requireAuth,te=void 0!==ne&&ne,ie=e.sendingStatus,re=e.errorCode,ae=void 0===re?0:re,se=e.silent,oe=void 0!==se&&se,le=e.isGlobalBlocked,ue=void 0!==le&&le,ce=e.messageSurvivalSeconds,de=void 0===ce?-1:ce,he=e.ogMetaData,pe=void 0===he?null:he,fe=e.isOperatorMessage,ye=void 0!==fe&&fe,ge=e.appleCriticalAlertOptions,_e=e.createdAt,me=e.updatedAt,ve=void 0===me?0:me,Ee={};Ee.req_id=y,Ee.msg_id=p,Ee.user=a.objectify({user:_,role:n.currentUser&&n.currentUser.userId===_.userId?m.myRole:_.role,isBlockedByMe:_.isBlockedByMe}),Ee.channel_url=m.url,Ee.channel_type=m.channelType===i.CHANNEL_TYPE_OPEN?i.CHANNEL_TYPE_OPEN:i.CHANNEL_TYPE_GROUP,Ee.url=v,Ee.name=E,Ee.type=C,Ee.size=U,Ee.custom=I,Ee.custom_type=k,Ee.thumbnails=ee,Ee.require_auth=te,Ee.is_global_block=!!ue,Ee.ts=_e,Ee.updated_at=ve,Ee.mention_type=N,Ee.mentioned_users=R.map((function(e){return s.objectify(e)})),Ee.mentioned_user_ids=P,Ee.requested_mention_user_ids=w,Ee.reactions=F.map((function(e){return e.serialize()})),Ee.metaarray={};for(var Ce=0;Ce<j.length;Ce++){var be=j[Ce].key;Ee.metaarray[be]=j[Ce].value}if(Ee.metaarray_key_order=j.map((function(e){return e.key})),Ee.root_message_id=x,Ee.parent_message_id=z,Ee.parent_message_text=V,K&&(Ee.thread_info=c.objectify(K)),Ee.is_reply_to_channel=J,Z)switch(Z.messageType){case i.MESSAGE_TYPE_USER:Ee.parent_message_info=o.objectify(Z);break;case i.MESSAGE_TYPE_FILE:Ee.parent_message_info=l.objectify(Z);break;case i.MESSAGE_TYPE_ADMIN:Ee.parent_message_info=u.objectify(Z)}return Ee.sending_status=p>0?n.MessageSendingStatus.SUCCEEDED:n.MessageSendingStatus.FAILED,ie&&(Ee.sending_status=ie),Ee.silent=!!oe,Ee.error_code=ae,Ee.message_survival_seconds=de,pe&&(Ee.og_tag=d.objectify(pe)),Ee.is_op_msg=!!ye,ge&&(Ee.apple_critical_alert_options=h.objectify(ge)),Ee}},{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,T){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:T,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),We=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,T=void 0===N?"":N,R=e.threadInfo,M=void 0===R?null:R,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=T,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),Je=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=gt.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}(),Xe=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,t.CHANNEL_TYPE_OPEN].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}(),Ze=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}(),$e=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}(),en=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}(),nn=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).RestrictedUser,s=String(i.next);n._token=s,n.hasNext=!!s,r=i.banned_list.map((function(e){var n=new a(e);return n.restrictionInfo.restrictionType=a.RestrictionType.BANNED,n}))}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.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}(),rn=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}(),an=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}(),sn=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}(),on=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).RestrictedUser,s=String(i.next);n._token=s,n.hasNext=!!s,r=i.muted_list.map((function(e){var n=new a(e);return n.restrictionInfo.restrictionType=a.RestrictionType.MUTED,n}))}n.isLoading=!1,e(t,r)}))):e(null,[]):e(ie.error,null)}),e)}}]),e}(),ln=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}(),un=new WeakMap,cn=function(){function e(n){c(this,e),this.isLoading=!1,this.hasNext=!0,this.limit=20,this._token="",un.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=un.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}(),dn=new WeakMap,hn=function(){function e(n){c(this,e),this.isLoading=!1,this.hasNext=!0,this.limit=20,this._token="",n&&dn.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:dn.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}(),pn=new WeakMap,fn=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,pn.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 pn.get(this).keyword}},{key:"limit",get:function(){return pn.get(this).limit}},{key:"reverse",get:function(){return pn.get(this).reverse}},{key:"exactMatch",get:function(){return pn.get(this).exactMatch}},{key:"channelUrl",get:function(){return pn.get(this).channelUrl}},{key:"channelCustomType",get:function(){return pn.get(this).channelCustomType}},{key:"messageTimestampFrom",get:function(){return pn.get(this).messageTimestampFrom}},{key:"messageTimestampTo",get:function(){return pn.get(this).messageTimestampTo}},{key:"order",get:function(){return pn.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=pn.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,pn.get(n).nextToken=s.end_cursor),n.isLoading=!1,e(t,o)}))):e(null,[])}),e)}}]),e}(),yn=new WeakMap,gn=new WeakMap,_n=function(){function e(n){c(this,e),this.isLoading=!1,this.hasMore=!0,this.limit=20,gn.set(this,Number.MAX_SAFE_INTEGER),yn.set(this,n),this.reverse=!1,this.messageTypeFilter=null,this.customTypeFilter=null,this.customTypesFilter=[],this.senderUserIdsFilter=[],this.includeMetaArray=!1,this.includeReaction=null,this.includeReactions=null,this.includeReplies=null,this.includeParentMessageText=null,this.includeThreadInfo=!1,this.replyType=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(("string"!=typeof r.customTypeFilter&&null!==r.customTypeFilter||!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||null!==r.includeReaction&&"boolean"!=typeof r.includeReaction||null!==r.includeReactions&&"boolean"!=typeof r.includeReactions||"boolean"!=typeof r.includeThreadInfo||null!==r.includeReplies&&"boolean"!=typeof r.includeReplies||!(null===r.replyType||"string"==typeof r.replyType&&Object.values(o.ReplyType).includes(r.replyType))||null!==r.includeParentMessageText&&"boolean"!=typeof r.includeParentMessageText||null!==r.includeParentMessageInfo&&"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=yn.get(r);M.get(r._iid).container.apiClient.getMessageList({channel:a,token:gn.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,includeReaction:r.includeReaction,includeReactions:r.includeReactions,includeReplies:r.includeReplies,includeParentMessageText:r.includeParentMessageText,includeThreadInfo:r.includeThreadInfo,replyType:r.replyType,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=gn.get(r);gn.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}(),mn=function(){function e(){c(this,e),this.isLoading=!1,this.hasNext=!0,this.limit=20,this.includeEmpty=!1,this.order=an.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}(),vn=new WeakMap,En=new WeakMap,Cn=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,vn.set(this,!1),En.set(this,!0)}return h(e,[{key:"isLoading",get:function(){return!!vn.get(this)}},{key:"hasNext",get:function(){return!!En.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?(vn.set(n,!0),M.get(n._iid).container.apiClient.getPollList(l({},n),(function(t,i){if(t)vn.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,vn.set(n,!1),En.set(n,!!s),e(null,a)}}))):e(null,[]):e(ie.error,null)}),e)}}]),e}(),bn=new WeakMap,Un=new WeakMap,An=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,bn.set(this,!1),Un.set(this,!0)}return h(e,[{key:"isLoading",get:function(){return!!bn.get(this)}},{key:"hasNext",get:function(){return!!Un.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?(bn.set(n,!0),M.get(n._iid).container.apiClient.getPollOptionVoterList(l({},n),(function(t,i){if(t)bn.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,bn.set(n,!1),Un.set(n,!!s),e(null,a)}}))):e(null,[]):e(ie.error,null)}),e)}}]),e}(),In=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}(),Sn=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}(),kn=new WeakMap,On=function(){function e(){c(this,e),this._mentionType=e.MentionType.USERS,this._mentionedUserIds=[],this._cachedMentionedUsers=[],this._cachedMentionedUserIds=[],this._metaArrays=[],kn.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=gt.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=gt.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 kn.get(this)}},{key:"parentMessageId",get:function(){return this._parentMessageId},set:function(e){kn.set(this,e),this._parentMessageId=e}},{key:"_validate",value:function(){var e=D.get(this._iid),n=e.BaseMessageParams,t=e.MessageMetaArray,i=kn.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}(),Nn=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}(On),Tn=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}(On),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}(Nn),Mn=function e(){c(this,e),this.channelCustomTypesFilter=[],this.superChannelFilter=De.SuperChannelFilter.ALL},Pn=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"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&&(null===this.includeParentMessageText||"boolean"==typeof this.includeParentMessageText)&&(null===this.includeParentMessageInfo||"boolean"==typeof this.includeParentMessageInfo)&&"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=null,this.includeReplies=null,this.includeParentMessageText=null,this.includeThreadInfo=!1,this.replyType=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"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&&(null===this.includeReaction||"boolean"==typeof this.includeReaction)&&(null===this.includeReactions||"boolean"==typeof this.includeReactions)&&"boolean"==typeof this.includeThreadInfo&&(null===this.includeReplies||"boolean"==typeof this.includeReplies)&&(null===this.replyType||"string"==typeof this.replyType&&Object.values(t.ReplyType).includes(this.replyType))&&(null===this.includeParentMessageText||"boolean"==typeof this.includeParentMessageText)&&(null===this.includeParentMessageInfo||"boolean"==typeof this.includeParentMessageInfo)&&"boolean"==typeof this.showSubchannelMessagesOnly&&"boolean"==typeof this.includePollDetails}},{key:"belongsTo",value:function(e){var n=D.get(this._iid),t=n.BaseChannel,i=n.UserMessageParams,r=n.FileMessageParams,a=n.BaseMessage;if(this.messageType!==t.MessageTypeFilter.ALL){if(e instanceof i&&this.messageType!==t.MessageTypeFilter.USER)return!1;if(e instanceof r&&this.messageType!==t.MessageTypeFilter.FILE)return!1}if(Array.isArray(this.customTypes)&&this.customTypes.length>0&&!this.customTypes.includes(e.customType))return!1;if("string"==typeof this.customType&&this.customType!==e.customType)return!1;if(Array.isArray(this.senderUserIds)&&this.senderUserIds.length>0){var s=gt.getInstance(e._iid);if(!s||!s.currentUser||!this.senderUserIds.includes(s.currentUser.userId))return!1}if("string"==typeof this.replyType&&e.parentMessageId){if(this.replyType===a.ReplyType.NONE)return!1;if(this.replyType===a.ReplyType.ONLY_REPLY_TO_CHANNEL&&!e.isReplyToChannel)return!1}else if(!1===this.includeReplies&&e.parentMessageId)return!1;return!0}}]),e}(),wn=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=null,this.includeParentMessageText=null,this.includeParentMessageInfo=null,this.includePollDetails=!1}return h(e,[{key:"_validate",value:function(){var e=D.get(this._iid).BaseChannel;return"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&&(null===this.includeReaction||"boolean"==typeof this.includeReaction)&&(null===this.includeReactions||"boolean"==typeof this.includeReactions)&&(null===this.includeParentMessageText||"boolean"==typeof this.includeParentMessageText)&&(null===this.includeParentMessageInfo||"boolean"==typeof this.includeParentMessageInfo)&&"boolean"==typeof this.includePollDetails}}]),e}(),Dn=function(){function e(){c(this,e),this.includeMetaArray=!1,this.includeReaction=null,this.includeReactions=null,this.includeReplies=null,this.includeParentMessageText=null,this.includeThreadInfo=!1,this.replyType=null,this.includeParentMessageInfo=null,this.includePollDetails=!1}return h(e,[{key:"_validate",value:function(){return"boolean"==typeof this.includeMetaArray&&(null===this.includeReaction||"boolean"==typeof this.includeReaction)&&(null===this.includeReactions||"boolean"==typeof this.includeReactions)&&"boolean"==typeof this.includeThreadInfo&&(null===this.includeReplies||"boolean"==typeof this.includeReplies)&&(null===this.replyType||"string"==typeof this.replyType&&Object.values(BaseMessage.ReplyType).includes(this.replyType))&&(null===this.includeParentMessageText||"boolean"==typeof this.includeParentMessageText)&&(null===this.includeParentMessageInfo||"boolean"==typeof this.includeParentMessageInfo)&&"boolean"==typeof this.includePollDetails}}]),e}(),Hn=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}(),Fn=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}(),Gn=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}(),jn=function e(){c(this,e),this.onReconnectStarted=function(){},this.onReconnectSucceeded=function(){},this.onReconnectFailed=function(){}},Bn=function e(){c(this,e),this.onFriendsDiscovered=function(e){},this.onTotalUnreadMessageCountUpdated=function(e,n){}},xn=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){}},qn=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}},zn=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}(),Qn=new WeakMap,Vn=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})),Qn.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=Qn.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}(),Yn=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}(),Kn=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}(),Wn=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}(),Jn=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}(),Xn=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){if(a)n(a,null);else{var i={text:e.data};M.get(t._iid).container.apiClient.updatePoll(l(l({pollId:t.id},e),{},{data:i}),(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){if(a)n(a,null);else{var i={text:e.data};M.get(t._iid).container.apiClient.createPoll(l(l({},e),{},{data:i}),(function(e,i){if(e)n(e,null);else{var r=new(0,D.get(t._iid).Poll)(i);n(null,r)}}))}}),n)}}]),e}(),Zn=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}(),$n=new WeakMap,et=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,$n.set(this,null),this._update(n)}return h(e,[{key:"lastVotedAt",get:function(){return $n.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,$n.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}(),nt=function(){function e(n){c(this,e),this.restrictionType=null,this.description=null,this.endAt=-1,n&&this._update(n)}return h(e,[{key:"_update",value:function(e){e.hasOwnProperty("restriction_type")&&(this.restrictionType=e.restriction_type),e.hasOwnProperty("description")?this.description=e.description:e.hasOwnProperty("muted_description")&&(this.description=e.muted_description),e.hasOwnProperty("end_at")?this.endAt=parseInt(e.end_at):e.hasOwnProperty("muted_end_at")&&(this.endAt=parseInt(e.muted_end_at))}}],[{key:"objectify",value:function(e){var n=e.restrictionType,t=void 0===n?null:n,i=e.description,r=void 0===i?null:i,a=e.endAt,s=void 0===a?-1:a,o={};return o.restriction_type=t,o.description=r,o.end_at=s,o}}]),e}(),tt="default",it=function(){function e(n){c(this,e),this.name=tt,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?tt:n,i=e.volume;return{name:t,volume:void 0===i?1:i}}}]),e}(),rt=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}(),at=new WeakMap,st=function(){function e(n){c(this,e),this.isLoading=!1,at.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=at.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=at.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=at.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}(),ot=0,lt=1,ut=2,ct=function(){function e(n){var t=this;c(this,e),this.state=ot,this._value=null,this._reason=null;if("function"!=typeof n)throw"Promise resolver ".concat(n," is not a function");n((function(e){t.state===ot&&(t.state=lt,t._value=e)}),(function(e){t.state===ot&&(t.state=ut,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 ot:setTimeout((function(){return i.then(n,t)}),100);break;case lt:n&&"function"==typeof n&&(r=n(this._value));break;case ut: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 ot:setTimeout((function(){return t.catch(n)}),100);break;case lt:break;case ut:i=n(this._reason)}return i instanceof e?i:this}},{key:"finally",value:function(n){var t=this,i=this;switch(this.state){case ot:setTimeout((function(){return t.finally(n)}),100);break;case lt:case ut: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}(),dt=function(){"undefined"==typeof Promise&&("undefined"!=typeof window?window.Promise=ct:"undefined"!=typeof global?global.Promise=ct:"undefined"!=typeof self?self.Promise=ct:"undefined"!=typeof globalThis&&(globalThis.Promise=ct)),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})},ht=3e5,pt=null,ft={},yt=!1,gt=function(){function e(){var n=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};c(this,e),dt();var i=!1;if((t.newInstance||!pt||pt&&t.appId!==pt.getApplicationId()&&pt.getConnectionState()===pt.ConnectionState.CLOSED)&&(i=!0,pt=this),i){try{if(!t.hasOwnProperty("appId"))return V.warn("Must be set appId."),pt=null,null}catch(e){return V.warn("Must be set appId."),pt=null,null}var r=Te.create();Object.defineProperty(this,"_iid",{get:function(){return r}}),ft[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,RestrictedUser:Ge,GroupChannel:De,OpenChannel:Ve,UserMessage:Ye,FileMessage:Ke,AdminMessage:We,GroupChannelListQuery:an,MemberListQuery:sn,GroupChannelParams:In,OpenChannelParams:Sn,BaseMessageParams:On,UserMessageParams:Nn,FileMessageParams:Tn,ScheduledUserMessageParams:Rn,GroupChannelTotalUnreadMessageCountParams:Mn,MessageRetrievalParams:Pn,MessageListParams:Ln,ThreadedMessageListParams:wn,MessageChangeLogsParams:Dn,GroupChannelChangeLogsParams:Hn,PollParams:Fn,PollRetrievalParams:Gn,MessageMetaArray:zn,UserEventHandler:Bn,SessionHandler:ae,ChannelHandler:xn,ConnectionHandler:jn,AppleCriticalAlertOptions:it,Poll:Xn,PollOption:et},s={SessionManager:se,BaseChannel:Ue,BaseMessage:ve,UserListQuery:rt,ApplicationUserListQuery:en,BannedUserListQuery:nn,BlockedUserListQuery:tn,FriendListQuery:rn,MutedUserListQuery:on,OpenChannelListQuery:ln,OperatorListQuery:cn,ParticipantListQuery:hn,MessageListQuery:st,PreviousMessageListQuery:_n,MessageSearchQuery:fn,PublicGroupChannelListQuery:mn,PollListQuery:Cn,PollVoterListQuery:An,ScheduledUserMessage:Je,ThreadInfo:Yn,ThreadInfoUpdateEvent:Xe,OGMetaData:Kn,OGImage:Wn,Plugin:Jn,Command:ue,Sender:Fe,ReadStatus:qn,Reaction:Vn,ReactionEvent:pe,Emoji:xe,EmojiCategory:Be,EmojiContainer:je,PollDetails:Zn,PollUpdateEvent:Ze,PollVoteEvent:$e,RestrictionInfo:nt,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<=ht&&(this._websocketResponseTimeout=e)},includePollDetails:!1}}return pt}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 yt}},{key:"setDebugMode",value:function(e){yt=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.setHandler(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?ft[e]:pt}},{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 gt}));